trotl-table 1.0.61 → 1.0.63
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 +46 -8
- package/dist/Table.cjs.js.map +1 -1
- package/dist/Table.esm.js +46 -8
- package/dist/Table.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/Table.cjs.js
CHANGED
|
@@ -9657,6 +9657,8 @@ function TableInner({
|
|
|
9657
9657
|
downloadCallback = () => {},
|
|
9658
9658
|
// callback for cell edits: (row, accessor, newValue)
|
|
9659
9659
|
onCellChange = () => {},
|
|
9660
|
+
// callback for any cell click
|
|
9661
|
+
cellCallback = () => {},
|
|
9660
9662
|
// when true, skip the integrated confirmation modal and delete immediately
|
|
9661
9663
|
disableDeleteModal = false,
|
|
9662
9664
|
deleteLabelKey = "name",
|
|
@@ -9714,6 +9716,7 @@ function TableInner({
|
|
|
9714
9716
|
const duplicateCallbackRef = React.useRef(duplicateCallback);
|
|
9715
9717
|
const downloadCallbackRef = React.useRef(downloadCallback);
|
|
9716
9718
|
const onCellChangeRef = React.useRef(onCellChange);
|
|
9719
|
+
const cellCallbackRef = React.useRef(cellCallback);
|
|
9717
9720
|
|
|
9718
9721
|
// Update refs when callbacks change (using useLayoutEffect to update before render)
|
|
9719
9722
|
React.useLayoutEffect(() => {
|
|
@@ -9723,6 +9726,7 @@ function TableInner({
|
|
|
9723
9726
|
editCallbackRef.current = editCallback;
|
|
9724
9727
|
deleteCallbackRef.current = deleteCallback;
|
|
9725
9728
|
onCellChangeRef.current = onCellChange;
|
|
9729
|
+
cellCallbackRef.current = cellCallback;
|
|
9726
9730
|
});
|
|
9727
9731
|
React.useEffect(() => {
|
|
9728
9732
|
shareCallbackRef.current = shareCallback;
|
|
@@ -10179,6 +10183,28 @@ function TableInner({
|
|
|
10179
10183
|
title: text
|
|
10180
10184
|
}, text.slice(idx + query.length)));
|
|
10181
10185
|
}, [searchTerm]);
|
|
10186
|
+
const triggerCellCallback = React.useCallback((row, col, explicitValue) => {
|
|
10187
|
+
const accessor = col?.accessor ?? null;
|
|
10188
|
+
const value = explicitValue !== undefined ? explicitValue : accessor != null ? row?.[accessor] : undefined;
|
|
10189
|
+
const type = col?.type ?? (col?.isCustom ? "custom" : "text");
|
|
10190
|
+
try {
|
|
10191
|
+
const callback = cellCallbackRef.current;
|
|
10192
|
+
if (typeof callback !== "function") return;
|
|
10193
|
+
if (callback.length >= 2) {
|
|
10194
|
+
callback(row, accessor, value, col);
|
|
10195
|
+
return;
|
|
10196
|
+
}
|
|
10197
|
+
callback({
|
|
10198
|
+
type,
|
|
10199
|
+
accessor,
|
|
10200
|
+
value,
|
|
10201
|
+
row,
|
|
10202
|
+
column: col
|
|
10203
|
+
});
|
|
10204
|
+
} catch (err) {
|
|
10205
|
+
console.error("cellCallback error", err);
|
|
10206
|
+
}
|
|
10207
|
+
}, []);
|
|
10182
10208
|
const renderCell = React.useCallback((v, accessor, row, col) => {
|
|
10183
10209
|
// Checkbox column type (editable in-table)
|
|
10184
10210
|
if (col && col.type === 'checkbox') {
|
|
@@ -10186,7 +10212,10 @@ function TableInner({
|
|
|
10186
10212
|
return /*#__PURE__*/React.createElement("input", {
|
|
10187
10213
|
type: "checkbox",
|
|
10188
10214
|
checked: checked,
|
|
10189
|
-
onClick: e =>
|
|
10215
|
+
onClick: e => {
|
|
10216
|
+
e.stopPropagation();
|
|
10217
|
+
triggerCellCallback(row, col, checked);
|
|
10218
|
+
},
|
|
10190
10219
|
onChange: e => {
|
|
10191
10220
|
const next = !!e.target.checked;
|
|
10192
10221
|
setLocalData(prev => {
|
|
@@ -10218,7 +10247,10 @@ function TableInner({
|
|
|
10218
10247
|
if (col && col.type === 'switch') {
|
|
10219
10248
|
const checked = !!v;
|
|
10220
10249
|
return /*#__PURE__*/React.createElement("div", {
|
|
10221
|
-
onClick: e =>
|
|
10250
|
+
onClick: e => {
|
|
10251
|
+
e.stopPropagation();
|
|
10252
|
+
triggerCellCallback(row, col, checked);
|
|
10253
|
+
}
|
|
10222
10254
|
}, /*#__PURE__*/React.createElement(Switch.default, {
|
|
10223
10255
|
checked: checked,
|
|
10224
10256
|
onChange: valOrEvent => {
|
|
@@ -10255,7 +10287,10 @@ function TableInner({
|
|
|
10255
10287
|
type: "text",
|
|
10256
10288
|
className: "table-cell-input",
|
|
10257
10289
|
value: text,
|
|
10258
|
-
onClick: e =>
|
|
10290
|
+
onClick: e => {
|
|
10291
|
+
e.stopPropagation();
|
|
10292
|
+
triggerCellCallback(row, col, text);
|
|
10293
|
+
},
|
|
10259
10294
|
onChange: e => {
|
|
10260
10295
|
const next = e.target.value;
|
|
10261
10296
|
setLocalData(prev => {
|
|
@@ -10331,7 +10366,7 @@ function TableInner({
|
|
|
10331
10366
|
}
|
|
10332
10367
|
// existing highlight logic for other fields
|
|
10333
10368
|
return highlight(String(v));
|
|
10334
|
-
}, [highlight, isGrouped]);
|
|
10369
|
+
}, [highlight, isGrouped, triggerCellCallback]);
|
|
10335
10370
|
const showView = buttons.includes("view");
|
|
10336
10371
|
const showEdit = buttons.includes("edit");
|
|
10337
10372
|
// show delete only when view is also shown (per request)
|
|
@@ -10565,7 +10600,8 @@ function TableInner({
|
|
|
10565
10600
|
className: "table-cell group-header",
|
|
10566
10601
|
style: {
|
|
10567
10602
|
width: '100%'
|
|
10568
|
-
}
|
|
10603
|
+
},
|
|
10604
|
+
title: `${translate(item.groupName)} (0)`
|
|
10569
10605
|
}, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (0) \u2014 ", translate("DropHereToMoveIntoThisGroup")), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
|
|
10570
10606
|
key: i,
|
|
10571
10607
|
className: "table-cell"
|
|
@@ -10605,7 +10641,8 @@ function TableInner({
|
|
|
10605
10641
|
maxWidth: keyWidth
|
|
10606
10642
|
} : undefined
|
|
10607
10643
|
}), /*#__PURE__*/React.createElement("div", {
|
|
10608
|
-
className: "table-cell group-header"
|
|
10644
|
+
className: "table-cell group-header",
|
|
10645
|
+
title: `${translate(item.groupName)} (${item.rowCount})`
|
|
10609
10646
|
}, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (", item.rowCount, ")"), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
|
|
10610
10647
|
key: i,
|
|
10611
10648
|
className: "table-cell"
|
|
@@ -10678,7 +10715,8 @@ function TableInner({
|
|
|
10678
10715
|
return /*#__PURE__*/React.createElement("div", {
|
|
10679
10716
|
key: i,
|
|
10680
10717
|
className: "table-cell",
|
|
10681
|
-
style: cellStyle
|
|
10718
|
+
style: cellStyle,
|
|
10719
|
+
onClick: () => triggerCellCallback(row, col)
|
|
10682
10720
|
}, col.isCustom ? typeof col.render === 'function' ? col.render(row, i) : col.render : renderCell(row[col.accessor], col.accessor, row, col));
|
|
10683
10721
|
})), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10684
10722
|
className: "table-cell action-cell",
|
|
@@ -10753,7 +10791,7 @@ function TableInner({
|
|
|
10753
10791
|
}, content);
|
|
10754
10792
|
}
|
|
10755
10793
|
return content;
|
|
10756
|
-
}, [tableDataFlat, columns, selectedRows, toggleRowSelection, groupRowsById, renderCell, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, doubleClickEnable, keyWidth, actionColumnStyle, showDuplicate, showDownload, showIcons, showShare]);
|
|
10794
|
+
}, [tableDataFlat, columns, selectedRows, toggleRowSelection, groupRowsById, renderCell, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, doubleClickEnable, keyWidth, actionColumnStyle, showDuplicate, showDownload, showIcons, showShare, triggerCellCallback]);
|
|
10757
10795
|
const rowHeightGetter = ({
|
|
10758
10796
|
index
|
|
10759
10797
|
}) => tableDataFlat[index]?.type === "group" ? groupHeaderHeight : rowHeight;
|