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