@byteluck-fe/model-driven-engine 2.5.0-alpha.9 → 2.5.0-beta.1

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.
Files changed (33) hide show
  1. package/dist/esm/common/ActionManager.js +63 -98
  2. package/dist/esm/common/DataManager.js +34 -75
  3. package/dist/esm/common/Engine.js +931 -1100
  4. package/dist/esm/common/OkWorker.js +74 -119
  5. package/dist/esm/common/Runtime.js +21 -38
  6. package/dist/esm/common/Store.js +141 -152
  7. package/dist/esm/common/checkerValue.js +241 -316
  8. package/dist/esm/plugins/CalcPlugin.js +309 -389
  9. package/dist/esm/plugins/ControlsEventPlugin.js +130 -169
  10. package/dist/esm/plugins/ES6ModulePlugin.js +31 -65
  11. package/dist/esm/plugins/LifecycleEventPlugin.js +83 -119
  12. package/dist/esm/plugins/StylePlugin.js +13 -46
  13. package/dist/index.umd.js +8 -8
  14. package/dist/types/common/ActionManager.d.ts +14 -14
  15. package/dist/types/common/DataManager.d.ts +10 -10
  16. package/dist/types/common/Engine.d.ts +180 -180
  17. package/dist/types/common/OkWorker.d.ts +13 -13
  18. package/dist/types/common/Plugin.d.ts +6 -6
  19. package/dist/types/common/Runtime.d.ts +25 -25
  20. package/dist/types/common/Store.d.ts +50 -49
  21. package/dist/types/common/checkerValue.d.ts +3 -3
  22. package/dist/types/common/index.d.ts +2 -2
  23. package/dist/types/common/proxyState.d.ts +30 -30
  24. package/dist/types/index.d.ts +3 -3
  25. package/dist/types/plugins/CalcPlugin.d.ts +121 -121
  26. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
  27. package/dist/types/plugins/ES6ModulePlugin.d.ts +26 -26
  28. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -14
  29. package/dist/types/plugins/StylePlugin.d.ts +12 -12
  30. package/dist/types/plugins/index.d.ts +5 -5
  31. package/dist/types/utils/index.d.ts +1 -1
  32. package/dist/types/utils/runtimeUtils.d.ts +5 -5
  33. package/package.json +4 -4
@@ -3,20 +3,6 @@ function _classCallCheck(instance, Constructor) {
3
3
  throw new TypeError("Cannot call a class as a function");
4
4
  }
5
5
  }
6
- function _defineProperties(target, props) {
7
- for(var i = 0; i < props.length; i++){
8
- var descriptor = props[i];
9
- descriptor.enumerable = descriptor.enumerable || false;
10
- descriptor.configurable = true;
11
- if ("value" in descriptor) descriptor.writable = true;
12
- Object.defineProperty(target, descriptor.key, descriptor);
13
- }
14
- }
15
- function _createClass(Constructor, protoProps, staticProps) {
16
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
- if (staticProps) _defineProperties(Constructor, staticProps);
18
- return Constructor;
19
- }
20
6
  function _defineProperty(obj, key, value) {
21
7
  if (key in obj) {
22
8
  Object.defineProperty(obj, key, {
@@ -37,6 +23,21 @@ function _instanceof(left, right) {
37
23
  return left instanceof right;
38
24
  }
39
25
  }
26
+ function _objectSpread(target) {
27
+ for(var i = 1; i < arguments.length; i++){
28
+ var source = arguments[i] != null ? arguments[i] : {};
29
+ var ownKeys = Object.keys(source);
30
+ if (typeof Object.getOwnPropertySymbols === "function") {
31
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
32
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
33
+ }));
34
+ }
35
+ ownKeys.forEach(function(key) {
36
+ _defineProperty(target, key, source[key]);
37
+ });
38
+ }
39
+ return target;
40
+ }
40
41
  import { DataBind, ObjectDataBind } from "@byteluck-fe/model-driven-core";
41
42
  import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from "@byteluck-fe/model-driven-shared";
42
43
  import { loopDataViewControl, loopFormControl, buildUUID } from "../utils/runtimeUtils";
@@ -44,169 +45,152 @@ var Store = /*#__PURE__*/ function() {
44
45
  "use strict";
45
46
  function Store(props) {
46
47
  _classCallCheck(this, Store);
47
- _defineProperty(this, "emptyState", void 0);
48
- _defineProperty(this, "state", void 0);
49
- _defineProperty(this, "dataBindMapping", void 0 // 主要提供给二开使用
50
- );
51
- _defineProperty(this, "controlIdMapping", void 0);
52
- var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping;
48
+ var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState;
53
49
  this.emptyState = emptyState;
54
50
  this.state = state;
55
51
  this.dataBindMapping = databindMapping;
56
52
  this.controlIdMapping = controlidMapping;
53
+ this.defaultState = defaultState;
57
54
  }
58
- _createClass(Store, [
59
- {
60
- /**
55
+ var _proto = Store.prototype;
56
+ /**
61
57
  * 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
62
58
  * @param controlId 组件ID
63
59
  * @param value
64
- */ key: "setState",
65
- value: function setState(controlId, value, rowIndex) {
66
- var _this = this;
67
- var controlInfo = this.controlIdMapping[controlId];
68
- if (controlInfo !== undefined) {
69
- //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
70
- this.state[controlInfo.dataView][controlId] = value;
71
- // if (
72
- // controlInfo.dataBind instanceof ObjectDataBind &&
73
- // isPlainObject(value)
74
- // ) {
75
- // Object.assign(this.state[controlInfo.dataView][controlId], value)
76
- // } else {
77
- // this.state[controlInfo.dataView][controlId] = value
78
- // }
79
- } else {
80
- if (rowIndex !== undefined) {
81
- //TODO 目前只找了一层明细表,没有递归 如果是添加uid
82
- Object.keys(this.controlIdMapping).map(function(subtableId) {
83
- var dataView = _this.controlIdMapping[subtableId].dataView;
84
- var children = _this.controlIdMapping[subtableId].children;
85
- if (children !== undefined) {
86
- Object.keys(children).map(function(childControlId) {
87
- if (childControlId === controlId) {
88
- _this.state[dataView][subtableId][rowIndex][controlId] = value;
89
- }
90
- });
60
+ */ _proto.setState = function setState(controlId, value, rowIndex) {
61
+ var _this = this;
62
+ var controlInfo = this.controlIdMapping[controlId];
63
+ if (controlInfo !== undefined) {
64
+ //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
65
+ this.state[controlInfo.dataView][controlId] = value;
66
+ // if (
67
+ // controlInfo.dataBind instanceof ObjectDataBind &&
68
+ // isPlainObject(value)
69
+ // ) {
70
+ // Object.assign(this.state[controlInfo.dataView][controlId], value)
71
+ // } else {
72
+ // this.state[controlInfo.dataView][controlId] = value
73
+ // }
74
+ } else {
75
+ if (rowIndex !== undefined) {
76
+ //TODO 目前只找了一层明细表,没有递归 如果是添加uid
77
+ Object.keys(this.controlIdMapping).map(function(subtableId) {
78
+ var dataView = _this.controlIdMapping[subtableId].dataView;
79
+ var children = _this.controlIdMapping[subtableId].children;
80
+ if (children !== undefined) {
81
+ Object.keys(children).map(function(childControlId) {
82
+ if (childControlId === controlId) {
83
+ _this.state[dataView][subtableId][rowIndex][controlId] = value;
91
84
  }
92
85
  });
93
- } else {
94
- //不存在的 controlId,直接被挂载到外部key
95
- this.state[controlId] = value;
96
86
  }
97
- }
87
+ });
88
+ } else {
89
+ //不存在的 controlId,直接被挂载到外部key
90
+ this.state[controlId] = value;
98
91
  }
99
- },
100
- {
101
- key: "getState",
102
- value: function getState(controlId, rowIndex) {
103
- var _this = this;
104
- //qiyu 由于header的数据是后补充的,所以从state获取第一层值。
105
- // const controlInfo = this.controlIdMapping[controlId]
106
- var detection = this.state[controlId];
107
- if (detection !== undefined) {
108
- return this.state[controlId];
109
- } else {
110
- var controlInfo = this.controlIdMapping[controlId];
111
- if (controlInfo !== undefined) {
112
- return this.state[controlInfo.dataView][controlId];
113
- } else {
114
- if (rowIndex !== undefined) {
115
- var state;
116
- //TODO 目前只找了一层明细表,没有递归
117
- Object.keys(this.controlIdMapping).map(function(subtableId) {
118
- var dataViewId = _this.controlIdMapping[subtableId].dataView;
119
- var children = _this.controlIdMapping[subtableId].children;
120
- if (children !== undefined) {
121
- Object.keys(children).map(function(childControlId) {
122
- if (childControlId === controlId) {
123
- var _this_state_dataViewId_subtableId_rowIndex;
124
- state = (_this_state_dataViewId_subtableId_rowIndex = _this.state[dataViewId][subtableId][rowIndex]) === null || _this_state_dataViewId_subtableId_rowIndex === void 0 ? void 0 : _this_state_dataViewId_subtableId_rowIndex[controlId];
125
- }
126
- });
92
+ }
93
+ };
94
+ _proto.getState = function getState(controlId, rowIndex) {
95
+ var _this = this;
96
+ //qiyu 由于header的数据是后补充的,所以从state获取第一层值。
97
+ // const controlInfo = this.controlIdMapping[controlId]
98
+ var detection = this.state[controlId];
99
+ if (detection !== undefined) {
100
+ return this.state[controlId];
101
+ } else {
102
+ var controlInfo = this.controlIdMapping[controlId];
103
+ if (controlInfo !== undefined) {
104
+ return this.state[controlInfo.dataView][controlId];
105
+ } else {
106
+ if (rowIndex !== undefined) {
107
+ var state;
108
+ //TODO 目前只找了一层明细表,没有递归
109
+ Object.keys(this.controlIdMapping).map(function(subtableId) {
110
+ var dataViewId = _this.controlIdMapping[subtableId].dataView;
111
+ var children = _this.controlIdMapping[subtableId].children;
112
+ if (children !== undefined) {
113
+ Object.keys(children).map(function(childControlId) {
114
+ if (childControlId === controlId) {
115
+ var _this_state_dataViewId_subtableId_rowIndex;
116
+ state = (_this_state_dataViewId_subtableId_rowIndex = _this.state[dataViewId][subtableId][rowIndex]) === null || _this_state_dataViewId_subtableId_rowIndex === void 0 ? void 0 : _this_state_dataViewId_subtableId_rowIndex[controlId];
127
117
  }
128
118
  });
129
- return state;
130
- } else {
131
- var states = [];
132
- Object.keys(this.controlIdMapping).map(function(subtableId) {
133
- var dataViewId = _this.controlIdMapping[subtableId].dataView;
134
- var children = _this.controlIdMapping[subtableId].children;
135
- if (children !== undefined) {
136
- Object.keys(children).map(function(childControlId) {
137
- if (childControlId === controlId) {
138
- _this.state[dataViewId][subtableId].map(function(item) {
139
- states.push(item[controlId]);
140
- });
141
- }
119
+ }
120
+ });
121
+ return state;
122
+ } else {
123
+ var states = [];
124
+ Object.keys(this.controlIdMapping).map(function(subtableId) {
125
+ var dataViewId = _this.controlIdMapping[subtableId].dataView;
126
+ var children = _this.controlIdMapping[subtableId].children;
127
+ if (children !== undefined) {
128
+ Object.keys(children).map(function(childControlId) {
129
+ if (childControlId === controlId) {
130
+ _this.state[dataViewId][subtableId].map(function(item) {
131
+ states.push(item[controlId]);
142
132
  });
143
133
  }
144
134
  });
145
- return states;
146
135
  }
147
- }
136
+ });
137
+ return states;
148
138
  }
149
139
  }
150
- },
151
- {
152
- key: "getEmptyState",
153
- value: function getEmptyState(controlId) {
154
- var _this = this;
155
- var detection = this.emptyState[controlId];
156
- if (detection !== undefined) {
157
- return this.emptyState[controlId];
158
- } else {
159
- var controlInfo = this.controlIdMapping[controlId];
160
- if (controlInfo !== undefined) {
161
- var state = this.emptyState[controlInfo.dataView][controlId];
162
- //判断找到的是否是明细表的控件
163
- if ("children" in controlInfo) {
164
- Object.assign(state, {
165
- uid: "new:" + buildUUID("uid")
166
- });
167
- }
168
- return state;
169
- } else {
170
- var state1;
171
- //TODO 目前只找了一层明细表,没有递归
172
- Object.keys(this.controlIdMapping).map(function(subtableId) {
173
- var dataViewId = _this.controlIdMapping[subtableId].dataView;
174
- var children = _this.controlIdMapping[subtableId].children;
175
- if (children !== undefined) {
176
- Object.keys(children).map(function(childControlId) {
177
- if (childControlId === controlId) {
178
- state1 = _this.emptyState[dataViewId][subtableId][controlId];
179
- }
180
- });
140
+ }
141
+ };
142
+ _proto.getEmptyState = function getEmptyState(controlId) {
143
+ var _this = this;
144
+ var detection = this.emptyState[controlId];
145
+ if (detection !== undefined) {
146
+ return this.emptyState[controlId];
147
+ } else {
148
+ var controlInfo = this.controlIdMapping[controlId];
149
+ if (controlInfo !== undefined) {
150
+ var state = this.emptyState[controlInfo.dataView][controlId];
151
+ //判断找到的是否是明细表的控件
152
+ if ("children" in controlInfo) {
153
+ Object.assign(state, {
154
+ uid: "new:" + buildUUID("uid")
155
+ });
156
+ }
157
+ return state;
158
+ } else {
159
+ var state1;
160
+ //TODO 目前只找了一层明细表,没有递归
161
+ Object.keys(this.controlIdMapping).map(function(subtableId) {
162
+ var dataViewId = _this.controlIdMapping[subtableId].dataView;
163
+ var children = _this.controlIdMapping[subtableId].children;
164
+ if (children !== undefined) {
165
+ Object.keys(children).map(function(childControlId) {
166
+ if (childControlId === controlId) {
167
+ state1 = _this.emptyState[dataViewId][subtableId][controlId];
181
168
  }
182
169
  });
183
- return state1;
184
170
  }
185
- }
171
+ });
172
+ return state1;
186
173
  }
187
- },
188
- {
189
- key: "getDataBind",
190
- value: function getDataBind(controlId) {
191
- var result = this.controlIdMapping[controlId];
192
- if (result) {
193
- return result.dataBind;
194
- }
195
- wrapperFor: for(var id in this.controlIdMapping){
196
- var dataBindMapping = this.controlIdMapping[id];
197
- if (dataBindMapping.children) {
198
- for(var subId in dataBindMapping.children){
199
- if (subId === controlId) {
200
- result = dataBindMapping.children[subId];
201
- break wrapperFor;
202
- }
203
- }
174
+ }
175
+ };
176
+ _proto.getDataBind = function getDataBind(controlId) {
177
+ var result = this.controlIdMapping[controlId];
178
+ if (result) {
179
+ return result.dataBind;
180
+ }
181
+ wrapperFor: for(var id in this.controlIdMapping){
182
+ var dataBindMapping = this.controlIdMapping[id];
183
+ if (dataBindMapping.children) {
184
+ for(var subId in dataBindMapping.children){
185
+ if (subId === controlId) {
186
+ result = dataBindMapping.children[subId];
187
+ break wrapperFor;
204
188
  }
205
189
  }
206
- return result === null || result === void 0 ? void 0 : result.dataBind;
207
190
  }
208
191
  }
209
- ]);
192
+ return result === null || result === void 0 ? void 0 : result.dataBind;
193
+ };
210
194
  return Store;
211
195
  }();
212
196
  function init(instance) {
@@ -214,6 +198,7 @@ function init(instance) {
214
198
  var emptyState = {};
215
199
  var databindMapping = {};
216
200
  var controlidMapping = {};
201
+ var defaultState = {};
217
202
  // loopFormControl(instance, (item, children) => {
218
203
  // })
219
204
  // @ts-ignore
@@ -229,11 +214,13 @@ function init(instance) {
229
214
  buildDataBindMapping(databindMapping, dvId, item);
230
215
  buildControlIdMapping(controlidMapping, dvId, item);
231
216
  });
232
- state[dvId] = dataViewState;
217
+ state[dvId] = {};
218
+ defaultState[dvId] = dataViewState;
233
219
  emptyState[dvId] = emptyDataViewState;
234
220
  });
235
221
  return {
236
222
  state: state,
223
+ defaultState: defaultState,
237
224
  emptyState: emptyState,
238
225
  databindMapping: databindMapping,
239
226
  controlidMapping: controlidMapping
@@ -244,7 +231,7 @@ item) {
244
231
  //if (item instanceof RuntimeFormControl) {
245
232
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
246
233
  // 2023-4-2 jiaqi 首次进入页面去除填充默认值
247
- // dataViewState[item.id] = JSONCopy(item.props.defaultValue)
234
+ dataViewState[item.id] = JSONCopy(item.props.defaultValue);
248
235
  emptyDataViewState[item.id] = JSONCopy(item.props.defaultValue);
249
236
  } else {
250
237
  var emptyTemplate = {};
@@ -253,7 +240,9 @@ item) {
253
240
  });
254
241
  var _item_props_defaultRows;
255
242
  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() {
256
- return JSONCopy(emptyTemplate);
243
+ return _objectSpread({
244
+ uid: "new:" + buildUUID("uid")
245
+ }, JSONCopy(emptyTemplate));
257
246
  });
258
247
  emptyDataViewState[item.id] = emptyTemplate;
259
248
  }