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