@surreal-ui/react 0.8.1 → 0.9.1
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.
- package/LICENSE +21 -0
- package/dist/index.js +955 -7227
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +14 -0
- package/package.json +21 -4
- package/CHANGELOG.md +0 -149
- package/src/components/GlassmorphismAlert.tsx +0 -43
- package/src/components/GlassmorphismButton.tsx +0 -20
- package/src/components/GlassmorphismCard.tsx +0 -43
- package/src/components/GlassmorphismEmptyState.tsx +0 -20
- package/src/components/GlassmorphismInputGroup.tsx +0 -148
- package/src/components/GlassmorphismMenubar.tsx +0 -96
- package/src/components/GlassmorphismScrollArea.tsx +0 -67
- package/src/components/GlassmorphismTable.tsx +0 -61
- package/src/components/GlassmorphismTypography.tsx +0 -31
- package/src/components/MinimalistAccordion.tsx +0 -215
- package/src/components/MinimalistAlert.tsx +0 -43
- package/src/components/MinimalistAlertDialog.tsx +0 -318
- package/src/components/MinimalistAspectRatio.tsx +0 -30
- package/src/components/MinimalistAvatar.tsx +0 -149
- package/src/components/MinimalistBadge.tsx +0 -49
- package/src/components/MinimalistBreadcrumb.tsx +0 -109
- package/src/components/MinimalistButton.tsx +0 -86
- package/src/components/MinimalistButtonGroup.tsx +0 -86
- package/src/components/MinimalistCalendar.tsx +0 -355
- package/src/components/MinimalistCard.tsx +0 -89
- package/src/components/MinimalistCarousel.tsx +0 -266
- package/src/components/MinimalistChart.tsx +0 -296
- package/src/components/MinimalistCheckbox.tsx +0 -117
- package/src/components/MinimalistCodeBlock.tsx +0 -203
- package/src/components/MinimalistCollapsible.tsx +0 -134
- package/src/components/MinimalistCommand.tsx +0 -344
- package/src/components/MinimalistContextMenu.tsx +0 -408
- package/src/components/MinimalistDialog.tsx +0 -273
- package/src/components/MinimalistDrawer.tsx +0 -220
- package/src/components/MinimalistDropdownMenu.tsx +0 -431
- package/src/components/MinimalistEmpty.tsx +0 -105
- package/src/components/MinimalistEmptyState.tsx +0 -34
- package/src/components/MinimalistField.tsx +0 -275
- package/src/components/MinimalistForm.tsx +0 -205
- package/src/components/MinimalistHoverCard.tsx +0 -48
- package/src/components/MinimalistInput.tsx +0 -24
- package/src/components/MinimalistInputGroup.tsx +0 -180
- package/src/components/MinimalistInputOtp.tsx +0 -189
- package/src/components/MinimalistItem.tsx +0 -182
- package/src/components/MinimalistKbd.tsx +0 -46
- package/src/components/MinimalistLabel.tsx +0 -19
- package/src/components/MinimalistMenubar.tsx +0 -491
- package/src/components/MinimalistNativeSelect.tsx +0 -77
- package/src/components/MinimalistNavigationMenu.tsx +0 -198
- package/src/components/MinimalistPagination.tsx +0 -152
- package/src/components/MinimalistPopover.tsx +0 -229
- package/src/components/MinimalistProgress.tsx +0 -39
- package/src/components/MinimalistRadioGroup.tsx +0 -115
- package/src/components/MinimalistRangeCalendar.tsx +0 -396
- package/src/components/MinimalistResizable.tsx +0 -54
- package/src/components/MinimalistScrollArea.tsx +0 -41
- package/src/components/MinimalistSelect.tsx +0 -262
- package/src/components/MinimalistSeparator.tsx +0 -45
- package/src/components/MinimalistSheet.tsx +0 -247
- package/src/components/MinimalistSidebar.tsx +0 -638
- package/src/components/MinimalistSkeleton.tsx +0 -16
- package/src/components/MinimalistSlider.tsx +0 -213
- package/src/components/MinimalistSonner.tsx +0 -41
- package/src/components/MinimalistSpinner.tsx +0 -39
- package/src/components/MinimalistSwitch.tsx +0 -92
- package/src/components/MinimalistTable.tsx +0 -65
- package/src/components/MinimalistTabs.tsx +0 -171
- package/src/components/MinimalistTextarea.tsx +0 -24
- package/src/components/MinimalistToggle.tsx +0 -74
- package/src/components/MinimalistToggleGroup.tsx +0 -197
- package/src/components/MinimalistTooltip.tsx +0 -172
- package/src/components/MinimalistTypography.tsx +0 -33
- package/src/components/NeubrutalismCard.tsx +0 -84
- package/src/components/NeubrutalismItem.tsx +0 -48
- package/src/components/ShadcnAccordion.tsx +0 -215
- package/src/components/ShadcnAlertDialog.tsx +0 -318
- package/src/components/ShadcnAspectRatio.tsx +0 -30
- package/src/components/ShadcnAvatar.tsx +0 -149
- package/src/components/ShadcnBadge.tsx +0 -49
- package/src/components/ShadcnBreadcrumb.tsx +0 -109
- package/src/components/ShadcnButton.tsx +0 -86
- package/src/components/ShadcnButtonGroup.tsx +0 -86
- package/src/components/ShadcnCalendar.tsx +0 -355
- package/src/components/ShadcnCarousel.tsx +0 -266
- package/src/components/ShadcnChart.tsx +0 -296
- package/src/components/ShadcnCheckbox.tsx +0 -117
- package/src/components/ShadcnCodeBlock.tsx +0 -203
- package/src/components/ShadcnCollapsible.tsx +0 -134
- package/src/components/ShadcnCommand.tsx +0 -344
- package/src/components/ShadcnContextMenu.tsx +0 -408
- package/src/components/ShadcnDialog.tsx +0 -273
- package/src/components/ShadcnDrawer.tsx +0 -220
- package/src/components/ShadcnDropdownMenu.tsx +0 -431
- package/src/components/ShadcnEmpty.tsx +0 -105
- package/src/components/ShadcnField.tsx +0 -275
- package/src/components/ShadcnForm.tsx +0 -205
- package/src/components/ShadcnHoverCard.tsx +0 -48
- package/src/components/ShadcnInput.tsx +0 -24
- package/src/components/ShadcnInputGroup.tsx +0 -180
- package/src/components/ShadcnInputOtp.tsx +0 -189
- package/src/components/ShadcnItem.tsx +0 -182
- package/src/components/ShadcnKbd.tsx +0 -46
- package/src/components/ShadcnLabel.tsx +0 -19
- package/src/components/ShadcnMenubar.tsx +0 -491
- package/src/components/ShadcnNativeSelect.tsx +0 -77
- package/src/components/ShadcnNavigationMenu.tsx +0 -198
- package/src/components/ShadcnPagination.tsx +0 -152
- package/src/components/ShadcnPopover.tsx +0 -229
- package/src/components/ShadcnProgress.tsx +0 -39
- package/src/components/ShadcnRadioGroup.tsx +0 -115
- package/src/components/ShadcnRangeCalendar.tsx +0 -396
- package/src/components/ShadcnSelect.tsx +0 -262
- package/src/components/ShadcnSeparator.tsx +0 -45
- package/src/components/ShadcnSheet.tsx +0 -247
- package/src/components/ShadcnSidebar.tsx +0 -638
- package/src/components/ShadcnSkeleton.tsx +0 -16
- package/src/components/ShadcnSlider.tsx +0 -213
- package/src/components/ShadcnSonner.tsx +0 -41
- package/src/components/ShadcnSpinner.tsx +0 -39
- package/src/components/ShadcnSwitch.tsx +0 -92
- package/src/components/ShadcnTabs.tsx +0 -171
- package/src/components/ShadcnTextarea.tsx +0 -24
- package/src/components/ShadcnToggle.tsx +0 -74
- package/src/components/ShadcnToggleGroup.tsx +0 -197
- package/src/components/ShadcnTooltip.tsx +0 -172
- package/src/index.ts +0 -124
- package/tsconfig.json +0 -10
|
@@ -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 ShadcnAccordion;
|
|
@@ -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 ShadcnAlertDialog;
|
|
@@ -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 ShadcnAspectRatio;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { cn } from '@surreal-ui/core';
|
|
3
|
-
|
|
4
|
-
export interface ShadcnAvatarProps extends React.ComponentProps<'div'> {
|
|
5
|
-
size?: 'default' | 'sm' | 'lg';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const ShadcnAvatar = React.forwardRef<HTMLDivElement, AvatarProps>(
|
|
9
|
-
({ className, size = 'default', ...props }, ref) => {
|
|
10
|
-
return (
|
|
11
|
-
<div
|
|
12
|
-
ref={ref}
|
|
13
|
-
data-slot="avatar"
|
|
14
|
-
data-size={size}
|
|
15
|
-
className={cn(
|
|
16
|
-
'size-8 rounded-full after:rounded-full data-[size=lg]:size-10 data-[size=sm]:size-6 group/avatar relative flex shrink-0 select-none after:absolute after:inset-0 after:border after:border-border after:mix-blend-darken dark:after:mix-blend-lighten',
|
|
17
|
-
className
|
|
18
|
-
)}
|
|
19
|
-
{...props}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
Avatar.displayName = 'Avatar';
|
|
25
|
-
|
|
26
|
-
export interface ShadcnAvatarImageProps extends React.ComponentProps<'img'> {}
|
|
27
|
-
|
|
28
|
-
export const ShadcnAvatarImage = React.forwardRef<HTMLImageElement, AvatarImageProps>(
|
|
29
|
-
({ className, onError, onLoad, ...props }, ref) => {
|
|
30
|
-
const [hasError, setHasError] = React.useState(false);
|
|
31
|
-
const [hasLoaded, setHasLoaded] = React.useState(false);
|
|
32
|
-
|
|
33
|
-
if (hasError) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<img
|
|
39
|
-
ref={ref}
|
|
40
|
-
data-slot="avatar-image"
|
|
41
|
-
className={cn(
|
|
42
|
-
'rounded-full aspect-square size-full object-cover',
|
|
43
|
-
!hasLoaded && 'hidden',
|
|
44
|
-
className
|
|
45
|
-
)}
|
|
46
|
-
onLoad={(e) => {
|
|
47
|
-
setHasLoaded(true);
|
|
48
|
-
onLoad?.(e);
|
|
49
|
-
}}
|
|
50
|
-
onError={(e) => {
|
|
51
|
-
setHasError(true);
|
|
52
|
-
onError?.(e);
|
|
53
|
-
}}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
AvatarImage.displayName = 'AvatarImage';
|
|
60
|
-
|
|
61
|
-
export interface ShadcnAvatarFallbackProps extends React.ComponentProps<'span'> {}
|
|
62
|
-
|
|
63
|
-
export const ShadcnAvatarFallback = React.forwardRef<HTMLSpanElement, AvatarFallbackProps>(
|
|
64
|
-
({ className, ...props }, ref) => {
|
|
65
|
-
return (
|
|
66
|
-
<span
|
|
67
|
-
ref={ref}
|
|
68
|
-
data-slot="avatar-fallback"
|
|
69
|
-
className={cn(
|
|
70
|
-
'rounded-full bg-muted text-muted-foreground flex size-full items-center justify-center text-sm group-data-[size=sm]/avatar:text-xs',
|
|
71
|
-
className
|
|
72
|
-
)}
|
|
73
|
-
{...props}
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
AvatarFallback.displayName = 'AvatarFallback';
|
|
79
|
-
|
|
80
|
-
export interface ShadcnAvatarBadgeProps extends React.ComponentProps<'span'> {}
|
|
81
|
-
|
|
82
|
-
export const ShadcnAvatarBadge = React.forwardRef<HTMLSpanElement, AvatarBadgeProps>(
|
|
83
|
-
({ className, ...props }, ref) => {
|
|
84
|
-
return (
|
|
85
|
-
<span
|
|
86
|
-
ref={ref}
|
|
87
|
-
data-slot="avatar-badge"
|
|
88
|
-
className={cn(
|
|
89
|
-
'bg-primary text-primary-foreground ring-background absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-blend-color ring-2 select-none',
|
|
90
|
-
'group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden',
|
|
91
|
-
'group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2',
|
|
92
|
-
'group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2',
|
|
93
|
-
className
|
|
94
|
-
)}
|
|
95
|
-
{...props}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
AvatarBadge.displayName = 'AvatarBadge';
|
|
101
|
-
|
|
102
|
-
export interface ShadcnAvatarGroupProps extends React.ComponentProps<'div'> {}
|
|
103
|
-
|
|
104
|
-
export const ShadcnAvatarGroup = React.forwardRef<HTMLDivElement, AvatarGroupProps>(
|
|
105
|
-
({ className, ...props }, ref) => {
|
|
106
|
-
return (
|
|
107
|
-
<div
|
|
108
|
-
ref={ref}
|
|
109
|
-
data-slot="avatar-group"
|
|
110
|
-
className={cn(
|
|
111
|
-
'cn-avatar-group group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background',
|
|
112
|
-
className
|
|
113
|
-
)}
|
|
114
|
-
{...props}
|
|
115
|
-
/>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
AvatarGroup.displayName = 'AvatarGroup';
|
|
120
|
-
|
|
121
|
-
export interface AvatarGroupCountProps extends React.ComponentProps<'div'> {}
|
|
122
|
-
|
|
123
|
-
export const AvatarGroupCount = React.forwardRef<HTMLDivElement, AvatarGroupCountProps>(
|
|
124
|
-
({ className, ...props }, ref) => {
|
|
125
|
-
return (
|
|
126
|
-
<div
|
|
127
|
-
ref={ref}
|
|
128
|
-
data-slot="avatar-group-count"
|
|
129
|
-
className={cn(
|
|
130
|
-
'size-8 rounded-full bg-muted text-sm text-muted-foreground group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3 relative flex shrink-0 items-center justify-center ring-2 ring-background',
|
|
131
|
-
className
|
|
132
|
-
)}
|
|
133
|
-
{...props}
|
|
134
|
-
/>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
AvatarGroupCount.displayName = 'AvatarGroupCount';
|
|
139
|
-
|
|
140
|
-
export {
|
|
141
|
-
ShadcnAvatar as Root,
|
|
142
|
-
AvatarImage as Image,
|
|
143
|
-
AvatarFallback as Fallback,
|
|
144
|
-
AvatarBadge as Badge,
|
|
145
|
-
AvatarGroup as Group,
|
|
146
|
-
AvatarGroupCount as GroupCount
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export default ShadcnAvatar;
|