@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.js
CHANGED
|
@@ -20956,7 +20956,7 @@ function XlsxGrid({
|
|
|
20956
20956
|
renderImageSelection,
|
|
20957
20957
|
renderTableHeaderMenu,
|
|
20958
20958
|
enableGestureZoom = true,
|
|
20959
|
-
experimentalCanvas =
|
|
20959
|
+
experimentalCanvas = true,
|
|
20960
20960
|
selectionColor,
|
|
20961
20961
|
selectionFillColor,
|
|
20962
20962
|
selectionHeaderColor,
|
|
@@ -22396,17 +22396,17 @@ function XlsxGrid({
|
|
|
22396
22396
|
}, []);
|
|
22397
22397
|
const resolvePointerCellFromClient = React4.useCallback((clientX, clientY) => {
|
|
22398
22398
|
const geometryCell = resolvePointerCellFromGeometry(clientX, clientY);
|
|
22399
|
-
if (geometryCell
|
|
22400
|
-
return
|
|
22399
|
+
if (geometryCell) {
|
|
22400
|
+
return geometryCell;
|
|
22401
22401
|
}
|
|
22402
|
-
const resolvedCell = resolvePointerCellFromHitTest(clientX, clientY)
|
|
22402
|
+
const resolvedCell = resolvePointerCellFromHitTest(clientX, clientY);
|
|
22403
22403
|
return resolvedCell ? resolveMergeAnchorCell(resolvedCell) : null;
|
|
22404
|
-
}, [resolveMergeAnchorCell, resolvePointerCellFromGeometry, resolvePointerCellFromHitTest
|
|
22404
|
+
}, [resolveMergeAnchorCell, resolvePointerCellFromGeometry, resolvePointerCellFromHitTest]);
|
|
22405
22405
|
const resolveDraggedSelectionCell = React4.useCallback((dragState, clientX, clientY) => {
|
|
22406
22406
|
const geometryCell = resolvePointerCellFromGeometry(clientX, clientY);
|
|
22407
22407
|
const hitCell = resolvePointerCellFromHitTest(clientX, clientY);
|
|
22408
|
-
const actualRow = hitCell && rowIndexByActual.has(hitCell.row) ? hitCell.row :
|
|
22409
|
-
const actualCol =
|
|
22408
|
+
const actualRow = geometryCell?.row ?? (hitCell && rowIndexByActual.has(hitCell.row) ? hitCell.row : void 0);
|
|
22409
|
+
const actualCol = geometryCell?.col ?? hitCell?.col;
|
|
22410
22410
|
if (actualRow === void 0 || actualCol === void 0) {
|
|
22411
22411
|
return null;
|
|
22412
22412
|
}
|
|
@@ -22416,8 +22416,8 @@ function XlsxGrid({
|
|
|
22416
22416
|
if (dragState.axis === "column") {
|
|
22417
22417
|
return { row: dragState.originCell.row, col: actualCol };
|
|
22418
22418
|
}
|
|
22419
|
-
return
|
|
22420
|
-
}, [
|
|
22419
|
+
return { row: actualRow, col: actualCol };
|
|
22420
|
+
}, [resolvePointerCellFromGeometry, resolvePointerCellFromHitTest, rowIndexByActual]);
|
|
22421
22421
|
const resolveCellPointerOrigin = React4.useCallback((cell, rect, clientX, clientY) => {
|
|
22422
22422
|
const rowIndex = rowIndexByActual.get(cell.row);
|
|
22423
22423
|
const colIndex = colIndexByActual.get(cell.col);
|
|
@@ -22435,6 +22435,40 @@ function XlsxGrid({
|
|
|
22435
22435
|
originContentY: (rowPrefixSums[rowIndex] ?? 0) + clampContentOffset((clientY - rect.top) / contentScaleY, displayHeight)
|
|
22436
22436
|
};
|
|
22437
22437
|
}, [colIndexByActual, colPrefixSums, displayDefaultColWidth, displayDefaultRowHeight, displayEffectiveColWidths, displayEffectiveRowHeights, rowIndexByActual, rowPrefixSums]);
|
|
22438
|
+
const resolveCellPointerOriginFromClient = React4.useCallback((cell, clientX, clientY) => {
|
|
22439
|
+
const scroller = scrollRef.current;
|
|
22440
|
+
const rowIndex = rowIndexByActual.get(cell.row);
|
|
22441
|
+
const colIndex = colIndexByActual.get(cell.col);
|
|
22442
|
+
if (!scroller || rowIndex === void 0 || colIndex === void 0) {
|
|
22443
|
+
return null;
|
|
22444
|
+
}
|
|
22445
|
+
const scrollerRect = cachedScrollerRectRef.current ?? scroller.getBoundingClientRect();
|
|
22446
|
+
const pointerOffsetX = clientX - scrollerRect.left;
|
|
22447
|
+
const pointerOffsetY = clientY - scrollerRect.top;
|
|
22448
|
+
const localX = pointerOffsetX + (pointerOffsetX >= frozenPaneRight ? scroller.scrollLeft : 0);
|
|
22449
|
+
const localY = pointerOffsetY + (pointerOffsetY >= frozenPaneBottom ? scroller.scrollTop : 0);
|
|
22450
|
+
const displayWidth = displayEffectiveColWidths[colIndex] ?? displayDefaultColWidth;
|
|
22451
|
+
const displayHeight = displayEffectiveRowHeights[rowIndex] ?? displayDefaultRowHeight;
|
|
22452
|
+
return {
|
|
22453
|
+
contentScaleX: 1,
|
|
22454
|
+
contentScaleY: 1,
|
|
22455
|
+
originContentX: (colPrefixSums[colIndex] ?? 0) + clampContentOffset(localX - displayRowHeaderWidth - (colPrefixSums[colIndex] ?? 0), displayWidth),
|
|
22456
|
+
originContentY: (rowPrefixSums[rowIndex] ?? 0) + clampContentOffset(localY - displayHeaderHeight - (rowPrefixSums[rowIndex] ?? 0), displayHeight)
|
|
22457
|
+
};
|
|
22458
|
+
}, [
|
|
22459
|
+
colIndexByActual,
|
|
22460
|
+
colPrefixSums,
|
|
22461
|
+
displayDefaultColWidth,
|
|
22462
|
+
displayDefaultRowHeight,
|
|
22463
|
+
displayEffectiveColWidths,
|
|
22464
|
+
displayEffectiveRowHeights,
|
|
22465
|
+
displayHeaderHeight,
|
|
22466
|
+
displayRowHeaderWidth,
|
|
22467
|
+
frozenPaneBottom,
|
|
22468
|
+
frozenPaneRight,
|
|
22469
|
+
rowIndexByActual,
|
|
22470
|
+
rowPrefixSums
|
|
22471
|
+
]);
|
|
22438
22472
|
const resolveRowPointerOrigin = React4.useCallback((actualRow, rect, clientY) => {
|
|
22439
22473
|
const rowIndex = rowIndexByActual.get(actualRow);
|
|
22440
22474
|
if (rowIndex === void 0) {
|
|
@@ -23183,10 +23217,11 @@ function XlsxGrid({
|
|
|
23183
23217
|
}, [resolveMountedCellOverlayRect]);
|
|
23184
23218
|
const resolveGeometryOverlayRect = React4.useCallback((range) => {
|
|
23185
23219
|
const normalized = normalizeRange2(range);
|
|
23186
|
-
const startCell = resolveMergeAnchorCell(normalized.start);
|
|
23187
23220
|
const isSingleCellSelection = normalized.start.row === normalized.end.row && normalized.start.col === normalized.end.col;
|
|
23188
|
-
const
|
|
23189
|
-
const
|
|
23221
|
+
const isMergedSecondarySelection = isSingleCellSelection ? worksheet?.isMergedSecondary(normalized.start.row, normalized.start.col) === true : false;
|
|
23222
|
+
const startCell = isSingleCellSelection && !isMergedSecondarySelection ? resolveMergeAnchorCell(normalized.start) : normalized.start;
|
|
23223
|
+
const merge = isSingleCellSelection && !isMergedSecondarySelection ? worksheet?.getMergeSpan(startCell.row, startCell.col) : null;
|
|
23224
|
+
const endCell = isSingleCellSelection && !isMergedSecondarySelection ? {
|
|
23190
23225
|
row: startCell.row + Math.max(1, merge?.rowSpan ?? 1) - 1,
|
|
23191
23226
|
col: startCell.col + Math.max(1, merge?.colSpan ?? 1) - 1
|
|
23192
23227
|
} : normalized.end;
|
|
@@ -23818,13 +23853,14 @@ function XlsxGrid({
|
|
|
23818
23853
|
}
|
|
23819
23854
|
event.preventDefault();
|
|
23820
23855
|
focusGrid();
|
|
23856
|
+
const targetCell = event.currentTarget.colSpan > 1 || event.currentTarget.rowSpan > 1 ? resolvePointerCellFromGeometry(event.clientX, event.clientY) ?? cell : cell;
|
|
23821
23857
|
const currentSelection = selectionRef.current;
|
|
23822
|
-
const anchor = event.shiftKey && currentSelection ? currentSelection.start :
|
|
23823
|
-
const initialRange = normalizeRange2({ start: anchor, end:
|
|
23824
|
-
const isActive = isSameCell(activeCellRef.current,
|
|
23858
|
+
const anchor = event.shiftKey && currentSelection ? currentSelection.start : targetCell;
|
|
23859
|
+
const initialRange = normalizeRange2({ start: anchor, end: targetCell });
|
|
23860
|
+
const isActive = isSameCell(activeCellRef.current, targetCell);
|
|
23825
23861
|
const committedOnPointerDown = !isActive || !editingCellRef.current;
|
|
23826
|
-
const pointerOrigin = resolveCellPointerOrigin(cell, event.currentTarget.getBoundingClientRect(), event.clientX, event.clientY);
|
|
23827
|
-
const originOverlayRect = resolveMountedCellOverlayRect(event.currentTarget);
|
|
23862
|
+
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);
|
|
23863
|
+
const originOverlayRect = targetCell.row === cell.row && targetCell.col === cell.col ? resolveMountedCellOverlayRect(event.currentTarget) : resolveOverlayRect(initialRange);
|
|
23828
23864
|
if (!pointerOrigin) {
|
|
23829
23865
|
return;
|
|
23830
23866
|
}
|
|
@@ -23832,7 +23868,7 @@ function XlsxGrid({
|
|
|
23832
23868
|
event.pointerId,
|
|
23833
23869
|
anchor,
|
|
23834
23870
|
"cell",
|
|
23835
|
-
|
|
23871
|
+
targetCell,
|
|
23836
23872
|
pointerOrigin,
|
|
23837
23873
|
originOverlayRect,
|
|
23838
23874
|
committedOnPointerDown,
|
|
@@ -23840,11 +23876,25 @@ function XlsxGrid({
|
|
|
23840
23876
|
event.clientX,
|
|
23841
23877
|
event.clientY
|
|
23842
23878
|
);
|
|
23843
|
-
|
|
23879
|
+
if (targetCell.row === cell.row && targetCell.col === cell.col) {
|
|
23880
|
+
applyPreviewOverlayFromElement(event.currentTarget, initialRange);
|
|
23881
|
+
} else {
|
|
23882
|
+
applyPreviewOverlay(initialRange);
|
|
23883
|
+
}
|
|
23844
23884
|
if (committedOnPointerDown) {
|
|
23845
23885
|
commitSelectionRange(initialRange);
|
|
23846
23886
|
}
|
|
23847
|
-
}, [
|
|
23887
|
+
}, [
|
|
23888
|
+
applyPreviewOverlay,
|
|
23889
|
+
applyPreviewOverlayFromElement,
|
|
23890
|
+
commitSelectionRange,
|
|
23891
|
+
focusGrid,
|
|
23892
|
+
resolveCellPointerOrigin,
|
|
23893
|
+
resolveCellPointerOriginFromClient,
|
|
23894
|
+
resolveMountedCellOverlayRect,
|
|
23895
|
+
resolveOverlayRect,
|
|
23896
|
+
resolvePointerCellFromGeometry
|
|
23897
|
+
]);
|
|
23848
23898
|
const handleRowPointerDown = React4.useCallback((event, actualRow) => {
|
|
23849
23899
|
if (event.button !== 0 || firstVisibleCol === void 0 || lastVisibleCol === void 0) {
|
|
23850
23900
|
return;
|
|
@@ -27089,7 +27139,7 @@ function XlsxViewerInner({
|
|
|
27089
27139
|
enableCanvasSelectionAnimation = true,
|
|
27090
27140
|
enableGestureZoom = true,
|
|
27091
27141
|
errorState,
|
|
27092
|
-
experimentalCanvas =
|
|
27142
|
+
experimentalCanvas = true,
|
|
27093
27143
|
fileTooLargeState,
|
|
27094
27144
|
height,
|
|
27095
27145
|
isDark = false,
|