@voila.dev/ui 1.1.9

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 (99) hide show
  1. package/package.json +78 -0
  2. package/src/components/ui/accordion.tsx +79 -0
  3. package/src/components/ui/alert-dialog.tsx +198 -0
  4. package/src/components/ui/alert.tsx +105 -0
  5. package/src/components/ui/aspect-ratio.tsx +30 -0
  6. package/src/components/ui/avatar.tsx +125 -0
  7. package/src/components/ui/badge-variants.ts +166 -0
  8. package/src/components/ui/badge.tsx +45 -0
  9. package/src/components/ui/banner.tsx +84 -0
  10. package/src/components/ui/breadcrumb.tsx +127 -0
  11. package/src/components/ui/button-group.tsx +99 -0
  12. package/src/components/ui/button-variants.ts +108 -0
  13. package/src/components/ui/button.tsx +54 -0
  14. package/src/components/ui/calendar.tsx +266 -0
  15. package/src/components/ui/card.tsx +155 -0
  16. package/src/components/ui/carousel.tsx +319 -0
  17. package/src/components/ui/chat.tsx +896 -0
  18. package/src/components/ui/checkbox-group.tsx +44 -0
  19. package/src/components/ui/checkbox.tsx +34 -0
  20. package/src/components/ui/chip.tsx +60 -0
  21. package/src/components/ui/collapsible.tsx +44 -0
  22. package/src/components/ui/color-picker.tsx +191 -0
  23. package/src/components/ui/combobox.tsx +317 -0
  24. package/src/components/ui/command.tsx +187 -0
  25. package/src/components/ui/confirm-dialog.tsx +125 -0
  26. package/src/components/ui/context-menu.tsx +254 -0
  27. package/src/components/ui/copyable-text.tsx +65 -0
  28. package/src/components/ui/date-picker.tsx +316 -0
  29. package/src/components/ui/date-time-picker.tsx +1071 -0
  30. package/src/components/ui/dialog.tsx +176 -0
  31. package/src/components/ui/direction.tsx +15 -0
  32. package/src/components/ui/drawer.tsx +178 -0
  33. package/src/components/ui/dropdown-menu.tsx +247 -0
  34. package/src/components/ui/empty.tsx +131 -0
  35. package/src/components/ui/field.tsx +257 -0
  36. package/src/components/ui/formatted-input.tsx +219 -0
  37. package/src/components/ui/gallery.tsx +161 -0
  38. package/src/components/ui/hover-card.tsx +77 -0
  39. package/src/components/ui/icon-picker.tsx +193 -0
  40. package/src/components/ui/image-cropper.tsx +787 -0
  41. package/src/components/ui/image-upload-field.tsx +344 -0
  42. package/src/components/ui/input-group.tsx +175 -0
  43. package/src/components/ui/input-otp.tsx +83 -0
  44. package/src/components/ui/input.tsx +21 -0
  45. package/src/components/ui/item.tsx +212 -0
  46. package/src/components/ui/kbd.tsx +62 -0
  47. package/src/components/ui/label.tsx +19 -0
  48. package/src/components/ui/list.tsx +46 -0
  49. package/src/components/ui/menu-variants.ts +71 -0
  50. package/src/components/ui/menubar.tsx +226 -0
  51. package/src/components/ui/money-input.tsx +96 -0
  52. package/src/components/ui/native-date-picker.tsx +120 -0
  53. package/src/components/ui/native-select.tsx +74 -0
  54. package/src/components/ui/navigation-menu.tsx +183 -0
  55. package/src/components/ui/pagination.tsx +150 -0
  56. package/src/components/ui/popover.tsx +104 -0
  57. package/src/components/ui/profile-header.tsx +196 -0
  58. package/src/components/ui/progress.tsx +71 -0
  59. package/src/components/ui/radio-group.tsx +115 -0
  60. package/src/components/ui/rating.tsx +200 -0
  61. package/src/components/ui/resizable.tsx +61 -0
  62. package/src/components/ui/responsive-dialog.tsx +278 -0
  63. package/src/components/ui/responsive-select.tsx +289 -0
  64. package/src/components/ui/responsive-sheet.tsx +225 -0
  65. package/src/components/ui/scroll-area.tsx +51 -0
  66. package/src/components/ui/section.tsx +106 -0
  67. package/src/components/ui/segmented-control.tsx +148 -0
  68. package/src/components/ui/select.tsx +216 -0
  69. package/src/components/ui/separator.tsx +69 -0
  70. package/src/components/ui/sheet.tsx +154 -0
  71. package/src/components/ui/shortcut.tsx +41 -0
  72. package/src/components/ui/sidebar.tsx +739 -0
  73. package/src/components/ui/skeleton.tsx +23 -0
  74. package/src/components/ui/slider.tsx +74 -0
  75. package/src/components/ui/sonner.tsx +64 -0
  76. package/src/components/ui/spinner.tsx +19 -0
  77. package/src/components/ui/stat-card.tsx +138 -0
  78. package/src/components/ui/stepper.tsx +181 -0
  79. package/src/components/ui/sticky-action-bar.tsx +42 -0
  80. package/src/components/ui/switch.tsx +30 -0
  81. package/src/components/ui/table.tsx +132 -0
  82. package/src/components/ui/tabs.tsx +77 -0
  83. package/src/components/ui/textarea.tsx +24 -0
  84. package/src/components/ui/time-picker.tsx +221 -0
  85. package/src/components/ui/toggle-group.tsx +86 -0
  86. package/src/components/ui/toggle.tsx +43 -0
  87. package/src/components/ui/tooltip.tsx +79 -0
  88. package/src/components/ui/translation-input.tsx +126 -0
  89. package/src/components/ui/user-avatar.tsx +74 -0
  90. package/src/css-modules.d.ts +4 -0
  91. package/src/hooks/use-command-palette.ts +28 -0
  92. package/src/hooks/use-mobile.ts +21 -0
  93. package/src/hooks/use-pagination.ts +81 -0
  94. package/src/hooks/use-picker-state.ts +44 -0
  95. package/src/lib/cva.ts +18 -0
  96. package/src/lib/time-math.ts +62 -0
  97. package/src/lib/utils.ts +14 -0
  98. package/src/styles/globals.css +36 -0
  99. package/src/styles.css +10 -0
@@ -0,0 +1,739 @@
1
+ import { mergeProps } from "@base-ui/react/merge-props";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ import { SidebarSimpleIcon } from "@phosphor-icons/react";
4
+ import * as React from "react";
5
+ import { Button } from "#/components/ui/button.tsx";
6
+ import { Input } from "#/components/ui/input.tsx";
7
+ import { Separator } from "#/components/ui/separator.tsx";
8
+ import {
9
+ Sheet,
10
+ SheetContent,
11
+ SheetDescription,
12
+ SheetHeader,
13
+ SheetTitle,
14
+ } from "#/components/ui/sheet.tsx";
15
+ import { Skeleton } from "#/components/ui/skeleton.tsx";
16
+ import {
17
+ Tooltip,
18
+ TooltipContent,
19
+ TooltipTrigger,
20
+ } from "#/components/ui/tooltip.tsx";
21
+ import { useIsMobile } from "#/hooks/use-mobile.ts";
22
+ import { cva, type VariantProps } from "#/lib/cva.ts";
23
+ import { cn } from "#/lib/utils.ts";
24
+
25
+ // Widths are CSS variables: override per instance with
26
+ // style={{ "--sidebar-width": "20rem" }} on SidebarProvider.
27
+ const SIDEBAR_WIDTH = "16rem";
28
+ const SIDEBAR_WIDTH_MOBILE = "18rem";
29
+ const SIDEBAR_WIDTH_ICON = "3rem";
30
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b";
31
+
32
+ type SidebarContextProps = {
33
+ state: "expanded" | "collapsed";
34
+ open: boolean;
35
+ setOpen: (open: boolean) => void;
36
+ openMobile: boolean;
37
+ setOpenMobile: (open: boolean) => void;
38
+ isMobile: boolean;
39
+ toggleSidebar: () => void;
40
+ };
41
+
42
+ const SidebarContext = React.createContext<SidebarContextProps | null>(null);
43
+
44
+ function useSidebar() {
45
+ const context = React.useContext(SidebarContext);
46
+ if (!context) {
47
+ throw new Error("useSidebar must be used within a SidebarProvider.");
48
+ }
49
+
50
+ return context;
51
+ }
52
+
53
+ function SidebarProvider({
54
+ defaultOpen = true,
55
+ open: openProp,
56
+ onOpenChange: setOpenProp,
57
+ keyboardShortcut = SIDEBAR_KEYBOARD_SHORTCUT,
58
+ className,
59
+ style,
60
+ children,
61
+ ...props
62
+ }: React.ComponentProps<"div"> & {
63
+ defaultOpen?: boolean;
64
+ open?: boolean;
65
+ onOpenChange?: (open: boolean) => void;
66
+ keyboardShortcut?: string | false;
67
+ }) {
68
+ const isMobile = useIsMobile();
69
+ const [openMobile, setOpenMobile] = React.useState(false);
70
+
71
+ // This is the internal state of the sidebar.
72
+ // We use openProp and setOpenProp for control from outside the component.
73
+ const [_open, _setOpen] = React.useState(defaultOpen);
74
+ const open = openProp ?? _open;
75
+ const setOpen = React.useCallback(
76
+ (value: boolean | ((value: boolean) => boolean)) => {
77
+ const openState = typeof value === "function" ? value(open) : value;
78
+ if (setOpenProp) {
79
+ setOpenProp(openState);
80
+ } else {
81
+ _setOpen(openState);
82
+ }
83
+ },
84
+ [setOpenProp, open],
85
+ );
86
+
87
+ // Helper to toggle the sidebar.
88
+ const toggleSidebar = React.useCallback(() => {
89
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
90
+ }, [isMobile, setOpen, setOpenMobile]);
91
+
92
+ // Adds a keyboard shortcut to toggle the sidebar.
93
+ React.useEffect(() => {
94
+ if (keyboardShortcut === false) {
95
+ return;
96
+ }
97
+
98
+ const handleKeyDown = (event: KeyboardEvent) => {
99
+ if (event.key === keyboardShortcut && (event.metaKey || event.ctrlKey)) {
100
+ event.preventDefault();
101
+ toggleSidebar();
102
+ }
103
+ };
104
+
105
+ window.addEventListener("keydown", handleKeyDown);
106
+ return () => window.removeEventListener("keydown", handleKeyDown);
107
+ }, [keyboardShortcut, toggleSidebar]);
108
+
109
+ // We add a state so that we can do data-state="expanded" or "collapsed".
110
+ // This makes it easier to style the sidebar with Tailwind classes.
111
+ const state = open ? "expanded" : "collapsed";
112
+
113
+ const contextValue = React.useMemo<SidebarContextProps>(
114
+ () => ({
115
+ state,
116
+ open,
117
+ setOpen,
118
+ isMobile,
119
+ openMobile,
120
+ setOpenMobile,
121
+ toggleSidebar,
122
+ }),
123
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
124
+ );
125
+
126
+ return (
127
+ <SidebarContext.Provider value={contextValue}>
128
+ <div
129
+ data-slot="sidebar-wrapper"
130
+ style={
131
+ {
132
+ "--sidebar-width": SIDEBAR_WIDTH,
133
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
134
+ ...style,
135
+ } as React.CSSProperties
136
+ }
137
+ className={cn(
138
+ "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
139
+ className,
140
+ )}
141
+ {...props}
142
+ >
143
+ {children}
144
+ </div>
145
+ </SidebarContext.Provider>
146
+ );
147
+ }
148
+
149
+ function Sidebar({
150
+ side = "left",
151
+ variant = "sidebar",
152
+ collapsible = "offcanvas",
153
+ sheetTitle = "Sidebar",
154
+ sheetDescription = "Displays the mobile sidebar.",
155
+ className,
156
+ style,
157
+ children,
158
+ ...props
159
+ }: React.ComponentProps<"div"> & {
160
+ side?: "left" | "right";
161
+ variant?: "sidebar" | "floating" | "inset";
162
+ collapsible?: "offcanvas" | "icon" | "none";
163
+ sheetTitle?: string;
164
+ sheetDescription?: string;
165
+ }) {
166
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
167
+
168
+ if (collapsible === "none") {
169
+ return (
170
+ <div
171
+ data-slot="sidebar"
172
+ className={cn(
173
+ "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
174
+ className,
175
+ )}
176
+ style={style}
177
+ {...props}
178
+ >
179
+ {children}
180
+ </div>
181
+ );
182
+ }
183
+
184
+ if (isMobile) {
185
+ return (
186
+ <Sheet open={openMobile} onOpenChange={setOpenMobile}>
187
+ <SheetContent
188
+ data-sidebar="sidebar"
189
+ data-slot="sidebar"
190
+ data-mobile="true"
191
+ className={cn(
192
+ "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",
193
+ className,
194
+ )}
195
+ style={
196
+ {
197
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
198
+ ...style,
199
+ } as React.CSSProperties
200
+ }
201
+ side={side}
202
+ {...props}
203
+ >
204
+ <SheetHeader className="sr-only">
205
+ <SheetTitle>{sheetTitle}</SheetTitle>
206
+ <SheetDescription>{sheetDescription}</SheetDescription>
207
+ </SheetHeader>
208
+ <div className="flex h-full w-full flex-col">{children}</div>
209
+ </SheetContent>
210
+ </Sheet>
211
+ );
212
+ }
213
+
214
+ return (
215
+ <div
216
+ className="group peer hidden text-sidebar-foreground md:block"
217
+ data-state={state}
218
+ data-collapsible={state === "collapsed" ? collapsible : ""}
219
+ data-variant={variant}
220
+ data-side={side}
221
+ data-slot="sidebar"
222
+ >
223
+ {/* This is what handles the sidebar gap on desktop */}
224
+ <div
225
+ data-slot="sidebar-gap"
226
+ className={cn(
227
+ "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-in-out motion-reduce:transition-none",
228
+ "group-data-[collapsible=offcanvas]:w-0",
229
+ "group-data-[side=right]:rotate-180",
230
+ variant === "floating" || variant === "inset"
231
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
232
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
233
+ )}
234
+ />
235
+ <div
236
+ data-slot="sidebar-container"
237
+ data-side={side}
238
+ className={cn(
239
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-in-out data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex motion-reduce:transition-none",
240
+ // Adjust the padding for floating and inset variants.
241
+ variant === "floating" || variant === "inset"
242
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
243
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
244
+ className,
245
+ )}
246
+ style={style}
247
+ {...props}
248
+ >
249
+ <div
250
+ data-sidebar="sidebar"
251
+ data-slot="sidebar-inner"
252
+ className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
253
+ >
254
+ {children}
255
+ </div>
256
+ </div>
257
+ </div>
258
+ );
259
+ }
260
+
261
+ function SidebarTrigger({
262
+ className,
263
+ onClick,
264
+ children,
265
+ ...props
266
+ }: React.ComponentProps<typeof Button>) {
267
+ const { toggleSidebar } = useSidebar();
268
+
269
+ return (
270
+ <Button
271
+ data-sidebar="trigger"
272
+ data-slot="sidebar-trigger"
273
+ variant="ghost"
274
+ size="icon-sm"
275
+ className={className}
276
+ onClick={(event) => {
277
+ onClick?.(event);
278
+ toggleSidebar();
279
+ }}
280
+ {...props}
281
+ >
282
+ {children ?? (
283
+ <>
284
+ <SidebarSimpleIcon />
285
+ <span className="sr-only">Toggle Sidebar</span>
286
+ </>
287
+ )}
288
+ </Button>
289
+ );
290
+ }
291
+
292
+ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
293
+ const { toggleSidebar } = useSidebar();
294
+
295
+ return (
296
+ <button
297
+ data-sidebar="rail"
298
+ data-slot="sidebar-rail"
299
+ aria-label="Toggle Sidebar"
300
+ tabIndex={-1}
301
+ onClick={toggleSidebar}
302
+ title="Toggle Sidebar"
303
+ className={cn(
304
+ "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-in-out group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex motion-reduce:transition-none",
305
+ "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
306
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
307
+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
308
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
309
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
310
+ className,
311
+ )}
312
+ {...props}
313
+ />
314
+ );
315
+ }
316
+
317
+ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
318
+ return (
319
+ <main
320
+ data-slot="sidebar-inset"
321
+ className={cn(
322
+ "relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
323
+ className,
324
+ )}
325
+ {...props}
326
+ />
327
+ );
328
+ }
329
+
330
+ function SidebarInput({
331
+ className,
332
+ ...props
333
+ }: React.ComponentProps<typeof Input>) {
334
+ return (
335
+ <Input
336
+ data-slot="sidebar-input"
337
+ data-sidebar="input"
338
+ className={cn("h-8 w-full bg-background shadow-none", className)}
339
+ {...props}
340
+ />
341
+ );
342
+ }
343
+
344
+ function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
345
+ return (
346
+ <div
347
+ data-slot="sidebar-header"
348
+ data-sidebar="header"
349
+ className={cn("flex flex-col gap-2 p-2", className)}
350
+ {...props}
351
+ />
352
+ );
353
+ }
354
+
355
+ function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
356
+ return (
357
+ <div
358
+ data-slot="sidebar-footer"
359
+ data-sidebar="footer"
360
+ className={cn("flex flex-col gap-2 p-2", className)}
361
+ {...props}
362
+ />
363
+ );
364
+ }
365
+
366
+ function SidebarSeparator({
367
+ className,
368
+ ...props
369
+ }: React.ComponentProps<typeof Separator>) {
370
+ return (
371
+ <Separator
372
+ data-slot="sidebar-separator"
373
+ data-sidebar="separator"
374
+ className={cn("mx-2 w-auto bg-sidebar-border", className)}
375
+ {...props}
376
+ />
377
+ );
378
+ }
379
+
380
+ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
381
+ return (
382
+ <div
383
+ data-slot="sidebar-content"
384
+ data-sidebar="content"
385
+ className={cn(
386
+ "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
387
+ className,
388
+ )}
389
+ {...props}
390
+ />
391
+ );
392
+ }
393
+
394
+ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
395
+ return (
396
+ <div
397
+ data-slot="sidebar-group"
398
+ data-sidebar="group"
399
+ className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
400
+ {...props}
401
+ />
402
+ );
403
+ }
404
+
405
+ function SidebarGroupLabel({
406
+ className,
407
+ render,
408
+ ...props
409
+ }: useRender.ComponentProps<"div"> & React.ComponentProps<"div">) {
410
+ return useRender({
411
+ defaultTagName: "div",
412
+ props: mergeProps<"div">(
413
+ {
414
+ className: cn(
415
+ "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-in-out group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 motion-reduce:transition-none [&>svg]:size-4 [&>svg]:shrink-0",
416
+ className,
417
+ ),
418
+ },
419
+ props,
420
+ ),
421
+ render,
422
+ state: {
423
+ slot: "sidebar-group-label",
424
+ sidebar: "group-label",
425
+ },
426
+ });
427
+ }
428
+
429
+ function SidebarGroupAction({
430
+ className,
431
+ render,
432
+ ...props
433
+ }: useRender.ComponentProps<"button"> & React.ComponentProps<"button">) {
434
+ return useRender({
435
+ defaultTagName: "button",
436
+ props: mergeProps<"button">(
437
+ {
438
+ className: cn(
439
+ "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
440
+ className,
441
+ ),
442
+ },
443
+ props,
444
+ ),
445
+ render,
446
+ state: {
447
+ slot: "sidebar-group-action",
448
+ sidebar: "group-action",
449
+ },
450
+ });
451
+ }
452
+
453
+ function SidebarGroupContent({
454
+ className,
455
+ ...props
456
+ }: React.ComponentProps<"div">) {
457
+ return (
458
+ <div
459
+ data-slot="sidebar-group-content"
460
+ data-sidebar="group-content"
461
+ className={cn("w-full text-sm", className)}
462
+ {...props}
463
+ />
464
+ );
465
+ }
466
+
467
+ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
468
+ return (
469
+ <ul
470
+ data-slot="sidebar-menu"
471
+ data-sidebar="menu"
472
+ className={cn("flex w-full min-w-0 flex-col gap-0", className)}
473
+ {...props}
474
+ />
475
+ );
476
+ }
477
+
478
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
479
+ return (
480
+ <li
481
+ data-slot="sidebar-menu-item"
482
+ data-sidebar="menu-item"
483
+ className={cn("group/menu-item relative", className)}
484
+ {...props}
485
+ />
486
+ );
487
+ }
488
+
489
+ const sidebarMenuButtonVariants = cva({
490
+ base: "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-popup-open:hover:bg-sidebar-accent data-popup-open:hover:text-sidebar-accent-foreground data-panel-open:hover:bg-sidebar-accent data-panel-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
491
+ variants: {
492
+ variant: {
493
+ default: "",
494
+ outline:
495
+ "bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]",
496
+ },
497
+ size: {
498
+ default: "h-8 text-sm",
499
+ sm: "h-7 text-xs",
500
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
501
+ },
502
+ },
503
+ defaultVariants: {
504
+ variant: "default",
505
+ size: "default",
506
+ },
507
+ });
508
+
509
+ function SidebarMenuButton({
510
+ render,
511
+ isActive = false,
512
+ variant = "default",
513
+ size = "default",
514
+ tooltip,
515
+ className,
516
+ ...props
517
+ }: useRender.ComponentProps<"button"> &
518
+ React.ComponentProps<"button"> & {
519
+ isActive?: boolean;
520
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>;
521
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
522
+ const { isMobile, state } = useSidebar();
523
+ const comp = useRender({
524
+ defaultTagName: "button",
525
+ props: mergeProps<"button">(
526
+ {
527
+ className: cn(sidebarMenuButtonVariants({ variant, size }), className),
528
+ },
529
+ props,
530
+ ),
531
+ render: !tooltip ? render : <TooltipTrigger render={render} />,
532
+ state: {
533
+ slot: "sidebar-menu-button",
534
+ sidebar: "menu-button",
535
+ size,
536
+ active: isActive,
537
+ },
538
+ });
539
+
540
+ if (!tooltip) {
541
+ return comp;
542
+ }
543
+
544
+ if (typeof tooltip === "string") {
545
+ tooltip = {
546
+ children: tooltip,
547
+ };
548
+ }
549
+
550
+ return (
551
+ <Tooltip>
552
+ {comp}
553
+ <TooltipContent
554
+ side="right"
555
+ align="center"
556
+ hidden={state !== "collapsed" || isMobile}
557
+ {...tooltip}
558
+ />
559
+ </Tooltip>
560
+ );
561
+ }
562
+
563
+ function SidebarMenuAction({
564
+ className,
565
+ render,
566
+ showOnHover = false,
567
+ ...props
568
+ }: useRender.ComponentProps<"button"> &
569
+ React.ComponentProps<"button"> & {
570
+ showOnHover?: boolean;
571
+ }) {
572
+ return useRender({
573
+ defaultTagName: "button",
574
+ props: mergeProps<"button">(
575
+ {
576
+ className: cn(
577
+ "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
578
+ showOnHover &&
579
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
580
+ className,
581
+ ),
582
+ },
583
+ props,
584
+ ),
585
+ render,
586
+ state: {
587
+ slot: "sidebar-menu-action",
588
+ sidebar: "menu-action",
589
+ },
590
+ });
591
+ }
592
+
593
+ function SidebarMenuBadge({
594
+ className,
595
+ ...props
596
+ }: React.ComponentProps<"div">) {
597
+ return (
598
+ <div
599
+ data-slot="sidebar-menu-badge"
600
+ data-sidebar="menu-badge"
601
+ className={cn(
602
+ "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
603
+ className,
604
+ )}
605
+ {...props}
606
+ />
607
+ );
608
+ }
609
+
610
+ function SidebarMenuSkeleton({
611
+ className,
612
+ showIcon = false,
613
+ ...props
614
+ }: React.ComponentProps<"div"> & {
615
+ showIcon?: boolean;
616
+ }) {
617
+ // Deterministic width between 50 and 90% derived from useId so server and
618
+ // client render the same markup (Math.random() caused hydration mismatches).
619
+ const id = React.useId();
620
+ const width = React.useMemo(() => {
621
+ let hash = 0;
622
+ for (const character of id) {
623
+ hash = (hash * 31 + character.charCodeAt(0)) % 41;
624
+ }
625
+ return `${hash + 50}%`;
626
+ }, [id]);
627
+
628
+ return (
629
+ <div
630
+ data-slot="sidebar-menu-skeleton"
631
+ data-sidebar="menu-skeleton"
632
+ className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
633
+ {...props}
634
+ >
635
+ {showIcon && (
636
+ <Skeleton
637
+ className="size-4 rounded-md"
638
+ data-sidebar="menu-skeleton-icon"
639
+ />
640
+ )}
641
+ <Skeleton
642
+ className="h-4 max-w-(--skeleton-width) flex-1"
643
+ data-sidebar="menu-skeleton-text"
644
+ style={
645
+ {
646
+ "--skeleton-width": width,
647
+ } as React.CSSProperties
648
+ }
649
+ />
650
+ </div>
651
+ );
652
+ }
653
+
654
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
655
+ return (
656
+ <ul
657
+ data-slot="sidebar-menu-sub"
658
+ data-sidebar="menu-sub"
659
+ className={cn(
660
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
661
+ className,
662
+ )}
663
+ {...props}
664
+ />
665
+ );
666
+ }
667
+
668
+ function SidebarMenuSubItem({
669
+ className,
670
+ ...props
671
+ }: React.ComponentProps<"li">) {
672
+ return (
673
+ <li
674
+ data-slot="sidebar-menu-sub-item"
675
+ data-sidebar="menu-sub-item"
676
+ className={cn("group/menu-sub-item relative", className)}
677
+ {...props}
678
+ />
679
+ );
680
+ }
681
+
682
+ function SidebarMenuSubButton({
683
+ render,
684
+ size = "default",
685
+ isActive = false,
686
+ className,
687
+ ...props
688
+ }: useRender.ComponentProps<"a"> &
689
+ React.ComponentProps<"a"> & {
690
+ size?: "sm" | "default";
691
+ isActive?: boolean;
692
+ }) {
693
+ return useRender({
694
+ defaultTagName: "a",
695
+ props: mergeProps<"a">(
696
+ {
697
+ className: cn(
698
+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=default]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
699
+ className,
700
+ ),
701
+ },
702
+ props,
703
+ ),
704
+ render,
705
+ state: {
706
+ slot: "sidebar-menu-sub-button",
707
+ sidebar: "menu-sub-button",
708
+ size,
709
+ active: isActive,
710
+ },
711
+ });
712
+ }
713
+
714
+ export {
715
+ Sidebar,
716
+ SidebarContent,
717
+ SidebarFooter,
718
+ SidebarGroup,
719
+ SidebarGroupAction,
720
+ SidebarGroupContent,
721
+ SidebarGroupLabel,
722
+ SidebarHeader,
723
+ SidebarInput,
724
+ SidebarInset,
725
+ SidebarMenu,
726
+ SidebarMenuAction,
727
+ SidebarMenuBadge,
728
+ SidebarMenuButton,
729
+ SidebarMenuItem,
730
+ SidebarMenuSkeleton,
731
+ SidebarMenuSub,
732
+ SidebarMenuSubButton,
733
+ SidebarMenuSubItem,
734
+ SidebarProvider,
735
+ SidebarRail,
736
+ SidebarSeparator,
737
+ SidebarTrigger,
738
+ useSidebar,
739
+ };