@byteluck-fe/model-driven-core 2.7.0-alpha.2 → 2.7.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/common/BaseControl/designer.js +228 -191
- package/dist/esm/common/BaseControl/property.js +29 -4
- package/dist/esm/common/BaseControl/runtime.js +26 -5
- package/dist/esm/common/ColumnControl/designer.js +15 -1
- package/dist/esm/common/ColumnControl/property.js +59 -11
- package/dist/esm/common/ColumnControl/runtime.js +15 -1
- package/dist/esm/common/FormControl/designer.js +18 -3
- package/dist/esm/common/FormControl/property.js +86 -21
- package/dist/esm/common/FormControl/runtime.js +16 -1
- package/dist/esm/common/LayoutControl/designer.js +104 -70
- package/dist/esm/common/LayoutControl/runtime.js +16 -1
- package/dist/esm/common/ListControl/designer.js +86 -61
- package/dist/esm/common/ListControl/property.js +14 -0
- package/dist/esm/common/ListControl/runtime.js +16 -1
- package/dist/esm/common/SearchViewControl/designer.js +15 -1
- package/dist/esm/common/SearchViewControl/property.js +14 -0
- package/dist/esm/common/SearchViewControl/runtime.js +15 -1
- package/dist/esm/common/WrapControl/designer.js +15 -1
- package/dist/esm/common/WrapControl/runtime.js +15 -1
- package/dist/esm/framework/RegisterControls.js +197 -128
- package/dist/esm/framework/index.js +437 -3
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -3,147 +3,216 @@ 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
|
|
13
|
-
this
|
|
14
|
-
this
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
// @ts-ignore
|
|
133
|
+
if (this.isListControl(schema) && schema.props.headers) {
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
schema.props.headers = schema.props.headers.map(function(item) {
|
|
136
|
+
return(// @ts-ignore
|
|
137
|
+
_this.createControl(item, beforeCreateInstance));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
var Constructor = this.getControlFormType(schema.type);
|
|
142
|
+
if (Constructor) {
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
var createSchema = schema;
|
|
145
|
+
if (typeof beforeCreateInstance === "function") {
|
|
146
|
+
var result = beforeCreateInstance(createSchema);
|
|
147
|
+
if (result) {
|
|
148
|
+
createSchema = result;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
var control = new Constructor(createSchema);
|
|
153
|
+
// this.defineParentToChildren(control)
|
|
154
|
+
return control;
|
|
155
|
+
} else {
|
|
156
|
+
error(// @ts-ignore
|
|
157
|
+
"The constructor of ".concat(schema.type, " could not be found, please confirm that the constructor has been registered"));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
key: "createControlInstance",
|
|
163
|
+
value: function createControlInstance(type, initSchema) {
|
|
164
|
+
var Constructor = this.getControlFormType(type);
|
|
165
|
+
if (Constructor) {
|
|
166
|
+
// @ts-ignore
|
|
167
|
+
return new Constructor(initSchema);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
key: "getControlFormType",
|
|
173
|
+
value: // 根据xtype获取控件类
|
|
174
|
+
function getControlFormType(type) {
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
return this._controls.find(function(Control) {
|
|
177
|
+
return Control.controlType === type;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
key: "_initControls",
|
|
183
|
+
value: // 初始化_controls,得到所有可用控件类组成的扁平数组
|
|
184
|
+
function _initControls(type) {
|
|
185
|
+
var _this = this;
|
|
186
|
+
this.constructor.staticControls.forEach(function(item) {
|
|
187
|
+
_this.register(item[type]);
|
|
188
|
+
});
|
|
96
189
|
}
|
|
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
190
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
191
|
+
], [
|
|
192
|
+
{
|
|
193
|
+
key: "register",
|
|
194
|
+
value: function register(control) {
|
|
195
|
+
var Designer = control.Designer, Runtime = control.Runtime;
|
|
196
|
+
if (!Designer || !Runtime || !Designer.__is_control__ || !Runtime.__is_control__) {
|
|
197
|
+
error("".concat(control, " is can't register as a Control"));
|
|
198
|
+
}
|
|
199
|
+
var repeatRegisterIndex = this.staticControls.findIndex(function(item) {
|
|
200
|
+
return item.Designer.controlType === Designer.controlType;
|
|
201
|
+
});
|
|
202
|
+
if (repeatRegisterIndex > -1) {
|
|
203
|
+
warn("The ".concat(Designer.controlType, " is repeat register, So it overwrites the one that was registered before."));
|
|
204
|
+
this.staticControls.splice(repeatRegisterIndex, 1);
|
|
205
|
+
}
|
|
206
|
+
this.staticRegisteredTypes.add(Designer.controlType);
|
|
207
|
+
this.staticControls.push(control);
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
138
210
|
}
|
|
139
|
-
|
|
140
|
-
this.staticControls.push(control);
|
|
141
|
-
return this;
|
|
142
|
-
};
|
|
211
|
+
]);
|
|
143
212
|
return RegisterControls;
|
|
144
213
|
}();
|
|
145
|
-
RegisterControls
|
|
146
|
-
RegisterControls
|
|
214
|
+
_defineProperty(RegisterControls, "staticControls", baseStaticControls);
|
|
215
|
+
_defineProperty(RegisterControls, "staticRegisteredTypes", new Set(baseStaticControls.map(function(item) {
|
|
147
216
|
return item.Designer.controlType;
|
|
148
|
-
}));
|
|
149
|
-
RegisterControls
|
|
217
|
+
})));
|
|
218
|
+
_defineProperty(RegisterControls, "staticRegisteredConfigs", new Map());
|