@byteluck-fe/model-driven-driven 2.7.0-alpha.0 → 2.7.0-alpha.2
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 +86 -113
- package/dist/esm/Designer.js +177 -128
- package/dist/esm/Driven.js +406 -547
- package/dist/esm/EventLogic.js +1 -1
- package/dist/esm/Store.js +89 -112
- package/dist/esm/constants.js +8 -8
- package/dist/esm/designerUtils.js +5 -6
- package/dist/esm/index.js +6 -6
- package/dist/esm/utils.js +176 -75
- package/dist/index.umd.js +3 -3
- package/dist/types/Driven.d.ts +6 -6
- package/dist/types/Store.d.ts +1 -1
- package/package.json +6 -6
package/dist/esm/EventLogic.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EventLogic } from
|
|
1
|
+
import { EventLogic } from "@byteluck-fe/model-driven-shared";
|
|
2
2
|
export default EventLogic;
|
package/dist/esm/Store.js
CHANGED
|
@@ -30,7 +30,7 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
30
30
|
}
|
|
31
31
|
function _instanceof(left, right) {
|
|
32
32
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
33
|
-
return right[Symbol.hasInstance](left);
|
|
33
|
+
return !!right[Symbol.hasInstance](left);
|
|
34
34
|
} else {
|
|
35
35
|
return left instanceof right;
|
|
36
36
|
}
|
|
@@ -82,10 +82,10 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
82
82
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
83
83
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
84
84
|
}
|
|
85
|
-
import { DataBind } from
|
|
86
|
-
import { hasChildrenControl, hasHeaderControl } from
|
|
87
|
-
import { Group } from
|
|
88
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from
|
|
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";
|
|
89
89
|
// 维护当前selected,。。 selectedControlSetting
|
|
90
90
|
export var Store = /*#__PURE__*/ function() {
|
|
91
91
|
"use strict";
|
|
@@ -111,13 +111,94 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
111
111
|
this.movingInstance = null;
|
|
112
112
|
this.movingInstanceOldParent = null;
|
|
113
113
|
this.movingInstanceOldDataScopeParent = null;
|
|
114
|
-
var
|
|
115
|
-
this.getParentBeforeInstanceMove = (
|
|
114
|
+
var _options_getParentBeforeInstanceMove;
|
|
115
|
+
this.getParentBeforeInstanceMove = (_options_getParentBeforeInstanceMove = options.getParentBeforeInstanceMove) !== null && _options_getParentBeforeInstanceMove !== void 0 ? _options_getParentBeforeInstanceMove : function(instance) {
|
|
116
116
|
return instance.parent;
|
|
117
117
|
};
|
|
118
118
|
this.instance = options.instance;
|
|
119
119
|
this.getFlatInstances();
|
|
120
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
|
+
};
|
|
121
202
|
_createClass(Store, [
|
|
122
203
|
{
|
|
123
204
|
key: "selectedRules",
|
|
@@ -142,110 +223,6 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
142
223
|
// TODO 转换Antd rules
|
|
143
224
|
return rules;
|
|
144
225
|
}
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
key: "setInstances",
|
|
148
|
-
value: function setInstances(instances) {
|
|
149
|
-
this.instance = instances;
|
|
150
|
-
this.getFlatInstances();
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
key: "setSelectInstance",
|
|
155
|
-
value: function setSelectInstance(instance) {
|
|
156
|
-
this.selected = instance;
|
|
157
|
-
this.selectedInstanceDataScopeParent = instance ? findInstanceDataScopeParent(instance) : null;
|
|
158
|
-
this.selectedDataScopeFlatInstances = this.selectedInstanceDataScopeParent ? getDataScopeFlatInstances(this.selectedInstanceDataScopeParent) : [];
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
key: "setSelectInstanceSettings",
|
|
163
|
-
value: function setSelectInstanceSettings(settings) {
|
|
164
|
-
var _this = this;
|
|
165
|
-
this.selectedInstanceSetting = settings;
|
|
166
|
-
this.selectedInstanceSettingItems = [];
|
|
167
|
-
this.selectedInstanceSetting.forEach(function(group) {
|
|
168
|
-
var _selectedInstanceSettingItems;
|
|
169
|
-
(_selectedInstanceSettingItems = _this.selectedInstanceSettingItems).push.apply(_selectedInstanceSettingItems, _toConsumableArray(_this.getSettingItems(group)));
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
key: "getSettingItems",
|
|
175
|
-
value: function getSettingItems(group) {
|
|
176
|
-
return _instanceof(group, Group) ? group.items : group.items.reduce(function(result, curr) {
|
|
177
|
-
var _result;
|
|
178
|
-
(_result = result).push.apply(_result, _toConsumableArray(curr.items));
|
|
179
|
-
return result;
|
|
180
|
-
}, []);
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
key: "setSelectedFieldItem",
|
|
185
|
-
value: function setSelectedFieldItem(fieldItem) {
|
|
186
|
-
this.selectedFieldItem = fieldItem;
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
key: "setMovingInstance",
|
|
191
|
-
value: function setMovingInstance(instance) {
|
|
192
|
-
this.movingInstance = instance;
|
|
193
|
-
this.movingInstanceOldParent = instance ? this.getParentBeforeInstanceMove(instance) : null;
|
|
194
|
-
this.movingInstanceOldDataScopeParent = findInstanceDataScopeParent(instance);
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
key: "updateDataFieldCodeMap",
|
|
199
|
-
value: function updateDataFieldCodeMap(instance) {
|
|
200
|
-
var scopeParent = findInstanceDataScopeParent(instance);
|
|
201
|
-
if (!scopeParent) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
var map = this.dataFieldCodeMap.get(scopeParent.props.datasourceBind.dataCode);
|
|
205
|
-
if (!map) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
209
|
-
try {
|
|
210
|
-
for(var _iterator = map.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
211
|
-
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
212
|
-
if (value.id === instance.id) {
|
|
213
|
-
map.delete(key);
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
} catch (err) {
|
|
218
|
-
_didIteratorError = true;
|
|
219
|
-
_iteratorError = err;
|
|
220
|
-
} finally{
|
|
221
|
-
try {
|
|
222
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
223
|
-
_iterator.return();
|
|
224
|
-
}
|
|
225
|
-
} finally{
|
|
226
|
-
if (_didIteratorError) {
|
|
227
|
-
throw _iteratorError;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
setInstanceInDataFieldCodeMap(instance, this.dataFieldCodeMap);
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
key: "getFlatInstances",
|
|
236
|
-
value: function getFlatInstances() {
|
|
237
|
-
var instances = [];
|
|
238
|
-
var instanceIdMap = new Map();
|
|
239
|
-
var dataFieldCodeMap = new Map();
|
|
240
|
-
loop(this.instance, function(instance) {
|
|
241
|
-
instances.push(instance);
|
|
242
|
-
instanceIdMap.set(instance.id, instance);
|
|
243
|
-
setInstanceInDataFieldCodeMap(instance, dataFieldCodeMap);
|
|
244
|
-
});
|
|
245
|
-
this.flatInstances = instances;
|
|
246
|
-
this.instanceIdMap = instanceIdMap;
|
|
247
|
-
this.dataFieldCodeMap = dataFieldCodeMap;
|
|
248
|
-
}
|
|
249
226
|
}
|
|
250
227
|
]);
|
|
251
228
|
return Store;
|
|
@@ -290,7 +267,7 @@ export function isDataScopeInstance(instance) {
|
|
|
290
267
|
return [
|
|
291
268
|
CONTROL_TYPE.SUBTABLE,
|
|
292
269
|
CONTROL_TYPE.DATA_VIEW,
|
|
293
|
-
CONTROL_TYPE.LIST_VIEW
|
|
270
|
+
CONTROL_TYPE.LIST_VIEW
|
|
294
271
|
].includes(instance.type);
|
|
295
272
|
}
|
|
296
273
|
export function findInstanceDataScopeParent(instance) {
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { CONTROL_TYPE, FieldTypes } from
|
|
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,9 @@
|
|
|
1
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, isArray } from
|
|
1
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, isArray } from "@byteluck-fe/model-driven-shared";
|
|
2
2
|
export function hasChildrenControl(instance) {
|
|
3
|
-
return
|
|
3
|
+
return "children" in instance && isArray(instance.children);
|
|
4
4
|
}
|
|
5
5
|
export function hasHeaderControl(instance) {
|
|
6
|
-
return
|
|
6
|
+
return "headers" in instance.props && isArray(instance.props.headers);
|
|
7
7
|
}
|
|
8
8
|
export function loopFormControl(control, callback) {
|
|
9
9
|
if (Array.isArray(control)) {
|
|
@@ -14,9 +14,8 @@ export function loopFormControl(control, callback) {
|
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
loopFormControl(item.props.headers, callback);
|
|
16
16
|
} else if (hasChildrenControl(item)) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
loopFormControl((ref = (item)) === null || ref === void 0 ? void 0 : ref.children, callback);
|
|
17
|
+
loopFormControl(// @ts-ignore
|
|
18
|
+
item === null || item === void 0 ? void 0 : item.children, callback);
|
|
20
19
|
// @ts-ignore
|
|
21
20
|
// } else if (item instanceof DesignerFormControl) {
|
|
22
21
|
} else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Designer from
|
|
1
|
+
import Designer from "./Designer";
|
|
2
2
|
export { Designer };
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
3
|
+
export * from "./utils";
|
|
4
|
+
export * from "./Builder";
|
|
5
|
+
export * from "./designerUtils";
|
|
6
|
+
export * from "./Driven";
|
|
7
|
+
export * from "./Store";
|