@extend-ai/react-xlsx 0.1.0 → 0.3.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.
package/dist/index.js CHANGED
@@ -5929,21 +5929,35 @@ function getSheetsWasmModule() {
5929
5929
  }
5930
5930
 
5931
5931
  // src/worker-client.ts
5932
+ function createAbortError() {
5933
+ if (typeof DOMException !== "undefined") {
5934
+ return new DOMException("Aborted", "AbortError");
5935
+ }
5936
+ const error = new Error("Aborted");
5937
+ error.name = "AbortError";
5938
+ return error;
5939
+ }
5932
5940
  var XlsxWorkerClient = class {
5933
5941
  worker;
5934
5942
  nextRequestId = 1;
5935
5943
  pendingRequests = /* @__PURE__ */ new Map();
5944
+ disposed = false;
5936
5945
  constructor() {
5937
5946
  this.worker = new Worker(new URL("./xlsx-worker.js", import.meta.url), { type: "module" });
5938
5947
  this.worker.addEventListener("message", this.handleMessage);
5939
5948
  this.worker.addEventListener("error", this.handleError);
5940
5949
  }
5941
5950
  dispose() {
5951
+ if (this.disposed) {
5952
+ return;
5953
+ }
5954
+ this.disposed = true;
5942
5955
  this.worker.removeEventListener("message", this.handleMessage);
5943
5956
  this.worker.removeEventListener("error", this.handleError);
5944
5957
  this.worker.terminate();
5958
+ const abortError = createAbortError();
5945
5959
  for (const request of this.pendingRequests.values()) {
5946
- request.reject(new Error("Worker was disposed."));
5960
+ request.reject(abortError);
5947
5961
  }
5948
5962
  this.pendingRequests.clear();
5949
5963
  }
@@ -5979,6 +5993,10 @@ var XlsxWorkerClient = class {
5979
5993
  }
5980
5994
  request(message, transfer = []) {
5981
5995
  return new Promise((resolve, reject) => {
5996
+ if (this.disposed) {
5997
+ reject(createAbortError());
5998
+ return;
5999
+ }
5982
6000
  const id = this.nextRequestId;
5983
6001
  this.nextRequestId += 1;
5984
6002
  this.pendingRequests.set(id, { reject, resolve });
@@ -6610,12 +6628,26 @@ function parseClipboardText(text) {
6610
6628
  }
6611
6629
  return rows.map((row) => row.split(" "));
6612
6630
  }
6613
- async function resolveWorkbookBuffer({ file, src }) {
6631
+ function createAbortError2() {
6632
+ if (typeof DOMException !== "undefined") {
6633
+ return new DOMException("Aborted", "AbortError");
6634
+ }
6635
+ const error = new Error("Aborted");
6636
+ error.name = "AbortError";
6637
+ return error;
6638
+ }
6639
+ function isAbortError(error) {
6640
+ return error instanceof Error && error.name === "AbortError";
6641
+ }
6642
+ async function resolveWorkbookBuffer({ file, src }, signal) {
6614
6643
  let buffer;
6644
+ if (signal?.aborted) {
6645
+ throw createAbortError2();
6646
+ }
6615
6647
  if (file) {
6616
6648
  buffer = file;
6617
6649
  } else if (src) {
6618
- const response = await fetch(src);
6650
+ const response = await fetch(src, { signal });
6619
6651
  if (!response.ok) {
6620
6652
  throw new Error(`Failed to fetch workbook (status ${response.status})`);
6621
6653
  }
@@ -7380,10 +7412,13 @@ function useXlsxViewerController(options) {
7380
7412
  } catch {
7381
7413
  triggerFallback();
7382
7414
  }
7383
- }).catch(() => {
7415
+ }).catch((error2) => {
7384
7416
  if (workerTimeoutHandle !== null) {
7385
7417
  window.clearTimeout(workerTimeoutHandle);
7386
7418
  }
7419
+ if (isAbortError(error2)) {
7420
+ return;
7421
+ }
7387
7422
  triggerFallback();
7388
7423
  });
7389
7424
  }, [getWorkerClient, hasIncompleteWorkerChartSnapshot, setChartAssets, workerSupported]);
@@ -7453,6 +7488,7 @@ function useXlsxViewerController(options) {
7453
7488
  return;
7454
7489
  }
7455
7490
  let isCurrent = true;
7491
+ const abortController = new AbortController();
7456
7492
  setIsLoading(true);
7457
7493
  setError(null);
7458
7494
  clearImageAssets();
@@ -7477,11 +7513,9 @@ function useXlsxViewerController(options) {
7477
7513
  setSortState(null);
7478
7514
  setZoomScaleOverridesByTabId({});
7479
7515
  setRevision(0);
7480
- if (!workerSupported) {
7481
- disposeWorkerClient();
7482
- }
7483
- void resolveWorkbookBuffer({ file, src }).then(async (buffer) => {
7484
- if (!isCurrent) {
7516
+ disposeWorkerClient();
7517
+ void resolveWorkbookBuffer({ file, src }, abortController.signal).then(async (buffer) => {
7518
+ if (!isCurrent || abortController.signal.aborted) {
7485
7519
  return;
7486
7520
  }
7487
7521
  if (maxFileSizeBytes > 0 && buffer.byteLength > maxFileSizeBytes) {
@@ -7507,7 +7541,7 @@ function useXlsxViewerController(options) {
7507
7541
  if (shouldUseWorkerForLoad) {
7508
7542
  try {
7509
7543
  const snapshot = await getWorkerClient().loadWorkbook(buffer);
7510
- if (!isCurrent) {
7544
+ if (!isCurrent || abortController.signal.aborted) {
7511
7545
  return;
7512
7546
  }
7513
7547
  if (hasIncompleteWorkerChartSnapshot(snapshot)) {
@@ -7527,6 +7561,9 @@ function useXlsxViewerController(options) {
7527
7561
  setIsLoading(false);
7528
7562
  return;
7529
7563
  } catch (workerError) {
7564
+ if (!isCurrent || isAbortError(workerError)) {
7565
+ return;
7566
+ }
7530
7567
  if (!shouldFallbackFromWorkerError(workerError)) {
7531
7568
  throw workerError;
7532
7569
  }
@@ -7534,7 +7571,7 @@ function useXlsxViewerController(options) {
7534
7571
  }
7535
7572
  }
7536
7573
  const { imageAssets: nextImageAssets, parsedWorkbook: nextParsedWorkbook } = await loadWorkbookOnMainThread(buffer);
7537
- if (!isCurrent) {
7574
+ if (!isCurrent || abortController.signal.aborted) {
7538
7575
  revokeWorkbookImageAssets(nextImageAssets);
7539
7576
  return;
7540
7577
  }
@@ -7556,7 +7593,7 @@ function useXlsxViewerController(options) {
7556
7593
  setSortState(null);
7557
7594
  setIsLoading(false);
7558
7595
  }).catch((nextError) => {
7559
- if (!isCurrent) {
7596
+ if (!isCurrent || isAbortError(nextError)) {
7560
7597
  return;
7561
7598
  }
7562
7599
  setWorkbook(null);
@@ -7572,9 +7609,8 @@ function useXlsxViewerController(options) {
7572
7609
  });
7573
7610
  return () => {
7574
7611
  isCurrent = false;
7575
- if (!workerSupported) {
7576
- disposeWorkerClient();
7577
- }
7612
+ abortController.abort();
7613
+ disposeWorkerClient();
7578
7614
  };
7579
7615
  }, [
7580
7616
  clearChartAssets,
@@ -7740,6 +7776,9 @@ function useXlsxViewerController(options) {
7740
7776
  setIsChartsLoading(false);
7741
7777
  setIsLoading(false);
7742
7778
  }).catch(async (workerError) => {
7779
+ if (isAbortError(workerError)) {
7780
+ return;
7781
+ }
7743
7782
  if (!shouldFallbackFromWorkerError(workerError)) {
7744
7783
  throw workerError;
7745
7784
  }
@@ -9422,9 +9461,6 @@ function useXlsxViewerController(options) {
9422
9461
  // src/XlsxViewer.tsx
9423
9462
  import * as React4 from "react";
9424
9463
  import {
9425
- elementScroll,
9426
- observeElementOffset,
9427
- observeElementRect,
9428
9464
  useVirtualizer
9429
9465
  } from "@tanstack/react-virtual";
9430
9466
 
@@ -15888,21 +15924,68 @@ var IMAGE_HANDLE_CURSOR = {
15888
15924
  sw: "nesw-resize",
15889
15925
  w: "ew-resize"
15890
15926
  };
15891
- function observeZoomedElementRect(instance, zoomFactor, cb) {
15892
- return observeElementRect(instance, (rect) => {
15893
- cb({
15894
- height: rect.height / zoomFactor,
15895
- width: rect.width / zoomFactor
15896
- });
15927
+ var NUMERIC_LENGTH_STYLE_KEYS = /* @__PURE__ */ new Set([
15928
+ "borderRadius",
15929
+ "borderTopLeftRadius",
15930
+ "borderTopRightRadius",
15931
+ "borderBottomLeftRadius",
15932
+ "borderBottomRightRadius",
15933
+ "bottom",
15934
+ "fontSize",
15935
+ "gap",
15936
+ "height",
15937
+ "left",
15938
+ "letterSpacing",
15939
+ "margin",
15940
+ "marginBottom",
15941
+ "marginLeft",
15942
+ "marginRight",
15943
+ "marginTop",
15944
+ "maxHeight",
15945
+ "maxWidth",
15946
+ "minHeight",
15947
+ "minWidth",
15948
+ "outlineOffset",
15949
+ "outlineWidth",
15950
+ "padding",
15951
+ "paddingBottom",
15952
+ "paddingLeft",
15953
+ "paddingRight",
15954
+ "paddingTop",
15955
+ "right",
15956
+ "textIndent",
15957
+ "top",
15958
+ "width"
15959
+ ]);
15960
+ function scaleCssLengthExpression(value, scale) {
15961
+ if (scale === 1) {
15962
+ return value;
15963
+ }
15964
+ return value.replace(/(-?\d*\.?\d+)(px|pt)\b/g, (_, rawNumber, unit) => {
15965
+ const nextValue = Number.parseFloat(rawNumber);
15966
+ if (!Number.isFinite(nextValue)) {
15967
+ return `${rawNumber}${unit}`;
15968
+ }
15969
+ return `${nextValue * scale}${unit}`;
15897
15970
  });
15898
15971
  }
15899
- function observeZoomedElementOffset(instance, zoomFactor, cb) {
15900
- return observeElementOffset(instance, (offset, isScrolling) => {
15901
- cb(offset / zoomFactor, isScrolling);
15972
+ function scaleCssProperties(style, scale) {
15973
+ if (scale === 1) {
15974
+ return style;
15975
+ }
15976
+ const nextStyle = {};
15977
+ Object.entries(style).forEach(([key, value]) => {
15978
+ if (typeof value === "string") {
15979
+ nextStyle[key] = scaleCssLengthExpression(value, scale);
15980
+ return;
15981
+ }
15982
+ if (typeof value === "number" && NUMERIC_LENGTH_STYLE_KEYS.has(key)) {
15983
+ nextStyle[key] = value * scale;
15984
+ return;
15985
+ }
15986
+ nextStyle[key] = value;
15902
15987
  });
15903
- }
15904
- function scrollToZoomedOffset(offset, zoomFactor, options, instance) {
15905
- elementScroll(offset * zoomFactor, options, instance);
15988
+ return nextStyle;
15906
15989
  }
15907
15990
  function formatZoomScale(zoomScale) {
15908
15991
  return `${Math.round(zoomScale)}%`;
@@ -15981,6 +16064,7 @@ function darkenColor3(color, ratio) {
15981
16064
  return mixRgbColor3(color, "#000000", ratio);
15982
16065
  }
15983
16066
  var ViewerContext = React4.createContext(null);
16067
+ var ViewerAppearanceContext = React4.createContext({ isDark: false });
15984
16068
  function classNames(...values) {
15985
16069
  return values.filter(Boolean).join(" ");
15986
16070
  }
@@ -16138,7 +16222,9 @@ function resolveAxisStartOffset(actualIndex, actualIndices, sizes, indexByActual
16138
16222
  return sumBeforeActualIndex(actualIndices, sizes, actualIndex);
16139
16223
  }
16140
16224
  function resolveAnchoredRect(anchor, visibleRows, visibleCols, rowHeights, colWidths, options) {
16141
- const resolveMarkerLeft = (col, colOffsetEmu) => ROW_HEADER_WIDTH + resolveAxisStartOffset(
16225
+ const headerHeight = options?.headerHeight ?? HEADER_HEIGHT;
16226
+ const rowHeaderWidth = options?.rowHeaderWidth ?? ROW_HEADER_WIDTH;
16227
+ const resolveMarkerLeft = (col, colOffsetEmu) => rowHeaderWidth + resolveAxisStartOffset(
16142
16228
  col,
16143
16229
  visibleCols,
16144
16230
  colWidths,
@@ -16146,7 +16232,7 @@ function resolveAnchoredRect(anchor, visibleRows, visibleCols, rowHeights, colWi
16146
16232
  options?.colPrefixSums,
16147
16233
  options?.actualColPrefixSums
16148
16234
  ) + emuToPixels(colOffsetEmu);
16149
- const resolveMarkerTop = (row, rowOffsetEmu) => HEADER_HEIGHT + resolveAxisStartOffset(
16235
+ const resolveMarkerTop = (row, rowOffsetEmu) => headerHeight + resolveAxisStartOffset(
16150
16236
  row,
16151
16237
  visibleRows,
16152
16238
  rowHeights,
@@ -16157,8 +16243,8 @@ function resolveAnchoredRect(anchor, visibleRows, visibleCols, rowHeights, colWi
16157
16243
  if (anchor.kind === "absolute") {
16158
16244
  return {
16159
16245
  height: Math.max(1, emuToPixels(anchor.sizeEmu.cy)),
16160
- left: ROW_HEADER_WIDTH + emuToPixels(anchor.positionEmu.x),
16161
- top: HEADER_HEIGHT + emuToPixels(anchor.positionEmu.y),
16246
+ left: rowHeaderWidth + emuToPixels(anchor.positionEmu.x),
16247
+ top: headerHeight + emuToPixels(anchor.positionEmu.y),
16162
16248
  width: Math.max(1, emuToPixels(anchor.sizeEmu.cx))
16163
16249
  };
16164
16250
  }
@@ -16238,14 +16324,18 @@ function rectIntersectsViewport(rect, viewport, overscan = 240) {
16238
16324
  const rectBottom = rect.top + rect.height;
16239
16325
  return rectRight >= viewportLeft && rect.left <= viewportRight && rectBottom >= viewportTop && rect.top <= viewportBottom;
16240
16326
  }
16241
- function resolveFrozenDrawingPane(rect, frozenRows, frozenCols, actualRowHeights, actualColWidths, freezePanes, stickyTopByRow, stickyLeftByCol) {
16327
+ function resolveFrozenDrawingPane(rect, frozenRows, frozenCols, actualRowHeights, actualColWidths, freezePanes, stickyTopByRow, stickyLeftByCol, options) {
16328
+ const headerHeight = options?.headerHeight ?? HEADER_HEIGHT;
16329
+ const rowHeaderWidth = options?.rowHeaderWidth ?? ROW_HEADER_WIDTH;
16330
+ const defaultRowHeight = options?.defaultRowHeight ?? DEFAULT_ROW_HEIGHT2;
16331
+ const defaultColWidth = options?.defaultColWidth ?? DEFAULT_COL_WIDTH2;
16242
16332
  const frozenPaneBottom = freezePanes?.row && freezePanes.row > 0 && frozenRows.length > 0 ? frozenRows.reduce(
16243
- (max, row) => Math.max(max, (stickyTopByRow.get(row) ?? HEADER_HEIGHT) + (actualRowHeights[row] ?? DEFAULT_ROW_HEIGHT2)),
16244
- HEADER_HEIGHT
16333
+ (max, row) => Math.max(max, (stickyTopByRow.get(row) ?? headerHeight) + (actualRowHeights[row] ?? defaultRowHeight)),
16334
+ headerHeight
16245
16335
  ) : null;
16246
16336
  const frozenPaneRight = freezePanes?.col && freezePanes.col > 0 && frozenCols.length > 0 ? frozenCols.reduce(
16247
- (max, col) => Math.max(max, (stickyLeftByCol.get(col) ?? ROW_HEADER_WIDTH) + (actualColWidths[col] ?? DEFAULT_COL_WIDTH2)),
16248
- ROW_HEADER_WIDTH
16337
+ (max, col) => Math.max(max, (stickyLeftByCol.get(col) ?? rowHeaderWidth) + (actualColWidths[col] ?? defaultColWidth)),
16338
+ rowHeaderWidth
16249
16339
  ) : null;
16250
16340
  const freezeTop = frozenPaneBottom !== null && rect.top + rect.height <= frozenPaneBottom + 0.5;
16251
16341
  const freezeLeft = frozenPaneRight !== null && rect.left + rect.width <= frozenPaneRight + 0.5;
@@ -16260,8 +16350,8 @@ function resolveFrozenDrawingPane(rect, frozenRows, frozenCols, actualRowHeights
16260
16350
  }
16261
16351
  return "scroll";
16262
16352
  }
16263
- function buildShapeContainerStyle(shape, rect) {
16264
- const borderWidth = shape.stroke?.none ? 0 : Math.max(0, shape.stroke?.widthPx ?? 0);
16353
+ function buildShapeContainerStyle(shape, rect, viewerScale = 1) {
16354
+ const borderWidth = shape.stroke?.none ? 0 : Math.max(0, shape.stroke?.widthPx ?? 0) * viewerScale;
16265
16355
  const strokeColor = shape.stroke?.color ?? "transparent";
16266
16356
  const fillColor = shape.fill?.none ? "transparent" : shape.fill?.color ?? "transparent";
16267
16357
  const hasVisibleText = shape.paragraphs.some((paragraph) => paragraph.runs.some((run) => run.text.trim().length > 0));
@@ -16274,7 +16364,7 @@ function buildShapeContainerStyle(shape, rect) {
16274
16364
  if (shape.geometry === "ellipse") {
16275
16365
  borderRadius = "9999px";
16276
16366
  } else if (shape.geometry === "roundRect") {
16277
- borderRadius = 12;
16367
+ borderRadius = 12 * viewerScale;
16278
16368
  }
16279
16369
  return {
16280
16370
  alignItems: shape.textBox?.verticalAlign === "middle" ? "center" : shape.textBox?.verticalAlign === "bottom" ? "flex-end" : "flex-start",
@@ -17202,25 +17292,29 @@ function renderShapeParagraph(paragraph, index, fallbackAlign = "left", textScal
17202
17292
  index
17203
17293
  );
17204
17294
  }
17205
- function clampImageRect(rect) {
17295
+ function clampImageRect(rect, options) {
17296
+ const contentOffsetLeft = options?.contentOffsetLeft ?? ROW_HEADER_WIDTH;
17297
+ const contentOffsetTop = options?.contentOffsetTop ?? HEADER_HEIGHT;
17298
+ const minSizePx = options?.minSizePx ?? IMAGE_MIN_SIZE_PX;
17206
17299
  return {
17207
- height: Math.max(IMAGE_MIN_SIZE_PX, rect.height),
17208
- left: Math.max(ROW_HEADER_WIDTH, rect.left),
17209
- top: Math.max(HEADER_HEIGHT, rect.top),
17210
- width: Math.max(IMAGE_MIN_SIZE_PX, rect.width)
17300
+ height: Math.max(minSizePx, rect.height),
17301
+ left: Math.max(contentOffsetLeft, rect.left),
17302
+ top: Math.max(contentOffsetTop, rect.top),
17303
+ width: Math.max(minSizePx, rect.width)
17211
17304
  };
17212
17305
  }
17213
- function resolveImageHandleStyle(position, stroke, surface) {
17214
- const offset = IMAGE_HANDLE_SIZE_PX / 2;
17306
+ function resolveImageHandleStyle(position, stroke, surface, scale = 1) {
17307
+ const handleSize = IMAGE_HANDLE_SIZE_PX * scale;
17308
+ const offset = handleSize / 2;
17215
17309
  const style = {
17216
17310
  backgroundColor: surface,
17217
- border: `1px solid ${stroke}`,
17218
- borderRadius: 6,
17311
+ border: `${Math.max(1, scale)}px solid ${stroke}`,
17312
+ borderRadius: 6 * scale,
17219
17313
  cursor: IMAGE_HANDLE_CURSOR[position],
17220
- height: IMAGE_HANDLE_SIZE_PX,
17314
+ height: handleSize,
17221
17315
  pointerEvents: "auto",
17222
17316
  position: "absolute",
17223
- width: IMAGE_HANDLE_SIZE_PX
17317
+ width: handleSize
17224
17318
  };
17225
17319
  if (position.includes("n")) {
17226
17320
  style.top = -offset;
@@ -17242,40 +17336,8 @@ function resolveImageHandleStyle(position, stroke, surface) {
17242
17336
  }
17243
17337
  return style;
17244
17338
  }
17245
- function resolveIsDarkMode() {
17246
- if (typeof document === "undefined") {
17247
- return false;
17248
- }
17249
- const classList = document.documentElement.classList;
17250
- if (classList.contains("dark")) {
17251
- return true;
17252
- }
17253
- if (classList.contains("light")) {
17254
- return false;
17255
- }
17256
- return typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches;
17257
- }
17258
- function useViewerPalette() {
17259
- const [isDarkMode, setIsDarkMode] = React4.useState(resolveIsDarkMode);
17260
- React4.useEffect(() => {
17261
- if (typeof window === "undefined") {
17262
- return;
17263
- }
17264
- const update = () => setIsDarkMode(resolveIsDarkMode());
17265
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
17266
- const observer = new MutationObserver(update);
17267
- observer.observe(document.documentElement, {
17268
- attributeFilter: ["class", "data-theme"],
17269
- attributes: true
17270
- });
17271
- mediaQuery.addEventListener?.("change", update);
17272
- update();
17273
- return () => {
17274
- observer.disconnect();
17275
- mediaQuery.removeEventListener?.("change", update);
17276
- };
17277
- }, []);
17278
- return isDarkMode ? DARK_PALETTE : LIGHT_PALETTE;
17339
+ function useViewerPalette(isDark = false) {
17340
+ return isDark ? DARK_PALETTE : LIGHT_PALETTE;
17279
17341
  }
17280
17342
  function columnLabel2(col) {
17281
17343
  let label = "";
@@ -18120,6 +18182,57 @@ function DefaultTableHeaderMenu({
18120
18182
  }
18121
18183
  );
18122
18184
  }
18185
+ function SegmentedControl({
18186
+ items,
18187
+ onValueChange,
18188
+ palette,
18189
+ value
18190
+ }) {
18191
+ return /* @__PURE__ */ jsx3(
18192
+ "div",
18193
+ {
18194
+ "aria-label": "Workbook sheets",
18195
+ role: "tablist",
18196
+ style: {
18197
+ alignItems: "center",
18198
+ backgroundColor: palette.sheetInactiveSurface,
18199
+ border: `1px solid ${palette.strongBorder}`,
18200
+ borderRadius: 10,
18201
+ display: "inline-flex",
18202
+ gap: 2,
18203
+ minHeight: 36,
18204
+ padding: 2
18205
+ },
18206
+ children: items.map((item) => {
18207
+ const selected = item.id === value;
18208
+ return /* @__PURE__ */ jsx3(
18209
+ "button",
18210
+ {
18211
+ "aria-selected": selected,
18212
+ onClick: () => onValueChange(item.id),
18213
+ role: "tab",
18214
+ style: {
18215
+ backgroundColor: selected ? palette.sheetActiveSurface : "transparent",
18216
+ border: "none",
18217
+ borderRadius: 8,
18218
+ boxShadow: selected ? palette.shadow : "none",
18219
+ color: selected ? palette.sheetActiveText : palette.sheetInactiveText,
18220
+ cursor: "pointer",
18221
+ fontSize: 12,
18222
+ fontWeight: selected ? 600 : 500,
18223
+ padding: "7px 12px",
18224
+ transition: "background-color 120ms ease, color 120ms ease, box-shadow 120ms ease",
18225
+ whiteSpace: "nowrap"
18226
+ },
18227
+ type: "button",
18228
+ children: item.label
18229
+ },
18230
+ item.id
18231
+ );
18232
+ })
18233
+ }
18234
+ );
18235
+ }
18123
18236
  function DefaultToolbar({ controller, palette }) {
18124
18237
  const {
18125
18238
  activeTabIndex,
@@ -18241,19 +18354,26 @@ function DefaultToolbar({ controller, palette }) {
18241
18354
  canDownload ? /* @__PURE__ */ jsx3(
18242
18355
  "button",
18243
18356
  {
18357
+ "aria-label": "Download workbook",
18244
18358
  onClick: download,
18245
18359
  style: {
18360
+ alignItems: "center",
18246
18361
  background: palette.buttonSurface,
18247
18362
  border: `1px solid ${palette.strongBorder}`,
18248
18363
  borderRadius: 8,
18249
18364
  color: palette.buttonText,
18250
18365
  cursor: "pointer",
18251
- fontSize: 12,
18366
+ display: "inline-flex",
18367
+ fontSize: 16,
18252
18368
  fontWeight: 500,
18253
- padding: "6px 10px"
18369
+ height: 32,
18370
+ justifyContent: "center",
18371
+ padding: 0,
18372
+ width: 32
18254
18373
  },
18374
+ title: "Download workbook",
18255
18375
  type: "button",
18256
- children: "Download"
18376
+ children: "\u2193"
18257
18377
  }
18258
18378
  ) : null
18259
18379
  ] })
@@ -18266,32 +18386,18 @@ function DefaultToolbar({ controller, palette }) {
18266
18386
  style: {
18267
18387
  backgroundColor: palette.subtleSurface,
18268
18388
  borderBottom: `1px solid ${palette.border}`,
18269
- display: "flex",
18270
- gap: 6,
18271
18389
  overflowX: "auto",
18272
18390
  padding: "8px 12px"
18273
18391
  },
18274
- children: tabs.map((tab, index) => /* @__PURE__ */ jsx3(
18275
- "button",
18392
+ children: /* @__PURE__ */ jsx3(
18393
+ SegmentedControl,
18276
18394
  {
18277
- onClick: () => setActiveTabIndex(index),
18278
- style: {
18279
- backgroundColor: index === activeTabIndex ? palette.sheetActiveSurface : palette.sheetInactiveSurface,
18280
- border: `1px solid ${index === activeTabIndex ? palette.strongBorder : "transparent"}`,
18281
- borderRadius: 8,
18282
- boxShadow: index === activeTabIndex ? palette.shadow : "none",
18283
- color: index === activeTabIndex ? palette.sheetActiveText : palette.sheetInactiveText,
18284
- cursor: "pointer",
18285
- fontSize: 12,
18286
- fontWeight: 500,
18287
- padding: "6px 12px",
18288
- whiteSpace: "nowrap"
18289
- },
18290
- type: "button",
18291
- children: tab.name
18292
- },
18293
- tab.id
18294
- ))
18395
+ items: tabs.map((tab, index) => ({ id: String(index), label: tab.name })),
18396
+ onValueChange: (value) => setActiveTabIndex(Number(value)),
18397
+ palette,
18398
+ value: String(activeTabIndex)
18399
+ }
18400
+ )
18295
18401
  }
18296
18402
  ) : null
18297
18403
  ] });
@@ -18664,7 +18770,8 @@ function buildConditionalIcon(iconSet, iconId) {
18664
18770
  };
18665
18771
  }
18666
18772
  }
18667
- function renderConditionalIcon(icon) {
18773
+ function renderConditionalIcon(icon, scale = 1) {
18774
+ const iconSize = 14 * scale;
18668
18775
  if (icon.shape === "arrow") {
18669
18776
  const fill = icon.color ?? "#111827";
18670
18777
  const stroke = icon.borderColor ?? darkenColor3(fill, 0.32);
@@ -18672,10 +18779,10 @@ function renderConditionalIcon(icon) {
18672
18779
  "svg",
18673
18780
  {
18674
18781
  "aria-hidden": "true",
18675
- height: 14,
18782
+ height: iconSize,
18676
18783
  style: { display: "block" },
18677
18784
  viewBox: "0 0 16 16",
18678
- width: 14,
18785
+ width: iconSize,
18679
18786
  children: /* @__PURE__ */ jsx3("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx3(
18680
18787
  "path",
18681
18788
  {
@@ -18697,12 +18804,12 @@ function renderConditionalIcon(icon) {
18697
18804
  alignItems: "center",
18698
18805
  color: icon.color ?? "#111827",
18699
18806
  display: "inline-flex",
18700
- fontSize: 13,
18807
+ fontSize: 13 * scale,
18701
18808
  fontWeight: 700,
18702
- height: 14,
18809
+ height: iconSize,
18703
18810
  justifyContent: "center",
18704
18811
  lineHeight: 1,
18705
- width: 14
18812
+ width: iconSize
18706
18813
  },
18707
18814
  children: icon.glyph
18708
18815
  }
@@ -18716,17 +18823,17 @@ function renderConditionalIcon(icon) {
18716
18823
  border: icon.borderColor ? `1px solid ${icon.borderColor}` : "none",
18717
18824
  borderRadius: "999px",
18718
18825
  display: "inline-block",
18719
- height: 12,
18720
- width: 12
18826
+ height: 12 * scale,
18827
+ width: 12 * scale
18721
18828
  }
18722
18829
  }
18723
18830
  );
18724
18831
  }
18725
- function renderCheckboxControl(checked, palette) {
18832
+ function renderCheckboxControl(checked, palette, scale = 1) {
18726
18833
  const stroke = paletteIsDark(palette) ? "#cbd5e1" : "#475569";
18727
18834
  const fill = checked ? paletteIsDark(palette) ? "#60a5fa" : "#2563eb" : "transparent";
18728
18835
  const check = paletteIsDark(palette) ? "#020617" : "#ffffff";
18729
- return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height: 14, style: { display: "block" }, viewBox: "0 0 16 16", width: 14, children: [
18836
+ return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height: 14 * scale, style: { display: "block" }, viewBox: "0 0 16 16", width: 14 * scale, children: [
18730
18837
  /* @__PURE__ */ jsx3("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
18731
18838
  checked ? /* @__PURE__ */ jsx3(
18732
18839
  "path",
@@ -18924,10 +19031,12 @@ function GridRow({
18924
19031
  readOnly,
18925
19032
  renderCellAdornment,
18926
19033
  rowHeight,
19034
+ rowHeaderWidth,
18927
19035
  stickyLeftByCol,
18928
19036
  stickyTop,
18929
19037
  trailingSpacerWidth,
18930
- visibleCols
19038
+ visibleCols,
19039
+ zoomFactor
18931
19040
  }) {
18932
19041
  const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
18933
19042
  return /* @__PURE__ */ jsxs3("tr", { "data-xlsx-row": actualRow, style: { height: rowHeight }, children: [
@@ -18943,17 +19052,17 @@ function GridRow({
18943
19052
  boxSizing: "border-box",
18944
19053
  boxShadow: gutterSeparatorShadow,
18945
19054
  color: palette.mutedText,
18946
- fontSize: "11px",
19055
+ fontSize: scaleCssLengthExpression("11px", zoomFactor),
18947
19056
  height: rowHeight,
18948
19057
  left: 0,
18949
19058
  maxHeight: rowHeight,
18950
- minWidth: ROW_HEADER_WIDTH,
18951
- padding: "2px 4px",
19059
+ minWidth: rowHeaderWidth,
19060
+ padding: scaleCssLengthExpression("2px 4px", zoomFactor),
18952
19061
  position: "sticky",
18953
19062
  top: stickyTop,
18954
19063
  textAlign: "center",
18955
19064
  userSelect: "none",
18956
- width: ROW_HEADER_WIDTH,
19065
+ width: rowHeaderWidth,
18957
19066
  zIndex: stickyTop !== void 0 ? 45 : 35
18958
19067
  },
18959
19068
  children: /* @__PURE__ */ jsxs3("div", { style: { position: "relative" }, children: [
@@ -18964,9 +19073,9 @@ function GridRow({
18964
19073
  onPointerDown: (event) => onRowResizePointerDown(event, actualRow, rowHeight),
18965
19074
  style: {
18966
19075
  backgroundColor: "transparent",
18967
- bottom: -8,
19076
+ bottom: -8 * zoomFactor,
18968
19077
  cursor: "row-resize",
18969
- height: 16,
19078
+ height: 16 * zoomFactor,
18970
19079
  left: 0,
18971
19080
  position: "absolute",
18972
19081
  width: "100%",
@@ -19067,7 +19176,7 @@ function GridRow({
19067
19176
  cellContentStyle.zIndex = 1;
19068
19177
  }
19069
19178
  if (trailingInset > 0) {
19070
- cellContentStyle.paddingRight = trailingInset + 4;
19179
+ cellContentStyle.paddingRight = (trailingInset + 4) * zoomFactor;
19071
19180
  }
19072
19181
  if (cellData.conditionalIcon) {
19073
19182
  cellContentStyle.position = "relative";
@@ -19101,13 +19210,13 @@ function GridRow({
19101
19210
  "aria-hidden": "true",
19102
19211
  style: {
19103
19212
  alignItems: "center",
19104
- bottom: 4,
19213
+ bottom: 4 * zoomFactor,
19105
19214
  display: "flex",
19106
- left: 4,
19215
+ left: 4 * zoomFactor,
19107
19216
  pointerEvents: "none",
19108
19217
  position: "absolute",
19109
- right: 4,
19110
- top: 4,
19218
+ right: 4 * zoomFactor,
19219
+ top: 4 * zoomFactor,
19111
19220
  zIndex: 0
19112
19221
  },
19113
19222
  children: /* @__PURE__ */ jsx3(
@@ -19136,12 +19245,12 @@ function GridRow({
19136
19245
  justifyContent: "center",
19137
19246
  pointerEvents: "none",
19138
19247
  position: "absolute",
19139
- right: conditionalIconRight,
19248
+ right: conditionalIconRight * zoomFactor,
19140
19249
  top: "50%",
19141
19250
  transform: "translateY(-50%)",
19142
19251
  zIndex: 2
19143
19252
  },
19144
- children: renderConditionalIcon(cellData.conditionalIcon)
19253
+ children: renderConditionalIcon(cellData.conditionalIcon, zoomFactor)
19145
19254
  }
19146
19255
  ) : null,
19147
19256
  isEditing ? /* @__PURE__ */ jsx3(
@@ -19170,7 +19279,7 @@ function GridRow({
19170
19279
  height: "100%",
19171
19280
  margin: 0,
19172
19281
  outline: "none",
19173
- padding: DEFAULT_CELL_PADDING,
19282
+ padding: scaleCssLengthExpression(DEFAULT_CELL_PADDING, zoomFactor),
19174
19283
  width: "100%"
19175
19284
  },
19176
19285
  value: editingValue
@@ -19212,7 +19321,7 @@ function GridRow({
19212
19321
  pointerEvents: "none",
19213
19322
  width: "100%"
19214
19323
  },
19215
- children: renderCheckboxControl(cellData.checkboxState, palette)
19324
+ children: renderCheckboxControl(cellData.checkboxState, palette, zoomFactor)
19216
19325
  }
19217
19326
  ) : /* @__PURE__ */ jsx3("div", { style: cellContentStyle, children: cellData.value })
19218
19327
  ]
@@ -19235,7 +19344,7 @@ function GridRow({
19235
19344
  ] });
19236
19345
  }
19237
19346
  var MemoGridRow = React4.memo(GridRow, (prev, next) => {
19238
- if (prev.actualRow !== next.actualRow || prev.rowHeight !== next.rowHeight || prev.palette !== next.palette || prev.readOnly !== next.readOnly || prev.visibleCols !== next.visibleCols || prev.leadingSpacerWidth !== next.leadingSpacerWidth || prev.stickyLeftByCol !== next.stickyLeftByCol || prev.stickyTop !== next.stickyTop || prev.trailingSpacerWidth !== next.trailingSpacerWidth || prev.getCellData !== next.getCellData || prev.onCellClick !== next.onCellClick || prev.onCellDoubleClick !== next.onCellDoubleClick || prev.onCellPointerDown !== next.onCellPointerDown || prev.onEditingCancel !== next.onEditingCancel || prev.onEditingCommit !== next.onEditingCommit || prev.onEditingValueChange !== next.onEditingValueChange || prev.onRowHeaderRef !== next.onRowHeaderRef || prev.onRowPointerDown !== next.onRowPointerDown || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment) {
19347
+ if (prev.actualRow !== next.actualRow || prev.rowHeight !== next.rowHeight || 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.onEditingCancel !== next.onEditingCancel || prev.onEditingCommit !== next.onEditingCommit || prev.onEditingValueChange !== next.onEditingValueChange || prev.onRowHeaderRef !== next.onRowHeaderRef || prev.onRowPointerDown !== next.onRowPointerDown || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment) {
19239
19348
  return false;
19240
19349
  }
19241
19350
  const prevEditingCol = prev.editingCell?.row === prev.actualRow ? prev.editingCell.col : -1;
@@ -19412,20 +19521,25 @@ function XlsxGrid({
19412
19521
  );
19413
19522
  const hiddenRowSet = React4.useMemo(() => new Set(activeSheet?.hiddenRows ?? []), [activeSheet?.hiddenRows]);
19414
19523
  const hiddenColSet = React4.useMemo(() => new Set(activeSheet?.hiddenCols ?? []), [activeSheet?.hiddenCols]);
19524
+ const displayDefaultRowHeight = DEFAULT_ROW_HEIGHT2 * zoomFactor;
19525
+ const displayDefaultColWidth = DEFAULT_COL_WIDTH2 * zoomFactor;
19526
+ const displayHeaderHeight = HEADER_HEIGHT * zoomFactor;
19527
+ const displayRowHeaderWidth = ROW_HEADER_WIDTH * zoomFactor;
19528
+ const displayImageMinSize = IMAGE_MIN_SIZE_PX * zoomFactor;
19415
19529
  const syncDrawingViewport = React4.useCallback((scroller) => {
19416
19530
  if (!scroller) {
19417
19531
  return;
19418
19532
  }
19419
19533
  setDrawingViewport((current) => {
19420
19534
  const next = {
19421
- height: scroller.clientHeight / zoomFactor,
19422
- left: scroller.scrollLeft / zoomFactor,
19423
- top: scroller.scrollTop / zoomFactor,
19424
- width: scroller.clientWidth / zoomFactor
19535
+ height: scroller.clientHeight,
19536
+ left: scroller.scrollLeft,
19537
+ top: scroller.scrollTop,
19538
+ width: scroller.clientWidth
19425
19539
  };
19426
19540
  return current.left === next.left && current.top === next.top && current.width === next.width && current.height === next.height ? current : next;
19427
19541
  });
19428
- }, [zoomFactor]);
19542
+ }, []);
19429
19543
  const visibleRows = React4.useMemo(() => {
19430
19544
  return buildVisibleAxisIndices(
19431
19545
  activeSheet?.visibleRows ?? [],
@@ -19579,47 +19693,54 @@ function XlsxGrid({
19579
19693
  revision
19580
19694
  ]
19581
19695
  );
19582
- const effectiveColWidths = React4.useMemo(
19583
- () => visibleCols.map((col) => actualColWidths[col] ?? DEFAULT_COL_WIDTH2),
19584
- [actualColWidths, visibleCols]
19696
+ const displayActualColWidths = React4.useMemo(
19697
+ () => actualColWidths.map((width) => width * zoomFactor),
19698
+ [actualColWidths, zoomFactor]
19699
+ );
19700
+ const displayActualRowHeights = React4.useMemo(
19701
+ () => actualRowHeights.map((height) => height * zoomFactor),
19702
+ [actualRowHeights, zoomFactor]
19703
+ );
19704
+ const displayEffectiveColWidths = React4.useMemo(
19705
+ () => visibleCols.map((col) => displayActualColWidths[col] ?? displayDefaultColWidth),
19706
+ [displayActualColWidths, displayDefaultColWidth, visibleCols]
19585
19707
  );
19586
- const effectiveRowHeights = React4.useMemo(
19587
- () => visibleRows.map((row) => actualRowHeights[row] ?? DEFAULT_ROW_HEIGHT2),
19588
- [actualRowHeights, visibleRows]
19708
+ const displayEffectiveRowHeights = React4.useMemo(
19709
+ () => visibleRows.map((row) => displayActualRowHeights[row] ?? displayDefaultRowHeight),
19710
+ [displayActualRowHeights, displayDefaultRowHeight, visibleRows]
19589
19711
  );
19590
19712
  const rowIndexByActual = React4.useMemo(() => new Map(visibleRows.map((row, index) => [row, index])), [visibleRows]);
19591
19713
  const colIndexByActual = React4.useMemo(() => new Map(visibleCols.map((col, index) => [col, index])), [visibleCols]);
19592
19714
  const visibleRowsRef = React4.useRef(visibleRows);
19593
19715
  const visibleColsRef = React4.useRef(visibleCols);
19594
- const effectiveRowHeightsRef = React4.useRef(effectiveRowHeights);
19595
- const effectiveColWidthsRef = React4.useRef(effectiveColWidths);
19596
- const rowPrefixSums = React4.useMemo(() => buildPrefixSums(effectiveRowHeights), [effectiveRowHeights]);
19597
- const colPrefixSums = React4.useMemo(() => buildPrefixSums(effectiveColWidths), [effectiveColWidths]);
19598
- const actualRowPrefixSums = React4.useMemo(() => buildPrefixSums(actualRowHeights), [actualRowHeights]);
19599
- const actualColPrefixSums = React4.useMemo(() => buildPrefixSums(actualColWidths), [actualColWidths]);
19716
+ const effectiveRowHeightsRef = React4.useRef(displayEffectiveRowHeights);
19717
+ const effectiveColWidthsRef = React4.useRef(displayEffectiveColWidths);
19718
+ const rowPrefixSums = React4.useMemo(() => buildPrefixSums(displayEffectiveRowHeights), [displayEffectiveRowHeights]);
19719
+ const colPrefixSums = React4.useMemo(() => buildPrefixSums(displayEffectiveColWidths), [displayEffectiveColWidths]);
19720
+ const actualRowPrefixSums = React4.useMemo(() => buildPrefixSums(displayActualRowHeights), [displayActualRowHeights]);
19721
+ const actualColPrefixSums = React4.useMemo(() => buildPrefixSums(displayActualColWidths), [displayActualColWidths]);
19600
19722
  const stickyTopByRow = React4.useMemo(
19601
- () => buildStickyOffsets(frozenRows, actualRowHeights, HEADER_HEIGHT),
19602
- [actualRowHeights, frozenRows]
19723
+ () => buildStickyOffsets(frozenRows, displayActualRowHeights, displayHeaderHeight),
19724
+ [displayActualRowHeights, displayHeaderHeight, frozenRows]
19603
19725
  );
19604
19726
  const stickyLeftByCol = React4.useMemo(
19605
- () => buildStickyOffsets(frozenCols, actualColWidths, ROW_HEADER_WIDTH),
19606
- [actualColWidths, frozenCols]
19727
+ () => buildStickyOffsets(frozenCols, displayActualColWidths, displayRowHeaderWidth),
19728
+ [displayActualColWidths, displayRowHeaderWidth, frozenCols]
19607
19729
  );
19608
19730
  const frozenPaneBottom = React4.useMemo(
19609
19731
  () => frozenRows.length > 0 ? frozenRows.reduce(
19610
- (max, row) => Math.max(max, (stickyTopByRow.get(row) ?? HEADER_HEIGHT) + (actualRowHeights[row] ?? DEFAULT_ROW_HEIGHT2)),
19611
- HEADER_HEIGHT
19612
- ) : HEADER_HEIGHT,
19613
- [actualRowHeights, frozenRows, stickyTopByRow]
19732
+ (max, row) => Math.max(max, (stickyTopByRow.get(row) ?? displayHeaderHeight) + (displayActualRowHeights[row] ?? displayDefaultRowHeight)),
19733
+ displayHeaderHeight
19734
+ ) : displayHeaderHeight,
19735
+ [displayActualRowHeights, displayDefaultRowHeight, displayHeaderHeight, frozenRows, stickyTopByRow]
19614
19736
  );
19615
19737
  const frozenPaneRight = React4.useMemo(
19616
19738
  () => frozenCols.length > 0 ? frozenCols.reduce(
19617
- (max, col) => Math.max(max, (stickyLeftByCol.get(col) ?? ROW_HEADER_WIDTH) + (actualColWidths[col] ?? DEFAULT_COL_WIDTH2)),
19618
- ROW_HEADER_WIDTH
19619
- ) : ROW_HEADER_WIDTH,
19620
- [actualColWidths, frozenCols, stickyLeftByCol]
19739
+ (max, col) => Math.max(max, (stickyLeftByCol.get(col) ?? displayRowHeaderWidth) + (displayActualColWidths[col] ?? displayDefaultColWidth)),
19740
+ displayRowHeaderWidth
19741
+ ) : displayRowHeaderWidth,
19742
+ [displayActualColWidths, displayDefaultColWidth, displayRowHeaderWidth, frozenCols, stickyLeftByCol]
19621
19743
  );
19622
- const useNativeZoomForStickyLayout = zoomFactor !== 1;
19623
19744
  const rowPrefixSumsRef = React4.useRef(rowPrefixSums);
19624
19745
  const colPrefixSumsRef = React4.useRef(colPrefixSums);
19625
19746
  const firstVisibleRow = visibleRows[0];
@@ -19627,6 +19748,12 @@ function XlsxGrid({
19627
19748
  const firstVisibleCol = visibleCols[0];
19628
19749
  const lastVisibleCol = visibleCols[visibleCols.length - 1];
19629
19750
  const displayedSelection = fillPreviewRange ?? normalizedSelection;
19751
+ const toLogicalRect = React4.useCallback((rect) => ({
19752
+ height: rect.height / zoomFactor,
19753
+ left: rect.left / zoomFactor,
19754
+ top: rect.top / zoomFactor,
19755
+ width: rect.width / zoomFactor
19756
+ }), [zoomFactor]);
19630
19757
  const drawingExtents = React4.useMemo(() => {
19631
19758
  const imageExtents = images.reduce(
19632
19759
  (current, image) => {
@@ -19668,24 +19795,18 @@ function XlsxGrid({
19668
19795
  const shouldVirtualizeCols = !activeSheet?.hasHorizontalMerges && frozenCols.length === 0;
19669
19796
  const rowVirtualizer = useVirtualizer({
19670
19797
  count: visibleRows.length,
19671
- estimateSize: (index) => effectiveRowHeights[index] ?? DEFAULT_ROW_HEIGHT2,
19798
+ estimateSize: (index) => displayEffectiveRowHeights[index] ?? displayDefaultRowHeight,
19672
19799
  getScrollElement: () => scrollRef.current,
19673
19800
  getItemKey: (index) => visibleRows[index] ?? index,
19674
- observeElementOffset: (instance, cb) => observeZoomedElementOffset(instance, zoomFactor, cb),
19675
- observeElementRect: (instance, cb) => observeZoomedElementRect(instance, zoomFactor, cb),
19676
- overscan: 10,
19677
- scrollToFn: (offset, options, instance) => scrollToZoomedOffset(offset, zoomFactor, options, instance)
19801
+ overscan: 10
19678
19802
  });
19679
19803
  const colVirtualizer = useVirtualizer({
19680
19804
  count: visibleCols.length,
19681
- estimateSize: (index) => effectiveColWidths[index] ?? DEFAULT_COL_WIDTH2,
19805
+ estimateSize: (index) => displayEffectiveColWidths[index] ?? displayDefaultColWidth,
19682
19806
  getScrollElement: () => scrollRef.current,
19683
19807
  getItemKey: (index) => visibleCols[index] ?? index,
19684
19808
  horizontal: true,
19685
- observeElementOffset: (instance, cb) => observeZoomedElementOffset(instance, zoomFactor, cb),
19686
- observeElementRect: (instance, cb) => observeZoomedElementRect(instance, zoomFactor, cb),
19687
- overscan: 6,
19688
- scrollToFn: (offset, options, instance) => scrollToZoomedOffset(offset, zoomFactor, options, instance)
19809
+ overscan: 6
19689
19810
  });
19690
19811
  const currentRowVirtualItems = rowVirtualizer.getVirtualItems();
19691
19812
  const currentColVirtualItems = colVirtualizer.getVirtualItems();
@@ -19821,11 +19942,11 @@ function XlsxGrid({
19821
19942
  React4.useEffect(() => {
19822
19943
  visibleRowsRef.current = visibleRows;
19823
19944
  visibleColsRef.current = visibleCols;
19824
- effectiveRowHeightsRef.current = effectiveRowHeights;
19825
- effectiveColWidthsRef.current = effectiveColWidths;
19945
+ effectiveRowHeightsRef.current = displayEffectiveRowHeights;
19946
+ effectiveColWidthsRef.current = displayEffectiveColWidths;
19826
19947
  rowPrefixSumsRef.current = rowPrefixSums;
19827
19948
  colPrefixSumsRef.current = colPrefixSums;
19828
- }, [colPrefixSums, effectiveColWidths, effectiveRowHeights, rowPrefixSums, visibleCols, visibleRows]);
19949
+ }, [colPrefixSums, displayEffectiveColWidths, displayEffectiveRowHeights, rowPrefixSums, visibleCols, visibleRows]);
19829
19950
  React4.useLayoutEffect(() => {
19830
19951
  const scroller = scrollRef.current;
19831
19952
  const previousZoomFactor = previousZoomFactorRef.current;
@@ -19950,13 +20071,13 @@ function XlsxGrid({
19950
20071
  const currentScroller = event.currentTarget;
19951
20072
  cachedScrollerRectRef.current = null;
19952
20073
  syncDrawingViewport(currentScroller);
19953
- if ((currentScroller.scrollHeight - (currentScroller.scrollTop + currentScroller.clientHeight)) / zoomFactor < OPEN_GRID_VERTICAL_EDGE_PX) {
20074
+ if (currentScroller.scrollHeight - (currentScroller.scrollTop + currentScroller.clientHeight) < OPEN_GRID_VERTICAL_EDGE_PX) {
19954
20075
  setDisplayRowLimit((current) => current + OPEN_GRID_ROW_GROWTH);
19955
20076
  }
19956
- if ((currentScroller.scrollWidth - (currentScroller.scrollLeft + currentScroller.clientWidth)) / zoomFactor < OPEN_GRID_HORIZONTAL_EDGE_PX) {
20077
+ if (currentScroller.scrollWidth - (currentScroller.scrollLeft + currentScroller.clientWidth) < OPEN_GRID_HORIZONTAL_EDGE_PX) {
19957
20078
  setDisplayColLimit((current) => current + OPEN_GRID_COL_GROWTH);
19958
20079
  }
19959
- }, [syncDrawingViewport, zoomFactor]);
20080
+ }, [syncDrawingViewport]);
19960
20081
  React4.useEffect(() => {
19961
20082
  if (!openTableMenu) {
19962
20083
  return;
@@ -19995,24 +20116,24 @@ function XlsxGrid({
19995
20116
  }
19996
20117
  const pointerOffsetX = clientX - scrollerRect.left;
19997
20118
  const pointerOffsetY = clientY - scrollerRect.top;
19998
- const localX = pointerOffsetX / zoomFactor + (pointerOffsetX >= frozenPaneRight * zoomFactor ? scroller.scrollLeft / zoomFactor : 0);
19999
- const localY = pointerOffsetY / zoomFactor + (pointerOffsetY >= frozenPaneBottom * zoomFactor ? scroller.scrollTop / zoomFactor : 0);
20000
- const rowContentOffset = localY - HEADER_HEIGHT;
20001
- const colContentOffset = localX - ROW_HEADER_WIDTH;
20119
+ const localX = pointerOffsetX + (pointerOffsetX >= frozenPaneRight ? scroller.scrollLeft : 0);
20120
+ const localY = pointerOffsetY + (pointerOffsetY >= frozenPaneBottom ? scroller.scrollTop : 0);
20121
+ const rowContentOffset = localY - displayHeaderHeight;
20122
+ const colContentOffset = localX - displayRowHeaderWidth;
20002
20123
  let geometryCell = null;
20003
- if (localY >= HEADER_HEIGHT && localX < ROW_HEADER_WIDTH) {
20124
+ if (localY >= displayHeaderHeight && localX < displayRowHeaderWidth) {
20004
20125
  const rowIndex = findIndexForOffsetPrefix(rowPrefixSumsCurrent, rowContentOffset);
20005
20126
  const actualRow = visibleRowsCurrent[rowIndex];
20006
20127
  if (actualRow !== void 0 && firstVisibleColRef.current !== void 0) {
20007
20128
  geometryCell = { row: actualRow, col: firstVisibleColRef.current };
20008
20129
  }
20009
- } else if (localY < HEADER_HEIGHT && localX >= ROW_HEADER_WIDTH) {
20130
+ } else if (localY < displayHeaderHeight && localX >= displayRowHeaderWidth) {
20010
20131
  const colIndex = findIndexForOffsetPrefix(colPrefixSumsCurrent, colContentOffset);
20011
20132
  const actualCol = visibleColsCurrent[colIndex];
20012
20133
  if (actualCol !== void 0 && firstVisibleRowRef.current !== void 0) {
20013
20134
  geometryCell = { row: firstVisibleRowRef.current, col: actualCol };
20014
20135
  }
20015
- } else if (localY >= HEADER_HEIGHT && localX >= ROW_HEADER_WIDTH) {
20136
+ } else if (localY >= displayHeaderHeight && localX >= displayRowHeaderWidth) {
20016
20137
  const rowIndex = findIndexForOffsetPrefix(rowPrefixSumsCurrent, rowContentOffset);
20017
20138
  const colIndex = findIndexForOffsetPrefix(colPrefixSumsCurrent, colContentOffset);
20018
20139
  const actualRow = visibleRowsCurrent[rowIndex];
@@ -20022,7 +20143,7 @@ function XlsxGrid({
20022
20143
  }
20023
20144
  }
20024
20145
  return geometryCell;
20025
- }, [frozenPaneBottom, frozenPaneRight, zoomFactor]);
20146
+ }, [displayHeaderHeight, displayRowHeaderWidth, frozenPaneBottom, frozenPaneRight]);
20026
20147
  const resolvePointerCellFromHitTest = React4.useCallback((clientX, clientY) => {
20027
20148
  const elementsAtPoint = typeof document.elementsFromPoint === "function" ? document.elementsFromPoint(clientX, clientY) : [document.elementFromPoint(clientX, clientY)].filter((element) => Boolean(element));
20028
20149
  for (const element of elementsAtPoint) {
@@ -20082,59 +20203,59 @@ function XlsxGrid({
20082
20203
  if (rowIndex === void 0 || colIndex === void 0) {
20083
20204
  return null;
20084
20205
  }
20085
- const logicalWidth = effectiveColWidths[colIndex] ?? DEFAULT_COL_WIDTH2;
20086
- const logicalHeight = effectiveRowHeights[rowIndex] ?? DEFAULT_ROW_HEIGHT2;
20087
- const contentScaleX = Math.max(1e-4, rect.width > 0 ? rect.width / logicalWidth : zoomFactor);
20088
- const contentScaleY = Math.max(1e-4, rect.height > 0 ? rect.height / logicalHeight : zoomFactor);
20206
+ const displayWidth = displayEffectiveColWidths[colIndex] ?? displayDefaultColWidth;
20207
+ const displayHeight = displayEffectiveRowHeights[rowIndex] ?? displayDefaultRowHeight;
20208
+ const contentScaleX = Math.max(1e-4, rect.width > 0 ? rect.width / displayWidth : 1);
20209
+ const contentScaleY = Math.max(1e-4, rect.height > 0 ? rect.height / displayHeight : 1);
20089
20210
  return {
20090
20211
  contentScaleX,
20091
20212
  contentScaleY,
20092
- originContentX: (colPrefixSums[colIndex] ?? 0) + clampContentOffset((clientX - rect.left) / contentScaleX, logicalWidth),
20093
- originContentY: (rowPrefixSums[rowIndex] ?? 0) + clampContentOffset((clientY - rect.top) / contentScaleY, logicalHeight)
20213
+ originContentX: (colPrefixSums[colIndex] ?? 0) + clampContentOffset((clientX - rect.left) / contentScaleX, displayWidth),
20214
+ originContentY: (rowPrefixSums[rowIndex] ?? 0) + clampContentOffset((clientY - rect.top) / contentScaleY, displayHeight)
20094
20215
  };
20095
- }, [colIndexByActual, colPrefixSums, effectiveColWidths, effectiveRowHeights, rowIndexByActual, rowPrefixSums, zoomFactor]);
20216
+ }, [colIndexByActual, colPrefixSums, displayDefaultColWidth, displayDefaultRowHeight, displayEffectiveColWidths, displayEffectiveRowHeights, rowIndexByActual, rowPrefixSums]);
20096
20217
  const resolveRowPointerOrigin = React4.useCallback((actualRow, rect, clientY) => {
20097
20218
  const rowIndex = rowIndexByActual.get(actualRow);
20098
20219
  if (rowIndex === void 0) {
20099
20220
  return null;
20100
20221
  }
20101
- const logicalHeight = effectiveRowHeights[rowIndex] ?? DEFAULT_ROW_HEIGHT2;
20102
- const contentScaleY = Math.max(1e-4, rect.height > 0 ? rect.height / logicalHeight : zoomFactor);
20222
+ const displayHeight = displayEffectiveRowHeights[rowIndex] ?? displayDefaultRowHeight;
20223
+ const contentScaleY = Math.max(1e-4, rect.height > 0 ? rect.height / displayHeight : 1);
20103
20224
  return {
20104
- contentScaleX: Math.max(1e-4, zoomFactor),
20225
+ contentScaleX: 1,
20105
20226
  contentScaleY,
20106
20227
  originContentX: colPrefixSums[0] ?? 0,
20107
- originContentY: (rowPrefixSums[rowIndex] ?? 0) + clampContentOffset((clientY - rect.top) / contentScaleY, logicalHeight)
20228
+ originContentY: (rowPrefixSums[rowIndex] ?? 0) + clampContentOffset((clientY - rect.top) / contentScaleY, displayHeight)
20108
20229
  };
20109
- }, [colPrefixSums, effectiveRowHeights, rowIndexByActual, rowPrefixSums, zoomFactor]);
20230
+ }, [colPrefixSums, displayDefaultRowHeight, displayEffectiveRowHeights, rowIndexByActual, rowPrefixSums]);
20110
20231
  const resolveColumnPointerOrigin = React4.useCallback((actualCol, rect, clientX) => {
20111
20232
  const colIndex = colIndexByActual.get(actualCol);
20112
20233
  if (colIndex === void 0) {
20113
20234
  return null;
20114
20235
  }
20115
- const logicalWidth = effectiveColWidths[colIndex] ?? DEFAULT_COL_WIDTH2;
20116
- const contentScaleX = Math.max(1e-4, rect.width > 0 ? rect.width / logicalWidth : zoomFactor);
20236
+ const displayWidth = displayEffectiveColWidths[colIndex] ?? displayDefaultColWidth;
20237
+ const contentScaleX = Math.max(1e-4, rect.width > 0 ? rect.width / displayWidth : 1);
20117
20238
  return {
20118
20239
  contentScaleX,
20119
- contentScaleY: Math.max(1e-4, zoomFactor),
20120
- originContentX: (colPrefixSums[colIndex] ?? 0) + clampContentOffset((clientX - rect.left) / contentScaleX, logicalWidth),
20240
+ contentScaleY: 1,
20241
+ originContentX: (colPrefixSums[colIndex] ?? 0) + clampContentOffset((clientX - rect.left) / contentScaleX, displayWidth),
20121
20242
  originContentY: rowPrefixSums[0] ?? 0
20122
20243
  };
20123
- }, [colIndexByActual, colPrefixSums, effectiveColWidths, rowPrefixSums, zoomFactor]);
20244
+ }, [colIndexByActual, colPrefixSums, displayDefaultColWidth, displayEffectiveColWidths, rowPrefixSums]);
20124
20245
  const applyColumnPreview = React4.useCallback((actualCol, widthPx) => {
20125
20246
  const colElement = colElementRefs.current.get(actualCol);
20126
20247
  if (colElement) {
20127
20248
  colElement.style.width = widthPx === null ? "" : `${widthPx}px`;
20128
20249
  }
20129
20250
  const baseIndex = visibleCols.indexOf(actualCol);
20130
- const baseWidth = baseIndex >= 0 ? effectiveColWidths[baseIndex] ?? DEFAULT_COL_WIDTH2 : DEFAULT_COL_WIDTH2;
20251
+ const baseWidth = baseIndex >= 0 ? displayEffectiveColWidths[baseIndex] ?? displayDefaultColWidth : displayDefaultColWidth;
20131
20252
  const previewWidth = widthPx ?? baseWidth;
20132
- const baseTotalWidth = effectiveColWidths.reduce((sum, width) => sum + width, 0) + ROW_HEADER_WIDTH;
20253
+ const baseTotalWidth = displayEffectiveColWidths.reduce((sum, width) => sum + width, 0) + displayRowHeaderWidth;
20133
20254
  const widthDelta = previewWidth - baseWidth;
20134
20255
  if (tableRef.current) {
20135
20256
  tableRef.current.style.width = `${baseTotalWidth + widthDelta}px`;
20136
20257
  }
20137
- }, [effectiveColWidths, visibleCols]);
20258
+ }, [displayDefaultColWidth, displayEffectiveColWidths, displayRowHeaderWidth, visibleCols]);
20138
20259
  const applyRowPreview = React4.useCallback((actualRow, heightPx) => {
20139
20260
  const rowElement = rowElementRefs.current.get(actualRow) ?? wrapperRef.current?.querySelector(`tr[data-xlsx-row="${actualRow}"]`) ?? null;
20140
20261
  if (rowElement) {
@@ -20311,7 +20432,7 @@ function XlsxGrid({
20311
20432
  const viewportRowBatch = getRowsBatchAsync ? asyncViewportRowBatch : syncViewportRowBatch;
20312
20433
  React4.useEffect(() => {
20313
20434
  cellRenderCacheRef.current.clear();
20314
- }, [activeSheetIndex, displayColLimit, displayRowLimit, palette, revision, viewportRowBatch, worksheet]);
20435
+ }, [activeSheetIndex, displayColLimit, displayRowLimit, palette, revision, viewportRowBatch, worksheet, zoomFactor]);
20315
20436
  React4.useEffect(() => {
20316
20437
  setAsyncViewportRowBatch(null);
20317
20438
  }, [activeSheetIndex, revision]);
@@ -20333,7 +20454,7 @@ function XlsxGrid({
20333
20454
  if (!worksheet && !batchedCell) {
20334
20455
  const emptyData = {
20335
20456
  isMergedSecondary: false,
20336
- style: {
20457
+ style: scaleCssProperties({
20337
20458
  backgroundColor: resolveSheetSurface(activeSheet, palette),
20338
20459
  borderBottom: "none",
20339
20460
  borderRight: "none",
@@ -20341,7 +20462,7 @@ function XlsxGrid({
20341
20462
  padding: DEFAULT_CELL_PADDING,
20342
20463
  verticalAlign: "bottom",
20343
20464
  whiteSpace: "nowrap"
20344
- },
20465
+ }, zoomFactor),
20345
20466
  value: ""
20346
20467
  };
20347
20468
  cellRenderCacheRef.current.set(cacheKey, emptyData);
@@ -20420,9 +20541,9 @@ function XlsxGrid({
20420
20541
  isTableHeader: Boolean(table && row >= table.start.row && row < table.start.row + headerRowCount),
20421
20542
  rowSpan: merge?.rowSpan,
20422
20543
  sparkline: sparkline && sparklineValues ? { config: sparkline, values: sparklineValues } : null,
20423
- style: buildCellStyle(mergedStyle, palette, activeSheet?.themePalette, {
20544
+ style: scaleCssProperties(buildCellStyle(mergedStyle, palette, activeSheet?.themePalette, {
20424
20545
  showGridLines: activeSheet?.showGridLines
20425
- }),
20546
+ }), zoomFactor),
20426
20547
  validation: resolveCellDataValidation(row, col, activeSheet),
20427
20548
  value: sparkline ? "" : checkboxState !== null ? "" : batchCoversRow || !worksheet ? batchedCell?.value ?? "" : getCellDisplayValue(worksheet, row, col, activeSheet)
20428
20549
  };
@@ -20432,7 +20553,7 @@ function XlsxGrid({
20432
20553
  const horizontalPadding = getHorizontalPadding(nextData.style.padding);
20433
20554
  const textWidth = measureTextWidth(nextData.value, nextData.style);
20434
20555
  const requiredWidth = textWidth + horizontalPadding + 2;
20435
- let availableWidth = effectiveColWidths[startColIndex] ?? DEFAULT_COL_WIDTH2;
20556
+ let availableWidth = displayEffectiveColWidths[startColIndex] ?? displayDefaultColWidth;
20436
20557
  if (requiredWidth > availableWidth) {
20437
20558
  for (let nextColIndex = startColIndex + 1; nextColIndex < visibleCols.length; nextColIndex += 1) {
20438
20559
  const nextActualCol = visibleCols[nextColIndex];
@@ -20443,12 +20564,12 @@ function XlsxGrid({
20443
20564
  if (!canReceiveOverflowText(neighborData)) {
20444
20565
  break;
20445
20566
  }
20446
- availableWidth += effectiveColWidths[nextColIndex] ?? DEFAULT_COL_WIDTH2;
20567
+ availableWidth += displayEffectiveColWidths[nextColIndex] ?? displayDefaultColWidth;
20447
20568
  if (requiredWidth <= availableWidth) {
20448
20569
  break;
20449
20570
  }
20450
20571
  }
20451
- if (availableWidth > (effectiveColWidths[startColIndex] ?? DEFAULT_COL_WIDTH2)) {
20572
+ if (availableWidth > (displayEffectiveColWidths[startColIndex] ?? displayDefaultColWidth)) {
20452
20573
  nextData.spillWidth = Math.max(0, availableWidth - horizontalPadding);
20453
20574
  }
20454
20575
  }
@@ -20456,7 +20577,7 @@ function XlsxGrid({
20456
20577
  }
20457
20578
  cellRenderCacheRef.current.set(cacheKey, nextData);
20458
20579
  return nextData;
20459
- }, [activeSheet, colIndexByActual, effectiveColWidths, effectiveTables, palette, sparklinesByCell, viewportRowBatch, visibleCols, worksheet]);
20580
+ }, [activeSheet, colIndexByActual, displayDefaultColWidth, displayEffectiveColWidths, effectiveTables, palette, sparklinesByCell, viewportRowBatch, visibleCols, worksheet, zoomFactor]);
20460
20581
  React4.useEffect(() => {
20461
20582
  conditionalFormatMetricsCacheRef.current.clear();
20462
20583
  }, [activeSheet?.conditionalFormatRules, activeSheet?.workbookSheetIndex, revision]);
@@ -20474,11 +20595,11 @@ function XlsxGrid({
20474
20595
  }
20475
20596
  return {
20476
20597
  height: sumPrefixRange(rowPrefixSums, startRowIndex, endRowIndex),
20477
- left: ROW_HEADER_WIDTH + sumPrefixRange(colPrefixSums, 0, startColIndex - 1),
20478
- top: HEADER_HEIGHT + sumPrefixRange(rowPrefixSums, 0, startRowIndex - 1),
20598
+ left: displayRowHeaderWidth + sumPrefixRange(colPrefixSums, 0, startColIndex - 1),
20599
+ top: displayHeaderHeight + sumPrefixRange(rowPrefixSums, 0, startRowIndex - 1),
20479
20600
  width: sumPrefixRange(colPrefixSums, startColIndex, endColIndex)
20480
20601
  };
20481
- }, [colIndexByActual, colPrefixSums, displayedSelection, rowIndexByActual, rowPrefixSums]);
20602
+ }, [colIndexByActual, colPrefixSums, displayHeaderHeight, displayRowHeaderWidth, displayedSelection, rowIndexByActual, rowPrefixSums]);
20482
20603
  const resolvedSelectionOverlay = selectionOverlay;
20483
20604
  const virtualCols = React4.useMemo(
20484
20605
  () => shouldVirtualizeCols ? colVirtualizer.getVirtualItems().map((virtualCol) => ({
@@ -20491,10 +20612,10 @@ function XlsxGrid({
20491
20612
  end: colPrefixSums[index + 1] ?? 0,
20492
20613
  index,
20493
20614
  key: visibleCols[index] ?? index,
20494
- size: effectiveColWidths[index] ?? DEFAULT_COL_WIDTH2,
20615
+ size: displayEffectiveColWidths[index] ?? displayDefaultColWidth,
20495
20616
  start: colPrefixSums[index] ?? 0
20496
20617
  })),
20497
- [colPrefixSums, colVirtualizer, effectiveColWidths, shouldVirtualizeCols, visibleCols]
20618
+ [colPrefixSums, colVirtualizer, displayDefaultColWidth, displayEffectiveColWidths, shouldVirtualizeCols, visibleCols]
20498
20619
  );
20499
20620
  const renderedCols = React4.useMemo(
20500
20621
  () => {
@@ -20513,7 +20634,7 @@ function XlsxGrid({
20513
20634
  });
20514
20635
  return columns;
20515
20636
  },
20516
- [effectiveColWidths, virtualCols, visibleCols]
20637
+ [virtualCols, visibleCols]
20517
20638
  );
20518
20639
  const totalContentWidth = colPrefixSums[colPrefixSums.length - 1] ?? 0;
20519
20640
  const leadingColumnSpacerWidth = shouldVirtualizeCols ? virtualCols[0]?.start ?? 0 : 0;
@@ -20521,12 +20642,14 @@ function XlsxGrid({
20521
20642
  const imageRects = React4.useMemo(
20522
20643
  () => showImages ? images.map((image) => ({
20523
20644
  image,
20524
- rect: imagePreviewRect && imagePreviewRect.id === image.id ? imagePreviewRect.rect : resolveImageRect(image, visibleRows, visibleCols, effectiveRowHeights, effectiveColWidths, {
20645
+ rect: imagePreviewRect && imagePreviewRect.id === image.id ? imagePreviewRect.rect : resolveImageRect(image, visibleRows, visibleCols, displayEffectiveRowHeights, displayEffectiveColWidths, {
20525
20646
  actualColPrefixSums,
20526
20647
  actualRowPrefixSums,
20527
20648
  colIndexByActual,
20528
20649
  colPrefixSums,
20650
+ headerHeight: displayHeaderHeight,
20529
20651
  rowIndexByActual,
20652
+ rowHeaderWidth: displayRowHeaderWidth,
20530
20653
  rowPrefixSums
20531
20654
  })
20532
20655
  })) : [],
@@ -20535,8 +20658,10 @@ function XlsxGrid({
20535
20658
  colPrefixSums,
20536
20659
  actualColPrefixSums,
20537
20660
  actualRowPrefixSums,
20538
- effectiveColWidths,
20539
- effectiveRowHeights,
20661
+ displayHeaderHeight,
20662
+ displayEffectiveColWidths,
20663
+ displayEffectiveRowHeights,
20664
+ displayRowHeaderWidth,
20540
20665
  imagePreviewRect,
20541
20666
  images,
20542
20667
  rowIndexByActual,
@@ -20548,12 +20673,14 @@ function XlsxGrid({
20548
20673
  );
20549
20674
  const shapeRects = React4.useMemo(
20550
20675
  () => showImages ? shapes.map((shape) => ({
20551
- rect: resolveAnchoredRect(shape.anchor, visibleRows, visibleCols, effectiveRowHeights, effectiveColWidths, {
20676
+ rect: resolveAnchoredRect(shape.anchor, visibleRows, visibleCols, displayEffectiveRowHeights, displayEffectiveColWidths, {
20552
20677
  actualColPrefixSums,
20553
20678
  actualRowPrefixSums,
20554
20679
  colIndexByActual,
20555
20680
  colPrefixSums,
20681
+ headerHeight: displayHeaderHeight,
20556
20682
  rowIndexByActual,
20683
+ rowHeaderWidth: displayRowHeaderWidth,
20557
20684
  rowPrefixSums
20558
20685
  }),
20559
20686
  shape
@@ -20563,8 +20690,10 @@ function XlsxGrid({
20563
20690
  colPrefixSums,
20564
20691
  actualColPrefixSums,
20565
20692
  actualRowPrefixSums,
20566
- effectiveColWidths,
20567
- effectiveRowHeights,
20693
+ displayHeaderHeight,
20694
+ displayEffectiveColWidths,
20695
+ displayEffectiveRowHeights,
20696
+ displayRowHeaderWidth,
20568
20697
  rowIndexByActual,
20569
20698
  rowPrefixSums,
20570
20699
  shapes,
@@ -20576,12 +20705,14 @@ function XlsxGrid({
20576
20705
  const chartRects = React4.useMemo(
20577
20706
  () => showImages ? charts.map((chart) => ({
20578
20707
  chart,
20579
- rect: chartPreviewRect && chartPreviewRect.id === chart.id ? chartPreviewRect.rect : resolveAnchoredRect(chart.anchor, visibleRows, visibleCols, effectiveRowHeights, effectiveColWidths, {
20708
+ rect: chartPreviewRect && chartPreviewRect.id === chart.id ? chartPreviewRect.rect : resolveAnchoredRect(chart.anchor, visibleRows, visibleCols, displayEffectiveRowHeights, displayEffectiveColWidths, {
20580
20709
  actualColPrefixSums,
20581
20710
  actualRowPrefixSums,
20582
20711
  colIndexByActual,
20583
20712
  colPrefixSums,
20713
+ headerHeight: displayHeaderHeight,
20584
20714
  rowIndexByActual,
20715
+ rowHeaderWidth: displayRowHeaderWidth,
20585
20716
  rowPrefixSums
20586
20717
  })
20587
20718
  })) : [],
@@ -20592,8 +20723,10 @@ function XlsxGrid({
20592
20723
  charts,
20593
20724
  colIndexByActual,
20594
20725
  colPrefixSums,
20595
- effectiveColWidths,
20596
- effectiveRowHeights,
20726
+ displayHeaderHeight,
20727
+ displayEffectiveColWidths,
20728
+ displayEffectiveRowHeights,
20729
+ displayRowHeaderWidth,
20597
20730
  rowIndexByActual,
20598
20731
  rowPrefixSums,
20599
20732
  showImages,
@@ -20639,15 +20772,15 @@ function XlsxGrid({
20639
20772
  if (startRowIndex === void 0 || endRowIndex === void 0 || startColIndex === void 0 || endColIndex === void 0) {
20640
20773
  return null;
20641
20774
  }
20642
- let left = ROW_HEADER_WIDTH + sumPrefixRange(colPrefixSums, 0, startColIndex - 1);
20643
- let top = HEADER_HEIGHT + sumPrefixRange(rowPrefixSums, 0, startRowIndex - 1);
20775
+ let left = displayRowHeaderWidth + sumPrefixRange(colPrefixSums, 0, startColIndex - 1);
20776
+ let top = displayHeaderHeight + sumPrefixRange(rowPrefixSums, 0, startRowIndex - 1);
20644
20777
  let width = sumPrefixRange(colPrefixSums, startColIndex, endColIndex);
20645
20778
  let height = sumPrefixRange(rowPrefixSums, startRowIndex, endRowIndex);
20646
20779
  const columnPreview = columnPreviewRef.current;
20647
20780
  if (columnPreview) {
20648
20781
  const previewIndex = colIndexByActual.get(columnPreview.actualIndex);
20649
20782
  if (previewIndex !== void 0) {
20650
- const baseWidth = effectiveColWidths[previewIndex] ?? DEFAULT_COL_WIDTH2;
20783
+ const baseWidth = displayEffectiveColWidths[previewIndex] ?? displayDefaultColWidth;
20651
20784
  const widthDelta = columnPreview.size - baseWidth;
20652
20785
  if (previewIndex < startColIndex) {
20653
20786
  left += widthDelta;
@@ -20661,7 +20794,7 @@ function XlsxGrid({
20661
20794
  if (rowPreview) {
20662
20795
  const previewIndex = rowIndexByActual.get(rowPreview.actualIndex);
20663
20796
  if (previewIndex !== void 0) {
20664
- const baseHeight = effectiveRowHeights[previewIndex] ?? DEFAULT_ROW_HEIGHT2;
20797
+ const baseHeight = displayEffectiveRowHeights[previewIndex] ?? displayDefaultRowHeight;
20665
20798
  const heightDelta = rowPreview.size - baseHeight;
20666
20799
  if (previewIndex < startRowIndex) {
20667
20800
  top += heightDelta;
@@ -20673,11 +20806,11 @@ function XlsxGrid({
20673
20806
  }
20674
20807
  return {
20675
20808
  height: Math.max(0, height),
20676
- left: Math.max(ROW_HEADER_WIDTH, left),
20677
- top: Math.max(HEADER_HEIGHT, top),
20809
+ left: Math.max(displayRowHeaderWidth, left),
20810
+ top: Math.max(displayHeaderHeight, top),
20678
20811
  width: Math.max(0, width)
20679
20812
  };
20680
- }, [colIndexByActual, colPrefixSums, effectiveColWidths, effectiveRowHeights, rowIndexByActual, rowPrefixSums]);
20813
+ }, [colIndexByActual, colPrefixSums, displayDefaultColWidth, displayDefaultRowHeight, displayEffectiveColWidths, displayEffectiveRowHeights, displayHeaderHeight, displayRowHeaderWidth, rowIndexByActual, rowPrefixSums]);
20681
20814
  const resolveMountedRangeOverlayRect = React4.useCallback((range, geometryRect) => {
20682
20815
  const normalized = normalizeRange2(range);
20683
20816
  const startRect = resolveMountedCellOverlayRectForAddress(normalized.start);
@@ -20694,11 +20827,11 @@ function XlsxGrid({
20694
20827
  const bottom = bottomRect ? bottomRect.top + bottomRect.height : geometryRect.top + geometryRect.height;
20695
20828
  return {
20696
20829
  height: Math.max(0, bottom - top),
20697
- left: Math.max(ROW_HEADER_WIDTH, left),
20698
- top: Math.max(HEADER_HEIGHT, top),
20830
+ left: Math.max(displayRowHeaderWidth, left),
20831
+ top: Math.max(displayHeaderHeight, top),
20699
20832
  width: Math.max(0, right - left)
20700
20833
  };
20701
- }, [resolveMountedCellOverlayRectForAddress]);
20834
+ }, [displayHeaderHeight, displayRowHeaderWidth, resolveMountedCellOverlayRectForAddress]);
20702
20835
  const resolveDragPreviewRect = React4.useCallback((range) => {
20703
20836
  const dragState = selectionDragRef.current;
20704
20837
  if (!dragState || !dragState.didDrag || dragState.axis !== "cell" || !dragState.originOverlayRect) {
@@ -20816,11 +20949,11 @@ function XlsxGrid({
20816
20949
  overlay.style.visibility = "visible";
20817
20950
  const fillHandle = fillHandleRef.current;
20818
20951
  if (fillHandle) {
20819
- fillHandle.style.left = `${nextRect.left + nextRect.width - 4}px`;
20820
- fillHandle.style.top = `${nextRect.top + nextRect.height - 4}px`;
20952
+ fillHandle.style.left = `${nextRect.left + nextRect.width - 4 * zoomFactor}px`;
20953
+ fillHandle.style.top = `${nextRect.top + nextRect.height - 4 * zoomFactor}px`;
20821
20954
  }
20822
20955
  applyHeaderSelection(range);
20823
- }, [applyHeaderSelection, resolveDragPreviewRect, resolveGeometryOverlayRect, resolveOverlayRect]);
20956
+ }, [applyHeaderSelection, resolveDragPreviewRect, resolveGeometryOverlayRect, resolveOverlayRect, zoomFactor]);
20824
20957
  const applyPreviewOverlayFromElement = React4.useCallback((element, range) => {
20825
20958
  const overlay = selectionOverlayRef.current;
20826
20959
  if (!overlay) {
@@ -20839,11 +20972,11 @@ function XlsxGrid({
20839
20972
  overlay.style.visibility = "visible";
20840
20973
  const fillHandle = fillHandleRef.current;
20841
20974
  if (fillHandle) {
20842
- fillHandle.style.left = `${nextRect.left + nextRect.width - 4}px`;
20843
- fillHandle.style.top = `${nextRect.top + nextRect.height - 4}px`;
20975
+ fillHandle.style.left = `${nextRect.left + nextRect.width - 4 * zoomFactor}px`;
20976
+ fillHandle.style.top = `${nextRect.top + nextRect.height - 4 * zoomFactor}px`;
20844
20977
  }
20845
20978
  applyHeaderSelection(range);
20846
- }, [applyHeaderSelection, resolveMountedCellOverlayRect, resolveOverlayRect]);
20979
+ }, [applyHeaderSelection, resolveMountedCellOverlayRect, resolveOverlayRect, zoomFactor]);
20847
20980
  const syncActiveValidationOverlay = React4.useCallback((cell) => {
20848
20981
  const overlay = activeValidationOverlayRef.current;
20849
20982
  if (!overlay || !cell || editingCellRef.current || selectionDragRef.current || fillDragRef.current) {
@@ -20861,11 +20994,11 @@ function XlsxGrid({
20861
20994
  overlay.style.visibility = "hidden";
20862
20995
  return;
20863
20996
  }
20864
- overlay.style.left = `${rect.left + rect.width - 16}px`;
20997
+ overlay.style.left = `${rect.left + rect.width - 16 * zoomFactor}px`;
20865
20998
  overlay.style.top = `${rect.top + rect.height / 2}px`;
20866
20999
  overlay.style.opacity = "1";
20867
21000
  overlay.style.visibility = "visible";
20868
- }, [getCellData, resolveOverlayRect]);
21001
+ }, [getCellData, resolveOverlayRect, zoomFactor]);
20869
21002
  const commitSelectionRange = React4.useCallback((range) => {
20870
21003
  const normalized = normalizeRange2(range);
20871
21004
  if (selectionRef.current && rangesEqual(selectionRef.current, normalized) && isSameCell(activeCellRef.current, normalized.end) && selectedChartIdRef.current === null && selectedImageIdRef.current === null) {
@@ -20903,7 +21036,7 @@ function XlsxGrid({
20903
21036
  }
20904
21037
  pendingResizePreviewRef.current = {
20905
21038
  actualIndex: state.actualIndex,
20906
- size: state.type === "column" ? Math.max(DEFAULT_COL_WIDTH2 / 2, state.initialPx + (event.clientX - state.startPosition) / zoomFactor) : Math.max(DEFAULT_ROW_HEIGHT2 / 1.5, state.initialPx + (event.clientY - state.startPosition) / zoomFactor),
21039
+ size: state.type === "column" ? Math.max(displayDefaultColWidth / 2, state.initialPx + (event.clientX - state.startPosition)) : Math.max(displayDefaultRowHeight / 1.5, state.initialPx + (event.clientY - state.startPosition)),
20907
21040
  type: state.type
20908
21041
  };
20909
21042
  if (resizeFrameRef.current !== null) {
@@ -20950,9 +21083,9 @@ function XlsxGrid({
20950
21083
  }
20951
21084
  if (preview && preview.actualIndex === resizeState.actualIndex && preview.type === resizeState.type) {
20952
21085
  if (preview.type === "column") {
20953
- controller.resizeColumn(preview.actualIndex, preview.size);
21086
+ controller.resizeColumn(preview.actualIndex, preview.size / zoomFactor);
20954
21087
  } else {
20955
- controller.resizeRow(preview.actualIndex, preview.size);
21088
+ controller.resizeRow(preview.actualIndex, preview.size / zoomFactor);
20956
21089
  }
20957
21090
  }
20958
21091
  }
@@ -20969,7 +21102,7 @@ function XlsxGrid({
20969
21102
  resizeFrameRef.current = null;
20970
21103
  }
20971
21104
  };
20972
- }, [applyColumnPreview, applyRowPreview, controller, refreshOverlayFromCurrentSelection, rowVirtualizer, shouldVirtualizeRows, zoomFactor]);
21105
+ }, [applyColumnPreview, applyRowPreview, controller, displayDefaultColWidth, displayDefaultRowHeight, refreshOverlayFromCurrentSelection, rowVirtualizer, shouldVirtualizeRows, zoomFactor]);
20973
21106
  function buildDraggedSelectionRange(dragState, cell) {
20974
21107
  if (dragState.axis === "row") {
20975
21108
  if (firstVisibleCol === void 0 || lastVisibleCol === void 0) {
@@ -21298,21 +21431,21 @@ function XlsxGrid({
21298
21431
  color: palette.mutedText,
21299
21432
  cursor: "pointer",
21300
21433
  display: "inline-flex",
21301
- fontSize: 10,
21302
- height: 16,
21434
+ fontSize: 10 * zoomFactor,
21435
+ height: 16 * zoomFactor,
21303
21436
  justifyContent: "center",
21304
21437
  padding: 0,
21305
21438
  position: "absolute",
21306
- right: 4,
21307
- top: 3,
21308
- width: 16,
21439
+ right: 4 * zoomFactor,
21440
+ top: 3 * zoomFactor,
21441
+ width: 16 * zoomFactor,
21309
21442
  zIndex: 6
21310
21443
  },
21311
21444
  type: "button",
21312
21445
  children: direction === "ascending" ? "\u25B2" : direction === "descending" ? "\u25BC" : "\u25BE"
21313
21446
  }
21314
21447
  );
21315
- }, [effectiveTables, palette.mutedText, sortState]);
21448
+ }, [effectiveTables, palette.mutedText, sortState, zoomFactor]);
21316
21449
  const startChartMove = React4.useCallback((event, chart, rect) => {
21317
21450
  if (event.button !== 0) {
21318
21451
  return;
@@ -21518,7 +21651,7 @@ function XlsxGrid({
21518
21651
  end: rowPrefixSums[index + 1] ?? 0,
21519
21652
  index,
21520
21653
  key: actualRow,
21521
- size: effectiveRowHeights[index] ?? DEFAULT_ROW_HEIGHT2,
21654
+ size: displayEffectiveRowHeights[index] ?? displayDefaultRowHeight,
21522
21655
  start: rowPrefixSums[index] ?? 0
21523
21656
  })) : (() => {
21524
21657
  const renderedRowsByIndex = /* @__PURE__ */ new Map();
@@ -21539,27 +21672,25 @@ function XlsxGrid({
21539
21672
  end: rowPrefixSums[index + 1] ?? 0,
21540
21673
  index,
21541
21674
  key: visibleRows[index] ?? index,
21542
- size: effectiveRowHeights[index] ?? DEFAULT_ROW_HEIGHT2,
21675
+ size: displayEffectiveRowHeights[index] ?? displayDefaultRowHeight,
21543
21676
  start: rowPrefixSums[index] ?? 0
21544
21677
  });
21545
21678
  });
21546
21679
  return Array.from(renderedRowsByIndex.values()).sort((left, right) => left.index - right.index);
21547
21680
  })();
21548
21681
  const totalHeight = shouldVirtualizeRows ? rowVirtualizer.getTotalSize() : rowPrefixSums[rowPrefixSums.length - 1] ?? 0;
21549
- const totalWidth = totalContentWidth + ROW_HEADER_WIDTH;
21550
- const sheetContentHeight = HEADER_HEIGHT + totalHeight;
21551
- const zoomedSheetHeight = sheetContentHeight * zoomFactor;
21552
- const zoomedSheetWidth = totalWidth * zoomFactor;
21682
+ const totalWidth = totalContentWidth + displayRowHeaderWidth;
21683
+ const sheetContentHeight = displayHeaderHeight + totalHeight;
21553
21684
  const { fill: selectionFill, header: selectionHeaderSurface, stroke: selectionStroke } = resolveSelectionColors({
21554
21685
  palette,
21555
21686
  selectionColor,
21556
21687
  selectionFillColor,
21557
21688
  selectionHeaderColor
21558
21689
  });
21559
- const selectionBorderWidth = 1.5;
21690
+ const selectionBorderWidth = Math.max(1, zoomFactor);
21560
21691
  const rowColSpan = renderedCols.length + 1 + (leadingColumnSpacerWidth > 0 ? 1 : 0) + (trailingColumnSpacerWidth > 0 ? 1 : 0);
21561
21692
  const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
21562
- const headerCellStyle = {
21693
+ const headerCellStyle = scaleCssProperties({
21563
21694
  backgroundColor: palette.headerSurface,
21564
21695
  borderBottom: "none",
21565
21696
  borderRight: "none",
@@ -21576,8 +21707,8 @@ function XlsxGrid({
21576
21707
  userSelect: "none",
21577
21708
  whiteSpace: "nowrap",
21578
21709
  zIndex: 50
21579
- };
21580
- const columnResizeHandleStyle = {
21710
+ }, zoomFactor);
21711
+ const columnResizeHandleStyle = scaleCssProperties({
21581
21712
  backgroundColor: "transparent",
21582
21713
  cursor: "col-resize",
21583
21714
  position: "absolute",
@@ -21586,17 +21717,23 @@ function XlsxGrid({
21586
21717
  width: 16,
21587
21718
  height: "100%",
21588
21719
  zIndex: 5
21589
- };
21720
+ }, zoomFactor);
21590
21721
  function resolveDrawingPane(rect) {
21591
21722
  return resolveFrozenDrawingPane(
21592
21723
  rect,
21593
21724
  frozenRows,
21594
21725
  frozenCols,
21595
- actualRowHeights,
21596
- actualColWidths,
21726
+ displayActualRowHeights,
21727
+ displayActualColWidths,
21597
21728
  activeSheet?.freezePanes ?? null,
21598
21729
  stickyTopByRow,
21599
- stickyLeftByCol
21730
+ stickyLeftByCol,
21731
+ {
21732
+ defaultColWidth: displayDefaultColWidth,
21733
+ defaultRowHeight: displayDefaultRowHeight,
21734
+ headerHeight: displayHeaderHeight,
21735
+ rowHeaderWidth: displayRowHeaderWidth
21736
+ }
21600
21737
  );
21601
21738
  }
21602
21739
  function renderShapeDrawing(shape, rect, pane) {
@@ -21613,12 +21750,12 @@ function XlsxGrid({
21613
21750
  const groupScaleX = shape.scaleX ?? 1;
21614
21751
  const groupScaleY = shape.scaleY ?? 1;
21615
21752
  const strokeScale = Math.max(groupScaleX, groupScaleY);
21616
- const textScale = strokeScale;
21753
+ const textScale = strokeScale * zoomFactor;
21617
21754
  const textWidth = groupScaleX !== 0 ? rect.width / groupScaleX : rect.width;
21618
21755
  const textHeight = groupScaleY !== 0 ? rect.height / groupScaleY : rect.height;
21619
21756
  const vectorShape = resolveShapeVector(shape);
21620
21757
  const strokeColor = shape.stroke?.none ? "transparent" : shape.stroke?.color ?? "transparent";
21621
- const scaledStrokeWidth = (shape.stroke?.widthPx ?? (shape.geometry === "line" ? 2 : 1)) * strokeScale;
21758
+ const scaledStrokeWidth = (shape.stroke?.widthPx ?? (shape.geometry === "line" ? 2 : 1)) * strokeScale * zoomFactor;
21622
21759
  const headMarkerId = `${shape.id}-${pane}-head-marker`;
21623
21760
  const tailMarkerId = `${shape.id}-${pane}-tail-marker`;
21624
21761
  const headMarker = vectorShape ? resolveShapeLineEndMarker(
@@ -21638,7 +21775,7 @@ function XlsxGrid({
21638
21775
  vectorShape.viewBox
21639
21776
  ) : null;
21640
21777
  const style = {
21641
- ...buildShapeContainerStyle(shape, rect),
21778
+ ...buildShapeContainerStyle(shape, rect, zoomFactor),
21642
21779
  ...vectorShape ? {
21643
21780
  backgroundColor: "transparent",
21644
21781
  border: "none"
@@ -21701,13 +21838,13 @@ function XlsxGrid({
21701
21838
  display: "flex",
21702
21839
  flex: 1,
21703
21840
  flexDirection: "column",
21704
- gap: 2,
21841
+ gap: 2 * zoomFactor,
21705
21842
  height: textHeight,
21706
21843
  justifyContent: shape.textBox?.verticalAlign === "middle" ? "center" : shape.textBox?.verticalAlign === "bottom" ? "flex-end" : "flex-start",
21707
- paddingBottom: inset?.bottom ?? 4,
21708
- paddingLeft: inset?.left ?? 6,
21709
- paddingRight: inset?.right ?? 6,
21710
- paddingTop: inset?.top ?? 4,
21844
+ paddingBottom: (inset?.bottom ?? 4) * zoomFactor,
21845
+ paddingLeft: (inset?.left ?? 6) * zoomFactor,
21846
+ paddingRight: (inset?.right ?? 6) * zoomFactor,
21847
+ paddingTop: (inset?.top ?? 4) * zoomFactor,
21711
21848
  pointerEvents: "none",
21712
21849
  position: "relative",
21713
21850
  transform: groupScaleX !== 1 || groupScaleY !== 1 ? `scale(${groupScaleX}, ${groupScaleY})` : void 0,
@@ -21779,8 +21916,8 @@ function XlsxGrid({
21779
21916
  "div",
21780
21917
  {
21781
21918
  style: {
21782
- border: `1.5px solid ${selectionStroke}`,
21783
- boxShadow: `0 0 0 1px ${palette.surface}`,
21919
+ border: `${Math.max(1, zoomFactor)}px solid ${selectionStroke}`,
21920
+ boxShadow: `0 0 0 ${Math.max(1, zoomFactor)}px ${palette.surface}`,
21784
21921
  boxSizing: "border-box",
21785
21922
  inset: 0,
21786
21923
  pointerEvents: "none",
@@ -21790,7 +21927,7 @@ function XlsxGrid({
21790
21927
  "div",
21791
21928
  {
21792
21929
  onPointerDown: (event) => startImageResize(event, image, rect, position),
21793
- style: resolveImageHandleStyle(position, selectionStroke, palette.surface)
21930
+ style: resolveImageHandleStyle(position, selectionStroke, palette.surface, zoomFactor)
21794
21931
  },
21795
21932
  position
21796
21933
  )) : null
@@ -21802,7 +21939,7 @@ function XlsxGrid({
21802
21939
  startImageResize(event, image, rect, position);
21803
21940
  }
21804
21941
  },
21805
- style: canEditImage ? resolveImageHandleStyle(position, selectionStroke, palette.surface) : { ...resolveImageHandleStyle(position, selectionStroke, palette.surface), display: "none" }
21942
+ style: canEditImage ? resolveImageHandleStyle(position, selectionStroke, palette.surface, zoomFactor) : { ...resolveImageHandleStyle(position, selectionStroke, palette.surface, zoomFactor), display: "none" }
21806
21943
  }),
21807
21944
  image,
21808
21945
  rect
@@ -21810,8 +21947,8 @@ function XlsxGrid({
21810
21947
  "div",
21811
21948
  {
21812
21949
  style: {
21813
- border: `1.5px solid ${selectionStroke}`,
21814
- boxShadow: `0 0 0 1px ${palette.surface}`,
21950
+ border: `${Math.max(1, zoomFactor)}px solid ${selectionStroke}`,
21951
+ boxShadow: `0 0 0 ${Math.max(1, zoomFactor)}px ${palette.surface}`,
21815
21952
  boxSizing: "border-box",
21816
21953
  inset: 0,
21817
21954
  pointerEvents: "none",
@@ -21821,7 +21958,7 @@ function XlsxGrid({
21821
21958
  "div",
21822
21959
  {
21823
21960
  onPointerDown: (event) => startImageResize(event, image, rect, position),
21824
- style: resolveImageHandleStyle(position, selectionStroke, palette.surface)
21961
+ style: resolveImageHandleStyle(position, selectionStroke, palette.surface, zoomFactor)
21825
21962
  },
21826
21963
  position
21827
21964
  )) : null
@@ -21883,8 +22020,8 @@ function XlsxGrid({
21883
22020
  "div",
21884
22021
  {
21885
22022
  style: {
21886
- border: `1.5px solid ${selectionStroke}`,
21887
- boxShadow: `0 0 0 1px ${palette.surface}`,
22023
+ border: `${Math.max(1, zoomFactor)}px solid ${selectionStroke}`,
22024
+ boxShadow: `0 0 0 ${Math.max(1, zoomFactor)}px ${palette.surface}`,
21888
22025
  boxSizing: "border-box",
21889
22026
  inset: 0,
21890
22027
  pointerEvents: "none",
@@ -21894,7 +22031,7 @@ function XlsxGrid({
21894
22031
  "div",
21895
22032
  {
21896
22033
  onPointerDown: (event) => startChartResize(event, chart, rect, position),
21897
- style: resolveImageHandleStyle(position, selectionStroke, palette.surface)
22034
+ style: resolveImageHandleStyle(position, selectionStroke, palette.surface, zoomFactor)
21898
22035
  },
21899
22036
  position
21900
22037
  )) : null
@@ -22130,8 +22267,8 @@ function XlsxGrid({
22130
22267
  if (!interaction) {
22131
22268
  return;
22132
22269
  }
22133
- const deltaX = (event.clientX - interaction.startClientX) / zoomFactor;
22134
- const deltaY = (event.clientY - interaction.startClientY) / zoomFactor;
22270
+ const deltaX = event.clientX - interaction.startClientX;
22271
+ const deltaY = event.clientY - interaction.startClientY;
22135
22272
  if (!interaction.didMove && (Math.abs(deltaX) > 3 || Math.abs(deltaY) > 3)) {
22136
22273
  interaction.didMove = true;
22137
22274
  }
@@ -22140,7 +22277,12 @@ function XlsxGrid({
22140
22277
  ...interaction.baseRect,
22141
22278
  left: interaction.baseRect.left + deltaX,
22142
22279
  top: interaction.baseRect.top + deltaY
22143
- } : resizeImageRect(interaction.baseRect, interaction.handle, deltaX, deltaY, IMAGE_MIN_SIZE_PX)
22280
+ } : resizeImageRect(interaction.baseRect, interaction.handle, deltaX, deltaY, displayImageMinSize),
22281
+ {
22282
+ contentOffsetLeft: displayRowHeaderWidth,
22283
+ contentOffsetTop: displayHeaderHeight,
22284
+ minSizePx: displayImageMinSize
22285
+ }
22144
22286
  );
22145
22287
  scheduleImagePreviewRect({ id: interaction.imageId, rect: nextRect });
22146
22288
  };
@@ -22175,7 +22317,7 @@ function XlsxGrid({
22175
22317
  if (interaction.didMove) {
22176
22318
  skipNextImageClickRef.current = interaction.imageId;
22177
22319
  }
22178
- setImageRect(interaction.imageId, preview.rect);
22320
+ setImageRect(interaction.imageId, toLogicalRect(preview.rect));
22179
22321
  }
22180
22322
  imagePreviewRectRef.current = null;
22181
22323
  setImagePreviewRect(null);
@@ -22195,8 +22337,8 @@ function XlsxGrid({
22195
22337
  if (!interaction) {
22196
22338
  return;
22197
22339
  }
22198
- const deltaX = (event.clientX - interaction.startClientX) / zoomFactor;
22199
- const deltaY = (event.clientY - interaction.startClientY) / zoomFactor;
22340
+ const deltaX = event.clientX - interaction.startClientX;
22341
+ const deltaY = event.clientY - interaction.startClientY;
22200
22342
  if (!interaction.didMove && (Math.abs(deltaX) > 3 || Math.abs(deltaY) > 3)) {
22201
22343
  interaction.didMove = true;
22202
22344
  }
@@ -22205,7 +22347,12 @@ function XlsxGrid({
22205
22347
  ...interaction.baseRect,
22206
22348
  left: interaction.baseRect.left + deltaX,
22207
22349
  top: interaction.baseRect.top + deltaY
22208
- } : resizeImageRect(interaction.baseRect, interaction.handle, deltaX, deltaY, 48)
22350
+ } : resizeImageRect(interaction.baseRect, interaction.handle, deltaX, deltaY, 48 * zoomFactor),
22351
+ {
22352
+ contentOffsetLeft: displayRowHeaderWidth,
22353
+ contentOffsetTop: displayHeaderHeight,
22354
+ minSizePx: 48 * zoomFactor
22355
+ }
22209
22356
  );
22210
22357
  scheduleChartPreviewRect({ id: interaction.chartId, rect: nextRect });
22211
22358
  };
@@ -22240,7 +22387,7 @@ function XlsxGrid({
22240
22387
  if (interaction.didMove) {
22241
22388
  skipNextChartClickRef.current = interaction.chartId;
22242
22389
  }
22243
- setChartRect(interaction.chartId, preview.rect);
22390
+ setChartRect(interaction.chartId, toLogicalRect(preview.rect));
22244
22391
  }
22245
22392
  chartPreviewRectRef.current = null;
22246
22393
  setChartPreviewRect(null);
@@ -22422,8 +22569,8 @@ function XlsxGrid({
22422
22569
  minHeight: "100%",
22423
22570
  minWidth: "100%",
22424
22571
  position: "relative",
22425
- width: zoomedSheetWidth,
22426
- height: zoomedSheetHeight
22572
+ width: totalWidth,
22573
+ height: sheetContentHeight
22427
22574
  },
22428
22575
  children: /* @__PURE__ */ jsxs3(
22429
22576
  "div",
@@ -22434,9 +22581,6 @@ function XlsxGrid({
22434
22581
  left: 0,
22435
22582
  position: "absolute",
22436
22583
  top: 0,
22437
- transform: void 0,
22438
- transformOrigin: "top left",
22439
- zoom: useNativeZoomForStickyLayout ? zoomFactor : void 0,
22440
22584
  width: totalWidth
22441
22585
  },
22442
22586
  children: [
@@ -22459,7 +22603,7 @@ function XlsxGrid({
22459
22603
  },
22460
22604
  children: [
22461
22605
  /* @__PURE__ */ jsxs3("colgroup", { children: [
22462
- /* @__PURE__ */ jsx3("col", { style: { width: ROW_HEADER_WIDTH } }),
22606
+ /* @__PURE__ */ jsx3("col", { style: { width: displayRowHeaderWidth } }),
22463
22607
  leadingColumnSpacerWidth > 0 ? /* @__PURE__ */ jsx3("col", { style: { width: leadingColumnSpacerWidth } }) : null,
22464
22608
  renderedCols.map((column) => /* @__PURE__ */ jsx3(
22465
22609
  "col",
@@ -22485,7 +22629,7 @@ function XlsxGrid({
22485
22629
  ...headerCellStyle,
22486
22630
  backgroundColor: palette.headerSurface,
22487
22631
  left: 0,
22488
- width: ROW_HEADER_WIDTH,
22632
+ width: displayRowHeaderWidth,
22489
22633
  zIndex: 60
22490
22634
  }
22491
22635
  }
@@ -22560,10 +22704,12 @@ function XlsxGrid({
22560
22704
  readOnly,
22561
22705
  renderCellAdornment,
22562
22706
  rowHeight: virtualRow.size,
22707
+ rowHeaderWidth: displayRowHeaderWidth,
22563
22708
  stickyLeftByCol,
22564
22709
  stickyTop: stickyTopByRow.get(actualRow),
22565
22710
  trailingSpacerWidth: trailingColumnSpacerWidth,
22566
- visibleCols: renderedCols
22711
+ visibleCols: renderedCols,
22712
+ zoomFactor
22567
22713
  },
22568
22714
  virtualRow.key
22569
22715
  )
@@ -22612,16 +22758,16 @@ function XlsxGrid({
22612
22758
  alignItems: "center",
22613
22759
  color: palette.mutedText,
22614
22760
  display: "inline-flex",
22615
- fontSize: 10,
22761
+ fontSize: 10 * zoomFactor,
22616
22762
  fontWeight: 700,
22617
- height: 16,
22763
+ height: 16 * zoomFactor,
22618
22764
  justifyContent: "center",
22619
22765
  opacity: 0,
22620
22766
  pointerEvents: "none",
22621
22767
  position: "absolute",
22622
22768
  transform: "translateY(-50%)",
22623
22769
  visibility: "hidden",
22624
- width: 12,
22770
+ width: 12 * zoomFactor,
22625
22771
  zIndex: 26
22626
22772
  },
22627
22773
  children: "\u25BE"
@@ -22641,16 +22787,16 @@ function XlsxGrid({
22641
22787
  },
22642
22788
  style: {
22643
22789
  backgroundColor: selectionStroke,
22644
- border: `1px solid ${palette.surface}`,
22790
+ border: `${Math.max(1, zoomFactor)}px solid ${palette.surface}`,
22645
22791
  contain: "layout paint",
22646
22792
  cursor: "crosshair",
22647
22793
  display: !readOnly && resolvedSelectionOverlay ? "block" : "none",
22648
- height: 8,
22649
- left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 : 0,
22794
+ height: 8 * zoomFactor,
22795
+ left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 * zoomFactor : 0,
22650
22796
  pointerEvents: "auto",
22651
22797
  position: "absolute",
22652
- top: resolvedSelectionOverlay ? resolvedSelectionOverlay.top + resolvedSelectionOverlay.height - 4 : 0,
22653
- width: 8,
22798
+ top: resolvedSelectionOverlay ? resolvedSelectionOverlay.top + resolvedSelectionOverlay.height - 4 * zoomFactor : 0,
22799
+ width: 8 * zoomFactor,
22654
22800
  zIndex: 25
22655
22801
  }
22656
22802
  }
@@ -22661,7 +22807,7 @@ function XlsxGrid({
22661
22807
  ref: tableMenuRef,
22662
22808
  style: {
22663
22809
  color: palette.text,
22664
- left: Math.max(ROW_HEADER_WIDTH + 4, openTableMenuState.left),
22810
+ left: Math.max(displayRowHeaderWidth + 4 * zoomFactor, openTableMenuState.left),
22665
22811
  position: "absolute",
22666
22812
  top: openTableMenuState.top,
22667
22813
  zIndex: 50
@@ -22701,7 +22847,8 @@ function XlsxViewerInner({
22701
22847
  emptyState,
22702
22848
  errorState,
22703
22849
  fileTooLargeState,
22704
- height = "100%",
22850
+ height,
22851
+ isDark = false,
22705
22852
  loadingComponent,
22706
22853
  loadingState,
22707
22854
  renderChartLoading,
@@ -22716,15 +22863,14 @@ function XlsxViewerInner({
22716
22863
  showDefaultToolbar = true,
22717
22864
  toolbar
22718
22865
  }) {
22719
- const palette = useViewerPalette();
22720
- return /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children: /* @__PURE__ */ jsxs3(
22866
+ const palette = useViewerPalette(isDark);
22867
+ return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children: /* @__PURE__ */ jsxs3(
22721
22868
  "div",
22722
22869
  {
22723
22870
  className: classNames("react-xlsx-viewer", className),
22724
22871
  style: {
22725
22872
  blockSize: height,
22726
22873
  backgroundColor: palette.surface,
22727
- border: `1px solid ${palette.border}`,
22728
22874
  borderRadius: rounded ? 12 : 0,
22729
22875
  color: palette.text,
22730
22876
  display: "flex",
@@ -22762,7 +22908,7 @@ function XlsxViewerInner({
22762
22908
  ) })
22763
22909
  ]
22764
22910
  }
22765
- ) });
22911
+ ) }) });
22766
22912
  }
22767
22913
  function XlsxViewerWithInlineController(props) {
22768
22914
  const controller = useXlsxViewerController(props);
@@ -22770,16 +22916,17 @@ function XlsxViewerWithInlineController(props) {
22770
22916
  }
22771
22917
  function XlsxViewerProviderWithInlineController({
22772
22918
  children,
22919
+ isDark = false,
22773
22920
  ...options
22774
22921
  }) {
22775
22922
  const controller = useXlsxViewerController(options);
22776
- return /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children });
22923
+ return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children }) });
22777
22924
  }
22778
- function XlsxViewerProvider({ children, controller, ...options }) {
22925
+ function XlsxViewerProvider({ children, controller, isDark = false, ...options }) {
22779
22926
  if (controller) {
22780
- return /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children });
22927
+ return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children }) });
22781
22928
  }
22782
- return /* @__PURE__ */ jsx3(XlsxViewerProviderWithInlineController, { ...options, children });
22929
+ return /* @__PURE__ */ jsx3(XlsxViewerProviderWithInlineController, { ...options, isDark, children });
22783
22930
  }
22784
22931
  function useXlsxViewer() {
22785
22932
  const context = React4.useContext(ViewerContext);
@@ -23105,7 +23252,8 @@ function XlsxViewer(props) {
23105
23252
  }
23106
23253
  function DefaultXlsxToolbar() {
23107
23254
  const controller = useXlsxViewer();
23108
- const palette = useViewerPalette();
23255
+ const { isDark } = React4.useContext(ViewerAppearanceContext);
23256
+ const palette = useViewerPalette(isDark);
23109
23257
  return /* @__PURE__ */ jsx3(DefaultToolbar, { controller, palette });
23110
23258
  }
23111
23259
  export {