@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
|
@@ -34,8 +34,6 @@ import {
|
|
|
34
34
|
resolveWorkbookFillStyle,
|
|
35
35
|
resolveWorksheetDefaultColumnWidthPixels,
|
|
36
36
|
resolveWorksheetDefaultRowHeightPixels,
|
|
37
|
-
resolveWorksheetHiddenCols,
|
|
38
|
-
resolveWorksheetHiddenRows,
|
|
39
37
|
resolveWorksheetMergeMetadata,
|
|
40
38
|
restoreWorkerImageBlobs,
|
|
41
39
|
revokeWorkbookImageAssets,
|
|
@@ -45,7 +43,7 @@ import {
|
|
|
45
43
|
updateWorkbookChartDefinition,
|
|
46
44
|
updateWorkbookImageAnchor,
|
|
47
45
|
xlsxAnchorToDukeDrawingAnchor
|
|
48
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-Q6YY3AB4.js";
|
|
49
47
|
import {
|
|
50
48
|
$,
|
|
51
49
|
A,
|
|
@@ -73,7 +71,7 @@ import {
|
|
|
73
71
|
w,
|
|
74
72
|
x,
|
|
75
73
|
y
|
|
76
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-HAV76TR2.js";
|
|
77
75
|
import {
|
|
78
76
|
configureWorkbookArchiveDecoder,
|
|
79
77
|
configureWorkbookXmlDecoder,
|
|
@@ -107,6 +105,129 @@ var XlsxFileSizeLimitExceededError = class extends Error {
|
|
|
107
105
|
}
|
|
108
106
|
};
|
|
109
107
|
|
|
108
|
+
// src/selection-ranges.ts
|
|
109
|
+
function resolveFreezePanesCell(activeCell, selection) {
|
|
110
|
+
if (activeCell && selection && (activeCell.row < selection.start.row || activeCell.col < selection.start.col)) {
|
|
111
|
+
return selection.start;
|
|
112
|
+
}
|
|
113
|
+
return activeCell;
|
|
114
|
+
}
|
|
115
|
+
function subtractRange(area, cut) {
|
|
116
|
+
const top = Math.max(area.start.row, cut.start.row);
|
|
117
|
+
const bottom = Math.min(area.end.row, cut.end.row);
|
|
118
|
+
const left = Math.max(area.start.col, cut.start.col);
|
|
119
|
+
const right = Math.min(area.end.col, cut.end.col);
|
|
120
|
+
if (top > bottom || left > right) return [area];
|
|
121
|
+
const remaining = [];
|
|
122
|
+
if (area.start.row < top) remaining.push({ start: area.start, end: { row: top - 1, col: area.end.col } });
|
|
123
|
+
if (bottom < area.end.row) remaining.push({ start: { row: bottom + 1, col: area.start.col }, end: area.end });
|
|
124
|
+
if (area.start.col < left) remaining.push({ start: { row: top, col: area.start.col }, end: { row: bottom, col: left - 1 } });
|
|
125
|
+
if (right < area.end.col) remaining.push({ start: { row: top, col: right + 1 }, end: { row: bottom, col: area.end.col } });
|
|
126
|
+
return remaining;
|
|
127
|
+
}
|
|
128
|
+
function addSelectionRange(areas, range) {
|
|
129
|
+
return [...areas.flatMap((area) => subtractRange(area, range)), range];
|
|
130
|
+
}
|
|
131
|
+
function selectionCoversRange(areas, range) {
|
|
132
|
+
let remaining = [range];
|
|
133
|
+
for (const area of areas) {
|
|
134
|
+
remaining = remaining.flatMap((piece) => subtractRange(piece, area));
|
|
135
|
+
if (!remaining.length) return true;
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
function clipboardBands(areas) {
|
|
140
|
+
const first = areas[0];
|
|
141
|
+
if (!first) return null;
|
|
142
|
+
const sameExtent = (axis) => areas.every((area) => area.start[axis] === first.start[axis] && area.end[axis] === first.end[axis]);
|
|
143
|
+
const bands = (axis, ranges) => ranges.map((range) => ({ start: range.start[axis], end: range.end[axis] })).sort((a, b) => a.start - b.start);
|
|
144
|
+
if (sameExtent("col")) return { rows: bands("row", areas), cols: bands("col", [first]) };
|
|
145
|
+
if (sameExtent("row")) return { rows: bands("row", [first]), cols: bands("col", areas) };
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
function* bandIndices(bands) {
|
|
149
|
+
let offset = 0;
|
|
150
|
+
for (const band of bands) {
|
|
151
|
+
for (let index = band.start; index <= band.end; index++) {
|
|
152
|
+
yield { index, offset: offset++, remaining: band.end - index + 1 };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/read-only-layout.ts
|
|
158
|
+
function changedVisibilityRanges(existing, ranges, hidden, fromSelection) {
|
|
159
|
+
if (!hidden && !existing.size) return [];
|
|
160
|
+
let firstVisible = 0;
|
|
161
|
+
if (!hidden && fromSelection) {
|
|
162
|
+
while (existing.has(firstVisible)) firstVisible++;
|
|
163
|
+
}
|
|
164
|
+
const changed = [];
|
|
165
|
+
for (const range of ranges) {
|
|
166
|
+
const start = firstVisible > 0 && range.start === firstVisible ? 0 : range.start;
|
|
167
|
+
for (let index = start; index <= range.end; index++) {
|
|
168
|
+
if (existing.has(index) !== hidden) {
|
|
169
|
+
changed.push({ start, end: range.end });
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return changed;
|
|
175
|
+
}
|
|
176
|
+
function nextVisibleIndex(index, limit, isHidden) {
|
|
177
|
+
let next = index;
|
|
178
|
+
while (next < limit && isHidden(next)) next++;
|
|
179
|
+
if (next < limit) return next;
|
|
180
|
+
next = index - 1;
|
|
181
|
+
while (next >= 0 && isHidden(next)) next--;
|
|
182
|
+
return next;
|
|
183
|
+
}
|
|
184
|
+
function visibleAxis(hidden, max, originalIndices, originalSizes, overrides, defaultSize) {
|
|
185
|
+
const indices = [];
|
|
186
|
+
const sizes = [];
|
|
187
|
+
let offset = 0;
|
|
188
|
+
for (let index = 0; index <= max; index++) {
|
|
189
|
+
const originalSize = originalIndices[offset] === index ? originalSizes[offset++] : void 0;
|
|
190
|
+
if (hidden.has(index)) continue;
|
|
191
|
+
indices.push(index);
|
|
192
|
+
sizes.push(originalSize ?? overrides[index] ?? defaultSize);
|
|
193
|
+
}
|
|
194
|
+
return { indices, sizes };
|
|
195
|
+
}
|
|
196
|
+
function applyReadOnlyLayout(sheet, layout) {
|
|
197
|
+
if (!layout) return sheet;
|
|
198
|
+
const view = { ...sheet };
|
|
199
|
+
if (layout.freezePanes !== void 0) view.freezePanes = layout.freezePanes;
|
|
200
|
+
if (layout.hiddenRows) {
|
|
201
|
+
const rows = visibleAxis(
|
|
202
|
+
layout.hiddenRows,
|
|
203
|
+
sheet.maxUsedRow,
|
|
204
|
+
sheet.visibleRows,
|
|
205
|
+
sheet.rowHeights,
|
|
206
|
+
sheet.rowHeightOverridesPx,
|
|
207
|
+
sheet.defaultRowHeightPx
|
|
208
|
+
);
|
|
209
|
+
view.hiddenRows = Array.from(layout.hiddenRows).sort((a, b) => a - b);
|
|
210
|
+
view.visibleRows = rows.indices;
|
|
211
|
+
view.rowHeights = rows.sizes;
|
|
212
|
+
view.rowCount = rows.indices.length;
|
|
213
|
+
}
|
|
214
|
+
if (layout.hiddenCols) {
|
|
215
|
+
const cols = visibleAxis(
|
|
216
|
+
layout.hiddenCols,
|
|
217
|
+
sheet.maxUsedCol,
|
|
218
|
+
sheet.visibleCols,
|
|
219
|
+
sheet.colWidths,
|
|
220
|
+
sheet.colWidthOverridesPx,
|
|
221
|
+
sheet.defaultColWidthPx
|
|
222
|
+
);
|
|
223
|
+
view.hiddenCols = Array.from(layout.hiddenCols).sort((a, b) => a - b);
|
|
224
|
+
view.visibleCols = cols.indices;
|
|
225
|
+
view.colWidths = cols.sizes;
|
|
226
|
+
view.colCount = cols.indices.length;
|
|
227
|
+
}
|
|
228
|
+
return view;
|
|
229
|
+
}
|
|
230
|
+
|
|
110
231
|
// src/merged-range-lookup.ts
|
|
111
232
|
function createMergedRangeLookup(ranges) {
|
|
112
233
|
const normalizedRanges = [];
|
|
@@ -1022,7 +1143,7 @@ var XlsxWorkerClient = class {
|
|
|
1022
1143
|
}
|
|
1023
1144
|
async getMainRuntime() {
|
|
1024
1145
|
if (this.disposed) throw createAbortError();
|
|
1025
|
-
this.mainRuntime ??= import("./workbook-runtime-
|
|
1146
|
+
this.mainRuntime ??= import("./workbook-runtime-FCKPXLTW.js").then(({ createWorkbookRuntime }) => createWorkbookRuntime());
|
|
1026
1147
|
const runtime = await this.mainRuntime;
|
|
1027
1148
|
if (this.disposed) {
|
|
1028
1149
|
runtime.dispose();
|
|
@@ -1251,8 +1372,8 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
1251
1372
|
maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
|
|
1252
1373
|
maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
|
|
1253
1374
|
mergedRanges: mergeMetadata.mergedRanges,
|
|
1254
|
-
hiddenCols:
|
|
1255
|
-
hiddenRows:
|
|
1375
|
+
hiddenCols: Array.from(worksheet.hiddenColumns),
|
|
1376
|
+
hiddenRows: Array.from(worksheet.hiddenRows),
|
|
1256
1377
|
minUsedCol: -1,
|
|
1257
1378
|
minUsedRow: -1,
|
|
1258
1379
|
maxUsedCol: -1,
|
|
@@ -1341,8 +1462,8 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
1341
1462
|
maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
|
|
1342
1463
|
maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
|
|
1343
1464
|
mergedRanges: mergeMetadata.mergedRanges,
|
|
1344
|
-
hiddenCols:
|
|
1345
|
-
hiddenRows:
|
|
1465
|
+
hiddenCols: Array.from(worksheet.hiddenColumns),
|
|
1466
|
+
hiddenRows: Array.from(worksheet.hiddenRows),
|
|
1346
1467
|
minUsedCol: minCol,
|
|
1347
1468
|
minUsedRow: minRow,
|
|
1348
1469
|
maxUsedCol: maxCol,
|
|
@@ -1998,6 +2119,8 @@ function downloadUrl(src, fileName) {
|
|
|
1998
2119
|
}
|
|
1999
2120
|
function useXlsxViewerController(options2) {
|
|
2000
2121
|
const {
|
|
2122
|
+
allowFreezeInReadOnly = false,
|
|
2123
|
+
allowHideInReadOnly = false,
|
|
2001
2124
|
allowResizeInReadOnly = false,
|
|
2002
2125
|
deferLoadingAboveBytes = DEFAULT_DEFER_LOADING_ABOVE_BYTES,
|
|
2003
2126
|
file,
|
|
@@ -2016,7 +2139,8 @@ function useXlsxViewerController(options2) {
|
|
|
2016
2139
|
const [isLoading, setIsLoading] = d(Boolean(file ?? src));
|
|
2017
2140
|
const [error, setError] = d(null);
|
|
2018
2141
|
const [workbook, setWorkbook] = d(null);
|
|
2019
|
-
const [
|
|
2142
|
+
const [readOnlyLayouts, setReadOnlyLayouts] = d({});
|
|
2143
|
+
const [workbookSheets, setSheets] = d([]);
|
|
2020
2144
|
const [chartsByWorkbookSheetIndex, setChartsByWorkbookSheetIndex] = d([]);
|
|
2021
2145
|
const [chartsheets, setChartsheets] = d([]);
|
|
2022
2146
|
const [tabs, setTabs] = d([]);
|
|
@@ -2036,7 +2160,11 @@ function useXlsxViewerController(options2) {
|
|
|
2036
2160
|
const [activeTabIndex, setActiveTabIndexState] = d(0);
|
|
2037
2161
|
const [zoomScaleOverridesByTabId, setZoomScaleOverridesByTabId] = d({});
|
|
2038
2162
|
const [activeCell, setActiveCell] = d(null);
|
|
2039
|
-
const [
|
|
2163
|
+
const [selectionRanges, setSelectionRanges] = d([]);
|
|
2164
|
+
const selection = selectionRanges.at(-1) ?? null;
|
|
2165
|
+
const setSelection = q((range) => {
|
|
2166
|
+
setSelectionRanges(range ? [range] : []);
|
|
2167
|
+
}, []);
|
|
2040
2168
|
const [highlightedRanges, setHighlightedRanges] = d([]);
|
|
2041
2169
|
const [selectedChartId, setSelectedChartId] = d(null);
|
|
2042
2170
|
const [selectedChartElement, setSelectedChartElement] = d(null);
|
|
@@ -2067,6 +2195,7 @@ function useXlsxViewerController(options2) {
|
|
|
2067
2195
|
const displayFileName = T(() => resolveDisplayFileName(src, fileName), [fileName, src]);
|
|
2068
2196
|
const shouldDeferLoading = deferLoadingAboveBytes > 0;
|
|
2069
2197
|
const readOnly = requestedReadOnly || forcedReadOnly;
|
|
2198
|
+
const sheets = T(() => readOnly ? workbookSheets.map((sheet) => applyReadOnlyLayout(sheet, readOnlyLayouts[sheet.workbookSheetIndex])) : workbookSheets, [readOnly, readOnlyLayouts, workbookSheets]);
|
|
2070
2199
|
const drawingMutationEpoch = A(0);
|
|
2071
2200
|
const drawingMutationState = A({ workbook, revision, readOnly, activeCell, activeSheetIndex });
|
|
2072
2201
|
drawingMutationState.current = { workbook, revision, readOnly, activeCell, activeSheetIndex };
|
|
@@ -2228,6 +2357,7 @@ function useXlsxViewerController(options2) {
|
|
|
2228
2357
|
}, [disposeWorkerClient]);
|
|
2229
2358
|
h(() => {
|
|
2230
2359
|
loadGenerationRef.current += 1;
|
|
2360
|
+
setReadOnlyLayouts({});
|
|
2231
2361
|
if (!file && !src) {
|
|
2232
2362
|
disposeWorkerClient();
|
|
2233
2363
|
setForcedReadOnly(false);
|
|
@@ -2797,23 +2927,20 @@ function useXlsxViewerController(options2) {
|
|
|
2797
2927
|
}, [activeSheet, getActiveWorksheet, locale]);
|
|
2798
2928
|
const getClipboardData = q(() => {
|
|
2799
2929
|
const worksheet = getActiveWorksheet();
|
|
2800
|
-
const
|
|
2801
|
-
if (!worksheet || !
|
|
2802
|
-
return null;
|
|
2803
|
-
}
|
|
2804
|
-
const normalized = normalizeRange(targetRange);
|
|
2930
|
+
const bands = clipboardBands(selectionRanges);
|
|
2931
|
+
if (!worksheet || !bands) return null;
|
|
2805
2932
|
const rows = [];
|
|
2806
2933
|
const htmlRows = [];
|
|
2807
2934
|
const payload = {
|
|
2808
2935
|
cells: [],
|
|
2809
|
-
cols:
|
|
2936
|
+
cols: bands.cols.reduce((total, band) => total + band.end - band.start + 1, 0),
|
|
2810
2937
|
merges: [],
|
|
2811
|
-
rows:
|
|
2938
|
+
rows: bands.rows.reduce((total, band) => total + band.end - band.start + 1, 0)
|
|
2812
2939
|
};
|
|
2813
|
-
for (
|
|
2940
|
+
for (const { index: row3, offset: rowOffset, remaining: rowsRemaining } of bandIndices(bands.rows)) {
|
|
2814
2941
|
const textCells = [];
|
|
2815
2942
|
const htmlCells = [];
|
|
2816
|
-
for (
|
|
2943
|
+
for (const { index: col, offset: colOffset, remaining: colsRemaining } of bandIndices(bands.cols)) {
|
|
2817
2944
|
if (worksheet.isMergedSecondary(row3, col)) {
|
|
2818
2945
|
textCells.push("");
|
|
2819
2946
|
continue;
|
|
@@ -2880,19 +3007,19 @@ function useXlsxViewerController(options2) {
|
|
|
2880
3007
|
if (border?.left?.style && border.left.style !== "none") {
|
|
2881
3008
|
cellStyles.push(`border-left:${mapBorder(border.left)}`);
|
|
2882
3009
|
}
|
|
2883
|
-
const rowSpan = Math.min(merge?.rowSpan ?? 1,
|
|
2884
|
-
const colSpan = Math.min(merge?.colSpan ?? 1,
|
|
3010
|
+
const rowSpan = Math.min(merge?.rowSpan ?? 1, rowsRemaining);
|
|
3011
|
+
const colSpan = Math.min(merge?.colSpan ?? 1, colsRemaining);
|
|
2885
3012
|
payload.cells.push({
|
|
2886
|
-
colOffset
|
|
3013
|
+
colOffset,
|
|
2887
3014
|
formula,
|
|
2888
|
-
rowOffset
|
|
3015
|
+
rowOffset,
|
|
2889
3016
|
value
|
|
2890
3017
|
});
|
|
2891
3018
|
if (rowSpan > 1 || colSpan > 1) {
|
|
2892
3019
|
payload.merges.push({
|
|
2893
|
-
colOffset
|
|
3020
|
+
colOffset,
|
|
2894
3021
|
colSpan,
|
|
2895
|
-
rowOffset
|
|
3022
|
+
rowOffset,
|
|
2896
3023
|
rowSpan
|
|
2897
3024
|
});
|
|
2898
3025
|
}
|
|
@@ -2909,7 +3036,7 @@ function useXlsxViewerController(options2) {
|
|
|
2909
3036
|
structured: JSON.stringify(payload),
|
|
2910
3037
|
text: rows.join("\n")
|
|
2911
3038
|
};
|
|
2912
|
-
}, [
|
|
3039
|
+
}, [activeSheet, getActiveWorksheet, getCellDisplayValue2, selectionRanges]);
|
|
2913
3040
|
h(() => {
|
|
2914
3041
|
if (!isWorkerBacked || !deferredMetadataSheet || !deferredMetadataCell) {
|
|
2915
3042
|
return;
|
|
@@ -2940,7 +3067,7 @@ function useXlsxViewerController(options2) {
|
|
|
2940
3067
|
};
|
|
2941
3068
|
}, [deferredMetadataCell, deferredMetadataSheet, getCellSnapshotAsync, isWorkerBacked, locale]);
|
|
2942
3069
|
const activeCellAddress = T(() => activeCell ? cellAddressToA1(activeCell) : null, [activeCell]);
|
|
2943
|
-
const selectedRangeAddress = T(() =>
|
|
3070
|
+
const selectedRangeAddress = T(() => selectionRanges.map(rangeToA1).join(",") || null, [selectionRanges]);
|
|
2944
3071
|
const selectedValue = T(
|
|
2945
3072
|
() => getCellDisplayValue2(deferredMetadataCell),
|
|
2946
3073
|
[deferredMetadataCell, getCellDisplayValue2, revision, workerCellSnapshotRevision]
|
|
@@ -2990,10 +3117,10 @@ function useXlsxViewerController(options2) {
|
|
|
2990
3117
|
bytes: workbook.exportSnapshot(),
|
|
2991
3118
|
assets: imageAssetsRef.current ? structuredClone(imageAssetsRef.current) : null,
|
|
2992
3119
|
origins: structuredClone(sheetOriginsRef.current),
|
|
2993
|
-
|
|
3120
|
+
selectionRanges,
|
|
2994
3121
|
sortState
|
|
2995
3122
|
};
|
|
2996
|
-
}, [activeCell, activeSheetIndex,
|
|
3123
|
+
}, [activeCell, activeSheetIndex, selectionRanges, sortState, workbook]);
|
|
2997
3124
|
const captureCellMutationState = q((cell) => {
|
|
2998
3125
|
const worksheet = getActiveWorksheet();
|
|
2999
3126
|
if (!worksheet) {
|
|
@@ -3035,9 +3162,9 @@ function useXlsxViewerController(options2) {
|
|
|
3035
3162
|
setActiveTabIndexState(nextTabIndex);
|
|
3036
3163
|
}
|
|
3037
3164
|
setActiveCell(entry.activeCell);
|
|
3038
|
-
|
|
3165
|
+
setSelectionRanges(entry.selectionRanges);
|
|
3039
3166
|
setSortState(entry.sortState);
|
|
3040
|
-
selectionAnchorRef.current = entry.
|
|
3167
|
+
selectionAnchorRef.current = entry.selectionRanges.at(-1)?.start ?? entry.activeCell;
|
|
3041
3168
|
setRevision((current) => current + 1);
|
|
3042
3169
|
}, [setChartAssets, setImageAssets]);
|
|
3043
3170
|
const applyCellEditHistoryEntry = q((entry, direction) => {
|
|
@@ -3057,8 +3184,8 @@ function useXlsxViewerController(options2) {
|
|
|
3057
3184
|
setActiveSheetIndexState(visibleSheetIndex);
|
|
3058
3185
|
}
|
|
3059
3186
|
setActiveCell(nextActiveCell);
|
|
3060
|
-
|
|
3061
|
-
selectionAnchorRef.current = nextSelection
|
|
3187
|
+
setSelectionRanges(nextSelection);
|
|
3188
|
+
selectionAnchorRef.current = nextSelection.at(-1)?.start ?? nextActiveCell;
|
|
3062
3189
|
isApplyingHistoryRef.current = false;
|
|
3063
3190
|
}, [maybeRecalculateWorkbook, refreshWorkbookState, sheets, workbook]);
|
|
3064
3191
|
const applyRangeEditHistoryEntry = q((entry, direction) => {
|
|
@@ -3080,8 +3207,8 @@ function useXlsxViewerController(options2) {
|
|
|
3080
3207
|
setActiveSheetIndexState(visibleSheetIndex);
|
|
3081
3208
|
}
|
|
3082
3209
|
setActiveCell(nextActiveCell);
|
|
3083
|
-
|
|
3084
|
-
selectionAnchorRef.current = nextSelection
|
|
3210
|
+
setSelectionRanges(nextSelection);
|
|
3211
|
+
selectionAnchorRef.current = nextSelection.at(-1)?.start ?? nextActiveCell;
|
|
3085
3212
|
isApplyingHistoryRef.current = false;
|
|
3086
3213
|
}, [maybeRecalculateWorkbook, refreshWorkbookState, sheets, workbook]);
|
|
3087
3214
|
const recordHistoryBeforeMutation = q(() => {
|
|
@@ -3340,13 +3467,13 @@ function useXlsxViewerController(options2) {
|
|
|
3340
3467
|
after,
|
|
3341
3468
|
before,
|
|
3342
3469
|
cell,
|
|
3343
|
-
selectionAfter: { start: cell, end: cell },
|
|
3344
|
-
selectionBefore:
|
|
3470
|
+
selectionAfter: [{ start: cell, end: cell }],
|
|
3471
|
+
selectionBefore: selectionRanges,
|
|
3345
3472
|
sheetIndex: activeSheet.workbookSheetIndex
|
|
3346
3473
|
});
|
|
3347
3474
|
redoStackRef.current = [];
|
|
3348
3475
|
setHistoryRevision((current) => current + 1);
|
|
3349
|
-
}, [activeCell, activeSheet,
|
|
3476
|
+
}, [activeCell, activeSheet, selectionRanges]);
|
|
3350
3477
|
const recordRangeEditHistory = q((mutations, selectionAfter, activeCellAfter, sortStateAfter = sortState) => {
|
|
3351
3478
|
if (!activeSheet || isApplyingHistoryRef.current || mutations.length === 0 && sortStateAfter === sortState) {
|
|
3352
3479
|
return;
|
|
@@ -3357,14 +3484,14 @@ function useXlsxViewerController(options2) {
|
|
|
3357
3484
|
activeCellBefore: activeCell,
|
|
3358
3485
|
mutations,
|
|
3359
3486
|
selectionAfter,
|
|
3360
|
-
selectionBefore:
|
|
3487
|
+
selectionBefore: selectionRanges,
|
|
3361
3488
|
sheetIndex: activeSheet.workbookSheetIndex,
|
|
3362
3489
|
sortStateAfter,
|
|
3363
3490
|
sortStateBefore: sortState
|
|
3364
3491
|
});
|
|
3365
3492
|
redoStackRef.current = [];
|
|
3366
3493
|
setHistoryRevision((current) => current + 1);
|
|
3367
|
-
}, [activeCell, activeSheet,
|
|
3494
|
+
}, [activeCell, activeSheet, selectionRanges, sortState]);
|
|
3368
3495
|
const sortTable = q((tableName, columnIndex, direction) => {
|
|
3369
3496
|
const worksheet = getActiveWorksheet();
|
|
3370
3497
|
const targetTable = tables.find((table) => table.name === tableName || table.displayName === tableName);
|
|
@@ -3423,7 +3550,7 @@ function useXlsxViewerController(options2) {
|
|
|
3423
3550
|
return;
|
|
3424
3551
|
}
|
|
3425
3552
|
setSortState(nextSortState);
|
|
3426
|
-
recordRangeEditHistory([],
|
|
3553
|
+
recordRangeEditHistory([], selectionRanges, activeCell, nextSortState);
|
|
3427
3554
|
return;
|
|
3428
3555
|
}
|
|
3429
3556
|
const mutations = [];
|
|
@@ -3452,7 +3579,7 @@ function useXlsxViewerController(options2) {
|
|
|
3452
3579
|
maybeRecalculateWorkbook(workbook);
|
|
3453
3580
|
refreshWorkbookState(workbook);
|
|
3454
3581
|
setSortState(nextSortState);
|
|
3455
|
-
recordRangeEditHistory(mutations,
|
|
3582
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell, nextSortState);
|
|
3456
3583
|
}, [
|
|
3457
3584
|
intersectsPivot,
|
|
3458
3585
|
activeCell,
|
|
@@ -3462,7 +3589,7 @@ function useXlsxViewerController(options2) {
|
|
|
3462
3589
|
readOnly,
|
|
3463
3590
|
recordRangeEditHistory,
|
|
3464
3591
|
refreshWorkbookState,
|
|
3465
|
-
|
|
3592
|
+
selectionRanges,
|
|
3466
3593
|
sortState,
|
|
3467
3594
|
tables,
|
|
3468
3595
|
workbook
|
|
@@ -3507,106 +3634,149 @@ function useXlsxViewerController(options2) {
|
|
|
3507
3634
|
}
|
|
3508
3635
|
setShouldAutoCalculate(false);
|
|
3509
3636
|
}, [refreshWorkbookState, workbook]);
|
|
3510
|
-
const applyReadOnlyResizeOverride = q((axis,
|
|
3511
|
-
if (!activeSheet)
|
|
3512
|
-
return;
|
|
3513
|
-
}
|
|
3637
|
+
const applyReadOnlyResizeOverride = q((axis, indices, sizePx) => {
|
|
3638
|
+
if (!activeSheet) return;
|
|
3514
3639
|
const contentSizePx = activeSheet.officeLayout ? sizePx : resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
|
|
3515
|
-
const
|
|
3516
|
-
setSheets((
|
|
3517
|
-
if (sheet.workbookSheetIndex !==
|
|
3518
|
-
|
|
3519
|
-
}
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
};
|
|
3525
|
-
const nextColWidths = [...sheet.colWidths];
|
|
3526
|
-
const visibleColIndex = sheet.visibleCols.indexOf(actualIndex);
|
|
3527
|
-
if (visibleColIndex >= 0) {
|
|
3528
|
-
nextColWidths[visibleColIndex] = contentSizePx;
|
|
3529
|
-
}
|
|
3530
|
-
return {
|
|
3531
|
-
...sheet,
|
|
3532
|
-
colWidthOverridesPx: nextColWidthOverridesPx,
|
|
3533
|
-
colWidths: nextColWidths
|
|
3534
|
-
};
|
|
3535
|
-
}
|
|
3536
|
-
const nextRowHeightOverridesPx = {
|
|
3537
|
-
...sheet.rowHeightOverridesPx,
|
|
3538
|
-
[actualIndex]: contentSizePx
|
|
3539
|
-
};
|
|
3540
|
-
const nextRowHeights = [...sheet.rowHeights];
|
|
3541
|
-
const visibleRowIndex = sheet.visibleRows.indexOf(actualIndex);
|
|
3542
|
-
if (visibleRowIndex >= 0) {
|
|
3543
|
-
nextRowHeights[visibleRowIndex] = contentSizePx;
|
|
3544
|
-
}
|
|
3545
|
-
return {
|
|
3546
|
-
...sheet,
|
|
3547
|
-
rowHeightOverridesPx: nextRowHeightOverridesPx,
|
|
3548
|
-
rowHeights: nextRowHeights
|
|
3549
|
-
};
|
|
3640
|
+
const selected = new Set(indices);
|
|
3641
|
+
setSheets((current) => current.map((sheet) => {
|
|
3642
|
+
if (sheet.workbookSheetIndex !== activeSheet.workbookSheetIndex) return sheet;
|
|
3643
|
+
const isRow = axis === "row";
|
|
3644
|
+
const overrides = { ...isRow ? sheet.rowHeightOverridesPx : sheet.colWidthOverridesPx };
|
|
3645
|
+
for (const index of selected) overrides[index] = contentSizePx;
|
|
3646
|
+
const visible = isRow ? sheet.visibleRows : sheet.visibleCols;
|
|
3647
|
+
const sizes = (isRow ? sheet.rowHeights : sheet.colWidths).map((size, offset) => selected.has(visible[offset]) ? contentSizePx : size);
|
|
3648
|
+
return isRow ? { ...sheet, rowHeightOverridesPx: overrides, rowHeights: sizes } : { ...sheet, colWidthOverridesPx: overrides, colWidths: sizes };
|
|
3550
3649
|
}));
|
|
3551
3650
|
setRevision((current) => current + 1);
|
|
3552
3651
|
}, [activeSheet]);
|
|
3553
|
-
const
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
if (
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
if (
|
|
3652
|
+
const canChangeVisibility = Boolean(activeSheet && !isLoading && (readOnly ? allowHideInReadOnly : workbook));
|
|
3653
|
+
const canChangeFreezePanes = Boolean(activeSheet && !isLoading && (readOnly ? allowFreezeInReadOnly : workbook));
|
|
3654
|
+
const activeLayout = activeSheet && readOnly ? readOnlyLayouts[activeSheet.workbookSheetIndex] : void 0;
|
|
3655
|
+
h(() => {
|
|
3656
|
+
if (!activeCell || !activeLayout) return;
|
|
3657
|
+
const { hiddenRows, hiddenCols } = activeLayout;
|
|
3658
|
+
const row3 = hiddenRows?.has(activeCell.row) ? nextVisibleIndex(activeCell.row, XLSX_MAX_ROWS, (index) => hiddenRows.has(index)) : activeCell.row;
|
|
3659
|
+
const col = hiddenCols?.has(activeCell.col) ? nextVisibleIndex(activeCell.col, XLSX_MAX_COLUMNS, (index) => hiddenCols.has(index)) : activeCell.col;
|
|
3660
|
+
if (row3 === activeCell.row && col === activeCell.col) return;
|
|
3661
|
+
const cell = row3 < 0 || col < 0 ? null : { row: row3, col };
|
|
3662
|
+
setActiveCell(cell);
|
|
3663
|
+
setSelection(cell && { start: cell, end: cell });
|
|
3664
|
+
selectionAnchorRef.current = cell;
|
|
3665
|
+
}, [activeCell, activeLayout, setSelection]);
|
|
3666
|
+
const setAxisHidden = q((axis, hidden, start, end = start) => {
|
|
3667
|
+
if (!canChangeVisibility || !activeSheet) return;
|
|
3668
|
+
const limit = axis === "row" ? XLSX_MAX_ROWS : XLSX_MAX_COLUMNS;
|
|
3669
|
+
const fromSelection = start === void 0 && end === void 0;
|
|
3670
|
+
const ranges = fromSelection ? selectionRanges.map((area) => ({ start: area.start[axis], end: area.end[axis] })) : [{ start: start ?? -1, end: end ?? -1 }];
|
|
3671
|
+
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;
|
|
3672
|
+
const sheetIndex = activeSheet.workbookSheetIndex;
|
|
3673
|
+
if (readOnly) {
|
|
3674
|
+
const key = axis === "row" ? "hiddenRows" : "hiddenCols";
|
|
3675
|
+
setReadOnlyLayouts((current) => {
|
|
3676
|
+
const layout = current[sheetIndex];
|
|
3677
|
+
const existing = layout?.[key] ?? new Set(activeSheet[key]);
|
|
3678
|
+
const changes = changedVisibilityRanges(existing, ranges, hidden, fromSelection);
|
|
3679
|
+
if (!changes.length) return current;
|
|
3680
|
+
const next = new Set(existing);
|
|
3681
|
+
for (const range of changes) {
|
|
3682
|
+
for (let index = range.start; index <= range.end; index++) {
|
|
3683
|
+
if (hidden) next.add(index);
|
|
3684
|
+
else next.delete(index);
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
return { ...current, [sheetIndex]: { ...layout, [key]: next } };
|
|
3688
|
+
});
|
|
3562
3689
|
return;
|
|
3563
3690
|
}
|
|
3564
|
-
|
|
3565
|
-
const worksheet = workbook.getSheet(
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
)
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3691
|
+
if (!workbook) return;
|
|
3692
|
+
const worksheet = workbook.getSheet(sheetIndex);
|
|
3693
|
+
try {
|
|
3694
|
+
const existing = new Set(axis === "row" ? worksheet.hiddenRows : worksheet.hiddenColumns);
|
|
3695
|
+
const changes = changedVisibilityRanges(existing, ranges, hidden, fromSelection);
|
|
3696
|
+
if (!changes.length) return;
|
|
3697
|
+
recordHistoryBeforeMutation();
|
|
3698
|
+
for (const range of changes) {
|
|
3699
|
+
if (axis === "row") worksheet.setRowsHidden(range.start, range.end, hidden);
|
|
3700
|
+
else worksheet.setColumnsHidden(range.start, range.end, hidden);
|
|
3701
|
+
}
|
|
3702
|
+
if (hidden && activeCell && changes.some((range) => range.start <= activeCell[axis] && activeCell[axis] <= range.end)) {
|
|
3703
|
+
const index = nextVisibleIndex(
|
|
3704
|
+
activeCell[axis],
|
|
3705
|
+
limit,
|
|
3706
|
+
(value) => axis === "row" ? worksheet.isRowHidden(value) : worksheet.isColumnHidden(value)
|
|
3707
|
+
);
|
|
3708
|
+
if (index >= 0) {
|
|
3709
|
+
const cell = { ...activeCell, [axis]: index };
|
|
3710
|
+
setActiveCell(cell);
|
|
3711
|
+
setSelection({ start: cell, end: cell });
|
|
3712
|
+
selectionAnchorRef.current = cell;
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
refreshWorkbookState(workbook);
|
|
3716
|
+
} finally {
|
|
3717
|
+
worksheet.free();
|
|
3718
|
+
}
|
|
3719
|
+
}, [activeCell, activeSheet, canChangeVisibility, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selectionRanges, setSelection, workbook]);
|
|
3720
|
+
const hideRows = q((start, end) => setAxisHidden("row", true, start, end), [setAxisHidden]);
|
|
3721
|
+
const unhideRows = q((start, end) => setAxisHidden("row", false, start, end), [setAxisHidden]);
|
|
3722
|
+
const hideColumns = q((start, end) => setAxisHidden("col", true, start, end), [setAxisHidden]);
|
|
3723
|
+
const unhideColumns = q((start, end) => setAxisHidden("col", false, start, end), [setAxisHidden]);
|
|
3724
|
+
const setFreezeBoundary = q((cell) => {
|
|
3725
|
+
if (!canChangeFreezePanes || !activeSheet) return;
|
|
3726
|
+
const { row: row3, col } = cell;
|
|
3727
|
+
if (!Number.isInteger(row3) || row3 < 0 || row3 >= XLSX_MAX_ROWS || !Number.isInteger(col) || col < 0 || col >= XLSX_MAX_COLUMNS) return;
|
|
3728
|
+
const sheetIndex = activeSheet.workbookSheetIndex;
|
|
3729
|
+
if (readOnly) {
|
|
3730
|
+
const freezePanes2 = row3 || col ? { row: row3, col } : null;
|
|
3731
|
+
setReadOnlyLayouts((current) => ({ ...current, [sheetIndex]: { ...current[sheetIndex], freezePanes: freezePanes2 } }));
|
|
3585
3732
|
return;
|
|
3586
3733
|
}
|
|
3734
|
+
if (!workbook) return;
|
|
3735
|
+
const worksheet = workbook.getSheet(sheetIndex);
|
|
3736
|
+
try {
|
|
3737
|
+
const current = parseWorksheetFreezePanes(worksheet);
|
|
3738
|
+
if (row3 === (current?.row ?? 0) && col === (current?.col ?? 0)) return;
|
|
3739
|
+
recordHistoryBeforeMutation();
|
|
3740
|
+
worksheet.setFreezePanes(row3, col);
|
|
3741
|
+
refreshWorkbookState(workbook);
|
|
3742
|
+
} finally {
|
|
3743
|
+
worksheet.free();
|
|
3744
|
+
}
|
|
3745
|
+
}, [activeSheet, canChangeFreezePanes, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
|
|
3746
|
+
const freezeCell = resolveFreezePanesCell(activeCell, selection);
|
|
3747
|
+
const canFreezePanes = Boolean(canChangeFreezePanes && freezeCell && (freezeCell.row > 0 || freezeCell.col > 0));
|
|
3748
|
+
const freezePanes = q((cell = freezeCell) => {
|
|
3749
|
+
if (cell) setFreezeBoundary(cell);
|
|
3750
|
+
}, [freezeCell, setFreezeBoundary]);
|
|
3751
|
+
const unfreezePanes = q(() => setFreezeBoundary({ row: 0, col: 0 }), [setFreezeBoundary]);
|
|
3752
|
+
const resizeAxis = q((axis, target, sizePx) => {
|
|
3753
|
+
if (!canResize || !activeSheet || !Number.isFinite(sizePx)) return;
|
|
3754
|
+
const indices = typeof target === "number" ? [target] : target;
|
|
3755
|
+
const limit = axis === "row" ? XLSX_MAX_ROWS : XLSX_MAX_COLUMNS;
|
|
3756
|
+
if (!indices.length || indices.some((index) => !Number.isInteger(index) || index < 0 || index >= limit)) return;
|
|
3587
3757
|
if (isWorkerBacked) {
|
|
3588
|
-
applyReadOnlyResizeOverride(
|
|
3758
|
+
applyReadOnlyResizeOverride(axis, indices, sizePx);
|
|
3589
3759
|
return;
|
|
3590
3760
|
}
|
|
3591
|
-
if (!workbook)
|
|
3592
|
-
return;
|
|
3593
|
-
}
|
|
3594
|
-
recordHistoryBeforeMutation();
|
|
3761
|
+
if (!workbook) return;
|
|
3595
3762
|
const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3763
|
+
try {
|
|
3764
|
+
recordHistoryBeforeMutation();
|
|
3765
|
+
const contentPx = resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
|
|
3766
|
+
if (axis === "row") {
|
|
3767
|
+
const points = activeSheet.officeLayout ? Math.max(sizePx, MIN_ROW_HEIGHT_PX) * 3 / 4 : pxToSheetRowHeight(contentPx);
|
|
3768
|
+
for (const index of indices) worksheet.setRowHeight(index, points);
|
|
3769
|
+
} else {
|
|
3770
|
+
const width = activeSheet.officeLayout ? pxToOfficeColumnWidth(sizePx, activeSheet.officeLayout.columnDigitWidthPt) : pxToSheetColumnWidth(contentPx, activeSheet.columnWidthCharacterWidthPx);
|
|
3771
|
+
for (const index of indices) worksheet.setColumnWidth(index, width);
|
|
3772
|
+
}
|
|
3773
|
+
refreshWorkbookState(workbook);
|
|
3774
|
+
} finally {
|
|
3775
|
+
worksheet.free();
|
|
3776
|
+
}
|
|
3777
|
+
}, [activeSheet, applyReadOnlyResizeOverride, canResize, isWorkerBacked, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
|
|
3778
|
+
const resizeColumn = q((col, widthPx) => resizeAxis("column", col, widthPx), [resizeAxis]);
|
|
3779
|
+
const resizeRow = q((row3, heightPx) => resizeAxis("row", row3, heightPx), [resizeAxis]);
|
|
3610
3780
|
const resolveAnchoredObjectRect = q((anchor, worksheet) => {
|
|
3611
3781
|
const resolveAxisSum = (index, getSize) => {
|
|
3612
3782
|
let total = 0;
|
|
@@ -4036,15 +4206,20 @@ function useXlsxViewerController(options2) {
|
|
|
4036
4206
|
selectionAnchorRef.current = anchorCell;
|
|
4037
4207
|
setSelection(merged ?? { start: cell, end: cell });
|
|
4038
4208
|
}, [activeSheet?.mergedRanges, findSelectionMerge]);
|
|
4039
|
-
const
|
|
4040
|
-
const
|
|
4209
|
+
const selectRanges = q((ranges, activeCorner = "end") => {
|
|
4210
|
+
const areas = ranges.reduce((previous, range) => addSelectionRange(previous, normalizeRange(range)), []);
|
|
4211
|
+
const active = areas.at(-1);
|
|
4041
4212
|
setSelectedChartId(null);
|
|
4042
4213
|
setSelectedChartElement(null);
|
|
4043
4214
|
setSelectedImageId(null);
|
|
4044
|
-
selectionAnchorRef.current =
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4215
|
+
selectionAnchorRef.current = active?.start ?? null;
|
|
4216
|
+
const cell = active?.[activeCorner];
|
|
4217
|
+
setActiveCell(cell ? findSelectionMerge(cell)?.start ?? cell : null);
|
|
4218
|
+
setSelectionRanges(areas);
|
|
4219
|
+
}, [findSelectionMerge]);
|
|
4220
|
+
const selectRange = q((range) => {
|
|
4221
|
+
selectRanges([expandHighlightedRange(normalizeRange(range), activeSheet?.mergedRanges ?? [])]);
|
|
4222
|
+
}, [activeSheet?.mergedRanges, selectRanges]);
|
|
4048
4223
|
const clearSelection = q(() => {
|
|
4049
4224
|
selectionAnchorRef.current = null;
|
|
4050
4225
|
setActiveCell(null);
|
|
@@ -4055,38 +4230,35 @@ function useXlsxViewerController(options2) {
|
|
|
4055
4230
|
}, []);
|
|
4056
4231
|
const clearSelectedCells = q(() => {
|
|
4057
4232
|
const worksheet = getActiveWorksheet();
|
|
4058
|
-
|
|
4059
|
-
if (readOnly || !worksheet || !workbook || !targetRange) {
|
|
4060
|
-
return;
|
|
4061
|
-
}
|
|
4062
|
-
if (intersectsPivot(targetRange)) return;
|
|
4063
|
-
const normalized = normalizeRange(targetRange);
|
|
4233
|
+
if (readOnly || !worksheet || !workbook || !selectionRanges.length || selectionRanges.some(intersectsPivot)) return;
|
|
4064
4234
|
const mutations = [];
|
|
4065
|
-
for (
|
|
4066
|
-
for (let
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4235
|
+
for (const area of selectionRanges) {
|
|
4236
|
+
for (let row3 = area.start.row; row3 <= area.end.row; row3 += 1) {
|
|
4237
|
+
for (let col = area.start.col; col <= area.end.col; col += 1) {
|
|
4238
|
+
if (worksheet.isMergedSecondary(row3, col)) {
|
|
4239
|
+
continue;
|
|
4240
|
+
}
|
|
4241
|
+
const cell = { row: row3, col };
|
|
4242
|
+
const before = captureCellMutationState(cell);
|
|
4243
|
+
if (!before) {
|
|
4244
|
+
continue;
|
|
4245
|
+
}
|
|
4246
|
+
worksheet.setCell(cellAddressToA1({ row: row3, col }), "");
|
|
4247
|
+
const after = captureCellMutationState(cell);
|
|
4248
|
+
if (!after) {
|
|
4249
|
+
continue;
|
|
4250
|
+
}
|
|
4251
|
+
mutations.push({
|
|
4252
|
+
after,
|
|
4253
|
+
before,
|
|
4254
|
+
cell
|
|
4255
|
+
});
|
|
4079
4256
|
}
|
|
4080
|
-
mutations.push({
|
|
4081
|
-
after,
|
|
4082
|
-
before,
|
|
4083
|
-
cell
|
|
4084
|
-
});
|
|
4085
4257
|
}
|
|
4086
4258
|
}
|
|
4087
4259
|
maybeRecalculateWorkbook(workbook);
|
|
4088
4260
|
refreshWorkbookState(workbook);
|
|
4089
|
-
recordRangeEditHistory(mutations,
|
|
4261
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
4090
4262
|
}, [
|
|
4091
4263
|
intersectsPivot,
|
|
4092
4264
|
activeCell,
|
|
@@ -4096,7 +4268,7 @@ function useXlsxViewerController(options2) {
|
|
|
4096
4268
|
readOnly,
|
|
4097
4269
|
recordRangeEditHistory,
|
|
4098
4270
|
refreshWorkbookState,
|
|
4099
|
-
|
|
4271
|
+
selectionRanges,
|
|
4100
4272
|
workbook
|
|
4101
4273
|
]);
|
|
4102
4274
|
const setCellValue = q((cell, value) => {
|
|
@@ -4181,8 +4353,8 @@ function useXlsxViewerController(options2) {
|
|
|
4181
4353
|
if (after) mutations.push({ cell, before, after });
|
|
4182
4354
|
}
|
|
4183
4355
|
refreshWorkbookState(workbook);
|
|
4184
|
-
recordRangeEditHistory(mutations,
|
|
4185
|
-
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState,
|
|
4356
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
4357
|
+
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selectionRanges, workbook]);
|
|
4186
4358
|
const setSelectedCellValue = q((value) => {
|
|
4187
4359
|
if (!activeCell) {
|
|
4188
4360
|
return;
|
|
@@ -4216,25 +4388,27 @@ function useXlsxViewerController(options2) {
|
|
|
4216
4388
|
if (readOnly || !worksheet || !workbook) {
|
|
4217
4389
|
return;
|
|
4218
4390
|
}
|
|
4219
|
-
const
|
|
4391
|
+
const areas = "start" in range ? [normalizeRange(range)] : range.map(normalizeRange);
|
|
4220
4392
|
const beforeStates = [];
|
|
4221
|
-
for (
|
|
4222
|
-
for (let
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4393
|
+
for (const area of areas) {
|
|
4394
|
+
for (let row3 = area.start.row; row3 <= area.end.row; row3 += 1) {
|
|
4395
|
+
for (let col = area.start.col; col <= area.end.col; col += 1) {
|
|
4396
|
+
const cell = { row: row3, col };
|
|
4397
|
+
const before = captureCellMutationState(cell);
|
|
4398
|
+
if (!before) {
|
|
4399
|
+
continue;
|
|
4400
|
+
}
|
|
4401
|
+
beforeStates.push({
|
|
4402
|
+
before,
|
|
4403
|
+
cell
|
|
4404
|
+
});
|
|
4227
4405
|
}
|
|
4228
|
-
beforeStates.push({
|
|
4229
|
-
before,
|
|
4230
|
-
cell
|
|
4231
|
-
});
|
|
4232
4406
|
}
|
|
4233
4407
|
}
|
|
4234
4408
|
if (beforeStates.length === 0) {
|
|
4235
4409
|
return;
|
|
4236
4410
|
}
|
|
4237
|
-
worksheet.setRangeStyle(rangeToA1(
|
|
4411
|
+
for (const area of areas) worksheet.setRangeStyle(rangeToA1(area), style);
|
|
4238
4412
|
const mutations = [];
|
|
4239
4413
|
for (const mutation of beforeStates) {
|
|
4240
4414
|
const after = captureCellMutationState(mutation.cell);
|
|
@@ -4248,11 +4422,11 @@ function useXlsxViewerController(options2) {
|
|
|
4248
4422
|
});
|
|
4249
4423
|
}
|
|
4250
4424
|
refreshWorkbookState(workbook);
|
|
4251
|
-
recordRangeEditHistory(mutations,
|
|
4252
|
-
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState,
|
|
4425
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
4426
|
+
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selectionRanges, workbook]);
|
|
4253
4427
|
const fillSelection = q((targetRange) => {
|
|
4254
4428
|
const worksheet = getActiveWorksheet();
|
|
4255
|
-
if (readOnly || !worksheet || !workbook || !selection) {
|
|
4429
|
+
if (readOnly || !worksheet || !workbook || !selection || selectionRanges.length > 1) {
|
|
4256
4430
|
return;
|
|
4257
4431
|
}
|
|
4258
4432
|
if (intersectsPivot(targetRange)) return;
|
|
@@ -4303,11 +4477,11 @@ function useXlsxViewerController(options2) {
|
|
|
4303
4477
|
setSelection(nextRange);
|
|
4304
4478
|
setActiveCell(nextRange.end);
|
|
4305
4479
|
selectionAnchorRef.current = nextRange.start;
|
|
4306
|
-
recordRangeEditHistory(mutations, nextRange, nextRange.end);
|
|
4307
|
-
}, [intersectsPivot, captureCellMutationState, getActiveWorksheet, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
|
|
4480
|
+
recordRangeEditHistory(mutations, [nextRange], nextRange.end);
|
|
4481
|
+
}, [intersectsPivot, captureCellMutationState, getActiveWorksheet, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4308
4482
|
const mergeSelection = q((mode = "cells") => {
|
|
4309
4483
|
const worksheet = getActiveWorksheet();
|
|
4310
|
-
if (readOnly || !worksheet || !selection || !workbook) {
|
|
4484
|
+
if (readOnly || !worksheet || !selection || selectionRanges.length > 1 || !workbook) {
|
|
4311
4485
|
return;
|
|
4312
4486
|
}
|
|
4313
4487
|
if (intersectsPivot(selection)) return;
|
|
@@ -4340,10 +4514,10 @@ function useXlsxViewerController(options2) {
|
|
|
4340
4514
|
selectionAnchorRef.current = range.start;
|
|
4341
4515
|
setSelection(range);
|
|
4342
4516
|
setActiveCell(range.start);
|
|
4343
|
-
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, workbook]);
|
|
4517
|
+
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4344
4518
|
const unmergeSelection = q(() => {
|
|
4345
4519
|
const worksheet = getActiveWorksheet();
|
|
4346
|
-
if (readOnly || !worksheet || !selection || !workbook) {
|
|
4520
|
+
if (readOnly || !worksheet || !selection || selectionRanges.length > 1 || !workbook) {
|
|
4347
4521
|
return;
|
|
4348
4522
|
}
|
|
4349
4523
|
const range = normalizeRange(selection);
|
|
@@ -4355,7 +4529,7 @@ function useXlsxViewerController(options2) {
|
|
|
4355
4529
|
worksheet.unmergeCells(rangeToA1(merged));
|
|
4356
4530
|
}
|
|
4357
4531
|
refreshWorkbookState(workbook);
|
|
4358
|
-
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, workbook]);
|
|
4532
|
+
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4359
4533
|
const addSheet = q((name) => {
|
|
4360
4534
|
if (readOnly || !workbook) {
|
|
4361
4535
|
return;
|
|
@@ -4444,18 +4618,18 @@ function useXlsxViewerController(options2) {
|
|
|
4444
4618
|
if (!trimmed) {
|
|
4445
4619
|
return;
|
|
4446
4620
|
}
|
|
4447
|
-
const targetRange = range ?? selection;
|
|
4621
|
+
const targetRange = range ?? (selectionRanges.length === 1 ? selection : null);
|
|
4448
4622
|
if (!targetRange) {
|
|
4449
4623
|
return;
|
|
4450
4624
|
}
|
|
4451
4625
|
recordHistoryBeforeMutation();
|
|
4452
4626
|
workbook.defineName(trimmed, rangeToA1(targetRange));
|
|
4453
4627
|
setRevision((current) => current + 1);
|
|
4454
|
-
}, [readOnly, recordHistoryBeforeMutation, selection, workbook]);
|
|
4628
|
+
}, [readOnly, recordHistoryBeforeMutation, selection, selectionRanges, workbook]);
|
|
4455
4629
|
const pasteText = q((text) => {
|
|
4456
4630
|
const worksheet = getActiveWorksheet();
|
|
4457
4631
|
const targetCell = activeCell ?? selection?.start ?? null;
|
|
4458
|
-
if (readOnly || !worksheet || !workbook || !targetCell || !text) {
|
|
4632
|
+
if (readOnly || !worksheet || !workbook || !targetCell || selectionRanges.length > 1 || !text) {
|
|
4459
4633
|
return false;
|
|
4460
4634
|
}
|
|
4461
4635
|
const grid = parseClipboardText(text);
|
|
@@ -4518,13 +4692,13 @@ function useXlsxViewerController(options2) {
|
|
|
4518
4692
|
setActiveCell(targetCell);
|
|
4519
4693
|
setSelection(nextRange);
|
|
4520
4694
|
selectionAnchorRef.current = targetCell;
|
|
4521
|
-
recordRangeEditHistory(mutations, nextRange, targetCell);
|
|
4695
|
+
recordRangeEditHistory(mutations, [nextRange], targetCell);
|
|
4522
4696
|
return true;
|
|
4523
|
-
}, [intersectsPivot, activeCell, captureCellMutationState, getActiveWorksheet, locale, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
|
|
4697
|
+
}, [intersectsPivot, activeCell, captureCellMutationState, getActiveWorksheet, locale, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4524
4698
|
const pasteStructuredClipboardData = q((serializedPayload) => {
|
|
4525
4699
|
const worksheet = getActiveWorksheet();
|
|
4526
4700
|
const targetCell = activeCell ?? selection?.start ?? null;
|
|
4527
|
-
if (readOnly || !worksheet || !workbook || !targetCell || !serializedPayload) {
|
|
4701
|
+
if (readOnly || !worksheet || !workbook || !targetCell || selectionRanges.length > 1 || !serializedPayload) {
|
|
4528
4702
|
return false;
|
|
4529
4703
|
}
|
|
4530
4704
|
let payload;
|
|
@@ -4613,7 +4787,7 @@ function useXlsxViewerController(options2) {
|
|
|
4613
4787
|
setSelection(nextRange);
|
|
4614
4788
|
selectionAnchorRef.current = targetCell;
|
|
4615
4789
|
if (!hasMergeOperations) {
|
|
4616
|
-
recordRangeEditHistory(mutations, nextRange, targetCell);
|
|
4790
|
+
recordRangeEditHistory(mutations, [nextRange], targetCell);
|
|
4617
4791
|
}
|
|
4618
4792
|
return true;
|
|
4619
4793
|
}, [
|
|
@@ -4627,33 +4801,37 @@ function useXlsxViewerController(options2) {
|
|
|
4627
4801
|
recordRangeEditHistory,
|
|
4628
4802
|
refreshWorkbookState,
|
|
4629
4803
|
selection,
|
|
4804
|
+
selectionRanges,
|
|
4630
4805
|
workbook
|
|
4631
4806
|
]);
|
|
4632
4807
|
const copySelectionToClipboard = q(async () => {
|
|
4633
4808
|
if (typeof navigator === "undefined" || !navigator.clipboard) {
|
|
4634
4809
|
return false;
|
|
4635
4810
|
}
|
|
4636
|
-
if (isWorkerBacked && activeSheet
|
|
4637
|
-
const
|
|
4811
|
+
if (isWorkerBacked && activeSheet) {
|
|
4812
|
+
const bands = clipboardBands(selectionRanges);
|
|
4813
|
+
if (!bands) return false;
|
|
4638
4814
|
const textPromise = (async () => {
|
|
4639
4815
|
const lines = [];
|
|
4640
|
-
for (
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
for (const
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4816
|
+
for (const band of bands.rows) {
|
|
4817
|
+
for (let startRow = band.start; startRow <= band.end; startRow += 128) {
|
|
4818
|
+
const count = Math.min(128, band.end - startRow + 1);
|
|
4819
|
+
const batch = await getRowsBatchAsync(activeSheet.workbookSheetIndex, startRow, count);
|
|
4820
|
+
if (!batch) throw new Error("Unable to read the selected cells.");
|
|
4821
|
+
const values = /* @__PURE__ */ new Map();
|
|
4822
|
+
for (const entry of batch) {
|
|
4823
|
+
for (const cell of entry.cells ?? []) {
|
|
4824
|
+
if (cell.isMergedSecondary) continue;
|
|
4825
|
+
const value = String(cell.value ?? "");
|
|
4826
|
+
const cached = cell.formula ? activeSheet.cachedFormulaValues[cellAddressToA1({ row: entry.index, col: cell.col })] : void 0;
|
|
4827
|
+
values.set(`${entry.index}:${cell.col}`, decodeHtmlEntities(cached !== void 0 && value.startsWith("#") ? cached : value));
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4830
|
+
for (let row3 = startRow; row3 < startRow + count; row3++) {
|
|
4831
|
+
const cells = [];
|
|
4832
|
+
for (const { index: col } of bandIndices(bands.cols)) cells.push(values.get(`${row3}:${col}`) ?? "");
|
|
4833
|
+
lines.push(cells.join(" "));
|
|
4651
4834
|
}
|
|
4652
|
-
}
|
|
4653
|
-
for (let row3 = startRow; row3 < startRow + count; row3++) {
|
|
4654
|
-
const cells = [];
|
|
4655
|
-
for (let col = range.start.col; col <= range.end.col; col++) cells.push(values.get(`${row3}:${col}`) ?? "");
|
|
4656
|
-
lines.push(cells.join(" "));
|
|
4657
4835
|
}
|
|
4658
4836
|
}
|
|
4659
4837
|
return lines.join("\n");
|
|
@@ -4691,7 +4869,7 @@ function useXlsxViewerController(options2) {
|
|
|
4691
4869
|
}
|
|
4692
4870
|
await navigator.clipboard.writeText(clipboardData.text);
|
|
4693
4871
|
return true;
|
|
4694
|
-
}, [activeSheet, getClipboardData, getRowsBatchAsync, isWorkerBacked,
|
|
4872
|
+
}, [activeSheet, getClipboardData, getRowsBatchAsync, isWorkerBacked, selectionRanges]);
|
|
4695
4873
|
const pasteFromClipboard = q(async (clipboardData) => {
|
|
4696
4874
|
if (readOnly) return false;
|
|
4697
4875
|
const state = drawingMutationState.current;
|
|
@@ -4856,6 +5034,16 @@ function useXlsxViewerController(options2) {
|
|
|
4856
5034
|
revision,
|
|
4857
5035
|
resizeChartBy,
|
|
4858
5036
|
resizeImageBy,
|
|
5037
|
+
frozenPanes: activeSheet?.freezePanes ?? null,
|
|
5038
|
+
canChangeFreezePanes,
|
|
5039
|
+
canChangeVisibility,
|
|
5040
|
+
canFreezePanes,
|
|
5041
|
+
hideRows,
|
|
5042
|
+
unhideRows,
|
|
5043
|
+
hideColumns,
|
|
5044
|
+
unhideColumns,
|
|
5045
|
+
freezePanes,
|
|
5046
|
+
unfreezePanes,
|
|
4859
5047
|
resizeColumn,
|
|
4860
5048
|
resizeRow,
|
|
4861
5049
|
setCellFormula,
|
|
@@ -4884,6 +5072,8 @@ function useXlsxViewerController(options2) {
|
|
|
4884
5072
|
selectChartElement,
|
|
4885
5073
|
selectImage,
|
|
4886
5074
|
selectRange,
|
|
5075
|
+
selectRanges,
|
|
5076
|
+
selectionRanges,
|
|
4887
5077
|
selection,
|
|
4888
5078
|
setActiveSheetIndex,
|
|
4889
5079
|
setActiveTabIndex,
|
|
@@ -4999,6 +5189,15 @@ function useXlsxViewerController(options2) {
|
|
|
4999
5189
|
revision,
|
|
5000
5190
|
resizeChartBy,
|
|
5001
5191
|
resizeImageBy,
|
|
5192
|
+
canChangeFreezePanes,
|
|
5193
|
+
canChangeVisibility,
|
|
5194
|
+
canFreezePanes,
|
|
5195
|
+
hideRows,
|
|
5196
|
+
unhideRows,
|
|
5197
|
+
hideColumns,
|
|
5198
|
+
unhideColumns,
|
|
5199
|
+
freezePanes,
|
|
5200
|
+
unfreezePanes,
|
|
5002
5201
|
resizeColumn,
|
|
5003
5202
|
resizeRow,
|
|
5004
5203
|
setCellFormula,
|
|
@@ -5027,6 +5226,8 @@ function useXlsxViewerController(options2) {
|
|
|
5027
5226
|
selectChartElement,
|
|
5028
5227
|
selectImage,
|
|
5029
5228
|
selectRange,
|
|
5229
|
+
selectRanges,
|
|
5230
|
+
selectionRanges,
|
|
5030
5231
|
selection,
|
|
5031
5232
|
setActiveSheetIndex,
|
|
5032
5233
|
setActiveTabIndex,
|
|
@@ -6639,6 +6840,15 @@ function resolveCellTextClipOverscan(overscan, usesWrappedText) {
|
|
|
6639
6840
|
}
|
|
6640
6841
|
|
|
6641
6842
|
// src/scroll-display-limit.ts
|
|
6843
|
+
function minimumVisibleExtent(minimum, sortedHidden, maximum) {
|
|
6844
|
+
if (!sortedHidden?.length || sortedHidden.length === maximum) return minimum;
|
|
6845
|
+
let extent = minimum;
|
|
6846
|
+
for (const index of sortedHidden) {
|
|
6847
|
+
if (index >= extent || extent >= maximum) break;
|
|
6848
|
+
extent++;
|
|
6849
|
+
}
|
|
6850
|
+
return extent;
|
|
6851
|
+
}
|
|
6642
6852
|
function growScrollDisplayLimit(current, growth, maximum, readOnly) {
|
|
6643
6853
|
const nextLimit = current + growth;
|
|
6644
6854
|
return readOnly ? Math.max(current, Math.min(maximum, nextLimit)) : nextLimit;
|
|
@@ -7181,6 +7391,110 @@ function getCellGeneralAlignment(worksheet, row3, col) {
|
|
|
7181
7391
|
}
|
|
7182
7392
|
}
|
|
7183
7393
|
|
|
7394
|
+
// src/header-size-dialog.tsx
|
|
7395
|
+
function HeaderSizeDialog({ axis, context, sizes, maxSize, messages, locale, palette, close, resize }) {
|
|
7396
|
+
const dialog = A(null);
|
|
7397
|
+
const input = A(null);
|
|
7398
|
+
const titleId = g();
|
|
7399
|
+
const coordinate = axis === "row" ? "row" : "col";
|
|
7400
|
+
const title = axis === "row" ? messages.rowHeight : messages.columnWidth;
|
|
7401
|
+
const indices = T(() => {
|
|
7402
|
+
const selected = /* @__PURE__ */ new Set();
|
|
7403
|
+
for (const area of context.selectionRanges ?? [context.selection]) {
|
|
7404
|
+
for (let index = area.start[coordinate]; index <= area.end[coordinate]; index++) selected.add(index);
|
|
7405
|
+
}
|
|
7406
|
+
return [...selected];
|
|
7407
|
+
}, [context, coordinate]);
|
|
7408
|
+
const [value, setValue] = d(() => {
|
|
7409
|
+
const size = sizes[context.cell[coordinate]];
|
|
7410
|
+
return Number.isFinite(size) && indices.every((index) => sizes[index] === size) ? String(Math.round(size * 100) / 100) : "";
|
|
7411
|
+
});
|
|
7412
|
+
const dismiss = () => {
|
|
7413
|
+
dialog.current?.close();
|
|
7414
|
+
close();
|
|
7415
|
+
};
|
|
7416
|
+
const buttonStyle = {
|
|
7417
|
+
minWidth: 60,
|
|
7418
|
+
padding: "4px 12px",
|
|
7419
|
+
borderRadius: 4,
|
|
7420
|
+
font: "inherit",
|
|
7421
|
+
cursor: "pointer",
|
|
7422
|
+
border: `1px solid ${palette.strongBorder}`,
|
|
7423
|
+
background: palette.buttonSurface,
|
|
7424
|
+
color: palette.buttonText
|
|
7425
|
+
};
|
|
7426
|
+
_(() => {
|
|
7427
|
+
dialog.current?.showModal();
|
|
7428
|
+
input.current?.select();
|
|
7429
|
+
}, []);
|
|
7430
|
+
return $(
|
|
7431
|
+
/* @__PURE__ */ u(
|
|
7432
|
+
"dialog",
|
|
7433
|
+
{
|
|
7434
|
+
ref: dialog,
|
|
7435
|
+
"aria-labelledby": titleId,
|
|
7436
|
+
lang: locale,
|
|
7437
|
+
onCancel: (event) => {
|
|
7438
|
+
event.preventDefault();
|
|
7439
|
+
dismiss();
|
|
7440
|
+
},
|
|
7441
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
7442
|
+
style: {
|
|
7443
|
+
margin: "auto",
|
|
7444
|
+
width: 240,
|
|
7445
|
+
maxWidth: "calc(100vw - 32px)",
|
|
7446
|
+
padding: 16,
|
|
7447
|
+
borderRadius: 8,
|
|
7448
|
+
border: `1px solid ${palette.border}`,
|
|
7449
|
+
background: palette.surface,
|
|
7450
|
+
color: palette.text,
|
|
7451
|
+
font: "13px/1.4 system-ui, sans-serif"
|
|
7452
|
+
},
|
|
7453
|
+
children: /* @__PURE__ */ u("form", { onSubmit: (event) => {
|
|
7454
|
+
event.preventDefault();
|
|
7455
|
+
const size = input.current?.valueAsNumber;
|
|
7456
|
+
if (size === void 0 || !Number.isFinite(size)) return;
|
|
7457
|
+
if (indices.some((index) => Math.abs(sizes[index] - size) >= 5e-3)) resize(indices, size);
|
|
7458
|
+
dismiss();
|
|
7459
|
+
}, children: [
|
|
7460
|
+
/* @__PURE__ */ u("div", { id: titleId, style: { fontSize: 15, fontWeight: 600, marginBottom: 12 }, children: title }),
|
|
7461
|
+
/* @__PURE__ */ u("label", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
|
|
7462
|
+
messages.pixels,
|
|
7463
|
+
/* @__PURE__ */ u(
|
|
7464
|
+
"input",
|
|
7465
|
+
{
|
|
7466
|
+
ref: input,
|
|
7467
|
+
type: "number",
|
|
7468
|
+
min: axis === "row" ? 16 : 30,
|
|
7469
|
+
max: Math.floor(maxSize),
|
|
7470
|
+
step: "any",
|
|
7471
|
+
required: true,
|
|
7472
|
+
value,
|
|
7473
|
+
onChange: (event) => setValue(event.currentTarget.value),
|
|
7474
|
+
style: {
|
|
7475
|
+
minWidth: 0,
|
|
7476
|
+
width: "100%",
|
|
7477
|
+
padding: "4px 8px",
|
|
7478
|
+
border: `1px solid ${palette.strongBorder}`,
|
|
7479
|
+
borderRadius: 4,
|
|
7480
|
+
background: palette.surface,
|
|
7481
|
+
color: palette.text,
|
|
7482
|
+
font: "inherit"
|
|
7483
|
+
}
|
|
7484
|
+
}
|
|
7485
|
+
)
|
|
7486
|
+
] }),
|
|
7487
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8, marginTop: 16 }, children: [
|
|
7488
|
+
/* @__PURE__ */ u("button", { type: "button", style: buttonStyle, onClick: dismiss, children: messages.cancel }),
|
|
7489
|
+
/* @__PURE__ */ u("button", { type: "submit", style: { ...buttonStyle, background: palette.text, color: palette.surface }, children: messages.ok })
|
|
7490
|
+
] })
|
|
7491
|
+
] })
|
|
7492
|
+
}
|
|
7493
|
+
),
|
|
7494
|
+
document.body
|
|
7495
|
+
);
|
|
7496
|
+
}
|
|
7497
|
+
|
|
7184
7498
|
// src/viewer-palette.ts
|
|
7185
7499
|
var LIGHT_PALETTE = {
|
|
7186
7500
|
border: "#e4e4e7",
|
|
@@ -7434,6 +7748,8 @@ function XlsxContextMenu({
|
|
|
7434
7748
|
closeMenu,
|
|
7435
7749
|
editCell,
|
|
7436
7750
|
selectExtent,
|
|
7751
|
+
canResize,
|
|
7752
|
+
editSize,
|
|
7437
7753
|
renderContextMenu,
|
|
7438
7754
|
contextMenuClassName,
|
|
7439
7755
|
contextMenuStyle
|
|
@@ -7454,15 +7770,38 @@ function XlsxContextMenu({
|
|
|
7454
7770
|
const table = controller.tables.find(({ start, end }) => context.cell.row >= start.row && context.cell.row <= end.row && context.cell.col >= start.col && context.cell.col <= end.col);
|
|
7455
7771
|
const range = expandHighlightedRange(context.selection, controller.activeSheet?.mergedRanges ?? []);
|
|
7456
7772
|
const multiple = range.start.row !== range.end.row || range.start.col !== range.end.col;
|
|
7457
|
-
const
|
|
7773
|
+
const areas = context.selectionRanges ?? [range];
|
|
7774
|
+
const multiArea = areas.length > 1;
|
|
7775
|
+
const canCopy = !multiArea || Boolean(clipboardBands(areas));
|
|
7776
|
+
const touchesPivot = areas.some((area) => findIntersectingPivot(controller.pivotTables, controller.activeSheet?.name, area));
|
|
7458
7777
|
const pivot = controller.getPivotTableAtCell(context.cell);
|
|
7778
|
+
const cutCopy = [
|
|
7779
|
+
...!controller.readOnly ? [{ id: "cut", label: messages.cut, shortcut: `${modifier}X`, disabled: !canCopy || touchesPivot }] : [],
|
|
7780
|
+
{ id: "copy", label: messages.copy, shortcut: `${modifier}C`, disabled: !canCopy }
|
|
7781
|
+
];
|
|
7782
|
+
const paste = { id: "paste", label: messages.paste, shortcut: `${modifier}V`, disabled: multiArea || touchesPivot };
|
|
7783
|
+
const clearContents = { id: "clearContents", label: messages.clearContents, destructive: true, disabled: touchesPivot };
|
|
7784
|
+
const isHeader = context.kind === "row" || context.kind === "column";
|
|
7785
|
+
const row3 = context.kind === "row";
|
|
7786
|
+
const headerActions = [
|
|
7787
|
+
...cutCopy,
|
|
7788
|
+
...!controller.readOnly ? [paste, clearContents] : [],
|
|
7789
|
+
...canResize ? [{
|
|
7790
|
+
id: row3 ? "rowHeight" : "columnWidth",
|
|
7791
|
+
label: `${row3 ? messages.rowHeight : messages.columnWidth}\u2026`,
|
|
7792
|
+
separatorBefore: true
|
|
7793
|
+
}] : [],
|
|
7794
|
+
...controller.canChangeVisibility ?? !controller.readOnly ? [
|
|
7795
|
+
{ id: row3 ? "hideRows" : "hideColumns", label: messages.hide, separatorBefore: !canResize },
|
|
7796
|
+
{ id: row3 ? "unhideRows" : "unhideColumns", label: messages.unhide }
|
|
7797
|
+
] : []
|
|
7798
|
+
];
|
|
7459
7799
|
const cellActions = [
|
|
7460
|
-
|
|
7461
|
-
{ id: "copy", label: messages.copy, shortcut: `${modifier}C` },
|
|
7800
|
+
...cutCopy,
|
|
7462
7801
|
...!controller.readOnly ? [
|
|
7463
7802
|
{ id: "undo", label: messages.undo, shortcut: `${modifier}Z`, disabled: !controller.canUndo },
|
|
7464
7803
|
{ id: "redo", label: messages.redo, shortcut: `${modifier}\u21E7Z`, disabled: !controller.canRedo },
|
|
7465
|
-
{
|
|
7804
|
+
{ ...paste, separatorBefore: true }
|
|
7466
7805
|
] : [],
|
|
7467
7806
|
...pivot ? [{ id: "togglePivotFieldList", label: controller.pivotFieldListVisible ? messages.hidePivotFieldList : messages.showPivotFieldList, checked: controller.pivotFieldListVisible }] : [],
|
|
7468
7807
|
...pivot && !controller.readOnly ? [
|
|
@@ -7470,12 +7809,12 @@ function XlsxContextMenu({
|
|
|
7470
7809
|
{ id: "showPivotDetails", label: messages.showPivotDetails, disabled: pivot.unsupportedFeatures.length > 0 }
|
|
7471
7810
|
] : [],
|
|
7472
7811
|
...!controller.readOnly ? [
|
|
7473
|
-
{ id: "editCell", label: messages.editCell, shortcut: "F2", separatorBefore: true, disabled: touchesPivot },
|
|
7474
|
-
|
|
7475
|
-
{ id: "mergeAndCenter", label: messages.mergeAndCenter, separatorBefore: true, disabled: !multiple || touchesPivot },
|
|
7476
|
-
{ id: "mergeAcross", label: messages.mergeAcross, disabled: range.start.col === range.end.col || touchesPivot },
|
|
7477
|
-
{ id: "mergeCells", label: messages.mergeCells, disabled: !multiple || touchesPivot },
|
|
7478
|
-
{ id: "unmergeCells", label: messages.unmergeCells, disabled: touchesPivot },
|
|
7812
|
+
{ id: "editCell", label: messages.editCell, shortcut: "F2", separatorBefore: true, disabled: multiArea || touchesPivot },
|
|
7813
|
+
clearContents,
|
|
7814
|
+
{ id: "mergeAndCenter", label: messages.mergeAndCenter, separatorBefore: true, disabled: multiArea || !multiple || touchesPivot },
|
|
7815
|
+
{ id: "mergeAcross", label: messages.mergeAcross, disabled: multiArea || range.start.col === range.end.col || touchesPivot },
|
|
7816
|
+
{ id: "mergeCells", label: messages.mergeCells, disabled: multiArea || !multiple || touchesPivot },
|
|
7817
|
+
{ id: "unmergeCells", label: messages.unmergeCells, disabled: multiArea || touchesPivot },
|
|
7479
7818
|
...table ? [
|
|
7480
7819
|
{ id: "sortAscending", label: messages.sortAscending, separatorBefore: true },
|
|
7481
7820
|
{ id: "sortDescending", label: messages.sortDescending }
|
|
@@ -7528,7 +7867,7 @@ function XlsxContextMenu({
|
|
|
7528
7867
|
{ id: "sendBackward", label: "Send Backward", disabled: drawingDisabled || drawing.zIndex <= minOrder }
|
|
7529
7868
|
]
|
|
7530
7869
|
}
|
|
7531
|
-
] : cellActions;
|
|
7870
|
+
] : isHeader ? headerActions : cellActions;
|
|
7532
7871
|
const findAction = (items, id) => {
|
|
7533
7872
|
for (const item of items) {
|
|
7534
7873
|
if (item.disabled) continue;
|
|
@@ -7653,6 +7992,16 @@ function XlsxContextMenu({
|
|
|
7653
7992
|
case "sortDescending":
|
|
7654
7993
|
if (table) controller.sortTable(table.name, context.cell.col - table.start.col, id === "sortAscending" ? "ascending" : "descending");
|
|
7655
7994
|
break;
|
|
7995
|
+
case "rowHeight":
|
|
7996
|
+
case "columnWidth":
|
|
7997
|
+
editSize(id === "rowHeight" ? "row" : "column");
|
|
7998
|
+
return true;
|
|
7999
|
+
case "hideRows":
|
|
8000
|
+
case "unhideRows":
|
|
8001
|
+
case "hideColumns":
|
|
8002
|
+
case "unhideColumns":
|
|
8003
|
+
controller[id]();
|
|
8004
|
+
break;
|
|
7656
8005
|
case "selectRow":
|
|
7657
8006
|
selectExtent("row");
|
|
7658
8007
|
break;
|
|
@@ -9019,7 +9368,7 @@ function createChartModule(importModule) {
|
|
|
9019
9368
|
};
|
|
9020
9369
|
}
|
|
9021
9370
|
var officeChartRenderer = createChartModule(async () => {
|
|
9022
|
-
const { SharedChartSvg } = await import("./shared-chart-
|
|
9371
|
+
const { SharedChartSvg } = await import("./shared-chart-CGEK7EAB.js");
|
|
9023
9372
|
return { renderer: null, SharedChartSvg };
|
|
9024
9373
|
});
|
|
9025
9374
|
var suppliedOfficeChartRenderer = officeChartRenderer;
|
|
@@ -9132,7 +9481,7 @@ var OPEN_GRID_HORIZONTAL_EDGE_PX = 480;
|
|
|
9132
9481
|
var SELECTION_DRAG_THRESHOLD_PX = 4;
|
|
9133
9482
|
var IMAGE_MIN_SIZE_PX = 16;
|
|
9134
9483
|
var IMAGE_HANDLE_SIZE_PX = 10;
|
|
9135
|
-
var
|
|
9484
|
+
var HEADER_RESIZE_HANDLE_PX = 8;
|
|
9136
9485
|
var RESIZE_DRAG_THRESHOLD_PX = 3;
|
|
9137
9486
|
var CANVAS_VIEWPORT_OVERSCAN_PX = 480;
|
|
9138
9487
|
var CANVAS_SCROLL_BUFFER_PX = 480;
|
|
@@ -9160,6 +9509,7 @@ var CANVAS_TEXT_MEASURE_CACHE_LIMIT = 2e4;
|
|
|
9160
9509
|
var CANVAS_TEXT_TRUNCATE_CACHE_LIMIT = 4096;
|
|
9161
9510
|
var CANVAS_TEXT_WRAP_CACHE_LIMIT = 2048;
|
|
9162
9511
|
var CANVAS_PATH2D_CACHE_LIMIT = 512;
|
|
9512
|
+
var EMPTY_SELECTION_RANGES = [];
|
|
9163
9513
|
var EMPTY_VIRTUAL_ITEMS = [];
|
|
9164
9514
|
var IMAGE_HANDLE_CURSOR = {
|
|
9165
9515
|
e: "ew-resize",
|
|
@@ -10153,23 +10503,10 @@ function buildVisibleAxisIndices(precomputed, displayLimit, maxUsedIndex, hidden
|
|
|
10153
10503
|
if (displayLimit <= 0) {
|
|
10154
10504
|
return [];
|
|
10155
10505
|
}
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
if (!hiddenIndices?.has(index)) {
|
|
10161
|
-
visible2.push(index);
|
|
10162
|
-
}
|
|
10163
|
-
}
|
|
10164
|
-
for (let index = usedLimit; index < displayLimit; index += 1) {
|
|
10165
|
-
visible2.push(index);
|
|
10166
|
-
}
|
|
10167
|
-
return visible2;
|
|
10168
|
-
}
|
|
10169
|
-
const visible = precomputed.filter((value) => value < displayLimit);
|
|
10170
|
-
const appendStart = Math.max(0, maxUsedIndex + 1);
|
|
10171
|
-
for (let index = appendStart; index < displayLimit; index += 1) {
|
|
10172
|
-
visible.push(index);
|
|
10506
|
+
const visible = precomputed.filter((index) => index < displayLimit);
|
|
10507
|
+
const appendStart = precomputed.length ? Math.max(0, maxUsedIndex + 1) : 0;
|
|
10508
|
+
for (let index = appendStart; index < displayLimit; index++) {
|
|
10509
|
+
if (!hiddenIndices?.has(index)) visible.push(index);
|
|
10173
10510
|
}
|
|
10174
10511
|
return visible;
|
|
10175
10512
|
}
|
|
@@ -14098,7 +14435,7 @@ function GridRow({
|
|
|
14098
14435
|
style: {
|
|
14099
14436
|
bottom: 0,
|
|
14100
14437
|
cursor: "row-resize",
|
|
14101
|
-
height:
|
|
14438
|
+
height: HEADER_RESIZE_HANDLE_PX,
|
|
14102
14439
|
left: 0,
|
|
14103
14440
|
position: "absolute",
|
|
14104
14441
|
width: "100%",
|
|
@@ -14546,6 +14883,8 @@ function XlsxGrid({
|
|
|
14546
14883
|
selectChartElement,
|
|
14547
14884
|
selectImage,
|
|
14548
14885
|
selectRange,
|
|
14886
|
+
selectRanges,
|
|
14887
|
+
selectionRanges,
|
|
14549
14888
|
selection,
|
|
14550
14889
|
setActiveSheetIndex,
|
|
14551
14890
|
setChartRect,
|
|
@@ -14639,8 +14978,6 @@ function XlsxGrid({
|
|
|
14639
14978
|
const activeCellRef = A(activeCell);
|
|
14640
14979
|
const selectedChartIdRef = A(selectedChartId);
|
|
14641
14980
|
const selectedImageIdRef = A(selectedImageId);
|
|
14642
|
-
const pendingSelectionCommitRef = A(null);
|
|
14643
|
-
const selectionCommitFrameRef = A(null);
|
|
14644
14981
|
const selectionRef = A(null);
|
|
14645
14982
|
const editingCellRef = A(null);
|
|
14646
14983
|
const editingOriginalValueRef = A(null);
|
|
@@ -14798,6 +15135,11 @@ function XlsxGrid({
|
|
|
14798
15135
|
[activeSheet?.mergedRanges, activeSheet?.workbookSheetIndex, highlightedRanges, mergedRegions]
|
|
14799
15136
|
);
|
|
14800
15137
|
const normalizedSelection = T(() => selection ? normalizeRange2(selection) : null, [selection]);
|
|
15138
|
+
const secondaryRanges = T(() => selectionRanges.length > 1 ? selectionRanges.slice(0, -1) : EMPTY_SELECTION_RANGES, [selectionRanges]);
|
|
15139
|
+
const selectionRangesRef = A(selectionRanges);
|
|
15140
|
+
_(() => {
|
|
15141
|
+
selectionRangesRef.current = selectionRanges;
|
|
15142
|
+
}, [selectionRanges]);
|
|
14801
15143
|
const zoomFactor = T(() => Math.max(0.1, zoomScale / 100), [zoomScale]);
|
|
14802
15144
|
const previousZoomFactorRef = A(zoomFactor);
|
|
14803
15145
|
const effectiveTables = tables;
|
|
@@ -15310,7 +15652,7 @@ function XlsxGrid({
|
|
|
15310
15652
|
);
|
|
15311
15653
|
if (worksheet) {
|
|
15312
15654
|
for (let col = 0; col < displayColLimit; col += 1) {
|
|
15313
|
-
if (
|
|
15655
|
+
if (hiddenColSet.has(col)) {
|
|
15314
15656
|
continue;
|
|
15315
15657
|
}
|
|
15316
15658
|
const width = worksheet.getColumnWidth(col);
|
|
@@ -15350,6 +15692,7 @@ function XlsxGrid({
|
|
|
15350
15692
|
);
|
|
15351
15693
|
}
|
|
15352
15694
|
for (let col = Math.max(0, (activeSheet?.maxUsedCol ?? -1) + 1); col < displayColLimit; col += 1) {
|
|
15695
|
+
if (hiddenColSet.has(col)) continue;
|
|
15353
15696
|
const overrideWidth = activeSheet?.colWidthOverridesPx[col];
|
|
15354
15697
|
widths[col] = overrideWidth === void 0 ? fallbackWidth : Math.max(resolveRenderedSheetAxisPixels(overrideWidth, showGridLines), DEFAULT_COL_WIDTH2 / 2);
|
|
15355
15698
|
}
|
|
@@ -15409,7 +15752,7 @@ function XlsxGrid({
|
|
|
15409
15752
|
estimatedHeights.set(row3, estimatedHeight);
|
|
15410
15753
|
}
|
|
15411
15754
|
for (let row3 = 0; row3 < displayRowLimit; row3 += 1) {
|
|
15412
|
-
if (
|
|
15755
|
+
if (hiddenRowSet.has(row3)) continue;
|
|
15413
15756
|
const height = worksheet.getRowHeight(row3);
|
|
15414
15757
|
if (height !== void 0 && height !== null) {
|
|
15415
15758
|
heights[row3] = Math.max(
|
|
@@ -15445,6 +15788,7 @@ function XlsxGrid({
|
|
|
15445
15788
|
);
|
|
15446
15789
|
}
|
|
15447
15790
|
for (let row3 = Math.max(0, (activeSheet?.maxUsedRow ?? -1) + 1); row3 < displayRowLimit; row3 += 1) {
|
|
15791
|
+
if (hiddenRowSet.has(row3)) continue;
|
|
15448
15792
|
const overrideHeight = activeSheet?.rowHeightOverridesPx[row3];
|
|
15449
15793
|
heights[row3] = overrideHeight === void 0 ? fallbackHeight : Math.max(resolveRenderedSheetAxisPixels(overrideHeight, showGridLines), DEFAULT_ROW_HEIGHT2 / 1.5);
|
|
15450
15794
|
}
|
|
@@ -15529,6 +15873,21 @@ function XlsxGrid({
|
|
|
15529
15873
|
const lastVisibleRow = visibleRows[visibleRows.length - 1];
|
|
15530
15874
|
const firstVisibleCol = visibleCols[0];
|
|
15531
15875
|
const lastVisibleCol = visibleCols[visibleCols.length - 1];
|
|
15876
|
+
const previousGridExtent = A({ activeTabIndex, lastVisibleRow, lastVisibleCol });
|
|
15877
|
+
_(() => {
|
|
15878
|
+
const previous = previousGridExtent.current;
|
|
15879
|
+
previousGridExtent.current = { activeTabIndex, lastVisibleRow, lastVisibleCol };
|
|
15880
|
+
if (previous.activeTabIndex !== activeTabIndex || !axisSelectionRef.current) return;
|
|
15881
|
+
const growRows = lastVisibleRow !== void 0 && previous.lastVisibleRow !== void 0 && lastVisibleRow > previous.lastVisibleRow;
|
|
15882
|
+
const growCols = lastVisibleCol !== void 0 && previous.lastVisibleCol !== void 0 && lastVisibleCol > previous.lastVisibleCol;
|
|
15883
|
+
if (!growRows && !growCols) return;
|
|
15884
|
+
const areas = selectionRanges.map((area) => {
|
|
15885
|
+
const row3 = growRows && area.start.row === firstVisibleRow && area.end.row === previous.lastVisibleRow ? lastVisibleRow : area.end.row;
|
|
15886
|
+
const col = growCols && area.start.col === firstVisibleCol && area.end.col === previous.lastVisibleCol ? lastVisibleCol : area.end.col;
|
|
15887
|
+
return row3 === area.end.row && col === area.end.col ? area : { start: area.start, end: { row: row3, col } };
|
|
15888
|
+
});
|
|
15889
|
+
if (areas.some((area, i) => area !== selectionRanges[i])) selectRanges(areas, "start");
|
|
15890
|
+
}, [activeTabIndex, firstVisibleCol, firstVisibleRow, lastVisibleCol, lastVisibleRow, selectionRanges, selectRanges]);
|
|
15532
15891
|
const displayedSelection = fillPreviewRange ?? normalizedSelection;
|
|
15533
15892
|
const toLogicalRect = q((rect) => ({
|
|
15534
15893
|
height: rect.height / zoomFactor,
|
|
@@ -15745,10 +16104,6 @@ function XlsxGrid({
|
|
|
15745
16104
|
imagePreviewRectRef.current = imagePreviewRect;
|
|
15746
16105
|
}, [imagePreviewRect]);
|
|
15747
16106
|
h(() => () => {
|
|
15748
|
-
if (selectionCommitFrameRef.current !== null) {
|
|
15749
|
-
window.cancelAnimationFrame(selectionCommitFrameRef.current);
|
|
15750
|
-
selectionCommitFrameRef.current = null;
|
|
15751
|
-
}
|
|
15752
16107
|
if (liveGestureZoomFrameRef.current !== null) {
|
|
15753
16108
|
window.cancelAnimationFrame(liveGestureZoomFrameRef.current);
|
|
15754
16109
|
liveGestureZoomFrameRef.current = null;
|
|
@@ -15901,34 +16256,38 @@ function XlsxGrid({
|
|
|
15901
16256
|
h(() => {
|
|
15902
16257
|
const selectionEndRow = normalizedSelection?.end.row ?? -1;
|
|
15903
16258
|
const selectionEndCol = normalizedSelection?.end.col ?? -1;
|
|
16259
|
+
const rowPadding = axisSelectionRef.current?.axis === "column" ? 0 : OPEN_GRID_ROW_PADDING;
|
|
16260
|
+
const colPadding = axisSelectionRef.current?.axis === "row" ? 0 : OPEN_GRID_COL_PADDING;
|
|
15904
16261
|
const nextRowLimit = Math.max(
|
|
15905
16262
|
resolveInitialDisplayExtent(
|
|
15906
16263
|
activeSheet?.maxUsedRow ?? -1,
|
|
15907
|
-
MIN_OPEN_GRID_ROWS,
|
|
16264
|
+
minimumVisibleExtent(MIN_OPEN_GRID_ROWS, activeSheet?.hiddenRows, XLSX_MAX_ROWS),
|
|
15908
16265
|
OPEN_GRID_ROW_PADDING,
|
|
15909
16266
|
false,
|
|
15910
16267
|
INITIAL_WORKER_GRID_ROWS
|
|
15911
16268
|
),
|
|
15912
|
-
(activeCell?.row ?? -1) +
|
|
15913
|
-
selectionEndRow +
|
|
16269
|
+
(activeCell?.row ?? -1) + rowPadding + 1,
|
|
16270
|
+
selectionEndRow + rowPadding + 1,
|
|
15914
16271
|
drawingExtents.maxRow + OPEN_GRID_ROW_PADDING + 1
|
|
15915
16272
|
);
|
|
15916
16273
|
const nextColLimit = Math.max(
|
|
15917
16274
|
resolveInitialDisplayExtent(
|
|
15918
16275
|
activeSheet?.maxUsedCol ?? -1,
|
|
15919
|
-
MIN_OPEN_GRID_COLS,
|
|
16276
|
+
minimumVisibleExtent(MIN_OPEN_GRID_COLS, activeSheet?.hiddenCols, XLSX_MAX_COLUMNS),
|
|
15920
16277
|
OPEN_GRID_COL_PADDING,
|
|
15921
16278
|
false,
|
|
15922
16279
|
INITIAL_WORKER_GRID_COLS
|
|
15923
16280
|
),
|
|
15924
|
-
(activeCell?.col ?? -1) +
|
|
15925
|
-
selectionEndCol +
|
|
16281
|
+
(activeCell?.col ?? -1) + colPadding + 1,
|
|
16282
|
+
selectionEndCol + colPadding + 1,
|
|
15926
16283
|
drawingExtents.maxCol + OPEN_GRID_COL_PADDING + 1
|
|
15927
16284
|
);
|
|
15928
16285
|
setDisplayRowLimit((current) => current < nextRowLimit ? nextRowLimit : current);
|
|
15929
16286
|
setDisplayColLimit((current) => current < nextColLimit ? nextColLimit : current);
|
|
15930
16287
|
}, [
|
|
15931
16288
|
activeCell,
|
|
16289
|
+
activeSheet?.hiddenRows,
|
|
16290
|
+
activeSheet?.hiddenCols,
|
|
15932
16291
|
activeSheet?.maxUsedCol,
|
|
15933
16292
|
activeSheet?.maxUsedRow,
|
|
15934
16293
|
drawingExtents.maxCol,
|
|
@@ -16656,7 +17015,6 @@ function XlsxGrid({
|
|
|
16656
17015
|
commitEditingRef.current = commitEditing;
|
|
16657
17016
|
}, [commitEditing]);
|
|
16658
17017
|
const [, startBatchTransition] = k();
|
|
16659
|
-
const [, startSelectionTransition] = k();
|
|
16660
17018
|
const [asyncViewportRowBatch, setAsyncViewportRowBatch] = d(null);
|
|
16661
17019
|
const viewportRequest = T(() => {
|
|
16662
17020
|
const rowIndices = experimentalCanvas ? (() => {
|
|
@@ -17124,26 +17482,22 @@ function XlsxGrid({
|
|
|
17124
17482
|
h(() => {
|
|
17125
17483
|
conditionalFormatMetricsCacheRef.current.clear();
|
|
17126
17484
|
}, [activeSheet?.conditionalFormatRules, activeSheet?.workbookSheetIndex, revision]);
|
|
17127
|
-
const
|
|
17128
|
-
if (!
|
|
17129
|
-
return null;
|
|
17130
|
-
}
|
|
17131
|
-
const normalized = normalizeRange2(displayedSelection);
|
|
17132
|
-
const startRowIndex = rowIndexByActual.get(normalized.start.row);
|
|
17133
|
-
const endRowIndex = rowIndexByActual.get(normalized.end.row);
|
|
17134
|
-
const startColIndex = colIndexByActual.get(normalized.start.col);
|
|
17135
|
-
const endColIndex = colIndexByActual.get(normalized.end.col);
|
|
17136
|
-
if (startRowIndex === void 0 || endRowIndex === void 0 || startColIndex === void 0 || endColIndex === void 0) {
|
|
17485
|
+
const getSelectionOverlay = q((range) => {
|
|
17486
|
+
if (!range) {
|
|
17137
17487
|
return null;
|
|
17138
17488
|
}
|
|
17489
|
+
const rows = getHighlightAxisExtent(visibleRows, rowPrefixSums, range.start.row, range.end.row);
|
|
17490
|
+
const cols = getHighlightAxisExtent(visibleCols, colPrefixSums, range.start.col, range.end.col);
|
|
17491
|
+
if (!rows || !cols) return null;
|
|
17139
17492
|
return {
|
|
17140
|
-
height:
|
|
17141
|
-
left: displayRowHeaderWidth +
|
|
17142
|
-
top: displayHeaderHeight +
|
|
17143
|
-
width:
|
|
17493
|
+
height: rows.end - rows.start,
|
|
17494
|
+
left: displayRowHeaderWidth + cols.start,
|
|
17495
|
+
top: displayHeaderHeight + rows.start,
|
|
17496
|
+
width: cols.end - cols.start
|
|
17144
17497
|
};
|
|
17145
|
-
}, [
|
|
17146
|
-
const resolvedSelectionOverlay =
|
|
17498
|
+
}, [colPrefixSums, displayHeaderHeight, displayRowHeaderWidth, rowPrefixSums, visibleRows, visibleCols]);
|
|
17499
|
+
const resolvedSelectionOverlay = T(() => getSelectionOverlay(displayedSelection), [displayedSelection, getSelectionOverlay]);
|
|
17500
|
+
const secondaryOverlays = T(() => secondaryRanges.map(getSelectionOverlay), [secondaryRanges, getSelectionOverlay]);
|
|
17147
17501
|
const rangeHighlightRects = T(() => highlightedCellRanges.map(({ highlight, index, range }) => {
|
|
17148
17502
|
const rows = getHighlightAxisExtent(visibleRows, rowPrefixSums, range.start.row, range.end.row);
|
|
17149
17503
|
const cols = getHighlightAxisExtent(visibleCols, colPrefixSums, range.start.col, range.end.col);
|
|
@@ -17741,18 +18095,19 @@ function XlsxGrid({
|
|
|
17741
18095
|
observer.observe(scroller);
|
|
17742
18096
|
return () => observer.disconnect();
|
|
17743
18097
|
}, [contextMenuClassName, contextMenuStyle, displayRowHeaderWidth, openTableMenuState, renderTableHeaderMenu, zoomFactor]);
|
|
18098
|
+
const headerIsSelected = q((axis, index, active) => Boolean(active && index >= active.start[axis] && index <= active.end[axis]) || secondaryRanges.some((area) => index >= area.start[axis] && index <= area.end[axis]), [secondaryRanges]);
|
|
17744
18099
|
const applyHeaderSelection = q((range) => {
|
|
17745
18100
|
if (experimentalCanvas) {
|
|
17746
18101
|
return;
|
|
17747
18102
|
}
|
|
17748
18103
|
const normalized = range ? normalizeRange2(range) : null;
|
|
17749
18104
|
rowHeaderCellRefs.current.forEach((element, actualRow) => {
|
|
17750
|
-
element.style.backgroundColor =
|
|
18105
|
+
element.style.backgroundColor = headerIsSelected("row", actualRow, normalized) ? "var(--xlsx-selection-header)" : palette.rowHeaderSurface;
|
|
17751
18106
|
});
|
|
17752
18107
|
colHeaderCellRefs.current.forEach((element, actualCol) => {
|
|
17753
|
-
element.style.backgroundColor =
|
|
18108
|
+
element.style.backgroundColor = headerIsSelected("col", actualCol, normalized) ? "var(--xlsx-selection-header)" : palette.headerSurface;
|
|
17754
18109
|
});
|
|
17755
|
-
}, [experimentalCanvas, palette.headerSurface, palette.rowHeaderSurface]);
|
|
18110
|
+
}, [experimentalCanvas, headerIsSelected, palette.headerSurface, palette.rowHeaderSurface]);
|
|
17756
18111
|
const setRowHeaderRef = q((actualRow, element) => {
|
|
17757
18112
|
if (experimentalCanvas) {
|
|
17758
18113
|
rowHeaderCellRefs.current.delete(actualRow);
|
|
@@ -17761,11 +18116,11 @@ function XlsxGrid({
|
|
|
17761
18116
|
if (element) {
|
|
17762
18117
|
rowHeaderCellRefs.current.set(actualRow, element);
|
|
17763
18118
|
const range = selectionPreviewRangeRef.current ?? displayedSelectionRef.current;
|
|
17764
|
-
element.style.backgroundColor =
|
|
18119
|
+
element.style.backgroundColor = headerIsSelected("row", actualRow, range) ? "var(--xlsx-selection-header)" : palette.rowHeaderSurface;
|
|
17765
18120
|
return;
|
|
17766
18121
|
}
|
|
17767
18122
|
rowHeaderCellRefs.current.delete(actualRow);
|
|
17768
|
-
}, [experimentalCanvas, palette.rowHeaderSurface]);
|
|
18123
|
+
}, [experimentalCanvas, headerIsSelected, palette.rowHeaderSurface]);
|
|
17769
18124
|
const setColHeaderRef = q((actualCol, element) => {
|
|
17770
18125
|
if (experimentalCanvas) {
|
|
17771
18126
|
colHeaderCellRefs.current.delete(actualCol);
|
|
@@ -17774,11 +18129,11 @@ function XlsxGrid({
|
|
|
17774
18129
|
if (element) {
|
|
17775
18130
|
colHeaderCellRefs.current.set(actualCol, element);
|
|
17776
18131
|
const range = selectionPreviewRangeRef.current ?? displayedSelectionRef.current;
|
|
17777
|
-
element.style.backgroundColor =
|
|
18132
|
+
element.style.backgroundColor = headerIsSelected("col", actualCol, range) ? "var(--xlsx-selection-header)" : palette.headerSurface;
|
|
17778
18133
|
return;
|
|
17779
18134
|
}
|
|
17780
18135
|
colHeaderCellRefs.current.delete(actualCol);
|
|
17781
|
-
}, [experimentalCanvas, palette.headerSurface]);
|
|
18136
|
+
}, [experimentalCanvas, headerIsSelected, palette.headerSurface]);
|
|
17782
18137
|
const applyPreviewOverlay = q((range, options2) => {
|
|
17783
18138
|
const overlays = experimentalCanvas ? [...selectionPaneOverlayRefs.current.values()] : [selectionOverlayRef.current];
|
|
17784
18139
|
if (!range) {
|
|
@@ -17867,28 +18222,12 @@ function XlsxGrid({
|
|
|
17867
18222
|
const commitSelectionRange = q((range) => {
|
|
17868
18223
|
gridKeyboardActiveRef.current = true;
|
|
17869
18224
|
const normalized = normalizeRange2(range);
|
|
17870
|
-
if (selectionRef.current && rangesEqual(selectionRef.current, normalized) && isSameCell(activeCellRef.current, normalized.end) && selectedChartIdRef.current === null && selectedImageIdRef.current === null) {
|
|
17871
|
-
return;
|
|
17872
|
-
}
|
|
17873
|
-
pendingSelectionCommitRef.current = normalized;
|
|
17874
|
-
if (selectionCommitFrameRef.current !== null) {
|
|
18225
|
+
if (selectionRangesRef.current.length === 1 && selectionRef.current && rangesEqual(selectionRef.current, normalized) && isSameCell(activeCellRef.current, normalized.end) && selectedChartIdRef.current === null && selectedImageIdRef.current === null) {
|
|
17875
18226
|
return;
|
|
17876
18227
|
}
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
17880
|
-
pendingSelectionCommitRef.current = null;
|
|
17881
|
-
if (!pendingRange) {
|
|
17882
|
-
return;
|
|
17883
|
-
}
|
|
17884
|
-
if (selectionRef.current && rangesEqual(selectionRef.current, pendingRange) && isSameCell(activeCellRef.current, pendingRange.end) && selectedChartIdRef.current === null && selectedImageIdRef.current === null) {
|
|
17885
|
-
return;
|
|
17886
|
-
}
|
|
17887
|
-
startSelectionTransition(() => {
|
|
17888
|
-
selectRange(pendingRange);
|
|
17889
|
-
});
|
|
17890
|
-
});
|
|
17891
|
-
}, [selectRange, startSelectionTransition]);
|
|
18228
|
+
selectionRangesRef.current = [normalized];
|
|
18229
|
+
selectRange(normalized);
|
|
18230
|
+
}, [selectRange]);
|
|
17892
18231
|
const refreshOverlayFromCurrentSelection = q(() => {
|
|
17893
18232
|
if (displayedSelectionRef.current) {
|
|
17894
18233
|
applyPreviewOverlay(displayedSelectionRef.current);
|
|
@@ -18012,6 +18351,27 @@ function XlsxGrid({
|
|
|
18012
18351
|
}
|
|
18013
18352
|
return resolveCellSelectionRange({ start: dragState.anchor, end: cell });
|
|
18014
18353
|
}
|
|
18354
|
+
function commitHeaderSelection(gesture, range, axis) {
|
|
18355
|
+
const areas = gesture.remove ? gesture.base.flatMap((area) => subtractRange(area, range)) : [...gesture.base, range];
|
|
18356
|
+
const active = areas.at(-1);
|
|
18357
|
+
axisSelectionRef.current = null;
|
|
18358
|
+
if (active) {
|
|
18359
|
+
const isFullRow = active.start.col === firstVisibleCol && active.end.col === lastVisibleCol;
|
|
18360
|
+
const isFullColumn = active.start.row === firstVisibleRow && active.end.row === lastVisibleRow;
|
|
18361
|
+
if (isFullRow && (axis === "row" || !isFullColumn)) {
|
|
18362
|
+
const startRow = gesture.remove ? active.start.row : gesture.anchor;
|
|
18363
|
+
axisSelectionRef.current = { axis: "row", startRow, endRow: startRow === active.start.row ? active.end.row : active.start.row };
|
|
18364
|
+
} else if (isFullColumn) {
|
|
18365
|
+
const startCol = gesture.remove ? active.start.col : gesture.anchor;
|
|
18366
|
+
axisSelectionRef.current = { axis: "column", startCol, endCol: startCol === active.start.col ? active.end.col : active.start.col };
|
|
18367
|
+
}
|
|
18368
|
+
}
|
|
18369
|
+
selectionPreviewRangeRef.current = null;
|
|
18370
|
+
displayedSelectionRef.current = active ?? null;
|
|
18371
|
+
selectionRangesRef.current = areas;
|
|
18372
|
+
gridKeyboardActiveRef.current = true;
|
|
18373
|
+
selectRanges(areas, "start");
|
|
18374
|
+
}
|
|
18015
18375
|
function updateSelectionDragPreview(clientX, clientY) {
|
|
18016
18376
|
const dragState = selectionDragRef.current;
|
|
18017
18377
|
if (!dragState) {
|
|
@@ -18026,6 +18386,10 @@ function XlsxGrid({
|
|
|
18026
18386
|
return;
|
|
18027
18387
|
}
|
|
18028
18388
|
dragState.previewRange = nextRange;
|
|
18389
|
+
if (dragState.headerGesture && dragState.axis !== "cell") {
|
|
18390
|
+
commitHeaderSelection(dragState.headerGesture, nextRange, dragState.axis);
|
|
18391
|
+
return;
|
|
18392
|
+
}
|
|
18029
18393
|
selectionPreviewRangeRef.current = nextRange;
|
|
18030
18394
|
displayedSelectionRef.current = nextRange;
|
|
18031
18395
|
applyPreviewOverlay(nextRange);
|
|
@@ -18052,8 +18416,10 @@ function XlsxGrid({
|
|
|
18052
18416
|
cachedScrollerRectRef.current = scrollRef.current?.getBoundingClientRect() ?? null;
|
|
18053
18417
|
pendingState.didDrag = true;
|
|
18054
18418
|
selectionDragRef.current = pendingState;
|
|
18055
|
-
|
|
18056
|
-
|
|
18419
|
+
if (!pendingState.headerGesture) {
|
|
18420
|
+
selectionPreviewRangeRef.current = pendingState.previewRange;
|
|
18421
|
+
displayedSelectionRef.current = pendingState.previewRange;
|
|
18422
|
+
}
|
|
18057
18423
|
setInteractionMode("select");
|
|
18058
18424
|
document.body.style.userSelect = "none";
|
|
18059
18425
|
installSelectionDragListeners(pendingState.pointerId);
|
|
@@ -18159,26 +18525,14 @@ function XlsxGrid({
|
|
|
18159
18525
|
}
|
|
18160
18526
|
selectionDragRef.current = null;
|
|
18161
18527
|
cachedScrollerRectRef.current = null;
|
|
18162
|
-
if (nextRange &&
|
|
18528
|
+
if (nextRange && dragState?.headerGesture && dragState.axis !== "cell") {
|
|
18529
|
+
if (!rangesEqual(nextRange, dragState.previewRange)) {
|
|
18530
|
+
commitHeaderSelection(dragState.headerGesture, nextRange, dragState.axis);
|
|
18531
|
+
}
|
|
18532
|
+
} else if (nextRange && (dragState?.didDrag || !dragState?.committedOnPointerDown)) {
|
|
18163
18533
|
selectionPreviewRangeRef.current = nextRange;
|
|
18164
18534
|
displayedSelectionRef.current = nextRange;
|
|
18165
|
-
|
|
18166
|
-
const normalized = normalizeRange2(nextRange);
|
|
18167
|
-
axisSelectionRef.current = {
|
|
18168
|
-
axis: "column",
|
|
18169
|
-
startCol: normalized.start.col,
|
|
18170
|
-
endCol: normalized.end.col
|
|
18171
|
-
};
|
|
18172
|
-
} else if (dragState?.axis === "row") {
|
|
18173
|
-
const normalized = normalizeRange2(nextRange);
|
|
18174
|
-
axisSelectionRef.current = {
|
|
18175
|
-
axis: "row",
|
|
18176
|
-
startRow: normalized.start.row,
|
|
18177
|
-
endRow: normalized.end.row
|
|
18178
|
-
};
|
|
18179
|
-
} else {
|
|
18180
|
-
axisSelectionRef.current = null;
|
|
18181
|
-
}
|
|
18535
|
+
axisSelectionRef.current = null;
|
|
18182
18536
|
commitSelectionRange(nextRange);
|
|
18183
18537
|
} else if (!nextRange) {
|
|
18184
18538
|
selectionPreviewRangeRef.current = null;
|
|
@@ -18303,26 +18657,28 @@ function XlsxGrid({
|
|
|
18303
18657
|
function selectContextExtent(kind, range) {
|
|
18304
18658
|
const nextRange = getContextExtent(kind, range);
|
|
18305
18659
|
axisSelectionRef.current = kind === "row" ? { axis: "row", startRow: nextRange.start.row, endRow: nextRange.end.row } : kind === "column" ? { axis: "column", startCol: nextRange.start.col, endCol: nextRange.end.col } : null;
|
|
18306
|
-
|
|
18660
|
+
selectRanges([nextRange], "start");
|
|
18307
18661
|
}
|
|
18308
18662
|
function openContextMenu(cell, kind, position) {
|
|
18309
18663
|
if (!enableContextMenu || !activeSheet) return;
|
|
18310
18664
|
if (kind === "cell") cell = resolveMergeAnchorCell(cell);
|
|
18311
18665
|
if (editingCellRef.current) commitEditingRef.current();
|
|
18312
18666
|
const current = normalizedSelection;
|
|
18313
|
-
const inside =
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18667
|
+
const inside = selectionRanges.some((area) => isCellInRange(cell, area));
|
|
18668
|
+
const target = { start: cell, end: cell };
|
|
18669
|
+
const extent = kind === "cell" ? target : getContextExtent(kind, target);
|
|
18670
|
+
const preserve = kind === "cell" ? inside : selectionCoversRange(selectionRanges, extent);
|
|
18671
|
+
let range = preserve && current ? current : target;
|
|
18672
|
+
if (kind !== "cell" && !preserve) {
|
|
18673
|
+
range = extent;
|
|
18318
18674
|
selectContextExtent(kind, range);
|
|
18319
|
-
} else if (!
|
|
18675
|
+
} else if (!preserve) {
|
|
18320
18676
|
axisSelectionRef.current = null;
|
|
18321
18677
|
selectCell(cell);
|
|
18322
18678
|
}
|
|
18323
18679
|
setOpenTableMenu(null);
|
|
18324
18680
|
setContextMenu({
|
|
18325
|
-
context: { kind, cell, selection: range, sheetIndex: activeSheetIndex, sheetName: activeSheet.name, readOnly },
|
|
18681
|
+
context: { kind, cell, selection: range, selectionRanges: preserve ? selectionRanges : [range], sheetIndex: activeSheetIndex, sheetName: activeSheet.name, readOnly },
|
|
18326
18682
|
position
|
|
18327
18683
|
});
|
|
18328
18684
|
}
|
|
@@ -18409,70 +18765,64 @@ function XlsxGrid({
|
|
|
18409
18765
|
resolveMergeAnchorCell,
|
|
18410
18766
|
resolvePointerCellFromGeometry
|
|
18411
18767
|
]);
|
|
18412
|
-
|
|
18413
|
-
|
|
18414
|
-
|
|
18415
|
-
|
|
18768
|
+
function startHeaderSelection(event, axis, index, pointerOrigin) {
|
|
18769
|
+
const first = axis === "row" ? firstVisibleCol : firstVisibleRow;
|
|
18770
|
+
const last = axis === "row" ? lastVisibleCol : lastVisibleRow;
|
|
18771
|
+
if (!pointerOrigin || first === void 0 || last === void 0) return;
|
|
18772
|
+
if (event.ctrlKey && /Mac|iPad|iPhone/.test(navigator.platform)) return;
|
|
18416
18773
|
event.preventDefault();
|
|
18417
18774
|
focusGrid();
|
|
18418
|
-
|
|
18419
|
-
const
|
|
18420
|
-
const
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
|
|
18775
|
+
if (editingCellRef.current) commitEditingRef.current();
|
|
18776
|
+
const areas = selectionRangesRef.current;
|
|
18777
|
+
const coordinate = axis === "row" ? "row" : "col";
|
|
18778
|
+
const activeAxis = axisSelectionRef.current;
|
|
18779
|
+
const active = areas.at(-1);
|
|
18780
|
+
let anchorIndex = index;
|
|
18781
|
+
if (event.shiftKey && active) {
|
|
18782
|
+
anchorIndex = active.start[coordinate];
|
|
18783
|
+
if (activeAxis?.axis === "row" && axis === "row") anchorIndex = activeAxis.startRow;
|
|
18784
|
+
if (activeAxis?.axis === "column" && axis === "column") anchorIndex = activeAxis.startCol;
|
|
18785
|
+
}
|
|
18786
|
+
const cell = (along, across) => axis === "row" ? { row: along, col: across } : { row: across, col: along };
|
|
18787
|
+
const range = normalizeRange2({ start: cell(anchorIndex, first), end: cell(index, last) });
|
|
18788
|
+
const additive = event.metaKey || event.ctrlKey;
|
|
18789
|
+
const base = additive ? areas : event.shiftKey ? areas.slice(0, -1) : [];
|
|
18790
|
+
const headerGesture = { anchor: anchorIndex, base, remove: additive && !event.shiftKey && selectionCoversRange(base, range) };
|
|
18428
18791
|
startCellSelection(
|
|
18429
18792
|
event.currentTarget,
|
|
18430
18793
|
event.pointerId,
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
18794
|
+
cell(anchorIndex, first),
|
|
18795
|
+
axis,
|
|
18796
|
+
cell(index, first),
|
|
18434
18797
|
pointerOrigin,
|
|
18435
18798
|
null,
|
|
18436
18799
|
true,
|
|
18437
|
-
|
|
18800
|
+
range,
|
|
18438
18801
|
event.clientX,
|
|
18439
|
-
event.clientY
|
|
18802
|
+
event.clientY,
|
|
18803
|
+
headerGesture
|
|
18440
18804
|
);
|
|
18441
|
-
|
|
18442
|
-
|
|
18443
|
-
|
|
18444
|
-
const
|
|
18445
|
-
if (event.button !== 0
|
|
18446
|
-
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18451
|
-
|
|
18452
|
-
|
|
18453
|
-
|
|
18454
|
-
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
if (!pointerOrigin) {
|
|
18458
|
-
return;
|
|
18459
|
-
}
|
|
18460
|
-
startCellSelection(
|
|
18461
|
-
event.currentTarget,
|
|
18462
|
-
event.pointerId,
|
|
18463
|
-
{ row: firstVisibleRow, col: anchorCol },
|
|
18805
|
+
}
|
|
18806
|
+
const startHeaderSelectionRef = A(startHeaderSelection);
|
|
18807
|
+
startHeaderSelectionRef.current = startHeaderSelection;
|
|
18808
|
+
const handleRowPointerDown = q((event, actualRow) => {
|
|
18809
|
+
if (event.button !== 0) return;
|
|
18810
|
+
startHeaderSelectionRef.current(
|
|
18811
|
+
event,
|
|
18812
|
+
"row",
|
|
18813
|
+
actualRow,
|
|
18814
|
+
resolveRowPointerOrigin(actualRow, event.currentTarget.getBoundingClientRect(), event.clientY)
|
|
18815
|
+
);
|
|
18816
|
+
}, [resolveRowPointerOrigin]);
|
|
18817
|
+
const handleColumnPointerDown = (event, actualCol) => {
|
|
18818
|
+
if (event.button !== 0) return;
|
|
18819
|
+
startHeaderSelection(
|
|
18820
|
+
event,
|
|
18464
18821
|
"column",
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
null,
|
|
18468
|
-
true,
|
|
18469
|
-
initialRange,
|
|
18470
|
-
event.clientX,
|
|
18471
|
-
event.clientY
|
|
18822
|
+
actualCol,
|
|
18823
|
+
resolveColumnPointerOrigin(actualCol, event.currentTarget.getBoundingClientRect(), event.clientX)
|
|
18472
18824
|
);
|
|
18473
|
-
|
|
18474
|
-
commitSelectionRange(initialRange);
|
|
18475
|
-
}, [commitSelectionRange, firstVisibleRow, focusGrid, lastVisibleRow, resolveColumnPointerOrigin]);
|
|
18825
|
+
};
|
|
18476
18826
|
const handleRowResizePointerDown = q((event, actualRow, rowHeight) => {
|
|
18477
18827
|
if (!canResizeHeaders) {
|
|
18478
18828
|
return;
|
|
@@ -18804,7 +19154,7 @@ function XlsxGrid({
|
|
|
18804
19154
|
}
|
|
18805
19155
|
const localX = clientX - scrollerRect.left;
|
|
18806
19156
|
for (const column of canvasColumnHeaderCells) {
|
|
18807
|
-
if (Math.abs(localX - (column.left + column.width)) <=
|
|
19157
|
+
if (Math.abs(localX - (column.left + column.width)) <= HEADER_RESIZE_HANDLE_PX / 2) {
|
|
18808
19158
|
return { actualCol: column.actualCol, width: column.width };
|
|
18809
19159
|
}
|
|
18810
19160
|
}
|
|
@@ -18841,7 +19191,7 @@ function XlsxGrid({
|
|
|
18841
19191
|
}
|
|
18842
19192
|
const localY = clientY - scrollerRect.top;
|
|
18843
19193
|
for (const row3 of canvasRowHeaderCells) {
|
|
18844
|
-
if (Math.abs(localY - (row3.top + row3.height)) <=
|
|
19194
|
+
if (Math.abs(localY - (row3.top + row3.height)) <= HEADER_RESIZE_HANDLE_PX / 2) {
|
|
18845
19195
|
return { actualRow: row3.actualRow, height: row3.height };
|
|
18846
19196
|
}
|
|
18847
19197
|
}
|
|
@@ -18996,7 +19346,7 @@ function XlsxGrid({
|
|
|
18996
19346
|
}
|
|
18997
19347
|
startEditing(cell, void 0, "double-click");
|
|
18998
19348
|
}, [readOnly, resolvePointerCellFromClient, startEditing]);
|
|
18999
|
-
const handleCanvasColumnHeaderPointerDown =
|
|
19349
|
+
const handleCanvasColumnHeaderPointerDown = (event) => {
|
|
19000
19350
|
if (event.button !== 0 || firstVisibleRow === void 0 || lastVisibleRow === void 0) {
|
|
19001
19351
|
return;
|
|
19002
19352
|
}
|
|
@@ -19011,51 +19361,16 @@ function XlsxGrid({
|
|
|
19011
19361
|
if (actualCol === null) {
|
|
19012
19362
|
return;
|
|
19013
19363
|
}
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19364
|
+
const index = colIndexByActual.get(actualCol);
|
|
19365
|
+
if (index === void 0) return;
|
|
19366
|
+
startHeaderSelection(event, "column", actualCol, {
|
|
19367
|
+
contentScaleX: 1,
|
|
19368
|
+
contentScaleY: 1,
|
|
19369
|
+
originContentX: colPrefixSums[index] ?? 0,
|
|
19370
|
+
originContentY: rowPrefixSums[0] ?? 0
|
|
19021
19371
|
});
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
return;
|
|
19025
|
-
}
|
|
19026
|
-
startCellSelection(
|
|
19027
|
-
event.currentTarget,
|
|
19028
|
-
event.pointerId,
|
|
19029
|
-
{ row: firstVisibleRow, col: anchorCol },
|
|
19030
|
-
"column",
|
|
19031
|
-
{ row: firstVisibleRow, col: actualCol },
|
|
19032
|
-
{
|
|
19033
|
-
contentScaleX: 1,
|
|
19034
|
-
contentScaleY: 1,
|
|
19035
|
-
originContentX: colPrefixSums[anchorColIndex] ?? 0,
|
|
19036
|
-
originContentY: rowPrefixSums[0] ?? 0
|
|
19037
|
-
},
|
|
19038
|
-
null,
|
|
19039
|
-
true,
|
|
19040
|
-
initialRange,
|
|
19041
|
-
event.clientX,
|
|
19042
|
-
event.clientY
|
|
19043
|
-
);
|
|
19044
|
-
axisSelectionRef.current = { axis: "column", startCol: anchorCol, endCol: actualCol };
|
|
19045
|
-
commitSelectionRange(initialRange);
|
|
19046
|
-
}, [
|
|
19047
|
-
colIndexByActual,
|
|
19048
|
-
colPrefixSums,
|
|
19049
|
-
commitSelectionRange,
|
|
19050
|
-
firstVisibleRow,
|
|
19051
|
-
focusGrid,
|
|
19052
|
-
lastVisibleRow,
|
|
19053
|
-
resolveCanvasColumnHeaderTarget,
|
|
19054
|
-
resolveCanvasColumnResizeTarget,
|
|
19055
|
-
rowPrefixSums,
|
|
19056
|
-
startCellSelection
|
|
19057
|
-
]);
|
|
19058
|
-
const handleCanvasRowHeaderPointerDown = q((event) => {
|
|
19372
|
+
};
|
|
19373
|
+
const handleCanvasRowHeaderPointerDown = (event) => {
|
|
19059
19374
|
if (event.button !== 0 || firstVisibleCol === void 0 || lastVisibleCol === void 0) {
|
|
19060
19375
|
return;
|
|
19061
19376
|
}
|
|
@@ -19070,50 +19385,15 @@ function XlsxGrid({
|
|
|
19070
19385
|
if (actualRow === null) {
|
|
19071
19386
|
return;
|
|
19072
19387
|
}
|
|
19073
|
-
|
|
19074
|
-
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
|
|
19078
|
-
|
|
19079
|
-
|
|
19388
|
+
const index = rowIndexByActual.get(actualRow);
|
|
19389
|
+
if (index === void 0) return;
|
|
19390
|
+
startHeaderSelection(event, "row", actualRow, {
|
|
19391
|
+
contentScaleX: 1,
|
|
19392
|
+
contentScaleY: 1,
|
|
19393
|
+
originContentX: colPrefixSums[0] ?? 0,
|
|
19394
|
+
originContentY: rowPrefixSums[index] ?? 0
|
|
19080
19395
|
});
|
|
19081
|
-
|
|
19082
|
-
if (anchorRowIndex === void 0) {
|
|
19083
|
-
return;
|
|
19084
|
-
}
|
|
19085
|
-
startCellSelection(
|
|
19086
|
-
event.currentTarget,
|
|
19087
|
-
event.pointerId,
|
|
19088
|
-
{ row: anchorRow, col: firstVisibleCol },
|
|
19089
|
-
"row",
|
|
19090
|
-
{ row: actualRow, col: firstVisibleCol },
|
|
19091
|
-
{
|
|
19092
|
-
contentScaleX: 1,
|
|
19093
|
-
contentScaleY: 1,
|
|
19094
|
-
originContentX: colPrefixSums[0] ?? 0,
|
|
19095
|
-
originContentY: rowPrefixSums[anchorRowIndex] ?? 0
|
|
19096
|
-
},
|
|
19097
|
-
null,
|
|
19098
|
-
true,
|
|
19099
|
-
initialRange,
|
|
19100
|
-
event.clientX,
|
|
19101
|
-
event.clientY
|
|
19102
|
-
);
|
|
19103
|
-
axisSelectionRef.current = { axis: "row", startRow: anchorRow, endRow: actualRow };
|
|
19104
|
-
commitSelectionRange(initialRange);
|
|
19105
|
-
}, [
|
|
19106
|
-
colPrefixSums,
|
|
19107
|
-
commitSelectionRange,
|
|
19108
|
-
firstVisibleCol,
|
|
19109
|
-
focusGrid,
|
|
19110
|
-
lastVisibleCol,
|
|
19111
|
-
resolveCanvasRowHeaderTarget,
|
|
19112
|
-
resolveCanvasRowResizeTarget,
|
|
19113
|
-
rowIndexByActual,
|
|
19114
|
-
rowPrefixSums,
|
|
19115
|
-
startCellSelection
|
|
19116
|
-
]);
|
|
19396
|
+
};
|
|
19117
19397
|
const getCanvasImage = q((image) => {
|
|
19118
19398
|
if (typeof Image === "undefined") {
|
|
19119
19399
|
return null;
|
|
@@ -19189,7 +19469,7 @@ function XlsxGrid({
|
|
|
19189
19469
|
const rowHeaderWidth = Math.min(displayRowHeaderWidth, bodyWidth);
|
|
19190
19470
|
const visibleRange = selectionPreviewRangeRef.current ?? displayedSelection;
|
|
19191
19471
|
const normalizedVisibleRange = visibleRange ? normalizeRange2(visibleRange) : null;
|
|
19192
|
-
const rangeSignature = buildRangeSignature(
|
|
19472
|
+
const rangeSignature = [...secondaryRanges, normalizedVisibleRange].map(buildRangeSignature).join("|");
|
|
19193
19473
|
const nextBodyCanvasSignature = {
|
|
19194
19474
|
activeSheet: activeSheet ?? null,
|
|
19195
19475
|
bakedDrawingSignature: bakedCanvasDrawingSignature,
|
|
@@ -20100,7 +20380,7 @@ function XlsxGrid({
|
|
|
20100
20380
|
if (!column.isFrozen && !intersectsCanvasDirtyRects(column.localLeft, 0, column.width, column.height, topScrollHeaderDirtyRects)) {
|
|
20101
20381
|
continue;
|
|
20102
20382
|
}
|
|
20103
|
-
const selected =
|
|
20383
|
+
const selected = headerIsSelected("col", column.actualCol, normalizedVisibleRange);
|
|
20104
20384
|
paneContext.fillStyle = selected ? selectionHeaderSurface : palette.headerSurface;
|
|
20105
20385
|
paneContext.fillRect(column.localLeft, 0, column.width, column.height);
|
|
20106
20386
|
paneContext.strokeStyle = palette.border;
|
|
@@ -20149,7 +20429,7 @@ function XlsxGrid({
|
|
|
20149
20429
|
if (!row3.isFrozen && !intersectsCanvasDirtyRects(0, row3.localTop, rowHeaderWidth, row3.height, leftScrollHeaderDirtyRects)) {
|
|
20150
20430
|
continue;
|
|
20151
20431
|
}
|
|
20152
|
-
const selected =
|
|
20432
|
+
const selected = headerIsSelected("row", row3.actualRow, normalizedVisibleRange);
|
|
20153
20433
|
paneContext.fillStyle = selected ? selectionHeaderSurface : palette.rowHeaderSurface;
|
|
20154
20434
|
paneContext.fillRect(0, row3.localTop, rowHeaderWidth, row3.height);
|
|
20155
20435
|
paneContext.beginPath();
|
|
@@ -20239,6 +20519,8 @@ function XlsxGrid({
|
|
|
20239
20519
|
rowIndexByActual,
|
|
20240
20520
|
rowPrefixSums,
|
|
20241
20521
|
selectionHeaderSurface,
|
|
20522
|
+
headerIsSelected,
|
|
20523
|
+
secondaryRanges,
|
|
20242
20524
|
sortState,
|
|
20243
20525
|
shouldBakeCanvasStaticDrawings,
|
|
20244
20526
|
stickyLeftByCol,
|
|
@@ -20544,7 +20826,7 @@ function XlsxGrid({
|
|
|
20544
20826
|
position: "absolute",
|
|
20545
20827
|
right: 0,
|
|
20546
20828
|
top: 0,
|
|
20547
|
-
width:
|
|
20829
|
+
width: HEADER_RESIZE_HANDLE_PX,
|
|
20548
20830
|
height: "100%",
|
|
20549
20831
|
zIndex: 5
|
|
20550
20832
|
}, zoomFactor);
|
|
@@ -21654,10 +21936,11 @@ function XlsxGrid({
|
|
|
21654
21936
|
setInteractionMode("select");
|
|
21655
21937
|
setGlobalCursor("row-resize");
|
|
21656
21938
|
}
|
|
21657
|
-
function startCellSelection(target, pointerId, anchor, axis, originCell, pointerOrigin, originOverlayRect, committedOnPointerDown, initialRange, startClientX, startClientY) {
|
|
21939
|
+
function startCellSelection(target, pointerId, anchor, axis, originCell, pointerOrigin, originOverlayRect, committedOnPointerDown, initialRange, startClientX, startClientY, headerGesture) {
|
|
21658
21940
|
clearPendingSelectionDrag();
|
|
21659
21941
|
const previewRange = normalizeRange2(initialRange);
|
|
21660
21942
|
pendingSelectionDragRef.current = {
|
|
21943
|
+
headerGesture,
|
|
21661
21944
|
anchor,
|
|
21662
21945
|
axis,
|
|
21663
21946
|
contentScaleX: pointerOrigin.contentScaleX,
|
|
@@ -21673,9 +21956,13 @@ function XlsxGrid({
|
|
|
21673
21956
|
startClientX,
|
|
21674
21957
|
startClientY
|
|
21675
21958
|
};
|
|
21676
|
-
|
|
21677
|
-
|
|
21678
|
-
|
|
21959
|
+
if (headerGesture && axis !== "cell") {
|
|
21960
|
+
commitHeaderSelection(headerGesture, previewRange, axis);
|
|
21961
|
+
} else {
|
|
21962
|
+
selectionPreviewRangeRef.current = previewRange;
|
|
21963
|
+
displayedSelectionRef.current = previewRange;
|
|
21964
|
+
applyPreviewOverlay(previewRange);
|
|
21965
|
+
}
|
|
21679
21966
|
installPendingSelectionDragListeners(pointerId, target);
|
|
21680
21967
|
}
|
|
21681
21968
|
function resolveFillRange(sourceRange, cell) {
|
|
@@ -22051,10 +22338,27 @@ function XlsxGrid({
|
|
|
22051
22338
|
};
|
|
22052
22339
|
if (selectedChart) openDrawingContextMenu("chart", selectedChart, position);
|
|
22053
22340
|
else if (selectedImage) openDrawingContextMenu("image", selectedImage, position);
|
|
22054
|
-
else
|
|
22341
|
+
else {
|
|
22342
|
+
const axis = axisSelectionRef.current?.axis;
|
|
22343
|
+
const kind = axis && selectionCoversRange(selectionRanges, getContextExtent(axis, { start: cell, end: cell })) ? axis : "cell";
|
|
22344
|
+
if (kind === "row") position.x = rect.left + displayRowHeaderWidth;
|
|
22345
|
+
if (kind === "column") position.y = rect.top + displayHeaderHeight;
|
|
22346
|
+
openContextMenu(cell, kind, position);
|
|
22347
|
+
}
|
|
22055
22348
|
}
|
|
22056
22349
|
return;
|
|
22057
22350
|
}
|
|
22351
|
+
if ((controller.canChangeVisibility ?? !readOnly) && !selectedChart && !selectedImage && event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
22352
|
+
if (event.code === "Digit9" || event.code === "Digit0") {
|
|
22353
|
+
event.preventDefault();
|
|
22354
|
+
if (event.code === "Digit9") {
|
|
22355
|
+
if (event.shiftKey) controller.unhideRows();
|
|
22356
|
+
else controller.hideRows();
|
|
22357
|
+
} else if (event.shiftKey) controller.unhideColumns();
|
|
22358
|
+
else controller.hideColumns();
|
|
22359
|
+
return;
|
|
22360
|
+
}
|
|
22361
|
+
}
|
|
22058
22362
|
if (!readOnly && (event.metaKey || event.ctrlKey) && !event.altKey) {
|
|
22059
22363
|
const normalizedKey = event.key.toLowerCase();
|
|
22060
22364
|
if (normalizedKey === "z" && event.shiftKey) {
|
|
@@ -22261,6 +22565,11 @@ function XlsxGrid({
|
|
|
22261
22565
|
const clipboard = event.clipboardData;
|
|
22262
22566
|
const clipboardData = getClipboardData();
|
|
22263
22567
|
if (!clipboardData) {
|
|
22568
|
+
if (controller.isWorkerBacked) {
|
|
22569
|
+
event.preventDefault();
|
|
22570
|
+
void copySelectionToClipboard().catch(() => {
|
|
22571
|
+
});
|
|
22572
|
+
}
|
|
22264
22573
|
return;
|
|
22265
22574
|
}
|
|
22266
22575
|
event.preventDefault();
|
|
@@ -22421,6 +22730,14 @@ function XlsxGrid({
|
|
|
22421
22730
|
});
|
|
22422
22731
|
function renderSelectionOverlay(pane) {
|
|
22423
22732
|
return /* @__PURE__ */ u("div", { style: { display: editingCell ? "none" : "contents" }, children: [
|
|
22733
|
+
secondaryOverlays.map((rect, i) => rect && /* @__PURE__ */ u("div", { "data-xlsx-selection-area": "", style: {
|
|
22734
|
+
...rect,
|
|
22735
|
+
backgroundColor: selectionFill,
|
|
22736
|
+
boxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
|
|
22737
|
+
pointerEvents: "none",
|
|
22738
|
+
position: "absolute",
|
|
22739
|
+
zIndex: 24
|
|
22740
|
+
} }, buildRangeSignature(secondaryRanges[i]))),
|
|
22424
22741
|
/* @__PURE__ */ u(
|
|
22425
22742
|
"div",
|
|
22426
22743
|
{
|
|
@@ -22475,7 +22792,7 @@ function XlsxGrid({
|
|
|
22475
22792
|
boxSizing: "border-box",
|
|
22476
22793
|
contain: "layout paint",
|
|
22477
22794
|
cursor: "crosshair",
|
|
22478
|
-
display: !readOnly && resolvedSelectionOverlay ? "block" : "none",
|
|
22795
|
+
display: !readOnly && !secondaryRanges.length && resolvedSelectionOverlay ? "block" : "none",
|
|
22479
22796
|
height: 8,
|
|
22480
22797
|
left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 : 0,
|
|
22481
22798
|
pointerEvents: "auto",
|
|
@@ -23170,7 +23487,7 @@ function XlsxGrid({
|
|
|
23170
23487
|
);
|
|
23171
23488
|
return /* @__PURE__ */ u("div", { style: { backgroundColor: palette.canvas, display: "flex", flex: 1, minHeight: 0, minWidth: 0 }, children: [
|
|
23172
23489
|
renderScroller ? renderScroller({ children: scrollerContent, viewportProps: scrollerViewportProps }) : /* @__PURE__ */ u("div", { ...scrollerViewportProps, children: scrollerContent }, activeTabIndex),
|
|
23173
|
-
renderSelectionPopover && normalizedSelection && activeCell && !isLoading && interactionMode === "idle" && !contextMenu && /* @__PURE__ */ u(
|
|
23490
|
+
renderSelectionPopover && !secondaryRanges.length && normalizedSelection && activeCell && !isLoading && interactionMode === "idle" && !contextMenu && /* @__PURE__ */ u(
|
|
23174
23491
|
SelectionPopover,
|
|
23175
23492
|
{
|
|
23176
23493
|
context: { cell: resolveMergeAnchorCell(activeCell), selection: normalizedSelection, sheetIndex: activeSheetIndex, sheetName: activeSheet?.name ?? "", readOnly },
|
|
@@ -23213,13 +23530,28 @@ function XlsxGrid({
|
|
|
23213
23530
|
},
|
|
23214
23531
|
`${activeSheetIndex}:${editingCell?.row}:${editingCell?.col}`
|
|
23215
23532
|
),
|
|
23216
|
-
enableContextMenu && contextMenu && /* @__PURE__ */ u(
|
|
23533
|
+
enableContextMenu && contextMenu && (contextMenu.sizeAxis ? /* @__PURE__ */ u(
|
|
23534
|
+
HeaderSizeDialog,
|
|
23535
|
+
{
|
|
23536
|
+
axis: contextMenu.sizeAxis,
|
|
23537
|
+
context: contextMenu.context,
|
|
23538
|
+
sizes: contextMenu.sizeAxis === "row" ? actualRowHeights : actualColWidths,
|
|
23539
|
+
maxSize: contextMenu.sizeAxis === "row" ? MAX_AUTOFIT_ROW_HEIGHT_PX : activeSheet?.officeLayout ? resolveOfficeColumnWidthPixels(MAX_COLUMN_WIDTH_CHARACTERS, activeSheet.officeLayout.columnDigitWidthPt) : resolveSheetColumnWidthPixels(MAX_COLUMN_WIDTH_CHARACTERS, activeSheet?.columnWidthCharacterWidthPx),
|
|
23540
|
+
messages,
|
|
23541
|
+
locale,
|
|
23542
|
+
palette,
|
|
23543
|
+
close: closeContextMenu,
|
|
23544
|
+
resize: contextMenu.sizeAxis === "row" ? controller.resizeRow : controller.resizeColumn
|
|
23545
|
+
}
|
|
23546
|
+
) : /* @__PURE__ */ u(
|
|
23217
23547
|
XlsxContextMenu,
|
|
23218
23548
|
{
|
|
23219
23549
|
...contextMenu,
|
|
23220
23550
|
controller,
|
|
23221
23551
|
palette,
|
|
23222
23552
|
closeMenu: closeContextMenu,
|
|
23553
|
+
canResize: canResizeHeaders,
|
|
23554
|
+
editSize: (axis) => setContextMenu({ ...contextMenu, sizeAxis: axis }),
|
|
23223
23555
|
editCell: () => startEditing(contextMenu.context.cell, void 0, "context-menu"),
|
|
23224
23556
|
selectExtent: (kind) => selectContextExtent(kind, contextMenu.context.selection),
|
|
23225
23557
|
renderContextMenu,
|
|
@@ -23227,7 +23559,7 @@ function XlsxGrid({
|
|
|
23227
23559
|
contextMenuStyle
|
|
23228
23560
|
},
|
|
23229
23561
|
`${contextMenu.position.x}:${contextMenu.position.y}`
|
|
23230
|
-
)
|
|
23562
|
+
))
|
|
23231
23563
|
] });
|
|
23232
23564
|
}
|
|
23233
23565
|
function XlsxViewerInner({
|
|
@@ -23617,4 +23949,4 @@ export {
|
|
|
23617
23949
|
__createContentNode,
|
|
23618
23950
|
__createContentRoot
|
|
23619
23951
|
};
|
|
23620
|
-
//# sourceMappingURL=chunk-
|
|
23952
|
+
//# sourceMappingURL=chunk-XUHSQ3GF.js.map
|