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

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) {
@@ -1337,55 +1343,59 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1337
1343
  * 如果控件在表头内,则返回-1
1338
1344
  * 如果控件在表内,则返回行下标
1339
1345
  * 如果控件不在明细表内,则返回undefined
1340
- * */ // public getInstanceRowIndex(
1341
- // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1342
- // ) {
1343
- // if (!instance.parent) {
1344
- // return
1345
- // }
1346
- // let rowIndex: number | undefined
1347
- // // @ts-ignore
1348
- // if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
1349
- // // 表头内的控件
1350
- // // @ts-ignore
1351
- // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1352
- // rowIndex = -1
1353
- // } else {
1354
- // // @ts-ignore
1355
- // const index = instance.parent.children.findIndex(
1356
- // (item: any) => item === instance
1357
- // )
1358
- // if (index > -1) {
1359
- // rowIndex = index
1360
- // }
1361
- // }
1362
- // } else {
1363
- // rowIndex = this.getInstanceRowIndex(instance.parent)
1364
- // }
1365
- // return rowIndex
1366
- // }
1367
- function getInstanceRowIndex(instance) {
1346
+ * */ function getInstanceRowIndex(instance) {
1347
+ if (!instance.parent) {
1348
+ return;
1349
+ }
1368
1350
  var rowIndex;
1369
1351
  // @ts-ignore
1370
- if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1371
- rowIndex = -1;
1372
- } else {
1373
- var instanceList = this.runtime.instanceMap[instance.id];
1374
- if (Object.prototype.toString.call(instanceList) === '[object Array]') {
1375
- var index = instanceList.findIndex(function(item) {
1352
+ if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE) || this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1353
+ // 表头内的控件
1354
+ // @ts-ignore
1355
+ if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1356
+ rowIndex = -1;
1357
+ } else {
1358
+ // @ts-ignore
1359
+ // const index = instance.parent.children.findIndex(
1360
+ // (item: any) => item === instance
1361
+ // )
1362
+ var instances = this.runtime.instanceMap[instance.id] || [];
1363
+ var index = instances.findIndex(function(item) {
1376
1364
  return item === instance;
1377
1365
  });
1378
1366
  if (index > -1) {
1379
1367
  rowIndex = index;
1380
1368
  }
1381
1369
  }
1370
+ } else {
1371
+ rowIndex = this.getInstanceRowIndex(instance.parent);
1382
1372
  }
1383
1373
  return rowIndex;
1384
1374
  }
1385
1375
  },
1386
1376
  {
1387
1377
  key: "getInstanceParentControl",
1388
- value: function getInstanceParentControl(instance, controlType) {
1378
+ value: // public getInstanceRowIndex(
1379
+ // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1380
+ // ) {
1381
+ // let rowIndex: number | undefined
1382
+ // // @ts-ignore
1383
+ // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1384
+ // rowIndex = -1
1385
+ // }else{
1386
+ // const instanceList = this.runtime.instanceMap[instance.id]
1387
+ // if(Object.prototype.toString.call(instanceList) === '[object Array]'){
1388
+ // const index = instanceList.findIndex(
1389
+ // (item: any) => item === instance
1390
+ // )
1391
+ // if (index > -1) {
1392
+ // rowIndex = index
1393
+ // }
1394
+ // }
1395
+ // }
1396
+ // return rowIndex
1397
+ // }
1398
+ function getInstanceParentControl(instance, controlType) {
1389
1399
  if (!instance.parent) {
1390
1400
  return;
1391
1401
  }
@@ -1479,5 +1489,5 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1479
1489
  ]);
1480
1490
  return Engine;
1481
1491
  }(Watcher);
1492
+ // @ts-ignore
1482
1493
  export { Engine };
1483
- console.log('a');
@@ -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);