@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
@@ -733,6 +733,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
733
733
  reset(elem) {
734
734
  elem.validity = undefined;
735
735
  elem.value = undefined;
736
+ elem.touched = false;
736
737
 
737
738
  // Resets the second value of the datepicker in range state
738
739
  if (elem.valueEnd) {
@@ -870,7 +871,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
870
871
  } else if (elem.type === 'date' && elem.value?.length > 0) {
871
872
 
872
873
  // Guard Clause: if the value is too short
873
- if (elem.value.length < elem.lengthForType) {
874
+ if (elem.value?.length < elem.lengthForType) {
874
875
 
875
876
  elem.validity = 'tooShort';
876
877
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -940,11 +941,17 @@ let AuroFormValidation$1 = class AuroFormValidation {
940
941
  this.getAuroInputs(elem);
941
942
 
942
943
  // Validate only if noValidate is not true and the input does not have focus
943
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
944
+ let validationShouldRun =
945
+ force ||
946
+ (!elem.contains(document.activeElement) &&
947
+ (elem.touched ||
948
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
949
+ elem.validateOnInput;
944
950
 
945
951
  if (elem.hasAttribute('error')) {
946
952
  elem.validity = 'customError';
947
953
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
954
+ validationShouldRun = false;
948
955
  } else if (validationShouldRun) {
949
956
  elem.validity = 'valid';
950
957
  elem.errorMessage = '';
@@ -965,7 +972,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
965
972
  }
966
973
  }
967
974
 
968
- if (!hasValue && elem.required) {
975
+ if (!hasValue && elem.required && elem.touched) {
969
976
  elem.validity = 'valueMissing';
970
977
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
971
978
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -976,7 +983,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
976
983
  }
977
984
  }
978
985
 
979
- if (this.auroInputElements?.length > 0) {
986
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
980
987
  elem.validity = this.auroInputElements[0].validity;
981
988
  elem.errorMessage = this.auroInputElements[0].errorMessage;
982
989
 
@@ -1055,7 +1062,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
1055
1062
  }
1056
1063
  }
1057
1064
  } else {
1058
- elem.errorMessage = undefined;
1065
+ elem.errorMessage = '';
1059
1066
  }
1060
1067
  }
1061
1068
  };
@@ -9288,6 +9295,7 @@ class AuroFormValidation {
9288
9295
  reset(elem) {
9289
9296
  elem.validity = undefined;
9290
9297
  elem.value = undefined;
9298
+ elem.touched = false;
9291
9299
 
9292
9300
  // Resets the second value of the datepicker in range state
9293
9301
  if (elem.valueEnd) {
@@ -9425,7 +9433,7 @@ class AuroFormValidation {
9425
9433
  } else if (elem.type === 'date' && elem.value?.length > 0) {
9426
9434
 
9427
9435
  // Guard Clause: if the value is too short
9428
- if (elem.value.length < elem.lengthForType) {
9436
+ if (elem.value?.length < elem.lengthForType) {
9429
9437
 
9430
9438
  elem.validity = 'tooShort';
9431
9439
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
@@ -9495,11 +9503,17 @@ class AuroFormValidation {
9495
9503
  this.getAuroInputs(elem);
9496
9504
 
9497
9505
  // Validate only if noValidate is not true and the input does not have focus
9498
- const validationShouldRun = force || (!elem.contains(document.activeElement) && elem.value !== undefined) || elem.validateOnInput;
9506
+ let validationShouldRun =
9507
+ force ||
9508
+ (!elem.contains(document.activeElement) &&
9509
+ (elem.touched ||
9510
+ (!elem.touched && typeof elem.value !== "undefined"))) ||
9511
+ elem.validateOnInput;
9499
9512
 
9500
9513
  if (elem.hasAttribute('error')) {
9501
9514
  elem.validity = 'customError';
9502
9515
  elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
9516
+ validationShouldRun = false;
9503
9517
  } else if (validationShouldRun) {
9504
9518
  elem.validity = 'valid';
9505
9519
  elem.errorMessage = '';
@@ -9520,7 +9534,7 @@ class AuroFormValidation {
9520
9534
  }
9521
9535
  }
9522
9536
 
9523
- if (!hasValue && elem.required) {
9537
+ if (!hasValue && elem.required && elem.touched) {
9524
9538
  elem.validity = 'valueMissing';
9525
9539
  elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
9526
9540
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
@@ -9531,7 +9545,7 @@ class AuroFormValidation {
9531
9545
  }
9532
9546
  }
9533
9547
 
9534
- if (this.auroInputElements?.length > 0) {
9548
+ if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
9535
9549
  elem.validity = this.auroInputElements[0].validity;
9536
9550
  elem.errorMessage = this.auroInputElements[0].errorMessage;
9537
9551
 
@@ -9610,7 +9624,7 @@ class AuroFormValidation {
9610
9624
  }
9611
9625
  }
9612
9626
  } else {
9613
- elem.errorMessage = undefined;
9627
+ elem.errorMessage = '';
9614
9628
  }
9615
9629
  }
9616
9630
  }
@@ -9661,6 +9675,7 @@ class BaseInput extends i$2 {
9661
9675
  * @returns {void}
9662
9676
  */
9663
9677
  privateDefaults() {
9678
+ this.touched = false;
9664
9679
  this.util = new AuroInputUtilities();
9665
9680
  this.validation = new AuroFormValidation();
9666
9681
  this.inputIconName = undefined;
@@ -9821,6 +9836,13 @@ class BaseInput extends i$2 {
9821
9836
  type: String
9822
9837
  },
9823
9838
 
9839
+ /** Exposes inputmode attribute for input. */
9840
+ inputmode: {
9841
+ type: String,
9842
+ attribute: true,
9843
+ reflect: true
9844
+ },
9845
+
9824
9846
  /**
9825
9847
  * Defines the language of an element.
9826
9848
  */
@@ -10022,6 +10044,18 @@ class BaseInput extends i$2 {
10022
10044
  validity: {
10023
10045
  type: String,
10024
10046
  reflect: true
10047
+ },
10048
+
10049
+ /**
10050
+ * Indicates whether the input is in a dirty state (has been interacted with).
10051
+ * @type {boolean}
10052
+ * @default false
10053
+ * @private
10054
+ */
10055
+ touched: {
10056
+ type: Boolean,
10057
+ reflect: true,
10058
+ attribute: false
10025
10059
  }
10026
10060
  };
10027
10061
  }
@@ -10308,15 +10342,7 @@ class BaseInput extends i$2 {
10308
10342
  */
10309
10343
  handleFocusin() {
10310
10344
 
10311
- /**
10312
- * The input is considered to be in it's initial state based on
10313
- * if this.value === undefined. The first time we interact with the
10314
- * input manually, by applying focusin, we need to flag the
10315
- * input as no longer in the initial state.
10316
- */
10317
- if (this.value === undefined) {
10318
- this.value = '';
10319
- }
10345
+ this.touched = true;
10320
10346
  }
10321
10347
 
10322
10348
  /**
@@ -10382,9 +10408,9 @@ class BaseInput extends i$2 {
10382
10408
 
10383
10409
  if (this.type in defaultLengths) {
10384
10410
  this.lengthForType = this.format ? this.format.length : defaultLengths[this.type];
10385
- this.inputMode = 'numeric';
10411
+ this.inputmode = this.inputmode || 'numeric';
10386
10412
  } else if (this.type === 'number') {
10387
- this.inputMode = 'numeric';
10413
+ this.inputmode = this.inputmode || 'numeric';
10388
10414
  }
10389
10415
 
10390
10416
  if (this.type === "date" && !this.format) {
@@ -11742,7 +11768,7 @@ class AuroInput extends BaseInput {
11742
11768
  pattern="${o(this.definePattern())}"
11743
11769
  maxlength="${o(this.maxLength ? this.maxLength : undefined)}"
11744
11770
  minlength="${o(this.minLength ? this.minLength : undefined)}"
11745
- inputMode="${o(this.inputMode ? this.inputMode : undefined)}"
11771
+ inputMode="${o(this.inputmode ? this.inputmode : undefined)}"
11746
11772
  ?required="${this.required}"
11747
11773
  ?disabled="${this.disabled}"
11748
11774
  aria-describedby="${this.uniqueId}"
@@ -12801,6 +12827,13 @@ class AuroCombobox extends i$2 {
12801
12827
  reflect: true
12802
12828
  },
12803
12829
 
12830
+ /** Exposes inputmode attribute for input. */
12831
+ inputmode: {
12832
+ type: String,
12833
+ attribute: true,
12834
+ reflect: true
12835
+ },
12836
+
12804
12837
  /**
12805
12838
  * If set, combobox will not filter menuoptions based in input.
12806
12839
  */
@@ -12950,14 +12983,6 @@ class AuroCombobox extends i$2 {
12950
12983
  reflect: true
12951
12984
  },
12952
12985
 
12953
- /**
12954
- * @private
12955
- */
12956
- isDropdownFullscreen: {
12957
- type: Boolean,
12958
- reflect: false
12959
- },
12960
-
12961
12986
  /**
12962
12987
  * @private
12963
12988
  * specifies the currently active option
@@ -12992,6 +13017,14 @@ class AuroCombobox extends i$2 {
12992
13017
  * @returns {void}
12993
13018
  */
12994
13019
  handleMenuOptions() {
13020
+ // Reset menu matchword UI
13021
+ this.menu.updateItemsState(new Map([
13022
+ [
13023
+ 'matchWord',
13024
+ true
13025
+ ]
13026
+ ]));
13027
+
12995
13028
  this.generateOptionsArray();
12996
13029
  this.availableOptions = [];
12997
13030
 
@@ -13099,8 +13132,6 @@ class AuroCombobox extends i$2 {
13099
13132
  return;
13100
13133
  }
13101
13134
 
13102
- this.isDropdownFullscreen = this.dropdown.isBibFullscreen;
13103
-
13104
13135
  if (!this.dropdown.isPopoverVisible && this.input.value && this.input.value.length > 0) {
13105
13136
  if (this.menu.getAttribute('loading') || (this.availableOptions && this.availableOptions.length > 0) || this.noMatchOption !== undefined) { // eslint-disable-line no-extra-parens
13106
13137
  if (this.menu.hasAttribute('loading') && !this.menu.hasLoadingPlaceholder) {
@@ -13127,6 +13158,13 @@ class AuroCombobox extends i$2 {
13127
13158
  // Listen for the dropdown to be shown or hidden
13128
13159
  this.dropdown.addEventListener("auroDropdown-toggled", (ev) => {
13129
13160
  this.dropdownOpen = ev.detail.expanded;
13161
+
13162
+ // wait a frame in case the bib gets hide immediately after showing because there is no value
13163
+ setTimeout(this.transportInput);
13164
+ });
13165
+
13166
+ this.dropdown.addEventListener('auroDropdown-triggerClick', () => {
13167
+ this.showBib();
13130
13168
  });
13131
13169
 
13132
13170
  // this.dropdown.addEventListener('auroDropdown-show', () => {
@@ -13145,19 +13183,10 @@ class AuroCombobox extends i$2 {
13145
13183
  this.hideBib = this.hideBib.bind(this);
13146
13184
  this.bibtemplate.addEventListener('close-click', this.hideBib);
13147
13185
 
13148
- this.dropdown.addEventListener('auroDropdown-triggerClick', () => {
13149
- this.showBib();
13150
- });
13151
-
13152
13186
  this.transportInput = this.transportInput.bind(this);
13153
- this.dropdown.addEventListener('auroDropdown-toggled', () => {
13154
- // wait a frame in case the bib gets hide immediately after showing because there is no value
13155
- setTimeout(this.transportInput);
13156
- });
13157
13187
 
13158
- this.dropdown.addEventListener('auroDropdown-strategy-change', (event) => {
13188
+ this.dropdown.addEventListener('auroDropdown-strategy-change', () => {
13159
13189
  // event when the strategy(bib mode) is changed between fullscreen and floating
13160
- this.isDropdownFullscreen = event.detail.strategy === 'fullscreen';
13161
13190
  setTimeout(this.transportInput);
13162
13191
  });
13163
13192
  }
@@ -13253,20 +13282,17 @@ class AuroCombobox extends i$2 {
13253
13282
  * @private
13254
13283
  * Dispatches input's keyboard events from host
13255
13284
  * This allows key events from the input to be handled by the parent.
13256
- * @param {KeyboardEvent} event - The keyboard event.
13285
+ * @param {Event} event - The keyboard event.
13257
13286
  */
13258
- bubbleUpInputKeyEvent(event) {
13287
+ bubbleUpInputEvent(event) {
13288
+ // Do not need to bubble events if the input is not in bib.
13259
13289
  if (event.currentTarget.parentNode !== this.dropdown) {
13290
+ // prevents browsers to move cursor in input element.
13260
13291
  if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
13261
13292
  event.preventDefault();
13262
13293
  }
13263
-
13264
- const ke = new KeyboardEvent(event.type, {
13265
- key: event.key,
13266
- code: event.code,
13267
- repeat: event.repeat,
13268
- });
13269
- this.dispatchEvent(ke);
13294
+ const dupEvent = new event.constructor(event.type, event);
13295
+ this.dispatchEvent(dupEvent);
13270
13296
  }
13271
13297
  }
13272
13298
 
@@ -13277,14 +13303,22 @@ class AuroCombobox extends i$2 {
13277
13303
  */
13278
13304
  configureInput() {
13279
13305
  // When input is in bibtemplate, make the event to be fired at combobox element
13280
- this.bubbleUpInputKeyEvent = this.bubbleUpInputKeyEvent.bind(this);
13281
- this.input.addEventListener('keydown', this.bubbleUpInputKeyEvent);
13282
- this.input.addEventListener('keyup', this.bubbleUpInputKeyEvent);
13283
- this.input.addEventListener('input', this.bubbleUpInputKeyEvent);
13306
+ this.bubbleUpInputEvent = this.bubbleUpInputEvent.bind(this);
13307
+
13308
+ const events = [
13309
+ 'input',
13310
+ 'keydown',
13311
+ 'keyup'
13312
+ ];
13313
+ events.forEach((eventType) => {
13314
+ this.input.addEventListener(eventType, this.bubbleUpInputEvent);
13315
+ });
13284
13316
 
13285
13317
  this.addEventListener('keyup', (evt) => {
13286
13318
  if (evt.key.length === 1 || evt.key === 'Backspace' || evt.key === 'Delete') {
13287
- this.showBib();
13319
+ if (!this.dropdown.isPopoverVisible) {
13320
+ this.showBib();
13321
+ }
13288
13322
  }
13289
13323
  });
13290
13324
 
@@ -13345,8 +13379,8 @@ class AuroCombobox extends i$2 {
13345
13379
  const inputHelpText = this.input.shadowRoot.querySelector('auro-helptext, [auro-helptext');
13346
13380
  const inputAlertIcon = this.input.shadowRoot.querySelector(".alertNotification");
13347
13381
 
13348
- if (this.dropdown.isPopoverVisible && this.isDropdownFullscreen) {
13349
- if (this.input.parentNode !== this.bibtemplate) {
13382
+ if (this.dropdown.isPopoverVisible && this.dropdown.isBibFullscreen) {
13383
+ if (this.input.parentNode === this.dropdown) {
13350
13384
  // keep the trigger size the same even after input gets removed
13351
13385
  const parentSize = window.getComputedStyle(this.dropdown.trigger);
13352
13386
  this.dropdown.trigger.style.height = parentSize.height;
@@ -13432,7 +13466,7 @@ class AuroCombobox extends i$2 {
13432
13466
  }
13433
13467
 
13434
13468
  // Force dropdown bib to hide if input value has no matching suggestions
13435
- if ((!this.availableOptions || this.availableOptions.length === 0) && !this.isDropdownFullscreen) {
13469
+ if ((!this.availableOptions || this.availableOptions.length === 0) && !this.dropdown.isBibFullscreen) {
13436
13470
  this.hideBib();
13437
13471
  }
13438
13472
  }
@@ -13455,7 +13489,7 @@ class AuroCombobox extends i$2 {
13455
13489
  if (evt.key === 'Tab') {
13456
13490
  this.hideBib();
13457
13491
 
13458
- if (this.dropdown.isPopoverVisible && this.isDropdownFullscreen) {
13492
+ if (this.dropdown.isPopoverVisible && this.dropdown.isBibFullscreen) {
13459
13493
  // if bib is open in fullscreen, just close the bib and do not move the focus to the next focasable element
13460
13494
  evt.preventDefault();
13461
13495
  }
@@ -13680,6 +13714,7 @@ class AuroCombobox extends i$2 {
13680
13714
  setCustomValidityCustomError="${this.setCustomValidityCustomError}"
13681
13715
  .autocomplete="${this.autocomplete}"
13682
13716
  .type="${this.type}"
13717
+ inputmode="${o(this.inputmode)}"
13683
13718
  @input="${this.handleInputValueChange}">
13684
13719
  </${this.inputTag}>
13685
13720