@byteluck-fe/model-driven-core 2.7.0-alpha.1 → 2.7.0-alpha.11
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/api-doc-index.js +4 -4
- package/dist/esm/common/BaseControl/designer.js +254 -306
- package/dist/esm/common/BaseControl/index.js +7 -7
- package/dist/esm/common/BaseControl/property.js +10 -13
- package/dist/esm/common/BaseControl/runtime.js +16 -16
- package/dist/esm/common/ColumnControl/designer.js +5 -5
- package/dist/esm/common/ColumnControl/index.js +6 -6
- package/dist/esm/common/ColumnControl/property.js +36 -36
- package/dist/esm/common/ColumnControl/runtime.js +5 -5
- package/dist/esm/common/ControlArray.js +8 -8
- package/dist/esm/common/FormControl/designer.js +8 -8
- package/dist/esm/common/FormControl/index.js +6 -6
- package/dist/esm/common/FormControl/property.js +68 -73
- package/dist/esm/common/FormControl/runtime.js +5 -5
- package/dist/esm/common/LayoutControl/designer.js +102 -196
- package/dist/esm/common/LayoutControl/index.js +6 -6
- package/dist/esm/common/LayoutControl/property.js +3 -3
- package/dist/esm/common/LayoutControl/runtime.js +7 -7
- package/dist/esm/common/ListControl/designer.js +93 -184
- package/dist/esm/common/ListControl/index.js +6 -6
- package/dist/esm/common/ListControl/property.js +5 -5
- package/dist/esm/common/ListControl/runtime.js +7 -7
- package/dist/esm/common/SearchViewControl/designer.js +5 -5
- package/dist/esm/common/SearchViewControl/index.js +6 -6
- package/dist/esm/common/SearchViewControl/property.js +4 -4
- package/dist/esm/common/SearchViewControl/runtime.js +5 -5
- package/dist/esm/common/Validator.js +5 -5
- package/dist/esm/common/WrapControl/designer.js +5 -5
- package/dist/esm/common/WrapControl/index.js +6 -6
- package/dist/esm/common/WrapControl/property.js +3 -3
- package/dist/esm/common/WrapControl/runtime.js +5 -5
- package/dist/esm/common/controlHooksEmitter.js +1 -1
- package/dist/esm/common/index.js +12 -12
- package/dist/esm/common/initLinkOperationRules.js +6 -6
- package/dist/esm/common/initOptionAndDataSourceRules.js +82 -82
- package/dist/esm/framework/RegisterControls.js +196 -122
- package/dist/esm/framework/index.js +334 -345
- package/dist/esm/framework/isDataBind.js +7 -0
- package/dist/esm/index.js +4 -3
- package/dist/index.umd.js +1 -1
- package/dist/types/common/BaseControl/designer.d.ts +4 -0
- package/dist/types/common/ListControl/property.d.ts +1 -0
- package/dist/types/common/Validator.d.ts +1 -1
- package/dist/types/common/controlHooksEmitter.d.ts +1 -1
- 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/dist/types/type.d.ts +23 -23
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export { default as BaseControlProperty } from
|
|
3
|
-
export { default as ColumnControlProperty } from
|
|
4
|
-
export { default as FormControlProperty } from
|
|
1
|
+
export * from './framework/index';
|
|
2
|
+
export { default as BaseControlProperty } from './common/BaseControl/property';
|
|
3
|
+
export { default as ColumnControlProperty } from './common/ColumnControl/property';
|
|
4
|
+
export { default as FormControlProperty } from './common/FormControl/property';
|
|
@@ -72,7 +72,7 @@ function _defineProperty(obj, key, value) {
|
|
|
72
72
|
}
|
|
73
73
|
function _instanceof(left, right) {
|
|
74
74
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
75
|
-
return
|
|
75
|
+
return right[Symbol.hasInstance](left);
|
|
76
76
|
} else {
|
|
77
77
|
return left instanceof right;
|
|
78
78
|
}
|
|
@@ -102,7 +102,7 @@ function _objectSpread(target) {
|
|
|
102
102
|
return target;
|
|
103
103
|
}
|
|
104
104
|
function _toArray(arr) {
|
|
105
|
-
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
105
|
+
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
106
106
|
}
|
|
107
107
|
function _toConsumableArray(arr) {
|
|
108
108
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
@@ -115,105 +115,11 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
115
115
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
116
116
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
117
117
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return t[1];
|
|
124
|
-
},
|
|
125
|
-
trys: [],
|
|
126
|
-
ops: []
|
|
127
|
-
};
|
|
128
|
-
return g = {
|
|
129
|
-
next: verb(0),
|
|
130
|
-
"throw": verb(1),
|
|
131
|
-
"return": verb(2)
|
|
132
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
133
|
-
return this;
|
|
134
|
-
}), g;
|
|
135
|
-
function verb(n) {
|
|
136
|
-
return function(v) {
|
|
137
|
-
return step([
|
|
138
|
-
n,
|
|
139
|
-
v
|
|
140
|
-
]);
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function step(op) {
|
|
144
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
145
|
-
while(_)try {
|
|
146
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
147
|
-
if (y = 0, t) op = [
|
|
148
|
-
op[0] & 2,
|
|
149
|
-
t.value
|
|
150
|
-
];
|
|
151
|
-
switch(op[0]){
|
|
152
|
-
case 0:
|
|
153
|
-
case 1:
|
|
154
|
-
t = op;
|
|
155
|
-
break;
|
|
156
|
-
case 4:
|
|
157
|
-
_.label++;
|
|
158
|
-
return {
|
|
159
|
-
value: op[1],
|
|
160
|
-
done: false
|
|
161
|
-
};
|
|
162
|
-
case 5:
|
|
163
|
-
_.label++;
|
|
164
|
-
y = op[1];
|
|
165
|
-
op = [
|
|
166
|
-
0
|
|
167
|
-
];
|
|
168
|
-
continue;
|
|
169
|
-
case 7:
|
|
170
|
-
op = _.ops.pop();
|
|
171
|
-
_.trys.pop();
|
|
172
|
-
continue;
|
|
173
|
-
default:
|
|
174
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
175
|
-
_ = 0;
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
179
|
-
_.label = op[1];
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
183
|
-
_.label = t[1];
|
|
184
|
-
t = op;
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
if (t && _.label < t[2]) {
|
|
188
|
-
_.label = t[2];
|
|
189
|
-
_.ops.push(op);
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
if (t[2]) _.ops.pop();
|
|
193
|
-
_.trys.pop();
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
op = body.call(thisArg, _);
|
|
197
|
-
} catch (e) {
|
|
198
|
-
op = [
|
|
199
|
-
6,
|
|
200
|
-
e
|
|
201
|
-
];
|
|
202
|
-
y = 0;
|
|
203
|
-
} finally{
|
|
204
|
-
f = t = 0;
|
|
205
|
-
}
|
|
206
|
-
if (op[0] & 5) throw op[1];
|
|
207
|
-
return {
|
|
208
|
-
value: op[0] ? op[1] : void 0,
|
|
209
|
-
done: true
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
import Property from "./property";
|
|
214
|
-
import { genNonDuplicateId, JSONCopy, referenceError, updateValueFromKeys } from "@byteluck-fe/model-driven-shared";
|
|
215
|
-
import { createValidator } from "../Validator";
|
|
216
|
-
import { controlHooksEmitter } from "../controlHooksEmitter";
|
|
118
|
+
import regeneratorRuntime from "regenerator-runtime";
|
|
119
|
+
import Property from './property';
|
|
120
|
+
import { genNonDuplicateId, JSONCopy, referenceError, updateValueFromKeys } from '@byteluck-fe/model-driven-shared';
|
|
121
|
+
import { createValidator } from '../Validator';
|
|
122
|
+
import { controlHooksEmitter } from '../controlHooksEmitter';
|
|
217
123
|
var Control = /*#__PURE__*/ function _target() {
|
|
218
124
|
"use strict";
|
|
219
125
|
function Control(props) {
|
|
@@ -225,203 +131,31 @@ var Control = /*#__PURE__*/ function _target() {
|
|
|
225
131
|
this.parent = null;
|
|
226
132
|
this.updateSetting = updateSetting;
|
|
227
133
|
this.removeSetting = removeSetting;
|
|
228
|
-
this.
|
|
229
|
-
|
|
134
|
+
this.addSetting = addSetting;
|
|
135
|
+
this.replaceSetting = replaceSetting;
|
|
136
|
+
this._callControlHooks('preInstance', props);
|
|
137
|
+
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
138
|
if (!(controlName && controlIcon && controlType)) {
|
|
231
139
|
referenceError("The ".concat(name, " controlName,controlIcon,controlType is not define"));
|
|
232
140
|
}
|
|
233
|
-
var
|
|
234
|
-
this.id = (
|
|
141
|
+
var ref1;
|
|
142
|
+
this.id = (ref1 = props === null || props === void 0 ? void 0 : props.id) !== null && ref1 !== void 0 ? ref1 : genNonDuplicateId(10);
|
|
235
143
|
this.name = controlName;
|
|
236
144
|
this.icon = controlIcon;
|
|
237
|
-
var
|
|
238
|
-
this.type = (
|
|
145
|
+
var ref2;
|
|
146
|
+
this.type = (ref2 = props === null || props === void 0 ? void 0 : props.type) !== null && ref2 !== void 0 ? ref2 : controlType;
|
|
239
147
|
this.props = new Property(props === null || props === void 0 ? void 0 : props.props, (_instanceof(this, Control) ? this.constructor : void 0).controlName);
|
|
240
|
-
var
|
|
241
|
-
this.controlType = (
|
|
148
|
+
var ref3;
|
|
149
|
+
this.controlType = (ref3 = props === null || props === void 0 ? void 0 : props.controlType) !== null && ref3 !== void 0 ? ref3 : 'base';
|
|
242
150
|
this.setting = JSONCopy(setting);
|
|
243
|
-
var
|
|
244
|
-
this.fieldType = (
|
|
151
|
+
var ref4;
|
|
152
|
+
this.fieldType = (ref4 = props === null || props === void 0 ? void 0 : props.fieldType) !== null && ref4 !== void 0 ? ref4 : controlFieldType;
|
|
245
153
|
this.eventKeys = JSONCopy(controlEventKeys);
|
|
246
154
|
this.customEvents = JSONCopy(controlCustomEvents);
|
|
247
155
|
Promise.resolve().then(function() {
|
|
248
|
-
_this._callControlHooks(
|
|
156
|
+
_this._callControlHooks('postInstance', props);
|
|
249
157
|
});
|
|
250
158
|
}
|
|
251
|
-
var _proto = Control.prototype;
|
|
252
|
-
_proto._callControlHooks = function _callControlHooks() {
|
|
253
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
254
|
-
args[_key] = arguments[_key];
|
|
255
|
-
}
|
|
256
|
-
var _controlHooksEmitter;
|
|
257
|
-
var _args = _toArray(args), key = _args[0], arg = _args.slice(1);
|
|
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
|
-
];
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
})();
|
|
299
|
-
};
|
|
300
|
-
// property校验
|
|
301
|
-
_proto.validate = function validate(messages, ignore) {
|
|
302
|
-
var _this = this;
|
|
303
|
-
return _asyncToGenerator(function() {
|
|
304
|
-
var result, rules, validator, err;
|
|
305
|
-
return __generator(this, function(_state) {
|
|
306
|
-
switch(_state.label){
|
|
307
|
-
case 0:
|
|
308
|
-
return [
|
|
309
|
-
4,
|
|
310
|
-
_this.preValidate()
|
|
311
|
-
];
|
|
312
|
-
case 1:
|
|
313
|
-
result = _state.sent();
|
|
314
|
-
rules = result !== undefined ? result : _objectSpread({}, _this.rules);
|
|
315
|
-
if (Array.isArray(ignore)) {
|
|
316
|
-
ignore.forEach(function(key) {
|
|
317
|
-
if (rules.hasOwnProperty(key)) {
|
|
318
|
-
delete rules[key];
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
validator = createValidator(rules, messages);
|
|
323
|
-
_state.label = 2;
|
|
324
|
-
case 2:
|
|
325
|
-
_state.trys.push([
|
|
326
|
-
2,
|
|
327
|
-
4,
|
|
328
|
-
,
|
|
329
|
-
5
|
|
330
|
-
]);
|
|
331
|
-
return [
|
|
332
|
-
4,
|
|
333
|
-
validator.validate(_this.props)
|
|
334
|
-
];
|
|
335
|
-
case 3:
|
|
336
|
-
_state.sent();
|
|
337
|
-
return [
|
|
338
|
-
2,
|
|
339
|
-
true
|
|
340
|
-
];
|
|
341
|
-
case 4:
|
|
342
|
-
err = _state.sent();
|
|
343
|
-
if (!err.control) {
|
|
344
|
-
err.control = _this;
|
|
345
|
-
}
|
|
346
|
-
throw err;
|
|
347
|
-
case 5:
|
|
348
|
-
return [
|
|
349
|
-
2
|
|
350
|
-
];
|
|
351
|
-
}
|
|
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;
|
|
378
|
-
}
|
|
379
|
-
break;
|
|
380
|
-
case "custom":
|
|
381
|
-
dataBindModelType.props.options = options;
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
if (required !== undefined) {
|
|
385
|
-
dataBindModelType.required = required;
|
|
386
|
-
}
|
|
387
|
-
if (maxLength !== undefined) {
|
|
388
|
-
dataBindModelType.maxLength = maxLength;
|
|
389
|
-
}
|
|
390
|
-
if (encrypted !== undefined) {
|
|
391
|
-
dataBindModelType.encrypted = encrypted;
|
|
392
|
-
}
|
|
393
|
-
if (encryptedMode !== undefined) {
|
|
394
|
-
dataBindModelType.encryptedMode = encryptedMode;
|
|
395
|
-
}
|
|
396
|
-
return dataBindModelType;
|
|
397
|
-
};
|
|
398
|
-
_proto.preToSchema = function preToSchema() {
|
|
399
|
-
// 在处理Schema之前,预留的钩子函数,允许在toSchema之前处理一些数据
|
|
400
|
-
this._callControlHooks("preToSchema", this);
|
|
401
|
-
};
|
|
402
|
-
_proto.toSchema = function toSchema() {
|
|
403
|
-
this.preToSchema();
|
|
404
|
-
return {
|
|
405
|
-
id: this.id,
|
|
406
|
-
type: this.type,
|
|
407
|
-
props: JSONCopy(this.props),
|
|
408
|
-
fieldType: this.fieldType,
|
|
409
|
-
controlType: this.controlType
|
|
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)
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
159
|
_createClass(Control, [
|
|
426
160
|
{
|
|
427
161
|
key: "rules",
|
|
@@ -432,22 +166,210 @@ var Control = /*#__PURE__*/ function _target() {
|
|
|
432
166
|
}
|
|
433
167
|
return {};
|
|
434
168
|
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
key: "_callControlHooks",
|
|
172
|
+
value: function _callControlHooks() {
|
|
173
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
174
|
+
args[_key] = arguments[_key];
|
|
175
|
+
}
|
|
176
|
+
var _controlHooksEmitter;
|
|
177
|
+
var _args = _toArray(args), key = _args[0], arg = _args.slice(1);
|
|
178
|
+
return (_controlHooksEmitter = controlHooksEmitter).emit.apply(_controlHooksEmitter, [
|
|
179
|
+
key,
|
|
180
|
+
this
|
|
181
|
+
].concat(_toConsumableArray(arg)));
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: "preUpdate",
|
|
186
|
+
value: function preUpdate(key, value) {
|
|
187
|
+
// 在修改props之前
|
|
188
|
+
this._callControlHooks('preUpdateProps', key, value);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
key: "postUpdate",
|
|
193
|
+
value: function postUpdate(key, value) {
|
|
194
|
+
// 在修改props之后
|
|
195
|
+
this._callControlHooks('postUpdateProps', key, value);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
key: "updateProps",
|
|
200
|
+
value: // 修改实例上的props,key可以是caption,caption.zh...
|
|
201
|
+
function updateProps(key, value) {
|
|
202
|
+
this.preUpdate(key, value);
|
|
203
|
+
updateValueFromKeys(this.props, key, value);
|
|
204
|
+
this.postUpdate(key, value);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
key: "preValidate",
|
|
209
|
+
value: function preValidate() {
|
|
210
|
+
var _this = this;
|
|
211
|
+
return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
|
212
|
+
var rules, results, result;
|
|
213
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
214
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
215
|
+
case 0:
|
|
216
|
+
rules = _objectSpread({}, _this.rules);
|
|
217
|
+
_ctx.next = 3;
|
|
218
|
+
return _this._callControlHooks('preValidate', rules);
|
|
219
|
+
case 3:
|
|
220
|
+
results = _ctx.sent;
|
|
221
|
+
result = results[results.length - 1];
|
|
222
|
+
return _ctx.abrupt("return", result === false ? undefined : result);
|
|
223
|
+
case 6:
|
|
224
|
+
case "end":
|
|
225
|
+
return _ctx.stop();
|
|
226
|
+
}
|
|
227
|
+
}, _callee);
|
|
228
|
+
}))();
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
key: "validate",
|
|
233
|
+
value: // property校验
|
|
234
|
+
function validate(messages, ignore) {
|
|
235
|
+
var _this = this;
|
|
236
|
+
return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
|
237
|
+
var result, rules, validator;
|
|
238
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
239
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
240
|
+
case 0:
|
|
241
|
+
_ctx.next = 2;
|
|
242
|
+
return _this.preValidate();
|
|
243
|
+
case 2:
|
|
244
|
+
result = _ctx.sent;
|
|
245
|
+
rules = result !== undefined ? result : _objectSpread({}, _this.rules);
|
|
246
|
+
if (Array.isArray(ignore)) {
|
|
247
|
+
ignore.forEach(function(key) {
|
|
248
|
+
if (rules.hasOwnProperty(key)) {
|
|
249
|
+
delete rules[key];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
validator = createValidator(rules, messages);
|
|
254
|
+
_ctx.prev = 6;
|
|
255
|
+
_ctx.next = 9;
|
|
256
|
+
return validator.validate(_this.props);
|
|
257
|
+
case 9:
|
|
258
|
+
return _ctx.abrupt("return", true);
|
|
259
|
+
case 12:
|
|
260
|
+
_ctx.prev = 12;
|
|
261
|
+
_ctx.t0 = _ctx["catch"](6);
|
|
262
|
+
if (!_ctx.t0.control) {
|
|
263
|
+
_ctx.t0.control = _this;
|
|
264
|
+
}
|
|
265
|
+
throw _ctx.t0;
|
|
266
|
+
case 16:
|
|
267
|
+
case "end":
|
|
268
|
+
return _ctx.stop();
|
|
269
|
+
}
|
|
270
|
+
}, _callee, null, [
|
|
271
|
+
[
|
|
272
|
+
6,
|
|
273
|
+
12
|
|
274
|
+
]
|
|
275
|
+
]);
|
|
276
|
+
}))();
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
key: "toDataBindModel",
|
|
281
|
+
value: function toDataBindModel() {
|
|
282
|
+
var parentId = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
283
|
+
var fieldType = this.fieldType;
|
|
284
|
+
var controlId = this.id;
|
|
285
|
+
var type = this.type;
|
|
286
|
+
var _props = this.props, dataBind = _props.dataBind, datasourceBind = _props.datasourceBind, optionConfig = _props.optionConfig, caption = _props.caption, required = _props.required, maxLength = _props.maxLength, options = _props.options, encrypted = _props.encrypted, encryptedMode = _props.encryptedMode;
|
|
287
|
+
if (!fieldType && !dataBind && !datasourceBind) return;
|
|
288
|
+
var dataBindModelType = {
|
|
289
|
+
parentId: parentId,
|
|
290
|
+
fieldType: fieldType,
|
|
291
|
+
controlId: controlId,
|
|
292
|
+
caption: caption,
|
|
293
|
+
type: type,
|
|
294
|
+
props: {}
|
|
295
|
+
};
|
|
296
|
+
if (dataBind) {
|
|
297
|
+
dataBindModelType.dataBind = dataBind;
|
|
298
|
+
}
|
|
299
|
+
switch(optionConfig){
|
|
300
|
+
case 'datasource':
|
|
301
|
+
case undefined:
|
|
302
|
+
if (datasourceBind) {
|
|
303
|
+
dataBindModelType.datasourceBind = datasourceBind;
|
|
304
|
+
}
|
|
305
|
+
break;
|
|
306
|
+
case 'custom':
|
|
307
|
+
dataBindModelType.props.options = options;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
if (required !== undefined) {
|
|
311
|
+
dataBindModelType.required = required;
|
|
312
|
+
}
|
|
313
|
+
if (maxLength !== undefined) {
|
|
314
|
+
dataBindModelType.maxLength = maxLength;
|
|
315
|
+
}
|
|
316
|
+
if (encrypted !== undefined) {
|
|
317
|
+
dataBindModelType.encrypted = encrypted;
|
|
318
|
+
}
|
|
319
|
+
if (encryptedMode !== undefined) {
|
|
320
|
+
dataBindModelType.encryptedMode = encryptedMode;
|
|
321
|
+
}
|
|
322
|
+
return dataBindModelType;
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
key: "preToSchema",
|
|
327
|
+
value: function preToSchema() {
|
|
328
|
+
// 在处理Schema之前,预留的钩子函数,允许在toSchema之前处理一些数据
|
|
329
|
+
this._callControlHooks('preToSchema', this);
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
key: "toSchema",
|
|
334
|
+
value: function toSchema() {
|
|
335
|
+
this.preToSchema();
|
|
336
|
+
return {
|
|
337
|
+
id: this.id,
|
|
338
|
+
type: this.type,
|
|
339
|
+
props: JSONCopy(this.props),
|
|
340
|
+
fieldType: this.fieldType,
|
|
341
|
+
controlType: this.controlType
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
], [
|
|
346
|
+
{
|
|
347
|
+
key: "updateBasicControl",
|
|
348
|
+
value: function updateBasicControl(key, setting) {
|
|
349
|
+
if (key !== 'setting') return;
|
|
350
|
+
if (setting.add) {
|
|
351
|
+
var _setting;
|
|
352
|
+
(_setting = this.setting).push.apply(_setting, _toConsumableArray(setting.add));
|
|
353
|
+
}
|
|
354
|
+
if (setting.remove) {
|
|
355
|
+
this.removeSettingItem(setting.remove);
|
|
356
|
+
}
|
|
357
|
+
if (setting.update) {
|
|
358
|
+
// this.updateSettingItem(setting.update, false)
|
|
359
|
+
}
|
|
360
|
+
}
|
|
435
361
|
}
|
|
436
362
|
]);
|
|
437
363
|
return Control;
|
|
438
364
|
}();
|
|
439
|
-
Control.controlName =
|
|
440
|
-
Control.controlIcon =
|
|
441
|
-
Control.controlType =
|
|
442
|
-
// 控件可以触发的事件key
|
|
365
|
+
Control.controlName = '控件';
|
|
366
|
+
Control.controlIcon = 'icon';
|
|
367
|
+
Control.controlType = 'control';
|
|
443
368
|
Control.controlEventKeys = [];
|
|
444
369
|
Control.controlCustomEvents = [];
|
|
445
|
-
// setting应该是全量的设置项,外部控制,在初始化的时候会deepCopy一份
|
|
446
370
|
Control.setting = [];
|
|
447
371
|
Control.__is_control__ = true;
|
|
448
|
-
// 删除指定的settingItem
|
|
449
372
|
Control.removeSettingItem = removeSetting;
|
|
450
|
-
// 修改指定的settingItem的visible
|
|
451
373
|
Control.updateSettingItem = updateSetting;
|
|
452
374
|
export default Control;
|
|
453
375
|
export { Control as DesignerControl };
|
|
@@ -461,21 +383,25 @@ export { Control as DesignerControl };
|
|
|
461
383
|
keys
|
|
462
384
|
];
|
|
463
385
|
deleteKeys.forEach(function(deleteKey) {
|
|
386
|
+
var ref;
|
|
464
387
|
// 是否存在子项
|
|
465
|
-
var isHasItem = typeof deleteKey !==
|
|
388
|
+
var isHasItem = typeof deleteKey !== 'string';
|
|
389
|
+
// 判断setting是否是自定义控件setting项
|
|
466
390
|
// @ts-ignore
|
|
467
|
-
|
|
391
|
+
if (!Array.isArray(_this.setting)) return;
|
|
392
|
+
// @ts-ignore
|
|
393
|
+
var settingIndex = (ref = _this.setting) === null || ref === void 0 ? void 0 : ref.findIndex(function(option) {
|
|
468
394
|
return option.key === (isHasItem ? deleteKey.key : deleteKey);
|
|
469
395
|
});
|
|
470
396
|
// 移除对应选项
|
|
471
397
|
if (settingIndex !== -1) {
|
|
472
|
-
var
|
|
473
|
-
isHasItem ? _this.setting[settingIndex].showItems = (
|
|
398
|
+
var ref5, ref6;
|
|
399
|
+
isHasItem ? _this.setting[settingIndex].showItems = (ref5 = _this.setting[settingIndex].showItems) === null || ref5 === void 0 ? void 0 : ref5.filter(function(item) {
|
|
474
400
|
return !deleteKey.hideItems.includes(item);
|
|
475
401
|
}) : _this.setting.splice(settingIndex, 1);
|
|
476
402
|
// 子项长度为0,自动移除当前设置项
|
|
477
403
|
isHasItem && // @ts-ignore
|
|
478
|
-
!((
|
|
404
|
+
!((ref6 = _this.setting[settingIndex].showItems) === null || ref6 === void 0 ? void 0 : ref6.length) && // @ts-ignore
|
|
479
405
|
_this.setting.splice(settingIndex, 1);
|
|
480
406
|
}
|
|
481
407
|
});
|
|
@@ -489,27 +415,49 @@ export { Control as DesignerControl };
|
|
|
489
415
|
* @param value.type 默认是replace替换,可以更改为push新增
|
|
490
416
|
* */ function updateSetting(settingKey, value) {
|
|
491
417
|
var _this = this;
|
|
492
|
-
var keys = typeof settingKey ===
|
|
418
|
+
var keys = typeof settingKey === 'string' ? [
|
|
493
419
|
settingKey
|
|
494
420
|
] : settingKey;
|
|
495
421
|
keys.forEach(function(key) {
|
|
422
|
+
// @ts-ignore
|
|
423
|
+
if (!Array.isArray(_this.setting)) return;
|
|
496
424
|
// @ts-ignore
|
|
497
425
|
var settingItem = _this.setting.find(function(item) {
|
|
498
426
|
return item.key === key;
|
|
499
427
|
});
|
|
500
428
|
if (settingItem) {
|
|
501
|
-
if (typeof value ===
|
|
429
|
+
if (typeof value === 'boolean') {
|
|
502
430
|
settingItem.visible = value;
|
|
503
|
-
} else if (typeof value ===
|
|
504
|
-
var
|
|
505
|
-
var type = (
|
|
506
|
-
if (type ===
|
|
431
|
+
} else if (typeof value === 'object') {
|
|
432
|
+
var _type;
|
|
433
|
+
var type = (_type = value.type) !== null && _type !== void 0 ? _type : 'replace';
|
|
434
|
+
if (type === 'replace') {
|
|
507
435
|
settingItem.showItems = value.showItems;
|
|
508
436
|
} else {
|
|
509
|
-
var
|
|
510
|
-
(
|
|
437
|
+
var _showItems;
|
|
438
|
+
(_showItems = settingItem.showItems).push.apply(_showItems, _toConsumableArray(value.showItems));
|
|
511
439
|
}
|
|
512
440
|
}
|
|
513
441
|
}
|
|
514
442
|
});
|
|
515
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* @function 新增控件或者实例上的setting的方法
|
|
446
|
+
* @description 其中的this可能是DesignerControl的类,也可以是实例
|
|
447
|
+
* @param setting 需要新增的setting或者setting项组成的数组
|
|
448
|
+
* */ function addSetting(setting) {
|
|
449
|
+
var // @ts-ignore
|
|
450
|
+
_setting;
|
|
451
|
+
var settings = Object.prototype.toString.call(setting) === '[object Object]' ? [
|
|
452
|
+
setting
|
|
453
|
+
] : setting;
|
|
454
|
+
(_setting = this.setting).push.apply(_setting, _toConsumableArray(settings));
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* @function 新增控件或者实例上的setting的方法
|
|
458
|
+
* @description 其中的this可能是DesignerControl的类,也可以是实例
|
|
459
|
+
* @param setting 需要新增的setting或者setting项组成的数组
|
|
460
|
+
* */ function replaceSetting(setting) {
|
|
461
|
+
// @ts-ignore
|
|
462
|
+
this.setting = setting;
|
|
463
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import Designer from
|
|
2
|
-
import Runtime from
|
|
3
|
-
import Property from
|
|
1
|
+
import Designer from './designer';
|
|
2
|
+
import Runtime from './runtime';
|
|
3
|
+
import Property from './property';
|
|
4
4
|
export default {
|
|
5
5
|
Designer: Designer,
|
|
6
6
|
Runtime: Runtime,
|
|
7
7
|
Property: Property
|
|
8
8
|
};
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
9
|
+
export * from './designer';
|
|
10
|
+
export * from './runtime';
|
|
11
|
+
export * from './property';
|
|
12
|
+
export * from './types';
|