@visactor/vtable-sheet 1.23.3 → 1.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/cjs/components/sheet-tab-event-handler.js +2 -5
- package/cjs/components/sheet-tab-event-handler.js.map +1 -1
- package/cjs/components/vtable-sheet.d.ts +14 -0
- package/cjs/components/vtable-sheet.js +77 -55
- package/cjs/components/vtable-sheet.js.map +1 -1
- package/cjs/core/WorkSheet.js +3 -46
- package/cjs/core/WorkSheet.js.map +1 -1
- package/cjs/core/table-plugins.js +30 -2
- package/cjs/core/table-plugins.js.map +1 -1
- package/cjs/formula/formula-editor.d.ts +1 -1
- package/cjs/formula/formula-editor.js +22 -5
- package/cjs/formula/formula-editor.js.map +1 -1
- package/cjs/formula/formula-engine.d.ts +1 -0
- package/cjs/formula/formula-engine.js +47 -16
- package/cjs/formula/formula-engine.js.map +1 -1
- package/cjs/formula/formula-range-selector.js +1 -5
- package/cjs/formula/formula-range-selector.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/managers/formula-manager.d.ts +3 -1
- package/cjs/managers/formula-manager.js +7 -5
- package/cjs/managers/formula-manager.js.map +1 -1
- package/cjs/managers/menu-manager.d.ts +7 -1
- package/cjs/managers/menu-manager.js +37 -4
- package/cjs/managers/menu-manager.js.map +1 -1
- package/cjs/managers/tab-drag-manager.d.ts +2 -2
- package/cjs/managers/tab-drag-manager.js +1 -2
- package/cjs/managers/tab-drag-manager.js.map +1 -1
- package/cjs/managers/workbook-history-manager.d.ts +53 -0
- package/cjs/managers/workbook-history-manager.js +294 -0
- package/cjs/managers/workbook-history-manager.js.map +1 -0
- package/cjs/styles/menu.js +1 -1
- package/cjs/styles/menu.js.map +1 -1
- package/cjs/test-shims/vtable-plugins.d.ts +5 -0
- package/cjs/test-shims/vtable-plugins.js +34 -0
- package/cjs/test-shims/vtable-plugins.js.map +1 -0
- package/cjs/ts-types/base.js +1 -2
- package/cjs/ts-types/formula.js +2 -1
- package/cjs/ts-types/index.d.ts +4 -0
- package/cjs/ts-types/index.js.map +1 -1
- package/dist/vtable-sheet.js +2506 -321
- package/dist/vtable-sheet.min.js +1 -1
- package/es/components/sheet-tab-event-handler.js +1 -4
- package/es/components/sheet-tab-event-handler.js.map +1 -1
- package/es/components/vtable-sheet.d.ts +14 -0
- package/es/components/vtable-sheet.js +76 -33
- package/es/components/vtable-sheet.js.map +1 -1
- package/es/core/WorkSheet.js +3 -46
- package/es/core/WorkSheet.js.map +1 -1
- package/es/core/table-plugins.js +31 -1
- package/es/core/table-plugins.js.map +1 -1
- package/es/formula/formula-editor.d.ts +1 -1
- package/es/formula/formula-editor.js +19 -4
- package/es/formula/formula-editor.js.map +1 -1
- package/es/formula/formula-engine.d.ts +1 -0
- package/es/formula/formula-engine.js +47 -16
- package/es/formula/formula-engine.js.map +1 -1
- package/es/formula/formula-range-selector.js +1 -5
- package/es/formula/formula-range-selector.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/managers/formula-manager.d.ts +3 -1
- package/es/managers/formula-manager.js +7 -5
- package/es/managers/formula-manager.js.map +1 -1
- package/es/managers/menu-manager.d.ts +7 -1
- package/es/managers/menu-manager.js +37 -4
- package/es/managers/menu-manager.js.map +1 -1
- package/es/managers/tab-drag-manager.d.ts +2 -2
- package/es/managers/tab-drag-manager.js +1 -2
- package/es/managers/tab-drag-manager.js.map +1 -1
- package/es/managers/workbook-history-manager.d.ts +53 -0
- package/es/managers/workbook-history-manager.js +286 -0
- package/es/managers/workbook-history-manager.js.map +1 -0
- package/es/styles/menu.js +1 -1
- package/es/styles/menu.js.map +1 -1
- package/es/test-shims/vtable-plugins.d.ts +5 -0
- package/es/test-shims/vtable-plugins.js +6 -0
- package/es/test-shims/vtable-plugins.js.map +1 -0
- package/es/ts-types/base.js +1 -2
- package/es/ts-types/formula.js +2 -1
- package/es/ts-types/index.d.ts +4 -0
- package/es/ts-types/index.js.map +1 -1
- package/package.json +6 -6
package/dist/vtable-sheet.js
CHANGED
|
@@ -1080,34 +1080,29 @@
|
|
|
1080
1080
|
}
|
|
1081
1081
|
evaluateArithmeticWithFunctions(expr) {
|
|
1082
1082
|
try {
|
|
1083
|
-
const functionMatches = [];
|
|
1084
|
-
const functionRegex = /[A-Z]+\([^)]*\)/g;
|
|
1085
|
-
let match;
|
|
1086
|
-
while ((match = functionRegex.exec(expr)) !== null) {
|
|
1087
|
-
functionMatches.push({
|
|
1088
|
-
match: match[0],
|
|
1089
|
-
start: match.index,
|
|
1090
|
-
end: match.index + match[0].length
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
1083
|
let processedExpr = expr;
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1084
|
+
let guard = 0;
|
|
1085
|
+
while (true) {
|
|
1086
|
+
if (guard++ > 1000) {
|
|
1087
|
+
return { value: null, error: 'Basic arithmetic evaluation failed' };
|
|
1088
|
+
}
|
|
1089
|
+
const funcSpan = this.findInnermostFunctionCallSpan(processedExpr);
|
|
1090
|
+
if (!funcSpan) {
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
const funcCall = processedExpr.slice(funcSpan.start, funcSpan.end + 1);
|
|
1094
|
+
const funcResult = this.parseExpression(funcCall);
|
|
1097
1095
|
if (funcResult.error) {
|
|
1098
|
-
return { value: null, error: `Error in function ${
|
|
1096
|
+
return { value: null, error: `Error in function ${funcCall}: ${funcResult.error}` };
|
|
1099
1097
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1098
|
+
processedExpr =
|
|
1099
|
+
processedExpr.slice(0, funcSpan.start) + String(funcResult.value) + processedExpr.slice(funcSpan.end + 1);
|
|
1102
1100
|
}
|
|
1103
1101
|
const cellRefs = processedExpr.match(/('[^']+'!)?([A-Za-z0-9_\s一-龥]+!)?[A-Z]+[0-9]+/g) || [];
|
|
1104
1102
|
for (const cellRef of cellRefs) {
|
|
1105
1103
|
const value = this.getCellValueByA1(cellRef);
|
|
1106
1104
|
processedExpr = processedExpr.replace(cellRef, String(value));
|
|
1107
1105
|
}
|
|
1108
|
-
for (let i = 0; i < functionValues.length; i++) {
|
|
1109
|
-
processedExpr = processedExpr.replace(`__FUNC_${i}__`, String(functionValues[i]));
|
|
1110
|
-
}
|
|
1111
1106
|
const result = Function('"use strict"; return (' + processedExpr + ')')();
|
|
1112
1107
|
return { value: result, error: undefined };
|
|
1113
1108
|
}
|
|
@@ -1115,6 +1110,55 @@
|
|
|
1115
1110
|
return { value: null, error: 'Basic arithmetic evaluation failed' };
|
|
1116
1111
|
}
|
|
1117
1112
|
}
|
|
1113
|
+
findInnermostFunctionCallSpan(expr) {
|
|
1114
|
+
const stack = [];
|
|
1115
|
+
let inQuotes = false;
|
|
1116
|
+
let quoteChar = '';
|
|
1117
|
+
for (let i = 0; i < expr.length; i++) {
|
|
1118
|
+
const char = expr[i];
|
|
1119
|
+
if ((char === '"' || char === "'") && (i === 0 || expr[i - 1] !== '\\')) {
|
|
1120
|
+
if (!inQuotes) {
|
|
1121
|
+
inQuotes = true;
|
|
1122
|
+
quoteChar = char;
|
|
1123
|
+
}
|
|
1124
|
+
else if (char === quoteChar) {
|
|
1125
|
+
inQuotes = false;
|
|
1126
|
+
quoteChar = '';
|
|
1127
|
+
}
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
if (inQuotes) {
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
if (char === '(') {
|
|
1134
|
+
let j = i - 1;
|
|
1135
|
+
while (j >= 0 && expr[j] === ' ') {
|
|
1136
|
+
j--;
|
|
1137
|
+
}
|
|
1138
|
+
const idEnd = j;
|
|
1139
|
+
while (j >= 0 && /[A-Za-z0-9]/.test(expr[j])) {
|
|
1140
|
+
j--;
|
|
1141
|
+
}
|
|
1142
|
+
const idStart = j + 1;
|
|
1143
|
+
let funcStart = null;
|
|
1144
|
+
if (idStart <= idEnd && /[A-Za-z]/.test(expr[idStart])) {
|
|
1145
|
+
const beforeChar = idStart > 0 ? expr[idStart - 1] : '';
|
|
1146
|
+
if (!beforeChar || !/[A-Za-z0-9_]/.test(beforeChar)) {
|
|
1147
|
+
funcStart = idStart;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
stack.push({ funcStart });
|
|
1151
|
+
continue;
|
|
1152
|
+
}
|
|
1153
|
+
if (char === ')') {
|
|
1154
|
+
const frame = stack.pop();
|
|
1155
|
+
if (frame?.funcStart !== null && frame?.funcStart !== undefined) {
|
|
1156
|
+
return { start: frame.funcStart, end: i };
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
return null;
|
|
1161
|
+
}
|
|
1118
1162
|
getCellValueByA1(a1Notation) {
|
|
1119
1163
|
try {
|
|
1120
1164
|
let sheetKey = this.activeSheetKey || this.reverseSheets.get(0) || 'Sheet1';
|
|
@@ -1207,8 +1251,12 @@
|
|
|
1207
1251
|
const startCell = this.parseA1Notation(startParsed.cellRef);
|
|
1208
1252
|
const endCell = this.parseA1Notation(endParsed.cellRef);
|
|
1209
1253
|
const values = [];
|
|
1210
|
-
|
|
1211
|
-
|
|
1254
|
+
const minRow = Math.min(startCell.row, endCell.row);
|
|
1255
|
+
const maxRow = Math.max(startCell.row, endCell.row);
|
|
1256
|
+
const minCol = Math.min(startCell.col, endCell.col);
|
|
1257
|
+
const maxCol = Math.max(startCell.col, endCell.col);
|
|
1258
|
+
for (let row = minRow; row <= maxRow; row++) {
|
|
1259
|
+
for (let col = minCol; col <= maxCol; col++) {
|
|
1212
1260
|
const cell = { sheet: sheetKey, row, col };
|
|
1213
1261
|
values.push(this.getCellValue(cell).value);
|
|
1214
1262
|
}
|
|
@@ -2601,11 +2649,6 @@
|
|
|
2601
2649
|
newValue = currentValue;
|
|
2602
2650
|
}
|
|
2603
2651
|
formulaInput.value = newValue;
|
|
2604
|
-
this.formulaManager.setCellContent({
|
|
2605
|
-
sheet: this.formulaManager.sheet.getActiveSheet().getKey(),
|
|
2606
|
-
row: this.formulaManager.sheet.getActiveSheet().editingCell.row,
|
|
2607
|
-
col: this.formulaManager.sheet.getActiveSheet().editingCell.col
|
|
2608
|
-
}, newValue);
|
|
2609
2652
|
const newCursorPos = isCtrlAddSelection
|
|
2610
2653
|
? this.formulaManager.lastKnownCursorPosInFormulaInput + (newValue.length - currentValue.length)
|
|
2611
2654
|
: argPosition
|
|
@@ -4462,7 +4505,7 @@
|
|
|
4462
4505
|
has = (object, key) => null != object && hasOwnProperty$a.call(object, key);
|
|
4463
4506
|
var has$1 = has;
|
|
4464
4507
|
|
|
4465
|
-
function cloneDeep$
|
|
4508
|
+
function cloneDeep$2(value, ignoreWhen, excludeKeys) {
|
|
4466
4509
|
let result;
|
|
4467
4510
|
if (!isValid$2(value) || "object" != typeof value || ignoreWhen && ignoreWhen(value)) return value;
|
|
4468
4511
|
const isArr = isArray$8(value),
|
|
@@ -4473,7 +4516,7 @@
|
|
|
4473
4516
|
if (result) for (; ++index < (props || value).length;) {
|
|
4474
4517
|
const key = props ? props[index] : index,
|
|
4475
4518
|
subValue = value[key];
|
|
4476
|
-
excludeKeys && excludeKeys.includes(key.toString()) ? result[key] = subValue : result[key] = cloneDeep$
|
|
4519
|
+
excludeKeys && excludeKeys.includes(key.toString()) ? result[key] = subValue : result[key] = cloneDeep$2(subValue, ignoreWhen, excludeKeys);
|
|
4477
4520
|
}
|
|
4478
4521
|
return result;
|
|
4479
4522
|
}
|
|
@@ -25870,7 +25913,7 @@
|
|
|
25870
25913
|
return this._prevInnerView;
|
|
25871
25914
|
}
|
|
25872
25915
|
getBoundsWithoutRender(attributes) {
|
|
25873
|
-
const currentAttribute = cloneDeep$
|
|
25916
|
+
const currentAttribute = cloneDeep$2(this.attribute);
|
|
25874
25917
|
currentAttribute.scale = this.attribute.scale, this.attribute = attributes;
|
|
25875
25918
|
const offscreenGroup = graphicCreator.group({
|
|
25876
25919
|
x: this.attribute.x,
|
|
@@ -38946,6 +38989,8 @@
|
|
|
38946
38989
|
RESIZE_COLUMN_END: "resize_column_end",
|
|
38947
38990
|
RESIZE_ROW: "resize_row",
|
|
38948
38991
|
RESIZE_ROW_END: "resize_row_end",
|
|
38992
|
+
MERGE_CELLS: "merge_cells",
|
|
38993
|
+
UNMERGE_CELLS: "unmerge_cells",
|
|
38949
38994
|
CHANGE_HEADER_POSITION_START: "change_header_position_start",
|
|
38950
38995
|
CHANGE_HEADER_POSITION: "change_header_position",
|
|
38951
38996
|
CHANGING_HEADER_POSITION: "changing_header_position",
|
|
@@ -41154,7 +41199,7 @@
|
|
|
41154
41199
|
if (!this.beforeChangedRecordsMap.has(rawKey)) {
|
|
41155
41200
|
const rawRecords = Array.isArray(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.records) ? this.dataSourceObj.records : null,
|
|
41156
41201
|
originRecord = rawRecords ? Array.isArray(recordIndex) ? getValueFromDeepArray(rawRecords, recordIndex) : rawRecords[recordIndex] : void 0;
|
|
41157
|
-
this.beforeChangedRecordsMap.set(rawKey, null !== (_b = cloneDeep$
|
|
41202
|
+
this.beforeChangedRecordsMap.set(rawKey, null !== (_b = cloneDeep$2(originRecord, void 0, ["vtable_gantt_linkedFrom", "vtable_gantt_linkedTo"])) && void 0 !== _b ? _b : {});
|
|
41158
41203
|
}
|
|
41159
41204
|
if ("string" == typeof field || "number" == typeof field) {
|
|
41160
41205
|
const beforeChangedValue = null === (_c = this.beforeChangedRecordsMap.get(rawKey)) || void 0 === _c ? void 0 : _c[field],
|
|
@@ -41168,7 +41213,7 @@
|
|
|
41168
41213
|
var _a;
|
|
41169
41214
|
if (!this.beforeChangedRecordsMap.has(dataIndex.toString())) {
|
|
41170
41215
|
const originRecord = this.getOriginalRecord(dataIndex);
|
|
41171
|
-
this.beforeChangedRecordsMap.set(dataIndex.toString(), null !== (_a = cloneDeep$
|
|
41216
|
+
this.beforeChangedRecordsMap.set(dataIndex.toString(), null !== (_a = cloneDeep$2(originRecord, void 0, ["vtable_gantt_linkedFrom", "vtable_gantt_linkedTo"])) && void 0 !== _a ? _a : {});
|
|
41172
41217
|
}
|
|
41173
41218
|
}
|
|
41174
41219
|
setRecord(record, index) {
|
|
@@ -41439,7 +41484,7 @@
|
|
|
41439
41484
|
}
|
|
41440
41485
|
clearFilteredChildren(record) {
|
|
41441
41486
|
var _a, _b;
|
|
41442
|
-
record.filteredChildren = void 0;
|
|
41487
|
+
record.filteredChildren = void 0, delete record.filteredChildren;
|
|
41443
41488
|
for (let i = 0; i < (null !== (_b = null === (_a = record.children) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0); i++) this.clearFilteredChildren(record.children[i]);
|
|
41444
41489
|
}
|
|
41445
41490
|
filterRecord(record) {
|
|
@@ -41542,8 +41587,9 @@
|
|
|
41542
41587
|
fieldPromiseCallBack(_index, _field, _value) {}
|
|
41543
41588
|
recordPromiseCallBack(_index, _record) {}
|
|
41544
41589
|
canChangeOrder(sourceIndex, targetIndex) {
|
|
41545
|
-
var _a;
|
|
41590
|
+
var _a, _b;
|
|
41546
41591
|
if (null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.canChangeOrder) return this.dataSourceObj.canChangeOrder(sourceIndex, targetIndex);
|
|
41592
|
+
if (null === (_b = this.lastSortStates) || void 0 === _b ? void 0 : _b.some(state => "asc" === state.order || "desc" === state.order)) return !1;
|
|
41547
41593
|
if (this.hasHierarchyStateExpand) {
|
|
41548
41594
|
let sourceIndexs = this.currentPagerIndexedData[sourceIndex],
|
|
41549
41595
|
targetIndexs = this.currentPagerIndexedData[targetIndex];
|
|
@@ -43086,7 +43132,7 @@
|
|
|
43086
43132
|
cacheBeforeChangedRecord(dataIndex, table) {
|
|
43087
43133
|
var _a;
|
|
43088
43134
|
const originRecord = this.getOriginalRecord(dataIndex);
|
|
43089
|
-
table.internalProps.groupBy && (dataIndex = this.getOriginRecordIndexForGroup(dataIndex)), this.beforeChangedRecordsMap.has(dataIndex.toString()) || this.beforeChangedRecordsMap.set(dataIndex.toString(), null !== (_a = cloneDeep$
|
|
43135
|
+
table.internalProps.groupBy && (dataIndex = this.getOriginRecordIndexForGroup(dataIndex)), this.beforeChangedRecordsMap.has(dataIndex.toString()) || this.beforeChangedRecordsMap.set(dataIndex.toString(), null !== (_a = cloneDeep$2(originRecord, void 0, ["vtable_gantt_linkedFrom", "vtable_gantt_linkedTo"])) && void 0 !== _a ? _a : {});
|
|
43090
43136
|
}
|
|
43091
43137
|
getGroupSeriesNumber(showIndex) {
|
|
43092
43138
|
const recordIndex = this.dataSource.currentIndexedData[showIndex],
|
|
@@ -45546,7 +45592,7 @@
|
|
|
45546
45592
|
function updateCell$1(col, row, table, addNew, isShadow, forceFastUpdate) {
|
|
45547
45593
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
45548
45594
|
const oldCellGroup = table.scenegraph.highPerformanceGetCell(col, row, !0);
|
|
45549
|
-
if ("cell" !== oldCellGroup.role && !addNew) return;
|
|
45595
|
+
if ("cell" !== oldCellGroup.role && "shadow-cell" !== oldCellGroup.role && !addNew) return;
|
|
45550
45596
|
const cellLocation = table.getCellLocation(col, row);
|
|
45551
45597
|
let isMerge,
|
|
45552
45598
|
range,
|
|
@@ -52996,7 +53042,7 @@
|
|
|
52996
53042
|
}), scene.tableGroup.role = "table";
|
|
52997
53043
|
const colHeaderGroup = createContainerGroup(0, 0, !scene.table.internalProps.enableTreeStickCell);
|
|
52998
53044
|
colHeaderGroup.role = "col-header", scene.colHeaderGroup = colHeaderGroup;
|
|
52999
|
-
const cornerHeaderGroup = createContainerGroup(0, 0, !scene.table.
|
|
53045
|
+
const cornerHeaderGroup = createContainerGroup(0, 0, !scene.table.internalProps.enableTreeStickCell);
|
|
53000
53046
|
cornerHeaderGroup.role = "corner-header", scene.cornerHeaderGroup = cornerHeaderGroup;
|
|
53001
53047
|
const rowHeaderGroup = createContainerGroup(0, 0, !0);
|
|
53002
53048
|
rowHeaderGroup.role = "row-header", scene.rowHeaderGroup = rowHeaderGroup;
|
|
@@ -55794,13 +55840,13 @@
|
|
|
55794
55840
|
setSortState(sortState) {
|
|
55795
55841
|
const state = this;
|
|
55796
55842
|
const sort = (sortState = !sortState || Array.isArray(sortState) ? sortState : [sortState]) && sortState.reduce((prev, item) => {
|
|
55797
|
-
var _a, _b, _c;
|
|
55843
|
+
var _a, _b, _c, _d, _e;
|
|
55798
55844
|
const column = null === (_a = function (columns) {
|
|
55799
55845
|
const result = [];
|
|
55800
55846
|
return function flatten(cols, parentStartIndex = 0) {
|
|
55801
55847
|
cols.forEach(col => {
|
|
55802
55848
|
var _a;
|
|
55803
|
-
const startIndex = col.startInTotal ? null !== (_a =
|
|
55849
|
+
const startIndex = col.startInTotal ? col.startInTotal + (null !== (_a = state.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _a ? _a : 0) : parentStartIndex;
|
|
55804
55850
|
col.columns ? flatten(col.columns, startIndex) : result.push(Object.assign(Object.assign({}, col), {
|
|
55805
55851
|
startIndex: startIndex
|
|
55806
55852
|
}));
|
|
@@ -55810,12 +55856,12 @@
|
|
|
55810
55856
|
return this.table.internalProps.transpose ? prev.push({
|
|
55811
55857
|
field: item.field,
|
|
55812
55858
|
order: item.order,
|
|
55813
|
-
row: null !== (_b =
|
|
55859
|
+
row: (null !== (_b = null == column ? void 0 : column.startInTotal) && void 0 !== _b ? _b : 0) + (null !== (_c = this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _c ? _c : 0),
|
|
55814
55860
|
col: null == column ? void 0 : column.level
|
|
55815
55861
|
}) : prev.push({
|
|
55816
55862
|
field: item.field,
|
|
55817
55863
|
order: item.order,
|
|
55818
|
-
col: null !== (
|
|
55864
|
+
col: (null !== (_d = null == column ? void 0 : column.startInTotal) && void 0 !== _d ? _d : 0) + (null !== (_e = this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _e ? _e : 0),
|
|
55819
55865
|
row: null == column ? void 0 : column.level
|
|
55820
55866
|
}), prev;
|
|
55821
55867
|
}, []);
|
|
@@ -56327,13 +56373,16 @@
|
|
|
56327
56373
|
this.select.selectInline = selectInline;
|
|
56328
56374
|
}
|
|
56329
56375
|
updateSortState(sortState) {
|
|
56330
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
56331
|
-
sortState = Array.isArray(sortState) ? sortState : [sortState]
|
|
56376
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
56377
|
+
const isSame = (sortState = Array.isArray(sortState) ? sortState : [sortState]).length === this.sort.length && sortState.every((item, index) => {
|
|
56378
|
+
var _a, _b;
|
|
56379
|
+
return (null == item ? void 0 : item.field) === (null === (_a = this.sort[index]) || void 0 === _a ? void 0 : _a.field) && (null == item ? void 0 : item.order) === (null === (_b = this.sort[index]) || void 0 === _b ? void 0 : _b.order);
|
|
56380
|
+
});
|
|
56381
|
+
if (isSame) return;
|
|
56332
56382
|
for (let index = 0; index < sortState.length; index++) {
|
|
56333
|
-
|
|
56334
|
-
|
|
56335
|
-
|
|
56336
|
-
"asc" === (null === (_e = this.sort[index]) || void 0 === _e ? void 0 : _e.order) || null === (_f = this.sort[index]) || void 0 === _f || _f.order;
|
|
56383
|
+
const oldSortCol = this.table.internalProps.multipleSort ? null : (null === (_a = this.sort[index]) || void 0 === _a ? void 0 : _a.col) || null,
|
|
56384
|
+
oldSortRow = this.table.internalProps.multipleSort ? null : (null === (_b = this.sort[index]) || void 0 === _b ? void 0 : _b.row) || null;
|
|
56385
|
+
"asc" === (null === (_c = this.sort[index]) || void 0 === _c ? void 0 : _c.order) || null === (_d = this.sort[index]) || void 0 === _d || _d.order;
|
|
56337
56386
|
this.setSortState(sortState.slice(0, index + 1));
|
|
56338
56387
|
const cellAddress = this.table.internalProps.layoutMap.getHeaderCellAddressByField(sortState[index].field);
|
|
56339
56388
|
this.sort[index].col = cellAddress.col, this.sort[index].row = cellAddress.row;
|
|
@@ -56346,7 +56395,7 @@
|
|
|
56346
56395
|
order: this.sort[index].order,
|
|
56347
56396
|
oldSortCol: oldSortCol,
|
|
56348
56397
|
oldSortRow: oldSortRow,
|
|
56349
|
-
oldIconMark: null === (
|
|
56398
|
+
oldIconMark: null === (_e = this.sort[index]) || void 0 === _e ? void 0 : _e.icon
|
|
56350
56399
|
});
|
|
56351
56400
|
}
|
|
56352
56401
|
const normalHeaders = [];
|
|
@@ -56360,7 +56409,7 @@
|
|
|
56360
56409
|
row: null,
|
|
56361
56410
|
iconMark: null,
|
|
56362
56411
|
order: null,
|
|
56363
|
-
oldSortCol: null !== (
|
|
56412
|
+
oldSortCol: (null !== (_f = column.startInTotal) && void 0 !== _f ? _f : 0) + (null !== (_g = this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _g ? _g : 0),
|
|
56364
56413
|
oldSortRow: column.level,
|
|
56365
56414
|
oldIconMark: null
|
|
56366
56415
|
});
|
|
@@ -59913,7 +59962,7 @@
|
|
|
59913
59962
|
sourceColumns.unshift(targetSubIndex, 0), Array.prototype.splice.apply(children, sourceColumns);
|
|
59914
59963
|
}
|
|
59915
59964
|
getCopiedTree() {
|
|
59916
|
-
const children = cloneDeep$
|
|
59965
|
+
const children = cloneDeep$2(this.tree.children);
|
|
59917
59966
|
return clearNode(children), children;
|
|
59918
59967
|
}
|
|
59919
59968
|
setAllNodesState(state) {
|
|
@@ -60541,7 +60590,7 @@
|
|
|
60541
60590
|
}
|
|
60542
60591
|
}
|
|
60543
60592
|
|
|
60544
|
-
function getCustomMergeCellFunc(customMergeCell) {
|
|
60593
|
+
function getCustomMergeCellFunc$1(customMergeCell) {
|
|
60545
60594
|
return isFunction$4(customMergeCell) ? customMergeCell : isArray$8(customMergeCell) ? (col, row) => customMergeCell.find(item => item.range.start.col <= col && item.range.end.col >= col && item.range.start.row <= row && item.range.end.row >= row) : void 0;
|
|
60546
60595
|
}
|
|
60547
60596
|
|
|
@@ -60613,7 +60662,7 @@
|
|
|
60613
60662
|
}
|
|
60614
60663
|
constructor(container, options = {}) {
|
|
60615
60664
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
60616
|
-
if (super(), this.showFrozenIcon = !0, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.
|
|
60665
|
+
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.24.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env$1.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
|
|
60617
60666
|
this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
|
|
60618
60667
|
options: options,
|
|
60619
60668
|
container: container
|
|
@@ -60730,7 +60779,7 @@
|
|
|
60730
60779
|
}
|
|
60731
60780
|
this.headerStyleCache = new Map(), this.bodyStyleCache = new Map(), this.bodyMergeTitleCache = new Map(), this.bodyBottomStyleCache = new Map(), internalProps.stick = {
|
|
60732
60781
|
changedCells: new Map()
|
|
60733
|
-
}, internalProps.customMergeCell = getCustomMergeCellFunc(options.customMergeCell);
|
|
60782
|
+
}, internalProps.customMergeCell = getCustomMergeCellFunc$1(options.customMergeCell);
|
|
60734
60783
|
const CustomCellStylePlugin = Factory.getComponent("customCellStylePlugin");
|
|
60735
60784
|
CustomCellStylePlugin && (this.customCellStylePlugin = new CustomCellStylePlugin(this, null !== (_y = options.customCellStyle) && void 0 !== _y ? _y : [], null !== (_z = options.customCellStyleArrangement) && void 0 !== _z ? _z : [])), this._adjustCanvasSizeByOption();
|
|
60736
60785
|
}
|
|
@@ -61551,12 +61600,15 @@
|
|
|
61551
61600
|
dispose() {
|
|
61552
61601
|
this.release();
|
|
61553
61602
|
}
|
|
61603
|
+
clearCorrectTimer() {
|
|
61604
|
+
this._scrollToRowCorrectTimer && (clearTimeout(this._scrollToRowCorrectTimer), this._scrollToRowCorrectTimer = null);
|
|
61605
|
+
}
|
|
61554
61606
|
release() {
|
|
61555
61607
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
61556
61608
|
null === (_c = null === (_b = null === (_a = this.scenegraph) || void 0 === _a ? void 0 : _a.component) || void 0 === _b ? void 0 : _b.vScrollBar) || void 0 === _c || _c.release(), null === (_f = null === (_e = null === (_d = this.scenegraph) || void 0 === _d ? void 0 : _d.component) || void 0 === _e ? void 0 : _e.hScrollBar) || void 0 === _f || _f.release(), this.animationManager.clear(), this.animationManager.ticker.release(), null === (_j = null === (_h = null === (_g = this.scenegraph) || void 0 === _g ? void 0 : _g.stage) || void 0 === _h ? void 0 : _h.ticker) || void 0 === _j || _j.release();
|
|
61557
61609
|
const internalProps = this.internalProps;
|
|
61558
61610
|
if (this.isReleased) return;
|
|
61559
|
-
null === (_l = null === (_k = internalProps.tooltipHandler) || void 0 === _k ? void 0 : _k.release) || void 0 === _l || _l.call(_k), null === (_o = null === (_m = internalProps.menuHandler) || void 0 === _m ? void 0 : _m.release) || void 0 === _o || _o.call(_m), null === (_p = super.release) || void 0 === _p || _p.call(this), this.pluginManager.release(), null === (_r = null === (_q = internalProps.handler) || void 0 === _q ? void 0 : _q.release) || void 0 === _r || _r.call(_q), this.eventManager.release(), null === (_t = null === (_s = internalProps.focusControl) || void 0 === _s ? void 0 : _s.release) || void 0 === _t || _t.call(_s), null === (_u = internalProps.legends) || void 0 === _u || _u.forEach(legend => {
|
|
61611
|
+
this.clearCorrectTimer(), null === (_l = null === (_k = internalProps.tooltipHandler) || void 0 === _k ? void 0 : _k.release) || void 0 === _l || _l.call(_k), null === (_o = null === (_m = internalProps.menuHandler) || void 0 === _m ? void 0 : _m.release) || void 0 === _o || _o.call(_m), null === (_p = super.release) || void 0 === _p || _p.call(this), this.pluginManager.release(), null === (_r = null === (_q = internalProps.handler) || void 0 === _q ? void 0 : _q.release) || void 0 === _r || _r.call(_q), this.eventManager.release(), null === (_t = null === (_s = internalProps.focusControl) || void 0 === _s ? void 0 : _s.release) || void 0 === _t || _t.call(_s), null === (_u = internalProps.legends) || void 0 === _u || _u.forEach(legend => {
|
|
61560
61612
|
null == legend || legend.release();
|
|
61561
61613
|
}), null === (_v = internalProps.title) || void 0 === _v || _v.release(), internalProps.title = null, null === (_w = internalProps.emptyTip) || void 0 === _w || _w.release(), internalProps.emptyTip = null, internalProps.layoutMap.release(), internalProps.releaseList && (internalProps.releaseList.forEach(releaseObj => {
|
|
61562
61614
|
var _a;
|
|
@@ -61669,7 +61721,7 @@
|
|
|
61669
61721
|
const MenuHandler = Factory.getComponent("menuHandler");
|
|
61670
61722
|
internalProps.menuHandler = new MenuHandler(this);
|
|
61671
61723
|
}
|
|
61672
|
-
this.clearCellStyleCache(), (null == updateConfig ? void 0 : updateConfig.clearColWidthCache) && this.clearColWidthCache(), (null == updateConfig ? void 0 : updateConfig.clearRowHeightCache) && this.clearRowHeightCache(), internalProps.customMergeCell = getCustomMergeCellFunc(options.customMergeCell), null === (_z = this.customCellStylePlugin) || void 0 === _z || _z.updateCustomCell(null !== (_0 = options.customCellStyle) && void 0 !== _0 ? _0 : [], null !== (_1 = options.customCellStyleArrangement) && void 0 !== _1 ? _1 : []), this._adjustCanvasSizeByOption();
|
|
61724
|
+
this.clearCellStyleCache(), (null == updateConfig ? void 0 : updateConfig.clearColWidthCache) && this.clearColWidthCache(), (null == updateConfig ? void 0 : updateConfig.clearRowHeightCache) && this.clearRowHeightCache(), internalProps.customMergeCell = getCustomMergeCellFunc$1(options.customMergeCell), null === (_z = this.customCellStylePlugin) || void 0 === _z || _z.updateCustomCell(null !== (_0 = options.customCellStyle) && void 0 !== _0 ? _0 : [], null !== (_1 = options.customCellStyleArrangement) && void 0 !== _1 ? _1 : []), this._adjustCanvasSizeByOption();
|
|
61673
61725
|
}
|
|
61674
61726
|
renderWithRecreateCells() {
|
|
61675
61727
|
this.internalProps.stick.changedCells.clear();
|
|
@@ -61861,6 +61913,30 @@
|
|
|
61861
61913
|
lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
|
|
61862
61914
|
lastSelectRange && (lastSelectRange.end.row = rowIndex), this.stateManager.updateSelectPos(this.colCount - 1, rowIndex, !1, isCtrl, !1, makeSelectCellVisible, !0), this.stateManager.select.selecting = !1;
|
|
61863
61915
|
}
|
|
61916
|
+
changeHeaderPosition(args) {
|
|
61917
|
+
var _a, _b, _c, _d, _e;
|
|
61918
|
+
if (!("canMoveHeaderPosition" in this.internalProps.layoutMap) || !0 === (null === (_a = this.options.customConfig) || void 0 === _a ? void 0 : _a.notUpdateInColumnRowMove)) return !1;
|
|
61919
|
+
const prevMoving = this.stateManager.columnMove.movingColumnOrRow;
|
|
61920
|
+
this.stateManager.columnMove.movingColumnOrRow = args.movingColumnOrRow;
|
|
61921
|
+
try {
|
|
61922
|
+
if (!1 === (null === (_c = (_b = this.internalProps.layoutMap).canMoveHeaderPosition) || void 0 === _c ? void 0 : _c.call(_b, args.source, args.target))) return !1;
|
|
61923
|
+
const oldSourceMergeInfo = this.getCellRange(args.source.col, args.source.row),
|
|
61924
|
+
oldTargetMergeInfo = this.getCellRange(args.target.col, args.target.row),
|
|
61925
|
+
moveContext = this._moveHeaderPosition(args.source, args.target);
|
|
61926
|
+
if (!moveContext || moveContext.targetIndex === moveContext.sourceIndex) return !1;
|
|
61927
|
+
this.internalProps.useOneRowHeightFillAll = !1, this.internalProps.layoutMap.clearCellRangeMap();
|
|
61928
|
+
const sourceMergeInfo = this.getCellRange(args.source.col, args.source.row),
|
|
61929
|
+
targetMergeInfo = this.getCellRange(args.target.col, args.target.row),
|
|
61930
|
+
colMin = Math.min(sourceMergeInfo.start.col, targetMergeInfo.start.col, oldSourceMergeInfo.start.col, oldTargetMergeInfo.start.col),
|
|
61931
|
+
colMax = Math.max(sourceMergeInfo.end.col, targetMergeInfo.end.col, oldSourceMergeInfo.end.col, oldTargetMergeInfo.end.col),
|
|
61932
|
+
rowMin = Math.min(sourceMergeInfo.start.row, targetMergeInfo.start.row, oldSourceMergeInfo.start.row, oldTargetMergeInfo.start.row);
|
|
61933
|
+
let rowMax = Math.max(sourceMergeInfo.end.row, targetMergeInfo.end.row, oldSourceMergeInfo.end.row, oldTargetMergeInfo.end.row);
|
|
61934
|
+
if ("row" === moveContext.moveType && "tree" === this.internalProps.layoutMap.rowHierarchyType && (rowMax = moveContext.targetIndex > moveContext.sourceIndex ? rowMax + moveContext.targetSize - 1 : rowMax + moveContext.sourceSize - 1), this.transpose || !this.isSeriesNumberInBody(args.source.col, args.source.row) && "row" !== args.movingColumnOrRow || (this.changeRecordOrder(moveContext.sourceIndex, moveContext.targetIndex), this.stateManager.changeCheckboxAndRadioOrder(moveContext.sourceIndex, moveContext.targetIndex)), "column" === moveContext.moveType) for (let col = colMin; col <= colMax; col++) this._clearColRangeWidthsMap(col);else for (let row = rowMin; row <= rowMax; row++) this._clearRowRangeHeightsMap(row);
|
|
61935
|
+
return this.clearCellStyleCache(), this.isSeriesNumberInBody(args.source.col, args.source.row) || "row" === args.movingColumnOrRow ? this.scenegraph.updateHeaderPosition(this.scenegraph.proxy.colStart, this.scenegraph.proxy.colEnd, this.scenegraph.proxy.rowStart, this.scenegraph.proxy.rowEnd, moveContext.moveType) : "column" === moveContext.moveType ? this.scenegraph.updateHeaderPosition(colMin, colMax, 0, -1, moveContext.moveType) : this.scenegraph.updateHeaderPosition(0, -1, rowMin, rowMax, moveContext.moveType), "adjustFrozenCount" === this.internalProps.frozenColDragHeaderMode && this.isListTable() && (this.isLeftFrozenColumn(args.target.col) && !this.isLeftFrozenColumn(args.source.col) ? this.frozenColCount += sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1 : this.isLeftFrozenColumn(args.source.col) && !this.isLeftFrozenColumn(args.target.col) && (this.frozenColCount -= sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1), this.isRightFrozenColumn(args.target.col) && !this.isRightFrozenColumn(args.source.col) ? this.rightFrozenColCount += sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1 : this.isRightFrozenColumn(args.source.col) && !this.isRightFrozenColumn(args.target.col) && (this.rightFrozenColCount -= sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1)), null === (_e = (_d = this.scenegraph).updateNextFrame) || void 0 === _e || _e.call(_d), !0;
|
|
61936
|
+
} finally {
|
|
61937
|
+
this.stateManager.columnMove.movingColumnOrRow = prevMoving;
|
|
61938
|
+
}
|
|
61939
|
+
}
|
|
61864
61940
|
get recordsCount() {
|
|
61865
61941
|
var _a;
|
|
61866
61942
|
return null === (_a = this.records) || void 0 === _a ? void 0 : _a.length;
|
|
@@ -62006,7 +62082,7 @@
|
|
|
62006
62082
|
getCustomMerge(col, row) {
|
|
62007
62083
|
if (this.internalProps.customMergeCell) {
|
|
62008
62084
|
const customMerge = this.internalProps.customMergeCell(col, row, this);
|
|
62009
|
-
if (customMerge && customMerge.range
|
|
62085
|
+
if (customMerge && customMerge.range) {
|
|
62010
62086
|
if (customMerge.style) {
|
|
62011
62087
|
const styleClass = this.internalProps.bodyHelper.getStyleClass("text"),
|
|
62012
62088
|
style = customMerge.style,
|
|
@@ -62412,7 +62488,7 @@
|
|
|
62412
62488
|
}
|
|
62413
62489
|
getSelectedCellRanges() {
|
|
62414
62490
|
const ranges = this.stateManager.select.ranges;
|
|
62415
|
-
return ranges.length ? cloneDeep$
|
|
62491
|
+
return ranges.length ? cloneDeep$2(ranges) : [];
|
|
62416
62492
|
}
|
|
62417
62493
|
measureText(text, font) {
|
|
62418
62494
|
return textMeasure.measureText(text, font);
|
|
@@ -62717,12 +62793,34 @@
|
|
|
62717
62793
|
this.eventManager.enableScroll();
|
|
62718
62794
|
}
|
|
62719
62795
|
getGroupTitleLevel(col, row) {}
|
|
62796
|
+
getTargetScrollTop(row) {
|
|
62797
|
+
const drawRange = this.getDrawRange(),
|
|
62798
|
+
frozenHeight = this.getFrozenRowsHeight();
|
|
62799
|
+
return Math.max(0, Math.min(this.getRowsHeight(0, row - 1) - frozenHeight, this.getAllRowsHeight() - drawRange.height));
|
|
62800
|
+
}
|
|
62801
|
+
_scheduleScrollToRowCorrect(row, delay = 0) {
|
|
62802
|
+
this._scrollToRowCorrectTimer = setTimeout(() => {
|
|
62803
|
+
this.clearCorrectTimer();
|
|
62804
|
+
const targetScrollTop = this.getTargetScrollTop(row);
|
|
62805
|
+
if (targetScrollTop !== this.scrollTop) {
|
|
62806
|
+
this.scrollTop = targetScrollTop;
|
|
62807
|
+
const correctedTargetScrollTop = this.getTargetScrollTop(row);
|
|
62808
|
+
correctedTargetScrollTop !== this.scrollTop && (this.scrollTop = correctedTargetScrollTop);
|
|
62809
|
+
}
|
|
62810
|
+
}, delay);
|
|
62811
|
+
}
|
|
62720
62812
|
scrollToRow(row, animationOption) {
|
|
62721
|
-
|
|
62722
|
-
|
|
62723
|
-
|
|
62724
|
-
row:
|
|
62725
|
-
});
|
|
62813
|
+
var _a;
|
|
62814
|
+
const targetRow = Math.min(Math.max(Math.floor(row), 0), this.rowCount - 1);
|
|
62815
|
+
if (this.clearCorrectTimer(), !animationOption) return this.scrollToCell({
|
|
62816
|
+
row: targetRow
|
|
62817
|
+
}), void this._scheduleScrollToRowCorrect(targetRow);
|
|
62818
|
+
const duration = isBoolean$2(animationOption) ? 3e3 : null !== (_a = null == animationOption ? void 0 : animationOption.duration) && void 0 !== _a ? _a : 3e3;
|
|
62819
|
+
this.animationManager.scrollTo({
|
|
62820
|
+
row: targetRow
|
|
62821
|
+
}, animationOption), this._scrollToRowCorrectTimer = setTimeout(() => {
|
|
62822
|
+
this.scrollToRow(targetRow, !1);
|
|
62823
|
+
}, duration);
|
|
62726
62824
|
}
|
|
62727
62825
|
scrollToCol(col, animationOption) {
|
|
62728
62826
|
animationOption ? this.animationManager.scrollTo({
|
|
@@ -62741,8 +62839,8 @@
|
|
|
62741
62839
|
}
|
|
62742
62840
|
if (isValid$2(cellAddr.row) && cellAddr.row >= this.frozenRowCount) {
|
|
62743
62841
|
const frozenHeight = this.getFrozenRowsHeight(),
|
|
62744
|
-
top = this.
|
|
62745
|
-
this.scrollTop = Math.min(top - frozenHeight, this.
|
|
62842
|
+
top = this.rowHeightsMap.getSumInRange(0, cellAddr.row - 1);
|
|
62843
|
+
this.scrollTop = Math.min(top - frozenHeight, this.rowHeightsMap.getSumInRange(0, this.rowCount - 1) - drawRange.height);
|
|
62746
62844
|
}
|
|
62747
62845
|
this.render();
|
|
62748
62846
|
}
|
|
@@ -63042,7 +63140,7 @@
|
|
|
63042
63140
|
}
|
|
63043
63141
|
cloneParseData(data, options) {
|
|
63044
63142
|
let clone = !1;
|
|
63045
|
-
return data instanceof DataView || !0 !== (null == options ? void 0 : options.clone) || (clone = !0), clone ? cloneDeep$
|
|
63143
|
+
return data instanceof DataView || !0 !== (null == options ? void 0 : options.clone) || (clone = !0), clone ? cloneDeep$2(data) : data;
|
|
63046
63144
|
}
|
|
63047
63145
|
parseNewData(data, options) {
|
|
63048
63146
|
this.parse(data, options || this.parseOption), this.reRunAllTransform();
|
|
@@ -63075,7 +63173,7 @@
|
|
|
63075
63173
|
|
|
63076
63174
|
const ignoreWhen = value => isDataView(value) || isHTMLElement(value);
|
|
63077
63175
|
function cloneDeepSpec(spec, excludeKeys = ["data"]) {
|
|
63078
|
-
return cloneDeep$
|
|
63176
|
+
return cloneDeep$2(spec, ignoreWhen, excludeKeys);
|
|
63079
63177
|
}
|
|
63080
63178
|
|
|
63081
63179
|
function transformLegendTitleAttributes(title) {
|
|
@@ -63390,9 +63488,24 @@
|
|
|
63390
63488
|
return layout._cellRangeMap.set(`$${col}$${row}`, cellRange), cellRange;
|
|
63391
63489
|
}
|
|
63392
63490
|
function getTreeTitleMerge(col, row, cellRange, layout) {
|
|
63491
|
+
var _a;
|
|
63393
63492
|
if ("tree" !== layout.rowHierarchyType) return;
|
|
63394
|
-
const
|
|
63395
|
-
|
|
63493
|
+
const table = layout._table,
|
|
63494
|
+
internalProps = table.internalProps || {},
|
|
63495
|
+
isGroupMode = !!internalProps.groupBy,
|
|
63496
|
+
cellRecord = table.getCellRawRecord(col, row);
|
|
63497
|
+
if (!(null == cellRecord ? void 0 : cellRecord.vtableMerge)) return;
|
|
63498
|
+
const treeTitleStartCol = internalProps.groupTitleCheckbox && internalProps.rowSeriesNumber ? layout.rowHeaderLevelCount + layout.leftRowSeriesNumberColumnCount : layout.rowHeaderLevelCount;
|
|
63499
|
+
if (!(col < treeTitleStartCol) && (cellRange.start.col = treeTitleStartCol, cellRange.end.col = layout.colCount - 1, cellRange.start.row = cellRange.end.row = row, isGroupMode && 1 === (null === (_a = layout.columnObjects) || void 0 === _a ? void 0 : _a.length))) {
|
|
63500
|
+
const onlyColumn = layout.columnObjects[0],
|
|
63501
|
+
field = null == onlyColumn ? void 0 : onlyColumn.field;
|
|
63502
|
+
if (null != field) {
|
|
63503
|
+
let text = cellRecord.vtableMergeName;
|
|
63504
|
+
const groupTitleFieldFormat = internalProps.groupTitleFieldFormat;
|
|
63505
|
+
"function" == typeof groupTitleFieldFormat && (text = groupTitleFieldFormat(cellRecord, col, row, table));
|
|
63506
|
+
null == cellRecord[field] && null != text && (cellRecord[field] = text);
|
|
63507
|
+
}
|
|
63508
|
+
}
|
|
63396
63509
|
}
|
|
63397
63510
|
function getCellRangeTranspose(col, row, layout) {
|
|
63398
63511
|
var _a, _b, _c, _d;
|
|
@@ -64309,7 +64422,7 @@
|
|
|
64309
64422
|
this.listenersId.push(doubleClickEventId, clickEventId, selectedChangedEventId);
|
|
64310
64423
|
}
|
|
64311
64424
|
startEditCell(col, row, value, editElement) {
|
|
64312
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
64425
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
64313
64426
|
if (this.editingEditor) return;
|
|
64314
64427
|
const editor = this.table.getEditor(col, row);
|
|
64315
64428
|
if (editor) {
|
|
@@ -64325,7 +64438,8 @@
|
|
|
64325
64438
|
col: col,
|
|
64326
64439
|
row: row
|
|
64327
64440
|
}), this.table._makeVisibleCell(col, row), this.editingEditor = editor;
|
|
64328
|
-
const
|
|
64441
|
+
const customMergeText = null === (_j = this.table.getCustomMerge(col, row)) || void 0 === _j ? void 0 : _j.text,
|
|
64442
|
+
dataValue = isValid$2(value) ? value : isValid$2(customMergeText) ? customMergeText : this.table.getCellOriginValue(col, row),
|
|
64329
64443
|
rect = this.table.getCellRangeRelativeRect(this.table.getCellRange(col, row)),
|
|
64330
64444
|
referencePosition = {
|
|
64331
64445
|
rect: {
|
|
@@ -64335,9 +64449,9 @@
|
|
|
64335
64449
|
height: rect.height
|
|
64336
64450
|
}
|
|
64337
64451
|
};
|
|
64338
|
-
col === this.table.colCount - 1 ? referencePosition.rect.width = rect.width - 1 : referencePosition.rect.width = rect.width + 1, row === this.table.rowCount - 1 ? referencePosition.rect.height = rect.height - 1 : referencePosition.rect.height = rect.height + 1, editor.beginEditing, null === (
|
|
64452
|
+
col === this.table.colCount - 1 ? referencePosition.rect.width = rect.width - 1 : referencePosition.rect.width = rect.width + 1, row === this.table.rowCount - 1 ? referencePosition.rect.height = rect.height - 1 : referencePosition.rect.height = rect.height + 1, editor.beginEditing, null === (_k = editor.beginEditing) || void 0 === _k || _k.call(editor, this.table.getElement(), referencePosition, dataValue), editor.bindSuccessCallback, null === (_l = editor.bindSuccessCallback) || void 0 === _l || _l.call(editor, () => {
|
|
64339
64453
|
this.completeEdit();
|
|
64340
|
-
}), null === (
|
|
64454
|
+
}), null === (_m = editor.onStart) || void 0 === _m || _m.call(editor, {
|
|
64341
64455
|
value: dataValue,
|
|
64342
64456
|
endEdit: () => {
|
|
64343
64457
|
this.completeEdit();
|
|
@@ -64351,7 +64465,7 @@
|
|
|
64351
64465
|
}
|
|
64352
64466
|
}
|
|
64353
64467
|
completeEdit(e) {
|
|
64354
|
-
var _a, _b;
|
|
64468
|
+
var _a, _b, _c;
|
|
64355
64469
|
if (!this.editingEditor) return !0;
|
|
64356
64470
|
if (this.isValidatingValue) return !1;
|
|
64357
64471
|
this.cacheLastSelectedCellEditor = {};
|
|
@@ -64365,9 +64479,10 @@
|
|
|
64365
64479
|
if (this.editingEditor.getValue, this.editingEditor.validateValue) {
|
|
64366
64480
|
this.isValidatingValue = !0;
|
|
64367
64481
|
const newValue = this.editingEditor.getValue(),
|
|
64368
|
-
|
|
64482
|
+
customMergeText = null === (_a = this.table.getCustomMerge(this.editCell.col, this.editCell.row)) || void 0 === _a ? void 0 : _a.text,
|
|
64483
|
+
oldValue = isValid$2(customMergeText) ? customMergeText : this.table.getCellOriginValue(this.editCell.col, this.editCell.row),
|
|
64369
64484
|
target = null == e ? void 0 : e.target,
|
|
64370
|
-
maybePromiseOrValue = null === (
|
|
64485
|
+
maybePromiseOrValue = null === (_c = (_b = this.editingEditor).validateValue) || void 0 === _c ? void 0 : _c.call(_b, newValue, oldValue, this.editCell, this.table, !!this.table.getElement().contains(target));
|
|
64371
64486
|
return isPromise(maybePromiseOrValue) ? (this.isValidatingValue = !0, new Promise((resolve, reject) => {
|
|
64372
64487
|
maybePromiseOrValue.then(result => {
|
|
64373
64488
|
dealWithValidateValue(result, this, oldValue, resolve);
|
|
@@ -64381,14 +64496,17 @@
|
|
|
64381
64496
|
doExit() {
|
|
64382
64497
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
64383
64498
|
const changedValue = null === (_b = (_a = this.editingEditor).getValue) || void 0 === _b ? void 0 : _b.call(_a),
|
|
64384
|
-
range = this.table.getCellRange(this.editCell.col, this.editCell.row)
|
|
64385
|
-
|
|
64386
|
-
|
|
64387
|
-
|
|
64388
|
-
|
|
64389
|
-
|
|
64499
|
+
range = this.table.getCellRange(this.editCell.col, this.editCell.row);
|
|
64500
|
+
if (null === (_d = (_c = this.editingEditor).beforeEnd) || void 0 === _d || _d.call(_c), range.isCustom) this.table.changeCellValue(range.start.col, range.start.row, changedValue);else {
|
|
64501
|
+
const changedValues = [];
|
|
64502
|
+
for (let row = range.start.row; row <= range.end.row; row++) {
|
|
64503
|
+
const rowChangedValues = [];
|
|
64504
|
+
for (let col = range.start.col; col <= range.end.col; col++) rowChangedValues.push(changedValue);
|
|
64505
|
+
changedValues.push(rowChangedValues);
|
|
64506
|
+
}
|
|
64507
|
+
this.table.changeCellValues(range.start.col, range.start.row, changedValues);
|
|
64390
64508
|
}
|
|
64391
|
-
|
|
64509
|
+
this.editingEditor.exit, null === (_f = (_e = this.editingEditor).exit) || void 0 === _f || _f.call(_e), null === (_h = (_g = this.editingEditor).onEnd) || void 0 === _h || _h.call(_g), this.editingEditor = null, this.isValidatingValue = !1, this.beginTriggerEditCellMode = null;
|
|
64392
64510
|
}
|
|
64393
64511
|
cancelEdit() {
|
|
64394
64512
|
var _a, _b, _c, _d;
|
|
@@ -64448,7 +64566,18 @@
|
|
|
64448
64566
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64449
64567
|
});
|
|
64450
64568
|
};
|
|
64569
|
+
function refreshCustomMergeCellGroups(table) {
|
|
64570
|
+
var _a;
|
|
64571
|
+
if (!Array.isArray(table.options.customMergeCell)) return;
|
|
64572
|
+
table.internalProps.customMergeCell = getCustomMergeCellFunc$1(table.options.customMergeCell);
|
|
64573
|
+
const merges = table.options.customMergeCell;
|
|
64574
|
+
for (let i = 0; i < merges.length; i++) {
|
|
64575
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
64576
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) table.scenegraph.updateCellContent(col, row);
|
|
64577
|
+
}
|
|
64578
|
+
}
|
|
64451
64579
|
function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
|
|
64580
|
+
var _a, _b;
|
|
64452
64581
|
if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
|
|
64453
64582
|
const recordShowIndex = table.getRecordShowIndexByCell(col, row),
|
|
64454
64583
|
recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
|
|
@@ -64458,8 +64587,12 @@
|
|
|
64458
64587
|
beforeChangeValue = table.getCellRawValue(col, row),
|
|
64459
64588
|
oldValue = table.getCellOriginValue(col, row);
|
|
64460
64589
|
table.isHeader(col, row) ? table.internalProps.layoutMap.updateColumnTitle(col, row, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, col, row, table);
|
|
64461
|
-
const range = table.getCellRange(col, row)
|
|
64462
|
-
|
|
64590
|
+
const range = table.getCellRange(col, row);
|
|
64591
|
+
if (range.isCustom && range.start.col === col && range.start.row === row && Array.isArray(table.options.customMergeCell) && "function" == typeof table.getCellValue) {
|
|
64592
|
+
const customMerge = null === (_b = null === (_a = table.internalProps) || void 0 === _a ? void 0 : _a.customMergeCell) || void 0 === _b ? void 0 : _b.call(_a, col, row, table);
|
|
64593
|
+
customMerge && (customMerge.text = value);
|
|
64594
|
+
}
|
|
64595
|
+
const aggregators = table.internalProps.layoutMap.getAggregatorsByCell(col, row);
|
|
64463
64596
|
if (aggregators) {
|
|
64464
64597
|
if (Array.isArray(aggregators)) for (let i = 0; i < (null == aggregators ? void 0 : aggregators.length); i++) aggregators[i].recalculate();else aggregators.recalculate();
|
|
64465
64598
|
const aggregatorCells = table.internalProps.layoutMap.getAggregatorCellAddress(range.start.col, range.start.row, range.end.col, range.end.row);
|
|
@@ -64682,7 +64815,13 @@
|
|
|
64682
64815
|
(void 0 === recordIndex || recordIndex > table.dataSource.sourceLength) && (recordIndex = table.dataSource.sourceLength);
|
|
64683
64816
|
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64684
64817
|
syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords);
|
|
64685
|
-
if (table.dataSource.addRecord(record, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1), syncToOriginalRecords)
|
|
64818
|
+
if (table.dataSource.addRecord(record, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1), syncToOriginalRecords) {
|
|
64819
|
+
if (!table.transpose) {
|
|
64820
|
+
const insertRowIndex = recordIndex + headerCount + table.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
64821
|
+
table.rowHeightsMap.insert(insertRowIndex);
|
|
64822
|
+
}
|
|
64823
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(!0), !0;
|
|
64824
|
+
}
|
|
64686
64825
|
const oldRowCount = table.rowCount;
|
|
64687
64826
|
if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
|
|
64688
64827
|
const newRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
@@ -64760,7 +64899,13 @@
|
|
|
64760
64899
|
void 0 === recordIndex || recordIndex > table.dataSource.sourceLength ? recordIndex = table.dataSource.sourceLength : recordIndex < 0 && (recordIndex = 0);
|
|
64761
64900
|
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64762
64901
|
syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords);
|
|
64763
|
-
if (table.dataSource.addRecords(records, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length), syncToOriginalRecords)
|
|
64902
|
+
if (table.dataSource.addRecords(records, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length), syncToOriginalRecords) {
|
|
64903
|
+
if (!table.transpose) {
|
|
64904
|
+
const insertRowIndex = recordIndex + headerCount + table.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
64905
|
+
for (let i = 0; i < records.length; i++) table.rowHeightsMap.insert(insertRowIndex);
|
|
64906
|
+
}
|
|
64907
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(!0), !0;
|
|
64908
|
+
}
|
|
64764
64909
|
const oldRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
64765
64910
|
if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
|
|
64766
64911
|
const newRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
@@ -64829,7 +64974,7 @@
|
|
|
64829
64974
|
}
|
|
64830
64975
|
}
|
|
64831
64976
|
function listTableDeleteRecords(recordIndexs, table) {
|
|
64832
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
64977
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
64833
64978
|
if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0) if (table.internalProps.groupBy) null === (_b = (_a = table.dataSource).deleteRecordsForGroup) || void 0 === _b || _b.call(_a, recordIndexs), table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.sortState && sortRecords(table), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph();else if ("tree" === table.dataSource.rowHierarchyType) {
|
|
64834
64979
|
const deletedRecordIndexs = null === (_d = (_c = table.dataSource).deleteRecordsForTree) || void 0 === _d ? void 0 : _d.call(_c, recordIndexs);
|
|
64835
64980
|
if (0 === deletedRecordIndexs.length) return;
|
|
@@ -64841,8 +64986,17 @@
|
|
|
64841
64986
|
const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
|
|
64842
64987
|
deletedRecordIndexs = table.dataSource.deleteRecords(recordIndexs, syncToOriginalRecords);
|
|
64843
64988
|
if (0 === deletedRecordIndexs.length) return;
|
|
64989
|
+
Array.isArray(table.options.customMergeCell) && (table.internalProps.customMergeCell = getCustomMergeCellFunc$1(table.options.customMergeCell));
|
|
64844
64990
|
for (let index = 0; index < deletedRecordIndexs.length; index++) adjustCheckBoxStateMapWithDeleteRecordIndex(table, deletedRecordIndexs[index], 1);
|
|
64845
|
-
if (syncToOriginalRecords)
|
|
64991
|
+
if (syncToOriginalRecords) {
|
|
64992
|
+
if (!table.transpose) {
|
|
64993
|
+
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64994
|
+
topAggregationCount = table.internalProps.layoutMap.hasAggregationOnTopCount,
|
|
64995
|
+
sorted = [...deletedRecordIndexs].sort((a, b) => b - a);
|
|
64996
|
+
for (let i = 0; i < sorted.length; i++) table.rowHeightsMap.delete(sorted[i] + headerCount + topAggregationCount);
|
|
64997
|
+
}
|
|
64998
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph(!0);
|
|
64999
|
+
}
|
|
64846
65000
|
const oldRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
64847
65001
|
table.refreshRowColCount();
|
|
64848
65002
|
const newRowCount = table.transpose ? table.colCount : table.rowCount,
|
|
@@ -64880,7 +65034,7 @@
|
|
|
64880
65034
|
col: 0,
|
|
64881
65035
|
row: row
|
|
64882
65036
|
});
|
|
64883
|
-
null === (_g = table.reactCustomLayout) || void 0 === _g || _g.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_h = table.reactCustomLayout) || void 0 === _h || _h.updateAllCustomCell();
|
|
65037
|
+
null === (_g = table.reactCustomLayout) || void 0 === _g || _g.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_h = table.reactCustomLayout) || void 0 === _h || _h.updateAllCustomCell(), refreshCustomMergeCellGroups(table);
|
|
64884
65038
|
}
|
|
64885
65039
|
} else {
|
|
64886
65040
|
const delRows = [],
|
|
@@ -64898,6 +65052,42 @@
|
|
|
64898
65052
|
});
|
|
64899
65053
|
}
|
|
64900
65054
|
const updateRows = [];
|
|
65055
|
+
if (table.internalProps.customMergeCell) {
|
|
65056
|
+
const proxy = table.scenegraph.proxy,
|
|
65057
|
+
deletedIndexNums = (recordIndexsMinToMax[0], recordIndexsMinToMax.map(recordIndex => recordIndex + headerCount + topAggregationCount)),
|
|
65058
|
+
minIndexNum = deletedIndexNums[0];
|
|
65059
|
+
let updateMin = minIndexNum,
|
|
65060
|
+
updateMax = minIndexNum;
|
|
65061
|
+
if (Array.isArray(table.options.customMergeCell)) {
|
|
65062
|
+
const merges = table.options.customMergeCell,
|
|
65063
|
+
axis = table.transpose ? "col" : "row";
|
|
65064
|
+
merges.forEach(m => {
|
|
65065
|
+
const r = null == m ? void 0 : m.range;
|
|
65066
|
+
if ((null == r ? void 0 : r.start) && (null == r ? void 0 : r.end)) for (let i = 0; i < deletedIndexNums.length; i++) {
|
|
65067
|
+
const deleteIndex = deletedIndexNums[i];
|
|
65068
|
+
if (r.end[axis] >= deleteIndex - 1) {
|
|
65069
|
+
updateMin = Math.min(updateMin, r.start[axis]), updateMax = Math.max(updateMax, r.end[axis]);
|
|
65070
|
+
break;
|
|
65071
|
+
}
|
|
65072
|
+
}
|
|
65073
|
+
});
|
|
65074
|
+
}
|
|
65075
|
+
if (table.transpose) {
|
|
65076
|
+
const start = Math.max(updateMin, null !== (_j = null == proxy ? void 0 : proxy.colStart) && void 0 !== _j ? _j : updateMin),
|
|
65077
|
+
end = Math.min(updateMax, null !== (_k = null == proxy ? void 0 : proxy.colEnd) && void 0 !== _k ? _k : updateMax);
|
|
65078
|
+
for (let col = start; col <= end; col++) updateRows.push({
|
|
65079
|
+
col: col,
|
|
65080
|
+
row: 0
|
|
65081
|
+
});
|
|
65082
|
+
} else {
|
|
65083
|
+
const start = Math.max(updateMin, null !== (_l = null == proxy ? void 0 : proxy.rowStart) && void 0 !== _l ? _l : updateMin),
|
|
65084
|
+
end = Math.min(updateMax, null !== (_m = null == proxy ? void 0 : proxy.rowEnd) && void 0 !== _m ? _m : updateMax);
|
|
65085
|
+
for (let row = start; row <= end; row++) updateRows.push({
|
|
65086
|
+
col: 0,
|
|
65087
|
+
row: row
|
|
65088
|
+
});
|
|
65089
|
+
}
|
|
65090
|
+
}
|
|
64901
65091
|
for (let row = headerCount; row < headerCount + topAggregationCount; row++) table.transpose ? updateRows.push({
|
|
64902
65092
|
col: row,
|
|
64903
65093
|
row: 0
|
|
@@ -64912,7 +65102,7 @@
|
|
|
64912
65102
|
col: 0,
|
|
64913
65103
|
row: row
|
|
64914
65104
|
});
|
|
64915
|
-
null === (
|
|
65105
|
+
null === (_o = table.reactCustomLayout) || void 0 === _o || _o.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_p = table.reactCustomLayout) || void 0 === _p || _p.updateAllCustomCell(), refreshCustomMergeCellGroups(table);
|
|
64916
65106
|
}
|
|
64917
65107
|
}
|
|
64918
65108
|
}
|
|
@@ -64924,7 +65114,7 @@
|
|
|
64924
65114
|
const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
|
|
64925
65115
|
updateRecordIndexs = table.dataSource.updateRecords(records, recordIndexs, syncToOriginalRecords);
|
|
64926
65116
|
if (0 === updateRecordIndexs.length) return;
|
|
64927
|
-
if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph();
|
|
65117
|
+
if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph(!0);
|
|
64928
65118
|
const recordIndexsMinToMax = updateRecordIndexs.map(index => table.getBodyRowIndexByRecordIndex(index)).sort((a, b) => a - b);
|
|
64929
65119
|
if (table.pagination) {
|
|
64930
65120
|
const {
|
|
@@ -65247,10 +65437,33 @@
|
|
|
65247
65437
|
this._hasAutoImageColumn = void 0, this.refreshHeader(), this.records && checkHasAggregationOnColumnDefine(this.internalProps.columns) && this.dataSource.processRecords(null !== (_b = null === (_a = this.dataSource.dataSourceObj) || void 0 === _a ? void 0 : _a.records) && void 0 !== _b ? _b : this.dataSource.dataSourceObj), this.internalProps.useOneRowHeightFillAll = !1, this.headerStyleCache = new Map(), this.bodyStyleCache = new Map(), this.bodyBottomStyleCache = new Map(), this._updateSize(), this.scenegraph.createSceneGraph(), this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row), this.renderAsync(), this.eventManager.updateEventBinder();
|
|
65248
65438
|
}
|
|
65249
65439
|
addColumns(toAddColumns, colIndex, isMaintainArrayData = !0) {
|
|
65250
|
-
var _a;
|
|
65440
|
+
var _a, _b;
|
|
65251
65441
|
const columns = this.options.columns;
|
|
65442
|
+
if (Array.isArray(this.options.customMergeCell) && (null == toAddColumns ? void 0 : toAddColumns.length)) {
|
|
65443
|
+
const axis = this.transpose ? "row" : "col";
|
|
65444
|
+
let insertIndex = colIndex;
|
|
65445
|
+
void 0 === insertIndex ? insertIndex = columns.length : insertIndex < 0 ? insertIndex = 0 : insertIndex > columns.length && (insertIndex = columns.length);
|
|
65446
|
+
const toAddCount = toAddColumns.length,
|
|
65447
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
65448
|
+
range: {
|
|
65449
|
+
start: Object.assign({}, m.range.start),
|
|
65450
|
+
end: Object.assign({}, m.range.end)
|
|
65451
|
+
}
|
|
65452
|
+
}));
|
|
65453
|
+
for (let i = 0; i < merges.length; i++) {
|
|
65454
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
65455
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
65456
|
+
const start = r.start[axis],
|
|
65457
|
+
end = r.end[axis];
|
|
65458
|
+
end < insertIndex || (start > insertIndex ? (r.start[axis] = start + toAddCount, r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
|
|
65459
|
+
}
|
|
65460
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
65461
|
+
const r = null == m ? void 0 : m.range;
|
|
65462
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
65463
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
65464
|
+
}
|
|
65252
65465
|
void 0 === colIndex ? (colIndex = columns.length, columns.push(...toAddColumns)) : columns.splice(colIndex, 0, ...toAddColumns);
|
|
65253
|
-
for (let i = 0; i < toAddColumns.length; i++) this.colWidthsMap.addAndReorder(colIndex + i, null !== (
|
|
65466
|
+
for (let i = 0; i < toAddColumns.length; i++) this.colWidthsMap.addAndReorder(colIndex + i, null !== (_b = toAddColumns[i].width) && void 0 !== _b ? _b : this.internalProps.defaultColWidth);
|
|
65254
65467
|
this.internalProps._colRangeWidthsMap.clear();
|
|
65255
65468
|
const resizedColIndexs = Array.from(this.internalProps._widthResizedColMap.keys());
|
|
65256
65469
|
for (let i = 0; i < resizedColIndexs.length; i++) resizedColIndexs[i] >= colIndex && (this.internalProps._widthResizedColMap.delete(resizedColIndexs[i]), this.internalProps._widthResizedColMap.add(resizedColIndexs[i] + toAddColumns.length));
|
|
@@ -65263,15 +65476,46 @@
|
|
|
65263
65476
|
}
|
|
65264
65477
|
this.updateColumns(columns, {
|
|
65265
65478
|
clearRowHeightCache: !1
|
|
65266
|
-
}), this.
|
|
65479
|
+
}), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
65480
|
+
const r = null == m ? void 0 : m.range;
|
|
65481
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
65482
|
+
}), this.scenegraph.updateNextFrame()), this.fireListeners(TABLE_EVENT_TYPE.ADD_COLUMN, {
|
|
65267
65483
|
columnIndex: colIndex,
|
|
65268
65484
|
columnCount: toAddColumns.length,
|
|
65269
65485
|
columns: columns
|
|
65270
65486
|
});
|
|
65271
65487
|
}
|
|
65272
65488
|
deleteColumns(deleteColIndexs, isMaintainArrayData = !0) {
|
|
65489
|
+
var _a;
|
|
65273
65490
|
const columns = this.options.columns;
|
|
65274
65491
|
deleteColIndexs.sort((a, b) => b - a);
|
|
65492
|
+
const deletedColumns = deleteColIndexs.map(idx => cloneDeepSpec(columns[idx], ["children"]));
|
|
65493
|
+
let deletedRecordValues;
|
|
65494
|
+
if (Array.isArray(this.options.customMergeCell) && (null == deleteColIndexs ? void 0 : deleteColIndexs.length)) {
|
|
65495
|
+
const axis = this.transpose ? "row" : "col",
|
|
65496
|
+
deleteIndexNums = deleteColIndexs.slice().sort((a, b) => a - b).map((idx, i) => idx - i),
|
|
65497
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
65498
|
+
range: {
|
|
65499
|
+
start: Object.assign({}, m.range.start),
|
|
65500
|
+
end: Object.assign({}, m.range.end)
|
|
65501
|
+
}
|
|
65502
|
+
}));
|
|
65503
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
65504
|
+
const deleteIndex = deleteIndexNums[i];
|
|
65505
|
+
for (let j = 0; j < merges.length; j++) {
|
|
65506
|
+
const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
|
|
65507
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
65508
|
+
const start = r.start[axis],
|
|
65509
|
+
end = r.end[axis];
|
|
65510
|
+
end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
|
|
65511
|
+
}
|
|
65512
|
+
}
|
|
65513
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
65514
|
+
const r = null == m ? void 0 : m.range;
|
|
65515
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
65516
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
65517
|
+
}
|
|
65518
|
+
isMaintainArrayData && Array.isArray(this.records) && this.records.length && (deletedRecordValues = this.records.map(record => Array.isArray(record) ? deleteColIndexs.map(idx => record[idx]) : []), deletedRecordValues.every(v => 0 === v.length) && (deletedRecordValues = void 0));
|
|
65275
65519
|
for (let i = 0; i < deleteColIndexs.length; i++) if (columns.splice(deleteColIndexs[i], 1), this.colWidthsMap.delAndReorder(deleteColIndexs[i]), this.internalProps._widthResizedColMap.delete(deleteColIndexs[i]), isMaintainArrayData) for (let j = 0; j < this.records.length; j++) {
|
|
65276
65520
|
const record = this.records[j];
|
|
65277
65521
|
Array.isArray(record) && record.splice(deleteColIndexs[i], 1);
|
|
@@ -65287,7 +65531,9 @@
|
|
|
65287
65531
|
clearRowHeightCache: !1
|
|
65288
65532
|
}), this.fireListeners(TABLE_EVENT_TYPE.DELETE_COLUMN, {
|
|
65289
65533
|
deleteColIndexs: deleteColIndexs,
|
|
65290
|
-
columns: columns
|
|
65534
|
+
columns: columns,
|
|
65535
|
+
deletedColumns: deletedColumns,
|
|
65536
|
+
deletedRecordValues: deletedRecordValues
|
|
65291
65537
|
});
|
|
65292
65538
|
}
|
|
65293
65539
|
get columns() {
|
|
@@ -65675,9 +65921,9 @@
|
|
|
65675
65921
|
}
|
|
65676
65922
|
}
|
|
65677
65923
|
updateSortState(sortState, executeSort = !0) {
|
|
65678
|
-
var _a;
|
|
65679
|
-
|
|
65680
|
-
(
|
|
65924
|
+
var _a, _b, _c, _d, _e;
|
|
65925
|
+
const normalizedSortState = (Array.isArray(sortState) ? sortState : sortState ? [sortState] : []).filter(Boolean);
|
|
65926
|
+
if (normalizedSortState.length ? this.internalProps.sortState = sortState : this.internalProps.sortState = null, executeSort) if (normalizedSortState.length) this.internalProps.layoutMap.headerObjects.some(item => !1 !== item.define.sort) && (this.dataSource.sort(normalizedSortState.map(item => {
|
|
65681
65927
|
const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, item.field);
|
|
65682
65928
|
this.internalProps.layoutMap.headerObjects.find(col => col && col.field === item.field);
|
|
65683
65929
|
return {
|
|
@@ -65685,13 +65931,20 @@
|
|
|
65685
65931
|
order: item.order,
|
|
65686
65932
|
orderFn: null != sortFunc ? sortFunc : defaultOrderFn
|
|
65687
65933
|
};
|
|
65688
|
-
})), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell())
|
|
65934
|
+
})), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell());else {
|
|
65935
|
+
const ds = this.dataSource,
|
|
65936
|
+
sourceLength = null !== (_c = null !== (_b = null !== (_a = null == ds ? void 0 : ds.sourceLength) && void 0 !== _a ? _a : null == ds ? void 0 : ds._sourceLength) && void 0 !== _b ? _b : null == ds ? void 0 : ds.length) && void 0 !== _c ? _c : 0;
|
|
65937
|
+
(null === (_d = null == ds ? void 0 : ds.sortedIndexMap) || void 0 === _d ? void 0 : _d.clear) && ds.sortedIndexMap.clear(), void 0 !== ds.currentIndexedData && (ds.currentIndexedData = Array.from({
|
|
65938
|
+
length: sourceLength
|
|
65939
|
+
}, (_, i) => i)), ds.lastSortStates = [], null === (_e = ds.updatePagination) || void 0 === _e || _e.call(ds, ds.pagination), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell();
|
|
65940
|
+
}
|
|
65941
|
+
this.stateManager.updateSortState(normalizedSortState);
|
|
65689
65942
|
}
|
|
65690
65943
|
updateFilterRules(filterRules, options = {
|
|
65691
65944
|
clearRowHeightCache: !0
|
|
65692
65945
|
}) {
|
|
65693
65946
|
var _a, _b, _c;
|
|
65694
|
-
this.scenegraph.clearCells(), null === (_b = (_a = this.dataSource).clearForceVisibleRecords) || void 0 === _b || _b.call(_a), this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules), sortRecords(this)) : this.dataSource.updateFilterRules(filterRules, null == options ? void 0 : options.onFilterRecordsEnd), this.refreshRowColCount(), this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!(null == options ? void 0 : options.clearRowHeightCache)), null === (_c = this.internalProps.emptyTip) || void 0 === _c || _c.resetVisible(), this.resize();
|
|
65947
|
+
this.scenegraph.clearCells(), !1 !== (null == options ? void 0 : options.clearForceVisibleRecords) && (null === (_b = (_a = this.dataSource).clearForceVisibleRecords) || void 0 === _b || _b.call(_a)), this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules), sortRecords(this)) : this.dataSource.updateFilterRules(filterRules, null == options ? void 0 : options.onFilterRecordsEnd), this.refreshRowColCount(), this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!(null == options ? void 0 : options.clearRowHeightCache)), null === (_c = this.internalProps.emptyTip) || void 0 === _c || _c.resetVisible(), this.resize();
|
|
65695
65948
|
}
|
|
65696
65949
|
getFilteredRecords() {
|
|
65697
65950
|
return this.dataSource.records;
|
|
@@ -65966,30 +66219,112 @@
|
|
|
65966
66219
|
traverseColumns(this.internalProps.columns), this.refreshRowColCount(), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!clearRowHeightCache), null === (_k = this.internalProps.emptyTip) || void 0 === _k || _k.resetVisible(), this.resize();
|
|
65967
66220
|
}
|
|
65968
66221
|
addRecord(record, recordIndex, triggerEvent = !0) {
|
|
65969
|
-
var _a;
|
|
66222
|
+
var _a, _b;
|
|
66223
|
+
if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex) {
|
|
66224
|
+
const axis = this.transpose ? "col" : "row",
|
|
66225
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66226
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
66227
|
+
let insertIndex = recordIndex;
|
|
66228
|
+
void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
|
|
66229
|
+
const insertIndexNum = insertIndex + headerCount + topAggregationCount,
|
|
66230
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
66231
|
+
range: {
|
|
66232
|
+
start: Object.assign({}, m.range.start),
|
|
66233
|
+
end: Object.assign({}, m.range.end)
|
|
66234
|
+
}
|
|
66235
|
+
}));
|
|
66236
|
+
for (let i = 0; i < merges.length; i++) {
|
|
66237
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
66238
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66239
|
+
const start = r.start[axis],
|
|
66240
|
+
end = r.end[axis];
|
|
66241
|
+
end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + 1, r.end[axis] = end + 1) : r.end[axis] = end + 1);
|
|
66242
|
+
}
|
|
66243
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66244
|
+
const r = null == m ? void 0 : m.range;
|
|
66245
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
66246
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66247
|
+
}
|
|
65970
66248
|
const success = listTableAddRecord(record, recordIndex, this);
|
|
65971
|
-
adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (
|
|
66249
|
+
adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible(), success && Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
66250
|
+
const r = null == m ? void 0 : m.range;
|
|
66251
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
66252
|
+
}), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
|
|
65972
66253
|
records: [record],
|
|
65973
66254
|
recordIndex: recordIndex,
|
|
65974
66255
|
recordCount: 1
|
|
65975
66256
|
});
|
|
65976
66257
|
}
|
|
65977
66258
|
addRecords(records, recordIndex, triggerEvent = !0) {
|
|
65978
|
-
var _a;
|
|
66259
|
+
var _a, _b;
|
|
66260
|
+
if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex && (null == records ? void 0 : records.length)) {
|
|
66261
|
+
const axis = this.transpose ? "col" : "row",
|
|
66262
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66263
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
66264
|
+
let insertIndex = recordIndex;
|
|
66265
|
+
void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
|
|
66266
|
+
const insertIndexNum = insertIndex + headerCount + topAggregationCount,
|
|
66267
|
+
toAddCount = records.length,
|
|
66268
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
66269
|
+
range: {
|
|
66270
|
+
start: Object.assign({}, m.range.start),
|
|
66271
|
+
end: Object.assign({}, m.range.end)
|
|
66272
|
+
}
|
|
66273
|
+
}));
|
|
66274
|
+
for (let i = 0; i < merges.length; i++) {
|
|
66275
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
66276
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66277
|
+
const start = r.start[axis],
|
|
66278
|
+
end = r.end[axis];
|
|
66279
|
+
end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + toAddCount, r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
|
|
66280
|
+
}
|
|
66281
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66282
|
+
const r = null == m ? void 0 : m.range;
|
|
66283
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
66284
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66285
|
+
}
|
|
65979
66286
|
const success = listTableAddRecords(records, recordIndex, this);
|
|
65980
|
-
"number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (
|
|
66287
|
+
"number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible(), success && Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
66288
|
+
const r = null == m ? void 0 : m.range;
|
|
66289
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
66290
|
+
}), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
|
|
65981
66291
|
records: records,
|
|
65982
66292
|
recordIndex: recordIndex,
|
|
65983
66293
|
recordCount: records.length
|
|
65984
66294
|
});
|
|
65985
66295
|
}
|
|
65986
66296
|
deleteRecords(recordIndexs, triggerEvent = !0) {
|
|
65987
|
-
var _a;
|
|
65988
|
-
const
|
|
65989
|
-
|
|
66297
|
+
var _a, _b;
|
|
66298
|
+
const prevMergeRanges = Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map(m => null == m ? void 0 : m.range).filter(Boolean).map(r => ({
|
|
66299
|
+
start: Object.assign({}, r.start),
|
|
66300
|
+
end: Object.assign({}, r.end)
|
|
66301
|
+
})) : [],
|
|
66302
|
+
deletedRecords = [];
|
|
66303
|
+
if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0 && recordIndexs.forEach(index => {
|
|
65990
66304
|
let record = null;
|
|
65991
66305
|
record = "number" == typeof index ? this.dataSource.get(index) : [], deletedRecords.push(record);
|
|
65992
|
-
}),
|
|
66306
|
+
}), Array.isArray(this.options.customMergeCell) && (null == recordIndexs ? void 0 : recordIndexs.length) && "number" == typeof recordIndexs[0]) {
|
|
66307
|
+
const axis = this.transpose ? "col" : "row",
|
|
66308
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66309
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount,
|
|
66310
|
+
deleteIndexNums = recordIndexs.slice().sort((a, b) => a - b).map((index, i) => index + headerCount + topAggregationCount - i),
|
|
66311
|
+
merges = this.options.customMergeCell;
|
|
66312
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
66313
|
+
const deleteIndex = deleteIndexNums[i];
|
|
66314
|
+
for (let j = 0; j < merges.length; j++) {
|
|
66315
|
+
const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
|
|
66316
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66317
|
+
const start = r.start[axis],
|
|
66318
|
+
end = r.end[axis];
|
|
66319
|
+
end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
|
|
66320
|
+
}
|
|
66321
|
+
}
|
|
66322
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66323
|
+
const r = null == m ? void 0 : m.range;
|
|
66324
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
66325
|
+
});
|
|
66326
|
+
}
|
|
66327
|
+
listTableDeleteRecords(recordIndexs, this), adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible();
|
|
65993
66328
|
const rowIndexs = [];
|
|
65994
66329
|
for (let i = 0; i < recordIndexs.length; i++) rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
|
|
65995
66330
|
triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
|
|
@@ -65997,7 +66332,16 @@
|
|
|
65997
66332
|
records: deletedRecords,
|
|
65998
66333
|
rowIndexs: rowIndexs,
|
|
65999
66334
|
deletedCount: (Array.isArray(recordIndexs[0]), recordIndexs.length)
|
|
66000
|
-
})
|
|
66335
|
+
}), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
66336
|
+
const r = null == m ? void 0 : m.range;
|
|
66337
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
66338
|
+
}), this.scenegraph.updateNextFrame(), setTimeout(() => {
|
|
66339
|
+
if (!this.internalProps || !this.options || !this.scenegraph) return;
|
|
66340
|
+
Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell));
|
|
66341
|
+
[...prevMergeRanges, ...(Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map(m => null == m ? void 0 : m.range) : [])].filter(Boolean).forEach(r => {
|
|
66342
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
66343
|
+
}), this.scenegraph.updateNextFrame();
|
|
66344
|
+
}, 0));
|
|
66001
66345
|
}
|
|
66002
66346
|
updateRecords(records, recordIndexs, triggerEvent = !0) {
|
|
66003
66347
|
listTableUpdateRecords(records, recordIndexs, this), triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
|
|
@@ -66099,9 +66443,14 @@
|
|
|
66099
66443
|
row: endRow
|
|
66100
66444
|
}
|
|
66101
66445
|
}
|
|
66102
|
-
}), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
|
|
66446
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66103
66447
|
for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
|
|
66104
|
-
this.scenegraph.updateNextFrame()
|
|
66448
|
+
this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE.MERGE_CELLS, {
|
|
66449
|
+
startCol: startCol,
|
|
66450
|
+
startRow: startRow,
|
|
66451
|
+
endCol: endCol,
|
|
66452
|
+
endRow: endRow
|
|
66453
|
+
});
|
|
66105
66454
|
}
|
|
66106
66455
|
unmergeCells(startCol, startRow, endCol, endRow) {
|
|
66107
66456
|
this.options.customMergeCell ? "function" == typeof this.options.customMergeCell && (this.options.customMergeCell = []) : this.options.customMergeCell = [], this.options.customMergeCell = this.options.customMergeCell.filter(item => {
|
|
@@ -66110,9 +66459,14 @@
|
|
|
66110
66459
|
end: end
|
|
66111
66460
|
} = item.range;
|
|
66112
66461
|
return !(start.col === startCol && start.row === startRow && end.col === endCol && end.row === endRow);
|
|
66113
|
-
}), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
|
|
66462
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66114
66463
|
for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
|
|
66115
|
-
this.scenegraph.updateNextFrame()
|
|
66464
|
+
this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE.UNMERGE_CELLS, {
|
|
66465
|
+
startCol: startCol,
|
|
66466
|
+
startRow: startRow,
|
|
66467
|
+
endCol: endCol,
|
|
66468
|
+
endRow: endRow
|
|
66469
|
+
});
|
|
66116
66470
|
}
|
|
66117
66471
|
}
|
|
66118
66472
|
|
|
@@ -66913,7 +67267,7 @@
|
|
|
66913
67267
|
class DiscreteTableLegend {
|
|
66914
67268
|
constructor(option, table) {
|
|
66915
67269
|
var _a, _b, _c, _d;
|
|
66916
|
-
this.table = table, this.option = cloneDeep$
|
|
67270
|
+
this.table = table, this.option = cloneDeep$2(option), this.orient = null !== (_a = option.orient) && void 0 !== _a ? _a : "left", this.visible = null === (_b = option.visible) || void 0 === _b || _b, this.position = null !== (_c = option.position) && void 0 !== _c ? _c : "middle", this.selectedData = null !== (_d = option.defaultSelected) && void 0 !== _d ? _d : null, this.createComponent(), this.initEvent();
|
|
66917
67271
|
}
|
|
66918
67272
|
createComponent() {
|
|
66919
67273
|
const attrs = this.getLegendAttributes({
|
|
@@ -67162,7 +67516,7 @@
|
|
|
67162
67516
|
class ContinueTableLegend {
|
|
67163
67517
|
constructor(option, table) {
|
|
67164
67518
|
var _a, _b, _c, _d;
|
|
67165
|
-
this.table = table, this.option = cloneDeep$
|
|
67519
|
+
this.table = table, this.option = cloneDeep$2(option), this.orient = null !== (_a = option.orient) && void 0 !== _a ? _a : "left", this.visible = null === (_b = option.visible) || void 0 === _b || _b, this.position = null !== (_c = option.position) && void 0 !== _c ? _c : "middle", this.selectedData = null !== (_d = option.defaultSelected) && void 0 !== _d ? _d : null, this.createComponent(), this.initEvent();
|
|
67166
67520
|
}
|
|
67167
67521
|
createComponent() {
|
|
67168
67522
|
const attrs = this.getLegendAttributes({
|
|
@@ -72131,7 +72485,10 @@
|
|
|
72131
72485
|
}
|
|
72132
72486
|
}), table.updateFilterRules([...this.filterFuncRule, ...this.filterValueRule], {
|
|
72133
72487
|
clearRowHeightCache: !1,
|
|
72134
|
-
onFilterRecordsEnd: null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.onFilterRecordsEnd
|
|
72488
|
+
onFilterRecordsEnd: (null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.onFilterRecordsEnd) ? records => {
|
|
72489
|
+
var _a, _b;
|
|
72490
|
+
return null === (_b = (_a = this.pluginOptions).onFilterRecordsEnd) || void 0 === _b || _b.call(_a, records), records;
|
|
72491
|
+
} : void 0
|
|
72135
72492
|
});
|
|
72136
72493
|
}
|
|
72137
72494
|
createFilterFunction(filter) {
|
|
@@ -72223,6 +72580,79 @@
|
|
|
72223
72580
|
getAllFilterStates() {
|
|
72224
72581
|
return this.state;
|
|
72225
72582
|
}
|
|
72583
|
+
getSnapshot() {
|
|
72584
|
+
const filters = [];
|
|
72585
|
+
return this.state.filters.forEach(v => {
|
|
72586
|
+
const next = Object.assign({}, v);
|
|
72587
|
+
next && "byValue" === next.type && Array.isArray(next.values) && (next.values = next.values.slice().sort((a, b) => String(a).localeCompare(String(b)))), next && Array.isArray(next.condition) && next.condition.length > 2 && (next.condition = next.condition.slice()), filters.push(next);
|
|
72588
|
+
}), filters.sort((a, b) => String(a.field).localeCompare(String(b.field))), {
|
|
72589
|
+
filters: filters
|
|
72590
|
+
};
|
|
72591
|
+
}
|
|
72592
|
+
applySnapshot(snapshot, actionType = FilterActionType.APPLY_FILTERS) {
|
|
72593
|
+
var _a;
|
|
72594
|
+
const next = new Map();
|
|
72595
|
+
(null !== (_a = null == snapshot ? void 0 : snapshot.filters) && void 0 !== _a ? _a : []).forEach(cfg => {
|
|
72596
|
+
if (!cfg) return;
|
|
72597
|
+
const cloned = Object.assign({}, cfg);
|
|
72598
|
+
cloned && "byValue" === cloned.type && Array.isArray(cloned.values) && (cloned.values = cloned.values.slice()), cloned && Array.isArray(cloned.condition) && (cloned.condition = cloned.condition.slice()), next.set(cloned.field, cloned);
|
|
72599
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72600
|
+
filters: next
|
|
72601
|
+
}), this.applyFilters(), this.notifyListeners({
|
|
72602
|
+
type: actionType,
|
|
72603
|
+
payload: {
|
|
72604
|
+
fromSnapshot: !0
|
|
72605
|
+
}
|
|
72606
|
+
});
|
|
72607
|
+
}
|
|
72608
|
+
shiftFieldsOnAddColumns(columnIndex, columnCount) {
|
|
72609
|
+
if (!Number.isFinite(columnIndex) || !Number.isFinite(columnCount) || columnCount <= 0) return;
|
|
72610
|
+
const next = new Map();
|
|
72611
|
+
this.state.filters.forEach((cfg, key) => {
|
|
72612
|
+
let newKey = key;
|
|
72613
|
+
const cloned = Object.assign({}, cfg);
|
|
72614
|
+
"number" == typeof newKey && newKey >= columnIndex && (newKey += columnCount), "number" == typeof cloned.field && cloned.field >= columnIndex && (cloned.field = cloned.field + columnCount), cloned && "byValue" === cloned.type && Array.isArray(cloned.values) && (cloned.values = cloned.values.slice()), cloned && Array.isArray(cloned.condition) && (cloned.condition = cloned.condition.slice()), next.set(newKey, cloned);
|
|
72615
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72616
|
+
filters: next
|
|
72617
|
+
});
|
|
72618
|
+
}
|
|
72619
|
+
shiftFieldsOnDeleteColumns(deleteColIndexs) {
|
|
72620
|
+
if (!Array.isArray(deleteColIndexs) || 0 === deleteColIndexs.length) return;
|
|
72621
|
+
const deleteIndexNums = deleteColIndexs.slice().filter(n => Number.isFinite(n)).sort((a, b) => a - b).map((idx, i) => idx - i),
|
|
72622
|
+
next = new Map();
|
|
72623
|
+
this.state.filters.forEach((cfg, key) => {
|
|
72624
|
+
let newKey = key;
|
|
72625
|
+
const cloned = Object.assign({}, cfg);
|
|
72626
|
+
let removed = !1;
|
|
72627
|
+
if ("number" == typeof newKey) {
|
|
72628
|
+
let k = newKey;
|
|
72629
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
72630
|
+
const d = deleteIndexNums[i];
|
|
72631
|
+
if (k === d) {
|
|
72632
|
+
removed = !0;
|
|
72633
|
+
break;
|
|
72634
|
+
}
|
|
72635
|
+
k > d && (k -= 1);
|
|
72636
|
+
}
|
|
72637
|
+
newKey = k;
|
|
72638
|
+
}
|
|
72639
|
+
if ("number" == typeof cloned.field) {
|
|
72640
|
+
let f = cloned.field;
|
|
72641
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
72642
|
+
const d = deleteIndexNums[i];
|
|
72643
|
+
if (f === d) {
|
|
72644
|
+
removed = !0;
|
|
72645
|
+
break;
|
|
72646
|
+
}
|
|
72647
|
+
f > d && (f -= 1);
|
|
72648
|
+
}
|
|
72649
|
+
cloned.field = f;
|
|
72650
|
+
}
|
|
72651
|
+
removed || (cloned && "byValue" === cloned.type && Array.isArray(cloned.values) && (cloned.values = cloned.values.slice()), cloned && Array.isArray(cloned.condition) && (cloned.condition = cloned.condition.slice()), next.set(newKey, cloned));
|
|
72652
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72653
|
+
filters: next
|
|
72654
|
+
});
|
|
72655
|
+
}
|
|
72226
72656
|
reapplyCurrentFilters() {
|
|
72227
72657
|
this.getActiveFilterFields().length > 0 && this.applyFilters();
|
|
72228
72658
|
}
|
|
@@ -72499,7 +72929,7 @@
|
|
|
72499
72929
|
}), this.candidateKeys.set(candidateField, countMap), this.toUnformattedCache.set(candidateField, toUnformatted);
|
|
72500
72930
|
}
|
|
72501
72931
|
toggleSelectAll(fieldId, selected) {
|
|
72502
|
-
this.valueFilterOptionList.get(fieldId).forEach(option => {
|
|
72932
|
+
(this.valueFilterOptionList.get(fieldId) || []).forEach(option => {
|
|
72503
72933
|
"none" !== option.itemContainer.style.display && (option.checkbox.checked = selected);
|
|
72504
72934
|
});
|
|
72505
72935
|
}
|
|
@@ -72510,7 +72940,7 @@
|
|
|
72510
72940
|
this.selectAllCheckbox.checked = allChecked, this.selectAllCheckbox.indeterminate = !allChecked && !noneChecked;
|
|
72511
72941
|
}
|
|
72512
72942
|
onSearch(fieldId, value) {
|
|
72513
|
-
const items = this.valueFilterOptionList.get(fieldId),
|
|
72943
|
+
const items = this.valueFilterOptionList.get(fieldId) || [],
|
|
72514
72944
|
filterKeywords = value.toUpperCase().split(" ").filter(s => s);
|
|
72515
72945
|
for (const item of items) {
|
|
72516
72946
|
const txtValue = item.id.toUpperCase() || "",
|
|
@@ -72520,48 +72950,19 @@
|
|
|
72520
72950
|
}
|
|
72521
72951
|
}
|
|
72522
72952
|
syncSingleStateFromTableData(fieldId) {
|
|
72523
|
-
|
|
72524
|
-
const selectedValues = new Set(),
|
|
72525
|
-
originalValues = new Set();
|
|
72953
|
+
const originalValues = new Set();
|
|
72526
72954
|
this.table.internalProps.records.forEach(record => {
|
|
72527
72955
|
isValid$2(record) && originalValues.add(record[fieldId]);
|
|
72528
72956
|
});
|
|
72529
|
-
const
|
|
72530
|
-
|
|
72531
|
-
|
|
72532
|
-
|
|
72533
|
-
this.
|
|
72534
|
-
|
|
72535
|
-
|
|
72536
|
-
field: fieldId,
|
|
72537
|
-
values: Array.from(selectedValues),
|
|
72538
|
-
enable: !0
|
|
72539
|
-
}
|
|
72540
|
-
});
|
|
72541
|
-
!arrayEqual(Array.from(originalValues), Array.from(selectedValues)) && (this.selectedKeys.set(fieldId, selectedValues), this.filterStateManager.dispatch({
|
|
72542
|
-
type: FilterActionType.ADD_FILTER,
|
|
72543
|
-
payload: {
|
|
72544
|
-
field: fieldId,
|
|
72545
|
-
type: "byValue",
|
|
72546
|
-
values: Array.from(selectedValues),
|
|
72547
|
-
enable: !0
|
|
72548
|
-
}
|
|
72549
|
-
}));
|
|
72957
|
+
const current = this.filterStateManager.getFilterState(fieldId);
|
|
72958
|
+
if ("byValue" === (null == current ? void 0 : current.type) && Array.isArray(current.values)) this.selectedKeys.set(fieldId, new Set(current.values));else {
|
|
72959
|
+
if ("byCondition" === (null == current ? void 0 : current.type) && current.enable) {
|
|
72960
|
+
const visibleValues = new Set();
|
|
72961
|
+
return this.getRecords(this.table, !1).forEach(record => {
|
|
72962
|
+
isValid$2(record) && visibleValues.add(record[fieldId]);
|
|
72963
|
+
}), void this.selectedKeys.set(fieldId, visibleValues);
|
|
72550
72964
|
}
|
|
72551
|
-
|
|
72552
|
-
const selectedRules = null === (_c = this.filterStateManager.getFilterState(fieldId)) || void 0 === _c ? void 0 : _c.values;
|
|
72553
|
-
if (selectedRules) {
|
|
72554
|
-
!arrayEqual(Array.from(originalValues), selectedRules) && (this.selectedKeys.set(fieldId, new Set(selectedRules)), this.filterStateManager.dispatch({
|
|
72555
|
-
type: FilterActionType.ADD_FILTER,
|
|
72556
|
-
payload: {
|
|
72557
|
-
field: fieldId,
|
|
72558
|
-
type: "byValue",
|
|
72559
|
-
values: selectedRules,
|
|
72560
|
-
enable: !0,
|
|
72561
|
-
shouldKeepUnrelatedState: !0
|
|
72562
|
-
}
|
|
72563
|
-
}));
|
|
72564
|
-
} else this.selectedKeys.set(fieldId, originalValues);
|
|
72965
|
+
this.selectedKeys.set(fieldId, originalValues);
|
|
72565
72966
|
}
|
|
72566
72967
|
}
|
|
72567
72968
|
applyFilter(fieldId = this.selectedField) {
|
|
@@ -72914,12 +73315,13 @@
|
|
|
72914
73315
|
|
|
72915
73316
|
class FilterToolbar {
|
|
72916
73317
|
constructor(table, filterStateManager, pluginOptions) {
|
|
73318
|
+
var _a;
|
|
72917
73319
|
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue", this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.hide = (currentCol, currentRow) => {
|
|
72918
73320
|
this.filterMenu.style.display = "none", this.isVisible = !1, this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {
|
|
72919
73321
|
col: null != currentCol ? currentCol : this.currentCol,
|
|
72920
73322
|
row: null != currentRow ? currentRow : this.currentRow
|
|
72921
73323
|
});
|
|
72922
|
-
}, this.table = table, this.filterStateManager = filterStateManager, this.valueFilter = new ValueFilter(this.table, this.filterStateManager, pluginOptions), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, pluginOptions, this.hide), this.pluginOptions = pluginOptions, this.filterMenuWidth = 300, this.filterStateManager.subscribe(state => {
|
|
73324
|
+
}, this.table = table, this.filterStateManager = filterStateManager, this.valueFilter = new ValueFilter(this.table, this.filterStateManager, pluginOptions), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, pluginOptions, this.hide), this.pluginOptions = pluginOptions, this.pluginId = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : "filter", this.filterMenuWidth = 300, this.filterStateManager.subscribe(state => {
|
|
72923
73325
|
this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
|
|
72924
73326
|
});
|
|
72925
73327
|
}
|
|
@@ -72937,6 +73339,18 @@
|
|
|
72937
73339
|
clearFilter(field) {
|
|
72938
73340
|
this.valueFilter && this.valueFilter.clearFilter(field), this.conditionFilter && this.conditionFilter.clearFilter(field), this.hide();
|
|
72939
73341
|
}
|
|
73342
|
+
recordHistory(before, after) {
|
|
73343
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
73344
|
+
if (JSON.stringify(before) === JSON.stringify(after)) return;
|
|
73345
|
+
const pm = this.table.pluginManager,
|
|
73346
|
+
history = null !== (_f = null !== (_d = null !== (_b = null === (_a = null == pm ? void 0 : pm.getPlugin) || void 0 === _a ? void 0 : _a.call(pm, "history-plugin")) && void 0 !== _b ? _b : null === (_c = null == pm ? void 0 : pm.getPluginByName) || void 0 === _c ? void 0 : _c.call(pm, "History")) && void 0 !== _d ? _d : null === (_e = null == pm ? void 0 : pm.getPlugin) || void 0 === _e ? void 0 : _e.call(pm, "history")) && void 0 !== _f ? _f : null === (_g = null == pm ? void 0 : pm.getPluginByName) || void 0 === _g ? void 0 : _g.call(pm, "history");
|
|
73347
|
+
null === (_h = null == history ? void 0 : history.recordExternalCommand) || void 0 === _h || _h.call(history, {
|
|
73348
|
+
type: "filter",
|
|
73349
|
+
pluginId: this.pluginId,
|
|
73350
|
+
oldSnapshot: before,
|
|
73351
|
+
newSnapshot: after
|
|
73352
|
+
});
|
|
73353
|
+
}
|
|
72940
73354
|
updateClearFilterButtonState(field) {
|
|
72941
73355
|
const currentFilter = this.filterStateManager.getFilterState(field),
|
|
72942
73356
|
hasActiveFilter = currentFilter && currentFilter.enable;
|
|
@@ -72963,9 +73377,16 @@
|
|
|
72963
73377
|
}), this.filterTabByCondition.addEventListener("click", () => {
|
|
72964
73378
|
this.onTabSwitch("byCondition");
|
|
72965
73379
|
}), this.cancelFilterButton.addEventListener("click", () => this.hide()), this.clearFilterOptionLink.addEventListener("click", e => {
|
|
72966
|
-
e.preventDefault()
|
|
73380
|
+
e.preventDefault();
|
|
73381
|
+
const before = this.filterStateManager.getSnapshot();
|
|
73382
|
+
this.clearFilter(this.selectedField);
|
|
73383
|
+
const after = this.filterStateManager.getSnapshot();
|
|
73384
|
+
this.recordHistory(before, after);
|
|
72967
73385
|
}), this.applyFilterButton.addEventListener("click", () => {
|
|
73386
|
+
const before = this.filterStateManager.getSnapshot();
|
|
72968
73387
|
this.applyFilter(this.selectedField);
|
|
73388
|
+
const after = this.filterStateManager.getSnapshot();
|
|
73389
|
+
this.recordHistory(before, after);
|
|
72969
73390
|
}), document.addEventListener("click", () => {
|
|
72970
73391
|
this.isVisible && this.hide();
|
|
72971
73392
|
}), this.filterMenu.addEventListener("click", e => {
|
|
@@ -72990,7 +73411,7 @@
|
|
|
72990
73411
|
const field = this.table.internalProps.layoutMap.getHeaderField(col, row);
|
|
72991
73412
|
this.updateSelectedField(field);
|
|
72992
73413
|
const currentFilter = this.filterStateManager.getFilterState(field);
|
|
72993
|
-
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"), this.updateClearFilterButtonState(field), setTimeout(() => {
|
|
73414
|
+
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.filterModes.includes("byValue") && this.onTabSwitch("byValue"), this.updateClearFilterButtonState(field), setTimeout(() => {
|
|
72994
73415
|
this.isVisible = !0, this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_SHOW, {
|
|
72995
73416
|
col: col,
|
|
72996
73417
|
row: row
|
|
@@ -82471,7 +82892,7 @@
|
|
|
82471
82892
|
class FilterPlugin {
|
|
82472
82893
|
constructor(pluginOptions) {
|
|
82473
82894
|
var _a, _b, _c, _d, _e;
|
|
82474
|
-
this.id = "filter", this.name = "Filter", this.runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, TABLE_EVENT_TYPE.ICON_CLICK, TABLE_EVENT_TYPE.SCROLL, TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, TABLE_EVENT_TYPE.UPDATE_RECORD, TABLE_EVENT_TYPE.ADD_RECORD, TABLE_EVENT_TYPE.DELETE_RECORD], this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = lodashExports.cloneDeep(pluginOptions), this.pluginOptions.filterIcon = null !== (_b = pluginOptions.filterIcon) && void 0 !== _b ? _b : {
|
|
82895
|
+
this.id = "filter", this.name = "Filter", this.runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, TABLE_EVENT_TYPE.ICON_CLICK, TABLE_EVENT_TYPE.SCROLL, TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, TABLE_EVENT_TYPE.UPDATE_RECORD, TABLE_EVENT_TYPE.ADD_RECORD, TABLE_EVENT_TYPE.DELETE_RECORD, TABLE_EVENT_TYPE.ADD_COLUMN, TABLE_EVENT_TYPE.DELETE_COLUMN], this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = lodashExports.cloneDeep(pluginOptions), this.pluginOptions.filterIcon = null !== (_b = pluginOptions.filterIcon) && void 0 !== _b ? _b : {
|
|
82475
82896
|
name: "filter-icon",
|
|
82476
82897
|
type: "svg",
|
|
82477
82898
|
width: 12,
|
|
@@ -82497,7 +82918,7 @@
|
|
|
82497
82918
|
});
|
|
82498
82919
|
}
|
|
82499
82920
|
run(...args) {
|
|
82500
|
-
var _a, _b, _c, _d, _e;
|
|
82921
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
82501
82922
|
const eventArgs = args[0],
|
|
82502
82923
|
runtime = args[1],
|
|
82503
82924
|
table = args[2];
|
|
@@ -82505,20 +82926,43 @@
|
|
|
82505
82926
|
if (3 === (null === (_c = eventArgs.event) || void 0 === _c ? void 0 : _c.which) || 2 === (null === (_d = eventArgs.event) || void 0 === _d ? void 0 : _d.button) || 2 == (2 & (null === (_e = eventArgs.event) || void 0 === _e ? void 0 : _e.buttons))) return;
|
|
82506
82927
|
const col = eventArgs.col,
|
|
82507
82928
|
row = eventArgs.row;
|
|
82508
|
-
this.filterToolbar.isVisible ? this.filterToolbar.hide(eventArgs.col, eventArgs.row) :
|
|
82509
|
-
col: eventArgs.col,
|
|
82510
|
-
row: eventArgs.row
|
|
82511
|
-
}));
|
|
82929
|
+
this.filterToolbar.isVisible ? this.filterToolbar.hide(eventArgs.col, eventArgs.row) : this.filterToolbar.show(col, row, this.pluginOptions.filterModes);
|
|
82512
82930
|
} else if (runtime === TABLE_EVENT_TYPE.SCROLL) "horizontal" === eventArgs.scrollDirection && this.filterToolbar.adjustMenuPosition();else if (runtime === TABLE_EVENT_TYPE.CHANGE_CELL_VALUE) {
|
|
82513
82931
|
const changedField = this.table.getHeaderField(eventArgs.col, eventArgs.row);
|
|
82514
82932
|
this.syncFilterWithTableData(changedField);
|
|
82515
|
-
} else (runtime === TABLE_EVENT_TYPE.UPDATE_RECORD
|
|
82933
|
+
} else if (runtime === TABLE_EVENT_TYPE.UPDATE_RECORD) this.syncFilterWithTableData();else if (runtime === TABLE_EVENT_TYPE.ADD_RECORD) {
|
|
82934
|
+
if ((null === (_g = null === (_f = this.filterStateManager) || void 0 === _f ? void 0 : _f.getActiveFilterFields) || void 0 === _g ? void 0 : _g.call(_f).length) > 0 && Array.isArray(null == eventArgs ? void 0 : eventArgs.records)) {
|
|
82935
|
+
const ds = this.table.dataSource;
|
|
82936
|
+
eventArgs.records.forEach(r => {
|
|
82937
|
+
var _a;
|
|
82938
|
+
return null === (_a = null == ds ? void 0 : ds.markForceVisibleRecord) || void 0 === _a ? void 0 : _a.call(ds, r);
|
|
82939
|
+
});
|
|
82940
|
+
}
|
|
82941
|
+
this.syncFilterWithTableData();
|
|
82942
|
+
} else if (runtime === TABLE_EVENT_TYPE.DELETE_RECORD) this.syncFilterWithTableData();else if (runtime === TABLE_EVENT_TYPE.ADD_COLUMN) {
|
|
82943
|
+
const columnIndex = null == eventArgs ? void 0 : eventArgs.columnIndex,
|
|
82944
|
+
columnCount = null == eventArgs ? void 0 : eventArgs.columnCount;
|
|
82945
|
+
"number" == typeof columnIndex && "number" == typeof columnCount && columnCount > 0 && (null === (_j = null === (_h = this.filterStateManager) || void 0 === _h ? void 0 : _h.shiftFieldsOnAddColumns) || void 0 === _j || _j.call(_h, columnIndex, columnCount)), this.reapplyActiveFilters();
|
|
82946
|
+
} else if (runtime === TABLE_EVENT_TYPE.DELETE_COLUMN) {
|
|
82947
|
+
const deleteColIndexs = null == eventArgs ? void 0 : eventArgs.deleteColIndexs;
|
|
82948
|
+
Array.isArray(deleteColIndexs) && deleteColIndexs.length > 0 && (null === (_l = null === (_k = this.filterStateManager) || void 0 === _k ? void 0 : _k.shiftFieldsOnDeleteColumns) || void 0 === _l || _l.call(_k, deleteColIndexs)), this.reapplyActiveFilters();
|
|
82949
|
+
}
|
|
82516
82950
|
}
|
|
82517
82951
|
updatePluginOptions(pluginOptions) {
|
|
82518
82952
|
this.pluginOptions = lodashExports.merge(this.pluginOptions, pluginOptions), this.filterToolbar.updateStyles(this.pluginOptions.styles), this.table.updateColumns(this.columns, {
|
|
82519
82953
|
clearRowHeightCache: !1
|
|
82520
82954
|
});
|
|
82521
82955
|
}
|
|
82956
|
+
getFilterSnapshot() {
|
|
82957
|
+
var _a, _b, _c;
|
|
82958
|
+
return null !== (_c = null === (_b = null === (_a = this.filterStateManager) || void 0 === _a ? void 0 : _a.getSnapshot) || void 0 === _b ? void 0 : _b.call(_a)) && void 0 !== _c ? _c : {
|
|
82959
|
+
filters: []
|
|
82960
|
+
};
|
|
82961
|
+
}
|
|
82962
|
+
applyFilterSnapshot(snapshot) {
|
|
82963
|
+
var _a, _b;
|
|
82964
|
+
null === (_b = null === (_a = this.filterStateManager) || void 0 === _a ? void 0 : _a.applySnapshot) || void 0 === _b || _b.call(_a, snapshot, FilterActionType.APPLY_FILTERS);
|
|
82965
|
+
}
|
|
82522
82966
|
update() {
|
|
82523
82967
|
this.filterStateManager && this.reapplyActiveFilters();
|
|
82524
82968
|
}
|
|
@@ -83630,10 +84074,10 @@
|
|
|
83630
84074
|
* console.log(deep[0] === objects[0]);
|
|
83631
84075
|
* // => false
|
|
83632
84076
|
*/
|
|
83633
|
-
function cloneDeep(value) {
|
|
84077
|
+
function cloneDeep$1(value) {
|
|
83634
84078
|
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
|
|
83635
84079
|
}
|
|
83636
|
-
var cloneDeep_1 = cloneDeep;
|
|
84080
|
+
var cloneDeep_1 = cloneDeep$1;
|
|
83637
84081
|
var deepClone = /*@__PURE__*/getDefaultExportFromCjs(cloneDeep_1);
|
|
83638
84082
|
|
|
83639
84083
|
const chnNumChar = {
|
|
@@ -84764,6 +85208,1200 @@
|
|
|
84764
85208
|
}
|
|
84765
85209
|
}
|
|
84766
85210
|
|
|
85211
|
+
function makeCellKey(sheetKey, row, col) {
|
|
85212
|
+
return `${sheetKey}:${row}:${col}`;
|
|
85213
|
+
}
|
|
85214
|
+
function parseA1Notation(a1) {
|
|
85215
|
+
const match = a1.match(/^([A-Z]+)([0-9]+)$/i);
|
|
85216
|
+
if (!match) return null;
|
|
85217
|
+
const letters = match[1].toUpperCase(),
|
|
85218
|
+
rowNumber = parseInt(match[2], 10);
|
|
85219
|
+
if (!rowNumber || rowNumber < 1) return null;
|
|
85220
|
+
let col = 0;
|
|
85221
|
+
for (let i = 0; i < letters.length; i++) col = 26 * col + (letters.charCodeAt(i) - 64);
|
|
85222
|
+
return {
|
|
85223
|
+
row: rowNumber - 1,
|
|
85224
|
+
col: col - 1
|
|
85225
|
+
};
|
|
85226
|
+
}
|
|
85227
|
+
function captureCellPreChangeContent(args) {
|
|
85228
|
+
const {
|
|
85229
|
+
sheetKey: sheetKey,
|
|
85230
|
+
row: row,
|
|
85231
|
+
col: col,
|
|
85232
|
+
currentValue: currentValue,
|
|
85233
|
+
formulaManager: formulaManager,
|
|
85234
|
+
store: store
|
|
85235
|
+
} = args;
|
|
85236
|
+
if (!sheetKey) return;
|
|
85237
|
+
const cellKey = makeCellKey(sheetKey, row, col);
|
|
85238
|
+
if (null == formulaManager ? void 0 : formulaManager.getCellFormula) try {
|
|
85239
|
+
const oldFormula = formulaManager.getCellFormula({
|
|
85240
|
+
sheet: sheetKey,
|
|
85241
|
+
row: row,
|
|
85242
|
+
col: col
|
|
85243
|
+
});
|
|
85244
|
+
if (oldFormula) {
|
|
85245
|
+
const normalized = "string" != typeof oldFormula || oldFormula.startsWith("=") ? oldFormula : `=${oldFormula}`;
|
|
85246
|
+
return void store.set(cellKey, normalized);
|
|
85247
|
+
}
|
|
85248
|
+
} catch (_a) {}
|
|
85249
|
+
store.set(cellKey, null == currentValue ? "" : currentValue);
|
|
85250
|
+
}
|
|
85251
|
+
function popCellPreChangeContent(args) {
|
|
85252
|
+
const {
|
|
85253
|
+
sheetKey: sheetKey,
|
|
85254
|
+
row: row,
|
|
85255
|
+
col: col,
|
|
85256
|
+
fallbackOldContent: fallbackOldContent,
|
|
85257
|
+
store: store
|
|
85258
|
+
} = args;
|
|
85259
|
+
if (!sheetKey) return fallbackOldContent;
|
|
85260
|
+
const cellKey = makeCellKey(sheetKey, row, col),
|
|
85261
|
+
oldContent = store.get(cellKey);
|
|
85262
|
+
return store.delete(cellKey), void 0 !== oldContent ? oldContent : fallbackOldContent;
|
|
85263
|
+
}
|
|
85264
|
+
function applyCellContent(args) {
|
|
85265
|
+
const {
|
|
85266
|
+
table: table,
|
|
85267
|
+
sheetKey: sheetKey,
|
|
85268
|
+
row: row,
|
|
85269
|
+
col: col,
|
|
85270
|
+
content: content,
|
|
85271
|
+
formulaManager: formulaManager
|
|
85272
|
+
} = args;
|
|
85273
|
+
if (sheetKey && (null == formulaManager ? void 0 : formulaManager.setCellContent) && (null == formulaManager ? void 0 : formulaManager.getCellValue)) {
|
|
85274
|
+
try {
|
|
85275
|
+
formulaManager.setCellContent({
|
|
85276
|
+
sheet: sheetKey,
|
|
85277
|
+
row: row,
|
|
85278
|
+
col: col
|
|
85279
|
+
}, content);
|
|
85280
|
+
} catch (_a) {
|
|
85281
|
+
return void table.changeCellValue(col, row, content, !1, !1, !0);
|
|
85282
|
+
}
|
|
85283
|
+
if ("string" == typeof content && content.startsWith("=")) {
|
|
85284
|
+
const result = formulaManager.getCellValue({
|
|
85285
|
+
sheet: sheetKey,
|
|
85286
|
+
row: row,
|
|
85287
|
+
col: col
|
|
85288
|
+
}),
|
|
85289
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
85290
|
+
return table.changeCellValue(col, row, display, !1, !1, !0), void refreshDependentDisplays({
|
|
85291
|
+
table: table,
|
|
85292
|
+
sheetKey: sheetKey,
|
|
85293
|
+
startCell: {
|
|
85294
|
+
sheet: sheetKey,
|
|
85295
|
+
row: row,
|
|
85296
|
+
col: col
|
|
85297
|
+
},
|
|
85298
|
+
formulaManager: formulaManager
|
|
85299
|
+
});
|
|
85300
|
+
}
|
|
85301
|
+
return table.changeCellValue(col, row, content, !1, !1, !0), void refreshDependentDisplays({
|
|
85302
|
+
table: table,
|
|
85303
|
+
sheetKey: sheetKey,
|
|
85304
|
+
startCell: {
|
|
85305
|
+
sheet: sheetKey,
|
|
85306
|
+
row: row,
|
|
85307
|
+
col: col
|
|
85308
|
+
},
|
|
85309
|
+
formulaManager: formulaManager
|
|
85310
|
+
});
|
|
85311
|
+
}
|
|
85312
|
+
table.changeCellValue(col, row, content, !1, !1, !0);
|
|
85313
|
+
}
|
|
85314
|
+
function refreshDependentDisplays(args) {
|
|
85315
|
+
var _a;
|
|
85316
|
+
const {
|
|
85317
|
+
table: table,
|
|
85318
|
+
sheetKey: sheetKey,
|
|
85319
|
+
startCell: startCell,
|
|
85320
|
+
formulaManager: formulaManager
|
|
85321
|
+
} = args,
|
|
85322
|
+
maxCells = null !== (_a = args.maxCells) && void 0 !== _a ? _a : 5e3;
|
|
85323
|
+
if (!(null == formulaManager ? void 0 : formulaManager.getCellDependents) || !(null == formulaManager ? void 0 : formulaManager.getCellValue)) return;
|
|
85324
|
+
const visited = new Set(),
|
|
85325
|
+
queue = [...(formulaManager.getCellDependents(startCell) || [])];
|
|
85326
|
+
let processed = 0;
|
|
85327
|
+
for (; queue.length;) {
|
|
85328
|
+
const cell = queue.shift();
|
|
85329
|
+
if (!cell || cell.sheet !== sheetKey) continue;
|
|
85330
|
+
const key = makeCellKey(cell.sheet, cell.row, cell.col);
|
|
85331
|
+
if (visited.has(key)) continue;
|
|
85332
|
+
if (visited.add(key), processed++, processed > maxCells) break;
|
|
85333
|
+
const result = formulaManager.getCellValue(cell),
|
|
85334
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
85335
|
+
table.changeCellValue(cell.col, cell.row, display, !1, !1, !0);
|
|
85336
|
+
(formulaManager.getCellDependents(cell) || []).forEach(d => queue.push(d));
|
|
85337
|
+
}
|
|
85338
|
+
}
|
|
85339
|
+
|
|
85340
|
+
function cloneMergeConfig(input) {
|
|
85341
|
+
return Array.isArray(input) ? input.map(i => Object.assign(Object.assign({}, i), {
|
|
85342
|
+
range: (null == i ? void 0 : i.range) ? {
|
|
85343
|
+
start: Object.assign({}, i.range.start),
|
|
85344
|
+
end: Object.assign({}, i.range.end)
|
|
85345
|
+
} : null == i ? void 0 : i.range
|
|
85346
|
+
})) : input;
|
|
85347
|
+
}
|
|
85348
|
+
function getCustomMergeCellFunc(customMergeCell) {
|
|
85349
|
+
return "function" == typeof customMergeCell ? customMergeCell : Array.isArray(customMergeCell) ? (col, row) => customMergeCell.find(item => item.range.start.col <= col && item.range.end.col >= col && item.range.start.row <= row && item.range.end.row >= row) : void 0;
|
|
85350
|
+
}
|
|
85351
|
+
function applyMergeConfig(table, customMergeCell) {
|
|
85352
|
+
(null == table ? void 0 : table.options) && (null == table ? void 0 : table.internalProps) && (table.options.customMergeCell = cloneMergeConfig(customMergeCell), table.internalProps.customMergeCell = getCustomMergeCellFunc(table.options.customMergeCell));
|
|
85353
|
+
}
|
|
85354
|
+
function cloneSortState(input) {
|
|
85355
|
+
return input ? Array.isArray(input) ? input.filter(Boolean).map(s => ({
|
|
85356
|
+
field: s.field,
|
|
85357
|
+
order: s.order
|
|
85358
|
+
})) : {
|
|
85359
|
+
field: input.field,
|
|
85360
|
+
order: input.order
|
|
85361
|
+
} : null;
|
|
85362
|
+
}
|
|
85363
|
+
function replayCommand(args) {
|
|
85364
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
|
|
85365
|
+
const {
|
|
85366
|
+
table: table,
|
|
85367
|
+
vtableSheet: vtableSheet,
|
|
85368
|
+
cmd: cmd,
|
|
85369
|
+
direction: direction,
|
|
85370
|
+
deleteRecordsByReference: deleteRecordsByReference
|
|
85371
|
+
} = args;
|
|
85372
|
+
switch (cmd.type) {
|
|
85373
|
+
case "cell":
|
|
85374
|
+
case "cells":
|
|
85375
|
+
{
|
|
85376
|
+
const sheetKey = cmd.sheetKey;
|
|
85377
|
+
cmd.cells.forEach(c => {
|
|
85378
|
+
const content = "undo" === direction ? c.oldContent : c.newContent;
|
|
85379
|
+
applyCellContent({
|
|
85380
|
+
table: table,
|
|
85381
|
+
sheetKey: sheetKey,
|
|
85382
|
+
row: c.row,
|
|
85383
|
+
col: c.col,
|
|
85384
|
+
content: content,
|
|
85385
|
+
formulaManager: null == vtableSheet ? void 0 : vtableSheet.formulaManager
|
|
85386
|
+
});
|
|
85387
|
+
});
|
|
85388
|
+
break;
|
|
85389
|
+
}
|
|
85390
|
+
case "merge_cells":
|
|
85391
|
+
{
|
|
85392
|
+
const c = cmd,
|
|
85393
|
+
next = "undo" === direction ? c.oldCustomMergeCell : c.newCustomMergeCell;
|
|
85394
|
+
applyMergeConfig(table, next);
|
|
85395
|
+
const sg = table.scenegraph;
|
|
85396
|
+
if (null == sg ? void 0 : sg.updateCellContent) {
|
|
85397
|
+
for (let i = c.startCol; i <= c.endCol; i++) for (let j = c.startRow; j <= c.endRow; j++) sg.updateCellContent(i, j);
|
|
85398
|
+
null === (_a = sg.updateNextFrame) || void 0 === _a || _a.call(sg);
|
|
85399
|
+
} else "function" == typeof table.renderWithRecreateCells && table.renderWithRecreateCells();
|
|
85400
|
+
break;
|
|
85401
|
+
}
|
|
85402
|
+
case "filter":
|
|
85403
|
+
{
|
|
85404
|
+
const c = cmd,
|
|
85405
|
+
pluginId = c.pluginId,
|
|
85406
|
+
snapshot = "undo" === direction ? c.oldSnapshot : c.newSnapshot,
|
|
85407
|
+
pm = table.pluginManager,
|
|
85408
|
+
filterPlugin = null !== (_g = null !== (_e = null !== (_c = null === (_b = null == pm ? void 0 : pm.getPlugin) || void 0 === _b ? void 0 : _b.call(pm, pluginId)) && void 0 !== _c ? _c : null === (_d = null == pm ? void 0 : pm.getPluginByName) || void 0 === _d ? void 0 : _d.call(pm, "Filter")) && void 0 !== _e ? _e : null === (_f = null == pm ? void 0 : pm.getPlugin) || void 0 === _f ? void 0 : _f.call(pm, "filter")) && void 0 !== _g ? _g : null === (_h = null == pm ? void 0 : pm.getPluginByName) || void 0 === _h ? void 0 : _h.call(pm, "filter");
|
|
85409
|
+
(null == filterPlugin ? void 0 : filterPlugin.applyFilterSnapshot) && filterPlugin.applyFilterSnapshot(snapshot);
|
|
85410
|
+
break;
|
|
85411
|
+
}
|
|
85412
|
+
case "sort":
|
|
85413
|
+
{
|
|
85414
|
+
const c = cmd,
|
|
85415
|
+
next = "undo" === direction ? c.oldSortState : c.newSortState;
|
|
85416
|
+
null === (_k = (_j = table).updateSortState) || void 0 === _k || _k.call(_j, null !== (_l = cloneSortState(next)) && void 0 !== _l ? _l : null, !0);
|
|
85417
|
+
break;
|
|
85418
|
+
}
|
|
85419
|
+
case "add_record":
|
|
85420
|
+
{
|
|
85421
|
+
const c = cmd;
|
|
85422
|
+
if ("undo" === direction) {
|
|
85423
|
+
const ds = null === (_m = null == table ? void 0 : table.internalProps) || void 0 === _m ? void 0 : _m.dataSource,
|
|
85424
|
+
rawRecords = null === (_o = null == ds ? void 0 : ds.dataSourceObj) || void 0 === _o ? void 0 : _o.records;
|
|
85425
|
+
let deletedByRaw = !1;
|
|
85426
|
+
if (Array.isArray(rawRecords) && "number" == typeof c.rawInsertIndex && c.recordCount > 0) {
|
|
85427
|
+
const idx = c.rawInsertIndex;
|
|
85428
|
+
idx >= 0 && idx < rawRecords.length && (rawRecords.splice(idx, c.recordCount), deletedByRaw = !0);
|
|
85429
|
+
}
|
|
85430
|
+
if (Array.isArray(rawRecords) && Array.isArray(c.records) && c.records.length) for (let i = 0; i < c.records.length; i++) {
|
|
85431
|
+
const rawIndex = rawRecords.indexOf(c.records[i]);
|
|
85432
|
+
rawIndex >= 0 && (rawRecords.splice(rawIndex, 1), deletedByRaw = !0);
|
|
85433
|
+
}
|
|
85434
|
+
if (!deletedByRaw && Array.isArray(rawRecords) && "number" == typeof c.recordCount && c.recordCount > 0) {
|
|
85435
|
+
const before = c.anchorBefore,
|
|
85436
|
+
after = c.anchorAfter,
|
|
85437
|
+
beforeIndex = before ? rawRecords.indexOf(before) : -1,
|
|
85438
|
+
afterIndex = after ? rawRecords.indexOf(after) : -1;
|
|
85439
|
+
beforeIndex >= 0 ? (rawRecords.splice(beforeIndex + 1, c.recordCount), deletedByRaw = !0) : afterIndex >= 0 && (rawRecords.splice(Math.max(0, afterIndex - c.recordCount), c.recordCount), deletedByRaw = !0);
|
|
85440
|
+
}
|
|
85441
|
+
if (deletedByRaw && (null === (_q = null === (_p = null == ds ? void 0 : ds.beforeChangedRecordsMap) || void 0 === _p ? void 0 : _p.clear) || void 0 === _q || _q.call(_p), null === (_s = null === (_r = null == ds ? void 0 : ds.sortedIndexMap) || void 0 === _r ? void 0 : _r.clear) || void 0 === _s || _s.call(_r), "function" == typeof table.updateFilterRules ? table.updateFilterRules(null === (_t = null == ds ? void 0 : ds.dataConfig) || void 0 === _t ? void 0 : _t.filterRules, {
|
|
85442
|
+
clearRowHeightCache: !1
|
|
85443
|
+
}) : null === (_u = null == ds ? void 0 : ds.updateFilterRules) || void 0 === _u || _u.call(ds, null === (_v = null == ds ? void 0 : ds.dataConfig) || void 0 === _v ? void 0 : _v.filterRules)), !deletedByRaw) if ("number" == typeof c.recordIndex && c.recordCount > 0) {
|
|
85444
|
+
const indexs = [];
|
|
85445
|
+
for (let i = 0; i < c.recordCount; i++) indexs.push(c.recordIndex + i);
|
|
85446
|
+
null === (_x = (_w = table).deleteRecords) || void 0 === _x || _x.call(_w, indexs);
|
|
85447
|
+
} else deleteRecordsByReference(c.records);
|
|
85448
|
+
} else c.records.length && (null === (_z = (_y = table).addRecords) || void 0 === _z || _z.call(_y, c.records, c.recordIndex));
|
|
85449
|
+
break;
|
|
85450
|
+
}
|
|
85451
|
+
case "delete_record":
|
|
85452
|
+
{
|
|
85453
|
+
const c = cmd;
|
|
85454
|
+
if ("undo" === direction) {
|
|
85455
|
+
if (table.addRecord && Array.isArray(c.records) && Array.isArray(c.recordIndexs)) {
|
|
85456
|
+
const pairs = [];
|
|
85457
|
+
for (let i = 0; i < c.recordIndexs.length; i++) {
|
|
85458
|
+
const idx = c.recordIndexs[i];
|
|
85459
|
+
"number" == typeof idx && pairs.push({
|
|
85460
|
+
idx: idx,
|
|
85461
|
+
record: c.records[i]
|
|
85462
|
+
});
|
|
85463
|
+
}
|
|
85464
|
+
pairs.sort((a, b) => a.idx - b.idx);
|
|
85465
|
+
for (const p of pairs) table.addRecord(p.record, p.idx);
|
|
85466
|
+
}
|
|
85467
|
+
if (c.deletedRowHeights && "function" == typeof table.setRowHeight) {
|
|
85468
|
+
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
|
|
85469
|
+
Object.keys(c.deletedRowHeights).forEach(k => {
|
|
85470
|
+
const idx = Number(k),
|
|
85471
|
+
height = c.deletedRowHeights[k];
|
|
85472
|
+
Number.isFinite(idx) && "number" == typeof height && table.setRowHeight(idx + (null != headerCount ? headerCount : 0), height);
|
|
85473
|
+
});
|
|
85474
|
+
}
|
|
85475
|
+
} else table.deleteRecords && table.deleteRecords(c.recordIndexs);
|
|
85476
|
+
if ("oldCustomMergeCell" in c || "newCustomMergeCell" in c) {
|
|
85477
|
+
const target = "undo" === direction ? c.oldCustomMergeCell : c.newCustomMergeCell;
|
|
85478
|
+
applyMergeConfig(table, target);
|
|
85479
|
+
const sg = table.scenegraph;
|
|
85480
|
+
if (null == sg ? void 0 : sg.updateCellContent) {
|
|
85481
|
+
[...(Array.isArray(c.oldCustomMergeCell) ? c.oldCustomMergeCell.map(i => null == i ? void 0 : i.range).filter(Boolean) : []), ...(Array.isArray(c.newCustomMergeCell) ? c.newCustomMergeCell.map(i => null == i ? void 0 : i.range).filter(Boolean) : [])].forEach(r => {
|
|
85482
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) sg.updateCellContent(col, row);
|
|
85483
|
+
}), null === (_0 = sg.updateNextFrame) || void 0 === _0 || _0.call(sg);
|
|
85484
|
+
} else "function" == typeof table.renderWithRecreateCells && table.renderWithRecreateCells();
|
|
85485
|
+
}
|
|
85486
|
+
break;
|
|
85487
|
+
}
|
|
85488
|
+
case "update_record":
|
|
85489
|
+
{
|
|
85490
|
+
const c = cmd;
|
|
85491
|
+
table.updateRecords && ("undo" === direction ? table.updateRecords(c.oldRecords, c.recordIndexs) : table.updateRecords(c.newRecords, c.recordIndexs));
|
|
85492
|
+
break;
|
|
85493
|
+
}
|
|
85494
|
+
case "add_column":
|
|
85495
|
+
{
|
|
85496
|
+
const c = cmd;
|
|
85497
|
+
if ("undo" === direction) {
|
|
85498
|
+
const deleteIndexs = [];
|
|
85499
|
+
for (let i = 0; i < c.columnCount; i++) deleteIndexs.push(c.columnIndex + i);
|
|
85500
|
+
null === (_2 = (_1 = table).deleteColumns) || void 0 === _2 || _2.call(_1, deleteIndexs, !0);
|
|
85501
|
+
} else null === (_4 = (_3 = table).addColumns) || void 0 === _4 || _4.call(_3, c.columns, c.columnIndex, !0);
|
|
85502
|
+
break;
|
|
85503
|
+
}
|
|
85504
|
+
case "delete_column":
|
|
85505
|
+
{
|
|
85506
|
+
const c = cmd;
|
|
85507
|
+
if ("undo" === direction) {
|
|
85508
|
+
if (c.deleteColIndexs.map((idx, i) => ({
|
|
85509
|
+
idx: idx,
|
|
85510
|
+
column: c.columns[i]
|
|
85511
|
+
})).sort((a, b) => a.idx - b.idx).forEach(item => {
|
|
85512
|
+
var _a, _b;
|
|
85513
|
+
null === (_b = (_a = table).addColumns) || void 0 === _b || _b.call(_a, [item.column], item.idx, !0);
|
|
85514
|
+
}), c.deletedColWidths && "function" == typeof table.setColWidth && Object.entries(c.deletedColWidths).forEach(([k, width]) => {
|
|
85515
|
+
const idx = Number(k);
|
|
85516
|
+
Number.isFinite(idx) && "number" == typeof width && table.setColWidth(idx, width);
|
|
85517
|
+
}), Array.isArray(c.deletedRecordValues) && c.deletedRecordValues.length) {
|
|
85518
|
+
const records = table.records;
|
|
85519
|
+
if (Array.isArray(records) && records.length) {
|
|
85520
|
+
const recordIndexs = [],
|
|
85521
|
+
newRecords = [];
|
|
85522
|
+
for (let i = 0; i < records.length; i++) {
|
|
85523
|
+
const rec = records[i],
|
|
85524
|
+
rowValues = c.deletedRecordValues[i];
|
|
85525
|
+
if (!Array.isArray(rec) || !Array.isArray(rowValues) || rowValues.length !== c.deleteColIndexs.length) continue;
|
|
85526
|
+
const next = rec.slice();
|
|
85527
|
+
for (let k = 0; k < c.deleteColIndexs.length; k++) next[c.deleteColIndexs[k]] = rowValues[k];
|
|
85528
|
+
recordIndexs.push(i), newRecords.push(next);
|
|
85529
|
+
}
|
|
85530
|
+
recordIndexs.length && (null === (_6 = (_5 = table).updateRecords) || void 0 === _6 || _6.call(_5, newRecords, recordIndexs, !1));
|
|
85531
|
+
}
|
|
85532
|
+
}
|
|
85533
|
+
if (c.sheetKey) {
|
|
85534
|
+
const fm = null == vtableSheet ? void 0 : vtableSheet.formulaManager,
|
|
85535
|
+
engine = null == fm ? void 0 : fm.formulaEngine;
|
|
85536
|
+
if ((null == fm ? void 0 : fm.normalizeSheetData) && (null == engine ? void 0 : engine.updateSheetData)) try {
|
|
85537
|
+
const normalized = fm.normalizeSheetData(table.records || [], table);
|
|
85538
|
+
engine.updateSheetData(c.sheetKey, normalized);
|
|
85539
|
+
} catch (_17) {}
|
|
85540
|
+
}
|
|
85541
|
+
if (c.sheetKey && c.deletedFormulas) {
|
|
85542
|
+
Object.entries(c.deletedFormulas).forEach(([cellRef, formula]) => {
|
|
85543
|
+
const parsed = parseA1Notation(cellRef);
|
|
85544
|
+
parsed && applyCellContent({
|
|
85545
|
+
table: table,
|
|
85546
|
+
sheetKey: c.sheetKey,
|
|
85547
|
+
row: parsed.row,
|
|
85548
|
+
col: parsed.col,
|
|
85549
|
+
content: formula,
|
|
85550
|
+
formulaManager: null == vtableSheet ? void 0 : vtableSheet.formulaManager
|
|
85551
|
+
});
|
|
85552
|
+
});
|
|
85553
|
+
}
|
|
85554
|
+
} else null === (_8 = (_7 = table).deleteColumns) || void 0 === _8 || _8.call(_7, c.deleteColIndexs, !0);
|
|
85555
|
+
break;
|
|
85556
|
+
}
|
|
85557
|
+
case "change_header_position":
|
|
85558
|
+
{
|
|
85559
|
+
const c = cmd,
|
|
85560
|
+
moving = c.moving,
|
|
85561
|
+
from = "undo" === direction ? c.targetIndex : c.sourceIndex,
|
|
85562
|
+
to = "undo" === direction ? c.sourceIndex : c.targetIndex;
|
|
85563
|
+
"column" === moving ? null === (_10 = (_9 = table).changeHeaderPosition) || void 0 === _10 || _10.call(_9, {
|
|
85564
|
+
source: {
|
|
85565
|
+
col: from,
|
|
85566
|
+
row: 0
|
|
85567
|
+
},
|
|
85568
|
+
target: {
|
|
85569
|
+
col: to,
|
|
85570
|
+
row: 0
|
|
85571
|
+
},
|
|
85572
|
+
movingColumnOrRow: "column"
|
|
85573
|
+
}) : null === (_12 = (_11 = table).changeHeaderPosition) || void 0 === _12 || _12.call(_11, {
|
|
85574
|
+
source: {
|
|
85575
|
+
col: 0,
|
|
85576
|
+
row: from
|
|
85577
|
+
},
|
|
85578
|
+
target: {
|
|
85579
|
+
col: 0,
|
|
85580
|
+
row: to
|
|
85581
|
+
},
|
|
85582
|
+
movingColumnOrRow: "row"
|
|
85583
|
+
});
|
|
85584
|
+
break;
|
|
85585
|
+
}
|
|
85586
|
+
case "resize_row":
|
|
85587
|
+
{
|
|
85588
|
+
const c = cmd,
|
|
85589
|
+
height = "undo" === direction ? c.oldHeight : c.newHeight;
|
|
85590
|
+
null === (_14 = (_13 = table).setRowHeight) || void 0 === _14 || _14.call(_13, c.row, height);
|
|
85591
|
+
break;
|
|
85592
|
+
}
|
|
85593
|
+
case "resize_column":
|
|
85594
|
+
{
|
|
85595
|
+
const c = cmd,
|
|
85596
|
+
width = "undo" === direction ? c.oldWidth : c.newWidth;
|
|
85597
|
+
null === (_16 = (_15 = table).setColWidth) || void 0 === _16 || _16.call(_15, c.col, width);
|
|
85598
|
+
break;
|
|
85599
|
+
}
|
|
85600
|
+
}
|
|
85601
|
+
}
|
|
85602
|
+
|
|
85603
|
+
function cloneDeep(input, cache = new WeakMap()) {
|
|
85604
|
+
if (null == input) return input;
|
|
85605
|
+
const t = typeof input;
|
|
85606
|
+
if ("function" === t || "object" !== t) return input;
|
|
85607
|
+
const obj = input;
|
|
85608
|
+
if (obj instanceof Date) return new Date(obj.getTime());
|
|
85609
|
+
if (obj instanceof RegExp) return new RegExp(obj);
|
|
85610
|
+
if (cache.has(obj)) return cache.get(obj);
|
|
85611
|
+
if (Array.isArray(obj)) {
|
|
85612
|
+
const arr = [];
|
|
85613
|
+
cache.set(obj, arr);
|
|
85614
|
+
for (let i = 0; i < obj.length; i++) arr[i] = cloneDeep(obj[i], cache);
|
|
85615
|
+
return arr;
|
|
85616
|
+
}
|
|
85617
|
+
const out = {};
|
|
85618
|
+
return cache.set(obj, out), Object.keys(obj).forEach(key => {
|
|
85619
|
+
out[key] = cloneDeep(obj[key], cache);
|
|
85620
|
+
}), out;
|
|
85621
|
+
}
|
|
85622
|
+
function captureSnapshot(table, state, options) {
|
|
85623
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85624
|
+
const tableOptions = table.options || {},
|
|
85625
|
+
columns = tableOptions.columns;
|
|
85626
|
+
Array.isArray(columns) ? state.prevColumnsSnapshot = columns.map(c => cloneDeep(c)) : state.prevColumnsSnapshot = null;
|
|
85627
|
+
const merge = tableOptions.customMergeCell;
|
|
85628
|
+
Array.isArray(merge) ? state.prevMergeSnapshot = merge.map(m => Object.assign(Object.assign({}, m), {
|
|
85629
|
+
range: {
|
|
85630
|
+
start: Object.assign({}, m.range.start),
|
|
85631
|
+
end: Object.assign({}, m.range.end)
|
|
85632
|
+
}
|
|
85633
|
+
})) : state.prevMergeSnapshot = merge;
|
|
85634
|
+
const records = table.records || [];
|
|
85635
|
+
Array.isArray(records) ? state.prevRecordsSnapshot = records.map(r => cloneRecord(r)) : state.prevRecordsSnapshot = null;
|
|
85636
|
+
try {
|
|
85637
|
+
const resizedRowIndexs = Array.from(null !== (_d = null === (_c = null === (_b = null === (_a = table.internalProps) || void 0 === _a ? void 0 : _a._heightResizedRowMap) || void 0 === _b ? void 0 : _b.keys) || void 0 === _c ? void 0 : _c.call(_b)) && void 0 !== _d ? _d : []);
|
|
85638
|
+
if (resizedRowIndexs.length && "function" == typeof table.getRowHeight) {
|
|
85639
|
+
const map = {};
|
|
85640
|
+
resizedRowIndexs.forEach(rowIndex => {
|
|
85641
|
+
if ("number" != typeof rowIndex) return;
|
|
85642
|
+
const h = table.getRowHeight(rowIndex);
|
|
85643
|
+
"number" == typeof h && (map[rowIndex] = h);
|
|
85644
|
+
}), state.prevResizedRowHeightsSnapshot = map;
|
|
85645
|
+
} else state.prevResizedRowHeightsSnapshot = null;
|
|
85646
|
+
} catch (_k) {
|
|
85647
|
+
state.prevResizedRowHeightsSnapshot = null;
|
|
85648
|
+
}
|
|
85649
|
+
try {
|
|
85650
|
+
const resizedColIndexs = Array.from(null !== (_h = null === (_g = null === (_f = null === (_e = table.internalProps) || void 0 === _e ? void 0 : _e._widthResizedColMap) || void 0 === _f ? void 0 : _f.keys) || void 0 === _g ? void 0 : _g.call(_f)) && void 0 !== _h ? _h : []);
|
|
85651
|
+
if (resizedColIndexs.length && "function" == typeof table.getColWidth) {
|
|
85652
|
+
const map = {};
|
|
85653
|
+
resizedColIndexs.forEach(colIndex => {
|
|
85654
|
+
if ("number" != typeof colIndex) return;
|
|
85655
|
+
const w = table.getColWidth(colIndex);
|
|
85656
|
+
"number" == typeof w && (map[colIndex] = w);
|
|
85657
|
+
}), state.prevResizedColWidthsSnapshot = map;
|
|
85658
|
+
} else state.prevResizedColWidthsSnapshot = null;
|
|
85659
|
+
} catch (_l) {
|
|
85660
|
+
state.prevResizedColWidthsSnapshot = null;
|
|
85661
|
+
}
|
|
85662
|
+
if ((null === (_j = null == options ? void 0 : options.formulaManager) || void 0 === _j ? void 0 : _j.exportFormulas) && options.sheetKey) try {
|
|
85663
|
+
const formulas = options.formulaManager.exportFormulas(options.sheetKey);
|
|
85664
|
+
state.prevFormulasSnapshot = formulas ? Object.assign({}, formulas) : null;
|
|
85665
|
+
} catch (_m) {
|
|
85666
|
+
state.prevFormulasSnapshot = null;
|
|
85667
|
+
} else state.prevFormulasSnapshot = null;
|
|
85668
|
+
}
|
|
85669
|
+
function cloneRecord(record) {
|
|
85670
|
+
return Array.isArray(record) ? record.slice() : record && "object" == typeof record ? Object.assign({}, record) : record;
|
|
85671
|
+
}
|
|
85672
|
+
|
|
85673
|
+
function resolveSheetKey(args) {
|
|
85674
|
+
var _a, _b, _c;
|
|
85675
|
+
const {
|
|
85676
|
+
vtableSheet: vtableSheet,
|
|
85677
|
+
table: table,
|
|
85678
|
+
cached: cached
|
|
85679
|
+
} = args;
|
|
85680
|
+
if (!vtableSheet) return {
|
|
85681
|
+
sheetKey: void 0,
|
|
85682
|
+
cached: void 0
|
|
85683
|
+
};
|
|
85684
|
+
if (cached) return {
|
|
85685
|
+
sheetKey: cached,
|
|
85686
|
+
cached: cached
|
|
85687
|
+
};
|
|
85688
|
+
try {
|
|
85689
|
+
const workSheetInstances = vtableSheet.workSheetInstances;
|
|
85690
|
+
if (workSheetInstances && table) for (const [sheetKey, worksheet] of workSheetInstances.entries()) if ((null == worksheet ? void 0 : worksheet.tableInstance) === table) return {
|
|
85691
|
+
sheetKey: sheetKey,
|
|
85692
|
+
cached: sheetKey
|
|
85693
|
+
};
|
|
85694
|
+
const active = null === (_a = vtableSheet.getActiveSheet) || void 0 === _a ? void 0 : _a.call(vtableSheet);
|
|
85695
|
+
if (null == active ? void 0 : active.getKey) {
|
|
85696
|
+
const key = active.getKey();
|
|
85697
|
+
return {
|
|
85698
|
+
sheetKey: key,
|
|
85699
|
+
cached: key
|
|
85700
|
+
};
|
|
85701
|
+
}
|
|
85702
|
+
const activeDefine = null === (_c = null === (_b = vtableSheet.sheetManager) || void 0 === _b ? void 0 : _b.getActiveSheet) || void 0 === _c ? void 0 : _c.call(_b),
|
|
85703
|
+
key = null == activeDefine ? void 0 : activeDefine.sheetKey;
|
|
85704
|
+
return {
|
|
85705
|
+
sheetKey: key,
|
|
85706
|
+
cached: key
|
|
85707
|
+
};
|
|
85708
|
+
} catch (_d) {
|
|
85709
|
+
return {
|
|
85710
|
+
sheetKey: void 0,
|
|
85711
|
+
cached: void 0
|
|
85712
|
+
};
|
|
85713
|
+
}
|
|
85714
|
+
}
|
|
85715
|
+
|
|
85716
|
+
class HistoryPlugin {
|
|
85717
|
+
constructor(options) {
|
|
85718
|
+
var _a, _b, _c;
|
|
85719
|
+
this.id = "history-plugin", this.name = "History", this.runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.INITIALIZED, TABLE_EVENT_TYPE.BEFORE_KEYDOWN, TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, TABLE_EVENT_TYPE.PASTED_DATA, TABLE_EVENT_TYPE.MERGE_CELLS, TABLE_EVENT_TYPE.UNMERGE_CELLS, TABLE_EVENT_TYPE.ADD_RECORD, TABLE_EVENT_TYPE.DELETE_RECORD, TABLE_EVENT_TYPE.UPDATE_RECORD, TABLE_EVENT_TYPE.ADD_COLUMN, TABLE_EVENT_TYPE.DELETE_COLUMN, TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION, TABLE_EVENT_TYPE.SORT_CLICK, TABLE_EVENT_TYPE.RESIZE_ROW, TABLE_EVENT_TYPE.RESIZE_ROW_END, TABLE_EVENT_TYPE.RESIZE_COLUMN, TABLE_EVENT_TYPE.RESIZE_COLUMN_END], this.table = null, this.undoStack = [], this.redoStack = [], this.currentTransaction = null, this.isReplaying = !1, this.prevColumnsSnapshot = null, this.prevRecordsSnapshot = null, this.prevFormulasSnapshot = null, this.prevResizedRowHeightsSnapshot = null, this.prevResizedColWidthsSnapshot = null, this.lastKnownSortState = null, this.sortStartSnapshot = null, this.sortPending = !1, this.sortEventBound = !1, this.cellPreChangeContent = new Map(), this.formulaCache = new Map(), this.formulaEventBound = !1, this.resizeRowStartHeight = new Map(), this.resizeColStartWidth = new Map(), this.filterEventBound = !1, this.filterUnsubscribe = null, this.filterApplyingSnapshot = !1, this.id = null !== (_a = null == options ? void 0 : options.id) && void 0 !== _a ? _a : this.id, this.maxHistory = null !== (_b = null == options ? void 0 : options.maxHistory) && void 0 !== _b ? _b : 100, this.enableCompression = null !== (_c = null == options ? void 0 : options.enableCompression) && void 0 !== _c && _c, this.onTransactionPushed = null == options ? void 0 : options.onTransactionPushed;
|
|
85720
|
+
}
|
|
85721
|
+
run(...args) {
|
|
85722
|
+
var _a, _b, _c, _d, _e, _f;
|
|
85723
|
+
const eventArgs = args[0],
|
|
85724
|
+
runtime = args[1],
|
|
85725
|
+
table = args[2];
|
|
85726
|
+
if (!table) return;
|
|
85727
|
+
if (this.table) this.vtableSheet || (this.vtableSheet = table.__vtableSheet);else if (this.table = table, this.vtableSheet = table.__vtableSheet, runtime !== TABLE_EVENT_TYPE.BEFORE_INIT && (null === (_a = table.internalProps) || void 0 === _a ? void 0 : _a.dataSource)) {
|
|
85728
|
+
const state = this.getSnapshotState(),
|
|
85729
|
+
sheetKey = this.getSheetKey();
|
|
85730
|
+
captureSnapshot(table, state, {
|
|
85731
|
+
formulaManager: null === (_b = this.vtableSheet) || void 0 === _b ? void 0 : _b.formulaManager,
|
|
85732
|
+
sheetKey: sheetKey
|
|
85733
|
+
}), this.setSnapshotState(state), this.lastKnownSortState = this.normalizeSortState(null === (_c = table.internalProps) || void 0 === _c ? void 0 : _c.sortState);
|
|
85734
|
+
}
|
|
85735
|
+
if (this.ensureFilterEventBindings(), runtime === TABLE_EVENT_TYPE.BEFORE_INIT) return;
|
|
85736
|
+
this.ensureFormulaEventBindings(), this.ensureSortEventBindings();
|
|
85737
|
+
const workbookReplaying = null === (_e = null === (_d = this.table) || void 0 === _d ? void 0 : _d.__vtableSheet) || void 0 === _e ? void 0 : _e.__workbookHistoryReplaying;
|
|
85738
|
+
if (!this.isReplaying && !workbookReplaying) {
|
|
85739
|
+
switch (runtime) {
|
|
85740
|
+
case TABLE_EVENT_TYPE.INITIALIZED:
|
|
85741
|
+
break;
|
|
85742
|
+
case TABLE_EVENT_TYPE.BEFORE_KEYDOWN:
|
|
85743
|
+
this.handleBeforeKeydown(eventArgs);
|
|
85744
|
+
break;
|
|
85745
|
+
case TABLE_EVENT_TYPE.CHANGE_CELL_VALUE:
|
|
85746
|
+
this.handleChangeCellValue(eventArgs);
|
|
85747
|
+
break;
|
|
85748
|
+
case TABLE_EVENT_TYPE.CHANGE_CELL_VALUES:
|
|
85749
|
+
this.handleChangeCellValues(eventArgs);
|
|
85750
|
+
break;
|
|
85751
|
+
case TABLE_EVENT_TYPE.PASTED_DATA:
|
|
85752
|
+
break;
|
|
85753
|
+
case TABLE_EVENT_TYPE.MERGE_CELLS:
|
|
85754
|
+
this.handleMergeCells(eventArgs);
|
|
85755
|
+
break;
|
|
85756
|
+
case TABLE_EVENT_TYPE.UNMERGE_CELLS:
|
|
85757
|
+
this.handleUnmergeCells(eventArgs);
|
|
85758
|
+
break;
|
|
85759
|
+
case TABLE_EVENT_TYPE.ADD_RECORD:
|
|
85760
|
+
this.handleAddRecord(eventArgs);
|
|
85761
|
+
break;
|
|
85762
|
+
case TABLE_EVENT_TYPE.DELETE_RECORD:
|
|
85763
|
+
this.handleDeleteRecord(eventArgs);
|
|
85764
|
+
break;
|
|
85765
|
+
case TABLE_EVENT_TYPE.UPDATE_RECORD:
|
|
85766
|
+
this.handleUpdateRecord(eventArgs);
|
|
85767
|
+
break;
|
|
85768
|
+
case TABLE_EVENT_TYPE.ADD_COLUMN:
|
|
85769
|
+
this.handleAddColumn(eventArgs);
|
|
85770
|
+
break;
|
|
85771
|
+
case TABLE_EVENT_TYPE.DELETE_COLUMN:
|
|
85772
|
+
this.handleDeleteColumn(eventArgs);
|
|
85773
|
+
break;
|
|
85774
|
+
case TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION:
|
|
85775
|
+
this.handleChangeHeaderPosition(eventArgs);
|
|
85776
|
+
break;
|
|
85777
|
+
case TABLE_EVENT_TYPE.SORT_CLICK:
|
|
85778
|
+
this.handleSortClick(eventArgs);
|
|
85779
|
+
break;
|
|
85780
|
+
case TABLE_EVENT_TYPE.RESIZE_ROW:
|
|
85781
|
+
this.handleResizeRow(eventArgs);
|
|
85782
|
+
break;
|
|
85783
|
+
case TABLE_EVENT_TYPE.RESIZE_ROW_END:
|
|
85784
|
+
this.handleResizeRowEnd(eventArgs);
|
|
85785
|
+
break;
|
|
85786
|
+
case TABLE_EVENT_TYPE.RESIZE_COLUMN:
|
|
85787
|
+
this.handleResizeColumn(eventArgs);
|
|
85788
|
+
break;
|
|
85789
|
+
case TABLE_EVENT_TYPE.RESIZE_COLUMN_END:
|
|
85790
|
+
this.handleResizeColumnEnd(eventArgs);
|
|
85791
|
+
}
|
|
85792
|
+
if (this.table) {
|
|
85793
|
+
const state = this.getSnapshotState(),
|
|
85794
|
+
sheetKey = this.getSheetKey();
|
|
85795
|
+
captureSnapshot(this.table, state, {
|
|
85796
|
+
formulaManager: null === (_f = this.vtableSheet) || void 0 === _f ? void 0 : _f.formulaManager,
|
|
85797
|
+
sheetKey: sheetKey
|
|
85798
|
+
}), this.setSnapshotState(state);
|
|
85799
|
+
}
|
|
85800
|
+
}
|
|
85801
|
+
}
|
|
85802
|
+
startTransaction() {
|
|
85803
|
+
this.currentTransaction || (this.currentTransaction = {
|
|
85804
|
+
commands: []
|
|
85805
|
+
});
|
|
85806
|
+
}
|
|
85807
|
+
endTransaction() {
|
|
85808
|
+
this.currentTransaction && 0 !== this.currentTransaction.commands.length ? (this.pushTransaction(this.currentTransaction), this.currentTransaction = null) : this.currentTransaction = null;
|
|
85809
|
+
}
|
|
85810
|
+
undo() {
|
|
85811
|
+
var _a;
|
|
85812
|
+
if (!this.table || 0 === this.undoStack.length) return;
|
|
85813
|
+
const transaction = this.undoStack.pop();
|
|
85814
|
+
this.isReplaying = !0;
|
|
85815
|
+
try {
|
|
85816
|
+
for (let i = transaction.commands.length - 1; i >= 0; i--) this.applyCommand(transaction.commands[i], "undo");
|
|
85817
|
+
} finally {
|
|
85818
|
+
this.isReplaying = !1;
|
|
85819
|
+
}
|
|
85820
|
+
if (this.redoStack.push(transaction), this.table) {
|
|
85821
|
+
const state = this.getSnapshotState(),
|
|
85822
|
+
sheetKey = this.getSheetKey();
|
|
85823
|
+
captureSnapshot(this.table, state, {
|
|
85824
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85825
|
+
sheetKey: sheetKey
|
|
85826
|
+
}), this.setSnapshotState(state);
|
|
85827
|
+
}
|
|
85828
|
+
}
|
|
85829
|
+
redo() {
|
|
85830
|
+
var _a;
|
|
85831
|
+
if (!this.table || 0 === this.redoStack.length) return;
|
|
85832
|
+
const transaction = this.redoStack.pop();
|
|
85833
|
+
this.isReplaying = !0;
|
|
85834
|
+
try {
|
|
85835
|
+
for (const cmd of transaction.commands) this.applyCommand(cmd, "redo");
|
|
85836
|
+
} finally {
|
|
85837
|
+
this.isReplaying = !1;
|
|
85838
|
+
}
|
|
85839
|
+
if (this.undoStack.push(transaction), this.table) {
|
|
85840
|
+
const state = this.getSnapshotState(),
|
|
85841
|
+
sheetKey = this.getSheetKey();
|
|
85842
|
+
captureSnapshot(this.table, state, {
|
|
85843
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85844
|
+
sheetKey: sheetKey
|
|
85845
|
+
}), this.setSnapshotState(state);
|
|
85846
|
+
}
|
|
85847
|
+
}
|
|
85848
|
+
clear() {
|
|
85849
|
+
this.undoStack = [], this.redoStack = [], this.currentTransaction = null;
|
|
85850
|
+
}
|
|
85851
|
+
updateOptions(options) {
|
|
85852
|
+
null != options.maxHistory && (this.maxHistory = options.maxHistory, this.trimHistory()), null != options.enableCompression && (this.enableCompression = options.enableCompression), options.onTransactionPushed && (this.onTransactionPushed = options.onTransactionPushed);
|
|
85853
|
+
}
|
|
85854
|
+
release() {
|
|
85855
|
+
this.clear(), this.unbindFormulaEvents(), this.unbindSortEvents(), this.unbindFilterEvents(), this.table = null, this.vtableSheet = null, this.resolvedSheetKey = void 0, this.prevColumnsSnapshot = null, this.prevMergeSnapshot = void 0, this.prevRecordsSnapshot = null, this.prevFormulasSnapshot = null, this.prevResizedRowHeightsSnapshot = null, this.prevResizedColWidthsSnapshot = null, this.lastKnownSortState = null, this.sortStartSnapshot = null, this.sortPending = !1, this.sortEventBound = !1, this.sortChangeOrderListenerId = void 0, this.cellPreChangeContent.clear(), this.formulaCache.clear(), this.resizeRowStartHeight.clear(), this.resizeColStartWidth.clear(), this.filterEventBound = !1, this.filterUnsubscribe = null, this.filterSnapshotCache = void 0, this.filterPluginId = void 0;
|
|
85856
|
+
}
|
|
85857
|
+
ensureFilterEventBindings() {
|
|
85858
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85859
|
+
if (!this.table) return;
|
|
85860
|
+
const pm = this.table.pluginManager,
|
|
85861
|
+
filterPlugin = null !== (_f = null !== (_d = null !== (_b = null === (_a = null == pm ? void 0 : pm.getPlugin) || void 0 === _a ? void 0 : _a.call(pm, "filter")) && void 0 !== _b ? _b : null === (_c = null == pm ? void 0 : pm.getPluginByName) || void 0 === _c ? void 0 : _c.call(pm, "Filter")) && void 0 !== _d ? _d : null === (_e = null == pm ? void 0 : pm.getPlugin) || void 0 === _e ? void 0 : _e.call(pm, "filter-plugin")) && void 0 !== _f ? _f : null === (_g = null == pm ? void 0 : pm.getPluginByName) || void 0 === _g ? void 0 : _g.call(pm, "filter-plugin");
|
|
85862
|
+
if (!(null == filterPlugin ? void 0 : filterPlugin.getFilterSnapshot) || !(null == filterPlugin ? void 0 : filterPlugin.applyFilterSnapshot)) return;
|
|
85863
|
+
this.filterEventBound || (this.filterEventBound = !0, this.filterPluginRef = filterPlugin, this.filterPluginId = null !== (_h = filterPlugin.id) && void 0 !== _h ? _h : "filter", this.filterSnapshotCache = cloneDeep(filterPlugin.getFilterSnapshot())), this.filterApplySnapshotOriginal || (this.filterApplySnapshotOriginal = null === (_j = filterPlugin.applyFilterSnapshot) || void 0 === _j ? void 0 : _j.bind(filterPlugin), this.filterApplySnapshotOriginal && (filterPlugin.applyFilterSnapshot = snapshot => {
|
|
85864
|
+
var _a, _b;
|
|
85865
|
+
if (this.isReplaying) return this.filterApplySnapshotOriginal(snapshot);
|
|
85866
|
+
const oldSnapshot = null !== (_a = this.filterSnapshotCache) && void 0 !== _a ? _a : filterPlugin.getFilterSnapshot();
|
|
85867
|
+
this.filterApplyingSnapshot = !0;
|
|
85868
|
+
try {
|
|
85869
|
+
return this.filterApplySnapshotOriginal(snapshot);
|
|
85870
|
+
} finally {
|
|
85871
|
+
this.filterApplyingSnapshot = !1;
|
|
85872
|
+
const newSnapshot = filterPlugin.getFilterSnapshot();
|
|
85873
|
+
if (JSON.stringify(oldSnapshot) !== JSON.stringify(newSnapshot)) {
|
|
85874
|
+
const cmd = {
|
|
85875
|
+
type: "filter",
|
|
85876
|
+
sheetKey: this.getSheetKey(),
|
|
85877
|
+
pluginId: null !== (_b = this.filterPluginId) && void 0 !== _b ? _b : "filter",
|
|
85878
|
+
oldSnapshot: oldSnapshot,
|
|
85879
|
+
newSnapshot: newSnapshot
|
|
85880
|
+
};
|
|
85881
|
+
this.pushCommand(cmd), this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85882
|
+
} else this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85883
|
+
}
|
|
85884
|
+
}));
|
|
85885
|
+
const stateManager = null == filterPlugin ? void 0 : filterPlugin.filterStateManager;
|
|
85886
|
+
!this.filterUnsubscribe && (null == stateManager ? void 0 : stateManager.subscribe) && (this.filterUnsubscribe = stateManager.subscribe((_state, action) => {
|
|
85887
|
+
var _a, _b;
|
|
85888
|
+
if (this.isReplaying) return;
|
|
85889
|
+
if (this.filterApplyingSnapshot) return void (this.filterSnapshotCache = cloneDeep(filterPlugin.getFilterSnapshot()));
|
|
85890
|
+
const t = null == action ? void 0 : action.type;
|
|
85891
|
+
if (t !== FilterActionType.APPLY_FILTERS && t !== FilterActionType.CLEAR_ALL_FILTERS && t !== FilterActionType.REMOVE_FILTER && t !== FilterActionType.DISABLE_FILTER) return;
|
|
85892
|
+
const oldSnapshot = null !== (_a = this.filterSnapshotCache) && void 0 !== _a ? _a : filterPlugin.getFilterSnapshot(),
|
|
85893
|
+
newSnapshot = filterPlugin.getFilterSnapshot();
|
|
85894
|
+
if (JSON.stringify(oldSnapshot) === JSON.stringify(newSnapshot)) return;
|
|
85895
|
+
const cmd = {
|
|
85896
|
+
type: "filter",
|
|
85897
|
+
sheetKey: this.getSheetKey(),
|
|
85898
|
+
pluginId: null !== (_b = this.filterPluginId) && void 0 !== _b ? _b : "filter",
|
|
85899
|
+
oldSnapshot: oldSnapshot,
|
|
85900
|
+
newSnapshot: newSnapshot
|
|
85901
|
+
};
|
|
85902
|
+
this.pushCommand(cmd), this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85903
|
+
}));
|
|
85904
|
+
}
|
|
85905
|
+
unbindFilterEvents() {
|
|
85906
|
+
var _a;
|
|
85907
|
+
null === (_a = this.filterUnsubscribe) || void 0 === _a || _a.call(this), this.filterUnsubscribe = null, this.filterEventBound = !1, this.filterPluginRef && this.filterApplySnapshotOriginal && (this.filterPluginRef.applyFilterSnapshot = this.filterApplySnapshotOriginal), this.filterPluginRef = null, this.filterApplySnapshotOriginal = null, this.filterApplyingSnapshot = !1;
|
|
85908
|
+
}
|
|
85909
|
+
getSheetKey() {
|
|
85910
|
+
const resolved = resolveSheetKey({
|
|
85911
|
+
vtableSheet: this.vtableSheet,
|
|
85912
|
+
table: this.table,
|
|
85913
|
+
cached: this.resolvedSheetKey
|
|
85914
|
+
});
|
|
85915
|
+
return this.resolvedSheetKey = resolved.cached, resolved.sheetKey;
|
|
85916
|
+
}
|
|
85917
|
+
getSnapshotState() {
|
|
85918
|
+
return {
|
|
85919
|
+
prevColumnsSnapshot: this.prevColumnsSnapshot,
|
|
85920
|
+
prevMergeSnapshot: this.prevMergeSnapshot,
|
|
85921
|
+
prevRecordsSnapshot: this.prevRecordsSnapshot,
|
|
85922
|
+
prevFormulasSnapshot: this.prevFormulasSnapshot,
|
|
85923
|
+
prevResizedRowHeightsSnapshot: this.prevResizedRowHeightsSnapshot,
|
|
85924
|
+
prevResizedColWidthsSnapshot: this.prevResizedColWidthsSnapshot
|
|
85925
|
+
};
|
|
85926
|
+
}
|
|
85927
|
+
setSnapshotState(next) {
|
|
85928
|
+
var _a, _b, _c;
|
|
85929
|
+
this.prevColumnsSnapshot = next.prevColumnsSnapshot, this.prevMergeSnapshot = next.prevMergeSnapshot, this.prevRecordsSnapshot = next.prevRecordsSnapshot, this.prevFormulasSnapshot = null !== (_a = next.prevFormulasSnapshot) && void 0 !== _a ? _a : null, this.prevResizedRowHeightsSnapshot = null !== (_b = next.prevResizedRowHeightsSnapshot) && void 0 !== _b ? _b : null, this.prevResizedColWidthsSnapshot = null !== (_c = next.prevResizedColWidthsSnapshot) && void 0 !== _c ? _c : null;
|
|
85930
|
+
}
|
|
85931
|
+
pushTransaction(tx) {
|
|
85932
|
+
var _a, _b, _c;
|
|
85933
|
+
if (0 !== tx.commands.length && (this.undoStack.push(tx), this.redoStack = [], this.trimHistory(), this.onTransactionPushed && !this.isReplaying)) {
|
|
85934
|
+
(null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.__vtableSheet) || void 0 === _b ? void 0 : _b.__workbookHistoryReplaying) || this.onTransactionPushed({
|
|
85935
|
+
tx: tx,
|
|
85936
|
+
sheetKey: this.getSheetKey(),
|
|
85937
|
+
table: null !== (_c = this.table) && void 0 !== _c ? _c : void 0
|
|
85938
|
+
});
|
|
85939
|
+
}
|
|
85940
|
+
}
|
|
85941
|
+
trimHistory() {
|
|
85942
|
+
this.undoStack.length > this.maxHistory && this.undoStack.splice(0, this.undoStack.length - this.maxHistory);
|
|
85943
|
+
}
|
|
85944
|
+
pushCommand(cmd) {
|
|
85945
|
+
this.currentTransaction ? this.currentTransaction.commands.push(cmd) : this.pushTransaction({
|
|
85946
|
+
commands: [cmd]
|
|
85947
|
+
});
|
|
85948
|
+
}
|
|
85949
|
+
recordExternalCommand(cmd) {
|
|
85950
|
+
this.isReplaying || this.pushCommand(cmd);
|
|
85951
|
+
}
|
|
85952
|
+
tryCompressCellChange(change, sheetKey) {
|
|
85953
|
+
if (!this.enableCompression) return !1;
|
|
85954
|
+
const targetTx = this.currentTransaction || this.undoStack[this.undoStack.length - 1];
|
|
85955
|
+
if (!targetTx || 0 === targetTx.commands.length) return !1;
|
|
85956
|
+
const last = targetTx.commands[targetTx.commands.length - 1];
|
|
85957
|
+
if (("cell" === last.type || "cells" === last.type) && last.sheetKey === sheetKey) {
|
|
85958
|
+
const cells = last.cells;
|
|
85959
|
+
if (1 === cells.length && cells[0].row === change.row && cells[0].col === change.col) return cells[0].newContent = change.newContent, !0;
|
|
85960
|
+
}
|
|
85961
|
+
return !1;
|
|
85962
|
+
}
|
|
85963
|
+
handleBeforeKeydown(eventArgs) {
|
|
85964
|
+
var _a, _b, _c, _d, _e, _f;
|
|
85965
|
+
const e = eventArgs.event;
|
|
85966
|
+
if (!e || !this.table) return;
|
|
85967
|
+
if (!(e.ctrlKey || e.metaKey)) return;
|
|
85968
|
+
const formulaManager = null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager;
|
|
85969
|
+
if (null == formulaManager ? void 0 : formulaManager.formulaWorkingOnCell) return;
|
|
85970
|
+
if (null === (_b = this.table.editorManager) || void 0 === _b ? void 0 : _b.editingEditor) return;
|
|
85971
|
+
const key = e.key.toLowerCase();
|
|
85972
|
+
if ("z" === key) {
|
|
85973
|
+
const workbookHistory = null === (_d = null === (_c = this.vtableSheet) || void 0 === _c ? void 0 : _c.getWorkbookHistoryManager) || void 0 === _d ? void 0 : _d.call(_c);
|
|
85974
|
+
e.shiftKey ? workbookHistory ? workbookHistory.redo() : this.redo() : workbookHistory ? workbookHistory.undo() : this.undo(), e.preventDefault(), e.stopPropagation();
|
|
85975
|
+
} else if ("y" === key) {
|
|
85976
|
+
const workbookHistory = null === (_f = null === (_e = this.vtableSheet) || void 0 === _e ? void 0 : _e.getWorkbookHistoryManager) || void 0 === _f ? void 0 : _f.call(_e);
|
|
85977
|
+
workbookHistory ? workbookHistory.redo() : this.redo(), e.preventDefault(), e.stopPropagation();
|
|
85978
|
+
}
|
|
85979
|
+
}
|
|
85980
|
+
handleChangeCellValue(eventArgs) {
|
|
85981
|
+
var _a;
|
|
85982
|
+
captureCellPreChangeContent({
|
|
85983
|
+
sheetKey: this.getSheetKey(),
|
|
85984
|
+
row: eventArgs.row,
|
|
85985
|
+
col: eventArgs.col,
|
|
85986
|
+
currentValue: eventArgs.currentValue,
|
|
85987
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85988
|
+
store: this.cellPreChangeContent
|
|
85989
|
+
});
|
|
85990
|
+
}
|
|
85991
|
+
handleChangeCellValues(eventArgs) {
|
|
85992
|
+
var _a;
|
|
85993
|
+
if (!this.table) return;
|
|
85994
|
+
const sheetKey = this.getSheetKey(),
|
|
85995
|
+
formulaManager = null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85996
|
+
cells = eventArgs.values.map(v => {
|
|
85997
|
+
const oldContent = popCellPreChangeContent({
|
|
85998
|
+
sheetKey: sheetKey,
|
|
85999
|
+
row: v.row,
|
|
86000
|
+
col: v.col,
|
|
86001
|
+
fallbackOldContent: v.currentValue,
|
|
86002
|
+
store: this.cellPreChangeContent
|
|
86003
|
+
}),
|
|
86004
|
+
normalizedOld = null == oldContent ? "" : oldContent,
|
|
86005
|
+
normalizedNew = null == v.changedValue ? "" : v.changedValue;
|
|
86006
|
+
return {
|
|
86007
|
+
row: v.row,
|
|
86008
|
+
col: v.col,
|
|
86009
|
+
oldContent: normalizedOld,
|
|
86010
|
+
newContent: normalizedNew
|
|
86011
|
+
};
|
|
86012
|
+
}).filter(c => {
|
|
86013
|
+
if (c.oldContent === c.newContent) return !1;
|
|
86014
|
+
if (!sheetKey || !(null == formulaManager ? void 0 : formulaManager.getCellFormula) || !(null == formulaManager ? void 0 : formulaManager.getCellValue)) return !0;
|
|
86015
|
+
if ("string" == typeof c.newContent && c.newContent.startsWith("=")) return !1;
|
|
86016
|
+
if (!formulaManager.getCellFormula({
|
|
86017
|
+
sheet: sheetKey,
|
|
86018
|
+
row: c.row,
|
|
86019
|
+
col: c.col
|
|
86020
|
+
})) return !0;
|
|
86021
|
+
const result = formulaManager.getCellValue({
|
|
86022
|
+
sheet: sheetKey,
|
|
86023
|
+
row: c.row,
|
|
86024
|
+
col: c.col
|
|
86025
|
+
}),
|
|
86026
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
86027
|
+
return display !== c.newContent && (null == display || null == c.newContent || String(display) !== String(c.newContent));
|
|
86028
|
+
});
|
|
86029
|
+
if (!cells.length) return;
|
|
86030
|
+
if (sheetKey && 1 === cells.length && this.tryCompressCellChange(cells[0], sheetKey)) return;
|
|
86031
|
+
const cmd = {
|
|
86032
|
+
type: "cells",
|
|
86033
|
+
sheetKey: sheetKey,
|
|
86034
|
+
cells: cells
|
|
86035
|
+
};
|
|
86036
|
+
this.pushCommand(cmd);
|
|
86037
|
+
}
|
|
86038
|
+
ensureFormulaEventBindings() {
|
|
86039
|
+
var _a, _b, _c, _d, _e;
|
|
86040
|
+
if (!this.table || !this.vtableSheet || this.formulaEventBound) return;
|
|
86041
|
+
const sheetKey = this.getSheetKey();
|
|
86042
|
+
if (!sheetKey) return;
|
|
86043
|
+
const worksheet = null !== (_c = null === (_b = (_a = this.vtableSheet).getWorkSheetByKey) || void 0 === _b ? void 0 : _b.call(_a, sheetKey)) && void 0 !== _c ? _c : null === (_e = null === (_d = this.vtableSheet.workSheetInstances) || void 0 === _d ? void 0 : _d.get) || void 0 === _e ? void 0 : _e.call(_d, sheetKey),
|
|
86044
|
+
eventManager = null == worksheet ? void 0 : worksheet.eventManager;
|
|
86045
|
+
(null == eventManager ? void 0 : eventManager.on) && (null == eventManager ? void 0 : eventManager.off) && (this.formulaEventBound = !0, this.formulaEventManager = eventManager, this.onFormulaAddedHandler = event => {
|
|
86046
|
+
if (this.isReplaying) return;
|
|
86047
|
+
const cell = null == event ? void 0 : event.cell,
|
|
86048
|
+
formula = null == event ? void 0 : event.formula;
|
|
86049
|
+
if (!cell || "number" != typeof cell.row || "number" != typeof cell.col) return;
|
|
86050
|
+
if ("string" != typeof formula || !formula.length) return;
|
|
86051
|
+
const normalized = formula.startsWith("=") ? formula : `=${formula}`,
|
|
86052
|
+
key = `${sheetKey}:${cell.row}:${cell.col}`,
|
|
86053
|
+
prev = this.formulaCache.get(key),
|
|
86054
|
+
oldContent = popCellPreChangeContent({
|
|
86055
|
+
sheetKey: sheetKey,
|
|
86056
|
+
row: cell.row,
|
|
86057
|
+
col: cell.col,
|
|
86058
|
+
fallbackOldContent: void 0 !== prev ? prev : "",
|
|
86059
|
+
store: this.cellPreChangeContent
|
|
86060
|
+
});
|
|
86061
|
+
if (oldContent === normalized) return void this.formulaCache.set(key, normalized);
|
|
86062
|
+
const cmd = {
|
|
86063
|
+
type: "cells",
|
|
86064
|
+
sheetKey: sheetKey,
|
|
86065
|
+
cells: [{
|
|
86066
|
+
row: cell.row,
|
|
86067
|
+
col: cell.col,
|
|
86068
|
+
oldContent: oldContent,
|
|
86069
|
+
newContent: normalized
|
|
86070
|
+
}]
|
|
86071
|
+
};
|
|
86072
|
+
this.pushCommand(cmd), this.formulaCache.set(key, normalized);
|
|
86073
|
+
}, eventManager.on("formula_added", this.onFormulaAddedHandler));
|
|
86074
|
+
}
|
|
86075
|
+
ensureSortEventBindings() {
|
|
86076
|
+
var _a;
|
|
86077
|
+
if (!this.table || this.sortEventBound) return;
|
|
86078
|
+
const ds = null === (_a = this.table.internalProps) || void 0 === _a ? void 0 : _a.dataSource;
|
|
86079
|
+
(null == ds ? void 0 : ds.on) && (null == ds ? void 0 : ds.off) && (this.sortEventBound = !0, this.sortChangeOrderListenerId = ds.on("change_order", () => {
|
|
86080
|
+
var _a;
|
|
86081
|
+
if (this.isReplaying || !this.table || !this.sortPending) return;
|
|
86082
|
+
const sheetKey = this.getSheetKey(),
|
|
86083
|
+
oldSortState = this.sortStartSnapshot;
|
|
86084
|
+
this.sortStartSnapshot = null, this.sortPending = !1;
|
|
86085
|
+
const newSortState = this.normalizeSortState(null === (_a = this.table.internalProps) || void 0 === _a ? void 0 : _a.sortState);
|
|
86086
|
+
if (JSON.stringify(oldSortState) === JSON.stringify(newSortState)) return void (this.lastKnownSortState = newSortState);
|
|
86087
|
+
const cmd = {
|
|
86088
|
+
type: "sort",
|
|
86089
|
+
sheetKey: sheetKey,
|
|
86090
|
+
oldSortState: oldSortState,
|
|
86091
|
+
newSortState: newSortState
|
|
86092
|
+
};
|
|
86093
|
+
this.pushCommand(cmd), this.lastKnownSortState = newSortState;
|
|
86094
|
+
}));
|
|
86095
|
+
}
|
|
86096
|
+
unbindSortEvents() {
|
|
86097
|
+
var _a, _b;
|
|
86098
|
+
if (!this.sortEventBound) return;
|
|
86099
|
+
const ds = null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.internalProps) || void 0 === _b ? void 0 : _b.dataSource;
|
|
86100
|
+
try {
|
|
86101
|
+
(null == ds ? void 0 : ds.off) && this.sortChangeOrderListenerId && ds.off(this.sortChangeOrderListenerId);
|
|
86102
|
+
} catch (_c) {} finally {
|
|
86103
|
+
this.sortEventBound = !1, this.sortChangeOrderListenerId = void 0, this.sortPending = !1, this.sortStartSnapshot = null;
|
|
86104
|
+
}
|
|
86105
|
+
}
|
|
86106
|
+
unbindFormulaEvents() {
|
|
86107
|
+
if (this.formulaEventBound && this.formulaEventManager) try {
|
|
86108
|
+
this.onFormulaAddedHandler && this.formulaEventManager.off("formula_added", this.onFormulaAddedHandler);
|
|
86109
|
+
} catch (_a) {} finally {
|
|
86110
|
+
this.formulaEventBound = !1, this.formulaEventManager = void 0, this.onFormulaAddedHandler = void 0;
|
|
86111
|
+
}
|
|
86112
|
+
}
|
|
86113
|
+
cloneMergeConfig(input) {
|
|
86114
|
+
return Array.isArray(input) ? input.map(i => cloneDeep(i)) : input;
|
|
86115
|
+
}
|
|
86116
|
+
isSameMergeConfig(a, b) {
|
|
86117
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
86118
|
+
const normalize = v => null == v ? [] : (v),
|
|
86119
|
+
aa = normalize(a),
|
|
86120
|
+
bb = normalize(b);
|
|
86121
|
+
if (aa === bb) return !0;
|
|
86122
|
+
if (Array.isArray(aa) && Array.isArray(bb)) {
|
|
86123
|
+
if (aa.length !== bb.length) return !1;
|
|
86124
|
+
for (let i = 0; i < aa.length; i++) {
|
|
86125
|
+
const ra = null === (_a = aa[i]) || void 0 === _a ? void 0 : _a.range,
|
|
86126
|
+
rb = null === (_b = bb[i]) || void 0 === _b ? void 0 : _b.range;
|
|
86127
|
+
if (!ra || !rb || (null === (_c = ra.start) || void 0 === _c ? void 0 : _c.col) !== (null === (_d = rb.start) || void 0 === _d ? void 0 : _d.col) || (null === (_e = ra.start) || void 0 === _e ? void 0 : _e.row) !== (null === (_f = rb.start) || void 0 === _f ? void 0 : _f.row) || (null === (_g = ra.end) || void 0 === _g ? void 0 : _g.col) !== (null === (_h = rb.end) || void 0 === _h ? void 0 : _h.col) || (null === (_j = ra.end) || void 0 === _j ? void 0 : _j.row) !== (null === (_k = rb.end) || void 0 === _k ? void 0 : _k.row) || (null === (_l = aa[i]) || void 0 === _l ? void 0 : _l.text) !== (null === (_m = bb[i]) || void 0 === _m ? void 0 : _m.text)) return !1;
|
|
86128
|
+
}
|
|
86129
|
+
return !0;
|
|
86130
|
+
}
|
|
86131
|
+
return !1;
|
|
86132
|
+
}
|
|
86133
|
+
handleMergeCells(eventArgs) {
|
|
86134
|
+
this.handleMergeConfigChanged(eventArgs);
|
|
86135
|
+
}
|
|
86136
|
+
handleUnmergeCells(eventArgs) {
|
|
86137
|
+
this.handleMergeConfigChanged(eventArgs);
|
|
86138
|
+
}
|
|
86139
|
+
handleMergeConfigChanged(eventArgs) {
|
|
86140
|
+
var _a;
|
|
86141
|
+
if (!this.table) return;
|
|
86142
|
+
const {
|
|
86143
|
+
startCol: startCol,
|
|
86144
|
+
startRow: startRow,
|
|
86145
|
+
endCol: endCol,
|
|
86146
|
+
endRow: endRow
|
|
86147
|
+
} = eventArgs,
|
|
86148
|
+
before = this.cloneMergeConfig(this.prevMergeSnapshot),
|
|
86149
|
+
after = this.cloneMergeConfig(null === (_a = this.table.options) || void 0 === _a ? void 0 : _a.customMergeCell);
|
|
86150
|
+
if (this.isSameMergeConfig(before, after)) return;
|
|
86151
|
+
const cmd = {
|
|
86152
|
+
type: "merge_cells",
|
|
86153
|
+
sheetKey: this.getSheetKey(),
|
|
86154
|
+
startCol: startCol,
|
|
86155
|
+
startRow: startRow,
|
|
86156
|
+
endCol: endCol,
|
|
86157
|
+
endRow: endRow,
|
|
86158
|
+
oldCustomMergeCell: before,
|
|
86159
|
+
newCustomMergeCell: after
|
|
86160
|
+
};
|
|
86161
|
+
this.pushCommand(cmd);
|
|
86162
|
+
}
|
|
86163
|
+
handleAddRecord(eventArgs) {
|
|
86164
|
+
var _a, _b, _c, _d;
|
|
86165
|
+
const cmd = {
|
|
86166
|
+
type: "add_record",
|
|
86167
|
+
sheetKey: this.getSheetKey(),
|
|
86168
|
+
records: Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [],
|
|
86169
|
+
recordIndex: eventArgs.recordIndex,
|
|
86170
|
+
recordCount: null !== (_a = eventArgs.recordCount) && void 0 !== _a ? _a : Array.isArray(eventArgs.records) ? eventArgs.records.length : 0
|
|
86171
|
+
};
|
|
86172
|
+
if (this.table && "number" == typeof eventArgs.recordIndex) {
|
|
86173
|
+
const start = eventArgs.recordIndex,
|
|
86174
|
+
count = cmd.recordCount,
|
|
86175
|
+
ds = null === (_c = null === (_b = this.table) || void 0 === _b ? void 0 : _b.internalProps) || void 0 === _c ? void 0 : _c.dataSource,
|
|
86176
|
+
rawRecords = null === (_d = null == ds ? void 0 : ds.dataSourceObj) || void 0 === _d ? void 0 : _d.records,
|
|
86177
|
+
viewRecords = this.table.records;
|
|
86178
|
+
if (Array.isArray(viewRecords) && viewRecords.length && (cmd.anchorBefore = start > 0 ? viewRecords[start - 1] : void 0, cmd.anchorAfter = viewRecords[start + count]), Array.isArray(rawRecords) && Array.isArray(viewRecords)) {
|
|
86179
|
+
let rawInsertIndex = rawRecords.length;
|
|
86180
|
+
if (0 === viewRecords.length) rawInsertIndex = rawRecords.length;else if (start <= 0) {
|
|
86181
|
+
const first = viewRecords[0],
|
|
86182
|
+
idx = rawRecords.indexOf(first);
|
|
86183
|
+
rawInsertIndex = idx >= 0 ? idx : 0;
|
|
86184
|
+
} else if (start >= viewRecords.length) {
|
|
86185
|
+
const last = viewRecords[viewRecords.length - 1],
|
|
86186
|
+
idx = rawRecords.indexOf(last);
|
|
86187
|
+
rawInsertIndex = idx >= 0 ? idx + 1 : rawRecords.length;
|
|
86188
|
+
} else {
|
|
86189
|
+
const prev = viewRecords[start - 1],
|
|
86190
|
+
idx = rawRecords.indexOf(prev);
|
|
86191
|
+
rawInsertIndex = idx >= 0 ? idx + 1 : rawRecords.length;
|
|
86192
|
+
}
|
|
86193
|
+
cmd.rawInsertIndex = rawInsertIndex;
|
|
86194
|
+
}
|
|
86195
|
+
}
|
|
86196
|
+
this.pushCommand(cmd);
|
|
86197
|
+
}
|
|
86198
|
+
handleDeleteRecord(eventArgs) {
|
|
86199
|
+
var _a, _b;
|
|
86200
|
+
const sheetKey = this.getSheetKey(),
|
|
86201
|
+
recordIndexs = Array.isArray(eventArgs.recordIndexs) ? eventArgs.recordIndexs.slice() : [eventArgs.recordIndexs];
|
|
86202
|
+
let deletedRowHeights;
|
|
86203
|
+
if (this.table && this.prevResizedRowHeightsSnapshot) {
|
|
86204
|
+
const headerCount = this.table.transpose ? this.table.rowHeaderLevelCount : this.table.columnHeaderLevelCount;
|
|
86205
|
+
recordIndexs.forEach(idx => {
|
|
86206
|
+
var _a;
|
|
86207
|
+
if ("number" != typeof idx) return;
|
|
86208
|
+
const rowIndex = idx + (null != headerCount ? headerCount : 0),
|
|
86209
|
+
height = null === (_a = this.prevResizedRowHeightsSnapshot) || void 0 === _a ? void 0 : _a[rowIndex];
|
|
86210
|
+
"number" == typeof height && (deletedRowHeights || (deletedRowHeights = {}), deletedRowHeights[idx] = height);
|
|
86211
|
+
});
|
|
86212
|
+
}
|
|
86213
|
+
const oldCustomMergeCell = this.cloneMergeConfig(this.prevMergeSnapshot),
|
|
86214
|
+
newCustomMergeCell = this.cloneMergeConfig(null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.customMergeCell),
|
|
86215
|
+
cmd = {
|
|
86216
|
+
type: "delete_record",
|
|
86217
|
+
sheetKey: sheetKey,
|
|
86218
|
+
records: Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [],
|
|
86219
|
+
recordIndexs: recordIndexs,
|
|
86220
|
+
deletedRowHeights: deletedRowHeights,
|
|
86221
|
+
oldCustomMergeCell: oldCustomMergeCell,
|
|
86222
|
+
newCustomMergeCell: newCustomMergeCell
|
|
86223
|
+
};
|
|
86224
|
+
this.pushCommand(cmd);
|
|
86225
|
+
}
|
|
86226
|
+
handleUpdateRecord(eventArgs) {
|
|
86227
|
+
if (!this.table) return;
|
|
86228
|
+
const sheetKey = this.getSheetKey(),
|
|
86229
|
+
recordIndexs = eventArgs.recordIndexs || [],
|
|
86230
|
+
newRecords = Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [];
|
|
86231
|
+
if (!this.prevRecordsSnapshot || !Array.isArray(this.prevRecordsSnapshot) || !recordIndexs.length) return;
|
|
86232
|
+
const oldRecords = [];
|
|
86233
|
+
recordIndexs.forEach(idx => {
|
|
86234
|
+
if ("number" == typeof idx) {
|
|
86235
|
+
const rec = this.prevRecordsSnapshot[idx];
|
|
86236
|
+
oldRecords.push(void 0 !== rec ? cloneRecord(rec) : void 0);
|
|
86237
|
+
} else oldRecords.push(void 0);
|
|
86238
|
+
});
|
|
86239
|
+
const cmd = {
|
|
86240
|
+
type: "update_record",
|
|
86241
|
+
sheetKey: sheetKey,
|
|
86242
|
+
oldRecords: oldRecords,
|
|
86243
|
+
newRecords: newRecords,
|
|
86244
|
+
recordIndexs: recordIndexs
|
|
86245
|
+
};
|
|
86246
|
+
this.pushCommand(cmd);
|
|
86247
|
+
}
|
|
86248
|
+
handleAddColumn(eventArgs) {
|
|
86249
|
+
if (!this.table) return;
|
|
86250
|
+
const sheetKey = this.getSheetKey(),
|
|
86251
|
+
{
|
|
86252
|
+
columnIndex: columnIndex,
|
|
86253
|
+
columnCount: columnCount,
|
|
86254
|
+
columns: columns
|
|
86255
|
+
} = eventArgs,
|
|
86256
|
+
cmd = {
|
|
86257
|
+
type: "add_column",
|
|
86258
|
+
sheetKey: sheetKey,
|
|
86259
|
+
columnIndex: columnIndex,
|
|
86260
|
+
columnCount: columnCount,
|
|
86261
|
+
columns: columns.slice(columnIndex, columnIndex + columnCount).map(c => cloneDeep(c))
|
|
86262
|
+
};
|
|
86263
|
+
this.pushCommand(cmd);
|
|
86264
|
+
}
|
|
86265
|
+
handleDeleteColumn(eventArgs) {
|
|
86266
|
+
if (!this.table) return;
|
|
86267
|
+
const sheetKey = this.getSheetKey(),
|
|
86268
|
+
deleteColIndexs = (eventArgs.deleteColIndexs || []).slice(),
|
|
86269
|
+
deletedColumnsFromEvent = eventArgs.deletedColumns,
|
|
86270
|
+
prevColumns = this.prevColumnsSnapshot || [],
|
|
86271
|
+
deletedColumns = Array.isArray(deletedColumnsFromEvent) ? deletedColumnsFromEvent.map(c => cloneDeep(c)) : [];
|
|
86272
|
+
deletedColumns.length || deleteColIndexs.forEach(idx => {
|
|
86273
|
+
idx >= 0 && idx < prevColumns.length && deletedColumns.push(cloneDeep(prevColumns[idx]));
|
|
86274
|
+
});
|
|
86275
|
+
let deletedFormulas,
|
|
86276
|
+
deletedColWidths,
|
|
86277
|
+
deletedRecordValues = eventArgs.deletedRecordValues;
|
|
86278
|
+
if (Array.isArray(deletedRecordValues) && deletedRecordValues.length || (deletedRecordValues = void 0, Array.isArray(this.prevRecordsSnapshot) && this.prevRecordsSnapshot.length && (deletedRecordValues = this.prevRecordsSnapshot.map(rec => Array.isArray(rec) ? deleteColIndexs.map(idx => rec[idx]) : []), deletedRecordValues.every(v => 0 === v.length) && (deletedRecordValues = void 0))), this.prevFormulasSnapshot && deleteColIndexs.length) {
|
|
86279
|
+
Object.entries(this.prevFormulasSnapshot).forEach(([cellRef, formula]) => {
|
|
86280
|
+
const parsed = parseA1Notation(cellRef);
|
|
86281
|
+
parsed && deleteColIndexs.includes(parsed.col) && (deletedFormulas || (deletedFormulas = {}), deletedFormulas[cellRef] = formula);
|
|
86282
|
+
});
|
|
86283
|
+
}
|
|
86284
|
+
this.prevResizedColWidthsSnapshot && deleteColIndexs.length && deleteColIndexs.forEach(idx => {
|
|
86285
|
+
var _a;
|
|
86286
|
+
const w = null === (_a = this.prevResizedColWidthsSnapshot) || void 0 === _a ? void 0 : _a[idx];
|
|
86287
|
+
"number" == typeof w && (deletedColWidths || (deletedColWidths = {}), deletedColWidths[idx] = w);
|
|
86288
|
+
});
|
|
86289
|
+
const cmd = {
|
|
86290
|
+
type: "delete_column",
|
|
86291
|
+
sheetKey: sheetKey,
|
|
86292
|
+
deleteColIndexs: deleteColIndexs,
|
|
86293
|
+
columns: deletedColumns,
|
|
86294
|
+
deletedRecordValues: deletedRecordValues,
|
|
86295
|
+
deletedFormulas: deletedFormulas,
|
|
86296
|
+
deletedColWidths: deletedColWidths
|
|
86297
|
+
};
|
|
86298
|
+
this.pushCommand(cmd);
|
|
86299
|
+
}
|
|
86300
|
+
handleChangeHeaderPosition(eventArgs) {
|
|
86301
|
+
var _a;
|
|
86302
|
+
const sheetKey = this.getSheetKey(),
|
|
86303
|
+
moving = null !== (_a = eventArgs.movingColumnOrRow) && void 0 !== _a ? _a : "column",
|
|
86304
|
+
cmd = {
|
|
86305
|
+
type: "change_header_position",
|
|
86306
|
+
sheetKey: sheetKey,
|
|
86307
|
+
moving: moving,
|
|
86308
|
+
sourceIndex: "column" === moving ? eventArgs.source.col : eventArgs.source.row,
|
|
86309
|
+
targetIndex: "column" === moving ? eventArgs.target.col : eventArgs.target.row
|
|
86310
|
+
};
|
|
86311
|
+
this.pushCommand(cmd);
|
|
86312
|
+
}
|
|
86313
|
+
normalizeSortState(input) {
|
|
86314
|
+
if (!input) return null;
|
|
86315
|
+
if (Array.isArray(input)) {
|
|
86316
|
+
const list = input.filter(Boolean).map(s => ({
|
|
86317
|
+
field: s.field,
|
|
86318
|
+
order: s.order
|
|
86319
|
+
})).filter(s => void 0 !== s.field && s.order && "normal" !== s.order);
|
|
86320
|
+
return list.length ? list : null;
|
|
86321
|
+
}
|
|
86322
|
+
const s = input;
|
|
86323
|
+
return void 0 !== s.field && s.order && "normal" !== s.order ? {
|
|
86324
|
+
field: s.field,
|
|
86325
|
+
order: s.order
|
|
86326
|
+
} : null;
|
|
86327
|
+
}
|
|
86328
|
+
handleSortClick(_eventArgs) {
|
|
86329
|
+
this.table && (this.sortStartSnapshot = this.lastKnownSortState, this.sortPending = !0, setTimeout(() => {
|
|
86330
|
+
this.sortPending && (this.sortPending = !1, this.sortStartSnapshot = null);
|
|
86331
|
+
}, 0));
|
|
86332
|
+
}
|
|
86333
|
+
handleResizeRow(eventArgs) {
|
|
86334
|
+
var _a, _b;
|
|
86335
|
+
if (!this.table) return;
|
|
86336
|
+
const row = eventArgs.row;
|
|
86337
|
+
if (!this.resizeRowStartHeight.has(row)) {
|
|
86338
|
+
const oldHeight = null === (_b = (_a = this.table).getRowHeight) || void 0 === _b ? void 0 : _b.call(_a, row);
|
|
86339
|
+
"number" == typeof oldHeight && this.resizeRowStartHeight.set(row, oldHeight);
|
|
86340
|
+
}
|
|
86341
|
+
}
|
|
86342
|
+
handleResizeRowEnd(eventArgs) {
|
|
86343
|
+
var _a;
|
|
86344
|
+
if (!this.table) return;
|
|
86345
|
+
const sheetKey = this.getSheetKey(),
|
|
86346
|
+
row = eventArgs.row,
|
|
86347
|
+
newHeight = eventArgs.rowHeight,
|
|
86348
|
+
oldHeight = null !== (_a = this.resizeRowStartHeight.get(row)) && void 0 !== _a ? _a : newHeight;
|
|
86349
|
+
if (this.resizeRowStartHeight.delete(row), "number" == typeof oldHeight && "number" == typeof newHeight && oldHeight === newHeight) return;
|
|
86350
|
+
const cmd = {
|
|
86351
|
+
type: "resize_row",
|
|
86352
|
+
sheetKey: sheetKey,
|
|
86353
|
+
row: row,
|
|
86354
|
+
oldHeight: oldHeight,
|
|
86355
|
+
newHeight: newHeight
|
|
86356
|
+
};
|
|
86357
|
+
this.pushCommand(cmd);
|
|
86358
|
+
}
|
|
86359
|
+
handleResizeColumn(eventArgs) {
|
|
86360
|
+
var _a, _b;
|
|
86361
|
+
if (!this.table) return;
|
|
86362
|
+
const col = eventArgs.col;
|
|
86363
|
+
if (!this.resizeColStartWidth.has(col)) {
|
|
86364
|
+
const oldWidth = null === (_b = (_a = this.table).getColWidth) || void 0 === _b ? void 0 : _b.call(_a, col);
|
|
86365
|
+
"number" == typeof oldWidth && this.resizeColStartWidth.set(col, oldWidth);
|
|
86366
|
+
}
|
|
86367
|
+
}
|
|
86368
|
+
handleResizeColumnEnd(eventArgs) {
|
|
86369
|
+
var _a, _b, _c, _d;
|
|
86370
|
+
if (!this.table) return;
|
|
86371
|
+
const sheetKey = this.getSheetKey(),
|
|
86372
|
+
col = eventArgs.col,
|
|
86373
|
+
newWidth = null !== (_a = (eventArgs.colWidths || [])[col]) && void 0 !== _a ? _a : null === (_c = (_b = this.table).getColWidth) || void 0 === _c ? void 0 : _c.call(_b, col),
|
|
86374
|
+
oldWidth = null !== (_d = this.resizeColStartWidth.get(col)) && void 0 !== _d ? _d : newWidth;
|
|
86375
|
+
if (this.resizeColStartWidth.delete(col), "number" == typeof oldWidth && "number" == typeof newWidth && oldWidth === newWidth) return;
|
|
86376
|
+
const cmd = {
|
|
86377
|
+
type: "resize_column",
|
|
86378
|
+
sheetKey: sheetKey,
|
|
86379
|
+
col: col,
|
|
86380
|
+
oldWidth: oldWidth,
|
|
86381
|
+
newWidth: newWidth
|
|
86382
|
+
};
|
|
86383
|
+
this.pushCommand(cmd);
|
|
86384
|
+
}
|
|
86385
|
+
applyCommand(cmd, direction) {
|
|
86386
|
+
this.table && replayCommand({
|
|
86387
|
+
table: this.table,
|
|
86388
|
+
vtableSheet: this.vtableSheet,
|
|
86389
|
+
cmd: cmd,
|
|
86390
|
+
direction: direction,
|
|
86391
|
+
deleteRecordsByReference: records => this.deleteRecordsByReference(records)
|
|
86392
|
+
});
|
|
86393
|
+
}
|
|
86394
|
+
deleteRecordsByReference(records) {
|
|
86395
|
+
if (!this.table || !(null == records ? void 0 : records.length)) return;
|
|
86396
|
+
const tableRecords = this.table.records || [],
|
|
86397
|
+
indexs = [];
|
|
86398
|
+
records.forEach(rec => {
|
|
86399
|
+
const idx = tableRecords.indexOf(rec);
|
|
86400
|
+
idx >= 0 && indexs.push(idx);
|
|
86401
|
+
}), indexs.length && this.table.deleteRecords && this.table.deleteRecords(indexs);
|
|
86402
|
+
}
|
|
86403
|
+
}
|
|
86404
|
+
|
|
84767
86405
|
class FormulaAutocomplete {
|
|
84768
86406
|
container;
|
|
84769
86407
|
dropdown = null;
|
|
@@ -85263,12 +86901,41 @@
|
|
|
85263
86901
|
if (!this.element || !this.sheet) {
|
|
85264
86902
|
return;
|
|
85265
86903
|
}
|
|
85266
|
-
|
|
85267
|
-
|
|
85268
|
-
const
|
|
85269
|
-
|
|
85270
|
-
|
|
86904
|
+
const value = this.element.value;
|
|
86905
|
+
const selectionStart = this.element.selectionStart ?? value.length;
|
|
86906
|
+
const selectionEnd = this.element.selectionEnd ?? selectionStart;
|
|
86907
|
+
let replaceStart = selectionStart;
|
|
86908
|
+
let replaceEnd = selectionEnd;
|
|
86909
|
+
if (selectionStart === selectionEnd) {
|
|
86910
|
+
replaceStart = selectionStart;
|
|
86911
|
+
while (replaceStart > 1 && /[A-Za-z0-9]/.test(value[replaceStart - 1])) {
|
|
86912
|
+
replaceStart--;
|
|
86913
|
+
}
|
|
86914
|
+
const hasLeftWord = replaceStart < selectionStart;
|
|
86915
|
+
replaceEnd = selectionStart;
|
|
86916
|
+
if (hasLeftWord) {
|
|
86917
|
+
while (replaceEnd < value.length && /[A-Za-z0-9]/.test(value[replaceEnd])) {
|
|
86918
|
+
replaceEnd++;
|
|
86919
|
+
}
|
|
86920
|
+
}
|
|
85271
86921
|
}
|
|
86922
|
+
const isFunction = item?.type === 'function';
|
|
86923
|
+
const itemValue = String(item?.value ?? '');
|
|
86924
|
+
const nextChar = value[replaceEnd];
|
|
86925
|
+
const shouldAppendParen = isFunction && nextChar !== '(';
|
|
86926
|
+
const insertText = itemValue + (shouldAppendParen ? '(' : '');
|
|
86927
|
+
const newValue = value.slice(0, replaceStart) + insertText + value.slice(replaceEnd);
|
|
86928
|
+
this.element.value = newValue;
|
|
86929
|
+
let newCursorPos = replaceStart + itemValue.length;
|
|
86930
|
+
if (isFunction && newValue[newCursorPos] === '(') {
|
|
86931
|
+
newCursorPos += 1;
|
|
86932
|
+
}
|
|
86933
|
+
this.element.setSelectionRange(newCursorPos, newCursorPos);
|
|
86934
|
+
if (this.sheet.formulaUIManager.formulaInput) {
|
|
86935
|
+
this.sheet.formulaUIManager.formulaInput.value = newValue;
|
|
86936
|
+
}
|
|
86937
|
+
const inputEvent = new Event('input', { bubbles: true });
|
|
86938
|
+
this.element.dispatchEvent(inputEvent);
|
|
85272
86939
|
}
|
|
85273
86940
|
onStart(context) {
|
|
85274
86941
|
const formula = this.sheet.formulaManager.getCellFormula({
|
|
@@ -85360,7 +87027,9 @@
|
|
|
85360
87027
|
return `${startCol}${startRow}:${endCol}${endRow}`;
|
|
85361
87028
|
}
|
|
85362
87029
|
}
|
|
85363
|
-
|
|
87030
|
+
function createFormulaEditor() {
|
|
87031
|
+
return new FormulaInputEditor();
|
|
87032
|
+
}
|
|
85364
87033
|
|
|
85365
87034
|
class FormulaUIManager {
|
|
85366
87035
|
sheet;
|
|
@@ -87514,7 +89183,7 @@
|
|
|
87514
89183
|
}
|
|
87515
89184
|
return this.addSheet(sheetKey);
|
|
87516
89185
|
}
|
|
87517
|
-
setCellContent(cell, value) {
|
|
89186
|
+
setCellContent(cell, value, options) {
|
|
87518
89187
|
this.ensureInitialized();
|
|
87519
89188
|
if (!cell || cell.sheet === undefined || cell.row === undefined || cell.col === undefined) {
|
|
87520
89189
|
throw new Error('Invalid cell parameter for setCellContent');
|
|
@@ -87532,16 +89201,18 @@
|
|
|
87532
89201
|
else {
|
|
87533
89202
|
this.formulaEngine.setCellContent(cell, value);
|
|
87534
89203
|
}
|
|
87535
|
-
|
|
87536
|
-
|
|
87537
|
-
|
|
87538
|
-
|
|
87539
|
-
|
|
87540
|
-
|
|
89204
|
+
if (options?.emitEvent !== false) {
|
|
89205
|
+
const newFormula = this.getCellFormula(cell);
|
|
89206
|
+
if (newFormula && newFormula !== oldFormula) {
|
|
89207
|
+
this.emitFormulaEvent(cell, 'added', newFormula);
|
|
89208
|
+
}
|
|
89209
|
+
else if (!newFormula && oldFormula) {
|
|
89210
|
+
this.emitFormulaEvent(cell, 'removed', oldFormula);
|
|
89211
|
+
}
|
|
87541
89212
|
}
|
|
87542
89213
|
}
|
|
87543
89214
|
catch (error) {
|
|
87544
|
-
if (typeof value === 'string' && value.startsWith('=')) {
|
|
89215
|
+
if (options?.emitEvent !== false && typeof value === 'string' && value.startsWith('=')) {
|
|
87545
89216
|
this.emitFormulaEvent(cell, 'error', value, error);
|
|
87546
89217
|
}
|
|
87547
89218
|
if (error instanceof Error) {
|
|
@@ -88791,6 +90462,7 @@
|
|
|
88791
90462
|
maintainArrayDataOrder: true
|
|
88792
90463
|
},
|
|
88793
90464
|
addRecordRule: 'Array',
|
|
90465
|
+
syncRecordOperationsToSourceRecords: true,
|
|
88794
90466
|
defaultCursor: 'cell',
|
|
88795
90467
|
records: this.options.data,
|
|
88796
90468
|
sortState: this.options.sortState,
|
|
@@ -88946,54 +90618,6 @@
|
|
|
88946
90618
|
if (rowIndexs && rowIndexs.length > 0) {
|
|
88947
90619
|
const minIndex = Math.min(...rowIndexs.flat());
|
|
88948
90620
|
this.vtableSheet.formulaManager.removeRows(sheetKey, minIndex, deletedCount);
|
|
88949
|
-
if (Array.isArray(this.tableInstance.options.customMergeCell)) {
|
|
88950
|
-
const mergeCellsToRemove = [];
|
|
88951
|
-
const deleteEndIndex = minIndex + deletedCount - 1;
|
|
88952
|
-
const customMergeCellArray = this.tableInstance.options.customMergeCell;
|
|
88953
|
-
const cloneMergeCellArray = customMergeCellArray.map(mergeCell => ({
|
|
88954
|
-
...mergeCell,
|
|
88955
|
-
range: {
|
|
88956
|
-
start: { ...mergeCell.range.start },
|
|
88957
|
-
end: { ...mergeCell.range.end }
|
|
88958
|
-
}
|
|
88959
|
-
}));
|
|
88960
|
-
customMergeCellArray.forEach((mergeCell, index) => {
|
|
88961
|
-
const startRow = mergeCell.range.start.row;
|
|
88962
|
-
const endRow = mergeCell.range.end.row;
|
|
88963
|
-
if (startRow >= minIndex && endRow <= deleteEndIndex) {
|
|
88964
|
-
mergeCellsToRemove.push(index);
|
|
88965
|
-
return;
|
|
88966
|
-
}
|
|
88967
|
-
if (startRow <= deleteEndIndex && endRow >= minIndex) {
|
|
88968
|
-
if (startRow >= minIndex) {
|
|
88969
|
-
mergeCell.range.start.row = minIndex;
|
|
88970
|
-
}
|
|
88971
|
-
if (endRow <= deleteEndIndex) {
|
|
88972
|
-
mergeCell.range.end.row = minIndex - 1;
|
|
88973
|
-
}
|
|
88974
|
-
else {
|
|
88975
|
-
mergeCell.range.end.row -= deletedCount;
|
|
88976
|
-
}
|
|
88977
|
-
if (mergeCell.range.start.row > mergeCell.range.end.row) {
|
|
88978
|
-
mergeCellsToRemove.push(index);
|
|
88979
|
-
}
|
|
88980
|
-
}
|
|
88981
|
-
else if (startRow > deleteEndIndex) {
|
|
88982
|
-
mergeCell.range.start.row -= deletedCount;
|
|
88983
|
-
mergeCell.range.end.row -= deletedCount;
|
|
88984
|
-
}
|
|
88985
|
-
});
|
|
88986
|
-
mergeCellsToRemove
|
|
88987
|
-
.sort((a, b) => b - a)
|
|
88988
|
-
.forEach(index => {
|
|
88989
|
-
customMergeCellArray.splice(index, 1);
|
|
88990
|
-
});
|
|
88991
|
-
const updateRanges = cloneMergeCellArray.map(mergeCell => ({
|
|
88992
|
-
start: { ...mergeCell.range.start },
|
|
88993
|
-
end: { ...mergeCell.range.end }
|
|
88994
|
-
}));
|
|
88995
|
-
this.tableInstance.updateCellContentRange(updateRanges);
|
|
88996
|
-
}
|
|
88997
90621
|
}
|
|
88998
90622
|
}
|
|
88999
90623
|
}
|
|
@@ -89021,54 +90645,6 @@
|
|
|
89021
90645
|
const minIndex = Math.min(...deleteColIndexs.flat());
|
|
89022
90646
|
const deletedCount = deleteColIndexs.length;
|
|
89023
90647
|
this.vtableSheet.formulaManager.removeColumns(sheetKey, minIndex, deletedCount);
|
|
89024
|
-
if (Array.isArray(this.tableInstance.options.customMergeCell)) {
|
|
89025
|
-
const mergeCellsToRemove = [];
|
|
89026
|
-
const deleteEndIndex = minIndex + deletedCount - 1;
|
|
89027
|
-
const customMergeCellArray = this.tableInstance.options.customMergeCell;
|
|
89028
|
-
const cloneMergeCellArray = customMergeCellArray.map(mergeCell => ({
|
|
89029
|
-
...mergeCell,
|
|
89030
|
-
range: {
|
|
89031
|
-
start: { ...mergeCell.range.start },
|
|
89032
|
-
end: { ...mergeCell.range.end }
|
|
89033
|
-
}
|
|
89034
|
-
}));
|
|
89035
|
-
customMergeCellArray.forEach((mergeCell, index) => {
|
|
89036
|
-
const startCol = mergeCell.range.start.col;
|
|
89037
|
-
const endCol = mergeCell.range.end.col;
|
|
89038
|
-
if (startCol >= minIndex && endCol <= deleteEndIndex) {
|
|
89039
|
-
mergeCellsToRemove.push(index);
|
|
89040
|
-
return;
|
|
89041
|
-
}
|
|
89042
|
-
if (startCol <= deleteEndIndex && endCol >= minIndex) {
|
|
89043
|
-
if (startCol >= minIndex) {
|
|
89044
|
-
mergeCell.range.start.col = minIndex;
|
|
89045
|
-
}
|
|
89046
|
-
if (endCol <= deleteEndIndex) {
|
|
89047
|
-
mergeCell.range.end.col = minIndex - 1;
|
|
89048
|
-
}
|
|
89049
|
-
else {
|
|
89050
|
-
mergeCell.range.end.col -= deletedCount;
|
|
89051
|
-
}
|
|
89052
|
-
if (mergeCell.range.start.col > mergeCell.range.end.col) {
|
|
89053
|
-
mergeCellsToRemove.push(index);
|
|
89054
|
-
}
|
|
89055
|
-
}
|
|
89056
|
-
else if (startCol > deleteEndIndex) {
|
|
89057
|
-
mergeCell.range.start.col -= deletedCount;
|
|
89058
|
-
mergeCell.range.end.col -= deletedCount;
|
|
89059
|
-
}
|
|
89060
|
-
});
|
|
89061
|
-
mergeCellsToRemove
|
|
89062
|
-
.sort((a, b) => b - a)
|
|
89063
|
-
.forEach(index => {
|
|
89064
|
-
customMergeCellArray.splice(index, 1);
|
|
89065
|
-
});
|
|
89066
|
-
const updateRanges = cloneMergeCellArray.map(mergeCell => ({
|
|
89067
|
-
start: { ...mergeCell.range.start },
|
|
89068
|
-
end: { ...mergeCell.range.end }
|
|
89069
|
-
}));
|
|
89070
|
-
this.tableInstance.updateCellContentRange(updateRanges);
|
|
89071
|
-
}
|
|
89072
90648
|
}
|
|
89073
90649
|
}
|
|
89074
90650
|
}
|
|
@@ -89411,6 +90987,20 @@
|
|
|
89411
90987
|
const plugins = [];
|
|
89412
90988
|
const disabledPluginsUserSetted = options?.VTablePluginModules?.filter(module => module.disabled);
|
|
89413
90989
|
let enabledPluginsUserSetted = options?.VTablePluginModules?.filter(module => !module.disabled);
|
|
90990
|
+
if (vtableSheet?.getWorkbookHistoryManager &&
|
|
90991
|
+
!disabledPluginsUserSetted?.some(module => module.module === HistoryPlugin) &&
|
|
90992
|
+
!enabledPluginsUserSetted?.some(module => module.module === HistoryPlugin)) {
|
|
90993
|
+
const workbookHistory = vtableSheet.getWorkbookHistoryManager();
|
|
90994
|
+
if (typeof HistoryPlugin !== 'function') ;
|
|
90995
|
+
else {
|
|
90996
|
+
plugins.push(new HistoryPlugin({
|
|
90997
|
+
enableCompression: false,
|
|
90998
|
+
onTransactionPushed: (args) => {
|
|
90999
|
+
workbookHistory.recordTableTransaction({ sheetKey: args?.sheetKey, tx: args?.tx });
|
|
91000
|
+
}
|
|
91001
|
+
}));
|
|
91002
|
+
}
|
|
91003
|
+
}
|
|
89414
91004
|
if (!disabledPluginsUserSetted?.some(module => module.module === FilterPlugin)) {
|
|
89415
91005
|
const userPluginOptions = enabledPluginsUserSetted?.find(module => module.module === FilterPlugin)
|
|
89416
91006
|
?.moduleOptions;
|
|
@@ -89490,7 +91080,20 @@
|
|
|
89490
91080
|
if (enabledPluginsUserSetted?.length) {
|
|
89491
91081
|
enabledPluginsUserSetted.forEach((module) => {
|
|
89492
91082
|
if (typeof module?.module === 'function') {
|
|
89493
|
-
|
|
91083
|
+
let moduleOptions = module.moduleOptions;
|
|
91084
|
+
if (module.module === HistoryPlugin && vtableSheet?.getWorkbookHistoryManager) {
|
|
91085
|
+
const workbookHistory = vtableSheet.getWorkbookHistoryManager();
|
|
91086
|
+
const prev = moduleOptions?.onTransactionPushed;
|
|
91087
|
+
moduleOptions = {
|
|
91088
|
+
...(moduleOptions ?? {}),
|
|
91089
|
+
enableCompression: moduleOptions?.enableCompression ?? false,
|
|
91090
|
+
onTransactionPushed: (args) => {
|
|
91091
|
+
prev?.(args);
|
|
91092
|
+
workbookHistory.recordTableTransaction({ sheetKey: args?.sheetKey, tx: args?.tx });
|
|
91093
|
+
}
|
|
91094
|
+
};
|
|
91095
|
+
}
|
|
91096
|
+
plugins.push(new module.module(moduleOptions));
|
|
89494
91097
|
}
|
|
89495
91098
|
});
|
|
89496
91099
|
}
|
|
@@ -89975,9 +91578,7 @@
|
|
|
89975
91578
|
}
|
|
89976
91579
|
performTabReorder(sourceKey, targetKey, position) {
|
|
89977
91580
|
try {
|
|
89978
|
-
this.sheet.
|
|
89979
|
-
this.sheet.updateSheetTabs();
|
|
89980
|
-
this.sheet.updateSheetMenu();
|
|
91581
|
+
this.sheet.reorderSheet(sourceKey, targetKey, position);
|
|
89981
91582
|
}
|
|
89982
91583
|
catch (error) {
|
|
89983
91584
|
}
|
|
@@ -89996,10 +91597,18 @@
|
|
|
89996
91597
|
class MenuManager {
|
|
89997
91598
|
sheet;
|
|
89998
91599
|
menuContainer;
|
|
91600
|
+
undoButton = null;
|
|
91601
|
+
redoButton = null;
|
|
89999
91602
|
clickOutsideHandler;
|
|
91603
|
+
historyUnsubscribe = null;
|
|
90000
91604
|
constructor(sheet) {
|
|
90001
91605
|
this.sheet = sheet;
|
|
90002
|
-
|
|
91606
|
+
}
|
|
91607
|
+
createUndoRedoOnly() {
|
|
91608
|
+
const wrap = document.createElement('div');
|
|
91609
|
+
wrap.className = 'vtable-sheet-undo-redo';
|
|
91610
|
+
this.mountUndoRedoActions(wrap);
|
|
91611
|
+
return wrap;
|
|
90003
91612
|
}
|
|
90004
91613
|
createMainMenu() {
|
|
90005
91614
|
const menuIcon = `<svg t="1754379519717" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1496" width="24" height="24"><path d="M510.435876 67.959811c-245.428735 0-444.382996 198.954261-444.382996 444.373787 0 245.420549 198.954261 444.373787 444.382996 444.373787 245.410316 0 444.372763-198.953238 444.372763-444.373787C954.807616 266.914072 755.846192 67.959811 510.435876 67.959811zM510.435876 901.156184c-214.743876 0-388.831796-174.08792-388.831796-388.822586 0-214.743876 174.088944-388.831796 388.831796-388.831796 214.732619 0 388.822586 174.08792 388.822586 388.831796C899.257439 727.068264 725.167472 901.156184 510.435876 901.156184zM666.028561 329.355193 337.411171 329.355193c-15.117302 0-27.384697 15.60235-27.384697 34.844599 0 19.259646 12.267395 34.861996 27.384697 34.861996l328.618413 0c15.124466 0 27.375487-15.60235 27.375487-34.861996C693.404048 344.957543 681.15405 329.355193 666.028561 329.355193zM666.028561 486.191194 337.411171 486.191194c-15.117302 0-27.384697 15.601326-27.384697 34.852786 0 19.25146 12.267395 34.853809 27.384697 34.853809l328.618413 0c15.124466 0 27.375487-15.601326 27.375487-34.853809C693.404048 501.792521 681.15405 486.191194 666.028561 486.191194zM666.028561 625.604384 337.411171 625.604384c-15.117302 0-27.384697 15.60235-27.384697 34.845623 0 19.25146 12.267395 34.861996 27.384697 34.861996l328.618413 0c15.124466 0 27.375487-15.611559 27.375487-34.861996C693.404048 641.206734 681.15405 625.604384 666.028561 625.604384z" fill="#8a8a8a" p-id="1497"></path></svg>`;
|
|
@@ -90010,6 +91619,7 @@
|
|
|
90010
91619
|
menuButton.className = 'vtable-sheet-main-menu-button';
|
|
90011
91620
|
menuButton.innerHTML = menuIcon;
|
|
90012
91621
|
menu.appendChild(menuButton);
|
|
91622
|
+
this.mountUndoRedoActions(menu);
|
|
90013
91623
|
const menuContainer = document.createElement('div');
|
|
90014
91624
|
menuContainer.className = 'vtable-sheet-main-menu-container';
|
|
90015
91625
|
menu.appendChild(menuContainer);
|
|
@@ -90058,6 +91668,55 @@
|
|
|
90058
91668
|
this.menuContainer = menuContainer;
|
|
90059
91669
|
return menu;
|
|
90060
91670
|
}
|
|
91671
|
+
mountUndoRedoActions(container) {
|
|
91672
|
+
const showUndoRedo = this.sheet.getOptions().undoRedo?.show ?? true;
|
|
91673
|
+
if (!showUndoRedo) {
|
|
91674
|
+
this.undoButton = null;
|
|
91675
|
+
this.redoButton = null;
|
|
91676
|
+
this.historyUnsubscribe?.();
|
|
91677
|
+
this.historyUnsubscribe = null;
|
|
91678
|
+
return;
|
|
91679
|
+
}
|
|
91680
|
+
const undoIcon = `<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-icon="UndoOutlined"><path d="M8.707 2.293a1 1 0 0 1 0 1.414L5.414 7H14.5a7.5 7.5 0 0 1 0 15H11a1 1 0 1 1 0-2h3.5a5.5 5.5 0 1 0 0-11H5.414l3.293 3.293a1 1 0 1 1-1.414 1.414l-5-5a1 1 0 0 1 0-1.414l5-5a1 1 0 0 1 1.414 0Z" fill="currentColor"></path></svg>`;
|
|
91681
|
+
const redoIcon = `<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-icon="RedoOutlined"><path d="M15.293 2.293a1 1 0 0 0 0 1.414L18.586 7H9.5a7.5 7.5 0 0 0 0 15H13a1 1 0 1 0 0-2H9.5a5.5 5.5 0 1 1 0-11h9.086l-3.293 3.293a1 1 0 0 0 1.414 1.414l5-5a1 1 0 0 0 0-1.414l-5-5a1 1 0 0 0-1.414 0Z" fill="currentColor"></path></svg>`;
|
|
91682
|
+
const actions = document.createElement('div');
|
|
91683
|
+
actions.className = 'vtable-sheet-main-menu-actions';
|
|
91684
|
+
container.appendChild(actions);
|
|
91685
|
+
this.undoButton = document.createElement('button');
|
|
91686
|
+
this.undoButton.className = 'vtable-sheet-main-menu-action';
|
|
91687
|
+
this.undoButton.type = 'button';
|
|
91688
|
+
this.undoButton.title = '撤销';
|
|
91689
|
+
this.undoButton.innerHTML = undoIcon;
|
|
91690
|
+
this.undoButton.addEventListener('click', e => {
|
|
91691
|
+
e.stopPropagation();
|
|
91692
|
+
this.sheet.undo();
|
|
91693
|
+
});
|
|
91694
|
+
actions.appendChild(this.undoButton);
|
|
91695
|
+
this.redoButton = document.createElement('button');
|
|
91696
|
+
this.redoButton.className = 'vtable-sheet-main-menu-action';
|
|
91697
|
+
this.redoButton.type = 'button';
|
|
91698
|
+
this.redoButton.title = '重做';
|
|
91699
|
+
this.redoButton.innerHTML = redoIcon;
|
|
91700
|
+
this.redoButton.addEventListener('click', e => {
|
|
91701
|
+
e.stopPropagation();
|
|
91702
|
+
this.sheet.redo();
|
|
91703
|
+
});
|
|
91704
|
+
actions.appendChild(this.redoButton);
|
|
91705
|
+
this.historyUnsubscribe?.();
|
|
91706
|
+
this.historyUnsubscribe = this.sheet.getWorkbookHistoryManager().onChange(() => {
|
|
91707
|
+
this.updateUndoRedoState();
|
|
91708
|
+
});
|
|
91709
|
+
this.updateUndoRedoState();
|
|
91710
|
+
}
|
|
91711
|
+
updateUndoRedoState() {
|
|
91712
|
+
const history = this.sheet.getWorkbookHistoryManager();
|
|
91713
|
+
if (this.undoButton) {
|
|
91714
|
+
this.undoButton.disabled = !history.canUndo();
|
|
91715
|
+
}
|
|
91716
|
+
if (this.redoButton) {
|
|
91717
|
+
this.redoButton.disabled = !history.canRedo();
|
|
91718
|
+
}
|
|
91719
|
+
}
|
|
90061
91720
|
createSubMenu(items) {
|
|
90062
91721
|
const subMenuContainer = document.createElement('div');
|
|
90063
91722
|
subMenuContainer.className = 'vtable-sheet-submenu-container';
|
|
@@ -90176,10 +91835,12 @@
|
|
|
90176
91835
|
document.removeEventListener('click', this.clickOutsideHandler);
|
|
90177
91836
|
this.clickOutsideHandler = null;
|
|
90178
91837
|
}
|
|
91838
|
+
this.historyUnsubscribe?.();
|
|
91839
|
+
this.historyUnsubscribe = null;
|
|
90179
91840
|
}
|
|
90180
91841
|
updateMainMenu(mainMenu) {
|
|
90181
91842
|
this.release();
|
|
90182
|
-
this.createMainMenu();
|
|
91843
|
+
return this.createMainMenu();
|
|
90183
91844
|
}
|
|
90184
91845
|
}
|
|
90185
91846
|
|
|
@@ -90246,11 +91907,7 @@
|
|
|
90246
91907
|
showSnackbar('工作表名称已存在,请重新输入', 1300);
|
|
90247
91908
|
return false;
|
|
90248
91909
|
}
|
|
90249
|
-
this.vTableSheet.
|
|
90250
|
-
this.vTableSheet.workSheetInstances.get(sheetKey)?.setTitle(newTitle);
|
|
90251
|
-
this.vTableSheet.getFormulaManager().updateSheetTitle(sheetKey, newTitle);
|
|
90252
|
-
this.vTableSheet.updateSheetTabs();
|
|
90253
|
-
this.vTableSheet.updateSheetMenu();
|
|
91910
|
+
this.vTableSheet.renameSheet(sheetKey, newTitle);
|
|
90254
91911
|
return true;
|
|
90255
91912
|
}
|
|
90256
91913
|
getSheetTabElementByKey(sheetKey) {
|
|
@@ -90800,7 +92457,430 @@
|
|
|
90800
92457
|
}
|
|
90801
92458
|
}
|
|
90802
92459
|
|
|
90803
|
-
|
|
92460
|
+
function cloneJson(input) {
|
|
92461
|
+
return JSON.parse(JSON.stringify(input));
|
|
92462
|
+
}
|
|
92463
|
+
function cloneSafe(input) {
|
|
92464
|
+
const sc = globalThis.structuredClone;
|
|
92465
|
+
if (typeof sc === 'function') {
|
|
92466
|
+
try {
|
|
92467
|
+
return sc(input);
|
|
92468
|
+
}
|
|
92469
|
+
catch { }
|
|
92470
|
+
}
|
|
92471
|
+
return cloneJson(input);
|
|
92472
|
+
}
|
|
92473
|
+
class WorkbookHistoryManager {
|
|
92474
|
+
sheet;
|
|
92475
|
+
undoStack = [];
|
|
92476
|
+
redoStack = [];
|
|
92477
|
+
currentTransaction = null;
|
|
92478
|
+
maxHistory;
|
|
92479
|
+
enabled = true;
|
|
92480
|
+
isReplaying = false;
|
|
92481
|
+
changeListeners = new Set();
|
|
92482
|
+
constructor(sheet, options) {
|
|
92483
|
+
this.sheet = sheet;
|
|
92484
|
+
this.maxHistory = options?.maxHistory ?? 100;
|
|
92485
|
+
}
|
|
92486
|
+
canUndo() {
|
|
92487
|
+
return this.undoStack.length > 0;
|
|
92488
|
+
}
|
|
92489
|
+
canRedo() {
|
|
92490
|
+
return this.redoStack.length > 0;
|
|
92491
|
+
}
|
|
92492
|
+
onChange(listener) {
|
|
92493
|
+
this.changeListeners.add(listener);
|
|
92494
|
+
return () => {
|
|
92495
|
+
this.changeListeners.delete(listener);
|
|
92496
|
+
};
|
|
92497
|
+
}
|
|
92498
|
+
emitChange() {
|
|
92499
|
+
this.changeListeners.forEach(fn => {
|
|
92500
|
+
try {
|
|
92501
|
+
fn();
|
|
92502
|
+
}
|
|
92503
|
+
catch { }
|
|
92504
|
+
});
|
|
92505
|
+
}
|
|
92506
|
+
suspend() {
|
|
92507
|
+
this.enabled = false;
|
|
92508
|
+
}
|
|
92509
|
+
resume() {
|
|
92510
|
+
this.enabled = true;
|
|
92511
|
+
}
|
|
92512
|
+
startTransaction() {
|
|
92513
|
+
if (this.currentTransaction) {
|
|
92514
|
+
return;
|
|
92515
|
+
}
|
|
92516
|
+
this.currentTransaction = { commands: [] };
|
|
92517
|
+
}
|
|
92518
|
+
endTransaction() {
|
|
92519
|
+
if (!this.currentTransaction || this.currentTransaction.commands.length === 0) {
|
|
92520
|
+
this.currentTransaction = null;
|
|
92521
|
+
return;
|
|
92522
|
+
}
|
|
92523
|
+
this.pushTransaction(this.currentTransaction);
|
|
92524
|
+
this.currentTransaction = null;
|
|
92525
|
+
}
|
|
92526
|
+
clear() {
|
|
92527
|
+
this.undoStack = [];
|
|
92528
|
+
this.redoStack = [];
|
|
92529
|
+
this.currentTransaction = null;
|
|
92530
|
+
this.emitChange();
|
|
92531
|
+
}
|
|
92532
|
+
updateOptions(options) {
|
|
92533
|
+
if (options.maxHistory != null) {
|
|
92534
|
+
this.maxHistory = options.maxHistory;
|
|
92535
|
+
this.trimHistory();
|
|
92536
|
+
this.emitChange();
|
|
92537
|
+
}
|
|
92538
|
+
}
|
|
92539
|
+
undo() {
|
|
92540
|
+
if (this.undoStack.length === 0) {
|
|
92541
|
+
return;
|
|
92542
|
+
}
|
|
92543
|
+
const tx = this.undoStack.pop();
|
|
92544
|
+
this.isReplaying = true;
|
|
92545
|
+
this.sheet.__workbookHistoryReplaying = true;
|
|
92546
|
+
try {
|
|
92547
|
+
for (let i = tx.commands.length - 1; i >= 0; i--) {
|
|
92548
|
+
this.applyCommand(tx.commands[i], 'undo');
|
|
92549
|
+
}
|
|
92550
|
+
}
|
|
92551
|
+
finally {
|
|
92552
|
+
this.isReplaying = false;
|
|
92553
|
+
this.sheet.__workbookHistoryReplaying = false;
|
|
92554
|
+
}
|
|
92555
|
+
this.redoStack.push(tx);
|
|
92556
|
+
this.emitChange();
|
|
92557
|
+
}
|
|
92558
|
+
redo() {
|
|
92559
|
+
if (this.redoStack.length === 0) {
|
|
92560
|
+
return;
|
|
92561
|
+
}
|
|
92562
|
+
const tx = this.redoStack.pop();
|
|
92563
|
+
this.isReplaying = true;
|
|
92564
|
+
this.sheet.__workbookHistoryReplaying = true;
|
|
92565
|
+
try {
|
|
92566
|
+
for (const cmd of tx.commands) {
|
|
92567
|
+
this.applyCommand(cmd, 'redo');
|
|
92568
|
+
}
|
|
92569
|
+
}
|
|
92570
|
+
finally {
|
|
92571
|
+
this.isReplaying = false;
|
|
92572
|
+
this.sheet.__workbookHistoryReplaying = false;
|
|
92573
|
+
}
|
|
92574
|
+
this.undoStack.push(tx);
|
|
92575
|
+
this.emitChange();
|
|
92576
|
+
}
|
|
92577
|
+
recordTableTransaction(args) {
|
|
92578
|
+
if (!this.enabled || this.isReplaying) {
|
|
92579
|
+
return;
|
|
92580
|
+
}
|
|
92581
|
+
const sheetKey = args.sheetKey ?? this.getActiveSheetKey();
|
|
92582
|
+
if (!sheetKey) {
|
|
92583
|
+
return;
|
|
92584
|
+
}
|
|
92585
|
+
const cmd = {
|
|
92586
|
+
type: 'table_tx',
|
|
92587
|
+
sheetKey,
|
|
92588
|
+
tx: cloneSafe(args.tx)
|
|
92589
|
+
};
|
|
92590
|
+
this.pushCommand(cmd);
|
|
92591
|
+
}
|
|
92592
|
+
addSheet(args) {
|
|
92593
|
+
if (!this.enabled || this.isReplaying) {
|
|
92594
|
+
this.addSheetInternal(args.sheet, args.activate);
|
|
92595
|
+
return;
|
|
92596
|
+
}
|
|
92597
|
+
const orderBefore = this.getSheetOrder();
|
|
92598
|
+
const activeBefore = this.getActiveSheetKey();
|
|
92599
|
+
this.startTransaction();
|
|
92600
|
+
try {
|
|
92601
|
+
this.addSheetInternal(args.sheet, args.activate);
|
|
92602
|
+
const orderAfter = this.getSheetOrder();
|
|
92603
|
+
const activeAfter = this.getActiveSheetKey();
|
|
92604
|
+
const cmd = {
|
|
92605
|
+
type: 'sheet_add',
|
|
92606
|
+
sheet: cloneSafe(args.sheet),
|
|
92607
|
+
orderBefore,
|
|
92608
|
+
orderAfter,
|
|
92609
|
+
activeBefore,
|
|
92610
|
+
activeAfter
|
|
92611
|
+
};
|
|
92612
|
+
this.pushCommand(cmd);
|
|
92613
|
+
}
|
|
92614
|
+
finally {
|
|
92615
|
+
this.endTransaction();
|
|
92616
|
+
}
|
|
92617
|
+
}
|
|
92618
|
+
removeSheet(sheetKey) {
|
|
92619
|
+
if (!this.enabled || this.isReplaying) {
|
|
92620
|
+
this.removeSheetInternal(sheetKey);
|
|
92621
|
+
return;
|
|
92622
|
+
}
|
|
92623
|
+
const sheetDefine = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92624
|
+
if (!sheetDefine) {
|
|
92625
|
+
return;
|
|
92626
|
+
}
|
|
92627
|
+
const orderBefore = this.getSheetOrder();
|
|
92628
|
+
const activeBefore = this.getActiveSheetKey();
|
|
92629
|
+
this.startTransaction();
|
|
92630
|
+
try {
|
|
92631
|
+
this.removeSheetInternal(sheetKey);
|
|
92632
|
+
const orderAfter = this.getSheetOrder();
|
|
92633
|
+
const activeAfter = this.getActiveSheetKey();
|
|
92634
|
+
const cmd = {
|
|
92635
|
+
type: 'sheet_remove',
|
|
92636
|
+
sheet: cloneSafe(sheetDefine),
|
|
92637
|
+
orderBefore,
|
|
92638
|
+
orderAfter,
|
|
92639
|
+
activeBefore,
|
|
92640
|
+
activeAfter
|
|
92641
|
+
};
|
|
92642
|
+
this.pushCommand(cmd);
|
|
92643
|
+
}
|
|
92644
|
+
finally {
|
|
92645
|
+
this.endTransaction();
|
|
92646
|
+
}
|
|
92647
|
+
}
|
|
92648
|
+
renameSheet(sheetKey, newTitle) {
|
|
92649
|
+
const sheetDefine = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92650
|
+
if (!sheetDefine) {
|
|
92651
|
+
return;
|
|
92652
|
+
}
|
|
92653
|
+
const oldTitle = sheetDefine.sheetTitle;
|
|
92654
|
+
if (!this.enabled || this.isReplaying) {
|
|
92655
|
+
this.renameSheetInternal(sheetKey, newTitle);
|
|
92656
|
+
return;
|
|
92657
|
+
}
|
|
92658
|
+
this.startTransaction();
|
|
92659
|
+
try {
|
|
92660
|
+
this.renameSheetInternal(sheetKey, newTitle);
|
|
92661
|
+
const cmd = { type: 'sheet_rename', sheetKey, oldTitle, newTitle };
|
|
92662
|
+
this.pushCommand(cmd);
|
|
92663
|
+
}
|
|
92664
|
+
finally {
|
|
92665
|
+
this.endTransaction();
|
|
92666
|
+
}
|
|
92667
|
+
}
|
|
92668
|
+
reorderSheet(sourceKey, targetKey, position) {
|
|
92669
|
+
if (!this.enabled || this.isReplaying) {
|
|
92670
|
+
this.sheet.getSheetManager().reorderSheet(sourceKey, targetKey, position);
|
|
92671
|
+
this.sheet.updateSheetTabs();
|
|
92672
|
+
this.sheet.updateSheetMenu();
|
|
92673
|
+
return;
|
|
92674
|
+
}
|
|
92675
|
+
const orderBefore = this.getSheetOrder();
|
|
92676
|
+
this.startTransaction();
|
|
92677
|
+
try {
|
|
92678
|
+
this.sheet.getSheetManager().reorderSheet(sourceKey, targetKey, position);
|
|
92679
|
+
this.sheet.updateSheetTabs();
|
|
92680
|
+
this.sheet.updateSheetMenu();
|
|
92681
|
+
const orderAfter = this.getSheetOrder();
|
|
92682
|
+
const cmd = { type: 'sheet_reorder', orderBefore, orderAfter };
|
|
92683
|
+
this.pushCommand(cmd);
|
|
92684
|
+
}
|
|
92685
|
+
finally {
|
|
92686
|
+
this.endTransaction();
|
|
92687
|
+
}
|
|
92688
|
+
}
|
|
92689
|
+
pushTransaction(tx) {
|
|
92690
|
+
if (!tx.commands.length) {
|
|
92691
|
+
return;
|
|
92692
|
+
}
|
|
92693
|
+
this.undoStack.push(tx);
|
|
92694
|
+
this.redoStack = [];
|
|
92695
|
+
this.trimHistory();
|
|
92696
|
+
this.emitChange();
|
|
92697
|
+
}
|
|
92698
|
+
pushCommand(cmd) {
|
|
92699
|
+
if (this.currentTransaction) {
|
|
92700
|
+
this.currentTransaction.commands.push(cmd);
|
|
92701
|
+
return;
|
|
92702
|
+
}
|
|
92703
|
+
this.pushTransaction({ commands: [cmd] });
|
|
92704
|
+
}
|
|
92705
|
+
trimHistory() {
|
|
92706
|
+
if (this.undoStack.length > this.maxHistory) {
|
|
92707
|
+
this.undoStack.splice(0, this.undoStack.length - this.maxHistory);
|
|
92708
|
+
}
|
|
92709
|
+
}
|
|
92710
|
+
applyCommand(cmd, direction) {
|
|
92711
|
+
switch (cmd.type) {
|
|
92712
|
+
case 'sheet_add': {
|
|
92713
|
+
if (direction === 'undo') {
|
|
92714
|
+
this.removeSheetInternal(cmd.sheet.sheetKey);
|
|
92715
|
+
this.setSheetOrder(cmd.orderBefore);
|
|
92716
|
+
if (cmd.activeBefore) {
|
|
92717
|
+
this.sheet.activateSheet(cmd.activeBefore);
|
|
92718
|
+
}
|
|
92719
|
+
}
|
|
92720
|
+
else {
|
|
92721
|
+
this.addSheetInternal(cmd.sheet, false);
|
|
92722
|
+
this.setSheetOrder(cmd.orderAfter);
|
|
92723
|
+
if (cmd.activeAfter) {
|
|
92724
|
+
this.sheet.activateSheet(cmd.activeAfter);
|
|
92725
|
+
}
|
|
92726
|
+
}
|
|
92727
|
+
break;
|
|
92728
|
+
}
|
|
92729
|
+
case 'sheet_remove': {
|
|
92730
|
+
if (direction === 'undo') {
|
|
92731
|
+
this.addSheetInternal(cmd.sheet, false);
|
|
92732
|
+
this.setSheetOrder(cmd.orderBefore);
|
|
92733
|
+
if (!this.sheet.getWorkSheetInstance(cmd.sheet.sheetKey)) {
|
|
92734
|
+
const restored = this.sheet.createWorkSheetInstance(cmd.sheet);
|
|
92735
|
+
restored.getElement().style.display = 'none';
|
|
92736
|
+
this.sheet.setWorkSheetInstance(cmd.sheet.sheetKey, restored);
|
|
92737
|
+
}
|
|
92738
|
+
if (cmd.activeBefore) {
|
|
92739
|
+
this.sheet.activateSheet(cmd.activeBefore);
|
|
92740
|
+
}
|
|
92741
|
+
}
|
|
92742
|
+
else {
|
|
92743
|
+
this.removeSheetInternal(cmd.sheet.sheetKey);
|
|
92744
|
+
this.setSheetOrder(cmd.orderAfter);
|
|
92745
|
+
if (cmd.activeAfter) {
|
|
92746
|
+
this.sheet.activateSheet(cmd.activeAfter);
|
|
92747
|
+
}
|
|
92748
|
+
}
|
|
92749
|
+
break;
|
|
92750
|
+
}
|
|
92751
|
+
case 'sheet_rename': {
|
|
92752
|
+
const nextTitle = direction === 'undo' ? cmd.oldTitle : cmd.newTitle;
|
|
92753
|
+
this.renameSheetInternal(cmd.sheetKey, nextTitle);
|
|
92754
|
+
break;
|
|
92755
|
+
}
|
|
92756
|
+
case 'sheet_reorder': {
|
|
92757
|
+
this.setSheetOrder(direction === 'undo' ? cmd.orderBefore : cmd.orderAfter);
|
|
92758
|
+
break;
|
|
92759
|
+
}
|
|
92760
|
+
case 'table_tx': {
|
|
92761
|
+
this.applyTableTransaction(cmd.sheetKey, cmd.tx, direction);
|
|
92762
|
+
break;
|
|
92763
|
+
}
|
|
92764
|
+
}
|
|
92765
|
+
}
|
|
92766
|
+
addSheetInternal(sheetDefine, activate) {
|
|
92767
|
+
this.sheet.getSheetManager().addSheet(sheetDefine);
|
|
92768
|
+
if (activate) {
|
|
92769
|
+
this.sheet.activateSheet(sheetDefine.sheetKey);
|
|
92770
|
+
}
|
|
92771
|
+
else {
|
|
92772
|
+
this.sheet.updateSheetTabs();
|
|
92773
|
+
this.sheet.updateSheetMenu();
|
|
92774
|
+
}
|
|
92775
|
+
}
|
|
92776
|
+
removeSheetInternal(sheetKey) {
|
|
92777
|
+
const instance = this.sheet.getWorkSheetInstance(sheetKey);
|
|
92778
|
+
if (instance) {
|
|
92779
|
+
instance.release();
|
|
92780
|
+
this.sheet.deleteWorkSheetInstance(sheetKey);
|
|
92781
|
+
}
|
|
92782
|
+
const active = this.getActiveSheetKey();
|
|
92783
|
+
const newActiveSheetKey = this.sheet.getSheetManager().removeSheet(sheetKey);
|
|
92784
|
+
try {
|
|
92785
|
+
this.sheet.getFormulaManager().removeSheet(sheetKey);
|
|
92786
|
+
}
|
|
92787
|
+
catch { }
|
|
92788
|
+
if (newActiveSheetKey && newActiveSheetKey !== active) {
|
|
92789
|
+
this.sheet.activateSheet(newActiveSheetKey);
|
|
92790
|
+
}
|
|
92791
|
+
this.sheet.updateSheetTabs();
|
|
92792
|
+
this.sheet.updateSheetMenu();
|
|
92793
|
+
}
|
|
92794
|
+
renameSheetInternal(sheetKey, newTitle) {
|
|
92795
|
+
this.sheet.getSheetManager().renameSheet(sheetKey, newTitle);
|
|
92796
|
+
this.sheet.getWorkSheetInstance(sheetKey)?.setTitle(newTitle);
|
|
92797
|
+
this.sheet.getFormulaManager().updateSheetTitle(sheetKey, newTitle);
|
|
92798
|
+
this.sheet.updateSheetTabs();
|
|
92799
|
+
this.sheet.updateSheetMenu();
|
|
92800
|
+
}
|
|
92801
|
+
applyTableTransaction(sheetKey, tx, direction) {
|
|
92802
|
+
const ws = this.ensureWorkSheetInstance(sheetKey);
|
|
92803
|
+
if (ws && this.getActiveSheetKey() !== sheetKey) {
|
|
92804
|
+
this.sheet.activateSheet(sheetKey);
|
|
92805
|
+
}
|
|
92806
|
+
const table = ws?.tableInstance;
|
|
92807
|
+
if (!table) {
|
|
92808
|
+
return;
|
|
92809
|
+
}
|
|
92810
|
+
const vtableSheet = this.sheet;
|
|
92811
|
+
const apply = (cmd, dir) => {
|
|
92812
|
+
replayCommand({
|
|
92813
|
+
table,
|
|
92814
|
+
vtableSheet,
|
|
92815
|
+
cmd,
|
|
92816
|
+
direction: dir,
|
|
92817
|
+
deleteRecordsByReference: (records) => {
|
|
92818
|
+
const tableRecords = (table.records || []);
|
|
92819
|
+
const indexs = [];
|
|
92820
|
+
records.forEach(rec => {
|
|
92821
|
+
const idx = tableRecords.indexOf(rec);
|
|
92822
|
+
if (idx >= 0) {
|
|
92823
|
+
indexs.push(idx);
|
|
92824
|
+
}
|
|
92825
|
+
});
|
|
92826
|
+
if (indexs.length && table.deleteRecords) {
|
|
92827
|
+
table.deleteRecords(indexs);
|
|
92828
|
+
}
|
|
92829
|
+
}
|
|
92830
|
+
});
|
|
92831
|
+
};
|
|
92832
|
+
if (direction === 'undo') {
|
|
92833
|
+
for (let i = tx.commands.length - 1; i >= 0; i--) {
|
|
92834
|
+
apply(tx.commands[i], 'undo');
|
|
92835
|
+
}
|
|
92836
|
+
}
|
|
92837
|
+
else {
|
|
92838
|
+
for (let i = 0; i < tx.commands.length; i++) {
|
|
92839
|
+
apply(tx.commands[i], 'redo');
|
|
92840
|
+
}
|
|
92841
|
+
}
|
|
92842
|
+
}
|
|
92843
|
+
ensureWorkSheetInstance(sheetKey) {
|
|
92844
|
+
const existing = this.sheet.getWorkSheetInstance(sheetKey);
|
|
92845
|
+
if (existing) {
|
|
92846
|
+
return existing;
|
|
92847
|
+
}
|
|
92848
|
+
const def = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92849
|
+
if (!def) {
|
|
92850
|
+
return undefined;
|
|
92851
|
+
}
|
|
92852
|
+
const instance = this.sheet.createWorkSheetInstance(def);
|
|
92853
|
+
instance.getElement().style.display = 'none';
|
|
92854
|
+
this.sheet.setWorkSheetInstance(sheetKey, instance);
|
|
92855
|
+
return instance;
|
|
92856
|
+
}
|
|
92857
|
+
getSheetOrder() {
|
|
92858
|
+
return this.sheet
|
|
92859
|
+
.getSheetManager()
|
|
92860
|
+
.getAllSheets()
|
|
92861
|
+
.map(s => s.sheetKey);
|
|
92862
|
+
}
|
|
92863
|
+
setSheetOrder(order) {
|
|
92864
|
+
const all = this.sheet.getSheetManager().getAllSheets();
|
|
92865
|
+
const map = new Map(all.map(s => [s.sheetKey, s]));
|
|
92866
|
+
const next = [];
|
|
92867
|
+
order.forEach(key => {
|
|
92868
|
+
const s = map.get(key);
|
|
92869
|
+
if (s) {
|
|
92870
|
+
next.push(s);
|
|
92871
|
+
}
|
|
92872
|
+
});
|
|
92873
|
+
if (next.length === all.length) {
|
|
92874
|
+
this.sheet.getSheetManager().sortSheets(next);
|
|
92875
|
+
this.sheet.updateSheetTabs();
|
|
92876
|
+
this.sheet.updateSheetMenu();
|
|
92877
|
+
}
|
|
92878
|
+
}
|
|
92879
|
+
getActiveSheetKey() {
|
|
92880
|
+
return this.sheet.getSheetManager().getActiveSheet()?.sheetKey;
|
|
92881
|
+
}
|
|
92882
|
+
}
|
|
92883
|
+
|
|
90804
92884
|
class VTableSheet {
|
|
90805
92885
|
container;
|
|
90806
92886
|
options;
|
|
@@ -90819,9 +92899,11 @@
|
|
|
90819
92899
|
formulaBarElement = null;
|
|
90820
92900
|
sheetTabElement = null;
|
|
90821
92901
|
mainMenuElement = null;
|
|
92902
|
+
undoRedoElement = null;
|
|
90822
92903
|
contentElement;
|
|
90823
92904
|
dragManager;
|
|
90824
92905
|
sheetTabEventHandler;
|
|
92906
|
+
workbookHistoryManager;
|
|
90825
92907
|
constructor(container, options) {
|
|
90826
92908
|
this.container = container;
|
|
90827
92909
|
this.options = this.mergeDefaultOptions(options);
|
|
@@ -90831,12 +92913,15 @@
|
|
|
90831
92913
|
this.tableEventRelay = new TableEventRelay(this);
|
|
90832
92914
|
this.eventManager = new DomEventManager(this);
|
|
90833
92915
|
this.dragManager = new SheetTabDragManager(this);
|
|
90834
|
-
this.menuManager = new MenuManager(this);
|
|
90835
92916
|
this.formulaUIManager = new FormulaUIManager(this);
|
|
90836
92917
|
this.sheetTabEventHandler = new SheetTabEventHandler(this);
|
|
90837
92918
|
this.spreadsheetEventManager = new SpreadSheetEventManager(this);
|
|
92919
|
+
this.workbookHistoryManager = new WorkbookHistoryManager(this);
|
|
92920
|
+
this.menuManager = new MenuManager(this);
|
|
90838
92921
|
this.initUI();
|
|
92922
|
+
this.workbookHistoryManager.suspend();
|
|
90839
92923
|
this.initSheets();
|
|
92924
|
+
this.workbookHistoryManager.resume();
|
|
90840
92925
|
this.resize();
|
|
90841
92926
|
}
|
|
90842
92927
|
mergeDefaultOptions(options) {
|
|
@@ -90865,10 +92950,7 @@
|
|
|
90865
92950
|
const topContainer = document.createElement('div');
|
|
90866
92951
|
topContainer.className = 'vtable-sheet-top-container';
|
|
90867
92952
|
this.rootElement.appendChild(topContainer);
|
|
90868
|
-
|
|
90869
|
-
this.mainMenuElement = this.menuManager.createMainMenu();
|
|
90870
|
-
topContainer.appendChild(this.mainMenuElement);
|
|
90871
|
-
}
|
|
92953
|
+
this.renderTopLeftControls(topContainer);
|
|
90872
92954
|
if (this.options.showFormulaBar) {
|
|
90873
92955
|
this.formulaBarElement = this.formulaUIManager.createFormulaBar();
|
|
90874
92956
|
topContainer.appendChild(this.formulaBarElement);
|
|
@@ -90882,6 +92964,38 @@
|
|
|
90882
92964
|
this.rootElement.appendChild(this.sheetTabElement);
|
|
90883
92965
|
}
|
|
90884
92966
|
}
|
|
92967
|
+
renderTopLeftControls(topContainer) {
|
|
92968
|
+
if (this.mainMenuElement?.parentElement) {
|
|
92969
|
+
this.mainMenuElement.parentElement.removeChild(this.mainMenuElement);
|
|
92970
|
+
this.mainMenuElement = null;
|
|
92971
|
+
}
|
|
92972
|
+
if (this.undoRedoElement?.parentElement) {
|
|
92973
|
+
this.undoRedoElement.parentElement.removeChild(this.undoRedoElement);
|
|
92974
|
+
this.undoRedoElement = null;
|
|
92975
|
+
}
|
|
92976
|
+
this.menuManager.release();
|
|
92977
|
+
const showMainMenu = !!this.options.mainMenu?.show;
|
|
92978
|
+
const showUndoRedo = this.options.undoRedo?.show ?? true;
|
|
92979
|
+
if (showMainMenu) {
|
|
92980
|
+
this.mainMenuElement = this.menuManager.createMainMenu();
|
|
92981
|
+
if (topContainer.firstChild) {
|
|
92982
|
+
topContainer.insertBefore(this.mainMenuElement, topContainer.firstChild);
|
|
92983
|
+
}
|
|
92984
|
+
else {
|
|
92985
|
+
topContainer.appendChild(this.mainMenuElement);
|
|
92986
|
+
}
|
|
92987
|
+
return;
|
|
92988
|
+
}
|
|
92989
|
+
if (showUndoRedo) {
|
|
92990
|
+
this.undoRedoElement = this.menuManager.createUndoRedoOnly();
|
|
92991
|
+
if (topContainer.firstChild) {
|
|
92992
|
+
topContainer.insertBefore(this.undoRedoElement, topContainer.firstChild);
|
|
92993
|
+
}
|
|
92994
|
+
else {
|
|
92995
|
+
topContainer.appendChild(this.undoRedoElement);
|
|
92996
|
+
}
|
|
92997
|
+
}
|
|
92998
|
+
}
|
|
90885
92999
|
createSheetTab() {
|
|
90886
93000
|
const addIcon = '<svg viewBox="0 0 24 24" width="16" height="16">' +
|
|
90887
93001
|
'<path fill="currentColor" d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"/>' +
|
|
@@ -91047,26 +93161,14 @@
|
|
|
91047
93161
|
}
|
|
91048
93162
|
}
|
|
91049
93163
|
addSheet(sheet) {
|
|
91050
|
-
this.
|
|
91051
|
-
this.updateSheetTabs();
|
|
91052
|
-
this.updateSheetMenu();
|
|
93164
|
+
this.workbookHistoryManager.addSheet({ sheet, activate: false });
|
|
91053
93165
|
}
|
|
91054
93166
|
removeSheet(sheetKey) {
|
|
91055
93167
|
if (this.sheetManager.getSheetCount() <= 1) {
|
|
91056
93168
|
showSnackbar('至少保留一个工作表', 1300);
|
|
91057
93169
|
return;
|
|
91058
93170
|
}
|
|
91059
|
-
|
|
91060
|
-
if (instance) {
|
|
91061
|
-
instance.release();
|
|
91062
|
-
this.workSheetInstances.delete(sheetKey);
|
|
91063
|
-
}
|
|
91064
|
-
const newActiveSheetKey = this.sheetManager.removeSheet(sheetKey);
|
|
91065
|
-
if (newActiveSheetKey) {
|
|
91066
|
-
this.activateSheet(newActiveSheetKey);
|
|
91067
|
-
}
|
|
91068
|
-
this.updateSheetTabs();
|
|
91069
|
-
this.updateSheetMenu();
|
|
93171
|
+
this.workbookHistoryManager.removeSheet(sheetKey);
|
|
91070
93172
|
}
|
|
91071
93173
|
getSheetCount() {
|
|
91072
93174
|
return this.sheetManager.getSheetCount();
|
|
@@ -91078,10 +93180,10 @@
|
|
|
91078
93180
|
return this.sheetManager.getAllSheets();
|
|
91079
93181
|
}
|
|
91080
93182
|
createWorkSheetInstance(sheetDefine) {
|
|
91081
|
-
formulaEditor.setSheet(this);
|
|
91082
93183
|
const contentWidth = this.contentElement.clientWidth;
|
|
91083
93184
|
const contentHeight = this.contentElement.clientHeight;
|
|
91084
93185
|
sheetDefine.dragOrder = sheetDefine.dragOrder ?? this.options.dragOrder;
|
|
93186
|
+
const formulaEditor = createFormulaEditor();
|
|
91085
93187
|
const sheet = new WorkSheet(this, {
|
|
91086
93188
|
...sheetDefine,
|
|
91087
93189
|
container: this.contentElement,
|
|
@@ -91091,8 +93193,8 @@
|
|
|
91091
93193
|
defaultColWidth: this.options.defaultColWidth,
|
|
91092
93194
|
dragOrder: sheetDefine.dragOrder,
|
|
91093
93195
|
plugins: getTablePlugins(sheetDefine, this.options, this),
|
|
91094
|
-
headerEditor:
|
|
91095
|
-
editor:
|
|
93196
|
+
headerEditor: formulaEditor,
|
|
93197
|
+
editor: formulaEditor,
|
|
91096
93198
|
select: {
|
|
91097
93199
|
makeSelectCellVisible: false
|
|
91098
93200
|
},
|
|
@@ -91100,6 +93202,7 @@
|
|
|
91100
93202
|
customMergeCell: sheetDefine.cellMerge,
|
|
91101
93203
|
theme: sheetDefine.theme?.tableTheme || this.options.theme?.tableTheme
|
|
91102
93204
|
});
|
|
93205
|
+
formulaEditor.setSheet(this);
|
|
91103
93206
|
try {
|
|
91104
93207
|
const normalizedData = sheetDefine.data
|
|
91105
93208
|
? this.formulaManager.normalizeSheetData(sheetDefine.data, sheet.tableInstance)
|
|
@@ -91175,8 +93278,7 @@
|
|
|
91175
93278
|
rowCount: 100,
|
|
91176
93279
|
data: []
|
|
91177
93280
|
};
|
|
91178
|
-
this.
|
|
91179
|
-
this.activateSheet(key);
|
|
93281
|
+
this.workbookHistoryManager.addSheet({ sheet: newSheet, activate: true });
|
|
91180
93282
|
}
|
|
91181
93283
|
updateFormulaBar() {
|
|
91182
93284
|
this.formulaUIManager.updateFormulaBar();
|
|
@@ -91193,9 +93295,39 @@
|
|
|
91193
93295
|
getSheetManager() {
|
|
91194
93296
|
return this.sheetManager;
|
|
91195
93297
|
}
|
|
93298
|
+
getWorkbookHistoryManager() {
|
|
93299
|
+
return this.workbookHistoryManager;
|
|
93300
|
+
}
|
|
91196
93301
|
getActiveSheet() {
|
|
91197
93302
|
return this.activeWorkSheet;
|
|
91198
93303
|
}
|
|
93304
|
+
getWorkSheetInstance(sheetKey) {
|
|
93305
|
+
return this.workSheetInstances.get(sheetKey);
|
|
93306
|
+
}
|
|
93307
|
+
setWorkSheetInstance(sheetKey, instance) {
|
|
93308
|
+
this.workSheetInstances.set(sheetKey, instance);
|
|
93309
|
+
}
|
|
93310
|
+
deleteWorkSheetInstance(sheetKey) {
|
|
93311
|
+
this.workSheetInstances.delete(sheetKey);
|
|
93312
|
+
}
|
|
93313
|
+
renameSheet(sheetKey, newTitle) {
|
|
93314
|
+
this.workbookHistoryManager.renameSheet(sheetKey, newTitle);
|
|
93315
|
+
}
|
|
93316
|
+
reorderSheet(sourceKey, targetKey, position) {
|
|
93317
|
+
this.workbookHistoryManager.reorderSheet(sourceKey, targetKey, position);
|
|
93318
|
+
}
|
|
93319
|
+
undo() {
|
|
93320
|
+
this.workbookHistoryManager.undo();
|
|
93321
|
+
}
|
|
93322
|
+
redo() {
|
|
93323
|
+
this.workbookHistoryManager.redo();
|
|
93324
|
+
}
|
|
93325
|
+
startHistoryTransaction() {
|
|
93326
|
+
this.workbookHistoryManager.startTransaction();
|
|
93327
|
+
}
|
|
93328
|
+
endHistoryTransaction() {
|
|
93329
|
+
this.workbookHistoryManager.endTransaction();
|
|
93330
|
+
}
|
|
91199
93331
|
onTableEvent(type, callback) {
|
|
91200
93332
|
this.tableEventRelay.onTableEvent(type, callback);
|
|
91201
93333
|
}
|
|
@@ -91306,22 +93438,30 @@
|
|
|
91306
93438
|
}
|
|
91307
93439
|
updateMainMenu(mainMenu) {
|
|
91308
93440
|
this.options.mainMenu = mainMenu;
|
|
91309
|
-
this.
|
|
93441
|
+
const topContainer = this.rootElement.querySelector('.vtable-sheet-top-container');
|
|
93442
|
+
if (!topContainer) {
|
|
93443
|
+
return;
|
|
93444
|
+
}
|
|
93445
|
+
this.renderTopLeftControls(topContainer);
|
|
91310
93446
|
}
|
|
91311
93447
|
updateOption(options) {
|
|
91312
93448
|
if (!options) {
|
|
91313
93449
|
return;
|
|
91314
93450
|
}
|
|
91315
93451
|
const hasMainMenu = typeof options.mainMenu !== 'undefined';
|
|
91316
|
-
|
|
91317
|
-
this.updateMainMenu(options.mainMenu);
|
|
91318
|
-
}
|
|
93452
|
+
const hasUndoRedo = typeof options.undoRedo !== 'undefined';
|
|
91319
93453
|
const pluginModulesChanged = pluginIsChanged(this.options.VTablePluginModules, options.VTablePluginModules);
|
|
91320
93454
|
const tableThemeChanged = tableThemeIsChanged(this.options.theme?.tableTheme, options.theme?.tableTheme);
|
|
91321
93455
|
this.options = {
|
|
91322
93456
|
...this.options,
|
|
91323
93457
|
...options
|
|
91324
93458
|
};
|
|
93459
|
+
if (hasMainMenu || hasUndoRedo) {
|
|
93460
|
+
const topContainer = this.rootElement.querySelector('.vtable-sheet-top-container');
|
|
93461
|
+
if (topContainer) {
|
|
93462
|
+
this.renderTopLeftControls(topContainer);
|
|
93463
|
+
}
|
|
93464
|
+
}
|
|
91325
93465
|
if (Array.isArray(options.sheets) || pluginModulesChanged || tableThemeChanged) {
|
|
91326
93466
|
this.updateSheets(options);
|
|
91327
93467
|
}
|
|
@@ -91372,6 +93512,7 @@
|
|
|
91372
93512
|
this.workSheetInstances.set(next_sheetDefine.sheetKey, newInstance);
|
|
91373
93513
|
return;
|
|
91374
93514
|
}
|
|
93515
|
+
const formulaEditor = createFormulaEditor();
|
|
91375
93516
|
const sheetOption = {
|
|
91376
93517
|
sheetTitle: next_sheetDefine.sheetTitle,
|
|
91377
93518
|
sheetKey: next_sheetDefine.sheetKey,
|
|
@@ -91387,8 +93528,8 @@
|
|
|
91387
93528
|
defaultColWidth: this.options.defaultColWidth,
|
|
91388
93529
|
dragOrder: next_sheetDefine.dragOrder,
|
|
91389
93530
|
plugins: getTablePlugins(next_sheetDefine, this.options, this),
|
|
91390
|
-
headerEditor:
|
|
91391
|
-
editor:
|
|
93531
|
+
headerEditor: formulaEditor,
|
|
93532
|
+
editor: formulaEditor,
|
|
91392
93533
|
select: {
|
|
91393
93534
|
makeSelectCellVisible: false
|
|
91394
93535
|
},
|
|
@@ -91398,6 +93539,7 @@
|
|
|
91398
93539
|
data: next_sheetDefine.data,
|
|
91399
93540
|
columns: next_sheetDefine.columns
|
|
91400
93541
|
};
|
|
93542
|
+
formulaEditor.setSheet(this);
|
|
91401
93543
|
instance.updateSheetOption(sheetOption);
|
|
91402
93544
|
});
|
|
91403
93545
|
try {
|
|
@@ -92198,7 +94340,7 @@
|
|
|
92198
94340
|
display: flex;
|
|
92199
94341
|
align-items: center;
|
|
92200
94342
|
background-color: #fff;
|
|
92201
|
-
width:
|
|
94343
|
+
width: auto;
|
|
92202
94344
|
/* 内容居中 */
|
|
92203
94345
|
justify-content: center;
|
|
92204
94346
|
flex-shrink: 0; /* 防止菜单被压缩 */
|
|
@@ -92207,6 +94349,17 @@
|
|
|
92207
94349
|
background-color: #f0f0f0;
|
|
92208
94350
|
}
|
|
92209
94351
|
|
|
94352
|
+
.vtable-sheet-undo-redo {
|
|
94353
|
+
display: flex;
|
|
94354
|
+
flex-direction: row;
|
|
94355
|
+
align-items: center;
|
|
94356
|
+
height: 30px;
|
|
94357
|
+
padding: 0;
|
|
94358
|
+
border-bottom: 1px solid #e0e0e0;
|
|
94359
|
+
background-color: #fff;
|
|
94360
|
+
flex-shrink: 0;
|
|
94361
|
+
}
|
|
94362
|
+
|
|
92210
94363
|
.vtable-sheet-main-menu-button {
|
|
92211
94364
|
display: flex;
|
|
92212
94365
|
align-items: center;
|
|
@@ -92215,6 +94368,38 @@
|
|
|
92215
94368
|
height: 30px;
|
|
92216
94369
|
}
|
|
92217
94370
|
|
|
94371
|
+
.vtable-sheet-main-menu-actions {
|
|
94372
|
+
display: flex;
|
|
94373
|
+
align-items: center;
|
|
94374
|
+
height: 30px;
|
|
94375
|
+
gap: 4px;
|
|
94376
|
+
padding-right: 6px;
|
|
94377
|
+
}
|
|
94378
|
+
|
|
94379
|
+
.vtable-sheet-main-menu-action {
|
|
94380
|
+
display: inline-flex;
|
|
94381
|
+
align-items: center;
|
|
94382
|
+
justify-content: center;
|
|
94383
|
+
width: 28px;
|
|
94384
|
+
height: 28px;
|
|
94385
|
+
border: none;
|
|
94386
|
+
background: transparent;
|
|
94387
|
+
color: #666;
|
|
94388
|
+
cursor: pointer;
|
|
94389
|
+
padding: 0;
|
|
94390
|
+
}
|
|
94391
|
+
|
|
94392
|
+
.vtable-sheet-main-menu-action:hover:not(:disabled) {
|
|
94393
|
+
color: #333;
|
|
94394
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
94395
|
+
border-radius: 4px;
|
|
94396
|
+
}
|
|
94397
|
+
|
|
94398
|
+
.vtable-sheet-main-menu-action:disabled {
|
|
94399
|
+
opacity: 0.4;
|
|
94400
|
+
cursor: not-allowed;
|
|
94401
|
+
}
|
|
94402
|
+
|
|
92218
94403
|
/* 菜单项容器 */
|
|
92219
94404
|
.vtable-sheet-main-menu-container {
|
|
92220
94405
|
position: absolute;
|
|
@@ -93003,7 +95188,7 @@
|
|
|
93003
95188
|
importStyle();
|
|
93004
95189
|
}
|
|
93005
95190
|
|
|
93006
|
-
const version = "1.
|
|
95191
|
+
const version = "1.24.0";
|
|
93007
95192
|
importStyles();
|
|
93008
95193
|
|
|
93009
95194
|
exports.TYPES = index;
|