@behavioral-agentic-design-system/core 0.1.1

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