trotl-table 1.0.89 → 1.0.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Table.cjs.js +63 -40
- package/dist/Table.cjs.js.map +1 -1
- package/dist/Table.esm.js +63 -40
- package/dist/Table.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/Table.esm.js
CHANGED
|
@@ -9804,28 +9804,71 @@ function TableInner({
|
|
|
9804
9804
|
flex: "1 1 0%"
|
|
9805
9805
|
};
|
|
9806
9806
|
}, [columnWidths, getColumnKey]);
|
|
9807
|
-
const
|
|
9807
|
+
const getNestedValue = useCallback((row, accessor) => {
|
|
9808
9808
|
if (!row || accessor == null) return undefined;
|
|
9809
|
-
|
|
9810
|
-
// Support fallback accessors: ["preverjen", "Preverjen", ...]
|
|
9811
9809
|
if (Array.isArray(accessor)) {
|
|
9812
9810
|
for (const key of accessor) {
|
|
9813
|
-
|
|
9811
|
+
const value = getNestedValue(row, key);
|
|
9812
|
+
if (value !== undefined) return value;
|
|
9814
9813
|
}
|
|
9815
9814
|
return undefined;
|
|
9816
9815
|
}
|
|
9817
|
-
|
|
9816
|
+
const path = String(accessor).split(".").filter(Boolean);
|
|
9817
|
+
if (path.length === 0) return undefined;
|
|
9818
|
+
let current = row;
|
|
9819
|
+
for (const key of path) {
|
|
9820
|
+
if (current == null || typeof current !== "object") return undefined;
|
|
9821
|
+
current = current[key];
|
|
9822
|
+
}
|
|
9823
|
+
return current;
|
|
9818
9824
|
}, []);
|
|
9825
|
+
const getAccessorValue = useCallback((row, accessor) => {
|
|
9826
|
+
return getNestedValue(row, accessor);
|
|
9827
|
+
}, [getNestedValue]);
|
|
9819
9828
|
const getAccessorKey = useCallback((row, accessor) => {
|
|
9820
9829
|
if (accessor == null) return accessor;
|
|
9821
9830
|
if (Array.isArray(accessor)) {
|
|
9822
9831
|
for (const key of accessor) {
|
|
9823
|
-
if (row
|
|
9832
|
+
if (getNestedValue(row, key) !== undefined) return key;
|
|
9824
9833
|
}
|
|
9825
9834
|
return accessor[0];
|
|
9826
9835
|
}
|
|
9827
9836
|
return accessor;
|
|
9828
|
-
}, []);
|
|
9837
|
+
}, [getNestedValue]);
|
|
9838
|
+
const updateRowField = useCallback((row, accessor, value) => {
|
|
9839
|
+
if (row == null || typeof row !== "object") return row;
|
|
9840
|
+
if (Array.isArray(accessor)) {
|
|
9841
|
+
for (const key of accessor) {
|
|
9842
|
+
if (getNestedValue(row, key) !== undefined) {
|
|
9843
|
+
return updateRowField(row, key, value);
|
|
9844
|
+
}
|
|
9845
|
+
}
|
|
9846
|
+
return {
|
|
9847
|
+
...row,
|
|
9848
|
+
[accessor[0]]: value
|
|
9849
|
+
};
|
|
9850
|
+
}
|
|
9851
|
+
const path = String(accessor).split(".").filter(Boolean);
|
|
9852
|
+
if (path.length === 0) return row;
|
|
9853
|
+
if (path.length === 1) return {
|
|
9854
|
+
...row,
|
|
9855
|
+
[path[0]]: value
|
|
9856
|
+
};
|
|
9857
|
+
const nextRow = {
|
|
9858
|
+
...row
|
|
9859
|
+
};
|
|
9860
|
+
let current = nextRow;
|
|
9861
|
+
for (let i = 0; i < path.length - 1; i += 1) {
|
|
9862
|
+
const key = path[i];
|
|
9863
|
+
const nextValue = current[key];
|
|
9864
|
+
current[key] = nextValue && typeof nextValue === "object" ? {
|
|
9865
|
+
...nextValue
|
|
9866
|
+
} : {};
|
|
9867
|
+
current = current[key];
|
|
9868
|
+
}
|
|
9869
|
+
current[path[path.length - 1]] = value;
|
|
9870
|
+
return nextRow;
|
|
9871
|
+
}, [getNestedValue]);
|
|
9829
9872
|
const normalizeHighlightComparable = useCallback((value, compareTo) => {
|
|
9830
9873
|
if (value instanceof Date || compareTo instanceof Date) {
|
|
9831
9874
|
const leftTime = value == null ? NaN : new Date(value).getTime();
|
|
@@ -10555,16 +10598,10 @@ function TableInner({
|
|
|
10555
10598
|
if (isGrouped) {
|
|
10556
10599
|
return prev.map(g => ({
|
|
10557
10600
|
...g,
|
|
10558
|
-
rows: (g.rows || []).map(r => r.id === row.id ?
|
|
10559
|
-
...r,
|
|
10560
|
-
[accessor]: next
|
|
10561
|
-
} : r)
|
|
10601
|
+
rows: (g.rows || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r)
|
|
10562
10602
|
}));
|
|
10563
10603
|
}
|
|
10564
|
-
return (prev || []).map(r => r.id === row.id ?
|
|
10565
|
-
...r,
|
|
10566
|
-
[accessor]: next
|
|
10567
|
-
} : r);
|
|
10604
|
+
return (prev || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r);
|
|
10568
10605
|
});
|
|
10569
10606
|
refreshTriggerRef.current?.();
|
|
10570
10607
|
try {
|
|
@@ -10593,16 +10630,10 @@ function TableInner({
|
|
|
10593
10630
|
if (isGrouped) {
|
|
10594
10631
|
return prev.map(g => ({
|
|
10595
10632
|
...g,
|
|
10596
|
-
rows: (g.rows || []).map(r => r.id === row.id ?
|
|
10597
|
-
...r,
|
|
10598
|
-
[accessor]: next
|
|
10599
|
-
} : r)
|
|
10633
|
+
rows: (g.rows || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r)
|
|
10600
10634
|
}));
|
|
10601
10635
|
}
|
|
10602
|
-
return (prev || []).map(r => r.id === row.id ?
|
|
10603
|
-
...r,
|
|
10604
|
-
[accessor]: next
|
|
10605
|
-
} : r);
|
|
10636
|
+
return (prev || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r);
|
|
10606
10637
|
});
|
|
10607
10638
|
refreshTriggerRef.current?.();
|
|
10608
10639
|
try {
|
|
@@ -10657,16 +10688,10 @@ function TableInner({
|
|
|
10657
10688
|
if (isGrouped) {
|
|
10658
10689
|
return prev.map(g => ({
|
|
10659
10690
|
...g,
|
|
10660
|
-
rows: (g.rows || []).map(r => r.id === row.id ?
|
|
10661
|
-
...r,
|
|
10662
|
-
[accessor]: next
|
|
10663
|
-
} : r)
|
|
10691
|
+
rows: (g.rows || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r)
|
|
10664
10692
|
}));
|
|
10665
10693
|
}
|
|
10666
|
-
return (prev || []).map(r => r.id === row.id ?
|
|
10667
|
-
...r,
|
|
10668
|
-
[accessor]: next
|
|
10669
|
-
} : r);
|
|
10694
|
+
return (prev || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r);
|
|
10670
10695
|
});
|
|
10671
10696
|
refreshTriggerRef.current?.();
|
|
10672
10697
|
try {
|
|
@@ -10701,16 +10726,10 @@ function TableInner({
|
|
|
10701
10726
|
if (isGrouped) {
|
|
10702
10727
|
return prev.map(g => ({
|
|
10703
10728
|
...g,
|
|
10704
|
-
rows: (g.rows || []).map(r => r.id === row.id ?
|
|
10705
|
-
...r,
|
|
10706
|
-
[accessor]: next
|
|
10707
|
-
} : r)
|
|
10729
|
+
rows: (g.rows || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r)
|
|
10708
10730
|
}));
|
|
10709
10731
|
}
|
|
10710
|
-
return (prev || []).map(r => r.id === row.id ?
|
|
10711
|
-
...r,
|
|
10712
|
-
[accessor]: next
|
|
10713
|
-
} : r);
|
|
10732
|
+
return (prev || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r);
|
|
10714
10733
|
});
|
|
10715
10734
|
refreshTriggerRef.current?.();
|
|
10716
10735
|
try {
|
|
@@ -11395,6 +11414,10 @@ function TableInner({
|
|
|
11395
11414
|
showCancel: true,
|
|
11396
11415
|
showConfirm: true
|
|
11397
11416
|
}, /*#__PURE__*/React__default.createElement("p", null, translate("areYouSureYouWantToDelete"), " ", /*#__PURE__*/React__default.createElement("strong", null, pendingDelete ? pendingDelete[deleteLabelKey] ?? pendingDelete.name ?? pendingDelete.id : ""), "?")));
|
|
11417
|
+
const getContextActionLabel = (action, row, index) => {
|
|
11418
|
+
const label = typeof action?.label === "function" ? action.label(row, action) : action?.label;
|
|
11419
|
+
return label || action?.text || `Action ${index + 1}`;
|
|
11420
|
+
};
|
|
11398
11421
|
const contextMenuMarkup = contextMenu.visible && rightClickActions.length > 0 ? /*#__PURE__*/React__default.createElement("div", {
|
|
11399
11422
|
style: {
|
|
11400
11423
|
position: "fixed",
|
|
@@ -11421,7 +11444,7 @@ function TableInner({
|
|
|
11421
11444
|
onMouseEnter: () => setHoveredActionIndex(i),
|
|
11422
11445
|
onMouseLeave: () => setHoveredActionIndex(null),
|
|
11423
11446
|
onClick: () => performContextMenuAction(action, contextMenu.row)
|
|
11424
|
-
}, action
|
|
11447
|
+
}, getContextActionLabel(action, contextMenu.row, i)))) : null;
|
|
11425
11448
|
const contextMenuModalMarkup = contextMenuModal.visible && contextMenuModal.component ? /*#__PURE__*/React__default.createElement(Modal, {
|
|
11426
11449
|
isOpen: true,
|
|
11427
11450
|
title: contextMenuModal.title || "",
|