@byteluck-fe/model-driven-core 2.7.0-alpha.13 → 2.7.0-alpha.15a
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 +99 -243
- package/dist/esm/common/BaseControl/index.js +7 -7
- package/dist/esm/common/BaseControl/property.js +14 -42
- package/dist/esm/common/BaseControl/runtime.js +21 -41
- package/dist/esm/common/ColumnControl/designer.js +5 -19
- package/dist/esm/common/ColumnControl/index.js +6 -6
- package/dist/esm/common/ColumnControl/property.js +47 -95
- package/dist/esm/common/ColumnControl/runtime.js +5 -19
- package/dist/esm/common/ControlArray.js +21 -19
- package/dist/esm/common/FormControl/designer.js +10 -25
- package/dist/esm/common/FormControl/index.js +6 -6
- package/dist/esm/common/FormControl/property.js +95 -157
- package/dist/esm/common/FormControl/runtime.js +5 -20
- package/dist/esm/common/LayoutControl/designer.js +30 -158
- 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 -22
- package/dist/esm/common/ListControl/designer.js +29 -154
- package/dist/esm/common/ListControl/index.js +6 -6
- package/dist/esm/common/ListControl/property.js +6 -21
- package/dist/esm/common/ListControl/runtime.js +8 -23
- package/dist/esm/common/SearchViewControl/designer.js +5 -19
- package/dist/esm/common/SearchViewControl/index.js +6 -6
- package/dist/esm/common/SearchViewControl/property.js +4 -18
- package/dist/esm/common/SearchViewControl/runtime.js +5 -19
- package/dist/esm/common/Validator.js +5 -5
- package/dist/esm/common/WrapControl/designer.js +5 -19
- 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 -19
- 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 +84 -33
- package/dist/esm/framework/index.js +332 -769
- package/dist/esm/index.js +4 -4
- package/dist/index.umd.js +1 -1
- package/dist/types/common/BaseControl/designer.d.ts +2 -5
- package/dist/types/common/BaseControl/property.d.ts +2 -0
- package/dist/types/common/BaseControl/runtime.d.ts +2 -1
- package/dist/types/common/ControlArray.d.ts +4 -3
- package/dist/types/common/ListControl/property.d.ts +1 -1
- package/dist/types/common/Validator.d.ts +1 -1
- package/dist/types/common/controlHooksEmitter.d.ts +1 -1
- package/dist/types/framework/RegisterControls.d.ts +4 -1
- package/dist/types/type.d.ts +23 -23
- package/package.json +3 -3
|
@@ -9,19 +9,6 @@ function _classCallCheck(instance, Constructor) {
|
|
|
9
9
|
throw new TypeError("Cannot call a class as a function");
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function _defineProperty(obj, key, value) {
|
|
13
|
-
if (key in obj) {
|
|
14
|
-
Object.defineProperty(obj, key, {
|
|
15
|
-
value: value,
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true
|
|
19
|
-
});
|
|
20
|
-
} else {
|
|
21
|
-
obj[key] = value;
|
|
22
|
-
}
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
12
|
function _getPrototypeOf(o) {
|
|
26
13
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
27
14
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
@@ -82,18 +69,17 @@ function _createSuper(Derived) {
|
|
|
82
69
|
return _possibleConstructorReturn(this, result);
|
|
83
70
|
};
|
|
84
71
|
}
|
|
85
|
-
import WrapControlProperty from
|
|
86
|
-
import { RuntimeLayoutControl } from
|
|
87
|
-
var WrapControl = /*#__PURE__*/ function(
|
|
72
|
+
import WrapControlProperty from './property';
|
|
73
|
+
import { RuntimeLayoutControl } from '../LayoutControl';
|
|
74
|
+
var WrapControl = /*#__PURE__*/ function(RuntimeLayoutControl1) {
|
|
88
75
|
"use strict";
|
|
89
|
-
_inherits(WrapControl,
|
|
76
|
+
_inherits(WrapControl, RuntimeLayoutControl1);
|
|
90
77
|
var _super = _createSuper(WrapControl);
|
|
91
78
|
function WrapControl(props) {
|
|
92
79
|
_classCallCheck(this, WrapControl);
|
|
93
80
|
var _this;
|
|
94
81
|
_this = _super.call(this, props);
|
|
95
|
-
|
|
96
|
-
_defineProperty(_assertThisInitialized(_this), "props", void 0);
|
|
82
|
+
_this.controlType = 'wrap';
|
|
97
83
|
_this.props = new WrapControlProperty(props === null || props === void 0 ? void 0 : props.props);
|
|
98
84
|
return _this;
|
|
99
85
|
}
|
package/dist/esm/common/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
1
|
+
export * from './BaseControl';
|
|
2
|
+
export * from './FormControl';
|
|
3
|
+
export * from './LayoutControl';
|
|
4
|
+
export * from './ListControl';
|
|
5
|
+
export * from './ColumnControl';
|
|
6
|
+
export * from './SearchViewControl';
|
|
7
|
+
export * from './WrapControl';
|
|
8
|
+
export * from './Validator';
|
|
9
|
+
export * from './ControlArray';
|
|
10
|
+
export * from './initOptionAndDataSourceRules';
|
|
11
|
+
export * from './initLinkOperationRules';
|
|
12
|
+
export * from './controlHooksEmitter';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { RulesMessage } from
|
|
1
|
+
import { RulesMessage } from '@byteluck-fe/model-driven-shared';
|
|
2
2
|
export function initLinkOperationRules(props) {
|
|
3
|
-
if (props.hasOwnProperty(
|
|
3
|
+
if (props.hasOwnProperty('linkOperationOption') && props.hasOwnProperty('showLinkOperation') && props.showLinkOperation) {
|
|
4
4
|
this.linkOperationOption = [
|
|
5
5
|
{
|
|
6
|
-
type:
|
|
6
|
+
type: 'object',
|
|
7
7
|
fields: {
|
|
8
8
|
formKey: {
|
|
9
|
-
type:
|
|
9
|
+
type: 'string',
|
|
10
10
|
required: true,
|
|
11
|
-
message: RulesMessage.getMessage(
|
|
11
|
+
message: RulesMessage.getMessage('pleaseEnterForm')
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
];
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -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
|
}
|
|
@@ -17,29 +17,16 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
17
17
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
18
|
return Constructor;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
}
|
|
33
|
-
import { error, CONTROL_BASE_TYPE, warn } from "@byteluck-fe/model-driven-shared";
|
|
20
|
+
import { error, CONTROL_BASE_TYPE, warn } from '@byteluck-fe/model-driven-shared';
|
|
21
|
+
import { setPropertyDontEnum } from "../common/ControlArray";
|
|
34
22
|
var baseStaticControls = [];
|
|
35
23
|
export var RegisterControls = /*#__PURE__*/ function() {
|
|
36
24
|
"use strict";
|
|
37
25
|
function RegisterControls(type) {
|
|
38
26
|
_classCallCheck(this, RegisterControls);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
_defineProperty(this, "_type", void 0);
|
|
27
|
+
this.registeredControlTypes = new Set();
|
|
28
|
+
this.controlConfigMap = new Map();
|
|
29
|
+
this._controls = [];
|
|
43
30
|
this._type = type;
|
|
44
31
|
this._initControls(type);
|
|
45
32
|
}
|
|
@@ -116,38 +103,41 @@ export var RegisterControls = /*#__PURE__*/ function() {
|
|
|
116
103
|
{
|
|
117
104
|
key: "createControl",
|
|
118
105
|
value: function createControl(schema, beforeCreateInstance) {
|
|
119
|
-
var _this = this;
|
|
120
106
|
if (Array.isArray(schema)) {
|
|
107
|
+
var _this = this;
|
|
121
108
|
return schema.map(function(item) {
|
|
122
109
|
return _this.createControl(item, beforeCreateInstance);
|
|
123
110
|
});
|
|
124
111
|
}
|
|
125
112
|
// @ts-ignore
|
|
126
113
|
if (schema.children) {
|
|
114
|
+
var _this1 = this;
|
|
127
115
|
// @ts-ignore
|
|
128
116
|
schema.children = schema.children.map(function(item) {
|
|
129
|
-
return
|
|
117
|
+
return _this1.createControl(item, beforeCreateInstance);
|
|
130
118
|
});
|
|
131
119
|
}
|
|
132
120
|
if (this.isListControl(schema)) {
|
|
133
121
|
// @ts-ignore
|
|
134
122
|
var props = schema.props;
|
|
135
123
|
if (props.headers) {
|
|
124
|
+
var _this2 = this;
|
|
136
125
|
// @ts-ignore
|
|
137
126
|
props.headers = props.headers.map(function(item) {
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
return _this2.createControl(item, beforeCreateInstance);
|
|
140
129
|
});
|
|
141
130
|
}
|
|
142
131
|
// list类型的控件,允许存在footer
|
|
143
132
|
if (props.footers) {
|
|
133
|
+
var _this3 = this;
|
|
144
134
|
// @ts-ignore
|
|
145
135
|
props.footers = props.footers.map(function(item) {
|
|
146
136
|
var newctl;
|
|
147
137
|
// footers 允许有空存在
|
|
148
138
|
if (item) {
|
|
149
139
|
// @ts-ignore
|
|
150
|
-
newctl =
|
|
140
|
+
newctl = _this3.createControl(item, beforeCreateInstance);
|
|
151
141
|
}
|
|
152
142
|
return newctl;
|
|
153
143
|
});
|
|
@@ -158,15 +148,21 @@ export var RegisterControls = /*#__PURE__*/ function() {
|
|
|
158
148
|
if (Constructor) {
|
|
159
149
|
// @ts-ignore
|
|
160
150
|
var createSchema = schema;
|
|
161
|
-
if (typeof beforeCreateInstance ===
|
|
151
|
+
if (typeof beforeCreateInstance === 'function') {
|
|
162
152
|
var result = beforeCreateInstance(createSchema);
|
|
163
153
|
if (result) {
|
|
164
154
|
createSchema = result;
|
|
165
155
|
}
|
|
166
156
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
157
|
+
var control;
|
|
158
|
+
if (Constructor.mode === 'Runtime') {
|
|
159
|
+
control = createSchema;
|
|
160
|
+
// this.defineParentToChildren(control)
|
|
161
|
+
this._setParentPrototypeToSchema(control, this);
|
|
162
|
+
} else {
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
control = new Constructor(createSchema);
|
|
165
|
+
}
|
|
170
166
|
return control;
|
|
171
167
|
} else {
|
|
172
168
|
error(// @ts-ignore
|
|
@@ -174,6 +170,45 @@ export var RegisterControls = /*#__PURE__*/ function() {
|
|
|
174
170
|
}
|
|
175
171
|
}
|
|
176
172
|
},
|
|
173
|
+
{
|
|
174
|
+
key: "_setParentPrototypeToSchema",
|
|
175
|
+
value: function _setParentPrototypeToSchema(schema, runtime) {
|
|
176
|
+
// if (Reflect.has(schema, 'parent')) {
|
|
177
|
+
// return
|
|
178
|
+
// }
|
|
179
|
+
if (runtime._type !== 'Runtime') {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
Object.defineProperty(schema, 'parent', {
|
|
183
|
+
get: function get() {
|
|
184
|
+
// @ts-ignore
|
|
185
|
+
var id = schema.id;
|
|
186
|
+
var controlParentIdMap = runtime._controlParentIdMap;
|
|
187
|
+
var instanceMap = runtime.instanceMap;
|
|
188
|
+
if (!controlParentIdMap || !instanceMap) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
var parentId = controlParentIdMap[id];
|
|
192
|
+
var selfInInstances = instanceMap[id];
|
|
193
|
+
if (!parentId && !selfInInstances) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
var selfIndex = selfInInstances.findIndex(function(item) {
|
|
197
|
+
return item == schema;
|
|
198
|
+
});
|
|
199
|
+
var parentInstances = instanceMap[parentId] || [];
|
|
200
|
+
var parentInstance;
|
|
201
|
+
if (parentInstances.length !== selfInInstances.length) {
|
|
202
|
+
parentInstance = parentInstances[0];
|
|
203
|
+
} else {
|
|
204
|
+
parentInstance = parentInstances[selfIndex];
|
|
205
|
+
}
|
|
206
|
+
return parentInstance;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
setPropertyDontEnum(schema, 'parent');
|
|
210
|
+
}
|
|
211
|
+
},
|
|
177
212
|
{
|
|
178
213
|
key: "createControlInstance",
|
|
179
214
|
value: function createControlInstance(type, initSchema) {
|
|
@@ -201,14 +236,28 @@ export var RegisterControls = /*#__PURE__*/ function() {
|
|
|
201
236
|
var _this = this;
|
|
202
237
|
this.constructor.staticControls.forEach(function(item) {
|
|
203
238
|
_this.register(item[type]);
|
|
239
|
+
RegisterControls.staticControlsRuntimeRules.set(item.Runtime.controlType, item.Property.RuntimeRules);
|
|
240
|
+
item.Property.mode = type;
|
|
204
241
|
});
|
|
205
242
|
}
|
|
206
243
|
}
|
|
207
244
|
], [
|
|
245
|
+
{
|
|
246
|
+
key: "staticGetRules",
|
|
247
|
+
value: function staticGetRules(controlType, props) {
|
|
248
|
+
var Rules = RegisterControls.staticControlsRuntimeRules.get(controlType);
|
|
249
|
+
var result = [];
|
|
250
|
+
if (Rules) {
|
|
251
|
+
var rules = new Rules(props);
|
|
252
|
+
result = Array.from(rules);
|
|
253
|
+
}
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
},
|
|
208
257
|
{
|
|
209
258
|
key: "register",
|
|
210
|
-
value: function register(control) {
|
|
211
|
-
var Designer = control.Designer, Runtime = control.Runtime;
|
|
259
|
+
value: function register(control, mode) {
|
|
260
|
+
var Designer = control.Designer, Runtime = control.Runtime, Property = control.Property;
|
|
212
261
|
if (!Designer || !Runtime || !Designer.__is_control__ || !Runtime.__is_control__) {
|
|
213
262
|
error("".concat(control, " is can't register as a Control"));
|
|
214
263
|
}
|
|
@@ -221,14 +270,16 @@ export var RegisterControls = /*#__PURE__*/ function() {
|
|
|
221
270
|
}
|
|
222
271
|
this.staticRegisteredTypes.add(Designer.controlType);
|
|
223
272
|
this.staticControls.push(control);
|
|
273
|
+
Property.mode = mode;
|
|
224
274
|
return this;
|
|
225
275
|
}
|
|
226
276
|
}
|
|
227
277
|
]);
|
|
228
278
|
return RegisterControls;
|
|
229
279
|
}();
|
|
230
|
-
|
|
231
|
-
|
|
280
|
+
RegisterControls.staticControlsRuntimeRules = new Map();
|
|
281
|
+
RegisterControls.staticControls = baseStaticControls;
|
|
282
|
+
RegisterControls.staticRegisteredTypes = new Set(baseStaticControls.map(function(item) {
|
|
232
283
|
return item.Designer.controlType;
|
|
233
|
-
}))
|
|
234
|
-
|
|
284
|
+
}));
|
|
285
|
+
RegisterControls.staticRegisteredConfigs = new Map();
|