trotl-table 1.0.57 → 1.0.59
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 +9 -2
- package/dist/Table.cjs.js +19 -2
- package/dist/Table.cjs.js.map +1 -1
- package/dist/Table.esm.js +19 -2
- package/dist/Table.esm.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,6 +72,11 @@ export default function Demo() {
|
|
|
72
72
|
console.log("view", row);
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
+
const downloadCallback = (row) => {
|
|
76
|
+
console.log("download", row);
|
|
77
|
+
// perform download logic here
|
|
78
|
+
};
|
|
79
|
+
|
|
75
80
|
// handle cell edits (e.g. checkbox column)
|
|
76
81
|
const onCellChange = (row, accessor, value) => {
|
|
77
82
|
console.log('cell changed', row.id, accessor, value);
|
|
@@ -94,7 +99,8 @@ export default function Demo() {
|
|
|
94
99
|
deleteCallback={deleteCallback}
|
|
95
100
|
editCallback={editCallback}
|
|
96
101
|
viewCallback={viewCallback}
|
|
97
|
-
|
|
102
|
+
downloadCallback={downloadCallback}
|
|
103
|
+
buttons={["view", "edit", "delete", "download"]}
|
|
98
104
|
/>
|
|
99
105
|
);
|
|
100
106
|
}
|
|
@@ -129,8 +135,9 @@ export default function Demo() {
|
|
|
129
135
|
- `editCallback`: callback when editing a row
|
|
130
136
|
- `viewCallback`: callback when viewing a row
|
|
131
137
|
- `deleteCallback`: async callback for deleting a row
|
|
138
|
+
- `downloadCallback`: callback invoked when the user clicks the **download** action (row passed as argument)
|
|
132
139
|
- Note: earlier versions required the delete button for multi‑select; now `enableMultiSelect` works even when `buttons` is empty
|
|
133
|
-
- `buttons`: array of action buttons to show
|
|
140
|
+
- `buttons`: array of action buttons to show (supports `"view"`, `"edit"`, `"delete"`, `"share"`, `"duplicate"` and `"download"`)
|
|
134
141
|
- `onCellChange`: callback invoked when a cell value changes (signature: `(row, accessor, newValue)`).
|
|
135
142
|
- Supported editable column `type` values: `checkbox`, `switch` (renders a `Switch` component), `input` (renders a text input).
|
|
136
143
|
|
package/dist/Table.cjs.js
CHANGED
|
@@ -9653,6 +9653,8 @@ function TableInner({
|
|
|
9653
9653
|
deleteCallback = null,
|
|
9654
9654
|
shareCallback = () => {},
|
|
9655
9655
|
duplicateCallback = () => {},
|
|
9656
|
+
// new download callback
|
|
9657
|
+
downloadCallback = () => {},
|
|
9656
9658
|
// callback for cell edits: (row, accessor, newValue)
|
|
9657
9659
|
onCellChange = () => {},
|
|
9658
9660
|
// when true, skip the integrated confirmation modal and delete immediately
|
|
@@ -9692,6 +9694,7 @@ function TableInner({
|
|
|
9692
9694
|
delete: "Delete",
|
|
9693
9695
|
share: "Share",
|
|
9694
9696
|
duplicate: "Duplicate",
|
|
9697
|
+
download: "Download",
|
|
9695
9698
|
confirmDelete: "Confirm Delete",
|
|
9696
9699
|
yesDelete: "Yes, Delete",
|
|
9697
9700
|
areYouSureYouWantToDelete: "Are you sure you want to delete",
|
|
@@ -9709,6 +9712,7 @@ function TableInner({
|
|
|
9709
9712
|
const deleteCallbackRef = React.useRef(deleteCallback);
|
|
9710
9713
|
const shareCallbackRef = React.useRef(shareCallback);
|
|
9711
9714
|
const duplicateCallbackRef = React.useRef(duplicateCallback);
|
|
9715
|
+
const downloadCallbackRef = React.useRef(downloadCallback);
|
|
9712
9716
|
const onCellChangeRef = React.useRef(onCellChange);
|
|
9713
9717
|
|
|
9714
9718
|
// Update refs when callbacks change (using useLayoutEffect to update before render)
|
|
@@ -9726,6 +9730,9 @@ function TableInner({
|
|
|
9726
9730
|
React.useEffect(() => {
|
|
9727
9731
|
duplicateCallbackRef.current = duplicateCallback;
|
|
9728
9732
|
}, [duplicateCallback]);
|
|
9733
|
+
React.useEffect(() => {
|
|
9734
|
+
downloadCallbackRef.current = downloadCallback;
|
|
9735
|
+
}, [downloadCallback]);
|
|
9729
9736
|
const resolvedInitialSelectedRows = React.useMemo(() => {
|
|
9730
9737
|
const source = Array.isArray(initialSelectedRows) ? initialSelectedRows : Array.isArray(initaialSelectedRows) ? initaialSelectedRows : [];
|
|
9731
9738
|
return [...new Set(source.map(item => item && typeof item === "object" ? item.id : item).filter(id => id != null))];
|
|
@@ -10331,7 +10338,8 @@ function TableInner({
|
|
|
10331
10338
|
const showDelete = showView && buttons.includes("delete");
|
|
10332
10339
|
const showShare = buttons.includes("share");
|
|
10333
10340
|
const showDuplicate = buttons.includes("duplicate") || buttons.includes("duplicates");
|
|
10334
|
-
const
|
|
10341
|
+
const showDownload = buttons.includes("download");
|
|
10342
|
+
const showActions = showView || showEdit || showDelete || showShare || showDuplicate || showDownload;
|
|
10335
10343
|
|
|
10336
10344
|
// MOVE ROW (internal + between groups)
|
|
10337
10345
|
// moveRow: allow toIndex to be null or an object { emptyGroupId } for empty group drop
|
|
@@ -10704,7 +10712,16 @@ function TableInner({
|
|
|
10704
10712
|
role: "img",
|
|
10705
10713
|
"aria-hidden": "false",
|
|
10706
10714
|
title: translate("share")
|
|
10707
|
-
}, "\uD83D\uDD17") : translate("share"))
|
|
10715
|
+
}, "\uD83D\uDD17") : translate("share")), showDownload && /*#__PURE__*/React.createElement("button", {
|
|
10716
|
+
className: "action-btn-table",
|
|
10717
|
+
onClick: () => downloadCallbackRef.current(row),
|
|
10718
|
+
onDoubleClick: e => e.stopPropagation(),
|
|
10719
|
+
"aria-label": translate("download") || "Download"
|
|
10720
|
+
}, showIcons ? /*#__PURE__*/React.createElement("span", {
|
|
10721
|
+
role: "img",
|
|
10722
|
+
"aria-hidden": "false",
|
|
10723
|
+
title: translate("download") || "Download"
|
|
10724
|
+
}, "\uD83D\uDCE5") : translate("download") || "Download")));
|
|
10708
10725
|
if (enableDragRow && item.type === "row") {
|
|
10709
10726
|
return /*#__PURE__*/React.createElement(DraggableRow, {
|
|
10710
10727
|
key: key,
|