@byteluck-fe/model-driven-engine 2.5.7 → 2.5.9-beta.4
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 +3 -3
- package/dist/esm/common/DataManager.js +2 -2
- package/dist/esm/common/Engine.js +46 -46
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +48 -22
- package/dist/esm/common/Store.js +9 -9
- package/dist/esm/common/checkerValue.js +22 -22
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +38 -34
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +18 -14
- package/dist/esm/plugins/ControlsEventPlugin.js +2 -2
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +4 -4
- package/dist/esm/plugins/StylePlugin.js +5 -5
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +3 -3
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Runtime.d.ts +1 -0
- package/package.json +2 -2
|
@@ -164,9 +164,9 @@ function _create_super(Derived) {
|
|
|
164
164
|
return _possible_constructor_return(this, result);
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from
|
|
168
|
-
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from
|
|
169
|
-
import { camelizeKeys } from
|
|
167
|
+
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from '@byteluck-fe/model-driven-shared';
|
|
168
|
+
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from '@byteluck-fe/model-driven-core';
|
|
169
|
+
import { camelizeKeys } from 'humps';
|
|
170
170
|
var ValueChecker = function ValueChecker() {
|
|
171
171
|
"use strict";
|
|
172
172
|
_class_call_check(this, ValueChecker);
|
|
@@ -190,7 +190,7 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
190
190
|
key: "transform",
|
|
191
191
|
value: function transform(value) {
|
|
192
192
|
if (value === null || value === undefined) {
|
|
193
|
-
return
|
|
193
|
+
return '';
|
|
194
194
|
}
|
|
195
195
|
if (!isPlainObject(value) && !isFunction(value)) {
|
|
196
196
|
return String(value);
|
|
@@ -217,14 +217,14 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
217
217
|
// 数字类型允许是空字符串,用于置空数据
|
|
218
218
|
key: "validate",
|
|
219
219
|
value: function validate(value) {
|
|
220
|
-
return isNumber(value) || value ===
|
|
220
|
+
return isNumber(value) || value === '';
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
key: "transform",
|
|
225
225
|
value: function transform(value) {
|
|
226
226
|
if (value === null || value === undefined) {
|
|
227
|
-
return
|
|
227
|
+
return '';
|
|
228
228
|
}
|
|
229
229
|
var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
|
|
230
230
|
if (!Number.isNaN(newValue) && newValue !== undefined) {
|
|
@@ -259,7 +259,7 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
259
259
|
}
|
|
260
260
|
function getStringValueArray(value) {
|
|
261
261
|
return value.map(function(item) {
|
|
262
|
-
return !item ?
|
|
262
|
+
return !item ? '' : String(item);
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
265
|
if (isArray(value)) {
|
|
@@ -304,9 +304,9 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
304
304
|
}
|
|
305
305
|
function getNumberValueArray(value) {
|
|
306
306
|
return value.map(function(item) {
|
|
307
|
-
return !item && item !== 0 ?
|
|
307
|
+
return !item && item !== 0 ? '' : Number(item);
|
|
308
308
|
}).filter(function(item) {
|
|
309
|
-
return item ===
|
|
309
|
+
return item === '' || !Number.isNaN(item);
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
312
|
if (isArray(value)) {
|
|
@@ -344,13 +344,13 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
344
344
|
{
|
|
345
345
|
key: "validate",
|
|
346
346
|
value: function validate(value) {
|
|
347
|
-
return _instanceof(value, AmountValue) || isPlainObject(value) &&
|
|
347
|
+
return _instanceof(value, AmountValue) || isPlainObject(value) && 'amount' in value && isNumber(value.amount) && 'currency' in value && isString(value.currency);
|
|
348
348
|
}
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
351
|
key: "transform",
|
|
352
352
|
value: function transform(value, oldValue) {
|
|
353
|
-
if (value === undefined || value === null || value ===
|
|
353
|
+
if (value === undefined || value === null || value === '') {
|
|
354
354
|
return new AmountValue({
|
|
355
355
|
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
356
356
|
});
|
|
@@ -394,13 +394,13 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
394
394
|
{
|
|
395
395
|
key: "validate",
|
|
396
396
|
value: function validate(value) {
|
|
397
|
-
return _instanceof(value, RangeDateValue) || isPlainObject(value) &&
|
|
397
|
+
return _instanceof(value, RangeDateValue) || isPlainObject(value) && 'min' in value && isString(value.min) && 'max' in value && isString(value.max);
|
|
398
398
|
}
|
|
399
399
|
},
|
|
400
400
|
{
|
|
401
401
|
key: "transform",
|
|
402
402
|
value: function transform(value, oldValue) {
|
|
403
|
-
if (value === undefined || value === null || value ===
|
|
403
|
+
if (value === undefined || value === null || value === '') {
|
|
404
404
|
return new RangeDateValue();
|
|
405
405
|
}
|
|
406
406
|
var result;
|
|
@@ -441,13 +441,13 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
441
441
|
{
|
|
442
442
|
key: "validate",
|
|
443
443
|
value: function validate(value) {
|
|
444
|
-
return _instanceof(value, CalcValue) || isPlainObject(value) &&
|
|
444
|
+
return _instanceof(value, CalcValue) || isPlainObject(value) && 'result' in value && isNumber(value.result) && 'unit' in value && isString(value.unit);
|
|
445
445
|
}
|
|
446
446
|
},
|
|
447
447
|
{
|
|
448
448
|
key: "transform",
|
|
449
449
|
value: function transform(value, oldValue) {
|
|
450
|
-
if (value === undefined || value === null || value ===
|
|
450
|
+
if (value === undefined || value === null || value === '') {
|
|
451
451
|
return new CalcValue({
|
|
452
452
|
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
453
453
|
});
|
|
@@ -497,7 +497,7 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
497
497
|
{
|
|
498
498
|
key: "transform",
|
|
499
499
|
value: function transform(value, oldValue) {
|
|
500
|
-
if (value === undefined || value === null || value ===
|
|
500
|
+
if (value === undefined || value === null || value === '') {
|
|
501
501
|
return new AddressValue();
|
|
502
502
|
}
|
|
503
503
|
var result;
|
|
@@ -581,15 +581,15 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
581
581
|
}();
|
|
582
582
|
function getFieldTypeFromKey(key) {
|
|
583
583
|
if ([
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
584
|
+
'min',
|
|
585
|
+
'max',
|
|
586
|
+
'currency',
|
|
587
|
+
'unit'
|
|
588
588
|
].includes(key)) {
|
|
589
589
|
return FieldTypes.VARCHAR;
|
|
590
590
|
} else if ([
|
|
591
|
-
|
|
592
|
-
|
|
591
|
+
'result',
|
|
592
|
+
'amount'
|
|
593
593
|
].includes(key)) {
|
|
594
594
|
return FieldTypes.DECIMAL;
|
|
595
595
|
}
|
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';
|
|
@@ -15,6 +15,10 @@ function _non_iterable_spread() {
|
|
|
15
15
|
function _to_consumable_array(arr) {
|
|
16
16
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
17
17
|
}
|
|
18
|
+
function _type_of(obj) {
|
|
19
|
+
"@swc/helpers - typeof";
|
|
20
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
21
|
+
}
|
|
18
22
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
19
23
|
if (!o) return;
|
|
20
24
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -24,21 +28,21 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
24
28
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
29
|
}
|
|
26
30
|
var cc = console;
|
|
27
|
-
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from
|
|
31
|
+
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from '@byteluck-fe/model-driven-shared';
|
|
28
32
|
var proxyArrayApi = [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
'splice',
|
|
34
|
+
'push',
|
|
35
|
+
'shift',
|
|
36
|
+
'pop',
|
|
37
|
+
'unshift',
|
|
38
|
+
'reverse'
|
|
35
39
|
];
|
|
36
|
-
export var engineProxyFlag = Symbol(
|
|
37
|
-
export var engineTargetKey = Symbol(
|
|
38
|
-
export var engineArrayBeforeSetCallbackFlag = Symbol(
|
|
39
|
-
export var engineProxyThisKey = Symbol(
|
|
40
|
+
export var engineProxyFlag = Symbol('__engineProxy__');
|
|
41
|
+
export var engineTargetKey = Symbol('__engineTarget__');
|
|
42
|
+
export var engineArrayBeforeSetCallbackFlag = Symbol('__engineArrayBeforeSetCallbackFlag__');
|
|
43
|
+
export var engineProxyThisKey = Symbol('__engineProxyThisKey__');
|
|
40
44
|
var currentHandlerState = {
|
|
41
|
-
type:
|
|
45
|
+
type: '',
|
|
42
46
|
args: [],
|
|
43
47
|
callback: emptyFn
|
|
44
48
|
};
|
|
@@ -55,16 +59,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
55
59
|
// 操作下标
|
|
56
60
|
// Number(propertyKey) > target.length 说明当前操作的下标已经超过了安全范围(数组的运行长度,比如[1,2,3],它的长度为3,可操作的下标为0,1,2,3,如果操作4将会产生一个empty index)
|
|
57
61
|
if (index > target.length) {
|
|
58
|
-
error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(
|
|
62
|
+
error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(','), " for array operations"));
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
// 不是操作下标,而是直接操作length或者自定义属性等
|
|
62
66
|
var isNotHandlerIndex = Number.isNaN(index);
|
|
63
|
-
if (isNotHandlerIndex && propertyKey !==
|
|
67
|
+
if (isNotHandlerIndex && propertyKey !== 'length') {
|
|
64
68
|
return;
|
|
65
69
|
}
|
|
66
70
|
// 直接操作length
|
|
67
|
-
if (propertyKey ===
|
|
71
|
+
if (propertyKey === 'length') {
|
|
68
72
|
var newLength = value;
|
|
69
73
|
var oldLength = target.length;
|
|
70
74
|
if (newLength > target.length) {
|
|
@@ -76,7 +80,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
76
80
|
}
|
|
77
81
|
// 通过操作length删除旧的行
|
|
78
82
|
return function() {
|
|
79
|
-
return callback.call(null, target, thisKey,
|
|
83
|
+
return callback.call(null, target, thisKey, 'splice', [
|
|
80
84
|
newLength,
|
|
81
85
|
oldLength - newLength
|
|
82
86
|
]);
|
|
@@ -86,13 +90,13 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
86
90
|
// 正常操作
|
|
87
91
|
if (index === target.length) {
|
|
88
92
|
return function() {
|
|
89
|
-
return callback.call(null, target, thisKey,
|
|
93
|
+
return callback.call(null, target, thisKey, 'push', [
|
|
90
94
|
value
|
|
91
95
|
]);
|
|
92
96
|
};
|
|
93
97
|
} else {
|
|
94
98
|
return function() {
|
|
95
|
-
return callback.call(null, target, thisKey,
|
|
99
|
+
return callback.call(null, target, thisKey, 'splice', [
|
|
96
100
|
index,
|
|
97
101
|
1,
|
|
98
102
|
value
|
|
@@ -128,9 +132,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
128
132
|
var newValue = JSONCopy(value);
|
|
129
133
|
// @ts-ignore
|
|
130
134
|
var oldValue = target[propertyKey];
|
|
131
|
-
var concatKey = thisKey ===
|
|
135
|
+
var concatKey = thisKey === '' ? propertyKey : thisKey + '.' + propertyKey;
|
|
132
136
|
function reProxyState(value) {
|
|
133
|
-
if (typeof value === "
|
|
137
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value !== null) {
|
|
134
138
|
// @ts-ignore
|
|
135
139
|
if (value[engineProxyFlag] !== true) {
|
|
136
140
|
return proxyState(value, callback, beforeSetCallback, concatKey);
|
|
@@ -186,15 +190,15 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
186
190
|
* @param beforeSetCallback
|
|
187
191
|
* @param prevKey 递归对象的key
|
|
188
192
|
* */ export function proxyState(state, callback, beforeSetCallback) {
|
|
189
|
-
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] :
|
|
193
|
+
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : '';
|
|
190
194
|
// 冻结的对象不需要再执行proxy,否则会报错
|
|
191
195
|
if (Object.isFrozen(state)) {
|
|
192
196
|
return state;
|
|
193
197
|
}
|
|
194
198
|
for(var key in state){
|
|
195
|
-
var concatKey = prevKey ===
|
|
199
|
+
var concatKey = prevKey === '' ? key : prevKey + '.' + key;
|
|
196
200
|
var obj = state[key];
|
|
197
|
-
if (typeof obj === "
|
|
201
|
+
if ((typeof obj === "undefined" ? "undefined" : _type_of(obj)) === 'object' && obj !== null) {
|
|
198
202
|
// @ts-ignore
|
|
199
203
|
state[key] = proxyState(obj, callback, beforeSetCallback, concatKey);
|
|
200
204
|
}
|
|
@@ -205,7 +209,7 @@ function flatInstanceForChildren(controls) {
|
|
|
205
209
|
var result = [];
|
|
206
210
|
controls.forEach(function(item) {
|
|
207
211
|
result.push(item);
|
|
208
|
-
if (item.controlType ===
|
|
212
|
+
if (item.controlType === 'layout') {
|
|
209
213
|
var _result;
|
|
210
214
|
(_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
|
|
211
215
|
}
|
|
@@ -217,8 +221,8 @@ function flatInstanceForChildren(controls) {
|
|
|
217
221
|
* @param flatInstance 拍平的instance数组
|
|
218
222
|
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
219
223
|
* */ export function findItem(flatInstance, key, instanceMap) {
|
|
220
|
-
if (key ===
|
|
221
|
-
var keys = key.split(
|
|
224
|
+
if (key === '') return undefined;
|
|
225
|
+
var keys = key.split('.');
|
|
222
226
|
if (keys.length === 0) return undefined;
|
|
223
227
|
var oneKey = keys[0];
|
|
224
228
|
var otherKeys = keys.slice(1);
|
|
@@ -253,22 +257,22 @@ function flatInstanceForChildren(controls) {
|
|
|
253
257
|
}
|
|
254
258
|
function getArrayNewValue(type, args) {
|
|
255
259
|
if ([
|
|
256
|
-
|
|
257
|
-
|
|
260
|
+
'push',
|
|
261
|
+
'unshift'
|
|
258
262
|
].includes(type)) {
|
|
259
263
|
return args;
|
|
260
|
-
} else if (type ===
|
|
264
|
+
} else if (type === 'splice') {
|
|
261
265
|
return args.slice(2);
|
|
262
266
|
}
|
|
263
267
|
return [];
|
|
264
268
|
}
|
|
265
269
|
function getArrayNewArgs(type, args, value) {
|
|
266
270
|
if ([
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
'push',
|
|
272
|
+
'unshift'
|
|
269
273
|
].includes(type)) {
|
|
270
274
|
return value;
|
|
271
|
-
} else if (type ===
|
|
275
|
+
} else if (type === 'splice') {
|
|
272
276
|
return args.slice(0, 2).concat(value);
|
|
273
277
|
}
|
|
274
278
|
}
|
|
@@ -303,8 +307,8 @@ function getArrayNewArgs(type, args, value) {
|
|
|
303
307
|
// @ts-ignore
|
|
304
308
|
result = oldApiHandler.apply(this, args);
|
|
305
309
|
}
|
|
306
|
-
typeof currentHandlerState.callback ===
|
|
307
|
-
currentHandlerState.type =
|
|
310
|
+
typeof currentHandlerState.callback === 'function' && currentHandlerState.callback(key, args, result);
|
|
311
|
+
currentHandlerState.type = '';
|
|
308
312
|
currentHandlerState.args = [];
|
|
309
313
|
currentHandlerState.callback = emptyFn;
|
|
310
314
|
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';
|
|
@@ -47,6 +47,10 @@ function _non_iterable_spread() {
|
|
|
47
47
|
function _to_consumable_array(arr) {
|
|
48
48
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
49
49
|
}
|
|
50
|
+
function _type_of(obj) {
|
|
51
|
+
"@swc/helpers - typeof";
|
|
52
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
53
|
+
}
|
|
50
54
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
51
55
|
if (!o) return;
|
|
52
56
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -55,8 +59,8 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
55
59
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
56
60
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
57
61
|
}
|
|
58
|
-
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from
|
|
59
|
-
import { format } from
|
|
62
|
+
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
63
|
+
import { format } from 'mathjs';
|
|
60
64
|
var DisplayType;
|
|
61
65
|
(function(DisplayType) {
|
|
62
66
|
/**
|
|
@@ -171,7 +175,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
171
175
|
this.watchControlChange();
|
|
172
176
|
this.watchSubtableChange();
|
|
173
177
|
this.watchSchemaHideChange();
|
|
174
|
-
this.engine.on(
|
|
178
|
+
this.engine.on('engine-mounted', function() {
|
|
175
179
|
_this.allCalcControlComputed();
|
|
176
180
|
});
|
|
177
181
|
}
|
|
@@ -268,8 +272,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
268
272
|
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
269
273
|
* */ function watchSchemaHideChange() {
|
|
270
274
|
var _this = this;
|
|
271
|
-
this.engine.on(
|
|
272
|
-
if (payload.props ===
|
|
275
|
+
this.engine.on('schema-change', function(payload) {
|
|
276
|
+
if (payload.props === 'isHide') {
|
|
273
277
|
var _this_dependenciesTriggerMap_get;
|
|
274
278
|
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
275
279
|
calcControls.forEach(function(calc) {
|
|
@@ -285,7 +289,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
285
289
|
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
286
290
|
* */ function watchSubtableChange() {
|
|
287
291
|
var _this = this;
|
|
288
|
-
this.engine.on(
|
|
292
|
+
this.engine.on('list-change', function(payload) {
|
|
289
293
|
var _payload_options;
|
|
290
294
|
_this.resetDependencies();
|
|
291
295
|
var _payload_options_changed;
|
|
@@ -311,7 +315,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
311
315
|
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
312
316
|
* */ function watchControlChange() {
|
|
313
317
|
var _this = this;
|
|
314
|
-
this.engine.on(
|
|
318
|
+
this.engine.on('change', function(payload) {
|
|
315
319
|
var instance = payload.instance;
|
|
316
320
|
if (!_this.dependenciesTriggerMap.has(instance.id)) {
|
|
317
321
|
return;
|
|
@@ -406,7 +410,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
406
410
|
result += 0;
|
|
407
411
|
}
|
|
408
412
|
return result;
|
|
409
|
-
},
|
|
413
|
+
}, '');
|
|
410
414
|
var value;
|
|
411
415
|
// 有缓存的话取缓存,没有缓存再执行eval
|
|
412
416
|
if (this.cacheComputedResult[scriptText] !== undefined) {
|
|
@@ -427,7 +431,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
427
431
|
}
|
|
428
432
|
}
|
|
429
433
|
var oldValue = this.engine.getState(control.id, rowIndex);
|
|
430
|
-
var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision ===
|
|
434
|
+
var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision === '' ? value : Number(value.toFixed(control.props.precision));
|
|
431
435
|
// 如果值没变的话,不触发修改
|
|
432
436
|
if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
433
437
|
return;
|
|
@@ -435,7 +439,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
435
439
|
var _oldValue_unit;
|
|
436
440
|
this.engine.setState(control.id, {
|
|
437
441
|
result: result,
|
|
438
|
-
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit :
|
|
442
|
+
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ''
|
|
439
443
|
}, rowIndex);
|
|
440
444
|
}
|
|
441
445
|
},
|
|
@@ -444,14 +448,14 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
444
448
|
value: /**
|
|
445
449
|
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
446
450
|
* */ function getNumberValue(value) {
|
|
447
|
-
if (typeof value === "
|
|
448
|
-
if (
|
|
451
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value) {
|
|
452
|
+
if ('result' in value) {
|
|
449
453
|
return value.result;
|
|
450
|
-
} else if (
|
|
454
|
+
} else if ('amount' in value) {
|
|
451
455
|
return value.amount;
|
|
452
456
|
}
|
|
453
457
|
}
|
|
454
|
-
if (typeof value ===
|
|
458
|
+
if (typeof value === 'number') {
|
|
455
459
|
return value;
|
|
456
460
|
}
|
|
457
461
|
return 0;
|
|
@@ -154,7 +154,7 @@ function _ts_generator(thisArg, body) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
import { EventLogic } from
|
|
157
|
+
import { EventLogic } from '@byteluck-fe/model-driven-shared';
|
|
158
158
|
// type EventKeyMap = {
|
|
159
159
|
// [eventKey in EventKeys]?: string
|
|
160
160
|
// }
|
|
@@ -213,7 +213,7 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
213
213
|
switch(_state.label){
|
|
214
214
|
case 0:
|
|
215
215
|
// 初始化state的时候不触发change事件,必须在engine mounted以后才触发
|
|
216
|
-
if ((eventKey ===
|
|
216
|
+
if ((eventKey === 'change' || eventKey === 'list-change') && !_this.engine.isMounted) {
|
|
217
217
|
return [
|
|
218
218
|
2
|
|
219
219
|
];
|
|
@@ -76,7 +76,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
76
76
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
77
77
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
78
78
|
}
|
|
79
|
-
import { error } from
|
|
79
|
+
import { error } from '@byteluck-fe/model-driven-shared';
|
|
80
80
|
export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
81
81
|
"use strict";
|
|
82
82
|
function ES6ModulePlugin(config, env) {
|
|
@@ -141,11 +141,11 @@ export function parseModule(action, engine, env) {
|
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
try {
|
|
144
|
-
new Function(
|
|
144
|
+
new Function('module', 'exports', compiled).call(module, module, module.exports);
|
|
145
145
|
} catch (e) {
|
|
146
|
-
error(e.message +
|
|
147
|
-
if (process.env.NODE_ENV !==
|
|
148
|
-
error(
|
|
146
|
+
error(e.message + '. fail to parse the module');
|
|
147
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
148
|
+
error('fail to parse the module');
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
var funcMap = {};
|
|
@@ -154,7 +154,7 @@ export function parseModule(action, engine, env) {
|
|
|
154
154
|
try {
|
|
155
155
|
for(var _iterator = Object.entries(module.exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
156
156
|
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
157
|
-
if (typeof value ===
|
|
157
|
+
if (typeof value === 'function') {
|
|
158
158
|
funcMap[key] = value;
|
|
159
159
|
} else {
|
|
160
160
|
variables[key] = value;
|
|
@@ -201,10 +201,10 @@ function _ts_generator(thisArg, body) {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
var LifecycleEventKeyMap = {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
'engine-mounted': 'did_mount',
|
|
205
|
+
'engine-submit': 'will_submit',
|
|
206
|
+
'engine-submit-params': 'do_submit',
|
|
207
|
+
'engine-submitted': 'did_submit'
|
|
208
208
|
};
|
|
209
209
|
export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
210
210
|
"use strict";
|
|
@@ -45,12 +45,12 @@ export var StylePlugin = /*#__PURE__*/ function() {
|
|
|
45
45
|
var _this_config;
|
|
46
46
|
this.engine = engine;
|
|
47
47
|
var _this_config_source;
|
|
48
|
-
var compiledStyle = (_this_config_source = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _this_config_source !== void 0 ? _this_config_source :
|
|
49
|
-
var style = document.createElement(
|
|
50
|
-
style.className =
|
|
51
|
-
style.type =
|
|
48
|
+
var compiledStyle = (_this_config_source = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _this_config_source !== void 0 ? _this_config_source : '';
|
|
49
|
+
var style = document.createElement('style');
|
|
50
|
+
style.className = 'edit-css';
|
|
51
|
+
style.type = 'text/css';
|
|
52
52
|
style.innerHTML = compiledStyle;
|
|
53
|
-
var dom = document.querySelector(
|
|
53
|
+
var dom = document.querySelector('head');
|
|
54
54
|
dom.appendChild(style);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './ES6ModulePlugin';
|
|
2
|
+
export * from './LifecycleEventPlugin';
|
|
3
|
+
export * from './ControlsEventPlugin';
|
|
4
|
+
export * from './CalcPlugin';
|
|
5
|
+
export * from './StylePlugin';
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './runtimeUtils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from
|
|
1
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
2
2
|
export function hasChildrenControl(instance) {
|
|
3
3
|
return instance.controlType === CONTROL_BASE_TYPE.LAYOUT || instance.controlType === CONTROL_BASE_TYPE.WRAP || instance.controlType === CONTROL_BASE_TYPE.LIST || instance.controlType === CONTROL_BASE_TYPE.SEARCH;
|
|
4
4
|
}
|
|
@@ -35,9 +35,9 @@ callback) {
|
|
|
35
35
|
var unique = 0;
|
|
36
36
|
// uuid生成
|
|
37
37
|
export function buildUUID() {
|
|
38
|
-
var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
38
|
+
var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
|
|
39
39
|
var time = Date.now();
|
|
40
40
|
var random = Math.floor(Math.random() * 1000000000);
|
|
41
41
|
unique++;
|
|
42
|
-
return prefix +
|
|
42
|
+
return prefix + '_' + random + unique + String(time);
|
|
43
43
|
}
|