@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
package/dist/index.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import {
2
- loadOfficeFonts
3
- } from "./chunk-7GBCRNGO.js";
2
+ formatMessage,
3
+ loadOfficeFonts,
4
+ mergeMessages,
5
+ resolveMessages,
6
+ useXlsxMessages
7
+ } from "./chunk-IRC7BQ6E.js";
4
8
 
5
9
  // src/number-locale.ts
6
10
  var separators = /* @__PURE__ */ new Map();
@@ -9427,6 +9431,7 @@ function useXlsxViewerController(options) {
9427
9431
  file,
9428
9432
  fileName,
9429
9433
  locale = "en-US",
9434
+ messages: messageOverrides,
9430
9435
  maxFileSizeBytes = DEFAULT_MAX_FILE_SIZE_BYTES,
9431
9436
  readOnly: requestedReadOnly = false,
9432
9437
  readOnlyAboveBytes = 0,
@@ -9435,6 +9440,7 @@ function useXlsxViewerController(options) {
9435
9440
  src,
9436
9441
  useWorker = true
9437
9442
  } = options;
9443
+ const messages = React.useMemo(() => resolveMessages(locale, messageOverrides), [locale, messageOverrides]);
9438
9444
  const [isLoading, setIsLoading] = React.useState(Boolean(file ?? src));
9439
9445
  const [error, setError] = React.useState(null);
9440
9446
  const [workbook, setWorkbook] = React.useState(null);
@@ -11571,6 +11577,28 @@ function useXlsxViewerController(options) {
11571
11577
  refreshWorkbookState(workbook);
11572
11578
  recordCellEditHistory(cell, before, after);
11573
11579
  }, [captureCellMutationState, getActiveWorksheet, readOnly, recordCellEditHistory, refreshWorkbookState, workbook]);
11580
+ const setCellStyles = React.useCallback((updates) => {
11581
+ const worksheet = getActiveWorksheet();
11582
+ if (readOnly || !worksheet || !workbook) return;
11583
+ const beforeStates = /* @__PURE__ */ new Map();
11584
+ for (const { cell, style } of updates) {
11585
+ const key = `${cell.row}:${cell.col}`;
11586
+ if (!beforeStates.has(key)) {
11587
+ const before = captureCellMutationState(cell);
11588
+ if (!before) continue;
11589
+ beforeStates.set(key, { cell: { ...cell }, before });
11590
+ }
11591
+ worksheet.setCellStyleAt(cell.row, cell.col, style);
11592
+ }
11593
+ if (!beforeStates.size) return;
11594
+ const mutations = [];
11595
+ for (const { cell, before } of beforeStates.values()) {
11596
+ const after = captureCellMutationState(cell);
11597
+ if (after) mutations.push({ cell, before, after });
11598
+ }
11599
+ refreshWorkbookState(workbook);
11600
+ recordRangeEditHistory(mutations, selection, activeCell);
11601
+ }, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
11574
11602
  const setSelectedCellValue = React.useCallback((value) => {
11575
11603
  if (!activeCell) {
11576
11604
  return;
@@ -12177,6 +12205,7 @@ function useXlsxViewerController(options) {
12177
12205
  defineNamedRange,
12178
12206
  displayFileName,
12179
12207
  locale,
12208
+ messages,
12180
12209
  download,
12181
12210
  exportCsv,
12182
12211
  exportXlsx,
@@ -12226,6 +12255,7 @@ function useXlsxViewerController(options) {
12226
12255
  resizeRow,
12227
12256
  setCellFormula,
12228
12257
  setCellStyle,
12258
+ setCellStyles,
12229
12259
  setCellValue,
12230
12260
  setRangeStyle,
12231
12261
  setSelectedFormula,
@@ -12301,6 +12331,7 @@ function useXlsxViewerController(options) {
12301
12331
  defineNamedRange,
12302
12332
  displayFileName,
12303
12333
  locale,
12334
+ messages,
12304
12335
  download,
12305
12336
  error,
12306
12337
  exportCsv,
@@ -12349,6 +12380,7 @@ function useXlsxViewerController(options) {
12349
12380
  resizeRow,
12350
12381
  setCellFormula,
12351
12382
  setCellStyle,
12383
+ setCellStyles,
12352
12384
  setCellValue,
12353
12385
  setRangeStyle,
12354
12386
  setSelectedFormula,
@@ -12402,12 +12434,12 @@ function useXlsxViewerController(options) {
12402
12434
  import { initWasm, parseXlsxRange as parseXlsxRange2, setWasmSource, XlsxFileSizeLimitExceededError as XlsxFileSizeLimitExceededError3 } from "@extend-ai/react-xlsx/vanilla";
12403
12435
 
12404
12436
  // src/react-viewer.tsx
12405
- import * as React7 from "react";
12406
- import { createPortal as createPortal2 } from "react-dom";
12437
+ import * as React10 from "react";
12438
+ import { createPortal as createPortal4 } from "react-dom";
12407
12439
  import { __createContentNode, __createContentRoot, __createControlledViewer } from "@extend-ai/react-xlsx/internal";
12408
12440
 
12409
12441
  // src/XlsxViewer.tsx
12410
- import * as React6 from "react";
12442
+ import * as React9 from "react";
12411
12443
 
12412
12444
  // src/cell-editor.tsx
12413
12445
  import * as React2 from "react";
@@ -12416,6 +12448,8 @@ function CellEditor({
12416
12448
  value,
12417
12449
  references,
12418
12450
  inputRef,
12451
+ editorRef,
12452
+ onFocusOverlay,
12419
12453
  canvasText = false,
12420
12454
  canvasOffset,
12421
12455
  paintCanvasText,
@@ -12427,6 +12461,7 @@ function CellEditor({
12427
12461
  onNavigate
12428
12462
  }) {
12429
12463
  const rootRef = React2.useRef(null);
12464
+ const messages = useXlsxMessages();
12430
12465
  const mirrorRef = React2.useRef(null);
12431
12466
  const textRef = React2.useRef(null);
12432
12467
  const baselineRef = React2.useRef(null);
@@ -12554,7 +12589,12 @@ function CellEditor({
12554
12589
  return /* @__PURE__ */ jsxs(
12555
12590
  "div",
12556
12591
  {
12557
- ref: rootRef,
12592
+ ref: (element) => {
12593
+ rootRef.current = element;
12594
+ if (typeof editorRef === "function") editorRef(element);
12595
+ else if (editorRef) editorRef.current = element;
12596
+ },
12597
+ "data-xlsx-cell-editor": "",
12558
12598
  onPointerDown: (event) => event.stopPropagation(),
12559
12599
  onClick: (event) => event.stopPropagation(),
12560
12600
  onDoubleClick: (event) => event.stopPropagation(),
@@ -12603,7 +12643,7 @@ function CellEditor({
12603
12643
  ] })
12604
12644
  }
12605
12645
  ),
12606
- paintCanvasText ? /* @__PURE__ */ jsx("canvas", { ref: canvasRef, "aria-hidden": "true", style: { position: "absolute", pointerEvents: "none" } }) : null,
12646
+ paintCanvasText ? /* @__PURE__ */ jsx("canvas", { ref: canvasRef, "data-xlsx-formula-text": "", "aria-hidden": "true", style: { position: "absolute", pointerEvents: "none" } }) : null,
12607
12647
  /* @__PURE__ */ jsx(
12608
12648
  "textarea",
12609
12649
  {
@@ -12612,7 +12652,8 @@ function CellEditor({
12612
12652
  if (typeof inputRef === "function") inputRef(element);
12613
12653
  else if (inputRef) inputRef.current = element;
12614
12654
  },
12615
- "aria-label": "Edit cell",
12655
+ "aria-label": messages.editCell,
12656
+ "aria-keyshortcuts": onFocusOverlay ? "Alt+ArrowDown" : void 0,
12616
12657
  autoFocus: true,
12617
12658
  autoComplete: "off",
12618
12659
  spellCheck: false,
@@ -12626,7 +12667,9 @@ function CellEditor({
12626
12667
  onKeyDown: (event) => {
12627
12668
  event.stopPropagation();
12628
12669
  if (event.nativeEvent.isComposing) return;
12629
- if (event.key === "Enter" && !event.altKey) {
12670
+ if (event.key === "ArrowDown" && event.altKey && onFocusOverlay?.()) {
12671
+ event.preventDefault();
12672
+ } else if (event.key === "Enter" && !event.altKey) {
12630
12673
  event.preventDefault();
12631
12674
  onCommit();
12632
12675
  } else if (event.key === "Escape") {
@@ -12672,6 +12715,19 @@ function CellEditor({
12672
12715
  );
12673
12716
  }
12674
12717
 
12718
+ // src/cell-editor-overlay.tsx
12719
+ import * as React3 from "react";
12720
+ import { createPortal } from "react-dom";
12721
+ import { jsx as jsx2 } from "react/jsx-runtime";
12722
+
12723
+ // src/selection-popover.tsx
12724
+ import * as React4 from "react";
12725
+ import { createPortal as createPortal2 } from "react-dom";
12726
+ import { jsx as jsx3 } from "react/jsx-runtime";
12727
+
12728
+ // src/cell-editor-session.ts
12729
+ import * as React5 from "react";
12730
+
12675
12731
  // src/cell-alignment.ts
12676
12732
  function getCellGeneralAlignment(worksheet, row, col) {
12677
12733
  const value = worksheet.getCalculatedValueAt(row, col);
@@ -12685,8 +12741,8 @@ function getCellGeneralAlignment(worksheet, row, col) {
12685
12741
  }
12686
12742
 
12687
12743
  // src/context-menu.tsx
12688
- import * as React3 from "react";
12689
- import { createPortal } from "react-dom";
12744
+ import * as React6 from "react";
12745
+ import { createPortal as createPortal3 } from "react-dom";
12690
12746
 
12691
12747
  // src/viewer-palette.ts
12692
12748
  var LIGHT_PALETTE = {
@@ -12750,10 +12806,10 @@ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextC
12750
12806
  }
12751
12807
 
12752
12808
  // src/context-menu.tsx
12753
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
12809
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
12754
12810
 
12755
12811
  // src/lazy-chart.tsx
12756
- import * as React5 from "react";
12812
+ import * as React8 from "react";
12757
12813
 
12758
12814
  // src/chart-loader.ts
12759
12815
  function createChartModule(importModule) {
@@ -12786,27 +12842,27 @@ function createChartModule(importModule) {
12786
12842
  var officeChartRenderer = createChartModule(async () => {
12787
12843
  const [{ loadOfficeCharts }, { SharedChartSvg }] = await Promise.all([
12788
12844
  import("./browser-AWFV5QM2.js"),
12789
- import("./shared-chart-BLOOGI7S.js")
12845
+ import("./shared-chart-UTUK46E4.js")
12790
12846
  ]);
12791
12847
  return { renderer: await loadOfficeCharts(), SharedChartSvg };
12792
12848
  });
12793
12849
  var suppliedOfficeChartRenderer = createChartModule(async () => {
12794
- const { SharedChartSvg } = await import("./shared-chart-BLOOGI7S.js");
12850
+ const { SharedChartSvg } = await import("./shared-chart-UTUK46E4.js");
12795
12851
  return { renderer: null, SharedChartSvg };
12796
12852
  });
12797
12853
  var officeExtendedChartRenderer = createChartModule(async () => {
12798
12854
  const [{ loadOfficeCharts }, { SharedChartSvg }] = await Promise.all([
12799
12855
  import("./full-ERXNU2LF.js"),
12800
- import("./shared-chart-BLOOGI7S.js")
12856
+ import("./shared-chart-UTUK46E4.js")
12801
12857
  ]);
12802
12858
  return { renderer: await loadOfficeCharts(typeof DecompressionStream === "function" ? void 0 : new URL("./office_charts_full_bg.wasm", import.meta.url)), SharedChartSvg };
12803
12859
  });
12804
12860
 
12805
12861
  // src/use-chart-module.ts
12806
- import * as React4 from "react";
12862
+ import * as React7 from "react";
12807
12863
 
12808
12864
  // src/lazy-chart.tsx
12809
- import { Fragment as Fragment3, jsx as jsx3 } from "react/jsx-runtime";
12865
+ import { Fragment as Fragment3, jsx as jsx5 } from "react/jsx-runtime";
12810
12866
 
12811
12867
  // src/picture-paint.ts
12812
12868
  function resolvePicturePaintRect(image, rect) {
@@ -12823,7 +12879,7 @@ function resolvePicturePaintRect(image, rect) {
12823
12879
  }
12824
12880
 
12825
12881
  // src/XlsxViewer.tsx
12826
- import { Fragment as Fragment5, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
12882
+ import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
12827
12883
  var DEFAULT_ROW_HEIGHT2 = 24;
12828
12884
  var DEFAULT_COL_WIDTH2 = 80;
12829
12885
  var HEADER_HEIGHT = 24;
@@ -13421,8 +13477,8 @@ function drawCanvasConditionalIcon(context, icon, centerX, centerY, size) {
13421
13477
  context.fill();
13422
13478
  context.restore();
13423
13479
  }
13424
- function formatZoomScale(zoomScale) {
13425
- return `${Math.round(zoomScale)}%`;
13480
+ function formatZoomScale(zoomScale, locale) {
13481
+ return new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 }).format(zoomScale / 100);
13426
13482
  }
13427
13483
  function parseRgbColor(color) {
13428
13484
  const match = /^#?([0-9a-f]{6})$/i.exec(color);
@@ -13455,10 +13511,10 @@ function lightenColor(color, ratio) {
13455
13511
  function darkenColor(color, ratio) {
13456
13512
  return mixRgbColor(color, "#000000", ratio);
13457
13513
  }
13458
- var ViewerContext = React6.createContext(null);
13459
- var ViewerAppearanceContext = React6.createContext({ isDark: false });
13514
+ var ViewerContext = React9.createContext(null);
13515
+ var ViewerAppearanceContext = React9.createContext({ isDark: false });
13460
13516
  function ReferenceRangeHandles({ color, top = true, bottom = true, left = true, right = true }) {
13461
- return /* @__PURE__ */ jsx4(Fragment5, { children: [top && "top", bottom && "bottom"].flatMap((vertical) => vertical ? [left && "left", right && "right"].map((horizontal) => horizontal ? /* @__PURE__ */ jsx4("span", { style: {
13517
+ return /* @__PURE__ */ jsx6(Fragment5, { children: [top && "top", bottom && "bottom"].flatMap((vertical) => vertical ? [left && "left", right && "right"].map((horizontal) => horizontal ? /* @__PURE__ */ jsx6("span", { style: {
13462
13518
  position: "absolute",
13463
13519
  [vertical]: -4,
13464
13520
  [horizontal]: -4,
@@ -14432,7 +14488,7 @@ function applyCanvasShapeDash(context, dash, lineWidth) {
14432
14488
  }
14433
14489
  }
14434
14490
  function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
14435
- return React6.useMemo(
14491
+ return React9.useMemo(
14436
14492
  () => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
14437
14493
  [headerBackgroundColor, headerTextColor, isDark]
14438
14494
  );
@@ -15119,10 +15175,10 @@ function renderSparkline(sparkline, values, palette) {
15119
15175
  const gap = normalizedValues.length > 1 ? (innerWidth - segmentWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
15120
15176
  const positiveY = 4.5;
15121
15177
  const negativeY = height - 4.5;
15122
- return /* @__PURE__ */ jsx4("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: normalizedValues.map((entry, index) => {
15178
+ return /* @__PURE__ */ jsx6("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: normalizedValues.map((entry, index) => {
15123
15179
  const left = 1 + index * (segmentWidth + Math.max(0, gap));
15124
15180
  const y = entry.value >= 0 ? positiveY : negativeY;
15125
- return /* @__PURE__ */ jsx4(
15181
+ return /* @__PURE__ */ jsx6(
15126
15182
  "line",
15127
15183
  {
15128
15184
  stroke: seriesColor,
@@ -15145,14 +15201,14 @@ function renderSparkline(sparkline, values, palette) {
15145
15201
  const barWidth = Math.max(2, innerWidth / Math.max(normalizedValues.length * 1.8, 1));
15146
15202
  const gap = normalizedValues.length > 1 ? (innerWidth - barWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
15147
15203
  return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
15148
- /* @__PURE__ */ jsx4("line", { stroke: palette.border, strokeWidth: 1, x1: 1, x2: width - 1, y1: zeroY, y2: zeroY }),
15204
+ /* @__PURE__ */ jsx6("line", { stroke: palette.border, strokeWidth: 1, x1: 1, x2: width - 1, y1: zeroY, y2: zeroY }),
15149
15205
  normalizedValues.map((entry, index) => {
15150
15206
  const left = 1 + index * (barWidth + Math.max(0, gap));
15151
15207
  const y = 2 + innerHeight - clampSparklineValue(entry.value, minValue2, maxValue2) * innerHeight;
15152
15208
  const top = Math.min(y, zeroY);
15153
15209
  const barHeight = Math.max(1, Math.abs(y - zeroY));
15154
15210
  const fill = entry.value < 0 ? negativeColor : seriesColor;
15155
- return /* @__PURE__ */ jsx4(
15211
+ return /* @__PURE__ */ jsx6(
15156
15212
  "rect",
15157
15213
  {
15158
15214
  fill,
@@ -15179,7 +15235,7 @@ function renderSparkline(sparkline, values, palette) {
15179
15235
  const highValue = Math.max(...points.map((entry) => entry.value));
15180
15236
  const lowValue = Math.min(...points.map((entry) => entry.value));
15181
15237
  return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
15182
- /* @__PURE__ */ jsx4("path", { d: path, fill: "none", stroke: seriesColor, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6 }),
15238
+ /* @__PURE__ */ jsx6("path", { d: path, fill: "none", stroke: seriesColor, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6 }),
15183
15239
  sparkline.markers ? points.map((entry, index) => {
15184
15240
  const x = 1 + index * xStep;
15185
15241
  const y = 2 + innerHeight - clampSparklineValue(entry.value, minValue, maxValue) * innerHeight;
@@ -15195,7 +15251,7 @@ function renderSparkline(sparkline, values, palette) {
15195
15251
  } else if (entry.value < 0 && sparkline.negative && sparkline.negativeColor) {
15196
15252
  fill = sparkline.negativeColor;
15197
15253
  }
15198
- return /* @__PURE__ */ jsx4("circle", { cx: x, cy: y, fill, r: 1.75 }, `spark-point-${index}`);
15254
+ return /* @__PURE__ */ jsx6("circle", { cx: x, cy: y, fill, r: 1.75 }, `spark-point-${index}`);
15199
15255
  }) : null
15200
15256
  ] });
15201
15257
  }
@@ -15313,14 +15369,15 @@ function mergeResolvedCellStyle(base, overlay, options) {
15313
15369
  }
15314
15370
  function SegmentedControl({
15315
15371
  items,
15372
+ messages,
15316
15373
  onValueChange,
15317
15374
  palette,
15318
15375
  value
15319
15376
  }) {
15320
- return /* @__PURE__ */ jsx4(
15377
+ return /* @__PURE__ */ jsx6(
15321
15378
  "div",
15322
15379
  {
15323
- "aria-label": "Workbook sheets",
15380
+ "aria-label": messages.workbookSheets,
15324
15381
  role: "tablist",
15325
15382
  style: {
15326
15383
  alignItems: "center",
@@ -15335,7 +15392,7 @@ function SegmentedControl({
15335
15392
  children: items.map((item) => {
15336
15393
  const selected = item.id === value;
15337
15394
  const isHidden = item.visibility === "hidden" || item.visibility === "veryHidden";
15338
- return /* @__PURE__ */ jsx4(
15395
+ return /* @__PURE__ */ jsx6(
15339
15396
  "button",
15340
15397
  {
15341
15398
  "aria-selected": selected,
@@ -15372,6 +15429,8 @@ function DefaultToolbar({ controller, palette }) {
15372
15429
  canZoomIn,
15373
15430
  canZoomOut,
15374
15431
  defaultZoomScale,
15432
+ locale,
15433
+ messages,
15375
15434
  displayFileName,
15376
15435
  download,
15377
15436
  resetZoom,
@@ -15397,7 +15456,7 @@ function DefaultToolbar({ controller, palette }) {
15397
15456
  padding: "0 16px"
15398
15457
  },
15399
15458
  children: [
15400
- /* @__PURE__ */ jsx4("div", { style: { minWidth: 0 }, children: /* @__PURE__ */ jsx4(
15459
+ /* @__PURE__ */ jsx6("div", { style: { minWidth: 0 }, children: /* @__PURE__ */ jsx6(
15401
15460
  "div",
15402
15461
  {
15403
15462
  style: {
@@ -15424,9 +15483,10 @@ function DefaultToolbar({ controller, palette }) {
15424
15483
  overflow: "hidden"
15425
15484
  },
15426
15485
  children: [
15427
- /* @__PURE__ */ jsx4(
15486
+ /* @__PURE__ */ jsx6(
15428
15487
  "button",
15429
15488
  {
15489
+ "aria-label": messages.zoomOut,
15430
15490
  disabled: !canZoomOut,
15431
15491
  onClick: zoomOut,
15432
15492
  style: {
@@ -15442,9 +15502,10 @@ function DefaultToolbar({ controller, palette }) {
15442
15502
  children: "-"
15443
15503
  }
15444
15504
  ),
15445
- /* @__PURE__ */ jsx4(
15505
+ /* @__PURE__ */ jsx6(
15446
15506
  "button",
15447
15507
  {
15508
+ "aria-label": messages.resetZoom,
15448
15509
  onClick: resetZoom,
15449
15510
  style: {
15450
15511
  background: Math.round(zoomScale) === Math.round(defaultZoomScale) ? "transparent" : palette.subtleSurface,
@@ -15459,12 +15520,13 @@ function DefaultToolbar({ controller, palette }) {
15459
15520
  padding: "6px 10px"
15460
15521
  },
15461
15522
  type: "button",
15462
- children: formatZoomScale(zoomScale)
15523
+ children: formatZoomScale(zoomScale, locale)
15463
15524
  }
15464
15525
  ),
15465
- /* @__PURE__ */ jsx4(
15526
+ /* @__PURE__ */ jsx6(
15466
15527
  "button",
15467
15528
  {
15529
+ "aria-label": messages.zoomIn,
15468
15530
  disabled: !canZoomIn,
15469
15531
  onClick: zoomIn,
15470
15532
  style: {
@@ -15483,10 +15545,10 @@ function DefaultToolbar({ controller, palette }) {
15483
15545
  ]
15484
15546
  }
15485
15547
  ),
15486
- canDownload ? /* @__PURE__ */ jsx4(
15548
+ canDownload ? /* @__PURE__ */ jsx6(
15487
15549
  "button",
15488
15550
  {
15489
- "aria-label": "Download workbook",
15551
+ "aria-label": messages.downloadWorkbook,
15490
15552
  onClick: download,
15491
15553
  style: {
15492
15554
  alignItems: "center",
@@ -15503,7 +15565,7 @@ function DefaultToolbar({ controller, palette }) {
15503
15565
  padding: 0,
15504
15566
  width: 32
15505
15567
  },
15506
- title: "Download workbook",
15568
+ title: messages.downloadWorkbook,
15507
15569
  type: "button",
15508
15570
  children: "\u2193"
15509
15571
  }
@@ -15512,7 +15574,7 @@ function DefaultToolbar({ controller, palette }) {
15512
15574
  ]
15513
15575
  }
15514
15576
  ),
15515
- tabs.length > 1 ? /* @__PURE__ */ jsx4(
15577
+ tabs.length > 1 ? /* @__PURE__ */ jsx6(
15516
15578
  "div",
15517
15579
  {
15518
15580
  style: {
@@ -15521,13 +15583,14 @@ function DefaultToolbar({ controller, palette }) {
15521
15583
  overflowX: "auto",
15522
15584
  padding: "8px 12px"
15523
15585
  },
15524
- children: /* @__PURE__ */ jsx4(
15586
+ children: /* @__PURE__ */ jsx6(
15525
15587
  SegmentedControl,
15526
15588
  {
15589
+ messages,
15527
15590
  items: tabs.map((tab, index) => ({
15528
15591
  id: String(index),
15529
15592
  label: tab.name,
15530
- title: tab.visibility === "hidden" ? `${tab.name} (hidden)` : tab.visibility === "veryHidden" ? `${tab.name} (very hidden)` : tab.name,
15593
+ title: tab.visibility === "hidden" ? formatMessage(messages.hiddenSheet, { sheet: tab.name }) : tab.visibility === "veryHidden" ? formatMessage(messages.veryHiddenSheet, { sheet: tab.name }) : tab.name,
15531
15594
  visibility: tab.visibility
15532
15595
  })),
15533
15596
  onValueChange: (value) => setActiveTabIndex(Number(value)),
@@ -15838,7 +15901,7 @@ function renderConditionalIcon(icon, scale = 1) {
15838
15901
  if (icon.shape === "arrow") {
15839
15902
  const fill = icon.color ?? "#111827";
15840
15903
  const stroke = icon.borderColor ?? darkenColor(fill, 0.32);
15841
- return /* @__PURE__ */ jsx4(
15904
+ return /* @__PURE__ */ jsx6(
15842
15905
  "svg",
15843
15906
  {
15844
15907
  "aria-hidden": "true",
@@ -15846,7 +15909,7 @@ function renderConditionalIcon(icon, scale = 1) {
15846
15909
  style: { display: "block" },
15847
15910
  viewBox: "0 0 16 16",
15848
15911
  width: iconSize,
15849
- children: /* @__PURE__ */ jsx4("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx4(
15912
+ children: /* @__PURE__ */ jsx6("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx6(
15850
15913
  "path",
15851
15914
  {
15852
15915
  d: "M2.5 8 L8.4 2.4 L8.4 5.2 L13.5 5.2 L13.5 10.8 L8.4 10.8 L8.4 13.6 Z",
@@ -15860,7 +15923,7 @@ function renderConditionalIcon(icon, scale = 1) {
15860
15923
  );
15861
15924
  }
15862
15925
  if (icon.glyph) {
15863
- return /* @__PURE__ */ jsx4(
15926
+ return /* @__PURE__ */ jsx6(
15864
15927
  "span",
15865
15928
  {
15866
15929
  style: {
@@ -15878,7 +15941,7 @@ function renderConditionalIcon(icon, scale = 1) {
15878
15941
  }
15879
15942
  );
15880
15943
  }
15881
- return /* @__PURE__ */ jsx4(
15944
+ return /* @__PURE__ */ jsx6(
15882
15945
  "span",
15883
15946
  {
15884
15947
  style: {
@@ -15903,8 +15966,8 @@ function renderCheckboxControl(checked, palette, scale = 1, mixed = false) {
15903
15966
  const fill = checked || mixed ? paletteIsDark(palette) ? "#60a5fa" : "#2563eb" : "transparent";
15904
15967
  const check = paletteIsDark(palette) ? "#020617" : "#ffffff";
15905
15968
  return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height: 14 * scale, style: { display: "block" }, viewBox: "0 0 16 16", width: 14 * scale, children: [
15906
- /* @__PURE__ */ jsx4("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
15907
- mixed ? /* @__PURE__ */ jsx4("path", { d: "M5 8h6", fill: "none", stroke: check, strokeLinecap: "round", strokeWidth: 1.8 }) : checked ? /* @__PURE__ */ jsx4(
15969
+ /* @__PURE__ */ jsx6("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
15970
+ mixed ? /* @__PURE__ */ jsx6("path", { d: "M5 8h6", fill: "none", stroke: check, strokeLinecap: "round", strokeWidth: 1.8 }) : checked ? /* @__PURE__ */ jsx6(
15908
15971
  "path",
15909
15972
  {
15910
15973
  d: "M5 8.1 7.1 10.2 11.3 5.8",
@@ -16316,6 +16379,10 @@ function GridRow({
16316
16379
  editingValue,
16317
16380
  formulaReferences,
16318
16381
  editorBoxShadow,
16382
+ editorRef,
16383
+ editorInputRef,
16384
+ cellEditorStyle,
16385
+ onFocusEditorOverlay,
16319
16386
  frozenRowHeaderZIndex,
16320
16387
  getCellData,
16321
16388
  headerLabelLiveScale,
@@ -16345,7 +16412,7 @@ function GridRow({
16345
16412
  }) {
16346
16413
  const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
16347
16414
  return /* @__PURE__ */ jsxs3("tr", { "data-xlsx-row": actualRow, style: { height: rowHeight }, children: [
16348
- /* @__PURE__ */ jsx4(
16415
+ /* @__PURE__ */ jsx6(
16349
16416
  "td",
16350
16417
  {
16351
16418
  ref: (element) => onRowHeaderRef(actualRow, element),
@@ -16371,7 +16438,7 @@ function GridRow({
16371
16438
  zIndex: stickyTop !== void 0 ? frozenRowHeaderZIndex : rowHeaderZIndex
16372
16439
  },
16373
16440
  children: /* @__PURE__ */ jsxs3("div", { style: { position: "relative" }, children: [
16374
- /* @__PURE__ */ jsx4(
16441
+ /* @__PURE__ */ jsx6(
16375
16442
  "span",
16376
16443
  {
16377
16444
  style: {
@@ -16382,7 +16449,7 @@ function GridRow({
16382
16449
  children: actualRow + 1
16383
16450
  }
16384
16451
  ),
16385
- /* @__PURE__ */ jsx4(
16452
+ /* @__PURE__ */ jsx6(
16386
16453
  "div",
16387
16454
  {
16388
16455
  onPointerDown: (event) => onRowResizePointerDown(event, actualRow, rowHeight),
@@ -16401,7 +16468,7 @@ function GridRow({
16401
16468
  ] })
16402
16469
  }
16403
16470
  ),
16404
- leadingSpacerWidth > 0 ? /* @__PURE__ */ jsx4(
16471
+ leadingSpacerWidth > 0 ? /* @__PURE__ */ jsx6(
16405
16472
  "td",
16406
16473
  {
16407
16474
  "aria-hidden": "true",
@@ -16563,7 +16630,7 @@ function GridRow({
16563
16630
  style: cellStyle,
16564
16631
  title,
16565
16632
  children: [
16566
- cellData.chartHighlight ? /* @__PURE__ */ jsx4(
16633
+ cellData.chartHighlight ? /* @__PURE__ */ jsx6(
16567
16634
  "div",
16568
16635
  {
16569
16636
  "aria-hidden": "true",
@@ -16578,7 +16645,7 @@ function GridRow({
16578
16645
  pointerEvents: "none",
16579
16646
  position: "absolute"
16580
16647
  },
16581
- children: /* @__PURE__ */ jsx4(
16648
+ children: /* @__PURE__ */ jsx6(
16582
16649
  ReferenceRangeHandles,
16583
16650
  {
16584
16651
  color: cellData.chartHighlight.strokeColor,
@@ -16590,7 +16657,7 @@ function GridRow({
16590
16657
  )
16591
16658
  }
16592
16659
  ) : null,
16593
- cellData.conditionalDataBar ? /* @__PURE__ */ jsx4(
16660
+ cellData.conditionalDataBar ? /* @__PURE__ */ jsx6(
16594
16661
  "div",
16595
16662
  {
16596
16663
  "aria-hidden": "true",
@@ -16605,7 +16672,7 @@ function GridRow({
16605
16672
  top: 4 * zoomFactor,
16606
16673
  zIndex: 0
16607
16674
  },
16608
- children: /* @__PURE__ */ jsx4(
16675
+ children: /* @__PURE__ */ jsx6(
16609
16676
  "div",
16610
16677
  {
16611
16678
  style: {
@@ -16621,7 +16688,7 @@ function GridRow({
16621
16688
  }
16622
16689
  ) : null,
16623
16690
  adornment,
16624
- cellData.conditionalIcon ? /* @__PURE__ */ jsx4(
16691
+ cellData.conditionalIcon ? /* @__PURE__ */ jsx6(
16625
16692
  "div",
16626
16693
  {
16627
16694
  "aria-hidden": "true",
@@ -16639,7 +16706,7 @@ function GridRow({
16639
16706
  children: renderConditionalIcon(cellData.conditionalIcon, zoomFactor)
16640
16707
  }
16641
16708
  ) : null,
16642
- isSpilling && !isEditing ? /* @__PURE__ */ jsx4("div", { "aria-hidden": "true", style: {
16709
+ isSpilling && !isEditing ? /* @__PURE__ */ jsx6("div", { "aria-hidden": "true", style: {
16643
16710
  backgroundColor: cellStyle.backgroundColor ?? palette.surface,
16644
16711
  position: "absolute",
16645
16712
  left: cellData.spillSide === "left" ? cellData.spillOffsetX : "calc(100% - 1px)",
@@ -16648,9 +16715,12 @@ function GridRow({
16648
16715
  height: "calc(100% - 1px)",
16649
16716
  pointerEvents: "none"
16650
16717
  } }) : null,
16651
- isEditing ? /* @__PURE__ */ jsx4(
16718
+ isEditing ? /* @__PURE__ */ jsx6(
16652
16719
  CellEditor,
16653
16720
  {
16721
+ editorRef,
16722
+ inputRef: editorInputRef,
16723
+ onFocusOverlay: onFocusEditorOverlay,
16654
16724
  value: editingValue,
16655
16725
  references: formulaReferences,
16656
16726
  onBlur: onEditingBlur,
@@ -16665,10 +16735,11 @@ function GridRow({
16665
16735
  font: "inherit",
16666
16736
  lineHeight: cellData.style.lineHeight,
16667
16737
  verticalAlign: cellData.style.verticalAlign,
16668
- padding: cellData.style.padding
16738
+ padding: cellData.style.padding,
16739
+ ...cellEditorStyle
16669
16740
  }
16670
16741
  }
16671
- ) : isSpilling ? /* @__PURE__ */ jsx4(
16742
+ ) : isSpilling ? /* @__PURE__ */ jsx6(
16672
16743
  "div",
16673
16744
  {
16674
16745
  style: {
@@ -16682,7 +16753,7 @@ function GridRow({
16682
16753
  },
16683
16754
  children: cellData.value
16684
16755
  }
16685
- ) : cellData.sparkline ? /* @__PURE__ */ jsx4(
16756
+ ) : cellData.sparkline ? /* @__PURE__ */ jsx6(
16686
16757
  "div",
16687
16758
  {
16688
16759
  style: {
@@ -16695,7 +16766,7 @@ function GridRow({
16695
16766
  },
16696
16767
  children: renderSparkline(cellData.sparkline.config, cellData.sparkline.values, palette)
16697
16768
  }
16698
- ) : cellData.checkboxState != null ? /* @__PURE__ */ jsx4(
16769
+ ) : cellData.checkboxState != null ? /* @__PURE__ */ jsx6(
16699
16770
  "div",
16700
16771
  {
16701
16772
  style: {
@@ -16708,13 +16779,13 @@ function GridRow({
16708
16779
  },
16709
16780
  children: renderCheckboxControl(cellData.checkboxState, palette, zoomFactor)
16710
16781
  }
16711
- ) : /* @__PURE__ */ jsx4("div", { style: cellContentStyle, children: rotatedTextStyle ? /* @__PURE__ */ jsx4("span", { style: { ...rotatedTextBounds, flex: "0 0 auto", position: "relative" }, children: /* @__PURE__ */ jsx4("span", { style: rotatedTextStyle, children: cellData.value }) }) : wrappedTextStyle ? /* @__PURE__ */ jsx4("span", { style: wrappedTextStyle, children: cellData.value }) : cellData.value })
16782
+ ) : /* @__PURE__ */ jsx6("div", { style: cellContentStyle, children: rotatedTextStyle ? /* @__PURE__ */ jsx6("span", { style: { ...rotatedTextBounds, flex: "0 0 auto", position: "relative" }, children: /* @__PURE__ */ jsx6("span", { style: rotatedTextStyle, children: cellData.value }) }) : wrappedTextStyle ? /* @__PURE__ */ jsx6("span", { style: wrappedTextStyle, children: cellData.value }) : cellData.value })
16712
16783
  ]
16713
16784
  },
16714
16785
  key
16715
16786
  );
16716
16787
  }),
16717
- trailingSpacerWidth > 0 ? /* @__PURE__ */ jsx4(
16788
+ trailingSpacerWidth > 0 ? /* @__PURE__ */ jsx6(
16718
16789
  "td",
16719
16790
  {
16720
16791
  "aria-hidden": "true",
@@ -16728,8 +16799,8 @@ function GridRow({
16728
16799
  ) : null
16729
16800
  ] });
16730
16801
  }
16731
- var MemoGridRow = React6.memo(GridRow, (prev, next) => {
16732
- 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) {
16802
+ var MemoGridRow = React9.memo(GridRow, (prev, next) => {
16803
+ 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) {
16733
16804
  return false;
16734
16805
  }
16735
16806
  const prevEditingCol = prev.editingCell?.row === prev.actualRow ? prev.editingCell.col : -1;
@@ -16748,16 +16819,16 @@ function XlsxViewerProviderWithInlineController({
16748
16819
  ...options
16749
16820
  }) {
16750
16821
  const controller = useXlsxViewerController(options);
16751
- return /* @__PURE__ */ jsx4(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx4(ViewerContext.Provider, { value: controller, children }) });
16822
+ return /* @__PURE__ */ jsx6(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx6(ViewerContext.Provider, { value: controller, children }) });
16752
16823
  }
16753
16824
  function XlsxViewerProvider({ children, controller, isDark = false, ...options }) {
16754
16825
  if (controller) {
16755
- return /* @__PURE__ */ jsx4(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx4(ViewerContext.Provider, { value: controller, children }) });
16826
+ return /* @__PURE__ */ jsx6(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx6(ViewerContext.Provider, { value: controller, children }) });
16756
16827
  }
16757
- return /* @__PURE__ */ jsx4(XlsxViewerProviderWithInlineController, { ...options, isDark, children });
16828
+ return /* @__PURE__ */ jsx6(XlsxViewerProviderWithInlineController, { ...options, isDark, children });
16758
16829
  }
16759
16830
  function useXlsxViewer() {
16760
- const context = React6.useContext(ViewerContext);
16831
+ const context = React9.useContext(ViewerContext);
16761
16832
  if (!context) {
16762
16833
  throw new Error("useXlsxViewer must be used inside XlsxViewer or XlsxViewerProvider.");
16763
16834
  }
@@ -16773,7 +16844,7 @@ function useXlsxViewerSelection() {
16773
16844
  selectRange,
16774
16845
  selection
16775
16846
  } = useXlsxViewer();
16776
- return React6.useMemo(
16847
+ return React9.useMemo(
16777
16848
  () => ({
16778
16849
  activeCell,
16779
16850
  activeCellAddress,
@@ -16799,7 +16870,7 @@ function useXlsxViewerZoom() {
16799
16870
  zoomOut,
16800
16871
  zoomScale
16801
16872
  } = useXlsxViewer();
16802
- return React6.useMemo(
16873
+ return React9.useMemo(
16803
16874
  () => ({
16804
16875
  canZoomIn,
16805
16876
  canZoomOut,
@@ -16857,6 +16928,7 @@ function useXlsxViewerEditing() {
16857
16928
  selectedValue,
16858
16929
  setCellFormula,
16859
16930
  setCellStyle,
16931
+ setCellStyles,
16860
16932
  setCellValue,
16861
16933
  setRangeStyle,
16862
16934
  setSelectedFormula,
@@ -16867,7 +16939,7 @@ function useXlsxViewerEditing() {
16867
16939
  unmergeSelection,
16868
16940
  updateFormControl
16869
16941
  } = useXlsxViewer();
16870
- return React6.useMemo(
16942
+ return React9.useMemo(
16871
16943
  () => ({
16872
16944
  addFormControl,
16873
16945
  addSheet,
@@ -16898,6 +16970,7 @@ function useXlsxViewerEditing() {
16898
16970
  selectedValue,
16899
16971
  setCellFormula,
16900
16972
  setCellStyle,
16973
+ setCellStyles,
16901
16974
  setCellValue,
16902
16975
  setRangeStyle,
16903
16976
  setSelectedFormula,
@@ -16938,6 +17011,7 @@ function useXlsxViewerEditing() {
16938
17011
  selectedValue,
16939
17012
  setCellFormula,
16940
17013
  setCellStyle,
17014
+ setCellStyles,
16941
17015
  setCellValue,
16942
17016
  setRangeStyle,
16943
17017
  setSelectedFormula,
@@ -16952,7 +17026,7 @@ function useXlsxViewerEditing() {
16952
17026
  }
16953
17027
  function useXlsxViewerTables() {
16954
17028
  const { sortState, sortTable, tables } = useXlsxViewer();
16955
- return React6.useMemo(
17029
+ return React9.useMemo(
16956
17030
  () => ({
16957
17031
  sortState,
16958
17032
  sortTable,
@@ -16993,7 +17067,7 @@ function useXlsxViewerImages() {
16993
17067
  setImageRect,
16994
17068
  updateChart
16995
17069
  } = useXlsxViewer();
16996
- return React6.useMemo(
17070
+ return React9.useMemo(
16997
17071
  () => ({
16998
17072
  charts,
16999
17073
  clearSelectedChart,
@@ -17086,7 +17160,7 @@ function useXlsxViewerCharts() {
17086
17160
  tabs,
17087
17161
  updateChart
17088
17162
  } = useXlsxViewer();
17089
- return React6.useMemo(
17163
+ return React9.useMemo(
17090
17164
  () => ({
17091
17165
  activeTab,
17092
17166
  activeTabIndex,
@@ -17153,30 +17227,30 @@ function useXlsxViewerThumbnails(options = {}) {
17153
17227
  workbook,
17154
17228
  sheets
17155
17229
  } = useXlsxViewer();
17156
- const { headerBackgroundColor, headerTextColor, isDark } = React6.useContext(ViewerAppearanceContext);
17230
+ const { headerBackgroundColor, headerTextColor, isDark } = React9.useContext(ViewerAppearanceContext);
17157
17231
  const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
17158
17232
  const includeHeaders = options.includeHeaders ?? true;
17159
17233
  const resolution = options.resolution;
17160
- const thumbnailImageCacheRef = React6.useRef(/* @__PURE__ */ new Map());
17161
- const workerThumbnailRowBatchCacheRef = React6.useRef(/* @__PURE__ */ new Map());
17162
- const workerThumbnailRowBatchRequestRef = React6.useRef(
17234
+ const thumbnailImageCacheRef = React9.useRef(/* @__PURE__ */ new Map());
17235
+ const workerThumbnailRowBatchCacheRef = React9.useRef(/* @__PURE__ */ new Map());
17236
+ const workerThumbnailRowBatchRequestRef = React9.useRef(
17163
17237
  /* @__PURE__ */ new Map()
17164
17238
  );
17165
- const isMountedRef = React6.useRef(false);
17166
- const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] = React6.useState(0);
17167
- const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] = React6.useState(0);
17168
- React6.useEffect(() => {
17239
+ const isMountedRef = React9.useRef(false);
17240
+ const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] = React9.useState(0);
17241
+ const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] = React9.useState(0);
17242
+ React9.useEffect(() => {
17169
17243
  isMountedRef.current = true;
17170
17244
  return () => {
17171
17245
  isMountedRef.current = false;
17172
17246
  };
17173
17247
  }, []);
17174
- React6.useEffect(() => {
17248
+ React9.useEffect(() => {
17175
17249
  workerThumbnailRowBatchCacheRef.current.clear();
17176
17250
  workerThumbnailRowBatchRequestRef.current.clear();
17177
17251
  setWorkerThumbnailRowBatchVersion((version) => version + 1);
17178
17252
  }, [locale]);
17179
- React6.useEffect(() => {
17253
+ React9.useEffect(() => {
17180
17254
  const currentSheets = new Set(sheets);
17181
17255
  for (const sheet of workerThumbnailRowBatchCacheRef.current.keys()) {
17182
17256
  if (!currentSheets.has(sheet)) {
@@ -17189,7 +17263,7 @@ function useXlsxViewerThumbnails(options = {}) {
17189
17263
  }
17190
17264
  }
17191
17265
  }, [sheets]);
17192
- const getWorkerThumbnailRowBatch = React6.useCallback((sheet, startRow, endRow) => {
17266
+ const getWorkerThumbnailRowBatch = React9.useCallback((sheet, startRow, endRow) => {
17193
17267
  const cachedBatch = workerThumbnailRowBatchCacheRef.current.get(sheet);
17194
17268
  if (cachedBatch && startRow >= cachedBatch.startRow && endRow <= cachedBatch.endRow) {
17195
17269
  return cachedBatch;
@@ -17231,7 +17305,7 @@ function useXlsxViewerThumbnails(options = {}) {
17231
17305
  }
17232
17306
  return null;
17233
17307
  }, [getRowsBatchAsync]);
17234
- const getThumbnailImage = React6.useCallback((image) => {
17308
+ const getThumbnailImage = React9.useCallback((image) => {
17235
17309
  if (typeof Image === "undefined") {
17236
17310
  return null;
17237
17311
  }
@@ -17263,7 +17337,7 @@ function useXlsxViewerThumbnails(options = {}) {
17263
17337
  imageElement.src = image.src;
17264
17338
  return null;
17265
17339
  }, []);
17266
- const thumbnails = React6.useMemo(() => {
17340
+ const thumbnails = React9.useMemo(() => {
17267
17341
  return sheets.map((sheet, sheetIndex) => {
17268
17342
  const worksheet = workbook?.getSheet(sheet.workbookSheetIndex) ?? null;
17269
17343
  const sheetImages = getSheetImages(sheetIndex).filter((image) => image.src).sort((left, right) => left.zIndex - right.zIndex);
@@ -17837,11 +17911,11 @@ function useXlsxViewerThumbnails(options = {}) {
17837
17911
  locale,
17838
17912
  workbook
17839
17913
  ]);
17840
- const paintThumbnail = React6.useCallback(
17914
+ const paintThumbnail = React9.useCallback(
17841
17915
  (sheetIndex, canvas) => thumbnails[sheetIndex]?.paint(canvas) ?? false,
17842
17916
  [thumbnails]
17843
17917
  );
17844
- return React6.useMemo(
17918
+ return React9.useMemo(
17845
17919
  () => ({
17846
17920
  paintThumbnail,
17847
17921
  thumbnails
@@ -17851,13 +17925,13 @@ function useXlsxViewerThumbnails(options = {}) {
17851
17925
  }
17852
17926
  function DefaultXlsxToolbar() {
17853
17927
  const controller = useXlsxViewer();
17854
- const { headerBackgroundColor, headerTextColor, isDark } = React6.useContext(ViewerAppearanceContext);
17928
+ const { headerBackgroundColor, headerTextColor, isDark } = React9.useContext(ViewerAppearanceContext);
17855
17929
  const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
17856
- return /* @__PURE__ */ jsx4(DefaultToolbar, { controller, palette });
17930
+ return /* @__PURE__ */ jsx6(DefaultToolbar, { controller, palette });
17857
17931
  }
17858
17932
 
17859
17933
  // src/react-viewer.tsx
17860
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
17934
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
17861
17935
  var SlotStore = class {
17862
17936
  slots = /* @__PURE__ */ new Map();
17863
17937
  listeners = /* @__PURE__ */ new Set();
@@ -17893,7 +17967,7 @@ var SlotStore = class {
17893
17967
  return __createContentNode(slot.host);
17894
17968
  }
17895
17969
  portals() {
17896
- return Array.from(this.slots, ([key, slot]) => createPortal2(slot.node, slot.host, key));
17970
+ return Array.from(this.slots, ([key, slot]) => createPortal4(slot.node, slot.host, key));
17897
17971
  }
17898
17972
  destroy() {
17899
17973
  this.destroyed = true;
@@ -17926,9 +18000,9 @@ var SlotStore = class {
17926
18000
  }
17927
18001
  };
17928
18002
  function RuntimeContent({ content }) {
17929
- const hostRef = React7.useRef(null);
17930
- const rootRef = React7.useRef(null);
17931
- React7.useLayoutEffect(() => {
18003
+ const hostRef = React10.useRef(null);
18004
+ const rootRef = React10.useRef(null);
18005
+ React10.useLayoutEffect(() => {
17932
18006
  const host = hostRef.current;
17933
18007
  if (!host) return;
17934
18008
  const root = __createContentRoot(host);
@@ -17938,14 +18012,14 @@ function RuntimeContent({ content }) {
17938
18012
  root.destroy();
17939
18013
  };
17940
18014
  }, []);
17941
- React7.useLayoutEffect(() => {
18015
+ React10.useLayoutEffect(() => {
17942
18016
  rootRef.current?.update(content);
17943
18017
  }, [content]);
17944
- return /* @__PURE__ */ jsx5("span", { ref: hostRef, style: { display: "contents" } });
18018
+ return /* @__PURE__ */ jsx7("span", { ref: hostRef, style: { display: "contents" } });
17945
18019
  }
17946
18020
  function renderOptions(props, controller, slots, owner) {
17947
18021
  const slot = (key, node) => slots.render(key, node, owner);
17948
- const runtime = (node) => /* @__PURE__ */ jsx5(RuntimeContent, { content: node });
18022
+ const runtime = (node) => /* @__PURE__ */ jsx7(RuntimeContent, { content: node });
17949
18023
  const {
17950
18024
  emptyState,
17951
18025
  errorState,
@@ -17953,6 +18027,8 @@ function renderOptions(props, controller, slots, owner) {
17953
18027
  loadingComponent,
17954
18028
  loadingState,
17955
18029
  renderActiveCellOverlay,
18030
+ renderCellEditorOverlay,
18031
+ renderSelectionPopover,
17956
18032
  renderChartLoading,
17957
18033
  renderContextMenu,
17958
18034
  renderFormControl,
@@ -17973,6 +18049,14 @@ function renderOptions(props, controller, slots, owner) {
17973
18049
  fileTooLargeState: fileTooLargeState === void 0 ? void 0 : typeof fileTooLargeState === "function" ? ({ defaultNode, ...rest }) => slot("too-large", fileTooLargeState({ ...rest, defaultNode: runtime(defaultNode) })) : slot("too-large", fileTooLargeState),
17974
18050
  toolbar: toolbar === void 0 ? void 0 : typeof toolbar === "function" ? (current) => slot("toolbar", toolbar(current)) : slot("toolbar", toolbar),
17975
18051
  renderActiveCellOverlay: renderActiveCellOverlay ? (value) => slot(`active:${value.cell.row}:${value.cell.col}`, renderActiveCellOverlay(value)) : void 0,
18052
+ renderSelectionPopover: renderSelectionPopover ? (value) => {
18053
+ const content = renderSelectionPopover(value);
18054
+ return content == null || content === false ? null : slot("selection-popover", content);
18055
+ } : void 0,
18056
+ renderCellEditorOverlay: renderCellEditorOverlay ? (value) => {
18057
+ const content = renderCellEditorOverlay(value);
18058
+ return content == null || content === false ? null : slot("cell-editor-overlay", content);
18059
+ } : void 0,
17976
18060
  renderChartLoading: renderChartLoading ? ({ defaultNode, ...value }) => slot(`chart:${value.chart.id}`, renderChartLoading({ ...value, defaultNode: runtime(defaultNode) })) : void 0,
17977
18061
  renderContextMenu: renderContextMenu ? ({ defaultNode, ...value }) => slot("context-menu", renderContextMenu({ ...value, defaultNode: runtime(defaultNode) })) : void 0,
17978
18062
  renderFormControl: renderFormControl ? (value) => slot(`control:${value.control.id}`, renderFormControl(value)) : void 0,
@@ -17982,12 +18066,14 @@ function renderOptions(props, controller, slots, owner) {
17982
18066
  renderTableHeaderMenu: renderTableHeaderMenu ? (value) => slot(`table:${value.table.name}:${value.cell.row}:${value.cell.col}`, renderTableHeaderMenu(value)) : void 0
17983
18067
  };
17984
18068
  }
17985
- function BoundViewer({ props, controller }) {
17986
- const hostRef = React7.useRef(null);
17987
- const viewerRef = React7.useRef(null);
17988
- const slots = React7.useMemo(() => new SlotStore(), []);
17989
- React7.useSyncExternalStore(slots.subscribe, slots.getSnapshot, slots.getServerSnapshot);
17990
- React7.useLayoutEffect(() => {
18069
+ function BoundViewer({ props, controller: sourceController }) {
18070
+ const messages = React10.useMemo(() => mergeMessages(sourceController.messages, props.messages), [sourceController.messages, props.messages]);
18071
+ const controller = React10.useMemo(() => ({ ...sourceController, messages }), [sourceController, messages]);
18072
+ const hostRef = React10.useRef(null);
18073
+ const viewerRef = React10.useRef(null);
18074
+ const slots = React10.useMemo(() => new SlotStore(), []);
18075
+ React10.useSyncExternalStore(slots.subscribe, slots.getSnapshot, slots.getServerSnapshot);
18076
+ React10.useLayoutEffect(() => {
17991
18077
  const host = hostRef.current;
17992
18078
  if (!host) return;
17993
18079
  slots.observe(host);
@@ -17999,27 +18085,27 @@ function BoundViewer({ props, controller }) {
17999
18085
  slots.destroy();
18000
18086
  };
18001
18087
  }, [slots]);
18002
- React7.useLayoutEffect(() => {
18088
+ React10.useLayoutEffect(() => {
18003
18089
  const host = hostRef.current;
18004
18090
  if (host) viewerRef.current?.update(renderOptions(props, controller, slots, host.ownerDocument));
18005
18091
  }, [controller, props, slots]);
18006
- return /* @__PURE__ */ jsx5(ViewerAppearanceContext.Provider, { value: {
18092
+ return /* @__PURE__ */ jsx7(ViewerAppearanceContext.Provider, { value: {
18007
18093
  headerBackgroundColor: props.headerBackgroundColor,
18008
18094
  headerTextColor: props.headerTextColor,
18009
18095
  isDark: props.isDark ?? false
18010
18096
  }, children: /* @__PURE__ */ jsxs4(ViewerContext.Provider, { value: controller, children: [
18011
- /* @__PURE__ */ jsx5("div", { ref: hostRef, style: { display: "contents" } }),
18097
+ /* @__PURE__ */ jsx7("div", { ref: hostRef, style: { display: "contents" } }),
18012
18098
  slots.portals()
18013
18099
  ] }) });
18014
18100
  }
18015
18101
  function UncontrolledViewer(props) {
18016
18102
  const controller = useXlsxViewerController(props);
18017
- return /* @__PURE__ */ jsx5(BoundViewer, { props, controller });
18103
+ return /* @__PURE__ */ jsx7(BoundViewer, { props, controller });
18018
18104
  }
18019
18105
  function XlsxViewer(props) {
18020
- const context = React7.useContext(ViewerContext);
18106
+ const context = React10.useContext(ViewerContext);
18021
18107
  const controller = props.controller ?? context;
18022
- return controller ? /* @__PURE__ */ jsx5(BoundViewer, { props, controller }) : /* @__PURE__ */ jsx5(UncontrolledViewer, { ...props });
18108
+ return controller ? /* @__PURE__ */ jsx7(BoundViewer, { props, controller }) : /* @__PURE__ */ jsx7(UncontrolledViewer, { ...props });
18023
18109
  }
18024
18110
  export {
18025
18111
  DefaultXlsxToolbar,