@lensui/lens-table 0.1.28 → 0.1.29
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 +37 -26
- package/dist/index.css +8 -5
- package/dist/index.js +37 -26
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3663,13 +3663,23 @@ function TableInner({
|
|
|
3663
3663
|
const sourceCell = drag.sourceCell;
|
|
3664
3664
|
const rootRect = rootRef.current?.getBoundingClientRect() ?? event.currentTarget.getBoundingClientRect();
|
|
3665
3665
|
const sourceWidth = metrics[sourceCell.startIndex]?.width ?? 160;
|
|
3666
|
-
const
|
|
3667
|
-
const
|
|
3668
|
-
const
|
|
3666
|
+
const sourceColumn = columns[sourceCell.startIndex];
|
|
3667
|
+
const previewContext = event.currentTarget.getContext("2d");
|
|
3668
|
+
const previewStyles = rootRef.current ? getComputedStyle(rootRef.current) : null;
|
|
3669
|
+
const previewFontSize = previewStyles ? readThemePixel(previewStyles, "--rvg-font-size-body", 13) : 13;
|
|
3670
|
+
if (previewContext) previewContext.font = `${previewFontSize}px Inter, ui-sans-serif, system-ui, sans-serif`;
|
|
3671
|
+
const measurePreviewText = (value) => previewContext?.measureText(value).width ?? value.length * previewFontSize * 0.58;
|
|
3672
|
+
const previewContentWidth = Math.max(
|
|
3673
|
+
measurePreviewText(sourceColumn?.title ?? ""),
|
|
3674
|
+
...rows.slice(0, 100).map((_row, rowIndex) => measurePreviewText(getCellLabel(rowIndex, sourceCell.startIndex)))
|
|
3675
|
+
) + 24;
|
|
3676
|
+
const previewWidth = Math.min(
|
|
3677
|
+
Math.max(sourceWidth, Math.ceil(previewContentWidth)),
|
|
3678
|
+
Math.max(60, Math.min(360, viewport.width - 16))
|
|
3679
|
+
);
|
|
3669
3680
|
setColumnDragPreview({
|
|
3670
3681
|
sourceIndex: sourceCell.startIndex,
|
|
3671
|
-
left: Math.max(4, Math.min(viewport.width - previewWidth - 4, event.clientX - rootRect.left
|
|
3672
|
-
top: Math.max(4, Math.min(viewport.height - previewHeight - 4, event.clientY - rootRect.top + 12)),
|
|
3682
|
+
left: Math.max(4, Math.min(viewport.width - previewWidth - 4, event.clientX - rootRect.left - previewWidth / 2)),
|
|
3673
3683
|
width: previewWidth
|
|
3674
3684
|
});
|
|
3675
3685
|
const hoveredColumnIndex = locateColumn(event.clientX);
|
|
@@ -3697,10 +3707,14 @@ function TableInner({
|
|
|
3697
3707
|
columnEdge,
|
|
3698
3708
|
columns.length
|
|
3699
3709
|
);
|
|
3710
|
+
const compatibleHighlightCells = headerCells.filter((cell) => {
|
|
3711
|
+
const cellColumn = columns[cell.startIndex];
|
|
3712
|
+
return cellColumn && !cellColumn.rowSelection && !cellColumn.rowDragHandle && !cellColumn.rowNumber && cellColumn.fixed === targetColumn.fixed;
|
|
3713
|
+
});
|
|
3714
|
+
setColumnDropTarget(resolveColumnDropHighlightRange(targetCell, columnEdge, compatibleHighlightCells));
|
|
3715
|
+
setDragGuide(columnEdge === "right" ? targetLeft + targetWidth : targetLeft, headerRowOffsets[sourceCell.level] ?? 0);
|
|
3700
3716
|
if (destinationIndex === sourceCell.startIndex) {
|
|
3701
3717
|
validColumnDropRef.current = null;
|
|
3702
|
-
setColumnDropTarget(null);
|
|
3703
|
-
setDragGuide(null);
|
|
3704
3718
|
return;
|
|
3705
3719
|
}
|
|
3706
3720
|
validColumnDropRef.current = {
|
|
@@ -3713,13 +3727,7 @@ function TableInner({
|
|
|
3713
3727
|
fixed: targetColumn.fixed,
|
|
3714
3728
|
columnEdge
|
|
3715
3729
|
};
|
|
3716
|
-
|
|
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));
|
|
3721
|
-
setDragGuide(columnEdge === "right" ? targetLeft + targetWidth : targetLeft, headerRowOffsets[sourceCell.level] ?? 0);
|
|
3722
|
-
}, [columns, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerLeafHeight, headerRowOffsets, hideDragTooltips, locateColumn, locateHeaderCell, metrics, rowHeight, rows.length, setDragGuide, viewport.height, viewport.width]);
|
|
3730
|
+
}, [columns, getCellLabel, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerRowOffsets, hideDragTooltips, locateColumn, locateHeaderCell, metrics, rows, setDragGuide, viewport.width]);
|
|
3723
3731
|
const finishColumnOrderPointerDrag = (0, import_react5.useCallback)((event, apply) => {
|
|
3724
3732
|
const drag = columnOrderDragRef.current;
|
|
3725
3733
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
@@ -5238,21 +5246,24 @@ function TableInner({
|
|
|
5238
5246
|
className: "rvg-column-drag-preview",
|
|
5239
5247
|
style: {
|
|
5240
5248
|
left: columnDragPreview.left,
|
|
5241
|
-
top:
|
|
5249
|
+
top: 0,
|
|
5242
5250
|
width: columnDragPreview.width,
|
|
5243
|
-
height:
|
|
5251
|
+
height: renderHeight
|
|
5244
5252
|
},
|
|
5245
5253
|
children: [
|
|
5246
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rvg-column-drag-preview-header", style: { top:
|
|
5247
|
-
rows.slice(
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5254
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rvg-column-drag-preview-header", style: { top: headerLeafTop, height: headerLeafHeight }, children: columns[columnDragPreview.sourceIndex]?.renderHeader?.(columns[columnDragPreview.sourceIndex]) ?? columns[columnDragPreview.sourceIndex]?.title }),
|
|
5255
|
+
rows.slice(domRange.rowStart, domRange.rowEnd).map((_row, visibleRowOffset) => {
|
|
5256
|
+
const rowIndex = domRange.rowStart + visibleRowOffset;
|
|
5257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5258
|
+
"div",
|
|
5259
|
+
{
|
|
5260
|
+
className: `rvg-column-drag-preview-cell${hasStripedRows && rowIndex % 2 === 1 ? " is-striped" : ""}`,
|
|
5261
|
+
style: { top: bodyTop + rowIndex * rowHeight - scrollRef.current.top, height: rowHeight },
|
|
5262
|
+
children: getCellLabel(rowIndex, columnDragPreview.sourceIndex)
|
|
5263
|
+
},
|
|
5264
|
+
`column-preview:${String(getRowKey(rows[rowIndex], rowIndex))}`
|
|
5265
|
+
);
|
|
5266
|
+
})
|
|
5256
5267
|
]
|
|
5257
5268
|
}
|
|
5258
5269
|
),
|
package/dist/index.css
CHANGED
|
@@ -1511,10 +1511,10 @@
|
|
|
1511
1511
|
position: absolute;
|
|
1512
1512
|
z-index: 11;
|
|
1513
1513
|
overflow: hidden;
|
|
1514
|
-
border: 1px solid color-mix(in srgb, var(--rvg-color-primary)
|
|
1515
|
-
background:
|
|
1516
|
-
box-shadow: 0
|
|
1517
|
-
opacity: 0.
|
|
1514
|
+
border: 1px solid color-mix(in srgb, var(--rvg-color-primary) 38%, var(--rvg-color-grid));
|
|
1515
|
+
background: var(--rvg-color-bg);
|
|
1516
|
+
box-shadow: 0 6px 18px rgba(50, 91, 136, 0.18);
|
|
1517
|
+
opacity: 0.94;
|
|
1518
1518
|
pointer-events: none;
|
|
1519
1519
|
box-sizing: border-box;
|
|
1520
1520
|
}
|
|
@@ -1539,10 +1539,13 @@
|
|
|
1539
1539
|
box-sizing: border-box;
|
|
1540
1540
|
}
|
|
1541
1541
|
.rvg-column-drag-preview-header {
|
|
1542
|
-
background:
|
|
1542
|
+
background: var(--rvg-color-header-bg);
|
|
1543
1543
|
color: var(--rvg-color-text);
|
|
1544
1544
|
font-weight: 600;
|
|
1545
1545
|
}
|
|
1546
|
+
.rvg-column-drag-preview-cell.is-striped {
|
|
1547
|
+
background: var(--rvg-color-stripe);
|
|
1548
|
+
}
|
|
1546
1549
|
.rvg-column-drag-preview-header .rvg-preview-header-icon {
|
|
1547
1550
|
position: absolute;
|
|
1548
1551
|
top: 50%;
|
package/dist/index.js
CHANGED
|
@@ -3633,13 +3633,23 @@ function TableInner({
|
|
|
3633
3633
|
const sourceCell = drag.sourceCell;
|
|
3634
3634
|
const rootRect = rootRef.current?.getBoundingClientRect() ?? event.currentTarget.getBoundingClientRect();
|
|
3635
3635
|
const sourceWidth = metrics[sourceCell.startIndex]?.width ?? 160;
|
|
3636
|
-
const
|
|
3637
|
-
const
|
|
3638
|
-
const
|
|
3636
|
+
const sourceColumn = columns[sourceCell.startIndex];
|
|
3637
|
+
const previewContext = event.currentTarget.getContext("2d");
|
|
3638
|
+
const previewStyles = rootRef.current ? getComputedStyle(rootRef.current) : null;
|
|
3639
|
+
const previewFontSize = previewStyles ? readThemePixel(previewStyles, "--rvg-font-size-body", 13) : 13;
|
|
3640
|
+
if (previewContext) previewContext.font = `${previewFontSize}px Inter, ui-sans-serif, system-ui, sans-serif`;
|
|
3641
|
+
const measurePreviewText = (value) => previewContext?.measureText(value).width ?? value.length * previewFontSize * 0.58;
|
|
3642
|
+
const previewContentWidth = Math.max(
|
|
3643
|
+
measurePreviewText(sourceColumn?.title ?? ""),
|
|
3644
|
+
...rows.slice(0, 100).map((_row, rowIndex) => measurePreviewText(getCellLabel(rowIndex, sourceCell.startIndex)))
|
|
3645
|
+
) + 24;
|
|
3646
|
+
const previewWidth = Math.min(
|
|
3647
|
+
Math.max(sourceWidth, Math.ceil(previewContentWidth)),
|
|
3648
|
+
Math.max(60, Math.min(360, viewport.width - 16))
|
|
3649
|
+
);
|
|
3639
3650
|
setColumnDragPreview({
|
|
3640
3651
|
sourceIndex: sourceCell.startIndex,
|
|
3641
|
-
left: Math.max(4, Math.min(viewport.width - previewWidth - 4, event.clientX - rootRect.left
|
|
3642
|
-
top: Math.max(4, Math.min(viewport.height - previewHeight - 4, event.clientY - rootRect.top + 12)),
|
|
3652
|
+
left: Math.max(4, Math.min(viewport.width - previewWidth - 4, event.clientX - rootRect.left - previewWidth / 2)),
|
|
3643
3653
|
width: previewWidth
|
|
3644
3654
|
});
|
|
3645
3655
|
const hoveredColumnIndex = locateColumn(event.clientX);
|
|
@@ -3667,10 +3677,14 @@ function TableInner({
|
|
|
3667
3677
|
columnEdge,
|
|
3668
3678
|
columns.length
|
|
3669
3679
|
);
|
|
3680
|
+
const compatibleHighlightCells = headerCells.filter((cell) => {
|
|
3681
|
+
const cellColumn = columns[cell.startIndex];
|
|
3682
|
+
return cellColumn && !cellColumn.rowSelection && !cellColumn.rowDragHandle && !cellColumn.rowNumber && cellColumn.fixed === targetColumn.fixed;
|
|
3683
|
+
});
|
|
3684
|
+
setColumnDropTarget(resolveColumnDropHighlightRange(targetCell, columnEdge, compatibleHighlightCells));
|
|
3685
|
+
setDragGuide(columnEdge === "right" ? targetLeft + targetWidth : targetLeft, headerRowOffsets[sourceCell.level] ?? 0);
|
|
3670
3686
|
if (destinationIndex === sourceCell.startIndex) {
|
|
3671
3687
|
validColumnDropRef.current = null;
|
|
3672
|
-
setColumnDropTarget(null);
|
|
3673
|
-
setDragGuide(null);
|
|
3674
3688
|
return;
|
|
3675
3689
|
}
|
|
3676
3690
|
validColumnDropRef.current = {
|
|
@@ -3683,13 +3697,7 @@ function TableInner({
|
|
|
3683
3697
|
fixed: targetColumn.fixed,
|
|
3684
3698
|
columnEdge
|
|
3685
3699
|
};
|
|
3686
|
-
|
|
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));
|
|
3691
|
-
setDragGuide(columnEdge === "right" ? targetLeft + targetWidth : targetLeft, headerRowOffsets[sourceCell.level] ?? 0);
|
|
3692
|
-
}, [columns, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerLeafHeight, headerRowOffsets, hideDragTooltips, locateColumn, locateHeaderCell, metrics, rowHeight, rows.length, setDragGuide, viewport.height, viewport.width]);
|
|
3700
|
+
}, [columns, getCellLabel, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerRowOffsets, hideDragTooltips, locateColumn, locateHeaderCell, metrics, rows, setDragGuide, viewport.width]);
|
|
3693
3701
|
const finishColumnOrderPointerDrag = useCallback2((event, apply) => {
|
|
3694
3702
|
const drag = columnOrderDragRef.current;
|
|
3695
3703
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
@@ -5208,21 +5216,24 @@ function TableInner({
|
|
|
5208
5216
|
className: "rvg-column-drag-preview",
|
|
5209
5217
|
style: {
|
|
5210
5218
|
left: columnDragPreview.left,
|
|
5211
|
-
top:
|
|
5219
|
+
top: 0,
|
|
5212
5220
|
width: columnDragPreview.width,
|
|
5213
|
-
height:
|
|
5221
|
+
height: renderHeight
|
|
5214
5222
|
},
|
|
5215
5223
|
children: [
|
|
5216
|
-
/* @__PURE__ */ jsx7("div", { className: "rvg-column-drag-preview-header", style: { top:
|
|
5217
|
-
rows.slice(
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5224
|
+
/* @__PURE__ */ jsx7("div", { className: "rvg-column-drag-preview-header", style: { top: headerLeafTop, height: headerLeafHeight }, children: columns[columnDragPreview.sourceIndex]?.renderHeader?.(columns[columnDragPreview.sourceIndex]) ?? columns[columnDragPreview.sourceIndex]?.title }),
|
|
5225
|
+
rows.slice(domRange.rowStart, domRange.rowEnd).map((_row, visibleRowOffset) => {
|
|
5226
|
+
const rowIndex = domRange.rowStart + visibleRowOffset;
|
|
5227
|
+
return /* @__PURE__ */ jsx7(
|
|
5228
|
+
"div",
|
|
5229
|
+
{
|
|
5230
|
+
className: `rvg-column-drag-preview-cell${hasStripedRows && rowIndex % 2 === 1 ? " is-striped" : ""}`,
|
|
5231
|
+
style: { top: bodyTop + rowIndex * rowHeight - scrollRef.current.top, height: rowHeight },
|
|
5232
|
+
children: getCellLabel(rowIndex, columnDragPreview.sourceIndex)
|
|
5233
|
+
},
|
|
5234
|
+
`column-preview:${String(getRowKey(rows[rowIndex], rowIndex))}`
|
|
5235
|
+
);
|
|
5236
|
+
})
|
|
5226
5237
|
]
|
|
5227
5238
|
}
|
|
5228
5239
|
),
|