@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/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
|
@@ -6801,6 +6801,204 @@ function cloneArrayBufferForTransfer(buffer) {
|
|
|
6801
6801
|
return buffer.slice(0);
|
|
6802
6802
|
}
|
|
6803
6803
|
|
|
6804
|
+
// src/zip-entry-names.ts
|
|
6805
|
+
var BACKSLASH_BYTE = 92;
|
|
6806
|
+
var FORWARD_SLASH_BYTE = 47;
|
|
6807
|
+
var END_OF_CENTRAL_DIRECTORY_SIGNATURE = 101010256;
|
|
6808
|
+
var CENTRAL_FILE_HEADER_SIGNATURE = 33639248;
|
|
6809
|
+
var LOCAL_FILE_HEADER_SIGNATURE = 67324752;
|
|
6810
|
+
var END_OF_CENTRAL_DIRECTORY_LENGTH = 22;
|
|
6811
|
+
var CENTRAL_FILE_HEADER_LENGTH = 46;
|
|
6812
|
+
var LOCAL_FILE_HEADER_LENGTH = 30;
|
|
6813
|
+
var MAX_ZIP_COMMENT_LENGTH = 65535;
|
|
6814
|
+
var ZIP16_SENTINEL = 65535;
|
|
6815
|
+
var ZIP32_SENTINEL = 4294967295;
|
|
6816
|
+
function findEndOfCentralDirectoryOffset(view) {
|
|
6817
|
+
const firstPossibleOffset = Math.max(
|
|
6818
|
+
0,
|
|
6819
|
+
view.byteLength - END_OF_CENTRAL_DIRECTORY_LENGTH - MAX_ZIP_COMMENT_LENGTH
|
|
6820
|
+
);
|
|
6821
|
+
for (let offset = view.byteLength - END_OF_CENTRAL_DIRECTORY_LENGTH; offset >= firstPossibleOffset; offset -= 1) {
|
|
6822
|
+
if (view.getUint32(offset, true) !== END_OF_CENTRAL_DIRECTORY_SIGNATURE) {
|
|
6823
|
+
continue;
|
|
6824
|
+
}
|
|
6825
|
+
const commentLength = view.getUint16(offset + 20, true);
|
|
6826
|
+
if (offset + END_OF_CENTRAL_DIRECTORY_LENGTH + commentLength === view.byteLength) {
|
|
6827
|
+
return offset;
|
|
6828
|
+
}
|
|
6829
|
+
}
|
|
6830
|
+
return null;
|
|
6831
|
+
}
|
|
6832
|
+
function readCentralDirectoryInfo(view) {
|
|
6833
|
+
if (view.byteLength < END_OF_CENTRAL_DIRECTORY_LENGTH) {
|
|
6834
|
+
return null;
|
|
6835
|
+
}
|
|
6836
|
+
const endOfCentralDirectoryOffset = findEndOfCentralDirectoryOffset(view);
|
|
6837
|
+
if (endOfCentralDirectoryOffset === null) {
|
|
6838
|
+
return null;
|
|
6839
|
+
}
|
|
6840
|
+
const diskNumber = view.getUint16(endOfCentralDirectoryOffset + 4, true);
|
|
6841
|
+
const centralDirectoryDiskNumber = view.getUint16(endOfCentralDirectoryOffset + 6, true);
|
|
6842
|
+
const entriesOnDisk = view.getUint16(endOfCentralDirectoryOffset + 8, true);
|
|
6843
|
+
const entryCount = view.getUint16(endOfCentralDirectoryOffset + 10, true);
|
|
6844
|
+
const centralDirectorySize = view.getUint32(endOfCentralDirectoryOffset + 12, true);
|
|
6845
|
+
const centralDirectoryOffset = view.getUint32(endOfCentralDirectoryOffset + 16, true);
|
|
6846
|
+
if (diskNumber !== 0 || centralDirectoryDiskNumber !== 0 || entriesOnDisk !== entryCount || entryCount === ZIP16_SENTINEL || centralDirectorySize === ZIP32_SENTINEL || centralDirectoryOffset === ZIP32_SENTINEL) {
|
|
6847
|
+
return null;
|
|
6848
|
+
}
|
|
6849
|
+
const centralDirectoryEndOffset = centralDirectoryOffset + centralDirectorySize;
|
|
6850
|
+
if (centralDirectoryOffset > endOfCentralDirectoryOffset || centralDirectoryEndOffset > endOfCentralDirectoryOffset || centralDirectoryEndOffset > view.byteLength) {
|
|
6851
|
+
return null;
|
|
6852
|
+
}
|
|
6853
|
+
return {
|
|
6854
|
+
endOffset: centralDirectoryEndOffset,
|
|
6855
|
+
entryCount,
|
|
6856
|
+
offset: centralDirectoryOffset
|
|
6857
|
+
};
|
|
6858
|
+
}
|
|
6859
|
+
function readCentralDirectoryEntry(view, centralDirectoryEndOffset, offset) {
|
|
6860
|
+
if (offset < 0 || offset + CENTRAL_FILE_HEADER_LENGTH > centralDirectoryEndOffset || offset + CENTRAL_FILE_HEADER_LENGTH > view.byteLength || view.getUint32(offset, true) !== CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
6861
|
+
return null;
|
|
6862
|
+
}
|
|
6863
|
+
const nameLength = view.getUint16(offset + 28, true);
|
|
6864
|
+
const extraLength = view.getUint16(offset + 30, true);
|
|
6865
|
+
const commentLength = view.getUint16(offset + 32, true);
|
|
6866
|
+
const nameStart = offset + CENTRAL_FILE_HEADER_LENGTH;
|
|
6867
|
+
const nameEnd = nameStart + nameLength;
|
|
6868
|
+
const nextOffset = nameEnd + extraLength + commentLength;
|
|
6869
|
+
if (nameEnd > centralDirectoryEndOffset || nextOffset > centralDirectoryEndOffset) {
|
|
6870
|
+
return null;
|
|
6871
|
+
}
|
|
6872
|
+
return {
|
|
6873
|
+
diskNumberStart: view.getUint16(offset + 34, true),
|
|
6874
|
+
localHeaderOffset: view.getUint32(offset + 42, true),
|
|
6875
|
+
nameEnd,
|
|
6876
|
+
nameStart,
|
|
6877
|
+
nextOffset
|
|
6878
|
+
};
|
|
6879
|
+
}
|
|
6880
|
+
function entryNameUsesBackslash(bytes, entry) {
|
|
6881
|
+
for (let cursor = entry.nameStart; cursor < entry.nameEnd; cursor += 1) {
|
|
6882
|
+
if (bytes[cursor] === BACKSLASH_BYTE) {
|
|
6883
|
+
return true;
|
|
6884
|
+
}
|
|
6885
|
+
}
|
|
6886
|
+
return false;
|
|
6887
|
+
}
|
|
6888
|
+
function centralDirectoryUsesBackslashSeparators(bytes, view, centralDirectory) {
|
|
6889
|
+
let offset = centralDirectory.offset;
|
|
6890
|
+
for (let index = 0; index < centralDirectory.entryCount; index += 1) {
|
|
6891
|
+
const entry = readCentralDirectoryEntry(view, centralDirectory.endOffset, offset);
|
|
6892
|
+
if (!entry) {
|
|
6893
|
+
return null;
|
|
6894
|
+
}
|
|
6895
|
+
if (entryNameUsesBackslash(bytes, entry)) {
|
|
6896
|
+
return true;
|
|
6897
|
+
}
|
|
6898
|
+
offset = entry.nextOffset;
|
|
6899
|
+
}
|
|
6900
|
+
return false;
|
|
6901
|
+
}
|
|
6902
|
+
function normalizedEntryNameKey(bytes, entry) {
|
|
6903
|
+
let key = "";
|
|
6904
|
+
for (let cursor = entry.nameStart; cursor < entry.nameEnd; cursor += 1) {
|
|
6905
|
+
const byte = bytes[cursor] === BACKSLASH_BYTE ? FORWARD_SLASH_BYTE : bytes[cursor];
|
|
6906
|
+
key += String.fromCharCode(byte);
|
|
6907
|
+
}
|
|
6908
|
+
return key;
|
|
6909
|
+
}
|
|
6910
|
+
function validateEntryNamePatches(bytes, view, centralDirectory) {
|
|
6911
|
+
const normalizedNames = /* @__PURE__ */ new Set();
|
|
6912
|
+
const localHeaderOffsets = /* @__PURE__ */ new Set();
|
|
6913
|
+
let offset = centralDirectory.offset;
|
|
6914
|
+
for (let index = 0; index < centralDirectory.entryCount; index += 1) {
|
|
6915
|
+
const entry = readCentralDirectoryEntry(view, centralDirectory.endOffset, offset);
|
|
6916
|
+
if (!entry || entry.diskNumberStart !== 0 || entry.localHeaderOffset === ZIP32_SENTINEL || entry.localHeaderOffset + LOCAL_FILE_HEADER_LENGTH > centralDirectory.offset || localHeaderOffsets.has(entry.localHeaderOffset)) {
|
|
6917
|
+
return false;
|
|
6918
|
+
}
|
|
6919
|
+
localHeaderOffsets.add(entry.localHeaderOffset);
|
|
6920
|
+
const normalizedName = normalizedEntryNameKey(bytes, entry);
|
|
6921
|
+
if (normalizedNames.has(normalizedName)) {
|
|
6922
|
+
return false;
|
|
6923
|
+
}
|
|
6924
|
+
normalizedNames.add(normalizedName);
|
|
6925
|
+
if (!entryNameUsesBackslash(bytes, entry)) {
|
|
6926
|
+
offset = entry.nextOffset;
|
|
6927
|
+
continue;
|
|
6928
|
+
}
|
|
6929
|
+
if (view.getUint32(entry.localHeaderOffset, true) !== LOCAL_FILE_HEADER_SIGNATURE) {
|
|
6930
|
+
return false;
|
|
6931
|
+
}
|
|
6932
|
+
const localNameLength = view.getUint16(entry.localHeaderOffset + 26, true);
|
|
6933
|
+
const localNameStart = entry.localHeaderOffset + LOCAL_FILE_HEADER_LENGTH;
|
|
6934
|
+
const localNameEnd = localNameStart + localNameLength;
|
|
6935
|
+
if (localNameLength !== entry.nameEnd - entry.nameStart || localNameEnd > centralDirectory.offset) {
|
|
6936
|
+
return false;
|
|
6937
|
+
}
|
|
6938
|
+
for (let nameIndex = 0; nameIndex < localNameLength; nameIndex += 1) {
|
|
6939
|
+
const centralNameOffset = entry.nameStart + nameIndex;
|
|
6940
|
+
const localNameOffset = localNameStart + nameIndex;
|
|
6941
|
+
if (bytes[centralNameOffset] !== bytes[localNameOffset]) {
|
|
6942
|
+
return false;
|
|
6943
|
+
}
|
|
6944
|
+
}
|
|
6945
|
+
offset = entry.nextOffset;
|
|
6946
|
+
}
|
|
6947
|
+
return true;
|
|
6948
|
+
}
|
|
6949
|
+
function patchEntryNameSeparators(bytes, view, centralDirectory) {
|
|
6950
|
+
let offset = centralDirectory.offset;
|
|
6951
|
+
for (let index = 0; index < centralDirectory.entryCount; index += 1) {
|
|
6952
|
+
const entry = readCentralDirectoryEntry(view, centralDirectory.endOffset, offset);
|
|
6953
|
+
if (!entry) {
|
|
6954
|
+
return;
|
|
6955
|
+
}
|
|
6956
|
+
if (entryNameUsesBackslash(bytes, entry)) {
|
|
6957
|
+
const localNameStart = entry.localHeaderOffset + LOCAL_FILE_HEADER_LENGTH;
|
|
6958
|
+
for (let nameIndex = 0; nameIndex < entry.nameEnd - entry.nameStart; nameIndex += 1) {
|
|
6959
|
+
const centralNameOffset = entry.nameStart + nameIndex;
|
|
6960
|
+
if (bytes[centralNameOffset] === BACKSLASH_BYTE) {
|
|
6961
|
+
bytes[centralNameOffset] = FORWARD_SLASH_BYTE;
|
|
6962
|
+
bytes[localNameStart + nameIndex] = FORWARD_SLASH_BYTE;
|
|
6963
|
+
}
|
|
6964
|
+
}
|
|
6965
|
+
}
|
|
6966
|
+
offset = entry.nextOffset;
|
|
6967
|
+
}
|
|
6968
|
+
}
|
|
6969
|
+
function normalizeZipEntryNames(bytes) {
|
|
6970
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
6971
|
+
const centralDirectory = readCentralDirectoryInfo(view);
|
|
6972
|
+
if (!centralDirectory || centralDirectoryUsesBackslashSeparators(bytes, view, centralDirectory) !== true) {
|
|
6973
|
+
return bytes;
|
|
6974
|
+
}
|
|
6975
|
+
if (!validateEntryNamePatches(bytes, view, centralDirectory)) {
|
|
6976
|
+
return bytes;
|
|
6977
|
+
}
|
|
6978
|
+
const normalizedBytes = new Uint8Array(bytes.byteLength);
|
|
6979
|
+
normalizedBytes.set(bytes);
|
|
6980
|
+
const normalizedView = new DataView(
|
|
6981
|
+
normalizedBytes.buffer,
|
|
6982
|
+
normalizedBytes.byteOffset,
|
|
6983
|
+
normalizedBytes.byteLength
|
|
6984
|
+
);
|
|
6985
|
+
patchEntryNameSeparators(normalizedBytes, normalizedView, centralDirectory);
|
|
6986
|
+
return normalizedBytes;
|
|
6987
|
+
}
|
|
6988
|
+
function normalizeWorkbookArrayBuffer(buffer) {
|
|
6989
|
+
const bytes = new Uint8Array(buffer);
|
|
6990
|
+
const normalizedBytes = normalizeZipEntryNames(bytes);
|
|
6991
|
+
if (normalizedBytes === bytes) {
|
|
6992
|
+
return buffer;
|
|
6993
|
+
}
|
|
6994
|
+
if (normalizedBytes.byteOffset === 0 && normalizedBytes.byteLength === normalizedBytes.buffer.byteLength && normalizedBytes.buffer instanceof ArrayBuffer) {
|
|
6995
|
+
return normalizedBytes.buffer;
|
|
6996
|
+
}
|
|
6997
|
+
const normalizedBuffer = new ArrayBuffer(normalizedBytes.byteLength);
|
|
6998
|
+
new Uint8Array(normalizedBuffer).set(normalizedBytes);
|
|
6999
|
+
return normalizedBuffer;
|
|
7000
|
+
}
|
|
7001
|
+
|
|
6804
7002
|
// src/controller.tsx
|
|
6805
7003
|
var FORMULA_COUNT_THRESHOLD = 1e3;
|
|
6806
7004
|
var DEFAULT_ROW_HEIGHT = 24;
|
|
@@ -8444,6 +8642,7 @@ function useXlsxViewerController(options) {
|
|
|
8444
8642
|
if (maxFileSizeBytes > 0 && buffer.byteLength > maxFileSizeBytes) {
|
|
8445
8643
|
throw new XlsxFileSizeLimitExceededError(buffer.byteLength, maxFileSizeBytes);
|
|
8446
8644
|
}
|
|
8645
|
+
buffer = normalizeWorkbookArrayBuffer(buffer);
|
|
8447
8646
|
const preflight = preflightWorkbookBuffer(buffer);
|
|
8448
8647
|
if (preflight?.tooLarge) {
|
|
8449
8648
|
throw createWorkbookTooLargeError(preflight);
|
|
@@ -17635,6 +17834,67 @@ var MemoChartSvg = React3.memo(function MemoChartSvg2({
|
|
|
17635
17834
|
);
|
|
17636
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);
|
|
17637
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
|
+
|
|
17638
17898
|
// src/XlsxViewer.tsx
|
|
17639
17899
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
17640
17900
|
var DEFAULT_ROW_HEIGHT2 = 24;
|
|
@@ -18392,48 +18652,6 @@ function resolveEventAnchor(clientX, clientY, rect) {
|
|
|
18392
18652
|
function resolveTouchDistance(firstTouch, secondTouch) {
|
|
18393
18653
|
return Math.hypot(firstTouch.clientX - secondTouch.clientX, firstTouch.clientY - secondTouch.clientY);
|
|
18394
18654
|
}
|
|
18395
|
-
var LIGHT_PALETTE = {
|
|
18396
|
-
border: "#e4e4e7",
|
|
18397
|
-
buttonSurface: "#ffffff",
|
|
18398
|
-
buttonText: "#18181b",
|
|
18399
|
-
canvas: "#fafafa",
|
|
18400
|
-
danger: "#dc2626",
|
|
18401
|
-
headerSurface: "#f4f4f5",
|
|
18402
|
-
mutedSurface: "#f5f5f5",
|
|
18403
|
-
mutedText: "#71717a",
|
|
18404
|
-
rowHeaderSurface: "#f4f4f5",
|
|
18405
|
-
shadow: "0 1px 2px rgba(0, 0, 0, 0.04)",
|
|
18406
|
-
sheetActiveSurface: "#ffffff",
|
|
18407
|
-
sheetActiveText: "#18181b",
|
|
18408
|
-
sheetInactiveSurface: "#e4e4e7",
|
|
18409
|
-
sheetInactiveText: "#52525b",
|
|
18410
|
-
strongBorder: "#d4d4d8",
|
|
18411
|
-
subtleSurface: "#fafafa",
|
|
18412
|
-
surface: "#ffffff",
|
|
18413
|
-
text: "#18181b",
|
|
18414
|
-
toolbarSurface: "#f5f5f5"
|
|
18415
|
-
};
|
|
18416
|
-
var DARK_PALETTE = {
|
|
18417
|
-
border: "rgba(255, 255, 255, 0.10)",
|
|
18418
|
-
buttonSurface: "rgba(255, 255, 255, 0.06)",
|
|
18419
|
-
buttonText: "#f4f4f5",
|
|
18420
|
-
canvas: "#09090b",
|
|
18421
|
-
danger: "#f87171",
|
|
18422
|
-
headerSurface: "#18181b",
|
|
18423
|
-
mutedSurface: "#111113",
|
|
18424
|
-
mutedText: "#a1a1aa",
|
|
18425
|
-
rowHeaderSurface: "#18181b",
|
|
18426
|
-
shadow: "0 1px 2px rgba(0, 0, 0, 0.28)",
|
|
18427
|
-
sheetActiveSurface: "#27272a",
|
|
18428
|
-
sheetActiveText: "#fafafa",
|
|
18429
|
-
sheetInactiveSurface: "#18181b",
|
|
18430
|
-
sheetInactiveText: "#a1a1aa",
|
|
18431
|
-
strongBorder: "rgba(255, 255, 255, 0.16)",
|
|
18432
|
-
subtleSurface: "#101012",
|
|
18433
|
-
surface: "#111113",
|
|
18434
|
-
text: "#f4f4f5",
|
|
18435
|
-
toolbarSurface: "#101012"
|
|
18436
|
-
};
|
|
18437
18655
|
function parseRgbColor3(color) {
|
|
18438
18656
|
const match = /^#?([0-9a-f]{6})$/i.exec(color);
|
|
18439
18657
|
if (!match) {
|
|
@@ -19888,8 +20106,11 @@ function resolveImageHandleStyle(position, stroke, surface, scale = 1) {
|
|
|
19888
20106
|
}
|
|
19889
20107
|
return style;
|
|
19890
20108
|
}
|
|
19891
|
-
function useViewerPalette(isDark = false) {
|
|
19892
|
-
return
|
|
20109
|
+
function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
|
|
20110
|
+
return React4.useMemo(
|
|
20111
|
+
() => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
|
|
20112
|
+
[headerBackgroundColor, headerTextColor, isDark]
|
|
20113
|
+
);
|
|
19893
20114
|
}
|
|
19894
20115
|
function normalizeThumbnailResolution(resolution) {
|
|
19895
20116
|
if (typeof resolution === "number" && Number.isFinite(resolution) && resolution > 0) {
|
|
@@ -20137,7 +20358,7 @@ function mapBorder2(edge, themePalette) {
|
|
|
20137
20358
|
return `${widthMap[edge.style] ?? "1px"} ${styleMap[edge.style] ?? "solid"} ${color}`;
|
|
20138
20359
|
}
|
|
20139
20360
|
function paletteIsDark(palette) {
|
|
20140
|
-
return palette
|
|
20361
|
+
return isDarkViewerPalette(palette);
|
|
20141
20362
|
}
|
|
20142
20363
|
function parseHexColor3(color) {
|
|
20143
20364
|
const normalized = color.trim().toLowerCase();
|
|
@@ -22463,7 +22684,7 @@ function GridRow({
|
|
|
22463
22684
|
borderRight: "none",
|
|
22464
22685
|
boxSizing: "border-box",
|
|
22465
22686
|
boxShadow: gutterSeparatorShadow,
|
|
22466
|
-
color: palette.
|
|
22687
|
+
color: palette.headerText,
|
|
22467
22688
|
fontSize: scaleCssLengthExpression("11px", zoomFactor),
|
|
22468
22689
|
height: rowHeight,
|
|
22469
22690
|
left: 0,
|
|
@@ -27863,7 +28084,7 @@ function XlsxGrid({
|
|
|
27863
28084
|
paneContext.lineTo(column.localLeft + column.width, column.height - 0.5);
|
|
27864
28085
|
paneContext.stroke();
|
|
27865
28086
|
paneContext.font = `600 ${11 * zoomFactor}px ui-sans-serif, system-ui, sans-serif`;
|
|
27866
|
-
paneContext.fillStyle = palette.
|
|
28087
|
+
paneContext.fillStyle = palette.headerText;
|
|
27867
28088
|
paneContext.textAlign = "center";
|
|
27868
28089
|
paneContext.textBaseline = "middle";
|
|
27869
28090
|
paneContext.fillText(
|
|
@@ -27911,7 +28132,7 @@ function XlsxGrid({
|
|
|
27911
28132
|
paneContext.lineTo(rowHeaderWidth - 0.5, row.localTop + row.height);
|
|
27912
28133
|
paneContext.stroke();
|
|
27913
28134
|
paneContext.font = `600 ${11 * zoomFactor}px ui-sans-serif, system-ui, sans-serif`;
|
|
27914
|
-
paneContext.fillStyle = palette.
|
|
28135
|
+
paneContext.fillStyle = palette.headerText;
|
|
27915
28136
|
paneContext.textAlign = "center";
|
|
27916
28137
|
paneContext.textBaseline = "middle";
|
|
27917
28138
|
paneContext.fillText(`${row.actualRow + 1}`, rowHeaderWidth / 2, row.localTop + row.height / 2);
|
|
@@ -28254,7 +28475,7 @@ function XlsxGrid({
|
|
|
28254
28475
|
borderBottom: "none",
|
|
28255
28476
|
borderRight: "none",
|
|
28256
28477
|
boxShadow: gutterSeparatorShadow,
|
|
28257
|
-
color: palette.
|
|
28478
|
+
color: palette.headerText,
|
|
28258
28479
|
fontSize: "11px",
|
|
28259
28480
|
fontWeight: 600,
|
|
28260
28481
|
height: HEADER_HEIGHT,
|
|
@@ -30518,6 +30739,8 @@ function XlsxViewerInner({
|
|
|
30518
30739
|
experimentalCanvas = true,
|
|
30519
30740
|
fileTooLargeState,
|
|
30520
30741
|
getCellStyle,
|
|
30742
|
+
headerBackgroundColor,
|
|
30743
|
+
headerTextColor,
|
|
30521
30744
|
height,
|
|
30522
30745
|
isDark = false,
|
|
30523
30746
|
loadingComponent,
|
|
@@ -30538,7 +30761,7 @@ function XlsxViewerInner({
|
|
|
30538
30761
|
showDefaultToolbar = true,
|
|
30539
30762
|
toolbar
|
|
30540
30763
|
}) {
|
|
30541
|
-
const palette = useViewerPalette(isDark);
|
|
30764
|
+
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
30542
30765
|
const { displayFileName, error } = controller;
|
|
30543
30766
|
const customFileTooLarge = error instanceof XlsxFileSizeLimitExceededError ? renderCustomFileTooLarge(
|
|
30544
30767
|
fileTooLargeState,
|
|
@@ -30549,7 +30772,7 @@ function XlsxViewerInner({
|
|
|
30549
30772
|
},
|
|
30550
30773
|
palette
|
|
30551
30774
|
) : void 0;
|
|
30552
|
-
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)(
|
|
30553
30776
|
"div",
|
|
30554
30777
|
{
|
|
30555
30778
|
className: classNames("react-xlsx-viewer", className),
|
|
@@ -31020,8 +31243,8 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
31020
31243
|
workbook,
|
|
31021
31244
|
sheets
|
|
31022
31245
|
} = useXlsxViewer();
|
|
31023
|
-
const { isDark } = React4.useContext(ViewerAppearanceContext);
|
|
31024
|
-
const palette = useViewerPalette(isDark);
|
|
31246
|
+
const { headerBackgroundColor, headerTextColor, isDark } = React4.useContext(ViewerAppearanceContext);
|
|
31247
|
+
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
31025
31248
|
const includeHeaders = options.includeHeaders ?? true;
|
|
31026
31249
|
const resolution = options.resolution;
|
|
31027
31250
|
const thumbnailImageCacheRef = React4.useRef(/* @__PURE__ */ new Map());
|
|
@@ -31633,7 +31856,7 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
31633
31856
|
context.strokeStyle = palette.border;
|
|
31634
31857
|
context.lineWidth = 1;
|
|
31635
31858
|
context.font = "600 11px ui-sans-serif, system-ui, sans-serif";
|
|
31636
|
-
context.fillStyle = palette.
|
|
31859
|
+
context.fillStyle = palette.headerText;
|
|
31637
31860
|
context.textBaseline = "middle";
|
|
31638
31861
|
for (const colItem of colAxis.items) {
|
|
31639
31862
|
const left = rowHeaderWidth + colItem.start;
|
|
@@ -31720,8 +31943,8 @@ function XlsxViewer(props) {
|
|
|
31720
31943
|
}
|
|
31721
31944
|
function DefaultXlsxToolbar() {
|
|
31722
31945
|
const controller = useXlsxViewer();
|
|
31723
|
-
const { isDark } = React4.useContext(ViewerAppearanceContext);
|
|
31724
|
-
const palette = useViewerPalette(isDark);
|
|
31946
|
+
const { headerBackgroundColor, headerTextColor, isDark } = React4.useContext(ViewerAppearanceContext);
|
|
31947
|
+
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
31725
31948
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DefaultToolbar, { controller, palette });
|
|
31726
31949
|
}
|
|
31727
31950
|
// Annotate the CommonJS export names for ESM import in node:
|