@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
@@ -591,6 +591,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
591
591
  reset(elem) {
592
592
  elem.validity = undefined;
593
593
  elem.value = undefined;
594
+ elem.touched = false;
594
595
 
595
596
  // Resets the second value of the datepicker in range state
596
597
  if (elem.valueEnd) {
@@ -728,7 +729,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
728
729
  } else if (elem.type === 'date' && elem.value?.length > 0) {
729
730
 
730
731
  // Guard Clause: if the value is too short
731
- if (elem.value.length < elem.lengthForType) {
732
+ if (elem.value?.length < elem.lengthForType) {
732
733
 
733
734
  elem.validity = 'tooShort';
734
735
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -798,11 +799,17 @@ let AuroFormValidation$1 = class AuroFormValidation {
798
799
  this.getAuroInputs(elem);
799
800
 
800
801
  // Validate only if noValidate is not true and the input does not have focus
801
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
802
+ let validationShouldRun =
803
+ force ||
804
+ (!elem.contains(document.activeElement) &&
805
+ (elem.touched ||
806
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
807
+ elem.validateOnInput;
802
808
 
803
809
  if (elem.hasAttribute('error')) {
804
810
  elem.validity = 'customError';
805
811
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
812
+ validationShouldRun = false;
806
813
  } else if (validationShouldRun) {
807
814
  elem.validity = 'valid';
808
815
  elem.errorMessage = '';
@@ -823,7 +830,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
823
830
  }
824
831
  }
825
832
 
826
- if (!hasValue && elem.required) {
833
+ if (!hasValue && elem.required && elem.touched) {
827
834
  elem.validity = 'valueMissing';
828
835
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
829
836
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -834,7 +841,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
834
841
  }
835
842
  }
836
843
 
837
- if (this.auroInputElements?.length > 0) {
844
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
838
845
  elem.validity = this.auroInputElements[0].validity;
839
846
  elem.errorMessage = this.auroInputElements[0].errorMessage;
840
847
 
@@ -913,7 +920,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
913
920
  }
914
921
  }
915
922
  } else {
916
- elem.errorMessage = undefined;
923
+ elem.errorMessage = '';
917
924
  }
918
925
  }
919
926
  };
@@ -9146,6 +9153,7 @@ class AuroFormValidation {
9146
9153
  reset(elem) {
9147
9154
  elem.validity = undefined;
9148
9155
  elem.value = undefined;
9156
+ elem.touched = false;
9149
9157
 
9150
9158
  // Resets the second value of the datepicker in range state
9151
9159
  if (elem.valueEnd) {
@@ -9283,7 +9291,7 @@ class AuroFormValidation {
9283
9291
  } else if (elem.type === 'date' && elem.value?.length > 0) {
9284
9292
 
9285
9293
  // Guard Clause: if the value is too short
9286
- if (elem.value.length < elem.lengthForType) {
9294
+ if (elem.value?.length < elem.lengthForType) {
9287
9295
 
9288
9296
  elem.validity = 'tooShort';
9289
9297
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -9353,11 +9361,17 @@ class AuroFormValidation {
9353
9361
  this.getAuroInputs(elem);
9354
9362
 
9355
9363
  // Validate only if noValidate is not true and the input does not have focus
9356
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
9364
+ let validationShouldRun =
9365
+ force ||
9366
+ (!elem.contains(document.activeElement) &&
9367
+ (elem.touched ||
9368
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
9369
+ elem.validateOnInput;
9357
9370
 
9358
9371
  if (elem.hasAttribute('error')) {
9359
9372
  elem.validity = 'customError';
9360
9373
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
9374
+ validationShouldRun = false;
9361
9375
  } else if (validationShouldRun) {
9362
9376
  elem.validity = 'valid';
9363
9377
  elem.errorMessage = '';
@@ -9378,7 +9392,7 @@ class AuroFormValidation {
9378
9392
  }
9379
9393
  }
9380
9394
 
9381
- if (!hasValue && elem.required) {
9395
+ if (!hasValue && elem.required && elem.touched) {
9382
9396
  elem.validity = 'valueMissing';
9383
9397
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
9384
9398
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -9389,7 +9403,7 @@ class AuroFormValidation {
9389
9403
  }
9390
9404
  }
9391
9405
 
9392
- if (this.auroInputElements?.length > 0) {
9406
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
9393
9407
  elem.validity = this.auroInputElements[0].validity;
9394
9408
  elem.errorMessage = this.auroInputElements[0].errorMessage;
9395
9409
 
@@ -9468,7 +9482,7 @@ class AuroFormValidation {
9468
9482
  }
9469
9483
  }
9470
9484
  } else {
9471
- elem.errorMessage = undefined;
9485
+ elem.errorMessage = '';
9472
9486
  }
9473
9487
  }
9474
9488
  }
@@ -9519,6 +9533,7 @@ class BaseInput extends i$2 {
9519
9533
  * @returns {void}
9520
9534
  */
9521
9535
  privateDefaults() {
9536
+ this.touched = false;
9522
9537
  this.util = new AuroInputUtilities();
9523
9538
  this.validation = new AuroFormValidation();
9524
9539
  this.inputIconName = undefined;
@@ -9679,6 +9694,13 @@ class BaseInput extends i$2 {
9679
9694
  type: String
9680
9695
  },
9681
9696
 
9697
+ /** Exposes inputmode attribute for input. */
9698
+ inputmode: {
9699
+ type: String,
9700
+ attribute: true,
9701
+ reflect: true
9702
+ },
9703
+
9682
9704
  /**
9683
9705
  * Defines the language of an element.
9684
9706
  */
@@ -9880,6 +9902,18 @@ class BaseInput extends i$2 {
9880
9902
  validity: {
9881
9903
  type: String,
9882
9904
  reflect: true
9905
+ },
9906
+
9907
+ /**
9908
+ * Indicates whether the input is in a dirty state (has been interacted with).
9909
+ * @type {boolean}
9910
+ * @default false
9911
+ * @private
9912
+ */
9913
+ touched: {
9914
+ type: Boolean,
9915
+ reflect: true,
9916
+ attribute: false
9883
9917
  }
9884
9918
  };
9885
9919
  }
@@ -10166,15 +10200,7 @@ class BaseInput extends i$2 {
10166
10200
  */
10167
10201
  handleFocusin() {
10168
10202
 
10169
- /**
10170
- * The input is considered to be in it's initial state based on
10171
- * if this.value === undefined. The first time we interact with the
10172
- * input manually, by applying focusin, we need to flag the
10173
- * input as no longer in the initial state.
10174
- */
10175
- if (this.value === undefined) {
10176
- this.value = '';
10177
- }
10203
+ this.touched = true;
10178
10204
  }
10179
10205
 
10180
10206
  /**
@@ -10240,9 +10266,9 @@ class BaseInput extends i$2 {
10240
10266
 
10241
10267
  if (this.type in defaultLengths) {
10242
10268
  this.lengthForType = this.format ? this.format.length : defaultLengths[this.type];
10243
- this.inputMode = 'numeric';
10269
+ this.inputmode = this.inputmode || 'numeric';
10244
10270
  } else if (this.type === 'number') {
10245
- this.inputMode = 'numeric';
10271
+ this.inputmode = this.inputmode || 'numeric';
10246
10272
  }
10247
10273
 
10248
10274
  if (this.type === "date" && !this.format) {
@@ -11600,7 +11626,7 @@ class AuroInput extends BaseInput {
11600
11626
  pattern="${o(this.definePattern())}"
11601
11627
  maxlength="${o(this.maxLength ? this.maxLength : undefined)}"
11602
11628
  minlength="${o(this.minLength ? this.minLength : undefined)}"
11603
- inputMode="${o(this.inputMode ? this.inputMode : undefined)}"
11629
+ inputMode="${o(this.inputmode ? this.inputmode : undefined)}"
11604
11630
  ?required="${this.required}"
11605
11631
  ?disabled="${this.disabled}"
11606
11632
  aria-describedby="${this.uniqueId}"
@@ -12659,6 +12685,13 @@ class AuroCombobox extends i$2 {
12659
12685
  reflect: true
12660
12686
  },
12661
12687
 
12688
+ /** Exposes inputmode attribute for input. */
12689
+ inputmode: {
12690
+ type: String,
12691
+ attribute: true,
12692
+ reflect: true
12693
+ },
12694
+
12662
12695
  /**
12663
12696
  * If set, combobox will not filter menuoptions based in input.
12664
12697
  */
@@ -12808,14 +12841,6 @@ class AuroCombobox extends i$2 {
12808
12841
  reflect: true
12809
12842
  },
12810
12843
 
12811
- /**
12812
- * @private
12813
- */
12814
- isDropdownFullscreen: {
12815
- type: Boolean,
12816
- reflect: false
12817
- },
12818
-
12819
12844
  /**
12820
12845
  * @private
12821
12846
  * specifies the currently active option
@@ -12850,6 +12875,14 @@ class AuroCombobox extends i$2 {
12850
12875
  * @returns {void}
12851
12876
  */
12852
12877
  handleMenuOptions() {
12878
+ // Reset menu matchword UI
12879
+ this.menu.updateItemsState(new Map([
12880
+ [
12881
+ 'matchWord',
12882
+ true
12883
+ ]
12884
+ ]));
12885
+
12853
12886
  this.generateOptionsArray();
12854
12887
  this.availableOptions = [];
12855
12888
 
@@ -12957,8 +12990,6 @@ class AuroCombobox extends i$2 {
12957
12990
  return;
12958
12991
  }
12959
12992
 
12960
- this.isDropdownFullscreen = this.dropdown.isBibFullscreen;
12961
-
12962
12993
  if (!this.dropdown.isPopoverVisible && this.input.value && this.input.value.length > 0) {
12963
12994
  if (this.menu.getAttribute('loading') || (this.availableOptions && this.availableOptions.length > 0) || this.noMatchOption !== undefined) { // eslint-disable-line no-extra-parens
12964
12995
  if (this.menu.hasAttribute('loading') && !this.menu.hasLoadingPlaceholder) {
@@ -12985,6 +13016,13 @@ class AuroCombobox extends i$2 {
12985
13016
  // Listen for the dropdown to be shown or hidden
12986
13017
  this.dropdown.addEventListener("auroDropdown-toggled", (ev) => {
12987
13018
  this.dropdownOpen = ev.detail.expanded;
13019
+
13020
+ // wait a frame in case the bib gets hide immediately after showing because there is no value
13021
+ setTimeout(this.transportInput);
13022
+ });
13023
+
13024
+ this.dropdown.addEventListener('auroDropdown-triggerClick', () => {
13025
+ this.showBib();
12988
13026
  });
12989
13027
 
12990
13028
  // this.dropdown.addEventListener('auroDropdown-show', () => {
@@ -13003,19 +13041,10 @@ class AuroCombobox extends i$2 {
13003
13041
  this.hideBib = this.hideBib.bind(this);
13004
13042
  this.bibtemplate.addEventListener('close-click', this.hideBib);
13005
13043
 
13006
- this.dropdown.addEventListener('auroDropdown-triggerClick', () => {
13007
- this.showBib();
13008
- });
13009
-
13010
13044
  this.transportInput = this.transportInput.bind(this);
13011
- this.dropdown.addEventListener('auroDropdown-toggled', () => {
13012
- // wait a frame in case the bib gets hide immediately after showing because there is no value
13013
- setTimeout(this.transportInput);
13014
- });
13015
13045
 
13016
- this.dropdown.addEventListener('auroDropdown-strategy-change', (event) => {
13046
+ this.dropdown.addEventListener('auroDropdown-strategy-change', () => {
13017
13047
  // event when the strategy(bib mode) is changed between fullscreen and floating
13018
- this.isDropdownFullscreen = event.detail.strategy === 'fullscreen';
13019
13048
  setTimeout(this.transportInput);
13020
13049
  });
13021
13050
  }
@@ -13111,20 +13140,17 @@ class AuroCombobox extends i$2 {
13111
13140
  * @private
13112
13141
  * Dispatches input's keyboard events from host
13113
13142
  * This allows key events from the input to be handled by the parent.
13114
- * @param {KeyboardEvent} event - The keyboard event.
13143
+ * @param {Event} event - The keyboard event.
13115
13144
  */
13116
- bubbleUpInputKeyEvent(event) {
13145
+ bubbleUpInputEvent(event) {
13146
+ // Do not need to bubble events if the input is not in bib.
13117
13147
  if (event.currentTarget.parentNode !== this.dropdown) {
13148
+ // prevents browsers to move cursor in input element.
13118
13149
  if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
13119
13150
  event.preventDefault();
13120
13151
  }
13121
-
13122
- const ke = new KeyboardEvent(event.type, {
13123
- key: event.key,
13124
- code: event.code,
13125
- repeat: event.repeat,
13126
- });
13127
- this.dispatchEvent(ke);
13152
+ const dupEvent = new event.constructor(event.type, event);
13153
+ this.dispatchEvent(dupEvent);
13128
13154
  }
13129
13155
  }
13130
13156
 
@@ -13135,14 +13161,22 @@ class AuroCombobox extends i$2 {
13135
13161
  */
13136
13162
  configureInput() {
13137
13163
  // When input is in bibtemplate, make the event to be fired at combobox element
13138
- this.bubbleUpInputKeyEvent = this.bubbleUpInputKeyEvent.bind(this);
13139
- this.input.addEventListener('keydown', this.bubbleUpInputKeyEvent);
13140
- this.input.addEventListener('keyup', this.bubbleUpInputKeyEvent);
13141
- this.input.addEventListener('input', this.bubbleUpInputKeyEvent);
13164
+ this.bubbleUpInputEvent = this.bubbleUpInputEvent.bind(this);
13165
+
13166
+ const events = [
13167
+ 'input',
13168
+ 'keydown',
13169
+ 'keyup'
13170
+ ];
13171
+ events.forEach((eventType) => {
13172
+ this.input.addEventListener(eventType, this.bubbleUpInputEvent);
13173
+ });
13142
13174
 
13143
13175
  this.addEventListener('keyup', (evt) => {
13144
13176
  if (evt.key.length === 1 || evt.key === 'Backspace' || evt.key === 'Delete') {
13145
- this.showBib();
13177
+ if (!this.dropdown.isPopoverVisible) {
13178
+ this.showBib();
13179
+ }
13146
13180
  }
13147
13181
  });
13148
13182
 
@@ -13203,8 +13237,8 @@ class AuroCombobox extends i$2 {
13203
13237
  const inputHelpText = this.input.shadowRoot.querySelector('auro-helptext, [auro-helptext');
13204
13238
  const inputAlertIcon = this.input.shadowRoot.querySelector(".alertNotification");
13205
13239
 
13206
- if (this.dropdown.isPopoverVisible && this.isDropdownFullscreen) {
13207
- if (this.input.parentNode !== this.bibtemplate) {
13240
+ if (this.dropdown.isPopoverVisible && this.dropdown.isBibFullscreen) {
13241
+ if (this.input.parentNode === this.dropdown) {
13208
13242
  // keep the trigger size the same even after input gets removed
13209
13243
  const parentSize = window.getComputedStyle(this.dropdown.trigger);
13210
13244
  this.dropdown.trigger.style.height = parentSize.height;
@@ -13290,7 +13324,7 @@ class AuroCombobox extends i$2 {
13290
13324
  }
13291
13325
 
13292
13326
  // Force dropdown bib to hide if input value has no matching suggestions
13293
- if ((!this.availableOptions || this.availableOptions.length === 0) && !this.isDropdownFullscreen) {
13327
+ if ((!this.availableOptions || this.availableOptions.length === 0) && !this.dropdown.isBibFullscreen) {
13294
13328
  this.hideBib();
13295
13329
  }
13296
13330
  }
@@ -13313,7 +13347,7 @@ class AuroCombobox extends i$2 {
13313
13347
  if (evt.key === 'Tab') {
13314
13348
  this.hideBib();
13315
13349
 
13316
- if (this.dropdown.isPopoverVisible && this.isDropdownFullscreen) {
13350
+ if (this.dropdown.isPopoverVisible && this.dropdown.isBibFullscreen) {
13317
13351
  // if bib is open in fullscreen, just close the bib and do not move the focus to the next focasable element
13318
13352
  evt.preventDefault();
13319
13353
  }
@@ -13538,6 +13572,7 @@ class AuroCombobox extends i$2 {
13538
13572
  setCustomValidityCustomError="${this.setCustomValidityCustomError}"
13539
13573
  .autocomplete="${this.autocomplete}"
13540
13574
  .type="${this.type}"
13575
+ inputmode="${o(this.inputmode)}"
13541
13576
  @input="${this.handleInputValueChange}">
13542
13577
  </${this.inputTag}>
13543
13578
 
@@ -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-combobox/+esm"></script>
114
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.3.0/auro-combobox/+esm"></script>
115
115
  ```
116
116
  <!-- AURO-GENERATED-CONTENT:END -->
117
117
 
@@ -62,6 +62,12 @@ export class AuroCombobox extends LitElement {
62
62
  type: StringConstructor;
63
63
  reflect: boolean;
64
64
  };
65
+ /** Exposes inputmode attribute for input. */
66
+ inputmode: {
67
+ type: StringConstructor;
68
+ attribute: boolean;
69
+ reflect: boolean;
70
+ };
65
71
  /**
66
72
  * If set, combobox will not filter menuoptions based in input.
67
73
  */
@@ -194,13 +200,6 @@ export class AuroCombobox extends LitElement {
194
200
  type: StringConstructor;
195
201
  reflect: boolean;
196
202
  };
197
- /**
198
- * @private
199
- */
200
- isDropdownFullscreen: {
201
- type: BooleanConstructor;
202
- reflect: boolean;
203
- };
204
203
  /**
205
204
  * @private
206
205
  * specifies the currently active option
@@ -279,7 +278,6 @@ export class AuroCombobox extends LitElement {
279
278
  * @returns {void}
280
279
  */
281
280
  private showBib;
282
- isDropdownFullscreen: any;
283
281
  /**
284
282
  * Binds all behavior needed to the dropdown after rendering.
285
283
  * @private
@@ -307,9 +305,9 @@ export class AuroCombobox extends LitElement {
307
305
  * @private
308
306
  * Dispatches input's keyboard events from host
309
307
  * This allows key events from the input to be handled by the parent.
310
- * @param {KeyboardEvent} event - The keyboard event.
308
+ * @param {Event} event - The keyboard event.
311
309
  */
312
- private bubbleUpInputKeyEvent;
310
+ private bubbleUpInputEvent;
313
311
  /**
314
312
  * Binds all behavior needed to the input after rendering.
315
313
  * @private