@lensui/lens-table 0.1.82 → 0.1.83

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
@@ -1144,6 +1144,24 @@ function ellipsizeText(context, text, maxWidth) {
1144
1144
  }
1145
1145
  return `${text.slice(0, start)}${ellipsis}`;
1146
1146
  }
1147
+ function getSelectionOutlineBounds({
1148
+ left,
1149
+ right,
1150
+ top,
1151
+ bottom,
1152
+ horizontalStart,
1153
+ horizontalEnd,
1154
+ verticalStart,
1155
+ verticalEnd,
1156
+ borderWidth = 2
1157
+ }) {
1158
+ return {
1159
+ left: Math.max(left - borderWidth, horizontalStart - borderWidth),
1160
+ right: Math.min(right + 1, horizontalEnd + 1),
1161
+ top: Math.max(top - borderWidth, verticalStart - borderWidth),
1162
+ bottom: Math.min(bottom + borderWidth, verticalEnd + borderWidth)
1163
+ };
1164
+ }
1147
1165
  function paintGrid(options) {
1148
1166
  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;
1149
1167
  const headerLeafTop = options.headerLeafTop ?? 0;
@@ -1632,51 +1650,65 @@ function paintGrid(options) {
1632
1650
  const visibleRight = x + selectionWidth;
1633
1651
  const visibleBottom = y + selectionHeight;
1634
1652
  const selectionTop = fixedHeader ? bodyTop : 0;
1635
- const selectionClipTop = selectionTop;
1636
1653
  const hiddenAboveHeader = visibleBottom <= selectionTop;
1637
1654
  const hiddenBelowViewport = y >= height;
1638
1655
  const hiddenBehindLeft = !isFixed && visibleRight <= visibleLeft;
1639
1656
  const hiddenBehindRight = !isFixed && x >= selectionAreaRight;
1640
- const leftMarkerX = Math.max(0, leftFixedWidth);
1657
+ const leftMarkerX = leftFixedWidth - borderWidth;
1658
+ const rightMarkerX = selectionAreaRight - 1;
1659
+ const topMarkerY = selectionTop - borderWidth;
1660
+ const bottomMarkerY = height;
1641
1661
  if ((hiddenAboveHeader || hiddenBelowViewport) && (hiddenBehindLeft || hiddenBehindRight)) {
1642
1662
  const markerSize = 2;
1643
- const markerX = hiddenBehindLeft ? leftMarkerX : selectionAreaRight - borderWidth - rightFixedBoundaryInset;
1644
- const markerY = hiddenAboveHeader ? selectionClipTop : height - markerSize;
1663
+ const markerX = hiddenBehindLeft ? leftMarkerX : rightMarkerX;
1664
+ const markerY = hiddenAboveHeader ? topMarkerY : bottomMarkerY;
1645
1665
  ctx.fillStyle = colors.selection;
1646
1666
  ctx.fillRect(markerX, markerY, markerSize, markerSize);
1647
1667
  return;
1648
1668
  }
1669
+ const outline = getSelectionOutlineBounds({
1670
+ left: x,
1671
+ right: visibleRight,
1672
+ top: y,
1673
+ bottom: visibleBottom,
1674
+ horizontalStart: visibleLeft,
1675
+ horizontalEnd: selectionAreaRight,
1676
+ verticalStart: selectionTop,
1677
+ verticalEnd: height,
1678
+ borderWidth
1679
+ });
1649
1680
  ctx.save();
1650
1681
  ctx.beginPath();
1651
- const clipLeft = fixedSide === "left" ? 0 : Math.max(0, leftFixedWidth);
1682
+ const clipLeft = Math.max(0, outline.left);
1652
1683
  const clipRight = Math.min(width, selectionAreaRight + 1);
1653
- ctx.rect(clipLeft, selectionClipTop, clipRight - clipLeft, height - selectionClipTop);
1684
+ const clipTop = Math.max(0, outline.top);
1685
+ ctx.rect(clipLeft, clipTop, clipRight - clipLeft, height - clipTop);
1654
1686
  ctx.clip();
1655
1687
  ctx.fillStyle = colors.selection;
1656
1688
  if (hiddenAboveHeader) {
1657
- const markerLeft = Math.max(x - borderWidth, visibleLeft - 1);
1658
- const markerRight = Math.min(visibleRight + 1, selectionAreaRight);
1659
- if (markerRight > markerLeft) ctx.fillRect(markerLeft, selectionClipTop, markerRight - markerLeft, borderWidth);
1689
+ const markerLeft = Math.max(x - borderWidth, visibleLeft - borderWidth);
1690
+ const markerRight = Math.min(visibleRight + 1, selectionAreaRight + 1);
1691
+ if (markerRight > markerLeft) ctx.fillRect(markerLeft, topMarkerY, markerRight - markerLeft, borderWidth);
1660
1692
  }
1661
1693
  if (hiddenBelowViewport) {
1662
- const markerLeft = Math.max(x - borderWidth, visibleLeft - 1);
1663
- const markerRight = Math.min(visibleRight + 1, selectionAreaRight);
1664
- if (markerRight > markerLeft) ctx.fillRect(markerLeft, height - borderWidth, markerRight - markerLeft, borderWidth);
1694
+ const markerLeft = Math.max(x - borderWidth, visibleLeft - borderWidth);
1695
+ const markerRight = Math.min(visibleRight + 1, selectionAreaRight + 1);
1696
+ if (markerRight > markerLeft) ctx.fillRect(markerLeft, bottomMarkerY, markerRight - markerLeft, borderWidth);
1665
1697
  }
1666
1698
  if (hiddenBehindLeft || hiddenBehindRight) {
1667
- const markerTop = Math.max(y - borderWidth, selectionTop);
1668
- const markerBottom = Math.min(y + selectionHeight + 1, height);
1669
- const markerX = hiddenBehindLeft ? leftMarkerX : selectionAreaRight - borderWidth - rightFixedBoundaryInset;
1699
+ const markerTop = Math.max(y - borderWidth, selectionTop - borderWidth);
1700
+ const markerBottom = Math.min(y + selectionHeight + borderWidth, height + borderWidth);
1701
+ const markerX = hiddenBehindLeft ? leftMarkerX : rightMarkerX;
1670
1702
  ctx.fillRect(markerX, markerTop, borderWidth, Math.max(0, markerBottom - markerTop));
1671
1703
  }
1672
1704
  if (hiddenAboveHeader || hiddenBelowViewport || hiddenBehindLeft || hiddenBehindRight) {
1673
1705
  ctx.restore();
1674
1706
  return;
1675
1707
  }
1676
- const borderLeft = x <= 0 ? 0 : Math.max(x - borderWidth, visibleLeft);
1677
- const borderRight = Math.min(x + selectionWidth - 1, selectionAreaRight - borderWidth, width - borderWidth);
1678
- const borderTop = Math.max(y - borderWidth, selectionClipTop);
1679
- const borderBottom = Math.min(y + selectionHeight, height - borderWidth);
1708
+ const borderLeft = outline.left;
1709
+ const borderRight = outline.right - borderWidth;
1710
+ const borderTop = outline.top;
1711
+ const borderBottom = outline.bottom - borderWidth;
1680
1712
  const borderOuterWidth = borderRight + borderWidth - borderLeft;
1681
1713
  ctx.fillRect(borderLeft, borderTop, borderOuterWidth, borderWidth);
1682
1714
  ctx.fillRect(borderLeft, borderBottom, borderOuterWidth, borderWidth);
@@ -2696,14 +2728,17 @@ function TableInner({
2696
2728
  const cornerLength = 10;
2697
2729
  const hitSlop = 6;
2698
2730
  const targetSize = borderWidth + hitSlop * 2;
2699
- const rightBoundaryInset = rightFixedWidth > 0 && hasVerticalBorders ? 1 : 0;
2700
- const markerX = hiddenLeft ? horizontalStart : horizontalEnd - borderWidth - rightBoundaryInset;
2701
- const markerY = hiddenTop ? verticalStart : renderHeight - borderWidth;
2731
+ const leftBoundary = horizontalStart - borderWidth;
2732
+ const rightBoundary = horizontalEnd - 1;
2733
+ const topBoundary = verticalStart - borderWidth;
2734
+ const bottomBoundary = renderHeight;
2735
+ const markerX = hiddenLeft ? leftBoundary : rightBoundary;
2736
+ const markerY = hiddenTop ? topBoundary : bottomBoundary;
2702
2737
  if (hiddenLeft || hiddenRight) {
2703
- let markerTop = Math.max(rawTop - borderWidth, verticalStart);
2704
- let markerBottom = Math.min(rawBottom + 1, renderHeight);
2705
- const topClip = Math.max(0, verticalStart - (rawTop - borderWidth));
2706
- const bottomClip = Math.max(0, rawBottom + 1 - renderHeight);
2738
+ const markerTop = Math.max(rawTop - borderWidth, topBoundary);
2739
+ const markerBottom = Math.min(rawBottom + borderWidth, renderHeight + borderWidth);
2740
+ const topClip = Math.max(0, verticalStart - rawTop);
2741
+ const bottomClip = Math.max(0, rawBottom - renderHeight);
2707
2742
  if (topClip > 0 || bottomClip > 0) {
2708
2743
  const foldAtTop = topClip > 0;
2709
2744
  const fold = Math.min(cornerLength, foldAtTop ? topClip : bottomClip);
@@ -2712,7 +2747,7 @@ function TableInner({
2712
2747
  const cornerHeight = Math.max(cornerLength, markerBottom - markerTop);
2713
2748
  const cornerOnLeft = hiddenLeft;
2714
2749
  const shapeLeft = cornerOnLeft ? markerX : markerX + borderWidth - cornerWidth;
2715
- const shapeTop = foldAtTop ? verticalStart : renderHeight - cornerHeight;
2750
+ const shapeTop = foldAtTop ? topBoundary : renderHeight + borderWidth - cornerHeight;
2716
2751
  return {
2717
2752
  side: `${foldAtTop ? "top" : "bottom"}-${cornerOnLeft ? "left" : "right"}`,
2718
2753
  orientation: "corner",
@@ -2739,19 +2774,19 @@ function TableInner({
2739
2774
  }
2740
2775
  };
2741
2776
  }
2742
- const horizontalMarkerEnd = horizontalEnd - rightBoundaryInset;
2743
- let markerLeft = Math.max(rawLeft - borderWidth, horizontalStart);
2744
- let markerRight = Math.min(rawRight + 1, horizontalMarkerEnd);
2745
- const leftClip = Math.max(0, horizontalStart - (rawLeft - borderWidth));
2746
- const rightClip = Math.max(0, rawRight + 1 - horizontalMarkerEnd);
2777
+ const horizontalMarkerEnd = horizontalEnd + 1;
2778
+ const markerLeft = Math.max(rawLeft - borderWidth, leftBoundary);
2779
+ const markerRight = Math.min(rawRight + 1, horizontalMarkerEnd);
2780
+ const leftClip = Math.max(0, horizontalStart - rawLeft);
2781
+ const rightClip = Math.max(0, rawRight - horizontalEnd);
2747
2782
  if (leftClip > 0 || rightClip > 0) {
2748
2783
  const foldAtLeft = leftClip > 0;
2749
2784
  const fold = Math.min(cornerLength, foldAtLeft ? leftClip : rightClip);
2750
2785
  if (fold > borderWidth) {
2751
2786
  const cornerWidth = Math.max(cornerLength, markerRight - markerLeft);
2752
2787
  const cornerHeight = fold;
2753
- const shapeLeft = foldAtLeft ? horizontalStart : horizontalMarkerEnd - cornerWidth;
2754
- const shapeTop = hiddenTop ? verticalStart : renderHeight - cornerHeight;
2788
+ const shapeLeft = foldAtLeft ? leftBoundary : horizontalMarkerEnd - cornerWidth;
2789
+ const shapeTop = hiddenTop ? topBoundary : renderHeight + borderWidth - cornerHeight;
2755
2790
  return {
2756
2791
  side: `${hiddenTop ? "top" : "bottom"}-${foldAtLeft ? "left" : "right"}`,
2757
2792
  orientation: "corner",
@@ -2777,7 +2812,7 @@ function TableInner({
2777
2812
  height: targetSize
2778
2813
  }
2779
2814
  };
2780
- }, [bodyTop, columns, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getRowKey, getScrollableColumnLeft, hasVerticalBorders, leftFixedOffsets, metrics, renderHeight, rightFixedOffsets, rightFixedWidth, rowHeight, rows, selection, selectionRange, viewport.width]);
2815
+ }, [bodyTop, columns, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getRowKey, getScrollableColumnLeft, leftFixedOffsets, metrics, renderHeight, rightFixedOffsets, rightFixedWidth, rowHeight, rows, selection, selectionRange, viewport.width]);
2781
2816
  const syncSelectionEdgeTarget = (0, import_react8.useCallback)((scrollLeft, scrollTop) => {
2782
2817
  const target = selectionEdgeTargetRef.current;
2783
2818
  if (!target) return;
@@ -3147,11 +3182,20 @@ function TableInner({
3147
3182
  if (rawRight <= horizontalStart || rawLeft >= horizontalEnd || rawBottom <= verticalStart || rawTop >= renderHeight) {
3148
3183
  focus.style.display = "none";
3149
3184
  } else {
3150
- const borderWidth = 2;
3151
- const left = Math.round(Math.max(rawLeft - borderWidth, horizontalStart));
3152
- const right = Math.round(Math.min(rawRight + 1, horizontalEnd, viewport.width));
3153
- const top = Math.round(Math.max(rawTop - borderWidth, verticalStart));
3154
- const bottom = Math.round(Math.min(rawBottom + borderWidth, renderHeight));
3185
+ const bounds = getSelectionOutlineBounds({
3186
+ left: rawLeft,
3187
+ right: rawRight,
3188
+ top: rawTop,
3189
+ bottom: rawBottom,
3190
+ horizontalStart,
3191
+ horizontalEnd,
3192
+ verticalStart,
3193
+ verticalEnd: renderHeight
3194
+ });
3195
+ const left = Math.round(bounds.left);
3196
+ const right = Math.round(bounds.right);
3197
+ const top = Math.round(bounds.top);
3198
+ const bottom = Math.round(bounds.bottom);
3155
3199
  focus.style.display = "block";
3156
3200
  focus.style.left = `${left}px`;
3157
3201
  focus.style.top = `${top}px`;
@@ -4687,11 +4731,20 @@ function TableInner({
4687
4731
  const horizontalEnd = column.fixed === void 0 ? viewport.width - rightFixedWidth : viewport.width;
4688
4732
  const verticalStart = fixedHeader ? bodyTop : 0;
4689
4733
  if (rawRight <= horizontalStart || rawLeft >= horizontalEnd || rawBottom + dragOffset <= verticalStart || rawTop + dragOffset >= renderHeight) return null;
4690
- const borderWidth = 2;
4691
- const left = Math.round(Math.max(rawLeft - borderWidth, horizontalStart));
4692
- const right = Math.round(Math.min(rawRight + 1, horizontalEnd, viewport.width));
4693
- const top = Math.round(Math.max(rawTop - borderWidth, verticalStart));
4694
- const bottom = Math.round(Math.min(rawBottom + borderWidth, renderHeight));
4734
+ const bounds = getSelectionOutlineBounds({
4735
+ left: rawLeft,
4736
+ right: rawRight,
4737
+ top: rawTop,
4738
+ bottom: rawBottom,
4739
+ horizontalStart,
4740
+ horizontalEnd,
4741
+ verticalStart,
4742
+ verticalEnd: renderHeight
4743
+ });
4744
+ const left = Math.round(bounds.left);
4745
+ const right = Math.round(bounds.right);
4746
+ const top = Math.round(bounds.top);
4747
+ const bottom = Math.round(bounds.bottom);
4695
4748
  return {
4696
4749
  left,
4697
4750
  top,
package/dist/index.js CHANGED
@@ -1114,6 +1114,24 @@ function ellipsizeText(context, text, maxWidth) {
1114
1114
  }
1115
1115
  return `${text.slice(0, start)}${ellipsis}`;
1116
1116
  }
1117
+ function getSelectionOutlineBounds({
1118
+ left,
1119
+ right,
1120
+ top,
1121
+ bottom,
1122
+ horizontalStart,
1123
+ horizontalEnd,
1124
+ verticalStart,
1125
+ verticalEnd,
1126
+ borderWidth = 2
1127
+ }) {
1128
+ return {
1129
+ left: Math.max(left - borderWidth, horizontalStart - borderWidth),
1130
+ right: Math.min(right + 1, horizontalEnd + 1),
1131
+ top: Math.max(top - borderWidth, verticalStart - borderWidth),
1132
+ bottom: Math.min(bottom + borderWidth, verticalEnd + borderWidth)
1133
+ };
1134
+ }
1117
1135
  function paintGrid(options) {
1118
1136
  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;
1119
1137
  const headerLeafTop = options.headerLeafTop ?? 0;
@@ -1602,51 +1620,65 @@ function paintGrid(options) {
1602
1620
  const visibleRight = x + selectionWidth;
1603
1621
  const visibleBottom = y + selectionHeight;
1604
1622
  const selectionTop = fixedHeader ? bodyTop : 0;
1605
- const selectionClipTop = selectionTop;
1606
1623
  const hiddenAboveHeader = visibleBottom <= selectionTop;
1607
1624
  const hiddenBelowViewport = y >= height;
1608
1625
  const hiddenBehindLeft = !isFixed && visibleRight <= visibleLeft;
1609
1626
  const hiddenBehindRight = !isFixed && x >= selectionAreaRight;
1610
- const leftMarkerX = Math.max(0, leftFixedWidth);
1627
+ const leftMarkerX = leftFixedWidth - borderWidth;
1628
+ const rightMarkerX = selectionAreaRight - 1;
1629
+ const topMarkerY = selectionTop - borderWidth;
1630
+ const bottomMarkerY = height;
1611
1631
  if ((hiddenAboveHeader || hiddenBelowViewport) && (hiddenBehindLeft || hiddenBehindRight)) {
1612
1632
  const markerSize = 2;
1613
- const markerX = hiddenBehindLeft ? leftMarkerX : selectionAreaRight - borderWidth - rightFixedBoundaryInset;
1614
- const markerY = hiddenAboveHeader ? selectionClipTop : height - markerSize;
1633
+ const markerX = hiddenBehindLeft ? leftMarkerX : rightMarkerX;
1634
+ const markerY = hiddenAboveHeader ? topMarkerY : bottomMarkerY;
1615
1635
  ctx.fillStyle = colors.selection;
1616
1636
  ctx.fillRect(markerX, markerY, markerSize, markerSize);
1617
1637
  return;
1618
1638
  }
1639
+ const outline = getSelectionOutlineBounds({
1640
+ left: x,
1641
+ right: visibleRight,
1642
+ top: y,
1643
+ bottom: visibleBottom,
1644
+ horizontalStart: visibleLeft,
1645
+ horizontalEnd: selectionAreaRight,
1646
+ verticalStart: selectionTop,
1647
+ verticalEnd: height,
1648
+ borderWidth
1649
+ });
1619
1650
  ctx.save();
1620
1651
  ctx.beginPath();
1621
- const clipLeft = fixedSide === "left" ? 0 : Math.max(0, leftFixedWidth);
1652
+ const clipLeft = Math.max(0, outline.left);
1622
1653
  const clipRight = Math.min(width, selectionAreaRight + 1);
1623
- ctx.rect(clipLeft, selectionClipTop, clipRight - clipLeft, height - selectionClipTop);
1654
+ const clipTop = Math.max(0, outline.top);
1655
+ ctx.rect(clipLeft, clipTop, clipRight - clipLeft, height - clipTop);
1624
1656
  ctx.clip();
1625
1657
  ctx.fillStyle = colors.selection;
1626
1658
  if (hiddenAboveHeader) {
1627
- const markerLeft = Math.max(x - borderWidth, visibleLeft - 1);
1628
- const markerRight = Math.min(visibleRight + 1, selectionAreaRight);
1629
- if (markerRight > markerLeft) ctx.fillRect(markerLeft, selectionClipTop, markerRight - markerLeft, borderWidth);
1659
+ const markerLeft = Math.max(x - borderWidth, visibleLeft - borderWidth);
1660
+ const markerRight = Math.min(visibleRight + 1, selectionAreaRight + 1);
1661
+ if (markerRight > markerLeft) ctx.fillRect(markerLeft, topMarkerY, markerRight - markerLeft, borderWidth);
1630
1662
  }
1631
1663
  if (hiddenBelowViewport) {
1632
- const markerLeft = Math.max(x - borderWidth, visibleLeft - 1);
1633
- const markerRight = Math.min(visibleRight + 1, selectionAreaRight);
1634
- if (markerRight > markerLeft) ctx.fillRect(markerLeft, height - borderWidth, markerRight - markerLeft, borderWidth);
1664
+ const markerLeft = Math.max(x - borderWidth, visibleLeft - borderWidth);
1665
+ const markerRight = Math.min(visibleRight + 1, selectionAreaRight + 1);
1666
+ if (markerRight > markerLeft) ctx.fillRect(markerLeft, bottomMarkerY, markerRight - markerLeft, borderWidth);
1635
1667
  }
1636
1668
  if (hiddenBehindLeft || hiddenBehindRight) {
1637
- const markerTop = Math.max(y - borderWidth, selectionTop);
1638
- const markerBottom = Math.min(y + selectionHeight + 1, height);
1639
- const markerX = hiddenBehindLeft ? leftMarkerX : selectionAreaRight - borderWidth - rightFixedBoundaryInset;
1669
+ const markerTop = Math.max(y - borderWidth, selectionTop - borderWidth);
1670
+ const markerBottom = Math.min(y + selectionHeight + borderWidth, height + borderWidth);
1671
+ const markerX = hiddenBehindLeft ? leftMarkerX : rightMarkerX;
1640
1672
  ctx.fillRect(markerX, markerTop, borderWidth, Math.max(0, markerBottom - markerTop));
1641
1673
  }
1642
1674
  if (hiddenAboveHeader || hiddenBelowViewport || hiddenBehindLeft || hiddenBehindRight) {
1643
1675
  ctx.restore();
1644
1676
  return;
1645
1677
  }
1646
- const borderLeft = x <= 0 ? 0 : Math.max(x - borderWidth, visibleLeft);
1647
- const borderRight = Math.min(x + selectionWidth - 1, selectionAreaRight - borderWidth, width - borderWidth);
1648
- const borderTop = Math.max(y - borderWidth, selectionClipTop);
1649
- const borderBottom = Math.min(y + selectionHeight, height - borderWidth);
1678
+ const borderLeft = outline.left;
1679
+ const borderRight = outline.right - borderWidth;
1680
+ const borderTop = outline.top;
1681
+ const borderBottom = outline.bottom - borderWidth;
1650
1682
  const borderOuterWidth = borderRight + borderWidth - borderLeft;
1651
1683
  ctx.fillRect(borderLeft, borderTop, borderOuterWidth, borderWidth);
1652
1684
  ctx.fillRect(borderLeft, borderBottom, borderOuterWidth, borderWidth);
@@ -2666,14 +2698,17 @@ function TableInner({
2666
2698
  const cornerLength = 10;
2667
2699
  const hitSlop = 6;
2668
2700
  const targetSize = borderWidth + hitSlop * 2;
2669
- const rightBoundaryInset = rightFixedWidth > 0 && hasVerticalBorders ? 1 : 0;
2670
- const markerX = hiddenLeft ? horizontalStart : horizontalEnd - borderWidth - rightBoundaryInset;
2671
- const markerY = hiddenTop ? verticalStart : renderHeight - borderWidth;
2701
+ const leftBoundary = horizontalStart - borderWidth;
2702
+ const rightBoundary = horizontalEnd - 1;
2703
+ const topBoundary = verticalStart - borderWidth;
2704
+ const bottomBoundary = renderHeight;
2705
+ const markerX = hiddenLeft ? leftBoundary : rightBoundary;
2706
+ const markerY = hiddenTop ? topBoundary : bottomBoundary;
2672
2707
  if (hiddenLeft || hiddenRight) {
2673
- let markerTop = Math.max(rawTop - borderWidth, verticalStart);
2674
- let markerBottom = Math.min(rawBottom + 1, renderHeight);
2675
- const topClip = Math.max(0, verticalStart - (rawTop - borderWidth));
2676
- const bottomClip = Math.max(0, rawBottom + 1 - renderHeight);
2708
+ const markerTop = Math.max(rawTop - borderWidth, topBoundary);
2709
+ const markerBottom = Math.min(rawBottom + borderWidth, renderHeight + borderWidth);
2710
+ const topClip = Math.max(0, verticalStart - rawTop);
2711
+ const bottomClip = Math.max(0, rawBottom - renderHeight);
2677
2712
  if (topClip > 0 || bottomClip > 0) {
2678
2713
  const foldAtTop = topClip > 0;
2679
2714
  const fold = Math.min(cornerLength, foldAtTop ? topClip : bottomClip);
@@ -2682,7 +2717,7 @@ function TableInner({
2682
2717
  const cornerHeight = Math.max(cornerLength, markerBottom - markerTop);
2683
2718
  const cornerOnLeft = hiddenLeft;
2684
2719
  const shapeLeft = cornerOnLeft ? markerX : markerX + borderWidth - cornerWidth;
2685
- const shapeTop = foldAtTop ? verticalStart : renderHeight - cornerHeight;
2720
+ const shapeTop = foldAtTop ? topBoundary : renderHeight + borderWidth - cornerHeight;
2686
2721
  return {
2687
2722
  side: `${foldAtTop ? "top" : "bottom"}-${cornerOnLeft ? "left" : "right"}`,
2688
2723
  orientation: "corner",
@@ -2709,19 +2744,19 @@ function TableInner({
2709
2744
  }
2710
2745
  };
2711
2746
  }
2712
- const horizontalMarkerEnd = horizontalEnd - rightBoundaryInset;
2713
- let markerLeft = Math.max(rawLeft - borderWidth, horizontalStart);
2714
- let markerRight = Math.min(rawRight + 1, horizontalMarkerEnd);
2715
- const leftClip = Math.max(0, horizontalStart - (rawLeft - borderWidth));
2716
- const rightClip = Math.max(0, rawRight + 1 - horizontalMarkerEnd);
2747
+ const horizontalMarkerEnd = horizontalEnd + 1;
2748
+ const markerLeft = Math.max(rawLeft - borderWidth, leftBoundary);
2749
+ const markerRight = Math.min(rawRight + 1, horizontalMarkerEnd);
2750
+ const leftClip = Math.max(0, horizontalStart - rawLeft);
2751
+ const rightClip = Math.max(0, rawRight - horizontalEnd);
2717
2752
  if (leftClip > 0 || rightClip > 0) {
2718
2753
  const foldAtLeft = leftClip > 0;
2719
2754
  const fold = Math.min(cornerLength, foldAtLeft ? leftClip : rightClip);
2720
2755
  if (fold > borderWidth) {
2721
2756
  const cornerWidth = Math.max(cornerLength, markerRight - markerLeft);
2722
2757
  const cornerHeight = fold;
2723
- const shapeLeft = foldAtLeft ? horizontalStart : horizontalMarkerEnd - cornerWidth;
2724
- const shapeTop = hiddenTop ? verticalStart : renderHeight - cornerHeight;
2758
+ const shapeLeft = foldAtLeft ? leftBoundary : horizontalMarkerEnd - cornerWidth;
2759
+ const shapeTop = hiddenTop ? topBoundary : renderHeight + borderWidth - cornerHeight;
2725
2760
  return {
2726
2761
  side: `${hiddenTop ? "top" : "bottom"}-${foldAtLeft ? "left" : "right"}`,
2727
2762
  orientation: "corner",
@@ -2747,7 +2782,7 @@ function TableInner({
2747
2782
  height: targetSize
2748
2783
  }
2749
2784
  };
2750
- }, [bodyTop, columns, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getRowKey, getScrollableColumnLeft, hasVerticalBorders, leftFixedOffsets, metrics, renderHeight, rightFixedOffsets, rightFixedWidth, rowHeight, rows, selection, selectionRange, viewport.width]);
2785
+ }, [bodyTop, columns, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getRowKey, getScrollableColumnLeft, leftFixedOffsets, metrics, renderHeight, rightFixedOffsets, rightFixedWidth, rowHeight, rows, selection, selectionRange, viewport.width]);
2751
2786
  const syncSelectionEdgeTarget = useCallback2((scrollLeft, scrollTop) => {
2752
2787
  const target = selectionEdgeTargetRef.current;
2753
2788
  if (!target) return;
@@ -3117,11 +3152,20 @@ function TableInner({
3117
3152
  if (rawRight <= horizontalStart || rawLeft >= horizontalEnd || rawBottom <= verticalStart || rawTop >= renderHeight) {
3118
3153
  focus.style.display = "none";
3119
3154
  } else {
3120
- const borderWidth = 2;
3121
- const left = Math.round(Math.max(rawLeft - borderWidth, horizontalStart));
3122
- const right = Math.round(Math.min(rawRight + 1, horizontalEnd, viewport.width));
3123
- const top = Math.round(Math.max(rawTop - borderWidth, verticalStart));
3124
- const bottom = Math.round(Math.min(rawBottom + borderWidth, renderHeight));
3155
+ const bounds = getSelectionOutlineBounds({
3156
+ left: rawLeft,
3157
+ right: rawRight,
3158
+ top: rawTop,
3159
+ bottom: rawBottom,
3160
+ horizontalStart,
3161
+ horizontalEnd,
3162
+ verticalStart,
3163
+ verticalEnd: renderHeight
3164
+ });
3165
+ const left = Math.round(bounds.left);
3166
+ const right = Math.round(bounds.right);
3167
+ const top = Math.round(bounds.top);
3168
+ const bottom = Math.round(bounds.bottom);
3125
3169
  focus.style.display = "block";
3126
3170
  focus.style.left = `${left}px`;
3127
3171
  focus.style.top = `${top}px`;
@@ -4657,11 +4701,20 @@ function TableInner({
4657
4701
  const horizontalEnd = column.fixed === void 0 ? viewport.width - rightFixedWidth : viewport.width;
4658
4702
  const verticalStart = fixedHeader ? bodyTop : 0;
4659
4703
  if (rawRight <= horizontalStart || rawLeft >= horizontalEnd || rawBottom + dragOffset <= verticalStart || rawTop + dragOffset >= renderHeight) return null;
4660
- const borderWidth = 2;
4661
- const left = Math.round(Math.max(rawLeft - borderWidth, horizontalStart));
4662
- const right = Math.round(Math.min(rawRight + 1, horizontalEnd, viewport.width));
4663
- const top = Math.round(Math.max(rawTop - borderWidth, verticalStart));
4664
- const bottom = Math.round(Math.min(rawBottom + borderWidth, renderHeight));
4704
+ const bounds = getSelectionOutlineBounds({
4705
+ left: rawLeft,
4706
+ right: rawRight,
4707
+ top: rawTop,
4708
+ bottom: rawBottom,
4709
+ horizontalStart,
4710
+ horizontalEnd,
4711
+ verticalStart,
4712
+ verticalEnd: renderHeight
4713
+ });
4714
+ const left = Math.round(bounds.left);
4715
+ const right = Math.round(bounds.right);
4716
+ const top = Math.round(bounds.top);
4717
+ const bottom = Math.round(bounds.bottom);
4665
4718
  return {
4666
4719
  left,
4667
4720
  top,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensui/lens-table",
3
- "version": "0.1.82",
3
+ "version": "0.1.83",
4
4
  "description": "A lightweight, canvas-rendered React table component for LensUI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",