@nubitio/ui 1.3.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/index.cjs +668 -150
- package/dist/index.d.cts +202 -240
- package/dist/index.d.mts +202 -240
- package/dist/index.mjs +663 -148
- package/dist/style.css +150 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { Menu } from "@base-ui/react/menu";
|
|
|
8
8
|
import { getLocalTimeZone, parseDate, parseTime, today } from "@internationalized/date";
|
|
9
9
|
import { Popover as Popover$2 } from "@base-ui/react/popover";
|
|
10
10
|
import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
|
|
11
|
-
|
|
11
|
+
// packages/ui/Avatar.tsx
|
|
12
12
|
/**
|
|
13
13
|
* 8 semantic hues aligned with the Fluent / @nubitio design palette.
|
|
14
14
|
* Expressed as HSL so the lightness can be adjusted for dark mode via CSS.
|
|
@@ -40,7 +40,7 @@ function getAvatarInitials(owner = "") {
|
|
|
40
40
|
}
|
|
41
41
|
function getAvatarHue(owner = "") {
|
|
42
42
|
let hash = 0;
|
|
43
|
-
for (let i = 0; i < owner.length; i++) hash = hash * 31 + owner.charCodeAt(i) &
|
|
43
|
+
for (let i = 0; i < owner.length; i++) hash = hash * 31 + owner.charCodeAt(i) & 0xfffffff;
|
|
44
44
|
return AVATAR_HUES[Math.abs(hash) % AVATAR_HUES.length];
|
|
45
45
|
}
|
|
46
46
|
const Avatar = ({ owner = "", size, variant = "md", shape = "circle", alt, className }) => {
|
|
@@ -65,13 +65,11 @@ const Avatar = ({ owner = "", size, variant = "md", shape = "circle", alt, class
|
|
|
65
65
|
children: initials
|
|
66
66
|
});
|
|
67
67
|
};
|
|
68
|
-
|
|
69
|
-
//#region packages/ui/OverlayContainer.tsx
|
|
68
|
+
// packages/ui/OverlayContainer.tsx
|
|
70
69
|
/** Keeps nested portals within the modal's focus and accessibility boundary. */
|
|
71
70
|
const OverlayContainerContext = createContext(null);
|
|
72
71
|
const useOverlayContainer = () => useContext(OverlayContainerContext);
|
|
73
|
-
|
|
74
|
-
//#region packages/ui/ModalSurface.tsx
|
|
72
|
+
// packages/ui/ModalSurface.tsx
|
|
75
73
|
/** Shared modal behavior for centered dialogs and side sheets. */
|
|
76
74
|
function ModalSurface({ open, onClose, children, rootClassName, className, style, scrimClassName, scrimLabel, labelledBy, ariaLabel, role = "dialog", keepMounted = false, restoreFocus = true, closeOnEscape = true, initialFocus, closeOnOutsideClick = true }) {
|
|
77
75
|
const parentContainer = useOverlayContainer();
|
|
@@ -131,8 +129,7 @@ function ModalSurface({ open, onClose, children, rootClassName, className, style
|
|
|
131
129
|
})
|
|
132
130
|
});
|
|
133
131
|
}
|
|
134
|
-
|
|
135
|
-
//#region packages/ui/Button.tsx
|
|
132
|
+
// packages/ui/Button.tsx
|
|
136
133
|
const cx$2 = (...values) => values.filter(Boolean).join(" ");
|
|
137
134
|
const Button = forwardRef(function Button({ variant = "secondary", size = "md", fullWidth = false, icon, loading = false, className, children, disabled, ...props }, ref) {
|
|
138
135
|
return /* @__PURE__ */ jsxs("button", {
|
|
@@ -165,8 +162,7 @@ const IconButton = forwardRef(function IconButton({ icon, label, variant = "defa
|
|
|
165
162
|
})
|
|
166
163
|
});
|
|
167
164
|
});
|
|
168
|
-
|
|
169
|
-
//#region packages/ui/UiStrings.tsx
|
|
165
|
+
// packages/ui/UiStrings.tsx
|
|
170
166
|
const EN_UI_STRINGS = {
|
|
171
167
|
close: "Close",
|
|
172
168
|
closeDialog: "Close dialog",
|
|
@@ -237,7 +233,15 @@ const EN_UI_STRINGS = {
|
|
|
237
233
|
redo: "Redo (Ctrl+Y)",
|
|
238
234
|
featureUnavailable: "This feature is not available on your current plan.",
|
|
239
235
|
featureRequiresPlan: "This feature requires the {plan} plan. Upgrade your plan to unlock it.",
|
|
240
|
-
viewPlans: "View plans"
|
|
236
|
+
viewPlans: "View plans",
|
|
237
|
+
treeListFilter: "Filter rows",
|
|
238
|
+
treeListEmpty: "No rows to display",
|
|
239
|
+
treeListExpand: "Expand",
|
|
240
|
+
treeListCollapse: "Collapse",
|
|
241
|
+
treeListSelect: "Select row",
|
|
242
|
+
treeListSelectAll: "Select all visible rows",
|
|
243
|
+
treeListEdit: "Edit",
|
|
244
|
+
treeListMoveFailed: "The row could not be moved."
|
|
241
245
|
};
|
|
242
246
|
const ES_UI_STRINGS = {
|
|
243
247
|
close: "Cerrar",
|
|
@@ -309,7 +313,15 @@ const ES_UI_STRINGS = {
|
|
|
309
313
|
redo: "Rehacer (Ctrl+Y)",
|
|
310
314
|
featureUnavailable: "Esta función no está disponible en tu plan actual.",
|
|
311
315
|
featureRequiresPlan: "Esta función requiere el plan {plan}. Actualiza tu plan para desbloquearla.",
|
|
312
|
-
viewPlans: "Ver planes"
|
|
316
|
+
viewPlans: "Ver planes",
|
|
317
|
+
treeListFilter: "Filtrar filas",
|
|
318
|
+
treeListEmpty: "No hay filas para mostrar",
|
|
319
|
+
treeListExpand: "Expandir",
|
|
320
|
+
treeListCollapse: "Contraer",
|
|
321
|
+
treeListSelect: "Seleccionar fila",
|
|
322
|
+
treeListSelectAll: "Seleccionar todas las filas visibles",
|
|
323
|
+
treeListEdit: "Editar",
|
|
324
|
+
treeListMoveFailed: "No se pudo mover la fila."
|
|
313
325
|
};
|
|
314
326
|
const UiStringsContext = createContext(EN_UI_STRINGS);
|
|
315
327
|
const UiStringsProvider = ({ strings, children }) => {
|
|
@@ -323,8 +335,7 @@ const UiStringsProvider = ({ strings, children }) => {
|
|
|
323
335
|
});
|
|
324
336
|
};
|
|
325
337
|
const useUiStrings = () => useContext(UiStringsContext);
|
|
326
|
-
|
|
327
|
-
//#region packages/ui/AppDialog.tsx
|
|
338
|
+
// packages/ui/AppDialog.tsx
|
|
328
339
|
const formatSize = (value) => {
|
|
329
340
|
if (value === void 0) return void 0;
|
|
330
341
|
return typeof value === "number" ? `${value}px` : value;
|
|
@@ -380,8 +391,7 @@ const AppDialog = ({ visible, open, title, onClose, children, footer, width, max
|
|
|
380
391
|
]
|
|
381
392
|
});
|
|
382
393
|
};
|
|
383
|
-
|
|
384
|
-
//#region packages/ui/ConfirmDialog.tsx
|
|
394
|
+
// packages/ui/ConfirmDialog.tsx
|
|
385
395
|
function ConfirmDialog({ open, title, message, onConfirm, onCancel, confirmLabel, cancelLabel, variant = "warning" }) {
|
|
386
396
|
const strings = useUiStrings();
|
|
387
397
|
const cancelRef = useRef(null);
|
|
@@ -410,8 +420,7 @@ function ConfirmDialog({ open, title, message, onConfirm, onCancel, confirmLabel
|
|
|
410
420
|
})
|
|
411
421
|
});
|
|
412
422
|
}
|
|
413
|
-
|
|
414
|
-
//#region packages/ui/AppToolbar.tsx
|
|
423
|
+
// packages/ui/AppToolbar.tsx
|
|
415
424
|
const AppToolbar = ({ title, additionalToolbarContent, showRefreshButton = true, onRefresh, icon, refreshLabel = "Refresh", children }) => {
|
|
416
425
|
return /* @__PURE__ */ jsxs("div", {
|
|
417
426
|
className: "view-wrapper view-wrapper-dashboard",
|
|
@@ -444,8 +453,7 @@ const AppToolbar = ({ title, additionalToolbarContent, showRefreshButton = true,
|
|
|
444
453
|
}), children]
|
|
445
454
|
});
|
|
446
455
|
};
|
|
447
|
-
|
|
448
|
-
//#region packages/ui/layoutUtils.ts
|
|
456
|
+
// packages/ui/layoutUtils.ts
|
|
449
457
|
function joinClasses(...parts) {
|
|
450
458
|
return parts.filter(Boolean).join(" ");
|
|
451
459
|
}
|
|
@@ -460,8 +468,7 @@ function colSpanClasses(span, spanSm, spanMd, spanLg) {
|
|
|
460
468
|
if (spanLg != null) classes.push(`nb-col--span-lg-${spanLg}`);
|
|
461
469
|
return classes;
|
|
462
470
|
}
|
|
463
|
-
|
|
464
|
-
//#region packages/ui/Card.tsx
|
|
471
|
+
// packages/ui/Card.tsx
|
|
465
472
|
const Card = ({ title, description, variant = "auth", className, children }) => {
|
|
466
473
|
const showHeader = Boolean(title || description);
|
|
467
474
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -481,8 +488,7 @@ const Card = ({ title, description, variant = "auth", className, children }) =>
|
|
|
481
488
|
})
|
|
482
489
|
});
|
|
483
490
|
};
|
|
484
|
-
|
|
485
|
-
//#region packages/ui/FormControls.tsx
|
|
491
|
+
// packages/ui/FormControls.tsx
|
|
486
492
|
const cx$1 = (...values) => values.filter(Boolean).join(" ");
|
|
487
493
|
const FormField = ({ label, error, helpText, children, className, ...props }) => /* @__PURE__ */ jsxs("label", {
|
|
488
494
|
...props,
|
|
@@ -525,8 +531,7 @@ const TextAreaField = forwardRef(function TextAreaField({ className, invalid, ..
|
|
|
525
531
|
className: cx$1("nb-input", "nb-textarea", invalid && "nb-input--invalid", className)
|
|
526
532
|
});
|
|
527
533
|
});
|
|
528
|
-
|
|
529
|
-
//#region packages/ui/FileDropzone.tsx
|
|
534
|
+
// packages/ui/FileDropzone.tsx
|
|
530
535
|
function cx(...values) {
|
|
531
536
|
return values.filter(Boolean).join(" ");
|
|
532
537
|
}
|
|
@@ -666,8 +671,7 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
|
|
|
666
671
|
})]
|
|
667
672
|
});
|
|
668
673
|
}
|
|
669
|
-
|
|
670
|
-
//#region packages/ui/AppDropdown.tsx
|
|
674
|
+
// packages/ui/AppDropdown.tsx
|
|
671
675
|
function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange, triggerIcon }) {
|
|
672
676
|
const generatedId = useId();
|
|
673
677
|
const id = idProp ?? generatedId;
|
|
@@ -806,8 +810,7 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
|
|
|
806
810
|
})
|
|
807
811
|
});
|
|
808
812
|
}
|
|
809
|
-
|
|
810
|
-
//#region packages/ui/useComboboxOptions.ts
|
|
813
|
+
// packages/ui/useComboboxOptions.ts
|
|
811
814
|
function mergeOptions(...groups) {
|
|
812
815
|
const map = /* @__PURE__ */ new Map();
|
|
813
816
|
for (const group of groups) for (const option of group) map.set(option.value, option);
|
|
@@ -944,8 +947,7 @@ function useComboboxOptions({ options, selected, loadOptions, open, query, debou
|
|
|
944
947
|
retry: () => setRevision((previous) => previous + 1)
|
|
945
948
|
};
|
|
946
949
|
}
|
|
947
|
-
|
|
948
|
-
//#region packages/ui/Combobox.tsx
|
|
950
|
+
// packages/ui/Combobox.tsx
|
|
949
951
|
const Combobox = forwardRef(function Combobox(props, ref) {
|
|
950
952
|
return /* @__PURE__ */ jsx(SelectionCombobox, {
|
|
951
953
|
...props,
|
|
@@ -1170,8 +1172,7 @@ function ComboboxClear({ label, disabled, multiple }) {
|
|
|
1170
1172
|
})
|
|
1171
1173
|
});
|
|
1172
1174
|
}
|
|
1173
|
-
|
|
1174
|
-
//#region packages/ui/SearchableAppDropdown.tsx
|
|
1175
|
+
// packages/ui/SearchableAppDropdown.tsx
|
|
1175
1176
|
const toOption = (option) => ({
|
|
1176
1177
|
value: option.value,
|
|
1177
1178
|
label: option.selectedLabel ?? option.label,
|
|
@@ -1222,8 +1223,7 @@ function SearchableAppDropdown({ options = [], searchable = true, searchPlacehol
|
|
|
1222
1223
|
loadingMessage: loadingLabel
|
|
1223
1224
|
});
|
|
1224
1225
|
}
|
|
1225
|
-
|
|
1226
|
-
//#region packages/ui/theme/ThemeProvider.tsx
|
|
1226
|
+
// packages/ui/theme/ThemeProvider.tsx
|
|
1227
1227
|
const ThemeContext = React.createContext(null);
|
|
1228
1228
|
function useTheme() {
|
|
1229
1229
|
const ctx = useContext(ThemeContext);
|
|
@@ -1345,8 +1345,7 @@ const ThemeProvider = ({ storageKey = "nb-theme", themePrefix = "nb-theme-", bas
|
|
|
1345
1345
|
children
|
|
1346
1346
|
});
|
|
1347
1347
|
};
|
|
1348
|
-
|
|
1349
|
-
//#region packages/ui/theme/ThemeSwitcher.tsx
|
|
1348
|
+
// packages/ui/theme/ThemeSwitcher.tsx
|
|
1350
1349
|
const iconByMode = {
|
|
1351
1350
|
light: "ph ph-sun",
|
|
1352
1351
|
dark: "ph ph-moon",
|
|
@@ -1370,8 +1369,7 @@ const ThemeSwitcher = ({ labelByMode: overrides } = {}) => {
|
|
|
1370
1369
|
onClick: switchTheme
|
|
1371
1370
|
}) });
|
|
1372
1371
|
};
|
|
1373
|
-
|
|
1374
|
-
//#region packages/ui/theme/DensityProvider.tsx
|
|
1372
|
+
// packages/ui/theme/DensityProvider.tsx
|
|
1375
1373
|
const DensityContext = createContext(null);
|
|
1376
1374
|
function useDensity() {
|
|
1377
1375
|
const ctx = useContext(DensityContext);
|
|
@@ -1399,8 +1397,7 @@ const DensityProvider = ({ children }) => {
|
|
|
1399
1397
|
children
|
|
1400
1398
|
});
|
|
1401
1399
|
};
|
|
1402
|
-
|
|
1403
|
-
//#region packages/ui/theme/useAccentColor.ts
|
|
1400
|
+
// packages/ui/theme/useAccentColor.ts
|
|
1404
1401
|
const ACCENT_PRESETS = [
|
|
1405
1402
|
{
|
|
1406
1403
|
label: "Azure",
|
|
@@ -1452,8 +1449,7 @@ function useAccentColor() {
|
|
|
1452
1449
|
presets: ACCENT_PRESETS
|
|
1453
1450
|
};
|
|
1454
1451
|
}
|
|
1455
|
-
|
|
1456
|
-
//#region packages/ui/SettingsPanel.tsx
|
|
1452
|
+
// packages/ui/SettingsPanel.tsx
|
|
1457
1453
|
const SettingsPanel = ({ onClose: _onClose }) => {
|
|
1458
1454
|
const strings = useUiStrings();
|
|
1459
1455
|
const { density, toggleDensity } = useDensity();
|
|
@@ -1516,8 +1512,7 @@ const SettingsPanel = ({ onClose: _onClose }) => {
|
|
|
1516
1512
|
]
|
|
1517
1513
|
});
|
|
1518
1514
|
};
|
|
1519
|
-
|
|
1520
|
-
//#region packages/ui/Badge.tsx
|
|
1515
|
+
// packages/ui/Badge.tsx
|
|
1521
1516
|
const Badge = ({ variant = "primary", size = "md", outlined = false, pill = true, dot = false, children, className }) => {
|
|
1522
1517
|
const classes = [
|
|
1523
1518
|
"nb-badge",
|
|
@@ -1533,8 +1528,7 @@ const Badge = ({ variant = "primary", size = "md", outlined = false, pill = true
|
|
|
1533
1528
|
children: dot ? null : children
|
|
1534
1529
|
});
|
|
1535
1530
|
};
|
|
1536
|
-
|
|
1537
|
-
//#region packages/ui/FeatureGate.tsx
|
|
1531
|
+
// packages/ui/FeatureGate.tsx
|
|
1538
1532
|
function FeatureGate({ featureKey, children, enabled = false, behavior = "lock", planBadge = "Pro", upgradeMessage, upgradeUrl = "/settings", lockTooltip }) {
|
|
1539
1533
|
const strings = useUiStrings();
|
|
1540
1534
|
const tooltip = lockTooltip ?? strings.featureUnavailable;
|
|
@@ -1608,8 +1602,7 @@ function UpgradeGate({ planBadge, upgradeMessage, upgradeUrl, children }) {
|
|
|
1608
1602
|
]
|
|
1609
1603
|
});
|
|
1610
1604
|
}
|
|
1611
|
-
|
|
1612
|
-
//#region packages/ui/Skeleton.tsx
|
|
1605
|
+
// packages/ui/Skeleton.tsx
|
|
1613
1606
|
const fmtSize = (v) => v === void 0 ? void 0 : typeof v === "number" ? `${v}px` : v;
|
|
1614
1607
|
const Skeleton = ({ variant = "rect", width, height, lines = 1, className }) => {
|
|
1615
1608
|
const base = [
|
|
@@ -1634,8 +1627,7 @@ const Skeleton = ({ variant = "rect", width, height, lines = 1, className }) =>
|
|
|
1634
1627
|
"aria-hidden": "true"
|
|
1635
1628
|
});
|
|
1636
1629
|
};
|
|
1637
|
-
|
|
1638
|
-
//#region packages/ui/EmptyState.tsx
|
|
1630
|
+
// packages/ui/EmptyState.tsx
|
|
1639
1631
|
const DEFAULT_ICONS = {
|
|
1640
1632
|
default: "folder-open",
|
|
1641
1633
|
danger: "warning-circle",
|
|
@@ -1678,8 +1670,7 @@ const EmptyState = ({ icon, illustration, variant = "default", title, descriptio
|
|
|
1678
1670
|
]
|
|
1679
1671
|
});
|
|
1680
1672
|
};
|
|
1681
|
-
|
|
1682
|
-
//#region packages/ui/Chip.tsx
|
|
1673
|
+
// packages/ui/Chip.tsx
|
|
1683
1674
|
/**
|
|
1684
1675
|
* Pill-shaped filter/tag chip. Stateless — caller controls `active`.
|
|
1685
1676
|
* Use for category filters, tag lists, and multi-select inputs.
|
|
@@ -1706,8 +1697,7 @@ const Chip = ({ label, active = false, count, icon, size = "md", disabled = fals
|
|
|
1706
1697
|
]
|
|
1707
1698
|
});
|
|
1708
1699
|
};
|
|
1709
|
-
|
|
1710
|
-
//#region packages/ui/Toggle.tsx
|
|
1700
|
+
// packages/ui/Toggle.tsx
|
|
1711
1701
|
/**
|
|
1712
1702
|
* Accessible toggle switch. Always controlled — pass `checked` + `onChange`.
|
|
1713
1703
|
* Renders a visually-hidden `<input type="checkbox">` with a custom track.
|
|
@@ -1737,8 +1727,7 @@ const Toggle = ({ checked, onChange, label, size = "md", disabled = false, "aria
|
|
|
1737
1727
|
children: [label && /* @__PURE__ */ jsx("span", { children: label }), input]
|
|
1738
1728
|
});
|
|
1739
1729
|
};
|
|
1740
|
-
|
|
1741
|
-
//#region packages/ui/ContextMenu.tsx
|
|
1730
|
+
// packages/ui/ContextMenu.tsx
|
|
1742
1731
|
const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones", align = "right", className = "" }) => {
|
|
1743
1732
|
const container = useOverlayContainer();
|
|
1744
1733
|
const triggerRef = useRef(null);
|
|
@@ -1786,8 +1775,7 @@ const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones"
|
|
|
1786
1775
|
})
|
|
1787
1776
|
});
|
|
1788
1777
|
};
|
|
1789
|
-
|
|
1790
|
-
//#region packages/ui/StatCard.tsx
|
|
1778
|
+
// packages/ui/StatCard.tsx
|
|
1791
1779
|
/**
|
|
1792
1780
|
* General-purpose analytics / dashboard card.
|
|
1793
1781
|
* Replaces the legacy `shared/ui/card-analytics/CardAnalytics` component.
|
|
@@ -1812,8 +1800,7 @@ const StatCard = ({ title, headerExtra, menuVisible = true, menuItems = [{ label
|
|
|
1812
1800
|
children
|
|
1813
1801
|
})]
|
|
1814
1802
|
});
|
|
1815
|
-
|
|
1816
|
-
//#region packages/ui/KpiMetricRow.tsx
|
|
1803
|
+
// packages/ui/KpiMetricRow.tsx
|
|
1817
1804
|
function normalizeIcon$1(icon) {
|
|
1818
1805
|
if (!icon) return void 0;
|
|
1819
1806
|
if (icon.startsWith("ph ")) return icon;
|
|
@@ -1856,8 +1843,7 @@ function KpiMetricRow({ items, className = "", layout = "cards", density = "defa
|
|
|
1856
1843
|
})
|
|
1857
1844
|
});
|
|
1858
1845
|
}
|
|
1859
|
-
|
|
1860
|
-
//#region packages/ui/SegmentedControl.tsx
|
|
1846
|
+
// packages/ui/SegmentedControl.tsx
|
|
1861
1847
|
function SegmentedControl({ options, value, onChange, ariaLabel, className = "", size = "md" }) {
|
|
1862
1848
|
if (options.length === 0) return null;
|
|
1863
1849
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -1877,8 +1863,7 @@ function SegmentedControl({ options, value, onChange, ariaLabel, className = "",
|
|
|
1877
1863
|
})
|
|
1878
1864
|
});
|
|
1879
1865
|
}
|
|
1880
|
-
|
|
1881
|
-
//#region packages/ui/FilterPanel.tsx
|
|
1866
|
+
// packages/ui/FilterPanel.tsx
|
|
1882
1867
|
function FilterPanel({ category, status, layout = "stacked", density = "default", className = "", testId }) {
|
|
1883
1868
|
const [search, setSearch] = useState("");
|
|
1884
1869
|
const threshold = category.searchThreshold ?? 10;
|
|
@@ -1987,8 +1972,7 @@ function FilterPanel({ category, status, layout = "stacked", density = "default"
|
|
|
1987
1972
|
})]
|
|
1988
1973
|
});
|
|
1989
1974
|
}
|
|
1990
|
-
|
|
1991
|
-
//#region packages/ui/ScopeTabs.tsx
|
|
1975
|
+
// packages/ui/ScopeTabs.tsx
|
|
1992
1976
|
/**
|
|
1993
1977
|
* Pill tabs for scoping a list view (warehouse, branch, period, etc.).
|
|
1994
1978
|
* Hides itself when there is at most one scope option.
|
|
@@ -2017,8 +2001,7 @@ function ScopeTabs({ options, selectedKey, onChange, allLabel = "Todos", ariaLab
|
|
|
2017
2001
|
}, option.key))]
|
|
2018
2002
|
});
|
|
2019
2003
|
}
|
|
2020
|
-
|
|
2021
|
-
//#region packages/ui/OperationCardGrid.tsx
|
|
2004
|
+
// packages/ui/OperationCardGrid.tsx
|
|
2022
2005
|
function normalizeIcon(icon) {
|
|
2023
2006
|
if (icon.startsWith("ph ")) return icon;
|
|
2024
2007
|
if (icon.startsWith("ph-")) return `ph ${icon}`;
|
|
@@ -2073,8 +2056,7 @@ function OperationCardGrid({ title, description, operations, className = "", tes
|
|
|
2073
2056
|
})]
|
|
2074
2057
|
});
|
|
2075
2058
|
}
|
|
2076
|
-
|
|
2077
|
-
//#region packages/ui/HubPanel.tsx
|
|
2059
|
+
// packages/ui/HubPanel.tsx
|
|
2078
2060
|
/**
|
|
2079
2061
|
* Card shell for feature-hub chrome above a CRUD grid (KPIs, scope tabs, filters).
|
|
2080
2062
|
*/
|
|
@@ -2085,8 +2067,7 @@ function HubPanel({ children, variant = "card", className = "", testId }) {
|
|
|
2085
2067
|
children
|
|
2086
2068
|
});
|
|
2087
2069
|
}
|
|
2088
|
-
|
|
2089
|
-
//#region packages/ui/CollapsibleSection.tsx
|
|
2070
|
+
// packages/ui/CollapsibleSection.tsx
|
|
2090
2071
|
/**
|
|
2091
2072
|
* Accessible collapsible section with a labelled header trigger.
|
|
2092
2073
|
*
|
|
@@ -2141,8 +2122,7 @@ const CollapsibleSection = ({ label, icon, open, onToggle, children, trailing, c
|
|
|
2141
2122
|
})]
|
|
2142
2123
|
});
|
|
2143
2124
|
};
|
|
2144
|
-
|
|
2145
|
-
//#region packages/ui/CalendarContent.tsx
|
|
2125
|
+
// packages/ui/CalendarContent.tsx
|
|
2146
2126
|
/** Shared presentation; React Aria owns navigation, focus and range preview. */
|
|
2147
2127
|
function CalendarContent() {
|
|
2148
2128
|
const strings = useUiStrings();
|
|
@@ -2211,8 +2191,7 @@ function CalendarDialog({ id, ariaLabel, children }) {
|
|
|
2211
2191
|
children
|
|
2212
2192
|
});
|
|
2213
2193
|
}
|
|
2214
|
-
|
|
2215
|
-
//#region packages/ui/dateValues.ts
|
|
2194
|
+
// packages/ui/dateValues.ts
|
|
2216
2195
|
const getDateLocale = (locale) => locale || typeof document !== "undefined" && document.documentElement.lang || typeof navigator !== "undefined" && navigator.language || "en-US";
|
|
2217
2196
|
const calendarDate = (value) => {
|
|
2218
2197
|
if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
|
|
@@ -2267,8 +2246,7 @@ const parseDisplayDate = (text, locale) => {
|
|
|
2267
2246
|
const iso = `${fields.year}-${fields.month?.padStart(2, "0")}-${fields.day?.padStart(2, "0")}`;
|
|
2268
2247
|
return calendarDate(iso) ? iso : null;
|
|
2269
2248
|
};
|
|
2270
|
-
|
|
2271
|
-
//#region packages/ui/DateTextInput.tsx
|
|
2249
|
+
// packages/ui/DateTextInput.tsx
|
|
2272
2250
|
/** Keeps the real input/ref/ID contract used by CRUD forms. */
|
|
2273
2251
|
const DateTextInput = forwardRef(function DateTextInput({ value, locale, min, max, onChange, onOpen, onBlur, onKeyDown, ...props }, ref) {
|
|
2274
2252
|
const [draft, setDraft] = useState(null);
|
|
@@ -2311,8 +2289,7 @@ const DateTextInput = forwardRef(function DateTextInput({ value, locale, min, ma
|
|
|
2311
2289
|
}
|
|
2312
2290
|
});
|
|
2313
2291
|
});
|
|
2314
|
-
|
|
2315
|
-
//#region packages/ui/useCalendarPopover.ts
|
|
2292
|
+
// packages/ui/useCalendarPopover.ts
|
|
2316
2293
|
/** Bridge focus restoration between React Aria's popup and a parent Base UI modal. */
|
|
2317
2294
|
function useCalendarPopover() {
|
|
2318
2295
|
const container = useOverlayContainer();
|
|
@@ -2353,8 +2330,7 @@ function useCalendarPopover() {
|
|
|
2353
2330
|
}, [container])
|
|
2354
2331
|
};
|
|
2355
2332
|
}
|
|
2356
|
-
|
|
2357
|
-
//#region packages/ui/DatePicker.tsx
|
|
2333
|
+
// packages/ui/DatePicker.tsx
|
|
2358
2334
|
const DatePicker = forwardRef(function DatePicker({ id, name, value, placeholder, disabled = false, readOnly = false, required = false, invalid = false, clearable = true, locale, min, max, className, ariaLabel, onChange, onBlur }, ref) {
|
|
2359
2335
|
const generatedId = useId();
|
|
2360
2336
|
const inputId = id ?? generatedId;
|
|
@@ -2480,8 +2456,7 @@ const DatePicker = forwardRef(function DatePicker({ id, name, value, placeholder
|
|
|
2480
2456
|
})
|
|
2481
2457
|
});
|
|
2482
2458
|
});
|
|
2483
|
-
|
|
2484
|
-
//#region packages/ui/DateRangePicker.tsx
|
|
2459
|
+
// packages/ui/DateRangePicker.tsx
|
|
2485
2460
|
function DateRangePicker({ startValue, endValue, placeholder, disabled = false, clearable = true, readOnly = false, required = false, invalid = false, locale, min, max, className, ariaLabel, onChange, onBlur }) {
|
|
2486
2461
|
const { container, groupRef, panelRef, open, setOpen } = useCalendarPopover();
|
|
2487
2462
|
const strings = useUiStrings();
|
|
@@ -2612,8 +2587,7 @@ function DateRangePicker({ startValue, endValue, placeholder, disabled = false,
|
|
|
2612
2587
|
})
|
|
2613
2588
|
});
|
|
2614
2589
|
}
|
|
2615
|
-
|
|
2616
|
-
//#region packages/ui/Popover.tsx
|
|
2590
|
+
// packages/ui/Popover.tsx
|
|
2617
2591
|
const Popover = ({ trigger, panel, align = "end", ariaLabel, className }) => {
|
|
2618
2592
|
const [open, setOpen] = useState(false);
|
|
2619
2593
|
const triggerRef = useRef(null);
|
|
@@ -2673,8 +2647,7 @@ const Popover = ({ trigger, panel, align = "end", ariaLabel, className }) => {
|
|
|
2673
2647
|
})
|
|
2674
2648
|
});
|
|
2675
2649
|
};
|
|
2676
|
-
|
|
2677
|
-
//#region packages/ui/useFloatingPanel.ts
|
|
2650
|
+
// packages/ui/useFloatingPanel.ts
|
|
2678
2651
|
/** Style applied to an anchored panel before its first position is computed. */
|
|
2679
2652
|
const HIDDEN_PANEL_STYLE = {
|
|
2680
2653
|
position: "fixed",
|
|
@@ -2775,8 +2748,7 @@ function useFloatingPanel(options = {}) {
|
|
|
2775
2748
|
panelStyle
|
|
2776
2749
|
};
|
|
2777
2750
|
}
|
|
2778
|
-
|
|
2779
|
-
//#region packages/ui/Drawer.tsx
|
|
2751
|
+
// packages/ui/Drawer.tsx
|
|
2780
2752
|
const formatWidth = (value) => {
|
|
2781
2753
|
if (value === void 0) return void 0;
|
|
2782
2754
|
return typeof value === "number" ? `${value}px` : value;
|
|
@@ -2829,8 +2801,7 @@ const Drawer = ({ isOpen, busy = false, onClose, title, width, side = "right", s
|
|
|
2829
2801
|
]
|
|
2830
2802
|
});
|
|
2831
2803
|
};
|
|
2832
|
-
|
|
2833
|
-
//#region packages/ui/Timeline.tsx
|
|
2804
|
+
// packages/ui/Timeline.tsx
|
|
2834
2805
|
const TimelineVariantContext = createContext("stepper");
|
|
2835
2806
|
function useTimelineVariant() {
|
|
2836
2807
|
return useContext(TimelineVariantContext);
|
|
@@ -2926,8 +2897,7 @@ function Timeline({ variant = "stepper", orientation = "vertical", title, descri
|
|
|
2926
2897
|
})
|
|
2927
2898
|
});
|
|
2928
2899
|
}
|
|
2929
|
-
|
|
2930
|
-
//#region packages/ui/Page.tsx
|
|
2900
|
+
// packages/ui/Page.tsx
|
|
2931
2901
|
function Page({ children, fill, wide, narrow, gap = 5, className, ...props }) {
|
|
2932
2902
|
return /* @__PURE__ */ jsx("div", {
|
|
2933
2903
|
className: joinClasses("nb-page", fill && "nb-page--fill", wide && "nb-page--wide", narrow && "nb-page--narrow", gapClass("nb-page", gap), className),
|
|
@@ -2935,8 +2905,7 @@ function Page({ children, fill, wide, narrow, gap = 5, className, ...props }) {
|
|
|
2935
2905
|
children
|
|
2936
2906
|
});
|
|
2937
2907
|
}
|
|
2938
|
-
|
|
2939
|
-
//#region packages/ui/PageHeader.tsx
|
|
2908
|
+
// packages/ui/PageHeader.tsx
|
|
2940
2909
|
function PageHeader({ title, subtitle, metadata, breadcrumb, breadcrumbSlot, badge, actions, className }) {
|
|
2941
2910
|
const breadcrumbNode = breadcrumbSlot ?? (breadcrumb ? /* @__PURE__ */ jsxs("a", {
|
|
2942
2911
|
href: breadcrumb.href,
|
|
@@ -2975,8 +2944,7 @@ function PageHeader({ title, subtitle, metadata, breadcrumb, breadcrumbSlot, bad
|
|
|
2975
2944
|
})]
|
|
2976
2945
|
});
|
|
2977
2946
|
}
|
|
2978
|
-
|
|
2979
|
-
//#region packages/ui/Stack.tsx
|
|
2947
|
+
// packages/ui/Stack.tsx
|
|
2980
2948
|
function Stack({ children, gap = 4, align, justify, fill, className, ...props }) {
|
|
2981
2949
|
return /* @__PURE__ */ jsx("div", {
|
|
2982
2950
|
className: joinClasses("nb-stack", gapClass("nb-stack", gap), align && `nb-stack--align-${align}`, justify && `nb-stack--justify-${justify}`, fill && "nb-stack--fill", className),
|
|
@@ -2984,8 +2952,7 @@ function Stack({ children, gap = 4, align, justify, fill, className, ...props })
|
|
|
2984
2952
|
children
|
|
2985
2953
|
});
|
|
2986
2954
|
}
|
|
2987
|
-
|
|
2988
|
-
//#region packages/ui/Row.tsx
|
|
2955
|
+
// packages/ui/Row.tsx
|
|
2989
2956
|
function Row({ children, gap = 2, align, justify, wrap, fill, className, ...props }) {
|
|
2990
2957
|
return /* @__PURE__ */ jsx("div", {
|
|
2991
2958
|
className: joinClasses("nb-row", gapClass("nb-row", gap), align && `nb-row--align-${align}`, justify && `nb-row--justify-${justify}`, wrap && "nb-row--wrap", fill && "nb-row--fill", className),
|
|
@@ -2993,8 +2960,7 @@ function Row({ children, gap = 2, align, justify, wrap, fill, className, ...prop
|
|
|
2993
2960
|
children
|
|
2994
2961
|
});
|
|
2995
2962
|
}
|
|
2996
|
-
|
|
2997
|
-
//#region packages/ui/Cluster.tsx
|
|
2963
|
+
// packages/ui/Cluster.tsx
|
|
2998
2964
|
/** Inline flex row that wraps — ideal for button groups and filter actions. */
|
|
2999
2965
|
function Cluster({ children, gap = 2, className, ...props }) {
|
|
3000
2966
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -3003,8 +2969,7 @@ function Cluster({ children, gap = 2, className, ...props }) {
|
|
|
3003
2969
|
children
|
|
3004
2970
|
});
|
|
3005
2971
|
}
|
|
3006
|
-
|
|
3007
|
-
//#region packages/ui/Grid.tsx
|
|
2972
|
+
// packages/ui/Grid.tsx
|
|
3008
2973
|
function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, style, ...props }) {
|
|
3009
2974
|
const gridStyle = {
|
|
3010
2975
|
...style,
|
|
@@ -3018,8 +2983,7 @@ function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, styl
|
|
|
3018
2983
|
children
|
|
3019
2984
|
});
|
|
3020
2985
|
}
|
|
3021
|
-
|
|
3022
|
-
//#region packages/ui/Col.tsx
|
|
2986
|
+
// packages/ui/Col.tsx
|
|
3023
2987
|
function Col({ children, span, spanSm, spanMd, spanLg, fullWidth, className, ...props }) {
|
|
3024
2988
|
return /* @__PURE__ */ jsx("div", {
|
|
3025
2989
|
className: joinClasses(...colSpanClasses(span, spanSm, spanMd, spanLg), fullWidth && "nb-span-full", className),
|
|
@@ -3027,8 +2991,7 @@ function Col({ children, span, spanSm, spanMd, spanLg, fullWidth, className, ...
|
|
|
3027
2991
|
children
|
|
3028
2992
|
});
|
|
3029
2993
|
}
|
|
3030
|
-
|
|
3031
|
-
//#region packages/ui/Section.tsx
|
|
2994
|
+
// packages/ui/Section.tsx
|
|
3032
2995
|
function Section({ title, children, className, variant = "label" }) {
|
|
3033
2996
|
return /* @__PURE__ */ jsxs("section", {
|
|
3034
2997
|
className: joinClasses("nb-section", variant === "panel" && "nb-section--panel", className),
|
|
@@ -3038,8 +3001,7 @@ function Section({ title, children, className, variant = "label" }) {
|
|
|
3038
3001
|
}), children]
|
|
3039
3002
|
});
|
|
3040
3003
|
}
|
|
3041
|
-
|
|
3042
|
-
//#region packages/ui/FormLayout.tsx
|
|
3004
|
+
// packages/ui/FormLayout.tsx
|
|
3043
3005
|
function FormLayout({ children, variant = "stack", minColWidth, className, style, ...props }) {
|
|
3044
3006
|
const formStyle = {
|
|
3045
3007
|
...style,
|
|
@@ -3052,16 +3014,14 @@ function FormLayout({ children, variant = "stack", minColWidth, className, style
|
|
|
3052
3014
|
children
|
|
3053
3015
|
});
|
|
3054
3016
|
}
|
|
3055
|
-
|
|
3056
|
-
//#region packages/ui/FormActions.tsx
|
|
3017
|
+
// packages/ui/FormActions.tsx
|
|
3057
3018
|
function FormActions({ children, className }) {
|
|
3058
3019
|
return /* @__PURE__ */ jsx("div", {
|
|
3059
3020
|
className: joinClasses("nb-form-actions", className),
|
|
3060
3021
|
children
|
|
3061
3022
|
});
|
|
3062
3023
|
}
|
|
3063
|
-
|
|
3064
|
-
//#region packages/ui/Alert.tsx
|
|
3024
|
+
// packages/ui/Alert.tsx
|
|
3065
3025
|
const ICONS = {
|
|
3066
3026
|
danger: "ph-warning-circle",
|
|
3067
3027
|
warning: "ph-warning",
|
|
@@ -3077,8 +3037,7 @@ function Alert({ tone = "info", children, className }) {
|
|
|
3077
3037
|
}), /* @__PURE__ */ jsx("span", { children })]
|
|
3078
3038
|
});
|
|
3079
3039
|
}
|
|
3080
|
-
|
|
3081
|
-
//#region packages/ui/DescriptionList.tsx
|
|
3040
|
+
// packages/ui/DescriptionList.tsx
|
|
3082
3041
|
function DescriptionList({ items, className }) {
|
|
3083
3042
|
return /* @__PURE__ */ jsx("dl", {
|
|
3084
3043
|
className: joinClasses("nb-description-list", className),
|
|
@@ -3088,16 +3047,14 @@ function DescriptionList({ items, className }) {
|
|
|
3088
3047
|
}, item.term))
|
|
3089
3048
|
});
|
|
3090
3049
|
}
|
|
3091
|
-
|
|
3092
|
-
//#region packages/ui/Code.tsx
|
|
3050
|
+
// packages/ui/Code.tsx
|
|
3093
3051
|
function Code({ children, className }) {
|
|
3094
3052
|
return /* @__PURE__ */ jsx("code", {
|
|
3095
3053
|
className: joinClasses("nb-code", className),
|
|
3096
3054
|
children
|
|
3097
3055
|
});
|
|
3098
3056
|
}
|
|
3099
|
-
|
|
3100
|
-
//#region packages/ui/Text.tsx
|
|
3057
|
+
// packages/ui/Text.tsx
|
|
3101
3058
|
function Text({ children, tone = "default", as: Tag = "span", className, ...props }) {
|
|
3102
3059
|
return /* @__PURE__ */ jsx(Tag, {
|
|
3103
3060
|
className: joinClasses(tone === "muted" && "nb-text-muted", className),
|
|
@@ -3105,8 +3062,7 @@ function Text({ children, tone = "default", as: Tag = "span", className, ...prop
|
|
|
3105
3062
|
children
|
|
3106
3063
|
});
|
|
3107
3064
|
}
|
|
3108
|
-
|
|
3109
|
-
//#region packages/ui/Pagination.tsx
|
|
3065
|
+
// packages/ui/Pagination.tsx
|
|
3110
3066
|
function Pagination({ page, totalPages, onPageChange, ariaLabel, maxVisible = 7, className }) {
|
|
3111
3067
|
const strings = useUiStrings();
|
|
3112
3068
|
if (totalPages <= 1) return null;
|
|
@@ -3146,8 +3102,7 @@ function Pagination({ page, totalPages, onPageChange, ariaLabel, maxVisible = 7,
|
|
|
3146
3102
|
]
|
|
3147
3103
|
});
|
|
3148
3104
|
}
|
|
3149
|
-
|
|
3150
|
-
//#region packages/ui/RowActions.tsx
|
|
3105
|
+
// packages/ui/RowActions.tsx
|
|
3151
3106
|
/** Context menu preset for table row overflow actions. */
|
|
3152
3107
|
function RowActions({ items, triggerLabel, align = "right", className }) {
|
|
3153
3108
|
const strings = useUiStrings();
|
|
@@ -3160,8 +3115,7 @@ function RowActions({ items, triggerLabel, align = "right", className }) {
|
|
|
3160
3115
|
visible: true
|
|
3161
3116
|
});
|
|
3162
3117
|
}
|
|
3163
|
-
|
|
3164
|
-
//#region packages/ui/DataTable.tsx
|
|
3118
|
+
// packages/ui/DataTable.tsx
|
|
3165
3119
|
function alignClass(align) {
|
|
3166
3120
|
if (align === "right") return "nb-data-table__cell--num";
|
|
3167
3121
|
if (align === "center") return "nb-data-table__cell--center";
|
|
@@ -3205,8 +3159,7 @@ function DataTable({ columns, rows, getRowKey, emptyMessage, fill, variant = "de
|
|
|
3205
3159
|
})
|
|
3206
3160
|
}), pagination && /* @__PURE__ */ jsx(Pagination, { ...pagination })] });
|
|
3207
3161
|
}
|
|
3208
|
-
|
|
3209
|
-
//#region packages/ui/useConfirm.tsx
|
|
3162
|
+
// packages/ui/useConfirm.tsx
|
|
3210
3163
|
function useConfirm() {
|
|
3211
3164
|
const strings = useUiStrings();
|
|
3212
3165
|
const [pending, setPending] = useState(null);
|
|
@@ -3233,8 +3186,7 @@ function useConfirm() {
|
|
|
3233
3186
|
ConfirmHost
|
|
3234
3187
|
};
|
|
3235
3188
|
}
|
|
3236
|
-
|
|
3237
|
-
//#region packages/ui/Checkbox.tsx
|
|
3189
|
+
// packages/ui/Checkbox.tsx
|
|
3238
3190
|
/** Native checkbox, including the mixed state used by bulk selection. */
|
|
3239
3191
|
const Checkbox = forwardRef(function Checkbox({ label, indeterminate = false, invalid = false, id, className, ...props }, ref) {
|
|
3240
3192
|
const generatedId = useId();
|
|
@@ -3257,8 +3209,7 @@ const Checkbox = forwardRef(function Checkbox({ label, indeterminate = false, in
|
|
|
3257
3209
|
}), label && /* @__PURE__ */ jsx("span", { children: label })]
|
|
3258
3210
|
});
|
|
3259
3211
|
});
|
|
3260
|
-
|
|
3261
|
-
//#region packages/ui/RadioGroup.tsx
|
|
3212
|
+
// packages/ui/RadioGroup.tsx
|
|
3262
3213
|
/** Native radios share a name for browser keyboard navigation and form submission. */
|
|
3263
3214
|
function RadioGroup({ label, name, value, options, onChange, orientation = "vertical", required, invalid = false, disabled, className, ...props }) {
|
|
3264
3215
|
const generatedName = useId();
|
|
@@ -3284,8 +3235,7 @@ function RadioGroup({ label, name, value, options, onChange, orientation = "vert
|
|
|
3284
3235
|
})]
|
|
3285
3236
|
});
|
|
3286
3237
|
}
|
|
3287
|
-
|
|
3288
|
-
//#region packages/ui/Tabs.tsx
|
|
3238
|
+
// packages/ui/Tabs.tsx
|
|
3289
3239
|
function Tabs({ items, value, onChange, "aria-label": ariaLabel, orientation = "horizontal", activationMode = "automatic", keepMounted = false, className }) {
|
|
3290
3240
|
const id = useId();
|
|
3291
3241
|
const listRef = useRef(null);
|
|
@@ -3341,8 +3291,7 @@ function Tabs({ items, value, onChange, "aria-label": ariaLabel, orientation = "
|
|
|
3341
3291
|
}, item.value))]
|
|
3342
3292
|
});
|
|
3343
3293
|
}
|
|
3344
|
-
|
|
3345
|
-
//#region packages/ui/Spinner.tsx
|
|
3294
|
+
// packages/ui/Spinner.tsx
|
|
3346
3295
|
function Spinner({ label, size = "md", className, ...props }) {
|
|
3347
3296
|
return /* @__PURE__ */ jsx("span", {
|
|
3348
3297
|
...props,
|
|
@@ -3352,8 +3301,7 @@ function Spinner({ label, size = "md", className, ...props }) {
|
|
|
3352
3301
|
"aria-hidden": label ? void 0 : true
|
|
3353
3302
|
});
|
|
3354
3303
|
}
|
|
3355
|
-
|
|
3356
|
-
//#region packages/ui/Progress.tsx
|
|
3304
|
+
// packages/ui/Progress.tsx
|
|
3357
3305
|
/** Omit value for indeterminate progress; max defaults to 100. */
|
|
3358
3306
|
function Progress({ label, id, max = 100, className, ...props }) {
|
|
3359
3307
|
const generatedId = useId();
|
|
@@ -3371,8 +3319,7 @@ function Progress({ label, id, max = 100, className, ...props }) {
|
|
|
3371
3319
|
})]
|
|
3372
3320
|
});
|
|
3373
3321
|
}
|
|
3374
|
-
|
|
3375
|
-
//#region packages/ui/Tooltip.tsx
|
|
3322
|
+
// packages/ui/Tooltip.tsx
|
|
3376
3323
|
const TooltipProvider = Tooltip$1.Provider;
|
|
3377
3324
|
/** Uses the existing child as the trigger without adding a nested button. */
|
|
3378
3325
|
function Tooltip({ children, content, side = "top", delay, disabled, className }) {
|
|
@@ -3409,8 +3356,7 @@ function Tooltip({ children, content, side = "top", delay, disabled, className }
|
|
|
3409
3356
|
})]
|
|
3410
3357
|
});
|
|
3411
3358
|
}
|
|
3412
|
-
|
|
3413
|
-
//#region packages/ui/TimePicker.tsx
|
|
3359
|
+
// packages/ui/TimePicker.tsx
|
|
3414
3360
|
const timeValue = (value) => {
|
|
3415
3361
|
if (!value) return null;
|
|
3416
3362
|
try {
|
|
@@ -3452,8 +3398,7 @@ const TimePicker = forwardRef(function TimePicker({ id, name, value, onChange, o
|
|
|
3452
3398
|
})
|
|
3453
3399
|
});
|
|
3454
3400
|
});
|
|
3455
|
-
|
|
3456
|
-
//#region packages/ui/DetailLayout.tsx
|
|
3401
|
+
// packages/ui/DetailLayout.tsx
|
|
3457
3402
|
/** Responsive main/aside composition for record detail pages. */
|
|
3458
3403
|
function DetailLayout({ children, aside, asideLabel, className }) {
|
|
3459
3404
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -3468,5 +3413,575 @@ function DetailLayout({ children, aside, asideLabel, className }) {
|
|
|
3468
3413
|
})]
|
|
3469
3414
|
});
|
|
3470
3415
|
}
|
|
3471
|
-
|
|
3472
|
-
|
|
3416
|
+
// packages/ui/treeListModel.ts
|
|
3417
|
+
/**
|
|
3418
|
+
* Normalizes either nested records or a flat parentId collection into a
|
|
3419
|
+
* deterministic tree. A record may not be supplied through both relationships.
|
|
3420
|
+
*/
|
|
3421
|
+
function buildTreeListModel(items, options) {
|
|
3422
|
+
const { getId, getParentId, getChildren } = options;
|
|
3423
|
+
const records = /* @__PURE__ */ new Map();
|
|
3424
|
+
const nestedChildren = /* @__PURE__ */ new Map();
|
|
3425
|
+
const visitNested = (item, ancestors) => {
|
|
3426
|
+
const id = getId(item);
|
|
3427
|
+
if (records.has(id)) throw new Error(`TreeList contains duplicate id "${id}".`);
|
|
3428
|
+
if (ancestors.has(id)) throw new Error(`TreeList contains a cycle at id "${id}".`);
|
|
3429
|
+
records.set(id, item);
|
|
3430
|
+
const children = getChildren?.(item) ?? [];
|
|
3431
|
+
const nextAncestors = new Set(ancestors).add(id);
|
|
3432
|
+
const childIds = [];
|
|
3433
|
+
for (const child of children) {
|
|
3434
|
+
const childId = getId(child);
|
|
3435
|
+
childIds.push(childId);
|
|
3436
|
+
visitNested(child, nextAncestors);
|
|
3437
|
+
}
|
|
3438
|
+
nestedChildren.set(id, childIds);
|
|
3439
|
+
};
|
|
3440
|
+
for (const item of items) visitNested(item, /* @__PURE__ */ new Set());
|
|
3441
|
+
const nestedIds = /* @__PURE__ */ new Set();
|
|
3442
|
+
for (const ids of nestedChildren.values()) for (const id of ids) nestedIds.add(id);
|
|
3443
|
+
const parentById = /* @__PURE__ */ new Map();
|
|
3444
|
+
for (const [id, item] of records) {
|
|
3445
|
+
const parentId = getParentId?.(item);
|
|
3446
|
+
if (parentId != null && nestedIds.has(id)) throw new Error(`TreeList record "${id}" has both nested and parentId relationships.`);
|
|
3447
|
+
parentById.set(id, parentId == null ? null : parentId);
|
|
3448
|
+
}
|
|
3449
|
+
for (const [parentId, childIds] of nestedChildren) for (const childId of childIds) parentById.set(childId, parentId);
|
|
3450
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
3451
|
+
for (const [id, parentId] of parentById) {
|
|
3452
|
+
if (parentId != null && !records.has(parentId)) throw new Error(`TreeList record "${id}" refers to missing parent "${parentId}".`);
|
|
3453
|
+
const siblings = childrenByParent.get(parentId) ?? [];
|
|
3454
|
+
siblings.push(id);
|
|
3455
|
+
childrenByParent.set(parentId, siblings);
|
|
3456
|
+
}
|
|
3457
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
3458
|
+
const built = /* @__PURE__ */ new Map();
|
|
3459
|
+
const makeNode = (id, depth) => {
|
|
3460
|
+
if (visiting.has(id)) throw new Error(`TreeList contains a parentId cycle at id "${id}".`);
|
|
3461
|
+
const existing = built.get(id);
|
|
3462
|
+
if (existing) return existing;
|
|
3463
|
+
visiting.add(id);
|
|
3464
|
+
const node = {
|
|
3465
|
+
id,
|
|
3466
|
+
item: records.get(id),
|
|
3467
|
+
depth,
|
|
3468
|
+
children: (childrenByParent.get(id) ?? []).map((childId) => makeNode(childId, depth + 1))
|
|
3469
|
+
};
|
|
3470
|
+
visiting.delete(id);
|
|
3471
|
+
built.set(id, node);
|
|
3472
|
+
return node;
|
|
3473
|
+
};
|
|
3474
|
+
const result = (childrenByParent.get(null) ?? []).map((id) => makeNode(id, 0));
|
|
3475
|
+
if (built.size !== records.size) {
|
|
3476
|
+
const orphanedCycle = [...records.keys()].find((id) => !built.has(id));
|
|
3477
|
+
throw new Error(`TreeList contains an unreachable parentId cycle at id "${orphanedCycle}".`);
|
|
3478
|
+
}
|
|
3479
|
+
return result;
|
|
3480
|
+
}
|
|
3481
|
+
function flattenVisibleTree(roots, expandedIds) {
|
|
3482
|
+
const visible = [];
|
|
3483
|
+
const visit = (node) => {
|
|
3484
|
+
visible.push(node);
|
|
3485
|
+
if (expandedIds.has(node.id)) node.children.forEach(visit);
|
|
3486
|
+
};
|
|
3487
|
+
roots.forEach(visit);
|
|
3488
|
+
return visible;
|
|
3489
|
+
}
|
|
3490
|
+
function getDescendantIds(node) {
|
|
3491
|
+
const ids = [];
|
|
3492
|
+
const visit = (current) => {
|
|
3493
|
+
for (const child of current.children) {
|
|
3494
|
+
ids.push(child.id);
|
|
3495
|
+
visit(child);
|
|
3496
|
+
}
|
|
3497
|
+
};
|
|
3498
|
+
visit(node);
|
|
3499
|
+
return ids;
|
|
3500
|
+
}
|
|
3501
|
+
// packages/ui/TreeList.tsx
|
|
3502
|
+
function itemValue(column, item) {
|
|
3503
|
+
if (column.value) return column.value(item);
|
|
3504
|
+
return item[column.id];
|
|
3505
|
+
}
|
|
3506
|
+
function compareValues(left, right) {
|
|
3507
|
+
if (left == null) return right == null ? 0 : -1;
|
|
3508
|
+
if (right == null) return 1;
|
|
3509
|
+
if (typeof left === "number" && typeof right === "number") return left - right;
|
|
3510
|
+
return String(left).localeCompare(String(right), void 0, {
|
|
3511
|
+
numeric: true,
|
|
3512
|
+
sensitivity: "base"
|
|
3513
|
+
});
|
|
3514
|
+
}
|
|
3515
|
+
function filterTree(nodes, query, columns) {
|
|
3516
|
+
if (!query) return [...nodes];
|
|
3517
|
+
const normalizedQuery = query.toLocaleLowerCase();
|
|
3518
|
+
const result = [];
|
|
3519
|
+
for (const node of nodes) {
|
|
3520
|
+
const children = filterTree(node.children, query, columns);
|
|
3521
|
+
if (columns.some((column) => String(itemValue(column, node.item) ?? "").toLocaleLowerCase().includes(normalizedQuery)) || children.length > 0) result.push({
|
|
3522
|
+
...node,
|
|
3523
|
+
children
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3526
|
+
return result;
|
|
3527
|
+
}
|
|
3528
|
+
function sortTree(nodes, column, direction) {
|
|
3529
|
+
const result = nodes.map((node) => ({
|
|
3530
|
+
...node,
|
|
3531
|
+
children: sortTree(node.children, column, direction)
|
|
3532
|
+
}));
|
|
3533
|
+
if (!column || !direction) return result;
|
|
3534
|
+
const multiplier = direction === "asc" ? 1 : -1;
|
|
3535
|
+
return result.sort((left, right) => multiplier * compareValues(itemValue(column, left.item), itemValue(column, right.item)));
|
|
3536
|
+
}
|
|
3537
|
+
function TreeList({ items, columns, getId, getParentId, getChildren, hasChildren, loadChildren, withParent, expandedIds: controlledExpandedIds, defaultExpandedIds = /* @__PURE__ */ new Set(), onExpandedIdsChange, selectionMode = "none", selectedIds: controlledSelectedIds, defaultSelectedIds = /* @__PURE__ */ new Set(), onSelectedIdsChange, onSelectedItemsChange, selectDescendants = true, rowActions, onRowActivate, onMove, onEdit, editable, filter: controlledFilter, onFilterChange, filterable = true, loading = false, emptyState, error, ariaLabel, className, density = "comfortable", testId }) {
|
|
3538
|
+
const strings = useUiStrings();
|
|
3539
|
+
const [localItems, setLocalItems] = useState(items);
|
|
3540
|
+
const [localExpandedIds, setLocalExpandedIds] = useState(defaultExpandedIds);
|
|
3541
|
+
const [localSelectedIds, setLocalSelectedIds] = useState(defaultSelectedIds);
|
|
3542
|
+
const [localFilter, setLocalFilter] = useState("");
|
|
3543
|
+
const [sort, setSort] = useState(null);
|
|
3544
|
+
const [editingCell, setEditingCell] = useState(null);
|
|
3545
|
+
const [editValue, setEditValue] = useState("");
|
|
3546
|
+
const [moveError, setMoveError] = useState(false);
|
|
3547
|
+
const [loadingIds, setLoadingIds] = useState(() => /* @__PURE__ */ new Set());
|
|
3548
|
+
const [loadErrors, setLoadErrors] = useState(() => /* @__PURE__ */ new Map());
|
|
3549
|
+
const [editErrors, setEditErrors] = useState(() => /* @__PURE__ */ new Map());
|
|
3550
|
+
const controllers = useRef(/* @__PURE__ */ new Map());
|
|
3551
|
+
const rows = useRef(/* @__PURE__ */ new Map());
|
|
3552
|
+
const filter = controlledFilter ?? localFilter;
|
|
3553
|
+
const expandedIds = controlledExpandedIds ?? localExpandedIds;
|
|
3554
|
+
const selectedIds = controlledSelectedIds ?? localSelectedIds;
|
|
3555
|
+
React.useEffect(() => setLocalItems(items), [items]);
|
|
3556
|
+
React.useEffect(() => () => {
|
|
3557
|
+
controllers.current.forEach((controller) => controller.abort());
|
|
3558
|
+
controllers.current.clear();
|
|
3559
|
+
}, []);
|
|
3560
|
+
const modelOptions = useMemo(() => ({
|
|
3561
|
+
getId,
|
|
3562
|
+
getParentId,
|
|
3563
|
+
getChildren
|
|
3564
|
+
}), [
|
|
3565
|
+
getChildren,
|
|
3566
|
+
getId,
|
|
3567
|
+
getParentId
|
|
3568
|
+
]);
|
|
3569
|
+
const tree = useMemo(() => buildTreeListModel(localItems, modelOptions), [localItems, modelOptions]);
|
|
3570
|
+
const filteredTree = useMemo(() => filterTree(tree, filter.trim(), columns), [
|
|
3571
|
+
columns,
|
|
3572
|
+
filter,
|
|
3573
|
+
tree
|
|
3574
|
+
]);
|
|
3575
|
+
const sortColumn = sort ? columns.find((column) => column.id === sort.columnId) : void 0;
|
|
3576
|
+
const sortedTree = useMemo(() => sortTree(filteredTree, sortColumn, sort?.direction), [
|
|
3577
|
+
filteredTree,
|
|
3578
|
+
sort?.direction,
|
|
3579
|
+
sortColumn
|
|
3580
|
+
]);
|
|
3581
|
+
const filterExpandedIds = useMemo(() => {
|
|
3582
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3583
|
+
const visit = (node) => {
|
|
3584
|
+
if (node.children.length > 0) ids.add(node.id);
|
|
3585
|
+
node.children.forEach(visit);
|
|
3586
|
+
};
|
|
3587
|
+
sortedTree.forEach(visit);
|
|
3588
|
+
return ids;
|
|
3589
|
+
}, [sortedTree]);
|
|
3590
|
+
const visibleNodes = useMemo(() => flattenVisibleTree(sortedTree, filter.trim() ? filterExpandedIds : expandedIds), [
|
|
3591
|
+
expandedIds,
|
|
3592
|
+
filter,
|
|
3593
|
+
filterExpandedIds,
|
|
3594
|
+
sortedTree
|
|
3595
|
+
]);
|
|
3596
|
+
const effectiveExpandedIds = filter.trim() ? filterExpandedIds : expandedIds;
|
|
3597
|
+
const nodeById = useMemo(() => {
|
|
3598
|
+
const result = /* @__PURE__ */ new Map();
|
|
3599
|
+
const visit = (node) => {
|
|
3600
|
+
result.set(node.id, node);
|
|
3601
|
+
node.children.forEach(visit);
|
|
3602
|
+
};
|
|
3603
|
+
tree.forEach(visit);
|
|
3604
|
+
return result;
|
|
3605
|
+
}, [tree]);
|
|
3606
|
+
const updateExpanded = useCallback((next) => {
|
|
3607
|
+
if (controlledExpandedIds === void 0) setLocalExpandedIds(next);
|
|
3608
|
+
onExpandedIdsChange?.(next);
|
|
3609
|
+
}, [controlledExpandedIds, onExpandedIdsChange]);
|
|
3610
|
+
const updateSelected = useCallback((next) => {
|
|
3611
|
+
if (controlledSelectedIds === void 0) setLocalSelectedIds(next);
|
|
3612
|
+
onSelectedIdsChange?.(next);
|
|
3613
|
+
if (onSelectedItemsChange) onSelectedItemsChange([...next].flatMap((id) => {
|
|
3614
|
+
const node = nodeById.get(id);
|
|
3615
|
+
return node ? [node.item] : [];
|
|
3616
|
+
}));
|
|
3617
|
+
}, [
|
|
3618
|
+
controlledSelectedIds,
|
|
3619
|
+
nodeById,
|
|
3620
|
+
onSelectedIdsChange,
|
|
3621
|
+
onSelectedItemsChange
|
|
3622
|
+
]);
|
|
3623
|
+
const updateFilter = (value) => {
|
|
3624
|
+
if (controlledFilter === void 0) setLocalFilter(value);
|
|
3625
|
+
onFilterChange?.(value);
|
|
3626
|
+
};
|
|
3627
|
+
const expand = useCallback(async (node) => {
|
|
3628
|
+
const next = new Set(expandedIds);
|
|
3629
|
+
if (next.has(node.id) && !loadErrors.has(node.id)) {
|
|
3630
|
+
controllers.current.get(node.id)?.abort();
|
|
3631
|
+
next.delete(node.id);
|
|
3632
|
+
updateExpanded(next);
|
|
3633
|
+
return;
|
|
3634
|
+
}
|
|
3635
|
+
next.add(node.id);
|
|
3636
|
+
updateExpanded(next);
|
|
3637
|
+
if (!loadChildren || (hasChildren ? !hasChildren(node.item) : false) || node.children.length > 0) return;
|
|
3638
|
+
const controller = new AbortController();
|
|
3639
|
+
controllers.current.get(node.id)?.abort();
|
|
3640
|
+
controllers.current.set(node.id, controller);
|
|
3641
|
+
setLoadingIds((current) => new Set(current).add(node.id));
|
|
3642
|
+
setLoadErrors((current) => {
|
|
3643
|
+
const nextErrors = new Map(current);
|
|
3644
|
+
nextErrors.delete(node.id);
|
|
3645
|
+
return nextErrors;
|
|
3646
|
+
});
|
|
3647
|
+
try {
|
|
3648
|
+
const children = await loadChildren(node.item, { signal: controller.signal });
|
|
3649
|
+
if (controller.signal.aborted) return;
|
|
3650
|
+
const normalized = withParent ? children.map((child) => withParent(child, node.item)) : children;
|
|
3651
|
+
setLocalItems((current) => [...current, ...normalized]);
|
|
3652
|
+
} catch (cause) {
|
|
3653
|
+
if (!controller.signal.aborted) setLoadErrors((current) => new Map(current).set(node.id, cause));
|
|
3654
|
+
} finally {
|
|
3655
|
+
if (controllers.current.get(node.id) === controller) controllers.current.delete(node.id);
|
|
3656
|
+
setLoadingIds((current) => {
|
|
3657
|
+
const nextLoading = new Set(current);
|
|
3658
|
+
nextLoading.delete(node.id);
|
|
3659
|
+
return nextLoading;
|
|
3660
|
+
});
|
|
3661
|
+
}
|
|
3662
|
+
}, [
|
|
3663
|
+
expandedIds,
|
|
3664
|
+
hasChildren,
|
|
3665
|
+
loadChildren,
|
|
3666
|
+
loadErrors,
|
|
3667
|
+
updateExpanded,
|
|
3668
|
+
withParent
|
|
3669
|
+
]);
|
|
3670
|
+
const toggleSelected = (node) => {
|
|
3671
|
+
const next = new Set(selectionMode === "single" ? [] : selectedIds);
|
|
3672
|
+
if (selectedIds.has(node.id)) next.delete(node.id);
|
|
3673
|
+
else next.add(node.id);
|
|
3674
|
+
if (selectionMode === "multiple" && selectDescendants) for (const id of getDescendantIds(node)) if (selectedIds.has(node.id)) next.delete(id);
|
|
3675
|
+
else next.add(id);
|
|
3676
|
+
updateSelected(next);
|
|
3677
|
+
};
|
|
3678
|
+
const parentOf = (targetId) => {
|
|
3679
|
+
const find = (nodes) => {
|
|
3680
|
+
for (const node of nodes) {
|
|
3681
|
+
if (node.children.some((child) => child.id === targetId)) return node;
|
|
3682
|
+
const found = find(node.children);
|
|
3683
|
+
if (found) return found;
|
|
3684
|
+
}
|
|
3685
|
+
return null;
|
|
3686
|
+
};
|
|
3687
|
+
return find(tree);
|
|
3688
|
+
};
|
|
3689
|
+
const siblingsOf = (parent) => parent ? parent.children : tree;
|
|
3690
|
+
const moveRow = (item, target, position = "inside") => {
|
|
3691
|
+
if (!onMove) return;
|
|
3692
|
+
const sourceId = getId(item);
|
|
3693
|
+
const sourceNode = nodeById.get(sourceId);
|
|
3694
|
+
if (!sourceNode) return;
|
|
3695
|
+
if (target?.id === sourceId) return;
|
|
3696
|
+
const parent = position === "inside" ? target : target ? parentOf(target.id) : null;
|
|
3697
|
+
if (parent && (parent.id === sourceId || getDescendantIds(sourceNode).includes(parent.id))) return;
|
|
3698
|
+
const siblings = siblingsOf(parent).filter((node) => node.id !== sourceId);
|
|
3699
|
+
const targetIndex = target ? siblings.findIndex((node) => node.id === target.id) : -1;
|
|
3700
|
+
const index = targetIndex < 0 ? siblings.length : targetIndex + (position === "after" ? 1 : 0);
|
|
3701
|
+
Promise.resolve(onMove({
|
|
3702
|
+
item,
|
|
3703
|
+
newParent: parent?.item ?? null,
|
|
3704
|
+
index,
|
|
3705
|
+
position
|
|
3706
|
+
})).then(() => setMoveError(false)).catch(() => setMoveError(true));
|
|
3707
|
+
};
|
|
3708
|
+
const saveEdit = async (node, columnId) => {
|
|
3709
|
+
const key = `${String(node.id)}:${columnId}`;
|
|
3710
|
+
setEditingCell(null);
|
|
3711
|
+
try {
|
|
3712
|
+
await onEdit?.(node.item, columnId, editValue);
|
|
3713
|
+
setEditErrors((current) => {
|
|
3714
|
+
const next = new Map(current);
|
|
3715
|
+
next.delete(key);
|
|
3716
|
+
return next;
|
|
3717
|
+
});
|
|
3718
|
+
} catch (cause) {
|
|
3719
|
+
setEditErrors((current) => new Map(current).set(key, cause));
|
|
3720
|
+
setEditingCell({
|
|
3721
|
+
id: node.id,
|
|
3722
|
+
columnId
|
|
3723
|
+
});
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
const onRowKeyDown = (event, index) => {
|
|
3727
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
3728
|
+
event.preventDefault();
|
|
3729
|
+
const target = visibleNodes[index + (event.key === "ArrowDown" ? 1 : -1)];
|
|
3730
|
+
if (target) rows.current.get(target.id)?.focus();
|
|
3731
|
+
}
|
|
3732
|
+
if (event.key === "ArrowRight" && visibleNodes[index]) {
|
|
3733
|
+
event.preventDefault();
|
|
3734
|
+
const node = visibleNodes[index];
|
|
3735
|
+
if ((node.children.length > 0 || hasChildren?.(node.item)) && !expandedIds.has(node.id)) expand(node);
|
|
3736
|
+
else if (expandedIds.has(node.id) && node.children[0]) rows.current.get(node.children[0].id)?.focus();
|
|
3737
|
+
}
|
|
3738
|
+
if (event.key === "ArrowLeft" && visibleNodes[index]) {
|
|
3739
|
+
event.preventDefault();
|
|
3740
|
+
const node = visibleNodes[index];
|
|
3741
|
+
if (expandedIds.has(node.id)) expand(node);
|
|
3742
|
+
else {
|
|
3743
|
+
const parentId = getParentId?.(node.item);
|
|
3744
|
+
if (parentId != null) rows.current.get(parentId)?.focus();
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
if (event.key === "Enter" && visibleNodes[index]) onRowActivate?.(visibleNodes[index].item);
|
|
3748
|
+
};
|
|
3749
|
+
const classNames = [
|
|
3750
|
+
"nb-tree-list",
|
|
3751
|
+
`nb-tree-list--${density}`,
|
|
3752
|
+
className
|
|
3753
|
+
].filter(Boolean).join(" ");
|
|
3754
|
+
const hasSelection = selectionMode !== "none";
|
|
3755
|
+
const allVisibleSelected = visibleNodes.length > 0 && visibleNodes.every((node) => selectedIds.has(node.id));
|
|
3756
|
+
const someVisibleSelected = !allVisibleSelected && visibleNodes.some((node) => selectedIds.has(node.id));
|
|
3757
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3758
|
+
className: classNames,
|
|
3759
|
+
"data-testid": testId,
|
|
3760
|
+
children: [
|
|
3761
|
+
filterable && /* @__PURE__ */ jsxs("div", {
|
|
3762
|
+
className: "nb-tree-list__toolbar",
|
|
3763
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
3764
|
+
className: "nb-tree-list__filter",
|
|
3765
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3766
|
+
className: "nb-tree-list__sr-only",
|
|
3767
|
+
children: strings.treeListFilter
|
|
3768
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
3769
|
+
type: "search",
|
|
3770
|
+
value: filter,
|
|
3771
|
+
placeholder: strings.treeListFilter,
|
|
3772
|
+
onChange: (event) => updateFilter(event.currentTarget.value)
|
|
3773
|
+
})]
|
|
3774
|
+
}), filter && /* @__PURE__ */ jsx("button", {
|
|
3775
|
+
type: "button",
|
|
3776
|
+
className: "nb-tree-list__clear-filter",
|
|
3777
|
+
onClick: () => updateFilter(""),
|
|
3778
|
+
children: strings.clear
|
|
3779
|
+
})]
|
|
3780
|
+
}),
|
|
3781
|
+
error && /* @__PURE__ */ jsx("div", {
|
|
3782
|
+
className: "nb-tree-list__error",
|
|
3783
|
+
role: "alert",
|
|
3784
|
+
children: error
|
|
3785
|
+
}),
|
|
3786
|
+
moveError && /* @__PURE__ */ jsx("div", {
|
|
3787
|
+
className: "nb-tree-list__error",
|
|
3788
|
+
role: "alert",
|
|
3789
|
+
children: strings.treeListMoveFailed
|
|
3790
|
+
}),
|
|
3791
|
+
loading && /* @__PURE__ */ jsx("div", {
|
|
3792
|
+
className: "nb-tree-list__loading",
|
|
3793
|
+
role: "status",
|
|
3794
|
+
children: strings.searching
|
|
3795
|
+
}),
|
|
3796
|
+
!loading && visibleNodes.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
3797
|
+
className: "nb-tree-list__empty",
|
|
3798
|
+
children: emptyState ?? strings.treeListEmpty
|
|
3799
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
3800
|
+
className: "nb-tree-list__scroll",
|
|
3801
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
3802
|
+
className: "nb-tree-list__table",
|
|
3803
|
+
role: "treegrid",
|
|
3804
|
+
"aria-label": ariaLabel,
|
|
3805
|
+
"aria-busy": loading || loadingIds.size > 0,
|
|
3806
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
3807
|
+
hasSelection && /* @__PURE__ */ jsx("th", {
|
|
3808
|
+
className: "nb-tree-list__selection-cell",
|
|
3809
|
+
children: selectionMode === "multiple" && /* @__PURE__ */ jsx(Checkbox, {
|
|
3810
|
+
"aria-label": strings.treeListSelectAll,
|
|
3811
|
+
checked: allVisibleSelected,
|
|
3812
|
+
indeterminate: someVisibleSelected,
|
|
3813
|
+
onChange: () => {
|
|
3814
|
+
const next = new Set(selectedIds);
|
|
3815
|
+
for (const node of visibleNodes) if (allVisibleSelected) next.delete(node.id);
|
|
3816
|
+
else next.add(node.id);
|
|
3817
|
+
updateSelected(next);
|
|
3818
|
+
}
|
|
3819
|
+
})
|
|
3820
|
+
}),
|
|
3821
|
+
columns.map((column, index) => /* @__PURE__ */ jsx("th", {
|
|
3822
|
+
scope: "col",
|
|
3823
|
+
"aria-sort": sort?.columnId === column.id ? sort.direction === "asc" ? "ascending" : "descending" : void 0,
|
|
3824
|
+
style: column.width ? { width: column.width } : void 0,
|
|
3825
|
+
className: `nb-tree-list__align--${column.align ?? "start"}`,
|
|
3826
|
+
children: column.sortable === false || index === 0 ? column.header : /* @__PURE__ */ jsxs("button", {
|
|
3827
|
+
type: "button",
|
|
3828
|
+
className: "nb-tree-list__sort",
|
|
3829
|
+
onClick: () => setSort((current) => current?.columnId === column.id ? current.direction === "asc" ? {
|
|
3830
|
+
columnId: column.id,
|
|
3831
|
+
direction: "desc"
|
|
3832
|
+
} : null : {
|
|
3833
|
+
columnId: column.id,
|
|
3834
|
+
direction: "asc"
|
|
3835
|
+
}),
|
|
3836
|
+
children: [column.header, /* @__PURE__ */ jsx("span", {
|
|
3837
|
+
"aria-hidden": "true",
|
|
3838
|
+
children: sort?.columnId === column.id ? sort.direction === "asc" ? "↑" : "↓" : "↕"
|
|
3839
|
+
})]
|
|
3840
|
+
})
|
|
3841
|
+
}, column.id)),
|
|
3842
|
+
rowActions && /* @__PURE__ */ jsx("th", {
|
|
3843
|
+
scope: "col",
|
|
3844
|
+
"aria-label": strings.rowActions
|
|
3845
|
+
})
|
|
3846
|
+
] }) }), /* @__PURE__ */ jsx("tbody", {
|
|
3847
|
+
onDragOver: (event) => {
|
|
3848
|
+
if (onMove && event.target === event.currentTarget) {
|
|
3849
|
+
event.preventDefault();
|
|
3850
|
+
event.dataTransfer.dropEffect = "move";
|
|
3851
|
+
}
|
|
3852
|
+
},
|
|
3853
|
+
onDrop: (event) => {
|
|
3854
|
+
if (!onMove || event.target !== event.currentTarget) return;
|
|
3855
|
+
event.preventDefault();
|
|
3856
|
+
const draggedId = event.dataTransfer.getData("text/plain");
|
|
3857
|
+
const dragged = nodeById.get(draggedId) ?? nodeById.get(Number(draggedId));
|
|
3858
|
+
if (dragged) moveRow(dragged.item, null, "after");
|
|
3859
|
+
},
|
|
3860
|
+
children: visibleNodes.map((node, index) => {
|
|
3861
|
+
const expanded = effectiveExpandedIds.has(node.id);
|
|
3862
|
+
const canExpand = node.children.length > 0 || (hasChildren ? hasChildren(node.item) : !!loadChildren);
|
|
3863
|
+
const selected = selectedIds.has(node.id);
|
|
3864
|
+
const parent = getParentId?.(node.item);
|
|
3865
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
3866
|
+
ref: (element) => {
|
|
3867
|
+
if (element) rows.current.set(node.id, element);
|
|
3868
|
+
else rows.current.delete(node.id);
|
|
3869
|
+
},
|
|
3870
|
+
role: "row",
|
|
3871
|
+
"aria-level": node.depth + 1,
|
|
3872
|
+
"aria-expanded": canExpand ? expanded : void 0,
|
|
3873
|
+
"aria-selected": hasSelection ? selected : void 0,
|
|
3874
|
+
tabIndex: index === 0 ? 0 : -1,
|
|
3875
|
+
draggable: !!onMove,
|
|
3876
|
+
onKeyDown: (event) => onRowKeyDown(event, index),
|
|
3877
|
+
onClick: () => onRowActivate?.(node.item),
|
|
3878
|
+
onDragStart: (event) => {
|
|
3879
|
+
event.dataTransfer.setData("text/plain", String(node.id));
|
|
3880
|
+
event.dataTransfer.effectAllowed = "move";
|
|
3881
|
+
},
|
|
3882
|
+
onDragOver: (event) => {
|
|
3883
|
+
if (onMove) {
|
|
3884
|
+
event.preventDefault();
|
|
3885
|
+
event.dataTransfer.dropEffect = "move";
|
|
3886
|
+
}
|
|
3887
|
+
},
|
|
3888
|
+
onDrop: (event) => {
|
|
3889
|
+
event.preventDefault();
|
|
3890
|
+
event.stopPropagation();
|
|
3891
|
+
const draggedId = event.dataTransfer.getData("text/plain");
|
|
3892
|
+
const dragged = nodeById.get(draggedId) ?? nodeById.get(Number(draggedId));
|
|
3893
|
+
const bounds = event.currentTarget.getBoundingClientRect();
|
|
3894
|
+
const relativeY = event.clientY - bounds.top;
|
|
3895
|
+
const position = relativeY < bounds.height * .25 ? "before" : relativeY > bounds.height * .75 ? "after" : "inside";
|
|
3896
|
+
if (dragged) moveRow(dragged.item, node, position);
|
|
3897
|
+
},
|
|
3898
|
+
onDragEnd: () => {},
|
|
3899
|
+
"data-parent-id": parent == null ? void 0 : String(parent),
|
|
3900
|
+
children: [
|
|
3901
|
+
hasSelection && /* @__PURE__ */ jsx("td", {
|
|
3902
|
+
className: "nb-tree-list__selection-cell",
|
|
3903
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
3904
|
+
"aria-label": `${strings.treeListSelect} ${String(getId(node.item))}`,
|
|
3905
|
+
checked: selected,
|
|
3906
|
+
onClick: (event) => event.stopPropagation(),
|
|
3907
|
+
onChange: () => toggleSelected(node)
|
|
3908
|
+
})
|
|
3909
|
+
}),
|
|
3910
|
+
columns.map((column, columnIndex) => {
|
|
3911
|
+
const isEditing = editingCell?.id === node.id && editingCell.columnId === column.id;
|
|
3912
|
+
const rawValue = itemValue(column, node.item);
|
|
3913
|
+
return /* @__PURE__ */ jsxs("td", {
|
|
3914
|
+
className: `nb-tree-list__align--${column.align ?? "start"}`,
|
|
3915
|
+
onDoubleClick: () => {
|
|
3916
|
+
const columnCanEdit = column.editable === true || typeof column.editable === "function" && column.editable(node.item) || editable?.(node.item, column.id) === true;
|
|
3917
|
+
if (!onEdit || !columnCanEdit) return;
|
|
3918
|
+
setEditingCell({
|
|
3919
|
+
id: node.id,
|
|
3920
|
+
columnId: column.id
|
|
3921
|
+
});
|
|
3922
|
+
setEditValue(String(rawValue ?? ""));
|
|
3923
|
+
},
|
|
3924
|
+
children: [
|
|
3925
|
+
columnIndex === 0 && /* @__PURE__ */ jsx("span", {
|
|
3926
|
+
className: "nb-tree-list__indent",
|
|
3927
|
+
style: { "--nb-tree-depth": node.depth },
|
|
3928
|
+
children: canExpand ? /* @__PURE__ */ jsx(IconButton, {
|
|
3929
|
+
icon: loadingIds.has(node.id) ? "ph ph-spinner" : expanded ? "ph ph-caret-down" : "ph ph-caret-right",
|
|
3930
|
+
label: `${expanded ? strings.treeListCollapse : strings.treeListExpand} ${String(getId(node.item))}`,
|
|
3931
|
+
disabled: loadingIds.has(node.id),
|
|
3932
|
+
onClick: (event) => {
|
|
3933
|
+
event.stopPropagation();
|
|
3934
|
+
expand(node);
|
|
3935
|
+
}
|
|
3936
|
+
}) : /* @__PURE__ */ jsx("span", { className: "nb-tree-list__spacer" })
|
|
3937
|
+
}),
|
|
3938
|
+
isEditing ? column.editor ? column.editor({
|
|
3939
|
+
item: node.item,
|
|
3940
|
+
value: editValue,
|
|
3941
|
+
onChange: setEditValue
|
|
3942
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
3943
|
+
autoFocus: true,
|
|
3944
|
+
value: editValue,
|
|
3945
|
+
"aria-label": `${strings.treeListEdit} ${column.id}`,
|
|
3946
|
+
onChange: (event) => setEditValue(event.currentTarget.value),
|
|
3947
|
+
onBlur: () => void saveEdit(node, column.id),
|
|
3948
|
+
onKeyDown: (event) => {
|
|
3949
|
+
if (event.key === "Enter") saveEdit(node, column.id);
|
|
3950
|
+
if (event.key === "Escape") setEditingCell(null);
|
|
3951
|
+
}
|
|
3952
|
+
}) : column.render ? column.render(node.item, {
|
|
3953
|
+
depth: node.depth,
|
|
3954
|
+
expanded
|
|
3955
|
+
}) : String(rawValue ?? ""),
|
|
3956
|
+
loadErrors.has(node.id) && columnIndex === 0 && /* @__PURE__ */ jsx("button", {
|
|
3957
|
+
type: "button",
|
|
3958
|
+
className: "nb-tree-list__retry",
|
|
3959
|
+
onClick: () => void expand(node),
|
|
3960
|
+
children: strings.retrySearch
|
|
3961
|
+
}),
|
|
3962
|
+
editErrors.has(`${String(node.id)}:${column.id}`) && isEditing && /* @__PURE__ */ jsx("span", {
|
|
3963
|
+
className: "nb-tree-list__edit-error",
|
|
3964
|
+
role: "alert",
|
|
3965
|
+
children: strings.searchFailed
|
|
3966
|
+
})
|
|
3967
|
+
]
|
|
3968
|
+
}, column.id);
|
|
3969
|
+
}),
|
|
3970
|
+
rowActions && /* @__PURE__ */ jsx("td", {
|
|
3971
|
+
className: "nb-tree-list__actions-cell",
|
|
3972
|
+
onClick: (event) => event.stopPropagation(),
|
|
3973
|
+
children: /* @__PURE__ */ jsx(RowActions, {
|
|
3974
|
+
items: rowActions(node.item),
|
|
3975
|
+
triggerLabel: strings.rowActions
|
|
3976
|
+
})
|
|
3977
|
+
})
|
|
3978
|
+
]
|
|
3979
|
+
}, node.id);
|
|
3980
|
+
})
|
|
3981
|
+
})]
|
|
3982
|
+
})
|
|
3983
|
+
})
|
|
3984
|
+
]
|
|
3985
|
+
});
|
|
3986
|
+
}
|
|
3987
|
+
export { ACCENT_PRESETS, Alert, AppDialog, AppDropdown, AppToolbar, Avatar, Badge, Button, Card, Checkbox, Chip, Cluster, Code, Col, CollapsibleSection, Combobox, ConfirmDialog, ContextMenu, DataTable, DatePicker, DateRangePicker, DensityContext, DensityProvider, DescriptionList, DetailLayout, Drawer, EN_UI_STRINGS, ES_UI_STRINGS, EmptyState, FeatureGate, FileDropzone, FilterPanel, FormActions, FormField, FormLayout, Grid, HubPanel, IconButton, KpiMetricRow, MultiSelect, OperationCardGrid, Page, PageHeader, Pagination, Popover, Progress, RadioGroup, Row, RowActions, ScopeTabs, SearchableAppDropdown, Section, SegmentedControl, SelectField, SettingsPanel, Skeleton, Spinner, Stack, StatCard, Tabs, Text, TextAreaField, TextField, ThemeContext, ThemeProvider, ThemeSwitcher, TimePicker, Timeline, TimelineItem, Toggle, Tooltip, TooltipProvider, TreeList, UiStringsProvider, buildTreeListModel, flattenVisibleTree, getAvatarHue, getAvatarInitials, getDescendantIds, useAccentColor, useConfirm, useDensity, useFloatingPanel, useOverlayContainer, useTheme, useUiStrings };
|