@momentumworld/ui-react 0.17.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 (138) hide show
  1. package/dist/chunk-2HQPCV2L.js +895 -0
  2. package/dist/chunk-2HQPCV2L.js.map +1 -0
  3. package/dist/form.d.ts +175 -0
  4. package/dist/form.js +356 -0
  5. package/dist/form.js.map +1 -0
  6. package/dist/index.d.ts +2162 -0
  7. package/dist/index.js +11640 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/input-JCZs61MO.d.ts +24 -0
  10. package/package.json +90 -0
  11. package/src/components/form/checkbox-group-field.tsx +101 -0
  12. package/src/components/form/date-field.tsx +79 -0
  13. package/src/components/form/date-range-field.tsx +106 -0
  14. package/src/components/form/form-context.ts +10 -0
  15. package/src/components/form/form.tsx +54 -0
  16. package/src/components/form/number-field.tsx +69 -0
  17. package/src/components/form/select-field.tsx +76 -0
  18. package/src/components/form/submit-button.tsx +28 -0
  19. package/src/components/form/text-field.tsx +107 -0
  20. package/src/components/layout/dashboard-header.tsx +54 -0
  21. package/src/components/layout/dashboard-panel.tsx +34 -0
  22. package/src/components/layout/dashboard-topbar.tsx +221 -0
  23. package/src/components/theme-provider.tsx +403 -0
  24. package/src/components/ui/accordion.tsx +69 -0
  25. package/src/components/ui/alert-dialog.tsx +169 -0
  26. package/src/components/ui/alert.tsx +80 -0
  27. package/src/components/ui/animated-counter.tsx +109 -0
  28. package/src/components/ui/animated-theme-toggler.tsx +265 -0
  29. package/src/components/ui/app-store-buttons.tsx +182 -0
  30. package/src/components/ui/aspect-ratio.tsx +23 -0
  31. package/src/components/ui/aurora-orb.tsx +163 -0
  32. package/src/components/ui/aurora-text.tsx +76 -0
  33. package/src/components/ui/autocomplete.tsx +296 -0
  34. package/src/components/ui/avatar-group.tsx +150 -0
  35. package/src/components/ui/avatar.tsx +285 -0
  36. package/src/components/ui/badge-group.tsx +160 -0
  37. package/src/components/ui/badge.tsx +172 -0
  38. package/src/components/ui/breadcrumb.tsx +112 -0
  39. package/src/components/ui/button.tsx +77 -0
  40. package/src/components/ui/calendar.tsx +137 -0
  41. package/src/components/ui/card.tsx +244 -0
  42. package/src/components/ui/carousel.tsx +258 -0
  43. package/src/components/ui/chart.tsx +379 -0
  44. package/src/components/ui/chat-divider.tsx +67 -0
  45. package/src/components/ui/chat.tsx +494 -0
  46. package/src/components/ui/checkbox-group.tsx +16 -0
  47. package/src/components/ui/checkbox.tsx +82 -0
  48. package/src/components/ui/collapsible.tsx +45 -0
  49. package/src/components/ui/color-picker.tsx +389 -0
  50. package/src/components/ui/combobox.tsx +411 -0
  51. package/src/components/ui/command.tsx +264 -0
  52. package/src/components/ui/confetti.tsx +196 -0
  53. package/src/components/ui/context-menu.tsx +271 -0
  54. package/src/components/ui/context-meter.tsx +134 -0
  55. package/src/components/ui/credit-card.tsx +214 -0
  56. package/src/components/ui/data-table-paged.tsx +163 -0
  57. package/src/components/ui/date-picker.tsx +154 -0
  58. package/src/components/ui/dialog.tsx +196 -0
  59. package/src/components/ui/drawer.tsx +135 -0
  60. package/src/components/ui/empty.tsx +127 -0
  61. package/src/components/ui/fab.tsx +45 -0
  62. package/src/components/ui/featured-icon.tsx +149 -0
  63. package/src/components/ui/field.tsx +88 -0
  64. package/src/components/ui/fieldset.tsx +29 -0
  65. package/src/components/ui/form.tsx +17 -0
  66. package/src/components/ui/frame.tsx +82 -0
  67. package/src/components/ui/generic-empty.tsx +142 -0
  68. package/src/components/ui/group.tsx +97 -0
  69. package/src/components/ui/help-tip.tsx +94 -0
  70. package/src/components/ui/horizontal-scroll-fader.tsx +228 -0
  71. package/src/components/ui/input-group.tsx +102 -0
  72. package/src/components/ui/input-otp.tsx +96 -0
  73. package/src/components/ui/input.tsx +66 -0
  74. package/src/components/ui/item.tsx +198 -0
  75. package/src/components/ui/kbd.tsx +30 -0
  76. package/src/components/ui/label.tsx +28 -0
  77. package/src/components/ui/markdown.tsx +188 -0
  78. package/src/components/ui/menu.tsx +312 -0
  79. package/src/components/ui/menubar.tsx +93 -0
  80. package/src/components/ui/meter.tsx +67 -0
  81. package/src/components/ui/multi-select.tsx +308 -0
  82. package/src/components/ui/navigation-menu.tsx +143 -0
  83. package/src/components/ui/number-field.tsx +160 -0
  84. package/src/components/ui/pagination-controls.tsx +74 -0
  85. package/src/components/ui/pagination.tsx +149 -0
  86. package/src/components/ui/pipeline.tsx +102 -0
  87. package/src/components/ui/popover.tsx +119 -0
  88. package/src/components/ui/preview-card.tsx +55 -0
  89. package/src/components/ui/progress.tsx +289 -0
  90. package/src/components/ui/qr-code.tsx +150 -0
  91. package/src/components/ui/radio-group.tsx +103 -0
  92. package/src/components/ui/resizable.tsx +56 -0
  93. package/src/components/ui/scroll-area.tsx +90 -0
  94. package/src/components/ui/scroller.tsx +38 -0
  95. package/src/components/ui/section-header.tsx +118 -0
  96. package/src/components/ui/segmented-control.tsx +83 -0
  97. package/src/components/ui/select.tsx +181 -0
  98. package/src/components/ui/separator.tsx +23 -0
  99. package/src/components/ui/sheet.tsx +224 -0
  100. package/src/components/ui/sidebar.tsx +774 -0
  101. package/src/components/ui/skeleton.tsx +16 -0
  102. package/src/components/ui/slider.tsx +108 -0
  103. package/src/components/ui/smooth-scroll.tsx +206 -0
  104. package/src/components/ui/social-button.tsx +247 -0
  105. package/src/components/ui/spinner-on-demand.tsx +32 -0
  106. package/src/components/ui/spinner.tsx +18 -0
  107. package/src/components/ui/stat.tsx +187 -0
  108. package/src/components/ui/stepper.tsx +167 -0
  109. package/src/components/ui/switch.tsx +56 -0
  110. package/src/components/ui/table.tsx +126 -0
  111. package/src/components/ui/tabs.tsx +90 -0
  112. package/src/components/ui/tag.tsx +242 -0
  113. package/src/components/ui/target-countdown.tsx +46 -0
  114. package/src/components/ui/text-editor.tsx +313 -0
  115. package/src/components/ui/textarea.tsx +51 -0
  116. package/src/components/ui/thinking-orb.tsx +6 -0
  117. package/src/components/ui/time-picker.tsx +308 -0
  118. package/src/components/ui/timeline.tsx +116 -0
  119. package/src/components/ui/toast.tsx +268 -0
  120. package/src/components/ui/toggle-group.tsx +101 -0
  121. package/src/components/ui/toggle.tsx +45 -0
  122. package/src/components/ui/toolbar.tsx +89 -0
  123. package/src/components/ui/tooltip.tsx +102 -0
  124. package/src/components/ui/vertical-scroll-fader.tsx +250 -0
  125. package/src/components/ui/video-player.tsx +275 -0
  126. package/src/components/upload/avatar-upload-base.tsx +131 -0
  127. package/src/components/upload/image-upload-base.tsx +112 -0
  128. package/src/form.ts +17 -0
  129. package/src/index.ts +143 -0
  130. package/src/lib/hooks/use-callback-ref.ts +15 -0
  131. package/src/lib/hooks/use-first-render.ts +11 -0
  132. package/src/lib/hooks/use-hover.ts +53 -0
  133. package/src/lib/hooks/use-is-tab-active.ts +17 -0
  134. package/src/lib/hooks/use-media-query.ts +164 -0
  135. package/src/lib/utils/css.ts +6 -0
  136. package/src/styles.css +329 -0
  137. package/src/types/helpers.ts +24 -0
  138. package/src/types/react.d.ts +7 -0
@@ -0,0 +1,774 @@
1
+ "use client";
2
+
3
+ import { mergeProps } from "@base-ui/react/merge-props";
4
+ import { useRender } from "@base-ui/react/use-render";
5
+ import { cva, type VariantProps } from "class-variance-authority";
6
+ import { PanelLeftIcon } from "lucide-react";
7
+ import * as React from "react";
8
+ import { Button } from "./button";
9
+ import { Input } from "./input";
10
+ import { ScrollArea } from "./scroll-area";
11
+ import { Separator } from "./separator";
12
+ import {
13
+ Sheet,
14
+ SheetDescription,
15
+ SheetHeader,
16
+ SheetPopup,
17
+ SheetTitle,
18
+ } from "./sheet";
19
+ import { Skeleton } from "./skeleton";
20
+ import { Tooltip, TooltipPopup, TooltipTrigger } from "./tooltip";
21
+ import { cn } from "../../lib/utils/css";
22
+
23
+ // Runs before paint on the client (so the mobile/desktop sidebar is correct on
24
+ // the first frame — no pop-in), but degrades to useEffect during SSR.
25
+ const useIsomorphicLayoutEffect =
26
+ typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
27
+
28
+ const SIDEBAR_COOKIE_NAME = "sidebar_state";
29
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
30
+ const SIDEBAR_WIDTH_LG = "18.5rem";
31
+ const SIDEBAR_WIDTH_MD = "14.5rem";
32
+ const SIDEBAR_WIDTH_MOBILE = "18rem";
33
+ const SIDEBAR_WIDTH_ICON = "3rem";
34
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b";
35
+
36
+ type SidebarContextProps = {
37
+ state: "expanded" | "collapsed";
38
+ open: boolean;
39
+ setOpen: (open: boolean) => void;
40
+ openMobile: boolean;
41
+ setOpenMobile: (open: boolean) => void;
42
+ isMobile: boolean;
43
+ toggleSidebar: () => void;
44
+ };
45
+
46
+ const SidebarContext = React.createContext<SidebarContextProps | null>(null);
47
+
48
+ function useSidebar() {
49
+ const context = React.useContext(SidebarContext);
50
+ if (!context) {
51
+ throw new Error("useSidebar must be used within a SidebarProvider.");
52
+ }
53
+
54
+ return context;
55
+ }
56
+
57
+ function SidebarProvider({
58
+ defaultOpen = true,
59
+ open: openProp,
60
+ onOpenChange: setOpenProp,
61
+ persistKey,
62
+ className,
63
+ style,
64
+ children,
65
+ ...props
66
+ }: React.ComponentProps<"div"> & {
67
+ defaultOpen?: boolean;
68
+ open?: boolean;
69
+ onOpenChange?: (open: boolean) => void;
70
+ /**
71
+ * Remember the expanded/collapsed state in `localStorage` under this key and
72
+ * restore it on the next load (desktop rail only; the mobile sheet is always
73
+ * closed on load). Opt-in — omit to keep the sidebar un-persisted. Ignored in
74
+ * controlled mode (when `open` is provided). The restore runs before first
75
+ * paint, so there's no expand→collapse flash.
76
+ */
77
+ persistKey?: string;
78
+ }) {
79
+ // Self-contained breakpoint check (md = 48rem). Resolved in a layout effect
80
+ // before the first paint so the sidebar never flashes from mobile to desktop.
81
+ const [isMobile, setIsMobile] = React.useState(false);
82
+ useIsomorphicLayoutEffect(() => {
83
+ const mql = window.matchMedia("(max-width: 47.999rem)");
84
+ const onChange = () => setIsMobile(mql.matches);
85
+ onChange();
86
+ mql.addEventListener("change", onChange);
87
+ return () => mql.removeEventListener("change", onChange);
88
+ }, []);
89
+ const [openMobile, setOpenMobile] = React.useState(false);
90
+
91
+ // This is the internal state of the sidebar.
92
+ // We use openProp and setOpenProp for control from outside the component.
93
+ const [_open, _setOpen] = React.useState(defaultOpen);
94
+ const open = openProp ?? _open;
95
+ const setOpen = React.useCallback(
96
+ (value: boolean | ((value: boolean) => boolean)) => {
97
+ const openState = typeof value === "function" ? value(open) : value;
98
+ if (setOpenProp) {
99
+ setOpenProp(openState);
100
+ } else {
101
+ _setOpen(openState);
102
+ }
103
+
104
+ // Persist the sidebar state. document.cookie works in every browser
105
+ // (cookieStore is Chromium-only and throws elsewhere). When `persistKey`
106
+ // is set we also mirror it to localStorage so a client-only app (no SSR
107
+ // cookie read) can restore it on load.
108
+ try {
109
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
110
+ if (persistKey) {
111
+ window.localStorage.setItem(persistKey, openState ? "true" : "false");
112
+ }
113
+ } catch {
114
+ // Ignore — persistence is best-effort.
115
+ }
116
+ },
117
+ [setOpenProp, open, persistKey],
118
+ );
119
+
120
+ // Restore the persisted (localStorage) open state on mount — uncontrolled use
121
+ // only. Runs in a layout effect so the restore lands before first paint (no
122
+ // expand→collapse flash). SSR renders `defaultOpen` and the client's first
123
+ // render matches it, so this reconciles afterwards without a hydration
124
+ // mismatch.
125
+ useIsomorphicLayoutEffect(() => {
126
+ if (!persistKey || openProp !== undefined) return;
127
+ try {
128
+ const stored = window.localStorage.getItem(persistKey);
129
+ if (stored === "true" || stored === "false") {
130
+ _setOpen(stored === "true");
131
+ }
132
+ } catch {
133
+ // Ignore — restore is best-effort.
134
+ }
135
+ }, [persistKey, openProp]);
136
+
137
+ // Helper to toggle the sidebar.
138
+ const toggleSidebar = React.useCallback(() => {
139
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
140
+ }, [isMobile, setOpen]);
141
+
142
+ // Adds a keyboard shortcut to toggle the sidebar.
143
+ React.useEffect(() => {
144
+ const handleKeyDown = (event: KeyboardEvent) => {
145
+ if (
146
+ event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
147
+ (event.metaKey || event.ctrlKey)
148
+ ) {
149
+ event.preventDefault();
150
+ toggleSidebar();
151
+ }
152
+ };
153
+
154
+ window.addEventListener("keydown", handleKeyDown);
155
+ return () => window.removeEventListener("keydown", handleKeyDown);
156
+ }, [toggleSidebar]);
157
+
158
+ // We add a state so that we can do data-state="expanded" or "collapsed".
159
+ // This makes it easier to style the sidebar with Tailwind classes.
160
+ const state = open ? "expanded" : "collapsed";
161
+
162
+ const contextValue = React.useMemo<SidebarContextProps>(
163
+ () => ({
164
+ isMobile,
165
+ open,
166
+ openMobile,
167
+ setOpen,
168
+ setOpenMobile,
169
+ state,
170
+ toggleSidebar,
171
+ }),
172
+ [state, open, setOpen, isMobile, openMobile, toggleSidebar],
173
+ );
174
+
175
+ return (
176
+ <SidebarContext.Provider value={contextValue}>
177
+ <div
178
+ className={cn(
179
+ "group/sidebar-wrapper flex h-full w-full",
180
+ "[--sidebar-width:var(--sidebar-width-md)] lg:[--sidebar-width:var(--sidebar-width-lg)]",
181
+ className,
182
+ )}
183
+ data-slot="sidebar-wrapper"
184
+ style={{
185
+ "--sidebar-width-lg": SIDEBAR_WIDTH_LG,
186
+ "--sidebar-width-md": SIDEBAR_WIDTH_MD,
187
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
188
+ ...style,
189
+ }}
190
+ {...props}
191
+ >
192
+ {children}
193
+ </div>
194
+ </SidebarContext.Provider>
195
+ );
196
+ }
197
+
198
+ function Sidebar({
199
+ side = "left",
200
+ variant = "sidebar",
201
+ collapsible = "offcanvas",
202
+ className,
203
+ children,
204
+ ...props
205
+ }: React.ComponentProps<"div"> & {
206
+ side?: "left" | "right";
207
+ variant?: "sidebar" | "floating" | "inset";
208
+ collapsible?: "offcanvas" | "icon" | "none";
209
+ }) {
210
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
211
+
212
+ if (collapsible === "none") {
213
+ return (
214
+ <div
215
+ className={cn(
216
+ "flex h-full w-(--sidebar-width) flex-col bg-sidebar md:bg-transparent text-sidebar-foreground",
217
+ className,
218
+ )}
219
+ data-slot="sidebar"
220
+ {...props}
221
+ >
222
+ {children}
223
+ </div>
224
+ );
225
+ }
226
+
227
+ if (isMobile) {
228
+ return (
229
+ <Sheet onOpenChange={setOpenMobile} open={openMobile} {...props}>
230
+ <SheetPopup
231
+ className="w-(--sidebar-width) bg-sidebar md:bg-transparent p-0 text-sidebar-foreground [&>button]:hidden"
232
+ data-mobile="true"
233
+ data-sidebar="sidebar"
234
+ data-slot="sidebar"
235
+ side={side}
236
+ style={{
237
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
238
+ }}
239
+ >
240
+ <SheetHeader className="sr-only">
241
+ <SheetTitle>Sidebar</SheetTitle>
242
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
243
+ </SheetHeader>
244
+ <div className="flex h-full w-full flex-col">{children}</div>
245
+ </SheetPopup>
246
+ </Sheet>
247
+ );
248
+ }
249
+
250
+ return (
251
+ <div
252
+ className="group peer hidden text-sidebar-foreground md:block"
253
+ data-collapsible={state === "collapsed" ? collapsible : ""}
254
+ data-side={side}
255
+ data-slot="sidebar"
256
+ data-state={state}
257
+ data-variant={variant}
258
+ >
259
+ {/* This is what handles the sidebar gap on desktop */}
260
+ <div
261
+ className={cn(
262
+ "relative w-(--sidebar-width) bg-transparent transition-[width] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)]",
263
+ "group-data-[collapsible=offcanvas]:w-0",
264
+ "group-data-[side=right]:rotate-180",
265
+ variant === "floating" || variant === "inset"
266
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
267
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
268
+ )}
269
+ data-slot="sidebar-gap"
270
+ />
271
+ <div
272
+ className={cn(
273
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] md:flex",
274
+ side === "left"
275
+ ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
276
+ : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
277
+ // Adjust the padding for floating and inset variants.
278
+ variant === "floating" || variant === "inset"
279
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
280
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
281
+ className,
282
+ )}
283
+ data-slot="sidebar-container"
284
+ {...props}
285
+ >
286
+ <div
287
+ className="flex h-full w-full flex-col bg-sidebar md:bg-transparent group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm/5"
288
+ data-sidebar="sidebar"
289
+ data-slot="sidebar-inner"
290
+ >
291
+ {children}
292
+ </div>
293
+ </div>
294
+ </div>
295
+ );
296
+ }
297
+
298
+ function SidebarTrigger({
299
+ className,
300
+ onClick,
301
+ ...props
302
+ }: React.ComponentProps<typeof Button>) {
303
+ const { toggleSidebar } = useSidebar();
304
+
305
+ return (
306
+ <Button
307
+ className={cn("size-7", className)}
308
+ data-sidebar="trigger"
309
+ data-slot="sidebar-trigger"
310
+ onClick={(event) => {
311
+ onClick?.(event);
312
+ toggleSidebar();
313
+ }}
314
+ size="icon"
315
+ variant="ghost"
316
+ {...props}
317
+ >
318
+ <PanelLeftIcon />
319
+ <span className="sr-only">Toggle Sidebar</span>
320
+ </Button>
321
+ );
322
+ }
323
+
324
+ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
325
+ const { toggleSidebar } = useSidebar();
326
+
327
+ return (
328
+ <button
329
+ aria-label="Toggle Sidebar"
330
+ className={cn(
331
+ "-translate-x-1/2 group-data-[side=left]:-right-4 absolute inset-y-0 z-20 hidden w-4 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=right]:left-0 sm:flex",
332
+ "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
333
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
334
+ "group-data-[collapsible=offcanvas]:translate-x-0 hover:group-data-[collapsible=offcanvas]:bg-sidebar md:bg-transparent group-data-[collapsible=offcanvas]:after:left-full",
335
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
336
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
337
+ className,
338
+ )}
339
+ data-sidebar="rail"
340
+ data-slot="sidebar-rail"
341
+ onClick={toggleSidebar}
342
+ tabIndex={-1}
343
+ title="Toggle Sidebar"
344
+ type="button"
345
+ {...props}
346
+ />
347
+ );
348
+ }
349
+
350
+ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
351
+ return (
352
+ <main
353
+ className={cn(
354
+ "relative flex w-full flex-1 flex-col bg-background",
355
+ "md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ms-2 md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ms-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm/5",
356
+ className,
357
+ )}
358
+ data-slot="sidebar-inset"
359
+ {...props}
360
+ />
361
+ );
362
+ }
363
+
364
+ function SidebarInput({
365
+ className,
366
+ ...props
367
+ }: React.ComponentProps<typeof Input>) {
368
+ return (
369
+ <Input
370
+ className={cn("h-8 w-full bg-background shadow-none", className)}
371
+ data-sidebar="input"
372
+ data-slot="sidebar-input"
373
+ {...props}
374
+ />
375
+ );
376
+ }
377
+
378
+ function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
379
+ return (
380
+ <div
381
+ className={cn("flex flex-col gap-2 p-2", className)}
382
+ data-sidebar="header"
383
+ data-slot="sidebar-header"
384
+ {...props}
385
+ />
386
+ );
387
+ }
388
+
389
+ function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
390
+ return (
391
+ <div
392
+ className={cn("flex flex-col gap-2 p-2", className)}
393
+ data-sidebar="footer"
394
+ data-slot="sidebar-footer"
395
+ {...props}
396
+ />
397
+ );
398
+ }
399
+
400
+ function SidebarSeparator({
401
+ className,
402
+ ...props
403
+ }: React.ComponentProps<typeof Separator>) {
404
+ return (
405
+ <Separator
406
+ className={cn("mx-2 w-auto bg-sidebar-border", className)}
407
+ data-sidebar="separator"
408
+ data-slot="sidebar-separator"
409
+ {...props}
410
+ />
411
+ );
412
+ }
413
+
414
+ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
415
+ return (
416
+ <ScrollArea className="pr-1.5 -mr-1.5" scrollFade>
417
+ <div
418
+ className={cn(
419
+ "flex flex-1 flex-col group-data-[collapsible=icon]:overflow-hidden",
420
+ className,
421
+ )}
422
+ data-sidebar="content"
423
+ data-slot="sidebar-content"
424
+ {...props}
425
+ />
426
+ </ScrollArea>
427
+ );
428
+ }
429
+
430
+ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
431
+ return (
432
+ <div
433
+ className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
434
+ data-sidebar="group"
435
+ data-slot="sidebar-group"
436
+ {...props}
437
+ />
438
+ );
439
+ }
440
+
441
+ function SidebarGroupLabel({
442
+ className,
443
+ render,
444
+ ...props
445
+ }: useRender.ComponentProps<"div">) {
446
+ const defaultProps = {
447
+ className: cn(
448
+ "flex h-8 shrink-0 items-center rounded-lg px-2 font-medium text-sidebar-foreground/70 text-xs outline-hidden ring-sidebar-ring transition-[margin,opacity] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
449
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
450
+ className,
451
+ ),
452
+ "data-sidebar": "group-label",
453
+ "data-slot": "sidebar-group-label",
454
+ };
455
+
456
+ return useRender({
457
+ defaultTagName: "div",
458
+ props: mergeProps(defaultProps, props),
459
+ render,
460
+ });
461
+ }
462
+
463
+ function SidebarGroupAction({
464
+ className,
465
+ render,
466
+ ...props
467
+ }: useRender.ComponentProps<"button">) {
468
+ const defaultProps = {
469
+ className: cn(
470
+ "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-lg p-0 text-sidebar-foreground outline-hidden ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0",
471
+ // Increases the hit area of the button on mobile.
472
+ "after:-inset-2 after:absolute md:after:hidden",
473
+ "group-data-[collapsible=icon]:hidden",
474
+ className,
475
+ ),
476
+ "data-sidebar": "group-action",
477
+ "data-slot": "sidebar-group-action",
478
+ };
479
+
480
+ return useRender({
481
+ defaultTagName: "button",
482
+ props: mergeProps(defaultProps, props),
483
+ render,
484
+ });
485
+ }
486
+
487
+ function SidebarGroupContent({
488
+ className,
489
+ ...props
490
+ }: React.ComponentProps<"div">) {
491
+ return (
492
+ <div
493
+ className={cn("w-full text-sm", className)}
494
+ data-sidebar="group-content"
495
+ data-slot="sidebar-group-content"
496
+ {...props}
497
+ />
498
+ );
499
+ }
500
+
501
+ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
502
+ return (
503
+ <ul
504
+ className={cn("flex w-full min-w-0 flex-col gap-1", className)}
505
+ data-sidebar="menu"
506
+ data-slot="sidebar-menu"
507
+ {...props}
508
+ />
509
+ );
510
+ }
511
+
512
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
513
+ return (
514
+ <li
515
+ className={cn("group/menu-item relative", className)}
516
+ data-sidebar="menu-item"
517
+ data-slot="sidebar-menu-item"
518
+ {...props}
519
+ />
520
+ );
521
+ }
522
+
523
+ const sidebarMenuButtonVariants = cva(
524
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-lg border border-transparent text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding,background-color] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] hover:bg-secondary focus-visible:ring-2 active:bg-secondary disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pe-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[status=active]:bg-background data-[status=active]:font-medium data-[status=active]:text-sidebar-accent-foreground data-[active=true]:bg-background data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-background data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-3! [&>span:last-child]:truncate [&>span:last-child]:transition-opacity [&>span:last-child]:duration-200 [&>span:last-child]:ease-out group-data-[collapsible=icon]:[&>span:last-child]:opacity-0 [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0 data-[status=active]:border-border data-[status=active]:shadow-xs data-[status=active]:hover:bg-background data-[status=active]:hover:text-sidebar-accent-foreground",
525
+ {
526
+ defaultVariants: {
527
+ size: "default",
528
+ variant: "default",
529
+ },
530
+ variants: {
531
+ size: {
532
+ default: "h-9 font-normal p-2 text-sm",
533
+ lg: "h-11 p-3 font-medium text-sm group-data-[collapsible=icon]:p-0!",
534
+ sm: "h-7 p-2 font-normal text-xs",
535
+ },
536
+ variant: {
537
+ default: "hover:bg-secondary",
538
+ outline: "bg-sidebar-accent text-foreground shadow-xs border",
539
+ },
540
+ },
541
+ },
542
+ );
543
+
544
+ function SidebarMenuButton({
545
+ isActive = false,
546
+ variant = "default",
547
+ size = "default",
548
+ tooltip,
549
+ className,
550
+ render,
551
+ ...props
552
+ }: useRender.ComponentProps<"button"> & {
553
+ isActive?: boolean;
554
+ tooltip?: string | React.ComponentProps<typeof TooltipPopup>;
555
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
556
+ const { isMobile, state } = useSidebar();
557
+
558
+ const defaultProps = {
559
+ className: cn(sidebarMenuButtonVariants({ size, variant }), className),
560
+ "data-active": isActive,
561
+ "data-sidebar": "menu-button",
562
+ "data-size": size,
563
+ "data-slot": "sidebar-menu-button",
564
+ };
565
+
566
+ const buttonProps = mergeProps<"button">(defaultProps, props);
567
+
568
+ const buttonElement = useRender({
569
+ defaultTagName: "button",
570
+ props: buttonProps,
571
+ render,
572
+ });
573
+
574
+ if (!tooltip) {
575
+ return buttonElement;
576
+ }
577
+
578
+ if (typeof tooltip === "string") {
579
+ tooltip = {
580
+ children: tooltip,
581
+ };
582
+ }
583
+
584
+ return (
585
+ <Tooltip>
586
+ <TooltipTrigger
587
+ render={buttonElement as React.ReactElement<Record<string, unknown>>}
588
+ />
589
+ <TooltipPopup
590
+ align="center"
591
+ hidden={state !== "collapsed" || isMobile}
592
+ side="right"
593
+ {...tooltip}
594
+ />
595
+ </Tooltip>
596
+ );
597
+ }
598
+
599
+ function SidebarMenuAction({
600
+ className,
601
+ showOnHover = false,
602
+ render,
603
+ ...props
604
+ }: useRender.ComponentProps<"button"> & {
605
+ showOnHover?: boolean;
606
+ }) {
607
+ const defaultProps = {
608
+ className: cn(
609
+ "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-lg p-0 text-sidebar-foreground outline-hidden ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0",
610
+ // Increases the hit area of the button on mobile.
611
+ "after:-inset-2 after:absolute md:after:hidden",
612
+ "peer-data-[size=sm]/menu-button:top-1",
613
+ "peer-data-[size=default]/menu-button:top-1.5",
614
+ "peer-data-[size=lg]/menu-button:top-2.5",
615
+ "group-data-[collapsible=icon]:hidden",
616
+ showOnHover &&
617
+ "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 peer-data-[status=active]/menu-button:text-sidebar-accent-foreground md:opacity-0",
618
+ className,
619
+ ),
620
+ "data-sidebar": "menu-action",
621
+ "data-slot": "sidebar-menu-action",
622
+ };
623
+
624
+ return useRender({
625
+ defaultTagName: "button",
626
+ props: mergeProps<"button">(defaultProps, props),
627
+ render,
628
+ });
629
+ }
630
+
631
+ function SidebarMenuBadge({
632
+ className,
633
+ ...props
634
+ }: React.ComponentProps<"div">) {
635
+ return (
636
+ <div
637
+ className={cn(
638
+ // Vertically centered against the menu button (size-agnostic) rather
639
+ // than pinned to the top, so the count reads level with the label.
640
+ "pointer-events-none absolute right-1 top-1/2 flex h-5 min-w-5 -translate-y-1/2 select-none items-center justify-center rounded-lg px-1 font-medium text-sidebar-foreground text-xs tabular-nums",
641
+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground peer-data-[status=active]/menu-button:text-sidebar-accent-foreground",
642
+ "group-data-[collapsible=icon]:hidden",
643
+ className,
644
+ )}
645
+ data-sidebar="menu-badge"
646
+ data-slot="sidebar-menu-badge"
647
+ {...props}
648
+ />
649
+ );
650
+ }
651
+
652
+ function SidebarMenuSkeleton({
653
+ className,
654
+ showIcon = false,
655
+ ...props
656
+ }: React.ComponentProps<"div"> & {
657
+ showIcon?: boolean;
658
+ }) {
659
+ // Random width between 50 to 90%.
660
+ const width = React.useMemo(() => {
661
+ return `${Math.floor(Math.random() * 40) + 50}%`;
662
+ }, []);
663
+
664
+ return (
665
+ <div
666
+ className={cn("flex h-8 items-center gap-2 rounded-lg px-2", className)}
667
+ data-sidebar="menu-skeleton"
668
+ data-slot="sidebar-menu-skeleton"
669
+ {...props}
670
+ >
671
+ {showIcon && (
672
+ <Skeleton
673
+ className="size-4 rounded-lg"
674
+ data-sidebar="menu-skeleton-icon"
675
+ />
676
+ )}
677
+ <Skeleton
678
+ className="h-4 max-w-(--skeleton-width) flex-1"
679
+ data-sidebar="menu-skeleton-text"
680
+ style={{
681
+ "--skeleton-width": width,
682
+ }}
683
+ />
684
+ </div>
685
+ );
686
+ }
687
+
688
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
689
+ return (
690
+ <ul
691
+ className={cn(
692
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-sidebar-border border-l px-2.5 py-0.5",
693
+ "group-data-[collapsible=icon]:hidden",
694
+ className,
695
+ )}
696
+ data-sidebar="menu-sub"
697
+ data-slot="sidebar-menu-sub"
698
+ {...props}
699
+ />
700
+ );
701
+ }
702
+
703
+ function SidebarMenuSubItem({
704
+ className,
705
+ ...props
706
+ }: React.ComponentProps<"li">) {
707
+ return (
708
+ <li
709
+ className={cn("group/menu-sub-item relative", className)}
710
+ data-sidebar="menu-sub-item"
711
+ data-slot="sidebar-menu-sub-item"
712
+ {...props}
713
+ />
714
+ );
715
+ }
716
+
717
+ function SidebarMenuSubButton({
718
+ size = "md",
719
+ isActive = false,
720
+ className,
721
+ render,
722
+ ...props
723
+ }: useRender.ComponentProps<"a"> & {
724
+ size?: "sm" | "md";
725
+ isActive?: boolean;
726
+ }) {
727
+ const defaultProps = {
728
+ className: cn(
729
+ "-translate-x-px flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-lg px-2 text-sidebar-foreground outline-hidden ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-secondary active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
730
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground data-[status=active]:bg-sidebar-accent data-[status=active]:text-sidebar-accent-foreground",
731
+ size === "sm" && "text-xs",
732
+ size === "md" && "text-sm",
733
+ "group-data-[collapsible=icon]:hidden",
734
+ className,
735
+ ),
736
+ "data-active": isActive,
737
+ "data-sidebar": "menu-sub-button",
738
+ "data-size": size,
739
+ "data-slot": "sidebar-menu-sub-button",
740
+ };
741
+
742
+ return useRender({
743
+ defaultTagName: "a",
744
+ props: mergeProps<"a">(defaultProps, props),
745
+ render,
746
+ });
747
+ }
748
+
749
+ export {
750
+ Sidebar,
751
+ SidebarContent,
752
+ SidebarFooter,
753
+ SidebarGroup,
754
+ SidebarGroupAction,
755
+ SidebarGroupContent,
756
+ SidebarGroupLabel,
757
+ SidebarHeader,
758
+ SidebarInput,
759
+ SidebarInset,
760
+ SidebarMenu,
761
+ SidebarMenuAction,
762
+ SidebarMenuBadge,
763
+ SidebarMenuButton,
764
+ SidebarMenuItem,
765
+ SidebarMenuSkeleton,
766
+ SidebarMenuSub,
767
+ SidebarMenuSubButton,
768
+ SidebarMenuSubItem,
769
+ SidebarProvider,
770
+ SidebarRail,
771
+ SidebarSeparator,
772
+ SidebarTrigger,
773
+ useSidebar,
774
+ };