@nubitio/ui 1.3.1 → 1.4.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.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20,9 +20,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let react = require("react");
|
|
25
|
-
react = __toESM(react, 1);
|
|
26
24
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
27
25
|
let _base_ui_react_dialog = require("@base-ui/react/dialog");
|
|
28
26
|
let react_dropzone = require("react-dropzone");
|
|
@@ -32,7 +30,8 @@ let _base_ui_react_menu = require("@base-ui/react/menu");
|
|
|
32
30
|
let _internationalized_date = require("@internationalized/date");
|
|
33
31
|
let _base_ui_react_popover = require("@base-ui/react/popover");
|
|
34
32
|
let _base_ui_react_tooltip = require("@base-ui/react/tooltip");
|
|
35
|
-
|
|
33
|
+
react = __toESM(react, 1);
|
|
34
|
+
// packages/ui/Avatar.tsx
|
|
36
35
|
/**
|
|
37
36
|
* 8 semantic hues aligned with the Fluent / @nubitio design palette.
|
|
38
37
|
* Expressed as HSL so the lightness can be adjusted for dark mode via CSS.
|
|
@@ -64,7 +63,7 @@ function getAvatarInitials(owner = "") {
|
|
|
64
63
|
}
|
|
65
64
|
function getAvatarHue(owner = "") {
|
|
66
65
|
let hash = 0;
|
|
67
|
-
for (let i = 0; i < owner.length; i++) hash = hash * 31 + owner.charCodeAt(i) &
|
|
66
|
+
for (let i = 0; i < owner.length; i++) hash = hash * 31 + owner.charCodeAt(i) & 0xfffffff;
|
|
68
67
|
return AVATAR_HUES[Math.abs(hash) % AVATAR_HUES.length];
|
|
69
68
|
}
|
|
70
69
|
const Avatar = ({ owner = "", size, variant = "md", shape = "circle", alt, className }) => {
|
|
@@ -89,13 +88,11 @@ const Avatar = ({ owner = "", size, variant = "md", shape = "circle", alt, class
|
|
|
89
88
|
children: initials
|
|
90
89
|
});
|
|
91
90
|
};
|
|
92
|
-
|
|
93
|
-
//#region packages/ui/OverlayContainer.tsx
|
|
91
|
+
// packages/ui/OverlayContainer.tsx
|
|
94
92
|
/** Keeps nested portals within the modal's focus and accessibility boundary. */
|
|
95
93
|
const OverlayContainerContext = (0, react.createContext)(null);
|
|
96
94
|
const useOverlayContainer = () => (0, react.useContext)(OverlayContainerContext);
|
|
97
|
-
|
|
98
|
-
//#region packages/ui/ModalSurface.tsx
|
|
95
|
+
// packages/ui/ModalSurface.tsx
|
|
99
96
|
/** Shared modal behavior for centered dialogs and side sheets. */
|
|
100
97
|
function ModalSurface({ open, onClose, children, rootClassName, className, style, scrimClassName, scrimLabel, labelledBy, ariaLabel, role = "dialog", keepMounted = false, restoreFocus = true, closeOnEscape = true, initialFocus, closeOnOutsideClick = true }) {
|
|
101
98
|
const parentContainer = useOverlayContainer();
|
|
@@ -155,8 +152,7 @@ function ModalSurface({ open, onClose, children, rootClassName, className, style
|
|
|
155
152
|
})
|
|
156
153
|
});
|
|
157
154
|
}
|
|
158
|
-
|
|
159
|
-
//#region packages/ui/Button.tsx
|
|
155
|
+
// packages/ui/Button.tsx
|
|
160
156
|
const cx$2 = (...values) => values.filter(Boolean).join(" ");
|
|
161
157
|
const Button = (0, react.forwardRef)(function Button({ variant = "secondary", size = "md", fullWidth = false, icon, loading = false, className, children, disabled, ...props }, ref) {
|
|
162
158
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
@@ -189,8 +185,7 @@ const IconButton = (0, react.forwardRef)(function IconButton({ icon, label, vari
|
|
|
189
185
|
})
|
|
190
186
|
});
|
|
191
187
|
});
|
|
192
|
-
|
|
193
|
-
//#region packages/ui/UiStrings.tsx
|
|
188
|
+
// packages/ui/UiStrings.tsx
|
|
194
189
|
const EN_UI_STRINGS = {
|
|
195
190
|
close: "Close",
|
|
196
191
|
closeDialog: "Close dialog",
|
|
@@ -261,7 +256,15 @@ const EN_UI_STRINGS = {
|
|
|
261
256
|
redo: "Redo (Ctrl+Y)",
|
|
262
257
|
featureUnavailable: "This feature is not available on your current plan.",
|
|
263
258
|
featureRequiresPlan: "This feature requires the {plan} plan. Upgrade your plan to unlock it.",
|
|
264
|
-
viewPlans: "View plans"
|
|
259
|
+
viewPlans: "View plans",
|
|
260
|
+
treeListFilter: "Filter rows",
|
|
261
|
+
treeListEmpty: "No rows to display",
|
|
262
|
+
treeListExpand: "Expand",
|
|
263
|
+
treeListCollapse: "Collapse",
|
|
264
|
+
treeListSelect: "Select row",
|
|
265
|
+
treeListSelectAll: "Select all visible rows",
|
|
266
|
+
treeListEdit: "Edit",
|
|
267
|
+
treeListMoveFailed: "The row could not be moved."
|
|
265
268
|
};
|
|
266
269
|
const ES_UI_STRINGS = {
|
|
267
270
|
close: "Cerrar",
|
|
@@ -333,7 +336,15 @@ const ES_UI_STRINGS = {
|
|
|
333
336
|
redo: "Rehacer (Ctrl+Y)",
|
|
334
337
|
featureUnavailable: "Esta función no está disponible en tu plan actual.",
|
|
335
338
|
featureRequiresPlan: "Esta función requiere el plan {plan}. Actualiza tu plan para desbloquearla.",
|
|
336
|
-
viewPlans: "Ver planes"
|
|
339
|
+
viewPlans: "Ver planes",
|
|
340
|
+
treeListFilter: "Filtrar filas",
|
|
341
|
+
treeListEmpty: "No hay filas para mostrar",
|
|
342
|
+
treeListExpand: "Expandir",
|
|
343
|
+
treeListCollapse: "Contraer",
|
|
344
|
+
treeListSelect: "Seleccionar fila",
|
|
345
|
+
treeListSelectAll: "Seleccionar todas las filas visibles",
|
|
346
|
+
treeListEdit: "Editar",
|
|
347
|
+
treeListMoveFailed: "No se pudo mover la fila."
|
|
337
348
|
};
|
|
338
349
|
const UiStringsContext = (0, react.createContext)(EN_UI_STRINGS);
|
|
339
350
|
const UiStringsProvider = ({ strings, children }) => {
|
|
@@ -347,8 +358,7 @@ const UiStringsProvider = ({ strings, children }) => {
|
|
|
347
358
|
});
|
|
348
359
|
};
|
|
349
360
|
const useUiStrings = () => (0, react.useContext)(UiStringsContext);
|
|
350
|
-
|
|
351
|
-
//#region packages/ui/AppDialog.tsx
|
|
361
|
+
// packages/ui/AppDialog.tsx
|
|
352
362
|
const formatSize = (value) => {
|
|
353
363
|
if (value === void 0) return void 0;
|
|
354
364
|
return typeof value === "number" ? `${value}px` : value;
|
|
@@ -404,8 +414,7 @@ const AppDialog = ({ visible, open, title, onClose, children, footer, width, max
|
|
|
404
414
|
]
|
|
405
415
|
});
|
|
406
416
|
};
|
|
407
|
-
|
|
408
|
-
//#region packages/ui/ConfirmDialog.tsx
|
|
417
|
+
// packages/ui/ConfirmDialog.tsx
|
|
409
418
|
function ConfirmDialog({ open, title, message, onConfirm, onCancel, confirmLabel, cancelLabel, variant = "warning" }) {
|
|
410
419
|
const strings = useUiStrings();
|
|
411
420
|
const cancelRef = (0, react.useRef)(null);
|
|
@@ -434,8 +443,7 @@ function ConfirmDialog({ open, title, message, onConfirm, onCancel, confirmLabel
|
|
|
434
443
|
})
|
|
435
444
|
});
|
|
436
445
|
}
|
|
437
|
-
|
|
438
|
-
//#region packages/ui/AppToolbar.tsx
|
|
446
|
+
// packages/ui/AppToolbar.tsx
|
|
439
447
|
const AppToolbar = ({ title, additionalToolbarContent, showRefreshButton = true, onRefresh, icon, refreshLabel = "Refresh", children }) => {
|
|
440
448
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
441
449
|
className: "view-wrapper view-wrapper-dashboard",
|
|
@@ -468,8 +476,7 @@ const AppToolbar = ({ title, additionalToolbarContent, showRefreshButton = true,
|
|
|
468
476
|
}), children]
|
|
469
477
|
});
|
|
470
478
|
};
|
|
471
|
-
|
|
472
|
-
//#region packages/ui/layoutUtils.ts
|
|
479
|
+
// packages/ui/layoutUtils.ts
|
|
473
480
|
function joinClasses(...parts) {
|
|
474
481
|
return parts.filter(Boolean).join(" ");
|
|
475
482
|
}
|
|
@@ -484,8 +491,7 @@ function colSpanClasses(span, spanSm, spanMd, spanLg) {
|
|
|
484
491
|
if (spanLg != null) classes.push(`nb-col--span-lg-${spanLg}`);
|
|
485
492
|
return classes;
|
|
486
493
|
}
|
|
487
|
-
|
|
488
|
-
//#region packages/ui/Card.tsx
|
|
494
|
+
// packages/ui/Card.tsx
|
|
489
495
|
const Card = ({ title, description, variant = "auth", className, children }) => {
|
|
490
496
|
const showHeader = Boolean(title || description);
|
|
491
497
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -505,8 +511,7 @@ const Card = ({ title, description, variant = "auth", className, children }) =>
|
|
|
505
511
|
})
|
|
506
512
|
});
|
|
507
513
|
};
|
|
508
|
-
|
|
509
|
-
//#region packages/ui/FormControls.tsx
|
|
514
|
+
// packages/ui/FormControls.tsx
|
|
510
515
|
const cx$1 = (...values) => values.filter(Boolean).join(" ");
|
|
511
516
|
const FormField = ({ label, error, helpText, children, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
512
517
|
...props,
|
|
@@ -549,8 +554,7 @@ const TextAreaField = (0, react.forwardRef)(function TextAreaField({ className,
|
|
|
549
554
|
className: cx$1("nb-input", "nb-textarea", invalid && "nb-input--invalid", className)
|
|
550
555
|
});
|
|
551
556
|
});
|
|
552
|
-
|
|
553
|
-
//#region packages/ui/FileDropzone.tsx
|
|
557
|
+
// packages/ui/FileDropzone.tsx
|
|
554
558
|
function cx(...values) {
|
|
555
559
|
return values.filter(Boolean).join(" ");
|
|
556
560
|
}
|
|
@@ -690,8 +694,7 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
|
|
|
690
694
|
})]
|
|
691
695
|
});
|
|
692
696
|
}
|
|
693
|
-
|
|
694
|
-
//#region packages/ui/AppDropdown.tsx
|
|
697
|
+
// packages/ui/AppDropdown.tsx
|
|
695
698
|
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 }) {
|
|
696
699
|
const generatedId = (0, react.useId)();
|
|
697
700
|
const id = idProp ?? generatedId;
|
|
@@ -830,8 +833,7 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
|
|
|
830
833
|
})
|
|
831
834
|
});
|
|
832
835
|
}
|
|
833
|
-
|
|
834
|
-
//#region packages/ui/useComboboxOptions.ts
|
|
836
|
+
// packages/ui/useComboboxOptions.ts
|
|
835
837
|
function mergeOptions(...groups) {
|
|
836
838
|
const map = /* @__PURE__ */ new Map();
|
|
837
839
|
for (const group of groups) for (const option of group) map.set(option.value, option);
|
|
@@ -968,8 +970,7 @@ function useComboboxOptions({ options, selected, loadOptions, open, query, debou
|
|
|
968
970
|
retry: () => setRevision((previous) => previous + 1)
|
|
969
971
|
};
|
|
970
972
|
}
|
|
971
|
-
|
|
972
|
-
//#region packages/ui/Combobox.tsx
|
|
973
|
+
// packages/ui/Combobox.tsx
|
|
973
974
|
const Combobox = (0, react.forwardRef)(function Combobox(props, ref) {
|
|
974
975
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectionCombobox, {
|
|
975
976
|
...props,
|
|
@@ -1194,8 +1195,7 @@ function ComboboxClear({ label, disabled, multiple }) {
|
|
|
1194
1195
|
})
|
|
1195
1196
|
});
|
|
1196
1197
|
}
|
|
1197
|
-
|
|
1198
|
-
//#region packages/ui/SearchableAppDropdown.tsx
|
|
1198
|
+
// packages/ui/SearchableAppDropdown.tsx
|
|
1199
1199
|
const toOption = (option) => ({
|
|
1200
1200
|
value: option.value,
|
|
1201
1201
|
label: option.selectedLabel ?? option.label,
|
|
@@ -1246,8 +1246,7 @@ function SearchableAppDropdown({ options = [], searchable = true, searchPlacehol
|
|
|
1246
1246
|
loadingMessage: loadingLabel
|
|
1247
1247
|
});
|
|
1248
1248
|
}
|
|
1249
|
-
|
|
1250
|
-
//#region packages/ui/theme/ThemeProvider.tsx
|
|
1249
|
+
// packages/ui/theme/ThemeProvider.tsx
|
|
1251
1250
|
const ThemeContext = react.default.createContext(null);
|
|
1252
1251
|
function useTheme() {
|
|
1253
1252
|
const ctx = (0, react.useContext)(ThemeContext);
|
|
@@ -1369,8 +1368,7 @@ const ThemeProvider = ({ storageKey = "nb-theme", themePrefix = "nb-theme-", bas
|
|
|
1369
1368
|
children
|
|
1370
1369
|
});
|
|
1371
1370
|
};
|
|
1372
|
-
|
|
1373
|
-
//#region packages/ui/theme/ThemeSwitcher.tsx
|
|
1371
|
+
// packages/ui/theme/ThemeSwitcher.tsx
|
|
1374
1372
|
const iconByMode = {
|
|
1375
1373
|
light: "ph ph-sun",
|
|
1376
1374
|
dark: "ph ph-moon",
|
|
@@ -1394,8 +1392,7 @@ const ThemeSwitcher = ({ labelByMode: overrides } = {}) => {
|
|
|
1394
1392
|
onClick: switchTheme
|
|
1395
1393
|
}) });
|
|
1396
1394
|
};
|
|
1397
|
-
|
|
1398
|
-
//#region packages/ui/theme/DensityProvider.tsx
|
|
1395
|
+
// packages/ui/theme/DensityProvider.tsx
|
|
1399
1396
|
const DensityContext = (0, react.createContext)(null);
|
|
1400
1397
|
function useDensity() {
|
|
1401
1398
|
const ctx = (0, react.useContext)(DensityContext);
|
|
@@ -1423,8 +1420,7 @@ const DensityProvider = ({ children }) => {
|
|
|
1423
1420
|
children
|
|
1424
1421
|
});
|
|
1425
1422
|
};
|
|
1426
|
-
|
|
1427
|
-
//#region packages/ui/theme/useAccentColor.ts
|
|
1423
|
+
// packages/ui/theme/useAccentColor.ts
|
|
1428
1424
|
const ACCENT_PRESETS = [
|
|
1429
1425
|
{
|
|
1430
1426
|
label: "Azure",
|
|
@@ -1476,8 +1472,7 @@ function useAccentColor() {
|
|
|
1476
1472
|
presets: ACCENT_PRESETS
|
|
1477
1473
|
};
|
|
1478
1474
|
}
|
|
1479
|
-
|
|
1480
|
-
//#region packages/ui/SettingsPanel.tsx
|
|
1475
|
+
// packages/ui/SettingsPanel.tsx
|
|
1481
1476
|
const SettingsPanel = ({ onClose: _onClose }) => {
|
|
1482
1477
|
const strings = useUiStrings();
|
|
1483
1478
|
const { density, toggleDensity } = useDensity();
|
|
@@ -1540,8 +1535,7 @@ const SettingsPanel = ({ onClose: _onClose }) => {
|
|
|
1540
1535
|
]
|
|
1541
1536
|
});
|
|
1542
1537
|
};
|
|
1543
|
-
|
|
1544
|
-
//#region packages/ui/Badge.tsx
|
|
1538
|
+
// packages/ui/Badge.tsx
|
|
1545
1539
|
const Badge = ({ variant = "primary", size = "md", outlined = false, pill = true, dot = false, children, className }) => {
|
|
1546
1540
|
const classes = [
|
|
1547
1541
|
"nb-badge",
|
|
@@ -1557,8 +1551,7 @@ const Badge = ({ variant = "primary", size = "md", outlined = false, pill = true
|
|
|
1557
1551
|
children: dot ? null : children
|
|
1558
1552
|
});
|
|
1559
1553
|
};
|
|
1560
|
-
|
|
1561
|
-
//#region packages/ui/FeatureGate.tsx
|
|
1554
|
+
// packages/ui/FeatureGate.tsx
|
|
1562
1555
|
function FeatureGate({ featureKey, children, enabled = false, behavior = "lock", planBadge = "Pro", upgradeMessage, upgradeUrl = "/settings", lockTooltip }) {
|
|
1563
1556
|
const strings = useUiStrings();
|
|
1564
1557
|
const tooltip = lockTooltip ?? strings.featureUnavailable;
|
|
@@ -1632,8 +1625,7 @@ function UpgradeGate({ planBadge, upgradeMessage, upgradeUrl, children }) {
|
|
|
1632
1625
|
]
|
|
1633
1626
|
});
|
|
1634
1627
|
}
|
|
1635
|
-
|
|
1636
|
-
//#region packages/ui/Skeleton.tsx
|
|
1628
|
+
// packages/ui/Skeleton.tsx
|
|
1637
1629
|
const fmtSize = (v) => v === void 0 ? void 0 : typeof v === "number" ? `${v}px` : v;
|
|
1638
1630
|
const Skeleton = ({ variant = "rect", width, height, lines = 1, className }) => {
|
|
1639
1631
|
const base = [
|
|
@@ -1658,8 +1650,7 @@ const Skeleton = ({ variant = "rect", width, height, lines = 1, className }) =>
|
|
|
1658
1650
|
"aria-hidden": "true"
|
|
1659
1651
|
});
|
|
1660
1652
|
};
|
|
1661
|
-
|
|
1662
|
-
//#region packages/ui/EmptyState.tsx
|
|
1653
|
+
// packages/ui/EmptyState.tsx
|
|
1663
1654
|
const DEFAULT_ICONS = {
|
|
1664
1655
|
default: "folder-open",
|
|
1665
1656
|
danger: "warning-circle",
|
|
@@ -1702,8 +1693,7 @@ const EmptyState = ({ icon, illustration, variant = "default", title, descriptio
|
|
|
1702
1693
|
]
|
|
1703
1694
|
});
|
|
1704
1695
|
};
|
|
1705
|
-
|
|
1706
|
-
//#region packages/ui/Chip.tsx
|
|
1696
|
+
// packages/ui/Chip.tsx
|
|
1707
1697
|
/**
|
|
1708
1698
|
* Pill-shaped filter/tag chip. Stateless — caller controls `active`.
|
|
1709
1699
|
* Use for category filters, tag lists, and multi-select inputs.
|
|
@@ -1730,8 +1720,7 @@ const Chip = ({ label, active = false, count, icon, size = "md", disabled = fals
|
|
|
1730
1720
|
]
|
|
1731
1721
|
});
|
|
1732
1722
|
};
|
|
1733
|
-
|
|
1734
|
-
//#region packages/ui/Toggle.tsx
|
|
1723
|
+
// packages/ui/Toggle.tsx
|
|
1735
1724
|
/**
|
|
1736
1725
|
* Accessible toggle switch. Always controlled — pass `checked` + `onChange`.
|
|
1737
1726
|
* Renders a visually-hidden `<input type="checkbox">` with a custom track.
|
|
@@ -1761,8 +1750,7 @@ const Toggle = ({ checked, onChange, label, size = "md", disabled = false, "aria
|
|
|
1761
1750
|
children: [label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }), input]
|
|
1762
1751
|
});
|
|
1763
1752
|
};
|
|
1764
|
-
|
|
1765
|
-
//#region packages/ui/ContextMenu.tsx
|
|
1753
|
+
// packages/ui/ContextMenu.tsx
|
|
1766
1754
|
const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones", align = "right", className = "" }) => {
|
|
1767
1755
|
const container = useOverlayContainer();
|
|
1768
1756
|
const triggerRef = (0, react.useRef)(null);
|
|
@@ -1810,8 +1798,7 @@ const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones"
|
|
|
1810
1798
|
})
|
|
1811
1799
|
});
|
|
1812
1800
|
};
|
|
1813
|
-
|
|
1814
|
-
//#region packages/ui/StatCard.tsx
|
|
1801
|
+
// packages/ui/StatCard.tsx
|
|
1815
1802
|
/**
|
|
1816
1803
|
* General-purpose analytics / dashboard card.
|
|
1817
1804
|
* Replaces the legacy `shared/ui/card-analytics/CardAnalytics` component.
|
|
@@ -1836,8 +1823,7 @@ const StatCard = ({ title, headerExtra, menuVisible = true, menuItems = [{ label
|
|
|
1836
1823
|
children
|
|
1837
1824
|
})]
|
|
1838
1825
|
});
|
|
1839
|
-
|
|
1840
|
-
//#region packages/ui/KpiMetricRow.tsx
|
|
1826
|
+
// packages/ui/KpiMetricRow.tsx
|
|
1841
1827
|
function normalizeIcon$1(icon) {
|
|
1842
1828
|
if (!icon) return void 0;
|
|
1843
1829
|
if (icon.startsWith("ph ")) return icon;
|
|
@@ -1880,8 +1866,7 @@ function KpiMetricRow({ items, className = "", layout = "cards", density = "defa
|
|
|
1880
1866
|
})
|
|
1881
1867
|
});
|
|
1882
1868
|
}
|
|
1883
|
-
|
|
1884
|
-
//#region packages/ui/SegmentedControl.tsx
|
|
1869
|
+
// packages/ui/SegmentedControl.tsx
|
|
1885
1870
|
function SegmentedControl({ options, value, onChange, ariaLabel, className = "", size = "md" }) {
|
|
1886
1871
|
if (options.length === 0) return null;
|
|
1887
1872
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1901,8 +1886,7 @@ function SegmentedControl({ options, value, onChange, ariaLabel, className = "",
|
|
|
1901
1886
|
})
|
|
1902
1887
|
});
|
|
1903
1888
|
}
|
|
1904
|
-
|
|
1905
|
-
//#region packages/ui/FilterPanel.tsx
|
|
1889
|
+
// packages/ui/FilterPanel.tsx
|
|
1906
1890
|
function FilterPanel({ category, status, layout = "stacked", density = "default", className = "", testId }) {
|
|
1907
1891
|
const [search, setSearch] = (0, react.useState)("");
|
|
1908
1892
|
const threshold = category.searchThreshold ?? 10;
|
|
@@ -2011,8 +1995,7 @@ function FilterPanel({ category, status, layout = "stacked", density = "default"
|
|
|
2011
1995
|
})]
|
|
2012
1996
|
});
|
|
2013
1997
|
}
|
|
2014
|
-
|
|
2015
|
-
//#region packages/ui/ScopeTabs.tsx
|
|
1998
|
+
// packages/ui/ScopeTabs.tsx
|
|
2016
1999
|
/**
|
|
2017
2000
|
* Pill tabs for scoping a list view (warehouse, branch, period, etc.).
|
|
2018
2001
|
* Hides itself when there is at most one scope option.
|
|
@@ -2041,8 +2024,7 @@ function ScopeTabs({ options, selectedKey, onChange, allLabel = "Todos", ariaLab
|
|
|
2041
2024
|
}, option.key))]
|
|
2042
2025
|
});
|
|
2043
2026
|
}
|
|
2044
|
-
|
|
2045
|
-
//#region packages/ui/OperationCardGrid.tsx
|
|
2027
|
+
// packages/ui/OperationCardGrid.tsx
|
|
2046
2028
|
function normalizeIcon(icon) {
|
|
2047
2029
|
if (icon.startsWith("ph ")) return icon;
|
|
2048
2030
|
if (icon.startsWith("ph-")) return `ph ${icon}`;
|
|
@@ -2097,8 +2079,7 @@ function OperationCardGrid({ title, description, operations, className = "", tes
|
|
|
2097
2079
|
})]
|
|
2098
2080
|
});
|
|
2099
2081
|
}
|
|
2100
|
-
|
|
2101
|
-
//#region packages/ui/HubPanel.tsx
|
|
2082
|
+
// packages/ui/HubPanel.tsx
|
|
2102
2083
|
/**
|
|
2103
2084
|
* Card shell for feature-hub chrome above a CRUD grid (KPIs, scope tabs, filters).
|
|
2104
2085
|
*/
|
|
@@ -2109,8 +2090,7 @@ function HubPanel({ children, variant = "card", className = "", testId }) {
|
|
|
2109
2090
|
children
|
|
2110
2091
|
});
|
|
2111
2092
|
}
|
|
2112
|
-
|
|
2113
|
-
//#region packages/ui/CollapsibleSection.tsx
|
|
2093
|
+
// packages/ui/CollapsibleSection.tsx
|
|
2114
2094
|
/**
|
|
2115
2095
|
* Accessible collapsible section with a labelled header trigger.
|
|
2116
2096
|
*
|
|
@@ -2165,8 +2145,7 @@ const CollapsibleSection = ({ label, icon, open, onToggle, children, trailing, c
|
|
|
2165
2145
|
})]
|
|
2166
2146
|
});
|
|
2167
2147
|
};
|
|
2168
|
-
|
|
2169
|
-
//#region packages/ui/CalendarContent.tsx
|
|
2148
|
+
// packages/ui/CalendarContent.tsx
|
|
2170
2149
|
/** Shared presentation; React Aria owns navigation, focus and range preview. */
|
|
2171
2150
|
function CalendarContent() {
|
|
2172
2151
|
const strings = useUiStrings();
|
|
@@ -2235,8 +2214,7 @@ function CalendarDialog({ id, ariaLabel, children }) {
|
|
|
2235
2214
|
children
|
|
2236
2215
|
});
|
|
2237
2216
|
}
|
|
2238
|
-
|
|
2239
|
-
//#region packages/ui/dateValues.ts
|
|
2217
|
+
// packages/ui/dateValues.ts
|
|
2240
2218
|
const getDateLocale = (locale) => locale || typeof document !== "undefined" && document.documentElement.lang || typeof navigator !== "undefined" && navigator.language || "en-US";
|
|
2241
2219
|
const calendarDate = (value) => {
|
|
2242
2220
|
if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
|
|
@@ -2291,8 +2269,7 @@ const parseDisplayDate = (text, locale) => {
|
|
|
2291
2269
|
const iso = `${fields.year}-${fields.month?.padStart(2, "0")}-${fields.day?.padStart(2, "0")}`;
|
|
2292
2270
|
return calendarDate(iso) ? iso : null;
|
|
2293
2271
|
};
|
|
2294
|
-
|
|
2295
|
-
//#region packages/ui/DateTextInput.tsx
|
|
2272
|
+
// packages/ui/DateTextInput.tsx
|
|
2296
2273
|
/** Keeps the real input/ref/ID contract used by CRUD forms. */
|
|
2297
2274
|
const DateTextInput = (0, react.forwardRef)(function DateTextInput({ value, locale, min, max, onChange, onOpen, onBlur, onKeyDown, ...props }, ref) {
|
|
2298
2275
|
const [draft, setDraft] = (0, react.useState)(null);
|
|
@@ -2335,8 +2312,7 @@ const DateTextInput = (0, react.forwardRef)(function DateTextInput({ value, loca
|
|
|
2335
2312
|
}
|
|
2336
2313
|
});
|
|
2337
2314
|
});
|
|
2338
|
-
|
|
2339
|
-
//#region packages/ui/useCalendarPopover.ts
|
|
2315
|
+
// packages/ui/useCalendarPopover.ts
|
|
2340
2316
|
/** Bridge focus restoration between React Aria's popup and a parent Base UI modal. */
|
|
2341
2317
|
function useCalendarPopover() {
|
|
2342
2318
|
const container = useOverlayContainer();
|
|
@@ -2377,8 +2353,7 @@ function useCalendarPopover() {
|
|
|
2377
2353
|
}, [container])
|
|
2378
2354
|
};
|
|
2379
2355
|
}
|
|
2380
|
-
|
|
2381
|
-
//#region packages/ui/DatePicker.tsx
|
|
2356
|
+
// packages/ui/DatePicker.tsx
|
|
2382
2357
|
const DatePicker = (0, react.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) {
|
|
2383
2358
|
const generatedId = (0, react.useId)();
|
|
2384
2359
|
const inputId = id ?? generatedId;
|
|
@@ -2504,8 +2479,7 @@ const DatePicker = (0, react.forwardRef)(function DatePicker({ id, name, value,
|
|
|
2504
2479
|
})
|
|
2505
2480
|
});
|
|
2506
2481
|
});
|
|
2507
|
-
|
|
2508
|
-
//#region packages/ui/DateRangePicker.tsx
|
|
2482
|
+
// packages/ui/DateRangePicker.tsx
|
|
2509
2483
|
function DateRangePicker({ startValue, endValue, placeholder, disabled = false, clearable = true, readOnly = false, required = false, invalid = false, locale, min, max, className, ariaLabel, onChange, onBlur }) {
|
|
2510
2484
|
const { container, groupRef, panelRef, open, setOpen } = useCalendarPopover();
|
|
2511
2485
|
const strings = useUiStrings();
|
|
@@ -2636,8 +2610,7 @@ function DateRangePicker({ startValue, endValue, placeholder, disabled = false,
|
|
|
2636
2610
|
})
|
|
2637
2611
|
});
|
|
2638
2612
|
}
|
|
2639
|
-
|
|
2640
|
-
//#region packages/ui/Popover.tsx
|
|
2613
|
+
// packages/ui/Popover.tsx
|
|
2641
2614
|
const Popover = ({ trigger, panel, align = "end", ariaLabel, className }) => {
|
|
2642
2615
|
const [open, setOpen] = (0, react.useState)(false);
|
|
2643
2616
|
const triggerRef = (0, react.useRef)(null);
|
|
@@ -2697,8 +2670,7 @@ const Popover = ({ trigger, panel, align = "end", ariaLabel, className }) => {
|
|
|
2697
2670
|
})
|
|
2698
2671
|
});
|
|
2699
2672
|
};
|
|
2700
|
-
|
|
2701
|
-
//#region packages/ui/useFloatingPanel.ts
|
|
2673
|
+
// packages/ui/useFloatingPanel.ts
|
|
2702
2674
|
/** Style applied to an anchored panel before its first position is computed. */
|
|
2703
2675
|
const HIDDEN_PANEL_STYLE = {
|
|
2704
2676
|
position: "fixed",
|
|
@@ -2799,8 +2771,7 @@ function useFloatingPanel(options = {}) {
|
|
|
2799
2771
|
panelStyle
|
|
2800
2772
|
};
|
|
2801
2773
|
}
|
|
2802
|
-
|
|
2803
|
-
//#region packages/ui/Drawer.tsx
|
|
2774
|
+
// packages/ui/Drawer.tsx
|
|
2804
2775
|
const formatWidth = (value) => {
|
|
2805
2776
|
if (value === void 0) return void 0;
|
|
2806
2777
|
return typeof value === "number" ? `${value}px` : value;
|
|
@@ -2853,8 +2824,7 @@ const Drawer = ({ isOpen, busy = false, onClose, title, width, side = "right", s
|
|
|
2853
2824
|
]
|
|
2854
2825
|
});
|
|
2855
2826
|
};
|
|
2856
|
-
|
|
2857
|
-
//#region packages/ui/Timeline.tsx
|
|
2827
|
+
// packages/ui/Timeline.tsx
|
|
2858
2828
|
const TimelineVariantContext = (0, react.createContext)("stepper");
|
|
2859
2829
|
function useTimelineVariant() {
|
|
2860
2830
|
return (0, react.useContext)(TimelineVariantContext);
|
|
@@ -2950,8 +2920,7 @@ function Timeline({ variant = "stepper", orientation = "vertical", title, descri
|
|
|
2950
2920
|
})
|
|
2951
2921
|
});
|
|
2952
2922
|
}
|
|
2953
|
-
|
|
2954
|
-
//#region packages/ui/Page.tsx
|
|
2923
|
+
// packages/ui/Page.tsx
|
|
2955
2924
|
function Page({ children, fill, wide, narrow, gap = 5, className, ...props }) {
|
|
2956
2925
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2957
2926
|
className: joinClasses("nb-page", fill && "nb-page--fill", wide && "nb-page--wide", narrow && "nb-page--narrow", gapClass("nb-page", gap), className),
|
|
@@ -2959,8 +2928,7 @@ function Page({ children, fill, wide, narrow, gap = 5, className, ...props }) {
|
|
|
2959
2928
|
children
|
|
2960
2929
|
});
|
|
2961
2930
|
}
|
|
2962
|
-
|
|
2963
|
-
//#region packages/ui/PageHeader.tsx
|
|
2931
|
+
// packages/ui/PageHeader.tsx
|
|
2964
2932
|
function PageHeader({ title, subtitle, metadata, breadcrumb, breadcrumbSlot, badge, actions, className }) {
|
|
2965
2933
|
const breadcrumbNode = breadcrumbSlot ?? (breadcrumb ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
2966
2934
|
href: breadcrumb.href,
|
|
@@ -2999,8 +2967,7 @@ function PageHeader({ title, subtitle, metadata, breadcrumb, breadcrumbSlot, bad
|
|
|
2999
2967
|
})]
|
|
3000
2968
|
});
|
|
3001
2969
|
}
|
|
3002
|
-
|
|
3003
|
-
//#region packages/ui/Stack.tsx
|
|
2970
|
+
// packages/ui/Stack.tsx
|
|
3004
2971
|
function Stack({ children, gap = 4, align, justify, fill, className, ...props }) {
|
|
3005
2972
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3006
2973
|
className: joinClasses("nb-stack", gapClass("nb-stack", gap), align && `nb-stack--align-${align}`, justify && `nb-stack--justify-${justify}`, fill && "nb-stack--fill", className),
|
|
@@ -3008,8 +2975,7 @@ function Stack({ children, gap = 4, align, justify, fill, className, ...props })
|
|
|
3008
2975
|
children
|
|
3009
2976
|
});
|
|
3010
2977
|
}
|
|
3011
|
-
|
|
3012
|
-
//#region packages/ui/Row.tsx
|
|
2978
|
+
// packages/ui/Row.tsx
|
|
3013
2979
|
function Row({ children, gap = 2, align, justify, wrap, fill, className, ...props }) {
|
|
3014
2980
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3015
2981
|
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),
|
|
@@ -3017,8 +2983,7 @@ function Row({ children, gap = 2, align, justify, wrap, fill, className, ...prop
|
|
|
3017
2983
|
children
|
|
3018
2984
|
});
|
|
3019
2985
|
}
|
|
3020
|
-
|
|
3021
|
-
//#region packages/ui/Cluster.tsx
|
|
2986
|
+
// packages/ui/Cluster.tsx
|
|
3022
2987
|
/** Inline flex row that wraps — ideal for button groups and filter actions. */
|
|
3023
2988
|
function Cluster({ children, gap = 2, className, ...props }) {
|
|
3024
2989
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3027,8 +2992,7 @@ function Cluster({ children, gap = 2, className, ...props }) {
|
|
|
3027
2992
|
children
|
|
3028
2993
|
});
|
|
3029
2994
|
}
|
|
3030
|
-
|
|
3031
|
-
//#region packages/ui/Grid.tsx
|
|
2995
|
+
// packages/ui/Grid.tsx
|
|
3032
2996
|
function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, style, ...props }) {
|
|
3033
2997
|
const gridStyle = {
|
|
3034
2998
|
...style,
|
|
@@ -3042,8 +3006,7 @@ function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, styl
|
|
|
3042
3006
|
children
|
|
3043
3007
|
});
|
|
3044
3008
|
}
|
|
3045
|
-
|
|
3046
|
-
//#region packages/ui/Col.tsx
|
|
3009
|
+
// packages/ui/Col.tsx
|
|
3047
3010
|
function Col({ children, span, spanSm, spanMd, spanLg, fullWidth, className, ...props }) {
|
|
3048
3011
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3049
3012
|
className: joinClasses(...colSpanClasses(span, spanSm, spanMd, spanLg), fullWidth && "nb-span-full", className),
|
|
@@ -3051,8 +3014,7 @@ function Col({ children, span, spanSm, spanMd, spanLg, fullWidth, className, ...
|
|
|
3051
3014
|
children
|
|
3052
3015
|
});
|
|
3053
3016
|
}
|
|
3054
|
-
|
|
3055
|
-
//#region packages/ui/Section.tsx
|
|
3017
|
+
// packages/ui/Section.tsx
|
|
3056
3018
|
function Section({ title, children, className, variant = "label" }) {
|
|
3057
3019
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3058
3020
|
className: joinClasses("nb-section", variant === "panel" && "nb-section--panel", className),
|
|
@@ -3062,8 +3024,7 @@ function Section({ title, children, className, variant = "label" }) {
|
|
|
3062
3024
|
}), children]
|
|
3063
3025
|
});
|
|
3064
3026
|
}
|
|
3065
|
-
|
|
3066
|
-
//#region packages/ui/FormLayout.tsx
|
|
3027
|
+
// packages/ui/FormLayout.tsx
|
|
3067
3028
|
function FormLayout({ children, variant = "stack", minColWidth, className, style, ...props }) {
|
|
3068
3029
|
const formStyle = {
|
|
3069
3030
|
...style,
|
|
@@ -3076,16 +3037,14 @@ function FormLayout({ children, variant = "stack", minColWidth, className, style
|
|
|
3076
3037
|
children
|
|
3077
3038
|
});
|
|
3078
3039
|
}
|
|
3079
|
-
|
|
3080
|
-
//#region packages/ui/FormActions.tsx
|
|
3040
|
+
// packages/ui/FormActions.tsx
|
|
3081
3041
|
function FormActions({ children, className }) {
|
|
3082
3042
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3083
3043
|
className: joinClasses("nb-form-actions", className),
|
|
3084
3044
|
children
|
|
3085
3045
|
});
|
|
3086
3046
|
}
|
|
3087
|
-
|
|
3088
|
-
//#region packages/ui/Alert.tsx
|
|
3047
|
+
// packages/ui/Alert.tsx
|
|
3089
3048
|
const ICONS = {
|
|
3090
3049
|
danger: "ph-warning-circle",
|
|
3091
3050
|
warning: "ph-warning",
|
|
@@ -3101,8 +3060,7 @@ function Alert({ tone = "info", children, className }) {
|
|
|
3101
3060
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children })]
|
|
3102
3061
|
});
|
|
3103
3062
|
}
|
|
3104
|
-
|
|
3105
|
-
//#region packages/ui/DescriptionList.tsx
|
|
3063
|
+
// packages/ui/DescriptionList.tsx
|
|
3106
3064
|
function DescriptionList({ items, className }) {
|
|
3107
3065
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
3108
3066
|
className: joinClasses("nb-description-list", className),
|
|
@@ -3112,16 +3070,14 @@ function DescriptionList({ items, className }) {
|
|
|
3112
3070
|
}, item.term))
|
|
3113
3071
|
});
|
|
3114
3072
|
}
|
|
3115
|
-
|
|
3116
|
-
//#region packages/ui/Code.tsx
|
|
3073
|
+
// packages/ui/Code.tsx
|
|
3117
3074
|
function Code({ children, className }) {
|
|
3118
3075
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
3119
3076
|
className: joinClasses("nb-code", className),
|
|
3120
3077
|
children
|
|
3121
3078
|
});
|
|
3122
3079
|
}
|
|
3123
|
-
|
|
3124
|
-
//#region packages/ui/Text.tsx
|
|
3080
|
+
// packages/ui/Text.tsx
|
|
3125
3081
|
function Text({ children, tone = "default", as: Tag = "span", className, ...props }) {
|
|
3126
3082
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {
|
|
3127
3083
|
className: joinClasses(tone === "muted" && "nb-text-muted", className),
|
|
@@ -3129,8 +3085,7 @@ function Text({ children, tone = "default", as: Tag = "span", className, ...prop
|
|
|
3129
3085
|
children
|
|
3130
3086
|
});
|
|
3131
3087
|
}
|
|
3132
|
-
|
|
3133
|
-
//#region packages/ui/Pagination.tsx
|
|
3088
|
+
// packages/ui/Pagination.tsx
|
|
3134
3089
|
function Pagination({ page, totalPages, onPageChange, ariaLabel, maxVisible = 7, className }) {
|
|
3135
3090
|
const strings = useUiStrings();
|
|
3136
3091
|
if (totalPages <= 1) return null;
|
|
@@ -3170,8 +3125,7 @@ function Pagination({ page, totalPages, onPageChange, ariaLabel, maxVisible = 7,
|
|
|
3170
3125
|
]
|
|
3171
3126
|
});
|
|
3172
3127
|
}
|
|
3173
|
-
|
|
3174
|
-
//#region packages/ui/RowActions.tsx
|
|
3128
|
+
// packages/ui/RowActions.tsx
|
|
3175
3129
|
/** Context menu preset for table row overflow actions. */
|
|
3176
3130
|
function RowActions({ items, triggerLabel, align = "right", className }) {
|
|
3177
3131
|
const strings = useUiStrings();
|
|
@@ -3184,8 +3138,7 @@ function RowActions({ items, triggerLabel, align = "right", className }) {
|
|
|
3184
3138
|
visible: true
|
|
3185
3139
|
});
|
|
3186
3140
|
}
|
|
3187
|
-
|
|
3188
|
-
//#region packages/ui/DataTable.tsx
|
|
3141
|
+
// packages/ui/DataTable.tsx
|
|
3189
3142
|
function alignClass(align) {
|
|
3190
3143
|
if (align === "right") return "nb-data-table__cell--num";
|
|
3191
3144
|
if (align === "center") return "nb-data-table__cell--center";
|
|
@@ -3229,8 +3182,7 @@ function DataTable({ columns, rows, getRowKey, emptyMessage, fill, variant = "de
|
|
|
3229
3182
|
})
|
|
3230
3183
|
}), pagination && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pagination, { ...pagination })] });
|
|
3231
3184
|
}
|
|
3232
|
-
|
|
3233
|
-
//#region packages/ui/useConfirm.tsx
|
|
3185
|
+
// packages/ui/useConfirm.tsx
|
|
3234
3186
|
function useConfirm() {
|
|
3235
3187
|
const strings = useUiStrings();
|
|
3236
3188
|
const [pending, setPending] = (0, react.useState)(null);
|
|
@@ -3257,8 +3209,7 @@ function useConfirm() {
|
|
|
3257
3209
|
ConfirmHost
|
|
3258
3210
|
};
|
|
3259
3211
|
}
|
|
3260
|
-
|
|
3261
|
-
//#region packages/ui/Checkbox.tsx
|
|
3212
|
+
// packages/ui/Checkbox.tsx
|
|
3262
3213
|
/** Native checkbox, including the mixed state used by bulk selection. */
|
|
3263
3214
|
const Checkbox = (0, react.forwardRef)(function Checkbox({ label, indeterminate = false, invalid = false, id, className, ...props }, ref) {
|
|
3264
3215
|
const generatedId = (0, react.useId)();
|
|
@@ -3281,8 +3232,7 @@ const Checkbox = (0, react.forwardRef)(function Checkbox({ label, indeterminate
|
|
|
3281
3232
|
}), label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label })]
|
|
3282
3233
|
});
|
|
3283
3234
|
});
|
|
3284
|
-
|
|
3285
|
-
//#region packages/ui/RadioGroup.tsx
|
|
3235
|
+
// packages/ui/RadioGroup.tsx
|
|
3286
3236
|
/** Native radios share a name for browser keyboard navigation and form submission. */
|
|
3287
3237
|
function RadioGroup({ label, name, value, options, onChange, orientation = "vertical", required, invalid = false, disabled, className, ...props }) {
|
|
3288
3238
|
const generatedName = (0, react.useId)();
|
|
@@ -3308,8 +3258,7 @@ function RadioGroup({ label, name, value, options, onChange, orientation = "vert
|
|
|
3308
3258
|
})]
|
|
3309
3259
|
});
|
|
3310
3260
|
}
|
|
3311
|
-
|
|
3312
|
-
//#region packages/ui/Tabs.tsx
|
|
3261
|
+
// packages/ui/Tabs.tsx
|
|
3313
3262
|
function Tabs({ items, value, onChange, "aria-label": ariaLabel, orientation = "horizontal", activationMode = "automatic", keepMounted = false, className }) {
|
|
3314
3263
|
const id = (0, react.useId)();
|
|
3315
3264
|
const listRef = (0, react.useRef)(null);
|
|
@@ -3365,8 +3314,7 @@ function Tabs({ items, value, onChange, "aria-label": ariaLabel, orientation = "
|
|
|
3365
3314
|
}, item.value))]
|
|
3366
3315
|
});
|
|
3367
3316
|
}
|
|
3368
|
-
|
|
3369
|
-
//#region packages/ui/Spinner.tsx
|
|
3317
|
+
// packages/ui/Spinner.tsx
|
|
3370
3318
|
function Spinner({ label, size = "md", className, ...props }) {
|
|
3371
3319
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3372
3320
|
...props,
|
|
@@ -3376,8 +3324,7 @@ function Spinner({ label, size = "md", className, ...props }) {
|
|
|
3376
3324
|
"aria-hidden": label ? void 0 : true
|
|
3377
3325
|
});
|
|
3378
3326
|
}
|
|
3379
|
-
|
|
3380
|
-
//#region packages/ui/Progress.tsx
|
|
3327
|
+
// packages/ui/Progress.tsx
|
|
3381
3328
|
/** Omit value for indeterminate progress; max defaults to 100. */
|
|
3382
3329
|
function Progress({ label, id, max = 100, className, ...props }) {
|
|
3383
3330
|
const generatedId = (0, react.useId)();
|
|
@@ -3395,8 +3342,7 @@ function Progress({ label, id, max = 100, className, ...props }) {
|
|
|
3395
3342
|
})]
|
|
3396
3343
|
});
|
|
3397
3344
|
}
|
|
3398
|
-
|
|
3399
|
-
//#region packages/ui/Tooltip.tsx
|
|
3345
|
+
// packages/ui/Tooltip.tsx
|
|
3400
3346
|
const TooltipProvider = _base_ui_react_tooltip.Tooltip.Provider;
|
|
3401
3347
|
/** Uses the existing child as the trigger without adding a nested button. */
|
|
3402
3348
|
function Tooltip({ children, content, side = "top", delay, disabled, className }) {
|
|
@@ -3433,8 +3379,7 @@ function Tooltip({ children, content, side = "top", delay, disabled, className }
|
|
|
3433
3379
|
})]
|
|
3434
3380
|
});
|
|
3435
3381
|
}
|
|
3436
|
-
|
|
3437
|
-
//#region packages/ui/TimePicker.tsx
|
|
3382
|
+
// packages/ui/TimePicker.tsx
|
|
3438
3383
|
const timeValue = (value) => {
|
|
3439
3384
|
if (!value) return null;
|
|
3440
3385
|
try {
|
|
@@ -3476,8 +3421,7 @@ const TimePicker = (0, react.forwardRef)(function TimePicker({ id, name, value,
|
|
|
3476
3421
|
})
|
|
3477
3422
|
});
|
|
3478
3423
|
});
|
|
3479
|
-
|
|
3480
|
-
//#region packages/ui/DetailLayout.tsx
|
|
3424
|
+
// packages/ui/DetailLayout.tsx
|
|
3481
3425
|
/** Responsive main/aside composition for record detail pages. */
|
|
3482
3426
|
function DetailLayout({ children, aside, asideLabel, className }) {
|
|
3483
3427
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3492,7 +3436,577 @@ function DetailLayout({ children, aside, asideLabel, className }) {
|
|
|
3492
3436
|
})]
|
|
3493
3437
|
});
|
|
3494
3438
|
}
|
|
3495
|
-
|
|
3439
|
+
// packages/ui/treeListModel.ts
|
|
3440
|
+
/**
|
|
3441
|
+
* Normalizes either nested records or a flat parentId collection into a
|
|
3442
|
+
* deterministic tree. A record may not be supplied through both relationships.
|
|
3443
|
+
*/
|
|
3444
|
+
function buildTreeListModel(items, options) {
|
|
3445
|
+
const { getId, getParentId, getChildren } = options;
|
|
3446
|
+
const records = /* @__PURE__ */ new Map();
|
|
3447
|
+
const nestedChildren = /* @__PURE__ */ new Map();
|
|
3448
|
+
const visitNested = (item, ancestors) => {
|
|
3449
|
+
const id = getId(item);
|
|
3450
|
+
if (records.has(id)) throw new Error(`TreeList contains duplicate id "${id}".`);
|
|
3451
|
+
if (ancestors.has(id)) throw new Error(`TreeList contains a cycle at id "${id}".`);
|
|
3452
|
+
records.set(id, item);
|
|
3453
|
+
const children = getChildren?.(item) ?? [];
|
|
3454
|
+
const nextAncestors = new Set(ancestors).add(id);
|
|
3455
|
+
const childIds = [];
|
|
3456
|
+
for (const child of children) {
|
|
3457
|
+
const childId = getId(child);
|
|
3458
|
+
childIds.push(childId);
|
|
3459
|
+
visitNested(child, nextAncestors);
|
|
3460
|
+
}
|
|
3461
|
+
nestedChildren.set(id, childIds);
|
|
3462
|
+
};
|
|
3463
|
+
for (const item of items) visitNested(item, /* @__PURE__ */ new Set());
|
|
3464
|
+
const nestedIds = /* @__PURE__ */ new Set();
|
|
3465
|
+
for (const ids of nestedChildren.values()) for (const id of ids) nestedIds.add(id);
|
|
3466
|
+
const parentById = /* @__PURE__ */ new Map();
|
|
3467
|
+
for (const [id, item] of records) {
|
|
3468
|
+
const parentId = getParentId?.(item);
|
|
3469
|
+
if (parentId != null && nestedIds.has(id)) throw new Error(`TreeList record "${id}" has both nested and parentId relationships.`);
|
|
3470
|
+
parentById.set(id, parentId == null ? null : parentId);
|
|
3471
|
+
}
|
|
3472
|
+
for (const [parentId, childIds] of nestedChildren) for (const childId of childIds) parentById.set(childId, parentId);
|
|
3473
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
3474
|
+
for (const [id, parentId] of parentById) {
|
|
3475
|
+
if (parentId != null && !records.has(parentId)) throw new Error(`TreeList record "${id}" refers to missing parent "${parentId}".`);
|
|
3476
|
+
const siblings = childrenByParent.get(parentId) ?? [];
|
|
3477
|
+
siblings.push(id);
|
|
3478
|
+
childrenByParent.set(parentId, siblings);
|
|
3479
|
+
}
|
|
3480
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
3481
|
+
const built = /* @__PURE__ */ new Map();
|
|
3482
|
+
const makeNode = (id, depth) => {
|
|
3483
|
+
if (visiting.has(id)) throw new Error(`TreeList contains a parentId cycle at id "${id}".`);
|
|
3484
|
+
const existing = built.get(id);
|
|
3485
|
+
if (existing) return existing;
|
|
3486
|
+
visiting.add(id);
|
|
3487
|
+
const node = {
|
|
3488
|
+
id,
|
|
3489
|
+
item: records.get(id),
|
|
3490
|
+
depth,
|
|
3491
|
+
children: (childrenByParent.get(id) ?? []).map((childId) => makeNode(childId, depth + 1))
|
|
3492
|
+
};
|
|
3493
|
+
visiting.delete(id);
|
|
3494
|
+
built.set(id, node);
|
|
3495
|
+
return node;
|
|
3496
|
+
};
|
|
3497
|
+
const result = (childrenByParent.get(null) ?? []).map((id) => makeNode(id, 0));
|
|
3498
|
+
if (built.size !== records.size) {
|
|
3499
|
+
const orphanedCycle = [...records.keys()].find((id) => !built.has(id));
|
|
3500
|
+
throw new Error(`TreeList contains an unreachable parentId cycle at id "${orphanedCycle}".`);
|
|
3501
|
+
}
|
|
3502
|
+
return result;
|
|
3503
|
+
}
|
|
3504
|
+
function flattenVisibleTree(roots, expandedIds) {
|
|
3505
|
+
const visible = [];
|
|
3506
|
+
const visit = (node) => {
|
|
3507
|
+
visible.push(node);
|
|
3508
|
+
if (expandedIds.has(node.id)) node.children.forEach(visit);
|
|
3509
|
+
};
|
|
3510
|
+
roots.forEach(visit);
|
|
3511
|
+
return visible;
|
|
3512
|
+
}
|
|
3513
|
+
function getDescendantIds(node) {
|
|
3514
|
+
const ids = [];
|
|
3515
|
+
const visit = (current) => {
|
|
3516
|
+
for (const child of current.children) {
|
|
3517
|
+
ids.push(child.id);
|
|
3518
|
+
visit(child);
|
|
3519
|
+
}
|
|
3520
|
+
};
|
|
3521
|
+
visit(node);
|
|
3522
|
+
return ids;
|
|
3523
|
+
}
|
|
3524
|
+
// packages/ui/TreeList.tsx
|
|
3525
|
+
function itemValue(column, item) {
|
|
3526
|
+
if (column.value) return column.value(item);
|
|
3527
|
+
return item[column.id];
|
|
3528
|
+
}
|
|
3529
|
+
function compareValues(left, right) {
|
|
3530
|
+
if (left == null) return right == null ? 0 : -1;
|
|
3531
|
+
if (right == null) return 1;
|
|
3532
|
+
if (typeof left === "number" && typeof right === "number") return left - right;
|
|
3533
|
+
return String(left).localeCompare(String(right), void 0, {
|
|
3534
|
+
numeric: true,
|
|
3535
|
+
sensitivity: "base"
|
|
3536
|
+
});
|
|
3537
|
+
}
|
|
3538
|
+
function filterTree(nodes, query, columns) {
|
|
3539
|
+
if (!query) return [...nodes];
|
|
3540
|
+
const normalizedQuery = query.toLocaleLowerCase();
|
|
3541
|
+
const result = [];
|
|
3542
|
+
for (const node of nodes) {
|
|
3543
|
+
const children = filterTree(node.children, query, columns);
|
|
3544
|
+
if (columns.some((column) => String(itemValue(column, node.item) ?? "").toLocaleLowerCase().includes(normalizedQuery)) || children.length > 0) result.push({
|
|
3545
|
+
...node,
|
|
3546
|
+
children
|
|
3547
|
+
});
|
|
3548
|
+
}
|
|
3549
|
+
return result;
|
|
3550
|
+
}
|
|
3551
|
+
function sortTree(nodes, column, direction) {
|
|
3552
|
+
const result = nodes.map((node) => ({
|
|
3553
|
+
...node,
|
|
3554
|
+
children: sortTree(node.children, column, direction)
|
|
3555
|
+
}));
|
|
3556
|
+
if (!column || !direction) return result;
|
|
3557
|
+
const multiplier = direction === "asc" ? 1 : -1;
|
|
3558
|
+
return result.sort((left, right) => multiplier * compareValues(itemValue(column, left.item), itemValue(column, right.item)));
|
|
3559
|
+
}
|
|
3560
|
+
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 }) {
|
|
3561
|
+
const strings = useUiStrings();
|
|
3562
|
+
const [localItems, setLocalItems] = (0, react.useState)(items);
|
|
3563
|
+
const [localExpandedIds, setLocalExpandedIds] = (0, react.useState)(defaultExpandedIds);
|
|
3564
|
+
const [localSelectedIds, setLocalSelectedIds] = (0, react.useState)(defaultSelectedIds);
|
|
3565
|
+
const [localFilter, setLocalFilter] = (0, react.useState)("");
|
|
3566
|
+
const [sort, setSort] = (0, react.useState)(null);
|
|
3567
|
+
const [editingCell, setEditingCell] = (0, react.useState)(null);
|
|
3568
|
+
const [editValue, setEditValue] = (0, react.useState)("");
|
|
3569
|
+
const [moveError, setMoveError] = (0, react.useState)(false);
|
|
3570
|
+
const [loadingIds, setLoadingIds] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
3571
|
+
const [loadErrors, setLoadErrors] = (0, react.useState)(() => /* @__PURE__ */ new Map());
|
|
3572
|
+
const [editErrors, setEditErrors] = (0, react.useState)(() => /* @__PURE__ */ new Map());
|
|
3573
|
+
const controllers = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
3574
|
+
const rows = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
3575
|
+
const filter = controlledFilter ?? localFilter;
|
|
3576
|
+
const expandedIds = controlledExpandedIds ?? localExpandedIds;
|
|
3577
|
+
const selectedIds = controlledSelectedIds ?? localSelectedIds;
|
|
3578
|
+
react.default.useEffect(() => setLocalItems(items), [items]);
|
|
3579
|
+
react.default.useEffect(() => () => {
|
|
3580
|
+
controllers.current.forEach((controller) => controller.abort());
|
|
3581
|
+
controllers.current.clear();
|
|
3582
|
+
}, []);
|
|
3583
|
+
const modelOptions = (0, react.useMemo)(() => ({
|
|
3584
|
+
getId,
|
|
3585
|
+
getParentId,
|
|
3586
|
+
getChildren
|
|
3587
|
+
}), [
|
|
3588
|
+
getChildren,
|
|
3589
|
+
getId,
|
|
3590
|
+
getParentId
|
|
3591
|
+
]);
|
|
3592
|
+
const tree = (0, react.useMemo)(() => buildTreeListModel(localItems, modelOptions), [localItems, modelOptions]);
|
|
3593
|
+
const filteredTree = (0, react.useMemo)(() => filterTree(tree, filter.trim(), columns), [
|
|
3594
|
+
columns,
|
|
3595
|
+
filter,
|
|
3596
|
+
tree
|
|
3597
|
+
]);
|
|
3598
|
+
const sortColumn = sort ? columns.find((column) => column.id === sort.columnId) : void 0;
|
|
3599
|
+
const sortedTree = (0, react.useMemo)(() => sortTree(filteredTree, sortColumn, sort?.direction), [
|
|
3600
|
+
filteredTree,
|
|
3601
|
+
sort?.direction,
|
|
3602
|
+
sortColumn
|
|
3603
|
+
]);
|
|
3604
|
+
const filterExpandedIds = (0, react.useMemo)(() => {
|
|
3605
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3606
|
+
const visit = (node) => {
|
|
3607
|
+
if (node.children.length > 0) ids.add(node.id);
|
|
3608
|
+
node.children.forEach(visit);
|
|
3609
|
+
};
|
|
3610
|
+
sortedTree.forEach(visit);
|
|
3611
|
+
return ids;
|
|
3612
|
+
}, [sortedTree]);
|
|
3613
|
+
const visibleNodes = (0, react.useMemo)(() => flattenVisibleTree(sortedTree, filter.trim() ? filterExpandedIds : expandedIds), [
|
|
3614
|
+
expandedIds,
|
|
3615
|
+
filter,
|
|
3616
|
+
filterExpandedIds,
|
|
3617
|
+
sortedTree
|
|
3618
|
+
]);
|
|
3619
|
+
const effectiveExpandedIds = filter.trim() ? filterExpandedIds : expandedIds;
|
|
3620
|
+
const nodeById = (0, react.useMemo)(() => {
|
|
3621
|
+
const result = /* @__PURE__ */ new Map();
|
|
3622
|
+
const visit = (node) => {
|
|
3623
|
+
result.set(node.id, node);
|
|
3624
|
+
node.children.forEach(visit);
|
|
3625
|
+
};
|
|
3626
|
+
tree.forEach(visit);
|
|
3627
|
+
return result;
|
|
3628
|
+
}, [tree]);
|
|
3629
|
+
const updateExpanded = (0, react.useCallback)((next) => {
|
|
3630
|
+
if (controlledExpandedIds === void 0) setLocalExpandedIds(next);
|
|
3631
|
+
onExpandedIdsChange?.(next);
|
|
3632
|
+
}, [controlledExpandedIds, onExpandedIdsChange]);
|
|
3633
|
+
const updateSelected = (0, react.useCallback)((next) => {
|
|
3634
|
+
if (controlledSelectedIds === void 0) setLocalSelectedIds(next);
|
|
3635
|
+
onSelectedIdsChange?.(next);
|
|
3636
|
+
if (onSelectedItemsChange) onSelectedItemsChange([...next].flatMap((id) => {
|
|
3637
|
+
const node = nodeById.get(id);
|
|
3638
|
+
return node ? [node.item] : [];
|
|
3639
|
+
}));
|
|
3640
|
+
}, [
|
|
3641
|
+
controlledSelectedIds,
|
|
3642
|
+
nodeById,
|
|
3643
|
+
onSelectedIdsChange,
|
|
3644
|
+
onSelectedItemsChange
|
|
3645
|
+
]);
|
|
3646
|
+
const updateFilter = (value) => {
|
|
3647
|
+
if (controlledFilter === void 0) setLocalFilter(value);
|
|
3648
|
+
onFilterChange?.(value);
|
|
3649
|
+
};
|
|
3650
|
+
const expand = (0, react.useCallback)(async (node) => {
|
|
3651
|
+
const next = new Set(expandedIds);
|
|
3652
|
+
if (next.has(node.id) && !loadErrors.has(node.id)) {
|
|
3653
|
+
controllers.current.get(node.id)?.abort();
|
|
3654
|
+
next.delete(node.id);
|
|
3655
|
+
updateExpanded(next);
|
|
3656
|
+
return;
|
|
3657
|
+
}
|
|
3658
|
+
next.add(node.id);
|
|
3659
|
+
updateExpanded(next);
|
|
3660
|
+
if (!loadChildren || (hasChildren ? !hasChildren(node.item) : false) || node.children.length > 0) return;
|
|
3661
|
+
const controller = new AbortController();
|
|
3662
|
+
controllers.current.get(node.id)?.abort();
|
|
3663
|
+
controllers.current.set(node.id, controller);
|
|
3664
|
+
setLoadingIds((current) => new Set(current).add(node.id));
|
|
3665
|
+
setLoadErrors((current) => {
|
|
3666
|
+
const nextErrors = new Map(current);
|
|
3667
|
+
nextErrors.delete(node.id);
|
|
3668
|
+
return nextErrors;
|
|
3669
|
+
});
|
|
3670
|
+
try {
|
|
3671
|
+
const children = await loadChildren(node.item, { signal: controller.signal });
|
|
3672
|
+
if (controller.signal.aborted) return;
|
|
3673
|
+
const normalized = withParent ? children.map((child) => withParent(child, node.item)) : children;
|
|
3674
|
+
setLocalItems((current) => [...current, ...normalized]);
|
|
3675
|
+
} catch (cause) {
|
|
3676
|
+
if (!controller.signal.aborted) setLoadErrors((current) => new Map(current).set(node.id, cause));
|
|
3677
|
+
} finally {
|
|
3678
|
+
if (controllers.current.get(node.id) === controller) controllers.current.delete(node.id);
|
|
3679
|
+
setLoadingIds((current) => {
|
|
3680
|
+
const nextLoading = new Set(current);
|
|
3681
|
+
nextLoading.delete(node.id);
|
|
3682
|
+
return nextLoading;
|
|
3683
|
+
});
|
|
3684
|
+
}
|
|
3685
|
+
}, [
|
|
3686
|
+
expandedIds,
|
|
3687
|
+
hasChildren,
|
|
3688
|
+
loadChildren,
|
|
3689
|
+
loadErrors,
|
|
3690
|
+
updateExpanded,
|
|
3691
|
+
withParent
|
|
3692
|
+
]);
|
|
3693
|
+
const toggleSelected = (node) => {
|
|
3694
|
+
const next = new Set(selectionMode === "single" ? [] : selectedIds);
|
|
3695
|
+
if (selectedIds.has(node.id)) next.delete(node.id);
|
|
3696
|
+
else next.add(node.id);
|
|
3697
|
+
if (selectionMode === "multiple" && selectDescendants) for (const id of getDescendantIds(node)) if (selectedIds.has(node.id)) next.delete(id);
|
|
3698
|
+
else next.add(id);
|
|
3699
|
+
updateSelected(next);
|
|
3700
|
+
};
|
|
3701
|
+
const parentOf = (targetId) => {
|
|
3702
|
+
const find = (nodes) => {
|
|
3703
|
+
for (const node of nodes) {
|
|
3704
|
+
if (node.children.some((child) => child.id === targetId)) return node;
|
|
3705
|
+
const found = find(node.children);
|
|
3706
|
+
if (found) return found;
|
|
3707
|
+
}
|
|
3708
|
+
return null;
|
|
3709
|
+
};
|
|
3710
|
+
return find(tree);
|
|
3711
|
+
};
|
|
3712
|
+
const siblingsOf = (parent) => parent ? parent.children : tree;
|
|
3713
|
+
const moveRow = (item, target, position = "inside") => {
|
|
3714
|
+
if (!onMove) return;
|
|
3715
|
+
const sourceId = getId(item);
|
|
3716
|
+
const sourceNode = nodeById.get(sourceId);
|
|
3717
|
+
if (!sourceNode) return;
|
|
3718
|
+
if (target?.id === sourceId) return;
|
|
3719
|
+
const parent = position === "inside" ? target : target ? parentOf(target.id) : null;
|
|
3720
|
+
if (parent && (parent.id === sourceId || getDescendantIds(sourceNode).includes(parent.id))) return;
|
|
3721
|
+
const siblings = siblingsOf(parent).filter((node) => node.id !== sourceId);
|
|
3722
|
+
const targetIndex = target ? siblings.findIndex((node) => node.id === target.id) : -1;
|
|
3723
|
+
const index = targetIndex < 0 ? siblings.length : targetIndex + (position === "after" ? 1 : 0);
|
|
3724
|
+
Promise.resolve(onMove({
|
|
3725
|
+
item,
|
|
3726
|
+
newParent: parent?.item ?? null,
|
|
3727
|
+
index,
|
|
3728
|
+
position
|
|
3729
|
+
})).then(() => setMoveError(false)).catch(() => setMoveError(true));
|
|
3730
|
+
};
|
|
3731
|
+
const saveEdit = async (node, columnId) => {
|
|
3732
|
+
const key = `${String(node.id)}:${columnId}`;
|
|
3733
|
+
setEditingCell(null);
|
|
3734
|
+
try {
|
|
3735
|
+
await onEdit?.(node.item, columnId, editValue);
|
|
3736
|
+
setEditErrors((current) => {
|
|
3737
|
+
const next = new Map(current);
|
|
3738
|
+
next.delete(key);
|
|
3739
|
+
return next;
|
|
3740
|
+
});
|
|
3741
|
+
} catch (cause) {
|
|
3742
|
+
setEditErrors((current) => new Map(current).set(key, cause));
|
|
3743
|
+
setEditingCell({
|
|
3744
|
+
id: node.id,
|
|
3745
|
+
columnId
|
|
3746
|
+
});
|
|
3747
|
+
}
|
|
3748
|
+
};
|
|
3749
|
+
const onRowKeyDown = (event, index) => {
|
|
3750
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
3751
|
+
event.preventDefault();
|
|
3752
|
+
const target = visibleNodes[index + (event.key === "ArrowDown" ? 1 : -1)];
|
|
3753
|
+
if (target) rows.current.get(target.id)?.focus();
|
|
3754
|
+
}
|
|
3755
|
+
if (event.key === "ArrowRight" && visibleNodes[index]) {
|
|
3756
|
+
event.preventDefault();
|
|
3757
|
+
const node = visibleNodes[index];
|
|
3758
|
+
if ((node.children.length > 0 || hasChildren?.(node.item)) && !expandedIds.has(node.id)) expand(node);
|
|
3759
|
+
else if (expandedIds.has(node.id) && node.children[0]) rows.current.get(node.children[0].id)?.focus();
|
|
3760
|
+
}
|
|
3761
|
+
if (event.key === "ArrowLeft" && visibleNodes[index]) {
|
|
3762
|
+
event.preventDefault();
|
|
3763
|
+
const node = visibleNodes[index];
|
|
3764
|
+
if (expandedIds.has(node.id)) expand(node);
|
|
3765
|
+
else {
|
|
3766
|
+
const parentId = getParentId?.(node.item);
|
|
3767
|
+
if (parentId != null) rows.current.get(parentId)?.focus();
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
if (event.key === "Enter" && visibleNodes[index]) onRowActivate?.(visibleNodes[index].item);
|
|
3771
|
+
};
|
|
3772
|
+
const classNames = [
|
|
3773
|
+
"nb-tree-list",
|
|
3774
|
+
`nb-tree-list--${density}`,
|
|
3775
|
+
className
|
|
3776
|
+
].filter(Boolean).join(" ");
|
|
3777
|
+
const hasSelection = selectionMode !== "none";
|
|
3778
|
+
const allVisibleSelected = visibleNodes.length > 0 && visibleNodes.every((node) => selectedIds.has(node.id));
|
|
3779
|
+
const someVisibleSelected = !allVisibleSelected && visibleNodes.some((node) => selectedIds.has(node.id));
|
|
3780
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3781
|
+
className: classNames,
|
|
3782
|
+
"data-testid": testId,
|
|
3783
|
+
children: [
|
|
3784
|
+
filterable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3785
|
+
className: "nb-tree-list__toolbar",
|
|
3786
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3787
|
+
className: "nb-tree-list__filter",
|
|
3788
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3789
|
+
className: "nb-tree-list__sr-only",
|
|
3790
|
+
children: strings.treeListFilter
|
|
3791
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3792
|
+
type: "search",
|
|
3793
|
+
value: filter,
|
|
3794
|
+
placeholder: strings.treeListFilter,
|
|
3795
|
+
onChange: (event) => updateFilter(event.currentTarget.value)
|
|
3796
|
+
})]
|
|
3797
|
+
}), filter && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3798
|
+
type: "button",
|
|
3799
|
+
className: "nb-tree-list__clear-filter",
|
|
3800
|
+
onClick: () => updateFilter(""),
|
|
3801
|
+
children: strings.clear
|
|
3802
|
+
})]
|
|
3803
|
+
}),
|
|
3804
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3805
|
+
className: "nb-tree-list__error",
|
|
3806
|
+
role: "alert",
|
|
3807
|
+
children: error
|
|
3808
|
+
}),
|
|
3809
|
+
moveError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3810
|
+
className: "nb-tree-list__error",
|
|
3811
|
+
role: "alert",
|
|
3812
|
+
children: strings.treeListMoveFailed
|
|
3813
|
+
}),
|
|
3814
|
+
loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3815
|
+
className: "nb-tree-list__loading",
|
|
3816
|
+
role: "status",
|
|
3817
|
+
children: strings.searching
|
|
3818
|
+
}),
|
|
3819
|
+
!loading && visibleNodes.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3820
|
+
className: "nb-tree-list__empty",
|
|
3821
|
+
children: emptyState ?? strings.treeListEmpty
|
|
3822
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3823
|
+
className: "nb-tree-list__scroll",
|
|
3824
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3825
|
+
className: "nb-tree-list__table",
|
|
3826
|
+
role: "treegrid",
|
|
3827
|
+
"aria-label": ariaLabel,
|
|
3828
|
+
"aria-busy": loading || loadingIds.size > 0,
|
|
3829
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3830
|
+
hasSelection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3831
|
+
className: "nb-tree-list__selection-cell",
|
|
3832
|
+
children: selectionMode === "multiple" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
|
|
3833
|
+
"aria-label": strings.treeListSelectAll,
|
|
3834
|
+
checked: allVisibleSelected,
|
|
3835
|
+
indeterminate: someVisibleSelected,
|
|
3836
|
+
onChange: () => {
|
|
3837
|
+
const next = new Set(selectedIds);
|
|
3838
|
+
for (const node of visibleNodes) if (allVisibleSelected) next.delete(node.id);
|
|
3839
|
+
else next.add(node.id);
|
|
3840
|
+
updateSelected(next);
|
|
3841
|
+
}
|
|
3842
|
+
})
|
|
3843
|
+
}),
|
|
3844
|
+
columns.map((column, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3845
|
+
scope: "col",
|
|
3846
|
+
"aria-sort": sort?.columnId === column.id ? sort.direction === "asc" ? "ascending" : "descending" : void 0,
|
|
3847
|
+
style: column.width ? { width: column.width } : void 0,
|
|
3848
|
+
className: `nb-tree-list__align--${column.align ?? "start"}`,
|
|
3849
|
+
children: column.sortable === false || index === 0 ? column.header : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3850
|
+
type: "button",
|
|
3851
|
+
className: "nb-tree-list__sort",
|
|
3852
|
+
onClick: () => setSort((current) => current?.columnId === column.id ? current.direction === "asc" ? {
|
|
3853
|
+
columnId: column.id,
|
|
3854
|
+
direction: "desc"
|
|
3855
|
+
} : null : {
|
|
3856
|
+
columnId: column.id,
|
|
3857
|
+
direction: "asc"
|
|
3858
|
+
}),
|
|
3859
|
+
children: [column.header, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3860
|
+
"aria-hidden": "true",
|
|
3861
|
+
children: sort?.columnId === column.id ? sort.direction === "asc" ? "↑" : "↓" : "↕"
|
|
3862
|
+
})]
|
|
3863
|
+
})
|
|
3864
|
+
}, column.id)),
|
|
3865
|
+
rowActions && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3866
|
+
scope: "col",
|
|
3867
|
+
"aria-label": strings.rowActions
|
|
3868
|
+
})
|
|
3869
|
+
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", {
|
|
3870
|
+
onDragOver: (event) => {
|
|
3871
|
+
if (onMove && event.target === event.currentTarget) {
|
|
3872
|
+
event.preventDefault();
|
|
3873
|
+
event.dataTransfer.dropEffect = "move";
|
|
3874
|
+
}
|
|
3875
|
+
},
|
|
3876
|
+
onDrop: (event) => {
|
|
3877
|
+
if (!onMove || event.target !== event.currentTarget) return;
|
|
3878
|
+
event.preventDefault();
|
|
3879
|
+
const draggedId = event.dataTransfer.getData("text/plain");
|
|
3880
|
+
const dragged = nodeById.get(draggedId) ?? nodeById.get(Number(draggedId));
|
|
3881
|
+
if (dragged) moveRow(dragged.item, null, "after");
|
|
3882
|
+
},
|
|
3883
|
+
children: visibleNodes.map((node, index) => {
|
|
3884
|
+
const expanded = effectiveExpandedIds.has(node.id);
|
|
3885
|
+
const canExpand = node.children.length > 0 || (hasChildren ? hasChildren(node.item) : !!loadChildren);
|
|
3886
|
+
const selected = selectedIds.has(node.id);
|
|
3887
|
+
const parent = getParentId?.(node.item);
|
|
3888
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
|
|
3889
|
+
ref: (element) => {
|
|
3890
|
+
if (element) rows.current.set(node.id, element);
|
|
3891
|
+
else rows.current.delete(node.id);
|
|
3892
|
+
},
|
|
3893
|
+
role: "row",
|
|
3894
|
+
"aria-level": node.depth + 1,
|
|
3895
|
+
"aria-expanded": canExpand ? expanded : void 0,
|
|
3896
|
+
"aria-selected": hasSelection ? selected : void 0,
|
|
3897
|
+
tabIndex: index === 0 ? 0 : -1,
|
|
3898
|
+
draggable: !!onMove,
|
|
3899
|
+
onKeyDown: (event) => onRowKeyDown(event, index),
|
|
3900
|
+
onClick: () => onRowActivate?.(node.item),
|
|
3901
|
+
onDragStart: (event) => {
|
|
3902
|
+
event.dataTransfer.setData("text/plain", String(node.id));
|
|
3903
|
+
event.dataTransfer.effectAllowed = "move";
|
|
3904
|
+
},
|
|
3905
|
+
onDragOver: (event) => {
|
|
3906
|
+
if (onMove) {
|
|
3907
|
+
event.preventDefault();
|
|
3908
|
+
event.dataTransfer.dropEffect = "move";
|
|
3909
|
+
}
|
|
3910
|
+
},
|
|
3911
|
+
onDrop: (event) => {
|
|
3912
|
+
event.preventDefault();
|
|
3913
|
+
event.stopPropagation();
|
|
3914
|
+
const draggedId = event.dataTransfer.getData("text/plain");
|
|
3915
|
+
const dragged = nodeById.get(draggedId) ?? nodeById.get(Number(draggedId));
|
|
3916
|
+
const bounds = event.currentTarget.getBoundingClientRect();
|
|
3917
|
+
const relativeY = event.clientY - bounds.top;
|
|
3918
|
+
const position = relativeY < bounds.height * .25 ? "before" : relativeY > bounds.height * .75 ? "after" : "inside";
|
|
3919
|
+
if (dragged) moveRow(dragged.item, node, position);
|
|
3920
|
+
},
|
|
3921
|
+
onDragEnd: () => {},
|
|
3922
|
+
"data-parent-id": parent == null ? void 0 : String(parent),
|
|
3923
|
+
children: [
|
|
3924
|
+
hasSelection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3925
|
+
className: "nb-tree-list__selection-cell",
|
|
3926
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
|
|
3927
|
+
"aria-label": `${strings.treeListSelect} ${String(getId(node.item))}`,
|
|
3928
|
+
checked: selected,
|
|
3929
|
+
onClick: (event) => event.stopPropagation(),
|
|
3930
|
+
onChange: () => toggleSelected(node)
|
|
3931
|
+
})
|
|
3932
|
+
}),
|
|
3933
|
+
columns.map((column, columnIndex) => {
|
|
3934
|
+
const isEditing = editingCell?.id === node.id && editingCell.columnId === column.id;
|
|
3935
|
+
const rawValue = itemValue(column, node.item);
|
|
3936
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
|
|
3937
|
+
className: `nb-tree-list__align--${column.align ?? "start"}`,
|
|
3938
|
+
onDoubleClick: () => {
|
|
3939
|
+
const columnCanEdit = column.editable === true || typeof column.editable === "function" && column.editable(node.item) || editable?.(node.item, column.id) === true;
|
|
3940
|
+
if (!onEdit || !columnCanEdit) return;
|
|
3941
|
+
setEditingCell({
|
|
3942
|
+
id: node.id,
|
|
3943
|
+
columnId: column.id
|
|
3944
|
+
});
|
|
3945
|
+
setEditValue(String(rawValue ?? ""));
|
|
3946
|
+
},
|
|
3947
|
+
children: [
|
|
3948
|
+
columnIndex === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3949
|
+
className: "nb-tree-list__indent",
|
|
3950
|
+
style: { "--nb-tree-depth": node.depth },
|
|
3951
|
+
children: canExpand ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
|
|
3952
|
+
icon: loadingIds.has(node.id) ? "ph ph-spinner" : expanded ? "ph ph-caret-down" : "ph ph-caret-right",
|
|
3953
|
+
label: `${expanded ? strings.treeListCollapse : strings.treeListExpand} ${String(getId(node.item))}`,
|
|
3954
|
+
disabled: loadingIds.has(node.id),
|
|
3955
|
+
onClick: (event) => {
|
|
3956
|
+
event.stopPropagation();
|
|
3957
|
+
expand(node);
|
|
3958
|
+
}
|
|
3959
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "nb-tree-list__spacer" })
|
|
3960
|
+
}),
|
|
3961
|
+
isEditing ? column.editor ? column.editor({
|
|
3962
|
+
item: node.item,
|
|
3963
|
+
value: editValue,
|
|
3964
|
+
onChange: setEditValue
|
|
3965
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3966
|
+
autoFocus: true,
|
|
3967
|
+
value: editValue,
|
|
3968
|
+
"aria-label": `${strings.treeListEdit} ${column.id}`,
|
|
3969
|
+
onChange: (event) => setEditValue(event.currentTarget.value),
|
|
3970
|
+
onBlur: () => void saveEdit(node, column.id),
|
|
3971
|
+
onKeyDown: (event) => {
|
|
3972
|
+
if (event.key === "Enter") saveEdit(node, column.id);
|
|
3973
|
+
if (event.key === "Escape") setEditingCell(null);
|
|
3974
|
+
}
|
|
3975
|
+
}) : column.render ? column.render(node.item, {
|
|
3976
|
+
depth: node.depth,
|
|
3977
|
+
expanded
|
|
3978
|
+
}) : String(rawValue ?? ""),
|
|
3979
|
+
loadErrors.has(node.id) && columnIndex === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3980
|
+
type: "button",
|
|
3981
|
+
className: "nb-tree-list__retry",
|
|
3982
|
+
onClick: () => void expand(node),
|
|
3983
|
+
children: strings.retrySearch
|
|
3984
|
+
}),
|
|
3985
|
+
editErrors.has(`${String(node.id)}:${column.id}`) && isEditing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3986
|
+
className: "nb-tree-list__edit-error",
|
|
3987
|
+
role: "alert",
|
|
3988
|
+
children: strings.searchFailed
|
|
3989
|
+
})
|
|
3990
|
+
]
|
|
3991
|
+
}, column.id);
|
|
3992
|
+
}),
|
|
3993
|
+
rowActions && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3994
|
+
className: "nb-tree-list__actions-cell",
|
|
3995
|
+
onClick: (event) => event.stopPropagation(),
|
|
3996
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowActions, {
|
|
3997
|
+
items: rowActions(node.item),
|
|
3998
|
+
triggerLabel: strings.rowActions
|
|
3999
|
+
})
|
|
4000
|
+
})
|
|
4001
|
+
]
|
|
4002
|
+
}, node.id);
|
|
4003
|
+
})
|
|
4004
|
+
})]
|
|
4005
|
+
})
|
|
4006
|
+
})
|
|
4007
|
+
]
|
|
4008
|
+
});
|
|
4009
|
+
}
|
|
3496
4010
|
exports.ACCENT_PRESETS = ACCENT_PRESETS;
|
|
3497
4011
|
exports.Alert = Alert;
|
|
3498
4012
|
exports.AppDialog = AppDialog;
|
|
@@ -3565,9 +4079,13 @@ exports.TimelineItem = TimelineItem;
|
|
|
3565
4079
|
exports.Toggle = Toggle;
|
|
3566
4080
|
exports.Tooltip = Tooltip;
|
|
3567
4081
|
exports.TooltipProvider = TooltipProvider;
|
|
4082
|
+
exports.TreeList = TreeList;
|
|
3568
4083
|
exports.UiStringsProvider = UiStringsProvider;
|
|
4084
|
+
exports.buildTreeListModel = buildTreeListModel;
|
|
4085
|
+
exports.flattenVisibleTree = flattenVisibleTree;
|
|
3569
4086
|
exports.getAvatarHue = getAvatarHue;
|
|
3570
4087
|
exports.getAvatarInitials = getAvatarInitials;
|
|
4088
|
+
exports.getDescendantIds = getDescendantIds;
|
|
3571
4089
|
exports.useAccentColor = useAccentColor;
|
|
3572
4090
|
exports.useConfirm = useConfirm;
|
|
3573
4091
|
exports.useDensity = useDensity;
|