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