@byteluck-fe/model-driven-engine 2.7.0-beta → 2.8.0-alpha.1

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.
@@ -111,13 +111,6 @@ function _inherits(subClass, superClass) {
111
111
  });
112
112
  if (superClass) _set_prototype_of(subClass, superClass);
113
113
  }
114
- function _instanceof(left, right) {
115
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
116
- return !!right[Symbol.hasInstance](left);
117
- } else {
118
- return left instanceof right;
119
- }
120
- }
121
114
  function _iterable_to_array(iter) {
122
115
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
123
116
  }
@@ -347,8 +340,8 @@ function _ts_generator(thisArg, body) {
347
340
  };
348
341
  }
349
342
  }
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";
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";
352
345
  import { Runtime } from "./Runtime";
353
346
  import { Store } from "./Store";
354
347
  import { findItem, proxyState } from "./proxyState";
@@ -481,7 +474,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
481
474
  }
482
475
  // @ts-ignore
483
476
  if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
484
- var _newValue;
485
477
  if (newValue === null) {
486
478
  return [];
487
479
  }
@@ -496,7 +488,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
496
488
  }, {});
497
489
  // @ts-ignore
498
490
  var emptyState = this.getEmptyState(instance.id);
499
- return (_newValue = newValue) === null || _newValue === void 0 ? void 0 : _newValue.map(function(row) {
491
+ return newValue === null || newValue === void 0 ? void 0 : newValue.map(function(row) {
500
492
  return(// @ts-ignore
501
493
  checkerSubtableValue(fieldTypeMap, row, emptyState));
502
494
  });
@@ -526,7 +518,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
526
518
  value: function _handlerArrayUpdate(state, key, type, args, result) {
527
519
  var _this = this;
528
520
  var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
529
- if (!_instanceof(subtable, RuntimeListControl)) return;
521
+ // if (!(subtable instanceof RuntimeListControl)) return
522
+ if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
530
523
  // 新增多行方法
531
524
  var createRows = function(len) {
532
525
  // @ts-ignore
@@ -544,6 +537,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
544
537
  var createdNewRows = [];
545
538
  var createdNewRowsData = [];
546
539
  var deleted = [];
540
+ var isDeleteLastOne = false;
547
541
  if (type && args) {
548
542
  // const subtableOldLength = subtable.children.length
549
543
  switch(type){
@@ -580,6 +574,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
580
574
  } else {
581
575
  var // @ts-ignore
582
576
  _subtable_children2;
577
+ // 从哪儿开始
578
+ var start1 = args[0];
579
+ // 替换几个
580
+ var replace1 = args[1];
581
+ if (start1 + replace1 === subtable.children.length - 1) {
582
+ isDeleteLastOne = true;
583
+ }
583
584
  (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
584
585
  this.runtime.getFlatInstances();
585
586
  }
@@ -608,7 +609,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
608
609
  changed: createdNewRows,
609
610
  data: createdNewRowsData,
610
611
  deleted: deleted !== null && deleted !== void 0 ? deleted : [],
611
- jsonValue: JSON.stringify(this.getState(subtable.id))
612
+ jsonValue: JSON.stringify(this.getState(subtable.id)),
613
+ isDeleteLastOne: isDeleteLastOne,
614
+ type: type,
615
+ args: args
612
616
  })
613
617
  });
614
618
  // 主动清空本次任务中的options
@@ -651,7 +655,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
651
655
  // @ts-ignore
652
656
  changed: newRows,
653
657
  data: newValue,
654
- deleted: oldValue !== null && oldValue !== void 0 ? oldValue : []
658
+ deleted: oldValue !== null && oldValue !== void 0 ? oldValue : [],
659
+ type: "push"
655
660
  })
656
661
  });
657
662
  } else {
@@ -946,7 +951,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
946
951
  }
947
952
  var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
948
953
  var state = this.getState(controlId1, rowIndex);
949
- if (_instanceof(dataBind, ObjectDataBind)) {
954
+ //if (dataBind instanceof ObjectDataBind) {
955
+ if (!isDataBind(dataBind)) {
950
956
  return Object.entries(dataBind).reduce(function(result, param) {
951
957
  var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
952
958
  // objectDataBind的元素,跳过下一次赋值
@@ -1053,7 +1059,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1053
1059
  return;
1054
1060
  }
1055
1061
  var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
1056
- if (_instanceof(dataBind, ObjectDataBind)) {
1062
+ // if (dataBind instanceof ObjectDataBind) {
1063
+ if (!isDataBind(dataBind)) {
1057
1064
  var _JSONCopy;
1058
1065
  var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
1059
1066
  // fieldCode不代表是key,所以需要找到对应的key
@@ -1095,7 +1102,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1095
1102
  return;
1096
1103
  }
1097
1104
  // 对象类型的值
1098
- if (_instanceof(dataBind, ObjectDataBind)) {
1105
+ // if (dataBind instanceof ObjectDataBind) {
1106
+ if (!isDataBind(dataBind)) {
1099
1107
  var _JSONCopy;
1100
1108
  var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
1101
1109
  // fieldCode不代表是key,所以需要找到对应的key
@@ -1139,7 +1147,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1139
1147
  return;
1140
1148
  }
1141
1149
  // 对象类型的值
1142
- if (_instanceof(dataBind, ObjectDataBind)) {
1150
+ // if (dataBind instanceof ObjectDataBind) {
1151
+ if (!isDataBind(dataBind)) {
1143
1152
  var oldState = _this.getEmptyState(controlId);
1144
1153
  // fieldCode不代表是key,所以需要找到对应的key
1145
1154
  result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
@@ -1198,9 +1207,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1198
1207
  return i.fieldCode === fieldCode;
1199
1208
  });
1200
1209
  if (fieldMapping) {
1201
- if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
1210
+ if (// fieldMapping.dataBind instanceof DataBind &&
1211
+ isDataBind(fieldMapping.dataBind) && row[fieldCode] !== undefined) {
1202
1212
  newRow[fieldMapping.controlId] = row[fieldCode];
1203
- } else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
1213
+ // } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
1214
+ } else if (!isDataBind(fieldMapping.dataBind)) {
1204
1215
  var _this_getEmptyState;
1205
1216
  var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
1206
1217
  Object.keys(fieldMapping.dataBind).map(function(key) {
@@ -1233,9 +1244,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1233
1244
  if (!newState[mapping.dataViewId[0]]) {
1234
1245
  newState[mapping.dataViewId[0]] = {};
1235
1246
  }
1236
- if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
1247
+ if (// mapping.dataBind instanceof DataBind &&
1248
+ isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
1237
1249
  newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1238
- } else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
1250
+ // } else if (mapping.dataBind instanceof ObjectDataBind) {
1251
+ } else if (!isDataBind(mapping.dataBind)) {
1239
1252
  var _this_getEmptyState;
1240
1253
  var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
1241
1254
  Object.keys(mapping.dataBind).map(function(key) {
@@ -1252,20 +1265,17 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1252
1265
  }
1253
1266
  var newMapping = _this.getDataBindMapping(dataCode);
1254
1267
  if (newMapping) {
1255
- var _newMapping_fields, _newMapping, _newMapping1, _newMapping2, _newState, _mappingKeys;
1256
- var mappingKeys = (_newMapping = newMapping) === null || _newMapping === void 0 ? void 0 : (_newMapping_fields = _newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
1257
- var _item;
1258
- return (_item = item) === null || _item === void 0 ? void 0 : _item.controlId;
1268
+ var _newMapping_fields;
1269
+ var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (_newMapping_fields = newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
1270
+ return item === null || item === void 0 ? void 0 : item.controlId;
1259
1271
  });
1260
- var mappingValue = _this.getEmptyState((_newMapping1 = newMapping) === null || _newMapping1 === void 0 ? void 0 : _newMapping1.controlId);
1272
+ var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
1261
1273
  var _newState_newMapping_controlId;
1262
- var mainStateKeys = Object.keys((_newState_newMapping_controlId = (_newState = newState) === null || _newState === void 0 ? void 0 : _newState[(_newMapping2 = newMapping) === null || _newMapping2 === void 0 ? void 0 : _newMapping2.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
1263
- (_mappingKeys = mappingKeys) === null || _mappingKeys === void 0 ? void 0 : _mappingKeys.forEach(function(key) {
1264
- var _newMapping;
1265
- if (!mainStateKeys.includes(key) && key !== "uid" && newState[(_newMapping = newMapping) === null || _newMapping === void 0 ? void 0 : _newMapping.controlId]) {
1274
+ 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 : {});
1275
+ mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
1276
+ if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1266
1277
  if (Object.keys(newState).length) {
1267
- var _newMapping1;
1268
- Object.assign(newState[(_newMapping1 = newMapping) === null || _newMapping1 === void 0 ? void 0 : _newMapping1.controlId], _define_property({}, key, mappingValue[key]));
1278
+ Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
1269
1279
  } else {
1270
1280
  Object.assign(newState, _define_property({}, newMapping.controlId, _define_property({}, key, mappingValue[key])));
1271
1281
  }
@@ -1331,6 +1341,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1331
1341
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1332
1342
  if (instances.length) {
1333
1343
  var instance = instances[0];
1344
+ // if (this.inList(instance.id) === true) {
1334
1345
  if (this.inList(instance.id) !== undefined) {
1335
1346
  var headerInstance = this.getInstanceInSubtableHeader(instance);
1336
1347
  if (headerInstance) {
@@ -1468,6 +1479,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1468
1479
  return isString(types) ? instance.type === types : types.includes(instance.type);
1469
1480
  }
1470
1481
  },
1482
+ {
1483
+ key: "assertInstanceIsCustomControl",
1484
+ value: /**
1485
+ * 判断控件或控件类型是一个自定义控件
1486
+ * */ function assertInstanceIsCustomControl(instance) {
1487
+ return !isBuiltInControls(isString(instance) ? instance : instance.type);
1488
+ }
1489
+ },
1471
1490
  {
1472
1491
  key: "getInstanceRowIndex",
1473
1492
  value: /**
@@ -1503,7 +1522,27 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1503
1522
  },
1504
1523
  {
1505
1524
  key: "getInstanceParentControl",
1506
- value: function getInstanceParentControl(instance, controlType) {
1525
+ value: // public getInstanceRowIndex(
1526
+ // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1527
+ // ) {
1528
+ // let rowIndex: number | undefined
1529
+ // // @ts-ignore
1530
+ // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1531
+ // rowIndex = -1
1532
+ // }else{
1533
+ // const instanceList = this.runtime.instanceMap[instance.id]
1534
+ // if(Object.prototype.toString.call(instanceList) === '[object Array]'){
1535
+ // const index = instanceList.findIndex(
1536
+ // (item: any) => item === instance
1537
+ // )
1538
+ // if (index > -1) {
1539
+ // rowIndex = index
1540
+ // }
1541
+ // }
1542
+ // }
1543
+ // return rowIndex
1544
+ // }
1545
+ function getInstanceParentControl(instance, controlType) {
1507
1546
  if (!instance.parent) {
1508
1547
  return;
1509
1548
  }
@@ -77,7 +77,9 @@ var OkWorker = /*#__PURE__*/ function() {
77
77
  key: "createWorkerFunction",
78
78
  value: function createWorkerFunction() {
79
79
  return function() {
80
- var createHandler = function createHandler(parentKey) {
80
+ log("‍\uD83D\uDE80 worker running");
81
+ var _self = self;
82
+ function createHandler(parentKey) {
81
83
  return {
82
84
  get: function get(target, key, value) {
83
85
  return Reflect.get(target, key, value);
@@ -92,9 +94,7 @@ var OkWorker = /*#__PURE__*/ function() {
92
94
  return Reflect.set(target, key, value);
93
95
  }
94
96
  };
95
- };
96
- log("‍\uD83D\uDE80 worker running");
97
- var _self = self;
97
+ }
98
98
  // function createProxy(
99
99
  // obj: Record<string, unknown> | Array<Record<string, unknown>>,
100
100
  // parentKey?: string
@@ -234,8 +234,12 @@ function loop(control, callback) {
234
234
  control.map(function(item) {
235
235
  callback(item);
236
236
  if (hasChildrenControl(item)) {
237
+ var ctl = item;
238
+ if (!ctl.children) {
239
+ ctl.children = [];
240
+ }
237
241
  // @ts-ignore
238
- loop(item.children, callback);
242
+ loop(ctl.children, callback);
239
243
  }
240
244
  });
241
245
  } else {
@@ -30,13 +30,6 @@ function _define_property(obj, key, value) {
30
30
  }
31
31
  return obj;
32
32
  }
33
- function _instanceof(left, right) {
34
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
35
- return !!right[Symbol.hasInstance](left);
36
- } else {
37
- return left instanceof right;
38
- }
39
- }
40
33
  function _object_spread(target) {
41
34
  for(var i = 1; i < arguments.length; i++){
42
35
  var source = arguments[i] != null ? arguments[i] : {};
@@ -52,7 +45,7 @@ function _object_spread(target) {
52
45
  }
53
46
  return target;
54
47
  }
55
- import { DataBind, ObjectDataBind } from "@byteluck-fe/model-driven-core";
48
+ import { DataBind, isDataBind } from "@byteluck-fe/model-driven-core";
56
49
  import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from "@byteluck-fe/model-driven-shared";
57
50
  import { loopDataViewControl, loopFormControl, buildUUID } from "../utils/runtimeUtils";
58
51
  var Store = /*#__PURE__*/ function() {
@@ -82,10 +75,9 @@ var Store = /*#__PURE__*/ function() {
82
75
  value: function setState(controlId, value, rowIndex) {
83
76
  var _this = this;
84
77
  var controlInfo = this.controlIdMapping[controlId];
85
- var noProxyValue = JSONCopy(value);
86
78
  if (controlInfo !== undefined) {
87
79
  //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
88
- this.state[controlInfo.dataView][controlId] = noProxyValue;
80
+ this.state[controlInfo.dataView][controlId] = value;
89
81
  // if (
90
82
  // controlInfo.dataBind instanceof ObjectDataBind &&
91
83
  // isPlainObject(value)
@@ -104,7 +96,7 @@ var Store = /*#__PURE__*/ function() {
104
96
  Object.keys(children).map(function(childControlId) {
105
97
  if (childControlId === controlId) {
106
98
  if (_this.state[dataView][subtableId][rowIndex]) {
107
- _this.state[dataView][subtableId][rowIndex][controlId] = noProxyValue;
99
+ _this.state[dataView][subtableId][rowIndex][controlId] = value;
108
100
  }
109
101
  }
110
102
  });
@@ -112,7 +104,7 @@ var Store = /*#__PURE__*/ function() {
112
104
  });
113
105
  } else {
114
106
  //不存在的 controlId,直接被挂载到外部key
115
- this.state[controlId] = noProxyValue;
107
+ this.state[controlId] = value;
116
108
  }
117
109
  }
118
110
  }
@@ -208,7 +200,6 @@ var Store = /*#__PURE__*/ function() {
208
200
  {
209
201
  key: "getDataBind",
210
202
  value: function getDataBind(controlId) {
211
- var _result;
212
203
  var result = this.controlIdMapping[controlId];
213
204
  if (result) {
214
205
  return result.dataBind;
@@ -224,7 +215,7 @@ var Store = /*#__PURE__*/ function() {
224
215
  }
225
216
  }
226
217
  }
227
- return (_result = result) === null || _result === void 0 ? void 0 : _result.dataBind;
218
+ return result === null || result === void 0 ? void 0 : result.dataBind;
228
219
  }
229
220
  }
230
221
  ]);
@@ -289,7 +280,8 @@ item) {
289
280
  // if (item instanceof RuntimeFormControl) {
290
281
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
291
282
  var _item_props_dataBind, _item_props;
292
- if (_instanceof(item.props.dataBind, ObjectDataBind)) {
283
+ // if (item.props.dataBind instanceof ObjectDataBind) {
284
+ if (!isDataBind(item.props.dataBind)) {
293
285
  // 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
294
286
  Object.keys(item.props.dataBind).map(function(key) {
295
287
  var dataBind = item.props.dataBind;
@@ -344,7 +336,8 @@ item) {
344
336
  };
345
337
  var subtableId = item.id;
346
338
  loopFormSchema(item.props.headers, function(item) {
347
- if (_instanceof(item.props.dataBind, ObjectDataBind)) {
339
+ // if (item.props.dataBind instanceof ObjectDataBind) {
340
+ if (!isDataBind(item.props.dataBind)) {
348
341
  Object.keys(item.props.dataBind).map(function(key) {
349
342
  var dataBind = item.props.dataBind;
350
343
  var dataCode = dataBind[key].dataCode;
@@ -63,13 +63,6 @@ function _inherits(subClass, superClass) {
63
63
  });
64
64
  if (superClass) _set_prototype_of(subClass, superClass);
65
65
  }
66
- function _instanceof(left, right) {
67
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
68
- return !!right[Symbol.hasInstance](left);
69
- } else {
70
- return left instanceof right;
71
- }
72
- }
73
66
  function _iterable_to_array_limit(arr, i) {
74
67
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
75
68
  if (_i == null) return;
@@ -254,13 +247,13 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
254
247
  {
255
248
  key: "transform",
256
249
  value: function transform(value) {
257
- var getStringValueArray = function getStringValueArray(value) {
250
+ if (value === undefined || value === null) {
251
+ return [];
252
+ }
253
+ function getStringValueArray(value) {
258
254
  return value.map(function(item) {
259
255
  return !item ? "" : String(item);
260
256
  });
261
- };
262
- if (value === undefined || value === null) {
263
- return [];
264
257
  }
265
258
  if (isArray(value)) {
266
259
  return getStringValueArray(value);
@@ -299,15 +292,15 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
299
292
  {
300
293
  key: "transform",
301
294
  value: function transform(value) {
302
- var getNumberValueArray = function getNumberValueArray(value) {
295
+ if (value === undefined || value === null) {
296
+ return [];
297
+ }
298
+ function getNumberValueArray(value) {
303
299
  return value.map(function(item) {
304
300
  return !item && item !== 0 ? "" : Number(item);
305
301
  }).filter(function(item) {
306
302
  return item === "" || !Number.isNaN(item);
307
303
  });
308
- };
309
- if (value === undefined || value === null) {
310
- return [];
311
304
  }
312
305
  if (isArray(value)) {
313
306
  return getNumberValueArray(value);
@@ -344,16 +337,16 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
344
337
  {
345
338
  key: "validate",
346
339
  value: function validate(value) {
347
- return _instanceof(value, AmountValue) || isPlainObject(value) && "amount" in value && isNumber(value.amount) && "currency" in value && isString(value.currency);
340
+ return(// value instanceof AmountValue ||
341
+ isPlainObject(value) && "amount" in value && isNumber(value.amount) && "currency" in value && isString(value.currency));
348
342
  }
349
343
  },
350
344
  {
351
345
  key: "transform",
352
346
  value: function transform(value, oldValue) {
353
347
  if (value === undefined || value === null || value === "") {
354
- var _oldValue;
355
348
  return new AmountValue({
356
- currency: (_oldValue = oldValue) === null || _oldValue === void 0 ? void 0 : _oldValue.currency
349
+ currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
357
350
  });
358
351
  }
359
352
  var result;
@@ -395,7 +388,8 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
395
388
  {
396
389
  key: "validate",
397
390
  value: function validate(value) {
398
- return _instanceof(value, RangeDateValue) || isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max);
391
+ return(// value instanceof RangeDateValue ||
392
+ isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max));
399
393
  }
400
394
  },
401
395
  {
@@ -442,16 +436,16 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
442
436
  {
443
437
  key: "validate",
444
438
  value: function validate(value) {
445
- return _instanceof(value, CalcValue) || isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit);
439
+ return(// value instanceof CalcValue ||
440
+ isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit));
446
441
  }
447
442
  },
448
443
  {
449
444
  key: "transform",
450
445
  value: function transform(value, oldValue) {
451
446
  if (value === undefined || value === null || value === "") {
452
- var _oldValue;
453
447
  return new CalcValue({
454
- unit: (_oldValue = oldValue) === null || _oldValue === void 0 ? void 0 : _oldValue.unit
448
+ unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
455
449
  });
456
450
  }
457
451
  var result;
@@ -493,7 +487,18 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
493
487
  {
494
488
  key: "validate",
495
489
  value: function validate(value) {
496
- return _instanceof(value, AddressValue);
490
+ // return value instanceof AddressValue
491
+ if (isPlainObject(value)) {
492
+ // city?: string;
493
+ // cityDisplay?: string;
494
+ // district?: string;
495
+ // districtDisplay?: string;
496
+ // province?: string;
497
+ // provinceDisplay?: string
498
+ return true;
499
+ } else {
500
+ return false;
501
+ }
497
502
  }
498
503
  },
499
504
  {
@@ -24,7 +24,7 @@ function _unsupported_iterable_to_array(o, minLen) {
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
26
  var cc = console;
27
- import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from "@byteluck-fe/model-driven-shared";
27
+ import { CONTROL_BASE_TYPE, error, logerror } from "@byteluck-fe/model-driven-shared";
28
28
  var proxyArrayApi = [
29
29
  "splice",
30
30
  "push",
@@ -125,7 +125,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
125
125
  return Reflect.get(target, propertyKey, receiver);
126
126
  },
127
127
  set: function set(target, propertyKey, value, receiver) {
128
- var reProxyState = function reProxyState(value) {
128
+ var newValue = value;
129
+ // @ts-ignore
130
+ var oldValue = target[propertyKey];
131
+ var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
132
+ function reProxyState(value) {
129
133
  if (typeof value === "object" && value !== null) {
130
134
  // @ts-ignore
131
135
  if (value[engineProxyFlag] !== true) {
@@ -136,20 +140,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
136
140
  value[engineTargetKey], callback, beforeSetCallback, concatKey);
137
141
  }
138
142
  }
139
- };
140
- var newValue = JSONCopy(value);
141
- // @ts-ignore
142
- var oldValue = target[propertyKey];
143
- var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
143
+ }
144
144
  var _reProxyState;
145
- newValue = (_reProxyState = reProxyState(newValue)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
145
+ newValue = (_reProxyState = reProxyState(value)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
146
146
  // 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
147
147
  var setResult;
148
148
  // TODO 数组拦截操作需要重构,优化现有逻辑
149
149
  // TODO 直接操作下标改动明细表时,没有对行数据进行checker
150
150
  if (Array.isArray(target)) {
151
151
  // 操作数组的时候,不需要使用拼接的thisKey,先判断执行的是否是违规操作,违规操作的话会报错,不允许继续执行,正常操作的话,返回一个回调函数,用于在值修改完之后触发
152
- var nextHandler = ArrayHandler(target, propertyKey, newValue, thisKey, callback);
152
+ var nextHandler = ArrayHandler(target, propertyKey, value, thisKey, callback);
153
153
  setResult = Reflect.set(target, propertyKey, newValue, receiver);
154
154
  if (nextHandler) {
155
155
  nextHandler();
@@ -171,7 +171,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
171
171
  return true;
172
172
  }
173
173
  setResult = Reflect.set(target, propertyKey, newValue, receiver);
174
- callback.call(null, target, concatKey, newValue, oldValue);
174
+ callback.call(null, target, concatKey, value, oldValue);
175
175
  }
176
176
  // 不返回falsy 值(即 false、0、null、undefined、空字符串等)
177
177
  //fix: TypeError: Proxy object's 'set' trap returned falsy value for property 'length'
@@ -205,7 +205,7 @@ function flatInstanceForChildren(controls) {
205
205
  var result = [];
206
206
  controls.forEach(function(item) {
207
207
  result.push(item);
208
- if (item.controlType === "layout") {
208
+ if (item.controlType === "layout" || item.controlType === "wrap") {
209
209
  var _result;
210
210
  (_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
211
211
  }
@@ -237,18 +237,17 @@ function flatInstanceForChildren(controls) {
237
237
  var index = Number(key);
238
238
  var isNotIndex = Number.isNaN(index);
239
239
  if (isNotIndex && prevItem) {
240
- var _prevItem, _flatChildren;
241
- var flatChildren = ((_prevItem = prevItem) === null || _prevItem === void 0 ? void 0 : _prevItem.children) ? flatInstanceForChildren(prevItem.children) : undefined;
242
- var findEndItem = (_flatChildren = flatChildren) === null || _flatChildren === void 0 ? void 0 : _flatChildren.find(function(item) {
240
+ var flatChildren = (prevItem === null || prevItem === void 0 ? void 0 : prevItem.children) ? flatInstanceForChildren(prevItem.children) : undefined;
241
+ var findEndItem = flatChildren === null || flatChildren === void 0 ? void 0 : flatChildren.find(function(item) {
243
242
  return item.id === key;
244
243
  });
245
244
  // 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
246
245
  return findEndItem ? findEndItem : prevItem.controlType === CONTROL_BASE_TYPE.FORM ? prevItem : undefined;
247
246
  } else {
248
- var _prevItem_children, _prevItem1;
247
+ var _prevItem_children;
249
248
  var _prevItem_children_index;
250
249
  // 如果有children,则取children中对应的下标,没有的话一直返回prevItem
251
- return (_prevItem_children_index = (_prevItem1 = prevItem) === null || _prevItem1 === void 0 ? void 0 : (_prevItem_children = _prevItem1.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _prevItem_children_index !== void 0 ? _prevItem_children_index : prevItem;
250
+ return (_prevItem_children_index = prevItem === null || prevItem === void 0 ? void 0 : (_prevItem_children = prevItem.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _prevItem_children_index !== void 0 ? _prevItem_children_index : prevItem;
252
251
  }
253
252
  }, initInstance);
254
253
  }