@byteluck-fe/model-driven-core 1.3.0-beta.27 → 1.5.0-beta.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.
Files changed (91) hide show
  1. package/dist/esm/common/BaseControl/designer.js +409 -0
  2. package/dist/esm/common/BaseControl/index.js +12 -0
  3. package/dist/esm/common/BaseControl/property.js +160 -0
  4. package/dist/esm/common/BaseControl/runtime.js +72 -0
  5. package/dist/esm/common/BaseControl/types.js +1 -0
  6. package/dist/esm/common/ColumnControl/designer.js +89 -0
  7. package/dist/esm/common/ColumnControl/index.js +11 -0
  8. package/dist/esm/common/ColumnControl/property.js +157 -0
  9. package/dist/esm/common/ColumnControl/runtime.js +89 -0
  10. package/dist/esm/common/ColumnControl/types.js +0 -0
  11. package/dist/esm/common/ControlArray.js +100 -0
  12. package/dist/esm/common/FormControl/designer.js +94 -0
  13. package/dist/esm/common/FormControl/index.js +11 -0
  14. package/dist/esm/common/FormControl/property.js +262 -0
  15. package/dist/esm/common/FormControl/runtime.js +89 -0
  16. package/dist/esm/common/FormControl/types.js +0 -0
  17. package/dist/esm/common/LayoutControl/designer.js +300 -0
  18. package/dist/esm/common/LayoutControl/index.js +11 -0
  19. package/dist/esm/common/LayoutControl/property.js +84 -0
  20. package/dist/esm/common/LayoutControl/runtime.js +91 -0
  21. package/dist/esm/common/LayoutControl/types.js +0 -0
  22. package/dist/esm/common/ListControl/designer.js +276 -0
  23. package/dist/esm/common/ListControl/index.js +11 -0
  24. package/dist/esm/common/ListControl/property.js +88 -0
  25. package/dist/esm/common/ListControl/runtime.js +113 -0
  26. package/dist/esm/common/ListControl/types.js +0 -0
  27. package/dist/esm/common/SearchViewControl/designer.js +89 -0
  28. package/dist/esm/common/SearchViewControl/index.js +11 -0
  29. package/dist/esm/common/SearchViewControl/property.js +88 -0
  30. package/dist/esm/common/SearchViewControl/runtime.js +89 -0
  31. package/dist/esm/common/SearchViewControl/types.js +0 -0
  32. package/dist/esm/common/Validator.js +16 -0
  33. package/dist/esm/common/WrapControl/designer.js +89 -0
  34. package/dist/esm/common/WrapControl/index.js +11 -0
  35. package/dist/esm/common/WrapControl/property.js +84 -0
  36. package/dist/esm/common/WrapControl/runtime.js +89 -0
  37. package/dist/esm/common/WrapControl/types.js +0 -0
  38. package/dist/esm/common/controlHooksEmitter.js +3 -0
  39. package/dist/esm/common/index.js +11 -0
  40. package/dist/esm/common/initOptionAndDataSourceRules.js +227 -0
  41. package/dist/esm/framework/RegisterControls.js +149 -0
  42. package/dist/esm/framework/index.js +690 -0
  43. package/dist/esm/index.js +3 -0
  44. package/dist/esm/type.js +1 -0
  45. package/dist/index.umd.js +1 -0
  46. package/dist/types/common/BaseControl/designer.d.ts +62 -0
  47. package/dist/types/common/BaseControl/index.d.ts +13 -0
  48. package/dist/types/common/BaseControl/property.d.ts +22 -0
  49. package/dist/types/common/BaseControl/runtime.d.ts +22 -0
  50. package/dist/types/common/BaseControl/types.d.ts +35 -0
  51. package/dist/types/common/ColumnControl/designer.d.ts +10 -0
  52. package/dist/types/common/ColumnControl/index.d.ts +12 -0
  53. package/dist/types/common/ColumnControl/property.d.ts +30 -0
  54. package/dist/types/common/ColumnControl/runtime.d.ts +10 -0
  55. package/dist/types/common/ColumnControl/types.d.ts +0 -0
  56. package/dist/types/common/ControlArray.d.ts +8 -0
  57. package/dist/types/common/FormControl/designer.d.ts +13 -0
  58. package/dist/types/common/FormControl/index.d.ts +12 -0
  59. package/dist/types/common/FormControl/property.d.ts +44 -0
  60. package/dist/types/common/FormControl/runtime.d.ts +11 -0
  61. package/dist/types/common/FormControl/types.d.ts +0 -0
  62. package/dist/types/common/LayoutControl/designer.d.ts +21 -0
  63. package/dist/types/common/LayoutControl/index.d.ts +12 -0
  64. package/dist/types/common/LayoutControl/property.d.ts +6 -0
  65. package/dist/types/common/LayoutControl/runtime.d.ts +11 -0
  66. package/dist/types/common/LayoutControl/types.d.ts +0 -0
  67. package/dist/types/common/ListControl/designer.d.ts +16 -0
  68. package/dist/types/common/ListControl/index.d.ts +12 -0
  69. package/dist/types/common/ListControl/property.d.ts +12 -0
  70. package/dist/types/common/ListControl/runtime.d.ts +12 -0
  71. package/dist/types/common/ListControl/types.d.ts +0 -0
  72. package/dist/types/common/SearchViewControl/designer.d.ts +11 -0
  73. package/dist/types/common/SearchViewControl/index.d.ts +12 -0
  74. package/dist/types/common/SearchViewControl/property.d.ts +8 -0
  75. package/dist/types/common/SearchViewControl/runtime.d.ts +11 -0
  76. package/dist/types/common/SearchViewControl/types.d.ts +0 -0
  77. package/dist/types/common/Validator.d.ts +15 -0
  78. package/dist/types/common/WrapControl/designer.d.ts +11 -0
  79. package/dist/types/common/WrapControl/index.d.ts +12 -0
  80. package/dist/types/common/WrapControl/property.d.ts +6 -0
  81. package/dist/types/common/WrapControl/runtime.d.ts +11 -0
  82. package/dist/types/common/WrapControl/types.d.ts +0 -0
  83. package/dist/types/common/controlHooksEmitter.d.ts +4 -0
  84. package/dist/types/common/index.d.ts +11 -0
  85. package/dist/types/common/initOptionAndDataSourceRules.d.ts +10 -0
  86. package/dist/types/framework/RegisterControls.d.ts +33 -0
  87. package/dist/types/framework/index.d.ts +349 -0
  88. package/dist/types/index.d.ts +3 -0
  89. package/dist/types/type.d.ts +91 -0
  90. package/package.json +4 -4
  91. package/src/index.ts +0 -3
@@ -0,0 +1,409 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i1 = 0, arr2 = new Array(len); i1 < len; i1++)arr2[i1] = arr[i1];
4
+ return arr2;
5
+ }
6
+ function _arrayWithHoles(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _arrayWithoutHoles(arr) {
10
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
11
+ }
12
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
+ try {
14
+ var info = gen[key](arg);
15
+ var value = info.value;
16
+ } catch (error) {
17
+ reject(error);
18
+ return;
19
+ }
20
+ if (info.done) {
21
+ resolve(value);
22
+ } else {
23
+ Promise.resolve(value).then(_next, _throw);
24
+ }
25
+ }
26
+ function _asyncToGenerator(fn) {
27
+ return function() {
28
+ var self = this, args = arguments;
29
+ return new Promise(function(resolve, reject) {
30
+ var gen = fn.apply(self, args);
31
+ function _next(value) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33
+ }
34
+ function _throw(err) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
+ }
37
+ _next(undefined);
38
+ });
39
+ };
40
+ }
41
+ function _classCallCheck(instance, Constructor) {
42
+ if (!(instance instanceof Constructor)) {
43
+ throw new TypeError("Cannot call a class as a function");
44
+ }
45
+ }
46
+ function _defineProperties(target, props) {
47
+ for(var i1 = 0; i1 < props.length; i1++){
48
+ var descriptor = props[i1];
49
+ descriptor.enumerable = descriptor.enumerable || false;
50
+ descriptor.configurable = true;
51
+ if ("value" in descriptor) descriptor.writable = true;
52
+ Object.defineProperty(target, descriptor.key, descriptor);
53
+ }
54
+ }
55
+ function _createClass(Constructor, protoProps, staticProps) {
56
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
57
+ if (staticProps) _defineProperties(Constructor, staticProps);
58
+ return Constructor;
59
+ }
60
+ function _defineProperty(obj, key, value) {
61
+ if (key in obj) {
62
+ Object.defineProperty(obj, key, {
63
+ value: value,
64
+ enumerable: true,
65
+ configurable: true,
66
+ writable: true
67
+ });
68
+ } else {
69
+ obj[key] = value;
70
+ }
71
+ return obj;
72
+ }
73
+ function _instanceof(left, right) {
74
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
75
+ return !!right[Symbol.hasInstance](left);
76
+ } else {
77
+ return left instanceof right;
78
+ }
79
+ }
80
+ function _iterableToArray(iter) {
81
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
82
+ }
83
+ function _nonIterableRest() {
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
+ }
86
+ function _nonIterableSpread() {
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
+ }
89
+ function _objectSpread(target) {
90
+ for(var i1 = 1; i1 < arguments.length; i1++){
91
+ var source = arguments[i1] != null ? arguments[i1] : {};
92
+ var ownKeys = Object.keys(source);
93
+ if (typeof Object.getOwnPropertySymbols === "function") {
94
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
95
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
96
+ }));
97
+ }
98
+ ownKeys.forEach(function(key) {
99
+ _defineProperty(target, key, source[key]);
100
+ });
101
+ }
102
+ return target;
103
+ }
104
+ function _toArray(arr) {
105
+ return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
106
+ }
107
+ function _toConsumableArray(arr) {
108
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
109
+ }
110
+ function _unsupportedIterableToArray(o, minLen) {
111
+ if (!o) return;
112
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
113
+ var n = Object.prototype.toString.call(o).slice(8, -1);
114
+ if (n === "Object" && o.constructor) n = o.constructor.name;
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 _arrayLikeToArray(o, minLen);
117
+ }
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";
123
+ var Control = /*#__PURE__*/ function _target() {
124
+ "use strict";
125
+ function Control(props) {
126
+ var _this = this;
127
+ _classCallCheck(this, Control);
128
+ this.setting = [];
129
+ this.eventKeys = [];
130
+ this.customEvents = [];
131
+ this.parent = null;
132
+ this.updateSetting = updateSetting;
133
+ this.removeSetting = removeSetting;
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;
136
+ if (!(controlName && controlIcon && controlType)) {
137
+ referenceError("The ".concat(name, " controlName,controlIcon,controlType is not define"));
138
+ }
139
+ var ref1;
140
+ this.id = (ref1 = props === null || props === void 0 ? void 0 : props.id) !== null && ref1 !== void 0 ? ref1 : genNonDuplicateId(10);
141
+ this.name = controlName;
142
+ this.icon = controlIcon;
143
+ var ref2;
144
+ this.type = (ref2 = props === null || props === void 0 ? void 0 : props.type) !== null && ref2 !== void 0 ? ref2 : controlType;
145
+ this.props = new Property(props === null || props === void 0 ? void 0 : props.props, (_instanceof(this, Control) ? this.constructor : void 0).controlName);
146
+ var ref3;
147
+ this.controlType = (ref3 = props === null || props === void 0 ? void 0 : props.controlType) !== null && ref3 !== void 0 ? ref3 : "base";
148
+ this.setting = JSONCopy(setting);
149
+ var ref4;
150
+ this.fieldType = (ref4 = props === null || props === void 0 ? void 0 : props.fieldType) !== null && ref4 !== void 0 ? ref4 : controlFieldType;
151
+ this.eventKeys = JSONCopy(controlEventKeys);
152
+ this.customEvents = JSONCopy(controlCustomEvents);
153
+ Promise.resolve().then(function() {
154
+ _this._callControlHooks("postInstance", props);
155
+ });
156
+ }
157
+ var _proto = Control.prototype;
158
+ _proto._callControlHooks = function _callControlHooks() {
159
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
160
+ args[_key] = arguments[_key];
161
+ }
162
+ var _controlHooksEmitter;
163
+ var _args = _toArray(args), key = _args[0], arg = _args.slice(1);
164
+ return (_controlHooksEmitter = controlHooksEmitter).emit.apply(_controlHooksEmitter, [
165
+ key,
166
+ this
167
+ ].concat(_toConsumableArray(arg)));
168
+ };
169
+ _proto.preUpdate = function preUpdate(key, value) {
170
+ // 在修改props之前
171
+ this._callControlHooks("preUpdateProps", key, value);
172
+ };
173
+ _proto.postUpdate = function postUpdate(key, value) {
174
+ // 在修改props之后
175
+ this._callControlHooks("postUpdateProps", key, value);
176
+ };
177
+ // 修改实例上的props,key可以是caption,caption.zh...
178
+ _proto.updateProps = function updateProps(key, value) {
179
+ this.preUpdate(key, value);
180
+ updateValueFromKeys(this.props, key, value);
181
+ this.postUpdate(key, value);
182
+ };
183
+ _proto.preValidate = function preValidate() {
184
+ var _this = this;
185
+ return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
186
+ var rules, results, result;
187
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
188
+ while(1)switch(_ctx.prev = _ctx.next){
189
+ case 0:
190
+ rules = _objectSpread({}, _this.rules);
191
+ _ctx.next = 3;
192
+ return _this._callControlHooks("preValidate", rules);
193
+ case 3:
194
+ results = _ctx.sent;
195
+ result = results[results.length - 1];
196
+ return _ctx.abrupt("return", result === false ? undefined : result);
197
+ case 6:
198
+ case "end":
199
+ return _ctx.stop();
200
+ }
201
+ }, _callee);
202
+ }))();
203
+ };
204
+ // property校验
205
+ _proto.validate = function validate(messages, ignore) {
206
+ var _this = this;
207
+ return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
208
+ var result, rules, validator;
209
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
210
+ while(1)switch(_ctx.prev = _ctx.next){
211
+ case 0:
212
+ _ctx.next = 2;
213
+ return _this.preValidate();
214
+ case 2:
215
+ result = _ctx.sent;
216
+ rules = result !== undefined ? result : _objectSpread({}, _this.rules);
217
+ if (Array.isArray(ignore)) {
218
+ ignore.forEach(function(key) {
219
+ if (rules.hasOwnProperty(key)) {
220
+ delete rules[key];
221
+ }
222
+ });
223
+ }
224
+ validator = createValidator(rules, messages);
225
+ _ctx.prev = 6;
226
+ _ctx.next = 9;
227
+ return validator.validate(_this.props);
228
+ case 9:
229
+ return _ctx.abrupt("return", true);
230
+ case 12:
231
+ _ctx.prev = 12;
232
+ _ctx.t0 = _ctx["catch"](6);
233
+ if (!_ctx.t0.control) {
234
+ _ctx.t0.control = _this;
235
+ }
236
+ throw _ctx.t0;
237
+ case 16:
238
+ case "end":
239
+ return _ctx.stop();
240
+ }
241
+ }, _callee, null, [
242
+ [
243
+ 6,
244
+ 12
245
+ ]
246
+ ]);
247
+ }))();
248
+ };
249
+ _proto.toDataBindModel = function toDataBindModel() {
250
+ var parentId = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
251
+ var fieldType = this.fieldType;
252
+ var controlId = this.id;
253
+ var type = this.type;
254
+ 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;
255
+ if (!fieldType && !dataBind && !datasourceBind) return;
256
+ var dataBindModelType = {
257
+ parentId: parentId,
258
+ fieldType: fieldType,
259
+ controlId: controlId,
260
+ caption: caption,
261
+ type: type,
262
+ props: {}
263
+ };
264
+ if (dataBind) {
265
+ dataBindModelType.dataBind = dataBind;
266
+ }
267
+ switch(optionConfig){
268
+ case "datasource":
269
+ case undefined:
270
+ if (datasourceBind) {
271
+ dataBindModelType.datasourceBind = datasourceBind;
272
+ }
273
+ break;
274
+ case "custom":
275
+ dataBindModelType.props.options = options;
276
+ break;
277
+ }
278
+ if (required !== undefined) {
279
+ dataBindModelType.required = required;
280
+ }
281
+ if (maxLength !== undefined) {
282
+ dataBindModelType.maxLength = maxLength;
283
+ }
284
+ if (encrypted !== undefined) {
285
+ dataBindModelType.encrypted = encrypted;
286
+ }
287
+ if (encryptedMode !== undefined) {
288
+ dataBindModelType.encryptedMode = encryptedMode;
289
+ }
290
+ return dataBindModelType;
291
+ };
292
+ _proto.preToSchema = function preToSchema() {
293
+ // 在处理Schema之前,预留的钩子函数,允许在toSchema之前处理一些数据
294
+ this._callControlHooks("preToSchema", this);
295
+ };
296
+ _proto.toSchema = function toSchema() {
297
+ this.preToSchema();
298
+ return {
299
+ id: this.id,
300
+ type: this.type,
301
+ props: JSONCopy(this.props),
302
+ fieldType: this.fieldType,
303
+ controlType: this.controlType
304
+ };
305
+ };
306
+ Control.updateBasicControl = function updateBasicControl(key, setting) {
307
+ if (key !== "setting") return;
308
+ if (setting.add) {
309
+ var _setting;
310
+ (_setting = this.setting).push.apply(_setting, _toConsumableArray(setting.add));
311
+ }
312
+ if (setting.remove) {
313
+ this.removeSettingItem(setting.remove);
314
+ }
315
+ if (setting.update) {
316
+ // this.updateSettingItem(setting.update, false)
317
+ }
318
+ };
319
+ _createClass(Control, [
320
+ {
321
+ key: "rules",
322
+ get: function get() {
323
+ var Rules = this.props.constructor.Rules;
324
+ if (Rules) {
325
+ return new Rules(this.props);
326
+ }
327
+ return {};
328
+ }
329
+ }
330
+ ]);
331
+ return Control;
332
+ }();
333
+ Control.controlName = "控件";
334
+ Control.controlIcon = "icon";
335
+ Control.controlType = "control";
336
+ // 控件可以触发的事件key
337
+ Control.controlEventKeys = [];
338
+ Control.controlCustomEvents = [];
339
+ // setting应该是全量的设置项,外部控制,在初始化的时候会deepCopy一份
340
+ Control.setting = [];
341
+ Control.__is_control__ = true;
342
+ // 删除指定的settingItem
343
+ Control.removeSettingItem = removeSetting;
344
+ // 修改指定的settingItem的visible
345
+ Control.updateSettingItem = updateSetting;
346
+ export default Control;
347
+ export { Control as DesignerControl };
348
+ /**
349
+ * @function 删除控件或者实例上的setting的方法
350
+ * @description 其中的this可能是DesignerControl的类,也可以是实例
351
+ * @param keys 需要删除的key或key组成的数组
352
+ * */ function removeSetting(keys) {
353
+ var _this = this;
354
+ var deleteKeys = Array.isArray(keys) ? keys : [
355
+ keys
356
+ ];
357
+ deleteKeys.forEach(function(deleteKey) {
358
+ // 是否存在子项
359
+ var isHasItem = typeof deleteKey !== "string";
360
+ // @ts-ignore
361
+ var settingIndex = _this.setting.findIndex(function(option) {
362
+ return option.key === (isHasItem ? deleteKey.key : deleteKey);
363
+ });
364
+ // 移除对应选项
365
+ if (settingIndex !== -1) {
366
+ var ref, ref1;
367
+ isHasItem ? _this.setting[settingIndex].showItems = (ref = _this.setting[settingIndex].showItems) === null || ref === void 0 ? void 0 : ref.filter(function(item) {
368
+ return !deleteKey.hideItems.includes(item);
369
+ }) : _this.setting.splice(settingIndex, 1);
370
+ // 子项长度为0,自动移除当前设置项
371
+ isHasItem && // @ts-ignore
372
+ !((ref1 = _this.setting[settingIndex].showItems) === null || ref1 === void 0 ? void 0 : ref1.length) && // @ts-ignore
373
+ _this.setting.splice(settingIndex, 1);
374
+ }
375
+ });
376
+ }
377
+ /**
378
+ * @function 修改控件或者实例上的setting的方法
379
+ * @description 其中的this可能是DesignerControl的类,也可以是实例
380
+ * @param settingKey 需要修改的key或者key组成的数组
381
+ * @param value 修改之后的visible值
382
+ * @param value.showItems 需要添加或替换的showItems
383
+ * @param value.type 默认是replace替换,可以更改为push新增
384
+ * */ function updateSetting(settingKey, value) {
385
+ var _this = this;
386
+ var keys = typeof settingKey === "string" ? [
387
+ settingKey
388
+ ] : settingKey;
389
+ keys.forEach(function(key) {
390
+ // @ts-ignore
391
+ var settingItem = _this.setting.find(function(item) {
392
+ return item.key === key;
393
+ });
394
+ if (settingItem) {
395
+ if (typeof value === "boolean") {
396
+ settingItem.visible = value;
397
+ } else if (typeof value === "object") {
398
+ var _type;
399
+ var type = (_type = value.type) !== null && _type !== void 0 ? _type : "replace";
400
+ if (type === "replace") {
401
+ settingItem.showItems = value.showItems;
402
+ } else {
403
+ var _showItems;
404
+ (_showItems = settingItem.showItems).push.apply(_showItems, _toConsumableArray(value.showItems));
405
+ }
406
+ }
407
+ }
408
+ });
409
+ }
@@ -0,0 +1,12 @@
1
+ import Designer from "./designer";
2
+ import Runtime from "./runtime";
3
+ import Property from "./property";
4
+ export default {
5
+ Designer: Designer,
6
+ Runtime: Runtime,
7
+ Property: Property
8
+ };
9
+ export * from "./designer";
10
+ export * from "./runtime";
11
+ export * from "./property";
12
+ export * from "./types";
@@ -0,0 +1,160 @@
1
+ function _assertThisInitialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _classCallCheck(instance, Constructor) {
8
+ if (!(instance instanceof Constructor)) {
9
+ throw new TypeError("Cannot call a class as a function");
10
+ }
11
+ }
12
+ function isNativeReflectConstruct() {
13
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
14
+ if (Reflect.construct.sham) return false;
15
+ if (typeof Proxy === "function") return true;
16
+ try {
17
+ Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
18
+ return true;
19
+ } catch (e) {
20
+ return false;
21
+ }
22
+ }
23
+ function _construct(Parent, args, Class) {
24
+ if (isNativeReflectConstruct()) {
25
+ _construct = Reflect.construct;
26
+ } else {
27
+ _construct = function _construct(Parent, args, Class) {
28
+ var a = [
29
+ null
30
+ ];
31
+ a.push.apply(a, args);
32
+ var Constructor = Function.bind.apply(Parent, a);
33
+ var instance = new Constructor();
34
+ if (Class) _setPrototypeOf(instance, Class.prototype);
35
+ return instance;
36
+ };
37
+ }
38
+ return _construct.apply(null, arguments);
39
+ }
40
+ function _getPrototypeOf(o) {
41
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
42
+ return o.__proto__ || Object.getPrototypeOf(o);
43
+ };
44
+ return _getPrototypeOf(o);
45
+ }
46
+ function _inherits(subClass, superClass) {
47
+ if (typeof superClass !== "function" && superClass !== null) {
48
+ throw new TypeError("Super expression must either be null or a function");
49
+ }
50
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
51
+ constructor: {
52
+ value: subClass,
53
+ writable: true,
54
+ configurable: true
55
+ }
56
+ });
57
+ if (superClass) _setPrototypeOf(subClass, superClass);
58
+ }
59
+ function _isNativeFunction(fn) {
60
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
61
+ }
62
+ function _possibleConstructorReturn(self, call) {
63
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
64
+ return call;
65
+ }
66
+ return _assertThisInitialized(self);
67
+ }
68
+ function _setPrototypeOf(o, p) {
69
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
70
+ o.__proto__ = p;
71
+ return o;
72
+ };
73
+ return _setPrototypeOf(o, p);
74
+ }
75
+ var _typeof = function(obj) {
76
+ "@swc/helpers - typeof";
77
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
78
+ };
79
+ function _wrapNativeSuper(Class) {
80
+ var _cache = typeof Map === "function" ? new Map() : undefined;
81
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
82
+ if (Class === null || !_isNativeFunction(Class)) return Class;
83
+ if (typeof Class !== "function") {
84
+ throw new TypeError("Super expression must either be null or a function");
85
+ }
86
+ if (typeof _cache !== "undefined") {
87
+ if (_cache.has(Class)) return _cache.get(Class);
88
+ _cache.set(Class, Wrapper);
89
+ }
90
+ function Wrapper() {
91
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
92
+ }
93
+ Wrapper.prototype = Object.create(Class.prototype, {
94
+ constructor: {
95
+ value: Wrapper,
96
+ enumerable: false,
97
+ writable: true,
98
+ configurable: true
99
+ }
100
+ });
101
+ return _setPrototypeOf(Wrapper, Class);
102
+ };
103
+ return _wrapNativeSuper(Class);
104
+ }
105
+ function _isNativeReflectConstruct() {
106
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
107
+ if (Reflect.construct.sham) return false;
108
+ if (typeof Proxy === "function") return true;
109
+ try {
110
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
111
+ return true;
112
+ } catch (e) {
113
+ return false;
114
+ }
115
+ }
116
+ function _createSuper(Derived) {
117
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
118
+ return function _createSuperInternal() {
119
+ var Super = _getPrototypeOf(Derived), result;
120
+ if (hasNativeReflectConstruct) {
121
+ var NewTarget = _getPrototypeOf(this).constructor;
122
+ result = Reflect.construct(Super, arguments, NewTarget);
123
+ } else {
124
+ result = Super.apply(this, arguments);
125
+ }
126
+ return _possibleConstructorReturn(this, result);
127
+ };
128
+ }
129
+ import { BaseStyle } from "../../framework";
130
+ var PropertyRules = function PropertyRules(props) {
131
+ "use strict";
132
+ _classCallCheck(this, PropertyRules);
133
+ this.isHide = {
134
+ type: "boolean"
135
+ };
136
+ };
137
+ var PropertyRuntimeRules = /*#__PURE__*/ function(Array1) {
138
+ "use strict";
139
+ _inherits(PropertyRuntimeRules, Array1);
140
+ var _super = _createSuper(PropertyRuntimeRules);
141
+ function PropertyRuntimeRules(props) {
142
+ _classCallCheck(this, PropertyRuntimeRules);
143
+ return _super.call(this);
144
+ }
145
+ return PropertyRuntimeRules;
146
+ }(_wrapNativeSuper(Array));
147
+ var Property = function Property(props) {
148
+ "use strict";
149
+ var caption = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
150
+ _classCallCheck(this, Property);
151
+ var ref;
152
+ this.isHide = (ref = props === null || props === void 0 ? void 0 : props.isHide) !== null && ref !== void 0 ? ref : false;
153
+ this.style = new BaseStyle(props === null || props === void 0 ? void 0 : props.style);
154
+ var ref1;
155
+ this.caption = (ref1 = props === null || props === void 0 ? void 0 : props.caption) !== null && ref1 !== void 0 ? ref1 : caption;
156
+ };
157
+ Property.Rules = PropertyRules;
158
+ Property.RuntimeRules = PropertyRuntimeRules;
159
+ export default Property;
160
+ export { Property, PropertyRules, PropertyRuntimeRules };
@@ -0,0 +1,72 @@
1
+ function _classCallCheck(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
13
+ }
14
+ }
15
+ function _createClass(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
20
+ function _instanceof(left, right) {
21
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
22
+ return !!right[Symbol.hasInstance](left);
23
+ } else {
24
+ return left instanceof right;
25
+ }
26
+ }
27
+ import Property from "./property";
28
+ import { genNonDuplicateId, referenceError } from "@byteluck-fe/model-driven-shared";
29
+ import { PAGE_STATUS } from "../../framework";
30
+ var Control = /*#__PURE__*/ function _target() {
31
+ "use strict";
32
+ function Control(props) {
33
+ _classCallCheck(this, Control);
34
+ this.customEvents = [];
35
+ this.parent = null;
36
+ var ref = _instanceof(this, Control) ? this.constructor : void 0, controlType = ref.controlType, controlFieldType = ref.controlFieldType, name = ref.name, controlCustomEvents = ref.controlCustomEvents;
37
+ if (!controlType) {
38
+ referenceError("The ".concat(name, " controlType is not define"));
39
+ }
40
+ var ref1;
41
+ this.id = (ref1 = props === null || props === void 0 ? void 0 : props.id) !== null && ref1 !== void 0 ? ref1 : genNonDuplicateId(10);
42
+ var ref2;
43
+ this.type = (ref2 = props === null || props === void 0 ? void 0 : props.type) !== null && ref2 !== void 0 ? ref2 : controlType;
44
+ this.props = new Property(props === null || props === void 0 ? void 0 : props.props);
45
+ this.customEvents = controlCustomEvents;
46
+ var ref3;
47
+ this.controlType = (ref3 = props === null || props === void 0 ? void 0 : props.controlType) !== null && ref3 !== void 0 ? ref3 : "base";
48
+ var ref4;
49
+ this.fieldType = (ref4 = props === null || props === void 0 ? void 0 : props.fieldType) !== null && ref4 !== void 0 ? ref4 : controlFieldType;
50
+ var ref5;
51
+ this.pageStatus = (ref5 = props === null || props === void 0 ? void 0 : props.pageStatus) !== null && ref5 !== void 0 ? ref5 : PAGE_STATUS.UNKNOWN;
52
+ }
53
+ _createClass(Control, [
54
+ {
55
+ key: "rules",
56
+ get: function get() {
57
+ var Rules = this.props.constructor.RuntimeRules;
58
+ if (Rules) {
59
+ var rules = new Rules(this.props);
60
+ return Array.from(rules);
61
+ }
62
+ return [];
63
+ }
64
+ }
65
+ ]);
66
+ return Control;
67
+ }();
68
+ Control.controlType = "control";
69
+ Control.__is_control__ = true;
70
+ Control.controlCustomEvents = [];
71
+ export default Control;
72
+ export { Control as RuntimeControl };
@@ -0,0 +1 @@
1
+ export { };