@extend-ai/react-xlsx 0.15.1 → 0.16.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/README.md CHANGED
@@ -468,6 +468,8 @@ Common rendering props:
468
468
  - `height?: React.CSSProperties["height"]`
469
469
  - `className?: string`
470
470
  - `isDark?: boolean`
471
+ - `headerBackgroundColor?: string`
472
+ - `headerTextColor?: string`
471
473
  - `rounded?: boolean`
472
474
  - `showDefaultToolbar?: boolean`
473
475
  - `toolbar?: React.ReactNode | ((controller: XlsxViewerController) => React.ReactNode)`
package/dist/index.cjs CHANGED
@@ -17834,6 +17834,67 @@ var MemoChartSvg = React3.memo(function MemoChartSvg2({
17834
17834
  );
17835
17835
  }, (prev, next) => prev.chart === next.chart && prev.onChartElementDoubleClick === next.onChartElementDoubleClick && prev.onChartElementPointerDown === next.onChartElementPointerDown && prev.palette === next.palette && prev.rect.height === next.rect.height && prev.rect.width === next.rect.width && prev.rect.left === next.rect.left && prev.rect.top === next.rect.top && prev.selectedChartElement === next.selectedChartElement);
17836
17836
 
17837
+ // src/viewer-palette.ts
17838
+ var LIGHT_PALETTE = {
17839
+ border: "#e4e4e7",
17840
+ buttonSurface: "#ffffff",
17841
+ buttonText: "#18181b",
17842
+ canvas: "#fafafa",
17843
+ danger: "#dc2626",
17844
+ headerSurface: "#f4f4f5",
17845
+ headerText: "#71717a",
17846
+ mutedSurface: "#f5f5f5",
17847
+ mutedText: "#71717a",
17848
+ rowHeaderSurface: "#f4f4f5",
17849
+ shadow: "0 1px 2px rgba(0, 0, 0, 0.04)",
17850
+ sheetActiveSurface: "#ffffff",
17851
+ sheetActiveText: "#18181b",
17852
+ sheetInactiveSurface: "#e4e4e7",
17853
+ sheetInactiveText: "#52525b",
17854
+ strongBorder: "#d4d4d8",
17855
+ subtleSurface: "#fafafa",
17856
+ surface: "#ffffff",
17857
+ text: "#18181b",
17858
+ toolbarSurface: "#f5f5f5"
17859
+ };
17860
+ var DARK_PALETTE = {
17861
+ border: "rgba(255, 255, 255, 0.10)",
17862
+ buttonSurface: "rgba(255, 255, 255, 0.06)",
17863
+ buttonText: "#f4f4f5",
17864
+ canvas: "#09090b",
17865
+ danger: "#f87171",
17866
+ headerSurface: "#18181b",
17867
+ headerText: "#a1a1aa",
17868
+ mutedSurface: "#111113",
17869
+ mutedText: "#a1a1aa",
17870
+ rowHeaderSurface: "#18181b",
17871
+ shadow: "0 1px 2px rgba(0, 0, 0, 0.28)",
17872
+ sheetActiveSurface: "#27272a",
17873
+ sheetActiveText: "#fafafa",
17874
+ sheetInactiveSurface: "#18181b",
17875
+ sheetInactiveText: "#a1a1aa",
17876
+ strongBorder: "rgba(255, 255, 255, 0.16)",
17877
+ subtleSurface: "#101012",
17878
+ surface: "#111113",
17879
+ text: "#f4f4f5",
17880
+ toolbarSurface: "#101012"
17881
+ };
17882
+ function isDarkViewerPalette(palette) {
17883
+ return palette.surface === DARK_PALETTE.surface;
17884
+ }
17885
+ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
17886
+ const basePalette = isDark ? DARK_PALETTE : LIGHT_PALETTE;
17887
+ if (headerBackgroundColor === void 0 && headerTextColor === void 0) {
17888
+ return basePalette;
17889
+ }
17890
+ return {
17891
+ ...basePalette,
17892
+ headerSurface: headerBackgroundColor ?? basePalette.headerSurface,
17893
+ headerText: headerTextColor ?? basePalette.headerText,
17894
+ rowHeaderSurface: headerBackgroundColor ?? basePalette.rowHeaderSurface
17895
+ };
17896
+ }
17897
+
17837
17898
  // src/XlsxViewer.tsx
17838
17899
  var import_jsx_runtime3 = require("react/jsx-runtime");
17839
17900
  var DEFAULT_ROW_HEIGHT2 = 24;
@@ -18591,48 +18652,6 @@ function resolveEventAnchor(clientX, clientY, rect) {
18591
18652
  function resolveTouchDistance(firstTouch, secondTouch) {
18592
18653
  return Math.hypot(firstTouch.clientX - secondTouch.clientX, firstTouch.clientY - secondTouch.clientY);
18593
18654
  }
18594
- var LIGHT_PALETTE = {
18595
- border: "#e4e4e7",
18596
- buttonSurface: "#ffffff",
18597
- buttonText: "#18181b",
18598
- canvas: "#fafafa",
18599
- danger: "#dc2626",
18600
- headerSurface: "#f4f4f5",
18601
- mutedSurface: "#f5f5f5",
18602
- mutedText: "#71717a",
18603
- rowHeaderSurface: "#f4f4f5",
18604
- shadow: "0 1px 2px rgba(0, 0, 0, 0.04)",
18605
- sheetActiveSurface: "#ffffff",
18606
- sheetActiveText: "#18181b",
18607
- sheetInactiveSurface: "#e4e4e7",
18608
- sheetInactiveText: "#52525b",
18609
- strongBorder: "#d4d4d8",
18610
- subtleSurface: "#fafafa",
18611
- surface: "#ffffff",
18612
- text: "#18181b",
18613
- toolbarSurface: "#f5f5f5"
18614
- };
18615
- var DARK_PALETTE = {
18616
- border: "rgba(255, 255, 255, 0.10)",
18617
- buttonSurface: "rgba(255, 255, 255, 0.06)",
18618
- buttonText: "#f4f4f5",
18619
- canvas: "#09090b",
18620
- danger: "#f87171",
18621
- headerSurface: "#18181b",
18622
- mutedSurface: "#111113",
18623
- mutedText: "#a1a1aa",
18624
- rowHeaderSurface: "#18181b",
18625
- shadow: "0 1px 2px rgba(0, 0, 0, 0.28)",
18626
- sheetActiveSurface: "#27272a",
18627
- sheetActiveText: "#fafafa",
18628
- sheetInactiveSurface: "#18181b",
18629
- sheetInactiveText: "#a1a1aa",
18630
- strongBorder: "rgba(255, 255, 255, 0.16)",
18631
- subtleSurface: "#101012",
18632
- surface: "#111113",
18633
- text: "#f4f4f5",
18634
- toolbarSurface: "#101012"
18635
- };
18636
18655
  function parseRgbColor3(color) {
18637
18656
  const match = /^#?([0-9a-f]{6})$/i.exec(color);
18638
18657
  if (!match) {
@@ -20087,8 +20106,11 @@ function resolveImageHandleStyle(position, stroke, surface, scale = 1) {
20087
20106
  }
20088
20107
  return style;
20089
20108
  }
20090
- function useViewerPalette(isDark = false) {
20091
- return isDark ? DARK_PALETTE : LIGHT_PALETTE;
20109
+ function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
20110
+ return React4.useMemo(
20111
+ () => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
20112
+ [headerBackgroundColor, headerTextColor, isDark]
20113
+ );
20092
20114
  }
20093
20115
  function normalizeThumbnailResolution(resolution) {
20094
20116
  if (typeof resolution === "number" && Number.isFinite(resolution) && resolution > 0) {
@@ -20336,7 +20358,7 @@ function mapBorder2(edge, themePalette) {
20336
20358
  return `${widthMap[edge.style] ?? "1px"} ${styleMap[edge.style] ?? "solid"} ${color}`;
20337
20359
  }
20338
20360
  function paletteIsDark(palette) {
20339
- return palette.surface === DARK_PALETTE.surface;
20361
+ return isDarkViewerPalette(palette);
20340
20362
  }
20341
20363
  function parseHexColor3(color) {
20342
20364
  const normalized = color.trim().toLowerCase();
@@ -22662,7 +22684,7 @@ function GridRow({
22662
22684
  borderRight: "none",
22663
22685
  boxSizing: "border-box",
22664
22686
  boxShadow: gutterSeparatorShadow,
22665
- color: palette.mutedText,
22687
+ color: palette.headerText,
22666
22688
  fontSize: scaleCssLengthExpression("11px", zoomFactor),
22667
22689
  height: rowHeight,
22668
22690
  left: 0,
@@ -28062,7 +28084,7 @@ function XlsxGrid({
28062
28084
  paneContext.lineTo(column.localLeft + column.width, column.height - 0.5);
28063
28085
  paneContext.stroke();
28064
28086
  paneContext.font = `600 ${11 * zoomFactor}px ui-sans-serif, system-ui, sans-serif`;
28065
- paneContext.fillStyle = palette.mutedText;
28087
+ paneContext.fillStyle = palette.headerText;
28066
28088
  paneContext.textAlign = "center";
28067
28089
  paneContext.textBaseline = "middle";
28068
28090
  paneContext.fillText(
@@ -28110,7 +28132,7 @@ function XlsxGrid({
28110
28132
  paneContext.lineTo(rowHeaderWidth - 0.5, row.localTop + row.height);
28111
28133
  paneContext.stroke();
28112
28134
  paneContext.font = `600 ${11 * zoomFactor}px ui-sans-serif, system-ui, sans-serif`;
28113
- paneContext.fillStyle = palette.mutedText;
28135
+ paneContext.fillStyle = palette.headerText;
28114
28136
  paneContext.textAlign = "center";
28115
28137
  paneContext.textBaseline = "middle";
28116
28138
  paneContext.fillText(`${row.actualRow + 1}`, rowHeaderWidth / 2, row.localTop + row.height / 2);
@@ -28453,7 +28475,7 @@ function XlsxGrid({
28453
28475
  borderBottom: "none",
28454
28476
  borderRight: "none",
28455
28477
  boxShadow: gutterSeparatorShadow,
28456
- color: palette.mutedText,
28478
+ color: palette.headerText,
28457
28479
  fontSize: "11px",
28458
28480
  fontWeight: 600,
28459
28481
  height: HEADER_HEIGHT,
@@ -30717,6 +30739,8 @@ function XlsxViewerInner({
30717
30739
  experimentalCanvas = true,
30718
30740
  fileTooLargeState,
30719
30741
  getCellStyle,
30742
+ headerBackgroundColor,
30743
+ headerTextColor,
30720
30744
  height,
30721
30745
  isDark = false,
30722
30746
  loadingComponent,
@@ -30737,7 +30761,7 @@ function XlsxViewerInner({
30737
30761
  showDefaultToolbar = true,
30738
30762
  toolbar
30739
30763
  }) {
30740
- const palette = useViewerPalette(isDark);
30764
+ const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
30741
30765
  const { displayFileName, error } = controller;
30742
30766
  const customFileTooLarge = error instanceof XlsxFileSizeLimitExceededError ? renderCustomFileTooLarge(
30743
30767
  fileTooLargeState,
@@ -30748,7 +30772,7 @@ function XlsxViewerInner({
30748
30772
  },
30749
30773
  palette
30750
30774
  ) : void 0;
30751
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ViewerContext.Provider, { value: controller, children: customFileTooLarge !== void 0 ? customFileTooLarge : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
30775
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ViewerAppearanceContext.Provider, { value: { headerBackgroundColor, headerTextColor, isDark }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ViewerContext.Provider, { value: controller, children: customFileTooLarge !== void 0 ? customFileTooLarge : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
30752
30776
  "div",
30753
30777
  {
30754
30778
  className: classNames("react-xlsx-viewer", className),
@@ -31219,8 +31243,8 @@ function useXlsxViewerThumbnails(options = {}) {
31219
31243
  workbook,
31220
31244
  sheets
31221
31245
  } = useXlsxViewer();
31222
- const { isDark } = React4.useContext(ViewerAppearanceContext);
31223
- const palette = useViewerPalette(isDark);
31246
+ const { headerBackgroundColor, headerTextColor, isDark } = React4.useContext(ViewerAppearanceContext);
31247
+ const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
31224
31248
  const includeHeaders = options.includeHeaders ?? true;
31225
31249
  const resolution = options.resolution;
31226
31250
  const thumbnailImageCacheRef = React4.useRef(/* @__PURE__ */ new Map());
@@ -31832,7 +31856,7 @@ function useXlsxViewerThumbnails(options = {}) {
31832
31856
  context.strokeStyle = palette.border;
31833
31857
  context.lineWidth = 1;
31834
31858
  context.font = "600 11px ui-sans-serif, system-ui, sans-serif";
31835
- context.fillStyle = palette.mutedText;
31859
+ context.fillStyle = palette.headerText;
31836
31860
  context.textBaseline = "middle";
31837
31861
  for (const colItem of colAxis.items) {
31838
31862
  const left = rowHeaderWidth + colItem.start;
@@ -31919,8 +31943,8 @@ function XlsxViewer(props) {
31919
31943
  }
31920
31944
  function DefaultXlsxToolbar() {
31921
31945
  const controller = useXlsxViewer();
31922
- const { isDark } = React4.useContext(ViewerAppearanceContext);
31923
- const palette = useViewerPalette(isDark);
31946
+ const { headerBackgroundColor, headerTextColor, isDark } = React4.useContext(ViewerAppearanceContext);
31947
+ const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
31924
31948
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DefaultToolbar, { controller, palette });
31925
31949
  }
31926
31950
  // Annotate the CommonJS export names for ESM import in node: