@surreal-ui/react 0.5.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 (125) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/index.js +11307 -0
  3. package/package.json +38 -0
  4. package/src/components/GlassmorphismAlert.tsx +40 -0
  5. package/src/components/GlassmorphismButton.tsx +20 -0
  6. package/src/components/GlassmorphismCard.tsx +43 -0
  7. package/src/components/GlassmorphismEmptyState.tsx +20 -0
  8. package/src/components/GlassmorphismInputGroup.tsx +148 -0
  9. package/src/components/GlassmorphismMenubar.tsx +96 -0
  10. package/src/components/GlassmorphismScrollArea.tsx +67 -0
  11. package/src/components/GlassmorphismTable.tsx +61 -0
  12. package/src/components/GlassmorphismTypography.tsx +31 -0
  13. package/src/components/MinimalistAccordion.tsx +215 -0
  14. package/src/components/MinimalistAlert.tsx +40 -0
  15. package/src/components/MinimalistAlertDialog.tsx +317 -0
  16. package/src/components/MinimalistAspectRatio.tsx +30 -0
  17. package/src/components/MinimalistAvatar.tsx +149 -0
  18. package/src/components/MinimalistBadge.tsx +49 -0
  19. package/src/components/MinimalistBreadcrumb.tsx +105 -0
  20. package/src/components/MinimalistButton.tsx +86 -0
  21. package/src/components/MinimalistButtonGroup.tsx +85 -0
  22. package/src/components/MinimalistCalendar.tsx +352 -0
  23. package/src/components/MinimalistCard.tsx +89 -0
  24. package/src/components/MinimalistCarousel.tsx +266 -0
  25. package/src/components/MinimalistChart.tsx +296 -0
  26. package/src/components/MinimalistCheckbox.tsx +117 -0
  27. package/src/components/MinimalistCodeBlock.tsx +203 -0
  28. package/src/components/MinimalistCollapsible.tsx +134 -0
  29. package/src/components/MinimalistCommand.tsx +344 -0
  30. package/src/components/MinimalistContextMenu.tsx +400 -0
  31. package/src/components/MinimalistDialog.tsx +269 -0
  32. package/src/components/MinimalistDrawer.tsx +216 -0
  33. package/src/components/MinimalistDropdownMenu.tsx +431 -0
  34. package/src/components/MinimalistEmpty.tsx +105 -0
  35. package/src/components/MinimalistEmptyState.tsx +34 -0
  36. package/src/components/MinimalistField.tsx +275 -0
  37. package/src/components/MinimalistForm.tsx +203 -0
  38. package/src/components/MinimalistHoverCard.tsx +48 -0
  39. package/src/components/MinimalistInput.tsx +24 -0
  40. package/src/components/MinimalistInputGroup.tsx +180 -0
  41. package/src/components/MinimalistInputOtp.tsx +189 -0
  42. package/src/components/MinimalistItem.tsx +181 -0
  43. package/src/components/MinimalistKbd.tsx +46 -0
  44. package/src/components/MinimalistLabel.tsx +19 -0
  45. package/src/components/MinimalistMenubar.tsx +491 -0
  46. package/src/components/MinimalistNativeSelect.tsx +77 -0
  47. package/src/components/MinimalistNavigationMenu.tsx +198 -0
  48. package/src/components/MinimalistPagination.tsx +152 -0
  49. package/src/components/MinimalistPopover.tsx +228 -0
  50. package/src/components/MinimalistProgress.tsx +39 -0
  51. package/src/components/MinimalistRadioGroup.tsx +115 -0
  52. package/src/components/MinimalistRangeCalendar.tsx +396 -0
  53. package/src/components/MinimalistResizable.tsx +54 -0
  54. package/src/components/MinimalistScrollArea.tsx +41 -0
  55. package/src/components/MinimalistSelect.tsx +265 -0
  56. package/src/components/MinimalistSeparator.tsx +45 -0
  57. package/src/components/MinimalistSheet.tsx +247 -0
  58. package/src/components/MinimalistSidebar.tsx +637 -0
  59. package/src/components/MinimalistSkeleton.tsx +16 -0
  60. package/src/components/MinimalistSlider.tsx +213 -0
  61. package/src/components/MinimalistSonner.tsx +41 -0
  62. package/src/components/MinimalistSpinner.tsx +39 -0
  63. package/src/components/MinimalistSwitch.tsx +92 -0
  64. package/src/components/MinimalistTable.tsx +65 -0
  65. package/src/components/MinimalistTabs.tsx +166 -0
  66. package/src/components/MinimalistTextarea.tsx +24 -0
  67. package/src/components/MinimalistToggle.tsx +74 -0
  68. package/src/components/MinimalistToggleGroup.tsx +196 -0
  69. package/src/components/MinimalistTooltip.tsx +172 -0
  70. package/src/components/MinimalistTypography.tsx +33 -0
  71. package/src/components/NeubrutalismCard.tsx +3 -0
  72. package/src/components/NeubrutalismItem.tsx +48 -0
  73. package/src/components/ShadcnAccordion.tsx +215 -0
  74. package/src/components/ShadcnAlertDialog.tsx +317 -0
  75. package/src/components/ShadcnAspectRatio.tsx +30 -0
  76. package/src/components/ShadcnAvatar.tsx +149 -0
  77. package/src/components/ShadcnBadge.tsx +49 -0
  78. package/src/components/ShadcnBreadcrumb.tsx +105 -0
  79. package/src/components/ShadcnButton.tsx +86 -0
  80. package/src/components/ShadcnButtonGroup.tsx +85 -0
  81. package/src/components/ShadcnCalendar.tsx +352 -0
  82. package/src/components/ShadcnCarousel.tsx +266 -0
  83. package/src/components/ShadcnChart.tsx +296 -0
  84. package/src/components/ShadcnCheckbox.tsx +117 -0
  85. package/src/components/ShadcnCodeBlock.tsx +203 -0
  86. package/src/components/ShadcnCollapsible.tsx +134 -0
  87. package/src/components/ShadcnCommand.tsx +344 -0
  88. package/src/components/ShadcnContextMenu.tsx +400 -0
  89. package/src/components/ShadcnDialog.tsx +269 -0
  90. package/src/components/ShadcnDrawer.tsx +216 -0
  91. package/src/components/ShadcnDropdownMenu.tsx +431 -0
  92. package/src/components/ShadcnEmpty.tsx +105 -0
  93. package/src/components/ShadcnField.tsx +275 -0
  94. package/src/components/ShadcnForm.tsx +203 -0
  95. package/src/components/ShadcnHoverCard.tsx +48 -0
  96. package/src/components/ShadcnInput.tsx +24 -0
  97. package/src/components/ShadcnInputGroup.tsx +180 -0
  98. package/src/components/ShadcnInputOtp.tsx +189 -0
  99. package/src/components/ShadcnItem.tsx +181 -0
  100. package/src/components/ShadcnKbd.tsx +46 -0
  101. package/src/components/ShadcnLabel.tsx +19 -0
  102. package/src/components/ShadcnMenubar.tsx +491 -0
  103. package/src/components/ShadcnNativeSelect.tsx +77 -0
  104. package/src/components/ShadcnNavigationMenu.tsx +198 -0
  105. package/src/components/ShadcnPagination.tsx +152 -0
  106. package/src/components/ShadcnPopover.tsx +228 -0
  107. package/src/components/ShadcnProgress.tsx +39 -0
  108. package/src/components/ShadcnRadioGroup.tsx +115 -0
  109. package/src/components/ShadcnRangeCalendar.tsx +396 -0
  110. package/src/components/ShadcnSelect.tsx +265 -0
  111. package/src/components/ShadcnSeparator.tsx +45 -0
  112. package/src/components/ShadcnSheet.tsx +247 -0
  113. package/src/components/ShadcnSidebar.tsx +637 -0
  114. package/src/components/ShadcnSkeleton.tsx +16 -0
  115. package/src/components/ShadcnSlider.tsx +213 -0
  116. package/src/components/ShadcnSonner.tsx +41 -0
  117. package/src/components/ShadcnSpinner.tsx +39 -0
  118. package/src/components/ShadcnSwitch.tsx +92 -0
  119. package/src/components/ShadcnTabs.tsx +166 -0
  120. package/src/components/ShadcnTextarea.tsx +24 -0
  121. package/src/components/ShadcnToggle.tsx +74 -0
  122. package/src/components/ShadcnToggleGroup.tsx +196 -0
  123. package/src/components/ShadcnTooltip.tsx +172 -0
  124. package/src/index.ts +124 -0
  125. package/tsconfig.json +10 -0
@@ -0,0 +1,216 @@
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({ className, children, ...props }: React.ComponentProps<'div'>) {
117
+ const { open, direction } = useDrawer();
118
+ if (!open) return null;
119
+
120
+ return (
121
+ <DrawerPortal>
122
+ <DrawerOverlay />
123
+ <div
124
+ data-slot="drawer-content"
125
+ data-vaul-drawer-direction={direction}
126
+ data-state={open ? 'open' : 'closed'}
127
+ className={cn(
128
+ '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',
129
+ direction === 'bottom' &&
130
+ 'inset-x-0 bottom-0 mt-24 max-h-[80vh] rounded-t-xl border-t animate-in slide-in-from-bottom',
131
+ direction === 'top' &&
132
+ 'inset-x-0 top-0 mb-24 max-h-[80vh] rounded-b-xl border-b animate-in slide-in-from-top',
133
+ direction === 'left' &&
134
+ 'inset-y-0 left-0 w-3/4 max-w-sm rounded-r-xl border-r animate-in slide-in-from-left',
135
+ direction === 'right' &&
136
+ 'inset-y-0 right-0 w-3/4 max-w-sm rounded-l-xl border-l animate-in slide-in-from-right',
137
+ className,
138
+ )}
139
+ {...props}
140
+ >
141
+ {direction === 'bottom' && (
142
+ <div className="mx-auto mt-4 h-1.5 w-12 shrink-0 rounded-full bg-muted" />
143
+ )}
144
+ {children}
145
+ </div>
146
+ </DrawerPortal>
147
+ );
148
+ }
149
+
150
+ export function ShadcnDrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {
151
+ return (
152
+ <div
153
+ data-slot="drawer-header"
154
+ className={cn('flex flex-col gap-1.5 p-4 text-center md:text-left', className)}
155
+ {...props}
156
+ />
157
+ );
158
+ }
159
+
160
+ export function ShadcnDrawerTitle({ className, ...props }: React.ComponentProps<'h2'>) {
161
+ return (
162
+ <h2
163
+ data-slot="drawer-title"
164
+ className={cn(
165
+ 'text-base font-semibold leading-none tracking-tight text-foreground',
166
+ className,
167
+ )}
168
+ {...props}
169
+ />
170
+ );
171
+ }
172
+
173
+ export function ShadcnDrawerDescription({ className, ...props }: React.ComponentProps<'p'>) {
174
+ return (
175
+ <p
176
+ data-slot="drawer-description"
177
+ className={cn('text-sm text-muted-foreground', className)}
178
+ {...props}
179
+ />
180
+ );
181
+ }
182
+
183
+ export function ShadcnDrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {
184
+ return (
185
+ <div
186
+ data-slot="drawer-footer"
187
+ className={cn('mt-auto flex flex-col gap-2 p-4', className)}
188
+ {...props}
189
+ />
190
+ );
191
+ }
192
+
193
+ export function ShadcnDrawerClose({
194
+ className,
195
+ children,
196
+ onClick,
197
+ ...props
198
+ }: React.ComponentProps<'button'>) {
199
+ const { setOpen } = useDrawer();
200
+ return (
201
+ <button
202
+ type="button"
203
+ data-slot="drawer-close"
204
+ className={cn('inline-flex items-center justify-center', className)}
205
+ onClick={(e) => {
206
+ onClick?.(e);
207
+ setOpen(false);
208
+ }}
209
+ {...props}
210
+ >
211
+ {children}
212
+ </button>
213
+ );
214
+ }
215
+
216
+ export default MinimalistDrawer;
@@ -0,0 +1,431 @@
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<HTMLButtonElement, DropdownMenuTriggerProps>(
55
+ ({ className, onClick, ...props }, ref) => {
56
+ const context = React.useContext(DropdownMenuContext);
57
+ return (
58
+ <button
59
+ ref={ref}
60
+ type="button"
61
+ data-slot="dropdown-menu-trigger"
62
+ aria-haspopup="menu"
63
+ aria-expanded={context?.open ?? false}
64
+ className={cn(
65
+ 'inline-flex items-center justify-center outline-none select-none',
66
+ className,
67
+ )}
68
+ onClick={(e) => {
69
+ context?.setOpen((prev) => !prev);
70
+ onClick?.(e);
71
+ }}
72
+ {...props}
73
+ />
74
+ );
75
+ },
76
+ );
77
+ DropdownMenuTrigger.displayName = 'DropdownMenuTrigger';
78
+
79
+ export interface ShadcnDropdownMenuPortalProps {
80
+ children?: React.ReactNode;
81
+ }
82
+
83
+ export function ShadcnDropdownMenuPortal({ children }: DropdownMenuPortalProps) {
84
+ return <>{children}</>;
85
+ }
86
+
87
+ export interface ShadcnDropdownMenuContentProps extends React.HTMLAttributes<HTMLDivElement> {
88
+ sideOffset?: number;
89
+ align?: 'start' | 'center' | 'end';
90
+ }
91
+
92
+ export const ShadcnDropdownMenuContent = React.forwardRef<HTMLDivElement, DropdownMenuContentProps>(
93
+ ({ className, sideOffset = 4, align = 'start', children, ...props }, ref) => {
94
+ const context = React.useContext(DropdownMenuContext);
95
+ const menuRef = React.useRef<HTMLDivElement | null>(null);
96
+
97
+ React.useEffect(() => {
98
+ function handleClickOutside(event: MouseEvent) {
99
+ if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
100
+ context?.setOpen(false);
101
+ }
102
+ }
103
+ if (context?.open) {
104
+ document.addEventListener('mousedown', handleClickOutside);
105
+ }
106
+ return () => {
107
+ document.removeEventListener('mousedown', handleClickOutside);
108
+ };
109
+ }, [context?.open, context]);
110
+
111
+ if (!context?.open) return null;
112
+
113
+ return (
114
+ <div
115
+ ref={(node) => {
116
+ menuRef.current = node;
117
+ if (typeof ref === 'function') ref(node);
118
+ else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
119
+ }}
120
+ data-slot="dropdown-menu-content"
121
+ role="menu"
122
+ tabIndex={-1}
123
+ style={{ marginTop: `${sideOffset}px` }}
124
+ className={cn(
125
+ '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',
126
+ align === 'end' ? 'right-0' : align === 'center' ? 'left-1/2 -translate-x-1/2' : 'left-0',
127
+ className,
128
+ )}
129
+ {...props}
130
+ >
131
+ {children}
132
+ </div>
133
+ );
134
+ },
135
+ );
136
+ DropdownMenuContent.displayName = 'DropdownMenuContent';
137
+
138
+ export interface ShadcnDropdownMenuGroupProps extends React.HTMLAttributes<HTMLDivElement> {}
139
+
140
+ export const ShadcnDropdownMenuGroup = React.forwardRef<HTMLDivElement, DropdownMenuGroupProps>(
141
+ ({ className, ...props }, ref) => (
142
+ <div ref={ref} data-slot="dropdown-menu-group" className={cn('w-full', className)} {...props} />
143
+ ),
144
+ );
145
+ DropdownMenuGroup.displayName = 'DropdownMenuGroup';
146
+
147
+ export interface DropdownMenuGroupHeadingProps extends React.HTMLAttributes<HTMLDivElement> {
148
+ inset?: boolean;
149
+ }
150
+
151
+ export const DropdownMenuGroupHeading = React.forwardRef<
152
+ HTMLDivElement,
153
+ DropdownMenuGroupHeadingProps
154
+ >(({ className, inset, ...props }, ref) => (
155
+ <div
156
+ ref={ref}
157
+ data-slot="dropdown-menu-group-heading"
158
+ data-inset={inset ? '' : undefined}
159
+ className={cn('px-2 py-1.5 text-sm font-semibold data-[inset]:ps-8', className)}
160
+ {...props}
161
+ />
162
+ ));
163
+ DropdownMenuGroupHeading.displayName = 'DropdownMenuGroupHeading';
164
+
165
+ export interface ShadcnDropdownMenuItemProps extends React.HTMLAttributes<HTMLDivElement> {
166
+ inset?: boolean;
167
+ variant?: 'default' | 'destructive';
168
+ disabled?: boolean;
169
+ onSelect?: (event: React.MouseEvent<HTMLDivElement>) => void;
170
+ }
171
+
172
+ export const ShadcnDropdownMenuItem = React.forwardRef<HTMLDivElement, DropdownMenuItemProps>(
173
+ (
174
+ { className, inset, variant = 'default', disabled = false, onSelect, onClick, ...props },
175
+ ref,
176
+ ) => {
177
+ const context = React.useContext(DropdownMenuContext);
178
+ return (
179
+ <div
180
+ ref={ref}
181
+ role="menuitem"
182
+ tabIndex={disabled ? -1 : 0}
183
+ data-slot="dropdown-menu-item"
184
+ data-inset={inset ? '' : undefined}
185
+ data-variant={variant}
186
+ data-disabled={disabled ? '' : undefined}
187
+ className={cn(
188
+ "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",
189
+ className,
190
+ )}
191
+ onClick={(e) => {
192
+ if (disabled) return;
193
+ onSelect?.(e);
194
+ onClick?.(e);
195
+ context?.setOpen(false);
196
+ }}
197
+ {...props}
198
+ />
199
+ );
200
+ },
201
+ );
202
+ DropdownMenuItem.displayName = 'DropdownMenuItem';
203
+
204
+ export interface DropdownMenuCheckboxItemProps extends React.HTMLAttributes<HTMLDivElement> {
205
+ checked?: boolean;
206
+ indeterminate?: boolean;
207
+ disabled?: boolean;
208
+ onCheckedChange?: (checked: boolean) => void;
209
+ }
210
+
211
+ export const DropdownMenuCheckboxItem = React.forwardRef<
212
+ HTMLDivElement,
213
+ DropdownMenuCheckboxItemProps
214
+ >(
215
+ (
216
+ {
217
+ className,
218
+ checked = false,
219
+ indeterminate = false,
220
+ disabled = false,
221
+ onCheckedChange,
222
+ onClick,
223
+ children,
224
+ ...props
225
+ },
226
+ ref,
227
+ ) => {
228
+ return (
229
+ <div
230
+ ref={ref}
231
+ role="menuitemcheckbox"
232
+ aria-checked={indeterminate ? 'mixed' : checked}
233
+ tabIndex={disabled ? -1 : 0}
234
+ data-slot="dropdown-menu-checkbox-item"
235
+ data-disabled={disabled ? '' : undefined}
236
+ className={cn(
237
+ "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",
238
+ className,
239
+ )}
240
+ onClick={(e) => {
241
+ if (disabled) return;
242
+ onCheckedChange?.(!checked);
243
+ onClick?.(e);
244
+ }}
245
+ {...props}
246
+ >
247
+ <span
248
+ className="absolute right-2 flex items-center justify-center pointer-events-none"
249
+ data-slot="dropdown-menu-checkbox-item-indicator"
250
+ >
251
+ {indeterminate ? (
252
+ <Minus className="size-4" />
253
+ ) : checked ? (
254
+ <Check className="size-4" />
255
+ ) : null}
256
+ </span>
257
+ {children}
258
+ </div>
259
+ );
260
+ },
261
+ );
262
+ DropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';
263
+
264
+ interface RadioGroupContextValue {
265
+ value?: string;
266
+ onValueChange?: (val: string) => void;
267
+ }
268
+ const RadioGroupContext = React.createContext<RadioGroupContextValue | null>(null);
269
+
270
+ export interface DropdownMenuRadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
271
+ value?: string;
272
+ onValueChange?: (value: string) => void;
273
+ }
274
+
275
+ export const DropdownMenuRadioGroup = React.forwardRef<HTMLDivElement, DropdownMenuRadioGroupProps>(
276
+ ({ className, value, onValueChange, ...props }, ref) => (
277
+ <RadioGroupContext.Provider value={{ value, onValueChange }}>
278
+ <div
279
+ ref={ref}
280
+ data-slot="dropdown-menu-radio-group"
281
+ className={cn('w-full', className)}
282
+ {...props}
283
+ />
284
+ </RadioGroupContext.Provider>
285
+ ),
286
+ );
287
+ DropdownMenuRadioGroup.displayName = 'DropdownMenuRadioGroup';
288
+
289
+ export interface DropdownMenuRadioItemProps extends React.HTMLAttributes<HTMLDivElement> {
290
+ value: string;
291
+ disabled?: boolean;
292
+ }
293
+
294
+ export const DropdownMenuRadioItem = React.forwardRef<HTMLDivElement, DropdownMenuRadioItemProps>(
295
+ ({ className, value, disabled = false, children, onClick, ...props }, ref) => {
296
+ const group = React.useContext(RadioGroupContext);
297
+ const checked = group?.value === value;
298
+ return (
299
+ <div
300
+ ref={ref}
301
+ role="menuitemradio"
302
+ aria-checked={checked}
303
+ tabIndex={disabled ? -1 : 0}
304
+ data-slot="dropdown-menu-radio-item"
305
+ data-disabled={disabled ? '' : undefined}
306
+ className={cn(
307
+ "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",
308
+ className,
309
+ )}
310
+ onClick={(e) => {
311
+ if (disabled) return;
312
+ group?.onValueChange?.(value);
313
+ onClick?.(e);
314
+ }}
315
+ {...props}
316
+ >
317
+ <span
318
+ className="absolute right-2 flex items-center justify-center pointer-events-none"
319
+ data-slot="dropdown-menu-radio-item-indicator"
320
+ >
321
+ {checked ? <Check className="size-4" /> : null}
322
+ </span>
323
+ {children}
324
+ </div>
325
+ );
326
+ },
327
+ );
328
+ DropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';
329
+
330
+ export interface ShadcnDropdownMenuLabelProps extends React.HTMLAttributes<HTMLDivElement> {
331
+ inset?: boolean;
332
+ }
333
+
334
+ export const ShadcnDropdownMenuLabel = React.forwardRef<HTMLDivElement, DropdownMenuLabelProps>(
335
+ ({ className, inset, ...props }, ref) => (
336
+ <div
337
+ ref={ref}
338
+ data-slot="dropdown-menu-label"
339
+ data-inset={inset ? '' : undefined}
340
+ className={cn(
341
+ 'px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7 data-[inset]:pl-8',
342
+ className,
343
+ )}
344
+ {...props}
345
+ />
346
+ ),
347
+ );
348
+ DropdownMenuLabel.displayName = 'DropdownMenuLabel';
349
+
350
+ export interface ShadcnDropdownMenuSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {}
351
+
352
+ export const ShadcnDropdownMenuSeparator = React.forwardRef<HTMLDivElement, 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
+ );
363
+ DropdownMenuSeparator.displayName = 'DropdownMenuSeparator';
364
+
365
+ export interface ShadcnDropdownMenuShortcutProps extends React.HTMLAttributes<HTMLSpanElement> {}
366
+
367
+ export const ShadcnDropdownMenuShortcut = React.forwardRef<HTMLSpanElement, DropdownMenuShortcutProps>(
368
+ ({ className, ...props }, ref) => (
369
+ <span
370
+ ref={ref}
371
+ data-slot="dropdown-menu-shortcut"
372
+ className={cn(
373
+ 'ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground',
374
+ className,
375
+ )}
376
+ {...props}
377
+ />
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;