@lensui/lens-table 0.1.88 → 0.1.89
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 +53 -4
- package/dist/index.css +4 -0
- package/dist/index.js +53 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1183,6 +1183,34 @@ function getAnimatedRowDragOffset(preview, rowIndex, rowHeight) {
|
|
|
1183
1183
|
const progress = Math.max(0, Math.min(1, preview.progress ?? 1));
|
|
1184
1184
|
return startOffset + (targetOffset - startOffset) * progress;
|
|
1185
1185
|
}
|
|
1186
|
+
function getAnimatedRowDragGapRanges(preview, rowCount, rowHeight, bodyTop, scrollTop) {
|
|
1187
|
+
if (!preview || rowCount <= 0 || rowHeight <= 0) return [];
|
|
1188
|
+
const affectedIndices = [preview.sourceIndex, preview.targetIndex];
|
|
1189
|
+
preview.fromOffsets?.forEach((offset, rowIndex) => {
|
|
1190
|
+
if (Math.abs(offset) > 0.01) affectedIndices.push(rowIndex);
|
|
1191
|
+
});
|
|
1192
|
+
const startIndex = Math.max(0, Math.min(...affectedIndices));
|
|
1193
|
+
const endIndex = Math.min(rowCount - 1, Math.max(...affectedIndices));
|
|
1194
|
+
const regionTop = bodyTop + startIndex * rowHeight - scrollTop;
|
|
1195
|
+
const regionBottom = bodyTop + (endIndex + 1) * rowHeight - scrollTop;
|
|
1196
|
+
const occupied = [];
|
|
1197
|
+
for (let rowIndex = startIndex; rowIndex <= endIndex; rowIndex += 1) {
|
|
1198
|
+
if (rowIndex === preview.sourceIndex) continue;
|
|
1199
|
+
const top = bodyTop + rowIndex * rowHeight - scrollTop + getAnimatedRowDragOffset(preview, rowIndex, rowHeight);
|
|
1200
|
+
occupied.push({ top, bottom: top + rowHeight });
|
|
1201
|
+
}
|
|
1202
|
+
occupied.sort((left, right) => left.top - right.top);
|
|
1203
|
+
const gaps = [];
|
|
1204
|
+
let cursor = regionTop;
|
|
1205
|
+
for (const interval of occupied) {
|
|
1206
|
+
const top = Math.max(regionTop, interval.top);
|
|
1207
|
+
const bottom = Math.min(regionBottom, interval.bottom);
|
|
1208
|
+
if (top > cursor + 0.01) gaps.push({ top: cursor, bottom: top });
|
|
1209
|
+
cursor = Math.max(cursor, bottom);
|
|
1210
|
+
}
|
|
1211
|
+
if (cursor < regionBottom - 0.01) gaps.push({ top: cursor, bottom: regionBottom });
|
|
1212
|
+
return gaps;
|
|
1213
|
+
}
|
|
1186
1214
|
function paintGrid(options) {
|
|
1187
1215
|
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;
|
|
1188
1216
|
const headerLeafTop = options.headerLeafTop ?? 0;
|
|
@@ -1344,7 +1372,7 @@ function paintGrid(options) {
|
|
|
1344
1372
|
if (!verticalBorderless && !(frameBorderless && columnIndex + colSpan >= columns.length)) {
|
|
1345
1373
|
ctx.fillRect(x + cellWidth - 1, y, 1, cellHeight);
|
|
1346
1374
|
}
|
|
1347
|
-
if (rowIndex === rowBelowDragGap) ctx.fillRect(x, y, cellWidth, 1);
|
|
1375
|
+
if (!horizontalBorderless && rowIndex === rowBelowDragGap) ctx.fillRect(x, y, cellWidth, 1);
|
|
1348
1376
|
if (!horizontalBorderless && (!options.suppressLastRowBottomBorder || rowIndex !== rows.length - 1)) {
|
|
1349
1377
|
ctx.fillRect(x, y + cellHeight - 1, cellWidth, 1);
|
|
1350
1378
|
}
|
|
@@ -1478,6 +1506,26 @@ function paintGrid(options) {
|
|
|
1478
1506
|
paintBodyColumns("scroll");
|
|
1479
1507
|
paintBodyColumns("left");
|
|
1480
1508
|
paintBodyColumns("right");
|
|
1509
|
+
if (rowDragPreview && !verticalBorderless) {
|
|
1510
|
+
const gapRanges = getAnimatedRowDragGapRanges(
|
|
1511
|
+
rowDragPreview,
|
|
1512
|
+
rows.length,
|
|
1513
|
+
rowHeight,
|
|
1514
|
+
bodyTop,
|
|
1515
|
+
scrollTop
|
|
1516
|
+
);
|
|
1517
|
+
ctx.fillStyle = colors.grid;
|
|
1518
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex += 1) {
|
|
1519
|
+
if (frameBorderless && columnIndex === columns.length - 1) continue;
|
|
1520
|
+
const x = getColumnX(columnIndex) + metrics[columnIndex].width - 1;
|
|
1521
|
+
if (columns[columnIndex].fixed === void 0 && (x < leftFixedWidth || x >= rightFixedLeft)) continue;
|
|
1522
|
+
for (const gap of gapRanges) {
|
|
1523
|
+
const top = Math.max(bodyTop, gap.top);
|
|
1524
|
+
const bottom = Math.min(height, gap.bottom);
|
|
1525
|
+
if (bottom > top) ctx.fillRect(x, top, 1, bottom - top);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1481
1529
|
if (extendVerticalGridLines) {
|
|
1482
1530
|
const extensionTop = Math.max(bodyTop, Math.min(height, bodyTop + rows.length * rowHeight - scrollTop));
|
|
1483
1531
|
const extensionHeight = Math.max(0, height - extensionTop);
|
|
@@ -3446,9 +3494,10 @@ function TableInner({
|
|
|
3446
3494
|
const setRowDragGuide = (0, import_react8.useCallback)((y) => {
|
|
3447
3495
|
const guide = rowDragGuideRef.current;
|
|
3448
3496
|
if (!guide) return;
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3497
|
+
const visibleY = horizontalBorderless ? null : y;
|
|
3498
|
+
guide.style.display = visibleY === null ? "none" : "block";
|
|
3499
|
+
if (visibleY !== null) guide.style.transform = `translateY(${Math.round(visibleY)}px)`;
|
|
3500
|
+
}, [horizontalBorderless]);
|
|
3452
3501
|
const locateRow = (0, import_react8.useCallback)((clientY) => {
|
|
3453
3502
|
const canvas = canvasRef.current;
|
|
3454
3503
|
if (!canvas) return -1;
|
package/dist/index.css
CHANGED
|
@@ -1653,6 +1653,10 @@
|
|
|
1653
1653
|
pointer-events: none;
|
|
1654
1654
|
transform: translateY(-1px);
|
|
1655
1655
|
}
|
|
1656
|
+
.rvg-root.is-horizontal-borderless .rvg-row-drag-preview {
|
|
1657
|
+
border-top: 0;
|
|
1658
|
+
border-bottom: 0;
|
|
1659
|
+
}
|
|
1656
1660
|
.rvg-row-drag-preview.is-striped {
|
|
1657
1661
|
background: var(--rvg-color-stripe);
|
|
1658
1662
|
}
|
package/dist/index.js
CHANGED
|
@@ -1153,6 +1153,34 @@ function getAnimatedRowDragOffset(preview, rowIndex, rowHeight) {
|
|
|
1153
1153
|
const progress = Math.max(0, Math.min(1, preview.progress ?? 1));
|
|
1154
1154
|
return startOffset + (targetOffset - startOffset) * progress;
|
|
1155
1155
|
}
|
|
1156
|
+
function getAnimatedRowDragGapRanges(preview, rowCount, rowHeight, bodyTop, scrollTop) {
|
|
1157
|
+
if (!preview || rowCount <= 0 || rowHeight <= 0) return [];
|
|
1158
|
+
const affectedIndices = [preview.sourceIndex, preview.targetIndex];
|
|
1159
|
+
preview.fromOffsets?.forEach((offset, rowIndex) => {
|
|
1160
|
+
if (Math.abs(offset) > 0.01) affectedIndices.push(rowIndex);
|
|
1161
|
+
});
|
|
1162
|
+
const startIndex = Math.max(0, Math.min(...affectedIndices));
|
|
1163
|
+
const endIndex = Math.min(rowCount - 1, Math.max(...affectedIndices));
|
|
1164
|
+
const regionTop = bodyTop + startIndex * rowHeight - scrollTop;
|
|
1165
|
+
const regionBottom = bodyTop + (endIndex + 1) * rowHeight - scrollTop;
|
|
1166
|
+
const occupied = [];
|
|
1167
|
+
for (let rowIndex = startIndex; rowIndex <= endIndex; rowIndex += 1) {
|
|
1168
|
+
if (rowIndex === preview.sourceIndex) continue;
|
|
1169
|
+
const top = bodyTop + rowIndex * rowHeight - scrollTop + getAnimatedRowDragOffset(preview, rowIndex, rowHeight);
|
|
1170
|
+
occupied.push({ top, bottom: top + rowHeight });
|
|
1171
|
+
}
|
|
1172
|
+
occupied.sort((left, right) => left.top - right.top);
|
|
1173
|
+
const gaps = [];
|
|
1174
|
+
let cursor = regionTop;
|
|
1175
|
+
for (const interval of occupied) {
|
|
1176
|
+
const top = Math.max(regionTop, interval.top);
|
|
1177
|
+
const bottom = Math.min(regionBottom, interval.bottom);
|
|
1178
|
+
if (top > cursor + 0.01) gaps.push({ top: cursor, bottom: top });
|
|
1179
|
+
cursor = Math.max(cursor, bottom);
|
|
1180
|
+
}
|
|
1181
|
+
if (cursor < regionBottom - 0.01) gaps.push({ top: cursor, bottom: regionBottom });
|
|
1182
|
+
return gaps;
|
|
1183
|
+
}
|
|
1156
1184
|
function paintGrid(options) {
|
|
1157
1185
|
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;
|
|
1158
1186
|
const headerLeafTop = options.headerLeafTop ?? 0;
|
|
@@ -1314,7 +1342,7 @@ function paintGrid(options) {
|
|
|
1314
1342
|
if (!verticalBorderless && !(frameBorderless && columnIndex + colSpan >= columns.length)) {
|
|
1315
1343
|
ctx.fillRect(x + cellWidth - 1, y, 1, cellHeight);
|
|
1316
1344
|
}
|
|
1317
|
-
if (rowIndex === rowBelowDragGap) ctx.fillRect(x, y, cellWidth, 1);
|
|
1345
|
+
if (!horizontalBorderless && rowIndex === rowBelowDragGap) ctx.fillRect(x, y, cellWidth, 1);
|
|
1318
1346
|
if (!horizontalBorderless && (!options.suppressLastRowBottomBorder || rowIndex !== rows.length - 1)) {
|
|
1319
1347
|
ctx.fillRect(x, y + cellHeight - 1, cellWidth, 1);
|
|
1320
1348
|
}
|
|
@@ -1448,6 +1476,26 @@ function paintGrid(options) {
|
|
|
1448
1476
|
paintBodyColumns("scroll");
|
|
1449
1477
|
paintBodyColumns("left");
|
|
1450
1478
|
paintBodyColumns("right");
|
|
1479
|
+
if (rowDragPreview && !verticalBorderless) {
|
|
1480
|
+
const gapRanges = getAnimatedRowDragGapRanges(
|
|
1481
|
+
rowDragPreview,
|
|
1482
|
+
rows.length,
|
|
1483
|
+
rowHeight,
|
|
1484
|
+
bodyTop,
|
|
1485
|
+
scrollTop
|
|
1486
|
+
);
|
|
1487
|
+
ctx.fillStyle = colors.grid;
|
|
1488
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex += 1) {
|
|
1489
|
+
if (frameBorderless && columnIndex === columns.length - 1) continue;
|
|
1490
|
+
const x = getColumnX(columnIndex) + metrics[columnIndex].width - 1;
|
|
1491
|
+
if (columns[columnIndex].fixed === void 0 && (x < leftFixedWidth || x >= rightFixedLeft)) continue;
|
|
1492
|
+
for (const gap of gapRanges) {
|
|
1493
|
+
const top = Math.max(bodyTop, gap.top);
|
|
1494
|
+
const bottom = Math.min(height, gap.bottom);
|
|
1495
|
+
if (bottom > top) ctx.fillRect(x, top, 1, bottom - top);
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1451
1499
|
if (extendVerticalGridLines) {
|
|
1452
1500
|
const extensionTop = Math.max(bodyTop, Math.min(height, bodyTop + rows.length * rowHeight - scrollTop));
|
|
1453
1501
|
const extensionHeight = Math.max(0, height - extensionTop);
|
|
@@ -3416,9 +3464,10 @@ function TableInner({
|
|
|
3416
3464
|
const setRowDragGuide = useCallback3((y) => {
|
|
3417
3465
|
const guide = rowDragGuideRef.current;
|
|
3418
3466
|
if (!guide) return;
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3467
|
+
const visibleY = horizontalBorderless ? null : y;
|
|
3468
|
+
guide.style.display = visibleY === null ? "none" : "block";
|
|
3469
|
+
if (visibleY !== null) guide.style.transform = `translateY(${Math.round(visibleY)}px)`;
|
|
3470
|
+
}, [horizontalBorderless]);
|
|
3422
3471
|
const locateRow = useCallback3((clientY) => {
|
|
3423
3472
|
const canvas = canvasRef.current;
|
|
3424
3473
|
if (!canvas) return -1;
|