@byteluck-fe/model-driven-engine 2.9.0-beta.1 → 2.9.0-beta.3
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 +112 -95
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +27 -43
- package/dist/esm/common/Store.js +12 -9
- package/dist/esm/common/checkerValue.js +39 -59
- 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 +21 -17
- package/dist/esm/plugins/ControlsEventPlugin.js +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +7 -7
- 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 +7 -12
- package/dist/types/common/Engine.d.ts +2 -0
- package/package.json +2 -2
|
@@ -4,6 +4,10 @@ function _assert_this_initialized(self) {
|
|
|
4
4
|
}
|
|
5
5
|
return self;
|
|
6
6
|
}
|
|
7
|
+
function _call_super(_this, derived, args) {
|
|
8
|
+
derived = _get_prototype_of(derived);
|
|
9
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
10
|
+
}
|
|
7
11
|
function _class_call_check(instance, Constructor) {
|
|
8
12
|
if (!(instance instanceof Constructor)) {
|
|
9
13
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -73,45 +77,25 @@ function _type_of(obj) {
|
|
|
73
77
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
74
78
|
}
|
|
75
79
|
function _is_native_reflect_construct() {
|
|
76
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
77
|
-
if (Reflect.construct.sham) return false;
|
|
78
|
-
if (typeof Proxy === "function") return true;
|
|
79
80
|
try {
|
|
80
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function _create_super(Derived) {
|
|
87
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
88
|
-
return function _createSuperInternal() {
|
|
89
|
-
var Super = _get_prototype_of(Derived), result;
|
|
90
|
-
if (hasNativeReflectConstruct) {
|
|
91
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
92
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
93
|
-
} else {
|
|
94
|
-
result = Super.apply(this, arguments);
|
|
95
|
-
}
|
|
96
|
-
return _possible_constructor_return(this, result);
|
|
97
|
-
};
|
|
81
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
82
|
+
} catch (_) {}
|
|
83
|
+
return (_is_native_reflect_construct = function() {
|
|
84
|
+
return !!result;
|
|
85
|
+
})();
|
|
98
86
|
}
|
|
99
|
-
import { RegisterControls, isDataBind } from
|
|
100
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema, isArray } from
|
|
101
|
-
import { hasChildrenControl, loopDataViewControl, loopFormControl } from
|
|
87
|
+
import { RegisterControls, isDataBind } from '@byteluck-fe/model-driven-core';
|
|
88
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema, isArray } from '@byteluck-fe/model-driven-shared';
|
|
89
|
+
import { hasChildrenControl, loopDataViewControl, loopFormControl } from '../utils/runtimeUtils';
|
|
102
90
|
export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
103
91
|
"use strict";
|
|
104
92
|
_inherits(Runtime, RegisterControls);
|
|
105
|
-
var _super = _create_super(Runtime);
|
|
106
93
|
function Runtime(props) {
|
|
107
94
|
_class_call_check(this, Runtime);
|
|
108
95
|
var _this;
|
|
109
|
-
_this =
|
|
110
|
-
|
|
111
|
-
_define_property(
|
|
112
|
-
_define_property(_assert_this_initialized(_this), "_flatInstances", []);
|
|
113
|
-
_define_property(_assert_this_initialized(_this), "_instanceMap", {});
|
|
114
|
-
_define_property(_assert_this_initialized(_this), "_controlParentIdMap", {});
|
|
96
|
+
_this = _call_super(this, Runtime, [
|
|
97
|
+
'Runtime'
|
|
98
|
+
]), _define_property(_this, "_schema", void 0), _define_property(_this, "_instance", void 0), _define_property(_this, "_flatInstances", []), _define_property(_this, "_instanceMap", {}), _define_property(_this, "_controlParentIdMap", {});
|
|
115
99
|
var schema = props.schema;
|
|
116
100
|
_this._schema = schema;
|
|
117
101
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
@@ -125,7 +109,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
125
109
|
var instances = [];
|
|
126
110
|
var instanceMap = {};
|
|
127
111
|
var controlParentIdMap = {};
|
|
128
|
-
loop(this._instance,
|
|
112
|
+
loop(this._instance, '', function(item, parentId) {
|
|
129
113
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
130
114
|
//4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
|
|
131
115
|
// if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
@@ -139,7 +123,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
139
123
|
instanceMap[item.id] = [];
|
|
140
124
|
}
|
|
141
125
|
//不知为何subtable-column会多存一次
|
|
142
|
-
if (item.type ===
|
|
126
|
+
if (item.type === 'subtable-column') {
|
|
143
127
|
if (instanceMap[item.id].length > 0) {
|
|
144
128
|
return;
|
|
145
129
|
}
|
|
@@ -290,10 +274,10 @@ function loop(control, parentId, callback) {
|
|
|
290
274
|
// @ts-ignore
|
|
291
275
|
loop(ctl.children, ctl.id, callback);
|
|
292
276
|
}
|
|
293
|
-
if (hasHeaderOrFooterControl(item,
|
|
277
|
+
if (hasHeaderOrFooterControl(item, 'headers')) {
|
|
294
278
|
loop(item.props.headers, item.id, callback);
|
|
295
279
|
}
|
|
296
|
-
if (hasHeaderOrFooterControl(item,
|
|
280
|
+
if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
297
281
|
loop(item.props.footers, item.id, callback);
|
|
298
282
|
}
|
|
299
283
|
});
|
|
@@ -327,7 +311,7 @@ item) {
|
|
|
327
311
|
// data[item.id] = item.rules
|
|
328
312
|
data[item.id] = result;
|
|
329
313
|
var itemRules = {
|
|
330
|
-
type:
|
|
314
|
+
type: 'array',
|
|
331
315
|
fields: {}
|
|
332
316
|
};
|
|
333
317
|
(isSubtableDefaultRules === true ? [
|
|
@@ -339,7 +323,7 @@ item) {
|
|
|
339
323
|
if (itemRules.fields) {
|
|
340
324
|
if (!itemRules.fields[index]) {
|
|
341
325
|
itemRules.fields[index] = {
|
|
342
|
-
type:
|
|
326
|
+
type: 'object',
|
|
343
327
|
required: true,
|
|
344
328
|
fields: {}
|
|
345
329
|
};
|
|
@@ -368,7 +352,7 @@ item) {
|
|
|
368
352
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
369
353
|
if (isDataBind(item.props.dataBind)) {
|
|
370
354
|
var _item_props_dataBind;
|
|
371
|
-
if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) !=
|
|
355
|
+
if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) != '') {
|
|
372
356
|
var _item_props_dataBind1;
|
|
373
357
|
data[(_item_props_dataBind1 = item.props.dataBind) === null || _item_props_dataBind1 === void 0 ? void 0 : _item_props_dataBind1.fieldCode] = result;
|
|
374
358
|
}
|
|
@@ -376,7 +360,7 @@ item) {
|
|
|
376
360
|
for(var dataBindKey in item.props.dataBind){
|
|
377
361
|
var _item_props_dataBind_dataBindKey;
|
|
378
362
|
// @ts-ignore
|
|
379
|
-
if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) !=
|
|
363
|
+
if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) != '') {
|
|
380
364
|
var // @ts-ignore
|
|
381
365
|
_item_props_dataBind_dataBindKey1, _findFields;
|
|
382
366
|
// @ts-ignore
|
|
@@ -388,7 +372,7 @@ item) {
|
|
|
388
372
|
var _item_props_datasourceBind, _item_props_datasourceBind1;
|
|
389
373
|
data[(_item_props_datasourceBind = item.props.datasourceBind) === null || _item_props_datasourceBind === void 0 ? void 0 : _item_props_datasourceBind.dataCode] = result;
|
|
390
374
|
var itemRules = {
|
|
391
|
-
type:
|
|
375
|
+
type: 'array',
|
|
392
376
|
fields: {}
|
|
393
377
|
};
|
|
394
378
|
(isSubtableDefaultRules === true ? [
|
|
@@ -400,7 +384,7 @@ item) {
|
|
|
400
384
|
if (itemRules.fields) {
|
|
401
385
|
if (!itemRules.fields[index]) {
|
|
402
386
|
itemRules.fields[index] = {
|
|
403
|
-
type:
|
|
387
|
+
type: 'object',
|
|
404
388
|
required: true,
|
|
405
389
|
fields: {}
|
|
406
390
|
};
|
|
@@ -410,7 +394,7 @@ item) {
|
|
|
410
394
|
for(var dataBindKey in formControl.props.dataBind){
|
|
411
395
|
var _formControl_props_dataBind_dataBindKey;
|
|
412
396
|
// @ts-ignore
|
|
413
|
-
if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) !=
|
|
397
|
+
if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) != '') {
|
|
414
398
|
var _findFields;
|
|
415
399
|
// @ts-ignore
|
|
416
400
|
itemRules.fields[index].fields[// @ts-ignore
|
|
@@ -419,7 +403,7 @@ item) {
|
|
|
419
403
|
}
|
|
420
404
|
} else {
|
|
421
405
|
var _formControl_props_dataBind;
|
|
422
|
-
if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) !=
|
|
406
|
+
if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) != '') {
|
|
423
407
|
var _formControl_props_dataBind1;
|
|
424
408
|
// @ts-ignore
|
|
425
409
|
itemRules.fields[index].fields[(_formControl_props_dataBind1 = formControl.props.dataBind) === null || _formControl_props_dataBind1 === void 0 ? void 0 : _formControl_props_dataBind1.fieldCode] = childResult;
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -45,9 +45,9 @@ function _object_spread(target) {
|
|
|
45
45
|
}
|
|
46
46
|
return target;
|
|
47
47
|
}
|
|
48
|
-
import { DataBind, isDataBind } from
|
|
49
|
-
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from
|
|
50
|
-
import { loopDataViewControl, loopFormControl, buildUUID } from
|
|
48
|
+
import { DataBind, isDataBind } from '@byteluck-fe/model-driven-core';
|
|
49
|
+
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
50
|
+
import { loopDataViewControl, loopFormControl, buildUUID } from '../utils/runtimeUtils';
|
|
51
51
|
var Store = /*#__PURE__*/ function() {
|
|
52
52
|
"use strict";
|
|
53
53
|
function Store(props) {
|
|
@@ -81,10 +81,11 @@ var Store = /*#__PURE__*/ function() {
|
|
|
81
81
|
if (controlInfo !== undefined) {
|
|
82
82
|
//明细表
|
|
83
83
|
if (controlInfo.children) {
|
|
84
|
+
;
|
|
84
85
|
value.forEach(function(item) {
|
|
85
86
|
if (!item.uid) {
|
|
86
87
|
Object.assign(item, {
|
|
87
|
-
uid:
|
|
88
|
+
uid: 'new:' + buildUUID('uid')
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
});
|
|
@@ -109,6 +110,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
109
110
|
Object.keys(children).map(function(childControlId) {
|
|
110
111
|
if (childControlId === controlId) {
|
|
111
112
|
if (_this.state[dataView][subtableId][rowIndex]) {
|
|
113
|
+
;
|
|
112
114
|
_this.state[dataView][subtableId][rowIndex][controlId] = noProxyValue;
|
|
113
115
|
}
|
|
114
116
|
}
|
|
@@ -167,6 +169,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
167
169
|
if (children !== undefined) {
|
|
168
170
|
Object.keys(children).map(function(childControlId) {
|
|
169
171
|
if (childControlId === controlId) {
|
|
172
|
+
;
|
|
170
173
|
_this.state[dataViewId][subtableId].map(function(item) {
|
|
171
174
|
states.push(item[controlId]);
|
|
172
175
|
});
|
|
@@ -192,9 +195,9 @@ var Store = /*#__PURE__*/ function() {
|
|
|
192
195
|
if (controlInfo !== undefined) {
|
|
193
196
|
var state = this.emptyState[controlInfo.dataView][controlId];
|
|
194
197
|
//判断找到的是否是明细表的控件
|
|
195
|
-
if (
|
|
198
|
+
if ('children' in controlInfo) {
|
|
196
199
|
Object.assign(state, {
|
|
197
|
-
uid:
|
|
200
|
+
uid: 'new:' + buildUUID('uid')
|
|
198
201
|
});
|
|
199
202
|
}
|
|
200
203
|
return state;
|
|
@@ -292,7 +295,7 @@ item) {
|
|
|
292
295
|
var _item_props_defaultRows, _fill_map;
|
|
293
296
|
dataViewState[item.id] = (_fill_map = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
294
297
|
return _object_spread({
|
|
295
|
-
uid:
|
|
298
|
+
uid: 'new:' + buildUUID('uid')
|
|
296
299
|
}, JSONCopy(emptyTemplate));
|
|
297
300
|
})) !== null && _fill_map !== void 0 ? _fill_map : [];
|
|
298
301
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
@@ -347,7 +350,7 @@ item) {
|
|
|
347
350
|
});
|
|
348
351
|
}
|
|
349
352
|
} else {
|
|
350
|
-
if (item.props.datasourceBind.dataCode ===
|
|
353
|
+
if (item.props.datasourceBind.dataCode === '') {
|
|
351
354
|
//敏捷依赖后端生成dataCode,预览的时候没有
|
|
352
355
|
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item.id, " type:").concat(item.type));
|
|
353
356
|
return;
|
|
@@ -408,7 +411,7 @@ item) {
|
|
|
408
411
|
data[item.id] = {
|
|
409
412
|
dataBind: new DataBind({
|
|
410
413
|
dataCode: item.props.datasourceBind.dataCode,
|
|
411
|
-
fieldCode:
|
|
414
|
+
fieldCode: ''
|
|
412
415
|
}),
|
|
413
416
|
dataView: dataViewId,
|
|
414
417
|
children: {},
|
|
@@ -12,6 +12,10 @@ function _assert_this_initialized(self) {
|
|
|
12
12
|
}
|
|
13
13
|
return self;
|
|
14
14
|
}
|
|
15
|
+
function _call_super(_this, derived, args) {
|
|
16
|
+
derived = _get_prototype_of(derived);
|
|
17
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
18
|
+
}
|
|
15
19
|
function _class_call_check(instance, Constructor) {
|
|
16
20
|
if (!(instance instanceof Constructor)) {
|
|
17
21
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -134,32 +138,16 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
134
138
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
135
139
|
}
|
|
136
140
|
function _is_native_reflect_construct() {
|
|
137
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
138
|
-
if (Reflect.construct.sham) return false;
|
|
139
|
-
if (typeof Proxy === "function") return true;
|
|
140
141
|
try {
|
|
141
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function _create_super(Derived) {
|
|
148
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
149
|
-
return function _createSuperInternal() {
|
|
150
|
-
var Super = _get_prototype_of(Derived), result;
|
|
151
|
-
if (hasNativeReflectConstruct) {
|
|
152
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
153
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
154
|
-
} else {
|
|
155
|
-
result = Super.apply(this, arguments);
|
|
156
|
-
}
|
|
157
|
-
return _possible_constructor_return(this, result);
|
|
158
|
-
};
|
|
142
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
143
|
+
} catch (_) {}
|
|
144
|
+
return (_is_native_reflect_construct = function() {
|
|
145
|
+
return !!result;
|
|
146
|
+
})();
|
|
159
147
|
}
|
|
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
|
|
148
|
+
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from '@byteluck-fe/model-driven-shared';
|
|
149
|
+
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from '@byteluck-fe/model-driven-core';
|
|
150
|
+
import { camelizeKeys } from 'humps';
|
|
163
151
|
var ValueChecker = function ValueChecker() {
|
|
164
152
|
"use strict";
|
|
165
153
|
_class_call_check(this, ValueChecker);
|
|
@@ -167,10 +155,9 @@ var ValueChecker = function ValueChecker() {
|
|
|
167
155
|
var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
168
156
|
"use strict";
|
|
169
157
|
_inherits(StringValueChecker, ValueChecker);
|
|
170
|
-
var _super = _create_super(StringValueChecker);
|
|
171
158
|
function StringValueChecker() {
|
|
172
159
|
_class_call_check(this, StringValueChecker);
|
|
173
|
-
return
|
|
160
|
+
return _call_super(this, StringValueChecker, arguments);
|
|
174
161
|
}
|
|
175
162
|
_create_class(StringValueChecker, [
|
|
176
163
|
{
|
|
@@ -183,7 +170,7 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
183
170
|
key: "transform",
|
|
184
171
|
value: function transform(value) {
|
|
185
172
|
if (value === null || value === undefined) {
|
|
186
|
-
return
|
|
173
|
+
return '';
|
|
187
174
|
}
|
|
188
175
|
if (!isPlainObject(value) && !isFunction(value)) {
|
|
189
176
|
return String(value);
|
|
@@ -200,24 +187,23 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
200
187
|
var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
201
188
|
"use strict";
|
|
202
189
|
_inherits(NumberValueChecker, ValueChecker);
|
|
203
|
-
var _super = _create_super(NumberValueChecker);
|
|
204
190
|
function NumberValueChecker() {
|
|
205
191
|
_class_call_check(this, NumberValueChecker);
|
|
206
|
-
return
|
|
192
|
+
return _call_super(this, NumberValueChecker, arguments);
|
|
207
193
|
}
|
|
208
194
|
_create_class(NumberValueChecker, [
|
|
209
195
|
{
|
|
210
196
|
// 数字类型允许是空字符串,用于置空数据
|
|
211
197
|
key: "validate",
|
|
212
198
|
value: function validate(value) {
|
|
213
|
-
return isNumber(value) || value ===
|
|
199
|
+
return isNumber(value) || value === '';
|
|
214
200
|
}
|
|
215
201
|
},
|
|
216
202
|
{
|
|
217
203
|
key: "transform",
|
|
218
204
|
value: function transform(value) {
|
|
219
205
|
if (value === null || value === undefined) {
|
|
220
|
-
return
|
|
206
|
+
return '';
|
|
221
207
|
}
|
|
222
208
|
var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
|
|
223
209
|
if (!Number.isNaN(newValue) && newValue !== undefined) {
|
|
@@ -232,10 +218,9 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
232
218
|
var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
233
219
|
"use strict";
|
|
234
220
|
_inherits(StringArrayValueChecker, ValueChecker);
|
|
235
|
-
var _super = _create_super(StringArrayValueChecker);
|
|
236
221
|
function StringArrayValueChecker() {
|
|
237
222
|
_class_call_check(this, StringArrayValueChecker);
|
|
238
|
-
return
|
|
223
|
+
return _call_super(this, StringArrayValueChecker, arguments);
|
|
239
224
|
}
|
|
240
225
|
_create_class(StringArrayValueChecker, [
|
|
241
226
|
{
|
|
@@ -252,7 +237,7 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
252
237
|
}
|
|
253
238
|
function getStringValueArray(value) {
|
|
254
239
|
return value.map(function(item) {
|
|
255
|
-
return !item ?
|
|
240
|
+
return !item ? '' : String(item);
|
|
256
241
|
});
|
|
257
242
|
}
|
|
258
243
|
if (isArray(value)) {
|
|
@@ -277,10 +262,9 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
277
262
|
var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
278
263
|
"use strict";
|
|
279
264
|
_inherits(NumberArrayValueChecker, ValueChecker);
|
|
280
|
-
var _super = _create_super(NumberArrayValueChecker);
|
|
281
265
|
function NumberArrayValueChecker() {
|
|
282
266
|
_class_call_check(this, NumberArrayValueChecker);
|
|
283
|
-
return
|
|
267
|
+
return _call_super(this, NumberArrayValueChecker, arguments);
|
|
284
268
|
}
|
|
285
269
|
_create_class(NumberArrayValueChecker, [
|
|
286
270
|
{
|
|
@@ -297,9 +281,9 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
297
281
|
}
|
|
298
282
|
function getNumberValueArray(value) {
|
|
299
283
|
return value.map(function(item) {
|
|
300
|
-
return !item && item !== 0 ?
|
|
284
|
+
return !item && item !== 0 ? '' : Number(item);
|
|
301
285
|
}).filter(function(item) {
|
|
302
|
-
return item ===
|
|
286
|
+
return item === '' || !Number.isNaN(item);
|
|
303
287
|
});
|
|
304
288
|
}
|
|
305
289
|
if (isArray(value)) {
|
|
@@ -328,23 +312,22 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
328
312
|
var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
329
313
|
"use strict";
|
|
330
314
|
_inherits(MoneyValueChecker, ValueChecker);
|
|
331
|
-
var _super = _create_super(MoneyValueChecker);
|
|
332
315
|
function MoneyValueChecker() {
|
|
333
316
|
_class_call_check(this, MoneyValueChecker);
|
|
334
|
-
return
|
|
317
|
+
return _call_super(this, MoneyValueChecker, arguments);
|
|
335
318
|
}
|
|
336
319
|
_create_class(MoneyValueChecker, [
|
|
337
320
|
{
|
|
338
321
|
key: "validate",
|
|
339
322
|
value: function validate(value) {
|
|
340
323
|
return(// value instanceof AmountValue ||
|
|
341
|
-
isPlainObject(value) &&
|
|
324
|
+
isPlainObject(value) && 'amount' in value && isNumber(value.amount) && 'currency' in value && isString(value.currency));
|
|
342
325
|
}
|
|
343
326
|
},
|
|
344
327
|
{
|
|
345
328
|
key: "transform",
|
|
346
329
|
value: function transform(value, oldValue) {
|
|
347
|
-
if (value === undefined || value === null || value ===
|
|
330
|
+
if (value === undefined || value === null || value === '') {
|
|
348
331
|
return new AmountValue({
|
|
349
332
|
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
350
333
|
});
|
|
@@ -379,23 +362,22 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
379
362
|
var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
380
363
|
"use strict";
|
|
381
364
|
_inherits(TimeScopeValueChecker, ValueChecker);
|
|
382
|
-
var _super = _create_super(TimeScopeValueChecker);
|
|
383
365
|
function TimeScopeValueChecker() {
|
|
384
366
|
_class_call_check(this, TimeScopeValueChecker);
|
|
385
|
-
return
|
|
367
|
+
return _call_super(this, TimeScopeValueChecker, arguments);
|
|
386
368
|
}
|
|
387
369
|
_create_class(TimeScopeValueChecker, [
|
|
388
370
|
{
|
|
389
371
|
key: "validate",
|
|
390
372
|
value: function validate(value) {
|
|
391
373
|
return(// value instanceof RangeDateValue ||
|
|
392
|
-
isPlainObject(value) &&
|
|
374
|
+
isPlainObject(value) && 'min' in value && isString(value.min) && 'max' in value && isString(value.max));
|
|
393
375
|
}
|
|
394
376
|
},
|
|
395
377
|
{
|
|
396
378
|
key: "transform",
|
|
397
379
|
value: function transform(value, oldValue) {
|
|
398
|
-
if (value === undefined || value === null || value ===
|
|
380
|
+
if (value === undefined || value === null || value === '') {
|
|
399
381
|
return new RangeDateValue();
|
|
400
382
|
}
|
|
401
383
|
var result;
|
|
@@ -427,23 +409,22 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
427
409
|
var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
428
410
|
"use strict";
|
|
429
411
|
_inherits(CalcValueChecker, ValueChecker);
|
|
430
|
-
var _super = _create_super(CalcValueChecker);
|
|
431
412
|
function CalcValueChecker() {
|
|
432
413
|
_class_call_check(this, CalcValueChecker);
|
|
433
|
-
return
|
|
414
|
+
return _call_super(this, CalcValueChecker, arguments);
|
|
434
415
|
}
|
|
435
416
|
_create_class(CalcValueChecker, [
|
|
436
417
|
{
|
|
437
418
|
key: "validate",
|
|
438
419
|
value: function validate(value) {
|
|
439
420
|
return(// value instanceof CalcValue ||
|
|
440
|
-
isPlainObject(value) &&
|
|
421
|
+
isPlainObject(value) && 'result' in value && isNumber(value.result) && 'unit' in value && isString(value.unit));
|
|
441
422
|
}
|
|
442
423
|
},
|
|
443
424
|
{
|
|
444
425
|
key: "transform",
|
|
445
426
|
value: function transform(value, oldValue) {
|
|
446
|
-
if (value === undefined || value === null || value ===
|
|
427
|
+
if (value === undefined || value === null || value === '') {
|
|
447
428
|
return new CalcValue({
|
|
448
429
|
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
449
430
|
});
|
|
@@ -478,10 +459,9 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
478
459
|
var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
479
460
|
"use strict";
|
|
480
461
|
_inherits(AddressValueChecker, ValueChecker);
|
|
481
|
-
var _super = _create_super(AddressValueChecker);
|
|
482
462
|
function AddressValueChecker() {
|
|
483
463
|
_class_call_check(this, AddressValueChecker);
|
|
484
|
-
return
|
|
464
|
+
return _call_super(this, AddressValueChecker, arguments);
|
|
485
465
|
}
|
|
486
466
|
_create_class(AddressValueChecker, [
|
|
487
467
|
{
|
|
@@ -504,7 +484,7 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
504
484
|
{
|
|
505
485
|
key: "transform",
|
|
506
486
|
value: function transform(value, oldValue) {
|
|
507
|
-
if (value === undefined || value === null || value ===
|
|
487
|
+
if (value === undefined || value === null || value === '') {
|
|
508
488
|
return new AddressValue();
|
|
509
489
|
}
|
|
510
490
|
var result;
|
|
@@ -588,15 +568,15 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
588
568
|
}();
|
|
589
569
|
function getFieldTypeFromKey(key) {
|
|
590
570
|
if ([
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
571
|
+
'min',
|
|
572
|
+
'max',
|
|
573
|
+
'currency',
|
|
574
|
+
'unit'
|
|
595
575
|
].includes(key)) {
|
|
596
576
|
return FieldTypes.VARCHAR;
|
|
597
577
|
} else if ([
|
|
598
|
-
|
|
599
|
-
|
|
578
|
+
'result',
|
|
579
|
+
'amount'
|
|
600
580
|
].includes(key)) {
|
|
601
581
|
return FieldTypes.DECIMAL;
|
|
602
582
|
}
|
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';
|