@lensui/lens-table 0.1.25 → 0.1.28
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/index.cjs +99 -27
- package/dist/index.css +10 -8
- package/dist/index.js +99 -27
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -882,7 +882,7 @@ var COLORS = {
|
|
|
882
882
|
rowHoverFill: "#f6f9fc",
|
|
883
883
|
editedFill: "#fff1b8",
|
|
884
884
|
insertedFill: "#c8ead4",
|
|
885
|
-
columnDropTargetFill: "#
|
|
885
|
+
columnDropTargetFill: "#e2edf9",
|
|
886
886
|
stripe: "#fafbfc"
|
|
887
887
|
};
|
|
888
888
|
function ellipsizeText(context, text, maxWidth) {
|
|
@@ -966,15 +966,17 @@ function paintGrid(options) {
|
|
|
966
966
|
const row = rows[rowIndex];
|
|
967
967
|
const rowKey = getRowKey(row, rowIndex);
|
|
968
968
|
const trailingRowStyle = options.rowStyle?.(row, rowIndex);
|
|
969
|
-
let fill = striped && rowIndex % 2 === 1 ? colors.stripe : null;
|
|
970
|
-
if (trailingRowStyle?.backgroundColor) fill = trailingRowStyle.backgroundColor;
|
|
971
|
-
if (selectedRowKeys.has(rowKey)) fill = colors.axisSelectionFill;
|
|
972
|
-
if (hoveredRowIndex === rowIndex) fill = colors.rowHoverFill;
|
|
973
|
-
if (highlightInsertedRows && insertedRowKeys.has(rowKey)) fill = colors.insertedFill;
|
|
974
|
-
if (!fill) continue;
|
|
975
969
|
const y = bodyTop + rowIndex * rowHeight - scrollTop + getRowDragOffset(rowIndex);
|
|
976
|
-
|
|
977
|
-
|
|
970
|
+
const paintTrailingLayer = (fill) => {
|
|
971
|
+
if (!fill) return;
|
|
972
|
+
ctx.fillStyle = fill;
|
|
973
|
+
ctx.fillRect(trailingBlankStart, y, width - trailingBlankStart, rowHeight);
|
|
974
|
+
};
|
|
975
|
+
if (striped && rowIndex % 2 === 1) paintTrailingLayer(colors.stripe);
|
|
976
|
+
paintTrailingLayer(trailingRowStyle?.backgroundColor);
|
|
977
|
+
if (selectedRowKeys.has(rowKey)) paintTrailingLayer(colors.axisSelectionFill);
|
|
978
|
+
if (hoveredRowIndex === rowIndex) paintTrailingLayer(colors.rowHoverFill);
|
|
979
|
+
if (highlightInsertedRows && insertedRowKeys.has(rowKey)) paintTrailingLayer(colors.insertedFill);
|
|
978
980
|
}
|
|
979
981
|
}
|
|
980
982
|
const paintBodyColumns = (layer) => {
|
|
@@ -999,6 +1001,7 @@ function paintGrid(options) {
|
|
|
999
1001
|
const cellWidth = getCellWidth(columnIndex, colSpan);
|
|
1000
1002
|
const cellHeight = rowHeight * rowSpan;
|
|
1001
1003
|
const isAxisSelected = selectedRowKeys.has(rowKey) || selectedColumnKeys.has(column.key);
|
|
1004
|
+
const isColumnDropTarget = Boolean(columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex);
|
|
1002
1005
|
const rangeRowStart = selectionRange ? Math.min(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
1003
1006
|
const rangeRowEnd = selectionRange ? Math.max(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
1004
1007
|
const rangeColumnStart = selectionRange ? Math.min(selectionRange.anchor.columnIndex, selectionRange.focus.columnIndex) : -1;
|
|
@@ -1020,10 +1023,6 @@ function paintGrid(options) {
|
|
|
1020
1023
|
ctx.fillStyle = colors.rowHoverFill;
|
|
1021
1024
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1022
1025
|
}
|
|
1023
|
-
if (columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex) {
|
|
1024
|
-
ctx.fillStyle = colors.columnDropTargetFill;
|
|
1025
|
-
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1026
|
-
}
|
|
1027
1026
|
if (highlightInsertedRows && insertedRowKeys.has(rowKey)) {
|
|
1028
1027
|
ctx.fillStyle = colors.insertedFill;
|
|
1029
1028
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
@@ -1048,6 +1047,10 @@ function paintGrid(options) {
|
|
|
1048
1047
|
ctx.fillStyle = annotation.color;
|
|
1049
1048
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1050
1049
|
}
|
|
1050
|
+
if (isColumnDropTarget) {
|
|
1051
|
+
ctx.fillStyle = colors.columnDropTargetFill;
|
|
1052
|
+
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1053
|
+
}
|
|
1051
1054
|
ctx.fillStyle = colors.grid;
|
|
1052
1055
|
if (!verticalBorderless && !(frameBorderless && columnIndex + colSpan >= columns.length)) {
|
|
1053
1056
|
ctx.fillRect(x + cellWidth - 1, y, 1, cellHeight);
|
|
@@ -1057,14 +1060,14 @@ function paintGrid(options) {
|
|
|
1057
1060
|
ctx.fillRect(x, y + cellHeight - 1, cellWidth, 1);
|
|
1058
1061
|
}
|
|
1059
1062
|
if (rowSpan > 1) {
|
|
1060
|
-
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? rowStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1063
|
+
const mergedFill = isColumnDropTarget ? colors.columnDropTargetFill : annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? rowStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1061
1064
|
ctx.fillStyle = mergedFill;
|
|
1062
1065
|
for (let offset = 1; offset < rowSpan; offset += 1) {
|
|
1063
1066
|
ctx.fillRect(x, y + offset * rowHeight - 1, cellWidth, 2);
|
|
1064
1067
|
}
|
|
1065
1068
|
}
|
|
1066
1069
|
if (colSpan > 1 && !verticalBorderless) {
|
|
1067
|
-
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? rowStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1070
|
+
const mergedFill = isColumnDropTarget ? colors.columnDropTargetFill : annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? rowStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1068
1071
|
ctx.fillStyle = mergedFill;
|
|
1069
1072
|
let offsetLeft = 0;
|
|
1070
1073
|
for (let offset = 1; offset < colSpan; offset += 1) {
|
|
@@ -1161,7 +1164,7 @@ function paintGrid(options) {
|
|
|
1161
1164
|
ctx.beginPath();
|
|
1162
1165
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1163
1166
|
ctx.clip();
|
|
1164
|
-
ctx.fillStyle = isAxisSelected && !isSelectedCell && !isRangeCell ? colors.axisSelectionText : cellStyle?.color ?? rowStyle?.color ?? colors.text;
|
|
1167
|
+
ctx.fillStyle = isColumnDropTarget ? colors.text : isAxisSelected && !isSelectedCell && !isRangeCell ? colors.axisSelectionText : cellStyle?.color ?? rowStyle?.color ?? colors.text;
|
|
1165
1168
|
ctx.font = createCellFont(bodyFontSize);
|
|
1166
1169
|
ctx.textBaseline = "alphabetic";
|
|
1167
1170
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
@@ -1224,6 +1227,25 @@ function paintGrid(options) {
|
|
|
1224
1227
|
paintExtendedColumnSelection("scroll");
|
|
1225
1228
|
paintExtendedColumnSelection("left");
|
|
1226
1229
|
paintExtendedColumnSelection("right");
|
|
1230
|
+
const paintExtendedColumnDropTarget = (layer) => {
|
|
1231
|
+
if (!columnDropTarget) return;
|
|
1232
|
+
ctx.save();
|
|
1233
|
+
if (layer === "scroll") {
|
|
1234
|
+
ctx.beginPath();
|
|
1235
|
+
ctx.rect(leftFixedWidth, extensionTop, Math.max(0, rightFixedLeft - leftFixedWidth), extensionHeight);
|
|
1236
|
+
ctx.clip();
|
|
1237
|
+
}
|
|
1238
|
+
ctx.fillStyle = colors.columnDropTargetFill;
|
|
1239
|
+
for (let columnIndex = columnDropTarget.startIndex; columnIndex <= columnDropTarget.endIndex; columnIndex += 1) {
|
|
1240
|
+
if (layer === "scroll" ? columns[columnIndex]?.fixed !== void 0 : columns[columnIndex]?.fixed !== layer) continue;
|
|
1241
|
+
if (layer === "scroll" && (columnIndex < range.columnStart || columnIndex >= range.columnEnd)) continue;
|
|
1242
|
+
ctx.fillRect(getColumnX(columnIndex), extensionTop, metrics[columnIndex].width, extensionHeight);
|
|
1243
|
+
}
|
|
1244
|
+
ctx.restore();
|
|
1245
|
+
};
|
|
1246
|
+
paintExtendedColumnDropTarget("scroll");
|
|
1247
|
+
paintExtendedColumnDropTarget("left");
|
|
1248
|
+
paintExtendedColumnDropTarget("right");
|
|
1227
1249
|
if (!verticalBorderless) {
|
|
1228
1250
|
paintExtendedColumnLines("scroll");
|
|
1229
1251
|
paintExtendedColumnLines("left");
|
|
@@ -1245,11 +1267,12 @@ function paintGrid(options) {
|
|
|
1245
1267
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1246
1268
|
}
|
|
1247
1269
|
const isAxisSelected = selectedColumnKeys.has(columns[columnIndex].key);
|
|
1270
|
+
const isColumnDropTarget = Boolean(columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex);
|
|
1248
1271
|
if (isAxisSelected) {
|
|
1249
1272
|
ctx.fillStyle = colors.axisSelectionFill;
|
|
1250
1273
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1251
1274
|
}
|
|
1252
|
-
if (
|
|
1275
|
+
if (isColumnDropTarget) {
|
|
1253
1276
|
ctx.fillStyle = colors.columnDropTargetFill;
|
|
1254
1277
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1255
1278
|
}
|
|
@@ -1278,7 +1301,7 @@ function paintGrid(options) {
|
|
|
1278
1301
|
ctx.beginPath();
|
|
1279
1302
|
ctx.rect(x + 2, headerY + headerLeafTop + 1, Math.max(0, clipWidth - 4), headerLeafHeight - 2);
|
|
1280
1303
|
ctx.clip();
|
|
1281
|
-
ctx.fillStyle = isAxisSelected ? colors.axisSelectionText : colors.muted;
|
|
1304
|
+
ctx.fillStyle = isColumnDropTarget ? colors.muted : isAxisSelected ? colors.axisSelectionText : colors.muted;
|
|
1282
1305
|
ctx.textAlign = titleAlign === "right" ? "right" : titleAlign === "center" ? "center" : "left";
|
|
1283
1306
|
ctx.fillText(title, textX, headerY + headerLeafTop + headerLeafHeight / 2);
|
|
1284
1307
|
ctx.restore();
|
|
@@ -1437,6 +1460,9 @@ function resolveColumnDropIndex(sourceIndex, targetIndex, edge, columnCount) {
|
|
|
1437
1460
|
function resolveColumnDropPlacement(edge) {
|
|
1438
1461
|
return edge === "right" ? "after" : "before";
|
|
1439
1462
|
}
|
|
1463
|
+
function resolveColumnDropHighlightRange(target, _edge, _cells) {
|
|
1464
|
+
return { startIndex: target.startIndex, endIndex: target.endIndex };
|
|
1465
|
+
}
|
|
1440
1466
|
var ANNOTATION_COLORS = ["#f44336", "#ff7a45", "#f5a623", "#f2c94c", "#52c41a", "#13a8a8", "#1677ff", "#597ef7", "#9254de", "#eb2f96"];
|
|
1441
1467
|
var FALLBACK_HEIGHT = 480;
|
|
1442
1468
|
var EMPTY_BODY_HEIGHT = 240;
|
|
@@ -1783,7 +1809,6 @@ function TableInner({
|
|
|
1783
1809
|
const contextMenuRef = (0, import_react5.useRef)(null);
|
|
1784
1810
|
const suppressClickRef = (0, import_react5.useRef)(false);
|
|
1785
1811
|
const hasCompletedLoadRef = (0, import_react5.useRef)(!loading);
|
|
1786
|
-
const columnDragPreviewRef = (0, import_react5.useRef)(null);
|
|
1787
1812
|
const validColumnDropRef = (0, import_react5.useRef)(null);
|
|
1788
1813
|
const hoveredHeaderActionRef = (0, import_react5.useRef)(null);
|
|
1789
1814
|
const hoveredRowIndexRef = (0, import_react5.useRef)(null);
|
|
@@ -1817,6 +1842,7 @@ function TableInner({
|
|
|
1817
1842
|
const [editing, setEditing] = (0, import_react5.useState)(null);
|
|
1818
1843
|
const [draft, setDraft] = (0, import_react5.useState)("");
|
|
1819
1844
|
const [rowDragPreview, setRowDragPreview] = (0, import_react5.useState)(null);
|
|
1845
|
+
const [columnDragPreview, setColumnDragPreview] = (0, import_react5.useState)(null);
|
|
1820
1846
|
const [columnDropTarget, setColumnDropTarget] = (0, import_react5.useState)(null);
|
|
1821
1847
|
(0, import_react5.useEffect)(() => {
|
|
1822
1848
|
if (!loading) hasCompletedLoadRef.current = true;
|
|
@@ -2316,7 +2342,7 @@ function TableInner({
|
|
|
2316
2342
|
rowHoverFill: readThemeColor(themeStyles, "--rvg-color-row-hover-fill", "#f6f9fc"),
|
|
2317
2343
|
editedFill: editedCellHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-edited-fill", "#fff1b8"),
|
|
2318
2344
|
insertedFill: insertedRowHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-inserted-fill", "#c8ead4"),
|
|
2319
|
-
columnDropTargetFill: readThemeColor(themeStyles, "--rvg-color-column-drop-target-fill", "#
|
|
2345
|
+
columnDropTargetFill: readThemeColor(themeStyles, "--rvg-color-column-drop-target-fill", "#e2edf9"),
|
|
2320
2346
|
stripe: stripedColor ?? readThemeColor(themeStyles, "--rvg-color-stripe", "#fafbfc")
|
|
2321
2347
|
};
|
|
2322
2348
|
const scroll = scrollRef.current;
|
|
@@ -3599,7 +3625,7 @@ function TableInner({
|
|
|
3599
3625
|
}, []);
|
|
3600
3626
|
const clearColumnOrderPointerDrag = (0, import_react5.useCallback)((canvas) => {
|
|
3601
3627
|
columnOrderDragRef.current = null;
|
|
3602
|
-
|
|
3628
|
+
setColumnDragPreview(null);
|
|
3603
3629
|
validColumnDropRef.current = null;
|
|
3604
3630
|
setColumnDropTarget(null);
|
|
3605
3631
|
setDragGuide(null);
|
|
@@ -3635,6 +3661,17 @@ function TableInner({
|
|
|
3635
3661
|
}
|
|
3636
3662
|
event.preventDefault();
|
|
3637
3663
|
const sourceCell = drag.sourceCell;
|
|
3664
|
+
const rootRect = rootRef.current?.getBoundingClientRect() ?? event.currentTarget.getBoundingClientRect();
|
|
3665
|
+
const sourceWidth = metrics[sourceCell.startIndex]?.width ?? 160;
|
|
3666
|
+
const previewWidth = Math.min(sourceWidth, Math.max(60, viewport.width - 16));
|
|
3667
|
+
const previewRowCount = Math.min(rows.length, 6);
|
|
3668
|
+
const previewHeight = headerLeafHeight + previewRowCount * rowHeight;
|
|
3669
|
+
setColumnDragPreview({
|
|
3670
|
+
sourceIndex: sourceCell.startIndex,
|
|
3671
|
+
left: Math.max(4, Math.min(viewport.width - previewWidth - 4, event.clientX - rootRect.left + 12)),
|
|
3672
|
+
top: Math.max(4, Math.min(viewport.height - previewHeight - 4, event.clientY - rootRect.top + 12)),
|
|
3673
|
+
width: previewWidth
|
|
3674
|
+
});
|
|
3638
3675
|
const hoveredColumnIndex = locateColumn(event.clientX);
|
|
3639
3676
|
const targetCell = locateHeaderCell(event.clientX, event.clientY) ?? headerCells.find((cell) => hoveredColumnIndex >= cell.startIndex && hoveredColumnIndex <= cell.endIndex && cell.level === sourceCell.level && cell.leaf === sourceCell.leaf && cell.parentKey === sourceCell.parentKey && columns[cell.startIndex]?.fixed === columns[sourceCell.startIndex]?.fixed);
|
|
3640
3677
|
if (!targetCell) {
|
|
@@ -3660,7 +3697,6 @@ function TableInner({
|
|
|
3660
3697
|
columnEdge,
|
|
3661
3698
|
columns.length
|
|
3662
3699
|
);
|
|
3663
|
-
columnDragPreviewRef.current = { sourceIndex: sourceCell.startIndex, targetIndex: destinationIndex };
|
|
3664
3700
|
if (destinationIndex === sourceCell.startIndex) {
|
|
3665
3701
|
validColumnDropRef.current = null;
|
|
3666
3702
|
setColumnDropTarget(null);
|
|
@@ -3677,9 +3713,13 @@ function TableInner({
|
|
|
3677
3713
|
fixed: targetColumn.fixed,
|
|
3678
3714
|
columnEdge
|
|
3679
3715
|
};
|
|
3680
|
-
|
|
3716
|
+
const compatibleHighlightCells = headerCells.filter((cell) => {
|
|
3717
|
+
const cellColumn = columns[cell.startIndex];
|
|
3718
|
+
return cellColumn && !cellColumn.rowSelection && !cellColumn.rowDragHandle && !cellColumn.rowNumber && cellColumn.fixed === targetColumn.fixed;
|
|
3719
|
+
});
|
|
3720
|
+
setColumnDropTarget(resolveColumnDropHighlightRange(targetCell, columnEdge, compatibleHighlightCells));
|
|
3681
3721
|
setDragGuide(columnEdge === "right" ? targetLeft + targetWidth : targetLeft, headerRowOffsets[sourceCell.level] ?? 0);
|
|
3682
|
-
}, [columns, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerRowOffsets, hideDragTooltips, locateColumn, locateHeaderCell, setDragGuide]);
|
|
3722
|
+
}, [columns, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerLeafHeight, headerRowOffsets, hideDragTooltips, locateColumn, locateHeaderCell, metrics, rowHeight, rows.length, setDragGuide, viewport.height, viewport.width]);
|
|
3683
3723
|
const finishColumnOrderPointerDrag = (0, import_react5.useCallback)((event, apply) => {
|
|
3684
3724
|
const drag = columnOrderDragRef.current;
|
|
3685
3725
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
@@ -3832,7 +3872,11 @@ function TableInner({
|
|
|
3832
3872
|
const rect = target.getBoundingClientRect();
|
|
3833
3873
|
if (clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom) continue;
|
|
3834
3874
|
const label = target.dataset.rvgTooltip?.trim();
|
|
3835
|
-
if (!label) return
|
|
3875
|
+
if (!label) return false;
|
|
3876
|
+
const visibleText = target.textContent?.replace(/\s+/g, " ").trim() ?? "";
|
|
3877
|
+
const candidates = [target, ...target.querySelectorAll("*")];
|
|
3878
|
+
const truncated = candidates.some((candidate) => candidate.scrollWidth > candidate.clientWidth + 1 || candidate.scrollHeight > candidate.clientHeight + 1);
|
|
3879
|
+
if (!truncated && label.replace(/\s+/g, " ").trim() === visibleText) return false;
|
|
3836
3880
|
const rawLeft = rect.left - canvasRect.left;
|
|
3837
3881
|
return {
|
|
3838
3882
|
key: `content:${columnIndex}:${label}:${Math.round(rawLeft)}:${Math.round(rect.top - canvasRect.top)}`,
|
|
@@ -4190,6 +4234,7 @@ function TableInner({
|
|
|
4190
4234
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4191
4235
|
"span",
|
|
4192
4236
|
{
|
|
4237
|
+
style: { width: "100%" },
|
|
4193
4238
|
ref: (node) => {
|
|
4194
4239
|
if (node) {
|
|
4195
4240
|
customHeaderContentRefs.current.set(column.key, node);
|
|
@@ -4556,8 +4601,10 @@ function TableInner({
|
|
|
4556
4601
|
const hoveredAction = inLeafHeader ? locateHeaderAction(event.clientX, columnIndex) : null;
|
|
4557
4602
|
const hoveredDragHandle = Boolean(hoveredHeaderCell && locateHeaderCellDragHandle(event.clientX, hoveredHeaderCell));
|
|
4558
4603
|
const hoveredDragColumnIndex = hoveredHeaderCell?.startIndex ?? columnIndex;
|
|
4559
|
-
const
|
|
4560
|
-
const
|
|
4604
|
+
const customHeaderTooltipMatch = inHeader && !hoveredAction && !hoveredDragHandle ? locateCustomHeaderTooltip(event.clientX, event.clientY, columnIndex) : null;
|
|
4605
|
+
const hoveredContentTooltip = customHeaderTooltipMatch || null;
|
|
4606
|
+
const hoveredCustomContent = customHeaderTooltipMatch !== null;
|
|
4607
|
+
const hoveredTitle = inHeader && !hoveredAction && !hoveredDragHandle && !hoveredCustomContent && hoveredHeaderCell && Boolean(hoveredHeaderCell.column.title) && isPointerOnHeaderTitle(event.clientX, event.clientY, hoveredHeaderCell) && (tooltipConfig.header || hoveredHeaderCell.leaf && isHeaderTitleTruncated(hoveredHeaderCell.startIndex));
|
|
4561
4608
|
const nextHover = hoveredAction ? { columnIndex, action: hoveredAction } : hoveredDragHandle ? { columnIndex: hoveredDragColumnIndex, action: "drag" } : hoveredContentTooltip ? { columnIndex, action: "content" } : hoveredTitle ? { columnIndex: hoveredHeaderCell.startIndex, action: "title" } : null;
|
|
4562
4609
|
const nextTooltip = hoveredAction && hoveredHeaderCell ? createHeaderTooltip(hoveredAction, columnIndex, hoveredHeaderCell) : hoveredDragHandle && hoveredHeaderCell ? createHeaderTooltip("drag", hoveredDragColumnIndex, hoveredHeaderCell) : hoveredContentTooltip ? hoveredContentTooltip : hoveredTitle && hoveredHeaderCell ? createHeaderTooltip("title", hoveredHeaderCell.startIndex, hoveredHeaderCell) : null;
|
|
4563
4610
|
const previousHover = hoveredHeaderActionRef.current;
|
|
@@ -5184,6 +5231,31 @@ function TableInner({
|
|
|
5184
5231
|
}
|
|
5185
5232
|
),
|
|
5186
5233
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: dragGuideRef, className: "rvg-column-guide" }),
|
|
5234
|
+
columnDragPreview && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
5235
|
+
"div",
|
|
5236
|
+
{
|
|
5237
|
+
"aria-hidden": "true",
|
|
5238
|
+
className: "rvg-column-drag-preview",
|
|
5239
|
+
style: {
|
|
5240
|
+
left: columnDragPreview.left,
|
|
5241
|
+
top: columnDragPreview.top,
|
|
5242
|
+
width: columnDragPreview.width,
|
|
5243
|
+
height: headerLeafHeight + Math.min(rows.length, 6) * rowHeight
|
|
5244
|
+
},
|
|
5245
|
+
children: [
|
|
5246
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rvg-column-drag-preview-header", style: { top: 0, height: headerLeafHeight }, children: columns[columnDragPreview.sourceIndex]?.title }),
|
|
5247
|
+
rows.slice(0, 6).map((_row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5248
|
+
"div",
|
|
5249
|
+
{
|
|
5250
|
+
className: "rvg-column-drag-preview-cell",
|
|
5251
|
+
style: { top: headerLeafHeight + rowIndex * rowHeight, height: rowHeight },
|
|
5252
|
+
children: getCellLabel(rowIndex, columnDragPreview.sourceIndex)
|
|
5253
|
+
},
|
|
5254
|
+
`column-preview:${String(getRowKey(rows[rowIndex], rowIndex))}`
|
|
5255
|
+
))
|
|
5256
|
+
]
|
|
5257
|
+
}
|
|
5258
|
+
),
|
|
5187
5259
|
resizeGuideX !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5188
5260
|
"div",
|
|
5189
5261
|
{
|
package/dist/index.css
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
--rvg-color-selection-fill: #edf4ff;
|
|
18
18
|
--rvg-color-axis-selection-fill: #e8f2ff;
|
|
19
19
|
--rvg-color-axis-selection-text: var(--rvg-color-text);
|
|
20
|
-
--rvg-color-column-drop-target-fill: #
|
|
20
|
+
--rvg-color-column-drop-target-fill: #e2edf9;
|
|
21
21
|
--rvg-color-range-fill: #e8f1ff;
|
|
22
22
|
--rvg-color-row-hover-fill: #f6f9fc;
|
|
23
23
|
--rvg-color-hover: #f1f4f8;
|
|
@@ -1508,12 +1508,14 @@
|
|
|
1508
1508
|
background: var(--rvg-color-danger);
|
|
1509
1509
|
}
|
|
1510
1510
|
.rvg-column-drag-preview {
|
|
1511
|
-
position:
|
|
1511
|
+
position: absolute;
|
|
1512
|
+
z-index: 11;
|
|
1512
1513
|
overflow: hidden;
|
|
1513
|
-
border: 1px solid
|
|
1514
|
-
background:
|
|
1515
|
-
box-shadow:
|
|
1516
|
-
opacity: 0.
|
|
1514
|
+
border: 1px solid color-mix(in srgb, var(--rvg-color-primary) 32%, var(--rvg-color-grid));
|
|
1515
|
+
background: color-mix(in srgb, var(--rvg-color-primary) 4%, var(--rvg-color-bg));
|
|
1516
|
+
box-shadow: 0 8px 22px rgba(50, 91, 136, 0.2);
|
|
1517
|
+
opacity: 0.96;
|
|
1518
|
+
pointer-events: none;
|
|
1517
1519
|
box-sizing: border-box;
|
|
1518
1520
|
}
|
|
1519
1521
|
.rvg-column-drag-preview-header,
|
|
@@ -1537,8 +1539,8 @@
|
|
|
1537
1539
|
box-sizing: border-box;
|
|
1538
1540
|
}
|
|
1539
1541
|
.rvg-column-drag-preview-header {
|
|
1540
|
-
background: var(--rvg-color-header-bg);
|
|
1541
|
-
color: var(--rvg-color-
|
|
1542
|
+
background: color-mix(in srgb, var(--rvg-color-primary) 10%, var(--rvg-color-header-bg));
|
|
1543
|
+
color: var(--rvg-color-text);
|
|
1542
1544
|
font-weight: 600;
|
|
1543
1545
|
}
|
|
1544
1546
|
.rvg-column-drag-preview-header .rvg-preview-header-icon {
|
package/dist/index.js
CHANGED
|
@@ -852,7 +852,7 @@ var COLORS = {
|
|
|
852
852
|
rowHoverFill: "#f6f9fc",
|
|
853
853
|
editedFill: "#fff1b8",
|
|
854
854
|
insertedFill: "#c8ead4",
|
|
855
|
-
columnDropTargetFill: "#
|
|
855
|
+
columnDropTargetFill: "#e2edf9",
|
|
856
856
|
stripe: "#fafbfc"
|
|
857
857
|
};
|
|
858
858
|
function ellipsizeText(context, text, maxWidth) {
|
|
@@ -936,15 +936,17 @@ function paintGrid(options) {
|
|
|
936
936
|
const row = rows[rowIndex];
|
|
937
937
|
const rowKey = getRowKey(row, rowIndex);
|
|
938
938
|
const trailingRowStyle = options.rowStyle?.(row, rowIndex);
|
|
939
|
-
let fill = striped && rowIndex % 2 === 1 ? colors.stripe : null;
|
|
940
|
-
if (trailingRowStyle?.backgroundColor) fill = trailingRowStyle.backgroundColor;
|
|
941
|
-
if (selectedRowKeys.has(rowKey)) fill = colors.axisSelectionFill;
|
|
942
|
-
if (hoveredRowIndex === rowIndex) fill = colors.rowHoverFill;
|
|
943
|
-
if (highlightInsertedRows && insertedRowKeys.has(rowKey)) fill = colors.insertedFill;
|
|
944
|
-
if (!fill) continue;
|
|
945
939
|
const y = bodyTop + rowIndex * rowHeight - scrollTop + getRowDragOffset(rowIndex);
|
|
946
|
-
|
|
947
|
-
|
|
940
|
+
const paintTrailingLayer = (fill) => {
|
|
941
|
+
if (!fill) return;
|
|
942
|
+
ctx.fillStyle = fill;
|
|
943
|
+
ctx.fillRect(trailingBlankStart, y, width - trailingBlankStart, rowHeight);
|
|
944
|
+
};
|
|
945
|
+
if (striped && rowIndex % 2 === 1) paintTrailingLayer(colors.stripe);
|
|
946
|
+
paintTrailingLayer(trailingRowStyle?.backgroundColor);
|
|
947
|
+
if (selectedRowKeys.has(rowKey)) paintTrailingLayer(colors.axisSelectionFill);
|
|
948
|
+
if (hoveredRowIndex === rowIndex) paintTrailingLayer(colors.rowHoverFill);
|
|
949
|
+
if (highlightInsertedRows && insertedRowKeys.has(rowKey)) paintTrailingLayer(colors.insertedFill);
|
|
948
950
|
}
|
|
949
951
|
}
|
|
950
952
|
const paintBodyColumns = (layer) => {
|
|
@@ -969,6 +971,7 @@ function paintGrid(options) {
|
|
|
969
971
|
const cellWidth = getCellWidth(columnIndex, colSpan);
|
|
970
972
|
const cellHeight = rowHeight * rowSpan;
|
|
971
973
|
const isAxisSelected = selectedRowKeys.has(rowKey) || selectedColumnKeys.has(column.key);
|
|
974
|
+
const isColumnDropTarget = Boolean(columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex);
|
|
972
975
|
const rangeRowStart = selectionRange ? Math.min(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
973
976
|
const rangeRowEnd = selectionRange ? Math.max(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
974
977
|
const rangeColumnStart = selectionRange ? Math.min(selectionRange.anchor.columnIndex, selectionRange.focus.columnIndex) : -1;
|
|
@@ -990,10 +993,6 @@ function paintGrid(options) {
|
|
|
990
993
|
ctx.fillStyle = colors.rowHoverFill;
|
|
991
994
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
992
995
|
}
|
|
993
|
-
if (columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex) {
|
|
994
|
-
ctx.fillStyle = colors.columnDropTargetFill;
|
|
995
|
-
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
996
|
-
}
|
|
997
996
|
if (highlightInsertedRows && insertedRowKeys.has(rowKey)) {
|
|
998
997
|
ctx.fillStyle = colors.insertedFill;
|
|
999
998
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
@@ -1018,6 +1017,10 @@ function paintGrid(options) {
|
|
|
1018
1017
|
ctx.fillStyle = annotation.color;
|
|
1019
1018
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1020
1019
|
}
|
|
1020
|
+
if (isColumnDropTarget) {
|
|
1021
|
+
ctx.fillStyle = colors.columnDropTargetFill;
|
|
1022
|
+
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1023
|
+
}
|
|
1021
1024
|
ctx.fillStyle = colors.grid;
|
|
1022
1025
|
if (!verticalBorderless && !(frameBorderless && columnIndex + colSpan >= columns.length)) {
|
|
1023
1026
|
ctx.fillRect(x + cellWidth - 1, y, 1, cellHeight);
|
|
@@ -1027,14 +1030,14 @@ function paintGrid(options) {
|
|
|
1027
1030
|
ctx.fillRect(x, y + cellHeight - 1, cellWidth, 1);
|
|
1028
1031
|
}
|
|
1029
1032
|
if (rowSpan > 1) {
|
|
1030
|
-
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? rowStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1033
|
+
const mergedFill = isColumnDropTarget ? colors.columnDropTargetFill : annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? rowStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1031
1034
|
ctx.fillStyle = mergedFill;
|
|
1032
1035
|
for (let offset = 1; offset < rowSpan; offset += 1) {
|
|
1033
1036
|
ctx.fillRect(x, y + offset * rowHeight - 1, cellWidth, 2);
|
|
1034
1037
|
}
|
|
1035
1038
|
}
|
|
1036
1039
|
if (colSpan > 1 && !verticalBorderless) {
|
|
1037
|
-
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? rowStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1040
|
+
const mergedFill = isColumnDropTarget ? colors.columnDropTargetFill : annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? rowStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1038
1041
|
ctx.fillStyle = mergedFill;
|
|
1039
1042
|
let offsetLeft = 0;
|
|
1040
1043
|
for (let offset = 1; offset < colSpan; offset += 1) {
|
|
@@ -1131,7 +1134,7 @@ function paintGrid(options) {
|
|
|
1131
1134
|
ctx.beginPath();
|
|
1132
1135
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1133
1136
|
ctx.clip();
|
|
1134
|
-
ctx.fillStyle = isAxisSelected && !isSelectedCell && !isRangeCell ? colors.axisSelectionText : cellStyle?.color ?? rowStyle?.color ?? colors.text;
|
|
1137
|
+
ctx.fillStyle = isColumnDropTarget ? colors.text : isAxisSelected && !isSelectedCell && !isRangeCell ? colors.axisSelectionText : cellStyle?.color ?? rowStyle?.color ?? colors.text;
|
|
1135
1138
|
ctx.font = createCellFont(bodyFontSize);
|
|
1136
1139
|
ctx.textBaseline = "alphabetic";
|
|
1137
1140
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
@@ -1194,6 +1197,25 @@ function paintGrid(options) {
|
|
|
1194
1197
|
paintExtendedColumnSelection("scroll");
|
|
1195
1198
|
paintExtendedColumnSelection("left");
|
|
1196
1199
|
paintExtendedColumnSelection("right");
|
|
1200
|
+
const paintExtendedColumnDropTarget = (layer) => {
|
|
1201
|
+
if (!columnDropTarget) return;
|
|
1202
|
+
ctx.save();
|
|
1203
|
+
if (layer === "scroll") {
|
|
1204
|
+
ctx.beginPath();
|
|
1205
|
+
ctx.rect(leftFixedWidth, extensionTop, Math.max(0, rightFixedLeft - leftFixedWidth), extensionHeight);
|
|
1206
|
+
ctx.clip();
|
|
1207
|
+
}
|
|
1208
|
+
ctx.fillStyle = colors.columnDropTargetFill;
|
|
1209
|
+
for (let columnIndex = columnDropTarget.startIndex; columnIndex <= columnDropTarget.endIndex; columnIndex += 1) {
|
|
1210
|
+
if (layer === "scroll" ? columns[columnIndex]?.fixed !== void 0 : columns[columnIndex]?.fixed !== layer) continue;
|
|
1211
|
+
if (layer === "scroll" && (columnIndex < range.columnStart || columnIndex >= range.columnEnd)) continue;
|
|
1212
|
+
ctx.fillRect(getColumnX(columnIndex), extensionTop, metrics[columnIndex].width, extensionHeight);
|
|
1213
|
+
}
|
|
1214
|
+
ctx.restore();
|
|
1215
|
+
};
|
|
1216
|
+
paintExtendedColumnDropTarget("scroll");
|
|
1217
|
+
paintExtendedColumnDropTarget("left");
|
|
1218
|
+
paintExtendedColumnDropTarget("right");
|
|
1197
1219
|
if (!verticalBorderless) {
|
|
1198
1220
|
paintExtendedColumnLines("scroll");
|
|
1199
1221
|
paintExtendedColumnLines("left");
|
|
@@ -1215,11 +1237,12 @@ function paintGrid(options) {
|
|
|
1215
1237
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1216
1238
|
}
|
|
1217
1239
|
const isAxisSelected = selectedColumnKeys.has(columns[columnIndex].key);
|
|
1240
|
+
const isColumnDropTarget = Boolean(columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex);
|
|
1218
1241
|
if (isAxisSelected) {
|
|
1219
1242
|
ctx.fillStyle = colors.axisSelectionFill;
|
|
1220
1243
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1221
1244
|
}
|
|
1222
|
-
if (
|
|
1245
|
+
if (isColumnDropTarget) {
|
|
1223
1246
|
ctx.fillStyle = colors.columnDropTargetFill;
|
|
1224
1247
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1225
1248
|
}
|
|
@@ -1248,7 +1271,7 @@ function paintGrid(options) {
|
|
|
1248
1271
|
ctx.beginPath();
|
|
1249
1272
|
ctx.rect(x + 2, headerY + headerLeafTop + 1, Math.max(0, clipWidth - 4), headerLeafHeight - 2);
|
|
1250
1273
|
ctx.clip();
|
|
1251
|
-
ctx.fillStyle = isAxisSelected ? colors.axisSelectionText : colors.muted;
|
|
1274
|
+
ctx.fillStyle = isColumnDropTarget ? colors.muted : isAxisSelected ? colors.axisSelectionText : colors.muted;
|
|
1252
1275
|
ctx.textAlign = titleAlign === "right" ? "right" : titleAlign === "center" ? "center" : "left";
|
|
1253
1276
|
ctx.fillText(title, textX, headerY + headerLeafTop + headerLeafHeight / 2);
|
|
1254
1277
|
ctx.restore();
|
|
@@ -1407,6 +1430,9 @@ function resolveColumnDropIndex(sourceIndex, targetIndex, edge, columnCount) {
|
|
|
1407
1430
|
function resolveColumnDropPlacement(edge) {
|
|
1408
1431
|
return edge === "right" ? "after" : "before";
|
|
1409
1432
|
}
|
|
1433
|
+
function resolveColumnDropHighlightRange(target, _edge, _cells) {
|
|
1434
|
+
return { startIndex: target.startIndex, endIndex: target.endIndex };
|
|
1435
|
+
}
|
|
1410
1436
|
var ANNOTATION_COLORS = ["#f44336", "#ff7a45", "#f5a623", "#f2c94c", "#52c41a", "#13a8a8", "#1677ff", "#597ef7", "#9254de", "#eb2f96"];
|
|
1411
1437
|
var FALLBACK_HEIGHT = 480;
|
|
1412
1438
|
var EMPTY_BODY_HEIGHT = 240;
|
|
@@ -1753,7 +1779,6 @@ function TableInner({
|
|
|
1753
1779
|
const contextMenuRef = useRef2(null);
|
|
1754
1780
|
const suppressClickRef = useRef2(false);
|
|
1755
1781
|
const hasCompletedLoadRef = useRef2(!loading);
|
|
1756
|
-
const columnDragPreviewRef = useRef2(null);
|
|
1757
1782
|
const validColumnDropRef = useRef2(null);
|
|
1758
1783
|
const hoveredHeaderActionRef = useRef2(null);
|
|
1759
1784
|
const hoveredRowIndexRef = useRef2(null);
|
|
@@ -1787,6 +1812,7 @@ function TableInner({
|
|
|
1787
1812
|
const [editing, setEditing] = useState4(null);
|
|
1788
1813
|
const [draft, setDraft] = useState4("");
|
|
1789
1814
|
const [rowDragPreview, setRowDragPreview] = useState4(null);
|
|
1815
|
+
const [columnDragPreview, setColumnDragPreview] = useState4(null);
|
|
1790
1816
|
const [columnDropTarget, setColumnDropTarget] = useState4(null);
|
|
1791
1817
|
useEffect2(() => {
|
|
1792
1818
|
if (!loading) hasCompletedLoadRef.current = true;
|
|
@@ -2286,7 +2312,7 @@ function TableInner({
|
|
|
2286
2312
|
rowHoverFill: readThemeColor(themeStyles, "--rvg-color-row-hover-fill", "#f6f9fc"),
|
|
2287
2313
|
editedFill: editedCellHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-edited-fill", "#fff1b8"),
|
|
2288
2314
|
insertedFill: insertedRowHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-inserted-fill", "#c8ead4"),
|
|
2289
|
-
columnDropTargetFill: readThemeColor(themeStyles, "--rvg-color-column-drop-target-fill", "#
|
|
2315
|
+
columnDropTargetFill: readThemeColor(themeStyles, "--rvg-color-column-drop-target-fill", "#e2edf9"),
|
|
2290
2316
|
stripe: stripedColor ?? readThemeColor(themeStyles, "--rvg-color-stripe", "#fafbfc")
|
|
2291
2317
|
};
|
|
2292
2318
|
const scroll = scrollRef.current;
|
|
@@ -3569,7 +3595,7 @@ function TableInner({
|
|
|
3569
3595
|
}, []);
|
|
3570
3596
|
const clearColumnOrderPointerDrag = useCallback2((canvas) => {
|
|
3571
3597
|
columnOrderDragRef.current = null;
|
|
3572
|
-
|
|
3598
|
+
setColumnDragPreview(null);
|
|
3573
3599
|
validColumnDropRef.current = null;
|
|
3574
3600
|
setColumnDropTarget(null);
|
|
3575
3601
|
setDragGuide(null);
|
|
@@ -3605,6 +3631,17 @@ function TableInner({
|
|
|
3605
3631
|
}
|
|
3606
3632
|
event.preventDefault();
|
|
3607
3633
|
const sourceCell = drag.sourceCell;
|
|
3634
|
+
const rootRect = rootRef.current?.getBoundingClientRect() ?? event.currentTarget.getBoundingClientRect();
|
|
3635
|
+
const sourceWidth = metrics[sourceCell.startIndex]?.width ?? 160;
|
|
3636
|
+
const previewWidth = Math.min(sourceWidth, Math.max(60, viewport.width - 16));
|
|
3637
|
+
const previewRowCount = Math.min(rows.length, 6);
|
|
3638
|
+
const previewHeight = headerLeafHeight + previewRowCount * rowHeight;
|
|
3639
|
+
setColumnDragPreview({
|
|
3640
|
+
sourceIndex: sourceCell.startIndex,
|
|
3641
|
+
left: Math.max(4, Math.min(viewport.width - previewWidth - 4, event.clientX - rootRect.left + 12)),
|
|
3642
|
+
top: Math.max(4, Math.min(viewport.height - previewHeight - 4, event.clientY - rootRect.top + 12)),
|
|
3643
|
+
width: previewWidth
|
|
3644
|
+
});
|
|
3608
3645
|
const hoveredColumnIndex = locateColumn(event.clientX);
|
|
3609
3646
|
const targetCell = locateHeaderCell(event.clientX, event.clientY) ?? headerCells.find((cell) => hoveredColumnIndex >= cell.startIndex && hoveredColumnIndex <= cell.endIndex && cell.level === sourceCell.level && cell.leaf === sourceCell.leaf && cell.parentKey === sourceCell.parentKey && columns[cell.startIndex]?.fixed === columns[sourceCell.startIndex]?.fixed);
|
|
3610
3647
|
if (!targetCell) {
|
|
@@ -3630,7 +3667,6 @@ function TableInner({
|
|
|
3630
3667
|
columnEdge,
|
|
3631
3668
|
columns.length
|
|
3632
3669
|
);
|
|
3633
|
-
columnDragPreviewRef.current = { sourceIndex: sourceCell.startIndex, targetIndex: destinationIndex };
|
|
3634
3670
|
if (destinationIndex === sourceCell.startIndex) {
|
|
3635
3671
|
validColumnDropRef.current = null;
|
|
3636
3672
|
setColumnDropTarget(null);
|
|
@@ -3647,9 +3683,13 @@ function TableInner({
|
|
|
3647
3683
|
fixed: targetColumn.fixed,
|
|
3648
3684
|
columnEdge
|
|
3649
3685
|
};
|
|
3650
|
-
|
|
3686
|
+
const compatibleHighlightCells = headerCells.filter((cell) => {
|
|
3687
|
+
const cellColumn = columns[cell.startIndex];
|
|
3688
|
+
return cellColumn && !cellColumn.rowSelection && !cellColumn.rowDragHandle && !cellColumn.rowNumber && cellColumn.fixed === targetColumn.fixed;
|
|
3689
|
+
});
|
|
3690
|
+
setColumnDropTarget(resolveColumnDropHighlightRange(targetCell, columnEdge, compatibleHighlightCells));
|
|
3651
3691
|
setDragGuide(columnEdge === "right" ? targetLeft + targetWidth : targetLeft, headerRowOffsets[sourceCell.level] ?? 0);
|
|
3652
|
-
}, [columns, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerRowOffsets, hideDragTooltips, locateColumn, locateHeaderCell, setDragGuide]);
|
|
3692
|
+
}, [columns, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerLeafHeight, headerRowOffsets, hideDragTooltips, locateColumn, locateHeaderCell, metrics, rowHeight, rows.length, setDragGuide, viewport.height, viewport.width]);
|
|
3653
3693
|
const finishColumnOrderPointerDrag = useCallback2((event, apply) => {
|
|
3654
3694
|
const drag = columnOrderDragRef.current;
|
|
3655
3695
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
@@ -3802,7 +3842,11 @@ function TableInner({
|
|
|
3802
3842
|
const rect = target.getBoundingClientRect();
|
|
3803
3843
|
if (clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom) continue;
|
|
3804
3844
|
const label = target.dataset.rvgTooltip?.trim();
|
|
3805
|
-
if (!label) return
|
|
3845
|
+
if (!label) return false;
|
|
3846
|
+
const visibleText = target.textContent?.replace(/\s+/g, " ").trim() ?? "";
|
|
3847
|
+
const candidates = [target, ...target.querySelectorAll("*")];
|
|
3848
|
+
const truncated = candidates.some((candidate) => candidate.scrollWidth > candidate.clientWidth + 1 || candidate.scrollHeight > candidate.clientHeight + 1);
|
|
3849
|
+
if (!truncated && label.replace(/\s+/g, " ").trim() === visibleText) return false;
|
|
3806
3850
|
const rawLeft = rect.left - canvasRect.left;
|
|
3807
3851
|
return {
|
|
3808
3852
|
key: `content:${columnIndex}:${label}:${Math.round(rawLeft)}:${Math.round(rect.top - canvasRect.top)}`,
|
|
@@ -4160,6 +4204,7 @@ function TableInner({
|
|
|
4160
4204
|
children: /* @__PURE__ */ jsx7(
|
|
4161
4205
|
"span",
|
|
4162
4206
|
{
|
|
4207
|
+
style: { width: "100%" },
|
|
4163
4208
|
ref: (node) => {
|
|
4164
4209
|
if (node) {
|
|
4165
4210
|
customHeaderContentRefs.current.set(column.key, node);
|
|
@@ -4526,8 +4571,10 @@ function TableInner({
|
|
|
4526
4571
|
const hoveredAction = inLeafHeader ? locateHeaderAction(event.clientX, columnIndex) : null;
|
|
4527
4572
|
const hoveredDragHandle = Boolean(hoveredHeaderCell && locateHeaderCellDragHandle(event.clientX, hoveredHeaderCell));
|
|
4528
4573
|
const hoveredDragColumnIndex = hoveredHeaderCell?.startIndex ?? columnIndex;
|
|
4529
|
-
const
|
|
4530
|
-
const
|
|
4574
|
+
const customHeaderTooltipMatch = inHeader && !hoveredAction && !hoveredDragHandle ? locateCustomHeaderTooltip(event.clientX, event.clientY, columnIndex) : null;
|
|
4575
|
+
const hoveredContentTooltip = customHeaderTooltipMatch || null;
|
|
4576
|
+
const hoveredCustomContent = customHeaderTooltipMatch !== null;
|
|
4577
|
+
const hoveredTitle = inHeader && !hoveredAction && !hoveredDragHandle && !hoveredCustomContent && hoveredHeaderCell && Boolean(hoveredHeaderCell.column.title) && isPointerOnHeaderTitle(event.clientX, event.clientY, hoveredHeaderCell) && (tooltipConfig.header || hoveredHeaderCell.leaf && isHeaderTitleTruncated(hoveredHeaderCell.startIndex));
|
|
4531
4578
|
const nextHover = hoveredAction ? { columnIndex, action: hoveredAction } : hoveredDragHandle ? { columnIndex: hoveredDragColumnIndex, action: "drag" } : hoveredContentTooltip ? { columnIndex, action: "content" } : hoveredTitle ? { columnIndex: hoveredHeaderCell.startIndex, action: "title" } : null;
|
|
4532
4579
|
const nextTooltip = hoveredAction && hoveredHeaderCell ? createHeaderTooltip(hoveredAction, columnIndex, hoveredHeaderCell) : hoveredDragHandle && hoveredHeaderCell ? createHeaderTooltip("drag", hoveredDragColumnIndex, hoveredHeaderCell) : hoveredContentTooltip ? hoveredContentTooltip : hoveredTitle && hoveredHeaderCell ? createHeaderTooltip("title", hoveredHeaderCell.startIndex, hoveredHeaderCell) : null;
|
|
4533
4580
|
const previousHover = hoveredHeaderActionRef.current;
|
|
@@ -5154,6 +5201,31 @@ function TableInner({
|
|
|
5154
5201
|
}
|
|
5155
5202
|
),
|
|
5156
5203
|
/* @__PURE__ */ jsx7("div", { ref: dragGuideRef, className: "rvg-column-guide" }),
|
|
5204
|
+
columnDragPreview && /* @__PURE__ */ jsxs7(
|
|
5205
|
+
"div",
|
|
5206
|
+
{
|
|
5207
|
+
"aria-hidden": "true",
|
|
5208
|
+
className: "rvg-column-drag-preview",
|
|
5209
|
+
style: {
|
|
5210
|
+
left: columnDragPreview.left,
|
|
5211
|
+
top: columnDragPreview.top,
|
|
5212
|
+
width: columnDragPreview.width,
|
|
5213
|
+
height: headerLeafHeight + Math.min(rows.length, 6) * rowHeight
|
|
5214
|
+
},
|
|
5215
|
+
children: [
|
|
5216
|
+
/* @__PURE__ */ jsx7("div", { className: "rvg-column-drag-preview-header", style: { top: 0, height: headerLeafHeight }, children: columns[columnDragPreview.sourceIndex]?.title }),
|
|
5217
|
+
rows.slice(0, 6).map((_row, rowIndex) => /* @__PURE__ */ jsx7(
|
|
5218
|
+
"div",
|
|
5219
|
+
{
|
|
5220
|
+
className: "rvg-column-drag-preview-cell",
|
|
5221
|
+
style: { top: headerLeafHeight + rowIndex * rowHeight, height: rowHeight },
|
|
5222
|
+
children: getCellLabel(rowIndex, columnDragPreview.sourceIndex)
|
|
5223
|
+
},
|
|
5224
|
+
`column-preview:${String(getRowKey(rows[rowIndex], rowIndex))}`
|
|
5225
|
+
))
|
|
5226
|
+
]
|
|
5227
|
+
}
|
|
5228
|
+
),
|
|
5157
5229
|
resizeGuideX !== null && /* @__PURE__ */ jsx7(
|
|
5158
5230
|
"div",
|
|
5159
5231
|
{
|