@extend-ai/react-xlsx 0.9.1 → 0.9.2
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 +117 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +117 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21605,8 +21605,10 @@ function XlsxGrid({
|
|
|
21605
21605
|
const resizeFrameRef = React4.useRef(null);
|
|
21606
21606
|
const pendingResizePreviewRef = React4.useRef(null);
|
|
21607
21607
|
const selectionDragRef = React4.useRef(null);
|
|
21608
|
+
const pendingSelectionDragRef = React4.useRef(null);
|
|
21608
21609
|
const fillDragRef = React4.useRef(null);
|
|
21609
21610
|
const selectionDragCleanupRef = React4.useRef(null);
|
|
21611
|
+
const pendingSelectionDragCleanupRef = React4.useRef(null);
|
|
21610
21612
|
const fillDragCleanupRef = React4.useRef(null);
|
|
21611
21613
|
const cachedScrollerRectRef = React4.useRef(null);
|
|
21612
21614
|
const imageInteractionCleanupRef = React4.useRef(null);
|
|
@@ -22540,7 +22542,7 @@ function XlsxGrid({
|
|
|
22540
22542
|
}, [displayedSelection]);
|
|
22541
22543
|
React4.useEffect(() => {
|
|
22542
22544
|
const previewRange = selectionPreviewRangeRef.current;
|
|
22543
|
-
if (!previewRange || selectionDragRef.current || fillDragRef.current) {
|
|
22545
|
+
if (!previewRange || pendingSelectionDragRef.current || selectionDragRef.current || fillDragRef.current) {
|
|
22544
22546
|
return;
|
|
22545
22547
|
}
|
|
22546
22548
|
if (normalizedSelection && rangesEqual(previewRange, normalizedSelection)) {
|
|
@@ -23147,14 +23149,17 @@ function XlsxGrid({
|
|
|
23147
23149
|
}
|
|
23148
23150
|
}, []);
|
|
23149
23151
|
React4.useEffect(() => {
|
|
23152
|
+
pendingSelectionDragCleanupRef.current?.();
|
|
23150
23153
|
selectionDragCleanupRef.current?.();
|
|
23151
23154
|
fillDragCleanupRef.current?.();
|
|
23152
23155
|
chartInteractionCleanupRef.current?.();
|
|
23153
23156
|
imageInteractionCleanupRef.current?.();
|
|
23157
|
+
pendingSelectionDragCleanupRef.current = null;
|
|
23154
23158
|
selectionDragCleanupRef.current = null;
|
|
23155
23159
|
fillDragCleanupRef.current = null;
|
|
23156
23160
|
chartInteractionCleanupRef.current = null;
|
|
23157
23161
|
imageInteractionCleanupRef.current = null;
|
|
23162
|
+
pendingSelectionDragRef.current = null;
|
|
23158
23163
|
selectionDragRef.current = null;
|
|
23159
23164
|
fillDragRef.current = null;
|
|
23160
23165
|
chartInteractionRef.current = null;
|
|
@@ -24345,6 +24350,101 @@ function XlsxGrid({
|
|
|
24345
24350
|
}
|
|
24346
24351
|
return normalizeRange2({ start: dragState.anchor, end: cell });
|
|
24347
24352
|
}
|
|
24353
|
+
function updateSelectionDragPreview(clientX, clientY) {
|
|
24354
|
+
const dragState = selectionDragRef.current;
|
|
24355
|
+
if (!dragState) {
|
|
24356
|
+
return;
|
|
24357
|
+
}
|
|
24358
|
+
const nextCell = resolveDraggedSelectionCell(dragState, clientX, clientY);
|
|
24359
|
+
if (!nextCell) {
|
|
24360
|
+
return;
|
|
24361
|
+
}
|
|
24362
|
+
const nextRange = buildDraggedSelectionRange(dragState, nextCell);
|
|
24363
|
+
if (!nextRange || rangesEqual(nextRange, dragState.previewRange)) {
|
|
24364
|
+
return;
|
|
24365
|
+
}
|
|
24366
|
+
dragState.previewRange = nextRange;
|
|
24367
|
+
selectionPreviewRangeRef.current = nextRange;
|
|
24368
|
+
displayedSelectionRef.current = nextRange;
|
|
24369
|
+
applyPreviewOverlay(nextRange);
|
|
24370
|
+
}
|
|
24371
|
+
function clearPendingSelectionDrag() {
|
|
24372
|
+
const cleanup = pendingSelectionDragCleanupRef.current;
|
|
24373
|
+
pendingSelectionDragCleanupRef.current = null;
|
|
24374
|
+
pendingSelectionDragRef.current = null;
|
|
24375
|
+
cleanup?.();
|
|
24376
|
+
}
|
|
24377
|
+
function finishPendingSelectionDrag() {
|
|
24378
|
+
const pendingState = pendingSelectionDragRef.current;
|
|
24379
|
+
clearPendingSelectionDrag();
|
|
24380
|
+
if (pendingState && !pendingState.committedOnPointerDown) {
|
|
24381
|
+
commitSelectionRange(pendingState.previewRange);
|
|
24382
|
+
}
|
|
24383
|
+
}
|
|
24384
|
+
function promotePendingSelectionDrag(clientX, clientY) {
|
|
24385
|
+
const pendingState = pendingSelectionDragRef.current;
|
|
24386
|
+
if (!pendingState) {
|
|
24387
|
+
return;
|
|
24388
|
+
}
|
|
24389
|
+
clearPendingSelectionDrag();
|
|
24390
|
+
cachedScrollerRectRef.current = scrollRef.current?.getBoundingClientRect() ?? null;
|
|
24391
|
+
pendingState.didDrag = true;
|
|
24392
|
+
selectionDragRef.current = pendingState;
|
|
24393
|
+
selectionPreviewRangeRef.current = pendingState.previewRange;
|
|
24394
|
+
displayedSelectionRef.current = pendingState.previewRange;
|
|
24395
|
+
setInteractionMode("select");
|
|
24396
|
+
document.body.style.userSelect = "none";
|
|
24397
|
+
installSelectionDragListeners(pendingState.pointerId);
|
|
24398
|
+
updateSelectionDragPreview(clientX, clientY);
|
|
24399
|
+
}
|
|
24400
|
+
function installPendingSelectionDragListeners(pointerId, target) {
|
|
24401
|
+
const existingCleanup = pendingSelectionDragCleanupRef.current;
|
|
24402
|
+
pendingSelectionDragCleanupRef.current = null;
|
|
24403
|
+
existingCleanup?.();
|
|
24404
|
+
const pointerTarget = target;
|
|
24405
|
+
try {
|
|
24406
|
+
pointerTarget.setPointerCapture?.(pointerId);
|
|
24407
|
+
} catch {
|
|
24408
|
+
}
|
|
24409
|
+
const handlePointerMove = (event) => {
|
|
24410
|
+
const pointerEvent = event;
|
|
24411
|
+
if (pointerEvent.pointerId !== pointerId) {
|
|
24412
|
+
return;
|
|
24413
|
+
}
|
|
24414
|
+
const pendingState = pendingSelectionDragRef.current;
|
|
24415
|
+
if (!pendingState) {
|
|
24416
|
+
return;
|
|
24417
|
+
}
|
|
24418
|
+
const deltaX = Math.abs(pointerEvent.clientX - pendingState.startClientX);
|
|
24419
|
+
const deltaY = Math.abs(pointerEvent.clientY - pendingState.startClientY);
|
|
24420
|
+
if (deltaX < SELECTION_DRAG_THRESHOLD_PX && deltaY < SELECTION_DRAG_THRESHOLD_PX) {
|
|
24421
|
+
return;
|
|
24422
|
+
}
|
|
24423
|
+
event.preventDefault();
|
|
24424
|
+
promotePendingSelectionDrag(pointerEvent.clientX, pointerEvent.clientY);
|
|
24425
|
+
};
|
|
24426
|
+
const handlePointerEnd = (event) => {
|
|
24427
|
+
const pointerEvent = event;
|
|
24428
|
+
if (pointerEvent.pointerId !== pointerId) {
|
|
24429
|
+
return;
|
|
24430
|
+
}
|
|
24431
|
+
finishPendingSelectionDrag();
|
|
24432
|
+
};
|
|
24433
|
+
target.addEventListener("pointermove", handlePointerMove);
|
|
24434
|
+
target.addEventListener("pointerup", handlePointerEnd);
|
|
24435
|
+
target.addEventListener("pointercancel", handlePointerEnd);
|
|
24436
|
+
pendingSelectionDragCleanupRef.current = () => {
|
|
24437
|
+
target.removeEventListener("pointermove", handlePointerMove);
|
|
24438
|
+
target.removeEventListener("pointerup", handlePointerEnd);
|
|
24439
|
+
target.removeEventListener("pointercancel", handlePointerEnd);
|
|
24440
|
+
try {
|
|
24441
|
+
if (pointerTarget.hasPointerCapture?.(pointerId)) {
|
|
24442
|
+
pointerTarget.releasePointerCapture?.(pointerId);
|
|
24443
|
+
}
|
|
24444
|
+
} catch {
|
|
24445
|
+
}
|
|
24446
|
+
};
|
|
24447
|
+
}
|
|
24348
24448
|
function installSelectionDragListeners(pointerId) {
|
|
24349
24449
|
selectionDragCleanupRef.current?.();
|
|
24350
24450
|
let pendingClientPoint = null;
|
|
@@ -24368,18 +24468,7 @@ function XlsxGrid({
|
|
|
24368
24468
|
}
|
|
24369
24469
|
dragState.didDrag = true;
|
|
24370
24470
|
}
|
|
24371
|
-
|
|
24372
|
-
if (!nextCell) {
|
|
24373
|
-
return;
|
|
24374
|
-
}
|
|
24375
|
-
const nextRange = buildDraggedSelectionRange(dragState, nextCell);
|
|
24376
|
-
if (!nextRange || rangesEqual(nextRange, dragState.previewRange)) {
|
|
24377
|
-
return;
|
|
24378
|
-
}
|
|
24379
|
-
dragState.previewRange = nextRange;
|
|
24380
|
-
selectionPreviewRangeRef.current = nextRange;
|
|
24381
|
-
displayedSelectionRef.current = nextRange;
|
|
24382
|
-
applyPreviewOverlay(nextRange);
|
|
24471
|
+
updateSelectionDragPreview(pendingPoint.x, pendingPoint.y);
|
|
24383
24472
|
};
|
|
24384
24473
|
const handlePointerMove = (event) => {
|
|
24385
24474
|
if (event.pointerId !== pointerId) {
|
|
@@ -24544,6 +24633,7 @@ function XlsxGrid({
|
|
|
24544
24633
|
return;
|
|
24545
24634
|
}
|
|
24546
24635
|
startCellSelection(
|
|
24636
|
+
event.currentTarget,
|
|
24547
24637
|
event.pointerId,
|
|
24548
24638
|
anchor,
|
|
24549
24639
|
"cell",
|
|
@@ -24591,6 +24681,7 @@ function XlsxGrid({
|
|
|
24591
24681
|
return;
|
|
24592
24682
|
}
|
|
24593
24683
|
startCellSelection(
|
|
24684
|
+
event.currentTarget,
|
|
24594
24685
|
event.pointerId,
|
|
24595
24686
|
{ row: anchorRow, col: firstVisibleCol },
|
|
24596
24687
|
"row",
|
|
@@ -24621,6 +24712,7 @@ function XlsxGrid({
|
|
|
24621
24712
|
return;
|
|
24622
24713
|
}
|
|
24623
24714
|
startCellSelection(
|
|
24715
|
+
event.currentTarget,
|
|
24624
24716
|
event.pointerId,
|
|
24625
24717
|
{ row: firstVisibleRow, col: anchorCol },
|
|
24626
24718
|
"column",
|
|
@@ -24902,6 +24994,7 @@ function XlsxGrid({
|
|
|
24902
24994
|
return;
|
|
24903
24995
|
}
|
|
24904
24996
|
startCellSelection(
|
|
24997
|
+
event.currentTarget,
|
|
24905
24998
|
event.pointerId,
|
|
24906
24999
|
anchor,
|
|
24907
25000
|
"cell",
|
|
@@ -24979,6 +25072,7 @@ function XlsxGrid({
|
|
|
24979
25072
|
return;
|
|
24980
25073
|
}
|
|
24981
25074
|
startCellSelection(
|
|
25075
|
+
event.currentTarget,
|
|
24982
25076
|
event.pointerId,
|
|
24983
25077
|
{ row: firstVisibleRow, col: anchorCol },
|
|
24984
25078
|
"column",
|
|
@@ -25036,6 +25130,7 @@ function XlsxGrid({
|
|
|
25036
25130
|
return;
|
|
25037
25131
|
}
|
|
25038
25132
|
startCellSelection(
|
|
25133
|
+
event.currentTarget,
|
|
25039
25134
|
event.pointerId,
|
|
25040
25135
|
{ row: anchorRow, col: firstVisibleCol },
|
|
25041
25136
|
"row",
|
|
@@ -27278,9 +27373,10 @@ function XlsxGrid({
|
|
|
27278
27373
|
setGlobalCursor("row-resize");
|
|
27279
27374
|
document.body.style.userSelect = "none";
|
|
27280
27375
|
}
|
|
27281
|
-
function startCellSelection(pointerId, anchor, axis, originCell, pointerOrigin, originOverlayRect, committedOnPointerDown, initialRange, startClientX, startClientY) {
|
|
27282
|
-
|
|
27283
|
-
|
|
27376
|
+
function startCellSelection(target, pointerId, anchor, axis, originCell, pointerOrigin, originOverlayRect, committedOnPointerDown, initialRange, startClientX, startClientY) {
|
|
27377
|
+
clearPendingSelectionDrag();
|
|
27378
|
+
const previewRange = normalizeRange2(initialRange);
|
|
27379
|
+
pendingSelectionDragRef.current = {
|
|
27284
27380
|
anchor,
|
|
27285
27381
|
axis,
|
|
27286
27382
|
contentScaleX: pointerOrigin.contentScaleX,
|
|
@@ -27292,16 +27388,14 @@ function XlsxGrid({
|
|
|
27292
27388
|
originContentX: pointerOrigin.originContentX,
|
|
27293
27389
|
originContentY: pointerOrigin.originContentY,
|
|
27294
27390
|
pointerId,
|
|
27295
|
-
previewRange
|
|
27391
|
+
previewRange,
|
|
27296
27392
|
startClientX,
|
|
27297
27393
|
startClientY
|
|
27298
27394
|
};
|
|
27299
|
-
selectionPreviewRangeRef.current =
|
|
27300
|
-
displayedSelectionRef.current =
|
|
27301
|
-
applyPreviewOverlay(
|
|
27302
|
-
|
|
27303
|
-
document.body.style.userSelect = "none";
|
|
27304
|
-
installSelectionDragListeners(pointerId);
|
|
27395
|
+
selectionPreviewRangeRef.current = previewRange;
|
|
27396
|
+
displayedSelectionRef.current = previewRange;
|
|
27397
|
+
applyPreviewOverlay(previewRange);
|
|
27398
|
+
installPendingSelectionDragListeners(pointerId, target);
|
|
27305
27399
|
}
|
|
27306
27400
|
function resolveFillRange(sourceRange, cell) {
|
|
27307
27401
|
const normalizedSource = normalizeRange2(sourceRange);
|