@byteluck-fe/model-driven-engine 2.6.0-alpha.15 → 2.6.0-alpha.17b

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.
@@ -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";
@@ -154,8 +154,14 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
154
154
  var antdRules = {};
155
155
  var ruleItems = {};
156
156
  loopDataViewControl(this._instance, function(dataView) {
157
- ruleItems[dataView.id] = dataView.rules[0];
158
- antdRules[dataView.id] = dataView.rules[0];
157
+ var result = {};
158
+ var Rules = Runtime.staticControlsRuntimeRules.get(dataView.type);
159
+ if (Rules) {
160
+ var rules = new Rules(dataView.props);
161
+ result = Array.from(rules)[0];
162
+ }
163
+ ruleItems[dataView.id] = JSONCopy(result);
164
+ antdRules[dataView.id] = JSONCopy(result);
159
165
  loopFormControl(dataView.children, function(item) {
160
166
  // if (
161
167
  // item instanceof RuntimeFormControl ||
@@ -178,7 +184,14 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
178
184
  get: function get() {
179
185
  var ruleItems = {};
180
186
  loopDataViewControl(this._instance, function(dataView) {
181
- ruleItems[dataView.id] = dataView.rules[0];
187
+ var result = {};
188
+ var Rules = Runtime.staticControlsRuntimeRules.get(dataView.type);
189
+ if (Rules) {
190
+ var rules = new Rules(dataView.props);
191
+ result = Array.from(rules)[0];
192
+ }
193
+ // ruleItems[dataView.id] = dataView.rules[0]
194
+ ruleItems[dataView.id] = result;
182
195
  loopFormControl(dataView.children, function(item) {
183
196
  // if (
184
197
  // item instanceof RuntimeFormControl ||
@@ -197,7 +210,14 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
197
210
  get: function get() {
198
211
  var antdRules = {};
199
212
  loopDataViewControl(this._instance, function(dataView) {
200
- antdRules[dataView.id] = dataView.rules[0];
213
+ var result = {};
214
+ var Rules = Runtime.staticControlsRuntimeRules.get(dataView.type);
215
+ if (Rules) {
216
+ var rules = new Rules(dataView.props);
217
+ result = Array.from(rules)[0];
218
+ }
219
+ // antdRules[dataView.id] = dataView.rules[0]
220
+ antdRules[dataView.id] = result;
201
221
  loopFormControl(dataView.children, function(item) {
202
222
  // if (
203
223
  // item instanceof RuntimeFormControl ||
@@ -237,7 +257,7 @@ function loop(control, callback) {
237
257
  if (control.props.isHide) {
238
258
  return true;
239
259
  }
240
- if (control.parent === null) {
260
+ if (control.parent === null || control.parent === undefined) {
241
261
  return false;
242
262
  }
243
263
  return getControlIsHide(control.parent);
@@ -247,11 +267,19 @@ item) {
247
267
  if (getControlIsHide(item)) {
248
268
  return;
249
269
  }
270
+ var result = [];
271
+ var Rules = Runtime.staticControlsRuntimeRules.get(item.type);
272
+ if (Rules) {
273
+ var rules = new Rules(item.props);
274
+ result = Array.from(rules);
275
+ }
250
276
  // if (item instanceof RuntimeFormControl) {
251
277
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
252
- data[item.id] = item.rules;
278
+ // data[item.id] = item.rules
279
+ data[item.id] = result;
253
280
  } else if (item.type === CONTROL_TYPE.SUBTABLE) {
254
- data[item.id] = item.rules;
281
+ // data[item.id] = item.rules
282
+ data[item.id] = result;
255
283
  var itemRules = {
256
284
  type: 'array',
257
285
  fields: {}
@@ -266,8 +294,18 @@ item) {
266
294
  fields: {}
267
295
  };
268
296
  }
297
+ // // @ts-ignore
298
+ // itemRules.fields[index].fields[formControl.id] = (
299
+ // formControl as RuntimeFormControl
300
+ // ).rules
301
+ var childResult = [];
302
+ var childRules = Runtime.staticControlsRuntimeRules.get(formControl.type);
303
+ if (childRules) {
304
+ var childrules = new childRules(formControl.props);
305
+ childResult = Array.from(childrules);
306
+ }
269
307
  // @ts-ignore
270
- itemRules.fields[index].fields[formControl.id] = formControl.rules;
308
+ itemRules.fields[index].fields[formControl.id] = childResult;
271
309
  }
272
310
  });
273
311
  });
@@ -279,15 +317,29 @@ item) {
279
317
  if (getControlIsHide(item)) {
280
318
  return;
281
319
  }
320
+ var result = [];
321
+ var Rules = Runtime.staticControlsRuntimeRules.get(item.type);
322
+ if (Rules) {
323
+ var rules = new Rules(item.props);
324
+ result = Array.from(rules);
325
+ }
282
326
  // if (item instanceof RuntimeFormControl) {
283
327
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
284
- antdRules[item.id] = item.rules;
328
+ // antdRules[item.id] = item.rules
329
+ antdRules[item.id] = result;
285
330
  } else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
286
331
  antdRules[item.id] = [];
287
332
  item.children.forEach(function(row) {
288
333
  var rules = {};
289
334
  loopFormSchema(row.children, function(formControl) {
290
- rules[formControl.id] = formControl.rules;
335
+ // rules[formControl.id] = (formControl as RuntimeFormControl).rules
336
+ var childResult = [];
337
+ var childRules = Runtime.staticControlsRuntimeRules.get(formControl.type);
338
+ if (childRules) {
339
+ var childrules = new childRules(formControl.props);
340
+ childResult = Array.from(childrules);
341
+ }
342
+ rules[formControl.id] = childResult;
291
343
  });
292
344
  antdRules[item.id].push(rules);
293
345
  });