@byteluck-fe/model-driven-engine 2.6.0-alpha.17d → 2.6.0-alpha.17e

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.
@@ -680,6 +680,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
680
680
  return this.setInstance(instance, props, value, rowIndex);
681
681
  }
682
682
  },
683
+ {
684
+ key: "getRule",
685
+ value: function getRule(controlType, props) {
686
+ return Runtime.staticGetRules(controlType, props);
687
+ }
688
+ },
683
689
  {
684
690
  key: "getAllRules",
685
691
  value: function getAllRules(controlId) {
@@ -162,14 +162,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
162
162
  var antdRules = {};
163
163
  var ruleItems = {};
164
164
  loopDataViewControl(this._instance, function(dataView) {
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);
165
+ var result = Runtime.staticGetRules(dataView.type, dataView.props);
166
+ ruleItems[dataView.id] = JSONCopy(result[0]);
167
+ antdRules[dataView.id] = JSONCopy(result[0]);
173
168
  loopFormControl(dataView.children, function(item) {
174
169
  // if (
175
170
  // item instanceof RuntimeFormControl ||
@@ -192,14 +187,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
192
187
  get: function get() {
193
188
  var ruleItems = {};
194
189
  loopDataViewControl(this._instance, function(dataView) {
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
- }
190
+ var result = Runtime.staticGetRules(dataView.type, dataView.props);
201
191
  // ruleItems[dataView.id] = dataView.rules[0]
202
- ruleItems[dataView.id] = result;
192
+ ruleItems[dataView.id] = result[0];
203
193
  loopFormControl(dataView.children, function(item) {
204
194
  // if (
205
195
  // item instanceof RuntimeFormControl ||
@@ -218,14 +208,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
218
208
  get: function get() {
219
209
  var antdRules = {};
220
210
  loopDataViewControl(this._instance, function(dataView) {
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
- }
211
+ var result = Runtime.staticGetRules(dataView.type, dataView.props);
227
212
  // antdRules[dataView.id] = dataView.rules[0]
228
- antdRules[dataView.id] = result;
213
+ antdRules[dataView.id] = result[0];
229
214
  loopFormControl(dataView.children, function(item) {
230
215
  // if (
231
216
  // item instanceof RuntimeFormControl ||
@@ -283,12 +268,7 @@ item) {
283
268
  if (getControlIsHide(item)) {
284
269
  return;
285
270
  }
286
- var result = [];
287
- var Rules = Runtime.staticControlsRuntimeRules.get(item.type);
288
- if (Rules) {
289
- var rules = new Rules(item.props);
290
- result = Array.from(rules);
291
- }
271
+ var result = Runtime.staticGetRules(item.type, item.props);
292
272
  // if (item instanceof RuntimeFormControl) {
293
273
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
294
274
  // data[item.id] = item.rules
@@ -314,12 +294,7 @@ item) {
314
294
  // itemRules.fields[index].fields[formControl.id] = (
315
295
  // formControl as RuntimeFormControl
316
296
  // ).rules
317
- var childResult = [];
318
- var childRules = Runtime.staticControlsRuntimeRules.get(formControl.type);
319
- if (childRules) {
320
- var childrules = new childRules(formControl.props);
321
- childResult = Array.from(childrules);
322
- }
297
+ var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
323
298
  // @ts-ignore
324
299
  itemRules.fields[index].fields[formControl.id] = childResult;
325
300
  }
@@ -333,12 +308,7 @@ item) {
333
308
  if (getControlIsHide(item)) {
334
309
  return;
335
310
  }
336
- var result = [];
337
- var Rules = Runtime.staticControlsRuntimeRules.get(item.type);
338
- if (Rules) {
339
- var rules = new Rules(item.props);
340
- result = Array.from(rules);
341
- }
311
+ var result = Runtime.staticGetRules(item.type, item.props);
342
312
  // if (item instanceof RuntimeFormControl) {
343
313
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
344
314
  // antdRules[item.id] = item.rules
@@ -349,12 +319,7 @@ item) {
349
319
  var rules = {};
350
320
  loopFormSchema(row.children, function(formControl) {
351
321
  // rules[formControl.id] = (formControl as RuntimeFormControl).rules
352
- var childResult = [];
353
- var childRules = Runtime.staticControlsRuntimeRules.get(formControl.type);
354
- if (childRules) {
355
- var childrules = new childRules(formControl.props);
356
- childResult = Array.from(childrules);
357
- }
322
+ var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
358
323
  rules[formControl.id] = childResult;
359
324
  });
360
325
  antdRules[item.id].push(rules);