@byteluck-fe/model-driven-core 2.6.0-alpha.4 → 2.6.0-alpha.5
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 +225 -305
- package/dist/esm/common/BaseControl/index.js +7 -7
- package/dist/esm/common/BaseControl/property.js +9 -9
- 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 +66 -66
- 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 +84 -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 +179 -122
- package/dist/esm/framework/index.js +326 -326
- package/dist/esm/index.js +3 -3
- package/dist/index.umd.js +1 -1
- package/dist/types/api-doc-index.d.ts +4 -4
- package/dist/types/common/BaseControl/designer.d.ts +62 -62
- package/dist/types/common/BaseControl/index.d.ts +13 -13
- package/dist/types/common/BaseControl/property.d.ts +22 -22
- package/dist/types/common/BaseControl/runtime.d.ts +22 -22
- package/dist/types/common/BaseControl/types.d.ts +35 -35
- package/dist/types/common/ColumnControl/designer.d.ts +10 -10
- package/dist/types/common/ColumnControl/index.d.ts +12 -12
- package/dist/types/common/ColumnControl/property.d.ts +73 -73
- package/dist/types/common/ColumnControl/runtime.d.ts +10 -10
- package/dist/types/common/ControlArray.d.ts +8 -8
- package/dist/types/common/FormControl/designer.d.ts +13 -13
- package/dist/types/common/FormControl/index.d.ts +12 -12
- package/dist/types/common/FormControl/property.d.ts +96 -96
- package/dist/types/common/FormControl/runtime.d.ts +11 -11
- package/dist/types/common/LayoutControl/designer.d.ts +21 -21
- package/dist/types/common/LayoutControl/index.d.ts +12 -12
- package/dist/types/common/LayoutControl/property.d.ts +6 -6
- package/dist/types/common/LayoutControl/runtime.d.ts +11 -11
- package/dist/types/common/ListControl/designer.d.ts +16 -16
- package/dist/types/common/ListControl/index.d.ts +12 -12
- package/dist/types/common/ListControl/property.d.ts +12 -12
- package/dist/types/common/ListControl/runtime.d.ts +12 -12
- package/dist/types/common/SearchViewControl/designer.d.ts +11 -11
- package/dist/types/common/SearchViewControl/index.d.ts +12 -12
- package/dist/types/common/SearchViewControl/property.d.ts +8 -8
- package/dist/types/common/SearchViewControl/runtime.d.ts +11 -11
- package/dist/types/common/Validator.d.ts +15 -15
- package/dist/types/common/WrapControl/designer.d.ts +11 -11
- package/dist/types/common/WrapControl/index.d.ts +12 -12
- package/dist/types/common/WrapControl/property.d.ts +6 -6
- package/dist/types/common/WrapControl/runtime.d.ts +11 -11
- package/dist/types/common/controlHooksEmitter.d.ts +4 -4
- package/dist/types/common/index.d.ts +12 -12
- package/dist/types/common/initLinkOperationRules.d.ts +6 -6
- package/dist/types/common/initOptionAndDataSourceRules.d.ts +10 -10
- package/dist/types/framework/RegisterControls.d.ts +33 -33
- package/dist/types/framework/index.d.ts +616 -616
- package/dist/types/index.d.ts +3 -3
- package/dist/types/type.d.ts +91 -91
- 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,29 @@ var Control = /*#__PURE__*/ function _target() {
|
|
|
225
131
|
this.parent = null;
|
|
226
132
|
this.updateSetting = updateSetting;
|
|
227
133
|
this.removeSetting = removeSetting;
|
|
228
|
-
this._callControlHooks(
|
|
229
|
-
var
|
|
134
|
+
this._callControlHooks('preInstance', props);
|
|
135
|
+
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
136
|
if (!(controlName && controlIcon && controlType)) {
|
|
231
137
|
referenceError("The ".concat(name, " controlName,controlIcon,controlType is not define"));
|
|
232
138
|
}
|
|
233
|
-
var
|
|
234
|
-
this.id = (
|
|
139
|
+
var ref1;
|
|
140
|
+
this.id = (ref1 = props === null || props === void 0 ? void 0 : props.id) !== null && ref1 !== void 0 ? ref1 : genNonDuplicateId(10);
|
|
235
141
|
this.name = controlName;
|
|
236
142
|
this.icon = controlIcon;
|
|
237
|
-
var
|
|
238
|
-
this.type = (
|
|
143
|
+
var ref2;
|
|
144
|
+
this.type = (ref2 = props === null || props === void 0 ? void 0 : props.type) !== null && ref2 !== void 0 ? ref2 : controlType;
|
|
239
145
|
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 = (
|
|
146
|
+
var ref3;
|
|
147
|
+
this.controlType = (ref3 = props === null || props === void 0 ? void 0 : props.controlType) !== null && ref3 !== void 0 ? ref3 : 'base';
|
|
242
148
|
this.setting = JSONCopy(setting);
|
|
243
|
-
var
|
|
244
|
-
this.fieldType = (
|
|
149
|
+
var ref4;
|
|
150
|
+
this.fieldType = (ref4 = props === null || props === void 0 ? void 0 : props.fieldType) !== null && ref4 !== void 0 ? ref4 : controlFieldType;
|
|
245
151
|
this.eventKeys = JSONCopy(controlEventKeys);
|
|
246
152
|
this.customEvents = JSONCopy(controlCustomEvents);
|
|
247
153
|
Promise.resolve().then(function() {
|
|
248
|
-
_this._callControlHooks(
|
|
154
|
+
_this._callControlHooks('postInstance', props);
|
|
249
155
|
});
|
|
250
156
|
}
|
|
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
157
|
_createClass(Control, [
|
|
426
158
|
{
|
|
427
159
|
key: "rules",
|
|
@@ -432,22 +164,210 @@ var Control = /*#__PURE__*/ function _target() {
|
|
|
432
164
|
}
|
|
433
165
|
return {};
|
|
434
166
|
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
key: "_callControlHooks",
|
|
170
|
+
value: function _callControlHooks() {
|
|
171
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
172
|
+
args[_key] = arguments[_key];
|
|
173
|
+
}
|
|
174
|
+
var _controlHooksEmitter;
|
|
175
|
+
var _args = _toArray(args), key = _args[0], arg = _args.slice(1);
|
|
176
|
+
return (_controlHooksEmitter = controlHooksEmitter).emit.apply(_controlHooksEmitter, [
|
|
177
|
+
key,
|
|
178
|
+
this
|
|
179
|
+
].concat(_toConsumableArray(arg)));
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
key: "preUpdate",
|
|
184
|
+
value: function preUpdate(key, value) {
|
|
185
|
+
// 在修改props之前
|
|
186
|
+
this._callControlHooks('preUpdateProps', key, value);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
key: "postUpdate",
|
|
191
|
+
value: function postUpdate(key, value) {
|
|
192
|
+
// 在修改props之后
|
|
193
|
+
this._callControlHooks('postUpdateProps', key, value);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
key: "updateProps",
|
|
198
|
+
value: // 修改实例上的props,key可以是caption,caption.zh...
|
|
199
|
+
function updateProps(key, value) {
|
|
200
|
+
this.preUpdate(key, value);
|
|
201
|
+
updateValueFromKeys(this.props, key, value);
|
|
202
|
+
this.postUpdate(key, value);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
key: "preValidate",
|
|
207
|
+
value: function preValidate() {
|
|
208
|
+
var _this = this;
|
|
209
|
+
return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
|
210
|
+
var rules, results, result;
|
|
211
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
212
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
213
|
+
case 0:
|
|
214
|
+
rules = _objectSpread({}, _this.rules);
|
|
215
|
+
_ctx.next = 3;
|
|
216
|
+
return _this._callControlHooks('preValidate', rules);
|
|
217
|
+
case 3:
|
|
218
|
+
results = _ctx.sent;
|
|
219
|
+
result = results[results.length - 1];
|
|
220
|
+
return _ctx.abrupt("return", result === false ? undefined : result);
|
|
221
|
+
case 6:
|
|
222
|
+
case "end":
|
|
223
|
+
return _ctx.stop();
|
|
224
|
+
}
|
|
225
|
+
}, _callee);
|
|
226
|
+
}))();
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
key: "validate",
|
|
231
|
+
value: // property校验
|
|
232
|
+
function validate(messages, ignore) {
|
|
233
|
+
var _this = this;
|
|
234
|
+
return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
|
235
|
+
var result, rules, validator;
|
|
236
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
237
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
238
|
+
case 0:
|
|
239
|
+
_ctx.next = 2;
|
|
240
|
+
return _this.preValidate();
|
|
241
|
+
case 2:
|
|
242
|
+
result = _ctx.sent;
|
|
243
|
+
rules = result !== undefined ? result : _objectSpread({}, _this.rules);
|
|
244
|
+
if (Array.isArray(ignore)) {
|
|
245
|
+
ignore.forEach(function(key) {
|
|
246
|
+
if (rules.hasOwnProperty(key)) {
|
|
247
|
+
delete rules[key];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
validator = createValidator(rules, messages);
|
|
252
|
+
_ctx.prev = 6;
|
|
253
|
+
_ctx.next = 9;
|
|
254
|
+
return validator.validate(_this.props);
|
|
255
|
+
case 9:
|
|
256
|
+
return _ctx.abrupt("return", true);
|
|
257
|
+
case 12:
|
|
258
|
+
_ctx.prev = 12;
|
|
259
|
+
_ctx.t0 = _ctx["catch"](6);
|
|
260
|
+
if (!_ctx.t0.control) {
|
|
261
|
+
_ctx.t0.control = _this;
|
|
262
|
+
}
|
|
263
|
+
throw _ctx.t0;
|
|
264
|
+
case 16:
|
|
265
|
+
case "end":
|
|
266
|
+
return _ctx.stop();
|
|
267
|
+
}
|
|
268
|
+
}, _callee, null, [
|
|
269
|
+
[
|
|
270
|
+
6,
|
|
271
|
+
12
|
|
272
|
+
]
|
|
273
|
+
]);
|
|
274
|
+
}))();
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
key: "toDataBindModel",
|
|
279
|
+
value: function toDataBindModel() {
|
|
280
|
+
var parentId = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
281
|
+
var fieldType = this.fieldType;
|
|
282
|
+
var controlId = this.id;
|
|
283
|
+
var type = this.type;
|
|
284
|
+
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;
|
|
285
|
+
if (!fieldType && !dataBind && !datasourceBind) return;
|
|
286
|
+
var dataBindModelType = {
|
|
287
|
+
parentId: parentId,
|
|
288
|
+
fieldType: fieldType,
|
|
289
|
+
controlId: controlId,
|
|
290
|
+
caption: caption,
|
|
291
|
+
type: type,
|
|
292
|
+
props: {}
|
|
293
|
+
};
|
|
294
|
+
if (dataBind) {
|
|
295
|
+
dataBindModelType.dataBind = dataBind;
|
|
296
|
+
}
|
|
297
|
+
switch(optionConfig){
|
|
298
|
+
case 'datasource':
|
|
299
|
+
case undefined:
|
|
300
|
+
if (datasourceBind) {
|
|
301
|
+
dataBindModelType.datasourceBind = datasourceBind;
|
|
302
|
+
}
|
|
303
|
+
break;
|
|
304
|
+
case 'custom':
|
|
305
|
+
dataBindModelType.props.options = options;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
if (required !== undefined) {
|
|
309
|
+
dataBindModelType.required = required;
|
|
310
|
+
}
|
|
311
|
+
if (maxLength !== undefined) {
|
|
312
|
+
dataBindModelType.maxLength = maxLength;
|
|
313
|
+
}
|
|
314
|
+
if (encrypted !== undefined) {
|
|
315
|
+
dataBindModelType.encrypted = encrypted;
|
|
316
|
+
}
|
|
317
|
+
if (encryptedMode !== undefined) {
|
|
318
|
+
dataBindModelType.encryptedMode = encryptedMode;
|
|
319
|
+
}
|
|
320
|
+
return dataBindModelType;
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
key: "preToSchema",
|
|
325
|
+
value: function preToSchema() {
|
|
326
|
+
// 在处理Schema之前,预留的钩子函数,允许在toSchema之前处理一些数据
|
|
327
|
+
this._callControlHooks('preToSchema', this);
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
key: "toSchema",
|
|
332
|
+
value: function toSchema() {
|
|
333
|
+
this.preToSchema();
|
|
334
|
+
return {
|
|
335
|
+
id: this.id,
|
|
336
|
+
type: this.type,
|
|
337
|
+
props: JSONCopy(this.props),
|
|
338
|
+
fieldType: this.fieldType,
|
|
339
|
+
controlType: this.controlType
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
], [
|
|
344
|
+
{
|
|
345
|
+
key: "updateBasicControl",
|
|
346
|
+
value: function updateBasicControl(key, setting) {
|
|
347
|
+
if (key !== 'setting') return;
|
|
348
|
+
if (setting.add) {
|
|
349
|
+
var _setting;
|
|
350
|
+
(_setting = this.setting).push.apply(_setting, _toConsumableArray(setting.add));
|
|
351
|
+
}
|
|
352
|
+
if (setting.remove) {
|
|
353
|
+
this.removeSettingItem(setting.remove);
|
|
354
|
+
}
|
|
355
|
+
if (setting.update) {
|
|
356
|
+
// this.updateSettingItem(setting.update, false)
|
|
357
|
+
}
|
|
358
|
+
}
|
|
435
359
|
}
|
|
436
360
|
]);
|
|
437
361
|
return Control;
|
|
438
362
|
}();
|
|
439
|
-
Control.controlName =
|
|
440
|
-
Control.controlIcon =
|
|
441
|
-
Control.controlType =
|
|
442
|
-
// 控件可以触发的事件key
|
|
363
|
+
Control.controlName = '控件';
|
|
364
|
+
Control.controlIcon = 'icon';
|
|
365
|
+
Control.controlType = 'control';
|
|
443
366
|
Control.controlEventKeys = [];
|
|
444
367
|
Control.controlCustomEvents = [];
|
|
445
|
-
// setting应该是全量的设置项,外部控制,在初始化的时候会deepCopy一份
|
|
446
368
|
Control.setting = [];
|
|
447
369
|
Control.__is_control__ = true;
|
|
448
|
-
// 删除指定的settingItem
|
|
449
370
|
Control.removeSettingItem = removeSetting;
|
|
450
|
-
// 修改指定的settingItem的visible
|
|
451
371
|
Control.updateSettingItem = updateSetting;
|
|
452
372
|
export default Control;
|
|
453
373
|
export { Control as DesignerControl };
|
|
@@ -462,20 +382,20 @@ export { Control as DesignerControl };
|
|
|
462
382
|
];
|
|
463
383
|
deleteKeys.forEach(function(deleteKey) {
|
|
464
384
|
// 是否存在子项
|
|
465
|
-
var isHasItem = typeof deleteKey !==
|
|
385
|
+
var isHasItem = typeof deleteKey !== 'string';
|
|
466
386
|
// @ts-ignore
|
|
467
387
|
var settingIndex = _this.setting.findIndex(function(option) {
|
|
468
388
|
return option.key === (isHasItem ? deleteKey.key : deleteKey);
|
|
469
389
|
});
|
|
470
390
|
// 移除对应选项
|
|
471
391
|
if (settingIndex !== -1) {
|
|
472
|
-
var
|
|
473
|
-
isHasItem ? _this.setting[settingIndex].showItems = (
|
|
392
|
+
var ref, ref5;
|
|
393
|
+
isHasItem ? _this.setting[settingIndex].showItems = (ref = _this.setting[settingIndex].showItems) === null || ref === void 0 ? void 0 : ref.filter(function(item) {
|
|
474
394
|
return !deleteKey.hideItems.includes(item);
|
|
475
395
|
}) : _this.setting.splice(settingIndex, 1);
|
|
476
396
|
// 子项长度为0,自动移除当前设置项
|
|
477
397
|
isHasItem && // @ts-ignore
|
|
478
|
-
!((
|
|
398
|
+
!((ref5 = _this.setting[settingIndex].showItems) === null || ref5 === void 0 ? void 0 : ref5.length) && // @ts-ignore
|
|
479
399
|
_this.setting.splice(settingIndex, 1);
|
|
480
400
|
}
|
|
481
401
|
});
|
|
@@ -489,7 +409,7 @@ export { Control as DesignerControl };
|
|
|
489
409
|
* @param value.type 默认是replace替换,可以更改为push新增
|
|
490
410
|
* */ function updateSetting(settingKey, value) {
|
|
491
411
|
var _this = this;
|
|
492
|
-
var keys = typeof settingKey ===
|
|
412
|
+
var keys = typeof settingKey === 'string' ? [
|
|
493
413
|
settingKey
|
|
494
414
|
] : settingKey;
|
|
495
415
|
keys.forEach(function(key) {
|
|
@@ -498,16 +418,16 @@ export { Control as DesignerControl };
|
|
|
498
418
|
return item.key === key;
|
|
499
419
|
});
|
|
500
420
|
if (settingItem) {
|
|
501
|
-
if (typeof value ===
|
|
421
|
+
if (typeof value === 'boolean') {
|
|
502
422
|
settingItem.visible = value;
|
|
503
|
-
} else if (typeof value ===
|
|
504
|
-
var
|
|
505
|
-
var type = (
|
|
506
|
-
if (type ===
|
|
423
|
+
} else if (typeof value === 'object') {
|
|
424
|
+
var _type;
|
|
425
|
+
var type = (_type = value.type) !== null && _type !== void 0 ? _type : 'replace';
|
|
426
|
+
if (type === 'replace') {
|
|
507
427
|
settingItem.showItems = value.showItems;
|
|
508
428
|
} else {
|
|
509
|
-
var
|
|
510
|
-
(
|
|
429
|
+
var _showItems;
|
|
430
|
+
(_showItems = settingItem.showItems).push.apply(_showItems, _toConsumableArray(value.showItems));
|
|
511
431
|
}
|
|
512
432
|
}
|
|
513
433
|
}
|
|
@@ -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';
|