bmj-ui 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.
@@ -0,0 +1,719 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { mergeProps } from "@base-ui/react/merge-props";
5
+ import { useRender } from "@base-ui/react/use-render";
6
+ import { cva, type VariantProps } from "class-variance-authority";
7
+
8
+ import { useIsMobile } from "../../hooks/use-mobile";
9
+ import { cn } from "../../lib/utils";
10
+ import { Button } from "./button";
11
+ import { Input } from "./input";
12
+ import { Separator } from "./separator";
13
+ import {
14
+ Sheet,
15
+ SheetContent,
16
+ SheetDescription,
17
+ SheetHeader,
18
+ SheetTitle,
19
+ } from "./sheet";
20
+ import { Skeleton } from "./skeleton";
21
+ import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
22
+ import { PanelLeftIcon } from "lucide-react";
23
+
24
+ const SIDEBAR_COOKIE_NAME = "sidebar_state";
25
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
26
+ const SIDEBAR_WIDTH = "16rem";
27
+ const SIDEBAR_WIDTH_MOBILE = "18rem";
28
+ const SIDEBAR_WIDTH_ICON = "3rem";
29
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b";
30
+
31
+ type SidebarContextProps = {
32
+ state: "expanded" | "collapsed";
33
+ open: boolean;
34
+ setOpen: (open: boolean) => void;
35
+ openMobile: boolean;
36
+ setOpenMobile: (open: boolean) => void;
37
+ isMobile: boolean;
38
+ toggleSidebar: () => void;
39
+ };
40
+
41
+ const SidebarContext = React.createContext<SidebarContextProps | null>(null);
42
+
43
+ function useSidebar() {
44
+ const context = React.useContext(SidebarContext);
45
+ if (!context) {
46
+ throw new Error("useSidebar must be used within a SidebarProvider.");
47
+ }
48
+
49
+ return context;
50
+ }
51
+
52
+ function SidebarProvider({
53
+ defaultOpen = true,
54
+ open: openProp,
55
+ onOpenChange: setOpenProp,
56
+ className,
57
+ style,
58
+ children,
59
+ ...props
60
+ }: React.ComponentProps<"div"> & {
61
+ defaultOpen?: boolean;
62
+ open?: boolean;
63
+ onOpenChange?: (open: boolean) => void;
64
+ }) {
65
+ const isMobile = useIsMobile();
66
+ const [openMobile, setOpenMobile] = React.useState(false);
67
+
68
+ // This is the internal state of the sidebar.
69
+ // We use openProp and setOpenProp for control from outside the component.
70
+ const [_open, _setOpen] = React.useState(defaultOpen);
71
+ const open = openProp ?? _open;
72
+ const setOpen = React.useCallback(
73
+ (value: boolean | ((value: boolean) => boolean)) => {
74
+ const openState = typeof value === "function" ? value(open) : value;
75
+ if (setOpenProp) {
76
+ setOpenProp(openState);
77
+ } else {
78
+ _setOpen(openState);
79
+ }
80
+
81
+ // This sets the cookie to keep the sidebar state.
82
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
83
+ },
84
+ [setOpenProp, open],
85
+ );
86
+
87
+ // Helper to toggle the sidebar.
88
+ const toggleSidebar = React.useCallback(() => {
89
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
90
+ }, [isMobile, setOpen, setOpenMobile]);
91
+
92
+ // Adds a keyboard shortcut to toggle the sidebar.
93
+ React.useEffect(() => {
94
+ const handleKeyDown = (event: KeyboardEvent) => {
95
+ if (
96
+ event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
97
+ (event.metaKey || event.ctrlKey)
98
+ ) {
99
+ event.preventDefault();
100
+ toggleSidebar();
101
+ }
102
+ };
103
+
104
+ window.addEventListener("keydown", handleKeyDown);
105
+ return () => window.removeEventListener("keydown", handleKeyDown);
106
+ }, [toggleSidebar]);
107
+
108
+ // We add a state so that we can do data-state="expanded" or "collapsed".
109
+ // This makes it easier to style the sidebar with Tailwind classes.
110
+ const state = open ? "expanded" : "collapsed";
111
+
112
+ const contextValue = React.useMemo<SidebarContextProps>(
113
+ () => ({
114
+ state,
115
+ open,
116
+ setOpen,
117
+ isMobile,
118
+ openMobile,
119
+ setOpenMobile,
120
+ toggleSidebar,
121
+ }),
122
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
123
+ );
124
+
125
+ return (
126
+ <SidebarContext.Provider value={contextValue}>
127
+ <div
128
+ data-slot="sidebar-wrapper"
129
+ style={
130
+ {
131
+ "--sidebar-width": SIDEBAR_WIDTH,
132
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
133
+ ...style,
134
+ } as React.CSSProperties
135
+ }
136
+ className={cn(
137
+ "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
138
+ className,
139
+ )}
140
+ {...props}
141
+ >
142
+ {children}
143
+ </div>
144
+ </SidebarContext.Provider>
145
+ );
146
+ }
147
+
148
+ function Sidebar({
149
+ side = "left",
150
+ variant = "sidebar",
151
+ collapsible = "offcanvas",
152
+ className,
153
+ children,
154
+ dir,
155
+ ...props
156
+ }: React.ComponentProps<"div"> & {
157
+ side?: "left" | "right";
158
+ variant?: "sidebar" | "floating" | "inset";
159
+ collapsible?: "offcanvas" | "icon" | "none";
160
+ }) {
161
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
162
+
163
+ if (collapsible === "none") {
164
+ return (
165
+ <div
166
+ data-slot="sidebar"
167
+ className={cn(
168
+ "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
169
+ className,
170
+ )}
171
+ {...props}
172
+ >
173
+ {children}
174
+ </div>
175
+ );
176
+ }
177
+
178
+ if (isMobile) {
179
+ return (
180
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
181
+ <SheetContent
182
+ dir={dir}
183
+ data-sidebar="sidebar"
184
+ data-slot="sidebar"
185
+ data-mobile="true"
186
+ className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
187
+ style={
188
+ {
189
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
190
+ } as React.CSSProperties
191
+ }
192
+ side={side}
193
+ >
194
+ <SheetHeader className="sr-only">
195
+ <SheetTitle>Sidebar</SheetTitle>
196
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
197
+ </SheetHeader>
198
+ <div className="flex h-full w-full flex-col">{children}</div>
199
+ </SheetContent>
200
+ </Sheet>
201
+ );
202
+ }
203
+
204
+ return (
205
+ <div
206
+ className="group peer hidden text-sidebar-foreground md:block"
207
+ data-state={state}
208
+ data-collapsible={state === "collapsed" ? collapsible : ""}
209
+ data-variant={variant}
210
+ data-side={side}
211
+ data-slot="sidebar"
212
+ >
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
+ data-side={side}
228
+ className={cn(
229
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
230
+ // Adjust the padding for floating and inset variants.
231
+ variant === "floating" || variant === "inset"
232
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
233
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
234
+ className,
235
+ )}
236
+ {...props}
237
+ >
238
+ <div
239
+ data-sidebar="sidebar"
240
+ data-slot="sidebar-inner"
241
+ className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
242
+ >
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-sm"
263
+ className={cn(className)}
264
+ onClick={(event) => {
265
+ onClick?.(event);
266
+ toggleSidebar();
267
+ }}
268
+ {...props}
269
+ >
270
+ <PanelLeftIcon />
271
+ <span className="sr-only">Toggle Sidebar</span>
272
+ </Button>
273
+ );
274
+ }
275
+
276
+ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
277
+ const { toggleSidebar } = useSidebar();
278
+
279
+ return (
280
+ <button
281
+ data-sidebar="rail"
282
+ data-slot="sidebar-rail"
283
+ aria-label="Toggle Sidebar"
284
+ tabIndex={-1}
285
+ onClick={toggleSidebar}
286
+ title="Toggle Sidebar"
287
+ className={cn(
288
+ "absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
289
+ "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
290
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
291
+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
292
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
293
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
294
+ className,
295
+ )}
296
+ {...props}
297
+ />
298
+ );
299
+ }
300
+
301
+ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
302
+ return (
303
+ <main
304
+ data-slot="sidebar-inset"
305
+ className={cn(
306
+ "relative flex w-full flex-1 flex-col bg-background 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("h-8 w-full bg-background 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("mx-2 w-auto bg-sidebar-border", 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
+ "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 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
+ render,
392
+ ...props
393
+ }: useRender.ComponentProps<"div"> & React.ComponentProps<"div">) {
394
+ return useRender({
395
+ defaultTagName: "div",
396
+ props: mergeProps<"div">(
397
+ {
398
+ className: cn(
399
+ "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
400
+ className,
401
+ ),
402
+ },
403
+ props,
404
+ ),
405
+ render,
406
+ state: {
407
+ slot: "sidebar-group-label",
408
+ sidebar: "group-label",
409
+ },
410
+ });
411
+ }
412
+
413
+ function SidebarGroupAction({
414
+ className,
415
+ render,
416
+ ...props
417
+ }: useRender.ComponentProps<"button"> & React.ComponentProps<"button">) {
418
+ return useRender({
419
+ defaultTagName: "button",
420
+ props: mergeProps<"button">(
421
+ {
422
+ className: cn(
423
+ "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
424
+ className,
425
+ ),
426
+ },
427
+ props,
428
+ ),
429
+ render,
430
+ state: {
431
+ slot: "sidebar-group-action",
432
+ sidebar: "group-action",
433
+ },
434
+ });
435
+ }
436
+
437
+ function SidebarGroupContent({
438
+ className,
439
+ ...props
440
+ }: React.ComponentProps<"div">) {
441
+ return (
442
+ <div
443
+ data-slot="sidebar-group-content"
444
+ data-sidebar="group-content"
445
+ className={cn("w-full text-sm", className)}
446
+ {...props}
447
+ />
448
+ );
449
+ }
450
+
451
+ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
452
+ return (
453
+ <ul
454
+ data-slot="sidebar-menu"
455
+ data-sidebar="menu"
456
+ className={cn("flex w-full min-w-0 flex-col gap-0", className)}
457
+ {...props}
458
+ />
459
+ );
460
+ }
461
+
462
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
463
+ return (
464
+ <li
465
+ data-slot="sidebar-menu-item"
466
+ data-sidebar="menu-item"
467
+ className={cn("group/menu-item relative", className)}
468
+ {...props}
469
+ />
470
+ );
471
+ }
472
+
473
+ const sidebarMenuButtonVariants = cva(
474
+ "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! 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 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
475
+ {
476
+ variants: {
477
+ variant: {
478
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
479
+ outline:
480
+ "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))]",
481
+ },
482
+ size: {
483
+ default: "h-8 text-sm",
484
+ sm: "h-7 text-xs",
485
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
486
+ },
487
+ },
488
+ defaultVariants: {
489
+ variant: "default",
490
+ size: "default",
491
+ },
492
+ },
493
+ );
494
+
495
+ function SidebarMenuButton({
496
+ render,
497
+ isActive = false,
498
+ variant = "default",
499
+ size = "default",
500
+ tooltip,
501
+ className,
502
+ ...props
503
+ }: useRender.ComponentProps<"button"> &
504
+ React.ComponentProps<"button"> & {
505
+ isActive?: boolean;
506
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>;
507
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
508
+ const { isMobile, state } = useSidebar();
509
+ const comp = useRender({
510
+ defaultTagName: "button",
511
+ props: mergeProps<"button">(
512
+ {
513
+ className: cn(sidebarMenuButtonVariants({ variant, size }), className),
514
+ },
515
+ props,
516
+ ),
517
+ render: !tooltip ? render : <TooltipTrigger render={render} />,
518
+ state: {
519
+ slot: "sidebar-menu-button",
520
+ sidebar: "menu-button",
521
+ size,
522
+ active: isActive,
523
+ },
524
+ });
525
+
526
+ if (!tooltip) {
527
+ return comp;
528
+ }
529
+
530
+ if (typeof tooltip === "string") {
531
+ tooltip = {
532
+ children: tooltip,
533
+ };
534
+ }
535
+
536
+ return (
537
+ <Tooltip>
538
+ {comp}
539
+ <TooltipContent
540
+ side="right"
541
+ align="center"
542
+ hidden={state !== "collapsed" || isMobile}
543
+ {...tooltip}
544
+ />
545
+ </Tooltip>
546
+ );
547
+ }
548
+
549
+ function SidebarMenuAction({
550
+ className,
551
+ render,
552
+ showOnHover = false,
553
+ ...props
554
+ }: useRender.ComponentProps<"button"> &
555
+ React.ComponentProps<"button"> & {
556
+ showOnHover?: boolean;
557
+ }) {
558
+ return useRender({
559
+ defaultTagName: "button",
560
+ props: mergeProps<"button">(
561
+ {
562
+ className: cn(
563
+ "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
564
+ showOnHover &&
565
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
566
+ className,
567
+ ),
568
+ },
569
+ props,
570
+ ),
571
+ render,
572
+ state: {
573
+ slot: "sidebar-menu-action",
574
+ sidebar: "menu-action",
575
+ },
576
+ });
577
+ }
578
+
579
+ function SidebarMenuBadge({
580
+ className,
581
+ ...props
582
+ }: React.ComponentProps<"div">) {
583
+ return (
584
+ <div
585
+ data-slot="sidebar-menu-badge"
586
+ data-sidebar="menu-badge"
587
+ className={cn(
588
+ "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
589
+ className,
590
+ )}
591
+ {...props}
592
+ />
593
+ );
594
+ }
595
+
596
+ function SidebarMenuSkeleton({
597
+ className,
598
+ showIcon = false,
599
+ ...props
600
+ }: React.ComponentProps<"div"> & {
601
+ showIcon?: boolean;
602
+ }) {
603
+ // Random width between 50 to 90%.
604
+ const [width] = React.useState(() => {
605
+ return `${Math.floor(Math.random() * 40) + 50}%`;
606
+ });
607
+
608
+ return (
609
+ <div
610
+ data-slot="sidebar-menu-skeleton"
611
+ data-sidebar="menu-skeleton"
612
+ className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
613
+ {...props}
614
+ >
615
+ {showIcon && (
616
+ <Skeleton
617
+ className="size-4 rounded-md"
618
+ data-sidebar="menu-skeleton-icon"
619
+ />
620
+ )}
621
+ <Skeleton
622
+ className="h-4 max-w-(--skeleton-width) flex-1"
623
+ data-sidebar="menu-skeleton-text"
624
+ style={
625
+ {
626
+ "--skeleton-width": width,
627
+ } as React.CSSProperties
628
+ }
629
+ />
630
+ </div>
631
+ );
632
+ }
633
+
634
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
635
+ return (
636
+ <ul
637
+ data-slot="sidebar-menu-sub"
638
+ data-sidebar="menu-sub"
639
+ className={cn(
640
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
641
+ className,
642
+ )}
643
+ {...props}
644
+ />
645
+ );
646
+ }
647
+
648
+ function SidebarMenuSubItem({
649
+ className,
650
+ ...props
651
+ }: React.ComponentProps<"li">) {
652
+ return (
653
+ <li
654
+ data-slot="sidebar-menu-sub-item"
655
+ data-sidebar="menu-sub-item"
656
+ className={cn("group/menu-sub-item relative", className)}
657
+ {...props}
658
+ />
659
+ );
660
+ }
661
+
662
+ function SidebarMenuSubButton({
663
+ render,
664
+ size = "md",
665
+ isActive = false,
666
+ className,
667
+ ...props
668
+ }: useRender.ComponentProps<"a"> &
669
+ React.ComponentProps<"a"> & {
670
+ size?: "sm" | "md";
671
+ isActive?: boolean;
672
+ }) {
673
+ return useRender({
674
+ defaultTagName: "a",
675
+ props: mergeProps<"a">(
676
+ {
677
+ className: cn(
678
+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden 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 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
679
+ className,
680
+ ),
681
+ },
682
+ props,
683
+ ),
684
+ render,
685
+ state: {
686
+ slot: "sidebar-menu-sub-button",
687
+ sidebar: "menu-sub-button",
688
+ size,
689
+ active: isActive,
690
+ },
691
+ });
692
+ }
693
+
694
+ export {
695
+ Sidebar,
696
+ SidebarContent,
697
+ SidebarFooter,
698
+ SidebarGroup,
699
+ SidebarGroupAction,
700
+ SidebarGroupContent,
701
+ SidebarGroupLabel,
702
+ SidebarHeader,
703
+ SidebarInput,
704
+ SidebarInset,
705
+ SidebarMenu,
706
+ SidebarMenuAction,
707
+ SidebarMenuBadge,
708
+ SidebarMenuButton,
709
+ SidebarMenuItem,
710
+ SidebarMenuSkeleton,
711
+ SidebarMenuSub,
712
+ SidebarMenuSubButton,
713
+ SidebarMenuSubItem,
714
+ SidebarProvider,
715
+ SidebarRail,
716
+ SidebarSeparator,
717
+ SidebarTrigger,
718
+ useSidebar,
719
+ };