@byteluck-fe/model-driven-engine 2.7.0-alpha.15b → 2.7.0-alpha.15c
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 +173 -56
- package/dist/esm/common/DataManager.js +134 -25
- package/dist/esm/common/Engine.js +405 -273
- package/dist/esm/common/OkWorker.js +31 -17
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +54 -39
- package/dist/esm/common/Store.js +61 -59
- package/dist/esm/common/checkerValue.js +112 -110
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +61 -60
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +86 -77
- package/dist/esm/plugins/ControlsEventPlugin.js +196 -73
- package/dist/esm/plugins/ES6ModulePlugin.js +37 -21
- package/dist/esm/plugins/LifecycleEventPlugin.js +198 -79
- package/dist/esm/plugins/StylePlugin.js +26 -11
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +7 -7
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Engine.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +1 -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 +2 -2
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
2
|
if (len == null || len > arr.length) len = arr.length;
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function _assert_this_initialized(self) {
|
|
10
10
|
if (self === void 0) {
|
|
11
11
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
12
12
|
}
|
|
13
13
|
return self;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function _class_call_check(instance, Constructor) {
|
|
16
16
|
if (!(instance instanceof Constructor)) {
|
|
17
17
|
throw new TypeError("Cannot call a class as a function");
|
|
18
18
|
}
|
|
@@ -26,12 +26,12 @@ function _defineProperties(target, props) {
|
|
|
26
26
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
30
30
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
31
31
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
32
32
|
return Constructor;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function _define_property(obj, key, value) {
|
|
35
35
|
if (key in obj) {
|
|
36
36
|
Object.defineProperty(obj, key, {
|
|
37
37
|
value: value,
|
|
@@ -44,11 +44,11 @@ function _defineProperty(obj, key, value) {
|
|
|
44
44
|
}
|
|
45
45
|
return obj;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
47
|
+
function _get_prototype_of(o) {
|
|
48
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
49
49
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
50
50
|
};
|
|
51
|
-
return
|
|
51
|
+
return _get_prototype_of(o);
|
|
52
52
|
}
|
|
53
53
|
function _inherits(subClass, superClass) {
|
|
54
54
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -61,9 +61,9 @@ function _inherits(subClass, superClass) {
|
|
|
61
61
|
configurable: true
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
-
if (superClass)
|
|
64
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function _iterable_to_array_limit(arr, i) {
|
|
67
67
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
68
68
|
if (_i == null) return;
|
|
69
69
|
var _arr = [];
|
|
@@ -87,10 +87,10 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
87
87
|
}
|
|
88
88
|
return _arr;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function _non_iterable_rest() {
|
|
91
91
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function _object_spread(target) {
|
|
94
94
|
for(var i = 1; i < arguments.length; i++){
|
|
95
95
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
96
96
|
var ownKeys = Object.keys(source);
|
|
@@ -100,40 +100,40 @@ function _objectSpread(target) {
|
|
|
100
100
|
}));
|
|
101
101
|
}
|
|
102
102
|
ownKeys.forEach(function(key) {
|
|
103
|
-
|
|
103
|
+
_define_property(target, key, source[key]);
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
return target;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
if (call && (
|
|
108
|
+
function _possible_constructor_return(self, call) {
|
|
109
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
110
110
|
return call;
|
|
111
111
|
}
|
|
112
|
-
return
|
|
112
|
+
return _assert_this_initialized(self);
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
114
|
+
function _set_prototype_of(o, p) {
|
|
115
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
116
116
|
o.__proto__ = p;
|
|
117
117
|
return o;
|
|
118
118
|
};
|
|
119
|
-
return
|
|
119
|
+
return _set_prototype_of(o, p);
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
121
|
+
function _sliced_to_array(arr, i) {
|
|
122
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
function _type_of(obj) {
|
|
125
125
|
"@swc/helpers - typeof";
|
|
126
126
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
127
|
-
}
|
|
128
|
-
function
|
|
127
|
+
}
|
|
128
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
129
129
|
if (!o) return;
|
|
130
|
-
if (typeof o === "string") return
|
|
130
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
131
131
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
132
132
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
133
133
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
134
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
134
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function _is_native_reflect_construct() {
|
|
137
137
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
138
138
|
if (Reflect.construct.sham) return false;
|
|
139
139
|
if (typeof Proxy === "function") return true;
|
|
@@ -144,35 +144,35 @@ function _isNativeReflectConstruct() {
|
|
|
144
144
|
return false;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
var hasNativeReflectConstruct =
|
|
147
|
+
function _create_super(Derived) {
|
|
148
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
149
149
|
return function _createSuperInternal() {
|
|
150
|
-
var Super =
|
|
150
|
+
var Super = _get_prototype_of(Derived), result;
|
|
151
151
|
if (hasNativeReflectConstruct) {
|
|
152
|
-
var NewTarget =
|
|
152
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
153
153
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
154
154
|
} else {
|
|
155
155
|
result = Super.apply(this, arguments);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
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);
|
|
166
166
|
};
|
|
167
167
|
var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
168
168
|
"use strict";
|
|
169
169
|
_inherits(StringValueChecker, ValueChecker);
|
|
170
|
-
var _super =
|
|
170
|
+
var _super = _create_super(StringValueChecker);
|
|
171
171
|
function StringValueChecker() {
|
|
172
|
-
|
|
172
|
+
_class_call_check(this, StringValueChecker);
|
|
173
173
|
return _super.apply(this, arguments);
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
_create_class(StringValueChecker, [
|
|
176
176
|
{
|
|
177
177
|
key: "validate",
|
|
178
178
|
value: function validate(value) {
|
|
@@ -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);
|
|
@@ -200,24 +200,24 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
200
200
|
var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
201
201
|
"use strict";
|
|
202
202
|
_inherits(NumberValueChecker, ValueChecker);
|
|
203
|
-
var _super =
|
|
203
|
+
var _super = _create_super(NumberValueChecker);
|
|
204
204
|
function NumberValueChecker() {
|
|
205
|
-
|
|
205
|
+
_class_call_check(this, NumberValueChecker);
|
|
206
206
|
return _super.apply(this, arguments);
|
|
207
207
|
}
|
|
208
|
-
|
|
208
|
+
_create_class(NumberValueChecker, [
|
|
209
209
|
{
|
|
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) {
|
|
@@ -232,12 +232,12 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
232
232
|
var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
233
233
|
"use strict";
|
|
234
234
|
_inherits(StringArrayValueChecker, ValueChecker);
|
|
235
|
-
var _super =
|
|
235
|
+
var _super = _create_super(StringArrayValueChecker);
|
|
236
236
|
function StringArrayValueChecker() {
|
|
237
|
-
|
|
237
|
+
_class_call_check(this, StringArrayValueChecker);
|
|
238
238
|
return _super.apply(this, arguments);
|
|
239
239
|
}
|
|
240
|
-
|
|
240
|
+
_create_class(StringArrayValueChecker, [
|
|
241
241
|
{
|
|
242
242
|
key: "validate",
|
|
243
243
|
value: function validate(value) {
|
|
@@ -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(value) {
|
|
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 (value === undefined || value === null) {
|
|
256
256
|
return [];
|
|
257
257
|
}
|
|
258
|
-
if (isArray(
|
|
259
|
-
return getStringValueArray(
|
|
258
|
+
if (isArray(value)) {
|
|
259
|
+
return getStringValueArray(value);
|
|
260
260
|
}
|
|
261
|
-
if (isString(
|
|
261
|
+
if (isString(value) && isJSONArray(value)) {
|
|
262
262
|
try {
|
|
263
|
-
var newValue = JSON.parse(
|
|
263
|
+
var newValue = JSON.parse(value);
|
|
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(value)
|
|
271
271
|
];
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -277,12 +277,12 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
277
277
|
var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
278
278
|
"use strict";
|
|
279
279
|
_inherits(NumberArrayValueChecker, ValueChecker);
|
|
280
|
-
var _super =
|
|
280
|
+
var _super = _create_super(NumberArrayValueChecker);
|
|
281
281
|
function NumberArrayValueChecker() {
|
|
282
|
-
|
|
282
|
+
_class_call_check(this, NumberArrayValueChecker);
|
|
283
283
|
return _super.apply(this, arguments);
|
|
284
284
|
}
|
|
285
|
-
|
|
285
|
+
_create_class(NumberArrayValueChecker, [
|
|
286
286
|
{
|
|
287
287
|
key: "validate",
|
|
288
288
|
value: function validate(value) {
|
|
@@ -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(value) {
|
|
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 (value === undefined || value === null) {
|
|
303
303
|
return [];
|
|
304
304
|
}
|
|
305
|
-
if (isArray(
|
|
306
|
-
return getNumberValueArray(
|
|
305
|
+
if (isArray(value)) {
|
|
306
|
+
return getNumberValueArray(value);
|
|
307
307
|
}
|
|
308
|
-
if (isString(
|
|
308
|
+
if (isString(value) && isJSONArray(value)) {
|
|
309
309
|
try {
|
|
310
|
-
var newValue = JSON.parse(
|
|
310
|
+
var newValue = JSON.parse(value);
|
|
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(value);
|
|
317
317
|
if (Number.isNaN(newValue1)) {
|
|
318
|
-
throw "".concat(
|
|
318
|
+
throw "".concat(value, " is not a number array");
|
|
319
319
|
}
|
|
320
320
|
return [
|
|
321
321
|
newValue1
|
|
@@ -328,35 +328,36 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
328
328
|
var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
329
329
|
"use strict";
|
|
330
330
|
_inherits(MoneyValueChecker, ValueChecker);
|
|
331
|
-
var _super =
|
|
331
|
+
var _super = _create_super(MoneyValueChecker);
|
|
332
332
|
function MoneyValueChecker() {
|
|
333
|
-
|
|
333
|
+
_class_call_check(this, MoneyValueChecker);
|
|
334
334
|
return _super.apply(this, arguments);
|
|
335
335
|
}
|
|
336
|
-
|
|
336
|
+
_create_class(MoneyValueChecker, [
|
|
337
337
|
{
|
|
338
338
|
key: "validate",
|
|
339
339
|
value: function validate(value) {
|
|
340
340
|
return(// value instanceof AmountValue ||
|
|
341
|
-
|
|
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
|
+
var _oldValue;
|
|
348
349
|
return new AmountValue({
|
|
349
|
-
currency: oldValue === null ||
|
|
350
|
+
currency: (_oldValue = oldValue) === null || _oldValue === void 0 ? void 0 : _oldValue.currency
|
|
350
351
|
});
|
|
351
352
|
}
|
|
352
353
|
var result;
|
|
353
354
|
if (isPlainObject(value)) {
|
|
354
|
-
result = new AmountValue(
|
|
355
|
+
result = new AmountValue(_object_spread({}, oldValue, value));
|
|
355
356
|
}
|
|
356
357
|
if (isString(value) && isJSONObject(value)) {
|
|
357
358
|
try {
|
|
358
359
|
var newValue = JSON.parse(value);
|
|
359
|
-
result = new AmountValue(
|
|
360
|
+
result = new AmountValue(_object_spread({}, oldValue, newValue));
|
|
360
361
|
} catch (e) {}
|
|
361
362
|
}
|
|
362
363
|
if (result) {
|
|
@@ -379,33 +380,33 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
379
380
|
var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
380
381
|
"use strict";
|
|
381
382
|
_inherits(TimeScopeValueChecker, ValueChecker);
|
|
382
|
-
var _super =
|
|
383
|
+
var _super = _create_super(TimeScopeValueChecker);
|
|
383
384
|
function TimeScopeValueChecker() {
|
|
384
|
-
|
|
385
|
+
_class_call_check(this, TimeScopeValueChecker);
|
|
385
386
|
return _super.apply(this, arguments);
|
|
386
387
|
}
|
|
387
|
-
|
|
388
|
+
_create_class(TimeScopeValueChecker, [
|
|
388
389
|
{
|
|
389
390
|
key: "validate",
|
|
390
391
|
value: function validate(value) {
|
|
391
392
|
return(// value instanceof RangeDateValue ||
|
|
392
|
-
|
|
393
|
+
isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max));
|
|
393
394
|
}
|
|
394
395
|
},
|
|
395
396
|
{
|
|
396
397
|
key: "transform",
|
|
397
398
|
value: function transform(value, oldValue) {
|
|
398
|
-
if (value === undefined || value === null || value ===
|
|
399
|
+
if (value === undefined || value === null || value === "") {
|
|
399
400
|
return new RangeDateValue();
|
|
400
401
|
}
|
|
401
402
|
var result;
|
|
402
403
|
if (isPlainObject(value)) {
|
|
403
|
-
result = new RangeDateValue(
|
|
404
|
+
result = new RangeDateValue(_object_spread({}, oldValue, value));
|
|
404
405
|
}
|
|
405
406
|
if (isString(value) && isJSONObject(value)) {
|
|
406
407
|
try {
|
|
407
408
|
var newValue = JSON.parse(value);
|
|
408
|
-
result = new RangeDateValue(
|
|
409
|
+
result = new RangeDateValue(_object_spread({}, oldValue, newValue));
|
|
409
410
|
} catch (e) {}
|
|
410
411
|
}
|
|
411
412
|
if (result) {
|
|
@@ -427,35 +428,36 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
427
428
|
var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
428
429
|
"use strict";
|
|
429
430
|
_inherits(CalcValueChecker, ValueChecker);
|
|
430
|
-
var _super =
|
|
431
|
+
var _super = _create_super(CalcValueChecker);
|
|
431
432
|
function CalcValueChecker() {
|
|
432
|
-
|
|
433
|
+
_class_call_check(this, CalcValueChecker);
|
|
433
434
|
return _super.apply(this, arguments);
|
|
434
435
|
}
|
|
435
|
-
|
|
436
|
+
_create_class(CalcValueChecker, [
|
|
436
437
|
{
|
|
437
438
|
key: "validate",
|
|
438
439
|
value: function validate(value) {
|
|
439
440
|
return(// value instanceof CalcValue ||
|
|
440
|
-
|
|
441
|
+
isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit));
|
|
441
442
|
}
|
|
442
443
|
},
|
|
443
444
|
{
|
|
444
445
|
key: "transform",
|
|
445
446
|
value: function transform(value, oldValue) {
|
|
446
|
-
if (value === undefined || value === null || value ===
|
|
447
|
+
if (value === undefined || value === null || value === "") {
|
|
448
|
+
var _oldValue;
|
|
447
449
|
return new CalcValue({
|
|
448
|
-
unit: oldValue === null ||
|
|
450
|
+
unit: (_oldValue = oldValue) === null || _oldValue === void 0 ? void 0 : _oldValue.unit
|
|
449
451
|
});
|
|
450
452
|
}
|
|
451
453
|
var result;
|
|
452
454
|
if (isPlainObject(value)) {
|
|
453
|
-
result = new CalcValue(
|
|
455
|
+
result = new CalcValue(_object_spread({}, oldValue, value));
|
|
454
456
|
}
|
|
455
457
|
if (isString(value) && isJSONObject(value)) {
|
|
456
458
|
try {
|
|
457
459
|
var newValue = JSON.parse(value);
|
|
458
|
-
result = new CalcValue(
|
|
460
|
+
result = new CalcValue(_object_spread({}, oldValue, newValue));
|
|
459
461
|
} catch (e) {}
|
|
460
462
|
}
|
|
461
463
|
if (result) {
|
|
@@ -478,12 +480,12 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
478
480
|
var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
479
481
|
"use strict";
|
|
480
482
|
_inherits(AddressValueChecker, ValueChecker);
|
|
481
|
-
var _super =
|
|
483
|
+
var _super = _create_super(AddressValueChecker);
|
|
482
484
|
function AddressValueChecker() {
|
|
483
|
-
|
|
485
|
+
_class_call_check(this, AddressValueChecker);
|
|
484
486
|
return _super.apply(this, arguments);
|
|
485
487
|
}
|
|
486
|
-
|
|
488
|
+
_create_class(AddressValueChecker, [
|
|
487
489
|
{
|
|
488
490
|
key: "validate",
|
|
489
491
|
value: function validate(value) {
|
|
@@ -504,17 +506,17 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
504
506
|
{
|
|
505
507
|
key: "transform",
|
|
506
508
|
value: function transform(value, oldValue) {
|
|
507
|
-
if (value === undefined || value === null || value ===
|
|
509
|
+
if (value === undefined || value === null || value === "") {
|
|
508
510
|
return new AddressValue();
|
|
509
511
|
}
|
|
510
512
|
var result;
|
|
511
513
|
if (isPlainObject(value)) {
|
|
512
|
-
result = new AddressValue(
|
|
514
|
+
result = new AddressValue(_object_spread({}, oldValue, camelizeKeys(value)));
|
|
513
515
|
}
|
|
514
516
|
if (isString(value) && isJSONObject(value)) {
|
|
515
517
|
try {
|
|
516
518
|
var newValue = JSON.parse(value);
|
|
517
|
-
result = new AddressValue(
|
|
519
|
+
result = new AddressValue(_object_spread({}, oldValue, camelizeKeys(newValue)));
|
|
518
520
|
} catch (e) {}
|
|
519
521
|
}
|
|
520
522
|
if (result) {
|
|
@@ -539,9 +541,9 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
539
541
|
var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
540
542
|
"use strict";
|
|
541
543
|
function ValueCheckerFactory() {
|
|
542
|
-
|
|
544
|
+
_class_call_check(this, ValueCheckerFactory);
|
|
543
545
|
}
|
|
544
|
-
|
|
546
|
+
_create_class(ValueCheckerFactory, null, [
|
|
545
547
|
{
|
|
546
548
|
key: "getValueChecker",
|
|
547
549
|
value: function getValueChecker(fieldType) {
|
|
@@ -588,22 +590,22 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
588
590
|
}();
|
|
589
591
|
function getFieldTypeFromKey(key) {
|
|
590
592
|
if ([
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
593
|
+
"min",
|
|
594
|
+
"max",
|
|
595
|
+
"currency",
|
|
596
|
+
"unit"
|
|
595
597
|
].includes(key)) {
|
|
596
598
|
return FieldTypes.VARCHAR;
|
|
597
599
|
} else if ([
|
|
598
|
-
|
|
599
|
-
|
|
600
|
+
"result",
|
|
601
|
+
"amount"
|
|
600
602
|
].includes(key)) {
|
|
601
603
|
return FieldTypes.DECIMAL;
|
|
602
604
|
}
|
|
603
605
|
}
|
|
604
606
|
export function checkerValue(fieldType, key, value, oldValue) {
|
|
605
|
-
var
|
|
606
|
-
var getCheckerFieldType = (
|
|
607
|
+
var _getFieldTypeFromKey;
|
|
608
|
+
var getCheckerFieldType = (_getFieldTypeFromKey = getFieldTypeFromKey(key)) !== null && _getFieldTypeFromKey !== void 0 ? _getFieldTypeFromKey : fieldType;
|
|
607
609
|
var checker = ValueCheckerFactory.getValueChecker(getCheckerFieldType);
|
|
608
610
|
if (!checker || checker.validate(value)) {
|
|
609
611
|
return value;
|
|
@@ -621,7 +623,7 @@ export function checkerValue(fieldType, key, value, oldValue) {
|
|
|
621
623
|
}
|
|
622
624
|
export function checkerSubtableValue(fieldTypeMap, value, emptyValue) {
|
|
623
625
|
return Object.entries(fieldTypeMap).reduce(function(result, param) {
|
|
624
|
-
var _param =
|
|
626
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], fieldType = _param[1];
|
|
625
627
|
var nowValue = value[key];
|
|
626
628
|
result[key] = checkerValue(fieldType, key, nowValue, emptyValue[key]);
|
|
627
629
|
return result;
|
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";
|