@visactor/vtable-sheet 1.23.3-alpha.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/sheet-tab-event-handler.js +2 -5
- package/cjs/components/sheet-tab-event-handler.js.map +1 -1
- package/cjs/components/vtable-sheet.d.ts +14 -0
- package/cjs/components/vtable-sheet.js +77 -55
- package/cjs/components/vtable-sheet.js.map +1 -1
- package/cjs/core/WorkSheet.js +3 -46
- package/cjs/core/WorkSheet.js.map +1 -1
- package/cjs/core/table-plugins.js +30 -2
- package/cjs/core/table-plugins.js.map +1 -1
- package/cjs/formula/formula-editor.d.ts +1 -1
- package/cjs/formula/formula-editor.js +22 -5
- package/cjs/formula/formula-editor.js.map +1 -1
- package/cjs/formula/formula-engine.d.ts +1 -0
- package/cjs/formula/formula-engine.js +47 -16
- package/cjs/formula/formula-engine.js.map +1 -1
- package/cjs/formula/formula-range-selector.js +1 -5
- package/cjs/formula/formula-range-selector.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/managers/formula-manager.d.ts +3 -1
- package/cjs/managers/formula-manager.js +7 -5
- package/cjs/managers/formula-manager.js.map +1 -1
- package/cjs/managers/menu-manager.d.ts +7 -1
- package/cjs/managers/menu-manager.js +37 -4
- package/cjs/managers/menu-manager.js.map +1 -1
- package/cjs/managers/tab-drag-manager.d.ts +2 -2
- package/cjs/managers/tab-drag-manager.js +1 -2
- package/cjs/managers/tab-drag-manager.js.map +1 -1
- package/cjs/managers/workbook-history-manager.d.ts +53 -0
- package/cjs/managers/workbook-history-manager.js +294 -0
- package/cjs/managers/workbook-history-manager.js.map +1 -0
- package/cjs/styles/menu.js +1 -1
- package/cjs/styles/menu.js.map +1 -1
- package/cjs/test-shims/vtable-plugins.d.ts +5 -0
- package/cjs/test-shims/vtable-plugins.js +34 -0
- package/cjs/test-shims/vtable-plugins.js.map +1 -0
- package/cjs/ts-types/base.js +1 -2
- package/cjs/ts-types/formula.js +2 -1
- package/cjs/ts-types/index.d.ts +4 -0
- package/cjs/ts-types/index.js.map +1 -1
- package/dist/vtable-sheet.js +2559 -336
- package/dist/vtable-sheet.min.js +1 -1
- package/es/components/sheet-tab-event-handler.js +1 -4
- package/es/components/sheet-tab-event-handler.js.map +1 -1
- package/es/components/vtable-sheet.d.ts +14 -0
- package/es/components/vtable-sheet.js +76 -33
- package/es/components/vtable-sheet.js.map +1 -1
- package/es/core/WorkSheet.js +3 -46
- package/es/core/WorkSheet.js.map +1 -1
- package/es/core/table-plugins.js +31 -1
- package/es/core/table-plugins.js.map +1 -1
- package/es/formula/formula-editor.d.ts +1 -1
- package/es/formula/formula-editor.js +19 -4
- package/es/formula/formula-editor.js.map +1 -1
- package/es/formula/formula-engine.d.ts +1 -0
- package/es/formula/formula-engine.js +47 -16
- package/es/formula/formula-engine.js.map +1 -1
- package/es/formula/formula-range-selector.js +1 -5
- package/es/formula/formula-range-selector.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/managers/formula-manager.d.ts +3 -1
- package/es/managers/formula-manager.js +7 -5
- package/es/managers/formula-manager.js.map +1 -1
- package/es/managers/menu-manager.d.ts +7 -1
- package/es/managers/menu-manager.js +37 -4
- package/es/managers/menu-manager.js.map +1 -1
- package/es/managers/tab-drag-manager.d.ts +2 -2
- package/es/managers/tab-drag-manager.js +1 -2
- package/es/managers/tab-drag-manager.js.map +1 -1
- package/es/managers/workbook-history-manager.d.ts +53 -0
- package/es/managers/workbook-history-manager.js +286 -0
- package/es/managers/workbook-history-manager.js.map +1 -0
- package/es/styles/menu.js +1 -1
- package/es/styles/menu.js.map +1 -1
- package/es/test-shims/vtable-plugins.d.ts +5 -0
- package/es/test-shims/vtable-plugins.js +6 -0
- package/es/test-shims/vtable-plugins.js.map +1 -0
- package/es/ts-types/base.js +1 -2
- package/es/ts-types/formula.js +2 -1
- package/es/ts-types/index.d.ts +4 -0
- package/es/ts-types/index.js.map +1 -1
- package/package.json +7 -7
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
|
|
@@ -3735,28 +3778,59 @@
|
|
|
3735
3778
|
}
|
|
3736
3779
|
addEventListener(type, listener, options) {
|
|
3737
3780
|
if (!listener) return;
|
|
3781
|
+
const capture = this._resolveCapture(options),
|
|
3782
|
+
once = this._resolveOnce(options),
|
|
3783
|
+
listenerTypeMap = this._getOrCreateListenerTypeMap(type),
|
|
3784
|
+
wrappedMap = this._getOrCreateWrappedMap(listenerTypeMap, listener);
|
|
3785
|
+
if (wrappedMap.has(capture)) return;
|
|
3738
3786
|
const wrappedListener = event => {
|
|
3739
3787
|
const transformedEvent = this._eventListenerTransformer(event);
|
|
3740
|
-
"function" == typeof listener ? listener(transformedEvent) : listener.handleEvent && listener.handleEvent(transformedEvent);
|
|
3788
|
+
"function" == typeof listener ? listener(transformedEvent) : listener.handleEvent && listener.handleEvent(transformedEvent), once && this._deleteListenerRecord(type, listener, capture);
|
|
3741
3789
|
};
|
|
3742
|
-
|
|
3790
|
+
wrappedMap.set(capture, {
|
|
3791
|
+
wrappedListener: wrappedListener,
|
|
3792
|
+
options: options
|
|
3793
|
+
}), this._nativeAddEventListener(type, wrappedListener, options);
|
|
3743
3794
|
}
|
|
3744
3795
|
removeEventListener(type, listener, options) {
|
|
3745
|
-
var _a;
|
|
3796
|
+
var _a, _b;
|
|
3746
3797
|
if (!listener) return;
|
|
3747
|
-
const
|
|
3748
|
-
|
|
3798
|
+
const capture = this._resolveCapture(options),
|
|
3799
|
+
wrappedRecord = null === (_b = null === (_a = this._listenerMap.get(type)) || void 0 === _a ? void 0 : _a.get(listener)) || void 0 === _b ? void 0 : _b.get(capture);
|
|
3800
|
+
wrappedRecord && (this._nativeRemoveEventListener(type, wrappedRecord.wrappedListener, capture), this._deleteListenerRecord(type, listener, capture));
|
|
3749
3801
|
}
|
|
3750
3802
|
dispatchEvent(event) {
|
|
3751
3803
|
return this._nativeDispatchEvent(event);
|
|
3752
3804
|
}
|
|
3753
3805
|
clearAllEventListeners() {
|
|
3754
|
-
this._listenerMap.forEach((
|
|
3755
|
-
|
|
3756
|
-
|
|
3806
|
+
this._listenerMap.forEach((listenerMap, type) => {
|
|
3807
|
+
listenerMap.forEach(wrappedMap => {
|
|
3808
|
+
wrappedMap.forEach((wrappedRecord, capture) => {
|
|
3809
|
+
this._nativeRemoveEventListener(type, wrappedRecord.wrappedListener, capture);
|
|
3810
|
+
});
|
|
3757
3811
|
});
|
|
3758
3812
|
}), this._listenerMap.clear();
|
|
3759
3813
|
}
|
|
3814
|
+
_resolveCapture(options) {
|
|
3815
|
+
return "boolean" == typeof options ? options : !!(null == options ? void 0 : options.capture);
|
|
3816
|
+
}
|
|
3817
|
+
_resolveOnce(options) {
|
|
3818
|
+
return "object" == typeof options && !!(null == options ? void 0 : options.once);
|
|
3819
|
+
}
|
|
3820
|
+
_getOrCreateListenerTypeMap(type) {
|
|
3821
|
+
let listenerTypeMap = this._listenerMap.get(type);
|
|
3822
|
+
return listenerTypeMap || (listenerTypeMap = new Map(), this._listenerMap.set(type, listenerTypeMap)), listenerTypeMap;
|
|
3823
|
+
}
|
|
3824
|
+
_getOrCreateWrappedMap(listenerTypeMap, listener) {
|
|
3825
|
+
let wrappedMap = listenerTypeMap.get(listener);
|
|
3826
|
+
return wrappedMap || (wrappedMap = new Map(), listenerTypeMap.set(listener, wrappedMap)), wrappedMap;
|
|
3827
|
+
}
|
|
3828
|
+
_deleteListenerRecord(type, listener, capture) {
|
|
3829
|
+
const listenerTypeMap = this._listenerMap.get(type);
|
|
3830
|
+
if (!listenerTypeMap) return;
|
|
3831
|
+
const wrappedMap = listenerTypeMap.get(listener);
|
|
3832
|
+
wrappedMap && (wrappedMap.delete(capture), 0 === wrappedMap.size && listenerTypeMap.delete(listener), 0 === listenerTypeMap.size && this._listenerMap.delete(type));
|
|
3833
|
+
}
|
|
3760
3834
|
_nativeAddEventListener(type, listener, options) {
|
|
3761
3835
|
throw new Error("_nativeAddEventListener must be implemented by derived classes");
|
|
3762
3836
|
}
|
|
@@ -4431,7 +4505,7 @@
|
|
|
4431
4505
|
has = (object, key) => null != object && hasOwnProperty$a.call(object, key);
|
|
4432
4506
|
var has$1 = has;
|
|
4433
4507
|
|
|
4434
|
-
function cloneDeep$
|
|
4508
|
+
function cloneDeep$2(value, ignoreWhen, excludeKeys) {
|
|
4435
4509
|
let result;
|
|
4436
4510
|
if (!isValid$2(value) || "object" != typeof value || ignoreWhen && ignoreWhen(value)) return value;
|
|
4437
4511
|
const isArr = isArray$8(value),
|
|
@@ -4442,7 +4516,7 @@
|
|
|
4442
4516
|
if (result) for (; ++index < (props || value).length;) {
|
|
4443
4517
|
const key = props ? props[index] : index,
|
|
4444
4518
|
subValue = value[key];
|
|
4445
|
-
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);
|
|
4446
4520
|
}
|
|
4447
4521
|
return result;
|
|
4448
4522
|
}
|
|
@@ -10270,7 +10344,9 @@
|
|
|
10270
10344
|
var _a;
|
|
10271
10345
|
if (event.manager !== this) throw new Error("It is illegal to free an event not managed by this EventManager!");
|
|
10272
10346
|
const constructor = event.constructor;
|
|
10273
|
-
this.eventPool.has(constructor) || this.eventPool.
|
|
10347
|
+
this.eventPool.has(constructor) || (this.eventPool.get(constructor).forEach(e => {
|
|
10348
|
+
e.eventPhase = event.NONE, e.currentTarget = null, e.path = [], e.detailPath = [], e.target = null;
|
|
10349
|
+
}), this.eventPool.set(constructor, [])), null === (_a = this.eventPool.get(constructor)) || void 0 === _a || _a.push(event);
|
|
10274
10350
|
}
|
|
10275
10351
|
notifyListeners(e, type) {
|
|
10276
10352
|
const listeners = e.currentTarget._events[type];
|
|
@@ -12874,7 +12950,7 @@
|
|
|
12874
12950
|
});
|
|
12875
12951
|
}
|
|
12876
12952
|
release() {
|
|
12877
|
-
this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this);
|
|
12953
|
+
this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this), super.release();
|
|
12878
12954
|
}
|
|
12879
12955
|
_emitCustomEvent(type, context) {
|
|
12880
12956
|
var _a, _b;
|
|
@@ -20281,12 +20357,12 @@
|
|
|
20281
20357
|
throw new Error("暂不支持");
|
|
20282
20358
|
}
|
|
20283
20359
|
release() {
|
|
20284
|
-
var _a, _b;
|
|
20360
|
+
var _a, _b, _d;
|
|
20285
20361
|
super.release(), this.hooks.beforeRender.unTap("constructor", this.beforeRender), this.hooks.afterRender.unTap("constructor", this.afterRender), this.eventSystem && this.eventSystem.release(), this.layerService.releaseStage(this), this.pluginService.release(), this.forEach(layer => {
|
|
20286
20362
|
layer.release();
|
|
20287
20363
|
}), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
|
|
20288
20364
|
item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
|
|
20289
|
-
}), this.interactiveLayer.release()), this.window.release(), null === (_a = this._ticker) || void 0 === _a || _a.remTimeline(null == this ? void 0 : this.timeline), null === (_b = this._ticker) || void 0 === _b || _b.removeListener("tick", this.afterTickCb), this.renderService.renderTreeRoots = [];
|
|
20365
|
+
}), this.interactiveLayer.release()), this.window.release(), null === (_a = this._ticker) || void 0 === _a || _a.remTimeline(null == this ? void 0 : this.timeline), null === (_b = this._ticker) || void 0 === _b || _b.removeListener("tick", this.afterTickCb), this.params.ticker || null === (_d = this._ticker) || void 0 === _d || _d.release(), this.renderService.renderTreeRoots = [];
|
|
20290
20366
|
}
|
|
20291
20367
|
setStage(stage) {}
|
|
20292
20368
|
dirty(b, matrix) {
|
|
@@ -25837,7 +25913,7 @@
|
|
|
25837
25913
|
return this._prevInnerView;
|
|
25838
25914
|
}
|
|
25839
25915
|
getBoundsWithoutRender(attributes) {
|
|
25840
|
-
const currentAttribute = cloneDeep$
|
|
25916
|
+
const currentAttribute = cloneDeep$2(this.attribute);
|
|
25841
25917
|
currentAttribute.scale = this.attribute.scale, this.attribute = attributes;
|
|
25842
25918
|
const offscreenGroup = graphicCreator.group({
|
|
25843
25919
|
x: this.attribute.x,
|
|
@@ -35701,7 +35777,7 @@
|
|
|
35701
35777
|
};
|
|
35702
35778
|
}
|
|
35703
35779
|
release(all) {
|
|
35704
|
-
super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).
|
|
35780
|
+
super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).removeEventListener("touchmove", this._handleTouchMove, {
|
|
35705
35781
|
passive: !1
|
|
35706
35782
|
}), this._clearAllDragEvents();
|
|
35707
35783
|
}
|
|
@@ -38189,6 +38265,7 @@
|
|
|
38189
38265
|
};
|
|
38190
38266
|
}
|
|
38191
38267
|
on(type, listener) {
|
|
38268
|
+
if (!this.listenersData) return;
|
|
38192
38269
|
const list = this.listenersData.listeners[type] || (this.listenersData.listeners[type] = []);
|
|
38193
38270
|
list.push(listener);
|
|
38194
38271
|
const id = idCount$1++;
|
|
@@ -38196,9 +38273,10 @@
|
|
|
38196
38273
|
type: type,
|
|
38197
38274
|
listener: listener,
|
|
38198
38275
|
remove: () => {
|
|
38276
|
+
if (!this.listenersData) return;
|
|
38199
38277
|
delete this.listenersData.listenerData[id];
|
|
38200
38278
|
const index = list.indexOf(listener);
|
|
38201
|
-
list.splice(index, 1), this.listenersData.listeners[type].length
|
|
38279
|
+
list.splice(index, 1), this.listenersData.listeners[type] && !this.listenersData.listeners[type].length && delete this.listenersData.listeners[type];
|
|
38202
38280
|
}
|
|
38203
38281
|
}, id;
|
|
38204
38282
|
}
|
|
@@ -38911,6 +38989,8 @@
|
|
|
38911
38989
|
RESIZE_COLUMN_END: "resize_column_end",
|
|
38912
38990
|
RESIZE_ROW: "resize_row",
|
|
38913
38991
|
RESIZE_ROW_END: "resize_row_end",
|
|
38992
|
+
MERGE_CELLS: "merge_cells",
|
|
38993
|
+
UNMERGE_CELLS: "unmerge_cells",
|
|
38914
38994
|
CHANGE_HEADER_POSITION_START: "change_header_position_start",
|
|
38915
38995
|
CHANGE_HEADER_POSITION: "change_header_position",
|
|
38916
38996
|
CHANGING_HEADER_POSITION: "changing_header_position",
|
|
@@ -41119,7 +41199,7 @@
|
|
|
41119
41199
|
if (!this.beforeChangedRecordsMap.has(rawKey)) {
|
|
41120
41200
|
const rawRecords = Array.isArray(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.records) ? this.dataSourceObj.records : null,
|
|
41121
41201
|
originRecord = rawRecords ? Array.isArray(recordIndex) ? getValueFromDeepArray(rawRecords, recordIndex) : rawRecords[recordIndex] : void 0;
|
|
41122
|
-
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 : {});
|
|
41123
41203
|
}
|
|
41124
41204
|
if ("string" == typeof field || "number" == typeof field) {
|
|
41125
41205
|
const beforeChangedValue = null === (_c = this.beforeChangedRecordsMap.get(rawKey)) || void 0 === _c ? void 0 : _c[field],
|
|
@@ -41133,7 +41213,7 @@
|
|
|
41133
41213
|
var _a;
|
|
41134
41214
|
if (!this.beforeChangedRecordsMap.has(dataIndex.toString())) {
|
|
41135
41215
|
const originRecord = this.getOriginalRecord(dataIndex);
|
|
41136
|
-
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 : {});
|
|
41137
41217
|
}
|
|
41138
41218
|
}
|
|
41139
41219
|
setRecord(record, index) {
|
|
@@ -41404,7 +41484,7 @@
|
|
|
41404
41484
|
}
|
|
41405
41485
|
clearFilteredChildren(record) {
|
|
41406
41486
|
var _a, _b;
|
|
41407
|
-
record.filteredChildren = void 0;
|
|
41487
|
+
record.filteredChildren = void 0, delete record.filteredChildren;
|
|
41408
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]);
|
|
41409
41489
|
}
|
|
41410
41490
|
filterRecord(record) {
|
|
@@ -41507,8 +41587,9 @@
|
|
|
41507
41587
|
fieldPromiseCallBack(_index, _field, _value) {}
|
|
41508
41588
|
recordPromiseCallBack(_index, _record) {}
|
|
41509
41589
|
canChangeOrder(sourceIndex, targetIndex) {
|
|
41510
|
-
var _a;
|
|
41590
|
+
var _a, _b;
|
|
41511
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;
|
|
41512
41593
|
if (this.hasHierarchyStateExpand) {
|
|
41513
41594
|
let sourceIndexs = this.currentPagerIndexedData[sourceIndex],
|
|
41514
41595
|
targetIndexs = this.currentPagerIndexedData[targetIndex];
|
|
@@ -43051,7 +43132,7 @@
|
|
|
43051
43132
|
cacheBeforeChangedRecord(dataIndex, table) {
|
|
43052
43133
|
var _a;
|
|
43053
43134
|
const originRecord = this.getOriginalRecord(dataIndex);
|
|
43054
|
-
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 : {});
|
|
43055
43136
|
}
|
|
43056
43137
|
getGroupSeriesNumber(showIndex) {
|
|
43057
43138
|
const recordIndex = this.dataSource.currentIndexedData[showIndex],
|
|
@@ -45511,7 +45592,7 @@
|
|
|
45511
45592
|
function updateCell$1(col, row, table, addNew, isShadow, forceFastUpdate) {
|
|
45512
45593
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
45513
45594
|
const oldCellGroup = table.scenegraph.highPerformanceGetCell(col, row, !0);
|
|
45514
|
-
if ("cell" !== oldCellGroup.role && !addNew) return;
|
|
45595
|
+
if ("cell" !== oldCellGroup.role && "shadow-cell" !== oldCellGroup.role && !addNew) return;
|
|
45515
45596
|
const cellLocation = table.getCellLocation(col, row);
|
|
45516
45597
|
let isMerge,
|
|
45517
45598
|
range,
|
|
@@ -52961,7 +53042,7 @@
|
|
|
52961
53042
|
}), scene.tableGroup.role = "table";
|
|
52962
53043
|
const colHeaderGroup = createContainerGroup(0, 0, !scene.table.internalProps.enableTreeStickCell);
|
|
52963
53044
|
colHeaderGroup.role = "col-header", scene.colHeaderGroup = colHeaderGroup;
|
|
52964
|
-
const cornerHeaderGroup = createContainerGroup(0, 0, !scene.table.
|
|
53045
|
+
const cornerHeaderGroup = createContainerGroup(0, 0, !scene.table.internalProps.enableTreeStickCell);
|
|
52965
53046
|
cornerHeaderGroup.role = "corner-header", scene.cornerHeaderGroup = cornerHeaderGroup;
|
|
52966
53047
|
const rowHeaderGroup = createContainerGroup(0, 0, !0);
|
|
52967
53048
|
rowHeaderGroup.role = "row-header", scene.rowHeaderGroup = rowHeaderGroup;
|
|
@@ -55759,13 +55840,13 @@
|
|
|
55759
55840
|
setSortState(sortState) {
|
|
55760
55841
|
const state = this;
|
|
55761
55842
|
const sort = (sortState = !sortState || Array.isArray(sortState) ? sortState : [sortState]) && sortState.reduce((prev, item) => {
|
|
55762
|
-
var _a, _b, _c;
|
|
55843
|
+
var _a, _b, _c, _d, _e;
|
|
55763
55844
|
const column = null === (_a = function (columns) {
|
|
55764
55845
|
const result = [];
|
|
55765
55846
|
return function flatten(cols, parentStartIndex = 0) {
|
|
55766
55847
|
cols.forEach(col => {
|
|
55767
55848
|
var _a;
|
|
55768
|
-
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;
|
|
55769
55850
|
col.columns ? flatten(col.columns, startIndex) : result.push(Object.assign(Object.assign({}, col), {
|
|
55770
55851
|
startIndex: startIndex
|
|
55771
55852
|
}));
|
|
@@ -55775,12 +55856,12 @@
|
|
|
55775
55856
|
return this.table.internalProps.transpose ? prev.push({
|
|
55776
55857
|
field: item.field,
|
|
55777
55858
|
order: item.order,
|
|
55778
|
-
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),
|
|
55779
55860
|
col: null == column ? void 0 : column.level
|
|
55780
55861
|
}) : prev.push({
|
|
55781
55862
|
field: item.field,
|
|
55782
55863
|
order: item.order,
|
|
55783
|
-
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),
|
|
55784
55865
|
row: null == column ? void 0 : column.level
|
|
55785
55866
|
}), prev;
|
|
55786
55867
|
}, []);
|
|
@@ -56292,13 +56373,16 @@
|
|
|
56292
56373
|
this.select.selectInline = selectInline;
|
|
56293
56374
|
}
|
|
56294
56375
|
updateSortState(sortState) {
|
|
56295
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
56296
|
-
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;
|
|
56297
56382
|
for (let index = 0; index < sortState.length; index++) {
|
|
56298
|
-
|
|
56299
|
-
|
|
56300
|
-
|
|
56301
|
-
"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;
|
|
56302
56386
|
this.setSortState(sortState.slice(0, index + 1));
|
|
56303
56387
|
const cellAddress = this.table.internalProps.layoutMap.getHeaderCellAddressByField(sortState[index].field);
|
|
56304
56388
|
this.sort[index].col = cellAddress.col, this.sort[index].row = cellAddress.row;
|
|
@@ -56311,7 +56395,7 @@
|
|
|
56311
56395
|
order: this.sort[index].order,
|
|
56312
56396
|
oldSortCol: oldSortCol,
|
|
56313
56397
|
oldSortRow: oldSortRow,
|
|
56314
|
-
oldIconMark: null === (
|
|
56398
|
+
oldIconMark: null === (_e = this.sort[index]) || void 0 === _e ? void 0 : _e.icon
|
|
56315
56399
|
});
|
|
56316
56400
|
}
|
|
56317
56401
|
const normalHeaders = [];
|
|
@@ -56325,7 +56409,7 @@
|
|
|
56325
56409
|
row: null,
|
|
56326
56410
|
iconMark: null,
|
|
56327
56411
|
order: null,
|
|
56328
|
-
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),
|
|
56329
56413
|
oldSortRow: column.level,
|
|
56330
56414
|
oldIconMark: null
|
|
56331
56415
|
});
|
|
@@ -59878,7 +59962,7 @@
|
|
|
59878
59962
|
sourceColumns.unshift(targetSubIndex, 0), Array.prototype.splice.apply(children, sourceColumns);
|
|
59879
59963
|
}
|
|
59880
59964
|
getCopiedTree() {
|
|
59881
|
-
const children = cloneDeep$
|
|
59965
|
+
const children = cloneDeep$2(this.tree.children);
|
|
59882
59966
|
return clearNode(children), children;
|
|
59883
59967
|
}
|
|
59884
59968
|
setAllNodesState(state) {
|
|
@@ -60506,7 +60590,7 @@
|
|
|
60506
60590
|
}
|
|
60507
60591
|
}
|
|
60508
60592
|
|
|
60509
|
-
function getCustomMergeCellFunc(customMergeCell) {
|
|
60593
|
+
function getCustomMergeCellFunc$1(customMergeCell) {
|
|
60510
60594
|
return isFunction$4(customMergeCell) ? customMergeCell : isArray$8(customMergeCell) ? (col, row) => customMergeCell.find(item => item.range.start.col <= col && item.range.end.col >= col && item.range.start.row <= row && item.range.end.row >= row) : void 0;
|
|
60511
60595
|
}
|
|
60512
60596
|
|
|
@@ -60578,7 +60662,7 @@
|
|
|
60578
60662
|
}
|
|
60579
60663
|
constructor(container, options = {}) {
|
|
60580
60664
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
60581
|
-
if (super(), this.showFrozenIcon = !0, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.
|
|
60665
|
+
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.24.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env$1.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
|
|
60582
60666
|
this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
|
|
60583
60667
|
options: options,
|
|
60584
60668
|
container: container
|
|
@@ -60695,7 +60779,7 @@
|
|
|
60695
60779
|
}
|
|
60696
60780
|
this.headerStyleCache = new Map(), this.bodyStyleCache = new Map(), this.bodyMergeTitleCache = new Map(), this.bodyBottomStyleCache = new Map(), internalProps.stick = {
|
|
60697
60781
|
changedCells: new Map()
|
|
60698
|
-
}, internalProps.customMergeCell = getCustomMergeCellFunc(options.customMergeCell);
|
|
60782
|
+
}, internalProps.customMergeCell = getCustomMergeCellFunc$1(options.customMergeCell);
|
|
60699
60783
|
const CustomCellStylePlugin = Factory.getComponent("customCellStylePlugin");
|
|
60700
60784
|
CustomCellStylePlugin && (this.customCellStylePlugin = new CustomCellStylePlugin(this, null !== (_y = options.customCellStyle) && void 0 !== _y ? _y : [], null !== (_z = options.customCellStyleArrangement) && void 0 !== _z ? _z : [])), this._adjustCanvasSizeByOption();
|
|
60701
60785
|
}
|
|
@@ -61516,12 +61600,15 @@
|
|
|
61516
61600
|
dispose() {
|
|
61517
61601
|
this.release();
|
|
61518
61602
|
}
|
|
61603
|
+
clearCorrectTimer() {
|
|
61604
|
+
this._scrollToRowCorrectTimer && (clearTimeout(this._scrollToRowCorrectTimer), this._scrollToRowCorrectTimer = null);
|
|
61605
|
+
}
|
|
61519
61606
|
release() {
|
|
61520
61607
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
61521
61608
|
null === (_c = null === (_b = null === (_a = this.scenegraph) || void 0 === _a ? void 0 : _a.component) || void 0 === _b ? void 0 : _b.vScrollBar) || void 0 === _c || _c.release(), null === (_f = null === (_e = null === (_d = this.scenegraph) || void 0 === _d ? void 0 : _d.component) || void 0 === _e ? void 0 : _e.hScrollBar) || void 0 === _f || _f.release(), this.animationManager.clear(), this.animationManager.ticker.release(), null === (_j = null === (_h = null === (_g = this.scenegraph) || void 0 === _g ? void 0 : _g.stage) || void 0 === _h ? void 0 : _h.ticker) || void 0 === _j || _j.release();
|
|
61522
61609
|
const internalProps = this.internalProps;
|
|
61523
61610
|
if (this.isReleased) return;
|
|
61524
|
-
null === (_l = null === (_k = internalProps.tooltipHandler) || void 0 === _k ? void 0 : _k.release) || void 0 === _l || _l.call(_k), null === (_o = null === (_m = internalProps.menuHandler) || void 0 === _m ? void 0 : _m.release) || void 0 === _o || _o.call(_m), null === (_p = super.release) || void 0 === _p || _p.call(this), this.pluginManager.release(), null === (_r = null === (_q = internalProps.handler) || void 0 === _q ? void 0 : _q.release) || void 0 === _r || _r.call(_q), this.eventManager.release(), null === (_t = null === (_s = internalProps.focusControl) || void 0 === _s ? void 0 : _s.release) || void 0 === _t || _t.call(_s), null === (_u = internalProps.legends) || void 0 === _u || _u.forEach(legend => {
|
|
61611
|
+
this.clearCorrectTimer(), null === (_l = null === (_k = internalProps.tooltipHandler) || void 0 === _k ? void 0 : _k.release) || void 0 === _l || _l.call(_k), null === (_o = null === (_m = internalProps.menuHandler) || void 0 === _m ? void 0 : _m.release) || void 0 === _o || _o.call(_m), null === (_p = super.release) || void 0 === _p || _p.call(this), this.pluginManager.release(), null === (_r = null === (_q = internalProps.handler) || void 0 === _q ? void 0 : _q.release) || void 0 === _r || _r.call(_q), this.eventManager.release(), null === (_t = null === (_s = internalProps.focusControl) || void 0 === _s ? void 0 : _s.release) || void 0 === _t || _t.call(_s), null === (_u = internalProps.legends) || void 0 === _u || _u.forEach(legend => {
|
|
61525
61612
|
null == legend || legend.release();
|
|
61526
61613
|
}), null === (_v = internalProps.title) || void 0 === _v || _v.release(), internalProps.title = null, null === (_w = internalProps.emptyTip) || void 0 === _w || _w.release(), internalProps.emptyTip = null, internalProps.layoutMap.release(), internalProps.releaseList && (internalProps.releaseList.forEach(releaseObj => {
|
|
61527
61614
|
var _a;
|
|
@@ -61634,7 +61721,7 @@
|
|
|
61634
61721
|
const MenuHandler = Factory.getComponent("menuHandler");
|
|
61635
61722
|
internalProps.menuHandler = new MenuHandler(this);
|
|
61636
61723
|
}
|
|
61637
|
-
this.clearCellStyleCache(), (null == updateConfig ? void 0 : updateConfig.clearColWidthCache) && this.clearColWidthCache(), (null == updateConfig ? void 0 : updateConfig.clearRowHeightCache) && this.clearRowHeightCache(), internalProps.customMergeCell = getCustomMergeCellFunc(options.customMergeCell), null === (_z = this.customCellStylePlugin) || void 0 === _z || _z.updateCustomCell(null !== (_0 = options.customCellStyle) && void 0 !== _0 ? _0 : [], null !== (_1 = options.customCellStyleArrangement) && void 0 !== _1 ? _1 : []), this._adjustCanvasSizeByOption();
|
|
61724
|
+
this.clearCellStyleCache(), (null == updateConfig ? void 0 : updateConfig.clearColWidthCache) && this.clearColWidthCache(), (null == updateConfig ? void 0 : updateConfig.clearRowHeightCache) && this.clearRowHeightCache(), internalProps.customMergeCell = getCustomMergeCellFunc$1(options.customMergeCell), null === (_z = this.customCellStylePlugin) || void 0 === _z || _z.updateCustomCell(null !== (_0 = options.customCellStyle) && void 0 !== _0 ? _0 : [], null !== (_1 = options.customCellStyleArrangement) && void 0 !== _1 ? _1 : []), this._adjustCanvasSizeByOption();
|
|
61638
61725
|
}
|
|
61639
61726
|
renderWithRecreateCells() {
|
|
61640
61727
|
this.internalProps.stick.changedCells.clear();
|
|
@@ -61826,6 +61913,30 @@
|
|
|
61826
61913
|
lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
|
|
61827
61914
|
lastSelectRange && (lastSelectRange.end.row = rowIndex), this.stateManager.updateSelectPos(this.colCount - 1, rowIndex, !1, isCtrl, !1, makeSelectCellVisible, !0), this.stateManager.select.selecting = !1;
|
|
61828
61915
|
}
|
|
61916
|
+
changeHeaderPosition(args) {
|
|
61917
|
+
var _a, _b, _c, _d, _e;
|
|
61918
|
+
if (!("canMoveHeaderPosition" in this.internalProps.layoutMap) || !0 === (null === (_a = this.options.customConfig) || void 0 === _a ? void 0 : _a.notUpdateInColumnRowMove)) return !1;
|
|
61919
|
+
const prevMoving = this.stateManager.columnMove.movingColumnOrRow;
|
|
61920
|
+
this.stateManager.columnMove.movingColumnOrRow = args.movingColumnOrRow;
|
|
61921
|
+
try {
|
|
61922
|
+
if (!1 === (null === (_c = (_b = this.internalProps.layoutMap).canMoveHeaderPosition) || void 0 === _c ? void 0 : _c.call(_b, args.source, args.target))) return !1;
|
|
61923
|
+
const oldSourceMergeInfo = this.getCellRange(args.source.col, args.source.row),
|
|
61924
|
+
oldTargetMergeInfo = this.getCellRange(args.target.col, args.target.row),
|
|
61925
|
+
moveContext = this._moveHeaderPosition(args.source, args.target);
|
|
61926
|
+
if (!moveContext || moveContext.targetIndex === moveContext.sourceIndex) return !1;
|
|
61927
|
+
this.internalProps.useOneRowHeightFillAll = !1, this.internalProps.layoutMap.clearCellRangeMap();
|
|
61928
|
+
const sourceMergeInfo = this.getCellRange(args.source.col, args.source.row),
|
|
61929
|
+
targetMergeInfo = this.getCellRange(args.target.col, args.target.row),
|
|
61930
|
+
colMin = Math.min(sourceMergeInfo.start.col, targetMergeInfo.start.col, oldSourceMergeInfo.start.col, oldTargetMergeInfo.start.col),
|
|
61931
|
+
colMax = Math.max(sourceMergeInfo.end.col, targetMergeInfo.end.col, oldSourceMergeInfo.end.col, oldTargetMergeInfo.end.col),
|
|
61932
|
+
rowMin = Math.min(sourceMergeInfo.start.row, targetMergeInfo.start.row, oldSourceMergeInfo.start.row, oldTargetMergeInfo.start.row);
|
|
61933
|
+
let rowMax = Math.max(sourceMergeInfo.end.row, targetMergeInfo.end.row, oldSourceMergeInfo.end.row, oldTargetMergeInfo.end.row);
|
|
61934
|
+
if ("row" === moveContext.moveType && "tree" === this.internalProps.layoutMap.rowHierarchyType && (rowMax = moveContext.targetIndex > moveContext.sourceIndex ? rowMax + moveContext.targetSize - 1 : rowMax + moveContext.sourceSize - 1), this.transpose || !this.isSeriesNumberInBody(args.source.col, args.source.row) && "row" !== args.movingColumnOrRow || (this.changeRecordOrder(moveContext.sourceIndex, moveContext.targetIndex), this.stateManager.changeCheckboxAndRadioOrder(moveContext.sourceIndex, moveContext.targetIndex)), "column" === moveContext.moveType) for (let col = colMin; col <= colMax; col++) this._clearColRangeWidthsMap(col);else for (let row = rowMin; row <= rowMax; row++) this._clearRowRangeHeightsMap(row);
|
|
61935
|
+
return this.clearCellStyleCache(), this.isSeriesNumberInBody(args.source.col, args.source.row) || "row" === args.movingColumnOrRow ? this.scenegraph.updateHeaderPosition(this.scenegraph.proxy.colStart, this.scenegraph.proxy.colEnd, this.scenegraph.proxy.rowStart, this.scenegraph.proxy.rowEnd, moveContext.moveType) : "column" === moveContext.moveType ? this.scenegraph.updateHeaderPosition(colMin, colMax, 0, -1, moveContext.moveType) : this.scenegraph.updateHeaderPosition(0, -1, rowMin, rowMax, moveContext.moveType), "adjustFrozenCount" === this.internalProps.frozenColDragHeaderMode && this.isListTable() && (this.isLeftFrozenColumn(args.target.col) && !this.isLeftFrozenColumn(args.source.col) ? this.frozenColCount += sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1 : this.isLeftFrozenColumn(args.source.col) && !this.isLeftFrozenColumn(args.target.col) && (this.frozenColCount -= sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1), this.isRightFrozenColumn(args.target.col) && !this.isRightFrozenColumn(args.source.col) ? this.rightFrozenColCount += sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1 : this.isRightFrozenColumn(args.source.col) && !this.isRightFrozenColumn(args.target.col) && (this.rightFrozenColCount -= sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1)), null === (_e = (_d = this.scenegraph).updateNextFrame) || void 0 === _e || _e.call(_d), !0;
|
|
61936
|
+
} finally {
|
|
61937
|
+
this.stateManager.columnMove.movingColumnOrRow = prevMoving;
|
|
61938
|
+
}
|
|
61939
|
+
}
|
|
61829
61940
|
get recordsCount() {
|
|
61830
61941
|
var _a;
|
|
61831
61942
|
return null === (_a = this.records) || void 0 === _a ? void 0 : _a.length;
|
|
@@ -61971,7 +62082,7 @@
|
|
|
61971
62082
|
getCustomMerge(col, row) {
|
|
61972
62083
|
if (this.internalProps.customMergeCell) {
|
|
61973
62084
|
const customMerge = this.internalProps.customMergeCell(col, row, this);
|
|
61974
|
-
if (customMerge && customMerge.range
|
|
62085
|
+
if (customMerge && customMerge.range) {
|
|
61975
62086
|
if (customMerge.style) {
|
|
61976
62087
|
const styleClass = this.internalProps.bodyHelper.getStyleClass("text"),
|
|
61977
62088
|
style = customMerge.style,
|
|
@@ -62377,7 +62488,7 @@
|
|
|
62377
62488
|
}
|
|
62378
62489
|
getSelectedCellRanges() {
|
|
62379
62490
|
const ranges = this.stateManager.select.ranges;
|
|
62380
|
-
return ranges.length ? cloneDeep$
|
|
62491
|
+
return ranges.length ? cloneDeep$2(ranges) : [];
|
|
62381
62492
|
}
|
|
62382
62493
|
measureText(text, font) {
|
|
62383
62494
|
return textMeasure.measureText(text, font);
|
|
@@ -62682,12 +62793,34 @@
|
|
|
62682
62793
|
this.eventManager.enableScroll();
|
|
62683
62794
|
}
|
|
62684
62795
|
getGroupTitleLevel(col, row) {}
|
|
62796
|
+
getTargetScrollTop(row) {
|
|
62797
|
+
const drawRange = this.getDrawRange(),
|
|
62798
|
+
frozenHeight = this.getFrozenRowsHeight();
|
|
62799
|
+
return Math.max(0, Math.min(this.getRowsHeight(0, row - 1) - frozenHeight, this.getAllRowsHeight() - drawRange.height));
|
|
62800
|
+
}
|
|
62801
|
+
_scheduleScrollToRowCorrect(row, delay = 0) {
|
|
62802
|
+
this._scrollToRowCorrectTimer = setTimeout(() => {
|
|
62803
|
+
this.clearCorrectTimer();
|
|
62804
|
+
const targetScrollTop = this.getTargetScrollTop(row);
|
|
62805
|
+
if (targetScrollTop !== this.scrollTop) {
|
|
62806
|
+
this.scrollTop = targetScrollTop;
|
|
62807
|
+
const correctedTargetScrollTop = this.getTargetScrollTop(row);
|
|
62808
|
+
correctedTargetScrollTop !== this.scrollTop && (this.scrollTop = correctedTargetScrollTop);
|
|
62809
|
+
}
|
|
62810
|
+
}, delay);
|
|
62811
|
+
}
|
|
62685
62812
|
scrollToRow(row, animationOption) {
|
|
62686
|
-
|
|
62687
|
-
|
|
62688
|
-
|
|
62689
|
-
row:
|
|
62690
|
-
});
|
|
62813
|
+
var _a;
|
|
62814
|
+
const targetRow = Math.min(Math.max(Math.floor(row), 0), this.rowCount - 1);
|
|
62815
|
+
if (this.clearCorrectTimer(), !animationOption) return this.scrollToCell({
|
|
62816
|
+
row: targetRow
|
|
62817
|
+
}), void this._scheduleScrollToRowCorrect(targetRow);
|
|
62818
|
+
const duration = isBoolean$2(animationOption) ? 3e3 : null !== (_a = null == animationOption ? void 0 : animationOption.duration) && void 0 !== _a ? _a : 3e3;
|
|
62819
|
+
this.animationManager.scrollTo({
|
|
62820
|
+
row: targetRow
|
|
62821
|
+
}, animationOption), this._scrollToRowCorrectTimer = setTimeout(() => {
|
|
62822
|
+
this.scrollToRow(targetRow, !1);
|
|
62823
|
+
}, duration);
|
|
62691
62824
|
}
|
|
62692
62825
|
scrollToCol(col, animationOption) {
|
|
62693
62826
|
animationOption ? this.animationManager.scrollTo({
|
|
@@ -62706,8 +62839,8 @@
|
|
|
62706
62839
|
}
|
|
62707
62840
|
if (isValid$2(cellAddr.row) && cellAddr.row >= this.frozenRowCount) {
|
|
62708
62841
|
const frozenHeight = this.getFrozenRowsHeight(),
|
|
62709
|
-
top = this.
|
|
62710
|
-
this.scrollTop = Math.min(top - frozenHeight, this.
|
|
62842
|
+
top = this.rowHeightsMap.getSumInRange(0, cellAddr.row - 1);
|
|
62843
|
+
this.scrollTop = Math.min(top - frozenHeight, this.rowHeightsMap.getSumInRange(0, this.rowCount - 1) - drawRange.height);
|
|
62711
62844
|
}
|
|
62712
62845
|
this.render();
|
|
62713
62846
|
}
|
|
@@ -63007,7 +63140,7 @@
|
|
|
63007
63140
|
}
|
|
63008
63141
|
cloneParseData(data, options) {
|
|
63009
63142
|
let clone = !1;
|
|
63010
|
-
return data instanceof DataView || !0 !== (null == options ? void 0 : options.clone) || (clone = !0), clone ? cloneDeep$
|
|
63143
|
+
return data instanceof DataView || !0 !== (null == options ? void 0 : options.clone) || (clone = !0), clone ? cloneDeep$2(data) : data;
|
|
63011
63144
|
}
|
|
63012
63145
|
parseNewData(data, options) {
|
|
63013
63146
|
this.parse(data, options || this.parseOption), this.reRunAllTransform();
|
|
@@ -63040,7 +63173,7 @@
|
|
|
63040
63173
|
|
|
63041
63174
|
const ignoreWhen = value => isDataView(value) || isHTMLElement(value);
|
|
63042
63175
|
function cloneDeepSpec(spec, excludeKeys = ["data"]) {
|
|
63043
|
-
return cloneDeep$
|
|
63176
|
+
return cloneDeep$2(spec, ignoreWhen, excludeKeys);
|
|
63044
63177
|
}
|
|
63045
63178
|
|
|
63046
63179
|
function transformLegendTitleAttributes(title) {
|
|
@@ -63355,9 +63488,24 @@
|
|
|
63355
63488
|
return layout._cellRangeMap.set(`$${col}$${row}`, cellRange), cellRange;
|
|
63356
63489
|
}
|
|
63357
63490
|
function getTreeTitleMerge(col, row, cellRange, layout) {
|
|
63491
|
+
var _a;
|
|
63358
63492
|
if ("tree" !== layout.rowHierarchyType) return;
|
|
63359
|
-
const
|
|
63360
|
-
|
|
63493
|
+
const table = layout._table,
|
|
63494
|
+
internalProps = table.internalProps || {},
|
|
63495
|
+
isGroupMode = !!internalProps.groupBy,
|
|
63496
|
+
cellRecord = table.getCellRawRecord(col, row);
|
|
63497
|
+
if (!(null == cellRecord ? void 0 : cellRecord.vtableMerge)) return;
|
|
63498
|
+
const treeTitleStartCol = internalProps.groupTitleCheckbox && internalProps.rowSeriesNumber ? layout.rowHeaderLevelCount + layout.leftRowSeriesNumberColumnCount : layout.rowHeaderLevelCount;
|
|
63499
|
+
if (!(col < treeTitleStartCol) && (cellRange.start.col = treeTitleStartCol, cellRange.end.col = layout.colCount - 1, cellRange.start.row = cellRange.end.row = row, isGroupMode && 1 === (null === (_a = layout.columnObjects) || void 0 === _a ? void 0 : _a.length))) {
|
|
63500
|
+
const onlyColumn = layout.columnObjects[0],
|
|
63501
|
+
field = null == onlyColumn ? void 0 : onlyColumn.field;
|
|
63502
|
+
if (null != field) {
|
|
63503
|
+
let text = cellRecord.vtableMergeName;
|
|
63504
|
+
const groupTitleFieldFormat = internalProps.groupTitleFieldFormat;
|
|
63505
|
+
"function" == typeof groupTitleFieldFormat && (text = groupTitleFieldFormat(cellRecord, col, row, table));
|
|
63506
|
+
null == cellRecord[field] && null != text && (cellRecord[field] = text);
|
|
63507
|
+
}
|
|
63508
|
+
}
|
|
63361
63509
|
}
|
|
63362
63510
|
function getCellRangeTranspose(col, row, layout) {
|
|
63363
63511
|
var _a, _b, _c, _d;
|
|
@@ -64274,7 +64422,7 @@
|
|
|
64274
64422
|
this.listenersId.push(doubleClickEventId, clickEventId, selectedChangedEventId);
|
|
64275
64423
|
}
|
|
64276
64424
|
startEditCell(col, row, value, editElement) {
|
|
64277
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
64425
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
64278
64426
|
if (this.editingEditor) return;
|
|
64279
64427
|
const editor = this.table.getEditor(col, row);
|
|
64280
64428
|
if (editor) {
|
|
@@ -64290,7 +64438,8 @@
|
|
|
64290
64438
|
col: col,
|
|
64291
64439
|
row: row
|
|
64292
64440
|
}), this.table._makeVisibleCell(col, row), this.editingEditor = editor;
|
|
64293
|
-
const
|
|
64441
|
+
const customMergeText = null === (_j = this.table.getCustomMerge(col, row)) || void 0 === _j ? void 0 : _j.text,
|
|
64442
|
+
dataValue = isValid$2(value) ? value : isValid$2(customMergeText) ? customMergeText : this.table.getCellOriginValue(col, row),
|
|
64294
64443
|
rect = this.table.getCellRangeRelativeRect(this.table.getCellRange(col, row)),
|
|
64295
64444
|
referencePosition = {
|
|
64296
64445
|
rect: {
|
|
@@ -64300,9 +64449,9 @@
|
|
|
64300
64449
|
height: rect.height
|
|
64301
64450
|
}
|
|
64302
64451
|
};
|
|
64303
|
-
col === this.table.colCount - 1 ? referencePosition.rect.width = rect.width - 1 : referencePosition.rect.width = rect.width + 1, row === this.table.rowCount - 1 ? referencePosition.rect.height = rect.height - 1 : referencePosition.rect.height = rect.height + 1, editor.beginEditing, null === (
|
|
64452
|
+
col === this.table.colCount - 1 ? referencePosition.rect.width = rect.width - 1 : referencePosition.rect.width = rect.width + 1, row === this.table.rowCount - 1 ? referencePosition.rect.height = rect.height - 1 : referencePosition.rect.height = rect.height + 1, editor.beginEditing, null === (_k = editor.beginEditing) || void 0 === _k || _k.call(editor, this.table.getElement(), referencePosition, dataValue), editor.bindSuccessCallback, null === (_l = editor.bindSuccessCallback) || void 0 === _l || _l.call(editor, () => {
|
|
64304
64453
|
this.completeEdit();
|
|
64305
|
-
}), null === (
|
|
64454
|
+
}), null === (_m = editor.onStart) || void 0 === _m || _m.call(editor, {
|
|
64306
64455
|
value: dataValue,
|
|
64307
64456
|
endEdit: () => {
|
|
64308
64457
|
this.completeEdit();
|
|
@@ -64316,7 +64465,7 @@
|
|
|
64316
64465
|
}
|
|
64317
64466
|
}
|
|
64318
64467
|
completeEdit(e) {
|
|
64319
|
-
var _a, _b;
|
|
64468
|
+
var _a, _b, _c;
|
|
64320
64469
|
if (!this.editingEditor) return !0;
|
|
64321
64470
|
if (this.isValidatingValue) return !1;
|
|
64322
64471
|
this.cacheLastSelectedCellEditor = {};
|
|
@@ -64330,9 +64479,10 @@
|
|
|
64330
64479
|
if (this.editingEditor.getValue, this.editingEditor.validateValue) {
|
|
64331
64480
|
this.isValidatingValue = !0;
|
|
64332
64481
|
const newValue = this.editingEditor.getValue(),
|
|
64333
|
-
|
|
64482
|
+
customMergeText = null === (_a = this.table.getCustomMerge(this.editCell.col, this.editCell.row)) || void 0 === _a ? void 0 : _a.text,
|
|
64483
|
+
oldValue = isValid$2(customMergeText) ? customMergeText : this.table.getCellOriginValue(this.editCell.col, this.editCell.row),
|
|
64334
64484
|
target = null == e ? void 0 : e.target,
|
|
64335
|
-
maybePromiseOrValue = null === (
|
|
64485
|
+
maybePromiseOrValue = null === (_c = (_b = this.editingEditor).validateValue) || void 0 === _c ? void 0 : _c.call(_b, newValue, oldValue, this.editCell, this.table, !!this.table.getElement().contains(target));
|
|
64336
64486
|
return isPromise(maybePromiseOrValue) ? (this.isValidatingValue = !0, new Promise((resolve, reject) => {
|
|
64337
64487
|
maybePromiseOrValue.then(result => {
|
|
64338
64488
|
dealWithValidateValue(result, this, oldValue, resolve);
|
|
@@ -64346,18 +64496,24 @@
|
|
|
64346
64496
|
doExit() {
|
|
64347
64497
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
64348
64498
|
const changedValue = null === (_b = (_a = this.editingEditor).getValue) || void 0 === _b ? void 0 : _b.call(_a),
|
|
64349
|
-
range = this.table.getCellRange(this.editCell.col, this.editCell.row)
|
|
64350
|
-
|
|
64351
|
-
|
|
64352
|
-
|
|
64353
|
-
|
|
64354
|
-
|
|
64499
|
+
range = this.table.getCellRange(this.editCell.col, this.editCell.row);
|
|
64500
|
+
if (null === (_d = (_c = this.editingEditor).beforeEnd) || void 0 === _d || _d.call(_c), range.isCustom) this.table.changeCellValue(range.start.col, range.start.row, changedValue);else {
|
|
64501
|
+
const changedValues = [];
|
|
64502
|
+
for (let row = range.start.row; row <= range.end.row; row++) {
|
|
64503
|
+
const rowChangedValues = [];
|
|
64504
|
+
for (let col = range.start.col; col <= range.end.col; col++) rowChangedValues.push(changedValue);
|
|
64505
|
+
changedValues.push(rowChangedValues);
|
|
64506
|
+
}
|
|
64507
|
+
this.table.changeCellValues(range.start.col, range.start.row, changedValues);
|
|
64355
64508
|
}
|
|
64356
|
-
|
|
64509
|
+
this.editingEditor.exit, null === (_f = (_e = this.editingEditor).exit) || void 0 === _f || _f.call(_e), null === (_h = (_g = this.editingEditor).onEnd) || void 0 === _h || _h.call(_g), this.editingEditor = null, this.isValidatingValue = !1, this.beginTriggerEditCellMode = null;
|
|
64357
64510
|
}
|
|
64358
64511
|
cancelEdit() {
|
|
64359
64512
|
var _a, _b, _c, _d;
|
|
64360
|
-
this.editingEditor && (null === (_b = (_a = this.editingEditor).exit) || void 0 === _b || _b.call(_a), null === (_d = (_c = this.editingEditor).onEnd) || void 0 === _d || _d.call(_c), this.editingEditor = null)
|
|
64513
|
+
this.editingEditor && (null === (_b = (_a = this.editingEditor).exit) || void 0 === _b || _b.call(_a), null === (_d = (_c = this.editingEditor).onEnd) || void 0 === _d || _d.call(_c), this.editingEditor = null), Object.values(this.cacheLastSelectedCellEditor).forEach(editor => {
|
|
64514
|
+
var _a;
|
|
64515
|
+
return null === (_a = null == editor ? void 0 : editor.onEnd) || void 0 === _a ? void 0 : _a.call(editor);
|
|
64516
|
+
}), this.cacheLastSelectedCellEditor = {};
|
|
64361
64517
|
}
|
|
64362
64518
|
release() {
|
|
64363
64519
|
this.listenersId.forEach(id => {
|
|
@@ -64410,7 +64566,18 @@
|
|
|
64410
64566
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64411
64567
|
});
|
|
64412
64568
|
};
|
|
64569
|
+
function refreshCustomMergeCellGroups(table) {
|
|
64570
|
+
var _a;
|
|
64571
|
+
if (!Array.isArray(table.options.customMergeCell)) return;
|
|
64572
|
+
table.internalProps.customMergeCell = getCustomMergeCellFunc$1(table.options.customMergeCell);
|
|
64573
|
+
const merges = table.options.customMergeCell;
|
|
64574
|
+
for (let i = 0; i < merges.length; i++) {
|
|
64575
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
64576
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) table.scenegraph.updateCellContent(col, row);
|
|
64577
|
+
}
|
|
64578
|
+
}
|
|
64413
64579
|
function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
|
|
64580
|
+
var _a, _b;
|
|
64414
64581
|
if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
|
|
64415
64582
|
const recordShowIndex = table.getRecordShowIndexByCell(col, row),
|
|
64416
64583
|
recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
|
|
@@ -64420,8 +64587,12 @@
|
|
|
64420
64587
|
beforeChangeValue = table.getCellRawValue(col, row),
|
|
64421
64588
|
oldValue = table.getCellOriginValue(col, row);
|
|
64422
64589
|
table.isHeader(col, row) ? table.internalProps.layoutMap.updateColumnTitle(col, row, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, col, row, table);
|
|
64423
|
-
const range = table.getCellRange(col, row)
|
|
64424
|
-
|
|
64590
|
+
const range = table.getCellRange(col, row);
|
|
64591
|
+
if (range.isCustom && range.start.col === col && range.start.row === row && Array.isArray(table.options.customMergeCell) && "function" == typeof table.getCellValue) {
|
|
64592
|
+
const customMerge = null === (_b = null === (_a = table.internalProps) || void 0 === _a ? void 0 : _a.customMergeCell) || void 0 === _b ? void 0 : _b.call(_a, col, row, table);
|
|
64593
|
+
customMerge && (customMerge.text = value);
|
|
64594
|
+
}
|
|
64595
|
+
const aggregators = table.internalProps.layoutMap.getAggregatorsByCell(col, row);
|
|
64425
64596
|
if (aggregators) {
|
|
64426
64597
|
if (Array.isArray(aggregators)) for (let i = 0; i < (null == aggregators ? void 0 : aggregators.length); i++) aggregators[i].recalculate();else aggregators.recalculate();
|
|
64427
64598
|
const aggregatorCells = table.internalProps.layoutMap.getAggregatorCellAddress(range.start.col, range.start.row, range.end.col, range.end.row);
|
|
@@ -64644,7 +64815,13 @@
|
|
|
64644
64815
|
(void 0 === recordIndex || recordIndex > table.dataSource.sourceLength) && (recordIndex = table.dataSource.sourceLength);
|
|
64645
64816
|
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64646
64817
|
syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords);
|
|
64647
|
-
if (table.dataSource.addRecord(record, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1), syncToOriginalRecords)
|
|
64818
|
+
if (table.dataSource.addRecord(record, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1), syncToOriginalRecords) {
|
|
64819
|
+
if (!table.transpose) {
|
|
64820
|
+
const insertRowIndex = recordIndex + headerCount + table.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
64821
|
+
table.rowHeightsMap.insert(insertRowIndex);
|
|
64822
|
+
}
|
|
64823
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(!0), !0;
|
|
64824
|
+
}
|
|
64648
64825
|
const oldRowCount = table.rowCount;
|
|
64649
64826
|
if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
|
|
64650
64827
|
const newRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
@@ -64722,7 +64899,13 @@
|
|
|
64722
64899
|
void 0 === recordIndex || recordIndex > table.dataSource.sourceLength ? recordIndex = table.dataSource.sourceLength : recordIndex < 0 && (recordIndex = 0);
|
|
64723
64900
|
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64724
64901
|
syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords);
|
|
64725
|
-
if (table.dataSource.addRecords(records, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length), syncToOriginalRecords)
|
|
64902
|
+
if (table.dataSource.addRecords(records, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length), syncToOriginalRecords) {
|
|
64903
|
+
if (!table.transpose) {
|
|
64904
|
+
const insertRowIndex = recordIndex + headerCount + table.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
64905
|
+
for (let i = 0; i < records.length; i++) table.rowHeightsMap.insert(insertRowIndex);
|
|
64906
|
+
}
|
|
64907
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(!0), !0;
|
|
64908
|
+
}
|
|
64726
64909
|
const oldRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
64727
64910
|
if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
|
|
64728
64911
|
const newRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
@@ -64791,7 +64974,7 @@
|
|
|
64791
64974
|
}
|
|
64792
64975
|
}
|
|
64793
64976
|
function listTableDeleteRecords(recordIndexs, table) {
|
|
64794
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
64977
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
64795
64978
|
if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0) if (table.internalProps.groupBy) null === (_b = (_a = table.dataSource).deleteRecordsForGroup) || void 0 === _b || _b.call(_a, recordIndexs), table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.sortState && sortRecords(table), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph();else if ("tree" === table.dataSource.rowHierarchyType) {
|
|
64796
64979
|
const deletedRecordIndexs = null === (_d = (_c = table.dataSource).deleteRecordsForTree) || void 0 === _d ? void 0 : _d.call(_c, recordIndexs);
|
|
64797
64980
|
if (0 === deletedRecordIndexs.length) return;
|
|
@@ -64803,8 +64986,17 @@
|
|
|
64803
64986
|
const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
|
|
64804
64987
|
deletedRecordIndexs = table.dataSource.deleteRecords(recordIndexs, syncToOriginalRecords);
|
|
64805
64988
|
if (0 === deletedRecordIndexs.length) return;
|
|
64989
|
+
Array.isArray(table.options.customMergeCell) && (table.internalProps.customMergeCell = getCustomMergeCellFunc$1(table.options.customMergeCell));
|
|
64806
64990
|
for (let index = 0; index < deletedRecordIndexs.length; index++) adjustCheckBoxStateMapWithDeleteRecordIndex(table, deletedRecordIndexs[index], 1);
|
|
64807
|
-
if (syncToOriginalRecords)
|
|
64991
|
+
if (syncToOriginalRecords) {
|
|
64992
|
+
if (!table.transpose) {
|
|
64993
|
+
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
|
|
64994
|
+
topAggregationCount = table.internalProps.layoutMap.hasAggregationOnTopCount,
|
|
64995
|
+
sorted = [...deletedRecordIndexs].sort((a, b) => b - a);
|
|
64996
|
+
for (let i = 0; i < sorted.length; i++) table.rowHeightsMap.delete(sorted[i] + headerCount + topAggregationCount);
|
|
64997
|
+
}
|
|
64998
|
+
return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph(!0);
|
|
64999
|
+
}
|
|
64808
65000
|
const oldRowCount = table.transpose ? table.colCount : table.rowCount;
|
|
64809
65001
|
table.refreshRowColCount();
|
|
64810
65002
|
const newRowCount = table.transpose ? table.colCount : table.rowCount,
|
|
@@ -64842,7 +65034,7 @@
|
|
|
64842
65034
|
col: 0,
|
|
64843
65035
|
row: row
|
|
64844
65036
|
});
|
|
64845
|
-
null === (_g = table.reactCustomLayout) || void 0 === _g || _g.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_h = table.reactCustomLayout) || void 0 === _h || _h.updateAllCustomCell();
|
|
65037
|
+
null === (_g = table.reactCustomLayout) || void 0 === _g || _g.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_h = table.reactCustomLayout) || void 0 === _h || _h.updateAllCustomCell(), refreshCustomMergeCellGroups(table);
|
|
64846
65038
|
}
|
|
64847
65039
|
} else {
|
|
64848
65040
|
const delRows = [],
|
|
@@ -64860,6 +65052,42 @@
|
|
|
64860
65052
|
});
|
|
64861
65053
|
}
|
|
64862
65054
|
const updateRows = [];
|
|
65055
|
+
if (table.internalProps.customMergeCell) {
|
|
65056
|
+
const proxy = table.scenegraph.proxy,
|
|
65057
|
+
deletedIndexNums = (recordIndexsMinToMax[0], recordIndexsMinToMax.map(recordIndex => recordIndex + headerCount + topAggregationCount)),
|
|
65058
|
+
minIndexNum = deletedIndexNums[0];
|
|
65059
|
+
let updateMin = minIndexNum,
|
|
65060
|
+
updateMax = minIndexNum;
|
|
65061
|
+
if (Array.isArray(table.options.customMergeCell)) {
|
|
65062
|
+
const merges = table.options.customMergeCell,
|
|
65063
|
+
axis = table.transpose ? "col" : "row";
|
|
65064
|
+
merges.forEach(m => {
|
|
65065
|
+
const r = null == m ? void 0 : m.range;
|
|
65066
|
+
if ((null == r ? void 0 : r.start) && (null == r ? void 0 : r.end)) for (let i = 0; i < deletedIndexNums.length; i++) {
|
|
65067
|
+
const deleteIndex = deletedIndexNums[i];
|
|
65068
|
+
if (r.end[axis] >= deleteIndex - 1) {
|
|
65069
|
+
updateMin = Math.min(updateMin, r.start[axis]), updateMax = Math.max(updateMax, r.end[axis]);
|
|
65070
|
+
break;
|
|
65071
|
+
}
|
|
65072
|
+
}
|
|
65073
|
+
});
|
|
65074
|
+
}
|
|
65075
|
+
if (table.transpose) {
|
|
65076
|
+
const start = Math.max(updateMin, null !== (_j = null == proxy ? void 0 : proxy.colStart) && void 0 !== _j ? _j : updateMin),
|
|
65077
|
+
end = Math.min(updateMax, null !== (_k = null == proxy ? void 0 : proxy.colEnd) && void 0 !== _k ? _k : updateMax);
|
|
65078
|
+
for (let col = start; col <= end; col++) updateRows.push({
|
|
65079
|
+
col: col,
|
|
65080
|
+
row: 0
|
|
65081
|
+
});
|
|
65082
|
+
} else {
|
|
65083
|
+
const start = Math.max(updateMin, null !== (_l = null == proxy ? void 0 : proxy.rowStart) && void 0 !== _l ? _l : updateMin),
|
|
65084
|
+
end = Math.min(updateMax, null !== (_m = null == proxy ? void 0 : proxy.rowEnd) && void 0 !== _m ? _m : updateMax);
|
|
65085
|
+
for (let row = start; row <= end; row++) updateRows.push({
|
|
65086
|
+
col: 0,
|
|
65087
|
+
row: row
|
|
65088
|
+
});
|
|
65089
|
+
}
|
|
65090
|
+
}
|
|
64863
65091
|
for (let row = headerCount; row < headerCount + topAggregationCount; row++) table.transpose ? updateRows.push({
|
|
64864
65092
|
col: row,
|
|
64865
65093
|
row: 0
|
|
@@ -64874,7 +65102,7 @@
|
|
|
64874
65102
|
col: 0,
|
|
64875
65103
|
row: row
|
|
64876
65104
|
});
|
|
64877
|
-
null === (
|
|
65105
|
+
null === (_o = table.reactCustomLayout) || void 0 === _o || _o.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_p = table.reactCustomLayout) || void 0 === _p || _p.updateAllCustomCell(), refreshCustomMergeCellGroups(table);
|
|
64878
65106
|
}
|
|
64879
65107
|
}
|
|
64880
65108
|
}
|
|
@@ -64886,7 +65114,7 @@
|
|
|
64886
65114
|
const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
|
|
64887
65115
|
updateRecordIndexs = table.dataSource.updateRecords(records, recordIndexs, syncToOriginalRecords);
|
|
64888
65116
|
if (0 === updateRecordIndexs.length) return;
|
|
64889
|
-
if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph();
|
|
65117
|
+
if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph(!0);
|
|
64890
65118
|
const recordIndexsMinToMax = updateRecordIndexs.map(index => table.getBodyRowIndexByRecordIndex(index)).sort((a, b) => a - b);
|
|
64891
65119
|
if (table.pagination) {
|
|
64892
65120
|
const {
|
|
@@ -65209,10 +65437,33 @@
|
|
|
65209
65437
|
this._hasAutoImageColumn = void 0, this.refreshHeader(), this.records && checkHasAggregationOnColumnDefine(this.internalProps.columns) && this.dataSource.processRecords(null !== (_b = null === (_a = this.dataSource.dataSourceObj) || void 0 === _a ? void 0 : _a.records) && void 0 !== _b ? _b : this.dataSource.dataSourceObj), this.internalProps.useOneRowHeightFillAll = !1, this.headerStyleCache = new Map(), this.bodyStyleCache = new Map(), this.bodyBottomStyleCache = new Map(), this._updateSize(), this.scenegraph.createSceneGraph(), this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row), this.renderAsync(), this.eventManager.updateEventBinder();
|
|
65210
65438
|
}
|
|
65211
65439
|
addColumns(toAddColumns, colIndex, isMaintainArrayData = !0) {
|
|
65212
|
-
var _a;
|
|
65440
|
+
var _a, _b;
|
|
65213
65441
|
const columns = this.options.columns;
|
|
65442
|
+
if (Array.isArray(this.options.customMergeCell) && (null == toAddColumns ? void 0 : toAddColumns.length)) {
|
|
65443
|
+
const axis = this.transpose ? "row" : "col";
|
|
65444
|
+
let insertIndex = colIndex;
|
|
65445
|
+
void 0 === insertIndex ? insertIndex = columns.length : insertIndex < 0 ? insertIndex = 0 : insertIndex > columns.length && (insertIndex = columns.length);
|
|
65446
|
+
const toAddCount = toAddColumns.length,
|
|
65447
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
65448
|
+
range: {
|
|
65449
|
+
start: Object.assign({}, m.range.start),
|
|
65450
|
+
end: Object.assign({}, m.range.end)
|
|
65451
|
+
}
|
|
65452
|
+
}));
|
|
65453
|
+
for (let i = 0; i < merges.length; i++) {
|
|
65454
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
65455
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
65456
|
+
const start = r.start[axis],
|
|
65457
|
+
end = r.end[axis];
|
|
65458
|
+
end < insertIndex || (start > insertIndex ? (r.start[axis] = start + toAddCount, r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
|
|
65459
|
+
}
|
|
65460
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
65461
|
+
const r = null == m ? void 0 : m.range;
|
|
65462
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
65463
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
65464
|
+
}
|
|
65214
65465
|
void 0 === colIndex ? (colIndex = columns.length, columns.push(...toAddColumns)) : columns.splice(colIndex, 0, ...toAddColumns);
|
|
65215
|
-
for (let i = 0; i < toAddColumns.length; i++) this.colWidthsMap.addAndReorder(colIndex + i, null !== (
|
|
65466
|
+
for (let i = 0; i < toAddColumns.length; i++) this.colWidthsMap.addAndReorder(colIndex + i, null !== (_b = toAddColumns[i].width) && void 0 !== _b ? _b : this.internalProps.defaultColWidth);
|
|
65216
65467
|
this.internalProps._colRangeWidthsMap.clear();
|
|
65217
65468
|
const resizedColIndexs = Array.from(this.internalProps._widthResizedColMap.keys());
|
|
65218
65469
|
for (let i = 0; i < resizedColIndexs.length; i++) resizedColIndexs[i] >= colIndex && (this.internalProps._widthResizedColMap.delete(resizedColIndexs[i]), this.internalProps._widthResizedColMap.add(resizedColIndexs[i] + toAddColumns.length));
|
|
@@ -65225,15 +65476,46 @@
|
|
|
65225
65476
|
}
|
|
65226
65477
|
this.updateColumns(columns, {
|
|
65227
65478
|
clearRowHeightCache: !1
|
|
65228
|
-
}), this.
|
|
65479
|
+
}), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
65480
|
+
const r = null == m ? void 0 : m.range;
|
|
65481
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
65482
|
+
}), this.scenegraph.updateNextFrame()), this.fireListeners(TABLE_EVENT_TYPE.ADD_COLUMN, {
|
|
65229
65483
|
columnIndex: colIndex,
|
|
65230
65484
|
columnCount: toAddColumns.length,
|
|
65231
65485
|
columns: columns
|
|
65232
65486
|
});
|
|
65233
65487
|
}
|
|
65234
65488
|
deleteColumns(deleteColIndexs, isMaintainArrayData = !0) {
|
|
65489
|
+
var _a;
|
|
65235
65490
|
const columns = this.options.columns;
|
|
65236
65491
|
deleteColIndexs.sort((a, b) => b - a);
|
|
65492
|
+
const deletedColumns = deleteColIndexs.map(idx => cloneDeepSpec(columns[idx], ["children"]));
|
|
65493
|
+
let deletedRecordValues;
|
|
65494
|
+
if (Array.isArray(this.options.customMergeCell) && (null == deleteColIndexs ? void 0 : deleteColIndexs.length)) {
|
|
65495
|
+
const axis = this.transpose ? "row" : "col",
|
|
65496
|
+
deleteIndexNums = deleteColIndexs.slice().sort((a, b) => a - b).map((idx, i) => idx - i),
|
|
65497
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
65498
|
+
range: {
|
|
65499
|
+
start: Object.assign({}, m.range.start),
|
|
65500
|
+
end: Object.assign({}, m.range.end)
|
|
65501
|
+
}
|
|
65502
|
+
}));
|
|
65503
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
65504
|
+
const deleteIndex = deleteIndexNums[i];
|
|
65505
|
+
for (let j = 0; j < merges.length; j++) {
|
|
65506
|
+
const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
|
|
65507
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
65508
|
+
const start = r.start[axis],
|
|
65509
|
+
end = r.end[axis];
|
|
65510
|
+
end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
|
|
65511
|
+
}
|
|
65512
|
+
}
|
|
65513
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
65514
|
+
const r = null == m ? void 0 : m.range;
|
|
65515
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
65516
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
65517
|
+
}
|
|
65518
|
+
isMaintainArrayData && Array.isArray(this.records) && this.records.length && (deletedRecordValues = this.records.map(record => Array.isArray(record) ? deleteColIndexs.map(idx => record[idx]) : []), deletedRecordValues.every(v => 0 === v.length) && (deletedRecordValues = void 0));
|
|
65237
65519
|
for (let i = 0; i < deleteColIndexs.length; i++) if (columns.splice(deleteColIndexs[i], 1), this.colWidthsMap.delAndReorder(deleteColIndexs[i]), this.internalProps._widthResizedColMap.delete(deleteColIndexs[i]), isMaintainArrayData) for (let j = 0; j < this.records.length; j++) {
|
|
65238
65520
|
const record = this.records[j];
|
|
65239
65521
|
Array.isArray(record) && record.splice(deleteColIndexs[i], 1);
|
|
@@ -65249,7 +65531,9 @@
|
|
|
65249
65531
|
clearRowHeightCache: !1
|
|
65250
65532
|
}), this.fireListeners(TABLE_EVENT_TYPE.DELETE_COLUMN, {
|
|
65251
65533
|
deleteColIndexs: deleteColIndexs,
|
|
65252
|
-
columns: columns
|
|
65534
|
+
columns: columns,
|
|
65535
|
+
deletedColumns: deletedColumns,
|
|
65536
|
+
deletedRecordValues: deletedRecordValues
|
|
65253
65537
|
});
|
|
65254
65538
|
}
|
|
65255
65539
|
get columns() {
|
|
@@ -65637,9 +65921,9 @@
|
|
|
65637
65921
|
}
|
|
65638
65922
|
}
|
|
65639
65923
|
updateSortState(sortState, executeSort = !0) {
|
|
65640
|
-
var _a;
|
|
65641
|
-
|
|
65642
|
-
(
|
|
65924
|
+
var _a, _b, _c, _d, _e;
|
|
65925
|
+
const normalizedSortState = (Array.isArray(sortState) ? sortState : sortState ? [sortState] : []).filter(Boolean);
|
|
65926
|
+
if (normalizedSortState.length ? this.internalProps.sortState = sortState : this.internalProps.sortState = null, executeSort) if (normalizedSortState.length) this.internalProps.layoutMap.headerObjects.some(item => !1 !== item.define.sort) && (this.dataSource.sort(normalizedSortState.map(item => {
|
|
65643
65927
|
const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, item.field);
|
|
65644
65928
|
this.internalProps.layoutMap.headerObjects.find(col => col && col.field === item.field);
|
|
65645
65929
|
return {
|
|
@@ -65647,13 +65931,20 @@
|
|
|
65647
65931
|
order: item.order,
|
|
65648
65932
|
orderFn: null != sortFunc ? sortFunc : defaultOrderFn
|
|
65649
65933
|
};
|
|
65650
|
-
})), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell())
|
|
65934
|
+
})), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell());else {
|
|
65935
|
+
const ds = this.dataSource,
|
|
65936
|
+
sourceLength = null !== (_c = null !== (_b = null !== (_a = null == ds ? void 0 : ds.sourceLength) && void 0 !== _a ? _a : null == ds ? void 0 : ds._sourceLength) && void 0 !== _b ? _b : null == ds ? void 0 : ds.length) && void 0 !== _c ? _c : 0;
|
|
65937
|
+
(null === (_d = null == ds ? void 0 : ds.sortedIndexMap) || void 0 === _d ? void 0 : _d.clear) && ds.sortedIndexMap.clear(), void 0 !== ds.currentIndexedData && (ds.currentIndexedData = Array.from({
|
|
65938
|
+
length: sourceLength
|
|
65939
|
+
}, (_, i) => i)), ds.lastSortStates = [], null === (_e = ds.updatePagination) || void 0 === _e || _e.call(ds, ds.pagination), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell();
|
|
65940
|
+
}
|
|
65941
|
+
this.stateManager.updateSortState(normalizedSortState);
|
|
65651
65942
|
}
|
|
65652
65943
|
updateFilterRules(filterRules, options = {
|
|
65653
65944
|
clearRowHeightCache: !0
|
|
65654
65945
|
}) {
|
|
65655
65946
|
var _a, _b, _c;
|
|
65656
|
-
this.scenegraph.clearCells(), null === (_b = (_a = this.dataSource).clearForceVisibleRecords) || void 0 === _b || _b.call(_a), this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules), sortRecords(this)) : this.dataSource.updateFilterRules(filterRules, null == options ? void 0 : options.onFilterRecordsEnd), this.refreshRowColCount(), this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!(null == options ? void 0 : options.clearRowHeightCache)), null === (_c = this.internalProps.emptyTip) || void 0 === _c || _c.resetVisible(), this.resize();
|
|
65947
|
+
this.scenegraph.clearCells(), !1 !== (null == options ? void 0 : options.clearForceVisibleRecords) && (null === (_b = (_a = this.dataSource).clearForceVisibleRecords) || void 0 === _b || _b.call(_a)), this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules), sortRecords(this)) : this.dataSource.updateFilterRules(filterRules, null == options ? void 0 : options.onFilterRecordsEnd), this.refreshRowColCount(), this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!(null == options ? void 0 : options.clearRowHeightCache)), null === (_c = this.internalProps.emptyTip) || void 0 === _c || _c.resetVisible(), this.resize();
|
|
65657
65948
|
}
|
|
65658
65949
|
getFilteredRecords() {
|
|
65659
65950
|
return this.dataSource.records;
|
|
@@ -65928,30 +66219,112 @@
|
|
|
65928
66219
|
traverseColumns(this.internalProps.columns), this.refreshRowColCount(), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!clearRowHeightCache), null === (_k = this.internalProps.emptyTip) || void 0 === _k || _k.resetVisible(), this.resize();
|
|
65929
66220
|
}
|
|
65930
66221
|
addRecord(record, recordIndex, triggerEvent = !0) {
|
|
65931
|
-
var _a;
|
|
66222
|
+
var _a, _b;
|
|
66223
|
+
if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex) {
|
|
66224
|
+
const axis = this.transpose ? "col" : "row",
|
|
66225
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66226
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
66227
|
+
let insertIndex = recordIndex;
|
|
66228
|
+
void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
|
|
66229
|
+
const insertIndexNum = insertIndex + headerCount + topAggregationCount,
|
|
66230
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
66231
|
+
range: {
|
|
66232
|
+
start: Object.assign({}, m.range.start),
|
|
66233
|
+
end: Object.assign({}, m.range.end)
|
|
66234
|
+
}
|
|
66235
|
+
}));
|
|
66236
|
+
for (let i = 0; i < merges.length; i++) {
|
|
66237
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
66238
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66239
|
+
const start = r.start[axis],
|
|
66240
|
+
end = r.end[axis];
|
|
66241
|
+
end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + 1, r.end[axis] = end + 1) : r.end[axis] = end + 1);
|
|
66242
|
+
}
|
|
66243
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66244
|
+
const r = null == m ? void 0 : m.range;
|
|
66245
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
66246
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66247
|
+
}
|
|
65932
66248
|
const success = listTableAddRecord(record, recordIndex, this);
|
|
65933
|
-
adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (
|
|
66249
|
+
adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible(), success && Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
66250
|
+
const r = null == m ? void 0 : m.range;
|
|
66251
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
66252
|
+
}), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
|
|
65934
66253
|
records: [record],
|
|
65935
66254
|
recordIndex: recordIndex,
|
|
65936
66255
|
recordCount: 1
|
|
65937
66256
|
});
|
|
65938
66257
|
}
|
|
65939
66258
|
addRecords(records, recordIndex, triggerEvent = !0) {
|
|
65940
|
-
var _a;
|
|
66259
|
+
var _a, _b;
|
|
66260
|
+
if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex && (null == records ? void 0 : records.length)) {
|
|
66261
|
+
const axis = this.transpose ? "col" : "row",
|
|
66262
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66263
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
66264
|
+
let insertIndex = recordIndex;
|
|
66265
|
+
void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
|
|
66266
|
+
const insertIndexNum = insertIndex + headerCount + topAggregationCount,
|
|
66267
|
+
toAddCount = records.length,
|
|
66268
|
+
merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
|
|
66269
|
+
range: {
|
|
66270
|
+
start: Object.assign({}, m.range.start),
|
|
66271
|
+
end: Object.assign({}, m.range.end)
|
|
66272
|
+
}
|
|
66273
|
+
}));
|
|
66274
|
+
for (let i = 0; i < merges.length; i++) {
|
|
66275
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
66276
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66277
|
+
const start = r.start[axis],
|
|
66278
|
+
end = r.end[axis];
|
|
66279
|
+
end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + toAddCount, r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
|
|
66280
|
+
}
|
|
66281
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66282
|
+
const r = null == m ? void 0 : m.range;
|
|
66283
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
66284
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66285
|
+
}
|
|
65941
66286
|
const success = listTableAddRecords(records, recordIndex, this);
|
|
65942
|
-
"number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (
|
|
66287
|
+
"number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible(), success && Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
66288
|
+
const r = null == m ? void 0 : m.range;
|
|
66289
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
66290
|
+
}), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
|
|
65943
66291
|
records: records,
|
|
65944
66292
|
recordIndex: recordIndex,
|
|
65945
66293
|
recordCount: records.length
|
|
65946
66294
|
});
|
|
65947
66295
|
}
|
|
65948
66296
|
deleteRecords(recordIndexs, triggerEvent = !0) {
|
|
65949
|
-
var _a;
|
|
65950
|
-
const
|
|
65951
|
-
|
|
66297
|
+
var _a, _b;
|
|
66298
|
+
const prevMergeRanges = Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map(m => null == m ? void 0 : m.range).filter(Boolean).map(r => ({
|
|
66299
|
+
start: Object.assign({}, r.start),
|
|
66300
|
+
end: Object.assign({}, r.end)
|
|
66301
|
+
})) : [],
|
|
66302
|
+
deletedRecords = [];
|
|
66303
|
+
if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0 && recordIndexs.forEach(index => {
|
|
65952
66304
|
let record = null;
|
|
65953
66305
|
record = "number" == typeof index ? this.dataSource.get(index) : [], deletedRecords.push(record);
|
|
65954
|
-
}),
|
|
66306
|
+
}), Array.isArray(this.options.customMergeCell) && (null == recordIndexs ? void 0 : recordIndexs.length) && "number" == typeof recordIndexs[0]) {
|
|
66307
|
+
const axis = this.transpose ? "col" : "row",
|
|
66308
|
+
headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
|
|
66309
|
+
topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount,
|
|
66310
|
+
deleteIndexNums = recordIndexs.slice().sort((a, b) => a - b).map((index, i) => index + headerCount + topAggregationCount - i),
|
|
66311
|
+
merges = this.options.customMergeCell;
|
|
66312
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
66313
|
+
const deleteIndex = deleteIndexNums[i];
|
|
66314
|
+
for (let j = 0; j < merges.length; j++) {
|
|
66315
|
+
const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
|
|
66316
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
66317
|
+
const start = r.start[axis],
|
|
66318
|
+
end = r.end[axis];
|
|
66319
|
+
end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
|
|
66320
|
+
}
|
|
66321
|
+
}
|
|
66322
|
+
this.options.customMergeCell = merges.filter(m => {
|
|
66323
|
+
const r = null == m ? void 0 : m.range;
|
|
66324
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
|
|
66325
|
+
});
|
|
66326
|
+
}
|
|
66327
|
+
listTableDeleteRecords(recordIndexs, this), adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible();
|
|
65955
66328
|
const rowIndexs = [];
|
|
65956
66329
|
for (let i = 0; i < recordIndexs.length; i++) rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
|
|
65957
66330
|
triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
|
|
@@ -65959,7 +66332,16 @@
|
|
|
65959
66332
|
records: deletedRecords,
|
|
65960
66333
|
rowIndexs: rowIndexs,
|
|
65961
66334
|
deletedCount: (Array.isArray(recordIndexs[0]), recordIndexs.length)
|
|
65962
|
-
})
|
|
66335
|
+
}), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
|
|
66336
|
+
const r = null == m ? void 0 : m.range;
|
|
66337
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
66338
|
+
}), this.scenegraph.updateNextFrame(), setTimeout(() => {
|
|
66339
|
+
if (!this.internalProps || !this.options || !this.scenegraph) return;
|
|
66340
|
+
Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell));
|
|
66341
|
+
[...prevMergeRanges, ...(Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map(m => null == m ? void 0 : m.range) : [])].filter(Boolean).forEach(r => {
|
|
66342
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
66343
|
+
}), this.scenegraph.updateNextFrame();
|
|
66344
|
+
}, 0));
|
|
65963
66345
|
}
|
|
65964
66346
|
updateRecords(records, recordIndexs, triggerEvent = !0) {
|
|
65965
66347
|
listTableUpdateRecords(records, recordIndexs, this), triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
|
|
@@ -66061,9 +66443,14 @@
|
|
|
66061
66443
|
row: endRow
|
|
66062
66444
|
}
|
|
66063
66445
|
}
|
|
66064
|
-
}), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
|
|
66446
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66065
66447
|
for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
|
|
66066
|
-
this.scenegraph.updateNextFrame()
|
|
66448
|
+
this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE.MERGE_CELLS, {
|
|
66449
|
+
startCol: startCol,
|
|
66450
|
+
startRow: startRow,
|
|
66451
|
+
endCol: endCol,
|
|
66452
|
+
endRow: endRow
|
|
66453
|
+
});
|
|
66067
66454
|
}
|
|
66068
66455
|
unmergeCells(startCol, startRow, endCol, endRow) {
|
|
66069
66456
|
this.options.customMergeCell ? "function" == typeof this.options.customMergeCell && (this.options.customMergeCell = []) : this.options.customMergeCell = [], this.options.customMergeCell = this.options.customMergeCell.filter(item => {
|
|
@@ -66072,9 +66459,14 @@
|
|
|
66072
66459
|
end: end
|
|
66073
66460
|
} = item.range;
|
|
66074
66461
|
return !(start.col === startCol && start.row === startRow && end.col === endCol && end.row === endRow);
|
|
66075
|
-
}), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
|
|
66462
|
+
}), this.internalProps.customMergeCell = getCustomMergeCellFunc$1(this.options.customMergeCell);
|
|
66076
66463
|
for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
|
|
66077
|
-
this.scenegraph.updateNextFrame()
|
|
66464
|
+
this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE.UNMERGE_CELLS, {
|
|
66465
|
+
startCol: startCol,
|
|
66466
|
+
startRow: startRow,
|
|
66467
|
+
endCol: endCol,
|
|
66468
|
+
endRow: endRow
|
|
66469
|
+
});
|
|
66078
66470
|
}
|
|
66079
66471
|
}
|
|
66080
66472
|
|
|
@@ -66875,7 +67267,7 @@
|
|
|
66875
67267
|
class DiscreteTableLegend {
|
|
66876
67268
|
constructor(option, table) {
|
|
66877
67269
|
var _a, _b, _c, _d;
|
|
66878
|
-
this.table = table, this.option = cloneDeep$
|
|
67270
|
+
this.table = table, this.option = cloneDeep$2(option), this.orient = null !== (_a = option.orient) && void 0 !== _a ? _a : "left", this.visible = null === (_b = option.visible) || void 0 === _b || _b, this.position = null !== (_c = option.position) && void 0 !== _c ? _c : "middle", this.selectedData = null !== (_d = option.defaultSelected) && void 0 !== _d ? _d : null, this.createComponent(), this.initEvent();
|
|
66879
67271
|
}
|
|
66880
67272
|
createComponent() {
|
|
66881
67273
|
const attrs = this.getLegendAttributes({
|
|
@@ -67124,7 +67516,7 @@
|
|
|
67124
67516
|
class ContinueTableLegend {
|
|
67125
67517
|
constructor(option, table) {
|
|
67126
67518
|
var _a, _b, _c, _d;
|
|
67127
|
-
this.table = table, this.option = cloneDeep$
|
|
67519
|
+
this.table = table, this.option = cloneDeep$2(option), this.orient = null !== (_a = option.orient) && void 0 !== _a ? _a : "left", this.visible = null === (_b = option.visible) || void 0 === _b || _b, this.position = null !== (_c = option.position) && void 0 !== _c ? _c : "middle", this.selectedData = null !== (_d = option.defaultSelected) && void 0 !== _d ? _d : null, this.createComponent(), this.initEvent();
|
|
67128
67520
|
}
|
|
67129
67521
|
createComponent() {
|
|
67130
67522
|
const attrs = this.getLegendAttributes({
|
|
@@ -72093,7 +72485,10 @@
|
|
|
72093
72485
|
}
|
|
72094
72486
|
}), table.updateFilterRules([...this.filterFuncRule, ...this.filterValueRule], {
|
|
72095
72487
|
clearRowHeightCache: !1,
|
|
72096
|
-
onFilterRecordsEnd: null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.onFilterRecordsEnd
|
|
72488
|
+
onFilterRecordsEnd: (null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.onFilterRecordsEnd) ? records => {
|
|
72489
|
+
var _a, _b;
|
|
72490
|
+
return null === (_b = (_a = this.pluginOptions).onFilterRecordsEnd) || void 0 === _b || _b.call(_a, records), records;
|
|
72491
|
+
} : void 0
|
|
72097
72492
|
});
|
|
72098
72493
|
}
|
|
72099
72494
|
createFilterFunction(filter) {
|
|
@@ -72185,6 +72580,79 @@
|
|
|
72185
72580
|
getAllFilterStates() {
|
|
72186
72581
|
return this.state;
|
|
72187
72582
|
}
|
|
72583
|
+
getSnapshot() {
|
|
72584
|
+
const filters = [];
|
|
72585
|
+
return this.state.filters.forEach(v => {
|
|
72586
|
+
const next = Object.assign({}, v);
|
|
72587
|
+
next && "byValue" === next.type && Array.isArray(next.values) && (next.values = next.values.slice().sort((a, b) => String(a).localeCompare(String(b)))), next && Array.isArray(next.condition) && next.condition.length > 2 && (next.condition = next.condition.slice()), filters.push(next);
|
|
72588
|
+
}), filters.sort((a, b) => String(a.field).localeCompare(String(b.field))), {
|
|
72589
|
+
filters: filters
|
|
72590
|
+
};
|
|
72591
|
+
}
|
|
72592
|
+
applySnapshot(snapshot, actionType = FilterActionType.APPLY_FILTERS) {
|
|
72593
|
+
var _a;
|
|
72594
|
+
const next = new Map();
|
|
72595
|
+
(null !== (_a = null == snapshot ? void 0 : snapshot.filters) && void 0 !== _a ? _a : []).forEach(cfg => {
|
|
72596
|
+
if (!cfg) return;
|
|
72597
|
+
const cloned = Object.assign({}, cfg);
|
|
72598
|
+
cloned && "byValue" === cloned.type && Array.isArray(cloned.values) && (cloned.values = cloned.values.slice()), cloned && Array.isArray(cloned.condition) && (cloned.condition = cloned.condition.slice()), next.set(cloned.field, cloned);
|
|
72599
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72600
|
+
filters: next
|
|
72601
|
+
}), this.applyFilters(), this.notifyListeners({
|
|
72602
|
+
type: actionType,
|
|
72603
|
+
payload: {
|
|
72604
|
+
fromSnapshot: !0
|
|
72605
|
+
}
|
|
72606
|
+
});
|
|
72607
|
+
}
|
|
72608
|
+
shiftFieldsOnAddColumns(columnIndex, columnCount) {
|
|
72609
|
+
if (!Number.isFinite(columnIndex) || !Number.isFinite(columnCount) || columnCount <= 0) return;
|
|
72610
|
+
const next = new Map();
|
|
72611
|
+
this.state.filters.forEach((cfg, key) => {
|
|
72612
|
+
let newKey = key;
|
|
72613
|
+
const cloned = Object.assign({}, cfg);
|
|
72614
|
+
"number" == typeof newKey && newKey >= columnIndex && (newKey += columnCount), "number" == typeof cloned.field && cloned.field >= columnIndex && (cloned.field = cloned.field + columnCount), cloned && "byValue" === cloned.type && Array.isArray(cloned.values) && (cloned.values = cloned.values.slice()), cloned && Array.isArray(cloned.condition) && (cloned.condition = cloned.condition.slice()), next.set(newKey, cloned);
|
|
72615
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72616
|
+
filters: next
|
|
72617
|
+
});
|
|
72618
|
+
}
|
|
72619
|
+
shiftFieldsOnDeleteColumns(deleteColIndexs) {
|
|
72620
|
+
if (!Array.isArray(deleteColIndexs) || 0 === deleteColIndexs.length) return;
|
|
72621
|
+
const deleteIndexNums = deleteColIndexs.slice().filter(n => Number.isFinite(n)).sort((a, b) => a - b).map((idx, i) => idx - i),
|
|
72622
|
+
next = new Map();
|
|
72623
|
+
this.state.filters.forEach((cfg, key) => {
|
|
72624
|
+
let newKey = key;
|
|
72625
|
+
const cloned = Object.assign({}, cfg);
|
|
72626
|
+
let removed = !1;
|
|
72627
|
+
if ("number" == typeof newKey) {
|
|
72628
|
+
let k = newKey;
|
|
72629
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
72630
|
+
const d = deleteIndexNums[i];
|
|
72631
|
+
if (k === d) {
|
|
72632
|
+
removed = !0;
|
|
72633
|
+
break;
|
|
72634
|
+
}
|
|
72635
|
+
k > d && (k -= 1);
|
|
72636
|
+
}
|
|
72637
|
+
newKey = k;
|
|
72638
|
+
}
|
|
72639
|
+
if ("number" == typeof cloned.field) {
|
|
72640
|
+
let f = cloned.field;
|
|
72641
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
72642
|
+
const d = deleteIndexNums[i];
|
|
72643
|
+
if (f === d) {
|
|
72644
|
+
removed = !0;
|
|
72645
|
+
break;
|
|
72646
|
+
}
|
|
72647
|
+
f > d && (f -= 1);
|
|
72648
|
+
}
|
|
72649
|
+
cloned.field = f;
|
|
72650
|
+
}
|
|
72651
|
+
removed || (cloned && "byValue" === cloned.type && Array.isArray(cloned.values) && (cloned.values = cloned.values.slice()), cloned && Array.isArray(cloned.condition) && (cloned.condition = cloned.condition.slice()), next.set(newKey, cloned));
|
|
72652
|
+
}), this.state = Object.assign(Object.assign({}, this.state), {
|
|
72653
|
+
filters: next
|
|
72654
|
+
});
|
|
72655
|
+
}
|
|
72188
72656
|
reapplyCurrentFilters() {
|
|
72189
72657
|
this.getActiveFilterFields().length > 0 && this.applyFilters();
|
|
72190
72658
|
}
|
|
@@ -72461,7 +72929,7 @@
|
|
|
72461
72929
|
}), this.candidateKeys.set(candidateField, countMap), this.toUnformattedCache.set(candidateField, toUnformatted);
|
|
72462
72930
|
}
|
|
72463
72931
|
toggleSelectAll(fieldId, selected) {
|
|
72464
|
-
this.valueFilterOptionList.get(fieldId).forEach(option => {
|
|
72932
|
+
(this.valueFilterOptionList.get(fieldId) || []).forEach(option => {
|
|
72465
72933
|
"none" !== option.itemContainer.style.display && (option.checkbox.checked = selected);
|
|
72466
72934
|
});
|
|
72467
72935
|
}
|
|
@@ -72472,7 +72940,7 @@
|
|
|
72472
72940
|
this.selectAllCheckbox.checked = allChecked, this.selectAllCheckbox.indeterminate = !allChecked && !noneChecked;
|
|
72473
72941
|
}
|
|
72474
72942
|
onSearch(fieldId, value) {
|
|
72475
|
-
const items = this.valueFilterOptionList.get(fieldId),
|
|
72943
|
+
const items = this.valueFilterOptionList.get(fieldId) || [],
|
|
72476
72944
|
filterKeywords = value.toUpperCase().split(" ").filter(s => s);
|
|
72477
72945
|
for (const item of items) {
|
|
72478
72946
|
const txtValue = item.id.toUpperCase() || "",
|
|
@@ -72482,48 +72950,19 @@
|
|
|
72482
72950
|
}
|
|
72483
72951
|
}
|
|
72484
72952
|
syncSingleStateFromTableData(fieldId) {
|
|
72485
|
-
|
|
72486
|
-
const selectedValues = new Set(),
|
|
72487
|
-
originalValues = new Set();
|
|
72953
|
+
const originalValues = new Set();
|
|
72488
72954
|
this.table.internalProps.records.forEach(record => {
|
|
72489
72955
|
isValid$2(record) && originalValues.add(record[fieldId]);
|
|
72490
72956
|
});
|
|
72491
|
-
const
|
|
72492
|
-
|
|
72493
|
-
|
|
72494
|
-
|
|
72495
|
-
this.
|
|
72496
|
-
|
|
72497
|
-
|
|
72498
|
-
field: fieldId,
|
|
72499
|
-
values: Array.from(selectedValues),
|
|
72500
|
-
enable: !0
|
|
72501
|
-
}
|
|
72502
|
-
});
|
|
72503
|
-
!arrayEqual(Array.from(originalValues), Array.from(selectedValues)) && (this.selectedKeys.set(fieldId, selectedValues), this.filterStateManager.dispatch({
|
|
72504
|
-
type: FilterActionType.ADD_FILTER,
|
|
72505
|
-
payload: {
|
|
72506
|
-
field: fieldId,
|
|
72507
|
-
type: "byValue",
|
|
72508
|
-
values: Array.from(selectedValues),
|
|
72509
|
-
enable: !0
|
|
72510
|
-
}
|
|
72511
|
-
}));
|
|
72957
|
+
const current = this.filterStateManager.getFilterState(fieldId);
|
|
72958
|
+
if ("byValue" === (null == current ? void 0 : current.type) && Array.isArray(current.values)) this.selectedKeys.set(fieldId, new Set(current.values));else {
|
|
72959
|
+
if ("byCondition" === (null == current ? void 0 : current.type) && current.enable) {
|
|
72960
|
+
const visibleValues = new Set();
|
|
72961
|
+
return this.getRecords(this.table, !1).forEach(record => {
|
|
72962
|
+
isValid$2(record) && visibleValues.add(record[fieldId]);
|
|
72963
|
+
}), void this.selectedKeys.set(fieldId, visibleValues);
|
|
72512
72964
|
}
|
|
72513
|
-
|
|
72514
|
-
const selectedRules = null === (_c = this.filterStateManager.getFilterState(fieldId)) || void 0 === _c ? void 0 : _c.values;
|
|
72515
|
-
if (selectedRules) {
|
|
72516
|
-
!arrayEqual(Array.from(originalValues), selectedRules) && (this.selectedKeys.set(fieldId, new Set(selectedRules)), this.filterStateManager.dispatch({
|
|
72517
|
-
type: FilterActionType.ADD_FILTER,
|
|
72518
|
-
payload: {
|
|
72519
|
-
field: fieldId,
|
|
72520
|
-
type: "byValue",
|
|
72521
|
-
values: selectedRules,
|
|
72522
|
-
enable: !0,
|
|
72523
|
-
shouldKeepUnrelatedState: !0
|
|
72524
|
-
}
|
|
72525
|
-
}));
|
|
72526
|
-
} else this.selectedKeys.set(fieldId, originalValues);
|
|
72965
|
+
this.selectedKeys.set(fieldId, originalValues);
|
|
72527
72966
|
}
|
|
72528
72967
|
}
|
|
72529
72968
|
applyFilter(fieldId = this.selectedField) {
|
|
@@ -72876,12 +73315,13 @@
|
|
|
72876
73315
|
|
|
72877
73316
|
class FilterToolbar {
|
|
72878
73317
|
constructor(table, filterStateManager, pluginOptions) {
|
|
73318
|
+
var _a;
|
|
72879
73319
|
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue", this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.hide = (currentCol, currentRow) => {
|
|
72880
73320
|
this.filterMenu.style.display = "none", this.isVisible = !1, this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {
|
|
72881
73321
|
col: null != currentCol ? currentCol : this.currentCol,
|
|
72882
73322
|
row: null != currentRow ? currentRow : this.currentRow
|
|
72883
73323
|
});
|
|
72884
|
-
}, this.table = table, this.filterStateManager = filterStateManager, this.valueFilter = new ValueFilter(this.table, this.filterStateManager, pluginOptions), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, pluginOptions, this.hide), this.pluginOptions = pluginOptions, this.filterMenuWidth = 300, this.filterStateManager.subscribe(state => {
|
|
73324
|
+
}, this.table = table, this.filterStateManager = filterStateManager, this.valueFilter = new ValueFilter(this.table, this.filterStateManager, pluginOptions), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, pluginOptions, this.hide), this.pluginOptions = pluginOptions, this.pluginId = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : "filter", this.filterMenuWidth = 300, this.filterStateManager.subscribe(state => {
|
|
72885
73325
|
this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
|
|
72886
73326
|
});
|
|
72887
73327
|
}
|
|
@@ -72899,6 +73339,18 @@
|
|
|
72899
73339
|
clearFilter(field) {
|
|
72900
73340
|
this.valueFilter && this.valueFilter.clearFilter(field), this.conditionFilter && this.conditionFilter.clearFilter(field), this.hide();
|
|
72901
73341
|
}
|
|
73342
|
+
recordHistory(before, after) {
|
|
73343
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
73344
|
+
if (JSON.stringify(before) === JSON.stringify(after)) return;
|
|
73345
|
+
const pm = this.table.pluginManager,
|
|
73346
|
+
history = null !== (_f = null !== (_d = null !== (_b = null === (_a = null == pm ? void 0 : pm.getPlugin) || void 0 === _a ? void 0 : _a.call(pm, "history-plugin")) && void 0 !== _b ? _b : null === (_c = null == pm ? void 0 : pm.getPluginByName) || void 0 === _c ? void 0 : _c.call(pm, "History")) && void 0 !== _d ? _d : null === (_e = null == pm ? void 0 : pm.getPlugin) || void 0 === _e ? void 0 : _e.call(pm, "history")) && void 0 !== _f ? _f : null === (_g = null == pm ? void 0 : pm.getPluginByName) || void 0 === _g ? void 0 : _g.call(pm, "history");
|
|
73347
|
+
null === (_h = null == history ? void 0 : history.recordExternalCommand) || void 0 === _h || _h.call(history, {
|
|
73348
|
+
type: "filter",
|
|
73349
|
+
pluginId: this.pluginId,
|
|
73350
|
+
oldSnapshot: before,
|
|
73351
|
+
newSnapshot: after
|
|
73352
|
+
});
|
|
73353
|
+
}
|
|
72902
73354
|
updateClearFilterButtonState(field) {
|
|
72903
73355
|
const currentFilter = this.filterStateManager.getFilterState(field),
|
|
72904
73356
|
hasActiveFilter = currentFilter && currentFilter.enable;
|
|
@@ -72925,9 +73377,16 @@
|
|
|
72925
73377
|
}), this.filterTabByCondition.addEventListener("click", () => {
|
|
72926
73378
|
this.onTabSwitch("byCondition");
|
|
72927
73379
|
}), this.cancelFilterButton.addEventListener("click", () => this.hide()), this.clearFilterOptionLink.addEventListener("click", e => {
|
|
72928
|
-
e.preventDefault()
|
|
73380
|
+
e.preventDefault();
|
|
73381
|
+
const before = this.filterStateManager.getSnapshot();
|
|
73382
|
+
this.clearFilter(this.selectedField);
|
|
73383
|
+
const after = this.filterStateManager.getSnapshot();
|
|
73384
|
+
this.recordHistory(before, after);
|
|
72929
73385
|
}), this.applyFilterButton.addEventListener("click", () => {
|
|
73386
|
+
const before = this.filterStateManager.getSnapshot();
|
|
72930
73387
|
this.applyFilter(this.selectedField);
|
|
73388
|
+
const after = this.filterStateManager.getSnapshot();
|
|
73389
|
+
this.recordHistory(before, after);
|
|
72931
73390
|
}), document.addEventListener("click", () => {
|
|
72932
73391
|
this.isVisible && this.hide();
|
|
72933
73392
|
}), this.filterMenu.addEventListener("click", e => {
|
|
@@ -72952,7 +73411,7 @@
|
|
|
72952
73411
|
const field = this.table.internalProps.layoutMap.getHeaderField(col, row);
|
|
72953
73412
|
this.updateSelectedField(field);
|
|
72954
73413
|
const currentFilter = this.filterStateManager.getFilterState(field);
|
|
72955
|
-
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"), this.updateClearFilterButtonState(field), setTimeout(() => {
|
|
73414
|
+
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.filterModes.includes("byValue") && this.onTabSwitch("byValue"), this.updateClearFilterButtonState(field), setTimeout(() => {
|
|
72956
73415
|
this.isVisible = !0, this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_SHOW, {
|
|
72957
73416
|
col: col,
|
|
72958
73417
|
row: row
|
|
@@ -82433,7 +82892,7 @@
|
|
|
82433
82892
|
class FilterPlugin {
|
|
82434
82893
|
constructor(pluginOptions) {
|
|
82435
82894
|
var _a, _b, _c, _d, _e;
|
|
82436
|
-
this.id = "filter", this.name = "Filter", this.runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, TABLE_EVENT_TYPE.ICON_CLICK, TABLE_EVENT_TYPE.SCROLL, TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, TABLE_EVENT_TYPE.UPDATE_RECORD, TABLE_EVENT_TYPE.ADD_RECORD, TABLE_EVENT_TYPE.DELETE_RECORD], this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = lodashExports.cloneDeep(pluginOptions), this.pluginOptions.filterIcon = null !== (_b = pluginOptions.filterIcon) && void 0 !== _b ? _b : {
|
|
82895
|
+
this.id = "filter", this.name = "Filter", this.runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, TABLE_EVENT_TYPE.ICON_CLICK, TABLE_EVENT_TYPE.SCROLL, TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, TABLE_EVENT_TYPE.UPDATE_RECORD, TABLE_EVENT_TYPE.ADD_RECORD, TABLE_EVENT_TYPE.DELETE_RECORD, TABLE_EVENT_TYPE.ADD_COLUMN, TABLE_EVENT_TYPE.DELETE_COLUMN], this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = lodashExports.cloneDeep(pluginOptions), this.pluginOptions.filterIcon = null !== (_b = pluginOptions.filterIcon) && void 0 !== _b ? _b : {
|
|
82437
82896
|
name: "filter-icon",
|
|
82438
82897
|
type: "svg",
|
|
82439
82898
|
width: 12,
|
|
@@ -82459,7 +82918,7 @@
|
|
|
82459
82918
|
});
|
|
82460
82919
|
}
|
|
82461
82920
|
run(...args) {
|
|
82462
|
-
var _a, _b, _c, _d, _e;
|
|
82921
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
82463
82922
|
const eventArgs = args[0],
|
|
82464
82923
|
runtime = args[1],
|
|
82465
82924
|
table = args[2];
|
|
@@ -82467,20 +82926,43 @@
|
|
|
82467
82926
|
if (3 === (null === (_c = eventArgs.event) || void 0 === _c ? void 0 : _c.which) || 2 === (null === (_d = eventArgs.event) || void 0 === _d ? void 0 : _d.button) || 2 == (2 & (null === (_e = eventArgs.event) || void 0 === _e ? void 0 : _e.buttons))) return;
|
|
82468
82927
|
const col = eventArgs.col,
|
|
82469
82928
|
row = eventArgs.row;
|
|
82470
|
-
this.filterToolbar.isVisible ? this.filterToolbar.hide(eventArgs.col, eventArgs.row) :
|
|
82471
|
-
col: eventArgs.col,
|
|
82472
|
-
row: eventArgs.row
|
|
82473
|
-
}));
|
|
82929
|
+
this.filterToolbar.isVisible ? this.filterToolbar.hide(eventArgs.col, eventArgs.row) : this.filterToolbar.show(col, row, this.pluginOptions.filterModes);
|
|
82474
82930
|
} else if (runtime === TABLE_EVENT_TYPE.SCROLL) "horizontal" === eventArgs.scrollDirection && this.filterToolbar.adjustMenuPosition();else if (runtime === TABLE_EVENT_TYPE.CHANGE_CELL_VALUE) {
|
|
82475
82931
|
const changedField = this.table.getHeaderField(eventArgs.col, eventArgs.row);
|
|
82476
82932
|
this.syncFilterWithTableData(changedField);
|
|
82477
|
-
} else (runtime === TABLE_EVENT_TYPE.UPDATE_RECORD
|
|
82933
|
+
} else if (runtime === TABLE_EVENT_TYPE.UPDATE_RECORD) this.syncFilterWithTableData();else if (runtime === TABLE_EVENT_TYPE.ADD_RECORD) {
|
|
82934
|
+
if ((null === (_g = null === (_f = this.filterStateManager) || void 0 === _f ? void 0 : _f.getActiveFilterFields) || void 0 === _g ? void 0 : _g.call(_f).length) > 0 && Array.isArray(null == eventArgs ? void 0 : eventArgs.records)) {
|
|
82935
|
+
const ds = this.table.dataSource;
|
|
82936
|
+
eventArgs.records.forEach(r => {
|
|
82937
|
+
var _a;
|
|
82938
|
+
return null === (_a = null == ds ? void 0 : ds.markForceVisibleRecord) || void 0 === _a ? void 0 : _a.call(ds, r);
|
|
82939
|
+
});
|
|
82940
|
+
}
|
|
82941
|
+
this.syncFilterWithTableData();
|
|
82942
|
+
} else if (runtime === TABLE_EVENT_TYPE.DELETE_RECORD) this.syncFilterWithTableData();else if (runtime === TABLE_EVENT_TYPE.ADD_COLUMN) {
|
|
82943
|
+
const columnIndex = null == eventArgs ? void 0 : eventArgs.columnIndex,
|
|
82944
|
+
columnCount = null == eventArgs ? void 0 : eventArgs.columnCount;
|
|
82945
|
+
"number" == typeof columnIndex && "number" == typeof columnCount && columnCount > 0 && (null === (_j = null === (_h = this.filterStateManager) || void 0 === _h ? void 0 : _h.shiftFieldsOnAddColumns) || void 0 === _j || _j.call(_h, columnIndex, columnCount)), this.reapplyActiveFilters();
|
|
82946
|
+
} else if (runtime === TABLE_EVENT_TYPE.DELETE_COLUMN) {
|
|
82947
|
+
const deleteColIndexs = null == eventArgs ? void 0 : eventArgs.deleteColIndexs;
|
|
82948
|
+
Array.isArray(deleteColIndexs) && deleteColIndexs.length > 0 && (null === (_l = null === (_k = this.filterStateManager) || void 0 === _k ? void 0 : _k.shiftFieldsOnDeleteColumns) || void 0 === _l || _l.call(_k, deleteColIndexs)), this.reapplyActiveFilters();
|
|
82949
|
+
}
|
|
82478
82950
|
}
|
|
82479
82951
|
updatePluginOptions(pluginOptions) {
|
|
82480
82952
|
this.pluginOptions = lodashExports.merge(this.pluginOptions, pluginOptions), this.filterToolbar.updateStyles(this.pluginOptions.styles), this.table.updateColumns(this.columns, {
|
|
82481
82953
|
clearRowHeightCache: !1
|
|
82482
82954
|
});
|
|
82483
82955
|
}
|
|
82956
|
+
getFilterSnapshot() {
|
|
82957
|
+
var _a, _b, _c;
|
|
82958
|
+
return null !== (_c = null === (_b = null === (_a = this.filterStateManager) || void 0 === _a ? void 0 : _a.getSnapshot) || void 0 === _b ? void 0 : _b.call(_a)) && void 0 !== _c ? _c : {
|
|
82959
|
+
filters: []
|
|
82960
|
+
};
|
|
82961
|
+
}
|
|
82962
|
+
applyFilterSnapshot(snapshot) {
|
|
82963
|
+
var _a, _b;
|
|
82964
|
+
null === (_b = null === (_a = this.filterStateManager) || void 0 === _a ? void 0 : _a.applySnapshot) || void 0 === _b || _b.call(_a, snapshot, FilterActionType.APPLY_FILTERS);
|
|
82965
|
+
}
|
|
82484
82966
|
update() {
|
|
82485
82967
|
this.filterStateManager && this.reapplyActiveFilters();
|
|
82486
82968
|
}
|
|
@@ -83592,10 +84074,10 @@
|
|
|
83592
84074
|
* console.log(deep[0] === objects[0]);
|
|
83593
84075
|
* // => false
|
|
83594
84076
|
*/
|
|
83595
|
-
function cloneDeep(value) {
|
|
84077
|
+
function cloneDeep$1(value) {
|
|
83596
84078
|
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
|
|
83597
84079
|
}
|
|
83598
|
-
var cloneDeep_1 = cloneDeep;
|
|
84080
|
+
var cloneDeep_1 = cloneDeep$1;
|
|
83599
84081
|
var deepClone = /*@__PURE__*/getDefaultExportFromCjs(cloneDeep_1);
|
|
83600
84082
|
|
|
83601
84083
|
const chnNumChar = {
|
|
@@ -84726,6 +85208,1200 @@
|
|
|
84726
85208
|
}
|
|
84727
85209
|
}
|
|
84728
85210
|
|
|
85211
|
+
function makeCellKey(sheetKey, row, col) {
|
|
85212
|
+
return `${sheetKey}:${row}:${col}`;
|
|
85213
|
+
}
|
|
85214
|
+
function parseA1Notation(a1) {
|
|
85215
|
+
const match = a1.match(/^([A-Z]+)([0-9]+)$/i);
|
|
85216
|
+
if (!match) return null;
|
|
85217
|
+
const letters = match[1].toUpperCase(),
|
|
85218
|
+
rowNumber = parseInt(match[2], 10);
|
|
85219
|
+
if (!rowNumber || rowNumber < 1) return null;
|
|
85220
|
+
let col = 0;
|
|
85221
|
+
for (let i = 0; i < letters.length; i++) col = 26 * col + (letters.charCodeAt(i) - 64);
|
|
85222
|
+
return {
|
|
85223
|
+
row: rowNumber - 1,
|
|
85224
|
+
col: col - 1
|
|
85225
|
+
};
|
|
85226
|
+
}
|
|
85227
|
+
function captureCellPreChangeContent(args) {
|
|
85228
|
+
const {
|
|
85229
|
+
sheetKey: sheetKey,
|
|
85230
|
+
row: row,
|
|
85231
|
+
col: col,
|
|
85232
|
+
currentValue: currentValue,
|
|
85233
|
+
formulaManager: formulaManager,
|
|
85234
|
+
store: store
|
|
85235
|
+
} = args;
|
|
85236
|
+
if (!sheetKey) return;
|
|
85237
|
+
const cellKey = makeCellKey(sheetKey, row, col);
|
|
85238
|
+
if (null == formulaManager ? void 0 : formulaManager.getCellFormula) try {
|
|
85239
|
+
const oldFormula = formulaManager.getCellFormula({
|
|
85240
|
+
sheet: sheetKey,
|
|
85241
|
+
row: row,
|
|
85242
|
+
col: col
|
|
85243
|
+
});
|
|
85244
|
+
if (oldFormula) {
|
|
85245
|
+
const normalized = "string" != typeof oldFormula || oldFormula.startsWith("=") ? oldFormula : `=${oldFormula}`;
|
|
85246
|
+
return void store.set(cellKey, normalized);
|
|
85247
|
+
}
|
|
85248
|
+
} catch (_a) {}
|
|
85249
|
+
store.set(cellKey, null == currentValue ? "" : currentValue);
|
|
85250
|
+
}
|
|
85251
|
+
function popCellPreChangeContent(args) {
|
|
85252
|
+
const {
|
|
85253
|
+
sheetKey: sheetKey,
|
|
85254
|
+
row: row,
|
|
85255
|
+
col: col,
|
|
85256
|
+
fallbackOldContent: fallbackOldContent,
|
|
85257
|
+
store: store
|
|
85258
|
+
} = args;
|
|
85259
|
+
if (!sheetKey) return fallbackOldContent;
|
|
85260
|
+
const cellKey = makeCellKey(sheetKey, row, col),
|
|
85261
|
+
oldContent = store.get(cellKey);
|
|
85262
|
+
return store.delete(cellKey), void 0 !== oldContent ? oldContent : fallbackOldContent;
|
|
85263
|
+
}
|
|
85264
|
+
function applyCellContent(args) {
|
|
85265
|
+
const {
|
|
85266
|
+
table: table,
|
|
85267
|
+
sheetKey: sheetKey,
|
|
85268
|
+
row: row,
|
|
85269
|
+
col: col,
|
|
85270
|
+
content: content,
|
|
85271
|
+
formulaManager: formulaManager
|
|
85272
|
+
} = args;
|
|
85273
|
+
if (sheetKey && (null == formulaManager ? void 0 : formulaManager.setCellContent) && (null == formulaManager ? void 0 : formulaManager.getCellValue)) {
|
|
85274
|
+
try {
|
|
85275
|
+
formulaManager.setCellContent({
|
|
85276
|
+
sheet: sheetKey,
|
|
85277
|
+
row: row,
|
|
85278
|
+
col: col
|
|
85279
|
+
}, content);
|
|
85280
|
+
} catch (_a) {
|
|
85281
|
+
return void table.changeCellValue(col, row, content, !1, !1, !0);
|
|
85282
|
+
}
|
|
85283
|
+
if ("string" == typeof content && content.startsWith("=")) {
|
|
85284
|
+
const result = formulaManager.getCellValue({
|
|
85285
|
+
sheet: sheetKey,
|
|
85286
|
+
row: row,
|
|
85287
|
+
col: col
|
|
85288
|
+
}),
|
|
85289
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
85290
|
+
return table.changeCellValue(col, row, display, !1, !1, !0), void refreshDependentDisplays({
|
|
85291
|
+
table: table,
|
|
85292
|
+
sheetKey: sheetKey,
|
|
85293
|
+
startCell: {
|
|
85294
|
+
sheet: sheetKey,
|
|
85295
|
+
row: row,
|
|
85296
|
+
col: col
|
|
85297
|
+
},
|
|
85298
|
+
formulaManager: formulaManager
|
|
85299
|
+
});
|
|
85300
|
+
}
|
|
85301
|
+
return table.changeCellValue(col, row, content, !1, !1, !0), void refreshDependentDisplays({
|
|
85302
|
+
table: table,
|
|
85303
|
+
sheetKey: sheetKey,
|
|
85304
|
+
startCell: {
|
|
85305
|
+
sheet: sheetKey,
|
|
85306
|
+
row: row,
|
|
85307
|
+
col: col
|
|
85308
|
+
},
|
|
85309
|
+
formulaManager: formulaManager
|
|
85310
|
+
});
|
|
85311
|
+
}
|
|
85312
|
+
table.changeCellValue(col, row, content, !1, !1, !0);
|
|
85313
|
+
}
|
|
85314
|
+
function refreshDependentDisplays(args) {
|
|
85315
|
+
var _a;
|
|
85316
|
+
const {
|
|
85317
|
+
table: table,
|
|
85318
|
+
sheetKey: sheetKey,
|
|
85319
|
+
startCell: startCell,
|
|
85320
|
+
formulaManager: formulaManager
|
|
85321
|
+
} = args,
|
|
85322
|
+
maxCells = null !== (_a = args.maxCells) && void 0 !== _a ? _a : 5e3;
|
|
85323
|
+
if (!(null == formulaManager ? void 0 : formulaManager.getCellDependents) || !(null == formulaManager ? void 0 : formulaManager.getCellValue)) return;
|
|
85324
|
+
const visited = new Set(),
|
|
85325
|
+
queue = [...(formulaManager.getCellDependents(startCell) || [])];
|
|
85326
|
+
let processed = 0;
|
|
85327
|
+
for (; queue.length;) {
|
|
85328
|
+
const cell = queue.shift();
|
|
85329
|
+
if (!cell || cell.sheet !== sheetKey) continue;
|
|
85330
|
+
const key = makeCellKey(cell.sheet, cell.row, cell.col);
|
|
85331
|
+
if (visited.has(key)) continue;
|
|
85332
|
+
if (visited.add(key), processed++, processed > maxCells) break;
|
|
85333
|
+
const result = formulaManager.getCellValue(cell),
|
|
85334
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
85335
|
+
table.changeCellValue(cell.col, cell.row, display, !1, !1, !0);
|
|
85336
|
+
(formulaManager.getCellDependents(cell) || []).forEach(d => queue.push(d));
|
|
85337
|
+
}
|
|
85338
|
+
}
|
|
85339
|
+
|
|
85340
|
+
function cloneMergeConfig(input) {
|
|
85341
|
+
return Array.isArray(input) ? input.map(i => Object.assign(Object.assign({}, i), {
|
|
85342
|
+
range: (null == i ? void 0 : i.range) ? {
|
|
85343
|
+
start: Object.assign({}, i.range.start),
|
|
85344
|
+
end: Object.assign({}, i.range.end)
|
|
85345
|
+
} : null == i ? void 0 : i.range
|
|
85346
|
+
})) : input;
|
|
85347
|
+
}
|
|
85348
|
+
function getCustomMergeCellFunc(customMergeCell) {
|
|
85349
|
+
return "function" == typeof customMergeCell ? customMergeCell : Array.isArray(customMergeCell) ? (col, row) => customMergeCell.find(item => item.range.start.col <= col && item.range.end.col >= col && item.range.start.row <= row && item.range.end.row >= row) : void 0;
|
|
85350
|
+
}
|
|
85351
|
+
function applyMergeConfig(table, customMergeCell) {
|
|
85352
|
+
(null == table ? void 0 : table.options) && (null == table ? void 0 : table.internalProps) && (table.options.customMergeCell = cloneMergeConfig(customMergeCell), table.internalProps.customMergeCell = getCustomMergeCellFunc(table.options.customMergeCell));
|
|
85353
|
+
}
|
|
85354
|
+
function cloneSortState(input) {
|
|
85355
|
+
return input ? Array.isArray(input) ? input.filter(Boolean).map(s => ({
|
|
85356
|
+
field: s.field,
|
|
85357
|
+
order: s.order
|
|
85358
|
+
})) : {
|
|
85359
|
+
field: input.field,
|
|
85360
|
+
order: input.order
|
|
85361
|
+
} : null;
|
|
85362
|
+
}
|
|
85363
|
+
function replayCommand(args) {
|
|
85364
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
|
|
85365
|
+
const {
|
|
85366
|
+
table: table,
|
|
85367
|
+
vtableSheet: vtableSheet,
|
|
85368
|
+
cmd: cmd,
|
|
85369
|
+
direction: direction,
|
|
85370
|
+
deleteRecordsByReference: deleteRecordsByReference
|
|
85371
|
+
} = args;
|
|
85372
|
+
switch (cmd.type) {
|
|
85373
|
+
case "cell":
|
|
85374
|
+
case "cells":
|
|
85375
|
+
{
|
|
85376
|
+
const sheetKey = cmd.sheetKey;
|
|
85377
|
+
cmd.cells.forEach(c => {
|
|
85378
|
+
const content = "undo" === direction ? c.oldContent : c.newContent;
|
|
85379
|
+
applyCellContent({
|
|
85380
|
+
table: table,
|
|
85381
|
+
sheetKey: sheetKey,
|
|
85382
|
+
row: c.row,
|
|
85383
|
+
col: c.col,
|
|
85384
|
+
content: content,
|
|
85385
|
+
formulaManager: null == vtableSheet ? void 0 : vtableSheet.formulaManager
|
|
85386
|
+
});
|
|
85387
|
+
});
|
|
85388
|
+
break;
|
|
85389
|
+
}
|
|
85390
|
+
case "merge_cells":
|
|
85391
|
+
{
|
|
85392
|
+
const c = cmd,
|
|
85393
|
+
next = "undo" === direction ? c.oldCustomMergeCell : c.newCustomMergeCell;
|
|
85394
|
+
applyMergeConfig(table, next);
|
|
85395
|
+
const sg = table.scenegraph;
|
|
85396
|
+
if (null == sg ? void 0 : sg.updateCellContent) {
|
|
85397
|
+
for (let i = c.startCol; i <= c.endCol; i++) for (let j = c.startRow; j <= c.endRow; j++) sg.updateCellContent(i, j);
|
|
85398
|
+
null === (_a = sg.updateNextFrame) || void 0 === _a || _a.call(sg);
|
|
85399
|
+
} else "function" == typeof table.renderWithRecreateCells && table.renderWithRecreateCells();
|
|
85400
|
+
break;
|
|
85401
|
+
}
|
|
85402
|
+
case "filter":
|
|
85403
|
+
{
|
|
85404
|
+
const c = cmd,
|
|
85405
|
+
pluginId = c.pluginId,
|
|
85406
|
+
snapshot = "undo" === direction ? c.oldSnapshot : c.newSnapshot,
|
|
85407
|
+
pm = table.pluginManager,
|
|
85408
|
+
filterPlugin = null !== (_g = null !== (_e = null !== (_c = null === (_b = null == pm ? void 0 : pm.getPlugin) || void 0 === _b ? void 0 : _b.call(pm, pluginId)) && void 0 !== _c ? _c : null === (_d = null == pm ? void 0 : pm.getPluginByName) || void 0 === _d ? void 0 : _d.call(pm, "Filter")) && void 0 !== _e ? _e : null === (_f = null == pm ? void 0 : pm.getPlugin) || void 0 === _f ? void 0 : _f.call(pm, "filter")) && void 0 !== _g ? _g : null === (_h = null == pm ? void 0 : pm.getPluginByName) || void 0 === _h ? void 0 : _h.call(pm, "filter");
|
|
85409
|
+
(null == filterPlugin ? void 0 : filterPlugin.applyFilterSnapshot) && filterPlugin.applyFilterSnapshot(snapshot);
|
|
85410
|
+
break;
|
|
85411
|
+
}
|
|
85412
|
+
case "sort":
|
|
85413
|
+
{
|
|
85414
|
+
const c = cmd,
|
|
85415
|
+
next = "undo" === direction ? c.oldSortState : c.newSortState;
|
|
85416
|
+
null === (_k = (_j = table).updateSortState) || void 0 === _k || _k.call(_j, null !== (_l = cloneSortState(next)) && void 0 !== _l ? _l : null, !0);
|
|
85417
|
+
break;
|
|
85418
|
+
}
|
|
85419
|
+
case "add_record":
|
|
85420
|
+
{
|
|
85421
|
+
const c = cmd;
|
|
85422
|
+
if ("undo" === direction) {
|
|
85423
|
+
const ds = null === (_m = null == table ? void 0 : table.internalProps) || void 0 === _m ? void 0 : _m.dataSource,
|
|
85424
|
+
rawRecords = null === (_o = null == ds ? void 0 : ds.dataSourceObj) || void 0 === _o ? void 0 : _o.records;
|
|
85425
|
+
let deletedByRaw = !1;
|
|
85426
|
+
if (Array.isArray(rawRecords) && "number" == typeof c.rawInsertIndex && c.recordCount > 0) {
|
|
85427
|
+
const idx = c.rawInsertIndex;
|
|
85428
|
+
idx >= 0 && idx < rawRecords.length && (rawRecords.splice(idx, c.recordCount), deletedByRaw = !0);
|
|
85429
|
+
}
|
|
85430
|
+
if (Array.isArray(rawRecords) && Array.isArray(c.records) && c.records.length) for (let i = 0; i < c.records.length; i++) {
|
|
85431
|
+
const rawIndex = rawRecords.indexOf(c.records[i]);
|
|
85432
|
+
rawIndex >= 0 && (rawRecords.splice(rawIndex, 1), deletedByRaw = !0);
|
|
85433
|
+
}
|
|
85434
|
+
if (!deletedByRaw && Array.isArray(rawRecords) && "number" == typeof c.recordCount && c.recordCount > 0) {
|
|
85435
|
+
const before = c.anchorBefore,
|
|
85436
|
+
after = c.anchorAfter,
|
|
85437
|
+
beforeIndex = before ? rawRecords.indexOf(before) : -1,
|
|
85438
|
+
afterIndex = after ? rawRecords.indexOf(after) : -1;
|
|
85439
|
+
beforeIndex >= 0 ? (rawRecords.splice(beforeIndex + 1, c.recordCount), deletedByRaw = !0) : afterIndex >= 0 && (rawRecords.splice(Math.max(0, afterIndex - c.recordCount), c.recordCount), deletedByRaw = !0);
|
|
85440
|
+
}
|
|
85441
|
+
if (deletedByRaw && (null === (_q = null === (_p = null == ds ? void 0 : ds.beforeChangedRecordsMap) || void 0 === _p ? void 0 : _p.clear) || void 0 === _q || _q.call(_p), null === (_s = null === (_r = null == ds ? void 0 : ds.sortedIndexMap) || void 0 === _r ? void 0 : _r.clear) || void 0 === _s || _s.call(_r), "function" == typeof table.updateFilterRules ? table.updateFilterRules(null === (_t = null == ds ? void 0 : ds.dataConfig) || void 0 === _t ? void 0 : _t.filterRules, {
|
|
85442
|
+
clearRowHeightCache: !1
|
|
85443
|
+
}) : null === (_u = null == ds ? void 0 : ds.updateFilterRules) || void 0 === _u || _u.call(ds, null === (_v = null == ds ? void 0 : ds.dataConfig) || void 0 === _v ? void 0 : _v.filterRules)), !deletedByRaw) if ("number" == typeof c.recordIndex && c.recordCount > 0) {
|
|
85444
|
+
const indexs = [];
|
|
85445
|
+
for (let i = 0; i < c.recordCount; i++) indexs.push(c.recordIndex + i);
|
|
85446
|
+
null === (_x = (_w = table).deleteRecords) || void 0 === _x || _x.call(_w, indexs);
|
|
85447
|
+
} else deleteRecordsByReference(c.records);
|
|
85448
|
+
} else c.records.length && (null === (_z = (_y = table).addRecords) || void 0 === _z || _z.call(_y, c.records, c.recordIndex));
|
|
85449
|
+
break;
|
|
85450
|
+
}
|
|
85451
|
+
case "delete_record":
|
|
85452
|
+
{
|
|
85453
|
+
const c = cmd;
|
|
85454
|
+
if ("undo" === direction) {
|
|
85455
|
+
if (table.addRecord && Array.isArray(c.records) && Array.isArray(c.recordIndexs)) {
|
|
85456
|
+
const pairs = [];
|
|
85457
|
+
for (let i = 0; i < c.recordIndexs.length; i++) {
|
|
85458
|
+
const idx = c.recordIndexs[i];
|
|
85459
|
+
"number" == typeof idx && pairs.push({
|
|
85460
|
+
idx: idx,
|
|
85461
|
+
record: c.records[i]
|
|
85462
|
+
});
|
|
85463
|
+
}
|
|
85464
|
+
pairs.sort((a, b) => a.idx - b.idx);
|
|
85465
|
+
for (const p of pairs) table.addRecord(p.record, p.idx);
|
|
85466
|
+
}
|
|
85467
|
+
if (c.deletedRowHeights && "function" == typeof table.setRowHeight) {
|
|
85468
|
+
const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
|
|
85469
|
+
Object.keys(c.deletedRowHeights).forEach(k => {
|
|
85470
|
+
const idx = Number(k),
|
|
85471
|
+
height = c.deletedRowHeights[k];
|
|
85472
|
+
Number.isFinite(idx) && "number" == typeof height && table.setRowHeight(idx + (null != headerCount ? headerCount : 0), height);
|
|
85473
|
+
});
|
|
85474
|
+
}
|
|
85475
|
+
} else table.deleteRecords && table.deleteRecords(c.recordIndexs);
|
|
85476
|
+
if ("oldCustomMergeCell" in c || "newCustomMergeCell" in c) {
|
|
85477
|
+
const target = "undo" === direction ? c.oldCustomMergeCell : c.newCustomMergeCell;
|
|
85478
|
+
applyMergeConfig(table, target);
|
|
85479
|
+
const sg = table.scenegraph;
|
|
85480
|
+
if (null == sg ? void 0 : sg.updateCellContent) {
|
|
85481
|
+
[...(Array.isArray(c.oldCustomMergeCell) ? c.oldCustomMergeCell.map(i => null == i ? void 0 : i.range).filter(Boolean) : []), ...(Array.isArray(c.newCustomMergeCell) ? c.newCustomMergeCell.map(i => null == i ? void 0 : i.range).filter(Boolean) : [])].forEach(r => {
|
|
85482
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) sg.updateCellContent(col, row);
|
|
85483
|
+
}), null === (_0 = sg.updateNextFrame) || void 0 === _0 || _0.call(sg);
|
|
85484
|
+
} else "function" == typeof table.renderWithRecreateCells && table.renderWithRecreateCells();
|
|
85485
|
+
}
|
|
85486
|
+
break;
|
|
85487
|
+
}
|
|
85488
|
+
case "update_record":
|
|
85489
|
+
{
|
|
85490
|
+
const c = cmd;
|
|
85491
|
+
table.updateRecords && ("undo" === direction ? table.updateRecords(c.oldRecords, c.recordIndexs) : table.updateRecords(c.newRecords, c.recordIndexs));
|
|
85492
|
+
break;
|
|
85493
|
+
}
|
|
85494
|
+
case "add_column":
|
|
85495
|
+
{
|
|
85496
|
+
const c = cmd;
|
|
85497
|
+
if ("undo" === direction) {
|
|
85498
|
+
const deleteIndexs = [];
|
|
85499
|
+
for (let i = 0; i < c.columnCount; i++) deleteIndexs.push(c.columnIndex + i);
|
|
85500
|
+
null === (_2 = (_1 = table).deleteColumns) || void 0 === _2 || _2.call(_1, deleteIndexs, !0);
|
|
85501
|
+
} else null === (_4 = (_3 = table).addColumns) || void 0 === _4 || _4.call(_3, c.columns, c.columnIndex, !0);
|
|
85502
|
+
break;
|
|
85503
|
+
}
|
|
85504
|
+
case "delete_column":
|
|
85505
|
+
{
|
|
85506
|
+
const c = cmd;
|
|
85507
|
+
if ("undo" === direction) {
|
|
85508
|
+
if (c.deleteColIndexs.map((idx, i) => ({
|
|
85509
|
+
idx: idx,
|
|
85510
|
+
column: c.columns[i]
|
|
85511
|
+
})).sort((a, b) => a.idx - b.idx).forEach(item => {
|
|
85512
|
+
var _a, _b;
|
|
85513
|
+
null === (_b = (_a = table).addColumns) || void 0 === _b || _b.call(_a, [item.column], item.idx, !0);
|
|
85514
|
+
}), c.deletedColWidths && "function" == typeof table.setColWidth && Object.entries(c.deletedColWidths).forEach(([k, width]) => {
|
|
85515
|
+
const idx = Number(k);
|
|
85516
|
+
Number.isFinite(idx) && "number" == typeof width && table.setColWidth(idx, width);
|
|
85517
|
+
}), Array.isArray(c.deletedRecordValues) && c.deletedRecordValues.length) {
|
|
85518
|
+
const records = table.records;
|
|
85519
|
+
if (Array.isArray(records) && records.length) {
|
|
85520
|
+
const recordIndexs = [],
|
|
85521
|
+
newRecords = [];
|
|
85522
|
+
for (let i = 0; i < records.length; i++) {
|
|
85523
|
+
const rec = records[i],
|
|
85524
|
+
rowValues = c.deletedRecordValues[i];
|
|
85525
|
+
if (!Array.isArray(rec) || !Array.isArray(rowValues) || rowValues.length !== c.deleteColIndexs.length) continue;
|
|
85526
|
+
const next = rec.slice();
|
|
85527
|
+
for (let k = 0; k < c.deleteColIndexs.length; k++) next[c.deleteColIndexs[k]] = rowValues[k];
|
|
85528
|
+
recordIndexs.push(i), newRecords.push(next);
|
|
85529
|
+
}
|
|
85530
|
+
recordIndexs.length && (null === (_6 = (_5 = table).updateRecords) || void 0 === _6 || _6.call(_5, newRecords, recordIndexs, !1));
|
|
85531
|
+
}
|
|
85532
|
+
}
|
|
85533
|
+
if (c.sheetKey) {
|
|
85534
|
+
const fm = null == vtableSheet ? void 0 : vtableSheet.formulaManager,
|
|
85535
|
+
engine = null == fm ? void 0 : fm.formulaEngine;
|
|
85536
|
+
if ((null == fm ? void 0 : fm.normalizeSheetData) && (null == engine ? void 0 : engine.updateSheetData)) try {
|
|
85537
|
+
const normalized = fm.normalizeSheetData(table.records || [], table);
|
|
85538
|
+
engine.updateSheetData(c.sheetKey, normalized);
|
|
85539
|
+
} catch (_17) {}
|
|
85540
|
+
}
|
|
85541
|
+
if (c.sheetKey && c.deletedFormulas) {
|
|
85542
|
+
Object.entries(c.deletedFormulas).forEach(([cellRef, formula]) => {
|
|
85543
|
+
const parsed = parseA1Notation(cellRef);
|
|
85544
|
+
parsed && applyCellContent({
|
|
85545
|
+
table: table,
|
|
85546
|
+
sheetKey: c.sheetKey,
|
|
85547
|
+
row: parsed.row,
|
|
85548
|
+
col: parsed.col,
|
|
85549
|
+
content: formula,
|
|
85550
|
+
formulaManager: null == vtableSheet ? void 0 : vtableSheet.formulaManager
|
|
85551
|
+
});
|
|
85552
|
+
});
|
|
85553
|
+
}
|
|
85554
|
+
} else null === (_8 = (_7 = table).deleteColumns) || void 0 === _8 || _8.call(_7, c.deleteColIndexs, !0);
|
|
85555
|
+
break;
|
|
85556
|
+
}
|
|
85557
|
+
case "change_header_position":
|
|
85558
|
+
{
|
|
85559
|
+
const c = cmd,
|
|
85560
|
+
moving = c.moving,
|
|
85561
|
+
from = "undo" === direction ? c.targetIndex : c.sourceIndex,
|
|
85562
|
+
to = "undo" === direction ? c.sourceIndex : c.targetIndex;
|
|
85563
|
+
"column" === moving ? null === (_10 = (_9 = table).changeHeaderPosition) || void 0 === _10 || _10.call(_9, {
|
|
85564
|
+
source: {
|
|
85565
|
+
col: from,
|
|
85566
|
+
row: 0
|
|
85567
|
+
},
|
|
85568
|
+
target: {
|
|
85569
|
+
col: to,
|
|
85570
|
+
row: 0
|
|
85571
|
+
},
|
|
85572
|
+
movingColumnOrRow: "column"
|
|
85573
|
+
}) : null === (_12 = (_11 = table).changeHeaderPosition) || void 0 === _12 || _12.call(_11, {
|
|
85574
|
+
source: {
|
|
85575
|
+
col: 0,
|
|
85576
|
+
row: from
|
|
85577
|
+
},
|
|
85578
|
+
target: {
|
|
85579
|
+
col: 0,
|
|
85580
|
+
row: to
|
|
85581
|
+
},
|
|
85582
|
+
movingColumnOrRow: "row"
|
|
85583
|
+
});
|
|
85584
|
+
break;
|
|
85585
|
+
}
|
|
85586
|
+
case "resize_row":
|
|
85587
|
+
{
|
|
85588
|
+
const c = cmd,
|
|
85589
|
+
height = "undo" === direction ? c.oldHeight : c.newHeight;
|
|
85590
|
+
null === (_14 = (_13 = table).setRowHeight) || void 0 === _14 || _14.call(_13, c.row, height);
|
|
85591
|
+
break;
|
|
85592
|
+
}
|
|
85593
|
+
case "resize_column":
|
|
85594
|
+
{
|
|
85595
|
+
const c = cmd,
|
|
85596
|
+
width = "undo" === direction ? c.oldWidth : c.newWidth;
|
|
85597
|
+
null === (_16 = (_15 = table).setColWidth) || void 0 === _16 || _16.call(_15, c.col, width);
|
|
85598
|
+
break;
|
|
85599
|
+
}
|
|
85600
|
+
}
|
|
85601
|
+
}
|
|
85602
|
+
|
|
85603
|
+
function cloneDeep(input, cache = new WeakMap()) {
|
|
85604
|
+
if (null == input) return input;
|
|
85605
|
+
const t = typeof input;
|
|
85606
|
+
if ("function" === t || "object" !== t) return input;
|
|
85607
|
+
const obj = input;
|
|
85608
|
+
if (obj instanceof Date) return new Date(obj.getTime());
|
|
85609
|
+
if (obj instanceof RegExp) return new RegExp(obj);
|
|
85610
|
+
if (cache.has(obj)) return cache.get(obj);
|
|
85611
|
+
if (Array.isArray(obj)) {
|
|
85612
|
+
const arr = [];
|
|
85613
|
+
cache.set(obj, arr);
|
|
85614
|
+
for (let i = 0; i < obj.length; i++) arr[i] = cloneDeep(obj[i], cache);
|
|
85615
|
+
return arr;
|
|
85616
|
+
}
|
|
85617
|
+
const out = {};
|
|
85618
|
+
return cache.set(obj, out), Object.keys(obj).forEach(key => {
|
|
85619
|
+
out[key] = cloneDeep(obj[key], cache);
|
|
85620
|
+
}), out;
|
|
85621
|
+
}
|
|
85622
|
+
function captureSnapshot(table, state, options) {
|
|
85623
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85624
|
+
const tableOptions = table.options || {},
|
|
85625
|
+
columns = tableOptions.columns;
|
|
85626
|
+
Array.isArray(columns) ? state.prevColumnsSnapshot = columns.map(c => cloneDeep(c)) : state.prevColumnsSnapshot = null;
|
|
85627
|
+
const merge = tableOptions.customMergeCell;
|
|
85628
|
+
Array.isArray(merge) ? state.prevMergeSnapshot = merge.map(m => Object.assign(Object.assign({}, m), {
|
|
85629
|
+
range: {
|
|
85630
|
+
start: Object.assign({}, m.range.start),
|
|
85631
|
+
end: Object.assign({}, m.range.end)
|
|
85632
|
+
}
|
|
85633
|
+
})) : state.prevMergeSnapshot = merge;
|
|
85634
|
+
const records = table.records || [];
|
|
85635
|
+
Array.isArray(records) ? state.prevRecordsSnapshot = records.map(r => cloneRecord(r)) : state.prevRecordsSnapshot = null;
|
|
85636
|
+
try {
|
|
85637
|
+
const resizedRowIndexs = Array.from(null !== (_d = null === (_c = null === (_b = null === (_a = table.internalProps) || void 0 === _a ? void 0 : _a._heightResizedRowMap) || void 0 === _b ? void 0 : _b.keys) || void 0 === _c ? void 0 : _c.call(_b)) && void 0 !== _d ? _d : []);
|
|
85638
|
+
if (resizedRowIndexs.length && "function" == typeof table.getRowHeight) {
|
|
85639
|
+
const map = {};
|
|
85640
|
+
resizedRowIndexs.forEach(rowIndex => {
|
|
85641
|
+
if ("number" != typeof rowIndex) return;
|
|
85642
|
+
const h = table.getRowHeight(rowIndex);
|
|
85643
|
+
"number" == typeof h && (map[rowIndex] = h);
|
|
85644
|
+
}), state.prevResizedRowHeightsSnapshot = map;
|
|
85645
|
+
} else state.prevResizedRowHeightsSnapshot = null;
|
|
85646
|
+
} catch (_k) {
|
|
85647
|
+
state.prevResizedRowHeightsSnapshot = null;
|
|
85648
|
+
}
|
|
85649
|
+
try {
|
|
85650
|
+
const resizedColIndexs = Array.from(null !== (_h = null === (_g = null === (_f = null === (_e = table.internalProps) || void 0 === _e ? void 0 : _e._widthResizedColMap) || void 0 === _f ? void 0 : _f.keys) || void 0 === _g ? void 0 : _g.call(_f)) && void 0 !== _h ? _h : []);
|
|
85651
|
+
if (resizedColIndexs.length && "function" == typeof table.getColWidth) {
|
|
85652
|
+
const map = {};
|
|
85653
|
+
resizedColIndexs.forEach(colIndex => {
|
|
85654
|
+
if ("number" != typeof colIndex) return;
|
|
85655
|
+
const w = table.getColWidth(colIndex);
|
|
85656
|
+
"number" == typeof w && (map[colIndex] = w);
|
|
85657
|
+
}), state.prevResizedColWidthsSnapshot = map;
|
|
85658
|
+
} else state.prevResizedColWidthsSnapshot = null;
|
|
85659
|
+
} catch (_l) {
|
|
85660
|
+
state.prevResizedColWidthsSnapshot = null;
|
|
85661
|
+
}
|
|
85662
|
+
if ((null === (_j = null == options ? void 0 : options.formulaManager) || void 0 === _j ? void 0 : _j.exportFormulas) && options.sheetKey) try {
|
|
85663
|
+
const formulas = options.formulaManager.exportFormulas(options.sheetKey);
|
|
85664
|
+
state.prevFormulasSnapshot = formulas ? Object.assign({}, formulas) : null;
|
|
85665
|
+
} catch (_m) {
|
|
85666
|
+
state.prevFormulasSnapshot = null;
|
|
85667
|
+
} else state.prevFormulasSnapshot = null;
|
|
85668
|
+
}
|
|
85669
|
+
function cloneRecord(record) {
|
|
85670
|
+
return Array.isArray(record) ? record.slice() : record && "object" == typeof record ? Object.assign({}, record) : record;
|
|
85671
|
+
}
|
|
85672
|
+
|
|
85673
|
+
function resolveSheetKey(args) {
|
|
85674
|
+
var _a, _b, _c;
|
|
85675
|
+
const {
|
|
85676
|
+
vtableSheet: vtableSheet,
|
|
85677
|
+
table: table,
|
|
85678
|
+
cached: cached
|
|
85679
|
+
} = args;
|
|
85680
|
+
if (!vtableSheet) return {
|
|
85681
|
+
sheetKey: void 0,
|
|
85682
|
+
cached: void 0
|
|
85683
|
+
};
|
|
85684
|
+
if (cached) return {
|
|
85685
|
+
sheetKey: cached,
|
|
85686
|
+
cached: cached
|
|
85687
|
+
};
|
|
85688
|
+
try {
|
|
85689
|
+
const workSheetInstances = vtableSheet.workSheetInstances;
|
|
85690
|
+
if (workSheetInstances && table) for (const [sheetKey, worksheet] of workSheetInstances.entries()) if ((null == worksheet ? void 0 : worksheet.tableInstance) === table) return {
|
|
85691
|
+
sheetKey: sheetKey,
|
|
85692
|
+
cached: sheetKey
|
|
85693
|
+
};
|
|
85694
|
+
const active = null === (_a = vtableSheet.getActiveSheet) || void 0 === _a ? void 0 : _a.call(vtableSheet);
|
|
85695
|
+
if (null == active ? void 0 : active.getKey) {
|
|
85696
|
+
const key = active.getKey();
|
|
85697
|
+
return {
|
|
85698
|
+
sheetKey: key,
|
|
85699
|
+
cached: key
|
|
85700
|
+
};
|
|
85701
|
+
}
|
|
85702
|
+
const activeDefine = null === (_c = null === (_b = vtableSheet.sheetManager) || void 0 === _b ? void 0 : _b.getActiveSheet) || void 0 === _c ? void 0 : _c.call(_b),
|
|
85703
|
+
key = null == activeDefine ? void 0 : activeDefine.sheetKey;
|
|
85704
|
+
return {
|
|
85705
|
+
sheetKey: key,
|
|
85706
|
+
cached: key
|
|
85707
|
+
};
|
|
85708
|
+
} catch (_d) {
|
|
85709
|
+
return {
|
|
85710
|
+
sheetKey: void 0,
|
|
85711
|
+
cached: void 0
|
|
85712
|
+
};
|
|
85713
|
+
}
|
|
85714
|
+
}
|
|
85715
|
+
|
|
85716
|
+
class HistoryPlugin {
|
|
85717
|
+
constructor(options) {
|
|
85718
|
+
var _a, _b, _c;
|
|
85719
|
+
this.id = "history-plugin", this.name = "History", this.runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.INITIALIZED, TABLE_EVENT_TYPE.BEFORE_KEYDOWN, TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, TABLE_EVENT_TYPE.PASTED_DATA, TABLE_EVENT_TYPE.MERGE_CELLS, TABLE_EVENT_TYPE.UNMERGE_CELLS, TABLE_EVENT_TYPE.ADD_RECORD, TABLE_EVENT_TYPE.DELETE_RECORD, TABLE_EVENT_TYPE.UPDATE_RECORD, TABLE_EVENT_TYPE.ADD_COLUMN, TABLE_EVENT_TYPE.DELETE_COLUMN, TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION, TABLE_EVENT_TYPE.SORT_CLICK, TABLE_EVENT_TYPE.RESIZE_ROW, TABLE_EVENT_TYPE.RESIZE_ROW_END, TABLE_EVENT_TYPE.RESIZE_COLUMN, TABLE_EVENT_TYPE.RESIZE_COLUMN_END], this.table = null, this.undoStack = [], this.redoStack = [], this.currentTransaction = null, this.isReplaying = !1, this.prevColumnsSnapshot = null, this.prevRecordsSnapshot = null, this.prevFormulasSnapshot = null, this.prevResizedRowHeightsSnapshot = null, this.prevResizedColWidthsSnapshot = null, this.lastKnownSortState = null, this.sortStartSnapshot = null, this.sortPending = !1, this.sortEventBound = !1, this.cellPreChangeContent = new Map(), this.formulaCache = new Map(), this.formulaEventBound = !1, this.resizeRowStartHeight = new Map(), this.resizeColStartWidth = new Map(), this.filterEventBound = !1, this.filterUnsubscribe = null, this.filterApplyingSnapshot = !1, this.id = null !== (_a = null == options ? void 0 : options.id) && void 0 !== _a ? _a : this.id, this.maxHistory = null !== (_b = null == options ? void 0 : options.maxHistory) && void 0 !== _b ? _b : 100, this.enableCompression = null !== (_c = null == options ? void 0 : options.enableCompression) && void 0 !== _c && _c, this.onTransactionPushed = null == options ? void 0 : options.onTransactionPushed;
|
|
85720
|
+
}
|
|
85721
|
+
run(...args) {
|
|
85722
|
+
var _a, _b, _c, _d, _e, _f;
|
|
85723
|
+
const eventArgs = args[0],
|
|
85724
|
+
runtime = args[1],
|
|
85725
|
+
table = args[2];
|
|
85726
|
+
if (!table) return;
|
|
85727
|
+
if (this.table) this.vtableSheet || (this.vtableSheet = table.__vtableSheet);else if (this.table = table, this.vtableSheet = table.__vtableSheet, runtime !== TABLE_EVENT_TYPE.BEFORE_INIT && (null === (_a = table.internalProps) || void 0 === _a ? void 0 : _a.dataSource)) {
|
|
85728
|
+
const state = this.getSnapshotState(),
|
|
85729
|
+
sheetKey = this.getSheetKey();
|
|
85730
|
+
captureSnapshot(table, state, {
|
|
85731
|
+
formulaManager: null === (_b = this.vtableSheet) || void 0 === _b ? void 0 : _b.formulaManager,
|
|
85732
|
+
sheetKey: sheetKey
|
|
85733
|
+
}), this.setSnapshotState(state), this.lastKnownSortState = this.normalizeSortState(null === (_c = table.internalProps) || void 0 === _c ? void 0 : _c.sortState);
|
|
85734
|
+
}
|
|
85735
|
+
if (this.ensureFilterEventBindings(), runtime === TABLE_EVENT_TYPE.BEFORE_INIT) return;
|
|
85736
|
+
this.ensureFormulaEventBindings(), this.ensureSortEventBindings();
|
|
85737
|
+
const workbookReplaying = null === (_e = null === (_d = this.table) || void 0 === _d ? void 0 : _d.__vtableSheet) || void 0 === _e ? void 0 : _e.__workbookHistoryReplaying;
|
|
85738
|
+
if (!this.isReplaying && !workbookReplaying) {
|
|
85739
|
+
switch (runtime) {
|
|
85740
|
+
case TABLE_EVENT_TYPE.INITIALIZED:
|
|
85741
|
+
break;
|
|
85742
|
+
case TABLE_EVENT_TYPE.BEFORE_KEYDOWN:
|
|
85743
|
+
this.handleBeforeKeydown(eventArgs);
|
|
85744
|
+
break;
|
|
85745
|
+
case TABLE_EVENT_TYPE.CHANGE_CELL_VALUE:
|
|
85746
|
+
this.handleChangeCellValue(eventArgs);
|
|
85747
|
+
break;
|
|
85748
|
+
case TABLE_EVENT_TYPE.CHANGE_CELL_VALUES:
|
|
85749
|
+
this.handleChangeCellValues(eventArgs);
|
|
85750
|
+
break;
|
|
85751
|
+
case TABLE_EVENT_TYPE.PASTED_DATA:
|
|
85752
|
+
break;
|
|
85753
|
+
case TABLE_EVENT_TYPE.MERGE_CELLS:
|
|
85754
|
+
this.handleMergeCells(eventArgs);
|
|
85755
|
+
break;
|
|
85756
|
+
case TABLE_EVENT_TYPE.UNMERGE_CELLS:
|
|
85757
|
+
this.handleUnmergeCells(eventArgs);
|
|
85758
|
+
break;
|
|
85759
|
+
case TABLE_EVENT_TYPE.ADD_RECORD:
|
|
85760
|
+
this.handleAddRecord(eventArgs);
|
|
85761
|
+
break;
|
|
85762
|
+
case TABLE_EVENT_TYPE.DELETE_RECORD:
|
|
85763
|
+
this.handleDeleteRecord(eventArgs);
|
|
85764
|
+
break;
|
|
85765
|
+
case TABLE_EVENT_TYPE.UPDATE_RECORD:
|
|
85766
|
+
this.handleUpdateRecord(eventArgs);
|
|
85767
|
+
break;
|
|
85768
|
+
case TABLE_EVENT_TYPE.ADD_COLUMN:
|
|
85769
|
+
this.handleAddColumn(eventArgs);
|
|
85770
|
+
break;
|
|
85771
|
+
case TABLE_EVENT_TYPE.DELETE_COLUMN:
|
|
85772
|
+
this.handleDeleteColumn(eventArgs);
|
|
85773
|
+
break;
|
|
85774
|
+
case TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION:
|
|
85775
|
+
this.handleChangeHeaderPosition(eventArgs);
|
|
85776
|
+
break;
|
|
85777
|
+
case TABLE_EVENT_TYPE.SORT_CLICK:
|
|
85778
|
+
this.handleSortClick(eventArgs);
|
|
85779
|
+
break;
|
|
85780
|
+
case TABLE_EVENT_TYPE.RESIZE_ROW:
|
|
85781
|
+
this.handleResizeRow(eventArgs);
|
|
85782
|
+
break;
|
|
85783
|
+
case TABLE_EVENT_TYPE.RESIZE_ROW_END:
|
|
85784
|
+
this.handleResizeRowEnd(eventArgs);
|
|
85785
|
+
break;
|
|
85786
|
+
case TABLE_EVENT_TYPE.RESIZE_COLUMN:
|
|
85787
|
+
this.handleResizeColumn(eventArgs);
|
|
85788
|
+
break;
|
|
85789
|
+
case TABLE_EVENT_TYPE.RESIZE_COLUMN_END:
|
|
85790
|
+
this.handleResizeColumnEnd(eventArgs);
|
|
85791
|
+
}
|
|
85792
|
+
if (this.table) {
|
|
85793
|
+
const state = this.getSnapshotState(),
|
|
85794
|
+
sheetKey = this.getSheetKey();
|
|
85795
|
+
captureSnapshot(this.table, state, {
|
|
85796
|
+
formulaManager: null === (_f = this.vtableSheet) || void 0 === _f ? void 0 : _f.formulaManager,
|
|
85797
|
+
sheetKey: sheetKey
|
|
85798
|
+
}), this.setSnapshotState(state);
|
|
85799
|
+
}
|
|
85800
|
+
}
|
|
85801
|
+
}
|
|
85802
|
+
startTransaction() {
|
|
85803
|
+
this.currentTransaction || (this.currentTransaction = {
|
|
85804
|
+
commands: []
|
|
85805
|
+
});
|
|
85806
|
+
}
|
|
85807
|
+
endTransaction() {
|
|
85808
|
+
this.currentTransaction && 0 !== this.currentTransaction.commands.length ? (this.pushTransaction(this.currentTransaction), this.currentTransaction = null) : this.currentTransaction = null;
|
|
85809
|
+
}
|
|
85810
|
+
undo() {
|
|
85811
|
+
var _a;
|
|
85812
|
+
if (!this.table || 0 === this.undoStack.length) return;
|
|
85813
|
+
const transaction = this.undoStack.pop();
|
|
85814
|
+
this.isReplaying = !0;
|
|
85815
|
+
try {
|
|
85816
|
+
for (let i = transaction.commands.length - 1; i >= 0; i--) this.applyCommand(transaction.commands[i], "undo");
|
|
85817
|
+
} finally {
|
|
85818
|
+
this.isReplaying = !1;
|
|
85819
|
+
}
|
|
85820
|
+
if (this.redoStack.push(transaction), this.table) {
|
|
85821
|
+
const state = this.getSnapshotState(),
|
|
85822
|
+
sheetKey = this.getSheetKey();
|
|
85823
|
+
captureSnapshot(this.table, state, {
|
|
85824
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85825
|
+
sheetKey: sheetKey
|
|
85826
|
+
}), this.setSnapshotState(state);
|
|
85827
|
+
}
|
|
85828
|
+
}
|
|
85829
|
+
redo() {
|
|
85830
|
+
var _a;
|
|
85831
|
+
if (!this.table || 0 === this.redoStack.length) return;
|
|
85832
|
+
const transaction = this.redoStack.pop();
|
|
85833
|
+
this.isReplaying = !0;
|
|
85834
|
+
try {
|
|
85835
|
+
for (const cmd of transaction.commands) this.applyCommand(cmd, "redo");
|
|
85836
|
+
} finally {
|
|
85837
|
+
this.isReplaying = !1;
|
|
85838
|
+
}
|
|
85839
|
+
if (this.undoStack.push(transaction), this.table) {
|
|
85840
|
+
const state = this.getSnapshotState(),
|
|
85841
|
+
sheetKey = this.getSheetKey();
|
|
85842
|
+
captureSnapshot(this.table, state, {
|
|
85843
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85844
|
+
sheetKey: sheetKey
|
|
85845
|
+
}), this.setSnapshotState(state);
|
|
85846
|
+
}
|
|
85847
|
+
}
|
|
85848
|
+
clear() {
|
|
85849
|
+
this.undoStack = [], this.redoStack = [], this.currentTransaction = null;
|
|
85850
|
+
}
|
|
85851
|
+
updateOptions(options) {
|
|
85852
|
+
null != options.maxHistory && (this.maxHistory = options.maxHistory, this.trimHistory()), null != options.enableCompression && (this.enableCompression = options.enableCompression), options.onTransactionPushed && (this.onTransactionPushed = options.onTransactionPushed);
|
|
85853
|
+
}
|
|
85854
|
+
release() {
|
|
85855
|
+
this.clear(), this.unbindFormulaEvents(), this.unbindSortEvents(), this.unbindFilterEvents(), this.table = null, this.vtableSheet = null, this.resolvedSheetKey = void 0, this.prevColumnsSnapshot = null, this.prevMergeSnapshot = void 0, this.prevRecordsSnapshot = null, this.prevFormulasSnapshot = null, this.prevResizedRowHeightsSnapshot = null, this.prevResizedColWidthsSnapshot = null, this.lastKnownSortState = null, this.sortStartSnapshot = null, this.sortPending = !1, this.sortEventBound = !1, this.sortChangeOrderListenerId = void 0, this.cellPreChangeContent.clear(), this.formulaCache.clear(), this.resizeRowStartHeight.clear(), this.resizeColStartWidth.clear(), this.filterEventBound = !1, this.filterUnsubscribe = null, this.filterSnapshotCache = void 0, this.filterPluginId = void 0;
|
|
85856
|
+
}
|
|
85857
|
+
ensureFilterEventBindings() {
|
|
85858
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85859
|
+
if (!this.table) return;
|
|
85860
|
+
const pm = this.table.pluginManager,
|
|
85861
|
+
filterPlugin = null !== (_f = null !== (_d = null !== (_b = null === (_a = null == pm ? void 0 : pm.getPlugin) || void 0 === _a ? void 0 : _a.call(pm, "filter")) && void 0 !== _b ? _b : null === (_c = null == pm ? void 0 : pm.getPluginByName) || void 0 === _c ? void 0 : _c.call(pm, "Filter")) && void 0 !== _d ? _d : null === (_e = null == pm ? void 0 : pm.getPlugin) || void 0 === _e ? void 0 : _e.call(pm, "filter-plugin")) && void 0 !== _f ? _f : null === (_g = null == pm ? void 0 : pm.getPluginByName) || void 0 === _g ? void 0 : _g.call(pm, "filter-plugin");
|
|
85862
|
+
if (!(null == filterPlugin ? void 0 : filterPlugin.getFilterSnapshot) || !(null == filterPlugin ? void 0 : filterPlugin.applyFilterSnapshot)) return;
|
|
85863
|
+
this.filterEventBound || (this.filterEventBound = !0, this.filterPluginRef = filterPlugin, this.filterPluginId = null !== (_h = filterPlugin.id) && void 0 !== _h ? _h : "filter", this.filterSnapshotCache = cloneDeep(filterPlugin.getFilterSnapshot())), this.filterApplySnapshotOriginal || (this.filterApplySnapshotOriginal = null === (_j = filterPlugin.applyFilterSnapshot) || void 0 === _j ? void 0 : _j.bind(filterPlugin), this.filterApplySnapshotOriginal && (filterPlugin.applyFilterSnapshot = snapshot => {
|
|
85864
|
+
var _a, _b;
|
|
85865
|
+
if (this.isReplaying) return this.filterApplySnapshotOriginal(snapshot);
|
|
85866
|
+
const oldSnapshot = null !== (_a = this.filterSnapshotCache) && void 0 !== _a ? _a : filterPlugin.getFilterSnapshot();
|
|
85867
|
+
this.filterApplyingSnapshot = !0;
|
|
85868
|
+
try {
|
|
85869
|
+
return this.filterApplySnapshotOriginal(snapshot);
|
|
85870
|
+
} finally {
|
|
85871
|
+
this.filterApplyingSnapshot = !1;
|
|
85872
|
+
const newSnapshot = filterPlugin.getFilterSnapshot();
|
|
85873
|
+
if (JSON.stringify(oldSnapshot) !== JSON.stringify(newSnapshot)) {
|
|
85874
|
+
const cmd = {
|
|
85875
|
+
type: "filter",
|
|
85876
|
+
sheetKey: this.getSheetKey(),
|
|
85877
|
+
pluginId: null !== (_b = this.filterPluginId) && void 0 !== _b ? _b : "filter",
|
|
85878
|
+
oldSnapshot: oldSnapshot,
|
|
85879
|
+
newSnapshot: newSnapshot
|
|
85880
|
+
};
|
|
85881
|
+
this.pushCommand(cmd), this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85882
|
+
} else this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85883
|
+
}
|
|
85884
|
+
}));
|
|
85885
|
+
const stateManager = null == filterPlugin ? void 0 : filterPlugin.filterStateManager;
|
|
85886
|
+
!this.filterUnsubscribe && (null == stateManager ? void 0 : stateManager.subscribe) && (this.filterUnsubscribe = stateManager.subscribe((_state, action) => {
|
|
85887
|
+
var _a, _b;
|
|
85888
|
+
if (this.isReplaying) return;
|
|
85889
|
+
if (this.filterApplyingSnapshot) return void (this.filterSnapshotCache = cloneDeep(filterPlugin.getFilterSnapshot()));
|
|
85890
|
+
const t = null == action ? void 0 : action.type;
|
|
85891
|
+
if (t !== FilterActionType.APPLY_FILTERS && t !== FilterActionType.CLEAR_ALL_FILTERS && t !== FilterActionType.REMOVE_FILTER && t !== FilterActionType.DISABLE_FILTER) return;
|
|
85892
|
+
const oldSnapshot = null !== (_a = this.filterSnapshotCache) && void 0 !== _a ? _a : filterPlugin.getFilterSnapshot(),
|
|
85893
|
+
newSnapshot = filterPlugin.getFilterSnapshot();
|
|
85894
|
+
if (JSON.stringify(oldSnapshot) === JSON.stringify(newSnapshot)) return;
|
|
85895
|
+
const cmd = {
|
|
85896
|
+
type: "filter",
|
|
85897
|
+
sheetKey: this.getSheetKey(),
|
|
85898
|
+
pluginId: null !== (_b = this.filterPluginId) && void 0 !== _b ? _b : "filter",
|
|
85899
|
+
oldSnapshot: oldSnapshot,
|
|
85900
|
+
newSnapshot: newSnapshot
|
|
85901
|
+
};
|
|
85902
|
+
this.pushCommand(cmd), this.filterSnapshotCache = cloneDeep(newSnapshot);
|
|
85903
|
+
}));
|
|
85904
|
+
}
|
|
85905
|
+
unbindFilterEvents() {
|
|
85906
|
+
var _a;
|
|
85907
|
+
null === (_a = this.filterUnsubscribe) || void 0 === _a || _a.call(this), this.filterUnsubscribe = null, this.filterEventBound = !1, this.filterPluginRef && this.filterApplySnapshotOriginal && (this.filterPluginRef.applyFilterSnapshot = this.filterApplySnapshotOriginal), this.filterPluginRef = null, this.filterApplySnapshotOriginal = null, this.filterApplyingSnapshot = !1;
|
|
85908
|
+
}
|
|
85909
|
+
getSheetKey() {
|
|
85910
|
+
const resolved = resolveSheetKey({
|
|
85911
|
+
vtableSheet: this.vtableSheet,
|
|
85912
|
+
table: this.table,
|
|
85913
|
+
cached: this.resolvedSheetKey
|
|
85914
|
+
});
|
|
85915
|
+
return this.resolvedSheetKey = resolved.cached, resolved.sheetKey;
|
|
85916
|
+
}
|
|
85917
|
+
getSnapshotState() {
|
|
85918
|
+
return {
|
|
85919
|
+
prevColumnsSnapshot: this.prevColumnsSnapshot,
|
|
85920
|
+
prevMergeSnapshot: this.prevMergeSnapshot,
|
|
85921
|
+
prevRecordsSnapshot: this.prevRecordsSnapshot,
|
|
85922
|
+
prevFormulasSnapshot: this.prevFormulasSnapshot,
|
|
85923
|
+
prevResizedRowHeightsSnapshot: this.prevResizedRowHeightsSnapshot,
|
|
85924
|
+
prevResizedColWidthsSnapshot: this.prevResizedColWidthsSnapshot
|
|
85925
|
+
};
|
|
85926
|
+
}
|
|
85927
|
+
setSnapshotState(next) {
|
|
85928
|
+
var _a, _b, _c;
|
|
85929
|
+
this.prevColumnsSnapshot = next.prevColumnsSnapshot, this.prevMergeSnapshot = next.prevMergeSnapshot, this.prevRecordsSnapshot = next.prevRecordsSnapshot, this.prevFormulasSnapshot = null !== (_a = next.prevFormulasSnapshot) && void 0 !== _a ? _a : null, this.prevResizedRowHeightsSnapshot = null !== (_b = next.prevResizedRowHeightsSnapshot) && void 0 !== _b ? _b : null, this.prevResizedColWidthsSnapshot = null !== (_c = next.prevResizedColWidthsSnapshot) && void 0 !== _c ? _c : null;
|
|
85930
|
+
}
|
|
85931
|
+
pushTransaction(tx) {
|
|
85932
|
+
var _a, _b, _c;
|
|
85933
|
+
if (0 !== tx.commands.length && (this.undoStack.push(tx), this.redoStack = [], this.trimHistory(), this.onTransactionPushed && !this.isReplaying)) {
|
|
85934
|
+
(null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.__vtableSheet) || void 0 === _b ? void 0 : _b.__workbookHistoryReplaying) || this.onTransactionPushed({
|
|
85935
|
+
tx: tx,
|
|
85936
|
+
sheetKey: this.getSheetKey(),
|
|
85937
|
+
table: null !== (_c = this.table) && void 0 !== _c ? _c : void 0
|
|
85938
|
+
});
|
|
85939
|
+
}
|
|
85940
|
+
}
|
|
85941
|
+
trimHistory() {
|
|
85942
|
+
this.undoStack.length > this.maxHistory && this.undoStack.splice(0, this.undoStack.length - this.maxHistory);
|
|
85943
|
+
}
|
|
85944
|
+
pushCommand(cmd) {
|
|
85945
|
+
this.currentTransaction ? this.currentTransaction.commands.push(cmd) : this.pushTransaction({
|
|
85946
|
+
commands: [cmd]
|
|
85947
|
+
});
|
|
85948
|
+
}
|
|
85949
|
+
recordExternalCommand(cmd) {
|
|
85950
|
+
this.isReplaying || this.pushCommand(cmd);
|
|
85951
|
+
}
|
|
85952
|
+
tryCompressCellChange(change, sheetKey) {
|
|
85953
|
+
if (!this.enableCompression) return !1;
|
|
85954
|
+
const targetTx = this.currentTransaction || this.undoStack[this.undoStack.length - 1];
|
|
85955
|
+
if (!targetTx || 0 === targetTx.commands.length) return !1;
|
|
85956
|
+
const last = targetTx.commands[targetTx.commands.length - 1];
|
|
85957
|
+
if (("cell" === last.type || "cells" === last.type) && last.sheetKey === sheetKey) {
|
|
85958
|
+
const cells = last.cells;
|
|
85959
|
+
if (1 === cells.length && cells[0].row === change.row && cells[0].col === change.col) return cells[0].newContent = change.newContent, !0;
|
|
85960
|
+
}
|
|
85961
|
+
return !1;
|
|
85962
|
+
}
|
|
85963
|
+
handleBeforeKeydown(eventArgs) {
|
|
85964
|
+
var _a, _b, _c, _d, _e, _f;
|
|
85965
|
+
const e = eventArgs.event;
|
|
85966
|
+
if (!e || !this.table) return;
|
|
85967
|
+
if (!(e.ctrlKey || e.metaKey)) return;
|
|
85968
|
+
const formulaManager = null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager;
|
|
85969
|
+
if (null == formulaManager ? void 0 : formulaManager.formulaWorkingOnCell) return;
|
|
85970
|
+
if (null === (_b = this.table.editorManager) || void 0 === _b ? void 0 : _b.editingEditor) return;
|
|
85971
|
+
const key = e.key.toLowerCase();
|
|
85972
|
+
if ("z" === key) {
|
|
85973
|
+
const workbookHistory = null === (_d = null === (_c = this.vtableSheet) || void 0 === _c ? void 0 : _c.getWorkbookHistoryManager) || void 0 === _d ? void 0 : _d.call(_c);
|
|
85974
|
+
e.shiftKey ? workbookHistory ? workbookHistory.redo() : this.redo() : workbookHistory ? workbookHistory.undo() : this.undo(), e.preventDefault(), e.stopPropagation();
|
|
85975
|
+
} else if ("y" === key) {
|
|
85976
|
+
const workbookHistory = null === (_f = null === (_e = this.vtableSheet) || void 0 === _e ? void 0 : _e.getWorkbookHistoryManager) || void 0 === _f ? void 0 : _f.call(_e);
|
|
85977
|
+
workbookHistory ? workbookHistory.redo() : this.redo(), e.preventDefault(), e.stopPropagation();
|
|
85978
|
+
}
|
|
85979
|
+
}
|
|
85980
|
+
handleChangeCellValue(eventArgs) {
|
|
85981
|
+
var _a;
|
|
85982
|
+
captureCellPreChangeContent({
|
|
85983
|
+
sheetKey: this.getSheetKey(),
|
|
85984
|
+
row: eventArgs.row,
|
|
85985
|
+
col: eventArgs.col,
|
|
85986
|
+
currentValue: eventArgs.currentValue,
|
|
85987
|
+
formulaManager: null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85988
|
+
store: this.cellPreChangeContent
|
|
85989
|
+
});
|
|
85990
|
+
}
|
|
85991
|
+
handleChangeCellValues(eventArgs) {
|
|
85992
|
+
var _a;
|
|
85993
|
+
if (!this.table) return;
|
|
85994
|
+
const sheetKey = this.getSheetKey(),
|
|
85995
|
+
formulaManager = null === (_a = this.vtableSheet) || void 0 === _a ? void 0 : _a.formulaManager,
|
|
85996
|
+
cells = eventArgs.values.map(v => {
|
|
85997
|
+
const oldContent = popCellPreChangeContent({
|
|
85998
|
+
sheetKey: sheetKey,
|
|
85999
|
+
row: v.row,
|
|
86000
|
+
col: v.col,
|
|
86001
|
+
fallbackOldContent: v.currentValue,
|
|
86002
|
+
store: this.cellPreChangeContent
|
|
86003
|
+
}),
|
|
86004
|
+
normalizedOld = null == oldContent ? "" : oldContent,
|
|
86005
|
+
normalizedNew = null == v.changedValue ? "" : v.changedValue;
|
|
86006
|
+
return {
|
|
86007
|
+
row: v.row,
|
|
86008
|
+
col: v.col,
|
|
86009
|
+
oldContent: normalizedOld,
|
|
86010
|
+
newContent: normalizedNew
|
|
86011
|
+
};
|
|
86012
|
+
}).filter(c => {
|
|
86013
|
+
if (c.oldContent === c.newContent) return !1;
|
|
86014
|
+
if (!sheetKey || !(null == formulaManager ? void 0 : formulaManager.getCellFormula) || !(null == formulaManager ? void 0 : formulaManager.getCellValue)) return !0;
|
|
86015
|
+
if ("string" == typeof c.newContent && c.newContent.startsWith("=")) return !1;
|
|
86016
|
+
if (!formulaManager.getCellFormula({
|
|
86017
|
+
sheet: sheetKey,
|
|
86018
|
+
row: c.row,
|
|
86019
|
+
col: c.col
|
|
86020
|
+
})) return !0;
|
|
86021
|
+
const result = formulaManager.getCellValue({
|
|
86022
|
+
sheet: sheetKey,
|
|
86023
|
+
row: c.row,
|
|
86024
|
+
col: c.col
|
|
86025
|
+
}),
|
|
86026
|
+
display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
86027
|
+
return display !== c.newContent && (null == display || null == c.newContent || String(display) !== String(c.newContent));
|
|
86028
|
+
});
|
|
86029
|
+
if (!cells.length) return;
|
|
86030
|
+
if (sheetKey && 1 === cells.length && this.tryCompressCellChange(cells[0], sheetKey)) return;
|
|
86031
|
+
const cmd = {
|
|
86032
|
+
type: "cells",
|
|
86033
|
+
sheetKey: sheetKey,
|
|
86034
|
+
cells: cells
|
|
86035
|
+
};
|
|
86036
|
+
this.pushCommand(cmd);
|
|
86037
|
+
}
|
|
86038
|
+
ensureFormulaEventBindings() {
|
|
86039
|
+
var _a, _b, _c, _d, _e;
|
|
86040
|
+
if (!this.table || !this.vtableSheet || this.formulaEventBound) return;
|
|
86041
|
+
const sheetKey = this.getSheetKey();
|
|
86042
|
+
if (!sheetKey) return;
|
|
86043
|
+
const worksheet = null !== (_c = null === (_b = (_a = this.vtableSheet).getWorkSheetByKey) || void 0 === _b ? void 0 : _b.call(_a, sheetKey)) && void 0 !== _c ? _c : null === (_e = null === (_d = this.vtableSheet.workSheetInstances) || void 0 === _d ? void 0 : _d.get) || void 0 === _e ? void 0 : _e.call(_d, sheetKey),
|
|
86044
|
+
eventManager = null == worksheet ? void 0 : worksheet.eventManager;
|
|
86045
|
+
(null == eventManager ? void 0 : eventManager.on) && (null == eventManager ? void 0 : eventManager.off) && (this.formulaEventBound = !0, this.formulaEventManager = eventManager, this.onFormulaAddedHandler = event => {
|
|
86046
|
+
if (this.isReplaying) return;
|
|
86047
|
+
const cell = null == event ? void 0 : event.cell,
|
|
86048
|
+
formula = null == event ? void 0 : event.formula;
|
|
86049
|
+
if (!cell || "number" != typeof cell.row || "number" != typeof cell.col) return;
|
|
86050
|
+
if ("string" != typeof formula || !formula.length) return;
|
|
86051
|
+
const normalized = formula.startsWith("=") ? formula : `=${formula}`,
|
|
86052
|
+
key = `${sheetKey}:${cell.row}:${cell.col}`,
|
|
86053
|
+
prev = this.formulaCache.get(key),
|
|
86054
|
+
oldContent = popCellPreChangeContent({
|
|
86055
|
+
sheetKey: sheetKey,
|
|
86056
|
+
row: cell.row,
|
|
86057
|
+
col: cell.col,
|
|
86058
|
+
fallbackOldContent: void 0 !== prev ? prev : "",
|
|
86059
|
+
store: this.cellPreChangeContent
|
|
86060
|
+
});
|
|
86061
|
+
if (oldContent === normalized) return void this.formulaCache.set(key, normalized);
|
|
86062
|
+
const cmd = {
|
|
86063
|
+
type: "cells",
|
|
86064
|
+
sheetKey: sheetKey,
|
|
86065
|
+
cells: [{
|
|
86066
|
+
row: cell.row,
|
|
86067
|
+
col: cell.col,
|
|
86068
|
+
oldContent: oldContent,
|
|
86069
|
+
newContent: normalized
|
|
86070
|
+
}]
|
|
86071
|
+
};
|
|
86072
|
+
this.pushCommand(cmd), this.formulaCache.set(key, normalized);
|
|
86073
|
+
}, eventManager.on("formula_added", this.onFormulaAddedHandler));
|
|
86074
|
+
}
|
|
86075
|
+
ensureSortEventBindings() {
|
|
86076
|
+
var _a;
|
|
86077
|
+
if (!this.table || this.sortEventBound) return;
|
|
86078
|
+
const ds = null === (_a = this.table.internalProps) || void 0 === _a ? void 0 : _a.dataSource;
|
|
86079
|
+
(null == ds ? void 0 : ds.on) && (null == ds ? void 0 : ds.off) && (this.sortEventBound = !0, this.sortChangeOrderListenerId = ds.on("change_order", () => {
|
|
86080
|
+
var _a;
|
|
86081
|
+
if (this.isReplaying || !this.table || !this.sortPending) return;
|
|
86082
|
+
const sheetKey = this.getSheetKey(),
|
|
86083
|
+
oldSortState = this.sortStartSnapshot;
|
|
86084
|
+
this.sortStartSnapshot = null, this.sortPending = !1;
|
|
86085
|
+
const newSortState = this.normalizeSortState(null === (_a = this.table.internalProps) || void 0 === _a ? void 0 : _a.sortState);
|
|
86086
|
+
if (JSON.stringify(oldSortState) === JSON.stringify(newSortState)) return void (this.lastKnownSortState = newSortState);
|
|
86087
|
+
const cmd = {
|
|
86088
|
+
type: "sort",
|
|
86089
|
+
sheetKey: sheetKey,
|
|
86090
|
+
oldSortState: oldSortState,
|
|
86091
|
+
newSortState: newSortState
|
|
86092
|
+
};
|
|
86093
|
+
this.pushCommand(cmd), this.lastKnownSortState = newSortState;
|
|
86094
|
+
}));
|
|
86095
|
+
}
|
|
86096
|
+
unbindSortEvents() {
|
|
86097
|
+
var _a, _b;
|
|
86098
|
+
if (!this.sortEventBound) return;
|
|
86099
|
+
const ds = null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.internalProps) || void 0 === _b ? void 0 : _b.dataSource;
|
|
86100
|
+
try {
|
|
86101
|
+
(null == ds ? void 0 : ds.off) && this.sortChangeOrderListenerId && ds.off(this.sortChangeOrderListenerId);
|
|
86102
|
+
} catch (_c) {} finally {
|
|
86103
|
+
this.sortEventBound = !1, this.sortChangeOrderListenerId = void 0, this.sortPending = !1, this.sortStartSnapshot = null;
|
|
86104
|
+
}
|
|
86105
|
+
}
|
|
86106
|
+
unbindFormulaEvents() {
|
|
86107
|
+
if (this.formulaEventBound && this.formulaEventManager) try {
|
|
86108
|
+
this.onFormulaAddedHandler && this.formulaEventManager.off("formula_added", this.onFormulaAddedHandler);
|
|
86109
|
+
} catch (_a) {} finally {
|
|
86110
|
+
this.formulaEventBound = !1, this.formulaEventManager = void 0, this.onFormulaAddedHandler = void 0;
|
|
86111
|
+
}
|
|
86112
|
+
}
|
|
86113
|
+
cloneMergeConfig(input) {
|
|
86114
|
+
return Array.isArray(input) ? input.map(i => cloneDeep(i)) : input;
|
|
86115
|
+
}
|
|
86116
|
+
isSameMergeConfig(a, b) {
|
|
86117
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
86118
|
+
const normalize = v => null == v ? [] : (v),
|
|
86119
|
+
aa = normalize(a),
|
|
86120
|
+
bb = normalize(b);
|
|
86121
|
+
if (aa === bb) return !0;
|
|
86122
|
+
if (Array.isArray(aa) && Array.isArray(bb)) {
|
|
86123
|
+
if (aa.length !== bb.length) return !1;
|
|
86124
|
+
for (let i = 0; i < aa.length; i++) {
|
|
86125
|
+
const ra = null === (_a = aa[i]) || void 0 === _a ? void 0 : _a.range,
|
|
86126
|
+
rb = null === (_b = bb[i]) || void 0 === _b ? void 0 : _b.range;
|
|
86127
|
+
if (!ra || !rb || (null === (_c = ra.start) || void 0 === _c ? void 0 : _c.col) !== (null === (_d = rb.start) || void 0 === _d ? void 0 : _d.col) || (null === (_e = ra.start) || void 0 === _e ? void 0 : _e.row) !== (null === (_f = rb.start) || void 0 === _f ? void 0 : _f.row) || (null === (_g = ra.end) || void 0 === _g ? void 0 : _g.col) !== (null === (_h = rb.end) || void 0 === _h ? void 0 : _h.col) || (null === (_j = ra.end) || void 0 === _j ? void 0 : _j.row) !== (null === (_k = rb.end) || void 0 === _k ? void 0 : _k.row) || (null === (_l = aa[i]) || void 0 === _l ? void 0 : _l.text) !== (null === (_m = bb[i]) || void 0 === _m ? void 0 : _m.text)) return !1;
|
|
86128
|
+
}
|
|
86129
|
+
return !0;
|
|
86130
|
+
}
|
|
86131
|
+
return !1;
|
|
86132
|
+
}
|
|
86133
|
+
handleMergeCells(eventArgs) {
|
|
86134
|
+
this.handleMergeConfigChanged(eventArgs);
|
|
86135
|
+
}
|
|
86136
|
+
handleUnmergeCells(eventArgs) {
|
|
86137
|
+
this.handleMergeConfigChanged(eventArgs);
|
|
86138
|
+
}
|
|
86139
|
+
handleMergeConfigChanged(eventArgs) {
|
|
86140
|
+
var _a;
|
|
86141
|
+
if (!this.table) return;
|
|
86142
|
+
const {
|
|
86143
|
+
startCol: startCol,
|
|
86144
|
+
startRow: startRow,
|
|
86145
|
+
endCol: endCol,
|
|
86146
|
+
endRow: endRow
|
|
86147
|
+
} = eventArgs,
|
|
86148
|
+
before = this.cloneMergeConfig(this.prevMergeSnapshot),
|
|
86149
|
+
after = this.cloneMergeConfig(null === (_a = this.table.options) || void 0 === _a ? void 0 : _a.customMergeCell);
|
|
86150
|
+
if (this.isSameMergeConfig(before, after)) return;
|
|
86151
|
+
const cmd = {
|
|
86152
|
+
type: "merge_cells",
|
|
86153
|
+
sheetKey: this.getSheetKey(),
|
|
86154
|
+
startCol: startCol,
|
|
86155
|
+
startRow: startRow,
|
|
86156
|
+
endCol: endCol,
|
|
86157
|
+
endRow: endRow,
|
|
86158
|
+
oldCustomMergeCell: before,
|
|
86159
|
+
newCustomMergeCell: after
|
|
86160
|
+
};
|
|
86161
|
+
this.pushCommand(cmd);
|
|
86162
|
+
}
|
|
86163
|
+
handleAddRecord(eventArgs) {
|
|
86164
|
+
var _a, _b, _c, _d;
|
|
86165
|
+
const cmd = {
|
|
86166
|
+
type: "add_record",
|
|
86167
|
+
sheetKey: this.getSheetKey(),
|
|
86168
|
+
records: Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [],
|
|
86169
|
+
recordIndex: eventArgs.recordIndex,
|
|
86170
|
+
recordCount: null !== (_a = eventArgs.recordCount) && void 0 !== _a ? _a : Array.isArray(eventArgs.records) ? eventArgs.records.length : 0
|
|
86171
|
+
};
|
|
86172
|
+
if (this.table && "number" == typeof eventArgs.recordIndex) {
|
|
86173
|
+
const start = eventArgs.recordIndex,
|
|
86174
|
+
count = cmd.recordCount,
|
|
86175
|
+
ds = null === (_c = null === (_b = this.table) || void 0 === _b ? void 0 : _b.internalProps) || void 0 === _c ? void 0 : _c.dataSource,
|
|
86176
|
+
rawRecords = null === (_d = null == ds ? void 0 : ds.dataSourceObj) || void 0 === _d ? void 0 : _d.records,
|
|
86177
|
+
viewRecords = this.table.records;
|
|
86178
|
+
if (Array.isArray(viewRecords) && viewRecords.length && (cmd.anchorBefore = start > 0 ? viewRecords[start - 1] : void 0, cmd.anchorAfter = viewRecords[start + count]), Array.isArray(rawRecords) && Array.isArray(viewRecords)) {
|
|
86179
|
+
let rawInsertIndex = rawRecords.length;
|
|
86180
|
+
if (0 === viewRecords.length) rawInsertIndex = rawRecords.length;else if (start <= 0) {
|
|
86181
|
+
const first = viewRecords[0],
|
|
86182
|
+
idx = rawRecords.indexOf(first);
|
|
86183
|
+
rawInsertIndex = idx >= 0 ? idx : 0;
|
|
86184
|
+
} else if (start >= viewRecords.length) {
|
|
86185
|
+
const last = viewRecords[viewRecords.length - 1],
|
|
86186
|
+
idx = rawRecords.indexOf(last);
|
|
86187
|
+
rawInsertIndex = idx >= 0 ? idx + 1 : rawRecords.length;
|
|
86188
|
+
} else {
|
|
86189
|
+
const prev = viewRecords[start - 1],
|
|
86190
|
+
idx = rawRecords.indexOf(prev);
|
|
86191
|
+
rawInsertIndex = idx >= 0 ? idx + 1 : rawRecords.length;
|
|
86192
|
+
}
|
|
86193
|
+
cmd.rawInsertIndex = rawInsertIndex;
|
|
86194
|
+
}
|
|
86195
|
+
}
|
|
86196
|
+
this.pushCommand(cmd);
|
|
86197
|
+
}
|
|
86198
|
+
handleDeleteRecord(eventArgs) {
|
|
86199
|
+
var _a, _b;
|
|
86200
|
+
const sheetKey = this.getSheetKey(),
|
|
86201
|
+
recordIndexs = Array.isArray(eventArgs.recordIndexs) ? eventArgs.recordIndexs.slice() : [eventArgs.recordIndexs];
|
|
86202
|
+
let deletedRowHeights;
|
|
86203
|
+
if (this.table && this.prevResizedRowHeightsSnapshot) {
|
|
86204
|
+
const headerCount = this.table.transpose ? this.table.rowHeaderLevelCount : this.table.columnHeaderLevelCount;
|
|
86205
|
+
recordIndexs.forEach(idx => {
|
|
86206
|
+
var _a;
|
|
86207
|
+
if ("number" != typeof idx) return;
|
|
86208
|
+
const rowIndex = idx + (null != headerCount ? headerCount : 0),
|
|
86209
|
+
height = null === (_a = this.prevResizedRowHeightsSnapshot) || void 0 === _a ? void 0 : _a[rowIndex];
|
|
86210
|
+
"number" == typeof height && (deletedRowHeights || (deletedRowHeights = {}), deletedRowHeights[idx] = height);
|
|
86211
|
+
});
|
|
86212
|
+
}
|
|
86213
|
+
const oldCustomMergeCell = this.cloneMergeConfig(this.prevMergeSnapshot),
|
|
86214
|
+
newCustomMergeCell = this.cloneMergeConfig(null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.customMergeCell),
|
|
86215
|
+
cmd = {
|
|
86216
|
+
type: "delete_record",
|
|
86217
|
+
sheetKey: sheetKey,
|
|
86218
|
+
records: Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [],
|
|
86219
|
+
recordIndexs: recordIndexs,
|
|
86220
|
+
deletedRowHeights: deletedRowHeights,
|
|
86221
|
+
oldCustomMergeCell: oldCustomMergeCell,
|
|
86222
|
+
newCustomMergeCell: newCustomMergeCell
|
|
86223
|
+
};
|
|
86224
|
+
this.pushCommand(cmd);
|
|
86225
|
+
}
|
|
86226
|
+
handleUpdateRecord(eventArgs) {
|
|
86227
|
+
if (!this.table) return;
|
|
86228
|
+
const sheetKey = this.getSheetKey(),
|
|
86229
|
+
recordIndexs = eventArgs.recordIndexs || [],
|
|
86230
|
+
newRecords = Array.isArray(eventArgs.records) ? eventArgs.records.slice() : [];
|
|
86231
|
+
if (!this.prevRecordsSnapshot || !Array.isArray(this.prevRecordsSnapshot) || !recordIndexs.length) return;
|
|
86232
|
+
const oldRecords = [];
|
|
86233
|
+
recordIndexs.forEach(idx => {
|
|
86234
|
+
if ("number" == typeof idx) {
|
|
86235
|
+
const rec = this.prevRecordsSnapshot[idx];
|
|
86236
|
+
oldRecords.push(void 0 !== rec ? cloneRecord(rec) : void 0);
|
|
86237
|
+
} else oldRecords.push(void 0);
|
|
86238
|
+
});
|
|
86239
|
+
const cmd = {
|
|
86240
|
+
type: "update_record",
|
|
86241
|
+
sheetKey: sheetKey,
|
|
86242
|
+
oldRecords: oldRecords,
|
|
86243
|
+
newRecords: newRecords,
|
|
86244
|
+
recordIndexs: recordIndexs
|
|
86245
|
+
};
|
|
86246
|
+
this.pushCommand(cmd);
|
|
86247
|
+
}
|
|
86248
|
+
handleAddColumn(eventArgs) {
|
|
86249
|
+
if (!this.table) return;
|
|
86250
|
+
const sheetKey = this.getSheetKey(),
|
|
86251
|
+
{
|
|
86252
|
+
columnIndex: columnIndex,
|
|
86253
|
+
columnCount: columnCount,
|
|
86254
|
+
columns: columns
|
|
86255
|
+
} = eventArgs,
|
|
86256
|
+
cmd = {
|
|
86257
|
+
type: "add_column",
|
|
86258
|
+
sheetKey: sheetKey,
|
|
86259
|
+
columnIndex: columnIndex,
|
|
86260
|
+
columnCount: columnCount,
|
|
86261
|
+
columns: columns.slice(columnIndex, columnIndex + columnCount).map(c => cloneDeep(c))
|
|
86262
|
+
};
|
|
86263
|
+
this.pushCommand(cmd);
|
|
86264
|
+
}
|
|
86265
|
+
handleDeleteColumn(eventArgs) {
|
|
86266
|
+
if (!this.table) return;
|
|
86267
|
+
const sheetKey = this.getSheetKey(),
|
|
86268
|
+
deleteColIndexs = (eventArgs.deleteColIndexs || []).slice(),
|
|
86269
|
+
deletedColumnsFromEvent = eventArgs.deletedColumns,
|
|
86270
|
+
prevColumns = this.prevColumnsSnapshot || [],
|
|
86271
|
+
deletedColumns = Array.isArray(deletedColumnsFromEvent) ? deletedColumnsFromEvent.map(c => cloneDeep(c)) : [];
|
|
86272
|
+
deletedColumns.length || deleteColIndexs.forEach(idx => {
|
|
86273
|
+
idx >= 0 && idx < prevColumns.length && deletedColumns.push(cloneDeep(prevColumns[idx]));
|
|
86274
|
+
});
|
|
86275
|
+
let deletedFormulas,
|
|
86276
|
+
deletedColWidths,
|
|
86277
|
+
deletedRecordValues = eventArgs.deletedRecordValues;
|
|
86278
|
+
if (Array.isArray(deletedRecordValues) && deletedRecordValues.length || (deletedRecordValues = void 0, Array.isArray(this.prevRecordsSnapshot) && this.prevRecordsSnapshot.length && (deletedRecordValues = this.prevRecordsSnapshot.map(rec => Array.isArray(rec) ? deleteColIndexs.map(idx => rec[idx]) : []), deletedRecordValues.every(v => 0 === v.length) && (deletedRecordValues = void 0))), this.prevFormulasSnapshot && deleteColIndexs.length) {
|
|
86279
|
+
Object.entries(this.prevFormulasSnapshot).forEach(([cellRef, formula]) => {
|
|
86280
|
+
const parsed = parseA1Notation(cellRef);
|
|
86281
|
+
parsed && deleteColIndexs.includes(parsed.col) && (deletedFormulas || (deletedFormulas = {}), deletedFormulas[cellRef] = formula);
|
|
86282
|
+
});
|
|
86283
|
+
}
|
|
86284
|
+
this.prevResizedColWidthsSnapshot && deleteColIndexs.length && deleteColIndexs.forEach(idx => {
|
|
86285
|
+
var _a;
|
|
86286
|
+
const w = null === (_a = this.prevResizedColWidthsSnapshot) || void 0 === _a ? void 0 : _a[idx];
|
|
86287
|
+
"number" == typeof w && (deletedColWidths || (deletedColWidths = {}), deletedColWidths[idx] = w);
|
|
86288
|
+
});
|
|
86289
|
+
const cmd = {
|
|
86290
|
+
type: "delete_column",
|
|
86291
|
+
sheetKey: sheetKey,
|
|
86292
|
+
deleteColIndexs: deleteColIndexs,
|
|
86293
|
+
columns: deletedColumns,
|
|
86294
|
+
deletedRecordValues: deletedRecordValues,
|
|
86295
|
+
deletedFormulas: deletedFormulas,
|
|
86296
|
+
deletedColWidths: deletedColWidths
|
|
86297
|
+
};
|
|
86298
|
+
this.pushCommand(cmd);
|
|
86299
|
+
}
|
|
86300
|
+
handleChangeHeaderPosition(eventArgs) {
|
|
86301
|
+
var _a;
|
|
86302
|
+
const sheetKey = this.getSheetKey(),
|
|
86303
|
+
moving = null !== (_a = eventArgs.movingColumnOrRow) && void 0 !== _a ? _a : "column",
|
|
86304
|
+
cmd = {
|
|
86305
|
+
type: "change_header_position",
|
|
86306
|
+
sheetKey: sheetKey,
|
|
86307
|
+
moving: moving,
|
|
86308
|
+
sourceIndex: "column" === moving ? eventArgs.source.col : eventArgs.source.row,
|
|
86309
|
+
targetIndex: "column" === moving ? eventArgs.target.col : eventArgs.target.row
|
|
86310
|
+
};
|
|
86311
|
+
this.pushCommand(cmd);
|
|
86312
|
+
}
|
|
86313
|
+
normalizeSortState(input) {
|
|
86314
|
+
if (!input) return null;
|
|
86315
|
+
if (Array.isArray(input)) {
|
|
86316
|
+
const list = input.filter(Boolean).map(s => ({
|
|
86317
|
+
field: s.field,
|
|
86318
|
+
order: s.order
|
|
86319
|
+
})).filter(s => void 0 !== s.field && s.order && "normal" !== s.order);
|
|
86320
|
+
return list.length ? list : null;
|
|
86321
|
+
}
|
|
86322
|
+
const s = input;
|
|
86323
|
+
return void 0 !== s.field && s.order && "normal" !== s.order ? {
|
|
86324
|
+
field: s.field,
|
|
86325
|
+
order: s.order
|
|
86326
|
+
} : null;
|
|
86327
|
+
}
|
|
86328
|
+
handleSortClick(_eventArgs) {
|
|
86329
|
+
this.table && (this.sortStartSnapshot = this.lastKnownSortState, this.sortPending = !0, setTimeout(() => {
|
|
86330
|
+
this.sortPending && (this.sortPending = !1, this.sortStartSnapshot = null);
|
|
86331
|
+
}, 0));
|
|
86332
|
+
}
|
|
86333
|
+
handleResizeRow(eventArgs) {
|
|
86334
|
+
var _a, _b;
|
|
86335
|
+
if (!this.table) return;
|
|
86336
|
+
const row = eventArgs.row;
|
|
86337
|
+
if (!this.resizeRowStartHeight.has(row)) {
|
|
86338
|
+
const oldHeight = null === (_b = (_a = this.table).getRowHeight) || void 0 === _b ? void 0 : _b.call(_a, row);
|
|
86339
|
+
"number" == typeof oldHeight && this.resizeRowStartHeight.set(row, oldHeight);
|
|
86340
|
+
}
|
|
86341
|
+
}
|
|
86342
|
+
handleResizeRowEnd(eventArgs) {
|
|
86343
|
+
var _a;
|
|
86344
|
+
if (!this.table) return;
|
|
86345
|
+
const sheetKey = this.getSheetKey(),
|
|
86346
|
+
row = eventArgs.row,
|
|
86347
|
+
newHeight = eventArgs.rowHeight,
|
|
86348
|
+
oldHeight = null !== (_a = this.resizeRowStartHeight.get(row)) && void 0 !== _a ? _a : newHeight;
|
|
86349
|
+
if (this.resizeRowStartHeight.delete(row), "number" == typeof oldHeight && "number" == typeof newHeight && oldHeight === newHeight) return;
|
|
86350
|
+
const cmd = {
|
|
86351
|
+
type: "resize_row",
|
|
86352
|
+
sheetKey: sheetKey,
|
|
86353
|
+
row: row,
|
|
86354
|
+
oldHeight: oldHeight,
|
|
86355
|
+
newHeight: newHeight
|
|
86356
|
+
};
|
|
86357
|
+
this.pushCommand(cmd);
|
|
86358
|
+
}
|
|
86359
|
+
handleResizeColumn(eventArgs) {
|
|
86360
|
+
var _a, _b;
|
|
86361
|
+
if (!this.table) return;
|
|
86362
|
+
const col = eventArgs.col;
|
|
86363
|
+
if (!this.resizeColStartWidth.has(col)) {
|
|
86364
|
+
const oldWidth = null === (_b = (_a = this.table).getColWidth) || void 0 === _b ? void 0 : _b.call(_a, col);
|
|
86365
|
+
"number" == typeof oldWidth && this.resizeColStartWidth.set(col, oldWidth);
|
|
86366
|
+
}
|
|
86367
|
+
}
|
|
86368
|
+
handleResizeColumnEnd(eventArgs) {
|
|
86369
|
+
var _a, _b, _c, _d;
|
|
86370
|
+
if (!this.table) return;
|
|
86371
|
+
const sheetKey = this.getSheetKey(),
|
|
86372
|
+
col = eventArgs.col,
|
|
86373
|
+
newWidth = null !== (_a = (eventArgs.colWidths || [])[col]) && void 0 !== _a ? _a : null === (_c = (_b = this.table).getColWidth) || void 0 === _c ? void 0 : _c.call(_b, col),
|
|
86374
|
+
oldWidth = null !== (_d = this.resizeColStartWidth.get(col)) && void 0 !== _d ? _d : newWidth;
|
|
86375
|
+
if (this.resizeColStartWidth.delete(col), "number" == typeof oldWidth && "number" == typeof newWidth && oldWidth === newWidth) return;
|
|
86376
|
+
const cmd = {
|
|
86377
|
+
type: "resize_column",
|
|
86378
|
+
sheetKey: sheetKey,
|
|
86379
|
+
col: col,
|
|
86380
|
+
oldWidth: oldWidth,
|
|
86381
|
+
newWidth: newWidth
|
|
86382
|
+
};
|
|
86383
|
+
this.pushCommand(cmd);
|
|
86384
|
+
}
|
|
86385
|
+
applyCommand(cmd, direction) {
|
|
86386
|
+
this.table && replayCommand({
|
|
86387
|
+
table: this.table,
|
|
86388
|
+
vtableSheet: this.vtableSheet,
|
|
86389
|
+
cmd: cmd,
|
|
86390
|
+
direction: direction,
|
|
86391
|
+
deleteRecordsByReference: records => this.deleteRecordsByReference(records)
|
|
86392
|
+
});
|
|
86393
|
+
}
|
|
86394
|
+
deleteRecordsByReference(records) {
|
|
86395
|
+
if (!this.table || !(null == records ? void 0 : records.length)) return;
|
|
86396
|
+
const tableRecords = this.table.records || [],
|
|
86397
|
+
indexs = [];
|
|
86398
|
+
records.forEach(rec => {
|
|
86399
|
+
const idx = tableRecords.indexOf(rec);
|
|
86400
|
+
idx >= 0 && indexs.push(idx);
|
|
86401
|
+
}), indexs.length && this.table.deleteRecords && this.table.deleteRecords(indexs);
|
|
86402
|
+
}
|
|
86403
|
+
}
|
|
86404
|
+
|
|
84729
86405
|
class FormulaAutocomplete {
|
|
84730
86406
|
container;
|
|
84731
86407
|
dropdown = null;
|
|
@@ -85225,12 +86901,41 @@
|
|
|
85225
86901
|
if (!this.element || !this.sheet) {
|
|
85226
86902
|
return;
|
|
85227
86903
|
}
|
|
85228
|
-
|
|
85229
|
-
|
|
85230
|
-
const
|
|
85231
|
-
|
|
85232
|
-
|
|
86904
|
+
const value = this.element.value;
|
|
86905
|
+
const selectionStart = this.element.selectionStart ?? value.length;
|
|
86906
|
+
const selectionEnd = this.element.selectionEnd ?? selectionStart;
|
|
86907
|
+
let replaceStart = selectionStart;
|
|
86908
|
+
let replaceEnd = selectionEnd;
|
|
86909
|
+
if (selectionStart === selectionEnd) {
|
|
86910
|
+
replaceStart = selectionStart;
|
|
86911
|
+
while (replaceStart > 1 && /[A-Za-z0-9]/.test(value[replaceStart - 1])) {
|
|
86912
|
+
replaceStart--;
|
|
86913
|
+
}
|
|
86914
|
+
const hasLeftWord = replaceStart < selectionStart;
|
|
86915
|
+
replaceEnd = selectionStart;
|
|
86916
|
+
if (hasLeftWord) {
|
|
86917
|
+
while (replaceEnd < value.length && /[A-Za-z0-9]/.test(value[replaceEnd])) {
|
|
86918
|
+
replaceEnd++;
|
|
86919
|
+
}
|
|
86920
|
+
}
|
|
86921
|
+
}
|
|
86922
|
+
const isFunction = item?.type === 'function';
|
|
86923
|
+
const itemValue = String(item?.value ?? '');
|
|
86924
|
+
const nextChar = value[replaceEnd];
|
|
86925
|
+
const shouldAppendParen = isFunction && nextChar !== '(';
|
|
86926
|
+
const insertText = itemValue + (shouldAppendParen ? '(' : '');
|
|
86927
|
+
const newValue = value.slice(0, replaceStart) + insertText + value.slice(replaceEnd);
|
|
86928
|
+
this.element.value = newValue;
|
|
86929
|
+
let newCursorPos = replaceStart + itemValue.length;
|
|
86930
|
+
if (isFunction && newValue[newCursorPos] === '(') {
|
|
86931
|
+
newCursorPos += 1;
|
|
86932
|
+
}
|
|
86933
|
+
this.element.setSelectionRange(newCursorPos, newCursorPos);
|
|
86934
|
+
if (this.sheet.formulaUIManager.formulaInput) {
|
|
86935
|
+
this.sheet.formulaUIManager.formulaInput.value = newValue;
|
|
85233
86936
|
}
|
|
86937
|
+
const inputEvent = new Event('input', { bubbles: true });
|
|
86938
|
+
this.element.dispatchEvent(inputEvent);
|
|
85234
86939
|
}
|
|
85235
86940
|
onStart(context) {
|
|
85236
86941
|
const formula = this.sheet.formulaManager.getCellFormula({
|
|
@@ -85322,7 +87027,9 @@
|
|
|
85322
87027
|
return `${startCol}${startRow}:${endCol}${endRow}`;
|
|
85323
87028
|
}
|
|
85324
87029
|
}
|
|
85325
|
-
|
|
87030
|
+
function createFormulaEditor() {
|
|
87031
|
+
return new FormulaInputEditor();
|
|
87032
|
+
}
|
|
85326
87033
|
|
|
85327
87034
|
class FormulaUIManager {
|
|
85328
87035
|
sheet;
|
|
@@ -87476,7 +89183,7 @@
|
|
|
87476
89183
|
}
|
|
87477
89184
|
return this.addSheet(sheetKey);
|
|
87478
89185
|
}
|
|
87479
|
-
setCellContent(cell, value) {
|
|
89186
|
+
setCellContent(cell, value, options) {
|
|
87480
89187
|
this.ensureInitialized();
|
|
87481
89188
|
if (!cell || cell.sheet === undefined || cell.row === undefined || cell.col === undefined) {
|
|
87482
89189
|
throw new Error('Invalid cell parameter for setCellContent');
|
|
@@ -87494,16 +89201,18 @@
|
|
|
87494
89201
|
else {
|
|
87495
89202
|
this.formulaEngine.setCellContent(cell, value);
|
|
87496
89203
|
}
|
|
87497
|
-
|
|
87498
|
-
|
|
87499
|
-
|
|
87500
|
-
|
|
87501
|
-
|
|
87502
|
-
|
|
89204
|
+
if (options?.emitEvent !== false) {
|
|
89205
|
+
const newFormula = this.getCellFormula(cell);
|
|
89206
|
+
if (newFormula && newFormula !== oldFormula) {
|
|
89207
|
+
this.emitFormulaEvent(cell, 'added', newFormula);
|
|
89208
|
+
}
|
|
89209
|
+
else if (!newFormula && oldFormula) {
|
|
89210
|
+
this.emitFormulaEvent(cell, 'removed', oldFormula);
|
|
89211
|
+
}
|
|
87503
89212
|
}
|
|
87504
89213
|
}
|
|
87505
89214
|
catch (error) {
|
|
87506
|
-
if (typeof value === 'string' && value.startsWith('=')) {
|
|
89215
|
+
if (options?.emitEvent !== false && typeof value === 'string' && value.startsWith('=')) {
|
|
87507
89216
|
this.emitFormulaEvent(cell, 'error', value, error);
|
|
87508
89217
|
}
|
|
87509
89218
|
if (error instanceof Error) {
|
|
@@ -88753,6 +90462,7 @@
|
|
|
88753
90462
|
maintainArrayDataOrder: true
|
|
88754
90463
|
},
|
|
88755
90464
|
addRecordRule: 'Array',
|
|
90465
|
+
syncRecordOperationsToSourceRecords: true,
|
|
88756
90466
|
defaultCursor: 'cell',
|
|
88757
90467
|
records: this.options.data,
|
|
88758
90468
|
sortState: this.options.sortState,
|
|
@@ -88908,54 +90618,6 @@
|
|
|
88908
90618
|
if (rowIndexs && rowIndexs.length > 0) {
|
|
88909
90619
|
const minIndex = Math.min(...rowIndexs.flat());
|
|
88910
90620
|
this.vtableSheet.formulaManager.removeRows(sheetKey, minIndex, deletedCount);
|
|
88911
|
-
if (Array.isArray(this.tableInstance.options.customMergeCell)) {
|
|
88912
|
-
const mergeCellsToRemove = [];
|
|
88913
|
-
const deleteEndIndex = minIndex + deletedCount - 1;
|
|
88914
|
-
const customMergeCellArray = this.tableInstance.options.customMergeCell;
|
|
88915
|
-
const cloneMergeCellArray = customMergeCellArray.map(mergeCell => ({
|
|
88916
|
-
...mergeCell,
|
|
88917
|
-
range: {
|
|
88918
|
-
start: { ...mergeCell.range.start },
|
|
88919
|
-
end: { ...mergeCell.range.end }
|
|
88920
|
-
}
|
|
88921
|
-
}));
|
|
88922
|
-
customMergeCellArray.forEach((mergeCell, index) => {
|
|
88923
|
-
const startRow = mergeCell.range.start.row;
|
|
88924
|
-
const endRow = mergeCell.range.end.row;
|
|
88925
|
-
if (startRow >= minIndex && endRow <= deleteEndIndex) {
|
|
88926
|
-
mergeCellsToRemove.push(index);
|
|
88927
|
-
return;
|
|
88928
|
-
}
|
|
88929
|
-
if (startRow <= deleteEndIndex && endRow >= minIndex) {
|
|
88930
|
-
if (startRow >= minIndex) {
|
|
88931
|
-
mergeCell.range.start.row = minIndex;
|
|
88932
|
-
}
|
|
88933
|
-
if (endRow <= deleteEndIndex) {
|
|
88934
|
-
mergeCell.range.end.row = minIndex - 1;
|
|
88935
|
-
}
|
|
88936
|
-
else {
|
|
88937
|
-
mergeCell.range.end.row -= deletedCount;
|
|
88938
|
-
}
|
|
88939
|
-
if (mergeCell.range.start.row > mergeCell.range.end.row) {
|
|
88940
|
-
mergeCellsToRemove.push(index);
|
|
88941
|
-
}
|
|
88942
|
-
}
|
|
88943
|
-
else if (startRow > deleteEndIndex) {
|
|
88944
|
-
mergeCell.range.start.row -= deletedCount;
|
|
88945
|
-
mergeCell.range.end.row -= deletedCount;
|
|
88946
|
-
}
|
|
88947
|
-
});
|
|
88948
|
-
mergeCellsToRemove
|
|
88949
|
-
.sort((a, b) => b - a)
|
|
88950
|
-
.forEach(index => {
|
|
88951
|
-
customMergeCellArray.splice(index, 1);
|
|
88952
|
-
});
|
|
88953
|
-
const updateRanges = cloneMergeCellArray.map(mergeCell => ({
|
|
88954
|
-
start: { ...mergeCell.range.start },
|
|
88955
|
-
end: { ...mergeCell.range.end }
|
|
88956
|
-
}));
|
|
88957
|
-
this.tableInstance.updateCellContentRange(updateRanges);
|
|
88958
|
-
}
|
|
88959
90621
|
}
|
|
88960
90622
|
}
|
|
88961
90623
|
}
|
|
@@ -88983,54 +90645,6 @@
|
|
|
88983
90645
|
const minIndex = Math.min(...deleteColIndexs.flat());
|
|
88984
90646
|
const deletedCount = deleteColIndexs.length;
|
|
88985
90647
|
this.vtableSheet.formulaManager.removeColumns(sheetKey, minIndex, deletedCount);
|
|
88986
|
-
if (Array.isArray(this.tableInstance.options.customMergeCell)) {
|
|
88987
|
-
const mergeCellsToRemove = [];
|
|
88988
|
-
const deleteEndIndex = minIndex + deletedCount - 1;
|
|
88989
|
-
const customMergeCellArray = this.tableInstance.options.customMergeCell;
|
|
88990
|
-
const cloneMergeCellArray = customMergeCellArray.map(mergeCell => ({
|
|
88991
|
-
...mergeCell,
|
|
88992
|
-
range: {
|
|
88993
|
-
start: { ...mergeCell.range.start },
|
|
88994
|
-
end: { ...mergeCell.range.end }
|
|
88995
|
-
}
|
|
88996
|
-
}));
|
|
88997
|
-
customMergeCellArray.forEach((mergeCell, index) => {
|
|
88998
|
-
const startCol = mergeCell.range.start.col;
|
|
88999
|
-
const endCol = mergeCell.range.end.col;
|
|
89000
|
-
if (startCol >= minIndex && endCol <= deleteEndIndex) {
|
|
89001
|
-
mergeCellsToRemove.push(index);
|
|
89002
|
-
return;
|
|
89003
|
-
}
|
|
89004
|
-
if (startCol <= deleteEndIndex && endCol >= minIndex) {
|
|
89005
|
-
if (startCol >= minIndex) {
|
|
89006
|
-
mergeCell.range.start.col = minIndex;
|
|
89007
|
-
}
|
|
89008
|
-
if (endCol <= deleteEndIndex) {
|
|
89009
|
-
mergeCell.range.end.col = minIndex - 1;
|
|
89010
|
-
}
|
|
89011
|
-
else {
|
|
89012
|
-
mergeCell.range.end.col -= deletedCount;
|
|
89013
|
-
}
|
|
89014
|
-
if (mergeCell.range.start.col > mergeCell.range.end.col) {
|
|
89015
|
-
mergeCellsToRemove.push(index);
|
|
89016
|
-
}
|
|
89017
|
-
}
|
|
89018
|
-
else if (startCol > deleteEndIndex) {
|
|
89019
|
-
mergeCell.range.start.col -= deletedCount;
|
|
89020
|
-
mergeCell.range.end.col -= deletedCount;
|
|
89021
|
-
}
|
|
89022
|
-
});
|
|
89023
|
-
mergeCellsToRemove
|
|
89024
|
-
.sort((a, b) => b - a)
|
|
89025
|
-
.forEach(index => {
|
|
89026
|
-
customMergeCellArray.splice(index, 1);
|
|
89027
|
-
});
|
|
89028
|
-
const updateRanges = cloneMergeCellArray.map(mergeCell => ({
|
|
89029
|
-
start: { ...mergeCell.range.start },
|
|
89030
|
-
end: { ...mergeCell.range.end }
|
|
89031
|
-
}));
|
|
89032
|
-
this.tableInstance.updateCellContentRange(updateRanges);
|
|
89033
|
-
}
|
|
89034
90648
|
}
|
|
89035
90649
|
}
|
|
89036
90650
|
}
|
|
@@ -89373,6 +90987,20 @@
|
|
|
89373
90987
|
const plugins = [];
|
|
89374
90988
|
const disabledPluginsUserSetted = options?.VTablePluginModules?.filter(module => module.disabled);
|
|
89375
90989
|
let enabledPluginsUserSetted = options?.VTablePluginModules?.filter(module => !module.disabled);
|
|
90990
|
+
if (vtableSheet?.getWorkbookHistoryManager &&
|
|
90991
|
+
!disabledPluginsUserSetted?.some(module => module.module === HistoryPlugin) &&
|
|
90992
|
+
!enabledPluginsUserSetted?.some(module => module.module === HistoryPlugin)) {
|
|
90993
|
+
const workbookHistory = vtableSheet.getWorkbookHistoryManager();
|
|
90994
|
+
if (typeof HistoryPlugin !== 'function') ;
|
|
90995
|
+
else {
|
|
90996
|
+
plugins.push(new HistoryPlugin({
|
|
90997
|
+
enableCompression: false,
|
|
90998
|
+
onTransactionPushed: (args) => {
|
|
90999
|
+
workbookHistory.recordTableTransaction({ sheetKey: args?.sheetKey, tx: args?.tx });
|
|
91000
|
+
}
|
|
91001
|
+
}));
|
|
91002
|
+
}
|
|
91003
|
+
}
|
|
89376
91004
|
if (!disabledPluginsUserSetted?.some(module => module.module === FilterPlugin)) {
|
|
89377
91005
|
const userPluginOptions = enabledPluginsUserSetted?.find(module => module.module === FilterPlugin)
|
|
89378
91006
|
?.moduleOptions;
|
|
@@ -89452,7 +91080,20 @@
|
|
|
89452
91080
|
if (enabledPluginsUserSetted?.length) {
|
|
89453
91081
|
enabledPluginsUserSetted.forEach((module) => {
|
|
89454
91082
|
if (typeof module?.module === 'function') {
|
|
89455
|
-
|
|
91083
|
+
let moduleOptions = module.moduleOptions;
|
|
91084
|
+
if (module.module === HistoryPlugin && vtableSheet?.getWorkbookHistoryManager) {
|
|
91085
|
+
const workbookHistory = vtableSheet.getWorkbookHistoryManager();
|
|
91086
|
+
const prev = moduleOptions?.onTransactionPushed;
|
|
91087
|
+
moduleOptions = {
|
|
91088
|
+
...(moduleOptions ?? {}),
|
|
91089
|
+
enableCompression: moduleOptions?.enableCompression ?? false,
|
|
91090
|
+
onTransactionPushed: (args) => {
|
|
91091
|
+
prev?.(args);
|
|
91092
|
+
workbookHistory.recordTableTransaction({ sheetKey: args?.sheetKey, tx: args?.tx });
|
|
91093
|
+
}
|
|
91094
|
+
};
|
|
91095
|
+
}
|
|
91096
|
+
plugins.push(new module.module(moduleOptions));
|
|
89456
91097
|
}
|
|
89457
91098
|
});
|
|
89458
91099
|
}
|
|
@@ -89937,9 +91578,7 @@
|
|
|
89937
91578
|
}
|
|
89938
91579
|
performTabReorder(sourceKey, targetKey, position) {
|
|
89939
91580
|
try {
|
|
89940
|
-
this.sheet.
|
|
89941
|
-
this.sheet.updateSheetTabs();
|
|
89942
|
-
this.sheet.updateSheetMenu();
|
|
91581
|
+
this.sheet.reorderSheet(sourceKey, targetKey, position);
|
|
89943
91582
|
}
|
|
89944
91583
|
catch (error) {
|
|
89945
91584
|
}
|
|
@@ -89958,10 +91597,18 @@
|
|
|
89958
91597
|
class MenuManager {
|
|
89959
91598
|
sheet;
|
|
89960
91599
|
menuContainer;
|
|
91600
|
+
undoButton = null;
|
|
91601
|
+
redoButton = null;
|
|
89961
91602
|
clickOutsideHandler;
|
|
91603
|
+
historyUnsubscribe = null;
|
|
89962
91604
|
constructor(sheet) {
|
|
89963
91605
|
this.sheet = sheet;
|
|
89964
|
-
|
|
91606
|
+
}
|
|
91607
|
+
createUndoRedoOnly() {
|
|
91608
|
+
const wrap = document.createElement('div');
|
|
91609
|
+
wrap.className = 'vtable-sheet-undo-redo';
|
|
91610
|
+
this.mountUndoRedoActions(wrap);
|
|
91611
|
+
return wrap;
|
|
89965
91612
|
}
|
|
89966
91613
|
createMainMenu() {
|
|
89967
91614
|
const menuIcon = `<svg t="1754379519717" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1496" width="24" height="24"><path d="M510.435876 67.959811c-245.428735 0-444.382996 198.954261-444.382996 444.373787 0 245.420549 198.954261 444.373787 444.382996 444.373787 245.410316 0 444.372763-198.953238 444.372763-444.373787C954.807616 266.914072 755.846192 67.959811 510.435876 67.959811zM510.435876 901.156184c-214.743876 0-388.831796-174.08792-388.831796-388.822586 0-214.743876 174.088944-388.831796 388.831796-388.831796 214.732619 0 388.822586 174.08792 388.822586 388.831796C899.257439 727.068264 725.167472 901.156184 510.435876 901.156184zM666.028561 329.355193 337.411171 329.355193c-15.117302 0-27.384697 15.60235-27.384697 34.844599 0 19.259646 12.267395 34.861996 27.384697 34.861996l328.618413 0c15.124466 0 27.375487-15.60235 27.375487-34.861996C693.404048 344.957543 681.15405 329.355193 666.028561 329.355193zM666.028561 486.191194 337.411171 486.191194c-15.117302 0-27.384697 15.601326-27.384697 34.852786 0 19.25146 12.267395 34.853809 27.384697 34.853809l328.618413 0c15.124466 0 27.375487-15.601326 27.375487-34.853809C693.404048 501.792521 681.15405 486.191194 666.028561 486.191194zM666.028561 625.604384 337.411171 625.604384c-15.117302 0-27.384697 15.60235-27.384697 34.845623 0 19.25146 12.267395 34.861996 27.384697 34.861996l328.618413 0c15.124466 0 27.375487-15.611559 27.375487-34.861996C693.404048 641.206734 681.15405 625.604384 666.028561 625.604384z" fill="#8a8a8a" p-id="1497"></path></svg>`;
|
|
@@ -89972,6 +91619,7 @@
|
|
|
89972
91619
|
menuButton.className = 'vtable-sheet-main-menu-button';
|
|
89973
91620
|
menuButton.innerHTML = menuIcon;
|
|
89974
91621
|
menu.appendChild(menuButton);
|
|
91622
|
+
this.mountUndoRedoActions(menu);
|
|
89975
91623
|
const menuContainer = document.createElement('div');
|
|
89976
91624
|
menuContainer.className = 'vtable-sheet-main-menu-container';
|
|
89977
91625
|
menu.appendChild(menuContainer);
|
|
@@ -90020,6 +91668,55 @@
|
|
|
90020
91668
|
this.menuContainer = menuContainer;
|
|
90021
91669
|
return menu;
|
|
90022
91670
|
}
|
|
91671
|
+
mountUndoRedoActions(container) {
|
|
91672
|
+
const showUndoRedo = this.sheet.getOptions().undoRedo?.show ?? true;
|
|
91673
|
+
if (!showUndoRedo) {
|
|
91674
|
+
this.undoButton = null;
|
|
91675
|
+
this.redoButton = null;
|
|
91676
|
+
this.historyUnsubscribe?.();
|
|
91677
|
+
this.historyUnsubscribe = null;
|
|
91678
|
+
return;
|
|
91679
|
+
}
|
|
91680
|
+
const undoIcon = `<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-icon="UndoOutlined"><path d="M8.707 2.293a1 1 0 0 1 0 1.414L5.414 7H14.5a7.5 7.5 0 0 1 0 15H11a1 1 0 1 1 0-2h3.5a5.5 5.5 0 1 0 0-11H5.414l3.293 3.293a1 1 0 1 1-1.414 1.414l-5-5a1 1 0 0 1 0-1.414l5-5a1 1 0 0 1 1.414 0Z" fill="currentColor"></path></svg>`;
|
|
91681
|
+
const redoIcon = `<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-icon="RedoOutlined"><path d="M15.293 2.293a1 1 0 0 0 0 1.414L18.586 7H9.5a7.5 7.5 0 0 0 0 15H13a1 1 0 1 0 0-2H9.5a5.5 5.5 0 1 1 0-11h9.086l-3.293 3.293a1 1 0 0 0 1.414 1.414l5-5a1 1 0 0 0 0-1.414l-5-5a1 1 0 0 0-1.414 0Z" fill="currentColor"></path></svg>`;
|
|
91682
|
+
const actions = document.createElement('div');
|
|
91683
|
+
actions.className = 'vtable-sheet-main-menu-actions';
|
|
91684
|
+
container.appendChild(actions);
|
|
91685
|
+
this.undoButton = document.createElement('button');
|
|
91686
|
+
this.undoButton.className = 'vtable-sheet-main-menu-action';
|
|
91687
|
+
this.undoButton.type = 'button';
|
|
91688
|
+
this.undoButton.title = '撤销';
|
|
91689
|
+
this.undoButton.innerHTML = undoIcon;
|
|
91690
|
+
this.undoButton.addEventListener('click', e => {
|
|
91691
|
+
e.stopPropagation();
|
|
91692
|
+
this.sheet.undo();
|
|
91693
|
+
});
|
|
91694
|
+
actions.appendChild(this.undoButton);
|
|
91695
|
+
this.redoButton = document.createElement('button');
|
|
91696
|
+
this.redoButton.className = 'vtable-sheet-main-menu-action';
|
|
91697
|
+
this.redoButton.type = 'button';
|
|
91698
|
+
this.redoButton.title = '重做';
|
|
91699
|
+
this.redoButton.innerHTML = redoIcon;
|
|
91700
|
+
this.redoButton.addEventListener('click', e => {
|
|
91701
|
+
e.stopPropagation();
|
|
91702
|
+
this.sheet.redo();
|
|
91703
|
+
});
|
|
91704
|
+
actions.appendChild(this.redoButton);
|
|
91705
|
+
this.historyUnsubscribe?.();
|
|
91706
|
+
this.historyUnsubscribe = this.sheet.getWorkbookHistoryManager().onChange(() => {
|
|
91707
|
+
this.updateUndoRedoState();
|
|
91708
|
+
});
|
|
91709
|
+
this.updateUndoRedoState();
|
|
91710
|
+
}
|
|
91711
|
+
updateUndoRedoState() {
|
|
91712
|
+
const history = this.sheet.getWorkbookHistoryManager();
|
|
91713
|
+
if (this.undoButton) {
|
|
91714
|
+
this.undoButton.disabled = !history.canUndo();
|
|
91715
|
+
}
|
|
91716
|
+
if (this.redoButton) {
|
|
91717
|
+
this.redoButton.disabled = !history.canRedo();
|
|
91718
|
+
}
|
|
91719
|
+
}
|
|
90023
91720
|
createSubMenu(items) {
|
|
90024
91721
|
const subMenuContainer = document.createElement('div');
|
|
90025
91722
|
subMenuContainer.className = 'vtable-sheet-submenu-container';
|
|
@@ -90138,10 +91835,12 @@
|
|
|
90138
91835
|
document.removeEventListener('click', this.clickOutsideHandler);
|
|
90139
91836
|
this.clickOutsideHandler = null;
|
|
90140
91837
|
}
|
|
91838
|
+
this.historyUnsubscribe?.();
|
|
91839
|
+
this.historyUnsubscribe = null;
|
|
90141
91840
|
}
|
|
90142
91841
|
updateMainMenu(mainMenu) {
|
|
90143
91842
|
this.release();
|
|
90144
|
-
this.createMainMenu();
|
|
91843
|
+
return this.createMainMenu();
|
|
90145
91844
|
}
|
|
90146
91845
|
}
|
|
90147
91846
|
|
|
@@ -90208,11 +91907,7 @@
|
|
|
90208
91907
|
showSnackbar('工作表名称已存在,请重新输入', 1300);
|
|
90209
91908
|
return false;
|
|
90210
91909
|
}
|
|
90211
|
-
this.vTableSheet.
|
|
90212
|
-
this.vTableSheet.workSheetInstances.get(sheetKey)?.setTitle(newTitle);
|
|
90213
|
-
this.vTableSheet.getFormulaManager().updateSheetTitle(sheetKey, newTitle);
|
|
90214
|
-
this.vTableSheet.updateSheetTabs();
|
|
90215
|
-
this.vTableSheet.updateSheetMenu();
|
|
91910
|
+
this.vTableSheet.renameSheet(sheetKey, newTitle);
|
|
90216
91911
|
return true;
|
|
90217
91912
|
}
|
|
90218
91913
|
getSheetTabElementByKey(sheetKey) {
|
|
@@ -90762,7 +92457,430 @@
|
|
|
90762
92457
|
}
|
|
90763
92458
|
}
|
|
90764
92459
|
|
|
90765
|
-
|
|
92460
|
+
function cloneJson(input) {
|
|
92461
|
+
return JSON.parse(JSON.stringify(input));
|
|
92462
|
+
}
|
|
92463
|
+
function cloneSafe(input) {
|
|
92464
|
+
const sc = globalThis.structuredClone;
|
|
92465
|
+
if (typeof sc === 'function') {
|
|
92466
|
+
try {
|
|
92467
|
+
return sc(input);
|
|
92468
|
+
}
|
|
92469
|
+
catch { }
|
|
92470
|
+
}
|
|
92471
|
+
return cloneJson(input);
|
|
92472
|
+
}
|
|
92473
|
+
class WorkbookHistoryManager {
|
|
92474
|
+
sheet;
|
|
92475
|
+
undoStack = [];
|
|
92476
|
+
redoStack = [];
|
|
92477
|
+
currentTransaction = null;
|
|
92478
|
+
maxHistory;
|
|
92479
|
+
enabled = true;
|
|
92480
|
+
isReplaying = false;
|
|
92481
|
+
changeListeners = new Set();
|
|
92482
|
+
constructor(sheet, options) {
|
|
92483
|
+
this.sheet = sheet;
|
|
92484
|
+
this.maxHistory = options?.maxHistory ?? 100;
|
|
92485
|
+
}
|
|
92486
|
+
canUndo() {
|
|
92487
|
+
return this.undoStack.length > 0;
|
|
92488
|
+
}
|
|
92489
|
+
canRedo() {
|
|
92490
|
+
return this.redoStack.length > 0;
|
|
92491
|
+
}
|
|
92492
|
+
onChange(listener) {
|
|
92493
|
+
this.changeListeners.add(listener);
|
|
92494
|
+
return () => {
|
|
92495
|
+
this.changeListeners.delete(listener);
|
|
92496
|
+
};
|
|
92497
|
+
}
|
|
92498
|
+
emitChange() {
|
|
92499
|
+
this.changeListeners.forEach(fn => {
|
|
92500
|
+
try {
|
|
92501
|
+
fn();
|
|
92502
|
+
}
|
|
92503
|
+
catch { }
|
|
92504
|
+
});
|
|
92505
|
+
}
|
|
92506
|
+
suspend() {
|
|
92507
|
+
this.enabled = false;
|
|
92508
|
+
}
|
|
92509
|
+
resume() {
|
|
92510
|
+
this.enabled = true;
|
|
92511
|
+
}
|
|
92512
|
+
startTransaction() {
|
|
92513
|
+
if (this.currentTransaction) {
|
|
92514
|
+
return;
|
|
92515
|
+
}
|
|
92516
|
+
this.currentTransaction = { commands: [] };
|
|
92517
|
+
}
|
|
92518
|
+
endTransaction() {
|
|
92519
|
+
if (!this.currentTransaction || this.currentTransaction.commands.length === 0) {
|
|
92520
|
+
this.currentTransaction = null;
|
|
92521
|
+
return;
|
|
92522
|
+
}
|
|
92523
|
+
this.pushTransaction(this.currentTransaction);
|
|
92524
|
+
this.currentTransaction = null;
|
|
92525
|
+
}
|
|
92526
|
+
clear() {
|
|
92527
|
+
this.undoStack = [];
|
|
92528
|
+
this.redoStack = [];
|
|
92529
|
+
this.currentTransaction = null;
|
|
92530
|
+
this.emitChange();
|
|
92531
|
+
}
|
|
92532
|
+
updateOptions(options) {
|
|
92533
|
+
if (options.maxHistory != null) {
|
|
92534
|
+
this.maxHistory = options.maxHistory;
|
|
92535
|
+
this.trimHistory();
|
|
92536
|
+
this.emitChange();
|
|
92537
|
+
}
|
|
92538
|
+
}
|
|
92539
|
+
undo() {
|
|
92540
|
+
if (this.undoStack.length === 0) {
|
|
92541
|
+
return;
|
|
92542
|
+
}
|
|
92543
|
+
const tx = this.undoStack.pop();
|
|
92544
|
+
this.isReplaying = true;
|
|
92545
|
+
this.sheet.__workbookHistoryReplaying = true;
|
|
92546
|
+
try {
|
|
92547
|
+
for (let i = tx.commands.length - 1; i >= 0; i--) {
|
|
92548
|
+
this.applyCommand(tx.commands[i], 'undo');
|
|
92549
|
+
}
|
|
92550
|
+
}
|
|
92551
|
+
finally {
|
|
92552
|
+
this.isReplaying = false;
|
|
92553
|
+
this.sheet.__workbookHistoryReplaying = false;
|
|
92554
|
+
}
|
|
92555
|
+
this.redoStack.push(tx);
|
|
92556
|
+
this.emitChange();
|
|
92557
|
+
}
|
|
92558
|
+
redo() {
|
|
92559
|
+
if (this.redoStack.length === 0) {
|
|
92560
|
+
return;
|
|
92561
|
+
}
|
|
92562
|
+
const tx = this.redoStack.pop();
|
|
92563
|
+
this.isReplaying = true;
|
|
92564
|
+
this.sheet.__workbookHistoryReplaying = true;
|
|
92565
|
+
try {
|
|
92566
|
+
for (const cmd of tx.commands) {
|
|
92567
|
+
this.applyCommand(cmd, 'redo');
|
|
92568
|
+
}
|
|
92569
|
+
}
|
|
92570
|
+
finally {
|
|
92571
|
+
this.isReplaying = false;
|
|
92572
|
+
this.sheet.__workbookHistoryReplaying = false;
|
|
92573
|
+
}
|
|
92574
|
+
this.undoStack.push(tx);
|
|
92575
|
+
this.emitChange();
|
|
92576
|
+
}
|
|
92577
|
+
recordTableTransaction(args) {
|
|
92578
|
+
if (!this.enabled || this.isReplaying) {
|
|
92579
|
+
return;
|
|
92580
|
+
}
|
|
92581
|
+
const sheetKey = args.sheetKey ?? this.getActiveSheetKey();
|
|
92582
|
+
if (!sheetKey) {
|
|
92583
|
+
return;
|
|
92584
|
+
}
|
|
92585
|
+
const cmd = {
|
|
92586
|
+
type: 'table_tx',
|
|
92587
|
+
sheetKey,
|
|
92588
|
+
tx: cloneSafe(args.tx)
|
|
92589
|
+
};
|
|
92590
|
+
this.pushCommand(cmd);
|
|
92591
|
+
}
|
|
92592
|
+
addSheet(args) {
|
|
92593
|
+
if (!this.enabled || this.isReplaying) {
|
|
92594
|
+
this.addSheetInternal(args.sheet, args.activate);
|
|
92595
|
+
return;
|
|
92596
|
+
}
|
|
92597
|
+
const orderBefore = this.getSheetOrder();
|
|
92598
|
+
const activeBefore = this.getActiveSheetKey();
|
|
92599
|
+
this.startTransaction();
|
|
92600
|
+
try {
|
|
92601
|
+
this.addSheetInternal(args.sheet, args.activate);
|
|
92602
|
+
const orderAfter = this.getSheetOrder();
|
|
92603
|
+
const activeAfter = this.getActiveSheetKey();
|
|
92604
|
+
const cmd = {
|
|
92605
|
+
type: 'sheet_add',
|
|
92606
|
+
sheet: cloneSafe(args.sheet),
|
|
92607
|
+
orderBefore,
|
|
92608
|
+
orderAfter,
|
|
92609
|
+
activeBefore,
|
|
92610
|
+
activeAfter
|
|
92611
|
+
};
|
|
92612
|
+
this.pushCommand(cmd);
|
|
92613
|
+
}
|
|
92614
|
+
finally {
|
|
92615
|
+
this.endTransaction();
|
|
92616
|
+
}
|
|
92617
|
+
}
|
|
92618
|
+
removeSheet(sheetKey) {
|
|
92619
|
+
if (!this.enabled || this.isReplaying) {
|
|
92620
|
+
this.removeSheetInternal(sheetKey);
|
|
92621
|
+
return;
|
|
92622
|
+
}
|
|
92623
|
+
const sheetDefine = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92624
|
+
if (!sheetDefine) {
|
|
92625
|
+
return;
|
|
92626
|
+
}
|
|
92627
|
+
const orderBefore = this.getSheetOrder();
|
|
92628
|
+
const activeBefore = this.getActiveSheetKey();
|
|
92629
|
+
this.startTransaction();
|
|
92630
|
+
try {
|
|
92631
|
+
this.removeSheetInternal(sheetKey);
|
|
92632
|
+
const orderAfter = this.getSheetOrder();
|
|
92633
|
+
const activeAfter = this.getActiveSheetKey();
|
|
92634
|
+
const cmd = {
|
|
92635
|
+
type: 'sheet_remove',
|
|
92636
|
+
sheet: cloneSafe(sheetDefine),
|
|
92637
|
+
orderBefore,
|
|
92638
|
+
orderAfter,
|
|
92639
|
+
activeBefore,
|
|
92640
|
+
activeAfter
|
|
92641
|
+
};
|
|
92642
|
+
this.pushCommand(cmd);
|
|
92643
|
+
}
|
|
92644
|
+
finally {
|
|
92645
|
+
this.endTransaction();
|
|
92646
|
+
}
|
|
92647
|
+
}
|
|
92648
|
+
renameSheet(sheetKey, newTitle) {
|
|
92649
|
+
const sheetDefine = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92650
|
+
if (!sheetDefine) {
|
|
92651
|
+
return;
|
|
92652
|
+
}
|
|
92653
|
+
const oldTitle = sheetDefine.sheetTitle;
|
|
92654
|
+
if (!this.enabled || this.isReplaying) {
|
|
92655
|
+
this.renameSheetInternal(sheetKey, newTitle);
|
|
92656
|
+
return;
|
|
92657
|
+
}
|
|
92658
|
+
this.startTransaction();
|
|
92659
|
+
try {
|
|
92660
|
+
this.renameSheetInternal(sheetKey, newTitle);
|
|
92661
|
+
const cmd = { type: 'sheet_rename', sheetKey, oldTitle, newTitle };
|
|
92662
|
+
this.pushCommand(cmd);
|
|
92663
|
+
}
|
|
92664
|
+
finally {
|
|
92665
|
+
this.endTransaction();
|
|
92666
|
+
}
|
|
92667
|
+
}
|
|
92668
|
+
reorderSheet(sourceKey, targetKey, position) {
|
|
92669
|
+
if (!this.enabled || this.isReplaying) {
|
|
92670
|
+
this.sheet.getSheetManager().reorderSheet(sourceKey, targetKey, position);
|
|
92671
|
+
this.sheet.updateSheetTabs();
|
|
92672
|
+
this.sheet.updateSheetMenu();
|
|
92673
|
+
return;
|
|
92674
|
+
}
|
|
92675
|
+
const orderBefore = this.getSheetOrder();
|
|
92676
|
+
this.startTransaction();
|
|
92677
|
+
try {
|
|
92678
|
+
this.sheet.getSheetManager().reorderSheet(sourceKey, targetKey, position);
|
|
92679
|
+
this.sheet.updateSheetTabs();
|
|
92680
|
+
this.sheet.updateSheetMenu();
|
|
92681
|
+
const orderAfter = this.getSheetOrder();
|
|
92682
|
+
const cmd = { type: 'sheet_reorder', orderBefore, orderAfter };
|
|
92683
|
+
this.pushCommand(cmd);
|
|
92684
|
+
}
|
|
92685
|
+
finally {
|
|
92686
|
+
this.endTransaction();
|
|
92687
|
+
}
|
|
92688
|
+
}
|
|
92689
|
+
pushTransaction(tx) {
|
|
92690
|
+
if (!tx.commands.length) {
|
|
92691
|
+
return;
|
|
92692
|
+
}
|
|
92693
|
+
this.undoStack.push(tx);
|
|
92694
|
+
this.redoStack = [];
|
|
92695
|
+
this.trimHistory();
|
|
92696
|
+
this.emitChange();
|
|
92697
|
+
}
|
|
92698
|
+
pushCommand(cmd) {
|
|
92699
|
+
if (this.currentTransaction) {
|
|
92700
|
+
this.currentTransaction.commands.push(cmd);
|
|
92701
|
+
return;
|
|
92702
|
+
}
|
|
92703
|
+
this.pushTransaction({ commands: [cmd] });
|
|
92704
|
+
}
|
|
92705
|
+
trimHistory() {
|
|
92706
|
+
if (this.undoStack.length > this.maxHistory) {
|
|
92707
|
+
this.undoStack.splice(0, this.undoStack.length - this.maxHistory);
|
|
92708
|
+
}
|
|
92709
|
+
}
|
|
92710
|
+
applyCommand(cmd, direction) {
|
|
92711
|
+
switch (cmd.type) {
|
|
92712
|
+
case 'sheet_add': {
|
|
92713
|
+
if (direction === 'undo') {
|
|
92714
|
+
this.removeSheetInternal(cmd.sheet.sheetKey);
|
|
92715
|
+
this.setSheetOrder(cmd.orderBefore);
|
|
92716
|
+
if (cmd.activeBefore) {
|
|
92717
|
+
this.sheet.activateSheet(cmd.activeBefore);
|
|
92718
|
+
}
|
|
92719
|
+
}
|
|
92720
|
+
else {
|
|
92721
|
+
this.addSheetInternal(cmd.sheet, false);
|
|
92722
|
+
this.setSheetOrder(cmd.orderAfter);
|
|
92723
|
+
if (cmd.activeAfter) {
|
|
92724
|
+
this.sheet.activateSheet(cmd.activeAfter);
|
|
92725
|
+
}
|
|
92726
|
+
}
|
|
92727
|
+
break;
|
|
92728
|
+
}
|
|
92729
|
+
case 'sheet_remove': {
|
|
92730
|
+
if (direction === 'undo') {
|
|
92731
|
+
this.addSheetInternal(cmd.sheet, false);
|
|
92732
|
+
this.setSheetOrder(cmd.orderBefore);
|
|
92733
|
+
if (!this.sheet.getWorkSheetInstance(cmd.sheet.sheetKey)) {
|
|
92734
|
+
const restored = this.sheet.createWorkSheetInstance(cmd.sheet);
|
|
92735
|
+
restored.getElement().style.display = 'none';
|
|
92736
|
+
this.sheet.setWorkSheetInstance(cmd.sheet.sheetKey, restored);
|
|
92737
|
+
}
|
|
92738
|
+
if (cmd.activeBefore) {
|
|
92739
|
+
this.sheet.activateSheet(cmd.activeBefore);
|
|
92740
|
+
}
|
|
92741
|
+
}
|
|
92742
|
+
else {
|
|
92743
|
+
this.removeSheetInternal(cmd.sheet.sheetKey);
|
|
92744
|
+
this.setSheetOrder(cmd.orderAfter);
|
|
92745
|
+
if (cmd.activeAfter) {
|
|
92746
|
+
this.sheet.activateSheet(cmd.activeAfter);
|
|
92747
|
+
}
|
|
92748
|
+
}
|
|
92749
|
+
break;
|
|
92750
|
+
}
|
|
92751
|
+
case 'sheet_rename': {
|
|
92752
|
+
const nextTitle = direction === 'undo' ? cmd.oldTitle : cmd.newTitle;
|
|
92753
|
+
this.renameSheetInternal(cmd.sheetKey, nextTitle);
|
|
92754
|
+
break;
|
|
92755
|
+
}
|
|
92756
|
+
case 'sheet_reorder': {
|
|
92757
|
+
this.setSheetOrder(direction === 'undo' ? cmd.orderBefore : cmd.orderAfter);
|
|
92758
|
+
break;
|
|
92759
|
+
}
|
|
92760
|
+
case 'table_tx': {
|
|
92761
|
+
this.applyTableTransaction(cmd.sheetKey, cmd.tx, direction);
|
|
92762
|
+
break;
|
|
92763
|
+
}
|
|
92764
|
+
}
|
|
92765
|
+
}
|
|
92766
|
+
addSheetInternal(sheetDefine, activate) {
|
|
92767
|
+
this.sheet.getSheetManager().addSheet(sheetDefine);
|
|
92768
|
+
if (activate) {
|
|
92769
|
+
this.sheet.activateSheet(sheetDefine.sheetKey);
|
|
92770
|
+
}
|
|
92771
|
+
else {
|
|
92772
|
+
this.sheet.updateSheetTabs();
|
|
92773
|
+
this.sheet.updateSheetMenu();
|
|
92774
|
+
}
|
|
92775
|
+
}
|
|
92776
|
+
removeSheetInternal(sheetKey) {
|
|
92777
|
+
const instance = this.sheet.getWorkSheetInstance(sheetKey);
|
|
92778
|
+
if (instance) {
|
|
92779
|
+
instance.release();
|
|
92780
|
+
this.sheet.deleteWorkSheetInstance(sheetKey);
|
|
92781
|
+
}
|
|
92782
|
+
const active = this.getActiveSheetKey();
|
|
92783
|
+
const newActiveSheetKey = this.sheet.getSheetManager().removeSheet(sheetKey);
|
|
92784
|
+
try {
|
|
92785
|
+
this.sheet.getFormulaManager().removeSheet(sheetKey);
|
|
92786
|
+
}
|
|
92787
|
+
catch { }
|
|
92788
|
+
if (newActiveSheetKey && newActiveSheetKey !== active) {
|
|
92789
|
+
this.sheet.activateSheet(newActiveSheetKey);
|
|
92790
|
+
}
|
|
92791
|
+
this.sheet.updateSheetTabs();
|
|
92792
|
+
this.sheet.updateSheetMenu();
|
|
92793
|
+
}
|
|
92794
|
+
renameSheetInternal(sheetKey, newTitle) {
|
|
92795
|
+
this.sheet.getSheetManager().renameSheet(sheetKey, newTitle);
|
|
92796
|
+
this.sheet.getWorkSheetInstance(sheetKey)?.setTitle(newTitle);
|
|
92797
|
+
this.sheet.getFormulaManager().updateSheetTitle(sheetKey, newTitle);
|
|
92798
|
+
this.sheet.updateSheetTabs();
|
|
92799
|
+
this.sheet.updateSheetMenu();
|
|
92800
|
+
}
|
|
92801
|
+
applyTableTransaction(sheetKey, tx, direction) {
|
|
92802
|
+
const ws = this.ensureWorkSheetInstance(sheetKey);
|
|
92803
|
+
if (ws && this.getActiveSheetKey() !== sheetKey) {
|
|
92804
|
+
this.sheet.activateSheet(sheetKey);
|
|
92805
|
+
}
|
|
92806
|
+
const table = ws?.tableInstance;
|
|
92807
|
+
if (!table) {
|
|
92808
|
+
return;
|
|
92809
|
+
}
|
|
92810
|
+
const vtableSheet = this.sheet;
|
|
92811
|
+
const apply = (cmd, dir) => {
|
|
92812
|
+
replayCommand({
|
|
92813
|
+
table,
|
|
92814
|
+
vtableSheet,
|
|
92815
|
+
cmd,
|
|
92816
|
+
direction: dir,
|
|
92817
|
+
deleteRecordsByReference: (records) => {
|
|
92818
|
+
const tableRecords = (table.records || []);
|
|
92819
|
+
const indexs = [];
|
|
92820
|
+
records.forEach(rec => {
|
|
92821
|
+
const idx = tableRecords.indexOf(rec);
|
|
92822
|
+
if (idx >= 0) {
|
|
92823
|
+
indexs.push(idx);
|
|
92824
|
+
}
|
|
92825
|
+
});
|
|
92826
|
+
if (indexs.length && table.deleteRecords) {
|
|
92827
|
+
table.deleteRecords(indexs);
|
|
92828
|
+
}
|
|
92829
|
+
}
|
|
92830
|
+
});
|
|
92831
|
+
};
|
|
92832
|
+
if (direction === 'undo') {
|
|
92833
|
+
for (let i = tx.commands.length - 1; i >= 0; i--) {
|
|
92834
|
+
apply(tx.commands[i], 'undo');
|
|
92835
|
+
}
|
|
92836
|
+
}
|
|
92837
|
+
else {
|
|
92838
|
+
for (let i = 0; i < tx.commands.length; i++) {
|
|
92839
|
+
apply(tx.commands[i], 'redo');
|
|
92840
|
+
}
|
|
92841
|
+
}
|
|
92842
|
+
}
|
|
92843
|
+
ensureWorkSheetInstance(sheetKey) {
|
|
92844
|
+
const existing = this.sheet.getWorkSheetInstance(sheetKey);
|
|
92845
|
+
if (existing) {
|
|
92846
|
+
return existing;
|
|
92847
|
+
}
|
|
92848
|
+
const def = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
92849
|
+
if (!def) {
|
|
92850
|
+
return undefined;
|
|
92851
|
+
}
|
|
92852
|
+
const instance = this.sheet.createWorkSheetInstance(def);
|
|
92853
|
+
instance.getElement().style.display = 'none';
|
|
92854
|
+
this.sheet.setWorkSheetInstance(sheetKey, instance);
|
|
92855
|
+
return instance;
|
|
92856
|
+
}
|
|
92857
|
+
getSheetOrder() {
|
|
92858
|
+
return this.sheet
|
|
92859
|
+
.getSheetManager()
|
|
92860
|
+
.getAllSheets()
|
|
92861
|
+
.map(s => s.sheetKey);
|
|
92862
|
+
}
|
|
92863
|
+
setSheetOrder(order) {
|
|
92864
|
+
const all = this.sheet.getSheetManager().getAllSheets();
|
|
92865
|
+
const map = new Map(all.map(s => [s.sheetKey, s]));
|
|
92866
|
+
const next = [];
|
|
92867
|
+
order.forEach(key => {
|
|
92868
|
+
const s = map.get(key);
|
|
92869
|
+
if (s) {
|
|
92870
|
+
next.push(s);
|
|
92871
|
+
}
|
|
92872
|
+
});
|
|
92873
|
+
if (next.length === all.length) {
|
|
92874
|
+
this.sheet.getSheetManager().sortSheets(next);
|
|
92875
|
+
this.sheet.updateSheetTabs();
|
|
92876
|
+
this.sheet.updateSheetMenu();
|
|
92877
|
+
}
|
|
92878
|
+
}
|
|
92879
|
+
getActiveSheetKey() {
|
|
92880
|
+
return this.sheet.getSheetManager().getActiveSheet()?.sheetKey;
|
|
92881
|
+
}
|
|
92882
|
+
}
|
|
92883
|
+
|
|
90766
92884
|
class VTableSheet {
|
|
90767
92885
|
container;
|
|
90768
92886
|
options;
|
|
@@ -90781,9 +92899,11 @@
|
|
|
90781
92899
|
formulaBarElement = null;
|
|
90782
92900
|
sheetTabElement = null;
|
|
90783
92901
|
mainMenuElement = null;
|
|
92902
|
+
undoRedoElement = null;
|
|
90784
92903
|
contentElement;
|
|
90785
92904
|
dragManager;
|
|
90786
92905
|
sheetTabEventHandler;
|
|
92906
|
+
workbookHistoryManager;
|
|
90787
92907
|
constructor(container, options) {
|
|
90788
92908
|
this.container = container;
|
|
90789
92909
|
this.options = this.mergeDefaultOptions(options);
|
|
@@ -90793,12 +92913,15 @@
|
|
|
90793
92913
|
this.tableEventRelay = new TableEventRelay(this);
|
|
90794
92914
|
this.eventManager = new DomEventManager(this);
|
|
90795
92915
|
this.dragManager = new SheetTabDragManager(this);
|
|
90796
|
-
this.menuManager = new MenuManager(this);
|
|
90797
92916
|
this.formulaUIManager = new FormulaUIManager(this);
|
|
90798
92917
|
this.sheetTabEventHandler = new SheetTabEventHandler(this);
|
|
90799
92918
|
this.spreadsheetEventManager = new SpreadSheetEventManager(this);
|
|
92919
|
+
this.workbookHistoryManager = new WorkbookHistoryManager(this);
|
|
92920
|
+
this.menuManager = new MenuManager(this);
|
|
90800
92921
|
this.initUI();
|
|
92922
|
+
this.workbookHistoryManager.suspend();
|
|
90801
92923
|
this.initSheets();
|
|
92924
|
+
this.workbookHistoryManager.resume();
|
|
90802
92925
|
this.resize();
|
|
90803
92926
|
}
|
|
90804
92927
|
mergeDefaultOptions(options) {
|
|
@@ -90827,10 +92950,7 @@
|
|
|
90827
92950
|
const topContainer = document.createElement('div');
|
|
90828
92951
|
topContainer.className = 'vtable-sheet-top-container';
|
|
90829
92952
|
this.rootElement.appendChild(topContainer);
|
|
90830
|
-
|
|
90831
|
-
this.mainMenuElement = this.menuManager.createMainMenu();
|
|
90832
|
-
topContainer.appendChild(this.mainMenuElement);
|
|
90833
|
-
}
|
|
92953
|
+
this.renderTopLeftControls(topContainer);
|
|
90834
92954
|
if (this.options.showFormulaBar) {
|
|
90835
92955
|
this.formulaBarElement = this.formulaUIManager.createFormulaBar();
|
|
90836
92956
|
topContainer.appendChild(this.formulaBarElement);
|
|
@@ -90844,6 +92964,38 @@
|
|
|
90844
92964
|
this.rootElement.appendChild(this.sheetTabElement);
|
|
90845
92965
|
}
|
|
90846
92966
|
}
|
|
92967
|
+
renderTopLeftControls(topContainer) {
|
|
92968
|
+
if (this.mainMenuElement?.parentElement) {
|
|
92969
|
+
this.mainMenuElement.parentElement.removeChild(this.mainMenuElement);
|
|
92970
|
+
this.mainMenuElement = null;
|
|
92971
|
+
}
|
|
92972
|
+
if (this.undoRedoElement?.parentElement) {
|
|
92973
|
+
this.undoRedoElement.parentElement.removeChild(this.undoRedoElement);
|
|
92974
|
+
this.undoRedoElement = null;
|
|
92975
|
+
}
|
|
92976
|
+
this.menuManager.release();
|
|
92977
|
+
const showMainMenu = !!this.options.mainMenu?.show;
|
|
92978
|
+
const showUndoRedo = this.options.undoRedo?.show ?? true;
|
|
92979
|
+
if (showMainMenu) {
|
|
92980
|
+
this.mainMenuElement = this.menuManager.createMainMenu();
|
|
92981
|
+
if (topContainer.firstChild) {
|
|
92982
|
+
topContainer.insertBefore(this.mainMenuElement, topContainer.firstChild);
|
|
92983
|
+
}
|
|
92984
|
+
else {
|
|
92985
|
+
topContainer.appendChild(this.mainMenuElement);
|
|
92986
|
+
}
|
|
92987
|
+
return;
|
|
92988
|
+
}
|
|
92989
|
+
if (showUndoRedo) {
|
|
92990
|
+
this.undoRedoElement = this.menuManager.createUndoRedoOnly();
|
|
92991
|
+
if (topContainer.firstChild) {
|
|
92992
|
+
topContainer.insertBefore(this.undoRedoElement, topContainer.firstChild);
|
|
92993
|
+
}
|
|
92994
|
+
else {
|
|
92995
|
+
topContainer.appendChild(this.undoRedoElement);
|
|
92996
|
+
}
|
|
92997
|
+
}
|
|
92998
|
+
}
|
|
90847
92999
|
createSheetTab() {
|
|
90848
93000
|
const addIcon = '<svg viewBox="0 0 24 24" width="16" height="16">' +
|
|
90849
93001
|
'<path fill="currentColor" d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"/>' +
|
|
@@ -91009,26 +93161,14 @@
|
|
|
91009
93161
|
}
|
|
91010
93162
|
}
|
|
91011
93163
|
addSheet(sheet) {
|
|
91012
|
-
this.
|
|
91013
|
-
this.updateSheetTabs();
|
|
91014
|
-
this.updateSheetMenu();
|
|
93164
|
+
this.workbookHistoryManager.addSheet({ sheet, activate: false });
|
|
91015
93165
|
}
|
|
91016
93166
|
removeSheet(sheetKey) {
|
|
91017
93167
|
if (this.sheetManager.getSheetCount() <= 1) {
|
|
91018
93168
|
showSnackbar('至少保留一个工作表', 1300);
|
|
91019
93169
|
return;
|
|
91020
93170
|
}
|
|
91021
|
-
|
|
91022
|
-
if (instance) {
|
|
91023
|
-
instance.release();
|
|
91024
|
-
this.workSheetInstances.delete(sheetKey);
|
|
91025
|
-
}
|
|
91026
|
-
const newActiveSheetKey = this.sheetManager.removeSheet(sheetKey);
|
|
91027
|
-
if (newActiveSheetKey) {
|
|
91028
|
-
this.activateSheet(newActiveSheetKey);
|
|
91029
|
-
}
|
|
91030
|
-
this.updateSheetTabs();
|
|
91031
|
-
this.updateSheetMenu();
|
|
93171
|
+
this.workbookHistoryManager.removeSheet(sheetKey);
|
|
91032
93172
|
}
|
|
91033
93173
|
getSheetCount() {
|
|
91034
93174
|
return this.sheetManager.getSheetCount();
|
|
@@ -91040,10 +93180,10 @@
|
|
|
91040
93180
|
return this.sheetManager.getAllSheets();
|
|
91041
93181
|
}
|
|
91042
93182
|
createWorkSheetInstance(sheetDefine) {
|
|
91043
|
-
formulaEditor.setSheet(this);
|
|
91044
93183
|
const contentWidth = this.contentElement.clientWidth;
|
|
91045
93184
|
const contentHeight = this.contentElement.clientHeight;
|
|
91046
93185
|
sheetDefine.dragOrder = sheetDefine.dragOrder ?? this.options.dragOrder;
|
|
93186
|
+
const formulaEditor = createFormulaEditor();
|
|
91047
93187
|
const sheet = new WorkSheet(this, {
|
|
91048
93188
|
...sheetDefine,
|
|
91049
93189
|
container: this.contentElement,
|
|
@@ -91053,8 +93193,8 @@
|
|
|
91053
93193
|
defaultColWidth: this.options.defaultColWidth,
|
|
91054
93194
|
dragOrder: sheetDefine.dragOrder,
|
|
91055
93195
|
plugins: getTablePlugins(sheetDefine, this.options, this),
|
|
91056
|
-
headerEditor:
|
|
91057
|
-
editor:
|
|
93196
|
+
headerEditor: formulaEditor,
|
|
93197
|
+
editor: formulaEditor,
|
|
91058
93198
|
select: {
|
|
91059
93199
|
makeSelectCellVisible: false
|
|
91060
93200
|
},
|
|
@@ -91062,6 +93202,7 @@
|
|
|
91062
93202
|
customMergeCell: sheetDefine.cellMerge,
|
|
91063
93203
|
theme: sheetDefine.theme?.tableTheme || this.options.theme?.tableTheme
|
|
91064
93204
|
});
|
|
93205
|
+
formulaEditor.setSheet(this);
|
|
91065
93206
|
try {
|
|
91066
93207
|
const normalizedData = sheetDefine.data
|
|
91067
93208
|
? this.formulaManager.normalizeSheetData(sheetDefine.data, sheet.tableInstance)
|
|
@@ -91137,8 +93278,7 @@
|
|
|
91137
93278
|
rowCount: 100,
|
|
91138
93279
|
data: []
|
|
91139
93280
|
};
|
|
91140
|
-
this.
|
|
91141
|
-
this.activateSheet(key);
|
|
93281
|
+
this.workbookHistoryManager.addSheet({ sheet: newSheet, activate: true });
|
|
91142
93282
|
}
|
|
91143
93283
|
updateFormulaBar() {
|
|
91144
93284
|
this.formulaUIManager.updateFormulaBar();
|
|
@@ -91155,9 +93295,39 @@
|
|
|
91155
93295
|
getSheetManager() {
|
|
91156
93296
|
return this.sheetManager;
|
|
91157
93297
|
}
|
|
93298
|
+
getWorkbookHistoryManager() {
|
|
93299
|
+
return this.workbookHistoryManager;
|
|
93300
|
+
}
|
|
91158
93301
|
getActiveSheet() {
|
|
91159
93302
|
return this.activeWorkSheet;
|
|
91160
93303
|
}
|
|
93304
|
+
getWorkSheetInstance(sheetKey) {
|
|
93305
|
+
return this.workSheetInstances.get(sheetKey);
|
|
93306
|
+
}
|
|
93307
|
+
setWorkSheetInstance(sheetKey, instance) {
|
|
93308
|
+
this.workSheetInstances.set(sheetKey, instance);
|
|
93309
|
+
}
|
|
93310
|
+
deleteWorkSheetInstance(sheetKey) {
|
|
93311
|
+
this.workSheetInstances.delete(sheetKey);
|
|
93312
|
+
}
|
|
93313
|
+
renameSheet(sheetKey, newTitle) {
|
|
93314
|
+
this.workbookHistoryManager.renameSheet(sheetKey, newTitle);
|
|
93315
|
+
}
|
|
93316
|
+
reorderSheet(sourceKey, targetKey, position) {
|
|
93317
|
+
this.workbookHistoryManager.reorderSheet(sourceKey, targetKey, position);
|
|
93318
|
+
}
|
|
93319
|
+
undo() {
|
|
93320
|
+
this.workbookHistoryManager.undo();
|
|
93321
|
+
}
|
|
93322
|
+
redo() {
|
|
93323
|
+
this.workbookHistoryManager.redo();
|
|
93324
|
+
}
|
|
93325
|
+
startHistoryTransaction() {
|
|
93326
|
+
this.workbookHistoryManager.startTransaction();
|
|
93327
|
+
}
|
|
93328
|
+
endHistoryTransaction() {
|
|
93329
|
+
this.workbookHistoryManager.endTransaction();
|
|
93330
|
+
}
|
|
91161
93331
|
onTableEvent(type, callback) {
|
|
91162
93332
|
this.tableEventRelay.onTableEvent(type, callback);
|
|
91163
93333
|
}
|
|
@@ -91268,22 +93438,30 @@
|
|
|
91268
93438
|
}
|
|
91269
93439
|
updateMainMenu(mainMenu) {
|
|
91270
93440
|
this.options.mainMenu = mainMenu;
|
|
91271
|
-
this.
|
|
93441
|
+
const topContainer = this.rootElement.querySelector('.vtable-sheet-top-container');
|
|
93442
|
+
if (!topContainer) {
|
|
93443
|
+
return;
|
|
93444
|
+
}
|
|
93445
|
+
this.renderTopLeftControls(topContainer);
|
|
91272
93446
|
}
|
|
91273
93447
|
updateOption(options) {
|
|
91274
93448
|
if (!options) {
|
|
91275
93449
|
return;
|
|
91276
93450
|
}
|
|
91277
93451
|
const hasMainMenu = typeof options.mainMenu !== 'undefined';
|
|
91278
|
-
|
|
91279
|
-
this.updateMainMenu(options.mainMenu);
|
|
91280
|
-
}
|
|
93452
|
+
const hasUndoRedo = typeof options.undoRedo !== 'undefined';
|
|
91281
93453
|
const pluginModulesChanged = pluginIsChanged(this.options.VTablePluginModules, options.VTablePluginModules);
|
|
91282
93454
|
const tableThemeChanged = tableThemeIsChanged(this.options.theme?.tableTheme, options.theme?.tableTheme);
|
|
91283
93455
|
this.options = {
|
|
91284
93456
|
...this.options,
|
|
91285
93457
|
...options
|
|
91286
93458
|
};
|
|
93459
|
+
if (hasMainMenu || hasUndoRedo) {
|
|
93460
|
+
const topContainer = this.rootElement.querySelector('.vtable-sheet-top-container');
|
|
93461
|
+
if (topContainer) {
|
|
93462
|
+
this.renderTopLeftControls(topContainer);
|
|
93463
|
+
}
|
|
93464
|
+
}
|
|
91287
93465
|
if (Array.isArray(options.sheets) || pluginModulesChanged || tableThemeChanged) {
|
|
91288
93466
|
this.updateSheets(options);
|
|
91289
93467
|
}
|
|
@@ -91334,6 +93512,7 @@
|
|
|
91334
93512
|
this.workSheetInstances.set(next_sheetDefine.sheetKey, newInstance);
|
|
91335
93513
|
return;
|
|
91336
93514
|
}
|
|
93515
|
+
const formulaEditor = createFormulaEditor();
|
|
91337
93516
|
const sheetOption = {
|
|
91338
93517
|
sheetTitle: next_sheetDefine.sheetTitle,
|
|
91339
93518
|
sheetKey: next_sheetDefine.sheetKey,
|
|
@@ -91349,8 +93528,8 @@
|
|
|
91349
93528
|
defaultColWidth: this.options.defaultColWidth,
|
|
91350
93529
|
dragOrder: next_sheetDefine.dragOrder,
|
|
91351
93530
|
plugins: getTablePlugins(next_sheetDefine, this.options, this),
|
|
91352
|
-
headerEditor:
|
|
91353
|
-
editor:
|
|
93531
|
+
headerEditor: formulaEditor,
|
|
93532
|
+
editor: formulaEditor,
|
|
91354
93533
|
select: {
|
|
91355
93534
|
makeSelectCellVisible: false
|
|
91356
93535
|
},
|
|
@@ -91360,6 +93539,7 @@
|
|
|
91360
93539
|
data: next_sheetDefine.data,
|
|
91361
93540
|
columns: next_sheetDefine.columns
|
|
91362
93541
|
};
|
|
93542
|
+
formulaEditor.setSheet(this);
|
|
91363
93543
|
instance.updateSheetOption(sheetOption);
|
|
91364
93544
|
});
|
|
91365
93545
|
try {
|
|
@@ -92160,7 +94340,7 @@
|
|
|
92160
94340
|
display: flex;
|
|
92161
94341
|
align-items: center;
|
|
92162
94342
|
background-color: #fff;
|
|
92163
|
-
width:
|
|
94343
|
+
width: auto;
|
|
92164
94344
|
/* 内容居中 */
|
|
92165
94345
|
justify-content: center;
|
|
92166
94346
|
flex-shrink: 0; /* 防止菜单被压缩 */
|
|
@@ -92169,6 +94349,17 @@
|
|
|
92169
94349
|
background-color: #f0f0f0;
|
|
92170
94350
|
}
|
|
92171
94351
|
|
|
94352
|
+
.vtable-sheet-undo-redo {
|
|
94353
|
+
display: flex;
|
|
94354
|
+
flex-direction: row;
|
|
94355
|
+
align-items: center;
|
|
94356
|
+
height: 30px;
|
|
94357
|
+
padding: 0;
|
|
94358
|
+
border-bottom: 1px solid #e0e0e0;
|
|
94359
|
+
background-color: #fff;
|
|
94360
|
+
flex-shrink: 0;
|
|
94361
|
+
}
|
|
94362
|
+
|
|
92172
94363
|
.vtable-sheet-main-menu-button {
|
|
92173
94364
|
display: flex;
|
|
92174
94365
|
align-items: center;
|
|
@@ -92177,6 +94368,38 @@
|
|
|
92177
94368
|
height: 30px;
|
|
92178
94369
|
}
|
|
92179
94370
|
|
|
94371
|
+
.vtable-sheet-main-menu-actions {
|
|
94372
|
+
display: flex;
|
|
94373
|
+
align-items: center;
|
|
94374
|
+
height: 30px;
|
|
94375
|
+
gap: 4px;
|
|
94376
|
+
padding-right: 6px;
|
|
94377
|
+
}
|
|
94378
|
+
|
|
94379
|
+
.vtable-sheet-main-menu-action {
|
|
94380
|
+
display: inline-flex;
|
|
94381
|
+
align-items: center;
|
|
94382
|
+
justify-content: center;
|
|
94383
|
+
width: 28px;
|
|
94384
|
+
height: 28px;
|
|
94385
|
+
border: none;
|
|
94386
|
+
background: transparent;
|
|
94387
|
+
color: #666;
|
|
94388
|
+
cursor: pointer;
|
|
94389
|
+
padding: 0;
|
|
94390
|
+
}
|
|
94391
|
+
|
|
94392
|
+
.vtable-sheet-main-menu-action:hover:not(:disabled) {
|
|
94393
|
+
color: #333;
|
|
94394
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
94395
|
+
border-radius: 4px;
|
|
94396
|
+
}
|
|
94397
|
+
|
|
94398
|
+
.vtable-sheet-main-menu-action:disabled {
|
|
94399
|
+
opacity: 0.4;
|
|
94400
|
+
cursor: not-allowed;
|
|
94401
|
+
}
|
|
94402
|
+
|
|
92180
94403
|
/* 菜单项容器 */
|
|
92181
94404
|
.vtable-sheet-main-menu-container {
|
|
92182
94405
|
position: absolute;
|
|
@@ -92965,7 +95188,7 @@
|
|
|
92965
95188
|
importStyle();
|
|
92966
95189
|
}
|
|
92967
95190
|
|
|
92968
|
-
const version = "1.
|
|
95191
|
+
const version = "1.24.0";
|
|
92969
95192
|
importStyles();
|
|
92970
95193
|
|
|
92971
95194
|
exports.TYPES = index;
|