trotl-table 1.0.38 → 1.0.40
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 +68 -9
- package/dist/Table.cjs.js.map +1 -1
- package/dist/Table.esm.js +68 -9
- package/dist/Table.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/Table.cjs.js
CHANGED
|
@@ -9644,7 +9644,9 @@ function TableInner({
|
|
|
9644
9644
|
rowHeight = 34,
|
|
9645
9645
|
groupHeaderHeight = 36,
|
|
9646
9646
|
showKey = false,
|
|
9647
|
+
keyWidth = null,
|
|
9647
9648
|
selectedRowsCallback = () => {},
|
|
9649
|
+
doubleClickEnable = false,
|
|
9648
9650
|
refreshTrigger = () => {},
|
|
9649
9651
|
editCallback = () => {},
|
|
9650
9652
|
viewCallback = () => {},
|
|
@@ -9911,9 +9913,34 @@ function TableInner({
|
|
|
9911
9913
|
return dir === "asc" ? dx - dy : dy - dx;
|
|
9912
9914
|
}
|
|
9913
9915
|
|
|
9914
|
-
// Fallback string compare
|
|
9916
|
+
// Fallback string compare with numeric-prefix awareness
|
|
9915
9917
|
const sx = String(x).toLowerCase();
|
|
9916
9918
|
const sy = String(y).toLowerCase();
|
|
9919
|
+
|
|
9920
|
+
// helper to extract leading number and remainder
|
|
9921
|
+
const extractPrefix = str => {
|
|
9922
|
+
const m = str.match(/^(\d+)(.*)$/);
|
|
9923
|
+
if (m) return [Number(m[1]), m[2]];
|
|
9924
|
+
return null;
|
|
9925
|
+
};
|
|
9926
|
+
const px = extractPrefix(sx);
|
|
9927
|
+
const py = extractPrefix(sy);
|
|
9928
|
+
if (px && py) {
|
|
9929
|
+
// both have numeric prefix
|
|
9930
|
+
if (px[0] !== py[0]) {
|
|
9931
|
+
return dir === "asc" ? px[0] - py[0] : py[0] - px[0];
|
|
9932
|
+
}
|
|
9933
|
+
// same number, compare remainder lexicographically
|
|
9934
|
+
const restCmp = px[1].localeCompare(py[1]);
|
|
9935
|
+
return dir === "asc" ? restCmp : -restCmp;
|
|
9936
|
+
} else if (px && !py) {
|
|
9937
|
+
// number-prefixed should come before text-only
|
|
9938
|
+
return dir === "asc" ? -1 : 1;
|
|
9939
|
+
} else if (!px && py) {
|
|
9940
|
+
return dir === "asc" ? 1 : -1;
|
|
9941
|
+
}
|
|
9942
|
+
|
|
9943
|
+
// default lexicographic fall back
|
|
9917
9944
|
if (sx < sy) return dir === "asc" ? -1 : 1;
|
|
9918
9945
|
if (sx > sy) return dir === "asc" ? 1 : -1;
|
|
9919
9946
|
return 0;
|
|
@@ -10369,7 +10396,12 @@ function TableInner({
|
|
|
10369
10396
|
},
|
|
10370
10397
|
onClick: e => e.stopPropagation()
|
|
10371
10398
|
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10372
|
-
className: "table-cell key-cell"
|
|
10399
|
+
className: "table-cell key-cell",
|
|
10400
|
+
style: keyWidth ? {
|
|
10401
|
+
width: keyWidth,
|
|
10402
|
+
minWidth: keyWidth,
|
|
10403
|
+
maxWidth: keyWidth
|
|
10404
|
+
} : undefined
|
|
10373
10405
|
}), /*#__PURE__*/React.createElement("div", {
|
|
10374
10406
|
className: "table-cell group-header",
|
|
10375
10407
|
style: {
|
|
@@ -10406,7 +10438,12 @@ function TableInner({
|
|
|
10406
10438
|
},
|
|
10407
10439
|
onClick: e => e.stopPropagation()
|
|
10408
10440
|
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10409
|
-
className: "table-cell key-cell"
|
|
10441
|
+
className: "table-cell key-cell",
|
|
10442
|
+
style: keyWidth ? {
|
|
10443
|
+
width: keyWidth,
|
|
10444
|
+
minWidth: keyWidth,
|
|
10445
|
+
maxWidth: keyWidth
|
|
10446
|
+
} : undefined
|
|
10410
10447
|
}), /*#__PURE__*/React.createElement("div", {
|
|
10411
10448
|
className: "table-cell group-header"
|
|
10412
10449
|
}, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (", item.rowCount, ")"), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
|
|
@@ -10432,10 +10469,19 @@ function TableInner({
|
|
|
10432
10469
|
}
|
|
10433
10470
|
});
|
|
10434
10471
|
}
|
|
10472
|
+
const handleRowDoubleClick = e => {
|
|
10473
|
+
if (!doubleClickEnable) return;
|
|
10474
|
+
// ignore double-clicks on action buttons or inputs
|
|
10475
|
+
if (e.target.closest('.action-btn-table') || e.target.closest('input') || e.target.closest('button')) {
|
|
10476
|
+
return;
|
|
10477
|
+
}
|
|
10478
|
+
editCallbackRef.current(row);
|
|
10479
|
+
};
|
|
10435
10480
|
const content = /*#__PURE__*/React.createElement("div", {
|
|
10436
10481
|
key: key,
|
|
10437
10482
|
style: style,
|
|
10438
|
-
className: "table-row"
|
|
10483
|
+
className: "table-row",
|
|
10484
|
+
onDoubleClick: handleRowDoubleClick
|
|
10439
10485
|
}, enableMultiSelect && showDelete && /*#__PURE__*/React.createElement("div", {
|
|
10440
10486
|
className: "table-cell checkbox-cell"
|
|
10441
10487
|
}, /*#__PURE__*/React.createElement("input", {
|
|
@@ -10444,7 +10490,12 @@ function TableInner({
|
|
|
10444
10490
|
onChange: () => toggleRowSelection(row.id)
|
|
10445
10491
|
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10446
10492
|
title: visualIndex,
|
|
10447
|
-
className: "table-cell key-cell"
|
|
10493
|
+
className: "table-cell key-cell",
|
|
10494
|
+
style: keyWidth ? {
|
|
10495
|
+
width: keyWidth,
|
|
10496
|
+
minWidth: keyWidth,
|
|
10497
|
+
maxWidth: keyWidth
|
|
10498
|
+
} : undefined
|
|
10448
10499
|
}, visualIndex), allColumns.map((col, i) => {
|
|
10449
10500
|
let cellStyle = col.style ? {
|
|
10450
10501
|
...col.style
|
|
@@ -10533,7 +10584,7 @@ function TableInner({
|
|
|
10533
10584
|
}, content);
|
|
10534
10585
|
}
|
|
10535
10586
|
return content;
|
|
10536
|
-
}, [tableDataFlat, columns, selectedRows, toggleRowSelection, groupRowsById, renderCell, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns]);
|
|
10587
|
+
}, [tableDataFlat, columns, selectedRows, toggleRowSelection, groupRowsById, renderCell, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, doubleClickEnable]);
|
|
10537
10588
|
const rowHeightGetter = ({
|
|
10538
10589
|
index
|
|
10539
10590
|
}) => tableDataFlat[index]?.type === "group" ? groupHeaderHeight : rowHeight;
|
|
@@ -10605,7 +10656,12 @@ function TableInner({
|
|
|
10605
10656
|
}
|
|
10606
10657
|
}
|
|
10607
10658
|
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10608
|
-
className: "table-cell key-cell"
|
|
10659
|
+
className: "table-cell key-cell",
|
|
10660
|
+
style: keyWidth ? {
|
|
10661
|
+
width: keyWidth,
|
|
10662
|
+
minWidth: keyWidth,
|
|
10663
|
+
maxWidth: keyWidth
|
|
10664
|
+
} : undefined
|
|
10609
10665
|
}, "#"), allColumns.map((col, i) => {
|
|
10610
10666
|
let cellStyle = col.style ? {
|
|
10611
10667
|
...col.style,
|
|
@@ -10618,15 +10674,18 @@ function TableInner({
|
|
|
10618
10674
|
cellStyle.maxWidth = col.style.width;
|
|
10619
10675
|
cellStyle.width = col.style.width;
|
|
10620
10676
|
}
|
|
10677
|
+
// determine header title text for tooltip; custom columns may also have string headers
|
|
10678
|
+
const headerTitle = typeof col.header === 'string' ? col.header : undefined;
|
|
10621
10679
|
return /*#__PURE__*/React.createElement("div", {
|
|
10622
10680
|
key: i,
|
|
10623
10681
|
className: "table-cell",
|
|
10624
10682
|
style: cellStyle,
|
|
10625
|
-
title:
|
|
10683
|
+
title: headerTitle,
|
|
10626
10684
|
onClick: col.isCustom ? undefined : () => setSort(col.accessor)
|
|
10627
10685
|
}, col.isCustom ? col.header ?? '' : col.header, !col.isCustom && sorting?.column === col.accessor && (sorting.direction === "asc" ? " ↑" : " ↓"));
|
|
10628
10686
|
}), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10629
|
-
className: "table-cell action-cell"
|
|
10687
|
+
className: "table-cell action-cell",
|
|
10688
|
+
title: translate("action")
|
|
10630
10689
|
}, showIcons ? /*#__PURE__*/React.createElement("span", {
|
|
10631
10690
|
title: translate("action")
|
|
10632
10691
|
}, "\u2699\uFE0F") : translate("action")))), /*#__PURE__*/React.createElement("div", {
|