@byteluck-fe/model-driven-engine 2.22.2-beta.0 → 2.22.2-beta.2
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 +57 -55
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +15 -15
- 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 +34 -38
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +14 -18
- package/dist/esm/plugins/ControlsEventPlugin.js +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +5 -5
- package/dist/esm/plugins/StylePlugin.js +4 -4
- 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 +25 -25
- package/dist/types/common/Engine.d.ts +7 -1
- package/package.json +4 -4
|
@@ -157,9 +157,9 @@ function _create_super(Derived) {
|
|
|
157
157
|
return _possible_constructor_return(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
|
_class_call_check(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) {
|
|
@@ -252,7 +252,7 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
252
252
|
}
|
|
253
253
|
function getStringValueArray(value) {
|
|
254
254
|
return value.map(function(item) {
|
|
255
|
-
return !item ?
|
|
255
|
+
return !item ? "" : String(item);
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
258
|
if (isArray(value)) {
|
|
@@ -297,9 +297,9 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
297
297
|
}
|
|
298
298
|
function getNumberValueArray(value) {
|
|
299
299
|
return value.map(function(item) {
|
|
300
|
-
return !item && item !== 0 ?
|
|
300
|
+
return !item && item !== 0 ? "" : Number(item);
|
|
301
301
|
}).filter(function(item) {
|
|
302
|
-
return item ===
|
|
302
|
+
return item === "" || !Number.isNaN(item);
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
305
|
if (isArray(value)) {
|
|
@@ -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,15 +588,15 @@ 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
|
}
|
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,10 +15,6 @@ 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
|
-
}
|
|
22
18
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
23
19
|
if (!o) return;
|
|
24
20
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -28,21 +24,21 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
28
24
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
29
25
|
}
|
|
30
26
|
var cc = console;
|
|
31
|
-
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from
|
|
27
|
+
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from "@byteluck-fe/model-driven-shared";
|
|
32
28
|
var proxyArrayApi = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
"splice",
|
|
30
|
+
"push",
|
|
31
|
+
"shift",
|
|
32
|
+
"pop",
|
|
33
|
+
"unshift",
|
|
34
|
+
"reverse"
|
|
39
35
|
];
|
|
40
|
-
export var engineProxyFlag = Symbol(
|
|
41
|
-
export var engineTargetKey = Symbol(
|
|
42
|
-
export var engineArrayBeforeSetCallbackFlag = Symbol(
|
|
43
|
-
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__");
|
|
44
40
|
var currentHandlerState = {
|
|
45
|
-
type:
|
|
41
|
+
type: "",
|
|
46
42
|
args: [],
|
|
47
43
|
callback: emptyFn
|
|
48
44
|
};
|
|
@@ -59,16 +55,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
59
55
|
// 操作下标
|
|
60
56
|
// Number(propertyKey) > target.length 说明当前操作的下标已经超过了安全范围(数组的运行长度,比如[1,2,3],它的长度为3,可操作的下标为0,1,2,3,如果操作4将会产生一个empty index)
|
|
61
57
|
if (index > target.length) {
|
|
62
|
-
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"));
|
|
63
59
|
return;
|
|
64
60
|
}
|
|
65
61
|
// 不是操作下标,而是直接操作length或者自定义属性等
|
|
66
62
|
var isNotHandlerIndex = Number.isNaN(index);
|
|
67
|
-
if (isNotHandlerIndex && propertyKey !==
|
|
63
|
+
if (isNotHandlerIndex && propertyKey !== "length") {
|
|
68
64
|
return;
|
|
69
65
|
}
|
|
70
66
|
// 直接操作length
|
|
71
|
-
if (propertyKey ===
|
|
67
|
+
if (propertyKey === "length") {
|
|
72
68
|
var newLength = value;
|
|
73
69
|
var oldLength = target.length;
|
|
74
70
|
if (newLength > target.length) {
|
|
@@ -80,7 +76,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
80
76
|
}
|
|
81
77
|
// 通过操作length删除旧的行
|
|
82
78
|
return function() {
|
|
83
|
-
return callback.call(null, target, thisKey,
|
|
79
|
+
return callback.call(null, target, thisKey, "splice", [
|
|
84
80
|
newLength,
|
|
85
81
|
oldLength - newLength
|
|
86
82
|
]);
|
|
@@ -90,13 +86,13 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
90
86
|
// 正常操作
|
|
91
87
|
if (index === target.length) {
|
|
92
88
|
return function() {
|
|
93
|
-
return callback.call(null, target, thisKey,
|
|
89
|
+
return callback.call(null, target, thisKey, "push", [
|
|
94
90
|
value
|
|
95
91
|
]);
|
|
96
92
|
};
|
|
97
93
|
} else {
|
|
98
94
|
return function() {
|
|
99
|
-
return callback.call(null, target, thisKey,
|
|
95
|
+
return callback.call(null, target, thisKey, "splice", [
|
|
100
96
|
index,
|
|
101
97
|
1,
|
|
102
98
|
value
|
|
@@ -132,9 +128,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
132
128
|
var newValue = JSONCopy(value);
|
|
133
129
|
// @ts-ignore
|
|
134
130
|
var oldValue = target[propertyKey];
|
|
135
|
-
var concatKey = thisKey ===
|
|
131
|
+
var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
|
|
136
132
|
function reProxyState(value) {
|
|
137
|
-
if (
|
|
133
|
+
if (typeof value === "object" && value !== null) {
|
|
138
134
|
// @ts-ignore
|
|
139
135
|
if (value[engineProxyFlag] !== true) {
|
|
140
136
|
return proxyState(value, callback, beforeSetCallback, concatKey);
|
|
@@ -190,15 +186,15 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
190
186
|
* @param beforeSetCallback
|
|
191
187
|
* @param prevKey 递归对象的key
|
|
192
188
|
* */ export function proxyState(state, callback, beforeSetCallback) {
|
|
193
|
-
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] :
|
|
189
|
+
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
|
|
194
190
|
// 冻结的对象不需要再执行proxy,否则会报错
|
|
195
191
|
if (Object.isFrozen(state)) {
|
|
196
192
|
return state;
|
|
197
193
|
}
|
|
198
194
|
for(var key in state){
|
|
199
|
-
var concatKey = prevKey ===
|
|
195
|
+
var concatKey = prevKey === "" ? key : prevKey + "." + key;
|
|
200
196
|
var obj = state[key];
|
|
201
|
-
if (
|
|
197
|
+
if (typeof obj === "object" && obj !== null) {
|
|
202
198
|
// @ts-ignore
|
|
203
199
|
state[key] = proxyState(obj, callback, beforeSetCallback, concatKey);
|
|
204
200
|
}
|
|
@@ -209,7 +205,7 @@ function flatInstanceForChildren(controls) {
|
|
|
209
205
|
var result = [];
|
|
210
206
|
controls.forEach(function(item) {
|
|
211
207
|
result.push(item);
|
|
212
|
-
if (item.controlType ===
|
|
208
|
+
if (item.controlType === "layout" || item.controlType === "wrap") {
|
|
213
209
|
var _result;
|
|
214
210
|
(_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
|
|
215
211
|
}
|
|
@@ -221,8 +217,8 @@ function flatInstanceForChildren(controls) {
|
|
|
221
217
|
* @param flatInstance 拍平的instance数组
|
|
222
218
|
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
223
219
|
* */ export function findItem(flatInstance, key, instanceMap) {
|
|
224
|
-
if (key ===
|
|
225
|
-
var keys = key.split(
|
|
220
|
+
if (key === "") return undefined;
|
|
221
|
+
var keys = key.split(".");
|
|
226
222
|
if (keys.length === 0) return undefined;
|
|
227
223
|
var oneKey = keys[0];
|
|
228
224
|
var otherKeys = keys.slice(1);
|
|
@@ -257,22 +253,22 @@ function flatInstanceForChildren(controls) {
|
|
|
257
253
|
}
|
|
258
254
|
function getArrayNewValue(type, args) {
|
|
259
255
|
if ([
|
|
260
|
-
|
|
261
|
-
|
|
256
|
+
"push",
|
|
257
|
+
"unshift"
|
|
262
258
|
].includes(type)) {
|
|
263
259
|
return args;
|
|
264
|
-
} else if (type ===
|
|
260
|
+
} else if (type === "splice") {
|
|
265
261
|
return args.slice(2);
|
|
266
262
|
}
|
|
267
263
|
return [];
|
|
268
264
|
}
|
|
269
265
|
function getArrayNewArgs(type, args, value) {
|
|
270
266
|
if ([
|
|
271
|
-
|
|
272
|
-
|
|
267
|
+
"push",
|
|
268
|
+
"unshift"
|
|
273
269
|
].includes(type)) {
|
|
274
270
|
return value;
|
|
275
|
-
} else if (type ===
|
|
271
|
+
} else if (type === "splice") {
|
|
276
272
|
return args.slice(0, 2).concat(value);
|
|
277
273
|
}
|
|
278
274
|
}
|
|
@@ -307,8 +303,8 @@ function getArrayNewArgs(type, args, value) {
|
|
|
307
303
|
// @ts-ignore
|
|
308
304
|
result = oldApiHandler.apply(this, args);
|
|
309
305
|
}
|
|
310
|
-
typeof currentHandlerState.callback ===
|
|
311
|
-
currentHandlerState.type =
|
|
306
|
+
typeof currentHandlerState.callback === "function" && currentHandlerState.callback(key, args, result);
|
|
307
|
+
currentHandlerState.type = "";
|
|
312
308
|
currentHandlerState.args = [];
|
|
313
309
|
currentHandlerState.callback = emptyFn;
|
|
314
310
|
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,10 +47,6 @@ 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
|
-
}
|
|
54
50
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
55
51
|
if (!o) return;
|
|
56
52
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -59,8 +55,8 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
59
55
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
60
56
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
61
57
|
}
|
|
62
|
-
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from
|
|
63
|
-
import { format } from
|
|
58
|
+
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from "@byteluck-fe/model-driven-shared";
|
|
59
|
+
import { format } from "mathjs";
|
|
64
60
|
var DisplayType;
|
|
65
61
|
(function(DisplayType) {
|
|
66
62
|
/**
|
|
@@ -174,7 +170,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
174
170
|
this.watchControlChange();
|
|
175
171
|
this.watchSubtableChange();
|
|
176
172
|
this.watchSchemaHideChange();
|
|
177
|
-
this.engine.on(
|
|
173
|
+
this.engine.on("engine-mounted", function() {
|
|
178
174
|
requestAnimationFrame(function() {
|
|
179
175
|
_this.resetDependencies();
|
|
180
176
|
_this.allCalcControlComputed();
|
|
@@ -278,8 +274,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
278
274
|
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
279
275
|
* */ function watchSchemaHideChange() {
|
|
280
276
|
var _this = this;
|
|
281
|
-
this.engine.on(
|
|
282
|
-
if (payload.props ===
|
|
277
|
+
this.engine.on("schema-change", function(payload) {
|
|
278
|
+
if (payload.props === "isHide") {
|
|
283
279
|
var _this_dependenciesTriggerMap_get;
|
|
284
280
|
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
285
281
|
calcControls.forEach(function(calc) {
|
|
@@ -295,7 +291,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
295
291
|
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
296
292
|
* */ function watchSubtableChange() {
|
|
297
293
|
var _this = this;
|
|
298
|
-
this.engine.on(
|
|
294
|
+
this.engine.on("list-change", function(payload) {
|
|
299
295
|
var _payload_options;
|
|
300
296
|
// 初始化前是批量操作。不做处理
|
|
301
297
|
if (_this.engine.isMounted === false) return;
|
|
@@ -323,7 +319,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
323
319
|
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
324
320
|
* */ function watchControlChange() {
|
|
325
321
|
var _this = this;
|
|
326
|
-
this.engine.on(
|
|
322
|
+
this.engine.on("change", function(payload) {
|
|
327
323
|
// 初始化前是批量操作。不做处理
|
|
328
324
|
if (_this.engine.isMounted === false) return;
|
|
329
325
|
var instance = payload.instance;
|
|
@@ -420,7 +416,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
420
416
|
result += 0;
|
|
421
417
|
}
|
|
422
418
|
return result;
|
|
423
|
-
},
|
|
419
|
+
}, "");
|
|
424
420
|
var value;
|
|
425
421
|
// 有缓存的话取缓存,没有缓存再执行eval
|
|
426
422
|
if (this.cacheComputedResult[scriptText] !== undefined) {
|
|
@@ -441,7 +437,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
441
437
|
}
|
|
442
438
|
}
|
|
443
439
|
var oldValue = this.engine.getState(control.id, rowIndex);
|
|
444
|
-
var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision ===
|
|
440
|
+
var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision === "" ? value : Number(value.toFixed(control.props.precision));
|
|
445
441
|
// 如果值没变的话,不触发修改
|
|
446
442
|
if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
447
443
|
return;
|
|
@@ -449,7 +445,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
449
445
|
var _oldValue_unit;
|
|
450
446
|
this.engine.setState(control.id, {
|
|
451
447
|
result: result,
|
|
452
|
-
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit :
|
|
448
|
+
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ""
|
|
453
449
|
}, rowIndex);
|
|
454
450
|
}
|
|
455
451
|
},
|
|
@@ -458,14 +454,14 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
458
454
|
value: /**
|
|
459
455
|
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
460
456
|
* */ function getNumberValue(value) {
|
|
461
|
-
if (
|
|
462
|
-
if (
|
|
457
|
+
if (typeof value === "object" && value) {
|
|
458
|
+
if ("result" in value) {
|
|
463
459
|
return value.result;
|
|
464
|
-
} else if (
|
|
460
|
+
} else if ("amount" in value) {
|
|
465
461
|
return value.amount;
|
|
466
462
|
}
|
|
467
463
|
}
|
|
468
|
-
if (typeof value ===
|
|
464
|
+
if (typeof value === "number") {
|
|
469
465
|
return value;
|
|
470
466
|
}
|
|
471
467
|
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
|
// }
|
|
@@ -206,8 +206,8 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
206
206
|
//注册自定义组件事件
|
|
207
207
|
this.customEvents.map(function(item) {
|
|
208
208
|
var key = item.key;
|
|
209
|
-
if (item.namespace !== undefined && item.namespace !== null && item.namespace !==
|
|
210
|
-
key = item.namespace +
|
|
209
|
+
if (item.namespace !== undefined && item.namespace !== null && item.namespace !== "") {
|
|
210
|
+
key = item.namespace + ":" + item.key;
|
|
211
211
|
}
|
|
212
212
|
_this.engineAddEventListener(key, key);
|
|
213
213
|
});
|
|
@@ -223,7 +223,7 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
223
223
|
switch(_state.label){
|
|
224
224
|
case 0:
|
|
225
225
|
// 初始化state的时候不触发change事件,必须在engine mounted以后才触发
|
|
226
|
-
if ((eventKey ===
|
|
226
|
+
if ((eventKey === "change" || eventKey === "list-change") && !_this.engine.isMounted) {
|
|
227
227
|
return [
|
|
228
228
|
2
|
|
229
229
|
];
|
|
@@ -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, eventJs) {
|
|
@@ -170,11 +170,11 @@ export function parseModule(action, engine, env) {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
try {
|
|
173
|
-
new Function(
|
|
173
|
+
new Function("module", "exports", compiled).call(module, module, module.exports);
|
|
174
174
|
} catch (e) {
|
|
175
|
-
error(e.message +
|
|
176
|
-
if (process.env.NODE_ENV !==
|
|
177
|
-
error(
|
|
175
|
+
error(e.message + ". fail to parse the module");
|
|
176
|
+
if (process.env.NODE_ENV !== "production") {
|
|
177
|
+
error("fail to parse the module");
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
var funcMap = {};
|
|
@@ -183,7 +183,7 @@ export function parseModule(action, engine, env) {
|
|
|
183
183
|
try {
|
|
184
184
|
for(var _iterator = Object.entries(module.exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
185
185
|
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
186
|
-
if (typeof value ===
|
|
186
|
+
if (typeof value === "function") {
|
|
187
187
|
funcMap[key] = value;
|
|
188
188
|
} else {
|
|
189
189
|
variables[key] = value;
|
|
@@ -201,11 +201,11 @@ function _ts_generator(thisArg, body) {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
var LifecycleEventKeyMap = {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
"engine-initialized": "did_init",
|
|
205
|
+
"engine-mounted": "did_mount",
|
|
206
|
+
"engine-submit": "will_submit",
|
|
207
|
+
"engine-submit-params": "do_submit",
|
|
208
|
+
"engine-submitted": "did_submit"
|
|
209
209
|
};
|
|
210
210
|
export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
211
211
|
"use strict";
|
|
@@ -54,10 +54,10 @@ export var StylePlugin = /*#__PURE__*/ function() {
|
|
|
54
54
|
var _this_config;
|
|
55
55
|
this.engine = engine;
|
|
56
56
|
var _this_config_source;
|
|
57
|
-
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 :
|
|
58
|
-
var style = document.createElement(
|
|
59
|
-
style.className =
|
|
60
|
-
var dom = document.querySelector(
|
|
57
|
+
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 : "";
|
|
58
|
+
var style = document.createElement("style");
|
|
59
|
+
style.className = "edit-css-" + engine.id;
|
|
60
|
+
var dom = document.querySelector("head");
|
|
61
61
|
dom === null || dom === void 0 ? void 0 : dom.appendChild(style);
|
|
62
62
|
var cssStyleText;
|
|
63
63
|
if (this.isPc) {
|
|
@@ -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 || instance.controlType === CONTROL_BASE_TYPE.COLUMN && instance.type !== CONTROL_TYPE.OPERATION_COLUMN;
|
|
4
4
|
}
|
|
@@ -37,9 +37,9 @@ callback) {
|
|
|
37
37
|
var unique = 0;
|
|
38
38
|
// uuid生成
|
|
39
39
|
export function buildUUID() {
|
|
40
|
-
var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
40
|
+
var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
41
41
|
var time = Date.now();
|
|
42
42
|
var random = Math.floor(Math.random() * 1000000000);
|
|
43
43
|
unique++;
|
|
44
|
-
return prefix +
|
|
44
|
+
return prefix + "_" + random + unique + String(time);
|
|
45
45
|
}
|