@extend-ai/react-xlsx 0.8.2 → 0.8.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 +71 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +213 -0
- package/dist/index.d.ts +213 -0
- package/dist/index.js +71 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20988,7 +20988,7 @@ function XlsxGrid({
|
|
|
20988
20988
|
renderImageSelection,
|
|
20989
20989
|
renderTableHeaderMenu,
|
|
20990
20990
|
enableGestureZoom = true,
|
|
20991
|
-
experimentalCanvas =
|
|
20991
|
+
experimentalCanvas = true,
|
|
20992
20992
|
selectionColor,
|
|
20993
20993
|
selectionFillColor,
|
|
20994
20994
|
selectionHeaderColor,
|
|
@@ -22428,17 +22428,17 @@ function XlsxGrid({
|
|
|
22428
22428
|
}, []);
|
|
22429
22429
|
const resolvePointerCellFromClient = React4.useCallback((clientX, clientY) => {
|
|
22430
22430
|
const geometryCell = resolvePointerCellFromGeometry(clientX, clientY);
|
|
22431
|
-
if (geometryCell
|
|
22432
|
-
return
|
|
22431
|
+
if (geometryCell) {
|
|
22432
|
+
return geometryCell;
|
|
22433
22433
|
}
|
|
22434
|
-
const resolvedCell = resolvePointerCellFromHitTest(clientX, clientY)
|
|
22434
|
+
const resolvedCell = resolvePointerCellFromHitTest(clientX, clientY);
|
|
22435
22435
|
return resolvedCell ? resolveMergeAnchorCell(resolvedCell) : null;
|
|
22436
|
-
}, [resolveMergeAnchorCell, resolvePointerCellFromGeometry, resolvePointerCellFromHitTest
|
|
22436
|
+
}, [resolveMergeAnchorCell, resolvePointerCellFromGeometry, resolvePointerCellFromHitTest]);
|
|
22437
22437
|
const resolveDraggedSelectionCell = React4.useCallback((dragState, clientX, clientY) => {
|
|
22438
22438
|
const geometryCell = resolvePointerCellFromGeometry(clientX, clientY);
|
|
22439
22439
|
const hitCell = resolvePointerCellFromHitTest(clientX, clientY);
|
|
22440
|
-
const actualRow = hitCell && rowIndexByActual.has(hitCell.row) ? hitCell.row :
|
|
22441
|
-
const actualCol =
|
|
22440
|
+
const actualRow = geometryCell?.row ?? (hitCell && rowIndexByActual.has(hitCell.row) ? hitCell.row : void 0);
|
|
22441
|
+
const actualCol = geometryCell?.col ?? hitCell?.col;
|
|
22442
22442
|
if (actualRow === void 0 || actualCol === void 0) {
|
|
22443
22443
|
return null;
|
|
22444
22444
|
}
|
|
@@ -22448,8 +22448,8 @@ function XlsxGrid({
|
|
|
22448
22448
|
if (dragState.axis === "column") {
|
|
22449
22449
|
return { row: dragState.originCell.row, col: actualCol };
|
|
22450
22450
|
}
|
|
22451
|
-
return
|
|
22452
|
-
}, [
|
|
22451
|
+
return { row: actualRow, col: actualCol };
|
|
22452
|
+
}, [resolvePointerCellFromGeometry, resolvePointerCellFromHitTest, rowIndexByActual]);
|
|
22453
22453
|
const resolveCellPointerOrigin = React4.useCallback((cell, rect, clientX, clientY) => {
|
|
22454
22454
|
const rowIndex = rowIndexByActual.get(cell.row);
|
|
22455
22455
|
const colIndex = colIndexByActual.get(cell.col);
|
|
@@ -22467,6 +22467,40 @@ function XlsxGrid({
|
|
|
22467
22467
|
originContentY: (rowPrefixSums[rowIndex] ?? 0) + clampContentOffset((clientY - rect.top) / contentScaleY, displayHeight)
|
|
22468
22468
|
};
|
|
22469
22469
|
}, [colIndexByActual, colPrefixSums, displayDefaultColWidth, displayDefaultRowHeight, displayEffectiveColWidths, displayEffectiveRowHeights, rowIndexByActual, rowPrefixSums]);
|
|
22470
|
+
const resolveCellPointerOriginFromClient = React4.useCallback((cell, clientX, clientY) => {
|
|
22471
|
+
const scroller = scrollRef.current;
|
|
22472
|
+
const rowIndex = rowIndexByActual.get(cell.row);
|
|
22473
|
+
const colIndex = colIndexByActual.get(cell.col);
|
|
22474
|
+
if (!scroller || rowIndex === void 0 || colIndex === void 0) {
|
|
22475
|
+
return null;
|
|
22476
|
+
}
|
|
22477
|
+
const scrollerRect = cachedScrollerRectRef.current ?? scroller.getBoundingClientRect();
|
|
22478
|
+
const pointerOffsetX = clientX - scrollerRect.left;
|
|
22479
|
+
const pointerOffsetY = clientY - scrollerRect.top;
|
|
22480
|
+
const localX = pointerOffsetX + (pointerOffsetX >= frozenPaneRight ? scroller.scrollLeft : 0);
|
|
22481
|
+
const localY = pointerOffsetY + (pointerOffsetY >= frozenPaneBottom ? scroller.scrollTop : 0);
|
|
22482
|
+
const displayWidth = displayEffectiveColWidths[colIndex] ?? displayDefaultColWidth;
|
|
22483
|
+
const displayHeight = displayEffectiveRowHeights[rowIndex] ?? displayDefaultRowHeight;
|
|
22484
|
+
return {
|
|
22485
|
+
contentScaleX: 1,
|
|
22486
|
+
contentScaleY: 1,
|
|
22487
|
+
originContentX: (colPrefixSums[colIndex] ?? 0) + clampContentOffset(localX - displayRowHeaderWidth - (colPrefixSums[colIndex] ?? 0), displayWidth),
|
|
22488
|
+
originContentY: (rowPrefixSums[rowIndex] ?? 0) + clampContentOffset(localY - displayHeaderHeight - (rowPrefixSums[rowIndex] ?? 0), displayHeight)
|
|
22489
|
+
};
|
|
22490
|
+
}, [
|
|
22491
|
+
colIndexByActual,
|
|
22492
|
+
colPrefixSums,
|
|
22493
|
+
displayDefaultColWidth,
|
|
22494
|
+
displayDefaultRowHeight,
|
|
22495
|
+
displayEffectiveColWidths,
|
|
22496
|
+
displayEffectiveRowHeights,
|
|
22497
|
+
displayHeaderHeight,
|
|
22498
|
+
displayRowHeaderWidth,
|
|
22499
|
+
frozenPaneBottom,
|
|
22500
|
+
frozenPaneRight,
|
|
22501
|
+
rowIndexByActual,
|
|
22502
|
+
rowPrefixSums
|
|
22503
|
+
]);
|
|
22470
22504
|
const resolveRowPointerOrigin = React4.useCallback((actualRow, rect, clientY) => {
|
|
22471
22505
|
const rowIndex = rowIndexByActual.get(actualRow);
|
|
22472
22506
|
if (rowIndex === void 0) {
|
|
@@ -23215,10 +23249,11 @@ function XlsxGrid({
|
|
|
23215
23249
|
}, [resolveMountedCellOverlayRect]);
|
|
23216
23250
|
const resolveGeometryOverlayRect = React4.useCallback((range) => {
|
|
23217
23251
|
const normalized = normalizeRange2(range);
|
|
23218
|
-
const startCell = resolveMergeAnchorCell(normalized.start);
|
|
23219
23252
|
const isSingleCellSelection = normalized.start.row === normalized.end.row && normalized.start.col === normalized.end.col;
|
|
23220
|
-
const
|
|
23221
|
-
const
|
|
23253
|
+
const isMergedSecondarySelection = isSingleCellSelection ? worksheet?.isMergedSecondary(normalized.start.row, normalized.start.col) === true : false;
|
|
23254
|
+
const startCell = isSingleCellSelection && !isMergedSecondarySelection ? resolveMergeAnchorCell(normalized.start) : normalized.start;
|
|
23255
|
+
const merge = isSingleCellSelection && !isMergedSecondarySelection ? worksheet?.getMergeSpan(startCell.row, startCell.col) : null;
|
|
23256
|
+
const endCell = isSingleCellSelection && !isMergedSecondarySelection ? {
|
|
23222
23257
|
row: startCell.row + Math.max(1, merge?.rowSpan ?? 1) - 1,
|
|
23223
23258
|
col: startCell.col + Math.max(1, merge?.colSpan ?? 1) - 1
|
|
23224
23259
|
} : normalized.end;
|
|
@@ -23850,13 +23885,14 @@ function XlsxGrid({
|
|
|
23850
23885
|
}
|
|
23851
23886
|
event.preventDefault();
|
|
23852
23887
|
focusGrid();
|
|
23888
|
+
const targetCell = event.currentTarget.colSpan > 1 || event.currentTarget.rowSpan > 1 ? resolvePointerCellFromGeometry(event.clientX, event.clientY) ?? cell : cell;
|
|
23853
23889
|
const currentSelection = selectionRef.current;
|
|
23854
|
-
const anchor = event.shiftKey && currentSelection ? currentSelection.start :
|
|
23855
|
-
const initialRange = normalizeRange2({ start: anchor, end:
|
|
23856
|
-
const isActive = isSameCell(activeCellRef.current,
|
|
23890
|
+
const anchor = event.shiftKey && currentSelection ? currentSelection.start : targetCell;
|
|
23891
|
+
const initialRange = normalizeRange2({ start: anchor, end: targetCell });
|
|
23892
|
+
const isActive = isSameCell(activeCellRef.current, targetCell);
|
|
23857
23893
|
const committedOnPointerDown = !isActive || !editingCellRef.current;
|
|
23858
|
-
const pointerOrigin = resolveCellPointerOrigin(cell, event.currentTarget.getBoundingClientRect(), event.clientX, event.clientY);
|
|
23859
|
-
const originOverlayRect = resolveMountedCellOverlayRect(event.currentTarget);
|
|
23894
|
+
const pointerOrigin = targetCell.row === cell.row && targetCell.col === cell.col ? resolveCellPointerOrigin(cell, event.currentTarget.getBoundingClientRect(), event.clientX, event.clientY) : resolveCellPointerOriginFromClient(targetCell, event.clientX, event.clientY);
|
|
23895
|
+
const originOverlayRect = targetCell.row === cell.row && targetCell.col === cell.col ? resolveMountedCellOverlayRect(event.currentTarget) : resolveOverlayRect(initialRange);
|
|
23860
23896
|
if (!pointerOrigin) {
|
|
23861
23897
|
return;
|
|
23862
23898
|
}
|
|
@@ -23864,7 +23900,7 @@ function XlsxGrid({
|
|
|
23864
23900
|
event.pointerId,
|
|
23865
23901
|
anchor,
|
|
23866
23902
|
"cell",
|
|
23867
|
-
|
|
23903
|
+
targetCell,
|
|
23868
23904
|
pointerOrigin,
|
|
23869
23905
|
originOverlayRect,
|
|
23870
23906
|
committedOnPointerDown,
|
|
@@ -23872,11 +23908,25 @@ function XlsxGrid({
|
|
|
23872
23908
|
event.clientX,
|
|
23873
23909
|
event.clientY
|
|
23874
23910
|
);
|
|
23875
|
-
|
|
23911
|
+
if (targetCell.row === cell.row && targetCell.col === cell.col) {
|
|
23912
|
+
applyPreviewOverlayFromElement(event.currentTarget, initialRange);
|
|
23913
|
+
} else {
|
|
23914
|
+
applyPreviewOverlay(initialRange);
|
|
23915
|
+
}
|
|
23876
23916
|
if (committedOnPointerDown) {
|
|
23877
23917
|
commitSelectionRange(initialRange);
|
|
23878
23918
|
}
|
|
23879
|
-
}, [
|
|
23919
|
+
}, [
|
|
23920
|
+
applyPreviewOverlay,
|
|
23921
|
+
applyPreviewOverlayFromElement,
|
|
23922
|
+
commitSelectionRange,
|
|
23923
|
+
focusGrid,
|
|
23924
|
+
resolveCellPointerOrigin,
|
|
23925
|
+
resolveCellPointerOriginFromClient,
|
|
23926
|
+
resolveMountedCellOverlayRect,
|
|
23927
|
+
resolveOverlayRect,
|
|
23928
|
+
resolvePointerCellFromGeometry
|
|
23929
|
+
]);
|
|
23880
23930
|
const handleRowPointerDown = React4.useCallback((event, actualRow) => {
|
|
23881
23931
|
if (event.button !== 0 || firstVisibleCol === void 0 || lastVisibleCol === void 0) {
|
|
23882
23932
|
return;
|
|
@@ -27121,7 +27171,7 @@ function XlsxViewerInner({
|
|
|
27121
27171
|
enableCanvasSelectionAnimation = true,
|
|
27122
27172
|
enableGestureZoom = true,
|
|
27123
27173
|
errorState,
|
|
27124
|
-
experimentalCanvas =
|
|
27174
|
+
experimentalCanvas = true,
|
|
27125
27175
|
fileTooLargeState,
|
|
27126
27176
|
height,
|
|
27127
27177
|
isDark = false,
|