@byteluck-fe/model-driven-engine 2.6.0-alpha.1 → 2.6.0-alpha.12

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 (39) hide show
  1. package/dist/esm/common/ActionManager.js +72 -154
  2. package/dist/esm/common/DataManager.js +60 -128
  3. package/dist/esm/common/Engine.js +1104 -1054
  4. package/dist/esm/common/OkWorker.js +106 -75
  5. package/dist/esm/common/Runtime.js +29 -27
  6. package/dist/esm/common/Store.js +180 -148
  7. package/dist/esm/common/checkerValue.js +328 -253
  8. package/dist/esm/common/index.js +2 -2
  9. package/dist/esm/common/proxyState.js +47 -47
  10. package/dist/esm/index.js +3 -3
  11. package/dist/esm/plugins/CalcPlugin.js +378 -302
  12. package/dist/esm/plugins/ControlsEventPlugin.js +141 -225
  13. package/dist/esm/plugins/ES6ModulePlugin.js +56 -38
  14. package/dist/esm/plugins/LifecycleEventPlugin.js +107 -190
  15. package/dist/esm/plugins/StylePlugin.js +31 -13
  16. package/dist/esm/plugins/index.js +5 -5
  17. package/dist/esm/utils/index.js +1 -1
  18. package/dist/esm/utils/runtimeUtils.js +7 -5
  19. package/dist/index.umd.js +8 -8
  20. package/dist/types/common/ActionManager.d.ts +14 -14
  21. package/dist/types/common/DataManager.d.ts +10 -10
  22. package/dist/types/common/Engine.d.ts +180 -180
  23. package/dist/types/common/OkWorker.d.ts +13 -13
  24. package/dist/types/common/Plugin.d.ts +6 -6
  25. package/dist/types/common/Runtime.d.ts +25 -25
  26. package/dist/types/common/Store.d.ts +49 -49
  27. package/dist/types/common/checkerValue.d.ts +3 -3
  28. package/dist/types/common/index.d.ts +2 -2
  29. package/dist/types/common/proxyState.d.ts +30 -30
  30. package/dist/types/index.d.ts +3 -3
  31. package/dist/types/plugins/CalcPlugin.d.ts +121 -121
  32. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
  33. package/dist/types/plugins/ES6ModulePlugin.d.ts +26 -26
  34. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -14
  35. package/dist/types/plugins/StylePlugin.d.ts +12 -12
  36. package/dist/types/plugins/index.d.ts +5 -5
  37. package/dist/types/utils/index.d.ts +1 -1
  38. package/dist/types/utils/runtimeUtils.d.ts +5 -5
  39. package/package.json +4 -4
@@ -3,6 +3,20 @@ 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
+ }
6
20
  function _defineProperty(obj, key, value) {
7
21
  if (key in obj) {
8
22
  Object.defineProperty(obj, key, {
@@ -18,163 +32,181 @@ function _defineProperty(obj, key, value) {
18
32
  }
19
33
  function _instanceof(left, right) {
20
34
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
21
- return !!right[Symbol.hasInstance](left);
35
+ return right[Symbol.hasInstance](left);
22
36
  } else {
23
37
  return left instanceof right;
24
38
  }
25
39
  }
26
- import { DataBind, ObjectDataBind } from "@byteluck-fe/model-driven-core";
27
- import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from "@byteluck-fe/model-driven-shared";
28
- import { loopDataViewControl, loopFormControl, buildUUID } from "../utils/runtimeUtils";
40
+ import { DataBind, ObjectDataBind } from '@byteluck-fe/model-driven-core';
41
+ import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from '@byteluck-fe/model-driven-shared';
42
+ import { loopDataViewControl, loopFormControl, buildUUID } from '../utils/runtimeUtils';
29
43
  var Store = /*#__PURE__*/ function() {
30
44
  "use strict";
31
45
  function Store(props) {
32
46
  _classCallCheck(this, Store);
33
- var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping;
47
+ var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping;
34
48
  this.emptyState = emptyState;
35
49
  this.state = state;
36
50
  this.dataBindMapping = databindMapping;
37
51
  this.controlIdMapping = controlidMapping;
38
52
  }
39
- var _proto = Store.prototype;
40
- /**
53
+ _createClass(Store, [
54
+ {
55
+ /**
41
56
  * 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
42
57
  * @param controlId 组件ID
43
58
  * @param value
44
- */ _proto.setState = function setState(controlId, value, rowIndex) {
45
- var _this = this;
46
- var controlInfo = this.controlIdMapping[controlId];
47
- if (controlInfo !== undefined) {
48
- //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
49
- this.state[controlInfo.dataView][controlId] = value;
50
- // if (
51
- // controlInfo.dataBind instanceof ObjectDataBind &&
52
- // isPlainObject(value)
53
- // ) {
54
- // Object.assign(this.state[controlInfo.dataView][controlId], value)
55
- // } else {
56
- // this.state[controlInfo.dataView][controlId] = value
57
- // }
58
- } else {
59
- if (rowIndex !== undefined) {
60
- //TODO 目前只找了一层明细表,没有递归 如果是添加uid
61
- Object.keys(this.controlIdMapping).map(function(subtableId) {
62
- var dataView = _this.controlIdMapping[subtableId].dataView;
63
- var children = _this.controlIdMapping[subtableId].children;
64
- if (children !== undefined) {
65
- Object.keys(children).map(function(childControlId) {
66
- if (childControlId === controlId) {
67
- _this.state[dataView][subtableId][rowIndex][controlId] = value;
59
+ */ key: "setState",
60
+ value: function setState(controlId, value, rowIndex) {
61
+ var controlInfo = this.controlIdMapping[controlId];
62
+ if (controlInfo !== undefined) {
63
+ //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
64
+ this.state[controlInfo.dataView][controlId] = value;
65
+ // if (
66
+ // controlInfo.dataBind instanceof ObjectDataBind &&
67
+ // isPlainObject(value)
68
+ // ) {
69
+ // Object.assign(this.state[controlInfo.dataView][controlId], value)
70
+ // } else {
71
+ // this.state[controlInfo.dataView][controlId] = value
72
+ // }
73
+ } else {
74
+ if (rowIndex !== undefined) {
75
+ var _this = this;
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
+ var _this1 = _this;
82
+ Object.keys(children).map(function(childControlId) {
83
+ if (childControlId === controlId) {
84
+ _this1.state[dataView][subtableId][rowIndex][controlId] = value;
85
+ }
86
+ });
68
87
  }
69
88
  });
89
+ } else {
90
+ //不存在的 controlId,直接被挂载到外部key
91
+ this.state[controlId] = value;
70
92
  }
71
- });
72
- } else {
73
- //不存在的 controlId,直接被挂载到外部key
74
- this.state[controlId] = value;
93
+ }
75
94
  }
76
- }
77
- };
78
- _proto.getState = function getState(controlId, rowIndex) {
79
- var _this = this;
80
- //qiyu 由于header的数据是后补充的,所以从state获取第一层值。
81
- // const controlInfo = this.controlIdMapping[controlId]
82
- var detection = this.state[controlId];
83
- if (detection !== undefined) {
84
- return this.state[controlId];
85
- } else {
86
- var controlInfo = this.controlIdMapping[controlId];
87
- if (controlInfo !== undefined) {
88
- return this.state[controlInfo.dataView][controlId];
89
- } else {
90
- if (rowIndex !== undefined) {
91
- var state;
92
- //TODO 目前只找了一层明细表,没有递归
93
- Object.keys(this.controlIdMapping).map(function(subtableId) {
94
- var dataViewId = _this.controlIdMapping[subtableId].dataView;
95
- var children = _this.controlIdMapping[subtableId].children;
96
- if (children !== undefined) {
97
- Object.keys(children).map(function(childControlId) {
98
- if (childControlId === controlId) {
99
- var _this_state_dataViewId_subtableId_rowIndex;
100
- 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];
95
+ },
96
+ {
97
+ key: "getState",
98
+ value: function getState(controlId, rowIndex) {
99
+ //qiyu 由于header的数据是后补充的,所以从state获取第一层值。
100
+ // const controlInfo = this.controlIdMapping[controlId]
101
+ var detection = this.state[controlId];
102
+ if (detection !== undefined) {
103
+ return this.state[controlId];
104
+ } else {
105
+ var controlInfo = this.controlIdMapping[controlId];
106
+ if (controlInfo !== undefined) {
107
+ return this.state[controlInfo.dataView][controlId];
108
+ } else {
109
+ if (rowIndex !== undefined) {
110
+ var _this = this;
111
+ var state;
112
+ //TODO 目前只找了一层明细表,没有递归
113
+ Object.keys(this.controlIdMapping).map(function(subtableId) {
114
+ var dataViewId = _this.controlIdMapping[subtableId].dataView;
115
+ var children = _this.controlIdMapping[subtableId].children;
116
+ if (children !== undefined) {
117
+ var _this3 = _this;
118
+ Object.keys(children).map(function(childControlId) {
119
+ if (childControlId === controlId) {
120
+ var ref;
121
+ state = (ref = _this3.state[dataViewId][subtableId][rowIndex]) === null || ref === void 0 ? void 0 : ref[controlId];
122
+ }
123
+ });
101
124
  }
102
125
  });
103
- }
104
- });
105
- return state;
106
- } else {
107
- var states = [];
108
- Object.keys(this.controlIdMapping).map(function(subtableId) {
109
- var dataViewId = _this.controlIdMapping[subtableId].dataView;
110
- var children = _this.controlIdMapping[subtableId].children;
111
- if (children !== undefined) {
112
- Object.keys(children).map(function(childControlId) {
113
- if (childControlId === controlId) {
114
- _this.state[dataViewId][subtableId].map(function(item) {
115
- states.push(item[controlId]);
126
+ return state;
127
+ } else {
128
+ var _this2 = this;
129
+ var states = [];
130
+ Object.keys(this.controlIdMapping).map(function(subtableId) {
131
+ var dataViewId = _this2.controlIdMapping[subtableId].dataView;
132
+ var children = _this2.controlIdMapping[subtableId].children;
133
+ if (children !== undefined) {
134
+ var _this = _this2;
135
+ Object.keys(children).map(function(childControlId) {
136
+ if (childControlId === controlId) {
137
+ _this.state[dataViewId][subtableId].map(function(item) {
138
+ states.push(item[controlId]);
139
+ });
140
+ }
116
141
  });
117
142
  }
118
143
  });
144
+ return states;
119
145
  }
120
- });
121
- return states;
146
+ }
122
147
  }
123
148
  }
124
- }
125
- };
126
- _proto.getEmptyState = function getEmptyState(controlId) {
127
- var _this = this;
128
- var detection = this.emptyState[controlId];
129
- if (detection !== undefined) {
130
- return this.emptyState[controlId];
131
- } else {
132
- var controlInfo = this.controlIdMapping[controlId];
133
- if (controlInfo !== undefined) {
134
- var state = this.emptyState[controlInfo.dataView][controlId];
135
- //判断找到的是否是明细表的控件
136
- if ("children" in controlInfo) {
137
- Object.assign(state, {
138
- uid: "new:" + buildUUID("uid")
139
- });
140
- }
141
- return state;
142
- } else {
143
- var state1;
144
- //TODO 目前只找了一层明细表,没有递归
145
- Object.keys(this.controlIdMapping).map(function(subtableId) {
146
- var dataViewId = _this.controlIdMapping[subtableId].dataView;
147
- var children = _this.controlIdMapping[subtableId].children;
148
- if (children !== undefined) {
149
- Object.keys(children).map(function(childControlId) {
150
- if (childControlId === controlId) {
151
- state1 = _this.emptyState[dataViewId][subtableId][controlId];
149
+ },
150
+ {
151
+ key: "getEmptyState",
152
+ value: function getEmptyState(controlId) {
153
+ var detection = this.emptyState[controlId];
154
+ if (detection !== undefined) {
155
+ return this.emptyState[controlId];
156
+ } else {
157
+ var controlInfo = this.controlIdMapping[controlId];
158
+ if (controlInfo !== undefined) {
159
+ var state = this.emptyState[controlInfo.dataView][controlId];
160
+ //判断找到的是否是明细表的控件
161
+ if ('children' in controlInfo) {
162
+ Object.assign(state, {
163
+ uid: 'new:' + buildUUID('uid')
164
+ });
165
+ }
166
+ return state;
167
+ } else {
168
+ var _this = this;
169
+ var state1;
170
+ //TODO 目前只找了一层明细表,没有递归
171
+ Object.keys(this.controlIdMapping).map(function(subtableId) {
172
+ var dataViewId = _this.controlIdMapping[subtableId].dataView;
173
+ var children = _this.controlIdMapping[subtableId].children;
174
+ if (children !== undefined) {
175
+ var _this4 = _this;
176
+ Object.keys(children).map(function(childControlId) {
177
+ if (childControlId === controlId) {
178
+ state1 = _this4.emptyState[dataViewId][subtableId][controlId];
179
+ }
180
+ });
152
181
  }
153
182
  });
183
+ return state1;
154
184
  }
155
- });
156
- return state1;
185
+ }
157
186
  }
158
- }
159
- };
160
- _proto.getDataBind = function getDataBind(controlId) {
161
- var result = this.controlIdMapping[controlId];
162
- if (result) {
163
- return result.dataBind;
164
- }
165
- wrapperFor: for(var id in this.controlIdMapping){
166
- var dataBindMapping = this.controlIdMapping[id];
167
- if (dataBindMapping.children) {
168
- for(var subId in dataBindMapping.children){
169
- if (subId === controlId) {
170
- result = dataBindMapping.children[subId];
171
- break wrapperFor;
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
+ }
172
204
  }
173
205
  }
206
+ return result === null || result === void 0 ? void 0 : result.dataBind;
174
207
  }
175
208
  }
176
- return result === null || result === void 0 ? void 0 : result.dataBind;
177
- };
209
+ ]);
178
210
  return Store;
179
211
  }();
180
212
  function init(instance) {
@@ -219,34 +251,34 @@ item) {
219
251
  loopFormSchema(item.props.headers, function(headerItem) {
220
252
  emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
221
253
  });
222
- var _item_props_defaultRows;
223
- 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() {
254
+ var _defaultRows;
255
+ dataViewState[item.id] = new Array((_defaultRows = item.props.defaultRows) !== null && _defaultRows !== void 0 ? _defaultRows : 1).fill(0).map(function() {
224
256
  return JSONCopy(emptyTemplate);
225
257
  });
226
258
  emptyDataViewState[item.id] = emptyTemplate;
227
259
  }
228
260
  }
229
261
  function buildDataBindMapping(data, dataViewId, // @ts-ignore
230
- item) {
262
+ item1) {
231
263
  // if (item instanceof RuntimeFormControl) {
232
- if (item.controlType === CONTROL_BASE_TYPE.FORM) {
233
- var _item_props, _item_props_dataBind;
234
- if (_instanceof(item.props.dataBind, ObjectDataBind)) {
264
+ if (item1.controlType === CONTROL_BASE_TYPE.FORM) {
265
+ var ref, ref1;
266
+ if (_instanceof(item1.props.dataBind, ObjectDataBind)) {
235
267
  // 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
236
- Object.keys(item.props.dataBind).map(function(key) {
237
- var dataBind = item.props.dataBind;
268
+ Object.keys(item1.props.dataBind).map(function(key) {
269
+ var dataBind = item1.props.dataBind;
238
270
  var dataCode = dataBind[key].dataCode;
239
271
  if (dataCode !== undefined) {
240
272
  if (data[dataCode] === undefined) {
241
273
  data[dataCode] = {
242
- controlId: item.id,
274
+ controlId: item1.id,
243
275
  fields: [],
244
276
  dataViewId: dataViewId
245
277
  };
246
278
  }
247
279
  data[dataCode].fields.push({
248
280
  fieldCode: dataBind[key].fieldCode,
249
- controlId: item.id,
281
+ controlId: item1.id,
250
282
  dataBind: dataBind,
251
283
  dataViewId: [
252
284
  dataViewId
@@ -254,38 +286,38 @@ item) {
254
286
  });
255
287
  }
256
288
  });
257
- } else if (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : (_item_props_dataBind = _item_props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.dataCode) === undefined) {
289
+ } else if (((ref = item1.props) === null || ref === void 0 ? void 0 : (ref1 = ref.dataBind) === null || ref1 === void 0 ? void 0 : ref1.dataCode) === undefined) {
258
290
  //qiyu 2023-2-27 为空跳过。form自定义组件加载失败时,hack的组件props为空。
259
291
  } else {
260
- if (data[item.props.dataBind.dataCode] === undefined) {
261
- data[item.props.dataBind.dataCode] = {
292
+ if (data[item1.props.dataBind.dataCode] === undefined) {
293
+ data[item1.props.dataBind.dataCode] = {
262
294
  controlId: dataViewId,
263
295
  fields: [],
264
296
  dataViewId: dataViewId
265
297
  };
266
298
  }
267
- data[item.props.dataBind.dataCode].fields.push({
268
- fieldCode: item.props.dataBind.fieldCode,
269
- controlId: item.id,
270
- dataBind: item.props.dataBind,
299
+ data[item1.props.dataBind.dataCode].fields.push({
300
+ fieldCode: item1.props.dataBind.fieldCode,
301
+ controlId: item1.id,
302
+ dataBind: item1.props.dataBind,
271
303
  dataViewId: [
272
304
  dataViewId
273
305
  ]
274
306
  });
275
307
  }
276
308
  } else {
277
- if (item.props.datasourceBind.dataCode === "") {
309
+ if (item1.props.datasourceBind.dataCode === '') {
278
310
  //敏捷依赖后端生成dataCode,预览的时候没有
279
- warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item.id, " type:").concat(item.type));
311
+ warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item1.id, " type:").concat(item1.type));
280
312
  return;
281
313
  }
282
- data[item.props.datasourceBind.dataCode] = {
283
- controlId: item.id,
314
+ data[item1.props.datasourceBind.dataCode] = {
315
+ controlId: item1.id,
284
316
  fields: [],
285
317
  dataViewId: dataViewId
286
318
  };
287
- var subtableId = item.id;
288
- loopFormSchema(item.props.headers, function(item) {
319
+ var subtableId = item1.id;
320
+ loopFormSchema(item1.props.headers, function(item) {
289
321
  if (_instanceof(item.props.dataBind, ObjectDataBind)) {
290
322
  Object.keys(item.props.dataBind).map(function(key) {
291
323
  var dataBind = item.props.dataBind;
@@ -327,16 +359,16 @@ item) {
327
359
  data[item.id] = {
328
360
  dataBind: new DataBind({
329
361
  dataCode: item.props.datasourceBind.dataCode,
330
- fieldCode: ""
362
+ fieldCode: ''
331
363
  }),
332
364
  dataView: dataViewId,
333
365
  children: {},
334
366
  options: []
335
367
  };
336
368
  loopFormSchema(item.props.headers, function(formControl) {
337
- var _data_item_id;
338
- var _data_item_id_children;
339
- 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 : {}, _defineProperty({}, formControl.id, {
369
+ var ref;
370
+ var ref2;
371
+ Object.assign((ref2 = (ref = data[item.id]) === null || ref === void 0 ? void 0 : ref.children) !== null && ref2 !== void 0 ? ref2 : {}, _defineProperty({}, formControl.id, {
340
372
  dataBind: formControl.props.dataBind
341
373
  }));
342
374
  });