@byteluck-fe/model-driven-core 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/common/BaseControl/designer.js +259 -220
- package/dist/esm/common/BaseControl/property.js +68 -53
- package/dist/esm/common/BaseControl/runtime.js +37 -15
- package/dist/esm/common/ColumnControl/designer.js +39 -24
- package/dist/esm/common/ColumnControl/property.js +97 -48
- package/dist/esm/common/ColumnControl/runtime.js +39 -24
- package/dist/esm/common/ControlArray.js +12 -12
- package/dist/esm/common/FormControl/designer.js +42 -26
- package/dist/esm/common/FormControl/property.js +130 -69
- package/dist/esm/common/FormControl/runtime.js +40 -24
- package/dist/esm/common/LayoutControl/designer.js +151 -116
- package/dist/esm/common/LayoutControl/property.js +22 -22
- package/dist/esm/common/LayoutControl/runtime.js +41 -25
- package/dist/esm/common/ListControl/designer.js +141 -106
- package/dist/esm/common/ListControl/property.js +40 -23
- package/dist/esm/common/ListControl/runtime.js +43 -27
- package/dist/esm/common/SearchViewControl/designer.js +39 -24
- package/dist/esm/common/SearchViewControl/property.js +38 -23
- package/dist/esm/common/SearchViewControl/runtime.js +39 -24
- package/dist/esm/common/WrapControl/designer.js +39 -24
- package/dist/esm/common/WrapControl/property.js +22 -22
- package/dist/esm/common/WrapControl/runtime.js +39 -24
- package/dist/esm/framework/RegisterControls.js +215 -130
- package/dist/esm/framework/index.js +714 -248
- package/dist/esm/framework/isDataBind.js +8 -0
- package/dist/esm/index.js +1 -0
- package/dist/index.umd.js +1 -1
- package/dist/types/common/ColumnControl/property.d.ts +1 -1
- package/dist/types/common/ListControl/property.d.ts +2 -0
- package/dist/types/framework/index.d.ts +3 -2
- package/dist/types/framework/isDataBind.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +3 -3
|
@@ -1,13 +1,13 @@
|
|
|
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
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
13
|
try {
|
|
@@ -23,7 +23,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
23
23
|
Promise.resolve(value).then(_next, _throw);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function _async_to_generator(fn) {
|
|
27
27
|
return function() {
|
|
28
28
|
var self = this, args = arguments;
|
|
29
29
|
return new Promise(function(resolve, reject) {
|
|
@@ -38,7 +38,7 @@ function _asyncToGenerator(fn) {
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function _class_call_check(instance, Constructor) {
|
|
42
42
|
if (!(instance instanceof Constructor)) {
|
|
43
43
|
throw new TypeError("Cannot call a class as a function");
|
|
44
44
|
}
|
|
@@ -52,12 +52,12 @@ function _defineProperties(target, props) {
|
|
|
52
52
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
56
56
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
57
57
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
58
58
|
return Constructor;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function _define_property(obj, key, value) {
|
|
61
61
|
if (key in obj) {
|
|
62
62
|
Object.defineProperty(obj, key, {
|
|
63
63
|
value: value,
|
|
@@ -77,16 +77,16 @@ function _instanceof(left, right) {
|
|
|
77
77
|
return left instanceof right;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function _iterable_to_array(iter) {
|
|
81
81
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function _non_iterable_rest() {
|
|
84
84
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function _non_iterable_spread() {
|
|
87
87
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function _object_spread(target) {
|
|
90
90
|
for(var i = 1; i < arguments.length; i++){
|
|
91
91
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
92
92
|
var ownKeys = Object.keys(source);
|
|
@@ -96,26 +96,26 @@ function _objectSpread(target) {
|
|
|
96
96
|
}));
|
|
97
97
|
}
|
|
98
98
|
ownKeys.forEach(function(key) {
|
|
99
|
-
|
|
99
|
+
_define_property(target, key, source[key]);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
return target;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
return
|
|
104
|
+
function _to_array(arr) {
|
|
105
|
+
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
107
|
+
function _to_consumable_array(arr) {
|
|
108
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
111
111
|
if (!o) return;
|
|
112
|
-
if (typeof o === "string") return
|
|
112
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
113
113
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
114
114
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
115
115
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
116
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
116
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
function _ts_generator(thisArg, body) {
|
|
119
119
|
var f, y, t, g, _ = {
|
|
120
120
|
label: 0,
|
|
121
121
|
sent: function() {
|
|
@@ -209,7 +209,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
209
209
|
done: true
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
-
}
|
|
212
|
+
}
|
|
213
213
|
import Property from "./property";
|
|
214
214
|
import { genNonDuplicateId, JSONCopy, referenceError, updateValueFromKeys } from "@byteluck-fe/model-driven-shared";
|
|
215
215
|
import { createValidator } from "../Validator";
|
|
@@ -218,237 +218,277 @@ var Control = /*#__PURE__*/ function _target() {
|
|
|
218
218
|
"use strict";
|
|
219
219
|
function Control(props) {
|
|
220
220
|
var _this = this;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
this
|
|
224
|
-
|
|
225
|
-
this
|
|
226
|
-
this
|
|
227
|
-
this
|
|
221
|
+
_class_call_check(this, Control);
|
|
222
|
+
var _props, _props1, _props2, _props3, _props4;
|
|
223
|
+
_define_property(this, "id", void 0 // 唯一标识符
|
|
224
|
+
);
|
|
225
|
+
_define_property(this, "name", void 0);
|
|
226
|
+
_define_property(this, "icon", void 0);
|
|
227
|
+
_define_property(this, "type", void 0);
|
|
228
|
+
_define_property(this, "controlType", void 0);
|
|
229
|
+
_define_property(this, "props", void 0);
|
|
230
|
+
_define_property(this, "setting", []);
|
|
231
|
+
_define_property(this, "fieldType", void 0);
|
|
232
|
+
_define_property(this, "eventKeys", []);
|
|
233
|
+
_define_property(this, "customEvents", []);
|
|
234
|
+
_define_property(this, "parent", null);
|
|
235
|
+
_define_property(this, "updateSetting", updateSetting);
|
|
236
|
+
_define_property(this, "removeSetting", removeSetting);
|
|
228
237
|
this._callControlHooks("preInstance", props);
|
|
229
238
|
var _ref = _instanceof(this, Control) ? this.constructor : void 0, controlName = _ref.controlName, controlIcon = _ref.controlIcon, controlType = _ref.controlType, controlFieldType = _ref.controlFieldType, controlEventKeys = _ref.controlEventKeys, controlCustomEvents = _ref.controlCustomEvents, name = _ref.name, setting = _ref.setting;
|
|
230
239
|
if (!(controlName && controlIcon && controlType)) {
|
|
231
240
|
referenceError("The ".concat(name, " controlName,controlIcon,controlType is not define"));
|
|
232
241
|
}
|
|
233
242
|
var _props_id;
|
|
234
|
-
this.id = (_props_id = props === null ||
|
|
243
|
+
this.id = (_props_id = (_props = props) === null || _props === void 0 ? void 0 : _props.id) !== null && _props_id !== void 0 ? _props_id : genNonDuplicateId(10);
|
|
235
244
|
this.name = controlName;
|
|
236
245
|
this.icon = controlIcon;
|
|
237
246
|
var _props_type;
|
|
238
|
-
this.type = (_props_type = props === null ||
|
|
239
|
-
this.props = new Property(props === null ||
|
|
247
|
+
this.type = (_props_type = (_props1 = props) === null || _props1 === void 0 ? void 0 : _props1.type) !== null && _props_type !== void 0 ? _props_type : controlType;
|
|
248
|
+
this.props = new Property((_props2 = props) === null || _props2 === void 0 ? void 0 : _props2.props, (_instanceof(this, Control) ? this.constructor : void 0).controlName);
|
|
240
249
|
var _props_controlType;
|
|
241
|
-
this.controlType = (_props_controlType = props === null ||
|
|
250
|
+
this.controlType = (_props_controlType = (_props3 = props) === null || _props3 === void 0 ? void 0 : _props3.controlType) !== null && _props_controlType !== void 0 ? _props_controlType : "base";
|
|
242
251
|
this.setting = JSONCopy(setting);
|
|
243
252
|
var _props_fieldType;
|
|
244
|
-
this.fieldType = (_props_fieldType = props === null ||
|
|
253
|
+
this.fieldType = (_props_fieldType = (_props4 = props) === null || _props4 === void 0 ? void 0 : _props4.fieldType) !== null && _props_fieldType !== void 0 ? _props_fieldType : controlFieldType;
|
|
245
254
|
this.eventKeys = JSONCopy(controlEventKeys);
|
|
246
255
|
this.customEvents = JSONCopy(controlCustomEvents);
|
|
247
256
|
Promise.resolve().then(function() {
|
|
248
257
|
_this._callControlHooks("postInstance", props);
|
|
249
258
|
});
|
|
250
259
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return (_controlHooksEmitter = controlHooksEmitter).emit.apply(_controlHooksEmitter, [
|
|
259
|
-
key,
|
|
260
|
-
this
|
|
261
|
-
].concat(_toConsumableArray(arg)));
|
|
262
|
-
};
|
|
263
|
-
_proto.preUpdate = function preUpdate(key, value) {
|
|
264
|
-
// 在修改props之前
|
|
265
|
-
this._callControlHooks("preUpdateProps", key, value);
|
|
266
|
-
};
|
|
267
|
-
_proto.postUpdate = function postUpdate(key, value) {
|
|
268
|
-
// 在修改props之后
|
|
269
|
-
this._callControlHooks("postUpdateProps", key, value);
|
|
270
|
-
};
|
|
271
|
-
// 修改实例上的props,key可以是caption,caption.zh...
|
|
272
|
-
_proto.updateProps = function updateProps(key, value) {
|
|
273
|
-
this.preUpdate(key, value);
|
|
274
|
-
updateValueFromKeys(this.props, key, value);
|
|
275
|
-
this.postUpdate(key, value);
|
|
276
|
-
};
|
|
277
|
-
_proto.preValidate = function preValidate() {
|
|
278
|
-
var _this = this;
|
|
279
|
-
return _asyncToGenerator(function() {
|
|
280
|
-
var rules, results, result;
|
|
281
|
-
return __generator(this, function(_state) {
|
|
282
|
-
switch(_state.label){
|
|
283
|
-
case 0:
|
|
284
|
-
rules = _objectSpread({}, _this.rules);
|
|
285
|
-
return [
|
|
286
|
-
4,
|
|
287
|
-
_this._callControlHooks("preValidate", rules)
|
|
288
|
-
];
|
|
289
|
-
case 1:
|
|
290
|
-
results = _state.sent();
|
|
291
|
-
result = results[results.length - 1];
|
|
292
|
-
return [
|
|
293
|
-
2,
|
|
294
|
-
result === false ? undefined : result
|
|
295
|
-
];
|
|
260
|
+
_create_class(Control, [
|
|
261
|
+
{
|
|
262
|
+
key: "rules",
|
|
263
|
+
get: function get() {
|
|
264
|
+
var Rules = this.props.constructor.Rules;
|
|
265
|
+
if (Rules) {
|
|
266
|
+
return new Rules(this.props);
|
|
296
267
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
268
|
+
return {};
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
key: "_callControlHooks",
|
|
273
|
+
value: function _callControlHooks() {
|
|
274
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
275
|
+
args[_key] = arguments[_key];
|
|
276
|
+
}
|
|
277
|
+
var _controlHooksEmitter;
|
|
278
|
+
var _args = _to_array(args), key = _args[0], arg = _args.slice(1);
|
|
279
|
+
return (_controlHooksEmitter = controlHooksEmitter).emit.apply(_controlHooksEmitter, [
|
|
280
|
+
key,
|
|
281
|
+
this
|
|
282
|
+
].concat(_to_consumable_array(arg)));
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
key: "preUpdate",
|
|
287
|
+
value: function preUpdate(key, value) {
|
|
288
|
+
// 在修改props之前
|
|
289
|
+
this._callControlHooks("preUpdateProps", key, value);
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
key: "postUpdate",
|
|
294
|
+
value: function postUpdate(key, value) {
|
|
295
|
+
// 在修改props之后
|
|
296
|
+
this._callControlHooks("postUpdateProps", key, value);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
key: "updateProps",
|
|
301
|
+
value: // 修改实例上的props,key可以是caption,caption.zh...
|
|
302
|
+
function updateProps(key, value) {
|
|
303
|
+
this.preUpdate(key, value);
|
|
304
|
+
updateValueFromKeys(this.props, key, value);
|
|
305
|
+
this.postUpdate(key, value);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
key: "preValidate",
|
|
310
|
+
value: function preValidate() {
|
|
311
|
+
var _this = this;
|
|
312
|
+
return _async_to_generator(function() {
|
|
313
|
+
var rules, results, result;
|
|
314
|
+
return _ts_generator(this, function(_state) {
|
|
315
|
+
switch(_state.label){
|
|
316
|
+
case 0:
|
|
317
|
+
rules = _object_spread({}, _this.rules);
|
|
318
|
+
return [
|
|
319
|
+
4,
|
|
320
|
+
_this._callControlHooks("preValidate", rules)
|
|
321
|
+
];
|
|
322
|
+
case 1:
|
|
323
|
+
results = _state.sent();
|
|
324
|
+
result = results[results.length - 1];
|
|
325
|
+
return [
|
|
326
|
+
2,
|
|
327
|
+
result === false ? undefined : result
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
})();
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
key: "validate",
|
|
336
|
+
value: // property校验
|
|
337
|
+
function validate(messages, ignore) {
|
|
338
|
+
var _this = this;
|
|
339
|
+
return _async_to_generator(function() {
|
|
340
|
+
var result, rules, validator, err;
|
|
341
|
+
return _ts_generator(this, function(_state) {
|
|
342
|
+
switch(_state.label){
|
|
343
|
+
case 0:
|
|
344
|
+
return [
|
|
345
|
+
4,
|
|
346
|
+
_this.preValidate()
|
|
347
|
+
];
|
|
348
|
+
case 1:
|
|
349
|
+
result = _state.sent();
|
|
350
|
+
rules = result !== undefined ? result : _object_spread({}, _this.rules);
|
|
351
|
+
if (Array.isArray(ignore)) {
|
|
352
|
+
ignore.forEach(function(key) {
|
|
353
|
+
if (rules.hasOwnProperty(key)) {
|
|
354
|
+
delete rules[key];
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
validator = createValidator(rules, messages);
|
|
359
|
+
_state.label = 2;
|
|
360
|
+
case 2:
|
|
361
|
+
_state.trys.push([
|
|
362
|
+
2,
|
|
363
|
+
4,
|
|
364
|
+
,
|
|
365
|
+
5
|
|
366
|
+
]);
|
|
367
|
+
return [
|
|
368
|
+
4,
|
|
369
|
+
validator.validate(_this.props)
|
|
370
|
+
];
|
|
371
|
+
case 3:
|
|
372
|
+
_state.sent();
|
|
373
|
+
return [
|
|
374
|
+
2,
|
|
375
|
+
true
|
|
376
|
+
];
|
|
377
|
+
case 4:
|
|
378
|
+
err = _state.sent();
|
|
379
|
+
if (!err.control) {
|
|
380
|
+
err.control = _this;
|
|
319
381
|
}
|
|
320
|
-
|
|
382
|
+
throw err;
|
|
383
|
+
case 5:
|
|
384
|
+
return [
|
|
385
|
+
2
|
|
386
|
+
];
|
|
321
387
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
388
|
+
});
|
|
389
|
+
})();
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
key: "toDataBindModel",
|
|
394
|
+
value: function toDataBindModel() {
|
|
395
|
+
var parentId = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
396
|
+
var fieldType = this.fieldType;
|
|
397
|
+
var controlId = this.id;
|
|
398
|
+
var type = this.type;
|
|
399
|
+
var _this_props = this.props, dataBind = _this_props.dataBind, datasourceBind = _this_props.datasourceBind, optionConfig = _this_props.optionConfig, caption = _this_props.caption, required = _this_props.required, maxLength = _this_props.maxLength, options = _this_props.options, encrypted = _this_props.encrypted, encryptedMode = _this_props.encryptedMode;
|
|
400
|
+
if (!fieldType && !dataBind && !datasourceBind) return;
|
|
401
|
+
var dataBindModelType = {
|
|
402
|
+
parentId: parentId,
|
|
403
|
+
fieldType: fieldType,
|
|
404
|
+
controlId: controlId,
|
|
405
|
+
caption: caption,
|
|
406
|
+
type: type,
|
|
407
|
+
props: {}
|
|
408
|
+
};
|
|
409
|
+
if (dataBind) {
|
|
410
|
+
dataBindModelType.dataBind = dataBind;
|
|
411
|
+
}
|
|
412
|
+
switch(optionConfig){
|
|
413
|
+
case "datasource":
|
|
414
|
+
case undefined:
|
|
415
|
+
if (datasourceBind) {
|
|
416
|
+
dataBindModelType.datasourceBind = datasourceBind;
|
|
345
417
|
}
|
|
346
|
-
|
|
347
|
-
case
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
];
|
|
418
|
+
break;
|
|
419
|
+
case "custom":
|
|
420
|
+
dataBindModelType.props.options = options;
|
|
421
|
+
break;
|
|
351
422
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
};
|
|
355
|
-
_proto.toDataBindModel = function toDataBindModel() {
|
|
356
|
-
var parentId = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
357
|
-
var fieldType = this.fieldType;
|
|
358
|
-
var controlId = this.id;
|
|
359
|
-
var type = this.type;
|
|
360
|
-
var _this_props = this.props, dataBind = _this_props.dataBind, datasourceBind = _this_props.datasourceBind, optionConfig = _this_props.optionConfig, caption = _this_props.caption, required = _this_props.required, maxLength = _this_props.maxLength, options = _this_props.options, encrypted = _this_props.encrypted, encryptedMode = _this_props.encryptedMode;
|
|
361
|
-
if (!fieldType && !dataBind && !datasourceBind) return;
|
|
362
|
-
var dataBindModelType = {
|
|
363
|
-
parentId: parentId,
|
|
364
|
-
fieldType: fieldType,
|
|
365
|
-
controlId: controlId,
|
|
366
|
-
caption: caption,
|
|
367
|
-
type: type,
|
|
368
|
-
props: {}
|
|
369
|
-
};
|
|
370
|
-
if (dataBind) {
|
|
371
|
-
dataBindModelType.dataBind = dataBind;
|
|
372
|
-
}
|
|
373
|
-
switch(optionConfig){
|
|
374
|
-
case "datasource":
|
|
375
|
-
case undefined:
|
|
376
|
-
if (datasourceBind) {
|
|
377
|
-
dataBindModelType.datasourceBind = datasourceBind;
|
|
423
|
+
if (required !== undefined) {
|
|
424
|
+
dataBindModelType.required = required;
|
|
378
425
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
};
|
|
411
|
-
};
|
|
412
|
-
Control.updateBasicControl = function updateBasicControl(key, setting) {
|
|
413
|
-
if (key !== "setting") return;
|
|
414
|
-
if (setting.add) {
|
|
415
|
-
var _this_setting;
|
|
416
|
-
(_this_setting = this.setting).push.apply(_this_setting, _toConsumableArray(setting.add));
|
|
417
|
-
}
|
|
418
|
-
if (setting.remove) {
|
|
419
|
-
this.removeSettingItem(setting.remove);
|
|
420
|
-
}
|
|
421
|
-
if (setting.update) {
|
|
422
|
-
// this.updateSettingItem(setting.update, false)
|
|
426
|
+
if (maxLength !== undefined) {
|
|
427
|
+
dataBindModelType.maxLength = maxLength;
|
|
428
|
+
}
|
|
429
|
+
if (encrypted !== undefined) {
|
|
430
|
+
dataBindModelType.encrypted = encrypted;
|
|
431
|
+
}
|
|
432
|
+
if (encryptedMode !== undefined) {
|
|
433
|
+
dataBindModelType.encryptedMode = encryptedMode;
|
|
434
|
+
}
|
|
435
|
+
return dataBindModelType;
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
key: "preToSchema",
|
|
440
|
+
value: function preToSchema() {
|
|
441
|
+
// 在处理Schema之前,预留的钩子函数,允许在toSchema之前处理一些数据
|
|
442
|
+
this._callControlHooks("preToSchema", this);
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
key: "toSchema",
|
|
447
|
+
value: function toSchema() {
|
|
448
|
+
this.preToSchema();
|
|
449
|
+
return {
|
|
450
|
+
id: this.id,
|
|
451
|
+
type: this.type,
|
|
452
|
+
props: JSONCopy(this.props),
|
|
453
|
+
fieldType: this.fieldType,
|
|
454
|
+
controlType: this.controlType
|
|
455
|
+
};
|
|
456
|
+
}
|
|
423
457
|
}
|
|
424
|
-
|
|
425
|
-
_createClass(Control, [
|
|
458
|
+
], [
|
|
426
459
|
{
|
|
427
|
-
key: "
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
if (
|
|
431
|
-
|
|
460
|
+
key: "updateBasicControl",
|
|
461
|
+
value: function updateBasicControl(key, setting) {
|
|
462
|
+
if (key !== "setting") return;
|
|
463
|
+
if (setting.add) {
|
|
464
|
+
var _this_setting;
|
|
465
|
+
(_this_setting = this.setting).push.apply(_this_setting, _to_consumable_array(setting.add));
|
|
466
|
+
}
|
|
467
|
+
if (setting.remove) {
|
|
468
|
+
this.removeSettingItem(setting.remove);
|
|
469
|
+
}
|
|
470
|
+
if (setting.update) {
|
|
471
|
+
// this.updateSettingItem(setting.update, false)
|
|
432
472
|
}
|
|
433
|
-
return {};
|
|
434
473
|
}
|
|
435
474
|
}
|
|
436
475
|
]);
|
|
437
476
|
return Control;
|
|
438
477
|
}();
|
|
439
|
-
Control
|
|
440
|
-
Control
|
|
441
|
-
Control
|
|
478
|
+
_define_property(Control, "controlName", "控件");
|
|
479
|
+
_define_property(Control, "controlIcon", "icon");
|
|
480
|
+
_define_property(Control, "controlType", "control");
|
|
481
|
+
_define_property(Control, "controlFieldType", void 0);
|
|
442
482
|
// 控件可以触发的事件key
|
|
443
|
-
Control
|
|
444
|
-
Control
|
|
483
|
+
_define_property(Control, "controlEventKeys", []);
|
|
484
|
+
_define_property(Control, "controlCustomEvents", []);
|
|
445
485
|
// setting应该是全量的设置项,外部控制,在初始化的时候会deepCopy一份
|
|
446
|
-
Control
|
|
447
|
-
Control
|
|
486
|
+
_define_property(Control, "setting", []);
|
|
487
|
+
_define_property(Control, "__is_control__", true);
|
|
448
488
|
// 删除指定的settingItem
|
|
449
|
-
Control
|
|
489
|
+
_define_property(Control, "removeSettingItem", removeSetting);
|
|
450
490
|
// 修改指定的settingItem的visible
|
|
451
|
-
Control
|
|
491
|
+
_define_property(Control, "updateSettingItem", updateSetting);
|
|
452
492
|
export default Control;
|
|
453
493
|
export { Control as DesignerControl };
|
|
454
494
|
/**
|
|
@@ -464,8 +504,7 @@ export { Control as DesignerControl };
|
|
|
464
504
|
var _this_setting;
|
|
465
505
|
// 是否存在子项
|
|
466
506
|
var isHasItem = typeof deleteKey !== "string";
|
|
467
|
-
//
|
|
468
|
-
if (!Array.isArray(_this.setting)) return;
|
|
507
|
+
// 判断setting是否是自定义控件setting项
|
|
469
508
|
// @ts-ignore
|
|
470
509
|
var settingIndex = (_this_setting = _this.setting) === null || _this_setting === void 0 ? void 0 : _this_setting.findIndex(function(option) {
|
|
471
510
|
return option.key === (isHasItem ? deleteKey.key : deleteKey);
|
|
@@ -510,7 +549,7 @@ export { Control as DesignerControl };
|
|
|
510
549
|
settingItem.showItems = value.showItems;
|
|
511
550
|
} else {
|
|
512
551
|
var _settingItem_showItems;
|
|
513
|
-
(_settingItem_showItems = settingItem.showItems).push.apply(_settingItem_showItems,
|
|
552
|
+
(_settingItem_showItems = settingItem.showItems).push.apply(_settingItem_showItems, _to_consumable_array(value.showItems));
|
|
514
553
|
}
|
|
515
554
|
}
|
|
516
555
|
}
|