@extend-ai/react-xlsx 0.20.11 → 0.20.12

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 +27 -3
  2. package/dist/{chunk-OGZ6ROZC.cjs → chunk-A3S3QKJN.cjs} +445 -3
  3. package/dist/chunk-A3S3QKJN.cjs.map +1 -0
  4. package/dist/chunk-IRC7BQ6E.js +538 -0
  5. package/dist/chunk-IRC7BQ6E.js.map +1 -0
  6. package/dist/{chunk-SXHHFUXA.cjs → chunk-NIN5D556.cjs} +899 -875
  7. package/dist/chunk-NIN5D556.cjs.map +1 -0
  8. package/dist/{chunk-VSM7WKLM.js → chunk-O4S5CRDM.js} +134 -110
  9. package/dist/chunk-O4S5CRDM.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 +32 -14
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +60 -2
  17. package/dist/index.d.ts +60 -2
  18. package/dist/index.js +32 -14
  19. package/dist/index.js.map +1 -1
  20. package/dist/{internal-BBaC9yCh.d.cts → internal-D_np3R-w.d.cts} +60 -2
  21. package/dist/{internal-BBaC9yCh.d.ts → internal-D_np3R-w.d.ts} +60 -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);
@@ -12340,6 +12347,7 @@ function useXlsxViewerController(options) {
12340
12347
  defineNamedRange,
12341
12348
  displayFileName,
12342
12349
  locale,
12350
+ messages,
12343
12351
  download,
12344
12352
  exportCsv,
12345
12353
  exportXlsx,
@@ -12464,6 +12472,7 @@ function useXlsxViewerController(options) {
12464
12472
  defineNamedRange,
12465
12473
  displayFileName,
12466
12474
  locale,
12475
+ messages,
12467
12476
  download,
12468
12477
  error,
12469
12478
  exportCsv,
@@ -14135,6 +14144,7 @@ function CellEditor({
14135
14144
  onNavigate
14136
14145
  }) {
14137
14146
  const rootRef = A(null);
14147
+ const messages = useXlsxMessages();
14138
14148
  const mirrorRef = A(null);
14139
14149
  const textRef = A(null);
14140
14150
  const baselineRef = A(null);
@@ -14320,7 +14330,7 @@ function CellEditor({
14320
14330
  if (typeof inputRef === "function") inputRef(element);
14321
14331
  else if (inputRef) inputRef.current = element;
14322
14332
  },
14323
- "aria-label": "Edit cell",
14333
+ "aria-label": messages.editCell,
14324
14334
  autoFocus: true,
14325
14335
  autoComplete: "off",
14326
14336
  spellCheck: false,
@@ -14505,6 +14515,13 @@ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextC
14505
14515
  }
14506
14516
 
14507
14517
  // src/context-menu.tsx
14518
+ var MenuActionError = class extends Error {
14519
+ key;
14520
+ constructor(key) {
14521
+ super(key);
14522
+ this.key = key;
14523
+ }
14524
+ };
14508
14525
  var menuStyles = `
14509
14526
  :where(.react-xlsx-context-menu) {
14510
14527
  background: var(--xlsx-context-menu-background);
@@ -14542,39 +14559,41 @@ function XlsxContextMenu({
14542
14559
  contextMenuClassName,
14543
14560
  contextMenuStyle
14544
14561
  }) {
14562
+ const { messages } = controller;
14545
14563
  const rootRef = A(null);
14546
14564
  const controllerRef = A(controller);
14547
14565
  controllerRef.current = controller;
14548
14566
  const aliveRef = A(true);
14549
14567
  const runningRef = A(false);
14550
14568
  const [busy, setBusy] = d(false);
14551
- const [error, setError] = d(null);
14569
+ const [errorKey, setErrorKey] = d(null);
14570
+ const error = errorKey ? messages[errorKey] : null;
14552
14571
  const [location, setLocation] = d(position);
14553
14572
  const modifier = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform) ? "\u2318" : "Ctrl+";
14554
14573
  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
14574
  const range = expandHighlightedRange(context.selection, controller.activeSheet?.mergedRanges ?? []);
14556
14575
  const multiple = range.start.row !== range.end.row || range.start.col !== range.end.col;
14557
14576
  const actions = [
14558
- ...!controller.readOnly ? [{ id: "cut", label: "Cut" }] : [],
14559
- { id: "copy", label: "Copy", shortcut: `${modifier}C` },
14577
+ ...!controller.readOnly ? [{ id: "cut", label: messages.cut }] : [],
14578
+ { id: "copy", label: messages.copy, shortcut: `${modifier}C` },
14560
14579
  ...!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" },
14580
+ { id: "paste", label: messages.paste, shortcut: `${modifier}V` },
14581
+ { id: "editCell", label: messages.editCell, shortcut: "F2", separatorBefore: true },
14582
+ { id: "clearContents", label: messages.clearContents, destructive: true },
14583
+ { id: "undo", label: messages.undo, shortcut: `${modifier}Z`, separatorBefore: true, disabled: !controller.canUndo },
14584
+ { id: "redo", label: messages.redo, shortcut: `${modifier}\u21E7Z`, disabled: !controller.canRedo },
14585
+ { id: "mergeAndCenter", label: messages.mergeAndCenter, separatorBefore: true, disabled: !multiple },
14586
+ { id: "mergeAcross", label: messages.mergeAcross, disabled: range.start.col === range.end.col },
14587
+ { id: "mergeCells", label: messages.mergeCells, disabled: !multiple },
14588
+ { id: "unmergeCells", label: messages.unmergeCells },
14570
14589
  ...table ? [
14571
- { id: "sortAscending", label: "Sort A to Z", separatorBefore: true },
14572
- { id: "sortDescending", label: "Sort Z to A" }
14590
+ { id: "sortAscending", label: messages.sortAscending, separatorBefore: true },
14591
+ { id: "sortDescending", label: messages.sortDescending }
14573
14592
  ] : []
14574
14593
  ] : [],
14575
- { id: "selectRow", label: "Select row", separatorBefore: true },
14576
- { id: "selectColumn", label: "Select column" },
14577
- { id: "selectAll", label: "Select all", shortcut: `${modifier}A` }
14594
+ { id: "selectRow", label: messages.selectRow, separatorBefore: true },
14595
+ { id: "selectColumn", label: messages.selectColumn },
14596
+ { id: "selectAll", label: messages.selectAll, shortcut: `${modifier}A` }
14578
14597
  ];
14579
14598
  _(() => {
14580
14599
  const root = rootRef.current;
@@ -14620,20 +14639,20 @@ function XlsxContextMenu({
14620
14639
  if (!isCurrent()) return false;
14621
14640
  runningRef.current = true;
14622
14641
  setBusy(true);
14623
- setError(null);
14642
+ setErrorKey(null);
14624
14643
  try {
14625
14644
  switch (id) {
14626
14645
  case "copy":
14627
14646
  case "cut": {
14628
14647
  const copied = await controller.copySelectionToClipboard();
14629
- if (!copied) throw new Error("Clipboard access is unavailable. Use the keyboard shortcut to copy.");
14648
+ if (!copied) throw new MenuActionError("clipboardCopyUnavailable");
14630
14649
  if (!isCurrent()) return false;
14631
14650
  if (id === "cut") controller.clearSelectedCells();
14632
14651
  break;
14633
14652
  }
14634
14653
  case "paste": {
14635
14654
  const clipboard = navigator.clipboard;
14636
- if (!clipboard) throw new Error("Clipboard access is unavailable. Use the keyboard shortcut to paste.");
14655
+ if (!clipboard) throw new MenuActionError("clipboardPasteUnavailable");
14637
14656
  let structured;
14638
14657
  let text;
14639
14658
  if (clipboard.read) {
@@ -14651,7 +14670,7 @@ function XlsxContextMenu({
14651
14670
  }
14652
14671
  if (!isCurrent()) return false;
14653
14672
  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.");
14673
+ if (!pasted) throw new MenuActionError("nothingToPaste");
14655
14674
  break;
14656
14675
  }
14657
14676
  case "clearContents":
@@ -14696,7 +14715,7 @@ function XlsxContextMenu({
14696
14715
  closeMenu();
14697
14716
  return true;
14698
14717
  } catch (cause) {
14699
- if (aliveRef.current) setError(cause instanceof Error ? cause.message : "The action could not be completed.");
14718
+ if (aliveRef.current) setErrorKey(cause instanceof MenuActionError ? cause.key : "actionFailed");
14700
14719
  return false;
14701
14720
  } finally {
14702
14721
  runningRef.current = false;
@@ -14730,7 +14749,8 @@ function XlsxContextMenu({
14730
14749
  /* @__PURE__ */ u(
14731
14750
  "div",
14732
14751
  {
14733
- "aria-label": "Spreadsheet context menu",
14752
+ lang: controller.locale,
14753
+ "aria-label": messages.contextMenu,
14734
14754
  "aria-busy": busy,
14735
14755
  className: ["react-xlsx-context-menu", contextMenuClassName].filter(Boolean).join(" "),
14736
14756
  "data-dark": isDarkViewerPalette(palette) ? "true" : "false",
@@ -14817,18 +14837,18 @@ function createChartModule(importModule) {
14817
14837
  var officeChartRenderer = createChartModule(async () => {
14818
14838
  const [{ loadOfficeCharts }, { SharedChartSvg }] = await Promise.all([
14819
14839
  import("./browser-AWFV5QM2.js"),
14820
- import("./shared-chart-XOCTF7KQ.js")
14840
+ import("./shared-chart-7RUN5IKZ.js")
14821
14841
  ]);
14822
14842
  return { renderer: await loadOfficeCharts(), SharedChartSvg };
14823
14843
  });
14824
14844
  var suppliedOfficeChartRenderer = createChartModule(async () => {
14825
- const { SharedChartSvg } = await import("./shared-chart-XOCTF7KQ.js");
14845
+ const { SharedChartSvg } = await import("./shared-chart-7RUN5IKZ.js");
14826
14846
  return { renderer: null, SharedChartSvg };
14827
14847
  });
14828
14848
  var officeExtendedChartRenderer = createChartModule(async () => {
14829
14849
  const [{ loadOfficeCharts }, { SharedChartSvg }] = await Promise.all([
14830
14850
  import("./full-ERXNU2LF.js"),
14831
- import("./shared-chart-XOCTF7KQ.js")
14851
+ import("./shared-chart-7RUN5IKZ.js")
14832
14852
  ]);
14833
14853
  return { renderer: await loadOfficeCharts(typeof DecompressionStream === "function" ? void 0 : new URL("./office_charts_full_bg.wasm", import.meta.url)), SharedChartSvg };
14834
14854
  });
@@ -14869,13 +14889,14 @@ var ChartLoadBoundary = class extends C {
14869
14889
  }
14870
14890
  render() {
14871
14891
  if (this.state.failed) {
14872
- return /* @__PURE__ */ u("div", { role: "status", children: "Unable to load chart." });
14892
+ return /* @__PURE__ */ u("div", { role: "status", children: this.props.errorMessage });
14873
14893
  }
14874
14894
  return this.props.children;
14875
14895
  }
14876
14896
  };
14877
14897
  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." });
14898
+ const messages = useXlsxMessages();
14899
+ return /* @__PURE__ */ u("div", { role: "status", "data-xlsx-chart-fallback": "unsupported", children: chart.chartType === "RegionMap" ? messages.mapUnavailable : messages.chartUnavailable });
14879
14900
  }
14880
14901
  function SharedChart(props) {
14881
14902
  const module = useChartModule(props.experimentalOfficeCharts ? suppliedOfficeChartRenderer : props.source.experimental ? officeExtendedChartRenderer : officeChartRenderer);
@@ -14885,7 +14906,8 @@ function SharedChart(props) {
14885
14906
  return renderer && module.SharedChartSvg ? /* @__PURE__ */ u(module.SharedChartSvg, { ...props, renderer, fallback }) : fallback;
14886
14907
  }
14887
14908
  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);
14909
+ const messages = useXlsxMessages();
14910
+ 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
14911
  }
14890
14912
 
14891
14913
  // src/picture-paint.ts
@@ -15654,8 +15676,8 @@ function drawCanvasConditionalIcon(context, icon, centerX, centerY, size) {
15654
15676
  context.fill();
15655
15677
  context.restore();
15656
15678
  }
15657
- function formatZoomScale(zoomScale) {
15658
- return `${Math.round(zoomScale)}%`;
15679
+ function formatZoomScale(zoomScale, locale) {
15680
+ return new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 }).format(zoomScale / 100);
15659
15681
  }
15660
15682
  function clampValue(value, min, max) {
15661
15683
  return Math.min(max, Math.max(min, value));
@@ -18269,6 +18291,7 @@ function DefaultTableHeaderMenu({
18269
18291
  sortAscending,
18270
18292
  sortDescending
18271
18293
  }) {
18294
+ const messages = useXlsxMessages();
18272
18295
  return /* @__PURE__ */ u(
18273
18296
  "div",
18274
18297
  {
@@ -18298,7 +18321,7 @@ function DefaultTableHeaderMenu({
18298
18321
  textAlign: "left"
18299
18322
  },
18300
18323
  type: "button",
18301
- children: "Sort A to Z"
18324
+ children: messages.sortAscending
18302
18325
  }
18303
18326
  ),
18304
18327
  /* @__PURE__ */ u(
@@ -18316,7 +18339,7 @@ function DefaultTableHeaderMenu({
18316
18339
  textAlign: "left"
18317
18340
  },
18318
18341
  type: "button",
18319
- children: "Sort Z to A"
18342
+ children: messages.sortDescending
18320
18343
  }
18321
18344
  )
18322
18345
  ]
@@ -18379,6 +18402,7 @@ function drawCanvasTableHeaderTrigger(context, rect, direction, palette, zoomFac
18379
18402
  }
18380
18403
  function SegmentedControl({
18381
18404
  items,
18405
+ messages,
18382
18406
  onValueChange,
18383
18407
  palette,
18384
18408
  value
@@ -18386,7 +18410,7 @@ function SegmentedControl({
18386
18410
  return /* @__PURE__ */ u(
18387
18411
  "div",
18388
18412
  {
18389
- "aria-label": "Workbook sheets",
18413
+ "aria-label": messages.workbookSheets,
18390
18414
  role: "tablist",
18391
18415
  style: {
18392
18416
  alignItems: "center",
@@ -18438,6 +18462,8 @@ function DefaultToolbar({ controller, palette }) {
18438
18462
  canZoomIn,
18439
18463
  canZoomOut,
18440
18464
  defaultZoomScale,
18465
+ locale,
18466
+ messages,
18441
18467
  displayFileName,
18442
18468
  download,
18443
18469
  resetZoom,
@@ -18493,6 +18519,7 @@ function DefaultToolbar({ controller, palette }) {
18493
18519
  /* @__PURE__ */ u(
18494
18520
  "button",
18495
18521
  {
18522
+ "aria-label": messages.zoomOut,
18496
18523
  disabled: !canZoomOut,
18497
18524
  onClick: zoomOut,
18498
18525
  style: {
@@ -18511,6 +18538,7 @@ function DefaultToolbar({ controller, palette }) {
18511
18538
  /* @__PURE__ */ u(
18512
18539
  "button",
18513
18540
  {
18541
+ "aria-label": messages.resetZoom,
18514
18542
  onClick: resetZoom,
18515
18543
  style: {
18516
18544
  background: Math.round(zoomScale) === Math.round(defaultZoomScale) ? "transparent" : palette.subtleSurface,
@@ -18525,12 +18553,13 @@ function DefaultToolbar({ controller, palette }) {
18525
18553
  padding: "6px 10px"
18526
18554
  },
18527
18555
  type: "button",
18528
- children: formatZoomScale(zoomScale)
18556
+ children: formatZoomScale(zoomScale, locale)
18529
18557
  }
18530
18558
  ),
18531
18559
  /* @__PURE__ */ u(
18532
18560
  "button",
18533
18561
  {
18562
+ "aria-label": messages.zoomIn,
18534
18563
  disabled: !canZoomIn,
18535
18564
  onClick: zoomIn,
18536
18565
  style: {
@@ -18552,7 +18581,7 @@ function DefaultToolbar({ controller, palette }) {
18552
18581
  canDownload ? /* @__PURE__ */ u(
18553
18582
  "button",
18554
18583
  {
18555
- "aria-label": "Download workbook",
18584
+ "aria-label": messages.downloadWorkbook,
18556
18585
  onClick: download,
18557
18586
  style: {
18558
18587
  alignItems: "center",
@@ -18569,7 +18598,7 @@ function DefaultToolbar({ controller, palette }) {
18569
18598
  padding: 0,
18570
18599
  width: 32
18571
18600
  },
18572
- title: "Download workbook",
18601
+ title: messages.downloadWorkbook,
18573
18602
  type: "button",
18574
18603
  children: "\u2193"
18575
18604
  }
@@ -18590,10 +18619,11 @@ function DefaultToolbar({ controller, palette }) {
18590
18619
  children: /* @__PURE__ */ u(
18591
18620
  SegmentedControl,
18592
18621
  {
18622
+ messages,
18593
18623
  items: tabs.map((tab, index) => ({
18594
18624
  id: String(index),
18595
18625
  label: tab.name,
18596
- title: tab.visibility === "hidden" ? `${tab.name} (hidden)` : tab.visibility === "veryHidden" ? `${tab.name} (very hidden)` : tab.name,
18626
+ title: tab.visibility === "hidden" ? formatMessage(messages.hiddenSheet, { sheet: tab.name }) : tab.visibility === "veryHidden" ? formatMessage(messages.veryHiddenSheet, { sheet: tab.name }) : tab.name,
18597
18627
  visibility: tab.visibility
18598
18628
  })),
18599
18629
  onValueChange: (value) => setActiveTabIndex(Number(value)),
@@ -18617,7 +18647,7 @@ function resolveToolbar(toolbar, showDefaultToolbar, controller, palette) {
18617
18647
  }
18618
18648
  return /* @__PURE__ */ u(DefaultToolbar, { controller, palette });
18619
18649
  }
18620
- function renderError(errorState, error, palette) {
18650
+ function renderError(errorState, error, palette, messages) {
18621
18651
  if (typeof errorState === "function") {
18622
18652
  return errorState(error);
18623
18653
  }
@@ -18637,11 +18667,11 @@ function renderError(errorState, error, palette) {
18637
18667
  padding: 16,
18638
18668
  textAlign: "center"
18639
18669
  },
18640
- children: error.message
18670
+ children: messages.loadWorkbookFailed
18641
18671
  }
18642
18672
  );
18643
18673
  }
18644
- function renderLoading(loadingComponent, loadingState, palette) {
18674
+ function renderLoading(loadingComponent, loadingState, palette, messages) {
18645
18675
  if (loadingComponent !== void 0) {
18646
18676
  return loadingComponent;
18647
18677
  }
@@ -18659,11 +18689,11 @@ function renderLoading(loadingComponent, loadingState, palette) {
18659
18689
  height: "100%",
18660
18690
  justifyContent: "center"
18661
18691
  },
18662
- children: "Loading workbook..."
18692
+ children: messages.loadingWorkbook
18663
18693
  }
18664
18694
  );
18665
18695
  }
18666
- function renderEmpty(emptyState, palette) {
18696
+ function renderEmpty(emptyState, palette, messages) {
18667
18697
  if (emptyState !== void 0) {
18668
18698
  return emptyState;
18669
18699
  }
@@ -18680,24 +18710,26 @@ function renderEmpty(emptyState, palette) {
18680
18710
  padding: 16,
18681
18711
  textAlign: "center"
18682
18712
  },
18683
- children: "No workbook loaded."
18713
+ children: messages.emptyWorkbook
18684
18714
  }
18685
18715
  );
18686
18716
  }
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;
18717
+ function formatBinaryBytes2(bytes, locale) {
18718
+ const units = ["byte", "kilobyte", "megabyte", "gigabyte"];
18719
+ let value = Number.isFinite(bytes) && bytes > 0 ? bytes : 0;
18693
18720
  let unitIndex = 0;
18694
18721
  while (value >= 1024 && unitIndex < units.length - 1) {
18695
18722
  value /= 1024;
18696
18723
  unitIndex += 1;
18697
18724
  }
18698
- return `${value >= 10 || unitIndex === 0 ? value.toFixed(0) : value.toFixed(1)} ${units[unitIndex]}`;
18725
+ return new Intl.NumberFormat(locale, {
18726
+ style: "unit",
18727
+ unit: units[unitIndex],
18728
+ unitDisplay: "short",
18729
+ maximumFractionDigits: value >= 10 || unitIndex === 0 ? 0 : 1
18730
+ }).format(value);
18699
18731
  }
18700
- function renderFileTooLarge(fileTooLargeState, renderProps, palette) {
18732
+ function renderFileTooLarge(fileTooLargeState, renderProps, palette, messages, locale) {
18701
18733
  const defaultNode = /* @__PURE__ */ u(
18702
18734
  "div",
18703
18735
  {
@@ -18715,14 +18747,10 @@ function renderFileTooLarge(fileTooLargeState, renderProps, palette) {
18715
18747
  },
18716
18748
  children: [
18717
18749
  /* @__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
- ] })
18750
+ /* @__PURE__ */ u("div", { children: formatMessage(messages.fileTooLarge, {
18751
+ size: formatBinaryBytes2(renderProps.fileSizeBytes, locale),
18752
+ limit: formatBinaryBytes2(renderProps.maxFileSizeBytes, locale)
18753
+ }) })
18726
18754
  ]
18727
18755
  }
18728
18756
  );
@@ -18739,19 +18767,21 @@ function renderFileTooLarge(fileTooLargeState, renderProps, palette) {
18739
18767
  }
18740
18768
  return defaultNode;
18741
18769
  }
18742
- function renderCustomFileTooLarge(fileTooLargeState, renderProps, palette) {
18770
+ function renderCustomFileTooLarge(fileTooLargeState, renderProps, palette, messages, locale) {
18743
18771
  if (fileTooLargeState === void 0) {
18744
18772
  return void 0;
18745
18773
  }
18746
- return renderFileTooLarge(fileTooLargeState, renderProps, palette);
18774
+ return renderFileTooLarge(fileTooLargeState, renderProps, palette, messages, locale);
18747
18775
  }
18748
- function renderDefaultChartLoadingCard(rect) {
18776
+ function renderDefaultChartLoadingCard(rect, messages) {
18749
18777
  const bars = [18, 32, 24];
18750
18778
  const barWidth = Math.max(8, Math.min(12, Math.round(rect.width * 0.018)));
18751
18779
  const barGap = 8;
18752
18780
  return /* @__PURE__ */ u(
18753
18781
  "div",
18754
18782
  {
18783
+ role: "status",
18784
+ "aria-label": messages.loadingChart,
18755
18785
  style: {
18756
18786
  backgroundColor: "#ffffff",
18757
18787
  border: "1px solid #e5e7eb",
@@ -18789,8 +18819,8 @@ function renderDefaultChartLoadingCard(rect) {
18789
18819
  }
18790
18820
  );
18791
18821
  }
18792
- function renderChartLoadingNode(renderChartLoading, chart, rect, stage = "metadata") {
18793
- const defaultNode = renderDefaultChartLoadingCard(rect);
18822
+ function renderChartLoadingNode(renderChartLoading, chart, rect, messages, stage = "metadata") {
18823
+ const defaultNode = renderDefaultChartLoadingCard(rect, messages);
18794
18824
  if (!renderChartLoading) {
18795
18825
  return defaultNode;
18796
18826
  }
@@ -18801,19 +18831,6 @@ function renderChartLoadingNode(renderChartLoading, chart, rect, stage = "metada
18801
18831
  stage
18802
18832
  });
18803
18833
  }
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
18834
  function renderDeferredLoad(controller, palette) {
18818
18835
  return /* @__PURE__ */ u(
18819
18836
  "div",
@@ -18839,13 +18856,8 @@ function renderDeferredLoad(controller, palette) {
18839
18856
  width: "100%"
18840
18857
  },
18841
18858
  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." }),
18859
+ /* @__PURE__ */ u("div", { style: { fontSize: 16, fontWeight: 600 }, children: controller.messages.largeWorkbook }),
18860
+ /* @__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
18861
  /* @__PURE__ */ u("div", { style: { display: "flex", gap: 10, marginTop: 16 }, children: /* @__PURE__ */ u(
18850
18862
  "button",
18851
18863
  {
@@ -18862,7 +18874,7 @@ function renderDeferredLoad(controller, palette) {
18862
18874
  padding: "8px 12px"
18863
18875
  },
18864
18876
  type: "button",
18865
- children: "Load Anyway"
18877
+ children: controller.messages.loadAnyway
18866
18878
  }
18867
18879
  ) })
18868
18880
  ]
@@ -20145,6 +20157,7 @@ function XlsxGrid({
20145
20157
  getCellDisplayValue: getControllerCellDisplayValue,
20146
20158
  getCellFormula,
20147
20159
  locale,
20160
+ messages,
20148
20161
  getFormControlItems,
20149
20162
  highlightedRanges,
20150
20163
  images,
@@ -24032,7 +24045,7 @@ function XlsxGrid({
24032
24045
  triggerIcon,
24033
24046
  triggerProps: {
24034
24047
  "aria-haspopup": "menu",
24035
- "aria-label": `Open menu for ${tableColumn.name}`,
24048
+ "aria-label": formatMessage(messages.openMenuForColumn, { column: tableColumn.name }),
24036
24049
  onClick: (event) => {
24037
24050
  event.stopPropagation();
24038
24051
  },
@@ -24048,7 +24061,7 @@ function XlsxGrid({
24048
24061
  "button",
24049
24062
  {
24050
24063
  "aria-haspopup": "menu",
24051
- "aria-label": `Open menu for ${tableColumn.name}`,
24064
+ "aria-label": formatMessage(messages.openMenuForColumn, { column: tableColumn.name }),
24052
24065
  "aria-expanded": openTableMenu?.tableName === table.name && openTableMenu.col === cell.col && openTableMenu.row === cell.row,
24053
24066
  onPointerDown: (event) => {
24054
24067
  event.preventDefault();
@@ -24066,7 +24079,7 @@ function XlsxGrid({
24066
24079
  children: experimentalCanvas ? null : triggerIcon
24067
24080
  }
24068
24081
  );
24069
- }, [effectiveTables, experimentalCanvas, openTableMenu, palette, renderTableHeaderMenu, sortState, sortTable, zoomFactor]);
24082
+ }, [effectiveTables, experimentalCanvas, messages, openTableMenu, palette, renderTableHeaderMenu, sortState, sortTable, zoomFactor]);
24070
24083
  const resolveCanvasColumnHeaderRect = q((actualCol) => {
24071
24084
  const colIndex = colIndexByActual.get(actualCol);
24072
24085
  if (colIndex === void 0) {
@@ -25728,7 +25741,7 @@ function XlsxGrid({
25728
25741
  selectChartElement(selection2);
25729
25742
  }, [selectChartElement]);
25730
25743
  if (isLoading) {
25731
- return /* @__PURE__ */ u(S, { children: renderLoading(loadingComponent, loadingState, palette) });
25744
+ return /* @__PURE__ */ u(S, { children: renderLoading(loadingComponent, loadingState, palette, messages) });
25732
25745
  }
25733
25746
  if (isLoadDeferred) {
25734
25747
  return /* @__PURE__ */ u(S, { children: renderDeferredLoad({ ...controller, canLoadDeferred, continueDeferredLoad, deferredLoadFileSize, isLoadDeferred }, palette) });
@@ -25742,10 +25755,12 @@ function XlsxGrid({
25742
25755
  fileSizeBytes: error.fileSizeBytes,
25743
25756
  maxFileSizeBytes: error.maxFileSizeBytes
25744
25757
  },
25745
- palette
25758
+ palette,
25759
+ messages,
25760
+ locale
25746
25761
  ) });
25747
25762
  }
25748
- return /* @__PURE__ */ u(S, { children: renderError(errorState, error, palette) });
25763
+ return /* @__PURE__ */ u(S, { children: renderError(errorState, error, palette, messages) });
25749
25764
  }
25750
25765
  if (!activeSheet && activeTab?.kind === "chartsheet") {
25751
25766
  return /* @__PURE__ */ u(
@@ -25788,12 +25803,12 @@ function XlsxGrid({
25788
25803
  maxWidth: "100%",
25789
25804
  aspectRatio: sourceSize ? `${chartsheetRect.width}/${chartsheetRect.height}` : void 0,
25790
25805
  position: "relative"
25791
- }, children: isChartsLoading ? renderChartLoadingNode(renderChartLoading, chart, chartsheetRect) : /* @__PURE__ */ u(
25806
+ }, children: isChartsLoading ? renderChartLoadingNode(renderChartLoading, chart, chartsheetRect, messages) : /* @__PURE__ */ u(
25792
25807
  MemoChartSvg,
25793
25808
  {
25794
25809
  experimentalOfficeCharts,
25795
25810
  chart,
25796
- loadingFallback: (stage) => renderChartLoadingNode(renderChartLoading, chart, chartsheetRect, stage),
25811
+ loadingFallback: (stage) => renderChartLoadingNode(renderChartLoading, chart, chartsheetRect, messages, stage),
25797
25812
  onChartElementDoubleClick: handleChartElementDoubleClick,
25798
25813
  onChartElementPointerDown: handleChartElementPointerDown,
25799
25814
  palette,
@@ -25812,7 +25827,7 @@ function XlsxGrid({
25812
25827
  justifyContent: "center",
25813
25828
  minHeight: 320
25814
25829
  },
25815
- children: "Chartsheet metadata is present, but no embedded chart payload was exposed for this tab."
25830
+ children: messages.chartsheetUnavailable
25816
25831
  }
25817
25832
  )
25818
25833
  }
@@ -25821,7 +25836,7 @@ function XlsxGrid({
25821
25836
  );
25822
25837
  }
25823
25838
  if (!activeSheet) {
25824
- return /* @__PURE__ */ u(S, { children: renderEmpty(emptyState, palette) });
25839
+ return /* @__PURE__ */ u(S, { children: renderEmpty(emptyState, palette, messages) });
25825
25840
  }
25826
25841
  const virtualRows = domExpandedWindow.rowIndices.map((index) => {
25827
25842
  const virtualRow = rowVirtualItemByIndex.get(index);
@@ -26434,7 +26449,7 @@ function XlsxGrid({
26434
26449
  "select",
26435
26450
  {
26436
26451
  "aria-disabled": readOnly || control.controlIndex === void 0 || controlItems.length === 0,
26437
- "aria-label": controlLabel || control.name || "Dropdown form control",
26452
+ "aria-label": controlLabel || control.name || messages.dropdownControl,
26438
26453
  disabled: !readOnly && (control.controlIndex === void 0 || controlItems.length === 0),
26439
26454
  onChange: (event) => {
26440
26455
  event.stopPropagation();
@@ -26468,7 +26483,7 @@ function XlsxGrid({
26468
26483
  "select",
26469
26484
  {
26470
26485
  "aria-disabled": readOnly || control.controlIndex === void 0 || controlItems.length === 0,
26471
- "aria-label": controlLabel || control.name || "List box form control",
26486
+ "aria-label": controlLabel || control.name || messages.listBoxControl,
26472
26487
  disabled: !readOnly && (control.controlIndex === void 0 || controlItems.length === 0),
26473
26488
  multiple: allowsMultipleSelection,
26474
26489
  onChange: (event) => {
@@ -26503,7 +26518,7 @@ function XlsxGrid({
26503
26518
  "input",
26504
26519
  {
26505
26520
  "aria-disabled": readOnly || control.controlIndex === void 0,
26506
- "aria-label": controlLabel || control.name || "Scrollbar form control",
26521
+ "aria-label": controlLabel || control.name || messages.scrollbarControl,
26507
26522
  disabled: !readOnly && control.controlIndex === void 0,
26508
26523
  max,
26509
26524
  min,
@@ -26535,7 +26550,7 @@ function XlsxGrid({
26535
26550
  "input",
26536
26551
  {
26537
26552
  "aria-disabled": readOnly || control.controlIndex === void 0,
26538
- "aria-label": controlLabel || control.name || "Spinner form control",
26553
+ "aria-label": controlLabel || control.name || messages.spinnerControl,
26539
26554
  disabled: !readOnly && control.controlIndex === void 0,
26540
26555
  max,
26541
26556
  min,
@@ -26777,12 +26792,12 @@ function XlsxGrid({
26777
26792
  cursor: canEditChart && selectedChartId === chart.id ? "move" : "cell",
26778
26793
  pointerEvents: "auto"
26779
26794
  },
26780
- children: isChartsLoading ? renderChartLoadingNode(renderChartLoading, chart, rect) : /* @__PURE__ */ u(
26795
+ children: isChartsLoading ? renderChartLoadingNode(renderChartLoading, chart, rect, messages) : /* @__PURE__ */ u(
26781
26796
  MemoChartSvg,
26782
26797
  {
26783
26798
  experimentalOfficeCharts,
26784
26799
  chart,
26785
- loadingFallback: (stage) => renderChartLoadingNode(renderChartLoading, chart, rect, stage),
26800
+ loadingFallback: (stage) => renderChartLoadingNode(renderChartLoading, chart, rect, messages, stage),
26786
26801
  onChartElementDoubleClick: handleChartElementDoubleClick,
26787
26802
  onChartElementPointerDown: handleChartElementPointerDown,
26788
26803
  palette,
@@ -27526,7 +27541,7 @@ function XlsxGrid({
27526
27541
  ref: scrollRef,
27527
27542
  "aria-colcount": Math.max(activeSheet?.colCount ?? 0, displayColLimit),
27528
27543
  "aria-keyshortcuts": "ArrowUp ArrowDown ArrowLeft ArrowRight Home End PageUp PageDown Control+Home Control+End",
27529
- "aria-label": activeSheet ? `${activeSheet.name} worksheet grid` : "Workbook grid",
27544
+ "aria-label": activeSheet ? formatMessage(messages.worksheetGrid, { sheet: activeSheet.name }) : messages.workbookGrid,
27530
27545
  "aria-readonly": readOnly,
27531
27546
  "aria-rowcount": Math.max(activeSheet?.rowCount ?? 0, displayRowLimit),
27532
27547
  role: "grid",
@@ -28337,7 +28352,8 @@ function XlsxViewerInner({
28337
28352
  allowResizeInReadOnly = false,
28338
28353
  autoScrollToHighlightedRanges = true,
28339
28354
  className,
28340
- controller,
28355
+ controller: sourceController,
28356
+ messages: messageOverrides,
28341
28357
  emptyState,
28342
28358
  enableCanvasSelectionAnimation = true,
28343
28359
  enableGestureZoom = true,
@@ -28375,6 +28391,11 @@ function XlsxViewerInner({
28375
28391
  showDefaultToolbar = true,
28376
28392
  toolbar
28377
28393
  }) {
28394
+ const messages = T(
28395
+ () => mergeMessages(sourceController.messages, messageOverrides),
28396
+ [sourceController.messages, messageOverrides]
28397
+ );
28398
+ const controller = T(() => ({ ...sourceController, messages }), [sourceController, messages]);
28378
28399
  const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
28379
28400
  const { displayFileName, error } = controller;
28380
28401
  const appliedHighlightRef = A(null);
@@ -28404,11 +28425,14 @@ function XlsxViewerInner({
28404
28425
  fileSizeBytes: error.fileSizeBytes,
28405
28426
  maxFileSizeBytes: error.maxFileSizeBytes
28406
28427
  },
28407
- palette
28428
+ palette,
28429
+ messages,
28430
+ controller.locale
28408
28431
  ) : 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(
28432
+ 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
28433
  "div",
28411
28434
  {
28435
+ lang: controller.locale,
28412
28436
  className: classNames("react-xlsx-viewer", className),
28413
28437
  style: {
28414
28438
  blockSize: height,
@@ -28469,7 +28493,7 @@ function XlsxViewerInner({
28469
28493
  ) })
28470
28494
  ]
28471
28495
  }
28472
- ) }) });
28496
+ ) }) }) });
28473
28497
  }
28474
28498
  function XlsxViewerWithInlineController(props) {
28475
28499
  const controller = useXlsxViewerController(props);
@@ -28688,4 +28712,4 @@ export {
28688
28712
  __createContentNode,
28689
28713
  __createContentRoot
28690
28714
  };
28691
- //# sourceMappingURL=chunk-VSM7WKLM.js.map
28715
+ //# sourceMappingURL=chunk-O4S5CRDM.js.map