@yenio-pld/blocks 1.1.0 → 1.2.0-rc.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.
package/dist/index.js CHANGED
@@ -1,16 +1,22 @@
1
1
  "use client";
2
- import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
2
+ import { createContext, useContext, useState, useCallback, useEffect, cloneElement, useRef, useId, useLayoutEffect } from 'react';
3
3
  import { Skeleton } from './ui/skeleton.js';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
- import { Loader2, AlertTriangle, Inbox, Bell, Moon, Sun, Monitor, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Pause, Play, BarChart3 } from 'lucide-react';
5
+ import { Loader2, AlertTriangle, Inbox, Languages, Moon, Sun, Monitor, ChevronsUpDown, LogOut, Bell, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Pause, Play, BarChart3 } from 'lucide-react';
6
6
  import { clsx } from 'clsx';
7
7
  import { twMerge } from 'tailwind-merge';
8
+ import { Avatar, AvatarImage, AvatarFallback } from './ui/avatar.js';
9
+ import { Button } from './ui/button.js';
10
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, miniMenuContentDefaults, DropdownMenuItem, miniMenuContentClassName, DropdownMenuLabel, DropdownMenuSeparator } from './ui/dropdown-menu.js';
8
11
  import { Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent } from './ui/empty.js';
12
+ import { useTheme } from 'next-themes';
13
+ import { Separator } from './ui/separator.js';
14
+ import { SidebarProvider, Sidebar, SidebarHeader, SidebarContent, SidebarFooter, SidebarRail, SidebarInset, SidebarTrigger, useSidebar, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarGroup, SidebarGroupLabel, SidebarGroupContent } from './ui/sidebar.js';
15
+ import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from './ui/table.js';
16
+ import { TooltipProvider } from './ui/tooltip.js';
17
+ import { Card, CardHeader, CardContent } from './ui/card.js';
9
18
  import { cva } from 'class-variance-authority';
10
19
  import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from './ui/alert-dialog.js';
11
- import { Button } from './ui/button.js';
12
- import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, miniMenuContentClassName, miniMenuContentDefaults, DropdownMenuItem } from './ui/dropdown-menu.js';
13
- import { useTheme } from 'next-themes';
14
20
  import { Slider } from './ui/slider.js';
15
21
  import { Toggle } from './ui/toggle.js';
16
22
  import { DialogClose, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './ui/dialog.js';
@@ -23,11 +29,19 @@ function useLanguageContext() {
23
29
  }
24
30
  function PageTitle({
25
31
  title,
26
- description
32
+ description,
33
+ eyebrow,
34
+ back,
35
+ actions
27
36
  }) {
28
- return /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-1", children: [
29
- /* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }),
30
- description ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }) : null
37
+ return /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4", children: [
38
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
39
+ back ? /* @__PURE__ */ jsx("div", { className: "text-sm", children: back }) : null,
40
+ eyebrow ? /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground", children: eyebrow }) : null,
41
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }),
42
+ description ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }) : null
43
+ ] }),
44
+ actions ? /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 *:flex-1 sm:w-auto sm:shrink-0 sm:flex-nowrap sm:*:flex-none", children: actions }) : null
31
45
  ] });
32
46
  }
33
47
  function Field({
@@ -54,6 +68,87 @@ function TableSkeleton({
54
68
  }) {
55
69
  return /* @__PURE__ */ jsx("div", { "aria-busy": "true", className: "flex flex-col gap-2", children: Array.from({ length: rows }, (_, row) => /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: Array.from({ length: columns }, (_2, column) => /* @__PURE__ */ jsx(Skeleton, { className: "h-8 flex-1" }, column)) }, row)) });
56
70
  }
71
+
72
+ // src/lib/avatar.ts
73
+ var EMPTY_COLORS = {
74
+ backgroundColor: "#9ca3af",
75
+ color: "#111111"
76
+ };
77
+ var AVATAR_PALETTE = [
78
+ "#4f6d8c",
79
+ // slate blue
80
+ "#3d7a6a",
81
+ // teal
82
+ "#6b5b8a",
83
+ // muted purple
84
+ "#8a5a4a",
85
+ // warm brown
86
+ "#4a7a8a",
87
+ // steel cyan
88
+ "#7a6b4a",
89
+ // olive
90
+ "#5a6b8a",
91
+ // periwinkle
92
+ "#8a4a5a",
93
+ // rose
94
+ "#4a8a6b",
95
+ // green
96
+ "#6b4a7a",
97
+ // plum
98
+ "#8a6b4a",
99
+ // amber brown
100
+ "#4a5a8a",
101
+ // indigo
102
+ "#7a4a6b",
103
+ // mauve
104
+ "#5a8a4a",
105
+ // leaf
106
+ "#8a5a7a",
107
+ // dusty pink
108
+ "#3d6b7a"
109
+ // deep teal
110
+ ];
111
+ function hashString(input) {
112
+ let hash = 2166136261;
113
+ for (let i = 0; i < input.length; i++) {
114
+ hash ^= input.charCodeAt(i);
115
+ hash = Math.imul(hash, 16777619);
116
+ }
117
+ return hash >>> 0;
118
+ }
119
+ function srgbToLinear(channel) {
120
+ const c = channel / 255;
121
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
122
+ }
123
+ function relativeLuminance(hex) {
124
+ const normalized = hex.replace("#", "");
125
+ const r = Number.parseInt(normalized.slice(0, 2), 16);
126
+ const g = Number.parseInt(normalized.slice(2, 4), 16);
127
+ const b = Number.parseInt(normalized.slice(4, 6), 16);
128
+ return 0.2126 * srgbToLinear(r) + 0.7152 * srgbToLinear(g) + 0.0722 * srgbToLinear(b);
129
+ }
130
+ function contrastingTextColor(backgroundHex) {
131
+ return relativeLuminance(backgroundHex) > 0.179 ? "#111111" : "#ffffff";
132
+ }
133
+ function getInitials(name, max = 2) {
134
+ const parts = name.trim().split(/\s+/).filter(Boolean);
135
+ if (parts.length === 0) return "?";
136
+ return parts.slice(0, Math.max(1, max)).map((part) => part.charAt(0)).join("").toUpperCase();
137
+ }
138
+ function getAvatarColors(name) {
139
+ const normalized = name.trim().toLowerCase();
140
+ if (!normalized) {
141
+ return { ...EMPTY_COLORS };
142
+ }
143
+ const backgroundColor = AVATAR_PALETTE[hashString(normalized) % AVATAR_PALETTE.length];
144
+ return {
145
+ backgroundColor,
146
+ color: contrastingTextColor(backgroundColor)
147
+ };
148
+ }
149
+ function avatarFallbackStyle(name) {
150
+ return getAvatarColors(name);
151
+ }
57
152
  function cn(...inputs) {
58
153
  return twMerge(clsx(inputs));
59
154
  }
@@ -144,11 +239,837 @@ function EmptyState({
144
239
  ),
145
240
  description ? /* @__PURE__ */ jsx(EmptyDescription, { className: "mt-0", children: description }) : null
146
241
  ] }),
147
- action ? /* @__PURE__ */ jsx(EmptyContent, { className: "gap-0", children: action }) : null
242
+ action ? /* @__PURE__ */ jsx(EmptyContent, { className: "gap-0", children: action }) : null
243
+ ]
244
+ }
245
+ );
246
+ }
247
+ var defaultLanguages = [
248
+ { key: "es-MX", label: "ES", nativeName: "Espa\xF1ol (M\xE9xico)" },
249
+ { key: "en", label: "EN", nativeName: "English" }
250
+ ];
251
+ var sizeClasses = {
252
+ sm: { button: "size-8", icon: "size-4" },
253
+ md: { button: "size-8", icon: "size-4" },
254
+ lg: { button: "size-9", icon: "size-4" }
255
+ };
256
+ var shapeClasses = {
257
+ rounded: "rounded-md",
258
+ squared: "rounded-sm",
259
+ pill: "rounded-full"
260
+ };
261
+ var iconTriggerClassName = "border border-border bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground dark:border-border dark:bg-transparent dark:text-muted-foreground dark:hover:bg-accent/50";
262
+ function LanguageSwitcher({
263
+ languages: propLanguages,
264
+ currentLanguage: propCurrentLanguage,
265
+ onLanguageChange: propOnLanguageChange,
266
+ labels = {},
267
+ className,
268
+ size = "sm",
269
+ shape = "rounded",
270
+ align = "end",
271
+ side = "bottom"
272
+ }) {
273
+ const context = useLanguageContext();
274
+ const contextLanguages = context?.languages?.map((lang) => ({
275
+ key: lang.code,
276
+ label: lang.code.toUpperCase(),
277
+ nativeName: lang.name
278
+ }));
279
+ const languages = propLanguages ?? contextLanguages ?? defaultLanguages;
280
+ const currentLanguage = propCurrentLanguage ?? context?.language ?? "en";
281
+ const onLanguageChange = propOnLanguageChange ?? context?.setLanguage;
282
+ const sizes = sizeClasses[size];
283
+ const shapeClass = shapeClasses[shape];
284
+ const accessibleName = labels.language ?? "Language";
285
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
286
+ /* @__PURE__ */ jsx(
287
+ DropdownMenuTrigger,
288
+ {
289
+ render: /* @__PURE__ */ jsx(
290
+ Button,
291
+ {
292
+ variant: "outline",
293
+ size: "icon",
294
+ "aria-label": accessibleName,
295
+ className: cn(
296
+ sizes.button,
297
+ shapeClass,
298
+ iconTriggerClassName,
299
+ className
300
+ )
301
+ }
302
+ ),
303
+ children: /* @__PURE__ */ jsx(Languages, { className: sizes.icon })
304
+ }
305
+ ),
306
+ /* @__PURE__ */ jsx(
307
+ DropdownMenuContent,
308
+ {
309
+ side,
310
+ align,
311
+ sideOffset: miniMenuContentDefaults.sideOffset,
312
+ collisionPadding: miniMenuContentDefaults.collisionPadding,
313
+ className: cn(miniMenuContentClassName, "min-w-0 w-auto"),
314
+ children: languages.map(({ key, nativeName }) => /* @__PURE__ */ jsx(
315
+ DropdownMenuItem,
316
+ {
317
+ onClick: () => onLanguageChange?.(key),
318
+ className: cn(
319
+ "justify-center text-xs font-semibold cursor-pointer px-3",
320
+ currentLanguage === key && "bg-accent text-accent-foreground"
321
+ ),
322
+ children: nativeName
323
+ },
324
+ key
325
+ ))
326
+ }
327
+ )
328
+ ] });
329
+ }
330
+ var defaultLabels = {
331
+ theme: "Theme",
332
+ system: "System",
333
+ light: "Light",
334
+ dark: "Dark"
335
+ };
336
+ var sizeClasses2 = {
337
+ sm: { button: "size-8", icon: "size-4" },
338
+ md: { button: "size-8", icon: "size-4" },
339
+ lg: { button: "size-9", icon: "size-4" }
340
+ };
341
+ var shapeClasses2 = {
342
+ rounded: "rounded-md",
343
+ pill: "rounded-full"
344
+ };
345
+ var iconTriggerClassName2 = "border border-border bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground dark:border-border dark:bg-transparent dark:text-muted-foreground dark:hover:bg-accent/50";
346
+ var themeIcons = {
347
+ system: Monitor,
348
+ light: Sun,
349
+ dark: Moon
350
+ };
351
+ var themes = [
352
+ { key: "system", icon: themeIcons.system },
353
+ { key: "light", icon: themeIcons.light },
354
+ { key: "dark", icon: themeIcons.dark }
355
+ ];
356
+ function storedTheme(value) {
357
+ if (value === "system" || value === "light" || value === "dark") return value;
358
+ return void 0;
359
+ }
360
+ function ThemeSwitcher({
361
+ className,
362
+ size = "sm",
363
+ shape = "rounded",
364
+ align = "end",
365
+ side = "bottom",
366
+ labels: userLabels
367
+ }) {
368
+ const { theme, setTheme } = useTheme();
369
+ const [mounted, setMounted] = useState(false);
370
+ const sizes = sizeClasses2[size];
371
+ const shapeClass = shapeClasses2[shape];
372
+ const labels = { ...defaultLabels, ...userLabels };
373
+ const handleThemeClick = useCallback(
374
+ (themeKey) => {
375
+ setTheme(themeKey);
376
+ },
377
+ [setTheme]
378
+ );
379
+ useEffect(() => {
380
+ setMounted(true);
381
+ }, []);
382
+ if (!mounted) {
383
+ return /* @__PURE__ */ jsx(
384
+ "div",
385
+ {
386
+ "aria-hidden": true,
387
+ className: cn(
388
+ sizes.button,
389
+ shapeClass,
390
+ iconTriggerClassName2,
391
+ className
392
+ )
393
+ }
394
+ );
395
+ }
396
+ const currentTheme = storedTheme(theme);
397
+ const TriggerIcon = currentTheme ? themeIcons[currentTheme] : Monitor;
398
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
399
+ /* @__PURE__ */ jsx(
400
+ DropdownMenuTrigger,
401
+ {
402
+ render: /* @__PURE__ */ jsx(
403
+ Button,
404
+ {
405
+ "data-testid": "theme-switcher",
406
+ variant: "outline",
407
+ size: "icon",
408
+ "aria-label": labels.theme,
409
+ className: cn(
410
+ sizes.button,
411
+ shapeClass,
412
+ iconTriggerClassName2,
413
+ className
414
+ )
415
+ }
416
+ ),
417
+ children: /* @__PURE__ */ jsx(TriggerIcon, { className: sizes.icon })
418
+ }
419
+ ),
420
+ /* @__PURE__ */ jsx(
421
+ DropdownMenuContent,
422
+ {
423
+ side,
424
+ align,
425
+ sideOffset: miniMenuContentDefaults.sideOffset,
426
+ collisionPadding: miniMenuContentDefaults.collisionPadding,
427
+ className: miniMenuContentClassName,
428
+ children: themes.map(({ key, icon: Icon }) => /* @__PURE__ */ jsxs(
429
+ DropdownMenuItem,
430
+ {
431
+ onClick: () => handleThemeClick(key),
432
+ className: cn(
433
+ "gap-2 cursor-pointer",
434
+ currentTheme === key && "bg-accent text-accent-foreground [&_svg]:text-accent-foreground"
435
+ ),
436
+ children: [
437
+ /* @__PURE__ */ jsx(Icon, { className: "size-4" }),
438
+ /* @__PURE__ */ jsx("span", { children: labels[key] })
439
+ ]
440
+ },
441
+ key
442
+ ))
443
+ }
444
+ )
445
+ ] });
446
+ }
447
+ var DATA_TABLE_ROW_CLASS = "h-14";
448
+ function renderShellLink({
449
+ href,
450
+ className,
451
+ children,
452
+ ...rest
453
+ }) {
454
+ return /* @__PURE__ */ jsx("a", { href, className, ...rest, children });
455
+ }
456
+ function DismissMobileSidebar({ pathname }) {
457
+ const { setOpenMobile } = useSidebar();
458
+ const previous = useRef(pathname);
459
+ useEffect(() => {
460
+ if (previous.current === pathname) return;
461
+ previous.current = pathname;
462
+ setOpenMobile(false);
463
+ }, [pathname, setOpenMobile]);
464
+ return null;
465
+ }
466
+ function AppNav({
467
+ nav,
468
+ navLabel,
469
+ renderLink
470
+ }) {
471
+ const { setOpenMobile } = useSidebar();
472
+ return /* @__PURE__ */ jsx("nav", { "aria-label": navLabel, children: nav.map((group) => /* @__PURE__ */ jsxs(SidebarGroup, { children: [
473
+ /* @__PURE__ */ jsx(SidebarGroupLabel, { children: group.label }),
474
+ /* @__PURE__ */ jsx(SidebarGroupContent, { children: /* @__PURE__ */ jsx(SidebarMenu, { children: group.items.map((item) => {
475
+ const Icon = item.icon;
476
+ return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(
477
+ SidebarMenuButton,
478
+ {
479
+ isActive: item.active === true,
480
+ tooltip: item.label,
481
+ render: renderLink({
482
+ href: item.href,
483
+ onClick: () => setOpenMobile(false),
484
+ "aria-current": item.active ? "page" : void 0,
485
+ // Children live on the link. The button's render element
486
+ // wins the merge, so a childless anchor would wipe the label.
487
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
488
+ /* @__PURE__ */ jsx(Icon, { "aria-hidden": "true" }),
489
+ /* @__PURE__ */ jsx("span", { children: item.label })
490
+ ] })
491
+ })
492
+ }
493
+ ) }, `${group.label}:${item.href}`);
494
+ }) }) })
495
+ ] }, group.label)) });
496
+ }
497
+ function AppShell({
498
+ brand,
499
+ nav,
500
+ navLabel = "Main",
501
+ sidebarFooter,
502
+ headerEnd,
503
+ defaultOpen = true,
504
+ pathname,
505
+ renderLink = renderShellLink,
506
+ children,
507
+ className
508
+ }) {
509
+ return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(
510
+ SidebarProvider,
511
+ {
512
+ defaultOpen,
513
+ className: cn("h-svh overflow-hidden", className),
514
+ children: [
515
+ /* @__PURE__ */ jsx(DismissMobileSidebar, { pathname }),
516
+ /* @__PURE__ */ jsxs(Sidebar, { collapsible: "icon", children: [
517
+ /* @__PURE__ */ jsx(SidebarHeader, { className: "flex h-14 shrink-0 flex-row items-center border-b border-sidebar-border p-2", children: brand }),
518
+ /* @__PURE__ */ jsx(SidebarContent, { children: /* @__PURE__ */ jsx(AppNav, { nav, navLabel, renderLink }) }),
519
+ /* @__PURE__ */ jsx(SidebarFooter, { children: sidebarFooter }),
520
+ /* @__PURE__ */ jsx(SidebarRail, {})
521
+ ] }),
522
+ /* @__PURE__ */ jsxs(SidebarInset, { className: "h-svh min-h-0 overflow-hidden", children: [
523
+ /* @__PURE__ */ jsxs("header", { className: "sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background/95 px-4 backdrop-blur", children: [
524
+ /* @__PURE__ */ jsx(SidebarTrigger, { className: "-ml-1" }),
525
+ /* @__PURE__ */ jsx(
526
+ Separator,
527
+ {
528
+ orientation: "vertical",
529
+ className: "mr-1 data-[orientation=vertical]:h-4"
530
+ }
531
+ ),
532
+ /* @__PURE__ */ jsx("div", { className: "ml-auto flex min-w-0 items-center gap-2", children: headerEnd })
533
+ ] }),
534
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto", children })
535
+ ] })
536
+ ]
537
+ }
538
+ ) });
539
+ }
540
+ function PageContainer({
541
+ children,
542
+ className
543
+ }) {
544
+ return /* @__PURE__ */ jsx(
545
+ "div",
546
+ {
547
+ className: cn(
548
+ "mx-auto flex w-full max-w-7xl flex-col gap-6 p-4 md:p-6",
549
+ className
550
+ ),
551
+ children
552
+ }
553
+ );
554
+ }
555
+ function NavTabs({
556
+ tabs,
557
+ label = "Sections",
558
+ renderLink = renderShellLink,
559
+ className
560
+ }) {
561
+ return /* @__PURE__ */ jsx(
562
+ "nav",
563
+ {
564
+ "aria-label": label,
565
+ className: cn("flex items-stretch gap-1 border-b", className),
566
+ children: tabs.map((tab) => {
567
+ const active = tab.active === true;
568
+ const link = renderLink({
569
+ href: tab.href,
570
+ className: cn(
571
+ "-mb-px border-b-2 px-3 py-2 text-sm font-medium whitespace-nowrap transition-colors",
572
+ active ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground"
573
+ ),
574
+ "aria-current": active ? "page" : void 0,
575
+ children: tab.label
576
+ });
577
+ return cloneElement(link, { key: tab.href });
578
+ })
579
+ }
580
+ );
581
+ }
582
+ var accountMenuDefaults = {
583
+ menu: "Account menu",
584
+ signOut: "Sign out",
585
+ theme: "Theme",
586
+ language: "Language",
587
+ system: "System",
588
+ light: "Light",
589
+ dark: "Dark"
590
+ };
591
+ function AccountMenu({
592
+ name,
593
+ email,
594
+ organization,
595
+ imageSrc,
596
+ imageAlt = "",
597
+ labels: userLabels,
598
+ languages,
599
+ currentLanguage,
600
+ onLanguageChange,
601
+ onSignOut
602
+ }) {
603
+ const labels = { ...accountMenuDefaults, ...userLabels };
604
+ const { isMobile } = useSidebar();
605
+ const side = isMobile ? "bottom" : "right";
606
+ const themeLabels = {
607
+ theme: labels.theme,
608
+ system: labels.system,
609
+ light: labels.light,
610
+ dark: labels.dark
611
+ };
612
+ const languageLabels = { language: labels.language };
613
+ return /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
614
+ /* @__PURE__ */ jsxs(
615
+ DropdownMenuTrigger,
616
+ {
617
+ render: /* @__PURE__ */ jsx(
618
+ SidebarMenuButton,
619
+ {
620
+ size: "lg",
621
+ "aria-label": labels.menu,
622
+ className: "data-open:bg-sidebar-accent data-open:text-sidebar-accent-foreground"
623
+ }
624
+ ),
625
+ children: [
626
+ /* @__PURE__ */ jsxs(Avatar, { className: "size-8", children: [
627
+ imageSrc ? /* @__PURE__ */ jsx(
628
+ AvatarImage,
629
+ {
630
+ src: imageSrc,
631
+ alt: imageAlt,
632
+ width: 32,
633
+ height: 32,
634
+ keepMounted: true
635
+ }
636
+ ) : null,
637
+ /* @__PURE__ */ jsx(AvatarFallback, { style: avatarFallbackStyle(name), children: getInitials(name) })
638
+ ] }),
639
+ /* @__PURE__ */ jsxs("span", { className: "grid min-w-0 flex-1 text-left text-sm leading-tight group-data-[collapsible=icon]:hidden", children: [
640
+ /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: name }),
641
+ /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: email }),
642
+ organization ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: organization }) : null
643
+ ] }),
644
+ /* @__PURE__ */ jsx(ChevronsUpDown, { className: "ml-auto size-4 group-data-[collapsible=icon]:hidden" })
645
+ ]
646
+ }
647
+ ),
648
+ /* @__PURE__ */ jsxs(
649
+ DropdownMenuContent,
650
+ {
651
+ side,
652
+ align: "end",
653
+ className: "w-56 min-w-56",
654
+ children: [
655
+ /* @__PURE__ */ jsxs(DropdownMenuLabel, { className: "font-normal", children: [
656
+ /* @__PURE__ */ jsx("span", { className: "block truncate font-medium", children: name }),
657
+ /* @__PURE__ */ jsx("span", { className: "block truncate text-xs text-muted-foreground", children: email }),
658
+ organization ? /* @__PURE__ */ jsx("span", { className: "block truncate text-xs text-muted-foreground", children: organization }) : null
659
+ ] }),
660
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
661
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-1 px-1.5 py-1", children: [
662
+ /* @__PURE__ */ jsx(ThemeSwitcher, { labels: themeLabels, side, align: "end" }),
663
+ /* @__PURE__ */ jsx(
664
+ LanguageSwitcher,
665
+ {
666
+ labels: languageLabels,
667
+ languages,
668
+ currentLanguage,
669
+ onLanguageChange,
670
+ side,
671
+ align: "end"
672
+ }
673
+ )
674
+ ] }),
675
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
676
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onSignOut, children: [
677
+ /* @__PURE__ */ jsx(LogOut, {}),
678
+ labels.signOut
679
+ ] })
680
+ ]
681
+ }
682
+ )
683
+ ] }) }) });
684
+ }
685
+ function dataTableMode(loading, count) {
686
+ if (loading) return "loading";
687
+ if (count === 0) return "empty";
688
+ return "rows";
689
+ }
690
+ function DataTableBody({
691
+ mode,
692
+ columns,
693
+ rows,
694
+ rowKey,
695
+ emptyTitle,
696
+ emptyDescription,
697
+ skeletonRows
698
+ }) {
699
+ switch (mode) {
700
+ case "loading":
701
+ return Array.from({ length: skeletonRows }, (_, index) => /* @__PURE__ */ jsx(TableRow, { className: DATA_TABLE_ROW_CLASS, children: columns.map((column) => /* @__PURE__ */ jsx(
702
+ TableCell,
703
+ {
704
+ className: cn("h-14", column.className),
705
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full max-w-32" })
706
+ },
707
+ column.key
708
+ )) }, `skeleton-${index}`));
709
+ case "empty":
710
+ return /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: Math.max(columns.length, 1), className: "p-0", children: /* @__PURE__ */ jsx(
711
+ EmptyState,
712
+ {
713
+ variant: "compact",
714
+ title: emptyTitle,
715
+ description: emptyDescription
716
+ }
717
+ ) }) });
718
+ case "rows":
719
+ return rows.map((row) => /* @__PURE__ */ jsx(TableRow, { className: DATA_TABLE_ROW_CLASS, children: columns.map((column) => /* @__PURE__ */ jsx(
720
+ TableCell,
721
+ {
722
+ className: cn("h-14", column.className),
723
+ children: /* @__PURE__ */ jsx("div", { className: "truncate", children: column.cell(row) })
724
+ },
725
+ column.key
726
+ )) }, rowKey(row)));
727
+ default: {
728
+ const exhaustive = mode;
729
+ throw new Error(`Unhandled table body: ${String(exhaustive)}`);
730
+ }
731
+ }
732
+ }
733
+ function DataTable({
734
+ columns,
735
+ rows,
736
+ rowKey,
737
+ toolbar,
738
+ emptyTitle,
739
+ emptyDescription,
740
+ loading = false,
741
+ skeletonRows = 5,
742
+ loadMore,
743
+ label,
744
+ className
745
+ }) {
746
+ const mode = dataTableMode(loading, rows.length);
747
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-4", className), children: [
748
+ toolbar ? /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: toolbar }) : null,
749
+ /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-lg border", children: /* @__PURE__ */ jsxs(Table, { "aria-label": label, "aria-busy": loading || void 0, children: [
750
+ /* @__PURE__ */ jsx(TableHeader, { className: "bg-muted/50", children: /* @__PURE__ */ jsx(TableRow, { className: "bg-muted/50 hover:bg-muted/50", children: columns.map((column) => /* @__PURE__ */ jsx(TableHead, { className: column.className, children: column.header }, column.key)) }) }),
751
+ /* @__PURE__ */ jsx(TableBody, { children: /* @__PURE__ */ jsx(
752
+ DataTableBody,
753
+ {
754
+ mode,
755
+ columns,
756
+ rows,
757
+ rowKey,
758
+ emptyTitle,
759
+ emptyDescription,
760
+ skeletonRows
761
+ }
762
+ ) })
763
+ ] }) }),
764
+ loadMore ? /* @__PURE__ */ jsx("div", { className: "flex min-h-8 justify-center", children: /* @__PURE__ */ jsx(
765
+ Button,
766
+ {
767
+ type: "button",
768
+ variant: "outline",
769
+ className: "min-w-36",
770
+ disabled: loadMore.pending === true,
771
+ "aria-busy": loadMore.pending || void 0,
772
+ onClick: loadMore.onLoadMore,
773
+ children: loadMore.label
774
+ }
775
+ ) }) : null
776
+ ] });
777
+ }
778
+ var MIN_VISIBLE_MS = 200;
779
+ var SAFETY_MS = 1e4;
780
+ var ROUTE_LOADING_SELECTOR = "[data-route-loading]";
781
+ var NAV_PROGRESS_CSS = `
782
+ @keyframes nav-progress-indeterminate {
783
+ 0% { transform: translateX(-100%); }
784
+ 100% { transform: translateX(400%); }
785
+ }
786
+ .nav-progress-indeterminate {
787
+ width: 33%;
788
+ height: 100%;
789
+ animation: nav-progress-indeterminate 1.1s ease-in-out infinite;
790
+ }
791
+ @media (prefers-reduced-motion: reduce) {
792
+ .nav-progress-indeterminate {
793
+ animation: none;
794
+ width: 100%;
795
+ transform: none;
796
+ }
797
+ }
798
+ `;
799
+ var startListeners = /* @__PURE__ */ new Set();
800
+ var navigationSuppressed = false;
801
+ var suppressTimer = 0;
802
+ function normalizeSearch(search) {
803
+ const params = new URLSearchParams(search);
804
+ const entries = [...params.entries()].sort(([a], [b]) => a.localeCompare(b));
805
+ const sorted = new URLSearchParams();
806
+ for (const [key, value] of entries) {
807
+ sorted.append(key, value);
808
+ }
809
+ return sorted.toString();
810
+ }
811
+ function routeKey(pathname, search) {
812
+ return `${pathname}?${normalizeSearch(search)}`;
813
+ }
814
+ function routeKeyFromHref(href) {
815
+ try {
816
+ const url = new URL(href, window.location.origin);
817
+ return routeKey(url.pathname, url.search.replace(/^\?/, ""));
818
+ } catch {
819
+ return null;
820
+ }
821
+ }
822
+ function isShown(element) {
823
+ if (!(element instanceof HTMLElement)) return false;
824
+ if (element.hidden) return false;
825
+ const display = element.style.display || getComputedStyle(element).display;
826
+ if (display === "none") return false;
827
+ const visibility = element.style.visibility || getComputedStyle(element).visibility;
828
+ if (visibility === "hidden") return false;
829
+ if (display === "contents") {
830
+ return Array.from(element.children).some((child) => isShown(child));
831
+ }
832
+ return true;
833
+ }
834
+ function routeLoadingIsActive() {
835
+ for (const node of document.querySelectorAll(ROUTE_LOADING_SELECTOR)) {
836
+ if (isShown(node)) return true;
837
+ }
838
+ return false;
839
+ }
840
+ function suppressNavigationProgress() {
841
+ navigationSuppressed = true;
842
+ window.clearTimeout(suppressTimer);
843
+ suppressTimer = window.setTimeout(() => {
844
+ navigationSuppressed = false;
845
+ }, 0);
846
+ }
847
+ function signalNavigationStart(href) {
848
+ if (navigationSuppressed) return;
849
+ for (const listener of startListeners) {
850
+ listener(href);
851
+ }
852
+ }
853
+ function isInternalNavigationClick(event) {
854
+ if (event.button !== 0) return false;
855
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
856
+ return false;
857
+ }
858
+ const target = event.target;
859
+ if (!(target instanceof Element)) return false;
860
+ const anchor = target.closest("a");
861
+ if (!(anchor instanceof HTMLAnchorElement)) return false;
862
+ if (anchor.target && anchor.target !== "_self") return false;
863
+ if (anchor.hasAttribute("download")) return false;
864
+ const raw = anchor.getAttribute("href");
865
+ if (!raw || raw.startsWith("#") || raw.startsWith("mailto:") || raw.startsWith("tel:")) {
866
+ return false;
867
+ }
868
+ let url;
869
+ try {
870
+ url = new URL(anchor.href, window.location.href);
871
+ } catch {
872
+ return false;
873
+ }
874
+ if (url.origin !== window.location.origin) return false;
875
+ if (url.pathname === window.location.pathname && url.search === window.location.search) {
876
+ return false;
877
+ }
878
+ return true;
879
+ }
880
+ function NavigationProgress({
881
+ pathname,
882
+ search = "",
883
+ ariaLabel = "Loading",
884
+ forceVisible = false
885
+ }) {
886
+ const [visible, setVisible] = useState(forceVisible);
887
+ const [runId, setRunId] = useState(0);
888
+ const startedAt = useRef(0);
889
+ const startedRoute = useRef(null);
890
+ const committedRoute = useRef(null);
891
+ useEffect(() => {
892
+ committedRoute.current = routeKey(pathname, search);
893
+ }, [pathname, search]);
894
+ useEffect(() => {
895
+ if (forceVisible) return;
896
+ function begin(route) {
897
+ if (navigationSuppressed) return;
898
+ startedAt.current = Date.now();
899
+ startedRoute.current = route;
900
+ setRunId((id) => id + 1);
901
+ setVisible(true);
902
+ }
903
+ function onClick(event) {
904
+ if (!isInternalNavigationClick(event)) return;
905
+ begin(committedRoute.current ?? routeKey(pathname, search));
906
+ }
907
+ function onPopState() {
908
+ const landed = routeKey(
909
+ window.location.pathname,
910
+ window.location.search.replace(/^\?/, "")
911
+ );
912
+ if (landed === (committedRoute.current ?? "")) return;
913
+ begin(committedRoute.current ?? "");
914
+ }
915
+ function onStart(href) {
916
+ if (href) {
917
+ const target = routeKeyFromHref(href);
918
+ if (target !== null && target === committedRoute.current) return;
919
+ }
920
+ begin(committedRoute.current ?? routeKey(pathname, search));
921
+ }
922
+ startListeners.add(onStart);
923
+ document.addEventListener("click", onClick, true);
924
+ window.addEventListener("popstate", onPopState);
925
+ return () => {
926
+ startListeners.delete(onStart);
927
+ document.removeEventListener("click", onClick, true);
928
+ window.removeEventListener("popstate", onPopState);
929
+ };
930
+ }, [forceVisible, pathname, search]);
931
+ useEffect(() => {
932
+ if (forceVisible || !visible) return;
933
+ const safety = window.setTimeout(() => setVisible(false), SAFETY_MS);
934
+ return () => window.clearTimeout(safety);
935
+ }, [forceVisible, runId, visible]);
936
+ useEffect(() => {
937
+ if (forceVisible || !visible) return;
938
+ const started = startedRoute.current;
939
+ if (!started) return;
940
+ let hideTimer = 0;
941
+ let stopped = false;
942
+ let sawLoading = false;
943
+ function hide() {
944
+ if (stopped) return;
945
+ if (routeLoadingIsActive()) {
946
+ sawLoading = true;
947
+ return;
948
+ }
949
+ const routeChanged = routeKey(pathname, search) !== started;
950
+ if (!routeChanged && !sawLoading) return;
951
+ stopped = true;
952
+ const wait = Math.max(
953
+ 0,
954
+ MIN_VISIBLE_MS - (Date.now() - startedAt.current)
955
+ );
956
+ hideTimer = window.setTimeout(() => setVisible(false), wait);
957
+ }
958
+ hide();
959
+ const observer = new MutationObserver(hide);
960
+ observer.observe(document.body, {
961
+ childList: true,
962
+ subtree: true,
963
+ attributes: true,
964
+ attributeFilter: ["style", "hidden", "class"]
965
+ });
966
+ return () => {
967
+ stopped = true;
968
+ window.clearTimeout(hideTimer);
969
+ observer.disconnect();
970
+ };
971
+ }, [forceVisible, pathname, search, visible]);
972
+ if (!visible) return null;
973
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
974
+ /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: NAV_PROGRESS_CSS } }),
975
+ /* @__PURE__ */ jsx(
976
+ "div",
977
+ {
978
+ role: "progressbar",
979
+ "aria-label": ariaLabel,
980
+ className: "pointer-events-none fixed inset-x-0 top-0 z-[60] h-0.5 overflow-hidden bg-primary/20",
981
+ children: /* @__PURE__ */ jsx("div", { className: "nav-progress-indeterminate bg-primary" })
982
+ }
983
+ )
984
+ ] });
985
+ }
986
+ function RouteLoading({ children }) {
987
+ return /* @__PURE__ */ jsx("div", { "data-route-loading": "", className: "contents", children });
988
+ }
989
+ function PageTitleSkeleton({
990
+ label,
991
+ action = false
992
+ }) {
993
+ return /* @__PURE__ */ jsxs(
994
+ "div",
995
+ {
996
+ role: "status",
997
+ "aria-label": label,
998
+ className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",
999
+ children: [
1000
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1001
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-48" }),
1002
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-72 max-w-full" })
1003
+ ] }),
1004
+ action ? /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-full sm:w-36" }) : null
1005
+ ]
1006
+ }
1007
+ );
1008
+ }
1009
+ function DataTableSkeletonBody({ rows }) {
1010
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
1011
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-full max-w-sm" }),
1012
+ /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-lg border", children: [
1013
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-none" }),
1014
+ Array.from({ length: rows }, (_, index) => /* @__PURE__ */ jsx(
1015
+ Skeleton,
1016
+ {
1017
+ className: cn(DATA_TABLE_ROW_CLASS, "w-full rounded-none")
1018
+ },
1019
+ index
1020
+ ))
1021
+ ] })
1022
+ ] });
1023
+ }
1024
+ function DataTableSkeleton({
1025
+ label,
1026
+ rows = 5
1027
+ }) {
1028
+ return /* @__PURE__ */ jsx("div", { role: "status", "aria-label": label, children: /* @__PURE__ */ jsx(DataTableSkeletonBody, { rows }) });
1029
+ }
1030
+ function DetailPageSkeleton({ label }) {
1031
+ return /* @__PURE__ */ jsxs(
1032
+ "div",
1033
+ {
1034
+ role: "status",
1035
+ "aria-label": label,
1036
+ className: "grid gap-6 lg:grid-cols-[minmax(0,1fr)_320px]",
1037
+ children: [
1038
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-4", children: [
1039
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-64 max-w-full" }),
1040
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-80 max-w-full" }),
1041
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-40 w-full" })
1042
+ ] }),
1043
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-48 w-full lg:w-[320px]" })
148
1044
  ]
149
1045
  }
150
1046
  );
151
1047
  }
1048
+ function FormCardSkeleton({
1049
+ label,
1050
+ fields = 4
1051
+ }) {
1052
+ return /* @__PURE__ */ jsxs(Card, { role: "status", "aria-label": label, children: [
1053
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-40" }) }),
1054
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-2", children: Array.from({ length: fields }, (_, index) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
1055
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" }),
1056
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-full" })
1057
+ ] }, index)) }) })
1058
+ ] });
1059
+ }
1060
+ function DashboardSkeleton({ label }) {
1061
+ return /* @__PURE__ */ jsxs("div", { role: "status", "aria-label": label, className: "flex flex-col gap-6", children: [
1062
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1063
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-48" }),
1064
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-64 max-w-full" })
1065
+ ] }),
1066
+ /* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-3", children: Array.from({ length: 3 }, (_, index) => /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "flex flex-col gap-2", children: [
1067
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" }),
1068
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-16" })
1069
+ ] }) }, index)) }),
1070
+ /* @__PURE__ */ jsx(DataTableSkeletonBody, { rows: 3 })
1071
+ ] });
1072
+ }
152
1073
  function Empty2({ className, ...props }) {
153
1074
  return /* @__PURE__ */ jsx(
154
1075
  "div",
@@ -662,321 +1583,121 @@ function EditableSection({
662
1583
  }),
663
1584
  dialog
664
1585
  ] });
665
- }
666
- return /* @__PURE__ */ jsxs("div", { "data-slot": "editable-section", className: cn("space-y-4", className), children: [
667
- actions,
668
- content,
669
- statusNode,
670
- dialog
671
- ] });
672
- }
673
- function DataList({ className, ...props }) {
674
- return /* @__PURE__ */ jsx(
675
- "dl",
676
- {
677
- "data-slot": "data-list",
678
- className: cn("grid gap-4 sm:grid-cols-2", className),
679
- ...props
680
- }
681
- );
682
- }
683
- function DataListItem({
684
- label,
685
- children,
686
- empty = "\u2014",
687
- className,
688
- labelClassName,
689
- valueClassName
690
- }) {
691
- const isEmpty = children == null || children === false || typeof children === "string" && children.trim().length === 0;
692
- return /* @__PURE__ */ jsxs(
693
- "div",
694
- {
695
- "data-slot": "data-list-item",
696
- className: cn("flex flex-col gap-1.5", className),
697
- children: [
698
- /* @__PURE__ */ jsx(
699
- "dt",
700
- {
701
- className: cn(
702
- "text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
703
- labelClassName
704
- ),
705
- children: label
706
- }
707
- ),
708
- /* @__PURE__ */ jsx(
709
- "dd",
710
- {
711
- className: cn(
712
- "text-sm wrap-break-word",
713
- isEmpty && "text-muted-foreground",
714
- valueClassName
715
- ),
716
- children: isEmpty ? empty : children
717
- }
718
- )
719
- ]
720
- }
721
- );
722
- }
723
- function FieldMessage({
724
- id,
725
- children,
726
- className,
727
- ...props
728
- }) {
729
- const hasMessage = children != null && children !== false && !(typeof children === "string" && children.trim().length === 0);
730
- return /* @__PURE__ */ jsx(
731
- "p",
732
- {
733
- id,
734
- role: hasMessage ? "alert" : void 0,
735
- "data-slot": "field-message",
736
- className: cn("min-h-5 text-xs text-destructive", className),
737
- ...props,
738
- children: hasMessage ? children : "\xA0"
739
- }
740
- );
741
- }
742
- function isBrokenImage(img) {
743
- return img.complete && img.naturalWidth === 0;
744
- }
745
- function SafeImage({
746
- src,
747
- fallback,
748
- alt = "",
749
- onError,
750
- ...imgProps
751
- }) {
752
- const [failed, setFailed] = useState(false);
753
- const imgRef = useRef(null);
754
- const resolvedSrc = typeof src === "string" && src.length > 0 ? src : null;
755
- useLayoutEffect(() => {
756
- setFailed(false);
757
- }, [resolvedSrc]);
758
- useLayoutEffect(() => {
759
- const img = imgRef.current;
760
- if (img && isBrokenImage(img)) {
761
- setFailed(true);
762
- }
763
- }, [resolvedSrc, failed]);
764
- if (!resolvedSrc || failed) {
765
- return /* @__PURE__ */ jsx(Fragment, { children: fallback });
766
- }
767
- return /* @__PURE__ */ jsx(
768
- "img",
769
- {
770
- ...imgProps,
771
- ref: imgRef,
772
- src: resolvedSrc,
773
- alt,
774
- onError: (event) => {
775
- setFailed(true);
776
- onError?.(event);
777
- }
778
- }
779
- );
780
- }
781
- var defaultLabels = {
782
- theme: "Theme",
783
- system: "System",
784
- light: "Light",
785
- dark: "Dark"
786
- };
787
- var sizeClasses = {
788
- sm: { button: "size-8", icon: "size-4" },
789
- md: { button: "size-8", icon: "size-4" },
790
- lg: { button: "size-9", icon: "size-4" }
791
- };
792
- var shapeClasses = {
793
- rounded: "rounded-md",
794
- pill: "rounded-full"
795
- };
796
- var iconTriggerClassName = "border border-border bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground dark:border-border dark:bg-transparent dark:text-muted-foreground dark:hover:bg-accent/50";
797
- var themeIcons = {
798
- system: Monitor,
799
- light: Sun,
800
- dark: Moon
801
- };
802
- var themes = [
803
- { key: "system", icon: themeIcons.system },
804
- { key: "light", icon: themeIcons.light },
805
- { key: "dark", icon: themeIcons.dark }
806
- ];
807
- function storedTheme(value) {
808
- if (value === "system" || value === "light" || value === "dark") return value;
809
- return void 0;
810
- }
811
- function ThemeSwitcher({
812
- className,
813
- size = "sm",
814
- shape = "rounded",
815
- align = "end",
816
- side = "bottom",
817
- labels: userLabels
818
- }) {
819
- const { theme, setTheme } = useTheme();
820
- const [mounted, setMounted] = useState(false);
821
- const sizes = sizeClasses[size];
822
- const shapeClass = shapeClasses[shape];
823
- const labels = { ...defaultLabels, ...userLabels };
824
- const handleThemeClick = useCallback(
825
- (themeKey) => {
826
- setTheme(themeKey);
827
- },
828
- [setTheme]
829
- );
830
- useEffect(() => {
831
- setMounted(true);
832
- }, []);
833
- if (!mounted) {
834
- return /* @__PURE__ */ jsx(
835
- "div",
836
- {
837
- "aria-hidden": true,
838
- className: cn(
839
- sizes.button,
840
- shapeClass,
841
- iconTriggerClassName,
842
- className
843
- )
844
- }
845
- );
846
- }
847
- const currentTheme = storedTheme(theme);
848
- const TriggerIcon = currentTheme ? themeIcons[currentTheme] : Monitor;
849
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
850
- /* @__PURE__ */ jsx(
851
- DropdownMenuTrigger,
852
- {
853
- render: /* @__PURE__ */ jsx(
854
- Button,
855
- {
856
- "data-testid": "theme-switcher",
857
- variant: "outline",
858
- size: "icon",
859
- "aria-label": labels.theme,
860
- className: cn(
861
- sizes.button,
862
- shapeClass,
863
- iconTriggerClassName,
864
- className
865
- )
866
- }
867
- ),
868
- children: /* @__PURE__ */ jsx(TriggerIcon, { className: sizes.icon })
869
- }
870
- ),
871
- /* @__PURE__ */ jsx(
872
- DropdownMenuContent,
873
- {
874
- side,
875
- align,
876
- sideOffset: miniMenuContentDefaults.sideOffset,
877
- collisionPadding: miniMenuContentDefaults.collisionPadding,
878
- className: miniMenuContentClassName,
879
- children: themes.map(({ key, icon: Icon }) => /* @__PURE__ */ jsxs(
880
- DropdownMenuItem,
881
- {
882
- onClick: () => handleThemeClick(key),
883
- className: cn(
884
- "gap-2 cursor-pointer",
885
- currentTheme === key && "bg-accent text-accent-foreground [&_svg]:text-accent-foreground"
886
- ),
887
- children: [
888
- /* @__PURE__ */ jsx(Icon, { className: "size-4" }),
889
- /* @__PURE__ */ jsx("span", { children: labels[key] })
890
- ]
891
- },
892
- key
893
- ))
894
- }
895
- )
1586
+ }
1587
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "editable-section", className: cn("space-y-4", className), children: [
1588
+ actions,
1589
+ content,
1590
+ statusNode,
1591
+ dialog
896
1592
  ] });
897
1593
  }
898
- var defaultLanguages = [
899
- { key: "es-MX", label: "ES", nativeName: "Espa\xF1ol (M\xE9xico)" },
900
- { key: "en", label: "EN", nativeName: "English" }
901
- ];
902
- var sizeClasses2 = {
903
- sm: { button: "size-8", icon: "size-4" },
904
- md: { button: "size-8", icon: "size-4" },
905
- lg: { button: "size-9", icon: "size-4" }
906
- };
907
- var shapeClasses2 = {
908
- rounded: "rounded-md",
909
- squared: "rounded-sm",
910
- pill: "rounded-full"
911
- };
912
- var iconTriggerClassName2 = "border border-border bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground dark:border-border dark:bg-transparent dark:text-muted-foreground dark:hover:bg-accent/50";
913
- function LanguageSwitcher({
914
- languages: propLanguages,
915
- currentLanguage: propCurrentLanguage,
916
- onLanguageChange: propOnLanguageChange,
917
- labels = {},
1594
+ function DataList({ className, ...props }) {
1595
+ return /* @__PURE__ */ jsx(
1596
+ "dl",
1597
+ {
1598
+ "data-slot": "data-list",
1599
+ className: cn("grid gap-4 sm:grid-cols-2", className),
1600
+ ...props
1601
+ }
1602
+ );
1603
+ }
1604
+ function DataListItem({
1605
+ label,
1606
+ children,
1607
+ empty = "\u2014",
918
1608
  className,
919
- size = "sm",
920
- shape = "rounded",
921
- align = "end",
922
- side = "bottom"
1609
+ labelClassName,
1610
+ valueClassName
923
1611
  }) {
924
- const context = useLanguageContext();
925
- const contextLanguages = context?.languages?.map((lang) => ({
926
- key: lang.code,
927
- label: lang.code.toUpperCase(),
928
- nativeName: lang.name
929
- }));
930
- const languages = propLanguages ?? contextLanguages ?? defaultLanguages;
931
- const currentLanguage = propCurrentLanguage ?? context?.language ?? "en";
932
- const onLanguageChange = propOnLanguageChange ?? context?.setLanguage;
933
- const sizes = sizeClasses2[size];
934
- const shapeClass = shapeClasses2[shape];
935
- const accessibleName = labels.language ?? "Language";
936
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
937
- /* @__PURE__ */ jsx(
938
- DropdownMenuTrigger,
939
- {
940
- render: /* @__PURE__ */ jsx(
941
- Button,
1612
+ const isEmpty = children == null || children === false || typeof children === "string" && children.trim().length === 0;
1613
+ return /* @__PURE__ */ jsxs(
1614
+ "div",
1615
+ {
1616
+ "data-slot": "data-list-item",
1617
+ className: cn("flex flex-col gap-1.5", className),
1618
+ children: [
1619
+ /* @__PURE__ */ jsx(
1620
+ "dt",
942
1621
  {
943
- variant: "outline",
944
- size: "icon",
945
- "aria-label": accessibleName,
946
1622
  className: cn(
947
- sizes.button,
948
- shapeClass,
949
- iconTriggerClassName2,
950
- className
951
- )
1623
+ "text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
1624
+ labelClassName
1625
+ ),
1626
+ children: label
952
1627
  }
953
1628
  ),
954
- children: /* @__PURE__ */ jsx(Languages, { className: sizes.icon })
955
- }
956
- ),
957
- /* @__PURE__ */ jsx(
958
- DropdownMenuContent,
959
- {
960
- side,
961
- align,
962
- sideOffset: miniMenuContentDefaults.sideOffset,
963
- collisionPadding: miniMenuContentDefaults.collisionPadding,
964
- className: cn(miniMenuContentClassName, "min-w-0 w-auto"),
965
- children: languages.map(({ key, nativeName }) => /* @__PURE__ */ jsx(
966
- DropdownMenuItem,
1629
+ /* @__PURE__ */ jsx(
1630
+ "dd",
967
1631
  {
968
- onClick: () => onLanguageChange?.(key),
969
1632
  className: cn(
970
- "justify-center text-xs font-semibold cursor-pointer px-3",
971
- currentLanguage === key && "bg-accent text-accent-foreground"
1633
+ "text-sm wrap-break-word",
1634
+ isEmpty && "text-muted-foreground",
1635
+ valueClassName
972
1636
  ),
973
- children: nativeName
974
- },
975
- key
976
- ))
1637
+ children: isEmpty ? empty : children
1638
+ }
1639
+ )
1640
+ ]
1641
+ }
1642
+ );
1643
+ }
1644
+ function FieldMessage({
1645
+ id,
1646
+ children,
1647
+ className,
1648
+ ...props
1649
+ }) {
1650
+ const hasMessage = children != null && children !== false && !(typeof children === "string" && children.trim().length === 0);
1651
+ return /* @__PURE__ */ jsx(
1652
+ "p",
1653
+ {
1654
+ id,
1655
+ role: hasMessage ? "alert" : void 0,
1656
+ "data-slot": "field-message",
1657
+ className: cn("min-h-5 text-xs text-destructive", className),
1658
+ ...props,
1659
+ children: hasMessage ? children : "\xA0"
1660
+ }
1661
+ );
1662
+ }
1663
+ function isBrokenImage(img) {
1664
+ return img.complete && img.naturalWidth === 0;
1665
+ }
1666
+ function SafeImage({
1667
+ src,
1668
+ fallback,
1669
+ alt = "",
1670
+ onError,
1671
+ ...imgProps
1672
+ }) {
1673
+ const [failed, setFailed] = useState(false);
1674
+ const imgRef = useRef(null);
1675
+ const resolvedSrc = typeof src === "string" && src.length > 0 ? src : null;
1676
+ useLayoutEffect(() => {
1677
+ setFailed(false);
1678
+ }, [resolvedSrc]);
1679
+ useLayoutEffect(() => {
1680
+ const img = imgRef.current;
1681
+ if (img && isBrokenImage(img)) {
1682
+ setFailed(true);
1683
+ }
1684
+ }, [resolvedSrc, failed]);
1685
+ if (!resolvedSrc || failed) {
1686
+ return /* @__PURE__ */ jsx(Fragment, { children: fallback });
1687
+ }
1688
+ return /* @__PURE__ */ jsx(
1689
+ "img",
1690
+ {
1691
+ ...imgProps,
1692
+ ref: imgRef,
1693
+ src: resolvedSrc,
1694
+ alt,
1695
+ onError: (event) => {
1696
+ setFailed(true);
1697
+ onError?.(event);
977
1698
  }
978
- )
979
- ] });
1699
+ }
1700
+ );
980
1701
  }
981
1702
  var DEFAULT_LABELS = {
982
1703
  uploadAria: "Upload image",
@@ -2347,87 +3068,6 @@ function useMediaQuery2(query) {
2347
3068
  }, [query]);
2348
3069
  return matches;
2349
3070
  }
2350
-
2351
- // src/lib/avatar.ts
2352
- var EMPTY_COLORS = {
2353
- backgroundColor: "#9ca3af",
2354
- color: "#111111"
2355
- };
2356
- var AVATAR_PALETTE = [
2357
- "#4f6d8c",
2358
- // slate blue
2359
- "#3d7a6a",
2360
- // teal
2361
- "#6b5b8a",
2362
- // muted purple
2363
- "#8a5a4a",
2364
- // warm brown
2365
- "#4a7a8a",
2366
- // steel cyan
2367
- "#7a6b4a",
2368
- // olive
2369
- "#5a6b8a",
2370
- // periwinkle
2371
- "#8a4a5a",
2372
- // rose
2373
- "#4a8a6b",
2374
- // green
2375
- "#6b4a7a",
2376
- // plum
2377
- "#8a6b4a",
2378
- // amber brown
2379
- "#4a5a8a",
2380
- // indigo
2381
- "#7a4a6b",
2382
- // mauve
2383
- "#5a8a4a",
2384
- // leaf
2385
- "#8a5a7a",
2386
- // dusty pink
2387
- "#3d6b7a"
2388
- // deep teal
2389
- ];
2390
- function hashString(input) {
2391
- let hash = 2166136261;
2392
- for (let i = 0; i < input.length; i++) {
2393
- hash ^= input.charCodeAt(i);
2394
- hash = Math.imul(hash, 16777619);
2395
- }
2396
- return hash >>> 0;
2397
- }
2398
- function srgbToLinear(channel) {
2399
- const c = channel / 255;
2400
- return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
2401
- }
2402
- function relativeLuminance(hex) {
2403
- const normalized = hex.replace("#", "");
2404
- const r = Number.parseInt(normalized.slice(0, 2), 16);
2405
- const g = Number.parseInt(normalized.slice(2, 4), 16);
2406
- const b = Number.parseInt(normalized.slice(4, 6), 16);
2407
- return 0.2126 * srgbToLinear(r) + 0.7152 * srgbToLinear(g) + 0.0722 * srgbToLinear(b);
2408
- }
2409
- function contrastingTextColor(backgroundHex) {
2410
- return relativeLuminance(backgroundHex) > 0.179 ? "#111111" : "#ffffff";
2411
- }
2412
- function getInitials(name, max = 2) {
2413
- const parts = name.trim().split(/\s+/).filter(Boolean);
2414
- if (parts.length === 0) return "?";
2415
- return parts.slice(0, Math.max(1, max)).map((part) => part.charAt(0)).join("").toUpperCase();
2416
- }
2417
- function getAvatarColors(name) {
2418
- const normalized = name.trim().toLowerCase();
2419
- if (!normalized) {
2420
- return { ...EMPTY_COLORS };
2421
- }
2422
- const backgroundColor = AVATAR_PALETTE[hashString(normalized) % AVATAR_PALETTE.length];
2423
- return {
2424
- backgroundColor,
2425
- color: contrastingTextColor(backgroundColor)
2426
- };
2427
- }
2428
- function avatarFallbackStyle(name) {
2429
- return getAvatarColors(name);
2430
- }
2431
3071
  function StatHighlightCard({
2432
3072
  label,
2433
3073
  value,
@@ -3468,6 +4108,6 @@ function MatchReview({
3468
4108
  );
3469
4109
  }
3470
4110
 
3471
- export { AuditTimeline, AvatarEditor, AvatarEditorDialog, COOKIE_CONSENT_MAX_AGE, COOKIE_CONSENT_NAME, COOKIE_CONSENT_VALUES, ConfirmDestructiveDialog, CookieConsentBanner, CostBreakdownCard, DEFAULT_AUDIT_TIMELINE_LABELS, DEFAULT_COOKIE_CONSENT_BANNER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_ENTITY_GRAPH_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_LEGAL_ACCEPT_CHECKBOX_LABELS, DEFAULT_LEGAL_ACCEPT_DIALOG_LABELS, DEFAULT_MATCH_REVIEW_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DEFAULT_RISK_BADGE_LABELS, DataList, DataListItem, DimensionBreakdownTable, EditableSection, Empty2 as Empty, EmptyContent2 as EmptyContent, EmptyDescription2 as EmptyDescription, EmptyHeader2 as EmptyHeader, EmptyMedia2 as EmptyMedia, EmptyState, EmptyTitle2 as EmptyTitle, EntityGraph, ErrorState, Field, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, LanguageContext, LanguageSwitcher, LegalAcceptCheckbox, LegalAcceptDialog, LegalMarkdown, ListSkeleton, LoadingState, MatchReview, MetricChartCard, MetricEmptyState, MetricSkeleton, NotificationBell, PageTitle, RiskBadge, SafeImage, SparklineStat, StatHighlightCard, THEME_INIT_SCRIPT, THEME_INIT_SCRIPT_ID, THEME_STORAGE_KEY, TIME_RANGE_OPTIONS, TableSkeleton, ThemeSwitcher, TimeRangePicker, avatarFallbackStyle, cn, cookieConsentAllowsReplay, cookieDomainFromHostname, createMultipartUploadController, defaultLanguages, fileMatchesAccept, getAvatarColors, getInitials, isCookieConsentValue, isEmbeddedWindow, matchClaimIsUnverified, parseCookieConsent, partRanges, progressFromBytes, readCookieConsent, serializeCookieConsent, sourceUrlIsHttps, useEditableSection, useLanguageContext, useMediaQuery2 as useMediaQuery, writeCookieConsent };
4111
+ export { AccountMenu, AppShell, AuditTimeline, AvatarEditor, AvatarEditorDialog, COOKIE_CONSENT_MAX_AGE, COOKIE_CONSENT_NAME, COOKIE_CONSENT_VALUES, ConfirmDestructiveDialog, CookieConsentBanner, CostBreakdownCard, DATA_TABLE_ROW_CLASS, DEFAULT_AUDIT_TIMELINE_LABELS, DEFAULT_COOKIE_CONSENT_BANNER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_ENTITY_GRAPH_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_LEGAL_ACCEPT_CHECKBOX_LABELS, DEFAULT_LEGAL_ACCEPT_DIALOG_LABELS, DEFAULT_MATCH_REVIEW_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DEFAULT_RISK_BADGE_LABELS, DashboardSkeleton, DataList, DataListItem, DataTable, DataTableSkeleton, DetailPageSkeleton, DimensionBreakdownTable, EditableSection, Empty2 as Empty, EmptyContent2 as EmptyContent, EmptyDescription2 as EmptyDescription, EmptyHeader2 as EmptyHeader, EmptyMedia2 as EmptyMedia, EmptyState, EmptyTitle2 as EmptyTitle, EntityGraph, ErrorState, Field, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, FormCardSkeleton, LanguageContext, LanguageSwitcher, LegalAcceptCheckbox, LegalAcceptDialog, LegalMarkdown, ListSkeleton, LoadingState, MatchReview, MetricChartCard, MetricEmptyState, MetricSkeleton, NavTabs, NavigationProgress, NotificationBell, PageContainer, PageTitle, PageTitleSkeleton, RiskBadge, RouteLoading, SafeImage, SparklineStat, StatHighlightCard, THEME_INIT_SCRIPT, THEME_INIT_SCRIPT_ID, THEME_STORAGE_KEY, TIME_RANGE_OPTIONS, TableSkeleton, ThemeSwitcher, TimeRangePicker, avatarFallbackStyle, cn, cookieConsentAllowsReplay, cookieDomainFromHostname, createMultipartUploadController, defaultLanguages, fileMatchesAccept, getAvatarColors, getInitials, isCookieConsentValue, isEmbeddedWindow, matchClaimIsUnverified, parseCookieConsent, partRanges, progressFromBytes, readCookieConsent, renderShellLink, serializeCookieConsent, signalNavigationStart, sourceUrlIsHttps, suppressNavigationProgress, useEditableSection, useLanguageContext, useMediaQuery2 as useMediaQuery, writeCookieConsent };
3472
4112
  //# sourceMappingURL=index.js.map
3473
4113
  //# sourceMappingURL=index.js.map