trotl-table 1.0.98 → 1.0.100
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 +1 -0
- package/dist/Table.cjs.js +47 -7
- package/dist/Table.cjs.js.map +1 -1
- package/dist/Table.esm.js +47 -7
- package/dist/Table.esm.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -129,6 +129,7 @@ export default function Demo() {
|
|
|
129
129
|
- `groupHeaderHeight`: group header height in px
|
|
130
130
|
- `mobileColumnCount`: number of data columns shown at viewport widths of 768px or less (1 or 2; default `2`). The full row details are shown in a modal when a mobile row is clicked.
|
|
131
131
|
- `mobileRowClick`: optional callback `(row) => {}` invoked instead of opening the built-in details modal when a mobile row is clicked. Clicks on row controls and action buttons keep their existing behavior.
|
|
132
|
+
- On mobile, when `enableMouseRightClick` actions are provided, double-tapping a row opens the same context menu as a right click (a single tap then opens details after a short ~280ms delay).
|
|
132
133
|
- `showKey`: show row key (true/false)
|
|
133
134
|
- `enableDragRow`: enable drag‑and‑drop (true/false)
|
|
134
135
|
- `selectedRowsCallback`: callback with selected row IDs
|
package/dist/Table.cjs.js
CHANGED
|
@@ -9782,6 +9782,10 @@ function TableInner({
|
|
|
9782
9782
|
const downloadCallbackRef = React.useRef(downloadCallback);
|
|
9783
9783
|
const undeleteCallbackRef = React.useRef(undeleteCallback);
|
|
9784
9784
|
const mobileRowClickRef = React.useRef(mobileRowClick);
|
|
9785
|
+
const lastTapRef = React.useRef({
|
|
9786
|
+
timer: null,
|
|
9787
|
+
rowId: null
|
|
9788
|
+
});
|
|
9785
9789
|
const onCellChangeRef = React.useRef(onCellChange);
|
|
9786
9790
|
const cellCallbackRef = React.useRef(cellCallback);
|
|
9787
9791
|
|
|
@@ -10979,7 +10983,7 @@ function TableInner({
|
|
|
10979
10983
|
const showUndelete = buttons.includes("undelete");
|
|
10980
10984
|
const showDuplicate = buttons.includes("duplicate") || buttons.includes("duplicates");
|
|
10981
10985
|
const showDownload = buttons.includes("download");
|
|
10982
|
-
const showActions = showView || showEdit || showDelete || showShare || showUndelete || showDuplicate || showDownload;
|
|
10986
|
+
const showActions = !isMobile && (showView || showEdit || showDelete || showShare || showUndelete || showDuplicate || showDownload);
|
|
10983
10987
|
const visibleActionCount = [showView, showEdit, showDuplicate, showDelete, showShare, showUndelete, showDownload].filter(Boolean).length;
|
|
10984
10988
|
const actionColumnStyle = React.useMemo(() => {
|
|
10985
10989
|
if (!showActions) return undefined;
|
|
@@ -11220,11 +11224,47 @@ function TableInner({
|
|
|
11220
11224
|
if (!isMobile || event.target.closest(".checkbox-cell, .action-cell, button, input, select, textarea, a, [contenteditable='true']")) {
|
|
11221
11225
|
return;
|
|
11222
11226
|
}
|
|
11223
|
-
|
|
11224
|
-
mobileRowClickRef.current
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
+
const openSingleTap = () => {
|
|
11228
|
+
if (typeof mobileRowClickRef.current === "function") {
|
|
11229
|
+
mobileRowClickRef.current(row);
|
|
11230
|
+
} else {
|
|
11231
|
+
setMobileDetailRow(row);
|
|
11232
|
+
}
|
|
11233
|
+
};
|
|
11234
|
+
const hasContextActions = Array.isArray(enableMouseRightClick) && enableMouseRightClick.length > 0;
|
|
11235
|
+
if (!hasContextActions) {
|
|
11236
|
+
openSingleTap();
|
|
11237
|
+
return;
|
|
11238
|
+
}
|
|
11239
|
+
|
|
11240
|
+
// Double tap opens the context menu; a single tap waits briefly so
|
|
11241
|
+
// the first tap of a double tap does not open the details modal.
|
|
11242
|
+
const tap = lastTapRef.current;
|
|
11243
|
+
if (tap.timer && tap.rowId === row.id) {
|
|
11244
|
+
window.clearTimeout(tap.timer);
|
|
11245
|
+
lastTapRef.current = {
|
|
11246
|
+
timer: null,
|
|
11247
|
+
rowId: null
|
|
11248
|
+
};
|
|
11249
|
+
setContextMenu({
|
|
11250
|
+
visible: true,
|
|
11251
|
+
x: Math.max(0, Math.min(event.clientX, window.innerWidth - 180)),
|
|
11252
|
+
y: Math.max(0, Math.min(event.clientY, window.innerHeight - 160)),
|
|
11253
|
+
row
|
|
11254
|
+
});
|
|
11255
|
+
return;
|
|
11227
11256
|
}
|
|
11257
|
+
window.clearTimeout(tap.timer);
|
|
11258
|
+
lastTapRef.current = {
|
|
11259
|
+
rowId: row.id,
|
|
11260
|
+
timer: window.setTimeout(() => {
|
|
11261
|
+
lastTapRef.current = {
|
|
11262
|
+
timer: null,
|
|
11263
|
+
rowId: null
|
|
11264
|
+
};
|
|
11265
|
+
openSingleTap();
|
|
11266
|
+
}, 280)
|
|
11267
|
+
};
|
|
11228
11268
|
};
|
|
11229
11269
|
const content = /*#__PURE__*/React.createElement("div", {
|
|
11230
11270
|
key: key,
|
|
@@ -11247,7 +11287,7 @@ function TableInner({
|
|
|
11247
11287
|
}
|
|
11248
11288
|
}, /*#__PURE__*/React.createElement("div", {
|
|
11249
11289
|
className: "row-main",
|
|
11250
|
-
onDoubleClick: doubleClickEnable ? handleRowDoubleClick : undefined,
|
|
11290
|
+
onDoubleClick: doubleClickEnable && !(isMobile && Array.isArray(enableMouseRightClick) && enableMouseRightClick.length > 0) ? handleRowDoubleClick : undefined,
|
|
11251
11291
|
style: {
|
|
11252
11292
|
display: "flex",
|
|
11253
11293
|
flex: 1
|
|
@@ -11365,7 +11405,7 @@ function TableInner({
|
|
|
11365
11405
|
}, content);
|
|
11366
11406
|
}
|
|
11367
11407
|
return content;
|
|
11368
|
-
}, [tableDataFlat, visibleColumns, selectedRows, toggleRowSelection, groupRowsById, renderCell, getCellStyle, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, isMobile, doubleClickEnable, keyWidth, actionColumnStyle, showDuplicate, showDownload, showIcons, showShare, getHighlightRowStyle, triggerCellCallback, getAccessorKey, getAccessorValue]);
|
|
11408
|
+
}, [tableDataFlat, visibleColumns, selectedRows, toggleRowSelection, groupRowsById, renderCell, getCellStyle, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, isMobile, enableMouseRightClick, doubleClickEnable, keyWidth, actionColumnStyle, showDuplicate, showDownload, showIcons, showShare, getHighlightRowStyle, triggerCellCallback, getAccessorKey, getAccessorValue]);
|
|
11369
11409
|
const rightClickActions = Array.isArray(enableMouseRightClick) ? enableMouseRightClick : [];
|
|
11370
11410
|
const [hoveredActionIndex, setHoveredActionIndex] = React.useState(null);
|
|
11371
11411
|
const rowHeightGetter = ({
|