@rowsncolumns/spreadsheet-state 28.0.72 → 28.0.74
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/dist/cjs/api/advanced-filter.d.ts +72 -0
- package/dist/cjs/api/advanced-filter.d.ts.map +1 -0
- package/dist/cjs/api/advanced-filter.js +0 -0
- package/dist/cjs/api/goal-seek.d.ts +29 -0
- package/dist/cjs/api/goal-seek.d.ts.map +1 -0
- package/dist/cjs/api/goal-seek.js +131 -0
- package/dist/cjs/api/immer-utils.d.ts.map +1 -1
- package/dist/cjs/api/immer-utils.js +2 -0
- package/dist/cjs/api/paint-format.d.ts +41 -0
- package/dist/cjs/api/paint-format.d.ts.map +1 -0
- package/dist/cjs/api/paint-format.js +115 -0
- package/dist/cjs/api/paste-special.d.ts +48 -0
- package/dist/cjs/api/paste-special.d.ts.map +1 -0
- package/dist/cjs/api/paste-special.js +229 -0
- package/dist/cjs/api/split-text.d.ts +12 -0
- package/dist/cjs/api/split-text.d.ts.map +1 -1
- package/dist/cjs/api/split-text.js +41 -0
- package/dist/cjs/api/subtotal.d.ts +85 -0
- package/dist/cjs/api/subtotal.d.ts.map +1 -0
- package/dist/cjs/api/subtotal.js +250 -0
- package/dist/cjs/commands.d.ts +13 -0
- package/dist/cjs/commands.d.ts.map +1 -1
- package/dist/cjs/components/editors/data-validation-rule-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/data-validation-rule-editor.js +83 -16
- package/dist/cjs/components/editors/table-editor.js +7 -2
- package/dist/cjs/hooks/use-calculation-worker.d.ts.map +1 -1
- package/dist/cjs/hooks/use-calculation-worker.js +39 -8
- package/dist/cjs/hooks/use-calculation.d.ts +12 -2
- package/dist/cjs/hooks/use-calculation.d.ts.map +1 -1
- package/dist/cjs/hooks/use-calculation.js +71 -35
- package/dist/cjs/hooks/use-on-advanced-filter.d.ts +21 -0
- package/dist/cjs/hooks/use-on-advanced-filter.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-advanced-filter.js +42 -0
- package/dist/cjs/hooks/use-on-goal-seek.d.ts +30 -0
- package/dist/cjs/hooks/use-on-goal-seek.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-goal-seek.js +140 -0
- package/dist/cjs/hooks/use-on-import-excel.d.ts +10 -1
- package/dist/cjs/hooks/use-on-import-excel.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-import-excel.js +8 -4
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.js +53 -34
- package/dist/cjs/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-paste.js +82 -52
- package/dist/cjs/hooks/use-on-remove-duplicates.d.ts +2 -1
- package/dist/cjs/hooks/use-on-remove-duplicates.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-remove-duplicates.js +5 -3
- package/dist/cjs/hooks/use-on-show-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-show-column.js +2 -0
- package/dist/cjs/hooks/use-on-show-row.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-show-row.js +2 -0
- package/dist/cjs/hooks/use-on-subtotal.d.ts +26 -0
- package/dist/cjs/hooks/use-on-subtotal.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-subtotal.js +53 -0
- package/dist/cjs/hooks/use-paint-format.d.ts +19 -3
- package/dist/cjs/hooks/use-paint-format.d.ts.map +1 -1
- package/dist/cjs/hooks/use-paint-format.js +85 -31
- package/dist/cjs/hooks/use-sheet-properties.d.ts +3 -0
- package/dist/cjs/hooks/use-sheet-properties.d.ts.map +1 -1
- package/dist/cjs/hooks/use-sheet-properties.js +8 -0
- package/dist/cjs/hooks/use-split-text-to-columns.d.ts +2 -1
- package/dist/cjs/hooks/use-split-text-to-columns.d.ts.map +1 -1
- package/dist/cjs/hooks/use-split-text-to-columns.js +3 -2
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +50 -36
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +98 -18
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/interface/calculation-interface.d.ts.map +1 -1
- package/dist/cjs/interface/calculation-interface.js +5 -0
- package/dist/cjs/interface/change-batch-stream.d.ts.map +1 -1
- package/dist/cjs/interface/change-batch-stream.js +12 -6
- package/dist/cjs/interface/change-batch.d.ts.map +1 -1
- package/dist/cjs/interface/change-batch.js +17 -9
- package/dist/cjs/interface/change-formatting.d.ts.map +1 -1
- package/dist/cjs/interface/change-formatting.js +30 -11
- package/dist/cjs/interface/hide-column.d.ts.map +1 -1
- package/dist/cjs/interface/hide-column.js +4 -0
- package/dist/cjs/interface/hide-row.d.ts.map +1 -1
- package/dist/cjs/interface/hide-row.js +4 -0
- package/dist/cjs/interface/remove-duplicates.d.ts +3 -2
- package/dist/cjs/interface/remove-duplicates.d.ts.map +1 -1
- package/dist/cjs/interface/remove-duplicates.js +41 -7
- package/dist/cjs/interface/split-text.d.ts +2 -1
- package/dist/cjs/interface/split-text.d.ts.map +1 -1
- package/dist/cjs/interface/split-text.js +7 -3
- package/dist/cjs/interface/spreadsheet-interface.d.ts +2 -1
- package/dist/cjs/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/cjs/interface/spreadsheet-interface.js +5 -5
- package/dist/cjs/sheet-cell.d.ts.map +1 -1
- package/dist/cjs/sheet-cell.js +7 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/api/advanced-filter.d.ts +72 -0
- package/dist/esm/api/advanced-filter.d.ts.map +1 -0
- package/dist/esm/api/advanced-filter.js +0 -0
- package/dist/esm/api/goal-seek.d.ts +29 -0
- package/dist/esm/api/goal-seek.d.ts.map +1 -0
- package/dist/esm/api/goal-seek.js +108 -0
- package/dist/esm/api/immer-utils.d.ts.map +1 -1
- package/dist/esm/api/immer-utils.js +2 -0
- package/dist/esm/api/paint-format.d.ts +41 -0
- package/dist/esm/api/paint-format.d.ts.map +1 -0
- package/dist/esm/api/paint-format.js +77 -0
- package/dist/esm/api/paste-special.d.ts +48 -0
- package/dist/esm/api/paste-special.d.ts.map +1 -0
- package/dist/esm/api/paste-special.js +220 -0
- package/dist/esm/api/split-text.d.ts +12 -0
- package/dist/esm/api/split-text.d.ts.map +1 -1
- package/dist/esm/api/split-text.js +28 -0
- package/dist/esm/api/subtotal.d.ts +85 -0
- package/dist/esm/api/subtotal.d.ts.map +1 -0
- package/dist/esm/api/subtotal.js +181 -0
- package/dist/esm/commands.d.ts +13 -0
- package/dist/esm/commands.d.ts.map +1 -1
- package/dist/esm/components/editors/data-validation-rule-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/data-validation-rule-editor.js +52 -4
- package/dist/esm/components/editors/table-editor.js +7 -4
- package/dist/esm/hooks/use-calculation-worker.d.ts.map +1 -1
- package/dist/esm/hooks/use-calculation-worker.js +20 -2
- package/dist/esm/hooks/use-calculation.d.ts +12 -2
- package/dist/esm/hooks/use-calculation.d.ts.map +1 -1
- package/dist/esm/hooks/use-calculation.js +38 -7
- package/dist/esm/hooks/use-on-advanced-filter.d.ts +21 -0
- package/dist/esm/hooks/use-on-advanced-filter.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-advanced-filter.js +41 -0
- package/dist/esm/hooks/use-on-goal-seek.d.ts +30 -0
- package/dist/esm/hooks/use-on-goal-seek.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-goal-seek.js +82 -0
- package/dist/esm/hooks/use-on-import-excel.d.ts +10 -1
- package/dist/esm/hooks/use-on-import-excel.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-import-excel.js +8 -4
- package/dist/esm/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-merge-unmerge-cells.js +13 -13
- package/dist/esm/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-paste.js +49 -14
- package/dist/esm/hooks/use-on-remove-duplicates.d.ts +2 -1
- package/dist/esm/hooks/use-on-remove-duplicates.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-remove-duplicates.js +5 -3
- package/dist/esm/hooks/use-on-show-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-show-column.js +2 -0
- package/dist/esm/hooks/use-on-show-row.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-show-row.js +2 -0
- package/dist/esm/hooks/use-on-subtotal.d.ts +26 -0
- package/dist/esm/hooks/use-on-subtotal.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-subtotal.js +48 -0
- package/dist/esm/hooks/use-paint-format.d.ts +19 -3
- package/dist/esm/hooks/use-paint-format.d.ts.map +1 -1
- package/dist/esm/hooks/use-paint-format.js +71 -29
- package/dist/esm/hooks/use-sheet-properties.d.ts +3 -0
- package/dist/esm/hooks/use-sheet-properties.d.ts.map +1 -1
- package/dist/esm/hooks/use-sheet-properties.js +8 -0
- package/dist/esm/hooks/use-split-text-to-columns.d.ts +2 -1
- package/dist/esm/hooks/use-split-text-to-columns.d.ts.map +1 -1
- package/dist/esm/hooks/use-split-text-to-columns.js +3 -2
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +50 -36
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +89 -16
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +9 -0
- package/dist/esm/interface/calculation-interface.d.ts.map +1 -1
- package/dist/esm/interface/calculation-interface.js +3 -0
- package/dist/esm/interface/change-batch-stream.d.ts.map +1 -1
- package/dist/esm/interface/change-batch-stream.js +12 -6
- package/dist/esm/interface/change-batch.d.ts.map +1 -1
- package/dist/esm/interface/change-batch.js +15 -9
- package/dist/esm/interface/change-formatting.d.ts.map +1 -1
- package/dist/esm/interface/change-formatting.js +28 -11
- package/dist/esm/interface/hide-column.d.ts.map +1 -1
- package/dist/esm/interface/hide-column.js +4 -0
- package/dist/esm/interface/hide-row.d.ts.map +1 -1
- package/dist/esm/interface/hide-row.js +4 -0
- package/dist/esm/interface/remove-duplicates.d.ts +3 -2
- package/dist/esm/interface/remove-duplicates.d.ts.map +1 -1
- package/dist/esm/interface/remove-duplicates.js +37 -6
- package/dist/esm/interface/split-text.d.ts +2 -1
- package/dist/esm/interface/split-text.d.ts.map +1 -1
- package/dist/esm/interface/split-text.js +6 -3
- package/dist/esm/interface/spreadsheet-interface.d.ts +2 -1
- package/dist/esm/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/esm/interface/spreadsheet-interface.js +5 -5
- package/dist/esm/sheet-cell.d.ts.map +1 -1
- package/dist/esm/sheet-cell.js +7 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +18 -18
|
@@ -10,6 +10,7 @@ import { useCallback } from "react";
|
|
|
10
10
|
import { processSideEffectDependentCells } from "../api/dependency";
|
|
11
11
|
import { createSheetCellIdentifier } from "../api/formula";
|
|
12
12
|
import { createSheetDraft } from "../api/immer-utils";
|
|
13
|
+
import { applyPasteOperation, isBlankClipboardCell, resolvePasteSpecialOptions, } from "../api/paste-special";
|
|
13
14
|
import { findAdjacentTable, findTableColumnIndex } from "../api/table";
|
|
14
15
|
import { addCalculatedColumnsForRowExpansion } from "../interface/change-table-column";
|
|
15
16
|
import { collectDataValidationTarget, extendDataValidationRanges, } from "../interface/data-validation-utils";
|
|
@@ -64,13 +65,15 @@ export var useOnPaste = function (_a) {
|
|
|
64
65
|
var getFinalRowHeight = useGetFinalRowHeight();
|
|
65
66
|
var _e = useCalculationQueue({ enqueueCalculation: enqueueCalculation }), enqueue = _e.enqueue, processQueue = _e.processQueue;
|
|
66
67
|
return useCallback(function (e, sourceSheetId, destinationSheetId, copiedSelections, activeCell, selections, finalSelections, isCutOperation) { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
|
-
var
|
|
68
|
+
var pasteSpecial, pasteMode, pasteOperation, pasteEvent, forcePlainText, activeSheetName, from, merges, embeds, tables, columnWidths, rowHeights, selectedRowValues, rowIndex, start, end, pasteResults, saveHistory, dataValidationTargets, fontFamilies, fontFamiliesWithWeights, err_1, _a, rowSpan, colSpan, to, rowDelta, columnDelta, _b, adjacentTable, isRowExpansion, isColumnExpansion, currentTable, nextSelections, existingTable, destinationRows, visibleRowIndexes, tableHeaderColumnIndex, cellValue, formattedValue, sharedStrings, sharedStringValue, activeCellValue, recalcCells, newEndRowIndex_1, pastedSheetData, values, rowIndex, row, columnIndex, cell, ue, firstEmbedId_1, citationIdMap_1, dataRowIndex, rowData, dataColumnIndex, cellValue_1, newCitations_1, citationIdRemap_1, _loop_1, _c, _d, _e, oldCitationId, _f, sourceRowIndex, sourceColumnIndex;
|
|
68
69
|
var e_1, _g;
|
|
69
|
-
var _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z
|
|
70
|
-
return __generator(this, function (
|
|
71
|
-
switch (
|
|
70
|
+
var _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
71
|
+
return __generator(this, function (_0) {
|
|
72
|
+
switch (_0.label) {
|
|
72
73
|
case 0:
|
|
73
|
-
|
|
74
|
+
pasteSpecial = resolvePasteSpecialOptions(e === null || e === void 0 ? void 0 : e.clipboardData);
|
|
75
|
+
pasteMode = pasteSpecial.paste;
|
|
76
|
+
pasteOperation = pasteSpecial.operation;
|
|
74
77
|
pasteEvent = e;
|
|
75
78
|
forcePlainText = Boolean((pasteEvent === null || pasteEvent === void 0 ? void 0 : pasteEvent.__forcePlainText) ||
|
|
76
79
|
((pasteEvent === null || pasteEvent === void 0 ? void 0 : pasteEvent.shiftKey) &&
|
|
@@ -82,34 +85,34 @@ export var useOnPaste = function (_a) {
|
|
|
82
85
|
for (rowIndex = from.range.startRowIndex; rowIndex <= from.range.endRowIndex; rowIndex++) {
|
|
83
86
|
start = from.range.startColumnIndex;
|
|
84
87
|
end = start + from.range.endColumnIndex - from.range.startColumnIndex + 1;
|
|
85
|
-
selectedRowValues.push((
|
|
88
|
+
selectedRowValues.push((_l = (_k = (_j = (_h = sheetData === null || sheetData === void 0 ? void 0 : sheetData[sourceSheetId]) === null || _h === void 0 ? void 0 : _h[rowIndex]) === null || _j === void 0 ? void 0 : _j.values) === null || _k === void 0 ? void 0 : _k.slice(start, end)) !== null && _l !== void 0 ? _l : []);
|
|
86
89
|
}
|
|
87
90
|
return [3 /*break*/, 3];
|
|
88
91
|
case 1: return [4 /*yield*/, generateDataFromClipboard(e, activeCell, destinationSheetId, activeSheetName, preserveFormatting, locale, idCreationStrategy, forcePlainText, sanitizeHtml, generatedNames)];
|
|
89
92
|
case 2:
|
|
90
|
-
pasteResults =
|
|
91
|
-
selectedRowValues = (
|
|
93
|
+
pasteResults = _0.sent();
|
|
94
|
+
selectedRowValues = (_m = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.results) !== null && _m !== void 0 ? _m : [];
|
|
92
95
|
merges = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.merges;
|
|
93
96
|
embeds = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.embeds;
|
|
94
97
|
tables = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.tables;
|
|
95
98
|
rowHeights = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.rowHeights;
|
|
96
99
|
columnWidths = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.columnWidths;
|
|
97
|
-
|
|
100
|
+
_0.label = 3;
|
|
98
101
|
case 3:
|
|
99
102
|
// No data,
|
|
100
103
|
if (isNil(selectedRowValues)) {
|
|
101
104
|
return [2 /*return*/];
|
|
102
105
|
}
|
|
103
|
-
if (
|
|
106
|
+
if (pasteSpecial.transpose && selectedRowValues.length) {
|
|
104
107
|
selectedRowValues = transpose(selectedRowValues);
|
|
105
108
|
}
|
|
106
|
-
|
|
109
|
+
if (pasteMode === "formats") {
|
|
107
110
|
selectedRowValues = pickFormatting(selectedRowValues);
|
|
108
111
|
}
|
|
109
|
-
else if (
|
|
112
|
+
else if (pasteMode === "formulas") {
|
|
110
113
|
selectedRowValues = pickFormula(selectedRowValues, destinationSheetId, locale);
|
|
111
114
|
}
|
|
112
|
-
else if (
|
|
115
|
+
else if (pasteMode === "values") {
|
|
113
116
|
selectedRowValues = pickValue(selectedRowValues, destinationSheetId, locale);
|
|
114
117
|
}
|
|
115
118
|
saveHistory = createHistory();
|
|
@@ -119,34 +122,34 @@ export var useOnPaste = function (_a) {
|
|
|
119
122
|
fontFamiliesWithWeights = fontFamilies
|
|
120
123
|
.map(function (family) { return ["".concat(family, ":400"), "".concat(family, ":700")]; })
|
|
121
124
|
.flat();
|
|
122
|
-
|
|
125
|
+
_0.label = 4;
|
|
123
126
|
case 4:
|
|
124
|
-
|
|
127
|
+
_0.trys.push([4, 9, , 10]);
|
|
125
128
|
if (!onRequestFonts) return [3 /*break*/, 6];
|
|
126
129
|
return [4 /*yield*/, onRequestFonts(fontFamilies)];
|
|
127
130
|
case 5:
|
|
128
|
-
|
|
131
|
+
_0.sent();
|
|
129
132
|
return [3 /*break*/, 8];
|
|
130
133
|
case 6: return [4 /*yield*/, loadWebFont(fontFamiliesWithWeights)];
|
|
131
134
|
case 7:
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
_0.sent();
|
|
136
|
+
_0.label = 8;
|
|
134
137
|
case 8:
|
|
135
138
|
redrawGrid === null || redrawGrid === void 0 ? void 0 : redrawGrid();
|
|
136
139
|
return [3 /*break*/, 10];
|
|
137
140
|
case 9:
|
|
138
|
-
err_1 =
|
|
141
|
+
err_1 = _0.sent();
|
|
139
142
|
error("Error loading webfonts", fontFamilies, err_1);
|
|
140
143
|
return [3 /*break*/, 10];
|
|
141
144
|
case 10:
|
|
142
145
|
_a = __read([
|
|
143
|
-
(
|
|
146
|
+
(_o = selectedRowValues === null || selectedRowValues === void 0 ? void 0 : selectedRowValues.length) !== null && _o !== void 0 ? _o : 0,
|
|
144
147
|
// For cut operations, use range dimensions since data may be sparse
|
|
145
148
|
isCutOperation && from
|
|
146
149
|
? from.range.endColumnIndex - from.range.startColumnIndex + 1
|
|
147
|
-
: (
|
|
150
|
+
: (_q = (_p = selectedRowValues[0]) === null || _p === void 0 ? void 0 : _p.length) !== null && _q !== void 0 ? _q : 0,
|
|
148
151
|
], 2), rowSpan = _a[0], colSpan = _a[1];
|
|
149
|
-
to = (
|
|
152
|
+
to = (_r = selections === null || selections === void 0 ? void 0 : selections[(selections === null || selections === void 0 ? void 0 : selections.length) - 1]) !== null && _r !== void 0 ? _r : selectionFromActiveCell(activeCell)[0];
|
|
150
153
|
rowDelta = from && to ? to.range.startRowIndex - from.range.startRowIndex : -1;
|
|
151
154
|
columnDelta = from && to
|
|
152
155
|
? to.range.startColumnIndex - from.range.startColumnIndex
|
|
@@ -206,7 +209,7 @@ export var useOnPaste = function (_a) {
|
|
|
206
209
|
return rowIndex;
|
|
207
210
|
});
|
|
208
211
|
tableHeaderColumnIndex = findTableColumnIndex(destinationSheetId, activeCell, currentTables);
|
|
209
|
-
cellValue = (
|
|
212
|
+
cellValue = (_s = selectedRowValues === null || selectedRowValues === void 0 ? void 0 : selectedRowValues[0]) === null || _s === void 0 ? void 0 : _s[0];
|
|
210
213
|
formattedValue = getCellFormattedValue(cellValue);
|
|
211
214
|
sharedStrings = sharedStringRegistry === null || sharedStringRegistry === void 0 ? void 0 : sharedStringRegistry.getSharedStrings();
|
|
212
215
|
sharedStringValue = (cellValue === null || cellValue === void 0 ? void 0 : cellValue.ss) == null || !sharedStrings
|
|
@@ -257,7 +260,7 @@ export var useOnPaste = function (_a) {
|
|
|
257
260
|
onChangeSheetData === null || onChangeSheetData === void 0 ? void 0 : onChangeSheetData(function (prevSheetData) {
|
|
258
261
|
var _a = __read(produceWithPatches(prevSheetData, function (draft) {
|
|
259
262
|
var e_2, _a, e_3, _b, e_4, _c, e_5, _d, e_6, _e;
|
|
260
|
-
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
263
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
261
264
|
// For cut operation
|
|
262
265
|
var movedKeys = new Set();
|
|
263
266
|
/**
|
|
@@ -267,8 +270,8 @@ export var useOnPaste = function (_a) {
|
|
|
267
270
|
if (isCutOperation && from && to && !isNil(sourceSheetId)) {
|
|
268
271
|
var sheetId = sourceSheetId;
|
|
269
272
|
try {
|
|
270
|
-
for (var
|
|
271
|
-
var
|
|
273
|
+
for (var _1 = __values(iterateCellsInRange(from.range)), _2 = _1.next(); !_2.done; _2 = _1.next()) {
|
|
274
|
+
var _3 = __read(_2.value, 2), rowIndex = _3[0], columnIndex = _3[1];
|
|
272
275
|
// Process dependents
|
|
273
276
|
processSideEffectDependentCells({
|
|
274
277
|
draft: draft,
|
|
@@ -293,7 +296,7 @@ export var useOnPaste = function (_a) {
|
|
|
293
296
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
294
297
|
finally {
|
|
295
298
|
try {
|
|
296
|
-
if (
|
|
299
|
+
if (_2 && !_2.done && (_a = _1.return)) _a.call(_1);
|
|
297
300
|
}
|
|
298
301
|
finally { if (e_2) throw e_2.error; }
|
|
299
302
|
}
|
|
@@ -320,7 +323,7 @@ export var useOnPaste = function (_a) {
|
|
|
320
323
|
}
|
|
321
324
|
try {
|
|
322
325
|
for (var destinationRows_1 = __values(destinationRows), destinationRows_1_1 = destinationRows_1.next(); !destinationRows_1_1.done; destinationRows_1_1 = destinationRows_1.next()) {
|
|
323
|
-
var
|
|
326
|
+
var _4 = destinationRows_1_1.value, rowIndex = _4.rowIndex, dataRowIndex = _4.dataRowIndex;
|
|
324
327
|
var currentSheet = createSheetDraft(draft, destinationSheetId, rowIndex);
|
|
325
328
|
var columnCursor = 0;
|
|
326
329
|
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++, columnCursor++) {
|
|
@@ -328,12 +331,12 @@ export var useOnPaste = function (_a) {
|
|
|
328
331
|
currentSheet[rowIndex].values[columnIndex] =
|
|
329
332
|
(_m = movedRowValues[dataRowIndex]) === null || _m === void 0 ? void 0 : _m[dataColumnIndex];
|
|
330
333
|
try {
|
|
331
|
-
for (var
|
|
334
|
+
for (var _5 = (e_4 = void 0, __values(getDependents({
|
|
332
335
|
rowIndex: rowIndex,
|
|
333
336
|
columnIndex: columnIndex,
|
|
334
337
|
sheetId: destinationSheetId,
|
|
335
|
-
}))),
|
|
336
|
-
var dependent =
|
|
338
|
+
}))), _6 = _5.next(); !_6.done; _6 = _5.next()) {
|
|
339
|
+
var dependent = _6.value;
|
|
337
340
|
if (isStaticNode(dependent)) {
|
|
338
341
|
continue;
|
|
339
342
|
}
|
|
@@ -349,7 +352,7 @@ export var useOnPaste = function (_a) {
|
|
|
349
352
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
350
353
|
finally {
|
|
351
354
|
try {
|
|
352
|
-
if (
|
|
355
|
+
if (_6 && !_6.done && (_c = _5.return)) _c.call(_5);
|
|
353
356
|
}
|
|
354
357
|
finally { if (e_4) throw e_4.error; }
|
|
355
358
|
}
|
|
@@ -387,26 +390,54 @@ export var useOnPaste = function (_a) {
|
|
|
387
390
|
};
|
|
388
391
|
try {
|
|
389
392
|
for (var destinationRows_2 = __values(destinationRows), destinationRows_2_1 = destinationRows_2.next(); !destinationRows_2_1.done; destinationRows_2_1 = destinationRows_2.next()) {
|
|
390
|
-
var
|
|
393
|
+
var _7 = destinationRows_2_1.value, rowIndex = _7.rowIndex, dataRowIndex = _7.dataRowIndex;
|
|
391
394
|
var currentSheet = createSheetDraft(draft, destinationSheetId, rowIndex);
|
|
392
395
|
var columnCursor = 0;
|
|
393
396
|
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++, columnCursor++) {
|
|
394
397
|
var dataColumnIndex = colSpan > 0 ? columnCursor % colSpan : 0;
|
|
395
398
|
var cellValue_2 = (_o = selectedRowValues[dataRowIndex]) === null || _o === void 0 ? void 0 : _o[dataColumnIndex];
|
|
396
|
-
|
|
397
|
-
|
|
399
|
+
// Skip blanks: an empty clipboard cell leaves the
|
|
400
|
+
// destination (value and format) untouched.
|
|
401
|
+
if (pasteSpecial.skipBlanks &&
|
|
402
|
+
isBlankClipboardCell(cellValue_2)) {
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
// Operation: combine the pasted cell with the cell it
|
|
406
|
+
// lands on. The clipboard is anchored at the FIRST tile,
|
|
407
|
+
// so a source formula is relocated to the tile it lands
|
|
408
|
+
// on first (the same `moveFormula` shift the plain paste
|
|
409
|
+
// applies below); the composed `=(dest)op(source)` is
|
|
410
|
+
// then anchored at the destination and must not be moved
|
|
411
|
+
// again (that would shift the destination fragment too).
|
|
412
|
+
if (pasteOperation) {
|
|
413
|
+
var sourceFormula = getExtendedValueFormula(getCellUserEnteredValue(cellValue_2));
|
|
414
|
+
if (!isNil(sourceFormula) &&
|
|
415
|
+
dataRowIndex === 0 &&
|
|
416
|
+
dataColumnIndex === 0 &&
|
|
417
|
+
(rowIndex !== sourceCell.rowIndex ||
|
|
418
|
+
columnIndex !== sourceCell.columnIndex)) {
|
|
419
|
+
var tileCell = new SheetCell();
|
|
420
|
+
tileCell.setLocale(locale);
|
|
421
|
+
tileCell.assign(destinationSheetId, sourceCell, cellValue_2);
|
|
422
|
+
tileCell.moveFormula(sourceCell, { rowIndex: rowIndex, columnIndex: columnIndex }, activeSheetName, { preserveAbsolutes: true });
|
|
423
|
+
cellValue_2 = __assign(__assign({}, cellValue_2), { ue: __assign(__assign({}, cellValue_2 === null || cellValue_2 === void 0 ? void 0 : cellValue_2.ue), { fv: tileCell.formula }) });
|
|
424
|
+
}
|
|
425
|
+
cellValue_2 = applyPasteOperation(cellValue_2, (_r = (_q = (_p = prevSheetData[destinationSheetId]) === null || _p === void 0 ? void 0 : _p[rowIndex]) === null || _q === void 0 ? void 0 : _q.values) === null || _r === void 0 ? void 0 : _r[columnIndex], pasteOperation, destinationSheetId, locale);
|
|
426
|
+
}
|
|
427
|
+
if (pasteMode === "formats") {
|
|
428
|
+
var existingCellData = (_u = (_t = (_s = prevSheetData[destinationSheetId]) === null || _s === void 0 ? void 0 : _s[rowIndex]) === null || _t === void 0 ? void 0 : _t.values) === null || _u === void 0 ? void 0 : _u[columnIndex];
|
|
398
429
|
cellValue_2 = __assign(__assign({}, existingCellData), cellValue_2);
|
|
399
430
|
sheetCell.extendCellData(cellValue_2);
|
|
400
431
|
}
|
|
401
|
-
if (
|
|
402
|
-
var existingCellData = (
|
|
432
|
+
if (pasteMode === "values" || forcePlainText) {
|
|
433
|
+
var existingCellData = (_x = (_w = (_v = prevSheetData[destinationSheetId]) === null || _v === void 0 ? void 0 : _v[rowIndex]) === null || _w === void 0 ? void 0 : _w.values) === null || _x === void 0 ? void 0 : _x[columnIndex];
|
|
403
434
|
// Remove ss from existingCellData since we're replacing the value
|
|
404
|
-
var
|
|
435
|
+
var _8 = existingCellData !== null && existingCellData !== void 0 ? existingCellData : {}, _ss = _8.ss, existingWithoutSs = __rest(_8, ["ss"]);
|
|
405
436
|
cellValue_2 = __assign(__assign({}, existingWithoutSs), cellValue_2);
|
|
406
437
|
sheetCell.extendCellData(cellValue_2);
|
|
407
438
|
}
|
|
408
|
-
if (
|
|
409
|
-
sheetCell.assign(destinationSheetId, { rowIndex: rowIndex, columnIndex: columnIndex }, (
|
|
439
|
+
if (pasteSpecial.transpose && pasteMode === "all") {
|
|
440
|
+
sheetCell.assign(destinationSheetId, { rowIndex: rowIndex, columnIndex: columnIndex }, (_0 = (_z = (_y = prevSheetData[destinationSheetId]) === null || _y === void 0 ? void 0 : _y[rowIndex]) === null || _z === void 0 ? void 0 : _z.values) === null || _0 === void 0 ? void 0 : _0[columnIndex], {
|
|
410
441
|
locale: locale,
|
|
411
442
|
cellXfsRegistry: cellXfsRegistry,
|
|
412
443
|
getDataValidationById: getDataValidationById,
|
|
@@ -427,11 +458,13 @@ export var useOnPaste = function (_a) {
|
|
|
427
458
|
sharedStringRegistry: sharedStringRegistry,
|
|
428
459
|
});
|
|
429
460
|
}
|
|
430
|
-
if (
|
|
461
|
+
if (pasteMode === "formats") {
|
|
431
462
|
sheetCell.refreshFormattedValue();
|
|
432
463
|
}
|
|
433
464
|
if (sheetCell.isFormula()) {
|
|
434
|
-
if (dataRowIndex === 0 &&
|
|
465
|
+
if (dataRowIndex === 0 &&
|
|
466
|
+
dataColumnIndex === 0 &&
|
|
467
|
+
!pasteOperation) {
|
|
435
468
|
sheetCell.moveFormula(sourceCell, {
|
|
436
469
|
rowIndex: rowIndex,
|
|
437
470
|
columnIndex: columnIndex,
|
|
@@ -454,12 +487,12 @@ export var useOnPaste = function (_a) {
|
|
|
454
487
|
});
|
|
455
488
|
}
|
|
456
489
|
try {
|
|
457
|
-
for (var
|
|
490
|
+
for (var _9 = (e_6 = void 0, __values(getDependents({
|
|
458
491
|
rowIndex: rowIndex,
|
|
459
492
|
columnIndex: columnIndex,
|
|
460
493
|
sheetId: destinationSheetId,
|
|
461
|
-
}))),
|
|
462
|
-
var dependent =
|
|
494
|
+
}))), _10 = _9.next(); !_10.done; _10 = _9.next()) {
|
|
495
|
+
var dependent = _10.value;
|
|
463
496
|
if (isStaticNode(dependent)) {
|
|
464
497
|
continue;
|
|
465
498
|
}
|
|
@@ -475,7 +508,7 @@ export var useOnPaste = function (_a) {
|
|
|
475
508
|
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
476
509
|
finally {
|
|
477
510
|
try {
|
|
478
|
-
if (
|
|
511
|
+
if (_10 && !_10.done && (_e = _9.return)) _e.call(_9);
|
|
479
512
|
}
|
|
480
513
|
finally { if (e_6) throw e_6.error; }
|
|
481
514
|
}
|
|
@@ -620,10 +653,7 @@ export var useOnPaste = function (_a) {
|
|
|
620
653
|
// Skipped for paste-special variants since the destination
|
|
621
654
|
// cell ends up as a merge of existing + pasted data, not
|
|
622
655
|
// the raw pasted value we can read from selectedRowValues.
|
|
623
|
-
var skipAutoResize =
|
|
624
|
-
pasteSpecialType === "Value" ||
|
|
625
|
-
pasteSpecialType === "Formula" ||
|
|
626
|
-
pasteSpecialType === "Transposed";
|
|
656
|
+
var skipAutoResize = pasteSpecial.isSpecial;
|
|
627
657
|
if (!skipAutoResize &&
|
|
628
658
|
getFinalRowHeight &&
|
|
629
659
|
selectedRowValues.length &&
|
|
@@ -744,11 +774,11 @@ export var useOnPaste = function (_a) {
|
|
|
744
774
|
for (rowIndex = to.range.startRowIndex; rowIndex <= to.range.endRowIndex; rowIndex++) {
|
|
745
775
|
row = [];
|
|
746
776
|
for (columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++) {
|
|
747
|
-
cell = (
|
|
777
|
+
cell = (_v = (_u = (_t = pastedSheetData[destinationSheetId]) === null || _t === void 0 ? void 0 : _t[rowIndex]) === null || _u === void 0 ? void 0 : _u.values) === null || _v === void 0 ? void 0 : _v[columnIndex];
|
|
748
778
|
ue = cell ? getCellUserEnteredValue(cell) : undefined;
|
|
749
779
|
// Formula text wins (e.g. "=SUM(A1:A2)"), else the literal string / number / bool.
|
|
750
780
|
// `??` (not `||`) so 0 and false survive; `null` clears the cell.
|
|
751
|
-
row.push((
|
|
781
|
+
row.push((_z = (_y = (_x = (_w = getExtendedValueFormula(ue)) !== null && _w !== void 0 ? _w : getExtendedValueString(ue)) !== null && _x !== void 0 ? _x : getExtendedValueNumber(ue)) !== null && _y !== void 0 ? _y : getExtendedValueBool(ue)) !== null && _z !== void 0 ? _z : null);
|
|
752
782
|
}
|
|
753
783
|
values.push(row);
|
|
754
784
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CellInterface, SelectionArea } from "@rowsncolumns/common-types";
|
|
2
2
|
import type { CellData, SelectionAttributes, Sheet } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
import { type RemoveDuplicatesOptions } from "../interface/remove-duplicates";
|
|
3
4
|
import type { useCalculation } from "./use-calculation";
|
|
4
5
|
import type { useSheetProperties } from "./use-sheet-properties";
|
|
5
6
|
import type { UseSpreadsheetProps } from "./use-spreadsheet-state";
|
|
@@ -17,5 +18,5 @@ export type UseOnRemoveDuplicatesProps<T extends CellData> = {
|
|
|
17
18
|
onChangeSheetData: UseSpreadsheetProps<T, Sheet>["onChangeSheetData"];
|
|
18
19
|
onCommand?: OnCommand;
|
|
19
20
|
};
|
|
20
|
-
export declare const useOnRemoveDuplicates: <T extends CellData>({ locale, cellXfsRegistry, sharedStringRegistry, getFormattedValue, onChangeSheetData, enqueueCalculation, createHistory, onCommand, }: UseOnRemoveDuplicatesProps<T>) => (sheetId: number, activeCell: CellInterface, selections?: SelectionArea<SelectionAttributes>[]) => import("../interface/remove-duplicates").RemoveDuplicatesResult | undefined;
|
|
21
|
+
export declare const useOnRemoveDuplicates: <T extends CellData>({ locale, cellXfsRegistry, sharedStringRegistry, getFormattedValue, onChangeSheetData, enqueueCalculation, createHistory, onCommand, }: UseOnRemoveDuplicatesProps<T>) => (sheetId: number, activeCell: CellInterface, selections?: SelectionArea<SelectionAttributes>[], options?: RemoveDuplicatesOptions) => import("../interface/remove-duplicates").RemoveDuplicatesResult | undefined;
|
|
21
22
|
//# sourceMappingURL=use-on-remove-duplicates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-on-remove-duplicates.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-remove-duplicates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EACV,QAAQ,EACR,mBAAmB,EACnB,KAAK,EACN,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-on-remove-duplicates.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-remove-duplicates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EACV,QAAQ,EACR,mBAAmB,EACnB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,QAAQ,IAAI;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,iBAAiB,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC9E,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5E,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACzD,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,mBAAmB,CAAC,CAAC;IACtE,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,EAAE,wIASvD,0BAA0B,CAAC,CAAC,CAAC,eAKjB,MAAM,cACH,aAAa,eACZ,aAAa,CAAC,mBAAmB,CAAC,EAAE,YACvC,uBAAuB,gFA2CtC,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
|
-
import { removeDuplicates } from "../interface/remove-duplicates";
|
|
2
|
+
import { removeDuplicates, } from "../interface/remove-duplicates";
|
|
3
3
|
import { useCanEditCellRange } from "./use-can-edit-cellrange";
|
|
4
4
|
export var useOnRemoveDuplicates = function (_a) {
|
|
5
5
|
var locale = _a.locale, cellXfsRegistry = _a.cellXfsRegistry, sharedStringRegistry = _a.sharedStringRegistry, getFormattedValue = _a.getFormattedValue, onChangeSheetData = _a.onChangeSheetData, enqueueCalculation = _a.enqueueCalculation, createHistory = _a.createHistory, onCommand = _a.onCommand;
|
|
6
6
|
var canEditCellRange = useCanEditCellRange();
|
|
7
|
-
return useCallback(function (sheetId, activeCell, selections) {
|
|
7
|
+
return useCallback(function (sheetId, activeCell, selections, options) {
|
|
8
8
|
if (!canEditCellRange(sheetId, activeCell)) {
|
|
9
9
|
console.debug("This range is protected, users cannot edit this cell range.");
|
|
10
10
|
return;
|
|
@@ -17,13 +17,15 @@ export var useOnRemoveDuplicates = function (_a) {
|
|
|
17
17
|
onChangeSheetData: onChangeSheetData,
|
|
18
18
|
enqueueCalculation: enqueueCalculation,
|
|
19
19
|
createHistory: createHistory,
|
|
20
|
-
})(sheetId, activeCell, selections);
|
|
20
|
+
})(sheetId, activeCell, selections, options);
|
|
21
21
|
// Stream the semantic command so an engine consumer recomputes from the deduped cells.
|
|
22
22
|
onCommand === null || onCommand === void 0 ? void 0 : onCommand({
|
|
23
23
|
command: "remove-duplicates",
|
|
24
24
|
sheetId: sheetId,
|
|
25
25
|
activeCell: activeCell,
|
|
26
26
|
selections: selections !== null && selections !== void 0 ? selections : [],
|
|
27
|
+
columnIndices: options === null || options === void 0 ? void 0 : options.columnIndices,
|
|
28
|
+
hasHeader: options === null || options === void 0 ? void 0 : options.hasHeader,
|
|
27
29
|
});
|
|
28
30
|
return result;
|
|
29
31
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-on-show-column.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-show-column.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EACV,QAAQ,EAER,mBAAmB,EACnB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAMnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAO7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,KAAK,oBAAoB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,IAAI;IAC/D,cAAc,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC5D,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/D,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,GAC/C,IAAI,CAAC;IACR,aAAa,IAAI,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,iGAOlE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,eAMf,MAAM,iBAAiB,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"use-on-show-column.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-show-column.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EACV,QAAQ,EAER,mBAAmB,EACnB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAMnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAO7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,KAAK,oBAAoB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,IAAI;IAC/D,cAAc,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC5D,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/D,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,GAC/C,IAAI,CAAC;IACR,aAAa,IAAI,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,iGAOlE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,eAMf,MAAM,iBAAiB,MAAM,EAAE,SAyF5C,CAAC"}
|
|
@@ -24,6 +24,8 @@ export var useOnShowColumn = function (_a) {
|
|
|
24
24
|
});
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
+
if (columnIndexes.length === 0)
|
|
28
|
+
return;
|
|
27
29
|
var saveHistory = createHistory();
|
|
28
30
|
var firstColumnIndex = columnIndexes[0];
|
|
29
31
|
var newActiveCell = (_a = getNextFocusableCell === null || getNextFocusableCell === void 0 ? void 0 : getNextFocusableCell(sheetId, { rowIndex: 0, columnIndex: firstColumnIndex }, Direction.Down, false)) !== null && _a !== void 0 ? _a : { rowIndex: 1, columnIndex: firstColumnIndex };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-on-show-row.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-show-row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EACV,QAAQ,EAER,mBAAmB,EACnB,KAAK,EACN,MAAM,2BAA2B,CAAC;AASnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAO7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,KAAK,iBAAiB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,IAAI;IAC5D,cAAc,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC5D,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/D,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,GAC/C,IAAI,CAAC;IACR,aAAa,IAAI,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACrD,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,2HAQ/D,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,eAMZ,MAAM,cAAc,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"use-on-show-row.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-show-row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EACV,QAAQ,EAER,mBAAmB,EACnB,KAAK,EACN,MAAM,2BAA2B,CAAC;AASnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAO7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,KAAK,iBAAiB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,IAAI;IAC5D,cAAc,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC5D,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/D,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,GAC/C,IAAI,CAAC;IACR,aAAa,IAAI,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACrD,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,2HAQ/D,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,eAMZ,MAAM,cAAc,MAAM,EAAE,SA6FzC,CAAC"}
|
|
@@ -24,6 +24,8 @@ export var useOnShowRow = function (_a) {
|
|
|
24
24
|
});
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
+
if (rowIndexes.length === 0)
|
|
28
|
+
return;
|
|
27
29
|
var saveHistory = createHistory();
|
|
28
30
|
var firstRowIndex = rowIndexes[0];
|
|
29
31
|
var newActiveCell = (_a = getNextFocusableCell === null || getNextFocusableCell === void 0 ? void 0 : getNextFocusableCell(sheetId, { rowIndex: firstRowIndex, columnIndex: 0 }, Direction.Right, false)) !== null && _a !== void 0 ? _a : { rowIndex: firstRowIndex, columnIndex: 1 };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { GridRange } from "@rowsncolumns/common-types";
|
|
2
|
+
import { type SubtotalOptions, type SubtotalPlan, type SubtotalPlanExecutor } from "../api/subtotal";
|
|
3
|
+
import type { useSheetProperties } from "./use-sheet-properties";
|
|
4
|
+
export type { SubtotalOptions, SubtotalPlan };
|
|
5
|
+
export type UseOnSubtotalProps = {
|
|
6
|
+
getEffectiveValue: ReturnType<typeof useSheetProperties>["getEffectiveValue"];
|
|
7
|
+
getFormattedValue: ReturnType<typeof useSheetProperties>["getFormattedValue"];
|
|
8
|
+
getFormulaValue: ReturnType<typeof useSheetProperties>["getFormulaValue"];
|
|
9
|
+
getRowOutlineLevel: ReturnType<typeof useSheetProperties>["getRowOutlineLevel"];
|
|
10
|
+
onDeleteRow: SubtotalPlanExecutor["onDeleteRow"];
|
|
11
|
+
onInsertRow: SubtotalPlanExecutor["onInsertRow"];
|
|
12
|
+
onChangeBatch: (sheetId: number, ranges: GridRange, values: (string | null)[][]) => void;
|
|
13
|
+
onGroupRows: SubtotalPlanExecutor["onGroupRows"];
|
|
14
|
+
onUngroupRows: SubtotalPlanExecutor["onUngroupRows"];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Excel's Data → Outline → Subtotal, composed over the existing row
|
|
18
|
+
* insert / batch write / row grouping callbacks so both engines execute it
|
|
19
|
+
* through the same streamed commands (see `planSubtotals` for the layout).
|
|
20
|
+
* Groups on the DISPLAYED value of the group column (Excel compares what the
|
|
21
|
+
* cells show). "Replace current subtotals" also resets the range's outline
|
|
22
|
+
* before regrouping, so re-applying keeps Excel's three levels. Returns the
|
|
23
|
+
* applied plan, or `undefined` when the range is protected or has no data rows.
|
|
24
|
+
*/
|
|
25
|
+
export declare const useOnSubtotal: ({ getEffectiveValue, getFormattedValue, getFormulaValue, getRowOutlineLevel, onDeleteRow, onInsertRow, onChangeBatch, onGroupRows, onUngroupRows, }: UseOnSubtotalProps) => (sheetId: number, options: SubtotalOptions) => SubtotalPlan | undefined;
|
|
26
|
+
//# sourceMappingURL=use-on-subtotal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-on-subtotal.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-subtotal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,iBAAiB,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC9E,iBAAiB,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC9E,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC1E,kBAAkB,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAChF,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IACjD,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IACjD,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,KACxB,IAAI,CAAC;IACV,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IACjD,aAAa,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,qJAU3B,kBAAkB,eAIP,MAAM,WAAW,eAAe,KAAG,YAAY,GAAG,SAoC/D,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { applySubtotalPlan, planSubtotals, } from "../api/subtotal";
|
|
3
|
+
import { useCanEditCellRange } from "./use-can-edit-cellrange";
|
|
4
|
+
/**
|
|
5
|
+
* Excel's Data → Outline → Subtotal, composed over the existing row
|
|
6
|
+
* insert / batch write / row grouping callbacks so both engines execute it
|
|
7
|
+
* through the same streamed commands (see `planSubtotals` for the layout).
|
|
8
|
+
* Groups on the DISPLAYED value of the group column (Excel compares what the
|
|
9
|
+
* cells show). "Replace current subtotals" also resets the range's outline
|
|
10
|
+
* before regrouping, so re-applying keeps Excel's three levels. Returns the
|
|
11
|
+
* applied plan, or `undefined` when the range is protected or has no data rows.
|
|
12
|
+
*/
|
|
13
|
+
export var useOnSubtotal = function (_a) {
|
|
14
|
+
var getEffectiveValue = _a.getEffectiveValue, getFormattedValue = _a.getFormattedValue, getFormulaValue = _a.getFormulaValue, getRowOutlineLevel = _a.getRowOutlineLevel, onDeleteRow = _a.onDeleteRow, onInsertRow = _a.onInsertRow, onChangeBatch = _a.onChangeBatch, onGroupRows = _a.onGroupRows, onUngroupRows = _a.onUngroupRows;
|
|
15
|
+
var canEditCellRange = useCanEditCellRange();
|
|
16
|
+
return useCallback(function (sheetId, options) {
|
|
17
|
+
if (!canEditCellRange(sheetId, options.range)) {
|
|
18
|
+
console.debug("This range is protected, users cannot edit this cell range.");
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
var plan = planSubtotals(options, {
|
|
22
|
+
getValue: function (rowIndex, columnIndex) {
|
|
23
|
+
var _a;
|
|
24
|
+
return (_a = getFormattedValue(sheetId, rowIndex, columnIndex)) !== null && _a !== void 0 ? _a : getEffectiveValue(sheetId, rowIndex, columnIndex);
|
|
25
|
+
},
|
|
26
|
+
getFormula: function (rowIndex, columnIndex) {
|
|
27
|
+
return getFormulaValue(sheetId, rowIndex, columnIndex);
|
|
28
|
+
},
|
|
29
|
+
getOutlineLevel: function (rowIndex) { return getRowOutlineLevel(sheetId, rowIndex); },
|
|
30
|
+
});
|
|
31
|
+
if (!plan)
|
|
32
|
+
return undefined;
|
|
33
|
+
applySubtotalPlan(sheetId, plan, {
|
|
34
|
+
onDeleteRow: onDeleteRow,
|
|
35
|
+
onInsertRow: onInsertRow,
|
|
36
|
+
onChangeBatch: onChangeBatch,
|
|
37
|
+
onGroupRows: onGroupRows,
|
|
38
|
+
onUngroupRows: onUngroupRows,
|
|
39
|
+
});
|
|
40
|
+
return plan;
|
|
41
|
+
}, [
|
|
42
|
+
canEditCellRange,
|
|
43
|
+
getEffectiveValue,
|
|
44
|
+
getFormattedValue,
|
|
45
|
+
getFormulaValue,
|
|
46
|
+
getRowOutlineLevel,
|
|
47
|
+
onDeleteRow,
|
|
48
|
+
onInsertRow,
|
|
49
|
+
onChangeBatch,
|
|
50
|
+
onGroupRows,
|
|
51
|
+
onUngroupRows,
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CellInterface, SelectionArea } from "@rowsncolumns/common-types";
|
|
2
|
-
import type { SelectionAttributes, SheetRange } from "@rowsncolumns/spreadsheet";
|
|
1
|
+
import type { CellInterface, GridRange, SelectionArea } from "@rowsncolumns/common-types";
|
|
2
|
+
import type { CellFormat, SelectionAttributes, SheetRange } from "@rowsncolumns/spreadsheet";
|
|
3
3
|
import type { useOnChangeFormatting } from "./use-on-change-formatting";
|
|
4
4
|
import type { useSheetProperties } from "./use-sheet-properties";
|
|
5
5
|
import type { useSheetState } from "./use-sheet-state";
|
|
@@ -7,8 +7,24 @@ export type UsePaintFormatProps = {
|
|
|
7
7
|
onChangeSelections: ReturnType<typeof useSheetState>["onChangeSelections"];
|
|
8
8
|
onChangeFormatting: ReturnType<typeof useOnChangeFormatting>["onChangeFormatting"];
|
|
9
9
|
getEffectiveFormat: ReturnType<typeof useSheetProperties>["getEffectiveFormat"];
|
|
10
|
+
/**
|
|
11
|
+
* The merges of a sheet (absolute ranges). When provided, the painter carries the merges that
|
|
12
|
+
* lie fully inside the source block and tiles them onto the target (Sheets / Excel parity).
|
|
13
|
+
*/
|
|
14
|
+
getMerges?: (sheetId: number) => GridRange[] | null | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Replace the merges inside `targetRange` with `merges` (already tiled, absolute). The
|
|
17
|
+
* spreadsheet-state wiring unmerges the target then merges each range in one step.
|
|
18
|
+
*/
|
|
19
|
+
onPaintMerges?: (sheetId: number, activeCell: CellInterface, targetRange: GridRange, merges: GridRange[]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* The table-banding / alternating-colour formats the grid paints on a sheet (keyed by
|
|
22
|
+
* `cellIdentifier`). When provided, the captured pattern carries the visible stripe colours as
|
|
23
|
+
* static fills, like Sheets.
|
|
24
|
+
*/
|
|
25
|
+
getBandedCells?: (sheetId: number) => Map<string, CellFormat> | undefined;
|
|
10
26
|
};
|
|
11
|
-
export declare const usePaintFormat: ({ getEffectiveFormat, onChangeFormatting, onChangeSelections, }: UsePaintFormatProps) => {
|
|
27
|
+
export declare const usePaintFormat: ({ getEffectiveFormat, onChangeFormatting, onChangeSelections, getMerges, onPaintMerges, getBandedCells, }: UsePaintFormatProps) => {
|
|
12
28
|
isPaintFormatActive: boolean;
|
|
13
29
|
onSavePaintFormat: (sheetId: number, activeCell: CellInterface, selections: SelectionArea<SelectionAttributes>[]) => void;
|
|
14
30
|
onApplyPaintFormat: (sheetId: number, activeCell: CellInterface, selections?: SelectionArea<SelectionAttributes>[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-paint-format.d.ts","sourceRoot":"","sources":["../../../hooks/use-paint-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"use-paint-format.d.ts","sourceRoot":"","sources":["../../../hooks/use-paint-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,MAAM,2BAA2B,CAAC;AAUnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,kBAAkB,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC3E,kBAAkB,EAAE,UAAU,CAC5B,OAAO,qBAAqB,CAC7B,CAAC,oBAAoB,CAAC,CAAC;IACxB,kBAAkB,EAAE,UAAU,CAC5B,OAAO,kBAAkB,CAC1B,CAAC,oBAAoB,CAAC,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,SAAS,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAChE;;;OAGG;IACH,aAAa,CAAC,EAAE,CACd,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,EACzB,WAAW,EAAE,SAAS,EACtB,MAAM,EAAE,SAAS,EAAE,KAChB,IAAI,CAAC;IACV;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC;CAC3E,CAAC;AAaF,eAAO,MAAM,cAAc,GAAI,2GAO5B,mBAAmB;;iCA4EP,MAAM,cACH,aAAa,cACb,aAAa,CAAC,mBAAmB,CAAC,EAAE;kCAkBvC,MAAM,cACH,aAAa,eACZ,aAAa,CAAC,mBAAmB,CAAC,EAAE;oCAkF/B,UAAU,oBAIV,UAAU;CAmCjC,CAAC"}
|