neo.mjs 4.0.53 → 4.0.56
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/text/MainContainer.mjs +7 -5
- package/package.json +1 -1
- package/resources/scss/src/form/field/Text.scss +28 -8
- package/resources/scss/theme-dark/form/field/Text.scss +3 -1
- package/resources/scss/theme-light/form/field/Text.scss +3 -1
- package/src/data/RecordFactory.mjs +12 -4
- package/src/form/field/Text.mjs +17 -11
|
@@ -151,11 +151,13 @@ class MainContainer extends ConfigurationViewport {
|
|
|
151
151
|
|
|
152
152
|
createExampleComponent() {
|
|
153
153
|
return Neo.create(TextField, {
|
|
154
|
-
clearable
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
clearable : true,
|
|
155
|
+
labelPosition: 'inline',
|
|
156
|
+
labelText : 'Label',
|
|
157
|
+
labelWidth : 70,
|
|
158
|
+
minLength : 3,
|
|
159
|
+
value : 'Hello World',
|
|
160
|
+
width : 200
|
|
159
161
|
});
|
|
160
162
|
}
|
|
161
163
|
}
|
package/package.json
CHANGED
|
@@ -12,14 +12,34 @@
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
&.neo-invalid {
|
|
15
|
+
&.neo-invalid:not(.neo-disabled) {
|
|
16
16
|
.neo-input-wrapper {
|
|
17
|
-
border-color:
|
|
17
|
+
border-color: v(textfield-border-color-invalid);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
.neo-
|
|
22
|
-
border-color:
|
|
20
|
+
.neo-label-wrapper {
|
|
21
|
+
.neo-center-border, .neo-left-border, .neo-right-border {
|
|
22
|
+
border-bottom-color: v(textfield-border-color-invalid);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.neo-left-border, .neo-right-border {
|
|
26
|
+
border-top-color: v(textfield-border-color-invalid);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.neo-left-border {
|
|
30
|
+
border-left-color: v(textfield-border-color-invalid);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.neo-right-border {
|
|
34
|
+
border-right-color: v(textfield-border-color-invalid);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.neo-invalid:not(.neo-disabled, .neo-has-content) {
|
|
40
|
+
.neo-label-wrapper {
|
|
41
|
+
.neo-center-border {
|
|
42
|
+
border-top-color: v(textfield-border-color-invalid);
|
|
23
43
|
}
|
|
24
44
|
}
|
|
25
45
|
}
|
|
@@ -48,7 +68,7 @@
|
|
|
48
68
|
}
|
|
49
69
|
|
|
50
70
|
.neo-center-border {
|
|
51
|
-
border-top-color: transparent;
|
|
71
|
+
border-top-color: transparent !important;
|
|
52
72
|
}
|
|
53
73
|
|
|
54
74
|
.neo-left-border {
|
|
@@ -82,7 +102,7 @@
|
|
|
82
102
|
}
|
|
83
103
|
|
|
84
104
|
.neo-input-wrapper {
|
|
85
|
-
border-color: transparent;
|
|
105
|
+
border-color: transparent !important;
|
|
86
106
|
}
|
|
87
107
|
|
|
88
108
|
.neo-label-wrapper {
|
|
@@ -193,7 +213,7 @@
|
|
|
193
213
|
}
|
|
194
214
|
|
|
195
215
|
&.neo-invalid {
|
|
196
|
-
border-color:
|
|
216
|
+
border-color: v(textfield-border-color-invalid);
|
|
197
217
|
|
|
198
218
|
&.neo-disabled {
|
|
199
219
|
border-color: inherit;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
$neoMap: map-merge($neoMap, (
|
|
2
2
|
'textfield-border-color' : #424242,
|
|
3
3
|
'textfield-border-color-active' : #5d83a7,
|
|
4
|
+
'textfield-border-color-invalid' : brown,
|
|
4
5
|
'textfield-border-radius' : 0,
|
|
5
6
|
'textfield-input-background-color' : #2b2b2b,
|
|
6
7
|
'textfield-input-color' : #ccc,
|
|
@@ -13,6 +14,7 @@ $neoMap: map-merge($neoMap, (
|
|
|
13
14
|
:root .neo-theme-dark { // .neo-textfield
|
|
14
15
|
--textfield-border-color : #{neo(textfield-border-color)};
|
|
15
16
|
--textfield-border-color-active : #{neo(textfield-border-color-active)};
|
|
17
|
+
--textfield-border-color-invalid : #{neo(textfield-border-color-invalid)};
|
|
16
18
|
--textfield-border-radius : #{neo(textfield-border-radius)};
|
|
17
19
|
--textfield-input-background-color : #{neo(textfield-input-background-color)};
|
|
18
20
|
--textfield-input-color : #{neo(textfield-input-color)};
|
|
@@ -20,4 +22,4 @@ $neoMap: map-merge($neoMap, (
|
|
|
20
22
|
--textfield-input-placeholder-opacity: #{neo(textfield-input-placeholder-opacity)};
|
|
21
23
|
--textfield-label-color : #{neo(textfield-label-color)};
|
|
22
24
|
}
|
|
23
|
-
}
|
|
25
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
$neoMap: map-merge($neoMap, (
|
|
2
2
|
'textfield-border-color' : #ddd,
|
|
3
3
|
'textfield-border-color-active' : #1c60a0,
|
|
4
|
+
'textfield-border-color-invalid' : brown,
|
|
4
5
|
'textfield-border-radius' : 3px,
|
|
5
6
|
'textfield-input-background-color' : #fff,
|
|
6
7
|
'textfield-input-color' : #000,
|
|
@@ -13,6 +14,7 @@ $neoMap: map-merge($neoMap, (
|
|
|
13
14
|
:root .neo-theme-light { // .neo-textfield
|
|
14
15
|
--textfield-border-color : #{neo(textfield-border-color)};
|
|
15
16
|
--textfield-border-color-active : #{neo(textfield-border-color-active)};
|
|
17
|
+
--textfield-border-color-invalid : #{neo(textfield-border-color-invalid)};
|
|
16
18
|
--textfield-border-radius : #{neo(textfield-border-radius)};
|
|
17
19
|
--textfield-input-background-color : #{neo(textfield-input-background-color)};
|
|
18
20
|
--textfield-input-color : #{neo(textfield-input-color)};
|
|
@@ -20,4 +22,4 @@ $neoMap: map-merge($neoMap, (
|
|
|
20
22
|
--textfield-input-placeholder-opacity: #{neo(textfield-input-placeholder-opacity)};
|
|
21
23
|
--textfield-label-color : #{neo(textfield-label-color)};
|
|
22
24
|
}
|
|
23
|
-
}
|
|
25
|
+
}
|
|
@@ -231,6 +231,7 @@ class RecordFactory extends Base {
|
|
|
231
231
|
let mapping = field.mapping,
|
|
232
232
|
maxLength = field.maxLength,
|
|
233
233
|
minLength = field.minLength,
|
|
234
|
+
nullable = field.nullable,
|
|
234
235
|
oldValue = recordConfig?.[field.name] || record[field.name],
|
|
235
236
|
type = field.type?.toLowerCase();
|
|
236
237
|
|
|
@@ -244,16 +245,23 @@ class RecordFactory extends Base {
|
|
|
244
245
|
value = ns[key];
|
|
245
246
|
}
|
|
246
247
|
|
|
247
|
-
if (Object.hasOwn(field, maxLength)) {
|
|
248
|
+
if (Object.hasOwn(field, 'maxLength')) {
|
|
248
249
|
if (value?.toString() > maxLength) {
|
|
249
|
-
console.warn(`Setting record field: ${field} value: ${value} conflicts with
|
|
250
|
+
console.warn(`Setting record field: ${field} value: ${value} conflicts with maxLength: ${maxLength}`);
|
|
250
251
|
return oldValue;
|
|
251
252
|
}
|
|
252
253
|
}
|
|
253
254
|
|
|
254
|
-
if (Object.hasOwn(field, minLength)) {
|
|
255
|
+
if (Object.hasOwn(field, 'minLength')) {
|
|
255
256
|
if (value?.toString() < minLength) {
|
|
256
|
-
console.warn(`Setting record field: ${field} value: ${value} conflicts with
|
|
257
|
+
console.warn(`Setting record field: ${field} value: ${value} conflicts with minLength: ${minLength}`);
|
|
258
|
+
return oldValue;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (Object.hasOwn(field, 'nullable')) {
|
|
263
|
+
if (nullable === false && value === null) {
|
|
264
|
+
console.warn(`Setting record field: ${field} value: ${value} conflicts with nullable: ${nullable}`);
|
|
257
265
|
return oldValue;
|
|
258
266
|
}
|
|
259
267
|
}
|
package/src/form/field/Text.mjs
CHANGED
|
@@ -10,6 +10,12 @@ import VNodeUtil from '../../util/VNode.mjs';
|
|
|
10
10
|
* @extends Neo.form.field.Base
|
|
11
11
|
*/
|
|
12
12
|
class Text extends Base {
|
|
13
|
+
/**
|
|
14
|
+
* Set this value to false, in case a field should display errors up front
|
|
15
|
+
* @member {Boolean} validBeforeMount=true
|
|
16
|
+
*/
|
|
17
|
+
validBeforeMount = true
|
|
18
|
+
|
|
13
19
|
static getStaticConfig() {return {
|
|
14
20
|
/**
|
|
15
21
|
* Valid values for autoCapitalize
|
|
@@ -877,19 +883,17 @@ class Text extends Base {
|
|
|
877
883
|
onFocusLeave(data) {
|
|
878
884
|
let me = this,
|
|
879
885
|
centerBorderEl = me.getCenterBorderEl(), // labelPosition: 'inline'
|
|
880
|
-
|
|
881
|
-
vdom;
|
|
886
|
+
vdom = me.vdom;
|
|
882
887
|
|
|
883
|
-
|
|
888
|
+
me.updateValidationIndicators();
|
|
889
|
+
|
|
890
|
+
NeoArray.remove(me._cls, 'neo-focus');
|
|
884
891
|
|
|
885
892
|
if (centerBorderEl && me.isEmpty()) {
|
|
886
|
-
me._cls = cls; // silent update
|
|
887
|
-
vdom = me.vdom;
|
|
888
893
|
delete centerBorderEl.width;
|
|
889
|
-
me.vdom = vdom;
|
|
890
|
-
} else {
|
|
891
|
-
me.cls = cls;
|
|
892
894
|
}
|
|
895
|
+
|
|
896
|
+
me.vdom = vdom;
|
|
893
897
|
}
|
|
894
898
|
|
|
895
899
|
/**
|
|
@@ -1023,10 +1027,12 @@ class Text extends Base {
|
|
|
1023
1027
|
let me = this,
|
|
1024
1028
|
vdom = me.vdom;
|
|
1025
1029
|
|
|
1026
|
-
|
|
1030
|
+
if (!(me.validBeforeMount && !me.mounted)) {
|
|
1031
|
+
NeoArray[!me.isValid() ? 'add' : 'remove'](me._cls, 'neo-invalid');
|
|
1027
1032
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1033
|
+
if (!silent) {
|
|
1034
|
+
me.vdom = vdom;
|
|
1035
|
+
}
|
|
1030
1036
|
}
|
|
1031
1037
|
}
|
|
1032
1038
|
}
|