@nubitio/ui 0.5.28 → 0.5.30

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.mjs CHANGED
@@ -517,7 +517,7 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
517
517
  function cx$2(...values) {
518
518
  return values.filter(Boolean).join(" ");
519
519
  }
520
- function normalizeIcon(icon) {
520
+ function normalizeIcon$2(icon) {
521
521
  if (!icon) return void 0;
522
522
  if (icon.startsWith("ph ")) return icon;
523
523
  if (icon.startsWith("ph-")) return `ph ${icon}`;
@@ -555,7 +555,7 @@ function getMenuStyle(containerRef, menuMinWidth = 72) {
555
555
  visibility: "visible"
556
556
  };
557
557
  }
558
- function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText }) {
558
+ function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange }) {
559
559
  const generatedId = useId();
560
560
  const id = idProp ?? generatedId;
561
561
  const [open, setOpen] = useState(false);
@@ -568,22 +568,26 @@ function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabl
568
568
  });
569
569
  const selected = options.find((option) => option.value === value);
570
570
  const computeMenuStyle = useCallback(() => getMenuStyle(containerRef, menuMinWidth), [menuMinWidth]);
571
+ const setMenuOpen = useCallback((next) => {
572
+ setOpen(next);
573
+ onOpenChange?.(next);
574
+ }, [onOpenChange]);
571
575
  useEffect(() => {
572
576
  if (!open) return;
573
577
  const handler = (e) => {
574
578
  const target = e.target;
575
- if (!containerRef.current?.contains(target) && !menuRef.current?.contains(target)) setOpen(false);
579
+ if (!containerRef.current?.contains(target) && !menuRef.current?.contains(target)) setMenuOpen(false);
576
580
  };
577
581
  document.addEventListener("mousedown", handler);
578
582
  return () => document.removeEventListener("mousedown", handler);
579
- }, [open]);
583
+ }, [open, setMenuOpen]);
580
584
  useLayoutEffect(() => {
581
585
  if (!open) return;
582
586
  const update = () => {
583
587
  if (!containerRef.current) return;
584
588
  const rect = containerRef.current.getBoundingClientRect();
585
589
  if (rect.top >= window.innerHeight || rect.bottom <= 0) {
586
- setOpen(false);
590
+ setMenuOpen(false);
587
591
  return;
588
592
  }
589
593
  setMenuStyle(computeMenuStyle());
@@ -598,11 +602,15 @@ function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabl
598
602
  window.removeEventListener("resize", update);
599
603
  window.removeEventListener("scroll", update, { capture: true });
600
604
  };
601
- }, [open, computeMenuStyle]);
605
+ }, [
606
+ open,
607
+ computeMenuStyle,
608
+ setMenuOpen
609
+ ]);
602
610
  const openMenu = useCallback(() => {
603
611
  setMenuStyle(computeMenuStyle());
604
- setOpen(true);
605
- }, [computeMenuStyle]);
612
+ setMenuOpen(true);
613
+ }, [computeMenuStyle, setMenuOpen]);
606
614
  const control = /* @__PURE__ */ jsxs("div", {
607
615
  ref: containerRef,
608
616
  className: cx$2("nb-dropdown", `nb-dropdown--${variant}`, open && "nb-dropdown--open", disabled && "nb-dropdown--disabled", className),
@@ -613,7 +621,7 @@ function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabl
613
621
  className: "nb-dropdown__toolbar-label",
614
622
  id: `${id}-label`,
615
623
  children: [icon && /* @__PURE__ */ jsx("i", {
616
- className: normalizeIcon(icon),
624
+ className: normalizeIcon$2(icon),
617
625
  "aria-hidden": "true"
618
626
  }), /* @__PURE__ */ jsx("span", { children: label })]
619
627
  }),
@@ -624,7 +632,7 @@ function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabl
624
632
  "aria-expanded": open,
625
633
  "aria-labelledby": label ? `${id}-label ${id}-value` : `${id}-value`,
626
634
  disabled,
627
- onClick: () => open ? setOpen(false) : openMenu(),
635
+ onClick: () => open ? setMenuOpen(false) : openMenu(),
628
636
  children: [/* @__PURE__ */ jsx("span", {
629
637
  className: "nb-dropdown__value",
630
638
  id: `${id}-value`,
@@ -634,38 +642,45 @@ function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabl
634
642
  "aria-hidden": "true"
635
643
  })]
636
644
  }),
637
- open && !disabled && createPortal(/* @__PURE__ */ jsx("ul", {
645
+ open && !disabled && createPortal(/* @__PURE__ */ jsxs("div", {
638
646
  ref: menuRef,
639
647
  className: cx$2("nb-dropdown__menu", `nb-dropdown__menu--${variant}`),
640
- role: "listbox",
641
- "aria-labelledby": label ? `${id}-label` : void 0,
642
648
  style: menuStyle,
643
- children: options.map((option) => {
644
- const isActive = option.value === value;
645
- return /* @__PURE__ */ jsx("li", {
646
- role: "presentation",
647
- children: /* @__PURE__ */ jsx("button", {
648
- type: "button",
649
- role: "option",
650
- "aria-selected": isActive,
651
- disabled: option.disabled,
652
- className: cx$2("nb-dropdown__option", isActive && "nb-dropdown__option--active"),
653
- onClick: () => {
654
- if (option.disabled) return;
655
- onChange(option.value);
656
- setOpen(false);
657
- },
658
- children: /* @__PURE__ */ jsxs("span", {
659
- className: "nb-dropdown__option-content",
660
- children: [option.iconText && /* @__PURE__ */ jsx("span", {
661
- className: "nb-dropdown__option-icon",
662
- "aria-hidden": "true",
663
- children: option.iconText
664
- }), /* @__PURE__ */ jsx("span", { children: option.label })]
665
- })
649
+ children: [
650
+ menuHeader,
651
+ /* @__PURE__ */ jsx("ul", {
652
+ role: "listbox",
653
+ "aria-labelledby": label ? `${id}-label` : void 0,
654
+ className: "nb-dropdown__menu-list",
655
+ children: options.map((option) => {
656
+ const isActive = option.value === value;
657
+ return /* @__PURE__ */ jsx("li", {
658
+ role: "presentation",
659
+ children: /* @__PURE__ */ jsx("button", {
660
+ type: "button",
661
+ role: "option",
662
+ "aria-selected": isActive,
663
+ disabled: option.disabled,
664
+ className: cx$2("nb-dropdown__option", isActive && "nb-dropdown__option--active"),
665
+ onClick: () => {
666
+ if (option.disabled) return;
667
+ onChange(option.value);
668
+ setMenuOpen(false);
669
+ },
670
+ children: /* @__PURE__ */ jsxs("span", {
671
+ className: "nb-dropdown__option-content",
672
+ children: [option.iconText && /* @__PURE__ */ jsx("span", {
673
+ className: "nb-dropdown__option-icon",
674
+ "aria-hidden": "true",
675
+ children: option.iconText
676
+ }), /* @__PURE__ */ jsx("span", { children: option.label })]
677
+ })
678
+ })
679
+ }, option.value);
666
680
  })
667
- }, option.value);
668
- })
681
+ }),
682
+ menuFooter
683
+ ]
669
684
  }), document.body)
670
685
  ]
671
686
  });
@@ -692,6 +707,139 @@ function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabl
692
707
  });
693
708
  }
694
709
  //#endregion
710
+ //#region packages/ui/SearchableAppDropdown.tsx
711
+ function normalizeSearch(value) {
712
+ return value.trim().toLowerCase();
713
+ }
714
+ function filterOptions(options, query) {
715
+ const needle = normalizeSearch(query);
716
+ if (!needle) return options;
717
+ return options.filter((option) => {
718
+ return [
719
+ option.label,
720
+ option.selectedLabel,
721
+ option.value
722
+ ].filter(Boolean).join(" ").toLowerCase().includes(needle);
723
+ });
724
+ }
725
+ function SearchableAppDropdown({ options = [], searchable = true, searchPlaceholder = "Buscar…", onSearch, minSearchLength = 2, emptySearchLabel = "Sin resultados", loadingLabel = "Buscando…", selectedOption = null, value, onChange, placeholder, disabled, ...rest }) {
726
+ const searchInputId = useId();
727
+ const [open, setOpen] = useState(false);
728
+ const [searchQuery, setSearchQuery] = useState("");
729
+ const [remoteOptions, setRemoteOptions] = useState([]);
730
+ const [loading, setLoading] = useState(false);
731
+ const requestIdRef = useRef(0);
732
+ const staticSelected = useMemo(() => options.find((option) => option.value === value) ?? selectedOption ?? null, [
733
+ options,
734
+ selectedOption,
735
+ value
736
+ ]);
737
+ const resolvedOptions = useMemo(() => {
738
+ const merged = /* @__PURE__ */ new Map();
739
+ for (const option of [...options, ...remoteOptions]) if (option.value) merged.set(option.value, option);
740
+ if (staticSelected?.value) merged.set(staticSelected.value, staticSelected);
741
+ const base = Array.from(merged.values()).filter((option) => option.value !== "");
742
+ if (!searchable) return base;
743
+ if (onSearch) return base;
744
+ return filterOptions(base, searchQuery);
745
+ }, [
746
+ onSearch,
747
+ options,
748
+ remoteOptions,
749
+ searchable,
750
+ searchQuery,
751
+ staticSelected
752
+ ]);
753
+ const runSearch = useCallback(async (query) => {
754
+ if (!onSearch) return;
755
+ const trimmed = query.trim();
756
+ if (trimmed.length < minSearchLength) {
757
+ setRemoteOptions([]);
758
+ setLoading(false);
759
+ return;
760
+ }
761
+ const requestId = ++requestIdRef.current;
762
+ setLoading(true);
763
+ try {
764
+ const results = await onSearch(trimmed);
765
+ if (requestId !== requestIdRef.current) return;
766
+ setRemoteOptions(results.filter((option) => option.value !== ""));
767
+ } catch {
768
+ if (requestId !== requestIdRef.current) return;
769
+ setRemoteOptions([]);
770
+ } finally {
771
+ if (requestId === requestIdRef.current) setLoading(false);
772
+ }
773
+ }, [minSearchLength, onSearch]);
774
+ useEffect(() => {
775
+ if (!open || !onSearch) return;
776
+ const timer = window.setTimeout(() => {
777
+ runSearch(searchQuery);
778
+ }, 250);
779
+ return () => window.clearTimeout(timer);
780
+ }, [
781
+ open,
782
+ onSearch,
783
+ runSearch,
784
+ searchQuery
785
+ ]);
786
+ useEffect(() => {
787
+ if (open) return;
788
+ setSearchQuery("");
789
+ setRemoteOptions([]);
790
+ setLoading(false);
791
+ }, [open]);
792
+ const menuHeader = searchable ? /* @__PURE__ */ jsxs("div", {
793
+ className: "nb-searchable-dropdown__search",
794
+ children: [/* @__PURE__ */ jsx("i", {
795
+ className: "ph ph-magnifying-glass",
796
+ "aria-hidden": "true"
797
+ }), /* @__PURE__ */ jsx("input", {
798
+ id: searchInputId,
799
+ type: "search",
800
+ value: searchQuery,
801
+ onChange: (event) => setSearchQuery(event.target.value),
802
+ placeholder: searchPlaceholder,
803
+ autoComplete: "off",
804
+ onKeyDown: (event) => event.stopPropagation()
805
+ })]
806
+ }) : null;
807
+ const menuFooter = (() => {
808
+ if (!searchable || !onSearch) return null;
809
+ if (loading) return /* @__PURE__ */ jsx("div", {
810
+ className: "nb-searchable-dropdown__status",
811
+ children: loadingLabel
812
+ });
813
+ if (searchQuery.trim().length < minSearchLength) return /* @__PURE__ */ jsxs("div", {
814
+ className: "nb-searchable-dropdown__status",
815
+ children: [
816
+ "Escribe al menos ",
817
+ minSearchLength,
818
+ " caracteres"
819
+ ]
820
+ });
821
+ if (resolvedOptions.length === 0) return /* @__PURE__ */ jsx("div", {
822
+ className: "nb-searchable-dropdown__status",
823
+ children: emptySearchLabel
824
+ });
825
+ return null;
826
+ })();
827
+ return /* @__PURE__ */ jsx(AppDropdown, {
828
+ ...rest,
829
+ value,
830
+ onChange,
831
+ placeholder,
832
+ disabled,
833
+ options: [{
834
+ value: "",
835
+ label: placeholder ?? "Seleccionar…"
836
+ }, ...resolvedOptions],
837
+ menuHeader,
838
+ menuFooter,
839
+ onOpenChange: setOpen
840
+ });
841
+ }
842
+ //#endregion
695
843
  //#region packages/ui/theme/ThemeProvider.tsx
696
844
  const ThemeContext = React.createContext(null);
697
845
  function useTheme() {
@@ -1298,21 +1446,275 @@ const StatCard = ({ title, headerExtra, menuVisible = true, menuItems = [{ label
1298
1446
  });
1299
1447
  //#endregion
1300
1448
  //#region packages/ui/KpiMetricRow.tsx
1301
- function KpiMetricRow({ items, className = "" }) {
1449
+ function normalizeIcon$1(icon) {
1450
+ if (!icon) return void 0;
1451
+ if (icon.startsWith("ph ")) return icon;
1452
+ if (icon.startsWith("ph-")) return `ph ${icon}`;
1453
+ return `ph ph-${icon}`;
1454
+ }
1455
+ function KpiMetricRow({ items, className = "", layout = "cards", density = "default", testId, loading = false }) {
1302
1456
  if (items.length === 0) return null;
1303
1457
  return /* @__PURE__ */ jsx("div", {
1304
- className: `nb-kpi-metric-row${className ? ` ${className}` : ""}`,
1458
+ className: `nb-kpi-metric-row${layout === "strip" ? " nb-kpi-metric-row--strip" : ""}${density === "compact" ? " nb-kpi-metric-row--compact" : ""}${className ? ` ${className}` : ""}`,
1459
+ "data-testid": testId,
1460
+ role: "group",
1461
+ "aria-busy": loading,
1462
+ children: items.map((item) => {
1463
+ const iconClass = normalizeIcon$1(item.icon);
1464
+ return /* @__PURE__ */ jsxs("div", {
1465
+ className: `nb-kpi-metric-card nb-kpi-metric-card--${item.tone ?? "default"}`,
1466
+ children: [layout === "strip" && iconClass && /* @__PURE__ */ jsx("span", {
1467
+ className: "nb-kpi-metric-card__icon",
1468
+ "aria-hidden": "true",
1469
+ children: /* @__PURE__ */ jsx("i", { className: iconClass })
1470
+ }), /* @__PURE__ */ jsxs("div", {
1471
+ className: "nb-kpi-metric-card__body",
1472
+ children: [
1473
+ /* @__PURE__ */ jsx("span", {
1474
+ className: "nb-kpi-metric-card__label",
1475
+ children: item.label
1476
+ }),
1477
+ /* @__PURE__ */ jsx("span", {
1478
+ className: "nb-kpi-metric-card__value",
1479
+ children: item.value
1480
+ }),
1481
+ item.hint && /* @__PURE__ */ jsx("span", {
1482
+ className: "nb-kpi-metric-card__hint",
1483
+ children: item.hint
1484
+ })
1485
+ ]
1486
+ })]
1487
+ }, item.label);
1488
+ })
1489
+ });
1490
+ }
1491
+ //#endregion
1492
+ //#region packages/ui/SegmentedControl.tsx
1493
+ function SegmentedControl({ options, value, onChange, ariaLabel, className = "", size = "md" }) {
1494
+ if (options.length === 0) return null;
1495
+ return /* @__PURE__ */ jsx("div", {
1496
+ className: `nb-segmented-control${size === "sm" ? " nb-segmented-control--sm" : ""}${className ? ` ${className}` : ""}`,
1497
+ role: "group",
1498
+ "aria-label": ariaLabel,
1499
+ children: options.map((option) => {
1500
+ const active = option.value === value;
1501
+ return /* @__PURE__ */ jsx("button", {
1502
+ type: "button",
1503
+ className: `nb-segmented-control__btn${active ? " nb-segmented-control__btn--active" : ""}`,
1504
+ "aria-pressed": active,
1505
+ disabled: option.disabled,
1506
+ onClick: () => onChange(option.value),
1507
+ children: option.label
1508
+ }, option.value);
1509
+ })
1510
+ });
1511
+ }
1512
+ //#endregion
1513
+ //#region packages/ui/FilterPanel.tsx
1514
+ function FilterPanel({ category, status, layout = "stacked", density = "default", className = "", testId }) {
1515
+ const [search, setSearch] = useState("");
1516
+ const threshold = category.searchThreshold ?? 10;
1517
+ const showSearch = category.options.length > threshold;
1518
+ const filteredOptions = useMemo(() => {
1519
+ const query = search.trim().toLowerCase();
1520
+ if (!query) return category.options;
1521
+ return category.options.filter((option) => String(option.label).toLowerCase().includes(query));
1522
+ }, [category.options, search]);
1523
+ const layoutClass = layout === "toolbar" ? " nb-filter-panel--toolbar" : "";
1524
+ const densityClass = density === "compact" ? " nb-filter-panel--compact" : "";
1525
+ const categoryChips = /* @__PURE__ */ jsxs("div", {
1526
+ className: "nb-filter-panel__chips",
1305
1527
  role: "group",
1306
- children: items.map((item) => /* @__PURE__ */ jsxs("div", {
1307
- className: `nb-kpi-metric-card nb-kpi-metric-card--${item.tone ?? "default"}`,
1528
+ "aria-label": category.ariaLabel,
1529
+ children: [
1530
+ /* @__PURE__ */ jsx(Chip, {
1531
+ label: category.allLabel ?? "Todas",
1532
+ active: category.selectedKey === null,
1533
+ size: "sm",
1534
+ onClick: () => category.onSelect(null)
1535
+ }),
1536
+ filteredOptions.map((option) => /* @__PURE__ */ jsx(Chip, {
1537
+ label: option.label,
1538
+ active: category.selectedKey === option.key,
1539
+ size: "sm",
1540
+ onClick: () => category.onSelect(option.key)
1541
+ }, option.key)),
1542
+ showSearch && filteredOptions.length === 0 && /* @__PURE__ */ jsx("span", {
1543
+ className: "nb-filter-panel__empty",
1544
+ children: category.emptyMessage ?? "Sin coincidencias"
1545
+ })
1546
+ ]
1547
+ });
1548
+ if (layout === "toolbar") return /* @__PURE__ */ jsx("div", {
1549
+ className: `nb-filter-panel${layoutClass}${densityClass}${className ? ` ${className}` : ""}`,
1550
+ "data-testid": testId,
1551
+ children: /* @__PURE__ */ jsxs("div", {
1552
+ className: "nb-filter-panel__toolbar",
1553
+ children: [
1554
+ /* @__PURE__ */ jsx("span", {
1555
+ className: "nb-filter-panel__title",
1556
+ children: category.title
1557
+ }),
1558
+ showSearch && /* @__PURE__ */ jsx("div", {
1559
+ className: "nb-filter-panel__search",
1560
+ children: /* @__PURE__ */ jsx(TextField, {
1561
+ value: search,
1562
+ onChange: (event) => setSearch(event.target.value),
1563
+ placeholder: category.searchPlaceholder ?? "Buscar…",
1564
+ "aria-label": category.searchPlaceholder ?? "Buscar"
1565
+ })
1566
+ }),
1567
+ /* @__PURE__ */ jsx("div", {
1568
+ className: "nb-filter-panel__scroll nb-filter-panel__scroll--grow",
1569
+ children: categoryChips
1570
+ }),
1571
+ status && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
1572
+ className: "nb-filter-panel__title nb-filter-panel__title--status",
1573
+ children: status.title
1574
+ }), /* @__PURE__ */ jsx(SegmentedControl, {
1575
+ options: status.options,
1576
+ value: status.value,
1577
+ onChange: status.onChange,
1578
+ ariaLabel: status.ariaLabel,
1579
+ size: "sm"
1580
+ })] })
1581
+ ]
1582
+ })
1583
+ });
1584
+ return /* @__PURE__ */ jsxs("div", {
1585
+ className: `nb-filter-panel${layoutClass}${densityClass}${className ? ` ${className}` : ""}`,
1586
+ "data-testid": testId,
1587
+ children: [/* @__PURE__ */ jsxs("div", {
1588
+ className: "nb-filter-panel__section",
1589
+ children: [/* @__PURE__ */ jsxs("div", {
1590
+ className: "nb-filter-panel__head",
1591
+ children: [/* @__PURE__ */ jsx("span", {
1592
+ className: "nb-filter-panel__title",
1593
+ children: category.title
1594
+ }), showSearch && /* @__PURE__ */ jsx("div", {
1595
+ className: "nb-filter-panel__search",
1596
+ children: /* @__PURE__ */ jsx(TextField, {
1597
+ value: search,
1598
+ onChange: (event) => setSearch(event.target.value),
1599
+ placeholder: category.searchPlaceholder ?? "Buscar…",
1600
+ "aria-label": category.searchPlaceholder ?? "Buscar"
1601
+ })
1602
+ })]
1603
+ }), /* @__PURE__ */ jsx("div", {
1604
+ className: "nb-filter-panel__scroll",
1605
+ children: categoryChips
1606
+ })]
1607
+ }), status && /* @__PURE__ */ jsxs("div", {
1608
+ className: "nb-filter-panel__section nb-filter-panel__section--status",
1308
1609
  children: [/* @__PURE__ */ jsx("span", {
1309
- className: "nb-kpi-metric-card__label",
1310
- children: item.label
1311
- }), /* @__PURE__ */ jsx("span", {
1312
- className: "nb-kpi-metric-card__value",
1313
- children: item.value
1610
+ className: "nb-filter-panel__title",
1611
+ children: status.title
1612
+ }), /* @__PURE__ */ jsx(SegmentedControl, {
1613
+ options: status.options,
1614
+ value: status.value,
1615
+ onChange: status.onChange,
1616
+ ariaLabel: status.ariaLabel,
1617
+ size: "sm"
1618
+ })]
1619
+ })]
1620
+ });
1621
+ }
1622
+ //#endregion
1623
+ //#region packages/ui/ScopeTabs.tsx
1624
+ /**
1625
+ * Pill tabs for scoping a list view (warehouse, branch, period, etc.).
1626
+ * Hides itself when there is at most one scope option.
1627
+ */
1628
+ function ScopeTabs({ options, selectedKey, onChange, allLabel = "Todos", ariaLabel, density = "default", className = "", testId }) {
1629
+ if (options.length <= 1) return null;
1630
+ return /* @__PURE__ */ jsxs("div", {
1631
+ className: `nb-scope-tabs${density === "compact" ? " nb-scope-tabs--compact" : ""}${className ? ` ${className}` : ""}`,
1632
+ "data-testid": testId,
1633
+ role: "tablist",
1634
+ "aria-label": ariaLabel,
1635
+ children: [/* @__PURE__ */ jsx("button", {
1636
+ type: "button",
1637
+ role: "tab",
1638
+ "aria-selected": selectedKey === null,
1639
+ className: `nb-scope-tabs__tab${selectedKey === null ? " nb-scope-tabs__tab--active" : ""}`,
1640
+ onClick: () => onChange(null),
1641
+ children: allLabel
1642
+ }), options.map((option) => /* @__PURE__ */ jsx("button", {
1643
+ type: "button",
1644
+ role: "tab",
1645
+ "aria-selected": selectedKey === option.key,
1646
+ className: `nb-scope-tabs__tab${selectedKey === option.key ? " nb-scope-tabs__tab--active" : ""}`,
1647
+ onClick: () => onChange(option.key),
1648
+ children: option.label
1649
+ }, option.key))]
1650
+ });
1651
+ }
1652
+ //#endregion
1653
+ //#region packages/ui/OperationCardGrid.tsx
1654
+ function normalizeIcon(icon) {
1655
+ if (icon.startsWith("ph ")) return icon;
1656
+ if (icon.startsWith("ph-")) return `ph ${icon}`;
1657
+ return `ph ph-${icon}`;
1658
+ }
1659
+ function OperationCardGrid({ title, description, operations, className = "", testId }) {
1660
+ return /* @__PURE__ */ jsxs("div", {
1661
+ className: `nb-operation-grid${className ? ` ${className}` : ""}`,
1662
+ "data-testid": testId,
1663
+ children: [(title || description) && /* @__PURE__ */ jsxs("header", {
1664
+ className: "nb-operation-grid__header",
1665
+ children: [title && /* @__PURE__ */ jsx("h3", {
1666
+ className: "nb-operation-grid__title",
1667
+ children: title
1668
+ }), description && /* @__PURE__ */ jsx("p", {
1669
+ className: "nb-operation-grid__intro",
1670
+ children: description
1314
1671
  })]
1315
- }, item.label))
1672
+ }), /* @__PURE__ */ jsx("div", {
1673
+ className: "nb-operation-grid__cards",
1674
+ children: operations.map((operation) => {
1675
+ const accent = operation.accent ?? "default";
1676
+ return /* @__PURE__ */ jsxs("button", {
1677
+ type: "button",
1678
+ className: `nb-operation-card nb-operation-card--${accent}`,
1679
+ "data-testid": operation.testId,
1680
+ onClick: operation.onClick,
1681
+ children: [
1682
+ /* @__PURE__ */ jsx("span", {
1683
+ className: `nb-operation-card__icon nb-operation-card__icon--${accent}`,
1684
+ "aria-hidden": "true",
1685
+ children: /* @__PURE__ */ jsx("i", { className: normalizeIcon(operation.icon) })
1686
+ }),
1687
+ /* @__PURE__ */ jsxs("span", {
1688
+ className: "nb-operation-card__body",
1689
+ children: [/* @__PURE__ */ jsx("span", {
1690
+ className: "nb-operation-card__title",
1691
+ children: operation.title
1692
+ }), operation.description && /* @__PURE__ */ jsx("span", {
1693
+ className: "nb-operation-card__desc",
1694
+ children: operation.description
1695
+ })]
1696
+ }),
1697
+ /* @__PURE__ */ jsx("span", {
1698
+ className: "nb-operation-card__arrow",
1699
+ "aria-hidden": "true",
1700
+ children: /* @__PURE__ */ jsx("i", { className: "ph ph-caret-right" })
1701
+ })
1702
+ ]
1703
+ }, operation.key);
1704
+ })
1705
+ })]
1706
+ });
1707
+ }
1708
+ //#endregion
1709
+ //#region packages/ui/HubPanel.tsx
1710
+ /**
1711
+ * Card shell for feature-hub chrome above a CRUD grid (KPIs, scope tabs, filters).
1712
+ */
1713
+ function HubPanel({ children, variant = "card", className = "", testId }) {
1714
+ return /* @__PURE__ */ jsx("div", {
1715
+ className: `nb-hub-panel${variant === "flush" ? " nb-hub-panel--flush" : ""}${className ? ` ${className}` : ""}`,
1716
+ "data-testid": testId,
1717
+ children
1316
1718
  });
1317
1719
  }
1318
1720
  //#endregion
@@ -2664,4 +3066,4 @@ function Timeline({ variant = "stepper", orientation = "vertical", title, descri
2664
3066
  });
2665
3067
  }
2666
3068
  //#endregion
2667
- export { ACCENT_PRESETS, AppDialog, AppDropdown, AppToolbar, Avatar, Badge, Button, Card, Chip, CollapsibleSection, ConfirmDialog, ContextMenu, DatePicker, DateRangePicker, DensityContext, DensityProvider, Drawer, EN_UI_STRINGS, ES_UI_STRINGS, EmptyState, FeatureGate, FileDropzone, FormField, IconButton, KpiMetricRow, Popover, SelectField, SettingsPanel, Skeleton, StatCard, TextAreaField, TextField, ThemeContext, ThemeProvider, ThemeSwitcher, Timeline, TimelineItem, Toggle, UiStringsProvider, getAvatarHue, getAvatarInitials, useAccentColor, useDensity, useFloatingPanel, useTheme, useUiStrings };
3069
+ export { ACCENT_PRESETS, AppDialog, AppDropdown, AppToolbar, Avatar, Badge, Button, Card, Chip, CollapsibleSection, ConfirmDialog, ContextMenu, DatePicker, DateRangePicker, DensityContext, DensityProvider, Drawer, EN_UI_STRINGS, ES_UI_STRINGS, EmptyState, FeatureGate, FileDropzone, FilterPanel, FormField, HubPanel, IconButton, KpiMetricRow, OperationCardGrid, Popover, ScopeTabs, SearchableAppDropdown, SegmentedControl, SelectField, SettingsPanel, Skeleton, StatCard, TextAreaField, TextField, ThemeContext, ThemeProvider, ThemeSwitcher, Timeline, TimelineItem, Toggle, UiStringsProvider, getAvatarHue, getAvatarInitials, useAccentColor, useDensity, useFloatingPanel, useTheme, useUiStrings };