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