@aurodesignsystem/auro-formkit 3.3.0-beta.2 → 3.4.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/CHANGELOG.md +30 -0
- package/components/checkbox/README.md +1 -1
- package/components/checkbox/demo/api.min.js +36 -5
- package/components/checkbox/demo/index.min.js +36 -5
- package/components/checkbox/demo/readme.md +1 -1
- package/components/checkbox/dist/auro-checkbox-group.d.ts +7 -0
- package/components/checkbox/dist/auro-checkbox.d.ts +7 -0
- package/components/checkbox/dist/index.js +36 -5
- package/components/checkbox/dist/registered.js +36 -5
- package/components/combobox/README.md +1 -1
- package/components/combobox/demo/api.md +44 -0
- package/components/combobox/demo/api.min.js +95 -60
- package/components/combobox/demo/index.min.js +95 -60
- package/components/combobox/demo/readme.md +1 -1
- package/components/combobox/dist/auro-combobox.d.ts +8 -10
- package/components/combobox/dist/index.js +95 -60
- package/components/combobox/dist/registered.js +95 -60
- package/components/counter/README.md +1 -1
- package/components/counter/demo/api.min.js +12 -5
- package/components/counter/demo/index.min.js +12 -5
- package/components/counter/demo/readme.md +1 -1
- package/components/counter/dist/index.js +12 -5
- package/components/counter/dist/registered.js +12 -5
- package/components/datepicker/README.md +1 -1
- package/components/datepicker/demo/api.md +30 -0
- package/components/datepicker/demo/api.min.js +72 -37
- package/components/datepicker/demo/index.min.js +72 -37
- package/components/datepicker/demo/readme.md +1 -1
- package/components/datepicker/dist/auro-datepicker.d.ts +14 -0
- package/components/datepicker/dist/index.js +72 -37
- package/components/datepicker/dist/registered.js +72 -37
- package/components/dropdown/README.md +1 -1
- package/components/dropdown/demo/readme.md +1 -1
- package/components/form/README.md +1 -1
- package/components/form/demo/readme.md +1 -1
- package/components/input/README.md +1 -1
- package/components/input/demo/api.md +24 -0
- package/components/input/demo/api.min.js +36 -17
- package/components/input/demo/index.min.js +36 -17
- package/components/input/demo/readme.md +1 -1
- package/components/input/dist/base-input.d.ts +15 -0
- package/components/input/dist/index.js +36 -17
- package/components/input/dist/registered.js +36 -17
- package/components/menu/README.md +1 -1
- package/components/menu/demo/readme.md +1 -1
- package/components/radio/README.md +1 -1
- package/components/radio/demo/api.min.js +39 -9
- package/components/radio/demo/index.min.js +39 -9
- package/components/radio/demo/readme.md +1 -1
- package/components/radio/dist/auro-radio-group.d.ts +8 -0
- package/components/radio/dist/auro-radio.d.ts +10 -0
- package/components/radio/dist/index.js +39 -9
- package/components/radio/dist/registered.js +39 -9
- package/components/select/README.md +1 -1
- package/components/select/demo/api.min.js +25 -15
- package/components/select/demo/index.min.js +25 -15
- package/components/select/demo/readme.md +1 -1
- package/components/select/dist/auro-select.d.ts +8 -0
- package/components/select/dist/index.js +25 -15
- package/components/select/dist/registered.js +25 -15
- package/package.json +1 -1
|
@@ -173,6 +173,7 @@ class AuroRadio extends i$2 {
|
|
|
173
173
|
this.error = false;
|
|
174
174
|
this.onDark = false;
|
|
175
175
|
this.tabIndex = -1;
|
|
176
|
+
this.touched = false;
|
|
176
177
|
|
|
177
178
|
/**
|
|
178
179
|
* @private
|
|
@@ -218,6 +219,16 @@ class AuroRadio extends i$2 {
|
|
|
218
219
|
tabIndex: {
|
|
219
220
|
type: Number,
|
|
220
221
|
reflect: true
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Whether or not the radio button has been touched by the user.
|
|
226
|
+
* @private
|
|
227
|
+
*/
|
|
228
|
+
touched: {
|
|
229
|
+
type: Boolean,
|
|
230
|
+
reflect: true,
|
|
231
|
+
attribute: false
|
|
221
232
|
}
|
|
222
233
|
};
|
|
223
234
|
}
|
|
@@ -269,6 +280,7 @@ class AuroRadio extends i$2 {
|
|
|
269
280
|
* @returns {void}
|
|
270
281
|
*/
|
|
271
282
|
handleFocus(event) {
|
|
283
|
+
this.touched = true;
|
|
272
284
|
this.dispatchEvent(new CustomEvent('focusSelected', {
|
|
273
285
|
bubbles: true,
|
|
274
286
|
composed: true,
|
|
@@ -295,6 +307,7 @@ class AuroRadio extends i$2 {
|
|
|
295
307
|
* @returns {void}
|
|
296
308
|
*/
|
|
297
309
|
reset() {
|
|
310
|
+
this.touched = false;
|
|
298
311
|
this.checked = false;
|
|
299
312
|
this.error = false;
|
|
300
313
|
}
|
|
@@ -832,6 +845,7 @@ class AuroFormValidation {
|
|
|
832
845
|
reset(elem) {
|
|
833
846
|
elem.validity = undefined;
|
|
834
847
|
elem.value = undefined;
|
|
848
|
+
elem.touched = false;
|
|
835
849
|
|
|
836
850
|
// Resets the second value of the datepicker in range state
|
|
837
851
|
if (elem.valueEnd) {
|
|
@@ -969,7 +983,7 @@ class AuroFormValidation {
|
|
|
969
983
|
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
970
984
|
|
|
971
985
|
// Guard Clause: if the value is too short
|
|
972
|
-
if (elem.value
|
|
986
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
973
987
|
|
|
974
988
|
elem.validity = 'tooShort';
|
|
975
989
|
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
@@ -1039,11 +1053,17 @@ class AuroFormValidation {
|
|
|
1039
1053
|
this.getAuroInputs(elem);
|
|
1040
1054
|
|
|
1041
1055
|
// Validate only if noValidate is not true and the input does not have focus
|
|
1042
|
-
|
|
1056
|
+
let validationShouldRun =
|
|
1057
|
+
force ||
|
|
1058
|
+
(!elem.contains(document.activeElement) &&
|
|
1059
|
+
(elem.touched ||
|
|
1060
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
1061
|
+
elem.validateOnInput;
|
|
1043
1062
|
|
|
1044
1063
|
if (elem.hasAttribute('error')) {
|
|
1045
1064
|
elem.validity = 'customError';
|
|
1046
1065
|
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
1066
|
+
validationShouldRun = false;
|
|
1047
1067
|
} else if (validationShouldRun) {
|
|
1048
1068
|
elem.validity = 'valid';
|
|
1049
1069
|
elem.errorMessage = '';
|
|
@@ -1064,7 +1084,7 @@ class AuroFormValidation {
|
|
|
1064
1084
|
}
|
|
1065
1085
|
}
|
|
1066
1086
|
|
|
1067
|
-
if (!hasValue && elem.required) {
|
|
1087
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
1068
1088
|
elem.validity = 'valueMissing';
|
|
1069
1089
|
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
1070
1090
|
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
@@ -1075,7 +1095,7 @@ class AuroFormValidation {
|
|
|
1075
1095
|
}
|
|
1076
1096
|
}
|
|
1077
1097
|
|
|
1078
|
-
if (this.auroInputElements?.length > 0) {
|
|
1098
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
1079
1099
|
elem.validity = this.auroInputElements[0].validity;
|
|
1080
1100
|
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
1081
1101
|
|
|
@@ -1154,7 +1174,7 @@ class AuroFormValidation {
|
|
|
1154
1174
|
}
|
|
1155
1175
|
}
|
|
1156
1176
|
} else {
|
|
1157
|
-
elem.errorMessage =
|
|
1177
|
+
elem.errorMessage = '';
|
|
1158
1178
|
}
|
|
1159
1179
|
}
|
|
1160
1180
|
}
|
|
@@ -1443,6 +1463,7 @@ class AuroRadioGroup extends i$2 {
|
|
|
1443
1463
|
this.value = undefined;
|
|
1444
1464
|
this.optionSelected = undefined;
|
|
1445
1465
|
this.onDark = false;
|
|
1466
|
+
this.touched = false;
|
|
1446
1467
|
|
|
1447
1468
|
/**
|
|
1448
1469
|
* @private
|
|
@@ -1524,6 +1545,18 @@ class AuroRadioGroup extends i$2 {
|
|
|
1524
1545
|
},
|
|
1525
1546
|
optionSelected: {
|
|
1526
1547
|
type: Object
|
|
1548
|
+
},
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Indicates whether the radio group is in a dirty state (has been interacted with).
|
|
1552
|
+
* @type {boolean}
|
|
1553
|
+
* @default false
|
|
1554
|
+
* @private
|
|
1555
|
+
*/
|
|
1556
|
+
touched: {
|
|
1557
|
+
type: Boolean,
|
|
1558
|
+
reflect: true,
|
|
1559
|
+
attribute: false
|
|
1527
1560
|
}
|
|
1528
1561
|
};
|
|
1529
1562
|
}
|
|
@@ -1579,10 +1612,7 @@ class AuroRadioGroup extends i$2 {
|
|
|
1579
1612
|
* @returns {void}
|
|
1580
1613
|
*/
|
|
1581
1614
|
handleRadioBlur() {
|
|
1582
|
-
|
|
1583
|
-
this.value = '';
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1615
|
+
this.touched = true;
|
|
1586
1616
|
this.validation.validate(this);
|
|
1587
1617
|
}
|
|
1588
1618
|
|
|
@@ -148,6 +148,7 @@ class AuroRadio extends i$2 {
|
|
|
148
148
|
this.error = false;
|
|
149
149
|
this.onDark = false;
|
|
150
150
|
this.tabIndex = -1;
|
|
151
|
+
this.touched = false;
|
|
151
152
|
|
|
152
153
|
/**
|
|
153
154
|
* @private
|
|
@@ -193,6 +194,16 @@ class AuroRadio extends i$2 {
|
|
|
193
194
|
tabIndex: {
|
|
194
195
|
type: Number,
|
|
195
196
|
reflect: true
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Whether or not the radio button has been touched by the user.
|
|
201
|
+
* @private
|
|
202
|
+
*/
|
|
203
|
+
touched: {
|
|
204
|
+
type: Boolean,
|
|
205
|
+
reflect: true,
|
|
206
|
+
attribute: false
|
|
196
207
|
}
|
|
197
208
|
};
|
|
198
209
|
}
|
|
@@ -244,6 +255,7 @@ class AuroRadio extends i$2 {
|
|
|
244
255
|
* @returns {void}
|
|
245
256
|
*/
|
|
246
257
|
handleFocus(event) {
|
|
258
|
+
this.touched = true;
|
|
247
259
|
this.dispatchEvent(new CustomEvent('focusSelected', {
|
|
248
260
|
bubbles: true,
|
|
249
261
|
composed: true,
|
|
@@ -270,6 +282,7 @@ class AuroRadio extends i$2 {
|
|
|
270
282
|
* @returns {void}
|
|
271
283
|
*/
|
|
272
284
|
reset() {
|
|
285
|
+
this.touched = false;
|
|
273
286
|
this.checked = false;
|
|
274
287
|
this.error = false;
|
|
275
288
|
}
|
|
@@ -807,6 +820,7 @@ class AuroFormValidation {
|
|
|
807
820
|
reset(elem) {
|
|
808
821
|
elem.validity = undefined;
|
|
809
822
|
elem.value = undefined;
|
|
823
|
+
elem.touched = false;
|
|
810
824
|
|
|
811
825
|
// Resets the second value of the datepicker in range state
|
|
812
826
|
if (elem.valueEnd) {
|
|
@@ -944,7 +958,7 @@ class AuroFormValidation {
|
|
|
944
958
|
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
945
959
|
|
|
946
960
|
// Guard Clause: if the value is too short
|
|
947
|
-
if (elem.value
|
|
961
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
948
962
|
|
|
949
963
|
elem.validity = 'tooShort';
|
|
950
964
|
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
@@ -1014,11 +1028,17 @@ class AuroFormValidation {
|
|
|
1014
1028
|
this.getAuroInputs(elem);
|
|
1015
1029
|
|
|
1016
1030
|
// Validate only if noValidate is not true and the input does not have focus
|
|
1017
|
-
|
|
1031
|
+
let validationShouldRun =
|
|
1032
|
+
force ||
|
|
1033
|
+
(!elem.contains(document.activeElement) &&
|
|
1034
|
+
(elem.touched ||
|
|
1035
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
1036
|
+
elem.validateOnInput;
|
|
1018
1037
|
|
|
1019
1038
|
if (elem.hasAttribute('error')) {
|
|
1020
1039
|
elem.validity = 'customError';
|
|
1021
1040
|
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
1041
|
+
validationShouldRun = false;
|
|
1022
1042
|
} else if (validationShouldRun) {
|
|
1023
1043
|
elem.validity = 'valid';
|
|
1024
1044
|
elem.errorMessage = '';
|
|
@@ -1039,7 +1059,7 @@ class AuroFormValidation {
|
|
|
1039
1059
|
}
|
|
1040
1060
|
}
|
|
1041
1061
|
|
|
1042
|
-
if (!hasValue && elem.required) {
|
|
1062
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
1043
1063
|
elem.validity = 'valueMissing';
|
|
1044
1064
|
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
1045
1065
|
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
@@ -1050,7 +1070,7 @@ class AuroFormValidation {
|
|
|
1050
1070
|
}
|
|
1051
1071
|
}
|
|
1052
1072
|
|
|
1053
|
-
if (this.auroInputElements?.length > 0) {
|
|
1073
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
1054
1074
|
elem.validity = this.auroInputElements[0].validity;
|
|
1055
1075
|
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
1056
1076
|
|
|
@@ -1129,7 +1149,7 @@ class AuroFormValidation {
|
|
|
1129
1149
|
}
|
|
1130
1150
|
}
|
|
1131
1151
|
} else {
|
|
1132
|
-
elem.errorMessage =
|
|
1152
|
+
elem.errorMessage = '';
|
|
1133
1153
|
}
|
|
1134
1154
|
}
|
|
1135
1155
|
}
|
|
@@ -1418,6 +1438,7 @@ class AuroRadioGroup extends i$2 {
|
|
|
1418
1438
|
this.value = undefined;
|
|
1419
1439
|
this.optionSelected = undefined;
|
|
1420
1440
|
this.onDark = false;
|
|
1441
|
+
this.touched = false;
|
|
1421
1442
|
|
|
1422
1443
|
/**
|
|
1423
1444
|
* @private
|
|
@@ -1499,6 +1520,18 @@ class AuroRadioGroup extends i$2 {
|
|
|
1499
1520
|
},
|
|
1500
1521
|
optionSelected: {
|
|
1501
1522
|
type: Object
|
|
1523
|
+
},
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* Indicates whether the radio group is in a dirty state (has been interacted with).
|
|
1527
|
+
* @type {boolean}
|
|
1528
|
+
* @default false
|
|
1529
|
+
* @private
|
|
1530
|
+
*/
|
|
1531
|
+
touched: {
|
|
1532
|
+
type: Boolean,
|
|
1533
|
+
reflect: true,
|
|
1534
|
+
attribute: false
|
|
1502
1535
|
}
|
|
1503
1536
|
};
|
|
1504
1537
|
}
|
|
@@ -1554,10 +1587,7 @@ class AuroRadioGroup extends i$2 {
|
|
|
1554
1587
|
* @returns {void}
|
|
1555
1588
|
*/
|
|
1556
1589
|
handleRadioBlur() {
|
|
1557
|
-
|
|
1558
|
-
this.value = '';
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1590
|
+
this.touched = true;
|
|
1561
1591
|
this.validation.validate(this);
|
|
1562
1592
|
}
|
|
1563
1593
|
|
|
@@ -100,7 +100,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
|
|
|
100
100
|
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
|
|
101
101
|
|
|
102
102
|
```html
|
|
103
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.
|
|
103
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.3.0/auro-radio/+esm"></script>
|
|
104
104
|
```
|
|
105
105
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
106
106
|
|
|
@@ -60,6 +60,13 @@ export class AuroRadioGroup extends LitElement {
|
|
|
60
60
|
optionSelected: {
|
|
61
61
|
type: ObjectConstructor;
|
|
62
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Indicates whether the radio group is in a dirty state (has been interacted with).
|
|
65
|
+
* @type {boolean}
|
|
66
|
+
* @default false
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
touched: boolean;
|
|
63
70
|
};
|
|
64
71
|
/**
|
|
65
72
|
* This will register this element with the browser.
|
|
@@ -77,6 +84,7 @@ export class AuroRadioGroup extends LitElement {
|
|
|
77
84
|
value: any;
|
|
78
85
|
optionSelected: EventTarget;
|
|
79
86
|
onDark: boolean;
|
|
87
|
+
touched: boolean;
|
|
80
88
|
/**
|
|
81
89
|
* @private
|
|
82
90
|
*/
|
|
@@ -49,6 +49,15 @@ export class AuroRadio extends LitElement {
|
|
|
49
49
|
type: NumberConstructor;
|
|
50
50
|
reflect: boolean;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Whether or not the radio button has been touched by the user.
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
touched: {
|
|
57
|
+
type: BooleanConstructor;
|
|
58
|
+
reflect: boolean;
|
|
59
|
+
attribute: boolean;
|
|
60
|
+
};
|
|
52
61
|
};
|
|
53
62
|
/**
|
|
54
63
|
* This will register this element with the browser.
|
|
@@ -64,6 +73,7 @@ export class AuroRadio extends LitElement {
|
|
|
64
73
|
required: boolean;
|
|
65
74
|
error: boolean;
|
|
66
75
|
onDark: boolean;
|
|
76
|
+
touched: boolean;
|
|
67
77
|
/**
|
|
68
78
|
* @private
|
|
69
79
|
*/
|
|
@@ -108,6 +108,7 @@ class AuroRadio extends LitElement {
|
|
|
108
108
|
this.error = false;
|
|
109
109
|
this.onDark = false;
|
|
110
110
|
this.tabIndex = -1;
|
|
111
|
+
this.touched = false;
|
|
111
112
|
|
|
112
113
|
/**
|
|
113
114
|
* @private
|
|
@@ -153,6 +154,16 @@ class AuroRadio extends LitElement {
|
|
|
153
154
|
tabIndex: {
|
|
154
155
|
type: Number,
|
|
155
156
|
reflect: true
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Whether or not the radio button has been touched by the user.
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
touched: {
|
|
164
|
+
type: Boolean,
|
|
165
|
+
reflect: true,
|
|
166
|
+
attribute: false
|
|
156
167
|
}
|
|
157
168
|
};
|
|
158
169
|
}
|
|
@@ -204,6 +215,7 @@ class AuroRadio extends LitElement {
|
|
|
204
215
|
* @returns {void}
|
|
205
216
|
*/
|
|
206
217
|
handleFocus(event) {
|
|
218
|
+
this.touched = true;
|
|
207
219
|
this.dispatchEvent(new CustomEvent('focusSelected', {
|
|
208
220
|
bubbles: true,
|
|
209
221
|
composed: true,
|
|
@@ -230,6 +242,7 @@ class AuroRadio extends LitElement {
|
|
|
230
242
|
* @returns {void}
|
|
231
243
|
*/
|
|
232
244
|
reset() {
|
|
245
|
+
this.touched = false;
|
|
233
246
|
this.checked = false;
|
|
234
247
|
this.error = false;
|
|
235
248
|
}
|
|
@@ -760,6 +773,7 @@ class AuroFormValidation {
|
|
|
760
773
|
reset(elem) {
|
|
761
774
|
elem.validity = undefined;
|
|
762
775
|
elem.value = undefined;
|
|
776
|
+
elem.touched = false;
|
|
763
777
|
|
|
764
778
|
// Resets the second value of the datepicker in range state
|
|
765
779
|
if (elem.valueEnd) {
|
|
@@ -897,7 +911,7 @@ class AuroFormValidation {
|
|
|
897
911
|
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
898
912
|
|
|
899
913
|
// Guard Clause: if the value is too short
|
|
900
|
-
if (elem.value
|
|
914
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
901
915
|
|
|
902
916
|
elem.validity = 'tooShort';
|
|
903
917
|
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
@@ -967,11 +981,17 @@ class AuroFormValidation {
|
|
|
967
981
|
this.getAuroInputs(elem);
|
|
968
982
|
|
|
969
983
|
// Validate only if noValidate is not true and the input does not have focus
|
|
970
|
-
|
|
984
|
+
let validationShouldRun =
|
|
985
|
+
force ||
|
|
986
|
+
(!elem.contains(document.activeElement) &&
|
|
987
|
+
(elem.touched ||
|
|
988
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
989
|
+
elem.validateOnInput;
|
|
971
990
|
|
|
972
991
|
if (elem.hasAttribute('error')) {
|
|
973
992
|
elem.validity = 'customError';
|
|
974
993
|
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
994
|
+
validationShouldRun = false;
|
|
975
995
|
} else if (validationShouldRun) {
|
|
976
996
|
elem.validity = 'valid';
|
|
977
997
|
elem.errorMessage = '';
|
|
@@ -992,7 +1012,7 @@ class AuroFormValidation {
|
|
|
992
1012
|
}
|
|
993
1013
|
}
|
|
994
1014
|
|
|
995
|
-
if (!hasValue && elem.required) {
|
|
1015
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
996
1016
|
elem.validity = 'valueMissing';
|
|
997
1017
|
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
998
1018
|
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
@@ -1003,7 +1023,7 @@ class AuroFormValidation {
|
|
|
1003
1023
|
}
|
|
1004
1024
|
}
|
|
1005
1025
|
|
|
1006
|
-
if (this.auroInputElements?.length > 0) {
|
|
1026
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
1007
1027
|
elem.validity = this.auroInputElements[0].validity;
|
|
1008
1028
|
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
1009
1029
|
|
|
@@ -1082,7 +1102,7 @@ class AuroFormValidation {
|
|
|
1082
1102
|
}
|
|
1083
1103
|
}
|
|
1084
1104
|
} else {
|
|
1085
|
-
elem.errorMessage =
|
|
1105
|
+
elem.errorMessage = '';
|
|
1086
1106
|
}
|
|
1087
1107
|
}
|
|
1088
1108
|
}
|
|
@@ -1371,6 +1391,7 @@ class AuroRadioGroup extends LitElement {
|
|
|
1371
1391
|
this.value = undefined;
|
|
1372
1392
|
this.optionSelected = undefined;
|
|
1373
1393
|
this.onDark = false;
|
|
1394
|
+
this.touched = false;
|
|
1374
1395
|
|
|
1375
1396
|
/**
|
|
1376
1397
|
* @private
|
|
@@ -1452,6 +1473,18 @@ class AuroRadioGroup extends LitElement {
|
|
|
1452
1473
|
},
|
|
1453
1474
|
optionSelected: {
|
|
1454
1475
|
type: Object
|
|
1476
|
+
},
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* Indicates whether the radio group is in a dirty state (has been interacted with).
|
|
1480
|
+
* @type {boolean}
|
|
1481
|
+
* @default false
|
|
1482
|
+
* @private
|
|
1483
|
+
*/
|
|
1484
|
+
touched: {
|
|
1485
|
+
type: Boolean,
|
|
1486
|
+
reflect: true,
|
|
1487
|
+
attribute: false
|
|
1455
1488
|
}
|
|
1456
1489
|
};
|
|
1457
1490
|
}
|
|
@@ -1507,10 +1540,7 @@ class AuroRadioGroup extends LitElement {
|
|
|
1507
1540
|
* @returns {void}
|
|
1508
1541
|
*/
|
|
1509
1542
|
handleRadioBlur() {
|
|
1510
|
-
|
|
1511
|
-
this.value = '';
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1543
|
+
this.touched = true;
|
|
1514
1544
|
this.validation.validate(this);
|
|
1515
1545
|
}
|
|
1516
1546
|
|
|
@@ -108,6 +108,7 @@ class AuroRadio extends LitElement {
|
|
|
108
108
|
this.error = false;
|
|
109
109
|
this.onDark = false;
|
|
110
110
|
this.tabIndex = -1;
|
|
111
|
+
this.touched = false;
|
|
111
112
|
|
|
112
113
|
/**
|
|
113
114
|
* @private
|
|
@@ -153,6 +154,16 @@ class AuroRadio extends LitElement {
|
|
|
153
154
|
tabIndex: {
|
|
154
155
|
type: Number,
|
|
155
156
|
reflect: true
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Whether or not the radio button has been touched by the user.
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
touched: {
|
|
164
|
+
type: Boolean,
|
|
165
|
+
reflect: true,
|
|
166
|
+
attribute: false
|
|
156
167
|
}
|
|
157
168
|
};
|
|
158
169
|
}
|
|
@@ -204,6 +215,7 @@ class AuroRadio extends LitElement {
|
|
|
204
215
|
* @returns {void}
|
|
205
216
|
*/
|
|
206
217
|
handleFocus(event) {
|
|
218
|
+
this.touched = true;
|
|
207
219
|
this.dispatchEvent(new CustomEvent('focusSelected', {
|
|
208
220
|
bubbles: true,
|
|
209
221
|
composed: true,
|
|
@@ -230,6 +242,7 @@ class AuroRadio extends LitElement {
|
|
|
230
242
|
* @returns {void}
|
|
231
243
|
*/
|
|
232
244
|
reset() {
|
|
245
|
+
this.touched = false;
|
|
233
246
|
this.checked = false;
|
|
234
247
|
this.error = false;
|
|
235
248
|
}
|
|
@@ -760,6 +773,7 @@ class AuroFormValidation {
|
|
|
760
773
|
reset(elem) {
|
|
761
774
|
elem.validity = undefined;
|
|
762
775
|
elem.value = undefined;
|
|
776
|
+
elem.touched = false;
|
|
763
777
|
|
|
764
778
|
// Resets the second value of the datepicker in range state
|
|
765
779
|
if (elem.valueEnd) {
|
|
@@ -897,7 +911,7 @@ class AuroFormValidation {
|
|
|
897
911
|
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
898
912
|
|
|
899
913
|
// Guard Clause: if the value is too short
|
|
900
|
-
if (elem.value
|
|
914
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
901
915
|
|
|
902
916
|
elem.validity = 'tooShort';
|
|
903
917
|
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
@@ -967,11 +981,17 @@ class AuroFormValidation {
|
|
|
967
981
|
this.getAuroInputs(elem);
|
|
968
982
|
|
|
969
983
|
// Validate only if noValidate is not true and the input does not have focus
|
|
970
|
-
|
|
984
|
+
let validationShouldRun =
|
|
985
|
+
force ||
|
|
986
|
+
(!elem.contains(document.activeElement) &&
|
|
987
|
+
(elem.touched ||
|
|
988
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
989
|
+
elem.validateOnInput;
|
|
971
990
|
|
|
972
991
|
if (elem.hasAttribute('error')) {
|
|
973
992
|
elem.validity = 'customError';
|
|
974
993
|
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
994
|
+
validationShouldRun = false;
|
|
975
995
|
} else if (validationShouldRun) {
|
|
976
996
|
elem.validity = 'valid';
|
|
977
997
|
elem.errorMessage = '';
|
|
@@ -992,7 +1012,7 @@ class AuroFormValidation {
|
|
|
992
1012
|
}
|
|
993
1013
|
}
|
|
994
1014
|
|
|
995
|
-
if (!hasValue && elem.required) {
|
|
1015
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
996
1016
|
elem.validity = 'valueMissing';
|
|
997
1017
|
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
998
1018
|
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
@@ -1003,7 +1023,7 @@ class AuroFormValidation {
|
|
|
1003
1023
|
}
|
|
1004
1024
|
}
|
|
1005
1025
|
|
|
1006
|
-
if (this.auroInputElements?.length > 0) {
|
|
1026
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
1007
1027
|
elem.validity = this.auroInputElements[0].validity;
|
|
1008
1028
|
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
1009
1029
|
|
|
@@ -1082,7 +1102,7 @@ class AuroFormValidation {
|
|
|
1082
1102
|
}
|
|
1083
1103
|
}
|
|
1084
1104
|
} else {
|
|
1085
|
-
elem.errorMessage =
|
|
1105
|
+
elem.errorMessage = '';
|
|
1086
1106
|
}
|
|
1087
1107
|
}
|
|
1088
1108
|
}
|
|
@@ -1371,6 +1391,7 @@ class AuroRadioGroup extends LitElement {
|
|
|
1371
1391
|
this.value = undefined;
|
|
1372
1392
|
this.optionSelected = undefined;
|
|
1373
1393
|
this.onDark = false;
|
|
1394
|
+
this.touched = false;
|
|
1374
1395
|
|
|
1375
1396
|
/**
|
|
1376
1397
|
* @private
|
|
@@ -1452,6 +1473,18 @@ class AuroRadioGroup extends LitElement {
|
|
|
1452
1473
|
},
|
|
1453
1474
|
optionSelected: {
|
|
1454
1475
|
type: Object
|
|
1476
|
+
},
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* Indicates whether the radio group is in a dirty state (has been interacted with).
|
|
1480
|
+
* @type {boolean}
|
|
1481
|
+
* @default false
|
|
1482
|
+
* @private
|
|
1483
|
+
*/
|
|
1484
|
+
touched: {
|
|
1485
|
+
type: Boolean,
|
|
1486
|
+
reflect: true,
|
|
1487
|
+
attribute: false
|
|
1455
1488
|
}
|
|
1456
1489
|
};
|
|
1457
1490
|
}
|
|
@@ -1507,10 +1540,7 @@ class AuroRadioGroup extends LitElement {
|
|
|
1507
1540
|
* @returns {void}
|
|
1508
1541
|
*/
|
|
1509
1542
|
handleRadioBlur() {
|
|
1510
|
-
|
|
1511
|
-
this.value = '';
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1543
|
+
this.touched = true;
|
|
1514
1544
|
this.validation.validate(this);
|
|
1515
1545
|
}
|
|
1516
1546
|
|
|
@@ -111,7 +111,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
|
|
|
111
111
|
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
|
|
112
112
|
|
|
113
113
|
```html
|
|
114
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.
|
|
114
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.3.0/auro-select/+esm"></script>
|
|
115
115
|
```
|
|
116
116
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
117
117
|
|