@byteluck-fe/model-driven-core 2.7.0-alpha.2 → 2.7.0-alpha.20

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 (29) hide show
  1. package/dist/esm/common/BaseControl/designer.js +229 -191
  2. package/dist/esm/common/BaseControl/property.js +29 -4
  3. package/dist/esm/common/BaseControl/runtime.js +26 -5
  4. package/dist/esm/common/ColumnControl/designer.js +15 -1
  5. package/dist/esm/common/ColumnControl/property.js +59 -11
  6. package/dist/esm/common/ColumnControl/runtime.js +15 -1
  7. package/dist/esm/common/FormControl/designer.js +18 -3
  8. package/dist/esm/common/FormControl/property.js +89 -29
  9. package/dist/esm/common/FormControl/runtime.js +16 -1
  10. package/dist/esm/common/LayoutControl/designer.js +104 -70
  11. package/dist/esm/common/LayoutControl/runtime.js +16 -1
  12. package/dist/esm/common/ListControl/designer.js +95 -61
  13. package/dist/esm/common/ListControl/property.js +16 -0
  14. package/dist/esm/common/ListControl/runtime.js +16 -1
  15. package/dist/esm/common/SearchViewControl/designer.js +15 -1
  16. package/dist/esm/common/SearchViewControl/property.js +14 -0
  17. package/dist/esm/common/SearchViewControl/runtime.js +15 -1
  18. package/dist/esm/common/WrapControl/designer.js +15 -1
  19. package/dist/esm/common/WrapControl/runtime.js +15 -1
  20. package/dist/esm/framework/RegisterControls.js +213 -128
  21. package/dist/esm/framework/index.js +444 -18
  22. package/dist/esm/framework/isDataBind.js +7 -0
  23. package/dist/esm/index.js +1 -0
  24. package/dist/index.umd.js +1 -1
  25. package/dist/types/common/ListControl/property.d.ts +2 -0
  26. package/dist/types/framework/index.d.ts +3 -2
  27. package/dist/types/framework/isDataBind.d.ts +2 -0
  28. package/dist/types/index.d.ts +1 -0
  29. package/package.json +3 -3
@@ -3,147 +3,232 @@ function _classCallCheck(instance, Constructor) {
3
3
  throw new TypeError("Cannot call a class as a function");
4
4
  }
5
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 _defineProperty(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
6
33
  import { error, CONTROL_BASE_TYPE, warn } from "@byteluck-fe/model-driven-shared";
7
34
  var baseStaticControls = [];
8
35
  export var RegisterControls = /*#__PURE__*/ function() {
9
36
  "use strict";
10
37
  function RegisterControls(type) {
11
38
  _classCallCheck(this, RegisterControls);
12
- this.registeredControlTypes = new Set();
13
- this.controlConfigMap = new Map();
14
- this._controls = [];
39
+ _defineProperty(this, "registeredControlTypes", new Set());
40
+ _defineProperty(this, "controlConfigMap", new Map());
41
+ _defineProperty(this, "_controls", []);
42
+ _defineProperty(this, "_type", void 0);
15
43
  this._type = type;
16
44
  this._initControls(type);
17
45
  }
18
- var _proto = RegisterControls.prototype;
19
- _proto.registerControlConfig = function registerControlConfig(type, config) {
20
- this.controlConfigMap.set(type, config);
21
- return this;
22
- };
23
- _proto.getControlConfig = function getControlConfig(type) {
24
- return this.controlConfigMap.get(type);
25
- };
26
- _proto.getControls = function getControls() {
27
- return this._controls;
28
- };
29
- // 注册控件
30
- _proto.register = function register(control) {
31
- // @ts-ignore
32
- if (!control.__is_control__) {
33
- // @ts-ignore
34
- error("".concat(control.name, " is not a Control"));
35
- }
36
- var repeatRegisterIndex = this._controls.findIndex(function(item) {
37
- return item.controlType === control.controlType;
38
- });
39
- if (repeatRegisterIndex > -1) {
40
- // @ts-ignore
41
- warn("The ".concat(control.controlType, " is repeat register, So it overwrites the one that was registered before."));
42
- this._controls.splice(repeatRegisterIndex, 1);
43
- }
44
- this.registeredControlTypes.add(control.controlType);
45
- this._controls.push(control);
46
- return this;
47
- };
48
- _proto.isLayoutControl = function isLayoutControl(// @ts-ignore
49
- schema) {
50
- return schema.controlType === CONTROL_BASE_TYPE.LAYOUT;
51
- };
52
- // @ts-ignore
53
- _proto.isFormControl = function isFormControl(schema) {
54
- return schema.controlType === CONTROL_BASE_TYPE.FORM;
55
- };
56
- // @ts-ignore
57
- _proto.isListControl = function isListControl(schema) {
58
- return schema.controlType === CONTROL_BASE_TYPE.LIST;
59
- };
60
- _proto.isColumnControl = function isColumnControl(// @ts-ignore
61
- schema) {
62
- return schema.controlType === CONTROL_BASE_TYPE.COLUMN;
63
- };
64
- _proto.createControl = function createControl(schema, beforeCreateInstance) {
65
- var _this = this;
66
- if (Array.isArray(schema)) {
67
- return schema.map(function(item) {
68
- return _this.createControl(item, beforeCreateInstance);
69
- });
70
- }
71
- // @ts-ignore
72
- if (schema.children) {
73
- // @ts-ignore
74
- schema.children = schema.children.map(function(item) {
75
- return _this.createControl(item, beforeCreateInstance);
76
- });
77
- }
78
- // @ts-ignore
79
- if (this.isListControl(schema) && schema.props.headers) {
80
- // @ts-ignore
81
- schema.props.headers = schema.props.headers.map(function(item) {
82
- return(// @ts-ignore
83
- _this.createControl(item, beforeCreateInstance));
84
- });
85
- }
86
- // @ts-ignore
87
- var Constructor = this.getControlFormType(schema.type);
88
- if (Constructor) {
89
- // @ts-ignore
90
- var createSchema = schema;
91
- if (typeof beforeCreateInstance === "function") {
92
- var result = beforeCreateInstance(createSchema);
93
- if (result) {
94
- createSchema = result;
46
+ _createClass(RegisterControls, [
47
+ {
48
+ key: "registerControlConfig",
49
+ value: function registerControlConfig(type, config) {
50
+ this.controlConfigMap.set(type, config);
51
+ return this;
52
+ }
53
+ },
54
+ {
55
+ key: "getControlConfig",
56
+ value: function getControlConfig(type) {
57
+ return this.controlConfigMap.get(type);
58
+ }
59
+ },
60
+ {
61
+ key: "getControls",
62
+ value: function getControls() {
63
+ return this._controls;
64
+ }
65
+ },
66
+ {
67
+ key: "register",
68
+ value: // 注册控件
69
+ function register(control) {
70
+ // @ts-ignore
71
+ if (!control.__is_control__) {
72
+ // @ts-ignore
73
+ error("".concat(control.name, " is not a Control"));
95
74
  }
75
+ var repeatRegisterIndex = this._controls.findIndex(function(item) {
76
+ return item.controlType === control.controlType;
77
+ });
78
+ if (repeatRegisterIndex > -1) {
79
+ // @ts-ignore
80
+ warn("The ".concat(control.controlType, " is repeat register, So it overwrites the one that was registered before."));
81
+ this._controls.splice(repeatRegisterIndex, 1);
82
+ }
83
+ this.registeredControlTypes.add(control.controlType);
84
+ this._controls.push(control);
85
+ return this;
86
+ }
87
+ },
88
+ {
89
+ key: "isLayoutControl",
90
+ value: function isLayoutControl(// @ts-ignore
91
+ schema) {
92
+ return schema.controlType === CONTROL_BASE_TYPE.LAYOUT;
93
+ }
94
+ },
95
+ {
96
+ key: "isFormControl",
97
+ value: // @ts-ignore
98
+ function isFormControl(schema) {
99
+ return schema.controlType === CONTROL_BASE_TYPE.FORM;
100
+ }
101
+ },
102
+ {
103
+ key: "isListControl",
104
+ value: // @ts-ignore
105
+ function isListControl(schema) {
106
+ return schema.controlType === CONTROL_BASE_TYPE.LIST;
107
+ }
108
+ },
109
+ {
110
+ key: "isColumnControl",
111
+ value: function isColumnControl(// @ts-ignore
112
+ schema) {
113
+ return schema.controlType === CONTROL_BASE_TYPE.COLUMN;
114
+ }
115
+ },
116
+ {
117
+ key: "createControl",
118
+ value: function createControl(schema, beforeCreateInstance) {
119
+ var _this = this;
120
+ if (Array.isArray(schema)) {
121
+ return schema.map(function(item) {
122
+ return _this.createControl(item, beforeCreateInstance);
123
+ });
124
+ }
125
+ // @ts-ignore
126
+ if (schema.children) {
127
+ // @ts-ignore
128
+ schema.children = schema.children.map(function(item) {
129
+ return _this.createControl(item, beforeCreateInstance);
130
+ });
131
+ }
132
+ if (this.isListControl(schema)) {
133
+ // @ts-ignore
134
+ var props = schema.props;
135
+ if (props.headers) {
136
+ // @ts-ignore
137
+ props.headers = props.headers.map(function(item) {
138
+ return(// @ts-ignore
139
+ _this.createControl(item, beforeCreateInstance));
140
+ });
141
+ }
142
+ // list类型的控件,允许存在footer
143
+ if (props.footers) {
144
+ // @ts-ignore
145
+ props.footers = props.footers.map(function(item) {
146
+ var newctl;
147
+ // footers 允许有空存在
148
+ if (item) {
149
+ // @ts-ignore
150
+ newctl = _this.createControl(item, beforeCreateInstance);
151
+ }
152
+ return newctl;
153
+ });
154
+ }
155
+ }
156
+ // @ts-ignore
157
+ var Constructor = this.getControlFormType(schema.type);
158
+ if (Constructor) {
159
+ // @ts-ignore
160
+ var createSchema = schema;
161
+ if (typeof beforeCreateInstance === "function") {
162
+ var result = beforeCreateInstance(createSchema);
163
+ if (result) {
164
+ createSchema = result;
165
+ }
166
+ }
167
+ // @ts-ignore
168
+ var control = new Constructor(createSchema);
169
+ // this.defineParentToChildren(control)
170
+ return control;
171
+ } else {
172
+ error(// @ts-ignore
173
+ "The constructor of ".concat(schema.type, " could not be found, please confirm that the constructor has been registered"));
174
+ }
175
+ }
176
+ },
177
+ {
178
+ key: "createControlInstance",
179
+ value: function createControlInstance(type, initSchema) {
180
+ var Constructor = this.getControlFormType(type);
181
+ if (Constructor) {
182
+ // @ts-ignore
183
+ return new Constructor(initSchema);
184
+ }
185
+ }
186
+ },
187
+ {
188
+ key: "getControlFormType",
189
+ value: // 根据xtype获取控件类
190
+ function getControlFormType(type) {
191
+ // @ts-ignore
192
+ return this._controls.find(function(Control) {
193
+ return Control.controlType === type;
194
+ });
195
+ }
196
+ },
197
+ {
198
+ key: "_initControls",
199
+ value: // 初始化_controls,得到所有可用控件类组成的扁平数组
200
+ function _initControls(type) {
201
+ var _this = this;
202
+ this.constructor.staticControls.forEach(function(item) {
203
+ _this.register(item[type]);
204
+ });
96
205
  }
97
- // @ts-ignore
98
- var control = new Constructor(createSchema);
99
- // this.defineParentToChildren(control)
100
- return control;
101
- } else {
102
- error(// @ts-ignore
103
- "The constructor of ".concat(schema.type, " could not be found, please confirm that the constructor has been registered"));
104
- }
105
- };
106
- _proto.createControlInstance = function createControlInstance(type, initSchema) {
107
- var Constructor = this.getControlFormType(type);
108
- if (Constructor) {
109
- // @ts-ignore
110
- return new Constructor(initSchema);
111
- }
112
- };
113
- // 根据xtype获取控件类
114
- _proto.getControlFormType = function getControlFormType(type) {
115
- // @ts-ignore
116
- return this._controls.find(function(Control) {
117
- return Control.controlType === type;
118
- });
119
- };
120
- // 初始化_controls,得到所有可用控件类组成的扁平数组
121
- _proto._initControls = function _initControls(type) {
122
- var _this = this;
123
- this.constructor.staticControls.forEach(function(item) {
124
- _this.register(item[type]);
125
- });
126
- };
127
- RegisterControls.register = function register(control) {
128
- var Designer = control.Designer, Runtime = control.Runtime;
129
- if (!Designer || !Runtime || !Designer.__is_control__ || !Runtime.__is_control__) {
130
- error("".concat(control, " is can't register as a Control"));
131
206
  }
132
- var repeatRegisterIndex = this.staticControls.findIndex(function(item) {
133
- return item.Designer.controlType === Designer.controlType;
134
- });
135
- if (repeatRegisterIndex > -1) {
136
- warn("The ".concat(Designer.controlType, " is repeat register, So it overwrites the one that was registered before."));
137
- this.staticControls.splice(repeatRegisterIndex, 1);
207
+ ], [
208
+ {
209
+ key: "register",
210
+ value: function register(control) {
211
+ var Designer = control.Designer, Runtime = control.Runtime;
212
+ if (!Designer || !Runtime || !Designer.__is_control__ || !Runtime.__is_control__) {
213
+ error("".concat(control, " is can't register as a Control"));
214
+ }
215
+ var repeatRegisterIndex = this.staticControls.findIndex(function(item) {
216
+ return item.Designer.controlType === Designer.controlType;
217
+ });
218
+ if (repeatRegisterIndex > -1) {
219
+ warn("The ".concat(Designer.controlType, " is repeat register, So it overwrites the one that was registered before."));
220
+ this.staticControls.splice(repeatRegisterIndex, 1);
221
+ }
222
+ this.staticRegisteredTypes.add(Designer.controlType);
223
+ this.staticControls.push(control);
224
+ return this;
225
+ }
138
226
  }
139
- this.staticRegisteredTypes.add(Designer.controlType);
140
- this.staticControls.push(control);
141
- return this;
142
- };
227
+ ]);
143
228
  return RegisterControls;
144
229
  }();
145
- RegisterControls.staticControls = baseStaticControls;
146
- RegisterControls.staticRegisteredTypes = new Set(baseStaticControls.map(function(item) {
230
+ _defineProperty(RegisterControls, "staticControls", baseStaticControls);
231
+ _defineProperty(RegisterControls, "staticRegisteredTypes", new Set(baseStaticControls.map(function(item) {
147
232
  return item.Designer.controlType;
148
- }));
149
- RegisterControls.staticRegisteredConfigs = new Map();
233
+ })));
234
+ _defineProperty(RegisterControls, "staticRegisteredConfigs", new Map());