@extend-ai/react-xlsx 0.23.2 → 0.24.1
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 +22 -2
- package/dist/{chunk-UICWNF5V.js → chunk-2TLD35UF.js} +3 -27
- package/dist/chunk-2TLD35UF.js.map +1 -0
- package/dist/{chunk-A3WA6ZLI.cjs → chunk-GP5SOQQH.cjs} +3 -29
- package/dist/chunk-GP5SOQQH.cjs.map +1 -0
- package/dist/{chunk-MEZOJBL5.js → chunk-HAV76TR2.js} +57 -1
- package/dist/{chunk-MEZOJBL5.js.map → chunk-HAV76TR2.js.map} +1 -1
- package/dist/{chunk-JJJZYWAL.js → chunk-MNIFKMIL.js} +57 -1
- package/dist/chunk-MNIFKMIL.js.map +1 -0
- package/dist/{chunk-3JFYU42O.js → chunk-Q6YY3AB4.js} +2 -28
- package/dist/chunk-Q6YY3AB4.js.map +1 -0
- package/dist/{chunk-FGJY2TIS.cjs → chunk-WW6G674Q.cjs} +2672 -2340
- package/dist/chunk-WW6G674Q.cjs.map +1 -0
- package/dist/{chunk-M7QVMFYT.js → chunk-XUHSQ3GF.js} +819 -487
- package/dist/chunk-XUHSQ3GF.js.map +1 -0
- package/dist/{chunk-JCSAS3M2.cjs → chunk-XZJLPW64.cjs} +2 -26
- package/dist/chunk-XZJLPW64.cjs.map +1 -0
- package/dist/{chunk-TMYAG7GY.cjs → chunk-YOLIVKZD.cjs} +57 -1
- package/dist/chunk-YOLIVKZD.cjs.map +1 -0
- package/dist/{chunk-R3FQM7V3.cjs → chunk-Z4WMURVU.cjs} +57 -1
- package/dist/chunk-Z4WMURVU.cjs.map +1 -0
- package/dist/duke-sheets-provenance.json +5 -5
- package/dist/{duke_sheets_wasm-TLSZAVKP.cjs → duke_sheets_wasm-GM4K5QQX.cjs} +57 -1
- package/dist/duke_sheets_wasm-GM4K5QQX.cjs.map +1 -0
- package/dist/{duke_sheets_wasm-V4J6QYIZ.js → duke_sheets_wasm-MYY4ZNUI.js} +57 -1
- package/dist/duke_sheets_wasm-MYY4ZNUI.js.map +1 -0
- package/dist/{duke_sheets_wasm-R7KXJNYL.js → duke_sheets_wasm-UXZ2KTVD.js} +57 -1
- package/dist/duke_sheets_wasm-UXZ2KTVD.js.map +1 -0
- package/dist/duke_sheets_wasm_bg.wasm +0 -0
- package/dist/index.cjs +805 -606
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -7
- package/dist/index.d.ts +53 -7
- package/dist/index.js +784 -585
- package/dist/index.js.map +1 -1
- package/dist/{internal-BVZRgYaH.d.ts → internal-D5HReXVR.d.cts} +114 -64
- package/dist/{internal-BVZRgYaH.d.cts → internal-D5HReXVR.d.ts} +114 -64
- package/dist/internal.cjs +4 -4
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +3 -3
- package/dist/{shared-chart-V24MOVXX.js → shared-chart-24MCGSFJ.js} +2 -2
- package/dist/{shared-chart-N44DT2QV.cjs → shared-chart-7E6KMGTG.cjs} +3 -3
- package/dist/{shared-chart-N44DT2QV.cjs.map → shared-chart-7E6KMGTG.cjs.map} +1 -1
- package/dist/{shared-chart-64L5EL3Z.js → shared-chart-CGEK7EAB.js} +2 -2
- package/dist/{shared-chart-BZTEPO7C.cjs → shared-chart-GKNMM72Q.cjs} +15 -15
- package/dist/{shared-chart-BZTEPO7C.cjs.map → shared-chart-GKNMM72Q.cjs.map} +1 -1
- package/dist/vanilla.cjs +4 -4
- package/dist/vanilla.d.cts +2 -2
- package/dist/vanilla.d.ts +2 -2
- package/dist/vanilla.js +3 -3
- package/dist/{workbook-runtime-OJDBGHMM.cjs → workbook-runtime-7WEPIK5Y.cjs} +85 -77
- package/dist/workbook-runtime-7WEPIK5Y.cjs.map +1 -0
- package/dist/{workbook-runtime-O3QY5UED.js → workbook-runtime-BAAYDYYK.js} +24 -16
- package/dist/workbook-runtime-BAAYDYYK.js.map +1 -0
- package/dist/{workbook-runtime-FXUSOOFT.js → workbook-runtime-FCKPXLTW.js} +24 -16
- package/dist/workbook-runtime-FCKPXLTW.js.map +1 -0
- package/dist/{workbook-runtime-2HYFRGZD.cjs → workbook-runtime-MOGSEJ5R.cjs} +83 -75
- package/dist/workbook-runtime-MOGSEJ5R.cjs.map +1 -0
- package/dist/xlsx-worker.js +23 -15
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-3JFYU42O.js.map +0 -1
- package/dist/chunk-A3WA6ZLI.cjs.map +0 -1
- package/dist/chunk-FGJY2TIS.cjs.map +0 -1
- package/dist/chunk-JCSAS3M2.cjs.map +0 -1
- package/dist/chunk-JJJZYWAL.js.map +0 -1
- package/dist/chunk-M7QVMFYT.js.map +0 -1
- package/dist/chunk-R3FQM7V3.cjs.map +0 -1
- package/dist/chunk-TMYAG7GY.cjs.map +0 -1
- package/dist/chunk-UICWNF5V.js.map +0 -1
- package/dist/duke_sheets_wasm-R7KXJNYL.js.map +0 -1
- package/dist/duke_sheets_wasm-TLSZAVKP.cjs.map +0 -1
- package/dist/duke_sheets_wasm-V4J6QYIZ.js.map +0 -1
- package/dist/workbook-runtime-2HYFRGZD.cjs.map +0 -1
- package/dist/workbook-runtime-FXUSOOFT.js.map +0 -1
- package/dist/workbook-runtime-O3QY5UED.js.map +0 -1
- package/dist/workbook-runtime-OJDBGHMM.cjs.map +0 -1
- /package/dist/{shared-chart-V24MOVXX.js.map → shared-chart-24MCGSFJ.js.map} +0 -0
- /package/dist/{shared-chart-64L5EL3Z.js.map → shared-chart-CGEK7EAB.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
XLSX_MAX_COLUMNS,
|
|
3
|
+
XLSX_MAX_ROWS,
|
|
2
4
|
applyChartSeriesFormula,
|
|
3
5
|
buildChartSeriesFormula,
|
|
4
6
|
emuToPixels,
|
|
@@ -25,8 +27,6 @@ import {
|
|
|
25
27
|
resolveWorkbookFillStyle,
|
|
26
28
|
resolveWorksheetDefaultColumnWidthPixels,
|
|
27
29
|
resolveWorksheetDefaultRowHeightPixels,
|
|
28
|
-
resolveWorksheetHiddenCols,
|
|
29
|
-
resolveWorksheetHiddenRows,
|
|
30
30
|
resolveWorksheetMergeMetadata,
|
|
31
31
|
restoreWorkerImageBlobs,
|
|
32
32
|
revokeWorkbookImageAssets,
|
|
@@ -36,13 +36,13 @@ import {
|
|
|
36
36
|
updateWorkbookChartDefinition,
|
|
37
37
|
updateWorkbookImageAnchor,
|
|
38
38
|
xlsxAnchorToDukeDrawingAnchor
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-2TLD35UF.js";
|
|
40
40
|
import {
|
|
41
41
|
formatMessage,
|
|
42
42
|
mergeMessages,
|
|
43
43
|
resolveMessages,
|
|
44
44
|
useXlsxMessages
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-MNIFKMIL.js";
|
|
46
46
|
import "./chunk-QXXS4J36.js";
|
|
47
47
|
import {
|
|
48
48
|
configureWorkbookArchiveDecoder,
|
|
@@ -52,6 +52,121 @@ import {
|
|
|
52
52
|
serializeWorkbookXml
|
|
53
53
|
} from "./chunk-67TEHWH5.js";
|
|
54
54
|
|
|
55
|
+
// src/selection-ranges.ts
|
|
56
|
+
function resolveFreezePanesCell(activeCell, selection) {
|
|
57
|
+
if (activeCell && selection && (activeCell.row < selection.start.row || activeCell.col < selection.start.col)) {
|
|
58
|
+
return selection.start;
|
|
59
|
+
}
|
|
60
|
+
return activeCell;
|
|
61
|
+
}
|
|
62
|
+
function subtractRange(area, cut) {
|
|
63
|
+
const top = Math.max(area.start.row, cut.start.row);
|
|
64
|
+
const bottom = Math.min(area.end.row, cut.end.row);
|
|
65
|
+
const left = Math.max(area.start.col, cut.start.col);
|
|
66
|
+
const right = Math.min(area.end.col, cut.end.col);
|
|
67
|
+
if (top > bottom || left > right) return [area];
|
|
68
|
+
const remaining = [];
|
|
69
|
+
if (area.start.row < top) remaining.push({ start: area.start, end: { row: top - 1, col: area.end.col } });
|
|
70
|
+
if (bottom < area.end.row) remaining.push({ start: { row: bottom + 1, col: area.start.col }, end: area.end });
|
|
71
|
+
if (area.start.col < left) remaining.push({ start: { row: top, col: area.start.col }, end: { row: bottom, col: left - 1 } });
|
|
72
|
+
if (right < area.end.col) remaining.push({ start: { row: top, col: right + 1 }, end: { row: bottom, col: area.end.col } });
|
|
73
|
+
return remaining;
|
|
74
|
+
}
|
|
75
|
+
function addSelectionRange(areas, range) {
|
|
76
|
+
return [...areas.flatMap((area) => subtractRange(area, range)), range];
|
|
77
|
+
}
|
|
78
|
+
function clipboardBands(areas) {
|
|
79
|
+
const first = areas[0];
|
|
80
|
+
if (!first) return null;
|
|
81
|
+
const sameExtent = (axis) => areas.every((area) => area.start[axis] === first.start[axis] && area.end[axis] === first.end[axis]);
|
|
82
|
+
const bands = (axis, ranges) => ranges.map((range) => ({ start: range.start[axis], end: range.end[axis] })).sort((a, b) => a.start - b.start);
|
|
83
|
+
if (sameExtent("col")) return { rows: bands("row", areas), cols: bands("col", [first]) };
|
|
84
|
+
if (sameExtent("row")) return { rows: bands("row", [first]), cols: bands("col", areas) };
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
function* bandIndices(bands) {
|
|
88
|
+
let offset = 0;
|
|
89
|
+
for (const band of bands) {
|
|
90
|
+
for (let index = band.start; index <= band.end; index++) {
|
|
91
|
+
yield { index, offset: offset++, remaining: band.end - index + 1 };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/read-only-layout.ts
|
|
97
|
+
function changedVisibilityRanges(existing, ranges, hidden, fromSelection) {
|
|
98
|
+
if (!hidden && !existing.size) return [];
|
|
99
|
+
let firstVisible = 0;
|
|
100
|
+
if (!hidden && fromSelection) {
|
|
101
|
+
while (existing.has(firstVisible)) firstVisible++;
|
|
102
|
+
}
|
|
103
|
+
const changed = [];
|
|
104
|
+
for (const range of ranges) {
|
|
105
|
+
const start = firstVisible > 0 && range.start === firstVisible ? 0 : range.start;
|
|
106
|
+
for (let index = start; index <= range.end; index++) {
|
|
107
|
+
if (existing.has(index) !== hidden) {
|
|
108
|
+
changed.push({ start, end: range.end });
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return changed;
|
|
114
|
+
}
|
|
115
|
+
function nextVisibleIndex(index, limit, isHidden) {
|
|
116
|
+
let next = index;
|
|
117
|
+
while (next < limit && isHidden(next)) next++;
|
|
118
|
+
if (next < limit) return next;
|
|
119
|
+
next = index - 1;
|
|
120
|
+
while (next >= 0 && isHidden(next)) next--;
|
|
121
|
+
return next;
|
|
122
|
+
}
|
|
123
|
+
function visibleAxis(hidden, max, originalIndices, originalSizes, overrides, defaultSize) {
|
|
124
|
+
const indices = [];
|
|
125
|
+
const sizes = [];
|
|
126
|
+
let offset = 0;
|
|
127
|
+
for (let index = 0; index <= max; index++) {
|
|
128
|
+
const originalSize = originalIndices[offset] === index ? originalSizes[offset++] : void 0;
|
|
129
|
+
if (hidden.has(index)) continue;
|
|
130
|
+
indices.push(index);
|
|
131
|
+
sizes.push(originalSize ?? overrides[index] ?? defaultSize);
|
|
132
|
+
}
|
|
133
|
+
return { indices, sizes };
|
|
134
|
+
}
|
|
135
|
+
function applyReadOnlyLayout(sheet, layout) {
|
|
136
|
+
if (!layout) return sheet;
|
|
137
|
+
const view = { ...sheet };
|
|
138
|
+
if (layout.freezePanes !== void 0) view.freezePanes = layout.freezePanes;
|
|
139
|
+
if (layout.hiddenRows) {
|
|
140
|
+
const rows = visibleAxis(
|
|
141
|
+
layout.hiddenRows,
|
|
142
|
+
sheet.maxUsedRow,
|
|
143
|
+
sheet.visibleRows,
|
|
144
|
+
sheet.rowHeights,
|
|
145
|
+
sheet.rowHeightOverridesPx,
|
|
146
|
+
sheet.defaultRowHeightPx
|
|
147
|
+
);
|
|
148
|
+
view.hiddenRows = Array.from(layout.hiddenRows).sort((a, b) => a - b);
|
|
149
|
+
view.visibleRows = rows.indices;
|
|
150
|
+
view.rowHeights = rows.sizes;
|
|
151
|
+
view.rowCount = rows.indices.length;
|
|
152
|
+
}
|
|
153
|
+
if (layout.hiddenCols) {
|
|
154
|
+
const cols = visibleAxis(
|
|
155
|
+
layout.hiddenCols,
|
|
156
|
+
sheet.maxUsedCol,
|
|
157
|
+
sheet.visibleCols,
|
|
158
|
+
sheet.colWidths,
|
|
159
|
+
sheet.colWidthOverridesPx,
|
|
160
|
+
sheet.defaultColWidthPx
|
|
161
|
+
);
|
|
162
|
+
view.hiddenCols = Array.from(layout.hiddenCols).sort((a, b) => a - b);
|
|
163
|
+
view.visibleCols = cols.indices;
|
|
164
|
+
view.colWidths = cols.sizes;
|
|
165
|
+
view.colCount = cols.indices.length;
|
|
166
|
+
}
|
|
167
|
+
return view;
|
|
168
|
+
}
|
|
169
|
+
|
|
55
170
|
// src/merged-range-lookup.ts
|
|
56
171
|
function createMergedRangeLookup(ranges) {
|
|
57
172
|
const normalizedRanges = [];
|
|
@@ -921,7 +1036,7 @@ var XlsxWorkerClient = class {
|
|
|
921
1036
|
}
|
|
922
1037
|
async getMainRuntime() {
|
|
923
1038
|
if (this.disposed) throw createAbortError();
|
|
924
|
-
this.mainRuntime ??= import("./workbook-runtime-
|
|
1039
|
+
this.mainRuntime ??= import("./workbook-runtime-BAAYDYYK.js").then(({ createWorkbookRuntime }) => createWorkbookRuntime());
|
|
925
1040
|
const runtime = await this.mainRuntime;
|
|
926
1041
|
if (this.disposed) {
|
|
927
1042
|
runtime.dispose();
|
|
@@ -1150,8 +1265,8 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
1150
1265
|
maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
|
|
1151
1266
|
maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
|
|
1152
1267
|
mergedRanges: mergeMetadata.mergedRanges,
|
|
1153
|
-
hiddenCols:
|
|
1154
|
-
hiddenRows:
|
|
1268
|
+
hiddenCols: Array.from(worksheet.hiddenColumns),
|
|
1269
|
+
hiddenRows: Array.from(worksheet.hiddenRows),
|
|
1155
1270
|
minUsedCol: -1,
|
|
1156
1271
|
minUsedRow: -1,
|
|
1157
1272
|
maxUsedCol: -1,
|
|
@@ -1240,8 +1355,8 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
1240
1355
|
maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
|
|
1241
1356
|
maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
|
|
1242
1357
|
mergedRanges: mergeMetadata.mergedRanges,
|
|
1243
|
-
hiddenCols:
|
|
1244
|
-
hiddenRows:
|
|
1358
|
+
hiddenCols: Array.from(worksheet.hiddenColumns),
|
|
1359
|
+
hiddenRows: Array.from(worksheet.hiddenRows),
|
|
1245
1360
|
minUsedCol: minCol,
|
|
1246
1361
|
minUsedRow: minRow,
|
|
1247
1362
|
maxUsedCol: maxCol,
|
|
@@ -1897,6 +2012,8 @@ function downloadUrl(src, fileName) {
|
|
|
1897
2012
|
}
|
|
1898
2013
|
function useXlsxViewerController(options2) {
|
|
1899
2014
|
const {
|
|
2015
|
+
allowFreezeInReadOnly = false,
|
|
2016
|
+
allowHideInReadOnly = false,
|
|
1900
2017
|
allowResizeInReadOnly = false,
|
|
1901
2018
|
deferLoadingAboveBytes = DEFAULT_DEFER_LOADING_ABOVE_BYTES,
|
|
1902
2019
|
file,
|
|
@@ -1915,7 +2032,8 @@ function useXlsxViewerController(options2) {
|
|
|
1915
2032
|
const [isLoading, setIsLoading] = React.useState(Boolean(file ?? src));
|
|
1916
2033
|
const [error, setError] = React.useState(null);
|
|
1917
2034
|
const [workbook, setWorkbook] = React.useState(null);
|
|
1918
|
-
const [
|
|
2035
|
+
const [readOnlyLayouts, setReadOnlyLayouts] = React.useState({});
|
|
2036
|
+
const [workbookSheets, setSheets] = React.useState([]);
|
|
1919
2037
|
const [chartsByWorkbookSheetIndex, setChartsByWorkbookSheetIndex] = React.useState([]);
|
|
1920
2038
|
const [chartsheets, setChartsheets] = React.useState([]);
|
|
1921
2039
|
const [tabs, setTabs] = React.useState([]);
|
|
@@ -1935,7 +2053,11 @@ function useXlsxViewerController(options2) {
|
|
|
1935
2053
|
const [activeTabIndex, setActiveTabIndexState] = React.useState(0);
|
|
1936
2054
|
const [zoomScaleOverridesByTabId, setZoomScaleOverridesByTabId] = React.useState({});
|
|
1937
2055
|
const [activeCell, setActiveCell] = React.useState(null);
|
|
1938
|
-
const [
|
|
2056
|
+
const [selectionRanges, setSelectionRanges] = React.useState([]);
|
|
2057
|
+
const selection = selectionRanges.at(-1) ?? null;
|
|
2058
|
+
const setSelection = React.useCallback((range) => {
|
|
2059
|
+
setSelectionRanges(range ? [range] : []);
|
|
2060
|
+
}, []);
|
|
1939
2061
|
const [highlightedRanges, setHighlightedRanges] = React.useState([]);
|
|
1940
2062
|
const [selectedChartId, setSelectedChartId] = React.useState(null);
|
|
1941
2063
|
const [selectedChartElement, setSelectedChartElement] = React.useState(null);
|
|
@@ -1966,6 +2088,7 @@ function useXlsxViewerController(options2) {
|
|
|
1966
2088
|
const displayFileName = React.useMemo(() => resolveDisplayFileName(src, fileName), [fileName, src]);
|
|
1967
2089
|
const shouldDeferLoading = deferLoadingAboveBytes > 0;
|
|
1968
2090
|
const readOnly = requestedReadOnly || forcedReadOnly;
|
|
2091
|
+
const sheets = React.useMemo(() => readOnly ? workbookSheets.map((sheet) => applyReadOnlyLayout(sheet, readOnlyLayouts[sheet.workbookSheetIndex])) : workbookSheets, [readOnly, readOnlyLayouts, workbookSheets]);
|
|
1969
2092
|
const drawingMutationEpoch = React.useRef(0);
|
|
1970
2093
|
const drawingMutationState = React.useRef({ workbook, revision, readOnly, activeCell, activeSheetIndex });
|
|
1971
2094
|
drawingMutationState.current = { workbook, revision, readOnly, activeCell, activeSheetIndex };
|
|
@@ -2127,6 +2250,7 @@ function useXlsxViewerController(options2) {
|
|
|
2127
2250
|
}, [disposeWorkerClient]);
|
|
2128
2251
|
React.useEffect(() => {
|
|
2129
2252
|
loadGenerationRef.current += 1;
|
|
2253
|
+
setReadOnlyLayouts({});
|
|
2130
2254
|
if (!file && !src) {
|
|
2131
2255
|
disposeWorkerClient();
|
|
2132
2256
|
setForcedReadOnly(false);
|
|
@@ -2696,23 +2820,20 @@ function useXlsxViewerController(options2) {
|
|
|
2696
2820
|
}, [activeSheet, getActiveWorksheet, locale]);
|
|
2697
2821
|
const getClipboardData = React.useCallback(() => {
|
|
2698
2822
|
const worksheet = getActiveWorksheet();
|
|
2699
|
-
const
|
|
2700
|
-
if (!worksheet || !
|
|
2701
|
-
return null;
|
|
2702
|
-
}
|
|
2703
|
-
const normalized = normalizeRange(targetRange);
|
|
2823
|
+
const bands = clipboardBands(selectionRanges);
|
|
2824
|
+
if (!worksheet || !bands) return null;
|
|
2704
2825
|
const rows = [];
|
|
2705
2826
|
const htmlRows = [];
|
|
2706
2827
|
const payload = {
|
|
2707
2828
|
cells: [],
|
|
2708
|
-
cols:
|
|
2829
|
+
cols: bands.cols.reduce((total, band) => total + band.end - band.start + 1, 0),
|
|
2709
2830
|
merges: [],
|
|
2710
|
-
rows:
|
|
2831
|
+
rows: bands.rows.reduce((total, band) => total + band.end - band.start + 1, 0)
|
|
2711
2832
|
};
|
|
2712
|
-
for (
|
|
2833
|
+
for (const { index: row2, offset: rowOffset, remaining: rowsRemaining } of bandIndices(bands.rows)) {
|
|
2713
2834
|
const textCells = [];
|
|
2714
2835
|
const htmlCells = [];
|
|
2715
|
-
for (
|
|
2836
|
+
for (const { index: col, offset: colOffset, remaining: colsRemaining } of bandIndices(bands.cols)) {
|
|
2716
2837
|
if (worksheet.isMergedSecondary(row2, col)) {
|
|
2717
2838
|
textCells.push("");
|
|
2718
2839
|
continue;
|
|
@@ -2779,19 +2900,19 @@ function useXlsxViewerController(options2) {
|
|
|
2779
2900
|
if (border?.left?.style && border.left.style !== "none") {
|
|
2780
2901
|
cellStyles.push(`border-left:${mapBorder(border.left)}`);
|
|
2781
2902
|
}
|
|
2782
|
-
const rowSpan = Math.min(merge?.rowSpan ?? 1,
|
|
2783
|
-
const colSpan = Math.min(merge?.colSpan ?? 1,
|
|
2903
|
+
const rowSpan = Math.min(merge?.rowSpan ?? 1, rowsRemaining);
|
|
2904
|
+
const colSpan = Math.min(merge?.colSpan ?? 1, colsRemaining);
|
|
2784
2905
|
payload.cells.push({
|
|
2785
|
-
colOffset
|
|
2906
|
+
colOffset,
|
|
2786
2907
|
formula,
|
|
2787
|
-
rowOffset
|
|
2908
|
+
rowOffset,
|
|
2788
2909
|
value
|
|
2789
2910
|
});
|
|
2790
2911
|
if (rowSpan > 1 || colSpan > 1) {
|
|
2791
2912
|
payload.merges.push({
|
|
2792
|
-
colOffset
|
|
2913
|
+
colOffset,
|
|
2793
2914
|
colSpan,
|
|
2794
|
-
rowOffset
|
|
2915
|
+
rowOffset,
|
|
2795
2916
|
rowSpan
|
|
2796
2917
|
});
|
|
2797
2918
|
}
|
|
@@ -2808,7 +2929,7 @@ function useXlsxViewerController(options2) {
|
|
|
2808
2929
|
structured: JSON.stringify(payload),
|
|
2809
2930
|
text: rows.join("\n")
|
|
2810
2931
|
};
|
|
2811
|
-
}, [
|
|
2932
|
+
}, [activeSheet, getActiveWorksheet, getCellDisplayValue2, selectionRanges]);
|
|
2812
2933
|
React.useEffect(() => {
|
|
2813
2934
|
if (!isWorkerBacked || !deferredMetadataSheet || !deferredMetadataCell) {
|
|
2814
2935
|
return;
|
|
@@ -2839,7 +2960,7 @@ function useXlsxViewerController(options2) {
|
|
|
2839
2960
|
};
|
|
2840
2961
|
}, [deferredMetadataCell, deferredMetadataSheet, getCellSnapshotAsync, isWorkerBacked, locale]);
|
|
2841
2962
|
const activeCellAddress = React.useMemo(() => activeCell ? cellAddressToA1(activeCell) : null, [activeCell]);
|
|
2842
|
-
const selectedRangeAddress = React.useMemo(() =>
|
|
2963
|
+
const selectedRangeAddress = React.useMemo(() => selectionRanges.map(rangeToA1).join(",") || null, [selectionRanges]);
|
|
2843
2964
|
const selectedValue = React.useMemo(
|
|
2844
2965
|
() => getCellDisplayValue2(deferredMetadataCell),
|
|
2845
2966
|
[deferredMetadataCell, getCellDisplayValue2, revision, workerCellSnapshotRevision]
|
|
@@ -2889,10 +3010,10 @@ function useXlsxViewerController(options2) {
|
|
|
2889
3010
|
bytes: workbook.exportSnapshot(),
|
|
2890
3011
|
assets: imageAssetsRef.current ? structuredClone(imageAssetsRef.current) : null,
|
|
2891
3012
|
origins: structuredClone(sheetOriginsRef.current),
|
|
2892
|
-
|
|
3013
|
+
selectionRanges,
|
|
2893
3014
|
sortState
|
|
2894
3015
|
};
|
|
2895
|
-
}, [activeCell, activeSheetIndex,
|
|
3016
|
+
}, [activeCell, activeSheetIndex, selectionRanges, sortState, workbook]);
|
|
2896
3017
|
const captureCellMutationState = React.useCallback((cell) => {
|
|
2897
3018
|
const worksheet = getActiveWorksheet();
|
|
2898
3019
|
if (!worksheet) {
|
|
@@ -2934,9 +3055,9 @@ function useXlsxViewerController(options2) {
|
|
|
2934
3055
|
setActiveTabIndexState(nextTabIndex);
|
|
2935
3056
|
}
|
|
2936
3057
|
setActiveCell(entry.activeCell);
|
|
2937
|
-
|
|
3058
|
+
setSelectionRanges(entry.selectionRanges);
|
|
2938
3059
|
setSortState(entry.sortState);
|
|
2939
|
-
selectionAnchorRef.current = entry.
|
|
3060
|
+
selectionAnchorRef.current = entry.selectionRanges.at(-1)?.start ?? entry.activeCell;
|
|
2940
3061
|
setRevision((current) => current + 1);
|
|
2941
3062
|
}, [setChartAssets, setImageAssets]);
|
|
2942
3063
|
const applyCellEditHistoryEntry = React.useCallback((entry, direction) => {
|
|
@@ -2956,8 +3077,8 @@ function useXlsxViewerController(options2) {
|
|
|
2956
3077
|
setActiveSheetIndexState(visibleSheetIndex);
|
|
2957
3078
|
}
|
|
2958
3079
|
setActiveCell(nextActiveCell);
|
|
2959
|
-
|
|
2960
|
-
selectionAnchorRef.current = nextSelection
|
|
3080
|
+
setSelectionRanges(nextSelection);
|
|
3081
|
+
selectionAnchorRef.current = nextSelection.at(-1)?.start ?? nextActiveCell;
|
|
2961
3082
|
isApplyingHistoryRef.current = false;
|
|
2962
3083
|
}, [maybeRecalculateWorkbook, refreshWorkbookState, sheets, workbook]);
|
|
2963
3084
|
const applyRangeEditHistoryEntry = React.useCallback((entry, direction) => {
|
|
@@ -2979,8 +3100,8 @@ function useXlsxViewerController(options2) {
|
|
|
2979
3100
|
setActiveSheetIndexState(visibleSheetIndex);
|
|
2980
3101
|
}
|
|
2981
3102
|
setActiveCell(nextActiveCell);
|
|
2982
|
-
|
|
2983
|
-
selectionAnchorRef.current = nextSelection
|
|
3103
|
+
setSelectionRanges(nextSelection);
|
|
3104
|
+
selectionAnchorRef.current = nextSelection.at(-1)?.start ?? nextActiveCell;
|
|
2984
3105
|
isApplyingHistoryRef.current = false;
|
|
2985
3106
|
}, [maybeRecalculateWorkbook, refreshWorkbookState, sheets, workbook]);
|
|
2986
3107
|
const recordHistoryBeforeMutation = React.useCallback(() => {
|
|
@@ -3239,13 +3360,13 @@ function useXlsxViewerController(options2) {
|
|
|
3239
3360
|
after,
|
|
3240
3361
|
before,
|
|
3241
3362
|
cell,
|
|
3242
|
-
selectionAfter: { start: cell, end: cell },
|
|
3243
|
-
selectionBefore:
|
|
3363
|
+
selectionAfter: [{ start: cell, end: cell }],
|
|
3364
|
+
selectionBefore: selectionRanges,
|
|
3244
3365
|
sheetIndex: activeSheet.workbookSheetIndex
|
|
3245
3366
|
});
|
|
3246
3367
|
redoStackRef.current = [];
|
|
3247
3368
|
setHistoryRevision((current) => current + 1);
|
|
3248
|
-
}, [activeCell, activeSheet,
|
|
3369
|
+
}, [activeCell, activeSheet, selectionRanges]);
|
|
3249
3370
|
const recordRangeEditHistory = React.useCallback((mutations, selectionAfter, activeCellAfter, sortStateAfter = sortState) => {
|
|
3250
3371
|
if (!activeSheet || isApplyingHistoryRef.current || mutations.length === 0 && sortStateAfter === sortState) {
|
|
3251
3372
|
return;
|
|
@@ -3256,14 +3377,14 @@ function useXlsxViewerController(options2) {
|
|
|
3256
3377
|
activeCellBefore: activeCell,
|
|
3257
3378
|
mutations,
|
|
3258
3379
|
selectionAfter,
|
|
3259
|
-
selectionBefore:
|
|
3380
|
+
selectionBefore: selectionRanges,
|
|
3260
3381
|
sheetIndex: activeSheet.workbookSheetIndex,
|
|
3261
3382
|
sortStateAfter,
|
|
3262
3383
|
sortStateBefore: sortState
|
|
3263
3384
|
});
|
|
3264
3385
|
redoStackRef.current = [];
|
|
3265
3386
|
setHistoryRevision((current) => current + 1);
|
|
3266
|
-
}, [activeCell, activeSheet,
|
|
3387
|
+
}, [activeCell, activeSheet, selectionRanges, sortState]);
|
|
3267
3388
|
const sortTable = React.useCallback((tableName, columnIndex, direction) => {
|
|
3268
3389
|
const worksheet = getActiveWorksheet();
|
|
3269
3390
|
const targetTable = tables.find((table) => table.name === tableName || table.displayName === tableName);
|
|
@@ -3322,7 +3443,7 @@ function useXlsxViewerController(options2) {
|
|
|
3322
3443
|
return;
|
|
3323
3444
|
}
|
|
3324
3445
|
setSortState(nextSortState);
|
|
3325
|
-
recordRangeEditHistory([],
|
|
3446
|
+
recordRangeEditHistory([], selectionRanges, activeCell, nextSortState);
|
|
3326
3447
|
return;
|
|
3327
3448
|
}
|
|
3328
3449
|
const mutations = [];
|
|
@@ -3351,7 +3472,7 @@ function useXlsxViewerController(options2) {
|
|
|
3351
3472
|
maybeRecalculateWorkbook(workbook);
|
|
3352
3473
|
refreshWorkbookState(workbook);
|
|
3353
3474
|
setSortState(nextSortState);
|
|
3354
|
-
recordRangeEditHistory(mutations,
|
|
3475
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell, nextSortState);
|
|
3355
3476
|
}, [
|
|
3356
3477
|
intersectsPivot,
|
|
3357
3478
|
activeCell,
|
|
@@ -3361,7 +3482,7 @@ function useXlsxViewerController(options2) {
|
|
|
3361
3482
|
readOnly,
|
|
3362
3483
|
recordRangeEditHistory,
|
|
3363
3484
|
refreshWorkbookState,
|
|
3364
|
-
|
|
3485
|
+
selectionRanges,
|
|
3365
3486
|
sortState,
|
|
3366
3487
|
tables,
|
|
3367
3488
|
workbook
|
|
@@ -3406,106 +3527,149 @@ function useXlsxViewerController(options2) {
|
|
|
3406
3527
|
}
|
|
3407
3528
|
setShouldAutoCalculate(false);
|
|
3408
3529
|
}, [refreshWorkbookState, workbook]);
|
|
3409
|
-
const applyReadOnlyResizeOverride = React.useCallback((axis,
|
|
3410
|
-
if (!activeSheet)
|
|
3411
|
-
return;
|
|
3412
|
-
}
|
|
3530
|
+
const applyReadOnlyResizeOverride = React.useCallback((axis, indices, sizePx) => {
|
|
3531
|
+
if (!activeSheet) return;
|
|
3413
3532
|
const contentSizePx = activeSheet.officeLayout ? sizePx : resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
|
|
3414
|
-
const
|
|
3415
|
-
setSheets((
|
|
3416
|
-
if (sheet.workbookSheetIndex !==
|
|
3417
|
-
|
|
3418
|
-
}
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
};
|
|
3424
|
-
const nextColWidths = [...sheet.colWidths];
|
|
3425
|
-
const visibleColIndex = sheet.visibleCols.indexOf(actualIndex);
|
|
3426
|
-
if (visibleColIndex >= 0) {
|
|
3427
|
-
nextColWidths[visibleColIndex] = contentSizePx;
|
|
3428
|
-
}
|
|
3429
|
-
return {
|
|
3430
|
-
...sheet,
|
|
3431
|
-
colWidthOverridesPx: nextColWidthOverridesPx,
|
|
3432
|
-
colWidths: nextColWidths
|
|
3433
|
-
};
|
|
3434
|
-
}
|
|
3435
|
-
const nextRowHeightOverridesPx = {
|
|
3436
|
-
...sheet.rowHeightOverridesPx,
|
|
3437
|
-
[actualIndex]: contentSizePx
|
|
3438
|
-
};
|
|
3439
|
-
const nextRowHeights = [...sheet.rowHeights];
|
|
3440
|
-
const visibleRowIndex = sheet.visibleRows.indexOf(actualIndex);
|
|
3441
|
-
if (visibleRowIndex >= 0) {
|
|
3442
|
-
nextRowHeights[visibleRowIndex] = contentSizePx;
|
|
3443
|
-
}
|
|
3444
|
-
return {
|
|
3445
|
-
...sheet,
|
|
3446
|
-
rowHeightOverridesPx: nextRowHeightOverridesPx,
|
|
3447
|
-
rowHeights: nextRowHeights
|
|
3448
|
-
};
|
|
3533
|
+
const selected = new Set(indices);
|
|
3534
|
+
setSheets((current) => current.map((sheet) => {
|
|
3535
|
+
if (sheet.workbookSheetIndex !== activeSheet.workbookSheetIndex) return sheet;
|
|
3536
|
+
const isRow = axis === "row";
|
|
3537
|
+
const overrides = { ...isRow ? sheet.rowHeightOverridesPx : sheet.colWidthOverridesPx };
|
|
3538
|
+
for (const index of selected) overrides[index] = contentSizePx;
|
|
3539
|
+
const visible = isRow ? sheet.visibleRows : sheet.visibleCols;
|
|
3540
|
+
const sizes = (isRow ? sheet.rowHeights : sheet.colWidths).map((size, offset) => selected.has(visible[offset]) ? contentSizePx : size);
|
|
3541
|
+
return isRow ? { ...sheet, rowHeightOverridesPx: overrides, rowHeights: sizes } : { ...sheet, colWidthOverridesPx: overrides, colWidths: sizes };
|
|
3449
3542
|
}));
|
|
3450
3543
|
setRevision((current) => current + 1);
|
|
3451
3544
|
}, [activeSheet]);
|
|
3452
|
-
const
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
if (
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
if (
|
|
3545
|
+
const canChangeVisibility = Boolean(activeSheet && !isLoading && (readOnly ? allowHideInReadOnly : workbook));
|
|
3546
|
+
const canChangeFreezePanes = Boolean(activeSheet && !isLoading && (readOnly ? allowFreezeInReadOnly : workbook));
|
|
3547
|
+
const activeLayout = activeSheet && readOnly ? readOnlyLayouts[activeSheet.workbookSheetIndex] : void 0;
|
|
3548
|
+
React.useEffect(() => {
|
|
3549
|
+
if (!activeCell || !activeLayout) return;
|
|
3550
|
+
const { hiddenRows, hiddenCols } = activeLayout;
|
|
3551
|
+
const row2 = hiddenRows?.has(activeCell.row) ? nextVisibleIndex(activeCell.row, XLSX_MAX_ROWS, (index) => hiddenRows.has(index)) : activeCell.row;
|
|
3552
|
+
const col = hiddenCols?.has(activeCell.col) ? nextVisibleIndex(activeCell.col, XLSX_MAX_COLUMNS, (index) => hiddenCols.has(index)) : activeCell.col;
|
|
3553
|
+
if (row2 === activeCell.row && col === activeCell.col) return;
|
|
3554
|
+
const cell = row2 < 0 || col < 0 ? null : { row: row2, col };
|
|
3555
|
+
setActiveCell(cell);
|
|
3556
|
+
setSelection(cell && { start: cell, end: cell });
|
|
3557
|
+
selectionAnchorRef.current = cell;
|
|
3558
|
+
}, [activeCell, activeLayout, setSelection]);
|
|
3559
|
+
const setAxisHidden = React.useCallback((axis, hidden, start, end = start) => {
|
|
3560
|
+
if (!canChangeVisibility || !activeSheet) return;
|
|
3561
|
+
const limit = axis === "row" ? XLSX_MAX_ROWS : XLSX_MAX_COLUMNS;
|
|
3562
|
+
const fromSelection = start === void 0 && end === void 0;
|
|
3563
|
+
const ranges = fromSelection ? selectionRanges.map((area) => ({ start: area.start[axis], end: area.end[axis] })) : [{ start: start ?? -1, end: end ?? -1 }];
|
|
3564
|
+
if (!ranges.length || ranges.some((range) => !Number.isInteger(range.start) || !Number.isInteger(range.end) || range.start < 0 || range.end < range.start || range.end >= limit)) return;
|
|
3565
|
+
const sheetIndex = activeSheet.workbookSheetIndex;
|
|
3566
|
+
if (readOnly) {
|
|
3567
|
+
const key = axis === "row" ? "hiddenRows" : "hiddenCols";
|
|
3568
|
+
setReadOnlyLayouts((current) => {
|
|
3569
|
+
const layout = current[sheetIndex];
|
|
3570
|
+
const existing = layout?.[key] ?? new Set(activeSheet[key]);
|
|
3571
|
+
const changes = changedVisibilityRanges(existing, ranges, hidden, fromSelection);
|
|
3572
|
+
if (!changes.length) return current;
|
|
3573
|
+
const next = new Set(existing);
|
|
3574
|
+
for (const range of changes) {
|
|
3575
|
+
for (let index = range.start; index <= range.end; index++) {
|
|
3576
|
+
if (hidden) next.add(index);
|
|
3577
|
+
else next.delete(index);
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
return { ...current, [sheetIndex]: { ...layout, [key]: next } };
|
|
3581
|
+
});
|
|
3461
3582
|
return;
|
|
3462
3583
|
}
|
|
3463
|
-
|
|
3464
|
-
const worksheet = workbook.getSheet(
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
)
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3584
|
+
if (!workbook) return;
|
|
3585
|
+
const worksheet = workbook.getSheet(sheetIndex);
|
|
3586
|
+
try {
|
|
3587
|
+
const existing = new Set(axis === "row" ? worksheet.hiddenRows : worksheet.hiddenColumns);
|
|
3588
|
+
const changes = changedVisibilityRanges(existing, ranges, hidden, fromSelection);
|
|
3589
|
+
if (!changes.length) return;
|
|
3590
|
+
recordHistoryBeforeMutation();
|
|
3591
|
+
for (const range of changes) {
|
|
3592
|
+
if (axis === "row") worksheet.setRowsHidden(range.start, range.end, hidden);
|
|
3593
|
+
else worksheet.setColumnsHidden(range.start, range.end, hidden);
|
|
3594
|
+
}
|
|
3595
|
+
if (hidden && activeCell && changes.some((range) => range.start <= activeCell[axis] && activeCell[axis] <= range.end)) {
|
|
3596
|
+
const index = nextVisibleIndex(
|
|
3597
|
+
activeCell[axis],
|
|
3598
|
+
limit,
|
|
3599
|
+
(value) => axis === "row" ? worksheet.isRowHidden(value) : worksheet.isColumnHidden(value)
|
|
3600
|
+
);
|
|
3601
|
+
if (index >= 0) {
|
|
3602
|
+
const cell = { ...activeCell, [axis]: index };
|
|
3603
|
+
setActiveCell(cell);
|
|
3604
|
+
setSelection({ start: cell, end: cell });
|
|
3605
|
+
selectionAnchorRef.current = cell;
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
refreshWorkbookState(workbook);
|
|
3609
|
+
} finally {
|
|
3610
|
+
worksheet.free();
|
|
3611
|
+
}
|
|
3612
|
+
}, [activeCell, activeSheet, canChangeVisibility, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selectionRanges, setSelection, workbook]);
|
|
3613
|
+
const hideRows = React.useCallback((start, end) => setAxisHidden("row", true, start, end), [setAxisHidden]);
|
|
3614
|
+
const unhideRows = React.useCallback((start, end) => setAxisHidden("row", false, start, end), [setAxisHidden]);
|
|
3615
|
+
const hideColumns = React.useCallback((start, end) => setAxisHidden("col", true, start, end), [setAxisHidden]);
|
|
3616
|
+
const unhideColumns = React.useCallback((start, end) => setAxisHidden("col", false, start, end), [setAxisHidden]);
|
|
3617
|
+
const setFreezeBoundary = React.useCallback((cell) => {
|
|
3618
|
+
if (!canChangeFreezePanes || !activeSheet) return;
|
|
3619
|
+
const { row: row2, col } = cell;
|
|
3620
|
+
if (!Number.isInteger(row2) || row2 < 0 || row2 >= XLSX_MAX_ROWS || !Number.isInteger(col) || col < 0 || col >= XLSX_MAX_COLUMNS) return;
|
|
3621
|
+
const sheetIndex = activeSheet.workbookSheetIndex;
|
|
3622
|
+
if (readOnly) {
|
|
3623
|
+
const freezePanes2 = row2 || col ? { row: row2, col } : null;
|
|
3624
|
+
setReadOnlyLayouts((current) => ({ ...current, [sheetIndex]: { ...current[sheetIndex], freezePanes: freezePanes2 } }));
|
|
3484
3625
|
return;
|
|
3485
3626
|
}
|
|
3627
|
+
if (!workbook) return;
|
|
3628
|
+
const worksheet = workbook.getSheet(sheetIndex);
|
|
3629
|
+
try {
|
|
3630
|
+
const current = parseWorksheetFreezePanes(worksheet);
|
|
3631
|
+
if (row2 === (current?.row ?? 0) && col === (current?.col ?? 0)) return;
|
|
3632
|
+
recordHistoryBeforeMutation();
|
|
3633
|
+
worksheet.setFreezePanes(row2, col);
|
|
3634
|
+
refreshWorkbookState(workbook);
|
|
3635
|
+
} finally {
|
|
3636
|
+
worksheet.free();
|
|
3637
|
+
}
|
|
3638
|
+
}, [activeSheet, canChangeFreezePanes, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
|
|
3639
|
+
const freezeCell = resolveFreezePanesCell(activeCell, selection);
|
|
3640
|
+
const canFreezePanes = Boolean(canChangeFreezePanes && freezeCell && (freezeCell.row > 0 || freezeCell.col > 0));
|
|
3641
|
+
const freezePanes = React.useCallback((cell = freezeCell) => {
|
|
3642
|
+
if (cell) setFreezeBoundary(cell);
|
|
3643
|
+
}, [freezeCell, setFreezeBoundary]);
|
|
3644
|
+
const unfreezePanes = React.useCallback(() => setFreezeBoundary({ row: 0, col: 0 }), [setFreezeBoundary]);
|
|
3645
|
+
const resizeAxis = React.useCallback((axis, target, sizePx) => {
|
|
3646
|
+
if (!canResize || !activeSheet || !Number.isFinite(sizePx)) return;
|
|
3647
|
+
const indices = typeof target === "number" ? [target] : target;
|
|
3648
|
+
const limit = axis === "row" ? XLSX_MAX_ROWS : XLSX_MAX_COLUMNS;
|
|
3649
|
+
if (!indices.length || indices.some((index) => !Number.isInteger(index) || index < 0 || index >= limit)) return;
|
|
3486
3650
|
if (isWorkerBacked) {
|
|
3487
|
-
applyReadOnlyResizeOverride(
|
|
3488
|
-
return;
|
|
3489
|
-
}
|
|
3490
|
-
if (!workbook) {
|
|
3651
|
+
applyReadOnlyResizeOverride(axis, indices, sizePx);
|
|
3491
3652
|
return;
|
|
3492
3653
|
}
|
|
3493
|
-
|
|
3654
|
+
if (!workbook) return;
|
|
3494
3655
|
const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3656
|
+
try {
|
|
3657
|
+
recordHistoryBeforeMutation();
|
|
3658
|
+
const contentPx = resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
|
|
3659
|
+
if (axis === "row") {
|
|
3660
|
+
const points = activeSheet.officeLayout ? Math.max(sizePx, MIN_ROW_HEIGHT_PX) * 3 / 4 : pxToSheetRowHeight(contentPx);
|
|
3661
|
+
for (const index of indices) worksheet.setRowHeight(index, points);
|
|
3662
|
+
} else {
|
|
3663
|
+
const width = activeSheet.officeLayout ? pxToOfficeColumnWidth(sizePx, activeSheet.officeLayout.columnDigitWidthPt) : pxToSheetColumnWidth(contentPx, activeSheet.columnWidthCharacterWidthPx);
|
|
3664
|
+
for (const index of indices) worksheet.setColumnWidth(index, width);
|
|
3665
|
+
}
|
|
3666
|
+
refreshWorkbookState(workbook);
|
|
3667
|
+
} finally {
|
|
3668
|
+
worksheet.free();
|
|
3669
|
+
}
|
|
3670
|
+
}, [activeSheet, applyReadOnlyResizeOverride, canResize, isWorkerBacked, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
|
|
3671
|
+
const resizeColumn = React.useCallback((col, widthPx) => resizeAxis("column", col, widthPx), [resizeAxis]);
|
|
3672
|
+
const resizeRow = React.useCallback((row2, heightPx) => resizeAxis("row", row2, heightPx), [resizeAxis]);
|
|
3509
3673
|
const resolveAnchoredObjectRect = React.useCallback((anchor, worksheet) => {
|
|
3510
3674
|
const resolveAxisSum = (index, getSize) => {
|
|
3511
3675
|
let total = 0;
|
|
@@ -3935,15 +4099,20 @@ function useXlsxViewerController(options2) {
|
|
|
3935
4099
|
selectionAnchorRef.current = anchorCell;
|
|
3936
4100
|
setSelection(merged ?? { start: cell, end: cell });
|
|
3937
4101
|
}, [activeSheet?.mergedRanges, findSelectionMerge]);
|
|
3938
|
-
const
|
|
3939
|
-
const
|
|
4102
|
+
const selectRanges = React.useCallback((ranges, activeCorner = "end") => {
|
|
4103
|
+
const areas = ranges.reduce((previous, range) => addSelectionRange(previous, normalizeRange(range)), []);
|
|
4104
|
+
const active = areas.at(-1);
|
|
3940
4105
|
setSelectedChartId(null);
|
|
3941
4106
|
setSelectedChartElement(null);
|
|
3942
4107
|
setSelectedImageId(null);
|
|
3943
|
-
selectionAnchorRef.current =
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
4108
|
+
selectionAnchorRef.current = active?.start ?? null;
|
|
4109
|
+
const cell = active?.[activeCorner];
|
|
4110
|
+
setActiveCell(cell ? findSelectionMerge(cell)?.start ?? cell : null);
|
|
4111
|
+
setSelectionRanges(areas);
|
|
4112
|
+
}, [findSelectionMerge]);
|
|
4113
|
+
const selectRange = React.useCallback((range) => {
|
|
4114
|
+
selectRanges([expandHighlightedRange(normalizeRange(range), activeSheet?.mergedRanges ?? [])]);
|
|
4115
|
+
}, [activeSheet?.mergedRanges, selectRanges]);
|
|
3947
4116
|
const clearSelection = React.useCallback(() => {
|
|
3948
4117
|
selectionAnchorRef.current = null;
|
|
3949
4118
|
setActiveCell(null);
|
|
@@ -3954,38 +4123,35 @@ function useXlsxViewerController(options2) {
|
|
|
3954
4123
|
}, []);
|
|
3955
4124
|
const clearSelectedCells = React.useCallback(() => {
|
|
3956
4125
|
const worksheet = getActiveWorksheet();
|
|
3957
|
-
|
|
3958
|
-
if (readOnly || !worksheet || !workbook || !targetRange) {
|
|
3959
|
-
return;
|
|
3960
|
-
}
|
|
3961
|
-
if (intersectsPivot(targetRange)) return;
|
|
3962
|
-
const normalized = normalizeRange(targetRange);
|
|
4126
|
+
if (readOnly || !worksheet || !workbook || !selectionRanges.length || selectionRanges.some(intersectsPivot)) return;
|
|
3963
4127
|
const mutations = [];
|
|
3964
|
-
for (
|
|
3965
|
-
for (let
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
4128
|
+
for (const area of selectionRanges) {
|
|
4129
|
+
for (let row2 = area.start.row; row2 <= area.end.row; row2 += 1) {
|
|
4130
|
+
for (let col = area.start.col; col <= area.end.col; col += 1) {
|
|
4131
|
+
if (worksheet.isMergedSecondary(row2, col)) {
|
|
4132
|
+
continue;
|
|
4133
|
+
}
|
|
4134
|
+
const cell = { row: row2, col };
|
|
4135
|
+
const before = captureCellMutationState(cell);
|
|
4136
|
+
if (!before) {
|
|
4137
|
+
continue;
|
|
4138
|
+
}
|
|
4139
|
+
worksheet.setCell(cellAddressToA1({ row: row2, col }), "");
|
|
4140
|
+
const after = captureCellMutationState(cell);
|
|
4141
|
+
if (!after) {
|
|
4142
|
+
continue;
|
|
4143
|
+
}
|
|
4144
|
+
mutations.push({
|
|
4145
|
+
after,
|
|
4146
|
+
before,
|
|
4147
|
+
cell
|
|
4148
|
+
});
|
|
3978
4149
|
}
|
|
3979
|
-
mutations.push({
|
|
3980
|
-
after,
|
|
3981
|
-
before,
|
|
3982
|
-
cell
|
|
3983
|
-
});
|
|
3984
4150
|
}
|
|
3985
4151
|
}
|
|
3986
4152
|
maybeRecalculateWorkbook(workbook);
|
|
3987
4153
|
refreshWorkbookState(workbook);
|
|
3988
|
-
recordRangeEditHistory(mutations,
|
|
4154
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
3989
4155
|
}, [
|
|
3990
4156
|
intersectsPivot,
|
|
3991
4157
|
activeCell,
|
|
@@ -3995,7 +4161,7 @@ function useXlsxViewerController(options2) {
|
|
|
3995
4161
|
readOnly,
|
|
3996
4162
|
recordRangeEditHistory,
|
|
3997
4163
|
refreshWorkbookState,
|
|
3998
|
-
|
|
4164
|
+
selectionRanges,
|
|
3999
4165
|
workbook
|
|
4000
4166
|
]);
|
|
4001
4167
|
const setCellValue = React.useCallback((cell, value) => {
|
|
@@ -4080,8 +4246,8 @@ function useXlsxViewerController(options2) {
|
|
|
4080
4246
|
if (after) mutations.push({ cell, before, after });
|
|
4081
4247
|
}
|
|
4082
4248
|
refreshWorkbookState(workbook);
|
|
4083
|
-
recordRangeEditHistory(mutations,
|
|
4084
|
-
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState,
|
|
4249
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
4250
|
+
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selectionRanges, workbook]);
|
|
4085
4251
|
const setSelectedCellValue = React.useCallback((value) => {
|
|
4086
4252
|
if (!activeCell) {
|
|
4087
4253
|
return;
|
|
@@ -4115,25 +4281,27 @@ function useXlsxViewerController(options2) {
|
|
|
4115
4281
|
if (readOnly || !worksheet || !workbook) {
|
|
4116
4282
|
return;
|
|
4117
4283
|
}
|
|
4118
|
-
const
|
|
4284
|
+
const areas = "start" in range ? [normalizeRange(range)] : range.map(normalizeRange);
|
|
4119
4285
|
const beforeStates = [];
|
|
4120
|
-
for (
|
|
4121
|
-
for (let
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4286
|
+
for (const area of areas) {
|
|
4287
|
+
for (let row2 = area.start.row; row2 <= area.end.row; row2 += 1) {
|
|
4288
|
+
for (let col = area.start.col; col <= area.end.col; col += 1) {
|
|
4289
|
+
const cell = { row: row2, col };
|
|
4290
|
+
const before = captureCellMutationState(cell);
|
|
4291
|
+
if (!before) {
|
|
4292
|
+
continue;
|
|
4293
|
+
}
|
|
4294
|
+
beforeStates.push({
|
|
4295
|
+
before,
|
|
4296
|
+
cell
|
|
4297
|
+
});
|
|
4126
4298
|
}
|
|
4127
|
-
beforeStates.push({
|
|
4128
|
-
before,
|
|
4129
|
-
cell
|
|
4130
|
-
});
|
|
4131
4299
|
}
|
|
4132
4300
|
}
|
|
4133
4301
|
if (beforeStates.length === 0) {
|
|
4134
4302
|
return;
|
|
4135
4303
|
}
|
|
4136
|
-
worksheet.setRangeStyle(rangeToA1(
|
|
4304
|
+
for (const area of areas) worksheet.setRangeStyle(rangeToA1(area), style);
|
|
4137
4305
|
const mutations = [];
|
|
4138
4306
|
for (const mutation of beforeStates) {
|
|
4139
4307
|
const after = captureCellMutationState(mutation.cell);
|
|
@@ -4147,11 +4315,11 @@ function useXlsxViewerController(options2) {
|
|
|
4147
4315
|
});
|
|
4148
4316
|
}
|
|
4149
4317
|
refreshWorkbookState(workbook);
|
|
4150
|
-
recordRangeEditHistory(mutations,
|
|
4151
|
-
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState,
|
|
4318
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
4319
|
+
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selectionRanges, workbook]);
|
|
4152
4320
|
const fillSelection = React.useCallback((targetRange) => {
|
|
4153
4321
|
const worksheet = getActiveWorksheet();
|
|
4154
|
-
if (readOnly || !worksheet || !workbook || !selection) {
|
|
4322
|
+
if (readOnly || !worksheet || !workbook || !selection || selectionRanges.length > 1) {
|
|
4155
4323
|
return;
|
|
4156
4324
|
}
|
|
4157
4325
|
if (intersectsPivot(targetRange)) return;
|
|
@@ -4202,11 +4370,11 @@ function useXlsxViewerController(options2) {
|
|
|
4202
4370
|
setSelection(nextRange);
|
|
4203
4371
|
setActiveCell(nextRange.end);
|
|
4204
4372
|
selectionAnchorRef.current = nextRange.start;
|
|
4205
|
-
recordRangeEditHistory(mutations, nextRange, nextRange.end);
|
|
4206
|
-
}, [intersectsPivot, captureCellMutationState, getActiveWorksheet, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
|
|
4373
|
+
recordRangeEditHistory(mutations, [nextRange], nextRange.end);
|
|
4374
|
+
}, [intersectsPivot, captureCellMutationState, getActiveWorksheet, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4207
4375
|
const mergeSelection = React.useCallback((mode = "cells") => {
|
|
4208
4376
|
const worksheet = getActiveWorksheet();
|
|
4209
|
-
if (readOnly || !worksheet || !selection || !workbook) {
|
|
4377
|
+
if (readOnly || !worksheet || !selection || selectionRanges.length > 1 || !workbook) {
|
|
4210
4378
|
return;
|
|
4211
4379
|
}
|
|
4212
4380
|
if (intersectsPivot(selection)) return;
|
|
@@ -4239,10 +4407,10 @@ function useXlsxViewerController(options2) {
|
|
|
4239
4407
|
selectionAnchorRef.current = range.start;
|
|
4240
4408
|
setSelection(range);
|
|
4241
4409
|
setActiveCell(range.start);
|
|
4242
|
-
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, workbook]);
|
|
4410
|
+
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4243
4411
|
const unmergeSelection = React.useCallback(() => {
|
|
4244
4412
|
const worksheet = getActiveWorksheet();
|
|
4245
|
-
if (readOnly || !worksheet || !selection || !workbook) {
|
|
4413
|
+
if (readOnly || !worksheet || !selection || selectionRanges.length > 1 || !workbook) {
|
|
4246
4414
|
return;
|
|
4247
4415
|
}
|
|
4248
4416
|
const range = normalizeRange(selection);
|
|
@@ -4254,7 +4422,7 @@ function useXlsxViewerController(options2) {
|
|
|
4254
4422
|
worksheet.unmergeCells(rangeToA1(merged));
|
|
4255
4423
|
}
|
|
4256
4424
|
refreshWorkbookState(workbook);
|
|
4257
|
-
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, workbook]);
|
|
4425
|
+
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4258
4426
|
const addSheet = React.useCallback((name) => {
|
|
4259
4427
|
if (readOnly || !workbook) {
|
|
4260
4428
|
return;
|
|
@@ -4343,18 +4511,18 @@ function useXlsxViewerController(options2) {
|
|
|
4343
4511
|
if (!trimmed) {
|
|
4344
4512
|
return;
|
|
4345
4513
|
}
|
|
4346
|
-
const targetRange = range ?? selection;
|
|
4514
|
+
const targetRange = range ?? (selectionRanges.length === 1 ? selection : null);
|
|
4347
4515
|
if (!targetRange) {
|
|
4348
4516
|
return;
|
|
4349
4517
|
}
|
|
4350
4518
|
recordHistoryBeforeMutation();
|
|
4351
4519
|
workbook.defineName(trimmed, rangeToA1(targetRange));
|
|
4352
4520
|
setRevision((current) => current + 1);
|
|
4353
|
-
}, [readOnly, recordHistoryBeforeMutation, selection, workbook]);
|
|
4521
|
+
}, [readOnly, recordHistoryBeforeMutation, selection, selectionRanges, workbook]);
|
|
4354
4522
|
const pasteText = React.useCallback((text) => {
|
|
4355
4523
|
const worksheet = getActiveWorksheet();
|
|
4356
4524
|
const targetCell = activeCell ?? selection?.start ?? null;
|
|
4357
|
-
if (readOnly || !worksheet || !workbook || !targetCell || !text) {
|
|
4525
|
+
if (readOnly || !worksheet || !workbook || !targetCell || selectionRanges.length > 1 || !text) {
|
|
4358
4526
|
return false;
|
|
4359
4527
|
}
|
|
4360
4528
|
const grid = parseClipboardText(text);
|
|
@@ -4417,13 +4585,13 @@ function useXlsxViewerController(options2) {
|
|
|
4417
4585
|
setActiveCell(targetCell);
|
|
4418
4586
|
setSelection(nextRange);
|
|
4419
4587
|
selectionAnchorRef.current = targetCell;
|
|
4420
|
-
recordRangeEditHistory(mutations, nextRange, targetCell);
|
|
4588
|
+
recordRangeEditHistory(mutations, [nextRange], targetCell);
|
|
4421
4589
|
return true;
|
|
4422
|
-
}, [intersectsPivot, activeCell, captureCellMutationState, getActiveWorksheet, locale, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
|
|
4590
|
+
}, [intersectsPivot, activeCell, captureCellMutationState, getActiveWorksheet, locale, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4423
4591
|
const pasteStructuredClipboardData = React.useCallback((serializedPayload) => {
|
|
4424
4592
|
const worksheet = getActiveWorksheet();
|
|
4425
4593
|
const targetCell = activeCell ?? selection?.start ?? null;
|
|
4426
|
-
if (readOnly || !worksheet || !workbook || !targetCell || !serializedPayload) {
|
|
4594
|
+
if (readOnly || !worksheet || !workbook || !targetCell || selectionRanges.length > 1 || !serializedPayload) {
|
|
4427
4595
|
return false;
|
|
4428
4596
|
}
|
|
4429
4597
|
let payload;
|
|
@@ -4512,7 +4680,7 @@ function useXlsxViewerController(options2) {
|
|
|
4512
4680
|
setSelection(nextRange);
|
|
4513
4681
|
selectionAnchorRef.current = targetCell;
|
|
4514
4682
|
if (!hasMergeOperations) {
|
|
4515
|
-
recordRangeEditHistory(mutations, nextRange, targetCell);
|
|
4683
|
+
recordRangeEditHistory(mutations, [nextRange], targetCell);
|
|
4516
4684
|
}
|
|
4517
4685
|
return true;
|
|
4518
4686
|
}, [
|
|
@@ -4526,33 +4694,37 @@ function useXlsxViewerController(options2) {
|
|
|
4526
4694
|
recordRangeEditHistory,
|
|
4527
4695
|
refreshWorkbookState,
|
|
4528
4696
|
selection,
|
|
4697
|
+
selectionRanges,
|
|
4529
4698
|
workbook
|
|
4530
4699
|
]);
|
|
4531
4700
|
const copySelectionToClipboard = React.useCallback(async () => {
|
|
4532
4701
|
if (typeof navigator === "undefined" || !navigator.clipboard) {
|
|
4533
4702
|
return false;
|
|
4534
4703
|
}
|
|
4535
|
-
if (isWorkerBacked && activeSheet
|
|
4536
|
-
const
|
|
4704
|
+
if (isWorkerBacked && activeSheet) {
|
|
4705
|
+
const bands = clipboardBands(selectionRanges);
|
|
4706
|
+
if (!bands) return false;
|
|
4537
4707
|
const textPromise = (async () => {
|
|
4538
4708
|
const lines = [];
|
|
4539
|
-
for (
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
for (const
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4709
|
+
for (const band of bands.rows) {
|
|
4710
|
+
for (let startRow = band.start; startRow <= band.end; startRow += 128) {
|
|
4711
|
+
const count = Math.min(128, band.end - startRow + 1);
|
|
4712
|
+
const batch = await getRowsBatchAsync(activeSheet.workbookSheetIndex, startRow, count);
|
|
4713
|
+
if (!batch) throw new Error("Unable to read the selected cells.");
|
|
4714
|
+
const values = /* @__PURE__ */ new Map();
|
|
4715
|
+
for (const entry of batch) {
|
|
4716
|
+
for (const cell of entry.cells ?? []) {
|
|
4717
|
+
if (cell.isMergedSecondary) continue;
|
|
4718
|
+
const value = String(cell.value ?? "");
|
|
4719
|
+
const cached = cell.formula ? activeSheet.cachedFormulaValues[cellAddressToA1({ row: entry.index, col: cell.col })] : void 0;
|
|
4720
|
+
values.set(`${entry.index}:${cell.col}`, decodeHtmlEntities(cached !== void 0 && value.startsWith("#") ? cached : value));
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
for (let row2 = startRow; row2 < startRow + count; row2++) {
|
|
4724
|
+
const cells = [];
|
|
4725
|
+
for (const { index: col } of bandIndices(bands.cols)) cells.push(values.get(`${row2}:${col}`) ?? "");
|
|
4726
|
+
lines.push(cells.join(" "));
|
|
4550
4727
|
}
|
|
4551
|
-
}
|
|
4552
|
-
for (let row2 = startRow; row2 < startRow + count; row2++) {
|
|
4553
|
-
const cells = [];
|
|
4554
|
-
for (let col = range.start.col; col <= range.end.col; col++) cells.push(values.get(`${row2}:${col}`) ?? "");
|
|
4555
|
-
lines.push(cells.join(" "));
|
|
4556
4728
|
}
|
|
4557
4729
|
}
|
|
4558
4730
|
return lines.join("\n");
|
|
@@ -4590,7 +4762,7 @@ function useXlsxViewerController(options2) {
|
|
|
4590
4762
|
}
|
|
4591
4763
|
await navigator.clipboard.writeText(clipboardData.text);
|
|
4592
4764
|
return true;
|
|
4593
|
-
}, [activeSheet, getClipboardData, getRowsBatchAsync, isWorkerBacked,
|
|
4765
|
+
}, [activeSheet, getClipboardData, getRowsBatchAsync, isWorkerBacked, selectionRanges]);
|
|
4594
4766
|
const pasteFromClipboard = React.useCallback(async (clipboardData) => {
|
|
4595
4767
|
if (readOnly) return false;
|
|
4596
4768
|
const state = drawingMutationState.current;
|
|
@@ -4755,6 +4927,16 @@ function useXlsxViewerController(options2) {
|
|
|
4755
4927
|
revision,
|
|
4756
4928
|
resizeChartBy,
|
|
4757
4929
|
resizeImageBy,
|
|
4930
|
+
frozenPanes: activeSheet?.freezePanes ?? null,
|
|
4931
|
+
canChangeFreezePanes,
|
|
4932
|
+
canChangeVisibility,
|
|
4933
|
+
canFreezePanes,
|
|
4934
|
+
hideRows,
|
|
4935
|
+
unhideRows,
|
|
4936
|
+
hideColumns,
|
|
4937
|
+
unhideColumns,
|
|
4938
|
+
freezePanes,
|
|
4939
|
+
unfreezePanes,
|
|
4758
4940
|
resizeColumn,
|
|
4759
4941
|
resizeRow,
|
|
4760
4942
|
setCellFormula,
|
|
@@ -4783,6 +4965,8 @@ function useXlsxViewerController(options2) {
|
|
|
4783
4965
|
selectChartElement,
|
|
4784
4966
|
selectImage,
|
|
4785
4967
|
selectRange,
|
|
4968
|
+
selectRanges,
|
|
4969
|
+
selectionRanges,
|
|
4786
4970
|
selection,
|
|
4787
4971
|
setActiveSheetIndex,
|
|
4788
4972
|
setActiveTabIndex,
|
|
@@ -4898,6 +5082,15 @@ function useXlsxViewerController(options2) {
|
|
|
4898
5082
|
revision,
|
|
4899
5083
|
resizeChartBy,
|
|
4900
5084
|
resizeImageBy,
|
|
5085
|
+
canChangeFreezePanes,
|
|
5086
|
+
canChangeVisibility,
|
|
5087
|
+
canFreezePanes,
|
|
5088
|
+
hideRows,
|
|
5089
|
+
unhideRows,
|
|
5090
|
+
hideColumns,
|
|
5091
|
+
unhideColumns,
|
|
5092
|
+
freezePanes,
|
|
5093
|
+
unfreezePanes,
|
|
4901
5094
|
resizeColumn,
|
|
4902
5095
|
resizeRow,
|
|
4903
5096
|
setCellFormula,
|
|
@@ -4926,6 +5119,8 @@ function useXlsxViewerController(options2) {
|
|
|
4926
5119
|
selectChartElement,
|
|
4927
5120
|
selectImage,
|
|
4928
5121
|
selectRange,
|
|
5122
|
+
selectRanges,
|
|
5123
|
+
selectionRanges,
|
|
4929
5124
|
selection,
|
|
4930
5125
|
setActiveSheetIndex,
|
|
4931
5126
|
setActiveTabIndex,
|
|
@@ -4957,13 +5152,13 @@ function useXlsxViewerController(options2) {
|
|
|
4957
5152
|
import { initWasm, parseXlsxRange as parseXlsxRange2, setWasmSource, XlsxFileSizeLimitExceededError as XlsxFileSizeLimitExceededError3 } from "@extend-ai/react-xlsx/vanilla";
|
|
4958
5153
|
|
|
4959
5154
|
// src/react-viewer.tsx
|
|
4960
|
-
import * as
|
|
4961
|
-
import { createPortal as
|
|
5155
|
+
import * as React16 from "react";
|
|
5156
|
+
import { createPortal as createPortal7 } from "react-dom";
|
|
4962
5157
|
import { __createContentNode, __createContentRoot, __createControlledViewer } from "@extend-ai/react-xlsx/internal";
|
|
4963
5158
|
|
|
4964
5159
|
// src/XlsxViewer.tsx
|
|
4965
|
-
import * as
|
|
4966
|
-
import { createPortal as
|
|
5160
|
+
import * as React15 from "react";
|
|
5161
|
+
import { createPortal as createPortal6 } from "react-dom";
|
|
4967
5162
|
|
|
4968
5163
|
// src/cell-editor.tsx
|
|
4969
5164
|
import * as React2 from "react";
|
|
@@ -5259,9 +5454,14 @@ function getCellGeneralAlignment(worksheet, row2, col) {
|
|
|
5259
5454
|
}
|
|
5260
5455
|
}
|
|
5261
5456
|
|
|
5262
|
-
// src/
|
|
5263
|
-
import * as
|
|
5457
|
+
// src/header-size-dialog.tsx
|
|
5458
|
+
import * as React6 from "react";
|
|
5264
5459
|
import { createPortal as createPortal3 } from "react-dom";
|
|
5460
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
5461
|
+
|
|
5462
|
+
// src/context-menu.tsx
|
|
5463
|
+
import * as React8 from "react";
|
|
5464
|
+
import { createPortal as createPortal4 } from "react-dom";
|
|
5265
5465
|
|
|
5266
5466
|
// src/viewer-palette.ts
|
|
5267
5467
|
var LIGHT_PALETTE = {
|
|
@@ -5325,23 +5525,23 @@ function resolveViewerPalette(isDark = false, headerBackgroundColor, headerTextC
|
|
|
5325
5525
|
}
|
|
5326
5526
|
|
|
5327
5527
|
// src/context-menu-items.tsx
|
|
5328
|
-
import * as
|
|
5329
|
-
import { Fragment as Fragment3, jsx as
|
|
5528
|
+
import * as React7 from "react";
|
|
5529
|
+
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
5330
5530
|
|
|
5331
5531
|
// src/context-menu.tsx
|
|
5332
|
-
import { jsx as
|
|
5532
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
5333
5533
|
|
|
5334
5534
|
// src/pivot-controls.tsx
|
|
5335
|
-
import * as
|
|
5336
|
-
import { Fragment as Fragment5, jsx as
|
|
5535
|
+
import * as React9 from "react";
|
|
5536
|
+
import { Fragment as Fragment5, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
5337
5537
|
|
|
5338
5538
|
// src/pivot-header-controls.tsx
|
|
5339
|
-
import * as
|
|
5340
|
-
import { createPortal as
|
|
5341
|
-
import { Fragment as Fragment7, jsx as
|
|
5539
|
+
import * as React10 from "react";
|
|
5540
|
+
import { createPortal as createPortal5 } from "react-dom";
|
|
5541
|
+
import { Fragment as Fragment7, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
5342
5542
|
|
|
5343
5543
|
// src/pivot-editor.ts
|
|
5344
|
-
import * as
|
|
5544
|
+
import * as React11 from "react";
|
|
5345
5545
|
function address(row2, col) {
|
|
5346
5546
|
let letters = "";
|
|
5347
5547
|
for (let n = col + 1; n > 0; n = Math.floor((n - 1) / 26)) letters = String.fromCharCode(65 + (n - 1) % 26) + letters;
|
|
@@ -5360,18 +5560,18 @@ function copyPivot(pivot) {
|
|
|
5360
5560
|
function usePivotTableEditor(viewer, options2 = {}) {
|
|
5361
5561
|
const open = viewer.pivotFieldListVisible;
|
|
5362
5562
|
const setOpen = viewer.setPivotFieldListVisible;
|
|
5363
|
-
const [draft, setDraft] =
|
|
5364
|
-
const [dirty, setDirty] =
|
|
5365
|
-
const [error, setError] =
|
|
5366
|
-
const [status, setStatus] =
|
|
5367
|
-
const [details, setDetails] =
|
|
5368
|
-
const [detailContext, setDetailContext] =
|
|
5369
|
-
const [loadedSource, setLoadedSource] =
|
|
5370
|
-
const [savedDefinition, setSavedDefinition] =
|
|
5371
|
-
const [pendingFocus, setPendingFocus] =
|
|
5563
|
+
const [draft, setDraft] = React11.useState(null);
|
|
5564
|
+
const [dirty, setDirty] = React11.useState(false);
|
|
5565
|
+
const [error, setError] = React11.useState(null);
|
|
5566
|
+
const [status, setStatus] = React11.useState(null);
|
|
5567
|
+
const [details, setDetails] = React11.useState(null);
|
|
5568
|
+
const [detailContext, setDetailContext] = React11.useState(null);
|
|
5569
|
+
const [loadedSource, setLoadedSource] = React11.useState("");
|
|
5570
|
+
const [savedDefinition, setSavedDefinition] = React11.useState("");
|
|
5571
|
+
const [pendingFocus, setPendingFocus] = React11.useState(null);
|
|
5372
5572
|
const sourceNeedsLoad = Boolean(draft && JSON.stringify(draft.source) !== loadedSource);
|
|
5373
5573
|
const stale = Boolean(dirty && draft?.id && savedDefinition !== JSON.stringify(viewer.pivotTables.find((pivot) => pivot.id === draft.id) ?? null));
|
|
5374
|
-
const run =
|
|
5574
|
+
const run = React11.useCallback((action) => {
|
|
5375
5575
|
setError(null);
|
|
5376
5576
|
setStatus(null);
|
|
5377
5577
|
try {
|
|
@@ -5381,7 +5581,7 @@ function usePivotTableEditor(viewer, options2 = {}) {
|
|
|
5381
5581
|
setOpen(true);
|
|
5382
5582
|
}
|
|
5383
5583
|
}, []);
|
|
5384
|
-
|
|
5584
|
+
React11.useEffect(() => {
|
|
5385
5585
|
if (options2.enabled === false) return;
|
|
5386
5586
|
setDraft(null);
|
|
5387
5587
|
setDirty(false);
|
|
@@ -5394,7 +5594,7 @@ function usePivotTableEditor(viewer, options2 = {}) {
|
|
|
5394
5594
|
setPendingFocus(null);
|
|
5395
5595
|
if (options2.initialOpen !== void 0) setOpen(options2.initialOpen);
|
|
5396
5596
|
}, [viewer.src, viewer.file]);
|
|
5397
|
-
|
|
5597
|
+
React11.useEffect(() => {
|
|
5398
5598
|
if (options2.enabled === false || dirty || !draft?.id) return;
|
|
5399
5599
|
const current = viewer.pivotTables.find((pivot) => pivot.id === draft.id);
|
|
5400
5600
|
setDraft(current ? copyPivot(current) : null);
|
|
@@ -5403,7 +5603,7 @@ function usePivotTableEditor(viewer, options2 = {}) {
|
|
|
5403
5603
|
setSavedDefinition(JSON.stringify(current));
|
|
5404
5604
|
}
|
|
5405
5605
|
}, [viewer.pivotTables]);
|
|
5406
|
-
|
|
5606
|
+
React11.useEffect(() => {
|
|
5407
5607
|
if (options2.enabled === false || options2.autoSelect === false || dirty || pendingFocus || !viewer.activeCell || !viewer.activeSheet) return;
|
|
5408
5608
|
const current = viewer.getPivotTableAtCell(viewer.activeCell, viewer.activeSheet.name);
|
|
5409
5609
|
if (!current || current.id === draft?.id) return;
|
|
@@ -5414,7 +5614,7 @@ function usePivotTableEditor(viewer, options2 = {}) {
|
|
|
5414
5614
|
setStatus(null);
|
|
5415
5615
|
setDetails(null);
|
|
5416
5616
|
}, [viewer.activeCell?.row, viewer.activeCell?.col, viewer.activeSheet?.name, viewer.pivotTables, options2.autoSelect, options2.enabled]);
|
|
5417
|
-
|
|
5617
|
+
React11.useEffect(() => {
|
|
5418
5618
|
if (!pendingFocus || viewer.activeSheet?.name.toLowerCase() !== pendingFocus.sheet.toLowerCase()) return;
|
|
5419
5619
|
viewer.selectCell({ row: pendingFocus.row, col: pendingFocus.col });
|
|
5420
5620
|
setPendingFocus(null);
|
|
@@ -5619,8 +5819,8 @@ function usePivotTableEditor(viewer, options2 = {}) {
|
|
|
5619
5819
|
}
|
|
5620
5820
|
|
|
5621
5821
|
// src/pivot-field-list.tsx
|
|
5622
|
-
import * as
|
|
5623
|
-
import { Fragment as Fragment8, jsx as
|
|
5822
|
+
import * as React12 from "react";
|
|
5823
|
+
import { Fragment as Fragment8, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
5624
5824
|
var AREAS = ["reportFilters", "columns", "rows", "values"];
|
|
5625
5825
|
var AREA_NAMES = { reportFilters: "Filters", columns: "Columns", rows: "Rows", values: "Values" };
|
|
5626
5826
|
var AGGREGATIONS = [["sum", "Sum"], ["count", "Count"], ["average", "Average"], ["max", "Max"], ["min", "Min"], ["product", "Product"], ["countNums", "Count Numbers"], ["stdDev", "StdDev"], ["stdDevp", "StdDevp"], ["var", "Var"], ["varp", "Varp"]];
|
|
@@ -5647,53 +5847,53 @@ function groupingUnit(axis) {
|
|
|
5647
5847
|
return axis?.grouping ? axis.grouping.kind === "date" ? axis.grouping.unit : axis.grouping.kind : null;
|
|
5648
5848
|
}
|
|
5649
5849
|
function Action({ children: children2, primary, style, ...props }) {
|
|
5650
|
-
return /* @__PURE__ */
|
|
5850
|
+
return /* @__PURE__ */ jsx9("button", { type: "button", ...props, style: { ...control, width: "auto", cursor: props.disabled ? "default" : "pointer", opacity: props.disabled ? 0.55 : 1, ...primary ? { background: "var(--xlsx-pivot-accent)", borderColor: "var(--xlsx-pivot-accent)", color: "#fff" } : {}, ...style }, children: children2 });
|
|
5651
5851
|
}
|
|
5652
5852
|
function Text({ label, value, onChange, ...props }) {
|
|
5653
|
-
return /* @__PURE__ */
|
|
5654
|
-
/* @__PURE__ */
|
|
5655
|
-
/* @__PURE__ */
|
|
5853
|
+
return /* @__PURE__ */ jsxs7("label", { style: { ...stack, gap: 4 }, children: [
|
|
5854
|
+
/* @__PURE__ */ jsx9("span", { children: label }),
|
|
5855
|
+
/* @__PURE__ */ jsx9("input", { ...props, style: { ...control, ...props.style }, value, onChange: (event) => onChange(event.target.value) })
|
|
5656
5856
|
] });
|
|
5657
5857
|
}
|
|
5658
5858
|
function Choice({ label, value, options: options2, onChange, placeholder, disabled }) {
|
|
5659
|
-
return /* @__PURE__ */
|
|
5660
|
-
/* @__PURE__ */
|
|
5661
|
-
/* @__PURE__ */
|
|
5662
|
-
placeholder ? /* @__PURE__ */
|
|
5663
|
-
options2.map(([key, text]) => /* @__PURE__ */
|
|
5859
|
+
return /* @__PURE__ */ jsxs7("label", { style: { ...stack, gap: 4 }, children: [
|
|
5860
|
+
/* @__PURE__ */ jsx9("span", { children: label }),
|
|
5861
|
+
/* @__PURE__ */ jsxs7("select", { disabled, style: control, value, onChange: (event) => onChange(event.target.value), children: [
|
|
5862
|
+
placeholder ? /* @__PURE__ */ jsx9("option", { value: "", children: placeholder }) : null,
|
|
5863
|
+
options2.map(([key, text]) => /* @__PURE__ */ jsx9("option", { value: key, children: text }, key))
|
|
5664
5864
|
] })
|
|
5665
5865
|
] });
|
|
5666
5866
|
}
|
|
5667
5867
|
function Check({ label, checked, onChange, disabled }) {
|
|
5668
|
-
return /* @__PURE__ */
|
|
5669
|
-
/* @__PURE__ */
|
|
5670
|
-
/* @__PURE__ */
|
|
5868
|
+
return /* @__PURE__ */ jsxs7("label", { style: { ...row, alignItems: "flex-start", cursor: disabled ? "default" : "pointer", paddingBlock: 2 }, children: [
|
|
5869
|
+
/* @__PURE__ */ jsx9("input", { type: "checkbox", disabled, checked, onChange: (event) => onChange(event.target.checked), style: { margin: "2px 0 0", accentColor: "var(--xlsx-pivot-accent)", flexShrink: 0 } }),
|
|
5870
|
+
/* @__PURE__ */ jsx9("span", { style: { overflowWrap: "anywhere" }, children: label })
|
|
5671
5871
|
] });
|
|
5672
5872
|
}
|
|
5673
5873
|
function Section({ title, children: children2 }) {
|
|
5674
|
-
return /* @__PURE__ */
|
|
5675
|
-
/* @__PURE__ */
|
|
5676
|
-
/* @__PURE__ */
|
|
5874
|
+
return /* @__PURE__ */ jsxs7("details", { style: { borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
|
|
5875
|
+
/* @__PURE__ */ jsx9("summary", { style: { cursor: "pointer", fontWeight: 600, padding: "11px 12px", userSelect: "none" }, children: title }),
|
|
5876
|
+
/* @__PURE__ */ jsx9("div", { style: { ...stack, padding: "0 12px 12px" }, children: children2 })
|
|
5677
5877
|
] });
|
|
5678
5878
|
}
|
|
5679
5879
|
function Members({ items, selected, onChange, label = "Items" }) {
|
|
5680
|
-
const [search, setSearch] =
|
|
5880
|
+
const [search, setSearch] = React12.useState("");
|
|
5681
5881
|
const visible = items.filter((item) => item.caption.toLocaleLowerCase().includes(search.toLocaleLowerCase()));
|
|
5682
5882
|
const keys = new Set(selected);
|
|
5683
|
-
return /* @__PURE__ */
|
|
5684
|
-
/* @__PURE__ */
|
|
5685
|
-
/* @__PURE__ */
|
|
5686
|
-
/* @__PURE__ */
|
|
5687
|
-
/* @__PURE__ */
|
|
5688
|
-
/* @__PURE__ */
|
|
5883
|
+
return /* @__PURE__ */ jsxs7("div", { style: { ...stack, gap: 6 }, children: [
|
|
5884
|
+
/* @__PURE__ */ jsx9(Text, { label: `Search ${label.toLowerCase()}`, type: "search", value: search, onChange: setSearch }),
|
|
5885
|
+
/* @__PURE__ */ jsxs7("div", { style: { ...row, flexWrap: "wrap" }, children: [
|
|
5886
|
+
/* @__PURE__ */ jsx9(Action, { onClick: () => onChange(items.map((item) => item.key)), children: "Select all" }),
|
|
5887
|
+
/* @__PURE__ */ jsx9(Action, { onClick: () => onChange([]), children: "Clear" }),
|
|
5888
|
+
/* @__PURE__ */ jsxs7("span", { style: hint, children: [
|
|
5689
5889
|
keys.size,
|
|
5690
5890
|
" selected"
|
|
5691
5891
|
] })
|
|
5692
5892
|
] }),
|
|
5693
|
-
/* @__PURE__ */
|
|
5694
|
-
visible.slice(0, 200).map((item) => /* @__PURE__ */
|
|
5695
|
-
!visible.length ? /* @__PURE__ */
|
|
5696
|
-
visible.length > 200 ? /* @__PURE__ */
|
|
5893
|
+
/* @__PURE__ */ jsxs7("div", { role: "group", "aria-label": label, style: { maxHeight: 150, overflowY: "auto", padding: "4px 6px", border: "1px solid var(--xlsx-pivot-border)" }, children: [
|
|
5894
|
+
visible.slice(0, 200).map((item) => /* @__PURE__ */ jsx9(Check, { label: item.caption || "(blank)", checked: keys.has(item.key), onChange: (checked) => onChange(checked ? [...keys, item.key] : selected.filter((key) => key !== item.key)) }, item.key)),
|
|
5895
|
+
!visible.length ? /* @__PURE__ */ jsx9("p", { style: hint, children: "No matching items." }) : null,
|
|
5896
|
+
visible.length > 200 ? /* @__PURE__ */ jsxs7("p", { style: hint, children: [
|
|
5697
5897
|
"Search to narrow ",
|
|
5698
5898
|
visible.length.toLocaleString(),
|
|
5699
5899
|
" items."
|
|
@@ -5708,17 +5908,17 @@ function ValueSettings({ pivot, value, onChange }) {
|
|
|
5708
5908
|
const baseAxes = axes.filter((axis) => axis.field === value.baseField);
|
|
5709
5909
|
const base = baseAxes.find((axis) => groupingUnit(axis) === (value.baseGroupingUnit ?? null)) ?? baseAxes[0];
|
|
5710
5910
|
const source = pivot.fields.find((field) => field.index === value.baseField);
|
|
5711
|
-
return /* @__PURE__ */
|
|
5712
|
-
/* @__PURE__ */
|
|
5713
|
-
/* @__PURE__ */
|
|
5714
|
-
/* @__PURE__ */
|
|
5715
|
-
needsBase ? /* @__PURE__ */
|
|
5716
|
-
needsBase && baseAxes.length > 1 ? /* @__PURE__ */
|
|
5717
|
-
needsItem ? /* @__PURE__ */
|
|
5718
|
-
/* @__PURE__ */
|
|
5719
|
-
/* @__PURE__ */
|
|
5720
|
-
/* @__PURE__ */
|
|
5721
|
-
/* @__PURE__ */
|
|
5911
|
+
return /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
5912
|
+
/* @__PURE__ */ jsx9(Text, { label: "Custom name", value: value.name, onChange: (name) => onChange({ ...value, name }) }),
|
|
5913
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Summarize values by", value: value.aggregation, options: AGGREGATIONS, onChange: (aggregation) => onChange({ ...value, aggregation }) }),
|
|
5914
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Show values as", value: value.showAs, options: SHOW_AS, onChange: (showAs) => onChange({ ...value, showAs, baseField: value.baseField ?? axes[0]?.field }) }),
|
|
5915
|
+
needsBase ? /* @__PURE__ */ jsx9(Choice, { label: "Base field", value: value.baseField == null ? "" : String(value.baseField), placeholder: "Choose a field", options: pivot.fields.filter((field) => axes.some((axis) => axis.field === field.index)).map((field) => [String(field.index), field.name]), onChange: (field) => onChange({ ...value, baseField: Number(field), baseGroupingUnit: null, baseItem: null }) }) : null,
|
|
5916
|
+
needsBase && baseAxes.length > 1 ? /* @__PURE__ */ jsx9(Choice, { label: "Base grouping level", value: value.baseGroupingUnit ?? groupingUnit(base) ?? "", options: baseAxes.map((axis) => [groupingUnit(axis) ?? "", axis.name || groupingUnit(axis) || "Source items"]), onChange: (unit) => onChange({ ...value, baseGroupingUnit: unit || null, baseItem: null }) }) : null,
|
|
5917
|
+
needsItem ? /* @__PURE__ */ jsx9(Choice, { label: "Base item", value: value.baseItem ?? "previous", options: [["previous", "(previous)"], ["next", "(next)"], ...(base?.items?.length ? base.items : source?.items ?? []).map((item) => [item.key, item.caption])], onChange: (baseItem) => onChange({ ...value, baseItem }) }) : null,
|
|
5918
|
+
/* @__PURE__ */ jsx9(Text, { label: "Number format", value: value.numberFormat ?? "", placeholder: "General", onChange: (numberFormat) => onChange({ ...value, numberFormat: numberFormat || null }) }),
|
|
5919
|
+
/* @__PURE__ */ jsx9(Text, { label: "Calculated field formula", value: value.formula ?? "", placeholder: "Leave blank for a source field", onChange: (formula) => onChange({ ...value, formula: formula || null }) }),
|
|
5920
|
+
/* @__PURE__ */ jsx9("p", { style: hint, children: "Use field names in formulas. Enclose names containing spaces in single quotes or square brackets." }),
|
|
5921
|
+
/* @__PURE__ */ jsx9("p", { style: hint, children: FORMULA_HELP })
|
|
5722
5922
|
] });
|
|
5723
5923
|
}
|
|
5724
5924
|
function AxisSettings({ pivot, axis, onChange, onAddDateLevel }) {
|
|
@@ -5726,39 +5926,39 @@ function AxisSettings({ pivot, axis, onChange, onAddDateLevel }) {
|
|
|
5726
5926
|
const grouping = axis.grouping;
|
|
5727
5927
|
const updateGrouping = (patch) => onChange({ ...axis, grouping: { ...grouping, ...patch }, items: [], collapsed: [] });
|
|
5728
5928
|
const availableUnits = DATE_UNITS.filter((unit) => ![...pivot.rows, ...pivot.columns].some((field) => field.field === axis.field && field.grouping?.kind === "date" && field.grouping.unit === unit));
|
|
5729
|
-
return /* @__PURE__ */
|
|
5730
|
-
/* @__PURE__ */
|
|
5731
|
-
/* @__PURE__ */
|
|
5732
|
-
axis.sort.startsWith("value") ? /* @__PURE__ */
|
|
5733
|
-
/* @__PURE__ */
|
|
5734
|
-
axis.subtotals ? /* @__PURE__ */
|
|
5735
|
-
/* @__PURE__ */
|
|
5736
|
-
/* @__PURE__ */
|
|
5737
|
-
/* @__PURE__ */
|
|
5929
|
+
return /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
5930
|
+
/* @__PURE__ */ jsx9(Text, { label: "Custom name", value: axis.name ?? "", placeholder: source?.name, onChange: (name) => onChange({ ...axis, name: name || null }) }),
|
|
5931
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Sort", value: axis.sort, options: [["ascending", "Ascending (A to Z)"], ["descending", "Descending (Z to A)"], ["manual", "Source order"], ["valueAscending", "Smallest to largest by value"], ["valueDescending", "Largest to smallest by value"]], onChange: (sort) => onChange({ ...axis, sort, sortMeasure: axis.sortMeasure ?? 0 }) }),
|
|
5932
|
+
axis.sort.startsWith("value") ? /* @__PURE__ */ jsx9(Choice, { label: "Sort by value", value: String(axis.sortMeasure ?? 0), options: pivot.values.map((value, index) => [String(index), value.name]), onChange: (sortMeasure) => onChange({ ...axis, sortMeasure: Number(sortMeasure) }) }) : null,
|
|
5933
|
+
/* @__PURE__ */ jsx9(Check, { label: "Show subtotals", checked: axis.subtotals, onChange: (subtotals) => onChange({ ...axis, subtotals }) }),
|
|
5934
|
+
axis.subtotals ? /* @__PURE__ */ jsxs7("details", { children: [
|
|
5935
|
+
/* @__PURE__ */ jsx9("summary", { style: { cursor: "pointer" }, children: "Custom subtotal functions" }),
|
|
5936
|
+
/* @__PURE__ */ jsx9("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 3, marginTop: 6 }, children: AGGREGATIONS.map(([value, label]) => /* @__PURE__ */ jsx9(Check, { label, checked: axis.subtotalFunctions?.includes(value) ?? false, onChange: (checked) => onChange({ ...axis, subtotalFunctions: checked ? [...axis.subtotalFunctions ?? [], value] : axis.subtotalFunctions?.filter((item) => item !== value) }) }, value)) }),
|
|
5937
|
+
/* @__PURE__ */ jsx9("p", { style: hint, children: "Leave unchecked to use the value field\u2019s summary function." })
|
|
5738
5938
|
] }) : null,
|
|
5739
|
-
/* @__PURE__ */
|
|
5740
|
-
/* @__PURE__ */
|
|
5741
|
-
grouping?.kind === "date" ? /* @__PURE__ */
|
|
5742
|
-
grouping && grouping.kind !== "manual" ? /* @__PURE__ */
|
|
5743
|
-
/* @__PURE__ */
|
|
5744
|
-
/* @__PURE__ */
|
|
5745
|
-
/* @__PURE__ */
|
|
5746
|
-
/* @__PURE__ */
|
|
5939
|
+
/* @__PURE__ */ jsx9(Check, { label: "Show items with no data", checked: axis.showItemsWithNoData ?? false, onChange: (showItemsWithNoData) => onChange({ ...axis, showItemsWithNoData }) }),
|
|
5940
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Grouping", value: grouping?.kind ?? "none", options: [["none", "None"], ["number", "Numeric intervals"], ["date", "Date intervals"], ["manual", "Named groups"]], onChange: (kind) => onChange({ ...axis, grouping: kind === "none" ? null : { kind, unit: "months", interval: 1, groups: [] }, items: [], collapsed: [] }) }),
|
|
5941
|
+
grouping?.kind === "date" ? /* @__PURE__ */ jsx9(Choice, { label: "Group dates by", value: grouping.unit, options: DATE_UNITS.map((unit) => [unit, unit[0].toUpperCase() + unit.slice(1)]), onChange: (unit) => updateGrouping({ unit }) }) : null,
|
|
5942
|
+
grouping && grouping.kind !== "manual" ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
5943
|
+
/* @__PURE__ */ jsx9(Text, { label: "Interval", type: "number", min: 1e-6, step: "any", value: String(grouping.interval), onChange: (interval) => updateGrouping({ interval: Number(interval) }) }),
|
|
5944
|
+
/* @__PURE__ */ jsxs7("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
|
|
5945
|
+
/* @__PURE__ */ jsx9(Text, { label: "Starting at", type: "number", step: "any", placeholder: "Automatic", value: grouping.start == null ? "" : String(grouping.start), onChange: (start) => updateGrouping({ start: start === "" ? null : Number(start) }) }),
|
|
5946
|
+
/* @__PURE__ */ jsx9(Text, { label: "Ending at", type: "number", step: "any", placeholder: "Automatic", value: grouping.end == null ? "" : String(grouping.end), onChange: (end) => updateGrouping({ end: end === "" ? null : Number(end) }) })
|
|
5747
5947
|
] }),
|
|
5748
|
-
grouping.kind === "date" ? /* @__PURE__ */
|
|
5948
|
+
grouping.kind === "date" ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Optional bounds use Excel date serial values." }) : null
|
|
5749
5949
|
] }) : null,
|
|
5750
|
-
grouping?.kind === "date" && availableUnits.length ? /* @__PURE__ */
|
|
5751
|
-
grouping?.kind === "manual" ? /* @__PURE__ */
|
|
5752
|
-
grouping.groups.map((group, index) => /* @__PURE__ */
|
|
5753
|
-
/* @__PURE__ */
|
|
5754
|
-
/* @__PURE__ */
|
|
5755
|
-
/* @__PURE__ */
|
|
5950
|
+
grouping?.kind === "date" && availableUnits.length ? /* @__PURE__ */ jsx9(Choice, { label: "Add date grouping level", value: "", placeholder: "Choose a level", options: availableUnits.map((unit) => [unit, unit[0].toUpperCase() + unit.slice(1)]), onChange: (unit) => onAddDateLevel(unit) }) : null,
|
|
5951
|
+
grouping?.kind === "manual" ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
5952
|
+
grouping.groups.map((group, index) => /* @__PURE__ */ jsxs7("div", { style: { ...stack, borderTop: "1px solid var(--xlsx-pivot-border)", paddingTop: 8 }, children: [
|
|
5953
|
+
/* @__PURE__ */ jsx9(Text, { label: "Group name", value: group.name, onChange: (name) => updateGrouping({ groups: grouping.groups.map((item, position) => position === index ? { ...item, name } : item) }) }),
|
|
5954
|
+
/* @__PURE__ */ jsx9(Members, { items: source?.items ?? [], selected: group.members, onChange: (members) => updateGrouping({ groups: grouping.groups.map((item, position) => position === index ? { ...item, members } : item) }) }),
|
|
5955
|
+
/* @__PURE__ */ jsx9(Action, { onClick: () => updateGrouping({ groups: grouping.groups.filter((_, position) => position !== index) }), children: "Remove group" })
|
|
5756
5956
|
] }, index)),
|
|
5757
|
-
/* @__PURE__ */
|
|
5957
|
+
/* @__PURE__ */ jsx9(Action, { onClick: () => updateGrouping({ groups: [...grouping.groups, { name: `Group ${grouping.groups.length + 1}`, members: [] }] }), children: "Add named group" })
|
|
5758
5958
|
] }) : null,
|
|
5759
|
-
/* @__PURE__ */
|
|
5760
|
-
/* @__PURE__ */
|
|
5761
|
-
/* @__PURE__ */
|
|
5959
|
+
/* @__PURE__ */ jsxs7("details", { children: [
|
|
5960
|
+
/* @__PURE__ */ jsx9("summary", { style: { cursor: "pointer" }, children: "Collapse members" }),
|
|
5961
|
+
/* @__PURE__ */ jsx9("div", { style: { paddingTop: 8 }, children: grouping && !axis.items?.length ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Apply grouping to load its members." }) : /* @__PURE__ */ jsx9(Members, { label: "Members to collapse", items: axis.items?.length ? axis.items : source?.items ?? [], selected: axis.collapsed, onChange: (collapsed) => onChange({ ...axis, collapsed }) }) })
|
|
5762
5962
|
] })
|
|
5763
5963
|
] });
|
|
5764
5964
|
}
|
|
@@ -5770,116 +5970,116 @@ function FieldFilters({ editor, pivot, field, axis }) {
|
|
|
5770
5970
|
const filters = pivot.filters.map((filter, index) => ({ filter, index })).filter(({ filter }) => filter.field === field && (filter.groupingUnit ?? null) === unit);
|
|
5771
5971
|
const kinds = [["members", "Select items"], ["label", "Label filter"], ["value", "Value filter"], ["top10", "Top / bottom filter"]];
|
|
5772
5972
|
const update = (index, next) => editor.edit((current) => ({ ...current, filters: current.filters.flatMap((filter, position) => position === index ? next ? [next] : [] : [filter]) }));
|
|
5773
|
-
return /* @__PURE__ */
|
|
5774
|
-
/* @__PURE__ */
|
|
5973
|
+
return /* @__PURE__ */ jsxs7("div", { style: { ...stack, paddingTop: 10, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
|
|
5974
|
+
/* @__PURE__ */ jsxs7("strong", { children: [
|
|
5775
5975
|
"Field filters",
|
|
5776
5976
|
unit ? ` \xB7 ${unit}` : ""
|
|
5777
5977
|
] }),
|
|
5778
|
-
filterAxis?.grouping && !filterAxis.items?.length ? /* @__PURE__ */
|
|
5779
|
-
filters.map(({ filter, index }) => /* @__PURE__ */
|
|
5780
|
-
/* @__PURE__ */
|
|
5781
|
-
/* @__PURE__ */
|
|
5782
|
-
/* @__PURE__ */
|
|
5978
|
+
filterAxis?.grouping && !filterAxis.items?.length ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Apply grouping before selecting its members." }) : null,
|
|
5979
|
+
filters.map(({ filter, index }) => /* @__PURE__ */ jsxs7("div", { style: { ...stack, paddingBlock: 8, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
|
|
5980
|
+
/* @__PURE__ */ jsxs7("div", { style: { ...row, justifyContent: "space-between" }, children: [
|
|
5981
|
+
/* @__PURE__ */ jsx9("span", { children: kinds.find(([kind]) => kind === filter.kind)?.[1] }),
|
|
5982
|
+
/* @__PURE__ */ jsx9(Action, { "aria-label": `Remove ${filter.kind} filter`, onClick: () => update(index, null), children: "\xD7" })
|
|
5783
5983
|
] }),
|
|
5784
|
-
filter.kind === "members" ? /* @__PURE__ */
|
|
5785
|
-
filter.kind === "label" || filter.kind === "value" ? /* @__PURE__ */
|
|
5786
|
-
/* @__PURE__ */
|
|
5787
|
-
/* @__PURE__ */
|
|
5788
|
-
filter.operator === "between" || filter.operator === "notBetween" ? /* @__PURE__ */
|
|
5984
|
+
filter.kind === "members" ? /* @__PURE__ */ jsx9(Members, { items: members, selected: filter.values, onChange: (values) => update(index, { ...filter, values }) }) : null,
|
|
5985
|
+
filter.kind === "label" || filter.kind === "value" ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
5986
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Condition", value: filter.operator, options: filter.kind === "value" ? OPERATORS.filter(([operator]) => !/contains|begins|ends/i.test(operator)) : OPERATORS, onChange: (operator) => update(index, { ...filter, operator }) }),
|
|
5987
|
+
/* @__PURE__ */ jsx9(Text, { label: "Value", type: filter.kind === "value" ? "number" : "text", value: filter.value, onChange: (value) => update(index, { ...filter, value }) }),
|
|
5988
|
+
filter.operator === "between" || filter.operator === "notBetween" ? /* @__PURE__ */ jsx9(Text, { label: "And", type: filter.kind === "value" ? "number" : "text", value: filter.value2, onChange: (value2) => update(index, { ...filter, value2 }) }) : null
|
|
5789
5989
|
] }) : null,
|
|
5790
|
-
filter.kind === "top10" ? /* @__PURE__ */
|
|
5791
|
-
/* @__PURE__ */
|
|
5792
|
-
/* @__PURE__ */
|
|
5793
|
-
/* @__PURE__ */
|
|
5990
|
+
filter.kind === "top10" ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
5991
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Show", value: filter.top ? "top" : "bottom", options: [["top", "Top"], ["bottom", "Bottom"]], onChange: (top) => update(index, { ...filter, top: top === "top" }) }),
|
|
5992
|
+
/* @__PURE__ */ jsx9(Text, { label: "Amount", type: "number", min: 1, value: String(filter.count), onChange: (count) => update(index, { ...filter, count: Number(count) }) }),
|
|
5993
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Unit", value: filter.percent ? "percent" : "items", options: [["items", "Items"], ["percent", "Percent"]], onChange: (percent) => update(index, { ...filter, percent: percent === "percent" }) })
|
|
5794
5994
|
] }) : null,
|
|
5795
|
-
filter.kind === "value" || filter.kind === "top10" ? /* @__PURE__ */
|
|
5995
|
+
filter.kind === "value" || filter.kind === "top10" ? /* @__PURE__ */ jsx9(Choice, { label: "By value", value: String(filter.measure), options: pivot.values.map((value, position) => [String(position), value.name]), onChange: (measure) => update(index, { ...filter, measure: Number(measure) }) }) : null
|
|
5796
5996
|
] }, index)),
|
|
5797
|
-
/* @__PURE__ */
|
|
5997
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Add filter", value: "", placeholder: "Choose a filter", options: kinds.filter(([kind]) => !filters.some(({ filter }) => filter.kind === kind)), onChange: (kind) => editor.edit((current) => ({ ...current, filters: [...current.filters, { field, groupingUnit: unit, kind, values: kind === "members" ? members.map((member) => member.key) : [], operator: "equal", value: "", value2: "", measure: 0, top: true, count: 10, percent: false }] })) })
|
|
5798
5998
|
] });
|
|
5799
5999
|
}
|
|
5800
6000
|
function Advanced({ editor, pivot }) {
|
|
5801
|
-
const [chartType, setChartType] =
|
|
5802
|
-
const [chartCell, setChartCell] =
|
|
5803
|
-
const [chartTitle, setChartTitle] =
|
|
5804
|
-
const [chartMeasure, setChartMeasure] =
|
|
5805
|
-
const [chartSheet, setChartSheet] =
|
|
5806
|
-
const [chartWidth, setChartWidth] =
|
|
5807
|
-
const [chartHeight, setChartHeight] =
|
|
6001
|
+
const [chartType, setChartType] = React12.useState("ColumnClustered");
|
|
6002
|
+
const [chartCell, setChartCell] = React12.useState("I2");
|
|
6003
|
+
const [chartTitle, setChartTitle] = React12.useState("");
|
|
6004
|
+
const [chartMeasure, setChartMeasure] = React12.useState("");
|
|
6005
|
+
const [chartSheet, setChartSheet] = React12.useState("");
|
|
6006
|
+
const [chartWidth, setChartWidth] = React12.useState("560");
|
|
6007
|
+
const [chartHeight, setChartHeight] = React12.useState("340");
|
|
5808
6008
|
const update = (patch) => editor.edit((current) => ({ ...current, ...patch }));
|
|
5809
6009
|
const sheets = editor.viewer.sheets.map((sheet) => [sheet.name, sheet.name]);
|
|
5810
|
-
return /* @__PURE__ */
|
|
5811
|
-
/* @__PURE__ */
|
|
5812
|
-
/* @__PURE__ */
|
|
5813
|
-
/* @__PURE__ */
|
|
5814
|
-
/* @__PURE__ */
|
|
5815
|
-
/* @__PURE__ */
|
|
5816
|
-
/* @__PURE__ */
|
|
5817
|
-
/* @__PURE__ */
|
|
5818
|
-
/* @__PURE__ */
|
|
6010
|
+
return /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
6011
|
+
/* @__PURE__ */ jsxs7(Section, { title: "Source and location", children: [
|
|
6012
|
+
/* @__PURE__ */ jsx9(Text, { label: "PivotTable name", value: pivot.name, onChange: (name) => update({ name }) }),
|
|
6013
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Source worksheet", value: pivot.source.sheet, options: sheets, onChange: (sheet) => update({ source: { ...pivot.source, sheet } }) }),
|
|
6014
|
+
/* @__PURE__ */ jsx9(Text, { label: "Source range", value: pivot.source.range, onChange: (range) => update({ source: { ...pivot.source, range } }) }),
|
|
6015
|
+
/* @__PURE__ */ jsx9(Text, { label: "Source table name (optional)", value: pivot.source.table ?? "", onChange: (table) => update({ source: { ...pivot.source, table: table || null } }) }),
|
|
6016
|
+
/* @__PURE__ */ jsx9(Action, { onClick: editor.readFields, children: "Load source fields" }),
|
|
6017
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Destination worksheet", value: pivot.target.sheet, options: sheets, onChange: (sheet) => update({ target: { ...pivot.target, sheet } }) }),
|
|
6018
|
+
/* @__PURE__ */ jsx9(Text, { label: "Destination cell", value: pivot.target.cell, onChange: (cell) => update({ target: { ...pivot.target, cell } }) })
|
|
5819
6019
|
] }),
|
|
5820
|
-
/* @__PURE__ */
|
|
5821
|
-
/* @__PURE__ */
|
|
5822
|
-
/* @__PURE__ */
|
|
5823
|
-
/* @__PURE__ */
|
|
5824
|
-
/* @__PURE__ */
|
|
5825
|
-
/* @__PURE__ */
|
|
5826
|
-
/* @__PURE__ */
|
|
5827
|
-
/* @__PURE__ */
|
|
5828
|
-
/* @__PURE__ */
|
|
5829
|
-
/* @__PURE__ */
|
|
6020
|
+
/* @__PURE__ */ jsxs7(Section, { title: "Layout and format", children: [
|
|
6021
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Report layout", value: pivot.layout, options: [["compact", "Compact form"], ["outline", "Outline form"], ["tabular", "Tabular form"]], onChange: (layout) => update({ layout }) }),
|
|
6022
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Multiple value fields", value: pivot.valuesOnRows ? "rows" : "columns", options: [["columns", "Show values in columns"], ["rows", "Show values in rows"]], onChange: (value) => update({ valuesOnRows: value === "rows" }) }),
|
|
6023
|
+
/* @__PURE__ */ jsx9(Check, { label: "Repeat item labels", checked: pivot.repeatLabels, onChange: (repeatLabels) => update({ repeatLabels }) }),
|
|
6024
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Subtotals", value: pivot.subtotalsPosition, options: [["top", "At top of group"], ["bottom", "At bottom of group"], ["none", "Do not show"]], onChange: (subtotalsPosition) => update({ subtotalsPosition }) }),
|
|
6025
|
+
/* @__PURE__ */ jsx9(Check, { label: "Grand totals for rows", checked: pivot.rowGrandTotals, onChange: (rowGrandTotals) => update({ rowGrandTotals }) }),
|
|
6026
|
+
/* @__PURE__ */ jsx9(Check, { label: "Grand totals for columns", checked: pivot.columnGrandTotals, onChange: (columnGrandTotals) => update({ columnGrandTotals }) }),
|
|
6027
|
+
/* @__PURE__ */ jsx9(Text, { label: "PivotTable style", value: pivot.styleName, onChange: (styleName) => update({ styleName }) }),
|
|
6028
|
+
/* @__PURE__ */ jsx9(Check, { label: "Preserve cell formatting", checked: pivot.preserveFormatting ?? true, onChange: (preserveFormatting) => update({ preserveFormatting }) }),
|
|
6029
|
+
/* @__PURE__ */ jsx9(Check, { label: "Refresh when opened in Excel", checked: pivot.refreshOnLoad, onChange: (refreshOnLoad) => update({ refreshOnLoad }) })
|
|
5830
6030
|
] }),
|
|
5831
|
-
/* @__PURE__ */
|
|
5832
|
-
/* @__PURE__ */
|
|
5833
|
-
/* @__PURE__ */
|
|
5834
|
-
/* @__PURE__ */
|
|
5835
|
-
pivot.calculatedItems.map((item, index) => /* @__PURE__ */
|
|
5836
|
-
/* @__PURE__ */
|
|
5837
|
-
/* @__PURE__ */
|
|
5838
|
-
/* @__PURE__ */
|
|
5839
|
-
/* @__PURE__ */
|
|
6031
|
+
/* @__PURE__ */ jsxs7(Section, { title: "Calculated fields and items", children: [
|
|
6032
|
+
/* @__PURE__ */ jsx9(Action, { disabled: !pivot.fields.length, onClick: () => editor.edit((current) => ({ ...current, values: [...current.values, { field: current.fields[0].index, name: `Calculated ${current.values.length + 1}`, aggregation: "sum", showAs: "normal", formula: "0" }] })), children: "Add calculated field" }),
|
|
6033
|
+
/* @__PURE__ */ jsx9("p", { style: hint, children: "Edit the new field\u2019s formula in its Values settings." }),
|
|
6034
|
+
/* @__PURE__ */ jsx9("p", { style: hint, children: FORMULA_HELP }),
|
|
6035
|
+
pivot.calculatedItems.map((item, index) => /* @__PURE__ */ jsxs7("div", { style: { ...stack, paddingTop: 8, borderTop: "1px solid var(--xlsx-pivot-border)" }, children: [
|
|
6036
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Field", value: String(item.field), options: pivot.fields.map((field) => [String(field.index), field.name]), onChange: (field) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, field: Number(field) } : entry) }) }),
|
|
6037
|
+
/* @__PURE__ */ jsx9(Text, { label: "Item name", value: item.name, onChange: (name) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, name } : entry) }) }),
|
|
6038
|
+
/* @__PURE__ */ jsx9(Text, { label: "Formula", value: item.formula, onChange: (formula) => update({ calculatedItems: pivot.calculatedItems.map((entry, position) => position === index ? { ...entry, formula } : entry) }) }),
|
|
6039
|
+
/* @__PURE__ */ jsx9(Action, { onClick: () => update({ calculatedItems: pivot.calculatedItems.filter((_, position) => position !== index) }), children: "Remove calculated item" })
|
|
5840
6040
|
] }, index)),
|
|
5841
|
-
/* @__PURE__ */
|
|
6041
|
+
/* @__PURE__ */ jsx9(Action, { disabled: !pivot.fields.length, onClick: () => update({ calculatedItems: [...pivot.calculatedItems, { field: pivot.rows[0]?.field ?? pivot.fields[0].index, name: `Calculated item ${pivot.calculatedItems.length + 1}`, formula: "0" }] }), children: "Add calculated item" })
|
|
5842
6042
|
] }),
|
|
5843
|
-
/* @__PURE__ */
|
|
5844
|
-
pivot.charts?.length ? /* @__PURE__ */
|
|
6043
|
+
/* @__PURE__ */ jsxs7(Section, { title: "PivotChart", children: [
|
|
6044
|
+
pivot.charts?.length ? /* @__PURE__ */ jsxs7("p", { style: hint, children: [
|
|
5845
6045
|
pivot.charts.length,
|
|
5846
6046
|
" linked chart",
|
|
5847
6047
|
pivot.charts.length === 1 ? "" : "s",
|
|
5848
6048
|
". Refreshing the PivotTable updates their values."
|
|
5849
6049
|
] }) : null,
|
|
5850
|
-
/* @__PURE__ */
|
|
5851
|
-
/* @__PURE__ */
|
|
5852
|
-
/* @__PURE__ */
|
|
5853
|
-
/* @__PURE__ */
|
|
5854
|
-
/* @__PURE__ */
|
|
5855
|
-
/* @__PURE__ */
|
|
5856
|
-
/* @__PURE__ */
|
|
6050
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Chart type", value: chartType, options: CHART_TYPES, onChange: (value) => setChartType(value) }),
|
|
6051
|
+
/* @__PURE__ */ jsx9(Text, { label: "Title", value: chartTitle, placeholder: pivot.name, onChange: setChartTitle }),
|
|
6052
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Chart worksheet", value: chartSheet || pivot.target.sheet, options: sheets, onChange: setChartSheet }),
|
|
6053
|
+
/* @__PURE__ */ jsx9(Text, { label: "Top-left cell", value: chartCell, onChange: setChartCell }),
|
|
6054
|
+
/* @__PURE__ */ jsxs7("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
|
|
6055
|
+
/* @__PURE__ */ jsx9(Text, { label: "Width (px)", type: "number", min: 80, max: 1e4, value: chartWidth, onChange: setChartWidth }),
|
|
6056
|
+
/* @__PURE__ */ jsx9(Text, { label: "Height (px)", type: "number", min: 80, max: 1e4, value: chartHeight, onChange: setChartHeight })
|
|
5857
6057
|
] }),
|
|
5858
|
-
/* @__PURE__ */
|
|
5859
|
-
chartType === "Pie" || chartType === "Doughnut" ? /* @__PURE__ */
|
|
5860
|
-
/* @__PURE__ */
|
|
6058
|
+
/* @__PURE__ */ jsx9(Choice, { label: "Values", value: chartMeasure, options: [["", "All value fields"], ...pivot.values.map((value, index) => [String(index), value.name])], onChange: setChartMeasure }),
|
|
6059
|
+
chartType === "Pie" || chartType === "Doughnut" ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Pie and doughnut charts display the first series." }) : null,
|
|
6060
|
+
/* @__PURE__ */ jsx9(Action, { disabled: !pivot.id || editor.dirty || !pivot.values.length, onClick: () => editor.run(() => {
|
|
5861
6061
|
editor.viewer.createPivotChart(pivot.id, { chartType, sheet: chartSheet || pivot.target.sheet, cell: chartCell, title: chartTitle || pivot.name, width: Number(chartWidth), height: Number(chartHeight), measure: chartMeasure ? Number(chartMeasure) : null });
|
|
5862
6062
|
}), children: "Insert PivotChart" }),
|
|
5863
|
-
editor.dirty ? /* @__PURE__ */
|
|
6063
|
+
editor.dirty ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Apply field changes before inserting a chart." }) : null
|
|
5864
6064
|
] })
|
|
5865
6065
|
] });
|
|
5866
6066
|
}
|
|
5867
6067
|
function DefaultXlsxPivotTableFieldList({ editor, isDark = false, className, style }) {
|
|
5868
|
-
const paneRef =
|
|
5869
|
-
const [placement, setPlacement] =
|
|
5870
|
-
const [search, setSearch] =
|
|
5871
|
-
const [selected, setSelected] =
|
|
5872
|
-
const [dragOver, setDragOver] =
|
|
5873
|
-
const [announcement, setAnnouncement] =
|
|
5874
|
-
const titleId =
|
|
5875
|
-
const settingsId =
|
|
6068
|
+
const paneRef = React12.useRef(null);
|
|
6069
|
+
const [placement, setPlacement] = React12.useState({ overlay: false, top: 0, width: 324 });
|
|
6070
|
+
const [search, setSearch] = React12.useState("");
|
|
6071
|
+
const [selected, setSelected] = React12.useState(null);
|
|
6072
|
+
const [dragOver, setDragOver] = React12.useState(null);
|
|
6073
|
+
const [announcement, setAnnouncement] = React12.useState("");
|
|
6074
|
+
const titleId = React12.useId();
|
|
6075
|
+
const settingsId = React12.useId();
|
|
5876
6076
|
const pivot = editor.draft;
|
|
5877
6077
|
const disabled = editor.readOnly || Boolean(pivot?.unsupportedFeatures.length) || editor.sourceNeedsLoad;
|
|
5878
|
-
|
|
6078
|
+
React12.useEffect(() => {
|
|
5879
6079
|
setSelected(null);
|
|
5880
6080
|
setSearch("");
|
|
5881
6081
|
}, [pivot?.id]);
|
|
5882
|
-
|
|
6082
|
+
React12.useEffect(() => {
|
|
5883
6083
|
const parent = paneRef.current?.parentElement;
|
|
5884
6084
|
if (!parent) return;
|
|
5885
6085
|
const viewer = parent.closest(".react-xlsx-viewer");
|
|
@@ -5936,36 +6136,36 @@ function DefaultXlsxPivotTableFieldList({ editor, isDark = false, className, sty
|
|
|
5936
6136
|
event.dataTransfer.setData(DRAG_TYPE, JSON.stringify(data));
|
|
5937
6137
|
event.dataTransfer.effectAllowed = "move";
|
|
5938
6138
|
};
|
|
5939
|
-
return /* @__PURE__ */
|
|
5940
|
-
/* @__PURE__ */
|
|
5941
|
-
/* @__PURE__ */
|
|
5942
|
-
/* @__PURE__ */
|
|
6139
|
+
return /* @__PURE__ */ jsxs7("aside", { ref: paneRef, "aria-labelledby": titleId, className, style: { ...theme, boxSizing: "border-box", display: "flex", flexDirection: "column", width: placement.width, minWidth: 0, maxWidth: "100%", height: "100%", minHeight: 0, flexShrink: 0, borderInlineStart: "1px solid var(--xlsx-pivot-border)", background: "var(--xlsx-pivot-bg)", color: isDark ? "#edf2ef" : "#202a24", font: "12px/1.4 system-ui, sans-serif", ...placement.overlay ? { position: "absolute", insetInlineEnd: 0, top: placement.top, bottom: 0, height: "auto", zIndex: 20, boxShadow: "-6px 0 18px #0002" } : {}, ...style }, children: [
|
|
6140
|
+
/* @__PURE__ */ jsxs7("header", { style: { ...row, justifyContent: "space-between", padding: "10px 12px", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: [
|
|
6141
|
+
/* @__PURE__ */ jsx9("h2", { id: titleId, style: { margin: 0, fontSize: 16, fontWeight: 600 }, children: "PivotTable Fields" }),
|
|
6142
|
+
/* @__PURE__ */ jsx9(Action, { "aria-label": "Close PivotTable field list", onClick: () => editor.setOpen(false), style: { border: 0, background: "transparent", fontSize: 20, lineHeight: 1, padding: "2px 6px" }, children: "\xD7" })
|
|
5943
6143
|
] }),
|
|
5944
|
-
/* @__PURE__ */
|
|
5945
|
-
/* @__PURE__ */
|
|
5946
|
-
/* @__PURE__ */
|
|
5947
|
-
/* @__PURE__ */
|
|
5948
|
-
/* @__PURE__ */
|
|
6144
|
+
/* @__PURE__ */ jsxs7("div", { style: { overflowY: "auto", flex: 1, minHeight: 0 }, children: [
|
|
6145
|
+
/* @__PURE__ */ jsxs7("div", { style: { ...stack, padding: 12 }, children: [
|
|
6146
|
+
/* @__PURE__ */ jsxs7("div", { style: { ...row, alignItems: "end" }, children: [
|
|
6147
|
+
/* @__PURE__ */ jsx9("div", { style: { flex: 1, minWidth: 0 }, children: /* @__PURE__ */ jsx9(Choice, { label: "PivotTable", value: pivot?.id ?? "", placeholder: pivot && !pivot.id ? pivot.name : "Choose a PivotTable", options: editor.viewer.pivotTables.map((item) => [item.id, item.name]), onChange: editor.select, disabled: editor.dirty }) }),
|
|
6148
|
+
/* @__PURE__ */ jsx9(Action, { disabled: editor.viewer.readOnly || editor.dirty, onClick: editor.create, children: "New" })
|
|
5949
6149
|
] }),
|
|
5950
|
-
editor.error ? /* @__PURE__ */
|
|
5951
|
-
editor.status ? /* @__PURE__ */
|
|
5952
|
-
editor.stale ? /* @__PURE__ */
|
|
5953
|
-
editor.sourceNeedsLoad ? /* @__PURE__ */
|
|
5954
|
-
pivot?.unsupportedFeatures.length ? /* @__PURE__ */
|
|
6150
|
+
editor.error ? /* @__PURE__ */ jsx9("p", { role: "alert", style: { margin: 0, color: isDark ? "#ffb7b0" : "#a12622", overflowWrap: "anywhere" }, children: editor.error }) : null,
|
|
6151
|
+
editor.status ? /* @__PURE__ */ jsx9("p", { role: "status", style: hint, children: editor.status }) : null,
|
|
6152
|
+
editor.stale ? /* @__PURE__ */ jsx9("p", { role: "alert", style: hint, children: "The worksheet changed while you were editing. Discard these changes to load the current PivotTable." }) : null,
|
|
6153
|
+
editor.sourceNeedsLoad ? /* @__PURE__ */ jsx9("p", { role: "status", style: hint, children: "The source changed. Load its fields under Source and location." }) : null,
|
|
6154
|
+
pivot?.unsupportedFeatures.length ? /* @__PURE__ */ jsxs7("p", { style: hint, children: [
|
|
5955
6155
|
"This PivotTable is preserved for Excel. Editing is unavailable for: ",
|
|
5956
6156
|
pivot.unsupportedFeatures.join(", "),
|
|
5957
6157
|
"."
|
|
5958
6158
|
] }) : null,
|
|
5959
|
-
editor.viewer.readOnly ? /* @__PURE__ */
|
|
6159
|
+
editor.viewer.readOnly ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Enable workbook editing to change this PivotTable." }) : null
|
|
5960
6160
|
] }),
|
|
5961
|
-
pivot ? /* @__PURE__ */
|
|
5962
|
-
/* @__PURE__ */
|
|
5963
|
-
/* @__PURE__ */
|
|
5964
|
-
/* @__PURE__ */
|
|
5965
|
-
/* @__PURE__ */
|
|
6161
|
+
pivot ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
6162
|
+
/* @__PURE__ */ jsxs7("fieldset", { disabled, style: { margin: 0, padding: "0 12px 12px", border: 0, minWidth: 0 }, children: [
|
|
6163
|
+
/* @__PURE__ */ jsx9("legend", { style: { padding: 0, fontWeight: 600, marginBottom: 8 }, children: "Choose fields to add to report" }),
|
|
6164
|
+
/* @__PURE__ */ jsx9("input", { "aria-label": "Search PivotTable fields", type: "search", placeholder: "Search fields", value: search, onChange: (event) => setSearch(event.target.value), style: { ...control, marginBottom: 6 } }),
|
|
6165
|
+
/* @__PURE__ */ jsxs7("div", { role: "group", "aria-label": "Source fields", style: { maxHeight: 190, overflowY: "auto", border: "1px solid var(--xlsx-pivot-border)", padding: "5px 7px", background: "var(--xlsx-pivot-input)" }, children: [
|
|
5966
6166
|
pivot.fields.filter((field) => field.name.toLocaleLowerCase().includes(search.toLocaleLowerCase())).map((field) => {
|
|
5967
6167
|
const checked = AREAS.some((area) => pivot[area].some((_, index) => sourceFieldIndex(pivot, area, index) === field.index));
|
|
5968
|
-
return /* @__PURE__ */
|
|
6168
|
+
return /* @__PURE__ */ jsx9("div", { draggable: !disabled, onDragStart: (event) => drag(event, { field: field.index }), style: { padding: "2px 0" }, children: /* @__PURE__ */ jsx9(Check, { label: field.name, checked, onChange: (value) => {
|
|
5969
6169
|
if (value) editor.addField(field.dataType === "number" ? "values" : "rows", field.index);
|
|
5970
6170
|
else {
|
|
5971
6171
|
for (const area of AREAS) for (let index = pivot[area].length - 1; index >= 0; index--) if (sourceFieldIndex(pivot, area, index) === field.index) editor.removeField(area, index);
|
|
@@ -5974,10 +6174,10 @@ function DefaultXlsxPivotTableFieldList({ editor, isDark = false, className, sty
|
|
|
5974
6174
|
setSelected(null);
|
|
5975
6175
|
} }) }, field.index);
|
|
5976
6176
|
}),
|
|
5977
|
-
!pivot.fields.length ? /* @__PURE__ */
|
|
6177
|
+
!pivot.fields.length ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Load source fields to begin." }) : !pivot.fields.some((field) => field.name.toLocaleLowerCase().includes(search.toLocaleLowerCase())) ? /* @__PURE__ */ jsx9("p", { style: hint, children: "No matching fields." }) : null
|
|
5978
6178
|
] }),
|
|
5979
|
-
/* @__PURE__ */
|
|
5980
|
-
/* @__PURE__ */
|
|
6179
|
+
/* @__PURE__ */ jsx9("p", { style: { ...hint, marginBlock: "10px 6px" }, children: "Drag fields between the areas below." }),
|
|
6180
|
+
/* @__PURE__ */ jsx9("div", { style: { display: "grid", gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1fr)", gap: 8 }, children: AREAS.map((area) => /* @__PURE__ */ jsxs7("section", { "aria-label": `${AREA_NAMES[area]} fields`, onDragOver: (event) => {
|
|
5981
6181
|
if (!disabled && event.dataTransfer.types.includes(DRAG_TYPE)) {
|
|
5982
6182
|
event.preventDefault();
|
|
5983
6183
|
setDragOver(area);
|
|
@@ -5985,100 +6185,100 @@ function DefaultXlsxPivotTableFieldList({ editor, isDark = false, className, sty
|
|
|
5985
6185
|
}, onDragLeave: (event) => {
|
|
5986
6186
|
if (!event.currentTarget.contains(event.relatedTarget)) setDragOver(null);
|
|
5987
6187
|
}, onDrop: (event) => drop(event, area), style: { minHeight: 94, minWidth: 0, border: `1px solid ${dragOver === area ? "var(--xlsx-pivot-accent)" : "var(--xlsx-pivot-border)"}`, background: dragOver === area ? "var(--xlsx-pivot-hover)" : "var(--xlsx-pivot-input)" }, children: [
|
|
5988
|
-
/* @__PURE__ */
|
|
6188
|
+
/* @__PURE__ */ jsxs7("h3", { style: { margin: 0, padding: "5px 6px", fontSize: 11, fontWeight: 600, borderBottom: "1px solid var(--xlsx-pivot-border)", background: "var(--xlsx-pivot-bg)" }, children: [
|
|
5989
6189
|
area === "values" ? "\u03A3 " : "",
|
|
5990
6190
|
AREA_NAMES[area]
|
|
5991
6191
|
] }),
|
|
5992
|
-
/* @__PURE__ */
|
|
6192
|
+
/* @__PURE__ */ jsxs7("div", { style: { padding: 4 }, children: [
|
|
5993
6193
|
pivot[area].map((_, index) => {
|
|
5994
6194
|
const field = fieldIndex(pivot, area, index);
|
|
5995
6195
|
const name = area === "values" ? pivot.values[index].name : area === "reportFilters" ? fieldName(pivot, field) : pivot[area][index].name || fieldName(pivot, field);
|
|
5996
6196
|
const active = selected?.area === area && selected.index === index;
|
|
5997
|
-
return /* @__PURE__ */
|
|
6197
|
+
return /* @__PURE__ */ jsx9("div", { draggable: !disabled, onDragStart: (event) => drag(event, { area, index }), onDrop: (event) => drop(event, area, index), style: { marginBottom: 3 }, children: /* @__PURE__ */ jsxs7("button", { type: "button", "aria-expanded": active, "aria-controls": settingsId, title: `${name} settings. Alt+Up or Alt+Down reorders the field.`, onClick: () => setSelected(active ? null : { area, index }), onKeyDown: (event) => {
|
|
5998
6198
|
if (!event.altKey || !["ArrowUp", "ArrowDown"].includes(event.key)) return;
|
|
5999
6199
|
event.preventDefault();
|
|
6000
6200
|
const position = index + (event.key === "ArrowUp" ? -1 : 1);
|
|
6001
6201
|
if (position >= 0 && position < pivot[area].length) move({ area, index }, area, position);
|
|
6002
6202
|
}, style: { ...control, ...row, textAlign: "start", justifyContent: "space-between", background: active ? "var(--xlsx-pivot-hover)" : "var(--xlsx-pivot-bg)", padding: "4px 5px", cursor: "pointer", fontSize: 11 }, children: [
|
|
6003
|
-
/* @__PURE__ */
|
|
6004
|
-
/* @__PURE__ */
|
|
6203
|
+
/* @__PURE__ */ jsx9("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: name }),
|
|
6204
|
+
/* @__PURE__ */ jsx9("span", { "aria-hidden": "true", children: "\u25BE" })
|
|
6005
6205
|
] }) }, `${field}-${index}`);
|
|
6006
6206
|
}),
|
|
6007
|
-
!pivot[area].length ? /* @__PURE__ */
|
|
6207
|
+
!pivot[area].length ? /* @__PURE__ */ jsx9("p", { style: { ...hint, padding: "5px 3px", fontSize: 10 }, children: "Drop fields here" }) : null
|
|
6008
6208
|
] })
|
|
6009
6209
|
] }, area)) }),
|
|
6010
|
-
/* @__PURE__ */
|
|
6011
|
-
selected && selectedField !== void 0 ? /* @__PURE__ */
|
|
6012
|
-
/* @__PURE__ */
|
|
6013
|
-
/* @__PURE__ */
|
|
6210
|
+
/* @__PURE__ */ jsx9("p", { style: { ...hint, marginTop: 6 }, children: "Select a field for settings and keyboard move controls." }),
|
|
6211
|
+
selected && selectedField !== void 0 ? /* @__PURE__ */ jsxs7("section", { id: settingsId, "aria-label": "Field settings", style: { ...stack, marginTop: 12, paddingTop: 10, borderTop: "2px solid var(--xlsx-pivot-accent)" }, children: [
|
|
6212
|
+
/* @__PURE__ */ jsxs7("div", { style: { ...row, justifyContent: "space-between" }, children: [
|
|
6213
|
+
/* @__PURE__ */ jsxs7("strong", { style: { overflowWrap: "anywhere" }, children: [
|
|
6014
6214
|
selected.area === "values" ? pivot.values[selected.index].name : fieldName(pivot, selectedField),
|
|
6015
6215
|
" settings"
|
|
6016
6216
|
] }),
|
|
6017
|
-
/* @__PURE__ */
|
|
6217
|
+
/* @__PURE__ */ jsx9(Action, { "aria-label": "Close field settings", onClick: () => setSelected(null), children: "\xD7" })
|
|
6018
6218
|
] }),
|
|
6019
|
-
selectedCalculated ? /* @__PURE__ */
|
|
6020
|
-
/* @__PURE__ */
|
|
6021
|
-
/* @__PURE__ */
|
|
6022
|
-
/* @__PURE__ */
|
|
6023
|
-
/* @__PURE__ */
|
|
6219
|
+
selectedCalculated ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Calculated fields stay in the Values area." }) : /* @__PURE__ */ jsx9(Choice, { label: "Move to", value: selected.area, options: AREAS.map((area) => [area, AREA_NAMES[area]]), onChange: (area) => move(selected, area) }),
|
|
6220
|
+
/* @__PURE__ */ jsxs7("div", { style: { ...row, flexWrap: "wrap" }, children: [
|
|
6221
|
+
/* @__PURE__ */ jsx9(Action, { disabled: selected.index === 0, onClick: () => move(selected, selected.area, selected.index - 1), children: "Move up" }),
|
|
6222
|
+
/* @__PURE__ */ jsx9(Action, { disabled: selected.index === pivot[selected.area].length - 1, onClick: () => move(selected, selected.area, selected.index + 1), children: "Move down" }),
|
|
6223
|
+
/* @__PURE__ */ jsx9(Action, { onClick: () => {
|
|
6024
6224
|
editor.removeField(selected.area, selected.index);
|
|
6025
6225
|
setSelected(null);
|
|
6026
6226
|
}, children: "Remove field" })
|
|
6027
6227
|
] }),
|
|
6028
|
-
selected.area === "values" ? /* @__PURE__ */
|
|
6228
|
+
selected.area === "values" ? /* @__PURE__ */ jsx9(ValueSettings, { pivot, value: pivot.values[selected.index], onChange: (value) => editor.edit((current) => ({ ...current, values: current.values.map((item, index) => index === selected.index ? value : item) })) }) : selected.area === "rows" || selected.area === "columns" ? /* @__PURE__ */ jsx9(AxisSettings, { pivot, axis: pivot[selected.area][selected.index], onChange: (axis) => editor.edit((current) => ({ ...current, [selected.area]: current[selected.area].map((item, index) => index === selected.index ? axis : item) })), onAddDateLevel: (unit) => editor.edit((current) => {
|
|
6029
6229
|
const area = selected.area;
|
|
6030
6230
|
const axis = current[area][selected.index];
|
|
6031
6231
|
return { ...current, [area]: [...current[area].slice(0, selected.index + 1), { ...axis, name: unit[0].toUpperCase() + unit.slice(1), grouping: { ...axis.grouping, kind: "date", unit }, items: [], collapsed: [] }, ...current[area].slice(selected.index + 1)] };
|
|
6032
6232
|
}) }) : null,
|
|
6033
|
-
selected.area !== "values" ? /* @__PURE__ */
|
|
6233
|
+
selected.area !== "values" ? /* @__PURE__ */ jsx9(FieldFilters, { editor, pivot, field: selectedField, axis: selected.area === "rows" || selected.area === "columns" ? pivot[selected.area][selected.index] : void 0 }) : null
|
|
6034
6234
|
] }) : null
|
|
6035
6235
|
] }),
|
|
6036
|
-
/* @__PURE__ */
|
|
6037
|
-
/* @__PURE__ */
|
|
6038
|
-
/* @__PURE__ */
|
|
6039
|
-
/* @__PURE__ */
|
|
6040
|
-
/* @__PURE__ */
|
|
6041
|
-
/* @__PURE__ */
|
|
6236
|
+
/* @__PURE__ */ jsx9("fieldset", { disabled: editor.readOnly || Boolean(pivot.unsupportedFeatures.length), style: { margin: 0, padding: 0, minWidth: 0, border: 0 }, children: /* @__PURE__ */ jsx9(Advanced, { editor, pivot }) }),
|
|
6237
|
+
/* @__PURE__ */ jsxs7(Section, { title: "Refresh and details", children: [
|
|
6238
|
+
/* @__PURE__ */ jsxs7("div", { style: { ...row, flexWrap: "wrap" }, children: [
|
|
6239
|
+
/* @__PURE__ */ jsx9(Action, { disabled: disabled || editor.dirty || !pivot.id, onClick: () => editor.refresh(), children: "Refresh" }),
|
|
6240
|
+
/* @__PURE__ */ jsx9(Action, { disabled: editor.readOnly || editor.dirty || !editor.viewer.pivotTables.length, onClick: () => editor.refresh(true), children: "Refresh all" }),
|
|
6241
|
+
/* @__PURE__ */ jsx9(Action, { disabled: disabled || editor.dirty || !pivot.id, onClick: editor.showDetails, children: "Show details" })
|
|
6042
6242
|
] }),
|
|
6043
|
-
/* @__PURE__ */
|
|
6044
|
-
editor.details ? /* @__PURE__ */
|
|
6045
|
-
/* @__PURE__ */
|
|
6046
|
-
/* @__PURE__ */
|
|
6243
|
+
/* @__PURE__ */ jsx9("p", { style: hint, children: "Select a value cell in the report to inspect its source records." }),
|
|
6244
|
+
editor.details ? /* @__PURE__ */ jsxs7(Fragment8, { children: [
|
|
6245
|
+
/* @__PURE__ */ jsxs7("div", { style: { ...row, justifyContent: "space-between" }, children: [
|
|
6246
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
6047
6247
|
editor.details.rows.length.toLocaleString(),
|
|
6048
6248
|
" records"
|
|
6049
6249
|
] }),
|
|
6050
|
-
/* @__PURE__ */
|
|
6250
|
+
/* @__PURE__ */ jsx9(Action, { onClick: editor.clearDetails, children: "Close details" })
|
|
6051
6251
|
] }),
|
|
6052
|
-
/* @__PURE__ */
|
|
6053
|
-
/* @__PURE__ */
|
|
6054
|
-
/* @__PURE__ */
|
|
6252
|
+
/* @__PURE__ */ jsx9("div", { style: { maxHeight: 210, overflow: "auto", border: "1px solid var(--xlsx-pivot-border)" }, children: /* @__PURE__ */ jsxs7("table", { style: { borderCollapse: "collapse", fontSize: 11 }, children: [
|
|
6253
|
+
/* @__PURE__ */ jsx9("thead", { children: /* @__PURE__ */ jsx9("tr", { children: editor.details.fields.map((field, index) => /* @__PURE__ */ jsx9("th", { scope: "col", style: { padding: "5px 7px", textAlign: "start", whiteSpace: "nowrap", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: field }, index)) }) }),
|
|
6254
|
+
/* @__PURE__ */ jsx9("tbody", { children: editor.details.rows.slice(0, 100).map((record, index) => /* @__PURE__ */ jsx9("tr", { children: record.map((value, column) => /* @__PURE__ */ jsx9("td", { style: { padding: "4px 7px", whiteSpace: "nowrap", borderBottom: "1px solid var(--xlsx-pivot-border)" }, children: value == null ? "" : String(value) }, column)) }, index)) })
|
|
6055
6255
|
] }) }),
|
|
6056
|
-
editor.details.rows.length > 100 ? /* @__PURE__ */
|
|
6057
|
-
/* @__PURE__ */
|
|
6256
|
+
editor.details.rows.length > 100 ? /* @__PURE__ */ jsx9("p", { style: hint, children: "Showing the first 100 records. Create a detail worksheet to see all records." }) : null,
|
|
6257
|
+
/* @__PURE__ */ jsx9(Action, { disabled: editor.readOnly || !editor.detailContext, onClick: () => editor.run(() => {
|
|
6058
6258
|
const context = editor.detailContext;
|
|
6059
6259
|
if (context) editor.viewer.showPivotDetails(context.id, context.row, context.col);
|
|
6060
6260
|
}), children: "Create detail worksheet" })
|
|
6061
6261
|
] }) : null,
|
|
6062
|
-
/* @__PURE__ */
|
|
6262
|
+
/* @__PURE__ */ jsx9(Action, { disabled: editor.readOnly || editor.dirty || !pivot.id, onClick: editor.remove, children: "Remove PivotTable" })
|
|
6063
6263
|
] })
|
|
6064
|
-
] }) : /* @__PURE__ */
|
|
6065
|
-
/* @__PURE__ */
|
|
6066
|
-
/* @__PURE__ */
|
|
6264
|
+
] }) : /* @__PURE__ */ jsxs7("div", { style: { ...stack, padding: "4px 12px 20px" }, children: [
|
|
6265
|
+
/* @__PURE__ */ jsx9("p", { style: hint, children: "Select a PivotTable cell to arrange its fields, or create a PivotTable from the selected data." }),
|
|
6266
|
+
/* @__PURE__ */ jsx9(Action, { primary: true, disabled: editor.readOnly || !editor.viewer.activeSheet, onClick: editor.create, children: "Create PivotTable" })
|
|
6067
6267
|
] })
|
|
6068
6268
|
] }),
|
|
6069
|
-
pivot ? /* @__PURE__ */
|
|
6070
|
-
/* @__PURE__ */
|
|
6071
|
-
/* @__PURE__ */
|
|
6072
|
-
/* @__PURE__ */
|
|
6073
|
-
/* @__PURE__ */
|
|
6269
|
+
pivot ? /* @__PURE__ */ jsx9("footer", { style: { ...stack, gap: 7, padding: "10px 12px", borderTop: "1px solid var(--xlsx-pivot-border)" }, children: /* @__PURE__ */ jsxs7("div", { style: { ...row, justifyContent: "space-between" }, children: [
|
|
6270
|
+
/* @__PURE__ */ jsx9("span", { style: hint, children: editor.dirty ? "Changes pending" : "Report is up to date" }),
|
|
6271
|
+
/* @__PURE__ */ jsxs7("div", { style: row, children: [
|
|
6272
|
+
/* @__PURE__ */ jsx9(Action, { disabled: !editor.dirty, onClick: editor.reset, children: "Discard" }),
|
|
6273
|
+
/* @__PURE__ */ jsx9(Action, { primary: true, disabled: disabled || !editor.dirty || editor.stale, onClick: editor.apply, children: "Apply" })
|
|
6074
6274
|
] })
|
|
6075
6275
|
] }) }) : null,
|
|
6076
|
-
/* @__PURE__ */
|
|
6276
|
+
/* @__PURE__ */ jsx9("span", { role: "status", "aria-live": "polite", style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)", whiteSpace: "nowrap" }, children: announcement })
|
|
6077
6277
|
] });
|
|
6078
6278
|
}
|
|
6079
6279
|
|
|
6080
6280
|
// src/lazy-chart.tsx
|
|
6081
|
-
import * as
|
|
6281
|
+
import * as React14 from "react";
|
|
6082
6282
|
|
|
6083
6283
|
// src/chart-loader.ts
|
|
6084
6284
|
function createChartModule(importModule) {
|
|
@@ -6109,15 +6309,15 @@ function createChartModule(importModule) {
|
|
|
6109
6309
|
};
|
|
6110
6310
|
}
|
|
6111
6311
|
var officeChartRenderer = createChartModule(async () => {
|
|
6112
|
-
const { SharedChartSvg } = await import("./shared-chart-
|
|
6312
|
+
const { SharedChartSvg } = await import("./shared-chart-24MCGSFJ.js");
|
|
6113
6313
|
return { renderer: null, SharedChartSvg };
|
|
6114
6314
|
});
|
|
6115
6315
|
|
|
6116
6316
|
// src/use-chart-module.ts
|
|
6117
|
-
import * as
|
|
6317
|
+
import * as React13 from "react";
|
|
6118
6318
|
|
|
6119
6319
|
// src/lazy-chart.tsx
|
|
6120
|
-
import { Fragment as Fragment9, jsx as
|
|
6320
|
+
import { Fragment as Fragment9, jsx as jsx10 } from "react/jsx-runtime";
|
|
6121
6321
|
|
|
6122
6322
|
// src/picture-paint.ts
|
|
6123
6323
|
function resolvePicturePaintRect(image, rect) {
|
|
@@ -6134,13 +6334,13 @@ function resolvePicturePaintRect(image, rect) {
|
|
|
6134
6334
|
}
|
|
6135
6335
|
|
|
6136
6336
|
// src/XlsxViewer.tsx
|
|
6137
|
-
import { Fragment as Fragment11, jsx as
|
|
6337
|
+
import { Fragment as Fragment11, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
6138
6338
|
var DEFAULT_ROW_HEIGHT2 = 24;
|
|
6139
6339
|
var DEFAULT_COL_WIDTH2 = 80;
|
|
6140
6340
|
var MAX_AUTOFIT_ROW_HEIGHT_PX = 409 * (4 / 3);
|
|
6141
6341
|
var HEADER_HEIGHT = 24;
|
|
6142
6342
|
var ROW_HEADER_WIDTH = 40;
|
|
6143
|
-
var
|
|
6343
|
+
var HEADER_RESIZE_HANDLE_PX = 8;
|
|
6144
6344
|
var CANVAS_VIEWPORT_OVERSCAN_PX = 480;
|
|
6145
6345
|
var CANVAS_SCROLL_BUFFER_PX = 480;
|
|
6146
6346
|
var CANVAS_DEFERRED_VIEWPORT_SYNC_THRESHOLD_PX = CANVAS_SCROLL_BUFFER_PX - 96;
|
|
@@ -6808,10 +7008,10 @@ function lightenColor(color, ratio) {
|
|
|
6808
7008
|
function darkenColor(color, ratio) {
|
|
6809
7009
|
return mixRgbColor(color, "#000000", ratio);
|
|
6810
7010
|
}
|
|
6811
|
-
var ViewerContext =
|
|
6812
|
-
var ViewerAppearanceContext =
|
|
7011
|
+
var ViewerContext = React15.createContext(null);
|
|
7012
|
+
var ViewerAppearanceContext = React15.createContext({ isDark: false });
|
|
6813
7013
|
function ReferenceRangeHandles({ color, top = true, bottom = true, left = true, right = true }) {
|
|
6814
|
-
return /* @__PURE__ */
|
|
7014
|
+
return /* @__PURE__ */ jsx11(Fragment11, { children: [top && "top", bottom && "bottom"].flatMap((vertical) => vertical ? [left && "left", right && "right"].map((horizontal) => horizontal ? /* @__PURE__ */ jsx11("span", { style: {
|
|
6815
7015
|
position: "absolute",
|
|
6816
7016
|
[vertical]: -4,
|
|
6817
7017
|
[horizontal]: -4,
|
|
@@ -6853,23 +7053,10 @@ function buildVisibleAxisIndices(precomputed, displayLimit, maxUsedIndex, hidden
|
|
|
6853
7053
|
if (displayLimit <= 0) {
|
|
6854
7054
|
return [];
|
|
6855
7055
|
}
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
if (!hiddenIndices?.has(index)) {
|
|
6861
|
-
visible2.push(index);
|
|
6862
|
-
}
|
|
6863
|
-
}
|
|
6864
|
-
for (let index = usedLimit; index < displayLimit; index += 1) {
|
|
6865
|
-
visible2.push(index);
|
|
6866
|
-
}
|
|
6867
|
-
return visible2;
|
|
6868
|
-
}
|
|
6869
|
-
const visible = precomputed.filter((value) => value < displayLimit);
|
|
6870
|
-
const appendStart = Math.max(0, maxUsedIndex + 1);
|
|
6871
|
-
for (let index = appendStart; index < displayLimit; index += 1) {
|
|
6872
|
-
visible.push(index);
|
|
7056
|
+
const visible = precomputed.filter((index) => index < displayLimit);
|
|
7057
|
+
const appendStart = precomputed.length ? Math.max(0, maxUsedIndex + 1) : 0;
|
|
7058
|
+
for (let index = appendStart; index < displayLimit; index++) {
|
|
7059
|
+
if (!hiddenIndices?.has(index)) visible.push(index);
|
|
6873
7060
|
}
|
|
6874
7061
|
return visible;
|
|
6875
7062
|
}
|
|
@@ -7788,7 +7975,7 @@ function applyCanvasShapeDash(context, dash, lineWidth) {
|
|
|
7788
7975
|
}
|
|
7789
7976
|
}
|
|
7790
7977
|
function useViewerPalette(isDark = false, headerBackgroundColor, headerTextColor) {
|
|
7791
|
-
return
|
|
7978
|
+
return React15.useMemo(
|
|
7792
7979
|
() => resolveViewerPalette(isDark, headerBackgroundColor, headerTextColor),
|
|
7793
7980
|
[headerBackgroundColor, headerTextColor, isDark]
|
|
7794
7981
|
);
|
|
@@ -8475,10 +8662,10 @@ function renderSparkline(sparkline, values, palette) {
|
|
|
8475
8662
|
const gap = normalizedValues.length > 1 ? (innerWidth2 - segmentWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
|
|
8476
8663
|
const positiveY = 4.5;
|
|
8477
8664
|
const negativeY = height - 4.5;
|
|
8478
|
-
return /* @__PURE__ */
|
|
8665
|
+
return /* @__PURE__ */ jsx11("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: normalizedValues.map((entry, index) => {
|
|
8479
8666
|
const left = 1 + index * (segmentWidth + Math.max(0, gap));
|
|
8480
8667
|
const y = entry.value >= 0 ? positiveY : negativeY;
|
|
8481
|
-
return /* @__PURE__ */
|
|
8668
|
+
return /* @__PURE__ */ jsx11(
|
|
8482
8669
|
"line",
|
|
8483
8670
|
{
|
|
8484
8671
|
stroke: seriesColor,
|
|
@@ -8500,15 +8687,15 @@ function renderSparkline(sparkline, values, palette) {
|
|
|
8500
8687
|
const zeroY = 2 + innerHeight2 - clampSparklineValue(0, minValue2, maxValue2) * innerHeight2;
|
|
8501
8688
|
const barWidth = Math.max(2, innerWidth2 / Math.max(normalizedValues.length * 1.8, 1));
|
|
8502
8689
|
const gap = normalizedValues.length > 1 ? (innerWidth2 - barWidth * normalizedValues.length) / (normalizedValues.length - 1) : 0;
|
|
8503
|
-
return /* @__PURE__ */
|
|
8504
|
-
/* @__PURE__ */
|
|
8690
|
+
return /* @__PURE__ */ jsxs8("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
|
|
8691
|
+
/* @__PURE__ */ jsx11("line", { stroke: palette.border, strokeWidth: 1, x1: 1, x2: width - 1, y1: zeroY, y2: zeroY }),
|
|
8505
8692
|
normalizedValues.map((entry, index) => {
|
|
8506
8693
|
const left = 1 + index * (barWidth + Math.max(0, gap));
|
|
8507
8694
|
const y = 2 + innerHeight2 - clampSparklineValue(entry.value, minValue2, maxValue2) * innerHeight2;
|
|
8508
8695
|
const top = Math.min(y, zeroY);
|
|
8509
8696
|
const barHeight = Math.max(1, Math.abs(y - zeroY));
|
|
8510
8697
|
const fill = entry.value < 0 ? negativeColor : seriesColor;
|
|
8511
|
-
return /* @__PURE__ */
|
|
8698
|
+
return /* @__PURE__ */ jsx11(
|
|
8512
8699
|
"rect",
|
|
8513
8700
|
{
|
|
8514
8701
|
fill,
|
|
@@ -8534,8 +8721,8 @@ function renderSparkline(sparkline, values, palette) {
|
|
|
8534
8721
|
}).join(" ");
|
|
8535
8722
|
const highValue = Math.max(...points.map((entry) => entry.value));
|
|
8536
8723
|
const lowValue = Math.min(...points.map((entry) => entry.value));
|
|
8537
|
-
return /* @__PURE__ */
|
|
8538
|
-
/* @__PURE__ */
|
|
8724
|
+
return /* @__PURE__ */ jsxs8("svg", { "aria-hidden": "true", height, style: { display: "block", overflow: "visible", width: "100%" }, viewBox: `0 0 ${width} ${height}`, width: "100%", children: [
|
|
8725
|
+
/* @__PURE__ */ jsx11("path", { d: path, fill: "none", stroke: seriesColor, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6 }),
|
|
8539
8726
|
sparkline.markers ? points.map((entry, index) => {
|
|
8540
8727
|
const x = 1 + index * xStep;
|
|
8541
8728
|
const y = 2 + innerHeight2 - clampSparklineValue(entry.value, minValue, maxValue) * innerHeight2;
|
|
@@ -8551,7 +8738,7 @@ function renderSparkline(sparkline, values, palette) {
|
|
|
8551
8738
|
} else if (entry.value < 0 && sparkline.negative && sparkline.negativeColor) {
|
|
8552
8739
|
fill = sparkline.negativeColor;
|
|
8553
8740
|
}
|
|
8554
|
-
return /* @__PURE__ */
|
|
8741
|
+
return /* @__PURE__ */ jsx11("circle", { cx: x, cy: y, fill, r: 1.75 }, `spark-point-${index}`);
|
|
8555
8742
|
}) : null
|
|
8556
8743
|
] });
|
|
8557
8744
|
}
|
|
@@ -8675,7 +8862,7 @@ function SegmentedControl({
|
|
|
8675
8862
|
palette,
|
|
8676
8863
|
value
|
|
8677
8864
|
}) {
|
|
8678
|
-
return /* @__PURE__ */
|
|
8865
|
+
return /* @__PURE__ */ jsx11(
|
|
8679
8866
|
"div",
|
|
8680
8867
|
{
|
|
8681
8868
|
"aria-label": messages.workbookSheets,
|
|
@@ -8693,7 +8880,7 @@ function SegmentedControl({
|
|
|
8693
8880
|
children: items.map((item) => {
|
|
8694
8881
|
const selected = item.id === value;
|
|
8695
8882
|
const isHidden = item.visibility === "hidden" || item.visibility === "veryHidden";
|
|
8696
|
-
return /* @__PURE__ */
|
|
8883
|
+
return /* @__PURE__ */ jsx11(
|
|
8697
8884
|
"button",
|
|
8698
8885
|
{
|
|
8699
8886
|
"aria-selected": selected,
|
|
@@ -8741,8 +8928,8 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8741
8928
|
zoomOut,
|
|
8742
8929
|
zoomScale
|
|
8743
8930
|
} = controller;
|
|
8744
|
-
return /* @__PURE__ */
|
|
8745
|
-
/* @__PURE__ */
|
|
8931
|
+
return /* @__PURE__ */ jsxs8(Fragment11, { children: [
|
|
8932
|
+
/* @__PURE__ */ jsxs8(
|
|
8746
8933
|
"div",
|
|
8747
8934
|
{
|
|
8748
8935
|
style: {
|
|
@@ -8757,7 +8944,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8757
8944
|
padding: "0 16px"
|
|
8758
8945
|
},
|
|
8759
8946
|
children: [
|
|
8760
|
-
/* @__PURE__ */
|
|
8947
|
+
/* @__PURE__ */ jsx11("div", { style: { minWidth: 0 }, children: /* @__PURE__ */ jsx11(
|
|
8761
8948
|
"div",
|
|
8762
8949
|
{
|
|
8763
8950
|
style: {
|
|
@@ -8771,8 +8958,8 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8771
8958
|
children: displayFileName
|
|
8772
8959
|
}
|
|
8773
8960
|
) }),
|
|
8774
|
-
/* @__PURE__ */
|
|
8775
|
-
pivotTableEditor && (!controller.readOnly || controller.pivotTables.length > 0) ? /* @__PURE__ */
|
|
8961
|
+
/* @__PURE__ */ jsxs8("div", { style: { alignItems: "center", display: "flex", gap: 8 }, children: [
|
|
8962
|
+
pivotTableEditor && (!controller.readOnly || controller.pivotTables.length > 0) ? /* @__PURE__ */ jsx11(
|
|
8776
8963
|
"button",
|
|
8777
8964
|
{
|
|
8778
8965
|
"aria-label": messages.pivotTableFields,
|
|
@@ -8788,7 +8975,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8788
8975
|
children: "PivotTable"
|
|
8789
8976
|
}
|
|
8790
8977
|
) : null,
|
|
8791
|
-
/* @__PURE__ */
|
|
8978
|
+
/* @__PURE__ */ jsxs8(
|
|
8792
8979
|
"div",
|
|
8793
8980
|
{
|
|
8794
8981
|
style: {
|
|
@@ -8800,7 +8987,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8800
8987
|
overflow: "hidden"
|
|
8801
8988
|
},
|
|
8802
8989
|
children: [
|
|
8803
|
-
/* @__PURE__ */
|
|
8990
|
+
/* @__PURE__ */ jsx11(
|
|
8804
8991
|
"button",
|
|
8805
8992
|
{
|
|
8806
8993
|
"aria-label": messages.zoomOut,
|
|
@@ -8819,7 +9006,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8819
9006
|
children: "-"
|
|
8820
9007
|
}
|
|
8821
9008
|
),
|
|
8822
|
-
/* @__PURE__ */
|
|
9009
|
+
/* @__PURE__ */ jsx11(
|
|
8823
9010
|
"button",
|
|
8824
9011
|
{
|
|
8825
9012
|
"aria-label": messages.resetZoom,
|
|
@@ -8840,7 +9027,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8840
9027
|
children: formatZoomScale(zoomScale, locale)
|
|
8841
9028
|
}
|
|
8842
9029
|
),
|
|
8843
|
-
/* @__PURE__ */
|
|
9030
|
+
/* @__PURE__ */ jsx11(
|
|
8844
9031
|
"button",
|
|
8845
9032
|
{
|
|
8846
9033
|
"aria-label": messages.zoomIn,
|
|
@@ -8862,7 +9049,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8862
9049
|
]
|
|
8863
9050
|
}
|
|
8864
9051
|
),
|
|
8865
|
-
canDownload ? /* @__PURE__ */
|
|
9052
|
+
canDownload ? /* @__PURE__ */ jsx11(
|
|
8866
9053
|
"button",
|
|
8867
9054
|
{
|
|
8868
9055
|
"aria-label": messages.downloadWorkbook,
|
|
@@ -8891,7 +9078,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8891
9078
|
]
|
|
8892
9079
|
}
|
|
8893
9080
|
),
|
|
8894
|
-
tabs.length > 1 ? /* @__PURE__ */
|
|
9081
|
+
tabs.length > 1 ? /* @__PURE__ */ jsx11(
|
|
8895
9082
|
"div",
|
|
8896
9083
|
{
|
|
8897
9084
|
style: {
|
|
@@ -8900,7 +9087,7 @@ function DefaultToolbar({ controller, palette, pivotTableEditor }) {
|
|
|
8900
9087
|
overflowX: "auto",
|
|
8901
9088
|
padding: "8px 12px"
|
|
8902
9089
|
},
|
|
8903
|
-
children: /* @__PURE__ */
|
|
9090
|
+
children: /* @__PURE__ */ jsx11(
|
|
8904
9091
|
SegmentedControl,
|
|
8905
9092
|
{
|
|
8906
9093
|
messages,
|
|
@@ -8952,7 +9139,7 @@ function resolveRichCellRuns(raw, value, base, theme, zoom) {
|
|
|
8952
9139
|
}
|
|
8953
9140
|
function renderRichCellText(cell) {
|
|
8954
9141
|
const scale = cell.shrinkToFitFontSizePx === void 0 ? 1 : cell.shrinkToFitFontSizePx / resolveCanvasFontSizePx(cell.style, 14);
|
|
8955
|
-
return cell.richText ? cell.richText.map((run, index) => /* @__PURE__ */
|
|
9142
|
+
return cell.richText ? cell.richText.map((run, index) => /* @__PURE__ */ jsx11("span", { style: {
|
|
8956
9143
|
fontFamily: run.style.fontFamily,
|
|
8957
9144
|
fontSize: resolveCanvasFontSizePx(run.style, 14) * scale,
|
|
8958
9145
|
fontWeight: run.style.fontWeight,
|
|
@@ -9353,7 +9540,7 @@ function renderConditionalIcon(icon, scale = 1) {
|
|
|
9353
9540
|
if (icon.shape === "arrow") {
|
|
9354
9541
|
const fill = icon.color ?? "#111827";
|
|
9355
9542
|
const stroke = icon.borderColor ?? darkenColor(fill, 0.32);
|
|
9356
|
-
return /* @__PURE__ */
|
|
9543
|
+
return /* @__PURE__ */ jsx11(
|
|
9357
9544
|
"svg",
|
|
9358
9545
|
{
|
|
9359
9546
|
"aria-hidden": "true",
|
|
@@ -9361,7 +9548,7 @@ function renderConditionalIcon(icon, scale = 1) {
|
|
|
9361
9548
|
style: { display: "block" },
|
|
9362
9549
|
viewBox: "0 0 16 16",
|
|
9363
9550
|
width: iconSize,
|
|
9364
|
-
children: /* @__PURE__ */
|
|
9551
|
+
children: /* @__PURE__ */ jsx11("g", { transform: `rotate(${icon.rotationDeg ?? 0} 8 8)`, children: /* @__PURE__ */ jsx11(
|
|
9365
9552
|
"path",
|
|
9366
9553
|
{
|
|
9367
9554
|
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",
|
|
@@ -9375,7 +9562,7 @@ function renderConditionalIcon(icon, scale = 1) {
|
|
|
9375
9562
|
);
|
|
9376
9563
|
}
|
|
9377
9564
|
if (icon.glyph) {
|
|
9378
|
-
return /* @__PURE__ */
|
|
9565
|
+
return /* @__PURE__ */ jsx11(
|
|
9379
9566
|
"span",
|
|
9380
9567
|
{
|
|
9381
9568
|
style: {
|
|
@@ -9393,7 +9580,7 @@ function renderConditionalIcon(icon, scale = 1) {
|
|
|
9393
9580
|
}
|
|
9394
9581
|
);
|
|
9395
9582
|
}
|
|
9396
|
-
return /* @__PURE__ */
|
|
9583
|
+
return /* @__PURE__ */ jsx11(
|
|
9397
9584
|
"span",
|
|
9398
9585
|
{
|
|
9399
9586
|
style: {
|
|
@@ -9417,9 +9604,9 @@ function renderCheckboxControl(checked, palette, scale = 1, mixed = false) {
|
|
|
9417
9604
|
const stroke = paletteIsDark(palette) ? "#cbd5e1" : "#475569";
|
|
9418
9605
|
const fill = checked || mixed ? paletteIsDark(palette) ? "#60a5fa" : "#2563eb" : "transparent";
|
|
9419
9606
|
const check = paletteIsDark(palette) ? "#020617" : "#ffffff";
|
|
9420
|
-
return /* @__PURE__ */
|
|
9421
|
-
/* @__PURE__ */
|
|
9422
|
-
mixed ? /* @__PURE__ */
|
|
9607
|
+
return /* @__PURE__ */ jsxs8("svg", { "aria-hidden": "true", height: 14 * scale, style: { display: "block" }, viewBox: "0 0 16 16", width: 14 * scale, children: [
|
|
9608
|
+
/* @__PURE__ */ jsx11("rect", { fill, height: 11, rx: 2, ry: 2, stroke, strokeWidth: 1.2, width: 11, x: 2.5, y: 2.5 }),
|
|
9609
|
+
mixed ? /* @__PURE__ */ jsx11("path", { d: "M5 8h6", fill: "none", stroke: check, strokeLinecap: "round", strokeWidth: 1.8 }) : checked ? /* @__PURE__ */ jsx11(
|
|
9423
9610
|
"path",
|
|
9424
9611
|
{
|
|
9425
9612
|
d: "M5 8.1 7.1 10.2 11.3 5.8",
|
|
@@ -9864,8 +10051,8 @@ function GridRow({
|
|
|
9864
10051
|
zoomFactor
|
|
9865
10052
|
}) {
|
|
9866
10053
|
const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
|
|
9867
|
-
return /* @__PURE__ */
|
|
9868
|
-
/* @__PURE__ */
|
|
10054
|
+
return /* @__PURE__ */ jsxs8("tr", { "data-xlsx-row": actualRow, style: { height: rowHeight }, children: [
|
|
10055
|
+
/* @__PURE__ */ jsxs8(
|
|
9869
10056
|
"td",
|
|
9870
10057
|
{
|
|
9871
10058
|
ref: (element) => onRowHeaderRef(actualRow, element),
|
|
@@ -9891,7 +10078,7 @@ function GridRow({
|
|
|
9891
10078
|
zIndex: stickyTop !== void 0 ? frozenRowHeaderZIndex : rowHeaderZIndex
|
|
9892
10079
|
},
|
|
9893
10080
|
children: [
|
|
9894
|
-
/* @__PURE__ */
|
|
10081
|
+
/* @__PURE__ */ jsx11("div", { style: { position: "relative" }, children: /* @__PURE__ */ jsx11(
|
|
9895
10082
|
"span",
|
|
9896
10083
|
{
|
|
9897
10084
|
style: {
|
|
@@ -9902,7 +10089,7 @@ function GridRow({
|
|
|
9902
10089
|
children: actualRow + 1
|
|
9903
10090
|
}
|
|
9904
10091
|
) }),
|
|
9905
|
-
/* @__PURE__ */
|
|
10092
|
+
/* @__PURE__ */ jsx11(
|
|
9906
10093
|
"div",
|
|
9907
10094
|
{
|
|
9908
10095
|
onDoubleClick: (event) => {
|
|
@@ -9913,7 +10100,7 @@ function GridRow({
|
|
|
9913
10100
|
style: {
|
|
9914
10101
|
bottom: 0,
|
|
9915
10102
|
cursor: "row-resize",
|
|
9916
|
-
height:
|
|
10103
|
+
height: HEADER_RESIZE_HANDLE_PX,
|
|
9917
10104
|
left: 0,
|
|
9918
10105
|
position: "absolute",
|
|
9919
10106
|
width: "100%",
|
|
@@ -9924,7 +10111,7 @@ function GridRow({
|
|
|
9924
10111
|
]
|
|
9925
10112
|
}
|
|
9926
10113
|
),
|
|
9927
|
-
leadingSpacerWidth > 0 ? /* @__PURE__ */
|
|
10114
|
+
leadingSpacerWidth > 0 ? /* @__PURE__ */ jsx11(
|
|
9928
10115
|
"td",
|
|
9929
10116
|
{
|
|
9930
10117
|
"aria-hidden": "true",
|
|
@@ -10071,7 +10258,7 @@ function GridRow({
|
|
|
10071
10258
|
width: "max-content"
|
|
10072
10259
|
} : null;
|
|
10073
10260
|
const title = [cellData.hyperlink?.tooltip, cellData.validation?.message, cellData.value].filter((value, index, values) => typeof value === "string" && value.length > 0 && values.indexOf(value) === index).join("\n");
|
|
10074
|
-
return /* @__PURE__ */
|
|
10261
|
+
return /* @__PURE__ */ jsxs8(
|
|
10075
10262
|
"td",
|
|
10076
10263
|
{
|
|
10077
10264
|
"data-xlsx-cell": `${actualRow}:${actualCol}`,
|
|
@@ -10088,7 +10275,7 @@ function GridRow({
|
|
|
10088
10275
|
style: cellStyle,
|
|
10089
10276
|
title,
|
|
10090
10277
|
children: [
|
|
10091
|
-
cellData.chartHighlight ? /* @__PURE__ */
|
|
10278
|
+
cellData.chartHighlight ? /* @__PURE__ */ jsx11(
|
|
10092
10279
|
"div",
|
|
10093
10280
|
{
|
|
10094
10281
|
"aria-hidden": "true",
|
|
@@ -10103,7 +10290,7 @@ function GridRow({
|
|
|
10103
10290
|
pointerEvents: "none",
|
|
10104
10291
|
position: "absolute"
|
|
10105
10292
|
},
|
|
10106
|
-
children: /* @__PURE__ */
|
|
10293
|
+
children: /* @__PURE__ */ jsx11(
|
|
10107
10294
|
ReferenceRangeHandles,
|
|
10108
10295
|
{
|
|
10109
10296
|
color: cellData.chartHighlight.strokeColor,
|
|
@@ -10115,7 +10302,7 @@ function GridRow({
|
|
|
10115
10302
|
)
|
|
10116
10303
|
}
|
|
10117
10304
|
) : null,
|
|
10118
|
-
cellData.conditionalDataBar ? /* @__PURE__ */
|
|
10305
|
+
cellData.conditionalDataBar ? /* @__PURE__ */ jsx11(
|
|
10119
10306
|
"div",
|
|
10120
10307
|
{
|
|
10121
10308
|
"aria-hidden": "true",
|
|
@@ -10127,7 +10314,7 @@ function GridRow({
|
|
|
10127
10314
|
position: "absolute",
|
|
10128
10315
|
zIndex: 0
|
|
10129
10316
|
},
|
|
10130
|
-
children: /* @__PURE__ */
|
|
10317
|
+
children: /* @__PURE__ */ jsx11(
|
|
10131
10318
|
"div",
|
|
10132
10319
|
{
|
|
10133
10320
|
style: {
|
|
@@ -10143,7 +10330,7 @@ function GridRow({
|
|
|
10143
10330
|
}
|
|
10144
10331
|
) : null,
|
|
10145
10332
|
adornment,
|
|
10146
|
-
cellData.conditionalIcon ? /* @__PURE__ */
|
|
10333
|
+
cellData.conditionalIcon ? /* @__PURE__ */ jsx11(
|
|
10147
10334
|
"div",
|
|
10148
10335
|
{
|
|
10149
10336
|
"aria-hidden": "true",
|
|
@@ -10161,7 +10348,7 @@ function GridRow({
|
|
|
10161
10348
|
children: renderConditionalIcon(cellData.conditionalIcon, zoomFactor)
|
|
10162
10349
|
}
|
|
10163
10350
|
) : null,
|
|
10164
|
-
isSpilling && !isEditing ? /* @__PURE__ */
|
|
10351
|
+
isSpilling && !isEditing ? /* @__PURE__ */ jsx11("div", { "aria-hidden": "true", style: {
|
|
10165
10352
|
backgroundColor: cellStyle.backgroundColor ?? palette.surface,
|
|
10166
10353
|
position: "absolute",
|
|
10167
10354
|
left: cellData.spillSide === "left" ? cellData.spillOffsetX : "calc(100% - 1px)",
|
|
@@ -10170,7 +10357,7 @@ function GridRow({
|
|
|
10170
10357
|
height: "calc(100% - 1px)",
|
|
10171
10358
|
pointerEvents: "none"
|
|
10172
10359
|
} }) : null,
|
|
10173
|
-
isEditing ? /* @__PURE__ */
|
|
10360
|
+
isEditing ? /* @__PURE__ */ jsx11(
|
|
10174
10361
|
CellEditor,
|
|
10175
10362
|
{
|
|
10176
10363
|
editorRef,
|
|
@@ -10195,7 +10382,7 @@ function GridRow({
|
|
|
10195
10382
|
...cellEditorStyle
|
|
10196
10383
|
}
|
|
10197
10384
|
}
|
|
10198
|
-
) : isSpilling ? /* @__PURE__ */
|
|
10385
|
+
) : isSpilling ? /* @__PURE__ */ jsx11(
|
|
10199
10386
|
"div",
|
|
10200
10387
|
{
|
|
10201
10388
|
style: {
|
|
@@ -10209,7 +10396,7 @@ function GridRow({
|
|
|
10209
10396
|
},
|
|
10210
10397
|
children: renderRichCellText(cellData)
|
|
10211
10398
|
}
|
|
10212
|
-
) : cellData.sparkline ? /* @__PURE__ */
|
|
10399
|
+
) : cellData.sparkline ? /* @__PURE__ */ jsx11(
|
|
10213
10400
|
"div",
|
|
10214
10401
|
{
|
|
10215
10402
|
style: {
|
|
@@ -10222,7 +10409,7 @@ function GridRow({
|
|
|
10222
10409
|
},
|
|
10223
10410
|
children: renderSparkline(cellData.sparkline.config, cellData.sparkline.values, palette)
|
|
10224
10411
|
}
|
|
10225
|
-
) : cellData.checkboxState != null ? /* @__PURE__ */
|
|
10412
|
+
) : cellData.checkboxState != null ? /* @__PURE__ */ jsx11(
|
|
10226
10413
|
"div",
|
|
10227
10414
|
{
|
|
10228
10415
|
style: {
|
|
@@ -10235,13 +10422,13 @@ function GridRow({
|
|
|
10235
10422
|
},
|
|
10236
10423
|
children: renderCheckboxControl(cellData.checkboxState, palette, zoomFactor)
|
|
10237
10424
|
}
|
|
10238
|
-
) : /* @__PURE__ */
|
|
10425
|
+
) : /* @__PURE__ */ jsx11("div", { style: cellContentStyle, children: rotatedTextStyle ? /* @__PURE__ */ jsx11("span", { style: { ...rotatedTextBounds, flex: "0 0 auto", position: "relative" }, children: /* @__PURE__ */ jsx11("span", { style: rotatedTextStyle, children: renderRichCellText(cellData) }) }) : wrappedTextStyle ? /* @__PURE__ */ jsx11("span", { style: wrappedTextStyle, children: renderRichCellText(cellData) }) : renderRichCellText(cellData) })
|
|
10239
10426
|
]
|
|
10240
10427
|
},
|
|
10241
10428
|
key
|
|
10242
10429
|
);
|
|
10243
10430
|
}),
|
|
10244
|
-
trailingSpacerWidth > 0 ? /* @__PURE__ */
|
|
10431
|
+
trailingSpacerWidth > 0 ? /* @__PURE__ */ jsx11(
|
|
10245
10432
|
"td",
|
|
10246
10433
|
{
|
|
10247
10434
|
"aria-hidden": "true",
|
|
@@ -10255,7 +10442,7 @@ function GridRow({
|
|
|
10255
10442
|
) : null
|
|
10256
10443
|
] });
|
|
10257
10444
|
}
|
|
10258
|
-
var MemoGridRow =
|
|
10445
|
+
var MemoGridRow = React15.memo(GridRow, (prev, next) => {
|
|
10259
10446
|
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.onRowResizeDoubleClick !== next.onRowResizeDoubleClick || prev.onRowResizePointerDown !== next.onRowResizePointerDown || prev.renderCellAdornment !== next.renderCellAdornment || prev.cellEditorStyle !== next.cellEditorStyle || prev.onFocusEditorOverlay !== next.onFocusEditorOverlay) {
|
|
10260
10447
|
return false;
|
|
10261
10448
|
}
|
|
@@ -10275,16 +10462,16 @@ function XlsxViewerProviderWithInlineController({
|
|
|
10275
10462
|
...options2
|
|
10276
10463
|
}) {
|
|
10277
10464
|
const controller = useXlsxViewerController(options2);
|
|
10278
|
-
return /* @__PURE__ */
|
|
10465
|
+
return /* @__PURE__ */ jsx11(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx11(ViewerContext.Provider, { value: controller, children: children2 }) });
|
|
10279
10466
|
}
|
|
10280
10467
|
function XlsxViewerProvider({ children: children2, controller, isDark = false, ...options2 }) {
|
|
10281
10468
|
if (controller) {
|
|
10282
|
-
return /* @__PURE__ */
|
|
10469
|
+
return /* @__PURE__ */ jsx11(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx11(ViewerContext.Provider, { value: controller, children: children2 }) });
|
|
10283
10470
|
}
|
|
10284
|
-
return /* @__PURE__ */
|
|
10471
|
+
return /* @__PURE__ */ jsx11(XlsxViewerProviderWithInlineController, { ...options2, isDark, children: children2 });
|
|
10285
10472
|
}
|
|
10286
10473
|
function useXlsxViewer() {
|
|
10287
|
-
const context =
|
|
10474
|
+
const context = React15.useContext(ViewerContext);
|
|
10288
10475
|
if (!context) {
|
|
10289
10476
|
throw new Error("useXlsxViewer must be used inside XlsxViewer or XlsxViewerProvider.");
|
|
10290
10477
|
}
|
|
@@ -10298,9 +10485,11 @@ function useXlsxViewerSelection() {
|
|
|
10298
10485
|
selectedRangeAddress,
|
|
10299
10486
|
selectCell,
|
|
10300
10487
|
selectRange,
|
|
10488
|
+
selectRanges,
|
|
10489
|
+
selectionRanges,
|
|
10301
10490
|
selection
|
|
10302
10491
|
} = useXlsxViewer();
|
|
10303
|
-
return
|
|
10492
|
+
return React15.useMemo(
|
|
10304
10493
|
() => ({
|
|
10305
10494
|
activeCell,
|
|
10306
10495
|
activeCellAddress,
|
|
@@ -10308,9 +10497,18 @@ function useXlsxViewerSelection() {
|
|
|
10308
10497
|
selectedRangeAddress,
|
|
10309
10498
|
selectCell,
|
|
10310
10499
|
selectRange,
|
|
10500
|
+
selectRanges,
|
|
10501
|
+
selectionRanges,
|
|
10311
10502
|
selection
|
|
10312
10503
|
}),
|
|
10313
|
-
[activeCell, activeCellAddress, clearSelection, selectedRangeAddress, selectCell, selectRange, selection]
|
|
10504
|
+
[activeCell, activeCellAddress, clearSelection, selectedRangeAddress, selectCell, selectRange, selectRanges, selectionRanges, selection]
|
|
10505
|
+
);
|
|
10506
|
+
}
|
|
10507
|
+
function useXlsxViewerLayout() {
|
|
10508
|
+
const { canChangeFreezePanes, canChangeVisibility, canFreezePanes, frozenPanes, hideRows, unhideRows, hideColumns, unhideColumns, freezePanes, unfreezePanes } = useXlsxViewer();
|
|
10509
|
+
return React15.useMemo(
|
|
10510
|
+
() => ({ canChangeFreezePanes, canChangeVisibility, canFreezePanes, frozenPanes, hideRows, unhideRows, hideColumns, unhideColumns, freezePanes, unfreezePanes }),
|
|
10511
|
+
[canChangeFreezePanes, canChangeVisibility, canFreezePanes, frozenPanes, hideRows, unhideRows, hideColumns, unhideColumns, freezePanes, unfreezePanes]
|
|
10314
10512
|
);
|
|
10315
10513
|
}
|
|
10316
10514
|
function useXlsxViewerZoom() {
|
|
@@ -10326,7 +10524,7 @@ function useXlsxViewerZoom() {
|
|
|
10326
10524
|
zoomOut,
|
|
10327
10525
|
zoomScale
|
|
10328
10526
|
} = useXlsxViewer();
|
|
10329
|
-
return
|
|
10527
|
+
return React15.useMemo(
|
|
10330
10528
|
() => ({
|
|
10331
10529
|
canZoomIn,
|
|
10332
10530
|
canZoomOut,
|
|
@@ -10395,7 +10593,7 @@ function useXlsxViewerEditing() {
|
|
|
10395
10593
|
unmergeSelection,
|
|
10396
10594
|
updateFormControl
|
|
10397
10595
|
} = useXlsxViewer();
|
|
10398
|
-
return
|
|
10596
|
+
return React15.useMemo(
|
|
10399
10597
|
() => ({
|
|
10400
10598
|
addFormControl,
|
|
10401
10599
|
addSheet,
|
|
@@ -10482,7 +10680,7 @@ function useXlsxViewerEditing() {
|
|
|
10482
10680
|
}
|
|
10483
10681
|
function useXlsxViewerTables() {
|
|
10484
10682
|
const { sortState, sortTable, tables } = useXlsxViewer();
|
|
10485
|
-
return
|
|
10683
|
+
return React15.useMemo(
|
|
10486
10684
|
() => ({
|
|
10487
10685
|
sortState,
|
|
10488
10686
|
sortTable,
|
|
@@ -10493,7 +10691,7 @@ function useXlsxViewerTables() {
|
|
|
10493
10691
|
}
|
|
10494
10692
|
function useXlsxViewerPivots() {
|
|
10495
10693
|
const { pivotTables, pivotFieldListVisible, setPivotFieldListVisible, getPivotSourceFields, getPivotTableAtCell, upsertPivotTable, refreshPivotTable, refreshAllPivotTables, removePivotTable, pivotDrillDown, showPivotDetails, createPivotChart, togglePivotGroup } = useXlsxViewer();
|
|
10496
|
-
return
|
|
10694
|
+
return React15.useMemo(() => ({
|
|
10497
10695
|
pivotTables,
|
|
10498
10696
|
pivotFieldListVisible,
|
|
10499
10697
|
setPivotFieldListVisible,
|
|
@@ -10547,7 +10745,7 @@ function useXlsxViewerImages() {
|
|
|
10547
10745
|
setImageRect,
|
|
10548
10746
|
updateChart
|
|
10549
10747
|
} = useXlsxViewer();
|
|
10550
|
-
return
|
|
10748
|
+
return React15.useMemo(
|
|
10551
10749
|
() => ({
|
|
10552
10750
|
arrangeDrawing,
|
|
10553
10751
|
changeChartType,
|
|
@@ -10649,7 +10847,7 @@ function useXlsxViewerCharts() {
|
|
|
10649
10847
|
tabs,
|
|
10650
10848
|
updateChart
|
|
10651
10849
|
} = useXlsxViewer();
|
|
10652
|
-
return
|
|
10850
|
+
return React15.useMemo(
|
|
10653
10851
|
() => ({
|
|
10654
10852
|
activeTab,
|
|
10655
10853
|
activeTabIndex,
|
|
@@ -10722,30 +10920,30 @@ function useXlsxViewerThumbnails(options2 = {}) {
|
|
|
10722
10920
|
workbook,
|
|
10723
10921
|
sheets
|
|
10724
10922
|
} = useXlsxViewer();
|
|
10725
|
-
const { headerBackgroundColor, headerTextColor, isDark } =
|
|
10923
|
+
const { headerBackgroundColor, headerTextColor, isDark } = React15.useContext(ViewerAppearanceContext);
|
|
10726
10924
|
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
10727
10925
|
const includeHeaders = options2.includeHeaders ?? true;
|
|
10728
10926
|
const resolution = options2.resolution;
|
|
10729
|
-
const thumbnailImageCacheRef =
|
|
10730
|
-
const workerThumbnailRowBatchCacheRef =
|
|
10731
|
-
const workerThumbnailRowBatchRequestRef =
|
|
10927
|
+
const thumbnailImageCacheRef = React15.useRef(/* @__PURE__ */ new Map());
|
|
10928
|
+
const workerThumbnailRowBatchCacheRef = React15.useRef(/* @__PURE__ */ new Map());
|
|
10929
|
+
const workerThumbnailRowBatchRequestRef = React15.useRef(
|
|
10732
10930
|
/* @__PURE__ */ new Map()
|
|
10733
10931
|
);
|
|
10734
|
-
const isMountedRef =
|
|
10735
|
-
const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] =
|
|
10736
|
-
const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] =
|
|
10737
|
-
|
|
10932
|
+
const isMountedRef = React15.useRef(false);
|
|
10933
|
+
const [thumbnailImageLoadVersion, setThumbnailImageLoadVersion] = React15.useState(0);
|
|
10934
|
+
const [workerThumbnailRowBatchVersion, setWorkerThumbnailRowBatchVersion] = React15.useState(0);
|
|
10935
|
+
React15.useEffect(() => {
|
|
10738
10936
|
isMountedRef.current = true;
|
|
10739
10937
|
return () => {
|
|
10740
10938
|
isMountedRef.current = false;
|
|
10741
10939
|
};
|
|
10742
10940
|
}, []);
|
|
10743
|
-
|
|
10941
|
+
React15.useEffect(() => {
|
|
10744
10942
|
workerThumbnailRowBatchCacheRef.current.clear();
|
|
10745
10943
|
workerThumbnailRowBatchRequestRef.current.clear();
|
|
10746
10944
|
setWorkerThumbnailRowBatchVersion((version) => version + 1);
|
|
10747
10945
|
}, [locale]);
|
|
10748
|
-
|
|
10946
|
+
React15.useEffect(() => {
|
|
10749
10947
|
const currentSheets = new Set(sheets);
|
|
10750
10948
|
for (const sheet of workerThumbnailRowBatchCacheRef.current.keys()) {
|
|
10751
10949
|
if (!currentSheets.has(sheet)) {
|
|
@@ -10758,7 +10956,7 @@ function useXlsxViewerThumbnails(options2 = {}) {
|
|
|
10758
10956
|
}
|
|
10759
10957
|
}
|
|
10760
10958
|
}, [sheets]);
|
|
10761
|
-
const getWorkerThumbnailRowBatch =
|
|
10959
|
+
const getWorkerThumbnailRowBatch = React15.useCallback((sheet, startRow, endRow) => {
|
|
10762
10960
|
const cachedBatch = workerThumbnailRowBatchCacheRef.current.get(sheet);
|
|
10763
10961
|
if (cachedBatch && startRow >= cachedBatch.startRow && endRow <= cachedBatch.endRow) {
|
|
10764
10962
|
return cachedBatch;
|
|
@@ -10800,7 +10998,7 @@ function useXlsxViewerThumbnails(options2 = {}) {
|
|
|
10800
10998
|
}
|
|
10801
10999
|
return null;
|
|
10802
11000
|
}, [getRowsBatchAsync]);
|
|
10803
|
-
const getThumbnailImage =
|
|
11001
|
+
const getThumbnailImage = React15.useCallback((image) => {
|
|
10804
11002
|
if (typeof Image === "undefined") {
|
|
10805
11003
|
return null;
|
|
10806
11004
|
}
|
|
@@ -10832,7 +11030,7 @@ function useXlsxViewerThumbnails(options2 = {}) {
|
|
|
10832
11030
|
imageElement.src = image.src;
|
|
10833
11031
|
return null;
|
|
10834
11032
|
}, []);
|
|
10835
|
-
const thumbnails =
|
|
11033
|
+
const thumbnails = React15.useMemo(() => {
|
|
10836
11034
|
return sheets.map((sheet, sheetIndex) => {
|
|
10837
11035
|
const worksheet = workbook?.getSheet(sheet.workbookSheetIndex) ?? null;
|
|
10838
11036
|
const sheetImages = getSheetImages(sheetIndex).filter((image) => image.src).sort((left, right) => left.zIndex - right.zIndex);
|
|
@@ -10878,7 +11076,7 @@ function useXlsxViewerThumbnails(options2 = {}) {
|
|
|
10878
11076
|
hiddenColSet
|
|
10879
11077
|
);
|
|
10880
11078
|
const resolveColumnWidthPx = (actualCol) => {
|
|
10881
|
-
if (worksheet && !
|
|
11079
|
+
if (worksheet && !hiddenColSet.has(actualCol)) {
|
|
10882
11080
|
const width = worksheet.getColumnWidth(actualCol);
|
|
10883
11081
|
if (width !== void 0 && width !== null) {
|
|
10884
11082
|
return Math.max(
|
|
@@ -10896,7 +11094,7 @@ function useXlsxViewerThumbnails(options2 = {}) {
|
|
|
10896
11094
|
);
|
|
10897
11095
|
};
|
|
10898
11096
|
const resolveRowHeightPx = (actualRow) => {
|
|
10899
|
-
if (worksheet && !
|
|
11097
|
+
if (worksheet && !hiddenRowSet.has(actualRow)) {
|
|
10900
11098
|
const height = worksheet.getRowHeight(actualRow);
|
|
10901
11099
|
if (height !== void 0 && height !== null) {
|
|
10902
11100
|
return Math.max(
|
|
@@ -11415,11 +11613,11 @@ function useXlsxViewerThumbnails(options2 = {}) {
|
|
|
11415
11613
|
locale,
|
|
11416
11614
|
workbook
|
|
11417
11615
|
]);
|
|
11418
|
-
const paintThumbnail =
|
|
11616
|
+
const paintThumbnail = React15.useCallback(
|
|
11419
11617
|
(sheetIndex, canvas) => thumbnails[sheetIndex]?.paint(canvas) ?? false,
|
|
11420
11618
|
[thumbnails]
|
|
11421
11619
|
);
|
|
11422
|
-
return
|
|
11620
|
+
return React15.useMemo(
|
|
11423
11621
|
() => ({
|
|
11424
11622
|
paintThumbnail,
|
|
11425
11623
|
thumbnails
|
|
@@ -11429,13 +11627,13 @@ function useXlsxViewerThumbnails(options2 = {}) {
|
|
|
11429
11627
|
}
|
|
11430
11628
|
function DefaultXlsxToolbar({ pivotTableEditor } = {}) {
|
|
11431
11629
|
const controller = useXlsxViewer();
|
|
11432
|
-
const { headerBackgroundColor, headerTextColor, isDark } =
|
|
11630
|
+
const { headerBackgroundColor, headerTextColor, isDark } = React15.useContext(ViewerAppearanceContext);
|
|
11433
11631
|
const palette = useViewerPalette(isDark, headerBackgroundColor, headerTextColor);
|
|
11434
|
-
return /* @__PURE__ */
|
|
11632
|
+
return /* @__PURE__ */ jsx11(DefaultToolbar, { controller, palette, pivotTableEditor });
|
|
11435
11633
|
}
|
|
11436
11634
|
|
|
11437
11635
|
// src/react-viewer.tsx
|
|
11438
|
-
import { jsx as
|
|
11636
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
11439
11637
|
var SlotStore = class {
|
|
11440
11638
|
slots = /* @__PURE__ */ new Map();
|
|
11441
11639
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -11471,7 +11669,7 @@ var SlotStore = class {
|
|
|
11471
11669
|
return __createContentNode(slot.host);
|
|
11472
11670
|
}
|
|
11473
11671
|
portals() {
|
|
11474
|
-
return Array.from(this.slots, ([key, slot]) =>
|
|
11672
|
+
return Array.from(this.slots, ([key, slot]) => createPortal7(slot.node, slot.host, key));
|
|
11475
11673
|
}
|
|
11476
11674
|
destroy() {
|
|
11477
11675
|
this.destroyed = true;
|
|
@@ -11504,9 +11702,9 @@ var SlotStore = class {
|
|
|
11504
11702
|
}
|
|
11505
11703
|
};
|
|
11506
11704
|
function RuntimeContent({ content }) {
|
|
11507
|
-
const hostRef =
|
|
11508
|
-
const rootRef =
|
|
11509
|
-
|
|
11705
|
+
const hostRef = React16.useRef(null);
|
|
11706
|
+
const rootRef = React16.useRef(null);
|
|
11707
|
+
React16.useLayoutEffect(() => {
|
|
11510
11708
|
const host = hostRef.current;
|
|
11511
11709
|
if (!host) return;
|
|
11512
11710
|
const root = __createContentRoot(host);
|
|
@@ -11516,14 +11714,14 @@ function RuntimeContent({ content }) {
|
|
|
11516
11714
|
root.destroy();
|
|
11517
11715
|
};
|
|
11518
11716
|
}, []);
|
|
11519
|
-
|
|
11717
|
+
React16.useLayoutEffect(() => {
|
|
11520
11718
|
rootRef.current?.update(content);
|
|
11521
11719
|
}, [content]);
|
|
11522
|
-
return /* @__PURE__ */
|
|
11720
|
+
return /* @__PURE__ */ jsx12("span", { ref: hostRef, style: { display: "contents" } });
|
|
11523
11721
|
}
|
|
11524
11722
|
function renderOptions(props, controller, slots, owner) {
|
|
11525
11723
|
const slot = (key, node) => slots.render(key, node, owner);
|
|
11526
|
-
const runtime = (node) => /* @__PURE__ */
|
|
11724
|
+
const runtime = (node) => /* @__PURE__ */ jsx12(RuntimeContent, { content: node });
|
|
11527
11725
|
const {
|
|
11528
11726
|
emptyState,
|
|
11529
11727
|
errorState,
|
|
@@ -11579,13 +11777,13 @@ function renderOptions(props, controller, slots, owner) {
|
|
|
11579
11777
|
};
|
|
11580
11778
|
}
|
|
11581
11779
|
function BoundViewer({ props, controller: sourceController }) {
|
|
11582
|
-
const messages =
|
|
11583
|
-
const controller =
|
|
11584
|
-
const hostRef =
|
|
11585
|
-
const viewerRef =
|
|
11586
|
-
const slots =
|
|
11587
|
-
|
|
11588
|
-
|
|
11780
|
+
const messages = React16.useMemo(() => mergeMessages(sourceController.messages, props.messages), [sourceController.messages, props.messages]);
|
|
11781
|
+
const controller = React16.useMemo(() => ({ ...sourceController, messages }), [sourceController, messages]);
|
|
11782
|
+
const hostRef = React16.useRef(null);
|
|
11783
|
+
const viewerRef = React16.useRef(null);
|
|
11784
|
+
const slots = React16.useMemo(() => new SlotStore(), []);
|
|
11785
|
+
React16.useSyncExternalStore(slots.subscribe, slots.getSnapshot, slots.getServerSnapshot);
|
|
11786
|
+
React16.useLayoutEffect(() => {
|
|
11589
11787
|
const host = hostRef.current;
|
|
11590
11788
|
if (!host) return;
|
|
11591
11789
|
slots.observe(host);
|
|
@@ -11597,27 +11795,27 @@ function BoundViewer({ props, controller: sourceController }) {
|
|
|
11597
11795
|
slots.destroy();
|
|
11598
11796
|
};
|
|
11599
11797
|
}, [slots]);
|
|
11600
|
-
|
|
11798
|
+
React16.useLayoutEffect(() => {
|
|
11601
11799
|
const host = hostRef.current;
|
|
11602
11800
|
if (host) viewerRef.current?.update(renderOptions(props, controller, slots, host.ownerDocument));
|
|
11603
11801
|
}, [controller, props, slots]);
|
|
11604
|
-
return /* @__PURE__ */
|
|
11802
|
+
return /* @__PURE__ */ jsx12(ViewerAppearanceContext.Provider, { value: {
|
|
11605
11803
|
headerBackgroundColor: props.headerBackgroundColor,
|
|
11606
11804
|
headerTextColor: props.headerTextColor,
|
|
11607
11805
|
isDark: props.isDark ?? false
|
|
11608
|
-
}, children: /* @__PURE__ */
|
|
11609
|
-
/* @__PURE__ */
|
|
11806
|
+
}, children: /* @__PURE__ */ jsxs9(ViewerContext.Provider, { value: controller, children: [
|
|
11807
|
+
/* @__PURE__ */ jsx12("div", { ref: hostRef, style: { display: "contents" } }),
|
|
11610
11808
|
slots.portals()
|
|
11611
11809
|
] }) });
|
|
11612
11810
|
}
|
|
11613
11811
|
function UncontrolledViewer(props) {
|
|
11614
11812
|
const controller = useXlsxViewerController(props);
|
|
11615
|
-
return /* @__PURE__ */
|
|
11813
|
+
return /* @__PURE__ */ jsx12(BoundViewer, { props, controller });
|
|
11616
11814
|
}
|
|
11617
11815
|
function XlsxViewer(props) {
|
|
11618
|
-
const context =
|
|
11816
|
+
const context = React16.useContext(ViewerContext);
|
|
11619
11817
|
const controller = props.controller ?? context;
|
|
11620
|
-
return controller ? /* @__PURE__ */
|
|
11818
|
+
return controller ? /* @__PURE__ */ jsx12(BoundViewer, { props, controller }) : /* @__PURE__ */ jsx12(UncontrolledViewer, { ...props });
|
|
11621
11819
|
}
|
|
11622
11820
|
export {
|
|
11623
11821
|
DefaultXlsxPivotTableFieldList,
|
|
@@ -11634,6 +11832,7 @@ export {
|
|
|
11634
11832
|
useXlsxViewerController,
|
|
11635
11833
|
useXlsxViewerEditing,
|
|
11636
11834
|
useXlsxViewerImages,
|
|
11835
|
+
useXlsxViewerLayout,
|
|
11637
11836
|
useXlsxViewerPivots,
|
|
11638
11837
|
useXlsxViewerSelection,
|
|
11639
11838
|
useXlsxViewerTables,
|