@extend-ai/react-xlsx 0.20.11 → 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.
Files changed (50) hide show
  1. package/README.md +171 -4
  2. package/dist/{chunk-VSM7WKLM.js → chunk-2UFSVI5Z.js} +565 -142
  3. package/dist/chunk-2UFSVI5Z.js.map +1 -0
  4. package/dist/{chunk-SXHHFUXA.cjs → chunk-7IL4KLCD.cjs} +1729 -1306
  5. package/dist/chunk-7IL4KLCD.cjs.map +1 -0
  6. package/dist/{chunk-OGZ6ROZC.cjs → chunk-A3S3QKJN.cjs} +445 -3
  7. package/dist/chunk-A3S3QKJN.cjs.map +1 -0
  8. package/dist/chunk-IRC7BQ6E.js +538 -0
  9. package/dist/chunk-IRC7BQ6E.js.map +1 -0
  10. package/dist/{chunk-CVMHJO5H.js → chunk-WHTV6N6S.js} +443 -1
  11. package/dist/chunk-WHTV6N6S.js.map +1 -0
  12. package/dist/chunk-ZPDHTVL6.cjs +538 -0
  13. package/dist/chunk-ZPDHTVL6.cjs.map +1 -0
  14. package/dist/index.cjs +245 -159
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +135 -2
  17. package/dist/index.d.ts +135 -2
  18. package/dist/index.js +203 -117
  19. package/dist/index.js.map +1 -1
  20. package/dist/{internal-BBaC9yCh.d.cts → internal-BO70EPFy.d.cts} +130 -2
  21. package/dist/{internal-BBaC9yCh.d.ts → internal-BO70EPFy.d.ts} +130 -2
  22. package/dist/internal.cjs +3 -3
  23. package/dist/internal.d.cts +1 -1
  24. package/dist/internal.d.ts +1 -1
  25. package/dist/internal.js +2 -2
  26. package/dist/{shared-chart-XOCTF7KQ.js → shared-chart-7RUN5IKZ.js} +6 -4
  27. package/dist/shared-chart-7RUN5IKZ.js.map +1 -0
  28. package/dist/{shared-chart-CIRSCWTO.cjs → shared-chart-P3KU6TQR.cjs} +15 -13
  29. package/dist/shared-chart-P3KU6TQR.cjs.map +1 -0
  30. package/dist/{shared-chart-BLOOGI7S.js → shared-chart-UTUK46E4.js} +6 -4
  31. package/dist/shared-chart-UTUK46E4.js.map +1 -0
  32. package/dist/{shared-chart-4LUQQI2B.cjs → shared-chart-VRXD57MU.cjs} +6 -4
  33. package/dist/shared-chart-VRXD57MU.cjs.map +1 -0
  34. package/dist/vanilla.cjs +3 -3
  35. package/dist/vanilla.d.cts +2 -2
  36. package/dist/vanilla.d.ts +2 -2
  37. package/dist/vanilla.js +2 -2
  38. package/package.json +1 -1
  39. package/dist/chunk-7GBCRNGO.js +0 -94
  40. package/dist/chunk-7GBCRNGO.js.map +0 -1
  41. package/dist/chunk-CVMHJO5H.js.map +0 -1
  42. package/dist/chunk-MFOGLSFJ.cjs +0 -94
  43. package/dist/chunk-MFOGLSFJ.cjs.map +0 -1
  44. package/dist/chunk-OGZ6ROZC.cjs.map +0 -1
  45. package/dist/chunk-SXHHFUXA.cjs.map +0 -1
  46. package/dist/chunk-VSM7WKLM.js.map +0 -1
  47. package/dist/shared-chart-4LUQQI2B.cjs.map +0 -1
  48. package/dist/shared-chart-BLOOGI7S.js.map +0 -1
  49. package/dist/shared-chart-CIRSCWTO.cjs.map +0 -1
  50. package/dist/shared-chart-XOCTF7KQ.js.map +0 -1
@@ -7,20 +7,25 @@ import {
7
7
  S,
8
8
  T,
9
9
  X,
10
+ XlsxMessagesContext,
10
11
  _,
11
12
  bn,
12
13
  d,
14
+ formatMessage,
13
15
  h,
14
16
  k,
15
17
  loadOfficeFonts,
18
+ mergeMessages,
16
19
  nn,
17
20
  pn,
18
21
  q,
22
+ resolveMessages,
19
23
  u,
24
+ useXlsxMessages,
20
25
  w,
21
26
  x,
22
27
  y
23
- } from "./chunk-CVMHJO5H.js";
28
+ } from "./chunk-WHTV6N6S.js";
24
29
 
25
30
  // src/range-reference.ts
26
31
  var XLSX_MAX_ROWS = 1048576;
@@ -9590,6 +9595,7 @@ function useXlsxViewerController(options) {
9590
9595
  file,
9591
9596
  fileName,
9592
9597
  locale = "en-US",
9598
+ messages: messageOverrides,
9593
9599
  maxFileSizeBytes = DEFAULT_MAX_FILE_SIZE_BYTES,
9594
9600
  readOnly: requestedReadOnly = false,
9595
9601
  readOnlyAboveBytes = 0,
@@ -9598,6 +9604,7 @@ function useXlsxViewerController(options) {
9598
9604
  src,
9599
9605
  useWorker = true
9600
9606
  } = options;
9607
+ const messages = T(() => resolveMessages(locale, messageOverrides), [locale, messageOverrides]);
9601
9608
  const [isLoading, setIsLoading] = d(Boolean(file ?? src));
9602
9609
  const [error, setError] = d(null);
9603
9610
  const [workbook, setWorkbook] = d(null);
@@ -11734,6 +11741,28 @@ function useXlsxViewerController(options) {
11734
11741
  refreshWorkbookState(workbook);
11735
11742
  recordCellEditHistory(cell, before, after);
11736
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]);
11737
11766
  const setSelectedCellValue = q((value) => {
11738
11767
  if (!activeCell) {
11739
11768
  return;
@@ -12340,6 +12369,7 @@ function useXlsxViewerController(options) {
12340
12369
  defineNamedRange,
12341
12370
  displayFileName,
12342
12371
  locale,
12372
+ messages,
12343
12373
  download,
12344
12374
  exportCsv,
12345
12375
  exportXlsx,
@@ -12389,6 +12419,7 @@ function useXlsxViewerController(options) {
12389
12419
  resizeRow,
12390
12420
  setCellFormula,
12391
12421
  setCellStyle,
12422
+ setCellStyles,
12392
12423
  setCellValue,
12393
12424
  setRangeStyle,
12394
12425
  setSelectedFormula,
@@ -12464,6 +12495,7 @@ function useXlsxViewerController(options) {
12464
12495
  defineNamedRange,
12465
12496
  displayFileName,
12466
12497
  locale,
12498
+ messages,
12467
12499
  download,
12468
12500
  error,
12469
12501
  exportCsv,
@@ -12512,6 +12544,7 @@ function useXlsxViewerController(options) {
12512
12544
  resizeRow,
12513
12545
  setCellFormula,
12514
12546
  setCellStyle,
12547
+ setCellStyles,
12515
12548
  setCellValue,
12516
12549
  setRangeStyle,
12517
12550
  setSelectedFormula,
@@ -14124,6 +14157,8 @@ function CellEditor({
14124
14157
  value,
14125
14158
  references,
14126
14159
  inputRef,
14160
+ editorRef,
14161
+ onFocusOverlay,
14127
14162
  canvasText = false,
14128
14163
  canvasOffset,
14129
14164
  paintCanvasText,
@@ -14135,6 +14170,7 @@ function CellEditor({
14135
14170
  onNavigate
14136
14171
  }) {
14137
14172
  const rootRef = A(null);
14173
+ const messages = useXlsxMessages();
14138
14174
  const mirrorRef = A(null);
14139
14175
  const textRef = A(null);
14140
14176
  const baselineRef = A(null);
@@ -14262,7 +14298,12 @@ function CellEditor({
14262
14298
  return /* @__PURE__ */ u(
14263
14299
  "div",
14264
14300
  {
14265
- ref: rootRef,
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": "",
14266
14307
  onPointerDown: (event) => event.stopPropagation(),
14267
14308
  onClick: (event) => event.stopPropagation(),
14268
14309
  onDoubleClick: (event) => event.stopPropagation(),
@@ -14311,7 +14352,7 @@ function CellEditor({
14311
14352
  ] })
14312
14353
  }
14313
14354
  ),
14314
- 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,
14315
14356
  /* @__PURE__ */ u(
14316
14357
  "textarea",
14317
14358
  {
@@ -14320,7 +14361,8 @@ function CellEditor({
14320
14361
  if (typeof inputRef === "function") inputRef(element);
14321
14362
  else if (inputRef) inputRef.current = element;
14322
14363
  },
14323
- "aria-label": "Edit cell",
14364
+ "aria-label": messages.editCell,
14365
+ "aria-keyshortcuts": onFocusOverlay ? "Alt+ArrowDown" : void 0,
14324
14366
  autoFocus: true,
14325
14367
  autoComplete: "off",
14326
14368
  spellCheck: false,
@@ -14334,7 +14376,9 @@ function CellEditor({
14334
14376
  onKeyDown: (event) => {
14335
14377
  event.stopPropagation();
14336
14378
  if (event.nativeEvent.isComposing) return;
14337
- if (event.key === "Enter" && !event.altKey) {
14379
+ if (event.key === "ArrowDown" && event.altKey && onFocusOverlay?.()) {
14380
+ event.preventDefault();
14381
+ } else if (event.key === "Enter" && !event.altKey) {
14338
14382
  event.preventDefault();
14339
14383
  onCommit();
14340
14384
  } else if (event.key === "Escape") {
@@ -14380,6 +14424,260 @@ function CellEditor({
14380
14424
  );
14381
14425
  }
14382
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
+
14383
14681
  // src/merged-range-lookup.ts
14384
14682
  function createMergedRangeLookup(ranges) {
14385
14683
  const normalizedRanges = [];
@@ -14505,6 +14803,13 @@ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextC
14505
14803
  }
14506
14804
 
14507
14805
  // src/context-menu.tsx
14806
+ var MenuActionError = class extends Error {
14807
+ key;
14808
+ constructor(key) {
14809
+ super(key);
14810
+ this.key = key;
14811
+ }
14812
+ };
14508
14813
  var menuStyles = `
14509
14814
  :where(.react-xlsx-context-menu) {
14510
14815
  background: var(--xlsx-context-menu-background);
@@ -14542,39 +14847,42 @@ function XlsxContextMenu({
14542
14847
  contextMenuClassName,
14543
14848
  contextMenuStyle
14544
14849
  }) {
14850
+ const { messages } = controller;
14545
14851
  const rootRef = A(null);
14852
+ const abortController = T(() => new AbortController(), []);
14546
14853
  const controllerRef = A(controller);
14547
14854
  controllerRef.current = controller;
14548
14855
  const aliveRef = A(true);
14549
14856
  const runningRef = A(false);
14550
14857
  const [busy, setBusy] = d(false);
14551
- const [error, setError] = d(null);
14858
+ const [errorKey, setErrorKey] = d(null);
14859
+ const error = errorKey ? messages[errorKey] : null;
14552
14860
  const [location, setLocation] = d(position);
14553
14861
  const modifier = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform) ? "\u2318" : "Ctrl+";
14554
14862
  const table = controller.tables.find(({ start, end }) => context.cell.row >= start.row && context.cell.row <= end.row && context.cell.col >= start.col && context.cell.col <= end.col);
14555
14863
  const range = expandHighlightedRange(context.selection, controller.activeSheet?.mergedRanges ?? []);
14556
14864
  const multiple = range.start.row !== range.end.row || range.start.col !== range.end.col;
14557
14865
  const actions = [
14558
- ...!controller.readOnly ? [{ id: "cut", label: "Cut" }] : [],
14559
- { id: "copy", label: "Copy", shortcut: `${modifier}C` },
14866
+ ...!controller.readOnly ? [{ id: "cut", label: messages.cut }] : [],
14867
+ { id: "copy", label: messages.copy, shortcut: `${modifier}C` },
14560
14868
  ...!controller.readOnly ? [
14561
- { id: "paste", label: "Paste", shortcut: `${modifier}V` },
14562
- { id: "editCell", label: "Edit cell", shortcut: "F2", separatorBefore: true },
14563
- { id: "clearContents", label: "Clear contents", destructive: true },
14564
- { id: "undo", label: "Undo", shortcut: `${modifier}Z`, separatorBefore: true, disabled: !controller.canUndo },
14565
- { id: "redo", label: "Redo", shortcut: `${modifier}\u21E7Z`, disabled: !controller.canRedo },
14566
- { id: "mergeAndCenter", label: "Merge & Center", separatorBefore: true, disabled: !multiple },
14567
- { id: "mergeAcross", label: "Merge Across", disabled: range.start.col === range.end.col },
14568
- { id: "mergeCells", label: "Merge Cells", disabled: !multiple },
14569
- { id: "unmergeCells", label: "Unmerge Cells" },
14869
+ { id: "paste", label: messages.paste, shortcut: `${modifier}V` },
14870
+ { id: "editCell", label: messages.editCell, shortcut: "F2", separatorBefore: true },
14871
+ { id: "clearContents", label: messages.clearContents, destructive: true },
14872
+ { id: "undo", label: messages.undo, shortcut: `${modifier}Z`, separatorBefore: true, disabled: !controller.canUndo },
14873
+ { id: "redo", label: messages.redo, shortcut: `${modifier}\u21E7Z`, disabled: !controller.canRedo },
14874
+ { id: "mergeAndCenter", label: messages.mergeAndCenter, separatorBefore: true, disabled: !multiple },
14875
+ { id: "mergeAcross", label: messages.mergeAcross, disabled: range.start.col === range.end.col },
14876
+ { id: "mergeCells", label: messages.mergeCells, disabled: !multiple },
14877
+ { id: "unmergeCells", label: messages.unmergeCells },
14570
14878
  ...table ? [
14571
- { id: "sortAscending", label: "Sort A to Z", separatorBefore: true },
14572
- { id: "sortDescending", label: "Sort Z to A" }
14879
+ { id: "sortAscending", label: messages.sortAscending, separatorBefore: true },
14880
+ { id: "sortDescending", label: messages.sortDescending }
14573
14881
  ] : []
14574
14882
  ] : [],
14575
- { id: "selectRow", label: "Select row", separatorBefore: true },
14576
- { id: "selectColumn", label: "Select column" },
14577
- { id: "selectAll", label: "Select all", shortcut: `${modifier}A` }
14883
+ { id: "selectRow", label: messages.selectRow, separatorBefore: true },
14884
+ { id: "selectColumn", label: messages.selectColumn },
14885
+ { id: "selectAll", label: messages.selectAll, shortcut: `${modifier}A` }
14578
14886
  ];
14579
14887
  _(() => {
14580
14888
  const root = rootRef.current;
@@ -14605,13 +14913,14 @@ function XlsxContextMenu({
14605
14913
  window.addEventListener("blur", dismiss);
14606
14914
  return () => {
14607
14915
  aliveRef.current = false;
14916
+ abortController.abort();
14608
14917
  document.removeEventListener("pointerdown", outside, true);
14609
14918
  document.removeEventListener("focusin", outside);
14610
14919
  document.removeEventListener("scroll", outside, true);
14611
14920
  window.removeEventListener("resize", dismiss);
14612
14921
  window.removeEventListener("blur", dismiss);
14613
14922
  };
14614
- }, [closeMenu]);
14923
+ }, [abortController, closeMenu]);
14615
14924
  const runAction = async (id) => {
14616
14925
  const action = actions.find((item) => item.id === id);
14617
14926
  if (!aliveRef.current || runningRef.current || !action || action.disabled) return false;
@@ -14620,20 +14929,20 @@ function XlsxContextMenu({
14620
14929
  if (!isCurrent()) return false;
14621
14930
  runningRef.current = true;
14622
14931
  setBusy(true);
14623
- setError(null);
14932
+ setErrorKey(null);
14624
14933
  try {
14625
14934
  switch (id) {
14626
14935
  case "copy":
14627
14936
  case "cut": {
14628
14937
  const copied = await controller.copySelectionToClipboard();
14629
- if (!copied) throw new Error("Clipboard access is unavailable. Use the keyboard shortcut to copy.");
14938
+ if (!copied) throw new MenuActionError("clipboardCopyUnavailable");
14630
14939
  if (!isCurrent()) return false;
14631
14940
  if (id === "cut") controller.clearSelectedCells();
14632
14941
  break;
14633
14942
  }
14634
14943
  case "paste": {
14635
14944
  const clipboard = navigator.clipboard;
14636
- if (!clipboard) throw new Error("Clipboard access is unavailable. Use the keyboard shortcut to paste.");
14945
+ if (!clipboard) throw new MenuActionError("clipboardPasteUnavailable");
14637
14946
  let structured;
14638
14947
  let text;
14639
14948
  if (clipboard.read) {
@@ -14651,7 +14960,7 @@ function XlsxContextMenu({
14651
14960
  }
14652
14961
  if (!isCurrent()) return false;
14653
14962
  const pasted = structured !== void 0 ? controller.pasteStructuredClipboardData(structured) : text !== void 0 && controller.pasteText(text);
14654
- if (!pasted) throw new Error("No spreadsheet cells or text are available to paste.");
14963
+ if (!pasted) throw new MenuActionError("nothingToPaste");
14655
14964
  break;
14656
14965
  }
14657
14966
  case "clearContents":
@@ -14696,7 +15005,7 @@ function XlsxContextMenu({
14696
15005
  closeMenu();
14697
15006
  return true;
14698
15007
  } catch (cause) {
14699
- if (aliveRef.current) setError(cause instanceof Error ? cause.message : "The action could not be completed.");
15008
+ if (aliveRef.current) setErrorKey(cause instanceof MenuActionError ? cause.key : "actionFailed");
14700
15009
  return false;
14701
15010
  } finally {
14702
15011
  runningRef.current = false;
@@ -14725,12 +15034,23 @@ function XlsxContextMenu({
14725
15034
  }
14726
15035
  )
14727
15036
  ] }, action.id));
14728
- const content = renderContextMenu ? renderContextMenu({ context, actions, runAction, closeMenu, position: location, isDark: isDarkViewerPalette(palette), busy, error, defaultNode }) : defaultNode;
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;
14729
15048
  return $(
14730
15049
  /* @__PURE__ */ u(
14731
15050
  "div",
14732
15051
  {
14733
- "aria-label": "Spreadsheet context menu",
15052
+ lang: controller.locale,
15053
+ "aria-label": messages.contextMenu,
14734
15054
  "aria-busy": busy,
14735
15055
  className: ["react-xlsx-context-menu", contextMenuClassName].filter(Boolean).join(" "),
14736
15056
  "data-dark": isDarkViewerPalette(palette) ? "true" : "false",
@@ -14817,18 +15137,18 @@ function createChartModule(importModule) {
14817
15137
  var officeChartRenderer = createChartModule(async () => {
14818
15138
  const [{ loadOfficeCharts }, { SharedChartSvg }] = await Promise.all([
14819
15139
  import("./browser-AWFV5QM2.js"),
14820
- import("./shared-chart-XOCTF7KQ.js")
15140
+ import("./shared-chart-7RUN5IKZ.js")
14821
15141
  ]);
14822
15142
  return { renderer: await loadOfficeCharts(), SharedChartSvg };
14823
15143
  });
14824
15144
  var suppliedOfficeChartRenderer = createChartModule(async () => {
14825
- const { SharedChartSvg } = await import("./shared-chart-XOCTF7KQ.js");
15145
+ const { SharedChartSvg } = await import("./shared-chart-7RUN5IKZ.js");
14826
15146
  return { renderer: null, SharedChartSvg };
14827
15147
  });
14828
15148
  var officeExtendedChartRenderer = createChartModule(async () => {
14829
15149
  const [{ loadOfficeCharts }, { SharedChartSvg }] = await Promise.all([
14830
15150
  import("./full-ERXNU2LF.js"),
14831
- import("./shared-chart-XOCTF7KQ.js")
15151
+ import("./shared-chart-7RUN5IKZ.js")
14832
15152
  ]);
14833
15153
  return { renderer: await loadOfficeCharts(typeof DecompressionStream === "function" ? void 0 : new URL("./office_charts_full_bg.wasm", import.meta.url)), SharedChartSvg };
14834
15154
  });
@@ -14869,13 +15189,14 @@ var ChartLoadBoundary = class extends C {
14869
15189
  }
14870
15190
  render() {
14871
15191
  if (this.state.failed) {
14872
- return /* @__PURE__ */ u("div", { role: "status", children: "Unable to load chart." });
15192
+ return /* @__PURE__ */ u("div", { role: "status", children: this.props.errorMessage });
14873
15193
  }
14874
15194
  return this.props.children;
14875
15195
  }
14876
15196
  };
14877
15197
  function UnsupportedChart({ chart }) {
14878
- return /* @__PURE__ */ u("div", { role: "status", "data-xlsx-chart-fallback": "unsupported", children: chart.chartType === "RegionMap" ? "Map data is unavailable." : "This chart cannot be rendered." });
15198
+ const messages = useXlsxMessages();
15199
+ return /* @__PURE__ */ u("div", { role: "status", "data-xlsx-chart-fallback": "unsupported", children: chart.chartType === "RegionMap" ? messages.mapUnavailable : messages.chartUnavailable });
14879
15200
  }
14880
15201
  function SharedChart(props) {
14881
15202
  const module = useChartModule(props.experimentalOfficeCharts ? suppliedOfficeChartRenderer : props.source.experimental ? officeExtendedChartRenderer : officeChartRenderer);
@@ -14885,7 +15206,8 @@ function SharedChart(props) {
14885
15206
  return renderer && module.SharedChartSvg ? /* @__PURE__ */ u(module.SharedChartSvg, { ...props, renderer, fallback }) : fallback;
14886
15207
  }
14887
15208
  function MemoChartSvg(props) {
14888
- return /* @__PURE__ */ u(ChartLoadBoundary, { children: props.chart.renderSource ? /* @__PURE__ */ u(SharedChart, { ...props, source: props.chart.renderSource }) : /* @__PURE__ */ u(UnsupportedChart, { chart: props.chart }) }, props.chart.id);
15209
+ const messages = useXlsxMessages();
15210
+ return /* @__PURE__ */ u(ChartLoadBoundary, { errorMessage: messages.loadChartFailed, children: props.chart.renderSource ? /* @__PURE__ */ u(SharedChart, { ...props, source: props.chart.renderSource }) : /* @__PURE__ */ u(UnsupportedChart, { chart: props.chart }) }, props.chart.id);
14889
15211
  }
14890
15212
 
14891
15213
  // src/picture-paint.ts
@@ -15654,8 +15976,8 @@ function drawCanvasConditionalIcon(context, icon, centerX, centerY, size) {
15654
15976
  context.fill();
15655
15977
  context.restore();
15656
15978
  }
15657
- function formatZoomScale(zoomScale) {
15658
- return `${Math.round(zoomScale)}%`;
15979
+ function formatZoomScale(zoomScale, locale) {
15980
+ return new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 }).format(zoomScale / 100);
15659
15981
  }
15660
15982
  function clampValue(value, min, max) {
15661
15983
  return Math.min(max, Math.max(min, value));
@@ -18269,6 +18591,7 @@ function DefaultTableHeaderMenu({
18269
18591
  sortAscending,
18270
18592
  sortDescending
18271
18593
  }) {
18594
+ const messages = useXlsxMessages();
18272
18595
  return /* @__PURE__ */ u(
18273
18596
  "div",
18274
18597
  {
@@ -18298,7 +18621,7 @@ function DefaultTableHeaderMenu({
18298
18621
  textAlign: "left"
18299
18622
  },
18300
18623
  type: "button",
18301
- children: "Sort A to Z"
18624
+ children: messages.sortAscending
18302
18625
  }
18303
18626
  ),
18304
18627
  /* @__PURE__ */ u(
@@ -18316,7 +18639,7 @@ function DefaultTableHeaderMenu({
18316
18639
  textAlign: "left"
18317
18640
  },
18318
18641
  type: "button",
18319
- children: "Sort Z to A"
18642
+ children: messages.sortDescending
18320
18643
  }
18321
18644
  )
18322
18645
  ]
@@ -18379,6 +18702,7 @@ function drawCanvasTableHeaderTrigger(context, rect, direction, palette, zoomFac
18379
18702
  }
18380
18703
  function SegmentedControl({
18381
18704
  items,
18705
+ messages,
18382
18706
  onValueChange,
18383
18707
  palette,
18384
18708
  value
@@ -18386,7 +18710,7 @@ function SegmentedControl({
18386
18710
  return /* @__PURE__ */ u(
18387
18711
  "div",
18388
18712
  {
18389
- "aria-label": "Workbook sheets",
18713
+ "aria-label": messages.workbookSheets,
18390
18714
  role: "tablist",
18391
18715
  style: {
18392
18716
  alignItems: "center",
@@ -18438,6 +18762,8 @@ function DefaultToolbar({ controller, palette }) {
18438
18762
  canZoomIn,
18439
18763
  canZoomOut,
18440
18764
  defaultZoomScale,
18765
+ locale,
18766
+ messages,
18441
18767
  displayFileName,
18442
18768
  download,
18443
18769
  resetZoom,
@@ -18493,6 +18819,7 @@ function DefaultToolbar({ controller, palette }) {
18493
18819
  /* @__PURE__ */ u(
18494
18820
  "button",
18495
18821
  {
18822
+ "aria-label": messages.zoomOut,
18496
18823
  disabled: !canZoomOut,
18497
18824
  onClick: zoomOut,
18498
18825
  style: {
@@ -18511,6 +18838,7 @@ function DefaultToolbar({ controller, palette }) {
18511
18838
  /* @__PURE__ */ u(
18512
18839
  "button",
18513
18840
  {
18841
+ "aria-label": messages.resetZoom,
18514
18842
  onClick: resetZoom,
18515
18843
  style: {
18516
18844
  background: Math.round(zoomScale) === Math.round(defaultZoomScale) ? "transparent" : palette.subtleSurface,
@@ -18525,12 +18853,13 @@ function DefaultToolbar({ controller, palette }) {
18525
18853
  padding: "6px 10px"
18526
18854
  },
18527
18855
  type: "button",
18528
- children: formatZoomScale(zoomScale)
18856
+ children: formatZoomScale(zoomScale, locale)
18529
18857
  }
18530
18858
  ),
18531
18859
  /* @__PURE__ */ u(
18532
18860
  "button",
18533
18861
  {
18862
+ "aria-label": messages.zoomIn,
18534
18863
  disabled: !canZoomIn,
18535
18864
  onClick: zoomIn,
18536
18865
  style: {
@@ -18552,7 +18881,7 @@ function DefaultToolbar({ controller, palette }) {
18552
18881
  canDownload ? /* @__PURE__ */ u(
18553
18882
  "button",
18554
18883
  {
18555
- "aria-label": "Download workbook",
18884
+ "aria-label": messages.downloadWorkbook,
18556
18885
  onClick: download,
18557
18886
  style: {
18558
18887
  alignItems: "center",
@@ -18569,7 +18898,7 @@ function DefaultToolbar({ controller, palette }) {
18569
18898
  padding: 0,
18570
18899
  width: 32
18571
18900
  },
18572
- title: "Download workbook",
18901
+ title: messages.downloadWorkbook,
18573
18902
  type: "button",
18574
18903
  children: "\u2193"
18575
18904
  }
@@ -18590,10 +18919,11 @@ function DefaultToolbar({ controller, palette }) {
18590
18919
  children: /* @__PURE__ */ u(
18591
18920
  SegmentedControl,
18592
18921
  {
18922
+ messages,
18593
18923
  items: tabs.map((tab, index) => ({
18594
18924
  id: String(index),
18595
18925
  label: tab.name,
18596
- title: tab.visibility === "hidden" ? `${tab.name} (hidden)` : tab.visibility === "veryHidden" ? `${tab.name} (very hidden)` : tab.name,
18926
+ title: tab.visibility === "hidden" ? formatMessage(messages.hiddenSheet, { sheet: tab.name }) : tab.visibility === "veryHidden" ? formatMessage(messages.veryHiddenSheet, { sheet: tab.name }) : tab.name,
18597
18927
  visibility: tab.visibility
18598
18928
  })),
18599
18929
  onValueChange: (value) => setActiveTabIndex(Number(value)),
@@ -18617,7 +18947,7 @@ function resolveToolbar(toolbar, showDefaultToolbar, controller, palette) {
18617
18947
  }
18618
18948
  return /* @__PURE__ */ u(DefaultToolbar, { controller, palette });
18619
18949
  }
18620
- function renderError(errorState, error, palette) {
18950
+ function renderError(errorState, error, palette, messages) {
18621
18951
  if (typeof errorState === "function") {
18622
18952
  return errorState(error);
18623
18953
  }
@@ -18637,11 +18967,11 @@ function renderError(errorState, error, palette) {
18637
18967
  padding: 16,
18638
18968
  textAlign: "center"
18639
18969
  },
18640
- children: error.message
18970
+ children: messages.loadWorkbookFailed
18641
18971
  }
18642
18972
  );
18643
18973
  }
18644
- function renderLoading(loadingComponent, loadingState, palette) {
18974
+ function renderLoading(loadingComponent, loadingState, palette, messages) {
18645
18975
  if (loadingComponent !== void 0) {
18646
18976
  return loadingComponent;
18647
18977
  }
@@ -18659,11 +18989,11 @@ function renderLoading(loadingComponent, loadingState, palette) {
18659
18989
  height: "100%",
18660
18990
  justifyContent: "center"
18661
18991
  },
18662
- children: "Loading workbook..."
18992
+ children: messages.loadingWorkbook
18663
18993
  }
18664
18994
  );
18665
18995
  }
18666
- function renderEmpty(emptyState, palette) {
18996
+ function renderEmpty(emptyState, palette, messages) {
18667
18997
  if (emptyState !== void 0) {
18668
18998
  return emptyState;
18669
18999
  }
@@ -18680,24 +19010,26 @@ function renderEmpty(emptyState, palette) {
18680
19010
  padding: 16,
18681
19011
  textAlign: "center"
18682
19012
  },
18683
- children: "No workbook loaded."
19013
+ children: messages.emptyWorkbook
18684
19014
  }
18685
19015
  );
18686
19016
  }
18687
- function formatBinaryBytes2(bytes) {
18688
- if (!Number.isFinite(bytes) || bytes <= 0) {
18689
- return "0 B";
18690
- }
18691
- const units = ["B", "KB", "MB", "GB"];
18692
- let value = bytes;
19017
+ function formatBinaryBytes2(bytes, locale) {
19018
+ const units = ["byte", "kilobyte", "megabyte", "gigabyte"];
19019
+ let value = Number.isFinite(bytes) && bytes > 0 ? bytes : 0;
18693
19020
  let unitIndex = 0;
18694
19021
  while (value >= 1024 && unitIndex < units.length - 1) {
18695
19022
  value /= 1024;
18696
19023
  unitIndex += 1;
18697
19024
  }
18698
- return `${value >= 10 || unitIndex === 0 ? value.toFixed(0) : value.toFixed(1)} ${units[unitIndex]}`;
19025
+ return new Intl.NumberFormat(locale, {
19026
+ style: "unit",
19027
+ unit: units[unitIndex],
19028
+ unitDisplay: "short",
19029
+ maximumFractionDigits: value >= 10 || unitIndex === 0 ? 0 : 1
19030
+ }).format(value);
18699
19031
  }
18700
- function renderFileTooLarge(fileTooLargeState, renderProps, palette) {
19032
+ function renderFileTooLarge(fileTooLargeState, renderProps, palette, messages, locale) {
18701
19033
  const defaultNode = /* @__PURE__ */ u(
18702
19034
  "div",
18703
19035
  {
@@ -18715,14 +19047,10 @@ function renderFileTooLarge(fileTooLargeState, renderProps, palette) {
18715
19047
  },
18716
19048
  children: [
18717
19049
  /* @__PURE__ */ u("div", { style: { color: palette.text, fontWeight: 600 }, children: renderProps.displayFileName }),
18718
- /* @__PURE__ */ u("div", { children: [
18719
- "File size ",
18720
- formatBinaryBytes2(renderProps.fileSizeBytes),
18721
- " exceeds the configured limit of",
18722
- " ",
18723
- formatBinaryBytes2(renderProps.maxFileSizeBytes),
18724
- "."
18725
- ] })
19050
+ /* @__PURE__ */ u("div", { children: formatMessage(messages.fileTooLarge, {
19051
+ size: formatBinaryBytes2(renderProps.fileSizeBytes, locale),
19052
+ limit: formatBinaryBytes2(renderProps.maxFileSizeBytes, locale)
19053
+ }) })
18726
19054
  ]
18727
19055
  }
18728
19056
  );
@@ -18739,19 +19067,21 @@ function renderFileTooLarge(fileTooLargeState, renderProps, palette) {
18739
19067
  }
18740
19068
  return defaultNode;
18741
19069
  }
18742
- function renderCustomFileTooLarge(fileTooLargeState, renderProps, palette) {
19070
+ function renderCustomFileTooLarge(fileTooLargeState, renderProps, palette, messages, locale) {
18743
19071
  if (fileTooLargeState === void 0) {
18744
19072
  return void 0;
18745
19073
  }
18746
- return renderFileTooLarge(fileTooLargeState, renderProps, palette);
19074
+ return renderFileTooLarge(fileTooLargeState, renderProps, palette, messages, locale);
18747
19075
  }
18748
- function renderDefaultChartLoadingCard(rect) {
19076
+ function renderDefaultChartLoadingCard(rect, messages) {
18749
19077
  const bars = [18, 32, 24];
18750
19078
  const barWidth = Math.max(8, Math.min(12, Math.round(rect.width * 0.018)));
18751
19079
  const barGap = 8;
18752
19080
  return /* @__PURE__ */ u(
18753
19081
  "div",
18754
19082
  {
19083
+ role: "status",
19084
+ "aria-label": messages.loadingChart,
18755
19085
  style: {
18756
19086
  backgroundColor: "#ffffff",
18757
19087
  border: "1px solid #e5e7eb",
@@ -18789,8 +19119,8 @@ function renderDefaultChartLoadingCard(rect) {
18789
19119
  }
18790
19120
  );
18791
19121
  }
18792
- function renderChartLoadingNode(renderChartLoading, chart, rect, stage = "metadata") {
18793
- const defaultNode = renderDefaultChartLoadingCard(rect);
19122
+ function renderChartLoadingNode(renderChartLoading, chart, rect, messages, stage = "metadata") {
19123
+ const defaultNode = renderDefaultChartLoadingCard(rect, messages);
18794
19124
  if (!renderChartLoading) {
18795
19125
  return defaultNode;
18796
19126
  }
@@ -18801,19 +19131,6 @@ function renderChartLoadingNode(renderChartLoading, chart, rect, stage = "metada
18801
19131
  stage
18802
19132
  });
18803
19133
  }
18804
- function formatBytes(value) {
18805
- if (!Number.isFinite(value) || value <= 0) {
18806
- return "0 B";
18807
- }
18808
- const units = ["B", "KB", "MB", "GB"];
18809
- let size = value;
18810
- let unitIndex = 0;
18811
- while (size >= 1024 && unitIndex < units.length - 1) {
18812
- size /= 1024;
18813
- unitIndex += 1;
18814
- }
18815
- return `${size >= 10 || unitIndex === 0 ? size.toFixed(0) : size.toFixed(1)} ${units[unitIndex]}`;
18816
- }
18817
19134
  function renderDeferredLoad(controller, palette) {
18818
19135
  return /* @__PURE__ */ u(
18819
19136
  "div",
@@ -18839,13 +19156,8 @@ function renderDeferredLoad(controller, palette) {
18839
19156
  width: "100%"
18840
19157
  },
18841
19158
  children: [
18842
- /* @__PURE__ */ u("div", { style: { fontSize: 16, fontWeight: 600 }, children: "Large workbook detected" }),
18843
- /* @__PURE__ */ u("div", { style: { color: palette.mutedText, fontSize: 13, lineHeight: 1.5, marginTop: 8 }, children: [
18844
- "This workbook is ",
18845
- formatBytes(controller.deferredLoadFileSize ?? 0),
18846
- ". Loading it immediately can block the main thread and freeze the page."
18847
- ] }),
18848
- /* @__PURE__ */ u("div", { style: { color: palette.mutedText, fontSize: 13, lineHeight: 1.5, marginTop: 8 }, children: "Best practice is to gate large files or move parsing into a worker. You can still load it manually below." }),
19159
+ /* @__PURE__ */ u("div", { style: { fontSize: 16, fontWeight: 600 }, children: controller.messages.largeWorkbook }),
19160
+ /* @__PURE__ */ u("div", { style: { color: palette.mutedText, fontSize: 13, lineHeight: 1.5, marginTop: 8 }, children: formatMessage(controller.messages.deferredLoadDescription, { size: formatBinaryBytes2(controller.deferredLoadFileSize ?? 0, controller.locale) }) }),
18849
19161
  /* @__PURE__ */ u("div", { style: { display: "flex", gap: 10, marginTop: 16 }, children: /* @__PURE__ */ u(
18850
19162
  "button",
18851
19163
  {
@@ -18862,7 +19174,7 @@ function renderDeferredLoad(controller, palette) {
18862
19174
  padding: "8px 12px"
18863
19175
  },
18864
19176
  type: "button",
18865
- children: "Load Anyway"
19177
+ children: controller.messages.loadAnyway
18866
19178
  }
18867
19179
  ) })
18868
19180
  ]
@@ -19660,6 +19972,10 @@ function GridRow({
19660
19972
  editingValue,
19661
19973
  formulaReferences,
19662
19974
  editorBoxShadow,
19975
+ editorRef,
19976
+ editorInputRef,
19977
+ cellEditorStyle,
19978
+ onFocusEditorOverlay,
19663
19979
  frozenRowHeaderZIndex,
19664
19980
  getCellData,
19665
19981
  headerLabelLiveScale,
@@ -19995,6 +20311,9 @@ function GridRow({
19995
20311
  isEditing ? /* @__PURE__ */ u(
19996
20312
  CellEditor,
19997
20313
  {
20314
+ editorRef,
20315
+ inputRef: editorInputRef,
20316
+ onFocusOverlay: onFocusEditorOverlay,
19998
20317
  value: editingValue,
19999
20318
  references: formulaReferences,
20000
20319
  onBlur: onEditingBlur,
@@ -20009,7 +20328,8 @@ function GridRow({
20009
20328
  font: "inherit",
20010
20329
  lineHeight: cellData.style.lineHeight,
20011
20330
  verticalAlign: cellData.style.verticalAlign,
20012
- padding: cellData.style.padding
20331
+ padding: cellData.style.padding,
20332
+ ...cellEditorStyle
20013
20333
  }
20014
20334
  }
20015
20335
  ) : isSpilling ? /* @__PURE__ */ u(
@@ -20073,7 +20393,7 @@ function GridRow({
20073
20393
  ] });
20074
20394
  }
20075
20395
  var MemoGridRow = N(GridRow, (prev, next) => {
20076
- 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) {
20077
20397
  return false;
20078
20398
  }
20079
20399
  const prevEditingCol = prev.editingCell?.row === prev.actualRow ? prev.editingCell.col : -1;
@@ -20110,6 +20430,9 @@ function XlsxGrid({
20110
20430
  renderImageSelection,
20111
20431
  renderTableHeaderMenu,
20112
20432
  renderActiveCellOverlay,
20433
+ renderCellEditorOverlay,
20434
+ renderSelectionPopover,
20435
+ cellEditorStyle,
20113
20436
  renderScroller,
20114
20437
  enableGestureZoom = true,
20115
20438
  experimentalCanvas = true,
@@ -20145,6 +20468,7 @@ function XlsxGrid({
20145
20468
  getCellDisplayValue: getControllerCellDisplayValue,
20146
20469
  getCellFormula,
20147
20470
  locale,
20471
+ messages,
20148
20472
  getFormControlItems,
20149
20473
  highlightedRanges,
20150
20474
  images,
@@ -20261,6 +20585,10 @@ function XlsxGrid({
20261
20585
  const commitEditingRef = A(() => {
20262
20586
  });
20263
20587
  const editingInputRef = A(null);
20588
+ const editorElementRef = A(null);
20589
+ const editorOverlayRef = A(null);
20590
+ const editingSavedValueRef = A("");
20591
+ const editingTriggerRef = A("keyboard");
20264
20592
  const readOnlyRef = A(readOnly);
20265
20593
  const committedZoomScaleRef = A(zoomScale);
20266
20594
  const gestureZoomScaleRef = A(zoomScale);
@@ -20363,9 +20691,11 @@ function XlsxGrid({
20363
20691
  const skipNextImageClickRef = A(null);
20364
20692
  const [pendingNavigation, setPendingNavigation] = d(null);
20365
20693
  const interactionModeRef = A("idle");
20694
+ const [interactionMode, setRenderedInteractionMode] = d("idle");
20366
20695
  const setInteractionMode = q((mode) => {
20367
20696
  interactionModeRef.current = mode;
20368
- }, []);
20697
+ if (renderSelectionPopover) setRenderedInteractionMode(mode);
20698
+ }, [!!renderSelectionPopover]);
20369
20699
  const worksheet = T(
20370
20700
  () => getActiveWorksheet(),
20371
20701
  [activeSheetIndex, getActiveWorksheet, revision]
@@ -22037,6 +22367,7 @@ function XlsxGrid({
22037
22367
  rowPreviewRef.current = null;
22038
22368
  setResizeGuide(null);
22039
22369
  clearGlobalCursor();
22370
+ editingCellRef.current = null;
22040
22371
  setEditingCell(null);
22041
22372
  setEditingValue("");
22042
22373
  setFillPreviewRange(null);
@@ -22124,17 +22455,20 @@ function XlsxGrid({
22124
22455
  window.open(url.href, "_blank", "noopener,noreferrer");
22125
22456
  }, [activeSheetIndex, selectCell, setActiveSheetIndex, sheets]);
22126
22457
  const startEditing = q(
22127
- (cell, initialValue) => {
22458
+ (cell, initialValue, trigger = "keyboard") => {
22128
22459
  if (readOnly) {
22129
22460
  return;
22130
22461
  }
22131
22462
  selectCell(cell);
22132
- editingCellRef.current = cell;
22133
- setEditingCell(cell);
22463
+ const target = { ...cell };
22464
+ editingCellRef.current = target;
22465
+ setEditingCell(target);
22134
22466
  const formula = getCellFormula(cell);
22135
22467
  const worksheet2 = getActiveWorksheet();
22136
22468
  const value = formula ? formula.startsWith("=") ? formula : `=${formula}` : worksheet2 ? getCellEditingValue(worksheet2, cell, locale) : getControllerCellDisplayValue(cell);
22137
22469
  editingOriginalValueRef.current = initialValue === void 0 ? value : null;
22470
+ editingSavedValueRef.current = value;
22471
+ editingTriggerRef.current = trigger;
22138
22472
  setEditingValue(initialValue ?? value);
22139
22473
  },
22140
22474
  [getActiveWorksheet, getCellFormula, getControllerCellDisplayValue, locale, readOnly, selectCell]
@@ -22149,7 +22483,7 @@ function XlsxGrid({
22149
22483
  setCellValue(cell, value);
22150
22484
  }
22151
22485
  }, [getActiveWorksheet, locale, setCellFormula, setCellValue]);
22152
- const commitEditing = q(() => {
22486
+ const commitEditing = q((nextValue) => {
22153
22487
  if (!editingCell || !editingCellRef.current) {
22154
22488
  return;
22155
22489
  }
@@ -22160,7 +22494,7 @@ function XlsxGrid({
22160
22494
  focusGrid();
22161
22495
  return;
22162
22496
  }
22163
- saveEditingValue(editingCell, editingValue);
22497
+ saveEditingValue(editingCell, nextValue ?? editingValue);
22164
22498
  editingCellRef.current = null;
22165
22499
  setEditingCell(null);
22166
22500
  setEditingValue("");
@@ -22172,12 +22506,37 @@ function XlsxGrid({
22172
22506
  setEditingValue("");
22173
22507
  focusGrid();
22174
22508
  }, [focusGrid]);
22175
- const handleEditingBlur = q(() => {
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) => {
22176
22534
  if (!editingCellRef.current) {
22177
22535
  return;
22178
22536
  }
22179
- commitEditing();
22180
- }, [commitEditing]);
22537
+ if (event.relatedTarget && editorOverlayRef.current?.contains(event.relatedTarget)) return;
22538
+ exitEditorScope();
22539
+ }, [exitEditorScope]);
22181
22540
  const handleEditingNavigate = q((key, value) => {
22182
22541
  const cell = editingCellRef.current;
22183
22542
  if (!cell) {
@@ -22186,7 +22545,7 @@ function XlsxGrid({
22186
22545
  const currentRowIndex = rowIndexByActual.get(cell.row);
22187
22546
  const currentColIndex = colIndexByActual.get(cell.col);
22188
22547
  if (currentRowIndex === void 0 || currentColIndex === void 0) {
22189
- if (!readOnlyRef.current) {
22548
+ if (!readOnlyRef.current && !hasEditorPreview()) {
22190
22549
  saveEditingValue(cell, value);
22191
22550
  }
22192
22551
  editingCellRef.current = null;
@@ -22213,7 +22572,7 @@ function XlsxGrid({
22213
22572
  default:
22214
22573
  return;
22215
22574
  }
22216
- if (!readOnlyRef.current) {
22575
+ if (!readOnlyRef.current && !hasEditorPreview()) {
22217
22576
  saveEditingValue(cell, value);
22218
22577
  }
22219
22578
  editingCellRef.current = null;
@@ -22221,7 +22580,7 @@ function XlsxGrid({
22221
22580
  setEditingValue("");
22222
22581
  moveSelection(nextRowIndex, nextColIndex, false);
22223
22582
  focusGrid();
22224
- }, [colIndexByActual, focusGrid, rowIndexByActual, saveEditingValue, visibleCols, visibleRows]);
22583
+ }, [colIndexByActual, focusGrid, hasEditorPreview, rowIndexByActual, saveEditingValue, visibleCols, visibleRows]);
22225
22584
  h(() => {
22226
22585
  commitEditingRef.current = commitEditing;
22227
22586
  }, [commitEditing]);
@@ -23872,7 +24231,7 @@ function XlsxGrid({
23872
24231
  });
23873
24232
  }
23874
24233
  const handleCellDoubleClick = q((cell) => {
23875
- startEditing(cell);
24234
+ startEditing(cell, void 0, "double-click");
23876
24235
  }, [startEditing]);
23877
24236
  const handleCellClick = q((cell, cellData) => {
23878
24237
  if (!cellData.hyperlink) {
@@ -24032,7 +24391,7 @@ function XlsxGrid({
24032
24391
  triggerIcon,
24033
24392
  triggerProps: {
24034
24393
  "aria-haspopup": "menu",
24035
- "aria-label": `Open menu for ${tableColumn.name}`,
24394
+ "aria-label": formatMessage(messages.openMenuForColumn, { column: tableColumn.name }),
24036
24395
  onClick: (event) => {
24037
24396
  event.stopPropagation();
24038
24397
  },
@@ -24048,7 +24407,7 @@ function XlsxGrid({
24048
24407
  "button",
24049
24408
  {
24050
24409
  "aria-haspopup": "menu",
24051
- "aria-label": `Open menu for ${tableColumn.name}`,
24410
+ "aria-label": formatMessage(messages.openMenuForColumn, { column: tableColumn.name }),
24052
24411
  "aria-expanded": openTableMenu?.tableName === table.name && openTableMenu.col === cell.col && openTableMenu.row === cell.row,
24053
24412
  onPointerDown: (event) => {
24054
24413
  event.preventDefault();
@@ -24066,7 +24425,7 @@ function XlsxGrid({
24066
24425
  children: experimentalCanvas ? null : triggerIcon
24067
24426
  }
24068
24427
  );
24069
- }, [effectiveTables, experimentalCanvas, openTableMenu, palette, renderTableHeaderMenu, sortState, sortTable, zoomFactor]);
24428
+ }, [effectiveTables, experimentalCanvas, messages, openTableMenu, palette, renderTableHeaderMenu, sortState, sortTable, zoomFactor]);
24070
24429
  const resolveCanvasColumnHeaderRect = q((actualCol) => {
24071
24430
  const colIndex = colIndexByActual.get(actualCol);
24072
24431
  if (colIndex === void 0) {
@@ -24349,7 +24708,7 @@ function XlsxGrid({
24349
24708
  if (!cell) {
24350
24709
  return;
24351
24710
  }
24352
- startEditing(cell);
24711
+ startEditing(cell, void 0, "double-click");
24353
24712
  }, [readOnly, resolvePointerCellFromClient, startEditing]);
24354
24713
  const handleCanvasColumnHeaderPointerDown = q((event) => {
24355
24714
  if (event.button !== 0 || firstVisibleRow === void 0 || lastVisibleRow === void 0) {
@@ -25728,7 +26087,7 @@ function XlsxGrid({
25728
26087
  selectChartElement(selection2);
25729
26088
  }, [selectChartElement]);
25730
26089
  if (isLoading) {
25731
- return /* @__PURE__ */ u(S, { children: renderLoading(loadingComponent, loadingState, palette) });
26090
+ return /* @__PURE__ */ u(S, { children: renderLoading(loadingComponent, loadingState, palette, messages) });
25732
26091
  }
25733
26092
  if (isLoadDeferred) {
25734
26093
  return /* @__PURE__ */ u(S, { children: renderDeferredLoad({ ...controller, canLoadDeferred, continueDeferredLoad, deferredLoadFileSize, isLoadDeferred }, palette) });
@@ -25742,10 +26101,12 @@ function XlsxGrid({
25742
26101
  fileSizeBytes: error.fileSizeBytes,
25743
26102
  maxFileSizeBytes: error.maxFileSizeBytes
25744
26103
  },
25745
- palette
26104
+ palette,
26105
+ messages,
26106
+ locale
25746
26107
  ) });
25747
26108
  }
25748
- return /* @__PURE__ */ u(S, { children: renderError(errorState, error, palette) });
26109
+ return /* @__PURE__ */ u(S, { children: renderError(errorState, error, palette, messages) });
25749
26110
  }
25750
26111
  if (!activeSheet && activeTab?.kind === "chartsheet") {
25751
26112
  return /* @__PURE__ */ u(
@@ -25788,12 +26149,12 @@ function XlsxGrid({
25788
26149
  maxWidth: "100%",
25789
26150
  aspectRatio: sourceSize ? `${chartsheetRect.width}/${chartsheetRect.height}` : void 0,
25790
26151
  position: "relative"
25791
- }, children: isChartsLoading ? renderChartLoadingNode(renderChartLoading, chart, chartsheetRect) : /* @__PURE__ */ u(
26152
+ }, children: isChartsLoading ? renderChartLoadingNode(renderChartLoading, chart, chartsheetRect, messages) : /* @__PURE__ */ u(
25792
26153
  MemoChartSvg,
25793
26154
  {
25794
26155
  experimentalOfficeCharts,
25795
26156
  chart,
25796
- loadingFallback: (stage) => renderChartLoadingNode(renderChartLoading, chart, chartsheetRect, stage),
26157
+ loadingFallback: (stage) => renderChartLoadingNode(renderChartLoading, chart, chartsheetRect, messages, stage),
25797
26158
  onChartElementDoubleClick: handleChartElementDoubleClick,
25798
26159
  onChartElementPointerDown: handleChartElementPointerDown,
25799
26160
  palette,
@@ -25812,7 +26173,7 @@ function XlsxGrid({
25812
26173
  justifyContent: "center",
25813
26174
  minHeight: 320
25814
26175
  },
25815
- children: "Chartsheet metadata is present, but no embedded chart payload was exposed for this tab."
26176
+ children: messages.chartsheetUnavailable
25816
26177
  }
25817
26178
  )
25818
26179
  }
@@ -25821,7 +26182,7 @@ function XlsxGrid({
25821
26182
  );
25822
26183
  }
25823
26184
  if (!activeSheet) {
25824
- return /* @__PURE__ */ u(S, { children: renderEmpty(emptyState, palette) });
26185
+ return /* @__PURE__ */ u(S, { children: renderEmpty(emptyState, palette, messages) });
25825
26186
  }
25826
26187
  const virtualRows = domExpandedWindow.rowIndices.map((index) => {
25827
26188
  const virtualRow = rowVirtualItemByIndex.get(index);
@@ -26434,7 +26795,7 @@ function XlsxGrid({
26434
26795
  "select",
26435
26796
  {
26436
26797
  "aria-disabled": readOnly || control.controlIndex === void 0 || controlItems.length === 0,
26437
- "aria-label": controlLabel || control.name || "Dropdown form control",
26798
+ "aria-label": controlLabel || control.name || messages.dropdownControl,
26438
26799
  disabled: !readOnly && (control.controlIndex === void 0 || controlItems.length === 0),
26439
26800
  onChange: (event) => {
26440
26801
  event.stopPropagation();
@@ -26468,7 +26829,7 @@ function XlsxGrid({
26468
26829
  "select",
26469
26830
  {
26470
26831
  "aria-disabled": readOnly || control.controlIndex === void 0 || controlItems.length === 0,
26471
- "aria-label": controlLabel || control.name || "List box form control",
26832
+ "aria-label": controlLabel || control.name || messages.listBoxControl,
26472
26833
  disabled: !readOnly && (control.controlIndex === void 0 || controlItems.length === 0),
26473
26834
  multiple: allowsMultipleSelection,
26474
26835
  onChange: (event) => {
@@ -26503,7 +26864,7 @@ function XlsxGrid({
26503
26864
  "input",
26504
26865
  {
26505
26866
  "aria-disabled": readOnly || control.controlIndex === void 0,
26506
- "aria-label": controlLabel || control.name || "Scrollbar form control",
26867
+ "aria-label": controlLabel || control.name || messages.scrollbarControl,
26507
26868
  disabled: !readOnly && control.controlIndex === void 0,
26508
26869
  max,
26509
26870
  min,
@@ -26535,7 +26896,7 @@ function XlsxGrid({
26535
26896
  "input",
26536
26897
  {
26537
26898
  "aria-disabled": readOnly || control.controlIndex === void 0,
26538
- "aria-label": controlLabel || control.name || "Spinner form control",
26899
+ "aria-label": controlLabel || control.name || messages.spinnerControl,
26539
26900
  disabled: !readOnly && control.controlIndex === void 0,
26540
26901
  max,
26541
26902
  min,
@@ -26777,12 +27138,12 @@ function XlsxGrid({
26777
27138
  cursor: canEditChart && selectedChartId === chart.id ? "move" : "cell",
26778
27139
  pointerEvents: "auto"
26779
27140
  },
26780
- children: isChartsLoading ? renderChartLoadingNode(renderChartLoading, chart, rect) : /* @__PURE__ */ u(
27141
+ children: isChartsLoading ? renderChartLoadingNode(renderChartLoading, chart, rect, messages) : /* @__PURE__ */ u(
26781
27142
  MemoChartSvg,
26782
27143
  {
26783
27144
  experimentalOfficeCharts,
26784
27145
  chart,
26785
- loadingFallback: (stage) => renderChartLoadingNode(renderChartLoading, chart, rect, stage),
27146
+ loadingFallback: (stage) => renderChartLoadingNode(renderChartLoading, chart, rect, messages, stage),
26786
27147
  onChartElementDoubleClick: handleChartElementDoubleClick,
26787
27148
  onChartElementPointerDown: handleChartElementPointerDown,
26788
27149
  palette,
@@ -27381,7 +27742,7 @@ function XlsxGrid({
27381
27742
  const isCommandNavigation = event.ctrlKey || event.metaKey;
27382
27743
  if (!readOnly && isPrintableKey(event)) {
27383
27744
  event.preventDefault();
27384
- startEditing(currentCell, event.key);
27745
+ startEditing(currentCell, event.key, "typing");
27385
27746
  return;
27386
27747
  }
27387
27748
  switch (event.key) {
@@ -27526,7 +27887,7 @@ function XlsxGrid({
27526
27887
  ref: scrollRef,
27527
27888
  "aria-colcount": Math.max(activeSheet?.colCount ?? 0, displayColLimit),
27528
27889
  "aria-keyshortcuts": "ArrowUp ArrowDown ArrowLeft ArrowRight Home End PageUp PageDown Control+Home Control+End",
27529
- "aria-label": activeSheet ? `${activeSheet.name} worksheet grid` : "Workbook grid",
27890
+ "aria-label": activeSheet ? formatMessage(messages.worksheetGrid, { sheet: activeSheet.name }) : messages.workbookGrid,
27530
27891
  "aria-readonly": readOnly,
27531
27892
  "aria-rowcount": Math.max(activeSheet?.rowCount ?? 0, displayRowLimit),
27532
27893
  role: "grid",
@@ -27949,8 +28310,8 @@ function XlsxGrid({
27949
28310
  ] }),
27950
28311
  editingCell && editingOverlayRect ? (() => {
27951
28312
  const editingCellData = getCellData(editingCell.row, editingCell.col);
27952
- const editingCellStyle = { ...editingCellData.style };
27953
- if (editingCellData.usesGeneralAlignment) {
28313
+ const editingCellStyle = { ...editingCellData.style, ...cellEditorStyle };
28314
+ if (editingCellData.usesGeneralAlignment && cellEditorStyle?.textAlign === void 0) {
27954
28315
  const enteredValue = worksheet && isTextCell(worksheet, editingCell) ? editingValue : coerceUserEnteredValue(editingValue, locale);
27955
28316
  editingCellStyle.textAlign = typeof enteredValue === "number" ? "right" : typeof enteredValue === "boolean" ? "center" : "left";
27956
28317
  }
@@ -27970,6 +28331,8 @@ function XlsxGrid({
27970
28331
  children: /* @__PURE__ */ u(
27971
28332
  CellEditor,
27972
28333
  {
28334
+ editorRef: editorElementRef,
28335
+ onFocusOverlay: renderCellEditorOverlay ? focusEditorOverlay : void 0,
27973
28336
  canvasText: true,
27974
28337
  canvasOffset: {
27975
28338
  left: editingOverlayRect.left - drawingViewport.left - (stickyLeftByCol.has(editingCell.col) ? displayRowHeaderWidth : scrollBodyCanvasLeft),
@@ -28009,9 +28372,9 @@ function XlsxGrid({
28009
28372
  value: editingValue,
28010
28373
  references: formulaReferences,
28011
28374
  onBlur: handleEditingBlur,
28012
- onChange: setEditingValue,
28013
- onCommit: commitEditing,
28014
- onCancel: cancelEditing,
28375
+ onChange: cellEditorSession?.setValue ?? setEditingValue,
28376
+ onCommit: cellEditorSession?.commit ?? commitEditing,
28377
+ onCancel: cellEditorSession?.cancel ?? cancelEditing,
28015
28378
  onNavigate: handleEditingNavigate,
28016
28379
  style: {
28017
28380
  backgroundColor: editingBackground,
@@ -28021,7 +28384,8 @@ function XlsxGrid({
28021
28384
  lineHeight: editingCellStyle.lineHeight,
28022
28385
  textAlign: editingCellStyle.textAlign,
28023
28386
  verticalAlign: editingCellStyle.verticalAlign,
28024
- padding: editingCellStyle.padding
28387
+ padding: editingCellStyle.padding,
28388
+ ...cellEditorStyle
28025
28389
  }
28026
28390
  }
28027
28391
  )
@@ -28152,6 +28516,10 @@ function XlsxGrid({
28152
28516
  actualRow,
28153
28517
  editingCell,
28154
28518
  editingValue,
28519
+ editorRef: editorElementRef,
28520
+ editorInputRef: editingInputRef,
28521
+ cellEditorStyle,
28522
+ onFocusEditorOverlay: renderCellEditorOverlay ? focusEditorOverlay : void 0,
28155
28523
  formulaReferences,
28156
28524
  editorBoxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
28157
28525
  frozenRowHeaderZIndex: frozenRowHeaderOverlayZIndex,
@@ -28161,10 +28529,10 @@ function XlsxGrid({
28161
28529
  onCellDoubleClick: handleCellDoubleClick,
28162
28530
  onCellPointerDown: handleCellPointerDown,
28163
28531
  onEditingBlur: handleEditingBlur,
28164
- onEditingCancel: cancelEditing,
28165
- onEditingCommit: commitEditing,
28532
+ onEditingCancel: cellEditorSession?.cancel ?? cancelEditing,
28533
+ onEditingCommit: cellEditorSession?.commit ?? commitEditing,
28166
28534
  onEditingNavigate: handleEditingNavigate,
28167
- onEditingValueChange: setEditingValue,
28535
+ onEditingValueChange: cellEditorSession?.setValue ?? setEditingValue,
28168
28536
  headerLabelLiveScale,
28169
28537
  onRowHeaderRef: setRowHeaderRef,
28170
28538
  onRowPointerDown: handleRowPointerDown,
@@ -28316,6 +28684,42 @@ function XlsxGrid({
28316
28684
  );
28317
28685
  return /* @__PURE__ */ u("div", { style: { backgroundColor: palette.canvas, display: "flex", flex: 1, minHeight: 0, minWidth: 0 }, children: [
28318
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
+ ),
28319
28723
  enableContextMenu && contextMenu && /* @__PURE__ */ u(
28320
28724
  XlsxContextMenu,
28321
28725
  {
@@ -28323,7 +28727,7 @@ function XlsxGrid({
28323
28727
  controller,
28324
28728
  palette,
28325
28729
  closeMenu: closeContextMenu,
28326
- editCell: () => startEditing(contextMenu.context.cell),
28730
+ editCell: () => startEditing(contextMenu.context.cell, void 0, "context-menu"),
28327
28731
  selectExtent: (kind) => selectContextExtent(kind, contextMenu.context.selection),
28328
28732
  renderContextMenu,
28329
28733
  contextMenuClassName,
@@ -28337,7 +28741,8 @@ function XlsxViewerInner({
28337
28741
  allowResizeInReadOnly = false,
28338
28742
  autoScrollToHighlightedRanges = true,
28339
28743
  className,
28340
- controller,
28744
+ controller: sourceController,
28745
+ messages: messageOverrides,
28341
28746
  emptyState,
28342
28747
  enableCanvasSelectionAnimation = true,
28343
28748
  enableGestureZoom = true,
@@ -28367,6 +28772,9 @@ function XlsxViewerInner({
28367
28772
  renderScroller,
28368
28773
  renderTableHeaderMenu,
28369
28774
  renderActiveCellOverlay,
28775
+ renderCellEditorOverlay,
28776
+ renderSelectionPopover,
28777
+ cellEditorStyle,
28370
28778
  rounded = true,
28371
28779
  selectionColor,
28372
28780
  selectionFillColor,
@@ -28375,6 +28783,11 @@ function XlsxViewerInner({
28375
28783
  showDefaultToolbar = true,
28376
28784
  toolbar
28377
28785
  }) {
28786
+ const messages = T(
28787
+ () => mergeMessages(sourceController.messages, messageOverrides),
28788
+ [sourceController.messages, messageOverrides]
28789
+ );
28790
+ const controller = T(() => ({ ...sourceController, messages }), [sourceController, messages]);
28378
28791
  const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
28379
28792
  const { displayFileName, error } = controller;
28380
28793
  const appliedHighlightRef = A(null);
@@ -28404,11 +28817,14 @@ function XlsxViewerInner({
28404
28817
  fileSizeBytes: error.fileSizeBytes,
28405
28818
  maxFileSizeBytes: error.maxFileSizeBytes
28406
28819
  },
28407
- palette
28820
+ palette,
28821
+ messages,
28822
+ controller.locale
28408
28823
  ) : void 0;
28409
- return /* @__PURE__ */ u(ViewerAppearanceContext.Provider, { value: { headerBackgroundColor, headerTextColor, isDark }, children: /* @__PURE__ */ u(ViewerContext.Provider, { value: controller, children: customFileTooLarge !== void 0 ? customFileTooLarge : /* @__PURE__ */ u(
28824
+ return /* @__PURE__ */ u(XlsxMessagesContext.Provider, { value: messages, children: /* @__PURE__ */ u(ViewerAppearanceContext.Provider, { value: { headerBackgroundColor, headerTextColor, isDark }, children: /* @__PURE__ */ u(ViewerContext.Provider, { value: controller, children: customFileTooLarge !== void 0 ? customFileTooLarge : /* @__PURE__ */ u(
28410
28825
  "div",
28411
28826
  {
28827
+ lang: controller.locale,
28412
28828
  className: classNames("react-xlsx-viewer", className),
28413
28829
  style: {
28414
28830
  blockSize: height,
@@ -28461,6 +28877,9 @@ function XlsxViewerInner({
28461
28877
  renderScroller,
28462
28878
  renderTableHeaderMenu,
28463
28879
  renderActiveCellOverlay,
28880
+ renderCellEditorOverlay,
28881
+ renderSelectionPopover,
28882
+ cellEditorStyle,
28464
28883
  selectionColor,
28465
28884
  selectionFillColor,
28466
28885
  selectionHeaderColor,
@@ -28469,7 +28888,7 @@ function XlsxViewerInner({
28469
28888
  ) })
28470
28889
  ]
28471
28890
  }
28472
- ) }) });
28891
+ ) }) }) });
28473
28892
  }
28474
28893
  function XlsxViewerWithInlineController(props) {
28475
28894
  const controller = useXlsxViewerController(props);
@@ -28509,6 +28928,8 @@ function toReactOptions(options) {
28509
28928
  fileTooLargeState,
28510
28929
  loadingState,
28511
28930
  renderActiveCellOverlay,
28931
+ renderCellEditorOverlay,
28932
+ renderSelectionPopover,
28512
28933
  renderChartLoading,
28513
28934
  renderContextMenu,
28514
28935
  renderFormControl,
@@ -28523,6 +28944,8 @@ function toReactOptions(options) {
28523
28944
  fileTooLargeState: typeof fileTooLargeState === "function" ? ({ defaultNode: _defaultNode, ...props }) => toReactContent(fileTooLargeState(props)) : toReactContent(fileTooLargeState),
28524
28945
  loadingState: toReactContent(loadingState),
28525
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,
28526
28949
  renderChartLoading: renderChartLoading ? ({ defaultNode: _defaultNode, ...props }) => toReactContent(renderChartLoading(props)) : void 0,
28527
28950
  renderContextMenu: renderContextMenu ? ({ defaultNode: _defaultNode, ...props }) => toReactContent(renderContextMenu(props)) : void 0,
28528
28951
  renderFormControl: renderFormControl ? (props) => toReactContent(renderFormControl({ ...props, stopPropagation: (event) => event.stopPropagation() })) : void 0,
@@ -28688,4 +29111,4 @@ export {
28688
29111
  __createContentNode,
28689
29112
  __createContentRoot
28690
29113
  };
28691
- //# sourceMappingURL=chunk-VSM7WKLM.js.map
29114
+ //# sourceMappingURL=chunk-2UFSVI5Z.js.map