@byteluck-fe/model-driven-core 2.7.0-alpha.0 → 2.7.0-alpha.2
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 +309 -226
- package/dist/esm/common/BaseControl/index.js +7 -7
- package/dist/esm/common/BaseControl/property.js +13 -10
- 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 +196 -102
- 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 +184 -84
- 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 +122 -179
- package/dist/esm/framework/index.js +336 -333
- package/dist/esm/index.js +3 -3
- package/dist/index.umd.js +1 -1
- package/dist/types/common/Validator.d.ts +1 -1
- package/dist/types/common/controlHooksEmitter.d.ts +1 -1
- package/dist/types/type.d.ts +23 -23
- package/package.json +3 -3
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import { getNotRepeatItems, RulesMessage } from
|
|
1
|
+
import { getNotRepeatItems, RulesMessage } from "@byteluck-fe/model-driven-shared";
|
|
2
2
|
export function initOptionAndDataSourceRules(props) {
|
|
3
|
-
if (!props.hasOwnProperty(
|
|
3
|
+
if (!props.hasOwnProperty("optionConfig")) {
|
|
4
4
|
this.optionConfig = {
|
|
5
|
-
type:
|
|
5
|
+
type: "any"
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
if (!props.hasOwnProperty(
|
|
8
|
+
if (!props.hasOwnProperty("options")) {
|
|
9
9
|
this.options = {
|
|
10
|
-
type:
|
|
10
|
+
type: "any"
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
if (!props.hasOwnProperty(
|
|
13
|
+
if (!props.hasOwnProperty("datasourceBind")) {
|
|
14
14
|
this.datasourceBind = {
|
|
15
|
-
type:
|
|
15
|
+
type: "any"
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
// 有options属性,并且没有optionConfig或者有options并且optionConfig===custom
|
|
19
|
-
if (props.hasOwnProperty(
|
|
19
|
+
if (props.hasOwnProperty("options") && (!props.hasOwnProperty("optionConfig") || props.hasOwnProperty("optionConfig") && props.optionConfig === "custom")) {
|
|
20
20
|
this.options = [
|
|
21
21
|
{
|
|
22
|
-
type:
|
|
23
|
-
message: RulesMessage.getMessage(
|
|
22
|
+
type: "array",
|
|
23
|
+
message: RulesMessage.getMessage("isNotArray")
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
type:
|
|
26
|
+
type: "array",
|
|
27
27
|
defaultField: {
|
|
28
|
-
type:
|
|
28
|
+
type: "object",
|
|
29
29
|
fields: {
|
|
30
30
|
label: {
|
|
31
|
-
type:
|
|
31
|
+
type: "string",
|
|
32
32
|
required: true,
|
|
33
|
-
message: RulesMessage.getMessage(
|
|
33
|
+
message: RulesMessage.getMessage("pleaseEnterLabel")
|
|
34
34
|
},
|
|
35
35
|
value: {
|
|
36
|
-
type:
|
|
36
|
+
type: "string",
|
|
37
37
|
required: true,
|
|
38
|
-
message: RulesMessage.getMessage(
|
|
38
|
+
message: RulesMessage.getMessage("pleaseEnterValue")
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
|
-
type:
|
|
44
|
+
type: "array",
|
|
45
45
|
validator: function validator(rule, value, callback) {
|
|
46
46
|
if (value.length === 0) {
|
|
47
|
-
callback(RulesMessage.getMessage(
|
|
47
|
+
callback(RulesMessage.getMessage("optionIsRequired"));
|
|
48
48
|
}
|
|
49
49
|
callback();
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
|
-
type:
|
|
53
|
+
type: "array",
|
|
54
54
|
validator: function validator(rule, value, callback) {
|
|
55
55
|
var ids = value.map(function(item) {
|
|
56
56
|
return item.value;
|
|
57
57
|
});
|
|
58
58
|
var notRepeatIds = getNotRepeatItems(ids);
|
|
59
59
|
if (ids.length !== notRepeatIds.length) {
|
|
60
|
-
callback(RulesMessage.getMessage(
|
|
60
|
+
callback(RulesMessage.getMessage("optionIdIsRepeat"));
|
|
61
61
|
} else {
|
|
62
62
|
callback();
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
message: RulesMessage.getMessage(
|
|
66
|
-
}
|
|
65
|
+
message: RulesMessage.getMessage("optionIdIsRepeat")
|
|
66
|
+
}
|
|
67
67
|
];
|
|
68
|
-
} else if (props.hasOwnProperty(
|
|
68
|
+
} else if (props.hasOwnProperty("datasourceBind") && (!props.hasOwnProperty("optionConfig") || props.hasOwnProperty("optionConfig") && props.optionConfig === "datasource")) {
|
|
69
69
|
this.datasourceBind = [
|
|
70
70
|
{
|
|
71
|
-
type:
|
|
72
|
-
message: RulesMessage.getMessage(
|
|
71
|
+
type: "object",
|
|
72
|
+
message: RulesMessage.getMessage("isNotObject")
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
|
-
type:
|
|
75
|
+
type: "object",
|
|
76
76
|
fields: {
|
|
77
77
|
dataCode: {
|
|
78
|
-
type:
|
|
78
|
+
type: "string",
|
|
79
79
|
required: true,
|
|
80
|
-
message: RulesMessage.getMessage(
|
|
80
|
+
message: RulesMessage.getMessage("pleaseEnterDataCode")
|
|
81
81
|
},
|
|
82
82
|
valueFieldCode: {
|
|
83
|
-
type:
|
|
83
|
+
type: "string",
|
|
84
84
|
required: true,
|
|
85
|
-
message: RulesMessage.getMessage(
|
|
85
|
+
message: RulesMessage.getMessage("pleaseEnterValueFieldCode")
|
|
86
86
|
},
|
|
87
87
|
svcCode: {
|
|
88
|
-
type:
|
|
88
|
+
type: "string",
|
|
89
89
|
required: true,
|
|
90
|
-
message: RulesMessage.getMessage(
|
|
90
|
+
message: RulesMessage.getMessage("pleaseEnterSvcCode")
|
|
91
91
|
},
|
|
92
92
|
displayBoList: [
|
|
93
93
|
{
|
|
94
|
-
type:
|
|
95
|
-
message: RulesMessage.getMessage(
|
|
94
|
+
type: "array",
|
|
95
|
+
message: RulesMessage.getMessage("isNotArray")
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
|
-
type:
|
|
98
|
+
type: "array",
|
|
99
99
|
validator: function validator(rule, value, callback) {
|
|
100
100
|
if (value.length === 0) {
|
|
101
|
-
callback(RulesMessage.getMessage(
|
|
101
|
+
callback(RulesMessage.getMessage("pleaseBindAtLeastOneDisplayValue"));
|
|
102
102
|
}
|
|
103
103
|
callback();
|
|
104
104
|
},
|
|
105
|
-
message: RulesMessage.getMessage(
|
|
106
|
-
}
|
|
105
|
+
message: RulesMessage.getMessage("pleaseBindAtLeastOneDisplayValue")
|
|
106
|
+
}
|
|
107
107
|
],
|
|
108
108
|
orders: [
|
|
109
109
|
{
|
|
110
|
-
type:
|
|
111
|
-
message: RulesMessage.getMessage(
|
|
110
|
+
type: "array",
|
|
111
|
+
message: RulesMessage.getMessage("isNotArray")
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
|
-
type:
|
|
114
|
+
type: "array",
|
|
115
115
|
defaultField: {
|
|
116
|
-
type:
|
|
116
|
+
type: "object",
|
|
117
117
|
fields: {
|
|
118
118
|
columnName: {
|
|
119
|
-
type:
|
|
119
|
+
type: "string",
|
|
120
120
|
required: true,
|
|
121
|
-
message: RulesMessage.getMessage(
|
|
121
|
+
message: RulesMessage.getMessage("pleaseEnterFieldCode")
|
|
122
122
|
},
|
|
123
123
|
desc: {
|
|
124
|
-
type:
|
|
125
|
-
message: RulesMessage.getMessage(
|
|
124
|
+
type: "boolean",
|
|
125
|
+
message: RulesMessage.getMessage("isNotBoolean")
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
}
|
|
129
|
+
}
|
|
130
130
|
]
|
|
131
131
|
}
|
|
132
|
-
}
|
|
132
|
+
}
|
|
133
133
|
];
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -137,91 +137,91 @@ export function initSuperDataSourceRules(props, attributes) {
|
|
|
137
137
|
var messageInDataSetting = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
138
138
|
this.datasourceBind = [
|
|
139
139
|
{
|
|
140
|
-
type:
|
|
141
|
-
message: RulesMessage.getMessage(
|
|
140
|
+
type: "object",
|
|
141
|
+
message: RulesMessage.getMessage("isNotObject")
|
|
142
142
|
},
|
|
143
143
|
{
|
|
144
|
-
type:
|
|
144
|
+
type: "object",
|
|
145
145
|
fields: {
|
|
146
146
|
dataCode: {
|
|
147
|
-
type:
|
|
147
|
+
type: "string",
|
|
148
148
|
required: true,
|
|
149
|
-
message: RulesMessage.getMessage(messageInDataSetting ?
|
|
149
|
+
message: RulesMessage.getMessage(messageInDataSetting ? "pleaseEnterDataCodeInDataSetting" : "pleaseEnterDataCode")
|
|
150
150
|
},
|
|
151
151
|
valueFieldCode: {
|
|
152
|
-
type:
|
|
152
|
+
type: "string",
|
|
153
153
|
required: true,
|
|
154
|
-
message: RulesMessage.getMessage(messageInDataSetting ?
|
|
154
|
+
message: RulesMessage.getMessage(messageInDataSetting ? "pleaseEnterValueFieldCodeInDataSetting" : "pleaseEnterValueFieldCode")
|
|
155
155
|
},
|
|
156
156
|
svcCode: {
|
|
157
|
-
type:
|
|
157
|
+
type: "string",
|
|
158
158
|
required: true,
|
|
159
|
-
message: RulesMessage.getMessage(messageInDataSetting ?
|
|
159
|
+
message: RulesMessage.getMessage(messageInDataSetting ? "pleaseEnterSvcCodeInDataSetting" : "pleaseEnterSvcCode")
|
|
160
160
|
},
|
|
161
161
|
attributes: [
|
|
162
162
|
{
|
|
163
|
-
type:
|
|
164
|
-
message: RulesMessage.getMessage(
|
|
163
|
+
type: "array",
|
|
164
|
+
message: RulesMessage.getMessage("isNotArray")
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
|
-
type:
|
|
167
|
+
type: "array",
|
|
168
168
|
defaultField: {
|
|
169
|
-
type:
|
|
169
|
+
type: "object",
|
|
170
170
|
fields: {
|
|
171
171
|
name: {
|
|
172
|
-
type:
|
|
172
|
+
type: "string",
|
|
173
173
|
required: true,
|
|
174
|
-
message: RulesMessage.getMessage(
|
|
174
|
+
message: RulesMessage.getMessage("isNotString")
|
|
175
175
|
},
|
|
176
176
|
key: {
|
|
177
|
-
type:
|
|
177
|
+
type: "string",
|
|
178
178
|
required: true,
|
|
179
|
-
message: RulesMessage.getMessage(
|
|
179
|
+
message: RulesMessage.getMessage("isNotString")
|
|
180
180
|
},
|
|
181
181
|
value: [
|
|
182
182
|
{
|
|
183
|
-
type:
|
|
184
|
-
message: RulesMessage.getMessage(
|
|
183
|
+
type: "array",
|
|
184
|
+
message: RulesMessage.getMessage("isNotArray")
|
|
185
185
|
},
|
|
186
186
|
{
|
|
187
|
-
type:
|
|
187
|
+
type: "array",
|
|
188
188
|
validator: function validator(rule, value, callback) {
|
|
189
189
|
if (value.length === 0) {
|
|
190
|
-
callback(RulesMessage.getMessage(messageInDataSetting ?
|
|
190
|
+
callback(RulesMessage.getMessage(messageInDataSetting ? "pleaseBindAtLeastOneDisplayValueInDataSetting" : "pleaseBindAtLeastOneDisplayValue"));
|
|
191
191
|
}
|
|
192
192
|
callback();
|
|
193
193
|
},
|
|
194
|
-
message: RulesMessage.getMessage(messageInDataSetting ?
|
|
195
|
-
}
|
|
194
|
+
message: RulesMessage.getMessage(messageInDataSetting ? "pleaseBindAtLeastOneDisplayValueInDataSetting" : "pleaseBindAtLeastOneDisplayValue")
|
|
195
|
+
}
|
|
196
196
|
]
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
}
|
|
199
|
+
}
|
|
200
200
|
],
|
|
201
201
|
orders: [
|
|
202
202
|
{
|
|
203
|
-
type:
|
|
204
|
-
message: RulesMessage.getMessage(
|
|
203
|
+
type: "array",
|
|
204
|
+
message: RulesMessage.getMessage("isNotArray")
|
|
205
205
|
},
|
|
206
206
|
{
|
|
207
|
-
type:
|
|
207
|
+
type: "array",
|
|
208
208
|
defaultField: {
|
|
209
|
-
type:
|
|
209
|
+
type: "object",
|
|
210
210
|
fields: {
|
|
211
211
|
columnName: {
|
|
212
|
-
type:
|
|
212
|
+
type: "string",
|
|
213
213
|
required: true,
|
|
214
|
-
message: RulesMessage.getMessage(
|
|
214
|
+
message: RulesMessage.getMessage("pleaseEnterFieldCode")
|
|
215
215
|
},
|
|
216
216
|
desc: {
|
|
217
|
-
type:
|
|
218
|
-
message: RulesMessage.getMessage(
|
|
217
|
+
type: "boolean",
|
|
218
|
+
message: RulesMessage.getMessage("isNotBoolean")
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
}
|
|
222
|
+
}
|
|
223
223
|
]
|
|
224
224
|
}
|
|
225
|
-
}
|
|
225
|
+
}
|
|
226
226
|
];
|
|
227
227
|
}
|
|
@@ -3,21 +3,7 @@ function _classCallCheck(instance, Constructor) {
|
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
|
|
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
|
-
import { error, CONTROL_BASE_TYPE, warn } from '@byteluck-fe/model-driven-shared';
|
|
6
|
+
import { error, CONTROL_BASE_TYPE, warn } from "@byteluck-fe/model-driven-shared";
|
|
21
7
|
var baseStaticControls = [];
|
|
22
8
|
export var RegisterControls = /*#__PURE__*/ function() {
|
|
23
9
|
"use strict";
|
|
@@ -29,174 +15,131 @@ export var RegisterControls = /*#__PURE__*/ function() {
|
|
|
29
15
|
this._type = type;
|
|
30
16
|
this._initControls(type);
|
|
31
17
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return this._controls;
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
key: "register",
|
|
54
|
-
value: // 注册控件
|
|
55
|
-
function register(control) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
if (!control.__is_control__) {
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
error("".concat(control.name, " is not a Control"));
|
|
60
|
-
}
|
|
61
|
-
var repeatRegisterIndex = this._controls.findIndex(function(item) {
|
|
62
|
-
return item.controlType === control.controlType;
|
|
63
|
-
});
|
|
64
|
-
if (repeatRegisterIndex > -1) {
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
warn("The ".concat(control.controlType, " is repeat register, So it overwrites the one that was registered before."));
|
|
67
|
-
this._controls.splice(repeatRegisterIndex, 1);
|
|
68
|
-
}
|
|
69
|
-
this.registeredControlTypes.add(control.controlType);
|
|
70
|
-
this._controls.push(control);
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
key: "isLayoutControl",
|
|
76
|
-
value: function isLayoutControl(// @ts-ignore
|
|
77
|
-
schema) {
|
|
78
|
-
return schema.controlType === CONTROL_BASE_TYPE.LAYOUT;
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
key: "isFormControl",
|
|
83
|
-
value: // @ts-ignore
|
|
84
|
-
function isFormControl(schema) {
|
|
85
|
-
return schema.controlType === CONTROL_BASE_TYPE.FORM;
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
key: "isListControl",
|
|
90
|
-
value: // @ts-ignore
|
|
91
|
-
function isListControl(schema) {
|
|
92
|
-
return schema.controlType === CONTROL_BASE_TYPE.LIST;
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
key: "isColumnControl",
|
|
97
|
-
value: function isColumnControl(// @ts-ignore
|
|
98
|
-
schema) {
|
|
99
|
-
return schema.controlType === CONTROL_BASE_TYPE.COLUMN;
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
key: "createControl",
|
|
104
|
-
value: function createControl(schema, beforeCreateInstance) {
|
|
105
|
-
if (Array.isArray(schema)) {
|
|
106
|
-
var _this = this;
|
|
107
|
-
return schema.map(function(item) {
|
|
108
|
-
return _this.createControl(item, beforeCreateInstance);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
// @ts-ignore
|
|
112
|
-
if (schema.children) {
|
|
113
|
-
var _this1 = this;
|
|
114
|
-
// @ts-ignore
|
|
115
|
-
schema.children = schema.children.map(function(item) {
|
|
116
|
-
return _this1.createControl(item, beforeCreateInstance);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
if (this.isListControl(schema) && schema.props.headers) {
|
|
121
|
-
var _this2 = this;
|
|
122
|
-
// @ts-ignore
|
|
123
|
-
schema.props.headers = schema.props.headers.map(function(item) {
|
|
124
|
-
// @ts-ignore
|
|
125
|
-
return _this2.createControl(item, beforeCreateInstance);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
// @ts-ignore
|
|
129
|
-
var Constructor = this.getControlFormType(schema.type);
|
|
130
|
-
if (Constructor) {
|
|
131
|
-
// @ts-ignore
|
|
132
|
-
var createSchema = schema;
|
|
133
|
-
if (typeof beforeCreateInstance === 'function') {
|
|
134
|
-
var result = beforeCreateInstance(createSchema);
|
|
135
|
-
if (result) {
|
|
136
|
-
createSchema = result;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
// @ts-ignore
|
|
140
|
-
var control = new Constructor(createSchema);
|
|
141
|
-
// this.defineParentToChildren(control)
|
|
142
|
-
return control;
|
|
143
|
-
} else {
|
|
144
|
-
error(// @ts-ignore
|
|
145
|
-
"The constructor of ".concat(schema.type, " could not be found, please confirm that the constructor has been registered"));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
key: "createControlInstance",
|
|
151
|
-
value: function createControlInstance(type, initSchema) {
|
|
152
|
-
var Constructor = this.getControlFormType(type);
|
|
153
|
-
if (Constructor) {
|
|
154
|
-
// @ts-ignore
|
|
155
|
-
return new Constructor(initSchema);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
key: "getControlFormType",
|
|
161
|
-
value: // 根据xtype获取控件类
|
|
162
|
-
function getControlFormType(type) {
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
return this._controls.find(function(Control) {
|
|
165
|
-
return Control.controlType === type;
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
key: "_initControls",
|
|
171
|
-
value: // 初始化_controls,得到所有可用控件类组成的扁平数组
|
|
172
|
-
function _initControls(type) {
|
|
173
|
-
var _this = this;
|
|
174
|
-
this.constructor.staticControls.forEach(function(item) {
|
|
175
|
-
_this.register(item[type]);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
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"));
|
|
178
35
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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;
|
|
193
95
|
}
|
|
194
|
-
this.staticRegisteredTypes.add(Designer.controlType);
|
|
195
|
-
this.staticControls.push(control);
|
|
196
|
-
return this;
|
|
197
96
|
}
|
|
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
|
+
}
|
|
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);
|
|
198
138
|
}
|
|
199
|
-
|
|
139
|
+
this.staticRegisteredTypes.add(Designer.controlType);
|
|
140
|
+
this.staticControls.push(control);
|
|
141
|
+
return this;
|
|
142
|
+
};
|
|
200
143
|
return RegisterControls;
|
|
201
144
|
}();
|
|
202
145
|
RegisterControls.staticControls = baseStaticControls;
|