neo.mjs 4.6.8 → 4.6.10
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/component/Base.mjs +1 -1
- package/src/form/field/CheckBox.mjs +90 -25
- package/src/form/field/Radio.mjs +5 -1
- package/src/form/field/Text.mjs +16 -2
@@ -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
package/src/component/Base.mjs
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,23 @@ 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
|
+
* @member {String[]} labelBaseCls=['neo-checkbox-label']
|
53
|
+
*/
|
54
|
+
labelBaseCls: ['neo-checkbox-label'],
|
55
|
+
/**
|
56
|
+
* @member {String[]} labelCls_=[]
|
57
|
+
*/
|
58
|
+
labelCls_: [],
|
59
|
+
/**
|
60
|
+
* Valid values: 'left', 'top'
|
61
|
+
* @member {String} labelPosition_='left'
|
62
|
+
*/
|
63
|
+
labelPosition_: 'left',
|
44
64
|
/**
|
45
65
|
* @member {String} labelText_='LabelText'
|
46
66
|
*/
|
@@ -55,15 +75,15 @@ class CheckBox extends Base {
|
|
55
75
|
*/
|
56
76
|
name_: '',
|
57
77
|
/**
|
58
|
-
* @member {String} valueLabelText_=
|
78
|
+
* @member {String|null} valueLabelText_=null
|
59
79
|
*/
|
60
|
-
valueLabelText_:
|
80
|
+
valueLabelText_: null,
|
61
81
|
/**
|
62
82
|
* @member {Object} _vdom
|
63
83
|
*/
|
64
84
|
_vdom:
|
65
85
|
{cn: [
|
66
|
-
{tag: 'label', cls: [
|
86
|
+
{tag: 'label', cls: []},
|
67
87
|
{tag: 'input', cls: ['neo-checkbox-input']},
|
68
88
|
{tag: 'label', cls: ['neo-checkbox-value-label']}
|
69
89
|
]}
|
@@ -132,17 +152,6 @@ class CheckBox extends Base {
|
|
132
152
|
this.update();
|
133
153
|
}
|
134
154
|
|
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
155
|
/**
|
147
156
|
* Triggered after the id config got changed
|
148
157
|
* @param {String} value
|
@@ -172,6 +181,37 @@ class CheckBox extends Base {
|
|
172
181
|
this.update();
|
173
182
|
}
|
174
183
|
|
184
|
+
/**
|
185
|
+
* Triggered after the labelCls config got changed
|
186
|
+
* @param {String[]} value
|
187
|
+
* @param {String[]} oldValue
|
188
|
+
* @protected
|
189
|
+
*/
|
190
|
+
afterSetLabelCls(value, oldValue) {
|
191
|
+
let me = this,
|
192
|
+
cls = me.vdom.cn[0].cls;
|
193
|
+
|
194
|
+
NeoArray.remove(cls, oldValue);
|
195
|
+
NeoArray.add(cls, value);
|
196
|
+
|
197
|
+
me.update();
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Triggered after the labelPosition config got changed
|
202
|
+
* @param {String} value
|
203
|
+
* @param {String} oldValue
|
204
|
+
* @protected
|
205
|
+
*/
|
206
|
+
afterSetLabelPosition(value, oldValue) {
|
207
|
+
let me = this,
|
208
|
+
cls = me.cls;
|
209
|
+
|
210
|
+
NeoArray.remove(cls, 'neo-label-' + oldValue);
|
211
|
+
NeoArray.add( cls, 'neo-label-' + value);
|
212
|
+
me.cls = cls;
|
213
|
+
}
|
214
|
+
|
175
215
|
/**
|
176
216
|
* Triggered after the labelText config got changed
|
177
217
|
* @param {String} value
|
@@ -226,17 +266,42 @@ class CheckBox extends Base {
|
|
226
266
|
|
227
267
|
/**
|
228
268
|
* Triggered after the valueLabel config got changed
|
229
|
-
* @param {String} value
|
230
|
-
* @param {String} oldValue
|
269
|
+
* @param {String|null} value
|
270
|
+
* @param {String|null} oldValue
|
231
271
|
* @protected
|
232
272
|
*/
|
233
273
|
afterSetValueLabelText(value, oldValue) {
|
234
|
-
let me
|
274
|
+
let me = this,
|
275
|
+
valueLabel = me.vdom.cn[2],
|
276
|
+
showLabel = !!value; // hide the label, in case value === null || value === ''
|
235
277
|
|
236
|
-
if (
|
237
|
-
|
238
|
-
me.update();
|
278
|
+
if (showLabel) {
|
279
|
+
valueLabel.innerHTML = value;
|
239
280
|
}
|
281
|
+
|
282
|
+
valueLabel.removeDom = !showLabel;
|
283
|
+
me.update();
|
284
|
+
}
|
285
|
+
|
286
|
+
/**
|
287
|
+
* Triggered before the labelCls config gets changed.
|
288
|
+
* @param {String[]} value
|
289
|
+
* @param {String[]} oldValue
|
290
|
+
* @protected
|
291
|
+
*/
|
292
|
+
beforeSetLabelCls(value, oldValue) {
|
293
|
+
return NeoArray.union(value || [], this.labelBaseCls);
|
294
|
+
}
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Triggered before the labelPosition config gets changed
|
298
|
+
* @param {String} value
|
299
|
+
* @param {String} oldValue
|
300
|
+
* @protected
|
301
|
+
* @returns {String}
|
302
|
+
*/
|
303
|
+
beforeSetLabelPosition(value, oldValue) {
|
304
|
+
return this.beforeSetEnumValue(value, oldValue, 'labelPosition');
|
240
305
|
}
|
241
306
|
|
242
307
|
/**
|
package/src/form/field/Radio.mjs
CHANGED
@@ -25,12 +25,16 @@ class Radio extends CheckBox {
|
|
25
25
|
* @member {String} inputType='radio'
|
26
26
|
*/
|
27
27
|
inputType: 'radio',
|
28
|
+
/**
|
29
|
+
* @member {String[]} labelBaseCls=['neo-radio-label']
|
30
|
+
*/
|
31
|
+
labelBaseCls: ['neo-radio-label'],
|
28
32
|
/**
|
29
33
|
* @member {Object} _vdom
|
30
34
|
*/
|
31
35
|
_vdom:
|
32
36
|
{cn: [
|
33
|
-
{tag: 'label', cls: [
|
37
|
+
{tag: 'label', cls: []},
|
34
38
|
{tag: 'input', cls: ['neo-radio-input']},
|
35
39
|
{tag: 'label', cls: ['neo-radio-value-label']}
|
36
40
|
]}
|
package/src/form/field/Text.mjs
CHANGED
@@ -94,9 +94,13 @@ class Text extends Base {
|
|
94
94
|
*/
|
95
95
|
inputType_: 'text',
|
96
96
|
/**
|
97
|
-
* @member {String[]}
|
97
|
+
* @member {String[]} labelBaseCls=['neo-textfield-label']
|
98
98
|
*/
|
99
|
-
|
99
|
+
labelBaseCls: ['neo-textfield-label'],
|
100
|
+
/**
|
101
|
+
* @member {String[]} labelCls_=[]
|
102
|
+
*/
|
103
|
+
labelCls_: [],
|
100
104
|
/**
|
101
105
|
* Valid values: 'bottom', 'inline', 'left', 'right', 'top'
|
102
106
|
* @member {String} labelPosition_='left'
|
@@ -648,6 +652,16 @@ class Text extends Base {
|
|
648
652
|
return this.beforeSetEnumValue(value, oldValue, 'autoCapitalize', 'autoCapitalizeValues');
|
649
653
|
}
|
650
654
|
|
655
|
+
/**
|
656
|
+
* Triggered before the labelCls config gets changed.
|
657
|
+
* @param {String[]} value
|
658
|
+
* @param {String[]} oldValue
|
659
|
+
* @protected
|
660
|
+
*/
|
661
|
+
beforeSetLabelCls(value, oldValue) {
|
662
|
+
return NeoArray.union(value || [], this.labelBaseCls);
|
663
|
+
}
|
664
|
+
|
651
665
|
/**
|
652
666
|
* Triggered before the labelPosition config gets changed
|
653
667
|
* @param {String} value
|