@extend-ai/react-xlsx 0.23.2 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/{chunk-UICWNF5V.js → chunk-2TLD35UF.js} +3 -27
- package/dist/chunk-2TLD35UF.js.map +1 -0
- package/dist/{chunk-M7QVMFYT.js → chunk-C4WTJIRG.js} +709 -487
- package/dist/chunk-C4WTJIRG.js.map +1 -0
- package/dist/{chunk-FGJY2TIS.cjs → chunk-DGNSB5M5.cjs} +2563 -2341
- package/dist/chunk-DGNSB5M5.cjs.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-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 +695 -606
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -7
- package/dist/index.d.ts +45 -7
- package/dist/index.js +674 -585
- package/dist/index.js.map +1 -1
- package/dist/{internal-BVZRgYaH.d.ts → internal-CwTqluL7.d.cts} +106 -64
- package/dist/{internal-BVZRgYaH.d.cts → internal-CwTqluL7.d.ts} +106 -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-O3QY5UED.js → workbook-runtime-56Y3B64Y.js} +8 -12
- package/dist/workbook-runtime-56Y3B64Y.js.map +1 -0
- package/dist/{workbook-runtime-FXUSOOFT.js → workbook-runtime-7DSKESFL.js} +8 -12
- package/dist/workbook-runtime-7DSKESFL.js.map +1 -0
- package/dist/{workbook-runtime-2HYFRGZD.cjs → workbook-runtime-MEI3CEWO.cjs} +64 -68
- package/dist/workbook-runtime-MEI3CEWO.cjs.map +1 -0
- package/dist/{workbook-runtime-OJDBGHMM.cjs → workbook-runtime-QFXDLSSI.cjs} +66 -70
- package/dist/workbook-runtime-QFXDLSSI.cjs.map +1 -0
- package/dist/xlsx-worker.js +7 -11
- 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,55 @@ 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
|
+
|
|
110
157
|
// src/merged-range-lookup.ts
|
|
111
158
|
function createMergedRangeLookup(ranges) {
|
|
112
159
|
const normalizedRanges = [];
|
|
@@ -1022,7 +1069,7 @@ var XlsxWorkerClient = class {
|
|
|
1022
1069
|
}
|
|
1023
1070
|
async getMainRuntime() {
|
|
1024
1071
|
if (this.disposed) throw createAbortError();
|
|
1025
|
-
this.mainRuntime ??= import("./workbook-runtime-
|
|
1072
|
+
this.mainRuntime ??= import("./workbook-runtime-7DSKESFL.js").then(({ createWorkbookRuntime }) => createWorkbookRuntime());
|
|
1026
1073
|
const runtime = await this.mainRuntime;
|
|
1027
1074
|
if (this.disposed) {
|
|
1028
1075
|
runtime.dispose();
|
|
@@ -1251,8 +1298,8 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
1251
1298
|
maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
|
|
1252
1299
|
maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
|
|
1253
1300
|
mergedRanges: mergeMetadata.mergedRanges,
|
|
1254
|
-
hiddenCols:
|
|
1255
|
-
hiddenRows:
|
|
1301
|
+
hiddenCols: Array.from(worksheet.hiddenColumns),
|
|
1302
|
+
hiddenRows: Array.from(worksheet.hiddenRows),
|
|
1256
1303
|
minUsedCol: -1,
|
|
1257
1304
|
minUsedRow: -1,
|
|
1258
1305
|
maxUsedCol: -1,
|
|
@@ -1341,8 +1388,8 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
1341
1388
|
maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
|
|
1342
1389
|
maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
|
|
1343
1390
|
mergedRanges: mergeMetadata.mergedRanges,
|
|
1344
|
-
hiddenCols:
|
|
1345
|
-
hiddenRows:
|
|
1391
|
+
hiddenCols: Array.from(worksheet.hiddenColumns),
|
|
1392
|
+
hiddenRows: Array.from(worksheet.hiddenRows),
|
|
1346
1393
|
minUsedCol: minCol,
|
|
1347
1394
|
minUsedRow: minRow,
|
|
1348
1395
|
maxUsedCol: maxCol,
|
|
@@ -2036,7 +2083,11 @@ function useXlsxViewerController(options2) {
|
|
|
2036
2083
|
const [activeTabIndex, setActiveTabIndexState] = d(0);
|
|
2037
2084
|
const [zoomScaleOverridesByTabId, setZoomScaleOverridesByTabId] = d({});
|
|
2038
2085
|
const [activeCell, setActiveCell] = d(null);
|
|
2039
|
-
const [
|
|
2086
|
+
const [selectionRanges, setSelectionRanges] = d([]);
|
|
2087
|
+
const selection = selectionRanges.at(-1) ?? null;
|
|
2088
|
+
const setSelection = q((range) => {
|
|
2089
|
+
setSelectionRanges(range ? [range] : []);
|
|
2090
|
+
}, []);
|
|
2040
2091
|
const [highlightedRanges, setHighlightedRanges] = d([]);
|
|
2041
2092
|
const [selectedChartId, setSelectedChartId] = d(null);
|
|
2042
2093
|
const [selectedChartElement, setSelectedChartElement] = d(null);
|
|
@@ -2797,23 +2848,20 @@ function useXlsxViewerController(options2) {
|
|
|
2797
2848
|
}, [activeSheet, getActiveWorksheet, locale]);
|
|
2798
2849
|
const getClipboardData = q(() => {
|
|
2799
2850
|
const worksheet = getActiveWorksheet();
|
|
2800
|
-
const
|
|
2801
|
-
if (!worksheet || !
|
|
2802
|
-
return null;
|
|
2803
|
-
}
|
|
2804
|
-
const normalized = normalizeRange(targetRange);
|
|
2851
|
+
const bands = clipboardBands(selectionRanges);
|
|
2852
|
+
if (!worksheet || !bands) return null;
|
|
2805
2853
|
const rows = [];
|
|
2806
2854
|
const htmlRows = [];
|
|
2807
2855
|
const payload = {
|
|
2808
2856
|
cells: [],
|
|
2809
|
-
cols:
|
|
2857
|
+
cols: bands.cols.reduce((total, band) => total + band.end - band.start + 1, 0),
|
|
2810
2858
|
merges: [],
|
|
2811
|
-
rows:
|
|
2859
|
+
rows: bands.rows.reduce((total, band) => total + band.end - band.start + 1, 0)
|
|
2812
2860
|
};
|
|
2813
|
-
for (
|
|
2861
|
+
for (const { index: row3, offset: rowOffset, remaining: rowsRemaining } of bandIndices(bands.rows)) {
|
|
2814
2862
|
const textCells = [];
|
|
2815
2863
|
const htmlCells = [];
|
|
2816
|
-
for (
|
|
2864
|
+
for (const { index: col, offset: colOffset, remaining: colsRemaining } of bandIndices(bands.cols)) {
|
|
2817
2865
|
if (worksheet.isMergedSecondary(row3, col)) {
|
|
2818
2866
|
textCells.push("");
|
|
2819
2867
|
continue;
|
|
@@ -2880,19 +2928,19 @@ function useXlsxViewerController(options2) {
|
|
|
2880
2928
|
if (border?.left?.style && border.left.style !== "none") {
|
|
2881
2929
|
cellStyles.push(`border-left:${mapBorder(border.left)}`);
|
|
2882
2930
|
}
|
|
2883
|
-
const rowSpan = Math.min(merge?.rowSpan ?? 1,
|
|
2884
|
-
const colSpan = Math.min(merge?.colSpan ?? 1,
|
|
2931
|
+
const rowSpan = Math.min(merge?.rowSpan ?? 1, rowsRemaining);
|
|
2932
|
+
const colSpan = Math.min(merge?.colSpan ?? 1, colsRemaining);
|
|
2885
2933
|
payload.cells.push({
|
|
2886
|
-
colOffset
|
|
2934
|
+
colOffset,
|
|
2887
2935
|
formula,
|
|
2888
|
-
rowOffset
|
|
2936
|
+
rowOffset,
|
|
2889
2937
|
value
|
|
2890
2938
|
});
|
|
2891
2939
|
if (rowSpan > 1 || colSpan > 1) {
|
|
2892
2940
|
payload.merges.push({
|
|
2893
|
-
colOffset
|
|
2941
|
+
colOffset,
|
|
2894
2942
|
colSpan,
|
|
2895
|
-
rowOffset
|
|
2943
|
+
rowOffset,
|
|
2896
2944
|
rowSpan
|
|
2897
2945
|
});
|
|
2898
2946
|
}
|
|
@@ -2909,7 +2957,7 @@ function useXlsxViewerController(options2) {
|
|
|
2909
2957
|
structured: JSON.stringify(payload),
|
|
2910
2958
|
text: rows.join("\n")
|
|
2911
2959
|
};
|
|
2912
|
-
}, [
|
|
2960
|
+
}, [activeSheet, getActiveWorksheet, getCellDisplayValue2, selectionRanges]);
|
|
2913
2961
|
h(() => {
|
|
2914
2962
|
if (!isWorkerBacked || !deferredMetadataSheet || !deferredMetadataCell) {
|
|
2915
2963
|
return;
|
|
@@ -2940,7 +2988,7 @@ function useXlsxViewerController(options2) {
|
|
|
2940
2988
|
};
|
|
2941
2989
|
}, [deferredMetadataCell, deferredMetadataSheet, getCellSnapshotAsync, isWorkerBacked, locale]);
|
|
2942
2990
|
const activeCellAddress = T(() => activeCell ? cellAddressToA1(activeCell) : null, [activeCell]);
|
|
2943
|
-
const selectedRangeAddress = T(() =>
|
|
2991
|
+
const selectedRangeAddress = T(() => selectionRanges.map(rangeToA1).join(",") || null, [selectionRanges]);
|
|
2944
2992
|
const selectedValue = T(
|
|
2945
2993
|
() => getCellDisplayValue2(deferredMetadataCell),
|
|
2946
2994
|
[deferredMetadataCell, getCellDisplayValue2, revision, workerCellSnapshotRevision]
|
|
@@ -2990,10 +3038,10 @@ function useXlsxViewerController(options2) {
|
|
|
2990
3038
|
bytes: workbook.exportSnapshot(),
|
|
2991
3039
|
assets: imageAssetsRef.current ? structuredClone(imageAssetsRef.current) : null,
|
|
2992
3040
|
origins: structuredClone(sheetOriginsRef.current),
|
|
2993
|
-
|
|
3041
|
+
selectionRanges,
|
|
2994
3042
|
sortState
|
|
2995
3043
|
};
|
|
2996
|
-
}, [activeCell, activeSheetIndex,
|
|
3044
|
+
}, [activeCell, activeSheetIndex, selectionRanges, sortState, workbook]);
|
|
2997
3045
|
const captureCellMutationState = q((cell) => {
|
|
2998
3046
|
const worksheet = getActiveWorksheet();
|
|
2999
3047
|
if (!worksheet) {
|
|
@@ -3035,9 +3083,9 @@ function useXlsxViewerController(options2) {
|
|
|
3035
3083
|
setActiveTabIndexState(nextTabIndex);
|
|
3036
3084
|
}
|
|
3037
3085
|
setActiveCell(entry.activeCell);
|
|
3038
|
-
|
|
3086
|
+
setSelectionRanges(entry.selectionRanges);
|
|
3039
3087
|
setSortState(entry.sortState);
|
|
3040
|
-
selectionAnchorRef.current = entry.
|
|
3088
|
+
selectionAnchorRef.current = entry.selectionRanges.at(-1)?.start ?? entry.activeCell;
|
|
3041
3089
|
setRevision((current) => current + 1);
|
|
3042
3090
|
}, [setChartAssets, setImageAssets]);
|
|
3043
3091
|
const applyCellEditHistoryEntry = q((entry, direction) => {
|
|
@@ -3057,8 +3105,8 @@ function useXlsxViewerController(options2) {
|
|
|
3057
3105
|
setActiveSheetIndexState(visibleSheetIndex);
|
|
3058
3106
|
}
|
|
3059
3107
|
setActiveCell(nextActiveCell);
|
|
3060
|
-
|
|
3061
|
-
selectionAnchorRef.current = nextSelection
|
|
3108
|
+
setSelectionRanges(nextSelection);
|
|
3109
|
+
selectionAnchorRef.current = nextSelection.at(-1)?.start ?? nextActiveCell;
|
|
3062
3110
|
isApplyingHistoryRef.current = false;
|
|
3063
3111
|
}, [maybeRecalculateWorkbook, refreshWorkbookState, sheets, workbook]);
|
|
3064
3112
|
const applyRangeEditHistoryEntry = q((entry, direction) => {
|
|
@@ -3080,8 +3128,8 @@ function useXlsxViewerController(options2) {
|
|
|
3080
3128
|
setActiveSheetIndexState(visibleSheetIndex);
|
|
3081
3129
|
}
|
|
3082
3130
|
setActiveCell(nextActiveCell);
|
|
3083
|
-
|
|
3084
|
-
selectionAnchorRef.current = nextSelection
|
|
3131
|
+
setSelectionRanges(nextSelection);
|
|
3132
|
+
selectionAnchorRef.current = nextSelection.at(-1)?.start ?? nextActiveCell;
|
|
3085
3133
|
isApplyingHistoryRef.current = false;
|
|
3086
3134
|
}, [maybeRecalculateWorkbook, refreshWorkbookState, sheets, workbook]);
|
|
3087
3135
|
const recordHistoryBeforeMutation = q(() => {
|
|
@@ -3340,13 +3388,13 @@ function useXlsxViewerController(options2) {
|
|
|
3340
3388
|
after,
|
|
3341
3389
|
before,
|
|
3342
3390
|
cell,
|
|
3343
|
-
selectionAfter: { start: cell, end: cell },
|
|
3344
|
-
selectionBefore:
|
|
3391
|
+
selectionAfter: [{ start: cell, end: cell }],
|
|
3392
|
+
selectionBefore: selectionRanges,
|
|
3345
3393
|
sheetIndex: activeSheet.workbookSheetIndex
|
|
3346
3394
|
});
|
|
3347
3395
|
redoStackRef.current = [];
|
|
3348
3396
|
setHistoryRevision((current) => current + 1);
|
|
3349
|
-
}, [activeCell, activeSheet,
|
|
3397
|
+
}, [activeCell, activeSheet, selectionRanges]);
|
|
3350
3398
|
const recordRangeEditHistory = q((mutations, selectionAfter, activeCellAfter, sortStateAfter = sortState) => {
|
|
3351
3399
|
if (!activeSheet || isApplyingHistoryRef.current || mutations.length === 0 && sortStateAfter === sortState) {
|
|
3352
3400
|
return;
|
|
@@ -3357,14 +3405,14 @@ function useXlsxViewerController(options2) {
|
|
|
3357
3405
|
activeCellBefore: activeCell,
|
|
3358
3406
|
mutations,
|
|
3359
3407
|
selectionAfter,
|
|
3360
|
-
selectionBefore:
|
|
3408
|
+
selectionBefore: selectionRanges,
|
|
3361
3409
|
sheetIndex: activeSheet.workbookSheetIndex,
|
|
3362
3410
|
sortStateAfter,
|
|
3363
3411
|
sortStateBefore: sortState
|
|
3364
3412
|
});
|
|
3365
3413
|
redoStackRef.current = [];
|
|
3366
3414
|
setHistoryRevision((current) => current + 1);
|
|
3367
|
-
}, [activeCell, activeSheet,
|
|
3415
|
+
}, [activeCell, activeSheet, selectionRanges, sortState]);
|
|
3368
3416
|
const sortTable = q((tableName, columnIndex, direction) => {
|
|
3369
3417
|
const worksheet = getActiveWorksheet();
|
|
3370
3418
|
const targetTable = tables.find((table) => table.name === tableName || table.displayName === tableName);
|
|
@@ -3423,7 +3471,7 @@ function useXlsxViewerController(options2) {
|
|
|
3423
3471
|
return;
|
|
3424
3472
|
}
|
|
3425
3473
|
setSortState(nextSortState);
|
|
3426
|
-
recordRangeEditHistory([],
|
|
3474
|
+
recordRangeEditHistory([], selectionRanges, activeCell, nextSortState);
|
|
3427
3475
|
return;
|
|
3428
3476
|
}
|
|
3429
3477
|
const mutations = [];
|
|
@@ -3452,7 +3500,7 @@ function useXlsxViewerController(options2) {
|
|
|
3452
3500
|
maybeRecalculateWorkbook(workbook);
|
|
3453
3501
|
refreshWorkbookState(workbook);
|
|
3454
3502
|
setSortState(nextSortState);
|
|
3455
|
-
recordRangeEditHistory(mutations,
|
|
3503
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell, nextSortState);
|
|
3456
3504
|
}, [
|
|
3457
3505
|
intersectsPivot,
|
|
3458
3506
|
activeCell,
|
|
@@ -3462,7 +3510,7 @@ function useXlsxViewerController(options2) {
|
|
|
3462
3510
|
readOnly,
|
|
3463
3511
|
recordRangeEditHistory,
|
|
3464
3512
|
refreshWorkbookState,
|
|
3465
|
-
|
|
3513
|
+
selectionRanges,
|
|
3466
3514
|
sortState,
|
|
3467
3515
|
tables,
|
|
3468
3516
|
workbook
|
|
@@ -3507,106 +3555,122 @@ function useXlsxViewerController(options2) {
|
|
|
3507
3555
|
}
|
|
3508
3556
|
setShouldAutoCalculate(false);
|
|
3509
3557
|
}, [refreshWorkbookState, workbook]);
|
|
3510
|
-
const applyReadOnlyResizeOverride = q((axis,
|
|
3511
|
-
if (!activeSheet)
|
|
3512
|
-
return;
|
|
3513
|
-
}
|
|
3558
|
+
const applyReadOnlyResizeOverride = q((axis, indices, sizePx) => {
|
|
3559
|
+
if (!activeSheet) return;
|
|
3514
3560
|
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
|
-
};
|
|
3561
|
+
const selected = new Set(indices);
|
|
3562
|
+
setSheets((current) => current.map((sheet) => {
|
|
3563
|
+
if (sheet.workbookSheetIndex !== activeSheet.workbookSheetIndex) return sheet;
|
|
3564
|
+
const isRow = axis === "row";
|
|
3565
|
+
const overrides = { ...isRow ? sheet.rowHeightOverridesPx : sheet.colWidthOverridesPx };
|
|
3566
|
+
for (const index of selected) overrides[index] = contentSizePx;
|
|
3567
|
+
const visible = isRow ? sheet.visibleRows : sheet.visibleCols;
|
|
3568
|
+
const sizes = (isRow ? sheet.rowHeights : sheet.colWidths).map((size, offset) => selected.has(visible[offset]) ? contentSizePx : size);
|
|
3569
|
+
return isRow ? { ...sheet, rowHeightOverridesPx: overrides, rowHeights: sizes } : { ...sheet, colWidthOverridesPx: overrides, colWidths: sizes };
|
|
3550
3570
|
}));
|
|
3551
3571
|
setRevision((current) => current + 1);
|
|
3552
3572
|
}, [activeSheet]);
|
|
3553
|
-
const
|
|
3554
|
-
if (!
|
|
3555
|
-
|
|
3556
|
-
}
|
|
3557
|
-
if (
|
|
3558
|
-
applyReadOnlyResizeOverride("column", col, widthPx);
|
|
3559
|
-
return;
|
|
3560
|
-
}
|
|
3561
|
-
if (!workbook) {
|
|
3562
|
-
return;
|
|
3563
|
-
}
|
|
3564
|
-
recordHistoryBeforeMutation();
|
|
3573
|
+
const setAxisHidden = q((axis, hidden, start, end = start) => {
|
|
3574
|
+
if (readOnly || !workbook || !activeSheet) return;
|
|
3575
|
+
const limit = axis === "row" ? XLSX_MAX_ROWS : XLSX_MAX_COLUMNS;
|
|
3576
|
+
const ranges = start === void 0 && end === void 0 ? selectionRanges.map((area) => ({ start: area.start[axis], end: area.end[axis] })) : [{ start: start ?? -1, end: end ?? -1 }];
|
|
3577
|
+
if (!ranges.length || ranges.some((range) => !Number.isInteger(range.start) || !Number.isInteger(range.end) || range.start < 0 || range.end < range.start || range.end >= limit)) return;
|
|
3565
3578
|
const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3579
|
+
try {
|
|
3580
|
+
const existing = new Set(axis === "row" ? worksheet.hiddenRows : worksheet.hiddenColumns);
|
|
3581
|
+
if (!hidden && !existing.size) return;
|
|
3582
|
+
if (!hidden && start === void 0 && existing.has(0)) {
|
|
3583
|
+
let firstVisible = 0;
|
|
3584
|
+
while (existing.has(firstVisible)) firstVisible++;
|
|
3585
|
+
for (const range of ranges) {
|
|
3586
|
+
if (range.start === firstVisible) range.start = 0;
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
const changes = ranges.filter((range) => {
|
|
3590
|
+
for (let index = range.start; index <= range.end; index++) {
|
|
3591
|
+
if (existing.has(index) !== hidden) return true;
|
|
3592
|
+
}
|
|
3593
|
+
return false;
|
|
3594
|
+
});
|
|
3595
|
+
if (!changes.length) return;
|
|
3596
|
+
recordHistoryBeforeMutation();
|
|
3597
|
+
for (const range of changes) {
|
|
3598
|
+
if (axis === "row") worksheet.setRowsHidden(range.start, range.end, hidden);
|
|
3599
|
+
else worksheet.setColumnsHidden(range.start, range.end, hidden);
|
|
3600
|
+
}
|
|
3601
|
+
if (hidden && activeCell && changes.some((range) => range.start <= activeCell[axis] && activeCell[axis] <= range.end)) {
|
|
3602
|
+
const isHidden = (index2) => axis === "row" ? worksheet.isRowHidden(index2) : worksheet.isColumnHidden(index2);
|
|
3603
|
+
let index = activeCell[axis];
|
|
3604
|
+
while (index < limit && isHidden(index)) index++;
|
|
3605
|
+
if (index === limit) {
|
|
3606
|
+
index = activeCell[axis] - 1;
|
|
3607
|
+
while (index >= 0 && isHidden(index)) index--;
|
|
3608
|
+
}
|
|
3609
|
+
if (index >= 0) {
|
|
3610
|
+
const cell = { ...activeCell, [axis]: index };
|
|
3611
|
+
setActiveCell(cell);
|
|
3612
|
+
setSelection({ start: cell, end: cell });
|
|
3613
|
+
selectionAnchorRef.current = cell;
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
refreshWorkbookState(workbook);
|
|
3617
|
+
} finally {
|
|
3618
|
+
worksheet.free();
|
|
3619
|
+
}
|
|
3620
|
+
}, [activeCell, activeSheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selectionRanges, setSelection, workbook]);
|
|
3621
|
+
const hideRows = q((start, end) => setAxisHidden("row", true, start, end), [setAxisHidden]);
|
|
3622
|
+
const unhideRows = q((start, end) => setAxisHidden("row", false, start, end), [setAxisHidden]);
|
|
3623
|
+
const hideColumns = q((start, end) => setAxisHidden("col", true, start, end), [setAxisHidden]);
|
|
3624
|
+
const unhideColumns = q((start, end) => setAxisHidden("col", false, start, end), [setAxisHidden]);
|
|
3625
|
+
const setFreezeBoundary = q((cell) => {
|
|
3626
|
+
if (readOnly || !workbook || !activeSheet) return;
|
|
3627
|
+
const { row: row3, col } = cell;
|
|
3628
|
+
if (!Number.isInteger(row3) || row3 < 0 || row3 >= XLSX_MAX_ROWS || !Number.isInteger(col) || col < 0 || col >= XLSX_MAX_COLUMNS) return;
|
|
3629
|
+
const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
|
|
3630
|
+
try {
|
|
3631
|
+
const current = parseWorksheetFreezePanes(worksheet);
|
|
3632
|
+
if (row3 === (current?.row ?? 0) && col === (current?.col ?? 0)) return;
|
|
3633
|
+
recordHistoryBeforeMutation();
|
|
3634
|
+
worksheet.setFreezePanes(row3, col);
|
|
3635
|
+
refreshWorkbookState(workbook);
|
|
3636
|
+
} finally {
|
|
3637
|
+
worksheet.free();
|
|
3638
|
+
}
|
|
3639
|
+
}, [activeSheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
|
|
3640
|
+
const freezeCell = resolveFreezePanesCell(activeCell, selection);
|
|
3641
|
+
const canFreezePanes = Boolean(!readOnly && workbook && activeSheet && freezeCell && (freezeCell.row > 0 || freezeCell.col > 0));
|
|
3642
|
+
const freezePanes = q((cell = freezeCell) => {
|
|
3643
|
+
if (cell) setFreezeBoundary(cell);
|
|
3644
|
+
}, [freezeCell, setFreezeBoundary]);
|
|
3645
|
+
const unfreezePanes = q(() => setFreezeBoundary({ row: 0, col: 0 }), [setFreezeBoundary]);
|
|
3646
|
+
const resizeAxis = q((axis, target, sizePx) => {
|
|
3647
|
+
if (!canResize || !activeSheet || !Number.isFinite(sizePx)) return;
|
|
3648
|
+
const indices = typeof target === "number" ? [target] : target;
|
|
3649
|
+
const limit = axis === "row" ? XLSX_MAX_ROWS : XLSX_MAX_COLUMNS;
|
|
3650
|
+
if (!indices.length || indices.some((index) => !Number.isInteger(index) || index < 0 || index >= limit)) return;
|
|
3587
3651
|
if (isWorkerBacked) {
|
|
3588
|
-
applyReadOnlyResizeOverride(
|
|
3589
|
-
return;
|
|
3590
|
-
}
|
|
3591
|
-
if (!workbook) {
|
|
3652
|
+
applyReadOnlyResizeOverride(axis, indices, sizePx);
|
|
3592
3653
|
return;
|
|
3593
3654
|
}
|
|
3594
|
-
|
|
3655
|
+
if (!workbook) return;
|
|
3595
3656
|
const worksheet = workbook.getSheet(activeSheet.workbookSheetIndex);
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3657
|
+
try {
|
|
3658
|
+
recordHistoryBeforeMutation();
|
|
3659
|
+
const contentPx = resolveContentSheetAxisPixels(sizePx, activeSheet.showGridLines);
|
|
3660
|
+
if (axis === "row") {
|
|
3661
|
+
const points = activeSheet.officeLayout ? Math.max(sizePx, MIN_ROW_HEIGHT_PX) * 3 / 4 : pxToSheetRowHeight(contentPx);
|
|
3662
|
+
for (const index of indices) worksheet.setRowHeight(index, points);
|
|
3663
|
+
} else {
|
|
3664
|
+
const width = activeSheet.officeLayout ? pxToOfficeColumnWidth(sizePx, activeSheet.officeLayout.columnDigitWidthPt) : pxToSheetColumnWidth(contentPx, activeSheet.columnWidthCharacterWidthPx);
|
|
3665
|
+
for (const index of indices) worksheet.setColumnWidth(index, width);
|
|
3666
|
+
}
|
|
3667
|
+
refreshWorkbookState(workbook);
|
|
3668
|
+
} finally {
|
|
3669
|
+
worksheet.free();
|
|
3670
|
+
}
|
|
3671
|
+
}, [activeSheet, applyReadOnlyResizeOverride, canResize, isWorkerBacked, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
|
|
3672
|
+
const resizeColumn = q((col, widthPx) => resizeAxis("column", col, widthPx), [resizeAxis]);
|
|
3673
|
+
const resizeRow = q((row3, heightPx) => resizeAxis("row", row3, heightPx), [resizeAxis]);
|
|
3610
3674
|
const resolveAnchoredObjectRect = q((anchor, worksheet) => {
|
|
3611
3675
|
const resolveAxisSum = (index, getSize) => {
|
|
3612
3676
|
let total = 0;
|
|
@@ -4036,15 +4100,20 @@ function useXlsxViewerController(options2) {
|
|
|
4036
4100
|
selectionAnchorRef.current = anchorCell;
|
|
4037
4101
|
setSelection(merged ?? { start: cell, end: cell });
|
|
4038
4102
|
}, [activeSheet?.mergedRanges, findSelectionMerge]);
|
|
4039
|
-
const
|
|
4040
|
-
const
|
|
4103
|
+
const selectRanges = q((ranges, activeCorner = "end") => {
|
|
4104
|
+
const areas = ranges.reduce((previous, range) => addSelectionRange(previous, normalizeRange(range)), []);
|
|
4105
|
+
const active = areas.at(-1);
|
|
4041
4106
|
setSelectedChartId(null);
|
|
4042
4107
|
setSelectedChartElement(null);
|
|
4043
4108
|
setSelectedImageId(null);
|
|
4044
|
-
selectionAnchorRef.current =
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4109
|
+
selectionAnchorRef.current = active?.start ?? null;
|
|
4110
|
+
const cell = active?.[activeCorner];
|
|
4111
|
+
setActiveCell(cell ? findSelectionMerge(cell)?.start ?? cell : null);
|
|
4112
|
+
setSelectionRanges(areas);
|
|
4113
|
+
}, [findSelectionMerge]);
|
|
4114
|
+
const selectRange = q((range) => {
|
|
4115
|
+
selectRanges([expandHighlightedRange(normalizeRange(range), activeSheet?.mergedRanges ?? [])]);
|
|
4116
|
+
}, [activeSheet?.mergedRanges, selectRanges]);
|
|
4048
4117
|
const clearSelection = q(() => {
|
|
4049
4118
|
selectionAnchorRef.current = null;
|
|
4050
4119
|
setActiveCell(null);
|
|
@@ -4055,38 +4124,35 @@ function useXlsxViewerController(options2) {
|
|
|
4055
4124
|
}, []);
|
|
4056
4125
|
const clearSelectedCells = q(() => {
|
|
4057
4126
|
const worksheet = getActiveWorksheet();
|
|
4058
|
-
|
|
4059
|
-
if (readOnly || !worksheet || !workbook || !targetRange) {
|
|
4060
|
-
return;
|
|
4061
|
-
}
|
|
4062
|
-
if (intersectsPivot(targetRange)) return;
|
|
4063
|
-
const normalized = normalizeRange(targetRange);
|
|
4127
|
+
if (readOnly || !worksheet || !workbook || !selectionRanges.length || selectionRanges.some(intersectsPivot)) return;
|
|
4064
4128
|
const mutations = [];
|
|
4065
|
-
for (
|
|
4066
|
-
for (let
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4129
|
+
for (const area of selectionRanges) {
|
|
4130
|
+
for (let row3 = area.start.row; row3 <= area.end.row; row3 += 1) {
|
|
4131
|
+
for (let col = area.start.col; col <= area.end.col; col += 1) {
|
|
4132
|
+
if (worksheet.isMergedSecondary(row3, col)) {
|
|
4133
|
+
continue;
|
|
4134
|
+
}
|
|
4135
|
+
const cell = { row: row3, col };
|
|
4136
|
+
const before = captureCellMutationState(cell);
|
|
4137
|
+
if (!before) {
|
|
4138
|
+
continue;
|
|
4139
|
+
}
|
|
4140
|
+
worksheet.setCell(cellAddressToA1({ row: row3, col }), "");
|
|
4141
|
+
const after = captureCellMutationState(cell);
|
|
4142
|
+
if (!after) {
|
|
4143
|
+
continue;
|
|
4144
|
+
}
|
|
4145
|
+
mutations.push({
|
|
4146
|
+
after,
|
|
4147
|
+
before,
|
|
4148
|
+
cell
|
|
4149
|
+
});
|
|
4079
4150
|
}
|
|
4080
|
-
mutations.push({
|
|
4081
|
-
after,
|
|
4082
|
-
before,
|
|
4083
|
-
cell
|
|
4084
|
-
});
|
|
4085
4151
|
}
|
|
4086
4152
|
}
|
|
4087
4153
|
maybeRecalculateWorkbook(workbook);
|
|
4088
4154
|
refreshWorkbookState(workbook);
|
|
4089
|
-
recordRangeEditHistory(mutations,
|
|
4155
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
4090
4156
|
}, [
|
|
4091
4157
|
intersectsPivot,
|
|
4092
4158
|
activeCell,
|
|
@@ -4096,7 +4162,7 @@ function useXlsxViewerController(options2) {
|
|
|
4096
4162
|
readOnly,
|
|
4097
4163
|
recordRangeEditHistory,
|
|
4098
4164
|
refreshWorkbookState,
|
|
4099
|
-
|
|
4165
|
+
selectionRanges,
|
|
4100
4166
|
workbook
|
|
4101
4167
|
]);
|
|
4102
4168
|
const setCellValue = q((cell, value) => {
|
|
@@ -4181,8 +4247,8 @@ function useXlsxViewerController(options2) {
|
|
|
4181
4247
|
if (after) mutations.push({ cell, before, after });
|
|
4182
4248
|
}
|
|
4183
4249
|
refreshWorkbookState(workbook);
|
|
4184
|
-
recordRangeEditHistory(mutations,
|
|
4185
|
-
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState,
|
|
4250
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
4251
|
+
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selectionRanges, workbook]);
|
|
4186
4252
|
const setSelectedCellValue = q((value) => {
|
|
4187
4253
|
if (!activeCell) {
|
|
4188
4254
|
return;
|
|
@@ -4216,25 +4282,27 @@ function useXlsxViewerController(options2) {
|
|
|
4216
4282
|
if (readOnly || !worksheet || !workbook) {
|
|
4217
4283
|
return;
|
|
4218
4284
|
}
|
|
4219
|
-
const
|
|
4285
|
+
const areas = "start" in range ? [normalizeRange(range)] : range.map(normalizeRange);
|
|
4220
4286
|
const beforeStates = [];
|
|
4221
|
-
for (
|
|
4222
|
-
for (let
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4287
|
+
for (const area of areas) {
|
|
4288
|
+
for (let row3 = area.start.row; row3 <= area.end.row; row3 += 1) {
|
|
4289
|
+
for (let col = area.start.col; col <= area.end.col; col += 1) {
|
|
4290
|
+
const cell = { row: row3, col };
|
|
4291
|
+
const before = captureCellMutationState(cell);
|
|
4292
|
+
if (!before) {
|
|
4293
|
+
continue;
|
|
4294
|
+
}
|
|
4295
|
+
beforeStates.push({
|
|
4296
|
+
before,
|
|
4297
|
+
cell
|
|
4298
|
+
});
|
|
4227
4299
|
}
|
|
4228
|
-
beforeStates.push({
|
|
4229
|
-
before,
|
|
4230
|
-
cell
|
|
4231
|
-
});
|
|
4232
4300
|
}
|
|
4233
4301
|
}
|
|
4234
4302
|
if (beforeStates.length === 0) {
|
|
4235
4303
|
return;
|
|
4236
4304
|
}
|
|
4237
|
-
worksheet.setRangeStyle(rangeToA1(
|
|
4305
|
+
for (const area of areas) worksheet.setRangeStyle(rangeToA1(area), style);
|
|
4238
4306
|
const mutations = [];
|
|
4239
4307
|
for (const mutation of beforeStates) {
|
|
4240
4308
|
const after = captureCellMutationState(mutation.cell);
|
|
@@ -4248,11 +4316,11 @@ function useXlsxViewerController(options2) {
|
|
|
4248
4316
|
});
|
|
4249
4317
|
}
|
|
4250
4318
|
refreshWorkbookState(workbook);
|
|
4251
|
-
recordRangeEditHistory(mutations,
|
|
4252
|
-
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState,
|
|
4319
|
+
recordRangeEditHistory(mutations, selectionRanges, activeCell);
|
|
4320
|
+
}, [activeCell, captureCellMutationState, getActiveWorksheet, readOnly, recordRangeEditHistory, refreshWorkbookState, selectionRanges, workbook]);
|
|
4253
4321
|
const fillSelection = q((targetRange) => {
|
|
4254
4322
|
const worksheet = getActiveWorksheet();
|
|
4255
|
-
if (readOnly || !worksheet || !workbook || !selection) {
|
|
4323
|
+
if (readOnly || !worksheet || !workbook || !selection || selectionRanges.length > 1) {
|
|
4256
4324
|
return;
|
|
4257
4325
|
}
|
|
4258
4326
|
if (intersectsPivot(targetRange)) return;
|
|
@@ -4303,11 +4371,11 @@ function useXlsxViewerController(options2) {
|
|
|
4303
4371
|
setSelection(nextRange);
|
|
4304
4372
|
setActiveCell(nextRange.end);
|
|
4305
4373
|
selectionAnchorRef.current = nextRange.start;
|
|
4306
|
-
recordRangeEditHistory(mutations, nextRange, nextRange.end);
|
|
4307
|
-
}, [intersectsPivot, captureCellMutationState, getActiveWorksheet, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
|
|
4374
|
+
recordRangeEditHistory(mutations, [nextRange], nextRange.end);
|
|
4375
|
+
}, [intersectsPivot, captureCellMutationState, getActiveWorksheet, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4308
4376
|
const mergeSelection = q((mode = "cells") => {
|
|
4309
4377
|
const worksheet = getActiveWorksheet();
|
|
4310
|
-
if (readOnly || !worksheet || !selection || !workbook) {
|
|
4378
|
+
if (readOnly || !worksheet || !selection || selectionRanges.length > 1 || !workbook) {
|
|
4311
4379
|
return;
|
|
4312
4380
|
}
|
|
4313
4381
|
if (intersectsPivot(selection)) return;
|
|
@@ -4340,10 +4408,10 @@ function useXlsxViewerController(options2) {
|
|
|
4340
4408
|
selectionAnchorRef.current = range.start;
|
|
4341
4409
|
setSelection(range);
|
|
4342
4410
|
setActiveCell(range.start);
|
|
4343
|
-
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, workbook]);
|
|
4411
|
+
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4344
4412
|
const unmergeSelection = q(() => {
|
|
4345
4413
|
const worksheet = getActiveWorksheet();
|
|
4346
|
-
if (readOnly || !worksheet || !selection || !workbook) {
|
|
4414
|
+
if (readOnly || !worksheet || !selection || selectionRanges.length > 1 || !workbook) {
|
|
4347
4415
|
return;
|
|
4348
4416
|
}
|
|
4349
4417
|
const range = normalizeRange(selection);
|
|
@@ -4355,7 +4423,7 @@ function useXlsxViewerController(options2) {
|
|
|
4355
4423
|
worksheet.unmergeCells(rangeToA1(merged));
|
|
4356
4424
|
}
|
|
4357
4425
|
refreshWorkbookState(workbook);
|
|
4358
|
-
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, workbook]);
|
|
4426
|
+
}, [intersectsPivot, getActiveWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4359
4427
|
const addSheet = q((name) => {
|
|
4360
4428
|
if (readOnly || !workbook) {
|
|
4361
4429
|
return;
|
|
@@ -4444,18 +4512,18 @@ function useXlsxViewerController(options2) {
|
|
|
4444
4512
|
if (!trimmed) {
|
|
4445
4513
|
return;
|
|
4446
4514
|
}
|
|
4447
|
-
const targetRange = range ?? selection;
|
|
4515
|
+
const targetRange = range ?? (selectionRanges.length === 1 ? selection : null);
|
|
4448
4516
|
if (!targetRange) {
|
|
4449
4517
|
return;
|
|
4450
4518
|
}
|
|
4451
4519
|
recordHistoryBeforeMutation();
|
|
4452
4520
|
workbook.defineName(trimmed, rangeToA1(targetRange));
|
|
4453
4521
|
setRevision((current) => current + 1);
|
|
4454
|
-
}, [readOnly, recordHistoryBeforeMutation, selection, workbook]);
|
|
4522
|
+
}, [readOnly, recordHistoryBeforeMutation, selection, selectionRanges, workbook]);
|
|
4455
4523
|
const pasteText = q((text) => {
|
|
4456
4524
|
const worksheet = getActiveWorksheet();
|
|
4457
4525
|
const targetCell = activeCell ?? selection?.start ?? null;
|
|
4458
|
-
if (readOnly || !worksheet || !workbook || !targetCell || !text) {
|
|
4526
|
+
if (readOnly || !worksheet || !workbook || !targetCell || selectionRanges.length > 1 || !text) {
|
|
4459
4527
|
return false;
|
|
4460
4528
|
}
|
|
4461
4529
|
const grid = parseClipboardText(text);
|
|
@@ -4518,13 +4586,13 @@ function useXlsxViewerController(options2) {
|
|
|
4518
4586
|
setActiveCell(targetCell);
|
|
4519
4587
|
setSelection(nextRange);
|
|
4520
4588
|
selectionAnchorRef.current = targetCell;
|
|
4521
|
-
recordRangeEditHistory(mutations, nextRange, targetCell);
|
|
4589
|
+
recordRangeEditHistory(mutations, [nextRange], targetCell);
|
|
4522
4590
|
return true;
|
|
4523
|
-
}, [intersectsPivot, activeCell, captureCellMutationState, getActiveWorksheet, locale, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, workbook]);
|
|
4591
|
+
}, [intersectsPivot, activeCell, captureCellMutationState, getActiveWorksheet, locale, maybeRecalculateWorkbook, readOnly, recordRangeEditHistory, refreshWorkbookState, selection, selectionRanges, workbook]);
|
|
4524
4592
|
const pasteStructuredClipboardData = q((serializedPayload) => {
|
|
4525
4593
|
const worksheet = getActiveWorksheet();
|
|
4526
4594
|
const targetCell = activeCell ?? selection?.start ?? null;
|
|
4527
|
-
if (readOnly || !worksheet || !workbook || !targetCell || !serializedPayload) {
|
|
4595
|
+
if (readOnly || !worksheet || !workbook || !targetCell || selectionRanges.length > 1 || !serializedPayload) {
|
|
4528
4596
|
return false;
|
|
4529
4597
|
}
|
|
4530
4598
|
let payload;
|
|
@@ -4613,7 +4681,7 @@ function useXlsxViewerController(options2) {
|
|
|
4613
4681
|
setSelection(nextRange);
|
|
4614
4682
|
selectionAnchorRef.current = targetCell;
|
|
4615
4683
|
if (!hasMergeOperations) {
|
|
4616
|
-
recordRangeEditHistory(mutations, nextRange, targetCell);
|
|
4684
|
+
recordRangeEditHistory(mutations, [nextRange], targetCell);
|
|
4617
4685
|
}
|
|
4618
4686
|
return true;
|
|
4619
4687
|
}, [
|
|
@@ -4627,33 +4695,37 @@ function useXlsxViewerController(options2) {
|
|
|
4627
4695
|
recordRangeEditHistory,
|
|
4628
4696
|
refreshWorkbookState,
|
|
4629
4697
|
selection,
|
|
4698
|
+
selectionRanges,
|
|
4630
4699
|
workbook
|
|
4631
4700
|
]);
|
|
4632
4701
|
const copySelectionToClipboard = q(async () => {
|
|
4633
4702
|
if (typeof navigator === "undefined" || !navigator.clipboard) {
|
|
4634
4703
|
return false;
|
|
4635
4704
|
}
|
|
4636
|
-
if (isWorkerBacked && activeSheet
|
|
4637
|
-
const
|
|
4705
|
+
if (isWorkerBacked && activeSheet) {
|
|
4706
|
+
const bands = clipboardBands(selectionRanges);
|
|
4707
|
+
if (!bands) return false;
|
|
4638
4708
|
const textPromise = (async () => {
|
|
4639
4709
|
const lines = [];
|
|
4640
|
-
for (
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
for (const
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4710
|
+
for (const band of bands.rows) {
|
|
4711
|
+
for (let startRow = band.start; startRow <= band.end; startRow += 128) {
|
|
4712
|
+
const count = Math.min(128, band.end - startRow + 1);
|
|
4713
|
+
const batch = await getRowsBatchAsync(activeSheet.workbookSheetIndex, startRow, count);
|
|
4714
|
+
if (!batch) throw new Error("Unable to read the selected cells.");
|
|
4715
|
+
const values = /* @__PURE__ */ new Map();
|
|
4716
|
+
for (const entry of batch) {
|
|
4717
|
+
for (const cell of entry.cells ?? []) {
|
|
4718
|
+
if (cell.isMergedSecondary) continue;
|
|
4719
|
+
const value = String(cell.value ?? "");
|
|
4720
|
+
const cached = cell.formula ? activeSheet.cachedFormulaValues[cellAddressToA1({ row: entry.index, col: cell.col })] : void 0;
|
|
4721
|
+
values.set(`${entry.index}:${cell.col}`, decodeHtmlEntities(cached !== void 0 && value.startsWith("#") ? cached : value));
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4724
|
+
for (let row3 = startRow; row3 < startRow + count; row3++) {
|
|
4725
|
+
const cells = [];
|
|
4726
|
+
for (const { index: col } of bandIndices(bands.cols)) cells.push(values.get(`${row3}:${col}`) ?? "");
|
|
4727
|
+
lines.push(cells.join(" "));
|
|
4651
4728
|
}
|
|
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
4729
|
}
|
|
4658
4730
|
}
|
|
4659
4731
|
return lines.join("\n");
|
|
@@ -4691,7 +4763,7 @@ function useXlsxViewerController(options2) {
|
|
|
4691
4763
|
}
|
|
4692
4764
|
await navigator.clipboard.writeText(clipboardData.text);
|
|
4693
4765
|
return true;
|
|
4694
|
-
}, [activeSheet, getClipboardData, getRowsBatchAsync, isWorkerBacked,
|
|
4766
|
+
}, [activeSheet, getClipboardData, getRowsBatchAsync, isWorkerBacked, selectionRanges]);
|
|
4695
4767
|
const pasteFromClipboard = q(async (clipboardData) => {
|
|
4696
4768
|
if (readOnly) return false;
|
|
4697
4769
|
const state = drawingMutationState.current;
|
|
@@ -4856,6 +4928,14 @@ function useXlsxViewerController(options2) {
|
|
|
4856
4928
|
revision,
|
|
4857
4929
|
resizeChartBy,
|
|
4858
4930
|
resizeImageBy,
|
|
4931
|
+
frozenPanes: activeSheet?.freezePanes ?? null,
|
|
4932
|
+
canFreezePanes,
|
|
4933
|
+
hideRows,
|
|
4934
|
+
unhideRows,
|
|
4935
|
+
hideColumns,
|
|
4936
|
+
unhideColumns,
|
|
4937
|
+
freezePanes,
|
|
4938
|
+
unfreezePanes,
|
|
4859
4939
|
resizeColumn,
|
|
4860
4940
|
resizeRow,
|
|
4861
4941
|
setCellFormula,
|
|
@@ -4884,6 +4964,8 @@ function useXlsxViewerController(options2) {
|
|
|
4884
4964
|
selectChartElement,
|
|
4885
4965
|
selectImage,
|
|
4886
4966
|
selectRange,
|
|
4967
|
+
selectRanges,
|
|
4968
|
+
selectionRanges,
|
|
4887
4969
|
selection,
|
|
4888
4970
|
setActiveSheetIndex,
|
|
4889
4971
|
setActiveTabIndex,
|
|
@@ -4999,6 +5081,13 @@ function useXlsxViewerController(options2) {
|
|
|
4999
5081
|
revision,
|
|
5000
5082
|
resizeChartBy,
|
|
5001
5083
|
resizeImageBy,
|
|
5084
|
+
canFreezePanes,
|
|
5085
|
+
hideRows,
|
|
5086
|
+
unhideRows,
|
|
5087
|
+
hideColumns,
|
|
5088
|
+
unhideColumns,
|
|
5089
|
+
freezePanes,
|
|
5090
|
+
unfreezePanes,
|
|
5002
5091
|
resizeColumn,
|
|
5003
5092
|
resizeRow,
|
|
5004
5093
|
setCellFormula,
|
|
@@ -5027,6 +5116,8 @@ function useXlsxViewerController(options2) {
|
|
|
5027
5116
|
selectChartElement,
|
|
5028
5117
|
selectImage,
|
|
5029
5118
|
selectRange,
|
|
5119
|
+
selectRanges,
|
|
5120
|
+
selectionRanges,
|
|
5030
5121
|
selection,
|
|
5031
5122
|
setActiveSheetIndex,
|
|
5032
5123
|
setActiveTabIndex,
|
|
@@ -6639,6 +6730,15 @@ function resolveCellTextClipOverscan(overscan, usesWrappedText) {
|
|
|
6639
6730
|
}
|
|
6640
6731
|
|
|
6641
6732
|
// src/scroll-display-limit.ts
|
|
6733
|
+
function minimumVisibleExtent(minimum, sortedHidden, maximum) {
|
|
6734
|
+
if (!sortedHidden?.length || sortedHidden.length === maximum) return minimum;
|
|
6735
|
+
let extent = minimum;
|
|
6736
|
+
for (const index of sortedHidden) {
|
|
6737
|
+
if (index >= extent || extent >= maximum) break;
|
|
6738
|
+
extent++;
|
|
6739
|
+
}
|
|
6740
|
+
return extent;
|
|
6741
|
+
}
|
|
6642
6742
|
function growScrollDisplayLimit(current, growth, maximum, readOnly) {
|
|
6643
6743
|
const nextLimit = current + growth;
|
|
6644
6744
|
return readOnly ? Math.max(current, Math.min(maximum, nextLimit)) : nextLimit;
|
|
@@ -7181,6 +7281,110 @@ function getCellGeneralAlignment(worksheet, row3, col) {
|
|
|
7181
7281
|
}
|
|
7182
7282
|
}
|
|
7183
7283
|
|
|
7284
|
+
// src/header-size-dialog.tsx
|
|
7285
|
+
function HeaderSizeDialog({ axis, context, sizes, maxSize, messages, locale, palette, close, resize }) {
|
|
7286
|
+
const dialog = A(null);
|
|
7287
|
+
const input = A(null);
|
|
7288
|
+
const titleId = g();
|
|
7289
|
+
const coordinate = axis === "row" ? "row" : "col";
|
|
7290
|
+
const title = axis === "row" ? messages.rowHeight : messages.columnWidth;
|
|
7291
|
+
const indices = T(() => {
|
|
7292
|
+
const selected = /* @__PURE__ */ new Set();
|
|
7293
|
+
for (const area of context.selectionRanges ?? [context.selection]) {
|
|
7294
|
+
for (let index = area.start[coordinate]; index <= area.end[coordinate]; index++) selected.add(index);
|
|
7295
|
+
}
|
|
7296
|
+
return [...selected];
|
|
7297
|
+
}, [context, coordinate]);
|
|
7298
|
+
const [value, setValue] = d(() => {
|
|
7299
|
+
const size = sizes[context.cell[coordinate]];
|
|
7300
|
+
return Number.isFinite(size) && indices.every((index) => sizes[index] === size) ? String(Math.round(size * 100) / 100) : "";
|
|
7301
|
+
});
|
|
7302
|
+
const dismiss = () => {
|
|
7303
|
+
dialog.current?.close();
|
|
7304
|
+
close();
|
|
7305
|
+
};
|
|
7306
|
+
const buttonStyle = {
|
|
7307
|
+
minWidth: 60,
|
|
7308
|
+
padding: "4px 12px",
|
|
7309
|
+
borderRadius: 4,
|
|
7310
|
+
font: "inherit",
|
|
7311
|
+
cursor: "pointer",
|
|
7312
|
+
border: `1px solid ${palette.strongBorder}`,
|
|
7313
|
+
background: palette.buttonSurface,
|
|
7314
|
+
color: palette.buttonText
|
|
7315
|
+
};
|
|
7316
|
+
_(() => {
|
|
7317
|
+
dialog.current?.showModal();
|
|
7318
|
+
input.current?.select();
|
|
7319
|
+
}, []);
|
|
7320
|
+
return $(
|
|
7321
|
+
/* @__PURE__ */ u(
|
|
7322
|
+
"dialog",
|
|
7323
|
+
{
|
|
7324
|
+
ref: dialog,
|
|
7325
|
+
"aria-labelledby": titleId,
|
|
7326
|
+
lang: locale,
|
|
7327
|
+
onCancel: (event) => {
|
|
7328
|
+
event.preventDefault();
|
|
7329
|
+
dismiss();
|
|
7330
|
+
},
|
|
7331
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
7332
|
+
style: {
|
|
7333
|
+
margin: "auto",
|
|
7334
|
+
width: 240,
|
|
7335
|
+
maxWidth: "calc(100vw - 32px)",
|
|
7336
|
+
padding: 16,
|
|
7337
|
+
borderRadius: 8,
|
|
7338
|
+
border: `1px solid ${palette.border}`,
|
|
7339
|
+
background: palette.surface,
|
|
7340
|
+
color: palette.text,
|
|
7341
|
+
font: "13px/1.4 system-ui, sans-serif"
|
|
7342
|
+
},
|
|
7343
|
+
children: /* @__PURE__ */ u("form", { onSubmit: (event) => {
|
|
7344
|
+
event.preventDefault();
|
|
7345
|
+
const size = input.current?.valueAsNumber;
|
|
7346
|
+
if (size === void 0 || !Number.isFinite(size)) return;
|
|
7347
|
+
if (indices.some((index) => Math.abs(sizes[index] - size) >= 5e-3)) resize(indices, size);
|
|
7348
|
+
dismiss();
|
|
7349
|
+
}, children: [
|
|
7350
|
+
/* @__PURE__ */ u("div", { id: titleId, style: { fontSize: 15, fontWeight: 600, marginBottom: 12 }, children: title }),
|
|
7351
|
+
/* @__PURE__ */ u("label", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
|
|
7352
|
+
messages.pixels,
|
|
7353
|
+
/* @__PURE__ */ u(
|
|
7354
|
+
"input",
|
|
7355
|
+
{
|
|
7356
|
+
ref: input,
|
|
7357
|
+
type: "number",
|
|
7358
|
+
min: axis === "row" ? 16 : 30,
|
|
7359
|
+
max: Math.floor(maxSize),
|
|
7360
|
+
step: "any",
|
|
7361
|
+
required: true,
|
|
7362
|
+
value,
|
|
7363
|
+
onChange: (event) => setValue(event.currentTarget.value),
|
|
7364
|
+
style: {
|
|
7365
|
+
minWidth: 0,
|
|
7366
|
+
width: "100%",
|
|
7367
|
+
padding: "4px 8px",
|
|
7368
|
+
border: `1px solid ${palette.strongBorder}`,
|
|
7369
|
+
borderRadius: 4,
|
|
7370
|
+
background: palette.surface,
|
|
7371
|
+
color: palette.text,
|
|
7372
|
+
font: "inherit"
|
|
7373
|
+
}
|
|
7374
|
+
}
|
|
7375
|
+
)
|
|
7376
|
+
] }),
|
|
7377
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8, marginTop: 16 }, children: [
|
|
7378
|
+
/* @__PURE__ */ u("button", { type: "button", style: buttonStyle, onClick: dismiss, children: messages.cancel }),
|
|
7379
|
+
/* @__PURE__ */ u("button", { type: "submit", style: { ...buttonStyle, background: palette.text, color: palette.surface }, children: messages.ok })
|
|
7380
|
+
] })
|
|
7381
|
+
] })
|
|
7382
|
+
}
|
|
7383
|
+
),
|
|
7384
|
+
document.body
|
|
7385
|
+
);
|
|
7386
|
+
}
|
|
7387
|
+
|
|
7184
7388
|
// src/viewer-palette.ts
|
|
7185
7389
|
var LIGHT_PALETTE = {
|
|
7186
7390
|
border: "#e4e4e7",
|
|
@@ -7434,6 +7638,8 @@ function XlsxContextMenu({
|
|
|
7434
7638
|
closeMenu,
|
|
7435
7639
|
editCell,
|
|
7436
7640
|
selectExtent,
|
|
7641
|
+
canResize,
|
|
7642
|
+
editSize,
|
|
7437
7643
|
renderContextMenu,
|
|
7438
7644
|
contextMenuClassName,
|
|
7439
7645
|
contextMenuStyle
|
|
@@ -7454,15 +7660,38 @@ function XlsxContextMenu({
|
|
|
7454
7660
|
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
7661
|
const range = expandHighlightedRange(context.selection, controller.activeSheet?.mergedRanges ?? []);
|
|
7456
7662
|
const multiple = range.start.row !== range.end.row || range.start.col !== range.end.col;
|
|
7457
|
-
const
|
|
7663
|
+
const areas = context.selectionRanges ?? [range];
|
|
7664
|
+
const multiArea = areas.length > 1;
|
|
7665
|
+
const canCopy = !multiArea || Boolean(clipboardBands(areas));
|
|
7666
|
+
const touchesPivot = areas.some((area) => findIntersectingPivot(controller.pivotTables, controller.activeSheet?.name, area));
|
|
7458
7667
|
const pivot = controller.getPivotTableAtCell(context.cell);
|
|
7668
|
+
const cutCopy = [
|
|
7669
|
+
...!controller.readOnly ? [{ id: "cut", label: messages.cut, shortcut: `${modifier}X`, disabled: !canCopy || touchesPivot }] : [],
|
|
7670
|
+
{ id: "copy", label: messages.copy, shortcut: `${modifier}C`, disabled: !canCopy }
|
|
7671
|
+
];
|
|
7672
|
+
const paste = { id: "paste", label: messages.paste, shortcut: `${modifier}V`, disabled: multiArea || touchesPivot };
|
|
7673
|
+
const clearContents = { id: "clearContents", label: messages.clearContents, destructive: true, disabled: touchesPivot };
|
|
7674
|
+
const isHeader = context.kind === "row" || context.kind === "column";
|
|
7675
|
+
const row3 = context.kind === "row";
|
|
7676
|
+
const headerActions = [
|
|
7677
|
+
...cutCopy,
|
|
7678
|
+
...!controller.readOnly ? [paste, clearContents] : [],
|
|
7679
|
+
...canResize ? [{
|
|
7680
|
+
id: row3 ? "rowHeight" : "columnWidth",
|
|
7681
|
+
label: `${row3 ? messages.rowHeight : messages.columnWidth}\u2026`,
|
|
7682
|
+
separatorBefore: true
|
|
7683
|
+
}] : [],
|
|
7684
|
+
...!controller.readOnly ? [
|
|
7685
|
+
{ id: row3 ? "hideRows" : "hideColumns", label: messages.hide, separatorBefore: !canResize },
|
|
7686
|
+
{ id: row3 ? "unhideRows" : "unhideColumns", label: messages.unhide }
|
|
7687
|
+
] : []
|
|
7688
|
+
];
|
|
7459
7689
|
const cellActions = [
|
|
7460
|
-
|
|
7461
|
-
{ id: "copy", label: messages.copy, shortcut: `${modifier}C` },
|
|
7690
|
+
...cutCopy,
|
|
7462
7691
|
...!controller.readOnly ? [
|
|
7463
7692
|
{ id: "undo", label: messages.undo, shortcut: `${modifier}Z`, disabled: !controller.canUndo },
|
|
7464
7693
|
{ id: "redo", label: messages.redo, shortcut: `${modifier}\u21E7Z`, disabled: !controller.canRedo },
|
|
7465
|
-
{
|
|
7694
|
+
{ ...paste, separatorBefore: true }
|
|
7466
7695
|
] : [],
|
|
7467
7696
|
...pivot ? [{ id: "togglePivotFieldList", label: controller.pivotFieldListVisible ? messages.hidePivotFieldList : messages.showPivotFieldList, checked: controller.pivotFieldListVisible }] : [],
|
|
7468
7697
|
...pivot && !controller.readOnly ? [
|
|
@@ -7470,12 +7699,12 @@ function XlsxContextMenu({
|
|
|
7470
7699
|
{ id: "showPivotDetails", label: messages.showPivotDetails, disabled: pivot.unsupportedFeatures.length > 0 }
|
|
7471
7700
|
] : [],
|
|
7472
7701
|
...!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 },
|
|
7702
|
+
{ id: "editCell", label: messages.editCell, shortcut: "F2", separatorBefore: true, disabled: multiArea || touchesPivot },
|
|
7703
|
+
clearContents,
|
|
7704
|
+
{ id: "mergeAndCenter", label: messages.mergeAndCenter, separatorBefore: true, disabled: multiArea || !multiple || touchesPivot },
|
|
7705
|
+
{ id: "mergeAcross", label: messages.mergeAcross, disabled: multiArea || range.start.col === range.end.col || touchesPivot },
|
|
7706
|
+
{ id: "mergeCells", label: messages.mergeCells, disabled: multiArea || !multiple || touchesPivot },
|
|
7707
|
+
{ id: "unmergeCells", label: messages.unmergeCells, disabled: multiArea || touchesPivot },
|
|
7479
7708
|
...table ? [
|
|
7480
7709
|
{ id: "sortAscending", label: messages.sortAscending, separatorBefore: true },
|
|
7481
7710
|
{ id: "sortDescending", label: messages.sortDescending }
|
|
@@ -7528,7 +7757,7 @@ function XlsxContextMenu({
|
|
|
7528
7757
|
{ id: "sendBackward", label: "Send Backward", disabled: drawingDisabled || drawing.zIndex <= minOrder }
|
|
7529
7758
|
]
|
|
7530
7759
|
}
|
|
7531
|
-
] : cellActions;
|
|
7760
|
+
] : isHeader ? headerActions : cellActions;
|
|
7532
7761
|
const findAction = (items, id) => {
|
|
7533
7762
|
for (const item of items) {
|
|
7534
7763
|
if (item.disabled) continue;
|
|
@@ -7653,6 +7882,16 @@ function XlsxContextMenu({
|
|
|
7653
7882
|
case "sortDescending":
|
|
7654
7883
|
if (table) controller.sortTable(table.name, context.cell.col - table.start.col, id === "sortAscending" ? "ascending" : "descending");
|
|
7655
7884
|
break;
|
|
7885
|
+
case "rowHeight":
|
|
7886
|
+
case "columnWidth":
|
|
7887
|
+
editSize(id === "rowHeight" ? "row" : "column");
|
|
7888
|
+
return true;
|
|
7889
|
+
case "hideRows":
|
|
7890
|
+
case "unhideRows":
|
|
7891
|
+
case "hideColumns":
|
|
7892
|
+
case "unhideColumns":
|
|
7893
|
+
controller[id]();
|
|
7894
|
+
break;
|
|
7656
7895
|
case "selectRow":
|
|
7657
7896
|
selectExtent("row");
|
|
7658
7897
|
break;
|
|
@@ -9019,7 +9258,7 @@ function createChartModule(importModule) {
|
|
|
9019
9258
|
};
|
|
9020
9259
|
}
|
|
9021
9260
|
var officeChartRenderer = createChartModule(async () => {
|
|
9022
|
-
const { SharedChartSvg } = await import("./shared-chart-
|
|
9261
|
+
const { SharedChartSvg } = await import("./shared-chart-CGEK7EAB.js");
|
|
9023
9262
|
return { renderer: null, SharedChartSvg };
|
|
9024
9263
|
});
|
|
9025
9264
|
var suppliedOfficeChartRenderer = officeChartRenderer;
|
|
@@ -9132,7 +9371,7 @@ var OPEN_GRID_HORIZONTAL_EDGE_PX = 480;
|
|
|
9132
9371
|
var SELECTION_DRAG_THRESHOLD_PX = 4;
|
|
9133
9372
|
var IMAGE_MIN_SIZE_PX = 16;
|
|
9134
9373
|
var IMAGE_HANDLE_SIZE_PX = 10;
|
|
9135
|
-
var
|
|
9374
|
+
var HEADER_RESIZE_HANDLE_PX = 8;
|
|
9136
9375
|
var RESIZE_DRAG_THRESHOLD_PX = 3;
|
|
9137
9376
|
var CANVAS_VIEWPORT_OVERSCAN_PX = 480;
|
|
9138
9377
|
var CANVAS_SCROLL_BUFFER_PX = 480;
|
|
@@ -9160,6 +9399,7 @@ var CANVAS_TEXT_MEASURE_CACHE_LIMIT = 2e4;
|
|
|
9160
9399
|
var CANVAS_TEXT_TRUNCATE_CACHE_LIMIT = 4096;
|
|
9161
9400
|
var CANVAS_TEXT_WRAP_CACHE_LIMIT = 2048;
|
|
9162
9401
|
var CANVAS_PATH2D_CACHE_LIMIT = 512;
|
|
9402
|
+
var EMPTY_SELECTION_RANGES = [];
|
|
9163
9403
|
var EMPTY_VIRTUAL_ITEMS = [];
|
|
9164
9404
|
var IMAGE_HANDLE_CURSOR = {
|
|
9165
9405
|
e: "ew-resize",
|
|
@@ -10153,23 +10393,10 @@ function buildVisibleAxisIndices(precomputed, displayLimit, maxUsedIndex, hidden
|
|
|
10153
10393
|
if (displayLimit <= 0) {
|
|
10154
10394
|
return [];
|
|
10155
10395
|
}
|
|
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);
|
|
10396
|
+
const visible = precomputed.filter((index) => index < displayLimit);
|
|
10397
|
+
const appendStart = precomputed.length ? Math.max(0, maxUsedIndex + 1) : 0;
|
|
10398
|
+
for (let index = appendStart; index < displayLimit; index++) {
|
|
10399
|
+
if (!hiddenIndices?.has(index)) visible.push(index);
|
|
10173
10400
|
}
|
|
10174
10401
|
return visible;
|
|
10175
10402
|
}
|
|
@@ -14098,7 +14325,7 @@ function GridRow({
|
|
|
14098
14325
|
style: {
|
|
14099
14326
|
bottom: 0,
|
|
14100
14327
|
cursor: "row-resize",
|
|
14101
|
-
height:
|
|
14328
|
+
height: HEADER_RESIZE_HANDLE_PX,
|
|
14102
14329
|
left: 0,
|
|
14103
14330
|
position: "absolute",
|
|
14104
14331
|
width: "100%",
|
|
@@ -14546,6 +14773,8 @@ function XlsxGrid({
|
|
|
14546
14773
|
selectChartElement,
|
|
14547
14774
|
selectImage,
|
|
14548
14775
|
selectRange,
|
|
14776
|
+
selectRanges,
|
|
14777
|
+
selectionRanges,
|
|
14549
14778
|
selection,
|
|
14550
14779
|
setActiveSheetIndex,
|
|
14551
14780
|
setChartRect,
|
|
@@ -14639,8 +14868,6 @@ function XlsxGrid({
|
|
|
14639
14868
|
const activeCellRef = A(activeCell);
|
|
14640
14869
|
const selectedChartIdRef = A(selectedChartId);
|
|
14641
14870
|
const selectedImageIdRef = A(selectedImageId);
|
|
14642
|
-
const pendingSelectionCommitRef = A(null);
|
|
14643
|
-
const selectionCommitFrameRef = A(null);
|
|
14644
14871
|
const selectionRef = A(null);
|
|
14645
14872
|
const editingCellRef = A(null);
|
|
14646
14873
|
const editingOriginalValueRef = A(null);
|
|
@@ -14798,6 +15025,11 @@ function XlsxGrid({
|
|
|
14798
15025
|
[activeSheet?.mergedRanges, activeSheet?.workbookSheetIndex, highlightedRanges, mergedRegions]
|
|
14799
15026
|
);
|
|
14800
15027
|
const normalizedSelection = T(() => selection ? normalizeRange2(selection) : null, [selection]);
|
|
15028
|
+
const secondaryRanges = T(() => selectionRanges.length > 1 ? selectionRanges.slice(0, -1) : EMPTY_SELECTION_RANGES, [selectionRanges]);
|
|
15029
|
+
const selectionRangesRef = A(selectionRanges);
|
|
15030
|
+
_(() => {
|
|
15031
|
+
selectionRangesRef.current = selectionRanges;
|
|
15032
|
+
}, [selectionRanges]);
|
|
14801
15033
|
const zoomFactor = T(() => Math.max(0.1, zoomScale / 100), [zoomScale]);
|
|
14802
15034
|
const previousZoomFactorRef = A(zoomFactor);
|
|
14803
15035
|
const effectiveTables = tables;
|
|
@@ -15350,6 +15582,7 @@ function XlsxGrid({
|
|
|
15350
15582
|
);
|
|
15351
15583
|
}
|
|
15352
15584
|
for (let col = Math.max(0, (activeSheet?.maxUsedCol ?? -1) + 1); col < displayColLimit; col += 1) {
|
|
15585
|
+
if (hiddenColSet.has(col)) continue;
|
|
15353
15586
|
const overrideWidth = activeSheet?.colWidthOverridesPx[col];
|
|
15354
15587
|
widths[col] = overrideWidth === void 0 ? fallbackWidth : Math.max(resolveRenderedSheetAxisPixels(overrideWidth, showGridLines), DEFAULT_COL_WIDTH2 / 2);
|
|
15355
15588
|
}
|
|
@@ -15445,6 +15678,7 @@ function XlsxGrid({
|
|
|
15445
15678
|
);
|
|
15446
15679
|
}
|
|
15447
15680
|
for (let row3 = Math.max(0, (activeSheet?.maxUsedRow ?? -1) + 1); row3 < displayRowLimit; row3 += 1) {
|
|
15681
|
+
if (hiddenRowSet.has(row3)) continue;
|
|
15448
15682
|
const overrideHeight = activeSheet?.rowHeightOverridesPx[row3];
|
|
15449
15683
|
heights[row3] = overrideHeight === void 0 ? fallbackHeight : Math.max(resolveRenderedSheetAxisPixels(overrideHeight, showGridLines), DEFAULT_ROW_HEIGHT2 / 1.5);
|
|
15450
15684
|
}
|
|
@@ -15529,6 +15763,21 @@ function XlsxGrid({
|
|
|
15529
15763
|
const lastVisibleRow = visibleRows[visibleRows.length - 1];
|
|
15530
15764
|
const firstVisibleCol = visibleCols[0];
|
|
15531
15765
|
const lastVisibleCol = visibleCols[visibleCols.length - 1];
|
|
15766
|
+
const previousGridExtent = A({ activeTabIndex, lastVisibleRow, lastVisibleCol });
|
|
15767
|
+
_(() => {
|
|
15768
|
+
const previous = previousGridExtent.current;
|
|
15769
|
+
previousGridExtent.current = { activeTabIndex, lastVisibleRow, lastVisibleCol };
|
|
15770
|
+
if (previous.activeTabIndex !== activeTabIndex || !axisSelectionRef.current) return;
|
|
15771
|
+
const growRows = lastVisibleRow !== void 0 && previous.lastVisibleRow !== void 0 && lastVisibleRow > previous.lastVisibleRow;
|
|
15772
|
+
const growCols = lastVisibleCol !== void 0 && previous.lastVisibleCol !== void 0 && lastVisibleCol > previous.lastVisibleCol;
|
|
15773
|
+
if (!growRows && !growCols) return;
|
|
15774
|
+
const areas = selectionRanges.map((area) => {
|
|
15775
|
+
const row3 = growRows && area.start.row === firstVisibleRow && area.end.row === previous.lastVisibleRow ? lastVisibleRow : area.end.row;
|
|
15776
|
+
const col = growCols && area.start.col === firstVisibleCol && area.end.col === previous.lastVisibleCol ? lastVisibleCol : area.end.col;
|
|
15777
|
+
return row3 === area.end.row && col === area.end.col ? area : { start: area.start, end: { row: row3, col } };
|
|
15778
|
+
});
|
|
15779
|
+
if (areas.some((area, i) => area !== selectionRanges[i])) selectRanges(areas, "start");
|
|
15780
|
+
}, [activeTabIndex, firstVisibleCol, firstVisibleRow, lastVisibleCol, lastVisibleRow, selectionRanges, selectRanges]);
|
|
15532
15781
|
const displayedSelection = fillPreviewRange ?? normalizedSelection;
|
|
15533
15782
|
const toLogicalRect = q((rect) => ({
|
|
15534
15783
|
height: rect.height / zoomFactor,
|
|
@@ -15745,10 +15994,6 @@ function XlsxGrid({
|
|
|
15745
15994
|
imagePreviewRectRef.current = imagePreviewRect;
|
|
15746
15995
|
}, [imagePreviewRect]);
|
|
15747
15996
|
h(() => () => {
|
|
15748
|
-
if (selectionCommitFrameRef.current !== null) {
|
|
15749
|
-
window.cancelAnimationFrame(selectionCommitFrameRef.current);
|
|
15750
|
-
selectionCommitFrameRef.current = null;
|
|
15751
|
-
}
|
|
15752
15997
|
if (liveGestureZoomFrameRef.current !== null) {
|
|
15753
15998
|
window.cancelAnimationFrame(liveGestureZoomFrameRef.current);
|
|
15754
15999
|
liveGestureZoomFrameRef.current = null;
|
|
@@ -15901,34 +16146,38 @@ function XlsxGrid({
|
|
|
15901
16146
|
h(() => {
|
|
15902
16147
|
const selectionEndRow = normalizedSelection?.end.row ?? -1;
|
|
15903
16148
|
const selectionEndCol = normalizedSelection?.end.col ?? -1;
|
|
16149
|
+
const rowPadding = axisSelectionRef.current?.axis === "column" ? 0 : OPEN_GRID_ROW_PADDING;
|
|
16150
|
+
const colPadding = axisSelectionRef.current?.axis === "row" ? 0 : OPEN_GRID_COL_PADDING;
|
|
15904
16151
|
const nextRowLimit = Math.max(
|
|
15905
16152
|
resolveInitialDisplayExtent(
|
|
15906
16153
|
activeSheet?.maxUsedRow ?? -1,
|
|
15907
|
-
MIN_OPEN_GRID_ROWS,
|
|
16154
|
+
minimumVisibleExtent(MIN_OPEN_GRID_ROWS, activeSheet?.hiddenRows, XLSX_MAX_ROWS),
|
|
15908
16155
|
OPEN_GRID_ROW_PADDING,
|
|
15909
16156
|
false,
|
|
15910
16157
|
INITIAL_WORKER_GRID_ROWS
|
|
15911
16158
|
),
|
|
15912
|
-
(activeCell?.row ?? -1) +
|
|
15913
|
-
selectionEndRow +
|
|
16159
|
+
(activeCell?.row ?? -1) + rowPadding + 1,
|
|
16160
|
+
selectionEndRow + rowPadding + 1,
|
|
15914
16161
|
drawingExtents.maxRow + OPEN_GRID_ROW_PADDING + 1
|
|
15915
16162
|
);
|
|
15916
16163
|
const nextColLimit = Math.max(
|
|
15917
16164
|
resolveInitialDisplayExtent(
|
|
15918
16165
|
activeSheet?.maxUsedCol ?? -1,
|
|
15919
|
-
MIN_OPEN_GRID_COLS,
|
|
16166
|
+
minimumVisibleExtent(MIN_OPEN_GRID_COLS, activeSheet?.hiddenCols, XLSX_MAX_COLUMNS),
|
|
15920
16167
|
OPEN_GRID_COL_PADDING,
|
|
15921
16168
|
false,
|
|
15922
16169
|
INITIAL_WORKER_GRID_COLS
|
|
15923
16170
|
),
|
|
15924
|
-
(activeCell?.col ?? -1) +
|
|
15925
|
-
selectionEndCol +
|
|
16171
|
+
(activeCell?.col ?? -1) + colPadding + 1,
|
|
16172
|
+
selectionEndCol + colPadding + 1,
|
|
15926
16173
|
drawingExtents.maxCol + OPEN_GRID_COL_PADDING + 1
|
|
15927
16174
|
);
|
|
15928
16175
|
setDisplayRowLimit((current) => current < nextRowLimit ? nextRowLimit : current);
|
|
15929
16176
|
setDisplayColLimit((current) => current < nextColLimit ? nextColLimit : current);
|
|
15930
16177
|
}, [
|
|
15931
16178
|
activeCell,
|
|
16179
|
+
activeSheet?.hiddenRows,
|
|
16180
|
+
activeSheet?.hiddenCols,
|
|
15932
16181
|
activeSheet?.maxUsedCol,
|
|
15933
16182
|
activeSheet?.maxUsedRow,
|
|
15934
16183
|
drawingExtents.maxCol,
|
|
@@ -16656,7 +16905,6 @@ function XlsxGrid({
|
|
|
16656
16905
|
commitEditingRef.current = commitEditing;
|
|
16657
16906
|
}, [commitEditing]);
|
|
16658
16907
|
const [, startBatchTransition] = k();
|
|
16659
|
-
const [, startSelectionTransition] = k();
|
|
16660
16908
|
const [asyncViewportRowBatch, setAsyncViewportRowBatch] = d(null);
|
|
16661
16909
|
const viewportRequest = T(() => {
|
|
16662
16910
|
const rowIndices = experimentalCanvas ? (() => {
|
|
@@ -17124,26 +17372,22 @@ function XlsxGrid({
|
|
|
17124
17372
|
h(() => {
|
|
17125
17373
|
conditionalFormatMetricsCacheRef.current.clear();
|
|
17126
17374
|
}, [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) {
|
|
17375
|
+
const getSelectionOverlay = q((range) => {
|
|
17376
|
+
if (!range) {
|
|
17137
17377
|
return null;
|
|
17138
17378
|
}
|
|
17379
|
+
const rows = getHighlightAxisExtent(visibleRows, rowPrefixSums, range.start.row, range.end.row);
|
|
17380
|
+
const cols = getHighlightAxisExtent(visibleCols, colPrefixSums, range.start.col, range.end.col);
|
|
17381
|
+
if (!rows || !cols) return null;
|
|
17139
17382
|
return {
|
|
17140
|
-
height:
|
|
17141
|
-
left: displayRowHeaderWidth +
|
|
17142
|
-
top: displayHeaderHeight +
|
|
17143
|
-
width:
|
|
17383
|
+
height: rows.end - rows.start,
|
|
17384
|
+
left: displayRowHeaderWidth + cols.start,
|
|
17385
|
+
top: displayHeaderHeight + rows.start,
|
|
17386
|
+
width: cols.end - cols.start
|
|
17144
17387
|
};
|
|
17145
|
-
}, [
|
|
17146
|
-
const resolvedSelectionOverlay =
|
|
17388
|
+
}, [colPrefixSums, displayHeaderHeight, displayRowHeaderWidth, rowPrefixSums, visibleRows, visibleCols]);
|
|
17389
|
+
const resolvedSelectionOverlay = T(() => getSelectionOverlay(displayedSelection), [displayedSelection, getSelectionOverlay]);
|
|
17390
|
+
const secondaryOverlays = T(() => secondaryRanges.map(getSelectionOverlay), [secondaryRanges, getSelectionOverlay]);
|
|
17147
17391
|
const rangeHighlightRects = T(() => highlightedCellRanges.map(({ highlight, index, range }) => {
|
|
17148
17392
|
const rows = getHighlightAxisExtent(visibleRows, rowPrefixSums, range.start.row, range.end.row);
|
|
17149
17393
|
const cols = getHighlightAxisExtent(visibleCols, colPrefixSums, range.start.col, range.end.col);
|
|
@@ -17741,18 +17985,19 @@ function XlsxGrid({
|
|
|
17741
17985
|
observer.observe(scroller);
|
|
17742
17986
|
return () => observer.disconnect();
|
|
17743
17987
|
}, [contextMenuClassName, contextMenuStyle, displayRowHeaderWidth, openTableMenuState, renderTableHeaderMenu, zoomFactor]);
|
|
17988
|
+
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
17989
|
const applyHeaderSelection = q((range) => {
|
|
17745
17990
|
if (experimentalCanvas) {
|
|
17746
17991
|
return;
|
|
17747
17992
|
}
|
|
17748
17993
|
const normalized = range ? normalizeRange2(range) : null;
|
|
17749
17994
|
rowHeaderCellRefs.current.forEach((element, actualRow) => {
|
|
17750
|
-
element.style.backgroundColor =
|
|
17995
|
+
element.style.backgroundColor = headerIsSelected("row", actualRow, normalized) ? "var(--xlsx-selection-header)" : palette.rowHeaderSurface;
|
|
17751
17996
|
});
|
|
17752
17997
|
colHeaderCellRefs.current.forEach((element, actualCol) => {
|
|
17753
|
-
element.style.backgroundColor =
|
|
17998
|
+
element.style.backgroundColor = headerIsSelected("col", actualCol, normalized) ? "var(--xlsx-selection-header)" : palette.headerSurface;
|
|
17754
17999
|
});
|
|
17755
|
-
}, [experimentalCanvas, palette.headerSurface, palette.rowHeaderSurface]);
|
|
18000
|
+
}, [experimentalCanvas, headerIsSelected, palette.headerSurface, palette.rowHeaderSurface]);
|
|
17756
18001
|
const setRowHeaderRef = q((actualRow, element) => {
|
|
17757
18002
|
if (experimentalCanvas) {
|
|
17758
18003
|
rowHeaderCellRefs.current.delete(actualRow);
|
|
@@ -17761,11 +18006,11 @@ function XlsxGrid({
|
|
|
17761
18006
|
if (element) {
|
|
17762
18007
|
rowHeaderCellRefs.current.set(actualRow, element);
|
|
17763
18008
|
const range = selectionPreviewRangeRef.current ?? displayedSelectionRef.current;
|
|
17764
|
-
element.style.backgroundColor =
|
|
18009
|
+
element.style.backgroundColor = headerIsSelected("row", actualRow, range) ? "var(--xlsx-selection-header)" : palette.rowHeaderSurface;
|
|
17765
18010
|
return;
|
|
17766
18011
|
}
|
|
17767
18012
|
rowHeaderCellRefs.current.delete(actualRow);
|
|
17768
|
-
}, [experimentalCanvas, palette.rowHeaderSurface]);
|
|
18013
|
+
}, [experimentalCanvas, headerIsSelected, palette.rowHeaderSurface]);
|
|
17769
18014
|
const setColHeaderRef = q((actualCol, element) => {
|
|
17770
18015
|
if (experimentalCanvas) {
|
|
17771
18016
|
colHeaderCellRefs.current.delete(actualCol);
|
|
@@ -17774,11 +18019,11 @@ function XlsxGrid({
|
|
|
17774
18019
|
if (element) {
|
|
17775
18020
|
colHeaderCellRefs.current.set(actualCol, element);
|
|
17776
18021
|
const range = selectionPreviewRangeRef.current ?? displayedSelectionRef.current;
|
|
17777
|
-
element.style.backgroundColor =
|
|
18022
|
+
element.style.backgroundColor = headerIsSelected("col", actualCol, range) ? "var(--xlsx-selection-header)" : palette.headerSurface;
|
|
17778
18023
|
return;
|
|
17779
18024
|
}
|
|
17780
18025
|
colHeaderCellRefs.current.delete(actualCol);
|
|
17781
|
-
}, [experimentalCanvas, palette.headerSurface]);
|
|
18026
|
+
}, [experimentalCanvas, headerIsSelected, palette.headerSurface]);
|
|
17782
18027
|
const applyPreviewOverlay = q((range, options2) => {
|
|
17783
18028
|
const overlays = experimentalCanvas ? [...selectionPaneOverlayRefs.current.values()] : [selectionOverlayRef.current];
|
|
17784
18029
|
if (!range) {
|
|
@@ -17867,28 +18112,12 @@ function XlsxGrid({
|
|
|
17867
18112
|
const commitSelectionRange = q((range) => {
|
|
17868
18113
|
gridKeyboardActiveRef.current = true;
|
|
17869
18114
|
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) {
|
|
18115
|
+
if (selectionRangesRef.current.length === 1 && selectionRef.current && rangesEqual(selectionRef.current, normalized) && isSameCell(activeCellRef.current, normalized.end) && selectedChartIdRef.current === null && selectedImageIdRef.current === null) {
|
|
17875
18116
|
return;
|
|
17876
18117
|
}
|
|
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]);
|
|
18118
|
+
selectionRangesRef.current = [normalized];
|
|
18119
|
+
selectRange(normalized);
|
|
18120
|
+
}, [selectRange]);
|
|
17892
18121
|
const refreshOverlayFromCurrentSelection = q(() => {
|
|
17893
18122
|
if (displayedSelectionRef.current) {
|
|
17894
18123
|
applyPreviewOverlay(displayedSelectionRef.current);
|
|
@@ -18012,6 +18241,27 @@ function XlsxGrid({
|
|
|
18012
18241
|
}
|
|
18013
18242
|
return resolveCellSelectionRange({ start: dragState.anchor, end: cell });
|
|
18014
18243
|
}
|
|
18244
|
+
function commitHeaderSelection(gesture, range, axis) {
|
|
18245
|
+
const areas = gesture.remove ? gesture.base.flatMap((area) => subtractRange(area, range)) : [...gesture.base, range];
|
|
18246
|
+
const active = areas.at(-1);
|
|
18247
|
+
axisSelectionRef.current = null;
|
|
18248
|
+
if (active) {
|
|
18249
|
+
const isFullRow = active.start.col === firstVisibleCol && active.end.col === lastVisibleCol;
|
|
18250
|
+
const isFullColumn = active.start.row === firstVisibleRow && active.end.row === lastVisibleRow;
|
|
18251
|
+
if (isFullRow && (axis === "row" || !isFullColumn)) {
|
|
18252
|
+
const startRow = gesture.remove ? active.start.row : gesture.anchor;
|
|
18253
|
+
axisSelectionRef.current = { axis: "row", startRow, endRow: startRow === active.start.row ? active.end.row : active.start.row };
|
|
18254
|
+
} else if (isFullColumn) {
|
|
18255
|
+
const startCol = gesture.remove ? active.start.col : gesture.anchor;
|
|
18256
|
+
axisSelectionRef.current = { axis: "column", startCol, endCol: startCol === active.start.col ? active.end.col : active.start.col };
|
|
18257
|
+
}
|
|
18258
|
+
}
|
|
18259
|
+
selectionPreviewRangeRef.current = null;
|
|
18260
|
+
displayedSelectionRef.current = active ?? null;
|
|
18261
|
+
selectionRangesRef.current = areas;
|
|
18262
|
+
gridKeyboardActiveRef.current = true;
|
|
18263
|
+
selectRanges(areas, "start");
|
|
18264
|
+
}
|
|
18015
18265
|
function updateSelectionDragPreview(clientX, clientY) {
|
|
18016
18266
|
const dragState = selectionDragRef.current;
|
|
18017
18267
|
if (!dragState) {
|
|
@@ -18026,6 +18276,10 @@ function XlsxGrid({
|
|
|
18026
18276
|
return;
|
|
18027
18277
|
}
|
|
18028
18278
|
dragState.previewRange = nextRange;
|
|
18279
|
+
if (dragState.headerGesture && dragState.axis !== "cell") {
|
|
18280
|
+
commitHeaderSelection(dragState.headerGesture, nextRange, dragState.axis);
|
|
18281
|
+
return;
|
|
18282
|
+
}
|
|
18029
18283
|
selectionPreviewRangeRef.current = nextRange;
|
|
18030
18284
|
displayedSelectionRef.current = nextRange;
|
|
18031
18285
|
applyPreviewOverlay(nextRange);
|
|
@@ -18052,8 +18306,10 @@ function XlsxGrid({
|
|
|
18052
18306
|
cachedScrollerRectRef.current = scrollRef.current?.getBoundingClientRect() ?? null;
|
|
18053
18307
|
pendingState.didDrag = true;
|
|
18054
18308
|
selectionDragRef.current = pendingState;
|
|
18055
|
-
|
|
18056
|
-
|
|
18309
|
+
if (!pendingState.headerGesture) {
|
|
18310
|
+
selectionPreviewRangeRef.current = pendingState.previewRange;
|
|
18311
|
+
displayedSelectionRef.current = pendingState.previewRange;
|
|
18312
|
+
}
|
|
18057
18313
|
setInteractionMode("select");
|
|
18058
18314
|
document.body.style.userSelect = "none";
|
|
18059
18315
|
installSelectionDragListeners(pendingState.pointerId);
|
|
@@ -18159,26 +18415,14 @@ function XlsxGrid({
|
|
|
18159
18415
|
}
|
|
18160
18416
|
selectionDragRef.current = null;
|
|
18161
18417
|
cachedScrollerRectRef.current = null;
|
|
18162
|
-
if (nextRange &&
|
|
18418
|
+
if (nextRange && dragState?.headerGesture && dragState.axis !== "cell") {
|
|
18419
|
+
if (!rangesEqual(nextRange, dragState.previewRange)) {
|
|
18420
|
+
commitHeaderSelection(dragState.headerGesture, nextRange, dragState.axis);
|
|
18421
|
+
}
|
|
18422
|
+
} else if (nextRange && (dragState?.didDrag || !dragState?.committedOnPointerDown)) {
|
|
18163
18423
|
selectionPreviewRangeRef.current = nextRange;
|
|
18164
18424
|
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
|
-
}
|
|
18425
|
+
axisSelectionRef.current = null;
|
|
18182
18426
|
commitSelectionRange(nextRange);
|
|
18183
18427
|
} else if (!nextRange) {
|
|
18184
18428
|
selectionPreviewRangeRef.current = null;
|
|
@@ -18303,26 +18547,28 @@ function XlsxGrid({
|
|
|
18303
18547
|
function selectContextExtent(kind, range) {
|
|
18304
18548
|
const nextRange = getContextExtent(kind, range);
|
|
18305
18549
|
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
|
-
|
|
18550
|
+
selectRanges([nextRange], "start");
|
|
18307
18551
|
}
|
|
18308
18552
|
function openContextMenu(cell, kind, position) {
|
|
18309
18553
|
if (!enableContextMenu || !activeSheet) return;
|
|
18310
18554
|
if (kind === "cell") cell = resolveMergeAnchorCell(cell);
|
|
18311
18555
|
if (editingCellRef.current) commitEditingRef.current();
|
|
18312
18556
|
const current = normalizedSelection;
|
|
18313
|
-
const inside =
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18557
|
+
const inside = selectionRanges.some((area) => isCellInRange(cell, area));
|
|
18558
|
+
const target = { start: cell, end: cell };
|
|
18559
|
+
const extent = kind === "cell" ? target : getContextExtent(kind, target);
|
|
18560
|
+
const preserve = kind === "cell" ? inside : selectionCoversRange(selectionRanges, extent);
|
|
18561
|
+
let range = preserve && current ? current : target;
|
|
18562
|
+
if (kind !== "cell" && !preserve) {
|
|
18563
|
+
range = extent;
|
|
18318
18564
|
selectContextExtent(kind, range);
|
|
18319
|
-
} else if (!
|
|
18565
|
+
} else if (!preserve) {
|
|
18320
18566
|
axisSelectionRef.current = null;
|
|
18321
18567
|
selectCell(cell);
|
|
18322
18568
|
}
|
|
18323
18569
|
setOpenTableMenu(null);
|
|
18324
18570
|
setContextMenu({
|
|
18325
|
-
context: { kind, cell, selection: range, sheetIndex: activeSheetIndex, sheetName: activeSheet.name, readOnly },
|
|
18571
|
+
context: { kind, cell, selection: range, selectionRanges: preserve ? selectionRanges : [range], sheetIndex: activeSheetIndex, sheetName: activeSheet.name, readOnly },
|
|
18326
18572
|
position
|
|
18327
18573
|
});
|
|
18328
18574
|
}
|
|
@@ -18409,70 +18655,64 @@ function XlsxGrid({
|
|
|
18409
18655
|
resolveMergeAnchorCell,
|
|
18410
18656
|
resolvePointerCellFromGeometry
|
|
18411
18657
|
]);
|
|
18412
|
-
|
|
18413
|
-
|
|
18414
|
-
|
|
18415
|
-
|
|
18658
|
+
function startHeaderSelection(event, axis, index, pointerOrigin) {
|
|
18659
|
+
const first = axis === "row" ? firstVisibleCol : firstVisibleRow;
|
|
18660
|
+
const last = axis === "row" ? lastVisibleCol : lastVisibleRow;
|
|
18661
|
+
if (!pointerOrigin || first === void 0 || last === void 0) return;
|
|
18662
|
+
if (event.ctrlKey && /Mac|iPad|iPhone/.test(navigator.platform)) return;
|
|
18416
18663
|
event.preventDefault();
|
|
18417
18664
|
focusGrid();
|
|
18418
|
-
|
|
18419
|
-
const
|
|
18420
|
-
const
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
|
|
18665
|
+
if (editingCellRef.current) commitEditingRef.current();
|
|
18666
|
+
const areas = selectionRangesRef.current;
|
|
18667
|
+
const coordinate = axis === "row" ? "row" : "col";
|
|
18668
|
+
const activeAxis = axisSelectionRef.current;
|
|
18669
|
+
const active = areas.at(-1);
|
|
18670
|
+
let anchorIndex = index;
|
|
18671
|
+
if (event.shiftKey && active) {
|
|
18672
|
+
anchorIndex = active.start[coordinate];
|
|
18673
|
+
if (activeAxis?.axis === "row" && axis === "row") anchorIndex = activeAxis.startRow;
|
|
18674
|
+
if (activeAxis?.axis === "column" && axis === "column") anchorIndex = activeAxis.startCol;
|
|
18675
|
+
}
|
|
18676
|
+
const cell = (along, across) => axis === "row" ? { row: along, col: across } : { row: across, col: along };
|
|
18677
|
+
const range = normalizeRange2({ start: cell(anchorIndex, first), end: cell(index, last) });
|
|
18678
|
+
const additive = event.metaKey || event.ctrlKey;
|
|
18679
|
+
const base = additive ? areas : event.shiftKey ? areas.slice(0, -1) : [];
|
|
18680
|
+
const headerGesture = { anchor: anchorIndex, base, remove: additive && !event.shiftKey && selectionCoversRange(base, range) };
|
|
18428
18681
|
startCellSelection(
|
|
18429
18682
|
event.currentTarget,
|
|
18430
18683
|
event.pointerId,
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
18684
|
+
cell(anchorIndex, first),
|
|
18685
|
+
axis,
|
|
18686
|
+
cell(index, first),
|
|
18434
18687
|
pointerOrigin,
|
|
18435
18688
|
null,
|
|
18436
18689
|
true,
|
|
18437
|
-
|
|
18690
|
+
range,
|
|
18438
18691
|
event.clientX,
|
|
18439
|
-
event.clientY
|
|
18692
|
+
event.clientY,
|
|
18693
|
+
headerGesture
|
|
18440
18694
|
);
|
|
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 },
|
|
18695
|
+
}
|
|
18696
|
+
const startHeaderSelectionRef = A(startHeaderSelection);
|
|
18697
|
+
startHeaderSelectionRef.current = startHeaderSelection;
|
|
18698
|
+
const handleRowPointerDown = q((event, actualRow) => {
|
|
18699
|
+
if (event.button !== 0) return;
|
|
18700
|
+
startHeaderSelectionRef.current(
|
|
18701
|
+
event,
|
|
18702
|
+
"row",
|
|
18703
|
+
actualRow,
|
|
18704
|
+
resolveRowPointerOrigin(actualRow, event.currentTarget.getBoundingClientRect(), event.clientY)
|
|
18705
|
+
);
|
|
18706
|
+
}, [resolveRowPointerOrigin]);
|
|
18707
|
+
const handleColumnPointerDown = (event, actualCol) => {
|
|
18708
|
+
if (event.button !== 0) return;
|
|
18709
|
+
startHeaderSelection(
|
|
18710
|
+
event,
|
|
18464
18711
|
"column",
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
null,
|
|
18468
|
-
true,
|
|
18469
|
-
initialRange,
|
|
18470
|
-
event.clientX,
|
|
18471
|
-
event.clientY
|
|
18712
|
+
actualCol,
|
|
18713
|
+
resolveColumnPointerOrigin(actualCol, event.currentTarget.getBoundingClientRect(), event.clientX)
|
|
18472
18714
|
);
|
|
18473
|
-
|
|
18474
|
-
commitSelectionRange(initialRange);
|
|
18475
|
-
}, [commitSelectionRange, firstVisibleRow, focusGrid, lastVisibleRow, resolveColumnPointerOrigin]);
|
|
18715
|
+
};
|
|
18476
18716
|
const handleRowResizePointerDown = q((event, actualRow, rowHeight) => {
|
|
18477
18717
|
if (!canResizeHeaders) {
|
|
18478
18718
|
return;
|
|
@@ -18804,7 +19044,7 @@ function XlsxGrid({
|
|
|
18804
19044
|
}
|
|
18805
19045
|
const localX = clientX - scrollerRect.left;
|
|
18806
19046
|
for (const column of canvasColumnHeaderCells) {
|
|
18807
|
-
if (Math.abs(localX - (column.left + column.width)) <=
|
|
19047
|
+
if (Math.abs(localX - (column.left + column.width)) <= HEADER_RESIZE_HANDLE_PX / 2) {
|
|
18808
19048
|
return { actualCol: column.actualCol, width: column.width };
|
|
18809
19049
|
}
|
|
18810
19050
|
}
|
|
@@ -18841,7 +19081,7 @@ function XlsxGrid({
|
|
|
18841
19081
|
}
|
|
18842
19082
|
const localY = clientY - scrollerRect.top;
|
|
18843
19083
|
for (const row3 of canvasRowHeaderCells) {
|
|
18844
|
-
if (Math.abs(localY - (row3.top + row3.height)) <=
|
|
19084
|
+
if (Math.abs(localY - (row3.top + row3.height)) <= HEADER_RESIZE_HANDLE_PX / 2) {
|
|
18845
19085
|
return { actualRow: row3.actualRow, height: row3.height };
|
|
18846
19086
|
}
|
|
18847
19087
|
}
|
|
@@ -18996,7 +19236,7 @@ function XlsxGrid({
|
|
|
18996
19236
|
}
|
|
18997
19237
|
startEditing(cell, void 0, "double-click");
|
|
18998
19238
|
}, [readOnly, resolvePointerCellFromClient, startEditing]);
|
|
18999
|
-
const handleCanvasColumnHeaderPointerDown =
|
|
19239
|
+
const handleCanvasColumnHeaderPointerDown = (event) => {
|
|
19000
19240
|
if (event.button !== 0 || firstVisibleRow === void 0 || lastVisibleRow === void 0) {
|
|
19001
19241
|
return;
|
|
19002
19242
|
}
|
|
@@ -19011,51 +19251,16 @@ function XlsxGrid({
|
|
|
19011
19251
|
if (actualCol === null) {
|
|
19012
19252
|
return;
|
|
19013
19253
|
}
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19254
|
+
const index = colIndexByActual.get(actualCol);
|
|
19255
|
+
if (index === void 0) return;
|
|
19256
|
+
startHeaderSelection(event, "column", actualCol, {
|
|
19257
|
+
contentScaleX: 1,
|
|
19258
|
+
contentScaleY: 1,
|
|
19259
|
+
originContentX: colPrefixSums[index] ?? 0,
|
|
19260
|
+
originContentY: rowPrefixSums[0] ?? 0
|
|
19021
19261
|
});
|
|
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) => {
|
|
19262
|
+
};
|
|
19263
|
+
const handleCanvasRowHeaderPointerDown = (event) => {
|
|
19059
19264
|
if (event.button !== 0 || firstVisibleCol === void 0 || lastVisibleCol === void 0) {
|
|
19060
19265
|
return;
|
|
19061
19266
|
}
|
|
@@ -19070,50 +19275,15 @@ function XlsxGrid({
|
|
|
19070
19275
|
if (actualRow === null) {
|
|
19071
19276
|
return;
|
|
19072
19277
|
}
|
|
19073
|
-
|
|
19074
|
-
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
|
|
19078
|
-
|
|
19079
|
-
|
|
19278
|
+
const index = rowIndexByActual.get(actualRow);
|
|
19279
|
+
if (index === void 0) return;
|
|
19280
|
+
startHeaderSelection(event, "row", actualRow, {
|
|
19281
|
+
contentScaleX: 1,
|
|
19282
|
+
contentScaleY: 1,
|
|
19283
|
+
originContentX: colPrefixSums[0] ?? 0,
|
|
19284
|
+
originContentY: rowPrefixSums[index] ?? 0
|
|
19080
19285
|
});
|
|
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
|
-
]);
|
|
19286
|
+
};
|
|
19117
19287
|
const getCanvasImage = q((image) => {
|
|
19118
19288
|
if (typeof Image === "undefined") {
|
|
19119
19289
|
return null;
|
|
@@ -19189,7 +19359,7 @@ function XlsxGrid({
|
|
|
19189
19359
|
const rowHeaderWidth = Math.min(displayRowHeaderWidth, bodyWidth);
|
|
19190
19360
|
const visibleRange = selectionPreviewRangeRef.current ?? displayedSelection;
|
|
19191
19361
|
const normalizedVisibleRange = visibleRange ? normalizeRange2(visibleRange) : null;
|
|
19192
|
-
const rangeSignature = buildRangeSignature(
|
|
19362
|
+
const rangeSignature = [...secondaryRanges, normalizedVisibleRange].map(buildRangeSignature).join("|");
|
|
19193
19363
|
const nextBodyCanvasSignature = {
|
|
19194
19364
|
activeSheet: activeSheet ?? null,
|
|
19195
19365
|
bakedDrawingSignature: bakedCanvasDrawingSignature,
|
|
@@ -20100,7 +20270,7 @@ function XlsxGrid({
|
|
|
20100
20270
|
if (!column.isFrozen && !intersectsCanvasDirtyRects(column.localLeft, 0, column.width, column.height, topScrollHeaderDirtyRects)) {
|
|
20101
20271
|
continue;
|
|
20102
20272
|
}
|
|
20103
|
-
const selected =
|
|
20273
|
+
const selected = headerIsSelected("col", column.actualCol, normalizedVisibleRange);
|
|
20104
20274
|
paneContext.fillStyle = selected ? selectionHeaderSurface : palette.headerSurface;
|
|
20105
20275
|
paneContext.fillRect(column.localLeft, 0, column.width, column.height);
|
|
20106
20276
|
paneContext.strokeStyle = palette.border;
|
|
@@ -20149,7 +20319,7 @@ function XlsxGrid({
|
|
|
20149
20319
|
if (!row3.isFrozen && !intersectsCanvasDirtyRects(0, row3.localTop, rowHeaderWidth, row3.height, leftScrollHeaderDirtyRects)) {
|
|
20150
20320
|
continue;
|
|
20151
20321
|
}
|
|
20152
|
-
const selected =
|
|
20322
|
+
const selected = headerIsSelected("row", row3.actualRow, normalizedVisibleRange);
|
|
20153
20323
|
paneContext.fillStyle = selected ? selectionHeaderSurface : palette.rowHeaderSurface;
|
|
20154
20324
|
paneContext.fillRect(0, row3.localTop, rowHeaderWidth, row3.height);
|
|
20155
20325
|
paneContext.beginPath();
|
|
@@ -20239,6 +20409,8 @@ function XlsxGrid({
|
|
|
20239
20409
|
rowIndexByActual,
|
|
20240
20410
|
rowPrefixSums,
|
|
20241
20411
|
selectionHeaderSurface,
|
|
20412
|
+
headerIsSelected,
|
|
20413
|
+
secondaryRanges,
|
|
20242
20414
|
sortState,
|
|
20243
20415
|
shouldBakeCanvasStaticDrawings,
|
|
20244
20416
|
stickyLeftByCol,
|
|
@@ -20544,7 +20716,7 @@ function XlsxGrid({
|
|
|
20544
20716
|
position: "absolute",
|
|
20545
20717
|
right: 0,
|
|
20546
20718
|
top: 0,
|
|
20547
|
-
width:
|
|
20719
|
+
width: HEADER_RESIZE_HANDLE_PX,
|
|
20548
20720
|
height: "100%",
|
|
20549
20721
|
zIndex: 5
|
|
20550
20722
|
}, zoomFactor);
|
|
@@ -21654,10 +21826,11 @@ function XlsxGrid({
|
|
|
21654
21826
|
setInteractionMode("select");
|
|
21655
21827
|
setGlobalCursor("row-resize");
|
|
21656
21828
|
}
|
|
21657
|
-
function startCellSelection(target, pointerId, anchor, axis, originCell, pointerOrigin, originOverlayRect, committedOnPointerDown, initialRange, startClientX, startClientY) {
|
|
21829
|
+
function startCellSelection(target, pointerId, anchor, axis, originCell, pointerOrigin, originOverlayRect, committedOnPointerDown, initialRange, startClientX, startClientY, headerGesture) {
|
|
21658
21830
|
clearPendingSelectionDrag();
|
|
21659
21831
|
const previewRange = normalizeRange2(initialRange);
|
|
21660
21832
|
pendingSelectionDragRef.current = {
|
|
21833
|
+
headerGesture,
|
|
21661
21834
|
anchor,
|
|
21662
21835
|
axis,
|
|
21663
21836
|
contentScaleX: pointerOrigin.contentScaleX,
|
|
@@ -21673,9 +21846,13 @@ function XlsxGrid({
|
|
|
21673
21846
|
startClientX,
|
|
21674
21847
|
startClientY
|
|
21675
21848
|
};
|
|
21676
|
-
|
|
21677
|
-
|
|
21678
|
-
|
|
21849
|
+
if (headerGesture && axis !== "cell") {
|
|
21850
|
+
commitHeaderSelection(headerGesture, previewRange, axis);
|
|
21851
|
+
} else {
|
|
21852
|
+
selectionPreviewRangeRef.current = previewRange;
|
|
21853
|
+
displayedSelectionRef.current = previewRange;
|
|
21854
|
+
applyPreviewOverlay(previewRange);
|
|
21855
|
+
}
|
|
21679
21856
|
installPendingSelectionDragListeners(pointerId, target);
|
|
21680
21857
|
}
|
|
21681
21858
|
function resolveFillRange(sourceRange, cell) {
|
|
@@ -22051,10 +22228,27 @@ function XlsxGrid({
|
|
|
22051
22228
|
};
|
|
22052
22229
|
if (selectedChart) openDrawingContextMenu("chart", selectedChart, position);
|
|
22053
22230
|
else if (selectedImage) openDrawingContextMenu("image", selectedImage, position);
|
|
22054
|
-
else
|
|
22231
|
+
else {
|
|
22232
|
+
const axis = axisSelectionRef.current?.axis;
|
|
22233
|
+
const kind = axis && selectionCoversRange(selectionRanges, getContextExtent(axis, { start: cell, end: cell })) ? axis : "cell";
|
|
22234
|
+
if (kind === "row") position.x = rect.left + displayRowHeaderWidth;
|
|
22235
|
+
if (kind === "column") position.y = rect.top + displayHeaderHeight;
|
|
22236
|
+
openContextMenu(cell, kind, position);
|
|
22237
|
+
}
|
|
22055
22238
|
}
|
|
22056
22239
|
return;
|
|
22057
22240
|
}
|
|
22241
|
+
if (!readOnly && !selectedChart && !selectedImage && event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
22242
|
+
if (event.code === "Digit9" || event.code === "Digit0") {
|
|
22243
|
+
event.preventDefault();
|
|
22244
|
+
if (event.code === "Digit9") {
|
|
22245
|
+
if (event.shiftKey) controller.unhideRows();
|
|
22246
|
+
else controller.hideRows();
|
|
22247
|
+
} else if (event.shiftKey) controller.unhideColumns();
|
|
22248
|
+
else controller.hideColumns();
|
|
22249
|
+
return;
|
|
22250
|
+
}
|
|
22251
|
+
}
|
|
22058
22252
|
if (!readOnly && (event.metaKey || event.ctrlKey) && !event.altKey) {
|
|
22059
22253
|
const normalizedKey = event.key.toLowerCase();
|
|
22060
22254
|
if (normalizedKey === "z" && event.shiftKey) {
|
|
@@ -22261,6 +22455,11 @@ function XlsxGrid({
|
|
|
22261
22455
|
const clipboard = event.clipboardData;
|
|
22262
22456
|
const clipboardData = getClipboardData();
|
|
22263
22457
|
if (!clipboardData) {
|
|
22458
|
+
if (controller.isWorkerBacked) {
|
|
22459
|
+
event.preventDefault();
|
|
22460
|
+
void copySelectionToClipboard().catch(() => {
|
|
22461
|
+
});
|
|
22462
|
+
}
|
|
22264
22463
|
return;
|
|
22265
22464
|
}
|
|
22266
22465
|
event.preventDefault();
|
|
@@ -22421,6 +22620,14 @@ function XlsxGrid({
|
|
|
22421
22620
|
});
|
|
22422
22621
|
function renderSelectionOverlay(pane) {
|
|
22423
22622
|
return /* @__PURE__ */ u("div", { style: { display: editingCell ? "none" : "contents" }, children: [
|
|
22623
|
+
secondaryOverlays.map((rect, i) => rect && /* @__PURE__ */ u("div", { "data-xlsx-selection-area": "", style: {
|
|
22624
|
+
...rect,
|
|
22625
|
+
backgroundColor: selectionFill,
|
|
22626
|
+
boxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
|
|
22627
|
+
pointerEvents: "none",
|
|
22628
|
+
position: "absolute",
|
|
22629
|
+
zIndex: 24
|
|
22630
|
+
} }, buildRangeSignature(secondaryRanges[i]))),
|
|
22424
22631
|
/* @__PURE__ */ u(
|
|
22425
22632
|
"div",
|
|
22426
22633
|
{
|
|
@@ -22475,7 +22682,7 @@ function XlsxGrid({
|
|
|
22475
22682
|
boxSizing: "border-box",
|
|
22476
22683
|
contain: "layout paint",
|
|
22477
22684
|
cursor: "crosshair",
|
|
22478
|
-
display: !readOnly && resolvedSelectionOverlay ? "block" : "none",
|
|
22685
|
+
display: !readOnly && !secondaryRanges.length && resolvedSelectionOverlay ? "block" : "none",
|
|
22479
22686
|
height: 8,
|
|
22480
22687
|
left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 : 0,
|
|
22481
22688
|
pointerEvents: "auto",
|
|
@@ -23170,7 +23377,7 @@ function XlsxGrid({
|
|
|
23170
23377
|
);
|
|
23171
23378
|
return /* @__PURE__ */ u("div", { style: { backgroundColor: palette.canvas, display: "flex", flex: 1, minHeight: 0, minWidth: 0 }, children: [
|
|
23172
23379
|
renderScroller ? renderScroller({ children: scrollerContent, viewportProps: scrollerViewportProps }) : /* @__PURE__ */ u("div", { ...scrollerViewportProps, children: scrollerContent }, activeTabIndex),
|
|
23173
|
-
renderSelectionPopover && normalizedSelection && activeCell && !isLoading && interactionMode === "idle" && !contextMenu && /* @__PURE__ */ u(
|
|
23380
|
+
renderSelectionPopover && !secondaryRanges.length && normalizedSelection && activeCell && !isLoading && interactionMode === "idle" && !contextMenu && /* @__PURE__ */ u(
|
|
23174
23381
|
SelectionPopover,
|
|
23175
23382
|
{
|
|
23176
23383
|
context: { cell: resolveMergeAnchorCell(activeCell), selection: normalizedSelection, sheetIndex: activeSheetIndex, sheetName: activeSheet?.name ?? "", readOnly },
|
|
@@ -23213,13 +23420,28 @@ function XlsxGrid({
|
|
|
23213
23420
|
},
|
|
23214
23421
|
`${activeSheetIndex}:${editingCell?.row}:${editingCell?.col}`
|
|
23215
23422
|
),
|
|
23216
|
-
enableContextMenu && contextMenu && /* @__PURE__ */ u(
|
|
23423
|
+
enableContextMenu && contextMenu && (contextMenu.sizeAxis ? /* @__PURE__ */ u(
|
|
23424
|
+
HeaderSizeDialog,
|
|
23425
|
+
{
|
|
23426
|
+
axis: contextMenu.sizeAxis,
|
|
23427
|
+
context: contextMenu.context,
|
|
23428
|
+
sizes: contextMenu.sizeAxis === "row" ? actualRowHeights : actualColWidths,
|
|
23429
|
+
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),
|
|
23430
|
+
messages,
|
|
23431
|
+
locale,
|
|
23432
|
+
palette,
|
|
23433
|
+
close: closeContextMenu,
|
|
23434
|
+
resize: contextMenu.sizeAxis === "row" ? controller.resizeRow : controller.resizeColumn
|
|
23435
|
+
}
|
|
23436
|
+
) : /* @__PURE__ */ u(
|
|
23217
23437
|
XlsxContextMenu,
|
|
23218
23438
|
{
|
|
23219
23439
|
...contextMenu,
|
|
23220
23440
|
controller,
|
|
23221
23441
|
palette,
|
|
23222
23442
|
closeMenu: closeContextMenu,
|
|
23443
|
+
canResize: canResizeHeaders,
|
|
23444
|
+
editSize: (axis) => setContextMenu({ ...contextMenu, sizeAxis: axis }),
|
|
23223
23445
|
editCell: () => startEditing(contextMenu.context.cell, void 0, "context-menu"),
|
|
23224
23446
|
selectExtent: (kind) => selectContextExtent(kind, contextMenu.context.selection),
|
|
23225
23447
|
renderContextMenu,
|
|
@@ -23227,7 +23449,7 @@ function XlsxGrid({
|
|
|
23227
23449
|
contextMenuStyle
|
|
23228
23450
|
},
|
|
23229
23451
|
`${contextMenu.position.x}:${contextMenu.position.y}`
|
|
23230
|
-
)
|
|
23452
|
+
))
|
|
23231
23453
|
] });
|
|
23232
23454
|
}
|
|
23233
23455
|
function XlsxViewerInner({
|
|
@@ -23617,4 +23839,4 @@ export {
|
|
|
23617
23839
|
__createContentNode,
|
|
23618
23840
|
__createContentRoot
|
|
23619
23841
|
};
|
|
23620
|
-
//# sourceMappingURL=chunk-
|
|
23842
|
+
//# sourceMappingURL=chunk-C4WTJIRG.js.map
|