create-next-imagicma 0.1.11 → 0.1.13

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 (96) hide show
  1. package/README.md +0 -2
  2. package/package.json +1 -1
  3. package/template-hono/AGENTS.md +53 -95
  4. package/template-hono/README.md +3 -31
  5. package/template-hono/client/public/imagicma-picker-bridge.js +6 -2
  6. package/template-hono/client/public/imagicma-preview-feedback.js +1 -0
  7. package/template-hono/client/src/lib/imagicma-preview-bridge.ts +1 -1
  8. package/template-hono/client/src/lib/imagicma-preview-picker.ts +130 -28
  9. package/template-hono/vite.config.ts +1 -1
  10. package/template/.env.example +0 -10
  11. package/template/AGENTS.md +0 -225
  12. package/template/README.md +0 -34
  13. package/template/app/_components/DevPreviewShield.tsx +0 -638
  14. package/template/app/api/greeting/route.ts +0 -27
  15. package/template/app/error.tsx +0 -93
  16. package/template/app/favicon.ico +0 -0
  17. package/template/app/globals.css +0 -767
  18. package/template/app/hello/_components/HelloClient.tsx +0 -94
  19. package/template/app/hello/page.tsx +0 -23
  20. package/template/app/layout.tsx +0 -32
  21. package/template/app/page.tsx +0 -27
  22. package/template/app/providers.tsx +0 -25
  23. package/template/components/ui/accordion.tsx +0 -58
  24. package/template/components/ui/alert-dialog.tsx +0 -141
  25. package/template/components/ui/alert.tsx +0 -61
  26. package/template/components/ui/aspect-ratio.tsx +0 -7
  27. package/template/components/ui/avatar.tsx +0 -51
  28. package/template/components/ui/badge.tsx +0 -40
  29. package/template/components/ui/breadcrumb.tsx +0 -117
  30. package/template/components/ui/button.tsx +0 -64
  31. package/template/components/ui/calendar.tsx +0 -72
  32. package/template/components/ui/card.tsx +0 -87
  33. package/template/components/ui/carousel.tsx +0 -262
  34. package/template/components/ui/chart.tsx +0 -365
  35. package/template/components/ui/checkbox.tsx +0 -30
  36. package/template/components/ui/collapsible.tsx +0 -11
  37. package/template/components/ui/command.tsx +0 -153
  38. package/template/components/ui/context-menu.tsx +0 -200
  39. package/template/components/ui/dialog.tsx +0 -122
  40. package/template/components/ui/drawer.tsx +0 -118
  41. package/template/components/ui/dropdown-menu.tsx +0 -200
  42. package/template/components/ui/form.tsx +0 -178
  43. package/template/components/ui/hover-card.tsx +0 -29
  44. package/template/components/ui/input-otp.tsx +0 -71
  45. package/template/components/ui/input.tsx +0 -25
  46. package/template/components/ui/label.tsx +0 -26
  47. package/template/components/ui/menubar.tsx +0 -256
  48. package/template/components/ui/navigation-menu.tsx +0 -130
  49. package/template/components/ui/pagination.tsx +0 -119
  50. package/template/components/ui/popover.tsx +0 -31
  51. package/template/components/ui/progress.tsx +0 -28
  52. package/template/components/ui/radio-group.tsx +0 -44
  53. package/template/components/ui/resizable.tsx +0 -45
  54. package/template/components/ui/scroll-area.tsx +0 -48
  55. package/template/components/ui/select.tsx +0 -160
  56. package/template/components/ui/separator.tsx +0 -31
  57. package/template/components/ui/sheet.tsx +0 -140
  58. package/template/components/ui/sidebar.tsx +0 -732
  59. package/template/components/ui/skeleton.tsx +0 -17
  60. package/template/components/ui/slider.tsx +0 -28
  61. package/template/components/ui/switch.tsx +0 -29
  62. package/template/components/ui/table.tsx +0 -119
  63. package/template/components/ui/tabs.tsx +0 -55
  64. package/template/components/ui/textarea.tsx +0 -24
  65. package/template/components/ui/toast.tsx +0 -129
  66. package/template/components/ui/toaster.tsx +0 -35
  67. package/template/components/ui/toggle-group.tsx +0 -61
  68. package/template/components/ui/toggle.tsx +0 -45
  69. package/template/components/ui/tooltip.tsx +0 -30
  70. package/template/drizzle.config.ts +0 -50
  71. package/template/eslint.config.mjs +0 -18
  72. package/template/gitignore +0 -46
  73. package/template/hooks/use-greeting.ts +0 -15
  74. package/template/hooks/use-mobile.ts +0 -21
  75. package/template/hooks/use-toast.ts +0 -194
  76. package/template/lib/queryClient.ts +0 -59
  77. package/template/lib/theme/default-theme.ts +0 -11
  78. package/template/lib/utils.ts +0 -6
  79. package/template/next.config.ts +0 -8
  80. package/template/package.json +0 -76
  81. package/template/pnpm-lock.yaml +0 -6937
  82. package/template/postcss.config.mjs +0 -7
  83. package/template/process-compose.yaml +0 -13
  84. package/template/public/file.svg +0 -1
  85. package/template/public/globe.svg +0 -1
  86. package/template/public/imagicma-picker-bridge.js +0 -374
  87. package/template/public/next.svg +0 -1
  88. package/template/public/vercel.svg +0 -1
  89. package/template/public/window.svg +0 -1
  90. package/template/server/db.ts +0 -24
  91. package/template/server/storage.ts +0 -41
  92. package/template/shared/routes.ts +0 -13
  93. package/template/shared/schema.ts +0 -17
  94. package/template/tailwind.config.mjs +0 -96
  95. package/template/tsconfig.json +0 -35
  96. package/template/types/pg.d.ts +0 -19
@@ -1,732 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import { Slot } from "@radix-ui/react-slot"
5
- import { cva, VariantProps } from "class-variance-authority"
6
- import { PanelLeftIcon } from "lucide-react"
7
-
8
- import { useIsMobile } from "@/hooks/use-mobile"
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
- Sheet,
15
- SheetContent,
16
- SheetDescription,
17
- SheetHeader,
18
- SheetTitle,
19
- } from "@/components/ui/sheet"
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(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
- // This sets the cookie to keep the sidebar state.
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-[var(--sidebar-width)] flex-col",
174
- className
175
- )}
176
- {...props}
177
- >
178
- {children}
179
- </div>
180
- )
181
- }
182
-
183
- if (isMobile) {
184
- return (
185
- <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
186
- <SheetContent
187
- data-sidebar="sidebar"
188
- data-slot="sidebar"
189
- data-mobile="true"
190
- className="bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden"
191
- style={
192
- {
193
- "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
194
- } as React.CSSProperties
195
- }
196
- side={side}
197
- >
198
- <SheetHeader className="sr-only">
199
- <SheetTitle>Sidebar</SheetTitle>
200
- <SheetDescription>Displays the mobile sidebar.</SheetDescription>
201
- </SheetHeader>
202
- <div className="flex h-full w-full flex-col">{children}</div>
203
- </SheetContent>
204
- </Sheet>
205
- )
206
- }
207
-
208
- return (
209
- <div
210
- className="group peer text-sidebar-foreground hidden md:block"
211
- data-state={state}
212
- data-collapsible={state === "collapsed" ? collapsible : ""}
213
- data-variant={variant}
214
- data-side={side}
215
- data-slot="sidebar"
216
- >
217
- {/* This is what handles the sidebar gap on desktop */}
218
- <div
219
- data-slot="sidebar-gap"
220
- className={cn(
221
- "relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear",
222
- "group-data-[collapsible=offcanvas]:w-0",
223
- "group-data-[side=right]:rotate-180",
224
- variant === "floating" || variant === "inset"
225
- ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+var(--spacing-4))]"
226
- : "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]"
227
- )}
228
- />
229
- <div
230
- data-slot="sidebar-container"
231
- className={cn(
232
- "fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex",
233
- side === "left"
234
- ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
235
- : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
236
- // Adjust the padding for floating and inset variants.
237
- variant === "floating" || variant === "inset"
238
- ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+var(--spacing-4)+2px)]"
239
- : "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",
240
- className
241
- )}
242
- {...props}
243
- >
244
- <div
245
- data-sidebar="sidebar"
246
- data-slot="sidebar-inner"
247
- 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"
248
- >
249
- {children}
250
- </div>
251
- </div>
252
- </div>
253
- )
254
- }
255
-
256
- function SidebarTrigger({
257
- className,
258
- onClick,
259
- ...props
260
- }: React.ComponentProps<typeof Button>) {
261
- const { toggleSidebar } = useSidebar()
262
-
263
- return (
264
- <Button
265
- data-sidebar="trigger"
266
- data-slot="sidebar-trigger"
267
- variant="ghost"
268
- size="icon"
269
- className={cn("h-7 w-7", className)}
270
- onClick={(event) => {
271
- onClick?.(event)
272
- toggleSidebar()
273
- }}
274
- {...props}
275
- >
276
- <PanelLeftIcon />
277
- <span className="sr-only">Toggle Sidebar</span>
278
- </Button>
279
- )
280
- }
281
-
282
- function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
283
- const { toggleSidebar } = useSidebar()
284
-
285
- // Note: Tailwind v3.4 doesn't support "in-" selectors. So the rail won't work perfectly.
286
- return (
287
- <button
288
- data-sidebar="rail"
289
- data-slot="sidebar-rail"
290
- aria-label="Toggle Sidebar"
291
- tabIndex={-1}
292
- onClick={toggleSidebar}
293
- title="Toggle Sidebar"
294
- className={cn(
295
- "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",
296
- "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
297
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
298
- "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
299
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
300
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
301
- className
302
- )}
303
- {...props}
304
- />
305
- )
306
- }
307
-
308
- function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
309
- return (
310
- <main
311
- data-slot="sidebar-inset"
312
- className={cn(
313
- "bg-background relative flex w-full flex-1 flex-col",
314
- "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",
315
- className
316
- )}
317
- {...props}
318
- />
319
- )
320
- }
321
-
322
- function SidebarInput({
323
- className,
324
- ...props
325
- }: React.ComponentProps<typeof Input>) {
326
- return (
327
- <Input
328
- data-slot="sidebar-input"
329
- data-sidebar="input"
330
- className={cn("bg-background h-8 w-full shadow-none", className)}
331
- {...props}
332
- />
333
- )
334
- }
335
-
336
- function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
337
- return (
338
- <div
339
- data-slot="sidebar-header"
340
- data-sidebar="header"
341
- className={cn("flex flex-col gap-2 p-2", className)}
342
- {...props}
343
- />
344
- )
345
- }
346
-
347
- function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
348
- return (
349
- <div
350
- data-slot="sidebar-footer"
351
- data-sidebar="footer"
352
- className={cn("flex flex-col gap-2 p-2", className)}
353
- {...props}
354
- />
355
- )
356
- }
357
-
358
- function SidebarSeparator({
359
- className,
360
- ...props
361
- }: React.ComponentProps<typeof Separator>) {
362
- return (
363
- <Separator
364
- data-slot="sidebar-separator"
365
- data-sidebar="separator"
366
- className={cn("bg-sidebar-border mx-2 w-auto", className)}
367
- {...props}
368
- />
369
- )
370
- }
371
-
372
- function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
373
- return (
374
- <div
375
- data-slot="sidebar-content"
376
- data-sidebar="content"
377
- className={cn(
378
- "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
379
- className
380
- )}
381
- {...props}
382
- />
383
- )
384
- }
385
-
386
- function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
387
- return (
388
- <div
389
- data-slot="sidebar-group"
390
- data-sidebar="group"
391
- className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
392
- {...props}
393
- />
394
- )
395
- }
396
-
397
- function SidebarGroupLabel({
398
- className,
399
- asChild = false,
400
- ...props
401
- }: React.ComponentProps<"div"> & { asChild?: boolean }) {
402
- const Comp = asChild ? Slot : "div"
403
-
404
- return (
405
- <Comp
406
- data-slot="sidebar-group-label"
407
- data-sidebar="group-label"
408
- className={cn(
409
- "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]:h-4 [&>svg]:w-4 [&>svg]:shrink-0",
410
- "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
411
- className
412
- )}
413
- {...props}
414
- />
415
- )
416
- }
417
-
418
- function SidebarGroupAction({
419
- className,
420
- asChild = false,
421
- ...props
422
- }: React.ComponentProps<"button"> & { asChild?: boolean }) {
423
- const Comp = asChild ? Slot : "button"
424
-
425
- return (
426
- <Comp
427
- data-slot="sidebar-group-action"
428
- data-sidebar="group-action"
429
- className={cn(
430
- "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",
431
- // Increases the hit area of the button on mobile.
432
- "after:absolute after:-inset-2 md:after:hidden",
433
- "group-data-[collapsible=icon]:hidden",
434
- className
435
- )}
436
- {...props}
437
- />
438
- )
439
- }
440
-
441
- function SidebarGroupContent({
442
- className,
443
- ...props
444
- }: React.ComponentProps<"div">) {
445
- return (
446
- <div
447
- data-slot="sidebar-group-content"
448
- data-sidebar="group-content"
449
- className={cn("w-full text-sm", className)}
450
- {...props}
451
- />
452
- )
453
- }
454
-
455
- function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
456
- return (
457
- <ul
458
- data-slot="sidebar-menu"
459
- data-sidebar="menu"
460
- className={cn("flex w-full min-w-0 flex-col gap-1", className)}
461
- {...props}
462
- />
463
- )
464
- }
465
-
466
- function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
467
- return (
468
- <li
469
- data-slot="sidebar-menu-item"
470
- data-sidebar="menu-item"
471
- className={cn("group/menu-item relative", className)}
472
- {...props}
473
- />
474
- )
475
- }
476
-
477
- const sidebarMenuButtonVariants = cva(
478
- "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]:w-8! group-data-[collapsible=icon]:h-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
479
- {
480
- variants: {
481
- variant: {
482
- default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
483
- outline:
484
- "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))]",
485
- },
486
- size: {
487
- default: "h-8 text-sm",
488
- sm: "h-7 text-xs",
489
- lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
490
- },
491
- },
492
- defaultVariants: {
493
- variant: "default",
494
- size: "default",
495
- },
496
- }
497
- )
498
-
499
- function SidebarMenuButton({
500
- asChild = false,
501
- isActive = false,
502
- variant = "default",
503
- size = "default",
504
- tooltip,
505
- className,
506
- ...props
507
- }: React.ComponentProps<"button"> & {
508
- asChild?: boolean
509
- isActive?: boolean
510
- tooltip?: string | React.ComponentProps<typeof TooltipContent>
511
- } & VariantProps<typeof sidebarMenuButtonVariants>) {
512
- const Comp = asChild ? Slot : "button"
513
- const { isMobile, state } = useSidebar()
514
-
515
- const button = (
516
- <Comp
517
- data-slot="sidebar-menu-button"
518
- data-sidebar="menu-button"
519
- data-size={size}
520
- data-active={isActive}
521
- className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
522
- {...props}
523
- />
524
- )
525
-
526
- if (!tooltip) {
527
- return button
528
- }
529
-
530
- if (typeof tooltip === "string") {
531
- tooltip = {
532
- children: tooltip,
533
- }
534
- }
535
-
536
- return (
537
- <Tooltip>
538
- <TooltipTrigger asChild>{button}</TooltipTrigger>
539
- <TooltipContent
540
- side="right"
541
- align="center"
542
- hidden={state !== "collapsed" || isMobile}
543
- {...tooltip}
544
- />
545
- </Tooltip>
546
- )
547
- }
548
-
549
- function SidebarMenuAction({
550
- className,
551
- asChild = false,
552
- showOnHover = false,
553
- ...props
554
- }: React.ComponentProps<"button"> & {
555
- asChild?: boolean
556
- showOnHover?: boolean
557
- }) {
558
- const Comp = asChild ? Slot : "button"
559
-
560
- return (
561
- <Comp
562
- data-slot="sidebar-menu-action"
563
- data-sidebar="menu-action"
564
- className={cn(
565
- "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",
566
- // Increases the hit area of the button on mobile.
567
- "after:absolute after:-inset-2 md:after:hidden",
568
- "peer-data-[size=sm]/menu-button:top-1",
569
- "peer-data-[size=default]/menu-button:top-1.5",
570
- "peer-data-[size=lg]/menu-button:top-2.5",
571
- "group-data-[collapsible=icon]:hidden",
572
- showOnHover &&
573
- "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",
574
- className
575
- )}
576
- {...props}
577
- />
578
- )
579
- }
580
-
581
- function SidebarMenuBadge({
582
- className,
583
- ...props
584
- }: React.ComponentProps<"div">) {
585
- return (
586
- <div
587
- data-slot="sidebar-menu-badge"
588
- data-sidebar="menu-badge"
589
- className={cn(
590
- "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",
591
- "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
592
- "peer-data-[size=sm]/menu-button:top-1",
593
- "peer-data-[size=default]/menu-button:top-1.5",
594
- "peer-data-[size=lg]/menu-button:top-2.5",
595
- "group-data-[collapsible=icon]:hidden",
596
- className
597
- )}
598
- {...props}
599
- />
600
- )
601
- }
602
-
603
- function SidebarMenuSkeleton({
604
- className,
605
- showIcon = false,
606
- ...props
607
- }: React.ComponentProps<"div"> & {
608
- showIcon?: boolean
609
- }) {
610
- // Stable pseudo-random width between 50% to 90% (no Math.random in render).
611
- const stableId = React.useId()
612
- const width = React.useMemo(() => {
613
- let hash = 0
614
- for (let i = 0; i < stableId.length; i++) {
615
- hash = (hash * 31 + stableId.charCodeAt(i)) % 41
616
- }
617
- return `${hash + 50}%`
618
- }, [stableId])
619
-
620
- return (
621
- <div
622
- data-slot="sidebar-menu-skeleton"
623
- data-sidebar="menu-skeleton"
624
- className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
625
- {...props}
626
- >
627
- {showIcon && (
628
- <Skeleton
629
- className="size-4 rounded-md"
630
- data-sidebar="menu-skeleton-icon"
631
- />
632
- )}
633
- <Skeleton
634
- className="h-4 max-w-[var(--skeleton-width)] flex-1"
635
- data-sidebar="menu-skeleton-text"
636
- style={
637
- {
638
- "--skeleton-width": width,
639
- } as React.CSSProperties
640
- }
641
- />
642
- </div>
643
- )
644
- }
645
-
646
- function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
647
- return (
648
- <ul
649
- data-slot="sidebar-menu-sub"
650
- data-sidebar="menu-sub"
651
- className={cn(
652
- "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",
653
- "group-data-[collapsible=icon]:hidden",
654
- className
655
- )}
656
- {...props}
657
- />
658
- )
659
- }
660
-
661
- function SidebarMenuSubItem({
662
- className,
663
- ...props
664
- }: React.ComponentProps<"li">) {
665
- return (
666
- <li
667
- data-slot="sidebar-menu-sub-item"
668
- data-sidebar="menu-sub-item"
669
- className={cn("group/menu-sub-item relative", className)}
670
- {...props}
671
- />
672
- )
673
- }
674
-
675
- function SidebarMenuSubButton({
676
- asChild = false,
677
- size = "md",
678
- isActive = false,
679
- className,
680
- ...props
681
- }: React.ComponentProps<"a"> & {
682
- asChild?: boolean
683
- size?: "sm" | "md"
684
- isActive?: boolean
685
- }) {
686
- const Comp = asChild ? Slot : "a"
687
-
688
- return (
689
- <Comp
690
- data-slot="sidebar-menu-sub-button"
691
- data-sidebar="menu-sub-button"
692
- data-size={size}
693
- data-active={isActive}
694
- className={cn(
695
- "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 outline-2 outline-transparent outline-offset-2 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",
696
- "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
697
- size === "sm" && "text-xs",
698
- size === "md" && "text-sm",
699
- "group-data-[collapsible=icon]:hidden",
700
- className
701
- )}
702
- {...props}
703
- />
704
- )
705
- }
706
-
707
- export {
708
- Sidebar,
709
- SidebarContent,
710
- SidebarFooter,
711
- SidebarGroup,
712
- SidebarGroupAction,
713
- SidebarGroupContent,
714
- SidebarGroupLabel,
715
- SidebarHeader,
716
- SidebarInput,
717
- SidebarInset,
718
- SidebarMenu,
719
- SidebarMenuAction,
720
- SidebarMenuBadge,
721
- SidebarMenuButton,
722
- SidebarMenuItem,
723
- SidebarMenuSkeleton,
724
- SidebarMenuSub,
725
- SidebarMenuSubButton,
726
- SidebarMenuSubItem,
727
- SidebarProvider,
728
- SidebarRail,
729
- SidebarSeparator,
730
- SidebarTrigger,
731
- useSidebar,
732
- }