@lensui/lens-table 0.1.27 → 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 +41 -8
- package/dist/index.css +9 -7
- package/dist/index.js +41 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1460,10 +1460,8 @@ function resolveColumnDropIndex(sourceIndex, targetIndex, edge, columnCount) {
|
|
|
1460
1460
|
function resolveColumnDropPlacement(edge) {
|
|
1461
1461
|
return edge === "right" ? "after" : "before";
|
|
1462
1462
|
}
|
|
1463
|
-
function resolveColumnDropHighlightRange(target,
|
|
1464
|
-
|
|
1465
|
-
const previous = cells.find((cell) => cell.endIndex === target.startIndex - 1 && cell.level === target.level && cell.parentKey === target.parentKey);
|
|
1466
|
-
return previous ? { startIndex: previous.startIndex, endIndex: previous.endIndex } : { startIndex: target.startIndex, endIndex: target.endIndex };
|
|
1463
|
+
function resolveColumnDropHighlightRange(target, _edge, _cells) {
|
|
1464
|
+
return { startIndex: target.startIndex, endIndex: target.endIndex };
|
|
1467
1465
|
}
|
|
1468
1466
|
var ANNOTATION_COLORS = ["#f44336", "#ff7a45", "#f5a623", "#f2c94c", "#52c41a", "#13a8a8", "#1677ff", "#597ef7", "#9254de", "#eb2f96"];
|
|
1469
1467
|
var FALLBACK_HEIGHT = 480;
|
|
@@ -1811,7 +1809,6 @@ function TableInner({
|
|
|
1811
1809
|
const contextMenuRef = (0, import_react5.useRef)(null);
|
|
1812
1810
|
const suppressClickRef = (0, import_react5.useRef)(false);
|
|
1813
1811
|
const hasCompletedLoadRef = (0, import_react5.useRef)(!loading);
|
|
1814
|
-
const columnDragPreviewRef = (0, import_react5.useRef)(null);
|
|
1815
1812
|
const validColumnDropRef = (0, import_react5.useRef)(null);
|
|
1816
1813
|
const hoveredHeaderActionRef = (0, import_react5.useRef)(null);
|
|
1817
1814
|
const hoveredRowIndexRef = (0, import_react5.useRef)(null);
|
|
@@ -1845,6 +1842,7 @@ function TableInner({
|
|
|
1845
1842
|
const [editing, setEditing] = (0, import_react5.useState)(null);
|
|
1846
1843
|
const [draft, setDraft] = (0, import_react5.useState)("");
|
|
1847
1844
|
const [rowDragPreview, setRowDragPreview] = (0, import_react5.useState)(null);
|
|
1845
|
+
const [columnDragPreview, setColumnDragPreview] = (0, import_react5.useState)(null);
|
|
1848
1846
|
const [columnDropTarget, setColumnDropTarget] = (0, import_react5.useState)(null);
|
|
1849
1847
|
(0, import_react5.useEffect)(() => {
|
|
1850
1848
|
if (!loading) hasCompletedLoadRef.current = true;
|
|
@@ -3627,7 +3625,7 @@ function TableInner({
|
|
|
3627
3625
|
}, []);
|
|
3628
3626
|
const clearColumnOrderPointerDrag = (0, import_react5.useCallback)((canvas) => {
|
|
3629
3627
|
columnOrderDragRef.current = null;
|
|
3630
|
-
|
|
3628
|
+
setColumnDragPreview(null);
|
|
3631
3629
|
validColumnDropRef.current = null;
|
|
3632
3630
|
setColumnDropTarget(null);
|
|
3633
3631
|
setDragGuide(null);
|
|
@@ -3663,6 +3661,17 @@ function TableInner({
|
|
|
3663
3661
|
}
|
|
3664
3662
|
event.preventDefault();
|
|
3665
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
|
+
});
|
|
3666
3675
|
const hoveredColumnIndex = locateColumn(event.clientX);
|
|
3667
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);
|
|
3668
3677
|
if (!targetCell) {
|
|
@@ -3688,7 +3697,6 @@ function TableInner({
|
|
|
3688
3697
|
columnEdge,
|
|
3689
3698
|
columns.length
|
|
3690
3699
|
);
|
|
3691
|
-
columnDragPreviewRef.current = { sourceIndex: sourceCell.startIndex, targetIndex: destinationIndex };
|
|
3692
3700
|
if (destinationIndex === sourceCell.startIndex) {
|
|
3693
3701
|
validColumnDropRef.current = null;
|
|
3694
3702
|
setColumnDropTarget(null);
|
|
@@ -3711,7 +3719,7 @@ function TableInner({
|
|
|
3711
3719
|
});
|
|
3712
3720
|
setColumnDropTarget(resolveColumnDropHighlightRange(targetCell, columnEdge, compatibleHighlightCells));
|
|
3713
3721
|
setDragGuide(columnEdge === "right" ? targetLeft + targetWidth : targetLeft, headerRowOffsets[sourceCell.level] ?? 0);
|
|
3714
|
-
}, [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]);
|
|
3715
3723
|
const finishColumnOrderPointerDrag = (0, import_react5.useCallback)((event, apply) => {
|
|
3716
3724
|
const drag = columnOrderDragRef.current;
|
|
3717
3725
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
@@ -5223,6 +5231,31 @@ function TableInner({
|
|
|
5223
5231
|
}
|
|
5224
5232
|
),
|
|
5225
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
|
+
),
|
|
5226
5259
|
resizeGuideX !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5227
5260
|
"div",
|
|
5228
5261
|
{
|
package/dist/index.css
CHANGED
|
@@ -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
|
@@ -1430,10 +1430,8 @@ function resolveColumnDropIndex(sourceIndex, targetIndex, edge, columnCount) {
|
|
|
1430
1430
|
function resolveColumnDropPlacement(edge) {
|
|
1431
1431
|
return edge === "right" ? "after" : "before";
|
|
1432
1432
|
}
|
|
1433
|
-
function resolveColumnDropHighlightRange(target,
|
|
1434
|
-
|
|
1435
|
-
const previous = cells.find((cell) => cell.endIndex === target.startIndex - 1 && cell.level === target.level && cell.parentKey === target.parentKey);
|
|
1436
|
-
return previous ? { startIndex: previous.startIndex, endIndex: previous.endIndex } : { startIndex: target.startIndex, endIndex: target.endIndex };
|
|
1433
|
+
function resolveColumnDropHighlightRange(target, _edge, _cells) {
|
|
1434
|
+
return { startIndex: target.startIndex, endIndex: target.endIndex };
|
|
1437
1435
|
}
|
|
1438
1436
|
var ANNOTATION_COLORS = ["#f44336", "#ff7a45", "#f5a623", "#f2c94c", "#52c41a", "#13a8a8", "#1677ff", "#597ef7", "#9254de", "#eb2f96"];
|
|
1439
1437
|
var FALLBACK_HEIGHT = 480;
|
|
@@ -1781,7 +1779,6 @@ function TableInner({
|
|
|
1781
1779
|
const contextMenuRef = useRef2(null);
|
|
1782
1780
|
const suppressClickRef = useRef2(false);
|
|
1783
1781
|
const hasCompletedLoadRef = useRef2(!loading);
|
|
1784
|
-
const columnDragPreviewRef = useRef2(null);
|
|
1785
1782
|
const validColumnDropRef = useRef2(null);
|
|
1786
1783
|
const hoveredHeaderActionRef = useRef2(null);
|
|
1787
1784
|
const hoveredRowIndexRef = useRef2(null);
|
|
@@ -1815,6 +1812,7 @@ function TableInner({
|
|
|
1815
1812
|
const [editing, setEditing] = useState4(null);
|
|
1816
1813
|
const [draft, setDraft] = useState4("");
|
|
1817
1814
|
const [rowDragPreview, setRowDragPreview] = useState4(null);
|
|
1815
|
+
const [columnDragPreview, setColumnDragPreview] = useState4(null);
|
|
1818
1816
|
const [columnDropTarget, setColumnDropTarget] = useState4(null);
|
|
1819
1817
|
useEffect2(() => {
|
|
1820
1818
|
if (!loading) hasCompletedLoadRef.current = true;
|
|
@@ -3597,7 +3595,7 @@ function TableInner({
|
|
|
3597
3595
|
}, []);
|
|
3598
3596
|
const clearColumnOrderPointerDrag = useCallback2((canvas) => {
|
|
3599
3597
|
columnOrderDragRef.current = null;
|
|
3600
|
-
|
|
3598
|
+
setColumnDragPreview(null);
|
|
3601
3599
|
validColumnDropRef.current = null;
|
|
3602
3600
|
setColumnDropTarget(null);
|
|
3603
3601
|
setDragGuide(null);
|
|
@@ -3633,6 +3631,17 @@ function TableInner({
|
|
|
3633
3631
|
}
|
|
3634
3632
|
event.preventDefault();
|
|
3635
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
|
+
});
|
|
3636
3645
|
const hoveredColumnIndex = locateColumn(event.clientX);
|
|
3637
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);
|
|
3638
3647
|
if (!targetCell) {
|
|
@@ -3658,7 +3667,6 @@ function TableInner({
|
|
|
3658
3667
|
columnEdge,
|
|
3659
3668
|
columns.length
|
|
3660
3669
|
);
|
|
3661
|
-
columnDragPreviewRef.current = { sourceIndex: sourceCell.startIndex, targetIndex: destinationIndex };
|
|
3662
3670
|
if (destinationIndex === sourceCell.startIndex) {
|
|
3663
3671
|
validColumnDropRef.current = null;
|
|
3664
3672
|
setColumnDropTarget(null);
|
|
@@ -3681,7 +3689,7 @@ function TableInner({
|
|
|
3681
3689
|
});
|
|
3682
3690
|
setColumnDropTarget(resolveColumnDropHighlightRange(targetCell, columnEdge, compatibleHighlightCells));
|
|
3683
3691
|
setDragGuide(columnEdge === "right" ? targetLeft + targetWidth : targetLeft, headerRowOffsets[sourceCell.level] ?? 0);
|
|
3684
|
-
}, [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]);
|
|
3685
3693
|
const finishColumnOrderPointerDrag = useCallback2((event, apply) => {
|
|
3686
3694
|
const drag = columnOrderDragRef.current;
|
|
3687
3695
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
@@ -5193,6 +5201,31 @@ function TableInner({
|
|
|
5193
5201
|
}
|
|
5194
5202
|
),
|
|
5195
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
|
+
),
|
|
5196
5229
|
resizeGuideX !== null && /* @__PURE__ */ jsx7(
|
|
5197
5230
|
"div",
|
|
5198
5231
|
{
|