@byteluck-fe/model-driven-engine 2.7.0-alpha.31b → 2.7.0-alpha.35

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 (41) hide show
  1. package/README.md +30 -30
  2. package/dist/esm/common/ActionManager.js +177 -60
  3. package/dist/esm/common/DataManager.js +134 -25
  4. package/dist/esm/common/Engine.js +480 -406
  5. package/dist/esm/common/OkWorker.js +31 -17
  6. package/dist/esm/common/Plugin.js +2 -2
  7. package/dist/esm/common/Runtime.js +80 -104
  8. package/dist/esm/common/Store.js +63 -62
  9. package/dist/esm/common/checkerValue.js +108 -108
  10. package/dist/esm/common/index.js +2 -2
  11. package/dist/esm/common/proxyState.js +76 -76
  12. package/dist/esm/index.js +3 -3
  13. package/dist/esm/plugins/CalcPlugin.js +128 -120
  14. package/dist/esm/plugins/ControlsEventPlugin.js +196 -73
  15. package/dist/esm/plugins/ES6ModulePlugin.js +54 -66
  16. package/dist/esm/plugins/LifecycleEventPlugin.js +198 -79
  17. package/dist/esm/plugins/StylePlugin.js +26 -11
  18. package/dist/esm/plugins/index.js +5 -5
  19. package/dist/esm/utils/index.js +1 -1
  20. package/dist/esm/utils/runtimeUtils.js +5 -7
  21. package/dist/index.umd.js +8 -8
  22. package/dist/types/common/ActionManager.d.ts +14 -14
  23. package/dist/types/common/DataManager.d.ts +10 -10
  24. package/dist/types/common/Engine.d.ts +184 -181
  25. package/dist/types/common/OkWorker.d.ts +13 -13
  26. package/dist/types/common/Plugin.d.ts +6 -6
  27. package/dist/types/common/Runtime.d.ts +25 -26
  28. package/dist/types/common/Store.d.ts +50 -50
  29. package/dist/types/common/checkerValue.d.ts +3 -3
  30. package/dist/types/common/index.d.ts +2 -2
  31. package/dist/types/common/proxyState.d.ts +30 -30
  32. package/dist/types/index.d.ts +3 -3
  33. package/dist/types/plugins/CalcPlugin.d.ts +121 -121
  34. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
  35. package/dist/types/plugins/ES6ModulePlugin.d.ts +26 -27
  36. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -14
  37. package/dist/types/plugins/StylePlugin.d.ts +12 -12
  38. package/dist/types/plugins/index.d.ts +5 -5
  39. package/dist/types/utils/index.d.ts +1 -1
  40. package/dist/types/utils/runtimeUtils.d.ts +5 -5
  41. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- function _classCallCheck(instance, Constructor) {
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 _createClass(Constructor, protoProps, staticProps) {
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 _defineProperty(obj, key, value) {
20
+ function _define_property(obj, key, value) {
21
21
  if (key in obj) {
22
22
  Object.defineProperty(obj, key, {
23
23
  value: value,
@@ -30,7 +30,7 @@ function _defineProperty(obj, key, value) {
30
30
  }
31
31
  return obj;
32
32
  }
33
- function _objectSpread(target) {
33
+ function _object_spread(target) {
34
34
  for(var i = 1; i < arguments.length; i++){
35
35
  var source = arguments[i] != null ? arguments[i] : {};
36
36
  var ownKeys = Object.keys(source);
@@ -40,33 +40,40 @@ function _objectSpread(target) {
40
40
  }));
41
41
  }
42
42
  ownKeys.forEach(function(key) {
43
- _defineProperty(target, key, source[key]);
43
+ _define_property(target, key, source[key]);
44
44
  });
45
45
  }
46
46
  return target;
47
47
  }
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';
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) {
54
- _classCallCheck(this, Store);
55
- var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping, defaultState = ref.defaultState;
54
+ _class_call_check(this, Store);
55
+ _define_property(this, "emptyState", void 0);
56
+ _define_property(this, "state", void 0);
57
+ _define_property(this, "dataBindMapping", void 0 // 主要提供给二开使用
58
+ );
59
+ _define_property(this, "controlIdMapping", void 0);
60
+ _define_property(this, "defaultState", void 0);
61
+ var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState;
56
62
  this.emptyState = emptyState;
57
63
  this.state = state;
58
64
  this.dataBindMapping = databindMapping;
59
65
  this.controlIdMapping = controlidMapping;
60
66
  this.defaultState = defaultState;
61
67
  }
62
- _createClass(Store, [
68
+ _create_class(Store, [
63
69
  {
64
- /**
65
- * 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
66
- * @param controlId 组件ID
67
- * @param value
70
+ /**
71
+ * 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
72
+ * @param controlId 组件ID
73
+ * @param value
68
74
  */ key: "setState",
69
75
  value: function setState(controlId, value, rowIndex) {
76
+ var _this = this;
70
77
  var controlInfo = this.controlIdMapping[controlId];
71
78
  if (controlInfo !== undefined) {
72
79
  //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
@@ -81,17 +88,15 @@ var Store = /*#__PURE__*/ function() {
81
88
  // }
82
89
  } else {
83
90
  if (rowIndex !== undefined) {
84
- var _this = this;
85
91
  //TODO 目前只找了一层明细表,没有递归 如果是添加uid
86
92
  Object.keys(this.controlIdMapping).map(function(subtableId) {
87
93
  var dataView = _this.controlIdMapping[subtableId].dataView;
88
94
  var children = _this.controlIdMapping[subtableId].children;
89
95
  if (children !== undefined) {
90
- var _this1 = _this;
91
96
  Object.keys(children).map(function(childControlId) {
92
97
  if (childControlId === controlId) {
93
- if (_this1.state[dataView][subtableId][rowIndex]) {
94
- _this1.state[dataView][subtableId][rowIndex][controlId] = value;
98
+ if (_this.state[dataView][subtableId][rowIndex]) {
99
+ _this.state[dataView][subtableId][rowIndex][controlId] = value;
95
100
  }
96
101
  }
97
102
  });
@@ -107,6 +112,7 @@ var Store = /*#__PURE__*/ function() {
107
112
  {
108
113
  key: "getState",
109
114
  value: function getState(controlId, rowIndex) {
115
+ var _this = this;
110
116
  //qiyu 由于header的数据是后补充的,所以从state获取第一层值。
111
117
  // const controlInfo = this.controlIdMapping[controlId]
112
118
  var detection = this.state[controlId];
@@ -118,31 +124,27 @@ var Store = /*#__PURE__*/ function() {
118
124
  return this.state[controlInfo.dataView][controlId];
119
125
  } else {
120
126
  if (rowIndex !== undefined) {
121
- var _this = this;
122
127
  var state;
123
128
  //TODO 目前只找了一层明细表,没有递归
124
129
  Object.keys(this.controlIdMapping).map(function(subtableId) {
125
130
  var dataViewId = _this.controlIdMapping[subtableId].dataView;
126
131
  var children = _this.controlIdMapping[subtableId].children;
127
132
  if (children !== undefined) {
128
- var _this3 = _this;
129
133
  Object.keys(children).map(function(childControlId) {
130
134
  if (childControlId === controlId) {
131
- var ref;
132
- state = (ref = _this3.state[dataViewId][subtableId][rowIndex]) === null || ref === void 0 ? void 0 : ref[controlId];
135
+ var _this_state_dataViewId_subtableId_rowIndex;
136
+ 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];
133
137
  }
134
138
  });
135
139
  }
136
140
  });
137
141
  return state;
138
142
  } else {
139
- var _this2 = this;
140
143
  var states = [];
141
144
  Object.keys(this.controlIdMapping).map(function(subtableId) {
142
- var dataViewId = _this2.controlIdMapping[subtableId].dataView;
143
- var children = _this2.controlIdMapping[subtableId].children;
145
+ var dataViewId = _this.controlIdMapping[subtableId].dataView;
146
+ var children = _this.controlIdMapping[subtableId].children;
144
147
  if (children !== undefined) {
145
- var _this = _this2;
146
148
  Object.keys(children).map(function(childControlId) {
147
149
  if (childControlId === controlId) {
148
150
  _this.state[dataViewId][subtableId].map(function(item) {
@@ -161,6 +163,7 @@ var Store = /*#__PURE__*/ function() {
161
163
  {
162
164
  key: "getEmptyState",
163
165
  value: function getEmptyState(controlId) {
166
+ var _this = this;
164
167
  var detection = this.emptyState[controlId];
165
168
  if (detection !== undefined) {
166
169
  return this.emptyState[controlId];
@@ -169,24 +172,22 @@ var Store = /*#__PURE__*/ function() {
169
172
  if (controlInfo !== undefined) {
170
173
  var state = this.emptyState[controlInfo.dataView][controlId];
171
174
  //判断找到的是否是明细表的控件
172
- if ('children' in controlInfo) {
175
+ if ("children" in controlInfo) {
173
176
  Object.assign(state, {
174
- uid: 'new:' + buildUUID('uid')
177
+ uid: "new:" + buildUUID("uid")
175
178
  });
176
179
  }
177
180
  return state;
178
181
  } else {
179
- var _this = this;
180
182
  var state1;
181
183
  //TODO 目前只找了一层明细表,没有递归
182
184
  Object.keys(this.controlIdMapping).map(function(subtableId) {
183
185
  var dataViewId = _this.controlIdMapping[subtableId].dataView;
184
186
  var children = _this.controlIdMapping[subtableId].children;
185
187
  if (children !== undefined) {
186
- var _this4 = _this;
187
188
  Object.keys(children).map(function(childControlId) {
188
189
  if (childControlId === controlId) {
189
- state1 = _this4.emptyState[dataViewId][subtableId][controlId];
190
+ state1 = _this.emptyState[dataViewId][subtableId][controlId];
190
191
  }
191
192
  });
192
193
  }
@@ -265,37 +266,37 @@ item) {
265
266
  loopFormSchema(item.props.headers, function(headerItem) {
266
267
  emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
267
268
  });
268
- var _defaultRows, ref;
269
- dataViewState[item.id] = (ref = new Array((_defaultRows = item.props.defaultRows) !== null && _defaultRows !== void 0 ? _defaultRows : 1).fill(0).map(function() {
270
- return _objectSpread({
271
- uid: 'new:' + buildUUID('uid')
269
+ var _item_props_defaultRows, _fill_map;
270
+ 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() {
271
+ return _object_spread({
272
+ uid: "new:" + buildUUID("uid")
272
273
  }, JSONCopy(emptyTemplate));
273
- })) !== null && ref !== void 0 ? ref : [];
274
+ })) !== null && _fill_map !== void 0 ? _fill_map : [];
274
275
  emptyDataViewState[item.id] = emptyTemplate;
275
276
  }
276
277
  }
277
278
  function buildDataBindMapping(data, dataViewId, // @ts-ignore
278
- item1) {
279
+ item) {
279
280
  // if (item instanceof RuntimeFormControl) {
280
- if (item1.controlType === CONTROL_BASE_TYPE.FORM) {
281
- var ref, ref1;
281
+ if (item.controlType === CONTROL_BASE_TYPE.FORM) {
282
+ var _item_props_dataBind, _item_props;
282
283
  // if (item.props.dataBind instanceof ObjectDataBind) {
283
- if (!isDataBind(item1.props.dataBind)) {
284
+ if (!isDataBind(item.props.dataBind)) {
284
285
  // 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
285
- Object.keys(item1.props.dataBind).map(function(key) {
286
- var dataBind = item1.props.dataBind;
286
+ Object.keys(item.props.dataBind).map(function(key) {
287
+ var dataBind = item.props.dataBind;
287
288
  var dataCode = dataBind[key].dataCode;
288
289
  if (dataCode !== undefined) {
289
290
  if (data[dataCode] === undefined) {
290
291
  data[dataCode] = {
291
- controlId: item1.id,
292
+ controlId: item.id,
292
293
  fields: [],
293
294
  dataViewId: dataViewId
294
295
  };
295
296
  }
296
297
  data[dataCode].fields.push({
297
298
  fieldCode: dataBind[key].fieldCode,
298
- controlId: item1.id,
299
+ controlId: item.id,
299
300
  dataBind: dataBind,
300
301
  dataViewId: [
301
302
  dataViewId
@@ -303,38 +304,38 @@ item1) {
303
304
  });
304
305
  }
305
306
  });
306
- } else if (((ref = item1.props) === null || ref === void 0 ? void 0 : (ref1 = ref.dataBind) === null || ref1 === void 0 ? void 0 : ref1.dataCode) === undefined) {
307
+ } 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) {
307
308
  //qiyu 2023-2-27 为空跳过。form自定义组件加载失败时,hack的组件props为空。
308
309
  } else {
309
- if (data[item1.props.dataBind.dataCode] === undefined) {
310
- data[item1.props.dataBind.dataCode] = {
310
+ if (data[item.props.dataBind.dataCode] === undefined) {
311
+ data[item.props.dataBind.dataCode] = {
311
312
  controlId: dataViewId,
312
313
  fields: [],
313
314
  dataViewId: dataViewId
314
315
  };
315
316
  }
316
- data[item1.props.dataBind.dataCode].fields.push({
317
- fieldCode: item1.props.dataBind.fieldCode,
318
- controlId: item1.id,
319
- dataBind: item1.props.dataBind,
317
+ data[item.props.dataBind.dataCode].fields.push({
318
+ fieldCode: item.props.dataBind.fieldCode,
319
+ controlId: item.id,
320
+ dataBind: item.props.dataBind,
320
321
  dataViewId: [
321
322
  dataViewId
322
323
  ]
323
324
  });
324
325
  }
325
326
  } else {
326
- if (item1.props.datasourceBind.dataCode === '') {
327
+ if (item.props.datasourceBind.dataCode === "") {
327
328
  //敏捷依赖后端生成dataCode,预览的时候没有
328
- warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item1.id, " type:").concat(item1.type));
329
+ warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item.id, " type:").concat(item.type));
329
330
  return;
330
331
  }
331
- data[item1.props.datasourceBind.dataCode] = {
332
- controlId: item1.id,
332
+ data[item.props.datasourceBind.dataCode] = {
333
+ controlId: item.id,
333
334
  fields: [],
334
335
  dataViewId: dataViewId
335
336
  };
336
- var subtableId = item1.id;
337
- loopFormSchema(item1.props.headers, function(item) {
337
+ var subtableId = item.id;
338
+ loopFormSchema(item.props.headers, function(item) {
338
339
  // if (item.props.dataBind instanceof ObjectDataBind) {
339
340
  if (!isDataBind(item.props.dataBind)) {
340
341
  Object.keys(item.props.dataBind).map(function(key) {
@@ -377,16 +378,16 @@ item) {
377
378
  data[item.id] = {
378
379
  dataBind: new DataBind({
379
380
  dataCode: item.props.datasourceBind.dataCode,
380
- fieldCode: ''
381
+ fieldCode: ""
381
382
  }),
382
383
  dataView: dataViewId,
383
384
  children: {},
384
385
  options: []
385
386
  };
386
387
  loopFormSchema(item.props.headers, function(formControl) {
387
- var ref;
388
- var ref2;
389
- Object.assign((ref2 = (ref = data[item.id]) === null || ref === void 0 ? void 0 : ref.children) !== null && ref2 !== void 0 ? ref2 : {}, _defineProperty({}, formControl.id, {
388
+ var _data_item_id;
389
+ var _data_item_id_children;
390
+ 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, {
390
391
  dataBind: formControl.props.dataBind
391
392
  }));
392
393
  });