@tioelvis/next-template 2.4.8 → 3.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 (132) hide show
  1. package/README.md +42 -42
  2. package/package.json +44 -92
  3. package/src/actions/configure-package-json.js +32 -0
  4. package/src/actions/init-project.js +40 -0
  5. package/src/actions/init-shadcn-ui.js +48 -0
  6. package/src/actions/init-theme.js +28 -0
  7. package/src/actions/init-tioelvis-components.js +42 -0
  8. package/src/actions/install-main-packages.js +51 -0
  9. package/src/constants.js +234 -97
  10. package/src/lib/exception.js +9 -0
  11. package/src/lib/utils.js +55 -0
  12. package/src/main.js +158 -229
  13. package/src/template/eslint.config.mjs +15 -13
  14. package/src/template/postcss.config.mjs +3 -1
  15. package/src/template/src/app/globals.css +0 -122
  16. package/src/template/src/app/layout.tsx +7 -15
  17. package/src/template/src/app/page.tsx +6 -2
  18. package/src/template/tsconfig.json +9 -2
  19. package/src/themes/blue.css +141 -0
  20. package/src/themes/default.css +141 -0
  21. package/src/themes/green.css +141 -0
  22. package/src/themes/orange.css +141 -0
  23. package/src/themes/red.css +141 -0
  24. package/src/themes/rose.css +141 -0
  25. package/src/themes/violet.css +141 -0
  26. package/src/themes/yellow.css +141 -0
  27. package/src/tioelvis-components/max-width-wrapper.tsx +21 -0
  28. package/src/app/components/ui/accordion.json +0 -6
  29. package/src/app/components/ui/accordion.tsx +0 -64
  30. package/src/app/components/ui/alert-dialog.json +0 -6
  31. package/src/app/components/ui/alert-dialog.tsx +0 -157
  32. package/src/app/components/ui/alert.json +0 -6
  33. package/src/app/components/ui/alert.tsx +0 -66
  34. package/src/app/components/ui/aspect-ratio.json +0 -6
  35. package/src/app/components/ui/aspect-ratio.tsx +0 -11
  36. package/src/app/components/ui/avatar.json +0 -6
  37. package/src/app/components/ui/avatar.tsx +0 -53
  38. package/src/app/components/ui/badge.json +0 -6
  39. package/src/app/components/ui/badge.tsx +0 -46
  40. package/src/app/components/ui/breadcrumb.json +0 -6
  41. package/src/app/components/ui/breadcrumb.tsx +0 -107
  42. package/src/app/components/ui/button.json +0 -6
  43. package/src/app/components/ui/button.tsx +0 -58
  44. package/src/app/components/ui/calendar.json +0 -6
  45. package/src/app/components/ui/calendar.tsx +0 -213
  46. package/src/app/components/ui/card.json +0 -6
  47. package/src/app/components/ui/card.tsx +0 -92
  48. package/src/app/components/ui/carousel.json +0 -6
  49. package/src/app/components/ui/carousel.tsx +0 -236
  50. package/src/app/components/ui/chart.json +0 -6
  51. package/src/app/components/ui/chart.tsx +0 -347
  52. package/src/app/components/ui/checkbox.json +0 -6
  53. package/src/app/components/ui/checkbox.tsx +0 -30
  54. package/src/app/components/ui/collapsible.json +0 -6
  55. package/src/app/components/ui/collapsible.tsx +0 -33
  56. package/src/app/components/ui/command.json +0 -6
  57. package/src/app/components/ui/command.tsx +0 -182
  58. package/src/app/components/ui/context-menu.json +0 -6
  59. package/src/app/components/ui/context-menu.tsx +0 -249
  60. package/src/app/components/ui/dialog.json +0 -6
  61. package/src/app/components/ui/dialog.tsx +0 -141
  62. package/src/app/components/ui/drawer.json +0 -6
  63. package/src/app/components/ui/drawer.tsx +0 -134
  64. package/src/app/components/ui/dropdown-menu.json +0 -6
  65. package/src/app/components/ui/dropdown-menu.tsx +0 -256
  66. package/src/app/components/ui/form.json +0 -12
  67. package/src/app/components/ui/form.tsx +0 -167
  68. package/src/app/components/ui/hover-card.json +0 -6
  69. package/src/app/components/ui/hover-card.tsx +0 -49
  70. package/src/app/components/ui/input-otp.json +0 -6
  71. package/src/app/components/ui/input-otp.tsx +0 -76
  72. package/src/app/components/ui/input.json +0 -6
  73. package/src/app/components/ui/input.tsx +0 -21
  74. package/src/app/components/ui/label.json +0 -6
  75. package/src/app/components/ui/label.tsx +0 -24
  76. package/src/app/components/ui/menubar.json +0 -6
  77. package/src/app/components/ui/menubar.tsx +0 -273
  78. package/src/app/components/ui/navigation-menu.json +0 -6
  79. package/src/app/components/ui/navigation-menu.tsx +0 -164
  80. package/src/app/components/ui/pagination.json +0 -6
  81. package/src/app/components/ui/pagination.tsx +0 -124
  82. package/src/app/components/ui/popover.json +0 -6
  83. package/src/app/components/ui/popover.tsx +0 -55
  84. package/src/app/components/ui/progress.json +0 -6
  85. package/src/app/components/ui/progress.tsx +0 -30
  86. package/src/app/components/ui/radio-group.json +0 -6
  87. package/src/app/components/ui/radio-group.tsx +0 -43
  88. package/src/app/components/ui/resizable.json +0 -6
  89. package/src/app/components/ui/resizable.tsx +0 -55
  90. package/src/app/components/ui/scroll-area.json +0 -6
  91. package/src/app/components/ui/scroll-area.tsx +0 -55
  92. package/src/app/components/ui/select.json +0 -6
  93. package/src/app/components/ui/select.tsx +0 -179
  94. package/src/app/components/ui/separator.json +0 -6
  95. package/src/app/components/ui/separator.tsx +0 -28
  96. package/src/app/components/ui/sheet.json +0 -6
  97. package/src/app/components/ui/sheet.tsx +0 -145
  98. package/src/app/components/ui/sidebar.json +0 -6
  99. package/src/app/components/ui/sidebar.tsx +0 -718
  100. package/src/app/components/ui/skeleton.json +0 -6
  101. package/src/app/components/ui/skeleton.tsx +0 -13
  102. package/src/app/components/ui/slider.json +0 -6
  103. package/src/app/components/ui/slider.tsx +0 -61
  104. package/src/app/components/ui/sonner.json +0 -6
  105. package/src/app/components/ui/sonner.tsx +0 -25
  106. package/src/app/components/ui/switch.json +0 -6
  107. package/src/app/components/ui/switch.tsx +0 -30
  108. package/src/app/components/ui/table.json +0 -6
  109. package/src/app/components/ui/table.tsx +0 -115
  110. package/src/app/components/ui/tabs.json +0 -6
  111. package/src/app/components/ui/tabs.tsx +0 -66
  112. package/src/app/components/ui/textarea.json +0 -6
  113. package/src/app/components/ui/textarea.tsx +0 -18
  114. package/src/app/components/ui/toggle-group.json +0 -6
  115. package/src/app/components/ui/toggle-group.tsx +0 -71
  116. package/src/app/components/ui/toggle.json +0 -6
  117. package/src/app/components/ui/toggle.tsx +0 -47
  118. package/src/app/components/ui/tooltip.json +0 -6
  119. package/src/app/components/ui/tooltip.tsx +0 -60
  120. package/src/app/hooks/use-mobile.ts +0 -21
  121. package/src/app/lib/utils.ts +0 -6
  122. package/src/app/tsconfig.json +0 -27
  123. package/src/template/components.json +0 -21
  124. package/src/template/next-env.d.ts +0 -5
  125. package/src/template/public/.gitkeep +0 -0
  126. package/src/template/src/lib/axios.ts +0 -39
  127. package/src/template/src/lib/constants.ts +0 -1
  128. package/src/template/src/lib/utils.ts +0 -6
  129. package/src/template/src/providers/query.provider.tsx +0 -12
  130. package/src/template/src/providers/theme.provider.tsx +0 -8
  131. package/src/utils.js +0 -113
  132. /package/src/template/{src/app → public}/favicon.ico +0 -0
@@ -1,718 +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
- {children}
147
- </div>
148
- </TooltipProvider>
149
- </SidebarContext.Provider>
150
- );
151
- }
152
-
153
- function Sidebar({
154
- side = "left",
155
- variant = "sidebar",
156
- collapsible = "offcanvas",
157
- className,
158
- children,
159
- ...props
160
- }: React.ComponentProps<"div"> & {
161
- side?: "left" | "right";
162
- variant?: "sidebar" | "floating" | "inset";
163
- collapsible?: "offcanvas" | "icon" | "none";
164
- }) {
165
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
166
-
167
- if (collapsible === "none") {
168
- return (
169
- <div
170
- data-slot="sidebar"
171
- className={cn(
172
- "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
173
- className
174
- )}
175
- {...props}>
176
- {children}
177
- </div>
178
- );
179
- }
180
-
181
- if (isMobile) {
182
- return (
183
- <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
184
- <SheetContent
185
- data-sidebar="sidebar"
186
- data-slot="sidebar"
187
- data-mobile="true"
188
- className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
189
- style={
190
- {
191
- "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
192
- } as React.CSSProperties
193
- }
194
- side={side}>
195
- <SheetHeader className="sr-only">
196
- <SheetTitle>Sidebar</SheetTitle>
197
- <SheetDescription>Displays the mobile sidebar.</SheetDescription>
198
- </SheetHeader>
199
- <div className="flex h-full w-full flex-col">{children}</div>
200
- </SheetContent>
201
- </Sheet>
202
- );
203
- }
204
-
205
- return (
206
- <div
207
- className="group peer text-sidebar-foreground hidden md:block"
208
- data-state={state}
209
- data-collapsible={state === "collapsed" ? collapsible : ""}
210
- data-variant={variant}
211
- data-side={side}
212
- data-slot="sidebar">
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
- className={cn(
228
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
229
- side === "left"
230
- ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
231
- : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
232
- // Adjust the padding for floating and inset variants.
233
- variant === "floating" || variant === "inset"
234
- ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
235
- : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
236
- className
237
- )}
238
- {...props}>
239
- <div
240
- data-sidebar="sidebar"
241
- data-slot="sidebar-inner"
242
- 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">
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"
263
- className={cn("size-7", className)}
264
- onClick={(event) => {
265
- onClick?.(event);
266
- toggleSidebar();
267
- }}
268
- {...props}>
269
- <PanelLeftIcon />
270
- <span className="sr-only">Toggle Sidebar</span>
271
- </Button>
272
- );
273
- }
274
-
275
- function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
276
- const { toggleSidebar } = useSidebar();
277
-
278
- return (
279
- <button
280
- data-sidebar="rail"
281
- data-slot="sidebar-rail"
282
- aria-label="Toggle Sidebar"
283
- tabIndex={-1}
284
- onClick={toggleSidebar}
285
- title="Toggle Sidebar"
286
- className={cn(
287
- "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",
288
- "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
289
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
290
- "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
291
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
292
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
293
- className
294
- )}
295
- {...props}
296
- />
297
- );
298
- }
299
-
300
- function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
301
- return (
302
- <main
303
- data-slot="sidebar-inset"
304
- className={cn(
305
- "bg-background relative flex w-full flex-1 flex-col",
306
- "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",
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("bg-background h-8 w-full 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("flex flex-col gap-2 p-2", className)}
334
- {...props}
335
- />
336
- );
337
- }
338
-
339
- function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
340
- return (
341
- <div
342
- data-slot="sidebar-footer"
343
- data-sidebar="footer"
344
- className={cn("flex flex-col gap-2 p-2", className)}
345
- {...props}
346
- />
347
- );
348
- }
349
-
350
- function SidebarSeparator({
351
- className,
352
- ...props
353
- }: React.ComponentProps<typeof Separator>) {
354
- return (
355
- <Separator
356
- data-slot="sidebar-separator"
357
- data-sidebar="separator"
358
- className={cn("bg-sidebar-border mx-2 w-auto", className)}
359
- {...props}
360
- />
361
- );
362
- }
363
-
364
- function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
365
- return (
366
- <div
367
- data-slot="sidebar-content"
368
- data-sidebar="content"
369
- className={cn(
370
- "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
371
- className
372
- )}
373
- {...props}
374
- />
375
- );
376
- }
377
-
378
- function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
379
- return (
380
- <div
381
- data-slot="sidebar-group"
382
- data-sidebar="group"
383
- className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
384
- {...props}
385
- />
386
- );
387
- }
388
-
389
- function SidebarGroupLabel({
390
- className,
391
- asChild = false,
392
- ...props
393
- }: React.ComponentProps<"div"> & { asChild?: boolean }) {
394
- const Comp = asChild ? Slot : "div";
395
-
396
- return (
397
- <Comp
398
- data-slot="sidebar-group-label"
399
- data-sidebar="group-label"
400
- className={cn(
401
- "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",
402
- "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
403
- className
404
- )}
405
- {...props}
406
- />
407
- );
408
- }
409
-
410
- function SidebarGroupAction({
411
- className,
412
- asChild = false,
413
- ...props
414
- }: React.ComponentProps<"button"> & { asChild?: boolean }) {
415
- const Comp = asChild ? Slot : "button";
416
-
417
- return (
418
- <Comp
419
- data-slot="sidebar-group-action"
420
- data-sidebar="group-action"
421
- className={cn(
422
- "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",
423
- // Increases the hit area of the button on mobile.
424
- "after:absolute after:-inset-2 md:after:hidden",
425
- "group-data-[collapsible=icon]:hidden",
426
- className
427
- )}
428
- {...props}
429
- />
430
- );
431
- }
432
-
433
- function SidebarGroupContent({
434
- className,
435
- ...props
436
- }: React.ComponentProps<"div">) {
437
- return (
438
- <div
439
- data-slot="sidebar-group-content"
440
- data-sidebar="group-content"
441
- className={cn("w-full text-sm", className)}
442
- {...props}
443
- />
444
- );
445
- }
446
-
447
- function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
448
- return (
449
- <ul
450
- data-slot="sidebar-menu"
451
- data-sidebar="menu"
452
- className={cn("flex w-full min-w-0 flex-col gap-1", className)}
453
- {...props}
454
- />
455
- );
456
- }
457
-
458
- function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
459
- return (
460
- <li
461
- data-slot="sidebar-menu-item"
462
- data-sidebar="menu-item"
463
- className={cn("group/menu-item relative", className)}
464
- {...props}
465
- />
466
- );
467
- }
468
-
469
- const sidebarMenuButtonVariants = cva(
470
- "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:cursor-not-allowed disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:cursor-not-allowed 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",
471
- {
472
- variants: {
473
- variant: {
474
- default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
475
- outline:
476
- "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))]",
477
- },
478
- size: {
479
- default: "h-8 text-sm",
480
- sm: "h-7 text-xs",
481
- lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
482
- },
483
- },
484
- defaultVariants: {
485
- variant: "default",
486
- size: "default",
487
- },
488
- }
489
- );
490
-
491
- function SidebarMenuButton({
492
- asChild = false,
493
- isActive = false,
494
- variant = "default",
495
- size = "default",
496
- tooltip,
497
- className,
498
- ...props
499
- }: React.ComponentProps<"button"> & {
500
- asChild?: boolean;
501
- isActive?: boolean;
502
- tooltip?: string | React.ComponentProps<typeof TooltipContent>;
503
- } & VariantProps<typeof sidebarMenuButtonVariants>) {
504
- const Comp = asChild ? Slot : "button";
505
- const { isMobile, state } = useSidebar();
506
-
507
- const button = (
508
- <Comp
509
- data-slot="sidebar-menu-button"
510
- data-sidebar="menu-button"
511
- data-size={size}
512
- data-active={isActive}
513
- className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
514
- {...props}
515
- />
516
- );
517
-
518
- if (!tooltip) {
519
- return button;
520
- }
521
-
522
- if (typeof tooltip === "string") {
523
- tooltip = {
524
- children: tooltip,
525
- };
526
- }
527
-
528
- return (
529
- <Tooltip>
530
- <TooltipTrigger asChild>{button}</TooltipTrigger>
531
- <TooltipContent
532
- side="right"
533
- align="center"
534
- hidden={state !== "collapsed" || isMobile}
535
- {...tooltip}
536
- />
537
- </Tooltip>
538
- );
539
- }
540
-
541
- function SidebarMenuAction({
542
- className,
543
- asChild = false,
544
- showOnHover = false,
545
- ...props
546
- }: React.ComponentProps<"button"> & {
547
- asChild?: boolean;
548
- showOnHover?: boolean;
549
- }) {
550
- const Comp = asChild ? Slot : "button";
551
-
552
- return (
553
- <Comp
554
- data-slot="sidebar-menu-action"
555
- data-sidebar="menu-action"
556
- className={cn(
557
- "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",
558
- // Increases the hit area of the button on mobile.
559
- "after:absolute after:-inset-2 md:after:hidden",
560
- "peer-data-[size=sm]/menu-button:top-1",
561
- "peer-data-[size=default]/menu-button:top-1.5",
562
- "peer-data-[size=lg]/menu-button:top-2.5",
563
- "group-data-[collapsible=icon]:hidden",
564
- showOnHover &&
565
- "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",
566
- className
567
- )}
568
- {...props}
569
- />
570
- );
571
- }
572
-
573
- function SidebarMenuBadge({
574
- className,
575
- ...props
576
- }: React.ComponentProps<"div">) {
577
- return (
578
- <div
579
- data-slot="sidebar-menu-badge"
580
- data-sidebar="menu-badge"
581
- className={cn(
582
- "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",
583
- "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
584
- "peer-data-[size=sm]/menu-button:top-1",
585
- "peer-data-[size=default]/menu-button:top-1.5",
586
- "peer-data-[size=lg]/menu-button:top-2.5",
587
- "group-data-[collapsible=icon]:hidden",
588
- className
589
- )}
590
- {...props}
591
- />
592
- );
593
- }
594
-
595
- function SidebarMenuSkeleton({
596
- className,
597
- showIcon = false,
598
- ...props
599
- }: React.ComponentProps<"div"> & {
600
- showIcon?: boolean;
601
- }) {
602
- // Random width between 50 to 90%.
603
- const width = React.useMemo(() => {
604
- return `${Math.floor(Math.random() * 40) + 50}%`;
605
- }, []);
606
-
607
- return (
608
- <div
609
- data-slot="sidebar-menu-skeleton"
610
- data-sidebar="menu-skeleton"
611
- className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
612
- {...props}>
613
- {showIcon && (
614
- <Skeleton
615
- className="size-4 rounded-md"
616
- data-sidebar="menu-skeleton-icon"
617
- />
618
- )}
619
- <Skeleton
620
- className="h-4 max-w-(--skeleton-width) flex-1"
621
- data-sidebar="menu-skeleton-text"
622
- style={
623
- {
624
- "--skeleton-width": width,
625
- } as React.CSSProperties
626
- }
627
- />
628
- </div>
629
- );
630
- }
631
-
632
- function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
633
- return (
634
- <ul
635
- data-slot="sidebar-menu-sub"
636
- data-sidebar="menu-sub"
637
- className={cn(
638
- "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",
639
- "group-data-[collapsible=icon]:hidden",
640
- className
641
- )}
642
- {...props}
643
- />
644
- );
645
- }
646
-
647
- function SidebarMenuSubItem({
648
- className,
649
- ...props
650
- }: React.ComponentProps<"li">) {
651
- return (
652
- <li
653
- data-slot="sidebar-menu-sub-item"
654
- data-sidebar="menu-sub-item"
655
- className={cn("group/menu-sub-item relative", className)}
656
- {...props}
657
- />
658
- );
659
- }
660
-
661
- function SidebarMenuSubButton({
662
- asChild = false,
663
- size = "md",
664
- isActive = false,
665
- className,
666
- ...props
667
- }: React.ComponentProps<"a"> & {
668
- asChild?: boolean;
669
- size?: "sm" | "md";
670
- isActive?: boolean;
671
- }) {
672
- const Comp = asChild ? Slot : "a";
673
-
674
- return (
675
- <Comp
676
- data-slot="sidebar-menu-sub-button"
677
- data-sidebar="menu-sub-button"
678
- data-size={size}
679
- data-active={isActive}
680
- className={cn(
681
- "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:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
682
- "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
683
- size === "sm" && "text-xs",
684
- size === "md" && "text-sm",
685
- "group-data-[collapsible=icon]:hidden",
686
- className
687
- )}
688
- {...props}
689
- />
690
- );
691
- }
692
-
693
- export {
694
- Sidebar,
695
- SidebarContent,
696
- SidebarFooter,
697
- SidebarGroup,
698
- SidebarGroupAction,
699
- SidebarGroupContent,
700
- SidebarGroupLabel,
701
- SidebarHeader,
702
- SidebarInput,
703
- SidebarInset,
704
- SidebarMenu,
705
- SidebarMenuAction,
706
- SidebarMenuBadge,
707
- SidebarMenuButton,
708
- SidebarMenuItem,
709
- SidebarMenuSkeleton,
710
- SidebarMenuSub,
711
- SidebarMenuSubButton,
712
- SidebarMenuSubItem,
713
- SidebarProvider,
714
- SidebarRail,
715
- SidebarSeparator,
716
- SidebarTrigger,
717
- useSidebar,
718
- };