@mesob/ui 0.1.1 → 0.2.1

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 (103) hide show
  1. package/dist/components/alert-dialog.js +22 -22
  2. package/dist/components/alert-dialog.js.map +1 -1
  3. package/dist/components/alert.js +1 -1
  4. package/dist/components/alert.js.map +1 -1
  5. package/dist/components/animated-tabs.js +1 -1
  6. package/dist/components/animated-tabs.js.map +1 -1
  7. package/dist/components/app-breadcrumbs.d.ts +34 -0
  8. package/dist/components/app-breadcrumbs.js +177 -0
  9. package/dist/components/app-breadcrumbs.js.map +1 -0
  10. package/dist/components/app-header-actions.d.ts +39 -0
  11. package/dist/components/app-header-actions.js +644 -0
  12. package/dist/components/app-header-actions.js.map +1 -0
  13. package/dist/components/app-sidebar.d.ts +24 -0
  14. package/dist/components/app-sidebar.js +669 -0
  15. package/dist/components/app-sidebar.js.map +1 -0
  16. package/dist/components/button-group.js +1 -1
  17. package/dist/components/button-group.js.map +1 -1
  18. package/dist/components/button.d.ts +6 -3
  19. package/dist/components/button.js +16 -8
  20. package/dist/components/button.js.map +1 -1
  21. package/dist/components/calendar.js +24 -16
  22. package/dist/components/calendar.js.map +1 -1
  23. package/dist/components/card.js +1 -1
  24. package/dist/components/card.js.map +1 -1
  25. package/dist/components/carousel.js +28 -20
  26. package/dist/components/carousel.js.map +1 -1
  27. package/dist/components/command.js +5 -5
  28. package/dist/components/command.js.map +1 -1
  29. package/dist/components/context-menu.js +2 -2
  30. package/dist/components/context-menu.js.map +1 -1
  31. package/dist/components/data-table/index.d.ts +9 -2
  32. package/dist/components/data-table/index.js +336 -152
  33. package/dist/components/data-table/index.js.map +1 -1
  34. package/dist/components/dialog.js +2 -2
  35. package/dist/components/dialog.js.map +1 -1
  36. package/dist/components/drawer.js +2 -2
  37. package/dist/components/drawer.js.map +1 -1
  38. package/dist/components/dropdown-menu.js +2 -2
  39. package/dist/components/dropdown-menu.js.map +1 -1
  40. package/dist/components/entity/index.d.ts +85 -9
  41. package/dist/components/entity/index.js +539 -414
  42. package/dist/components/entity/index.js.map +1 -1
  43. package/dist/components/hover-card.js +1 -1
  44. package/dist/components/hover-card.js.map +1 -1
  45. package/dist/components/input-group.d.ts +1 -1
  46. package/dist/components/input-group.js +27 -19
  47. package/dist/components/input-group.js.map +1 -1
  48. package/dist/components/item.d.ts +1 -1
  49. package/dist/components/link.d.ts +12 -0
  50. package/dist/components/link.js +51 -0
  51. package/dist/components/link.js.map +1 -0
  52. package/dist/components/menubar.js +3 -3
  53. package/dist/components/menubar.js.map +1 -1
  54. package/dist/components/mesob-context.d.ts +34 -0
  55. package/dist/components/mesob-context.js +53 -0
  56. package/dist/components/mesob-context.js.map +1 -0
  57. package/dist/components/navigation-menu.js +1 -1
  58. package/dist/components/navigation-menu.js.map +1 -1
  59. package/dist/components/page/index.d.ts +46 -0
  60. package/dist/components/page/index.js +205 -0
  61. package/dist/components/page/index.js.map +1 -0
  62. package/dist/components/pagination.js +20 -20
  63. package/dist/components/pagination.js.map +1 -1
  64. package/dist/components/popover.js +1 -1
  65. package/dist/components/popover.js.map +1 -1
  66. package/dist/components/powered-by.d.ts +4 -1
  67. package/dist/components/powered-by.js +28 -12
  68. package/dist/components/powered-by.js.map +1 -1
  69. package/dist/components/section/index.js +29 -21
  70. package/dist/components/section/index.js.map +1 -1
  71. package/dist/components/select.js +1 -1
  72. package/dist/components/select.js.map +1 -1
  73. package/dist/components/sheet.js +2 -2
  74. package/dist/components/sheet.js.map +1 -1
  75. package/dist/components/shell.d.ts +13 -0
  76. package/dist/components/shell.js +553 -0
  77. package/dist/components/shell.js.map +1 -0
  78. package/dist/components/sidebar.d.ts +4 -0
  79. package/dist/components/sidebar.js +119 -82
  80. package/dist/components/sidebar.js.map +1 -1
  81. package/dist/components/spotlight-search.js +67 -59
  82. package/dist/components/spotlight-search.js.map +1 -1
  83. package/dist/components/table.js +1 -1
  84. package/dist/components/table.js.map +1 -1
  85. package/dist/components/theme-toggle.js +21 -13
  86. package/dist/components/theme-toggle.js.map +1 -1
  87. package/dist/components/tooltip.d.ts +1 -1
  88. package/dist/components/tooltip.js +2 -1
  89. package/dist/components/tooltip.js.map +1 -1
  90. package/dist/hooks/use-router.d.ts +7 -0
  91. package/dist/hooks/use-router.js +36 -0
  92. package/dist/hooks/use-router.js.map +1 -0
  93. package/dist/hooks/use-translation.d.ts +5 -0
  94. package/dist/hooks/use-translation.js +42 -0
  95. package/dist/hooks/use-translation.js.map +1 -0
  96. package/dist/index.d.ts +1 -0
  97. package/dist/index.js +94 -1
  98. package/dist/index.js.map +1 -1
  99. package/dist/lib/theme-schema.d.ts +21 -0
  100. package/dist/lib/theme-schema.js +95 -0
  101. package/dist/lib/theme-schema.js.map +1 -0
  102. package/package.json +8 -5
  103. package/src/styles/globals.css +0 -126
@@ -0,0 +1,669 @@
1
+ "use client";
2
+
3
+ // src/lib/utils.ts
4
+ import { clsx } from "clsx";
5
+ import { twMerge } from "tailwind-merge";
6
+ function cn(...inputs) {
7
+ return twMerge(clsx(inputs));
8
+ }
9
+
10
+ // src/components/tooltip.tsx
11
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ function Tooltip({
14
+ children,
15
+ ...props
16
+ }) {
17
+ return /* @__PURE__ */ jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props, children });
18
+ }
19
+ function TooltipTrigger({
20
+ ...props
21
+ }) {
22
+ return /* @__PURE__ */ jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
23
+ }
24
+ function TooltipContent({
25
+ className,
26
+ sideOffset = 0,
27
+ children,
28
+ ...props
29
+ }) {
30
+ return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
31
+ TooltipPrimitive.Content,
32
+ {
33
+ "data-slot": "tooltip-content",
34
+ sideOffset,
35
+ className: cn(
36
+ "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
37
+ className
38
+ ),
39
+ ...props,
40
+ children: [
41
+ children,
42
+ /* @__PURE__ */ jsx(TooltipPrimitive.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
43
+ ]
44
+ }
45
+ ) });
46
+ }
47
+
48
+ // src/components/mesob-context.tsx
49
+ import {
50
+ createContext,
51
+ useContext,
52
+ useMemo
53
+ } from "react";
54
+ import { jsx as jsx2 } from "react/jsx-runtime";
55
+ var MesobContext = createContext(null);
56
+ function useMesob() {
57
+ return useContext(MesobContext);
58
+ }
59
+
60
+ // src/components/link.tsx
61
+ import { jsx as jsx3 } from "react/jsx-runtime";
62
+ function Link({
63
+ href,
64
+ children,
65
+ className,
66
+ onClick,
67
+ ...props
68
+ }) {
69
+ const mesob = useMesob();
70
+ const LinkComponent = mesob?.linkComponent ?? "a";
71
+ if (LinkComponent === "a") {
72
+ return /* @__PURE__ */ jsx3("a", { href, className, onClick, ...props, children });
73
+ }
74
+ return /* @__PURE__ */ jsx3(
75
+ LinkComponent,
76
+ {
77
+ href,
78
+ className,
79
+ onClick,
80
+ ...props,
81
+ children
82
+ }
83
+ );
84
+ }
85
+
86
+ // src/components/button.tsx
87
+ import { Slot } from "@radix-ui/react-slot";
88
+ import { cva } from "class-variance-authority";
89
+ import { jsxs as jsxs2 } from "react/jsx-runtime";
90
+ var buttonVariants = cva(
91
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
92
+ {
93
+ variants: {
94
+ variant: {
95
+ default: "bg-primary text-primary-foreground hover:bg-primary-600 dark:hover:bg-primary-400",
96
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",
97
+ outline: "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
98
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary-600 dark:hover:bg-secondary-400",
99
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
100
+ link: "text-primary underline-offset-4 hover:text-primary-600 dark:hover:text-primary-400 hover:underline"
101
+ },
102
+ size: {
103
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
104
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
105
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
106
+ icon: "size-9",
107
+ "icon-sm": "size-8",
108
+ "icon-lg": "size-10"
109
+ }
110
+ },
111
+ defaultVariants: {
112
+ variant: "default",
113
+ size: "default"
114
+ }
115
+ }
116
+ );
117
+
118
+ // src/components/input.tsx
119
+ import { jsx as jsx4 } from "react/jsx-runtime";
120
+
121
+ // src/components/separator.tsx
122
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
123
+ import { jsx as jsx5 } from "react/jsx-runtime";
124
+
125
+ // src/components/sheet.tsx
126
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
127
+ import { IconX } from "@tabler/icons-react";
128
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
129
+ function Sheet({ ...props }) {
130
+ return /* @__PURE__ */ jsx6(SheetPrimitive.Root, { "data-slot": "sheet", ...props });
131
+ }
132
+ function SheetPortal({
133
+ ...props
134
+ }) {
135
+ return /* @__PURE__ */ jsx6(SheetPrimitive.Portal, { "data-slot": "sheet-portal", ...props });
136
+ }
137
+ function SheetOverlay({
138
+ className,
139
+ ...props
140
+ }) {
141
+ return /* @__PURE__ */ jsx6(
142
+ SheetPrimitive.Overlay,
143
+ {
144
+ "data-slot": "sheet-overlay",
145
+ className: cn(
146
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=open]:opacity-100 fixed inset-0 z-50 bg-[var(--overlay,oklch(0_0_0/0.5))]",
147
+ className
148
+ ),
149
+ ...props
150
+ }
151
+ );
152
+ }
153
+ function SheetContent({
154
+ className,
155
+ children,
156
+ side = "right",
157
+ ...props
158
+ }) {
159
+ return /* @__PURE__ */ jsxs3(SheetPortal, { children: [
160
+ /* @__PURE__ */ jsx6(SheetOverlay, {}),
161
+ /* @__PURE__ */ jsxs3(
162
+ SheetPrimitive.Content,
163
+ {
164
+ "data-slot": "sheet-content",
165
+ className: cn(
166
+ "bg-background text-foreground border-border data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:opacity-100 fixed z-[51] flex min-w-0 flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
167
+ side === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
168
+ side === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
169
+ side === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
170
+ side === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
171
+ className
172
+ ),
173
+ ...props,
174
+ children: [
175
+ children,
176
+ /* @__PURE__ */ jsxs3(SheetPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
177
+ /* @__PURE__ */ jsx6(IconX, { className: "size-4" }),
178
+ /* @__PURE__ */ jsx6("span", { className: "sr-only", children: "Close" })
179
+ ] })
180
+ ]
181
+ }
182
+ )
183
+ ] });
184
+ }
185
+ function SheetHeader({ className, ...props }) {
186
+ return /* @__PURE__ */ jsx6(
187
+ "div",
188
+ {
189
+ "data-slot": "sheet-header",
190
+ className: cn("flex flex-col gap-1.5 p-4", className),
191
+ ...props
192
+ }
193
+ );
194
+ }
195
+ function SheetTitle({
196
+ className,
197
+ ...props
198
+ }) {
199
+ return /* @__PURE__ */ jsx6(
200
+ SheetPrimitive.Title,
201
+ {
202
+ "data-slot": "sheet-title",
203
+ className: cn("text-foreground font-semibold", className),
204
+ ...props
205
+ }
206
+ );
207
+ }
208
+ function SheetDescription({
209
+ className,
210
+ ...props
211
+ }) {
212
+ return /* @__PURE__ */ jsx6(
213
+ SheetPrimitive.Description,
214
+ {
215
+ "data-slot": "sheet-description",
216
+ className: cn("text-muted-foreground text-sm", className),
217
+ ...props
218
+ }
219
+ );
220
+ }
221
+
222
+ // src/components/skeleton.tsx
223
+ import { jsx as jsx7 } from "react/jsx-runtime";
224
+
225
+ // src/hooks/use-mobile.ts
226
+ import * as React from "react";
227
+
228
+ // src/components/sidebar.tsx
229
+ import { Slot as Slot2 } from "@radix-ui/react-slot";
230
+ import { IconMenu2 } from "@tabler/icons-react";
231
+ import { cva as cva2 } from "class-variance-authority";
232
+ import * as React2 from "react";
233
+ import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
234
+ var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
235
+ var SIDEBAR_WIDTH_MOBILE = "18rem";
236
+ var SidebarContext = React2.createContext(null);
237
+ function useSidebar() {
238
+ const context = React2.useContext(SidebarContext);
239
+ if (!context) {
240
+ throw new Error("useSidebar must be used within a SidebarProvider.");
241
+ }
242
+ return context;
243
+ }
244
+ function Sidebar({
245
+ side = "left",
246
+ variant = "sidebar",
247
+ collapsible = "offcanvas",
248
+ className,
249
+ children,
250
+ ...props
251
+ }) {
252
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
253
+ if (collapsible === "none") {
254
+ return /* @__PURE__ */ jsx8(
255
+ "div",
256
+ {
257
+ "data-slot": "sidebar",
258
+ className: cn(
259
+ "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
260
+ className
261
+ ),
262
+ ...props,
263
+ children
264
+ }
265
+ );
266
+ }
267
+ if (isMobile) {
268
+ return /* @__PURE__ */ jsx8(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxs4(
269
+ SheetContent,
270
+ {
271
+ "data-sidebar": "sidebar",
272
+ "data-slot": "sidebar",
273
+ "data-mobile": "true",
274
+ className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",
275
+ style: {
276
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE
277
+ },
278
+ side,
279
+ children: [
280
+ /* @__PURE__ */ jsxs4(SheetHeader, { className: "sr-only", children: [
281
+ /* @__PURE__ */ jsx8(SheetTitle, { children: "Sidebar" }),
282
+ /* @__PURE__ */ jsx8(SheetDescription, { children: "Displays the mobile sidebar." })
283
+ ] }),
284
+ /* @__PURE__ */ jsx8("div", { className: "flex h-full w-full flex-col", children })
285
+ ]
286
+ }
287
+ ) });
288
+ }
289
+ return /* @__PURE__ */ jsxs4(
290
+ "div",
291
+ {
292
+ className: "group peer text-sidebar-foreground hidden md:block",
293
+ "data-state": state,
294
+ "data-collapsible": state === "collapsed" ? collapsible : "",
295
+ "data-variant": variant,
296
+ "data-side": side,
297
+ "data-slot": "sidebar",
298
+ children: [
299
+ /* @__PURE__ */ jsx8(
300
+ "div",
301
+ {
302
+ "data-slot": "sidebar-gap",
303
+ className: cn(
304
+ "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
305
+ "group-data-[collapsible=offcanvas]:w-0",
306
+ "group-data-[side=right]:rotate-180",
307
+ variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
308
+ )
309
+ }
310
+ ),
311
+ /* @__PURE__ */ jsx8(
312
+ "div",
313
+ {
314
+ "data-slot": "sidebar-container",
315
+ className: cn(
316
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
317
+ side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
318
+ // Adjust the padding for floating and inset variants.
319
+ variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
320
+ className
321
+ ),
322
+ ...props,
323
+ children: /* @__PURE__ */ jsx8(
324
+ "div",
325
+ {
326
+ "data-sidebar": "sidebar",
327
+ "data-slot": "sidebar-inner",
328
+ 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",
329
+ children
330
+ }
331
+ )
332
+ }
333
+ )
334
+ ]
335
+ }
336
+ );
337
+ }
338
+ function SidebarHeader({ className, ...props }) {
339
+ return /* @__PURE__ */ jsx8(
340
+ "div",
341
+ {
342
+ "data-slot": "sidebar-header",
343
+ "data-sidebar": "header",
344
+ className: cn("flex flex-col gap-2 p-2", className),
345
+ ...props
346
+ }
347
+ );
348
+ }
349
+ function SidebarFooter({ className, ...props }) {
350
+ return /* @__PURE__ */ jsx8(
351
+ "div",
352
+ {
353
+ "data-slot": "sidebar-footer",
354
+ "data-sidebar": "footer",
355
+ className: cn("flex flex-col gap-2 p-2", className),
356
+ ...props
357
+ }
358
+ );
359
+ }
360
+ function SidebarContent({ className, ...props }) {
361
+ return /* @__PURE__ */ jsx8(
362
+ "div",
363
+ {
364
+ "data-slot": "sidebar-content",
365
+ "data-sidebar": "content",
366
+ className: cn(
367
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
368
+ className
369
+ ),
370
+ ...props
371
+ }
372
+ );
373
+ }
374
+ function SidebarGroup({ className, ...props }) {
375
+ return /* @__PURE__ */ jsx8(
376
+ "div",
377
+ {
378
+ "data-slot": "sidebar-group",
379
+ "data-sidebar": "group",
380
+ className: cn("relative flex w-full min-w-0 flex-col p-2", className),
381
+ ...props
382
+ }
383
+ );
384
+ }
385
+ function SidebarGroupLabel({
386
+ className,
387
+ asChild = false,
388
+ ...props
389
+ }) {
390
+ const Comp = asChild ? Slot2 : "div";
391
+ return /* @__PURE__ */ jsx8(
392
+ Comp,
393
+ {
394
+ "data-slot": "sidebar-group-label",
395
+ "data-sidebar": "group-label",
396
+ className: cn(
397
+ "text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
398
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
399
+ className
400
+ ),
401
+ ...props
402
+ }
403
+ );
404
+ }
405
+ function SidebarGroupContent({
406
+ className,
407
+ ...props
408
+ }) {
409
+ return /* @__PURE__ */ jsx8(
410
+ "div",
411
+ {
412
+ "data-slot": "sidebar-group-content",
413
+ "data-sidebar": "group-content",
414
+ className: cn("w-full text-sm", className),
415
+ ...props
416
+ }
417
+ );
418
+ }
419
+ var sidebarMenuButtonVariants = cva2(
420
+ 'peer/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-active focus-visible:ring-2 active:bg-sidebar-active 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]:relative data-[active=true]:bg-sidebar-active data-[active=true]:pl-3 data-[active=true]:font-medium data-[active=true]:text-sidebar-primary data-[active=true]:before:absolute data-[active=true]:before:left-1 data-[active=true]:before:top-[6px] data-[active=true]:before:bottom-[6px] data-[active=true]:before:w-[3px] data-[active=true]:before:rounded-full data-[active=true]:before:bg-primary data-[active=true]:before:content-[""] data-[state=open]:hover:bg-sidebar-active group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 min-w-0',
421
+ {
422
+ variants: {
423
+ variant: {
424
+ default: "hover:bg-sidebar-active",
425
+ outline: "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))]"
426
+ },
427
+ size: {
428
+ default: "h-8 text-sm",
429
+ sm: "h-7 text-xs",
430
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
431
+ }
432
+ },
433
+ defaultVariants: {
434
+ variant: "default",
435
+ size: "default"
436
+ }
437
+ }
438
+ );
439
+
440
+ // src/components/app-sidebar.tsx
441
+ import { IconChevronDown } from "@tabler/icons-react";
442
+ import { useEffect as useEffect3, useRef, useState as useState3 } from "react";
443
+ import { useToggle } from "react-use";
444
+ import { Fragment, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
445
+ function isLinkActive(pathname, href, pathMatch = "prefix") {
446
+ if (!pathname) {
447
+ return false;
448
+ }
449
+ if (!href) {
450
+ return false;
451
+ }
452
+ if (pathMatch === "exact") {
453
+ return pathname === href;
454
+ }
455
+ if (pathname === href) {
456
+ return true;
457
+ }
458
+ return pathname.startsWith(`${href}/`);
459
+ }
460
+ function hasActiveDescendant(item, pathname) {
461
+ if (!pathname) {
462
+ return false;
463
+ }
464
+ if (isLinkActive(pathname, item.href, item.pathMatch ?? "prefix")) {
465
+ return true;
466
+ }
467
+ return item.children?.some((c) => hasActiveDescendant(c, pathname)) ?? false;
468
+ }
469
+ function hasPermission(roles, permission) {
470
+ if (!permission?.length) {
471
+ return true;
472
+ }
473
+ if (!roles?.length) {
474
+ return true;
475
+ }
476
+ return permission.some((p) => roles.includes(p));
477
+ }
478
+ var TRUNCATION_TOOLTIP_MIN_LENGTH = 24;
479
+ function TruncationTooltip({
480
+ text,
481
+ children
482
+ }) {
483
+ const ref = useRef(null);
484
+ const [truncated, setTruncated] = useState3(false);
485
+ useEffect3(() => {
486
+ const el = ref.current;
487
+ if (!el) {
488
+ return;
489
+ }
490
+ const check = () => setTruncated(el.scrollWidth > el.clientWidth);
491
+ check();
492
+ const ro = new ResizeObserver(check);
493
+ ro.observe(el);
494
+ return () => ro.disconnect();
495
+ }, [text]);
496
+ const showTooltip = truncated || text.length >= TRUNCATION_TOOLTIP_MIN_LENGTH;
497
+ const inner = /* @__PURE__ */ jsx9("span", { ref, className: "min-w-0 truncate block", children });
498
+ if (!showTooltip) {
499
+ return inner;
500
+ }
501
+ return /* @__PURE__ */ jsxs5(Tooltip, { children: [
502
+ /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: inner }),
503
+ /* @__PURE__ */ jsx9(TooltipContent, { side: "right", sideOffset: 8, children: text })
504
+ ] });
505
+ }
506
+ function MenuLabel({ icon: Icon, label }) {
507
+ return /* @__PURE__ */ jsxs5("div", { className: "text-sidebar-foreground flex min-h-0 min-w-0 flex-1 cursor-pointer items-center gap-2 text-sm", children: [
508
+ Icon ? /* @__PURE__ */ jsx9(Icon, { className: "size-4 shrink-0" }) : null,
509
+ /* @__PURE__ */ jsx9(TruncationTooltip, { text: label, children: label })
510
+ ] });
511
+ }
512
+ function RowContent({
513
+ item,
514
+ hasChildren,
515
+ showChildren
516
+ }) {
517
+ return /* @__PURE__ */ jsxs5(Fragment, { children: [
518
+ /* @__PURE__ */ jsx9(MenuLabel, { icon: item.icon, label: item.title }),
519
+ hasChildren && /* @__PURE__ */ jsx9(
520
+ IconChevronDown,
521
+ {
522
+ className: cn(
523
+ "ml-auto size-4 shrink-0 cursor-pointer transition-transform",
524
+ showChildren && "rotate-180"
525
+ ),
526
+ "aria-hidden": true
527
+ }
528
+ )
529
+ ] });
530
+ }
531
+ function NavItemRow({
532
+ item,
533
+ level,
534
+ pathname,
535
+ roles,
536
+ onNavClick
537
+ }) {
538
+ const [open, toggle] = useToggle(hasActiveDescendant(item, pathname));
539
+ const hasChildren = (item.children?.length ?? 0) > 0;
540
+ const showChildren = (open || hasActiveDescendant(item, pathname)) && hasChildren;
541
+ const pathMatch = item.pathMatch ?? "prefix";
542
+ const isActive = isLinkActive(pathname, item.href, pathMatch);
543
+ const lineLeft = 28 + 20 * level;
544
+ if (!hasPermission(roles, item.permission)) {
545
+ return null;
546
+ }
547
+ const paddingLeft = 20 + 20 * level;
548
+ const rowWrapperClass = cn(
549
+ "text-sidebar-foreground relative flex h-8 w-full min-w-0 items-center rounded-md pr-2 text-left text-sm transition duration-300 ease-in-out",
550
+ "hover:bg-sidebar-active",
551
+ isActive && "bg-sidebar-active text-sidebar-primary"
552
+ );
553
+ const rowContent = /* @__PURE__ */ jsxs5(Fragment, { children: [
554
+ isActive && /* @__PURE__ */ jsx9(
555
+ "div",
556
+ {
557
+ className: "absolute left-1 top-1.5 bottom-1.5 z-10 w-[3px] rounded-full bg-primary",
558
+ "aria-hidden": true
559
+ }
560
+ ),
561
+ /* @__PURE__ */ jsx9(
562
+ RowContent,
563
+ {
564
+ item,
565
+ hasChildren,
566
+ showChildren
567
+ }
568
+ )
569
+ ] });
570
+ return /* @__PURE__ */ jsxs5("li", { className: "relative mt-1", children: [
571
+ item.href ? /* @__PURE__ */ jsx9(
572
+ Link,
573
+ {
574
+ href: item.href,
575
+ onClick: hasChildren ? toggle : onNavClick,
576
+ className: rowWrapperClass,
577
+ style: { paddingLeft },
578
+ "aria-current": isActive ? "page" : void 0,
579
+ children: rowContent
580
+ }
581
+ ) : /* @__PURE__ */ jsx9(
582
+ "button",
583
+ {
584
+ type: "button",
585
+ onClick: toggle,
586
+ className: rowWrapperClass,
587
+ style: { paddingLeft },
588
+ "aria-expanded": showChildren,
589
+ "aria-label": item.title,
590
+ children: rowContent
591
+ }
592
+ ),
593
+ showChildren && /* @__PURE__ */ jsxs5("ul", { className: "relative mt-1", children: [
594
+ /* @__PURE__ */ jsx9(
595
+ "div",
596
+ {
597
+ className: "absolute top-0 bottom-0 z-10 w-px bg-sidebar-border",
598
+ style: { left: lineLeft },
599
+ "aria-hidden": true
600
+ }
601
+ ),
602
+ (item.children ?? []).map((child) => /* @__PURE__ */ jsx9(
603
+ NavItemRow,
604
+ {
605
+ item: child,
606
+ level: level + 1,
607
+ pathname,
608
+ roles,
609
+ onNavClick
610
+ },
611
+ child.href ?? child.title
612
+ ))
613
+ ] })
614
+ ] });
615
+ }
616
+ function AppSidebar({
617
+ logo,
618
+ navItems,
619
+ footer,
620
+ pathname,
621
+ roles
622
+ }) {
623
+ const { isMobile, setOpenMobile } = useSidebar();
624
+ const closeSidebar = () => {
625
+ if (isMobile) {
626
+ setOpenMobile(false);
627
+ }
628
+ };
629
+ const groupedItems = navItems.reduce(
630
+ (acc, item) => {
631
+ const group = item.group ?? "default";
632
+ if (!acc[group]) {
633
+ acc[group] = [];
634
+ }
635
+ acc[group].push(item);
636
+ return acc;
637
+ },
638
+ {}
639
+ );
640
+ return /* @__PURE__ */ jsxs5(Sidebar, { children: [
641
+ /* @__PURE__ */ jsx9(SidebarHeader, { children: logo }),
642
+ /* @__PURE__ */ jsx9(SidebarContent, { children: /* @__PURE__ */ jsx9(
643
+ "nav",
644
+ {
645
+ "aria-label": "Main navigation",
646
+ className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",
647
+ children: Object.entries(groupedItems).map(([groupName, items]) => /* @__PURE__ */ jsxs5(SidebarGroup, { className: "py-0", children: [
648
+ groupName !== "default" && /* @__PURE__ */ jsx9(SidebarGroupLabel, { className: "uppercase tracking-wide", children: groupName }),
649
+ /* @__PURE__ */ jsx9(SidebarGroupContent, { children: /* @__PURE__ */ jsx9("ul", { className: "flex w-full min-w-0 list-none flex-col gap-0 p-0", children: items.map((item) => /* @__PURE__ */ jsx9(
650
+ NavItemRow,
651
+ {
652
+ item,
653
+ level: 0,
654
+ pathname,
655
+ roles,
656
+ onNavClick: closeSidebar
657
+ },
658
+ item.href ?? item.title
659
+ )) }) })
660
+ ] }, groupName))
661
+ }
662
+ ) }),
663
+ footer && /* @__PURE__ */ jsx9(SidebarFooter, { children: footer })
664
+ ] });
665
+ }
666
+ export {
667
+ AppSidebar
668
+ };
669
+ //# sourceMappingURL=app-sidebar.js.map