@visactor/vtable-sheet 1.23.3 → 1.24.0-alpha.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 +4 -48
- 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/event/vtable-sheet-event-bus.js +2 -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-paste-processor.js +1 -2
- package/cjs/formula/formula-range-selector.js +1 -5
- package/cjs/formula/formula-range-selector.js.map +1 -1
- package/cjs/formula/index.js +2 -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 +2513 -324
- 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 +4 -48
- 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/event/vtable-sheet-event-bus.js +2 -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-paste-processor.js +1 -2
- package/es/formula/formula-range-selector.js +1 -5
- package/es/formula/formula-range-selector.js.map +1 -1
- package/es/formula/index.js +2 -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) {
|
|
@@ -60490,11 +60539,11 @@
|
|
|
60490
60539
|
onUpdate(end, ratio, out) {
|
|
60491
60540
|
if (this.from.x !== this.to.x) {
|
|
60492
60541
|
const x = end ? this.to.x : this.from.x + Math.floor((this.to.x - this.from.x) * ratio);
|
|
60493
|
-
this.params.table.scrollLeft = x;
|
|
60542
|
+
this.params.table.scrollLeft = x, 1 === ratio && -1 !== this.to.targetCol && this.params.table.scrollToCol(this.to.targetCol, !1);
|
|
60494
60543
|
}
|
|
60495
60544
|
if (this.from.y !== this.to.y) {
|
|
60496
60545
|
const y = end ? this.to.y : this.from.y + Math.floor((this.to.y - this.from.y) * ratio);
|
|
60497
|
-
this.params.table.scrollTop = y;
|
|
60546
|
+
this.params.table.scrollTop = y, 1 === ratio && -1 !== this.to.targetRow && this.params.table.scrollToRow(this.to.targetRow, !1);
|
|
60498
60547
|
}
|
|
60499
60548
|
}
|
|
60500
60549
|
}
|
|
@@ -60526,7 +60575,9 @@
|
|
|
60526
60575
|
colDecimal && (left += colDecimal * cellRect.width), rowDecimal && (top += rowDecimal * cellRect.height);
|
|
60527
60576
|
const to = {
|
|
60528
60577
|
x: isNumber$2(col) ? left - this.table.getFrozenColsWidth() : this.table.scrollLeft,
|
|
60529
|
-
y: isNumber$2(row) ? top - this.table.getFrozenRowsHeight() : this.table.scrollTop
|
|
60578
|
+
y: isNumber$2(row) ? top - this.table.getFrozenRowsHeight() : this.table.scrollTop,
|
|
60579
|
+
targetRow: null != rowInt ? rowInt : -1,
|
|
60580
|
+
targetCol: null != colInt ? colInt : -1
|
|
60530
60581
|
},
|
|
60531
60582
|
duration = isBoolean$2(animationOption) ? animationOption ? 3e3 : 0 : null !== (_a = null == animationOption ? void 0 : animationOption.duration) && void 0 !== _a ? _a : 3e3,
|
|
60532
60583
|
easing = isBoolean$2(animationOption) ? animationOption ? "linear" : "" : null !== (_b = null == animationOption ? void 0 : animationOption.easing) && void 0 !== _b ? _b : "linear";
|
|
@@ -60541,7 +60592,7 @@
|
|
|
60541
60592
|
}
|
|
60542
60593
|
}
|
|
60543
60594
|
|
|
60544
|
-
function getCustomMergeCellFunc(customMergeCell) {
|
|
60595
|
+
function getCustomMergeCellFunc$1(customMergeCell) {
|
|
60545
60596
|
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
60597
|
}
|
|
60547
60598
|
|
|
@@ -60613,7 +60664,7 @@
|
|
|
60613
60664
|
}
|
|
60614
60665
|
constructor(container, options = {}) {
|
|
60615
60666
|
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.
|
|
60667
|
+
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-alpha.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
60668
|
this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
|
|
60618
60669
|
options: options,
|
|
60619
60670
|
container: container
|
|
@@ -60730,7 +60781,7 @@
|
|
|
60730
60781
|
}
|
|
60731
60782
|
this.headerStyleCache = new Map(), this.bodyStyleCache = new Map(), this.bodyMergeTitleCache = new Map(), this.bodyBottomStyleCache = new Map(), internalProps.stick = {
|
|
60732
60783
|
changedCells: new Map()
|
|
60733
|
-
}, internalProps.customMergeCell = getCustomMergeCellFunc(options.customMergeCell);
|
|
60784
|
+
}, internalProps.customMergeCell = getCustomMergeCellFunc$1(options.customMergeCell);
|
|
60734
60785
|
const CustomCellStylePlugin = Factory.getComponent("customCellStylePlugin");
|
|
60735
60786
|
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
60787
|
}
|
|
@@ -61551,12 +61602,15 @@
|
|
|
61551
61602
|
dispose() {
|
|
61552
61603
|
this.release();
|
|
61553
61604
|
}
|
|
61605
|
+
clearCorrectTimer() {
|
|
61606
|
+
this._scrollToRowCorrectTimer && (clearTimeout(this._scrollToRowCorrectTimer), this._scrollToRowCorrectTimer = null);
|
|
61607
|
+
}
|
|
61554
61608
|
release() {
|
|
61555
61609
|
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
61610
|
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
61611
|
const internalProps = this.internalProps;
|
|
61558
61612
|
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 => {
|
|
61613
|
+
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
61614
|
null == legend || legend.release();
|
|
61561
61615
|
}), 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
61616
|
var _a;
|
|
@@ -61669,7 +61723,7 @@
|
|
|
61669
61723
|
const MenuHandler = Factory.getComponent("menuHandler");
|
|
61670
61724
|
internalProps.menuHandler = new MenuHandler(this);
|
|
61671
61725
|
}
|
|
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();
|
|
61726
|
+
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
61727
|
}
|
|
61674
61728
|
renderWithRecreateCells() {
|
|
61675
61729
|
this.internalProps.stick.changedCells.clear();
|
|
@@ -61861,6 +61915,30 @@
|
|
|
61861
61915
|
lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
|
|
61862
61916
|
lastSelectRange && (lastSelectRange.end.row = rowIndex), this.stateManager.updateSelectPos(this.colCount - 1, rowIndex, !1, isCtrl, !1, makeSelectCellVisible, !0), this.stateManager.select.selecting = !1;
|
|
61863
61917
|
}
|
|
61918
|
+
changeHeaderPosition(args) {
|
|
61919
|
+
var _a, _b, _c, _d, _e;
|
|
61920
|
+
if (!("canMoveHeaderPosition" in this.internalProps.layoutMap) || !0 === (null === (_a = this.options.customConfig) || void 0 === _a ? void 0 : _a.notUpdateInColumnRowMove)) return !1;
|
|
61921
|
+
const prevMoving = this.stateManager.columnMove.movingColumnOrRow;
|
|
61922
|
+
this.stateManager.columnMove.movingColumnOrRow = args.movingColumnOrRow;
|
|
61923
|
+
try {
|
|
61924
|
+
if (!1 === (null === (_c = (_b = this.internalProps.layoutMap).canMoveHeaderPosition) || void 0 === _c ? void 0 : _c.call(_b, args.source, args.target))) return !1;
|
|
61925
|
+
const oldSourceMergeInfo = this.getCellRange(args.source.col, args.source.row),
|
|
61926
|
+
oldTargetMergeInfo = this.getCellRange(args.target.col, args.target.row),
|
|
61927
|
+
moveContext = this._moveHeaderPosition(args.source, args.target);
|
|
61928
|
+
if (!moveContext || moveContext.targetIndex === moveContext.sourceIndex) return !1;
|
|
61929
|
+
this.internalProps.useOneRowHeightFillAll = !1, this.internalProps.layoutMap.clearCellRangeMap();
|
|
61930
|
+
const sourceMergeInfo = this.getCellRange(args.source.col, args.source.row),
|
|
61931
|
+
targetMergeInfo = this.getCellRange(args.target.col, args.target.row),
|
|
61932
|
+
colMin = Math.min(sourceMergeInfo.start.col, targetMergeInfo.start.col, oldSourceMergeInfo.start.col, oldTargetMergeInfo.start.col),
|
|
61933
|
+
colMax = Math.max(sourceMergeInfo.end.col, targetMergeInfo.end.col, oldSourceMergeInfo.end.col, oldTargetMergeInfo.end.col),
|
|
61934
|
+
rowMin = Math.min(sourceMergeInfo.start.row, targetMergeInfo.start.row, oldSourceMergeInfo.start.row, oldTargetMergeInfo.start.row);
|
|
61935
|
+
let rowMax = Math.max(sourceMergeInfo.end.row, targetMergeInfo.end.row, oldSourceMergeInfo.end.row, oldTargetMergeInfo.end.row);
|
|
61936
|
+
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);
|
|
61937
|
+
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;
|
|
61938
|
+
} finally {
|
|
61939
|
+
this.stateManager.columnMove.movingColumnOrRow = prevMoving;
|
|
61940
|
+
}
|
|
61941
|
+
}
|
|
61864
61942
|
get recordsCount() {
|
|
61865
61943
|
var _a;
|
|
61866
61944
|
return null === (_a = this.records) || void 0 === _a ? void 0 : _a.length;
|
|
@@ -62006,7 +62084,7 @@
|
|
|
62006
62084
|
getCustomMerge(col, row) {
|
|
62007
62085
|
if (this.internalProps.customMergeCell) {
|
|
62008
62086
|
const customMerge = this.internalProps.customMergeCell(col, row, this);
|
|
62009
|
-
if (customMerge && customMerge.range
|
|
62087
|
+
if (customMerge && customMerge.range) {
|
|
62010
62088
|
if (customMerge.style) {
|
|
62011
62089
|
const styleClass = this.internalProps.bodyHelper.getStyleClass("text"),
|
|
62012
62090
|
style = customMerge.style,
|
|
@@ -62412,7 +62490,7 @@
|
|
|
62412
62490
|
}
|
|
62413
62491
|
getSelectedCellRanges() {
|
|
62414
62492
|
const ranges = this.stateManager.select.ranges;
|
|
62415
|
-
return ranges.length ? cloneDeep$
|
|
62493
|
+
return ranges.length ? cloneDeep$2(ranges) : [];
|
|
62416
62494
|
}
|
|
62417
62495
|
measureText(text, font) {
|
|
62418
62496
|
return textMeasure.measureText(text, font);
|
|
@@ -62717,12 +62795,36 @@
|
|
|
62717
62795
|
this.eventManager.enableScroll();
|
|
62718
62796
|
}
|
|
62719
62797
|
getGroupTitleLevel(col, row) {}
|
|
62798
|
+
getTargetScrollTop(row) {
|
|
62799
|
+
const drawRange = this.getDrawRange(),
|
|
62800
|
+
frozenHeight = this.getFrozenRowsHeight(),
|
|
62801
|
+
rowsHeight = Math.ceil(this.rowHeightsMap.getSumInRange(0, row - 1)),
|
|
62802
|
+
allRowsHeight = this.getAllRowsHeight();
|
|
62803
|
+
return Math.max(0, Math.min(rowsHeight - frozenHeight, allRowsHeight - drawRange.height));
|
|
62804
|
+
}
|
|
62805
|
+
_scheduleScrollToRowCorrect(row, delay = 0) {
|
|
62806
|
+
this._scrollToRowCorrectTimer = setTimeout(() => {
|
|
62807
|
+
this.clearCorrectTimer();
|
|
62808
|
+
const targetScrollTop = this.getTargetScrollTop(row);
|
|
62809
|
+
if (targetScrollTop !== this.scrollTop) {
|
|
62810
|
+
this.scrollTop = targetScrollTop;
|
|
62811
|
+
const correctedTargetScrollTop = this.getTargetScrollTop(row);
|
|
62812
|
+
correctedTargetScrollTop !== this.scrollTop && (this.scrollTop = correctedTargetScrollTop);
|
|
62813
|
+
}
|
|
62814
|
+
}, delay);
|
|
62815
|
+
}
|
|
62720
62816
|
scrollToRow(row, animationOption) {
|
|
62721
|
-
|
|
62722
|
-
|
|
62723
|
-
|
|
62724
|
-
row:
|
|
62725
|
-
});
|
|
62817
|
+
var _a;
|
|
62818
|
+
const targetRow = Math.min(Math.max(Math.floor(row), 0), this.rowCount - 1);
|
|
62819
|
+
if (this.clearCorrectTimer(), !animationOption) return this.scrollToCell({
|
|
62820
|
+
row: targetRow
|
|
62821
|
+
}), void this._scheduleScrollToRowCorrect(targetRow);
|
|
62822
|
+
const duration = isBoolean$2(animationOption) ? 3e3 : null !== (_a = null == animationOption ? void 0 : animationOption.duration) && void 0 !== _a ? _a : 3e3;
|
|
62823
|
+
this.animationManager.scrollTo({
|
|
62824
|
+
row: targetRow
|
|
62825
|
+
}, animationOption), this._scrollToRowCorrectTimer = setTimeout(() => {
|
|
62826
|
+
this.scrollToRow(targetRow, !1);
|
|
62827
|
+
}, duration);
|
|
62726
62828
|
}
|
|
62727
62829
|
scrollToCol(col, animationOption) {
|
|
62728
62830
|
animationOption ? this.animationManager.scrollTo({
|
|
@@ -62741,8 +62843,8 @@
|
|
|
62741
62843
|
}
|
|
62742
62844
|
if (isValid$2(cellAddr.row) && cellAddr.row >= this.frozenRowCount) {
|
|
62743
62845
|
const frozenHeight = this.getFrozenRowsHeight(),
|
|
62744
|
-
top = this.
|
|
62745
|
-
this.scrollTop = Math.min(top - frozenHeight, this.
|
|
62846
|
+
top = this.rowHeightsMap.getSumInRange(0, cellAddr.row - 1);
|
|
62847
|
+
this.scrollTop = Math.min(top - frozenHeight, this.rowHeightsMap.getSumInRange(0, this.rowCount - 1) - drawRange.height);
|
|
62746
62848
|
}
|
|
62747
62849
|
this.render();
|
|
62748
62850
|
}
|
|
@@ -63042,7 +63144,7 @@
|
|
|
63042
63144
|
}
|
|
63043
63145
|
cloneParseData(data, options) {
|
|
63044
63146
|
let clone = !1;
|
|
63045
|
-
return data instanceof DataView || !0 !== (null == options ? void 0 : options.clone) || (clone = !0), clone ? cloneDeep$
|
|
63147
|
+
return data instanceof DataView || !0 !== (null == options ? void 0 : options.clone) || (clone = !0), clone ? cloneDeep$2(data) : data;
|
|
63046
63148
|
}
|
|
63047
63149
|
parseNewData(data, options) {
|
|
63048
63150
|
this.parse(data, options || this.parseOption), this.reRunAllTransform();
|
|
@@ -63075,7 +63177,7 @@
|
|
|
63075
63177
|
|
|
63076
63178
|
const ignoreWhen = value => isDataView(value) || isHTMLElement(value);
|
|
63077
63179
|
function cloneDeepSpec(spec, excludeKeys = ["data"]) {
|
|
63078
|
-
return cloneDeep$
|
|
63180
|
+
return cloneDeep$2(spec, ignoreWhen, excludeKeys);
|
|
63079
63181
|
}
|
|
63080
63182
|
|
|
63081
63183
|
function transformLegendTitleAttributes(title) {
|
|
@@ -63390,9 +63492,24 @@
|
|
|
63390
63492
|
return layout._cellRangeMap.set(`$${col}$${row}`, cellRange), cellRange;
|
|
63391
63493
|
}
|
|
63392
63494
|
function getTreeTitleMerge(col, row, cellRange, layout) {
|
|
63495
|
+
var _a;
|
|
63393
63496
|
if ("tree" !== layout.rowHierarchyType) return;
|
|
63394
|
-
const
|
|
63395
|
-
|
|
63497
|
+
const table = layout._table,
|
|
63498
|
+
internalProps = table.internalProps || {},
|
|
63499
|
+
isGroupMode = !!internalProps.groupBy,
|
|
63500
|
+
cellRecord = table.getCellRawRecord(col, row);
|
|
63501
|
+
if (!(null == cellRecord ? void 0 : cellRecord.vtableMerge)) return;
|
|
63502
|
+
const treeTitleStartCol = internalProps.groupTitleCheckbox && internalProps.rowSeriesNumber ? layout.rowHeaderLevelCount + layout.leftRowSeriesNumberColumnCount : layout.rowHeaderLevelCount;
|
|
63503
|
+
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))) {
|
|
63504
|
+
const onlyColumn = layout.columnObjects[0],
|
|
63505
|
+
field = null == onlyColumn ? void 0 : onlyColumn.field;
|
|
63506
|
+
if (null != field) {
|
|
63507
|
+
let text = cellRecord.vtableMergeName;
|
|
63508
|
+
const groupTitleFieldFormat = internalProps.groupTitleFieldFormat;
|
|
63509
|
+
"function" == typeof groupTitleFieldFormat && (text = groupTitleFieldFormat(cellRecord, col, row, table));
|
|
63510
|
+
null == cellRecord[field] && null != text && (cellRecord[field] = text);
|
|
63511
|
+
}
|
|
63512
|
+
}
|
|
63396
63513
|
}
|
|
63397
63514
|
function getCellRangeTranspose(col, row, layout) {
|
|
63398
63515
|
var _a, _b, _c, _d;
|
|
@@ -64309,7 +64426,7 @@
|
|
|
64309
64426
|
this.listenersId.push(doubleClickEventId, clickEventId, selectedChangedEventId);
|
|
64310
64427
|
}
|
|
64311
64428
|
startEditCell(col, row, value, editElement) {
|
|
64312
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
64429
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
64313
64430
|
if (this.editingEditor) return;
|
|
64314
64431
|
const editor = this.table.getEditor(col, row);
|
|
64315
64432
|
if (editor) {
|
|
@@ -64325,7 +64442,8 @@
|
|
|
64325
64442
|
col: col,
|
|
64326
64443
|
row: row
|
|
64327
64444
|
}), this.table._makeVisibleCell(col, row), this.editingEditor = editor;
|
|
64328
|
-
const
|
|
64445
|
+
const customMergeText = null === (_j = this.table.getCustomMerge(col, row)) || void 0 === _j ? void 0 : _j.text,
|
|
64446
|
+
dataValue = isValid$2(value) ? value : isValid$2(customMergeText) ? customMergeText : this.table.getCellOriginValue(col, row),
|
|
64329
64447
|
rect = this.table.getCellRangeRelativeRect(this.table.getCellRange(col, row)),
|
|
64330
64448
|
referencePosition = {
|
|
64331
64449
|
rect: {
|
|
@@ -64335,9 +64453,9 @@
|
|
|
64335
64453
|
height: rect.height
|
|
64336
64454
|
}
|
|
64337
64455
|
};
|
|
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 === (
|
|
64456
|
+
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
64457
|
this.completeEdit();
|
|
64340
|
-
}), null === (
|
|
64458
|
+
}), null === (_m = editor.onStart) || void 0 === _m || _m.call(editor, {
|
|
64341
64459
|
value: dataValue,
|
|
64342
64460
|
endEdit: () => {
|
|
64343
64461
|
this.completeEdit();
|
|
@@ -64351,7 +64469,7 @@
|
|
|
64351
64469
|
}
|
|
64352
64470
|
}
|
|
64353
64471
|
completeEdit(e) {
|
|
64354
|
-
var _a, _b;
|
|
64472
|
+
var _a, _b, _c;
|
|
64355
64473
|
if (!this.editingEditor) return !0;
|
|
64356
64474
|
if (this.isValidatingValue) return !1;
|
|
64357
64475
|
this.cacheLastSelectedCellEditor = {};
|
|
@@ -64365,9 +64483,10 @@
|
|
|
64365
64483
|
if (this.editingEditor.getValue, this.editingEditor.validateValue) {
|
|
64366
64484
|
this.isValidatingValue = !0;
|
|
64367
64485
|
const newValue = this.editingEditor.getValue(),
|
|
64368
|
-
|
|
64486
|
+
customMergeText = null === (_a = this.table.getCustomMerge(this.editCell.col, this.editCell.row)) || void 0 === _a ? void 0 : _a.text,
|
|
64487
|
+
oldValue = isValid$2(customMergeText) ? customMergeText : this.table.getCellOriginValue(this.editCell.col, this.editCell.row),
|
|
64369
64488
|
target = null == e ? void 0 : e.target,
|
|
64370
|
-
maybePromiseOrValue = null === (
|
|
64489
|
+
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
64490
|
return isPromise(maybePromiseOrValue) ? (this.isValidatingValue = !0, new Promise((resolve, reject) => {
|
|
64372
64491
|
maybePromiseOrValue.then(result => {
|
|
64373
64492
|
dealWithValidateValue(result, this, oldValue, resolve);
|
|
@@ -64381,14 +64500,17 @@
|
|
|
64381
64500
|
doExit() {
|
|
64382
64501
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
64383
64502
|
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
|
-
|
|
64503
|
+
range = this.table.getCellRange(this.editCell.col, this.editCell.row);
|
|
64504
|
+
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 {
|
|
64505
|
+
const changedValues = [];
|
|
64506
|
+
for (let row = range.start.row; row <= range.end.row; row++) {
|
|
64507
|
+
const rowChangedValues = [];
|
|
64508
|
+
for (let col = range.start.col; col <= range.end.col; col++) rowChangedValues.push(changedValue);
|
|
64509
|
+
changedValues.push(rowChangedValues);
|
|
64510
|
+
}
|
|
64511
|
+
this.table.changeCellValues(range.start.col, range.start.row, changedValues);
|
|
64390
64512
|
}
|
|
64391
|
-
|
|
64513
|
+
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
64514
|
}
|
|
64393
64515
|
cancelEdit() {
|
|
64394
64516
|
var _a, _b, _c, _d;
|
|
@@ -64448,7 +64570,18 @@
|
|
|
64448
64570
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64449
64571
|
});
|
|
64450
64572
|
};
|
|
64573
|
+
function refreshCustomMergeCellGroups(table) {
|
|
64574
|
+
var _a;
|
|
64575
|
+
if (!Array.isArray(table.options.customMergeCell)) return;
|
|
64576
|
+
table.internalProps.customMergeCell = getCustomMergeCellFunc$1(table.options.customMergeCell);
|
|
64577
|
+
const merges = table.options.customMergeCell;
|
|
64578
|
+
for (let i = 0; i < merges.length; i++) {
|
|
64579
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
64580
|
+
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);
|
|
64581
|
+
}
|
|
64582
|
+
}
|
|
64451
64583
|
function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
|
|
64584
|
+
var _a, _b;
|
|
64452
64585
|
if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
|
|
64453
64586
|
const recordShowIndex = table.getRecordShowIndexByCell(col, row),
|
|
64454
64587
|
recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
|
|
@@ -64458,8 +64591,12 @@
|
|
|
64458
64591
|
beforeChangeValue = table.getCellRawValue(col, row),
|
|
64459
64592
|
oldValue = table.getCellOriginValue(col, row);
|
|
64460
64593
|
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
|
-
|
|
64594
|
+
const range = table.getCellRange(col, row);
|
|
64595
|
+
if (range.isCustom && range.start.col === col && range.start.row === row && Array.isArray(table.options.customMergeCell) && "function" == typeof table.getCellValue) {
|
|
64596
|
+
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);
|
|
64597
|
+
customMerge && (customMerge.text = value);
|
|
64598
|
+
}
|
|
64599
|
+
const aggregators = table.internalProps.layoutMap.getAggregatorsByCell(col, row);
|
|
64463
64600
|
if (aggregators) {
|
|
64464
64601
|
if (Array.isArray(aggregators)) for (let i = 0; i < (null == aggregators ? void 0 : aggregators.length); i++) aggregators[i].recalculate();else aggregators.recalculate();
|
|
64465
64602
|
const aggregatorCells = table.internalProps.layoutMap.getAggregatorCellAddress(range.start.col, range.start.row, range.end.col, range.end.row);
|
|
@@ -64682,7 +64819,13 @@
|
|
|
64682
64819
|
(void 0 === recordIndex || recordIndex > table.dataSource.sourceLength) && (recordIndex = table.dataSource.sourceLength);
|
|
64683
64820
|
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64684
64821
|
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)
|
|
64822
|
+
if (table.dataSource.addRecord(record, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1), syncToOriginalRecords) {
|
|
64823
|
+
if (!table.transpose) {
|
|
64824
|
+
const insertRowIndex = recordIndex + headerCount + table.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
64825
|
+
table.rowHeightsMap.insert(insertRowIndex);
|
|
64826
|
+
}
|
|
64827
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(!0), !0;
|
|
64828
|
+
}
|
|
64686
64829
|
const oldRowCount = table.rowCount;
|
|
64687
64830
|
if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
|
|
64688
64831
|
const newRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
@@ -64760,7 +64903,13 @@
|
|
|
64760
64903
|
void 0 === recordIndex || recordIndex > table.dataSource.sourceLength ? recordIndex = table.dataSource.sourceLength : recordIndex < 0 && (recordIndex = 0);
|
|
64761
64904
|
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64762
64905
|
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)
|
|
64906
|
+
if (table.dataSource.addRecords(records, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length), syncToOriginalRecords) {
|
|
64907
|
+
if (!table.transpose) {
|
|
64908
|
+
const insertRowIndex = recordIndex + headerCount + table.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
64909
|
+
for (let i = 0; i < records.length; i++) table.rowHeightsMap.insert(insertRowIndex);
|
|
64910
|
+
}
|
|
64911
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(!0), !0;
|
|
64912
|
+
}
|
|
64764
64913
|
const oldRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
64765
64914
|
if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
|
|
64766
64915
|
const newRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
@@ -64829,7 +64978,7 @@
|
|
|
64829
64978
|
}
|
|
64830
64979
|
}
|
|
64831
64980
|
function listTableDeleteRecords(recordIndexs, table) {
|
|
64832
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
64981
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
64833
64982
|
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
64983
|
const deletedRecordIndexs = null === (_d = (_c = table.dataSource).deleteRecordsForTree) || void 0 === _d ? void 0 : _d.call(_c, recordIndexs);
|
|
64835
64984
|
if (0 === deletedRecordIndexs.length) return;
|
|
@@ -64841,8 +64990,17 @@
|
|
|
64841
64990
|
const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
|
|
64842
64991
|
deletedRecordIndexs = table.dataSource.deleteRecords(recordIndexs, syncToOriginalRecords);
|
|
64843
64992
|
if (0 === deletedRecordIndexs.length) return;
|
|
64993
|
+
Array.isArray(table.options.customMergeCell) && (table.internalProps.customMergeCell = getCustomMergeCellFunc$1(table.options.customMergeCell));
|
|
64844
64994
|
for (let index = 0; index < deletedRecordIndexs.length; index++) adjustCheckBoxStateMapWithDeleteRecordIndex(table, deletedRecordIndexs[index], 1);
|
|
64845
|
-
if (syncToOriginalRecords)
|
|
64995
|
+
if (syncToOriginalRecords) {
|
|
64996
|
+
if (!table.transpose) {
|
|
64997
|
+
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64998
|
+
topAggregationCount = table.internalProps.layoutMap.hasAggregationOnTopCount,
|
|
64999
|
+
sorted = [...deletedRecordIndexs].sort((a, b) => b - a);
|
|
65000
|
+
for (let i = 0; i < sorted.length; i++) table.rowHeightsMap.delete(sorted[i] + headerCount + topAggregationCount);
|
|
65001
|
+
}
|
|
65002
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph(!0);
|
|
65003
|
+
}
|
|
64846
65004
|
const oldRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
64847
65005
|
table.refreshRowColCount();
|
|
64848
65006
|
const newRowCount = table.transpose ? table.colCount : table.rowCount,
|
|
@@ -64880,7 +65038,7 @@
|
|
|
64880
65038
|
col: 0,
|
|
64881
65039
|
row: row
|
|
64882
65040
|
});
|
|
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();
|
|
65041
|
+
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
65042
|
}
|
|
64885
65043
|
} else {
|
|
64886
65044
|
const delRows = [],
|
|
@@ -64898,6 +65056,42 @@
|
|
|
64898
65056
|
});
|
|
64899
65057
|
}
|
|
64900
65058
|
const updateRows = [];
|
|
65059
|
+
if (table.internalProps.customMergeCell) {
|
|
65060
|
+
const proxy = table.scenegraph.proxy,
|
|
65061
|
+
deletedIndexNums = (recordIndexsMinToMax[0], recordIndexsMinToMax.map(recordIndex => recordIndex + headerCount + topAggregationCount)),
|
|
65062
|
+
minIndexNum = deletedIndexNums[0];
|
|
65063
|
+
let updateMin = minIndexNum,
|
|
65064
|
+
updateMax = minIndexNum;
|
|
65065
|
+
if (Array.isArray(table.options.customMergeCell)) {
|
|
65066
|
+
const merges = table.options.customMergeCell,
|
|
65067
|
+
axis = table.transpose ? "col" : "row";
|
|
65068
|
+
merges.forEach(m => {
|
|
65069
|
+
const r = null == m ? void 0 : m.range;
|
|
65070
|
+
if ((null == r ? void 0 : r.start) && (null == r ? void 0 : r.end)) for (let i = 0; i < deletedIndexNums.length; i++) {
|
|
65071
|
+
const deleteIndex = deletedIndexNums[i];
|
|
65072
|
+
if (r.end[axis] >= deleteIndex - 1) {
|
|
65073
|
+
updateMin = Math.min(updateMin, r.start[axis]), updateMax = Math.max(updateMax, r.end[axis]);
|
|
65074
|
+
break;
|
|
65075
|
+
}
|
|
65076
|
+
}
|
|
65077
|
+
});
|
|
65078
|
+
}
|
|
65079
|
+
if (table.transpose) {
|
|
65080
|
+
const start = Math.max(updateMin, null !== (_j = null == proxy ? void 0 : proxy.colStart) && void 0 !== _j ? _j : updateMin),
|
|
65081
|
+
end = Math.min(updateMax, null !== (_k = null == proxy ? void 0 : proxy.colEnd) && void 0 !== _k ? _k : updateMax);
|
|
65082
|
+
for (let col = start; col <= end; col++) updateRows.push({
|
|
65083
|
+
col: col,
|
|
65084
|
+
row: 0
|
|
65085
|
+
});
|
|
65086
|
+
} else {
|
|
65087
|
+
const start = Math.max(updateMin, null !== (_l = null == proxy ? void 0 : proxy.rowStart) && void 0 !== _l ? _l : updateMin),
|
|
65088
|
+
end = Math.min(updateMax, null !== (_m = null == proxy ? void 0 : proxy.rowEnd) && void 0 !== _m ? _m : updateMax);
|
|
65089
|
+
for (let row = start; row <= end; row++) updateRows.push({
|
|
65090
|
+
col: 0,
|
|
65091
|
+
row: row
|
|
65092
|
+
});
|
|
65093
|
+
}
|
|
65094
|
+
}
|
|
64901
65095
|
for (let row = headerCount; row < headerCount + topAggregationCount; row++) table.transpose ? updateRows.push({
|
|
64902
65096
|
col: row,
|
|
64903
65097
|
row: 0
|
|
@@ -64912,7 +65106,7 @@
|
|
|
64912
65106
|
col: 0,
|
|
64913
65107
|
row: row
|
|
64914
65108
|
});
|
|
64915
|
-
null === (
|
|
65109
|
+
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
65110
|
}
|
|
64917
65111
|
}
|
|
64918
65112
|
}
|
|
@@ -64924,7 +65118,7 @@
|
|
|
64924
65118
|
const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
|
|
64925
65119
|
updateRecordIndexs = table.dataSource.updateRecords(records, recordIndexs, syncToOriginalRecords);
|
|
64926
65120
|
if (0 === updateRecordIndexs.length) return;
|
|
64927
|
-
if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph();
|
|
65121
|
+
if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph(!0);
|
|
64928
65122
|
const recordIndexsMinToMax = updateRecordIndexs.map(index => table.getBodyRowIndexByRecordIndex(index)).sort((a, b) => a - b);
|
|
64929
65123
|
if (table.pagination) {
|
|
64930
65124
|
const {
|
|
@@ -65247,10 +65441,33 @@
|
|
|
65247
65441
|
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
65442
|
}
|
|
65249
65443
|
addColumns(toAddColumns, colIndex, isMaintainArrayData = !0) {
|
|
65250
|
-
var _a;
|
|
65444
|
+
var _a, _b;
|
|
65251
65445
|
const columns = this.options.columns;
|
|
65446
|
+
if (Array.isArray(this.options.customMergeCell) && (null == toAddColumns ? void 0 : toAddColumns.length)) {
|
|
65447
|
+
const axis = this.transpose ? "row" : "col";
|
|
65448
|
+
let insertIndex = colIndex;
|
|
65449
|
+
void 0 === insertIndex ? insertIndex = columns.length : insertIndex < 0 ? insertIndex = 0 : insertIndex > columns.length && (insertIndex = columns.length);
|
|
65450
|
+
const toAddCount = toAddColumns.length,
|
|
65451
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
65452
|
+
range: {
|
|
65453
|
+
start: Object.assign({}, m.range.start),
|
|
65454
|
+
end: Object.assign({}, m.range.end)
|
|
65455
|
+
}
|
|
65456
|
+
}));
|
|
65457
|
+
for (let i = 0; i < merges.length; i++) {
|
|
65458
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
65459
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
65460
|
+
const start = r.start[axis],
|
|
65461
|
+
end = r.end[axis];
|
|
65462
|
+
end < insertIndex || (start > insertIndex ? (r.start[axis] = start + toAddCount, r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
|
|
65463
|
+
}
|
|
65464
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
65465
|
+
const r = null == m ? void 0 : m.range;
|
|
65466
|
+
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);
|
|
65467
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
65468
|
+
}
|
|
65252
65469
|
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 !== (
|
|
65470
|
+
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
65471
|
this.internalProps._colRangeWidthsMap.clear();
|
|
65255
65472
|
const resizedColIndexs = Array.from(this.internalProps._widthResizedColMap.keys());
|
|
65256
65473
|
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 +65480,46 @@
|
|
|
65263
65480
|
}
|
|
65264
65481
|
this.updateColumns(columns, {
|
|
65265
65482
|
clearRowHeightCache: !1
|
|
65266
|
-
}), this.
|
|
65483
|
+
}), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
65484
|
+
const r = null == m ? void 0 : m.range;
|
|
65485
|
+
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);
|
|
65486
|
+
}), this.scenegraph.updateNextFrame()), this.fireListeners(TABLE_EVENT_TYPE.ADD_COLUMN, {
|
|
65267
65487
|
columnIndex: colIndex,
|
|
65268
65488
|
columnCount: toAddColumns.length,
|
|
65269
65489
|
columns: columns
|
|
65270
65490
|
});
|
|
65271
65491
|
}
|
|
65272
65492
|
deleteColumns(deleteColIndexs, isMaintainArrayData = !0) {
|
|
65493
|
+
var _a;
|
|
65273
65494
|
const columns = this.options.columns;
|
|
65274
65495
|
deleteColIndexs.sort((a, b) => b - a);
|
|
65496
|
+
const deletedColumns = deleteColIndexs.map(idx => cloneDeepSpec(columns[idx], ["children"]));
|
|
65497
|
+
let deletedRecordValues;
|
|
65498
|
+
if (Array.isArray(this.options.customMergeCell) && (null == deleteColIndexs ? void 0 : deleteColIndexs.length)) {
|
|
65499
|
+
const axis = this.transpose ? "row" : "col",
|
|
65500
|
+
deleteIndexNums = deleteColIndexs.slice().sort((a, b) => a - b).map((idx, i) => idx - i),
|
|
65501
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
65502
|
+
range: {
|
|
65503
|
+
start: Object.assign({}, m.range.start),
|
|
65504
|
+
end: Object.assign({}, m.range.end)
|
|
65505
|
+
}
|
|
65506
|
+
}));
|
|
65507
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
65508
|
+
const deleteIndex = deleteIndexNums[i];
|
|
65509
|
+
for (let j = 0; j < merges.length; j++) {
|
|
65510
|
+
const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
|
|
65511
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
65512
|
+
const start = r.start[axis],
|
|
65513
|
+
end = r.end[axis];
|
|
65514
|
+
end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
|
|
65515
|
+
}
|
|
65516
|
+
}
|
|
65517
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
65518
|
+
const r = null == m ? void 0 : m.range;
|
|
65519
|
+
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);
|
|
65520
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
65521
|
+
}
|
|
65522
|
+
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
65523
|
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
65524
|
const record = this.records[j];
|
|
65277
65525
|
Array.isArray(record) && record.splice(deleteColIndexs[i], 1);
|
|
@@ -65287,7 +65535,9 @@
|
|
|
65287
65535
|
clearRowHeightCache: !1
|
|
65288
65536
|
}), this.fireListeners(TABLE_EVENT_TYPE.DELETE_COLUMN, {
|
|
65289
65537
|
deleteColIndexs: deleteColIndexs,
|
|
65290
|
-
columns: columns
|
|
65538
|
+
columns: columns,
|
|
65539
|
+
deletedColumns: deletedColumns,
|
|
65540
|
+
deletedRecordValues: deletedRecordValues
|
|
65291
65541
|
});
|
|
65292
65542
|
}
|
|
65293
65543
|
get columns() {
|
|
@@ -65675,9 +65925,9 @@
|
|
|
65675
65925
|
}
|
|
65676
65926
|
}
|
|
65677
65927
|
updateSortState(sortState, executeSort = !0) {
|
|
65678
|
-
var _a;
|
|
65679
|
-
|
|
65680
|
-
(
|
|
65928
|
+
var _a, _b, _c, _d, _e;
|
|
65929
|
+
const normalizedSortState = (Array.isArray(sortState) ? sortState : sortState ? [sortState] : []).filter(Boolean);
|
|
65930
|
+
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
65931
|
const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, item.field);
|
|
65682
65932
|
this.internalProps.layoutMap.headerObjects.find(col => col && col.field === item.field);
|
|
65683
65933
|
return {
|
|
@@ -65685,13 +65935,20 @@
|
|
|
65685
65935
|
order: item.order,
|
|
65686
65936
|
orderFn: null != sortFunc ? sortFunc : defaultOrderFn
|
|
65687
65937
|
};
|
|
65688
|
-
})), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell())
|
|
65938
|
+
})), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell());else {
|
|
65939
|
+
const ds = this.dataSource,
|
|
65940
|
+
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;
|
|
65941
|
+
(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({
|
|
65942
|
+
length: sourceLength
|
|
65943
|
+
}, (_, 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();
|
|
65944
|
+
}
|
|
65945
|
+
this.stateManager.updateSortState(normalizedSortState);
|
|
65689
65946
|
}
|
|
65690
65947
|
updateFilterRules(filterRules, options = {
|
|
65691
65948
|
clearRowHeightCache: !0
|
|
65692
65949
|
}) {
|
|
65693
65950
|
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();
|
|
65951
|
+
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
65952
|
}
|
|
65696
65953
|
getFilteredRecords() {
|
|
65697
65954
|
return this.dataSource.records;
|
|
@@ -65966,30 +66223,112 @@
|
|
|
65966
66223
|
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
66224
|
}
|
|
65968
66225
|
addRecord(record, recordIndex, triggerEvent = !0) {
|
|
65969
|
-
var _a;
|
|
66226
|
+
var _a, _b;
|
|
66227
|
+
if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex) {
|
|
66228
|
+
const axis = this.transpose ? "col" : "row",
|
|
66229
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66230
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
66231
|
+
let insertIndex = recordIndex;
|
|
66232
|
+
void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
|
|
66233
|
+
const insertIndexNum = insertIndex + headerCount + topAggregationCount,
|
|
66234
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
66235
|
+
range: {
|
|
66236
|
+
start: Object.assign({}, m.range.start),
|
|
66237
|
+
end: Object.assign({}, m.range.end)
|
|
66238
|
+
}
|
|
66239
|
+
}));
|
|
66240
|
+
for (let i = 0; i < merges.length; i++) {
|
|
66241
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
66242
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66243
|
+
const start = r.start[axis],
|
|
66244
|
+
end = r.end[axis];
|
|
66245
|
+
end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + 1, r.end[axis] = end + 1) : r.end[axis] = end + 1);
|
|
66246
|
+
}
|
|
66247
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66248
|
+
const r = null == m ? void 0 : m.range;
|
|
66249
|
+
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);
|
|
66250
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66251
|
+
}
|
|
65970
66252
|
const success = listTableAddRecord(record, recordIndex, this);
|
|
65971
|
-
adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (
|
|
66253
|
+
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 => {
|
|
66254
|
+
const r = null == m ? void 0 : m.range;
|
|
66255
|
+
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);
|
|
66256
|
+
}), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
|
|
65972
66257
|
records: [record],
|
|
65973
66258
|
recordIndex: recordIndex,
|
|
65974
66259
|
recordCount: 1
|
|
65975
66260
|
});
|
|
65976
66261
|
}
|
|
65977
66262
|
addRecords(records, recordIndex, triggerEvent = !0) {
|
|
65978
|
-
var _a;
|
|
66263
|
+
var _a, _b;
|
|
66264
|
+
if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex && (null == records ? void 0 : records.length)) {
|
|
66265
|
+
const axis = this.transpose ? "col" : "row",
|
|
66266
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66267
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
66268
|
+
let insertIndex = recordIndex;
|
|
66269
|
+
void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
|
|
66270
|
+
const insertIndexNum = insertIndex + headerCount + topAggregationCount,
|
|
66271
|
+
toAddCount = records.length,
|
|
66272
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
66273
|
+
range: {
|
|
66274
|
+
start: Object.assign({}, m.range.start),
|
|
66275
|
+
end: Object.assign({}, m.range.end)
|
|
66276
|
+
}
|
|
66277
|
+
}));
|
|
66278
|
+
for (let i = 0; i < merges.length; i++) {
|
|
66279
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
66280
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66281
|
+
const start = r.start[axis],
|
|
66282
|
+
end = r.end[axis];
|
|
66283
|
+
end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + toAddCount, r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
|
|
66284
|
+
}
|
|
66285
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66286
|
+
const r = null == m ? void 0 : m.range;
|
|
66287
|
+
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);
|
|
66288
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66289
|
+
}
|
|
65979
66290
|
const success = listTableAddRecords(records, recordIndex, this);
|
|
65980
|
-
"number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (
|
|
66291
|
+
"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 => {
|
|
66292
|
+
const r = null == m ? void 0 : m.range;
|
|
66293
|
+
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);
|
|
66294
|
+
}), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
|
|
65981
66295
|
records: records,
|
|
65982
66296
|
recordIndex: recordIndex,
|
|
65983
66297
|
recordCount: records.length
|
|
65984
66298
|
});
|
|
65985
66299
|
}
|
|
65986
66300
|
deleteRecords(recordIndexs, triggerEvent = !0) {
|
|
65987
|
-
var _a;
|
|
65988
|
-
const
|
|
65989
|
-
|
|
66301
|
+
var _a, _b;
|
|
66302
|
+
const prevMergeRanges = Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map(m => null == m ? void 0 : m.range).filter(Boolean).map(r => ({
|
|
66303
|
+
start: Object.assign({}, r.start),
|
|
66304
|
+
end: Object.assign({}, r.end)
|
|
66305
|
+
})) : [],
|
|
66306
|
+
deletedRecords = [];
|
|
66307
|
+
if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0 && recordIndexs.forEach(index => {
|
|
65990
66308
|
let record = null;
|
|
65991
66309
|
record = "number" == typeof index ? this.dataSource.get(index) : [], deletedRecords.push(record);
|
|
65992
|
-
}),
|
|
66310
|
+
}), Array.isArray(this.options.customMergeCell) && (null == recordIndexs ? void 0 : recordIndexs.length) && "number" == typeof recordIndexs[0]) {
|
|
66311
|
+
const axis = this.transpose ? "col" : "row",
|
|
66312
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66313
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount,
|
|
66314
|
+
deleteIndexNums = recordIndexs.slice().sort((a, b) => a - b).map((index, i) => index + headerCount + topAggregationCount - i),
|
|
66315
|
+
merges = this.options.customMergeCell;
|
|
66316
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
66317
|
+
const deleteIndex = deleteIndexNums[i];
|
|
66318
|
+
for (let j = 0; j < merges.length; j++) {
|
|
66319
|
+
const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
|
|
66320
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66321
|
+
const start = r.start[axis],
|
|
66322
|
+
end = r.end[axis];
|
|
66323
|
+
end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
|
|
66324
|
+
}
|
|
66325
|
+
}
|
|
66326
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66327
|
+
const r = null == m ? void 0 : m.range;
|
|
66328
|
+
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);
|
|
66329
|
+
});
|
|
66330
|
+
}
|
|
66331
|
+
listTableDeleteRecords(recordIndexs, this), adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible();
|
|
65993
66332
|
const rowIndexs = [];
|
|
65994
66333
|
for (let i = 0; i < recordIndexs.length; i++) rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
|
|
65995
66334
|
triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
|
|
@@ -65997,7 +66336,16 @@
|
|
|
65997
66336
|
records: deletedRecords,
|
|
65998
66337
|
rowIndexs: rowIndexs,
|
|
65999
66338
|
deletedCount: (Array.isArray(recordIndexs[0]), recordIndexs.length)
|
|
66000
|
-
})
|
|
66339
|
+
}), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
66340
|
+
const r = null == m ? void 0 : m.range;
|
|
66341
|
+
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);
|
|
66342
|
+
}), this.scenegraph.updateNextFrame(), setTimeout(() => {
|
|
66343
|
+
if (!this.internalProps || !this.options || !this.scenegraph) return;
|
|
66344
|
+
Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell));
|
|
66345
|
+
[...prevMergeRanges, ...(Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map(m => null == m ? void 0 : m.range) : [])].filter(Boolean).forEach(r => {
|
|
66346
|
+
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);
|
|
66347
|
+
}), this.scenegraph.updateNextFrame();
|
|
66348
|
+
}, 0));
|
|
66001
66349
|
}
|
|
66002
66350
|
updateRecords(records, recordIndexs, triggerEvent = !0) {
|
|
66003
66351
|
listTableUpdateRecords(records, recordIndexs, this), triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
|
|
@@ -66099,9 +66447,14 @@
|
|
|
66099
66447
|
row: endRow
|
|
66100
66448
|
}
|
|
66101
66449
|
}
|
|
66102
|
-
}), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
|
|
66450
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66103
66451
|
for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
|
|
66104
|
-
this.scenegraph.updateNextFrame()
|
|
66452
|
+
this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE.MERGE_CELLS, {
|
|
66453
|
+
startCol: startCol,
|
|
66454
|
+
startRow: startRow,
|
|
66455
|
+
endCol: endCol,
|
|
66456
|
+
endRow: endRow
|
|
66457
|
+
});
|
|
66105
66458
|
}
|
|
66106
66459
|
unmergeCells(startCol, startRow, endCol, endRow) {
|
|
66107
66460
|
this.options.customMergeCell ? "function" == typeof this.options.customMergeCell && (this.options.customMergeCell = []) : this.options.customMergeCell = [], this.options.customMergeCell = this.options.customMergeCell.filter(item => {
|
|
@@ -66110,9 +66463,14 @@
|
|
|
66110
66463
|
end: end
|
|
66111
66464
|
} = item.range;
|
|
66112
66465
|
return !(start.col === startCol && start.row === startRow && end.col === endCol && end.row === endRow);
|
|
66113
|
-
}), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
|
|
66466
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66114
66467
|
for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
|
|
66115
|
-
this.scenegraph.updateNextFrame()
|
|
66468
|
+
this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE.UNMERGE_CELLS, {
|
|
66469
|
+
startCol: startCol,
|
|
66470
|
+
startRow: startRow,
|
|
66471
|
+
endCol: endCol,
|
|
66472
|
+
endRow: endRow
|
|
66473
|
+
});
|
|
66116
66474
|
}
|
|
66117
66475
|
}
|
|
66118
66476
|
|
|
@@ -66913,7 +67271,7 @@
|
|
|
66913
67271
|
class DiscreteTableLegend {
|
|
66914
67272
|
constructor(option, table) {
|
|
66915
67273
|
var _a, _b, _c, _d;
|
|
66916
|
-
this.table = table, this.option = cloneDeep$
|
|
67274
|
+
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
67275
|
}
|
|
66918
67276
|
createComponent() {
|
|
66919
67277
|
const attrs = this.getLegendAttributes({
|
|
@@ -67162,7 +67520,7 @@
|
|
|
67162
67520
|
class ContinueTableLegend {
|
|
67163
67521
|
constructor(option, table) {
|
|
67164
67522
|
var _a, _b, _c, _d;
|
|
67165
|
-
this.table = table, this.option = cloneDeep$
|
|
67523
|
+
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
67524
|
}
|
|
67167
67525
|
createComponent() {
|
|
67168
67526
|
const attrs = this.getLegendAttributes({
|
|
@@ -72131,7 +72489,10 @@
|
|
|
72131
72489
|
}
|
|
72132
72490
|
}), table.updateFilterRules([...this.filterFuncRule, ...this.filterValueRule], {
|
|
72133
72491
|
clearRowHeightCache: !1,
|
|
72134
|
-
onFilterRecordsEnd: null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.onFilterRecordsEnd
|
|
72492
|
+
onFilterRecordsEnd: (null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.onFilterRecordsEnd) ? records => {
|
|
72493
|
+
var _a, _b;
|
|
72494
|
+
return null === (_b = (_a = this.pluginOptions).onFilterRecordsEnd) || void 0 === _b || _b.call(_a, records), records;
|
|
72495
|
+
} : void 0
|
|
72135
72496
|
});
|
|
72136
72497
|
}
|
|
72137
72498
|
createFilterFunction(filter) {
|
|
@@ -72223,6 +72584,79 @@
|
|
|
72223
72584
|
getAllFilterStates() {
|
|
72224
72585
|
return this.state;
|
|
72225
72586
|
}
|
|
72587
|
+
getSnapshot() {
|
|
72588
|
+
const filters = [];
|
|
72589
|
+
return this.state.filters.forEach(v => {
|
|
72590
|
+
const next = Object.assign({}, v);
|
|
72591
|
+
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);
|
|
72592
|
+
}), filters.sort((a, b) => String(a.field).localeCompare(String(b.field))), {
|
|
72593
|
+
filters: filters
|
|
72594
|
+
};
|
|
72595
|
+
}
|
|
72596
|
+
applySnapshot(snapshot, actionType = FilterActionType.APPLY_FILTERS) {
|
|
72597
|
+
var _a;
|
|
72598
|
+
const next = new Map();
|
|
72599
|
+
(null !== (_a = null == snapshot ? void 0 : snapshot.filters) && void 0 !== _a ? _a : []).forEach(cfg => {
|
|
72600
|
+
if (!cfg) return;
|
|
72601
|
+
const cloned = Object.assign({}, cfg);
|
|
72602
|
+
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);
|
|
72603
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72604
|
+
filters: next
|
|
72605
|
+
}), this.applyFilters(), this.notifyListeners({
|
|
72606
|
+
type: actionType,
|
|
72607
|
+
payload: {
|
|
72608
|
+
fromSnapshot: !0
|
|
72609
|
+
}
|
|
72610
|
+
});
|
|
72611
|
+
}
|
|
72612
|
+
shiftFieldsOnAddColumns(columnIndex, columnCount) {
|
|
72613
|
+
if (!Number.isFinite(columnIndex) || !Number.isFinite(columnCount) || columnCount <= 0) return;
|
|
72614
|
+
const next = new Map();
|
|
72615
|
+
this.state.filters.forEach((cfg, key) => {
|
|
72616
|
+
let newKey = key;
|
|
72617
|
+
const cloned = Object.assign({}, cfg);
|
|
72618
|
+
"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);
|
|
72619
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72620
|
+
filters: next
|
|
72621
|
+
});
|
|
72622
|
+
}
|
|
72623
|
+
shiftFieldsOnDeleteColumns(deleteColIndexs) {
|
|
72624
|
+
if (!Array.isArray(deleteColIndexs) || 0 === deleteColIndexs.length) return;
|
|
72625
|
+
const deleteIndexNums = deleteColIndexs.slice().filter(n => Number.isFinite(n)).sort((a, b) => a - b).map((idx, i) => idx - i),
|
|
72626
|
+
next = new Map();
|
|
72627
|
+
this.state.filters.forEach((cfg, key) => {
|
|
72628
|
+
let newKey = key;
|
|
72629
|
+
const cloned = Object.assign({}, cfg);
|
|
72630
|
+
let removed = !1;
|
|
72631
|
+
if ("number" == typeof newKey) {
|
|
72632
|
+
let k = newKey;
|
|
72633
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
72634
|
+
const d = deleteIndexNums[i];
|
|
72635
|
+
if (k === d) {
|
|
72636
|
+
removed = !0;
|
|
72637
|
+
break;
|
|
72638
|
+
}
|
|
72639
|
+
k > d && (k -= 1);
|
|
72640
|
+
}
|
|
72641
|
+
newKey = k;
|
|
72642
|
+
}
|
|
72643
|
+
if ("number" == typeof cloned.field) {
|
|
72644
|
+
let f = cloned.field;
|
|
72645
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
72646
|
+
const d = deleteIndexNums[i];
|
|
72647
|
+
if (f === d) {
|
|
72648
|
+
removed = !0;
|
|
72649
|
+
break;
|
|
72650
|
+
}
|
|
72651
|
+
f > d && (f -= 1);
|
|
72652
|
+
}
|
|
72653
|
+
cloned.field = f;
|
|
72654
|
+
}
|
|
72655
|
+
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));
|
|
72656
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72657
|
+
filters: next
|
|
72658
|
+
});
|
|
72659
|
+
}
|
|
72226
72660
|
reapplyCurrentFilters() {
|
|
72227
72661
|
this.getActiveFilterFields().length > 0 && this.applyFilters();
|
|
72228
72662
|
}
|
|
@@ -72499,7 +72933,7 @@
|
|
|
72499
72933
|
}), this.candidateKeys.set(candidateField, countMap), this.toUnformattedCache.set(candidateField, toUnformatted);
|
|
72500
72934
|
}
|
|
72501
72935
|
toggleSelectAll(fieldId, selected) {
|
|
72502
|
-
this.valueFilterOptionList.get(fieldId).forEach(option => {
|
|
72936
|
+
(this.valueFilterOptionList.get(fieldId) || []).forEach(option => {
|
|
72503
72937
|
"none" !== option.itemContainer.style.display && (option.checkbox.checked = selected);
|
|
72504
72938
|
});
|
|
72505
72939
|
}
|
|
@@ -72510,7 +72944,7 @@
|
|
|
72510
72944
|
this.selectAllCheckbox.checked = allChecked, this.selectAllCheckbox.indeterminate = !allChecked && !noneChecked;
|
|
72511
72945
|
}
|
|
72512
72946
|
onSearch(fieldId, value) {
|
|
72513
|
-
const items = this.valueFilterOptionList.get(fieldId),
|
|
72947
|
+
const items = this.valueFilterOptionList.get(fieldId) || [],
|
|
72514
72948
|
filterKeywords = value.toUpperCase().split(" ").filter(s => s);
|
|
72515
72949
|
for (const item of items) {
|
|
72516
72950
|
const txtValue = item.id.toUpperCase() || "",
|
|
@@ -72520,48 +72954,19 @@
|
|
|
72520
72954
|
}
|
|
72521
72955
|
}
|
|
72522
72956
|
syncSingleStateFromTableData(fieldId) {
|
|
72523
|
-
|
|
72524
|
-
const selectedValues = new Set(),
|
|
72525
|
-
originalValues = new Set();
|
|
72957
|
+
const originalValues = new Set();
|
|
72526
72958
|
this.table.internalProps.records.forEach(record => {
|
|
72527
72959
|
isValid$2(record) && originalValues.add(record[fieldId]);
|
|
72528
72960
|
});
|
|
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
|
-
}));
|
|
72961
|
+
const current = this.filterStateManager.getFilterState(fieldId);
|
|
72962
|
+
if ("byValue" === (null == current ? void 0 : current.type) && Array.isArray(current.values)) this.selectedKeys.set(fieldId, new Set(current.values));else {
|
|
72963
|
+
if ("byCondition" === (null == current ? void 0 : current.type) && current.enable) {
|
|
72964
|
+
const visibleValues = new Set();
|
|
72965
|
+
return this.getRecords(this.table, !1).forEach(record => {
|
|
72966
|
+
isValid$2(record) && visibleValues.add(record[fieldId]);
|
|
72967
|
+
}), void this.selectedKeys.set(fieldId, visibleValues);
|
|
72550
72968
|
}
|
|
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);
|
|
72969
|
+
this.selectedKeys.set(fieldId, originalValues);
|
|
72565
72970
|
}
|
|
72566
72971
|
}
|
|
72567
72972
|
applyFilter(fieldId = this.selectedField) {
|
|
@@ -72914,12 +73319,13 @@
|
|
|
72914
73319
|
|
|
72915
73320
|
class FilterToolbar {
|
|
72916
73321
|
constructor(table, filterStateManager, pluginOptions) {
|
|
73322
|
+
var _a;
|
|
72917
73323
|
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue", this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.hide = (currentCol, currentRow) => {
|
|
72918
73324
|
this.filterMenu.style.display = "none", this.isVisible = !1, this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {
|
|
72919
73325
|
col: null != currentCol ? currentCol : this.currentCol,
|
|
72920
73326
|
row: null != currentRow ? currentRow : this.currentRow
|
|
72921
73327
|
});
|
|
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 => {
|
|
73328
|
+
}, 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
73329
|
this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
|
|
72924
73330
|
});
|
|
72925
73331
|
}
|
|
@@ -72937,6 +73343,18 @@
|
|
|
72937
73343
|
clearFilter(field) {
|
|
72938
73344
|
this.valueFilter && this.valueFilter.clearFilter(field), this.conditionFilter && this.conditionFilter.clearFilter(field), this.hide();
|
|
72939
73345
|
}
|
|
73346
|
+
recordHistory(before, after) {
|
|
73347
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
73348
|
+
if (JSON.stringify(before) === JSON.stringify(after)) return;
|
|
73349
|
+
const pm = this.table.pluginManager,
|
|
73350
|
+
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");
|
|
73351
|
+
null === (_h = null == history ? void 0 : history.recordExternalCommand) || void 0 === _h || _h.call(history, {
|
|
73352
|
+
type: "filter",
|
|
73353
|
+
pluginId: this.pluginId,
|
|
73354
|
+
oldSnapshot: before,
|
|
73355
|
+
newSnapshot: after
|
|
73356
|
+
});
|
|
73357
|
+
}
|
|
72940
73358
|
updateClearFilterButtonState(field) {
|
|
72941
73359
|
const currentFilter = this.filterStateManager.getFilterState(field),
|
|
72942
73360
|
hasActiveFilter = currentFilter && currentFilter.enable;
|
|
@@ -72963,9 +73381,16 @@
|
|
|
72963
73381
|
}), this.filterTabByCondition.addEventListener("click", () => {
|
|
72964
73382
|
this.onTabSwitch("byCondition");
|
|
72965
73383
|
}), this.cancelFilterButton.addEventListener("click", () => this.hide()), this.clearFilterOptionLink.addEventListener("click", e => {
|
|
72966
|
-
e.preventDefault()
|
|
73384
|
+
e.preventDefault();
|
|
73385
|
+
const before = this.filterStateManager.getSnapshot();
|
|
73386
|
+
this.clearFilter(this.selectedField);
|
|
73387
|
+
const after = this.filterStateManager.getSnapshot();
|
|
73388
|
+
this.recordHistory(before, after);
|
|
72967
73389
|
}), this.applyFilterButton.addEventListener("click", () => {
|
|
73390
|
+
const before = this.filterStateManager.getSnapshot();
|
|
72968
73391
|
this.applyFilter(this.selectedField);
|
|
73392
|
+
const after = this.filterStateManager.getSnapshot();
|
|
73393
|
+
this.recordHistory(before, after);
|
|
72969
73394
|
}), document.addEventListener("click", () => {
|
|
72970
73395
|
this.isVisible && this.hide();
|
|
72971
73396
|
}), this.filterMenu.addEventListener("click", e => {
|
|
@@ -72990,7 +73415,7 @@
|
|
|
72990
73415
|
const field = this.table.internalProps.layoutMap.getHeaderField(col, row);
|
|
72991
73416
|
this.updateSelectedField(field);
|
|
72992
73417
|
const currentFilter = this.filterStateManager.getFilterState(field);
|
|
72993
|
-
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"), this.updateClearFilterButtonState(field), setTimeout(() => {
|
|
73418
|
+
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.filterModes.includes("byValue") && this.onTabSwitch("byValue"), this.updateClearFilterButtonState(field), setTimeout(() => {
|
|
72994
73419
|
this.isVisible = !0, this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_SHOW, {
|
|
72995
73420
|
col: col,
|
|
72996
73421
|
row: row
|
|
@@ -82471,7 +82896,7 @@
|
|
|
82471
82896
|
class FilterPlugin {
|
|
82472
82897
|
constructor(pluginOptions) {
|
|
82473
82898
|
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 : {
|
|
82899
|
+
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
82900
|
name: "filter-icon",
|
|
82476
82901
|
type: "svg",
|
|
82477
82902
|
width: 12,
|
|
@@ -82497,7 +82922,7 @@
|
|
|
82497
82922
|
});
|
|
82498
82923
|
}
|
|
82499
82924
|
run(...args) {
|
|
82500
|
-
var _a, _b, _c, _d, _e;
|
|
82925
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
82501
82926
|
const eventArgs = args[0],
|
|
82502
82927
|
runtime = args[1],
|
|
82503
82928
|
table = args[2];
|
|
@@ -82505,20 +82930,43 @@
|
|
|
82505
82930
|
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
82931
|
const col = eventArgs.col,
|
|
82507
82932
|
row = eventArgs.row;
|
|
82508
|
-
this.filterToolbar.isVisible ? this.filterToolbar.hide(eventArgs.col, eventArgs.row) :
|
|
82509
|
-
col: eventArgs.col,
|
|
82510
|
-
row: eventArgs.row
|
|
82511
|
-
}));
|
|
82933
|
+
this.filterToolbar.isVisible ? this.filterToolbar.hide(eventArgs.col, eventArgs.row) : this.filterToolbar.show(col, row, this.pluginOptions.filterModes);
|
|
82512
82934
|
} else if (runtime === TABLE_EVENT_TYPE.SCROLL) "horizontal" === eventArgs.scrollDirection && this.filterToolbar.adjustMenuPosition();else if (runtime === TABLE_EVENT_TYPE.CHANGE_CELL_VALUE) {
|
|
82513
82935
|
const changedField = this.table.getHeaderField(eventArgs.col, eventArgs.row);
|
|
82514
82936
|
this.syncFilterWithTableData(changedField);
|
|
82515
|
-
} else (runtime === TABLE_EVENT_TYPE.UPDATE_RECORD
|
|
82937
|
+
} else if (runtime === TABLE_EVENT_TYPE.UPDATE_RECORD) this.syncFilterWithTableData();else if (runtime === TABLE_EVENT_TYPE.ADD_RECORD) {
|
|
82938
|
+
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)) {
|
|
82939
|
+
const ds = this.table.dataSource;
|
|
82940
|
+
eventArgs.records.forEach(r => {
|
|
82941
|
+
var _a;
|
|
82942
|
+
return null === (_a = null == ds ? void 0 : ds.markForceVisibleRecord) || void 0 === _a ? void 0 : _a.call(ds, r);
|
|
82943
|
+
});
|
|
82944
|
+
}
|
|
82945
|
+
this.syncFilterWithTableData();
|
|
82946
|
+
} else if (runtime === TABLE_EVENT_TYPE.DELETE_RECORD) this.syncFilterWithTableData();else if (runtime === TABLE_EVENT_TYPE.ADD_COLUMN) {
|
|
82947
|
+
const columnIndex = null == eventArgs ? void 0 : eventArgs.columnIndex,
|
|
82948
|
+
columnCount = null == eventArgs ? void 0 : eventArgs.columnCount;
|
|
82949
|
+
"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();
|
|
82950
|
+
} else if (runtime === TABLE_EVENT_TYPE.DELETE_COLUMN) {
|
|
82951
|
+
const deleteColIndexs = null == eventArgs ? void 0 : eventArgs.deleteColIndexs;
|
|
82952
|
+
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();
|
|
82953
|
+
}
|
|
82516
82954
|
}
|
|
82517
82955
|
updatePluginOptions(pluginOptions) {
|
|
82518
82956
|
this.pluginOptions = lodashExports.merge(this.pluginOptions, pluginOptions), this.filterToolbar.updateStyles(this.pluginOptions.styles), this.table.updateColumns(this.columns, {
|
|
82519
82957
|
clearRowHeightCache: !1
|
|
82520
82958
|
});
|
|
82521
82959
|
}
|
|
82960
|
+
getFilterSnapshot() {
|
|
82961
|
+
var _a, _b, _c;
|
|
82962
|
+
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 : {
|
|
82963
|
+
filters: []
|
|
82964
|
+
};
|
|
82965
|
+
}
|
|
82966
|
+
applyFilterSnapshot(snapshot) {
|
|
82967
|
+
var _a, _b;
|
|
82968
|
+
null === (_b = null === (_a = this.filterStateManager) || void 0 === _a ? void 0 : _a.applySnapshot) || void 0 === _b || _b.call(_a, snapshot, FilterActionType.APPLY_FILTERS);
|
|
82969
|
+
}
|
|
82522
82970
|
update() {
|
|
82523
82971
|
this.filterStateManager && this.reapplyActiveFilters();
|
|
82524
82972
|
}
|
|
@@ -83630,10 +84078,10 @@
|
|
|
83630
84078
|
* console.log(deep[0] === objects[0]);
|
|
83631
84079
|
* // => false
|
|
83632
84080
|
*/
|
|
83633
|
-
function cloneDeep(value) {
|
|
84081
|
+
function cloneDeep$1(value) {
|
|
83634
84082
|
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
|
|
83635
84083
|
}
|
|
83636
|
-
var cloneDeep_1 = cloneDeep;
|
|
84084
|
+
var cloneDeep_1 = cloneDeep$1;
|
|
83637
84085
|
var deepClone = /*@__PURE__*/getDefaultExportFromCjs(cloneDeep_1);
|
|
83638
84086
|
|
|
83639
84087
|
const chnNumChar = {
|
|
@@ -84764,6 +85212,1200 @@
|
|
|
84764
85212
|
}
|
|
84765
85213
|
}
|
|
84766
85214
|
|
|
85215
|
+
function makeCellKey(sheetKey, row, col) {
|
|
85216
|
+
return `${sheetKey}:${row}:${col}`;
|
|
85217
|
+
}
|
|
85218
|
+
function parseA1Notation(a1) {
|
|
85219
|
+
const match = a1.match(/^([A-Z]+)([0-9]+)$/i);
|
|
85220
|
+
if (!match) return null;
|
|
85221
|
+
const letters = match[1].toUpperCase(),
|
|
85222
|
+
rowNumber = parseInt(match[2], 10);
|
|
85223
|
+
if (!rowNumber || rowNumber < 1) return null;
|
|
85224
|
+
let col = 0;
|
|
85225
|
+
for (let i = 0; i < letters.length; i++) col = 26 * col + (letters.charCodeAt(i) - 64);
|
|
85226
|
+
return {
|
|
85227
|
+
row: rowNumber - 1,
|
|
85228
|
+
col: col - 1
|
|
85229
|
+
};
|
|
85230
|
+
}
|
|
85231
|
+
function captureCellPreChangeContent(args) {
|
|
85232
|
+
const {
|
|
85233
|
+
sheetKey: sheetKey,
|
|
85234
|
+
row: row,
|
|
85235
|
+
col: col,
|
|
85236
|
+
currentValue: currentValue,
|
|
85237
|
+
formulaManager: formulaManager,
|
|
85238
|
+
store: store
|
|
85239
|
+
} = args;
|
|
85240
|
+
if (!sheetKey) return;
|
|
85241
|
+
const cellKey = makeCellKey(sheetKey, row, col);
|
|
85242
|
+
if (null == formulaManager ? void 0 : formulaManager.getCellFormula) try {
|
|
85243
|
+
const oldFormula = formulaManager.getCellFormula({
|
|
85244
|
+
sheet: sheetKey,
|
|
85245
|
+
row: row,
|
|
85246
|
+
col: col
|
|
85247
|
+
});
|
|
85248
|
+
if (oldFormula) {
|
|
85249
|
+
const normalized = "string" != typeof oldFormula || oldFormula.startsWith("=") ? oldFormula : `=${oldFormula}`;
|
|
85250
|
+
return void store.set(cellKey, normalized);
|
|
85251
|
+
}
|
|
85252
|
+
} catch (_a) {}
|
|
85253
|
+
store.set(cellKey, null == currentValue ? "" : currentValue);
|
|
85254
|
+
}
|
|
85255
|
+
function popCellPreChangeContent(args) {
|
|
85256
|
+
const {
|
|
85257
|
+
sheetKey: sheetKey,
|
|
85258
|
+
row: row,
|
|
85259
|
+
col: col,
|
|
85260
|
+
fallbackOldContent: fallbackOldContent,
|
|
85261
|
+
store: store
|
|
85262
|
+
} = args;
|
|
85263
|
+
if (!sheetKey) return fallbackOldContent;
|
|
85264
|
+
const cellKey = makeCellKey(sheetKey, row, col),
|
|
85265
|
+
oldContent = store.get(cellKey);
|
|
85266
|
+
return store.delete(cellKey), void 0 !== oldContent ? oldContent : fallbackOldContent;
|
|
85267
|
+
}
|
|
85268
|
+
function applyCellContent(args) {
|
|
85269
|
+
const {
|
|
85270
|
+
table: table,
|
|
85271
|
+
sheetKey: sheetKey,
|
|
85272
|
+
row: row,
|
|
85273
|
+
col: col,
|
|
85274
|
+
content: content,
|
|
85275
|
+
formulaManager: formulaManager
|
|
85276
|
+
} = args;
|
|
85277
|
+
if (sheetKey && (null == formulaManager ? void 0 : formulaManager.setCellContent) && (null == formulaManager ? void 0 : formulaManager.getCellValue)) {
|
|
85278
|
+
try {
|
|
85279
|
+
formulaManager.setCellContent({
|
|
85280
|
+
sheet: sheetKey,
|
|
85281
|
+
row: row,
|
|
85282
|
+
col: col
|
|
85283
|
+
}, content);
|
|
85284
|
+
} catch (_a) {
|
|
85285
|
+
return void table.changeCellValue(col, row, content, !1, !1, !0);
|
|
85286
|
+
}
|
|
85287
|
+
if ("string" == typeof content && content.startsWith("=")) {
|
|
85288
|
+
const result = formulaManager.getCellValue({
|
|
85289
|
+
sheet: sheetKey,
|
|
85290
|
+
row: row,
|
|
85291
|
+
col: col
|
|
85292
|
+
}),
|
|
85293
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
85294
|
+
return table.changeCellValue(col, row, display, !1, !1, !0), void refreshDependentDisplays({
|
|
85295
|
+
table: table,
|
|
85296
|
+
sheetKey: sheetKey,
|
|
85297
|
+
startCell: {
|
|
85298
|
+
sheet: sheetKey,
|
|
85299
|
+
row: row,
|
|
85300
|
+
col: col
|
|
85301
|
+
},
|
|
85302
|
+
formulaManager: formulaManager
|
|
85303
|
+
});
|
|
85304
|
+
}
|
|
85305
|
+
return table.changeCellValue(col, row, content, !1, !1, !0), void refreshDependentDisplays({
|
|
85306
|
+
table: table,
|
|
85307
|
+
sheetKey: sheetKey,
|
|
85308
|
+
startCell: {
|
|
85309
|
+
sheet: sheetKey,
|
|
85310
|
+
row: row,
|
|
85311
|
+
col: col
|
|
85312
|
+
},
|
|
85313
|
+
formulaManager: formulaManager
|
|
85314
|
+
});
|
|
85315
|
+
}
|
|
85316
|
+
table.changeCellValue(col, row, content, !1, !1, !0);
|
|
85317
|
+
}
|
|
85318
|
+
function refreshDependentDisplays(args) {
|
|
85319
|
+
var _a;
|
|
85320
|
+
const {
|
|
85321
|
+
table: table,
|
|
85322
|
+
sheetKey: sheetKey,
|
|
85323
|
+
startCell: startCell,
|
|
85324
|
+
formulaManager: formulaManager
|
|
85325
|
+
} = args,
|
|
85326
|
+
maxCells = null !== (_a = args.maxCells) && void 0 !== _a ? _a : 5e3;
|
|
85327
|
+
if (!(null == formulaManager ? void 0 : formulaManager.getCellDependents) || !(null == formulaManager ? void 0 : formulaManager.getCellValue)) return;
|
|
85328
|
+
const visited = new Set(),
|
|
85329
|
+
queue = [...(formulaManager.getCellDependents(startCell) || [])];
|
|
85330
|
+
let processed = 0;
|
|
85331
|
+
for (; queue.length;) {
|
|
85332
|
+
const cell = queue.shift();
|
|
85333
|
+
if (!cell || cell.sheet !== sheetKey) continue;
|
|
85334
|
+
const key = makeCellKey(cell.sheet, cell.row, cell.col);
|
|
85335
|
+
if (visited.has(key)) continue;
|
|
85336
|
+
if (visited.add(key), processed++, processed > maxCells) break;
|
|
85337
|
+
const result = formulaManager.getCellValue(cell),
|
|
85338
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
85339
|
+
table.changeCellValue(cell.col, cell.row, display, !1, !1, !0);
|
|
85340
|
+
(formulaManager.getCellDependents(cell) || []).forEach(d => queue.push(d));
|
|
85341
|
+
}
|
|
85342
|
+
}
|
|
85343
|
+
|
|
85344
|
+
function cloneMergeConfig(input) {
|
|
85345
|
+
return Array.isArray(input) ? input.map(i => Object.assign(Object.assign({}, i), {
|
|
85346
|
+
range: (null == i ? void 0 : i.range) ? {
|
|
85347
|
+
start: Object.assign({}, i.range.start),
|
|
85348
|
+
end: Object.assign({}, i.range.end)
|
|
85349
|
+
} : null == i ? void 0 : i.range
|
|
85350
|
+
})) : input;
|
|
85351
|
+
}
|
|
85352
|
+
function getCustomMergeCellFunc(customMergeCell) {
|
|
85353
|
+
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;
|
|
85354
|
+
}
|
|
85355
|
+
function applyMergeConfig(table, customMergeCell) {
|
|
85356
|
+
(null == table ? void 0 : table.options) && (null == table ? void 0 : table.internalProps) && (table.options.customMergeCell = cloneMergeConfig(customMergeCell), table.internalProps.customMergeCell = getCustomMergeCellFunc(table.options.customMergeCell));
|
|
85357
|
+
}
|
|
85358
|
+
function cloneSortState(input) {
|
|
85359
|
+
return input ? Array.isArray(input) ? input.filter(Boolean).map(s => ({
|
|
85360
|
+
field: s.field,
|
|
85361
|
+
order: s.order
|
|
85362
|
+
})) : {
|
|
85363
|
+
field: input.field,
|
|
85364
|
+
order: input.order
|
|
85365
|
+
} : null;
|
|
85366
|
+
}
|
|
85367
|
+
function replayCommand(args) {
|
|
85368
|
+
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;
|
|
85369
|
+
const {
|
|
85370
|
+
table: table,
|
|
85371
|
+
vtableSheet: vtableSheet,
|
|
85372
|
+
cmd: cmd,
|
|
85373
|
+
direction: direction,
|
|
85374
|
+
deleteRecordsByReference: deleteRecordsByReference
|
|
85375
|
+
} = args;
|
|
85376
|
+
switch (cmd.type) {
|
|
85377
|
+
case "cell":
|
|
85378
|
+
case "cells":
|
|
85379
|
+
{
|
|
85380
|
+
const sheetKey = cmd.sheetKey;
|
|
85381
|
+
cmd.cells.forEach(c => {
|
|
85382
|
+
const content = "undo" === direction ? c.oldContent : c.newContent;
|
|
85383
|
+
applyCellContent({
|
|
85384
|
+
table: table,
|
|
85385
|
+
sheetKey: sheetKey,
|
|
85386
|
+
row: c.row,
|
|
85387
|
+
col: c.col,
|
|
85388
|
+
content: content,
|
|
85389
|
+
formulaManager: null == vtableSheet ? void 0 : vtableSheet.formulaManager
|
|
85390
|
+
});
|
|
85391
|
+
});
|
|
85392
|
+
break;
|
|
85393
|
+
}
|
|
85394
|
+
case "merge_cells":
|
|
85395
|
+
{
|
|
85396
|
+
const c = cmd,
|
|
85397
|
+
next = "undo" === direction ? c.oldCustomMergeCell : c.newCustomMergeCell;
|
|
85398
|
+
applyMergeConfig(table, next);
|
|
85399
|
+
const sg = table.scenegraph;
|
|
85400
|
+
if (null == sg ? void 0 : sg.updateCellContent) {
|
|
85401
|
+
for (let i = c.startCol; i <= c.endCol; i++) for (let j = c.startRow; j <= c.endRow; j++) sg.updateCellContent(i, j);
|
|
85402
|
+
null === (_a = sg.updateNextFrame) || void 0 === _a || _a.call(sg);
|
|
85403
|
+
} else "function" == typeof table.renderWithRecreateCells && table.renderWithRecreateCells();
|
|
85404
|
+
break;
|
|
85405
|
+
}
|
|
85406
|
+
case "filter":
|
|
85407
|
+
{
|
|
85408
|
+
const c = cmd,
|
|
85409
|
+
pluginId = c.pluginId,
|
|
85410
|
+
snapshot = "undo" === direction ? c.oldSnapshot : c.newSnapshot,
|
|
85411
|
+
pm = table.pluginManager,
|
|
85412
|
+
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");
|
|
85413
|
+
(null == filterPlugin ? void 0 : filterPlugin.applyFilterSnapshot) && filterPlugin.applyFilterSnapshot(snapshot);
|
|
85414
|
+
break;
|
|
85415
|
+
}
|
|
85416
|
+
case "sort":
|
|
85417
|
+
{
|
|
85418
|
+
const c = cmd,
|
|
85419
|
+
next = "undo" === direction ? c.oldSortState : c.newSortState;
|
|
85420
|
+
null === (_k = (_j = table).updateSortState) || void 0 === _k || _k.call(_j, null !== (_l = cloneSortState(next)) && void 0 !== _l ? _l : null, !0);
|
|
85421
|
+
break;
|
|
85422
|
+
}
|
|
85423
|
+
case "add_record":
|
|
85424
|
+
{
|
|
85425
|
+
const c = cmd;
|
|
85426
|
+
if ("undo" === direction) {
|
|
85427
|
+
const ds = null === (_m = null == table ? void 0 : table.internalProps) || void 0 === _m ? void 0 : _m.dataSource,
|
|
85428
|
+
rawRecords = null === (_o = null == ds ? void 0 : ds.dataSourceObj) || void 0 === _o ? void 0 : _o.records;
|
|
85429
|
+
let deletedByRaw = !1;
|
|
85430
|
+
if (Array.isArray(rawRecords) && "number" == typeof c.rawInsertIndex && c.recordCount > 0) {
|
|
85431
|
+
const idx = c.rawInsertIndex;
|
|
85432
|
+
idx >= 0 && idx < rawRecords.length && (rawRecords.splice(idx, c.recordCount), deletedByRaw = !0);
|
|
85433
|
+
}
|
|
85434
|
+
if (Array.isArray(rawRecords) && Array.isArray(c.records) && c.records.length) for (let i = 0; i < c.records.length; i++) {
|
|
85435
|
+
const rawIndex = rawRecords.indexOf(c.records[i]);
|
|
85436
|
+
rawIndex >= 0 && (rawRecords.splice(rawIndex, 1), deletedByRaw = !0);
|
|
85437
|
+
}
|
|
85438
|
+
if (!deletedByRaw && Array.isArray(rawRecords) && "number" == typeof c.recordCount && c.recordCount > 0) {
|
|
85439
|
+
const before = c.anchorBefore,
|
|
85440
|
+
after = c.anchorAfter,
|
|
85441
|
+
beforeIndex = before ? rawRecords.indexOf(before) : -1,
|
|
85442
|
+
afterIndex = after ? rawRecords.indexOf(after) : -1;
|
|
85443
|
+
beforeIndex >= 0 ? (rawRecords.splice(beforeIndex + 1, c.recordCount), deletedByRaw = !0) : afterIndex >= 0 && (rawRecords.splice(Math.max(0, afterIndex - c.recordCount), c.recordCount), deletedByRaw = !0);
|
|
85444
|
+
}
|
|
85445
|
+
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, {
|
|
85446
|
+
clearRowHeightCache: !1
|
|
85447
|
+
}) : 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) {
|
|
85448
|
+
const indexs = [];
|
|
85449
|
+
for (let i = 0; i < c.recordCount; i++) indexs.push(c.recordIndex + i);
|
|
85450
|
+
null === (_x = (_w = table).deleteRecords) || void 0 === _x || _x.call(_w, indexs);
|
|
85451
|
+
} else deleteRecordsByReference(c.records);
|
|
85452
|
+
} else c.records.length && (null === (_z = (_y = table).addRecords) || void 0 === _z || _z.call(_y, c.records, c.recordIndex));
|
|
85453
|
+
break;
|
|
85454
|
+
}
|
|
85455
|
+
case "delete_record":
|
|
85456
|
+
{
|
|
85457
|
+
const c = cmd;
|
|
85458
|
+
if ("undo" === direction) {
|
|
85459
|
+
if (table.addRecord && Array.isArray(c.records) && Array.isArray(c.recordIndexs)) {
|
|
85460
|
+
const pairs = [];
|
|
85461
|
+
for (let i = 0; i < c.recordIndexs.length; i++) {
|
|
85462
|
+
const idx = c.recordIndexs[i];
|
|
85463
|
+
"number" == typeof idx && pairs.push({
|
|
85464
|
+
idx: idx,
|
|
85465
|
+
record: c.records[i]
|
|
85466
|
+
});
|
|
85467
|
+
}
|
|
85468
|
+
pairs.sort((a, b) => a.idx - b.idx);
|
|
85469
|
+
for (const p of pairs) table.addRecord(p.record, p.idx);
|
|
85470
|
+
}
|
|
85471
|
+
if (c.deletedRowHeights && "function" == typeof table.setRowHeight) {
|
|
85472
|
+
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
|
|
85473
|
+
Object.keys(c.deletedRowHeights).forEach(k => {
|
|
85474
|
+
const idx = Number(k),
|
|
85475
|
+
height = c.deletedRowHeights[k];
|
|
85476
|
+
Number.isFinite(idx) && "number" == typeof height && table.setRowHeight(idx + (null != headerCount ? headerCount : 0), height);
|
|
85477
|
+
});
|
|
85478
|
+
}
|
|
85479
|
+
} else table.deleteRecords && table.deleteRecords(c.recordIndexs);
|
|
85480
|
+
if ("oldCustomMergeCell" in c || "newCustomMergeCell" in c) {
|
|
85481
|
+
const target = "undo" === direction ? c.oldCustomMergeCell : c.newCustomMergeCell;
|
|
85482
|
+
applyMergeConfig(table, target);
|
|
85483
|
+
const sg = table.scenegraph;
|
|
85484
|
+
if (null == sg ? void 0 : sg.updateCellContent) {
|
|
85485
|
+
[...(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 => {
|
|
85486
|
+
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);
|
|
85487
|
+
}), null === (_0 = sg.updateNextFrame) || void 0 === _0 || _0.call(sg);
|
|
85488
|
+
} else "function" == typeof table.renderWithRecreateCells && table.renderWithRecreateCells();
|
|
85489
|
+
}
|
|
85490
|
+
break;
|
|
85491
|
+
}
|
|
85492
|
+
case "update_record":
|
|
85493
|
+
{
|
|
85494
|
+
const c = cmd;
|
|
85495
|
+
table.updateRecords && ("undo" === direction ? table.updateRecords(c.oldRecords, c.recordIndexs) : table.updateRecords(c.newRecords, c.recordIndexs));
|
|
85496
|
+
break;
|
|
85497
|
+
}
|
|
85498
|
+
case "add_column":
|
|
85499
|
+
{
|
|
85500
|
+
const c = cmd;
|
|
85501
|
+
if ("undo" === direction) {
|
|
85502
|
+
const deleteIndexs = [];
|
|
85503
|
+
for (let i = 0; i < c.columnCount; i++) deleteIndexs.push(c.columnIndex + i);
|
|
85504
|
+
null === (_2 = (_1 = table).deleteColumns) || void 0 === _2 || _2.call(_1, deleteIndexs, !0);
|
|
85505
|
+
} else null === (_4 = (_3 = table).addColumns) || void 0 === _4 || _4.call(_3, c.columns, c.columnIndex, !0);
|
|
85506
|
+
break;
|
|
85507
|
+
}
|
|
85508
|
+
case "delete_column":
|
|
85509
|
+
{
|
|
85510
|
+
const c = cmd;
|
|
85511
|
+
if ("undo" === direction) {
|
|
85512
|
+
if (c.deleteColIndexs.map((idx, i) => ({
|
|
85513
|
+
idx: idx,
|
|
85514
|
+
column: c.columns[i]
|
|
85515
|
+
})).sort((a, b) => a.idx - b.idx).forEach(item => {
|
|
85516
|
+
var _a, _b;
|
|
85517
|
+
null === (_b = (_a = table).addColumns) || void 0 === _b || _b.call(_a, [item.column], item.idx, !0);
|
|
85518
|
+
}), c.deletedColWidths && "function" == typeof table.setColWidth && Object.entries(c.deletedColWidths).forEach(([k, width]) => {
|
|
85519
|
+
const idx = Number(k);
|
|
85520
|
+
Number.isFinite(idx) && "number" == typeof width && table.setColWidth(idx, width);
|
|
85521
|
+
}), Array.isArray(c.deletedRecordValues) && c.deletedRecordValues.length) {
|
|
85522
|
+
const records = table.records;
|
|
85523
|
+
if (Array.isArray(records) && records.length) {
|
|
85524
|
+
const recordIndexs = [],
|
|
85525
|
+
newRecords = [];
|
|
85526
|
+
for (let i = 0; i < records.length; i++) {
|
|
85527
|
+
const rec = records[i],
|
|
85528
|
+
rowValues = c.deletedRecordValues[i];
|
|
85529
|
+
if (!Array.isArray(rec) || !Array.isArray(rowValues) || rowValues.length !== c.deleteColIndexs.length) continue;
|
|
85530
|
+
const next = rec.slice();
|
|
85531
|
+
for (let k = 0; k < c.deleteColIndexs.length; k++) next[c.deleteColIndexs[k]] = rowValues[k];
|
|
85532
|
+
recordIndexs.push(i), newRecords.push(next);
|
|
85533
|
+
}
|
|
85534
|
+
recordIndexs.length && (null === (_6 = (_5 = table).updateRecords) || void 0 === _6 || _6.call(_5, newRecords, recordIndexs, !1));
|
|
85535
|
+
}
|
|
85536
|
+
}
|
|
85537
|
+
if (c.sheetKey) {
|
|
85538
|
+
const fm = null == vtableSheet ? void 0 : vtableSheet.formulaManager,
|
|
85539
|
+
engine = null == fm ? void 0 : fm.formulaEngine;
|
|
85540
|
+
if ((null == fm ? void 0 : fm.normalizeSheetData) && (null == engine ? void 0 : engine.updateSheetData)) try {
|
|
85541
|
+
const normalized = fm.normalizeSheetData(table.records || [], table);
|
|
85542
|
+
engine.updateSheetData(c.sheetKey, normalized);
|
|
85543
|
+
} catch (_17) {}
|
|
85544
|
+
}
|
|
85545
|
+
if (c.sheetKey && c.deletedFormulas) {
|
|
85546
|
+
Object.entries(c.deletedFormulas).forEach(([cellRef, formula]) => {
|
|
85547
|
+
const parsed = parseA1Notation(cellRef);
|
|
85548
|
+
parsed && applyCellContent({
|
|
85549
|
+
table: table,
|
|
85550
|
+
sheetKey: c.sheetKey,
|
|
85551
|
+
row: parsed.row,
|
|
85552
|
+
col: parsed.col,
|
|
85553
|
+
content: formula,
|
|
85554
|
+
formulaManager: null == vtableSheet ? void 0 : vtableSheet.formulaManager
|
|
85555
|
+
});
|
|
85556
|
+
});
|
|
85557
|
+
}
|
|
85558
|
+
} else null === (_8 = (_7 = table).deleteColumns) || void 0 === _8 || _8.call(_7, c.deleteColIndexs, !0);
|
|
85559
|
+
break;
|
|
85560
|
+
}
|
|
85561
|
+
case "change_header_position":
|
|
85562
|
+
{
|
|
85563
|
+
const c = cmd,
|
|
85564
|
+
moving = c.moving,
|
|
85565
|
+
from = "undo" === direction ? c.targetIndex : c.sourceIndex,
|
|
85566
|
+
to = "undo" === direction ? c.sourceIndex : c.targetIndex;
|
|
85567
|
+
"column" === moving ? null === (_10 = (_9 = table).changeHeaderPosition) || void 0 === _10 || _10.call(_9, {
|
|
85568
|
+
source: {
|
|
85569
|
+
col: from,
|
|
85570
|
+
row: 0
|
|
85571
|
+
},
|
|
85572
|
+
target: {
|
|
85573
|
+
col: to,
|
|
85574
|
+
row: 0
|
|
85575
|
+
},
|
|
85576
|
+
movingColumnOrRow: "column"
|
|
85577
|
+
}) : null === (_12 = (_11 = table).changeHeaderPosition) || void 0 === _12 || _12.call(_11, {
|
|
85578
|
+
source: {
|
|
85579
|
+
col: 0,
|
|
85580
|
+
row: from
|
|
85581
|
+
},
|
|
85582
|
+
target: {
|
|
85583
|
+
col: 0,
|
|
85584
|
+
row: to
|
|
85585
|
+
},
|
|
85586
|
+
movingColumnOrRow: "row"
|
|
85587
|
+
});
|
|
85588
|
+
break;
|
|
85589
|
+
}
|
|
85590
|
+
case "resize_row":
|
|
85591
|
+
{
|
|
85592
|
+
const c = cmd,
|
|
85593
|
+
height = "undo" === direction ? c.oldHeight : c.newHeight;
|
|
85594
|
+
null === (_14 = (_13 = table).setRowHeight) || void 0 === _14 || _14.call(_13, c.row, height);
|
|
85595
|
+
break;
|
|
85596
|
+
}
|
|
85597
|
+
case "resize_column":
|
|
85598
|
+
{
|
|
85599
|
+
const c = cmd,
|
|
85600
|
+
width = "undo" === direction ? c.oldWidth : c.newWidth;
|
|
85601
|
+
null === (_16 = (_15 = table).setColWidth) || void 0 === _16 || _16.call(_15, c.col, width);
|
|
85602
|
+
break;
|
|
85603
|
+
}
|
|
85604
|
+
}
|
|
85605
|
+
}
|
|
85606
|
+
|
|
85607
|
+
function cloneDeep(input, cache = new WeakMap()) {
|
|
85608
|
+
if (null == input) return input;
|
|
85609
|
+
const t = typeof input;
|
|
85610
|
+
if ("function" === t || "object" !== t) return input;
|
|
85611
|
+
const obj = input;
|
|
85612
|
+
if (obj instanceof Date) return new Date(obj.getTime());
|
|
85613
|
+
if (obj instanceof RegExp) return new RegExp(obj);
|
|
85614
|
+
if (cache.has(obj)) return cache.get(obj);
|
|
85615
|
+
if (Array.isArray(obj)) {
|
|
85616
|
+
const arr = [];
|
|
85617
|
+
cache.set(obj, arr);
|
|
85618
|
+
for (let i = 0; i < obj.length; i++) arr[i] = cloneDeep(obj[i], cache);
|
|
85619
|
+
return arr;
|
|
85620
|
+
}
|
|
85621
|
+
const out = {};
|
|
85622
|
+
return cache.set(obj, out), Object.keys(obj).forEach(key => {
|
|
85623
|
+
out[key] = cloneDeep(obj[key], cache);
|
|
85624
|
+
}), out;
|
|
85625
|
+
}
|
|
85626
|
+
function captureSnapshot(table, state, options) {
|
|
85627
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85628
|
+
const tableOptions = table.options || {},
|
|
85629
|
+
columns = tableOptions.columns;
|
|
85630
|
+
Array.isArray(columns) ? state.prevColumnsSnapshot = columns.map(c => cloneDeep(c)) : state.prevColumnsSnapshot = null;
|
|
85631
|
+
const merge = tableOptions.customMergeCell;
|
|
85632
|
+
Array.isArray(merge) ? state.prevMergeSnapshot = merge.map(m => Object.assign(Object.assign({}, m), {
|
|
85633
|
+
range: {
|
|
85634
|
+
start: Object.assign({}, m.range.start),
|
|
85635
|
+
end: Object.assign({}, m.range.end)
|
|
85636
|
+
}
|
|
85637
|
+
})) : state.prevMergeSnapshot = merge;
|
|
85638
|
+
const records = table.records || [];
|
|
85639
|
+
Array.isArray(records) ? state.prevRecordsSnapshot = records.map(r => cloneRecord(r)) : state.prevRecordsSnapshot = null;
|
|
85640
|
+
try {
|
|
85641
|
+
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 : []);
|
|
85642
|
+
if (resizedRowIndexs.length && "function" == typeof table.getRowHeight) {
|
|
85643
|
+
const map = {};
|
|
85644
|
+
resizedRowIndexs.forEach(rowIndex => {
|
|
85645
|
+
if ("number" != typeof rowIndex) return;
|
|
85646
|
+
const h = table.getRowHeight(rowIndex);
|
|
85647
|
+
"number" == typeof h && (map[rowIndex] = h);
|
|
85648
|
+
}), state.prevResizedRowHeightsSnapshot = map;
|
|
85649
|
+
} else state.prevResizedRowHeightsSnapshot = null;
|
|
85650
|
+
} catch (_k) {
|
|
85651
|
+
state.prevResizedRowHeightsSnapshot = null;
|
|
85652
|
+
}
|
|
85653
|
+
try {
|
|
85654
|
+
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 : []);
|
|
85655
|
+
if (resizedColIndexs.length && "function" == typeof table.getColWidth) {
|
|
85656
|
+
const map = {};
|
|
85657
|
+
resizedColIndexs.forEach(colIndex => {
|
|
85658
|
+
if ("number" != typeof colIndex) return;
|
|
85659
|
+
const w = table.getColWidth(colIndex);
|
|
85660
|
+
"number" == typeof w && (map[colIndex] = w);
|
|
85661
|
+
}), state.prevResizedColWidthsSnapshot = map;
|
|
85662
|
+
} else state.prevResizedColWidthsSnapshot = null;
|
|
85663
|
+
} catch (_l) {
|
|
85664
|
+
state.prevResizedColWidthsSnapshot = null;
|
|
85665
|
+
}
|
|
85666
|
+
if ((null === (_j = null == options ? void 0 : options.formulaManager) || void 0 === _j ? void 0 : _j.exportFormulas) && options.sheetKey) try {
|
|
85667
|
+
const formulas = options.formulaManager.exportFormulas(options.sheetKey);
|
|
85668
|
+
state.prevFormulasSnapshot = formulas ? Object.assign({}, formulas) : null;
|
|
85669
|
+
} catch (_m) {
|
|
85670
|
+
state.prevFormulasSnapshot = null;
|
|
85671
|
+
} else state.prevFormulasSnapshot = null;
|
|
85672
|
+
}
|
|
85673
|
+
function cloneRecord(record) {
|
|
85674
|
+
return Array.isArray(record) ? record.slice() : record && "object" == typeof record ? Object.assign({}, record) : record;
|
|
85675
|
+
}
|
|
85676
|
+
|
|
85677
|
+
function resolveSheetKey(args) {
|
|
85678
|
+
var _a, _b, _c;
|
|
85679
|
+
const {
|
|
85680
|
+
vtableSheet: vtableSheet,
|
|
85681
|
+
table: table,
|
|
85682
|
+
cached: cached
|
|
85683
|
+
} = args;
|
|
85684
|
+
if (!vtableSheet) return {
|
|
85685
|
+
sheetKey: void 0,
|
|
85686
|
+
cached: void 0
|
|
85687
|
+
};
|
|
85688
|
+
if (cached) return {
|
|
85689
|
+
sheetKey: cached,
|
|
85690
|
+
cached: cached
|
|
85691
|
+
};
|
|
85692
|
+
try {
|
|
85693
|
+
const workSheetInstances = vtableSheet.workSheetInstances;
|
|
85694
|
+
if (workSheetInstances && table) for (const [sheetKey, worksheet] of workSheetInstances.entries()) if ((null == worksheet ? void 0 : worksheet.tableInstance) === table) return {
|
|
85695
|
+
sheetKey: sheetKey,
|
|
85696
|
+
cached: sheetKey
|
|
85697
|
+
};
|
|
85698
|
+
const active = null === (_a = vtableSheet.getActiveSheet) || void 0 === _a ? void 0 : _a.call(vtableSheet);
|
|
85699
|
+
if (null == active ? void 0 : active.getKey) {
|
|
85700
|
+
const key = active.getKey();
|
|
85701
|
+
return {
|
|
85702
|
+
sheetKey: key,
|
|
85703
|
+
cached: key
|
|
85704
|
+
};
|
|
85705
|
+
}
|
|
85706
|
+
const activeDefine = null === (_c = null === (_b = vtableSheet.sheetManager) || void 0 === _b ? void 0 : _b.getActiveSheet) || void 0 === _c ? void 0 : _c.call(_b),
|
|
85707
|
+
key = null == activeDefine ? void 0 : activeDefine.sheetKey;
|
|
85708
|
+
return {
|
|
85709
|
+
sheetKey: key,
|
|
85710
|
+
cached: key
|
|
85711
|
+
};
|
|
85712
|
+
} catch (_d) {
|
|
85713
|
+
return {
|
|
85714
|
+
sheetKey: void 0,
|
|
85715
|
+
cached: void 0
|
|
85716
|
+
};
|
|
85717
|
+
}
|
|
85718
|
+
}
|
|
85719
|
+
|
|
85720
|
+
class HistoryPlugin {
|
|
85721
|
+
constructor(options) {
|
|
85722
|
+
var _a, _b, _c;
|
|
85723
|
+
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;
|
|
85724
|
+
}
|
|
85725
|
+
run(...args) {
|
|
85726
|
+
var _a, _b, _c, _d, _e, _f;
|
|
85727
|
+
const eventArgs = args[0],
|
|
85728
|
+
runtime = args[1],
|
|
85729
|
+
table = args[2];
|
|
85730
|
+
if (!table) return;
|
|
85731
|
+
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)) {
|
|
85732
|
+
const state = this.getSnapshotState(),
|
|
85733
|
+
sheetKey = this.getSheetKey();
|
|
85734
|
+
captureSnapshot(table, state, {
|
|
85735
|
+
formulaManager: null === (_b = this.vtableSheet) || void 0 === _b ? void 0 : _b.formulaManager,
|
|
85736
|
+
sheetKey: sheetKey
|
|
85737
|
+
}), this.setSnapshotState(state), this.lastKnownSortState = this.normalizeSortState(null === (_c = table.internalProps) || void 0 === _c ? void 0 : _c.sortState);
|
|
85738
|
+
}
|
|
85739
|
+
if (this.ensureFilterEventBindings(), runtime === TABLE_EVENT_TYPE.BEFORE_INIT) return;
|
|
85740
|
+
this.ensureFormulaEventBindings(), this.ensureSortEventBindings();
|
|
85741
|
+
const workbookReplaying = null === (_e = null === (_d = this.table) || void 0 === _d ? void 0 : _d.__vtableSheet) || void 0 === _e ? void 0 : _e.__workbookHistoryReplaying;
|
|
85742
|
+
if (!this.isReplaying && !workbookReplaying) {
|
|
85743
|
+
switch (runtime) {
|
|
85744
|
+
case TABLE_EVENT_TYPE.INITIALIZED:
|
|
85745
|
+
break;
|
|
85746
|
+
case TABLE_EVENT_TYPE.BEFORE_KEYDOWN:
|
|
85747
|
+
this.handleBeforeKeydown(eventArgs);
|
|
85748
|
+
break;
|
|
85749
|
+
case TABLE_EVENT_TYPE.CHANGE_CELL_VALUE:
|
|
85750
|
+
this.handleChangeCellValue(eventArgs);
|
|
85751
|
+
break;
|
|
85752
|
+
case TABLE_EVENT_TYPE.CHANGE_CELL_VALUES:
|
|
85753
|
+
this.handleChangeCellValues(eventArgs);
|
|
85754
|
+
break;
|
|
85755
|
+
case TABLE_EVENT_TYPE.PASTED_DATA:
|
|
85756
|
+
break;
|
|
85757
|
+
case TABLE_EVENT_TYPE.MERGE_CELLS:
|
|
85758
|
+
this.handleMergeCells(eventArgs);
|
|
85759
|
+
break;
|
|
85760
|
+
case TABLE_EVENT_TYPE.UNMERGE_CELLS:
|
|
85761
|
+
this.handleUnmergeCells(eventArgs);
|
|
85762
|
+
break;
|
|
85763
|
+
case TABLE_EVENT_TYPE.ADD_RECORD:
|
|
85764
|
+
this.handleAddRecord(eventArgs);
|
|
85765
|
+
break;
|
|
85766
|
+
case TABLE_EVENT_TYPE.DELETE_RECORD:
|
|
85767
|
+
this.handleDeleteRecord(eventArgs);
|
|
85768
|
+
break;
|
|
85769
|
+
case TABLE_EVENT_TYPE.UPDATE_RECORD:
|
|
85770
|
+
this.handleUpdateRecord(eventArgs);
|
|
85771
|
+
break;
|
|
85772
|
+
case TABLE_EVENT_TYPE.ADD_COLUMN:
|
|
85773
|
+
this.handleAddColumn(eventArgs);
|
|
85774
|
+
break;
|
|
85775
|
+
case TABLE_EVENT_TYPE.DELETE_COLUMN:
|
|
85776
|
+
this.handleDeleteColumn(eventArgs);
|
|
85777
|
+
break;
|
|
85778
|
+
case TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION:
|
|
85779
|
+
this.handleChangeHeaderPosition(eventArgs);
|
|
85780
|
+
break;
|
|
85781
|
+
case TABLE_EVENT_TYPE.SORT_CLICK:
|
|
85782
|
+
this.handleSortClick(eventArgs);
|
|
85783
|
+
break;
|
|
85784
|
+
case TABLE_EVENT_TYPE.RESIZE_ROW:
|
|
85785
|
+
this.handleResizeRow(eventArgs);
|
|
85786
|
+
break;
|
|
85787
|
+
case TABLE_EVENT_TYPE.RESIZE_ROW_END:
|
|
85788
|
+
this.handleResizeRowEnd(eventArgs);
|
|
85789
|
+
break;
|
|
85790
|
+
case TABLE_EVENT_TYPE.RESIZE_COLUMN:
|
|
85791
|
+
this.handleResizeColumn(eventArgs);
|
|
85792
|
+
break;
|
|
85793
|
+
case TABLE_EVENT_TYPE.RESIZE_COLUMN_END:
|
|
85794
|
+
this.handleResizeColumnEnd(eventArgs);
|
|
85795
|
+
}
|
|
85796
|
+
if (this.table) {
|
|
85797
|
+
const state = this.getSnapshotState(),
|
|
85798
|
+
sheetKey = this.getSheetKey();
|
|
85799
|
+
captureSnapshot(this.table, state, {
|
|
85800
|
+
formulaManager: null === (_f = this.vtableSheet) || void 0 === _f ? void 0 : _f.formulaManager,
|
|
85801
|
+
sheetKey: sheetKey
|
|
85802
|
+
}), this.setSnapshotState(state);
|
|
85803
|
+
}
|
|
85804
|
+
}
|
|
85805
|
+
}
|
|
85806
|
+
startTransaction() {
|
|
85807
|
+
this.currentTransaction || (this.currentTransaction = {
|
|
85808
|
+
commands: []
|
|
85809
|
+
});
|
|
85810
|
+
}
|
|
85811
|
+
endTransaction() {
|
|
85812
|
+
this.currentTransaction && 0 !== this.currentTransaction.commands.length ? (this.pushTransaction(this.currentTransaction), this.currentTransaction = null) : this.currentTransaction = null;
|
|
85813
|
+
}
|
|
85814
|
+
undo() {
|
|
85815
|
+
var _a;
|
|
85816
|
+
if (!this.table || 0 === this.undoStack.length) return;
|
|
85817
|
+
const transaction = this.undoStack.pop();
|
|
85818
|
+
this.isReplaying = !0;
|
|
85819
|
+
try {
|
|
85820
|
+
for (let i = transaction.commands.length - 1; i >= 0; i--) this.applyCommand(transaction.commands[i], "undo");
|
|
85821
|
+
} finally {
|
|
85822
|
+
this.isReplaying = !1;
|
|
85823
|
+
}
|
|
85824
|
+
if (this.redoStack.push(transaction), this.table) {
|
|
85825
|
+
const state = this.getSnapshotState(),
|
|
85826
|
+
sheetKey = this.getSheetKey();
|
|
85827
|
+
captureSnapshot(this.table, state, {
|
|
85828
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85829
|
+
sheetKey: sheetKey
|
|
85830
|
+
}), this.setSnapshotState(state);
|
|
85831
|
+
}
|
|
85832
|
+
}
|
|
85833
|
+
redo() {
|
|
85834
|
+
var _a;
|
|
85835
|
+
if (!this.table || 0 === this.redoStack.length) return;
|
|
85836
|
+
const transaction = this.redoStack.pop();
|
|
85837
|
+
this.isReplaying = !0;
|
|
85838
|
+
try {
|
|
85839
|
+
for (const cmd of transaction.commands) this.applyCommand(cmd, "redo");
|
|
85840
|
+
} finally {
|
|
85841
|
+
this.isReplaying = !1;
|
|
85842
|
+
}
|
|
85843
|
+
if (this.undoStack.push(transaction), this.table) {
|
|
85844
|
+
const state = this.getSnapshotState(),
|
|
85845
|
+
sheetKey = this.getSheetKey();
|
|
85846
|
+
captureSnapshot(this.table, state, {
|
|
85847
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85848
|
+
sheetKey: sheetKey
|
|
85849
|
+
}), this.setSnapshotState(state);
|
|
85850
|
+
}
|
|
85851
|
+
}
|
|
85852
|
+
clear() {
|
|
85853
|
+
this.undoStack = [], this.redoStack = [], this.currentTransaction = null;
|
|
85854
|
+
}
|
|
85855
|
+
updateOptions(options) {
|
|
85856
|
+
null != options.maxHistory && (this.maxHistory = options.maxHistory, this.trimHistory()), null != options.enableCompression && (this.enableCompression = options.enableCompression), options.onTransactionPushed && (this.onTransactionPushed = options.onTransactionPushed);
|
|
85857
|
+
}
|
|
85858
|
+
release() {
|
|
85859
|
+
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;
|
|
85860
|
+
}
|
|
85861
|
+
ensureFilterEventBindings() {
|
|
85862
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85863
|
+
if (!this.table) return;
|
|
85864
|
+
const pm = this.table.pluginManager,
|
|
85865
|
+
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");
|
|
85866
|
+
if (!(null == filterPlugin ? void 0 : filterPlugin.getFilterSnapshot) || !(null == filterPlugin ? void 0 : filterPlugin.applyFilterSnapshot)) return;
|
|
85867
|
+
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 => {
|
|
85868
|
+
var _a, _b;
|
|
85869
|
+
if (this.isReplaying) return this.filterApplySnapshotOriginal(snapshot);
|
|
85870
|
+
const oldSnapshot = null !== (_a = this.filterSnapshotCache) && void 0 !== _a ? _a : filterPlugin.getFilterSnapshot();
|
|
85871
|
+
this.filterApplyingSnapshot = !0;
|
|
85872
|
+
try {
|
|
85873
|
+
return this.filterApplySnapshotOriginal(snapshot);
|
|
85874
|
+
} finally {
|
|
85875
|
+
this.filterApplyingSnapshot = !1;
|
|
85876
|
+
const newSnapshot = filterPlugin.getFilterSnapshot();
|
|
85877
|
+
if (JSON.stringify(oldSnapshot) !== JSON.stringify(newSnapshot)) {
|
|
85878
|
+
const cmd = {
|
|
85879
|
+
type: "filter",
|
|
85880
|
+
sheetKey: this.getSheetKey(),
|
|
85881
|
+
pluginId: null !== (_b = this.filterPluginId) && void 0 !== _b ? _b : "filter",
|
|
85882
|
+
oldSnapshot: oldSnapshot,
|
|
85883
|
+
newSnapshot: newSnapshot
|
|
85884
|
+
};
|
|
85885
|
+
this.pushCommand(cmd), this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85886
|
+
} else this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85887
|
+
}
|
|
85888
|
+
}));
|
|
85889
|
+
const stateManager = null == filterPlugin ? void 0 : filterPlugin.filterStateManager;
|
|
85890
|
+
!this.filterUnsubscribe && (null == stateManager ? void 0 : stateManager.subscribe) && (this.filterUnsubscribe = stateManager.subscribe((_state, action) => {
|
|
85891
|
+
var _a, _b;
|
|
85892
|
+
if (this.isReplaying) return;
|
|
85893
|
+
if (this.filterApplyingSnapshot) return void (this.filterSnapshotCache = cloneDeep(filterPlugin.getFilterSnapshot()));
|
|
85894
|
+
const t = null == action ? void 0 : action.type;
|
|
85895
|
+
if (t !== FilterActionType.APPLY_FILTERS && t !== FilterActionType.CLEAR_ALL_FILTERS && t !== FilterActionType.REMOVE_FILTER && t !== FilterActionType.DISABLE_FILTER) return;
|
|
85896
|
+
const oldSnapshot = null !== (_a = this.filterSnapshotCache) && void 0 !== _a ? _a : filterPlugin.getFilterSnapshot(),
|
|
85897
|
+
newSnapshot = filterPlugin.getFilterSnapshot();
|
|
85898
|
+
if (JSON.stringify(oldSnapshot) === JSON.stringify(newSnapshot)) return;
|
|
85899
|
+
const cmd = {
|
|
85900
|
+
type: "filter",
|
|
85901
|
+
sheetKey: this.getSheetKey(),
|
|
85902
|
+
pluginId: null !== (_b = this.filterPluginId) && void 0 !== _b ? _b : "filter",
|
|
85903
|
+
oldSnapshot: oldSnapshot,
|
|
85904
|
+
newSnapshot: newSnapshot
|
|
85905
|
+
};
|
|
85906
|
+
this.pushCommand(cmd), this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85907
|
+
}));
|
|
85908
|
+
}
|
|
85909
|
+
unbindFilterEvents() {
|
|
85910
|
+
var _a;
|
|
85911
|
+
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;
|
|
85912
|
+
}
|
|
85913
|
+
getSheetKey() {
|
|
85914
|
+
const resolved = resolveSheetKey({
|
|
85915
|
+
vtableSheet: this.vtableSheet,
|
|
85916
|
+
table: this.table,
|
|
85917
|
+
cached: this.resolvedSheetKey
|
|
85918
|
+
});
|
|
85919
|
+
return this.resolvedSheetKey = resolved.cached, resolved.sheetKey;
|
|
85920
|
+
}
|
|
85921
|
+
getSnapshotState() {
|
|
85922
|
+
return {
|
|
85923
|
+
prevColumnsSnapshot: this.prevColumnsSnapshot,
|
|
85924
|
+
prevMergeSnapshot: this.prevMergeSnapshot,
|
|
85925
|
+
prevRecordsSnapshot: this.prevRecordsSnapshot,
|
|
85926
|
+
prevFormulasSnapshot: this.prevFormulasSnapshot,
|
|
85927
|
+
prevResizedRowHeightsSnapshot: this.prevResizedRowHeightsSnapshot,
|
|
85928
|
+
prevResizedColWidthsSnapshot: this.prevResizedColWidthsSnapshot
|
|
85929
|
+
};
|
|
85930
|
+
}
|
|
85931
|
+
setSnapshotState(next) {
|
|
85932
|
+
var _a, _b, _c;
|
|
85933
|
+
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;
|
|
85934
|
+
}
|
|
85935
|
+
pushTransaction(tx) {
|
|
85936
|
+
var _a, _b, _c;
|
|
85937
|
+
if (0 !== tx.commands.length && (this.undoStack.push(tx), this.redoStack = [], this.trimHistory(), this.onTransactionPushed && !this.isReplaying)) {
|
|
85938
|
+
(null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.__vtableSheet) || void 0 === _b ? void 0 : _b.__workbookHistoryReplaying) || this.onTransactionPushed({
|
|
85939
|
+
tx: tx,
|
|
85940
|
+
sheetKey: this.getSheetKey(),
|
|
85941
|
+
table: null !== (_c = this.table) && void 0 !== _c ? _c : void 0
|
|
85942
|
+
});
|
|
85943
|
+
}
|
|
85944
|
+
}
|
|
85945
|
+
trimHistory() {
|
|
85946
|
+
this.undoStack.length > this.maxHistory && this.undoStack.splice(0, this.undoStack.length - this.maxHistory);
|
|
85947
|
+
}
|
|
85948
|
+
pushCommand(cmd) {
|
|
85949
|
+
this.currentTransaction ? this.currentTransaction.commands.push(cmd) : this.pushTransaction({
|
|
85950
|
+
commands: [cmd]
|
|
85951
|
+
});
|
|
85952
|
+
}
|
|
85953
|
+
recordExternalCommand(cmd) {
|
|
85954
|
+
this.isReplaying || this.pushCommand(cmd);
|
|
85955
|
+
}
|
|
85956
|
+
tryCompressCellChange(change, sheetKey) {
|
|
85957
|
+
if (!this.enableCompression) return !1;
|
|
85958
|
+
const targetTx = this.currentTransaction || this.undoStack[this.undoStack.length - 1];
|
|
85959
|
+
if (!targetTx || 0 === targetTx.commands.length) return !1;
|
|
85960
|
+
const last = targetTx.commands[targetTx.commands.length - 1];
|
|
85961
|
+
if (("cell" === last.type || "cells" === last.type) && last.sheetKey === sheetKey) {
|
|
85962
|
+
const cells = last.cells;
|
|
85963
|
+
if (1 === cells.length && cells[0].row === change.row && cells[0].col === change.col) return cells[0].newContent = change.newContent, !0;
|
|
85964
|
+
}
|
|
85965
|
+
return !1;
|
|
85966
|
+
}
|
|
85967
|
+
handleBeforeKeydown(eventArgs) {
|
|
85968
|
+
var _a, _b, _c, _d, _e, _f;
|
|
85969
|
+
const e = eventArgs.event;
|
|
85970
|
+
if (!e || !this.table) return;
|
|
85971
|
+
if (!(e.ctrlKey || e.metaKey)) return;
|
|
85972
|
+
const formulaManager = null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager;
|
|
85973
|
+
if (null == formulaManager ? void 0 : formulaManager.formulaWorkingOnCell) return;
|
|
85974
|
+
if (null === (_b = this.table.editorManager) || void 0 === _b ? void 0 : _b.editingEditor) return;
|
|
85975
|
+
const key = e.key.toLowerCase();
|
|
85976
|
+
if ("z" === key) {
|
|
85977
|
+
const workbookHistory = null === (_d = null === (_c = this.vtableSheet) || void 0 === _c ? void 0 : _c.getWorkbookHistoryManager) || void 0 === _d ? void 0 : _d.call(_c);
|
|
85978
|
+
e.shiftKey ? workbookHistory ? workbookHistory.redo() : this.redo() : workbookHistory ? workbookHistory.undo() : this.undo(), e.preventDefault(), e.stopPropagation();
|
|
85979
|
+
} else if ("y" === key) {
|
|
85980
|
+
const workbookHistory = null === (_f = null === (_e = this.vtableSheet) || void 0 === _e ? void 0 : _e.getWorkbookHistoryManager) || void 0 === _f ? void 0 : _f.call(_e);
|
|
85981
|
+
workbookHistory ? workbookHistory.redo() : this.redo(), e.preventDefault(), e.stopPropagation();
|
|
85982
|
+
}
|
|
85983
|
+
}
|
|
85984
|
+
handleChangeCellValue(eventArgs) {
|
|
85985
|
+
var _a;
|
|
85986
|
+
captureCellPreChangeContent({
|
|
85987
|
+
sheetKey: this.getSheetKey(),
|
|
85988
|
+
row: eventArgs.row,
|
|
85989
|
+
col: eventArgs.col,
|
|
85990
|
+
currentValue: eventArgs.currentValue,
|
|
85991
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85992
|
+
store: this.cellPreChangeContent
|
|
85993
|
+
});
|
|
85994
|
+
}
|
|
85995
|
+
handleChangeCellValues(eventArgs) {
|
|
85996
|
+
var _a;
|
|
85997
|
+
if (!this.table) return;
|
|
85998
|
+
const sheetKey = this.getSheetKey(),
|
|
85999
|
+
formulaManager = null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
86000
|
+
cells = eventArgs.values.map(v => {
|
|
86001
|
+
const oldContent = popCellPreChangeContent({
|
|
86002
|
+
sheetKey: sheetKey,
|
|
86003
|
+
row: v.row,
|
|
86004
|
+
col: v.col,
|
|
86005
|
+
fallbackOldContent: v.currentValue,
|
|
86006
|
+
store: this.cellPreChangeContent
|
|
86007
|
+
}),
|
|
86008
|
+
normalizedOld = null == oldContent ? "" : oldContent,
|
|
86009
|
+
normalizedNew = null == v.changedValue ? "" : v.changedValue;
|
|
86010
|
+
return {
|
|
86011
|
+
row: v.row,
|
|
86012
|
+
col: v.col,
|
|
86013
|
+
oldContent: normalizedOld,
|
|
86014
|
+
newContent: normalizedNew
|
|
86015
|
+
};
|
|
86016
|
+
}).filter(c => {
|
|
86017
|
+
if (c.oldContent === c.newContent) return !1;
|
|
86018
|
+
if (!sheetKey || !(null == formulaManager ? void 0 : formulaManager.getCellFormula) || !(null == formulaManager ? void 0 : formulaManager.getCellValue)) return !0;
|
|
86019
|
+
if ("string" == typeof c.newContent && c.newContent.startsWith("=")) return !1;
|
|
86020
|
+
if (!formulaManager.getCellFormula({
|
|
86021
|
+
sheet: sheetKey,
|
|
86022
|
+
row: c.row,
|
|
86023
|
+
col: c.col
|
|
86024
|
+
})) return !0;
|
|
86025
|
+
const result = formulaManager.getCellValue({
|
|
86026
|
+
sheet: sheetKey,
|
|
86027
|
+
row: c.row,
|
|
86028
|
+
col: c.col
|
|
86029
|
+
}),
|
|
86030
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
86031
|
+
return display !== c.newContent && (null == display || null == c.newContent || String(display) !== String(c.newContent));
|
|
86032
|
+
});
|
|
86033
|
+
if (!cells.length) return;
|
|
86034
|
+
if (sheetKey && 1 === cells.length && this.tryCompressCellChange(cells[0], sheetKey)) return;
|
|
86035
|
+
const cmd = {
|
|
86036
|
+
type: "cells",
|
|
86037
|
+
sheetKey: sheetKey,
|
|
86038
|
+
cells: cells
|
|
86039
|
+
};
|
|
86040
|
+
this.pushCommand(cmd);
|
|
86041
|
+
}
|
|
86042
|
+
ensureFormulaEventBindings() {
|
|
86043
|
+
var _a, _b, _c, _d, _e;
|
|
86044
|
+
if (!this.table || !this.vtableSheet || this.formulaEventBound) return;
|
|
86045
|
+
const sheetKey = this.getSheetKey();
|
|
86046
|
+
if (!sheetKey) return;
|
|
86047
|
+
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),
|
|
86048
|
+
eventManager = null == worksheet ? void 0 : worksheet.eventManager;
|
|
86049
|
+
(null == eventManager ? void 0 : eventManager.on) && (null == eventManager ? void 0 : eventManager.off) && (this.formulaEventBound = !0, this.formulaEventManager = eventManager, this.onFormulaAddedHandler = event => {
|
|
86050
|
+
if (this.isReplaying) return;
|
|
86051
|
+
const cell = null == event ? void 0 : event.cell,
|
|
86052
|
+
formula = null == event ? void 0 : event.formula;
|
|
86053
|
+
if (!cell || "number" != typeof cell.row || "number" != typeof cell.col) return;
|
|
86054
|
+
if ("string" != typeof formula || !formula.length) return;
|
|
86055
|
+
const normalized = formula.startsWith("=") ? formula : `=${formula}`,
|
|
86056
|
+
key = `${sheetKey}:${cell.row}:${cell.col}`,
|
|
86057
|
+
prev = this.formulaCache.get(key),
|
|
86058
|
+
oldContent = popCellPreChangeContent({
|
|
86059
|
+
sheetKey: sheetKey,
|
|
86060
|
+
row: cell.row,
|
|
86061
|
+
col: cell.col,
|
|
86062
|
+
fallbackOldContent: void 0 !== prev ? prev : "",
|
|
86063
|
+
store: this.cellPreChangeContent
|
|
86064
|
+
});
|
|
86065
|
+
if (oldContent === normalized) return void this.formulaCache.set(key, normalized);
|
|
86066
|
+
const cmd = {
|
|
86067
|
+
type: "cells",
|
|
86068
|
+
sheetKey: sheetKey,
|
|
86069
|
+
cells: [{
|
|
86070
|
+
row: cell.row,
|
|
86071
|
+
col: cell.col,
|
|
86072
|
+
oldContent: oldContent,
|
|
86073
|
+
newContent: normalized
|
|
86074
|
+
}]
|
|
86075
|
+
};
|
|
86076
|
+
this.pushCommand(cmd), this.formulaCache.set(key, normalized);
|
|
86077
|
+
}, eventManager.on("formula_added", this.onFormulaAddedHandler));
|
|
86078
|
+
}
|
|
86079
|
+
ensureSortEventBindings() {
|
|
86080
|
+
var _a;
|
|
86081
|
+
if (!this.table || this.sortEventBound) return;
|
|
86082
|
+
const ds = null === (_a = this.table.internalProps) || void 0 === _a ? void 0 : _a.dataSource;
|
|
86083
|
+
(null == ds ? void 0 : ds.on) && (null == ds ? void 0 : ds.off) && (this.sortEventBound = !0, this.sortChangeOrderListenerId = ds.on("change_order", () => {
|
|
86084
|
+
var _a;
|
|
86085
|
+
if (this.isReplaying || !this.table || !this.sortPending) return;
|
|
86086
|
+
const sheetKey = this.getSheetKey(),
|
|
86087
|
+
oldSortState = this.sortStartSnapshot;
|
|
86088
|
+
this.sortStartSnapshot = null, this.sortPending = !1;
|
|
86089
|
+
const newSortState = this.normalizeSortState(null === (_a = this.table.internalProps) || void 0 === _a ? void 0 : _a.sortState);
|
|
86090
|
+
if (JSON.stringify(oldSortState) === JSON.stringify(newSortState)) return void (this.lastKnownSortState = newSortState);
|
|
86091
|
+
const cmd = {
|
|
86092
|
+
type: "sort",
|
|
86093
|
+
sheetKey: sheetKey,
|
|
86094
|
+
oldSortState: oldSortState,
|
|
86095
|
+
newSortState: newSortState
|
|
86096
|
+
};
|
|
86097
|
+
this.pushCommand(cmd), this.lastKnownSortState = newSortState;
|
|
86098
|
+
}));
|
|
86099
|
+
}
|
|
86100
|
+
unbindSortEvents() {
|
|
86101
|
+
var _a, _b;
|
|
86102
|
+
if (!this.sortEventBound) return;
|
|
86103
|
+
const ds = null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.internalProps) || void 0 === _b ? void 0 : _b.dataSource;
|
|
86104
|
+
try {
|
|
86105
|
+
(null == ds ? void 0 : ds.off) && this.sortChangeOrderListenerId && ds.off(this.sortChangeOrderListenerId);
|
|
86106
|
+
} catch (_c) {} finally {
|
|
86107
|
+
this.sortEventBound = !1, this.sortChangeOrderListenerId = void 0, this.sortPending = !1, this.sortStartSnapshot = null;
|
|
86108
|
+
}
|
|
86109
|
+
}
|
|
86110
|
+
unbindFormulaEvents() {
|
|
86111
|
+
if (this.formulaEventBound && this.formulaEventManager) try {
|
|
86112
|
+
this.onFormulaAddedHandler && this.formulaEventManager.off("formula_added", this.onFormulaAddedHandler);
|
|
86113
|
+
} catch (_a) {} finally {
|
|
86114
|
+
this.formulaEventBound = !1, this.formulaEventManager = void 0, this.onFormulaAddedHandler = void 0;
|
|
86115
|
+
}
|
|
86116
|
+
}
|
|
86117
|
+
cloneMergeConfig(input) {
|
|
86118
|
+
return Array.isArray(input) ? input.map(i => cloneDeep(i)) : input;
|
|
86119
|
+
}
|
|
86120
|
+
isSameMergeConfig(a, b) {
|
|
86121
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
86122
|
+
const normalize = v => null == v ? [] : (v),
|
|
86123
|
+
aa = normalize(a),
|
|
86124
|
+
bb = normalize(b);
|
|
86125
|
+
if (aa === bb) return !0;
|
|
86126
|
+
if (Array.isArray(aa) && Array.isArray(bb)) {
|
|
86127
|
+
if (aa.length !== bb.length) return !1;
|
|
86128
|
+
for (let i = 0; i < aa.length; i++) {
|
|
86129
|
+
const ra = null === (_a = aa[i]) || void 0 === _a ? void 0 : _a.range,
|
|
86130
|
+
rb = null === (_b = bb[i]) || void 0 === _b ? void 0 : _b.range;
|
|
86131
|
+
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;
|
|
86132
|
+
}
|
|
86133
|
+
return !0;
|
|
86134
|
+
}
|
|
86135
|
+
return !1;
|
|
86136
|
+
}
|
|
86137
|
+
handleMergeCells(eventArgs) {
|
|
86138
|
+
this.handleMergeConfigChanged(eventArgs);
|
|
86139
|
+
}
|
|
86140
|
+
handleUnmergeCells(eventArgs) {
|
|
86141
|
+
this.handleMergeConfigChanged(eventArgs);
|
|
86142
|
+
}
|
|
86143
|
+
handleMergeConfigChanged(eventArgs) {
|
|
86144
|
+
var _a;
|
|
86145
|
+
if (!this.table) return;
|
|
86146
|
+
const {
|
|
86147
|
+
startCol: startCol,
|
|
86148
|
+
startRow: startRow,
|
|
86149
|
+
endCol: endCol,
|
|
86150
|
+
endRow: endRow
|
|
86151
|
+
} = eventArgs,
|
|
86152
|
+
before = this.cloneMergeConfig(this.prevMergeSnapshot),
|
|
86153
|
+
after = this.cloneMergeConfig(null === (_a = this.table.options) || void 0 === _a ? void 0 : _a.customMergeCell);
|
|
86154
|
+
if (this.isSameMergeConfig(before, after)) return;
|
|
86155
|
+
const cmd = {
|
|
86156
|
+
type: "merge_cells",
|
|
86157
|
+
sheetKey: this.getSheetKey(),
|
|
86158
|
+
startCol: startCol,
|
|
86159
|
+
startRow: startRow,
|
|
86160
|
+
endCol: endCol,
|
|
86161
|
+
endRow: endRow,
|
|
86162
|
+
oldCustomMergeCell: before,
|
|
86163
|
+
newCustomMergeCell: after
|
|
86164
|
+
};
|
|
86165
|
+
this.pushCommand(cmd);
|
|
86166
|
+
}
|
|
86167
|
+
handleAddRecord(eventArgs) {
|
|
86168
|
+
var _a, _b, _c, _d;
|
|
86169
|
+
const cmd = {
|
|
86170
|
+
type: "add_record",
|
|
86171
|
+
sheetKey: this.getSheetKey(),
|
|
86172
|
+
records: Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [],
|
|
86173
|
+
recordIndex: eventArgs.recordIndex,
|
|
86174
|
+
recordCount: null !== (_a = eventArgs.recordCount) && void 0 !== _a ? _a : Array.isArray(eventArgs.records) ? eventArgs.records.length : 0
|
|
86175
|
+
};
|
|
86176
|
+
if (this.table && "number" == typeof eventArgs.recordIndex) {
|
|
86177
|
+
const start = eventArgs.recordIndex,
|
|
86178
|
+
count = cmd.recordCount,
|
|
86179
|
+
ds = null === (_c = null === (_b = this.table) || void 0 === _b ? void 0 : _b.internalProps) || void 0 === _c ? void 0 : _c.dataSource,
|
|
86180
|
+
rawRecords = null === (_d = null == ds ? void 0 : ds.dataSourceObj) || void 0 === _d ? void 0 : _d.records,
|
|
86181
|
+
viewRecords = this.table.records;
|
|
86182
|
+
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)) {
|
|
86183
|
+
let rawInsertIndex = rawRecords.length;
|
|
86184
|
+
if (0 === viewRecords.length) rawInsertIndex = rawRecords.length;else if (start <= 0) {
|
|
86185
|
+
const first = viewRecords[0],
|
|
86186
|
+
idx = rawRecords.indexOf(first);
|
|
86187
|
+
rawInsertIndex = idx >= 0 ? idx : 0;
|
|
86188
|
+
} else if (start >= viewRecords.length) {
|
|
86189
|
+
const last = viewRecords[viewRecords.length - 1],
|
|
86190
|
+
idx = rawRecords.indexOf(last);
|
|
86191
|
+
rawInsertIndex = idx >= 0 ? idx + 1 : rawRecords.length;
|
|
86192
|
+
} else {
|
|
86193
|
+
const prev = viewRecords[start - 1],
|
|
86194
|
+
idx = rawRecords.indexOf(prev);
|
|
86195
|
+
rawInsertIndex = idx >= 0 ? idx + 1 : rawRecords.length;
|
|
86196
|
+
}
|
|
86197
|
+
cmd.rawInsertIndex = rawInsertIndex;
|
|
86198
|
+
}
|
|
86199
|
+
}
|
|
86200
|
+
this.pushCommand(cmd);
|
|
86201
|
+
}
|
|
86202
|
+
handleDeleteRecord(eventArgs) {
|
|
86203
|
+
var _a, _b;
|
|
86204
|
+
const sheetKey = this.getSheetKey(),
|
|
86205
|
+
recordIndexs = Array.isArray(eventArgs.recordIndexs) ? eventArgs.recordIndexs.slice() : [eventArgs.recordIndexs];
|
|
86206
|
+
let deletedRowHeights;
|
|
86207
|
+
if (this.table && this.prevResizedRowHeightsSnapshot) {
|
|
86208
|
+
const headerCount = this.table.transpose ? this.table.rowHeaderLevelCount : this.table.columnHeaderLevelCount;
|
|
86209
|
+
recordIndexs.forEach(idx => {
|
|
86210
|
+
var _a;
|
|
86211
|
+
if ("number" != typeof idx) return;
|
|
86212
|
+
const rowIndex = idx + (null != headerCount ? headerCount : 0),
|
|
86213
|
+
height = null === (_a = this.prevResizedRowHeightsSnapshot) || void 0 === _a ? void 0 : _a[rowIndex];
|
|
86214
|
+
"number" == typeof height && (deletedRowHeights || (deletedRowHeights = {}), deletedRowHeights[idx] = height);
|
|
86215
|
+
});
|
|
86216
|
+
}
|
|
86217
|
+
const oldCustomMergeCell = this.cloneMergeConfig(this.prevMergeSnapshot),
|
|
86218
|
+
newCustomMergeCell = this.cloneMergeConfig(null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.customMergeCell),
|
|
86219
|
+
cmd = {
|
|
86220
|
+
type: "delete_record",
|
|
86221
|
+
sheetKey: sheetKey,
|
|
86222
|
+
records: Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [],
|
|
86223
|
+
recordIndexs: recordIndexs,
|
|
86224
|
+
deletedRowHeights: deletedRowHeights,
|
|
86225
|
+
oldCustomMergeCell: oldCustomMergeCell,
|
|
86226
|
+
newCustomMergeCell: newCustomMergeCell
|
|
86227
|
+
};
|
|
86228
|
+
this.pushCommand(cmd);
|
|
86229
|
+
}
|
|
86230
|
+
handleUpdateRecord(eventArgs) {
|
|
86231
|
+
if (!this.table) return;
|
|
86232
|
+
const sheetKey = this.getSheetKey(),
|
|
86233
|
+
recordIndexs = eventArgs.recordIndexs || [],
|
|
86234
|
+
newRecords = Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [];
|
|
86235
|
+
if (!this.prevRecordsSnapshot || !Array.isArray(this.prevRecordsSnapshot) || !recordIndexs.length) return;
|
|
86236
|
+
const oldRecords = [];
|
|
86237
|
+
recordIndexs.forEach(idx => {
|
|
86238
|
+
if ("number" == typeof idx) {
|
|
86239
|
+
const rec = this.prevRecordsSnapshot[idx];
|
|
86240
|
+
oldRecords.push(void 0 !== rec ? cloneRecord(rec) : void 0);
|
|
86241
|
+
} else oldRecords.push(void 0);
|
|
86242
|
+
});
|
|
86243
|
+
const cmd = {
|
|
86244
|
+
type: "update_record",
|
|
86245
|
+
sheetKey: sheetKey,
|
|
86246
|
+
oldRecords: oldRecords,
|
|
86247
|
+
newRecords: newRecords,
|
|
86248
|
+
recordIndexs: recordIndexs
|
|
86249
|
+
};
|
|
86250
|
+
this.pushCommand(cmd);
|
|
86251
|
+
}
|
|
86252
|
+
handleAddColumn(eventArgs) {
|
|
86253
|
+
if (!this.table) return;
|
|
86254
|
+
const sheetKey = this.getSheetKey(),
|
|
86255
|
+
{
|
|
86256
|
+
columnIndex: columnIndex,
|
|
86257
|
+
columnCount: columnCount,
|
|
86258
|
+
columns: columns
|
|
86259
|
+
} = eventArgs,
|
|
86260
|
+
cmd = {
|
|
86261
|
+
type: "add_column",
|
|
86262
|
+
sheetKey: sheetKey,
|
|
86263
|
+
columnIndex: columnIndex,
|
|
86264
|
+
columnCount: columnCount,
|
|
86265
|
+
columns: columns.slice(columnIndex, columnIndex + columnCount).map(c => cloneDeep(c))
|
|
86266
|
+
};
|
|
86267
|
+
this.pushCommand(cmd);
|
|
86268
|
+
}
|
|
86269
|
+
handleDeleteColumn(eventArgs) {
|
|
86270
|
+
if (!this.table) return;
|
|
86271
|
+
const sheetKey = this.getSheetKey(),
|
|
86272
|
+
deleteColIndexs = (eventArgs.deleteColIndexs || []).slice(),
|
|
86273
|
+
deletedColumnsFromEvent = eventArgs.deletedColumns,
|
|
86274
|
+
prevColumns = this.prevColumnsSnapshot || [],
|
|
86275
|
+
deletedColumns = Array.isArray(deletedColumnsFromEvent) ? deletedColumnsFromEvent.map(c => cloneDeep(c)) : [];
|
|
86276
|
+
deletedColumns.length || deleteColIndexs.forEach(idx => {
|
|
86277
|
+
idx >= 0 && idx < prevColumns.length && deletedColumns.push(cloneDeep(prevColumns[idx]));
|
|
86278
|
+
});
|
|
86279
|
+
let deletedFormulas,
|
|
86280
|
+
deletedColWidths,
|
|
86281
|
+
deletedRecordValues = eventArgs.deletedRecordValues;
|
|
86282
|
+
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) {
|
|
86283
|
+
Object.entries(this.prevFormulasSnapshot).forEach(([cellRef, formula]) => {
|
|
86284
|
+
const parsed = parseA1Notation(cellRef);
|
|
86285
|
+
parsed && deleteColIndexs.includes(parsed.col) && (deletedFormulas || (deletedFormulas = {}), deletedFormulas[cellRef] = formula);
|
|
86286
|
+
});
|
|
86287
|
+
}
|
|
86288
|
+
this.prevResizedColWidthsSnapshot && deleteColIndexs.length && deleteColIndexs.forEach(idx => {
|
|
86289
|
+
var _a;
|
|
86290
|
+
const w = null === (_a = this.prevResizedColWidthsSnapshot) || void 0 === _a ? void 0 : _a[idx];
|
|
86291
|
+
"number" == typeof w && (deletedColWidths || (deletedColWidths = {}), deletedColWidths[idx] = w);
|
|
86292
|
+
});
|
|
86293
|
+
const cmd = {
|
|
86294
|
+
type: "delete_column",
|
|
86295
|
+
sheetKey: sheetKey,
|
|
86296
|
+
deleteColIndexs: deleteColIndexs,
|
|
86297
|
+
columns: deletedColumns,
|
|
86298
|
+
deletedRecordValues: deletedRecordValues,
|
|
86299
|
+
deletedFormulas: deletedFormulas,
|
|
86300
|
+
deletedColWidths: deletedColWidths
|
|
86301
|
+
};
|
|
86302
|
+
this.pushCommand(cmd);
|
|
86303
|
+
}
|
|
86304
|
+
handleChangeHeaderPosition(eventArgs) {
|
|
86305
|
+
var _a;
|
|
86306
|
+
const sheetKey = this.getSheetKey(),
|
|
86307
|
+
moving = null !== (_a = eventArgs.movingColumnOrRow) && void 0 !== _a ? _a : "column",
|
|
86308
|
+
cmd = {
|
|
86309
|
+
type: "change_header_position",
|
|
86310
|
+
sheetKey: sheetKey,
|
|
86311
|
+
moving: moving,
|
|
86312
|
+
sourceIndex: "column" === moving ? eventArgs.source.col : eventArgs.source.row,
|
|
86313
|
+
targetIndex: "column" === moving ? eventArgs.target.col : eventArgs.target.row
|
|
86314
|
+
};
|
|
86315
|
+
this.pushCommand(cmd);
|
|
86316
|
+
}
|
|
86317
|
+
normalizeSortState(input) {
|
|
86318
|
+
if (!input) return null;
|
|
86319
|
+
if (Array.isArray(input)) {
|
|
86320
|
+
const list = input.filter(Boolean).map(s => ({
|
|
86321
|
+
field: s.field,
|
|
86322
|
+
order: s.order
|
|
86323
|
+
})).filter(s => void 0 !== s.field && s.order && "normal" !== s.order);
|
|
86324
|
+
return list.length ? list : null;
|
|
86325
|
+
}
|
|
86326
|
+
const s = input;
|
|
86327
|
+
return void 0 !== s.field && s.order && "normal" !== s.order ? {
|
|
86328
|
+
field: s.field,
|
|
86329
|
+
order: s.order
|
|
86330
|
+
} : null;
|
|
86331
|
+
}
|
|
86332
|
+
handleSortClick(_eventArgs) {
|
|
86333
|
+
this.table && (this.sortStartSnapshot = this.lastKnownSortState, this.sortPending = !0, setTimeout(() => {
|
|
86334
|
+
this.sortPending && (this.sortPending = !1, this.sortStartSnapshot = null);
|
|
86335
|
+
}, 0));
|
|
86336
|
+
}
|
|
86337
|
+
handleResizeRow(eventArgs) {
|
|
86338
|
+
var _a, _b;
|
|
86339
|
+
if (!this.table) return;
|
|
86340
|
+
const row = eventArgs.row;
|
|
86341
|
+
if (!this.resizeRowStartHeight.has(row)) {
|
|
86342
|
+
const oldHeight = null === (_b = (_a = this.table).getRowHeight) || void 0 === _b ? void 0 : _b.call(_a, row);
|
|
86343
|
+
"number" == typeof oldHeight && this.resizeRowStartHeight.set(row, oldHeight);
|
|
86344
|
+
}
|
|
86345
|
+
}
|
|
86346
|
+
handleResizeRowEnd(eventArgs) {
|
|
86347
|
+
var _a;
|
|
86348
|
+
if (!this.table) return;
|
|
86349
|
+
const sheetKey = this.getSheetKey(),
|
|
86350
|
+
row = eventArgs.row,
|
|
86351
|
+
newHeight = eventArgs.rowHeight,
|
|
86352
|
+
oldHeight = null !== (_a = this.resizeRowStartHeight.get(row)) && void 0 !== _a ? _a : newHeight;
|
|
86353
|
+
if (this.resizeRowStartHeight.delete(row), "number" == typeof oldHeight && "number" == typeof newHeight && oldHeight === newHeight) return;
|
|
86354
|
+
const cmd = {
|
|
86355
|
+
type: "resize_row",
|
|
86356
|
+
sheetKey: sheetKey,
|
|
86357
|
+
row: row,
|
|
86358
|
+
oldHeight: oldHeight,
|
|
86359
|
+
newHeight: newHeight
|
|
86360
|
+
};
|
|
86361
|
+
this.pushCommand(cmd);
|
|
86362
|
+
}
|
|
86363
|
+
handleResizeColumn(eventArgs) {
|
|
86364
|
+
var _a, _b;
|
|
86365
|
+
if (!this.table) return;
|
|
86366
|
+
const col = eventArgs.col;
|
|
86367
|
+
if (!this.resizeColStartWidth.has(col)) {
|
|
86368
|
+
const oldWidth = null === (_b = (_a = this.table).getColWidth) || void 0 === _b ? void 0 : _b.call(_a, col);
|
|
86369
|
+
"number" == typeof oldWidth && this.resizeColStartWidth.set(col, oldWidth);
|
|
86370
|
+
}
|
|
86371
|
+
}
|
|
86372
|
+
handleResizeColumnEnd(eventArgs) {
|
|
86373
|
+
var _a, _b, _c, _d;
|
|
86374
|
+
if (!this.table) return;
|
|
86375
|
+
const sheetKey = this.getSheetKey(),
|
|
86376
|
+
col = eventArgs.col,
|
|
86377
|
+
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),
|
|
86378
|
+
oldWidth = null !== (_d = this.resizeColStartWidth.get(col)) && void 0 !== _d ? _d : newWidth;
|
|
86379
|
+
if (this.resizeColStartWidth.delete(col), "number" == typeof oldWidth && "number" == typeof newWidth && oldWidth === newWidth) return;
|
|
86380
|
+
const cmd = {
|
|
86381
|
+
type: "resize_column",
|
|
86382
|
+
sheetKey: sheetKey,
|
|
86383
|
+
col: col,
|
|
86384
|
+
oldWidth: oldWidth,
|
|
86385
|
+
newWidth: newWidth
|
|
86386
|
+
};
|
|
86387
|
+
this.pushCommand(cmd);
|
|
86388
|
+
}
|
|
86389
|
+
applyCommand(cmd, direction) {
|
|
86390
|
+
this.table && replayCommand({
|
|
86391
|
+
table: this.table,
|
|
86392
|
+
vtableSheet: this.vtableSheet,
|
|
86393
|
+
cmd: cmd,
|
|
86394
|
+
direction: direction,
|
|
86395
|
+
deleteRecordsByReference: records => this.deleteRecordsByReference(records)
|
|
86396
|
+
});
|
|
86397
|
+
}
|
|
86398
|
+
deleteRecordsByReference(records) {
|
|
86399
|
+
if (!this.table || !(null == records ? void 0 : records.length)) return;
|
|
86400
|
+
const tableRecords = this.table.records || [],
|
|
86401
|
+
indexs = [];
|
|
86402
|
+
records.forEach(rec => {
|
|
86403
|
+
const idx = tableRecords.indexOf(rec);
|
|
86404
|
+
idx >= 0 && indexs.push(idx);
|
|
86405
|
+
}), indexs.length && this.table.deleteRecords && this.table.deleteRecords(indexs);
|
|
86406
|
+
}
|
|
86407
|
+
}
|
|
86408
|
+
|
|
84767
86409
|
class FormulaAutocomplete {
|
|
84768
86410
|
container;
|
|
84769
86411
|
dropdown = null;
|
|
@@ -85263,12 +86905,41 @@
|
|
|
85263
86905
|
if (!this.element || !this.sheet) {
|
|
85264
86906
|
return;
|
|
85265
86907
|
}
|
|
85266
|
-
|
|
85267
|
-
|
|
85268
|
-
const
|
|
85269
|
-
|
|
85270
|
-
|
|
86908
|
+
const value = this.element.value;
|
|
86909
|
+
const selectionStart = this.element.selectionStart ?? value.length;
|
|
86910
|
+
const selectionEnd = this.element.selectionEnd ?? selectionStart;
|
|
86911
|
+
let replaceStart = selectionStart;
|
|
86912
|
+
let replaceEnd = selectionEnd;
|
|
86913
|
+
if (selectionStart === selectionEnd) {
|
|
86914
|
+
replaceStart = selectionStart;
|
|
86915
|
+
while (replaceStart > 1 && /[A-Za-z0-9]/.test(value[replaceStart - 1])) {
|
|
86916
|
+
replaceStart--;
|
|
86917
|
+
}
|
|
86918
|
+
const hasLeftWord = replaceStart < selectionStart;
|
|
86919
|
+
replaceEnd = selectionStart;
|
|
86920
|
+
if (hasLeftWord) {
|
|
86921
|
+
while (replaceEnd < value.length && /[A-Za-z0-9]/.test(value[replaceEnd])) {
|
|
86922
|
+
replaceEnd++;
|
|
86923
|
+
}
|
|
86924
|
+
}
|
|
85271
86925
|
}
|
|
86926
|
+
const isFunction = item?.type === 'function';
|
|
86927
|
+
const itemValue = String(item?.value ?? '');
|
|
86928
|
+
const nextChar = value[replaceEnd];
|
|
86929
|
+
const shouldAppendParen = isFunction && nextChar !== '(';
|
|
86930
|
+
const insertText = itemValue + (shouldAppendParen ? '(' : '');
|
|
86931
|
+
const newValue = value.slice(0, replaceStart) + insertText + value.slice(replaceEnd);
|
|
86932
|
+
this.element.value = newValue;
|
|
86933
|
+
let newCursorPos = replaceStart + itemValue.length;
|
|
86934
|
+
if (isFunction && newValue[newCursorPos] === '(') {
|
|
86935
|
+
newCursorPos += 1;
|
|
86936
|
+
}
|
|
86937
|
+
this.element.setSelectionRange(newCursorPos, newCursorPos);
|
|
86938
|
+
if (this.sheet.formulaUIManager.formulaInput) {
|
|
86939
|
+
this.sheet.formulaUIManager.formulaInput.value = newValue;
|
|
86940
|
+
}
|
|
86941
|
+
const inputEvent = new Event('input', { bubbles: true });
|
|
86942
|
+
this.element.dispatchEvent(inputEvent);
|
|
85272
86943
|
}
|
|
85273
86944
|
onStart(context) {
|
|
85274
86945
|
const formula = this.sheet.formulaManager.getCellFormula({
|
|
@@ -85360,7 +87031,9 @@
|
|
|
85360
87031
|
return `${startCol}${startRow}:${endCol}${endRow}`;
|
|
85361
87032
|
}
|
|
85362
87033
|
}
|
|
85363
|
-
|
|
87034
|
+
function createFormulaEditor() {
|
|
87035
|
+
return new FormulaInputEditor();
|
|
87036
|
+
}
|
|
85364
87037
|
|
|
85365
87038
|
class FormulaUIManager {
|
|
85366
87039
|
sheet;
|
|
@@ -87514,7 +89187,7 @@
|
|
|
87514
89187
|
}
|
|
87515
89188
|
return this.addSheet(sheetKey);
|
|
87516
89189
|
}
|
|
87517
|
-
setCellContent(cell, value) {
|
|
89190
|
+
setCellContent(cell, value, options) {
|
|
87518
89191
|
this.ensureInitialized();
|
|
87519
89192
|
if (!cell || cell.sheet === undefined || cell.row === undefined || cell.col === undefined) {
|
|
87520
89193
|
throw new Error('Invalid cell parameter for setCellContent');
|
|
@@ -87532,16 +89205,18 @@
|
|
|
87532
89205
|
else {
|
|
87533
89206
|
this.formulaEngine.setCellContent(cell, value);
|
|
87534
89207
|
}
|
|
87535
|
-
|
|
87536
|
-
|
|
87537
|
-
|
|
87538
|
-
|
|
87539
|
-
|
|
87540
|
-
|
|
89208
|
+
if (options?.emitEvent !== false) {
|
|
89209
|
+
const newFormula = this.getCellFormula(cell);
|
|
89210
|
+
if (newFormula && newFormula !== oldFormula) {
|
|
89211
|
+
this.emitFormulaEvent(cell, 'added', newFormula);
|
|
89212
|
+
}
|
|
89213
|
+
else if (!newFormula && oldFormula) {
|
|
89214
|
+
this.emitFormulaEvent(cell, 'removed', oldFormula);
|
|
89215
|
+
}
|
|
87541
89216
|
}
|
|
87542
89217
|
}
|
|
87543
89218
|
catch (error) {
|
|
87544
|
-
if (typeof value === 'string' && value.startsWith('=')) {
|
|
89219
|
+
if (options?.emitEvent !== false && typeof value === 'string' && value.startsWith('=')) {
|
|
87545
89220
|
this.emitFormulaEvent(cell, 'error', value, error);
|
|
87546
89221
|
}
|
|
87547
89222
|
if (error instanceof Error) {
|
|
@@ -88791,6 +90466,7 @@
|
|
|
88791
90466
|
maintainArrayDataOrder: true
|
|
88792
90467
|
},
|
|
88793
90468
|
addRecordRule: 'Array',
|
|
90469
|
+
syncRecordOperationsToSourceRecords: true,
|
|
88794
90470
|
defaultCursor: 'cell',
|
|
88795
90471
|
records: this.options.data,
|
|
88796
90472
|
sortState: this.options.sortState,
|
|
@@ -88946,54 +90622,6 @@
|
|
|
88946
90622
|
if (rowIndexs && rowIndexs.length > 0) {
|
|
88947
90623
|
const minIndex = Math.min(...rowIndexs.flat());
|
|
88948
90624
|
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
90625
|
}
|
|
88998
90626
|
}
|
|
88999
90627
|
}
|
|
@@ -89021,54 +90649,6 @@
|
|
|
89021
90649
|
const minIndex = Math.min(...deleteColIndexs.flat());
|
|
89022
90650
|
const deletedCount = deleteColIndexs.length;
|
|
89023
90651
|
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
90652
|
}
|
|
89073
90653
|
}
|
|
89074
90654
|
}
|
|
@@ -89411,6 +90991,20 @@
|
|
|
89411
90991
|
const plugins = [];
|
|
89412
90992
|
const disabledPluginsUserSetted = options?.VTablePluginModules?.filter(module => module.disabled);
|
|
89413
90993
|
let enabledPluginsUserSetted = options?.VTablePluginModules?.filter(module => !module.disabled);
|
|
90994
|
+
if (vtableSheet?.getWorkbookHistoryManager &&
|
|
90995
|
+
!disabledPluginsUserSetted?.some(module => module.module === HistoryPlugin) &&
|
|
90996
|
+
!enabledPluginsUserSetted?.some(module => module.module === HistoryPlugin)) {
|
|
90997
|
+
const workbookHistory = vtableSheet.getWorkbookHistoryManager();
|
|
90998
|
+
if (typeof HistoryPlugin !== 'function') ;
|
|
90999
|
+
else {
|
|
91000
|
+
plugins.push(new HistoryPlugin({
|
|
91001
|
+
enableCompression: false,
|
|
91002
|
+
onTransactionPushed: (args) => {
|
|
91003
|
+
workbookHistory.recordTableTransaction({ sheetKey: args?.sheetKey, tx: args?.tx });
|
|
91004
|
+
}
|
|
91005
|
+
}));
|
|
91006
|
+
}
|
|
91007
|
+
}
|
|
89414
91008
|
if (!disabledPluginsUserSetted?.some(module => module.module === FilterPlugin)) {
|
|
89415
91009
|
const userPluginOptions = enabledPluginsUserSetted?.find(module => module.module === FilterPlugin)
|
|
89416
91010
|
?.moduleOptions;
|
|
@@ -89490,7 +91084,20 @@
|
|
|
89490
91084
|
if (enabledPluginsUserSetted?.length) {
|
|
89491
91085
|
enabledPluginsUserSetted.forEach((module) => {
|
|
89492
91086
|
if (typeof module?.module === 'function') {
|
|
89493
|
-
|
|
91087
|
+
let moduleOptions = module.moduleOptions;
|
|
91088
|
+
if (module.module === HistoryPlugin && vtableSheet?.getWorkbookHistoryManager) {
|
|
91089
|
+
const workbookHistory = vtableSheet.getWorkbookHistoryManager();
|
|
91090
|
+
const prev = moduleOptions?.onTransactionPushed;
|
|
91091
|
+
moduleOptions = {
|
|
91092
|
+
...(moduleOptions ?? {}),
|
|
91093
|
+
enableCompression: moduleOptions?.enableCompression ?? false,
|
|
91094
|
+
onTransactionPushed: (args) => {
|
|
91095
|
+
prev?.(args);
|
|
91096
|
+
workbookHistory.recordTableTransaction({ sheetKey: args?.sheetKey, tx: args?.tx });
|
|
91097
|
+
}
|
|
91098
|
+
};
|
|
91099
|
+
}
|
|
91100
|
+
plugins.push(new module.module(moduleOptions));
|
|
89494
91101
|
}
|
|
89495
91102
|
});
|
|
89496
91103
|
}
|
|
@@ -89975,9 +91582,7 @@
|
|
|
89975
91582
|
}
|
|
89976
91583
|
performTabReorder(sourceKey, targetKey, position) {
|
|
89977
91584
|
try {
|
|
89978
|
-
this.sheet.
|
|
89979
|
-
this.sheet.updateSheetTabs();
|
|
89980
|
-
this.sheet.updateSheetMenu();
|
|
91585
|
+
this.sheet.reorderSheet(sourceKey, targetKey, position);
|
|
89981
91586
|
}
|
|
89982
91587
|
catch (error) {
|
|
89983
91588
|
}
|
|
@@ -89996,10 +91601,18 @@
|
|
|
89996
91601
|
class MenuManager {
|
|
89997
91602
|
sheet;
|
|
89998
91603
|
menuContainer;
|
|
91604
|
+
undoButton = null;
|
|
91605
|
+
redoButton = null;
|
|
89999
91606
|
clickOutsideHandler;
|
|
91607
|
+
historyUnsubscribe = null;
|
|
90000
91608
|
constructor(sheet) {
|
|
90001
91609
|
this.sheet = sheet;
|
|
90002
|
-
|
|
91610
|
+
}
|
|
91611
|
+
createUndoRedoOnly() {
|
|
91612
|
+
const wrap = document.createElement('div');
|
|
91613
|
+
wrap.className = 'vtable-sheet-undo-redo';
|
|
91614
|
+
this.mountUndoRedoActions(wrap);
|
|
91615
|
+
return wrap;
|
|
90003
91616
|
}
|
|
90004
91617
|
createMainMenu() {
|
|
90005
91618
|
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 +91623,7 @@
|
|
|
90010
91623
|
menuButton.className = 'vtable-sheet-main-menu-button';
|
|
90011
91624
|
menuButton.innerHTML = menuIcon;
|
|
90012
91625
|
menu.appendChild(menuButton);
|
|
91626
|
+
this.mountUndoRedoActions(menu);
|
|
90013
91627
|
const menuContainer = document.createElement('div');
|
|
90014
91628
|
menuContainer.className = 'vtable-sheet-main-menu-container';
|
|
90015
91629
|
menu.appendChild(menuContainer);
|
|
@@ -90058,6 +91672,55 @@
|
|
|
90058
91672
|
this.menuContainer = menuContainer;
|
|
90059
91673
|
return menu;
|
|
90060
91674
|
}
|
|
91675
|
+
mountUndoRedoActions(container) {
|
|
91676
|
+
const showUndoRedo = this.sheet.getOptions().undoRedo?.show ?? true;
|
|
91677
|
+
if (!showUndoRedo) {
|
|
91678
|
+
this.undoButton = null;
|
|
91679
|
+
this.redoButton = null;
|
|
91680
|
+
this.historyUnsubscribe?.();
|
|
91681
|
+
this.historyUnsubscribe = null;
|
|
91682
|
+
return;
|
|
91683
|
+
}
|
|
91684
|
+
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>`;
|
|
91685
|
+
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>`;
|
|
91686
|
+
const actions = document.createElement('div');
|
|
91687
|
+
actions.className = 'vtable-sheet-main-menu-actions';
|
|
91688
|
+
container.appendChild(actions);
|
|
91689
|
+
this.undoButton = document.createElement('button');
|
|
91690
|
+
this.undoButton.className = 'vtable-sheet-main-menu-action';
|
|
91691
|
+
this.undoButton.type = 'button';
|
|
91692
|
+
this.undoButton.title = '撤销';
|
|
91693
|
+
this.undoButton.innerHTML = undoIcon;
|
|
91694
|
+
this.undoButton.addEventListener('click', e => {
|
|
91695
|
+
e.stopPropagation();
|
|
91696
|
+
this.sheet.undo();
|
|
91697
|
+
});
|
|
91698
|
+
actions.appendChild(this.undoButton);
|
|
91699
|
+
this.redoButton = document.createElement('button');
|
|
91700
|
+
this.redoButton.className = 'vtable-sheet-main-menu-action';
|
|
91701
|
+
this.redoButton.type = 'button';
|
|
91702
|
+
this.redoButton.title = '重做';
|
|
91703
|
+
this.redoButton.innerHTML = redoIcon;
|
|
91704
|
+
this.redoButton.addEventListener('click', e => {
|
|
91705
|
+
e.stopPropagation();
|
|
91706
|
+
this.sheet.redo();
|
|
91707
|
+
});
|
|
91708
|
+
actions.appendChild(this.redoButton);
|
|
91709
|
+
this.historyUnsubscribe?.();
|
|
91710
|
+
this.historyUnsubscribe = this.sheet.getWorkbookHistoryManager().onChange(() => {
|
|
91711
|
+
this.updateUndoRedoState();
|
|
91712
|
+
});
|
|
91713
|
+
this.updateUndoRedoState();
|
|
91714
|
+
}
|
|
91715
|
+
updateUndoRedoState() {
|
|
91716
|
+
const history = this.sheet.getWorkbookHistoryManager();
|
|
91717
|
+
if (this.undoButton) {
|
|
91718
|
+
this.undoButton.disabled = !history.canUndo();
|
|
91719
|
+
}
|
|
91720
|
+
if (this.redoButton) {
|
|
91721
|
+
this.redoButton.disabled = !history.canRedo();
|
|
91722
|
+
}
|
|
91723
|
+
}
|
|
90061
91724
|
createSubMenu(items) {
|
|
90062
91725
|
const subMenuContainer = document.createElement('div');
|
|
90063
91726
|
subMenuContainer.className = 'vtable-sheet-submenu-container';
|
|
@@ -90176,10 +91839,12 @@
|
|
|
90176
91839
|
document.removeEventListener('click', this.clickOutsideHandler);
|
|
90177
91840
|
this.clickOutsideHandler = null;
|
|
90178
91841
|
}
|
|
91842
|
+
this.historyUnsubscribe?.();
|
|
91843
|
+
this.historyUnsubscribe = null;
|
|
90179
91844
|
}
|
|
90180
91845
|
updateMainMenu(mainMenu) {
|
|
90181
91846
|
this.release();
|
|
90182
|
-
this.createMainMenu();
|
|
91847
|
+
return this.createMainMenu();
|
|
90183
91848
|
}
|
|
90184
91849
|
}
|
|
90185
91850
|
|
|
@@ -90246,11 +91911,7 @@
|
|
|
90246
91911
|
showSnackbar('工作表名称已存在,请重新输入', 1300);
|
|
90247
91912
|
return false;
|
|
90248
91913
|
}
|
|
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();
|
|
91914
|
+
this.vTableSheet.renameSheet(sheetKey, newTitle);
|
|
90254
91915
|
return true;
|
|
90255
91916
|
}
|
|
90256
91917
|
getSheetTabElementByKey(sheetKey) {
|
|
@@ -90800,7 +92461,430 @@
|
|
|
90800
92461
|
}
|
|
90801
92462
|
}
|
|
90802
92463
|
|
|
90803
|
-
|
|
92464
|
+
function cloneJson(input) {
|
|
92465
|
+
return JSON.parse(JSON.stringify(input));
|
|
92466
|
+
}
|
|
92467
|
+
function cloneSafe(input) {
|
|
92468
|
+
const sc = globalThis.structuredClone;
|
|
92469
|
+
if (typeof sc === 'function') {
|
|
92470
|
+
try {
|
|
92471
|
+
return sc(input);
|
|
92472
|
+
}
|
|
92473
|
+
catch { }
|
|
92474
|
+
}
|
|
92475
|
+
return cloneJson(input);
|
|
92476
|
+
}
|
|
92477
|
+
class WorkbookHistoryManager {
|
|
92478
|
+
sheet;
|
|
92479
|
+
undoStack = [];
|
|
92480
|
+
redoStack = [];
|
|
92481
|
+
currentTransaction = null;
|
|
92482
|
+
maxHistory;
|
|
92483
|
+
enabled = true;
|
|
92484
|
+
isReplaying = false;
|
|
92485
|
+
changeListeners = new Set();
|
|
92486
|
+
constructor(sheet, options) {
|
|
92487
|
+
this.sheet = sheet;
|
|
92488
|
+
this.maxHistory = options?.maxHistory ?? 100;
|
|
92489
|
+
}
|
|
92490
|
+
canUndo() {
|
|
92491
|
+
return this.undoStack.length > 0;
|
|
92492
|
+
}
|
|
92493
|
+
canRedo() {
|
|
92494
|
+
return this.redoStack.length > 0;
|
|
92495
|
+
}
|
|
92496
|
+
onChange(listener) {
|
|
92497
|
+
this.changeListeners.add(listener);
|
|
92498
|
+
return () => {
|
|
92499
|
+
this.changeListeners.delete(listener);
|
|
92500
|
+
};
|
|
92501
|
+
}
|
|
92502
|
+
emitChange() {
|
|
92503
|
+
this.changeListeners.forEach(fn => {
|
|
92504
|
+
try {
|
|
92505
|
+
fn();
|
|
92506
|
+
}
|
|
92507
|
+
catch { }
|
|
92508
|
+
});
|
|
92509
|
+
}
|
|
92510
|
+
suspend() {
|
|
92511
|
+
this.enabled = false;
|
|
92512
|
+
}
|
|
92513
|
+
resume() {
|
|
92514
|
+
this.enabled = true;
|
|
92515
|
+
}
|
|
92516
|
+
startTransaction() {
|
|
92517
|
+
if (this.currentTransaction) {
|
|
92518
|
+
return;
|
|
92519
|
+
}
|
|
92520
|
+
this.currentTransaction = { commands: [] };
|
|
92521
|
+
}
|
|
92522
|
+
endTransaction() {
|
|
92523
|
+
if (!this.currentTransaction || this.currentTransaction.commands.length === 0) {
|
|
92524
|
+
this.currentTransaction = null;
|
|
92525
|
+
return;
|
|
92526
|
+
}
|
|
92527
|
+
this.pushTransaction(this.currentTransaction);
|
|
92528
|
+
this.currentTransaction = null;
|
|
92529
|
+
}
|
|
92530
|
+
clear() {
|
|
92531
|
+
this.undoStack = [];
|
|
92532
|
+
this.redoStack = [];
|
|
92533
|
+
this.currentTransaction = null;
|
|
92534
|
+
this.emitChange();
|
|
92535
|
+
}
|
|
92536
|
+
updateOptions(options) {
|
|
92537
|
+
if (options.maxHistory != null) {
|
|
92538
|
+
this.maxHistory = options.maxHistory;
|
|
92539
|
+
this.trimHistory();
|
|
92540
|
+
this.emitChange();
|
|
92541
|
+
}
|
|
92542
|
+
}
|
|
92543
|
+
undo() {
|
|
92544
|
+
if (this.undoStack.length === 0) {
|
|
92545
|
+
return;
|
|
92546
|
+
}
|
|
92547
|
+
const tx = this.undoStack.pop();
|
|
92548
|
+
this.isReplaying = true;
|
|
92549
|
+
this.sheet.__workbookHistoryReplaying = true;
|
|
92550
|
+
try {
|
|
92551
|
+
for (let i = tx.commands.length - 1; i >= 0; i--) {
|
|
92552
|
+
this.applyCommand(tx.commands[i], 'undo');
|
|
92553
|
+
}
|
|
92554
|
+
}
|
|
92555
|
+
finally {
|
|
92556
|
+
this.isReplaying = false;
|
|
92557
|
+
this.sheet.__workbookHistoryReplaying = false;
|
|
92558
|
+
}
|
|
92559
|
+
this.redoStack.push(tx);
|
|
92560
|
+
this.emitChange();
|
|
92561
|
+
}
|
|
92562
|
+
redo() {
|
|
92563
|
+
if (this.redoStack.length === 0) {
|
|
92564
|
+
return;
|
|
92565
|
+
}
|
|
92566
|
+
const tx = this.redoStack.pop();
|
|
92567
|
+
this.isReplaying = true;
|
|
92568
|
+
this.sheet.__workbookHistoryReplaying = true;
|
|
92569
|
+
try {
|
|
92570
|
+
for (const cmd of tx.commands) {
|
|
92571
|
+
this.applyCommand(cmd, 'redo');
|
|
92572
|
+
}
|
|
92573
|
+
}
|
|
92574
|
+
finally {
|
|
92575
|
+
this.isReplaying = false;
|
|
92576
|
+
this.sheet.__workbookHistoryReplaying = false;
|
|
92577
|
+
}
|
|
92578
|
+
this.undoStack.push(tx);
|
|
92579
|
+
this.emitChange();
|
|
92580
|
+
}
|
|
92581
|
+
recordTableTransaction(args) {
|
|
92582
|
+
if (!this.enabled || this.isReplaying) {
|
|
92583
|
+
return;
|
|
92584
|
+
}
|
|
92585
|
+
const sheetKey = args.sheetKey ?? this.getActiveSheetKey();
|
|
92586
|
+
if (!sheetKey) {
|
|
92587
|
+
return;
|
|
92588
|
+
}
|
|
92589
|
+
const cmd = {
|
|
92590
|
+
type: 'table_tx',
|
|
92591
|
+
sheetKey,
|
|
92592
|
+
tx: cloneSafe(args.tx)
|
|
92593
|
+
};
|
|
92594
|
+
this.pushCommand(cmd);
|
|
92595
|
+
}
|
|
92596
|
+
addSheet(args) {
|
|
92597
|
+
if (!this.enabled || this.isReplaying) {
|
|
92598
|
+
this.addSheetInternal(args.sheet, args.activate);
|
|
92599
|
+
return;
|
|
92600
|
+
}
|
|
92601
|
+
const orderBefore = this.getSheetOrder();
|
|
92602
|
+
const activeBefore = this.getActiveSheetKey();
|
|
92603
|
+
this.startTransaction();
|
|
92604
|
+
try {
|
|
92605
|
+
this.addSheetInternal(args.sheet, args.activate);
|
|
92606
|
+
const orderAfter = this.getSheetOrder();
|
|
92607
|
+
const activeAfter = this.getActiveSheetKey();
|
|
92608
|
+
const cmd = {
|
|
92609
|
+
type: 'sheet_add',
|
|
92610
|
+
sheet: cloneSafe(args.sheet),
|
|
92611
|
+
orderBefore,
|
|
92612
|
+
orderAfter,
|
|
92613
|
+
activeBefore,
|
|
92614
|
+
activeAfter
|
|
92615
|
+
};
|
|
92616
|
+
this.pushCommand(cmd);
|
|
92617
|
+
}
|
|
92618
|
+
finally {
|
|
92619
|
+
this.endTransaction();
|
|
92620
|
+
}
|
|
92621
|
+
}
|
|
92622
|
+
removeSheet(sheetKey) {
|
|
92623
|
+
if (!this.enabled || this.isReplaying) {
|
|
92624
|
+
this.removeSheetInternal(sheetKey);
|
|
92625
|
+
return;
|
|
92626
|
+
}
|
|
92627
|
+
const sheetDefine = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92628
|
+
if (!sheetDefine) {
|
|
92629
|
+
return;
|
|
92630
|
+
}
|
|
92631
|
+
const orderBefore = this.getSheetOrder();
|
|
92632
|
+
const activeBefore = this.getActiveSheetKey();
|
|
92633
|
+
this.startTransaction();
|
|
92634
|
+
try {
|
|
92635
|
+
this.removeSheetInternal(sheetKey);
|
|
92636
|
+
const orderAfter = this.getSheetOrder();
|
|
92637
|
+
const activeAfter = this.getActiveSheetKey();
|
|
92638
|
+
const cmd = {
|
|
92639
|
+
type: 'sheet_remove',
|
|
92640
|
+
sheet: cloneSafe(sheetDefine),
|
|
92641
|
+
orderBefore,
|
|
92642
|
+
orderAfter,
|
|
92643
|
+
activeBefore,
|
|
92644
|
+
activeAfter
|
|
92645
|
+
};
|
|
92646
|
+
this.pushCommand(cmd);
|
|
92647
|
+
}
|
|
92648
|
+
finally {
|
|
92649
|
+
this.endTransaction();
|
|
92650
|
+
}
|
|
92651
|
+
}
|
|
92652
|
+
renameSheet(sheetKey, newTitle) {
|
|
92653
|
+
const sheetDefine = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92654
|
+
if (!sheetDefine) {
|
|
92655
|
+
return;
|
|
92656
|
+
}
|
|
92657
|
+
const oldTitle = sheetDefine.sheetTitle;
|
|
92658
|
+
if (!this.enabled || this.isReplaying) {
|
|
92659
|
+
this.renameSheetInternal(sheetKey, newTitle);
|
|
92660
|
+
return;
|
|
92661
|
+
}
|
|
92662
|
+
this.startTransaction();
|
|
92663
|
+
try {
|
|
92664
|
+
this.renameSheetInternal(sheetKey, newTitle);
|
|
92665
|
+
const cmd = { type: 'sheet_rename', sheetKey, oldTitle, newTitle };
|
|
92666
|
+
this.pushCommand(cmd);
|
|
92667
|
+
}
|
|
92668
|
+
finally {
|
|
92669
|
+
this.endTransaction();
|
|
92670
|
+
}
|
|
92671
|
+
}
|
|
92672
|
+
reorderSheet(sourceKey, targetKey, position) {
|
|
92673
|
+
if (!this.enabled || this.isReplaying) {
|
|
92674
|
+
this.sheet.getSheetManager().reorderSheet(sourceKey, targetKey, position);
|
|
92675
|
+
this.sheet.updateSheetTabs();
|
|
92676
|
+
this.sheet.updateSheetMenu();
|
|
92677
|
+
return;
|
|
92678
|
+
}
|
|
92679
|
+
const orderBefore = this.getSheetOrder();
|
|
92680
|
+
this.startTransaction();
|
|
92681
|
+
try {
|
|
92682
|
+
this.sheet.getSheetManager().reorderSheet(sourceKey, targetKey, position);
|
|
92683
|
+
this.sheet.updateSheetTabs();
|
|
92684
|
+
this.sheet.updateSheetMenu();
|
|
92685
|
+
const orderAfter = this.getSheetOrder();
|
|
92686
|
+
const cmd = { type: 'sheet_reorder', orderBefore, orderAfter };
|
|
92687
|
+
this.pushCommand(cmd);
|
|
92688
|
+
}
|
|
92689
|
+
finally {
|
|
92690
|
+
this.endTransaction();
|
|
92691
|
+
}
|
|
92692
|
+
}
|
|
92693
|
+
pushTransaction(tx) {
|
|
92694
|
+
if (!tx.commands.length) {
|
|
92695
|
+
return;
|
|
92696
|
+
}
|
|
92697
|
+
this.undoStack.push(tx);
|
|
92698
|
+
this.redoStack = [];
|
|
92699
|
+
this.trimHistory();
|
|
92700
|
+
this.emitChange();
|
|
92701
|
+
}
|
|
92702
|
+
pushCommand(cmd) {
|
|
92703
|
+
if (this.currentTransaction) {
|
|
92704
|
+
this.currentTransaction.commands.push(cmd);
|
|
92705
|
+
return;
|
|
92706
|
+
}
|
|
92707
|
+
this.pushTransaction({ commands: [cmd] });
|
|
92708
|
+
}
|
|
92709
|
+
trimHistory() {
|
|
92710
|
+
if (this.undoStack.length > this.maxHistory) {
|
|
92711
|
+
this.undoStack.splice(0, this.undoStack.length - this.maxHistory);
|
|
92712
|
+
}
|
|
92713
|
+
}
|
|
92714
|
+
applyCommand(cmd, direction) {
|
|
92715
|
+
switch (cmd.type) {
|
|
92716
|
+
case 'sheet_add': {
|
|
92717
|
+
if (direction === 'undo') {
|
|
92718
|
+
this.removeSheetInternal(cmd.sheet.sheetKey);
|
|
92719
|
+
this.setSheetOrder(cmd.orderBefore);
|
|
92720
|
+
if (cmd.activeBefore) {
|
|
92721
|
+
this.sheet.activateSheet(cmd.activeBefore);
|
|
92722
|
+
}
|
|
92723
|
+
}
|
|
92724
|
+
else {
|
|
92725
|
+
this.addSheetInternal(cmd.sheet, false);
|
|
92726
|
+
this.setSheetOrder(cmd.orderAfter);
|
|
92727
|
+
if (cmd.activeAfter) {
|
|
92728
|
+
this.sheet.activateSheet(cmd.activeAfter);
|
|
92729
|
+
}
|
|
92730
|
+
}
|
|
92731
|
+
break;
|
|
92732
|
+
}
|
|
92733
|
+
case 'sheet_remove': {
|
|
92734
|
+
if (direction === 'undo') {
|
|
92735
|
+
this.addSheetInternal(cmd.sheet, false);
|
|
92736
|
+
this.setSheetOrder(cmd.orderBefore);
|
|
92737
|
+
if (!this.sheet.getWorkSheetInstance(cmd.sheet.sheetKey)) {
|
|
92738
|
+
const restored = this.sheet.createWorkSheetInstance(cmd.sheet);
|
|
92739
|
+
restored.getElement().style.display = 'none';
|
|
92740
|
+
this.sheet.setWorkSheetInstance(cmd.sheet.sheetKey, restored);
|
|
92741
|
+
}
|
|
92742
|
+
if (cmd.activeBefore) {
|
|
92743
|
+
this.sheet.activateSheet(cmd.activeBefore);
|
|
92744
|
+
}
|
|
92745
|
+
}
|
|
92746
|
+
else {
|
|
92747
|
+
this.removeSheetInternal(cmd.sheet.sheetKey);
|
|
92748
|
+
this.setSheetOrder(cmd.orderAfter);
|
|
92749
|
+
if (cmd.activeAfter) {
|
|
92750
|
+
this.sheet.activateSheet(cmd.activeAfter);
|
|
92751
|
+
}
|
|
92752
|
+
}
|
|
92753
|
+
break;
|
|
92754
|
+
}
|
|
92755
|
+
case 'sheet_rename': {
|
|
92756
|
+
const nextTitle = direction === 'undo' ? cmd.oldTitle : cmd.newTitle;
|
|
92757
|
+
this.renameSheetInternal(cmd.sheetKey, nextTitle);
|
|
92758
|
+
break;
|
|
92759
|
+
}
|
|
92760
|
+
case 'sheet_reorder': {
|
|
92761
|
+
this.setSheetOrder(direction === 'undo' ? cmd.orderBefore : cmd.orderAfter);
|
|
92762
|
+
break;
|
|
92763
|
+
}
|
|
92764
|
+
case 'table_tx': {
|
|
92765
|
+
this.applyTableTransaction(cmd.sheetKey, cmd.tx, direction);
|
|
92766
|
+
break;
|
|
92767
|
+
}
|
|
92768
|
+
}
|
|
92769
|
+
}
|
|
92770
|
+
addSheetInternal(sheetDefine, activate) {
|
|
92771
|
+
this.sheet.getSheetManager().addSheet(sheetDefine);
|
|
92772
|
+
if (activate) {
|
|
92773
|
+
this.sheet.activateSheet(sheetDefine.sheetKey);
|
|
92774
|
+
}
|
|
92775
|
+
else {
|
|
92776
|
+
this.sheet.updateSheetTabs();
|
|
92777
|
+
this.sheet.updateSheetMenu();
|
|
92778
|
+
}
|
|
92779
|
+
}
|
|
92780
|
+
removeSheetInternal(sheetKey) {
|
|
92781
|
+
const instance = this.sheet.getWorkSheetInstance(sheetKey);
|
|
92782
|
+
if (instance) {
|
|
92783
|
+
instance.release();
|
|
92784
|
+
this.sheet.deleteWorkSheetInstance(sheetKey);
|
|
92785
|
+
}
|
|
92786
|
+
const active = this.getActiveSheetKey();
|
|
92787
|
+
const newActiveSheetKey = this.sheet.getSheetManager().removeSheet(sheetKey);
|
|
92788
|
+
try {
|
|
92789
|
+
this.sheet.getFormulaManager().removeSheet(sheetKey);
|
|
92790
|
+
}
|
|
92791
|
+
catch { }
|
|
92792
|
+
if (newActiveSheetKey && newActiveSheetKey !== active) {
|
|
92793
|
+
this.sheet.activateSheet(newActiveSheetKey);
|
|
92794
|
+
}
|
|
92795
|
+
this.sheet.updateSheetTabs();
|
|
92796
|
+
this.sheet.updateSheetMenu();
|
|
92797
|
+
}
|
|
92798
|
+
renameSheetInternal(sheetKey, newTitle) {
|
|
92799
|
+
this.sheet.getSheetManager().renameSheet(sheetKey, newTitle);
|
|
92800
|
+
this.sheet.getWorkSheetInstance(sheetKey)?.setTitle(newTitle);
|
|
92801
|
+
this.sheet.getFormulaManager().updateSheetTitle(sheetKey, newTitle);
|
|
92802
|
+
this.sheet.updateSheetTabs();
|
|
92803
|
+
this.sheet.updateSheetMenu();
|
|
92804
|
+
}
|
|
92805
|
+
applyTableTransaction(sheetKey, tx, direction) {
|
|
92806
|
+
const ws = this.ensureWorkSheetInstance(sheetKey);
|
|
92807
|
+
if (ws && this.getActiveSheetKey() !== sheetKey) {
|
|
92808
|
+
this.sheet.activateSheet(sheetKey);
|
|
92809
|
+
}
|
|
92810
|
+
const table = ws?.tableInstance;
|
|
92811
|
+
if (!table) {
|
|
92812
|
+
return;
|
|
92813
|
+
}
|
|
92814
|
+
const vtableSheet = this.sheet;
|
|
92815
|
+
const apply = (cmd, dir) => {
|
|
92816
|
+
replayCommand({
|
|
92817
|
+
table,
|
|
92818
|
+
vtableSheet,
|
|
92819
|
+
cmd,
|
|
92820
|
+
direction: dir,
|
|
92821
|
+
deleteRecordsByReference: (records) => {
|
|
92822
|
+
const tableRecords = (table.records || []);
|
|
92823
|
+
const indexs = [];
|
|
92824
|
+
records.forEach(rec => {
|
|
92825
|
+
const idx = tableRecords.indexOf(rec);
|
|
92826
|
+
if (idx >= 0) {
|
|
92827
|
+
indexs.push(idx);
|
|
92828
|
+
}
|
|
92829
|
+
});
|
|
92830
|
+
if (indexs.length && table.deleteRecords) {
|
|
92831
|
+
table.deleteRecords(indexs);
|
|
92832
|
+
}
|
|
92833
|
+
}
|
|
92834
|
+
});
|
|
92835
|
+
};
|
|
92836
|
+
if (direction === 'undo') {
|
|
92837
|
+
for (let i = tx.commands.length - 1; i >= 0; i--) {
|
|
92838
|
+
apply(tx.commands[i], 'undo');
|
|
92839
|
+
}
|
|
92840
|
+
}
|
|
92841
|
+
else {
|
|
92842
|
+
for (let i = 0; i < tx.commands.length; i++) {
|
|
92843
|
+
apply(tx.commands[i], 'redo');
|
|
92844
|
+
}
|
|
92845
|
+
}
|
|
92846
|
+
}
|
|
92847
|
+
ensureWorkSheetInstance(sheetKey) {
|
|
92848
|
+
const existing = this.sheet.getWorkSheetInstance(sheetKey);
|
|
92849
|
+
if (existing) {
|
|
92850
|
+
return existing;
|
|
92851
|
+
}
|
|
92852
|
+
const def = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92853
|
+
if (!def) {
|
|
92854
|
+
return undefined;
|
|
92855
|
+
}
|
|
92856
|
+
const instance = this.sheet.createWorkSheetInstance(def);
|
|
92857
|
+
instance.getElement().style.display = 'none';
|
|
92858
|
+
this.sheet.setWorkSheetInstance(sheetKey, instance);
|
|
92859
|
+
return instance;
|
|
92860
|
+
}
|
|
92861
|
+
getSheetOrder() {
|
|
92862
|
+
return this.sheet
|
|
92863
|
+
.getSheetManager()
|
|
92864
|
+
.getAllSheets()
|
|
92865
|
+
.map(s => s.sheetKey);
|
|
92866
|
+
}
|
|
92867
|
+
setSheetOrder(order) {
|
|
92868
|
+
const all = this.sheet.getSheetManager().getAllSheets();
|
|
92869
|
+
const map = new Map(all.map(s => [s.sheetKey, s]));
|
|
92870
|
+
const next = [];
|
|
92871
|
+
order.forEach(key => {
|
|
92872
|
+
const s = map.get(key);
|
|
92873
|
+
if (s) {
|
|
92874
|
+
next.push(s);
|
|
92875
|
+
}
|
|
92876
|
+
});
|
|
92877
|
+
if (next.length === all.length) {
|
|
92878
|
+
this.sheet.getSheetManager().sortSheets(next);
|
|
92879
|
+
this.sheet.updateSheetTabs();
|
|
92880
|
+
this.sheet.updateSheetMenu();
|
|
92881
|
+
}
|
|
92882
|
+
}
|
|
92883
|
+
getActiveSheetKey() {
|
|
92884
|
+
return this.sheet.getSheetManager().getActiveSheet()?.sheetKey;
|
|
92885
|
+
}
|
|
92886
|
+
}
|
|
92887
|
+
|
|
90804
92888
|
class VTableSheet {
|
|
90805
92889
|
container;
|
|
90806
92890
|
options;
|
|
@@ -90819,9 +92903,11 @@
|
|
|
90819
92903
|
formulaBarElement = null;
|
|
90820
92904
|
sheetTabElement = null;
|
|
90821
92905
|
mainMenuElement = null;
|
|
92906
|
+
undoRedoElement = null;
|
|
90822
92907
|
contentElement;
|
|
90823
92908
|
dragManager;
|
|
90824
92909
|
sheetTabEventHandler;
|
|
92910
|
+
workbookHistoryManager;
|
|
90825
92911
|
constructor(container, options) {
|
|
90826
92912
|
this.container = container;
|
|
90827
92913
|
this.options = this.mergeDefaultOptions(options);
|
|
@@ -90831,12 +92917,15 @@
|
|
|
90831
92917
|
this.tableEventRelay = new TableEventRelay(this);
|
|
90832
92918
|
this.eventManager = new DomEventManager(this);
|
|
90833
92919
|
this.dragManager = new SheetTabDragManager(this);
|
|
90834
|
-
this.menuManager = new MenuManager(this);
|
|
90835
92920
|
this.formulaUIManager = new FormulaUIManager(this);
|
|
90836
92921
|
this.sheetTabEventHandler = new SheetTabEventHandler(this);
|
|
90837
92922
|
this.spreadsheetEventManager = new SpreadSheetEventManager(this);
|
|
92923
|
+
this.workbookHistoryManager = new WorkbookHistoryManager(this);
|
|
92924
|
+
this.menuManager = new MenuManager(this);
|
|
90838
92925
|
this.initUI();
|
|
92926
|
+
this.workbookHistoryManager.suspend();
|
|
90839
92927
|
this.initSheets();
|
|
92928
|
+
this.workbookHistoryManager.resume();
|
|
90840
92929
|
this.resize();
|
|
90841
92930
|
}
|
|
90842
92931
|
mergeDefaultOptions(options) {
|
|
@@ -90865,10 +92954,7 @@
|
|
|
90865
92954
|
const topContainer = document.createElement('div');
|
|
90866
92955
|
topContainer.className = 'vtable-sheet-top-container';
|
|
90867
92956
|
this.rootElement.appendChild(topContainer);
|
|
90868
|
-
|
|
90869
|
-
this.mainMenuElement = this.menuManager.createMainMenu();
|
|
90870
|
-
topContainer.appendChild(this.mainMenuElement);
|
|
90871
|
-
}
|
|
92957
|
+
this.renderTopLeftControls(topContainer);
|
|
90872
92958
|
if (this.options.showFormulaBar) {
|
|
90873
92959
|
this.formulaBarElement = this.formulaUIManager.createFormulaBar();
|
|
90874
92960
|
topContainer.appendChild(this.formulaBarElement);
|
|
@@ -90882,6 +92968,38 @@
|
|
|
90882
92968
|
this.rootElement.appendChild(this.sheetTabElement);
|
|
90883
92969
|
}
|
|
90884
92970
|
}
|
|
92971
|
+
renderTopLeftControls(topContainer) {
|
|
92972
|
+
if (this.mainMenuElement?.parentElement) {
|
|
92973
|
+
this.mainMenuElement.parentElement.removeChild(this.mainMenuElement);
|
|
92974
|
+
this.mainMenuElement = null;
|
|
92975
|
+
}
|
|
92976
|
+
if (this.undoRedoElement?.parentElement) {
|
|
92977
|
+
this.undoRedoElement.parentElement.removeChild(this.undoRedoElement);
|
|
92978
|
+
this.undoRedoElement = null;
|
|
92979
|
+
}
|
|
92980
|
+
this.menuManager.release();
|
|
92981
|
+
const showMainMenu = !!this.options.mainMenu?.show;
|
|
92982
|
+
const showUndoRedo = this.options.undoRedo?.show ?? true;
|
|
92983
|
+
if (showMainMenu) {
|
|
92984
|
+
this.mainMenuElement = this.menuManager.createMainMenu();
|
|
92985
|
+
if (topContainer.firstChild) {
|
|
92986
|
+
topContainer.insertBefore(this.mainMenuElement, topContainer.firstChild);
|
|
92987
|
+
}
|
|
92988
|
+
else {
|
|
92989
|
+
topContainer.appendChild(this.mainMenuElement);
|
|
92990
|
+
}
|
|
92991
|
+
return;
|
|
92992
|
+
}
|
|
92993
|
+
if (showUndoRedo) {
|
|
92994
|
+
this.undoRedoElement = this.menuManager.createUndoRedoOnly();
|
|
92995
|
+
if (topContainer.firstChild) {
|
|
92996
|
+
topContainer.insertBefore(this.undoRedoElement, topContainer.firstChild);
|
|
92997
|
+
}
|
|
92998
|
+
else {
|
|
92999
|
+
topContainer.appendChild(this.undoRedoElement);
|
|
93000
|
+
}
|
|
93001
|
+
}
|
|
93002
|
+
}
|
|
90885
93003
|
createSheetTab() {
|
|
90886
93004
|
const addIcon = '<svg viewBox="0 0 24 24" width="16" height="16">' +
|
|
90887
93005
|
'<path fill="currentColor" d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"/>' +
|
|
@@ -91047,26 +93165,14 @@
|
|
|
91047
93165
|
}
|
|
91048
93166
|
}
|
|
91049
93167
|
addSheet(sheet) {
|
|
91050
|
-
this.
|
|
91051
|
-
this.updateSheetTabs();
|
|
91052
|
-
this.updateSheetMenu();
|
|
93168
|
+
this.workbookHistoryManager.addSheet({ sheet, activate: false });
|
|
91053
93169
|
}
|
|
91054
93170
|
removeSheet(sheetKey) {
|
|
91055
93171
|
if (this.sheetManager.getSheetCount() <= 1) {
|
|
91056
93172
|
showSnackbar('至少保留一个工作表', 1300);
|
|
91057
93173
|
return;
|
|
91058
93174
|
}
|
|
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();
|
|
93175
|
+
this.workbookHistoryManager.removeSheet(sheetKey);
|
|
91070
93176
|
}
|
|
91071
93177
|
getSheetCount() {
|
|
91072
93178
|
return this.sheetManager.getSheetCount();
|
|
@@ -91078,10 +93184,10 @@
|
|
|
91078
93184
|
return this.sheetManager.getAllSheets();
|
|
91079
93185
|
}
|
|
91080
93186
|
createWorkSheetInstance(sheetDefine) {
|
|
91081
|
-
formulaEditor.setSheet(this);
|
|
91082
93187
|
const contentWidth = this.contentElement.clientWidth;
|
|
91083
93188
|
const contentHeight = this.contentElement.clientHeight;
|
|
91084
93189
|
sheetDefine.dragOrder = sheetDefine.dragOrder ?? this.options.dragOrder;
|
|
93190
|
+
const formulaEditor = createFormulaEditor();
|
|
91085
93191
|
const sheet = new WorkSheet(this, {
|
|
91086
93192
|
...sheetDefine,
|
|
91087
93193
|
container: this.contentElement,
|
|
@@ -91091,8 +93197,8 @@
|
|
|
91091
93197
|
defaultColWidth: this.options.defaultColWidth,
|
|
91092
93198
|
dragOrder: sheetDefine.dragOrder,
|
|
91093
93199
|
plugins: getTablePlugins(sheetDefine, this.options, this),
|
|
91094
|
-
headerEditor:
|
|
91095
|
-
editor:
|
|
93200
|
+
headerEditor: formulaEditor,
|
|
93201
|
+
editor: formulaEditor,
|
|
91096
93202
|
select: {
|
|
91097
93203
|
makeSelectCellVisible: false
|
|
91098
93204
|
},
|
|
@@ -91100,6 +93206,7 @@
|
|
|
91100
93206
|
customMergeCell: sheetDefine.cellMerge,
|
|
91101
93207
|
theme: sheetDefine.theme?.tableTheme || this.options.theme?.tableTheme
|
|
91102
93208
|
});
|
|
93209
|
+
formulaEditor.setSheet(this);
|
|
91103
93210
|
try {
|
|
91104
93211
|
const normalizedData = sheetDefine.data
|
|
91105
93212
|
? this.formulaManager.normalizeSheetData(sheetDefine.data, sheet.tableInstance)
|
|
@@ -91175,8 +93282,7 @@
|
|
|
91175
93282
|
rowCount: 100,
|
|
91176
93283
|
data: []
|
|
91177
93284
|
};
|
|
91178
|
-
this.
|
|
91179
|
-
this.activateSheet(key);
|
|
93285
|
+
this.workbookHistoryManager.addSheet({ sheet: newSheet, activate: true });
|
|
91180
93286
|
}
|
|
91181
93287
|
updateFormulaBar() {
|
|
91182
93288
|
this.formulaUIManager.updateFormulaBar();
|
|
@@ -91193,9 +93299,39 @@
|
|
|
91193
93299
|
getSheetManager() {
|
|
91194
93300
|
return this.sheetManager;
|
|
91195
93301
|
}
|
|
93302
|
+
getWorkbookHistoryManager() {
|
|
93303
|
+
return this.workbookHistoryManager;
|
|
93304
|
+
}
|
|
91196
93305
|
getActiveSheet() {
|
|
91197
93306
|
return this.activeWorkSheet;
|
|
91198
93307
|
}
|
|
93308
|
+
getWorkSheetInstance(sheetKey) {
|
|
93309
|
+
return this.workSheetInstances.get(sheetKey);
|
|
93310
|
+
}
|
|
93311
|
+
setWorkSheetInstance(sheetKey, instance) {
|
|
93312
|
+
this.workSheetInstances.set(sheetKey, instance);
|
|
93313
|
+
}
|
|
93314
|
+
deleteWorkSheetInstance(sheetKey) {
|
|
93315
|
+
this.workSheetInstances.delete(sheetKey);
|
|
93316
|
+
}
|
|
93317
|
+
renameSheet(sheetKey, newTitle) {
|
|
93318
|
+
this.workbookHistoryManager.renameSheet(sheetKey, newTitle);
|
|
93319
|
+
}
|
|
93320
|
+
reorderSheet(sourceKey, targetKey, position) {
|
|
93321
|
+
this.workbookHistoryManager.reorderSheet(sourceKey, targetKey, position);
|
|
93322
|
+
}
|
|
93323
|
+
undo() {
|
|
93324
|
+
this.workbookHistoryManager.undo();
|
|
93325
|
+
}
|
|
93326
|
+
redo() {
|
|
93327
|
+
this.workbookHistoryManager.redo();
|
|
93328
|
+
}
|
|
93329
|
+
startHistoryTransaction() {
|
|
93330
|
+
this.workbookHistoryManager.startTransaction();
|
|
93331
|
+
}
|
|
93332
|
+
endHistoryTransaction() {
|
|
93333
|
+
this.workbookHistoryManager.endTransaction();
|
|
93334
|
+
}
|
|
91199
93335
|
onTableEvent(type, callback) {
|
|
91200
93336
|
this.tableEventRelay.onTableEvent(type, callback);
|
|
91201
93337
|
}
|
|
@@ -91306,22 +93442,30 @@
|
|
|
91306
93442
|
}
|
|
91307
93443
|
updateMainMenu(mainMenu) {
|
|
91308
93444
|
this.options.mainMenu = mainMenu;
|
|
91309
|
-
this.
|
|
93445
|
+
const topContainer = this.rootElement.querySelector('.vtable-sheet-top-container');
|
|
93446
|
+
if (!topContainer) {
|
|
93447
|
+
return;
|
|
93448
|
+
}
|
|
93449
|
+
this.renderTopLeftControls(topContainer);
|
|
91310
93450
|
}
|
|
91311
93451
|
updateOption(options) {
|
|
91312
93452
|
if (!options) {
|
|
91313
93453
|
return;
|
|
91314
93454
|
}
|
|
91315
93455
|
const hasMainMenu = typeof options.mainMenu !== 'undefined';
|
|
91316
|
-
|
|
91317
|
-
this.updateMainMenu(options.mainMenu);
|
|
91318
|
-
}
|
|
93456
|
+
const hasUndoRedo = typeof options.undoRedo !== 'undefined';
|
|
91319
93457
|
const pluginModulesChanged = pluginIsChanged(this.options.VTablePluginModules, options.VTablePluginModules);
|
|
91320
93458
|
const tableThemeChanged = tableThemeIsChanged(this.options.theme?.tableTheme, options.theme?.tableTheme);
|
|
91321
93459
|
this.options = {
|
|
91322
93460
|
...this.options,
|
|
91323
93461
|
...options
|
|
91324
93462
|
};
|
|
93463
|
+
if (hasMainMenu || hasUndoRedo) {
|
|
93464
|
+
const topContainer = this.rootElement.querySelector('.vtable-sheet-top-container');
|
|
93465
|
+
if (topContainer) {
|
|
93466
|
+
this.renderTopLeftControls(topContainer);
|
|
93467
|
+
}
|
|
93468
|
+
}
|
|
91325
93469
|
if (Array.isArray(options.sheets) || pluginModulesChanged || tableThemeChanged) {
|
|
91326
93470
|
this.updateSheets(options);
|
|
91327
93471
|
}
|
|
@@ -91372,6 +93516,7 @@
|
|
|
91372
93516
|
this.workSheetInstances.set(next_sheetDefine.sheetKey, newInstance);
|
|
91373
93517
|
return;
|
|
91374
93518
|
}
|
|
93519
|
+
const formulaEditor = createFormulaEditor();
|
|
91375
93520
|
const sheetOption = {
|
|
91376
93521
|
sheetTitle: next_sheetDefine.sheetTitle,
|
|
91377
93522
|
sheetKey: next_sheetDefine.sheetKey,
|
|
@@ -91387,8 +93532,8 @@
|
|
|
91387
93532
|
defaultColWidth: this.options.defaultColWidth,
|
|
91388
93533
|
dragOrder: next_sheetDefine.dragOrder,
|
|
91389
93534
|
plugins: getTablePlugins(next_sheetDefine, this.options, this),
|
|
91390
|
-
headerEditor:
|
|
91391
|
-
editor:
|
|
93535
|
+
headerEditor: formulaEditor,
|
|
93536
|
+
editor: formulaEditor,
|
|
91392
93537
|
select: {
|
|
91393
93538
|
makeSelectCellVisible: false
|
|
91394
93539
|
},
|
|
@@ -91398,6 +93543,7 @@
|
|
|
91398
93543
|
data: next_sheetDefine.data,
|
|
91399
93544
|
columns: next_sheetDefine.columns
|
|
91400
93545
|
};
|
|
93546
|
+
formulaEditor.setSheet(this);
|
|
91401
93547
|
instance.updateSheetOption(sheetOption);
|
|
91402
93548
|
});
|
|
91403
93549
|
try {
|
|
@@ -92198,7 +94344,7 @@
|
|
|
92198
94344
|
display: flex;
|
|
92199
94345
|
align-items: center;
|
|
92200
94346
|
background-color: #fff;
|
|
92201
|
-
width:
|
|
94347
|
+
width: auto;
|
|
92202
94348
|
/* 内容居中 */
|
|
92203
94349
|
justify-content: center;
|
|
92204
94350
|
flex-shrink: 0; /* 防止菜单被压缩 */
|
|
@@ -92207,6 +94353,17 @@
|
|
|
92207
94353
|
background-color: #f0f0f0;
|
|
92208
94354
|
}
|
|
92209
94355
|
|
|
94356
|
+
.vtable-sheet-undo-redo {
|
|
94357
|
+
display: flex;
|
|
94358
|
+
flex-direction: row;
|
|
94359
|
+
align-items: center;
|
|
94360
|
+
height: 30px;
|
|
94361
|
+
padding: 0;
|
|
94362
|
+
border-bottom: 1px solid #e0e0e0;
|
|
94363
|
+
background-color: #fff;
|
|
94364
|
+
flex-shrink: 0;
|
|
94365
|
+
}
|
|
94366
|
+
|
|
92210
94367
|
.vtable-sheet-main-menu-button {
|
|
92211
94368
|
display: flex;
|
|
92212
94369
|
align-items: center;
|
|
@@ -92215,6 +94372,38 @@
|
|
|
92215
94372
|
height: 30px;
|
|
92216
94373
|
}
|
|
92217
94374
|
|
|
94375
|
+
.vtable-sheet-main-menu-actions {
|
|
94376
|
+
display: flex;
|
|
94377
|
+
align-items: center;
|
|
94378
|
+
height: 30px;
|
|
94379
|
+
gap: 4px;
|
|
94380
|
+
padding-right: 6px;
|
|
94381
|
+
}
|
|
94382
|
+
|
|
94383
|
+
.vtable-sheet-main-menu-action {
|
|
94384
|
+
display: inline-flex;
|
|
94385
|
+
align-items: center;
|
|
94386
|
+
justify-content: center;
|
|
94387
|
+
width: 28px;
|
|
94388
|
+
height: 28px;
|
|
94389
|
+
border: none;
|
|
94390
|
+
background: transparent;
|
|
94391
|
+
color: #666;
|
|
94392
|
+
cursor: pointer;
|
|
94393
|
+
padding: 0;
|
|
94394
|
+
}
|
|
94395
|
+
|
|
94396
|
+
.vtable-sheet-main-menu-action:hover:not(:disabled) {
|
|
94397
|
+
color: #333;
|
|
94398
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
94399
|
+
border-radius: 4px;
|
|
94400
|
+
}
|
|
94401
|
+
|
|
94402
|
+
.vtable-sheet-main-menu-action:disabled {
|
|
94403
|
+
opacity: 0.4;
|
|
94404
|
+
cursor: not-allowed;
|
|
94405
|
+
}
|
|
94406
|
+
|
|
92218
94407
|
/* 菜单项容器 */
|
|
92219
94408
|
.vtable-sheet-main-menu-container {
|
|
92220
94409
|
position: absolute;
|
|
@@ -93003,7 +95192,7 @@
|
|
|
93003
95192
|
importStyle();
|
|
93004
95193
|
}
|
|
93005
95194
|
|
|
93006
|
-
const version = "1.
|
|
95195
|
+
const version = "1.24.0-alpha.0";
|
|
93007
95196
|
importStyles();
|
|
93008
95197
|
|
|
93009
95198
|
exports.TYPES = index;
|