@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.js
CHANGED
|
@@ -21573,8 +21573,10 @@ function XlsxGrid({
|
|
|
21573
21573
|
const resizeFrameRef = React4.useRef(null);
|
|
21574
21574
|
const pendingResizePreviewRef = React4.useRef(null);
|
|
21575
21575
|
const selectionDragRef = React4.useRef(null);
|
|
21576
|
+
const pendingSelectionDragRef = React4.useRef(null);
|
|
21576
21577
|
const fillDragRef = React4.useRef(null);
|
|
21577
21578
|
const selectionDragCleanupRef = React4.useRef(null);
|
|
21579
|
+
const pendingSelectionDragCleanupRef = React4.useRef(null);
|
|
21578
21580
|
const fillDragCleanupRef = React4.useRef(null);
|
|
21579
21581
|
const cachedScrollerRectRef = React4.useRef(null);
|
|
21580
21582
|
const imageInteractionCleanupRef = React4.useRef(null);
|
|
@@ -22508,7 +22510,7 @@ function XlsxGrid({
|
|
|
22508
22510
|
}, [displayedSelection]);
|
|
22509
22511
|
React4.useEffect(() => {
|
|
22510
22512
|
const previewRange = selectionPreviewRangeRef.current;
|
|
22511
|
-
if (!previewRange || selectionDragRef.current || fillDragRef.current) {
|
|
22513
|
+
if (!previewRange || pendingSelectionDragRef.current || selectionDragRef.current || fillDragRef.current) {
|
|
22512
22514
|
return;
|
|
22513
22515
|
}
|
|
22514
22516
|
if (normalizedSelection && rangesEqual(previewRange, normalizedSelection)) {
|
|
@@ -23115,14 +23117,17 @@ function XlsxGrid({
|
|
|
23115
23117
|
}
|
|
23116
23118
|
}, []);
|
|
23117
23119
|
React4.useEffect(() => {
|
|
23120
|
+
pendingSelectionDragCleanupRef.current?.();
|
|
23118
23121
|
selectionDragCleanupRef.current?.();
|
|
23119
23122
|
fillDragCleanupRef.current?.();
|
|
23120
23123
|
chartInteractionCleanupRef.current?.();
|
|
23121
23124
|
imageInteractionCleanupRef.current?.();
|
|
23125
|
+
pendingSelectionDragCleanupRef.current = null;
|
|
23122
23126
|
selectionDragCleanupRef.current = null;
|
|
23123
23127
|
fillDragCleanupRef.current = null;
|
|
23124
23128
|
chartInteractionCleanupRef.current = null;
|
|
23125
23129
|
imageInteractionCleanupRef.current = null;
|
|
23130
|
+
pendingSelectionDragRef.current = null;
|
|
23126
23131
|
selectionDragRef.current = null;
|
|
23127
23132
|
fillDragRef.current = null;
|
|
23128
23133
|
chartInteractionRef.current = null;
|
|
@@ -24313,6 +24318,101 @@ function XlsxGrid({
|
|
|
24313
24318
|
}
|
|
24314
24319
|
return normalizeRange2({ start: dragState.anchor, end: cell });
|
|
24315
24320
|
}
|
|
24321
|
+
function updateSelectionDragPreview(clientX, clientY) {
|
|
24322
|
+
const dragState = selectionDragRef.current;
|
|
24323
|
+
if (!dragState) {
|
|
24324
|
+
return;
|
|
24325
|
+
}
|
|
24326
|
+
const nextCell = resolveDraggedSelectionCell(dragState, clientX, clientY);
|
|
24327
|
+
if (!nextCell) {
|
|
24328
|
+
return;
|
|
24329
|
+
}
|
|
24330
|
+
const nextRange = buildDraggedSelectionRange(dragState, nextCell);
|
|
24331
|
+
if (!nextRange || rangesEqual(nextRange, dragState.previewRange)) {
|
|
24332
|
+
return;
|
|
24333
|
+
}
|
|
24334
|
+
dragState.previewRange = nextRange;
|
|
24335
|
+
selectionPreviewRangeRef.current = nextRange;
|
|
24336
|
+
displayedSelectionRef.current = nextRange;
|
|
24337
|
+
applyPreviewOverlay(nextRange);
|
|
24338
|
+
}
|
|
24339
|
+
function clearPendingSelectionDrag() {
|
|
24340
|
+
const cleanup = pendingSelectionDragCleanupRef.current;
|
|
24341
|
+
pendingSelectionDragCleanupRef.current = null;
|
|
24342
|
+
pendingSelectionDragRef.current = null;
|
|
24343
|
+
cleanup?.();
|
|
24344
|
+
}
|
|
24345
|
+
function finishPendingSelectionDrag() {
|
|
24346
|
+
const pendingState = pendingSelectionDragRef.current;
|
|
24347
|
+
clearPendingSelectionDrag();
|
|
24348
|
+
if (pendingState && !pendingState.committedOnPointerDown) {
|
|
24349
|
+
commitSelectionRange(pendingState.previewRange);
|
|
24350
|
+
}
|
|
24351
|
+
}
|
|
24352
|
+
function promotePendingSelectionDrag(clientX, clientY) {
|
|
24353
|
+
const pendingState = pendingSelectionDragRef.current;
|
|
24354
|
+
if (!pendingState) {
|
|
24355
|
+
return;
|
|
24356
|
+
}
|
|
24357
|
+
clearPendingSelectionDrag();
|
|
24358
|
+
cachedScrollerRectRef.current = scrollRef.current?.getBoundingClientRect() ?? null;
|
|
24359
|
+
pendingState.didDrag = true;
|
|
24360
|
+
selectionDragRef.current = pendingState;
|
|
24361
|
+
selectionPreviewRangeRef.current = pendingState.previewRange;
|
|
24362
|
+
displayedSelectionRef.current = pendingState.previewRange;
|
|
24363
|
+
setInteractionMode("select");
|
|
24364
|
+
document.body.style.userSelect = "none";
|
|
24365
|
+
installSelectionDragListeners(pendingState.pointerId);
|
|
24366
|
+
updateSelectionDragPreview(clientX, clientY);
|
|
24367
|
+
}
|
|
24368
|
+
function installPendingSelectionDragListeners(pointerId, target) {
|
|
24369
|
+
const existingCleanup = pendingSelectionDragCleanupRef.current;
|
|
24370
|
+
pendingSelectionDragCleanupRef.current = null;
|
|
24371
|
+
existingCleanup?.();
|
|
24372
|
+
const pointerTarget = target;
|
|
24373
|
+
try {
|
|
24374
|
+
pointerTarget.setPointerCapture?.(pointerId);
|
|
24375
|
+
} catch {
|
|
24376
|
+
}
|
|
24377
|
+
const handlePointerMove = (event) => {
|
|
24378
|
+
const pointerEvent = event;
|
|
24379
|
+
if (pointerEvent.pointerId !== pointerId) {
|
|
24380
|
+
return;
|
|
24381
|
+
}
|
|
24382
|
+
const pendingState = pendingSelectionDragRef.current;
|
|
24383
|
+
if (!pendingState) {
|
|
24384
|
+
return;
|
|
24385
|
+
}
|
|
24386
|
+
const deltaX = Math.abs(pointerEvent.clientX - pendingState.startClientX);
|
|
24387
|
+
const deltaY = Math.abs(pointerEvent.clientY - pendingState.startClientY);
|
|
24388
|
+
if (deltaX < SELECTION_DRAG_THRESHOLD_PX && deltaY < SELECTION_DRAG_THRESHOLD_PX) {
|
|
24389
|
+
return;
|
|
24390
|
+
}
|
|
24391
|
+
event.preventDefault();
|
|
24392
|
+
promotePendingSelectionDrag(pointerEvent.clientX, pointerEvent.clientY);
|
|
24393
|
+
};
|
|
24394
|
+
const handlePointerEnd = (event) => {
|
|
24395
|
+
const pointerEvent = event;
|
|
24396
|
+
if (pointerEvent.pointerId !== pointerId) {
|
|
24397
|
+
return;
|
|
24398
|
+
}
|
|
24399
|
+
finishPendingSelectionDrag();
|
|
24400
|
+
};
|
|
24401
|
+
target.addEventListener("pointermove", handlePointerMove);
|
|
24402
|
+
target.addEventListener("pointerup", handlePointerEnd);
|
|
24403
|
+
target.addEventListener("pointercancel", handlePointerEnd);
|
|
24404
|
+
pendingSelectionDragCleanupRef.current = () => {
|
|
24405
|
+
target.removeEventListener("pointermove", handlePointerMove);
|
|
24406
|
+
target.removeEventListener("pointerup", handlePointerEnd);
|
|
24407
|
+
target.removeEventListener("pointercancel", handlePointerEnd);
|
|
24408
|
+
try {
|
|
24409
|
+
if (pointerTarget.hasPointerCapture?.(pointerId)) {
|
|
24410
|
+
pointerTarget.releasePointerCapture?.(pointerId);
|
|
24411
|
+
}
|
|
24412
|
+
} catch {
|
|
24413
|
+
}
|
|
24414
|
+
};
|
|
24415
|
+
}
|
|
24316
24416
|
function installSelectionDragListeners(pointerId) {
|
|
24317
24417
|
selectionDragCleanupRef.current?.();
|
|
24318
24418
|
let pendingClientPoint = null;
|
|
@@ -24336,18 +24436,7 @@ function XlsxGrid({
|
|
|
24336
24436
|
}
|
|
24337
24437
|
dragState.didDrag = true;
|
|
24338
24438
|
}
|
|
24339
|
-
|
|
24340
|
-
if (!nextCell) {
|
|
24341
|
-
return;
|
|
24342
|
-
}
|
|
24343
|
-
const nextRange = buildDraggedSelectionRange(dragState, nextCell);
|
|
24344
|
-
if (!nextRange || rangesEqual(nextRange, dragState.previewRange)) {
|
|
24345
|
-
return;
|
|
24346
|
-
}
|
|
24347
|
-
dragState.previewRange = nextRange;
|
|
24348
|
-
selectionPreviewRangeRef.current = nextRange;
|
|
24349
|
-
displayedSelectionRef.current = nextRange;
|
|
24350
|
-
applyPreviewOverlay(nextRange);
|
|
24439
|
+
updateSelectionDragPreview(pendingPoint.x, pendingPoint.y);
|
|
24351
24440
|
};
|
|
24352
24441
|
const handlePointerMove = (event) => {
|
|
24353
24442
|
if (event.pointerId !== pointerId) {
|
|
@@ -24512,6 +24601,7 @@ function XlsxGrid({
|
|
|
24512
24601
|
return;
|
|
24513
24602
|
}
|
|
24514
24603
|
startCellSelection(
|
|
24604
|
+
event.currentTarget,
|
|
24515
24605
|
event.pointerId,
|
|
24516
24606
|
anchor,
|
|
24517
24607
|
"cell",
|
|
@@ -24559,6 +24649,7 @@ function XlsxGrid({
|
|
|
24559
24649
|
return;
|
|
24560
24650
|
}
|
|
24561
24651
|
startCellSelection(
|
|
24652
|
+
event.currentTarget,
|
|
24562
24653
|
event.pointerId,
|
|
24563
24654
|
{ row: anchorRow, col: firstVisibleCol },
|
|
24564
24655
|
"row",
|
|
@@ -24589,6 +24680,7 @@ function XlsxGrid({
|
|
|
24589
24680
|
return;
|
|
24590
24681
|
}
|
|
24591
24682
|
startCellSelection(
|
|
24683
|
+
event.currentTarget,
|
|
24592
24684
|
event.pointerId,
|
|
24593
24685
|
{ row: firstVisibleRow, col: anchorCol },
|
|
24594
24686
|
"column",
|
|
@@ -24870,6 +24962,7 @@ function XlsxGrid({
|
|
|
24870
24962
|
return;
|
|
24871
24963
|
}
|
|
24872
24964
|
startCellSelection(
|
|
24965
|
+
event.currentTarget,
|
|
24873
24966
|
event.pointerId,
|
|
24874
24967
|
anchor,
|
|
24875
24968
|
"cell",
|
|
@@ -24947,6 +25040,7 @@ function XlsxGrid({
|
|
|
24947
25040
|
return;
|
|
24948
25041
|
}
|
|
24949
25042
|
startCellSelection(
|
|
25043
|
+
event.currentTarget,
|
|
24950
25044
|
event.pointerId,
|
|
24951
25045
|
{ row: firstVisibleRow, col: anchorCol },
|
|
24952
25046
|
"column",
|
|
@@ -25004,6 +25098,7 @@ function XlsxGrid({
|
|
|
25004
25098
|
return;
|
|
25005
25099
|
}
|
|
25006
25100
|
startCellSelection(
|
|
25101
|
+
event.currentTarget,
|
|
25007
25102
|
event.pointerId,
|
|
25008
25103
|
{ row: anchorRow, col: firstVisibleCol },
|
|
25009
25104
|
"row",
|
|
@@ -27246,9 +27341,10 @@ function XlsxGrid({
|
|
|
27246
27341
|
setGlobalCursor("row-resize");
|
|
27247
27342
|
document.body.style.userSelect = "none";
|
|
27248
27343
|
}
|
|
27249
|
-
function startCellSelection(pointerId, anchor, axis, originCell, pointerOrigin, originOverlayRect, committedOnPointerDown, initialRange, startClientX, startClientY) {
|
|
27250
|
-
|
|
27251
|
-
|
|
27344
|
+
function startCellSelection(target, pointerId, anchor, axis, originCell, pointerOrigin, originOverlayRect, committedOnPointerDown, initialRange, startClientX, startClientY) {
|
|
27345
|
+
clearPendingSelectionDrag();
|
|
27346
|
+
const previewRange = normalizeRange2(initialRange);
|
|
27347
|
+
pendingSelectionDragRef.current = {
|
|
27252
27348
|
anchor,
|
|
27253
27349
|
axis,
|
|
27254
27350
|
contentScaleX: pointerOrigin.contentScaleX,
|
|
@@ -27260,16 +27356,14 @@ function XlsxGrid({
|
|
|
27260
27356
|
originContentX: pointerOrigin.originContentX,
|
|
27261
27357
|
originContentY: pointerOrigin.originContentY,
|
|
27262
27358
|
pointerId,
|
|
27263
|
-
previewRange
|
|
27359
|
+
previewRange,
|
|
27264
27360
|
startClientX,
|
|
27265
27361
|
startClientY
|
|
27266
27362
|
};
|
|
27267
|
-
selectionPreviewRangeRef.current =
|
|
27268
|
-
displayedSelectionRef.current =
|
|
27269
|
-
applyPreviewOverlay(
|
|
27270
|
-
|
|
27271
|
-
document.body.style.userSelect = "none";
|
|
27272
|
-
installSelectionDragListeners(pointerId);
|
|
27363
|
+
selectionPreviewRangeRef.current = previewRange;
|
|
27364
|
+
displayedSelectionRef.current = previewRange;
|
|
27365
|
+
applyPreviewOverlay(previewRange);
|
|
27366
|
+
installPendingSelectionDragListeners(pointerId, target);
|
|
27273
27367
|
}
|
|
27274
27368
|
function resolveFillRange(sourceRange, cell) {
|
|
27275
27369
|
const normalizedSource = normalizeRange2(sourceRange);
|