@extend-ai/react-xlsx 0.15.0 → 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 +2 -0
- package/dist/index.cjs +279 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +279 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
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
|
@@ -6750,6 +6750,204 @@ function cloneArrayBufferForTransfer(buffer) {
|
|
|
6750
6750
|
return buffer.slice(0);
|
|
6751
6751
|
}
|
|
6752
6752
|
|
|
6753
|
+
// src/zip-entry-names.ts
|
|
6754
|
+
var BACKSLASH_BYTE = 92;
|
|
6755
|
+
var FORWARD_SLASH_BYTE = 47;
|
|
6756
|
+
var END_OF_CENTRAL_DIRECTORY_SIGNATURE = 101010256;
|
|
6757
|
+
var CENTRAL_FILE_HEADER_SIGNATURE = 33639248;
|
|
6758
|
+
var LOCAL_FILE_HEADER_SIGNATURE = 67324752;
|
|
6759
|
+
var END_OF_CENTRAL_DIRECTORY_LENGTH = 22;
|
|
6760
|
+
var CENTRAL_FILE_HEADER_LENGTH = 46;
|
|
6761
|
+
var LOCAL_FILE_HEADER_LENGTH = 30;
|
|
6762
|
+
var MAX_ZIP_COMMENT_LENGTH = 65535;
|
|
6763
|
+
var ZIP16_SENTINEL = 65535;
|
|
6764
|
+
var ZIP32_SENTINEL = 4294967295;
|
|
6765
|
+
function findEndOfCentralDirectoryOffset(view) {
|
|
6766
|
+
const firstPossibleOffset = Math.max(
|
|
6767
|
+
0,
|
|
6768
|
+
view.byteLength - END_OF_CENTRAL_DIRECTORY_LENGTH - MAX_ZIP_COMMENT_LENGTH
|
|
6769
|
+
);
|
|
6770
|
+
for (let offset = view.byteLength - END_OF_CENTRAL_DIRECTORY_LENGTH; offset >= firstPossibleOffset; offset -= 1) {
|
|
6771
|
+
if (view.getUint32(offset, true) !== END_OF_CENTRAL_DIRECTORY_SIGNATURE) {
|
|
6772
|
+
continue;
|
|
6773
|
+
}
|
|
6774
|
+
const commentLength = view.getUint16(offset + 20, true);
|
|
6775
|
+
if (offset + END_OF_CENTRAL_DIRECTORY_LENGTH + commentLength === view.byteLength) {
|
|
6776
|
+
return offset;
|
|
6777
|
+
}
|
|
6778
|
+
}
|
|
6779
|
+
return null;
|
|
6780
|
+
}
|
|
6781
|
+
function readCentralDirectoryInfo(view) {
|
|
6782
|
+
if (view.byteLength < END_OF_CENTRAL_DIRECTORY_LENGTH) {
|
|
6783
|
+
return null;
|
|
6784
|
+
}
|
|
6785
|
+
const endOfCentralDirectoryOffset = findEndOfCentralDirectoryOffset(view);
|
|
6786
|
+
if (endOfCentralDirectoryOffset === null) {
|
|
6787
|
+
return null;
|
|
6788
|
+
}
|
|
6789
|
+
const diskNumber = view.getUint16(endOfCentralDirectoryOffset + 4, true);
|
|
6790
|
+
const centralDirectoryDiskNumber = view.getUint16(endOfCentralDirectoryOffset + 6, true);
|
|
6791
|
+
const entriesOnDisk = view.getUint16(endOfCentralDirectoryOffset + 8, true);
|
|
6792
|
+
const entryCount = view.getUint16(endOfCentralDirectoryOffset + 10, true);
|
|
6793
|
+
const centralDirectorySize = view.getUint32(endOfCentralDirectoryOffset + 12, true);
|
|
6794
|
+
const centralDirectoryOffset = view.getUint32(endOfCentralDirectoryOffset + 16, true);
|
|
6795
|
+
if (diskNumber !== 0 || centralDirectoryDiskNumber !== 0 || entriesOnDisk !== entryCount || entryCount === ZIP16_SENTINEL || centralDirectorySize === ZIP32_SENTINEL || centralDirectoryOffset === ZIP32_SENTINEL) {
|
|
6796
|
+
return null;
|
|
6797
|
+
}
|
|
6798
|
+
const centralDirectoryEndOffset = centralDirectoryOffset + centralDirectorySize;
|
|
6799
|
+
if (centralDirectoryOffset > endOfCentralDirectoryOffset || centralDirectoryEndOffset > endOfCentralDirectoryOffset || centralDirectoryEndOffset > view.byteLength) {
|
|
6800
|
+
return null;
|
|
6801
|
+
}
|
|
6802
|
+
return {
|
|
6803
|
+
endOffset: centralDirectoryEndOffset,
|
|
6804
|
+
entryCount,
|
|
6805
|
+
offset: centralDirectoryOffset
|
|
6806
|
+
};
|
|
6807
|
+
}
|
|
6808
|
+
function readCentralDirectoryEntry(view, centralDirectoryEndOffset, offset) {
|
|
6809
|
+
if (offset < 0 || offset + CENTRAL_FILE_HEADER_LENGTH > centralDirectoryEndOffset || offset + CENTRAL_FILE_HEADER_LENGTH > view.byteLength || view.getUint32(offset, true) !== CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
6810
|
+
return null;
|
|
6811
|
+
}
|
|
6812
|
+
const nameLength = view.getUint16(offset + 28, true);
|
|
6813
|
+
const extraLength = view.getUint16(offset + 30, true);
|
|
6814
|
+
const commentLength = view.getUint16(offset + 32, true);
|
|
6815
|
+
const nameStart = offset + CENTRAL_FILE_HEADER_LENGTH;
|
|
6816
|
+
const nameEnd = nameStart + nameLength;
|
|
6817
|
+
const nextOffset = nameEnd + extraLength + commentLength;
|
|
6818
|
+
if (nameEnd > centralDirectoryEndOffset || nextOffset > centralDirectoryEndOffset) {
|
|
6819
|
+
return null;
|
|
6820
|
+
}
|
|
6821
|
+
return {
|
|
6822
|
+
diskNumberStart: view.getUint16(offset + 34, true),
|
|
6823
|
+
localHeaderOffset: view.getUint32(offset + 42, true),
|
|
6824
|
+
nameEnd,
|
|
6825
|
+
nameStart,
|
|
6826
|
+
nextOffset
|
|
6827
|
+
};
|
|
6828
|
+
}
|
|
6829
|
+
function entryNameUsesBackslash(bytes, entry) {
|
|
6830
|
+
for (let cursor = entry.nameStart; cursor < entry.nameEnd; cursor += 1) {
|
|
6831
|
+
if (bytes[cursor] === BACKSLASH_BYTE) {
|
|
6832
|
+
return true;
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
6835
|
+
return false;
|
|
6836
|
+
}
|
|
6837
|
+
function centralDirectoryUsesBackslashSeparators(bytes, view, centralDirectory) {
|
|
6838
|
+
let offset = centralDirectory.offset;
|
|
6839
|
+
for (let index = 0; index < centralDirectory.entryCount; index += 1) {
|
|
6840
|
+
const entry = readCentralDirectoryEntry(view, centralDirectory.endOffset, offset);
|
|
6841
|
+
if (!entry) {
|
|
6842
|
+
return null;
|
|
6843
|
+
}
|
|
6844
|
+
if (entryNameUsesBackslash(bytes, entry)) {
|
|
6845
|
+
return true;
|
|
6846
|
+
}
|
|
6847
|
+
offset = entry.nextOffset;
|
|
6848
|
+
}
|
|
6849
|
+
return false;
|
|
6850
|
+
}
|
|
6851
|
+
function normalizedEntryNameKey(bytes, entry) {
|
|
6852
|
+
let key = "";
|
|
6853
|
+
for (let cursor = entry.nameStart; cursor < entry.nameEnd; cursor += 1) {
|
|
6854
|
+
const byte = bytes[cursor] === BACKSLASH_BYTE ? FORWARD_SLASH_BYTE : bytes[cursor];
|
|
6855
|
+
key += String.fromCharCode(byte);
|
|
6856
|
+
}
|
|
6857
|
+
return key;
|
|
6858
|
+
}
|
|
6859
|
+
function validateEntryNamePatches(bytes, view, centralDirectory) {
|
|
6860
|
+
const normalizedNames = /* @__PURE__ */ new Set();
|
|
6861
|
+
const localHeaderOffsets = /* @__PURE__ */ new Set();
|
|
6862
|
+
let offset = centralDirectory.offset;
|
|
6863
|
+
for (let index = 0; index < centralDirectory.entryCount; index += 1) {
|
|
6864
|
+
const entry = readCentralDirectoryEntry(view, centralDirectory.endOffset, offset);
|
|
6865
|
+
if (!entry || entry.diskNumberStart !== 0 || entry.localHeaderOffset === ZIP32_SENTINEL || entry.localHeaderOffset + LOCAL_FILE_HEADER_LENGTH > centralDirectory.offset || localHeaderOffsets.has(entry.localHeaderOffset)) {
|
|
6866
|
+
return false;
|
|
6867
|
+
}
|
|
6868
|
+
localHeaderOffsets.add(entry.localHeaderOffset);
|
|
6869
|
+
const normalizedName = normalizedEntryNameKey(bytes, entry);
|
|
6870
|
+
if (normalizedNames.has(normalizedName)) {
|
|
6871
|
+
return false;
|
|
6872
|
+
}
|
|
6873
|
+
normalizedNames.add(normalizedName);
|
|
6874
|
+
if (!entryNameUsesBackslash(bytes, entry)) {
|
|
6875
|
+
offset = entry.nextOffset;
|
|
6876
|
+
continue;
|
|
6877
|
+
}
|
|
6878
|
+
if (view.getUint32(entry.localHeaderOffset, true) !== LOCAL_FILE_HEADER_SIGNATURE) {
|
|
6879
|
+
return false;
|
|
6880
|
+
}
|
|
6881
|
+
const localNameLength = view.getUint16(entry.localHeaderOffset + 26, true);
|
|
6882
|
+
const localNameStart = entry.localHeaderOffset + LOCAL_FILE_HEADER_LENGTH;
|
|
6883
|
+
const localNameEnd = localNameStart + localNameLength;
|
|
6884
|
+
if (localNameLength !== entry.nameEnd - entry.nameStart || localNameEnd > centralDirectory.offset) {
|
|
6885
|
+
return false;
|
|
6886
|
+
}
|
|
6887
|
+
for (let nameIndex = 0; nameIndex < localNameLength; nameIndex += 1) {
|
|
6888
|
+
const centralNameOffset = entry.nameStart + nameIndex;
|
|
6889
|
+
const localNameOffset = localNameStart + nameIndex;
|
|
6890
|
+
if (bytes[centralNameOffset] !== bytes[localNameOffset]) {
|
|
6891
|
+
return false;
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6894
|
+
offset = entry.nextOffset;
|
|
6895
|
+
}
|
|
6896
|
+
return true;
|
|
6897
|
+
}
|
|
6898
|
+
function patchEntryNameSeparators(bytes, view, centralDirectory) {
|
|
6899
|
+
let offset = centralDirectory.offset;
|
|
6900
|
+
for (let index = 0; index < centralDirectory.entryCount; index += 1) {
|
|
6901
|
+
const entry = readCentralDirectoryEntry(view, centralDirectory.endOffset, offset);
|
|
6902
|
+
if (!entry) {
|
|
6903
|
+
return;
|
|
6904
|
+
}
|
|
6905
|
+
if (entryNameUsesBackslash(bytes, entry)) {
|
|
6906
|
+
const localNameStart = entry.localHeaderOffset + LOCAL_FILE_HEADER_LENGTH;
|
|
6907
|
+
for (let nameIndex = 0; nameIndex < entry.nameEnd - entry.nameStart; nameIndex += 1) {
|
|
6908
|
+
const centralNameOffset = entry.nameStart + nameIndex;
|
|
6909
|
+
if (bytes[centralNameOffset] === BACKSLASH_BYTE) {
|
|
6910
|
+
bytes[centralNameOffset] = FORWARD_SLASH_BYTE;
|
|
6911
|
+
bytes[localNameStart + nameIndex] = FORWARD_SLASH_BYTE;
|
|
6912
|
+
}
|
|
6913
|
+
}
|
|
6914
|
+
}
|
|
6915
|
+
offset = entry.nextOffset;
|
|
6916
|
+
}
|
|
6917
|
+
}
|
|
6918
|
+
function normalizeZipEntryNames(bytes) {
|
|
6919
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
6920
|
+
const centralDirectory = readCentralDirectoryInfo(view);
|
|
6921
|
+
if (!centralDirectory || centralDirectoryUsesBackslashSeparators(bytes, view, centralDirectory) !== true) {
|
|
6922
|
+
return bytes;
|
|
6923
|
+
}
|
|
6924
|
+
if (!validateEntryNamePatches(bytes, view, centralDirectory)) {
|
|
6925
|
+
return bytes;
|
|
6926
|
+
}
|
|
6927
|
+
const normalizedBytes = new Uint8Array(bytes.byteLength);
|
|
6928
|
+
normalizedBytes.set(bytes);
|
|
6929
|
+
const normalizedView = new DataView(
|
|
6930
|
+
normalizedBytes.buffer,
|
|
6931
|
+
normalizedBytes.byteOffset,
|
|
6932
|
+
normalizedBytes.byteLength
|
|
6933
|
+
);
|
|
6934
|
+
patchEntryNameSeparators(normalizedBytes, normalizedView, centralDirectory);
|
|
6935
|
+
return normalizedBytes;
|
|
6936
|
+
}
|
|
6937
|
+
function normalizeWorkbookArrayBuffer(buffer) {
|
|
6938
|
+
const bytes = new Uint8Array(buffer);
|
|
6939
|
+
const normalizedBytes = normalizeZipEntryNames(bytes);
|
|
6940
|
+
if (normalizedBytes === bytes) {
|
|
6941
|
+
return buffer;
|
|
6942
|
+
}
|
|
6943
|
+
if (normalizedBytes.byteOffset === 0 && normalizedBytes.byteLength === normalizedBytes.buffer.byteLength && normalizedBytes.buffer instanceof ArrayBuffer) {
|
|
6944
|
+
return normalizedBytes.buffer;
|
|
6945
|
+
}
|
|
6946
|
+
const normalizedBuffer = new ArrayBuffer(normalizedBytes.byteLength);
|
|
6947
|
+
new Uint8Array(normalizedBuffer).set(normalizedBytes);
|
|
6948
|
+
return normalizedBuffer;
|
|
6949
|
+
}
|
|
6950
|
+
|
|
6753
6951
|
// src/controller.tsx
|
|
6754
6952
|
var FORMULA_COUNT_THRESHOLD = 1e3;
|
|
6755
6953
|
var DEFAULT_ROW_HEIGHT = 24;
|
|
@@ -8393,6 +8591,7 @@ function useXlsxViewerController(options) {
|
|
|
8393
8591
|
if (maxFileSizeBytes > 0 && buffer.byteLength > maxFileSizeBytes) {
|
|
8394
8592
|
throw new XlsxFileSizeLimitExceededError(buffer.byteLength, maxFileSizeBytes);
|
|
8395
8593
|
}
|
|
8594
|
+
buffer = normalizeWorkbookArrayBuffer(buffer);
|
|
8396
8595
|
const preflight = preflightWorkbookBuffer(buffer);
|
|
8397
8596
|
if (preflight?.tooLarge) {
|
|
8398
8597
|
throw createWorkbookTooLargeError(preflight);
|
|
@@ -17601,6 +17800,67 @@ var MemoChartSvg = React3.memo(function MemoChartSvg2({
|
|
|
17601
17800
|
);
|
|
17602
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);
|
|
17603
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
|
+
|
|
17604
17864
|
// src/XlsxViewer.tsx
|
|
17605
17865
|
import { Fragment as Fragment4, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
17606
17866
|
var DEFAULT_ROW_HEIGHT2 = 24;
|
|
@@ -18358,48 +18618,6 @@ function resolveEventAnchor(clientX, clientY, rect) {
|
|
|
18358
18618
|
function resolveTouchDistance(firstTouch, secondTouch) {
|
|
18359
18619
|
return Math.hypot(firstTouch.clientX - secondTouch.clientX, firstTouch.clientY - secondTouch.clientY);
|
|
18360
18620
|
}
|
|
18361
|
-
var LIGHT_PALETTE = {
|
|
18362
|
-
border: "#e4e4e7",
|
|
18363
|
-
buttonSurface: "#ffffff",
|
|
18364
|
-
buttonText: "#18181b",
|
|
18365
|
-
canvas: "#fafafa",
|
|
18366
|
-
danger: "#dc2626",
|
|
18367
|
-
headerSurface: "#f4f4f5",
|
|
18368
|
-
mutedSurface: "#f5f5f5",
|
|
18369
|
-
mutedText: "#71717a",
|
|
18370
|
-
rowHeaderSurface: "#f4f4f5",
|
|
18371
|
-
shadow: "0 1px 2px rgba(0, 0, 0, 0.04)",
|
|
18372
|
-
sheetActiveSurface: "#ffffff",
|
|
18373
|
-
sheetActiveText: "#18181b",
|
|
18374
|
-
sheetInactiveSurface: "#e4e4e7",
|
|
18375
|
-
sheetInactiveText: "#52525b",
|
|
18376
|
-
strongBorder: "#d4d4d8",
|
|
18377
|
-
subtleSurface: "#fafafa",
|
|
18378
|
-
surface: "#ffffff",
|
|
18379
|
-
text: "#18181b",
|
|
18380
|
-
toolbarSurface: "#f5f5f5"
|
|
18381
|
-
};
|
|
18382
|
-
var DARK_PALETTE = {
|
|
18383
|
-
border: "rgba(255, 255, 255, 0.10)",
|
|
18384
|
-
buttonSurface: "rgba(255, 255, 255, 0.06)",
|
|
18385
|
-
buttonText: "#f4f4f5",
|
|
18386
|
-
canvas: "#09090b",
|
|
18387
|
-
danger: "#f87171",
|
|
18388
|
-
headerSurface: "#18181b",
|
|
18389
|
-
mutedSurface: "#111113",
|
|
18390
|
-
mutedText: "#a1a1aa",
|
|
18391
|
-
rowHeaderSurface: "#18181b",
|
|
18392
|
-
shadow: "0 1px 2px rgba(0, 0, 0, 0.28)",
|
|
18393
|
-
sheetActiveSurface: "#27272a",
|
|
18394
|
-
sheetActiveText: "#fafafa",
|
|
18395
|
-
sheetInactiveSurface: "#18181b",
|
|
18396
|
-
sheetInactiveText: "#a1a1aa",
|
|
18397
|
-
strongBorder: "rgba(255, 255, 255, 0.16)",
|
|
18398
|
-
subtleSurface: "#101012",
|
|
18399
|
-
surface: "#111113",
|
|
18400
|
-
text: "#f4f4f5",
|
|
18401
|
-
toolbarSurface: "#101012"
|
|
18402
|
-
};
|
|
18403
18621
|
function parseRgbColor3(color) {
|
|
18404
18622
|
const match = /^#?([0-9a-f]{6})$/i.exec(color);
|
|
18405
18623
|
if (!match) {
|
|
@@ -19854,8 +20072,11 @@ function resolveImageHandleStyle(position, stroke, surface, scale = 1) {
|
|
|
19854
20072
|
}
|
|
19855
20073
|
return style;
|
|
19856
20074
|
}
|
|
19857
|
-
function useViewerPalette(isDark = false) {
|
|
19858
|
-
return
|
|
20075
|
+
function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
|
|
20076
|
+
return React4.useMemo(
|
|
20077
|
+
() => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
|
|
20078
|
+
[headerBackgroundColor, headerTextColor, isDark]
|
|
20079
|
+
);
|
|
19859
20080
|
}
|
|
19860
20081
|
function normalizeThumbnailResolution(resolution) {
|
|
19861
20082
|
if (typeof resolution === "number" && Number.isFinite(resolution) && resolution > 0) {
|
|
@@ -20103,7 +20324,7 @@ function mapBorder2(edge, themePalette) {
|
|
|
20103
20324
|
return `${widthMap[edge.style] ?? "1px"} ${styleMap[edge.style] ?? "solid"} ${color}`;
|
|
20104
20325
|
}
|
|
20105
20326
|
function paletteIsDark(palette) {
|
|
20106
|
-
return palette
|
|
20327
|
+
return isDarkViewerPalette(palette);
|
|
20107
20328
|
}
|
|
20108
20329
|
function parseHexColor3(color) {
|
|
20109
20330
|
const normalized = color.trim().toLowerCase();
|
|
@@ -22429,7 +22650,7 @@ function GridRow({
|
|
|
22429
22650
|
borderRight: "none",
|
|
22430
22651
|
boxSizing: "border-box",
|
|
22431
22652
|
boxShadow: gutterSeparatorShadow,
|
|
22432
|
-
color: palette.
|
|
22653
|
+
color: palette.headerText,
|
|
22433
22654
|
fontSize: scaleCssLengthExpression("11px", zoomFactor),
|
|
22434
22655
|
height: rowHeight,
|
|
22435
22656
|
left: 0,
|
|
@@ -27829,7 +28050,7 @@ function XlsxGrid({
|
|
|
27829
28050
|
paneContext.lineTo(column.localLeft + column.width, column.height - 0.5);
|
|
27830
28051
|
paneContext.stroke();
|
|
27831
28052
|
paneContext.font = `600 ${11 * zoomFactor}px ui-sans-serif, system-ui, sans-serif`;
|
|
27832
|
-
paneContext.fillStyle = palette.
|
|
28053
|
+
paneContext.fillStyle = palette.headerText;
|
|
27833
28054
|
paneContext.textAlign = "center";
|
|
27834
28055
|
paneContext.textBaseline = "middle";
|
|
27835
28056
|
paneContext.fillText(
|
|
@@ -27877,7 +28098,7 @@ function XlsxGrid({
|
|
|
27877
28098
|
paneContext.lineTo(rowHeaderWidth - 0.5, row.localTop + row.height);
|
|
27878
28099
|
paneContext.stroke();
|
|
27879
28100
|
paneContext.font = `600 ${11 * zoomFactor}px ui-sans-serif, system-ui, sans-serif`;
|
|
27880
|
-
paneContext.fillStyle = palette.
|
|
28101
|
+
paneContext.fillStyle = palette.headerText;
|
|
27881
28102
|
paneContext.textAlign = "center";
|
|
27882
28103
|
paneContext.textBaseline = "middle";
|
|
27883
28104
|
paneContext.fillText(`${row.actualRow + 1}`, rowHeaderWidth / 2, row.localTop + row.height / 2);
|
|
@@ -28220,7 +28441,7 @@ function XlsxGrid({
|
|
|
28220
28441
|
borderBottom: "none",
|
|
28221
28442
|
borderRight: "none",
|
|
28222
28443
|
boxShadow: gutterSeparatorShadow,
|
|
28223
|
-
color: palette.
|
|
28444
|
+
color: palette.headerText,
|
|
28224
28445
|
fontSize: "11px",
|
|
28225
28446
|
fontWeight: 600,
|
|
28226
28447
|
height: HEADER_HEIGHT,
|
|
@@ -30484,6 +30705,8 @@ function XlsxViewerInner({
|
|
|
30484
30705
|
experimentalCanvas = true,
|
|
30485
30706
|
fileTooLargeState,
|
|
30486
30707
|
getCellStyle,
|
|
30708
|
+
headerBackgroundColor,
|
|
30709
|
+
headerTextColor,
|
|
30487
30710
|
height,
|
|
30488
30711
|
isDark = false,
|
|
30489
30712
|
loadingComponent,
|
|
@@ -30504,7 +30727,7 @@ function XlsxViewerInner({
|
|
|
30504
30727
|
showDefaultToolbar = true,
|
|
30505
30728
|
toolbar
|
|
30506
30729
|
}) {
|
|
30507
|
-
const palette = useViewerPalette(isDark);
|
|
30730
|
+
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
30508
30731
|
const { displayFileName, error } = controller;
|
|
30509
30732
|
const customFileTooLarge = error instanceof XlsxFileSizeLimitExceededError ? renderCustomFileTooLarge(
|
|
30510
30733
|
fileTooLargeState,
|
|
@@ -30515,7 +30738,7 @@ function XlsxViewerInner({
|
|
|
30515
30738
|
},
|
|
30516
30739
|
palette
|
|
30517
30740
|
) : void 0;
|
|
30518
|
-
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(
|
|
30519
30742
|
"div",
|
|
30520
30743
|
{
|
|
30521
30744
|
className: classNames("react-xlsx-viewer", className),
|
|
@@ -30986,8 +31209,8 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
30986
31209
|
workbook,
|
|
30987
31210
|
sheets
|
|
30988
31211
|
} = useXlsxViewer();
|
|
30989
|
-
const { isDark } = React4.useContext(ViewerAppearanceContext);
|
|
30990
|
-
const palette = useViewerPalette(isDark);
|
|
31212
|
+
const { headerBackgroundColor, headerTextColor, isDark } = React4.useContext(ViewerAppearanceContext);
|
|
31213
|
+
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
30991
31214
|
const includeHeaders = options.includeHeaders ?? true;
|
|
30992
31215
|
const resolution = options.resolution;
|
|
30993
31216
|
const thumbnailImageCacheRef = React4.useRef(/* @__PURE__ */ new Map());
|
|
@@ -31599,7 +31822,7 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
31599
31822
|
context.strokeStyle = palette.border;
|
|
31600
31823
|
context.lineWidth = 1;
|
|
31601
31824
|
context.font = "600 11px ui-sans-serif, system-ui, sans-serif";
|
|
31602
|
-
context.fillStyle = palette.
|
|
31825
|
+
context.fillStyle = palette.headerText;
|
|
31603
31826
|
context.textBaseline = "middle";
|
|
31604
31827
|
for (const colItem of colAxis.items) {
|
|
31605
31828
|
const left = rowHeaderWidth + colItem.start;
|
|
@@ -31686,8 +31909,8 @@ function XlsxViewer(props) {
|
|
|
31686
31909
|
}
|
|
31687
31910
|
function DefaultXlsxToolbar() {
|
|
31688
31911
|
const controller = useXlsxViewer();
|
|
31689
|
-
const { isDark } = React4.useContext(ViewerAppearanceContext);
|
|
31690
|
-
const palette = useViewerPalette(isDark);
|
|
31912
|
+
const { headerBackgroundColor, headerTextColor, isDark } = React4.useContext(ViewerAppearanceContext);
|
|
31913
|
+
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
31691
31914
|
return /* @__PURE__ */ jsx3(DefaultToolbar, { controller, palette });
|
|
31692
31915
|
}
|
|
31693
31916
|
export {
|