@byteluck-fe/model-driven-engine 2.5.1-alpha.1 → 2.5.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 +28 -28
- package/dist/esm/common/DataManager.js +12 -12
- package/dist/esm/common/Engine.js +127 -138
- package/dist/esm/common/OkWorker.js +10 -10
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +29 -29
- package/dist/esm/common/Store.js +43 -22
- package/dist/esm/common/checkerValue.js +77 -77
- package/dist/esm/common/proxyState.js +25 -23
- package/dist/esm/plugins/CalcPlugin.js +29 -29
- package/dist/esm/plugins/ControlsEventPlugin.js +19 -19
- package/dist/esm/plugins/ES6ModulePlugin.js +19 -19
- package/dist/esm/plugins/LifecycleEventPlugin.js +28 -28
- package/dist/esm/plugins/StylePlugin.js +7 -7
- package/dist/index.umd.js +9 -10
- package/dist/types/common/Engine.d.ts +2 -1
- package/dist/types/common/Store.d.ts +5 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
@@ -12,12 +12,12 @@ function _defineProperties(target, props) {
|
|
|
12
12
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
16
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
17
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
18
|
return Constructor;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
21
|
if (key in obj) {
|
|
22
22
|
Object.defineProperty(obj, key, {
|
|
23
23
|
value: value,
|
|
@@ -34,10 +34,10 @@ import { log } from "@byteluck-fe/model-driven-shared";
|
|
|
34
34
|
var OkWorker = /*#__PURE__*/ function() {
|
|
35
35
|
"use strict";
|
|
36
36
|
function OkWorker() {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
_class_call_check(this, OkWorker);
|
|
38
|
+
_define_property(this, "worker", void 0);
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
_create_class(OkWorker, [
|
|
41
41
|
{
|
|
42
42
|
key: "run",
|
|
43
43
|
value: function run(initState) {
|
|
@@ -77,7 +77,9 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
77
77
|
key: "createWorkerFunction",
|
|
78
78
|
value: function createWorkerFunction() {
|
|
79
79
|
return function() {
|
|
80
|
-
|
|
80
|
+
log("\uD83D\uDE80 worker running");
|
|
81
|
+
var _self = self;
|
|
82
|
+
function createHandler(parentKey) {
|
|
81
83
|
return {
|
|
82
84
|
get: function get(target, key, value) {
|
|
83
85
|
return Reflect.get(target, key, value);
|
|
@@ -92,9 +94,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
92
94
|
return Reflect.set(target, key, value);
|
|
93
95
|
}
|
|
94
96
|
};
|
|
95
|
-
}
|
|
96
|
-
log("\uD83D\uDE80 worker running");
|
|
97
|
-
var _self = self;
|
|
97
|
+
}
|
|
98
98
|
// function createProxy(
|
|
99
99
|
// obj: Record<string, unknown> | Array<Record<string, unknown>>,
|
|
100
100
|
// parentKey?: string
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
6
|
var Plugin = function Plugin() {
|
|
7
7
|
"use strict";
|
|
8
|
-
|
|
8
|
+
_class_call_check(this, Plugin);
|
|
9
9
|
};
|
|
10
10
|
export { Plugin };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
2
2
|
if (self === void 0) {
|
|
3
3
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
4
|
}
|
|
5
5
|
return self;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function _class_call_check(instance, Constructor) {
|
|
8
8
|
if (!(instance instanceof Constructor)) {
|
|
9
9
|
throw new TypeError("Cannot call a class as a function");
|
|
10
10
|
}
|
|
@@ -18,12 +18,12 @@ function _defineProperties(target, props) {
|
|
|
18
18
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
22
22
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
23
23
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
24
|
return Constructor;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function _define_property(obj, key, value) {
|
|
27
27
|
if (key in obj) {
|
|
28
28
|
Object.defineProperty(obj, key, {
|
|
29
29
|
value: value,
|
|
@@ -36,11 +36,11 @@ function _defineProperty(obj, key, value) {
|
|
|
36
36
|
}
|
|
37
37
|
return obj;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
39
|
+
function _get_prototype_of(o) {
|
|
40
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
41
41
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
42
42
|
};
|
|
43
|
-
return
|
|
43
|
+
return _get_prototype_of(o);
|
|
44
44
|
}
|
|
45
45
|
function _inherits(subClass, superClass) {
|
|
46
46
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -53,26 +53,26 @@ function _inherits(subClass, superClass) {
|
|
|
53
53
|
configurable: true
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
-
if (superClass)
|
|
56
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
if (call && (
|
|
58
|
+
function _possible_constructor_return(self, call) {
|
|
59
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
60
60
|
return call;
|
|
61
61
|
}
|
|
62
|
-
return
|
|
62
|
+
return _assert_this_initialized(self);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
64
|
+
function _set_prototype_of(o, p) {
|
|
65
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
66
66
|
o.__proto__ = p;
|
|
67
67
|
return o;
|
|
68
68
|
};
|
|
69
|
-
return
|
|
69
|
+
return _set_prototype_of(o, p);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
function _type_of(obj) {
|
|
72
72
|
"@swc/helpers - typeof";
|
|
73
73
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
74
|
-
}
|
|
75
|
-
function
|
|
74
|
+
}
|
|
75
|
+
function _is_native_reflect_construct() {
|
|
76
76
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
77
77
|
if (Reflect.construct.sham) return false;
|
|
78
78
|
if (typeof Proxy === "function") return true;
|
|
@@ -83,17 +83,17 @@ function _isNativeReflectConstruct() {
|
|
|
83
83
|
return false;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
var hasNativeReflectConstruct =
|
|
86
|
+
function _create_super(Derived) {
|
|
87
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
88
88
|
return function _createSuperInternal() {
|
|
89
|
-
var Super =
|
|
89
|
+
var Super = _get_prototype_of(Derived), result;
|
|
90
90
|
if (hasNativeReflectConstruct) {
|
|
91
|
-
var NewTarget =
|
|
91
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
92
92
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
93
93
|
} else {
|
|
94
94
|
result = Super.apply(this, arguments);
|
|
95
95
|
}
|
|
96
|
-
return
|
|
96
|
+
return _possible_constructor_return(this, result);
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
import { RegisterControls } from "@byteluck-fe/model-driven-core";
|
|
@@ -102,22 +102,22 @@ import { hasChildrenControl, loopDataViewControl, loopFormControl } from "../uti
|
|
|
102
102
|
export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
103
103
|
"use strict";
|
|
104
104
|
_inherits(Runtime, RegisterControls);
|
|
105
|
-
var _super =
|
|
105
|
+
var _super = _create_super(Runtime);
|
|
106
106
|
function Runtime(props) {
|
|
107
|
-
|
|
107
|
+
_class_call_check(this, Runtime);
|
|
108
108
|
var _this;
|
|
109
109
|
_this = _super.call(this, "Runtime");
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
_define_property(_assert_this_initialized(_this), "_schema", void 0);
|
|
111
|
+
_define_property(_assert_this_initialized(_this), "_instance", void 0);
|
|
112
|
+
_define_property(_assert_this_initialized(_this), "_flatInstances", []);
|
|
113
|
+
_define_property(_assert_this_initialized(_this), "_instanceMap", {});
|
|
114
114
|
var schema = props.schema;
|
|
115
115
|
_this._schema = schema;
|
|
116
116
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
117
117
|
_this.getFlatInstances();
|
|
118
118
|
return _this;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
_create_class(Runtime, [
|
|
121
121
|
{
|
|
122
122
|
key: "getFlatInstances",
|
|
123
123
|
value: function getFlatInstances() {
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
@@ -12,12 +12,12 @@ function _defineProperties(target, props) {
|
|
|
12
12
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
16
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
17
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
18
|
return Constructor;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
21
|
if (key in obj) {
|
|
22
22
|
Object.defineProperty(obj, key, {
|
|
23
23
|
value: value,
|
|
@@ -37,7 +37,7 @@ function _instanceof(left, right) {
|
|
|
37
37
|
return left instanceof right;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function _object_spread(target) {
|
|
41
41
|
for(var i = 1; i < arguments.length; i++){
|
|
42
42
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
43
43
|
var ownKeys = Object.keys(source);
|
|
@@ -47,7 +47,7 @@ function _objectSpread(target) {
|
|
|
47
47
|
}));
|
|
48
48
|
}
|
|
49
49
|
ownKeys.forEach(function(key) {
|
|
50
|
-
|
|
50
|
+
_define_property(target, key, source[key]);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
return target;
|
|
@@ -58,21 +58,23 @@ import { loopDataViewControl, loopFormControl, buildUUID } from "../utils/runtim
|
|
|
58
58
|
var Store = /*#__PURE__*/ function() {
|
|
59
59
|
"use strict";
|
|
60
60
|
function Store(props) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
_class_call_check(this, Store);
|
|
62
|
+
_define_property(this, "emptyState", void 0);
|
|
63
|
+
_define_property(this, "state", void 0);
|
|
64
|
+
_define_property(this, "dataBindMapping", void 0 // 主要提供给二开使用
|
|
65
65
|
);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
_define_property(this, "controlIdMapping", void 0);
|
|
67
|
+
_define_property(this, "subtableHeadersControlIdMapping", void 0);
|
|
68
|
+
_define_property(this, "defaultState", void 0);
|
|
69
|
+
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState, subtableHeadersControlIdMapping = _init.subtableHeadersControlIdMapping;
|
|
69
70
|
this.emptyState = emptyState;
|
|
70
71
|
this.state = state;
|
|
71
72
|
this.dataBindMapping = databindMapping;
|
|
72
73
|
this.controlIdMapping = controlidMapping;
|
|
73
74
|
this.defaultState = defaultState;
|
|
75
|
+
this.subtableHeadersControlIdMapping = subtableHeadersControlIdMapping;
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
_create_class(Store, [
|
|
76
78
|
{
|
|
77
79
|
/**
|
|
78
80
|
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
@@ -82,9 +84,10 @@ var Store = /*#__PURE__*/ function() {
|
|
|
82
84
|
value: function setState(controlId, value, rowIndex) {
|
|
83
85
|
var _this = this;
|
|
84
86
|
var controlInfo = this.controlIdMapping[controlId];
|
|
87
|
+
var noProxyValue = JSONCopy(value);
|
|
85
88
|
if (controlInfo !== undefined) {
|
|
86
89
|
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
87
|
-
this.state[controlInfo.dataView][controlId] =
|
|
90
|
+
this.state[controlInfo.dataView][controlId] = noProxyValue;
|
|
88
91
|
// if (
|
|
89
92
|
// controlInfo.dataBind instanceof ObjectDataBind &&
|
|
90
93
|
// isPlainObject(value)
|
|
@@ -102,14 +105,16 @@ var Store = /*#__PURE__*/ function() {
|
|
|
102
105
|
if (children !== undefined) {
|
|
103
106
|
Object.keys(children).map(function(childControlId) {
|
|
104
107
|
if (childControlId === controlId) {
|
|
105
|
-
_this.state[dataView][subtableId][rowIndex]
|
|
108
|
+
if (_this.state[dataView][subtableId][rowIndex]) {
|
|
109
|
+
_this.state[dataView][subtableId][rowIndex][controlId] = noProxyValue;
|
|
110
|
+
}
|
|
106
111
|
}
|
|
107
112
|
});
|
|
108
113
|
}
|
|
109
114
|
});
|
|
110
115
|
} else {
|
|
111
116
|
//不存在的 controlId,直接被挂载到外部key
|
|
112
|
-
this.state[controlId] =
|
|
117
|
+
this.state[controlId] = noProxyValue;
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
}
|
|
@@ -231,6 +236,7 @@ function init(instance) {
|
|
|
231
236
|
var emptyState = {};
|
|
232
237
|
var databindMapping = {};
|
|
233
238
|
var controlidMapping = {};
|
|
239
|
+
var subtableHeadersControlIdMapping = {};
|
|
234
240
|
var defaultState = {};
|
|
235
241
|
// loopFormControl(instance, (item, children) => {
|
|
236
242
|
// })
|
|
@@ -246,6 +252,7 @@ function init(instance) {
|
|
|
246
252
|
buildState(dataViewState, emptyDataViewState, item);
|
|
247
253
|
buildDataBindMapping(databindMapping, dvId, item);
|
|
248
254
|
buildControlIdMapping(controlidMapping, dvId, item);
|
|
255
|
+
buildSubtableHeadersControlIdMapping(subtableHeadersControlIdMapping, item);
|
|
249
256
|
});
|
|
250
257
|
state[dvId] = {};
|
|
251
258
|
defaultState[dvId] = dataViewState;
|
|
@@ -254,6 +261,7 @@ function init(instance) {
|
|
|
254
261
|
return {
|
|
255
262
|
state: state,
|
|
256
263
|
defaultState: defaultState,
|
|
264
|
+
subtableHeadersControlIdMapping: subtableHeadersControlIdMapping,
|
|
257
265
|
emptyState: emptyState,
|
|
258
266
|
databindMapping: databindMapping,
|
|
259
267
|
controlidMapping: controlidMapping
|
|
@@ -271,12 +279,12 @@ item) {
|
|
|
271
279
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
272
280
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
273
281
|
});
|
|
274
|
-
var _item_props_defaultRows;
|
|
275
|
-
dataViewState[item.id] = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
276
|
-
return
|
|
282
|
+
var _item_props_defaultRows, _fill_map;
|
|
283
|
+
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() {
|
|
284
|
+
return _object_spread({
|
|
277
285
|
uid: "new:" + buildUUID("uid")
|
|
278
286
|
}, JSONCopy(emptyTemplate));
|
|
279
|
-
});
|
|
287
|
+
})) !== null && _fill_map !== void 0 ? _fill_map : [];
|
|
280
288
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
281
289
|
}
|
|
282
290
|
}
|
|
@@ -284,7 +292,7 @@ function buildDataBindMapping(data, dataViewId, // @ts-ignore
|
|
|
284
292
|
item) {
|
|
285
293
|
// if (item instanceof RuntimeFormControl) {
|
|
286
294
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
287
|
-
var
|
|
295
|
+
var _item_props_dataBind, _item_props;
|
|
288
296
|
if (_instanceof(item.props.dataBind, ObjectDataBind)) {
|
|
289
297
|
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
290
298
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
@@ -390,10 +398,23 @@ item) {
|
|
|
390
398
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
391
399
|
var _data_item_id;
|
|
392
400
|
var _data_item_id_children;
|
|
393
|
-
Object.assign((_data_item_id_children = (_data_item_id = data[item.id]) === null || _data_item_id === void 0 ? void 0 : _data_item_id.children) !== null && _data_item_id_children !== void 0 ? _data_item_id_children : {},
|
|
401
|
+
Object.assign((_data_item_id_children = (_data_item_id = data[item.id]) === null || _data_item_id === void 0 ? void 0 : _data_item_id.children) !== null && _data_item_id_children !== void 0 ? _data_item_id_children : {}, _define_property({}, formControl.id, {
|
|
394
402
|
dataBind: formControl.props.dataBind
|
|
395
403
|
}));
|
|
396
404
|
});
|
|
397
405
|
}
|
|
398
406
|
}
|
|
407
|
+
function buildSubtableHeadersControlIdMapping(data, // @ts-ignore
|
|
408
|
+
item) {
|
|
409
|
+
if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
410
|
+
var headersInstances = {};
|
|
411
|
+
item.props.headers.map(// @ts-ignore
|
|
412
|
+
function(item) {
|
|
413
|
+
item.children.map(function(item) {
|
|
414
|
+
Object.assign(headersInstances, _define_property({}, item.id, item));
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
Object.assign(data, _define_property({}, item.id, headersInstances));
|
|
418
|
+
}
|
|
419
|
+
}
|
|
399
420
|
export { Store };
|