@extend-ai/react-xlsx 0.22.0 → 0.22.1

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 (46) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-JOOWCDHK.js → chunk-CMI5MIZZ.js} +84 -102
  3. package/dist/chunk-CMI5MIZZ.js.map +1 -0
  4. package/dist/{chunk-OMKR4PZY.js → chunk-EDOXAWRE.js} +5 -3
  5. package/dist/chunk-EDOXAWRE.js.map +1 -0
  6. package/dist/{chunk-BVRJGSYM.cjs → chunk-J43N64B5.cjs} +5 -3
  7. package/dist/chunk-J43N64B5.cjs.map +1 -0
  8. package/dist/{chunk-FM2VAXTV.js → chunk-QSOAAYBJ.js} +5 -3
  9. package/dist/chunk-QSOAAYBJ.js.map +1 -0
  10. package/dist/{chunk-6N6KJKR5.cjs → chunk-WNFIRTYB.cjs} +5 -3
  11. package/dist/chunk-WNFIRTYB.cjs.map +1 -0
  12. package/dist/{chunk-BBF4GKSB.cjs → chunk-YCMFDK3C.cjs} +200 -218
  13. package/dist/chunk-YCMFDK3C.cjs.map +1 -0
  14. package/dist/duke-sheets-provenance.json +4 -4
  15. package/dist/duke_sheets_wasm_bg.wasm +0 -0
  16. package/dist/index.cjs +108 -109
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.js +15 -16
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal.cjs +3 -3
  21. package/dist/internal.d.cts +1 -1
  22. package/dist/internal.d.ts +1 -1
  23. package/dist/internal.js +2 -2
  24. package/dist/vanilla.cjs +3 -3
  25. package/dist/vanilla.d.cts +2 -2
  26. package/dist/vanilla.d.ts +2 -2
  27. package/dist/vanilla.js +2 -2
  28. package/dist/{workbook-runtime-NUTDPW3M.js → workbook-runtime-4GBESX74.js} +2 -2
  29. package/dist/{workbook-runtime-N63M5KMU.cjs → workbook-runtime-ITKMDWLO.cjs} +33 -33
  30. package/dist/{workbook-runtime-N63M5KMU.cjs.map → workbook-runtime-ITKMDWLO.cjs.map} +1 -1
  31. package/dist/{workbook-runtime-UIWE4FQ7.js → workbook-runtime-MVU32DIU.js} +2 -2
  32. package/dist/{workbook-runtime-CXEHXA7S.cjs → workbook-runtime-PHL746NC.cjs} +35 -35
  33. package/dist/{workbook-runtime-CXEHXA7S.cjs.map → workbook-runtime-PHL746NC.cjs.map} +1 -1
  34. package/dist/xlsx-worker.js +4 -2
  35. package/dist/xlsx-worker.js.map +1 -1
  36. package/package.json +2 -2
  37. package/dist/chunk-6N6KJKR5.cjs.map +0 -1
  38. package/dist/chunk-BBF4GKSB.cjs.map +0 -1
  39. package/dist/chunk-BVRJGSYM.cjs.map +0 -1
  40. package/dist/chunk-FM2VAXTV.js.map +0 -1
  41. package/dist/chunk-JOOWCDHK.js.map +0 -1
  42. package/dist/chunk-OMKR4PZY.js.map +0 -1
  43. package/dist/{internal-Ba92VZGf.d.cts → internal-DVsk7L2M.d.cts} +31 -31
  44. package/dist/{internal-Ba92VZGf.d.ts → internal-DVsk7L2M.d.ts} +31 -31
  45. /package/dist/{workbook-runtime-NUTDPW3M.js.map → workbook-runtime-4GBESX74.js.map} +0 -0
  46. /package/dist/{workbook-runtime-UIWE4FQ7.js.map → workbook-runtime-MVU32DIU.js.map} +0 -0
package/README.md CHANGED
@@ -728,7 +728,7 @@ Customize the existing menu with `contextMenuClassName`, `contextMenuStyle`, and
728
728
  <XlsxViewer
729
729
  file={file}
730
730
  contextMenuClassName="spreadsheet-menu"
731
- contextMenuStyle={{ borderRadius: 6 }}
731
+ contextMenuStyle={{ "--xlsx-menu-radius": "6px" }}
732
732
  renderContextMenu={({ context, actions, runAction, closeMenu, busy }) => (
733
733
  <>
734
734
  {actions.map((action) => (
@@ -755,7 +755,7 @@ Customize the existing menu with `contextMenuClassName`, `contextMenuStyle`, and
755
755
 
756
756
  The hook receives `context` (target kind, cell, selection, sheet index/name, and read-only state), `actions`, `runAction`, `closeMenu`, viewport `position`, `isDark`, `busy`, `error`, and `defaultNode`. Return `defaultNode` to keep built-in buttons while adding your own content. The viewer owns the portal, viewport-edge positioning, outside-click dismissal, and keyboard navigation for elements with `role="menuitem"`; return menu contents without another portal. `runAction` returns `Promise<boolean>` and rejects unavailable or disabled commands. Handle custom commands in your own callback and call `closeMenu` afterward.
757
757
 
758
- Default styling follows the document theme. Override `.react-xlsx-context-menu`, `.react-xlsx-context-menu-item`, `.react-xlsx-context-menu-separator`, and `.react-xlsx-context-menu-shortcut`, or set `--xlsx-context-menu-background`, `--xlsx-context-menu-color`, `--xlsx-context-menu-border`, `--xlsx-context-menu-hover`, `--xlsx-context-menu-muted`, and `--xlsx-context-menu-danger` through `contextMenuStyle`. The menu is portaled to the document body, so use its class rather than a viewer-descendant selector. Set `enableContextMenu={false}` to retain the browser's native context menu.
758
+ Default styling follows the document theme. Override `.react-xlsx-context-menu`, `.react-xlsx-context-menu-item`, `.react-xlsx-context-menu-separator`, and `.react-xlsx-context-menu-shortcut`, set `--xlsx-menu-radius` and `--xlsx-menu-padding` to resize the menu while keeping item corners concentric (items use the radius minus the padding), or set `--xlsx-context-menu-background`, `--xlsx-context-menu-color`, `--xlsx-context-menu-border`, `--xlsx-context-menu-hover`, `--xlsx-context-menu-muted`, and `--xlsx-context-menu-danger` through `contextMenuStyle`. The menu is portaled to the document body, so use its class rather than a viewer-descendant selector. The table header sort menu uses the same classes, so `contextMenuClassName` and `contextMenuStyle` restyle it too. Set `enableContextMenu={false}` to retain the browser's native context menu.
759
759
 
760
760
  ## Custom Cell Editor Overlays
761
761
 
@@ -43,7 +43,7 @@ import {
43
43
  updateWorkbookChartDefinition,
44
44
  updateWorkbookImageAnchor,
45
45
  xlsxAnchorToDukeDrawingAnchor
46
- } from "./chunk-OMKR4PZY.js";
46
+ } from "./chunk-EDOXAWRE.js";
47
47
  import {
48
48
  $,
49
49
  A,
@@ -474,7 +474,7 @@ var XlsxWorkerClient = class {
474
474
  }
475
475
  async getMainRuntime() {
476
476
  if (this.disposed) throw createAbortError();
477
- this.mainRuntime ??= import("./workbook-runtime-NUTDPW3M.js").then(({ createWorkbookRuntime }) => createWorkbookRuntime());
477
+ this.mainRuntime ??= import("./workbook-runtime-4GBESX74.js").then(({ createWorkbookRuntime }) => createWorkbookRuntime());
478
478
  const runtime = await this.mainRuntime;
479
479
  if (this.disposed) {
480
480
  runtime.dispose();
@@ -6549,17 +6549,19 @@ var menuStyles = `
6549
6549
  background: var(--xlsx-context-menu-background);
6550
6550
  color: var(--xlsx-context-menu-color);
6551
6551
  border: 1px solid var(--xlsx-context-menu-border);
6552
- border-radius: 8px;
6553
- padding: 5px;
6552
+ border-radius: var(--xlsx-menu-radius, 8px);
6553
+ padding: var(--xlsx-menu-padding, 5px);
6554
6554
  min-width: min(220px, calc(100vw - 16px));
6555
6555
  font: 13px/1.4 system-ui, sans-serif;
6556
6556
  box-shadow: 0 8px 28px rgb(0 0 0 / 18%);
6557
6557
  }
6558
6558
  :where(.react-xlsx-context-menu-item) {
6559
6559
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
6560
- width: 100%; border: 0; border-radius: 4px; padding: 7px 10px;
6560
+ width: 100%; border: 0; border-radius: max(0px, calc(var(--xlsx-menu-radius, 8px) - var(--xlsx-menu-padding, 5px)));
6561
+ padding: 7px 10px;
6561
6562
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
6562
6563
  }
6564
+ :where(.react-xlsx-context-menu-item[aria-pressed="true"]) { background: var(--xlsx-menu-active, var(--xlsx-context-menu-hover)); }
6563
6565
  :where(.react-xlsx-context-menu-item:focus-visible),
6564
6566
  :where(.react-xlsx-context-menu-item:hover:not(:disabled)) {
6565
6567
  background: var(--xlsx-context-menu-hover); outline: none;
@@ -6569,6 +6571,16 @@ var menuStyles = `
6569
6571
  :where(.react-xlsx-context-menu-shortcut) { font-size: 11px; color: var(--xlsx-context-menu-muted); }
6570
6572
  :where(.react-xlsx-context-menu-separator) { height: 1px; margin: 4px; background: var(--xlsx-context-menu-border); }
6571
6573
  `;
6574
+ function resolveMenuPaletteStyle(palette) {
6575
+ return {
6576
+ "--xlsx-context-menu-background": palette.surface,
6577
+ "--xlsx-context-menu-color": palette.text,
6578
+ "--xlsx-context-menu-border": palette.border,
6579
+ "--xlsx-context-menu-hover": palette.mutedSurface,
6580
+ "--xlsx-context-menu-muted": palette.mutedText,
6581
+ "--xlsx-context-menu-danger": palette.danger
6582
+ };
6583
+ }
6572
6584
  function XlsxContextMenu({
6573
6585
  context,
6574
6586
  position,
@@ -6836,12 +6848,7 @@ function XlsxContextMenu({
6836
6848
  ref: rootRef,
6837
6849
  role: "menu",
6838
6850
  style: {
6839
- "--xlsx-context-menu-background": palette.surface,
6840
- "--xlsx-context-menu-color": palette.text,
6841
- "--xlsx-context-menu-border": palette.border,
6842
- "--xlsx-context-menu-hover": palette.mutedSurface,
6843
- "--xlsx-context-menu-muted": palette.mutedText,
6844
- "--xlsx-context-menu-danger": palette.danger,
6851
+ ...resolveMenuPaletteStyle(palette),
6845
6852
  ...contextMenuStyle,
6846
6853
  position: "fixed",
6847
6854
  left: location.x,
@@ -8927,13 +8934,15 @@ function resolveCanvasGradientFill(context, rect, backgroundImage) {
8927
8934
  }
8928
8935
  return null;
8929
8936
  }
8937
+ var DATA_BAR_INSET = 2;
8938
+ var DATA_BAR_GRADIENT_TINT = 0.85;
8930
8939
  function resolveCanvasDataBarFill(context, left, top, width, _height, dataBar) {
8931
8940
  if (dataBar.gradient === false) {
8932
8941
  return dataBar.color;
8933
8942
  }
8934
8943
  const gradient = context.createLinearGradient(left, top, left + width, top);
8935
- gradient.addColorStop(0, lightenColor(dataBar.color, 0.28));
8936
- gradient.addColorStop(1, dataBar.color);
8944
+ gradient.addColorStop(0, dataBar.color);
8945
+ gradient.addColorStop(1, lightenColor(dataBar.color, DATA_BAR_GRADIENT_TINT));
8937
8946
  return gradient;
8938
8947
  }
8939
8948
  function drawCanvasConditionalIcon(context, icon, centerX, centerY, size) {
@@ -11594,59 +11603,10 @@ function DefaultTableHeaderMenu({
11594
11603
  sortDescending
11595
11604
  }) {
11596
11605
  const messages = useXlsxMessages();
11597
- return /* @__PURE__ */ u(
11598
- "div",
11599
- {
11600
- style: {
11601
- backgroundColor: "var(--xlsx-menu-surface)",
11602
- border: "1px solid var(--xlsx-menu-border)",
11603
- borderRadius: 10,
11604
- boxShadow: "0 10px 30px rgba(0, 0, 0, 0.16)",
11605
- display: "grid",
11606
- gap: 4,
11607
- minWidth: 160,
11608
- padding: 6
11609
- },
11610
- children: [
11611
- /* @__PURE__ */ u(
11612
- "button",
11613
- {
11614
- onClick: sortAscending,
11615
- style: {
11616
- background: direction === "ascending" ? "var(--xlsx-menu-active)" : "transparent",
11617
- border: "none",
11618
- borderRadius: 8,
11619
- color: "inherit",
11620
- cursor: "pointer",
11621
- fontSize: 12,
11622
- padding: "8px 10px",
11623
- textAlign: "left"
11624
- },
11625
- type: "button",
11626
- children: messages.sortAscending
11627
- }
11628
- ),
11629
- /* @__PURE__ */ u(
11630
- "button",
11631
- {
11632
- onClick: sortDescending,
11633
- style: {
11634
- background: direction === "descending" ? "var(--xlsx-menu-active)" : "transparent",
11635
- border: "none",
11636
- borderRadius: 8,
11637
- color: "inherit",
11638
- cursor: "pointer",
11639
- fontSize: 12,
11640
- padding: "8px 10px",
11641
- textAlign: "left"
11642
- },
11643
- type: "button",
11644
- children: messages.sortDescending
11645
- }
11646
- )
11647
- ]
11648
- }
11649
- );
11606
+ return /* @__PURE__ */ u(S, { children: [
11607
+ /* @__PURE__ */ u("button", { "aria-pressed": direction === "ascending", className: "react-xlsx-context-menu-item", onClick: sortAscending, type: "button", children: messages.sortAscending }),
11608
+ /* @__PURE__ */ u("button", { "aria-pressed": direction === "descending", className: "react-xlsx-context-menu-item", onClick: sortDescending, type: "button", children: messages.sortDescending })
11609
+ ] });
11650
11610
  }
11651
11611
  function resolveTableHeaderTriggerStyle(palette, zoomFactor) {
11652
11612
  return {
@@ -12934,8 +12894,8 @@ function resolveConditionalDataBarForCell(row3, col, worksheet, sheet, metricsCa
12934
12894
  if (minValue === null || maxValue === null) {
12935
12895
  return null;
12936
12896
  }
12937
- const minLength = Number.isFinite(matchingRule.minLength ?? Number.NaN) ? matchingRule.minLength ?? 0 : 0;
12938
- const maxLength = Number.isFinite(matchingRule.maxLength ?? Number.NaN) ? matchingRule.maxLength ?? 100 : 100;
12897
+ const minLength = Number.isFinite(matchingRule.minLength ?? Number.NaN) ? matchingRule.minLength ?? 10 : 10;
12898
+ const maxLength = Number.isFinite(matchingRule.maxLength ?? Number.NaN) ? matchingRule.maxLength ?? 90 : 90;
12939
12899
  const span = maxValue - minValue;
12940
12900
  const ratio = span === 0 ? numericValue >= maxValue ? 1 : 0 : (numericValue - minValue) / span;
12941
12901
  const widthPercent = minLength + Math.max(0, Math.min(1, ratio)) * (maxLength - minLength);
@@ -13388,22 +13348,19 @@ function GridRow({
13388
13348
  "aria-hidden": "true",
13389
13349
  style: {
13390
13350
  alignItems: "center",
13391
- bottom: 4 * zoomFactor,
13392
13351
  display: "flex",
13393
- left: 4 * zoomFactor,
13352
+ inset: DATA_BAR_INSET * zoomFactor,
13394
13353
  pointerEvents: "none",
13395
13354
  position: "absolute",
13396
- right: 4 * zoomFactor,
13397
- top: 4 * zoomFactor,
13398
13355
  zIndex: 0
13399
13356
  },
13400
13357
  children: /* @__PURE__ */ u(
13401
13358
  "div",
13402
13359
  {
13403
13360
  style: {
13404
- background: cellData.conditionalDataBar.gradient === false ? cellData.conditionalDataBar.color : `linear-gradient(90deg, ${lightenColor(cellData.conditionalDataBar.color, 0.28)} 0%, ${cellData.conditionalDataBar.color} 100%)`,
13361
+ background: cellData.conditionalDataBar.gradient === false ? cellData.conditionalDataBar.color : `linear-gradient(90deg, ${cellData.conditionalDataBar.color} 0%, ${lightenColor(cellData.conditionalDataBar.color, DATA_BAR_GRADIENT_TINT)} 100%)`,
13405
13362
  border: cellData.conditionalDataBar.border !== false && cellData.conditionalDataBar.borderColor ? `1px solid ${cellData.conditionalDataBar.borderColor}` : "none",
13406
- borderRadius: 2,
13363
+ boxSizing: "border-box",
13407
13364
  height: "100%",
13408
13365
  opacity: 1,
13409
13366
  width: `${cellData.conditionalDataBar.widthPercent}%`
@@ -16780,7 +16737,7 @@ function XlsxGrid({
16780
16737
  if (cell) {
16781
16738
  return {
16782
16739
  column,
16783
- left: cell.offsetLeft + cell.offsetWidth - 170,
16740
+ right: cell.offsetLeft + cell.offsetWidth,
16784
16741
  table,
16785
16742
  top: cell.offsetTop + cell.offsetHeight - 2
16786
16743
  };
@@ -16791,11 +16748,29 @@ function XlsxGrid({
16791
16748
  }
16792
16749
  return {
16793
16750
  column,
16794
- left: rect.left + rect.width - 170,
16751
+ right: rect.left + rect.width,
16795
16752
  table,
16796
16753
  top: rect.top + rect.height - 2
16797
16754
  };
16798
16755
  }, [effectiveTables, openTableMenu, resolveCellDisplayRect]);
16756
+ _(() => {
16757
+ const menu = tableMenuRef.current;
16758
+ const scroller = scrollRef.current;
16759
+ if (!openTableMenuState || !menu || !scroller || renderTableHeaderMenu) {
16760
+ return;
16761
+ }
16762
+ const updatePosition = () => {
16763
+ const margin = 4 * zoomFactor;
16764
+ const minLeft = scroller.scrollLeft + displayRowHeaderWidth + margin;
16765
+ const maxLeft = scroller.scrollLeft + scroller.clientWidth - margin - menu.offsetWidth;
16766
+ menu.style.left = `${Math.max(minLeft, Math.min(openTableMenuState.right - menu.offsetWidth, maxLeft))}px`;
16767
+ };
16768
+ updatePosition();
16769
+ const observer = new ResizeObserver(updatePosition);
16770
+ observer.observe(menu);
16771
+ observer.observe(scroller);
16772
+ return () => observer.disconnect();
16773
+ }, [contextMenuClassName, contextMenuStyle, displayRowHeaderWidth, openTableMenuState, renderTableHeaderMenu, zoomFactor]);
16799
16774
  const applyHeaderSelection = q((range) => {
16800
16775
  if (experimentalCanvas) {
16801
16776
  return;
@@ -18507,10 +18482,11 @@ function XlsxGrid({
18507
18482
  paneContext.fillStyle = gradientFill ?? fillColor;
18508
18483
  paneContext.fillRect(localRect.left, localRect.top, localRect.width, localRect.height);
18509
18484
  if (cellData.conditionalDataBar) {
18510
- const barLeft = localRect.left + 4 * zoomFactor;
18511
- const barTop = localRect.top + 4 * zoomFactor;
18512
- const barWidth = Math.max(0, (localRect.width - 8 * zoomFactor) * (cellData.conditionalDataBar.widthPercent / 100));
18513
- const barHeight = Math.max(0, localRect.height - 8 * zoomFactor);
18485
+ const barInset = DATA_BAR_INSET * zoomFactor;
18486
+ const barLeft = localRect.left + barInset;
18487
+ const barTop = localRect.top + barInset;
18488
+ const barWidth = Math.max(0, (localRect.width - barInset * 2) * (cellData.conditionalDataBar.widthPercent / 100));
18489
+ const barHeight = Math.max(0, localRect.height - barInset * 2);
18514
18490
  if (barWidth > 0 && barHeight > 0) {
18515
18491
  paneContext.fillStyle = resolveCanvasDataBarFill(
18516
18492
  paneContext,
@@ -21963,33 +21939,39 @@ function XlsxGrid({
21963
21939
  !renderTableHeaderMenu && openTableMenuState ? /* @__PURE__ */ u(
21964
21940
  "div",
21965
21941
  {
21942
+ className: ["react-xlsx-context-menu", contextMenuClassName].filter(Boolean).join(" "),
21966
21943
  ref: tableMenuRef,
21967
21944
  style: {
21968
- color: palette.text,
21969
- left: Math.max(displayRowHeaderWidth + 4 * zoomFactor, openTableMenuState.left),
21945
+ ...resolveMenuPaletteStyle(palette),
21946
+ ...contextMenuStyle,
21947
+ boxSizing: "border-box",
21948
+ left: openTableMenuState.right,
21970
21949
  position: "absolute",
21971
21950
  top: openTableMenuState.top,
21972
21951
  zIndex: 50
21973
21952
  },
21974
- children: /* @__PURE__ */ u(
21975
- DefaultTableHeaderMenu,
21976
- {
21977
- cell: { col: openTableMenuState.column.index + openTableMenuState.table.start.col, row: openTableMenuState.table.start.row },
21978
- column: openTableMenuState.column,
21979
- direction: sortState && sortState.tableName === openTableMenuState.table.name && sortState.columnIndex === openTableMenuState.column.index ? sortState.direction : null,
21980
- sortAscending: () => {
21981
- sortTable(openTableMenuState.table.name, openTableMenuState.column.index, "ascending");
21982
- setOpenTableMenu(null);
21983
- },
21984
- sortDescending: () => {
21985
- sortTable(openTableMenuState.table.name, openTableMenuState.column.index, "descending");
21986
- setOpenTableMenu(null);
21987
- },
21988
- table: openTableMenuState.table,
21989
- triggerIcon: "\u25BE",
21990
- triggerProps: { type: "button" }
21991
- }
21992
- )
21953
+ children: [
21954
+ /* @__PURE__ */ u("style", { children: menuStyles }),
21955
+ /* @__PURE__ */ u(
21956
+ DefaultTableHeaderMenu,
21957
+ {
21958
+ cell: { col: openTableMenuState.column.index + openTableMenuState.table.start.col, row: openTableMenuState.table.start.row },
21959
+ column: openTableMenuState.column,
21960
+ direction: sortState && sortState.tableName === openTableMenuState.table.name && sortState.columnIndex === openTableMenuState.column.index ? sortState.direction : null,
21961
+ sortAscending: () => {
21962
+ sortTable(openTableMenuState.table.name, openTableMenuState.column.index, "ascending");
21963
+ setOpenTableMenu(null);
21964
+ },
21965
+ sortDescending: () => {
21966
+ sortTable(openTableMenuState.table.name, openTableMenuState.column.index, "descending");
21967
+ setOpenTableMenu(null);
21968
+ },
21969
+ table: openTableMenuState.table,
21970
+ triggerIcon: "\u25BE",
21971
+ triggerProps: { type: "button" }
21972
+ }
21973
+ )
21974
+ ]
21993
21975
  }
21994
21976
  ) : null
21995
21977
  ]
@@ -22446,4 +22428,4 @@ export {
22446
22428
  __createContentNode,
22447
22429
  __createContentRoot
22448
22430
  };
22449
- //# sourceMappingURL=chunk-JOOWCDHK.js.map
22431
+ //# sourceMappingURL=chunk-CMI5MIZZ.js.map