@extend-ai/react-xlsx 0.17.2 → 0.17.3

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.js CHANGED
@@ -24495,6 +24495,9 @@ function XlsxGrid({
24495
24495
  const canvasCornerOverlayContentRef = React4.useRef(null);
24496
24496
  const canvasImageCacheRef = React4.useRef(/* @__PURE__ */ new Map());
24497
24497
  const selectionOverlayRef = React4.useRef(null);
24498
+ const selectionPaneContentRefs = React4.useRef(/* @__PURE__ */ new Map());
24499
+ const selectionPaneOverlayRefs = React4.useRef(/* @__PURE__ */ new Map());
24500
+ const selectionPaneFillHandleRefs = React4.useRef(/* @__PURE__ */ new Map());
24498
24501
  const canvasSelectionLayerRef = React4.useRef(null);
24499
24502
  const activeValidationOverlayRef = React4.useRef(null);
24500
24503
  const fillHandleRef = React4.useRef(null);
@@ -24756,15 +24759,17 @@ function XlsxGrid({
24756
24759
  shouldTransform ? "transform" : ""
24757
24760
  );
24758
24761
  };
24759
- const applyOverlayTransform = (element, baseTranslateX, baseTranslateY, paneLeft, paneTop, anchorX, anchorY) => {
24762
+ const applyOverlayTransform = (pane, element, baseTranslateX, baseTranslateY, paneLeft, paneTop, anchorX, anchorY) => {
24760
24763
  const translateX = resolveLiveTranslation(baseTranslateX, anchorX, paneLeft);
24761
24764
  const translateY = resolveLiveTranslation(baseTranslateY, anchorY, paneTop);
24762
- applyElementTransform(
24763
- element,
24764
- liveZoomScale2 !== 1 ? `translate3d(${translateX}px, ${translateY}px, 0) scale(${liveZoomScale2})` : `translate3d(${baseTranslateX}px, ${baseTranslateY}px, 0)`,
24765
- "transform",
24766
- "0 0"
24767
- );
24765
+ for (const content of [element, selectionPaneContentRefs.current.get(pane) ?? null]) {
24766
+ applyElementTransform(
24767
+ content,
24768
+ liveZoomScale2 !== 1 ? `translate3d(${translateX}px, ${translateY}px, 0) scale(${liveZoomScale2})` : `translate3d(${baseTranslateX}px, ${baseTranslateY}px, 0)`,
24769
+ "transform",
24770
+ "0 0"
24771
+ );
24772
+ }
24768
24773
  };
24769
24774
  const liveScrollBodyViewportWidth = Math.max(0, nextLiveViewport.width - liveFrozenPaneRight);
24770
24775
  const liveScrollBodyViewportHeight = Math.max(0, nextLiveViewport.height - liveFrozenPaneBottom);
@@ -24861,6 +24866,7 @@ function XlsxGrid({
24861
24866
  0
24862
24867
  );
24863
24868
  applyOverlayTransform(
24869
+ "scroll",
24864
24870
  canvasScrollOverlayContentRef.current,
24865
24871
  -nextLiveViewport.left - liveFrozenPaneRight,
24866
24872
  -nextLiveViewport.top - liveFrozenPaneBottom,
@@ -24870,6 +24876,7 @@ function XlsxGrid({
24870
24876
  liveZoomAnchorY
24871
24877
  );
24872
24878
  applyOverlayTransform(
24879
+ "top",
24873
24880
  canvasTopOverlayContentRef.current,
24874
24881
  -nextLiveViewport.left - liveFrozenPaneRight,
24875
24882
  -liveDisplayHeaderHeight,
@@ -24879,6 +24886,7 @@ function XlsxGrid({
24879
24886
  0
24880
24887
  );
24881
24888
  applyOverlayTransform(
24889
+ "left",
24882
24890
  canvasLeftOverlayContentRef.current,
24883
24891
  -liveDisplayRowHeaderWidth,
24884
24892
  -nextLiveViewport.top - liveFrozenPaneBottom,
@@ -24888,6 +24896,7 @@ function XlsxGrid({
24888
24896
  liveZoomAnchorY
24889
24897
  );
24890
24898
  applyOverlayTransform(
24899
+ "corner",
24891
24900
  canvasCornerOverlayContentRef.current,
24892
24901
  -liveDisplayRowHeaderWidth,
24893
24902
  -liveDisplayHeaderHeight,
@@ -27501,36 +27510,46 @@ function XlsxGrid({
27501
27510
  colHeaderCellRefs.current.delete(actualCol);
27502
27511
  }, [experimentalCanvas, palette.headerSurface]);
27503
27512
  const applyPreviewOverlay = React4.useCallback((range, options) => {
27504
- const overlay = selectionOverlayRef.current;
27505
- if (!overlay || !range) {
27513
+ const overlays = experimentalCanvas ? [...selectionPaneOverlayRefs.current.values()] : [selectionOverlayRef.current];
27514
+ if (!range) {
27506
27515
  if (options?.updateHeaderSelection !== false) {
27507
27516
  applyHeaderSelection(range);
27508
27517
  }
27509
27518
  return;
27510
27519
  }
27511
- const nextRect = options?.preferGeometry ? resolveGeometryOverlayRect(range) ?? resolveOverlayRect(range) : selectionDragRef.current?.didDrag || fillDragRef.current ? resolveDragPreviewRect(range) ?? resolveGeometryOverlayRect(range) ?? resolveOverlayRect(range) : resolveOverlayRect(range);
27520
+ const nextRect = experimentalCanvas || options?.preferGeometry ? resolveGeometryOverlayRect(range) ?? resolveOverlayRect(range) : selectionDragRef.current?.didDrag || fillDragRef.current ? resolveDragPreviewRect(range) ?? resolveGeometryOverlayRect(range) ?? resolveOverlayRect(range) : resolveOverlayRect(range);
27512
27521
  if (!nextRect) {
27513
27522
  if (options?.updateHeaderSelection !== false) {
27514
27523
  applyHeaderSelection(range);
27515
27524
  }
27516
27525
  return;
27517
27526
  }
27518
- overlay.style.left = `${nextRect.left}px`;
27519
- overlay.style.top = `${nextRect.top}px`;
27520
- overlay.style.width = `${nextRect.width}px`;
27521
- overlay.style.height = `${nextRect.height}px`;
27522
- overlay.style.opacity = "1";
27523
- overlay.style.visibility = "visible";
27524
- const fillHandle = fillHandleRef.current;
27525
- if (fillHandle) {
27526
- fillHandle.style.left = `${nextRect.left + nextRect.width - 4 * zoomFactor}px`;
27527
- fillHandle.style.top = `${nextRect.top + nextRect.height - 4 * zoomFactor}px`;
27527
+ for (const overlay of overlays) {
27528
+ if (overlay) {
27529
+ overlay.style.left = `${nextRect.left}px`;
27530
+ overlay.style.top = `${nextRect.top}px`;
27531
+ overlay.style.width = `${nextRect.width}px`;
27532
+ overlay.style.height = `${nextRect.height}px`;
27533
+ overlay.style.opacity = "1";
27534
+ overlay.style.visibility = "visible";
27535
+ }
27536
+ }
27537
+ const fillHandles = experimentalCanvas ? [...selectionPaneFillHandleRefs.current.values()] : [fillHandleRef.current];
27538
+ for (const fillHandle of fillHandles) {
27539
+ if (fillHandle) {
27540
+ fillHandle.style.left = `${nextRect.left + nextRect.width - 4 * zoomFactor}px`;
27541
+ fillHandle.style.top = `${nextRect.top + nextRect.height - 4 * zoomFactor}px`;
27542
+ }
27528
27543
  }
27529
27544
  if (options?.updateHeaderSelection !== false) {
27530
27545
  applyHeaderSelection(range);
27531
27546
  }
27532
- }, [applyHeaderSelection, resolveDragPreviewRect, resolveGeometryOverlayRect, resolveOverlayRect, zoomFactor]);
27547
+ }, [applyHeaderSelection, experimentalCanvas, resolveDragPreviewRect, resolveGeometryOverlayRect, resolveOverlayRect, zoomFactor]);
27533
27548
  const applyPreviewOverlayFromElement = React4.useCallback((element, range) => {
27549
+ if (experimentalCanvas) {
27550
+ applyPreviewOverlay(range);
27551
+ return;
27552
+ }
27534
27553
  const overlay = selectionOverlayRef.current;
27535
27554
  if (!overlay) {
27536
27555
  return;
@@ -27552,7 +27571,7 @@ function XlsxGrid({
27552
27571
  fillHandle.style.top = `${nextRect.top + nextRect.height - 4 * zoomFactor}px`;
27553
27572
  }
27554
27573
  applyHeaderSelection(range);
27555
- }, [applyHeaderSelection, resolveMountedCellOverlayRect, resolveOverlayRect, zoomFactor]);
27574
+ }, [applyHeaderSelection, applyPreviewOverlay, experimentalCanvas, resolveMountedCellOverlayRect, resolveOverlayRect, zoomFactor]);
27556
27575
  const syncActiveValidationOverlay = React4.useCallback((cell) => {
27557
27576
  const overlay = activeValidationOverlayRef.current;
27558
27577
  if (!overlay || !cell || editingCellRef.current || selectionDragRef.current || fillDragRef.current) {
@@ -27986,9 +28005,11 @@ function XlsxGrid({
27986
28005
  const overlayRange = selectionPreviewRangeRef.current ?? displayedSelection;
27987
28006
  if (!overlayRange || !wrapperRef.current) {
27988
28007
  applyHeaderSelection(null);
27989
- if (selectionOverlayRef.current) {
27990
- selectionOverlayRef.current.style.opacity = "0";
27991
- selectionOverlayRef.current.style.visibility = "hidden";
28008
+ for (const overlay of [selectionOverlayRef.current, ...selectionPaneOverlayRefs.current.values()]) {
28009
+ if (overlay) {
28010
+ overlay.style.opacity = "0";
28011
+ overlay.style.visibility = "hidden";
28012
+ }
27992
28013
  }
27993
28014
  return;
27994
28015
  }
@@ -31669,12 +31690,104 @@ function XlsxGrid({
31669
31690
  index
31670
31691
  )
31671
31692
  ] : []);
31672
- const drawingOverlayPanes = experimentalCanvas && hasCanvasDomDrawingOverlays || rangeHighlightNodes.length > 0 ? /* @__PURE__ */ jsx3("div", { style: { ...canvasBodyViewportLayerStyle, zIndex: experimentalCanvas ? 23 : 34 }, children: [
31693
+ function renderSelectionOverlay(pane) {
31694
+ return /* @__PURE__ */ jsxs3(Fragment4, { children: [
31695
+ /* @__PURE__ */ jsx3(
31696
+ "div",
31697
+ {
31698
+ ref: pane ? (element) => {
31699
+ if (element) {
31700
+ selectionPaneOverlayRefs.current.set(pane, element);
31701
+ } else {
31702
+ selectionPaneOverlayRefs.current.delete(pane);
31703
+ }
31704
+ } : selectionOverlayRef,
31705
+ style: {
31706
+ backgroundColor: selectionFill,
31707
+ boxSizing: "border-box",
31708
+ boxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
31709
+ contain: "layout paint",
31710
+ height: resolvedSelectionOverlay?.height ?? 0,
31711
+ left: resolvedSelectionOverlay?.left ?? 0,
31712
+ opacity: resolvedSelectionOverlay ? 1 : 0,
31713
+ pointerEvents: "none",
31714
+ position: "absolute",
31715
+ top: resolvedSelectionOverlay?.top ?? 0,
31716
+ transition: canvasSelectionTransition,
31717
+ visibility: resolvedSelectionOverlay ? "visible" : "hidden",
31718
+ willChange: shouldAnimateCanvasSelectionGeometry ? "left, top, width, height" : void 0,
31719
+ width: resolvedSelectionOverlay?.width ?? 0,
31720
+ zIndex: 24
31721
+ }
31722
+ }
31723
+ ),
31724
+ /* @__PURE__ */ jsx3(
31725
+ "div",
31726
+ {
31727
+ ref: pane ? (element) => {
31728
+ if (element) {
31729
+ selectionPaneFillHandleRefs.current.set(pane, element);
31730
+ } else {
31731
+ selectionPaneFillHandleRefs.current.delete(pane);
31732
+ }
31733
+ } : fillHandleRef,
31734
+ onPointerDown: (event) => {
31735
+ if (readOnly || event.button !== 0 || !normalizedSelection || !resolvedSelectionOverlay) {
31736
+ return;
31737
+ }
31738
+ event.preventDefault();
31739
+ event.stopPropagation();
31740
+ startFillDrag(event.pointerId, normalizedSelection);
31741
+ },
31742
+ style: {
31743
+ backgroundColor: selectionStroke,
31744
+ border: `${Math.max(1, zoomFactor)}px solid ${palette.surface}`,
31745
+ contain: "layout paint",
31746
+ cursor: "crosshair",
31747
+ display: !readOnly && resolvedSelectionOverlay ? "block" : "none",
31748
+ height: 8 * zoomFactor,
31749
+ left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 * zoomFactor : 0,
31750
+ pointerEvents: "auto",
31751
+ position: "absolute",
31752
+ top: resolvedSelectionOverlay ? resolvedSelectionOverlay.top + resolvedSelectionOverlay.height - 4 * zoomFactor : 0,
31753
+ transition: shouldAnimateCanvasSelectionGeometry ? "left 120ms cubic-bezier(0.22, 1, 0.36, 1), top 120ms cubic-bezier(0.22, 1, 0.36, 1)" : "none",
31754
+ willChange: shouldAnimateCanvasSelectionGeometry ? "left, top" : void 0,
31755
+ width: 8 * zoomFactor,
31756
+ zIndex: 25
31757
+ }
31758
+ }
31759
+ )
31760
+ ] });
31761
+ }
31762
+ const overlayPanes = [
31673
31763
  { pane: "scroll", style: canvasScrollOverlayPaneStyle, ref: canvasScrollOverlayContentRef, left: -drawingViewport.left - frozenPaneRight, top: -drawingViewport.top - frozenPaneBottom },
31674
31764
  { pane: "top", style: canvasTopOverlayPaneStyle, ref: canvasTopOverlayContentRef, left: -drawingViewport.left - frozenPaneRight, top: -displayHeaderHeight },
31675
31765
  { pane: "left", style: canvasLeftOverlayPaneStyle, ref: canvasLeftOverlayContentRef, left: -displayRowHeaderWidth, top: -drawingViewport.top - frozenPaneBottom },
31676
31766
  { pane: "corner", style: canvasCornerOverlayPaneStyle, ref: canvasCornerOverlayContentRef, left: -displayRowHeaderWidth, top: -displayHeaderHeight }
31677
- ].map(({ pane, style, ref, left, top }) => /* @__PURE__ */ jsx3("div", { style, children: /* @__PURE__ */ jsxs3(
31767
+ ];
31768
+ const selectionOverlayPanes = experimentalCanvas ? /* @__PURE__ */ jsx3("div", { style: { ...canvasBodyViewportLayerStyle, zIndex: 40 }, children: overlayPanes.map(({ pane, style, left, top }) => /* @__PURE__ */ jsx3("div", { style, children: /* @__PURE__ */ jsx3(
31769
+ "div",
31770
+ {
31771
+ ref: (element) => {
31772
+ if (element) {
31773
+ selectionPaneContentRefs.current.set(pane, element);
31774
+ } else {
31775
+ selectionPaneContentRefs.current.delete(pane);
31776
+ }
31777
+ },
31778
+ style: {
31779
+ height: sheetContentHeight,
31780
+ left: 0,
31781
+ position: "absolute",
31782
+ top: 0,
31783
+ transform: `translate(${left}px, ${top}px)`,
31784
+ transformOrigin: "0 0",
31785
+ width: totalWidth
31786
+ },
31787
+ children: renderSelectionOverlay(pane)
31788
+ }
31789
+ ) }, pane)) }) : null;
31790
+ const drawingOverlayPanes = experimentalCanvas && hasCanvasDomDrawingOverlays || rangeHighlightNodes.length > 0 ? /* @__PURE__ */ jsx3("div", { style: { ...canvasBodyViewportLayerStyle, zIndex: experimentalCanvas ? 23 : 34 }, children: overlayPanes.map(({ pane, style, ref, left, top }) => /* @__PURE__ */ jsx3("div", { style, children: /* @__PURE__ */ jsxs3(
31678
31791
  "div",
31679
31792
  {
31680
31793
  ref,
@@ -31728,6 +31841,7 @@ function XlsxGrid({
31728
31841
  /* @__PURE__ */ jsx3("div", { style: scrollOverlayStyle, children: paneDrawingNodes.scroll })
31729
31842
  ] }) : null,
31730
31843
  drawingOverlayPanes,
31844
+ selectionOverlayPanes,
31731
31845
  experimentalCanvas ? /* @__PURE__ */ jsxs3(Fragment4, { children: [
31732
31846
  /* @__PURE__ */ jsxs3("div", { style: canvasBodyViewportLayerStyle, children: [
31733
31847
  /* @__PURE__ */ jsx3(
@@ -32060,29 +32174,7 @@ function XlsxGrid({
32060
32174
  zIndex: 24
32061
32175
  },
32062
32176
  children: [
32063
- /* @__PURE__ */ jsx3(
32064
- "div",
32065
- {
32066
- ref: selectionOverlayRef,
32067
- style: {
32068
- backgroundColor: selectionFill,
32069
- boxSizing: "border-box",
32070
- boxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
32071
- contain: "layout paint",
32072
- height: resolvedSelectionOverlay?.height ?? 0,
32073
- left: resolvedSelectionOverlay?.left ?? 0,
32074
- opacity: resolvedSelectionOverlay ? 1 : 0,
32075
- pointerEvents: "none",
32076
- position: "absolute",
32077
- top: resolvedSelectionOverlay?.top ?? 0,
32078
- transition: canvasSelectionTransition,
32079
- visibility: resolvedSelectionOverlay ? "visible" : "hidden",
32080
- willChange: shouldAnimateCanvasSelectionGeometry ? "left, top, width, height" : void 0,
32081
- width: resolvedSelectionOverlay?.width ?? 0,
32082
- zIndex: 24
32083
- }
32084
- }
32085
- ),
32177
+ !experimentalCanvas ? renderSelectionOverlay() : null,
32086
32178
  activeCellOverlay != null && activeCellOverlayRect ? /* @__PURE__ */ jsx3(
32087
32179
  "div",
32088
32180
  {
@@ -32122,36 +32214,6 @@ function XlsxGrid({
32122
32214
  },
32123
32215
  children: "\u25BE"
32124
32216
  }
32125
- ),
32126
- /* @__PURE__ */ jsx3(
32127
- "div",
32128
- {
32129
- ref: fillHandleRef,
32130
- onPointerDown: (event) => {
32131
- if (readOnly || event.button !== 0 || !normalizedSelection || !resolvedSelectionOverlay) {
32132
- return;
32133
- }
32134
- event.preventDefault();
32135
- event.stopPropagation();
32136
- startFillDrag(event.pointerId, normalizedSelection);
32137
- },
32138
- style: {
32139
- backgroundColor: selectionStroke,
32140
- border: `${Math.max(1, zoomFactor)}px solid ${palette.surface}`,
32141
- contain: "layout paint",
32142
- cursor: "crosshair",
32143
- display: !readOnly && resolvedSelectionOverlay ? "block" : "none",
32144
- height: 8 * zoomFactor,
32145
- left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 * zoomFactor : 0,
32146
- pointerEvents: "auto",
32147
- position: "absolute",
32148
- top: resolvedSelectionOverlay ? resolvedSelectionOverlay.top + resolvedSelectionOverlay.height - 4 * zoomFactor : 0,
32149
- transition: shouldAnimateCanvasSelectionGeometry ? "left 120ms cubic-bezier(0.22, 1, 0.36, 1), top 120ms cubic-bezier(0.22, 1, 0.36, 1)" : "none",
32150
- willChange: shouldAnimateCanvasSelectionGeometry ? "left, top" : void 0,
32151
- width: 8 * zoomFactor,
32152
- zIndex: 25
32153
- }
32154
- }
32155
32217
  )
32156
32218
  ]
32157
32219
  }