@byteluck-fe/model-driven-engine 2.22.0-beta.4 → 2.22.0-beta.7
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 +54 -54
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +16 -16
- 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 +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +5 -5
- package/dist/esm/plugins/StylePlugin.js +12 -6
- 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/plugins/StylePlugin.d.ts +2 -1
- package/package.json +4 -4
|
@@ -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() {
|
|
@@ -255,7 +255,7 @@ export var ActionManager = /*#__PURE__*/ function() {
|
|
|
255
255
|
key: "addAction",
|
|
256
256
|
value: function addAction(name, func) {
|
|
257
257
|
if (this.actionMap.has(name)) {
|
|
258
|
-
error(
|
|
258
|
+
error('duplicated action key');
|
|
259
259
|
}
|
|
260
260
|
var action = new Action(name, func);
|
|
261
261
|
this.actionMap.set(name, action);
|
|
@@ -268,7 +268,7 @@ var Action = function Action(id, func) {
|
|
|
268
268
|
"use strict";
|
|
269
269
|
_class_call_check(this, Action);
|
|
270
270
|
_define_property(this, "func", void 0);
|
|
271
|
-
_define_property(this, "id",
|
|
271
|
+
_define_property(this, "id", '');
|
|
272
272
|
this.id = id;
|
|
273
273
|
this.func = func;
|
|
274
274
|
};
|
|
@@ -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
|
[]
|
|
@@ -340,23 +340,23 @@ function _ts_generator(thisArg, body) {
|
|
|
340
340
|
};
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
import { isDataBind } from
|
|
344
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from
|
|
345
|
-
import { Runtime } from
|
|
346
|
-
import { Store } from
|
|
347
|
-
import { findItem, proxyState } from
|
|
348
|
-
import { ActionManager } from
|
|
349
|
-
import { DataManager } from
|
|
350
|
-
import { checkerSubtableValue, checkerValue } from
|
|
351
|
-
import { buildUUID } from
|
|
352
|
-
if (typeof window !==
|
|
343
|
+
import { isDataBind } from '@byteluck-fe/model-driven-core';
|
|
344
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
|
|
345
|
+
import { Runtime } from './Runtime';
|
|
346
|
+
import { Store } from './Store';
|
|
347
|
+
import { findItem, proxyState } from './proxyState';
|
|
348
|
+
import { ActionManager } from './ActionManager';
|
|
349
|
+
import { DataManager } from './DataManager';
|
|
350
|
+
import { checkerSubtableValue, checkerValue } from './checkerValue';
|
|
351
|
+
import { buildUUID } from '../utils/runtimeUtils';
|
|
352
|
+
if (typeof window !== 'undefined') {
|
|
353
353
|
// @ts-ignore
|
|
354
354
|
window.engines = {};
|
|
355
355
|
}
|
|
356
356
|
// setState的时候,存储options中转变量
|
|
357
357
|
var eventOptionsTemp = null;
|
|
358
358
|
// 当前正在注册的插件名称
|
|
359
|
-
var applyingPluginName =
|
|
359
|
+
var applyingPluginName = '';
|
|
360
360
|
// 整体渲染引擎 并且 提供发布订阅能力
|
|
361
361
|
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
362
362
|
"use strict";
|
|
@@ -397,7 +397,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
397
397
|
_this.store = new Store({
|
|
398
398
|
instance: _this.runtime.instance
|
|
399
399
|
});
|
|
400
|
-
_this.debugLog(
|
|
400
|
+
_this.debugLog('engine is Instantiation complete');
|
|
401
401
|
// 自动执行挂载完成,也可以手动调用mount方法
|
|
402
402
|
autoMount && _this.mount();
|
|
403
403
|
return _this;
|
|
@@ -444,7 +444,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
444
444
|
// 触发所有控件的默认值的change事件
|
|
445
445
|
this.setStates(this.getState());
|
|
446
446
|
this.debugLog("engine的mount方法调用结束");
|
|
447
|
-
if (this.debug && typeof window !==
|
|
447
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
448
448
|
// @ts-ignore
|
|
449
449
|
window.engines[this.id] = this;
|
|
450
450
|
}
|
|
@@ -453,7 +453,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
453
453
|
{
|
|
454
454
|
key: "destroy",
|
|
455
455
|
value: function destroy() {
|
|
456
|
-
if (this.debug && typeof window !==
|
|
456
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
457
457
|
// @ts-ignore
|
|
458
458
|
delete window.engines[this.id];
|
|
459
459
|
}
|
|
@@ -494,7 +494,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
494
494
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
|
-
var keys = key.split(
|
|
497
|
+
var keys = key.split('.');
|
|
498
498
|
var lastKey = keys[keys.length - 1];
|
|
499
499
|
try {
|
|
500
500
|
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
@@ -527,7 +527,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
527
527
|
var newRows = [];
|
|
528
528
|
for(var i = 0; i < len; i++){
|
|
529
529
|
// @ts-ignore
|
|
530
|
-
var row = _this.listControlCreateRow(subtable,
|
|
530
|
+
var row = _this.listControlCreateRow(subtable, 'subtable-row');
|
|
531
531
|
row && newRows.push(row);
|
|
532
532
|
}
|
|
533
533
|
// @ts-ignore
|
|
@@ -542,8 +542,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
542
542
|
if (type && args) {
|
|
543
543
|
// const subtableOldLength = subtable.children.length
|
|
544
544
|
switch(type){
|
|
545
|
-
case
|
|
546
|
-
case
|
|
545
|
+
case 'push':
|
|
546
|
+
case 'unshift':
|
|
547
547
|
var _subtable_children;
|
|
548
548
|
var newRowLengths = args.length;
|
|
549
549
|
createdNewRows = createRows(newRowLengths);
|
|
@@ -551,7 +551,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
551
551
|
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
552
552
|
this.runtime.getFlatInstances();
|
|
553
553
|
break;
|
|
554
|
-
case
|
|
554
|
+
case 'splice':
|
|
555
555
|
if (args.length > 2) {
|
|
556
556
|
var // @ts-ignore
|
|
557
557
|
_subtable_children1;
|
|
@@ -593,11 +593,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
593
593
|
this.runtime.getFlatInstances();
|
|
594
594
|
break;
|
|
595
595
|
}
|
|
596
|
-
if (type ===
|
|
596
|
+
if (type === 'splice') {
|
|
597
597
|
deleted = result;
|
|
598
598
|
} else if ([
|
|
599
|
-
|
|
600
|
-
|
|
599
|
+
'pop',
|
|
600
|
+
'shift'
|
|
601
601
|
].includes(type)) {
|
|
602
602
|
deleted = [
|
|
603
603
|
result
|
|
@@ -605,7 +605,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
605
605
|
}
|
|
606
606
|
var subtableData = this.getState(subtable.id);
|
|
607
607
|
this._handlerSubtableUpdateUid(subtableData);
|
|
608
|
-
this.emit(
|
|
608
|
+
this.emit('list-change', {
|
|
609
609
|
instance: subtable,
|
|
610
610
|
value: subtableData,
|
|
611
611
|
options: Object.assign({}, options, {
|
|
@@ -629,7 +629,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
629
629
|
subtableData.forEach(function(item) {
|
|
630
630
|
if (!item.uid) {
|
|
631
631
|
Object.assign(item, {
|
|
632
|
-
uid:
|
|
632
|
+
uid: 'new:' + buildUUID('uid')
|
|
633
633
|
});
|
|
634
634
|
}
|
|
635
635
|
});
|
|
@@ -654,7 +654,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
654
654
|
var newRows = [];
|
|
655
655
|
for(var i = 0; i < newValue.length; i++){
|
|
656
656
|
// @ts-ignore
|
|
657
|
-
var row = this.listControlCreateRow(instance,
|
|
657
|
+
var row = this.listControlCreateRow(instance, 'subtable-row');
|
|
658
658
|
row && newRows.push(row);
|
|
659
659
|
}
|
|
660
660
|
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
@@ -668,7 +668,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
668
668
|
deleted = [];
|
|
669
669
|
}
|
|
670
670
|
this._handlerSubtableUpdateUid(newValue);
|
|
671
|
-
this.emit(
|
|
671
|
+
this.emit('list-change', {
|
|
672
672
|
instance: instance,
|
|
673
673
|
value: value,
|
|
674
674
|
options: _object_spread_props(_object_spread({}, options), {
|
|
@@ -677,12 +677,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
677
677
|
data: newValue,
|
|
678
678
|
deleted: deleted,
|
|
679
679
|
// deleted: oldValue ?? [],
|
|
680
|
-
type:
|
|
680
|
+
type: 'push',
|
|
681
681
|
jsonValue: JSON.stringify(newValue)
|
|
682
682
|
})
|
|
683
683
|
});
|
|
684
684
|
} else {
|
|
685
|
-
this.emit(
|
|
685
|
+
this.emit('change', {
|
|
686
686
|
instance: instance,
|
|
687
687
|
value: this.getState(instance.id, index),
|
|
688
688
|
rowIndex: index,
|
|
@@ -706,7 +706,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
706
706
|
} catch (e) {
|
|
707
707
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
708
708
|
} finally{
|
|
709
|
-
applyingPluginName =
|
|
709
|
+
applyingPluginName = '';
|
|
710
710
|
}
|
|
711
711
|
});
|
|
712
712
|
this.__pluginsApplied = true;
|
|
@@ -716,20 +716,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
716
716
|
key: "listControlCreateRow",
|
|
717
717
|
value: function listControlCreateRow(instance, rowType) {
|
|
718
718
|
var row;
|
|
719
|
-
if (rowType ===
|
|
719
|
+
if (rowType === 'subtable-row') {
|
|
720
720
|
row = {
|
|
721
721
|
children: [],
|
|
722
722
|
controlType: CONTROL_BASE_TYPE.LAYOUT,
|
|
723
723
|
id: genNonDuplicateId(),
|
|
724
|
-
type:
|
|
724
|
+
type: 'subtable-row',
|
|
725
725
|
props: {
|
|
726
|
-
caption:
|
|
726
|
+
caption: '',
|
|
727
727
|
isHide: false,
|
|
728
728
|
style: {
|
|
729
|
-
height:
|
|
730
|
-
heightConfig:
|
|
731
|
-
width:
|
|
732
|
-
widthConfig:
|
|
729
|
+
height: '',
|
|
730
|
+
heightConfig: 'fill',
|
|
731
|
+
width: '',
|
|
732
|
+
widthConfig: 'fill'
|
|
733
733
|
}
|
|
734
734
|
},
|
|
735
735
|
fieldType: undefined,
|
|
@@ -783,7 +783,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
783
783
|
key: "listControlAddRow",
|
|
784
784
|
value: function listControlAddRow(instance) {
|
|
785
785
|
var // @ts-ignore
|
|
786
|
-
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
786
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'subtable-row';
|
|
787
787
|
var row = this.listControlCreateRow(instance, rowType);
|
|
788
788
|
if (!row) return;
|
|
789
789
|
instance.children.push(row);
|
|
@@ -802,12 +802,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
802
802
|
return _ts_generator(this, function(_state) {
|
|
803
803
|
switch(_state.label){
|
|
804
804
|
case 0:
|
|
805
|
-
if (!(eventKey ===
|
|
805
|
+
if (!(eventKey === 'engine-mounted')) return [
|
|
806
806
|
3,
|
|
807
807
|
3
|
|
808
808
|
];
|
|
809
809
|
if (_this1.isMounted) {
|
|
810
|
-
warn(
|
|
810
|
+
warn('The engine-mounted life cycle can only be triggered once');
|
|
811
811
|
return [
|
|
812
812
|
2,
|
|
813
813
|
Promise.resolve([])
|
|
@@ -817,7 +817,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
817
817
|
3,
|
|
818
818
|
2
|
|
819
819
|
];
|
|
820
|
-
console.time(
|
|
820
|
+
console.time('engine-mounted need wait');
|
|
821
821
|
needWait = _to_consumable_array(_this1._jobTasks);
|
|
822
822
|
return [
|
|
823
823
|
4,
|
|
@@ -825,7 +825,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
825
825
|
];
|
|
826
826
|
case 1:
|
|
827
827
|
_state.sent();
|
|
828
|
-
console.timeEnd(
|
|
828
|
+
console.timeEnd('engine-mounted need wait');
|
|
829
829
|
_state.label = 2;
|
|
830
830
|
case 2:
|
|
831
831
|
_this1.isMounted = true;
|
|
@@ -990,9 +990,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
990
990
|
key: "setState",
|
|
991
991
|
value: function setState(controlId, value, rowIndex, options) {
|
|
992
992
|
eventOptionsTemp = options;
|
|
993
|
-
this.debugLog(
|
|
993
|
+
this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
|
|
994
994
|
this.store.setState(controlId, value, rowIndex);
|
|
995
|
-
this.debugLog(
|
|
995
|
+
this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
|
|
996
996
|
eventOptionsTemp = null;
|
|
997
997
|
}
|
|
998
998
|
},
|
|
@@ -1079,7 +1079,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1079
1079
|
var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
|
|
1080
1080
|
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;
|
|
1081
1081
|
//未绑定字段的控件,直接抛弃
|
|
1082
|
-
if (fieldCode !==
|
|
1082
|
+
if (fieldCode !== '') {
|
|
1083
1083
|
var _controlIdMapping_controlId1;
|
|
1084
1084
|
if (fieldCode) {
|
|
1085
1085
|
obj[fieldCode] = item[key];
|
|
@@ -1110,7 +1110,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1110
1110
|
var _controlIdMapping_key_children_keyChi;
|
|
1111
1111
|
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;
|
|
1112
1112
|
//未绑定字段的控件,直接抛弃
|
|
1113
|
-
if (fieldCode !==
|
|
1113
|
+
if (fieldCode !== '') {
|
|
1114
1114
|
if (fieldCode) {
|
|
1115
1115
|
objChi[fieldCode] = item[keyChi];
|
|
1116
1116
|
} else {
|
|
@@ -1331,9 +1331,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1331
1331
|
});
|
|
1332
1332
|
newRow[fieldMapping.controlId] = objValue;
|
|
1333
1333
|
}
|
|
1334
|
-
} else if (fieldCode ===
|
|
1334
|
+
} else if (fieldCode === 'uid' && row.uid !== undefined) {
|
|
1335
1335
|
newRow.uid = row.uid;
|
|
1336
|
-
} else if (fieldCode ===
|
|
1336
|
+
} else if (fieldCode === 'virtualStore' && row.virtualStore !== undefined) {
|
|
1337
1337
|
newRow.virtualStore = Object.freeze(row.virtualStore);
|
|
1338
1338
|
}
|
|
1339
1339
|
});
|
|
@@ -1385,7 +1385,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1385
1385
|
var _newState_newMapping_controlId;
|
|
1386
1386
|
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 : {});
|
|
1387
1387
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1388
|
-
if (!mainStateKeys.includes(key) && key !==
|
|
1388
|
+
if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1389
1389
|
if (Object.keys(newState).length) {
|
|
1390
1390
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
|
|
1391
1391
|
} else {
|
|
@@ -1522,14 +1522,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1522
1522
|
value: function setInstance(instance, props, value, rowIndex) {
|
|
1523
1523
|
var _this = this;
|
|
1524
1524
|
try {
|
|
1525
|
-
if (typeof instance ===
|
|
1525
|
+
if (typeof instance === 'string' && rowIndex === -1) {
|
|
1526
1526
|
//修改明细表整列属性的逻辑
|
|
1527
1527
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1528
1528
|
instances.map(function(_instance) {
|
|
1529
1529
|
if (_instance) {
|
|
1530
1530
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1531
1531
|
updateValueFromKeys(_instance.props, props, value);
|
|
1532
|
-
_this.schemaEvent(
|
|
1532
|
+
_this.schemaEvent('schema-change', {
|
|
1533
1533
|
instance: _instance,
|
|
1534
1534
|
props: props,
|
|
1535
1535
|
value: value,
|
|
@@ -1539,7 +1539,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1539
1539
|
});
|
|
1540
1540
|
} else {
|
|
1541
1541
|
var _instance;
|
|
1542
|
-
if (typeof instance ===
|
|
1542
|
+
if (typeof instance === 'string') {
|
|
1543
1543
|
_instance = this.getInstance(instance, rowIndex);
|
|
1544
1544
|
} else {
|
|
1545
1545
|
_instance = instance;
|
|
@@ -1549,7 +1549,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1549
1549
|
}
|
|
1550
1550
|
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1551
1551
|
updateValueFromKeys(_instance.props, props, value);
|
|
1552
|
-
this.schemaEvent(
|
|
1552
|
+
this.schemaEvent('schema-change', {
|
|
1553
1553
|
instance: _instance,
|
|
1554
1554
|
props: props,
|
|
1555
1555
|
value: value,
|
|
@@ -1676,7 +1676,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1676
1676
|
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1677
1677
|
if (isColumnChild) {
|
|
1678
1678
|
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1679
|
-
if (Object.prototype.toString.call(instanceList) ===
|
|
1679
|
+
if (Object.prototype.toString.call(instanceList) === '[object Array]') {
|
|
1680
1680
|
var index = instanceList.findIndex(function(item) {
|
|
1681
1681
|
return item === instance;
|
|
1682
1682
|
});
|
|
@@ -1782,7 +1782,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1782
1782
|
key: "register",
|
|
1783
1783
|
value: // 注册外部控件
|
|
1784
1784
|
function register(control) {
|
|
1785
|
-
return Runtime.register(control,
|
|
1785
|
+
return Runtime.register(control, 'Runtime');
|
|
1786
1786
|
}
|
|
1787
1787
|
},
|
|
1788
1788
|
{
|
|
@@ -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, isDataBind } from
|
|
100
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema, isArray } from
|
|
101
|
-
import { hasChildrenControl, loopDataViewControl, loopFormControl } from
|
|
99
|
+
import { RegisterControls, isDataBind } from '@byteluck-fe/model-driven-core';
|
|
100
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, 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,7 +106,7 @@ 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", []);
|
|
@@ -125,7 +125,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
125
125
|
var instances = [];
|
|
126
126
|
var instanceMap = {};
|
|
127
127
|
var controlParentIdMap = {};
|
|
128
|
-
loop(this._instance,
|
|
128
|
+
loop(this._instance, '', function(item, parentId) {
|
|
129
129
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
130
130
|
//4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
|
|
131
131
|
// if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
@@ -139,7 +139,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
139
139
|
instanceMap[item.id] = [];
|
|
140
140
|
}
|
|
141
141
|
//不知为何subtable-column会多存一次
|
|
142
|
-
if (item.type ===
|
|
142
|
+
if (item.type === 'subtable-column') {
|
|
143
143
|
if (instanceMap[item.id].length > 0) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
@@ -290,10 +290,10 @@ function loop(control, parentId, callback) {
|
|
|
290
290
|
// @ts-ignore
|
|
291
291
|
loop(ctl.children, ctl.id, callback);
|
|
292
292
|
}
|
|
293
|
-
if (hasHeaderOrFooterControl(item,
|
|
293
|
+
if (hasHeaderOrFooterControl(item, 'headers')) {
|
|
294
294
|
loop(item.props.headers, item.id, callback);
|
|
295
295
|
}
|
|
296
|
-
if (hasHeaderOrFooterControl(item,
|
|
296
|
+
if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
297
297
|
loop(item.props.footers, item.id, callback);
|
|
298
298
|
}
|
|
299
299
|
});
|
|
@@ -327,7 +327,7 @@ item) {
|
|
|
327
327
|
// data[item.id] = item.rules
|
|
328
328
|
data[item.id] = result;
|
|
329
329
|
var itemRules = {
|
|
330
|
-
type:
|
|
330
|
+
type: 'array',
|
|
331
331
|
fields: {}
|
|
332
332
|
};
|
|
333
333
|
(isSubtableDefaultRules === true ? [
|
|
@@ -339,7 +339,7 @@ item) {
|
|
|
339
339
|
if (itemRules.fields) {
|
|
340
340
|
if (!itemRules.fields[index]) {
|
|
341
341
|
itemRules.fields[index] = {
|
|
342
|
-
type:
|
|
342
|
+
type: 'object',
|
|
343
343
|
required: true,
|
|
344
344
|
fields: {}
|
|
345
345
|
};
|
|
@@ -368,7 +368,7 @@ item) {
|
|
|
368
368
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
369
369
|
if (isDataBind(item.props.dataBind)) {
|
|
370
370
|
var _item_props_dataBind;
|
|
371
|
-
if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) !=
|
|
371
|
+
if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) != '') {
|
|
372
372
|
var _item_props_dataBind1;
|
|
373
373
|
data[(_item_props_dataBind1 = item.props.dataBind) === null || _item_props_dataBind1 === void 0 ? void 0 : _item_props_dataBind1.fieldCode] = result;
|
|
374
374
|
}
|
|
@@ -376,7 +376,7 @@ item) {
|
|
|
376
376
|
for(var dataBindKey in item.props.dataBind){
|
|
377
377
|
var _item_props_dataBind_dataBindKey;
|
|
378
378
|
// @ts-ignore
|
|
379
|
-
if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) !=
|
|
379
|
+
if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) != '') {
|
|
380
380
|
var // @ts-ignore
|
|
381
381
|
_item_props_dataBind_dataBindKey1, _findFields;
|
|
382
382
|
// @ts-ignore
|
|
@@ -388,7 +388,7 @@ item) {
|
|
|
388
388
|
var _item_props_datasourceBind, _item_props_datasourceBind1;
|
|
389
389
|
data[(_item_props_datasourceBind = item.props.datasourceBind) === null || _item_props_datasourceBind === void 0 ? void 0 : _item_props_datasourceBind.dataCode] = result;
|
|
390
390
|
var itemRules = {
|
|
391
|
-
type:
|
|
391
|
+
type: 'array',
|
|
392
392
|
fields: {}
|
|
393
393
|
};
|
|
394
394
|
(isSubtableDefaultRules === true ? [
|
|
@@ -400,7 +400,7 @@ item) {
|
|
|
400
400
|
if (itemRules.fields) {
|
|
401
401
|
if (!itemRules.fields[index]) {
|
|
402
402
|
itemRules.fields[index] = {
|
|
403
|
-
type:
|
|
403
|
+
type: 'object',
|
|
404
404
|
required: true,
|
|
405
405
|
fields: {}
|
|
406
406
|
};
|
|
@@ -410,7 +410,7 @@ item) {
|
|
|
410
410
|
for(var dataBindKey in formControl.props.dataBind){
|
|
411
411
|
var _formControl_props_dataBind_dataBindKey;
|
|
412
412
|
// @ts-ignore
|
|
413
|
-
if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) !=
|
|
413
|
+
if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) != '') {
|
|
414
414
|
var _findFields;
|
|
415
415
|
// @ts-ignore
|
|
416
416
|
itemRules.fields[index].fields[// @ts-ignore
|
|
@@ -419,7 +419,7 @@ item) {
|
|
|
419
419
|
}
|
|
420
420
|
} else {
|
|
421
421
|
var _formControl_props_dataBind;
|
|
422
|
-
if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) !=
|
|
422
|
+
if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) != '') {
|
|
423
423
|
var _formControl_props_dataBind1;
|
|
424
424
|
// @ts-ignore
|
|
425
425
|
itemRules.fields[index].fields[(_formControl_props_dataBind1 = formControl.props.dataBind) === null || _formControl_props_dataBind1 === void 0 ? void 0 : _formControl_props_dataBind1.fieldCode] = childResult;
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -45,9 +45,9 @@ function _object_spread(target) {
|
|
|
45
45
|
}
|
|
46
46
|
return target;
|
|
47
47
|
}
|
|
48
|
-
import { DataBind, isDataBind } from
|
|
49
|
-
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from
|
|
50
|
-
import { loopDataViewControl, loopFormControl, buildUUID } from
|
|
48
|
+
import { DataBind, isDataBind } from '@byteluck-fe/model-driven-core';
|
|
49
|
+
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
50
|
+
import { loopDataViewControl, loopFormControl, buildUUID } from '../utils/runtimeUtils';
|
|
51
51
|
var Store = /*#__PURE__*/ function() {
|
|
52
52
|
"use strict";
|
|
53
53
|
function Store(props) {
|
|
@@ -84,7 +84,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
84
84
|
value.forEach(function(item) {
|
|
85
85
|
if (!item.uid) {
|
|
86
86
|
Object.assign(item, {
|
|
87
|
-
uid:
|
|
87
|
+
uid: 'new:' + buildUUID('uid')
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
});
|
|
@@ -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;
|
|
@@ -347,7 +347,7 @@ item) {
|
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
} else {
|
|
350
|
-
if (item.props.datasourceBind.dataCode ===
|
|
350
|
+
if (item.props.datasourceBind.dataCode === '') {
|
|
351
351
|
//敏捷依赖后端生成dataCode,预览的时候没有
|
|
352
352
|
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item.id, " type:").concat(item.type));
|
|
353
353
|
return;
|
|
@@ -408,7 +408,7 @@ item) {
|
|
|
408
408
|
data[item.id] = {
|
|
409
409
|
dataBind: new DataBind({
|
|
410
410
|
dataCode: item.props.datasourceBind.dataCode,
|
|
411
|
-
fieldCode:
|
|
411
|
+
fieldCode: ''
|
|
412
412
|
}),
|
|
413
413
|
dataView: dataViewId,
|
|
414
414
|
children: {},
|