@byteluck-fe/model-driven-engine 2.6.0-alpha.16 → 2.6.0-alpha.17c

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.
@@ -1466,12 +1466,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1466
1466
  {
1467
1467
  key: "register",
1468
1468
  value: // 注册外部控件
1469
- function register() {
1470
- for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
1471
- arg[_key] = arguments[_key];
1472
- }
1473
- var _Runtime;
1474
- return (_Runtime = Runtime).register.apply(_Runtime, _toConsumableArray(arg));
1469
+ function register(control) {
1470
+ return Runtime.register(control, 'Runtime');
1475
1471
  }
1476
1472
  },
1477
1473
  {
@@ -84,7 +84,7 @@ function _createSuper(Derived) {
84
84
  };
85
85
  }
86
86
  import { RegisterControls } from '@byteluck-fe/model-driven-core';
87
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from '@byteluck-fe/model-driven-shared';
87
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema } from '@byteluck-fe/model-driven-shared';
88
88
  import { hasChildrenControl, loopDataViewControl, loopFormControl } from '../utils/runtimeUtils';
89
89
  export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
90
90
  "use strict";
@@ -96,6 +96,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
96
96
  _this = _super.call(this, 'Runtime');
97
97
  _this._flatInstances = [];
98
98
  _this._instanceMap = {};
99
+ _this._controlParentIdMap = {};
99
100
  var schema = props.schema;
100
101
  _this._schema = schema;
101
102
  _this._instance = _this.createControl(schema, props.beforeCreateInstance);
@@ -108,19 +109,26 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
108
109
  value: function getFlatInstances() {
109
110
  var instances = [];
110
111
  var instanceMap = {};
111
- loop(this._instance, function(item) {
112
+ var controlParentIdMap = {};
113
+ loop(this._instance, '', function(item, parentId) {
112
114
  // 3.4.1 避免将subtable-row 放到 _flatInstances 中
113
- if (item.type === 'subtable-row' || item.type === 'subtable-column') {
114
- return;
115
- }
115
+ //4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
116
+ // if (item.type === 'subtable-row' || item.type === 'subtable-column') {
117
+ // return
118
+ // }
116
119
  instances.push(item);
117
120
  if (!instanceMap[item.id]) {
118
121
  instanceMap[item.id] = [];
119
122
  }
120
123
  instanceMap[item.id].push(item);
124
+ if (parentId) {
125
+ // @ts-ignore
126
+ controlParentIdMap[item.id] = parentId;
127
+ }
121
128
  });
122
129
  this._flatInstances = instances;
123
130
  this._instanceMap = instanceMap;
131
+ this._controlParentIdMap = controlParentIdMap;
124
132
  return this._flatInstances;
125
133
  }
126
134
  },
@@ -154,8 +162,14 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
154
162
  var antdRules = {};
155
163
  var ruleItems = {};
156
164
  loopDataViewControl(this._instance, function(dataView) {
157
- ruleItems[dataView.id] = dataView.rules[0];
158
- antdRules[dataView.id] = dataView.rules[0];
165
+ var result = {};
166
+ var Rules = Runtime.staticControlsRuntimeRules.get(dataView.type);
167
+ if (Rules) {
168
+ var rules = new Rules(dataView.props);
169
+ result = Array.from(rules)[0];
170
+ }
171
+ ruleItems[dataView.id] = JSONCopy(result);
172
+ antdRules[dataView.id] = JSONCopy(result);
159
173
  loopFormControl(dataView.children, function(item) {
160
174
  // if (
161
175
  // item instanceof RuntimeFormControl ||
@@ -178,7 +192,14 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
178
192
  get: function get() {
179
193
  var ruleItems = {};
180
194
  loopDataViewControl(this._instance, function(dataView) {
181
- ruleItems[dataView.id] = dataView.rules[0];
195
+ var result = {};
196
+ var Rules = Runtime.staticControlsRuntimeRules.get(dataView.type);
197
+ if (Rules) {
198
+ var rules = new Rules(dataView.props);
199
+ result = Array.from(rules)[0];
200
+ }
201
+ // ruleItems[dataView.id] = dataView.rules[0]
202
+ ruleItems[dataView.id] = result;
182
203
  loopFormControl(dataView.children, function(item) {
183
204
  // if (
184
205
  // item instanceof RuntimeFormControl ||
@@ -197,7 +218,14 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
197
218
  get: function get() {
198
219
  var antdRules = {};
199
220
  loopDataViewControl(this._instance, function(dataView) {
200
- antdRules[dataView.id] = dataView.rules[0];
221
+ var result = {};
222
+ var Rules = Runtime.staticControlsRuntimeRules.get(dataView.type);
223
+ if (Rules) {
224
+ var rules = new Rules(dataView.props);
225
+ result = Array.from(rules)[0];
226
+ }
227
+ // antdRules[dataView.id] = dataView.rules[0]
228
+ antdRules[dataView.id] = result;
201
229
  loopFormControl(dataView.children, function(item) {
202
230
  // if (
203
231
  // item instanceof RuntimeFormControl ||
@@ -214,21 +242,21 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
214
242
  ]);
215
243
  return Runtime;
216
244
  }(RegisterControls);
217
- function loop(control, callback) {
245
+ function loop(control, parentId, callback) {
218
246
  if (Array.isArray(control)) {
219
247
  control.map(function(item) {
220
- callback(item);
248
+ callback(item, parentId);
221
249
  if (hasChildrenControl(item)) {
222
250
  var ctl = item;
223
251
  if (!ctl.children) {
224
252
  ctl.children = [];
225
253
  }
226
254
  // @ts-ignore
227
- loop(ctl.children, callback);
255
+ loop(ctl.children, ctl.id, callback);
228
256
  }
229
257
  });
230
258
  } else {
231
- callback(control);
259
+ callback(control, parentId);
232
260
  }
233
261
  }
234
262
  /**
@@ -237,7 +265,7 @@ function loop(control, callback) {
237
265
  if (control.props.isHide) {
238
266
  return true;
239
267
  }
240
- if (control.parent === null) {
268
+ if (control.parent === null || control.parent === undefined) {
241
269
  return false;
242
270
  }
243
271
  return getControlIsHide(control.parent);
@@ -247,11 +275,19 @@ item) {
247
275
  if (getControlIsHide(item)) {
248
276
  return;
249
277
  }
278
+ var result = [];
279
+ var Rules = Runtime.staticControlsRuntimeRules.get(item.type);
280
+ if (Rules) {
281
+ var rules = new Rules(item.props);
282
+ result = Array.from(rules);
283
+ }
250
284
  // if (item instanceof RuntimeFormControl) {
251
285
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
252
- data[item.id] = item.rules;
286
+ // data[item.id] = item.rules
287
+ data[item.id] = result;
253
288
  } else if (item.type === CONTROL_TYPE.SUBTABLE) {
254
- data[item.id] = item.rules;
289
+ // data[item.id] = item.rules
290
+ data[item.id] = result;
255
291
  var itemRules = {
256
292
  type: 'array',
257
293
  fields: {}
@@ -266,8 +302,18 @@ item) {
266
302
  fields: {}
267
303
  };
268
304
  }
305
+ // // @ts-ignore
306
+ // itemRules.fields[index].fields[formControl.id] = (
307
+ // formControl as RuntimeFormControl
308
+ // ).rules
309
+ var childResult = [];
310
+ var childRules = Runtime.staticControlsRuntimeRules.get(formControl.type);
311
+ if (childRules) {
312
+ var childrules = new childRules(formControl.props);
313
+ childResult = Array.from(childrules);
314
+ }
269
315
  // @ts-ignore
270
- itemRules.fields[index].fields[formControl.id] = formControl.rules;
316
+ itemRules.fields[index].fields[formControl.id] = childResult;
271
317
  }
272
318
  });
273
319
  });
@@ -279,15 +325,29 @@ item) {
279
325
  if (getControlIsHide(item)) {
280
326
  return;
281
327
  }
328
+ var result = [];
329
+ var Rules = Runtime.staticControlsRuntimeRules.get(item.type);
330
+ if (Rules) {
331
+ var rules = new Rules(item.props);
332
+ result = Array.from(rules);
333
+ }
282
334
  // if (item instanceof RuntimeFormControl) {
283
335
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
284
- antdRules[item.id] = item.rules;
336
+ // antdRules[item.id] = item.rules
337
+ antdRules[item.id] = result;
285
338
  } else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
286
339
  antdRules[item.id] = [];
287
340
  item.children.forEach(function(row) {
288
341
  var rules = {};
289
342
  loopFormSchema(row.children, function(formControl) {
290
- rules[formControl.id] = formControl.rules;
343
+ // rules[formControl.id] = (formControl as RuntimeFormControl).rules
344
+ var childResult = [];
345
+ var childRules = Runtime.staticControlsRuntimeRules.get(formControl.type);
346
+ if (childRules) {
347
+ var childrules = new childRules(formControl.props);
348
+ childResult = Array.from(childrules);
349
+ }
350
+ rules[formControl.id] = childResult;
291
351
  });
292
352
  antdRules[item.id].push(rules);
293
353
  });