trotl-table 1.0.90 → 1.0.92
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 +75 -93
- package/dist/Table.cjs.js.map +1 -1
- package/dist/Table.esm.js +75 -93
- package/dist/Table.esm.js.map +1 -1
- package/dist/WorkOrderAnalyticsByClient.cjs.js +417 -0
- package/dist/WorkOrderAnalyticsByClient.cjs.js.map +1 -0
- package/dist/WorkOrderAnalyticsByClient.esm.js +412 -0
- package/dist/WorkOrderAnalyticsByClient.esm.js.map +1 -0
- package/package.json +1 -1
package/dist/Table.esm.js
CHANGED
|
@@ -9641,8 +9641,6 @@ function TableInner({
|
|
|
9641
9641
|
onCellChange = () => {},
|
|
9642
9642
|
// callback for any cell click
|
|
9643
9643
|
cellCallback = () => {},
|
|
9644
|
-
// when true, skip the integrated confirmation modal and delete immediately
|
|
9645
|
-
disableDeleteModal = false,
|
|
9646
9644
|
deleteLabelKey = "name",
|
|
9647
9645
|
buttons = ["view", "edit", "delete", "share", "duplicate"],
|
|
9648
9646
|
enableDragRow = false,
|
|
@@ -9695,6 +9693,9 @@ function TableInner({
|
|
|
9695
9693
|
return translations[key] || key;
|
|
9696
9694
|
};
|
|
9697
9695
|
}
|
|
9696
|
+
|
|
9697
|
+
// normalize delete modal flag early (handles string 'false' etc)
|
|
9698
|
+
|
|
9698
9699
|
// Use refs for callbacks to prevent infinite loops from dependency changes
|
|
9699
9700
|
const selectedRowsCallbackRef = useRef(selectedRowsCallback);
|
|
9700
9701
|
const refreshTriggerRef = useRef(refreshTrigger);
|
|
@@ -9804,28 +9805,71 @@ function TableInner({
|
|
|
9804
9805
|
flex: "1 1 0%"
|
|
9805
9806
|
};
|
|
9806
9807
|
}, [columnWidths, getColumnKey]);
|
|
9807
|
-
const
|
|
9808
|
+
const getNestedValue = useCallback((row, accessor) => {
|
|
9808
9809
|
if (!row || accessor == null) return undefined;
|
|
9809
|
-
|
|
9810
|
-
// Support fallback accessors: ["preverjen", "Preverjen", ...]
|
|
9811
9810
|
if (Array.isArray(accessor)) {
|
|
9812
9811
|
for (const key of accessor) {
|
|
9813
|
-
|
|
9812
|
+
const value = getNestedValue(row, key);
|
|
9813
|
+
if (value !== undefined) return value;
|
|
9814
9814
|
}
|
|
9815
9815
|
return undefined;
|
|
9816
9816
|
}
|
|
9817
|
-
|
|
9817
|
+
const path = String(accessor).split(".").filter(Boolean);
|
|
9818
|
+
if (path.length === 0) return undefined;
|
|
9819
|
+
let current = row;
|
|
9820
|
+
for (const key of path) {
|
|
9821
|
+
if (current == null || typeof current !== "object") return undefined;
|
|
9822
|
+
current = current[key];
|
|
9823
|
+
}
|
|
9824
|
+
return current;
|
|
9818
9825
|
}, []);
|
|
9826
|
+
const getAccessorValue = useCallback((row, accessor) => {
|
|
9827
|
+
return getNestedValue(row, accessor);
|
|
9828
|
+
}, [getNestedValue]);
|
|
9819
9829
|
const getAccessorKey = useCallback((row, accessor) => {
|
|
9820
9830
|
if (accessor == null) return accessor;
|
|
9821
9831
|
if (Array.isArray(accessor)) {
|
|
9822
9832
|
for (const key of accessor) {
|
|
9823
|
-
if (row
|
|
9833
|
+
if (getNestedValue(row, key) !== undefined) return key;
|
|
9824
9834
|
}
|
|
9825
9835
|
return accessor[0];
|
|
9826
9836
|
}
|
|
9827
9837
|
return accessor;
|
|
9828
|
-
}, []);
|
|
9838
|
+
}, [getNestedValue]);
|
|
9839
|
+
const updateRowField = useCallback((row, accessor, value) => {
|
|
9840
|
+
if (row == null || typeof row !== "object") return row;
|
|
9841
|
+
if (Array.isArray(accessor)) {
|
|
9842
|
+
for (const key of accessor) {
|
|
9843
|
+
if (getNestedValue(row, key) !== undefined) {
|
|
9844
|
+
return updateRowField(row, key, value);
|
|
9845
|
+
}
|
|
9846
|
+
}
|
|
9847
|
+
return {
|
|
9848
|
+
...row,
|
|
9849
|
+
[accessor[0]]: value
|
|
9850
|
+
};
|
|
9851
|
+
}
|
|
9852
|
+
const path = String(accessor).split(".").filter(Boolean);
|
|
9853
|
+
if (path.length === 0) return row;
|
|
9854
|
+
if (path.length === 1) return {
|
|
9855
|
+
...row,
|
|
9856
|
+
[path[0]]: value
|
|
9857
|
+
};
|
|
9858
|
+
const nextRow = {
|
|
9859
|
+
...row
|
|
9860
|
+
};
|
|
9861
|
+
let current = nextRow;
|
|
9862
|
+
for (let i = 0; i < path.length - 1; i += 1) {
|
|
9863
|
+
const key = path[i];
|
|
9864
|
+
const nextValue = current[key];
|
|
9865
|
+
current[key] = nextValue && typeof nextValue === "object" ? {
|
|
9866
|
+
...nextValue
|
|
9867
|
+
} : {};
|
|
9868
|
+
current = current[key];
|
|
9869
|
+
}
|
|
9870
|
+
current[path[path.length - 1]] = value;
|
|
9871
|
+
return nextRow;
|
|
9872
|
+
}, [getNestedValue]);
|
|
9829
9873
|
const normalizeHighlightComparable = useCallback((value, compareTo) => {
|
|
9830
9874
|
if (value instanceof Date || compareTo instanceof Date) {
|
|
9831
9875
|
const leftTime = value == null ? NaN : new Date(value).getTime();
|
|
@@ -10119,17 +10163,25 @@ function TableInner({
|
|
|
10119
10163
|
return a === b;
|
|
10120
10164
|
}, []);
|
|
10121
10165
|
const formatArrayValue = useCallback((value, col) => {
|
|
10122
|
-
if (!Array.isArray(value)) return
|
|
10166
|
+
if (!Array.isArray(value)) return "";
|
|
10123
10167
|
const objectKey = col?.objectKey;
|
|
10124
10168
|
const parts = value.map(item => {
|
|
10125
10169
|
if (item == null) return "";
|
|
10170
|
+
|
|
10171
|
+
// When objectKey is configured, only use that field. This prevents
|
|
10172
|
+
// objects without a label from displaying their key or JSON value.
|
|
10173
|
+
if (objectKey) {
|
|
10174
|
+
if (typeof item !== "object" || typeof item[objectKey] !== "string") {
|
|
10175
|
+
return "";
|
|
10176
|
+
}
|
|
10177
|
+
return item[objectKey].trim();
|
|
10178
|
+
}
|
|
10126
10179
|
if (typeof item !== "object") return String(item);
|
|
10127
|
-
if (objectKey && item?.[objectKey] !== undefined) return String(item[objectKey]);
|
|
10128
10180
|
if (item.label !== undefined) return String(item.label);
|
|
10129
10181
|
if (item.value !== undefined) return String(item.value);
|
|
10130
10182
|
return JSON.stringify(item);
|
|
10131
|
-
}).filter(
|
|
10132
|
-
return parts.join(", ");
|
|
10183
|
+
}).filter(Boolean);
|
|
10184
|
+
return [...new Set(parts)].join(", ");
|
|
10133
10185
|
}, []);
|
|
10134
10186
|
|
|
10135
10187
|
// console.log(extraSearchTerm)
|
|
@@ -10555,16 +10607,10 @@ function TableInner({
|
|
|
10555
10607
|
if (isGrouped) {
|
|
10556
10608
|
return prev.map(g => ({
|
|
10557
10609
|
...g,
|
|
10558
|
-
rows: (g.rows || []).map(r => r.id === row.id ?
|
|
10559
|
-
...r,
|
|
10560
|
-
[accessor]: next
|
|
10561
|
-
} : r)
|
|
10610
|
+
rows: (g.rows || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r)
|
|
10562
10611
|
}));
|
|
10563
10612
|
}
|
|
10564
|
-
return (prev || []).map(r => r.id === row.id ?
|
|
10565
|
-
...r,
|
|
10566
|
-
[accessor]: next
|
|
10567
|
-
} : r);
|
|
10613
|
+
return (prev || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r);
|
|
10568
10614
|
});
|
|
10569
10615
|
refreshTriggerRef.current?.();
|
|
10570
10616
|
try {
|
|
@@ -10593,16 +10639,10 @@ function TableInner({
|
|
|
10593
10639
|
if (isGrouped) {
|
|
10594
10640
|
return prev.map(g => ({
|
|
10595
10641
|
...g,
|
|
10596
|
-
rows: (g.rows || []).map(r => r.id === row.id ?
|
|
10597
|
-
...r,
|
|
10598
|
-
[accessor]: next
|
|
10599
|
-
} : r)
|
|
10642
|
+
rows: (g.rows || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r)
|
|
10600
10643
|
}));
|
|
10601
10644
|
}
|
|
10602
|
-
return (prev || []).map(r => r.id === row.id ?
|
|
10603
|
-
...r,
|
|
10604
|
-
[accessor]: next
|
|
10605
|
-
} : r);
|
|
10645
|
+
return (prev || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r);
|
|
10606
10646
|
});
|
|
10607
10647
|
refreshTriggerRef.current?.();
|
|
10608
10648
|
try {
|
|
@@ -10657,16 +10697,10 @@ function TableInner({
|
|
|
10657
10697
|
if (isGrouped) {
|
|
10658
10698
|
return prev.map(g => ({
|
|
10659
10699
|
...g,
|
|
10660
|
-
rows: (g.rows || []).map(r => r.id === row.id ?
|
|
10661
|
-
...r,
|
|
10662
|
-
[accessor]: next
|
|
10663
|
-
} : r)
|
|
10700
|
+
rows: (g.rows || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r)
|
|
10664
10701
|
}));
|
|
10665
10702
|
}
|
|
10666
|
-
return (prev || []).map(r => r.id === row.id ?
|
|
10667
|
-
...r,
|
|
10668
|
-
[accessor]: next
|
|
10669
|
-
} : r);
|
|
10703
|
+
return (prev || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r);
|
|
10670
10704
|
});
|
|
10671
10705
|
refreshTriggerRef.current?.();
|
|
10672
10706
|
try {
|
|
@@ -10701,16 +10735,10 @@ function TableInner({
|
|
|
10701
10735
|
if (isGrouped) {
|
|
10702
10736
|
return prev.map(g => ({
|
|
10703
10737
|
...g,
|
|
10704
|
-
rows: (g.rows || []).map(r => r.id === row.id ?
|
|
10705
|
-
...r,
|
|
10706
|
-
[accessor]: next
|
|
10707
|
-
} : r)
|
|
10738
|
+
rows: (g.rows || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r)
|
|
10708
10739
|
}));
|
|
10709
10740
|
}
|
|
10710
|
-
return (prev || []).map(r => r.id === row.id ?
|
|
10711
|
-
...r,
|
|
10712
|
-
[accessor]: next
|
|
10713
|
-
} : r);
|
|
10741
|
+
return (prev || []).map(r => r.id === row.id ? updateRowField(r, accessor, next) : r);
|
|
10714
10742
|
});
|
|
10715
10743
|
refreshTriggerRef.current?.();
|
|
10716
10744
|
try {
|
|
@@ -10752,10 +10780,8 @@ function TableInner({
|
|
|
10752
10780
|
}, formatted);
|
|
10753
10781
|
}
|
|
10754
10782
|
if (col && col.type === "array") {
|
|
10755
|
-
const
|
|
10756
|
-
const
|
|
10757
|
-
const count = arr.length;
|
|
10758
|
-
const display = count > 0 ? `${count}: ${list}` : "...";
|
|
10783
|
+
const list = formatArrayValue(v, col);
|
|
10784
|
+
const display = list || "...";
|
|
10759
10785
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
10760
10786
|
title: list || translate("noData")
|
|
10761
10787
|
}, display);
|
|
@@ -10939,50 +10965,6 @@ function TableInner({
|
|
|
10939
10965
|
});
|
|
10940
10966
|
}, [tableDataFlat, isGrouped, groupKey]);
|
|
10941
10967
|
|
|
10942
|
-
// DUPLICATE
|
|
10943
|
-
useCallback(row => {
|
|
10944
|
-
if (!row) return;
|
|
10945
|
-
// try user callback first; if it returns an object with newRow use that
|
|
10946
|
-
let newRow = null;
|
|
10947
|
-
if (duplicateCallbackRef.current) {
|
|
10948
|
-
try {
|
|
10949
|
-
const res = duplicateCallbackRef.current(row);
|
|
10950
|
-
if (res && res.newRow) {
|
|
10951
|
-
newRow = res.newRow;
|
|
10952
|
-
}
|
|
10953
|
-
} catch (err) {
|
|
10954
|
-
console.error("duplicateCallback threw", err);
|
|
10955
|
-
}
|
|
10956
|
-
}
|
|
10957
|
-
// fallback simple clone if callback didn't provide newRow
|
|
10958
|
-
if (!newRow) {
|
|
10959
|
-
newRow = {
|
|
10960
|
-
...row
|
|
10961
|
-
};
|
|
10962
|
-
// give it a distinct id if possible
|
|
10963
|
-
if (newRow.id != null) {
|
|
10964
|
-
newRow.id = `${newRow.id}-dup-${Date.now()}`;
|
|
10965
|
-
}
|
|
10966
|
-
}
|
|
10967
|
-
setLocalData(prev => {
|
|
10968
|
-
if (isGrouped) {
|
|
10969
|
-
return prev.map(g => {
|
|
10970
|
-
const gid = g[groupKey] ?? g.groupId ?? g.groupName;
|
|
10971
|
-
// insert into same group as original row
|
|
10972
|
-
if (row[groupKey] === gid || g.rows.some(r => r.id === row.id)) {
|
|
10973
|
-
return {
|
|
10974
|
-
...g,
|
|
10975
|
-
rows: [...(g.rows || []), newRow]
|
|
10976
|
-
};
|
|
10977
|
-
}
|
|
10978
|
-
return g;
|
|
10979
|
-
});
|
|
10980
|
-
}
|
|
10981
|
-
return [...(prev || []), newRow];
|
|
10982
|
-
});
|
|
10983
|
-
refreshTriggerRef.current?.();
|
|
10984
|
-
}, [duplicateCallbackRef, isGrouped, groupKey, refreshTriggerRef]);
|
|
10985
|
-
|
|
10986
10968
|
// ROW RENDERER
|
|
10987
10969
|
const rowRenderer = useCallback(({
|
|
10988
10970
|
index,
|