@surreal-ui/react 0.8.0 → 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.
- 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 +25 -8
- package/CHANGELOG.md +0 -142
- 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,220 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
|
-
import { cn } from '@surreal-ui/core';
|
|
4
|
-
|
|
5
|
-
interface DrawerContextValue {
|
|
6
|
-
open: boolean;
|
|
7
|
-
setOpen: (open: boolean) => void;
|
|
8
|
-
direction: 'bottom' | 'top' | 'left' | 'right';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const DrawerContext = React.createContext<DrawerContextValue | null>(null);
|
|
12
|
-
|
|
13
|
-
function useDrawer() {
|
|
14
|
-
const context = React.useContext(DrawerContext);
|
|
15
|
-
if (!context) {
|
|
16
|
-
throw new Error('Drawer compound components must be rendered inside <Drawer />');
|
|
17
|
-
}
|
|
18
|
-
return context;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ShadcnDrawerProps {
|
|
22
|
-
open?: boolean;
|
|
23
|
-
defaultOpen?: boolean;
|
|
24
|
-
onOpenChange?: (open: boolean) => void;
|
|
25
|
-
direction?: 'bottom' | 'top' | 'left' | 'right';
|
|
26
|
-
shouldScaleBackground?: boolean;
|
|
27
|
-
children?: React.ReactNode;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function ShadcnDrawer({
|
|
31
|
-
open: controlledOpen,
|
|
32
|
-
defaultOpen = false,
|
|
33
|
-
onOpenChange,
|
|
34
|
-
direction = 'bottom',
|
|
35
|
-
children
|
|
36
|
-
}: DrawerProps) {
|
|
37
|
-
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
|
|
38
|
-
const isControlled = controlledOpen !== undefined;
|
|
39
|
-
const open = isControlled ? controlledOpen : uncontrolledOpen;
|
|
40
|
-
|
|
41
|
-
const setOpen = React.useCallback(
|
|
42
|
-
(next: boolean) => {
|
|
43
|
-
if (!isControlled) {
|
|
44
|
-
setUncontrolledOpen(next);
|
|
45
|
-
}
|
|
46
|
-
onOpenChange?.(next);
|
|
47
|
-
},
|
|
48
|
-
[isControlled, onOpenChange]
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<DrawerContext.Provider value={{ open, setOpen, direction }}>
|
|
53
|
-
<div data-slot="drawer-root" data-state={open ? 'open' : 'closed'}>
|
|
54
|
-
{children}
|
|
55
|
-
</div>
|
|
56
|
-
</DrawerContext.Provider>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const DrawerNestedRoot = Drawer;
|
|
61
|
-
|
|
62
|
-
export function ShadcnDrawerTrigger({
|
|
63
|
-
className,
|
|
64
|
-
children,
|
|
65
|
-
onClick,
|
|
66
|
-
...props
|
|
67
|
-
}: React.ComponentProps<'button'>) {
|
|
68
|
-
const { setOpen } = useDrawer();
|
|
69
|
-
return (
|
|
70
|
-
<button
|
|
71
|
-
type="button"
|
|
72
|
-
data-slot="drawer-trigger"
|
|
73
|
-
className={cn('inline-flex items-center justify-center', className)}
|
|
74
|
-
onClick={(e) => {
|
|
75
|
-
onClick?.(e);
|
|
76
|
-
setOpen(true);
|
|
77
|
-
}}
|
|
78
|
-
{...props}
|
|
79
|
-
>
|
|
80
|
-
{children}
|
|
81
|
-
</button>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function ShadcnDrawerPortal({ children }: { children?: React.ReactNode }) {
|
|
86
|
-
const [mounted, setMounted] = React.useState(false);
|
|
87
|
-
React.useEffect(() => {
|
|
88
|
-
setMounted(true);
|
|
89
|
-
}, []);
|
|
90
|
-
|
|
91
|
-
if (!mounted) return null;
|
|
92
|
-
return createPortal(children, document.body);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function ShadcnDrawerOverlay({ className, onClick, ...props }: React.ComponentProps<'div'>) {
|
|
96
|
-
const { open, setOpen } = useDrawer();
|
|
97
|
-
if (!open) return null;
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<div
|
|
101
|
-
data-slot="drawer-overlay"
|
|
102
|
-
data-state={open ? 'open' : 'closed'}
|
|
103
|
-
className={cn(
|
|
104
|
-
'fixed inset-0 z-50 bg-black/80 supports-backdrop-filter:backdrop-blur-xs transition-opacity duration-300 animate-in fade-in-0',
|
|
105
|
-
className
|
|
106
|
-
)}
|
|
107
|
-
onClick={(e) => {
|
|
108
|
-
onClick?.(e);
|
|
109
|
-
setOpen(false);
|
|
110
|
-
}}
|
|
111
|
-
{...props}
|
|
112
|
-
/>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function ShadcnDrawerContent({
|
|
117
|
-
className,
|
|
118
|
-
children,
|
|
119
|
-
...props
|
|
120
|
-
}: React.ComponentProps<'div'>) {
|
|
121
|
-
const { open, direction } = useDrawer();
|
|
122
|
-
if (!open) return null;
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<DrawerPortal>
|
|
126
|
-
<DrawerOverlay />
|
|
127
|
-
<div
|
|
128
|
-
data-slot="drawer-content"
|
|
129
|
-
data-vaul-drawer-direction={direction}
|
|
130
|
-
data-state={open ? 'open' : 'closed'}
|
|
131
|
-
className={cn(
|
|
132
|
-
'group/drawer-content fixed z-50 flex h-auto flex-col bg-popover text-sm text-popover-foreground shadow-lg transition-transform duration-300 ease-out',
|
|
133
|
-
direction === 'bottom' &&
|
|
134
|
-
'inset-x-0 bottom-0 mt-24 max-h-[80vh] rounded-t-xl border-t animate-in slide-in-from-bottom',
|
|
135
|
-
direction === 'top' &&
|
|
136
|
-
'inset-x-0 top-0 mb-24 max-h-[80vh] rounded-b-xl border-b animate-in slide-in-from-top',
|
|
137
|
-
direction === 'left' &&
|
|
138
|
-
'inset-y-0 left-0 w-3/4 max-w-sm rounded-r-xl border-r animate-in slide-in-from-left',
|
|
139
|
-
direction === 'right' &&
|
|
140
|
-
'inset-y-0 right-0 w-3/4 max-w-sm rounded-l-xl border-l animate-in slide-in-from-right',
|
|
141
|
-
className
|
|
142
|
-
)}
|
|
143
|
-
{...props}
|
|
144
|
-
>
|
|
145
|
-
{direction === 'bottom' && (
|
|
146
|
-
<div className="mx-auto mt-4 h-1.5 w-12 shrink-0 rounded-full bg-muted" />
|
|
147
|
-
)}
|
|
148
|
-
{children}
|
|
149
|
-
</div>
|
|
150
|
-
</DrawerPortal>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function ShadcnDrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
155
|
-
return (
|
|
156
|
-
<div
|
|
157
|
-
data-slot="drawer-header"
|
|
158
|
-
className={cn('flex flex-col gap-1.5 p-4 text-center md:text-left', className)}
|
|
159
|
-
{...props}
|
|
160
|
-
/>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function ShadcnDrawerTitle({ className, ...props }: React.ComponentProps<'h2'>) {
|
|
165
|
-
return (
|
|
166
|
-
<h2
|
|
167
|
-
data-slot="drawer-title"
|
|
168
|
-
className={cn(
|
|
169
|
-
'text-base font-semibold leading-none tracking-tight text-foreground',
|
|
170
|
-
className
|
|
171
|
-
)}
|
|
172
|
-
{...props}
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export function ShadcnDrawerDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
178
|
-
return (
|
|
179
|
-
<p
|
|
180
|
-
data-slot="drawer-description"
|
|
181
|
-
className={cn('text-sm text-muted-foreground', className)}
|
|
182
|
-
{...props}
|
|
183
|
-
/>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function ShadcnDrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
188
|
-
return (
|
|
189
|
-
<div
|
|
190
|
-
data-slot="drawer-footer"
|
|
191
|
-
className={cn('mt-auto flex flex-col gap-2 p-4', className)}
|
|
192
|
-
{...props}
|
|
193
|
-
/>
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function ShadcnDrawerClose({
|
|
198
|
-
className,
|
|
199
|
-
children,
|
|
200
|
-
onClick,
|
|
201
|
-
...props
|
|
202
|
-
}: React.ComponentProps<'button'>) {
|
|
203
|
-
const { setOpen } = useDrawer();
|
|
204
|
-
return (
|
|
205
|
-
<button
|
|
206
|
-
type="button"
|
|
207
|
-
data-slot="drawer-close"
|
|
208
|
-
className={cn('inline-flex items-center justify-center', className)}
|
|
209
|
-
onClick={(e) => {
|
|
210
|
-
onClick?.(e);
|
|
211
|
-
setOpen(false);
|
|
212
|
-
}}
|
|
213
|
-
{...props}
|
|
214
|
-
>
|
|
215
|
-
{children}
|
|
216
|
-
</button>
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export default MinimalistDrawer;
|
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Check, Minus, ChevronRight } from 'lucide-react';
|
|
4
|
-
import { cn } from '@surreal-ui/core';
|
|
5
|
-
|
|
6
|
-
interface DropdownMenuContextValue {
|
|
7
|
-
open: boolean;
|
|
8
|
-
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const DropdownMenuContext = React.createContext<DropdownMenuContextValue | null>(null);
|
|
12
|
-
|
|
13
|
-
export interface ShadcnDropdownMenuProps {
|
|
14
|
-
open?: boolean;
|
|
15
|
-
defaultOpen?: boolean;
|
|
16
|
-
onOpenChange?: (open: boolean) => void;
|
|
17
|
-
children?: React.ReactNode;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function ShadcnDropdownMenu({
|
|
21
|
-
open: controlledOpen,
|
|
22
|
-
defaultOpen = false,
|
|
23
|
-
onOpenChange,
|
|
24
|
-
children
|
|
25
|
-
}: DropdownMenuProps) {
|
|
26
|
-
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
|
|
27
|
-
const isControlled = controlledOpen !== undefined;
|
|
28
|
-
const open = isControlled ? controlledOpen : uncontrolledOpen;
|
|
29
|
-
|
|
30
|
-
const setOpen = React.useCallback(
|
|
31
|
-
(updater: boolean | ((prev: boolean) => boolean)) => {
|
|
32
|
-
const next = typeof updater === 'function' ? updater(open) : updater;
|
|
33
|
-
if (!isControlled) {
|
|
34
|
-
setUncontrolledOpen(next);
|
|
35
|
-
}
|
|
36
|
-
onOpenChange?.(next);
|
|
37
|
-
},
|
|
38
|
-
[isControlled, open, onOpenChange]
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<DropdownMenuContext.Provider value={{ open, setOpen }}>
|
|
43
|
-
<div className="relative inline-block text-left" data-slot="dropdown-menu">
|
|
44
|
-
{children}
|
|
45
|
-
</div>
|
|
46
|
-
</DropdownMenuContext.Provider>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface ShadcnDropdownMenuTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
51
|
-
asChild?: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const ShadcnDropdownMenuTrigger = React.forwardRef<
|
|
55
|
-
HTMLButtonElement,
|
|
56
|
-
DropdownMenuTriggerProps
|
|
57
|
-
>(({ className, onClick, ...props }, ref) => {
|
|
58
|
-
const context = React.useContext(DropdownMenuContext);
|
|
59
|
-
return (
|
|
60
|
-
<button
|
|
61
|
-
ref={ref}
|
|
62
|
-
type="button"
|
|
63
|
-
data-slot="dropdown-menu-trigger"
|
|
64
|
-
aria-haspopup="menu"
|
|
65
|
-
aria-expanded={context?.open ?? false}
|
|
66
|
-
className={cn('inline-flex items-center justify-center outline-none select-none', className)}
|
|
67
|
-
onClick={(e) => {
|
|
68
|
-
context?.setOpen((prev) => !prev);
|
|
69
|
-
onClick?.(e);
|
|
70
|
-
}}
|
|
71
|
-
{...props}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
DropdownMenuTrigger.displayName = 'DropdownMenuTrigger';
|
|
76
|
-
|
|
77
|
-
export interface ShadcnDropdownMenuPortalProps {
|
|
78
|
-
children?: React.ReactNode;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function ShadcnDropdownMenuPortal({ children }: DropdownMenuPortalProps) {
|
|
82
|
-
return <>{children}</>;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface ShadcnDropdownMenuContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
86
|
-
sideOffset?: number;
|
|
87
|
-
align?: 'start' | 'center' | 'end';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const ShadcnDropdownMenuContent = React.forwardRef<HTMLDivElement, DropdownMenuContentProps>(
|
|
91
|
-
({ className, sideOffset = 4, align = 'start', children, ...props }, ref) => {
|
|
92
|
-
const context = React.useContext(DropdownMenuContext);
|
|
93
|
-
const menuRef = React.useRef<HTMLDivElement | null>(null);
|
|
94
|
-
|
|
95
|
-
React.useEffect(() => {
|
|
96
|
-
function handleClickOutside(event: MouseEvent) {
|
|
97
|
-
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
|
98
|
-
context?.setOpen(false);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (context?.open) {
|
|
102
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
103
|
-
}
|
|
104
|
-
return () => {
|
|
105
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
106
|
-
};
|
|
107
|
-
}, [context?.open, context]);
|
|
108
|
-
|
|
109
|
-
if (!context?.open) return null;
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<div
|
|
113
|
-
ref={(node) => {
|
|
114
|
-
menuRef.current = node;
|
|
115
|
-
if (typeof ref === 'function') ref(node);
|
|
116
|
-
else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
|
|
117
|
-
}}
|
|
118
|
-
data-slot="dropdown-menu-content"
|
|
119
|
-
role="menu"
|
|
120
|
-
tabIndex={-1}
|
|
121
|
-
style={{ marginTop: `${sideOffset}px` }}
|
|
122
|
-
className={cn(
|
|
123
|
-
'absolute z-50 min-w-32 rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 overflow-x-hidden overflow-y-auto outline-none',
|
|
124
|
-
align === 'end' ? 'right-0' : align === 'center' ? 'left-1/2 -translate-x-1/2' : 'left-0',
|
|
125
|
-
className
|
|
126
|
-
)}
|
|
127
|
-
{...props}
|
|
128
|
-
>
|
|
129
|
-
{children}
|
|
130
|
-
</div>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
DropdownMenuContent.displayName = 'DropdownMenuContent';
|
|
135
|
-
|
|
136
|
-
export interface ShadcnDropdownMenuGroupProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
137
|
-
|
|
138
|
-
export const ShadcnDropdownMenuGroup = React.forwardRef<HTMLDivElement, DropdownMenuGroupProps>(
|
|
139
|
-
({ className, ...props }, ref) => (
|
|
140
|
-
<div ref={ref} data-slot="dropdown-menu-group" className={cn('w-full', className)} {...props} />
|
|
141
|
-
)
|
|
142
|
-
);
|
|
143
|
-
DropdownMenuGroup.displayName = 'DropdownMenuGroup';
|
|
144
|
-
|
|
145
|
-
export interface DropdownMenuGroupHeadingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
146
|
-
inset?: boolean;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export const DropdownMenuGroupHeading = React.forwardRef<
|
|
150
|
-
HTMLDivElement,
|
|
151
|
-
DropdownMenuGroupHeadingProps
|
|
152
|
-
>(({ className, inset, ...props }, ref) => (
|
|
153
|
-
<div
|
|
154
|
-
ref={ref}
|
|
155
|
-
data-slot="dropdown-menu-group-heading"
|
|
156
|
-
data-inset={inset ? '' : undefined}
|
|
157
|
-
className={cn('px-2 py-1.5 text-sm font-semibold data-[inset]:ps-8', className)}
|
|
158
|
-
{...props}
|
|
159
|
-
/>
|
|
160
|
-
));
|
|
161
|
-
DropdownMenuGroupHeading.displayName = 'DropdownMenuGroupHeading';
|
|
162
|
-
|
|
163
|
-
export interface ShadcnDropdownMenuItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
164
|
-
inset?: boolean;
|
|
165
|
-
variant?: 'default' | 'destructive';
|
|
166
|
-
disabled?: boolean;
|
|
167
|
-
onSelect?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export const ShadcnDropdownMenuItem = React.forwardRef<HTMLDivElement, DropdownMenuItemProps>(
|
|
171
|
-
(
|
|
172
|
-
{ className, inset, variant = 'default', disabled = false, onSelect, onClick, ...props },
|
|
173
|
-
ref
|
|
174
|
-
) => {
|
|
175
|
-
const context = React.useContext(DropdownMenuContext);
|
|
176
|
-
return (
|
|
177
|
-
<div
|
|
178
|
-
ref={ref}
|
|
179
|
-
role="menuitem"
|
|
180
|
-
tabIndex={disabled ? -1 : 0}
|
|
181
|
-
data-slot="dropdown-menu-item"
|
|
182
|
-
data-inset={inset ? '' : undefined}
|
|
183
|
-
data-variant={variant}
|
|
184
|
-
data-disabled={disabled ? '' : undefined}
|
|
185
|
-
className={cn(
|
|
186
|
-
"gap-1.5 rounded-md px-1.5 py-1 text-sm focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-[inset]:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground",
|
|
187
|
-
className
|
|
188
|
-
)}
|
|
189
|
-
onClick={(e) => {
|
|
190
|
-
if (disabled) return;
|
|
191
|
-
onSelect?.(e);
|
|
192
|
-
onClick?.(e);
|
|
193
|
-
context?.setOpen(false);
|
|
194
|
-
}}
|
|
195
|
-
{...props}
|
|
196
|
-
/>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
);
|
|
200
|
-
DropdownMenuItem.displayName = 'DropdownMenuItem';
|
|
201
|
-
|
|
202
|
-
export interface DropdownMenuCheckboxItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
203
|
-
checked?: boolean;
|
|
204
|
-
indeterminate?: boolean;
|
|
205
|
-
disabled?: boolean;
|
|
206
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export const DropdownMenuCheckboxItem = React.forwardRef<
|
|
210
|
-
HTMLDivElement,
|
|
211
|
-
DropdownMenuCheckboxItemProps
|
|
212
|
-
>(
|
|
213
|
-
(
|
|
214
|
-
{
|
|
215
|
-
className,
|
|
216
|
-
checked = false,
|
|
217
|
-
indeterminate = false,
|
|
218
|
-
disabled = false,
|
|
219
|
-
onCheckedChange,
|
|
220
|
-
onClick,
|
|
221
|
-
children,
|
|
222
|
-
...props
|
|
223
|
-
},
|
|
224
|
-
ref
|
|
225
|
-
) => {
|
|
226
|
-
return (
|
|
227
|
-
<div
|
|
228
|
-
ref={ref}
|
|
229
|
-
role="menuitemcheckbox"
|
|
230
|
-
aria-checked={indeterminate ? 'mixed' : checked}
|
|
231
|
-
tabIndex={disabled ? -1 : 0}
|
|
232
|
-
data-slot="dropdown-menu-checkbox-item"
|
|
233
|
-
data-disabled={disabled ? '' : undefined}
|
|
234
|
-
className={cn(
|
|
235
|
-
"gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground",
|
|
236
|
-
className
|
|
237
|
-
)}
|
|
238
|
-
onClick={(e) => {
|
|
239
|
-
if (disabled) return;
|
|
240
|
-
onCheckedChange?.(!checked);
|
|
241
|
-
onClick?.(e);
|
|
242
|
-
}}
|
|
243
|
-
{...props}
|
|
244
|
-
>
|
|
245
|
-
<span
|
|
246
|
-
className="absolute right-2 flex items-center justify-center pointer-events-none"
|
|
247
|
-
data-slot="dropdown-menu-checkbox-item-indicator"
|
|
248
|
-
>
|
|
249
|
-
{indeterminate ? (
|
|
250
|
-
<Minus className="size-4" />
|
|
251
|
-
) : checked ? (
|
|
252
|
-
<Check className="size-4" />
|
|
253
|
-
) : null}
|
|
254
|
-
</span>
|
|
255
|
-
{children}
|
|
256
|
-
</div>
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
DropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';
|
|
261
|
-
|
|
262
|
-
interface RadioGroupContextValue {
|
|
263
|
-
value?: string;
|
|
264
|
-
onValueChange?: (val: string) => void;
|
|
265
|
-
}
|
|
266
|
-
const RadioGroupContext = React.createContext<RadioGroupContextValue | null>(null);
|
|
267
|
-
|
|
268
|
-
export interface DropdownMenuRadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
269
|
-
value?: string;
|
|
270
|
-
onValueChange?: (value: string) => void;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export const DropdownMenuRadioGroup = React.forwardRef<HTMLDivElement, DropdownMenuRadioGroupProps>(
|
|
274
|
-
({ className, value, onValueChange, ...props }, ref) => (
|
|
275
|
-
<RadioGroupContext.Provider value={{ value, onValueChange }}>
|
|
276
|
-
<div
|
|
277
|
-
ref={ref}
|
|
278
|
-
data-slot="dropdown-menu-radio-group"
|
|
279
|
-
className={cn('w-full', className)}
|
|
280
|
-
{...props}
|
|
281
|
-
/>
|
|
282
|
-
</RadioGroupContext.Provider>
|
|
283
|
-
)
|
|
284
|
-
);
|
|
285
|
-
DropdownMenuRadioGroup.displayName = 'DropdownMenuRadioGroup';
|
|
286
|
-
|
|
287
|
-
export interface DropdownMenuRadioItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
288
|
-
value: string;
|
|
289
|
-
disabled?: boolean;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export const DropdownMenuRadioItem = React.forwardRef<HTMLDivElement, DropdownMenuRadioItemProps>(
|
|
293
|
-
({ className, value, disabled = false, children, onClick, ...props }, ref) => {
|
|
294
|
-
const group = React.useContext(RadioGroupContext);
|
|
295
|
-
const checked = group?.value === value;
|
|
296
|
-
return (
|
|
297
|
-
<div
|
|
298
|
-
ref={ref}
|
|
299
|
-
role="menuitemradio"
|
|
300
|
-
aria-checked={checked}
|
|
301
|
-
tabIndex={disabled ? -1 : 0}
|
|
302
|
-
data-slot="dropdown-menu-radio-item"
|
|
303
|
-
data-disabled={disabled ? '' : undefined}
|
|
304
|
-
className={cn(
|
|
305
|
-
"gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground",
|
|
306
|
-
className
|
|
307
|
-
)}
|
|
308
|
-
onClick={(e) => {
|
|
309
|
-
if (disabled) return;
|
|
310
|
-
group?.onValueChange?.(value);
|
|
311
|
-
onClick?.(e);
|
|
312
|
-
}}
|
|
313
|
-
{...props}
|
|
314
|
-
>
|
|
315
|
-
<span
|
|
316
|
-
className="absolute right-2 flex items-center justify-center pointer-events-none"
|
|
317
|
-
data-slot="dropdown-menu-radio-item-indicator"
|
|
318
|
-
>
|
|
319
|
-
{checked ? <Check className="size-4" /> : null}
|
|
320
|
-
</span>
|
|
321
|
-
{children}
|
|
322
|
-
</div>
|
|
323
|
-
);
|
|
324
|
-
}
|
|
325
|
-
);
|
|
326
|
-
DropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';
|
|
327
|
-
|
|
328
|
-
export interface ShadcnDropdownMenuLabelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
329
|
-
inset?: boolean;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export const ShadcnDropdownMenuLabel = React.forwardRef<HTMLDivElement, DropdownMenuLabelProps>(
|
|
333
|
-
({ className, inset, ...props }, ref) => (
|
|
334
|
-
<div
|
|
335
|
-
ref={ref}
|
|
336
|
-
data-slot="dropdown-menu-label"
|
|
337
|
-
data-inset={inset ? '' : undefined}
|
|
338
|
-
className={cn(
|
|
339
|
-
'px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7 data-[inset]:pl-8',
|
|
340
|
-
className
|
|
341
|
-
)}
|
|
342
|
-
{...props}
|
|
343
|
-
/>
|
|
344
|
-
)
|
|
345
|
-
);
|
|
346
|
-
DropdownMenuLabel.displayName = 'DropdownMenuLabel';
|
|
347
|
-
|
|
348
|
-
export interface ShadcnDropdownMenuSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
349
|
-
|
|
350
|
-
export const ShadcnDropdownMenuSeparator = React.forwardRef<
|
|
351
|
-
HTMLDivElement,
|
|
352
|
-
DropdownMenuSeparatorProps
|
|
353
|
-
>(({ className, ...props }, ref) => (
|
|
354
|
-
<div
|
|
355
|
-
ref={ref}
|
|
356
|
-
role="separator"
|
|
357
|
-
data-slot="dropdown-menu-separator"
|
|
358
|
-
className={cn('-mx-1 my-1 h-px bg-border', className)}
|
|
359
|
-
{...props}
|
|
360
|
-
/>
|
|
361
|
-
));
|
|
362
|
-
DropdownMenuSeparator.displayName = 'DropdownMenuSeparator';
|
|
363
|
-
|
|
364
|
-
export interface ShadcnDropdownMenuShortcutProps extends React.HTMLAttributes<HTMLSpanElement> {}
|
|
365
|
-
|
|
366
|
-
export const ShadcnDropdownMenuShortcut = React.forwardRef<
|
|
367
|
-
HTMLSpanElement,
|
|
368
|
-
DropdownMenuShortcutProps
|
|
369
|
-
>(({ className, ...props }, ref) => (
|
|
370
|
-
<span
|
|
371
|
-
ref={ref}
|
|
372
|
-
data-slot="dropdown-menu-shortcut"
|
|
373
|
-
className={cn(
|
|
374
|
-
'ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground',
|
|
375
|
-
className
|
|
376
|
-
)}
|
|
377
|
-
{...props}
|
|
378
|
-
/>
|
|
379
|
-
));
|
|
380
|
-
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
|
381
|
-
|
|
382
|
-
export interface DropdownMenuSubProps {
|
|
383
|
-
open?: boolean;
|
|
384
|
-
children?: React.ReactNode;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export function DropdownMenuSub({ children }: DropdownMenuSubProps) {
|
|
388
|
-
return <div className="relative group/sub w-full">{children}</div>;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
export interface DropdownMenuSubTriggerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
392
|
-
inset?: boolean;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
export const DropdownMenuSubTrigger = React.forwardRef<HTMLDivElement, DropdownMenuSubTriggerProps>(
|
|
396
|
-
({ className, inset, children, ...props }, ref) => (
|
|
397
|
-
<div
|
|
398
|
-
ref={ref}
|
|
399
|
-
data-slot="dropdown-menu-sub-trigger"
|
|
400
|
-
data-inset={inset ? '' : undefined}
|
|
401
|
-
className={cn(
|
|
402
|
-
"gap-1.5 rounded-md px-1.5 py-1 text-sm focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg:not([class*='size-'])]:size-4 flex cursor-default items-center outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground",
|
|
403
|
-
className
|
|
404
|
-
)}
|
|
405
|
-
{...props}
|
|
406
|
-
>
|
|
407
|
-
{children}
|
|
408
|
-
<ChevronRight className="ml-auto size-4" />
|
|
409
|
-
</div>
|
|
410
|
-
)
|
|
411
|
-
);
|
|
412
|
-
DropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';
|
|
413
|
-
|
|
414
|
-
export interface DropdownMenuSubContentProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
415
|
-
|
|
416
|
-
export const DropdownMenuSubContent = React.forwardRef<HTMLDivElement, DropdownMenuSubContentProps>(
|
|
417
|
-
({ className, ...props }, ref) => (
|
|
418
|
-
<div
|
|
419
|
-
ref={ref}
|
|
420
|
-
data-slot="dropdown-menu-sub-content"
|
|
421
|
-
className={cn(
|
|
422
|
-
'min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 hidden group-hover/sub:block absolute left-full top-0 ml-1 z-50 w-auto',
|
|
423
|
-
className
|
|
424
|
-
)}
|
|
425
|
-
{...props}
|
|
426
|
-
/>
|
|
427
|
-
)
|
|
428
|
-
);
|
|
429
|
-
DropdownMenuSubContent.displayName = 'DropdownMenuSubContent';
|
|
430
|
-
|
|
431
|
-
export default MinimalistDropdownMenu;
|