@sonamu-kit/react-components 0.1.0 → 0.1.2

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