@byteluck-fe/model-driven-engine 2.5.7 → 2.5.9-beta.4
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/ActionManager.js +3 -3
- package/dist/esm/common/DataManager.js +2 -2
- package/dist/esm/common/Engine.js +46 -46
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +48 -22
- package/dist/esm/common/Store.js +9 -9
- package/dist/esm/common/checkerValue.js +22 -22
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +38 -34
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +18 -14
- package/dist/esm/plugins/ControlsEventPlugin.js +2 -2
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +4 -4
- package/dist/esm/plugins/StylePlugin.js +5 -5
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +3 -3
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Runtime.d.ts +1 -0
- package/package.json +2 -2
|
@@ -179,7 +179,7 @@ function _ts_generator(thisArg, body) {
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
import { error, logerror } from
|
|
182
|
+
import { error, logerror } from '@byteluck-fe/model-driven-shared';
|
|
183
183
|
export var ActionManager = /*#__PURE__*/ function() {
|
|
184
184
|
"use strict";
|
|
185
185
|
function ActionManager() {
|
|
@@ -254,7 +254,7 @@ export var ActionManager = /*#__PURE__*/ function() {
|
|
|
254
254
|
key: "addAction",
|
|
255
255
|
value: function addAction(name, func) {
|
|
256
256
|
if (this.actionMap.has(name)) {
|
|
257
|
-
error(
|
|
257
|
+
error('duplicated action key');
|
|
258
258
|
}
|
|
259
259
|
var action = new Action(name, func);
|
|
260
260
|
this.actionMap.set(name, action);
|
|
@@ -267,7 +267,7 @@ var Action = function Action(id, func) {
|
|
|
267
267
|
"use strict";
|
|
268
268
|
_class_call_check(this, Action);
|
|
269
269
|
_define_property(this, "func", void 0);
|
|
270
|
-
_define_property(this, "id",
|
|
270
|
+
_define_property(this, "id", '');
|
|
271
271
|
this.id = id;
|
|
272
272
|
this.func = func;
|
|
273
273
|
};
|
|
@@ -154,7 +154,7 @@ function _ts_generator(thisArg, body) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
import { JSONCopy, logerror } from
|
|
157
|
+
import { JSONCopy, logerror } from '@byteluck-fe/model-driven-shared';
|
|
158
158
|
export var DataManager = /*#__PURE__*/ function() {
|
|
159
159
|
"use strict";
|
|
160
160
|
function DataManager(callbackExecuter) {
|
|
@@ -190,7 +190,7 @@ export var DataManager = /*#__PURE__*/ function() {
|
|
|
190
190
|
return _async_to_generator(function() {
|
|
191
191
|
return _ts_generator(this, function(_state) {
|
|
192
192
|
if (_this.executer === undefined) {
|
|
193
|
-
logerror(
|
|
193
|
+
logerror('未初始化executer');
|
|
194
194
|
return [
|
|
195
195
|
2,
|
|
196
196
|
[]
|
|
@@ -347,23 +347,23 @@ function _ts_generator(thisArg, body) {
|
|
|
347
347
|
};
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
import { DataBind, ObjectDataBind, RuntimeListControl } from
|
|
351
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from
|
|
352
|
-
import { Runtime } from
|
|
353
|
-
import { Store } from
|
|
354
|
-
import { findItem, proxyState } from
|
|
355
|
-
import { ActionManager } from
|
|
356
|
-
import { DataManager } from
|
|
357
|
-
import { checkerSubtableValue, checkerValue } from
|
|
358
|
-
import { buildUUID } from
|
|
359
|
-
if (typeof window !==
|
|
350
|
+
import { DataBind, ObjectDataBind, RuntimeListControl } from '@byteluck-fe/model-driven-core';
|
|
351
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from '@byteluck-fe/model-driven-shared';
|
|
352
|
+
import { Runtime } from './Runtime';
|
|
353
|
+
import { Store } from './Store';
|
|
354
|
+
import { findItem, proxyState } from './proxyState';
|
|
355
|
+
import { ActionManager } from './ActionManager';
|
|
356
|
+
import { DataManager } from './DataManager';
|
|
357
|
+
import { checkerSubtableValue, checkerValue } from './checkerValue';
|
|
358
|
+
import { buildUUID } from '../utils/runtimeUtils';
|
|
359
|
+
if (typeof window !== 'undefined') {
|
|
360
360
|
// @ts-ignore
|
|
361
361
|
window.engines = {};
|
|
362
362
|
}
|
|
363
363
|
// setState的时候,存储options中转变量
|
|
364
364
|
var eventOptionsTemp = null;
|
|
365
365
|
// 当前正在注册的插件名称
|
|
366
|
-
var applyingPluginName =
|
|
366
|
+
var applyingPluginName = '';
|
|
367
367
|
// 整体渲染引擎 并且 提供发布订阅能力
|
|
368
368
|
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
369
369
|
"use strict";
|
|
@@ -404,7 +404,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
404
404
|
_this.store = new Store({
|
|
405
405
|
instance: _this.runtime.instance
|
|
406
406
|
});
|
|
407
|
-
_this.debugLog(
|
|
407
|
+
_this.debugLog('engine is Instantiation complete');
|
|
408
408
|
// 自动执行挂载完成,也可以手动调用mount方法
|
|
409
409
|
autoMount && _this.mount();
|
|
410
410
|
return _this;
|
|
@@ -451,7 +451,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
451
451
|
// 触发所有控件的默认值的change事件
|
|
452
452
|
this.setStates(this.getState());
|
|
453
453
|
this.debugLog("engine的mount方法调用结束");
|
|
454
|
-
if (this.debug && typeof window !==
|
|
454
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
455
455
|
// @ts-ignore
|
|
456
456
|
window.engines[this.id] = this;
|
|
457
457
|
}
|
|
@@ -460,7 +460,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
460
460
|
{
|
|
461
461
|
key: "destroy",
|
|
462
462
|
value: function destroy() {
|
|
463
|
-
if (this.debug && typeof window !==
|
|
463
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
464
464
|
// @ts-ignore
|
|
465
465
|
delete window.engines[this.id];
|
|
466
466
|
}
|
|
@@ -501,7 +501,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
501
501
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
502
502
|
});
|
|
503
503
|
}
|
|
504
|
-
var keys = key.split(
|
|
504
|
+
var keys = key.split('.');
|
|
505
505
|
var lastKey = keys[keys.length - 1];
|
|
506
506
|
try {
|
|
507
507
|
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
@@ -533,7 +533,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
533
533
|
var newRows = [];
|
|
534
534
|
for(var i = 0; i < len; i++){
|
|
535
535
|
// @ts-ignore
|
|
536
|
-
var row = _this.listControlCreateRow(subtable,
|
|
536
|
+
var row = _this.listControlCreateRow(subtable, 'subtable-row');
|
|
537
537
|
row && newRows.push(row);
|
|
538
538
|
}
|
|
539
539
|
// @ts-ignore
|
|
@@ -547,8 +547,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
547
547
|
if (type && args) {
|
|
548
548
|
// const subtableOldLength = subtable.children.length
|
|
549
549
|
switch(type){
|
|
550
|
-
case
|
|
551
|
-
case
|
|
550
|
+
case 'push':
|
|
551
|
+
case 'unshift':
|
|
552
552
|
var _subtable_children;
|
|
553
553
|
var newRowLengths = args.length;
|
|
554
554
|
createdNewRows = createRows(newRowLengths);
|
|
@@ -556,7 +556,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
556
556
|
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
557
557
|
this.runtime.getFlatInstances();
|
|
558
558
|
break;
|
|
559
|
-
case
|
|
559
|
+
case 'splice':
|
|
560
560
|
if (args.length > 2) {
|
|
561
561
|
var // @ts-ignore
|
|
562
562
|
_subtable_children1;
|
|
@@ -591,11 +591,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
591
591
|
this.runtime.getFlatInstances();
|
|
592
592
|
break;
|
|
593
593
|
}
|
|
594
|
-
if (type ===
|
|
594
|
+
if (type === 'splice') {
|
|
595
595
|
deleted = result;
|
|
596
596
|
} else if ([
|
|
597
|
-
|
|
598
|
-
|
|
597
|
+
'pop',
|
|
598
|
+
'shift'
|
|
599
599
|
].includes(type)) {
|
|
600
600
|
deleted = [
|
|
601
601
|
result
|
|
@@ -603,7 +603,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
603
603
|
}
|
|
604
604
|
var subtableData = this.getState(subtable.id);
|
|
605
605
|
this._handlerSubtableUpdateUid(subtableData);
|
|
606
|
-
this.emit(
|
|
606
|
+
this.emit('list-change', {
|
|
607
607
|
instance: subtable,
|
|
608
608
|
value: subtableData,
|
|
609
609
|
options: Object.assign({}, options, {
|
|
@@ -624,7 +624,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
624
624
|
subtableData.forEach(function(item) {
|
|
625
625
|
if (!item.uid) {
|
|
626
626
|
Object.assign(item, {
|
|
627
|
-
uid:
|
|
627
|
+
uid: 'new:' + buildUUID('uid')
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
630
|
});
|
|
@@ -649,7 +649,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
649
649
|
var newRows = [];
|
|
650
650
|
for(var i = 0; i < newValue.length; i++){
|
|
651
651
|
// @ts-ignore
|
|
652
|
-
var row = this.listControlCreateRow(instance,
|
|
652
|
+
var row = this.listControlCreateRow(instance, 'subtable-row');
|
|
653
653
|
row && newRows.push(row);
|
|
654
654
|
}
|
|
655
655
|
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
@@ -663,7 +663,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
663
663
|
deleted = [];
|
|
664
664
|
}
|
|
665
665
|
this._handlerSubtableUpdateUid(newValue);
|
|
666
|
-
this.emit(
|
|
666
|
+
this.emit('list-change', {
|
|
667
667
|
instance: instance,
|
|
668
668
|
value: value,
|
|
669
669
|
options: _object_spread_props(_object_spread({}, options), {
|
|
@@ -672,12 +672,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
672
672
|
data: newValue,
|
|
673
673
|
deleted: deleted,
|
|
674
674
|
// deleted: oldValue ?? [],
|
|
675
|
-
type:
|
|
675
|
+
type: 'push',
|
|
676
676
|
jsonValue: JSON.stringify(newValue)
|
|
677
677
|
})
|
|
678
678
|
});
|
|
679
679
|
} else {
|
|
680
|
-
this.emit(
|
|
680
|
+
this.emit('change', {
|
|
681
681
|
instance: instance,
|
|
682
682
|
value: this.getState(instance.id, index),
|
|
683
683
|
rowIndex: index,
|
|
@@ -701,7 +701,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
701
701
|
} catch (e) {
|
|
702
702
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
703
703
|
} finally{
|
|
704
|
-
applyingPluginName =
|
|
704
|
+
applyingPluginName = '';
|
|
705
705
|
}
|
|
706
706
|
});
|
|
707
707
|
this.__pluginsApplied = true;
|
|
@@ -729,7 +729,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
729
729
|
key: "listControlAddRow",
|
|
730
730
|
value: function listControlAddRow(instance) {
|
|
731
731
|
var // @ts-ignore
|
|
732
|
-
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
732
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'subtable-row';
|
|
733
733
|
var row = this.listControlCreateRow(instance, rowType);
|
|
734
734
|
if (!row) return;
|
|
735
735
|
instance.children.push(row);
|
|
@@ -748,12 +748,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
748
748
|
return _ts_generator(this, function(_state) {
|
|
749
749
|
switch(_state.label){
|
|
750
750
|
case 0:
|
|
751
|
-
if (!(eventKey ===
|
|
751
|
+
if (!(eventKey === 'engine-mounted')) return [
|
|
752
752
|
3,
|
|
753
753
|
3
|
|
754
754
|
];
|
|
755
755
|
if (_this1.isMounted) {
|
|
756
|
-
warn(
|
|
756
|
+
warn('The engine-mounted life cycle can only be triggered once');
|
|
757
757
|
return [
|
|
758
758
|
2,
|
|
759
759
|
Promise.resolve([])
|
|
@@ -763,7 +763,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
763
763
|
3,
|
|
764
764
|
2
|
|
765
765
|
];
|
|
766
|
-
console.time(
|
|
766
|
+
console.time('engine-mounted need wait');
|
|
767
767
|
needWait = _to_consumable_array(_this1._jobTasks);
|
|
768
768
|
return [
|
|
769
769
|
4,
|
|
@@ -771,7 +771,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
771
771
|
];
|
|
772
772
|
case 1:
|
|
773
773
|
_state.sent();
|
|
774
|
-
console.timeEnd(
|
|
774
|
+
console.timeEnd('engine-mounted need wait');
|
|
775
775
|
_state.label = 2;
|
|
776
776
|
case 2:
|
|
777
777
|
_this1.isMounted = true;
|
|
@@ -911,9 +911,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
911
911
|
key: "setState",
|
|
912
912
|
value: function setState(controlId, value, rowIndex, options) {
|
|
913
913
|
eventOptionsTemp = options;
|
|
914
|
-
this.debugLog(
|
|
914
|
+
this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
|
|
915
915
|
this.store.setState(controlId, value, rowIndex);
|
|
916
|
-
this.debugLog(
|
|
916
|
+
this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
|
|
917
917
|
eventOptionsTemp = null;
|
|
918
918
|
}
|
|
919
919
|
},
|
|
@@ -996,13 +996,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
996
996
|
var data = getFieldData.map(function(item) {
|
|
997
997
|
var obj = {};
|
|
998
998
|
for(var key in item){
|
|
999
|
-
if (key ===
|
|
999
|
+
if (key === 'uid') {
|
|
1000
1000
|
obj[key] = item[key];
|
|
1001
1001
|
} else {
|
|
1002
1002
|
var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
|
|
1003
1003
|
var fieldCode = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : (_controlIdMapping_controlId_children_key = _controlIdMapping_controlId.children[key]) === null || _controlIdMapping_controlId_children_key === void 0 ? void 0 : (_controlIdMapping_controlId_children_key_dataBind = _controlIdMapping_controlId_children_key.dataBind) === null || _controlIdMapping_controlId_children_key_dataBind === void 0 ? void 0 : _controlIdMapping_controlId_children_key_dataBind.fieldCode;
|
|
1004
1004
|
//未绑定字段的控件,直接抛弃
|
|
1005
|
-
if (fieldCode !==
|
|
1005
|
+
if (fieldCode !== '') {
|
|
1006
1006
|
var _controlIdMapping_controlId1;
|
|
1007
1007
|
if (fieldCode) {
|
|
1008
1008
|
obj[fieldCode] = item[key];
|
|
@@ -1031,13 +1031,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1031
1031
|
obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
|
|
1032
1032
|
var objChi = {};
|
|
1033
1033
|
for(var keyChi in item){
|
|
1034
|
-
if (keyChi ===
|
|
1034
|
+
if (keyChi === 'uid') {
|
|
1035
1035
|
objChi[keyChi] = item[keyChi];
|
|
1036
1036
|
} else {
|
|
1037
1037
|
var _controlIdMapping_key_children_keyChi;
|
|
1038
1038
|
var fieldCode = (_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode;
|
|
1039
1039
|
//未绑定字段的控件,直接抛弃
|
|
1040
|
-
if (fieldCode !==
|
|
1040
|
+
if (fieldCode !== '') {
|
|
1041
1041
|
if (fieldCode) {
|
|
1042
1042
|
objChi[fieldCode] = item[keyChi];
|
|
1043
1043
|
} else {
|
|
@@ -1243,7 +1243,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1243
1243
|
newRow[fieldMapping.controlId] = objValue;
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
|
1246
|
-
if (fieldCode ===
|
|
1246
|
+
if (fieldCode === 'uid' && row.uid !== undefined) {
|
|
1247
1247
|
newRow.uid = row.uid;
|
|
1248
1248
|
}
|
|
1249
1249
|
});
|
|
@@ -1293,7 +1293,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1293
1293
|
var _newState_newMapping_controlId;
|
|
1294
1294
|
var mainStateKeys = Object.keys((_newState_newMapping_controlId = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
|
|
1295
1295
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1296
|
-
if (!mainStateKeys.includes(key) && key !==
|
|
1296
|
+
if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1297
1297
|
if (Object.keys(newState).length) {
|
|
1298
1298
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
|
|
1299
1299
|
} else {
|
|
@@ -1376,14 +1376,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1376
1376
|
value: function setInstance(instance, props, value, rowIndex) {
|
|
1377
1377
|
var _this = this;
|
|
1378
1378
|
try {
|
|
1379
|
-
if (typeof instance ===
|
|
1379
|
+
if (typeof instance === 'string' && rowIndex === -1) {
|
|
1380
1380
|
//修改明细表整列属性的逻辑
|
|
1381
1381
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1382
1382
|
instances.map(function(_instance) {
|
|
1383
1383
|
if (_instance) {
|
|
1384
1384
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1385
1385
|
updateValueFromKeys(_instance.props, props, value);
|
|
1386
|
-
_this.schemaEvent(
|
|
1386
|
+
_this.schemaEvent('schema-change', {
|
|
1387
1387
|
instance: _instance,
|
|
1388
1388
|
props: props,
|
|
1389
1389
|
value: value,
|
|
@@ -1393,7 +1393,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1393
1393
|
});
|
|
1394
1394
|
} else {
|
|
1395
1395
|
var _instance;
|
|
1396
|
-
if (typeof instance ===
|
|
1396
|
+
if (typeof instance === 'string') {
|
|
1397
1397
|
_instance = this.getInstance(instance, rowIndex);
|
|
1398
1398
|
} else {
|
|
1399
1399
|
_instance = instance;
|
|
@@ -1403,7 +1403,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1405
1405
|
updateValueFromKeys(_instance.props, props, value);
|
|
1406
|
-
this.schemaEvent(
|
|
1406
|
+
this.schemaEvent('schema-change', {
|
|
1407
1407
|
instance: _instance,
|
|
1408
1408
|
props: props,
|
|
1409
1409
|
value: value,
|
|
@@ -30,7 +30,7 @@ function _define_property(obj, key, value) {
|
|
|
30
30
|
}
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
|
-
import { log } from
|
|
33
|
+
import { log } from '@byteluck-fe/model-driven-shared';
|
|
34
34
|
var OkWorker = /*#__PURE__*/ function() {
|
|
35
35
|
"use strict";
|
|
36
36
|
function OkWorker() {
|
|
@@ -43,7 +43,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
43
43
|
value: function run(initState) {
|
|
44
44
|
this.worker = OkWorker.createWorker();
|
|
45
45
|
this.postMessage({
|
|
46
|
-
action:
|
|
46
|
+
action: 'init',
|
|
47
47
|
payload: initState
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -77,7 +77,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
77
77
|
key: "createWorkerFunction",
|
|
78
78
|
value: function createWorkerFunction() {
|
|
79
79
|
return function() {
|
|
80
|
-
log(
|
|
80
|
+
log('🚀 worker running');
|
|
81
81
|
var _self = self;
|
|
82
82
|
function createHandler(parentKey) {
|
|
83
83
|
return {
|
|
@@ -87,7 +87,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
87
87
|
set: function set(target, key, value) {
|
|
88
88
|
if (parentKey) {
|
|
89
89
|
_self.postMessage({
|
|
90
|
-
action:
|
|
90
|
+
action: 'update',
|
|
91
91
|
key: "".concat(parentKey, ".").concat(key)
|
|
92
92
|
});
|
|
93
93
|
}
|
|
@@ -106,7 +106,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
106
106
|
// }
|
|
107
107
|
// return new Proxy(obj, createHandler(parentKey))
|
|
108
108
|
// }
|
|
109
|
-
_self.addEventListener(
|
|
109
|
+
_self.addEventListener('message', function(event) {
|
|
110
110
|
var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
|
|
111
111
|
log(action, payload);
|
|
112
112
|
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
@@ -118,10 +118,10 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
118
118
|
//
|
|
119
119
|
// const result = fn(data, schema)
|
|
120
120
|
_self.postMessage({
|
|
121
|
-
action:
|
|
121
|
+
action: 'delete',
|
|
122
122
|
payload: {
|
|
123
|
-
key:
|
|
124
|
-
value:
|
|
123
|
+
key: 'key3[0].key1',
|
|
124
|
+
value: 'index'
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
});
|
|
@@ -96,9 +96,9 @@ function _create_super(Derived) {
|
|
|
96
96
|
return _possible_constructor_return(this, result);
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
import { RegisterControls } from
|
|
100
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from
|
|
101
|
-
import { hasChildrenControl, loopDataViewControl, loopFormControl } from
|
|
99
|
+
import { RegisterControls } from '@byteluck-fe/model-driven-core';
|
|
100
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema, isArray } from '@byteluck-fe/model-driven-shared';
|
|
101
|
+
import { hasChildrenControl, loopDataViewControl, loopFormControl } from '../utils/runtimeUtils';
|
|
102
102
|
export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
103
103
|
"use strict";
|
|
104
104
|
_inherits(Runtime, RegisterControls);
|
|
@@ -106,11 +106,12 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
106
106
|
function Runtime(props) {
|
|
107
107
|
_class_call_check(this, Runtime);
|
|
108
108
|
var _this;
|
|
109
|
-
_this = _super.call(this,
|
|
109
|
+
_this = _super.call(this, 'Runtime');
|
|
110
110
|
_define_property(_assert_this_initialized(_this), "_schema", void 0);
|
|
111
111
|
_define_property(_assert_this_initialized(_this), "_instance", void 0);
|
|
112
112
|
_define_property(_assert_this_initialized(_this), "_flatInstances", []);
|
|
113
113
|
_define_property(_assert_this_initialized(_this), "_instanceMap", {});
|
|
114
|
+
_define_property(_assert_this_initialized(_this), "_controlParentIdMap", {});
|
|
114
115
|
var schema = props.schema;
|
|
115
116
|
_this._schema = schema;
|
|
116
117
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
@@ -123,19 +124,32 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
123
124
|
value: function getFlatInstances() {
|
|
124
125
|
var instances = [];
|
|
125
126
|
var instanceMap = {};
|
|
126
|
-
|
|
127
|
+
var controlParentIdMap = {};
|
|
128
|
+
loop(this._instance, '', function(item, parentId) {
|
|
127
129
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
//4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
|
|
131
|
+
// if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
132
|
+
// return
|
|
133
|
+
// }
|
|
134
|
+
if (parentId) {
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
controlParentIdMap[item.id] = parentId;
|
|
130
137
|
}
|
|
131
|
-
instances.push(item);
|
|
132
138
|
if (!instanceMap[item.id]) {
|
|
133
139
|
instanceMap[item.id] = [];
|
|
134
140
|
}
|
|
141
|
+
//不知为何subtable-column会多存一次
|
|
142
|
+
if (item.type === 'subtable-column') {
|
|
143
|
+
if (instanceMap[item.id].length > 0) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
instances.push(item);
|
|
135
148
|
instanceMap[item.id].push(item);
|
|
136
149
|
});
|
|
137
150
|
this._flatInstances = instances;
|
|
138
151
|
this._instanceMap = instanceMap;
|
|
152
|
+
this._controlParentIdMap = controlParentIdMap;
|
|
139
153
|
return this._flatInstances;
|
|
140
154
|
}
|
|
141
155
|
},
|
|
@@ -229,18 +243,30 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
229
243
|
]);
|
|
230
244
|
return Runtime;
|
|
231
245
|
}(RegisterControls);
|
|
232
|
-
function loop(control, callback) {
|
|
233
|
-
|
|
234
|
-
control
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
246
|
+
function loop(control, parentId, callback) {
|
|
247
|
+
var _instances = Array.isArray(control) ? control : [
|
|
248
|
+
control
|
|
249
|
+
];
|
|
250
|
+
_instances.map(function(item) {
|
|
251
|
+
callback(item, parentId);
|
|
252
|
+
if (hasChildrenControl(item)) {
|
|
253
|
+
var ctl = item;
|
|
254
|
+
if (!ctl.children) {
|
|
255
|
+
ctl.children = [];
|
|
239
256
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
257
|
+
// @ts-ignore
|
|
258
|
+
loop(ctl.children, ctl.id, callback);
|
|
259
|
+
}
|
|
260
|
+
if (hasHeaderOrFooterControl(item, 'headers')) {
|
|
261
|
+
loop(item.props.headers, item.id, callback);
|
|
262
|
+
}
|
|
263
|
+
if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
264
|
+
loop(item.props.footers, item.id, callback);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
function hasHeaderOrFooterControl(control, checkType) {
|
|
269
|
+
return checkType in control.props && isArray(control.props[checkType]);
|
|
244
270
|
}
|
|
245
271
|
/**
|
|
246
272
|
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
@@ -248,7 +274,7 @@ function loop(control, callback) {
|
|
|
248
274
|
if (control.props.isHide) {
|
|
249
275
|
return true;
|
|
250
276
|
}
|
|
251
|
-
if (control.parent === null) {
|
|
277
|
+
if (control.parent === null || control.parent === undefined) {
|
|
252
278
|
return false;
|
|
253
279
|
}
|
|
254
280
|
return getControlIsHide(control.parent);
|
|
@@ -264,7 +290,7 @@ item) {
|
|
|
264
290
|
} else if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
265
291
|
data[item.id] = item.rules;
|
|
266
292
|
var itemRules = {
|
|
267
|
-
type:
|
|
293
|
+
type: 'array',
|
|
268
294
|
fields: {}
|
|
269
295
|
};
|
|
270
296
|
item.children.forEach(function(row, index) {
|
|
@@ -272,7 +298,7 @@ item) {
|
|
|
272
298
|
if (itemRules.fields) {
|
|
273
299
|
if (!itemRules.fields[index]) {
|
|
274
300
|
itemRules.fields[index] = {
|
|
275
|
-
type:
|
|
301
|
+
type: 'object',
|
|
276
302
|
required: true,
|
|
277
303
|
fields: {}
|
|
278
304
|
};
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -52,9 +52,9 @@ function _object_spread(target) {
|
|
|
52
52
|
}
|
|
53
53
|
return target;
|
|
54
54
|
}
|
|
55
|
-
import { DataBind, ObjectDataBind } from
|
|
56
|
-
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from
|
|
57
|
-
import { loopDataViewControl, loopFormControl, buildUUID } from
|
|
55
|
+
import { DataBind, ObjectDataBind } from '@byteluck-fe/model-driven-core';
|
|
56
|
+
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
57
|
+
import { loopDataViewControl, loopFormControl, buildUUID } from '../utils/runtimeUtils';
|
|
58
58
|
var Store = /*#__PURE__*/ function() {
|
|
59
59
|
"use strict";
|
|
60
60
|
function Store(props) {
|
|
@@ -91,7 +91,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
91
91
|
value.forEach(function(item) {
|
|
92
92
|
if (!item.uid) {
|
|
93
93
|
Object.assign(item, {
|
|
94
|
-
uid:
|
|
94
|
+
uid: 'new:' + buildUUID('uid')
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
});
|
|
@@ -192,9 +192,9 @@ var Store = /*#__PURE__*/ function() {
|
|
|
192
192
|
if (controlInfo !== undefined) {
|
|
193
193
|
var state = this.emptyState[controlInfo.dataView][controlId];
|
|
194
194
|
//判断找到的是否是明细表的控件
|
|
195
|
-
if (
|
|
195
|
+
if ('children' in controlInfo) {
|
|
196
196
|
Object.assign(state, {
|
|
197
|
-
uid:
|
|
197
|
+
uid: 'new:' + buildUUID('uid')
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
return state;
|
|
@@ -292,7 +292,7 @@ item) {
|
|
|
292
292
|
var _item_props_defaultRows, _fill_map;
|
|
293
293
|
dataViewState[item.id] = (_fill_map = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
294
294
|
return _object_spread({
|
|
295
|
-
uid:
|
|
295
|
+
uid: 'new:' + buildUUID('uid')
|
|
296
296
|
}, JSONCopy(emptyTemplate));
|
|
297
297
|
})) !== null && _fill_map !== void 0 ? _fill_map : [];
|
|
298
298
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
@@ -346,7 +346,7 @@ item) {
|
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
348
|
} else {
|
|
349
|
-
if (item.props.datasourceBind.dataCode ===
|
|
349
|
+
if (item.props.datasourceBind.dataCode === '') {
|
|
350
350
|
//敏捷依赖后端生成dataCode,预览的时候没有
|
|
351
351
|
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item.id, " type:").concat(item.type));
|
|
352
352
|
return;
|
|
@@ -399,7 +399,7 @@ item) {
|
|
|
399
399
|
data[item.id] = {
|
|
400
400
|
dataBind: new DataBind({
|
|
401
401
|
dataCode: item.props.datasourceBind.dataCode,
|
|
402
|
-
fieldCode:
|
|
402
|
+
fieldCode: ''
|
|
403
403
|
}),
|
|
404
404
|
dataView: dataViewId,
|
|
405
405
|
children: {},
|