@byteluck-fe/model-driven-engine 2.6.0-alpha.18a → 2.6.0-alpha.19
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.
- package/dist/esm/common/Engine.js +10 -16
- package/dist/esm/common/Runtime.js +30 -63
- package/dist/index.umd.js +10 -10
- package/dist/types/common/Engine.d.ts +3 -4
- package/dist/types/common/Runtime.d.ts +0 -1
- package/package.json +3 -3
|
@@ -392,7 +392,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
392
392
|
var _this = this;
|
|
393
393
|
var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
394
394
|
// if (!(subtable instanceof RuntimeListControl)) return
|
|
395
|
-
if (!(subtable.controlType === CONTROL_BASE_TYPE.LIST)) return;
|
|
395
|
+
if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
|
|
396
396
|
// 新增多行方法
|
|
397
397
|
var createRows = function(len) {
|
|
398
398
|
// @ts-ignore
|
|
@@ -680,12 +680,6 @@ 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
|
-
},
|
|
689
683
|
{
|
|
690
684
|
key: "getAllRules",
|
|
691
685
|
value: function getAllRules(controlId) {
|
|
@@ -1349,18 +1343,14 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1349
1343
|
}
|
|
1350
1344
|
var rowIndex;
|
|
1351
1345
|
// @ts-ignore
|
|
1352
|
-
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)
|
|
1346
|
+
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1353
1347
|
// 表头内的控件
|
|
1354
1348
|
// @ts-ignore
|
|
1355
1349
|
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1356
1350
|
rowIndex = -1;
|
|
1357
1351
|
} else {
|
|
1358
1352
|
// @ts-ignore
|
|
1359
|
-
|
|
1360
|
-
// (item: any) => item === instance
|
|
1361
|
-
// )
|
|
1362
|
-
var instances = this.runtime.instanceMap[instance.id] || [];
|
|
1363
|
-
var index = instances.findIndex(function(item) {
|
|
1353
|
+
var index = instance.parent.children.findIndex(function(item) {
|
|
1364
1354
|
return item === instance;
|
|
1365
1355
|
});
|
|
1366
1356
|
if (index > -1) {
|
|
@@ -1476,8 +1466,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1476
1466
|
{
|
|
1477
1467
|
key: "register",
|
|
1478
1468
|
value: // 注册外部控件
|
|
1479
|
-
function register(
|
|
1480
|
-
|
|
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));
|
|
1481
1475
|
}
|
|
1482
1476
|
},
|
|
1483
1477
|
{
|
|
@@ -1489,5 +1483,5 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1489
1483
|
]);
|
|
1490
1484
|
return Engine;
|
|
1491
1485
|
}(Watcher);
|
|
1492
|
-
// @ts-ignore
|
|
1493
1486
|
export { Engine };
|
|
1487
|
+
console.log('a');
|
|
@@ -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,
|
|
87
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, 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,7 +96,6 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
96
96
|
_this = _super.call(this, 'Runtime');
|
|
97
97
|
_this._flatInstances = [];
|
|
98
98
|
_this._instanceMap = {};
|
|
99
|
-
_this._controlParentIdMap = {};
|
|
100
99
|
var schema = props.schema;
|
|
101
100
|
_this._schema = schema;
|
|
102
101
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
@@ -109,26 +108,19 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
109
108
|
value: function getFlatInstances() {
|
|
110
109
|
var instances = [];
|
|
111
110
|
var instanceMap = {};
|
|
112
|
-
|
|
113
|
-
loop(this._instance, '', function(item, parentId) {
|
|
111
|
+
loop(this._instance, function(item) {
|
|
114
112
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// }
|
|
113
|
+
if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
119
116
|
instances.push(item);
|
|
120
117
|
if (!instanceMap[item.id]) {
|
|
121
118
|
instanceMap[item.id] = [];
|
|
122
119
|
}
|
|
123
120
|
instanceMap[item.id].push(item);
|
|
124
|
-
if (parentId) {
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
controlParentIdMap[item.id] = parentId;
|
|
127
|
-
}
|
|
128
121
|
});
|
|
129
122
|
this._flatInstances = instances;
|
|
130
123
|
this._instanceMap = instanceMap;
|
|
131
|
-
this._controlParentIdMap = controlParentIdMap;
|
|
132
124
|
return this._flatInstances;
|
|
133
125
|
}
|
|
134
126
|
},
|
|
@@ -162,9 +154,8 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
162
154
|
var antdRules = {};
|
|
163
155
|
var ruleItems = {};
|
|
164
156
|
loopDataViewControl(this._instance, function(dataView) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
antdRules[dataView.id] = JSONCopy(result[0]);
|
|
157
|
+
ruleItems[dataView.id] = dataView.rules[0];
|
|
158
|
+
antdRules[dataView.id] = dataView.rules[0];
|
|
168
159
|
loopFormControl(dataView.children, function(item) {
|
|
169
160
|
// if (
|
|
170
161
|
// item instanceof RuntimeFormControl ||
|
|
@@ -187,9 +178,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
187
178
|
get: function get() {
|
|
188
179
|
var ruleItems = {};
|
|
189
180
|
loopDataViewControl(this._instance, function(dataView) {
|
|
190
|
-
|
|
191
|
-
// ruleItems[dataView.id] = dataView.rules[0]
|
|
192
|
-
ruleItems[dataView.id] = result[0];
|
|
181
|
+
ruleItems[dataView.id] = dataView.rules[0];
|
|
193
182
|
loopFormControl(dataView.children, function(item) {
|
|
194
183
|
// if (
|
|
195
184
|
// item instanceof RuntimeFormControl ||
|
|
@@ -208,9 +197,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
208
197
|
get: function get() {
|
|
209
198
|
var antdRules = {};
|
|
210
199
|
loopDataViewControl(this._instance, function(dataView) {
|
|
211
|
-
|
|
212
|
-
// antdRules[dataView.id] = dataView.rules[0]
|
|
213
|
-
antdRules[dataView.id] = result[0];
|
|
200
|
+
antdRules[dataView.id] = dataView.rules[0];
|
|
214
201
|
loopFormControl(dataView.children, function(item) {
|
|
215
202
|
// if (
|
|
216
203
|
// item instanceof RuntimeFormControl ||
|
|
@@ -227,30 +214,22 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
227
214
|
]);
|
|
228
215
|
return Runtime;
|
|
229
216
|
}(RegisterControls);
|
|
230
|
-
function loop(control,
|
|
231
|
-
|
|
232
|
-
control
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
217
|
+
function loop(control, callback) {
|
|
218
|
+
if (Array.isArray(control)) {
|
|
219
|
+
control.map(function(item) {
|
|
220
|
+
callback(item);
|
|
221
|
+
if (hasChildrenControl(item)) {
|
|
222
|
+
var ctl = item;
|
|
223
|
+
if (!ctl.children) {
|
|
224
|
+
ctl.children = [];
|
|
225
|
+
}
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
loop(ctl.children, callback);
|
|
240
228
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
loop(item.props.headers, item.id, callback);
|
|
246
|
-
}
|
|
247
|
-
if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
248
|
-
loop(item.props.footers, item.id, callback);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
function hasHeaderOrFooterControl(control, checkType) {
|
|
253
|
-
return checkType in control.props && isArray(control.props[checkType]);
|
|
229
|
+
});
|
|
230
|
+
} else {
|
|
231
|
+
callback(control);
|
|
232
|
+
}
|
|
254
233
|
}
|
|
255
234
|
/**
|
|
256
235
|
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
@@ -258,7 +237,7 @@ function hasHeaderOrFooterControl(control, checkType) {
|
|
|
258
237
|
if (control.props.isHide) {
|
|
259
238
|
return true;
|
|
260
239
|
}
|
|
261
|
-
if (control.parent === null
|
|
240
|
+
if (control.parent === null) {
|
|
262
241
|
return false;
|
|
263
242
|
}
|
|
264
243
|
return getControlIsHide(control.parent);
|
|
@@ -268,14 +247,11 @@ item) {
|
|
|
268
247
|
if (getControlIsHide(item)) {
|
|
269
248
|
return;
|
|
270
249
|
}
|
|
271
|
-
var result = Runtime.staticGetRules(item.type, item.props);
|
|
272
250
|
// if (item instanceof RuntimeFormControl) {
|
|
273
251
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
274
|
-
|
|
275
|
-
data[item.id] = result;
|
|
252
|
+
data[item.id] = item.rules;
|
|
276
253
|
} else if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
277
|
-
|
|
278
|
-
data[item.id] = result;
|
|
254
|
+
data[item.id] = item.rules;
|
|
279
255
|
var itemRules = {
|
|
280
256
|
type: 'array',
|
|
281
257
|
fields: {}
|
|
@@ -290,13 +266,8 @@ item) {
|
|
|
290
266
|
fields: {}
|
|
291
267
|
};
|
|
292
268
|
}
|
|
293
|
-
// // @ts-ignore
|
|
294
|
-
// itemRules.fields[index].fields[formControl.id] = (
|
|
295
|
-
// formControl as RuntimeFormControl
|
|
296
|
-
// ).rules
|
|
297
|
-
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
298
269
|
// @ts-ignore
|
|
299
|
-
itemRules.fields[index].fields[formControl.id] =
|
|
270
|
+
itemRules.fields[index].fields[formControl.id] = formControl.rules;
|
|
300
271
|
}
|
|
301
272
|
});
|
|
302
273
|
});
|
|
@@ -308,19 +279,15 @@ item) {
|
|
|
308
279
|
if (getControlIsHide(item)) {
|
|
309
280
|
return;
|
|
310
281
|
}
|
|
311
|
-
var result = Runtime.staticGetRules(item.type, item.props);
|
|
312
282
|
// if (item instanceof RuntimeFormControl) {
|
|
313
283
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
314
|
-
|
|
315
|
-
antdRules[item.id] = result;
|
|
284
|
+
antdRules[item.id] = item.rules;
|
|
316
285
|
} else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
|
|
317
286
|
antdRules[item.id] = [];
|
|
318
287
|
item.children.forEach(function(row) {
|
|
319
288
|
var rules = {};
|
|
320
289
|
loopFormSchema(row.children, function(formControl) {
|
|
321
|
-
|
|
322
|
-
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
323
|
-
rules[formControl.id] = childResult;
|
|
290
|
+
rules[formControl.id] = formControl.rules;
|
|
324
291
|
});
|
|
325
292
|
antdRules[item.id].push(rules);
|
|
326
293
|
});
|