neo.mjs 4.6.8 → 4.6.9
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/examples/form/field/checkbox/MainContainer.mjs +111 -0
- package/examples/form/field/checkbox/app.mjs +6 -0
- package/examples/form/field/checkbox/index.html +11 -0
- package/examples/form/field/checkbox/neo-config.json +6 -0
- package/examples/form/field/radio/MainContainer.mjs +111 -0
- package/examples/form/field/radio/app.mjs +6 -0
- package/examples/form/field/radio/index.html +11 -0
- package/examples/form/field/radio/neo-config.json +6 -0
- package/package.json +1 -1
- package/resources/scss/src/form/field/CheckBox.scss +10 -0
- package/resources/scss/src/form/field/Radio.scss +10 -0
- package/src/form/field/CheckBox.mjs +55 -24
@@ -0,0 +1,111 @@
|
|
1
|
+
import CheckBox from '../../../../src/form/field/CheckBox.mjs';
|
2
|
+
import ConfigurationViewport from '../../../ConfigurationViewport.mjs';
|
3
|
+
import NumberField from '../../../../src/form/field/Number.mjs';
|
4
|
+
import Radio from '../../../../src/form/field/Radio.mjs';
|
5
|
+
import TextField from '../../../../src/form/field/Text.mjs';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @class Neo.examples.form.field.checkbox.MainContainer
|
9
|
+
* @extends Neo.examples.ConfigurationViewport
|
10
|
+
*/
|
11
|
+
class MainContainer extends ConfigurationViewport {
|
12
|
+
static getConfig() {return {
|
13
|
+
className : 'Neo.examples.form.field.checkbox.MainContainer',
|
14
|
+
autoMount : true,
|
15
|
+
configItemLabelWidth: 160,
|
16
|
+
layout : {ntype: 'hbox', align: 'stretch'}
|
17
|
+
}}
|
18
|
+
|
19
|
+
createConfigurationComponents() {
|
20
|
+
let me = this;
|
21
|
+
|
22
|
+
return [{
|
23
|
+
module : CheckBox,
|
24
|
+
checked : me.exampleComponent.disabled,
|
25
|
+
labelText: 'disabled',
|
26
|
+
listeners: {change: me.onConfigChange.bind(me, 'disabled')},
|
27
|
+
style : {marginTop: '10px'}
|
28
|
+
}, {
|
29
|
+
module : CheckBox,
|
30
|
+
checked : me.exampleComponent.hideLabel,
|
31
|
+
labelText: 'hideLabel',
|
32
|
+
listeners: {change: me.onConfigChange.bind(me, 'hideLabel')},
|
33
|
+
style : {marginTop: '10px'}
|
34
|
+
}, {
|
35
|
+
module : Radio,
|
36
|
+
checked : me.exampleComponent.labelPosition === 'left',
|
37
|
+
hideValueLabel: false,
|
38
|
+
labelText : 'labelPosition',
|
39
|
+
listeners : {change: me.onRadioChange.bind(me, 'labelPosition', 'left')},
|
40
|
+
name : 'labelPosition',
|
41
|
+
style : {marginTop: '10px'},
|
42
|
+
valueLabelText: 'left'
|
43
|
+
}, {
|
44
|
+
module : Radio,
|
45
|
+
checked : me.exampleComponent.labelPosition === 'top',
|
46
|
+
hideValueLabel: false,
|
47
|
+
labelText : '',
|
48
|
+
listeners : {change: me.onRadioChange.bind(me, 'labelPosition', 'top')},
|
49
|
+
name : 'labelPosition',
|
50
|
+
valueLabelText: 'top'
|
51
|
+
}, {
|
52
|
+
module : TextField,
|
53
|
+
labelText: 'labelText',
|
54
|
+
listeners: {change: me.onConfigChange.bind(me, 'labelText')},
|
55
|
+
style : {marginTop: '10px'},
|
56
|
+
value : me.exampleComponent.labelText
|
57
|
+
}, {
|
58
|
+
module : NumberField,
|
59
|
+
labelText: 'labelWidth',
|
60
|
+
listeners: {change: me.onConfigChange.bind(me, 'labelWidth')},
|
61
|
+
maxValue : 200,
|
62
|
+
minValue : 50,
|
63
|
+
stepSize : 5,
|
64
|
+
value : me.exampleComponent.labelWidth
|
65
|
+
}, {
|
66
|
+
module : CheckBox,
|
67
|
+
checked : me.exampleComponent.readOnly,
|
68
|
+
labelText: 'readOnly',
|
69
|
+
listeners: {change: me.onConfigChange.bind(me, 'readOnly')},
|
70
|
+
style : {marginTop: '10px'}
|
71
|
+
}, {
|
72
|
+
module : CheckBox,
|
73
|
+
checked : me.exampleComponent.required,
|
74
|
+
labelText: 'required',
|
75
|
+
listeners: {change: me.onConfigChange.bind(me, 'required')},
|
76
|
+
style : {marginTop: '10px'}
|
77
|
+
}, {
|
78
|
+
module : TextField,
|
79
|
+
labelText: 'valueLabelText',
|
80
|
+
listeners: {change: me.onConfigChange.bind(me, 'valueLabelText')},
|
81
|
+
style : {marginTop: '10px'},
|
82
|
+
value : me.exampleComponent.valueLabelText
|
83
|
+
}, {
|
84
|
+
module : NumberField,
|
85
|
+
labelText: 'width',
|
86
|
+
listeners: {change: me.onConfigChange.bind(me, 'width')},
|
87
|
+
maxValue : 500,
|
88
|
+
minValue : 50,
|
89
|
+
stepSize : 5,
|
90
|
+
style : {marginTop: '10px'},
|
91
|
+
value : me.exampleComponent.width
|
92
|
+
}, {
|
93
|
+
ntype : 'button',
|
94
|
+
handler: (() => {me.exampleComponent.reset()}),
|
95
|
+
style : {marginTop: '10px', width: '50%'},
|
96
|
+
text : 'reset()'
|
97
|
+
}];
|
98
|
+
}
|
99
|
+
|
100
|
+
createExampleComponent() {
|
101
|
+
return Neo.create(CheckBox, {
|
102
|
+
labelText : 'Label',
|
103
|
+
labelWidth: 70,
|
104
|
+
width : 200
|
105
|
+
});
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
Neo.applyClassConfig(MainContainer);
|
110
|
+
|
111
|
+
export default MainContainer;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!DOCTYPE HTML>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
<title>Neo CheckBoxField</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<script src="../../../../src/MicroLoader.mjs" type="module"></script>
|
10
|
+
</body>
|
11
|
+
</html>
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import CheckBox from '../../../../src/form/field/CheckBox.mjs';
|
2
|
+
import ConfigurationViewport from '../../../ConfigurationViewport.mjs';
|
3
|
+
import NumberField from '../../../../src/form/field/Number.mjs';
|
4
|
+
import Radio from '../../../../src/form/field/Radio.mjs';
|
5
|
+
import TextField from '../../../../src/form/field/Text.mjs';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @class Neo.examples.form.field.radio.MainContainer
|
9
|
+
* @extends Neo.examples.ConfigurationViewport
|
10
|
+
*/
|
11
|
+
class MainContainer extends ConfigurationViewport {
|
12
|
+
static getConfig() {return {
|
13
|
+
className : 'Neo.examples.form.field.radio.MainContainer',
|
14
|
+
autoMount : true,
|
15
|
+
configItemLabelWidth: 160,
|
16
|
+
layout : {ntype: 'hbox', align: 'stretch'}
|
17
|
+
}}
|
18
|
+
|
19
|
+
createConfigurationComponents() {
|
20
|
+
let me = this;
|
21
|
+
|
22
|
+
return [{
|
23
|
+
module : CheckBox,
|
24
|
+
checked : me.exampleComponent.disabled,
|
25
|
+
labelText: 'disabled',
|
26
|
+
listeners: {change: me.onConfigChange.bind(me, 'disabled')},
|
27
|
+
style : {marginTop: '10px'}
|
28
|
+
}, {
|
29
|
+
module : CheckBox,
|
30
|
+
checked : me.exampleComponent.hideLabel,
|
31
|
+
labelText: 'hideLabel',
|
32
|
+
listeners: {change: me.onConfigChange.bind(me, 'hideLabel')},
|
33
|
+
style : {marginTop: '10px'}
|
34
|
+
}, {
|
35
|
+
module : Radio,
|
36
|
+
checked : me.exampleComponent.labelPosition === 'left',
|
37
|
+
hideValueLabel: false,
|
38
|
+
labelText : 'labelPosition',
|
39
|
+
listeners : {change: me.onRadioChange.bind(me, 'labelPosition', 'left')},
|
40
|
+
name : 'labelPosition',
|
41
|
+
style : {marginTop: '10px'},
|
42
|
+
valueLabelText: 'left'
|
43
|
+
}, {
|
44
|
+
module : Radio,
|
45
|
+
checked : me.exampleComponent.labelPosition === 'top',
|
46
|
+
hideValueLabel: false,
|
47
|
+
labelText : '',
|
48
|
+
listeners : {change: me.onRadioChange.bind(me, 'labelPosition', 'top')},
|
49
|
+
name : 'labelPosition',
|
50
|
+
valueLabelText: 'top'
|
51
|
+
}, {
|
52
|
+
module : TextField,
|
53
|
+
labelText: 'labelText',
|
54
|
+
listeners: {change: me.onConfigChange.bind(me, 'labelText')},
|
55
|
+
style : {marginTop: '10px'},
|
56
|
+
value : me.exampleComponent.labelText
|
57
|
+
}, {
|
58
|
+
module : NumberField,
|
59
|
+
labelText: 'labelWidth',
|
60
|
+
listeners: {change: me.onConfigChange.bind(me, 'labelWidth')},
|
61
|
+
maxValue : 200,
|
62
|
+
minValue : 50,
|
63
|
+
stepSize : 5,
|
64
|
+
value : me.exampleComponent.labelWidth
|
65
|
+
}, {
|
66
|
+
module : CheckBox,
|
67
|
+
checked : me.exampleComponent.readOnly,
|
68
|
+
labelText: 'readOnly',
|
69
|
+
listeners: {change: me.onConfigChange.bind(me, 'readOnly')},
|
70
|
+
style : {marginTop: '10px'}
|
71
|
+
}, {
|
72
|
+
module : CheckBox,
|
73
|
+
checked : me.exampleComponent.required,
|
74
|
+
labelText: 'required',
|
75
|
+
listeners: {change: me.onConfigChange.bind(me, 'required')},
|
76
|
+
style : {marginTop: '10px'}
|
77
|
+
}, {
|
78
|
+
module : TextField,
|
79
|
+
labelText: 'valueLabelText',
|
80
|
+
listeners: {change: me.onConfigChange.bind(me, 'valueLabelText')},
|
81
|
+
style : {marginTop: '10px'},
|
82
|
+
value : me.exampleComponent.valueLabelText
|
83
|
+
}, {
|
84
|
+
module : NumberField,
|
85
|
+
labelText: 'width',
|
86
|
+
listeners: {change: me.onConfigChange.bind(me, 'width')},
|
87
|
+
maxValue : 500,
|
88
|
+
minValue : 50,
|
89
|
+
stepSize : 5,
|
90
|
+
style : {marginTop: '10px'},
|
91
|
+
value : me.exampleComponent.width
|
92
|
+
}, {
|
93
|
+
ntype : 'button',
|
94
|
+
handler: (() => {me.exampleComponent.reset()}),
|
95
|
+
style : {marginTop: '10px', width: '50%'},
|
96
|
+
text : 'reset()'
|
97
|
+
}];
|
98
|
+
}
|
99
|
+
|
100
|
+
createExampleComponent() {
|
101
|
+
return Neo.create(Radio, {
|
102
|
+
labelText : 'Label',
|
103
|
+
labelWidth: 70,
|
104
|
+
width : 200
|
105
|
+
})
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
Neo.applyClassConfig(MainContainer);
|
110
|
+
|
111
|
+
export default MainContainer;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!DOCTYPE HTML>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
<title>Neo RadioField</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<script src="../../../../src/MicroLoader.mjs" type="module"></script>
|
10
|
+
</body>
|
11
|
+
</html>
|
package/package.json
CHANGED
@@ -1,10 +1,21 @@
|
|
1
|
-
import Base
|
1
|
+
import Base from './Base.mjs';
|
2
|
+
import NeoArray from '../../util/Array.mjs';
|
2
3
|
|
3
4
|
/**
|
4
5
|
* @class Neo.form.field.CheckBox
|
5
6
|
* @extends Neo.form.field.Base
|
6
7
|
*/
|
7
8
|
class CheckBox extends Base {
|
9
|
+
static getStaticConfig() {return {
|
10
|
+
/**
|
11
|
+
* Valid values for labelPosition
|
12
|
+
* @member {String[]} labelPositions=['left','top']
|
13
|
+
* @protected
|
14
|
+
* @static
|
15
|
+
*/
|
16
|
+
labelPositions: ['left', 'top']
|
17
|
+
}}
|
18
|
+
|
8
19
|
static getConfig() {return {
|
9
20
|
/**
|
10
21
|
* @member {String} className='Neo.form.field.CheckBox'
|
@@ -33,14 +44,15 @@ class CheckBox extends Base {
|
|
33
44
|
* @member {Boolean} hideLabel_=false
|
34
45
|
*/
|
35
46
|
hideLabel_: false,
|
36
|
-
/**
|
37
|
-
* @member {Boolean} hideValueLabel_=false
|
38
|
-
*/
|
39
|
-
hideValueLabel_: true,
|
40
47
|
/**
|
41
48
|
* @member {String} inputType_='checkbox'
|
42
49
|
*/
|
43
50
|
inputType_: 'checkbox',
|
51
|
+
/**
|
52
|
+
* Valid values: 'left', 'top'
|
53
|
+
* @member {String} labelPosition_='left'
|
54
|
+
*/
|
55
|
+
labelPosition_: 'left',
|
44
56
|
/**
|
45
57
|
* @member {String} labelText_='LabelText'
|
46
58
|
*/
|
@@ -55,9 +67,9 @@ class CheckBox extends Base {
|
|
55
67
|
*/
|
56
68
|
name_: '',
|
57
69
|
/**
|
58
|
-
* @member {String} valueLabelText_=
|
70
|
+
* @member {String|null} valueLabelText_=null
|
59
71
|
*/
|
60
|
-
valueLabelText_:
|
72
|
+
valueLabelText_: null,
|
61
73
|
/**
|
62
74
|
* @member {Object} _vdom
|
63
75
|
*/
|
@@ -132,17 +144,6 @@ class CheckBox extends Base {
|
|
132
144
|
this.update();
|
133
145
|
}
|
134
146
|
|
135
|
-
/**
|
136
|
-
* Triggered after the hideLabelValue config got changed
|
137
|
-
* @param {String} value
|
138
|
-
* @param {String} oldValue
|
139
|
-
* @protected
|
140
|
-
*/
|
141
|
-
afterSetHideValueLabel(value, oldValue) {
|
142
|
-
this.vdom.cn[2].removeDom = value;
|
143
|
-
this.update();
|
144
|
-
}
|
145
|
-
|
146
147
|
/**
|
147
148
|
* Triggered after the id config got changed
|
148
149
|
* @param {String} value
|
@@ -172,6 +173,21 @@ class CheckBox extends Base {
|
|
172
173
|
this.update();
|
173
174
|
}
|
174
175
|
|
176
|
+
/**
|
177
|
+
* Triggered after the labelPosition config got changed
|
178
|
+
* @param {String} value
|
179
|
+
* @param {String} oldValue
|
180
|
+
* @protected
|
181
|
+
*/
|
182
|
+
afterSetLabelPosition(value, oldValue) {
|
183
|
+
let me = this,
|
184
|
+
cls = me.cls;
|
185
|
+
|
186
|
+
NeoArray.remove(cls, 'neo-label-' + oldValue);
|
187
|
+
NeoArray.add( cls, 'neo-label-' + value);
|
188
|
+
me.cls = cls;
|
189
|
+
}
|
190
|
+
|
175
191
|
/**
|
176
192
|
* Triggered after the labelText config got changed
|
177
193
|
* @param {String} value
|
@@ -226,17 +242,32 @@ class CheckBox extends Base {
|
|
226
242
|
|
227
243
|
/**
|
228
244
|
* Triggered after the valueLabel config got changed
|
229
|
-
* @param {String} value
|
230
|
-
* @param {String} oldValue
|
245
|
+
* @param {String|null} value
|
246
|
+
* @param {String|null} oldValue
|
231
247
|
* @protected
|
232
248
|
*/
|
233
249
|
afterSetValueLabelText(value, oldValue) {
|
234
|
-
let me
|
250
|
+
let me = this,
|
251
|
+
valueLabel = me.vdom.cn[2],
|
252
|
+
showLabel = !!value; // hide the label, in case value === null || value === ''
|
235
253
|
|
236
|
-
if (
|
237
|
-
|
238
|
-
me.update();
|
254
|
+
if (showLabel) {
|
255
|
+
valueLabel.innerHTML = value;
|
239
256
|
}
|
257
|
+
|
258
|
+
valueLabel.removeDom = !showLabel;
|
259
|
+
me.update();
|
260
|
+
}
|
261
|
+
|
262
|
+
/**
|
263
|
+
* Triggered before the labelPosition config gets changed
|
264
|
+
* @param {String} value
|
265
|
+
* @param {String} oldValue
|
266
|
+
* @protected
|
267
|
+
* @returns {String}
|
268
|
+
*/
|
269
|
+
beforeSetLabelPosition(value, oldValue) {
|
270
|
+
return this.beforeSetEnumValue(value, oldValue, 'labelPosition');
|
240
271
|
}
|
241
272
|
|
242
273
|
/**
|