@byteluck-fe/model-driven-driven 2.5.0-beta.2 → 2.5.0-beta.6

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/Store.js CHANGED
@@ -28,19 +28,6 @@ function _createClass(Constructor, protoProps, staticProps) {
28
28
  if (staticProps) _defineProperties(Constructor, staticProps);
29
29
  return Constructor;
30
30
  }
31
- function _defineProperty(obj, key, value) {
32
- if (key in obj) {
33
- Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- } else {
40
- obj[key] = value;
41
- }
42
- return obj;
43
- }
44
31
  function _instanceof(left, right) {
45
32
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
46
33
  return !!right[Symbol.hasInstance](left);
@@ -105,46 +92,25 @@ export var Store = /*#__PURE__*/ function() {
105
92
  function Store(options) {
106
93
  _classCallCheck(this, Store);
107
94
  /**
108
- * 页面控件实例树
109
- * */ _defineProperty(this, "instance", void 0);
110
- /**
111
- * 拍平的控件数组
112
- * */ _defineProperty(this, "flatInstances", void 0);
113
- /**
114
- * 控件id组成的map
115
- * */ _defineProperty(this, "instanceIdMap", void 0);
116
- /**
117
- * dataCode和fieldCode组成的map
118
- * {
119
- * [主表dataCode]: {
120
- * [fieldCode]: 控件
121
- * },
122
- * [子表dataCode]: {
123
- * [fieldCode]: 控件
124
- * }
125
- * }
126
- * */ _defineProperty(this, "dataFieldCodeMap", void 0);
127
- /**
128
95
  * 当前选中的控件
129
- * */ _defineProperty(this, "selected", null);
96
+ * */ this.selected = null;
130
97
  /**
131
98
  * 当前选中的数据作用域控件
132
- * */ _defineProperty(this, "selectedInstanceDataScopeParent", null);
133
- _defineProperty(this, "selectedDataScopeFlatInstances", []);
99
+ * */ this.selectedInstanceDataScopeParent = null;
100
+ this.selectedDataScopeFlatInstances = [];
134
101
  /**
135
102
  * 当前选中控件的setting
136
- * */ _defineProperty(this, "selectedInstanceSetting", []);
137
- _defineProperty(this, "selectedInstanceSettingItems", []);
103
+ * */ this.selectedInstanceSetting = [];
104
+ this.selectedInstanceSettingItems = [];
138
105
  /**
139
106
  * 当前选中控件的数据模型
140
- * */ _defineProperty(this, "selectedFieldItem", null);
107
+ * */ this.selectedFieldItem = null;
141
108
  /**
142
109
  * 扩展字段,比如appId,dataCode等
143
- * */ _defineProperty(this, "external", {});
144
- _defineProperty(this, "movingInstance", null);
145
- _defineProperty(this, "movingInstanceOldParent", null);
146
- _defineProperty(this, "movingInstanceOldDataScopeParent", null);
147
- _defineProperty(this, "getParentBeforeInstanceMove", void 0);
110
+ * */ this.external = {};
111
+ this.movingInstance = null;
112
+ this.movingInstanceOldParent = null;
113
+ this.movingInstanceOldDataScopeParent = null;
148
114
  var _options_getParentBeforeInstanceMove;
149
115
  this.getParentBeforeInstanceMove = (_options_getParentBeforeInstanceMove = options.getParentBeforeInstanceMove) !== null && _options_getParentBeforeInstanceMove !== void 0 ? _options_getParentBeforeInstanceMove : function(instance) {
150
116
  return instance.parent;
@@ -152,6 +118,87 @@ export var Store = /*#__PURE__*/ function() {
152
118
  this.instance = options.instance;
153
119
  this.getFlatInstances();
154
120
  }
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
+ };
155
202
  _createClass(Store, [
156
203
  {
157
204
  key: "selectedRules",
@@ -176,110 +223,6 @@ export var Store = /*#__PURE__*/ function() {
176
223
  // TODO 转换Antd rules
177
224
  return rules;
178
225
  }
179
- },
180
- {
181
- key: "setInstances",
182
- value: function setInstances(instances) {
183
- this.instance = instances;
184
- this.getFlatInstances();
185
- }
186
- },
187
- {
188
- key: "setSelectInstance",
189
- value: function setSelectInstance(instance) {
190
- this.selected = instance;
191
- this.selectedInstanceDataScopeParent = instance ? findInstanceDataScopeParent(instance) : null;
192
- this.selectedDataScopeFlatInstances = this.selectedInstanceDataScopeParent ? getDataScopeFlatInstances(this.selectedInstanceDataScopeParent) : [];
193
- }
194
- },
195
- {
196
- key: "setSelectInstanceSettings",
197
- value: function setSelectInstanceSettings(settings) {
198
- var _this = this;
199
- this.selectedInstanceSetting = settings;
200
- this.selectedInstanceSettingItems = [];
201
- this.selectedInstanceSetting.forEach(function(group) {
202
- var _this_selectedInstanceSettingItems;
203
- (_this_selectedInstanceSettingItems = _this.selectedInstanceSettingItems).push.apply(_this_selectedInstanceSettingItems, _toConsumableArray(_this.getSettingItems(group)));
204
- });
205
- }
206
- },
207
- {
208
- key: "getSettingItems",
209
- value: function getSettingItems(group) {
210
- return _instanceof(group, Group) ? group.items : group.items.reduce(function(result, curr) {
211
- var _result;
212
- (_result = result).push.apply(_result, _toConsumableArray(curr.items));
213
- return result;
214
- }, []);
215
- }
216
- },
217
- {
218
- key: "setSelectedFieldItem",
219
- value: function setSelectedFieldItem(fieldItem) {
220
- this.selectedFieldItem = fieldItem;
221
- }
222
- },
223
- {
224
- key: "setMovingInstance",
225
- value: function setMovingInstance(instance) {
226
- this.movingInstance = instance;
227
- this.movingInstanceOldParent = instance ? this.getParentBeforeInstanceMove(instance) : null;
228
- this.movingInstanceOldDataScopeParent = findInstanceDataScopeParent(instance);
229
- }
230
- },
231
- {
232
- key: "updateDataFieldCodeMap",
233
- value: function updateDataFieldCodeMap(instance) {
234
- var scopeParent = findInstanceDataScopeParent(instance);
235
- if (!scopeParent) {
236
- return;
237
- }
238
- var map = this.dataFieldCodeMap.get(scopeParent.props.datasourceBind.dataCode);
239
- if (!map) {
240
- return;
241
- }
242
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
243
- try {
244
- for(var _iterator = map.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
245
- var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
246
- if (value.id === instance.id) {
247
- map.delete(key);
248
- break;
249
- }
250
- }
251
- } catch (err) {
252
- _didIteratorError = true;
253
- _iteratorError = err;
254
- } finally{
255
- try {
256
- if (!_iteratorNormalCompletion && _iterator.return != null) {
257
- _iterator.return();
258
- }
259
- } finally{
260
- if (_didIteratorError) {
261
- throw _iteratorError;
262
- }
263
- }
264
- }
265
- setInstanceInDataFieldCodeMap(instance, this.dataFieldCodeMap);
266
- }
267
- },
268
- {
269
- key: "getFlatInstances",
270
- value: function getFlatInstances() {
271
- var instances = [];
272
- var instanceIdMap = new Map();
273
- var dataFieldCodeMap = new Map();
274
- loop(this.instance, function(instance) {
275
- instances.push(instance);
276
- instanceIdMap.set(instance.id, instance);
277
- setInstanceInDataFieldCodeMap(instance, dataFieldCodeMap);
278
- });
279
- this.flatInstances = instances;
280
- this.instanceIdMap = instanceIdMap;
281
- this.dataFieldCodeMap = dataFieldCodeMap;
282
- }
283
226
  }
284
227
  ]);
285
228
  return Store;