@byteluck-fe/model-driven-driven 2.7.0-alpha.2 → 2.7.0-alpha.20
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 +578 -399
- package/dist/esm/Store.js +155 -99
- package/dist/esm/designerUtils.js +3 -0
- package/dist/esm/utils.js +3 -1
- package/dist/index.umd.js +3 -3
- package/dist/types/Driven.d.ts +4 -4
- package/dist/types/designerUtils.d.ts +1 -0
- package/package.json +6 -6
package/dist/esm/Store.js
CHANGED
|
@@ -28,12 +28,18 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
28
28
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
29
29
|
return Constructor;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
if (
|
|
33
|
-
|
|
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
|
+
});
|
|
34
39
|
} else {
|
|
35
|
-
|
|
40
|
+
obj[key] = value;
|
|
36
41
|
}
|
|
42
|
+
return obj;
|
|
37
43
|
}
|
|
38
44
|
function _iterableToArray(iter) {
|
|
39
45
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
@@ -82,9 +88,8 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
82
88
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
83
89
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
84
90
|
}
|
|
85
|
-
import {
|
|
86
|
-
import { hasChildrenControl, hasHeaderControl } from "./designerUtils";
|
|
87
|
-
import { Group } from "@byteluck-fe/model-driven-settings";
|
|
91
|
+
import { isDataBind } from "@byteluck-fe/model-driven-core";
|
|
92
|
+
import { hasChildrenControl, hasFooterControl, hasHeaderControl } from "./designerUtils";
|
|
88
93
|
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from "@byteluck-fe/model-driven-shared";
|
|
89
94
|
// 维护当前selected,。。 selectedControlSetting
|
|
90
95
|
export var Store = /*#__PURE__*/ function() {
|
|
@@ -92,25 +97,46 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
92
97
|
function Store(options) {
|
|
93
98
|
_classCallCheck(this, Store);
|
|
94
99
|
/**
|
|
100
|
+
* 页面控件实例树
|
|
101
|
+
* */ _defineProperty(this, "instance", void 0);
|
|
102
|
+
/**
|
|
103
|
+
* 拍平的控件数组
|
|
104
|
+
* */ _defineProperty(this, "flatInstances", void 0);
|
|
105
|
+
/**
|
|
106
|
+
* 控件id组成的map
|
|
107
|
+
* */ _defineProperty(this, "instanceIdMap", void 0);
|
|
108
|
+
/**
|
|
109
|
+
* dataCode和fieldCode组成的map
|
|
110
|
+
* {
|
|
111
|
+
* [主表dataCode]: {
|
|
112
|
+
* [fieldCode]: 控件
|
|
113
|
+
* },
|
|
114
|
+
* [子表dataCode]: {
|
|
115
|
+
* [fieldCode]: 控件
|
|
116
|
+
* }
|
|
117
|
+
* }
|
|
118
|
+
* */ _defineProperty(this, "dataFieldCodeMap", void 0);
|
|
119
|
+
/**
|
|
95
120
|
* 当前选中的控件
|
|
96
|
-
* */ this
|
|
121
|
+
* */ _defineProperty(this, "selected", null);
|
|
97
122
|
/**
|
|
98
123
|
* 当前选中的数据作用域控件
|
|
99
|
-
* */ this
|
|
100
|
-
this
|
|
124
|
+
* */ _defineProperty(this, "selectedInstanceDataScopeParent", null);
|
|
125
|
+
_defineProperty(this, "selectedDataScopeFlatInstances", []);
|
|
101
126
|
/**
|
|
102
127
|
* 当前选中控件的setting
|
|
103
|
-
* */ this
|
|
104
|
-
this
|
|
128
|
+
* */ _defineProperty(this, "selectedInstanceSetting", []);
|
|
129
|
+
_defineProperty(this, "selectedInstanceSettingItems", []);
|
|
105
130
|
/**
|
|
106
131
|
* 当前选中控件的数据模型
|
|
107
|
-
* */ this
|
|
132
|
+
* */ _defineProperty(this, "selectedFieldItem", null);
|
|
108
133
|
/**
|
|
109
134
|
* 扩展字段,比如appId,dataCode等
|
|
110
|
-
* */ this
|
|
111
|
-
this
|
|
112
|
-
this
|
|
113
|
-
this
|
|
135
|
+
* */ _defineProperty(this, "external", {});
|
|
136
|
+
_defineProperty(this, "movingInstance", null);
|
|
137
|
+
_defineProperty(this, "movingInstanceOldParent", null);
|
|
138
|
+
_defineProperty(this, "movingInstanceOldDataScopeParent", null);
|
|
139
|
+
_defineProperty(this, "getParentBeforeInstanceMove", void 0);
|
|
114
140
|
var _options_getParentBeforeInstanceMove;
|
|
115
141
|
this.getParentBeforeInstanceMove = (_options_getParentBeforeInstanceMove = options.getParentBeforeInstanceMove) !== null && _options_getParentBeforeInstanceMove !== void 0 ? _options_getParentBeforeInstanceMove : function(instance) {
|
|
116
142
|
return instance.parent;
|
|
@@ -118,87 +144,6 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
118
144
|
this.instance = options.instance;
|
|
119
145
|
this.getFlatInstances();
|
|
120
146
|
}
|
|
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
147
|
_createClass(Store, [
|
|
203
148
|
{
|
|
204
149
|
key: "selectedRules",
|
|
@@ -223,6 +168,111 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
223
168
|
// TODO 转换Antd rules
|
|
224
169
|
return rules;
|
|
225
170
|
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
key: "setInstances",
|
|
174
|
+
value: function setInstances(instances) {
|
|
175
|
+
this.instance = instances;
|
|
176
|
+
this.getFlatInstances();
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
key: "setSelectInstance",
|
|
181
|
+
value: function setSelectInstance(instance) {
|
|
182
|
+
this.selected = instance;
|
|
183
|
+
this.selectedInstanceDataScopeParent = instance ? findInstanceDataScopeParent(instance) : null;
|
|
184
|
+
this.selectedDataScopeFlatInstances = this.selectedInstanceDataScopeParent ? getDataScopeFlatInstances(this.selectedInstanceDataScopeParent) : [];
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
key: "setSelectInstanceSettings",
|
|
189
|
+
value: function setSelectInstanceSettings(settings) {
|
|
190
|
+
var _this = this;
|
|
191
|
+
this.selectedInstanceSetting = settings;
|
|
192
|
+
this.selectedInstanceSettingItems = [];
|
|
193
|
+
this.selectedInstanceSetting.forEach(function(group) {
|
|
194
|
+
var _this_selectedInstanceSettingItems;
|
|
195
|
+
(_this_selectedInstanceSettingItems = _this.selectedInstanceSettingItems).push.apply(_this_selectedInstanceSettingItems, _toConsumableArray(_this.getSettingItems(group)));
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
key: "getSettingItems",
|
|
201
|
+
value: function getSettingItems(group) {
|
|
202
|
+
// return group instanceof Group
|
|
203
|
+
return group.type === "group" ? group.items : group.items.reduce(function(result, curr) {
|
|
204
|
+
var _result;
|
|
205
|
+
(_result = result).push.apply(_result, _toConsumableArray(curr.items));
|
|
206
|
+
return result;
|
|
207
|
+
}, []);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
key: "setSelectedFieldItem",
|
|
212
|
+
value: function setSelectedFieldItem(fieldItem) {
|
|
213
|
+
this.selectedFieldItem = fieldItem;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
key: "setMovingInstance",
|
|
218
|
+
value: function setMovingInstance(instance) {
|
|
219
|
+
this.movingInstance = instance;
|
|
220
|
+
this.movingInstanceOldParent = instance ? this.getParentBeforeInstanceMove(instance) : null;
|
|
221
|
+
this.movingInstanceOldDataScopeParent = findInstanceDataScopeParent(instance);
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
key: "updateDataFieldCodeMap",
|
|
226
|
+
value: function updateDataFieldCodeMap(instance) {
|
|
227
|
+
var scopeParent = findInstanceDataScopeParent(instance);
|
|
228
|
+
if (!scopeParent) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
var map = this.dataFieldCodeMap.get(scopeParent.props.datasourceBind.dataCode);
|
|
232
|
+
if (!map) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
236
|
+
try {
|
|
237
|
+
for(var _iterator = map.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
238
|
+
var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
239
|
+
if (value.id === instance.id) {
|
|
240
|
+
map.delete(key);
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
_didIteratorError = true;
|
|
246
|
+
_iteratorError = err;
|
|
247
|
+
} finally{
|
|
248
|
+
try {
|
|
249
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
250
|
+
_iterator.return();
|
|
251
|
+
}
|
|
252
|
+
} finally{
|
|
253
|
+
if (_didIteratorError) {
|
|
254
|
+
throw _iteratorError;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
setInstanceInDataFieldCodeMap(instance, this.dataFieldCodeMap);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
key: "getFlatInstances",
|
|
263
|
+
value: function getFlatInstances() {
|
|
264
|
+
var instances = [];
|
|
265
|
+
var instanceIdMap = new Map();
|
|
266
|
+
var dataFieldCodeMap = new Map();
|
|
267
|
+
loop(this.instance, function(instance) {
|
|
268
|
+
instances.push(instance);
|
|
269
|
+
instanceIdMap.set(instance.id, instance);
|
|
270
|
+
setInstanceInDataFieldCodeMap(instance, dataFieldCodeMap);
|
|
271
|
+
});
|
|
272
|
+
this.flatInstances = instances;
|
|
273
|
+
this.instanceIdMap = instanceIdMap;
|
|
274
|
+
this.dataFieldCodeMap = dataFieldCodeMap;
|
|
275
|
+
}
|
|
226
276
|
}
|
|
227
277
|
]);
|
|
228
278
|
return Store;
|
|
@@ -240,7 +290,8 @@ function setInstanceInDataFieldCodeMap(instance, dataFieldCodeMap) {
|
|
|
240
290
|
// if (instance instanceof DesignerFormControl) {
|
|
241
291
|
if (instance.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
242
292
|
var dataBind = instance.props.dataBind;
|
|
243
|
-
if (
|
|
293
|
+
//if (dataBind instanceof DataBind) {
|
|
294
|
+
if (isDataBind(dataBind)) {
|
|
244
295
|
setDataFieldCodeMap(dataFieldCodeMap, dataBind, instance);
|
|
245
296
|
} else {
|
|
246
297
|
Object.values(dataBind).forEach(function(subDataBind) {
|
|
@@ -261,6 +312,11 @@ export function loop(instances, callback) {
|
|
|
261
312
|
if (hasHeaderControl(item)) {
|
|
262
313
|
loop(item.props.headers, callback);
|
|
263
314
|
}
|
|
315
|
+
if (hasFooterControl(item)) {
|
|
316
|
+
var _item_props;
|
|
317
|
+
var _item_props_footers;
|
|
318
|
+
loop((_item_props_footers = (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.footers) !== null && _item_props_footers !== void 0 ? _item_props_footers : [], callback);
|
|
319
|
+
}
|
|
264
320
|
});
|
|
265
321
|
}
|
|
266
322
|
export function isDataScopeInstance(instance) {
|
|
@@ -5,6 +5,9 @@ export function hasChildrenControl(instance) {
|
|
|
5
5
|
export function hasHeaderControl(instance) {
|
|
6
6
|
return "headers" in instance.props && isArray(instance.props.headers);
|
|
7
7
|
}
|
|
8
|
+
export function hasFooterControl(instance) {
|
|
9
|
+
return "footers" in instance.props && isArray(instance.props.footers);
|
|
10
|
+
}
|
|
8
11
|
export function loopFormControl(control, callback) {
|
|
9
12
|
if (Array.isArray(control)) {
|
|
10
13
|
control.map(function(item) {
|
package/dist/esm/utils.js
CHANGED
|
@@ -378,7 +378,9 @@ var PermissionExcludeControlTypes = [
|
|
|
378
378
|
CONTROL_TYPE.TAB_PANE,
|
|
379
379
|
CONTROL_TYPE.TAB,
|
|
380
380
|
CONTROL_TYPE.CARD_GROUP,
|
|
381
|
-
CONTROL_TYPE.ACTION_BAR
|
|
381
|
+
CONTROL_TYPE.ACTION_BAR,
|
|
382
|
+
CONTROL_TYPE.GRID_LAYOUT_CONTAINER,
|
|
383
|
+
CONTROL_TYPE.GRID_LAYOUT_WRAP
|
|
382
384
|
];
|
|
383
385
|
// 不可以编辑的控件
|
|
384
386
|
var cannotEditControlTypes = [
|