@byteluck-fe/model-driven-driven 2.7.0-alpha.2 → 2.7.0-alpha.21
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 +127 -87
- package/dist/esm/Designer.js +160 -105
- package/dist/esm/Driven.js +624 -445
- package/dist/esm/Plugin.js +2 -2
- package/dist/esm/Store.js +174 -118
- package/dist/esm/designerUtils.js +6 -2
- package/dist/esm/utils.js +35 -31
- 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/Driven.js
CHANGED
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
2
|
if (len == null || len > arr.length) len = arr.length;
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (Array.isArray(arr)) return
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function _assert_this_initialized(self) {
|
|
13
13
|
if (self === void 0) {
|
|
14
14
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
15
|
}
|
|
16
16
|
return self;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function _class_call_check(instance, Constructor) {
|
|
19
19
|
if (!(instance instanceof Constructor)) {
|
|
20
20
|
throw new TypeError("Cannot call a class as a function");
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function _defineProperties(target, props) {
|
|
24
|
+
for(var i = 0; i < props.length; i++){
|
|
25
|
+
var descriptor = props[i];
|
|
26
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
27
|
+
descriptor.configurable = true;
|
|
28
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
29
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
33
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
34
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
35
|
+
return Constructor;
|
|
36
|
+
}
|
|
37
|
+
function _define_property(obj, key, value) {
|
|
24
38
|
if (key in obj) {
|
|
25
39
|
Object.defineProperty(obj, key, {
|
|
26
40
|
value: value,
|
|
@@ -37,23 +51,23 @@ function _get(target, property, receiver) {
|
|
|
37
51
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
38
52
|
_get = Reflect.get;
|
|
39
53
|
} else {
|
|
40
|
-
_get = function
|
|
41
|
-
var base =
|
|
54
|
+
_get = function get(target, property, receiver) {
|
|
55
|
+
var base = _super_prop_base(target, property);
|
|
42
56
|
if (!base) return;
|
|
43
57
|
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
44
58
|
if (desc.get) {
|
|
45
|
-
return desc.get.call(receiver);
|
|
59
|
+
return desc.get.call(receiver || target);
|
|
46
60
|
}
|
|
47
61
|
return desc.value;
|
|
48
62
|
};
|
|
49
63
|
}
|
|
50
64
|
return _get(target, property, receiver || target);
|
|
51
65
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
66
|
+
function _get_prototype_of(o) {
|
|
67
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
54
68
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
55
69
|
};
|
|
56
|
-
return
|
|
70
|
+
return _get_prototype_of(o);
|
|
57
71
|
}
|
|
58
72
|
function _inherits(subClass, superClass) {
|
|
59
73
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -66,12 +80,12 @@ function _inherits(subClass, superClass) {
|
|
|
66
80
|
configurable: true
|
|
67
81
|
}
|
|
68
82
|
});
|
|
69
|
-
if (superClass)
|
|
83
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
70
84
|
}
|
|
71
|
-
function
|
|
85
|
+
function _iterable_to_array(iter) {
|
|
72
86
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
73
87
|
}
|
|
74
|
-
function
|
|
88
|
+
function _iterable_to_array_limit(arr, i) {
|
|
75
89
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
76
90
|
if (_i == null) return;
|
|
77
91
|
var _arr = [];
|
|
@@ -95,13 +109,13 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
95
109
|
}
|
|
96
110
|
return _arr;
|
|
97
111
|
}
|
|
98
|
-
function
|
|
112
|
+
function _non_iterable_rest() {
|
|
99
113
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
100
114
|
}
|
|
101
|
-
function
|
|
115
|
+
function _non_iterable_spread() {
|
|
102
116
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
103
117
|
}
|
|
104
|
-
function
|
|
118
|
+
function _object_spread(target) {
|
|
105
119
|
for(var i = 1; i < arguments.length; i++){
|
|
106
120
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
107
121
|
var ownKeys = Object.keys(source);
|
|
@@ -111,50 +125,50 @@ function _objectSpread(target) {
|
|
|
111
125
|
}));
|
|
112
126
|
}
|
|
113
127
|
ownKeys.forEach(function(key) {
|
|
114
|
-
|
|
128
|
+
_define_property(target, key, source[key]);
|
|
115
129
|
});
|
|
116
130
|
}
|
|
117
131
|
return target;
|
|
118
132
|
}
|
|
119
|
-
function
|
|
120
|
-
if (call && (
|
|
133
|
+
function _possible_constructor_return(self, call) {
|
|
134
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
121
135
|
return call;
|
|
122
136
|
}
|
|
123
|
-
return
|
|
137
|
+
return _assert_this_initialized(self);
|
|
124
138
|
}
|
|
125
|
-
function
|
|
126
|
-
|
|
139
|
+
function _set_prototype_of(o, p) {
|
|
140
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
127
141
|
o.__proto__ = p;
|
|
128
142
|
return o;
|
|
129
143
|
};
|
|
130
|
-
return
|
|
144
|
+
return _set_prototype_of(o, p);
|
|
131
145
|
}
|
|
132
|
-
function
|
|
133
|
-
return
|
|
146
|
+
function _sliced_to_array(arr, i) {
|
|
147
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
134
148
|
}
|
|
135
|
-
function
|
|
149
|
+
function _super_prop_base(object, property) {
|
|
136
150
|
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
137
|
-
object =
|
|
151
|
+
object = _get_prototype_of(object);
|
|
138
152
|
if (object === null) break;
|
|
139
153
|
}
|
|
140
154
|
return object;
|
|
141
155
|
}
|
|
142
|
-
function
|
|
143
|
-
return
|
|
156
|
+
function _to_consumable_array(arr) {
|
|
157
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
144
158
|
}
|
|
145
|
-
|
|
159
|
+
function _type_of(obj) {
|
|
146
160
|
"@swc/helpers - typeof";
|
|
147
161
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
148
|
-
}
|
|
149
|
-
function
|
|
162
|
+
}
|
|
163
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
150
164
|
if (!o) return;
|
|
151
|
-
if (typeof o === "string") return
|
|
165
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
152
166
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
153
167
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
154
168
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
155
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
169
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
156
170
|
}
|
|
157
|
-
function
|
|
171
|
+
function _is_native_reflect_construct() {
|
|
158
172
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
159
173
|
if (Reflect.construct.sham) return false;
|
|
160
174
|
if (typeof Proxy === "function") return true;
|
|
@@ -165,17 +179,17 @@ function _isNativeReflectConstruct() {
|
|
|
165
179
|
return false;
|
|
166
180
|
}
|
|
167
181
|
}
|
|
168
|
-
function
|
|
169
|
-
var hasNativeReflectConstruct =
|
|
182
|
+
function _create_super(Derived) {
|
|
183
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
170
184
|
return function _createSuperInternal() {
|
|
171
|
-
var Super =
|
|
185
|
+
var Super = _get_prototype_of(Derived), result;
|
|
172
186
|
if (hasNativeReflectConstruct) {
|
|
173
|
-
var NewTarget =
|
|
187
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
174
188
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
175
189
|
} else {
|
|
176
190
|
result = Super.apply(this, arguments);
|
|
177
191
|
}
|
|
178
|
-
return
|
|
192
|
+
return _possible_constructor_return(this, result);
|
|
179
193
|
};
|
|
180
194
|
}
|
|
181
195
|
import { CONTROL_BASE_TYPE, error, genNonDuplicateId, isArray, isBuiltInControls, isObject, isString, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
|
|
@@ -191,25 +205,42 @@ var applyingPluginName = "";
|
|
|
191
205
|
* */ var Driven = /*#__PURE__*/ function(Watcher) {
|
|
192
206
|
"use strict";
|
|
193
207
|
_inherits(Driven, Watcher);
|
|
194
|
-
var _super =
|
|
208
|
+
var _super = _create_super(Driven);
|
|
195
209
|
function Driven(options) {
|
|
196
|
-
|
|
210
|
+
_class_call_check(this, Driven);
|
|
197
211
|
var _this;
|
|
198
212
|
_this = _super.call(this);
|
|
199
|
-
_this
|
|
200
|
-
_this
|
|
201
|
-
_this
|
|
213
|
+
_define_property(_assert_this_initialized(_this), "mode", void 0);
|
|
214
|
+
_define_property(_assert_this_initialized(_this), "isMounted", false);
|
|
215
|
+
_define_property(_assert_this_initialized(_this), "id", genNonDuplicateId(8));
|
|
216
|
+
/**
|
|
217
|
+
* 控件可选的事件
|
|
218
|
+
* */ _define_property(_assert_this_initialized(_this), "eventLogic", void 0);
|
|
219
|
+
/**
|
|
220
|
+
* 处理数据存储,存放模型等
|
|
221
|
+
* */ _define_property(_assert_this_initialized(_this), "store", void 0);
|
|
222
|
+
/**
|
|
223
|
+
* 额外参数存储
|
|
224
|
+
*/ _define_property(_assert_this_initialized(_this), "externalParams", void 0);
|
|
225
|
+
/**
|
|
226
|
+
* 处理instance,和schema存储
|
|
227
|
+
* */ _define_property(_assert_this_initialized(_this), "designer", void 0);
|
|
228
|
+
/**
|
|
229
|
+
* 插件数组
|
|
230
|
+
* */ _define_property(_assert_this_initialized(_this), "__plugins", void 0);
|
|
231
|
+
_define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
|
|
232
|
+
_define_property(_assert_this_initialized(_this), "$options", void 0);
|
|
202
233
|
// TODO 拿到schema
|
|
203
|
-
_this
|
|
234
|
+
_define_property(_assert_this_initialized(_this), "getSchema", toSchema);
|
|
204
235
|
// TODO 拿到model_bind_info_list
|
|
205
|
-
_this
|
|
236
|
+
_define_property(_assert_this_initialized(_this), "getModelBindInfoList", getModelBindInfoList);
|
|
206
237
|
// TODO 拿到permission_controls
|
|
207
|
-
_this
|
|
238
|
+
_define_property(_assert_this_initialized(_this), "generatePermissions", generatePermissions);
|
|
208
239
|
_this.$options = Object.freeze(options);
|
|
209
240
|
var _this_$options = _this.$options, _this_$options_autoMount = _this_$options.autoMount, autoMount = _this_$options_autoMount === void 0 ? false : _this_$options_autoMount, tmp = _this_$options.Designer, DesignerClass = tmp === void 0 ? Designer : tmp, schema = _this_$options.schema, _this_$options_mode = _this_$options.mode, mode = _this_$options_mode === void 0 ? "form" : _this_$options_mode, tmp1 = _this_$options.store, storeOptions = tmp1 === void 0 ? {} : tmp1;
|
|
210
241
|
_this.eventLogic = new EventLogic();
|
|
211
242
|
_this.designer = new DesignerClass();
|
|
212
|
-
_this.store = new Store(
|
|
243
|
+
_this.store = new Store(_object_spread({
|
|
213
244
|
instance: _this.designer.createControl(Array.isArray(schema) ? schema : [
|
|
214
245
|
schema
|
|
215
246
|
])
|
|
@@ -218,417 +249,565 @@ var applyingPluginName = "";
|
|
|
218
249
|
autoMount && _this.mount();
|
|
219
250
|
return _this;
|
|
220
251
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
if (!this.__pluginsApplied) {
|
|
231
|
-
this.__plugins.push(plugin);
|
|
232
|
-
}
|
|
233
|
-
return this;
|
|
234
|
-
};
|
|
235
|
-
_proto.applyPlugins = function applyPlugins() {
|
|
236
|
-
var _this = this;
|
|
237
|
-
if (this.__pluginsApplied) return;
|
|
238
|
-
this.__plugins.forEach(function(plugin) {
|
|
239
|
-
try {
|
|
240
|
-
var _plugin_pluginName;
|
|
241
|
-
applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
|
|
242
|
-
plugin.apply(_this);
|
|
243
|
-
applyingPluginName = "";
|
|
244
|
-
} catch (e) {
|
|
245
|
-
error("".concat(applyingPluginName || plugin.constructor.name, " Plugin apply Error \n ").concat(e));
|
|
252
|
+
_create_class(Driven, [
|
|
253
|
+
{
|
|
254
|
+
key: "mount",
|
|
255
|
+
value: // 挂载
|
|
256
|
+
function mount() {
|
|
257
|
+
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
258
|
+
this.__plugins = plugins;
|
|
259
|
+
this.applyPlugins();
|
|
260
|
+
this.isMounted = true;
|
|
246
261
|
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if (!instance) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
this.setSelectedInstanceSetting();
|
|
275
|
-
this.emit("select", {
|
|
276
|
-
instance: instance
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
_proto.setSelectedInstanceSetting = function setSelectedInstanceSetting() {
|
|
280
|
-
var _instance_parent;
|
|
281
|
-
var instance = this.store.selected;
|
|
282
|
-
if (!instance) {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
var setting = this.getControlSetting(instance.type);
|
|
286
|
-
// console.log('iswrap:', instance.parent?.controlType, instance.parent)
|
|
287
|
-
// if (instance.parent instanceof DesignerWrapControl) {
|
|
288
|
-
if (((_instance_parent = instance.parent) === null || _instance_parent === void 0 ? void 0 : _instance_parent.controlType) === CONTROL_BASE_TYPE.WRAP) {
|
|
289
|
-
var _instance_parent1;
|
|
290
|
-
var wrapSetting = this.getControlSetting((_instance_parent1 = instance.parent) === null || _instance_parent1 === void 0 ? void 0 : _instance_parent1.type);
|
|
291
|
-
setting = this.concatSetting(setting, wrapSetting, instance.parent.id);
|
|
292
|
-
}
|
|
293
|
-
this.store.setSelectInstanceSettings(setting);
|
|
294
|
-
this.callSelectedEffect("");
|
|
295
|
-
// 选中触发scopeEffect
|
|
296
|
-
var payload = {
|
|
297
|
-
from: null,
|
|
298
|
-
current: this.store.selectedInstanceDataScopeParent,
|
|
299
|
-
oldParent: null,
|
|
300
|
-
newParent: instance.parent
|
|
301
|
-
};
|
|
302
|
-
this.callSelectedScopeEffect(payload);
|
|
303
|
-
};
|
|
304
|
-
_proto.concatSetting = function concatSetting(settings, otherSettings, settingFromId) {
|
|
305
|
-
var _this = this;
|
|
306
|
-
var _settings_, _otherSettings_, _settings_1, _otherSettings_1;
|
|
307
|
-
var result = settings;
|
|
308
|
-
// tab
|
|
309
|
-
if (((_settings_ = settings[0]) === null || _settings_ === void 0 ? void 0 : _settings_.type) === "tab" && ((_otherSettings_ = otherSettings[0]) === null || _otherSettings_ === void 0 ? void 0 : _otherSettings_.type) === "tab") {
|
|
310
|
-
var tabSettings = settings;
|
|
311
|
-
var otherTabSettings = otherSettings.slice(0);
|
|
312
|
-
result = tabSettings.map(function(tab, index) {
|
|
313
|
-
var result = new Tab(tab);
|
|
314
|
-
var otherTabIndex = otherTabSettings.findIndex(function(item) {
|
|
315
|
-
return item.title === tab.title;
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
key: "use",
|
|
265
|
+
value: function use(plugin) {
|
|
266
|
+
if (!this.__pluginsApplied) {
|
|
267
|
+
this.__plugins.push(plugin);
|
|
268
|
+
}
|
|
269
|
+
return this;
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
key: "applyPlugins",
|
|
274
|
+
value: function applyPlugins() {
|
|
275
|
+
var _this = this;
|
|
276
|
+
if (this.__pluginsApplied) return;
|
|
277
|
+
this.__plugins.forEach(function(plugin) {
|
|
278
|
+
try {
|
|
279
|
+
var _plugin_pluginName;
|
|
280
|
+
applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
|
|
281
|
+
plugin.apply(_this);
|
|
282
|
+
applyingPluginName = "";
|
|
283
|
+
} catch (e) {
|
|
284
|
+
error("".concat(applyingPluginName || plugin.constructor.name, " Plugin apply Error \n ").concat(e));
|
|
285
|
+
}
|
|
316
286
|
});
|
|
317
|
-
|
|
318
|
-
|
|
287
|
+
this.__pluginsApplied = true;
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
key: "emit",
|
|
292
|
+
value: function emit(key) {
|
|
293
|
+
for(var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
294
|
+
payload[_key - 1] = arguments[_key];
|
|
319
295
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
296
|
+
return _get(_get_prototype_of(Driven.prototype), "emit", this).call(this, key, payload);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
key: "on",
|
|
301
|
+
value: function on(key, callback) {
|
|
302
|
+
return _get(_get_prototype_of(Driven.prototype), "on", this).call(this, key, callback);
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
key: "setInstances",
|
|
307
|
+
value: function setInstances(schema, beforeCreateInstance) {
|
|
308
|
+
this.store.setInstances(this.designer.createControl(Array.isArray(schema) ? schema : [
|
|
309
|
+
schema
|
|
310
|
+
], beforeCreateInstance));
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
key: "beforeSelectInstance",
|
|
315
|
+
value: function beforeSelectInstance() {
|
|
316
|
+
this.store.setSelectInstance(null);
|
|
317
|
+
this.setSelectedFieldItem(null);
|
|
318
|
+
this.store.setSelectInstanceSettings([]);
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
key: "afterSelectInstance",
|
|
323
|
+
value: function afterSelectInstance() {
|
|
324
|
+
var instance = this.store.selected;
|
|
325
|
+
if (!instance) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
this.setSelectedInstanceSetting();
|
|
329
|
+
this.emit("select", {
|
|
330
|
+
instance: instance
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
key: "setSelectedInstanceSetting",
|
|
336
|
+
value: function setSelectedInstanceSetting() {
|
|
337
|
+
var _instance_parent;
|
|
338
|
+
var instance = this.store.selected;
|
|
339
|
+
if (!instance) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
var setting = this.getControlSetting(instance.type);
|
|
343
|
+
// console.log('iswrap:', instance.parent?.controlType, instance.parent)
|
|
344
|
+
// if (instance.parent instanceof DesignerWrapControl) {
|
|
345
|
+
// 如果父控件为自定义控件wrapper
|
|
346
|
+
if (((_instance_parent = instance.parent) === null || _instance_parent === void 0 ? void 0 : _instance_parent.controlType) === CONTROL_BASE_TYPE.WRAP) {
|
|
347
|
+
var _instance_parent1;
|
|
348
|
+
var wrapSetting = this.getControlSetting((_instance_parent1 = instance.parent) === null || _instance_parent1 === void 0 ? void 0 : _instance_parent1.type);
|
|
349
|
+
setting = this.concatSetting(setting, wrapSetting, instance.parent.id);
|
|
350
|
+
}
|
|
351
|
+
this.store.setSelectInstanceSettings(setting);
|
|
352
|
+
this.callSelectedEffect("");
|
|
353
|
+
// 选中触发scopeEffect
|
|
354
|
+
var payload = {
|
|
355
|
+
from: null,
|
|
356
|
+
current: this.store.selectedInstanceDataScopeParent,
|
|
357
|
+
oldParent: null,
|
|
358
|
+
newParent: instance.parent
|
|
359
|
+
};
|
|
360
|
+
this.callSelectedScopeEffect(payload);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
key: "concatSetting",
|
|
365
|
+
value: function concatSetting(settings, otherSettings, settingFromId) {
|
|
366
|
+
var _this = this;
|
|
367
|
+
var _settings_, _otherSettings_, _settings_1, _otherSettings_1, _settings_2, _otherSettings_2, _settings_3, _otherSettings_3;
|
|
368
|
+
var result = settings;
|
|
369
|
+
// tab
|
|
370
|
+
if (((_settings_ = settings[0]) === null || _settings_ === void 0 ? void 0 : _settings_.type) === "tab" && ((_otherSettings_ = otherSettings[0]) === null || _otherSettings_ === void 0 ? void 0 : _otherSettings_.type) === "tab") {
|
|
371
|
+
var tabSettings = settings;
|
|
372
|
+
var otherTabSettings = otherSettings.slice(0);
|
|
373
|
+
result = tabSettings.map(function(tab, index) {
|
|
374
|
+
var result = new Tab(tab);
|
|
375
|
+
var otherTabIndex = otherTabSettings.findIndex(function(item) {
|
|
376
|
+
return item.title === tab.title;
|
|
377
|
+
});
|
|
378
|
+
if (otherTabIndex === -1) {
|
|
379
|
+
return result;
|
|
380
|
+
}
|
|
381
|
+
var otherTab = otherTabSettings.splice(otherTabIndex, 1)[0];
|
|
382
|
+
if (otherTab) {
|
|
383
|
+
result.items = _to_consumable_array(_this.formatGroupSetting(otherTab.items, settingFromId)).concat(_to_consumable_array(result.items));
|
|
384
|
+
}
|
|
385
|
+
return result;
|
|
386
|
+
});
|
|
387
|
+
if (otherTabSettings.length) {
|
|
388
|
+
result = _to_consumable_array(result).concat(_to_consumable_array(otherTabSettings.map(function(item) {
|
|
389
|
+
return _this.formatGroupSetting(item, settingFromId);
|
|
390
|
+
})));
|
|
391
|
+
}
|
|
392
|
+
// group
|
|
393
|
+
} else if (((_settings_1 = settings[0]) === null || _settings_1 === void 0 ? void 0 : _settings_1.type) === "group" && ((_otherSettings_1 = otherSettings[0]) === null || _otherSettings_1 === void 0 ? void 0 : _otherSettings_1.type) === "group") {
|
|
394
|
+
var groupSettings = settings;
|
|
395
|
+
var otherGroupSettings = otherSettings;
|
|
396
|
+
result = _to_consumable_array(this.formatGroupSetting(otherGroupSettings, settingFromId)).concat(_to_consumable_array(groupSettings));
|
|
397
|
+
// 当前控件setting是tab,合并控件setting是group
|
|
398
|
+
} else if (((_settings_2 = settings[0]) === null || _settings_2 === void 0 ? void 0 : _settings_2.type) === "tab" && ((_otherSettings_2 = otherSettings[0]) === null || _otherSettings_2 === void 0 ? void 0 : _otherSettings_2.type) === "group") {
|
|
399
|
+
var tabSettings1 = settings;
|
|
400
|
+
var otherGroupSettings1 = otherSettings;
|
|
401
|
+
result = tabSettings1.map(function(tab, index) {
|
|
402
|
+
var result = new Tab(tab);
|
|
403
|
+
if (index === 0) {
|
|
404
|
+
result.items = _to_consumable_array(_this.formatGroupSetting(otherGroupSettings1, settingFromId)).concat(_to_consumable_array(result.items));
|
|
405
|
+
}
|
|
406
|
+
return result;
|
|
407
|
+
});
|
|
408
|
+
} else if (((_settings_3 = settings[0]) === null || _settings_3 === void 0 ? void 0 : _settings_3.type) === "group" && ((_otherSettings_3 = otherSettings[0]) === null || _otherSettings_3 === void 0 ? void 0 : _otherSettings_3.type) === "tab") {
|
|
409
|
+
var groupSettings1 = settings;
|
|
410
|
+
var otherTabSettings1 = otherSettings;
|
|
411
|
+
result = otherTabSettings1.map(function(tab, index) {
|
|
412
|
+
var result = new Tab(tab);
|
|
413
|
+
if (index === 0) {
|
|
414
|
+
result.items = _to_consumable_array(result.items).concat(_to_consumable_array(_this.formatGroupSetting(groupSettings1, settingFromId)));
|
|
415
|
+
}
|
|
416
|
+
return result;
|
|
417
|
+
});
|
|
323
418
|
}
|
|
324
419
|
return result;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
key: "formatGroupSetting",
|
|
424
|
+
value: function formatGroupSetting(tab, fromId) {
|
|
425
|
+
if (isArray(tab)) {
|
|
426
|
+
return tab.map(function(item) {
|
|
427
|
+
var group = new Group(item);
|
|
428
|
+
group.fromId = fromId;
|
|
429
|
+
return group;
|
|
430
|
+
});
|
|
431
|
+
} else {
|
|
432
|
+
var result = new Tab(tab);
|
|
433
|
+
result.items = this.formatGroupSetting(result.items, fromId);
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
key: "setControlConfig",
|
|
440
|
+
value: function setControlConfig() {
|
|
441
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
442
|
+
args[_key] = arguments[_key];
|
|
443
|
+
}
|
|
444
|
+
var _this_designer;
|
|
445
|
+
return (_this_designer = this.designer).registerControlConfig.apply(_this_designer, _to_consumable_array(args));
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
key: "getControlConfig",
|
|
450
|
+
value: function getControlConfig(control) {
|
|
451
|
+
return this.designer.getControlConfig(control);
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
key: "getControlSetting",
|
|
456
|
+
value: function getControlSetting(type) {
|
|
457
|
+
var settingInit = this.designer.getControlSetting(type);
|
|
458
|
+
if (!settingInit) {
|
|
459
|
+
return [];
|
|
460
|
+
}
|
|
461
|
+
return initSettings(settingInit);
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
key: "selectInstance",
|
|
466
|
+
value: function selectInstance(instance) {
|
|
467
|
+
// 先清空上一次的store
|
|
468
|
+
this.beforeSelectInstance();
|
|
469
|
+
// 选中一个控件
|
|
470
|
+
this.store.setSelectInstance(instance);
|
|
471
|
+
// 针对这一次选中的控件初始化一些内容,并触发事件
|
|
472
|
+
this.afterSelectInstance();
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
key: "setSelectedFieldItem",
|
|
477
|
+
value: function setSelectedFieldItem(fieldItem) {
|
|
478
|
+
this.store.setSelectedFieldItem(fieldItem);
|
|
479
|
+
this.callSelectedEffect("dataBind", {
|
|
480
|
+
fieldItem: fieldItem
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
key: "moveStart",
|
|
486
|
+
value: function moveStart(instance) {
|
|
487
|
+
// 移动之前,记录控件原始的位置和父级
|
|
488
|
+
var _instance = this.getInstance(instance);
|
|
489
|
+
if (_instance) {
|
|
490
|
+
this.store.setMovingInstance(_instance);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
key: "moveEnd",
|
|
496
|
+
value: function moveEnd() {
|
|
497
|
+
var instance = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.store.movingInstance;
|
|
498
|
+
var _this_store_selected;
|
|
499
|
+
if (instance === null) return;
|
|
500
|
+
var _instance = this.getInstance(instance);
|
|
501
|
+
if (!_instance) return;
|
|
502
|
+
/*
|
|
399
503
|
移动之后,拿到控件新的位置,并触发事件, 如果是新增的控件的话,就没有原始位置和父级,
|
|
400
504
|
事件是否区分move和add
|
|
401
505
|
move是从主表移动到子表或子表移动到主表才触发,还是所有移动都触发
|
|
402
506
|
*/ var oldDataScopeParent = this.store.movingInstanceOldDataScopeParent;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
};
|
|
428
|
-
_proto.createInstance = function createInstance(type, initSchema) {
|
|
429
|
-
return this.designer.createControlInstance(type, initSchema);
|
|
430
|
-
};
|
|
431
|
-
_proto.getInstance = function getInstance(instanceId) {
|
|
432
|
-
// if (instanceId instanceof DesignerControl) {
|
|
433
|
-
// return instanceId
|
|
434
|
-
// }
|
|
435
|
-
// return this.store.instanceIdMap.get(instanceId)
|
|
436
|
-
if (typeof instanceId === "string") {
|
|
437
|
-
return this.store.instanceIdMap.get(instanceId);
|
|
438
|
-
}
|
|
439
|
-
return instanceId;
|
|
440
|
-
};
|
|
441
|
-
_proto.getInstances = function getInstances() {
|
|
442
|
-
return this.store.flatInstances;
|
|
443
|
-
};
|
|
444
|
-
_proto.getInstancesFromType = function getInstancesFromType(type) {
|
|
445
|
-
return this.getInstances().filter(function(item) {
|
|
446
|
-
return item.type === type;
|
|
447
|
-
});
|
|
448
|
-
};
|
|
449
|
-
_proto.getDataScopeInstances = function getDataScopeInstances() {
|
|
450
|
-
return this.store.selectedDataScopeFlatInstances;
|
|
451
|
-
};
|
|
452
|
-
_proto.getDataScopeInstancesFromType = function getDataScopeInstancesFromType(type) {
|
|
453
|
-
return this.getDataScopeInstances().filter(function(item) {
|
|
454
|
-
return item.type === type;
|
|
455
|
-
});
|
|
456
|
-
};
|
|
457
|
-
_proto.updateInstancePropValue = function updateInstancePropValue(instance, propName, value, payload) {
|
|
458
|
-
var _this_store_selected;
|
|
459
|
-
var result = updateValueFromKeys(instance.props, propName, value);
|
|
460
|
-
if (!result) {
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
// 修改dataBind的时候要更新 fieldCodeMap
|
|
464
|
-
if (propName.startsWith("dataBind")) {
|
|
465
|
-
this.store.updateDataFieldCodeMap(instance);
|
|
466
|
-
}
|
|
467
|
-
if (instance.id === ((_this_store_selected = this.store.selected) === null || _this_store_selected === void 0 ? void 0 : _this_store_selected.id)) {
|
|
468
|
-
this.callSelectedEffect(propName, payload);
|
|
469
|
-
}
|
|
470
|
-
this.emit("updated", {
|
|
471
|
-
instance: instance,
|
|
472
|
-
propName: propName,
|
|
473
|
-
value: value
|
|
474
|
-
});
|
|
475
|
-
};
|
|
476
|
-
_proto.updateInstanceProps = function updateInstanceProps(instance, props, payload) {
|
|
477
|
-
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
|
|
478
|
-
var _this = this;
|
|
479
|
-
Object.entries(props).forEach(function(param) {
|
|
480
|
-
var _param = _slicedToArray(param, 2), key = _param[0], value = _param[1];
|
|
481
|
-
var propName = "".concat(prevKey ? prevKey + "." : "").concat(key);
|
|
482
|
-
if (isObject(value)) {
|
|
483
|
-
_this.updateInstanceProps(instance, value, payload, propName);
|
|
484
|
-
} else {
|
|
485
|
-
_this.updateInstancePropValue(instance, propName, value, payload);
|
|
507
|
+
var newDataScopeParent = findInstanceDataScopeParent(_instance);
|
|
508
|
+
var oldParent = this.store.movingInstanceOldParent;
|
|
509
|
+
var newParent = _instance.parent;
|
|
510
|
+
// 移动之后清空movingInstance
|
|
511
|
+
this.store.setMovingInstance(null);
|
|
512
|
+
if (_instance.id !== ((_this_store_selected = this.store.selected) === null || _this_store_selected === void 0 ? void 0 : _this_store_selected.id)) {
|
|
513
|
+
this.selectInstance(_instance);
|
|
514
|
+
} else {
|
|
515
|
+
this.store.setSelectInstance(_instance);
|
|
516
|
+
}
|
|
517
|
+
this.store.getFlatInstances();
|
|
518
|
+
// 结束以后
|
|
519
|
+
var payload = {
|
|
520
|
+
from: oldDataScopeParent,
|
|
521
|
+
current: newDataScopeParent,
|
|
522
|
+
oldParent: oldParent,
|
|
523
|
+
newParent: newParent
|
|
524
|
+
};
|
|
525
|
+
this.callSelectedScopeEffect(payload);
|
|
526
|
+
if (oldParent) {
|
|
527
|
+
this.emit("moved", _object_spread({}, payload));
|
|
528
|
+
} else {
|
|
529
|
+
this.emit("joined", _object_spread({}, payload));
|
|
530
|
+
}
|
|
486
531
|
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
key: "createInstance",
|
|
535
|
+
value: function createInstance(type, initSchema) {
|
|
536
|
+
return this.designer.createControlInstance(type, initSchema);
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
key: "getInstance",
|
|
541
|
+
value: function getInstance(instanceId) {
|
|
542
|
+
// if (instanceId instanceof DesignerControl) {
|
|
543
|
+
// return instanceId
|
|
544
|
+
// }
|
|
545
|
+
// return this.store.instanceIdMap.get(instanceId)
|
|
546
|
+
if (typeof instanceId === "string") {
|
|
547
|
+
return this.store.instanceIdMap.get(instanceId);
|
|
548
|
+
}
|
|
549
|
+
return instanceId;
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
key: "getInstances",
|
|
554
|
+
value: function getInstances() {
|
|
555
|
+
return this.store.flatInstances;
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
key: "getInstancesFromType",
|
|
560
|
+
value: function getInstancesFromType(type) {
|
|
561
|
+
return this.getInstances().filter(function(item) {
|
|
562
|
+
return item.type === type;
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
key: "getDataScopeInstances",
|
|
568
|
+
value: function getDataScopeInstances() {
|
|
569
|
+
return this.store.selectedDataScopeFlatInstances;
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
key: "getDataScopeInstancesFromType",
|
|
574
|
+
value: function getDataScopeInstancesFromType(type) {
|
|
575
|
+
return this.getDataScopeInstances().filter(function(item) {
|
|
576
|
+
return item.type === type;
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
key: "updateInstancePropValue",
|
|
582
|
+
value: function updateInstancePropValue(instance, propName, value, payload) {
|
|
583
|
+
var _this_store_selected;
|
|
584
|
+
var result = updateValueFromKeys(instance.props, propName, value);
|
|
585
|
+
if (!result) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
// 修改dataBind的时候要更新 fieldCodeMap
|
|
589
|
+
if (propName.startsWith("dataBind")) {
|
|
590
|
+
this.store.updateDataFieldCodeMap(instance);
|
|
591
|
+
}
|
|
592
|
+
if (instance.id === ((_this_store_selected = this.store.selected) === null || _this_store_selected === void 0 ? void 0 : _this_store_selected.id)) {
|
|
593
|
+
this.callSelectedEffect(propName, payload);
|
|
594
|
+
}
|
|
595
|
+
this.emit("updated", {
|
|
596
|
+
instance: instance,
|
|
597
|
+
propName: propName,
|
|
598
|
+
value: value
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
key: "updateInstanceProps",
|
|
604
|
+
value: function updateInstanceProps(instance, props, payload) {
|
|
605
|
+
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
|
|
606
|
+
var _this = this;
|
|
607
|
+
Object.entries(props).forEach(function(param) {
|
|
608
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
609
|
+
var propName = "".concat(prevKey ? prevKey + "." : "").concat(key);
|
|
610
|
+
if (isObject(value)) {
|
|
611
|
+
_this.updateInstanceProps(instance, value, payload, propName);
|
|
612
|
+
} else {
|
|
613
|
+
_this.updateInstancePropValue(instance, propName, value, payload);
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
key: "setInstance",
|
|
620
|
+
value: function setInstance(instance, propName, value, payload) {
|
|
621
|
+
if (isString(propName)) {
|
|
622
|
+
this.updateInstancePropValue(instance, String(propName), value, payload);
|
|
623
|
+
} else {
|
|
624
|
+
this.updateInstanceProps(instance, propName, value);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
key: "removeInstance",
|
|
630
|
+
value: /**
|
|
497
631
|
* 删除控件
|
|
498
|
-
* */
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
632
|
+
* */ function removeInstance(instance) {
|
|
633
|
+
// 删除实例,并触发事件 removed
|
|
634
|
+
var parent = instance.parent;
|
|
635
|
+
if (!parent) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
var parentList = // parent instanceof DesignerListControl &&
|
|
639
|
+
parent.controlType === CONTROL_BASE_TYPE.LIST && parent.props.headers.includes(instance) ? parent.props.headers : parent.children;
|
|
640
|
+
var index = parentList.findIndex(function(item) {
|
|
641
|
+
return item === instance;
|
|
642
|
+
});
|
|
643
|
+
index > -1 && parentList.splice(index, 1);
|
|
644
|
+
this.store.getFlatInstances();
|
|
645
|
+
this.emit("removed", {
|
|
646
|
+
instance: instance,
|
|
647
|
+
index: index,
|
|
648
|
+
parent: parent
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
key: "replaceInstance",
|
|
654
|
+
value: function replaceInstance(oldInstance, newInstance) {
|
|
655
|
+
var parent = oldInstance.parent;
|
|
656
|
+
if (!parent) {
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
var parentList = // parent instanceof DesignerListControl &&
|
|
660
|
+
parent.controlType === CONTROL_BASE_TYPE.LIST && parent.props.headers.includes(oldInstance) ? parent.props.headers : parent.children;
|
|
661
|
+
var index = parentList.findIndex(function(item) {
|
|
662
|
+
return item === oldInstance;
|
|
663
|
+
});
|
|
664
|
+
index > -1 && parentList.splice(index, 1, newInstance);
|
|
665
|
+
this.store.getFlatInstances();
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
key: "updateInstanceType",
|
|
670
|
+
value: /**
|
|
531
671
|
* 修改控件类型
|
|
532
|
-
* */
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
672
|
+
* */ function updateInstanceType(instance, type) {
|
|
673
|
+
var schema = instance.toSchema();
|
|
674
|
+
var newInstance = this.createInstance(type, {
|
|
675
|
+
id: schema.id,
|
|
676
|
+
props: schema.props
|
|
677
|
+
});
|
|
678
|
+
if (!newInstance) {
|
|
679
|
+
warn("can‘t update instance type to ".concat(type));
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
return newInstance;
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
key: "validate",
|
|
687
|
+
value: function validate(messages, ignore) {
|
|
688
|
+
//TODO 校验实例属性,并触发事件 before-validate 和 validated
|
|
689
|
+
return checkSchema(this.store.instance, messages, ignore);
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
key: "getCustomControlsInUse",
|
|
694
|
+
value: // 获取使用到的自定义控件
|
|
695
|
+
function getCustomControlsInUse() {
|
|
696
|
+
return this.getInstances().filter(this.assertInstanceIsCustomControl).reduce(function(result, item) {
|
|
697
|
+
if (!result.includes(item.type)) {
|
|
698
|
+
result.push(item.type);
|
|
699
|
+
}
|
|
700
|
+
return result;
|
|
701
|
+
}, []);
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
key: "assertInstanceIsCustomControl",
|
|
706
|
+
value: // 判断控件或控件类型是一个自定义控件
|
|
707
|
+
function assertInstanceIsCustomControl(instance) {
|
|
708
|
+
return !isBuiltInControls(isString(instance) ? instance : instance.type);
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
key: "judgeControlIsRegistered",
|
|
713
|
+
value: function judgeControlIsRegistered(control) {
|
|
714
|
+
return this.designer.registeredControlTypes.has(control.Designer.controlType);
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
key: "register",
|
|
719
|
+
value: function register() {
|
|
720
|
+
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
721
|
+
arg[_key] = arguments[_key];
|
|
722
|
+
}
|
|
723
|
+
var _this_designer;
|
|
724
|
+
(_this_designer = this.designer).registerControl.apply(_this_designer, _to_consumable_array(arg));
|
|
725
|
+
return this;
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
key: "assertInstance",
|
|
730
|
+
value: /**
|
|
573
731
|
* 判断控件的类型,返回当前控件的正确类型
|
|
574
|
-
* */
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
732
|
+
* */ function assertInstance(instance, types) {
|
|
733
|
+
return isString(types) ? instance.type === types : types.includes(instance.type);
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
key: "getInstanceInListControl",
|
|
738
|
+
value: /**
|
|
578
739
|
* 控件在列表控件内,如明细子表或列表控件
|
|
579
|
-
* */
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
740
|
+
* */ function getInstanceInListControl(instance) {
|
|
741
|
+
var _instance = instance;
|
|
742
|
+
while(_instance){
|
|
743
|
+
// if (_instance instanceof DesignerListControl) {
|
|
744
|
+
if (_instance.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
_instance = _instance.parent;
|
|
748
|
+
}
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
key: "getInstanceParentControl",
|
|
754
|
+
value: function getInstanceParentControl(instance, controlType) {
|
|
755
|
+
if (!instance.parent) {
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
if (this.assertInstance(instance.parent, controlType)) {
|
|
759
|
+
return instance.parent;
|
|
760
|
+
}
|
|
761
|
+
return this.getInstanceParentControl(instance.parent, controlType);
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
key: "callSelectedEffect",
|
|
766
|
+
value: function callSelectedEffect(effectKey) {
|
|
767
|
+
var payload = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
768
|
+
var _this = this;
|
|
769
|
+
this.store.selectedInstanceSettingItems.forEach(function(setting) {
|
|
770
|
+
setting.callEffect(effectKey, _this, _object_spread({
|
|
771
|
+
control: _this.store.selected
|
|
772
|
+
}, payload));
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
key: "callSelectedScopeEffect",
|
|
778
|
+
value: function callSelectedScopeEffect() {
|
|
779
|
+
var payload = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
780
|
+
var _this = this;
|
|
781
|
+
this.store.selectedInstanceSettingItems.forEach(function(setting) {
|
|
782
|
+
setting.callScopeEffect(_this, _object_spread({
|
|
783
|
+
control: _this.store.selected
|
|
784
|
+
}, payload));
|
|
785
|
+
});
|
|
786
|
+
}
|
|
596
787
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
};
|
|
617
|
-
// 注册外部控件
|
|
618
|
-
Driven.register = function register() {
|
|
619
|
-
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
620
|
-
arg[_key] = arguments[_key];
|
|
788
|
+
], [
|
|
789
|
+
{
|
|
790
|
+
key: "register",
|
|
791
|
+
value: // 注册外部控件
|
|
792
|
+
function register() {
|
|
793
|
+
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
794
|
+
arg[_key] = arguments[_key];
|
|
795
|
+
}
|
|
796
|
+
var _Designer;
|
|
797
|
+
(_Designer = Designer).register.apply(_Designer, _to_consumable_array(arg));
|
|
798
|
+
return this;
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
key: "judgeControlIsRegistered",
|
|
803
|
+
value: function judgeControlIsRegistered(control) {
|
|
804
|
+
return Designer.staticRegisteredTypes.has(control.Designer.controlType);
|
|
805
|
+
}
|
|
621
806
|
}
|
|
622
|
-
|
|
623
|
-
(_Designer = Designer).register.apply(_Designer, _toConsumableArray(arg));
|
|
624
|
-
return this;
|
|
625
|
-
};
|
|
626
|
-
Driven.judgeControlIsRegistered = function judgeControlIsRegistered(control) {
|
|
627
|
-
return Designer.staticRegisteredTypes.has(control.Designer.controlType);
|
|
628
|
-
};
|
|
807
|
+
]);
|
|
629
808
|
return Driven;
|
|
630
809
|
}(Watcher);
|
|
631
810
|
/**
|
|
632
811
|
* 控件事件定义
|
|
633
|
-
* */ Driven
|
|
812
|
+
* */ _define_property(Driven, "EventLogic", EventLogic);
|
|
634
813
|
export { Driven };
|