neo.mjs 5.4.11 → 5.5.0
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/apps/ServiceWorker.mjs +2 -2
- package/apps/form/view/pages/Page4.mjs +9 -4
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/form/field/checkbox/MainContainer.mjs +8 -2
- package/examples/form/field/checkbox/app.mjs +0 -1
- package/package.json +2 -2
- package/resources/scss/src/form/field/CheckBox.scss +14 -0
- package/src/DefaultConfig.mjs +2 -2
- package/src/form/field/CheckBox.mjs +240 -43
- package/src/form/field/Number.mjs +41 -21
- package/src/form/field/Radio.mjs +1 -1
- package/src/form/field/Text.mjs +83 -88
- package/examples/form/field/checkbox/Overrides.mjs +0 -13
package/apps/ServiceWorker.mjs
CHANGED
@@ -16,10 +16,12 @@ class Page4 extends FormPageContainer {
|
|
16
16
|
* @member {Object} itemDefaults
|
17
17
|
*/
|
18
18
|
itemDefaults: {
|
19
|
-
module
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
module : CheckBox,
|
20
|
+
groupRequired : true,
|
21
|
+
labelText : null,
|
22
|
+
labelWidth : 70,
|
23
|
+
name : 'fruits',
|
24
|
+
showErrorTexts: false
|
23
25
|
},
|
24
26
|
/**
|
25
27
|
* @member {Object[]} items
|
@@ -40,11 +42,14 @@ class Page4 extends FormPageContainer {
|
|
40
42
|
value : 'orange',
|
41
43
|
valueLabelText: 'Orange'
|
42
44
|
}, {
|
45
|
+
showErrorTexts: true, // overwriting the itemDefaults value
|
43
46
|
value : 'strawberry',
|
44
47
|
valueLabelText: 'Strawberry'
|
45
48
|
}, {
|
46
49
|
labelText : 'Boolean',
|
50
|
+
groupRequired : false, // overwriting the itemDefaults value
|
47
51
|
name : 'boolean',
|
52
|
+
showErrorTexts: true, // overwriting the itemDefaults value
|
48
53
|
style : {marginTop: '50px'},
|
49
54
|
uncheckedValue: false,
|
50
55
|
value : true
|
@@ -23,8 +23,14 @@ class MainContainer extends ConfigurationViewport {
|
|
23
23
|
module : CheckBox,
|
24
24
|
checked : me.exampleComponent.disabled,
|
25
25
|
labelText: 'disabled',
|
26
|
-
listeners: {change: me.onConfigChange.bind(me, 'disabled')}
|
27
|
-
|
26
|
+
listeners: {change: me.onConfigChange.bind(me, 'disabled')}
|
27
|
+
}, {
|
28
|
+
module : TextField,
|
29
|
+
clearable: true,
|
30
|
+
labelText: 'error',
|
31
|
+
listeners: {change: me.onConfigChange.bind(me, 'error')},
|
32
|
+
style : {marginTop: '10px'},
|
33
|
+
value : me.exampleComponent.error
|
28
34
|
}, {
|
29
35
|
module : CheckBox,
|
30
36
|
checked : me.exampleComponent.hideLabel,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neo.mjs",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.5.0",
|
4
4
|
"description": "The webworkers driven UI framework",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -56,7 +56,7 @@
|
|
56
56
|
"neo-jsdoc": "^1.0.1",
|
57
57
|
"neo-jsdoc-x": "^1.0.5",
|
58
58
|
"postcss": "^8.4.23",
|
59
|
-
"sass": "^1.62.
|
59
|
+
"sass": "^1.62.1",
|
60
60
|
"webpack": "^5.80.0",
|
61
61
|
"webpack-cli": "^5.0.2",
|
62
62
|
"webpack-dev-server": "4.13.3",
|
@@ -33,6 +33,20 @@
|
|
33
33
|
user-select: none;
|
34
34
|
}
|
35
35
|
|
36
|
+
.neo-error {
|
37
|
+
color : v(textfield-border-color-invalid);
|
38
|
+
font-size : 11px;
|
39
|
+
margin-top : .3em;
|
40
|
+
white-space: break-spaces;
|
41
|
+
word-break : break-word;
|
42
|
+
}
|
43
|
+
|
44
|
+
&.neo-invalid {
|
45
|
+
.neo-checkbox-icon {
|
46
|
+
color: v(textfield-border-color-invalid);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
36
50
|
&.neo-label-top {
|
37
51
|
.neo-checkbox-input {
|
38
52
|
margin-left: 0;
|
package/src/DefaultConfig.mjs
CHANGED
@@ -237,12 +237,12 @@ const DefaultConfig = {
|
|
237
237
|
useVdomWorker: true,
|
238
238
|
/**
|
239
239
|
* buildScripts/injectPackageVersion.mjs will update this value
|
240
|
-
* @default '5.
|
240
|
+
* @default '5.5.0'
|
241
241
|
* @memberOf! module:Neo
|
242
242
|
* @name config.version
|
243
243
|
* @type String
|
244
244
|
*/
|
245
|
-
version: '5.
|
245
|
+
version: '5.5.0'
|
246
246
|
};
|
247
247
|
|
248
248
|
Object.assign(DefaultConfig, {
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import Base
|
2
|
-
import
|
1
|
+
import Base from './Base.mjs';
|
2
|
+
import ComponentManager from '../../manager/Component.mjs';
|
3
|
+
import NeoArray from '../../util/Array.mjs';
|
3
4
|
|
4
5
|
/**
|
5
6
|
* @class Neo.form.field.CheckBox
|
@@ -33,6 +34,22 @@ class CheckBox extends Base {
|
|
33
34
|
* @member {Boolean} checked_=false
|
34
35
|
*/
|
35
36
|
checked_: false,
|
37
|
+
/**
|
38
|
+
* @member {String|null} error_=null
|
39
|
+
*/
|
40
|
+
error_: null,
|
41
|
+
/**
|
42
|
+
* @member {Function} errorTextGroupRequired='Required'
|
43
|
+
*/
|
44
|
+
errorTextGroupRequired: data => `Please check at least one item of the group: ${data.name}`,
|
45
|
+
/**
|
46
|
+
* @member {String} errorTextRequired='Required'
|
47
|
+
*/
|
48
|
+
errorTextRequired: 'Required',
|
49
|
+
/**
|
50
|
+
* @member {Boolean} groupRequired_=false
|
51
|
+
*/
|
52
|
+
groupRequired_: false,
|
36
53
|
/**
|
37
54
|
* @member {Boolean} hideLabel_=false
|
38
55
|
*/
|
@@ -75,6 +92,15 @@ class CheckBox extends Base {
|
|
75
92
|
* @member {String} The name (group) of the input dom node
|
76
93
|
*/
|
77
94
|
name_: '',
|
95
|
+
/**
|
96
|
+
* @member {Boolean} required_=false
|
97
|
+
*/
|
98
|
+
required_: false,
|
99
|
+
/**
|
100
|
+
* Use case: Set this config to false for all but one items with the same name.
|
101
|
+
* @member {Boolean} showErrorTexts_=true
|
102
|
+
*/
|
103
|
+
showErrorTexts_: true,
|
78
104
|
/**
|
79
105
|
* In case the CheckBox does not belong to a group (multiple fields with the same name),
|
80
106
|
* you can pass a custom value for the unchecked state.
|
@@ -93,14 +119,24 @@ class CheckBox extends Base {
|
|
93
119
|
* @member {Object} _vdom
|
94
120
|
*/
|
95
121
|
_vdom:
|
96
|
-
{
|
97
|
-
{tag: '
|
98
|
-
|
99
|
-
|
100
|
-
|
122
|
+
{cn: [
|
123
|
+
{tag: 'label', cls: ['neo-checkbox-label'], cn: [
|
124
|
+
{tag: 'span', cls: []},
|
125
|
+
{tag: 'input', cls: ['neo-checkbox-input']},
|
126
|
+
{tag: 'i', cls: ['neo-checkbox-icon']},
|
127
|
+
{tag: 'span', cls: ['neo-checkbox-value-label']}
|
128
|
+
]},
|
129
|
+
{cls: ['neo-error'], removeDom: true}
|
101
130
|
]}
|
102
131
|
}
|
103
132
|
|
133
|
+
/**
|
134
|
+
* Set this value to false, in case a field should display errors up front.
|
135
|
+
* Otherwise, errors will stay hidden on mounting, unless you trigger validate(false).
|
136
|
+
* @member {Boolean} clean=true
|
137
|
+
*/
|
138
|
+
clean = true
|
139
|
+
|
104
140
|
/**
|
105
141
|
* @param {Object} config
|
106
142
|
*/
|
@@ -111,7 +147,7 @@ class CheckBox extends Base {
|
|
111
147
|
|
112
148
|
me.addDomListeners(
|
113
149
|
{change: me.onInputValueChange, scope: me}
|
114
|
-
)
|
150
|
+
)
|
115
151
|
}
|
116
152
|
|
117
153
|
/**
|
@@ -121,21 +157,48 @@ class CheckBox extends Base {
|
|
121
157
|
*/
|
122
158
|
afterSetChecked(value, oldValue) {
|
123
159
|
let me = this,
|
124
|
-
|
160
|
+
labelEl = me.vdom.cn[0],
|
161
|
+
iconCls = labelEl.cn[2].cls,
|
125
162
|
newCls = value ? me.iconClsChecked : me.iconCls,
|
126
163
|
oldCls = value ? me.iconCls : me.iconClsChecked;
|
127
164
|
|
128
|
-
|
165
|
+
if (oldValue) {
|
166
|
+
me.clean = false;
|
167
|
+
}
|
168
|
+
|
169
|
+
me.validate(); // silent
|
170
|
+
|
171
|
+
labelEl.cn[1].checked = value;
|
129
172
|
|
130
173
|
NeoArray.removeAdd(iconCls, oldCls, newCls);
|
131
174
|
|
132
175
|
me.update();
|
133
176
|
|
134
177
|
if (oldValue !== undefined) {
|
135
|
-
me.fireChangeEvent(me.getValue(), null)
|
178
|
+
me.fireChangeEvent(me.getValue(), null)
|
136
179
|
}
|
137
180
|
}
|
138
181
|
|
182
|
+
/**
|
183
|
+
* Triggered after the error config got changed
|
184
|
+
* @param {String|null} value
|
185
|
+
* @param {String|null} oldValue
|
186
|
+
* @protected
|
187
|
+
*/
|
188
|
+
afterSetError(value, oldValue) {
|
189
|
+
this.updateError(value)
|
190
|
+
}
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Triggered after the required groupRequired got changed
|
194
|
+
* @param {Boolean} value
|
195
|
+
* @param {Boolean} oldValue
|
196
|
+
* @protected
|
197
|
+
*/
|
198
|
+
afterSetGroupRequired(value, oldValue) {
|
199
|
+
oldValue !== undefined && this.validate(false)
|
200
|
+
}
|
201
|
+
|
139
202
|
/**
|
140
203
|
* Triggered after the hideLabel config got changed
|
141
204
|
* @param {String} value
|
@@ -143,8 +206,8 @@ class CheckBox extends Base {
|
|
143
206
|
* @protected
|
144
207
|
*/
|
145
208
|
afterSetHideLabel(value, oldValue) {
|
146
|
-
this.vdom.cn[0].removeDom = value;
|
147
|
-
this.update()
|
209
|
+
this.vdom.cn[0].cn[0].removeDom = value;
|
210
|
+
this.update()
|
148
211
|
}
|
149
212
|
|
150
213
|
/**
|
@@ -154,16 +217,17 @@ class CheckBox extends Base {
|
|
154
217
|
* @protected
|
155
218
|
*/
|
156
219
|
afterSetId(value, oldValue) {
|
157
|
-
let me
|
158
|
-
vdom
|
220
|
+
let me = this,
|
221
|
+
vdom = me.vdom,
|
222
|
+
labelEl = vdom.cn[0];
|
159
223
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
224
|
+
labelEl.cn[0].id = me.getLabelId();
|
225
|
+
labelEl.cn[1].id = me.getInputElId();
|
226
|
+
labelEl.cn[2].id = me.getIconElId();
|
227
|
+
labelEl.cn[3].id = me.getValueLabelId();
|
164
228
|
|
165
229
|
// silent vdom update, the super call will trigger the engine
|
166
|
-
super.afterSetId(value, oldValue)
|
230
|
+
super.afterSetId(value, oldValue)
|
167
231
|
}
|
168
232
|
|
169
233
|
/**
|
@@ -173,8 +237,8 @@ class CheckBox extends Base {
|
|
173
237
|
* @protected
|
174
238
|
*/
|
175
239
|
afterSetInputType(value, oldValue) {
|
176
|
-
this.vdom.cn[1].type = value;
|
177
|
-
this.update()
|
240
|
+
this.vdom.cn[0].cn[1].type = value;
|
241
|
+
this.update()
|
178
242
|
}
|
179
243
|
|
180
244
|
/**
|
@@ -185,12 +249,12 @@ class CheckBox extends Base {
|
|
185
249
|
*/
|
186
250
|
afterSetLabelCls(value, oldValue) {
|
187
251
|
let me = this,
|
188
|
-
cls = me.vdom.cn[0].cls;
|
252
|
+
cls = me.vdom.cn[0].cn[0].cls;
|
189
253
|
|
190
254
|
NeoArray.remove(cls, oldValue);
|
191
255
|
NeoArray.add(cls, value);
|
192
256
|
|
193
|
-
me.update()
|
257
|
+
me.update()
|
194
258
|
}
|
195
259
|
|
196
260
|
/**
|
@@ -205,7 +269,7 @@ class CheckBox extends Base {
|
|
205
269
|
|
206
270
|
NeoArray.remove(cls, 'neo-label-' + oldValue);
|
207
271
|
NeoArray.add( cls, 'neo-label-' + value);
|
208
|
-
me.cls = cls
|
272
|
+
me.cls = cls
|
209
273
|
}
|
210
274
|
|
211
275
|
/**
|
@@ -215,8 +279,8 @@ class CheckBox extends Base {
|
|
215
279
|
* @protected
|
216
280
|
*/
|
217
281
|
afterSetLabelText(value, oldValue) {
|
218
|
-
this.vdom.cn[0].innerHTML = value;
|
219
|
-
this.update()
|
282
|
+
this.vdom.cn[0].cn[0].innerHTML = value;
|
283
|
+
this.update()
|
220
284
|
}
|
221
285
|
|
222
286
|
/**
|
@@ -229,8 +293,8 @@ class CheckBox extends Base {
|
|
229
293
|
let me = this;
|
230
294
|
|
231
295
|
if (!me.hideLabel) {
|
232
|
-
me.vdom.cn[0].width = value;
|
233
|
-
me.update()
|
296
|
+
me.vdom.cn[0].cn[0].width = value;
|
297
|
+
me.update()
|
234
298
|
}
|
235
299
|
}
|
236
300
|
|
@@ -241,8 +305,28 @@ class CheckBox extends Base {
|
|
241
305
|
* @protected
|
242
306
|
*/
|
243
307
|
afterSetName(value, oldValue) {
|
244
|
-
this.vdom.cn[1].name = value;
|
245
|
-
this.update()
|
308
|
+
this.vdom.cn[0].cn[1].name = value;
|
309
|
+
this.update()
|
310
|
+
}
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Triggered after the required config got changed
|
314
|
+
* @param {Boolean} value
|
315
|
+
* @param {Boolean} oldValue
|
316
|
+
* @protected
|
317
|
+
*/
|
318
|
+
afterSetRequired(value, oldValue) {
|
319
|
+
oldValue !== undefined && this.validate(false)
|
320
|
+
}
|
321
|
+
|
322
|
+
/**
|
323
|
+
* Triggered after the showErrorTexts config got changed
|
324
|
+
* @param {Boolean} value
|
325
|
+
* @param {Boolean} oldValue
|
326
|
+
* @protected
|
327
|
+
*/
|
328
|
+
afterSetShowErrorTexts(value, oldValue) {
|
329
|
+
oldValue !== undefined && this.validate(false)
|
246
330
|
}
|
247
331
|
|
248
332
|
/**
|
@@ -253,8 +337,8 @@ class CheckBox extends Base {
|
|
253
337
|
*/
|
254
338
|
afterSetValue(value, oldValue) {
|
255
339
|
if (value) {
|
256
|
-
this.vdom.cn[1].value = value;
|
257
|
-
this.update()
|
340
|
+
this.vdom.cn[0].cn[1].value = value;
|
341
|
+
this.update()
|
258
342
|
}
|
259
343
|
}
|
260
344
|
|
@@ -266,7 +350,7 @@ class CheckBox extends Base {
|
|
266
350
|
*/
|
267
351
|
afterSetValueLabelText(value, oldValue) {
|
268
352
|
let me = this,
|
269
|
-
valueLabel = me.vdom.cn[3],
|
353
|
+
valueLabel = me.vdom.cn[0].cn[3],
|
270
354
|
showLabel = !!value; // hide the label, in case value === null || value === ''
|
271
355
|
|
272
356
|
if (showLabel) {
|
@@ -274,7 +358,22 @@ class CheckBox extends Base {
|
|
274
358
|
}
|
275
359
|
|
276
360
|
valueLabel.removeDom = !showLabel;
|
277
|
-
me.update()
|
361
|
+
me.update()
|
362
|
+
}
|
363
|
+
|
364
|
+
/**
|
365
|
+
* Triggered before the groupRequired config gets changed.
|
366
|
+
* @param {Boolean} value
|
367
|
+
* @param {Boolean} oldValue
|
368
|
+
* @protected
|
369
|
+
*/
|
370
|
+
beforeSetGroupRequired(value, oldValue) {
|
371
|
+
if (value && this.required) {
|
372
|
+
console.warn('Do not use groupRequired & required at the same time. Switching to required.', this);
|
373
|
+
return false
|
374
|
+
}
|
375
|
+
|
376
|
+
return value
|
278
377
|
}
|
279
378
|
|
280
379
|
/**
|
@@ -284,7 +383,7 @@ class CheckBox extends Base {
|
|
284
383
|
* @protected
|
285
384
|
*/
|
286
385
|
beforeSetLabelCls(value, oldValue) {
|
287
|
-
return NeoArray.union(value || [], this.labelBaseCls)
|
386
|
+
return NeoArray.union(value || [], this.labelBaseCls)
|
288
387
|
}
|
289
388
|
|
290
389
|
/**
|
@@ -295,28 +394,28 @@ class CheckBox extends Base {
|
|
295
394
|
* @returns {String}
|
296
395
|
*/
|
297
396
|
beforeSetLabelPosition(value, oldValue) {
|
298
|
-
return this.beforeSetEnumValue(value, oldValue, 'labelPosition')
|
397
|
+
return this.beforeSetEnumValue(value, oldValue, 'labelPosition')
|
299
398
|
}
|
300
399
|
|
301
400
|
/**
|
302
401
|
* @returns {String}
|
303
402
|
*/
|
304
403
|
getIconElId() {
|
305
|
-
return `${this.id}__icon
|
404
|
+
return `${this.id}__icon`
|
306
405
|
}
|
307
406
|
|
308
407
|
/**
|
309
408
|
* @returns {String}
|
310
409
|
*/
|
311
410
|
getInputElId() {
|
312
|
-
return `${this.id}__input
|
411
|
+
return `${this.id}__input`
|
313
412
|
}
|
314
413
|
|
315
414
|
/**
|
316
415
|
* @returns {String}
|
317
416
|
*/
|
318
417
|
getLabelId() {
|
319
|
-
return `${this.id}__label
|
418
|
+
return `${this.id}__label`
|
320
419
|
}
|
321
420
|
|
322
421
|
/**
|
@@ -332,7 +431,14 @@ class CheckBox extends Base {
|
|
332
431
|
* @returns {String}
|
333
432
|
*/
|
334
433
|
getValueLabelId() {
|
335
|
-
return `${this.id}__value-label
|
434
|
+
return `${this.id}__value-label`
|
435
|
+
}
|
436
|
+
|
437
|
+
/**
|
438
|
+
* @returns {Boolean}
|
439
|
+
*/
|
440
|
+
isValid() {
|
441
|
+
return this.error ? false : super.isValid()
|
336
442
|
}
|
337
443
|
|
338
444
|
/**
|
@@ -344,9 +450,100 @@ class CheckBox extends Base {
|
|
344
450
|
checked = data.target.checked;
|
345
451
|
|
346
452
|
// keep the vdom & vnode in sync for future updates
|
347
|
-
me.vnode.childNodes[me.hideLabel ? 0 : 1].attributes.checked = `${checked}`;
|
453
|
+
me.vnode.childNodes[0].childNodes[me.hideLabel ? 0 : 1].attributes.checked = `${checked}`;
|
454
|
+
|
455
|
+
me.checked = checked
|
456
|
+
}
|
457
|
+
|
458
|
+
/**
|
459
|
+
@param {String|null} value
|
460
|
+
@param {Boolean} silent=false
|
461
|
+
*/
|
462
|
+
updateError(value, silent=false) {
|
463
|
+
let me = this,
|
464
|
+
cls = me.cls,
|
465
|
+
showError = value && me.showErrorTexts,
|
466
|
+
errorNode;
|
467
|
+
|
468
|
+
if (!(me.clean && !me.mounted)) {
|
469
|
+
me._error = value; // silent update
|
470
|
+
|
471
|
+
NeoArray[value ? 'add' : 'remove'](cls, 'neo-invalid');
|
472
|
+
me.cls = cls;
|
473
|
+
|
474
|
+
errorNode = me.vdom.cn[1];
|
475
|
+
|
476
|
+
if (showError) {
|
477
|
+
errorNode.html = value;
|
478
|
+
} else {
|
479
|
+
delete errorNode.html;
|
480
|
+
}
|
481
|
+
|
482
|
+
errorNode.removeDom = !showError;
|
483
|
+
|
484
|
+
!silent && me.update()
|
485
|
+
}
|
486
|
+
}
|
487
|
+
|
488
|
+
/**
|
489
|
+
* Checks for client-side field errors
|
490
|
+
* @param {Boolean} silent=true
|
491
|
+
* @returns {Boolean} Returns true in case there are no client-side errors
|
492
|
+
*/
|
493
|
+
validate(silent=true) {
|
494
|
+
let me = this,
|
495
|
+
name = me.name,
|
496
|
+
returnValue = true,
|
497
|
+
checkBox, checkBoxes;
|
498
|
+
|
499
|
+
if (!silent) {
|
500
|
+
// in case we manually call validate(false) on a form or field before it is mounted, we do want to see errors.
|
501
|
+
me.clean = false;
|
502
|
+
}
|
503
|
+
|
504
|
+
if (me.groupRequired) {
|
505
|
+
returnValue = false;
|
506
|
+
|
507
|
+
// discuss: we could limit this to checkBoxes / radios inside the same form, IF a top level form is used
|
508
|
+
checkBoxes = ComponentManager.find({
|
509
|
+
ntype: me.ntype,
|
510
|
+
name : me.name
|
511
|
+
});
|
512
|
+
|
513
|
+
// get the group validity state first
|
514
|
+
for (checkBox of checkBoxes) {
|
515
|
+
if (checkBox.checked) {
|
516
|
+
returnValue = true;
|
517
|
+
break;
|
518
|
+
}
|
519
|
+
}
|
520
|
+
|
521
|
+
// update all group items
|
522
|
+
for (checkBox of checkBoxes) {
|
523
|
+
if (checkBox.id !== me.id) {
|
524
|
+
if (!me.clean) {
|
525
|
+
checkBox.clean = false;
|
526
|
+
}
|
527
|
+
|
528
|
+
checkBox[me.clean ? '_error' : 'error'] = returnValue ? null : checkBox.errorTextGroupRequired({name})
|
529
|
+
}
|
530
|
+
}
|
531
|
+
|
532
|
+
if (!returnValue) {
|
533
|
+
me._error = me.errorTextGroupRequired({name});
|
534
|
+
}
|
535
|
+
} else if (me.required && !me.checked) {
|
536
|
+
me._error = me.errorTextRequired;
|
537
|
+
returnValue = false;
|
538
|
+
}
|
539
|
+
|
540
|
+
if (returnValue) {
|
541
|
+
me._error = null;
|
542
|
+
}
|
543
|
+
|
544
|
+
!me.clean && me.updateError(me._error, silent);
|
348
545
|
|
349
|
-
|
546
|
+
return !returnValue ? false : super.validate(silent)
|
350
547
|
}
|
351
548
|
}
|
352
549
|
|
@@ -162,6 +162,34 @@ class Number extends Text {
|
|
162
162
|
}
|
163
163
|
}
|
164
164
|
|
165
|
+
/**
|
166
|
+
* Triggered before the maxLength config gets changed
|
167
|
+
* @param {Number|null} value
|
168
|
+
* @param {Number|null} oldValue
|
169
|
+
* @protected
|
170
|
+
*/
|
171
|
+
beforeSetMaxLength(value, oldValue) {
|
172
|
+
if (value !== null) {
|
173
|
+
console.warn('input type number does not support maxLength. use maxValue instead.', this)
|
174
|
+
}
|
175
|
+
|
176
|
+
return null;
|
177
|
+
}
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Triggered before the minLength config gets changed
|
181
|
+
* @param {Number|null} value
|
182
|
+
* @param {Number|null} oldValue
|
183
|
+
* @protected
|
184
|
+
*/
|
185
|
+
beforeSetMinLength(value, oldValue) {
|
186
|
+
if (value !== null) {
|
187
|
+
console.warn('input type number does not support minLength. use minValue instead.', this)
|
188
|
+
}
|
189
|
+
|
190
|
+
return null;
|
191
|
+
}
|
192
|
+
|
165
193
|
/**
|
166
194
|
* Triggered after the triggerPosition config got changed
|
167
195
|
* @param {String} value
|
@@ -345,39 +373,31 @@ class Number extends Text {
|
|
345
373
|
*/
|
346
374
|
validate(silent=true) {
|
347
375
|
let me = this,
|
348
|
-
errorField = silent ? '_error' : 'error',
|
349
376
|
value = me.value,
|
350
377
|
isNumber = Neo.isNumber(value),
|
351
378
|
maxValue = me.maxValue,
|
352
379
|
minValue = me.minValue,
|
353
380
|
stepSize = me.stepSize,
|
354
381
|
stepSizePow = Math.pow(10, me.stepSizeDigits),
|
355
|
-
returnValue =
|
382
|
+
returnValue = super.validate(silent),
|
356
383
|
errorParam = {maxValue, minValue, stepSize, value};
|
357
384
|
|
358
|
-
if (!silent) {
|
359
|
-
// in case we manually call validate(false) on a form or field before it is mounted, we do want to see errors.
|
360
|
-
me.clean = false;
|
361
|
-
}
|
362
|
-
|
363
|
-
if (Neo.isNumber(maxValue) && isNumber && value > maxValue) {
|
364
|
-
me[errorField] = me.errorTextMaxValue(errorParam);
|
365
|
-
returnValue = false;
|
366
|
-
} else if (Neo.isNumber(minValue) && isNumber && value < minValue) {
|
367
|
-
me[errorField] = me.errorTextMinValue(errorParam);
|
368
|
-
returnValue = false;
|
369
|
-
} else if ((Math.round((value % me.stepSize) * stepSizePow) / stepSizePow) !== 0) {
|
370
|
-
me[errorField] = me.errorTextStepSize(errorParam);
|
371
|
-
returnValue = false;
|
372
|
-
}
|
373
|
-
|
374
385
|
if (returnValue) {
|
375
|
-
|
386
|
+
if (Neo.isNumber(maxValue) && isNumber && value > maxValue) {
|
387
|
+
me._error = me.errorTextMaxValue(errorParam);
|
388
|
+
returnValue = false;
|
389
|
+
} else if (Neo.isNumber(minValue) && isNumber && value < minValue) {
|
390
|
+
me._error = me.errorTextMinValue(errorParam);
|
391
|
+
returnValue = false;
|
392
|
+
} else if ((Math.round((value % me.stepSize) * stepSizePow) / stepSizePow) !== 0) {
|
393
|
+
me._error = me.errorTextStepSize(errorParam);
|
394
|
+
returnValue = false;
|
395
|
+
}
|
376
396
|
}
|
377
397
|
|
378
|
-
!me.clean && me.updateError(me
|
398
|
+
!returnValue && !me.clean && me.updateError(me._error, silent);
|
379
399
|
|
380
|
-
return
|
400
|
+
return returnValue
|
381
401
|
}
|
382
402
|
}
|
383
403
|
|
package/src/form/field/Radio.mjs
CHANGED
package/src/form/field/Text.mjs
CHANGED
@@ -281,7 +281,7 @@ class Text extends Base {
|
|
281
281
|
this.fire('changeClearToOriginalValue', {
|
282
282
|
oldValue,
|
283
283
|
value
|
284
|
-
})
|
284
|
+
})
|
285
285
|
}
|
286
286
|
|
287
287
|
/**
|
@@ -291,7 +291,7 @@ class Text extends Base {
|
|
291
291
|
* @protected
|
292
292
|
*/
|
293
293
|
afterSetError(value, oldValue) {
|
294
|
-
this.updateError(value)
|
294
|
+
this.updateError(value)
|
295
295
|
}
|
296
296
|
|
297
297
|
/**
|
@@ -305,7 +305,7 @@ class Text extends Base {
|
|
305
305
|
node = me.labelPosition === 'inline' ? me.getCenterBorderEl() : me.vdom.cn[0];
|
306
306
|
|
307
307
|
node.removeDom = value;
|
308
|
-
me.updateInputWidth()
|
308
|
+
me.updateInputWidth()
|
309
309
|
}
|
310
310
|
|
311
311
|
/**
|
@@ -325,7 +325,7 @@ class Text extends Base {
|
|
325
325
|
labelEl.for = inputElId;
|
326
326
|
|
327
327
|
// silent vdom update, the super call will trigger the engine
|
328
|
-
super.afterSetId(value, oldValue)
|
328
|
+
super.afterSetId(value, oldValue)
|
329
329
|
}
|
330
330
|
|
331
331
|
/**
|
@@ -340,7 +340,7 @@ class Text extends Base {
|
|
340
340
|
value = value.substring(1, value.length - 1);
|
341
341
|
}
|
342
342
|
|
343
|
-
this.changeInputElKey('pattern', value)
|
343
|
+
this.changeInputElKey('pattern', value)
|
344
344
|
}
|
345
345
|
|
346
346
|
/**
|
@@ -350,7 +350,7 @@ class Text extends Base {
|
|
350
350
|
* @protected
|
351
351
|
*/
|
352
352
|
afterSetInputType(value, oldValue) {
|
353
|
-
this.changeInputElKey('type', value)
|
353
|
+
this.changeInputElKey('type', value)
|
354
354
|
}
|
355
355
|
|
356
356
|
/**
|
@@ -366,7 +366,7 @@ class Text extends Base {
|
|
366
366
|
NeoArray.remove(cls, oldValue);
|
367
367
|
NeoArray.add(cls, value);
|
368
368
|
|
369
|
-
me.update()
|
369
|
+
me.update()
|
370
370
|
}
|
371
371
|
|
372
372
|
/**
|
@@ -376,7 +376,7 @@ class Text extends Base {
|
|
376
376
|
* @protected
|
377
377
|
*/
|
378
378
|
afterSetLabelOptionalText(value, oldValue) {
|
379
|
-
this.labelText = this.labelText
|
379
|
+
this.labelText = this.labelText // triggers a vdom update
|
380
380
|
}
|
381
381
|
|
382
382
|
/**
|
@@ -428,11 +428,11 @@ class Text extends Base {
|
|
428
428
|
me.updateInputWidth();
|
429
429
|
|
430
430
|
!isEmpty && setTimeout(() => {
|
431
|
-
me.updateCenterBorderElWidth(false)
|
431
|
+
me.updateCenterBorderElWidth(false)
|
432
432
|
}, 20);
|
433
433
|
} else {
|
434
434
|
// changes from e.g. left to top
|
435
|
-
me.updateInputWidth()
|
435
|
+
me.updateInputWidth()
|
436
436
|
}
|
437
437
|
}
|
438
438
|
|
@@ -455,7 +455,7 @@ class Text extends Base {
|
|
455
455
|
}
|
456
456
|
|
457
457
|
me.promiseVdomUpdate().then(() => {
|
458
|
-
me.updateCenterBorderElWidth(isEmpty)
|
458
|
+
me.updateCenterBorderElWidth(isEmpty)
|
459
459
|
});
|
460
460
|
} else {
|
461
461
|
me.update();
|
@@ -499,7 +499,7 @@ class Text extends Base {
|
|
499
499
|
*/
|
500
500
|
afterSetMinLength(value, oldValue) {
|
501
501
|
this.validate(); // silent
|
502
|
-
this.changeInputElKey('minlength', value)
|
502
|
+
this.changeInputElKey('minlength', value)
|
503
503
|
}
|
504
504
|
|
505
505
|
/**
|
@@ -526,9 +526,9 @@ class Text extends Base {
|
|
526
526
|
|
527
527
|
if (me.labelPosition === 'inline') {
|
528
528
|
if (value) {
|
529
|
-
me.updateCenterBorderElWidth()
|
529
|
+
me.updateCenterBorderElWidth()
|
530
530
|
} else {
|
531
|
-
delete me.getCenterBorderEl().width
|
531
|
+
delete me.getCenterBorderEl().width
|
532
532
|
}
|
533
533
|
}
|
534
534
|
}
|
@@ -550,7 +550,7 @@ class Text extends Base {
|
|
550
550
|
// => labelPosition: 'inline' should keep the label at the top
|
551
551
|
if (Neo.isEmpty(value) !== Neo.isEmpty(oldValue)) {
|
552
552
|
NeoArray[value !== null && value.toString().length > 0 ? 'add' : 'remove'](cls, 'neo-has-content');
|
553
|
-
me.cls = cls
|
553
|
+
me.cls = cls
|
554
554
|
}
|
555
555
|
}
|
556
556
|
|
@@ -601,7 +601,7 @@ class Text extends Base {
|
|
601
601
|
* @protected
|
602
602
|
*/
|
603
603
|
afterSetShowOptionalText(value, oldValue) {
|
604
|
-
this.labelText = this.labelText
|
604
|
+
this.labelText = this.labelText // triggers a vdom update
|
605
605
|
}
|
606
606
|
|
607
607
|
/**
|
@@ -627,7 +627,7 @@ class Text extends Base {
|
|
627
627
|
NeoArray.remove(cls, oldValue);
|
628
628
|
NeoArray.add(cls, value);
|
629
629
|
|
630
|
-
me.update()
|
630
|
+
me.update()
|
631
631
|
}
|
632
632
|
|
633
633
|
/**
|
@@ -644,7 +644,7 @@ class Text extends Base {
|
|
644
644
|
subLabel.html = value;
|
645
645
|
subLabel.removeDom = !showLabel;
|
646
646
|
|
647
|
-
me.update()
|
647
|
+
me.update()
|
648
648
|
}
|
649
649
|
|
650
650
|
/**
|
@@ -663,7 +663,7 @@ class Text extends Base {
|
|
663
663
|
|
664
664
|
oldValue?.forEach(item => {
|
665
665
|
if (!me.getTrigger(item.type)) {
|
666
|
-
item.destroy()
|
666
|
+
item.destroy()
|
667
667
|
}
|
668
668
|
});
|
669
669
|
|
@@ -705,8 +705,8 @@ class Text extends Base {
|
|
705
705
|
}
|
706
706
|
|
707
707
|
me.promiseVdomUpdate().then(() => {
|
708
|
-
me.updateTriggerVnodes()
|
709
|
-
})
|
708
|
+
me.updateTriggerVnodes()
|
709
|
+
})
|
710
710
|
}
|
711
711
|
|
712
712
|
/**
|
@@ -738,7 +738,7 @@ class Text extends Base {
|
|
738
738
|
|
739
739
|
me.update();
|
740
740
|
|
741
|
-
super.afterSetValue(value, oldValue)
|
741
|
+
super.afterSetValue(value, oldValue) // fires the change event
|
742
742
|
}
|
743
743
|
|
744
744
|
/**
|
@@ -749,7 +749,7 @@ class Text extends Base {
|
|
749
749
|
*/
|
750
750
|
afterSetWidth(value, oldValue) {
|
751
751
|
super.afterSetWidth(value, oldValue);
|
752
|
-
this.updateInputWidth()
|
752
|
+
this.updateInputWidth()
|
753
753
|
}
|
754
754
|
|
755
755
|
/**
|
@@ -762,7 +762,7 @@ class Text extends Base {
|
|
762
762
|
return [...value];
|
763
763
|
}
|
764
764
|
|
765
|
-
return value
|
765
|
+
return value
|
766
766
|
}
|
767
767
|
|
768
768
|
/**
|
@@ -773,7 +773,7 @@ class Text extends Base {
|
|
773
773
|
* @returns {String}
|
774
774
|
*/
|
775
775
|
beforeSetAutoCapitalize(value, oldValue) {
|
776
|
-
return this.beforeSetEnumValue(value, oldValue, 'autoCapitalize', 'autoCapitalizeValues')
|
776
|
+
return this.beforeSetEnumValue(value, oldValue, 'autoCapitalize', 'autoCapitalizeValues')
|
777
777
|
}
|
778
778
|
|
779
779
|
/**
|
@@ -783,7 +783,7 @@ class Text extends Base {
|
|
783
783
|
* @protected
|
784
784
|
*/
|
785
785
|
beforeSetLabelCls(value, oldValue) {
|
786
|
-
return NeoArray.union(value || [], this.labelBaseCls)
|
786
|
+
return NeoArray.union(value || [], this.labelBaseCls)
|
787
787
|
}
|
788
788
|
|
789
789
|
/**
|
@@ -794,7 +794,7 @@ class Text extends Base {
|
|
794
794
|
* @returns {String}
|
795
795
|
*/
|
796
796
|
beforeSetLabelPosition(value, oldValue) {
|
797
|
-
return this.beforeSetEnumValue(value, oldValue, 'labelPosition')
|
797
|
+
return this.beforeSetEnumValue(value, oldValue, 'labelPosition')
|
798
798
|
}
|
799
799
|
|
800
800
|
/**
|
@@ -817,7 +817,7 @@ class Text extends Base {
|
|
817
817
|
value = value.replace(labelOptionalText, '');
|
818
818
|
}
|
819
819
|
|
820
|
-
return value
|
820
|
+
return value
|
821
821
|
}
|
822
822
|
|
823
823
|
/**
|
@@ -828,7 +828,7 @@ class Text extends Base {
|
|
828
828
|
* @protected
|
829
829
|
*/
|
830
830
|
beforeSetSubLabelCls(value, oldValue) {
|
831
|
-
return NeoArray.union(value || [], this.subLabelBaseCls)
|
831
|
+
return NeoArray.union(value || [], this.subLabelBaseCls)
|
832
832
|
}
|
833
833
|
|
834
834
|
/**
|
@@ -869,11 +869,11 @@ class Text extends Base {
|
|
869
869
|
...item,
|
870
870
|
appName: me.appName,
|
871
871
|
field : me
|
872
|
-
})
|
872
|
+
})
|
873
873
|
}
|
874
874
|
});
|
875
875
|
|
876
|
-
return value
|
876
|
+
return value
|
877
877
|
}
|
878
878
|
|
879
879
|
/**
|
@@ -891,7 +891,7 @@ class Text extends Base {
|
|
891
891
|
delete me.getInputEl()[key];
|
892
892
|
}
|
893
893
|
|
894
|
-
!silent && me.update()
|
894
|
+
!silent && me.update()
|
895
895
|
}
|
896
896
|
|
897
897
|
/**
|
@@ -901,7 +901,7 @@ class Text extends Base {
|
|
901
901
|
let me = this;
|
902
902
|
|
903
903
|
me.value = me.clearToOriginalValue ? me.originalConfig.value : null;
|
904
|
-
me.fire('clear')
|
904
|
+
me.fire('clear')
|
905
905
|
}
|
906
906
|
|
907
907
|
/**
|
@@ -910,28 +910,28 @@ class Text extends Base {
|
|
910
910
|
* @override
|
911
911
|
*/
|
912
912
|
focus(id=this.id) {
|
913
|
-
super.focus(this.getInputElId())
|
913
|
+
super.focus(this.getInputElId())
|
914
914
|
}
|
915
915
|
|
916
916
|
/**
|
917
917
|
* @returns {Object|null}
|
918
918
|
*/
|
919
919
|
getCenterBorderEl() {
|
920
|
-
return VDomUtil.findVdomChild(this.vdom, {cls: 'neo-center-border'})?.vdom || null
|
920
|
+
return VDomUtil.findVdomChild(this.vdom, {cls: 'neo-center-border'})?.vdom || null
|
921
921
|
}
|
922
922
|
|
923
923
|
/**
|
924
924
|
* @returns {Object|null}
|
925
925
|
*/
|
926
926
|
getInputEl() {
|
927
|
-
return VDomUtil.findVdomChild(this.vdom, {flag: 'neo-real-input'})?.vdom || null
|
927
|
+
return VDomUtil.findVdomChild(this.vdom, {flag: 'neo-real-input'})?.vdom || null
|
928
928
|
}
|
929
929
|
|
930
930
|
/**
|
931
931
|
* @returns {String}
|
932
932
|
*/
|
933
933
|
getInputElId() {
|
934
|
-
return `${this.id}__input
|
934
|
+
return `${this.id}__input`
|
935
935
|
}
|
936
936
|
|
937
937
|
/**
|
@@ -945,33 +945,33 @@ class Text extends Base {
|
|
945
945
|
width = me.width;
|
946
946
|
|
947
947
|
if (labelWidth && width) {
|
948
|
-
return parseInt(width) - parseInt(labelWidth)
|
948
|
+
return parseInt(width) - parseInt(labelWidth)
|
949
949
|
} else if (width) {
|
950
|
-
return width
|
950
|
+
return width
|
951
951
|
}
|
952
952
|
|
953
|
-
return null
|
953
|
+
return null
|
954
954
|
}
|
955
955
|
|
956
956
|
/**
|
957
957
|
* @returns {String}
|
958
958
|
*/
|
959
959
|
getInputWrapperId() {
|
960
|
-
return `${this.id}__input-wrapper
|
960
|
+
return `${this.id}__input-wrapper`
|
961
961
|
}
|
962
962
|
|
963
963
|
/**
|
964
964
|
* @returns {Object|null}
|
965
965
|
*/
|
966
966
|
getLabelEl() {
|
967
|
-
return VDomUtil.findVdomChild(this.vdom, {tag: 'label'})?.vdom || null
|
967
|
+
return VDomUtil.findVdomChild(this.vdom, {tag: 'label'})?.vdom || null
|
968
968
|
}
|
969
969
|
|
970
970
|
/**
|
971
971
|
* @returns {String}
|
972
972
|
*/
|
973
973
|
getLabelId() {
|
974
|
-
return `${this.id}__label
|
974
|
+
return `${this.id}__label`
|
975
975
|
}
|
976
976
|
|
977
977
|
/**
|
@@ -986,11 +986,11 @@ class Text extends Base {
|
|
986
986
|
|
987
987
|
for (; i < len; i++) {
|
988
988
|
if (triggers[i].type === type) {
|
989
|
-
return triggers[i]
|
989
|
+
return triggers[i]
|
990
990
|
}
|
991
991
|
}
|
992
992
|
|
993
|
-
return null
|
993
|
+
return null
|
994
994
|
}
|
995
995
|
|
996
996
|
/**
|
@@ -1005,11 +1005,11 @@ class Text extends Base {
|
|
1005
1005
|
|
1006
1006
|
for (; i < len; i++) {
|
1007
1007
|
if (triggers[i].id === id) {
|
1008
|
-
return triggers[i]
|
1008
|
+
return triggers[i]
|
1009
1009
|
}
|
1010
1010
|
}
|
1011
1011
|
|
1012
|
-
return null
|
1012
|
+
return null
|
1013
1013
|
}
|
1014
1014
|
|
1015
1015
|
/**
|
@@ -1018,7 +1018,7 @@ class Text extends Base {
|
|
1018
1018
|
* @returns {String} The trigger node id
|
1019
1019
|
*/
|
1020
1020
|
getTriggerId(type) {
|
1021
|
-
return this.id + '-trigger-' + type
|
1021
|
+
return this.id + '-trigger-' + type
|
1022
1022
|
}
|
1023
1023
|
|
1024
1024
|
/**
|
@@ -1042,18 +1042,18 @@ class Text extends Base {
|
|
1042
1042
|
|
1043
1043
|
for (; i < len; i++) {
|
1044
1044
|
if (triggers[i].type === type) {
|
1045
|
-
return true
|
1045
|
+
return true
|
1046
1046
|
}
|
1047
1047
|
}
|
1048
1048
|
|
1049
|
-
return false
|
1049
|
+
return false
|
1050
1050
|
}
|
1051
1051
|
|
1052
1052
|
/**
|
1053
1053
|
* @returns {Boolean}
|
1054
1054
|
*/
|
1055
1055
|
isEmpty() {
|
1056
|
-
return !(this.value?.toString().length > 0)
|
1056
|
+
return !(this.value?.toString().length > 0)
|
1057
1057
|
}
|
1058
1058
|
|
1059
1059
|
/**
|
@@ -1062,7 +1062,7 @@ class Text extends Base {
|
|
1062
1062
|
isValid() {
|
1063
1063
|
this.validate(true); // silent
|
1064
1064
|
|
1065
|
-
return this.error
|
1065
|
+
return this.error ? false : super.isValid()
|
1066
1066
|
}
|
1067
1067
|
|
1068
1068
|
/**
|
@@ -1078,7 +1078,7 @@ class Text extends Base {
|
|
1078
1078
|
me[triggers ? 'triggers' : '_triggers'] = triggers;
|
1079
1079
|
|
1080
1080
|
delete config.triggers;
|
1081
|
-
return config
|
1081
|
+
return config
|
1082
1082
|
}
|
1083
1083
|
|
1084
1084
|
/**
|
@@ -1097,9 +1097,9 @@ class Text extends Base {
|
|
1097
1097
|
if (me.labelPosition === 'inline') {
|
1098
1098
|
if (me.centerBorderElWidth) {
|
1099
1099
|
me.getCenterBorderEl().width = me.centerBorderElWidth;
|
1100
|
-
me.update()
|
1100
|
+
me.update()
|
1101
1101
|
} else {
|
1102
|
-
me.updateCenterBorderElWidth(false)
|
1102
|
+
me.updateCenterBorderElWidth(false)
|
1103
1103
|
}
|
1104
1104
|
}
|
1105
1105
|
}
|
@@ -1127,10 +1127,10 @@ class Text extends Base {
|
|
1127
1127
|
delete centerBorderEl.width;
|
1128
1128
|
}
|
1129
1129
|
|
1130
|
-
me.update()
|
1130
|
+
me.update()
|
1131
1131
|
}
|
1132
1132
|
|
1133
|
-
super.onFocusLeave(data)
|
1133
|
+
super.onFocusLeave(data)
|
1134
1134
|
}
|
1135
1135
|
|
1136
1136
|
/**
|
@@ -1147,7 +1147,7 @@ class Text extends Base {
|
|
1147
1147
|
vnode.vnode.attributes.value = value;
|
1148
1148
|
}
|
1149
1149
|
|
1150
|
-
me.value = value
|
1150
|
+
me.value = value
|
1151
1151
|
}
|
1152
1152
|
|
1153
1153
|
/**
|
@@ -1159,7 +1159,7 @@ class Text extends Base {
|
|
1159
1159
|
|
1160
1160
|
if (!me.readOnly) {
|
1161
1161
|
NeoArray.add(cls, 'neo-hovered');
|
1162
|
-
me.cls = cls
|
1162
|
+
me.cls = cls
|
1163
1163
|
}
|
1164
1164
|
}
|
1165
1165
|
|
@@ -1172,7 +1172,7 @@ class Text extends Base {
|
|
1172
1172
|
|
1173
1173
|
if (!me.readOnly) {
|
1174
1174
|
NeoArray.remove(cls, 'neo-hovered');
|
1175
|
-
me.cls = cls
|
1175
|
+
me.cls = cls
|
1176
1176
|
}
|
1177
1177
|
}
|
1178
1178
|
|
@@ -1205,7 +1205,7 @@ class Text extends Base {
|
|
1205
1205
|
me.triggers = triggers;
|
1206
1206
|
}
|
1207
1207
|
|
1208
|
-
return hasMatch
|
1208
|
+
return hasMatch
|
1209
1209
|
}
|
1210
1210
|
|
1211
1211
|
/**
|
@@ -1227,7 +1227,7 @@ class Text extends Base {
|
|
1227
1227
|
super.reset(value);
|
1228
1228
|
|
1229
1229
|
if (value === null && me.clean) {
|
1230
|
-
me.updateError(null)
|
1230
|
+
me.updateError(null)
|
1231
1231
|
}
|
1232
1232
|
}
|
1233
1233
|
|
@@ -1244,9 +1244,9 @@ class Text extends Base {
|
|
1244
1244
|
|
1245
1245
|
if (!silent) {
|
1246
1246
|
me.getCenterBorderEl().width = me.centerBorderElWidth;
|
1247
|
-
me.update()
|
1247
|
+
me.update()
|
1248
1248
|
}
|
1249
|
-
})
|
1249
|
+
})
|
1250
1250
|
}
|
1251
1251
|
|
1252
1252
|
/**
|
@@ -1256,27 +1256,23 @@ class Text extends Base {
|
|
1256
1256
|
updateError(value, silent=false) {
|
1257
1257
|
let me = this,
|
1258
1258
|
cls = me.cls,
|
1259
|
-
errorNode
|
1259
|
+
errorNode;
|
1260
1260
|
|
1261
1261
|
if (!(me.clean && !me.mounted)) {
|
1262
|
-
|
1263
|
-
|
1264
|
-
isValid = !value || value === '';
|
1265
|
-
|
1266
|
-
NeoArray[!isValid ? 'add' : 'remove'](cls, 'neo-invalid');
|
1262
|
+
NeoArray[value ? 'add' : 'remove'](cls, 'neo-invalid');
|
1267
1263
|
me.cls = cls;
|
1268
1264
|
|
1269
1265
|
errorNode = VDomUtil.findVdomChild(me.vdom, {cls: 'neo-textfield-error'}).vdom;
|
1270
1266
|
|
1271
|
-
if (
|
1272
|
-
errorNode.html =
|
1267
|
+
if (value) {
|
1268
|
+
errorNode.html = value;
|
1273
1269
|
} else {
|
1274
1270
|
delete errorNode.html;
|
1275
1271
|
}
|
1276
1272
|
|
1277
|
-
errorNode.removeDom =
|
1273
|
+
errorNode.removeDom = !value;
|
1278
1274
|
|
1279
|
-
!silent && me.update()
|
1275
|
+
!silent && me.update()
|
1280
1276
|
}
|
1281
1277
|
}
|
1282
1278
|
|
@@ -1289,12 +1285,12 @@ class Text extends Base {
|
|
1289
1285
|
inputWidth = me.getInputWidth();
|
1290
1286
|
|
1291
1287
|
if (inputWidth !== null && inputWidth !== me.width) {
|
1292
|
-
me.vdom.cn[1].width = inputWidth
|
1288
|
+
me.vdom.cn[1].width = inputWidth
|
1293
1289
|
} else {
|
1294
|
-
delete me.vdom.cn[1].width
|
1290
|
+
delete me.vdom.cn[1].width
|
1295
1291
|
}
|
1296
1292
|
|
1297
|
-
me.update()
|
1293
|
+
me.update()
|
1298
1294
|
}
|
1299
1295
|
|
1300
1296
|
/**
|
@@ -1314,8 +1310,8 @@ class Text extends Base {
|
|
1314
1310
|
vnode,
|
1315
1311
|
_rendered: true,
|
1316
1312
|
_mounted : true
|
1317
|
-
})
|
1318
|
-
})
|
1313
|
+
})
|
1314
|
+
})
|
1319
1315
|
}
|
1320
1316
|
|
1321
1317
|
/**
|
@@ -1325,7 +1321,6 @@ class Text extends Base {
|
|
1325
1321
|
*/
|
1326
1322
|
validate(silent=true) {
|
1327
1323
|
let me = this,
|
1328
|
-
errorField = silent ? '_error' : 'error',
|
1329
1324
|
maxLength = me.maxLength,
|
1330
1325
|
minLength = me.minLength,
|
1331
1326
|
required = me.required,
|
@@ -1346,38 +1341,38 @@ class Text extends Base {
|
|
1346
1341
|
errorText = me.validator(me);
|
1347
1342
|
|
1348
1343
|
if (errorText !== true) {
|
1349
|
-
me
|
1344
|
+
me._error = errorText;
|
1350
1345
|
returnValue = false;
|
1351
1346
|
}
|
1352
1347
|
}
|
1353
1348
|
|
1354
1349
|
if (required && isEmpty) {
|
1355
|
-
me
|
1350
|
+
me._error = me.errorTextRequired;
|
1356
1351
|
returnValue = false;
|
1357
1352
|
} else if (Neo.isNumber(maxLength) && valueLength > maxLength) {
|
1358
1353
|
if (required || !isEmpty) {
|
1359
|
-
me
|
1354
|
+
me._error = me.errorTextMaxLength(errorParam);
|
1360
1355
|
returnValue = false;
|
1361
1356
|
}
|
1362
1357
|
} else if (Neo.isNumber(minLength) && valueLength < minLength) {
|
1363
1358
|
if (required || !isEmpty) {
|
1364
|
-
me
|
1359
|
+
me._error = me.errorTextMinLength(errorParam);
|
1365
1360
|
returnValue = false;
|
1366
1361
|
}
|
1367
1362
|
} else if (inputPattern && !inputPattern.test(value)) {
|
1368
1363
|
if (required || !isEmpty) {
|
1369
|
-
me
|
1364
|
+
me._error = me.errorTextInputPattern(errorParam);
|
1370
1365
|
returnValue = false;
|
1371
1366
|
}
|
1372
1367
|
}
|
1373
1368
|
|
1374
1369
|
if (returnValue) {
|
1375
|
-
me
|
1370
|
+
me._error = null;
|
1376
1371
|
}
|
1377
1372
|
|
1378
|
-
!me.clean && me.updateError(me
|
1373
|
+
!me.clean && me.updateError(me._error, silent);
|
1379
1374
|
|
1380
|
-
return !returnValue ? false : super.validate(silent)
|
1375
|
+
return !returnValue ? false : super.validate(silent)
|
1381
1376
|
}
|
1382
1377
|
}
|
1383
1378
|
|