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