@extend-ai/react-xlsx 0.20.12 → 0.21.0
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/README.md +144 -1
- package/dist/{chunk-O4S5CRDM.js → chunk-2UFSVI5Z.js} +432 -33
- package/dist/chunk-2UFSVI5Z.js.map +1 -0
- package/dist/{chunk-NIN5D556.cjs → chunk-7IL4KLCD.cjs} +837 -438
- package/dist/chunk-7IL4KLCD.cjs.map +1 -0
- package/dist/index.cjs +215 -147
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +173 -105
- package/dist/index.js.map +1 -1
- package/dist/{internal-D_np3R-w.d.cts → internal-BO70EPFy.d.cts} +71 -1
- package/dist/{internal-D_np3R-w.d.ts → internal-BO70EPFy.d.ts} +71 -1
- package/dist/internal.cjs +2 -2
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/vanilla.cjs +2 -2
- package/dist/vanilla.d.cts +2 -2
- package/dist/vanilla.d.ts +2 -2
- package/dist/vanilla.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-NIN5D556.cjs.map +0 -1
- package/dist/chunk-O4S5CRDM.js.map +0 -1
|
@@ -11741,6 +11741,28 @@ function useXlsxViewerController(options) {
|
|
|
11741
11741
|
refreshWorkbookState(workbook);
|
|
11742
11742
|
recordCellEditHistory(cell, before, after);
|
|
11743
11743
|
}, [captureCellMutationState, getActiveWorksheet, readOnly, recordCellEditHistory, refreshWorkbookState, workbook]);
|
|
11744
|
+
const setCellStyles = q((updates) => {
|
|
11745
|
+
const worksheet = getActiveWorksheet();
|
|
11746
|
+
if (readOnly || !worksheet || !workbook) return;
|
|
11747
|
+
const beforeStates = /* @__PURE__ */ new Map();
|
|
11748
|
+
for (const { cell, style } of updates) {
|
|
11749
|
+
const key = `${cell.row}:${cell.col}`;
|
|
11750
|
+
if (!beforeStates.has(key)) {
|
|
11751
|
+
const before = captureCellMutationState(cell);
|
|
11752
|
+
if (!before) continue;
|
|
11753
|
+
beforeStates.set(key, { cell: { ...cell }, before });
|
|
11754
|
+
}
|
|
11755
|
+
worksheet.setCellStyleAt(cell.row, cell.col, style);
|
|
11756
|
+
}
|
|
11757
|
+
if (!beforeStates.size) return;
|
|
11758
|
+
const mutations = [];
|
|
11759
|
+
for (const { cell, before } of beforeStates.values()) {
|
|
11760
|
+
const after = captureCellMutationState(cell);
|
|
11761
|
+
if (after) mutations.push({ cell, before, after });
|
|
11762
|
+
}
|
|
11763
|
+
refreshWorkbookState(workbook);
|
|
11764
|
+
recordRangeEditHistory(mutations, selection, activeCell);
|
|
11765
|
+
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
|
|
11744
11766
|
const setSelectedCellValue = q((value) => {
|
|
11745
11767
|
if (!activeCell) {
|
|
11746
11768
|
return;
|
|
@@ -12397,6 +12419,7 @@ function useXlsxViewerController(options) {
|
|
|
12397
12419
|
resizeRow,
|
|
12398
12420
|
setCellFormula,
|
|
12399
12421
|
setCellStyle,
|
|
12422
|
+
setCellStyles,
|
|
12400
12423
|
setCellValue,
|
|
12401
12424
|
setRangeStyle,
|
|
12402
12425
|
setSelectedFormula,
|
|
@@ -12521,6 +12544,7 @@ function useXlsxViewerController(options) {
|
|
|
12521
12544
|
resizeRow,
|
|
12522
12545
|
setCellFormula,
|
|
12523
12546
|
setCellStyle,
|
|
12547
|
+
setCellStyles,
|
|
12524
12548
|
setCellValue,
|
|
12525
12549
|
setRangeStyle,
|
|
12526
12550
|
setSelectedFormula,
|
|
@@ -14133,6 +14157,8 @@ function CellEditor({
|
|
|
14133
14157
|
value,
|
|
14134
14158
|
references,
|
|
14135
14159
|
inputRef,
|
|
14160
|
+
editorRef,
|
|
14161
|
+
onFocusOverlay,
|
|
14136
14162
|
canvasText = false,
|
|
14137
14163
|
canvasOffset,
|
|
14138
14164
|
paintCanvasText,
|
|
@@ -14272,7 +14298,12 @@ function CellEditor({
|
|
|
14272
14298
|
return /* @__PURE__ */ u(
|
|
14273
14299
|
"div",
|
|
14274
14300
|
{
|
|
14275
|
-
ref:
|
|
14301
|
+
ref: (element) => {
|
|
14302
|
+
rootRef.current = element;
|
|
14303
|
+
if (typeof editorRef === "function") editorRef(element);
|
|
14304
|
+
else if (editorRef) editorRef.current = element;
|
|
14305
|
+
},
|
|
14306
|
+
"data-xlsx-cell-editor": "",
|
|
14276
14307
|
onPointerDown: (event) => event.stopPropagation(),
|
|
14277
14308
|
onClick: (event) => event.stopPropagation(),
|
|
14278
14309
|
onDoubleClick: (event) => event.stopPropagation(),
|
|
@@ -14321,7 +14352,7 @@ function CellEditor({
|
|
|
14321
14352
|
] })
|
|
14322
14353
|
}
|
|
14323
14354
|
),
|
|
14324
|
-
paintCanvasText ? /* @__PURE__ */ u("canvas", { ref: canvasRef, "aria-hidden": "true", style: { position: "absolute", pointerEvents: "none" } }) : null,
|
|
14355
|
+
paintCanvasText ? /* @__PURE__ */ u("canvas", { ref: canvasRef, "data-xlsx-formula-text": "", "aria-hidden": "true", style: { position: "absolute", pointerEvents: "none" } }) : null,
|
|
14325
14356
|
/* @__PURE__ */ u(
|
|
14326
14357
|
"textarea",
|
|
14327
14358
|
{
|
|
@@ -14331,6 +14362,7 @@ function CellEditor({
|
|
|
14331
14362
|
else if (inputRef) inputRef.current = element;
|
|
14332
14363
|
},
|
|
14333
14364
|
"aria-label": messages.editCell,
|
|
14365
|
+
"aria-keyshortcuts": onFocusOverlay ? "Alt+ArrowDown" : void 0,
|
|
14334
14366
|
autoFocus: true,
|
|
14335
14367
|
autoComplete: "off",
|
|
14336
14368
|
spellCheck: false,
|
|
@@ -14344,7 +14376,9 @@ function CellEditor({
|
|
|
14344
14376
|
onKeyDown: (event) => {
|
|
14345
14377
|
event.stopPropagation();
|
|
14346
14378
|
if (event.nativeEvent.isComposing) return;
|
|
14347
|
-
if (event.key === "
|
|
14379
|
+
if (event.key === "ArrowDown" && event.altKey && onFocusOverlay?.()) {
|
|
14380
|
+
event.preventDefault();
|
|
14381
|
+
} else if (event.key === "Enter" && !event.altKey) {
|
|
14348
14382
|
event.preventDefault();
|
|
14349
14383
|
onCommit();
|
|
14350
14384
|
} else if (event.key === "Escape") {
|
|
@@ -14390,6 +14424,260 @@ function CellEditor({
|
|
|
14390
14424
|
);
|
|
14391
14425
|
}
|
|
14392
14426
|
|
|
14427
|
+
// src/cell-editor-overlay.tsx
|
|
14428
|
+
function CellEditorOverlay({ editorRef, overlayRef, session, render, onExit }) {
|
|
14429
|
+
const [geometry, setGeometry] = d(null);
|
|
14430
|
+
const latest = A({ onExit, session });
|
|
14431
|
+
latest.current = { onExit, session };
|
|
14432
|
+
_(() => {
|
|
14433
|
+
const editor = editorRef.current;
|
|
14434
|
+
const owner = editor?.ownerDocument;
|
|
14435
|
+
const win = owner?.defaultView;
|
|
14436
|
+
const viewport = editor?.closest('[role="grid"]');
|
|
14437
|
+
if (!editor || !owner || !win || !viewport) return;
|
|
14438
|
+
const update = () => {
|
|
14439
|
+
const bounds = editor.getBoundingClientRect();
|
|
14440
|
+
const view = viewport.getBoundingClientRect();
|
|
14441
|
+
const rect = { left: bounds.left, top: bounds.top, width: bounds.width, height: bounds.height };
|
|
14442
|
+
const visible = bounds.width > 0 && bounds.height > 0 && bounds.right > Math.max(view.left, 0) && bounds.bottom > Math.max(view.top, 0) && bounds.left < Math.min(view.right, win.innerWidth) && bounds.top < Math.min(view.bottom, win.innerHeight);
|
|
14443
|
+
setGeometry((previous) => previous && previous.editor === editor && previous.visible === visible && previous.rect.left === rect.left && previous.rect.top === rect.top && previous.rect.width === rect.width && previous.rect.height === rect.height ? previous : { owner, editor, rect, visible });
|
|
14444
|
+
};
|
|
14445
|
+
const outside = (event) => {
|
|
14446
|
+
const target = event.target;
|
|
14447
|
+
if (!latest.current.session.signal.aborted && !editor.contains(target) && !overlayRef.current?.contains(target)) {
|
|
14448
|
+
latest.current.onExit();
|
|
14449
|
+
}
|
|
14450
|
+
};
|
|
14451
|
+
update();
|
|
14452
|
+
const observer = new ResizeObserver(update);
|
|
14453
|
+
observer.observe(editor);
|
|
14454
|
+
observer.observe(viewport);
|
|
14455
|
+
owner.addEventListener("scroll", update, true);
|
|
14456
|
+
owner.addEventListener("pointerdown", outside, true);
|
|
14457
|
+
owner.addEventListener("focusin", outside);
|
|
14458
|
+
win.addEventListener("resize", update);
|
|
14459
|
+
return () => {
|
|
14460
|
+
observer.disconnect();
|
|
14461
|
+
owner.removeEventListener("scroll", update, true);
|
|
14462
|
+
owner.removeEventListener("pointerdown", outside, true);
|
|
14463
|
+
owner.removeEventListener("focusin", outside);
|
|
14464
|
+
win.removeEventListener("resize", update);
|
|
14465
|
+
};
|
|
14466
|
+
}, [editorRef, overlayRef, session.signal]);
|
|
14467
|
+
const content = geometry ? render({ ...session, rect: geometry.rect, editorElement: geometry.editor }) : null;
|
|
14468
|
+
if (!geometry || content == null || content === false) return null;
|
|
14469
|
+
return $(
|
|
14470
|
+
/* @__PURE__ */ u(
|
|
14471
|
+
"div",
|
|
14472
|
+
{
|
|
14473
|
+
ref: overlayRef,
|
|
14474
|
+
"data-xlsx-cell-editor-overlay": "",
|
|
14475
|
+
onPointerDown: (event) => {
|
|
14476
|
+
event.stopPropagation();
|
|
14477
|
+
const target = event.target;
|
|
14478
|
+
if (!target.closest('input, textarea, select, [contenteditable="true"]')) event.preventDefault();
|
|
14479
|
+
},
|
|
14480
|
+
onClick: (event) => event.stopPropagation(),
|
|
14481
|
+
onKeyDown: (event) => {
|
|
14482
|
+
event.stopPropagation();
|
|
14483
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
14484
|
+
event.preventDefault();
|
|
14485
|
+
session.cancel();
|
|
14486
|
+
}
|
|
14487
|
+
},
|
|
14488
|
+
style: { position: "fixed", ...geometry.rect, pointerEvents: "none", visibility: geometry.visible ? "visible" : "hidden", zIndex: 1e4 },
|
|
14489
|
+
children: content
|
|
14490
|
+
}
|
|
14491
|
+
),
|
|
14492
|
+
geometry.owner.body
|
|
14493
|
+
);
|
|
14494
|
+
}
|
|
14495
|
+
|
|
14496
|
+
// src/selection-popover.tsx
|
|
14497
|
+
function SelectionPopover({ context, suspended, viewportRef, getRects, render, onApply, focusGrid }) {
|
|
14498
|
+
const hostRef = A(null);
|
|
14499
|
+
const controller = T(() => new AbortController(), []);
|
|
14500
|
+
const [closed, setClosed] = d(false);
|
|
14501
|
+
const [rect, setRect] = d(null);
|
|
14502
|
+
const latest = A({ getRects, onApply, context, focusGrid });
|
|
14503
|
+
latest.current = { getRects, onApply, context, focusGrid };
|
|
14504
|
+
const close = q(() => {
|
|
14505
|
+
controller.abort();
|
|
14506
|
+
setClosed(true);
|
|
14507
|
+
}, [controller]);
|
|
14508
|
+
_(() => {
|
|
14509
|
+
if (suspended) close();
|
|
14510
|
+
}, [close, suspended]);
|
|
14511
|
+
const update = q(() => {
|
|
14512
|
+
const viewport = viewportRef.current;
|
|
14513
|
+
if (!viewport) return;
|
|
14514
|
+
const bounds = viewport.getBoundingClientRect();
|
|
14515
|
+
const win = viewport.ownerDocument.defaultView;
|
|
14516
|
+
const rects = latest.current.getRects().map((r) => ({
|
|
14517
|
+
left: Math.max(r.left, bounds.left, 0),
|
|
14518
|
+
top: Math.max(r.top, bounds.top, 0),
|
|
14519
|
+
right: Math.min(r.left + r.width, bounds.right, win.innerWidth),
|
|
14520
|
+
bottom: Math.min(r.top + r.height, bounds.bottom, win.innerHeight)
|
|
14521
|
+
})).filter((r) => r.right > r.left && r.bottom > r.top);
|
|
14522
|
+
const next = rects.length ? {
|
|
14523
|
+
left: Math.min(...rects.map((r) => r.left)),
|
|
14524
|
+
top: Math.min(...rects.map((r) => r.top)),
|
|
14525
|
+
width: Math.max(...rects.map((r) => r.right)) - Math.min(...rects.map((r) => r.left)),
|
|
14526
|
+
height: Math.max(...rects.map((r) => r.bottom)) - Math.min(...rects.map((r) => r.top))
|
|
14527
|
+
} : null;
|
|
14528
|
+
setRect((previous) => previous?.left === next?.left && previous?.top === next?.top && previous?.width === next?.width && previous?.height === next?.height ? previous : next);
|
|
14529
|
+
}, [viewportRef]);
|
|
14530
|
+
_(update);
|
|
14531
|
+
_(() => {
|
|
14532
|
+
const viewport = viewportRef.current;
|
|
14533
|
+
const owner = viewport?.ownerDocument;
|
|
14534
|
+
const win = owner?.defaultView;
|
|
14535
|
+
if (!viewport || !owner || !win) return;
|
|
14536
|
+
const outside = (event) => {
|
|
14537
|
+
if (!hostRef.current?.contains(event.target)) close();
|
|
14538
|
+
};
|
|
14539
|
+
const observer = new ResizeObserver(update);
|
|
14540
|
+
observer.observe(viewport);
|
|
14541
|
+
owner.addEventListener("scroll", update, true);
|
|
14542
|
+
viewport.addEventListener("transitionend", update);
|
|
14543
|
+
owner.addEventListener("pointerdown", outside, true);
|
|
14544
|
+
win.addEventListener("resize", update);
|
|
14545
|
+
return () => {
|
|
14546
|
+
controller.abort();
|
|
14547
|
+
observer.disconnect();
|
|
14548
|
+
owner.removeEventListener("scroll", update, true);
|
|
14549
|
+
viewport.removeEventListener("transitionend", update);
|
|
14550
|
+
owner.removeEventListener("pointerdown", outside, true);
|
|
14551
|
+
win.removeEventListener("resize", update);
|
|
14552
|
+
};
|
|
14553
|
+
}, [close, controller, update, viewportRef]);
|
|
14554
|
+
const commit = q((apply) => {
|
|
14555
|
+
if (controller.signal.aborted || latest.current.context.readOnly) return false;
|
|
14556
|
+
apply(latest.current.context);
|
|
14557
|
+
close();
|
|
14558
|
+
latest.current.focusGrid();
|
|
14559
|
+
return true;
|
|
14560
|
+
}, [close, controller]);
|
|
14561
|
+
const applyFormula = q((formula) => commit(() => latest.current.onApply(formula)), [commit]);
|
|
14562
|
+
if (closed || suspended || !rect || !viewportRef.current) return null;
|
|
14563
|
+
const content = render({ context, rect, signal: controller.signal, applyFormula, commit, close });
|
|
14564
|
+
if (content == null || content === false) return null;
|
|
14565
|
+
return $(
|
|
14566
|
+
/* @__PURE__ */ u(
|
|
14567
|
+
"div",
|
|
14568
|
+
{
|
|
14569
|
+
ref: hostRef,
|
|
14570
|
+
"data-xlsx-selection-popover": "",
|
|
14571
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
14572
|
+
onClick: (event) => event.stopPropagation(),
|
|
14573
|
+
onDoubleClick: (event) => event.stopPropagation(),
|
|
14574
|
+
onKeyDown: (event) => {
|
|
14575
|
+
event.stopPropagation();
|
|
14576
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
14577
|
+
event.preventDefault();
|
|
14578
|
+
close();
|
|
14579
|
+
latest.current.focusGrid();
|
|
14580
|
+
}
|
|
14581
|
+
},
|
|
14582
|
+
style: { position: "fixed", ...rect, pointerEvents: "none", zIndex: 1e4 },
|
|
14583
|
+
children: content
|
|
14584
|
+
}
|
|
14585
|
+
),
|
|
14586
|
+
viewportRef.current.ownerDocument.body
|
|
14587
|
+
);
|
|
14588
|
+
}
|
|
14589
|
+
|
|
14590
|
+
// src/cell-editor-session.ts
|
|
14591
|
+
function useCellEditorSession({
|
|
14592
|
+
enabled,
|
|
14593
|
+
cell,
|
|
14594
|
+
sheetIndex,
|
|
14595
|
+
sheetName,
|
|
14596
|
+
originalValue,
|
|
14597
|
+
trigger,
|
|
14598
|
+
value,
|
|
14599
|
+
inputRef,
|
|
14600
|
+
isEditing,
|
|
14601
|
+
onChange,
|
|
14602
|
+
onCommit,
|
|
14603
|
+
onCancel
|
|
14604
|
+
}) {
|
|
14605
|
+
const state = T(() => enabled && cell ? {
|
|
14606
|
+
controller: new AbortController(),
|
|
14607
|
+
context: { cell: { ...cell }, sheetIndex, sheetName, originalValue, trigger },
|
|
14608
|
+
beforePreview: null
|
|
14609
|
+
} : null, [enabled, cell]);
|
|
14610
|
+
const latest = A({ state, sheetIndex, value, isEditing, onChange, onCommit, onCancel });
|
|
14611
|
+
latest.current = { state, sheetIndex, value, isEditing, onChange, onCommit, onCancel };
|
|
14612
|
+
const [, refresh] = y((revision) => revision + 1, 0);
|
|
14613
|
+
_(() => () => {
|
|
14614
|
+
state?.controller.abort();
|
|
14615
|
+
if (state?.beforePreview != null && latest.current.state === null && latest.current.isEditing()) {
|
|
14616
|
+
latest.current.onCancel();
|
|
14617
|
+
}
|
|
14618
|
+
}, [state]);
|
|
14619
|
+
_(() => {
|
|
14620
|
+
if (state && state.context.sheetIndex !== sheetIndex) state.controller.abort();
|
|
14621
|
+
}, [state, sheetIndex]);
|
|
14622
|
+
const commands = T(() => {
|
|
14623
|
+
if (!state) return null;
|
|
14624
|
+
const current = () => latest.current.state === state && latest.current.sheetIndex === state.context.sheetIndex && !state.controller.signal.aborted && latest.current.isEditing();
|
|
14625
|
+
const setValue = (next) => {
|
|
14626
|
+
if (!current()) return false;
|
|
14627
|
+
latest.current.value = next;
|
|
14628
|
+
latest.current.onChange(next);
|
|
14629
|
+
return true;
|
|
14630
|
+
};
|
|
14631
|
+
const focus = () => {
|
|
14632
|
+
if (!current() || !inputRef.current) return false;
|
|
14633
|
+
inputRef.current.focus({ preventScroll: true });
|
|
14634
|
+
return true;
|
|
14635
|
+
};
|
|
14636
|
+
return {
|
|
14637
|
+
getValue: () => current() ? latest.current.value : null,
|
|
14638
|
+
setValue,
|
|
14639
|
+
focus,
|
|
14640
|
+
preview(next) {
|
|
14641
|
+
if (!current()) return false;
|
|
14642
|
+
state.beforePreview ??= latest.current.value;
|
|
14643
|
+
setValue(next);
|
|
14644
|
+
refresh();
|
|
14645
|
+
return true;
|
|
14646
|
+
},
|
|
14647
|
+
discardPreview() {
|
|
14648
|
+
if (!current() || state.beforePreview === null) return false;
|
|
14649
|
+
const previous = state.beforePreview;
|
|
14650
|
+
state.beforePreview = null;
|
|
14651
|
+
setValue(previous);
|
|
14652
|
+
refresh();
|
|
14653
|
+
focus();
|
|
14654
|
+
return true;
|
|
14655
|
+
},
|
|
14656
|
+
commit(next) {
|
|
14657
|
+
if (!current()) return false;
|
|
14658
|
+
state.controller.abort();
|
|
14659
|
+
latest.current.onCommit(next ?? latest.current.value);
|
|
14660
|
+
return true;
|
|
14661
|
+
},
|
|
14662
|
+
cancel() {
|
|
14663
|
+
if (!current()) return false;
|
|
14664
|
+
state.controller.abort();
|
|
14665
|
+
latest.current.onCancel();
|
|
14666
|
+
return true;
|
|
14667
|
+
}
|
|
14668
|
+
};
|
|
14669
|
+
}, [state, inputRef]);
|
|
14670
|
+
const hasPreview = q(() => latest.current.state?.beforePreview != null, []);
|
|
14671
|
+
const session = state && commands && state.context.sheetIndex === sheetIndex ? {
|
|
14672
|
+
...commands,
|
|
14673
|
+
context: state.context,
|
|
14674
|
+
signal: state.controller.signal,
|
|
14675
|
+
value,
|
|
14676
|
+
isPreview: state.beforePreview !== null
|
|
14677
|
+
} : null;
|
|
14678
|
+
return { session, hasPreview };
|
|
14679
|
+
}
|
|
14680
|
+
|
|
14393
14681
|
// src/merged-range-lookup.ts
|
|
14394
14682
|
function createMergedRangeLookup(ranges) {
|
|
14395
14683
|
const normalizedRanges = [];
|
|
@@ -14561,6 +14849,7 @@ function XlsxContextMenu({
|
|
|
14561
14849
|
}) {
|
|
14562
14850
|
const { messages } = controller;
|
|
14563
14851
|
const rootRef = A(null);
|
|
14852
|
+
const abortController = T(() => new AbortController(), []);
|
|
14564
14853
|
const controllerRef = A(controller);
|
|
14565
14854
|
controllerRef.current = controller;
|
|
14566
14855
|
const aliveRef = A(true);
|
|
@@ -14624,13 +14913,14 @@ function XlsxContextMenu({
|
|
|
14624
14913
|
window.addEventListener("blur", dismiss);
|
|
14625
14914
|
return () => {
|
|
14626
14915
|
aliveRef.current = false;
|
|
14916
|
+
abortController.abort();
|
|
14627
14917
|
document.removeEventListener("pointerdown", outside, true);
|
|
14628
14918
|
document.removeEventListener("focusin", outside);
|
|
14629
14919
|
document.removeEventListener("scroll", outside, true);
|
|
14630
14920
|
window.removeEventListener("resize", dismiss);
|
|
14631
14921
|
window.removeEventListener("blur", dismiss);
|
|
14632
14922
|
};
|
|
14633
|
-
}, [closeMenu]);
|
|
14923
|
+
}, [abortController, closeMenu]);
|
|
14634
14924
|
const runAction = async (id) => {
|
|
14635
14925
|
const action = actions.find((item) => item.id === id);
|
|
14636
14926
|
if (!aliveRef.current || runningRef.current || !action || action.disabled) return false;
|
|
@@ -14744,7 +15034,17 @@ function XlsxContextMenu({
|
|
|
14744
15034
|
}
|
|
14745
15035
|
)
|
|
14746
15036
|
] }, action.id));
|
|
14747
|
-
const
|
|
15037
|
+
const close = () => {
|
|
15038
|
+
abortController.abort();
|
|
15039
|
+
closeMenu();
|
|
15040
|
+
};
|
|
15041
|
+
const commit = (apply) => {
|
|
15042
|
+
if (!aliveRef.current || abortController.signal.aborted || controllerRef.current.readOnly || controllerRef.current.workbook !== controller.workbook || controllerRef.current.activeSheetIndex !== context.sheetIndex || controllerRef.current.selection !== controller.selection || controllerRef.current.revision !== controller.revision) return false;
|
|
15043
|
+
apply(context);
|
|
15044
|
+
close();
|
|
15045
|
+
return true;
|
|
15046
|
+
};
|
|
15047
|
+
const content = renderContextMenu ? renderContextMenu({ context, actions, runAction, closeMenu: close, signal: abortController.signal, commit, position: location, isDark: isDarkViewerPalette(palette), busy, error, defaultNode }) : defaultNode;
|
|
14748
15048
|
return $(
|
|
14749
15049
|
/* @__PURE__ */ u(
|
|
14750
15050
|
"div",
|
|
@@ -19672,6 +19972,10 @@ function GridRow({
|
|
|
19672
19972
|
editingValue,
|
|
19673
19973
|
formulaReferences,
|
|
19674
19974
|
editorBoxShadow,
|
|
19975
|
+
editorRef,
|
|
19976
|
+
editorInputRef,
|
|
19977
|
+
cellEditorStyle,
|
|
19978
|
+
onFocusEditorOverlay,
|
|
19675
19979
|
frozenRowHeaderZIndex,
|
|
19676
19980
|
getCellData,
|
|
19677
19981
|
headerLabelLiveScale,
|
|
@@ -20007,6 +20311,9 @@ function GridRow({
|
|
|
20007
20311
|
isEditing ? /* @__PURE__ */ u(
|
|
20008
20312
|
CellEditor,
|
|
20009
20313
|
{
|
|
20314
|
+
editorRef,
|
|
20315
|
+
inputRef: editorInputRef,
|
|
20316
|
+
onFocusOverlay: onFocusEditorOverlay,
|
|
20010
20317
|
value: editingValue,
|
|
20011
20318
|
references: formulaReferences,
|
|
20012
20319
|
onBlur: onEditingBlur,
|
|
@@ -20021,7 +20328,8 @@ function GridRow({
|
|
|
20021
20328
|
font: "inherit",
|
|
20022
20329
|
lineHeight: cellData.style.lineHeight,
|
|
20023
20330
|
verticalAlign: cellData.style.verticalAlign,
|
|
20024
|
-
padding: cellData.style.padding
|
|
20331
|
+
padding: cellData.style.padding,
|
|
20332
|
+
...cellEditorStyle
|
|
20025
20333
|
}
|
|
20026
20334
|
}
|
|
20027
20335
|
) : isSpilling ? /* @__PURE__ */ u(
|
|
@@ -20085,7 +20393,7 @@ function GridRow({
|
|
|
20085
20393
|
] });
|
|
20086
20394
|
}
|
|
20087
20395
|
var MemoGridRow = N(GridRow, (prev, next) => {
|
|
20088
|
-
if (prev.actualRow !== next.actualRow || prev.rowHeight !== next.rowHeight || prev.headerLabelLiveScale !== next.headerLabelLiveScale || prev.palette !== next.palette || prev.readOnly !== next.readOnly || prev.visibleCols !== next.visibleCols || prev.leadingSpacerWidth !== next.leadingSpacerWidth || prev.rowHeaderWidth !== next.rowHeaderWidth || prev.stickyLeftByCol !== next.stickyLeftByCol || prev.stickyTop !== next.stickyTop || prev.trailingSpacerWidth !== next.trailingSpacerWidth || prev.zoomFactor !== next.zoomFactor || prev.getCellData !== next.getCellData || prev.onCellClick !== next.onCellClick || prev.onCellDoubleClick !== next.onCellDoubleClick || prev.onCellPointerDown !== next.onCellPointerDown || prev.onEditingBlur !== next.onEditingBlur || prev.onEditingCancel !== next.onEditingCancel || prev.onEditingCommit !== next.onEditingCommit || prev.onEditingNavigate !== next.onEditingNavigate || prev.onEditingValueChange !== next.onEditingValueChange || prev.onRowHeaderRef !== next.onRowHeaderRef || prev.onRowPointerDown !== next.onRowPointerDown || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment) {
|
|
20396
|
+
if (prev.actualRow !== next.actualRow || prev.rowHeight !== next.rowHeight || prev.headerLabelLiveScale !== next.headerLabelLiveScale || prev.palette !== next.palette || prev.readOnly !== next.readOnly || prev.visibleCols !== next.visibleCols || prev.leadingSpacerWidth !== next.leadingSpacerWidth || prev.rowHeaderWidth !== next.rowHeaderWidth || prev.stickyLeftByCol !== next.stickyLeftByCol || prev.stickyTop !== next.stickyTop || prev.trailingSpacerWidth !== next.trailingSpacerWidth || prev.zoomFactor !== next.zoomFactor || prev.getCellData !== next.getCellData || prev.onCellClick !== next.onCellClick || prev.onCellDoubleClick !== next.onCellDoubleClick || prev.onCellPointerDown !== next.onCellPointerDown || prev.onEditingBlur !== next.onEditingBlur || prev.onEditingCancel !== next.onEditingCancel || prev.onEditingCommit !== next.onEditingCommit || prev.onEditingNavigate !== next.onEditingNavigate || prev.onEditingValueChange !== next.onEditingValueChange || prev.onRowHeaderRef !== next.onRowHeaderRef || prev.onRowPointerDown !== next.onRowPointerDown || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment || prev.cellEditorStyle !== next.cellEditorStyle || prev.onFocusEditorOverlay !== next.onFocusEditorOverlay) {
|
|
20089
20397
|
return false;
|
|
20090
20398
|
}
|
|
20091
20399
|
const prevEditingCol = prev.editingCell?.row === prev.actualRow ? prev.editingCell.col : -1;
|
|
@@ -20122,6 +20430,9 @@ function XlsxGrid({
|
|
|
20122
20430
|
renderImageSelection,
|
|
20123
20431
|
renderTableHeaderMenu,
|
|
20124
20432
|
renderActiveCellOverlay,
|
|
20433
|
+
renderCellEditorOverlay,
|
|
20434
|
+
renderSelectionPopover,
|
|
20435
|
+
cellEditorStyle,
|
|
20125
20436
|
renderScroller,
|
|
20126
20437
|
enableGestureZoom = true,
|
|
20127
20438
|
experimentalCanvas = true,
|
|
@@ -20274,6 +20585,10 @@ function XlsxGrid({
|
|
|
20274
20585
|
const commitEditingRef = A(() => {
|
|
20275
20586
|
});
|
|
20276
20587
|
const editingInputRef = A(null);
|
|
20588
|
+
const editorElementRef = A(null);
|
|
20589
|
+
const editorOverlayRef = A(null);
|
|
20590
|
+
const editingSavedValueRef = A("");
|
|
20591
|
+
const editingTriggerRef = A("keyboard");
|
|
20277
20592
|
const readOnlyRef = A(readOnly);
|
|
20278
20593
|
const committedZoomScaleRef = A(zoomScale);
|
|
20279
20594
|
const gestureZoomScaleRef = A(zoomScale);
|
|
@@ -20376,9 +20691,11 @@ function XlsxGrid({
|
|
|
20376
20691
|
const skipNextImageClickRef = A(null);
|
|
20377
20692
|
const [pendingNavigation, setPendingNavigation] = d(null);
|
|
20378
20693
|
const interactionModeRef = A("idle");
|
|
20694
|
+
const [interactionMode, setRenderedInteractionMode] = d("idle");
|
|
20379
20695
|
const setInteractionMode = q((mode) => {
|
|
20380
20696
|
interactionModeRef.current = mode;
|
|
20381
|
-
|
|
20697
|
+
if (renderSelectionPopover) setRenderedInteractionMode(mode);
|
|
20698
|
+
}, [!!renderSelectionPopover]);
|
|
20382
20699
|
const worksheet = T(
|
|
20383
20700
|
() => getActiveWorksheet(),
|
|
20384
20701
|
[activeSheetIndex, getActiveWorksheet, revision]
|
|
@@ -22050,6 +22367,7 @@ function XlsxGrid({
|
|
|
22050
22367
|
rowPreviewRef.current = null;
|
|
22051
22368
|
setResizeGuide(null);
|
|
22052
22369
|
clearGlobalCursor();
|
|
22370
|
+
editingCellRef.current = null;
|
|
22053
22371
|
setEditingCell(null);
|
|
22054
22372
|
setEditingValue("");
|
|
22055
22373
|
setFillPreviewRange(null);
|
|
@@ -22137,17 +22455,20 @@ function XlsxGrid({
|
|
|
22137
22455
|
window.open(url.href, "_blank", "noopener,noreferrer");
|
|
22138
22456
|
}, [activeSheetIndex, selectCell, setActiveSheetIndex, sheets]);
|
|
22139
22457
|
const startEditing = q(
|
|
22140
|
-
(cell, initialValue) => {
|
|
22458
|
+
(cell, initialValue, trigger = "keyboard") => {
|
|
22141
22459
|
if (readOnly) {
|
|
22142
22460
|
return;
|
|
22143
22461
|
}
|
|
22144
22462
|
selectCell(cell);
|
|
22145
|
-
|
|
22146
|
-
|
|
22463
|
+
const target = { ...cell };
|
|
22464
|
+
editingCellRef.current = target;
|
|
22465
|
+
setEditingCell(target);
|
|
22147
22466
|
const formula = getCellFormula(cell);
|
|
22148
22467
|
const worksheet2 = getActiveWorksheet();
|
|
22149
22468
|
const value = formula ? formula.startsWith("=") ? formula : `=${formula}` : worksheet2 ? getCellEditingValue(worksheet2, cell, locale) : getControllerCellDisplayValue(cell);
|
|
22150
22469
|
editingOriginalValueRef.current = initialValue === void 0 ? value : null;
|
|
22470
|
+
editingSavedValueRef.current = value;
|
|
22471
|
+
editingTriggerRef.current = trigger;
|
|
22151
22472
|
setEditingValue(initialValue ?? value);
|
|
22152
22473
|
},
|
|
22153
22474
|
[getActiveWorksheet, getCellFormula, getControllerCellDisplayValue, locale, readOnly, selectCell]
|
|
@@ -22162,7 +22483,7 @@ function XlsxGrid({
|
|
|
22162
22483
|
setCellValue(cell, value);
|
|
22163
22484
|
}
|
|
22164
22485
|
}, [getActiveWorksheet, locale, setCellFormula, setCellValue]);
|
|
22165
|
-
const commitEditing = q(() => {
|
|
22486
|
+
const commitEditing = q((nextValue) => {
|
|
22166
22487
|
if (!editingCell || !editingCellRef.current) {
|
|
22167
22488
|
return;
|
|
22168
22489
|
}
|
|
@@ -22173,7 +22494,7 @@ function XlsxGrid({
|
|
|
22173
22494
|
focusGrid();
|
|
22174
22495
|
return;
|
|
22175
22496
|
}
|
|
22176
|
-
saveEditingValue(editingCell, editingValue);
|
|
22497
|
+
saveEditingValue(editingCell, nextValue ?? editingValue);
|
|
22177
22498
|
editingCellRef.current = null;
|
|
22178
22499
|
setEditingCell(null);
|
|
22179
22500
|
setEditingValue("");
|
|
@@ -22185,12 +22506,37 @@ function XlsxGrid({
|
|
|
22185
22506
|
setEditingValue("");
|
|
22186
22507
|
focusGrid();
|
|
22187
22508
|
}, [focusGrid]);
|
|
22188
|
-
const
|
|
22509
|
+
const { session: cellEditorSession, hasPreview: hasEditorPreview } = useCellEditorSession({
|
|
22510
|
+
enabled: !!renderCellEditorOverlay && !readOnly && !isLoading,
|
|
22511
|
+
cell: editingCell,
|
|
22512
|
+
sheetIndex: activeSheetIndex,
|
|
22513
|
+
sheetName: activeSheet?.name ?? "",
|
|
22514
|
+
originalValue: editingSavedValueRef.current,
|
|
22515
|
+
trigger: editingTriggerRef.current,
|
|
22516
|
+
value: editingValue,
|
|
22517
|
+
inputRef: editingInputRef,
|
|
22518
|
+
isEditing: () => editingCell !== null && editingCellRef.current === editingCell && !readOnlyRef.current,
|
|
22519
|
+
onChange: setEditingValue,
|
|
22520
|
+
onCommit: commitEditing,
|
|
22521
|
+
onCancel: cancelEditing
|
|
22522
|
+
});
|
|
22523
|
+
const exitEditorScope = q(() => {
|
|
22524
|
+
if (hasEditorPreview()) cancelEditing();
|
|
22525
|
+
else commitEditing();
|
|
22526
|
+
}, [cancelEditing, commitEditing, hasEditorPreview]);
|
|
22527
|
+
const focusEditorOverlay = q(() => {
|
|
22528
|
+
const target = editorOverlayRef.current?.querySelector('button:not(:disabled), input:not(:disabled), textarea:not(:disabled), select:not(:disabled), a[href], [tabindex="0"]');
|
|
22529
|
+
if (!target) return false;
|
|
22530
|
+
target.focus({ preventScroll: true });
|
|
22531
|
+
return true;
|
|
22532
|
+
}, []);
|
|
22533
|
+
const handleEditingBlur = q((event) => {
|
|
22189
22534
|
if (!editingCellRef.current) {
|
|
22190
22535
|
return;
|
|
22191
22536
|
}
|
|
22192
|
-
|
|
22193
|
-
|
|
22537
|
+
if (event.relatedTarget && editorOverlayRef.current?.contains(event.relatedTarget)) return;
|
|
22538
|
+
exitEditorScope();
|
|
22539
|
+
}, [exitEditorScope]);
|
|
22194
22540
|
const handleEditingNavigate = q((key, value) => {
|
|
22195
22541
|
const cell = editingCellRef.current;
|
|
22196
22542
|
if (!cell) {
|
|
@@ -22199,7 +22545,7 @@ function XlsxGrid({
|
|
|
22199
22545
|
const currentRowIndex = rowIndexByActual.get(cell.row);
|
|
22200
22546
|
const currentColIndex = colIndexByActual.get(cell.col);
|
|
22201
22547
|
if (currentRowIndex === void 0 || currentColIndex === void 0) {
|
|
22202
|
-
if (!readOnlyRef.current) {
|
|
22548
|
+
if (!readOnlyRef.current && !hasEditorPreview()) {
|
|
22203
22549
|
saveEditingValue(cell, value);
|
|
22204
22550
|
}
|
|
22205
22551
|
editingCellRef.current = null;
|
|
@@ -22226,7 +22572,7 @@ function XlsxGrid({
|
|
|
22226
22572
|
default:
|
|
22227
22573
|
return;
|
|
22228
22574
|
}
|
|
22229
|
-
if (!readOnlyRef.current) {
|
|
22575
|
+
if (!readOnlyRef.current && !hasEditorPreview()) {
|
|
22230
22576
|
saveEditingValue(cell, value);
|
|
22231
22577
|
}
|
|
22232
22578
|
editingCellRef.current = null;
|
|
@@ -22234,7 +22580,7 @@ function XlsxGrid({
|
|
|
22234
22580
|
setEditingValue("");
|
|
22235
22581
|
moveSelection(nextRowIndex, nextColIndex, false);
|
|
22236
22582
|
focusGrid();
|
|
22237
|
-
}, [colIndexByActual, focusGrid, rowIndexByActual, saveEditingValue, visibleCols, visibleRows]);
|
|
22583
|
+
}, [colIndexByActual, focusGrid, hasEditorPreview, rowIndexByActual, saveEditingValue, visibleCols, visibleRows]);
|
|
22238
22584
|
h(() => {
|
|
22239
22585
|
commitEditingRef.current = commitEditing;
|
|
22240
22586
|
}, [commitEditing]);
|
|
@@ -23885,7 +24231,7 @@ function XlsxGrid({
|
|
|
23885
24231
|
});
|
|
23886
24232
|
}
|
|
23887
24233
|
const handleCellDoubleClick = q((cell) => {
|
|
23888
|
-
startEditing(cell);
|
|
24234
|
+
startEditing(cell, void 0, "double-click");
|
|
23889
24235
|
}, [startEditing]);
|
|
23890
24236
|
const handleCellClick = q((cell, cellData) => {
|
|
23891
24237
|
if (!cellData.hyperlink) {
|
|
@@ -24362,7 +24708,7 @@ function XlsxGrid({
|
|
|
24362
24708
|
if (!cell) {
|
|
24363
24709
|
return;
|
|
24364
24710
|
}
|
|
24365
|
-
startEditing(cell);
|
|
24711
|
+
startEditing(cell, void 0, "double-click");
|
|
24366
24712
|
}, [readOnly, resolvePointerCellFromClient, startEditing]);
|
|
24367
24713
|
const handleCanvasColumnHeaderPointerDown = q((event) => {
|
|
24368
24714
|
if (event.button !== 0 || firstVisibleRow === void 0 || lastVisibleRow === void 0) {
|
|
@@ -27396,7 +27742,7 @@ function XlsxGrid({
|
|
|
27396
27742
|
const isCommandNavigation = event.ctrlKey || event.metaKey;
|
|
27397
27743
|
if (!readOnly && isPrintableKey(event)) {
|
|
27398
27744
|
event.preventDefault();
|
|
27399
|
-
startEditing(currentCell, event.key);
|
|
27745
|
+
startEditing(currentCell, event.key, "typing");
|
|
27400
27746
|
return;
|
|
27401
27747
|
}
|
|
27402
27748
|
switch (event.key) {
|
|
@@ -27964,8 +28310,8 @@ function XlsxGrid({
|
|
|
27964
28310
|
] }),
|
|
27965
28311
|
editingCell && editingOverlayRect ? (() => {
|
|
27966
28312
|
const editingCellData = getCellData(editingCell.row, editingCell.col);
|
|
27967
|
-
const editingCellStyle = { ...editingCellData.style };
|
|
27968
|
-
if (editingCellData.usesGeneralAlignment) {
|
|
28313
|
+
const editingCellStyle = { ...editingCellData.style, ...cellEditorStyle };
|
|
28314
|
+
if (editingCellData.usesGeneralAlignment && cellEditorStyle?.textAlign === void 0) {
|
|
27969
28315
|
const enteredValue = worksheet && isTextCell(worksheet, editingCell) ? editingValue : coerceUserEnteredValue(editingValue, locale);
|
|
27970
28316
|
editingCellStyle.textAlign = typeof enteredValue === "number" ? "right" : typeof enteredValue === "boolean" ? "center" : "left";
|
|
27971
28317
|
}
|
|
@@ -27985,6 +28331,8 @@ function XlsxGrid({
|
|
|
27985
28331
|
children: /* @__PURE__ */ u(
|
|
27986
28332
|
CellEditor,
|
|
27987
28333
|
{
|
|
28334
|
+
editorRef: editorElementRef,
|
|
28335
|
+
onFocusOverlay: renderCellEditorOverlay ? focusEditorOverlay : void 0,
|
|
27988
28336
|
canvasText: true,
|
|
27989
28337
|
canvasOffset: {
|
|
27990
28338
|
left: editingOverlayRect.left - drawingViewport.left - (stickyLeftByCol.has(editingCell.col) ? displayRowHeaderWidth : scrollBodyCanvasLeft),
|
|
@@ -28024,9 +28372,9 @@ function XlsxGrid({
|
|
|
28024
28372
|
value: editingValue,
|
|
28025
28373
|
references: formulaReferences,
|
|
28026
28374
|
onBlur: handleEditingBlur,
|
|
28027
|
-
onChange: setEditingValue,
|
|
28028
|
-
onCommit: commitEditing,
|
|
28029
|
-
onCancel: cancelEditing,
|
|
28375
|
+
onChange: cellEditorSession?.setValue ?? setEditingValue,
|
|
28376
|
+
onCommit: cellEditorSession?.commit ?? commitEditing,
|
|
28377
|
+
onCancel: cellEditorSession?.cancel ?? cancelEditing,
|
|
28030
28378
|
onNavigate: handleEditingNavigate,
|
|
28031
28379
|
style: {
|
|
28032
28380
|
backgroundColor: editingBackground,
|
|
@@ -28036,7 +28384,8 @@ function XlsxGrid({
|
|
|
28036
28384
|
lineHeight: editingCellStyle.lineHeight,
|
|
28037
28385
|
textAlign: editingCellStyle.textAlign,
|
|
28038
28386
|
verticalAlign: editingCellStyle.verticalAlign,
|
|
28039
|
-
padding: editingCellStyle.padding
|
|
28387
|
+
padding: editingCellStyle.padding,
|
|
28388
|
+
...cellEditorStyle
|
|
28040
28389
|
}
|
|
28041
28390
|
}
|
|
28042
28391
|
)
|
|
@@ -28167,6 +28516,10 @@ function XlsxGrid({
|
|
|
28167
28516
|
actualRow,
|
|
28168
28517
|
editingCell,
|
|
28169
28518
|
editingValue,
|
|
28519
|
+
editorRef: editorElementRef,
|
|
28520
|
+
editorInputRef: editingInputRef,
|
|
28521
|
+
cellEditorStyle,
|
|
28522
|
+
onFocusEditorOverlay: renderCellEditorOverlay ? focusEditorOverlay : void 0,
|
|
28170
28523
|
formulaReferences,
|
|
28171
28524
|
editorBoxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
|
|
28172
28525
|
frozenRowHeaderZIndex: frozenRowHeaderOverlayZIndex,
|
|
@@ -28176,10 +28529,10 @@ function XlsxGrid({
|
|
|
28176
28529
|
onCellDoubleClick: handleCellDoubleClick,
|
|
28177
28530
|
onCellPointerDown: handleCellPointerDown,
|
|
28178
28531
|
onEditingBlur: handleEditingBlur,
|
|
28179
|
-
onEditingCancel: cancelEditing,
|
|
28180
|
-
onEditingCommit: commitEditing,
|
|
28532
|
+
onEditingCancel: cellEditorSession?.cancel ?? cancelEditing,
|
|
28533
|
+
onEditingCommit: cellEditorSession?.commit ?? commitEditing,
|
|
28181
28534
|
onEditingNavigate: handleEditingNavigate,
|
|
28182
|
-
onEditingValueChange: setEditingValue,
|
|
28535
|
+
onEditingValueChange: cellEditorSession?.setValue ?? setEditingValue,
|
|
28183
28536
|
headerLabelLiveScale,
|
|
28184
28537
|
onRowHeaderRef: setRowHeaderRef,
|
|
28185
28538
|
onRowPointerDown: handleRowPointerDown,
|
|
@@ -28331,6 +28684,42 @@ function XlsxGrid({
|
|
|
28331
28684
|
);
|
|
28332
28685
|
return /* @__PURE__ */ u("div", { style: { backgroundColor: palette.canvas, display: "flex", flex: 1, minHeight: 0, minWidth: 0 }, children: [
|
|
28333
28686
|
renderScroller ? renderScroller({ children: scrollerContent, viewportProps: scrollerViewportProps }) : /* @__PURE__ */ u("div", { ...scrollerViewportProps, children: scrollerContent }, activeTabIndex),
|
|
28687
|
+
renderSelectionPopover && normalizedSelection && activeCell && !isLoading && interactionMode === "idle" && !contextMenu && /* @__PURE__ */ u(
|
|
28688
|
+
SelectionPopover,
|
|
28689
|
+
{
|
|
28690
|
+
context: { cell: resolveMergeAnchorCell(activeCell), selection: normalizedSelection, sheetIndex: activeSheetIndex, sheetName: activeSheet?.name ?? "", readOnly },
|
|
28691
|
+
suspended: !!editingCell,
|
|
28692
|
+
viewportRef: scrollRef,
|
|
28693
|
+
getRects: () => {
|
|
28694
|
+
const elements = experimentalCanvas ? [...selectionPaneOverlayRefs.current.values()] : [selectionOverlayRef.current];
|
|
28695
|
+
return elements.flatMap((element) => {
|
|
28696
|
+
if (!element) return [];
|
|
28697
|
+
const bounds = element.getBoundingClientRect();
|
|
28698
|
+
const pane = experimentalCanvas ? element.parentElement?.parentElement?.getBoundingClientRect() : null;
|
|
28699
|
+
const left = Math.max(bounds.left, pane?.left ?? -Infinity);
|
|
28700
|
+
const top = Math.max(bounds.top, pane?.top ?? -Infinity);
|
|
28701
|
+
const right = Math.min(bounds.right, pane?.right ?? Infinity);
|
|
28702
|
+
const bottom = Math.min(bounds.bottom, pane?.bottom ?? Infinity);
|
|
28703
|
+
return right > left && bottom > top ? [{ left, top, width: right - left, height: bottom - top }] : [];
|
|
28704
|
+
});
|
|
28705
|
+
},
|
|
28706
|
+
render: renderSelectionPopover,
|
|
28707
|
+
onApply: (formula) => setCellFormula(resolveMergeAnchorCell(activeCell), formula),
|
|
28708
|
+
focusGrid
|
|
28709
|
+
},
|
|
28710
|
+
`${activeSheetIndex}:${readOnly}:${activeCell.row}:${activeCell.col}:${normalizedSelection.start.row}:${normalizedSelection.start.col}:${normalizedSelection.end.row}:${normalizedSelection.end.col}`
|
|
28711
|
+
),
|
|
28712
|
+
renderCellEditorOverlay && cellEditorSession && /* @__PURE__ */ u(
|
|
28713
|
+
CellEditorOverlay,
|
|
28714
|
+
{
|
|
28715
|
+
editorRef: editorElementRef,
|
|
28716
|
+
overlayRef: editorOverlayRef,
|
|
28717
|
+
session: cellEditorSession,
|
|
28718
|
+
render: renderCellEditorOverlay,
|
|
28719
|
+
onExit: exitEditorScope
|
|
28720
|
+
},
|
|
28721
|
+
`${activeSheetIndex}:${editingCell?.row}:${editingCell?.col}`
|
|
28722
|
+
),
|
|
28334
28723
|
enableContextMenu && contextMenu && /* @__PURE__ */ u(
|
|
28335
28724
|
XlsxContextMenu,
|
|
28336
28725
|
{
|
|
@@ -28338,7 +28727,7 @@ function XlsxGrid({
|
|
|
28338
28727
|
controller,
|
|
28339
28728
|
palette,
|
|
28340
28729
|
closeMenu: closeContextMenu,
|
|
28341
|
-
editCell: () => startEditing(contextMenu.context.cell),
|
|
28730
|
+
editCell: () => startEditing(contextMenu.context.cell, void 0, "context-menu"),
|
|
28342
28731
|
selectExtent: (kind) => selectContextExtent(kind, contextMenu.context.selection),
|
|
28343
28732
|
renderContextMenu,
|
|
28344
28733
|
contextMenuClassName,
|
|
@@ -28383,6 +28772,9 @@ function XlsxViewerInner({
|
|
|
28383
28772
|
renderScroller,
|
|
28384
28773
|
renderTableHeaderMenu,
|
|
28385
28774
|
renderActiveCellOverlay,
|
|
28775
|
+
renderCellEditorOverlay,
|
|
28776
|
+
renderSelectionPopover,
|
|
28777
|
+
cellEditorStyle,
|
|
28386
28778
|
rounded = true,
|
|
28387
28779
|
selectionColor,
|
|
28388
28780
|
selectionFillColor,
|
|
@@ -28485,6 +28877,9 @@ function XlsxViewerInner({
|
|
|
28485
28877
|
renderScroller,
|
|
28486
28878
|
renderTableHeaderMenu,
|
|
28487
28879
|
renderActiveCellOverlay,
|
|
28880
|
+
renderCellEditorOverlay,
|
|
28881
|
+
renderSelectionPopover,
|
|
28882
|
+
cellEditorStyle,
|
|
28488
28883
|
selectionColor,
|
|
28489
28884
|
selectionFillColor,
|
|
28490
28885
|
selectionHeaderColor,
|
|
@@ -28533,6 +28928,8 @@ function toReactOptions(options) {
|
|
|
28533
28928
|
fileTooLargeState,
|
|
28534
28929
|
loadingState,
|
|
28535
28930
|
renderActiveCellOverlay,
|
|
28931
|
+
renderCellEditorOverlay,
|
|
28932
|
+
renderSelectionPopover,
|
|
28536
28933
|
renderChartLoading,
|
|
28537
28934
|
renderContextMenu,
|
|
28538
28935
|
renderFormControl,
|
|
@@ -28547,6 +28944,8 @@ function toReactOptions(options) {
|
|
|
28547
28944
|
fileTooLargeState: typeof fileTooLargeState === "function" ? ({ defaultNode: _defaultNode, ...props }) => toReactContent(fileTooLargeState(props)) : toReactContent(fileTooLargeState),
|
|
28548
28945
|
loadingState: toReactContent(loadingState),
|
|
28549
28946
|
renderActiveCellOverlay: renderActiveCellOverlay ? (props) => toReactContent(renderActiveCellOverlay(props)) : void 0,
|
|
28947
|
+
renderSelectionPopover: renderSelectionPopover ? (props) => toReactContent(renderSelectionPopover(props)) : void 0,
|
|
28948
|
+
renderCellEditorOverlay: renderCellEditorOverlay ? (props) => toReactContent(renderCellEditorOverlay(props)) : void 0,
|
|
28550
28949
|
renderChartLoading: renderChartLoading ? ({ defaultNode: _defaultNode, ...props }) => toReactContent(renderChartLoading(props)) : void 0,
|
|
28551
28950
|
renderContextMenu: renderContextMenu ? ({ defaultNode: _defaultNode, ...props }) => toReactContent(renderContextMenu(props)) : void 0,
|
|
28552
28951
|
renderFormControl: renderFormControl ? (props) => toReactContent(renderFormControl({ ...props, stopPropagation: (event) => event.stopPropagation() })) : void 0,
|
|
@@ -28712,4 +29111,4 @@ export {
|
|
|
28712
29111
|
__createContentNode,
|
|
28713
29112
|
__createContentRoot
|
|
28714
29113
|
};
|
|
28715
|
-
//# sourceMappingURL=chunk-
|
|
29114
|
+
//# sourceMappingURL=chunk-2UFSVI5Z.js.map
|