@byteluck-fe/model-driven-driven 2.7.0-alpha.2 → 2.7.0-alpha.3
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/Builder.js +125 -85
- package/dist/esm/Designer.js +125 -70
- package/dist/esm/Driven.js +558 -399
- package/dist/esm/Store.js +148 -91
- package/dist/index.umd.js +3 -3
- package/package.json +5 -5
package/dist/esm/Store.js
CHANGED
|
@@ -28,6 +28,19 @@ 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
|
+
}
|
|
31
44
|
function _instanceof(left, right) {
|
|
32
45
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
33
46
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -92,25 +105,46 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
92
105
|
function Store(options) {
|
|
93
106
|
_classCallCheck(this, Store);
|
|
94
107
|
/**
|
|
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
|
+
/**
|
|
95
128
|
* 当前选中的控件
|
|
96
|
-
* */ this
|
|
129
|
+
* */ _defineProperty(this, "selected", null);
|
|
97
130
|
/**
|
|
98
131
|
* 当前选中的数据作用域控件
|
|
99
|
-
* */ this
|
|
100
|
-
this
|
|
132
|
+
* */ _defineProperty(this, "selectedInstanceDataScopeParent", null);
|
|
133
|
+
_defineProperty(this, "selectedDataScopeFlatInstances", []);
|
|
101
134
|
/**
|
|
102
135
|
* 当前选中控件的setting
|
|
103
|
-
* */ this
|
|
104
|
-
this
|
|
136
|
+
* */ _defineProperty(this, "selectedInstanceSetting", []);
|
|
137
|
+
_defineProperty(this, "selectedInstanceSettingItems", []);
|
|
105
138
|
/**
|
|
106
139
|
* 当前选中控件的数据模型
|
|
107
|
-
* */ this
|
|
140
|
+
* */ _defineProperty(this, "selectedFieldItem", null);
|
|
108
141
|
/**
|
|
109
142
|
* 扩展字段,比如appId,dataCode等
|
|
110
|
-
* */ this
|
|
111
|
-
this
|
|
112
|
-
this
|
|
113
|
-
this
|
|
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);
|
|
114
148
|
var _options_getParentBeforeInstanceMove;
|
|
115
149
|
this.getParentBeforeInstanceMove = (_options_getParentBeforeInstanceMove = options.getParentBeforeInstanceMove) !== null && _options_getParentBeforeInstanceMove !== void 0 ? _options_getParentBeforeInstanceMove : function(instance) {
|
|
116
150
|
return instance.parent;
|
|
@@ -118,87 +152,6 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
118
152
|
this.instance = options.instance;
|
|
119
153
|
this.getFlatInstances();
|
|
120
154
|
}
|
|
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
155
|
_createClass(Store, [
|
|
203
156
|
{
|
|
204
157
|
key: "selectedRules",
|
|
@@ -223,6 +176,110 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
223
176
|
// TODO 转换Antd rules
|
|
224
177
|
return rules;
|
|
225
178
|
}
|
|
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
|
+
}
|
|
226
283
|
}
|
|
227
284
|
]);
|
|
228
285
|
return Store;
|