@byteluck-fe/model-driven-engine 2.22.2-beta.2 → 2.22.2-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/README.md +30 -30
- package/dist/esm/common/ActionManager.js +7 -7
- package/dist/esm/common/DataManager.js +2 -2
- package/dist/esm/common/Engine.js +127 -123
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +17 -17
- package/dist/esm/common/Store.js +13 -13
- package/dist/esm/common/checkerValue.js +22 -22
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +56 -52
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +61 -57
- 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 +10 -10
- 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 +25 -25
- package/dist/types/common/ActionManager.d.ts +14 -14
- package/dist/types/common/DataManager.d.ts +10 -10
- package/dist/types/common/Engine.d.ts +201 -201
- package/dist/types/common/OkWorker.d.ts +13 -13
- package/dist/types/common/Plugin.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +31 -31
- package/dist/types/common/Store.d.ts +54 -54
- package/dist/types/common/checkerValue.d.ts +3 -3
- package/dist/types/common/index.d.ts +2 -2
- package/dist/types/common/proxyState.d.ts +30 -30
- package/dist/types/index.d.ts +3 -3
- package/dist/types/plugins/CalcPlugin.d.ts +121 -121
- package/dist/types/plugins/ControlsEventPlugin.d.ts +17 -17
- package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +15 -15
- package/dist/types/plugins/StylePlugin.d.ts +13 -13
- package/dist/types/plugins/index.d.ts +5 -5
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/runtimeUtils.d.ts +5 -5
- package/package.json +4 -4
|
@@ -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
|
var _item_parent;
|
|
130
130
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
131
131
|
//4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
|
|
@@ -140,7 +140,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
140
140
|
instanceMap[item.id] = [];
|
|
141
141
|
}
|
|
142
142
|
//不知为何subtable-column会多存一次
|
|
143
|
-
if (item.type ===
|
|
143
|
+
if (item.type === 'subtable-column') {
|
|
144
144
|
if (instanceMap[item.id].length > 0) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
@@ -294,7 +294,7 @@ function loop(control, parentId, callback) {
|
|
|
294
294
|
// @ts-ignore
|
|
295
295
|
loop(ctl.children, ctl.id, callback);
|
|
296
296
|
}
|
|
297
|
-
if (hasHeaderOrFooterControl(item,
|
|
297
|
+
if (hasHeaderOrFooterControl(item, 'headers')) {
|
|
298
298
|
loop(item.props.headers, item.id, callback);
|
|
299
299
|
}
|
|
300
300
|
// if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
@@ -305,8 +305,8 @@ function loop(control, parentId, callback) {
|
|
|
305
305
|
function hasHeaderOrFooterControl(control, checkType) {
|
|
306
306
|
return checkType in control.props && isArray(control.props[checkType]);
|
|
307
307
|
}
|
|
308
|
-
/**
|
|
309
|
-
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
308
|
+
/**
|
|
309
|
+
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
310
310
|
* */ function getControlIsHide(control) {
|
|
311
311
|
if (control.props.isHide) {
|
|
312
312
|
return true;
|
|
@@ -331,7 +331,7 @@ item) {
|
|
|
331
331
|
// data[item.id] = item.rules
|
|
332
332
|
data[item.id] = result;
|
|
333
333
|
var itemRules = {
|
|
334
|
-
type:
|
|
334
|
+
type: 'array',
|
|
335
335
|
fields: {}
|
|
336
336
|
};
|
|
337
337
|
(isSubtableDefaultRules === true ? [
|
|
@@ -343,7 +343,7 @@ item) {
|
|
|
343
343
|
if (itemRules.fields) {
|
|
344
344
|
if (!itemRules.fields[index]) {
|
|
345
345
|
itemRules.fields[index] = {
|
|
346
|
-
type:
|
|
346
|
+
type: 'object',
|
|
347
347
|
required: true,
|
|
348
348
|
fields: {}
|
|
349
349
|
};
|
|
@@ -372,7 +372,7 @@ item) {
|
|
|
372
372
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
373
373
|
if (isDataBind(item.props.dataBind)) {
|
|
374
374
|
var _item_props_dataBind;
|
|
375
|
-
if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) !=
|
|
375
|
+
if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) != '') {
|
|
376
376
|
var _item_props_dataBind1;
|
|
377
377
|
data[(_item_props_dataBind1 = item.props.dataBind) === null || _item_props_dataBind1 === void 0 ? void 0 : _item_props_dataBind1.fieldCode] = result;
|
|
378
378
|
}
|
|
@@ -380,7 +380,7 @@ item) {
|
|
|
380
380
|
for(var dataBindKey in item.props.dataBind){
|
|
381
381
|
var _item_props_dataBind_dataBindKey;
|
|
382
382
|
// @ts-ignore
|
|
383
|
-
if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) !=
|
|
383
|
+
if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) != '') {
|
|
384
384
|
var // @ts-ignore
|
|
385
385
|
_item_props_dataBind_dataBindKey1, _findFields;
|
|
386
386
|
// @ts-ignore
|
|
@@ -392,7 +392,7 @@ item) {
|
|
|
392
392
|
var _item_props_datasourceBind, _item_props_datasourceBind1;
|
|
393
393
|
data[(_item_props_datasourceBind = item.props.datasourceBind) === null || _item_props_datasourceBind === void 0 ? void 0 : _item_props_datasourceBind.dataCode] = result;
|
|
394
394
|
var itemRules = {
|
|
395
|
-
type:
|
|
395
|
+
type: 'array',
|
|
396
396
|
fields: {}
|
|
397
397
|
};
|
|
398
398
|
(isSubtableDefaultRules === true ? [
|
|
@@ -404,7 +404,7 @@ item) {
|
|
|
404
404
|
if (itemRules.fields) {
|
|
405
405
|
if (!itemRules.fields[index]) {
|
|
406
406
|
itemRules.fields[index] = {
|
|
407
|
-
type:
|
|
407
|
+
type: 'object',
|
|
408
408
|
required: true,
|
|
409
409
|
fields: {}
|
|
410
410
|
};
|
|
@@ -414,7 +414,7 @@ item) {
|
|
|
414
414
|
for(var dataBindKey in formControl.props.dataBind){
|
|
415
415
|
var _formControl_props_dataBind_dataBindKey;
|
|
416
416
|
// @ts-ignore
|
|
417
|
-
if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) !=
|
|
417
|
+
if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) != '') {
|
|
418
418
|
var _findFields;
|
|
419
419
|
// @ts-ignore
|
|
420
420
|
itemRules.fields[index].fields[// @ts-ignore
|
|
@@ -423,7 +423,7 @@ item) {
|
|
|
423
423
|
}
|
|
424
424
|
} else {
|
|
425
425
|
var _formControl_props_dataBind;
|
|
426
|
-
if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) !=
|
|
426
|
+
if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) != '') {
|
|
427
427
|
var _formControl_props_dataBind1;
|
|
428
428
|
// @ts-ignore
|
|
429
429
|
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) {
|
|
@@ -69,10 +69,10 @@ var Store = /*#__PURE__*/ function() {
|
|
|
69
69
|
}
|
|
70
70
|
_create_class(Store, [
|
|
71
71
|
{
|
|
72
|
-
/**
|
|
73
|
-
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
74
|
-
* @param controlId 组件ID
|
|
75
|
-
* @param value
|
|
72
|
+
/**
|
|
73
|
+
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
74
|
+
* @param controlId 组件ID
|
|
75
|
+
* @param value
|
|
76
76
|
*/ key: "setState",
|
|
77
77
|
value: function setState(controlId, value, rowIndex) {
|
|
78
78
|
var _this = this;
|
|
@@ -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: {},
|
|
@@ -157,9 +157,9 @@ function _create_super(Derived) {
|
|
|
157
157
|
return _possible_constructor_return(this, result);
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
-
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from
|
|
161
|
-
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from
|
|
162
|
-
import { camelizeKeys } from
|
|
160
|
+
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from '@byteluck-fe/model-driven-shared';
|
|
161
|
+
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from '@byteluck-fe/model-driven-core';
|
|
162
|
+
import { camelizeKeys } from 'humps';
|
|
163
163
|
var ValueChecker = function ValueChecker() {
|
|
164
164
|
"use strict";
|
|
165
165
|
_class_call_check(this, ValueChecker);
|
|
@@ -183,7 +183,7 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
183
183
|
key: "transform",
|
|
184
184
|
value: function transform(value) {
|
|
185
185
|
if (value === null || value === undefined) {
|
|
186
|
-
return
|
|
186
|
+
return '';
|
|
187
187
|
}
|
|
188
188
|
if (!isPlainObject(value) && !isFunction(value)) {
|
|
189
189
|
return String(value);
|
|
@@ -210,14 +210,14 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
210
210
|
// 数字类型允许是空字符串,用于置空数据
|
|
211
211
|
key: "validate",
|
|
212
212
|
value: function validate(value) {
|
|
213
|
-
return isNumber(value) || value ===
|
|
213
|
+
return isNumber(value) || value === '';
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
key: "transform",
|
|
218
218
|
value: function transform(value) {
|
|
219
219
|
if (value === null || value === undefined) {
|
|
220
|
-
return
|
|
220
|
+
return '';
|
|
221
221
|
}
|
|
222
222
|
var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
|
|
223
223
|
if (!Number.isNaN(newValue) && newValue !== undefined) {
|
|
@@ -252,7 +252,7 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
252
252
|
}
|
|
253
253
|
function getStringValueArray(value) {
|
|
254
254
|
return value.map(function(item) {
|
|
255
|
-
return !item ?
|
|
255
|
+
return !item ? '' : String(item);
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
258
|
if (isArray(value)) {
|
|
@@ -297,9 +297,9 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
297
297
|
}
|
|
298
298
|
function getNumberValueArray(value) {
|
|
299
299
|
return value.map(function(item) {
|
|
300
|
-
return !item && item !== 0 ?
|
|
300
|
+
return !item && item !== 0 ? '' : Number(item);
|
|
301
301
|
}).filter(function(item) {
|
|
302
|
-
return item ===
|
|
302
|
+
return item === '' || !Number.isNaN(item);
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
305
|
if (isArray(value)) {
|
|
@@ -338,13 +338,13 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
338
338
|
key: "validate",
|
|
339
339
|
value: function validate(value) {
|
|
340
340
|
return(// value instanceof AmountValue ||
|
|
341
|
-
isPlainObject(value) &&
|
|
341
|
+
isPlainObject(value) && 'amount' in value && isNumber(value.amount) && 'currency' in value && isString(value.currency));
|
|
342
342
|
}
|
|
343
343
|
},
|
|
344
344
|
{
|
|
345
345
|
key: "transform",
|
|
346
346
|
value: function transform(value, oldValue) {
|
|
347
|
-
if (value === undefined || value === null || value ===
|
|
347
|
+
if (value === undefined || value === null || value === '') {
|
|
348
348
|
return new AmountValue({
|
|
349
349
|
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
350
350
|
});
|
|
@@ -389,13 +389,13 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
389
389
|
key: "validate",
|
|
390
390
|
value: function validate(value) {
|
|
391
391
|
return(// value instanceof RangeDateValue ||
|
|
392
|
-
isPlainObject(value) &&
|
|
392
|
+
isPlainObject(value) && 'min' in value && isString(value.min) && 'max' in value && isString(value.max));
|
|
393
393
|
}
|
|
394
394
|
},
|
|
395
395
|
{
|
|
396
396
|
key: "transform",
|
|
397
397
|
value: function transform(value, oldValue) {
|
|
398
|
-
if (value === undefined || value === null || value ===
|
|
398
|
+
if (value === undefined || value === null || value === '') {
|
|
399
399
|
return new RangeDateValue();
|
|
400
400
|
}
|
|
401
401
|
var result;
|
|
@@ -437,13 +437,13 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
437
437
|
key: "validate",
|
|
438
438
|
value: function validate(value) {
|
|
439
439
|
return(// value instanceof CalcValue ||
|
|
440
|
-
isPlainObject(value) &&
|
|
440
|
+
isPlainObject(value) && 'result' in value && isNumber(value.result) && 'unit' in value && isString(value.unit));
|
|
441
441
|
}
|
|
442
442
|
},
|
|
443
443
|
{
|
|
444
444
|
key: "transform",
|
|
445
445
|
value: function transform(value, oldValue) {
|
|
446
|
-
if (value === undefined || value === null || value ===
|
|
446
|
+
if (value === undefined || value === null || value === '') {
|
|
447
447
|
return new CalcValue({
|
|
448
448
|
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
449
449
|
});
|
|
@@ -504,7 +504,7 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
504
504
|
{
|
|
505
505
|
key: "transform",
|
|
506
506
|
value: function transform(value, oldValue) {
|
|
507
|
-
if (value === undefined || value === null || value ===
|
|
507
|
+
if (value === undefined || value === null || value === '') {
|
|
508
508
|
return new AddressValue();
|
|
509
509
|
}
|
|
510
510
|
var result;
|
|
@@ -588,15 +588,15 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
588
588
|
}();
|
|
589
589
|
function getFieldTypeFromKey(key) {
|
|
590
590
|
if ([
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
'min',
|
|
592
|
+
'max',
|
|
593
|
+
'currency',
|
|
594
|
+
'unit'
|
|
595
595
|
].includes(key)) {
|
|
596
596
|
return FieldTypes.VARCHAR;
|
|
597
597
|
} else if ([
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
'result',
|
|
599
|
+
'amount'
|
|
600
600
|
].includes(key)) {
|
|
601
601
|
return FieldTypes.DECIMAL;
|
|
602
602
|
}
|
package/dist/esm/common/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './Engine';
|
|
2
|
+
export * from './Plugin';
|
|
@@ -15,6 +15,10 @@ function _non_iterable_spread() {
|
|
|
15
15
|
function _to_consumable_array(arr) {
|
|
16
16
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
17
17
|
}
|
|
18
|
+
function _type_of(obj) {
|
|
19
|
+
"@swc/helpers - typeof";
|
|
20
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
21
|
+
}
|
|
18
22
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
19
23
|
if (!o) return;
|
|
20
24
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -24,21 +28,21 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
24
28
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
29
|
}
|
|
26
30
|
var cc = console;
|
|
27
|
-
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from
|
|
31
|
+
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from '@byteluck-fe/model-driven-shared';
|
|
28
32
|
var proxyArrayApi = [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
'splice',
|
|
34
|
+
'push',
|
|
35
|
+
'shift',
|
|
36
|
+
'pop',
|
|
37
|
+
'unshift',
|
|
38
|
+
'reverse'
|
|
35
39
|
];
|
|
36
|
-
export var engineProxyFlag = Symbol(
|
|
37
|
-
export var engineTargetKey = Symbol(
|
|
38
|
-
export var engineArrayBeforeSetCallbackFlag = Symbol(
|
|
39
|
-
export var engineProxyThisKey = Symbol(
|
|
40
|
+
export var engineProxyFlag = Symbol('__engineProxy__');
|
|
41
|
+
export var engineTargetKey = Symbol('__engineTarget__');
|
|
42
|
+
export var engineArrayBeforeSetCallbackFlag = Symbol('__engineArrayBeforeSetCallbackFlag__');
|
|
43
|
+
export var engineProxyThisKey = Symbol('__engineProxyThisKey__');
|
|
40
44
|
var currentHandlerState = {
|
|
41
|
-
type:
|
|
45
|
+
type: '',
|
|
42
46
|
args: [],
|
|
43
47
|
callback: emptyFn
|
|
44
48
|
};
|
|
@@ -55,16 +59,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
55
59
|
// 操作下标
|
|
56
60
|
// Number(propertyKey) > target.length 说明当前操作的下标已经超过了安全范围(数组的运行长度,比如[1,2,3],它的长度为3,可操作的下标为0,1,2,3,如果操作4将会产生一个empty index)
|
|
57
61
|
if (index > target.length) {
|
|
58
|
-
error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(
|
|
62
|
+
error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(','), " for array operations"));
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
// 不是操作下标,而是直接操作length或者自定义属性等
|
|
62
66
|
var isNotHandlerIndex = Number.isNaN(index);
|
|
63
|
-
if (isNotHandlerIndex && propertyKey !==
|
|
67
|
+
if (isNotHandlerIndex && propertyKey !== 'length') {
|
|
64
68
|
return;
|
|
65
69
|
}
|
|
66
70
|
// 直接操作length
|
|
67
|
-
if (propertyKey ===
|
|
71
|
+
if (propertyKey === 'length') {
|
|
68
72
|
var newLength = value;
|
|
69
73
|
var oldLength = target.length;
|
|
70
74
|
if (newLength > target.length) {
|
|
@@ -76,7 +80,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
76
80
|
}
|
|
77
81
|
// 通过操作length删除旧的行
|
|
78
82
|
return function() {
|
|
79
|
-
return callback.call(null, target, thisKey,
|
|
83
|
+
return callback.call(null, target, thisKey, 'splice', [
|
|
80
84
|
newLength,
|
|
81
85
|
oldLength - newLength
|
|
82
86
|
]);
|
|
@@ -86,13 +90,13 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
86
90
|
// 正常操作
|
|
87
91
|
if (index === target.length) {
|
|
88
92
|
return function() {
|
|
89
|
-
return callback.call(null, target, thisKey,
|
|
93
|
+
return callback.call(null, target, thisKey, 'push', [
|
|
90
94
|
value
|
|
91
95
|
]);
|
|
92
96
|
};
|
|
93
97
|
} else {
|
|
94
98
|
return function() {
|
|
95
|
-
return callback.call(null, target, thisKey,
|
|
99
|
+
return callback.call(null, target, thisKey, 'splice', [
|
|
96
100
|
index,
|
|
97
101
|
1,
|
|
98
102
|
value
|
|
@@ -101,11 +105,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
|
-
/**
|
|
105
|
-
* 返回proxy操作对象
|
|
106
|
-
* @param thisKey 当前对象在上级中的key
|
|
107
|
-
* @param callback 需要在修改的时候,触发的回调函数
|
|
108
|
-
* @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
|
|
108
|
+
/**
|
|
109
|
+
* 返回proxy操作对象
|
|
110
|
+
* @param thisKey 当前对象在上级中的key
|
|
111
|
+
* @param callback 需要在修改的时候,触发的回调函数
|
|
112
|
+
* @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
|
|
109
113
|
* */ function handler(thisKey, callback, beforeSetCallback) {
|
|
110
114
|
return {
|
|
111
115
|
__engineProxy__: true,
|
|
@@ -128,9 +132,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
128
132
|
var newValue = JSONCopy(value);
|
|
129
133
|
// @ts-ignore
|
|
130
134
|
var oldValue = target[propertyKey];
|
|
131
|
-
var concatKey = thisKey ===
|
|
135
|
+
var concatKey = thisKey === '' ? propertyKey : thisKey + '.' + propertyKey;
|
|
132
136
|
function reProxyState(value) {
|
|
133
|
-
if (typeof value === "
|
|
137
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value !== null) {
|
|
134
138
|
// @ts-ignore
|
|
135
139
|
if (value[engineProxyFlag] !== true) {
|
|
136
140
|
return proxyState(value, callback, beforeSetCallback, concatKey);
|
|
@@ -179,22 +183,22 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
179
183
|
}
|
|
180
184
|
};
|
|
181
185
|
}
|
|
182
|
-
/**
|
|
183
|
-
* 代理state数据
|
|
184
|
-
* @param state 数据对象
|
|
185
|
-
* @param callback 触发set时候的回调函数
|
|
186
|
-
* @param beforeSetCallback
|
|
187
|
-
* @param prevKey 递归对象的key
|
|
186
|
+
/**
|
|
187
|
+
* 代理state数据
|
|
188
|
+
* @param state 数据对象
|
|
189
|
+
* @param callback 触发set时候的回调函数
|
|
190
|
+
* @param beforeSetCallback
|
|
191
|
+
* @param prevKey 递归对象的key
|
|
188
192
|
* */ export function proxyState(state, callback, beforeSetCallback) {
|
|
189
|
-
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] :
|
|
193
|
+
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : '';
|
|
190
194
|
// 冻结的对象不需要再执行proxy,否则会报错
|
|
191
195
|
if (Object.isFrozen(state)) {
|
|
192
196
|
return state;
|
|
193
197
|
}
|
|
194
198
|
for(var key in state){
|
|
195
|
-
var concatKey = prevKey ===
|
|
199
|
+
var concatKey = prevKey === '' ? key : prevKey + '.' + key;
|
|
196
200
|
var obj = state[key];
|
|
197
|
-
if (typeof obj === "
|
|
201
|
+
if ((typeof obj === "undefined" ? "undefined" : _type_of(obj)) === 'object' && obj !== null) {
|
|
198
202
|
// @ts-ignore
|
|
199
203
|
state[key] = proxyState(obj, callback, beforeSetCallback, concatKey);
|
|
200
204
|
}
|
|
@@ -205,20 +209,20 @@ function flatInstanceForChildren(controls) {
|
|
|
205
209
|
var result = [];
|
|
206
210
|
controls.forEach(function(item) {
|
|
207
211
|
result.push(item);
|
|
208
|
-
if (item.controlType ===
|
|
212
|
+
if (item.controlType === 'layout' || item.controlType === 'wrap') {
|
|
209
213
|
var _result;
|
|
210
214
|
(_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
|
|
211
215
|
}
|
|
212
216
|
});
|
|
213
217
|
return result;
|
|
214
218
|
}
|
|
215
|
-
/**
|
|
216
|
-
* 在flatInstance中通过key查找出对应的instance
|
|
217
|
-
* @param flatInstance 拍平的instance数组
|
|
218
|
-
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
219
|
+
/**
|
|
220
|
+
* 在flatInstance中通过key查找出对应的instance
|
|
221
|
+
* @param flatInstance 拍平的instance数组
|
|
222
|
+
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
219
223
|
* */ export function findItem(flatInstance, key, instanceMap) {
|
|
220
|
-
if (key ===
|
|
221
|
-
var keys = key.split(
|
|
224
|
+
if (key === '') return undefined;
|
|
225
|
+
var keys = key.split('.');
|
|
222
226
|
if (keys.length === 0) return undefined;
|
|
223
227
|
var oneKey = keys[0];
|
|
224
228
|
var otherKeys = keys.slice(1);
|
|
@@ -253,28 +257,28 @@ function flatInstanceForChildren(controls) {
|
|
|
253
257
|
}
|
|
254
258
|
function getArrayNewValue(type, args) {
|
|
255
259
|
if ([
|
|
256
|
-
|
|
257
|
-
|
|
260
|
+
'push',
|
|
261
|
+
'unshift'
|
|
258
262
|
].includes(type)) {
|
|
259
263
|
return args;
|
|
260
|
-
} else if (type ===
|
|
264
|
+
} else if (type === 'splice') {
|
|
261
265
|
return args.slice(2);
|
|
262
266
|
}
|
|
263
267
|
return [];
|
|
264
268
|
}
|
|
265
269
|
function getArrayNewArgs(type, args, value) {
|
|
266
270
|
if ([
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
'push',
|
|
272
|
+
'unshift'
|
|
269
273
|
].includes(type)) {
|
|
270
274
|
return value;
|
|
271
|
-
} else if (type ===
|
|
275
|
+
} else if (type === 'splice') {
|
|
272
276
|
return args.slice(0, 2).concat(value);
|
|
273
277
|
}
|
|
274
278
|
}
|
|
275
|
-
/**
|
|
276
|
-
* TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
|
|
277
|
-
* 劫持数组api,达到操作数组api的时候,可以同步操作instance
|
|
279
|
+
/**
|
|
280
|
+
* TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
|
|
281
|
+
* 劫持数组api,达到操作数组api的时候,可以同步操作instance
|
|
278
282
|
* */ function hijackArrayProperty() {
|
|
279
283
|
proxyArrayApi.forEach(function(key) {
|
|
280
284
|
var oldApiHandler = Array.prototype[key];
|
|
@@ -303,8 +307,8 @@ function getArrayNewArgs(type, args, value) {
|
|
|
303
307
|
// @ts-ignore
|
|
304
308
|
result = oldApiHandler.apply(this, args);
|
|
305
309
|
}
|
|
306
|
-
typeof currentHandlerState.callback ===
|
|
307
|
-
currentHandlerState.type =
|
|
310
|
+
typeof currentHandlerState.callback === 'function' && currentHandlerState.callback(key, args, result);
|
|
311
|
+
currentHandlerState.type = '';
|
|
308
312
|
currentHandlerState.args = [];
|
|
309
313
|
currentHandlerState.callback = emptyFn;
|
|
310
314
|
return result;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './plugins';
|
|
3
|
+
export * from './utils';
|