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