@extend-ai/react-xlsx 0.23.2 → 0.24.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 (80) hide show
  1. package/README.md +17 -1
  2. package/dist/{chunk-UICWNF5V.js → chunk-2TLD35UF.js} +3 -27
  3. package/dist/chunk-2TLD35UF.js.map +1 -0
  4. package/dist/{chunk-M7QVMFYT.js → chunk-C4WTJIRG.js} +709 -487
  5. package/dist/chunk-C4WTJIRG.js.map +1 -0
  6. package/dist/{chunk-FGJY2TIS.cjs → chunk-DGNSB5M5.cjs} +2563 -2341
  7. package/dist/chunk-DGNSB5M5.cjs.map +1 -0
  8. package/dist/{chunk-A3WA6ZLI.cjs → chunk-GP5SOQQH.cjs} +3 -29
  9. package/dist/chunk-GP5SOQQH.cjs.map +1 -0
  10. package/dist/{chunk-MEZOJBL5.js → chunk-HAV76TR2.js} +57 -1
  11. package/dist/{chunk-MEZOJBL5.js.map → chunk-HAV76TR2.js.map} +1 -1
  12. package/dist/{chunk-JJJZYWAL.js → chunk-MNIFKMIL.js} +57 -1
  13. package/dist/chunk-MNIFKMIL.js.map +1 -0
  14. package/dist/{chunk-3JFYU42O.js → chunk-Q6YY3AB4.js} +2 -28
  15. package/dist/chunk-Q6YY3AB4.js.map +1 -0
  16. package/dist/{chunk-JCSAS3M2.cjs → chunk-XZJLPW64.cjs} +2 -26
  17. package/dist/chunk-XZJLPW64.cjs.map +1 -0
  18. package/dist/{chunk-TMYAG7GY.cjs → chunk-YOLIVKZD.cjs} +57 -1
  19. package/dist/chunk-YOLIVKZD.cjs.map +1 -0
  20. package/dist/{chunk-R3FQM7V3.cjs → chunk-Z4WMURVU.cjs} +57 -1
  21. package/dist/chunk-Z4WMURVU.cjs.map +1 -0
  22. package/dist/duke-sheets-provenance.json +5 -5
  23. package/dist/{duke_sheets_wasm-TLSZAVKP.cjs → duke_sheets_wasm-GM4K5QQX.cjs} +57 -1
  24. package/dist/duke_sheets_wasm-GM4K5QQX.cjs.map +1 -0
  25. package/dist/{duke_sheets_wasm-V4J6QYIZ.js → duke_sheets_wasm-MYY4ZNUI.js} +57 -1
  26. package/dist/duke_sheets_wasm-MYY4ZNUI.js.map +1 -0
  27. package/dist/{duke_sheets_wasm-R7KXJNYL.js → duke_sheets_wasm-UXZ2KTVD.js} +57 -1
  28. package/dist/duke_sheets_wasm-UXZ2KTVD.js.map +1 -0
  29. package/dist/duke_sheets_wasm_bg.wasm +0 -0
  30. package/dist/index.cjs +695 -606
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +45 -7
  33. package/dist/index.d.ts +45 -7
  34. package/dist/index.js +674 -585
  35. package/dist/index.js.map +1 -1
  36. package/dist/{internal-BVZRgYaH.d.ts → internal-CwTqluL7.d.cts} +106 -64
  37. package/dist/{internal-BVZRgYaH.d.cts → internal-CwTqluL7.d.ts} +106 -64
  38. package/dist/internal.cjs +4 -4
  39. package/dist/internal.d.cts +1 -1
  40. package/dist/internal.d.ts +1 -1
  41. package/dist/internal.js +3 -3
  42. package/dist/{shared-chart-V24MOVXX.js → shared-chart-24MCGSFJ.js} +2 -2
  43. package/dist/{shared-chart-N44DT2QV.cjs → shared-chart-7E6KMGTG.cjs} +3 -3
  44. package/dist/{shared-chart-N44DT2QV.cjs.map → shared-chart-7E6KMGTG.cjs.map} +1 -1
  45. package/dist/{shared-chart-64L5EL3Z.js → shared-chart-CGEK7EAB.js} +2 -2
  46. package/dist/{shared-chart-BZTEPO7C.cjs → shared-chart-GKNMM72Q.cjs} +15 -15
  47. package/dist/{shared-chart-BZTEPO7C.cjs.map → shared-chart-GKNMM72Q.cjs.map} +1 -1
  48. package/dist/vanilla.cjs +4 -4
  49. package/dist/vanilla.d.cts +2 -2
  50. package/dist/vanilla.d.ts +2 -2
  51. package/dist/vanilla.js +3 -3
  52. package/dist/{workbook-runtime-O3QY5UED.js → workbook-runtime-56Y3B64Y.js} +8 -12
  53. package/dist/workbook-runtime-56Y3B64Y.js.map +1 -0
  54. package/dist/{workbook-runtime-FXUSOOFT.js → workbook-runtime-7DSKESFL.js} +8 -12
  55. package/dist/workbook-runtime-7DSKESFL.js.map +1 -0
  56. package/dist/{workbook-runtime-2HYFRGZD.cjs → workbook-runtime-MEI3CEWO.cjs} +64 -68
  57. package/dist/workbook-runtime-MEI3CEWO.cjs.map +1 -0
  58. package/dist/{workbook-runtime-OJDBGHMM.cjs → workbook-runtime-QFXDLSSI.cjs} +66 -70
  59. package/dist/workbook-runtime-QFXDLSSI.cjs.map +1 -0
  60. package/dist/xlsx-worker.js +7 -11
  61. package/dist/xlsx-worker.js.map +1 -1
  62. package/package.json +2 -2
  63. package/dist/chunk-3JFYU42O.js.map +0 -1
  64. package/dist/chunk-A3WA6ZLI.cjs.map +0 -1
  65. package/dist/chunk-FGJY2TIS.cjs.map +0 -1
  66. package/dist/chunk-JCSAS3M2.cjs.map +0 -1
  67. package/dist/chunk-JJJZYWAL.js.map +0 -1
  68. package/dist/chunk-M7QVMFYT.js.map +0 -1
  69. package/dist/chunk-R3FQM7V3.cjs.map +0 -1
  70. package/dist/chunk-TMYAG7GY.cjs.map +0 -1
  71. package/dist/chunk-UICWNF5V.js.map +0 -1
  72. package/dist/duke_sheets_wasm-R7KXJNYL.js.map +0 -1
  73. package/dist/duke_sheets_wasm-TLSZAVKP.cjs.map +0 -1
  74. package/dist/duke_sheets_wasm-V4J6QYIZ.js.map +0 -1
  75. package/dist/workbook-runtime-2HYFRGZD.cjs.map +0 -1
  76. package/dist/workbook-runtime-FXUSOOFT.js.map +0 -1
  77. package/dist/workbook-runtime-O3QY5UED.js.map +0 -1
  78. package/dist/workbook-runtime-OJDBGHMM.cjs.map +0 -1
  79. /package/dist/{shared-chart-V24MOVXX.js.map → shared-chart-24MCGSFJ.js.map} +0 -0
  80. /package/dist/{shared-chart-64L5EL3Z.js.map → shared-chart-CGEK7EAB.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import {
2
+ XLSX_MAX_COLUMNS,
3
+ XLSX_MAX_ROWS,
2
4
  applyChartSeriesFormula,
3
5
  buildChartSeriesFormula,
4
6
  emuToPixels,
@@ -25,8 +27,6 @@ import {
25
27
  resolveWorkbookFillStyle,
26
28
  resolveWorksheetDefaultColumnWidthPixels,
27
29
  resolveWorksheetDefaultRowHeightPixels,
28
- resolveWorksheetHiddenCols,
29
- resolveWorksheetHiddenRows,
30
30
  resolveWorksheetMergeMetadata,
31
31
  restoreWorkerImageBlobs,
32
32
  revokeWorkbookImageAssets,
@@ -36,13 +36,13 @@ import {
36
36
  updateWorkbookChartDefinition,
37
37
  updateWorkbookImageAnchor,
38
38
  xlsxAnchorToDukeDrawingAnchor
39
- } from "./chunk-UICWNF5V.js";
39
+ } from "./chunk-2TLD35UF.js";
40
40
  import {
41
41
  formatMessage,
42
42
  mergeMessages,
43
43
  resolveMessages,
44
44
  useXlsxMessages
45
- } from "./chunk-JJJZYWAL.js";
45
+ } from "./chunk-MNIFKMIL.js";
46
46
  import "./chunk-QXXS4J36.js";
47
47
  import {
48
48
  configureWorkbookArchiveDecoder,
@@ -52,6 +52,47 @@ import {
52
52
  serializeWorkbookXml
53
53
  } from "./chunk-67TEHWH5.js";
54
54
 
55
+ // src/selection-ranges.ts
56
+ function resolveFreezePanesCell(activeCell, selection) {
57
+ if (activeCell && selection && (activeCell.row < selection.start.row || activeCell.col < selection.start.col)) {
58
+ return selection.start;
59
+ }
60
+ return activeCell;
61
+ }
62
+ function subtractRange(area, cut) {
63
+ const top = Math.max(area.start.row, cut.start.row);
64
+ const bottom = Math.min(area.end.row, cut.end.row);
65
+ const left = Math.max(area.start.col, cut.start.col);
66
+ const right = Math.min(area.end.col, cut.end.col);
67
+ if (top > bottom || left > right) return [area];
68
+ const remaining = [];
69
+ if (area.start.row < top) remaining.push({ start: area.start, end: { row: top - 1, col: area.end.col } });
70
+ if (bottom < area.end.row) remaining.push({ start: { row: bottom + 1, col: area.start.col }, end: area.end });
71
+ if (area.start.col < left) remaining.push({ start: { row: top, col: area.start.col }, end: { row: bottom, col: left - 1 } });
72
+ if (right < area.end.col) remaining.push({ start: { row: top, col: right + 1 }, end: { row: bottom, col: area.end.col } });
73
+ return remaining;
74
+ }
75
+ function addSelectionRange(areas, range) {
76
+ return [...areas.flatMap((area) => subtractRange(area, range)), range];
77
+ }
78
+ function clipboardBands(areas) {
79
+ const first = areas[0];
80
+ if (!first) return null;
81
+ const sameExtent = (axis) => areas.every((area) => area.start[axis] === first.start[axis] && area.end[axis] === first.end[axis]);
82
+ const bands = (axis, ranges) => ranges.map((range) => ({ start: range.start[axis], end: range.end[axis] })).sort((a, b) => a.start - b.start);
83
+ if (sameExtent("col")) return { rows: bands("row", areas), cols: bands("col", [first]) };
84
+ if (sameExtent("row")) return { rows: bands("row", [first]), cols: bands("col", areas) };
85
+ return null;
86
+ }
87
+ function* bandIndices(bands) {
88
+ let offset = 0;
89
+ for (const band of bands) {
90
+ for (let index = band.start; index <= band.end; index++) {
91
+ yield { index, offset: offset++, remaining: band.end - index + 1 };
92
+ }
93
+ }
94
+ }
95
+
55
96
  // src/merged-range-lookup.ts
56
97
  function createMergedRangeLookup(ranges) {
57
98
  const normalizedRanges = [];
@@ -921,7 +962,7 @@ var XlsxWorkerClient = class {
921
962
  }
922
963
  async getMainRuntime() {
923
964
  if (this.disposed) throw createAbortError();
924
- this.mainRuntime ??= import("./workbook-runtime-O3QY5UED.js").then(({ createWorkbookRuntime }) => createWorkbookRuntime());
965
+ this.mainRuntime ??= import("./workbook-runtime-56Y3B64Y.js").then(({ createWorkbookRuntime }) => createWorkbookRuntime());
925
966
  const runtime = await this.mainRuntime;
926
967
  if (this.disposed) {
927
968
  runtime.dispose();
@@ -1150,8 +1191,8 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
1150
1191
  maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
1151
1192
  maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
1152
1193
  mergedRanges: mergeMetadata.mergedRanges,
1153
- hiddenCols: [],
1154
- hiddenRows: [],
1194
+ hiddenCols: Array.from(worksheet.hiddenColumns),
1195
+ hiddenRows: Array.from(worksheet.hiddenRows),
1155
1196
  minUsedCol: -1,
1156
1197
  minUsedRow: -1,
1157
1198
  maxUsedCol: -1,
@@ -1240,8 +1281,8 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
1240
1281
  maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
1241
1282
  maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
1242
1283
  mergedRanges: mergeMetadata.mergedRanges,
1243
- hiddenCols: resolveWorksheetHiddenCols(worksheet, maxCol),
1244
- hiddenRows: resolveWorksheetHiddenRows(worksheet, maxRow),
1284
+ hiddenCols: Array.from(worksheet.hiddenColumns),
1285
+ hiddenRows: Array.from(worksheet.hiddenRows),
1245
1286
  minUsedCol: minCol,
1246
1287
  minUsedRow: minRow,
1247
1288
  maxUsedCol: maxCol,
@@ -1935,7 +1976,11 @@ function useXlsxViewerController(options2) {
1935
1976
  const [activeTabIndex, setActiveTabIndexState] = React.useState(0);
1936
1977
  const [zoomScaleOverridesByTabId, setZoomScaleOverridesByTabId] = React.useState({});
1937
1978
  const [activeCell, setActiveCell] = React.useState(null);
1938
- const [selection, setSelection] = React.useState(null);
1979
+ const [selectionRanges, setSelectionRanges] = React.useState([]);
1980
+ const selection = selectionRanges.at(-1) ?? null;
1981
+ const setSelection = React.useCallback((range) => {
1982
+ setSelectionRanges(range ? [range] : []);
1983
+ }, []);
1939
1984
  const [highlightedRanges, setHighlightedRanges] = React.useState([]);
1940
1985
  const [selectedChartId, setSelectedChartId] = React.useState(null);
1941
1986
  const [selectedChartElement, setSelectedChartElement] = React.useState(null);
@@ -2696,23 +2741,20 @@ function useXlsxViewerController(options2) {
2696
2741
  }, [activeSheet, getActiveWorksheet, locale]);
2697
2742
  const getClipboardData = React.useCallback(() => {
2698
2743
  const worksheet = getActiveWorksheet();
2699
- const targetRange = selection ?? (activeCell ? { start: activeCell, end: activeCell } : null);
2700
- if (!worksheet || !targetRange) {
2701
- return null;
2702
- }
2703
- const normalized = normalizeRange(targetRange);
2744
+ const bands = clipboardBands(selectionRanges);
2745
+ if (!worksheet || !bands) return null;
2704
2746
  const rows = [];
2705
2747
  const htmlRows = [];
2706
2748
  const payload = {
2707
2749
  cells: [],
2708
- cols: normalized.end.col - normalized.start.col + 1,
2750
+ cols: bands.cols.reduce((total, band) => total + band.end - band.start + 1, 0),
2709
2751
  merges: [],
2710
- rows: normalized.end.row - normalized.start.row + 1
2752
+ rows: bands.rows.reduce((total, band) => total + band.end - band.start + 1, 0)
2711
2753
  };
2712
- for (let row2 = normalized.start.row; row2 <= normalized.end.row; row2 += 1) {
2754
+ for (const { index: row2, offset: rowOffset, remaining: rowsRemaining } of bandIndices(bands.rows)) {
2713
2755
  const textCells = [];
2714
2756
  const htmlCells = [];
2715
- for (let col = normalized.start.col; col <= normalized.end.col; col += 1) {
2757
+ for (const { index: col, offset: colOffset, remaining: colsRemaining } of bandIndices(bands.cols)) {
2716
2758
  if (worksheet.isMergedSecondary(row2, col)) {
2717
2759
  textCells.push("");
2718
2760
  continue;
@@ -2779,19 +2821,19 @@ function useXlsxViewerController(options2) {
2779
2821
  if (border?.left?.style && border.left.style !== "none") {
2780
2822
  cellStyles.push(`border-left:${mapBorder(border.left)}`);
2781
2823
  }
2782
- const rowSpan = Math.min(merge?.rowSpan ?? 1, normalized.end.row - row2 + 1);
2783
- const colSpan = Math.min(merge?.colSpan ?? 1, normalized.end.col - col + 1);
2824
+ const rowSpan = Math.min(merge?.rowSpan ?? 1, rowsRemaining);
2825
+ const colSpan = Math.min(merge?.colSpan ?? 1, colsRemaining);
2784
2826
  payload.cells.push({
2785
- colOffset: col - normalized.start.col,
2827
+ colOffset,
2786
2828
  formula,
2787
- rowOffset: row2 - normalized.start.row,
2829
+ rowOffset,
2788
2830
  value
2789
2831
  });
2790
2832
  if (rowSpan > 1 || colSpan > 1) {
2791
2833
  payload.merges.push({
2792
- colOffset: col - normalized.start.col,
2834
+ colOffset,
2793
2835
  colSpan,
2794
- rowOffset: row2 - normalized.start.row,
2836
+ rowOffset,
2795
2837
  rowSpan
2796
2838
  });
2797
2839
  }
@@ -2808,7 +2850,7 @@ function useXlsxViewerController(options2) {
2808
2850
  structured: JSON.stringify(payload),
2809
2851
  text: rows.join("\n")
2810
2852
  };
2811
- }, [activeCell, getActiveWorksheet, getCellDisplayValue2, selection]);
2853
+ }, [activeSheet, getActiveWorksheet, getCellDisplayValue2, selectionRanges]);
2812
2854
  React.useEffect(() => {
2813
2855
  if (!isWorkerBacked || !deferredMetadataSheet || !deferredMetadataCell) {
2814
2856
  return;
@@ -2839,7 +2881,7 @@ function useXlsxViewerController(options2) {
2839
2881
  };
2840
2882
  }, [deferredMetadataCell, deferredMetadataSheet, getCellSnapshotAsync, isWorkerBacked, locale]);
2841
2883
  const activeCellAddress = React.useMemo(() => activeCell ? cellAddressToA1(activeCell) : null, [activeCell]);
2842
- const selectedRangeAddress = React.useMemo(() => selection ? rangeToA1(selection) : null, [selection]);
2884
+ const selectedRangeAddress = React.useMemo(() => selectionRanges.map(rangeToA1).join(",") || null, [selectionRanges]);
2843
2885
  const selectedValue = React.useMemo(
2844
2886
  () => getCellDisplayValue2(deferredMetadataCell),
2845
2887
  [deferredMetadataCell, getCellDisplayValue2, revision, workerCellSnapshotRevision]
@@ -2889,10 +2931,10 @@ function useXlsxViewerController(options2) {
2889
2931
  bytes: workbook.exportSnapshot(),
2890
2932
  assets: imageAssetsRef.current ? structuredClone(imageAssetsRef.current) : null,
2891
2933
  origins: structuredClone(sheetOriginsRef.current),
2892
- selection,
2934
+ selectionRanges,
2893
2935
  sortState
2894
2936
  };
2895
- }, [activeCell, activeSheetIndex, selection, sortState, workbook]);
2937
+ }, [activeCell, activeSheetIndex, selectionRanges, sortState, workbook]);
2896
2938
  const captureCellMutationState = React.useCallback((cell) => {
2897
2939
  const worksheet = getActiveWorksheet();
2898
2940
  if (!worksheet) {
@@ -2934,9 +2976,9 @@ function useXlsxViewerController(options2) {
2934
2976
  setActiveTabIndexState(nextTabIndex);
2935
2977
  }
2936
2978
  setActiveCell(entry.activeCell);
2937
- setSelection(entry.selection);
2979
+ setSelectionRanges(entry.selectionRanges);
2938
2980
  setSortState(entry.sortState);
2939
- selectionAnchorRef.current = entry.selection ? normalizeRange(entry.selection).start : entry.activeCell;
2981
+ selectionAnchorRef.current = entry.selectionRanges.at(-1)?.start ?? entry.activeCell;
2940
2982
  setRevision((current) => current + 1);
2941
2983
  }, [setChartAssets, setImageAssets]);
2942
2984
  const applyCellEditHistoryEntry = React.useCallback((entry, direction) => {
@@ -2956,8 +2998,8 @@ function useXlsxViewerController(options2) {
2956
2998
  setActiveSheetIndexState(visibleSheetIndex);
2957
2999
  }
2958
3000
  setActiveCell(nextActiveCell);
2959
- setSelection(nextSelection);
2960
- selectionAnchorRef.current = nextSelection ? normalizeRange(nextSelection).start : nextActiveCell;
3001
+ setSelectionRanges(nextSelection);
3002
+ selectionAnchorRef.current = nextSelection.at(-1)?.start ?? nextActiveCell;
2961
3003
  isApplyingHistoryRef.current = false;
2962
3004
  }, [maybeRecalculateWorkbook, refreshWorkbookState, sheets, workbook]);
2963
3005
  const applyRangeEditHistoryEntry = React.useCallback((entry, direction) => {
@@ -2979,8 +3021,8 @@ function useXlsxViewerController(options2) {
2979
3021
  setActiveSheetIndexState(visibleSheetIndex);
2980
3022
  }
2981
3023
  setActiveCell(nextActiveCell);
2982
- setSelection(nextSelection);
2983
- selectionAnchorRef.current = nextSelection ? normalizeRange(nextSelection).start : nextActiveCell;
3024
+ setSelectionRanges(nextSelection);
3025
+ selectionAnchorRef.current = nextSelection.at(-1)?.start ?? nextActiveCell;
2984
3026
  isApplyingHistoryRef.current = false;
2985
3027
  }, [maybeRecalculateWorkbook, refreshWorkbookState, sheets, workbook]);
2986
3028
  const recordHistoryBeforeMutation = React.useCallback(() => {
@@ -3239,13 +3281,13 @@ function useXlsxViewerController(options2) {
3239
3281
  after,
3240
3282
  before,
3241
3283
  cell,
3242
- selectionAfter: { start: cell, end: cell },
3243
- selectionBefore: selection,
3284
+ selectionAfter: [{ start: cell, end: cell }],
3285
+ selectionBefore: selectionRanges,
3244
3286
  sheetIndex: activeSheet.workbookSheetIndex
3245
3287
  });
3246
3288
  redoStackRef.current = [];
3247
3289
  setHistoryRevision((current) => current + 1);
3248
- }, [activeCell, activeSheet, selection]);
3290
+ }, [activeCell, activeSheet, selectionRanges]);
3249
3291
  const recordRangeEditHistory = React.useCallback((mutations, selectionAfter, activeCellAfter, sortStateAfter = sortState) => {
3250
3292
  if (!activeSheet || isApplyingHistoryRef.current || mutations.length === 0 && sortStateAfter === sortState) {
3251
3293
  return;
@@ -3256,14 +3298,14 @@ function useXlsxViewerController(options2) {
3256
3298
  activeCellBefore: activeCell,
3257
3299
  mutations,
3258
3300
  selectionAfter,
3259
- selectionBefore: selection,
3301
+ selectionBefore: selectionRanges,
3260
3302
  sheetIndex: activeSheet.workbookSheetIndex,
3261
3303
  sortStateAfter,
3262
3304
  sortStateBefore: sortState
3263
3305
  });
3264
3306
  redoStackRef.current = [];
3265
3307
  setHistoryRevision((current) => current + 1);
3266
- }, [activeCell, activeSheet, selection, sortState]);
3308
+ }, [activeCell, activeSheet, selectionRanges, sortState]);
3267
3309
  const sortTable = React.useCallback((tableName, columnIndex, direction) => {
3268
3310
  const worksheet = getActiveWorksheet();
3269
3311
  const targetTable = tables.find((table) => table.name === tableName || table.displayName === tableName);
@@ -3322,7 +3364,7 @@ function useXlsxViewerController(options2) {
3322
3364
  return;
3323
3365
  }
3324
3366
  setSortState(nextSortState);
3325
- recordRangeEditHistory([], selection, activeCell, nextSortState);
3367
+ recordRangeEditHistory([], selectionRanges, activeCell, nextSortState);
3326
3368
  return;
3327
3369
  }
3328
3370
  const mutations = [];
@@ -3351,7 +3393,7 @@ function useXlsxViewerController(options2) {
3351
3393
  maybeRecalculateWorkbook(workbook);
3352
3394
  refreshWorkbookState(workbook);
3353
3395
  setSortState(nextSortState);
3354
- recordRangeEditHistory(mutations, selection, activeCell, nextSortState);
3396
+ recordRangeEditHistory(mutations, selectionRanges, activeCell, nextSortState);
3355
3397
  }, [
3356
3398
  intersectsPivot,
3357
3399
  activeCell,
@@ -3361,7 +3403,7 @@ function useXlsxViewerController(options2) {
3361
3403
  readOnly,
3362
3404
  recordRangeEditHistory,
3363
3405
  refreshWorkbookState,
3364
- selection,
3406
+ selectionRanges,
3365
3407
  sortState,
3366
3408
  tables,
3367
3409
  workbook
@@ -3406,106 +3448,122 @@ function useXlsxViewerController(options2) {
3406
3448
  }
3407
3449
  setShouldAutoCalculate(false);
3408
3450
  }, [refreshWorkbookState, workbook]);
3409
- const applyReadOnlyResizeOverride = React.useCallback((axis, actualIndex, sizePx) => {
3410
- if (!activeSheet) {
3411
- return;
3412
- }
3451
+ const applyReadOnlyResizeOverride = React.useCallback((axis, indices, sizePx) => {
3452
+ if (!activeSheet) return;
3413
3453
  const contentSizePx = activeSheet.officeLayout ? sizePx : resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
3414
- const targetWorkbookSheetIndex = activeSheet.workbookSheetIndex;
3415
- setSheets((currentSheets) => currentSheets.map((sheet) => {
3416
- if (sheet.workbookSheetIndex !== targetWorkbookSheetIndex) {
3417
- return sheet;
3418
- }
3419
- if (axis === "column") {
3420
- const nextColWidthOverridesPx = {
3421
- ...sheet.colWidthOverridesPx,
3422
- [actualIndex]: contentSizePx
3423
- };
3424
- const nextColWidths = [...sheet.colWidths];
3425
- const visibleColIndex = sheet.visibleCols.indexOf(actualIndex);
3426
- if (visibleColIndex >= 0) {
3427
- nextColWidths[visibleColIndex] = contentSizePx;
3428
- }
3429
- return {
3430
- ...sheet,
3431
- colWidthOverridesPx: nextColWidthOverridesPx,
3432
- colWidths: nextColWidths
3433
- };
3434
- }
3435
- const nextRowHeightOverridesPx = {
3436
- ...sheet.rowHeightOverridesPx,
3437
- [actualIndex]: contentSizePx
3438
- };
3439
- const nextRowHeights = [...sheet.rowHeights];
3440
- const visibleRowIndex = sheet.visibleRows.indexOf(actualIndex);
3441
- if (visibleRowIndex >= 0) {
3442
- nextRowHeights[visibleRowIndex] = contentSizePx;
3443
- }
3444
- return {
3445
- ...sheet,
3446
- rowHeightOverridesPx: nextRowHeightOverridesPx,
3447
- rowHeights: nextRowHeights
3448
- };
3454
+ const selected = new Set(indices);
3455
+ setSheets((current) => current.map((sheet) => {
3456
+ if (sheet.workbookSheetIndex !== activeSheet.workbookSheetIndex) return sheet;
3457
+ const isRow = axis === "row";
3458
+ const overrides = { ...isRow ? sheet.rowHeightOverridesPx : sheet.colWidthOverridesPx };
3459
+ for (const index of selected) overrides[index] = contentSizePx;
3460
+ const visible = isRow ? sheet.visibleRows : sheet.visibleCols;
3461
+ const sizes = (isRow ? sheet.rowHeights : sheet.colWidths).map((size, offset) => selected.has(visible[offset]) ? contentSizePx : size);
3462
+ return isRow ? { ...sheet, rowHeightOverridesPx: overrides, rowHeights: sizes } : { ...sheet, colWidthOverridesPx: overrides, colWidths: sizes };
3449
3463
  }));
3450
3464
  setRevision((current) => current + 1);
3451
3465
  }, [activeSheet]);
3452
- const resizeColumn = React.useCallback((col, widthPx) => {
3453
- if (!canResize || !activeSheet) {
3454
- return;
3455
- }
3456
- if (isWorkerBacked) {
3457
- applyReadOnlyResizeOverride("column", col, widthPx);
3458
- return;
3459
- }
3460
- if (!workbook) {
3461
- return;
3462
- }
3463
- recordHistoryBeforeMutation();
3466
+ const setAxisHidden = React.useCallback((axis, hidden, start, end = start) => {
3467
+ if (readOnly || !workbook || !activeSheet) return;
3468
+ const limit = axis === "row" ? XLSX_MAX_ROWS : XLSX_MAX_COLUMNS;
3469
+ const ranges = start === void 0 && end === void 0 ? selectionRanges.map((area) => ({ start: area.start[axis], end: area.end[axis] })) : [{ start: start ?? -1, end: end ?? -1 }];
3470
+ if (!ranges.length || ranges.some((range) => !Number.isInteger(range.start) || !Number.isInteger(range.end) || range.start < 0 || range.end < range.start || range.end >= limit)) return;
3464
3471
  const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
3465
- worksheet.setColumnWidth(
3466
- col,
3467
- activeSheet.officeLayout ? pxToOfficeColumnWidth(widthPx, activeSheet.officeLayout.columnDigitWidthPt) : pxToSheetColumnWidth(
3468
- resolveContentSheetAxisPixels(widthPx, activeSheet.showGridLines),
3469
- activeSheet.columnWidthCharacterWidthPx
3470
- )
3471
- );
3472
- refreshWorkbookState(workbook);
3473
- }, [
3474
- activeSheet,
3475
- applyReadOnlyResizeOverride,
3476
- canResize,
3477
- isWorkerBacked,
3478
- recordHistoryBeforeMutation,
3479
- refreshWorkbookState,
3480
- workbook
3481
- ]);
3482
- const resizeRow = React.useCallback((row2, heightPx) => {
3483
- if (!canResize || !activeSheet) {
3484
- return;
3485
- }
3472
+ try {
3473
+ const existing = new Set(axis === "row" ? worksheet.hiddenRows : worksheet.hiddenColumns);
3474
+ if (!hidden && !existing.size) return;
3475
+ if (!hidden && start === void 0 && existing.has(0)) {
3476
+ let firstVisible = 0;
3477
+ while (existing.has(firstVisible)) firstVisible++;
3478
+ for (const range of ranges) {
3479
+ if (range.start === firstVisible) range.start = 0;
3480
+ }
3481
+ }
3482
+ const changes = ranges.filter((range) => {
3483
+ for (let index = range.start; index <= range.end; index++) {
3484
+ if (existing.has(index) !== hidden) return true;
3485
+ }
3486
+ return false;
3487
+ });
3488
+ if (!changes.length) return;
3489
+ recordHistoryBeforeMutation();
3490
+ for (const range of changes) {
3491
+ if (axis === "row") worksheet.setRowsHidden(range.start, range.end, hidden);
3492
+ else worksheet.setColumnsHidden(range.start, range.end, hidden);
3493
+ }
3494
+ if (hidden && activeCell && changes.some((range) => range.start <= activeCell[axis] && activeCell[axis] <= range.end)) {
3495
+ const isHidden = (index2) => axis === "row" ? worksheet.isRowHidden(index2) : worksheet.isColumnHidden(index2);
3496
+ let index = activeCell[axis];
3497
+ while (index < limit && isHidden(index)) index++;
3498
+ if (index === limit) {
3499
+ index = activeCell[axis] - 1;
3500
+ while (index >= 0 && isHidden(index)) index--;
3501
+ }
3502
+ if (index >= 0) {
3503
+ const cell = { ...activeCell, [axis]: index };
3504
+ setActiveCell(cell);
3505
+ setSelection({ start: cell, end: cell });
3506
+ selectionAnchorRef.current = cell;
3507
+ }
3508
+ }
3509
+ refreshWorkbookState(workbook);
3510
+ } finally {
3511
+ worksheet.free();
3512
+ }
3513
+ }, [activeCell, activeSheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selectionRanges, setSelection, workbook]);
3514
+ const hideRows = React.useCallback((start, end) => setAxisHidden("row", true, start, end), [setAxisHidden]);
3515
+ const unhideRows = React.useCallback((start, end) => setAxisHidden("row", false, start, end), [setAxisHidden]);
3516
+ const hideColumns = React.useCallback((start, end) => setAxisHidden("col", true, start, end), [setAxisHidden]);
3517
+ const unhideColumns = React.useCallback((start, end) => setAxisHidden("col", false, start, end), [setAxisHidden]);
3518
+ const setFreezeBoundary = React.useCallback((cell) => {
3519
+ if (readOnly || !workbook || !activeSheet) return;
3520
+ const { row: row2, col } = cell;
3521
+ if (!Number.isInteger(row2) || row2 < 0 || row2 >= XLSX_MAX_ROWS || !Number.isInteger(col) || col < 0 || col >= XLSX_MAX_COLUMNS) return;
3522
+ const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
3523
+ try {
3524
+ const current = parseWorksheetFreezePanes(worksheet);
3525
+ if (row2 === (current?.row ?? 0) && col === (current?.col ?? 0)) return;
3526
+ recordHistoryBeforeMutation();
3527
+ worksheet.setFreezePanes(row2, col);
3528
+ refreshWorkbookState(workbook);
3529
+ } finally {
3530
+ worksheet.free();
3531
+ }
3532
+ }, [activeSheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
3533
+ const freezeCell = resolveFreezePanesCell(activeCell, selection);
3534
+ const canFreezePanes = Boolean(!readOnly && workbook && activeSheet && freezeCell && (freezeCell.row > 0 || freezeCell.col > 0));
3535
+ const freezePanes = React.useCallback((cell = freezeCell) => {
3536
+ if (cell) setFreezeBoundary(cell);
3537
+ }, [freezeCell, setFreezeBoundary]);
3538
+ const unfreezePanes = React.useCallback(() => setFreezeBoundary({ row: 0, col: 0 }), [setFreezeBoundary]);
3539
+ const resizeAxis = React.useCallback((axis, target, sizePx) => {
3540
+ if (!canResize || !activeSheet || !Number.isFinite(sizePx)) return;
3541
+ const indices = typeof target === "number" ? [target] : target;
3542
+ const limit = axis === "row" ? XLSX_MAX_ROWS : XLSX_MAX_COLUMNS;
3543
+ if (!indices.length || indices.some((index) => !Number.isInteger(index) || index < 0 || index >= limit)) return;
3486
3544
  if (isWorkerBacked) {
3487
- applyReadOnlyResizeOverride("row", row2, heightPx);
3545
+ applyReadOnlyResizeOverride(axis, indices, sizePx);
3488
3546
  return;
3489
3547
  }
3490
- if (!workbook) {
3491
- return;
3492
- }
3493
- recordHistoryBeforeMutation();
3548
+ if (!workbook) return;
3494
3549
  const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
3495
- worksheet.setRowHeight(
3496
- row2,
3497
- activeSheet.officeLayout ? Math.max(heightPx, MIN_ROW_HEIGHT_PX) * (3 / 4) : pxToSheetRowHeight(resolveContentSheetAxisPixels(heightPx, activeSheet.showGridLines))
3498
- );
3499
- refreshWorkbookState(workbook);
3500
- }, [
3501
- activeSheet,
3502
- applyReadOnlyResizeOverride,
3503
- canResize,
3504
- isWorkerBacked,
3505
- recordHistoryBeforeMutation,
3506
- refreshWorkbookState,
3507
- workbook
3508
- ]);
3550
+ try {
3551
+ recordHistoryBeforeMutation();
3552
+ const contentPx = resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
3553
+ if (axis === "row") {
3554
+ const points = activeSheet.officeLayout ? Math.max(sizePx, MIN_ROW_HEIGHT_PX) * 3 / 4 : pxToSheetRowHeight(contentPx);
3555
+ for (const index of indices) worksheet.setRowHeight(index, points);
3556
+ } else {
3557
+ const width = activeSheet.officeLayout ? pxToOfficeColumnWidth(sizePx, activeSheet.officeLayout.columnDigitWidthPt) : pxToSheetColumnWidth(contentPx, activeSheet.columnWidthCharacterWidthPx);
3558
+ for (const index of indices) worksheet.setColumnWidth(index, width);
3559
+ }
3560
+ refreshWorkbookState(workbook);
3561
+ } finally {
3562
+ worksheet.free();
3563
+ }
3564
+ }, [activeSheet, applyReadOnlyResizeOverride, canResize, isWorkerBacked, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
3565
+ const resizeColumn = React.useCallback((col, widthPx) => resizeAxis("column", col, widthPx), [resizeAxis]);
3566
+ const resizeRow = React.useCallback((row2, heightPx) => resizeAxis("row", row2, heightPx), [resizeAxis]);
3509
3567
  const resolveAnchoredObjectRect = React.useCallback((anchor, worksheet) => {
3510
3568
  const resolveAxisSum = (index, getSize) => {
3511
3569
  let total = 0;
@@ -3935,15 +3993,20 @@ function useXlsxViewerController(options2) {
3935
3993
  selectionAnchorRef.current = anchorCell;
3936
3994
  setSelection(merged ?? { start: cell, end: cell });
3937
3995
  }, [activeSheet?.mergedRanges, findSelectionMerge]);
3938
- const selectRange = React.useCallback((range) => {
3939
- const normalized = expandHighlightedRange(normalizeRange(range), activeSheet?.mergedRanges ?? []);
3996
+ const selectRanges = React.useCallback((ranges, activeCorner = "end") => {
3997
+ const areas = ranges.reduce((previous, range) => addSelectionRange(previous, normalizeRange(range)), []);
3998
+ const active = areas.at(-1);
3940
3999
  setSelectedChartId(null);
3941
4000
  setSelectedChartElement(null);
3942
4001
  setSelectedImageId(null);
3943
- selectionAnchorRef.current = normalized.start;
3944
- setActiveCell(findSelectionMerge(normalized.end)?.start ?? normalized.end);
3945
- setSelection(normalized);
3946
- }, [activeSheet?.mergedRanges, findSelectionMerge]);
4002
+ selectionAnchorRef.current = active?.start ?? null;
4003
+ const cell = active?.[activeCorner];
4004
+ setActiveCell(cell ? findSelectionMerge(cell)?.start ?? cell : null);
4005
+ setSelectionRanges(areas);
4006
+ }, [findSelectionMerge]);
4007
+ const selectRange = React.useCallback((range) => {
4008
+ selectRanges([expandHighlightedRange(normalizeRange(range), activeSheet?.mergedRanges ?? [])]);
4009
+ }, [activeSheet?.mergedRanges, selectRanges]);
3947
4010
  const clearSelection = React.useCallback(() => {
3948
4011
  selectionAnchorRef.current = null;
3949
4012
  setActiveCell(null);
@@ -3954,38 +4017,35 @@ function useXlsxViewerController(options2) {
3954
4017
  }, []);
3955
4018
  const clearSelectedCells = React.useCallback(() => {
3956
4019
  const worksheet = getActiveWorksheet();
3957
- const targetRange = selection ?? (activeCell ? { start: activeCell, end: activeCell } : null);
3958
- if (readOnly || !worksheet || !workbook || !targetRange) {
3959
- return;
3960
- }
3961
- if (intersectsPivot(targetRange)) return;
3962
- const normalized = normalizeRange(targetRange);
4020
+ if (readOnly || !worksheet || !workbook || !selectionRanges.length || selectionRanges.some(intersectsPivot)) return;
3963
4021
  const mutations = [];
3964
- for (let row2 = normalized.start.row; row2 <= normalized.end.row; row2 += 1) {
3965
- for (let col = normalized.start.col; col <= normalized.end.col; col += 1) {
3966
- if (worksheet.isMergedSecondary(row2, col)) {
3967
- continue;
3968
- }
3969
- const cell = { row: row2, col };
3970
- const before = captureCellMutationState(cell);
3971
- if (!before) {
3972
- continue;
3973
- }
3974
- worksheet.setCell(cellAddressToA1({ row: row2, col }), "");
3975
- const after = captureCellMutationState(cell);
3976
- if (!after) {
3977
- continue;
4022
+ for (const area of selectionRanges) {
4023
+ for (let row2 = area.start.row; row2 <= area.end.row; row2 += 1) {
4024
+ for (let col = area.start.col; col <= area.end.col; col += 1) {
4025
+ if (worksheet.isMergedSecondary(row2, col)) {
4026
+ continue;
4027
+ }
4028
+ const cell = { row: row2, col };
4029
+ const before = captureCellMutationState(cell);
4030
+ if (!before) {
4031
+ continue;
4032
+ }
4033
+ worksheet.setCell(cellAddressToA1({ row: row2, col }), "");
4034
+ const after = captureCellMutationState(cell);
4035
+ if (!after) {
4036
+ continue;
4037
+ }
4038
+ mutations.push({
4039
+ after,
4040
+ before,
4041
+ cell
4042
+ });
3978
4043
  }
3979
- mutations.push({
3980
- after,
3981
- before,
3982
- cell
3983
- });
3984
4044
  }
3985
4045
  }
3986
4046
  maybeRecalculateWorkbook(workbook);
3987
4047
  refreshWorkbookState(workbook);
3988
- recordRangeEditHistory(mutations, normalized, activeCell ?? normalized.start);
4048
+ recordRangeEditHistory(mutations, selectionRanges, activeCell);
3989
4049
  }, [
3990
4050
  intersectsPivot,
3991
4051
  activeCell,
@@ -3995,7 +4055,7 @@ function useXlsxViewerController(options2) {
3995
4055
  readOnly,
3996
4056
  recordRangeEditHistory,
3997
4057
  refreshWorkbookState,
3998
- selection,
4058
+ selectionRanges,
3999
4059
  workbook
4000
4060
  ]);
4001
4061
  const setCellValue = React.useCallback((cell, value) => {
@@ -4080,8 +4140,8 @@ function useXlsxViewerController(options2) {
4080
4140
  if (after) mutations.push({ cell, before, after });
4081
4141
  }
4082
4142
  refreshWorkbookState(workbook);
4083
- recordRangeEditHistory(mutations, selection, activeCell);
4084
- }, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
4143
+ recordRangeEditHistory(mutations, selectionRanges, activeCell);
4144
+ }, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selectionRanges, workbook]);
4085
4145
  const setSelectedCellValue = React.useCallback((value) => {
4086
4146
  if (!activeCell) {
4087
4147
  return;
@@ -4115,25 +4175,27 @@ function useXlsxViewerController(options2) {
4115
4175
  if (readOnly || !worksheet || !workbook) {
4116
4176
  return;
4117
4177
  }
4118
- const normalized = normalizeRange(range);
4178
+ const areas = "start" in range ? [normalizeRange(range)] : range.map(normalizeRange);
4119
4179
  const beforeStates = [];
4120
- for (let row2 = normalized.start.row; row2 <= normalized.end.row; row2 += 1) {
4121
- for (let col = normalized.start.col; col <= normalized.end.col; col += 1) {
4122
- const cell = { row: row2, col };
4123
- const before = captureCellMutationState(cell);
4124
- if (!before) {
4125
- continue;
4180
+ for (const area of areas) {
4181
+ for (let row2 = area.start.row; row2 <= area.end.row; row2 += 1) {
4182
+ for (let col = area.start.col; col <= area.end.col; col += 1) {
4183
+ const cell = { row: row2, col };
4184
+ const before = captureCellMutationState(cell);
4185
+ if (!before) {
4186
+ continue;
4187
+ }
4188
+ beforeStates.push({
4189
+ before,
4190
+ cell
4191
+ });
4126
4192
  }
4127
- beforeStates.push({
4128
- before,
4129
- cell
4130
- });
4131
4193
  }
4132
4194
  }
4133
4195
  if (beforeStates.length === 0) {
4134
4196
  return;
4135
4197
  }
4136
- worksheet.setRangeStyle(rangeToA1(normalized), style);
4198
+ for (const area of areas) worksheet.setRangeStyle(rangeToA1(area), style);
4137
4199
  const mutations = [];
4138
4200
  for (const mutation of beforeStates) {
4139
4201
  const after = captureCellMutationState(mutation.cell);
@@ -4147,11 +4209,11 @@ function useXlsxViewerController(options2) {
4147
4209
  });
4148
4210
  }
4149
4211
  refreshWorkbookState(workbook);
4150
- recordRangeEditHistory(mutations, selection, activeCell);
4151
- }, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
4212
+ recordRangeEditHistory(mutations, selectionRanges, activeCell);
4213
+ }, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selectionRanges, workbook]);
4152
4214
  const fillSelection = React.useCallback((targetRange) => {
4153
4215
  const worksheet = getActiveWorksheet();
4154
- if (readOnly || !worksheet || !workbook || !selection) {
4216
+ if (readOnly || !worksheet || !workbook || !selection || selectionRanges.length > 1) {
4155
4217
  return;
4156
4218
  }
4157
4219
  if (intersectsPivot(targetRange)) return;
@@ -4202,11 +4264,11 @@ function useXlsxViewerController(options2) {
4202
4264
  setSelection(nextRange);
4203
4265
  setActiveCell(nextRange.end);
4204
4266
  selectionAnchorRef.current = nextRange.start;
4205
- recordRangeEditHistory(mutations, nextRange, nextRange.end);
4206
- }, [intersectsPivot, captureCellMutationState, getActiveWorksheet, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
4267
+ recordRangeEditHistory(mutations, [nextRange], nextRange.end);
4268
+ }, [intersectsPivot, captureCellMutationState, getActiveWorksheet, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, selectionRanges, workbook]);
4207
4269
  const mergeSelection = React.useCallback((mode = "cells") => {
4208
4270
  const worksheet = getActiveWorksheet();
4209
- if (readOnly || !worksheet || !selection || !workbook) {
4271
+ if (readOnly || !worksheet || !selection || selectionRanges.length > 1 || !workbook) {
4210
4272
  return;
4211
4273
  }
4212
4274
  if (intersectsPivot(selection)) return;
@@ -4239,10 +4301,10 @@ function useXlsxViewerController(options2) {
4239
4301
  selectionAnchorRef.current = range.start;
4240
4302
  setSelection(range);
4241
4303
  setActiveCell(range.start);
4242
- }, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, workbook]);
4304
+ }, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, selectionRanges, workbook]);
4243
4305
  const unmergeSelection = React.useCallback(() => {
4244
4306
  const worksheet = getActiveWorksheet();
4245
- if (readOnly || !worksheet || !selection || !workbook) {
4307
+ if (readOnly || !worksheet || !selection || selectionRanges.length > 1 || !workbook) {
4246
4308
  return;
4247
4309
  }
4248
4310
  const range = normalizeRange(selection);
@@ -4254,7 +4316,7 @@ function useXlsxViewerController(options2) {
4254
4316
  worksheet.unmergeCells(rangeToA1(merged));
4255
4317
  }
4256
4318
  refreshWorkbookState(workbook);
4257
- }, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, workbook]);
4319
+ }, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, selectionRanges, workbook]);
4258
4320
  const addSheet = React.useCallback((name) => {
4259
4321
  if (readOnly || !workbook) {
4260
4322
  return;
@@ -4343,18 +4405,18 @@ function useXlsxViewerController(options2) {
4343
4405
  if (!trimmed) {
4344
4406
  return;
4345
4407
  }
4346
- const targetRange = range ?? selection;
4408
+ const targetRange = range ?? (selectionRanges.length === 1 ? selection : null);
4347
4409
  if (!targetRange) {
4348
4410
  return;
4349
4411
  }
4350
4412
  recordHistoryBeforeMutation();
4351
4413
  workbook.defineName(trimmed, rangeToA1(targetRange));
4352
4414
  setRevision((current) => current + 1);
4353
- }, [readOnly, recordHistoryBeforeMutation, selection, workbook]);
4415
+ }, [readOnly, recordHistoryBeforeMutation, selection, selectionRanges, workbook]);
4354
4416
  const pasteText = React.useCallback((text) => {
4355
4417
  const worksheet = getActiveWorksheet();
4356
4418
  const targetCell = activeCell ?? selection?.start ?? null;
4357
- if (readOnly || !worksheet || !workbook || !targetCell || !text) {
4419
+ if (readOnly || !worksheet || !workbook || !targetCell || selectionRanges.length > 1 || !text) {
4358
4420
  return false;
4359
4421
  }
4360
4422
  const grid = parseClipboardText(text);
@@ -4417,13 +4479,13 @@ function useXlsxViewerController(options2) {
4417
4479
  setActiveCell(targetCell);
4418
4480
  setSelection(nextRange);
4419
4481
  selectionAnchorRef.current = targetCell;
4420
- recordRangeEditHistory(mutations, nextRange, targetCell);
4482
+ recordRangeEditHistory(mutations, [nextRange], targetCell);
4421
4483
  return true;
4422
- }, [intersectsPivot, activeCell, captureCellMutationState, getActiveWorksheet, locale, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
4484
+ }, [intersectsPivot, activeCell, captureCellMutationState, getActiveWorksheet, locale, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, selectionRanges, workbook]);
4423
4485
  const pasteStructuredClipboardData = React.useCallback((serializedPayload) => {
4424
4486
  const worksheet = getActiveWorksheet();
4425
4487
  const targetCell = activeCell ?? selection?.start ?? null;
4426
- if (readOnly || !worksheet || !workbook || !targetCell || !serializedPayload) {
4488
+ if (readOnly || !worksheet || !workbook || !targetCell || selectionRanges.length > 1 || !serializedPayload) {
4427
4489
  return false;
4428
4490
  }
4429
4491
  let payload;
@@ -4512,7 +4574,7 @@ function useXlsxViewerController(options2) {
4512
4574
  setSelection(nextRange);
4513
4575
  selectionAnchorRef.current = targetCell;
4514
4576
  if (!hasMergeOperations) {
4515
- recordRangeEditHistory(mutations, nextRange, targetCell);
4577
+ recordRangeEditHistory(mutations, [nextRange], targetCell);
4516
4578
  }
4517
4579
  return true;
4518
4580
  }, [
@@ -4526,33 +4588,37 @@ function useXlsxViewerController(options2) {
4526
4588
  recordRangeEditHistory,
4527
4589
  refreshWorkbookState,
4528
4590
  selection,
4591
+ selectionRanges,
4529
4592
  workbook
4530
4593
  ]);
4531
4594
  const copySelectionToClipboard = React.useCallback(async () => {
4532
4595
  if (typeof navigator === "undefined" || !navigator.clipboard) {
4533
4596
  return false;
4534
4597
  }
4535
- if (isWorkerBacked && activeSheet && selection) {
4536
- const range = normalizeRange(selection);
4598
+ if (isWorkerBacked && activeSheet) {
4599
+ const bands = clipboardBands(selectionRanges);
4600
+ if (!bands) return false;
4537
4601
  const textPromise = (async () => {
4538
4602
  const lines = [];
4539
- for (let startRow = range.start.row; startRow <= range.end.row; startRow += 128) {
4540
- const count = Math.min(128, range.end.row - startRow + 1);
4541
- const batch = await getRowsBatchAsync(activeSheet.workbookSheetIndex, startRow, count);
4542
- if (!batch) throw new Error("Unable to read the selected cells.");
4543
- const values = /* @__PURE__ */ new Map();
4544
- for (const entry of batch) {
4545
- for (const cell of entry.cells ?? []) {
4546
- if (cell.col < range.start.col || cell.col > range.end.col || cell.isMergedSecondary) continue;
4547
- const value = String(cell.value ?? "");
4548
- const cached = cell.formula ? activeSheet.cachedFormulaValues[cellAddressToA1({ row: entry.index, col: cell.col })] : void 0;
4549
- values.set(`${entry.index}:${cell.col}`, decodeHtmlEntities(cached !== void 0 && value.startsWith("#") ? cached : value));
4603
+ for (const band of bands.rows) {
4604
+ for (let startRow = band.start; startRow <= band.end; startRow += 128) {
4605
+ const count = Math.min(128, band.end - startRow + 1);
4606
+ const batch = await getRowsBatchAsync(activeSheet.workbookSheetIndex, startRow, count);
4607
+ if (!batch) throw new Error("Unable to read the selected cells.");
4608
+ const values = /* @__PURE__ */ new Map();
4609
+ for (const entry of batch) {
4610
+ for (const cell of entry.cells ?? []) {
4611
+ if (cell.isMergedSecondary) continue;
4612
+ const value = String(cell.value ?? "");
4613
+ const cached = cell.formula ? activeSheet.cachedFormulaValues[cellAddressToA1({ row: entry.index, col: cell.col })] : void 0;
4614
+ values.set(`${entry.index}:${cell.col}`, decodeHtmlEntities(cached !== void 0 && value.startsWith("#") ? cached : value));
4615
+ }
4616
+ }
4617
+ for (let row2 = startRow; row2 < startRow + count; row2++) {
4618
+ const cells = [];
4619
+ for (const { index: col } of bandIndices(bands.cols)) cells.push(values.get(`${row2}:${col}`) ?? "");
4620
+ lines.push(cells.join(" "));
4550
4621
  }
4551
- }
4552
- for (let row2 = startRow; row2 < startRow + count; row2++) {
4553
- const cells = [];
4554
- for (let col = range.start.col; col <= range.end.col; col++) cells.push(values.get(`${row2}:${col}`) ?? "");
4555
- lines.push(cells.join(" "));
4556
4622
  }
4557
4623
  }
4558
4624
  return lines.join("\n");
@@ -4590,7 +4656,7 @@ function useXlsxViewerController(options2) {
4590
4656
  }
4591
4657
  await navigator.clipboard.writeText(clipboardData.text);
4592
4658
  return true;
4593
- }, [activeSheet, getClipboardData, getRowsBatchAsync, isWorkerBacked, selection]);
4659
+ }, [activeSheet, getClipboardData, getRowsBatchAsync, isWorkerBacked, selectionRanges]);
4594
4660
  const pasteFromClipboard = React.useCallback(async (clipboardData) => {
4595
4661
  if (readOnly) return false;
4596
4662
  const state = drawingMutationState.current;
@@ -4755,6 +4821,14 @@ function useXlsxViewerController(options2) {
4755
4821
  revision,
4756
4822
  resizeChartBy,
4757
4823
  resizeImageBy,
4824
+ frozenPanes: activeSheet?.freezePanes ?? null,
4825
+ canFreezePanes,
4826
+ hideRows,
4827
+ unhideRows,
4828
+ hideColumns,
4829
+ unhideColumns,
4830
+ freezePanes,
4831
+ unfreezePanes,
4758
4832
  resizeColumn,
4759
4833
  resizeRow,
4760
4834
  setCellFormula,
@@ -4783,6 +4857,8 @@ function useXlsxViewerController(options2) {
4783
4857
  selectChartElement,
4784
4858
  selectImage,
4785
4859
  selectRange,
4860
+ selectRanges,
4861
+ selectionRanges,
4786
4862
  selection,
4787
4863
  setActiveSheetIndex,
4788
4864
  setActiveTabIndex,
@@ -4898,6 +4974,13 @@ function useXlsxViewerController(options2) {
4898
4974
  revision,
4899
4975
  resizeChartBy,
4900
4976
  resizeImageBy,
4977
+ canFreezePanes,
4978
+ hideRows,
4979
+ unhideRows,
4980
+ hideColumns,
4981
+ unhideColumns,
4982
+ freezePanes,
4983
+ unfreezePanes,
4901
4984
  resizeColumn,
4902
4985
  resizeRow,
4903
4986
  setCellFormula,
@@ -4926,6 +5009,8 @@ function useXlsxViewerController(options2) {
4926
5009
  selectChartElement,
4927
5010
  selectImage,
4928
5011
  selectRange,
5012
+ selectRanges,
5013
+ selectionRanges,
4929
5014
  selection,
4930
5015
  setActiveSheetIndex,
4931
5016
  setActiveTabIndex,
@@ -4957,13 +5042,13 @@ function useXlsxViewerController(options2) {
4957
5042
  import { initWasm, parseXlsxRange as parseXlsxRange2, setWasmSource, XlsxFileSizeLimitExceededError as XlsxFileSizeLimitExceededError3 } from "@extend-ai/react-xlsx/vanilla";
4958
5043
 
4959
5044
  // src/react-viewer.tsx
4960
- import * as React15 from "react";
4961
- import { createPortal as createPortal6 } from "react-dom";
5045
+ import * as React16 from "react";
5046
+ import { createPortal as createPortal7 } from "react-dom";
4962
5047
  import { __createContentNode, __createContentRoot, __createControlledViewer } from "@extend-ai/react-xlsx/internal";
4963
5048
 
4964
5049
  // src/XlsxViewer.tsx
4965
- import * as React14 from "react";
4966
- import { createPortal as createPortal5 } from "react-dom";
5050
+ import * as React15 from "react";
5051
+ import { createPortal as createPortal6 } from "react-dom";
4967
5052
 
4968
5053
  // src/cell-editor.tsx
4969
5054
  import * as React2 from "react";
@@ -5259,9 +5344,14 @@ function getCellGeneralAlignment(worksheet, row2, col) {
5259
5344
  }
5260
5345
  }
5261
5346
 
5262
- // src/context-menu.tsx
5263
- import * as React7 from "react";
5347
+ // src/header-size-dialog.tsx
5348
+ import * as React6 from "react";
5264
5349
  import { createPortal as createPortal3 } from "react-dom";
5350
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
5351
+
5352
+ // src/context-menu.tsx
5353
+ import * as React8 from "react";
5354
+ import { createPortal as createPortal4 } from "react-dom";
5265
5355
 
5266
5356
  // src/viewer-palette.ts
5267
5357
  var LIGHT_PALETTE = {
@@ -5325,23 +5415,23 @@ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextC
5325
5415
  }
5326
5416
 
5327
5417
  // src/context-menu-items.tsx
5328
- import * as React6 from "react";
5329
- import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
5418
+ import * as React7 from "react";
5419
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
5330
5420
 
5331
5421
  // src/context-menu.tsx
5332
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
5422
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
5333
5423
 
5334
5424
  // src/pivot-controls.tsx
5335
- import * as React8 from "react";
5336
- import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
5425
+ import * as React9 from "react";
5426
+ import { Fragment as Fragment5, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
5337
5427
 
5338
5428
  // src/pivot-header-controls.tsx
5339
- import * as React9 from "react";
5340
- import { createPortal as createPortal4 } from "react-dom";
5341
- import { Fragment as Fragment7, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
5429
+ import * as React10 from "react";
5430
+ import { createPortal as createPortal5 } from "react-dom";
5431
+ import { Fragment as Fragment7, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
5342
5432
 
5343
5433
  // src/pivot-editor.ts
5344
- import * as React10 from "react";
5434
+ import * as React11 from "react";
5345
5435
  function address(row2, col) {
5346
5436
  let letters = "";
5347
5437
  for (let n = col + 1; n > 0; n = Math.floor((n - 1) / 26)) letters = String.fromCharCode(65 + (n - 1) % 26) + letters;
@@ -5360,18 +5450,18 @@ function copyPivot(pivot) {
5360
5450
  function usePivotTableEditor(viewer, options2 = {}) {
5361
5451
  const open = viewer.pivotFieldListVisible;
5362
5452
  const setOpen = viewer.setPivotFieldListVisible;
5363
- const [draft, setDraft] = React10.useState(null);
5364
- const [dirty, setDirty] = React10.useState(false);
5365
- const [error, setError] = React10.useState(null);
5366
- const [status, setStatus] = React10.useState(null);
5367
- const [details, setDetails] = React10.useState(null);
5368
- const [detailContext, setDetailContext] = React10.useState(null);
5369
- const [loadedSource, setLoadedSource] = React10.useState("");
5370
- const [savedDefinition, setSavedDefinition] = React10.useState("");
5371
- const [pendingFocus, setPendingFocus] = React10.useState(null);
5453
+ const [draft, setDraft] = React11.useState(null);
5454
+ const [dirty, setDirty] = React11.useState(false);
5455
+ const [error, setError] = React11.useState(null);
5456
+ const [status, setStatus] = React11.useState(null);
5457
+ const [details, setDetails] = React11.useState(null);
5458
+ const [detailContext, setDetailContext] = React11.useState(null);
5459
+ const [loadedSource, setLoadedSource] = React11.useState("");
5460
+ const [savedDefinition, setSavedDefinition] = React11.useState("");
5461
+ const [pendingFocus, setPendingFocus] = React11.useState(null);
5372
5462
  const sourceNeedsLoad = Boolean(draft && JSON.stringify(draft.source) !== loadedSource);
5373
5463
  const stale = Boolean(dirty && draft?.id && savedDefinition !== JSON.stringify(viewer.pivotTables.find((pivot) => pivot.id === draft.id) ?? null));
5374
- const run = React10.useCallback((action) => {
5464
+ const run = React11.useCallback((action) => {
5375
5465
  setError(null);
5376
5466
  setStatus(null);
5377
5467
  try {
@@ -5381,7 +5471,7 @@ function usePivotTableEditor(viewer, options2 = {}) {
5381
5471
  setOpen(true);
5382
5472
  }
5383
5473
  }, []);
5384
- React10.useEffect(() => {
5474
+ React11.useEffect(() => {
5385
5475
  if (options2.enabled === false) return;
5386
5476
  setDraft(null);
5387
5477
  setDirty(false);
@@ -5394,7 +5484,7 @@ function usePivotTableEditor(viewer, options2 = {}) {
5394
5484
  setPendingFocus(null);
5395
5485
  if (options2.initialOpen !== void 0) setOpen(options2.initialOpen);
5396
5486
  }, [viewer.src, viewer.file]);
5397
- React10.useEffect(() => {
5487
+ React11.useEffect(() => {
5398
5488
  if (options2.enabled === false || dirty || !draft?.id) return;
5399
5489
  const current = viewer.pivotTables.find((pivot) => pivot.id === draft.id);
5400
5490
  setDraft(current ? copyPivot(current) : null);
@@ -5403,7 +5493,7 @@ function usePivotTableEditor(viewer, options2 = {}) {
5403
5493
  setSavedDefinition(JSON.stringify(current));
5404
5494
  }
5405
5495
  }, [viewer.pivotTables]);
5406
- React10.useEffect(() => {
5496
+ React11.useEffect(() => {
5407
5497
  if (options2.enabled === false || options2.autoSelect === false || dirty || pendingFocus || !viewer.activeCell || !viewer.activeSheet) return;
5408
5498
  const current = viewer.getPivotTableAtCell(viewer.activeCell, viewer.activeSheet.name);
5409
5499
  if (!current || current.id === draft?.id) return;
@@ -5414,7 +5504,7 @@ function usePivotTableEditor(viewer, options2 = {}) {
5414
5504
  setStatus(null);
5415
5505
  setDetails(null);
5416
5506
  }, [viewer.activeCell?.row, viewer.activeCell?.col, viewer.activeSheet?.name, viewer.pivotTables, options2.autoSelect, options2.enabled]);
5417
- React10.useEffect(() => {
5507
+ React11.useEffect(() => {
5418
5508
  if (!pendingFocus || viewer.activeSheet?.name.toLowerCase() !== pendingFocus.sheet.toLowerCase()) return;
5419
5509
  viewer.selectCell({ row: pendingFocus.row, col: pendingFocus.col });
5420
5510
  setPendingFocus(null);
@@ -5619,8 +5709,8 @@ function usePivotTableEditor(viewer, options2 = {}) {
5619
5709
  }
5620
5710
 
5621
5711
  // src/pivot-field-list.tsx
5622
- import * as React11 from "react";
5623
- import { Fragment as Fragment8, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
5712
+ import * as React12 from "react";
5713
+ import { Fragment as Fragment8, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
5624
5714
  var AREAS = ["reportFilters", "columns", "rows", "values"];
5625
5715
  var AREA_NAMES = { reportFilters: "Filters", columns: "Columns", rows: "Rows", values: "Values" };
5626
5716
  var AGGREGATIONS = [["sum", "Sum"], ["count", "Count"], ["average", "Average"], ["max", "Max"], ["min", "Min"], ["product", "Product"], ["countNums", "Count Numbers"], ["stdDev", "StdDev"], ["stdDevp", "StdDevp"], ["var", "Var"], ["varp", "Varp"]];
@@ -5647,53 +5737,53 @@ function groupingUnit(axis) {
5647
5737
  return axis?.grouping ? axis.grouping.kind === "date" ? axis.grouping.unit : axis.grouping.kind : null;
5648
5738
  }
5649
5739
  function Action({ children: children2, primary, style, ...props }) {
5650
- return /* @__PURE__ */ jsx8("button", { type: "button", ...props, style: { ...control, width: "auto", cursor: props.disabled ? "default" : "pointer", opacity: props.disabled ? 0.55 : 1, ...primary ? { background: "var(--xlsx-pivot-accent)", borderColor: "var(--xlsx-pivot-accent)", color: "#fff" } : {}, ...style }, children: children2 });
5740
+ return /* @__PURE__ */ jsx9("button", { type: "button", ...props, style: { ...control, width: "auto", cursor: props.disabled ? "default" : "pointer", opacity: props.disabled ? 0.55 : 1, ...primary ? { background: "var(--xlsx-pivot-accent)", borderColor: "var(--xlsx-pivot-accent)", color: "#fff" } : {}, ...style }, children: children2 });
5651
5741
  }
5652
5742
  function Text({ label, value, onChange, ...props }) {
5653
- return /* @__PURE__ */ jsxs6("label", { style: { ...stack, gap: 4 }, children: [
5654
- /* @__PURE__ */ jsx8("span", { children: label }),
5655
- /* @__PURE__ */ jsx8("input", { ...props, style: { ...control, ...props.style }, value, onChange: (event) => onChange(event.target.value) })
5743
+ return /* @__PURE__ */ jsxs7("label", { style: { ...stack, gap: 4 }, children: [
5744
+ /* @__PURE__ */ jsx9("span", { children: label }),
5745
+ /* @__PURE__ */ jsx9("input", { ...props, style: { ...control, ...props.style }, value, onChange: (event) => onChange(event.target.value) })
5656
5746
  ] });
5657
5747
  }
5658
5748
  function Choice({ label, value, options: options2, onChange, placeholder, disabled }) {
5659
- return /* @__PURE__ */ jsxs6("label", { style: { ...stack, gap: 4 }, children: [
5660
- /* @__PURE__ */ jsx8("span", { children: label }),
5661
- /* @__PURE__ */ jsxs6("select", { disabled, style: control, value, onChange: (event) => onChange(event.target.value), children: [
5662
- placeholder ? /* @__PURE__ */ jsx8("option", { value: "", children: placeholder }) : null,
5663
- options2.map(([key, text]) => /* @__PURE__ */ jsx8("option", { value: key, children: text }, key))
5749
+ return /* @__PURE__ */ jsxs7("label", { style: { ...stack, gap: 4 }, children: [
5750
+ /* @__PURE__ */ jsx9("span", { children: label }),
5751
+ /* @__PURE__ */ jsxs7("select", { disabled, style: control, value, onChange: (event) => onChange(event.target.value), children: [
5752
+ placeholder ? /* @__PURE__ */ jsx9("option", { value: "", children: placeholder }) : null,
5753
+ options2.map(([key, text]) => /* @__PURE__ */ jsx9("option", { value: key, children: text }, key))
5664
5754
  ] })
5665
5755
  ] });
5666
5756
  }
5667
5757
  function Check({ label, checked, onChange, disabled }) {
5668
- return /* @__PURE__ */ jsxs6("label", { style: { ...row, alignItems: "flex-start", cursor: disabled ? "default" : "pointer", paddingBlock: 2 }, children: [
5669
- /* @__PURE__ */ jsx8("input", { type: "checkbox", disabled, checked, onChange: (event) => onChange(event.target.checked), style: { margin: "2px 0 0", accentColor: "var(--xlsx-pivot-accent)", flexShrink: 0 } }),
5670
- /* @__PURE__ */ jsx8("span", { style: { overflowWrap: "anywhere" }, children: label })
5758
+ return /* @__PURE__ */ jsxs7("label", { style: { ...row, alignItems: "flex-start", cursor: disabled ? "default" : "pointer", paddingBlock: 2 }, children: [
5759
+ /* @__PURE__ */ jsx9("input", { type: "checkbox", disabled, checked, onChange: (event) => onChange(event.target.checked), style: { margin: "2px 0 0", accentColor: "var(--xlsx-pivot-accent)", flexShrink: 0 } }),
5760
+ /* @__PURE__ */ jsx9("span", { style: { overflowWrap: "anywhere" }, children: label })
5671
5761
  ] });
5672
5762
  }
5673
5763
  function Section({ title, children: children2 }) {
5674
- return /* @__PURE__ */ jsxs6("details", { style: { borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
5675
- /* @__PURE__ */ jsx8("summary", { style: { cursor: "pointer", fontWeight: 600, padding: "11px 12px", userSelect: "none" }, children: title }),
5676
- /* @__PURE__ */ jsx8("div", { style: { ...stack, padding: "0 12px 12px" }, children: children2 })
5764
+ return /* @__PURE__ */ jsxs7("details", { style: { borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
5765
+ /* @__PURE__ */ jsx9("summary", { style: { cursor: "pointer", fontWeight: 600, padding: "11px 12px", userSelect: "none" }, children: title }),
5766
+ /* @__PURE__ */ jsx9("div", { style: { ...stack, padding: "0 12px 12px" }, children: children2 })
5677
5767
  ] });
5678
5768
  }
5679
5769
  function Members({ items, selected, onChange, label = "Items" }) {
5680
- const [search, setSearch] = React11.useState("");
5770
+ const [search, setSearch] = React12.useState("");
5681
5771
  const visible = items.filter((item) => item.caption.toLocaleLowerCase().includes(search.toLocaleLowerCase()));
5682
5772
  const keys = new Set(selected);
5683
- return /* @__PURE__ */ jsxs6("div", { style: { ...stack, gap: 6 }, children: [
5684
- /* @__PURE__ */ jsx8(Text, { label: `Search ${label.toLowerCase()}`, type: "search", value: search, onChange: setSearch }),
5685
- /* @__PURE__ */ jsxs6("div", { style: { ...row, flexWrap: "wrap" }, children: [
5686
- /* @__PURE__ */ jsx8(Action, { onClick: () => onChange(items.map((item) => item.key)), children: "Select all" }),
5687
- /* @__PURE__ */ jsx8(Action, { onClick: () => onChange([]), children: "Clear" }),
5688
- /* @__PURE__ */ jsxs6("span", { style: hint, children: [
5773
+ return /* @__PURE__ */ jsxs7("div", { style: { ...stack, gap: 6 }, children: [
5774
+ /* @__PURE__ */ jsx9(Text, { label: `Search ${label.toLowerCase()}`, type: "search", value: search, onChange: setSearch }),
5775
+ /* @__PURE__ */ jsxs7("div", { style: { ...row, flexWrap: "wrap" }, children: [
5776
+ /* @__PURE__ */ jsx9(Action, { onClick: () => onChange(items.map((item) => item.key)), children: "Select all" }),
5777
+ /* @__PURE__ */ jsx9(Action, { onClick: () => onChange([]), children: "Clear" }),
5778
+ /* @__PURE__ */ jsxs7("span", { style: hint, children: [
5689
5779
  keys.size,
5690
5780
  " selected"
5691
5781
  ] })
5692
5782
  ] }),
5693
- /* @__PURE__ */ jsxs6("div", { role: "group", "aria-label": label, style: { maxHeight: 150, overflowY: "auto", padding: "4px 6px", border: "1px solid var(--xlsx-pivot-border)" }, children: [
5694
- visible.slice(0, 200).map((item) => /* @__PURE__ */ jsx8(Check, { label: item.caption || "(blank)", checked: keys.has(item.key), onChange: (checked) => onChange(checked ? [...keys, item.key] : selected.filter((key) => key !== item.key)) }, item.key)),
5695
- !visible.length ? /* @__PURE__ */ jsx8("p", { style: hint, children: "No matching items." }) : null,
5696
- visible.length > 200 ? /* @__PURE__ */ jsxs6("p", { style: hint, children: [
5783
+ /* @__PURE__ */ jsxs7("div", { role: "group", "aria-label": label, style: { maxHeight: 150, overflowY: "auto", padding: "4px 6px", border: "1px solid var(--xlsx-pivot-border)" }, children: [
5784
+ visible.slice(0, 200).map((item) => /* @__PURE__ */ jsx9(Check, { label: item.caption || "(blank)", checked: keys.has(item.key), onChange: (checked) => onChange(checked ? [...keys, item.key] : selected.filter((key) => key !== item.key)) }, item.key)),
5785
+ !visible.length ? /* @__PURE__ */ jsx9("p", { style: hint, children: "No matching items." }) : null,
5786
+ visible.length > 200 ? /* @__PURE__ */ jsxs7("p", { style: hint, children: [
5697
5787
  "Search to narrow ",
5698
5788
  visible.length.toLocaleString(),
5699
5789
  " items."
@@ -5708,17 +5798,17 @@ function ValueSettings({ pivot, value, onChange }) {
5708
5798
  const baseAxes = axes.filter((axis) => axis.field === value.baseField);
5709
5799
  const base = baseAxes.find((axis) => groupingUnit(axis) === (value.baseGroupingUnit ?? null)) ?? baseAxes[0];
5710
5800
  const source = pivot.fields.find((field) => field.index === value.baseField);
5711
- return /* @__PURE__ */ jsxs6(Fragment8, { children: [
5712
- /* @__PURE__ */ jsx8(Text, { label: "Custom name", value: value.name, onChange: (name) => onChange({ ...value, name }) }),
5713
- /* @__PURE__ */ jsx8(Choice, { label: "Summarize values by", value: value.aggregation, options: AGGREGATIONS, onChange: (aggregation) => onChange({ ...value, aggregation }) }),
5714
- /* @__PURE__ */ jsx8(Choice, { label: "Show values as", value: value.showAs, options: SHOW_AS, onChange: (showAs) => onChange({ ...value, showAs, baseField: value.baseField ?? axes[0]?.field }) }),
5715
- needsBase ? /* @__PURE__ */ jsx8(Choice, { label: "Base field", value: value.baseField == null ? "" : String(value.baseField), placeholder: "Choose a field", options: pivot.fields.filter((field) => axes.some((axis) => axis.field === field.index)).map((field) => [String(field.index), field.name]), onChange: (field) => onChange({ ...value, baseField: Number(field), baseGroupingUnit: null, baseItem: null }) }) : null,
5716
- needsBase && baseAxes.length > 1 ? /* @__PURE__ */ jsx8(Choice, { label: "Base grouping level", value: value.baseGroupingUnit ?? groupingUnit(base) ?? "", options: baseAxes.map((axis) => [groupingUnit(axis) ?? "", axis.name || groupingUnit(axis) || "Source items"]), onChange: (unit) => onChange({ ...value, baseGroupingUnit: unit || null, baseItem: null }) }) : null,
5717
- needsItem ? /* @__PURE__ */ jsx8(Choice, { label: "Base item", value: value.baseItem ?? "previous", options: [["previous", "(previous)"], ["next", "(next)"], ...(base?.items?.length ? base.items : source?.items ?? []).map((item) => [item.key, item.caption])], onChange: (baseItem) => onChange({ ...value, baseItem }) }) : null,
5718
- /* @__PURE__ */ jsx8(Text, { label: "Number format", value: value.numberFormat ?? "", placeholder: "General", onChange: (numberFormat) => onChange({ ...value, numberFormat: numberFormat || null }) }),
5719
- /* @__PURE__ */ jsx8(Text, { label: "Calculated field formula", value: value.formula ?? "", placeholder: "Leave blank for a source field", onChange: (formula) => onChange({ ...value, formula: formula || null }) }),
5720
- /* @__PURE__ */ jsx8("p", { style: hint, children: "Use field names in formulas. Enclose names containing spaces in single quotes or square brackets." }),
5721
- /* @__PURE__ */ jsx8("p", { style: hint, children: FORMULA_HELP })
5801
+ return /* @__PURE__ */ jsxs7(Fragment8, { children: [
5802
+ /* @__PURE__ */ jsx9(Text, { label: "Custom name", value: value.name, onChange: (name) => onChange({ ...value, name }) }),
5803
+ /* @__PURE__ */ jsx9(Choice, { label: "Summarize values by", value: value.aggregation, options: AGGREGATIONS, onChange: (aggregation) => onChange({ ...value, aggregation }) }),
5804
+ /* @__PURE__ */ jsx9(Choice, { label: "Show values as", value: value.showAs, options: SHOW_AS, onChange: (showAs) => onChange({ ...value, showAs, baseField: value.baseField ?? axes[0]?.field }) }),
5805
+ needsBase ? /* @__PURE__ */ jsx9(Choice, { label: "Base field", value: value.baseField == null ? "" : String(value.baseField), placeholder: "Choose a field", options: pivot.fields.filter((field) => axes.some((axis) => axis.field === field.index)).map((field) => [String(field.index), field.name]), onChange: (field) => onChange({ ...value, baseField: Number(field), baseGroupingUnit: null, baseItem: null }) }) : null,
5806
+ needsBase && baseAxes.length > 1 ? /* @__PURE__ */ jsx9(Choice, { label: "Base grouping level", value: value.baseGroupingUnit ?? groupingUnit(base) ?? "", options: baseAxes.map((axis) => [groupingUnit(axis) ?? "", axis.name || groupingUnit(axis) || "Source items"]), onChange: (unit) => onChange({ ...value, baseGroupingUnit: unit || null, baseItem: null }) }) : null,
5807
+ needsItem ? /* @__PURE__ */ jsx9(Choice, { label: "Base item", value: value.baseItem ?? "previous", options: [["previous", "(previous)"], ["next", "(next)"], ...(base?.items?.length ? base.items : source?.items ?? []).map((item) => [item.key, item.caption])], onChange: (baseItem) => onChange({ ...value, baseItem }) }) : null,
5808
+ /* @__PURE__ */ jsx9(Text, { label: "Number format", value: value.numberFormat ?? "", placeholder: "General", onChange: (numberFormat) => onChange({ ...value, numberFormat: numberFormat || null }) }),
5809
+ /* @__PURE__ */ jsx9(Text, { label: "Calculated field formula", value: value.formula ?? "", placeholder: "Leave blank for a source field", onChange: (formula) => onChange({ ...value, formula: formula || null }) }),
5810
+ /* @__PURE__ */ jsx9("p", { style: hint, children: "Use field names in formulas. Enclose names containing spaces in single quotes or square brackets." }),
5811
+ /* @__PURE__ */ jsx9("p", { style: hint, children: FORMULA_HELP })
5722
5812
  ] });
5723
5813
  }
5724
5814
  function AxisSettings({ pivot, axis, onChange, onAddDateLevel }) {
@@ -5726,39 +5816,39 @@ function AxisSettings({ pivot, axis, onChange, onAddDateLevel }) {
5726
5816
  const grouping = axis.grouping;
5727
5817
  const updateGrouping = (patch) => onChange({ ...axis, grouping: { ...grouping, ...patch }, items: [], collapsed: [] });
5728
5818
  const availableUnits = DATE_UNITS.filter((unit) => ![...pivot.rows, ...pivot.columns].some((field) => field.field === axis.field && field.grouping?.kind === "date" && field.grouping.unit === unit));
5729
- return /* @__PURE__ */ jsxs6(Fragment8, { children: [
5730
- /* @__PURE__ */ jsx8(Text, { label: "Custom name", value: axis.name ?? "", placeholder: source?.name, onChange: (name) => onChange({ ...axis, name: name || null }) }),
5731
- /* @__PURE__ */ jsx8(Choice, { label: "Sort", value: axis.sort, options: [["ascending", "Ascending (A to Z)"], ["descending", "Descending (Z to A)"], ["manual", "Source order"], ["valueAscending", "Smallest to largest by value"], ["valueDescending", "Largest to smallest by value"]], onChange: (sort) => onChange({ ...axis, sort, sortMeasure: axis.sortMeasure ?? 0 }) }),
5732
- axis.sort.startsWith("value") ? /* @__PURE__ */ jsx8(Choice, { label: "Sort by value", value: String(axis.sortMeasure ?? 0), options: pivot.values.map((value, index) => [String(index), value.name]), onChange: (sortMeasure) => onChange({ ...axis, sortMeasure: Number(sortMeasure) }) }) : null,
5733
- /* @__PURE__ */ jsx8(Check, { label: "Show subtotals", checked: axis.subtotals, onChange: (subtotals) => onChange({ ...axis, subtotals }) }),
5734
- axis.subtotals ? /* @__PURE__ */ jsxs6("details", { children: [
5735
- /* @__PURE__ */ jsx8("summary", { style: { cursor: "pointer" }, children: "Custom subtotal functions" }),
5736
- /* @__PURE__ */ jsx8("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 3, marginTop: 6 }, children: AGGREGATIONS.map(([value, label]) => /* @__PURE__ */ jsx8(Check, { label, checked: axis.subtotalFunctions?.includes(value) ?? false, onChange: (checked) => onChange({ ...axis, subtotalFunctions: checked ? [...axis.subtotalFunctions ?? [], value] : axis.subtotalFunctions?.filter((item) => item !== value) }) }, value)) }),
5737
- /* @__PURE__ */ jsx8("p", { style: hint, children: "Leave unchecked to use the value field\u2019s summary function." })
5819
+ return /* @__PURE__ */ jsxs7(Fragment8, { children: [
5820
+ /* @__PURE__ */ jsx9(Text, { label: "Custom name", value: axis.name ?? "", placeholder: source?.name, onChange: (name) => onChange({ ...axis, name: name || null }) }),
5821
+ /* @__PURE__ */ jsx9(Choice, { label: "Sort", value: axis.sort, options: [["ascending", "Ascending (A to Z)"], ["descending", "Descending (Z to A)"], ["manual", "Source order"], ["valueAscending", "Smallest to largest by value"], ["valueDescending", "Largest to smallest by value"]], onChange: (sort) => onChange({ ...axis, sort, sortMeasure: axis.sortMeasure ?? 0 }) }),
5822
+ axis.sort.startsWith("value") ? /* @__PURE__ */ jsx9(Choice, { label: "Sort by value", value: String(axis.sortMeasure ?? 0), options: pivot.values.map((value, index) => [String(index), value.name]), onChange: (sortMeasure) => onChange({ ...axis, sortMeasure: Number(sortMeasure) }) }) : null,
5823
+ /* @__PURE__ */ jsx9(Check, { label: "Show subtotals", checked: axis.subtotals, onChange: (subtotals) => onChange({ ...axis, subtotals }) }),
5824
+ axis.subtotals ? /* @__PURE__ */ jsxs7("details", { children: [
5825
+ /* @__PURE__ */ jsx9("summary", { style: { cursor: "pointer" }, children: "Custom subtotal functions" }),
5826
+ /* @__PURE__ */ jsx9("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 3, marginTop: 6 }, children: AGGREGATIONS.map(([value, label]) => /* @__PURE__ */ jsx9(Check, { label, checked: axis.subtotalFunctions?.includes(value) ?? false, onChange: (checked) => onChange({ ...axis, subtotalFunctions: checked ? [...axis.subtotalFunctions ?? [], value] : axis.subtotalFunctions?.filter((item) => item !== value) }) }, value)) }),
5827
+ /* @__PURE__ */ jsx9("p", { style: hint, children: "Leave unchecked to use the value field\u2019s summary function." })
5738
5828
  ] }) : null,
5739
- /* @__PURE__ */ jsx8(Check, { label: "Show items with no data", checked: axis.showItemsWithNoData ?? false, onChange: (showItemsWithNoData) => onChange({ ...axis, showItemsWithNoData }) }),
5740
- /* @__PURE__ */ jsx8(Choice, { label: "Grouping", value: grouping?.kind ?? "none", options: [["none", "None"], ["number", "Numeric intervals"], ["date", "Date intervals"], ["manual", "Named groups"]], onChange: (kind) => onChange({ ...axis, grouping: kind === "none" ? null : { kind, unit: "months", interval: 1, groups: [] }, items: [], collapsed: [] }) }),
5741
- grouping?.kind === "date" ? /* @__PURE__ */ jsx8(Choice, { label: "Group dates by", value: grouping.unit, options: DATE_UNITS.map((unit) => [unit, unit[0].toUpperCase() + unit.slice(1)]), onChange: (unit) => updateGrouping({ unit }) }) : null,
5742
- grouping && grouping.kind !== "manual" ? /* @__PURE__ */ jsxs6(Fragment8, { children: [
5743
- /* @__PURE__ */ jsx8(Text, { label: "Interval", type: "number", min: 1e-6, step: "any", value: String(grouping.interval), onChange: (interval) => updateGrouping({ interval: Number(interval) }) }),
5744
- /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
5745
- /* @__PURE__ */ jsx8(Text, { label: "Starting at", type: "number", step: "any", placeholder: "Automatic", value: grouping.start == null ? "" : String(grouping.start), onChange: (start) => updateGrouping({ start: start === "" ? null : Number(start) }) }),
5746
- /* @__PURE__ */ jsx8(Text, { label: "Ending at", type: "number", step: "any", placeholder: "Automatic", value: grouping.end == null ? "" : String(grouping.end), onChange: (end) => updateGrouping({ end: end === "" ? null : Number(end) }) })
5829
+ /* @__PURE__ */ jsx9(Check, { label: "Show items with no data", checked: axis.showItemsWithNoData ?? false, onChange: (showItemsWithNoData) => onChange({ ...axis, showItemsWithNoData }) }),
5830
+ /* @__PURE__ */ jsx9(Choice, { label: "Grouping", value: grouping?.kind ?? "none", options: [["none", "None"], ["number", "Numeric intervals"], ["date", "Date intervals"], ["manual", "Named groups"]], onChange: (kind) => onChange({ ...axis, grouping: kind === "none" ? null : { kind, unit: "months", interval: 1, groups: [] }, items: [], collapsed: [] }) }),
5831
+ grouping?.kind === "date" ? /* @__PURE__ */ jsx9(Choice, { label: "Group dates by", value: grouping.unit, options: DATE_UNITS.map((unit) => [unit, unit[0].toUpperCase() + unit.slice(1)]), onChange: (unit) => updateGrouping({ unit }) }) : null,
5832
+ grouping && grouping.kind !== "manual" ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
5833
+ /* @__PURE__ */ jsx9(Text, { label: "Interval", type: "number", min: 1e-6, step: "any", value: String(grouping.interval), onChange: (interval) => updateGrouping({ interval: Number(interval) }) }),
5834
+ /* @__PURE__ */ jsxs7("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
5835
+ /* @__PURE__ */ jsx9(Text, { label: "Starting at", type: "number", step: "any", placeholder: "Automatic", value: grouping.start == null ? "" : String(grouping.start), onChange: (start) => updateGrouping({ start: start === "" ? null : Number(start) }) }),
5836
+ /* @__PURE__ */ jsx9(Text, { label: "Ending at", type: "number", step: "any", placeholder: "Automatic", value: grouping.end == null ? "" : String(grouping.end), onChange: (end) => updateGrouping({ end: end === "" ? null : Number(end) }) })
5747
5837
  ] }),
5748
- grouping.kind === "date" ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Optional bounds use Excel date serial values." }) : null
5838
+ grouping.kind === "date" ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Optional bounds use Excel date serial values." }) : null
5749
5839
  ] }) : null,
5750
- grouping?.kind === "date" && availableUnits.length ? /* @__PURE__ */ jsx8(Choice, { label: "Add date grouping level", value: "", placeholder: "Choose a level", options: availableUnits.map((unit) => [unit, unit[0].toUpperCase() + unit.slice(1)]), onChange: (unit) => onAddDateLevel(unit) }) : null,
5751
- grouping?.kind === "manual" ? /* @__PURE__ */ jsxs6(Fragment8, { children: [
5752
- grouping.groups.map((group, index) => /* @__PURE__ */ jsxs6("div", { style: { ...stack, borderTop: "1px solid var(--xlsx-pivot-border)", paddingTop: 8 }, children: [
5753
- /* @__PURE__ */ jsx8(Text, { label: "Group name", value: group.name, onChange: (name) => updateGrouping({ groups: grouping.groups.map((item, position) => position === index ? { ...item, name } : item) }) }),
5754
- /* @__PURE__ */ jsx8(Members, { items: source?.items ?? [], selected: group.members, onChange: (members) => updateGrouping({ groups: grouping.groups.map((item, position) => position === index ? { ...item, members } : item) }) }),
5755
- /* @__PURE__ */ jsx8(Action, { onClick: () => updateGrouping({ groups: grouping.groups.filter((_, position) => position !== index) }), children: "Remove group" })
5840
+ grouping?.kind === "date" && availableUnits.length ? /* @__PURE__ */ jsx9(Choice, { label: "Add date grouping level", value: "", placeholder: "Choose a level", options: availableUnits.map((unit) => [unit, unit[0].toUpperCase() + unit.slice(1)]), onChange: (unit) => onAddDateLevel(unit) }) : null,
5841
+ grouping?.kind === "manual" ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
5842
+ grouping.groups.map((group, index) => /* @__PURE__ */ jsxs7("div", { style: { ...stack, borderTop: "1px solid var(--xlsx-pivot-border)", paddingTop: 8 }, children: [
5843
+ /* @__PURE__ */ jsx9(Text, { label: "Group name", value: group.name, onChange: (name) => updateGrouping({ groups: grouping.groups.map((item, position) => position === index ? { ...item, name } : item) }) }),
5844
+ /* @__PURE__ */ jsx9(Members, { items: source?.items ?? [], selected: group.members, onChange: (members) => updateGrouping({ groups: grouping.groups.map((item, position) => position === index ? { ...item, members } : item) }) }),
5845
+ /* @__PURE__ */ jsx9(Action, { onClick: () => updateGrouping({ groups: grouping.groups.filter((_, position) => position !== index) }), children: "Remove group" })
5756
5846
  ] }, index)),
5757
- /* @__PURE__ */ jsx8(Action, { onClick: () => updateGrouping({ groups: [...grouping.groups, { name: `Group ${grouping.groups.length + 1}`, members: [] }] }), children: "Add named group" })
5847
+ /* @__PURE__ */ jsx9(Action, { onClick: () => updateGrouping({ groups: [...grouping.groups, { name: `Group ${grouping.groups.length + 1}`, members: [] }] }), children: "Add named group" })
5758
5848
  ] }) : null,
5759
- /* @__PURE__ */ jsxs6("details", { children: [
5760
- /* @__PURE__ */ jsx8("summary", { style: { cursor: "pointer" }, children: "Collapse members" }),
5761
- /* @__PURE__ */ jsx8("div", { style: { paddingTop: 8 }, children: grouping && !axis.items?.length ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Apply grouping to load its members." }) : /* @__PURE__ */ jsx8(Members, { label: "Members to collapse", items: axis.items?.length ? axis.items : source?.items ?? [], selected: axis.collapsed, onChange: (collapsed) => onChange({ ...axis, collapsed }) }) })
5849
+ /* @__PURE__ */ jsxs7("details", { children: [
5850
+ /* @__PURE__ */ jsx9("summary", { style: { cursor: "pointer" }, children: "Collapse members" }),
5851
+ /* @__PURE__ */ jsx9("div", { style: { paddingTop: 8 }, children: grouping && !axis.items?.length ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Apply grouping to load its members." }) : /* @__PURE__ */ jsx9(Members, { label: "Members to collapse", items: axis.items?.length ? axis.items : source?.items ?? [], selected: axis.collapsed, onChange: (collapsed) => onChange({ ...axis, collapsed }) }) })
5762
5852
  ] })
5763
5853
  ] });
5764
5854
  }
@@ -5770,116 +5860,116 @@ function FieldFilters({ editor, pivot, field, axis }) {
5770
5860
  const filters = pivot.filters.map((filter, index) => ({ filter, index })).filter(({ filter }) => filter.field === field && (filter.groupingUnit ?? null) === unit);
5771
5861
  const kinds = [["members", "Select items"], ["label", "Label filter"], ["value", "Value filter"], ["top10", "Top / bottom filter"]];
5772
5862
  const update = (index, next) => editor.edit((current) => ({ ...current, filters: current.filters.flatMap((filter, position) => position === index ? next ? [next] : [] : [filter]) }));
5773
- return /* @__PURE__ */ jsxs6("div", { style: { ...stack, paddingTop: 10, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
5774
- /* @__PURE__ */ jsxs6("strong", { children: [
5863
+ return /* @__PURE__ */ jsxs7("div", { style: { ...stack, paddingTop: 10, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
5864
+ /* @__PURE__ */ jsxs7("strong", { children: [
5775
5865
  "Field filters",
5776
5866
  unit ? ` \xB7 ${unit}` : ""
5777
5867
  ] }),
5778
- filterAxis?.grouping && !filterAxis.items?.length ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Apply grouping before selecting its members." }) : null,
5779
- filters.map(({ filter, index }) => /* @__PURE__ */ jsxs6("div", { style: { ...stack, paddingBlock: 8, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
5780
- /* @__PURE__ */ jsxs6("div", { style: { ...row, justifyContent: "space-between" }, children: [
5781
- /* @__PURE__ */ jsx8("span", { children: kinds.find(([kind]) => kind === filter.kind)?.[1] }),
5782
- /* @__PURE__ */ jsx8(Action, { "aria-label": `Remove ${filter.kind} filter`, onClick: () => update(index, null), children: "\xD7" })
5868
+ filterAxis?.grouping && !filterAxis.items?.length ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Apply grouping before selecting its members." }) : null,
5869
+ filters.map(({ filter, index }) => /* @__PURE__ */ jsxs7("div", { style: { ...stack, paddingBlock: 8, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
5870
+ /* @__PURE__ */ jsxs7("div", { style: { ...row, justifyContent: "space-between" }, children: [
5871
+ /* @__PURE__ */ jsx9("span", { children: kinds.find(([kind]) => kind === filter.kind)?.[1] }),
5872
+ /* @__PURE__ */ jsx9(Action, { "aria-label": `Remove ${filter.kind} filter`, onClick: () => update(index, null), children: "\xD7" })
5783
5873
  ] }),
5784
- filter.kind === "members" ? /* @__PURE__ */ jsx8(Members, { items: members, selected: filter.values, onChange: (values) => update(index, { ...filter, values }) }) : null,
5785
- filter.kind === "label" || filter.kind === "value" ? /* @__PURE__ */ jsxs6(Fragment8, { children: [
5786
- /* @__PURE__ */ jsx8(Choice, { label: "Condition", value: filter.operator, options: filter.kind === "value" ? OPERATORS.filter(([operator]) => !/contains|begins|ends/i.test(operator)) : OPERATORS, onChange: (operator) => update(index, { ...filter, operator }) }),
5787
- /* @__PURE__ */ jsx8(Text, { label: "Value", type: filter.kind === "value" ? "number" : "text", value: filter.value, onChange: (value) => update(index, { ...filter, value }) }),
5788
- filter.operator === "between" || filter.operator === "notBetween" ? /* @__PURE__ */ jsx8(Text, { label: "And", type: filter.kind === "value" ? "number" : "text", value: filter.value2, onChange: (value2) => update(index, { ...filter, value2 }) }) : null
5874
+ filter.kind === "members" ? /* @__PURE__ */ jsx9(Members, { items: members, selected: filter.values, onChange: (values) => update(index, { ...filter, values }) }) : null,
5875
+ filter.kind === "label" || filter.kind === "value" ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
5876
+ /* @__PURE__ */ jsx9(Choice, { label: "Condition", value: filter.operator, options: filter.kind === "value" ? OPERATORS.filter(([operator]) => !/contains|begins|ends/i.test(operator)) : OPERATORS, onChange: (operator) => update(index, { ...filter, operator }) }),
5877
+ /* @__PURE__ */ jsx9(Text, { label: "Value", type: filter.kind === "value" ? "number" : "text", value: filter.value, onChange: (value) => update(index, { ...filter, value }) }),
5878
+ filter.operator === "between" || filter.operator === "notBetween" ? /* @__PURE__ */ jsx9(Text, { label: "And", type: filter.kind === "value" ? "number" : "text", value: filter.value2, onChange: (value2) => update(index, { ...filter, value2 }) }) : null
5789
5879
  ] }) : null,
5790
- filter.kind === "top10" ? /* @__PURE__ */ jsxs6(Fragment8, { children: [
5791
- /* @__PURE__ */ jsx8(Choice, { label: "Show", value: filter.top ? "top" : "bottom", options: [["top", "Top"], ["bottom", "Bottom"]], onChange: (top) => update(index, { ...filter, top: top === "top" }) }),
5792
- /* @__PURE__ */ jsx8(Text, { label: "Amount", type: "number", min: 1, value: String(filter.count), onChange: (count) => update(index, { ...filter, count: Number(count) }) }),
5793
- /* @__PURE__ */ jsx8(Choice, { label: "Unit", value: filter.percent ? "percent" : "items", options: [["items", "Items"], ["percent", "Percent"]], onChange: (percent) => update(index, { ...filter, percent: percent === "percent" }) })
5880
+ filter.kind === "top10" ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
5881
+ /* @__PURE__ */ jsx9(Choice, { label: "Show", value: filter.top ? "top" : "bottom", options: [["top", "Top"], ["bottom", "Bottom"]], onChange: (top) => update(index, { ...filter, top: top === "top" }) }),
5882
+ /* @__PURE__ */ jsx9(Text, { label: "Amount", type: "number", min: 1, value: String(filter.count), onChange: (count) => update(index, { ...filter, count: Number(count) }) }),
5883
+ /* @__PURE__ */ jsx9(Choice, { label: "Unit", value: filter.percent ? "percent" : "items", options: [["items", "Items"], ["percent", "Percent"]], onChange: (percent) => update(index, { ...filter, percent: percent === "percent" }) })
5794
5884
  ] }) : null,
5795
- filter.kind === "value" || filter.kind === "top10" ? /* @__PURE__ */ jsx8(Choice, { label: "By value", value: String(filter.measure), options: pivot.values.map((value, position) => [String(position), value.name]), onChange: (measure) => update(index, { ...filter, measure: Number(measure) }) }) : null
5885
+ filter.kind === "value" || filter.kind === "top10" ? /* @__PURE__ */ jsx9(Choice, { label: "By value", value: String(filter.measure), options: pivot.values.map((value, position) => [String(position), value.name]), onChange: (measure) => update(index, { ...filter, measure: Number(measure) }) }) : null
5796
5886
  ] }, index)),
5797
- /* @__PURE__ */ jsx8(Choice, { label: "Add filter", value: "", placeholder: "Choose a filter", options: kinds.filter(([kind]) => !filters.some(({ filter }) => filter.kind === kind)), onChange: (kind) => editor.edit((current) => ({ ...current, filters: [...current.filters, { field, groupingUnit: unit, kind, values: kind === "members" ? members.map((member) => member.key) : [], operator: "equal", value: "", value2: "", measure: 0, top: true, count: 10, percent: false }] })) })
5887
+ /* @__PURE__ */ jsx9(Choice, { label: "Add filter", value: "", placeholder: "Choose a filter", options: kinds.filter(([kind]) => !filters.some(({ filter }) => filter.kind === kind)), onChange: (kind) => editor.edit((current) => ({ ...current, filters: [...current.filters, { field, groupingUnit: unit, kind, values: kind === "members" ? members.map((member) => member.key) : [], operator: "equal", value: "", value2: "", measure: 0, top: true, count: 10, percent: false }] })) })
5798
5888
  ] });
5799
5889
  }
5800
5890
  function Advanced({ editor, pivot }) {
5801
- const [chartType, setChartType] = React11.useState("ColumnClustered");
5802
- const [chartCell, setChartCell] = React11.useState("I2");
5803
- const [chartTitle, setChartTitle] = React11.useState("");
5804
- const [chartMeasure, setChartMeasure] = React11.useState("");
5805
- const [chartSheet, setChartSheet] = React11.useState("");
5806
- const [chartWidth, setChartWidth] = React11.useState("560");
5807
- const [chartHeight, setChartHeight] = React11.useState("340");
5891
+ const [chartType, setChartType] = React12.useState("ColumnClustered");
5892
+ const [chartCell, setChartCell] = React12.useState("I2");
5893
+ const [chartTitle, setChartTitle] = React12.useState("");
5894
+ const [chartMeasure, setChartMeasure] = React12.useState("");
5895
+ const [chartSheet, setChartSheet] = React12.useState("");
5896
+ const [chartWidth, setChartWidth] = React12.useState("560");
5897
+ const [chartHeight, setChartHeight] = React12.useState("340");
5808
5898
  const update = (patch) => editor.edit((current) => ({ ...current, ...patch }));
5809
5899
  const sheets = editor.viewer.sheets.map((sheet) => [sheet.name, sheet.name]);
5810
- return /* @__PURE__ */ jsxs6(Fragment8, { children: [
5811
- /* @__PURE__ */ jsxs6(Section, { title: "Source and location", children: [
5812
- /* @__PURE__ */ jsx8(Text, { label: "PivotTable name", value: pivot.name, onChange: (name) => update({ name }) }),
5813
- /* @__PURE__ */ jsx8(Choice, { label: "Source worksheet", value: pivot.source.sheet, options: sheets, onChange: (sheet) => update({ source: { ...pivot.source, sheet } }) }),
5814
- /* @__PURE__ */ jsx8(Text, { label: "Source range", value: pivot.source.range, onChange: (range) => update({ source: { ...pivot.source, range } }) }),
5815
- /* @__PURE__ */ jsx8(Text, { label: "Source table name (optional)", value: pivot.source.table ?? "", onChange: (table) => update({ source: { ...pivot.source, table: table || null } }) }),
5816
- /* @__PURE__ */ jsx8(Action, { onClick: editor.readFields, children: "Load source fields" }),
5817
- /* @__PURE__ */ jsx8(Choice, { label: "Destination worksheet", value: pivot.target.sheet, options: sheets, onChange: (sheet) => update({ target: { ...pivot.target, sheet } }) }),
5818
- /* @__PURE__ */ jsx8(Text, { label: "Destination cell", value: pivot.target.cell, onChange: (cell) => update({ target: { ...pivot.target, cell } }) })
5900
+ return /* @__PURE__ */ jsxs7(Fragment8, { children: [
5901
+ /* @__PURE__ */ jsxs7(Section, { title: "Source and location", children: [
5902
+ /* @__PURE__ */ jsx9(Text, { label: "PivotTable name", value: pivot.name, onChange: (name) => update({ name }) }),
5903
+ /* @__PURE__ */ jsx9(Choice, { label: "Source worksheet", value: pivot.source.sheet, options: sheets, onChange: (sheet) => update({ source: { ...pivot.source, sheet } }) }),
5904
+ /* @__PURE__ */ jsx9(Text, { label: "Source range", value: pivot.source.range, onChange: (range) => update({ source: { ...pivot.source, range } }) }),
5905
+ /* @__PURE__ */ jsx9(Text, { label: "Source table name (optional)", value: pivot.source.table ?? "", onChange: (table) => update({ source: { ...pivot.source, table: table || null } }) }),
5906
+ /* @__PURE__ */ jsx9(Action, { onClick: editor.readFields, children: "Load source fields" }),
5907
+ /* @__PURE__ */ jsx9(Choice, { label: "Destination worksheet", value: pivot.target.sheet, options: sheets, onChange: (sheet) => update({ target: { ...pivot.target, sheet } }) }),
5908
+ /* @__PURE__ */ jsx9(Text, { label: "Destination cell", value: pivot.target.cell, onChange: (cell) => update({ target: { ...pivot.target, cell } }) })
5819
5909
  ] }),
5820
- /* @__PURE__ */ jsxs6(Section, { title: "Layout and format", children: [
5821
- /* @__PURE__ */ jsx8(Choice, { label: "Report layout", value: pivot.layout, options: [["compact", "Compact form"], ["outline", "Outline form"], ["tabular", "Tabular form"]], onChange: (layout) => update({ layout }) }),
5822
- /* @__PURE__ */ jsx8(Choice, { label: "Multiple value fields", value: pivot.valuesOnRows ? "rows" : "columns", options: [["columns", "Show values in columns"], ["rows", "Show values in rows"]], onChange: (value) => update({ valuesOnRows: value === "rows" }) }),
5823
- /* @__PURE__ */ jsx8(Check, { label: "Repeat item labels", checked: pivot.repeatLabels, onChange: (repeatLabels) => update({ repeatLabels }) }),
5824
- /* @__PURE__ */ jsx8(Choice, { label: "Subtotals", value: pivot.subtotalsPosition, options: [["top", "At top of group"], ["bottom", "At bottom of group"], ["none", "Do not show"]], onChange: (subtotalsPosition) => update({ subtotalsPosition }) }),
5825
- /* @__PURE__ */ jsx8(Check, { label: "Grand totals for rows", checked: pivot.rowGrandTotals, onChange: (rowGrandTotals) => update({ rowGrandTotals }) }),
5826
- /* @__PURE__ */ jsx8(Check, { label: "Grand totals for columns", checked: pivot.columnGrandTotals, onChange: (columnGrandTotals) => update({ columnGrandTotals }) }),
5827
- /* @__PURE__ */ jsx8(Text, { label: "PivotTable style", value: pivot.styleName, onChange: (styleName) => update({ styleName }) }),
5828
- /* @__PURE__ */ jsx8(Check, { label: "Preserve cell formatting", checked: pivot.preserveFormatting ?? true, onChange: (preserveFormatting) => update({ preserveFormatting }) }),
5829
- /* @__PURE__ */ jsx8(Check, { label: "Refresh when opened in Excel", checked: pivot.refreshOnLoad, onChange: (refreshOnLoad) => update({ refreshOnLoad }) })
5910
+ /* @__PURE__ */ jsxs7(Section, { title: "Layout and format", children: [
5911
+ /* @__PURE__ */ jsx9(Choice, { label: "Report layout", value: pivot.layout, options: [["compact", "Compact form"], ["outline", "Outline form"], ["tabular", "Tabular form"]], onChange: (layout) => update({ layout }) }),
5912
+ /* @__PURE__ */ jsx9(Choice, { label: "Multiple value fields", value: pivot.valuesOnRows ? "rows" : "columns", options: [["columns", "Show values in columns"], ["rows", "Show values in rows"]], onChange: (value) => update({ valuesOnRows: value === "rows" }) }),
5913
+ /* @__PURE__ */ jsx9(Check, { label: "Repeat item labels", checked: pivot.repeatLabels, onChange: (repeatLabels) => update({ repeatLabels }) }),
5914
+ /* @__PURE__ */ jsx9(Choice, { label: "Subtotals", value: pivot.subtotalsPosition, options: [["top", "At top of group"], ["bottom", "At bottom of group"], ["none", "Do not show"]], onChange: (subtotalsPosition) => update({ subtotalsPosition }) }),
5915
+ /* @__PURE__ */ jsx9(Check, { label: "Grand totals for rows", checked: pivot.rowGrandTotals, onChange: (rowGrandTotals) => update({ rowGrandTotals }) }),
5916
+ /* @__PURE__ */ jsx9(Check, { label: "Grand totals for columns", checked: pivot.columnGrandTotals, onChange: (columnGrandTotals) => update({ columnGrandTotals }) }),
5917
+ /* @__PURE__ */ jsx9(Text, { label: "PivotTable style", value: pivot.styleName, onChange: (styleName) => update({ styleName }) }),
5918
+ /* @__PURE__ */ jsx9(Check, { label: "Preserve cell formatting", checked: pivot.preserveFormatting ?? true, onChange: (preserveFormatting) => update({ preserveFormatting }) }),
5919
+ /* @__PURE__ */ jsx9(Check, { label: "Refresh when opened in Excel", checked: pivot.refreshOnLoad, onChange: (refreshOnLoad) => update({ refreshOnLoad }) })
5830
5920
  ] }),
5831
- /* @__PURE__ */ jsxs6(Section, { title: "Calculated fields and items", children: [
5832
- /* @__PURE__ */ jsx8(Action, { disabled: !pivot.fields.length, onClick: () => editor.edit((current) => ({ ...current, values: [...current.values, { field: current.fields[0].index, name: `Calculated ${current.values.length + 1}`, aggregation: "sum", showAs: "normal", formula: "0" }] })), children: "Add calculated field" }),
5833
- /* @__PURE__ */ jsx8("p", { style: hint, children: "Edit the new field\u2019s formula in its Values settings." }),
5834
- /* @__PURE__ */ jsx8("p", { style: hint, children: FORMULA_HELP }),
5835
- pivot.calculatedItems.map((item, index) => /* @__PURE__ */ jsxs6("div", { style: { ...stack, paddingTop: 8, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
5836
- /* @__PURE__ */ jsx8(Choice, { label: "Field", value: String(item.field), options: pivot.fields.map((field) => [String(field.index), field.name]), onChange: (field) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, field: Number(field) } : entry) }) }),
5837
- /* @__PURE__ */ jsx8(Text, { label: "Item name", value: item.name, onChange: (name) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, name } : entry) }) }),
5838
- /* @__PURE__ */ jsx8(Text, { label: "Formula", value: item.formula, onChange: (formula) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, formula } : entry) }) }),
5839
- /* @__PURE__ */ jsx8(Action, { onClick: () => update({ calculatedItems: pivot.calculatedItems.filter((_, position) => position !== index) }), children: "Remove calculated item" })
5921
+ /* @__PURE__ */ jsxs7(Section, { title: "Calculated fields and items", children: [
5922
+ /* @__PURE__ */ jsx9(Action, { disabled: !pivot.fields.length, onClick: () => editor.edit((current) => ({ ...current, values: [...current.values, { field: current.fields[0].index, name: `Calculated ${current.values.length + 1}`, aggregation: "sum", showAs: "normal", formula: "0" }] })), children: "Add calculated field" }),
5923
+ /* @__PURE__ */ jsx9("p", { style: hint, children: "Edit the new field\u2019s formula in its Values settings." }),
5924
+ /* @__PURE__ */ jsx9("p", { style: hint, children: FORMULA_HELP }),
5925
+ pivot.calculatedItems.map((item, index) => /* @__PURE__ */ jsxs7("div", { style: { ...stack, paddingTop: 8, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
5926
+ /* @__PURE__ */ jsx9(Choice, { label: "Field", value: String(item.field), options: pivot.fields.map((field) => [String(field.index), field.name]), onChange: (field) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, field: Number(field) } : entry) }) }),
5927
+ /* @__PURE__ */ jsx9(Text, { label: "Item name", value: item.name, onChange: (name) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, name } : entry) }) }),
5928
+ /* @__PURE__ */ jsx9(Text, { label: "Formula", value: item.formula, onChange: (formula) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, formula } : entry) }) }),
5929
+ /* @__PURE__ */ jsx9(Action, { onClick: () => update({ calculatedItems: pivot.calculatedItems.filter((_, position) => position !== index) }), children: "Remove calculated item" })
5840
5930
  ] }, index)),
5841
- /* @__PURE__ */ jsx8(Action, { disabled: !pivot.fields.length, onClick: () => update({ calculatedItems: [...pivot.calculatedItems, { field: pivot.rows[0]?.field ?? pivot.fields[0].index, name: `Calculated item ${pivot.calculatedItems.length + 1}`, formula: "0" }] }), children: "Add calculated item" })
5931
+ /* @__PURE__ */ jsx9(Action, { disabled: !pivot.fields.length, onClick: () => update({ calculatedItems: [...pivot.calculatedItems, { field: pivot.rows[0]?.field ?? pivot.fields[0].index, name: `Calculated item ${pivot.calculatedItems.length + 1}`, formula: "0" }] }), children: "Add calculated item" })
5842
5932
  ] }),
5843
- /* @__PURE__ */ jsxs6(Section, { title: "PivotChart", children: [
5844
- pivot.charts?.length ? /* @__PURE__ */ jsxs6("p", { style: hint, children: [
5933
+ /* @__PURE__ */ jsxs7(Section, { title: "PivotChart", children: [
5934
+ pivot.charts?.length ? /* @__PURE__ */ jsxs7("p", { style: hint, children: [
5845
5935
  pivot.charts.length,
5846
5936
  " linked chart",
5847
5937
  pivot.charts.length === 1 ? "" : "s",
5848
5938
  ". Refreshing the PivotTable updates their values."
5849
5939
  ] }) : null,
5850
- /* @__PURE__ */ jsx8(Choice, { label: "Chart type", value: chartType, options: CHART_TYPES, onChange: (value) => setChartType(value) }),
5851
- /* @__PURE__ */ jsx8(Text, { label: "Title", value: chartTitle, placeholder: pivot.name, onChange: setChartTitle }),
5852
- /* @__PURE__ */ jsx8(Choice, { label: "Chart worksheet", value: chartSheet || pivot.target.sheet, options: sheets, onChange: setChartSheet }),
5853
- /* @__PURE__ */ jsx8(Text, { label: "Top-left cell", value: chartCell, onChange: setChartCell }),
5854
- /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
5855
- /* @__PURE__ */ jsx8(Text, { label: "Width (px)", type: "number", min: 80, max: 1e4, value: chartWidth, onChange: setChartWidth }),
5856
- /* @__PURE__ */ jsx8(Text, { label: "Height (px)", type: "number", min: 80, max: 1e4, value: chartHeight, onChange: setChartHeight })
5940
+ /* @__PURE__ */ jsx9(Choice, { label: "Chart type", value: chartType, options: CHART_TYPES, onChange: (value) => setChartType(value) }),
5941
+ /* @__PURE__ */ jsx9(Text, { label: "Title", value: chartTitle, placeholder: pivot.name, onChange: setChartTitle }),
5942
+ /* @__PURE__ */ jsx9(Choice, { label: "Chart worksheet", value: chartSheet || pivot.target.sheet, options: sheets, onChange: setChartSheet }),
5943
+ /* @__PURE__ */ jsx9(Text, { label: "Top-left cell", value: chartCell, onChange: setChartCell }),
5944
+ /* @__PURE__ */ jsxs7("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
5945
+ /* @__PURE__ */ jsx9(Text, { label: "Width (px)", type: "number", min: 80, max: 1e4, value: chartWidth, onChange: setChartWidth }),
5946
+ /* @__PURE__ */ jsx9(Text, { label: "Height (px)", type: "number", min: 80, max: 1e4, value: chartHeight, onChange: setChartHeight })
5857
5947
  ] }),
5858
- /* @__PURE__ */ jsx8(Choice, { label: "Values", value: chartMeasure, options: [["", "All value fields"], ...pivot.values.map((value, index) => [String(index), value.name])], onChange: setChartMeasure }),
5859
- chartType === "Pie" || chartType === "Doughnut" ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Pie and doughnut charts display the first series." }) : null,
5860
- /* @__PURE__ */ jsx8(Action, { disabled: !pivot.id || editor.dirty || !pivot.values.length, onClick: () => editor.run(() => {
5948
+ /* @__PURE__ */ jsx9(Choice, { label: "Values", value: chartMeasure, options: [["", "All value fields"], ...pivot.values.map((value, index) => [String(index), value.name])], onChange: setChartMeasure }),
5949
+ chartType === "Pie" || chartType === "Doughnut" ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Pie and doughnut charts display the first series." }) : null,
5950
+ /* @__PURE__ */ jsx9(Action, { disabled: !pivot.id || editor.dirty || !pivot.values.length, onClick: () => editor.run(() => {
5861
5951
  editor.viewer.createPivotChart(pivot.id, { chartType, sheet: chartSheet || pivot.target.sheet, cell: chartCell, title: chartTitle || pivot.name, width: Number(chartWidth), height: Number(chartHeight), measure: chartMeasure ? Number(chartMeasure) : null });
5862
5952
  }), children: "Insert PivotChart" }),
5863
- editor.dirty ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Apply field changes before inserting a chart." }) : null
5953
+ editor.dirty ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Apply field changes before inserting a chart." }) : null
5864
5954
  ] })
5865
5955
  ] });
5866
5956
  }
5867
5957
  function DefaultXlsxPivotTableFieldList({ editor, isDark = false, className, style }) {
5868
- const paneRef = React11.useRef(null);
5869
- const [placement, setPlacement] = React11.useState({ overlay: false, top: 0, width: 324 });
5870
- const [search, setSearch] = React11.useState("");
5871
- const [selected, setSelected] = React11.useState(null);
5872
- const [dragOver, setDragOver] = React11.useState(null);
5873
- const [announcement, setAnnouncement] = React11.useState("");
5874
- const titleId = React11.useId();
5875
- const settingsId = React11.useId();
5958
+ const paneRef = React12.useRef(null);
5959
+ const [placement, setPlacement] = React12.useState({ overlay: false, top: 0, width: 324 });
5960
+ const [search, setSearch] = React12.useState("");
5961
+ const [selected, setSelected] = React12.useState(null);
5962
+ const [dragOver, setDragOver] = React12.useState(null);
5963
+ const [announcement, setAnnouncement] = React12.useState("");
5964
+ const titleId = React12.useId();
5965
+ const settingsId = React12.useId();
5876
5966
  const pivot = editor.draft;
5877
5967
  const disabled = editor.readOnly || Boolean(pivot?.unsupportedFeatures.length) || editor.sourceNeedsLoad;
5878
- React11.useEffect(() => {
5968
+ React12.useEffect(() => {
5879
5969
  setSelected(null);
5880
5970
  setSearch("");
5881
5971
  }, [pivot?.id]);
5882
- React11.useEffect(() => {
5972
+ React12.useEffect(() => {
5883
5973
  const parent = paneRef.current?.parentElement;
5884
5974
  if (!parent) return;
5885
5975
  const viewer = parent.closest(".react-xlsx-viewer");
@@ -5936,36 +6026,36 @@ function DefaultXlsxPivotTableFieldList({ editor, isDark = false, className, sty
5936
6026
  event.dataTransfer.setData(DRAG_TYPE, JSON.stringify(data));
5937
6027
  event.dataTransfer.effectAllowed = "move";
5938
6028
  };
5939
- return /* @__PURE__ */ jsxs6("aside", { ref: paneRef, "aria-labelledby": titleId, className, style: { ...theme, boxSizing: "border-box", display: "flex", flexDirection: "column", width: placement.width, minWidth: 0, maxWidth: "100%", height: "100%", minHeight: 0, flexShrink: 0, borderInlineStart: "1px solid var(--xlsx-pivot-border)", background: "var(--xlsx-pivot-bg)", color: isDark ? "#edf2ef" : "#202a24", font: "12px/1.4 system-ui, sans-serif", ...placement.overlay ? { position: "absolute", insetInlineEnd: 0, top: placement.top, bottom: 0, height: "auto", zIndex: 20, boxShadow: "-6px 0 18px #0002" } : {}, ...style }, children: [
5940
- /* @__PURE__ */ jsxs6("header", { style: { ...row, justifyContent: "space-between", padding: "10px 12px", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: [
5941
- /* @__PURE__ */ jsx8("h2", { id: titleId, style: { margin: 0, fontSize: 16, fontWeight: 600 }, children: "PivotTable Fields" }),
5942
- /* @__PURE__ */ jsx8(Action, { "aria-label": "Close PivotTable field list", onClick: () => editor.setOpen(false), style: { border: 0, background: "transparent", fontSize: 20, lineHeight: 1, padding: "2px 6px" }, children: "\xD7" })
6029
+ return /* @__PURE__ */ jsxs7("aside", { ref: paneRef, "aria-labelledby": titleId, className, style: { ...theme, boxSizing: "border-box", display: "flex", flexDirection: "column", width: placement.width, minWidth: 0, maxWidth: "100%", height: "100%", minHeight: 0, flexShrink: 0, borderInlineStart: "1px solid var(--xlsx-pivot-border)", background: "var(--xlsx-pivot-bg)", color: isDark ? "#edf2ef" : "#202a24", font: "12px/1.4 system-ui, sans-serif", ...placement.overlay ? { position: "absolute", insetInlineEnd: 0, top: placement.top, bottom: 0, height: "auto", zIndex: 20, boxShadow: "-6px 0 18px #0002" } : {}, ...style }, children: [
6030
+ /* @__PURE__ */ jsxs7("header", { style: { ...row, justifyContent: "space-between", padding: "10px 12px", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: [
6031
+ /* @__PURE__ */ jsx9("h2", { id: titleId, style: { margin: 0, fontSize: 16, fontWeight: 600 }, children: "PivotTable Fields" }),
6032
+ /* @__PURE__ */ jsx9(Action, { "aria-label": "Close PivotTable field list", onClick: () => editor.setOpen(false), style: { border: 0, background: "transparent", fontSize: 20, lineHeight: 1, padding: "2px 6px" }, children: "\xD7" })
5943
6033
  ] }),
5944
- /* @__PURE__ */ jsxs6("div", { style: { overflowY: "auto", flex: 1, minHeight: 0 }, children: [
5945
- /* @__PURE__ */ jsxs6("div", { style: { ...stack, padding: 12 }, children: [
5946
- /* @__PURE__ */ jsxs6("div", { style: { ...row, alignItems: "end" }, children: [
5947
- /* @__PURE__ */ jsx8("div", { style: { flex: 1, minWidth: 0 }, children: /* @__PURE__ */ jsx8(Choice, { label: "PivotTable", value: pivot?.id ?? "", placeholder: pivot && !pivot.id ? pivot.name : "Choose a PivotTable", options: editor.viewer.pivotTables.map((item) => [item.id, item.name]), onChange: editor.select, disabled: editor.dirty }) }),
5948
- /* @__PURE__ */ jsx8(Action, { disabled: editor.viewer.readOnly || editor.dirty, onClick: editor.create, children: "New" })
6034
+ /* @__PURE__ */ jsxs7("div", { style: { overflowY: "auto", flex: 1, minHeight: 0 }, children: [
6035
+ /* @__PURE__ */ jsxs7("div", { style: { ...stack, padding: 12 }, children: [
6036
+ /* @__PURE__ */ jsxs7("div", { style: { ...row, alignItems: "end" }, children: [
6037
+ /* @__PURE__ */ jsx9("div", { style: { flex: 1, minWidth: 0 }, children: /* @__PURE__ */ jsx9(Choice, { label: "PivotTable", value: pivot?.id ?? "", placeholder: pivot && !pivot.id ? pivot.name : "Choose a PivotTable", options: editor.viewer.pivotTables.map((item) => [item.id, item.name]), onChange: editor.select, disabled: editor.dirty }) }),
6038
+ /* @__PURE__ */ jsx9(Action, { disabled: editor.viewer.readOnly || editor.dirty, onClick: editor.create, children: "New" })
5949
6039
  ] }),
5950
- editor.error ? /* @__PURE__ */ jsx8("p", { role: "alert", style: { margin: 0, color: isDark ? "#ffb7b0" : "#a12622", overflowWrap: "anywhere" }, children: editor.error }) : null,
5951
- editor.status ? /* @__PURE__ */ jsx8("p", { role: "status", style: hint, children: editor.status }) : null,
5952
- editor.stale ? /* @__PURE__ */ jsx8("p", { role: "alert", style: hint, children: "The worksheet changed while you were editing. Discard these changes to load the current PivotTable." }) : null,
5953
- editor.sourceNeedsLoad ? /* @__PURE__ */ jsx8("p", { role: "status", style: hint, children: "The source changed. Load its fields under Source and location." }) : null,
5954
- pivot?.unsupportedFeatures.length ? /* @__PURE__ */ jsxs6("p", { style: hint, children: [
6040
+ editor.error ? /* @__PURE__ */ jsx9("p", { role: "alert", style: { margin: 0, color: isDark ? "#ffb7b0" : "#a12622", overflowWrap: "anywhere" }, children: editor.error }) : null,
6041
+ editor.status ? /* @__PURE__ */ jsx9("p", { role: "status", style: hint, children: editor.status }) : null,
6042
+ editor.stale ? /* @__PURE__ */ jsx9("p", { role: "alert", style: hint, children: "The worksheet changed while you were editing. Discard these changes to load the current PivotTable." }) : null,
6043
+ editor.sourceNeedsLoad ? /* @__PURE__ */ jsx9("p", { role: "status", style: hint, children: "The source changed. Load its fields under Source and location." }) : null,
6044
+ pivot?.unsupportedFeatures.length ? /* @__PURE__ */ jsxs7("p", { style: hint, children: [
5955
6045
  "This PivotTable is preserved for Excel. Editing is unavailable for: ",
5956
6046
  pivot.unsupportedFeatures.join(", "),
5957
6047
  "."
5958
6048
  ] }) : null,
5959
- editor.viewer.readOnly ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Enable workbook editing to change this PivotTable." }) : null
6049
+ editor.viewer.readOnly ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Enable workbook editing to change this PivotTable." }) : null
5960
6050
  ] }),
5961
- pivot ? /* @__PURE__ */ jsxs6(Fragment8, { children: [
5962
- /* @__PURE__ */ jsxs6("fieldset", { disabled, style: { margin: 0, padding: "0 12px 12px", border: 0, minWidth: 0 }, children: [
5963
- /* @__PURE__ */ jsx8("legend", { style: { padding: 0, fontWeight: 600, marginBottom: 8 }, children: "Choose fields to add to report" }),
5964
- /* @__PURE__ */ jsx8("input", { "aria-label": "Search PivotTable fields", type: "search", placeholder: "Search fields", value: search, onChange: (event) => setSearch(event.target.value), style: { ...control, marginBottom: 6 } }),
5965
- /* @__PURE__ */ jsxs6("div", { role: "group", "aria-label": "Source fields", style: { maxHeight: 190, overflowY: "auto", border: "1px solid var(--xlsx-pivot-border)", padding: "5px 7px", background: "var(--xlsx-pivot-input)" }, children: [
6051
+ pivot ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
6052
+ /* @__PURE__ */ jsxs7("fieldset", { disabled, style: { margin: 0, padding: "0 12px 12px", border: 0, minWidth: 0 }, children: [
6053
+ /* @__PURE__ */ jsx9("legend", { style: { padding: 0, fontWeight: 600, marginBottom: 8 }, children: "Choose fields to add to report" }),
6054
+ /* @__PURE__ */ jsx9("input", { "aria-label": "Search PivotTable fields", type: "search", placeholder: "Search fields", value: search, onChange: (event) => setSearch(event.target.value), style: { ...control, marginBottom: 6 } }),
6055
+ /* @__PURE__ */ jsxs7("div", { role: "group", "aria-label": "Source fields", style: { maxHeight: 190, overflowY: "auto", border: "1px solid var(--xlsx-pivot-border)", padding: "5px 7px", background: "var(--xlsx-pivot-input)" }, children: [
5966
6056
  pivot.fields.filter((field) => field.name.toLocaleLowerCase().includes(search.toLocaleLowerCase())).map((field) => {
5967
6057
  const checked = AREAS.some((area) => pivot[area].some((_, index) => sourceFieldIndex(pivot, area, index) === field.index));
5968
- return /* @__PURE__ */ jsx8("div", { draggable: !disabled, onDragStart: (event) => drag(event, { field: field.index }), style: { padding: "2px 0" }, children: /* @__PURE__ */ jsx8(Check, { label: field.name, checked, onChange: (value) => {
6058
+ return /* @__PURE__ */ jsx9("div", { draggable: !disabled, onDragStart: (event) => drag(event, { field: field.index }), style: { padding: "2px 0" }, children: /* @__PURE__ */ jsx9(Check, { label: field.name, checked, onChange: (value) => {
5969
6059
  if (value) editor.addField(field.dataType === "number" ? "values" : "rows", field.index);
5970
6060
  else {
5971
6061
  for (const area of AREAS) for (let index = pivot[area].length - 1; index >= 0; index--) if (sourceFieldIndex(pivot, area, index) === field.index) editor.removeField(area, index);
@@ -5974,10 +6064,10 @@ function DefaultXlsxPivotTableFieldList({ editor, isDark = false, className, sty
5974
6064
  setSelected(null);
5975
6065
  } }) }, field.index);
5976
6066
  }),
5977
- !pivot.fields.length ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Load source fields to begin." }) : !pivot.fields.some((field) => field.name.toLocaleLowerCase().includes(search.toLocaleLowerCase())) ? /* @__PURE__ */ jsx8("p", { style: hint, children: "No matching fields." }) : null
6067
+ !pivot.fields.length ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Load source fields to begin." }) : !pivot.fields.some((field) => field.name.toLocaleLowerCase().includes(search.toLocaleLowerCase())) ? /* @__PURE__ */ jsx9("p", { style: hint, children: "No matching fields." }) : null
5978
6068
  ] }),
5979
- /* @__PURE__ */ jsx8("p", { style: { ...hint, marginBlock: "10px 6px" }, children: "Drag fields between the areas below." }),
5980
- /* @__PURE__ */ jsx8("div", { style: { display: "grid", gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1fr)", gap: 8 }, children: AREAS.map((area) => /* @__PURE__ */ jsxs6("section", { "aria-label": `${AREA_NAMES[area]} fields`, onDragOver: (event) => {
6069
+ /* @__PURE__ */ jsx9("p", { style: { ...hint, marginBlock: "10px 6px" }, children: "Drag fields between the areas below." }),
6070
+ /* @__PURE__ */ jsx9("div", { style: { display: "grid", gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1fr)", gap: 8 }, children: AREAS.map((area) => /* @__PURE__ */ jsxs7("section", { "aria-label": `${AREA_NAMES[area]} fields`, onDragOver: (event) => {
5981
6071
  if (!disabled && event.dataTransfer.types.includes(DRAG_TYPE)) {
5982
6072
  event.preventDefault();
5983
6073
  setDragOver(area);
@@ -5985,100 +6075,100 @@ function DefaultXlsxPivotTableFieldList({ editor, isDark = false, className, sty
5985
6075
  }, onDragLeave: (event) => {
5986
6076
  if (!event.currentTarget.contains(event.relatedTarget)) setDragOver(null);
5987
6077
  }, onDrop: (event) => drop(event, area), style: { minHeight: 94, minWidth: 0, border: `1px solid ${dragOver === area ? "var(--xlsx-pivot-accent)" : "var(--xlsx-pivot-border)"}`, background: dragOver === area ? "var(--xlsx-pivot-hover)" : "var(--xlsx-pivot-input)" }, children: [
5988
- /* @__PURE__ */ jsxs6("h3", { style: { margin: 0, padding: "5px 6px", fontSize: 11, fontWeight: 600, borderBottom: "1px solid var(--xlsx-pivot-border)", background: "var(--xlsx-pivot-bg)" }, children: [
6078
+ /* @__PURE__ */ jsxs7("h3", { style: { margin: 0, padding: "5px 6px", fontSize: 11, fontWeight: 600, borderBottom: "1px solid var(--xlsx-pivot-border)", background: "var(--xlsx-pivot-bg)" }, children: [
5989
6079
  area === "values" ? "\u03A3 " : "",
5990
6080
  AREA_NAMES[area]
5991
6081
  ] }),
5992
- /* @__PURE__ */ jsxs6("div", { style: { padding: 4 }, children: [
6082
+ /* @__PURE__ */ jsxs7("div", { style: { padding: 4 }, children: [
5993
6083
  pivot[area].map((_, index) => {
5994
6084
  const field = fieldIndex(pivot, area, index);
5995
6085
  const name = area === "values" ? pivot.values[index].name : area === "reportFilters" ? fieldName(pivot, field) : pivot[area][index].name || fieldName(pivot, field);
5996
6086
  const active = selected?.area === area && selected.index === index;
5997
- return /* @__PURE__ */ jsx8("div", { draggable: !disabled, onDragStart: (event) => drag(event, { area, index }), onDrop: (event) => drop(event, area, index), style: { marginBottom: 3 }, children: /* @__PURE__ */ jsxs6("button", { type: "button", "aria-expanded": active, "aria-controls": settingsId, title: `${name} settings. Alt+Up or Alt+Down reorders the field.`, onClick: () => setSelected(active ? null : { area, index }), onKeyDown: (event) => {
6087
+ return /* @__PURE__ */ jsx9("div", { draggable: !disabled, onDragStart: (event) => drag(event, { area, index }), onDrop: (event) => drop(event, area, index), style: { marginBottom: 3 }, children: /* @__PURE__ */ jsxs7("button", { type: "button", "aria-expanded": active, "aria-controls": settingsId, title: `${name} settings. Alt+Up or Alt+Down reorders the field.`, onClick: () => setSelected(active ? null : { area, index }), onKeyDown: (event) => {
5998
6088
  if (!event.altKey || !["ArrowUp", "ArrowDown"].includes(event.key)) return;
5999
6089
  event.preventDefault();
6000
6090
  const position = index + (event.key === "ArrowUp" ? -1 : 1);
6001
6091
  if (position >= 0 && position < pivot[area].length) move({ area, index }, area, position);
6002
6092
  }, style: { ...control, ...row, textAlign: "start", justifyContent: "space-between", background: active ? "var(--xlsx-pivot-hover)" : "var(--xlsx-pivot-bg)", padding: "4px 5px", cursor: "pointer", fontSize: 11 }, children: [
6003
- /* @__PURE__ */ jsx8("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: name }),
6004
- /* @__PURE__ */ jsx8("span", { "aria-hidden": "true", children: "\u25BE" })
6093
+ /* @__PURE__ */ jsx9("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: name }),
6094
+ /* @__PURE__ */ jsx9("span", { "aria-hidden": "true", children: "\u25BE" })
6005
6095
  ] }) }, `${field}-${index}`);
6006
6096
  }),
6007
- !pivot[area].length ? /* @__PURE__ */ jsx8("p", { style: { ...hint, padding: "5px 3px", fontSize: 10 }, children: "Drop fields here" }) : null
6097
+ !pivot[area].length ? /* @__PURE__ */ jsx9("p", { style: { ...hint, padding: "5px 3px", fontSize: 10 }, children: "Drop fields here" }) : null
6008
6098
  ] })
6009
6099
  ] }, area)) }),
6010
- /* @__PURE__ */ jsx8("p", { style: { ...hint, marginTop: 6 }, children: "Select a field for settings and keyboard move controls." }),
6011
- selected && selectedField !== void 0 ? /* @__PURE__ */ jsxs6("section", { id: settingsId, "aria-label": "Field settings", style: { ...stack, marginTop: 12, paddingTop: 10, borderTop: "2px solid var(--xlsx-pivot-accent)" }, children: [
6012
- /* @__PURE__ */ jsxs6("div", { style: { ...row, justifyContent: "space-between" }, children: [
6013
- /* @__PURE__ */ jsxs6("strong", { style: { overflowWrap: "anywhere" }, children: [
6100
+ /* @__PURE__ */ jsx9("p", { style: { ...hint, marginTop: 6 }, children: "Select a field for settings and keyboard move controls." }),
6101
+ selected && selectedField !== void 0 ? /* @__PURE__ */ jsxs7("section", { id: settingsId, "aria-label": "Field settings", style: { ...stack, marginTop: 12, paddingTop: 10, borderTop: "2px solid var(--xlsx-pivot-accent)" }, children: [
6102
+ /* @__PURE__ */ jsxs7("div", { style: { ...row, justifyContent: "space-between" }, children: [
6103
+ /* @__PURE__ */ jsxs7("strong", { style: { overflowWrap: "anywhere" }, children: [
6014
6104
  selected.area === "values" ? pivot.values[selected.index].name : fieldName(pivot, selectedField),
6015
6105
  " settings"
6016
6106
  ] }),
6017
- /* @__PURE__ */ jsx8(Action, { "aria-label": "Close field settings", onClick: () => setSelected(null), children: "\xD7" })
6107
+ /* @__PURE__ */ jsx9(Action, { "aria-label": "Close field settings", onClick: () => setSelected(null), children: "\xD7" })
6018
6108
  ] }),
6019
- selectedCalculated ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Calculated fields stay in the Values area." }) : /* @__PURE__ */ jsx8(Choice, { label: "Move to", value: selected.area, options: AREAS.map((area) => [area, AREA_NAMES[area]]), onChange: (area) => move(selected, area) }),
6020
- /* @__PURE__ */ jsxs6("div", { style: { ...row, flexWrap: "wrap" }, children: [
6021
- /* @__PURE__ */ jsx8(Action, { disabled: selected.index === 0, onClick: () => move(selected, selected.area, selected.index - 1), children: "Move up" }),
6022
- /* @__PURE__ */ jsx8(Action, { disabled: selected.index === pivot[selected.area].length - 1, onClick: () => move(selected, selected.area, selected.index + 1), children: "Move down" }),
6023
- /* @__PURE__ */ jsx8(Action, { onClick: () => {
6109
+ selectedCalculated ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Calculated fields stay in the Values area." }) : /* @__PURE__ */ jsx9(Choice, { label: "Move to", value: selected.area, options: AREAS.map((area) => [area, AREA_NAMES[area]]), onChange: (area) => move(selected, area) }),
6110
+ /* @__PURE__ */ jsxs7("div", { style: { ...row, flexWrap: "wrap" }, children: [
6111
+ /* @__PURE__ */ jsx9(Action, { disabled: selected.index === 0, onClick: () => move(selected, selected.area, selected.index - 1), children: "Move up" }),
6112
+ /* @__PURE__ */ jsx9(Action, { disabled: selected.index === pivot[selected.area].length - 1, onClick: () => move(selected, selected.area, selected.index + 1), children: "Move down" }),
6113
+ /* @__PURE__ */ jsx9(Action, { onClick: () => {
6024
6114
  editor.removeField(selected.area, selected.index);
6025
6115
  setSelected(null);
6026
6116
  }, children: "Remove field" })
6027
6117
  ] }),
6028
- selected.area === "values" ? /* @__PURE__ */ jsx8(ValueSettings, { pivot, value: pivot.values[selected.index], onChange: (value) => editor.edit((current) => ({ ...current, values: current.values.map((item, index) => index === selected.index ? value : item) })) }) : selected.area === "rows" || selected.area === "columns" ? /* @__PURE__ */ jsx8(AxisSettings, { pivot, axis: pivot[selected.area][selected.index], onChange: (axis) => editor.edit((current) => ({ ...current, [selected.area]: current[selected.area].map((item, index) => index === selected.index ? axis : item) })), onAddDateLevel: (unit) => editor.edit((current) => {
6118
+ selected.area === "values" ? /* @__PURE__ */ jsx9(ValueSettings, { pivot, value: pivot.values[selected.index], onChange: (value) => editor.edit((current) => ({ ...current, values: current.values.map((item, index) => index === selected.index ? value : item) })) }) : selected.area === "rows" || selected.area === "columns" ? /* @__PURE__ */ jsx9(AxisSettings, { pivot, axis: pivot[selected.area][selected.index], onChange: (axis) => editor.edit((current) => ({ ...current, [selected.area]: current[selected.area].map((item, index) => index === selected.index ? axis : item) })), onAddDateLevel: (unit) => editor.edit((current) => {
6029
6119
  const area = selected.area;
6030
6120
  const axis = current[area][selected.index];
6031
6121
  return { ...current, [area]: [...current[area].slice(0, selected.index + 1), { ...axis, name: unit[0].toUpperCase() + unit.slice(1), grouping: { ...axis.grouping, kind: "date", unit }, items: [], collapsed: [] }, ...current[area].slice(selected.index + 1)] };
6032
6122
  }) }) : null,
6033
- selected.area !== "values" ? /* @__PURE__ */ jsx8(FieldFilters, { editor, pivot, field: selectedField, axis: selected.area === "rows" || selected.area === "columns" ? pivot[selected.area][selected.index] : void 0 }) : null
6123
+ selected.area !== "values" ? /* @__PURE__ */ jsx9(FieldFilters, { editor, pivot, field: selectedField, axis: selected.area === "rows" || selected.area === "columns" ? pivot[selected.area][selected.index] : void 0 }) : null
6034
6124
  ] }) : null
6035
6125
  ] }),
6036
- /* @__PURE__ */ jsx8("fieldset", { disabled: editor.readOnly || Boolean(pivot.unsupportedFeatures.length), style: { margin: 0, padding: 0, minWidth: 0, border: 0 }, children: /* @__PURE__ */ jsx8(Advanced, { editor, pivot }) }),
6037
- /* @__PURE__ */ jsxs6(Section, { title: "Refresh and details", children: [
6038
- /* @__PURE__ */ jsxs6("div", { style: { ...row, flexWrap: "wrap" }, children: [
6039
- /* @__PURE__ */ jsx8(Action, { disabled: disabled || editor.dirty || !pivot.id, onClick: () => editor.refresh(), children: "Refresh" }),
6040
- /* @__PURE__ */ jsx8(Action, { disabled: editor.readOnly || editor.dirty || !editor.viewer.pivotTables.length, onClick: () => editor.refresh(true), children: "Refresh all" }),
6041
- /* @__PURE__ */ jsx8(Action, { disabled: disabled || editor.dirty || !pivot.id, onClick: editor.showDetails, children: "Show details" })
6126
+ /* @__PURE__ */ jsx9("fieldset", { disabled: editor.readOnly || Boolean(pivot.unsupportedFeatures.length), style: { margin: 0, padding: 0, minWidth: 0, border: 0 }, children: /* @__PURE__ */ jsx9(Advanced, { editor, pivot }) }),
6127
+ /* @__PURE__ */ jsxs7(Section, { title: "Refresh and details", children: [
6128
+ /* @__PURE__ */ jsxs7("div", { style: { ...row, flexWrap: "wrap" }, children: [
6129
+ /* @__PURE__ */ jsx9(Action, { disabled: disabled || editor.dirty || !pivot.id, onClick: () => editor.refresh(), children: "Refresh" }),
6130
+ /* @__PURE__ */ jsx9(Action, { disabled: editor.readOnly || editor.dirty || !editor.viewer.pivotTables.length, onClick: () => editor.refresh(true), children: "Refresh all" }),
6131
+ /* @__PURE__ */ jsx9(Action, { disabled: disabled || editor.dirty || !pivot.id, onClick: editor.showDetails, children: "Show details" })
6042
6132
  ] }),
6043
- /* @__PURE__ */ jsx8("p", { style: hint, children: "Select a value cell in the report to inspect its source records." }),
6044
- editor.details ? /* @__PURE__ */ jsxs6(Fragment8, { children: [
6045
- /* @__PURE__ */ jsxs6("div", { style: { ...row, justifyContent: "space-between" }, children: [
6046
- /* @__PURE__ */ jsxs6("span", { children: [
6133
+ /* @__PURE__ */ jsx9("p", { style: hint, children: "Select a value cell in the report to inspect its source records." }),
6134
+ editor.details ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
6135
+ /* @__PURE__ */ jsxs7("div", { style: { ...row, justifyContent: "space-between" }, children: [
6136
+ /* @__PURE__ */ jsxs7("span", { children: [
6047
6137
  editor.details.rows.length.toLocaleString(),
6048
6138
  " records"
6049
6139
  ] }),
6050
- /* @__PURE__ */ jsx8(Action, { onClick: editor.clearDetails, children: "Close details" })
6140
+ /* @__PURE__ */ jsx9(Action, { onClick: editor.clearDetails, children: "Close details" })
6051
6141
  ] }),
6052
- /* @__PURE__ */ jsx8("div", { style: { maxHeight: 210, overflow: "auto", border: "1px solid var(--xlsx-pivot-border)" }, children: /* @__PURE__ */ jsxs6("table", { style: { borderCollapse: "collapse", fontSize: 11 }, children: [
6053
- /* @__PURE__ */ jsx8("thead", { children: /* @__PURE__ */ jsx8("tr", { children: editor.details.fields.map((field, index) => /* @__PURE__ */ jsx8("th", { scope: "col", style: { padding: "5px 7px", textAlign: "start", whiteSpace: "nowrap", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: field }, index)) }) }),
6054
- /* @__PURE__ */ jsx8("tbody", { children: editor.details.rows.slice(0, 100).map((record, index) => /* @__PURE__ */ jsx8("tr", { children: record.map((value, column) => /* @__PURE__ */ jsx8("td", { style: { padding: "4px 7px", whiteSpace: "nowrap", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: value == null ? "" : String(value) }, column)) }, index)) })
6142
+ /* @__PURE__ */ jsx9("div", { style: { maxHeight: 210, overflow: "auto", border: "1px solid var(--xlsx-pivot-border)" }, children: /* @__PURE__ */ jsxs7("table", { style: { borderCollapse: "collapse", fontSize: 11 }, children: [
6143
+ /* @__PURE__ */ jsx9("thead", { children: /* @__PURE__ */ jsx9("tr", { children: editor.details.fields.map((field, index) => /* @__PURE__ */ jsx9("th", { scope: "col", style: { padding: "5px 7px", textAlign: "start", whiteSpace: "nowrap", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: field }, index)) }) }),
6144
+ /* @__PURE__ */ jsx9("tbody", { children: editor.details.rows.slice(0, 100).map((record, index) => /* @__PURE__ */ jsx9("tr", { children: record.map((value, column) => /* @__PURE__ */ jsx9("td", { style: { padding: "4px 7px", whiteSpace: "nowrap", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: value == null ? "" : String(value) }, column)) }, index)) })
6055
6145
  ] }) }),
6056
- editor.details.rows.length > 100 ? /* @__PURE__ */ jsx8("p", { style: hint, children: "Showing the first 100 records. Create a detail worksheet to see all records." }) : null,
6057
- /* @__PURE__ */ jsx8(Action, { disabled: editor.readOnly || !editor.detailContext, onClick: () => editor.run(() => {
6146
+ editor.details.rows.length > 100 ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Showing the first 100 records. Create a detail worksheet to see all records." }) : null,
6147
+ /* @__PURE__ */ jsx9(Action, { disabled: editor.readOnly || !editor.detailContext, onClick: () => editor.run(() => {
6058
6148
  const context = editor.detailContext;
6059
6149
  if (context) editor.viewer.showPivotDetails(context.id, context.row, context.col);
6060
6150
  }), children: "Create detail worksheet" })
6061
6151
  ] }) : null,
6062
- /* @__PURE__ */ jsx8(Action, { disabled: editor.readOnly || editor.dirty || !pivot.id, onClick: editor.remove, children: "Remove PivotTable" })
6152
+ /* @__PURE__ */ jsx9(Action, { disabled: editor.readOnly || editor.dirty || !pivot.id, onClick: editor.remove, children: "Remove PivotTable" })
6063
6153
  ] })
6064
- ] }) : /* @__PURE__ */ jsxs6("div", { style: { ...stack, padding: "4px 12px 20px" }, children: [
6065
- /* @__PURE__ */ jsx8("p", { style: hint, children: "Select a PivotTable cell to arrange its fields, or create a PivotTable from the selected data." }),
6066
- /* @__PURE__ */ jsx8(Action, { primary: true, disabled: editor.readOnly || !editor.viewer.activeSheet, onClick: editor.create, children: "Create PivotTable" })
6154
+ ] }) : /* @__PURE__ */ jsxs7("div", { style: { ...stack, padding: "4px 12px 20px" }, children: [
6155
+ /* @__PURE__ */ jsx9("p", { style: hint, children: "Select a PivotTable cell to arrange its fields, or create a PivotTable from the selected data." }),
6156
+ /* @__PURE__ */ jsx9(Action, { primary: true, disabled: editor.readOnly || !editor.viewer.activeSheet, onClick: editor.create, children: "Create PivotTable" })
6067
6157
  ] })
6068
6158
  ] }),
6069
- pivot ? /* @__PURE__ */ jsx8("footer", { style: { ...stack, gap: 7, padding: "10px 12px", borderTop: "1px solid var(--xlsx-pivot-border)" }, children: /* @__PURE__ */ jsxs6("div", { style: { ...row, justifyContent: "space-between" }, children: [
6070
- /* @__PURE__ */ jsx8("span", { style: hint, children: editor.dirty ? "Changes pending" : "Report is up to date" }),
6071
- /* @__PURE__ */ jsxs6("div", { style: row, children: [
6072
- /* @__PURE__ */ jsx8(Action, { disabled: !editor.dirty, onClick: editor.reset, children: "Discard" }),
6073
- /* @__PURE__ */ jsx8(Action, { primary: true, disabled: disabled || !editor.dirty || editor.stale, onClick: editor.apply, children: "Apply" })
6159
+ pivot ? /* @__PURE__ */ jsx9("footer", { style: { ...stack, gap: 7, padding: "10px 12px", borderTop: "1px solid var(--xlsx-pivot-border)" }, children: /* @__PURE__ */ jsxs7("div", { style: { ...row, justifyContent: "space-between" }, children: [
6160
+ /* @__PURE__ */ jsx9("span", { style: hint, children: editor.dirty ? "Changes pending" : "Report is up to date" }),
6161
+ /* @__PURE__ */ jsxs7("div", { style: row, children: [
6162
+ /* @__PURE__ */ jsx9(Action, { disabled: !editor.dirty, onClick: editor.reset, children: "Discard" }),
6163
+ /* @__PURE__ */ jsx9(Action, { primary: true, disabled: disabled || !editor.dirty || editor.stale, onClick: editor.apply, children: "Apply" })
6074
6164
  ] })
6075
6165
  ] }) }) : null,
6076
- /* @__PURE__ */ jsx8("span", { role: "status", "aria-live": "polite", style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)", whiteSpace: "nowrap" }, children: announcement })
6166
+ /* @__PURE__ */ jsx9("span", { role: "status", "aria-live": "polite", style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)", whiteSpace: "nowrap" }, children: announcement })
6077
6167
  ] });
6078
6168
  }
6079
6169
 
6080
6170
  // src/lazy-chart.tsx
6081
- import * as React13 from "react";
6171
+ import * as React14 from "react";
6082
6172
 
6083
6173
  // src/chart-loader.ts
6084
6174
  function createChartModule(importModule) {
@@ -6109,15 +6199,15 @@ function createChartModule(importModule) {
6109
6199
  };
6110
6200
  }
6111
6201
  var officeChartRenderer = createChartModule(async () => {
6112
- const { SharedChartSvg } = await import("./shared-chart-V24MOVXX.js");
6202
+ const { SharedChartSvg } = await import("./shared-chart-24MCGSFJ.js");
6113
6203
  return { renderer: null, SharedChartSvg };
6114
6204
  });
6115
6205
 
6116
6206
  // src/use-chart-module.ts
6117
- import * as React12 from "react";
6207
+ import * as React13 from "react";
6118
6208
 
6119
6209
  // src/lazy-chart.tsx
6120
- import { Fragment as Fragment9, jsx as jsx9 } from "react/jsx-runtime";
6210
+ import { Fragment as Fragment9, jsx as jsx10 } from "react/jsx-runtime";
6121
6211
 
6122
6212
  // src/picture-paint.ts
6123
6213
  function resolvePicturePaintRect(image, rect) {
@@ -6134,13 +6224,13 @@ function resolvePicturePaintRect(image, rect) {
6134
6224
  }
6135
6225
 
6136
6226
  // src/XlsxViewer.tsx
6137
- import { Fragment as Fragment11, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
6227
+ import { Fragment as Fragment11, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
6138
6228
  var DEFAULT_ROW_HEIGHT2 = 24;
6139
6229
  var DEFAULT_COL_WIDTH2 = 80;
6140
6230
  var MAX_AUTOFIT_ROW_HEIGHT_PX = 409 * (4 / 3);
6141
6231
  var HEADER_HEIGHT = 24;
6142
6232
  var ROW_HEADER_WIDTH = 40;
6143
- var CANVAS_RESIZE_HIT_SLOP_PX = 8;
6233
+ var HEADER_RESIZE_HANDLE_PX = 8;
6144
6234
  var CANVAS_VIEWPORT_OVERSCAN_PX = 480;
6145
6235
  var CANVAS_SCROLL_BUFFER_PX = 480;
6146
6236
  var CANVAS_DEFERRED_VIEWPORT_SYNC_THRESHOLD_PX = CANVAS_SCROLL_BUFFER_PX - 96;
@@ -6808,10 +6898,10 @@ function lightenColor(color, ratio) {
6808
6898
  function darkenColor(color, ratio) {
6809
6899
  return mixRgbColor(color, "#000000", ratio);
6810
6900
  }
6811
- var ViewerContext = React14.createContext(null);
6812
- var ViewerAppearanceContext = React14.createContext({ isDark: false });
6901
+ var ViewerContext = React15.createContext(null);
6902
+ var ViewerAppearanceContext = React15.createContext({ isDark: false });
6813
6903
  function ReferenceRangeHandles({ color, top = true, bottom = true, left = true, right = true }) {
6814
- return /* @__PURE__ */ jsx10(Fragment11, { children: [top && "top", bottom && "bottom"].flatMap((vertical) => vertical ? [left && "left", right && "right"].map((horizontal) => horizontal ? /* @__PURE__ */ jsx10("span", { style: {
6904
+ return /* @__PURE__ */ jsx11(Fragment11, { children: [top && "top", bottom && "bottom"].flatMap((vertical) => vertical ? [left && "left", right && "right"].map((horizontal) => horizontal ? /* @__PURE__ */ jsx11("span", { style: {
6815
6905
  position: "absolute",
6816
6906
  [vertical]: -4,
6817
6907
  [horizontal]: -4,
@@ -6853,23 +6943,10 @@ function buildVisibleAxisIndices(precomputed, displayLimit, maxUsedIndex, hidden
6853
6943
  if (displayLimit <= 0) {
6854
6944
  return [];
6855
6945
  }
6856
- if (precomputed.length === 0) {
6857
- const visible2 = [];
6858
- const usedLimit = Math.min(displayLimit, Math.max(0, maxUsedIndex + 1));
6859
- for (let index = 0; index < usedLimit; index += 1) {
6860
- if (!hiddenIndices?.has(index)) {
6861
- visible2.push(index);
6862
- }
6863
- }
6864
- for (let index = usedLimit; index < displayLimit; index += 1) {
6865
- visible2.push(index);
6866
- }
6867
- return visible2;
6868
- }
6869
- const visible = precomputed.filter((value) => value < displayLimit);
6870
- const appendStart = Math.max(0, maxUsedIndex + 1);
6871
- for (let index = appendStart; index < displayLimit; index += 1) {
6872
- visible.push(index);
6946
+ const visible = precomputed.filter((index) => index < displayLimit);
6947
+ const appendStart = precomputed.length ? Math.max(0, maxUsedIndex + 1) : 0;
6948
+ for (let index = appendStart; index < displayLimit; index++) {
6949
+ if (!hiddenIndices?.has(index)) visible.push(index);
6873
6950
  }
6874
6951
  return visible;
6875
6952
  }
@@ -7788,7 +7865,7 @@ function applyCanvasShapeDash(context, dash, lineWidth) {
7788
7865
  }
7789
7866
  }
7790
7867
  function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
7791
- return React14.useMemo(
7868
+ return React15.useMemo(
7792
7869
  () => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
7793
7870
  [headerBackgroundColor, headerTextColor, isDark]
7794
7871
  );
@@ -8475,10 +8552,10 @@ function renderSparkline(sparkline, values, palette) {
8475
8552
  const gap = normalizedValues.length > 1 ? (innerWidth2 - segmentWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
8476
8553
  const positiveY = 4.5;
8477
8554
  const negativeY = height - 4.5;
8478
- return /* @__PURE__ */ jsx10("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: normalizedValues.map((entry, index) => {
8555
+ return /* @__PURE__ */ jsx11("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: normalizedValues.map((entry, index) => {
8479
8556
  const left = 1 + index * (segmentWidth + Math.max(0, gap));
8480
8557
  const y = entry.value >= 0 ? positiveY : negativeY;
8481
- return /* @__PURE__ */ jsx10(
8558
+ return /* @__PURE__ */ jsx11(
8482
8559
  "line",
8483
8560
  {
8484
8561
  stroke: seriesColor,
@@ -8500,15 +8577,15 @@ function renderSparkline(sparkline, values, palette) {
8500
8577
  const zeroY = 2 + innerHeight2 - clampSparklineValue(0, minValue2, maxValue2) * innerHeight2;
8501
8578
  const barWidth = Math.max(2, innerWidth2 / Math.max(normalizedValues.length * 1.8, 1));
8502
8579
  const gap = normalizedValues.length > 1 ? (innerWidth2 - barWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
8503
- return /* @__PURE__ */ jsxs7("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
8504
- /* @__PURE__ */ jsx10("line", { stroke: palette.border, strokeWidth: 1, x1: 1, x2: width - 1, y1: zeroY, y2: zeroY }),
8580
+ return /* @__PURE__ */ jsxs8("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
8581
+ /* @__PURE__ */ jsx11("line", { stroke: palette.border, strokeWidth: 1, x1: 1, x2: width - 1, y1: zeroY, y2: zeroY }),
8505
8582
  normalizedValues.map((entry, index) => {
8506
8583
  const left = 1 + index * (barWidth + Math.max(0, gap));
8507
8584
  const y = 2 + innerHeight2 - clampSparklineValue(entry.value, minValue2, maxValue2) * innerHeight2;
8508
8585
  const top = Math.min(y, zeroY);
8509
8586
  const barHeight = Math.max(1, Math.abs(y - zeroY));
8510
8587
  const fill = entry.value < 0 ? negativeColor : seriesColor;
8511
- return /* @__PURE__ */ jsx10(
8588
+ return /* @__PURE__ */ jsx11(
8512
8589
  "rect",
8513
8590
  {
8514
8591
  fill,
@@ -8534,8 +8611,8 @@ function renderSparkline(sparkline, values, palette) {
8534
8611
  }).join(" ");
8535
8612
  const highValue = Math.max(...points.map((entry) => entry.value));
8536
8613
  const lowValue = Math.min(...points.map((entry) => entry.value));
8537
- return /* @__PURE__ */ jsxs7("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
8538
- /* @__PURE__ */ jsx10("path", { d: path, fill: "none", stroke: seriesColor, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6 }),
8614
+ return /* @__PURE__ */ jsxs8("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
8615
+ /* @__PURE__ */ jsx11("path", { d: path, fill: "none", stroke: seriesColor, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6 }),
8539
8616
  sparkline.markers ? points.map((entry, index) => {
8540
8617
  const x = 1 + index * xStep;
8541
8618
  const y = 2 + innerHeight2 - clampSparklineValue(entry.value, minValue, maxValue) * innerHeight2;
@@ -8551,7 +8628,7 @@ function renderSparkline(sparkline, values, palette) {
8551
8628
  } else if (entry.value < 0 && sparkline.negative && sparkline.negativeColor) {
8552
8629
  fill = sparkline.negativeColor;
8553
8630
  }
8554
- return /* @__PURE__ */ jsx10("circle", { cx: x, cy: y, fill, r: 1.75 }, `spark-point-${index}`);
8631
+ return /* @__PURE__ */ jsx11("circle", { cx: x, cy: y, fill, r: 1.75 }, `spark-point-${index}`);
8555
8632
  }) : null
8556
8633
  ] });
8557
8634
  }
@@ -8675,7 +8752,7 @@ function SegmentedControl({
8675
8752
  palette,
8676
8753
  value
8677
8754
  }) {
8678
- return /* @__PURE__ */ jsx10(
8755
+ return /* @__PURE__ */ jsx11(
8679
8756
  "div",
8680
8757
  {
8681
8758
  "aria-label": messages.workbookSheets,
@@ -8693,7 +8770,7 @@ function SegmentedControl({
8693
8770
  children: items.map((item) => {
8694
8771
  const selected = item.id === value;
8695
8772
  const isHidden = item.visibility === "hidden" || item.visibility === "veryHidden";
8696
- return /* @__PURE__ */ jsx10(
8773
+ return /* @__PURE__ */ jsx11(
8697
8774
  "button",
8698
8775
  {
8699
8776
  "aria-selected": selected,
@@ -8741,8 +8818,8 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8741
8818
  zoomOut,
8742
8819
  zoomScale
8743
8820
  } = controller;
8744
- return /* @__PURE__ */ jsxs7(Fragment11, { children: [
8745
- /* @__PURE__ */ jsxs7(
8821
+ return /* @__PURE__ */ jsxs8(Fragment11, { children: [
8822
+ /* @__PURE__ */ jsxs8(
8746
8823
  "div",
8747
8824
  {
8748
8825
  style: {
@@ -8757,7 +8834,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8757
8834
  padding: "0 16px"
8758
8835
  },
8759
8836
  children: [
8760
- /* @__PURE__ */ jsx10("div", { style: { minWidth: 0 }, children: /* @__PURE__ */ jsx10(
8837
+ /* @__PURE__ */ jsx11("div", { style: { minWidth: 0 }, children: /* @__PURE__ */ jsx11(
8761
8838
  "div",
8762
8839
  {
8763
8840
  style: {
@@ -8771,8 +8848,8 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8771
8848
  children: displayFileName
8772
8849
  }
8773
8850
  ) }),
8774
- /* @__PURE__ */ jsxs7("div", { style: { alignItems: "center", display: "flex", gap: 8 }, children: [
8775
- pivotTableEditor && (!controller.readOnly || controller.pivotTables.length > 0) ? /* @__PURE__ */ jsx10(
8851
+ /* @__PURE__ */ jsxs8("div", { style: { alignItems: "center", display: "flex", gap: 8 }, children: [
8852
+ pivotTableEditor && (!controller.readOnly || controller.pivotTables.length > 0) ? /* @__PURE__ */ jsx11(
8776
8853
  "button",
8777
8854
  {
8778
8855
  "aria-label": messages.pivotTableFields,
@@ -8788,7 +8865,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8788
8865
  children: "PivotTable"
8789
8866
  }
8790
8867
  ) : null,
8791
- /* @__PURE__ */ jsxs7(
8868
+ /* @__PURE__ */ jsxs8(
8792
8869
  "div",
8793
8870
  {
8794
8871
  style: {
@@ -8800,7 +8877,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8800
8877
  overflow: "hidden"
8801
8878
  },
8802
8879
  children: [
8803
- /* @__PURE__ */ jsx10(
8880
+ /* @__PURE__ */ jsx11(
8804
8881
  "button",
8805
8882
  {
8806
8883
  "aria-label": messages.zoomOut,
@@ -8819,7 +8896,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8819
8896
  children: "-"
8820
8897
  }
8821
8898
  ),
8822
- /* @__PURE__ */ jsx10(
8899
+ /* @__PURE__ */ jsx11(
8823
8900
  "button",
8824
8901
  {
8825
8902
  "aria-label": messages.resetZoom,
@@ -8840,7 +8917,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8840
8917
  children: formatZoomScale(zoomScale, locale)
8841
8918
  }
8842
8919
  ),
8843
- /* @__PURE__ */ jsx10(
8920
+ /* @__PURE__ */ jsx11(
8844
8921
  "button",
8845
8922
  {
8846
8923
  "aria-label": messages.zoomIn,
@@ -8862,7 +8939,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8862
8939
  ]
8863
8940
  }
8864
8941
  ),
8865
- canDownload ? /* @__PURE__ */ jsx10(
8942
+ canDownload ? /* @__PURE__ */ jsx11(
8866
8943
  "button",
8867
8944
  {
8868
8945
  "aria-label": messages.downloadWorkbook,
@@ -8891,7 +8968,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8891
8968
  ]
8892
8969
  }
8893
8970
  ),
8894
- tabs.length > 1 ? /* @__PURE__ */ jsx10(
8971
+ tabs.length > 1 ? /* @__PURE__ */ jsx11(
8895
8972
  "div",
8896
8973
  {
8897
8974
  style: {
@@ -8900,7 +8977,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
8900
8977
  overflowX: "auto",
8901
8978
  padding: "8px 12px"
8902
8979
  },
8903
- children: /* @__PURE__ */ jsx10(
8980
+ children: /* @__PURE__ */ jsx11(
8904
8981
  SegmentedControl,
8905
8982
  {
8906
8983
  messages,
@@ -8952,7 +9029,7 @@ function resolveRichCellRuns(raw, value, base, theme, zoom) {
8952
9029
  }
8953
9030
  function renderRichCellText(cell) {
8954
9031
  const scale = cell.shrinkToFitFontSizePx === void 0 ? 1 : cell.shrinkToFitFontSizePx / resolveCanvasFontSizePx(cell.style, 14);
8955
- return cell.richText ? cell.richText.map((run, index) => /* @__PURE__ */ jsx10("span", { style: {
9032
+ return cell.richText ? cell.richText.map((run, index) => /* @__PURE__ */ jsx11("span", { style: {
8956
9033
  fontFamily: run.style.fontFamily,
8957
9034
  fontSize: resolveCanvasFontSizePx(run.style, 14) * scale,
8958
9035
  fontWeight: run.style.fontWeight,
@@ -9353,7 +9430,7 @@ function renderConditionalIcon(icon, scale = 1) {
9353
9430
  if (icon.shape === "arrow") {
9354
9431
  const fill = icon.color ?? "#111827";
9355
9432
  const stroke = icon.borderColor ?? darkenColor(fill, 0.32);
9356
- return /* @__PURE__ */ jsx10(
9433
+ return /* @__PURE__ */ jsx11(
9357
9434
  "svg",
9358
9435
  {
9359
9436
  "aria-hidden": "true",
@@ -9361,7 +9438,7 @@ function renderConditionalIcon(icon, scale = 1) {
9361
9438
  style: { display: "block" },
9362
9439
  viewBox: "0 0 16 16",
9363
9440
  width: iconSize,
9364
- children: /* @__PURE__ */ jsx10("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx10(
9441
+ children: /* @__PURE__ */ jsx11("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx11(
9365
9442
  "path",
9366
9443
  {
9367
9444
  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",
@@ -9375,7 +9452,7 @@ function renderConditionalIcon(icon, scale = 1) {
9375
9452
  );
9376
9453
  }
9377
9454
  if (icon.glyph) {
9378
- return /* @__PURE__ */ jsx10(
9455
+ return /* @__PURE__ */ jsx11(
9379
9456
  "span",
9380
9457
  {
9381
9458
  style: {
@@ -9393,7 +9470,7 @@ function renderConditionalIcon(icon, scale = 1) {
9393
9470
  }
9394
9471
  );
9395
9472
  }
9396
- return /* @__PURE__ */ jsx10(
9473
+ return /* @__PURE__ */ jsx11(
9397
9474
  "span",
9398
9475
  {
9399
9476
  style: {
@@ -9417,9 +9494,9 @@ function renderCheckboxControl(checked, palette, scale = 1, mixed = false) {
9417
9494
  const stroke = paletteIsDark(palette) ? "#cbd5e1" : "#475569";
9418
9495
  const fill = checked || mixed ? paletteIsDark(palette) ? "#60a5fa" : "#2563eb" : "transparent";
9419
9496
  const check = paletteIsDark(palette) ? "#020617" : "#ffffff";
9420
- return /* @__PURE__ */ jsxs7("svg", { "aria-hidden": "true", height: 14 * scale, style: { display: "block" }, viewBox: "0 0 16 16", width: 14 * scale, children: [
9421
- /* @__PURE__ */ jsx10("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
9422
- mixed ? /* @__PURE__ */ jsx10("path", { d: "M5 8h6", fill: "none", stroke: check, strokeLinecap: "round", strokeWidth: 1.8 }) : checked ? /* @__PURE__ */ jsx10(
9497
+ return /* @__PURE__ */ jsxs8("svg", { "aria-hidden": "true", height: 14 * scale, style: { display: "block" }, viewBox: "0 0 16 16", width: 14 * scale, children: [
9498
+ /* @__PURE__ */ jsx11("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
9499
+ mixed ? /* @__PURE__ */ jsx11("path", { d: "M5 8h6", fill: "none", stroke: check, strokeLinecap: "round", strokeWidth: 1.8 }) : checked ? /* @__PURE__ */ jsx11(
9423
9500
  "path",
9424
9501
  {
9425
9502
  d: "M5 8.1 7.1 10.2 11.3 5.8",
@@ -9864,8 +9941,8 @@ function GridRow({
9864
9941
  zoomFactor
9865
9942
  }) {
9866
9943
  const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
9867
- return /* @__PURE__ */ jsxs7("tr", { "data-xlsx-row": actualRow, style: { height: rowHeight }, children: [
9868
- /* @__PURE__ */ jsxs7(
9944
+ return /* @__PURE__ */ jsxs8("tr", { "data-xlsx-row": actualRow, style: { height: rowHeight }, children: [
9945
+ /* @__PURE__ */ jsxs8(
9869
9946
  "td",
9870
9947
  {
9871
9948
  ref: (element) => onRowHeaderRef(actualRow, element),
@@ -9891,7 +9968,7 @@ function GridRow({
9891
9968
  zIndex: stickyTop !== void 0 ? frozenRowHeaderZIndex : rowHeaderZIndex
9892
9969
  },
9893
9970
  children: [
9894
- /* @__PURE__ */ jsx10("div", { style: { position: "relative" }, children: /* @__PURE__ */ jsx10(
9971
+ /* @__PURE__ */ jsx11("div", { style: { position: "relative" }, children: /* @__PURE__ */ jsx11(
9895
9972
  "span",
9896
9973
  {
9897
9974
  style: {
@@ -9902,7 +9979,7 @@ function GridRow({
9902
9979
  children: actualRow + 1
9903
9980
  }
9904
9981
  ) }),
9905
- /* @__PURE__ */ jsx10(
9982
+ /* @__PURE__ */ jsx11(
9906
9983
  "div",
9907
9984
  {
9908
9985
  onDoubleClick: (event) => {
@@ -9913,7 +9990,7 @@ function GridRow({
9913
9990
  style: {
9914
9991
  bottom: 0,
9915
9992
  cursor: "row-resize",
9916
- height: CANVAS_RESIZE_HIT_SLOP_PX,
9993
+ height: HEADER_RESIZE_HANDLE_PX,
9917
9994
  left: 0,
9918
9995
  position: "absolute",
9919
9996
  width: "100%",
@@ -9924,7 +10001,7 @@ function GridRow({
9924
10001
  ]
9925
10002
  }
9926
10003
  ),
9927
- leadingSpacerWidth > 0 ? /* @__PURE__ */ jsx10(
10004
+ leadingSpacerWidth > 0 ? /* @__PURE__ */ jsx11(
9928
10005
  "td",
9929
10006
  {
9930
10007
  "aria-hidden": "true",
@@ -10071,7 +10148,7 @@ function GridRow({
10071
10148
  width: "max-content"
10072
10149
  } : null;
10073
10150
  const title = [cellData.hyperlink?.tooltip, cellData.validation?.message, cellData.value].filter((value, index, values) => typeof value === "string" && value.length > 0 && values.indexOf(value) === index).join("\n");
10074
- return /* @__PURE__ */ jsxs7(
10151
+ return /* @__PURE__ */ jsxs8(
10075
10152
  "td",
10076
10153
  {
10077
10154
  "data-xlsx-cell": `${actualRow}:${actualCol}`,
@@ -10088,7 +10165,7 @@ function GridRow({
10088
10165
  style: cellStyle,
10089
10166
  title,
10090
10167
  children: [
10091
- cellData.chartHighlight ? /* @__PURE__ */ jsx10(
10168
+ cellData.chartHighlight ? /* @__PURE__ */ jsx11(
10092
10169
  "div",
10093
10170
  {
10094
10171
  "aria-hidden": "true",
@@ -10103,7 +10180,7 @@ function GridRow({
10103
10180
  pointerEvents: "none",
10104
10181
  position: "absolute"
10105
10182
  },
10106
- children: /* @__PURE__ */ jsx10(
10183
+ children: /* @__PURE__ */ jsx11(
10107
10184
  ReferenceRangeHandles,
10108
10185
  {
10109
10186
  color: cellData.chartHighlight.strokeColor,
@@ -10115,7 +10192,7 @@ function GridRow({
10115
10192
  )
10116
10193
  }
10117
10194
  ) : null,
10118
- cellData.conditionalDataBar ? /* @__PURE__ */ jsx10(
10195
+ cellData.conditionalDataBar ? /* @__PURE__ */ jsx11(
10119
10196
  "div",
10120
10197
  {
10121
10198
  "aria-hidden": "true",
@@ -10127,7 +10204,7 @@ function GridRow({
10127
10204
  position: "absolute",
10128
10205
  zIndex: 0
10129
10206
  },
10130
- children: /* @__PURE__ */ jsx10(
10207
+ children: /* @__PURE__ */ jsx11(
10131
10208
  "div",
10132
10209
  {
10133
10210
  style: {
@@ -10143,7 +10220,7 @@ function GridRow({
10143
10220
  }
10144
10221
  ) : null,
10145
10222
  adornment,
10146
- cellData.conditionalIcon ? /* @__PURE__ */ jsx10(
10223
+ cellData.conditionalIcon ? /* @__PURE__ */ jsx11(
10147
10224
  "div",
10148
10225
  {
10149
10226
  "aria-hidden": "true",
@@ -10161,7 +10238,7 @@ function GridRow({
10161
10238
  children: renderConditionalIcon(cellData.conditionalIcon, zoomFactor)
10162
10239
  }
10163
10240
  ) : null,
10164
- isSpilling && !isEditing ? /* @__PURE__ */ jsx10("div", { "aria-hidden": "true", style: {
10241
+ isSpilling && !isEditing ? /* @__PURE__ */ jsx11("div", { "aria-hidden": "true", style: {
10165
10242
  backgroundColor: cellStyle.backgroundColor ?? palette.surface,
10166
10243
  position: "absolute",
10167
10244
  left: cellData.spillSide === "left" ? cellData.spillOffsetX : "calc(100% - 1px)",
@@ -10170,7 +10247,7 @@ function GridRow({
10170
10247
  height: "calc(100% - 1px)",
10171
10248
  pointerEvents: "none"
10172
10249
  } }) : null,
10173
- isEditing ? /* @__PURE__ */ jsx10(
10250
+ isEditing ? /* @__PURE__ */ jsx11(
10174
10251
  CellEditor,
10175
10252
  {
10176
10253
  editorRef,
@@ -10195,7 +10272,7 @@ function GridRow({
10195
10272
  ...cellEditorStyle
10196
10273
  }
10197
10274
  }
10198
- ) : isSpilling ? /* @__PURE__ */ jsx10(
10275
+ ) : isSpilling ? /* @__PURE__ */ jsx11(
10199
10276
  "div",
10200
10277
  {
10201
10278
  style: {
@@ -10209,7 +10286,7 @@ function GridRow({
10209
10286
  },
10210
10287
  children: renderRichCellText(cellData)
10211
10288
  }
10212
- ) : cellData.sparkline ? /* @__PURE__ */ jsx10(
10289
+ ) : cellData.sparkline ? /* @__PURE__ */ jsx11(
10213
10290
  "div",
10214
10291
  {
10215
10292
  style: {
@@ -10222,7 +10299,7 @@ function GridRow({
10222
10299
  },
10223
10300
  children: renderSparkline(cellData.sparkline.config, cellData.sparkline.values, palette)
10224
10301
  }
10225
- ) : cellData.checkboxState != null ? /* @__PURE__ */ jsx10(
10302
+ ) : cellData.checkboxState != null ? /* @__PURE__ */ jsx11(
10226
10303
  "div",
10227
10304
  {
10228
10305
  style: {
@@ -10235,13 +10312,13 @@ function GridRow({
10235
10312
  },
10236
10313
  children: renderCheckboxControl(cellData.checkboxState, palette, zoomFactor)
10237
10314
  }
10238
- ) : /* @__PURE__ */ jsx10("div", { style: cellContentStyle, children: rotatedTextStyle ? /* @__PURE__ */ jsx10("span", { style: { ...rotatedTextBounds, flex: "0 0 auto", position: "relative" }, children: /* @__PURE__ */ jsx10("span", { style: rotatedTextStyle, children: renderRichCellText(cellData) }) }) : wrappedTextStyle ? /* @__PURE__ */ jsx10("span", { style: wrappedTextStyle, children: renderRichCellText(cellData) }) : renderRichCellText(cellData) })
10315
+ ) : /* @__PURE__ */ jsx11("div", { style: cellContentStyle, children: rotatedTextStyle ? /* @__PURE__ */ jsx11("span", { style: { ...rotatedTextBounds, flex: "0 0 auto", position: "relative" }, children: /* @__PURE__ */ jsx11("span", { style: rotatedTextStyle, children: renderRichCellText(cellData) }) }) : wrappedTextStyle ? /* @__PURE__ */ jsx11("span", { style: wrappedTextStyle, children: renderRichCellText(cellData) }) : renderRichCellText(cellData) })
10239
10316
  ]
10240
10317
  },
10241
10318
  key
10242
10319
  );
10243
10320
  }),
10244
- trailingSpacerWidth > 0 ? /* @__PURE__ */ jsx10(
10321
+ trailingSpacerWidth > 0 ? /* @__PURE__ */ jsx11(
10245
10322
  "td",
10246
10323
  {
10247
10324
  "aria-hidden": "true",
@@ -10255,7 +10332,7 @@ function GridRow({
10255
10332
  ) : null
10256
10333
  ] });
10257
10334
  }
10258
- var MemoGridRow = React14.memo(GridRow, (prev, next) => {
10335
+ var MemoGridRow = React15.memo(GridRow, (prev, next) => {
10259
10336
  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.onRowResizeDoubleClick !== next.onRowResizeDoubleClick || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment || prev.cellEditorStyle !== next.cellEditorStyle || prev.onFocusEditorOverlay !== next.onFocusEditorOverlay) {
10260
10337
  return false;
10261
10338
  }
@@ -10275,16 +10352,16 @@ function XlsxViewerProviderWithInlineController({
10275
10352
  ...options2
10276
10353
  }) {
10277
10354
  const controller = useXlsxViewerController(options2);
10278
- return /* @__PURE__ */ jsx10(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx10(ViewerContext.Provider, { value: controller, children: children2 }) });
10355
+ return /* @__PURE__ */ jsx11(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx11(ViewerContext.Provider, { value: controller, children: children2 }) });
10279
10356
  }
10280
10357
  function XlsxViewerProvider({ children: children2, controller, isDark = false, ...options2 }) {
10281
10358
  if (controller) {
10282
- return /* @__PURE__ */ jsx10(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx10(ViewerContext.Provider, { value: controller, children: children2 }) });
10359
+ return /* @__PURE__ */ jsx11(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx11(ViewerContext.Provider, { value: controller, children: children2 }) });
10283
10360
  }
10284
- return /* @__PURE__ */ jsx10(XlsxViewerProviderWithInlineController, { ...options2, isDark, children: children2 });
10361
+ return /* @__PURE__ */ jsx11(XlsxViewerProviderWithInlineController, { ...options2, isDark, children: children2 });
10285
10362
  }
10286
10363
  function useXlsxViewer() {
10287
- const context = React14.useContext(ViewerContext);
10364
+ const context = React15.useContext(ViewerContext);
10288
10365
  if (!context) {
10289
10366
  throw new Error("useXlsxViewer must be used inside XlsxViewer or XlsxViewerProvider.");
10290
10367
  }
@@ -10298,9 +10375,11 @@ function useXlsxViewerSelection() {
10298
10375
  selectedRangeAddress,
10299
10376
  selectCell,
10300
10377
  selectRange,
10378
+ selectRanges,
10379
+ selectionRanges,
10301
10380
  selection
10302
10381
  } = useXlsxViewer();
10303
- return React14.useMemo(
10382
+ return React15.useMemo(
10304
10383
  () => ({
10305
10384
  activeCell,
10306
10385
  activeCellAddress,
@@ -10308,9 +10387,18 @@ function useXlsxViewerSelection() {
10308
10387
  selectedRangeAddress,
10309
10388
  selectCell,
10310
10389
  selectRange,
10390
+ selectRanges,
10391
+ selectionRanges,
10311
10392
  selection
10312
10393
  }),
10313
- [activeCell, activeCellAddress, clearSelection, selectedRangeAddress, selectCell, selectRange, selection]
10394
+ [activeCell, activeCellAddress, clearSelection, selectedRangeAddress, selectCell, selectRange, selectRanges, selectionRanges, selection]
10395
+ );
10396
+ }
10397
+ function useXlsxViewerLayout() {
10398
+ const { canFreezePanes, frozenPanes, hideRows, unhideRows, hideColumns, unhideColumns, freezePanes, unfreezePanes } = useXlsxViewer();
10399
+ return React15.useMemo(
10400
+ () => ({ canFreezePanes, frozenPanes, hideRows, unhideRows, hideColumns, unhideColumns, freezePanes, unfreezePanes }),
10401
+ [canFreezePanes, frozenPanes, hideRows, unhideRows, hideColumns, unhideColumns, freezePanes, unfreezePanes]
10314
10402
  );
10315
10403
  }
10316
10404
  function useXlsxViewerZoom() {
@@ -10326,7 +10414,7 @@ function useXlsxViewerZoom() {
10326
10414
  zoomOut,
10327
10415
  zoomScale
10328
10416
  } = useXlsxViewer();
10329
- return React14.useMemo(
10417
+ return React15.useMemo(
10330
10418
  () => ({
10331
10419
  canZoomIn,
10332
10420
  canZoomOut,
@@ -10395,7 +10483,7 @@ function useXlsxViewerEditing() {
10395
10483
  unmergeSelection,
10396
10484
  updateFormControl
10397
10485
  } = useXlsxViewer();
10398
- return React14.useMemo(
10486
+ return React15.useMemo(
10399
10487
  () => ({
10400
10488
  addFormControl,
10401
10489
  addSheet,
@@ -10482,7 +10570,7 @@ function useXlsxViewerEditing() {
10482
10570
  }
10483
10571
  function useXlsxViewerTables() {
10484
10572
  const { sortState, sortTable, tables } = useXlsxViewer();
10485
- return React14.useMemo(
10573
+ return React15.useMemo(
10486
10574
  () => ({
10487
10575
  sortState,
10488
10576
  sortTable,
@@ -10493,7 +10581,7 @@ function useXlsxViewerTables() {
10493
10581
  }
10494
10582
  function useXlsxViewerPivots() {
10495
10583
  const { pivotTables, pivotFieldListVisible, setPivotFieldListVisible, getPivotSourceFields, getPivotTableAtCell, upsertPivotTable, refreshPivotTable, refreshAllPivotTables, removePivotTable, pivotDrillDown, showPivotDetails, createPivotChart, togglePivotGroup } = useXlsxViewer();
10496
- return React14.useMemo(() => ({
10584
+ return React15.useMemo(() => ({
10497
10585
  pivotTables,
10498
10586
  pivotFieldListVisible,
10499
10587
  setPivotFieldListVisible,
@@ -10547,7 +10635,7 @@ function useXlsxViewerImages() {
10547
10635
  setImageRect,
10548
10636
  updateChart
10549
10637
  } = useXlsxViewer();
10550
- return React14.useMemo(
10638
+ return React15.useMemo(
10551
10639
  () => ({
10552
10640
  arrangeDrawing,
10553
10641
  changeChartType,
@@ -10649,7 +10737,7 @@ function useXlsxViewerCharts() {
10649
10737
  tabs,
10650
10738
  updateChart
10651
10739
  } = useXlsxViewer();
10652
- return React14.useMemo(
10740
+ return React15.useMemo(
10653
10741
  () => ({
10654
10742
  activeTab,
10655
10743
  activeTabIndex,
@@ -10722,30 +10810,30 @@ function useXlsxViewerThumbnails(options2 = {}) {
10722
10810
  workbook,
10723
10811
  sheets
10724
10812
  } = useXlsxViewer();
10725
- const { headerBackgroundColor, headerTextColor, isDark } = React14.useContext(ViewerAppearanceContext);
10813
+ const { headerBackgroundColor, headerTextColor, isDark } = React15.useContext(ViewerAppearanceContext);
10726
10814
  const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
10727
10815
  const includeHeaders = options2.includeHeaders ?? true;
10728
10816
  const resolution = options2.resolution;
10729
- const thumbnailImageCacheRef = React14.useRef(/* @__PURE__ */ new Map());
10730
- const workerThumbnailRowBatchCacheRef = React14.useRef(/* @__PURE__ */ new Map());
10731
- const workerThumbnailRowBatchRequestRef = React14.useRef(
10817
+ const thumbnailImageCacheRef = React15.useRef(/* @__PURE__ */ new Map());
10818
+ const workerThumbnailRowBatchCacheRef = React15.useRef(/* @__PURE__ */ new Map());
10819
+ const workerThumbnailRowBatchRequestRef = React15.useRef(
10732
10820
  /* @__PURE__ */ new Map()
10733
10821
  );
10734
- const isMountedRef = React14.useRef(false);
10735
- const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] = React14.useState(0);
10736
- const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] = React14.useState(0);
10737
- React14.useEffect(() => {
10822
+ const isMountedRef = React15.useRef(false);
10823
+ const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] = React15.useState(0);
10824
+ const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] = React15.useState(0);
10825
+ React15.useEffect(() => {
10738
10826
  isMountedRef.current = true;
10739
10827
  return () => {
10740
10828
  isMountedRef.current = false;
10741
10829
  };
10742
10830
  }, []);
10743
- React14.useEffect(() => {
10831
+ React15.useEffect(() => {
10744
10832
  workerThumbnailRowBatchCacheRef.current.clear();
10745
10833
  workerThumbnailRowBatchRequestRef.current.clear();
10746
10834
  setWorkerThumbnailRowBatchVersion((version) => version + 1);
10747
10835
  }, [locale]);
10748
- React14.useEffect(() => {
10836
+ React15.useEffect(() => {
10749
10837
  const currentSheets = new Set(sheets);
10750
10838
  for (const sheet of workerThumbnailRowBatchCacheRef.current.keys()) {
10751
10839
  if (!currentSheets.has(sheet)) {
@@ -10758,7 +10846,7 @@ function useXlsxViewerThumbnails(options2 = {}) {
10758
10846
  }
10759
10847
  }
10760
10848
  }, [sheets]);
10761
- const getWorkerThumbnailRowBatch = React14.useCallback((sheet, startRow, endRow) => {
10849
+ const getWorkerThumbnailRowBatch = React15.useCallback((sheet, startRow, endRow) => {
10762
10850
  const cachedBatch = workerThumbnailRowBatchCacheRef.current.get(sheet);
10763
10851
  if (cachedBatch && startRow >= cachedBatch.startRow && endRow <= cachedBatch.endRow) {
10764
10852
  return cachedBatch;
@@ -10800,7 +10888,7 @@ function useXlsxViewerThumbnails(options2 = {}) {
10800
10888
  }
10801
10889
  return null;
10802
10890
  }, [getRowsBatchAsync]);
10803
- const getThumbnailImage = React14.useCallback((image) => {
10891
+ const getThumbnailImage = React15.useCallback((image) => {
10804
10892
  if (typeof Image === "undefined") {
10805
10893
  return null;
10806
10894
  }
@@ -10832,7 +10920,7 @@ function useXlsxViewerThumbnails(options2 = {}) {
10832
10920
  imageElement.src = image.src;
10833
10921
  return null;
10834
10922
  }, []);
10835
- const thumbnails = React14.useMemo(() => {
10923
+ const thumbnails = React15.useMemo(() => {
10836
10924
  return sheets.map((sheet, sheetIndex) => {
10837
10925
  const worksheet = workbook?.getSheet(sheet.workbookSheetIndex) ?? null;
10838
10926
  const sheetImages = getSheetImages(sheetIndex).filter((image) => image.src).sort((left, right) => left.zIndex - right.zIndex);
@@ -11415,11 +11503,11 @@ function useXlsxViewerThumbnails(options2 = {}) {
11415
11503
  locale,
11416
11504
  workbook
11417
11505
  ]);
11418
- const paintThumbnail = React14.useCallback(
11506
+ const paintThumbnail = React15.useCallback(
11419
11507
  (sheetIndex, canvas) => thumbnails[sheetIndex]?.paint(canvas) ?? false,
11420
11508
  [thumbnails]
11421
11509
  );
11422
- return React14.useMemo(
11510
+ return React15.useMemo(
11423
11511
  () => ({
11424
11512
  paintThumbnail,
11425
11513
  thumbnails
@@ -11429,13 +11517,13 @@ function useXlsxViewerThumbnails(options2 = {}) {
11429
11517
  }
11430
11518
  function DefaultXlsxToolbar({ pivotTableEditor } = {}) {
11431
11519
  const controller = useXlsxViewer();
11432
- const { headerBackgroundColor, headerTextColor, isDark } = React14.useContext(ViewerAppearanceContext);
11520
+ const { headerBackgroundColor, headerTextColor, isDark } = React15.useContext(ViewerAppearanceContext);
11433
11521
  const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
11434
- return /* @__PURE__ */ jsx10(DefaultToolbar, { controller, palette, pivotTableEditor });
11522
+ return /* @__PURE__ */ jsx11(DefaultToolbar, { controller, palette, pivotTableEditor });
11435
11523
  }
11436
11524
 
11437
11525
  // src/react-viewer.tsx
11438
- import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
11526
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
11439
11527
  var SlotStore = class {
11440
11528
  slots = /* @__PURE__ */ new Map();
11441
11529
  listeners = /* @__PURE__ */ new Set();
@@ -11471,7 +11559,7 @@ var SlotStore = class {
11471
11559
  return __createContentNode(slot.host);
11472
11560
  }
11473
11561
  portals() {
11474
- return Array.from(this.slots, ([key, slot]) => createPortal6(slot.node, slot.host, key));
11562
+ return Array.from(this.slots, ([key, slot]) => createPortal7(slot.node, slot.host, key));
11475
11563
  }
11476
11564
  destroy() {
11477
11565
  this.destroyed = true;
@@ -11504,9 +11592,9 @@ var SlotStore = class {
11504
11592
  }
11505
11593
  };
11506
11594
  function RuntimeContent({ content }) {
11507
- const hostRef = React15.useRef(null);
11508
- const rootRef = React15.useRef(null);
11509
- React15.useLayoutEffect(() => {
11595
+ const hostRef = React16.useRef(null);
11596
+ const rootRef = React16.useRef(null);
11597
+ React16.useLayoutEffect(() => {
11510
11598
  const host = hostRef.current;
11511
11599
  if (!host) return;
11512
11600
  const root = __createContentRoot(host);
@@ -11516,14 +11604,14 @@ function RuntimeContent({ content }) {
11516
11604
  root.destroy();
11517
11605
  };
11518
11606
  }, []);
11519
- React15.useLayoutEffect(() => {
11607
+ React16.useLayoutEffect(() => {
11520
11608
  rootRef.current?.update(content);
11521
11609
  }, [content]);
11522
- return /* @__PURE__ */ jsx11("span", { ref: hostRef, style: { display: "contents" } });
11610
+ return /* @__PURE__ */ jsx12("span", { ref: hostRef, style: { display: "contents" } });
11523
11611
  }
11524
11612
  function renderOptions(props, controller, slots, owner) {
11525
11613
  const slot = (key, node) => slots.render(key, node, owner);
11526
- const runtime = (node) => /* @__PURE__ */ jsx11(RuntimeContent, { content: node });
11614
+ const runtime = (node) => /* @__PURE__ */ jsx12(RuntimeContent, { content: node });
11527
11615
  const {
11528
11616
  emptyState,
11529
11617
  errorState,
@@ -11579,13 +11667,13 @@ function renderOptions(props, controller, slots, owner) {
11579
11667
  };
11580
11668
  }
11581
11669
  function BoundViewer({ props, controller: sourceController }) {
11582
- const messages = React15.useMemo(() => mergeMessages(sourceController.messages, props.messages), [sourceController.messages, props.messages]);
11583
- const controller = React15.useMemo(() => ({ ...sourceController, messages }), [sourceController, messages]);
11584
- const hostRef = React15.useRef(null);
11585
- const viewerRef = React15.useRef(null);
11586
- const slots = React15.useMemo(() => new SlotStore(), []);
11587
- React15.useSyncExternalStore(slots.subscribe, slots.getSnapshot, slots.getServerSnapshot);
11588
- React15.useLayoutEffect(() => {
11670
+ const messages = React16.useMemo(() => mergeMessages(sourceController.messages, props.messages), [sourceController.messages, props.messages]);
11671
+ const controller = React16.useMemo(() => ({ ...sourceController, messages }), [sourceController, messages]);
11672
+ const hostRef = React16.useRef(null);
11673
+ const viewerRef = React16.useRef(null);
11674
+ const slots = React16.useMemo(() => new SlotStore(), []);
11675
+ React16.useSyncExternalStore(slots.subscribe, slots.getSnapshot, slots.getServerSnapshot);
11676
+ React16.useLayoutEffect(() => {
11589
11677
  const host = hostRef.current;
11590
11678
  if (!host) return;
11591
11679
  slots.observe(host);
@@ -11597,27 +11685,27 @@ function BoundViewer({ props, controller: sourceController }) {
11597
11685
  slots.destroy();
11598
11686
  };
11599
11687
  }, [slots]);
11600
- React15.useLayoutEffect(() => {
11688
+ React16.useLayoutEffect(() => {
11601
11689
  const host = hostRef.current;
11602
11690
  if (host) viewerRef.current?.update(renderOptions(props, controller, slots, host.ownerDocument));
11603
11691
  }, [controller, props, slots]);
11604
- return /* @__PURE__ */ jsx11(ViewerAppearanceContext.Provider, { value: {
11692
+ return /* @__PURE__ */ jsx12(ViewerAppearanceContext.Provider, { value: {
11605
11693
  headerBackgroundColor: props.headerBackgroundColor,
11606
11694
  headerTextColor: props.headerTextColor,
11607
11695
  isDark: props.isDark ?? false
11608
- }, children: /* @__PURE__ */ jsxs8(ViewerContext.Provider, { value: controller, children: [
11609
- /* @__PURE__ */ jsx11("div", { ref: hostRef, style: { display: "contents" } }),
11696
+ }, children: /* @__PURE__ */ jsxs9(ViewerContext.Provider, { value: controller, children: [
11697
+ /* @__PURE__ */ jsx12("div", { ref: hostRef, style: { display: "contents" } }),
11610
11698
  slots.portals()
11611
11699
  ] }) });
11612
11700
  }
11613
11701
  function UncontrolledViewer(props) {
11614
11702
  const controller = useXlsxViewerController(props);
11615
- return /* @__PURE__ */ jsx11(BoundViewer, { props, controller });
11703
+ return /* @__PURE__ */ jsx12(BoundViewer, { props, controller });
11616
11704
  }
11617
11705
  function XlsxViewer(props) {
11618
- const context = React15.useContext(ViewerContext);
11706
+ const context = React16.useContext(ViewerContext);
11619
11707
  const controller = props.controller ?? context;
11620
- return controller ? /* @__PURE__ */ jsx11(BoundViewer, { props, controller }) : /* @__PURE__ */ jsx11(UncontrolledViewer, { ...props });
11708
+ return controller ? /* @__PURE__ */ jsx12(BoundViewer, { props, controller }) : /* @__PURE__ */ jsx12(UncontrolledViewer, { ...props });
11621
11709
  }
11622
11710
  export {
11623
11711
  DefaultXlsxPivotTableFieldList,
@@ -11634,6 +11722,7 @@ export {
11634
11722
  useXlsxViewerController,
11635
11723
  useXlsxViewerEditing,
11636
11724
  useXlsxViewerImages,
11725
+ useXlsxViewerLayout,
11637
11726
  useXlsxViewerPivots,
11638
11727
  useXlsxViewerSelection,
11639
11728
  useXlsxViewerTables,