@lensui/lens-table 0.1.86 → 0.1.88
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 +64 -31
- package/dist/index.css +23 -6
- package/dist/index.js +64 -31
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1176,6 +1176,13 @@ function getSelectionOutlineBounds({
|
|
|
1176
1176
|
bottom: Math.min(bottom + borderWidth, verticalEnd + borderWidth)
|
|
1177
1177
|
};
|
|
1178
1178
|
}
|
|
1179
|
+
function getAnimatedRowDragOffset(preview, rowIndex, rowHeight) {
|
|
1180
|
+
if (!preview || rowIndex === preview.sourceIndex) return 0;
|
|
1181
|
+
const targetOffset = preview.sourceIndex < preview.targetIndex ? rowIndex > preview.sourceIndex && rowIndex <= preview.targetIndex ? -rowHeight : 0 : rowIndex >= preview.targetIndex && rowIndex < preview.sourceIndex ? rowHeight : 0;
|
|
1182
|
+
const startOffset = preview.fromOffsets?.[rowIndex] ?? 0;
|
|
1183
|
+
const progress = Math.max(0, Math.min(1, preview.progress ?? 1));
|
|
1184
|
+
return startOffset + (targetOffset - startOffset) * progress;
|
|
1185
|
+
}
|
|
1179
1186
|
function paintGrid(options) {
|
|
1180
1187
|
const { context: ctx, width, height, pixelRatio, scrollLeft, scrollTop, rowHeight, bodyFontSize, headerActionSlotWidth, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, frameBorderless, extendVerticalGridLines, striped, columnDraggable, sortState, filterValues, hoveredHeaderAction, rows, columns, metrics, range, selection, editing, hoveredRowIndex, selectionRange, selectedRowKeys, rowSelectionMode, selectedColumnKeys, highlightEditedCells, highlightInsertedRows, insertedRowKeys, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget } = options;
|
|
1181
1188
|
const headerLeafTop = options.headerLeafTop ?? 0;
|
|
@@ -1228,13 +1235,7 @@ function paintGrid(options) {
|
|
|
1228
1235
|
};
|
|
1229
1236
|
const displayedContentRight = columns.reduce((right, _column, index) => Math.max(right, getColumnX(index) + metrics[index].width), 0);
|
|
1230
1237
|
const trailingBlankStart = displayedContentRight > 0 && displayedContentRight < width ? displayedContentRight : null;
|
|
1231
|
-
const getRowDragOffset = (rowIndex) =>
|
|
1232
|
-
if (!rowDragPreview || rowIndex === rowDragPreview.sourceIndex) return 0;
|
|
1233
|
-
if (rowDragPreview.sourceIndex < rowDragPreview.targetIndex) {
|
|
1234
|
-
return rowIndex > rowDragPreview.sourceIndex && rowIndex <= rowDragPreview.targetIndex ? -rowHeight : 0;
|
|
1235
|
-
}
|
|
1236
|
-
return rowIndex >= rowDragPreview.targetIndex && rowIndex < rowDragPreview.sourceIndex ? rowHeight : 0;
|
|
1237
|
-
};
|
|
1238
|
+
const getRowDragOffset = (rowIndex) => getAnimatedRowDragOffset(rowDragPreview, rowIndex, rowHeight);
|
|
1238
1239
|
const rowBelowDragGap = rowDragPreview ? rowDragPreview.sourceIndex <= rowDragPreview.targetIndex ? rowDragPreview.targetIndex + 1 : rowDragPreview.targetIndex : -1;
|
|
1239
1240
|
if (trailingBlankStart !== null) {
|
|
1240
1241
|
const rowStart = Math.max(0, range.rowStart);
|
|
@@ -2181,6 +2182,24 @@ function TableInner({
|
|
|
2181
2182
|
const [liftedRowPreview, setLiftedRowPreview] = (0, import_react8.useState)(null);
|
|
2182
2183
|
const [columnDragPreview, setColumnDragPreview] = (0, import_react8.useState)(null);
|
|
2183
2184
|
const [columnDropTarget, setColumnDropTarget] = (0, import_react8.useState)(null);
|
|
2185
|
+
(0, import_react8.useEffect)(() => {
|
|
2186
|
+
if (!rowDragPreview || (rowDragPreview.progress ?? 1) >= 1) return;
|
|
2187
|
+
const sourceIndex = rowDragPreview.sourceIndex;
|
|
2188
|
+
const targetIndex = rowDragPreview.targetIndex;
|
|
2189
|
+
if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
|
|
2190
|
+
setRowDragPreview((current) => current?.sourceIndex === sourceIndex && current.targetIndex === targetIndex ? { ...current, progress: 1 } : current);
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2193
|
+
const startedAt = performance.now();
|
|
2194
|
+
let frame = 0;
|
|
2195
|
+
const animate = (now) => {
|
|
2196
|
+
const progress = Math.min(1, (now - startedAt) / 140);
|
|
2197
|
+
setRowDragPreview((current) => current?.sourceIndex === sourceIndex && current.targetIndex === targetIndex ? { ...current, progress } : current);
|
|
2198
|
+
if (progress < 1) frame = requestAnimationFrame(animate);
|
|
2199
|
+
};
|
|
2200
|
+
frame = requestAnimationFrame(animate);
|
|
2201
|
+
return () => cancelAnimationFrame(frame);
|
|
2202
|
+
}, [rowDragPreview?.sourceIndex, rowDragPreview?.targetIndex]);
|
|
2184
2203
|
(0, import_react8.useEffect)(() => {
|
|
2185
2204
|
if (!loading) hasCompletedLoadRef.current = true;
|
|
2186
2205
|
}, [loading]);
|
|
@@ -3476,7 +3495,15 @@ function TableInner({
|
|
|
3476
3495
|
if (drag.sourceIndex < targetIndex) targetIndex -= 1;
|
|
3477
3496
|
targetIndex = Math.max(0, Math.min(rows.length - 1, targetIndex));
|
|
3478
3497
|
drag.targetIndex = targetIndex;
|
|
3479
|
-
setRowDragPreview(
|
|
3498
|
+
setRowDragPreview((current) => current?.sourceIndex === drag.sourceIndex && current.targetIndex === targetIndex ? current : {
|
|
3499
|
+
sourceIndex: drag.sourceIndex,
|
|
3500
|
+
targetIndex,
|
|
3501
|
+
fromOffsets: Array.from(
|
|
3502
|
+
{ length: rows.length },
|
|
3503
|
+
(_, rowIndex) => getAnimatedRowDragOffset(current, rowIndex, rowHeight)
|
|
3504
|
+
),
|
|
3505
|
+
progress: 0
|
|
3506
|
+
});
|
|
3480
3507
|
setRowDragGuide(rowTop + (edge === "bottom" ? rowHeight : 0));
|
|
3481
3508
|
}, [bodyTop, hideDragTooltips, locateRow, renderHeight, rowHeight, rows.length, setRowDragGuide]);
|
|
3482
3509
|
const finishRowOrderPointerDrag = (0, import_react8.useCallback)((event, apply) => {
|
|
@@ -4415,13 +4442,7 @@ function TableInner({
|
|
|
4415
4442
|
top: Math.min(Math.max(0, clientY - root.top), Math.max(0, renderHeight - 68))
|
|
4416
4443
|
});
|
|
4417
4444
|
};
|
|
4418
|
-
const getRowDragOffset = (rowIndex) =>
|
|
4419
|
-
if (!rowDragPreview || rowIndex === rowDragPreview.sourceIndex) return 0;
|
|
4420
|
-
if (rowDragPreview.sourceIndex < rowDragPreview.targetIndex) {
|
|
4421
|
-
return rowIndex > rowDragPreview.sourceIndex && rowIndex <= rowDragPreview.targetIndex ? -rowHeight : 0;
|
|
4422
|
-
}
|
|
4423
|
-
return rowIndex >= rowDragPreview.targetIndex && rowIndex < rowDragPreview.sourceIndex ? rowHeight : 0;
|
|
4424
|
-
};
|
|
4445
|
+
const getRowDragOffset = (rowIndex) => getAnimatedRowDragOffset(rowDragPreview, rowIndex, rowHeight);
|
|
4425
4446
|
const renderAnnotationControls = (targetCells) => {
|
|
4426
4447
|
const getKey = (cell) => `${typeof cell.rowKey}:${String(cell.rowKey)}\0${cell.columnKey}`;
|
|
4427
4448
|
const hasAnnotation = targetCells.some((cell) => cellAnnotations.has(getKey(cell)));
|
|
@@ -4731,7 +4752,7 @@ function TableInner({
|
|
|
4731
4752
|
})();
|
|
4732
4753
|
const selectionOutlineStyle = (() => {
|
|
4733
4754
|
if (!selection || selectionRange) return null;
|
|
4734
|
-
if (
|
|
4755
|
+
if (liftedRowPreview?.sourceIndex === selection.rowIndex) return null;
|
|
4735
4756
|
const row = rows[selection.rowIndex];
|
|
4736
4757
|
const metric = metrics[selection.columnIndex];
|
|
4737
4758
|
const column = columns[selection.columnIndex];
|
|
@@ -5011,7 +5032,12 @@ function TableInner({
|
|
|
5011
5032
|
const draggingSelectedColumn = Boolean(
|
|
5012
5033
|
columnDragPreview && selectedColumnKeySet.has(columns[columnDragPreview.sourceIndex]?.key)
|
|
5013
5034
|
);
|
|
5014
|
-
|
|
5035
|
+
const liftedRow = liftedRowPreview ? rows[liftedRowPreview.sourceIndex] : void 0;
|
|
5036
|
+
const liftedRowKey = liftedRow && liftedRowPreview ? getRowKey(liftedRow, liftedRowPreview.sourceIndex) : void 0;
|
|
5037
|
+
const liftedRowAxisSelected = liftedRowKey !== void 0 && selectedRowKeySet.has(liftedRowKey);
|
|
5038
|
+
const liftedRowCellFocused = liftedRowKey !== void 0 && selection?.rowKey === liftedRowKey;
|
|
5039
|
+
const liftedRowStyle = liftedRow && liftedRowPreview && !liftedRowAxisSelected ? rowStyle?.(liftedRow, liftedRowPreview.sourceIndex) : void 0;
|
|
5040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: rootRef, className: `rvg-root${!hasVerticalBorders ? " is-vertical-borderless" : ""}${horizontalBorderless ? " is-horizontal-borderless" : ""}${frameBorderless ? " is-frame-borderless" : ""}${hasStripedRows ? " is-striped" : ""}${insertBusy ? " is-inserting" : ""}${deleteBusy ? " is-deleting" : ""}${draggingSelectedColumn ? " is-dragging-selected-column" : ""}${rowDragPreview ? " is-row-dragging" : ""} ${loading && !hasCompletedLoadRef.current && !hasCustomLoading ? "is-initial-loading" : ""} ${className}`, style: rootStyle, children: [
|
|
5015
5041
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: scrollerRef, className: `rvg-scroller${contextMenu ? " is-context-menu-open" : ""}`, style: { bottom: scrollerBottom }, onScroll: handleScroll, onCopy: handleCopy, onContextMenu: handleContextMenu, tabIndex: 0, role: "grid", "aria-label": ariaLabel, "aria-rowcount": rows.length, "aria-colcount": columns.length, onKeyDown: handleKeyDown, children: [
|
|
5016
5042
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5017
5043
|
"canvas",
|
|
@@ -5724,24 +5750,31 @@ function TableInner({
|
|
|
5724
5750
|
]
|
|
5725
5751
|
}
|
|
5726
5752
|
),
|
|
5727
|
-
liftedRowPreview &&
|
|
5753
|
+
liftedRowPreview && liftedRow && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5728
5754
|
"div",
|
|
5729
5755
|
{
|
|
5730
5756
|
"aria-hidden": "true",
|
|
5731
|
-
className: `rvg-row-drag-preview${
|
|
5732
|
-
style: { top: liftedRowPreview.top, width: viewport.width, height: rowHeight },
|
|
5733
|
-
children: columns.map((column, columnIndex) =>
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5757
|
+
className: `rvg-row-drag-preview${liftedRowAxisSelected ? " is-selected is-axis-selected" : ""}${hasStripedRows && liftedRowPreview.sourceIndex % 2 === 1 ? " is-striped" : ""}`,
|
|
5758
|
+
style: { ...liftedRowStyle, top: liftedRowPreview.top, width: viewport.width, height: rowHeight },
|
|
5759
|
+
children: columns.map((column, columnIndex) => {
|
|
5760
|
+
const value = column.dataIndex === void 0 ? void 0 : liftedRow[column.dataIndex];
|
|
5761
|
+
const cellStyle = liftedRowAxisSelected ? void 0 : column.cellStyle?.(value, liftedRow, liftedRowPreview.sourceIndex);
|
|
5762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5763
|
+
"div",
|
|
5764
|
+
{
|
|
5765
|
+
className: `rvg-row-drag-preview-cell${column.renderCell ? " is-custom" : ""}${liftedRowAxisSelected ? " is-axis-selected" : ""}${liftedRowCellFocused && selection?.columnKey === column.key ? " is-selected" : ""}`,
|
|
5766
|
+
style: {
|
|
5767
|
+
...cellStyle,
|
|
5768
|
+
left: getDisplayedColumnLeft(columnIndex),
|
|
5769
|
+
width: metrics[columnIndex]?.width ?? 0,
|
|
5770
|
+
justifyContent: column.align === "right" ? "flex-end" : column.align === "center" ? "center" : "flex-start",
|
|
5771
|
+
color: cellStyle?.color ?? liftedRowStyle?.color
|
|
5772
|
+
},
|
|
5773
|
+
children: column.renderCell ? column.renderCell(value, liftedRow, liftedRowPreview.sourceIndex) : getCellLabel(liftedRowPreview.sourceIndex, columnIndex)
|
|
5740
5774
|
},
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
))
|
|
5775
|
+
`row-preview:${column.key}`
|
|
5776
|
+
);
|
|
5777
|
+
})
|
|
5745
5778
|
}
|
|
5746
5779
|
),
|
|
5747
5780
|
resizeGuideX !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
package/dist/index.css
CHANGED
|
@@ -230,7 +230,12 @@
|
|
|
230
230
|
font-size: var(--rvg-font-size-body);
|
|
231
231
|
transition: transform 140ms ease, opacity 100ms ease;
|
|
232
232
|
}
|
|
233
|
-
.rvg-row-
|
|
233
|
+
.rvg-root.is-row-dragging .rvg-cell-text,
|
|
234
|
+
.rvg-root.is-row-dragging .rvg-cell-render,
|
|
235
|
+
.rvg-root.is-row-dragging .rvg-selection-focus,
|
|
236
|
+
.rvg-row-drop-settling .rvg-cell-text,
|
|
237
|
+
.rvg-row-drop-settling .rvg-cell-render,
|
|
238
|
+
.rvg-row-drop-settling .rvg-selection-focus {
|
|
234
239
|
transition: none;
|
|
235
240
|
}
|
|
236
241
|
.rvg-cell-text > span,
|
|
@@ -482,7 +487,6 @@
|
|
|
482
487
|
border: 2px solid var(--rvg-color-primary);
|
|
483
488
|
box-sizing: border-box;
|
|
484
489
|
pointer-events: none;
|
|
485
|
-
transition: transform 140ms ease;
|
|
486
490
|
}
|
|
487
491
|
.rvg-selection-edge-target {
|
|
488
492
|
position: absolute;
|
|
@@ -1638,17 +1642,24 @@
|
|
|
1638
1642
|
}
|
|
1639
1643
|
.rvg-row-drag-preview {
|
|
1640
1644
|
position: absolute;
|
|
1641
|
-
z-index:
|
|
1645
|
+
z-index: 8;
|
|
1642
1646
|
left: 0;
|
|
1643
|
-
overflow:
|
|
1647
|
+
overflow: visible;
|
|
1644
1648
|
border: 1px solid #8db8f3;
|
|
1645
1649
|
background: var(--rvg-color-bg);
|
|
1646
1650
|
box-shadow: 0 5px 14px rgba(32, 75, 135, 0.2);
|
|
1647
1651
|
box-sizing: border-box;
|
|
1648
|
-
opacity:
|
|
1652
|
+
opacity: 1;
|
|
1649
1653
|
pointer-events: none;
|
|
1650
1654
|
transform: translateY(-1px);
|
|
1651
1655
|
}
|
|
1656
|
+
.rvg-row-drag-preview.is-striped {
|
|
1657
|
+
background: var(--rvg-color-stripe);
|
|
1658
|
+
}
|
|
1659
|
+
.rvg-row-drag-preview *,
|
|
1660
|
+
.rvg-row-drag-preview-cell > * {
|
|
1661
|
+
pointer-events: none !important;
|
|
1662
|
+
}
|
|
1652
1663
|
.rvg-row-drag-preview-cell {
|
|
1653
1664
|
position: absolute;
|
|
1654
1665
|
top: 0;
|
|
@@ -1670,7 +1681,7 @@
|
|
|
1670
1681
|
}
|
|
1671
1682
|
.rvg-row-drag-preview.is-selected {
|
|
1672
1683
|
border-color: var(--rvg-color-primary);
|
|
1673
|
-
background: var(--rvg-color-selection-fill);
|
|
1684
|
+
background: var(--rvg-color-axis-selection-fill);
|
|
1674
1685
|
}
|
|
1675
1686
|
.rvg-row-drag-preview.is-selected .rvg-row-drag-preview-cell {
|
|
1676
1687
|
border-right-color: color-mix(in srgb, var(--rvg-color-axis-selection-text) 34%, transparent);
|
|
@@ -1686,6 +1697,12 @@
|
|
|
1686
1697
|
background: var(--rvg-color-selection-fill);
|
|
1687
1698
|
box-shadow: 0 0 0 2px var(--rvg-color-primary);
|
|
1688
1699
|
}
|
|
1700
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1701
|
+
.rvg-cell-text,
|
|
1702
|
+
.rvg-cell-render {
|
|
1703
|
+
transition: none;
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1689
1706
|
.rvg-preview-checkbox {
|
|
1690
1707
|
display: grid;
|
|
1691
1708
|
width: 14px;
|
package/dist/index.js
CHANGED
|
@@ -1146,6 +1146,13 @@ function getSelectionOutlineBounds({
|
|
|
1146
1146
|
bottom: Math.min(bottom + borderWidth, verticalEnd + borderWidth)
|
|
1147
1147
|
};
|
|
1148
1148
|
}
|
|
1149
|
+
function getAnimatedRowDragOffset(preview, rowIndex, rowHeight) {
|
|
1150
|
+
if (!preview || rowIndex === preview.sourceIndex) return 0;
|
|
1151
|
+
const targetOffset = preview.sourceIndex < preview.targetIndex ? rowIndex > preview.sourceIndex && rowIndex <= preview.targetIndex ? -rowHeight : 0 : rowIndex >= preview.targetIndex && rowIndex < preview.sourceIndex ? rowHeight : 0;
|
|
1152
|
+
const startOffset = preview.fromOffsets?.[rowIndex] ?? 0;
|
|
1153
|
+
const progress = Math.max(0, Math.min(1, preview.progress ?? 1));
|
|
1154
|
+
return startOffset + (targetOffset - startOffset) * progress;
|
|
1155
|
+
}
|
|
1149
1156
|
function paintGrid(options) {
|
|
1150
1157
|
const { context: ctx, width, height, pixelRatio, scrollLeft, scrollTop, rowHeight, bodyFontSize, headerActionSlotWidth, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, frameBorderless, extendVerticalGridLines, striped, columnDraggable, sortState, filterValues, hoveredHeaderAction, rows, columns, metrics, range, selection, editing, hoveredRowIndex, selectionRange, selectedRowKeys, rowSelectionMode, selectedColumnKeys, highlightEditedCells, highlightInsertedRows, insertedRowKeys, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget } = options;
|
|
1151
1158
|
const headerLeafTop = options.headerLeafTop ?? 0;
|
|
@@ -1198,13 +1205,7 @@ function paintGrid(options) {
|
|
|
1198
1205
|
};
|
|
1199
1206
|
const displayedContentRight = columns.reduce((right, _column, index) => Math.max(right, getColumnX(index) + metrics[index].width), 0);
|
|
1200
1207
|
const trailingBlankStart = displayedContentRight > 0 && displayedContentRight < width ? displayedContentRight : null;
|
|
1201
|
-
const getRowDragOffset = (rowIndex) =>
|
|
1202
|
-
if (!rowDragPreview || rowIndex === rowDragPreview.sourceIndex) return 0;
|
|
1203
|
-
if (rowDragPreview.sourceIndex < rowDragPreview.targetIndex) {
|
|
1204
|
-
return rowIndex > rowDragPreview.sourceIndex && rowIndex <= rowDragPreview.targetIndex ? -rowHeight : 0;
|
|
1205
|
-
}
|
|
1206
|
-
return rowIndex >= rowDragPreview.targetIndex && rowIndex < rowDragPreview.sourceIndex ? rowHeight : 0;
|
|
1207
|
-
};
|
|
1208
|
+
const getRowDragOffset = (rowIndex) => getAnimatedRowDragOffset(rowDragPreview, rowIndex, rowHeight);
|
|
1208
1209
|
const rowBelowDragGap = rowDragPreview ? rowDragPreview.sourceIndex <= rowDragPreview.targetIndex ? rowDragPreview.targetIndex + 1 : rowDragPreview.targetIndex : -1;
|
|
1209
1210
|
if (trailingBlankStart !== null) {
|
|
1210
1211
|
const rowStart = Math.max(0, range.rowStart);
|
|
@@ -2151,6 +2152,24 @@ function TableInner({
|
|
|
2151
2152
|
const [liftedRowPreview, setLiftedRowPreview] = useState6(null);
|
|
2152
2153
|
const [columnDragPreview, setColumnDragPreview] = useState6(null);
|
|
2153
2154
|
const [columnDropTarget, setColumnDropTarget] = useState6(null);
|
|
2155
|
+
useEffect3(() => {
|
|
2156
|
+
if (!rowDragPreview || (rowDragPreview.progress ?? 1) >= 1) return;
|
|
2157
|
+
const sourceIndex = rowDragPreview.sourceIndex;
|
|
2158
|
+
const targetIndex = rowDragPreview.targetIndex;
|
|
2159
|
+
if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
|
|
2160
|
+
setRowDragPreview((current) => current?.sourceIndex === sourceIndex && current.targetIndex === targetIndex ? { ...current, progress: 1 } : current);
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
const startedAt = performance.now();
|
|
2164
|
+
let frame = 0;
|
|
2165
|
+
const animate = (now) => {
|
|
2166
|
+
const progress = Math.min(1, (now - startedAt) / 140);
|
|
2167
|
+
setRowDragPreview((current) => current?.sourceIndex === sourceIndex && current.targetIndex === targetIndex ? { ...current, progress } : current);
|
|
2168
|
+
if (progress < 1) frame = requestAnimationFrame(animate);
|
|
2169
|
+
};
|
|
2170
|
+
frame = requestAnimationFrame(animate);
|
|
2171
|
+
return () => cancelAnimationFrame(frame);
|
|
2172
|
+
}, [rowDragPreview?.sourceIndex, rowDragPreview?.targetIndex]);
|
|
2154
2173
|
useEffect3(() => {
|
|
2155
2174
|
if (!loading) hasCompletedLoadRef.current = true;
|
|
2156
2175
|
}, [loading]);
|
|
@@ -3446,7 +3465,15 @@ function TableInner({
|
|
|
3446
3465
|
if (drag.sourceIndex < targetIndex) targetIndex -= 1;
|
|
3447
3466
|
targetIndex = Math.max(0, Math.min(rows.length - 1, targetIndex));
|
|
3448
3467
|
drag.targetIndex = targetIndex;
|
|
3449
|
-
setRowDragPreview(
|
|
3468
|
+
setRowDragPreview((current) => current?.sourceIndex === drag.sourceIndex && current.targetIndex === targetIndex ? current : {
|
|
3469
|
+
sourceIndex: drag.sourceIndex,
|
|
3470
|
+
targetIndex,
|
|
3471
|
+
fromOffsets: Array.from(
|
|
3472
|
+
{ length: rows.length },
|
|
3473
|
+
(_, rowIndex) => getAnimatedRowDragOffset(current, rowIndex, rowHeight)
|
|
3474
|
+
),
|
|
3475
|
+
progress: 0
|
|
3476
|
+
});
|
|
3450
3477
|
setRowDragGuide(rowTop + (edge === "bottom" ? rowHeight : 0));
|
|
3451
3478
|
}, [bodyTop, hideDragTooltips, locateRow, renderHeight, rowHeight, rows.length, setRowDragGuide]);
|
|
3452
3479
|
const finishRowOrderPointerDrag = useCallback3((event, apply) => {
|
|
@@ -4385,13 +4412,7 @@ function TableInner({
|
|
|
4385
4412
|
top: Math.min(Math.max(0, clientY - root.top), Math.max(0, renderHeight - 68))
|
|
4386
4413
|
});
|
|
4387
4414
|
};
|
|
4388
|
-
const getRowDragOffset = (rowIndex) =>
|
|
4389
|
-
if (!rowDragPreview || rowIndex === rowDragPreview.sourceIndex) return 0;
|
|
4390
|
-
if (rowDragPreview.sourceIndex < rowDragPreview.targetIndex) {
|
|
4391
|
-
return rowIndex > rowDragPreview.sourceIndex && rowIndex <= rowDragPreview.targetIndex ? -rowHeight : 0;
|
|
4392
|
-
}
|
|
4393
|
-
return rowIndex >= rowDragPreview.targetIndex && rowIndex < rowDragPreview.sourceIndex ? rowHeight : 0;
|
|
4394
|
-
};
|
|
4415
|
+
const getRowDragOffset = (rowIndex) => getAnimatedRowDragOffset(rowDragPreview, rowIndex, rowHeight);
|
|
4395
4416
|
const renderAnnotationControls = (targetCells) => {
|
|
4396
4417
|
const getKey = (cell) => `${typeof cell.rowKey}:${String(cell.rowKey)}\0${cell.columnKey}`;
|
|
4397
4418
|
const hasAnnotation = targetCells.some((cell) => cellAnnotations.has(getKey(cell)));
|
|
@@ -4701,7 +4722,7 @@ function TableInner({
|
|
|
4701
4722
|
})();
|
|
4702
4723
|
const selectionOutlineStyle = (() => {
|
|
4703
4724
|
if (!selection || selectionRange) return null;
|
|
4704
|
-
if (
|
|
4725
|
+
if (liftedRowPreview?.sourceIndex === selection.rowIndex) return null;
|
|
4705
4726
|
const row = rows[selection.rowIndex];
|
|
4706
4727
|
const metric = metrics[selection.columnIndex];
|
|
4707
4728
|
const column = columns[selection.columnIndex];
|
|
@@ -4981,7 +5002,12 @@ function TableInner({
|
|
|
4981
5002
|
const draggingSelectedColumn = Boolean(
|
|
4982
5003
|
columnDragPreview && selectedColumnKeySet.has(columns[columnDragPreview.sourceIndex]?.key)
|
|
4983
5004
|
);
|
|
4984
|
-
|
|
5005
|
+
const liftedRow = liftedRowPreview ? rows[liftedRowPreview.sourceIndex] : void 0;
|
|
5006
|
+
const liftedRowKey = liftedRow && liftedRowPreview ? getRowKey(liftedRow, liftedRowPreview.sourceIndex) : void 0;
|
|
5007
|
+
const liftedRowAxisSelected = liftedRowKey !== void 0 && selectedRowKeySet.has(liftedRowKey);
|
|
5008
|
+
const liftedRowCellFocused = liftedRowKey !== void 0 && selection?.rowKey === liftedRowKey;
|
|
5009
|
+
const liftedRowStyle = liftedRow && liftedRowPreview && !liftedRowAxisSelected ? rowStyle?.(liftedRow, liftedRowPreview.sourceIndex) : void 0;
|
|
5010
|
+
return /* @__PURE__ */ jsxs8("div", { ref: rootRef, className: `rvg-root${!hasVerticalBorders ? " is-vertical-borderless" : ""}${horizontalBorderless ? " is-horizontal-borderless" : ""}${frameBorderless ? " is-frame-borderless" : ""}${hasStripedRows ? " is-striped" : ""}${insertBusy ? " is-inserting" : ""}${deleteBusy ? " is-deleting" : ""}${draggingSelectedColumn ? " is-dragging-selected-column" : ""}${rowDragPreview ? " is-row-dragging" : ""} ${loading && !hasCompletedLoadRef.current && !hasCustomLoading ? "is-initial-loading" : ""} ${className}`, style: rootStyle, children: [
|
|
4985
5011
|
/* @__PURE__ */ jsxs8("div", { ref: scrollerRef, className: `rvg-scroller${contextMenu ? " is-context-menu-open" : ""}`, style: { bottom: scrollerBottom }, onScroll: handleScroll, onCopy: handleCopy, onContextMenu: handleContextMenu, tabIndex: 0, role: "grid", "aria-label": ariaLabel, "aria-rowcount": rows.length, "aria-colcount": columns.length, onKeyDown: handleKeyDown, children: [
|
|
4986
5012
|
/* @__PURE__ */ jsx8(
|
|
4987
5013
|
"canvas",
|
|
@@ -5694,24 +5720,31 @@ function TableInner({
|
|
|
5694
5720
|
]
|
|
5695
5721
|
}
|
|
5696
5722
|
),
|
|
5697
|
-
liftedRowPreview &&
|
|
5723
|
+
liftedRowPreview && liftedRow && /* @__PURE__ */ jsx8(
|
|
5698
5724
|
"div",
|
|
5699
5725
|
{
|
|
5700
5726
|
"aria-hidden": "true",
|
|
5701
|
-
className: `rvg-row-drag-preview${
|
|
5702
|
-
style: { top: liftedRowPreview.top, width: viewport.width, height: rowHeight },
|
|
5703
|
-
children: columns.map((column, columnIndex) =>
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5727
|
+
className: `rvg-row-drag-preview${liftedRowAxisSelected ? " is-selected is-axis-selected" : ""}${hasStripedRows && liftedRowPreview.sourceIndex % 2 === 1 ? " is-striped" : ""}`,
|
|
5728
|
+
style: { ...liftedRowStyle, top: liftedRowPreview.top, width: viewport.width, height: rowHeight },
|
|
5729
|
+
children: columns.map((column, columnIndex) => {
|
|
5730
|
+
const value = column.dataIndex === void 0 ? void 0 : liftedRow[column.dataIndex];
|
|
5731
|
+
const cellStyle = liftedRowAxisSelected ? void 0 : column.cellStyle?.(value, liftedRow, liftedRowPreview.sourceIndex);
|
|
5732
|
+
return /* @__PURE__ */ jsx8(
|
|
5733
|
+
"div",
|
|
5734
|
+
{
|
|
5735
|
+
className: `rvg-row-drag-preview-cell${column.renderCell ? " is-custom" : ""}${liftedRowAxisSelected ? " is-axis-selected" : ""}${liftedRowCellFocused && selection?.columnKey === column.key ? " is-selected" : ""}`,
|
|
5736
|
+
style: {
|
|
5737
|
+
...cellStyle,
|
|
5738
|
+
left: getDisplayedColumnLeft(columnIndex),
|
|
5739
|
+
width: metrics[columnIndex]?.width ?? 0,
|
|
5740
|
+
justifyContent: column.align === "right" ? "flex-end" : column.align === "center" ? "center" : "flex-start",
|
|
5741
|
+
color: cellStyle?.color ?? liftedRowStyle?.color
|
|
5742
|
+
},
|
|
5743
|
+
children: column.renderCell ? column.renderCell(value, liftedRow, liftedRowPreview.sourceIndex) : getCellLabel(liftedRowPreview.sourceIndex, columnIndex)
|
|
5710
5744
|
},
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
))
|
|
5745
|
+
`row-preview:${column.key}`
|
|
5746
|
+
);
|
|
5747
|
+
})
|
|
5715
5748
|
}
|
|
5716
5749
|
),
|
|
5717
5750
|
resizeGuideX !== null && /* @__PURE__ */ jsx8(
|