@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.
Files changed (61) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/components/checkbox/README.md +1 -1
  3. package/components/checkbox/demo/api.min.js +36 -5
  4. package/components/checkbox/demo/index.min.js +36 -5
  5. package/components/checkbox/demo/readme.md +1 -1
  6. package/components/checkbox/dist/auro-checkbox-group.d.ts +7 -0
  7. package/components/checkbox/dist/auro-checkbox.d.ts +7 -0
  8. package/components/checkbox/dist/index.js +36 -5
  9. package/components/checkbox/dist/registered.js +36 -5
  10. package/components/combobox/README.md +1 -1
  11. package/components/combobox/demo/api.md +44 -0
  12. package/components/combobox/demo/api.min.js +95 -60
  13. package/components/combobox/demo/index.min.js +95 -60
  14. package/components/combobox/demo/readme.md +1 -1
  15. package/components/combobox/dist/auro-combobox.d.ts +8 -10
  16. package/components/combobox/dist/index.js +95 -60
  17. package/components/combobox/dist/registered.js +95 -60
  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.md +30 -0
  26. package/components/datepicker/demo/api.min.js +72 -37
  27. package/components/datepicker/demo/index.min.js +72 -37
  28. package/components/datepicker/demo/readme.md +1 -1
  29. package/components/datepicker/dist/auro-datepicker.d.ts +14 -0
  30. package/components/datepicker/dist/index.js +72 -37
  31. package/components/datepicker/dist/registered.js +72 -37
  32. package/components/dropdown/README.md +1 -1
  33. package/components/dropdown/demo/readme.md +1 -1
  34. package/components/form/README.md +1 -1
  35. package/components/form/demo/readme.md +1 -1
  36. package/components/input/README.md +1 -1
  37. package/components/input/demo/api.md +24 -0
  38. package/components/input/demo/api.min.js +36 -17
  39. package/components/input/demo/index.min.js +36 -17
  40. package/components/input/demo/readme.md +1 -1
  41. package/components/input/dist/base-input.d.ts +15 -0
  42. package/components/input/dist/index.js +36 -17
  43. package/components/input/dist/registered.js +36 -17
  44. package/components/menu/README.md +1 -1
  45. package/components/menu/demo/readme.md +1 -1
  46. package/components/radio/README.md +1 -1
  47. package/components/radio/demo/api.min.js +39 -9
  48. package/components/radio/demo/index.min.js +39 -9
  49. package/components/radio/demo/readme.md +1 -1
  50. package/components/radio/dist/auro-radio-group.d.ts +8 -0
  51. package/components/radio/dist/auro-radio.d.ts +10 -0
  52. package/components/radio/dist/index.js +39 -9
  53. package/components/radio/dist/registered.js +39 -9
  54. package/components/select/README.md +1 -1
  55. package/components/select/demo/api.min.js +25 -15
  56. package/components/select/demo/index.min.js +25 -15
  57. package/components/select/demo/readme.md +1 -1
  58. package/components/select/dist/auro-select.d.ts +8 -0
  59. package/components/select/dist/index.js +25 -15
  60. package/components/select/dist/registered.js +25 -15
  61. package/package.json +1 -1
@@ -633,6 +633,7 @@ class AuroFormValidation {
633
633
  reset(elem) {
634
634
  elem.validity = undefined;
635
635
  elem.value = undefined;
636
+ elem.touched = false;
636
637
 
637
638
  // Resets the second value of the datepicker in range state
638
639
  if (elem.valueEnd) {
@@ -770,7 +771,7 @@ class AuroFormValidation {
770
771
  } else if (elem.type === 'date' && elem.value?.length > 0) {
771
772
 
772
773
  // Guard Clause: if the value is too short
773
- if (elem.value.length < elem.lengthForType) {
774
+ if (elem.value?.length < elem.lengthForType) {
774
775
 
775
776
  elem.validity = 'tooShort';
776
777
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -840,11 +841,17 @@ class AuroFormValidation {
840
841
  this.getAuroInputs(elem);
841
842
 
842
843
  // Validate only if noValidate is not true and the input does not have focus
843
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
844
+ let validationShouldRun =
845
+ force ||
846
+ (!elem.contains(document.activeElement) &&
847
+ (elem.touched ||
848
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
849
+ elem.validateOnInput;
844
850
 
845
851
  if (elem.hasAttribute('error')) {
846
852
  elem.validity = 'customError';
847
853
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
854
+ validationShouldRun = false;
848
855
  } else if (validationShouldRun) {
849
856
  elem.validity = 'valid';
850
857
  elem.errorMessage = '';
@@ -865,7 +872,7 @@ class AuroFormValidation {
865
872
  }
866
873
  }
867
874
 
868
- if (!hasValue && elem.required) {
875
+ if (!hasValue && elem.required && elem.touched) {
869
876
  elem.validity = 'valueMissing';
870
877
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
871
878
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -876,7 +883,7 @@ class AuroFormValidation {
876
883
  }
877
884
  }
878
885
 
879
- if (this.auroInputElements?.length > 0) {
886
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
880
887
  elem.validity = this.auroInputElements[0].validity;
881
888
  elem.errorMessage = this.auroInputElements[0].errorMessage;
882
889
 
@@ -955,7 +962,7 @@ class AuroFormValidation {
955
962
  }
956
963
  }
957
964
  } else {
958
- elem.errorMessage = undefined;
965
+ elem.errorMessage = '';
959
966
  }
960
967
  }
961
968
  }
@@ -5841,6 +5848,18 @@ class AuroSelect extends i$2 {
5841
5848
  reflect: true,
5842
5849
  attribute: 'multiselect'
5843
5850
  },
5851
+
5852
+ /**
5853
+ * Indicates whether the input is in a dirty state (has been interacted with).
5854
+ * @type {boolean}
5855
+ * @default false
5856
+ * @private
5857
+ */
5858
+ touched: {
5859
+ type: Boolean,
5860
+ reflect: true,
5861
+ attribute: false
5862
+ }
5844
5863
  };
5845
5864
  }
5846
5865
 
@@ -6112,16 +6131,7 @@ class AuroSelect extends i$2 {
6112
6131
  */
6113
6132
  handleFocusin() {
6114
6133
 
6115
- /**
6116
- * The input is considered to be in it's initial state based on
6117
- * if this.value === undefined. The first time we interact with the
6118
- * input manually, by applying focusin, we need to flag the
6119
- * input as no longer in the initial state.
6120
- */
6121
- if (this.value === undefined) {
6122
- this.value = undefined;
6123
- this.removeEventListener('focusin', this.handleFocusin);
6124
- }
6134
+ this.touched = true;
6125
6135
  }
6126
6136
 
6127
6137
  /**
@@ -541,6 +541,7 @@ class AuroFormValidation {
541
541
  reset(elem) {
542
542
  elem.validity = undefined;
543
543
  elem.value = undefined;
544
+ elem.touched = false;
544
545
 
545
546
  // Resets the second value of the datepicker in range state
546
547
  if (elem.valueEnd) {
@@ -678,7 +679,7 @@ class AuroFormValidation {
678
679
  } else if (elem.type === 'date' && elem.value?.length > 0) {
679
680
 
680
681
  // Guard Clause: if the value is too short
681
- if (elem.value.length < elem.lengthForType) {
682
+ if (elem.value?.length < elem.lengthForType) {
682
683
 
683
684
  elem.validity = 'tooShort';
684
685
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -748,11 +749,17 @@ class AuroFormValidation {
748
749
  this.getAuroInputs(elem);
749
750
 
750
751
  // Validate only if noValidate is not true and the input does not have focus
751
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
752
+ let validationShouldRun =
753
+ force ||
754
+ (!elem.contains(document.activeElement) &&
755
+ (elem.touched ||
756
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
757
+ elem.validateOnInput;
752
758
 
753
759
  if (elem.hasAttribute('error')) {
754
760
  elem.validity = 'customError';
755
761
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
762
+ validationShouldRun = false;
756
763
  } else if (validationShouldRun) {
757
764
  elem.validity = 'valid';
758
765
  elem.errorMessage = '';
@@ -773,7 +780,7 @@ class AuroFormValidation {
773
780
  }
774
781
  }
775
782
 
776
- if (!hasValue && elem.required) {
783
+ if (!hasValue && elem.required && elem.touched) {
777
784
  elem.validity = 'valueMissing';
778
785
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
779
786
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -784,7 +791,7 @@ class AuroFormValidation {
784
791
  }
785
792
  }
786
793
 
787
- if (this.auroInputElements?.length > 0) {
794
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
788
795
  elem.validity = this.auroInputElements[0].validity;
789
796
  elem.errorMessage = this.auroInputElements[0].errorMessage;
790
797
 
@@ -863,7 +870,7 @@ class AuroFormValidation {
863
870
  }
864
871
  }
865
872
  } else {
866
- elem.errorMessage = undefined;
873
+ elem.errorMessage = '';
867
874
  }
868
875
  }
869
876
  }
@@ -5749,6 +5756,18 @@ class AuroSelect extends i$2 {
5749
5756
  reflect: true,
5750
5757
  attribute: 'multiselect'
5751
5758
  },
5759
+
5760
+ /**
5761
+ * Indicates whether the input is in a dirty state (has been interacted with).
5762
+ * @type {boolean}
5763
+ * @default false
5764
+ * @private
5765
+ */
5766
+ touched: {
5767
+ type: Boolean,
5768
+ reflect: true,
5769
+ attribute: false
5770
+ }
5752
5771
  };
5753
5772
  }
5754
5773
 
@@ -6020,16 +6039,7 @@ class AuroSelect extends i$2 {
6020
6039
  */
6021
6040
  handleFocusin() {
6022
6041
 
6023
- /**
6024
- * The input is considered to be in it's initial state based on
6025
- * if this.value === undefined. The first time we interact with the
6026
- * input manually, by applying focusin, we need to flag the
6027
- * input as no longer in the initial state.
6028
- */
6029
- if (this.value === undefined) {
6030
- this.value = undefined;
6031
- this.removeEventListener('focusin', this.handleFocusin);
6032
- }
6042
+ this.touched = true;
6033
6043
  }
6034
6044
 
6035
6045
  /**
@@ -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.2.8/auro-select/+esm"></script>
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
 
@@ -179,6 +179,13 @@ export class AuroSelect extends LitElement {
179
179
  reflect: boolean;
180
180
  attribute: string;
181
181
  };
182
+ /**
183
+ * Indicates whether the input is in a dirty state (has been interacted with).
184
+ * @type {boolean}
185
+ * @default false
186
+ * @private
187
+ */
188
+ touched: boolean;
182
189
  };
183
190
  static get styles(): import("lit").CSSResult[];
184
191
  /**
@@ -287,6 +294,7 @@ export class AuroSelect extends LitElement {
287
294
  * @return {void}
288
295
  */
289
296
  private handleFocusin;
297
+ touched: boolean;
290
298
  /**
291
299
  * Watch for slot changes and recalculate the menuoptions.
292
300
  * @private
@@ -500,6 +500,7 @@ class AuroFormValidation {
500
500
  reset(elem) {
501
501
  elem.validity = undefined;
502
502
  elem.value = undefined;
503
+ elem.touched = false;
503
504
 
504
505
  // Resets the second value of the datepicker in range state
505
506
  if (elem.valueEnd) {
@@ -637,7 +638,7 @@ class AuroFormValidation {
637
638
  } else if (elem.type === 'date' && elem.value?.length > 0) {
638
639
 
639
640
  // Guard Clause: if the value is too short
640
- if (elem.value.length < elem.lengthForType) {
641
+ if (elem.value?.length < elem.lengthForType) {
641
642
 
642
643
  elem.validity = 'tooShort';
643
644
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -707,11 +708,17 @@ class AuroFormValidation {
707
708
  this.getAuroInputs(elem);
708
709
 
709
710
  // Validate only if noValidate is not true and the input does not have focus
710
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
711
+ let validationShouldRun =
712
+ force ||
713
+ (!elem.contains(document.activeElement) &&
714
+ (elem.touched ||
715
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
716
+ elem.validateOnInput;
711
717
 
712
718
  if (elem.hasAttribute('error')) {
713
719
  elem.validity = 'customError';
714
720
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
721
+ validationShouldRun = false;
715
722
  } else if (validationShouldRun) {
716
723
  elem.validity = 'valid';
717
724
  elem.errorMessage = '';
@@ -732,7 +739,7 @@ class AuroFormValidation {
732
739
  }
733
740
  }
734
741
 
735
- if (!hasValue && elem.required) {
742
+ if (!hasValue && elem.required && elem.touched) {
736
743
  elem.validity = 'valueMissing';
737
744
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
738
745
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -743,7 +750,7 @@ class AuroFormValidation {
743
750
  }
744
751
  }
745
752
 
746
- if (this.auroInputElements?.length > 0) {
753
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
747
754
  elem.validity = this.auroInputElements[0].validity;
748
755
  elem.errorMessage = this.auroInputElements[0].errorMessage;
749
756
 
@@ -822,7 +829,7 @@ class AuroFormValidation {
822
829
  }
823
830
  }
824
831
  } else {
825
- elem.errorMessage = undefined;
832
+ elem.errorMessage = '';
826
833
  }
827
834
  }
828
835
  }
@@ -5702,6 +5709,18 @@ class AuroSelect extends LitElement {
5702
5709
  reflect: true,
5703
5710
  attribute: 'multiselect'
5704
5711
  },
5712
+
5713
+ /**
5714
+ * Indicates whether the input is in a dirty state (has been interacted with).
5715
+ * @type {boolean}
5716
+ * @default false
5717
+ * @private
5718
+ */
5719
+ touched: {
5720
+ type: Boolean,
5721
+ reflect: true,
5722
+ attribute: false
5723
+ }
5705
5724
  };
5706
5725
  }
5707
5726
 
@@ -5973,16 +5992,7 @@ class AuroSelect extends LitElement {
5973
5992
  */
5974
5993
  handleFocusin() {
5975
5994
 
5976
- /**
5977
- * The input is considered to be in it's initial state based on
5978
- * if this.value === undefined. The first time we interact with the
5979
- * input manually, by applying focusin, we need to flag the
5980
- * input as no longer in the initial state.
5981
- */
5982
- if (this.value === undefined) {
5983
- this.value = undefined;
5984
- this.removeEventListener('focusin', this.handleFocusin);
5985
- }
5995
+ this.touched = true;
5986
5996
  }
5987
5997
 
5988
5998
  /**
@@ -500,6 +500,7 @@ class AuroFormValidation {
500
500
  reset(elem) {
501
501
  elem.validity = undefined;
502
502
  elem.value = undefined;
503
+ elem.touched = false;
503
504
 
504
505
  // Resets the second value of the datepicker in range state
505
506
  if (elem.valueEnd) {
@@ -637,7 +638,7 @@ class AuroFormValidation {
637
638
  } else if (elem.type === 'date' && elem.value?.length > 0) {
638
639
 
639
640
  // Guard Clause: if the value is too short
640
- if (elem.value.length < elem.lengthForType) {
641
+ if (elem.value?.length < elem.lengthForType) {
641
642
 
642
643
  elem.validity = 'tooShort';
643
644
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -707,11 +708,17 @@ class AuroFormValidation {
707
708
  this.getAuroInputs(elem);
708
709
 
709
710
  // Validate only if noValidate is not true and the input does not have focus
710
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
711
+ let validationShouldRun =
712
+ force ||
713
+ (!elem.contains(document.activeElement) &&
714
+ (elem.touched ||
715
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
716
+ elem.validateOnInput;
711
717
 
712
718
  if (elem.hasAttribute('error')) {
713
719
  elem.validity = 'customError';
714
720
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
721
+ validationShouldRun = false;
715
722
  } else if (validationShouldRun) {
716
723
  elem.validity = 'valid';
717
724
  elem.errorMessage = '';
@@ -732,7 +739,7 @@ class AuroFormValidation {
732
739
  }
733
740
  }
734
741
 
735
- if (!hasValue && elem.required) {
742
+ if (!hasValue && elem.required && elem.touched) {
736
743
  elem.validity = 'valueMissing';
737
744
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
738
745
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -743,7 +750,7 @@ class AuroFormValidation {
743
750
  }
744
751
  }
745
752
 
746
- if (this.auroInputElements?.length > 0) {
753
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
747
754
  elem.validity = this.auroInputElements[0].validity;
748
755
  elem.errorMessage = this.auroInputElements[0].errorMessage;
749
756
 
@@ -822,7 +829,7 @@ class AuroFormValidation {
822
829
  }
823
830
  }
824
831
  } else {
825
- elem.errorMessage = undefined;
832
+ elem.errorMessage = '';
826
833
  }
827
834
  }
828
835
  }
@@ -5702,6 +5709,18 @@ class AuroSelect extends LitElement {
5702
5709
  reflect: true,
5703
5710
  attribute: 'multiselect'
5704
5711
  },
5712
+
5713
+ /**
5714
+ * Indicates whether the input is in a dirty state (has been interacted with).
5715
+ * @type {boolean}
5716
+ * @default false
5717
+ * @private
5718
+ */
5719
+ touched: {
5720
+ type: Boolean,
5721
+ reflect: true,
5722
+ attribute: false
5723
+ }
5705
5724
  };
5706
5725
  }
5707
5726
 
@@ -5973,16 +5992,7 @@ class AuroSelect extends LitElement {
5973
5992
  */
5974
5993
  handleFocusin() {
5975
5994
 
5976
- /**
5977
- * The input is considered to be in it's initial state based on
5978
- * if this.value === undefined. The first time we interact with the
5979
- * input manually, by applying focusin, we need to flag the
5980
- * input as no longer in the initial state.
5981
- */
5982
- if (this.value === undefined) {
5983
- this.value = undefined;
5984
- this.removeEventListener('focusin', this.handleFocusin);
5985
- }
5995
+ this.touched = true;
5986
5996
  }
5987
5997
 
5988
5998
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurodesignsystem/auro-formkit",
3
- "version": "3.3.0-beta.2",
3
+ "version": "3.4.0",
4
4
  "description": "A collection of web components used to build forms.",
5
5
  "homepage": "https://github.com/AlaskaAirlines/auro-formkit#readme",
6
6
  "bugs": {