@byteluck-fe/model-driven-engine 2.7.0-alpha.15 → 2.7.0-alpha.15a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/common/ActionManager.js +40 -157
- package/dist/esm/common/DataManager.js +20 -129
- package/dist/esm/common/Engine.js +322 -412
- package/dist/esm/common/OkWorker.js +13 -27
- package/dist/esm/common/Runtime.js +78 -54
- package/dist/esm/common/Store.js +50 -51
- package/dist/esm/common/checkerValue.js +39 -39
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +47 -47
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +59 -67
- package/dist/esm/plugins/ControlsEventPlugin.js +68 -191
- package/dist/esm/plugins/ES6ModulePlugin.js +8 -24
- package/dist/esm/plugins/LifecycleEventPlugin.js +64 -183
- package/dist/esm/plugins/StylePlugin.js +7 -22
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +7 -5
- package/dist/index.umd.js +10 -10
- package/dist/types/common/Engine.d.ts +10 -9
- package/dist/types/common/Runtime.d.ts +2 -1
- package/dist/types/common/Store.d.ts +5 -5
- package/dist/types/common/proxyState.d.ts +3 -3
- package/dist/types/plugins/ControlsEventPlugin.d.ts +1 -1
- package/dist/types/plugins/ES6ModulePlugin.d.ts +4 -4
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +1 -1
- package/dist/types/plugins/StylePlugin.d.ts +1 -1
- package/package.json +4 -4
|
@@ -157,9 +157,9 @@ function _createSuper(Derived) {
|
|
|
157
157
|
return _possibleConstructorReturn(this, result);
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
-
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from
|
|
161
|
-
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from
|
|
162
|
-
import { camelizeKeys } from
|
|
160
|
+
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from '@byteluck-fe/model-driven-shared';
|
|
161
|
+
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from '@byteluck-fe/model-driven-core';
|
|
162
|
+
import { camelizeKeys } from 'humps';
|
|
163
163
|
var ValueChecker = function ValueChecker() {
|
|
164
164
|
"use strict";
|
|
165
165
|
_classCallCheck(this, ValueChecker);
|
|
@@ -183,7 +183,7 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
183
183
|
key: "transform",
|
|
184
184
|
value: function transform(value) {
|
|
185
185
|
if (value === null || value === undefined) {
|
|
186
|
-
return
|
|
186
|
+
return '';
|
|
187
187
|
}
|
|
188
188
|
if (!isPlainObject(value) && !isFunction(value)) {
|
|
189
189
|
return String(value);
|
|
@@ -210,14 +210,14 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
210
210
|
// 数字类型允许是空字符串,用于置空数据
|
|
211
211
|
key: "validate",
|
|
212
212
|
value: function validate(value) {
|
|
213
|
-
return isNumber(value) || value ===
|
|
213
|
+
return isNumber(value) || value === '';
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
key: "transform",
|
|
218
218
|
value: function transform(value) {
|
|
219
219
|
if (value === null || value === undefined) {
|
|
220
|
-
return
|
|
220
|
+
return '';
|
|
221
221
|
}
|
|
222
222
|
var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
|
|
223
223
|
if (!Number.isNaN(newValue) && newValue !== undefined) {
|
|
@@ -246,28 +246,28 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
246
246
|
},
|
|
247
247
|
{
|
|
248
248
|
key: "transform",
|
|
249
|
-
value: function transform(
|
|
249
|
+
value: function transform(value1) {
|
|
250
250
|
var getStringValueArray = function getStringValueArray(value) {
|
|
251
251
|
return value.map(function(item) {
|
|
252
|
-
return !item ?
|
|
252
|
+
return !item ? '' : String(item);
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
|
-
if (
|
|
255
|
+
if (value1 === undefined || value1 === null) {
|
|
256
256
|
return [];
|
|
257
257
|
}
|
|
258
|
-
if (isArray(
|
|
259
|
-
return getStringValueArray(
|
|
258
|
+
if (isArray(value1)) {
|
|
259
|
+
return getStringValueArray(value1);
|
|
260
260
|
}
|
|
261
|
-
if (isString(
|
|
261
|
+
if (isString(value1) && isJSONArray(value1)) {
|
|
262
262
|
try {
|
|
263
|
-
var newValue = JSON.parse(
|
|
263
|
+
var newValue = JSON.parse(value1);
|
|
264
264
|
if (Array.isArray(newValue)) {
|
|
265
265
|
return getStringValueArray(newValue);
|
|
266
266
|
}
|
|
267
267
|
} catch (e) {}
|
|
268
268
|
}
|
|
269
269
|
return [
|
|
270
|
-
String(
|
|
270
|
+
String(value1)
|
|
271
271
|
];
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -291,31 +291,31 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
key: "transform",
|
|
294
|
-
value: function transform(
|
|
294
|
+
value: function transform(value2) {
|
|
295
295
|
var getNumberValueArray = function getNumberValueArray(value) {
|
|
296
296
|
return value.map(function(item) {
|
|
297
|
-
return !item && item !== 0 ?
|
|
297
|
+
return !item && item !== 0 ? '' : Number(item);
|
|
298
298
|
}).filter(function(item) {
|
|
299
|
-
return item ===
|
|
299
|
+
return item === '' || !Number.isNaN(item);
|
|
300
300
|
});
|
|
301
301
|
};
|
|
302
|
-
if (
|
|
302
|
+
if (value2 === undefined || value2 === null) {
|
|
303
303
|
return [];
|
|
304
304
|
}
|
|
305
|
-
if (isArray(
|
|
306
|
-
return getNumberValueArray(
|
|
305
|
+
if (isArray(value2)) {
|
|
306
|
+
return getNumberValueArray(value2);
|
|
307
307
|
}
|
|
308
|
-
if (isString(
|
|
308
|
+
if (isString(value2) && isJSONArray(value2)) {
|
|
309
309
|
try {
|
|
310
|
-
var newValue = JSON.parse(
|
|
310
|
+
var newValue = JSON.parse(value2);
|
|
311
311
|
if (isArray(newValue)) {
|
|
312
312
|
return getNumberValueArray(newValue);
|
|
313
313
|
}
|
|
314
314
|
} catch (e) {}
|
|
315
315
|
}
|
|
316
|
-
var newValue1 = Number(
|
|
316
|
+
var newValue1 = Number(value2);
|
|
317
317
|
if (Number.isNaN(newValue1)) {
|
|
318
|
-
throw "".concat(
|
|
318
|
+
throw "".concat(value2, " is not a number array");
|
|
319
319
|
}
|
|
320
320
|
return [
|
|
321
321
|
newValue1
|
|
@@ -338,13 +338,13 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
338
338
|
key: "validate",
|
|
339
339
|
value: function validate(value) {
|
|
340
340
|
return(// value instanceof AmountValue ||
|
|
341
|
-
isPlainObject(value) &&
|
|
341
|
+
(isPlainObject(value) && 'amount' in value && isNumber(value.amount) && 'currency' in value && isString(value.currency)));
|
|
342
342
|
}
|
|
343
343
|
},
|
|
344
344
|
{
|
|
345
345
|
key: "transform",
|
|
346
346
|
value: function transform(value, oldValue) {
|
|
347
|
-
if (value === undefined || value === null || value ===
|
|
347
|
+
if (value === undefined || value === null || value === '') {
|
|
348
348
|
return new AmountValue({
|
|
349
349
|
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
350
350
|
});
|
|
@@ -389,13 +389,13 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
389
389
|
key: "validate",
|
|
390
390
|
value: function validate(value) {
|
|
391
391
|
return(// value instanceof RangeDateValue ||
|
|
392
|
-
isPlainObject(value) &&
|
|
392
|
+
(isPlainObject(value) && 'min' in value && isString(value.min) && 'max' in value && isString(value.max)));
|
|
393
393
|
}
|
|
394
394
|
},
|
|
395
395
|
{
|
|
396
396
|
key: "transform",
|
|
397
397
|
value: function transform(value, oldValue) {
|
|
398
|
-
if (value === undefined || value === null || value ===
|
|
398
|
+
if (value === undefined || value === null || value === '') {
|
|
399
399
|
return new RangeDateValue();
|
|
400
400
|
}
|
|
401
401
|
var result;
|
|
@@ -437,13 +437,13 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
437
437
|
key: "validate",
|
|
438
438
|
value: function validate(value) {
|
|
439
439
|
return(// value instanceof CalcValue ||
|
|
440
|
-
isPlainObject(value) &&
|
|
440
|
+
(isPlainObject(value) && 'result' in value && isNumber(value.result) && 'unit' in value && isString(value.unit)));
|
|
441
441
|
}
|
|
442
442
|
},
|
|
443
443
|
{
|
|
444
444
|
key: "transform",
|
|
445
445
|
value: function transform(value, oldValue) {
|
|
446
|
-
if (value === undefined || value === null || value ===
|
|
446
|
+
if (value === undefined || value === null || value === '') {
|
|
447
447
|
return new CalcValue({
|
|
448
448
|
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
449
449
|
});
|
|
@@ -504,7 +504,7 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
504
504
|
{
|
|
505
505
|
key: "transform",
|
|
506
506
|
value: function transform(value, oldValue) {
|
|
507
|
-
if (value === undefined || value === null || value ===
|
|
507
|
+
if (value === undefined || value === null || value === '') {
|
|
508
508
|
return new AddressValue();
|
|
509
509
|
}
|
|
510
510
|
var result;
|
|
@@ -588,22 +588,22 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
588
588
|
}();
|
|
589
589
|
function getFieldTypeFromKey(key) {
|
|
590
590
|
if ([
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
'min',
|
|
592
|
+
'max',
|
|
593
|
+
'currency',
|
|
594
|
+
'unit'
|
|
595
595
|
].includes(key)) {
|
|
596
596
|
return FieldTypes.VARCHAR;
|
|
597
597
|
} else if ([
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
'result',
|
|
599
|
+
'amount'
|
|
600
600
|
].includes(key)) {
|
|
601
601
|
return FieldTypes.DECIMAL;
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
export function checkerValue(fieldType, key, value, oldValue) {
|
|
605
|
-
var
|
|
606
|
-
var getCheckerFieldType = (
|
|
605
|
+
var ref;
|
|
606
|
+
var getCheckerFieldType = (ref = getFieldTypeFromKey(key)) !== null && ref !== void 0 ? ref : fieldType;
|
|
607
607
|
var checker = ValueCheckerFactory.getValueChecker(getCheckerFieldType);
|
|
608
608
|
if (!checker || checker.validate(value)) {
|
|
609
609
|
return value;
|
package/dist/esm/common/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './Engine';
|
|
2
|
+
export * from './Plugin';
|
|
@@ -23,22 +23,22 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
23
23
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
24
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
25
25
|
}
|
|
26
|
+
import { CONTROL_BASE_TYPE, error, logerror } from '@byteluck-fe/model-driven-shared';
|
|
26
27
|
var cc = console;
|
|
27
|
-
import { CONTROL_BASE_TYPE, error, logerror } from "@byteluck-fe/model-driven-shared";
|
|
28
28
|
var proxyArrayApi = [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
'splice',
|
|
30
|
+
'push',
|
|
31
|
+
'shift',
|
|
32
|
+
'pop',
|
|
33
|
+
'unshift',
|
|
34
|
+
'reverse',
|
|
35
35
|
];
|
|
36
|
-
export var engineProxyFlag = Symbol(
|
|
37
|
-
export var engineTargetKey = Symbol(
|
|
38
|
-
export var engineArrayBeforeSetCallbackFlag = Symbol(
|
|
39
|
-
export var engineProxyThisKey = Symbol(
|
|
36
|
+
export var engineProxyFlag = Symbol('__engineProxy__');
|
|
37
|
+
export var engineTargetKey = Symbol('__engineTarget__');
|
|
38
|
+
export var engineArrayBeforeSetCallbackFlag = Symbol('__engineArrayBeforeSetCallbackFlag__');
|
|
39
|
+
export var engineProxyThisKey = Symbol('__engineProxyThisKey__');
|
|
40
40
|
var currentHandlerState = {
|
|
41
|
-
type:
|
|
41
|
+
type: '',
|
|
42
42
|
args: [],
|
|
43
43
|
callback: emptyFn
|
|
44
44
|
};
|
|
@@ -55,16 +55,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
55
55
|
// 操作下标
|
|
56
56
|
// Number(propertyKey) > target.length 说明当前操作的下标已经超过了安全范围(数组的运行长度,比如[1,2,3],它的长度为3,可操作的下标为0,1,2,3,如果操作4将会产生一个empty index)
|
|
57
57
|
if (index > target.length) {
|
|
58
|
-
error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(
|
|
58
|
+
error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(','), " for array operations"));
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
// 不是操作下标,而是直接操作length或者自定义属性等
|
|
62
62
|
var isNotHandlerIndex = Number.isNaN(index);
|
|
63
|
-
if (isNotHandlerIndex && propertyKey !==
|
|
63
|
+
if (isNotHandlerIndex && propertyKey !== 'length') {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
// 直接操作length
|
|
67
|
-
if (propertyKey ===
|
|
67
|
+
if (propertyKey === 'length') {
|
|
68
68
|
var newLength = value;
|
|
69
69
|
var oldLength = target.length;
|
|
70
70
|
if (newLength > target.length) {
|
|
@@ -76,9 +76,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
76
76
|
}
|
|
77
77
|
// 通过操作length删除旧的行
|
|
78
78
|
return function() {
|
|
79
|
-
return callback.call(null, target, thisKey,
|
|
79
|
+
return callback.call(null, target, thisKey, 'splice', [
|
|
80
80
|
newLength,
|
|
81
|
-
oldLength - newLength
|
|
81
|
+
oldLength - newLength,
|
|
82
82
|
]);
|
|
83
83
|
};
|
|
84
84
|
// 直接操作下标
|
|
@@ -86,13 +86,13 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
86
86
|
// 正常操作
|
|
87
87
|
if (index === target.length) {
|
|
88
88
|
return function() {
|
|
89
|
-
return callback.call(null, target, thisKey,
|
|
89
|
+
return callback.call(null, target, thisKey, 'push', [
|
|
90
90
|
value
|
|
91
91
|
]);
|
|
92
92
|
};
|
|
93
93
|
} else {
|
|
94
94
|
return function() {
|
|
95
|
-
return callback.call(null, target, thisKey,
|
|
95
|
+
return callback.call(null, target, thisKey, 'splice', [
|
|
96
96
|
index,
|
|
97
97
|
1,
|
|
98
98
|
value
|
|
@@ -124,9 +124,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
124
124
|
}
|
|
125
125
|
return Reflect.get(target, propertyKey, receiver);
|
|
126
126
|
},
|
|
127
|
-
set: function set(target, propertyKey,
|
|
127
|
+
set: function set(target, propertyKey, value1, receiver) {
|
|
128
128
|
var reProxyState = function reProxyState(value) {
|
|
129
|
-
if (typeof value ===
|
|
129
|
+
if (typeof value === 'object' && value !== null) {
|
|
130
130
|
// @ts-ignore
|
|
131
131
|
if (value[engineProxyFlag] !== true) {
|
|
132
132
|
return proxyState(value, callback, beforeSetCallback, concatKey);
|
|
@@ -137,19 +137,19 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
var newValue =
|
|
140
|
+
var newValue = value1;
|
|
141
141
|
// @ts-ignore
|
|
142
142
|
var oldValue = target[propertyKey];
|
|
143
|
-
var concatKey = thisKey ===
|
|
144
|
-
var
|
|
145
|
-
newValue = (
|
|
143
|
+
var concatKey = thisKey === '' ? propertyKey : thisKey + '.' + propertyKey;
|
|
144
|
+
var ref;
|
|
145
|
+
newValue = (ref = reProxyState(value1)) !== null && ref !== void 0 ? ref : newValue;
|
|
146
146
|
// 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
|
|
147
147
|
var setResult;
|
|
148
148
|
// TODO 数组拦截操作需要重构,优化现有逻辑
|
|
149
149
|
// TODO 直接操作下标改动明细表时,没有对行数据进行checker
|
|
150
150
|
if (Array.isArray(target)) {
|
|
151
151
|
// 操作数组的时候,不需要使用拼接的thisKey,先判断执行的是否是违规操作,违规操作的话会报错,不允许继续执行,正常操作的话,返回一个回调函数,用于在值修改完之后触发
|
|
152
|
-
var nextHandler = ArrayHandler(target, propertyKey,
|
|
152
|
+
var nextHandler = ArrayHandler(target, propertyKey, value1, thisKey, callback);
|
|
153
153
|
setResult = Reflect.set(target, propertyKey, newValue, receiver);
|
|
154
154
|
if (nextHandler) {
|
|
155
155
|
nextHandler();
|
|
@@ -171,7 +171,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
171
171
|
return true;
|
|
172
172
|
}
|
|
173
173
|
setResult = Reflect.set(target, propertyKey, newValue, receiver);
|
|
174
|
-
callback.call(null, target, concatKey,
|
|
174
|
+
callback.call(null, target, concatKey, value1, oldValue);
|
|
175
175
|
}
|
|
176
176
|
return setResult;
|
|
177
177
|
}
|
|
@@ -184,15 +184,15 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
184
184
|
* @param beforeSetCallback
|
|
185
185
|
* @param prevKey 递归对象的key
|
|
186
186
|
* */ export function proxyState(state, callback, beforeSetCallback) {
|
|
187
|
-
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] :
|
|
187
|
+
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : '';
|
|
188
188
|
// 冻结的对象不需要再执行proxy,否则会报错
|
|
189
189
|
if (Object.isFrozen(state)) {
|
|
190
190
|
return state;
|
|
191
191
|
}
|
|
192
192
|
for(var key in state){
|
|
193
|
-
var concatKey = prevKey ===
|
|
193
|
+
var concatKey = prevKey === '' ? key : prevKey + '.' + key;
|
|
194
194
|
var obj = state[key];
|
|
195
|
-
if (typeof obj ===
|
|
195
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
196
196
|
// @ts-ignore
|
|
197
197
|
state[key] = proxyState(obj, callback, beforeSetCallback, concatKey);
|
|
198
198
|
}
|
|
@@ -203,7 +203,7 @@ function flatInstanceForChildren(controls) {
|
|
|
203
203
|
var result = [];
|
|
204
204
|
controls.forEach(function(item) {
|
|
205
205
|
result.push(item);
|
|
206
|
-
if (item.controlType ===
|
|
206
|
+
if (item.controlType === 'layout' || item.controlType === 'wrap') {
|
|
207
207
|
var _result;
|
|
208
208
|
(_result = result).push.apply(_result, _toConsumableArray(flatInstanceForChildren(item.children)));
|
|
209
209
|
}
|
|
@@ -214,9 +214,9 @@ function flatInstanceForChildren(controls) {
|
|
|
214
214
|
* 在flatInstance中通过key查找出对应的instance
|
|
215
215
|
* @param flatInstance 拍平的instance数组
|
|
216
216
|
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
217
|
-
* */ export function findItem(flatInstance,
|
|
218
|
-
if (
|
|
219
|
-
var keys =
|
|
217
|
+
* */ export function findItem(flatInstance, key1, instanceMap) {
|
|
218
|
+
if (key1 === '') return undefined;
|
|
219
|
+
var keys = key1.split('.');
|
|
220
220
|
if (keys.length === 0) return undefined;
|
|
221
221
|
var oneKey = keys[0];
|
|
222
222
|
var otherKeys = keys.slice(1);
|
|
@@ -242,31 +242,31 @@ function flatInstanceForChildren(controls) {
|
|
|
242
242
|
// 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
|
|
243
243
|
return findEndItem ? findEndItem : prevItem.controlType === CONTROL_BASE_TYPE.FORM ? prevItem : undefined;
|
|
244
244
|
} else {
|
|
245
|
-
var
|
|
246
|
-
var
|
|
245
|
+
var ref;
|
|
246
|
+
var ref1;
|
|
247
247
|
// 如果有children,则取children中对应的下标,没有的话一直返回prevItem
|
|
248
|
-
return (
|
|
248
|
+
return (ref1 = prevItem === null || prevItem === void 0 ? void 0 : (ref = prevItem.children) === null || ref === void 0 ? void 0 : ref[index]) !== null && ref1 !== void 0 ? ref1 : prevItem;
|
|
249
249
|
}
|
|
250
250
|
}, initInstance);
|
|
251
251
|
}
|
|
252
252
|
function getArrayNewValue(type, args) {
|
|
253
253
|
if ([
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
'push',
|
|
255
|
+
'unshift'
|
|
256
256
|
].includes(type)) {
|
|
257
257
|
return args;
|
|
258
|
-
} else if (type ===
|
|
258
|
+
} else if (type === 'splice') {
|
|
259
259
|
return args.slice(2);
|
|
260
260
|
}
|
|
261
261
|
return [];
|
|
262
262
|
}
|
|
263
263
|
function getArrayNewArgs(type, args, value) {
|
|
264
264
|
if ([
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
'push',
|
|
266
|
+
'unshift'
|
|
267
267
|
].includes(type)) {
|
|
268
268
|
return value;
|
|
269
|
-
} else if (type ===
|
|
269
|
+
} else if (type === 'splice') {
|
|
270
270
|
return args.slice(0, 2).concat(value);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
@@ -285,9 +285,9 @@ function getArrayNewArgs(type, args, value) {
|
|
|
285
285
|
var result;
|
|
286
286
|
var addValue = getArrayNewValue(key, args);
|
|
287
287
|
if (addValue.length) {
|
|
288
|
-
var
|
|
288
|
+
var _obj, ref;
|
|
289
289
|
// @ts-ignore
|
|
290
|
-
var newValue = (
|
|
290
|
+
var newValue = (ref = (_obj = this)[engineArrayBeforeSetCallbackFlag]) === null || ref === void 0 ? void 0 : ref.call(_obj, // @ts-ignore
|
|
291
291
|
this[engineTargetKey], // @ts-ignore
|
|
292
292
|
this[engineProxyThisKey], addValue);
|
|
293
293
|
var newArgs = getArrayNewArgs(key, args, newValue);
|
|
@@ -301,8 +301,8 @@ function getArrayNewArgs(type, args, value) {
|
|
|
301
301
|
// @ts-ignore
|
|
302
302
|
result = oldApiHandler.apply(this, args);
|
|
303
303
|
}
|
|
304
|
-
typeof currentHandlerState.callback ===
|
|
305
|
-
currentHandlerState.type =
|
|
304
|
+
typeof currentHandlerState.callback === 'function' && currentHandlerState.callback(key, args, result);
|
|
305
|
+
currentHandlerState.type = '';
|
|
306
306
|
currentHandlerState.args = [];
|
|
307
307
|
currentHandlerState.callback = emptyFn;
|
|
308
308
|
return result;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './plugins';
|
|
3
|
+
export * from './utils';
|