@enya-learning/nova 0.4.0 → 0.4.1

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