@surreal-ui/react 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +955 -7227
  3. package/dist/utils.d.ts +9 -0
  4. package/dist/utils.js +14 -0
  5. package/package.json +21 -4
  6. package/CHANGELOG.md +0 -149
  7. package/src/components/GlassmorphismAlert.tsx +0 -43
  8. package/src/components/GlassmorphismButton.tsx +0 -20
  9. package/src/components/GlassmorphismCard.tsx +0 -43
  10. package/src/components/GlassmorphismEmptyState.tsx +0 -20
  11. package/src/components/GlassmorphismInputGroup.tsx +0 -148
  12. package/src/components/GlassmorphismMenubar.tsx +0 -96
  13. package/src/components/GlassmorphismScrollArea.tsx +0 -67
  14. package/src/components/GlassmorphismTable.tsx +0 -61
  15. package/src/components/GlassmorphismTypography.tsx +0 -31
  16. package/src/components/MinimalistAccordion.tsx +0 -215
  17. package/src/components/MinimalistAlert.tsx +0 -43
  18. package/src/components/MinimalistAlertDialog.tsx +0 -318
  19. package/src/components/MinimalistAspectRatio.tsx +0 -30
  20. package/src/components/MinimalistAvatar.tsx +0 -149
  21. package/src/components/MinimalistBadge.tsx +0 -49
  22. package/src/components/MinimalistBreadcrumb.tsx +0 -109
  23. package/src/components/MinimalistButton.tsx +0 -86
  24. package/src/components/MinimalistButtonGroup.tsx +0 -86
  25. package/src/components/MinimalistCalendar.tsx +0 -355
  26. package/src/components/MinimalistCard.tsx +0 -89
  27. package/src/components/MinimalistCarousel.tsx +0 -266
  28. package/src/components/MinimalistChart.tsx +0 -296
  29. package/src/components/MinimalistCheckbox.tsx +0 -117
  30. package/src/components/MinimalistCodeBlock.tsx +0 -203
  31. package/src/components/MinimalistCollapsible.tsx +0 -134
  32. package/src/components/MinimalistCommand.tsx +0 -344
  33. package/src/components/MinimalistContextMenu.tsx +0 -408
  34. package/src/components/MinimalistDialog.tsx +0 -273
  35. package/src/components/MinimalistDrawer.tsx +0 -220
  36. package/src/components/MinimalistDropdownMenu.tsx +0 -431
  37. package/src/components/MinimalistEmpty.tsx +0 -105
  38. package/src/components/MinimalistEmptyState.tsx +0 -34
  39. package/src/components/MinimalistField.tsx +0 -275
  40. package/src/components/MinimalistForm.tsx +0 -205
  41. package/src/components/MinimalistHoverCard.tsx +0 -48
  42. package/src/components/MinimalistInput.tsx +0 -24
  43. package/src/components/MinimalistInputGroup.tsx +0 -180
  44. package/src/components/MinimalistInputOtp.tsx +0 -189
  45. package/src/components/MinimalistItem.tsx +0 -182
  46. package/src/components/MinimalistKbd.tsx +0 -46
  47. package/src/components/MinimalistLabel.tsx +0 -19
  48. package/src/components/MinimalistMenubar.tsx +0 -491
  49. package/src/components/MinimalistNativeSelect.tsx +0 -77
  50. package/src/components/MinimalistNavigationMenu.tsx +0 -198
  51. package/src/components/MinimalistPagination.tsx +0 -152
  52. package/src/components/MinimalistPopover.tsx +0 -229
  53. package/src/components/MinimalistProgress.tsx +0 -39
  54. package/src/components/MinimalistRadioGroup.tsx +0 -115
  55. package/src/components/MinimalistRangeCalendar.tsx +0 -396
  56. package/src/components/MinimalistResizable.tsx +0 -54
  57. package/src/components/MinimalistScrollArea.tsx +0 -41
  58. package/src/components/MinimalistSelect.tsx +0 -262
  59. package/src/components/MinimalistSeparator.tsx +0 -45
  60. package/src/components/MinimalistSheet.tsx +0 -247
  61. package/src/components/MinimalistSidebar.tsx +0 -638
  62. package/src/components/MinimalistSkeleton.tsx +0 -16
  63. package/src/components/MinimalistSlider.tsx +0 -213
  64. package/src/components/MinimalistSonner.tsx +0 -41
  65. package/src/components/MinimalistSpinner.tsx +0 -39
  66. package/src/components/MinimalistSwitch.tsx +0 -92
  67. package/src/components/MinimalistTable.tsx +0 -65
  68. package/src/components/MinimalistTabs.tsx +0 -171
  69. package/src/components/MinimalistTextarea.tsx +0 -24
  70. package/src/components/MinimalistToggle.tsx +0 -74
  71. package/src/components/MinimalistToggleGroup.tsx +0 -197
  72. package/src/components/MinimalistTooltip.tsx +0 -172
  73. package/src/components/MinimalistTypography.tsx +0 -33
  74. package/src/components/NeubrutalismCard.tsx +0 -84
  75. package/src/components/NeubrutalismItem.tsx +0 -48
  76. package/src/components/ShadcnAccordion.tsx +0 -215
  77. package/src/components/ShadcnAlertDialog.tsx +0 -318
  78. package/src/components/ShadcnAspectRatio.tsx +0 -30
  79. package/src/components/ShadcnAvatar.tsx +0 -149
  80. package/src/components/ShadcnBadge.tsx +0 -49
  81. package/src/components/ShadcnBreadcrumb.tsx +0 -109
  82. package/src/components/ShadcnButton.tsx +0 -86
  83. package/src/components/ShadcnButtonGroup.tsx +0 -86
  84. package/src/components/ShadcnCalendar.tsx +0 -355
  85. package/src/components/ShadcnCarousel.tsx +0 -266
  86. package/src/components/ShadcnChart.tsx +0 -296
  87. package/src/components/ShadcnCheckbox.tsx +0 -117
  88. package/src/components/ShadcnCodeBlock.tsx +0 -203
  89. package/src/components/ShadcnCollapsible.tsx +0 -134
  90. package/src/components/ShadcnCommand.tsx +0 -344
  91. package/src/components/ShadcnContextMenu.tsx +0 -408
  92. package/src/components/ShadcnDialog.tsx +0 -273
  93. package/src/components/ShadcnDrawer.tsx +0 -220
  94. package/src/components/ShadcnDropdownMenu.tsx +0 -431
  95. package/src/components/ShadcnEmpty.tsx +0 -105
  96. package/src/components/ShadcnField.tsx +0 -275
  97. package/src/components/ShadcnForm.tsx +0 -205
  98. package/src/components/ShadcnHoverCard.tsx +0 -48
  99. package/src/components/ShadcnInput.tsx +0 -24
  100. package/src/components/ShadcnInputGroup.tsx +0 -180
  101. package/src/components/ShadcnInputOtp.tsx +0 -189
  102. package/src/components/ShadcnItem.tsx +0 -182
  103. package/src/components/ShadcnKbd.tsx +0 -46
  104. package/src/components/ShadcnLabel.tsx +0 -19
  105. package/src/components/ShadcnMenubar.tsx +0 -491
  106. package/src/components/ShadcnNativeSelect.tsx +0 -77
  107. package/src/components/ShadcnNavigationMenu.tsx +0 -198
  108. package/src/components/ShadcnPagination.tsx +0 -152
  109. package/src/components/ShadcnPopover.tsx +0 -229
  110. package/src/components/ShadcnProgress.tsx +0 -39
  111. package/src/components/ShadcnRadioGroup.tsx +0 -115
  112. package/src/components/ShadcnRangeCalendar.tsx +0 -396
  113. package/src/components/ShadcnSelect.tsx +0 -262
  114. package/src/components/ShadcnSeparator.tsx +0 -45
  115. package/src/components/ShadcnSheet.tsx +0 -247
  116. package/src/components/ShadcnSidebar.tsx +0 -638
  117. package/src/components/ShadcnSkeleton.tsx +0 -16
  118. package/src/components/ShadcnSlider.tsx +0 -213
  119. package/src/components/ShadcnSonner.tsx +0 -41
  120. package/src/components/ShadcnSpinner.tsx +0 -39
  121. package/src/components/ShadcnSwitch.tsx +0 -92
  122. package/src/components/ShadcnTabs.tsx +0 -171
  123. package/src/components/ShadcnTextarea.tsx +0 -24
  124. package/src/components/ShadcnToggle.tsx +0 -74
  125. package/src/components/ShadcnToggleGroup.tsx +0 -197
  126. package/src/components/ShadcnTooltip.tsx +0 -172
  127. package/src/index.ts +0 -124
  128. package/tsconfig.json +0 -10
@@ -1,61 +0,0 @@
1
- import React from 'react';
2
- interface PropItem {
3
- name: string;
4
- type: string;
5
- default?: string;
6
- description: string;
7
- }
8
- interface TableDocsProps {
9
- title: string;
10
- docs?: { usage?: string; props?: PropItem[] };
11
- }
12
- export const GlassTable: React.FC<TableDocsProps> = ({ title, docs }) => {
13
- const usageText = (docs?.usage || "import Component from '@surreal-ui/react';").trim();
14
- return (
15
- <div className="space-y-6 backdrop-blur-md bg-white/5 border border-white/10 p-6 rounded-2xl shadow-xl">
16
- <div>
17
- <h3 className="text-sm font-semibold text-slate-200 uppercase tracking-wider mb-2">
18
- Usage Example
19
- </h3>
20
- <pre className="p-4 rounded-xl bg-black/40 border border-white/10 text-xs font-mono text-indigo-300 leading-relaxed overflow-x-auto shadow-inner">
21
- <code>{usageText}</code>
22
- </pre>
23
- </div>
24
- <div>
25
- <h3 className="text-sm font-semibold text-slate-200 uppercase tracking-wider mb-3">
26
- Props & Component Interface
27
- </h3>
28
- {docs?.props && docs.props.length > 0 ? (
29
- <div className="border border-white/10 rounded-xl overflow-hidden text-xs backdrop-blur-sm bg-black/20">
30
- <table className="w-full text-left">
31
- <thead className="bg-white/5 border-b border-white/10 text-slate-300">
32
- <tr>
33
- <th className="p-3 font-semibold">Name</th>
34
- <th className="p-3 font-semibold">Type</th>
35
- <th className="p-3 font-semibold">Default</th>
36
- <th className="p-3 font-semibold">Description</th>
37
- </tr>
38
- </thead>
39
- <tbody className="divide-y divide-white/10 text-slate-200">
40
- {docs.props.map((prop, idx) => (
41
- <tr key={idx}>
42
- <td className="p-3 font-mono font-bold text-indigo-300">{prop.name}</td>
43
- <td className="p-3 font-mono text-slate-400">{prop.type}</td>
44
- <td className="p-3 font-mono text-slate-500">{prop.default || '-'}</td>
45
- <td className="p-3">{prop.description}</td>
46
- </tr>
47
- ))}
48
- </tbody>
49
- </table>
50
- </div>
51
- ) : (
52
- <p className="text-xs text-slate-400">
53
- No prop documentation specified for this package.
54
- </p>
55
- )}
56
- </div>
57
- </div>
58
- );
59
- };
60
-
61
- export default GlassmorphismTable;
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import { Sparkles } from 'lucide-react';
3
- interface GlassmorphismTypographyProps {
4
- badgeText?: string;
5
- title?: string;
6
- description?: string;
7
- highlightText?: string;
8
- }
9
- export const GlassmorphismTypography: React.FC<GlassmorphismTypographyProps> = ({
10
- badgeText = 'AI Multi-Platform Synthesizer Studio',
11
- title = 'Ingest & Generate Component',
12
- description = "Paste your raw component code in any framework. Surreal UI's engine (powered by ",
13
- highlightText = '@pixerate/ai-core'
14
- }) => {
15
- return (
16
- <div className="space-y-2">
17
- <div className="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-pink-500/10 border border-pink-500/30 text-pink-300 text-xs font-semibold backdrop-blur-md">
18
- <Sparkles className="w-3.5 h-3.5" />
19
- <span>{badgeText}</span>
20
- </div>
21
- <h1 className="text-3xl font-extrabold text-white tracking-tight">{title}</h1>
22
- <p className="text-slate-400 text-sm">
23
- {description}
24
- <strong className="text-slate-200">{highlightText}</strong>) will synthesize React, Svelte,
25
- and WebComponent variants, extract prop docs, and tag aesthetics automatically.
26
- </p>
27
- </div>
28
- );
29
- };
30
-
31
- export default GlassmorphismTypography;
@@ -1,215 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import { ChevronDown } from 'lucide-react';
4
- import { cn } from '@surreal-ui/core';
5
-
6
- type AccordionType = 'single' | 'multiple';
7
-
8
- interface AccordionContextValue {
9
- type: AccordionType;
10
- openValues: string[];
11
- toggleItem: (value: string, disabled?: boolean) => void;
12
- disabled?: boolean;
13
- }
14
-
15
- const AccordionContext = React.createContext<AccordionContextValue | null>(null);
16
-
17
- function useAccordionContext() {
18
- const context = React.useContext(AccordionContext);
19
- if (!context) {
20
- throw new Error('Accordion subcomponents must be used within an Accordion component.');
21
- }
22
- return context;
23
- }
24
-
25
- interface AccordionItemContextValue {
26
- value: string;
27
- disabled?: boolean;
28
- }
29
-
30
- const AccordionItemContext = React.createContext<AccordionItemContextValue | null>(null);
31
-
32
- function useAccordionItemContext() {
33
- const context = React.useContext(AccordionItemContext);
34
- if (!context) {
35
- throw new Error('AccordionTrigger and AccordionContent must be used within an AccordionItem.');
36
- }
37
- return context;
38
- }
39
-
40
- export interface ShadcnAccordionProps extends React.HTMLAttributes<HTMLDivElement> {
41
- type?: AccordionType;
42
- value?: string | string[];
43
- defaultValue?: string | string[];
44
- collapsible?: boolean;
45
- disabled?: boolean;
46
- onValueChange?: (value: string | string[]) => void;
47
- }
48
-
49
- export const Root = React.forwardRef<HTMLDivElement, AccordionProps>(
50
- (
51
- {
52
- type = 'single',
53
- value: controlledValue,
54
- defaultValue,
55
- collapsible = true,
56
- disabled = false,
57
- onValueChange,
58
- className,
59
- children,
60
- ...props
61
- },
62
- ref
63
- ) => {
64
- const [uncontrolledValue, setUncontrolledValue] = React.useState<string[]>(() => {
65
- if (defaultValue !== undefined) {
66
- return Array.isArray(defaultValue) ? defaultValue : [defaultValue];
67
- }
68
- return [];
69
- });
70
-
71
- const isControlled = controlledValue !== undefined;
72
- const openValues = isControlled
73
- ? Array.isArray(controlledValue)
74
- ? controlledValue
75
- : controlledValue
76
- ? [controlledValue]
77
- : []
78
- : uncontrolledValue;
79
-
80
- const toggleItem = React.useCallback(
81
- (itemValue: string, itemDisabled?: boolean) => {
82
- if (disabled || itemDisabled) return;
83
-
84
- let nextValues: string[];
85
- const isOpen = openValues.includes(itemValue);
86
-
87
- if (type === 'single') {
88
- if (isOpen) {
89
- nextValues = collapsible ? [] : [itemValue];
90
- } else {
91
- nextValues = [itemValue];
92
- }
93
- } else {
94
- if (isOpen) {
95
- nextValues = openValues.filter((v) => v !== itemValue);
96
- } else {
97
- nextValues = [...openValues, itemValue];
98
- }
99
- }
100
-
101
- if (!isControlled) {
102
- setUncontrolledValue(nextValues);
103
- }
104
-
105
- const emitted = type === 'single' ? (nextValues[0] ?? '') : nextValues;
106
- onValueChange?.(emitted);
107
- },
108
- [disabled, openValues, type, collapsible, isControlled, onValueChange]
109
- );
110
-
111
- return (
112
- <AccordionContext.Provider value={{ type, openValues, toggleItem, disabled }}>
113
- <div ref={ref} className={cn('w-full divide-y divide-border', className)} {...props}>
114
- {children}
115
- </div>
116
- </AccordionContext.Provider>
117
- );
118
- }
119
- );
120
- Root.displayName = 'Accordion';
121
-
122
- export interface ShadcnAccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {
123
- value: string;
124
- disabled?: boolean;
125
- }
126
-
127
- export const Item = React.forwardRef<HTMLDivElement, AccordionItemProps>(
128
- ({ className, value, disabled = false, children, ...props }, ref) => {
129
- const { openValues } = useAccordionContext();
130
- const isOpen = openValues.includes(value);
131
-
132
- return (
133
- <AccordionItemContext.Provider value={{ value, disabled }}>
134
- <div
135
- ref={ref}
136
- data-state={isOpen ? 'open' : 'closed'}
137
- data-disabled={disabled ? '' : undefined}
138
- className={cn('border-b border-border last:border-b-0', className)}
139
- {...props}
140
- >
141
- {children}
142
- </div>
143
- </AccordionItemContext.Provider>
144
- );
145
- }
146
- );
147
- Item.displayName = 'AccordionItem';
148
-
149
- export interface ShadcnAccordionTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {}
150
-
151
- export const Trigger = React.forwardRef<HTMLButtonElement, AccordionTriggerProps>(
152
- ({ className, children, ...props }, ref) => {
153
- const { openValues, toggleItem, disabled: rootDisabled } = useAccordionContext();
154
- const { value, disabled: itemDisabled } = useAccordionItemContext();
155
- const isOpen = openValues.includes(value);
156
- const isDisabled = rootDisabled || itemDisabled;
157
-
158
- return (
159
- <h3 className="flex">
160
- <button
161
- ref={ref}
162
- type="button"
163
- aria-expanded={isOpen}
164
- data-state={isOpen ? 'open' : 'closed'}
165
- disabled={isDisabled}
166
- onClick={() => toggleItem(value, itemDisabled)}
167
- className={cn(
168
- 'flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left text-foreground [&[data-state=open]>svg]:rotate-180 disabled:pointer-events-none disabled:opacity-50',
169
- className
170
- )}
171
- {...props}
172
- >
173
- {children}
174
- <ChevronDown className="size-4 shrink-0 text-muted-foreground transition-transform duration-200" />
175
- </button>
176
- </h3>
177
- );
178
- }
179
- );
180
- Trigger.displayName = 'AccordionTrigger';
181
-
182
- export interface ShadcnAccordionContentProps extends React.HTMLAttributes<HTMLDivElement> {}
183
-
184
- export const Content = React.forwardRef<HTMLDivElement, AccordionContentProps>(
185
- ({ className, children, ...props }, ref) => {
186
- const { openValues } = useAccordionContext();
187
- const { value } = useAccordionItemContext();
188
- const isOpen = openValues.includes(value);
189
-
190
- return (
191
- <div
192
- ref={ref}
193
- data-state={isOpen ? 'open' : 'closed'}
194
- className={cn(
195
- 'grid transition-all duration-200 ease-out text-sm text-muted-foreground',
196
- isOpen ? 'grid-rows-[1fr] opacity-100' : 'grid-rows-[0fr] opacity-0 invisible h-0',
197
- className
198
- )}
199
- {...props}
200
- >
201
- <div className="overflow-hidden pb-4 pt-0">{children}</div>
202
- </div>
203
- );
204
- }
205
- );
206
- Content.displayName = 'AccordionContent';
207
-
208
- export {
209
- Root as ShadcnAccordion,
210
- Item as AccordionItem,
211
- Trigger as AccordionTrigger,
212
- Content as AccordionContent
213
- };
214
-
215
- export default MinimalistAccordion;
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import { CheckCircle2, ArrowRight } from 'lucide-react';
3
-
4
- interface CreatedComponent {
5
- id: string;
6
- title: string;
7
- currentVersion: string | number;
8
- }
9
-
10
- interface ModernAlertProps {
11
- successMessage?: string;
12
- createdComponent?: CreatedComponent | null;
13
- }
14
-
15
- export const ModernAlert: React.FC<ModernAlertProps> = ({
16
- successMessage = '',
17
- createdComponent = null
18
- }) => {
19
- if (!successMessage || !createdComponent) {
20
- return null;
21
- }
22
-
23
- return (
24
- <div className="p-6 bg-emerald-500/10 border border-emerald-500/30 rounded-2xl space-y-4">
25
- <div className="flex items-center gap-3 text-emerald-300 font-bold text-lg">
26
- <CheckCircle2 className="w-6 h-6" />
27
- <span>{successMessage}</span>
28
- </div>
29
- <p className="text-slate-300 text-sm">
30
- View your new component v{createdComponent.currentVersion} in the Surreal UI catalog:
31
- </p>
32
- <a
33
- href={`/components/${createdComponent.id}`}
34
- className="inline-flex items-center gap-2 px-5 py-2.5 bg-emerald-600 hover:bg-emerald-700 text-white font-semibold text-sm rounded-xl transition-colors shadow-lg shadow-emerald-500/20"
35
- >
36
- <span>Open {createdComponent.title} in Playground</span>
37
- <ArrowRight className="w-4 h-4" />
38
- </a>
39
- </div>
40
- );
41
- };
42
-
43
- export default MinimalistAlert;
@@ -1,318 +0,0 @@
1
- import * as React from 'react';
2
- import { cn, cva, type VariantProps } from '@surreal-ui/core';
3
-
4
- interface AlertDialogContextType {
5
- open: boolean;
6
- setOpen: (open: boolean) => void;
7
- }
8
-
9
- const AlertDialogContext = React.createContext<AlertDialogContextType | undefined>(undefined);
10
-
11
- function useAlertDialog() {
12
- const context = React.useContext(AlertDialogContext);
13
- if (!context) {
14
- throw new Error('AlertDialog compound components must be used within an <AlertDialog />');
15
- }
16
- return context;
17
- }
18
-
19
- export interface ShadcnAlertDialogProps {
20
- open?: boolean;
21
- defaultOpen?: boolean;
22
- onOpenChange?: (open: boolean) => void;
23
- children?: React.ReactNode;
24
- }
25
-
26
- export function ShadcnAlertDialog({
27
- open: controlledOpen,
28
- defaultOpen = false,
29
- onOpenChange,
30
- children
31
- }: AlertDialogProps) {
32
- const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
33
- const isControlled = controlledOpen !== undefined;
34
- const open = isControlled ? controlledOpen : uncontrolledOpen;
35
-
36
- const setOpen = React.useCallback(
37
- (nextOpen: boolean) => {
38
- if (!isControlled) {
39
- setUncontrolledOpen(nextOpen);
40
- }
41
- onOpenChange?.(nextOpen);
42
- },
43
- [isControlled, onOpenChange]
44
- );
45
-
46
- return (
47
- <AlertDialogContext.Provider value={{ open, setOpen }}>{children}</AlertDialogContext.Provider>
48
- );
49
- }
50
-
51
- export interface ShadcnAlertDialogTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
52
- asChild?: boolean;
53
- }
54
-
55
- export const ShadcnAlertDialogTrigger = React.forwardRef<
56
- HTMLButtonElement,
57
- AlertDialogTriggerProps
58
- >(({ onClick, children, ...props }, ref) => {
59
- const { setOpen } = useAlertDialog();
60
- return (
61
- <button
62
- ref={ref}
63
- type="button"
64
- data-slot="alert-dialog-trigger"
65
- onClick={(e) => {
66
- onClick?.(e);
67
- setOpen(true);
68
- }}
69
- {...props}
70
- >
71
- {children}
72
- </button>
73
- );
74
- });
75
- AlertDialogTrigger.displayName = 'AlertDialogTrigger';
76
-
77
- export const ShadcnAlertDialogPortal = ({ children }: { children: React.ReactNode }) => {
78
- return <>{children}</>;
79
- };
80
-
81
- export interface ShadcnAlertDialogOverlayProps extends React.HTMLAttributes<HTMLDivElement> {}
82
-
83
- export const ShadcnAlertDialogOverlay = React.forwardRef<HTMLDivElement, AlertDialogOverlayProps>(
84
- ({ className, ...props }, ref) => {
85
- return (
86
- <div
87
- ref={ref}
88
- data-slot="alert-dialog-overlay"
89
- className={cn(
90
- 'fixed inset-0 z-50 bg-black/60 backdrop-blur-xs transition-opacity animate-in fade-in-0',
91
- className
92
- )}
93
- {...props}
94
- />
95
- );
96
- }
97
- );
98
- AlertDialogOverlay.displayName = 'AlertDialogOverlay';
99
-
100
- export interface ShadcnAlertDialogContentProps extends React.HTMLAttributes<HTMLDivElement> {
101
- size?: 'default' | 'sm';
102
- }
103
-
104
- export const ShadcnAlertDialogContent = React.forwardRef<HTMLDivElement, AlertDialogContentProps>(
105
- ({ className, size = 'default', children, ...props }, ref) => {
106
- const { open, setOpen } = useAlertDialog();
107
-
108
- React.useEffect(() => {
109
- const handleKeyDown = (e: KeyboardEvent) => {
110
- if (e.key === 'Escape' && open) {
111
- setOpen(false);
112
- }
113
- };
114
- window.addEventListener('keydown', handleKeyDown);
115
- return () => window.removeEventListener('keydown', handleKeyDown);
116
- }, [open, setOpen]);
117
-
118
- if (!open) return null;
119
-
120
- return (
121
- <AlertDialogPortal>
122
- <AlertDialogOverlay onClick={() => setOpen(false)} />
123
- <div
124
- ref={ref}
125
- role="alertdialog"
126
- aria-modal="true"
127
- data-slot="alert-dialog-content"
128
- data-size={size}
129
- className={cn(
130
- 'fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 shadow-2xl duration-150 animate-in fade-in-0 zoom-in-95 outline-none',
131
- size === 'default' ? 'max-w-xs sm:max-w-sm' : 'max-w-xs',
132
- className
133
- )}
134
- {...props}
135
- >
136
- {children}
137
- </div>
138
- </AlertDialogPortal>
139
- );
140
- }
141
- );
142
- AlertDialogContent.displayName = 'AlertDialogContent';
143
-
144
- export interface ShadcnAlertDialogHeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
145
-
146
- export const ShadcnAlertDialogHeader = React.forwardRef<HTMLDivElement, AlertDialogHeaderProps>(
147
- ({ className, ...props }, ref) => (
148
- <div
149
- ref={ref}
150
- data-slot="alert-dialog-header"
151
- className={cn(
152
- 'grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:place-items-start sm:text-left sm:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]',
153
- className
154
- )}
155
- {...props}
156
- />
157
- )
158
- );
159
- AlertDialogHeader.displayName = 'AlertDialogHeader';
160
-
161
- export interface ShadcnAlertDialogMediaProps extends React.HTMLAttributes<HTMLDivElement> {}
162
-
163
- export const ShadcnAlertDialogMedia = React.forwardRef<HTMLDivElement, AlertDialogMediaProps>(
164
- ({ className, ...props }, ref) => (
165
- <div
166
- ref={ref}
167
- data-slot="alert-dialog-media"
168
- className={cn(
169
- "mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:row-span-2 *:[svg:not([class*='size-'])]:size-6",
170
- className
171
- )}
172
- {...props}
173
- />
174
- )
175
- );
176
- AlertDialogMedia.displayName = 'AlertDialogMedia';
177
-
178
- export interface ShadcnAlertDialogTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {}
179
-
180
- export const ShadcnAlertDialogTitle = React.forwardRef<HTMLHeadingElement, AlertDialogTitleProps>(
181
- ({ className, ...props }, ref) => (
182
- <h2
183
- ref={ref}
184
- data-slot="alert-dialog-title"
185
- className={cn(
186
- 'text-base font-semibold tracking-tight text-foreground sm:col-start-2',
187
- className
188
- )}
189
- {...props}
190
- />
191
- )
192
- );
193
- AlertDialogTitle.displayName = 'AlertDialogTitle';
194
-
195
- export interface ShadcnAlertDialogDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {}
196
-
197
- export const ShadcnAlertDialogDescription = React.forwardRef<
198
- HTMLParagraphElement,
199
- AlertDialogDescriptionProps
200
- >(({ className, ...props }, ref) => (
201
- <p
202
- ref={ref}
203
- data-slot="alert-dialog-description"
204
- className={cn(
205
- 'text-sm text-balance text-muted-foreground leading-relaxed md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground',
206
- className
207
- )}
208
- {...props}
209
- />
210
- ));
211
- AlertDialogDescription.displayName = 'AlertDialogDescription';
212
-
213
- export interface ShadcnAlertDialogFooterProps extends React.HTMLAttributes<HTMLDivElement> {}
214
-
215
- export const ShadcnAlertDialogFooter = React.forwardRef<HTMLDivElement, AlertDialogFooterProps>(
216
- ({ className, ...props }, ref) => (
217
- <div
218
- ref={ref}
219
- data-slot="alert-dialog-footer"
220
- className={cn(
221
- '-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t border-border bg-muted/50 p-4 sm:flex-row sm:justify-end',
222
- className
223
- )}
224
- {...props}
225
- />
226
- )
227
- );
228
- AlertDialogFooter.displayName = 'AlertDialogFooter';
229
-
230
- const buttonVariants = cva(
231
- 'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
232
- {
233
- variants: {
234
- variant: {
235
- default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
236
- destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
237
- outline:
238
- 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
239
- secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
240
- ghost: 'hover:bg-accent hover:text-accent-foreground',
241
- link: 'text-primary underline-offset-4 hover:underline'
242
- },
243
- size: {
244
- default: 'h-9 px-4 py-2',
245
- sm: 'h-8 rounded-md px-3 text-xs',
246
- lg: 'h-10 rounded-md px-8',
247
- icon: 'h-9 w-9'
248
- }
249
- },
250
- defaultVariants: {
251
- variant: 'default',
252
- size: 'default'
253
- }
254
- }
255
- );
256
-
257
- export interface ShadcnAlertDialogActionProps
258
- extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {}
259
-
260
- export const ShadcnAlertDialogAction = React.forwardRef<HTMLButtonElement, AlertDialogActionProps>(
261
- ({ className, variant = 'default', size = 'default', onClick, ...props }, ref) => {
262
- const { setOpen } = useAlertDialog();
263
- return (
264
- <button
265
- ref={ref}
266
- type="button"
267
- data-slot="alert-dialog-action"
268
- className={cn(buttonVariants({ variant, size }), className)}
269
- onClick={(e) => {
270
- onClick?.(e);
271
- setOpen(false);
272
- }}
273
- {...props}
274
- />
275
- );
276
- }
277
- );
278
- AlertDialogAction.displayName = 'AlertDialogAction';
279
-
280
- export interface ShadcnAlertDialogCancelProps
281
- extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {}
282
-
283
- export const ShadcnAlertDialogCancel = React.forwardRef<HTMLButtonElement, AlertDialogCancelProps>(
284
- ({ className, variant = 'outline', size = 'default', onClick, ...props }, ref) => {
285
- const { setOpen } = useAlertDialog();
286
- return (
287
- <button
288
- ref={ref}
289
- type="button"
290
- data-slot="alert-dialog-cancel"
291
- className={cn(buttonVariants({ variant, size }), className)}
292
- onClick={(e) => {
293
- onClick?.(e);
294
- setOpen(false);
295
- }}
296
- {...props}
297
- />
298
- );
299
- }
300
- );
301
- AlertDialogCancel.displayName = 'AlertDialogCancel';
302
-
303
- export {
304
- ShadcnAlertDialog as Root,
305
- AlertDialogTrigger as Trigger,
306
- AlertDialogContent as Content,
307
- AlertDialogHeader as Header,
308
- AlertDialogFooter as Footer,
309
- AlertDialogTitle as Title,
310
- AlertDialogDescription as Description,
311
- AlertDialogAction as Action,
312
- AlertDialogCancel as Cancel,
313
- AlertDialogMedia as Media,
314
- AlertDialogOverlay as Overlay,
315
- AlertDialogPortal as Portal
316
- };
317
-
318
- export default MinimalistAlertDialog;
@@ -1,30 +0,0 @@
1
- import * as React from 'react';
2
- import { cn } from '@surreal-ui/core';
3
-
4
- export interface ShadcnAspectRatioProps extends React.ComponentProps<'div'> {
5
- ratio?: number;
6
- }
7
-
8
- export const ShadcnAspectRatio = React.forwardRef<HTMLDivElement, AspectRatioProps>(
9
- ({ ratio = 16 / 9, style, className, children, ...props }, ref) => {
10
- return (
11
- <div
12
- ref={ref}
13
- data-slot="aspect-ratio"
14
- style={{
15
- position: 'relative',
16
- width: '100%',
17
- aspectRatio: ratio,
18
- ...style
19
- }}
20
- className={cn(className)}
21
- {...props}
22
- >
23
- {children}
24
- </div>
25
- );
26
- }
27
- );
28
- AspectRatio.displayName = 'AspectRatio';
29
-
30
- export default MinimalistAspectRatio;