@extend-ai/react-xlsx 0.8.8 → 0.9.1
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 +80 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21547,6 +21547,9 @@ function XlsxGrid({
|
|
|
21547
21547
|
const selectionCommitFrameRef = React4.useRef(null);
|
|
21548
21548
|
const selectionRef = React4.useRef(null);
|
|
21549
21549
|
const editingCellRef = React4.useRef(null);
|
|
21550
|
+
const commitEditingRef = React4.useRef(() => {
|
|
21551
|
+
});
|
|
21552
|
+
const editingInputRef = React4.useRef(null);
|
|
21550
21553
|
const readOnlyRef = React4.useRef(readOnly);
|
|
21551
21554
|
const committedZoomScaleRef = React4.useRef(zoomScale);
|
|
21552
21555
|
const gestureZoomScaleRef = React4.useRef(zoomScale);
|
|
@@ -22424,6 +22427,18 @@ function XlsxGrid({
|
|
|
22424
22427
|
React4.useEffect(() => {
|
|
22425
22428
|
editingCellRef.current = editingCell;
|
|
22426
22429
|
}, [editingCell]);
|
|
22430
|
+
React4.useLayoutEffect(() => {
|
|
22431
|
+
if (!editingCell) {
|
|
22432
|
+
return;
|
|
22433
|
+
}
|
|
22434
|
+
const input = editingInputRef.current;
|
|
22435
|
+
if (!input) {
|
|
22436
|
+
return;
|
|
22437
|
+
}
|
|
22438
|
+
input.focus();
|
|
22439
|
+
const caret = input.value.length;
|
|
22440
|
+
input.setSelectionRange(caret, caret);
|
|
22441
|
+
}, [editingCell]);
|
|
22427
22442
|
React4.useEffect(() => {
|
|
22428
22443
|
readOnlyRef.current = readOnly;
|
|
22429
22444
|
}, [readOnly]);
|
|
@@ -23183,6 +23198,9 @@ function XlsxGrid({
|
|
|
23183
23198
|
setEditingValue("");
|
|
23184
23199
|
focusGrid();
|
|
23185
23200
|
}, [focusGrid]);
|
|
23201
|
+
React4.useEffect(() => {
|
|
23202
|
+
commitEditingRef.current = commitEditing;
|
|
23203
|
+
}, [commitEditing]);
|
|
23186
23204
|
const [, startBatchTransition] = React4.useTransition();
|
|
23187
23205
|
const [, startSelectionTransition] = React4.useTransition();
|
|
23188
23206
|
const [asyncViewportRowBatch, setAsyncViewportRowBatch] = React4.useState(null);
|
|
@@ -24485,6 +24503,9 @@ function XlsxGrid({
|
|
|
24485
24503
|
const initialRange = normalizeRange2({ start: anchor, end: targetCell });
|
|
24486
24504
|
const isActive = isSameCell(activeCellRef.current, targetCell);
|
|
24487
24505
|
const committedOnPointerDown = !isActive || !editingCellRef.current;
|
|
24506
|
+
if (editingCellRef.current && !isActive) {
|
|
24507
|
+
commitEditingRef.current();
|
|
24508
|
+
}
|
|
24488
24509
|
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);
|
|
24489
24510
|
const originOverlayRect = targetCell.row === cell.row && targetCell.col === cell.col ? resolveMountedCellOverlayRect(event.currentTarget) : resolveOverlayRect(initialRange);
|
|
24490
24511
|
if (!pointerOrigin) {
|
|
@@ -24840,6 +24861,9 @@ function XlsxGrid({
|
|
|
24840
24861
|
const initialRange = normalizeRange2({ start: anchor, end: cell });
|
|
24841
24862
|
const isActive = isSameCell(activeCellRef.current, cell);
|
|
24842
24863
|
const committedOnPointerDown = !isActive || !editingCellRef.current;
|
|
24864
|
+
if (editingCellRef.current && !isActive) {
|
|
24865
|
+
commitEditingRef.current();
|
|
24866
|
+
}
|
|
24843
24867
|
const rowIndex = rowIndexByActual.get(cell.row);
|
|
24844
24868
|
const colIndex = colIndexByActual.get(cell.col);
|
|
24845
24869
|
if (rowIndex === void 0 || colIndex === void 0) {
|
|
@@ -27801,52 +27825,62 @@ function XlsxGrid({
|
|
|
27801
27825
|
),
|
|
27802
27826
|
/* @__PURE__ */ jsx3("canvas", { ref: cornerHeaderCanvasRef, style: canvasCornerHeaderStyle })
|
|
27803
27827
|
] }),
|
|
27804
|
-
editingCell && editingOverlayRect ?
|
|
27805
|
-
|
|
27806
|
-
|
|
27807
|
-
|
|
27808
|
-
|
|
27809
|
-
|
|
27810
|
-
|
|
27811
|
-
|
|
27812
|
-
|
|
27813
|
-
|
|
27814
|
-
|
|
27815
|
-
|
|
27816
|
-
|
|
27817
|
-
|
|
27818
|
-
|
|
27819
|
-
|
|
27820
|
-
|
|
27821
|
-
|
|
27822
|
-
|
|
27823
|
-
|
|
27824
|
-
|
|
27825
|
-
|
|
27826
|
-
|
|
27827
|
-
|
|
27828
|
-
|
|
27829
|
-
|
|
27830
|
-
|
|
27831
|
-
|
|
27832
|
-
|
|
27833
|
-
|
|
27834
|
-
|
|
27835
|
-
|
|
27836
|
-
|
|
27837
|
-
|
|
27838
|
-
|
|
27839
|
-
|
|
27840
|
-
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
|
|
27844
|
-
|
|
27845
|
-
|
|
27846
|
-
|
|
27847
|
-
|
|
27848
|
-
|
|
27849
|
-
|
|
27828
|
+
editingCell && editingOverlayRect ? (() => {
|
|
27829
|
+
const editingCellStyle = getCellData(editingCell.row, editingCell.col).style;
|
|
27830
|
+
const editingBackground = typeof editingCellStyle.backgroundColor === "string" ? editingCellStyle.backgroundColor : resolveSheetSurface(activeSheet, palette);
|
|
27831
|
+
const editingColor = typeof editingCellStyle.color === "string" ? editingCellStyle.color : resolveReadableTextColor(null, editingBackground, palette);
|
|
27832
|
+
return /* @__PURE__ */ jsx3(
|
|
27833
|
+
"div",
|
|
27834
|
+
{
|
|
27835
|
+
style: {
|
|
27836
|
+
left: editingOverlayRect.left,
|
|
27837
|
+
position: "absolute",
|
|
27838
|
+
top: editingOverlayRect.top,
|
|
27839
|
+
width: editingOverlayRect.width,
|
|
27840
|
+
height: editingOverlayRect.height,
|
|
27841
|
+
zIndex: 28
|
|
27842
|
+
},
|
|
27843
|
+
children: /* @__PURE__ */ jsx3(
|
|
27844
|
+
"input",
|
|
27845
|
+
{
|
|
27846
|
+
ref: editingInputRef,
|
|
27847
|
+
autoFocus: true,
|
|
27848
|
+
onBlur: commitEditing,
|
|
27849
|
+
onChange: (event) => setEditingValue(event.target.value),
|
|
27850
|
+
onKeyDown: (event) => {
|
|
27851
|
+
event.stopPropagation();
|
|
27852
|
+
if (event.key === "Enter") {
|
|
27853
|
+
event.preventDefault();
|
|
27854
|
+
commitEditing();
|
|
27855
|
+
return;
|
|
27856
|
+
}
|
|
27857
|
+
if (event.key === "Escape") {
|
|
27858
|
+
event.preventDefault();
|
|
27859
|
+
cancelEditing();
|
|
27860
|
+
}
|
|
27861
|
+
},
|
|
27862
|
+
style: {
|
|
27863
|
+
backgroundColor: editingBackground,
|
|
27864
|
+
border: 0,
|
|
27865
|
+
boxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
|
|
27866
|
+
boxSizing: "border-box",
|
|
27867
|
+
color: editingColor,
|
|
27868
|
+
display: "block",
|
|
27869
|
+
font: resolveCanvasFont(editingCellStyle, 12 * zoomFactor),
|
|
27870
|
+
height: "100%",
|
|
27871
|
+
margin: 0,
|
|
27872
|
+
minHeight: 0,
|
|
27873
|
+
outline: "none",
|
|
27874
|
+
overflow: "hidden",
|
|
27875
|
+
padding: scaleCssLengthExpression(DEFAULT_CELL_PADDING, zoomFactor),
|
|
27876
|
+
width: "100%"
|
|
27877
|
+
},
|
|
27878
|
+
value: editingValue
|
|
27879
|
+
}
|
|
27880
|
+
)
|
|
27881
|
+
}
|
|
27882
|
+
);
|
|
27883
|
+
})() : null,
|
|
27850
27884
|
activeCellAdornment && activeCellAdornmentRect ? /* @__PURE__ */ jsx3(
|
|
27851
27885
|
"div",
|
|
27852
27886
|
{
|