trotl-table 1.0.59 → 1.0.61
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 +29 -8
- package/dist/Table.cjs.js.map +1 -1
- package/dist/Table.esm.js +29 -8
- 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/dist/Table.cjs.js
CHANGED
|
@@ -10340,6 +10340,22 @@ function TableInner({
|
|
|
10340
10340
|
const showDuplicate = buttons.includes("duplicate") || buttons.includes("duplicates");
|
|
10341
10341
|
const showDownload = buttons.includes("download");
|
|
10342
10342
|
const showActions = showView || showEdit || showDelete || showShare || showDuplicate || showDownload;
|
|
10343
|
+
const visibleActionCount = [showView, showEdit, showDuplicate, showDelete, showShare, showDownload].filter(Boolean).length;
|
|
10344
|
+
const actionColumnStyle = React.useMemo(() => {
|
|
10345
|
+
if (!showActions) return undefined;
|
|
10346
|
+
const gap = 4;
|
|
10347
|
+
const horizontalPadding = 8;
|
|
10348
|
+
const iconButtonWidth = 30;
|
|
10349
|
+
const textButtonWidth = 84;
|
|
10350
|
+
const buttonWidth = showIcons ? iconButtonWidth : textButtonWidth;
|
|
10351
|
+
const width = visibleActionCount > 0 ? visibleActionCount * buttonWidth + Math.max(visibleActionCount - 1, 0) * gap + horizontalPadding : 0;
|
|
10352
|
+
return {
|
|
10353
|
+
flex: `0 0 ${width}px`,
|
|
10354
|
+
width: `${width}px`,
|
|
10355
|
+
minWidth: `${width}px`,
|
|
10356
|
+
maxWidth: `${width}px`
|
|
10357
|
+
};
|
|
10358
|
+
}, [showActions, showIcons, visibleActionCount]);
|
|
10343
10359
|
|
|
10344
10360
|
// MOVE ROW (internal + between groups)
|
|
10345
10361
|
// moveRow: allow toIndex to be null or an object { emptyGroupId } for empty group drop
|
|
@@ -10431,7 +10447,7 @@ function TableInner({
|
|
|
10431
10447
|
}, [tableDataFlat, isGrouped, groupKey]);
|
|
10432
10448
|
|
|
10433
10449
|
// DUPLICATE
|
|
10434
|
-
|
|
10450
|
+
React.useCallback(row => {
|
|
10435
10451
|
if (!row) return;
|
|
10436
10452
|
// try user callback first; if it returns an object with newRow use that
|
|
10437
10453
|
let newRow = null;
|
|
@@ -10554,7 +10570,8 @@ function TableInner({
|
|
|
10554
10570
|
key: i,
|
|
10555
10571
|
className: "table-cell"
|
|
10556
10572
|
})), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10557
|
-
className: "table-cell action-cell"
|
|
10573
|
+
className: "table-cell action-cell",
|
|
10574
|
+
style: actionColumnStyle
|
|
10558
10575
|
}));
|
|
10559
10576
|
};
|
|
10560
10577
|
return /*#__PURE__*/React.createElement(GroupHeaderDrop, null);
|
|
@@ -10593,7 +10610,8 @@ function TableInner({
|
|
|
10593
10610
|
key: i,
|
|
10594
10611
|
className: "table-cell"
|
|
10595
10612
|
})), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10596
|
-
className: "table-cell action-cell"
|
|
10613
|
+
className: "table-cell action-cell",
|
|
10614
|
+
style: actionColumnStyle
|
|
10597
10615
|
}));
|
|
10598
10616
|
}
|
|
10599
10617
|
const row = item.row;
|
|
@@ -10663,7 +10681,8 @@ function TableInner({
|
|
|
10663
10681
|
style: cellStyle
|
|
10664
10682
|
}, col.isCustom ? typeof col.render === 'function' ? col.render(row, i) : col.render : renderCell(row[col.accessor], col.accessor, row, col));
|
|
10665
10683
|
})), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10666
|
-
className: "table-cell action-cell"
|
|
10684
|
+
className: "table-cell action-cell",
|
|
10685
|
+
style: actionColumnStyle
|
|
10667
10686
|
}, showView && /*#__PURE__*/React.createElement("button", {
|
|
10668
10687
|
className: "action-btn-table",
|
|
10669
10688
|
onClick: () => viewCallbackRef.current(row),
|
|
@@ -10734,7 +10753,7 @@ function TableInner({
|
|
|
10734
10753
|
}, content);
|
|
10735
10754
|
}
|
|
10736
10755
|
return content;
|
|
10737
|
-
}, [tableDataFlat, columns, selectedRows, toggleRowSelection, groupRowsById, renderCell, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, doubleClickEnable,
|
|
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]);
|
|
10738
10757
|
const rowHeightGetter = ({
|
|
10739
10758
|
index
|
|
10740
10759
|
}) => tableDataFlat[index]?.type === "group" ? groupHeaderHeight : rowHeight;
|
|
@@ -10824,17 +10843,19 @@ function TableInner({
|
|
|
10824
10843
|
cellStyle.maxWidth = col.style.width;
|
|
10825
10844
|
cellStyle.width = col.style.width;
|
|
10826
10845
|
}
|
|
10827
|
-
|
|
10828
|
-
|
|
10846
|
+
const translatedHeader = typeof col.header === "string" ? translate(col.header) : col.header;
|
|
10847
|
+
// Keep tooltip text in sync with rendered header when it's a string.
|
|
10848
|
+
const headerTitle = typeof translatedHeader === "string" ? translatedHeader : undefined;
|
|
10829
10849
|
return /*#__PURE__*/React.createElement("div", {
|
|
10830
10850
|
key: i,
|
|
10831
10851
|
className: "table-cell",
|
|
10832
10852
|
style: cellStyle,
|
|
10833
10853
|
title: headerTitle,
|
|
10834
10854
|
onClick: col.isCustom ? undefined : () => setSort(col.accessor)
|
|
10835
|
-
}, col.isCustom ?
|
|
10855
|
+
}, col.isCustom ? translatedHeader ?? "" : translatedHeader, !col.isCustom && sorting?.column === col.accessor && (sorting.direction === "asc" ? " ↑" : " ↓"));
|
|
10836
10856
|
}), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10837
10857
|
className: "table-cell action-cell",
|
|
10858
|
+
style: actionColumnStyle,
|
|
10838
10859
|
title: translate("action")
|
|
10839
10860
|
}, showIcons ? /*#__PURE__*/React.createElement("span", {
|
|
10840
10861
|
title: translate("action")
|