@aurodesignsystem/auro-formkit 3.3.0-beta.2 → 3.3.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/components/checkbox/README.md +1 -1
  3. package/components/checkbox/demo/api.md +1 -0
  4. package/components/checkbox/demo/api.min.js +34 -5
  5. package/components/checkbox/demo/index.min.js +34 -5
  6. package/components/checkbox/demo/readme.md +1 -1
  7. package/components/checkbox/dist/auro-checkbox-group.d.ts +7 -0
  8. package/components/checkbox/dist/auro-checkbox.d.ts +6 -0
  9. package/components/checkbox/dist/index.js +34 -5
  10. package/components/checkbox/dist/registered.js +34 -5
  11. package/components/combobox/README.md +1 -1
  12. package/components/combobox/demo/api.min.js +77 -57
  13. package/components/combobox/demo/index.min.js +77 -57
  14. package/components/combobox/demo/readme.md +1 -1
  15. package/components/combobox/dist/auro-combobox.d.ts +2 -10
  16. package/components/combobox/dist/index.js +77 -57
  17. package/components/combobox/dist/registered.js +77 -57
  18. package/components/counter/README.md +1 -1
  19. package/components/counter/demo/api.min.js +12 -5
  20. package/components/counter/demo/index.min.js +12 -5
  21. package/components/counter/demo/readme.md +1 -1
  22. package/components/counter/dist/index.js +12 -5
  23. package/components/counter/dist/registered.js +12 -5
  24. package/components/datepicker/README.md +1 -1
  25. package/components/datepicker/demo/api.min.js +54 -34
  26. package/components/datepicker/demo/index.min.js +54 -34
  27. package/components/datepicker/demo/readme.md +1 -1
  28. package/components/datepicker/dist/auro-datepicker.d.ts +8 -0
  29. package/components/datepicker/dist/index.js +54 -34
  30. package/components/datepicker/dist/registered.js +54 -34
  31. package/components/dropdown/README.md +1 -1
  32. package/components/dropdown/demo/readme.md +1 -1
  33. package/components/form/README.md +1 -1
  34. package/components/form/demo/readme.md +1 -1
  35. package/components/input/README.md +1 -1
  36. package/components/input/demo/api.min.js +26 -14
  37. package/components/input/demo/index.min.js +26 -14
  38. package/components/input/demo/readme.md +1 -1
  39. package/components/input/dist/base-input.d.ts +8 -0
  40. package/components/input/dist/index.js +26 -14
  41. package/components/input/dist/registered.js +26 -14
  42. package/components/menu/README.md +1 -1
  43. package/components/menu/demo/readme.md +1 -1
  44. package/components/radio/README.md +1 -1
  45. package/components/radio/demo/api.md +1 -0
  46. package/components/radio/demo/api.min.js +33 -9
  47. package/components/radio/demo/index.min.js +33 -9
  48. package/components/radio/demo/readme.md +1 -1
  49. package/components/radio/dist/auro-radio-group.d.ts +8 -0
  50. package/components/radio/dist/auro-radio.d.ts +5 -0
  51. package/components/radio/dist/index.js +33 -9
  52. package/components/radio/dist/registered.js +33 -9
  53. package/components/select/README.md +1 -1
  54. package/components/select/demo/api.min.js +25 -15
  55. package/components/select/demo/index.min.js +25 -15
  56. package/components/select/demo/readme.md +1 -1
  57. package/components/select/dist/auro-select.d.ts +8 -0
  58. package/components/select/dist/index.js +25 -15
  59. package/components/select/dist/registered.js +25 -15
  60. package/package.json +1 -1
@@ -4470,6 +4470,7 @@ class AuroFormValidation {
4470
4470
  reset(elem) {
4471
4471
  elem.validity = undefined;
4472
4472
  elem.value = undefined;
4473
+ elem.touched = false;
4473
4474
 
4474
4475
  // Resets the second value of the datepicker in range state
4475
4476
  if (elem.valueEnd) {
@@ -4607,7 +4608,7 @@ class AuroFormValidation {
4607
4608
  } else if (elem.type === 'date' && elem.value?.length > 0) {
4608
4609
 
4609
4610
  // Guard Clause: if the value is too short
4610
- if (elem.value.length < elem.lengthForType) {
4611
+ if (elem.value?.length < elem.lengthForType) {
4611
4612
 
4612
4613
  elem.validity = 'tooShort';
4613
4614
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -4677,11 +4678,17 @@ class AuroFormValidation {
4677
4678
  this.getAuroInputs(elem);
4678
4679
 
4679
4680
  // Validate only if noValidate is not true and the input does not have focus
4680
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
4681
+ let validationShouldRun =
4682
+ force ||
4683
+ (!elem.contains(document.activeElement) &&
4684
+ (elem.touched ||
4685
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
4686
+ elem.validateOnInput;
4681
4687
 
4682
4688
  if (elem.hasAttribute('error')) {
4683
4689
  elem.validity = 'customError';
4684
4690
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
4691
+ validationShouldRun = false;
4685
4692
  } else if (validationShouldRun) {
4686
4693
  elem.validity = 'valid';
4687
4694
  elem.errorMessage = '';
@@ -4702,7 +4709,7 @@ class AuroFormValidation {
4702
4709
  }
4703
4710
  }
4704
4711
 
4705
- if (!hasValue && elem.required) {
4712
+ if (!hasValue && elem.required && elem.touched) {
4706
4713
  elem.validity = 'valueMissing';
4707
4714
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
4708
4715
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -4713,7 +4720,7 @@ class AuroFormValidation {
4713
4720
  }
4714
4721
  }
4715
4722
 
4716
- if (this.auroInputElements?.length > 0) {
4723
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
4717
4724
  elem.validity = this.auroInputElements[0].validity;
4718
4725
  elem.errorMessage = this.auroInputElements[0].errorMessage;
4719
4726
 
@@ -4792,7 +4799,7 @@ class AuroFormValidation {
4792
4799
  }
4793
4800
  }
4794
4801
  } else {
4795
- elem.errorMessage = undefined;
4802
+ elem.errorMessage = '';
4796
4803
  }
4797
4804
  }
4798
4805
  }
@@ -4843,6 +4850,7 @@ class BaseInput extends LitElement {
4843
4850
  * @returns {void}
4844
4851
  */
4845
4852
  privateDefaults() {
4853
+ this.touched = false;
4846
4854
  this.util = new AuroInputUtilities();
4847
4855
  this.validation = new AuroFormValidation();
4848
4856
  this.inputIconName = undefined;
@@ -5204,6 +5212,18 @@ class BaseInput extends LitElement {
5204
5212
  validity: {
5205
5213
  type: String,
5206
5214
  reflect: true
5215
+ },
5216
+
5217
+ /**
5218
+ * Indicates whether the input is in a dirty state (has been interacted with).
5219
+ * @type {boolean}
5220
+ * @default false
5221
+ * @private
5222
+ */
5223
+ touched: {
5224
+ type: Boolean,
5225
+ reflect: true,
5226
+ attribute: false
5207
5227
  }
5208
5228
  };
5209
5229
  }
@@ -5490,15 +5510,7 @@ class BaseInput extends LitElement {
5490
5510
  */
5491
5511
  handleFocusin() {
5492
5512
 
5493
- /**
5494
- * The input is considered to be in it's initial state based on
5495
- * if this.value === undefined. The first time we interact with the
5496
- * input manually, by applying focusin, we need to flag the
5497
- * input as no longer in the initial state.
5498
- */
5499
- if (this.value === undefined) {
5500
- this.value = '';
5501
- }
5513
+ this.touched = true;
5502
5514
  }
5503
5515
 
5504
5516
  /**
@@ -110,7 +110,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
110
110
  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.
111
111
 
112
112
  ```html
113
- <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.2.8/auro-menu/+esm"></script>
113
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.3.0-beta.2/auro-menu/+esm"></script>
114
114
  ```
115
115
  <!-- AURO-GENERATED-CONTENT:END -->
116
116
 
@@ -110,7 +110,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
110
110
  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.
111
111
 
112
112
  ```html
113
- <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.2.8/auro-menu/+esm"></script>
113
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.3.0-beta.2/auro-menu/+esm"></script>
114
114
  ```
115
115
  <!-- AURO-GENERATED-CONTENT:END -->
116
116
 
@@ -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.2.8/auro-radio/+esm"></script>
103
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.3.0-beta.2/auro-radio/+esm"></script>
104
104
  ```
105
105
  <!-- AURO-GENERATED-CONTENT:END -->
106
106
 
@@ -63,6 +63,7 @@
63
63
  | [onDark](#onDark) | `onDark` | `Boolean` | false | If set to true, the component will render with a dark theme. |
64
64
  | [required](#required) | `required` | `Boolean` | false | Defines element as required. |
65
65
  | [tabIndex](#tabIndex) | `tabIndex` | `number` | -1 | |
66
+ | [touched](#touched) | `touched` | `boolean` | false | |
66
67
  | [value](#value) | `value` | `string` | | |
67
68
 
68
69
  ## Methods
@@ -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,10 @@ class AuroRadio extends i$2 {
218
219
  tabIndex: {
219
220
  type: Number,
220
221
  reflect: true
222
+ },
223
+ touched: {
224
+ type: Boolean,
225
+ reflect: true
221
226
  }
222
227
  };
223
228
  }
@@ -269,6 +274,7 @@ class AuroRadio extends i$2 {
269
274
  * @returns {void}
270
275
  */
271
276
  handleFocus(event) {
277
+ this.touched = true;
272
278
  this.dispatchEvent(new CustomEvent('focusSelected', {
273
279
  bubbles: true,
274
280
  composed: true,
@@ -295,6 +301,7 @@ class AuroRadio extends i$2 {
295
301
  * @returns {void}
296
302
  */
297
303
  reset() {
304
+ this.touched = false;
298
305
  this.checked = false;
299
306
  this.error = false;
300
307
  }
@@ -832,6 +839,7 @@ class AuroFormValidation {
832
839
  reset(elem) {
833
840
  elem.validity = undefined;
834
841
  elem.value = undefined;
842
+ elem.touched = false;
835
843
 
836
844
  // Resets the second value of the datepicker in range state
837
845
  if (elem.valueEnd) {
@@ -969,7 +977,7 @@ class AuroFormValidation {
969
977
  } else if (elem.type === 'date' && elem.value?.length > 0) {
970
978
 
971
979
  // Guard Clause: if the value is too short
972
- if (elem.value.length < elem.lengthForType) {
980
+ if (elem.value?.length < elem.lengthForType) {
973
981
 
974
982
  elem.validity = 'tooShort';
975
983
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -1039,11 +1047,17 @@ class AuroFormValidation {
1039
1047
  this.getAuroInputs(elem);
1040
1048
 
1041
1049
  // Validate only if noValidate is not true and the input does not have focus
1042
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
1050
+ let validationShouldRun =
1051
+ force ||
1052
+ (!elem.contains(document.activeElement) &&
1053
+ (elem.touched ||
1054
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
1055
+ elem.validateOnInput;
1043
1056
 
1044
1057
  if (elem.hasAttribute('error')) {
1045
1058
  elem.validity = 'customError';
1046
1059
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
1060
+ validationShouldRun = false;
1047
1061
  } else if (validationShouldRun) {
1048
1062
  elem.validity = 'valid';
1049
1063
  elem.errorMessage = '';
@@ -1064,7 +1078,7 @@ class AuroFormValidation {
1064
1078
  }
1065
1079
  }
1066
1080
 
1067
- if (!hasValue && elem.required) {
1081
+ if (!hasValue && elem.required && elem.touched) {
1068
1082
  elem.validity = 'valueMissing';
1069
1083
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
1070
1084
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -1075,7 +1089,7 @@ class AuroFormValidation {
1075
1089
  }
1076
1090
  }
1077
1091
 
1078
- if (this.auroInputElements?.length > 0) {
1092
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
1079
1093
  elem.validity = this.auroInputElements[0].validity;
1080
1094
  elem.errorMessage = this.auroInputElements[0].errorMessage;
1081
1095
 
@@ -1154,7 +1168,7 @@ class AuroFormValidation {
1154
1168
  }
1155
1169
  }
1156
1170
  } else {
1157
- elem.errorMessage = undefined;
1171
+ elem.errorMessage = '';
1158
1172
  }
1159
1173
  }
1160
1174
  }
@@ -1443,6 +1457,7 @@ class AuroRadioGroup extends i$2 {
1443
1457
  this.value = undefined;
1444
1458
  this.optionSelected = undefined;
1445
1459
  this.onDark = false;
1460
+ this.touched = false;
1446
1461
 
1447
1462
  /**
1448
1463
  * @private
@@ -1524,6 +1539,18 @@ class AuroRadioGroup extends i$2 {
1524
1539
  },
1525
1540
  optionSelected: {
1526
1541
  type: Object
1542
+ },
1543
+
1544
+ /**
1545
+ * Indicates whether the radio group is in a dirty state (has been interacted with).
1546
+ * @type {boolean}
1547
+ * @default false
1548
+ * @private
1549
+ */
1550
+ touched: {
1551
+ type: Boolean,
1552
+ reflect: true,
1553
+ attribute: false
1527
1554
  }
1528
1555
  };
1529
1556
  }
@@ -1579,10 +1606,7 @@ class AuroRadioGroup extends i$2 {
1579
1606
  * @returns {void}
1580
1607
  */
1581
1608
  handleRadioBlur() {
1582
- if (this.value === undefined) {
1583
- this.value = '';
1584
- }
1585
-
1609
+ this.touched = true;
1586
1610
  this.validation.validate(this);
1587
1611
  }
1588
1612
 
@@ -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,10 @@ class AuroRadio extends i$2 {
193
194
  tabIndex: {
194
195
  type: Number,
195
196
  reflect: true
197
+ },
198
+ touched: {
199
+ type: Boolean,
200
+ reflect: true
196
201
  }
197
202
  };
198
203
  }
@@ -244,6 +249,7 @@ class AuroRadio extends i$2 {
244
249
  * @returns {void}
245
250
  */
246
251
  handleFocus(event) {
252
+ this.touched = true;
247
253
  this.dispatchEvent(new CustomEvent('focusSelected', {
248
254
  bubbles: true,
249
255
  composed: true,
@@ -270,6 +276,7 @@ class AuroRadio extends i$2 {
270
276
  * @returns {void}
271
277
  */
272
278
  reset() {
279
+ this.touched = false;
273
280
  this.checked = false;
274
281
  this.error = false;
275
282
  }
@@ -807,6 +814,7 @@ class AuroFormValidation {
807
814
  reset(elem) {
808
815
  elem.validity = undefined;
809
816
  elem.value = undefined;
817
+ elem.touched = false;
810
818
 
811
819
  // Resets the second value of the datepicker in range state
812
820
  if (elem.valueEnd) {
@@ -944,7 +952,7 @@ class AuroFormValidation {
944
952
  } else if (elem.type === 'date' && elem.value?.length > 0) {
945
953
 
946
954
  // Guard Clause: if the value is too short
947
- if (elem.value.length < elem.lengthForType) {
955
+ if (elem.value?.length < elem.lengthForType) {
948
956
 
949
957
  elem.validity = 'tooShort';
950
958
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -1014,11 +1022,17 @@ class AuroFormValidation {
1014
1022
  this.getAuroInputs(elem);
1015
1023
 
1016
1024
  // Validate only if noValidate is not true and the input does not have focus
1017
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
1025
+ let validationShouldRun =
1026
+ force ||
1027
+ (!elem.contains(document.activeElement) &&
1028
+ (elem.touched ||
1029
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
1030
+ elem.validateOnInput;
1018
1031
 
1019
1032
  if (elem.hasAttribute('error')) {
1020
1033
  elem.validity = 'customError';
1021
1034
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
1035
+ validationShouldRun = false;
1022
1036
  } else if (validationShouldRun) {
1023
1037
  elem.validity = 'valid';
1024
1038
  elem.errorMessage = '';
@@ -1039,7 +1053,7 @@ class AuroFormValidation {
1039
1053
  }
1040
1054
  }
1041
1055
 
1042
- if (!hasValue && elem.required) {
1056
+ if (!hasValue && elem.required && elem.touched) {
1043
1057
  elem.validity = 'valueMissing';
1044
1058
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
1045
1059
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -1050,7 +1064,7 @@ class AuroFormValidation {
1050
1064
  }
1051
1065
  }
1052
1066
 
1053
- if (this.auroInputElements?.length > 0) {
1067
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
1054
1068
  elem.validity = this.auroInputElements[0].validity;
1055
1069
  elem.errorMessage = this.auroInputElements[0].errorMessage;
1056
1070
 
@@ -1129,7 +1143,7 @@ class AuroFormValidation {
1129
1143
  }
1130
1144
  }
1131
1145
  } else {
1132
- elem.errorMessage = undefined;
1146
+ elem.errorMessage = '';
1133
1147
  }
1134
1148
  }
1135
1149
  }
@@ -1418,6 +1432,7 @@ class AuroRadioGroup extends i$2 {
1418
1432
  this.value = undefined;
1419
1433
  this.optionSelected = undefined;
1420
1434
  this.onDark = false;
1435
+ this.touched = false;
1421
1436
 
1422
1437
  /**
1423
1438
  * @private
@@ -1499,6 +1514,18 @@ class AuroRadioGroup extends i$2 {
1499
1514
  },
1500
1515
  optionSelected: {
1501
1516
  type: Object
1517
+ },
1518
+
1519
+ /**
1520
+ * Indicates whether the radio group is in a dirty state (has been interacted with).
1521
+ * @type {boolean}
1522
+ * @default false
1523
+ * @private
1524
+ */
1525
+ touched: {
1526
+ type: Boolean,
1527
+ reflect: true,
1528
+ attribute: false
1502
1529
  }
1503
1530
  };
1504
1531
  }
@@ -1554,10 +1581,7 @@ class AuroRadioGroup extends i$2 {
1554
1581
  * @returns {void}
1555
1582
  */
1556
1583
  handleRadioBlur() {
1557
- if (this.value === undefined) {
1558
- this.value = '';
1559
- }
1560
-
1584
+ this.touched = true;
1561
1585
  this.validation.validate(this);
1562
1586
  }
1563
1587
 
@@ -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.2.8/auro-radio/+esm"></script>
103
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.3.0-beta.2/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,10 @@ export class AuroRadio extends LitElement {
49
49
  type: NumberConstructor;
50
50
  reflect: boolean;
51
51
  };
52
+ touched: {
53
+ type: BooleanConstructor;
54
+ reflect: boolean;
55
+ };
52
56
  };
53
57
  /**
54
58
  * This will register this element with the browser.
@@ -64,6 +68,7 @@ export class AuroRadio extends LitElement {
64
68
  required: boolean;
65
69
  error: boolean;
66
70
  onDark: boolean;
71
+ touched: boolean;
67
72
  /**
68
73
  * @private
69
74
  */
@@ -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,10 @@ class AuroRadio extends LitElement {
153
154
  tabIndex: {
154
155
  type: Number,
155
156
  reflect: true
157
+ },
158
+ touched: {
159
+ type: Boolean,
160
+ reflect: true
156
161
  }
157
162
  };
158
163
  }
@@ -204,6 +209,7 @@ class AuroRadio extends LitElement {
204
209
  * @returns {void}
205
210
  */
206
211
  handleFocus(event) {
212
+ this.touched = true;
207
213
  this.dispatchEvent(new CustomEvent('focusSelected', {
208
214
  bubbles: true,
209
215
  composed: true,
@@ -230,6 +236,7 @@ class AuroRadio extends LitElement {
230
236
  * @returns {void}
231
237
  */
232
238
  reset() {
239
+ this.touched = false;
233
240
  this.checked = false;
234
241
  this.error = false;
235
242
  }
@@ -760,6 +767,7 @@ class AuroFormValidation {
760
767
  reset(elem) {
761
768
  elem.validity = undefined;
762
769
  elem.value = undefined;
770
+ elem.touched = false;
763
771
 
764
772
  // Resets the second value of the datepicker in range state
765
773
  if (elem.valueEnd) {
@@ -897,7 +905,7 @@ class AuroFormValidation {
897
905
  } else if (elem.type === 'date' && elem.value?.length > 0) {
898
906
 
899
907
  // Guard Clause: if the value is too short
900
- if (elem.value.length < elem.lengthForType) {
908
+ if (elem.value?.length < elem.lengthForType) {
901
909
 
902
910
  elem.validity = 'tooShort';
903
911
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -967,11 +975,17 @@ class AuroFormValidation {
967
975
  this.getAuroInputs(elem);
968
976
 
969
977
  // Validate only if noValidate is not true and the input does not have focus
970
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
978
+ let validationShouldRun =
979
+ force ||
980
+ (!elem.contains(document.activeElement) &&
981
+ (elem.touched ||
982
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
983
+ elem.validateOnInput;
971
984
 
972
985
  if (elem.hasAttribute('error')) {
973
986
  elem.validity = 'customError';
974
987
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
988
+ validationShouldRun = false;
975
989
  } else if (validationShouldRun) {
976
990
  elem.validity = 'valid';
977
991
  elem.errorMessage = '';
@@ -992,7 +1006,7 @@ class AuroFormValidation {
992
1006
  }
993
1007
  }
994
1008
 
995
- if (!hasValue && elem.required) {
1009
+ if (!hasValue && elem.required && elem.touched) {
996
1010
  elem.validity = 'valueMissing';
997
1011
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
998
1012
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -1003,7 +1017,7 @@ class AuroFormValidation {
1003
1017
  }
1004
1018
  }
1005
1019
 
1006
- if (this.auroInputElements?.length > 0) {
1020
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
1007
1021
  elem.validity = this.auroInputElements[0].validity;
1008
1022
  elem.errorMessage = this.auroInputElements[0].errorMessage;
1009
1023
 
@@ -1082,7 +1096,7 @@ class AuroFormValidation {
1082
1096
  }
1083
1097
  }
1084
1098
  } else {
1085
- elem.errorMessage = undefined;
1099
+ elem.errorMessage = '';
1086
1100
  }
1087
1101
  }
1088
1102
  }
@@ -1371,6 +1385,7 @@ class AuroRadioGroup extends LitElement {
1371
1385
  this.value = undefined;
1372
1386
  this.optionSelected = undefined;
1373
1387
  this.onDark = false;
1388
+ this.touched = false;
1374
1389
 
1375
1390
  /**
1376
1391
  * @private
@@ -1452,6 +1467,18 @@ class AuroRadioGroup extends LitElement {
1452
1467
  },
1453
1468
  optionSelected: {
1454
1469
  type: Object
1470
+ },
1471
+
1472
+ /**
1473
+ * Indicates whether the radio group is in a dirty state (has been interacted with).
1474
+ * @type {boolean}
1475
+ * @default false
1476
+ * @private
1477
+ */
1478
+ touched: {
1479
+ type: Boolean,
1480
+ reflect: true,
1481
+ attribute: false
1455
1482
  }
1456
1483
  };
1457
1484
  }
@@ -1507,10 +1534,7 @@ class AuroRadioGroup extends LitElement {
1507
1534
  * @returns {void}
1508
1535
  */
1509
1536
  handleRadioBlur() {
1510
- if (this.value === undefined) {
1511
- this.value = '';
1512
- }
1513
-
1537
+ this.touched = true;
1514
1538
  this.validation.validate(this);
1515
1539
  }
1516
1540