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.
@@ -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,6 @@
1
+ import MainContainer from './MainContainer.mjs';
2
+
3
+ export const onStart = () => Neo.app({
4
+ mainView: MainContainer,
5
+ name : 'Neo.examples.form.field.checkbox'
6
+ });
@@ -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,6 @@
1
+ {
2
+ "appPath" : "examples/form/field/checkbox/app.mjs",
3
+ "basePath" : "../../../../",
4
+ "environment": "development",
5
+ "mainPath" : "./Main.mjs"
6
+ }
@@ -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,6 @@
1
+ import MainContainer from './MainContainer.mjs';
2
+
3
+ export const onStart = () => Neo.app({
4
+ mainView: MainContainer,
5
+ name : 'Neo.examples.form.field.radio'
6
+ });
@@ -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>
@@ -0,0 +1,6 @@
1
+ {
2
+ "appPath" : "examples/form/field/radio/app.mjs",
3
+ "basePath" : "../../../../",
4
+ "environment": "development",
5
+ "mainPath" : "./Main.mjs"
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.6.8",
3
+ "version": "4.6.9",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -35,4 +35,14 @@
35
35
  color : v(textfield-label-color);
36
36
  user-select: none;
37
37
  }
38
+
39
+ &.neo-label-top {
40
+ .neo-checkbox-input {
41
+ margin-left: 0;
42
+ }
43
+
44
+ .neo-checkbox-label {
45
+ display: block;
46
+ }
47
+ }
38
48
  }
@@ -35,4 +35,14 @@
35
35
  color : v(textfield-label-color);
36
36
  user-select: none;
37
37
  }
38
+
39
+ &.neo-label-top {
40
+ .neo-radio-input {
41
+ margin-left: 0;
42
+ }
43
+
44
+ .neo-radio-label {
45
+ display: block;
46
+ }
47
+ }
38
48
  }
@@ -1,10 +1,21 @@
1
- import Base from './Base.mjs';
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_='ValueLabel'
70
+ * @member {String|null} valueLabelText_=null
59
71
  */
60
- valueLabelText_: 'ValueLabel',
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 = this;
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 (!me.hideValueLabel) {
237
- me.vdom.cn[2].innerHTML = value;
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
  /**