@nubitio/ui 1.3.0 → 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 +686 -159
- package/dist/index.d.cts +207 -240
- package/dist/index.d.mts +207 -240
- package/dist/index.mjs +681 -157
- package/dist/style.css +160 -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,9 +671,8 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
|
|
|
666
671
|
})]
|
|
667
672
|
});
|
|
668
673
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
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 }) {
|
|
674
|
+
// packages/ui/AppDropdown.tsx
|
|
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;
|
|
674
678
|
const container = useOverlayContainer();
|
|
@@ -676,6 +680,7 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
|
|
|
676
680
|
const selected = options.find((option) => option.value === value);
|
|
677
681
|
const labelled = !!label && (showFieldLabel || variant === "toolbar");
|
|
678
682
|
const message = error ?? helpText;
|
|
683
|
+
const triggerIconClass = triggerIcon?.startsWith("ph ") ? triggerIcon : triggerIcon?.startsWith("ph-") ? `ph ${triggerIcon}` : `ph ph-${triggerIcon}`;
|
|
679
684
|
const iconClass = icon?.startsWith("ph ") ? icon : icon?.startsWith("ph-") ? `ph ${icon}` : `ph ph-${icon}`;
|
|
680
685
|
return /* @__PURE__ */ jsx(Select.Root, {
|
|
681
686
|
value,
|
|
@@ -727,17 +732,25 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
|
|
|
727
732
|
}
|
|
728
733
|
},
|
|
729
734
|
"aria-label": ariaLabel,
|
|
735
|
+
title: triggerIcon ? ariaLabel ?? selected?.label : void 0,
|
|
730
736
|
"aria-labelledby": ariaLabel ? void 0 : labelled ? `${id}-label ${id}-value` : `${id}-value`,
|
|
731
737
|
"aria-describedby": message ? `${id}-message` : void 0,
|
|
732
738
|
"aria-invalid": !!error || void 0,
|
|
733
|
-
children: [
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
739
|
+
children: [
|
|
740
|
+
triggerIcon && /* @__PURE__ */ jsx("i", {
|
|
741
|
+
className: `${triggerIconClass} nb-dropdown__trigger-icon`,
|
|
742
|
+
"aria-hidden": "true"
|
|
743
|
+
}),
|
|
744
|
+
/* @__PURE__ */ jsx("span", {
|
|
745
|
+
className: `nb-dropdown__value${triggerIcon ? " nb-sr-only" : ""}`,
|
|
746
|
+
id: `${id}-value`,
|
|
747
|
+
children: selected?.selectedLabel ?? selected?.label ?? placeholder
|
|
748
|
+
}),
|
|
749
|
+
/* @__PURE__ */ jsx("i", {
|
|
750
|
+
className: "ph ph-caret-down nb-dropdown__caret",
|
|
751
|
+
"aria-hidden": "true"
|
|
752
|
+
})
|
|
753
|
+
]
|
|
741
754
|
}),
|
|
742
755
|
/* @__PURE__ */ jsx(Select.Portal, {
|
|
743
756
|
container: container ?? void 0,
|
|
@@ -797,8 +810,7 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
|
|
|
797
810
|
})
|
|
798
811
|
});
|
|
799
812
|
}
|
|
800
|
-
|
|
801
|
-
//#region packages/ui/useComboboxOptions.ts
|
|
813
|
+
// packages/ui/useComboboxOptions.ts
|
|
802
814
|
function mergeOptions(...groups) {
|
|
803
815
|
const map = /* @__PURE__ */ new Map();
|
|
804
816
|
for (const group of groups) for (const option of group) map.set(option.value, option);
|
|
@@ -935,8 +947,7 @@ function useComboboxOptions({ options, selected, loadOptions, open, query, debou
|
|
|
935
947
|
retry: () => setRevision((previous) => previous + 1)
|
|
936
948
|
};
|
|
937
949
|
}
|
|
938
|
-
|
|
939
|
-
//#region packages/ui/Combobox.tsx
|
|
950
|
+
// packages/ui/Combobox.tsx
|
|
940
951
|
const Combobox = forwardRef(function Combobox(props, ref) {
|
|
941
952
|
return /* @__PURE__ */ jsx(SelectionCombobox, {
|
|
942
953
|
...props,
|
|
@@ -1161,8 +1172,7 @@ function ComboboxClear({ label, disabled, multiple }) {
|
|
|
1161
1172
|
})
|
|
1162
1173
|
});
|
|
1163
1174
|
}
|
|
1164
|
-
|
|
1165
|
-
//#region packages/ui/SearchableAppDropdown.tsx
|
|
1175
|
+
// packages/ui/SearchableAppDropdown.tsx
|
|
1166
1176
|
const toOption = (option) => ({
|
|
1167
1177
|
value: option.value,
|
|
1168
1178
|
label: option.selectedLabel ?? option.label,
|
|
@@ -1213,8 +1223,7 @@ function SearchableAppDropdown({ options = [], searchable = true, searchPlacehol
|
|
|
1213
1223
|
loadingMessage: loadingLabel
|
|
1214
1224
|
});
|
|
1215
1225
|
}
|
|
1216
|
-
|
|
1217
|
-
//#region packages/ui/theme/ThemeProvider.tsx
|
|
1226
|
+
// packages/ui/theme/ThemeProvider.tsx
|
|
1218
1227
|
const ThemeContext = React.createContext(null);
|
|
1219
1228
|
function useTheme() {
|
|
1220
1229
|
const ctx = useContext(ThemeContext);
|
|
@@ -1336,8 +1345,7 @@ const ThemeProvider = ({ storageKey = "nb-theme", themePrefix = "nb-theme-", bas
|
|
|
1336
1345
|
children
|
|
1337
1346
|
});
|
|
1338
1347
|
};
|
|
1339
|
-
|
|
1340
|
-
//#region packages/ui/theme/ThemeSwitcher.tsx
|
|
1348
|
+
// packages/ui/theme/ThemeSwitcher.tsx
|
|
1341
1349
|
const iconByMode = {
|
|
1342
1350
|
light: "ph ph-sun",
|
|
1343
1351
|
dark: "ph ph-moon",
|
|
@@ -1361,8 +1369,7 @@ const ThemeSwitcher = ({ labelByMode: overrides } = {}) => {
|
|
|
1361
1369
|
onClick: switchTheme
|
|
1362
1370
|
}) });
|
|
1363
1371
|
};
|
|
1364
|
-
|
|
1365
|
-
//#region packages/ui/theme/DensityProvider.tsx
|
|
1372
|
+
// packages/ui/theme/DensityProvider.tsx
|
|
1366
1373
|
const DensityContext = createContext(null);
|
|
1367
1374
|
function useDensity() {
|
|
1368
1375
|
const ctx = useContext(DensityContext);
|
|
@@ -1390,8 +1397,7 @@ const DensityProvider = ({ children }) => {
|
|
|
1390
1397
|
children
|
|
1391
1398
|
});
|
|
1392
1399
|
};
|
|
1393
|
-
|
|
1394
|
-
//#region packages/ui/theme/useAccentColor.ts
|
|
1400
|
+
// packages/ui/theme/useAccentColor.ts
|
|
1395
1401
|
const ACCENT_PRESETS = [
|
|
1396
1402
|
{
|
|
1397
1403
|
label: "Azure",
|
|
@@ -1443,8 +1449,7 @@ function useAccentColor() {
|
|
|
1443
1449
|
presets: ACCENT_PRESETS
|
|
1444
1450
|
};
|
|
1445
1451
|
}
|
|
1446
|
-
|
|
1447
|
-
//#region packages/ui/SettingsPanel.tsx
|
|
1452
|
+
// packages/ui/SettingsPanel.tsx
|
|
1448
1453
|
const SettingsPanel = ({ onClose: _onClose }) => {
|
|
1449
1454
|
const strings = useUiStrings();
|
|
1450
1455
|
const { density, toggleDensity } = useDensity();
|
|
@@ -1507,8 +1512,7 @@ const SettingsPanel = ({ onClose: _onClose }) => {
|
|
|
1507
1512
|
]
|
|
1508
1513
|
});
|
|
1509
1514
|
};
|
|
1510
|
-
|
|
1511
|
-
//#region packages/ui/Badge.tsx
|
|
1515
|
+
// packages/ui/Badge.tsx
|
|
1512
1516
|
const Badge = ({ variant = "primary", size = "md", outlined = false, pill = true, dot = false, children, className }) => {
|
|
1513
1517
|
const classes = [
|
|
1514
1518
|
"nb-badge",
|
|
@@ -1524,8 +1528,7 @@ const Badge = ({ variant = "primary", size = "md", outlined = false, pill = true
|
|
|
1524
1528
|
children: dot ? null : children
|
|
1525
1529
|
});
|
|
1526
1530
|
};
|
|
1527
|
-
|
|
1528
|
-
//#region packages/ui/FeatureGate.tsx
|
|
1531
|
+
// packages/ui/FeatureGate.tsx
|
|
1529
1532
|
function FeatureGate({ featureKey, children, enabled = false, behavior = "lock", planBadge = "Pro", upgradeMessage, upgradeUrl = "/settings", lockTooltip }) {
|
|
1530
1533
|
const strings = useUiStrings();
|
|
1531
1534
|
const tooltip = lockTooltip ?? strings.featureUnavailable;
|
|
@@ -1599,8 +1602,7 @@ function UpgradeGate({ planBadge, upgradeMessage, upgradeUrl, children }) {
|
|
|
1599
1602
|
]
|
|
1600
1603
|
});
|
|
1601
1604
|
}
|
|
1602
|
-
|
|
1603
|
-
//#region packages/ui/Skeleton.tsx
|
|
1605
|
+
// packages/ui/Skeleton.tsx
|
|
1604
1606
|
const fmtSize = (v) => v === void 0 ? void 0 : typeof v === "number" ? `${v}px` : v;
|
|
1605
1607
|
const Skeleton = ({ variant = "rect", width, height, lines = 1, className }) => {
|
|
1606
1608
|
const base = [
|
|
@@ -1625,8 +1627,7 @@ const Skeleton = ({ variant = "rect", width, height, lines = 1, className }) =>
|
|
|
1625
1627
|
"aria-hidden": "true"
|
|
1626
1628
|
});
|
|
1627
1629
|
};
|
|
1628
|
-
|
|
1629
|
-
//#region packages/ui/EmptyState.tsx
|
|
1630
|
+
// packages/ui/EmptyState.tsx
|
|
1630
1631
|
const DEFAULT_ICONS = {
|
|
1631
1632
|
default: "folder-open",
|
|
1632
1633
|
danger: "warning-circle",
|
|
@@ -1669,8 +1670,7 @@ const EmptyState = ({ icon, illustration, variant = "default", title, descriptio
|
|
|
1669
1670
|
]
|
|
1670
1671
|
});
|
|
1671
1672
|
};
|
|
1672
|
-
|
|
1673
|
-
//#region packages/ui/Chip.tsx
|
|
1673
|
+
// packages/ui/Chip.tsx
|
|
1674
1674
|
/**
|
|
1675
1675
|
* Pill-shaped filter/tag chip. Stateless — caller controls `active`.
|
|
1676
1676
|
* Use for category filters, tag lists, and multi-select inputs.
|
|
@@ -1697,8 +1697,7 @@ const Chip = ({ label, active = false, count, icon, size = "md", disabled = fals
|
|
|
1697
1697
|
]
|
|
1698
1698
|
});
|
|
1699
1699
|
};
|
|
1700
|
-
|
|
1701
|
-
//#region packages/ui/Toggle.tsx
|
|
1700
|
+
// packages/ui/Toggle.tsx
|
|
1702
1701
|
/**
|
|
1703
1702
|
* Accessible toggle switch. Always controlled — pass `checked` + `onChange`.
|
|
1704
1703
|
* Renders a visually-hidden `<input type="checkbox">` with a custom track.
|
|
@@ -1728,8 +1727,7 @@ const Toggle = ({ checked, onChange, label, size = "md", disabled = false, "aria
|
|
|
1728
1727
|
children: [label && /* @__PURE__ */ jsx("span", { children: label }), input]
|
|
1729
1728
|
});
|
|
1730
1729
|
};
|
|
1731
|
-
|
|
1732
|
-
//#region packages/ui/ContextMenu.tsx
|
|
1730
|
+
// packages/ui/ContextMenu.tsx
|
|
1733
1731
|
const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones", align = "right", className = "" }) => {
|
|
1734
1732
|
const container = useOverlayContainer();
|
|
1735
1733
|
const triggerRef = useRef(null);
|
|
@@ -1777,8 +1775,7 @@ const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones"
|
|
|
1777
1775
|
})
|
|
1778
1776
|
});
|
|
1779
1777
|
};
|
|
1780
|
-
|
|
1781
|
-
//#region packages/ui/StatCard.tsx
|
|
1778
|
+
// packages/ui/StatCard.tsx
|
|
1782
1779
|
/**
|
|
1783
1780
|
* General-purpose analytics / dashboard card.
|
|
1784
1781
|
* Replaces the legacy `shared/ui/card-analytics/CardAnalytics` component.
|
|
@@ -1803,8 +1800,7 @@ const StatCard = ({ title, headerExtra, menuVisible = true, menuItems = [{ label
|
|
|
1803
1800
|
children
|
|
1804
1801
|
})]
|
|
1805
1802
|
});
|
|
1806
|
-
|
|
1807
|
-
//#region packages/ui/KpiMetricRow.tsx
|
|
1803
|
+
// packages/ui/KpiMetricRow.tsx
|
|
1808
1804
|
function normalizeIcon$1(icon) {
|
|
1809
1805
|
if (!icon) return void 0;
|
|
1810
1806
|
if (icon.startsWith("ph ")) return icon;
|
|
@@ -1847,8 +1843,7 @@ function KpiMetricRow({ items, className = "", layout = "cards", density = "defa
|
|
|
1847
1843
|
})
|
|
1848
1844
|
});
|
|
1849
1845
|
}
|
|
1850
|
-
|
|
1851
|
-
//#region packages/ui/SegmentedControl.tsx
|
|
1846
|
+
// packages/ui/SegmentedControl.tsx
|
|
1852
1847
|
function SegmentedControl({ options, value, onChange, ariaLabel, className = "", size = "md" }) {
|
|
1853
1848
|
if (options.length === 0) return null;
|
|
1854
1849
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -1868,8 +1863,7 @@ function SegmentedControl({ options, value, onChange, ariaLabel, className = "",
|
|
|
1868
1863
|
})
|
|
1869
1864
|
});
|
|
1870
1865
|
}
|
|
1871
|
-
|
|
1872
|
-
//#region packages/ui/FilterPanel.tsx
|
|
1866
|
+
// packages/ui/FilterPanel.tsx
|
|
1873
1867
|
function FilterPanel({ category, status, layout = "stacked", density = "default", className = "", testId }) {
|
|
1874
1868
|
const [search, setSearch] = useState("");
|
|
1875
1869
|
const threshold = category.searchThreshold ?? 10;
|
|
@@ -1978,8 +1972,7 @@ function FilterPanel({ category, status, layout = "stacked", density = "default"
|
|
|
1978
1972
|
})]
|
|
1979
1973
|
});
|
|
1980
1974
|
}
|
|
1981
|
-
|
|
1982
|
-
//#region packages/ui/ScopeTabs.tsx
|
|
1975
|
+
// packages/ui/ScopeTabs.tsx
|
|
1983
1976
|
/**
|
|
1984
1977
|
* Pill tabs for scoping a list view (warehouse, branch, period, etc.).
|
|
1985
1978
|
* Hides itself when there is at most one scope option.
|
|
@@ -2008,8 +2001,7 @@ function ScopeTabs({ options, selectedKey, onChange, allLabel = "Todos", ariaLab
|
|
|
2008
2001
|
}, option.key))]
|
|
2009
2002
|
});
|
|
2010
2003
|
}
|
|
2011
|
-
|
|
2012
|
-
//#region packages/ui/OperationCardGrid.tsx
|
|
2004
|
+
// packages/ui/OperationCardGrid.tsx
|
|
2013
2005
|
function normalizeIcon(icon) {
|
|
2014
2006
|
if (icon.startsWith("ph ")) return icon;
|
|
2015
2007
|
if (icon.startsWith("ph-")) return `ph ${icon}`;
|
|
@@ -2064,8 +2056,7 @@ function OperationCardGrid({ title, description, operations, className = "", tes
|
|
|
2064
2056
|
})]
|
|
2065
2057
|
});
|
|
2066
2058
|
}
|
|
2067
|
-
|
|
2068
|
-
//#region packages/ui/HubPanel.tsx
|
|
2059
|
+
// packages/ui/HubPanel.tsx
|
|
2069
2060
|
/**
|
|
2070
2061
|
* Card shell for feature-hub chrome above a CRUD grid (KPIs, scope tabs, filters).
|
|
2071
2062
|
*/
|
|
@@ -2076,8 +2067,7 @@ function HubPanel({ children, variant = "card", className = "", testId }) {
|
|
|
2076
2067
|
children
|
|
2077
2068
|
});
|
|
2078
2069
|
}
|
|
2079
|
-
|
|
2080
|
-
//#region packages/ui/CollapsibleSection.tsx
|
|
2070
|
+
// packages/ui/CollapsibleSection.tsx
|
|
2081
2071
|
/**
|
|
2082
2072
|
* Accessible collapsible section with a labelled header trigger.
|
|
2083
2073
|
*
|
|
@@ -2132,8 +2122,7 @@ const CollapsibleSection = ({ label, icon, open, onToggle, children, trailing, c
|
|
|
2132
2122
|
})]
|
|
2133
2123
|
});
|
|
2134
2124
|
};
|
|
2135
|
-
|
|
2136
|
-
//#region packages/ui/CalendarContent.tsx
|
|
2125
|
+
// packages/ui/CalendarContent.tsx
|
|
2137
2126
|
/** Shared presentation; React Aria owns navigation, focus and range preview. */
|
|
2138
2127
|
function CalendarContent() {
|
|
2139
2128
|
const strings = useUiStrings();
|
|
@@ -2202,8 +2191,7 @@ function CalendarDialog({ id, ariaLabel, children }) {
|
|
|
2202
2191
|
children
|
|
2203
2192
|
});
|
|
2204
2193
|
}
|
|
2205
|
-
|
|
2206
|
-
//#region packages/ui/dateValues.ts
|
|
2194
|
+
// packages/ui/dateValues.ts
|
|
2207
2195
|
const getDateLocale = (locale) => locale || typeof document !== "undefined" && document.documentElement.lang || typeof navigator !== "undefined" && navigator.language || "en-US";
|
|
2208
2196
|
const calendarDate = (value) => {
|
|
2209
2197
|
if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
|
|
@@ -2258,8 +2246,7 @@ const parseDisplayDate = (text, locale) => {
|
|
|
2258
2246
|
const iso = `${fields.year}-${fields.month?.padStart(2, "0")}-${fields.day?.padStart(2, "0")}`;
|
|
2259
2247
|
return calendarDate(iso) ? iso : null;
|
|
2260
2248
|
};
|
|
2261
|
-
|
|
2262
|
-
//#region packages/ui/DateTextInput.tsx
|
|
2249
|
+
// packages/ui/DateTextInput.tsx
|
|
2263
2250
|
/** Keeps the real input/ref/ID contract used by CRUD forms. */
|
|
2264
2251
|
const DateTextInput = forwardRef(function DateTextInput({ value, locale, min, max, onChange, onOpen, onBlur, onKeyDown, ...props }, ref) {
|
|
2265
2252
|
const [draft, setDraft] = useState(null);
|
|
@@ -2302,8 +2289,7 @@ const DateTextInput = forwardRef(function DateTextInput({ value, locale, min, ma
|
|
|
2302
2289
|
}
|
|
2303
2290
|
});
|
|
2304
2291
|
});
|
|
2305
|
-
|
|
2306
|
-
//#region packages/ui/useCalendarPopover.ts
|
|
2292
|
+
// packages/ui/useCalendarPopover.ts
|
|
2307
2293
|
/** Bridge focus restoration between React Aria's popup and a parent Base UI modal. */
|
|
2308
2294
|
function useCalendarPopover() {
|
|
2309
2295
|
const container = useOverlayContainer();
|
|
@@ -2344,8 +2330,7 @@ function useCalendarPopover() {
|
|
|
2344
2330
|
}, [container])
|
|
2345
2331
|
};
|
|
2346
2332
|
}
|
|
2347
|
-
|
|
2348
|
-
//#region packages/ui/DatePicker.tsx
|
|
2333
|
+
// packages/ui/DatePicker.tsx
|
|
2349
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) {
|
|
2350
2335
|
const generatedId = useId();
|
|
2351
2336
|
const inputId = id ?? generatedId;
|
|
@@ -2471,8 +2456,7 @@ const DatePicker = forwardRef(function DatePicker({ id, name, value, placeholder
|
|
|
2471
2456
|
})
|
|
2472
2457
|
});
|
|
2473
2458
|
});
|
|
2474
|
-
|
|
2475
|
-
//#region packages/ui/DateRangePicker.tsx
|
|
2459
|
+
// packages/ui/DateRangePicker.tsx
|
|
2476
2460
|
function DateRangePicker({ startValue, endValue, placeholder, disabled = false, clearable = true, readOnly = false, required = false, invalid = false, locale, min, max, className, ariaLabel, onChange, onBlur }) {
|
|
2477
2461
|
const { container, groupRef, panelRef, open, setOpen } = useCalendarPopover();
|
|
2478
2462
|
const strings = useUiStrings();
|
|
@@ -2603,8 +2587,7 @@ function DateRangePicker({ startValue, endValue, placeholder, disabled = false,
|
|
|
2603
2587
|
})
|
|
2604
2588
|
});
|
|
2605
2589
|
}
|
|
2606
|
-
|
|
2607
|
-
//#region packages/ui/Popover.tsx
|
|
2590
|
+
// packages/ui/Popover.tsx
|
|
2608
2591
|
const Popover = ({ trigger, panel, align = "end", ariaLabel, className }) => {
|
|
2609
2592
|
const [open, setOpen] = useState(false);
|
|
2610
2593
|
const triggerRef = useRef(null);
|
|
@@ -2664,8 +2647,7 @@ const Popover = ({ trigger, panel, align = "end", ariaLabel, className }) => {
|
|
|
2664
2647
|
})
|
|
2665
2648
|
});
|
|
2666
2649
|
};
|
|
2667
|
-
|
|
2668
|
-
//#region packages/ui/useFloatingPanel.ts
|
|
2650
|
+
// packages/ui/useFloatingPanel.ts
|
|
2669
2651
|
/** Style applied to an anchored panel before its first position is computed. */
|
|
2670
2652
|
const HIDDEN_PANEL_STYLE = {
|
|
2671
2653
|
position: "fixed",
|
|
@@ -2766,8 +2748,7 @@ function useFloatingPanel(options = {}) {
|
|
|
2766
2748
|
panelStyle
|
|
2767
2749
|
};
|
|
2768
2750
|
}
|
|
2769
|
-
|
|
2770
|
-
//#region packages/ui/Drawer.tsx
|
|
2751
|
+
// packages/ui/Drawer.tsx
|
|
2771
2752
|
const formatWidth = (value) => {
|
|
2772
2753
|
if (value === void 0) return void 0;
|
|
2773
2754
|
return typeof value === "number" ? `${value}px` : value;
|
|
@@ -2820,8 +2801,7 @@ const Drawer = ({ isOpen, busy = false, onClose, title, width, side = "right", s
|
|
|
2820
2801
|
]
|
|
2821
2802
|
});
|
|
2822
2803
|
};
|
|
2823
|
-
|
|
2824
|
-
//#region packages/ui/Timeline.tsx
|
|
2804
|
+
// packages/ui/Timeline.tsx
|
|
2825
2805
|
const TimelineVariantContext = createContext("stepper");
|
|
2826
2806
|
function useTimelineVariant() {
|
|
2827
2807
|
return useContext(TimelineVariantContext);
|
|
@@ -2917,8 +2897,7 @@ function Timeline({ variant = "stepper", orientation = "vertical", title, descri
|
|
|
2917
2897
|
})
|
|
2918
2898
|
});
|
|
2919
2899
|
}
|
|
2920
|
-
|
|
2921
|
-
//#region packages/ui/Page.tsx
|
|
2900
|
+
// packages/ui/Page.tsx
|
|
2922
2901
|
function Page({ children, fill, wide, narrow, gap = 5, className, ...props }) {
|
|
2923
2902
|
return /* @__PURE__ */ jsx("div", {
|
|
2924
2903
|
className: joinClasses("nb-page", fill && "nb-page--fill", wide && "nb-page--wide", narrow && "nb-page--narrow", gapClass("nb-page", gap), className),
|
|
@@ -2926,8 +2905,7 @@ function Page({ children, fill, wide, narrow, gap = 5, className, ...props }) {
|
|
|
2926
2905
|
children
|
|
2927
2906
|
});
|
|
2928
2907
|
}
|
|
2929
|
-
|
|
2930
|
-
//#region packages/ui/PageHeader.tsx
|
|
2908
|
+
// packages/ui/PageHeader.tsx
|
|
2931
2909
|
function PageHeader({ title, subtitle, metadata, breadcrumb, breadcrumbSlot, badge, actions, className }) {
|
|
2932
2910
|
const breadcrumbNode = breadcrumbSlot ?? (breadcrumb ? /* @__PURE__ */ jsxs("a", {
|
|
2933
2911
|
href: breadcrumb.href,
|
|
@@ -2966,8 +2944,7 @@ function PageHeader({ title, subtitle, metadata, breadcrumb, breadcrumbSlot, bad
|
|
|
2966
2944
|
})]
|
|
2967
2945
|
});
|
|
2968
2946
|
}
|
|
2969
|
-
|
|
2970
|
-
//#region packages/ui/Stack.tsx
|
|
2947
|
+
// packages/ui/Stack.tsx
|
|
2971
2948
|
function Stack({ children, gap = 4, align, justify, fill, className, ...props }) {
|
|
2972
2949
|
return /* @__PURE__ */ jsx("div", {
|
|
2973
2950
|
className: joinClasses("nb-stack", gapClass("nb-stack", gap), align && `nb-stack--align-${align}`, justify && `nb-stack--justify-${justify}`, fill && "nb-stack--fill", className),
|
|
@@ -2975,8 +2952,7 @@ function Stack({ children, gap = 4, align, justify, fill, className, ...props })
|
|
|
2975
2952
|
children
|
|
2976
2953
|
});
|
|
2977
2954
|
}
|
|
2978
|
-
|
|
2979
|
-
//#region packages/ui/Row.tsx
|
|
2955
|
+
// packages/ui/Row.tsx
|
|
2980
2956
|
function Row({ children, gap = 2, align, justify, wrap, fill, className, ...props }) {
|
|
2981
2957
|
return /* @__PURE__ */ jsx("div", {
|
|
2982
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),
|
|
@@ -2984,8 +2960,7 @@ function Row({ children, gap = 2, align, justify, wrap, fill, className, ...prop
|
|
|
2984
2960
|
children
|
|
2985
2961
|
});
|
|
2986
2962
|
}
|
|
2987
|
-
|
|
2988
|
-
//#region packages/ui/Cluster.tsx
|
|
2963
|
+
// packages/ui/Cluster.tsx
|
|
2989
2964
|
/** Inline flex row that wraps — ideal for button groups and filter actions. */
|
|
2990
2965
|
function Cluster({ children, gap = 2, className, ...props }) {
|
|
2991
2966
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -2994,8 +2969,7 @@ function Cluster({ children, gap = 2, className, ...props }) {
|
|
|
2994
2969
|
children
|
|
2995
2970
|
});
|
|
2996
2971
|
}
|
|
2997
|
-
|
|
2998
|
-
//#region packages/ui/Grid.tsx
|
|
2972
|
+
// packages/ui/Grid.tsx
|
|
2999
2973
|
function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, style, ...props }) {
|
|
3000
2974
|
const gridStyle = {
|
|
3001
2975
|
...style,
|
|
@@ -3009,8 +2983,7 @@ function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, styl
|
|
|
3009
2983
|
children
|
|
3010
2984
|
});
|
|
3011
2985
|
}
|
|
3012
|
-
|
|
3013
|
-
//#region packages/ui/Col.tsx
|
|
2986
|
+
// packages/ui/Col.tsx
|
|
3014
2987
|
function Col({ children, span, spanSm, spanMd, spanLg, fullWidth, className, ...props }) {
|
|
3015
2988
|
return /* @__PURE__ */ jsx("div", {
|
|
3016
2989
|
className: joinClasses(...colSpanClasses(span, spanSm, spanMd, spanLg), fullWidth && "nb-span-full", className),
|
|
@@ -3018,8 +2991,7 @@ function Col({ children, span, spanSm, spanMd, spanLg, fullWidth, className, ...
|
|
|
3018
2991
|
children
|
|
3019
2992
|
});
|
|
3020
2993
|
}
|
|
3021
|
-
|
|
3022
|
-
//#region packages/ui/Section.tsx
|
|
2994
|
+
// packages/ui/Section.tsx
|
|
3023
2995
|
function Section({ title, children, className, variant = "label" }) {
|
|
3024
2996
|
return /* @__PURE__ */ jsxs("section", {
|
|
3025
2997
|
className: joinClasses("nb-section", variant === "panel" && "nb-section--panel", className),
|
|
@@ -3029,8 +3001,7 @@ function Section({ title, children, className, variant = "label" }) {
|
|
|
3029
3001
|
}), children]
|
|
3030
3002
|
});
|
|
3031
3003
|
}
|
|
3032
|
-
|
|
3033
|
-
//#region packages/ui/FormLayout.tsx
|
|
3004
|
+
// packages/ui/FormLayout.tsx
|
|
3034
3005
|
function FormLayout({ children, variant = "stack", minColWidth, className, style, ...props }) {
|
|
3035
3006
|
const formStyle = {
|
|
3036
3007
|
...style,
|
|
@@ -3043,16 +3014,14 @@ function FormLayout({ children, variant = "stack", minColWidth, className, style
|
|
|
3043
3014
|
children
|
|
3044
3015
|
});
|
|
3045
3016
|
}
|
|
3046
|
-
|
|
3047
|
-
//#region packages/ui/FormActions.tsx
|
|
3017
|
+
// packages/ui/FormActions.tsx
|
|
3048
3018
|
function FormActions({ children, className }) {
|
|
3049
3019
|
return /* @__PURE__ */ jsx("div", {
|
|
3050
3020
|
className: joinClasses("nb-form-actions", className),
|
|
3051
3021
|
children
|
|
3052
3022
|
});
|
|
3053
3023
|
}
|
|
3054
|
-
|
|
3055
|
-
//#region packages/ui/Alert.tsx
|
|
3024
|
+
// packages/ui/Alert.tsx
|
|
3056
3025
|
const ICONS = {
|
|
3057
3026
|
danger: "ph-warning-circle",
|
|
3058
3027
|
warning: "ph-warning",
|
|
@@ -3068,8 +3037,7 @@ function Alert({ tone = "info", children, className }) {
|
|
|
3068
3037
|
}), /* @__PURE__ */ jsx("span", { children })]
|
|
3069
3038
|
});
|
|
3070
3039
|
}
|
|
3071
|
-
|
|
3072
|
-
//#region packages/ui/DescriptionList.tsx
|
|
3040
|
+
// packages/ui/DescriptionList.tsx
|
|
3073
3041
|
function DescriptionList({ items, className }) {
|
|
3074
3042
|
return /* @__PURE__ */ jsx("dl", {
|
|
3075
3043
|
className: joinClasses("nb-description-list", className),
|
|
@@ -3079,16 +3047,14 @@ function DescriptionList({ items, className }) {
|
|
|
3079
3047
|
}, item.term))
|
|
3080
3048
|
});
|
|
3081
3049
|
}
|
|
3082
|
-
|
|
3083
|
-
//#region packages/ui/Code.tsx
|
|
3050
|
+
// packages/ui/Code.tsx
|
|
3084
3051
|
function Code({ children, className }) {
|
|
3085
3052
|
return /* @__PURE__ */ jsx("code", {
|
|
3086
3053
|
className: joinClasses("nb-code", className),
|
|
3087
3054
|
children
|
|
3088
3055
|
});
|
|
3089
3056
|
}
|
|
3090
|
-
|
|
3091
|
-
//#region packages/ui/Text.tsx
|
|
3057
|
+
// packages/ui/Text.tsx
|
|
3092
3058
|
function Text({ children, tone = "default", as: Tag = "span", className, ...props }) {
|
|
3093
3059
|
return /* @__PURE__ */ jsx(Tag, {
|
|
3094
3060
|
className: joinClasses(tone === "muted" && "nb-text-muted", className),
|
|
@@ -3096,8 +3062,7 @@ function Text({ children, tone = "default", as: Tag = "span", className, ...prop
|
|
|
3096
3062
|
children
|
|
3097
3063
|
});
|
|
3098
3064
|
}
|
|
3099
|
-
|
|
3100
|
-
//#region packages/ui/Pagination.tsx
|
|
3065
|
+
// packages/ui/Pagination.tsx
|
|
3101
3066
|
function Pagination({ page, totalPages, onPageChange, ariaLabel, maxVisible = 7, className }) {
|
|
3102
3067
|
const strings = useUiStrings();
|
|
3103
3068
|
if (totalPages <= 1) return null;
|
|
@@ -3137,8 +3102,7 @@ function Pagination({ page, totalPages, onPageChange, ariaLabel, maxVisible = 7,
|
|
|
3137
3102
|
]
|
|
3138
3103
|
});
|
|
3139
3104
|
}
|
|
3140
|
-
|
|
3141
|
-
//#region packages/ui/RowActions.tsx
|
|
3105
|
+
// packages/ui/RowActions.tsx
|
|
3142
3106
|
/** Context menu preset for table row overflow actions. */
|
|
3143
3107
|
function RowActions({ items, triggerLabel, align = "right", className }) {
|
|
3144
3108
|
const strings = useUiStrings();
|
|
@@ -3151,8 +3115,7 @@ function RowActions({ items, triggerLabel, align = "right", className }) {
|
|
|
3151
3115
|
visible: true
|
|
3152
3116
|
});
|
|
3153
3117
|
}
|
|
3154
|
-
|
|
3155
|
-
//#region packages/ui/DataTable.tsx
|
|
3118
|
+
// packages/ui/DataTable.tsx
|
|
3156
3119
|
function alignClass(align) {
|
|
3157
3120
|
if (align === "right") return "nb-data-table__cell--num";
|
|
3158
3121
|
if (align === "center") return "nb-data-table__cell--center";
|
|
@@ -3196,8 +3159,7 @@ function DataTable({ columns, rows, getRowKey, emptyMessage, fill, variant = "de
|
|
|
3196
3159
|
})
|
|
3197
3160
|
}), pagination && /* @__PURE__ */ jsx(Pagination, { ...pagination })] });
|
|
3198
3161
|
}
|
|
3199
|
-
|
|
3200
|
-
//#region packages/ui/useConfirm.tsx
|
|
3162
|
+
// packages/ui/useConfirm.tsx
|
|
3201
3163
|
function useConfirm() {
|
|
3202
3164
|
const strings = useUiStrings();
|
|
3203
3165
|
const [pending, setPending] = useState(null);
|
|
@@ -3224,8 +3186,7 @@ function useConfirm() {
|
|
|
3224
3186
|
ConfirmHost
|
|
3225
3187
|
};
|
|
3226
3188
|
}
|
|
3227
|
-
|
|
3228
|
-
//#region packages/ui/Checkbox.tsx
|
|
3189
|
+
// packages/ui/Checkbox.tsx
|
|
3229
3190
|
/** Native checkbox, including the mixed state used by bulk selection. */
|
|
3230
3191
|
const Checkbox = forwardRef(function Checkbox({ label, indeterminate = false, invalid = false, id, className, ...props }, ref) {
|
|
3231
3192
|
const generatedId = useId();
|
|
@@ -3248,8 +3209,7 @@ const Checkbox = forwardRef(function Checkbox({ label, indeterminate = false, in
|
|
|
3248
3209
|
}), label && /* @__PURE__ */ jsx("span", { children: label })]
|
|
3249
3210
|
});
|
|
3250
3211
|
});
|
|
3251
|
-
|
|
3252
|
-
//#region packages/ui/RadioGroup.tsx
|
|
3212
|
+
// packages/ui/RadioGroup.tsx
|
|
3253
3213
|
/** Native radios share a name for browser keyboard navigation and form submission. */
|
|
3254
3214
|
function RadioGroup({ label, name, value, options, onChange, orientation = "vertical", required, invalid = false, disabled, className, ...props }) {
|
|
3255
3215
|
const generatedName = useId();
|
|
@@ -3275,8 +3235,7 @@ function RadioGroup({ label, name, value, options, onChange, orientation = "vert
|
|
|
3275
3235
|
})]
|
|
3276
3236
|
});
|
|
3277
3237
|
}
|
|
3278
|
-
|
|
3279
|
-
//#region packages/ui/Tabs.tsx
|
|
3238
|
+
// packages/ui/Tabs.tsx
|
|
3280
3239
|
function Tabs({ items, value, onChange, "aria-label": ariaLabel, orientation = "horizontal", activationMode = "automatic", keepMounted = false, className }) {
|
|
3281
3240
|
const id = useId();
|
|
3282
3241
|
const listRef = useRef(null);
|
|
@@ -3332,8 +3291,7 @@ function Tabs({ items, value, onChange, "aria-label": ariaLabel, orientation = "
|
|
|
3332
3291
|
}, item.value))]
|
|
3333
3292
|
});
|
|
3334
3293
|
}
|
|
3335
|
-
|
|
3336
|
-
//#region packages/ui/Spinner.tsx
|
|
3294
|
+
// packages/ui/Spinner.tsx
|
|
3337
3295
|
function Spinner({ label, size = "md", className, ...props }) {
|
|
3338
3296
|
return /* @__PURE__ */ jsx("span", {
|
|
3339
3297
|
...props,
|
|
@@ -3343,8 +3301,7 @@ function Spinner({ label, size = "md", className, ...props }) {
|
|
|
3343
3301
|
"aria-hidden": label ? void 0 : true
|
|
3344
3302
|
});
|
|
3345
3303
|
}
|
|
3346
|
-
|
|
3347
|
-
//#region packages/ui/Progress.tsx
|
|
3304
|
+
// packages/ui/Progress.tsx
|
|
3348
3305
|
/** Omit value for indeterminate progress; max defaults to 100. */
|
|
3349
3306
|
function Progress({ label, id, max = 100, className, ...props }) {
|
|
3350
3307
|
const generatedId = useId();
|
|
@@ -3362,8 +3319,7 @@ function Progress({ label, id, max = 100, className, ...props }) {
|
|
|
3362
3319
|
})]
|
|
3363
3320
|
});
|
|
3364
3321
|
}
|
|
3365
|
-
|
|
3366
|
-
//#region packages/ui/Tooltip.tsx
|
|
3322
|
+
// packages/ui/Tooltip.tsx
|
|
3367
3323
|
const TooltipProvider = Tooltip$1.Provider;
|
|
3368
3324
|
/** Uses the existing child as the trigger without adding a nested button. */
|
|
3369
3325
|
function Tooltip({ children, content, side = "top", delay, disabled, className }) {
|
|
@@ -3400,8 +3356,7 @@ function Tooltip({ children, content, side = "top", delay, disabled, className }
|
|
|
3400
3356
|
})]
|
|
3401
3357
|
});
|
|
3402
3358
|
}
|
|
3403
|
-
|
|
3404
|
-
//#region packages/ui/TimePicker.tsx
|
|
3359
|
+
// packages/ui/TimePicker.tsx
|
|
3405
3360
|
const timeValue = (value) => {
|
|
3406
3361
|
if (!value) return null;
|
|
3407
3362
|
try {
|
|
@@ -3443,8 +3398,7 @@ const TimePicker = forwardRef(function TimePicker({ id, name, value, onChange, o
|
|
|
3443
3398
|
})
|
|
3444
3399
|
});
|
|
3445
3400
|
});
|
|
3446
|
-
|
|
3447
|
-
//#region packages/ui/DetailLayout.tsx
|
|
3401
|
+
// packages/ui/DetailLayout.tsx
|
|
3448
3402
|
/** Responsive main/aside composition for record detail pages. */
|
|
3449
3403
|
function DetailLayout({ children, aside, asideLabel, className }) {
|
|
3450
3404
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -3459,5 +3413,575 @@ function DetailLayout({ children, aside, asideLabel, className }) {
|
|
|
3459
3413
|
})]
|
|
3460
3414
|
});
|
|
3461
3415
|
}
|
|
3462
|
-
|
|
3463
|
-
|
|
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 };
|