@lensui/lens-table 0.1.78 → 0.1.79

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 CHANGED
@@ -907,7 +907,11 @@ function TextEditor({ value, type, min, max, integer = false, style, labels, onC
907
907
  if (type === "number" && integer && next !== "" && !/^-?\d+$/.test(next)) return;
908
908
  onChange(next);
909
909
  },
910
- onBlur: commitValue,
910
+ onBlur: (event) => {
911
+ const nextTarget = event.relatedTarget;
912
+ if (nextTarget instanceof Element && nextTarget.closest("[data-rvg-preserve-edit]")) return;
913
+ commitValue();
914
+ },
911
915
  onKeyDown: handleKeyDown
912
916
  }
913
917
  ),
@@ -1302,7 +1306,7 @@ function paintGrid(options) {
1302
1306
  ctx.fillStyle = isAxisSelected ? getAxisSelectionFill(rowIndex, column.key) : colors.columnDropTargetFill;
1303
1307
  ctx.fillRect(x, y, cellWidth, cellHeight);
1304
1308
  }
1305
- ctx.fillStyle = selectedRowKeys.has(rowKey) ? getAxisSelectionFill(rowIndex, column.key) : colors.grid;
1309
+ ctx.fillStyle = selectedRowKeys.has(rowKey) ? getAxisSelectionFill(rowIndex, column.key) : isRangeCell ? colors.selectionFill : colors.grid;
1306
1310
  if (!verticalBorderless && !(frameBorderless && columnIndex + colSpan >= columns.length)) {
1307
1311
  ctx.fillRect(x + cellWidth - 1, y, 1, cellHeight);
1308
1312
  }
@@ -2127,6 +2131,7 @@ function TableInner({
2127
2131
  const [editing, setEditing] = (0, import_react8.useState)(null);
2128
2132
  const [draft, setDraft] = (0, import_react8.useState)("");
2129
2133
  const [rowDragPreview, setRowDragPreview] = (0, import_react8.useState)(null);
2134
+ const [liftedRowPreview, setLiftedRowPreview] = (0, import_react8.useState)(null);
2130
2135
  const [columnDragPreview, setColumnDragPreview] = (0, import_react8.useState)(null);
2131
2136
  const [columnDropTarget, setColumnDropTarget] = (0, import_react8.useState)(null);
2132
2137
  (0, import_react8.useEffect)(() => {
@@ -3399,24 +3404,29 @@ function TableInner({
3399
3404
  event.currentTarget.style.cursor = "move";
3400
3405
  }
3401
3406
  event.preventDefault();
3407
+ const canvasTop = event.currentTarget.getBoundingClientRect().top;
3408
+ setLiftedRowPreview({
3409
+ sourceIndex: drag.sourceIndex,
3410
+ top: Math.max(bodyTop, Math.min(renderHeight - rowHeight, event.clientY - canvasTop - rowHeight / 2))
3411
+ });
3402
3412
  const rawTargetIndex = locateRow(event.clientY);
3403
3413
  if (rawTargetIndex < 0) return;
3404
- const canvasTop = event.currentTarget.getBoundingClientRect().top;
3405
3414
  const rowTop = bodyTop + rawTargetIndex * rowHeight - scrollRef.current.top;
3406
3415
  const edge = event.clientY - canvasTop < rowTop + rowHeight / 2 ? "top" : "bottom";
3407
3416
  let targetIndex = rawTargetIndex + (edge === "bottom" ? 1 : 0);
3408
3417
  if (drag.sourceIndex < targetIndex) targetIndex -= 1;
3409
3418
  targetIndex = Math.max(0, Math.min(rows.length - 1, targetIndex));
3410
3419
  drag.targetIndex = targetIndex;
3411
- setRowDragPreview((current) => current?.sourceIndex === drag.sourceIndex && current.targetIndex === targetIndex ? current : { sourceIndex: drag.sourceIndex, targetIndex });
3420
+ setRowDragPreview(null);
3412
3421
  setRowDragGuide(rowTop + (edge === "bottom" ? rowHeight : 0));
3413
- }, [bodyTop, hideDragTooltips, locateRow, rowHeight, rows.length, setRowDragGuide]);
3422
+ }, [bodyTop, hideDragTooltips, locateRow, renderHeight, rowHeight, rows.length, setRowDragGuide]);
3414
3423
  const finishRowOrderPointerDrag = (0, import_react8.useCallback)((event, apply) => {
3415
3424
  const drag = rowOrderDragRef.current;
3416
3425
  if (!drag || drag.pointerId !== event.pointerId) return;
3417
3426
  if (event.currentTarget.hasPointerCapture?.(event.pointerId)) event.currentTarget.releasePointerCapture?.(event.pointerId);
3418
3427
  rowOrderDragRef.current = null;
3419
3428
  setRowDragPreview(null);
3429
+ setLiftedRowPreview(null);
3420
3430
  setRowDragGuide(null);
3421
3431
  document.documentElement.classList.remove("rvg-is-dragging");
3422
3432
  event.currentTarget.style.cursor = "default";
@@ -5628,6 +5638,26 @@ function TableInner({
5628
5638
  ]
5629
5639
  }
5630
5640
  ),
5641
+ liftedRowPreview && rows[liftedRowPreview.sourceIndex] && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
5642
+ "div",
5643
+ {
5644
+ "aria-hidden": "true",
5645
+ className: `rvg-row-drag-preview${selectedRowKeySet.has(getRowKey(rows[liftedRowPreview.sourceIndex], liftedRowPreview.sourceIndex)) ? " is-selected" : ""}`,
5646
+ style: { top: liftedRowPreview.top, width: viewport.width, height: rowHeight },
5647
+ children: columns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
5648
+ "div",
5649
+ {
5650
+ className: "rvg-row-drag-preview-cell",
5651
+ style: {
5652
+ left: getDisplayedColumnLeft(columnIndex),
5653
+ width: metrics[columnIndex]?.width ?? 0
5654
+ },
5655
+ children: getCellLabel(liftedRowPreview.sourceIndex, columnIndex)
5656
+ },
5657
+ `row-preview:${column.key}`
5658
+ ))
5659
+ }
5660
+ ),
5631
5661
  resizeGuideX !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
5632
5662
  "div",
5633
5663
  {
package/dist/index.css CHANGED
@@ -1638,13 +1638,16 @@
1638
1638
  }
1639
1639
  .rvg-row-drag-preview {
1640
1640
  position: absolute;
1641
- top: 2px;
1642
- left: 2px;
1643
- overflow: visible;
1644
- border: 1px solid #a9c8f5;
1645
- background: #fff;
1646
- box-shadow: 0 2px 6px rgba(5, 5, 5, 0.08);
1641
+ z-index: 6;
1642
+ left: 0;
1643
+ overflow: hidden;
1644
+ border: 1px solid #8db8f3;
1645
+ background: var(--rvg-color-bg);
1646
+ box-shadow: 0 5px 14px rgba(32, 75, 135, 0.2);
1647
1647
  box-sizing: border-box;
1648
+ opacity: 0.94;
1649
+ pointer-events: none;
1650
+ transform: translateY(-1px);
1648
1651
  }
1649
1652
  .rvg-row-drag-preview-cell {
1650
1653
  position: absolute;
@@ -1665,6 +1668,14 @@
1665
1668
  text-overflow: ellipsis;
1666
1669
  box-sizing: border-box;
1667
1670
  }
1671
+ .rvg-row-drag-preview.is-selected {
1672
+ border-color: var(--rvg-color-primary);
1673
+ background: var(--rvg-color-selection-fill);
1674
+ }
1675
+ .rvg-row-drag-preview.is-selected .rvg-row-drag-preview-cell {
1676
+ border-right-color: color-mix(in srgb, var(--rvg-color-axis-selection-text) 34%, transparent);
1677
+ color: var(--rvg-color-axis-selection-text);
1678
+ }
1668
1679
  .rvg-row-drag-preview-cell svg {
1669
1680
  width: 16px;
1670
1681
  height: 16px;
package/dist/index.js CHANGED
@@ -877,7 +877,11 @@ function TextEditor({ value, type, min, max, integer = false, style, labels, onC
877
877
  if (type === "number" && integer && next !== "" && !/^-?\d+$/.test(next)) return;
878
878
  onChange(next);
879
879
  },
880
- onBlur: commitValue,
880
+ onBlur: (event) => {
881
+ const nextTarget = event.relatedTarget;
882
+ if (nextTarget instanceof Element && nextTarget.closest("[data-rvg-preserve-edit]")) return;
883
+ commitValue();
884
+ },
881
885
  onKeyDown: handleKeyDown
882
886
  }
883
887
  ),
@@ -1272,7 +1276,7 @@ function paintGrid(options) {
1272
1276
  ctx.fillStyle = isAxisSelected ? getAxisSelectionFill(rowIndex, column.key) : colors.columnDropTargetFill;
1273
1277
  ctx.fillRect(x, y, cellWidth, cellHeight);
1274
1278
  }
1275
- ctx.fillStyle = selectedRowKeys.has(rowKey) ? getAxisSelectionFill(rowIndex, column.key) : colors.grid;
1279
+ ctx.fillStyle = selectedRowKeys.has(rowKey) ? getAxisSelectionFill(rowIndex, column.key) : isRangeCell ? colors.selectionFill : colors.grid;
1276
1280
  if (!verticalBorderless && !(frameBorderless && columnIndex + colSpan >= columns.length)) {
1277
1281
  ctx.fillRect(x + cellWidth - 1, y, 1, cellHeight);
1278
1282
  }
@@ -2097,6 +2101,7 @@ function TableInner({
2097
2101
  const [editing, setEditing] = useState6(null);
2098
2102
  const [draft, setDraft] = useState6("");
2099
2103
  const [rowDragPreview, setRowDragPreview] = useState6(null);
2104
+ const [liftedRowPreview, setLiftedRowPreview] = useState6(null);
2100
2105
  const [columnDragPreview, setColumnDragPreview] = useState6(null);
2101
2106
  const [columnDropTarget, setColumnDropTarget] = useState6(null);
2102
2107
  useEffect3(() => {
@@ -3369,24 +3374,29 @@ function TableInner({
3369
3374
  event.currentTarget.style.cursor = "move";
3370
3375
  }
3371
3376
  event.preventDefault();
3377
+ const canvasTop = event.currentTarget.getBoundingClientRect().top;
3378
+ setLiftedRowPreview({
3379
+ sourceIndex: drag.sourceIndex,
3380
+ top: Math.max(bodyTop, Math.min(renderHeight - rowHeight, event.clientY - canvasTop - rowHeight / 2))
3381
+ });
3372
3382
  const rawTargetIndex = locateRow(event.clientY);
3373
3383
  if (rawTargetIndex < 0) return;
3374
- const canvasTop = event.currentTarget.getBoundingClientRect().top;
3375
3384
  const rowTop = bodyTop + rawTargetIndex * rowHeight - scrollRef.current.top;
3376
3385
  const edge = event.clientY - canvasTop < rowTop + rowHeight / 2 ? "top" : "bottom";
3377
3386
  let targetIndex = rawTargetIndex + (edge === "bottom" ? 1 : 0);
3378
3387
  if (drag.sourceIndex < targetIndex) targetIndex -= 1;
3379
3388
  targetIndex = Math.max(0, Math.min(rows.length - 1, targetIndex));
3380
3389
  drag.targetIndex = targetIndex;
3381
- setRowDragPreview((current) => current?.sourceIndex === drag.sourceIndex && current.targetIndex === targetIndex ? current : { sourceIndex: drag.sourceIndex, targetIndex });
3390
+ setRowDragPreview(null);
3382
3391
  setRowDragGuide(rowTop + (edge === "bottom" ? rowHeight : 0));
3383
- }, [bodyTop, hideDragTooltips, locateRow, rowHeight, rows.length, setRowDragGuide]);
3392
+ }, [bodyTop, hideDragTooltips, locateRow, renderHeight, rowHeight, rows.length, setRowDragGuide]);
3384
3393
  const finishRowOrderPointerDrag = useCallback2((event, apply) => {
3385
3394
  const drag = rowOrderDragRef.current;
3386
3395
  if (!drag || drag.pointerId !== event.pointerId) return;
3387
3396
  if (event.currentTarget.hasPointerCapture?.(event.pointerId)) event.currentTarget.releasePointerCapture?.(event.pointerId);
3388
3397
  rowOrderDragRef.current = null;
3389
3398
  setRowDragPreview(null);
3399
+ setLiftedRowPreview(null);
3390
3400
  setRowDragGuide(null);
3391
3401
  document.documentElement.classList.remove("rvg-is-dragging");
3392
3402
  event.currentTarget.style.cursor = "default";
@@ -5598,6 +5608,26 @@ function TableInner({
5598
5608
  ]
5599
5609
  }
5600
5610
  ),
5611
+ liftedRowPreview && rows[liftedRowPreview.sourceIndex] && /* @__PURE__ */ jsx8(
5612
+ "div",
5613
+ {
5614
+ "aria-hidden": "true",
5615
+ className: `rvg-row-drag-preview${selectedRowKeySet.has(getRowKey(rows[liftedRowPreview.sourceIndex], liftedRowPreview.sourceIndex)) ? " is-selected" : ""}`,
5616
+ style: { top: liftedRowPreview.top, width: viewport.width, height: rowHeight },
5617
+ children: columns.map((column, columnIndex) => /* @__PURE__ */ jsx8(
5618
+ "div",
5619
+ {
5620
+ className: "rvg-row-drag-preview-cell",
5621
+ style: {
5622
+ left: getDisplayedColumnLeft(columnIndex),
5623
+ width: metrics[columnIndex]?.width ?? 0
5624
+ },
5625
+ children: getCellLabel(liftedRowPreview.sourceIndex, columnIndex)
5626
+ },
5627
+ `row-preview:${column.key}`
5628
+ ))
5629
+ }
5630
+ ),
5601
5631
  resizeGuideX !== null && /* @__PURE__ */ jsx8(
5602
5632
  "div",
5603
5633
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensui/lens-table",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "description": "A lightweight, canvas-rendered React table component for LensUI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",