@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.cjs +142 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +142 -80
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24530,6 +24530,9 @@ function XlsxGrid({
|
|
|
24530
24530
|
const canvasCornerOverlayContentRef = React4.useRef(null);
|
|
24531
24531
|
const canvasImageCacheRef = React4.useRef(/* @__PURE__ */ new Map());
|
|
24532
24532
|
const selectionOverlayRef = React4.useRef(null);
|
|
24533
|
+
const selectionPaneContentRefs = React4.useRef(/* @__PURE__ */ new Map());
|
|
24534
|
+
const selectionPaneOverlayRefs = React4.useRef(/* @__PURE__ */ new Map());
|
|
24535
|
+
const selectionPaneFillHandleRefs = React4.useRef(/* @__PURE__ */ new Map());
|
|
24533
24536
|
const canvasSelectionLayerRef = React4.useRef(null);
|
|
24534
24537
|
const activeValidationOverlayRef = React4.useRef(null);
|
|
24535
24538
|
const fillHandleRef = React4.useRef(null);
|
|
@@ -24791,15 +24794,17 @@ function XlsxGrid({
|
|
|
24791
24794
|
shouldTransform ? "transform" : ""
|
|
24792
24795
|
);
|
|
24793
24796
|
};
|
|
24794
|
-
const applyOverlayTransform = (element, baseTranslateX, baseTranslateY, paneLeft, paneTop, anchorX, anchorY) => {
|
|
24797
|
+
const applyOverlayTransform = (pane, element, baseTranslateX, baseTranslateY, paneLeft, paneTop, anchorX, anchorY) => {
|
|
24795
24798
|
const translateX = resolveLiveTranslation(baseTranslateX, anchorX, paneLeft);
|
|
24796
24799
|
const translateY = resolveLiveTranslation(baseTranslateY, anchorY, paneTop);
|
|
24797
|
-
|
|
24798
|
-
|
|
24799
|
-
|
|
24800
|
-
|
|
24801
|
-
|
|
24802
|
-
|
|
24800
|
+
for (const content of [element, selectionPaneContentRefs.current.get(pane) ?? null]) {
|
|
24801
|
+
applyElementTransform(
|
|
24802
|
+
content,
|
|
24803
|
+
liveZoomScale2 !== 1 ? `translate3d(${translateX}px, ${translateY}px, 0) scale(${liveZoomScale2})` : `translate3d(${baseTranslateX}px, ${baseTranslateY}px, 0)`,
|
|
24804
|
+
"transform",
|
|
24805
|
+
"0 0"
|
|
24806
|
+
);
|
|
24807
|
+
}
|
|
24803
24808
|
};
|
|
24804
24809
|
const liveScrollBodyViewportWidth = Math.max(0, nextLiveViewport.width - liveFrozenPaneRight);
|
|
24805
24810
|
const liveScrollBodyViewportHeight = Math.max(0, nextLiveViewport.height - liveFrozenPaneBottom);
|
|
@@ -24896,6 +24901,7 @@ function XlsxGrid({
|
|
|
24896
24901
|
0
|
|
24897
24902
|
);
|
|
24898
24903
|
applyOverlayTransform(
|
|
24904
|
+
"scroll",
|
|
24899
24905
|
canvasScrollOverlayContentRef.current,
|
|
24900
24906
|
-nextLiveViewport.left - liveFrozenPaneRight,
|
|
24901
24907
|
-nextLiveViewport.top - liveFrozenPaneBottom,
|
|
@@ -24905,6 +24911,7 @@ function XlsxGrid({
|
|
|
24905
24911
|
liveZoomAnchorY
|
|
24906
24912
|
);
|
|
24907
24913
|
applyOverlayTransform(
|
|
24914
|
+
"top",
|
|
24908
24915
|
canvasTopOverlayContentRef.current,
|
|
24909
24916
|
-nextLiveViewport.left - liveFrozenPaneRight,
|
|
24910
24917
|
-liveDisplayHeaderHeight,
|
|
@@ -24914,6 +24921,7 @@ function XlsxGrid({
|
|
|
24914
24921
|
0
|
|
24915
24922
|
);
|
|
24916
24923
|
applyOverlayTransform(
|
|
24924
|
+
"left",
|
|
24917
24925
|
canvasLeftOverlayContentRef.current,
|
|
24918
24926
|
-liveDisplayRowHeaderWidth,
|
|
24919
24927
|
-nextLiveViewport.top - liveFrozenPaneBottom,
|
|
@@ -24923,6 +24931,7 @@ function XlsxGrid({
|
|
|
24923
24931
|
liveZoomAnchorY
|
|
24924
24932
|
);
|
|
24925
24933
|
applyOverlayTransform(
|
|
24934
|
+
"corner",
|
|
24926
24935
|
canvasCornerOverlayContentRef.current,
|
|
24927
24936
|
-liveDisplayRowHeaderWidth,
|
|
24928
24937
|
-liveDisplayHeaderHeight,
|
|
@@ -27536,36 +27545,46 @@ function XlsxGrid({
|
|
|
27536
27545
|
colHeaderCellRefs.current.delete(actualCol);
|
|
27537
27546
|
}, [experimentalCanvas, palette.headerSurface]);
|
|
27538
27547
|
const applyPreviewOverlay = React4.useCallback((range, options) => {
|
|
27539
|
-
const
|
|
27540
|
-
if (!
|
|
27548
|
+
const overlays = experimentalCanvas ? [...selectionPaneOverlayRefs.current.values()] : [selectionOverlayRef.current];
|
|
27549
|
+
if (!range) {
|
|
27541
27550
|
if (options?.updateHeaderSelection !== false) {
|
|
27542
27551
|
applyHeaderSelection(range);
|
|
27543
27552
|
}
|
|
27544
27553
|
return;
|
|
27545
27554
|
}
|
|
27546
|
-
const nextRect = options?.preferGeometry ? resolveGeometryOverlayRect(range) ?? resolveOverlayRect(range) : selectionDragRef.current?.didDrag || fillDragRef.current ? resolveDragPreviewRect(range) ?? resolveGeometryOverlayRect(range) ?? resolveOverlayRect(range) : resolveOverlayRect(range);
|
|
27555
|
+
const nextRect = experimentalCanvas || options?.preferGeometry ? resolveGeometryOverlayRect(range) ?? resolveOverlayRect(range) : selectionDragRef.current?.didDrag || fillDragRef.current ? resolveDragPreviewRect(range) ?? resolveGeometryOverlayRect(range) ?? resolveOverlayRect(range) : resolveOverlayRect(range);
|
|
27547
27556
|
if (!nextRect) {
|
|
27548
27557
|
if (options?.updateHeaderSelection !== false) {
|
|
27549
27558
|
applyHeaderSelection(range);
|
|
27550
27559
|
}
|
|
27551
27560
|
return;
|
|
27552
27561
|
}
|
|
27553
|
-
overlay
|
|
27554
|
-
|
|
27555
|
-
|
|
27556
|
-
|
|
27557
|
-
|
|
27558
|
-
|
|
27559
|
-
|
|
27560
|
-
|
|
27561
|
-
|
|
27562
|
-
|
|
27562
|
+
for (const overlay of overlays) {
|
|
27563
|
+
if (overlay) {
|
|
27564
|
+
overlay.style.left = `${nextRect.left}px`;
|
|
27565
|
+
overlay.style.top = `${nextRect.top}px`;
|
|
27566
|
+
overlay.style.width = `${nextRect.width}px`;
|
|
27567
|
+
overlay.style.height = `${nextRect.height}px`;
|
|
27568
|
+
overlay.style.opacity = "1";
|
|
27569
|
+
overlay.style.visibility = "visible";
|
|
27570
|
+
}
|
|
27571
|
+
}
|
|
27572
|
+
const fillHandles = experimentalCanvas ? [...selectionPaneFillHandleRefs.current.values()] : [fillHandleRef.current];
|
|
27573
|
+
for (const fillHandle of fillHandles) {
|
|
27574
|
+
if (fillHandle) {
|
|
27575
|
+
fillHandle.style.left = `${nextRect.left + nextRect.width - 4 * zoomFactor}px`;
|
|
27576
|
+
fillHandle.style.top = `${nextRect.top + nextRect.height - 4 * zoomFactor}px`;
|
|
27577
|
+
}
|
|
27563
27578
|
}
|
|
27564
27579
|
if (options?.updateHeaderSelection !== false) {
|
|
27565
27580
|
applyHeaderSelection(range);
|
|
27566
27581
|
}
|
|
27567
|
-
}, [applyHeaderSelection, resolveDragPreviewRect, resolveGeometryOverlayRect, resolveOverlayRect, zoomFactor]);
|
|
27582
|
+
}, [applyHeaderSelection, experimentalCanvas, resolveDragPreviewRect, resolveGeometryOverlayRect, resolveOverlayRect, zoomFactor]);
|
|
27568
27583
|
const applyPreviewOverlayFromElement = React4.useCallback((element, range) => {
|
|
27584
|
+
if (experimentalCanvas) {
|
|
27585
|
+
applyPreviewOverlay(range);
|
|
27586
|
+
return;
|
|
27587
|
+
}
|
|
27569
27588
|
const overlay = selectionOverlayRef.current;
|
|
27570
27589
|
if (!overlay) {
|
|
27571
27590
|
return;
|
|
@@ -27587,7 +27606,7 @@ function XlsxGrid({
|
|
|
27587
27606
|
fillHandle.style.top = `${nextRect.top + nextRect.height - 4 * zoomFactor}px`;
|
|
27588
27607
|
}
|
|
27589
27608
|
applyHeaderSelection(range);
|
|
27590
|
-
}, [applyHeaderSelection, resolveMountedCellOverlayRect, resolveOverlayRect, zoomFactor]);
|
|
27609
|
+
}, [applyHeaderSelection, applyPreviewOverlay, experimentalCanvas, resolveMountedCellOverlayRect, resolveOverlayRect, zoomFactor]);
|
|
27591
27610
|
const syncActiveValidationOverlay = React4.useCallback((cell) => {
|
|
27592
27611
|
const overlay = activeValidationOverlayRef.current;
|
|
27593
27612
|
if (!overlay || !cell || editingCellRef.current || selectionDragRef.current || fillDragRef.current) {
|
|
@@ -28021,9 +28040,11 @@ function XlsxGrid({
|
|
|
28021
28040
|
const overlayRange = selectionPreviewRangeRef.current ?? displayedSelection;
|
|
28022
28041
|
if (!overlayRange || !wrapperRef.current) {
|
|
28023
28042
|
applyHeaderSelection(null);
|
|
28024
|
-
|
|
28025
|
-
|
|
28026
|
-
|
|
28043
|
+
for (const overlay of [selectionOverlayRef.current, ...selectionPaneOverlayRefs.current.values()]) {
|
|
28044
|
+
if (overlay) {
|
|
28045
|
+
overlay.style.opacity = "0";
|
|
28046
|
+
overlay.style.visibility = "hidden";
|
|
28047
|
+
}
|
|
28027
28048
|
}
|
|
28028
28049
|
return;
|
|
28029
28050
|
}
|
|
@@ -31704,12 +31725,104 @@ function XlsxGrid({
|
|
|
31704
31725
|
index
|
|
31705
31726
|
)
|
|
31706
31727
|
] : []);
|
|
31707
|
-
|
|
31728
|
+
function renderSelectionOverlay(pane) {
|
|
31729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
31730
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
31731
|
+
"div",
|
|
31732
|
+
{
|
|
31733
|
+
ref: pane ? (element) => {
|
|
31734
|
+
if (element) {
|
|
31735
|
+
selectionPaneOverlayRefs.current.set(pane, element);
|
|
31736
|
+
} else {
|
|
31737
|
+
selectionPaneOverlayRefs.current.delete(pane);
|
|
31738
|
+
}
|
|
31739
|
+
} : selectionOverlayRef,
|
|
31740
|
+
style: {
|
|
31741
|
+
backgroundColor: selectionFill,
|
|
31742
|
+
boxSizing: "border-box",
|
|
31743
|
+
boxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
|
|
31744
|
+
contain: "layout paint",
|
|
31745
|
+
height: resolvedSelectionOverlay?.height ?? 0,
|
|
31746
|
+
left: resolvedSelectionOverlay?.left ?? 0,
|
|
31747
|
+
opacity: resolvedSelectionOverlay ? 1 : 0,
|
|
31748
|
+
pointerEvents: "none",
|
|
31749
|
+
position: "absolute",
|
|
31750
|
+
top: resolvedSelectionOverlay?.top ?? 0,
|
|
31751
|
+
transition: canvasSelectionTransition,
|
|
31752
|
+
visibility: resolvedSelectionOverlay ? "visible" : "hidden",
|
|
31753
|
+
willChange: shouldAnimateCanvasSelectionGeometry ? "left, top, width, height" : void 0,
|
|
31754
|
+
width: resolvedSelectionOverlay?.width ?? 0,
|
|
31755
|
+
zIndex: 24
|
|
31756
|
+
}
|
|
31757
|
+
}
|
|
31758
|
+
),
|
|
31759
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
31760
|
+
"div",
|
|
31761
|
+
{
|
|
31762
|
+
ref: pane ? (element) => {
|
|
31763
|
+
if (element) {
|
|
31764
|
+
selectionPaneFillHandleRefs.current.set(pane, element);
|
|
31765
|
+
} else {
|
|
31766
|
+
selectionPaneFillHandleRefs.current.delete(pane);
|
|
31767
|
+
}
|
|
31768
|
+
} : fillHandleRef,
|
|
31769
|
+
onPointerDown: (event) => {
|
|
31770
|
+
if (readOnly || event.button !== 0 || !normalizedSelection || !resolvedSelectionOverlay) {
|
|
31771
|
+
return;
|
|
31772
|
+
}
|
|
31773
|
+
event.preventDefault();
|
|
31774
|
+
event.stopPropagation();
|
|
31775
|
+
startFillDrag(event.pointerId, normalizedSelection);
|
|
31776
|
+
},
|
|
31777
|
+
style: {
|
|
31778
|
+
backgroundColor: selectionStroke,
|
|
31779
|
+
border: `${Math.max(1, zoomFactor)}px solid ${palette.surface}`,
|
|
31780
|
+
contain: "layout paint",
|
|
31781
|
+
cursor: "crosshair",
|
|
31782
|
+
display: !readOnly && resolvedSelectionOverlay ? "block" : "none",
|
|
31783
|
+
height: 8 * zoomFactor,
|
|
31784
|
+
left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 * zoomFactor : 0,
|
|
31785
|
+
pointerEvents: "auto",
|
|
31786
|
+
position: "absolute",
|
|
31787
|
+
top: resolvedSelectionOverlay ? resolvedSelectionOverlay.top + resolvedSelectionOverlay.height - 4 * zoomFactor : 0,
|
|
31788
|
+
transition: shouldAnimateCanvasSelectionGeometry ? "left 120ms cubic-bezier(0.22, 1, 0.36, 1), top 120ms cubic-bezier(0.22, 1, 0.36, 1)" : "none",
|
|
31789
|
+
willChange: shouldAnimateCanvasSelectionGeometry ? "left, top" : void 0,
|
|
31790
|
+
width: 8 * zoomFactor,
|
|
31791
|
+
zIndex: 25
|
|
31792
|
+
}
|
|
31793
|
+
}
|
|
31794
|
+
)
|
|
31795
|
+
] });
|
|
31796
|
+
}
|
|
31797
|
+
const overlayPanes = [
|
|
31708
31798
|
{ pane: "scroll", style: canvasScrollOverlayPaneStyle, ref: canvasScrollOverlayContentRef, left: -drawingViewport.left - frozenPaneRight, top: -drawingViewport.top - frozenPaneBottom },
|
|
31709
31799
|
{ pane: "top", style: canvasTopOverlayPaneStyle, ref: canvasTopOverlayContentRef, left: -drawingViewport.left - frozenPaneRight, top: -displayHeaderHeight },
|
|
31710
31800
|
{ pane: "left", style: canvasLeftOverlayPaneStyle, ref: canvasLeftOverlayContentRef, left: -displayRowHeaderWidth, top: -drawingViewport.top - frozenPaneBottom },
|
|
31711
31801
|
{ pane: "corner", style: canvasCornerOverlayPaneStyle, ref: canvasCornerOverlayContentRef, left: -displayRowHeaderWidth, top: -displayHeaderHeight }
|
|
31712
|
-
]
|
|
31802
|
+
];
|
|
31803
|
+
const selectionOverlayPanes = experimentalCanvas ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { ...canvasBodyViewportLayerStyle, zIndex: 40 }, children: overlayPanes.map(({ pane, style, left, top }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
31804
|
+
"div",
|
|
31805
|
+
{
|
|
31806
|
+
ref: (element) => {
|
|
31807
|
+
if (element) {
|
|
31808
|
+
selectionPaneContentRefs.current.set(pane, element);
|
|
31809
|
+
} else {
|
|
31810
|
+
selectionPaneContentRefs.current.delete(pane);
|
|
31811
|
+
}
|
|
31812
|
+
},
|
|
31813
|
+
style: {
|
|
31814
|
+
height: sheetContentHeight,
|
|
31815
|
+
left: 0,
|
|
31816
|
+
position: "absolute",
|
|
31817
|
+
top: 0,
|
|
31818
|
+
transform: `translate(${left}px, ${top}px)`,
|
|
31819
|
+
transformOrigin: "0 0",
|
|
31820
|
+
width: totalWidth
|
|
31821
|
+
},
|
|
31822
|
+
children: renderSelectionOverlay(pane)
|
|
31823
|
+
}
|
|
31824
|
+
) }, pane)) }) : null;
|
|
31825
|
+
const drawingOverlayPanes = experimentalCanvas && hasCanvasDomDrawingOverlays || rangeHighlightNodes.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { ...canvasBodyViewportLayerStyle, zIndex: experimentalCanvas ? 23 : 34 }, children: overlayPanes.map(({ pane, style, ref, left, top }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
31713
31826
|
"div",
|
|
31714
31827
|
{
|
|
31715
31828
|
ref,
|
|
@@ -31763,6 +31876,7 @@ function XlsxGrid({
|
|
|
31763
31876
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: scrollOverlayStyle, children: paneDrawingNodes.scroll })
|
|
31764
31877
|
] }) : null,
|
|
31765
31878
|
drawingOverlayPanes,
|
|
31879
|
+
selectionOverlayPanes,
|
|
31766
31880
|
experimentalCanvas ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
31767
31881
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: canvasBodyViewportLayerStyle, children: [
|
|
31768
31882
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -32095,29 +32209,7 @@ function XlsxGrid({
|
|
|
32095
32209
|
zIndex: 24
|
|
32096
32210
|
},
|
|
32097
32211
|
children: [
|
|
32098
|
-
|
|
32099
|
-
"div",
|
|
32100
|
-
{
|
|
32101
|
-
ref: selectionOverlayRef,
|
|
32102
|
-
style: {
|
|
32103
|
-
backgroundColor: selectionFill,
|
|
32104
|
-
boxSizing: "border-box",
|
|
32105
|
-
boxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
|
|
32106
|
-
contain: "layout paint",
|
|
32107
|
-
height: resolvedSelectionOverlay?.height ?? 0,
|
|
32108
|
-
left: resolvedSelectionOverlay?.left ?? 0,
|
|
32109
|
-
opacity: resolvedSelectionOverlay ? 1 : 0,
|
|
32110
|
-
pointerEvents: "none",
|
|
32111
|
-
position: "absolute",
|
|
32112
|
-
top: resolvedSelectionOverlay?.top ?? 0,
|
|
32113
|
-
transition: canvasSelectionTransition,
|
|
32114
|
-
visibility: resolvedSelectionOverlay ? "visible" : "hidden",
|
|
32115
|
-
willChange: shouldAnimateCanvasSelectionGeometry ? "left, top, width, height" : void 0,
|
|
32116
|
-
width: resolvedSelectionOverlay?.width ?? 0,
|
|
32117
|
-
zIndex: 24
|
|
32118
|
-
}
|
|
32119
|
-
}
|
|
32120
|
-
),
|
|
32212
|
+
!experimentalCanvas ? renderSelectionOverlay() : null,
|
|
32121
32213
|
activeCellOverlay != null && activeCellOverlayRect ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
32122
32214
|
"div",
|
|
32123
32215
|
{
|
|
@@ -32157,36 +32249,6 @@ function XlsxGrid({
|
|
|
32157
32249
|
},
|
|
32158
32250
|
children: "\u25BE"
|
|
32159
32251
|
}
|
|
32160
|
-
),
|
|
32161
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
32162
|
-
"div",
|
|
32163
|
-
{
|
|
32164
|
-
ref: fillHandleRef,
|
|
32165
|
-
onPointerDown: (event) => {
|
|
32166
|
-
if (readOnly || event.button !== 0 || !normalizedSelection || !resolvedSelectionOverlay) {
|
|
32167
|
-
return;
|
|
32168
|
-
}
|
|
32169
|
-
event.preventDefault();
|
|
32170
|
-
event.stopPropagation();
|
|
32171
|
-
startFillDrag(event.pointerId, normalizedSelection);
|
|
32172
|
-
},
|
|
32173
|
-
style: {
|
|
32174
|
-
backgroundColor: selectionStroke,
|
|
32175
|
-
border: `${Math.max(1, zoomFactor)}px solid ${palette.surface}`,
|
|
32176
|
-
contain: "layout paint",
|
|
32177
|
-
cursor: "crosshair",
|
|
32178
|
-
display: !readOnly && resolvedSelectionOverlay ? "block" : "none",
|
|
32179
|
-
height: 8 * zoomFactor,
|
|
32180
|
-
left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 * zoomFactor : 0,
|
|
32181
|
-
pointerEvents: "auto",
|
|
32182
|
-
position: "absolute",
|
|
32183
|
-
top: resolvedSelectionOverlay ? resolvedSelectionOverlay.top + resolvedSelectionOverlay.height - 4 * zoomFactor : 0,
|
|
32184
|
-
transition: shouldAnimateCanvasSelectionGeometry ? "left 120ms cubic-bezier(0.22, 1, 0.36, 1), top 120ms cubic-bezier(0.22, 1, 0.36, 1)" : "none",
|
|
32185
|
-
willChange: shouldAnimateCanvasSelectionGeometry ? "left, top" : void 0,
|
|
32186
|
-
width: 8 * zoomFactor,
|
|
32187
|
-
zIndex: 25
|
|
32188
|
-
}
|
|
32189
|
-
}
|
|
32190
32252
|
)
|
|
32191
32253
|
]
|
|
32192
32254
|
}
|