@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/dist/index.d.cts CHANGED
@@ -1495,6 +1495,10 @@ interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
1495
1495
  * ```
1496
1496
  */
1497
1497
  getCellStyle?: (context: XlsxCellStyleContext) => React.CSSProperties | null | undefined;
1498
+ /** Background color used for row-number, column-letter, and corner headers. */
1499
+ headerBackgroundColor?: string;
1500
+ /** Text color used for row-number and column-letter headers. */
1501
+ headerTextColor?: string;
1498
1502
  /**
1499
1503
  * CSS height for the viewer container.
1500
1504
  *
package/dist/index.d.ts CHANGED
@@ -1495,6 +1495,10 @@ interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
1495
1495
  * ```
1496
1496
  */
1497
1497
  getCellStyle?: (context: XlsxCellStyleContext) => React.CSSProperties | null | undefined;
1498
+ /** Background color used for row-number, column-letter, and corner headers. */
1499
+ headerBackgroundColor?: string;
1500
+ /** Text color used for row-number and column-letter headers. */
1501
+ headerTextColor?: string;
1498
1502
  /**
1499
1503
  * CSS height for the viewer container.
1500
1504
  *
package/dist/index.js CHANGED
@@ -17800,6 +17800,67 @@ var MemoChartSvg = React3.memo(function MemoChartSvg2({
17800
17800
  );
17801
17801
  }, (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);
17802
17802
 
17803
+ // src/viewer-palette.ts
17804
+ var LIGHT_PALETTE = {
17805
+ border: "#e4e4e7",
17806
+ buttonSurface: "#ffffff",
17807
+ buttonText: "#18181b",
17808
+ canvas: "#fafafa",
17809
+ danger: "#dc2626",
17810
+ headerSurface: "#f4f4f5",
17811
+ headerText: "#71717a",
17812
+ mutedSurface: "#f5f5f5",
17813
+ mutedText: "#71717a",
17814
+ rowHeaderSurface: "#f4f4f5",
17815
+ shadow: "0 1px 2px rgba(0, 0, 0, 0.04)",
17816
+ sheetActiveSurface: "#ffffff",
17817
+ sheetActiveText: "#18181b",
17818
+ sheetInactiveSurface: "#e4e4e7",
17819
+ sheetInactiveText: "#52525b",
17820
+ strongBorder: "#d4d4d8",
17821
+ subtleSurface: "#fafafa",
17822
+ surface: "#ffffff",
17823
+ text: "#18181b",
17824
+ toolbarSurface: "#f5f5f5"
17825
+ };
17826
+ var DARK_PALETTE = {
17827
+ border: "rgba(255, 255, 255, 0.10)",
17828
+ buttonSurface: "rgba(255, 255, 255, 0.06)",
17829
+ buttonText: "#f4f4f5",
17830
+ canvas: "#09090b",
17831
+ danger: "#f87171",
17832
+ headerSurface: "#18181b",
17833
+ headerText: "#a1a1aa",
17834
+ mutedSurface: "#111113",
17835
+ mutedText: "#a1a1aa",
17836
+ rowHeaderSurface: "#18181b",
17837
+ shadow: "0 1px 2px rgba(0, 0, 0, 0.28)",
17838
+ sheetActiveSurface: "#27272a",
17839
+ sheetActiveText: "#fafafa",
17840
+ sheetInactiveSurface: "#18181b",
17841
+ sheetInactiveText: "#a1a1aa",
17842
+ strongBorder: "rgba(255, 255, 255, 0.16)",
17843
+ subtleSurface: "#101012",
17844
+ surface: "#111113",
17845
+ text: "#f4f4f5",
17846
+ toolbarSurface: "#101012"
17847
+ };
17848
+ function isDarkViewerPalette(palette) {
17849
+ return palette.surface === DARK_PALETTE.surface;
17850
+ }
17851
+ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
17852
+ const basePalette = isDark ? DARK_PALETTE : LIGHT_PALETTE;
17853
+ if (headerBackgroundColor === void 0 && headerTextColor === void 0) {
17854
+ return basePalette;
17855
+ }
17856
+ return {
17857
+ ...basePalette,
17858
+ headerSurface: headerBackgroundColor ?? basePalette.headerSurface,
17859
+ headerText: headerTextColor ?? basePalette.headerText,
17860
+ rowHeaderSurface: headerBackgroundColor ?? basePalette.rowHeaderSurface
17861
+ };
17862
+ }
17863
+
17803
17864
  // src/XlsxViewer.tsx
17804
17865
  import { Fragment as Fragment4, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
17805
17866
  var DEFAULT_ROW_HEIGHT2 = 24;
@@ -18557,48 +18618,6 @@ function resolveEventAnchor(clientX, clientY, rect) {
18557
18618
  function resolveTouchDistance(firstTouch, secondTouch) {
18558
18619
  return Math.hypot(firstTouch.clientX - secondTouch.clientX, firstTouch.clientY - secondTouch.clientY);
18559
18620
  }
18560
- var LIGHT_PALETTE = {
18561
- border: "#e4e4e7",
18562
- buttonSurface: "#ffffff",
18563
- buttonText: "#18181b",
18564
- canvas: "#fafafa",
18565
- danger: "#dc2626",
18566
- headerSurface: "#f4f4f5",
18567
- mutedSurface: "#f5f5f5",
18568
- mutedText: "#71717a",
18569
- rowHeaderSurface: "#f4f4f5",
18570
- shadow: "0 1px 2px rgba(0, 0, 0, 0.04)",
18571
- sheetActiveSurface: "#ffffff",
18572
- sheetActiveText: "#18181b",
18573
- sheetInactiveSurface: "#e4e4e7",
18574
- sheetInactiveText: "#52525b",
18575
- strongBorder: "#d4d4d8",
18576
- subtleSurface: "#fafafa",
18577
- surface: "#ffffff",
18578
- text: "#18181b",
18579
- toolbarSurface: "#f5f5f5"
18580
- };
18581
- var DARK_PALETTE = {
18582
- border: "rgba(255, 255, 255, 0.10)",
18583
- buttonSurface: "rgba(255, 255, 255, 0.06)",
18584
- buttonText: "#f4f4f5",
18585
- canvas: "#09090b",
18586
- danger: "#f87171",
18587
- headerSurface: "#18181b",
18588
- mutedSurface: "#111113",
18589
- mutedText: "#a1a1aa",
18590
- rowHeaderSurface: "#18181b",
18591
- shadow: "0 1px 2px rgba(0, 0, 0, 0.28)",
18592
- sheetActiveSurface: "#27272a",
18593
- sheetActiveText: "#fafafa",
18594
- sheetInactiveSurface: "#18181b",
18595
- sheetInactiveText: "#a1a1aa",
18596
- strongBorder: "rgba(255, 255, 255, 0.16)",
18597
- subtleSurface: "#101012",
18598
- surface: "#111113",
18599
- text: "#f4f4f5",
18600
- toolbarSurface: "#101012"
18601
- };
18602
18621
  function parseRgbColor3(color) {
18603
18622
  const match = /^#?([0-9a-f]{6})$/i.exec(color);
18604
18623
  if (!match) {
@@ -20053,8 +20072,11 @@ function resolveImageHandleStyle(position, stroke, surface, scale = 1) {
20053
20072
  }
20054
20073
  return style;
20055
20074
  }
20056
- function useViewerPalette(isDark = false) {
20057
- return isDark ? DARK_PALETTE : LIGHT_PALETTE;
20075
+ function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
20076
+ return React4.useMemo(
20077
+ () => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
20078
+ [headerBackgroundColor, headerTextColor, isDark]
20079
+ );
20058
20080
  }
20059
20081
  function normalizeThumbnailResolution(resolution) {
20060
20082
  if (typeof resolution === "number" && Number.isFinite(resolution) && resolution > 0) {
@@ -20302,7 +20324,7 @@ function mapBorder2(edge, themePalette) {
20302
20324
  return `${widthMap[edge.style] ?? "1px"} ${styleMap[edge.style] ?? "solid"} ${color}`;
20303
20325
  }
20304
20326
  function paletteIsDark(palette) {
20305
- return palette.surface === DARK_PALETTE.surface;
20327
+ return isDarkViewerPalette(palette);
20306
20328
  }
20307
20329
  function parseHexColor3(color) {
20308
20330
  const normalized = color.trim().toLowerCase();
@@ -22628,7 +22650,7 @@ function GridRow({
22628
22650
  borderRight: "none",
22629
22651
  boxSizing: "border-box",
22630
22652
  boxShadow: gutterSeparatorShadow,
22631
- color: palette.mutedText,
22653
+ color: palette.headerText,
22632
22654
  fontSize: scaleCssLengthExpression("11px", zoomFactor),
22633
22655
  height: rowHeight,
22634
22656
  left: 0,
@@ -28028,7 +28050,7 @@ function XlsxGrid({
28028
28050
  paneContext.lineTo(column.localLeft + column.width, column.height - 0.5);
28029
28051
  paneContext.stroke();
28030
28052
  paneContext.font = `600 ${11 * zoomFactor}px ui-sans-serif, system-ui, sans-serif`;
28031
- paneContext.fillStyle = palette.mutedText;
28053
+ paneContext.fillStyle = palette.headerText;
28032
28054
  paneContext.textAlign = "center";
28033
28055
  paneContext.textBaseline = "middle";
28034
28056
  paneContext.fillText(
@@ -28076,7 +28098,7 @@ function XlsxGrid({
28076
28098
  paneContext.lineTo(rowHeaderWidth - 0.5, row.localTop + row.height);
28077
28099
  paneContext.stroke();
28078
28100
  paneContext.font = `600 ${11 * zoomFactor}px ui-sans-serif, system-ui, sans-serif`;
28079
- paneContext.fillStyle = palette.mutedText;
28101
+ paneContext.fillStyle = palette.headerText;
28080
28102
  paneContext.textAlign = "center";
28081
28103
  paneContext.textBaseline = "middle";
28082
28104
  paneContext.fillText(`${row.actualRow + 1}`, rowHeaderWidth / 2, row.localTop + row.height / 2);
@@ -28419,7 +28441,7 @@ function XlsxGrid({
28419
28441
  borderBottom: "none",
28420
28442
  borderRight: "none",
28421
28443
  boxShadow: gutterSeparatorShadow,
28422
- color: palette.mutedText,
28444
+ color: palette.headerText,
28423
28445
  fontSize: "11px",
28424
28446
  fontWeight: 600,
28425
28447
  height: HEADER_HEIGHT,
@@ -30683,6 +30705,8 @@ function XlsxViewerInner({
30683
30705
  experimentalCanvas = true,
30684
30706
  fileTooLargeState,
30685
30707
  getCellStyle,
30708
+ headerBackgroundColor,
30709
+ headerTextColor,
30686
30710
  height,
30687
30711
  isDark = false,
30688
30712
  loadingComponent,
@@ -30703,7 +30727,7 @@ function XlsxViewerInner({
30703
30727
  showDefaultToolbar = true,
30704
30728
  toolbar
30705
30729
  }) {
30706
- const palette = useViewerPalette(isDark);
30730
+ const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
30707
30731
  const { displayFileName, error } = controller;
30708
30732
  const customFileTooLarge = error instanceof XlsxFileSizeLimitExceededError ? renderCustomFileTooLarge(
30709
30733
  fileTooLargeState,
@@ -30714,7 +30738,7 @@ function XlsxViewerInner({
30714
30738
  },
30715
30739
  palette
30716
30740
  ) : void 0;
30717
- return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children: customFileTooLarge !== void 0 ? customFileTooLarge : /* @__PURE__ */ jsxs3(
30741
+ return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { headerBackgroundColor, headerTextColor, isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children: customFileTooLarge !== void 0 ? customFileTooLarge : /* @__PURE__ */ jsxs3(
30718
30742
  "div",
30719
30743
  {
30720
30744
  className: classNames("react-xlsx-viewer", className),
@@ -31185,8 +31209,8 @@ function useXlsxViewerThumbnails(options = {}) {
31185
31209
  workbook,
31186
31210
  sheets
31187
31211
  } = useXlsxViewer();
31188
- const { isDark } = React4.useContext(ViewerAppearanceContext);
31189
- const palette = useViewerPalette(isDark);
31212
+ const { headerBackgroundColor, headerTextColor, isDark } = React4.useContext(ViewerAppearanceContext);
31213
+ const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
31190
31214
  const includeHeaders = options.includeHeaders ?? true;
31191
31215
  const resolution = options.resolution;
31192
31216
  const thumbnailImageCacheRef = React4.useRef(/* @__PURE__ */ new Map());
@@ -31798,7 +31822,7 @@ function useXlsxViewerThumbnails(options = {}) {
31798
31822
  context.strokeStyle = palette.border;
31799
31823
  context.lineWidth = 1;
31800
31824
  context.font = "600 11px ui-sans-serif, system-ui, sans-serif";
31801
- context.fillStyle = palette.mutedText;
31825
+ context.fillStyle = palette.headerText;
31802
31826
  context.textBaseline = "middle";
31803
31827
  for (const colItem of colAxis.items) {
31804
31828
  const left = rowHeaderWidth + colItem.start;
@@ -31885,8 +31909,8 @@ function XlsxViewer(props) {
31885
31909
  }
31886
31910
  function DefaultXlsxToolbar() {
31887
31911
  const controller = useXlsxViewer();
31888
- const { isDark } = React4.useContext(ViewerAppearanceContext);
31889
- const palette = useViewerPalette(isDark);
31912
+ const { headerBackgroundColor, headerTextColor, isDark } = React4.useContext(ViewerAppearanceContext);
31913
+ const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
31890
31914
  return /* @__PURE__ */ jsx3(DefaultToolbar, { controller, palette });
31891
31915
  }
31892
31916
  export {