@byteluck-fe/model-driven-driven 2.7.0-alpha.1 → 2.7.0-alpha.11

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.
@@ -1,2 +1,2 @@
1
- import { EventLogic } from "@byteluck-fe/model-driven-shared";
1
+ import { EventLogic } from '@byteluck-fe/model-driven-shared';
2
2
  export default EventLogic;
package/dist/esm/Store.js CHANGED
@@ -28,13 +28,6 @@ function _createClass(Constructor, protoProps, staticProps) {
28
28
  if (staticProps) _defineProperties(Constructor, staticProps);
29
29
  return Constructor;
30
30
  }
31
- function _instanceof(left, right) {
32
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
33
- return !!right[Symbol.hasInstance](left);
34
- } else {
35
- return left instanceof right;
36
- }
37
- }
38
31
  function _iterableToArray(iter) {
39
32
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
40
33
  }
@@ -82,10 +75,9 @@ function _unsupportedIterableToArray(o, minLen) {
82
75
  if (n === "Map" || n === "Set") return Array.from(n);
83
76
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
84
77
  }
85
- import { DataBind } from "@byteluck-fe/model-driven-core";
86
- import { hasChildrenControl, hasHeaderControl } from "./designerUtils";
87
- import { Group } from "@byteluck-fe/model-driven-settings";
88
- import { CONTROL_BASE_TYPE, CONTROL_TYPE } from "@byteluck-fe/model-driven-shared";
78
+ import { isDataBind } from '@byteluck-fe/model-driven-core';
79
+ import { hasChildrenControl, hasFooterControl, hasHeaderControl } from './designerUtils';
80
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE } from '@byteluck-fe/model-driven-shared';
89
81
  // 维护当前selected,。。 selectedControlSetting
90
82
  export var Store = /*#__PURE__*/ function() {
91
83
  "use strict";
@@ -111,94 +103,13 @@ export var Store = /*#__PURE__*/ function() {
111
103
  this.movingInstance = null;
112
104
  this.movingInstanceOldParent = null;
113
105
  this.movingInstanceOldDataScopeParent = null;
114
- var _options_getParentBeforeInstanceMove;
115
- this.getParentBeforeInstanceMove = (_options_getParentBeforeInstanceMove = options.getParentBeforeInstanceMove) !== null && _options_getParentBeforeInstanceMove !== void 0 ? _options_getParentBeforeInstanceMove : function(instance) {
106
+ var _getParentBeforeInstanceMove;
107
+ this.getParentBeforeInstanceMove = (_getParentBeforeInstanceMove = options.getParentBeforeInstanceMove) !== null && _getParentBeforeInstanceMove !== void 0 ? _getParentBeforeInstanceMove : function(instance) {
116
108
  return instance.parent;
117
109
  };
118
110
  this.instance = options.instance;
119
111
  this.getFlatInstances();
120
112
  }
121
- var _proto = Store.prototype;
122
- _proto.setInstances = function setInstances(instances) {
123
- this.instance = instances;
124
- this.getFlatInstances();
125
- };
126
- _proto.setSelectInstance = function setSelectInstance(instance) {
127
- this.selected = instance;
128
- this.selectedInstanceDataScopeParent = instance ? findInstanceDataScopeParent(instance) : null;
129
- this.selectedDataScopeFlatInstances = this.selectedInstanceDataScopeParent ? getDataScopeFlatInstances(this.selectedInstanceDataScopeParent) : [];
130
- };
131
- _proto.setSelectInstanceSettings = function setSelectInstanceSettings(settings) {
132
- var _this = this;
133
- this.selectedInstanceSetting = settings;
134
- this.selectedInstanceSettingItems = [];
135
- this.selectedInstanceSetting.forEach(function(group) {
136
- var _this_selectedInstanceSettingItems;
137
- (_this_selectedInstanceSettingItems = _this.selectedInstanceSettingItems).push.apply(_this_selectedInstanceSettingItems, _toConsumableArray(_this.getSettingItems(group)));
138
- });
139
- };
140
- _proto.getSettingItems = function getSettingItems(group) {
141
- return _instanceof(group, Group) ? group.items : group.items.reduce(function(result, curr) {
142
- var _result;
143
- (_result = result).push.apply(_result, _toConsumableArray(curr.items));
144
- return result;
145
- }, []);
146
- };
147
- _proto.setSelectedFieldItem = function setSelectedFieldItem(fieldItem) {
148
- this.selectedFieldItem = fieldItem;
149
- };
150
- _proto.setMovingInstance = function setMovingInstance(instance) {
151
- this.movingInstance = instance;
152
- this.movingInstanceOldParent = instance ? this.getParentBeforeInstanceMove(instance) : null;
153
- this.movingInstanceOldDataScopeParent = findInstanceDataScopeParent(instance);
154
- };
155
- _proto.updateDataFieldCodeMap = function updateDataFieldCodeMap(instance) {
156
- var scopeParent = findInstanceDataScopeParent(instance);
157
- if (!scopeParent) {
158
- return;
159
- }
160
- var map = this.dataFieldCodeMap.get(scopeParent.props.datasourceBind.dataCode);
161
- if (!map) {
162
- return;
163
- }
164
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
165
- try {
166
- for(var _iterator = map.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
167
- var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
168
- if (value.id === instance.id) {
169
- map.delete(key);
170
- break;
171
- }
172
- }
173
- } catch (err) {
174
- _didIteratorError = true;
175
- _iteratorError = err;
176
- } finally{
177
- try {
178
- if (!_iteratorNormalCompletion && _iterator.return != null) {
179
- _iterator.return();
180
- }
181
- } finally{
182
- if (_didIteratorError) {
183
- throw _iteratorError;
184
- }
185
- }
186
- }
187
- setInstanceInDataFieldCodeMap(instance, this.dataFieldCodeMap);
188
- };
189
- _proto.getFlatInstances = function getFlatInstances() {
190
- var instances = [];
191
- var instanceIdMap = new Map();
192
- var dataFieldCodeMap = new Map();
193
- loop(this.instance, function(instance) {
194
- instances.push(instance);
195
- instanceIdMap.set(instance.id, instance);
196
- setInstanceInDataFieldCodeMap(instance, dataFieldCodeMap);
197
- });
198
- this.flatInstances = instances;
199
- this.instanceIdMap = instanceIdMap;
200
- this.dataFieldCodeMap = dataFieldCodeMap;
201
- };
202
113
  _createClass(Store, [
203
114
  {
204
115
  key: "selectedRules",
@@ -223,6 +134,111 @@ export var Store = /*#__PURE__*/ function() {
223
134
  // TODO 转换Antd rules
224
135
  return rules;
225
136
  }
137
+ },
138
+ {
139
+ key: "setInstances",
140
+ value: function setInstances(instances) {
141
+ this.instance = instances;
142
+ this.getFlatInstances();
143
+ }
144
+ },
145
+ {
146
+ key: "setSelectInstance",
147
+ value: function setSelectInstance(instance) {
148
+ this.selected = instance;
149
+ this.selectedInstanceDataScopeParent = instance ? findInstanceDataScopeParent(instance) : null;
150
+ this.selectedDataScopeFlatInstances = this.selectedInstanceDataScopeParent ? getDataScopeFlatInstances(this.selectedInstanceDataScopeParent) : [];
151
+ }
152
+ },
153
+ {
154
+ key: "setSelectInstanceSettings",
155
+ value: function setSelectInstanceSettings(settings) {
156
+ var _this = this;
157
+ this.selectedInstanceSetting = settings;
158
+ this.selectedInstanceSettingItems = [];
159
+ this.selectedInstanceSetting.forEach(function(group) {
160
+ var _selectedInstanceSettingItems;
161
+ (_selectedInstanceSettingItems = _this.selectedInstanceSettingItems).push.apply(_selectedInstanceSettingItems, _toConsumableArray(_this.getSettingItems(group)));
162
+ });
163
+ }
164
+ },
165
+ {
166
+ key: "getSettingItems",
167
+ value: function getSettingItems(group) {
168
+ // return group instanceof Group
169
+ return group.type === 'group' ? group.items : group.items.reduce(function(result, curr) {
170
+ var _result;
171
+ (_result = result).push.apply(_result, _toConsumableArray(curr.items));
172
+ return result;
173
+ }, []);
174
+ }
175
+ },
176
+ {
177
+ key: "setSelectedFieldItem",
178
+ value: function setSelectedFieldItem(fieldItem) {
179
+ this.selectedFieldItem = fieldItem;
180
+ }
181
+ },
182
+ {
183
+ key: "setMovingInstance",
184
+ value: function setMovingInstance(instance) {
185
+ this.movingInstance = instance;
186
+ this.movingInstanceOldParent = instance ? this.getParentBeforeInstanceMove(instance) : null;
187
+ this.movingInstanceOldDataScopeParent = findInstanceDataScopeParent(instance);
188
+ }
189
+ },
190
+ {
191
+ key: "updateDataFieldCodeMap",
192
+ value: function updateDataFieldCodeMap(instance) {
193
+ var scopeParent = findInstanceDataScopeParent(instance);
194
+ if (!scopeParent) {
195
+ return;
196
+ }
197
+ var map = this.dataFieldCodeMap.get(scopeParent.props.datasourceBind.dataCode);
198
+ if (!map) {
199
+ return;
200
+ }
201
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
202
+ try {
203
+ for(var _iterator = map.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
204
+ var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
205
+ if (value.id === instance.id) {
206
+ map.delete(key);
207
+ break;
208
+ }
209
+ }
210
+ } catch (err) {
211
+ _didIteratorError = true;
212
+ _iteratorError = err;
213
+ } finally{
214
+ try {
215
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
216
+ _iterator.return();
217
+ }
218
+ } finally{
219
+ if (_didIteratorError) {
220
+ throw _iteratorError;
221
+ }
222
+ }
223
+ }
224
+ setInstanceInDataFieldCodeMap(instance, this.dataFieldCodeMap);
225
+ }
226
+ },
227
+ {
228
+ key: "getFlatInstances",
229
+ value: function getFlatInstances() {
230
+ var instances = [];
231
+ var instanceIdMap = new Map();
232
+ var dataFieldCodeMap = new Map();
233
+ loop(this.instance, function(instance) {
234
+ instances.push(instance);
235
+ instanceIdMap.set(instance.id, instance);
236
+ setInstanceInDataFieldCodeMap(instance, dataFieldCodeMap);
237
+ });
238
+ this.flatInstances = instances;
239
+ this.instanceIdMap = instanceIdMap;
240
+ this.dataFieldCodeMap = dataFieldCodeMap;
241
+ }
226
242
  }
227
243
  ]);
228
244
  return Store;
@@ -240,7 +256,8 @@ function setInstanceInDataFieldCodeMap(instance, dataFieldCodeMap) {
240
256
  // if (instance instanceof DesignerFormControl) {
241
257
  if (instance.controlType === CONTROL_BASE_TYPE.FORM) {
242
258
  var dataBind = instance.props.dataBind;
243
- if (_instanceof(dataBind, DataBind)) {
259
+ //if (dataBind instanceof DataBind) {
260
+ if (isDataBind(dataBind)) {
244
261
  setDataFieldCodeMap(dataFieldCodeMap, dataBind, instance);
245
262
  } else {
246
263
  Object.values(dataBind).forEach(function(subDataBind) {
@@ -261,13 +278,18 @@ export function loop(instances, callback) {
261
278
  if (hasHeaderControl(item)) {
262
279
  loop(item.props.headers, callback);
263
280
  }
281
+ if (hasFooterControl(item)) {
282
+ var ref;
283
+ var ref1;
284
+ loop((ref1 = (ref = item.props) === null || ref === void 0 ? void 0 : ref.footers) !== null && ref1 !== void 0 ? ref1 : [], callback);
285
+ }
264
286
  });
265
287
  }
266
288
  export function isDataScopeInstance(instance) {
267
289
  return [
268
290
  CONTROL_TYPE.SUBTABLE,
269
291
  CONTROL_TYPE.DATA_VIEW,
270
- CONTROL_TYPE.LIST_VIEW
292
+ CONTROL_TYPE.LIST_VIEW,
271
293
  ].includes(instance.type);
272
294
  }
273
295
  export function findInstanceDataScopeParent(instance) {
@@ -1,33 +1,33 @@
1
- import { CONTROL_TYPE, FieldTypes } from "@byteluck-fe/model-driven-shared";
1
+ import { CONTROL_TYPE, FieldTypes } from '@byteluck-fe/model-driven-shared';
2
2
  // 使用ObjectDataBind 的控件
3
3
  export var objectDataBindControlTypes = [
4
4
  CONTROL_TYPE.AMOUNT,
5
5
  CONTROL_TYPE.CALC,
6
- CONTROL_TYPE.DATE_RANGE
6
+ CONTROL_TYPE.DATE_RANGE,
7
7
  ];
8
8
  export var objectDataBindKeyToFieldType = {
9
9
  amount: {
10
- caption: "金额",
10
+ caption: '金额',
11
11
  fieldType: FieldTypes.DECIMAL
12
12
  },
13
13
  currency: {
14
- caption: "币种",
14
+ caption: '币种',
15
15
  fieldType: FieldTypes.VARCHAR
16
16
  },
17
17
  result: {
18
- caption: "结果",
18
+ caption: '结果',
19
19
  fieldType: FieldTypes.DECIMAL
20
20
  },
21
21
  unit: {
22
- caption: "单位",
22
+ caption: '单位',
23
23
  fieldType: FieldTypes.VARCHAR
24
24
  },
25
25
  min: {
26
- caption: "开始时间",
26
+ caption: '开始时间',
27
27
  fieldType: FieldTypes.TIMESTAMP
28
28
  },
29
29
  max: {
30
- caption: "结束时间",
30
+ caption: '结束时间',
31
31
  fieldType: FieldTypes.TIMESTAMP
32
32
  }
33
33
  };
@@ -1,9 +1,12 @@
1
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, isArray } from "@byteluck-fe/model-driven-shared";
1
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, isArray } from '@byteluck-fe/model-driven-shared';
2
2
  export function hasChildrenControl(instance) {
3
- return "children" in instance && isArray(instance.children);
3
+ return 'children' in instance && isArray(instance.children);
4
4
  }
5
5
  export function hasHeaderControl(instance) {
6
- return "headers" in instance.props && isArray(instance.props.headers);
6
+ return 'headers' in instance.props && isArray(instance.props.headers);
7
+ }
8
+ export function hasFooterControl(instance) {
9
+ return 'footers' in instance.props && isArray(instance.props.footers);
7
10
  }
8
11
  export function loopFormControl(control, callback) {
9
12
  if (Array.isArray(control)) {
@@ -14,8 +17,9 @@ export function loopFormControl(control, callback) {
14
17
  // @ts-ignore
15
18
  loopFormControl(item.props.headers, callback);
16
19
  } else if (hasChildrenControl(item)) {
17
- loopFormControl(// @ts-ignore
18
- item === null || item === void 0 ? void 0 : item.children, callback);
20
+ var // @ts-ignore
21
+ ref;
22
+ loopFormControl((ref = (item)) === null || ref === void 0 ? void 0 : ref.children, callback);
19
23
  // @ts-ignore
20
24
  // } else if (item instanceof DesignerFormControl) {
21
25
  } else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import Designer from "./Designer";
1
+ import Designer from './Designer';
2
2
  export { Designer };
3
- export * from "./utils";
4
- export * from "./Builder";
5
- export * from "./designerUtils";
6
- export * from "./Driven";
7
- export * from "./Store";
3
+ export * from './utils';
4
+ export * from './Builder';
5
+ export * from './designerUtils';
6
+ export * from './Driven';
7
+ export * from './Store';