trotl-table 1.0.16 → 1.0.18
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 +17 -10
- package/dist/index.cjs.js +57 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +57 -17
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,16 +26,23 @@ yarn add trotl-table
|
|
|
26
26
|
|
|
27
27
|
## Versions
|
|
28
28
|
```js
|
|
29
|
-
1.0.
|
|
30
|
-
1.0.
|
|
31
|
-
1.0.
|
|
32
|
-
1.0.
|
|
33
|
-
1.0.
|
|
34
|
-
1.0.
|
|
35
|
-
1.0.
|
|
36
|
-
1.0.
|
|
37
|
-
1.0.
|
|
38
|
-
1.0.
|
|
29
|
+
1.0.17 => ...
|
|
30
|
+
1.0.16 => update/fix when scroll
|
|
31
|
+
1.0.15 => update add EmptyTableLoader
|
|
32
|
+
1.0.14 => ...
|
|
33
|
+
1.0.13 => ...
|
|
34
|
+
1.0.12 => ...
|
|
35
|
+
1.0.11 => ...
|
|
36
|
+
1.0.10 => ...
|
|
37
|
+
1.0.9 => fix readme, whatever
|
|
38
|
+
1.0.8 => fix readme
|
|
39
|
+
1.0.7 => removed context (better for npm consumers)
|
|
40
|
+
1.0.6 => ...
|
|
41
|
+
1.0.5 => ...
|
|
42
|
+
1.0.4 => fix sorting
|
|
43
|
+
1.0.3 => ...
|
|
44
|
+
1.0.2 => prepare for npm consumers
|
|
45
|
+
1.0.1 => initial release
|
|
39
46
|
```
|
|
40
47
|
|
|
41
48
|
## ⚡ Quick Start
|
package/dist/index.cjs.js
CHANGED
|
@@ -9733,8 +9733,38 @@ function TableInner({
|
|
|
9733
9733
|
enableExternalRowDrop = false,
|
|
9734
9734
|
onExternalRowDrop = () => {},
|
|
9735
9735
|
useExternalDndContext = false,
|
|
9736
|
-
customColumns = []
|
|
9736
|
+
customColumns = [],
|
|
9737
|
+
groupDefaultOpen = false,
|
|
9738
|
+
t
|
|
9737
9739
|
}) {
|
|
9740
|
+
let translate;
|
|
9741
|
+
if (t) {
|
|
9742
|
+
translate = t;
|
|
9743
|
+
} else {
|
|
9744
|
+
translate = key => {
|
|
9745
|
+
const translations = {
|
|
9746
|
+
addNewColumn: "Add New Column",
|
|
9747
|
+
add: "Add",
|
|
9748
|
+
cancel: "Cancel",
|
|
9749
|
+
editColumn: "Edit Column",
|
|
9750
|
+
save: "Save",
|
|
9751
|
+
title: "Title",
|
|
9752
|
+
color: "Color",
|
|
9753
|
+
collapsed: "Collapsed",
|
|
9754
|
+
lang: "Language",
|
|
9755
|
+
view: "View",
|
|
9756
|
+
edit: "Edit",
|
|
9757
|
+
delete: "Delete",
|
|
9758
|
+
confirmDelete: "Confirm Delete",
|
|
9759
|
+
yesDelete: "Yes, Delete",
|
|
9760
|
+
areYouSureYouWantToDelete: "Are you sure you want to delete",
|
|
9761
|
+
action: "Action",
|
|
9762
|
+
DropHereToMoveIntoThisGroup: "Drop here to move into this group"
|
|
9763
|
+
};
|
|
9764
|
+
return translations[key] || key;
|
|
9765
|
+
};
|
|
9766
|
+
}
|
|
9767
|
+
|
|
9738
9768
|
// Local selection & sorting state (removed TableContext dependency)
|
|
9739
9769
|
const [selectedRows, setSelectedRows] = React.useState([]);
|
|
9740
9770
|
const [sorting, setSorting] = React.useState(null);
|
|
@@ -9884,11 +9914,11 @@ function TableInner({
|
|
|
9884
9914
|
};
|
|
9885
9915
|
for (const g of normalizedGroups) {
|
|
9886
9916
|
const gid = g[groupKey] ?? g.groupId ?? g.groupName;
|
|
9887
|
-
if (!(gid in next)) next[gid] =
|
|
9917
|
+
if (!(gid in next)) next[gid] = groupDefaultOpen; // use prop for initial state
|
|
9888
9918
|
}
|
|
9889
9919
|
return next;
|
|
9890
9920
|
});
|
|
9891
|
-
}, [normalizedGroups, groupKey]);
|
|
9921
|
+
}, [normalizedGroups, groupKey, groupDefaultOpen]);
|
|
9892
9922
|
const groupRowsById = React.useMemo(() => {
|
|
9893
9923
|
const map = {};
|
|
9894
9924
|
for (const g of sortedGroupedData) {
|
|
@@ -10003,14 +10033,23 @@ function TableInner({
|
|
|
10003
10033
|
// RENDER CELL
|
|
10004
10034
|
const highlight = React.useCallback(text => {
|
|
10005
10035
|
// Use the actual searchTerm (from URL or prop) for highlighting
|
|
10006
|
-
if (!searchTerm || typeof text !== "string") return
|
|
10036
|
+
if (!searchTerm || typeof text !== "string") return /*#__PURE__*/React.createElement("span", {
|
|
10037
|
+
title: text
|
|
10038
|
+
}, text);
|
|
10007
10039
|
const lower = text.toLowerCase();
|
|
10008
10040
|
const query = searchTerm.toLowerCase();
|
|
10009
10041
|
const idx = lower.indexOf(query);
|
|
10010
|
-
if (idx === -1) return
|
|
10011
|
-
|
|
10042
|
+
if (idx === -1) return /*#__PURE__*/React.createElement("span", {
|
|
10043
|
+
title: text
|
|
10044
|
+
}, text);
|
|
10045
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
10046
|
+
title: text
|
|
10047
|
+
}, text.slice(0, idx)), /*#__PURE__*/React.createElement("span", {
|
|
10048
|
+
title: text,
|
|
10012
10049
|
className: "highlight"
|
|
10013
|
-
}, text.slice(idx, idx + query.length)),
|
|
10050
|
+
}, text.slice(idx, idx + query.length)), /*#__PURE__*/React.createElement("span", {
|
|
10051
|
+
title: text
|
|
10052
|
+
}, text.slice(idx + query.length)));
|
|
10014
10053
|
}, [searchTerm]);
|
|
10015
10054
|
const renderCell = React.useCallback((v, accessor) => {
|
|
10016
10055
|
if (accessor === "deadlineISO") {
|
|
@@ -10190,7 +10229,7 @@ function TableInner({
|
|
|
10190
10229
|
style: {
|
|
10191
10230
|
width: '100%'
|
|
10192
10231
|
}
|
|
10193
|
-
}, item.expanded ? "▾" : "▸", " ", item.groupName, " (0) \u2014
|
|
10232
|
+
}, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (0) \u2014 ", translate("DropHereToMoveIntoThisGroup")), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
|
|
10194
10233
|
key: i,
|
|
10195
10234
|
className: "table-cell"
|
|
10196
10235
|
})), showActions && /*#__PURE__*/React.createElement("div", {
|
|
@@ -10224,7 +10263,7 @@ function TableInner({
|
|
|
10224
10263
|
className: "table-cell key-cell"
|
|
10225
10264
|
}), /*#__PURE__*/React.createElement("div", {
|
|
10226
10265
|
className: "table-cell group-header"
|
|
10227
|
-
}, item.expanded ? "▾" : "▸", " ", item.groupName, " (", item.rowCount, ")"), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
|
|
10266
|
+
}, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (", item.rowCount, ")"), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
|
|
10228
10267
|
key: i,
|
|
10229
10268
|
className: "table-cell"
|
|
10230
10269
|
})), showActions && /*#__PURE__*/React.createElement("div", {
|
|
@@ -10258,6 +10297,7 @@ function TableInner({
|
|
|
10258
10297
|
checked: selectedRows.includes(row.id),
|
|
10259
10298
|
onChange: () => toggleRowSelection(row.id)
|
|
10260
10299
|
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10300
|
+
title: visualIndex,
|
|
10261
10301
|
className: "table-cell key-cell"
|
|
10262
10302
|
}, visualIndex), allColumns.map((col, i) => {
|
|
10263
10303
|
let cellStyle = col.style ? {
|
|
@@ -10282,13 +10322,13 @@ function TableInner({
|
|
|
10282
10322
|
background: "#646cffaa"
|
|
10283
10323
|
},
|
|
10284
10324
|
onClick: () => viewCallback(row)
|
|
10285
|
-
}, "
|
|
10325
|
+
}, translate("view")), showEdit && /*#__PURE__*/React.createElement("button", {
|
|
10286
10326
|
className: "action-btn-table",
|
|
10287
10327
|
style: {
|
|
10288
10328
|
background: "#4caf50"
|
|
10289
10329
|
},
|
|
10290
10330
|
onClick: () => editCallback(row)
|
|
10291
|
-
}, "
|
|
10331
|
+
}, translate("edit")), showDelete && /*#__PURE__*/React.createElement("button", {
|
|
10292
10332
|
className: "action-btn-table",
|
|
10293
10333
|
style: {
|
|
10294
10334
|
background: "#f44336"
|
|
@@ -10298,7 +10338,7 @@ function TableInner({
|
|
|
10298
10338
|
setPendingDelete(row);
|
|
10299
10339
|
setShowConfirm(true);
|
|
10300
10340
|
}
|
|
10301
|
-
}, "
|
|
10341
|
+
}, translate("delete"))));
|
|
10302
10342
|
if (enableDragRow && item.type === "row") {
|
|
10303
10343
|
return /*#__PURE__*/React.createElement(DraggableRow, {
|
|
10304
10344
|
key: key,
|
|
@@ -10404,7 +10444,7 @@ function TableInner({
|
|
|
10404
10444
|
}, col.isCustom ? col.header ?? '' : col.header, !col.isCustom && sorting?.column === col.accessor && (sorting.direction === "asc" ? " ↑" : " ↓"));
|
|
10405
10445
|
}), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10406
10446
|
className: "table-cell action-cell"
|
|
10407
|
-
}, "
|
|
10447
|
+
}, translate("action")))), /*#__PURE__*/React.createElement("div", {
|
|
10408
10448
|
className: "main-table",
|
|
10409
10449
|
ref: listRef
|
|
10410
10450
|
}, tableDataFlat.length === 0 ? /*#__PURE__*/React.createElement(DotsLoading, null) : /*#__PURE__*/React.createElement(AutoSizer, null, ({
|
|
@@ -10419,14 +10459,14 @@ function TableInner({
|
|
|
10419
10459
|
overscanRowCount: 8
|
|
10420
10460
|
}))), /*#__PURE__*/React.createElement(Modal, {
|
|
10421
10461
|
isOpen: showConfirm,
|
|
10422
|
-
title: "
|
|
10462
|
+
title: translate("confirmDelete"),
|
|
10423
10463
|
onConfirm: confirmDelete,
|
|
10424
10464
|
onCancel: () => setShowConfirm(false),
|
|
10425
|
-
confirmLabel: "
|
|
10426
|
-
cancelLabel: "
|
|
10465
|
+
confirmLabel: translate("yesDelete"),
|
|
10466
|
+
cancelLabel: translate("cancel"),
|
|
10427
10467
|
showCancel: true,
|
|
10428
10468
|
showConfirm: true
|
|
10429
|
-
}, /*#__PURE__*/React.createElement("p", null, "
|
|
10469
|
+
}, /*#__PURE__*/React.createElement("p", null, translate("areYouSureYouWantToDelete"), " ", /*#__PURE__*/React.createElement("strong", null, pendingDelete?.name || pendingDelete?.id), "?")));
|
|
10430
10470
|
return tableMarkup;
|
|
10431
10471
|
}
|
|
10432
10472
|
function Table(props) {
|