@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,491 +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 MenubarContextValue {
|
|
7
|
-
openMenuId: string | null;
|
|
8
|
-
setOpenMenuId: (id: string | null) => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const MenubarContext = React.createContext<MenubarContextValue>({
|
|
12
|
-
openMenuId: null,
|
|
13
|
-
setOpenMenuId: () => {}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
interface MenuContextValue {
|
|
17
|
-
menuId: string;
|
|
18
|
-
isOpen: boolean;
|
|
19
|
-
setIsOpen: (open: boolean) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const MenuContext = React.createContext<MenuContextValue>({
|
|
23
|
-
menuId: '',
|
|
24
|
-
isOpen: false,
|
|
25
|
-
setIsOpen: () => {}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export interface ShadcnMenubarProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
29
|
-
|
|
30
|
-
export function ShadcnMenubar({ className, children, ...props }: MenubarProps) {
|
|
31
|
-
const [openMenuId, setOpenMenuId] = React.useState<string | null>(null);
|
|
32
|
-
const menubarRef = React.useRef<HTMLDivElement>(null);
|
|
33
|
-
|
|
34
|
-
React.useEffect(() => {
|
|
35
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
36
|
-
if (menubarRef.current && !menubarRef.current.contains(event.target as Node)) {
|
|
37
|
-
setOpenMenuId(null);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
41
|
-
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
42
|
-
}, []);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<MenubarContext.Provider value={{ openMenuId, setOpenMenuId }}>
|
|
46
|
-
<div
|
|
47
|
-
ref={menubarRef}
|
|
48
|
-
role="menubar"
|
|
49
|
-
data-slot="menubar"
|
|
50
|
-
className={cn(
|
|
51
|
-
'h-8 gap-0.5 rounded-lg border border-border bg-background p-[3px] flex items-center shadow-xs text-foreground',
|
|
52
|
-
className
|
|
53
|
-
)}
|
|
54
|
-
{...props}
|
|
55
|
-
>
|
|
56
|
-
{children}
|
|
57
|
-
</div>
|
|
58
|
-
</MenubarContext.Provider>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface MenubarMenuProps {
|
|
63
|
-
children: React.ReactNode;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function MenubarMenu({ children }: MenubarMenuProps) {
|
|
67
|
-
const menuId = React.useId();
|
|
68
|
-
const { openMenuId, setOpenMenuId } = React.useContext(MenubarContext);
|
|
69
|
-
const isOpen = openMenuId === menuId;
|
|
70
|
-
|
|
71
|
-
const setIsOpen = React.useCallback(
|
|
72
|
-
(open: boolean) => {
|
|
73
|
-
setOpenMenuId(open ? menuId : null);
|
|
74
|
-
},
|
|
75
|
-
[menuId, setOpenMenuId]
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<MenuContext.Provider value={{ menuId, isOpen, setIsOpen }}>
|
|
80
|
-
<div data-slot="menubar-menu" className="relative inline-block">
|
|
81
|
-
{children}
|
|
82
|
-
</div>
|
|
83
|
-
</MenuContext.Provider>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface ShadcnMenubarTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {}
|
|
88
|
-
|
|
89
|
-
export function ShadcnMenubarTrigger({
|
|
90
|
-
className,
|
|
91
|
-
onClick,
|
|
92
|
-
onMouseEnter,
|
|
93
|
-
children,
|
|
94
|
-
...props
|
|
95
|
-
}: MenubarTriggerProps) {
|
|
96
|
-
const { isOpen, setIsOpen } = React.useContext(MenuContext);
|
|
97
|
-
const { openMenuId } = React.useContext(MenubarContext);
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<button
|
|
101
|
-
type="button"
|
|
102
|
-
role="menuitem"
|
|
103
|
-
aria-expanded={isOpen}
|
|
104
|
-
data-slot="menubar-trigger"
|
|
105
|
-
onClick={(e) => {
|
|
106
|
-
setIsOpen(!isOpen);
|
|
107
|
-
onClick?.(e);
|
|
108
|
-
}}
|
|
109
|
-
onMouseEnter={(e) => {
|
|
110
|
-
if (openMenuId !== null) {
|
|
111
|
-
setIsOpen(true);
|
|
112
|
-
}
|
|
113
|
-
onMouseEnter?.(e);
|
|
114
|
-
}}
|
|
115
|
-
className={cn(
|
|
116
|
-
'rounded-sm px-1.5 py-[2px] text-sm font-medium hover:bg-muted aria-expanded:bg-muted flex items-center outline-hidden select-none cursor-pointer transition-colors focus-visible:ring-1 focus-visible:ring-ring',
|
|
117
|
-
className
|
|
118
|
-
)}
|
|
119
|
-
{...props}
|
|
120
|
-
>
|
|
121
|
-
{children}
|
|
122
|
-
</button>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface ShadcnMenubarContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
127
|
-
align?: 'start' | 'center' | 'end';
|
|
128
|
-
sideOffset?: number;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function ShadcnMenubarContent({
|
|
132
|
-
className,
|
|
133
|
-
align = 'start',
|
|
134
|
-
sideOffset = 8,
|
|
135
|
-
children,
|
|
136
|
-
...props
|
|
137
|
-
}: MenubarContentProps) {
|
|
138
|
-
const { isOpen } = React.useContext(MenuContext);
|
|
139
|
-
|
|
140
|
-
if (!isOpen) return null;
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<div
|
|
144
|
-
role="menu"
|
|
145
|
-
data-slot="menubar-content"
|
|
146
|
-
data-open=""
|
|
147
|
-
className={cn(
|
|
148
|
-
'z-50 min-w-36 overflow-hidden 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 absolute left-0 top-full mt-1.5',
|
|
149
|
-
align === 'end' && 'right-0 left-auto',
|
|
150
|
-
align === 'center' && 'left-1/2 -translate-x-1/2',
|
|
151
|
-
className
|
|
152
|
-
)}
|
|
153
|
-
{...props}
|
|
154
|
-
>
|
|
155
|
-
{children}
|
|
156
|
-
</div>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export interface ShadcnMenubarItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
161
|
-
inset?: boolean;
|
|
162
|
-
variant?: 'default' | 'destructive';
|
|
163
|
-
disabled?: boolean;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function ShadcnMenubarItem({
|
|
167
|
-
className,
|
|
168
|
-
inset,
|
|
169
|
-
variant = 'default',
|
|
170
|
-
disabled,
|
|
171
|
-
onClick,
|
|
172
|
-
children,
|
|
173
|
-
...props
|
|
174
|
-
}: MenubarItemProps) {
|
|
175
|
-
const { setIsOpen } = React.useContext(MenuContext);
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<div
|
|
179
|
-
role="menuitem"
|
|
180
|
-
tabIndex={disabled ? -1 : 0}
|
|
181
|
-
aria-disabled={disabled}
|
|
182
|
-
data-slot="menubar-item"
|
|
183
|
-
data-inset={inset ? '' : undefined}
|
|
184
|
-
data-variant={variant}
|
|
185
|
-
onClick={(e) => {
|
|
186
|
-
if (disabled) return;
|
|
187
|
-
setIsOpen(false);
|
|
188
|
-
onClick?.(e);
|
|
189
|
-
}}
|
|
190
|
-
className={cn(
|
|
191
|
-
"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 data-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive! group/menubar-item flex items-center cursor-pointer select-none outline-none transition-colors",
|
|
192
|
-
disabled && 'pointer-events-none opacity-50',
|
|
193
|
-
className
|
|
194
|
-
)}
|
|
195
|
-
{...props}
|
|
196
|
-
>
|
|
197
|
-
{children}
|
|
198
|
-
</div>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface MenubarCheckboxItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
203
|
-
checked?: boolean;
|
|
204
|
-
indeterminate?: boolean;
|
|
205
|
-
inset?: boolean;
|
|
206
|
-
disabled?: boolean;
|
|
207
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export function MenubarCheckboxItem({
|
|
211
|
-
className,
|
|
212
|
-
checked = false,
|
|
213
|
-
indeterminate = false,
|
|
214
|
-
inset,
|
|
215
|
-
disabled,
|
|
216
|
-
onCheckedChange,
|
|
217
|
-
onClick,
|
|
218
|
-
children,
|
|
219
|
-
...props
|
|
220
|
-
}: MenubarCheckboxItemProps) {
|
|
221
|
-
return (
|
|
222
|
-
<div
|
|
223
|
-
role="menuitemcheckbox"
|
|
224
|
-
tabIndex={disabled ? -1 : 0}
|
|
225
|
-
aria-checked={checked}
|
|
226
|
-
aria-disabled={disabled}
|
|
227
|
-
data-slot="menubar-checkbox-item"
|
|
228
|
-
data-inset={inset ? '' : undefined}
|
|
229
|
-
onClick={(e) => {
|
|
230
|
-
if (disabled) return;
|
|
231
|
-
onCheckedChange?.(!checked);
|
|
232
|
-
onClick?.(e);
|
|
233
|
-
}}
|
|
234
|
-
className={cn(
|
|
235
|
-
'gap-1.5 rounded-md py-1 pr-1.5 pl-7 text-sm focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 relative flex cursor-pointer items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-colors',
|
|
236
|
-
disabled && 'pointer-events-none opacity-50',
|
|
237
|
-
className
|
|
238
|
-
)}
|
|
239
|
-
{...props}
|
|
240
|
-
>
|
|
241
|
-
<span className="left-1.5 size-4 [&_svg:not([class*='size-'])]:size-4 pointer-events-none absolute flex items-center justify-center">
|
|
242
|
-
{indeterminate ? (
|
|
243
|
-
<Minus className="size-3.5" />
|
|
244
|
-
) : checked ? (
|
|
245
|
-
<Check className="size-3.5" />
|
|
246
|
-
) : null}
|
|
247
|
-
</span>
|
|
248
|
-
{children}
|
|
249
|
-
</div>
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export interface MenubarRadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
254
|
-
value?: string;
|
|
255
|
-
onValueChange?: (value: string) => void;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
interface RadioGroupContextValue {
|
|
259
|
-
value?: string;
|
|
260
|
-
onValueChange?: (value: string) => void;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const RadioGroupContext = React.createContext<RadioGroupContextValue>({});
|
|
264
|
-
|
|
265
|
-
export function MenubarRadioGroup({
|
|
266
|
-
value,
|
|
267
|
-
onValueChange,
|
|
268
|
-
className,
|
|
269
|
-
children,
|
|
270
|
-
...props
|
|
271
|
-
}: MenubarRadioGroupProps) {
|
|
272
|
-
return (
|
|
273
|
-
<RadioGroupContext.Provider value={{ value, onValueChange }}>
|
|
274
|
-
<div data-slot="menubar-radio-group" className={cn('flex flex-col', className)} {...props}>
|
|
275
|
-
{children}
|
|
276
|
-
</div>
|
|
277
|
-
</RadioGroupContext.Provider>
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
export interface MenubarRadioItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
282
|
-
value: string;
|
|
283
|
-
inset?: boolean;
|
|
284
|
-
disabled?: boolean;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export function MenubarRadioItem({
|
|
288
|
-
className,
|
|
289
|
-
value,
|
|
290
|
-
inset,
|
|
291
|
-
disabled,
|
|
292
|
-
onClick,
|
|
293
|
-
children,
|
|
294
|
-
...props
|
|
295
|
-
}: MenubarRadioItemProps) {
|
|
296
|
-
const { value: groupValue, onValueChange } = React.useContext(RadioGroupContext);
|
|
297
|
-
const checked = groupValue === value;
|
|
298
|
-
|
|
299
|
-
return (
|
|
300
|
-
<div
|
|
301
|
-
role="menuitemradio"
|
|
302
|
-
tabIndex={disabled ? -1 : 0}
|
|
303
|
-
aria-checked={checked}
|
|
304
|
-
aria-disabled={disabled}
|
|
305
|
-
data-slot="menubar-radio-item"
|
|
306
|
-
data-inset={inset ? '' : undefined}
|
|
307
|
-
onClick={(e) => {
|
|
308
|
-
if (disabled) return;
|
|
309
|
-
onValueChange?.(value);
|
|
310
|
-
onClick?.(e);
|
|
311
|
-
}}
|
|
312
|
-
className={cn(
|
|
313
|
-
"gap-1.5 rounded-md py-1 pr-1.5 pl-7 text-sm focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-pointer items-center outline-hidden select-none data-disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-colors",
|
|
314
|
-
disabled && 'pointer-events-none opacity-50',
|
|
315
|
-
className
|
|
316
|
-
)}
|
|
317
|
-
{...props}
|
|
318
|
-
>
|
|
319
|
-
<span className="left-1.5 size-4 [&_svg:not([class*='size-'])]:size-4 pointer-events-none absolute flex items-center justify-center">
|
|
320
|
-
{checked && <Check className="size-3.5" />}
|
|
321
|
-
</span>
|
|
322
|
-
{children}
|
|
323
|
-
</div>
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
export interface ShadcnMenubarLabelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
328
|
-
inset?: boolean;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export function ShadcnMenubarLabel({ className, inset, children, ...props }: MenubarLabelProps) {
|
|
332
|
-
return (
|
|
333
|
-
<div
|
|
334
|
-
data-slot="menubar-label"
|
|
335
|
-
data-inset={inset ? '' : undefined}
|
|
336
|
-
className={cn('px-1.5 py-1 text-sm font-medium data-inset:pl-7 text-foreground', className)}
|
|
337
|
-
{...props}
|
|
338
|
-
>
|
|
339
|
-
{children}
|
|
340
|
-
</div>
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
export interface MenubarGroupHeadingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
345
|
-
inset?: boolean;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
export function MenubarGroupHeading({
|
|
349
|
-
className,
|
|
350
|
-
inset,
|
|
351
|
-
children,
|
|
352
|
-
...props
|
|
353
|
-
}: MenubarGroupHeadingProps) {
|
|
354
|
-
return (
|
|
355
|
-
<div
|
|
356
|
-
data-slot="menubar-group-heading"
|
|
357
|
-
data-inset={inset ? '' : undefined}
|
|
358
|
-
className={cn(
|
|
359
|
-
'px-2 py-1.5 text-sm font-medium data-[inset]:ps-8 text-muted-foreground',
|
|
360
|
-
className
|
|
361
|
-
)}
|
|
362
|
-
{...props}
|
|
363
|
-
>
|
|
364
|
-
{children}
|
|
365
|
-
</div>
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
export interface ShadcnMenubarGroupProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
370
|
-
|
|
371
|
-
export function ShadcnMenubarGroup({ className, ...props }: MenubarGroupProps) {
|
|
372
|
-
return <div data-slot="menubar-group" className={cn('flex flex-col', className)} {...props} />;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
export interface ShadcnMenubarSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
376
|
-
|
|
377
|
-
export function ShadcnMenubarSeparator({ className, ...props }: MenubarSeparatorProps) {
|
|
378
|
-
return (
|
|
379
|
-
<div
|
|
380
|
-
role="separator"
|
|
381
|
-
data-slot="menubar-separator"
|
|
382
|
-
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
|
383
|
-
{...props}
|
|
384
|
-
/>
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
export interface ShadcnMenubarShortcutProps extends React.HTMLAttributes<HTMLSpanElement> {}
|
|
389
|
-
|
|
390
|
-
export function ShadcnMenubarShortcut({ className, children, ...props }: MenubarShortcutProps) {
|
|
391
|
-
return (
|
|
392
|
-
<span
|
|
393
|
-
data-slot="menubar-shortcut"
|
|
394
|
-
className={cn(
|
|
395
|
-
'text-xs tracking-widest text-muted-foreground group-focus/menubar-item:text-accent-foreground ml-auto',
|
|
396
|
-
className
|
|
397
|
-
)}
|
|
398
|
-
{...props}
|
|
399
|
-
>
|
|
400
|
-
{children}
|
|
401
|
-
</span>
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
interface SubContextValue {
|
|
406
|
-
isSubOpen: boolean;
|
|
407
|
-
setIsSubOpen: (open: boolean) => void;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
const SubContext = React.createContext<SubContextValue>({
|
|
411
|
-
isSubOpen: false,
|
|
412
|
-
setIsSubOpen: () => {}
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
export interface MenubarSubProps {
|
|
416
|
-
open?: boolean;
|
|
417
|
-
children: React.ReactNode;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
export function MenubarSub({ open = false, children }: MenubarSubProps) {
|
|
421
|
-
const [isSubOpen, setIsSubOpen] = React.useState(open);
|
|
422
|
-
return (
|
|
423
|
-
<SubContext.Provider value={{ isSubOpen, setIsSubOpen }}>
|
|
424
|
-
<div data-slot="menubar-sub" className="relative">
|
|
425
|
-
{children}
|
|
426
|
-
</div>
|
|
427
|
-
</SubContext.Provider>
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
export interface MenubarSubTriggerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
432
|
-
inset?: boolean;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export function MenubarSubTrigger({
|
|
436
|
-
className,
|
|
437
|
-
inset,
|
|
438
|
-
children,
|
|
439
|
-
...props
|
|
440
|
-
}: MenubarSubTriggerProps) {
|
|
441
|
-
const { isSubOpen, setIsSubOpen } = React.useContext(SubContext);
|
|
442
|
-
|
|
443
|
-
return (
|
|
444
|
-
<div
|
|
445
|
-
role="menuitem"
|
|
446
|
-
data-slot="menubar-sub-trigger"
|
|
447
|
-
data-inset={inset ? '' : undefined}
|
|
448
|
-
data-open={isSubOpen ? '' : undefined}
|
|
449
|
-
onMouseEnter={() => setIsSubOpen(true)}
|
|
450
|
-
onMouseLeave={() => setIsSubOpen(false)}
|
|
451
|
-
className={cn(
|
|
452
|
-
"gap-1.5 rounded-md px-1.5 py-1 text-sm focus:bg-accent 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-pointer items-center outline-none select-none transition-colors",
|
|
453
|
-
className
|
|
454
|
-
)}
|
|
455
|
-
{...props}
|
|
456
|
-
>
|
|
457
|
-
{children}
|
|
458
|
-
<ChevronRight className="cn-rtl-flip ml-auto size-4" />
|
|
459
|
-
</div>
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
export interface MenubarSubContentProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
464
|
-
|
|
465
|
-
export function MenubarSubContent({ className, children, ...props }: MenubarSubContentProps) {
|
|
466
|
-
const { isSubOpen } = React.useContext(SubContext);
|
|
467
|
-
if (!isSubOpen) return null;
|
|
468
|
-
|
|
469
|
-
return (
|
|
470
|
-
<div
|
|
471
|
-
data-slot="menubar-sub-content"
|
|
472
|
-
className={cn(
|
|
473
|
-
'min-w-32 rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 animate-in fade-in-0 zoom-in-95 absolute left-full top-0 ml-1 z-50',
|
|
474
|
-
className
|
|
475
|
-
)}
|
|
476
|
-
{...props}
|
|
477
|
-
>
|
|
478
|
-
{children}
|
|
479
|
-
</div>
|
|
480
|
-
);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
export interface ShadcnMenubarPortalProps {
|
|
484
|
-
children: React.ReactNode;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
export function ShadcnMenubarPortal({ children }: MenubarPortalProps) {
|
|
488
|
-
return <>{children}</>;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
export default MinimalistMenubar;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { ChevronDown } from 'lucide-react';
|
|
4
|
-
import { cn } from '@surreal-ui/core';
|
|
5
|
-
|
|
6
|
-
export interface ShadcnNativeSelectProps extends Omit<React.ComponentProps<'select'>, 'size'> {
|
|
7
|
-
size?: 'sm' | 'default';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const ShadcnNativeSelect = React.forwardRef<HTMLSelectElement, NativeSelectProps>(
|
|
11
|
-
({ className, size = 'default', children, ...props }, ref) => {
|
|
12
|
-
return (
|
|
13
|
-
<div
|
|
14
|
-
className={cn(
|
|
15
|
-
'cn-native-select-wrapper group/native-select relative w-fit has-[select:disabled]:opacity-50',
|
|
16
|
-
className
|
|
17
|
-
)}
|
|
18
|
-
data-slot="native-select-wrapper"
|
|
19
|
-
data-size={size}
|
|
20
|
-
>
|
|
21
|
-
<select
|
|
22
|
-
ref={ref}
|
|
23
|
-
data-slot="native-select"
|
|
24
|
-
data-size={size}
|
|
25
|
-
className="h-8 w-full min-w-0 appearance-none rounded-lg border border-input bg-transparent py-1 pr-8 pl-2.5 text-sm transition-colors select-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[size=sm]:py-0.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 outline-none disabled:pointer-events-none disabled:cursor-not-allowed"
|
|
26
|
-
{...props}
|
|
27
|
-
>
|
|
28
|
-
{children}
|
|
29
|
-
</select>
|
|
30
|
-
<ChevronDown
|
|
31
|
-
className="top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground pointer-events-none absolute select-none"
|
|
32
|
-
aria-hidden="true"
|
|
33
|
-
data-slot="native-select-icon"
|
|
34
|
-
/>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
NativeSelect.displayName = 'NativeSelect';
|
|
40
|
-
|
|
41
|
-
export interface NativeSelectOptGroupProps extends React.ComponentProps<'optgroup'> {}
|
|
42
|
-
|
|
43
|
-
export const NativeSelectOptGroup = React.forwardRef<
|
|
44
|
-
HTMLOptGroupElement,
|
|
45
|
-
NativeSelectOptGroupProps
|
|
46
|
-
>(({ className, children, ...props }, ref) => {
|
|
47
|
-
return (
|
|
48
|
-
<optgroup ref={ref} data-slot="native-select-opt-group" className={className} {...props}>
|
|
49
|
-
{children}
|
|
50
|
-
</optgroup>
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
NativeSelectOptGroup.displayName = 'NativeSelectOptGroup';
|
|
54
|
-
|
|
55
|
-
export interface NativeSelectOptionProps extends React.ComponentProps<'option'> {}
|
|
56
|
-
|
|
57
|
-
export const NativeSelectOption = React.forwardRef<HTMLOptionElement, NativeSelectOptionProps>(
|
|
58
|
-
({ className, children, ...props }, ref) => {
|
|
59
|
-
return (
|
|
60
|
-
<option
|
|
61
|
-
ref={ref}
|
|
62
|
-
data-slot="native-select-option"
|
|
63
|
-
className={cn('bg-[Canvas] text-[CanvasText]', className)}
|
|
64
|
-
{...props}
|
|
65
|
-
>
|
|
66
|
-
{children}
|
|
67
|
-
</option>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
NativeSelectOption.displayName = 'NativeSelectOption';
|
|
72
|
-
|
|
73
|
-
export const Root = NativeSelect;
|
|
74
|
-
export const OptGroup = NativeSelectOptGroup;
|
|
75
|
-
export const Option = NativeSelectOption;
|
|
76
|
-
|
|
77
|
-
export default MinimalistNativeSelect;
|