@tioelvis/next-template 2.3.4 → 2.3.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tioelvis/next-template",
3
- "version": "2.3.4",
3
+ "version": "2.3.7",
4
4
  "description": "CLI to scaffold a Next.js + Tailwind project using shadcn/ui components",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,6 +51,7 @@
51
51
  "@radix-ui/react-select": "^2.2.5",
52
52
  "@radix-ui/react-separator": "^1.1.7",
53
53
  "@radix-ui/react-slot": "^1.2.3",
54
+ "@radix-ui/react-tooltip": "^1.2.7",
54
55
  "@tailwindcss/postcss": "^4.1.11",
55
56
  "@tanstack/react-query": "^5.83.0",
56
57
  "@types/node": "^24.1.0",
@@ -0,0 +1,6 @@
1
+ {
2
+ "dependencies": ["@radix-ui/react-dialog"],
3
+ "dev_dependence": [],
4
+ "hooks": [],
5
+ "supports": []
6
+ }
@@ -0,0 +1,145 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
5
+ import { XIcon } from "lucide-react";
6
+
7
+ import { cn } from "@/lib/utils";
8
+
9
+ function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
10
+ return <SheetPrimitive.Root data-slot="sheet" {...props} />;
11
+ }
12
+
13
+ function SheetTrigger({
14
+ className,
15
+ ...props
16
+ }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
17
+ return (
18
+ <SheetPrimitive.Trigger
19
+ data-slot="sheet-trigger"
20
+ className={cn("cursor-pointer", className)}
21
+ {...props}
22
+ />
23
+ );
24
+ }
25
+
26
+ function SheetClose({
27
+ ...props
28
+ }: React.ComponentProps<typeof SheetPrimitive.Close>) {
29
+ return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
30
+ }
31
+
32
+ function SheetPortal({
33
+ ...props
34
+ }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
35
+ return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
36
+ }
37
+
38
+ function SheetOverlay({
39
+ className,
40
+ ...props
41
+ }: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
42
+ return (
43
+ <SheetPrimitive.Overlay
44
+ data-slot="sheet-overlay"
45
+ className={cn(
46
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
47
+ className
48
+ )}
49
+ {...props}
50
+ />
51
+ );
52
+ }
53
+
54
+ function SheetContent({
55
+ className,
56
+ children,
57
+ side = "right",
58
+ ...props
59
+ }: React.ComponentProps<typeof SheetPrimitive.Content> & {
60
+ side?: "top" | "right" | "bottom" | "left";
61
+ }) {
62
+ return (
63
+ <SheetPortal>
64
+ <SheetOverlay />
65
+ <SheetPrimitive.Content
66
+ data-slot="sheet-content"
67
+ className={cn(
68
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
69
+ side === "right" &&
70
+ "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
71
+ side === "left" &&
72
+ "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
73
+ side === "top" &&
74
+ "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
75
+ side === "bottom" &&
76
+ "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
77
+ className
78
+ )}
79
+ {...props}>
80
+ {children}
81
+ <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
82
+ <XIcon className="size-4" />
83
+ <span className="sr-only">Close</span>
84
+ </SheetPrimitive.Close>
85
+ </SheetPrimitive.Content>
86
+ </SheetPortal>
87
+ );
88
+ }
89
+
90
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
91
+ return (
92
+ <div
93
+ data-slot="sheet-header"
94
+ className={cn("flex flex-col gap-1.5 p-4", className)}
95
+ {...props}
96
+ />
97
+ );
98
+ }
99
+
100
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
101
+ return (
102
+ <div
103
+ data-slot="sheet-footer"
104
+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}
105
+ {...props}
106
+ />
107
+ );
108
+ }
109
+
110
+ function SheetTitle({
111
+ className,
112
+ ...props
113
+ }: React.ComponentProps<typeof SheetPrimitive.Title>) {
114
+ return (
115
+ <SheetPrimitive.Title
116
+ data-slot="sheet-title"
117
+ className={cn("text-foreground font-semibold", className)}
118
+ {...props}
119
+ />
120
+ );
121
+ }
122
+
123
+ function SheetDescription({
124
+ className,
125
+ ...props
126
+ }: React.ComponentProps<typeof SheetPrimitive.Description>) {
127
+ return (
128
+ <SheetPrimitive.Description
129
+ data-slot="sheet-description"
130
+ className={cn("text-muted-foreground text-sm", className)}
131
+ {...props}
132
+ />
133
+ );
134
+ }
135
+
136
+ export {
137
+ Sheet,
138
+ SheetTrigger,
139
+ SheetClose,
140
+ SheetContent,
141
+ SheetHeader,
142
+ SheetFooter,
143
+ SheetTitle,
144
+ SheetDescription,
145
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "dependencies": ["@radix-ui/react-slot"],
3
+ "dev_dependence": [],
4
+ "hooks": ["use-mobile"],
5
+ "supports": ["button", "input", "separator", "sheet", "skeleton", "tooltip"]
6
+ }
@@ -0,0 +1,718 @@
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
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "dependencies": [],
3
+ "dev_dependence": [],
4
+ "hooks": [],
5
+ "supports": []
6
+ }
@@ -0,0 +1,13 @@
1
+ import { cn } from "@/lib/utils";
2
+
3
+ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
+ return (
5
+ <div
6
+ data-slot="skeleton"
7
+ className={cn("bg-accent animate-pulse rounded-md", className)}
8
+ {...props}
9
+ />
10
+ );
11
+ }
12
+
13
+ export { Skeleton };
@@ -0,0 +1,6 @@
1
+ {
2
+ "dependencies": ["@radix-ui/react-tooltip"],
3
+ "dev_dependence": [],
4
+ "hooks": [],
5
+ "supports": []
6
+ }
@@ -0,0 +1,60 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
5
+
6
+ import { cn } from "@/lib/utils";
7
+
8
+ function TooltipProvider({
9
+ delayDuration = 0,
10
+ ...props
11
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
12
+ return (
13
+ <TooltipPrimitive.Provider
14
+ data-slot="tooltip-provider"
15
+ delayDuration={delayDuration}
16
+ {...props}
17
+ />
18
+ );
19
+ }
20
+
21
+ function Tooltip({
22
+ ...props
23
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
24
+ return (
25
+ <TooltipProvider>
26
+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />
27
+ </TooltipProvider>
28
+ );
29
+ }
30
+
31
+ function TooltipTrigger({
32
+ ...props
33
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
34
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
35
+ }
36
+
37
+ function TooltipContent({
38
+ className,
39
+ sideOffset = 0,
40
+ children,
41
+ ...props
42
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
43
+ return (
44
+ <TooltipPrimitive.Portal>
45
+ <TooltipPrimitive.Content
46
+ data-slot="tooltip-content"
47
+ sideOffset={sideOffset}
48
+ className={cn(
49
+ "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
50
+ className
51
+ )}
52
+ {...props}>
53
+ {children}
54
+ <TooltipPrimitive.Arrow className="bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
55
+ </TooltipPrimitive.Content>
56
+ </TooltipPrimitive.Portal>
57
+ );
58
+ }
59
+
60
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+
3
+ const MOBILE_BREAKPOINT = 768;
4
+
5
+ export function useIsMobile() {
6
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
7
+ undefined
8
+ );
9
+
10
+ React.useEffect(() => {
11
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
12
+ const onChange = () => {
13
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
14
+ };
15
+ mql.addEventListener("change", onChange);
16
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
17
+ return () => mql.removeEventListener("change", onChange);
18
+ }, []);
19
+
20
+ return !!isMobile;
21
+ }
package/src/constants.js CHANGED
@@ -72,6 +72,9 @@ const COMPONENTS = [
72
72
  "scroll-area",
73
73
  "select",
74
74
  "separator",
75
+ "sheet",
76
+ "sidebar",
77
+ "skeleton",
75
78
  ];
76
79
 
77
80
  export {