@extend-ai/react-xlsx 0.20.12 → 0.21.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 +144 -1
- package/dist/{chunk-O4S5CRDM.js → chunk-2UFSVI5Z.js} +432 -33
- package/dist/chunk-2UFSVI5Z.js.map +1 -0
- package/dist/{chunk-NIN5D556.cjs → chunk-7IL4KLCD.cjs} +837 -438
- package/dist/chunk-7IL4KLCD.cjs.map +1 -0
- package/dist/index.cjs +215 -147
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +173 -105
- package/dist/index.js.map +1 -1
- package/dist/{internal-D_np3R-w.d.cts → internal-BO70EPFy.d.cts} +71 -1
- package/dist/{internal-D_np3R-w.d.ts → internal-BO70EPFy.d.ts} +71 -1
- package/dist/internal.cjs +2 -2
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/vanilla.cjs +2 -2
- package/dist/vanilla.d.cts +2 -2
- package/dist/vanilla.d.ts +2 -2
- package/dist/vanilla.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-NIN5D556.cjs.map +0 -1
- package/dist/chunk-O4S5CRDM.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -11577,6 +11577,28 @@ function useXlsxViewerController(options) {
|
|
|
11577
11577
|
refreshWorkbookState(workbook);
|
|
11578
11578
|
recordCellEditHistory(cell, before, after);
|
|
11579
11579
|
}, [captureCellMutationState, getActiveWorksheet, readOnly, recordCellEditHistory, refreshWorkbookState, workbook]);
|
|
11580
|
+
const setCellStyles = React.useCallback((updates) => {
|
|
11581
|
+
const worksheet = getActiveWorksheet();
|
|
11582
|
+
if (readOnly || !worksheet || !workbook) return;
|
|
11583
|
+
const beforeStates = /* @__PURE__ */ new Map();
|
|
11584
|
+
for (const { cell, style } of updates) {
|
|
11585
|
+
const key = `${cell.row}:${cell.col}`;
|
|
11586
|
+
if (!beforeStates.has(key)) {
|
|
11587
|
+
const before = captureCellMutationState(cell);
|
|
11588
|
+
if (!before) continue;
|
|
11589
|
+
beforeStates.set(key, { cell: { ...cell }, before });
|
|
11590
|
+
}
|
|
11591
|
+
worksheet.setCellStyleAt(cell.row, cell.col, style);
|
|
11592
|
+
}
|
|
11593
|
+
if (!beforeStates.size) return;
|
|
11594
|
+
const mutations = [];
|
|
11595
|
+
for (const { cell, before } of beforeStates.values()) {
|
|
11596
|
+
const after = captureCellMutationState(cell);
|
|
11597
|
+
if (after) mutations.push({ cell, before, after });
|
|
11598
|
+
}
|
|
11599
|
+
refreshWorkbookState(workbook);
|
|
11600
|
+
recordRangeEditHistory(mutations, selection, activeCell);
|
|
11601
|
+
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
|
|
11580
11602
|
const setSelectedCellValue = React.useCallback((value) => {
|
|
11581
11603
|
if (!activeCell) {
|
|
11582
11604
|
return;
|
|
@@ -12233,6 +12255,7 @@ function useXlsxViewerController(options) {
|
|
|
12233
12255
|
resizeRow,
|
|
12234
12256
|
setCellFormula,
|
|
12235
12257
|
setCellStyle,
|
|
12258
|
+
setCellStyles,
|
|
12236
12259
|
setCellValue,
|
|
12237
12260
|
setRangeStyle,
|
|
12238
12261
|
setSelectedFormula,
|
|
@@ -12357,6 +12380,7 @@ function useXlsxViewerController(options) {
|
|
|
12357
12380
|
resizeRow,
|
|
12358
12381
|
setCellFormula,
|
|
12359
12382
|
setCellStyle,
|
|
12383
|
+
setCellStyles,
|
|
12360
12384
|
setCellValue,
|
|
12361
12385
|
setRangeStyle,
|
|
12362
12386
|
setSelectedFormula,
|
|
@@ -12410,12 +12434,12 @@ function useXlsxViewerController(options) {
|
|
|
12410
12434
|
import { initWasm, parseXlsxRange as parseXlsxRange2, setWasmSource, XlsxFileSizeLimitExceededError as XlsxFileSizeLimitExceededError3 } from "@extend-ai/react-xlsx/vanilla";
|
|
12411
12435
|
|
|
12412
12436
|
// src/react-viewer.tsx
|
|
12413
|
-
import * as
|
|
12414
|
-
import { createPortal as
|
|
12437
|
+
import * as React10 from "react";
|
|
12438
|
+
import { createPortal as createPortal4 } from "react-dom";
|
|
12415
12439
|
import { __createContentNode, __createContentRoot, __createControlledViewer } from "@extend-ai/react-xlsx/internal";
|
|
12416
12440
|
|
|
12417
12441
|
// src/XlsxViewer.tsx
|
|
12418
|
-
import * as
|
|
12442
|
+
import * as React9 from "react";
|
|
12419
12443
|
|
|
12420
12444
|
// src/cell-editor.tsx
|
|
12421
12445
|
import * as React2 from "react";
|
|
@@ -12424,6 +12448,8 @@ function CellEditor({
|
|
|
12424
12448
|
value,
|
|
12425
12449
|
references,
|
|
12426
12450
|
inputRef,
|
|
12451
|
+
editorRef,
|
|
12452
|
+
onFocusOverlay,
|
|
12427
12453
|
canvasText = false,
|
|
12428
12454
|
canvasOffset,
|
|
12429
12455
|
paintCanvasText,
|
|
@@ -12563,7 +12589,12 @@ function CellEditor({
|
|
|
12563
12589
|
return /* @__PURE__ */ jsxs(
|
|
12564
12590
|
"div",
|
|
12565
12591
|
{
|
|
12566
|
-
ref:
|
|
12592
|
+
ref: (element) => {
|
|
12593
|
+
rootRef.current = element;
|
|
12594
|
+
if (typeof editorRef === "function") editorRef(element);
|
|
12595
|
+
else if (editorRef) editorRef.current = element;
|
|
12596
|
+
},
|
|
12597
|
+
"data-xlsx-cell-editor": "",
|
|
12567
12598
|
onPointerDown: (event) => event.stopPropagation(),
|
|
12568
12599
|
onClick: (event) => event.stopPropagation(),
|
|
12569
12600
|
onDoubleClick: (event) => event.stopPropagation(),
|
|
@@ -12612,7 +12643,7 @@ function CellEditor({
|
|
|
12612
12643
|
] })
|
|
12613
12644
|
}
|
|
12614
12645
|
),
|
|
12615
|
-
paintCanvasText ? /* @__PURE__ */ jsx("canvas", { ref: canvasRef, "aria-hidden": "true", style: { position: "absolute", pointerEvents: "none" } }) : null,
|
|
12646
|
+
paintCanvasText ? /* @__PURE__ */ jsx("canvas", { ref: canvasRef, "data-xlsx-formula-text": "", "aria-hidden": "true", style: { position: "absolute", pointerEvents: "none" } }) : null,
|
|
12616
12647
|
/* @__PURE__ */ jsx(
|
|
12617
12648
|
"textarea",
|
|
12618
12649
|
{
|
|
@@ -12622,6 +12653,7 @@ function CellEditor({
|
|
|
12622
12653
|
else if (inputRef) inputRef.current = element;
|
|
12623
12654
|
},
|
|
12624
12655
|
"aria-label": messages.editCell,
|
|
12656
|
+
"aria-keyshortcuts": onFocusOverlay ? "Alt+ArrowDown" : void 0,
|
|
12625
12657
|
autoFocus: true,
|
|
12626
12658
|
autoComplete: "off",
|
|
12627
12659
|
spellCheck: false,
|
|
@@ -12635,7 +12667,9 @@ function CellEditor({
|
|
|
12635
12667
|
onKeyDown: (event) => {
|
|
12636
12668
|
event.stopPropagation();
|
|
12637
12669
|
if (event.nativeEvent.isComposing) return;
|
|
12638
|
-
if (event.key === "
|
|
12670
|
+
if (event.key === "ArrowDown" && event.altKey && onFocusOverlay?.()) {
|
|
12671
|
+
event.preventDefault();
|
|
12672
|
+
} else if (event.key === "Enter" && !event.altKey) {
|
|
12639
12673
|
event.preventDefault();
|
|
12640
12674
|
onCommit();
|
|
12641
12675
|
} else if (event.key === "Escape") {
|
|
@@ -12681,6 +12715,19 @@ function CellEditor({
|
|
|
12681
12715
|
);
|
|
12682
12716
|
}
|
|
12683
12717
|
|
|
12718
|
+
// src/cell-editor-overlay.tsx
|
|
12719
|
+
import * as React3 from "react";
|
|
12720
|
+
import { createPortal } from "react-dom";
|
|
12721
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
12722
|
+
|
|
12723
|
+
// src/selection-popover.tsx
|
|
12724
|
+
import * as React4 from "react";
|
|
12725
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
12726
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
12727
|
+
|
|
12728
|
+
// src/cell-editor-session.ts
|
|
12729
|
+
import * as React5 from "react";
|
|
12730
|
+
|
|
12684
12731
|
// src/cell-alignment.ts
|
|
12685
12732
|
function getCellGeneralAlignment(worksheet, row, col) {
|
|
12686
12733
|
const value = worksheet.getCalculatedValueAt(row, col);
|
|
@@ -12694,8 +12741,8 @@ function getCellGeneralAlignment(worksheet, row, col) {
|
|
|
12694
12741
|
}
|
|
12695
12742
|
|
|
12696
12743
|
// src/context-menu.tsx
|
|
12697
|
-
import * as
|
|
12698
|
-
import { createPortal } from "react-dom";
|
|
12744
|
+
import * as React6 from "react";
|
|
12745
|
+
import { createPortal as createPortal3 } from "react-dom";
|
|
12699
12746
|
|
|
12700
12747
|
// src/viewer-palette.ts
|
|
12701
12748
|
var LIGHT_PALETTE = {
|
|
@@ -12759,10 +12806,10 @@ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextC
|
|
|
12759
12806
|
}
|
|
12760
12807
|
|
|
12761
12808
|
// src/context-menu.tsx
|
|
12762
|
-
import { jsx as
|
|
12809
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
12763
12810
|
|
|
12764
12811
|
// src/lazy-chart.tsx
|
|
12765
|
-
import * as
|
|
12812
|
+
import * as React8 from "react";
|
|
12766
12813
|
|
|
12767
12814
|
// src/chart-loader.ts
|
|
12768
12815
|
function createChartModule(importModule) {
|
|
@@ -12812,10 +12859,10 @@ var officeExtendedChartRenderer = createChartModule(async () => {
|
|
|
12812
12859
|
});
|
|
12813
12860
|
|
|
12814
12861
|
// src/use-chart-module.ts
|
|
12815
|
-
import * as
|
|
12862
|
+
import * as React7 from "react";
|
|
12816
12863
|
|
|
12817
12864
|
// src/lazy-chart.tsx
|
|
12818
|
-
import { Fragment as Fragment3, jsx as
|
|
12865
|
+
import { Fragment as Fragment3, jsx as jsx5 } from "react/jsx-runtime";
|
|
12819
12866
|
|
|
12820
12867
|
// src/picture-paint.ts
|
|
12821
12868
|
function resolvePicturePaintRect(image, rect) {
|
|
@@ -12832,7 +12879,7 @@ function resolvePicturePaintRect(image, rect) {
|
|
|
12832
12879
|
}
|
|
12833
12880
|
|
|
12834
12881
|
// src/XlsxViewer.tsx
|
|
12835
|
-
import { Fragment as Fragment5, jsx as
|
|
12882
|
+
import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
12836
12883
|
var DEFAULT_ROW_HEIGHT2 = 24;
|
|
12837
12884
|
var DEFAULT_COL_WIDTH2 = 80;
|
|
12838
12885
|
var HEADER_HEIGHT = 24;
|
|
@@ -13464,10 +13511,10 @@ function lightenColor(color, ratio) {
|
|
|
13464
13511
|
function darkenColor(color, ratio) {
|
|
13465
13512
|
return mixRgbColor(color, "#000000", ratio);
|
|
13466
13513
|
}
|
|
13467
|
-
var ViewerContext =
|
|
13468
|
-
var ViewerAppearanceContext =
|
|
13514
|
+
var ViewerContext = React9.createContext(null);
|
|
13515
|
+
var ViewerAppearanceContext = React9.createContext({ isDark: false });
|
|
13469
13516
|
function ReferenceRangeHandles({ color, top = true, bottom = true, left = true, right = true }) {
|
|
13470
|
-
return /* @__PURE__ */
|
|
13517
|
+
return /* @__PURE__ */ jsx6(Fragment5, { children: [top && "top", bottom && "bottom"].flatMap((vertical) => vertical ? [left && "left", right && "right"].map((horizontal) => horizontal ? /* @__PURE__ */ jsx6("span", { style: {
|
|
13471
13518
|
position: "absolute",
|
|
13472
13519
|
[vertical]: -4,
|
|
13473
13520
|
[horizontal]: -4,
|
|
@@ -14441,7 +14488,7 @@ function applyCanvasShapeDash(context, dash, lineWidth) {
|
|
|
14441
14488
|
}
|
|
14442
14489
|
}
|
|
14443
14490
|
function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
|
|
14444
|
-
return
|
|
14491
|
+
return React9.useMemo(
|
|
14445
14492
|
() => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
|
|
14446
14493
|
[headerBackgroundColor, headerTextColor, isDark]
|
|
14447
14494
|
);
|
|
@@ -15128,10 +15175,10 @@ function renderSparkline(sparkline, values, palette) {
|
|
|
15128
15175
|
const gap = normalizedValues.length > 1 ? (innerWidth - segmentWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
|
|
15129
15176
|
const positiveY = 4.5;
|
|
15130
15177
|
const negativeY = height - 4.5;
|
|
15131
|
-
return /* @__PURE__ */
|
|
15178
|
+
return /* @__PURE__ */ jsx6("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: normalizedValues.map((entry, index) => {
|
|
15132
15179
|
const left = 1 + index * (segmentWidth + Math.max(0, gap));
|
|
15133
15180
|
const y = entry.value >= 0 ? positiveY : negativeY;
|
|
15134
|
-
return /* @__PURE__ */
|
|
15181
|
+
return /* @__PURE__ */ jsx6(
|
|
15135
15182
|
"line",
|
|
15136
15183
|
{
|
|
15137
15184
|
stroke: seriesColor,
|
|
@@ -15154,14 +15201,14 @@ function renderSparkline(sparkline, values, palette) {
|
|
|
15154
15201
|
const barWidth = Math.max(2, innerWidth / Math.max(normalizedValues.length * 1.8, 1));
|
|
15155
15202
|
const gap = normalizedValues.length > 1 ? (innerWidth - barWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
|
|
15156
15203
|
return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
|
|
15157
|
-
/* @__PURE__ */
|
|
15204
|
+
/* @__PURE__ */ jsx6("line", { stroke: palette.border, strokeWidth: 1, x1: 1, x2: width - 1, y1: zeroY, y2: zeroY }),
|
|
15158
15205
|
normalizedValues.map((entry, index) => {
|
|
15159
15206
|
const left = 1 + index * (barWidth + Math.max(0, gap));
|
|
15160
15207
|
const y = 2 + innerHeight - clampSparklineValue(entry.value, minValue2, maxValue2) * innerHeight;
|
|
15161
15208
|
const top = Math.min(y, zeroY);
|
|
15162
15209
|
const barHeight = Math.max(1, Math.abs(y - zeroY));
|
|
15163
15210
|
const fill = entry.value < 0 ? negativeColor : seriesColor;
|
|
15164
|
-
return /* @__PURE__ */
|
|
15211
|
+
return /* @__PURE__ */ jsx6(
|
|
15165
15212
|
"rect",
|
|
15166
15213
|
{
|
|
15167
15214
|
fill,
|
|
@@ -15188,7 +15235,7 @@ function renderSparkline(sparkline, values, palette) {
|
|
|
15188
15235
|
const highValue = Math.max(...points.map((entry) => entry.value));
|
|
15189
15236
|
const lowValue = Math.min(...points.map((entry) => entry.value));
|
|
15190
15237
|
return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
|
|
15191
|
-
/* @__PURE__ */
|
|
15238
|
+
/* @__PURE__ */ jsx6("path", { d: path, fill: "none", stroke: seriesColor, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6 }),
|
|
15192
15239
|
sparkline.markers ? points.map((entry, index) => {
|
|
15193
15240
|
const x = 1 + index * xStep;
|
|
15194
15241
|
const y = 2 + innerHeight - clampSparklineValue(entry.value, minValue, maxValue) * innerHeight;
|
|
@@ -15204,7 +15251,7 @@ function renderSparkline(sparkline, values, palette) {
|
|
|
15204
15251
|
} else if (entry.value < 0 && sparkline.negative && sparkline.negativeColor) {
|
|
15205
15252
|
fill = sparkline.negativeColor;
|
|
15206
15253
|
}
|
|
15207
|
-
return /* @__PURE__ */
|
|
15254
|
+
return /* @__PURE__ */ jsx6("circle", { cx: x, cy: y, fill, r: 1.75 }, `spark-point-${index}`);
|
|
15208
15255
|
}) : null
|
|
15209
15256
|
] });
|
|
15210
15257
|
}
|
|
@@ -15327,7 +15374,7 @@ function SegmentedControl({
|
|
|
15327
15374
|
palette,
|
|
15328
15375
|
value
|
|
15329
15376
|
}) {
|
|
15330
|
-
return /* @__PURE__ */
|
|
15377
|
+
return /* @__PURE__ */ jsx6(
|
|
15331
15378
|
"div",
|
|
15332
15379
|
{
|
|
15333
15380
|
"aria-label": messages.workbookSheets,
|
|
@@ -15345,7 +15392,7 @@ function SegmentedControl({
|
|
|
15345
15392
|
children: items.map((item) => {
|
|
15346
15393
|
const selected = item.id === value;
|
|
15347
15394
|
const isHidden = item.visibility === "hidden" || item.visibility === "veryHidden";
|
|
15348
|
-
return /* @__PURE__ */
|
|
15395
|
+
return /* @__PURE__ */ jsx6(
|
|
15349
15396
|
"button",
|
|
15350
15397
|
{
|
|
15351
15398
|
"aria-selected": selected,
|
|
@@ -15409,7 +15456,7 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
15409
15456
|
padding: "0 16px"
|
|
15410
15457
|
},
|
|
15411
15458
|
children: [
|
|
15412
|
-
/* @__PURE__ */
|
|
15459
|
+
/* @__PURE__ */ jsx6("div", { style: { minWidth: 0 }, children: /* @__PURE__ */ jsx6(
|
|
15413
15460
|
"div",
|
|
15414
15461
|
{
|
|
15415
15462
|
style: {
|
|
@@ -15436,7 +15483,7 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
15436
15483
|
overflow: "hidden"
|
|
15437
15484
|
},
|
|
15438
15485
|
children: [
|
|
15439
|
-
/* @__PURE__ */
|
|
15486
|
+
/* @__PURE__ */ jsx6(
|
|
15440
15487
|
"button",
|
|
15441
15488
|
{
|
|
15442
15489
|
"aria-label": messages.zoomOut,
|
|
@@ -15455,7 +15502,7 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
15455
15502
|
children: "-"
|
|
15456
15503
|
}
|
|
15457
15504
|
),
|
|
15458
|
-
/* @__PURE__ */
|
|
15505
|
+
/* @__PURE__ */ jsx6(
|
|
15459
15506
|
"button",
|
|
15460
15507
|
{
|
|
15461
15508
|
"aria-label": messages.resetZoom,
|
|
@@ -15476,7 +15523,7 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
15476
15523
|
children: formatZoomScale(zoomScale, locale)
|
|
15477
15524
|
}
|
|
15478
15525
|
),
|
|
15479
|
-
/* @__PURE__ */
|
|
15526
|
+
/* @__PURE__ */ jsx6(
|
|
15480
15527
|
"button",
|
|
15481
15528
|
{
|
|
15482
15529
|
"aria-label": messages.zoomIn,
|
|
@@ -15498,7 +15545,7 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
15498
15545
|
]
|
|
15499
15546
|
}
|
|
15500
15547
|
),
|
|
15501
|
-
canDownload ? /* @__PURE__ */
|
|
15548
|
+
canDownload ? /* @__PURE__ */ jsx6(
|
|
15502
15549
|
"button",
|
|
15503
15550
|
{
|
|
15504
15551
|
"aria-label": messages.downloadWorkbook,
|
|
@@ -15527,7 +15574,7 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
15527
15574
|
]
|
|
15528
15575
|
}
|
|
15529
15576
|
),
|
|
15530
|
-
tabs.length > 1 ? /* @__PURE__ */
|
|
15577
|
+
tabs.length > 1 ? /* @__PURE__ */ jsx6(
|
|
15531
15578
|
"div",
|
|
15532
15579
|
{
|
|
15533
15580
|
style: {
|
|
@@ -15536,7 +15583,7 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
15536
15583
|
overflowX: "auto",
|
|
15537
15584
|
padding: "8px 12px"
|
|
15538
15585
|
},
|
|
15539
|
-
children: /* @__PURE__ */
|
|
15586
|
+
children: /* @__PURE__ */ jsx6(
|
|
15540
15587
|
SegmentedControl,
|
|
15541
15588
|
{
|
|
15542
15589
|
messages,
|
|
@@ -15854,7 +15901,7 @@ function renderConditionalIcon(icon, scale = 1) {
|
|
|
15854
15901
|
if (icon.shape === "arrow") {
|
|
15855
15902
|
const fill = icon.color ?? "#111827";
|
|
15856
15903
|
const stroke = icon.borderColor ?? darkenColor(fill, 0.32);
|
|
15857
|
-
return /* @__PURE__ */
|
|
15904
|
+
return /* @__PURE__ */ jsx6(
|
|
15858
15905
|
"svg",
|
|
15859
15906
|
{
|
|
15860
15907
|
"aria-hidden": "true",
|
|
@@ -15862,7 +15909,7 @@ function renderConditionalIcon(icon, scale = 1) {
|
|
|
15862
15909
|
style: { display: "block" },
|
|
15863
15910
|
viewBox: "0 0 16 16",
|
|
15864
15911
|
width: iconSize,
|
|
15865
|
-
children: /* @__PURE__ */
|
|
15912
|
+
children: /* @__PURE__ */ jsx6("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx6(
|
|
15866
15913
|
"path",
|
|
15867
15914
|
{
|
|
15868
15915
|
d: "M2.5 8 L8.4 2.4 L8.4 5.2 L13.5 5.2 L13.5 10.8 L8.4 10.8 L8.4 13.6 Z",
|
|
@@ -15876,7 +15923,7 @@ function renderConditionalIcon(icon, scale = 1) {
|
|
|
15876
15923
|
);
|
|
15877
15924
|
}
|
|
15878
15925
|
if (icon.glyph) {
|
|
15879
|
-
return /* @__PURE__ */
|
|
15926
|
+
return /* @__PURE__ */ jsx6(
|
|
15880
15927
|
"span",
|
|
15881
15928
|
{
|
|
15882
15929
|
style: {
|
|
@@ -15894,7 +15941,7 @@ function renderConditionalIcon(icon, scale = 1) {
|
|
|
15894
15941
|
}
|
|
15895
15942
|
);
|
|
15896
15943
|
}
|
|
15897
|
-
return /* @__PURE__ */
|
|
15944
|
+
return /* @__PURE__ */ jsx6(
|
|
15898
15945
|
"span",
|
|
15899
15946
|
{
|
|
15900
15947
|
style: {
|
|
@@ -15919,8 +15966,8 @@ function renderCheckboxControl(checked, palette, scale = 1, mixed = false) {
|
|
|
15919
15966
|
const fill = checked || mixed ? paletteIsDark(palette) ? "#60a5fa" : "#2563eb" : "transparent";
|
|
15920
15967
|
const check = paletteIsDark(palette) ? "#020617" : "#ffffff";
|
|
15921
15968
|
return /* @__PURE__ */ jsxs3("svg", { "aria-hidden": "true", height: 14 * scale, style: { display: "block" }, viewBox: "0 0 16 16", width: 14 * scale, children: [
|
|
15922
|
-
/* @__PURE__ */
|
|
15923
|
-
mixed ? /* @__PURE__ */
|
|
15969
|
+
/* @__PURE__ */ jsx6("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
|
|
15970
|
+
mixed ? /* @__PURE__ */ jsx6("path", { d: "M5 8h6", fill: "none", stroke: check, strokeLinecap: "round", strokeWidth: 1.8 }) : checked ? /* @__PURE__ */ jsx6(
|
|
15924
15971
|
"path",
|
|
15925
15972
|
{
|
|
15926
15973
|
d: "M5 8.1 7.1 10.2 11.3 5.8",
|
|
@@ -16332,6 +16379,10 @@ function GridRow({
|
|
|
16332
16379
|
editingValue,
|
|
16333
16380
|
formulaReferences,
|
|
16334
16381
|
editorBoxShadow,
|
|
16382
|
+
editorRef,
|
|
16383
|
+
editorInputRef,
|
|
16384
|
+
cellEditorStyle,
|
|
16385
|
+
onFocusEditorOverlay,
|
|
16335
16386
|
frozenRowHeaderZIndex,
|
|
16336
16387
|
getCellData,
|
|
16337
16388
|
headerLabelLiveScale,
|
|
@@ -16361,7 +16412,7 @@ function GridRow({
|
|
|
16361
16412
|
}) {
|
|
16362
16413
|
const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
|
|
16363
16414
|
return /* @__PURE__ */ jsxs3("tr", { "data-xlsx-row": actualRow, style: { height: rowHeight }, children: [
|
|
16364
|
-
/* @__PURE__ */
|
|
16415
|
+
/* @__PURE__ */ jsx6(
|
|
16365
16416
|
"td",
|
|
16366
16417
|
{
|
|
16367
16418
|
ref: (element) => onRowHeaderRef(actualRow, element),
|
|
@@ -16387,7 +16438,7 @@ function GridRow({
|
|
|
16387
16438
|
zIndex: stickyTop !== void 0 ? frozenRowHeaderZIndex : rowHeaderZIndex
|
|
16388
16439
|
},
|
|
16389
16440
|
children: /* @__PURE__ */ jsxs3("div", { style: { position: "relative" }, children: [
|
|
16390
|
-
/* @__PURE__ */
|
|
16441
|
+
/* @__PURE__ */ jsx6(
|
|
16391
16442
|
"span",
|
|
16392
16443
|
{
|
|
16393
16444
|
style: {
|
|
@@ -16398,7 +16449,7 @@ function GridRow({
|
|
|
16398
16449
|
children: actualRow + 1
|
|
16399
16450
|
}
|
|
16400
16451
|
),
|
|
16401
|
-
/* @__PURE__ */
|
|
16452
|
+
/* @__PURE__ */ jsx6(
|
|
16402
16453
|
"div",
|
|
16403
16454
|
{
|
|
16404
16455
|
onPointerDown: (event) => onRowResizePointerDown(event, actualRow, rowHeight),
|
|
@@ -16417,7 +16468,7 @@ function GridRow({
|
|
|
16417
16468
|
] })
|
|
16418
16469
|
}
|
|
16419
16470
|
),
|
|
16420
|
-
leadingSpacerWidth > 0 ? /* @__PURE__ */
|
|
16471
|
+
leadingSpacerWidth > 0 ? /* @__PURE__ */ jsx6(
|
|
16421
16472
|
"td",
|
|
16422
16473
|
{
|
|
16423
16474
|
"aria-hidden": "true",
|
|
@@ -16579,7 +16630,7 @@ function GridRow({
|
|
|
16579
16630
|
style: cellStyle,
|
|
16580
16631
|
title,
|
|
16581
16632
|
children: [
|
|
16582
|
-
cellData.chartHighlight ? /* @__PURE__ */
|
|
16633
|
+
cellData.chartHighlight ? /* @__PURE__ */ jsx6(
|
|
16583
16634
|
"div",
|
|
16584
16635
|
{
|
|
16585
16636
|
"aria-hidden": "true",
|
|
@@ -16594,7 +16645,7 @@ function GridRow({
|
|
|
16594
16645
|
pointerEvents: "none",
|
|
16595
16646
|
position: "absolute"
|
|
16596
16647
|
},
|
|
16597
|
-
children: /* @__PURE__ */
|
|
16648
|
+
children: /* @__PURE__ */ jsx6(
|
|
16598
16649
|
ReferenceRangeHandles,
|
|
16599
16650
|
{
|
|
16600
16651
|
color: cellData.chartHighlight.strokeColor,
|
|
@@ -16606,7 +16657,7 @@ function GridRow({
|
|
|
16606
16657
|
)
|
|
16607
16658
|
}
|
|
16608
16659
|
) : null,
|
|
16609
|
-
cellData.conditionalDataBar ? /* @__PURE__ */
|
|
16660
|
+
cellData.conditionalDataBar ? /* @__PURE__ */ jsx6(
|
|
16610
16661
|
"div",
|
|
16611
16662
|
{
|
|
16612
16663
|
"aria-hidden": "true",
|
|
@@ -16621,7 +16672,7 @@ function GridRow({
|
|
|
16621
16672
|
top: 4 * zoomFactor,
|
|
16622
16673
|
zIndex: 0
|
|
16623
16674
|
},
|
|
16624
|
-
children: /* @__PURE__ */
|
|
16675
|
+
children: /* @__PURE__ */ jsx6(
|
|
16625
16676
|
"div",
|
|
16626
16677
|
{
|
|
16627
16678
|
style: {
|
|
@@ -16637,7 +16688,7 @@ function GridRow({
|
|
|
16637
16688
|
}
|
|
16638
16689
|
) : null,
|
|
16639
16690
|
adornment,
|
|
16640
|
-
cellData.conditionalIcon ? /* @__PURE__ */
|
|
16691
|
+
cellData.conditionalIcon ? /* @__PURE__ */ jsx6(
|
|
16641
16692
|
"div",
|
|
16642
16693
|
{
|
|
16643
16694
|
"aria-hidden": "true",
|
|
@@ -16655,7 +16706,7 @@ function GridRow({
|
|
|
16655
16706
|
children: renderConditionalIcon(cellData.conditionalIcon, zoomFactor)
|
|
16656
16707
|
}
|
|
16657
16708
|
) : null,
|
|
16658
|
-
isSpilling && !isEditing ? /* @__PURE__ */
|
|
16709
|
+
isSpilling && !isEditing ? /* @__PURE__ */ jsx6("div", { "aria-hidden": "true", style: {
|
|
16659
16710
|
backgroundColor: cellStyle.backgroundColor ?? palette.surface,
|
|
16660
16711
|
position: "absolute",
|
|
16661
16712
|
left: cellData.spillSide === "left" ? cellData.spillOffsetX : "calc(100% - 1px)",
|
|
@@ -16664,9 +16715,12 @@ function GridRow({
|
|
|
16664
16715
|
height: "calc(100% - 1px)",
|
|
16665
16716
|
pointerEvents: "none"
|
|
16666
16717
|
} }) : null,
|
|
16667
|
-
isEditing ? /* @__PURE__ */
|
|
16718
|
+
isEditing ? /* @__PURE__ */ jsx6(
|
|
16668
16719
|
CellEditor,
|
|
16669
16720
|
{
|
|
16721
|
+
editorRef,
|
|
16722
|
+
inputRef: editorInputRef,
|
|
16723
|
+
onFocusOverlay: onFocusEditorOverlay,
|
|
16670
16724
|
value: editingValue,
|
|
16671
16725
|
references: formulaReferences,
|
|
16672
16726
|
onBlur: onEditingBlur,
|
|
@@ -16681,10 +16735,11 @@ function GridRow({
|
|
|
16681
16735
|
font: "inherit",
|
|
16682
16736
|
lineHeight: cellData.style.lineHeight,
|
|
16683
16737
|
verticalAlign: cellData.style.verticalAlign,
|
|
16684
|
-
padding: cellData.style.padding
|
|
16738
|
+
padding: cellData.style.padding,
|
|
16739
|
+
...cellEditorStyle
|
|
16685
16740
|
}
|
|
16686
16741
|
}
|
|
16687
|
-
) : isSpilling ? /* @__PURE__ */
|
|
16742
|
+
) : isSpilling ? /* @__PURE__ */ jsx6(
|
|
16688
16743
|
"div",
|
|
16689
16744
|
{
|
|
16690
16745
|
style: {
|
|
@@ -16698,7 +16753,7 @@ function GridRow({
|
|
|
16698
16753
|
},
|
|
16699
16754
|
children: cellData.value
|
|
16700
16755
|
}
|
|
16701
|
-
) : cellData.sparkline ? /* @__PURE__ */
|
|
16756
|
+
) : cellData.sparkline ? /* @__PURE__ */ jsx6(
|
|
16702
16757
|
"div",
|
|
16703
16758
|
{
|
|
16704
16759
|
style: {
|
|
@@ -16711,7 +16766,7 @@ function GridRow({
|
|
|
16711
16766
|
},
|
|
16712
16767
|
children: renderSparkline(cellData.sparkline.config, cellData.sparkline.values, palette)
|
|
16713
16768
|
}
|
|
16714
|
-
) : cellData.checkboxState != null ? /* @__PURE__ */
|
|
16769
|
+
) : cellData.checkboxState != null ? /* @__PURE__ */ jsx6(
|
|
16715
16770
|
"div",
|
|
16716
16771
|
{
|
|
16717
16772
|
style: {
|
|
@@ -16724,13 +16779,13 @@ function GridRow({
|
|
|
16724
16779
|
},
|
|
16725
16780
|
children: renderCheckboxControl(cellData.checkboxState, palette, zoomFactor)
|
|
16726
16781
|
}
|
|
16727
|
-
) : /* @__PURE__ */
|
|
16782
|
+
) : /* @__PURE__ */ jsx6("div", { style: cellContentStyle, children: rotatedTextStyle ? /* @__PURE__ */ jsx6("span", { style: { ...rotatedTextBounds, flex: "0 0 auto", position: "relative" }, children: /* @__PURE__ */ jsx6("span", { style: rotatedTextStyle, children: cellData.value }) }) : wrappedTextStyle ? /* @__PURE__ */ jsx6("span", { style: wrappedTextStyle, children: cellData.value }) : cellData.value })
|
|
16728
16783
|
]
|
|
16729
16784
|
},
|
|
16730
16785
|
key
|
|
16731
16786
|
);
|
|
16732
16787
|
}),
|
|
16733
|
-
trailingSpacerWidth > 0 ? /* @__PURE__ */
|
|
16788
|
+
trailingSpacerWidth > 0 ? /* @__PURE__ */ jsx6(
|
|
16734
16789
|
"td",
|
|
16735
16790
|
{
|
|
16736
16791
|
"aria-hidden": "true",
|
|
@@ -16744,8 +16799,8 @@ function GridRow({
|
|
|
16744
16799
|
) : null
|
|
16745
16800
|
] });
|
|
16746
16801
|
}
|
|
16747
|
-
var MemoGridRow =
|
|
16748
|
-
if (prev.actualRow !== next.actualRow || prev.rowHeight !== next.rowHeight || prev.headerLabelLiveScale !== next.headerLabelLiveScale || prev.palette !== next.palette || prev.readOnly !== next.readOnly || prev.visibleCols !== next.visibleCols || prev.leadingSpacerWidth !== next.leadingSpacerWidth || prev.rowHeaderWidth !== next.rowHeaderWidth || prev.stickyLeftByCol !== next.stickyLeftByCol || prev.stickyTop !== next.stickyTop || prev.trailingSpacerWidth !== next.trailingSpacerWidth || prev.zoomFactor !== next.zoomFactor || prev.getCellData !== next.getCellData || prev.onCellClick !== next.onCellClick || prev.onCellDoubleClick !== next.onCellDoubleClick || prev.onCellPointerDown !== next.onCellPointerDown || prev.onEditingBlur !== next.onEditingBlur || prev.onEditingCancel !== next.onEditingCancel || prev.onEditingCommit !== next.onEditingCommit || prev.onEditingNavigate !== next.onEditingNavigate || prev.onEditingValueChange !== next.onEditingValueChange || prev.onRowHeaderRef !== next.onRowHeaderRef || prev.onRowPointerDown !== next.onRowPointerDown || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment) {
|
|
16802
|
+
var MemoGridRow = React9.memo(GridRow, (prev, next) => {
|
|
16803
|
+
if (prev.actualRow !== next.actualRow || prev.rowHeight !== next.rowHeight || prev.headerLabelLiveScale !== next.headerLabelLiveScale || prev.palette !== next.palette || prev.readOnly !== next.readOnly || prev.visibleCols !== next.visibleCols || prev.leadingSpacerWidth !== next.leadingSpacerWidth || prev.rowHeaderWidth !== next.rowHeaderWidth || prev.stickyLeftByCol !== next.stickyLeftByCol || prev.stickyTop !== next.stickyTop || prev.trailingSpacerWidth !== next.trailingSpacerWidth || prev.zoomFactor !== next.zoomFactor || prev.getCellData !== next.getCellData || prev.onCellClick !== next.onCellClick || prev.onCellDoubleClick !== next.onCellDoubleClick || prev.onCellPointerDown !== next.onCellPointerDown || prev.onEditingBlur !== next.onEditingBlur || prev.onEditingCancel !== next.onEditingCancel || prev.onEditingCommit !== next.onEditingCommit || prev.onEditingNavigate !== next.onEditingNavigate || prev.onEditingValueChange !== next.onEditingValueChange || prev.onRowHeaderRef !== next.onRowHeaderRef || prev.onRowPointerDown !== next.onRowPointerDown || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment || prev.cellEditorStyle !== next.cellEditorStyle || prev.onFocusEditorOverlay !== next.onFocusEditorOverlay) {
|
|
16749
16804
|
return false;
|
|
16750
16805
|
}
|
|
16751
16806
|
const prevEditingCol = prev.editingCell?.row === prev.actualRow ? prev.editingCell.col : -1;
|
|
@@ -16764,16 +16819,16 @@ function XlsxViewerProviderWithInlineController({
|
|
|
16764
16819
|
...options
|
|
16765
16820
|
}) {
|
|
16766
16821
|
const controller = useXlsxViewerController(options);
|
|
16767
|
-
return /* @__PURE__ */
|
|
16822
|
+
return /* @__PURE__ */ jsx6(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx6(ViewerContext.Provider, { value: controller, children }) });
|
|
16768
16823
|
}
|
|
16769
16824
|
function XlsxViewerProvider({ children, controller, isDark = false, ...options }) {
|
|
16770
16825
|
if (controller) {
|
|
16771
|
-
return /* @__PURE__ */
|
|
16826
|
+
return /* @__PURE__ */ jsx6(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx6(ViewerContext.Provider, { value: controller, children }) });
|
|
16772
16827
|
}
|
|
16773
|
-
return /* @__PURE__ */
|
|
16828
|
+
return /* @__PURE__ */ jsx6(XlsxViewerProviderWithInlineController, { ...options, isDark, children });
|
|
16774
16829
|
}
|
|
16775
16830
|
function useXlsxViewer() {
|
|
16776
|
-
const context =
|
|
16831
|
+
const context = React9.useContext(ViewerContext);
|
|
16777
16832
|
if (!context) {
|
|
16778
16833
|
throw new Error("useXlsxViewer must be used inside XlsxViewer or XlsxViewerProvider.");
|
|
16779
16834
|
}
|
|
@@ -16789,7 +16844,7 @@ function useXlsxViewerSelection() {
|
|
|
16789
16844
|
selectRange,
|
|
16790
16845
|
selection
|
|
16791
16846
|
} = useXlsxViewer();
|
|
16792
|
-
return
|
|
16847
|
+
return React9.useMemo(
|
|
16793
16848
|
() => ({
|
|
16794
16849
|
activeCell,
|
|
16795
16850
|
activeCellAddress,
|
|
@@ -16815,7 +16870,7 @@ function useXlsxViewerZoom() {
|
|
|
16815
16870
|
zoomOut,
|
|
16816
16871
|
zoomScale
|
|
16817
16872
|
} = useXlsxViewer();
|
|
16818
|
-
return
|
|
16873
|
+
return React9.useMemo(
|
|
16819
16874
|
() => ({
|
|
16820
16875
|
canZoomIn,
|
|
16821
16876
|
canZoomOut,
|
|
@@ -16873,6 +16928,7 @@ function useXlsxViewerEditing() {
|
|
|
16873
16928
|
selectedValue,
|
|
16874
16929
|
setCellFormula,
|
|
16875
16930
|
setCellStyle,
|
|
16931
|
+
setCellStyles,
|
|
16876
16932
|
setCellValue,
|
|
16877
16933
|
setRangeStyle,
|
|
16878
16934
|
setSelectedFormula,
|
|
@@ -16883,7 +16939,7 @@ function useXlsxViewerEditing() {
|
|
|
16883
16939
|
unmergeSelection,
|
|
16884
16940
|
updateFormControl
|
|
16885
16941
|
} = useXlsxViewer();
|
|
16886
|
-
return
|
|
16942
|
+
return React9.useMemo(
|
|
16887
16943
|
() => ({
|
|
16888
16944
|
addFormControl,
|
|
16889
16945
|
addSheet,
|
|
@@ -16914,6 +16970,7 @@ function useXlsxViewerEditing() {
|
|
|
16914
16970
|
selectedValue,
|
|
16915
16971
|
setCellFormula,
|
|
16916
16972
|
setCellStyle,
|
|
16973
|
+
setCellStyles,
|
|
16917
16974
|
setCellValue,
|
|
16918
16975
|
setRangeStyle,
|
|
16919
16976
|
setSelectedFormula,
|
|
@@ -16954,6 +17011,7 @@ function useXlsxViewerEditing() {
|
|
|
16954
17011
|
selectedValue,
|
|
16955
17012
|
setCellFormula,
|
|
16956
17013
|
setCellStyle,
|
|
17014
|
+
setCellStyles,
|
|
16957
17015
|
setCellValue,
|
|
16958
17016
|
setRangeStyle,
|
|
16959
17017
|
setSelectedFormula,
|
|
@@ -16968,7 +17026,7 @@ function useXlsxViewerEditing() {
|
|
|
16968
17026
|
}
|
|
16969
17027
|
function useXlsxViewerTables() {
|
|
16970
17028
|
const { sortState, sortTable, tables } = useXlsxViewer();
|
|
16971
|
-
return
|
|
17029
|
+
return React9.useMemo(
|
|
16972
17030
|
() => ({
|
|
16973
17031
|
sortState,
|
|
16974
17032
|
sortTable,
|
|
@@ -17009,7 +17067,7 @@ function useXlsxViewerImages() {
|
|
|
17009
17067
|
setImageRect,
|
|
17010
17068
|
updateChart
|
|
17011
17069
|
} = useXlsxViewer();
|
|
17012
|
-
return
|
|
17070
|
+
return React9.useMemo(
|
|
17013
17071
|
() => ({
|
|
17014
17072
|
charts,
|
|
17015
17073
|
clearSelectedChart,
|
|
@@ -17102,7 +17160,7 @@ function useXlsxViewerCharts() {
|
|
|
17102
17160
|
tabs,
|
|
17103
17161
|
updateChart
|
|
17104
17162
|
} = useXlsxViewer();
|
|
17105
|
-
return
|
|
17163
|
+
return React9.useMemo(
|
|
17106
17164
|
() => ({
|
|
17107
17165
|
activeTab,
|
|
17108
17166
|
activeTabIndex,
|
|
@@ -17169,30 +17227,30 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
17169
17227
|
workbook,
|
|
17170
17228
|
sheets
|
|
17171
17229
|
} = useXlsxViewer();
|
|
17172
|
-
const { headerBackgroundColor, headerTextColor, isDark } =
|
|
17230
|
+
const { headerBackgroundColor, headerTextColor, isDark } = React9.useContext(ViewerAppearanceContext);
|
|
17173
17231
|
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
17174
17232
|
const includeHeaders = options.includeHeaders ?? true;
|
|
17175
17233
|
const resolution = options.resolution;
|
|
17176
|
-
const thumbnailImageCacheRef =
|
|
17177
|
-
const workerThumbnailRowBatchCacheRef =
|
|
17178
|
-
const workerThumbnailRowBatchRequestRef =
|
|
17234
|
+
const thumbnailImageCacheRef = React9.useRef(/* @__PURE__ */ new Map());
|
|
17235
|
+
const workerThumbnailRowBatchCacheRef = React9.useRef(/* @__PURE__ */ new Map());
|
|
17236
|
+
const workerThumbnailRowBatchRequestRef = React9.useRef(
|
|
17179
17237
|
/* @__PURE__ */ new Map()
|
|
17180
17238
|
);
|
|
17181
|
-
const isMountedRef =
|
|
17182
|
-
const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] =
|
|
17183
|
-
const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] =
|
|
17184
|
-
|
|
17239
|
+
const isMountedRef = React9.useRef(false);
|
|
17240
|
+
const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] = React9.useState(0);
|
|
17241
|
+
const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] = React9.useState(0);
|
|
17242
|
+
React9.useEffect(() => {
|
|
17185
17243
|
isMountedRef.current = true;
|
|
17186
17244
|
return () => {
|
|
17187
17245
|
isMountedRef.current = false;
|
|
17188
17246
|
};
|
|
17189
17247
|
}, []);
|
|
17190
|
-
|
|
17248
|
+
React9.useEffect(() => {
|
|
17191
17249
|
workerThumbnailRowBatchCacheRef.current.clear();
|
|
17192
17250
|
workerThumbnailRowBatchRequestRef.current.clear();
|
|
17193
17251
|
setWorkerThumbnailRowBatchVersion((version) => version + 1);
|
|
17194
17252
|
}, [locale]);
|
|
17195
|
-
|
|
17253
|
+
React9.useEffect(() => {
|
|
17196
17254
|
const currentSheets = new Set(sheets);
|
|
17197
17255
|
for (const sheet of workerThumbnailRowBatchCacheRef.current.keys()) {
|
|
17198
17256
|
if (!currentSheets.has(sheet)) {
|
|
@@ -17205,7 +17263,7 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
17205
17263
|
}
|
|
17206
17264
|
}
|
|
17207
17265
|
}, [sheets]);
|
|
17208
|
-
const getWorkerThumbnailRowBatch =
|
|
17266
|
+
const getWorkerThumbnailRowBatch = React9.useCallback((sheet, startRow, endRow) => {
|
|
17209
17267
|
const cachedBatch = workerThumbnailRowBatchCacheRef.current.get(sheet);
|
|
17210
17268
|
if (cachedBatch && startRow >= cachedBatch.startRow && endRow <= cachedBatch.endRow) {
|
|
17211
17269
|
return cachedBatch;
|
|
@@ -17247,7 +17305,7 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
17247
17305
|
}
|
|
17248
17306
|
return null;
|
|
17249
17307
|
}, [getRowsBatchAsync]);
|
|
17250
|
-
const getThumbnailImage =
|
|
17308
|
+
const getThumbnailImage = React9.useCallback((image) => {
|
|
17251
17309
|
if (typeof Image === "undefined") {
|
|
17252
17310
|
return null;
|
|
17253
17311
|
}
|
|
@@ -17279,7 +17337,7 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
17279
17337
|
imageElement.src = image.src;
|
|
17280
17338
|
return null;
|
|
17281
17339
|
}, []);
|
|
17282
|
-
const thumbnails =
|
|
17340
|
+
const thumbnails = React9.useMemo(() => {
|
|
17283
17341
|
return sheets.map((sheet, sheetIndex) => {
|
|
17284
17342
|
const worksheet = workbook?.getSheet(sheet.workbookSheetIndex) ?? null;
|
|
17285
17343
|
const sheetImages = getSheetImages(sheetIndex).filter((image) => image.src).sort((left, right) => left.zIndex - right.zIndex);
|
|
@@ -17853,11 +17911,11 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
17853
17911
|
locale,
|
|
17854
17912
|
workbook
|
|
17855
17913
|
]);
|
|
17856
|
-
const paintThumbnail =
|
|
17914
|
+
const paintThumbnail = React9.useCallback(
|
|
17857
17915
|
(sheetIndex, canvas) => thumbnails[sheetIndex]?.paint(canvas) ?? false,
|
|
17858
17916
|
[thumbnails]
|
|
17859
17917
|
);
|
|
17860
|
-
return
|
|
17918
|
+
return React9.useMemo(
|
|
17861
17919
|
() => ({
|
|
17862
17920
|
paintThumbnail,
|
|
17863
17921
|
thumbnails
|
|
@@ -17867,13 +17925,13 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
17867
17925
|
}
|
|
17868
17926
|
function DefaultXlsxToolbar() {
|
|
17869
17927
|
const controller = useXlsxViewer();
|
|
17870
|
-
const { headerBackgroundColor, headerTextColor, isDark } =
|
|
17928
|
+
const { headerBackgroundColor, headerTextColor, isDark } = React9.useContext(ViewerAppearanceContext);
|
|
17871
17929
|
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
17872
|
-
return /* @__PURE__ */
|
|
17930
|
+
return /* @__PURE__ */ jsx6(DefaultToolbar, { controller, palette });
|
|
17873
17931
|
}
|
|
17874
17932
|
|
|
17875
17933
|
// src/react-viewer.tsx
|
|
17876
|
-
import { jsx as
|
|
17934
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
17877
17935
|
var SlotStore = class {
|
|
17878
17936
|
slots = /* @__PURE__ */ new Map();
|
|
17879
17937
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -17909,7 +17967,7 @@ var SlotStore = class {
|
|
|
17909
17967
|
return __createContentNode(slot.host);
|
|
17910
17968
|
}
|
|
17911
17969
|
portals() {
|
|
17912
|
-
return Array.from(this.slots, ([key, slot]) =>
|
|
17970
|
+
return Array.from(this.slots, ([key, slot]) => createPortal4(slot.node, slot.host, key));
|
|
17913
17971
|
}
|
|
17914
17972
|
destroy() {
|
|
17915
17973
|
this.destroyed = true;
|
|
@@ -17942,9 +18000,9 @@ var SlotStore = class {
|
|
|
17942
18000
|
}
|
|
17943
18001
|
};
|
|
17944
18002
|
function RuntimeContent({ content }) {
|
|
17945
|
-
const hostRef =
|
|
17946
|
-
const rootRef =
|
|
17947
|
-
|
|
18003
|
+
const hostRef = React10.useRef(null);
|
|
18004
|
+
const rootRef = React10.useRef(null);
|
|
18005
|
+
React10.useLayoutEffect(() => {
|
|
17948
18006
|
const host = hostRef.current;
|
|
17949
18007
|
if (!host) return;
|
|
17950
18008
|
const root = __createContentRoot(host);
|
|
@@ -17954,14 +18012,14 @@ function RuntimeContent({ content }) {
|
|
|
17954
18012
|
root.destroy();
|
|
17955
18013
|
};
|
|
17956
18014
|
}, []);
|
|
17957
|
-
|
|
18015
|
+
React10.useLayoutEffect(() => {
|
|
17958
18016
|
rootRef.current?.update(content);
|
|
17959
18017
|
}, [content]);
|
|
17960
|
-
return /* @__PURE__ */
|
|
18018
|
+
return /* @__PURE__ */ jsx7("span", { ref: hostRef, style: { display: "contents" } });
|
|
17961
18019
|
}
|
|
17962
18020
|
function renderOptions(props, controller, slots, owner) {
|
|
17963
18021
|
const slot = (key, node) => slots.render(key, node, owner);
|
|
17964
|
-
const runtime = (node) => /* @__PURE__ */
|
|
18022
|
+
const runtime = (node) => /* @__PURE__ */ jsx7(RuntimeContent, { content: node });
|
|
17965
18023
|
const {
|
|
17966
18024
|
emptyState,
|
|
17967
18025
|
errorState,
|
|
@@ -17969,6 +18027,8 @@ function renderOptions(props, controller, slots, owner) {
|
|
|
17969
18027
|
loadingComponent,
|
|
17970
18028
|
loadingState,
|
|
17971
18029
|
renderActiveCellOverlay,
|
|
18030
|
+
renderCellEditorOverlay,
|
|
18031
|
+
renderSelectionPopover,
|
|
17972
18032
|
renderChartLoading,
|
|
17973
18033
|
renderContextMenu,
|
|
17974
18034
|
renderFormControl,
|
|
@@ -17989,6 +18049,14 @@ function renderOptions(props, controller, slots, owner) {
|
|
|
17989
18049
|
fileTooLargeState: fileTooLargeState === void 0 ? void 0 : typeof fileTooLargeState === "function" ? ({ defaultNode, ...rest }) => slot("too-large", fileTooLargeState({ ...rest, defaultNode: runtime(defaultNode) })) : slot("too-large", fileTooLargeState),
|
|
17990
18050
|
toolbar: toolbar === void 0 ? void 0 : typeof toolbar === "function" ? (current) => slot("toolbar", toolbar(current)) : slot("toolbar", toolbar),
|
|
17991
18051
|
renderActiveCellOverlay: renderActiveCellOverlay ? (value) => slot(`active:${value.cell.row}:${value.cell.col}`, renderActiveCellOverlay(value)) : void 0,
|
|
18052
|
+
renderSelectionPopover: renderSelectionPopover ? (value) => {
|
|
18053
|
+
const content = renderSelectionPopover(value);
|
|
18054
|
+
return content == null || content === false ? null : slot("selection-popover", content);
|
|
18055
|
+
} : void 0,
|
|
18056
|
+
renderCellEditorOverlay: renderCellEditorOverlay ? (value) => {
|
|
18057
|
+
const content = renderCellEditorOverlay(value);
|
|
18058
|
+
return content == null || content === false ? null : slot("cell-editor-overlay", content);
|
|
18059
|
+
} : void 0,
|
|
17992
18060
|
renderChartLoading: renderChartLoading ? ({ defaultNode, ...value }) => slot(`chart:${value.chart.id}`, renderChartLoading({ ...value, defaultNode: runtime(defaultNode) })) : void 0,
|
|
17993
18061
|
renderContextMenu: renderContextMenu ? ({ defaultNode, ...value }) => slot("context-menu", renderContextMenu({ ...value, defaultNode: runtime(defaultNode) })) : void 0,
|
|
17994
18062
|
renderFormControl: renderFormControl ? (value) => slot(`control:${value.control.id}`, renderFormControl(value)) : void 0,
|
|
@@ -17999,13 +18067,13 @@ function renderOptions(props, controller, slots, owner) {
|
|
|
17999
18067
|
};
|
|
18000
18068
|
}
|
|
18001
18069
|
function BoundViewer({ props, controller: sourceController }) {
|
|
18002
|
-
const messages =
|
|
18003
|
-
const controller =
|
|
18004
|
-
const hostRef =
|
|
18005
|
-
const viewerRef =
|
|
18006
|
-
const slots =
|
|
18007
|
-
|
|
18008
|
-
|
|
18070
|
+
const messages = React10.useMemo(() => mergeMessages(sourceController.messages, props.messages), [sourceController.messages, props.messages]);
|
|
18071
|
+
const controller = React10.useMemo(() => ({ ...sourceController, messages }), [sourceController, messages]);
|
|
18072
|
+
const hostRef = React10.useRef(null);
|
|
18073
|
+
const viewerRef = React10.useRef(null);
|
|
18074
|
+
const slots = React10.useMemo(() => new SlotStore(), []);
|
|
18075
|
+
React10.useSyncExternalStore(slots.subscribe, slots.getSnapshot, slots.getServerSnapshot);
|
|
18076
|
+
React10.useLayoutEffect(() => {
|
|
18009
18077
|
const host = hostRef.current;
|
|
18010
18078
|
if (!host) return;
|
|
18011
18079
|
slots.observe(host);
|
|
@@ -18017,27 +18085,27 @@ function BoundViewer({ props, controller: sourceController }) {
|
|
|
18017
18085
|
slots.destroy();
|
|
18018
18086
|
};
|
|
18019
18087
|
}, [slots]);
|
|
18020
|
-
|
|
18088
|
+
React10.useLayoutEffect(() => {
|
|
18021
18089
|
const host = hostRef.current;
|
|
18022
18090
|
if (host) viewerRef.current?.update(renderOptions(props, controller, slots, host.ownerDocument));
|
|
18023
18091
|
}, [controller, props, slots]);
|
|
18024
|
-
return /* @__PURE__ */
|
|
18092
|
+
return /* @__PURE__ */ jsx7(ViewerAppearanceContext.Provider, { value: {
|
|
18025
18093
|
headerBackgroundColor: props.headerBackgroundColor,
|
|
18026
18094
|
headerTextColor: props.headerTextColor,
|
|
18027
18095
|
isDark: props.isDark ?? false
|
|
18028
18096
|
}, children: /* @__PURE__ */ jsxs4(ViewerContext.Provider, { value: controller, children: [
|
|
18029
|
-
/* @__PURE__ */
|
|
18097
|
+
/* @__PURE__ */ jsx7("div", { ref: hostRef, style: { display: "contents" } }),
|
|
18030
18098
|
slots.portals()
|
|
18031
18099
|
] }) });
|
|
18032
18100
|
}
|
|
18033
18101
|
function UncontrolledViewer(props) {
|
|
18034
18102
|
const controller = useXlsxViewerController(props);
|
|
18035
|
-
return /* @__PURE__ */
|
|
18103
|
+
return /* @__PURE__ */ jsx7(BoundViewer, { props, controller });
|
|
18036
18104
|
}
|
|
18037
18105
|
function XlsxViewer(props) {
|
|
18038
|
-
const context =
|
|
18106
|
+
const context = React10.useContext(ViewerContext);
|
|
18039
18107
|
const controller = props.controller ?? context;
|
|
18040
|
-
return controller ? /* @__PURE__ */
|
|
18108
|
+
return controller ? /* @__PURE__ */ jsx7(BoundViewer, { props, controller }) : /* @__PURE__ */ jsx7(UncontrolledViewer, { ...props });
|
|
18041
18109
|
}
|
|
18042
18110
|
export {
|
|
18043
18111
|
DefaultXlsxToolbar,
|