@extend-ai/react-xlsx 0.20.7 → 0.20.8

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 (42) hide show
  1. package/dist/{chunk-PU7GI2DN.js → chunk-CVMHJO5H.js} +14 -14
  2. package/dist/{chunk-PU7GI2DN.js.map → chunk-CVMHJO5H.js.map} +1 -1
  3. package/dist/{chunk-6LLCA7IL.cjs → chunk-NXXZO2BL.cjs} +2448 -1871
  4. package/dist/chunk-NXXZO2BL.cjs.map +1 -0
  5. package/dist/{chunk-YNJ37P46.cjs → chunk-OGZ6ROZC.cjs} +13 -13
  6. package/dist/chunk-OGZ6ROZC.cjs.map +1 -0
  7. package/dist/{chunk-QGVGTRPL.js → chunk-R2KLWFAZ.js} +807 -230
  8. package/dist/chunk-R2KLWFAZ.js.map +1 -0
  9. package/dist/index.cjs +1252 -834
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +706 -288
  14. package/dist/index.js.map +1 -1
  15. package/dist/{internal-BWLyus2V.d.cts → internal-BBaC9yCh.d.cts} +1 -0
  16. package/dist/{internal-BWLyus2V.d.ts → internal-BBaC9yCh.d.ts} +1 -0
  17. package/dist/internal.cjs +3 -3
  18. package/dist/internal.d.cts +1 -1
  19. package/dist/internal.d.ts +1 -1
  20. package/dist/internal.js +2 -2
  21. package/dist/{shared-chart-X6KINN3S.cjs → shared-chart-4LUQQI2B.cjs} +4 -3
  22. package/dist/shared-chart-4LUQQI2B.cjs.map +1 -0
  23. package/dist/{shared-chart-PFTMNQGJ.js → shared-chart-BLOOGI7S.js} +4 -3
  24. package/dist/shared-chart-BLOOGI7S.js.map +1 -0
  25. package/dist/{shared-chart-7T3XVIDU.cjs → shared-chart-CIRSCWTO.cjs} +15 -14
  26. package/dist/shared-chart-CIRSCWTO.cjs.map +1 -0
  27. package/dist/{shared-chart-APBJ7QVM.js → shared-chart-XOCTF7KQ.js} +5 -4
  28. package/dist/shared-chart-XOCTF7KQ.js.map +1 -0
  29. package/dist/vanilla.cjs +3 -3
  30. package/dist/vanilla.d.cts +2 -2
  31. package/dist/vanilla.d.ts +2 -2
  32. package/dist/vanilla.js +2 -2
  33. package/dist/xlsx-worker.js +7 -3
  34. package/dist/xlsx-worker.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-6LLCA7IL.cjs.map +0 -1
  37. package/dist/chunk-QGVGTRPL.js.map +0 -1
  38. package/dist/chunk-YNJ37P46.cjs.map +0 -1
  39. package/dist/shared-chart-7T3XVIDU.cjs.map +0 -1
  40. package/dist/shared-chart-APBJ7QVM.js.map +0 -1
  41. package/dist/shared-chart-PFTMNQGJ.js.map +0 -1
  42. package/dist/shared-chart-X6KINN3S.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -65,6 +65,242 @@ function localizeCellNumber(worksheet, row, col, text, locale = "en-US") {
65
65
  );
66
66
  }
67
67
 
68
+ // src/range-reference.ts
69
+ var XLSX_MAX_ROWS = 1048576;
70
+ var XLSX_MAX_COLUMNS = 16384;
71
+ function parseColumn(value) {
72
+ let column = 0;
73
+ for (const character of value.toUpperCase()) {
74
+ column = column * 26 + character.charCodeAt(0) - 64;
75
+ }
76
+ return column > 0 && column <= XLSX_MAX_COLUMNS ? column - 1 : null;
77
+ }
78
+ function parseRow(value) {
79
+ const row = Number(value);
80
+ return row > 0 && row <= XLSX_MAX_ROWS ? row - 1 : null;
81
+ }
82
+ function parseCell(value) {
83
+ const match = /^\$?([a-z]{1,3})\$?([1-9]\d{0,6})$/i.exec(value);
84
+ if (!match) {
85
+ return null;
86
+ }
87
+ const col = parseColumn(match[1]);
88
+ const row = parseRow(match[2]);
89
+ return col === null || row === null ? null : { col, row };
90
+ }
91
+ function parseXlsxRange(reference) {
92
+ if (typeof reference !== "string") {
93
+ return null;
94
+ }
95
+ let address = reference.trim().replace(/^=\s*/, "");
96
+ let sheetName = null;
97
+ if (address.startsWith("'")) {
98
+ const match = /^'((?:[^']|'')+)'!(.+)$/.exec(address);
99
+ if (!match) {
100
+ return null;
101
+ }
102
+ sheetName = match[1].replace(/''/g, "'");
103
+ address = match[2];
104
+ } else if (address.includes("!")) {
105
+ const match = /^([^\s'!\[\]:*?/\\+,;(){}=<>"&^%\-]+)!(.+)$/.exec(address);
106
+ if (!match) {
107
+ return null;
108
+ }
109
+ sheetName = match[1];
110
+ address = match[2];
111
+ }
112
+ if (sheetName !== null && (sheetName.length > 31 || /[\[\]:*?/\\\u0000-\u001f]/.test(sheetName) || sheetName.startsWith("'") || sheetName.endsWith("'"))) {
113
+ return null;
114
+ }
115
+ const parts = address.split(":");
116
+ if (parts.length > 2) {
117
+ return null;
118
+ }
119
+ const start = parseCell(parts[0]);
120
+ const end = parseCell(parts[1] ?? parts[0]);
121
+ if (start && end) {
122
+ return {
123
+ kind: "cells",
124
+ range: {
125
+ start: { col: Math.min(start.col, end.col), row: Math.min(start.row, end.row) },
126
+ end: { col: Math.max(start.col, end.col), row: Math.max(start.row, end.row) }
127
+ },
128
+ sheetName
129
+ };
130
+ }
131
+ const columns = /^\$?([a-z]{1,3}):\$?([a-z]{1,3})$/i.exec(address);
132
+ if (columns) {
133
+ const first = parseColumn(columns[1]);
134
+ const last = parseColumn(columns[2]);
135
+ if (first !== null && last !== null) {
136
+ return {
137
+ kind: "columns",
138
+ range: {
139
+ start: { col: Math.min(first, last), row: 0 },
140
+ end: { col: Math.max(first, last), row: XLSX_MAX_ROWS - 1 }
141
+ },
142
+ sheetName
143
+ };
144
+ }
145
+ }
146
+ const rows = /^\$?([1-9]\d{0,6}):\$?([1-9]\d{0,6})$/.exec(address);
147
+ if (rows) {
148
+ const first = parseRow(rows[1]);
149
+ const last = parseRow(rows[2]);
150
+ if (first !== null && last !== null) {
151
+ return {
152
+ kind: "rows",
153
+ range: {
154
+ start: { col: 0, row: Math.min(first, last) },
155
+ end: { col: XLSX_MAX_COLUMNS - 1, row: Math.max(first, last) }
156
+ },
157
+ sheetName
158
+ };
159
+ }
160
+ }
161
+ return null;
162
+ }
163
+
164
+ // src/formula-references.ts
165
+ var REFERENCE_COLORS = ["#3472c9", "#c53645", "#9b4dbb", "#258447", "#b97812", "#16858e"];
166
+ var CELL = String.raw`\$?[A-Z]{1,3}\$?[1-9]\d{0,6}`;
167
+ var COLUMN = String.raw`\$?[A-Z]{1,3}`;
168
+ var ROW = String.raw`\$?[1-9]\d{0,6}`;
169
+ var SHEET = String.raw`(?:'(?:[^']|'')+'|[\p{L}\p{N}_\\.]+)!`;
170
+ var REFERENCE = new RegExp(
171
+ `(?:${SHEET})?(?:${CELL}(?:\\s*:\\s*${CELL})?|${COLUMN}\\s*:\\s*${COLUMN}|${ROW}\\s*:\\s*${ROW})`,
172
+ "iyu"
173
+ );
174
+ var NAME_CHARACTER = /[\p{L}\p{N}_.$\\]/u;
175
+ function getFormulaReferences(value, sheetName) {
176
+ if (!/^[=+-]/.test(value)) return [];
177
+ const references = [];
178
+ const colors = /* @__PURE__ */ new Map();
179
+ let index = value.startsWith("=") ? 1 : 0;
180
+ while (index < value.length) {
181
+ if (value[index] === '"') {
182
+ index += 1;
183
+ while (index < value.length) {
184
+ if (value[index++] === '"') {
185
+ if (value[index] !== '"') break;
186
+ index += 1;
187
+ }
188
+ }
189
+ continue;
190
+ }
191
+ if (value[index] === "[") {
192
+ let depth = 1;
193
+ while (++index < value.length && depth) {
194
+ if (value[index] === "[") depth += 1;
195
+ if (value[index] === "]") depth -= 1;
196
+ }
197
+ while (index < value.length && /[^\s+\-*/^&=<>(),;]/.test(value[index])) index += 1;
198
+ continue;
199
+ }
200
+ if (NAME_CHARACTER.test(value[index - 1])) {
201
+ index += 1;
202
+ continue;
203
+ }
204
+ REFERENCE.lastIndex = index;
205
+ const match = REFERENCE.exec(value);
206
+ if (match) {
207
+ const end = index + match[0].length;
208
+ const previous = value[index - 1];
209
+ const next = value[end];
210
+ const parsed = parseXlsxRange(match[0].replace(/\s*:\s*/g, ":"));
211
+ if (parsed && !NAME_CHARACTER.test(previous) && previous !== "]" && previous !== "!" && previous !== ":" && (!next || !NAME_CHARACTER.test(next) && !/[!\[]/.test(next)) && !/^\s*\(/.test(value.slice(end))) {
212
+ const { range } = parsed;
213
+ const key = `${(parsed.sheetName ?? sheetName).toLowerCase()}:${range.start.row},${range.start.col}:${range.end.row},${range.end.col}`;
214
+ let color = colors.get(key);
215
+ if (!color) {
216
+ color = REFERENCE_COLORS[colors.size % REFERENCE_COLORS.length];
217
+ colors.set(key, color);
218
+ }
219
+ references.push({ ...parsed, start: index, end, color });
220
+ }
221
+ index = end;
222
+ } else if (value[index] === "'") {
223
+ index += 1;
224
+ while (index < value.length) {
225
+ if (value[index++] === "'") {
226
+ if (value[index] !== "'") break;
227
+ index += 1;
228
+ }
229
+ }
230
+ } else {
231
+ index += 1;
232
+ }
233
+ }
234
+ return references;
235
+ }
236
+
237
+ // src/cell-input.ts
238
+ function isTextCell(worksheet, cell) {
239
+ const style = worksheet.getCellStyleAt(cell.row, cell.col);
240
+ return style?.numberFormat?.formatString === "@" || style?.numberFormat?.id === 49;
241
+ }
242
+ function coerceUserEnteredValue(value, locale = "en-US", source = "edit") {
243
+ if (source === "edit" && value.startsWith("'")) return value.slice(1);
244
+ const trimmed = value.trim();
245
+ if (!trimmed) return value;
246
+ if (/^(true|false)$/i.test(trimmed)) return trimmed.toLowerCase() === "true";
247
+ const localized = parseLocaleNumber(trimmed, locale);
248
+ if (localized !== void 0) return localized;
249
+ if (/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(trimmed)) {
250
+ const number = Number(trimmed);
251
+ if (Number.isFinite(number)) return number;
252
+ }
253
+ return value;
254
+ }
255
+ function getUserEnteredFormula(value, locale = "en-US") {
256
+ if (value.startsWith("=") && value.length > 1) return value;
257
+ if (/^[+-].+/.test(value) && typeof coerceUserEnteredValue(value, locale) !== "number") return `=${value}`;
258
+ return null;
259
+ }
260
+ function applyInputNumberFormat(worksheet, cell, input) {
261
+ const style = worksheet.getCellStyleAt(cell.row, cell.col);
262
+ const format = style?.numberFormat;
263
+ if (format?.formatString && format.formatString.toLowerCase() !== "general") return;
264
+ const formatString = /^[+-]?(?:\d+\.?\d*|\.\d+)[eE][+-]?\d+$/.test(input.trim()) ? "0.00E+00" : /^=\s*(?:DATE|TODAY)\s*\(/i.test(input) ? "m/d/yy" : void 0;
265
+ if (formatString) worksheet.setCellStyleAt(cell.row, cell.col, { ...style, numberFormat: { formatString } });
266
+ }
267
+ function normalizeFormulaReferences(formula) {
268
+ for (const reference of getFormulaReferences(formula, "").reverse()) {
269
+ const token = formula.slice(reference.start, reference.end);
270
+ const separator = token.lastIndexOf("!") + 1;
271
+ formula = formula.slice(0, reference.start) + token.slice(0, separator) + token.slice(separator).toUpperCase().replace(/\s*:\s*/g, ":") + formula.slice(reference.end);
272
+ }
273
+ return formula;
274
+ }
275
+ function parseClipboardText(text) {
276
+ const normalized = text.replace(/\r\n?/g, "\n");
277
+ const rows = [];
278
+ let row = [];
279
+ let offset = 0;
280
+ while (offset < normalized.length) {
281
+ let value = "";
282
+ if (normalized[offset] === '"') {
283
+ const quoted = /^"((?:[^"]|"")*)"(?=\t|\n|$)/.exec(normalized.slice(offset));
284
+ if (quoted) {
285
+ value = quoted[1].replace(/""/g, '"');
286
+ offset += quoted[0].length;
287
+ }
288
+ }
289
+ while (offset < normalized.length && normalized[offset] !== " " && normalized[offset] !== "\n") value += normalized[offset++];
290
+ row.push(value);
291
+ const delimiter = normalized[offset++];
292
+ if (delimiter === "\n" || delimiter === void 0) {
293
+ rows.push(row);
294
+ row = [];
295
+ } else if (offset === normalized.length) row.push("");
296
+ }
297
+ if (row.length) rows.push(row);
298
+ return rows;
299
+ }
300
+ function quoteClipboardField(value) {
301
+ return /[\t\r\n"]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value;
302
+ }
303
+
68
304
  // src/spreadsheet-fonts.ts
69
305
  import { strFromU8, unzipSync } from "fflate";
70
306
  async function loadSpreadsheetFonts(buffer) {
@@ -5514,12 +5750,11 @@ function parseSheetState(archive, path, options) {
5514
5750
  );
5515
5751
  const defaultRowHeight = Number(sheetFormatNode?.getAttribute("defaultRowHeight") ?? 15);
5516
5752
  const digitWidthPt = measureOfficeDigitWidthPt(options?.defaultFont?.family, options?.defaultFont?.sizePt);
5517
- const storedColumnPixels = (width) => Math.max(0, Math.floor(
5518
- (256 * width + Math.floor(128 / digitWidthPt)) / 256 * digitWidthPt
5519
- ) * (4 / 3));
5753
+ const storedColumnPixels = (width) => resolveOfficeColumnWidthPixels(width, digitWidthPt);
5520
5754
  const explicitDefaultWidth = Number(sheetFormatNode?.getAttribute("defaultColWidth") ?? Number.NaN);
5521
5755
  const baseWidth = Number(sheetFormatNode?.getAttribute("baseColWidth") ?? 8);
5522
5756
  const officeLayout = {
5757
+ columnDigitWidthPt: digitWidthPt,
5523
5758
  defaultColumnPx: Number.isFinite(explicitDefaultWidth) && explicitDefaultWidth > 0 ? storedColumnPixels(explicitDefaultWidth) : ((Number.isFinite(baseWidth) && baseWidth > 0 ? baseWidth : 8) * digitWidthPt + 5) * (4 / 3),
5524
5759
  defaultRowPx: (Number.isFinite(defaultRowHeight) && defaultRowHeight > 0 ? defaultRowHeight : 15) * (4 / 3),
5525
5760
  columns: {},
@@ -7294,6 +7529,15 @@ function pixelsToEmu(value) {
7294
7529
  function pxToSheetColumnWidth(widthPx) {
7295
7530
  return (Math.max(widthPx, MIN_COL_WIDTH_PX) - 5) / 7;
7296
7531
  }
7532
+ function resolveOfficeColumnWidthPixels(width, digitWidthPt = 6) {
7533
+ return Math.max(0, Math.floor(
7534
+ (256 * width + Math.floor(128 / digitWidthPt)) / 256 * digitWidthPt
7535
+ ) * (4 / 3));
7536
+ }
7537
+ function pxToOfficeColumnWidth(widthPx, digitWidthPt = 6) {
7538
+ const points = Math.round(Math.max(widthPx, MIN_COL_WIDTH_PX) * (3 / 4));
7539
+ return (points + 0.5) / digitWidthPt - Math.floor(128 / digitWidthPt) / 256;
7540
+ }
7297
7541
  function resolveSheetColumnWidthPixels(width, columnWidthCharacterWidthPx) {
7298
7542
  return sheetColumnWidthToPixels(width, columnWidthCharacterWidthPx);
7299
7543
  }
@@ -7534,102 +7778,6 @@ function tryRecalculate(workbook) {
7534
7778
  }
7535
7779
  }
7536
7780
 
7537
- // src/range-reference.ts
7538
- var XLSX_MAX_ROWS = 1048576;
7539
- var XLSX_MAX_COLUMNS = 16384;
7540
- function parseColumn(value) {
7541
- let column = 0;
7542
- for (const character of value.toUpperCase()) {
7543
- column = column * 26 + character.charCodeAt(0) - 64;
7544
- }
7545
- return column > 0 && column <= XLSX_MAX_COLUMNS ? column - 1 : null;
7546
- }
7547
- function parseRow(value) {
7548
- const row = Number(value);
7549
- return row > 0 && row <= XLSX_MAX_ROWS ? row - 1 : null;
7550
- }
7551
- function parseCell(value) {
7552
- const match = /^\$?([a-z]{1,3})\$?([1-9]\d{0,6})$/i.exec(value);
7553
- if (!match) {
7554
- return null;
7555
- }
7556
- const col = parseColumn(match[1]);
7557
- const row = parseRow(match[2]);
7558
- return col === null || row === null ? null : { col, row };
7559
- }
7560
- function parseXlsxRange(reference) {
7561
- if (typeof reference !== "string") {
7562
- return null;
7563
- }
7564
- let address = reference.trim().replace(/^=\s*/, "");
7565
- let sheetName = null;
7566
- if (address.startsWith("'")) {
7567
- const match = /^'((?:[^']|'')+)'!(.+)$/.exec(address);
7568
- if (!match) {
7569
- return null;
7570
- }
7571
- sheetName = match[1].replace(/''/g, "'");
7572
- address = match[2];
7573
- } else if (address.includes("!")) {
7574
- const match = /^([^\s'!\[\]:*?/\\+,;(){}=<>"&^%\-]+)!(.+)$/.exec(address);
7575
- if (!match) {
7576
- return null;
7577
- }
7578
- sheetName = match[1];
7579
- address = match[2];
7580
- }
7581
- if (sheetName !== null && (sheetName.length > 31 || /[\[\]:*?/\\\u0000-\u001f]/.test(sheetName) || sheetName.startsWith("'") || sheetName.endsWith("'"))) {
7582
- return null;
7583
- }
7584
- const parts = address.split(":");
7585
- if (parts.length > 2) {
7586
- return null;
7587
- }
7588
- const start = parseCell(parts[0]);
7589
- const end = parseCell(parts[1] ?? parts[0]);
7590
- if (start && end) {
7591
- return {
7592
- kind: "cells",
7593
- range: {
7594
- start: { col: Math.min(start.col, end.col), row: Math.min(start.row, end.row) },
7595
- end: { col: Math.max(start.col, end.col), row: Math.max(start.row, end.row) }
7596
- },
7597
- sheetName
7598
- };
7599
- }
7600
- const columns = /^\$?([a-z]{1,3}):\$?([a-z]{1,3})$/i.exec(address);
7601
- if (columns) {
7602
- const first = parseColumn(columns[1]);
7603
- const last = parseColumn(columns[2]);
7604
- if (first !== null && last !== null) {
7605
- return {
7606
- kind: "columns",
7607
- range: {
7608
- start: { col: Math.min(first, last), row: 0 },
7609
- end: { col: Math.max(first, last), row: XLSX_MAX_ROWS - 1 }
7610
- },
7611
- sheetName
7612
- };
7613
- }
7614
- }
7615
- const rows = /^\$?([1-9]\d{0,6}):\$?([1-9]\d{0,6})$/.exec(address);
7616
- if (rows) {
7617
- const first = parseRow(rows[1]);
7618
- const last = parseRow(rows[2]);
7619
- if (first !== null && last !== null) {
7620
- return {
7621
- kind: "rows",
7622
- range: {
7623
- start: { col: 0, row: Math.min(first, last) },
7624
- end: { col: XLSX_MAX_COLUMNS - 1, row: Math.max(first, last) }
7625
- },
7626
- sheetName
7627
- };
7628
- }
7629
- }
7630
- return null;
7631
- }
7632
-
7633
7781
  // src/range-highlight.ts
7634
7782
  function expandHighlightedRange(range, mergedRanges) {
7635
7783
  const expanded = { start: { ...range.start }, end: { ...range.end } };
@@ -8875,27 +9023,6 @@ function cloneCellStyle(style) {
8875
9023
  return style;
8876
9024
  }
8877
9025
  }
8878
- function coerceUserEnteredValue(value, locale = "en-US") {
8879
- const trimmed = value.trim();
8880
- if (!trimmed) {
8881
- return "";
8882
- }
8883
- if (trimmed.startsWith("'")) {
8884
- return trimmed.slice(1);
8885
- }
8886
- if (/^(true|false)$/i.test(trimmed)) {
8887
- return trimmed.toLowerCase() === "true";
8888
- }
8889
- const localizedNumber = parseLocaleNumber(trimmed, locale);
8890
- if (localizedNumber !== void 0) return localizedNumber;
8891
- if (/^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(trimmed)) {
8892
- const parsed = Number(trimmed);
8893
- if (Number.isFinite(parsed)) {
8894
- return parsed;
8895
- }
8896
- }
8897
- return value;
8898
- }
8899
9026
  function applyCellMutationState(worksheet, cell, state) {
8900
9027
  if (state.formula) {
8901
9028
  worksheet.setFormula(cellAddressToA1(cell), state.formula);
@@ -8909,14 +9036,6 @@ function applyCellMutationState(worksheet, cell, state) {
8909
9036
  function escapeHtml(value) {
8910
9037
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
8911
9038
  }
8912
- function parseClipboardText(text) {
8913
- const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
8914
- const rows = normalized.split("\n");
8915
- if (rows.length > 1 && rows[rows.length - 1] === "") {
8916
- rows.pop();
8917
- }
8918
- return rows.map((row) => row.split(" "));
8919
- }
8920
9039
  function createAbortError2() {
8921
9040
  if (typeof DOMException !== "undefined") {
8922
9041
  return new DOMException("Aborted", "AbortError");
@@ -10481,7 +10600,7 @@ function useXlsxViewerController(options) {
10481
10600
  rowSpan
10482
10601
  });
10483
10602
  }
10484
- textCells.push(value);
10603
+ textCells.push(quoteClipboardField(value));
10485
10604
  htmlCells.push(
10486
10605
  `<td${rowSpan > 1 ? ` rowspan="${rowSpan}"` : ""}${colSpan > 1 ? ` colspan="${colSpan}"` : ""} style="${escapeHtml(cellStyles.join(";"))}">${escapeHtml(value)}</td>`
10487
10606
  );
@@ -10940,7 +11059,7 @@ function useXlsxViewerController(options) {
10940
11059
  if (!activeSheet) {
10941
11060
  return;
10942
11061
  }
10943
- const contentSizePx = resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
11062
+ const contentSizePx = activeSheet.officeLayout ? sizePx : resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
10944
11063
  const targetWorkbookSheetIndex = activeSheet.workbookSheetIndex;
10945
11064
  setSheets((currentSheets) => currentSheets.map((sheet) => {
10946
11065
  if (sheet.workbookSheetIndex !== targetWorkbookSheetIndex) {
@@ -10994,7 +11113,7 @@ function useXlsxViewerController(options) {
10994
11113
  const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
10995
11114
  worksheet.setColumnWidth(
10996
11115
  col,
10997
- pxToSheetColumnWidth(resolveContentSheetAxisPixels(widthPx, activeSheet.showGridLines))
11116
+ activeSheet.officeLayout ? pxToOfficeColumnWidth(widthPx, activeSheet.officeLayout.columnDigitWidthPt) : pxToSheetColumnWidth(resolveContentSheetAxisPixels(widthPx, activeSheet.showGridLines))
10998
11117
  );
10999
11118
  refreshWorkbookState(workbook);
11000
11119
  }, [
@@ -11022,7 +11141,7 @@ function useXlsxViewerController(options) {
11022
11141
  const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
11023
11142
  worksheet.setRowHeight(
11024
11143
  row,
11025
- pxToSheetRowHeight(resolveContentSheetAxisPixels(heightPx, activeSheet.showGridLines))
11144
+ activeSheet.officeLayout ? Math.max(heightPx, MIN_ROW_HEIGHT_PX2) * (3 / 4) : pxToSheetRowHeight(resolveContentSheetAxisPixels(heightPx, activeSheet.showGridLines))
11026
11145
  );
11027
11146
  refreshWorkbookState(workbook);
11028
11147
  }, [
@@ -11389,8 +11508,9 @@ function useXlsxViewerController(options) {
11389
11508
  return;
11390
11509
  }
11391
11510
  if (locale !== "en-US" && value === getCellDisplayValue2(cell)) return;
11392
- const nextValue = coerceUserEnteredValue(value, locale);
11511
+ const nextValue = isTextCell(worksheet, cell) ? value.startsWith("'") ? value.slice(1) : value : coerceUserEnteredValue(value, locale);
11393
11512
  worksheet.setCell(cellAddressToA1(cell), nextValue);
11513
+ if (typeof nextValue === "number") applyInputNumberFormat(worksheet, cell, value);
11394
11514
  const after = captureCellMutationState(cell);
11395
11515
  if (!after) {
11396
11516
  return;
@@ -11412,7 +11532,8 @@ function useXlsxViewerController(options) {
11412
11532
  if (!formula.trim()) {
11413
11533
  worksheet.setCell(cellAddressToA1(cell), "");
11414
11534
  } else {
11415
- worksheet.setFormula(cellAddressToA1(cell), formula);
11535
+ worksheet.setFormula(cellAddressToA1(cell), normalizeFormulaReferences(formula));
11536
+ applyInputNumberFormat(worksheet, cell, formula);
11416
11537
  }
11417
11538
  const after = captureCellMutationState(cell);
11418
11539
  if (!after) {
@@ -11727,8 +11848,11 @@ function useXlsxViewerController(options) {
11727
11848
  if (!before) {
11728
11849
  continue;
11729
11850
  }
11730
- if (rawValue.startsWith("=") && rawValue.length > 1) {
11731
- worksheet.setFormula(cellAddressToA1(nextCell), rawValue);
11851
+ const textCell = isTextCell(worksheet, nextCell);
11852
+ const formula = textCell ? null : getUserEnteredFormula(rawValue, locale);
11853
+ if (formula) {
11854
+ worksheet.setFormula(cellAddressToA1(nextCell), normalizeFormulaReferences(formula));
11855
+ applyInputNumberFormat(worksheet, nextCell, formula);
11732
11856
  const after = captureCellMutationState(nextCell);
11733
11857
  if (!after) {
11734
11858
  continue;
@@ -11739,8 +11863,9 @@ function useXlsxViewerController(options) {
11739
11863
  cell: nextCell
11740
11864
  });
11741
11865
  } else {
11742
- const nextValue = coerceUserEnteredValue(rawValue, locale);
11866
+ const nextValue = textCell ? rawValue : coerceUserEnteredValue(rawValue, locale, "paste");
11743
11867
  worksheet.setCell(cellAddressToA1(nextCell), nextValue);
11868
+ if (typeof nextValue === "number") applyInputNumberFormat(worksheet, nextCell, rawValue);
11744
11869
  const after = captureCellMutationState(nextCell);
11745
11870
  if (!after) {
11746
11871
  continue;
@@ -12266,12 +12391,275 @@ function useXlsxViewerController(options) {
12266
12391
  import { initWasm, parseXlsxRange as parseXlsxRange2, setWasmSource, XlsxFileSizeLimitExceededError as XlsxFileSizeLimitExceededError3 } from "@extend-ai/react-xlsx/vanilla";
12267
12392
 
12268
12393
  // src/react-viewer.tsx
12269
- import * as React6 from "react";
12394
+ import * as React7 from "react";
12270
12395
  import { createPortal as createPortal2 } from "react-dom";
12271
12396
  import { __createContentNode, __createContentRoot, __createControlledViewer } from "@extend-ai/react-xlsx/internal";
12272
12397
 
12273
12398
  // src/XlsxViewer.tsx
12274
- import * as React5 from "react";
12399
+ import * as React6 from "react";
12400
+
12401
+ // src/cell-editor.tsx
12402
+ import * as React2 from "react";
12403
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12404
+ function CellEditor({
12405
+ value,
12406
+ references,
12407
+ inputRef,
12408
+ canvasText = false,
12409
+ canvasOffset,
12410
+ paintCanvasText,
12411
+ style,
12412
+ onChange,
12413
+ onBlur,
12414
+ onCommit,
12415
+ onCancel,
12416
+ onNavigate
12417
+ }) {
12418
+ const rootRef = React2.useRef(null);
12419
+ const mirrorRef = React2.useRef(null);
12420
+ const textRef = React2.useRef(null);
12421
+ const baselineRef = React2.useRef(null);
12422
+ const plainTextRef = React2.useRef(null);
12423
+ const canvasRef = React2.useRef(null);
12424
+ const textareaRef = React2.useRef(null);
12425
+ const baselineOffsetRef = React2.useRef(0);
12426
+ const measuringContextRef = React2.useRef(null);
12427
+ const [bounds, setBounds] = React2.useState({ width: 0, height: 0 });
12428
+ React2.useLayoutEffect(() => {
12429
+ const root = rootRef.current;
12430
+ const anchor = root?.parentElement;
12431
+ const viewport = root?.closest('[role="grid"]');
12432
+ if (!root || !anchor || !viewport) {
12433
+ return;
12434
+ }
12435
+ const updateBounds = () => {
12436
+ const anchorRect = anchor.getBoundingClientRect();
12437
+ const viewportRect = viewport.getBoundingClientRect();
12438
+ const anchorWidth = parseFloat(getComputedStyle(anchor).width) || anchor.offsetWidth;
12439
+ const scale = anchorWidth ? anchorRect.width / anchorWidth : 1;
12440
+ const viewportScale = viewport.offsetWidth ? viewportRect.width / viewport.offsetWidth : 1;
12441
+ const viewportRight = viewportRect.right - (viewport.offsetWidth - viewport.clientWidth - viewport.clientLeft) * viewportScale;
12442
+ const width = Math.max(anchor.clientWidth, (viewportRight - anchorRect.left) / (scale || 1));
12443
+ const height = anchorRect.height / (scale || 1);
12444
+ setBounds((previous) => previous.width === width && previous.height === height ? previous : { width, height });
12445
+ };
12446
+ updateBounds();
12447
+ const observer = new ResizeObserver(updateBounds);
12448
+ observer.observe(viewport);
12449
+ observer.observe(anchor);
12450
+ viewport.addEventListener("scroll", updateBounds);
12451
+ return () => {
12452
+ observer.disconnect();
12453
+ viewport.removeEventListener("scroll", updateBounds);
12454
+ };
12455
+ }, []);
12456
+ React2.useLayoutEffect(() => {
12457
+ const text = textRef.current;
12458
+ const textarea = textareaRef.current;
12459
+ const root = rootRef.current;
12460
+ const baseline = baselineRef.current;
12461
+ const mirror = mirrorRef.current;
12462
+ if (!text || !textarea || !root || !baseline || !mirror) return;
12463
+ const computedStyle = getComputedStyle(text);
12464
+ const lineHeight = parseFloat(computedStyle.lineHeight) || parseFloat(computedStyle.fontSize) * 1.2;
12465
+ mirror.style.padding = typeof style.padding === "number" ? `${style.padding}px` : style.padding ?? "0";
12466
+ const mirrorStyle = getComputedStyle(mirror);
12467
+ const paddingTop = parseFloat(mirrorStyle.paddingTop) || 0;
12468
+ const paddingBottom = parseFloat(mirrorStyle.paddingBottom) || 0;
12469
+ const spareHeight = Math.max(0, bounds.height - paddingTop - paddingBottom - lineHeight);
12470
+ const editorTextTop = paddingTop + (style.verticalAlign === "top" ? 0 : style.verticalAlign === "middle" ? spareHeight / 2 : spareHeight);
12471
+ if (canvasText) mirror.style.paddingTop = `${editorTextTop}px`;
12472
+ const rootRect = root.getBoundingClientRect();
12473
+ const scale = rootRect.width / parseFloat(getComputedStyle(root).width) || 1;
12474
+ const textTop = (text.getBoundingClientRect().top - rootRect.top) / scale - baselineOffsetRef.current;
12475
+ textarea.style.paddingTop = `${Math.max(0, textTop)}px`;
12476
+ let baselineOffset = 0;
12477
+ if (canvasText) {
12478
+ const context = measuringContextRef.current ??= document.createElement("canvas").getContext("2d");
12479
+ if (context) {
12480
+ context.font = computedStyle.font;
12481
+ context.textBaseline = "alphabetic";
12482
+ const alphabetic = context.measureText("M");
12483
+ context.textBaseline = "middle";
12484
+ const middle = context.measureText("M");
12485
+ const browserBaseline = (baseline.getBoundingClientRect().top - rootRect.top) / scale - baselineOffsetRef.current;
12486
+ baselineOffset = editorTextTop + lineHeight / 2 + alphabetic.actualBoundingBoxAscent - middle.actualBoundingBoxAscent - browserBaseline;
12487
+ }
12488
+ }
12489
+ baselineOffsetRef.current = baselineOffset;
12490
+ root.style.setProperty("--xlsx-editor-baseline-offset", `${baselineOffset}px`);
12491
+ const canvas = canvasRef.current;
12492
+ if (canvas && paintCanvasText) {
12493
+ const dpr = window.devicePixelRatio || 1;
12494
+ const offsetX = (canvasOffset?.left ?? 0) * dpr % 1 / dpr;
12495
+ const offsetY = (canvasOffset?.top ?? 0) * dpr % 1 / dpr;
12496
+ const width = rootRect.width / scale;
12497
+ const height = rootRect.height / scale;
12498
+ canvas.width = Math.ceil((width + offsetX) * dpr);
12499
+ canvas.height = Math.ceil((height + offsetY) * dpr);
12500
+ canvas.style.width = `${canvas.width / dpr}px`;
12501
+ canvas.style.height = `${canvas.height / dpr}px`;
12502
+ canvas.style.left = `${-offsetX}px`;
12503
+ canvas.style.top = `${-offsetY}px`;
12504
+ const context = canvas.getContext("2d");
12505
+ if (context) {
12506
+ const node = plainTextRef.current?.firstChild;
12507
+ const lines = [];
12508
+ if (node) {
12509
+ const range = document.createRange();
12510
+ const length = node.textContent?.length ?? 0;
12511
+ let start = 0;
12512
+ while (start < length) {
12513
+ range.setStart(node, start);
12514
+ range.setEnd(node, start + 1);
12515
+ const top = range.getBoundingClientRect().top;
12516
+ let low = start + 1;
12517
+ let high = length;
12518
+ while (low < high) {
12519
+ const middle = Math.floor((low + high) / 2);
12520
+ range.setStart(node, middle);
12521
+ range.setEnd(node, middle + 1);
12522
+ if (Math.abs(range.getBoundingClientRect().top - top) < 1) low = middle + 1;
12523
+ else high = middle;
12524
+ }
12525
+ lines.push({ start, text: value.slice(start, low).replace(/\r?\n$/, "") });
12526
+ start = low;
12527
+ }
12528
+ }
12529
+ context.scale(dpr, dpr);
12530
+ context.translate(offsetX, offsetY);
12531
+ paintCanvasText(context, width, height, lines, editorTextTop);
12532
+ }
12533
+ }
12534
+ });
12535
+ const parts = [];
12536
+ let offset = 0;
12537
+ for (const reference of references) {
12538
+ parts.push(value.slice(offset, reference.start));
12539
+ parts.push(/* @__PURE__ */ jsx("span", { style: { color: reference.color }, children: value.slice(reference.start, reference.end) }, reference.start));
12540
+ offset = reference.end;
12541
+ }
12542
+ parts.push(value.slice(offset));
12543
+ return /* @__PURE__ */ jsxs(
12544
+ "div",
12545
+ {
12546
+ ref: rootRef,
12547
+ onPointerDown: (event) => event.stopPropagation(),
12548
+ onClick: (event) => event.stopPropagation(),
12549
+ onDoubleClick: (event) => event.stopPropagation(),
12550
+ style: {
12551
+ ...style,
12552
+ boxSizing: "border-box",
12553
+ position: "absolute",
12554
+ top: 0,
12555
+ left: 0,
12556
+ minHeight: "100%",
12557
+ minWidth: "100%",
12558
+ width: "max-content",
12559
+ maxWidth: bounds.width || "100%",
12560
+ textAlign: style.textAlign ?? "left",
12561
+ whiteSpace: "pre-wrap",
12562
+ wordBreak: canvasText ? "break-all" : void 0,
12563
+ overflowWrap: "anywhere",
12564
+ padding: 0,
12565
+ lineHeight: style.lineHeight ?? "inherit",
12566
+ overflow: "hidden"
12567
+ },
12568
+ children: [
12569
+ /* @__PURE__ */ jsx(
12570
+ "div",
12571
+ {
12572
+ ref: mirrorRef,
12573
+ "aria-hidden": "true",
12574
+ "data-xlsx-formula-text": "",
12575
+ style: {
12576
+ boxSizing: "border-box",
12577
+ padding: style.padding,
12578
+ minHeight: bounds.height,
12579
+ display: canvasText ? "block" : "flex",
12580
+ flexDirection: "column",
12581
+ justifyContent: style.verticalAlign === "top" ? "flex-start" : style.verticalAlign === "middle" ? "center" : "flex-end",
12582
+ overflow: "hidden",
12583
+ visibility: paintCanvasText ? "hidden" : void 0,
12584
+ pointerEvents: "none"
12585
+ },
12586
+ children: /* @__PURE__ */ jsxs("span", { ref: textRef, style: { display: "block", transform: "translateY(var(--xlsx-editor-baseline-offset, 0px))" }, children: [
12587
+ /* @__PURE__ */ jsx("span", { ref: baselineRef, style: { display: "inline-block", width: 0, height: 0, verticalAlign: "baseline" } }),
12588
+ paintCanvasText ? /* @__PURE__ */ jsx("span", { ref: plainTextRef, children: !value || /[\r\n]$/.test(value) ? value + "\u200B" : value }) : /* @__PURE__ */ jsxs(Fragment, { children: [
12589
+ parts,
12590
+ "\u200B"
12591
+ ] })
12592
+ ] })
12593
+ }
12594
+ ),
12595
+ paintCanvasText ? /* @__PURE__ */ jsx("canvas", { ref: canvasRef, "aria-hidden": "true", style: { position: "absolute", pointerEvents: "none" } }) : null,
12596
+ /* @__PURE__ */ jsx(
12597
+ "textarea",
12598
+ {
12599
+ ref: (element) => {
12600
+ textareaRef.current = element;
12601
+ if (typeof inputRef === "function") inputRef(element);
12602
+ else if (inputRef) inputRef.current = element;
12603
+ },
12604
+ "aria-label": "Edit cell",
12605
+ autoFocus: true,
12606
+ autoComplete: "off",
12607
+ spellCheck: false,
12608
+ rows: 1,
12609
+ value,
12610
+ onBlur,
12611
+ onChange: (event) => onChange(event.target.value),
12612
+ onScroll: (event) => {
12613
+ if (mirrorRef.current) mirrorRef.current.scrollTop = event.currentTarget.scrollTop;
12614
+ },
12615
+ onKeyDown: (event) => {
12616
+ event.stopPropagation();
12617
+ if (event.nativeEvent.isComposing) return;
12618
+ if (event.key === "Enter" && !event.altKey) {
12619
+ event.preventDefault();
12620
+ onCommit();
12621
+ } else if (event.key === "Escape") {
12622
+ event.preventDefault();
12623
+ onCancel();
12624
+ } else if (event.key === "Tab") {
12625
+ event.preventDefault();
12626
+ onNavigate(event.shiftKey ? "ArrowLeft" : "ArrowRight", event.currentTarget.value);
12627
+ } else if ((event.key === "ArrowDown" || event.key === "ArrowUp") && event.currentTarget.clientHeight < parseFloat(getComputedStyle(event.currentTarget).lineHeight) * 2) {
12628
+ event.preventDefault();
12629
+ onNavigate(event.key, event.currentTarget.value);
12630
+ }
12631
+ },
12632
+ style: {
12633
+ position: "absolute",
12634
+ inset: 0,
12635
+ background: "transparent",
12636
+ border: 0,
12637
+ boxSizing: "border-box",
12638
+ color: "transparent",
12639
+ caretColor: style.color ?? "currentColor",
12640
+ font: "inherit",
12641
+ lineHeight: "inherit",
12642
+ letterSpacing: "inherit",
12643
+ textAlign: "inherit",
12644
+ height: "100%",
12645
+ width: "100%",
12646
+ minWidth: 0,
12647
+ whiteSpace: "pre-wrap",
12648
+ wordBreak: canvasText ? "break-all" : void 0,
12649
+ overflowWrap: "anywhere",
12650
+ resize: "none",
12651
+ overflow: "hidden",
12652
+ padding: style.padding,
12653
+ margin: 0,
12654
+ outline: "none",
12655
+ transform: "translateY(var(--xlsx-editor-baseline-offset, 0px))"
12656
+ }
12657
+ }
12658
+ )
12659
+ ]
12660
+ }
12661
+ );
12662
+ }
12275
12663
 
12276
12664
  // src/cell-alignment.ts
12277
12665
  function getCellGeneralAlignment(worksheet, row, col) {
@@ -12286,7 +12674,7 @@ function getCellGeneralAlignment(worksheet, row, col) {
12286
12674
  }
12287
12675
 
12288
12676
  // src/context-menu.tsx
12289
- import * as React2 from "react";
12677
+ import * as React3 from "react";
12290
12678
  import { createPortal } from "react-dom";
12291
12679
 
12292
12680
  // src/viewer-palette.ts
@@ -12351,10 +12739,10 @@ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextC
12351
12739
  }
12352
12740
 
12353
12741
  // src/context-menu.tsx
12354
- import { jsx, jsxs } from "react/jsx-runtime";
12742
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
12355
12743
 
12356
12744
  // src/lazy-chart.tsx
12357
- import * as React4 from "react";
12745
+ import * as React5 from "react";
12358
12746
 
12359
12747
  // src/chart-loader.ts
12360
12748
  function createChartModule(importModule) {
@@ -12387,27 +12775,27 @@ function createChartModule(importModule) {
12387
12775
  var officeChartRenderer = createChartModule(async () => {
12388
12776
  const [{ loadOfficeCharts }, { SharedChartSvg }] = await Promise.all([
12389
12777
  import("./browser-KDZS5QQX.js"),
12390
- import("./shared-chart-PFTMNQGJ.js")
12778
+ import("./shared-chart-BLOOGI7S.js")
12391
12779
  ]);
12392
12780
  return { renderer: await loadOfficeCharts(), SharedChartSvg };
12393
12781
  });
12394
12782
  var suppliedOfficeChartRenderer = createChartModule(async () => {
12395
- const { SharedChartSvg } = await import("./shared-chart-PFTMNQGJ.js");
12783
+ const { SharedChartSvg } = await import("./shared-chart-BLOOGI7S.js");
12396
12784
  return { renderer: null, SharedChartSvg };
12397
12785
  });
12398
12786
  var officeExtendedChartRenderer = createChartModule(async () => {
12399
12787
  const [{ loadOfficeCharts }, { SharedChartSvg }] = await Promise.all([
12400
12788
  import("./full-IEKDBMU3.js"),
12401
- import("./shared-chart-PFTMNQGJ.js")
12789
+ import("./shared-chart-BLOOGI7S.js")
12402
12790
  ]);
12403
12791
  return { renderer: await loadOfficeCharts(typeof DecompressionStream === "function" ? void 0 : new URL("./office_charts_full_bg.wasm", import.meta.url)), SharedChartSvg };
12404
12792
  });
12405
12793
 
12406
12794
  // src/use-chart-module.ts
12407
- import * as React3 from "react";
12795
+ import * as React4 from "react";
12408
12796
 
12409
12797
  // src/lazy-chart.tsx
12410
- import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
12798
+ import { Fragment as Fragment3, jsx as jsx3 } from "react/jsx-runtime";
12411
12799
 
12412
12800
  // src/picture-paint.ts
12413
12801
  function resolvePicturePaintRect(image, rect) {
@@ -12424,7 +12812,7 @@ function resolvePicturePaintRect(image, rect) {
12424
12812
  }
12425
12813
 
12426
12814
  // src/XlsxViewer.tsx
12427
- import { Fragment as Fragment4, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
12815
+ import { Fragment as Fragment5, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
12428
12816
  var DEFAULT_ROW_HEIGHT2 = 24;
12429
12817
  var DEFAULT_COL_WIDTH2 = 80;
12430
12818
  var HEADER_HEIGHT = 24;
@@ -12441,14 +12829,6 @@ var THUMBNAIL_MAX_ROWS = 200;
12441
12829
  var THUMBNAIL_MAX_COLS = 80;
12442
12830
  var THUMBNAIL_MAX_SOURCE_HEIGHT_PX = 900;
12443
12831
  var THUMBNAIL_MAX_SOURCE_WIDTH_PX = 1440;
12444
- var CHART_SOURCE_HIGHLIGHT_COLORS = ["#2563eb", "#dc2626", "#7c3aed", "#059669", "#ea580c", "#db2777"];
12445
- var CHART_SOURCE_HIGHLIGHT_COLOR_BY_ROLE = {
12446
- bubble: CHART_SOURCE_HIGHLIGHT_COLORS[3] ?? "#059669",
12447
- category: CHART_SOURCE_HIGHLIGHT_COLORS[2] ?? "#7c3aed",
12448
- name: CHART_SOURCE_HIGHLIGHT_COLORS[0] ?? "#2563eb",
12449
- point: CHART_SOURCE_HIGHLIGHT_COLORS[5] ?? "#db2777",
12450
- value: CHART_SOURCE_HIGHLIGHT_COLORS[4] ?? "#ea580c"
12451
- };
12452
12832
  var SHEET_SURFACE = "#ffffff";
12453
12833
  var DEFAULT_CELL_PADDING = "0 4px";
12454
12834
  var CANVAS_CELL_STYLE_CACHE_LIMIT = 4096;
@@ -13064,8 +13444,19 @@ function lightenColor(color, ratio) {
13064
13444
  function darkenColor(color, ratio) {
13065
13445
  return mixRgbColor(color, "#000000", ratio);
13066
13446
  }
13067
- var ViewerContext = React5.createContext(null);
13068
- var ViewerAppearanceContext = React5.createContext({ isDark: false });
13447
+ var ViewerContext = React6.createContext(null);
13448
+ var ViewerAppearanceContext = React6.createContext({ isDark: false });
13449
+ function ReferenceRangeHandles({ color, top = true, bottom = true, left = true, right = true }) {
13450
+ return /* @__PURE__ */ jsx4(Fragment5, { children: [top && "top", bottom && "bottom"].flatMap((vertical) => vertical ? [left && "left", right && "right"].map((horizontal) => horizontal ? /* @__PURE__ */ jsx4("span", { style: {
13451
+ position: "absolute",
13452
+ [vertical]: -4,
13453
+ [horizontal]: -4,
13454
+ width: 6,
13455
+ height: 6,
13456
+ backgroundColor: color,
13457
+ border: "1px solid white"
13458
+ } }, `${vertical}-${horizontal}`) : null) : []) });
13459
+ }
13069
13460
  function resolveDarkModeSurface(themePalette, palette) {
13070
13461
  return "hsl(225 4% 6%)";
13071
13462
  }
@@ -14030,7 +14421,7 @@ function applyCanvasShapeDash(context, dash, lineWidth) {
14030
14421
  }
14031
14422
  }
14032
14423
  function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
14033
- return React5.useMemo(
14424
+ return React6.useMemo(
14034
14425
  () => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
14035
14426
  [headerBackgroundColor, headerTextColor, isDark]
14036
14427
  );
@@ -14545,6 +14936,25 @@ function buildCellStyle(style, palette, themePalette, options) {
14545
14936
  return css;
14546
14937
  }
14547
14938
  var textMeasureCanvas = null;
14939
+ function getHorizontalPadding(padding) {
14940
+ if (typeof padding !== "string") {
14941
+ return 8;
14942
+ }
14943
+ const values = padding.trim().split(/\s+/).map((value) => Number.parseFloat(value)).filter((value) => Number.isFinite(value));
14944
+ if (values.length === 1) {
14945
+ return values[0] * 2;
14946
+ }
14947
+ if (values.length === 2) {
14948
+ return values[1] * 2;
14949
+ }
14950
+ if (values.length === 3) {
14951
+ return values[1] * 2;
14952
+ }
14953
+ if (values.length >= 4) {
14954
+ return values[1] + values[3];
14955
+ }
14956
+ return 8;
14957
+ }
14548
14958
  function buildCanvasFont(style) {
14549
14959
  return resolveCanvasFont(style, 12);
14550
14960
  }
@@ -14698,10 +15108,10 @@ function renderSparkline(sparkline, values, palette) {
14698
15108
  const gap = normalizedValues.length > 1 ? (innerWidth - segmentWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
14699
15109
  const positiveY = 4.5;
14700
15110
  const negativeY = height - 4.5;
14701
- return /* @__PURE__ */ jsx3("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: normalizedValues.map((entry, index) => {
15111
+ return /* @__PURE__ */ jsx4("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: normalizedValues.map((entry, index) => {
14702
15112
  const left = 1 + index * (segmentWidth + Math.max(0, gap));
14703
15113
  const y = entry.value >= 0 ? positiveY : negativeY;
14704
- return /* @__PURE__ */ jsx3(
15114
+ return /* @__PURE__ */ jsx4(
14705
15115
  "line",
14706
15116
  {
14707
15117
  stroke: seriesColor,
@@ -14723,15 +15133,15 @@ function renderSparkline(sparkline, values, palette) {
14723
15133
  const zeroY = 2 + innerHeight - clampSparklineValue(0, minValue2, maxValue2) * innerHeight;
14724
15134
  const barWidth = Math.max(2, innerWidth / Math.max(normalizedValues.length * 1.8, 1));
14725
15135
  const gap = normalizedValues.length > 1 ? (innerWidth - barWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
14726
- return /* @__PURE__ */ jsxs2("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
14727
- /* @__PURE__ */ jsx3("line", { stroke: palette.border, strokeWidth: 1, x1: 1, x2: width - 1, y1: zeroY, y2: zeroY }),
15136
+ return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
15137
+ /* @__PURE__ */ jsx4("line", { stroke: palette.border, strokeWidth: 1, x1: 1, x2: width - 1, y1: zeroY, y2: zeroY }),
14728
15138
  normalizedValues.map((entry, index) => {
14729
15139
  const left = 1 + index * (barWidth + Math.max(0, gap));
14730
15140
  const y = 2 + innerHeight - clampSparklineValue(entry.value, minValue2, maxValue2) * innerHeight;
14731
15141
  const top = Math.min(y, zeroY);
14732
15142
  const barHeight = Math.max(1, Math.abs(y - zeroY));
14733
15143
  const fill = entry.value < 0 ? negativeColor : seriesColor;
14734
- return /* @__PURE__ */ jsx3(
15144
+ return /* @__PURE__ */ jsx4(
14735
15145
  "rect",
14736
15146
  {
14737
15147
  fill,
@@ -14757,8 +15167,8 @@ function renderSparkline(sparkline, values, palette) {
14757
15167
  }).join(" ");
14758
15168
  const highValue = Math.max(...points.map((entry) => entry.value));
14759
15169
  const lowValue = Math.min(...points.map((entry) => entry.value));
14760
- return /* @__PURE__ */ jsxs2("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
14761
- /* @__PURE__ */ jsx3("path", { d: path, fill: "none", stroke: seriesColor, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6 }),
15170
+ return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
15171
+ /* @__PURE__ */ jsx4("path", { d: path, fill: "none", stroke: seriesColor, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6 }),
14762
15172
  sparkline.markers ? points.map((entry, index) => {
14763
15173
  const x = 1 + index * xStep;
14764
15174
  const y = 2 + innerHeight - clampSparklineValue(entry.value, minValue, maxValue) * innerHeight;
@@ -14774,7 +15184,7 @@ function renderSparkline(sparkline, values, palette) {
14774
15184
  } else if (entry.value < 0 && sparkline.negative && sparkline.negativeColor) {
14775
15185
  fill = sparkline.negativeColor;
14776
15186
  }
14777
- return /* @__PURE__ */ jsx3("circle", { cx: x, cy: y, fill, r: 1.75 }, `spark-point-${index}`);
15187
+ return /* @__PURE__ */ jsx4("circle", { cx: x, cy: y, fill, r: 1.75 }, `spark-point-${index}`);
14778
15188
  }) : null
14779
15189
  ] });
14780
15190
  }
@@ -14896,7 +15306,7 @@ function SegmentedControl({
14896
15306
  palette,
14897
15307
  value
14898
15308
  }) {
14899
- return /* @__PURE__ */ jsx3(
15309
+ return /* @__PURE__ */ jsx4(
14900
15310
  "div",
14901
15311
  {
14902
15312
  "aria-label": "Workbook sheets",
@@ -14914,7 +15324,7 @@ function SegmentedControl({
14914
15324
  children: items.map((item) => {
14915
15325
  const selected = item.id === value;
14916
15326
  const isHidden = item.visibility === "hidden" || item.visibility === "veryHidden";
14917
- return /* @__PURE__ */ jsx3(
15327
+ return /* @__PURE__ */ jsx4(
14918
15328
  "button",
14919
15329
  {
14920
15330
  "aria-selected": selected,
@@ -14960,8 +15370,8 @@ function DefaultToolbar({ controller, palette }) {
14960
15370
  zoomOut,
14961
15371
  zoomScale
14962
15372
  } = controller;
14963
- return /* @__PURE__ */ jsxs2(Fragment4, { children: [
14964
- /* @__PURE__ */ jsxs2(
15373
+ return /* @__PURE__ */ jsxs3(Fragment5, { children: [
15374
+ /* @__PURE__ */ jsxs3(
14965
15375
  "div",
14966
15376
  {
14967
15377
  style: {
@@ -14976,7 +15386,7 @@ function DefaultToolbar({ controller, palette }) {
14976
15386
  padding: "0 16px"
14977
15387
  },
14978
15388
  children: [
14979
- /* @__PURE__ */ jsx3("div", { style: { minWidth: 0 }, children: /* @__PURE__ */ jsx3(
15389
+ /* @__PURE__ */ jsx4("div", { style: { minWidth: 0 }, children: /* @__PURE__ */ jsx4(
14980
15390
  "div",
14981
15391
  {
14982
15392
  style: {
@@ -14990,8 +15400,8 @@ function DefaultToolbar({ controller, palette }) {
14990
15400
  children: displayFileName
14991
15401
  }
14992
15402
  ) }),
14993
- /* @__PURE__ */ jsxs2("div", { style: { alignItems: "center", display: "flex", gap: 8 }, children: [
14994
- /* @__PURE__ */ jsxs2(
15403
+ /* @__PURE__ */ jsxs3("div", { style: { alignItems: "center", display: "flex", gap: 8 }, children: [
15404
+ /* @__PURE__ */ jsxs3(
14995
15405
  "div",
14996
15406
  {
14997
15407
  style: {
@@ -15003,7 +15413,7 @@ function DefaultToolbar({ controller, palette }) {
15003
15413
  overflow: "hidden"
15004
15414
  },
15005
15415
  children: [
15006
- /* @__PURE__ */ jsx3(
15416
+ /* @__PURE__ */ jsx4(
15007
15417
  "button",
15008
15418
  {
15009
15419
  disabled: !canZoomOut,
@@ -15021,7 +15431,7 @@ function DefaultToolbar({ controller, palette }) {
15021
15431
  children: "-"
15022
15432
  }
15023
15433
  ),
15024
- /* @__PURE__ */ jsx3(
15434
+ /* @__PURE__ */ jsx4(
15025
15435
  "button",
15026
15436
  {
15027
15437
  onClick: resetZoom,
@@ -15041,7 +15451,7 @@ function DefaultToolbar({ controller, palette }) {
15041
15451
  children: formatZoomScale(zoomScale)
15042
15452
  }
15043
15453
  ),
15044
- /* @__PURE__ */ jsx3(
15454
+ /* @__PURE__ */ jsx4(
15045
15455
  "button",
15046
15456
  {
15047
15457
  disabled: !canZoomIn,
@@ -15062,7 +15472,7 @@ function DefaultToolbar({ controller, palette }) {
15062
15472
  ]
15063
15473
  }
15064
15474
  ),
15065
- canDownload ? /* @__PURE__ */ jsx3(
15475
+ canDownload ? /* @__PURE__ */ jsx4(
15066
15476
  "button",
15067
15477
  {
15068
15478
  "aria-label": "Download workbook",
@@ -15091,7 +15501,7 @@ function DefaultToolbar({ controller, palette }) {
15091
15501
  ]
15092
15502
  }
15093
15503
  ),
15094
- tabs.length > 1 ? /* @__PURE__ */ jsx3(
15504
+ tabs.length > 1 ? /* @__PURE__ */ jsx4(
15095
15505
  "div",
15096
15506
  {
15097
15507
  style: {
@@ -15100,7 +15510,7 @@ function DefaultToolbar({ controller, palette }) {
15100
15510
  overflowX: "auto",
15101
15511
  padding: "8px 12px"
15102
15512
  },
15103
- children: /* @__PURE__ */ jsx3(
15513
+ children: /* @__PURE__ */ jsx4(
15104
15514
  SegmentedControl,
15105
15515
  {
15106
15516
  items: tabs.map((tab, index) => ({
@@ -15417,7 +15827,7 @@ function renderConditionalIcon(icon, scale = 1) {
15417
15827
  if (icon.shape === "arrow") {
15418
15828
  const fill = icon.color ?? "#111827";
15419
15829
  const stroke = icon.borderColor ?? darkenColor(fill, 0.32);
15420
- return /* @__PURE__ */ jsx3(
15830
+ return /* @__PURE__ */ jsx4(
15421
15831
  "svg",
15422
15832
  {
15423
15833
  "aria-hidden": "true",
@@ -15425,7 +15835,7 @@ function renderConditionalIcon(icon, scale = 1) {
15425
15835
  style: { display: "block" },
15426
15836
  viewBox: "0 0 16 16",
15427
15837
  width: iconSize,
15428
- children: /* @__PURE__ */ jsx3("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx3(
15838
+ children: /* @__PURE__ */ jsx4("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx4(
15429
15839
  "path",
15430
15840
  {
15431
15841
  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",
@@ -15439,7 +15849,7 @@ function renderConditionalIcon(icon, scale = 1) {
15439
15849
  );
15440
15850
  }
15441
15851
  if (icon.glyph) {
15442
- return /* @__PURE__ */ jsx3(
15852
+ return /* @__PURE__ */ jsx4(
15443
15853
  "span",
15444
15854
  {
15445
15855
  style: {
@@ -15457,7 +15867,7 @@ function renderConditionalIcon(icon, scale = 1) {
15457
15867
  }
15458
15868
  );
15459
15869
  }
15460
- return /* @__PURE__ */ jsx3(
15870
+ return /* @__PURE__ */ jsx4(
15461
15871
  "span",
15462
15872
  {
15463
15873
  style: {
@@ -15481,9 +15891,9 @@ function renderCheckboxControl(checked, palette, scale = 1, mixed = false) {
15481
15891
  const stroke = paletteIsDark(palette) ? "#cbd5e1" : "#475569";
15482
15892
  const fill = checked || mixed ? paletteIsDark(palette) ? "#60a5fa" : "#2563eb" : "transparent";
15483
15893
  const check = paletteIsDark(palette) ? "#020617" : "#ffffff";
15484
- return /* @__PURE__ */ jsxs2("svg", { "aria-hidden": "true", height: 14 * scale, style: { display: "block" }, viewBox: "0 0 16 16", width: 14 * scale, children: [
15485
- /* @__PURE__ */ jsx3("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
15486
- mixed ? /* @__PURE__ */ jsx3("path", { d: "M5 8h6", fill: "none", stroke: check, strokeLinecap: "round", strokeWidth: 1.8 }) : checked ? /* @__PURE__ */ jsx3(
15894
+ return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height: 14 * scale, style: { display: "block" }, viewBox: "0 0 16 16", width: 14 * scale, children: [
15895
+ /* @__PURE__ */ jsx4("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
15896
+ mixed ? /* @__PURE__ */ jsx4("path", { d: "M5 8h6", fill: "none", stroke: check, strokeLinecap: "round", strokeWidth: 1.8 }) : checked ? /* @__PURE__ */ jsx4(
15487
15897
  "path",
15488
15898
  {
15489
15899
  d: "M5 8.1 7.1 10.2 11.3 5.8",
@@ -15893,6 +16303,8 @@ function GridRow({
15893
16303
  actualRow,
15894
16304
  editingCell,
15895
16305
  editingValue,
16306
+ formulaReferences,
16307
+ editorBoxShadow,
15896
16308
  frozenRowHeaderZIndex,
15897
16309
  getCellData,
15898
16310
  headerLabelLiveScale,
@@ -15921,8 +16333,8 @@ function GridRow({
15921
16333
  zoomFactor
15922
16334
  }) {
15923
16335
  const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
15924
- return /* @__PURE__ */ jsxs2("tr", { "data-xlsx-row": actualRow, style: { height: rowHeight }, children: [
15925
- /* @__PURE__ */ jsx3(
16336
+ return /* @__PURE__ */ jsxs3("tr", { "data-xlsx-row": actualRow, style: { height: rowHeight }, children: [
16337
+ /* @__PURE__ */ jsx4(
15926
16338
  "td",
15927
16339
  {
15928
16340
  ref: (element) => onRowHeaderRef(actualRow, element),
@@ -15947,8 +16359,8 @@ function GridRow({
15947
16359
  width: rowHeaderWidth,
15948
16360
  zIndex: stickyTop !== void 0 ? frozenRowHeaderZIndex : rowHeaderZIndex
15949
16361
  },
15950
- children: /* @__PURE__ */ jsxs2("div", { style: { position: "relative" }, children: [
15951
- /* @__PURE__ */ jsx3(
16362
+ children: /* @__PURE__ */ jsxs3("div", { style: { position: "relative" }, children: [
16363
+ /* @__PURE__ */ jsx4(
15952
16364
  "span",
15953
16365
  {
15954
16366
  style: {
@@ -15959,7 +16371,7 @@ function GridRow({
15959
16371
  children: actualRow + 1
15960
16372
  }
15961
16373
  ),
15962
- /* @__PURE__ */ jsx3(
16374
+ /* @__PURE__ */ jsx4(
15963
16375
  "div",
15964
16376
  {
15965
16377
  onPointerDown: (event) => onRowResizePointerDown(event, actualRow, rowHeight),
@@ -15978,7 +16390,7 @@ function GridRow({
15978
16390
  ] })
15979
16391
  }
15980
16392
  ),
15981
- leadingSpacerWidth > 0 ? /* @__PURE__ */ jsx3(
16393
+ leadingSpacerWidth > 0 ? /* @__PURE__ */ jsx4(
15982
16394
  "td",
15983
16395
  {
15984
16396
  "aria-hidden": "true",
@@ -16045,6 +16457,9 @@ function GridRow({
16045
16457
  }
16046
16458
  if (isEditing) {
16047
16459
  cellStyle.padding = 0;
16460
+ cellStyle.position = stickyTop !== void 0 || stickyLeft !== void 0 ? "sticky" : "relative";
16461
+ cellStyle.overflow = "visible";
16462
+ cellStyle.zIndex = 42;
16048
16463
  }
16049
16464
  const cellContentStyle = {
16050
16465
  alignItems: "stretch",
@@ -16120,7 +16535,7 @@ function GridRow({
16120
16535
  width: "max-content"
16121
16536
  } : null;
16122
16537
  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");
16123
- return /* @__PURE__ */ jsxs2(
16538
+ return /* @__PURE__ */ jsxs3(
16124
16539
  "td",
16125
16540
  {
16126
16541
  "data-xlsx-cell": `${actualRow}:${actualCol}`,
@@ -16137,24 +16552,34 @@ function GridRow({
16137
16552
  style: cellStyle,
16138
16553
  title,
16139
16554
  children: [
16140
- cellData.chartHighlight ? /* @__PURE__ */ jsx3(
16555
+ cellData.chartHighlight ? /* @__PURE__ */ jsx4(
16141
16556
  "div",
16142
16557
  {
16143
16558
  "aria-hidden": "true",
16144
16559
  style: {
16145
16560
  backgroundColor: cellData.chartHighlight.fillColor,
16146
- borderBottom: cellData.chartHighlight.borderBottom ? `${Math.max(1, zoomFactor)}px solid ${cellData.chartHighlight.strokeColor}` : void 0,
16147
- borderLeft: cellData.chartHighlight.borderLeft ? `${Math.max(1, zoomFactor)}px solid ${cellData.chartHighlight.strokeColor}` : void 0,
16148
- borderRight: cellData.chartHighlight.borderRight ? `${Math.max(1, zoomFactor)}px solid ${cellData.chartHighlight.strokeColor}` : void 0,
16149
- borderTop: cellData.chartHighlight.borderTop ? `${Math.max(1, zoomFactor)}px solid ${cellData.chartHighlight.strokeColor}` : void 0,
16561
+ borderBottom: cellData.chartHighlight.borderBottom ? `2px solid ${cellData.chartHighlight.strokeColor}` : void 0,
16562
+ borderLeft: cellData.chartHighlight.borderLeft ? `2px solid ${cellData.chartHighlight.strokeColor}` : void 0,
16563
+ borderRight: cellData.chartHighlight.borderRight ? `2px solid ${cellData.chartHighlight.strokeColor}` : void 0,
16564
+ borderTop: cellData.chartHighlight.borderTop ? `2px solid ${cellData.chartHighlight.strokeColor}` : void 0,
16150
16565
  boxSizing: "border-box",
16151
- inset: Math.max(1, zoomFactor * 0.5),
16566
+ inset: 0,
16152
16567
  pointerEvents: "none",
16153
16568
  position: "absolute"
16154
- }
16569
+ },
16570
+ children: /* @__PURE__ */ jsx4(
16571
+ ReferenceRangeHandles,
16572
+ {
16573
+ color: cellData.chartHighlight.strokeColor,
16574
+ top: cellData.chartHighlight.borderTop,
16575
+ bottom: cellData.chartHighlight.borderBottom,
16576
+ left: cellData.chartHighlight.borderLeft,
16577
+ right: cellData.chartHighlight.borderRight
16578
+ }
16579
+ )
16155
16580
  }
16156
16581
  ) : null,
16157
- cellData.conditionalDataBar ? /* @__PURE__ */ jsx3(
16582
+ cellData.conditionalDataBar ? /* @__PURE__ */ jsx4(
16158
16583
  "div",
16159
16584
  {
16160
16585
  "aria-hidden": "true",
@@ -16169,7 +16594,7 @@ function GridRow({
16169
16594
  top: 4 * zoomFactor,
16170
16595
  zIndex: 0
16171
16596
  },
16172
- children: /* @__PURE__ */ jsx3(
16597
+ children: /* @__PURE__ */ jsx4(
16173
16598
  "div",
16174
16599
  {
16175
16600
  style: {
@@ -16185,7 +16610,7 @@ function GridRow({
16185
16610
  }
16186
16611
  ) : null,
16187
16612
  adornment,
16188
- cellData.conditionalIcon ? /* @__PURE__ */ jsx3(
16613
+ cellData.conditionalIcon ? /* @__PURE__ */ jsx4(
16189
16614
  "div",
16190
16615
  {
16191
16616
  "aria-hidden": "true",
@@ -16203,43 +16628,36 @@ function GridRow({
16203
16628
  children: renderConditionalIcon(cellData.conditionalIcon, zoomFactor)
16204
16629
  }
16205
16630
  ) : null,
16206
- isEditing ? /* @__PURE__ */ jsx3(
16207
- "input",
16631
+ isSpilling && !isEditing ? /* @__PURE__ */ jsx4("div", { "aria-hidden": "true", style: {
16632
+ backgroundColor: cellStyle.backgroundColor ?? palette.surface,
16633
+ position: "absolute",
16634
+ left: cellData.spillSide === "left" ? cellData.spillOffsetX : "calc(100% - 1px)",
16635
+ top: 0,
16636
+ width: cellData.spillSide === "left" ? -(cellData.spillOffsetX ?? 0) + 1 : `calc(${(cellData.spillWidth ?? 0) + getHorizontalPadding(cellStyle.padding) + 1}px - 100%)`,
16637
+ height: "calc(100% - 1px)",
16638
+ pointerEvents: "none"
16639
+ } }) : null,
16640
+ isEditing ? /* @__PURE__ */ jsx4(
16641
+ CellEditor,
16208
16642
  {
16209
- autoFocus: true,
16643
+ value: editingValue,
16644
+ references: formulaReferences,
16210
16645
  onBlur: onEditingBlur,
16211
- onChange: (event) => onEditingValueChange(event.target.value),
16212
- onKeyDown: (event) => {
16213
- event.stopPropagation();
16214
- if (event.key === "Enter") {
16215
- event.preventDefault();
16216
- onEditingCommit();
16217
- return;
16218
- }
16219
- if (event.key === "Escape") {
16220
- event.preventDefault();
16221
- onEditingCancel();
16222
- return;
16223
- }
16224
- if (event.key === "ArrowDown" || event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "ArrowUp") {
16225
- event.preventDefault();
16226
- onEditingNavigate(event.key, event.currentTarget.value);
16227
- }
16228
- },
16646
+ onChange: onEditingValueChange,
16647
+ onCommit: onEditingCommit,
16648
+ onCancel: onEditingCancel,
16649
+ onNavigate: onEditingNavigate,
16229
16650
  style: {
16230
- backgroundColor: "transparent",
16231
- border: 0,
16232
- color: "inherit",
16651
+ backgroundColor: cellStyle.backgroundColor ?? palette.surface,
16652
+ boxShadow: editorBoxShadow,
16653
+ color: cellStyle.color ?? palette.text,
16233
16654
  font: "inherit",
16234
- height: "100%",
16235
- margin: 0,
16236
- outline: "none",
16237
- padding: scaleCssLengthExpression(DEFAULT_CELL_PADDING, zoomFactor),
16238
- width: "100%"
16239
- },
16240
- value: editingValue
16655
+ lineHeight: cellData.style.lineHeight,
16656
+ verticalAlign: cellData.style.verticalAlign,
16657
+ padding: cellData.style.padding
16658
+ }
16241
16659
  }
16242
- ) : isSpilling ? /* @__PURE__ */ jsx3(
16660
+ ) : isSpilling ? /* @__PURE__ */ jsx4(
16243
16661
  "div",
16244
16662
  {
16245
16663
  style: {
@@ -16253,7 +16671,7 @@ function GridRow({
16253
16671
  },
16254
16672
  children: cellData.value
16255
16673
  }
16256
- ) : cellData.sparkline ? /* @__PURE__ */ jsx3(
16674
+ ) : cellData.sparkline ? /* @__PURE__ */ jsx4(
16257
16675
  "div",
16258
16676
  {
16259
16677
  style: {
@@ -16266,7 +16684,7 @@ function GridRow({
16266
16684
  },
16267
16685
  children: renderSparkline(cellData.sparkline.config, cellData.sparkline.values, palette)
16268
16686
  }
16269
- ) : cellData.checkboxState != null ? /* @__PURE__ */ jsx3(
16687
+ ) : cellData.checkboxState != null ? /* @__PURE__ */ jsx4(
16270
16688
  "div",
16271
16689
  {
16272
16690
  style: {
@@ -16279,13 +16697,13 @@ function GridRow({
16279
16697
  },
16280
16698
  children: renderCheckboxControl(cellData.checkboxState, palette, zoomFactor)
16281
16699
  }
16282
- ) : /* @__PURE__ */ jsx3("div", { style: cellContentStyle, children: rotatedTextStyle ? /* @__PURE__ */ jsx3("span", { style: { ...rotatedTextBounds, flex: "0 0 auto", position: "relative" }, children: /* @__PURE__ */ jsx3("span", { style: rotatedTextStyle, children: cellData.value }) }) : wrappedTextStyle ? /* @__PURE__ */ jsx3("span", { style: wrappedTextStyle, children: cellData.value }) : cellData.value })
16700
+ ) : /* @__PURE__ */ jsx4("div", { style: cellContentStyle, children: rotatedTextStyle ? /* @__PURE__ */ jsx4("span", { style: { ...rotatedTextBounds, flex: "0 0 auto", position: "relative" }, children: /* @__PURE__ */ jsx4("span", { style: rotatedTextStyle, children: cellData.value }) }) : wrappedTextStyle ? /* @__PURE__ */ jsx4("span", { style: wrappedTextStyle, children: cellData.value }) : cellData.value })
16283
16701
  ]
16284
16702
  },
16285
16703
  key
16286
16704
  );
16287
16705
  }),
16288
- trailingSpacerWidth > 0 ? /* @__PURE__ */ jsx3(
16706
+ trailingSpacerWidth > 0 ? /* @__PURE__ */ jsx4(
16289
16707
  "td",
16290
16708
  {
16291
16709
  "aria-hidden": "true",
@@ -16299,7 +16717,7 @@ function GridRow({
16299
16717
  ) : null
16300
16718
  ] });
16301
16719
  }
16302
- var MemoGridRow = React5.memo(GridRow, (prev, next) => {
16720
+ var MemoGridRow = React6.memo(GridRow, (prev, next) => {
16303
16721
  if (prev.actualRow !== next.actualRow || prev.rowHeight !== next.rowHeight || prev.headerLabelLiveScale !== next.headerLabelLiveScale || prev.palette !== next.palette || prev.readOnly !== next.readOnly || prev.visibleCols !== next.visibleCols || prev.leadingSpacerWidth !== next.leadingSpacerWidth || prev.rowHeaderWidth !== next.rowHeaderWidth || prev.stickyLeftByCol !== next.stickyLeftByCol || prev.stickyTop !== next.stickyTop || prev.trailingSpacerWidth !== next.trailingSpacerWidth || prev.zoomFactor !== next.zoomFactor || prev.getCellData !== next.getCellData || prev.onCellClick !== next.onCellClick || prev.onCellDoubleClick !== next.onCellDoubleClick || prev.onCellPointerDown !== next.onCellPointerDown || prev.onEditingBlur !== next.onEditingBlur || prev.onEditingCancel !== next.onEditingCancel || prev.onEditingCommit !== next.onEditingCommit || prev.onEditingNavigate !== next.onEditingNavigate || prev.onEditingValueChange !== next.onEditingValueChange || prev.onRowHeaderRef !== next.onRowHeaderRef || prev.onRowPointerDown !== next.onRowPointerDown || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment) {
16304
16722
  return false;
16305
16723
  }
@@ -16308,7 +16726,7 @@ var MemoGridRow = React5.memo(GridRow, (prev, next) => {
16308
16726
  if (prevEditingCol !== nextEditingCol) {
16309
16727
  return false;
16310
16728
  }
16311
- if (prevEditingCol !== -1 && prev.editingValue !== next.editingValue) {
16729
+ if (prevEditingCol !== -1 && (prev.editingValue !== next.editingValue || prev.formulaReferences !== next.formulaReferences || prev.editorBoxShadow !== next.editorBoxShadow)) {
16312
16730
  return false;
16313
16731
  }
16314
16732
  return true;
@@ -16319,16 +16737,16 @@ function XlsxViewerProviderWithInlineController({
16319
16737
  ...options
16320
16738
  }) {
16321
16739
  const controller = useXlsxViewerController(options);
16322
- return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children }) });
16740
+ return /* @__PURE__ */ jsx4(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx4(ViewerContext.Provider, { value: controller, children }) });
16323
16741
  }
16324
16742
  function XlsxViewerProvider({ children, controller, isDark = false, ...options }) {
16325
16743
  if (controller) {
16326
- return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children }) });
16744
+ return /* @__PURE__ */ jsx4(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx4(ViewerContext.Provider, { value: controller, children }) });
16327
16745
  }
16328
- return /* @__PURE__ */ jsx3(XlsxViewerProviderWithInlineController, { ...options, isDark, children });
16746
+ return /* @__PURE__ */ jsx4(XlsxViewerProviderWithInlineController, { ...options, isDark, children });
16329
16747
  }
16330
16748
  function useXlsxViewer() {
16331
- const context = React5.useContext(ViewerContext);
16749
+ const context = React6.useContext(ViewerContext);
16332
16750
  if (!context) {
16333
16751
  throw new Error("useXlsxViewer must be used inside XlsxViewer or XlsxViewerProvider.");
16334
16752
  }
@@ -16344,7 +16762,7 @@ function useXlsxViewerSelection() {
16344
16762
  selectRange,
16345
16763
  selection
16346
16764
  } = useXlsxViewer();
16347
- return React5.useMemo(
16765
+ return React6.useMemo(
16348
16766
  () => ({
16349
16767
  activeCell,
16350
16768
  activeCellAddress,
@@ -16370,7 +16788,7 @@ function useXlsxViewerZoom() {
16370
16788
  zoomOut,
16371
16789
  zoomScale
16372
16790
  } = useXlsxViewer();
16373
- return React5.useMemo(
16791
+ return React6.useMemo(
16374
16792
  () => ({
16375
16793
  canZoomIn,
16376
16794
  canZoomOut,
@@ -16438,7 +16856,7 @@ function useXlsxViewerEditing() {
16438
16856
  unmergeSelection,
16439
16857
  updateFormControl
16440
16858
  } = useXlsxViewer();
16441
- return React5.useMemo(
16859
+ return React6.useMemo(
16442
16860
  () => ({
16443
16861
  addFormControl,
16444
16862
  addSheet,
@@ -16523,7 +16941,7 @@ function useXlsxViewerEditing() {
16523
16941
  }
16524
16942
  function useXlsxViewerTables() {
16525
16943
  const { sortState, sortTable, tables } = useXlsxViewer();
16526
- return React5.useMemo(
16944
+ return React6.useMemo(
16527
16945
  () => ({
16528
16946
  sortState,
16529
16947
  sortTable,
@@ -16564,7 +16982,7 @@ function useXlsxViewerImages() {
16564
16982
  setImageRect,
16565
16983
  updateChart
16566
16984
  } = useXlsxViewer();
16567
- return React5.useMemo(
16985
+ return React6.useMemo(
16568
16986
  () => ({
16569
16987
  charts,
16570
16988
  clearSelectedChart,
@@ -16657,7 +17075,7 @@ function useXlsxViewerCharts() {
16657
17075
  tabs,
16658
17076
  updateChart
16659
17077
  } = useXlsxViewer();
16660
- return React5.useMemo(
17078
+ return React6.useMemo(
16661
17079
  () => ({
16662
17080
  activeTab,
16663
17081
  activeTabIndex,
@@ -16724,30 +17142,30 @@ function useXlsxViewerThumbnails(options = {}) {
16724
17142
  workbook,
16725
17143
  sheets
16726
17144
  } = useXlsxViewer();
16727
- const { headerBackgroundColor, headerTextColor, isDark } = React5.useContext(ViewerAppearanceContext);
17145
+ const { headerBackgroundColor, headerTextColor, isDark } = React6.useContext(ViewerAppearanceContext);
16728
17146
  const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
16729
17147
  const includeHeaders = options.includeHeaders ?? true;
16730
17148
  const resolution = options.resolution;
16731
- const thumbnailImageCacheRef = React5.useRef(/* @__PURE__ */ new Map());
16732
- const workerThumbnailRowBatchCacheRef = React5.useRef(/* @__PURE__ */ new Map());
16733
- const workerThumbnailRowBatchRequestRef = React5.useRef(
17149
+ const thumbnailImageCacheRef = React6.useRef(/* @__PURE__ */ new Map());
17150
+ const workerThumbnailRowBatchCacheRef = React6.useRef(/* @__PURE__ */ new Map());
17151
+ const workerThumbnailRowBatchRequestRef = React6.useRef(
16734
17152
  /* @__PURE__ */ new Map()
16735
17153
  );
16736
- const isMountedRef = React5.useRef(false);
16737
- const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] = React5.useState(0);
16738
- const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] = React5.useState(0);
16739
- React5.useEffect(() => {
17154
+ const isMountedRef = React6.useRef(false);
17155
+ const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] = React6.useState(0);
17156
+ const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] = React6.useState(0);
17157
+ React6.useEffect(() => {
16740
17158
  isMountedRef.current = true;
16741
17159
  return () => {
16742
17160
  isMountedRef.current = false;
16743
17161
  };
16744
17162
  }, []);
16745
- React5.useEffect(() => {
17163
+ React6.useEffect(() => {
16746
17164
  workerThumbnailRowBatchCacheRef.current.clear();
16747
17165
  workerThumbnailRowBatchRequestRef.current.clear();
16748
17166
  setWorkerThumbnailRowBatchVersion((version) => version + 1);
16749
17167
  }, [locale]);
16750
- React5.useEffect(() => {
17168
+ React6.useEffect(() => {
16751
17169
  const currentSheets = new Set(sheets);
16752
17170
  for (const sheet of workerThumbnailRowBatchCacheRef.current.keys()) {
16753
17171
  if (!currentSheets.has(sheet)) {
@@ -16760,7 +17178,7 @@ function useXlsxViewerThumbnails(options = {}) {
16760
17178
  }
16761
17179
  }
16762
17180
  }, [sheets]);
16763
- const getWorkerThumbnailRowBatch = React5.useCallback((sheet, startRow, endRow) => {
17181
+ const getWorkerThumbnailRowBatch = React6.useCallback((sheet, startRow, endRow) => {
16764
17182
  const cachedBatch = workerThumbnailRowBatchCacheRef.current.get(sheet);
16765
17183
  if (cachedBatch && startRow >= cachedBatch.startRow && endRow <= cachedBatch.endRow) {
16766
17184
  return cachedBatch;
@@ -16802,7 +17220,7 @@ function useXlsxViewerThumbnails(options = {}) {
16802
17220
  }
16803
17221
  return null;
16804
17222
  }, [getRowsBatchAsync]);
16805
- const getThumbnailImage = React5.useCallback((image) => {
17223
+ const getThumbnailImage = React6.useCallback((image) => {
16806
17224
  if (typeof Image === "undefined") {
16807
17225
  return null;
16808
17226
  }
@@ -16834,7 +17252,7 @@ function useXlsxViewerThumbnails(options = {}) {
16834
17252
  imageElement.src = image.src;
16835
17253
  return null;
16836
17254
  }, []);
16837
- const thumbnails = React5.useMemo(() => {
17255
+ const thumbnails = React6.useMemo(() => {
16838
17256
  return sheets.map((sheet, sheetIndex) => {
16839
17257
  const worksheet = workbook?.getSheet(sheet.workbookSheetIndex) ?? null;
16840
17258
  const sheetImages = getSheetImages(sheetIndex).filter((image) => image.src).sort((left, right) => left.zIndex - right.zIndex);
@@ -17408,11 +17826,11 @@ function useXlsxViewerThumbnails(options = {}) {
17408
17826
  locale,
17409
17827
  workbook
17410
17828
  ]);
17411
- const paintThumbnail = React5.useCallback(
17829
+ const paintThumbnail = React6.useCallback(
17412
17830
  (sheetIndex, canvas) => thumbnails[sheetIndex]?.paint(canvas) ?? false,
17413
17831
  [thumbnails]
17414
17832
  );
17415
- return React5.useMemo(
17833
+ return React6.useMemo(
17416
17834
  () => ({
17417
17835
  paintThumbnail,
17418
17836
  thumbnails
@@ -17422,13 +17840,13 @@ function useXlsxViewerThumbnails(options = {}) {
17422
17840
  }
17423
17841
  function DefaultXlsxToolbar() {
17424
17842
  const controller = useXlsxViewer();
17425
- const { headerBackgroundColor, headerTextColor, isDark } = React5.useContext(ViewerAppearanceContext);
17843
+ const { headerBackgroundColor, headerTextColor, isDark } = React6.useContext(ViewerAppearanceContext);
17426
17844
  const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
17427
- return /* @__PURE__ */ jsx3(DefaultToolbar, { controller, palette });
17845
+ return /* @__PURE__ */ jsx4(DefaultToolbar, { controller, palette });
17428
17846
  }
17429
17847
 
17430
17848
  // src/react-viewer.tsx
17431
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
17849
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
17432
17850
  var SlotStore = class {
17433
17851
  slots = /* @__PURE__ */ new Map();
17434
17852
  listeners = /* @__PURE__ */ new Set();
@@ -17497,9 +17915,9 @@ var SlotStore = class {
17497
17915
  }
17498
17916
  };
17499
17917
  function RuntimeContent({ content }) {
17500
- const hostRef = React6.useRef(null);
17501
- const rootRef = React6.useRef(null);
17502
- React6.useLayoutEffect(() => {
17918
+ const hostRef = React7.useRef(null);
17919
+ const rootRef = React7.useRef(null);
17920
+ React7.useLayoutEffect(() => {
17503
17921
  const host = hostRef.current;
17504
17922
  if (!host) return;
17505
17923
  const root = __createContentRoot(host);
@@ -17509,14 +17927,14 @@ function RuntimeContent({ content }) {
17509
17927
  root.destroy();
17510
17928
  };
17511
17929
  }, []);
17512
- React6.useLayoutEffect(() => {
17930
+ React7.useLayoutEffect(() => {
17513
17931
  rootRef.current?.update(content);
17514
17932
  }, [content]);
17515
- return /* @__PURE__ */ jsx4("span", { ref: hostRef, style: { display: "contents" } });
17933
+ return /* @__PURE__ */ jsx5("span", { ref: hostRef, style: { display: "contents" } });
17516
17934
  }
17517
17935
  function renderOptions(props, controller, slots, owner) {
17518
17936
  const slot = (key, node) => slots.render(key, node, owner);
17519
- const runtime = (node) => /* @__PURE__ */ jsx4(RuntimeContent, { content: node });
17937
+ const runtime = (node) => /* @__PURE__ */ jsx5(RuntimeContent, { content: node });
17520
17938
  const {
17521
17939
  emptyState,
17522
17940
  errorState,
@@ -17554,11 +17972,11 @@ function renderOptions(props, controller, slots, owner) {
17554
17972
  };
17555
17973
  }
17556
17974
  function BoundViewer({ props, controller }) {
17557
- const hostRef = React6.useRef(null);
17558
- const viewerRef = React6.useRef(null);
17559
- const slots = React6.useMemo(() => new SlotStore(), []);
17560
- React6.useSyncExternalStore(slots.subscribe, slots.getSnapshot, slots.getServerSnapshot);
17561
- React6.useLayoutEffect(() => {
17975
+ const hostRef = React7.useRef(null);
17976
+ const viewerRef = React7.useRef(null);
17977
+ const slots = React7.useMemo(() => new SlotStore(), []);
17978
+ React7.useSyncExternalStore(slots.subscribe, slots.getSnapshot, slots.getServerSnapshot);
17979
+ React7.useLayoutEffect(() => {
17562
17980
  const host = hostRef.current;
17563
17981
  if (!host) return;
17564
17982
  slots.observe(host);
@@ -17570,27 +17988,27 @@ function BoundViewer({ props, controller }) {
17570
17988
  slots.destroy();
17571
17989
  };
17572
17990
  }, [slots]);
17573
- React6.useLayoutEffect(() => {
17991
+ React7.useLayoutEffect(() => {
17574
17992
  const host = hostRef.current;
17575
17993
  if (host) viewerRef.current?.update(renderOptions(props, controller, slots, host.ownerDocument));
17576
17994
  }, [controller, props, slots]);
17577
- return /* @__PURE__ */ jsx4(ViewerAppearanceContext.Provider, { value: {
17995
+ return /* @__PURE__ */ jsx5(ViewerAppearanceContext.Provider, { value: {
17578
17996
  headerBackgroundColor: props.headerBackgroundColor,
17579
17997
  headerTextColor: props.headerTextColor,
17580
17998
  isDark: props.isDark ?? false
17581
- }, children: /* @__PURE__ */ jsxs3(ViewerContext.Provider, { value: controller, children: [
17582
- /* @__PURE__ */ jsx4("div", { ref: hostRef, style: { display: "contents" } }),
17999
+ }, children: /* @__PURE__ */ jsxs4(ViewerContext.Provider, { value: controller, children: [
18000
+ /* @__PURE__ */ jsx5("div", { ref: hostRef, style: { display: "contents" } }),
17583
18001
  slots.portals()
17584
18002
  ] }) });
17585
18003
  }
17586
18004
  function UncontrolledViewer(props) {
17587
18005
  const controller = useXlsxViewerController(props);
17588
- return /* @__PURE__ */ jsx4(BoundViewer, { props, controller });
18006
+ return /* @__PURE__ */ jsx5(BoundViewer, { props, controller });
17589
18007
  }
17590
18008
  function XlsxViewer(props) {
17591
- const context = React6.useContext(ViewerContext);
18009
+ const context = React7.useContext(ViewerContext);
17592
18010
  const controller = props.controller ?? context;
17593
- return controller ? /* @__PURE__ */ jsx4(BoundViewer, { props, controller }) : /* @__PURE__ */ jsx4(UncontrolledViewer, { ...props });
18011
+ return controller ? /* @__PURE__ */ jsx5(BoundViewer, { props, controller }) : /* @__PURE__ */ jsx5(UncontrolledViewer, { ...props });
17594
18012
  }
17595
18013
  export {
17596
18014
  DefaultXlsxToolbar,