@aurodesignsystem/auro-formkit 5.1.3 → 5.1.4

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 (44) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/components/combobox/README.md +2 -0
  3. package/components/combobox/demo/api.md +190 -62
  4. package/components/combobox/demo/api.min.js +401 -146
  5. package/components/combobox/demo/index.md +2 -0
  6. package/components/combobox/demo/index.min.js +331 -132
  7. package/components/combobox/demo/readme.md +2 -0
  8. package/components/combobox/dist/auro-combobox.d.ts +81 -33
  9. package/components/combobox/dist/index.js +297 -122
  10. package/components/combobox/dist/registered.js +297 -122
  11. package/components/counter/demo/api.min.js +9 -4
  12. package/components/counter/demo/index.min.js +9 -4
  13. package/components/counter/dist/index.js +9 -4
  14. package/components/counter/dist/registered.js +9 -4
  15. package/components/datepicker/demo/api.min.js +61 -16
  16. package/components/datepicker/demo/index.min.js +61 -16
  17. package/components/datepicker/dist/index.js +61 -16
  18. package/components/datepicker/dist/registered.js +61 -16
  19. package/components/dropdown/demo/api.min.js +8 -3
  20. package/components/dropdown/demo/index.min.js +8 -3
  21. package/components/dropdown/dist/index.js +8 -3
  22. package/components/dropdown/dist/registered.js +8 -3
  23. package/components/input/demo/api.md +48 -46
  24. package/components/input/demo/api.min.js +52 -12
  25. package/components/input/demo/index.md +7 -3
  26. package/components/input/demo/index.min.js +52 -12
  27. package/components/input/dist/auro-input.d.ts +4 -0
  28. package/components/input/dist/base-input.d.ts +9 -1
  29. package/components/input/dist/index.js +52 -12
  30. package/components/input/dist/registered.js +52 -12
  31. package/components/layoutElement/dist/index.js +1 -1
  32. package/components/layoutElement/dist/registered.js +1 -1
  33. package/components/menu/demo/api.md +4 -3
  34. package/components/menu/demo/api.min.js +35 -11
  35. package/components/menu/demo/index.min.js +35 -11
  36. package/components/menu/dist/auro-menu.d.ts +3 -2
  37. package/components/menu/dist/auro-menuoption.d.ts +1 -0
  38. package/components/menu/dist/index.js +35 -11
  39. package/components/menu/dist/registered.js +35 -11
  40. package/components/select/demo/api.min.js +44 -15
  41. package/components/select/demo/index.min.js +44 -15
  42. package/components/select/dist/index.js +10 -5
  43. package/components/select/dist/registered.js +10 -5
  44. package/package.json +1 -1
@@ -4300,7 +4300,7 @@ let AuroElement$4 = class AuroElement extends LitElement {
4300
4300
  * @returns {boolean} - Returns true if the element has focus.
4301
4301
  */
4302
4302
  get componentHasFocus() {
4303
- return this.matches(':focus');
4303
+ return this.matches(':focus') || this.matches(':focus-within');
4304
4304
  }
4305
4305
 
4306
4306
  resetShapeClasses() {
@@ -5085,8 +5085,13 @@ class AuroDropdown extends AuroElement$4 {
5085
5085
  }
5086
5086
 
5087
5087
  if (event) {
5088
- this.triggerNode = event.target;
5089
- this.triggerContentSlot = event.target.assignedNodes();
5088
+ // Wrap in a try-catch block to handle errors when trying to use assignedNodes from the NodeJS test environment.
5089
+ try {
5090
+ this.triggerNode = event.target;
5091
+ this.triggerContentSlot = event.target.assignedNodes();
5092
+ } catch (error) {
5093
+ console.warn('auro-dropdown: Unable to access the trigger content slot.', error); // eslint-disable-line no-console
5094
+ }
5090
5095
  }
5091
5096
 
5092
5097
  if (this.triggerContentSlot) {
@@ -10147,7 +10152,7 @@ let AuroElement$2$1 = class AuroElement extends LitElement {
10147
10152
  * @returns {boolean} - Returns true if the element has focus.
10148
10153
  */
10149
10154
  get componentHasFocus() {
10150
- return this.matches(':focus');
10155
+ return this.matches(':focus') || this.matches(':focus-within');
10151
10156
  }
10152
10157
 
10153
10158
  resetShapeClasses() {
@@ -10221,7 +10226,7 @@ let AuroElement$2$1 = class AuroElement extends LitElement {
10221
10226
  * @prop {string} id - The id global attribute defines an identifier (ID) which must be unique in the whole document.
10222
10227
  * @attr id
10223
10228
  *
10224
- * @slot ariaLabel.clear - Sets aria-label on clear button for screenreader to read
10229
+ * @slot ariaLabel.clear - Sets aria-label on clear button for screen reader to read
10225
10230
  * @slot ariaLabel.password.show - Sets aria-label on password button to toggle on showing password
10226
10231
  * @slot ariaLabel.password.hide - Sets aria-label on password button to toggle off showing password
10227
10232
  * @slot helpText - Sets the help text displayed below the input.
@@ -10249,6 +10254,7 @@ class BaseInput extends AuroElement$2$1 {
10249
10254
  this.activeLabel = false;
10250
10255
  this.icon = false;
10251
10256
  this.disabled = false;
10257
+ this.dvInputOnly = false;
10252
10258
  this.max = undefined;
10253
10259
  this.maxLength = undefined;
10254
10260
  this.min = undefined;
@@ -10342,6 +10348,14 @@ class BaseInput extends AuroElement$2$1 {
10342
10348
  return {
10343
10349
  ...super.properties,
10344
10350
 
10351
+ /**
10352
+ * If defined, the display value slot content will only mask the HTML5 input element. The input's label will not be masked.
10353
+ */
10354
+ dvInputOnly: {
10355
+ type: Boolean,
10356
+ reflect: true
10357
+ },
10358
+
10345
10359
  /**
10346
10360
  * The value for the role attribute.
10347
10361
  */
@@ -13107,7 +13121,13 @@ class AuroInput extends BaseInput {
13107
13121
  * @private
13108
13122
  */
13109
13123
  get inputHidden() {
13110
- return (this.hasDisplayValueContent && !this.hasFocus && this.hasValue) || ((!this.value || this.value.length === 0) && !this.hasFocus && (!this.placeholder || this.placeholder === ''));
13124
+ return (
13125
+ this.hasDisplayValueContent && !this.hasFocus && this.hasValue) ||
13126
+ (
13127
+ (!this.value || this.value.length === 0) &&
13128
+ !this.hasFocus &&
13129
+ (!this.placeholder || this.placeholder === '')
13130
+ );
13111
13131
  }
13112
13132
 
13113
13133
  /**
@@ -13127,7 +13147,7 @@ class AuroInput extends BaseInput {
13127
13147
  * @private
13128
13148
  */
13129
13149
  get labelHidden() {
13130
- return this.hasDisplayValueContent && !this.hasFocus && this.hasValue;
13150
+ return this.hasDisplayValueContent && !this.dvInputOnly && !this.hasFocus && this.hasValue;
13131
13151
  }
13132
13152
 
13133
13153
  /**
@@ -13136,18 +13156,26 @@ class AuroInput extends BaseInput {
13136
13156
  * @returns {string} - The font class for the label.
13137
13157
  */
13138
13158
  get labelFontClass() {
13139
- const isHidden = this.inputHidden;
13140
-
13141
13159
  if (this.layout.startsWith('emphasized')) {
13142
- return this.noFocusOrValue ? 'accent-xl' : 'body-sm';
13160
+ let typeSize = 'body-sm';
13161
+
13162
+ if (this.hasDisplayValueContent) {
13163
+ if (!this.hasValue) {
13164
+ typeSize = 'accent-xl';
13165
+ }
13166
+ } else if (this.noFocusOrValue) {
13167
+ typeSize = 'accent-xl';
13168
+ }
13169
+
13170
+ return typeSize;
13143
13171
  }
13144
13172
 
13145
13173
  if (this.layout === 'snowflake') {
13146
- return isHidden ? 'body-lg' : 'body-xs';
13174
+ return this.hasValue || this.hasFocus || this.placeholder ? 'body-xs' : 'body-lg';
13147
13175
  }
13148
13176
 
13149
13177
  // classic layout (default)
13150
- return isHidden ? 'body-default' : 'body-xs';
13178
+ return ((!this.value || this.value.length === 0) && !this.placeholder && !this.hasFocus) ? 'body-default' : 'body-xs';
13151
13179
  }
13152
13180
 
13153
13181
  /**
@@ -13157,7 +13185,17 @@ class AuroInput extends BaseInput {
13157
13185
  */
13158
13186
  get inputFontClass() {
13159
13187
  if (this.layout.startsWith('emphasized')) {
13160
- return this.noFocusOrValue ? 'body-sm' : 'accent-xl';
13188
+ let typeSize = 'accent-xl';
13189
+
13190
+ if (this.hasDisplayValueContent) {
13191
+ if (!this.hasValue) {
13192
+ typeSize = 'body-sm';
13193
+ }
13194
+ } else if (this.noFocusOrValue) {
13195
+ typeSize = 'body-sm';
13196
+ }
13197
+
13198
+ return typeSize;
13161
13199
  }
13162
13200
 
13163
13201
  if (this.layout === 'snowflake') {
@@ -13200,6 +13238,13 @@ class AuroInput extends BaseInput {
13200
13238
  };
13201
13239
  }
13202
13240
 
13241
+ get commonDisplayValueWrapperClasses() {
13242
+ return {
13243
+ 'displayValueWrapper': true,
13244
+ [this.inputFontClass]: true,
13245
+ };
13246
+ }
13247
+
13203
13248
  /**
13204
13249
  * Returns classmap configuration for html5 inputs in each layout.
13205
13250
  * @private
@@ -13272,7 +13317,7 @@ class AuroInput extends BaseInput {
13272
13317
  let nodes = this.shadowRoot.querySelector('slot[name="displayValue"]').assignedNodes();
13273
13318
 
13274
13319
  // Handle when DisplayValue is multi-level slot content (e.g. combobox passing displayValue to input)
13275
- if (nodes[0].tagName === 'SLOT') {
13320
+ if (nodes && nodes[0] && nodes[0].tagName === 'SLOT') {
13276
13321
  nodes = nodes[0].assignedNodes();
13277
13322
  }
13278
13323
 
@@ -13363,7 +13408,7 @@ class AuroInput extends BaseInput {
13363
13408
  type="${this.type === "password" && this.showPassword ? "text" : this.getInputType(this.type)}"
13364
13409
  />
13365
13410
  <div class="${classMap(displayValueClasses)}" aria-hidden="true" part="displayValue">
13366
- <div class="displayValueWrapper">
13411
+ <div class="${classMap(this.commonDisplayValueWrapperClasses)}">
13367
13412
  <slot name="displayValue" @slotchange=${this.checkDisplayValueSlotChange}></slot>
13368
13413
  </div>
13369
13414
  </div>
@@ -15581,7 +15626,7 @@ var bibTemplateVersion = '1.0.0';
15581
15626
 
15582
15627
  var styleCss$1 = css`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}:host{display:block;text-align:left}:host [auro-dropdown]{--ds-auro-dropdown-trigger-background-color: transparent}:host #inputInBib::part(wrapper){box-shadow:none}:host #inputInBib::part(accent-left){display:none}:host #inputInBib::part(accent-right){display:none}:host([layout*=classic]) [auro-input]{width:100%}:host([layout*=classic]) [auro-input]::part(helpText){display:none}:host([layout*=classic]) #slotHolder{display:none}`;
15583
15628
 
15584
- var styleEmphasizedCss = css`:host([layout*=emphasized][shape*=pill]) [auro-input]{--ds-auro-input-background-color: var(--ds-advanced-color-dropdown-emphasized-background, rgba(0, 39, 74, 0.1019607843));--ds-auro-input-container-color: var(--ds-advanced-color-dropdown-emphasized-background, rgba(0, 39, 74, 0.1019607843));width:100%}:host([layout*=emphasized][shape*=pill]) [auro-input]:hover{--ds-auro-input-background-color: var(--ds-advanced-color-dropdown-emphasized-background-hover, rgba(0, 39, 74, 0.2));--ds-auro-input-container-color: var(--ds-advanced-color-dropdown-emphasized-background-hover, rgba(0, 39, 74, 0.2))}:host([layout*=emphasized][shape*=pill]) [auro-input]::part(inputHelpText){display:none}`;
15629
+ var styleEmphasizedCss = css`:host([layout*=emphasized][shape*=pill]) [auro-input]{--ds-auro-input-background-color: var(--ds-advanced-color-dropdown-emphasized-background, rgba(0, 39, 74, 0.1019607843));--ds-auro-input-container-color: var(--ds-advanced-color-dropdown-emphasized-background, rgba(0, 39, 74, 0.1019607843));width:100%}:host([layout*=emphasized][shape*=pill]) [auro-input]::part(inputHelpText){display:none}`;
15585
15630
 
15586
15631
  var styleSnowflakeCss = css`:host([layout*=snowflake][shape*=snowflake]) [auro-input]{width:100%}:host([layout*=snowflake][shape*=snowflake]) [auro-input]::part(inputHelpText){display:none}:host([layout*=snowflake][shape*=snowflake])::part(helpText){text-align:center}`;
15587
15632
 
@@ -15625,7 +15670,7 @@ class AuroElement extends LitElement {
15625
15670
  * @returns {boolean} - Returns true if the element has focus.
15626
15671
  */
15627
15672
  get componentHasFocus() {
15628
- return this.matches(':focus');
15673
+ return this.matches(':focus') || this.matches(':focus-within');
15629
15674
  }
15630
15675
 
15631
15676
  resetShapeClasses() {
@@ -15907,7 +15952,9 @@ class AuroHelpText extends LitElement {
15907
15952
  * @slot label - Defines the content of the label.
15908
15953
  * @slot helpText - Defines the content of the helpText.
15909
15954
  * @slot displayValue - Allows custom HTML content to display the selected value when the combobox is not focused. Only works with `snowflake` and `emphasized` layouts.
15910
- * @event auroCombobox-valueSet - Notifies that the component has a new value set.
15955
+ * @event auroCombobox-valueSet - (Deprecated) Notifies that the component has a new value set.
15956
+ * @event input - Notifies that the component has a new value set.
15957
+ * @event inputValue - Notifies that the components internal HTML5 input value has changed.
15911
15958
  * @event auroFormElement-validated - Notifies that the component value(s) have been validated.
15912
15959
  */
15913
15960
 
@@ -15917,75 +15964,60 @@ class AuroCombobox extends AuroElement {
15917
15964
  constructor() {
15918
15965
  super();
15919
15966
 
15920
- this.matchWidth = true;
15921
-
15922
- this.privateDefaults();
15923
- }
15924
-
15925
- /**
15926
- * @private
15927
- * @returns {void} Internal defaults.
15928
- */
15929
- privateDefaults() {
15930
- this.dropdownOpen = false;
15931
- this.dropdownId = undefined;
15932
- this.onDark = false;
15933
-
15934
- this.noFilter = false;
15935
- this.validity = undefined;
15936
- this.value = undefined;
15937
- this.optionSelected = undefined;
15938
-
15939
- this.checkmark = false;
15967
+ // Defaults that effect the combobox behavior and state
15940
15968
  this.disabled = false;
15969
+ this.msgSelectionMissing = 'Please select an option.';
15970
+ this.noFilter = false;
15941
15971
  this.noValidate = false;
15942
- this.required = false;
15943
- this.triggerIcon = false;
15944
-
15945
- this.availableOptions = [];
15946
15972
  this.optionActive = null;
15947
- this.msgSelectionMissing = 'Please select an option.';
15973
+ this.persistInput = false;
15974
+ this.required = false;
15975
+ this.value = undefined;
15976
+ this.typedValue = undefined;
15948
15977
 
15978
+ // Defaults that effect the overall layout of the combobox
15979
+ this.checkmark = false;
15980
+ this.dvInputOnly = false;
15949
15981
  this.fullscreenBreakpoint = 'sm';
15950
- this.largeFullscreenHeadline = false;
15951
-
15952
- this.validation = new AuroFormValidation$1();
15953
-
15954
- this.runtimeUtils = new AuroLibraryRuntimeUtils$6();
15955
-
15956
- this.isHiddenWhileLoading = false;
15957
-
15958
- // Error message
15959
- this.errorMessage = null;
15960
-
15961
- // Layout Config
15962
- /**
15963
- * @private
15964
- */
15965
15982
  this.layout = 'classic';
15966
-
15967
- /**
15968
- * @private
15969
- */
15983
+ this.matchWidth = true;
15970
15984
  this.shape = 'classic';
15971
-
15972
- /**
15973
- * @private
15974
- */
15975
15985
  this.size = 'xl';
15986
+ this.triggerIcon = false;
15976
15987
 
15977
- // floaterConfig
15988
+ // Defaults that effect the dropdown
15978
15989
  this.placement = 'bottom-start';
15979
15990
  this.offset = 0;
15980
15991
  this.noFlip = false;
15981
15992
  this.autoPlacement = false;
15982
15993
 
15994
+ this.privateDefaults();
15995
+ }
15996
+
15997
+ /**
15998
+ * @private
15999
+ * @returns {void} Internal defaults.
16000
+ */
16001
+ privateDefaults() {
15983
16002
  const versioning = new AuroDependencyVersioning$3();
15984
16003
 
15985
16004
  this.dropdownTag = versioning.generateTag('auro-formkit-combobox-dropdown', dropdownVersion, AuroDropdown);
15986
16005
  this.bibtemplateTag = versioning.generateTag('auro-formkit-combobox-bibtemplate', bibTemplateVersion, AuroBibtemplate);
15987
16006
  this.inputTag = versioning.generateTag('auro-formkit-combobox-input', inputVersion, AuroInput);
15988
16007
  this.helpTextTag = versioning.generateTag('auro-formkit-input-helptext', '1.0.0', AuroHelpText);
16008
+
16009
+ this.availableOptions = [];
16010
+ this.dropdownId = undefined;
16011
+ this.dropdownOpen = false;
16012
+ this.errorMessage = null;
16013
+ this.isHiddenWhileLoading = false;
16014
+ this.largeFullscreenHeadline = false;
16015
+ this.onDark = false;
16016
+ this.optionSelected = undefined;
16017
+ this.runtimeUtils = new AuroLibraryRuntimeUtils$6();
16018
+ this.touched = false;
16019
+ this.validation = new AuroFormValidation$1();
16020
+ this.validity = undefined;
15989
16021
  }
15990
16022
 
15991
16023
  // This function is to define props used within the scope of this component
@@ -16023,7 +16055,7 @@ class AuroCombobox extends AuroElement {
16023
16055
  },
16024
16056
 
16025
16057
  /**
16026
- * When attribute is present auro-menu will apply checkmarks to selected options.
16058
+ * When attribute is present auro-menu will apply check marks to selected options.
16027
16059
  */
16028
16060
  checkmark: {
16029
16061
  type: Boolean,
@@ -16058,6 +16090,14 @@ class AuroCombobox extends AuroElement {
16058
16090
  attribute: false
16059
16091
  },
16060
16092
 
16093
+ /**
16094
+ * If defined, the display value slot content will only mask the HTML5 input element. The inputs label will not be masked.
16095
+ */
16096
+ dvInputOnly: {
16097
+ type: Boolean,
16098
+ reflect: true
16099
+ },
16100
+
16061
16101
  /**
16062
16102
  * When defined, sets persistent validity to `customError` and sets the validation message to the attribute value.
16063
16103
  */
@@ -16140,6 +16180,17 @@ class AuroCombobox extends AuroElement {
16140
16180
  type: Object
16141
16181
  },
16142
16182
 
16183
+ /**
16184
+ * If declared, selecting a menu option will not change the input value. By doing so,
16185
+ * the current menu filter will be preserved and the user can continue from their last
16186
+ * filter state. It is recommended to use this in combination with the `displayValue` slot.
16187
+ * @type {Boolean}
16188
+ */
16189
+ persistInput: {
16190
+ type: Boolean,
16191
+ reflect: true
16192
+ },
16193
+
16143
16194
  /* eslint-disable jsdoc/require-description-complete-sentence */
16144
16195
  /**
16145
16196
  * Position where the bib should appear relative to the trigger.
@@ -16193,6 +16244,18 @@ class AuroCombobox extends AuroElement {
16193
16244
  type: String
16194
16245
  },
16195
16246
 
16247
+ /**
16248
+ * Indicates whether the combobox is in a dirty state (has been interacted with).
16249
+ * @type {boolean}
16250
+ * @default false
16251
+ * @private
16252
+ */
16253
+ touched: {
16254
+ type: Boolean,
16255
+ reflect: true,
16256
+ attribute: false
16257
+ },
16258
+
16196
16259
  /**
16197
16260
  * If set, the `icon` attribute will be applied to the trigger `auro-input` element.
16198
16261
  */
@@ -16209,6 +16272,14 @@ class AuroCombobox extends AuroElement {
16209
16272
  reflect: true
16210
16273
  },
16211
16274
 
16275
+ /**
16276
+ * Specifies the value of the input element within the combobox.
16277
+ */
16278
+ typedValue: {
16279
+ type: String,
16280
+ reflect: true
16281
+ },
16282
+
16212
16283
  /**
16213
16284
  * Specifies the `validityState` this element is in.
16214
16285
  */
@@ -16268,6 +16339,24 @@ class AuroCombobox extends AuroElement {
16268
16339
  ];
16269
16340
  }
16270
16341
 
16342
+ /**
16343
+ * Returns the current value of the input element within the combobox.
16344
+ * @returns {string|undefined} The value of the input element, or undefined if the input is not present.
16345
+ */
16346
+ get inputValue() {
16347
+ if (!this.input) {
16348
+ return undefined;
16349
+ }
16350
+ return this.input.value;
16351
+ }
16352
+
16353
+ // /**
16354
+ // * Sets the value of the input element within the combobox.
16355
+ // */
16356
+ // set inputValue(value) {
16357
+ // this.input.value = value;
16358
+ // }
16359
+
16271
16360
  /**
16272
16361
  * Checks if the element is valid.
16273
16362
  * @returns {boolean} - Returns true if the element is valid, false otherwise.
@@ -16356,11 +16445,38 @@ class AuroCombobox extends AuroElement {
16356
16445
  // Wait a lifecycle for child components to update
16357
16446
  await Promise.all([this.menu.updateComplete]);
16358
16447
 
16359
- if (this.menu.optionSelected && this.menu.optionSelected.textContent.length > 0) {
16360
- this.input.value = this.menu.optionSelected.textContent;
16361
- } else {
16362
- this.input.value = this.value;
16448
+ this.updateTriggerTextDisplay();
16449
+ }
16450
+
16451
+ /**
16452
+ * Update displayValue or input.value, it's called when making a selection.
16453
+ * @private
16454
+ */
16455
+ updateTriggerTextDisplay() {
16456
+ // update the input content if persistInput is false
16457
+ if (!this.persistInput) {
16458
+ if (this.menu.optionSelected && this.menu.optionSelected.textContent.length > 0) {
16459
+ this.input.value = this.menu.optionSelected.textContent;
16460
+ } else {
16461
+ this.input.value = this.value;
16462
+ }
16463
+ }
16464
+
16465
+ // update the displayValue in the trigger if displayValue slot content is present
16466
+ const displayValueInTrigger = this.input.querySelector('[slot="displayValue"]');
16467
+
16468
+ if (displayValueInTrigger) {
16469
+ displayValueInTrigger.remove();
16470
+ }
16471
+
16472
+ if (this.menu.optionSelected) {
16473
+ const displayValueEl = this.menu.optionSelected.querySelector("[slot='displayValue']");
16474
+ if (displayValueEl) {
16475
+ this.input.appendChild(displayValueEl.cloneNode(true));
16476
+ }
16363
16477
  }
16478
+
16479
+ this.requestUpdate();
16364
16480
  }
16365
16481
 
16366
16482
  /**
@@ -16382,11 +16498,15 @@ class AuroCombobox extends AuroElement {
16382
16498
  * @returns {void}
16383
16499
  */
16384
16500
  handleMenuOptions() {
16385
-
16386
16501
  this.resetMenuMatchword();
16502
+
16387
16503
  this.generateOptionsArray();
16388
16504
  this.availableOptions = [];
16389
16505
  this.updateFilter();
16506
+
16507
+ if (this.value && this.input.value && !this.menu.value) {
16508
+ this.syncValuesAndStates();
16509
+ }
16390
16510
  }
16391
16511
 
16392
16512
  /**
@@ -16484,14 +16604,29 @@ class AuroCombobox extends AuroElement {
16484
16604
  });
16485
16605
  }
16486
16606
 
16607
+ /**
16608
+ * @private
16609
+ */
16610
+ setClearBtnFocus() {
16611
+ const clearBtn = this.input.shadowRoot.querySelector('.clearBtn');
16612
+ if (clearBtn) {
16613
+ clearBtn.focus();
16614
+ }
16615
+ }
16616
+
16487
16617
  /**
16488
16618
  * @private
16489
16619
  */
16490
16620
  setInputFocus() {
16491
16621
  if (this.dropdown.isBibFullscreen && this.dropdown.isPopoverVisible) {
16492
16622
  this.inputInBib.focus();
16493
- } else {
16623
+ } else if (!this.input.componentHasFocus) {
16624
+ const focusedEl = this.querySelector(":focus");
16494
16625
  this.input.focus();
16626
+ // current focus is on a menuoption, after clicking on it.
16627
+ if (this.persistInput && focusedEl && (focusedEl.tagName.toLowerCase() === 'auro-menuoption' || focusedEl.hasAttribute('auro-menuoption'))) {
16628
+ this.setClearBtnFocus();
16629
+ }
16495
16630
  }
16496
16631
  }
16497
16632
 
@@ -16527,6 +16662,8 @@ class AuroCombobox extends AuroElement {
16527
16662
  configureMenu() {
16528
16663
  this.menu = this.querySelector('auro-menu, [auro-menu]');
16529
16664
 
16665
+ this.menu.value = this.value;
16666
+
16530
16667
  this.updateMenuShapeSize();
16531
16668
 
16532
16669
  // a racing condition on custom-combobox with custom-menu
@@ -16547,7 +16684,7 @@ class AuroCombobox extends AuroElement {
16547
16684
  }
16548
16685
 
16549
16686
  // handle the menu event for an option selection
16550
- this.menu.addEventListener('auroMenu-selectedOption', () => {
16687
+ this.menu.addEventListener('auroMenu-selectedOption', (evt) => {
16551
16688
  if (this.menu.optionSelected) {
16552
16689
  const selected = this.menu.optionSelected;
16553
16690
 
@@ -16557,12 +16694,10 @@ class AuroCombobox extends AuroElement {
16557
16694
 
16558
16695
  if (!this.value || this.value !== this.optionSelected.value) {
16559
16696
  this.value = this.optionSelected.value;
16560
- this.menu.value = this.value;
16697
+ // this.menu.value = this.value;
16561
16698
  }
16562
16699
 
16563
- if (this.input.value !== this.optionSelected.textContent) {
16564
- this.input.value = this.optionSelected.textContent;
16565
- }
16700
+ this.updateTriggerTextDisplay();
16566
16701
 
16567
16702
  if (this.menu.matchWord !== this.input.value) {
16568
16703
  this.menu.matchWord = this.input.value;
@@ -16570,18 +16705,14 @@ class AuroCombobox extends AuroElement {
16570
16705
 
16571
16706
  // update the hidden state of options based on newly selected value
16572
16707
  this.handleMenuOptions();
16573
-
16574
- this.dispatchEvent(new CustomEvent('auroCombobox-valueSet', {
16575
- bubbles: true,
16576
- cancelable: false,
16577
- composed: true,
16578
- }));
16579
16708
  }
16580
16709
 
16581
16710
  // dropdown bib should hide when making a selection
16582
- setTimeout(() => {
16583
- this.hideBib();
16584
- }, 0);
16711
+ if (evt.detail && evt.detail.source !== 'slotchange') {
16712
+ setTimeout(() => {
16713
+ this.hideBib();
16714
+ }, 0);
16715
+ }
16585
16716
  });
16586
16717
 
16587
16718
  this.menu.addEventListener('auroMenu-customEventFired', () => {
@@ -16623,12 +16754,8 @@ class AuroCombobox extends AuroElement {
16623
16754
  }
16624
16755
  });
16625
16756
 
16626
- // Handle validation messages from auroFormElement-validated event
16627
- this.input.addEventListener('auroFormElement-validated', (evt) => {
16628
- // not to bubble up input's validated event.
16629
- evt.stopPropagation();
16630
-
16631
- this.errorMessage = evt.detail.message;
16757
+ this.input.addEventListener('input', () => {
16758
+ this.dispatchEvent(new CustomEvent('inputValue', { detail: { value: this.inputValue} }));
16632
16759
  });
16633
16760
  }
16634
16761
 
@@ -16672,29 +16799,9 @@ class AuroCombobox extends AuroElement {
16672
16799
  this.menu.matchWord = this.input.value;
16673
16800
  this.optionActive = null;
16674
16801
 
16675
- let hasChange = false;
16676
-
16677
- if (!this.value || this.value !== this.input.value) {
16678
- this.menu.value = this.input.value;
16679
- this.value = this.menu.value;
16680
- hasChange = true;
16681
- this.dispatchEvent(new CustomEvent('auroCombobox-valueSet', {
16682
- bubbles: true,
16683
- cancelable: false,
16684
- composed: true,
16685
- }));
16686
- }
16687
-
16688
- if (this.optionSelected && this.input.value !== this.optionSelected.textContent) {
16689
- this.optionSelected = undefined;
16690
- hasChange = true;
16691
- }
16692
-
16693
- if (!hasChange) {
16694
- return;
16802
+ if (!this.input.value) {
16803
+ this.clear();
16695
16804
  }
16696
-
16697
- this.menu.clearSelection();
16698
16805
  this.handleMenuOptions();
16699
16806
 
16700
16807
  // Validate only if the value was set programmatically
@@ -16719,10 +16826,16 @@ class AuroCombobox extends AuroElement {
16719
16826
  * @returns {void}
16720
16827
  */
16721
16828
  configureCombobox() {
16722
- this.addEventListener('keydown', (evt) => {
16829
+ this.addEventListener('keydown', async (evt) => {
16723
16830
  if (evt.key === 'Enter') {
16724
16831
  if (this.dropdown.isPopoverVisible && this.optionActive) {
16725
16832
  this.menu.makeSelection();
16833
+
16834
+ await this.updateComplete;
16835
+
16836
+ evt.preventDefault();
16837
+ evt.stopPropagation();
16838
+ this.setClearBtnFocus();
16726
16839
  } else {
16727
16840
  this.showBib();
16728
16841
  }
@@ -16737,6 +16850,10 @@ class AuroCombobox extends AuroElement {
16737
16850
  this.dropdown.focus();
16738
16851
  }
16739
16852
  } else {
16853
+ if (this.menu.optionActive && this.menu.optionActive.value) {
16854
+ this.menu.value = this.menu.optionActive.value;
16855
+ }
16856
+
16740
16857
  setTimeout(() => {
16741
16858
  if (!this.componentHasFocus) {
16742
16859
  this.hideBib();
@@ -16766,8 +16883,15 @@ class AuroCombobox extends AuroElement {
16766
16883
  });
16767
16884
 
16768
16885
  this.addEventListener('focusin', () => {
16886
+ this.touched = true;
16887
+
16769
16888
  this.focus();
16770
16889
  });
16890
+
16891
+ this.addEventListener('auroFormElement-validated', (evt) => {
16892
+ this.input.validity = evt.detail.validity;
16893
+ this.input.errorMessage = evt.detail.message;
16894
+ });
16771
16895
  }
16772
16896
 
16773
16897
  /**
@@ -16812,7 +16936,9 @@ class AuroCombobox extends AuroElement {
16812
16936
  * @returns {void}
16813
16937
  */
16814
16938
  focus() {
16815
- this.input.focus();
16939
+ if (!this.componentHasFocus) {
16940
+ this.input.focus();
16941
+ }
16816
16942
  }
16817
16943
 
16818
16944
  /**
@@ -16820,8 +16946,13 @@ class AuroCombobox extends AuroElement {
16820
16946
  * @returns {void}
16821
16947
  */
16822
16948
  reset() {
16823
- this.input.reset();
16949
+ this.optionSelected = undefined;
16950
+ this.value = undefined;
16951
+ this.typedValue = undefined;
16952
+ this.input.value = undefined;
16953
+ this.menu.value = undefined;
16824
16954
  this.validation.reset(this);
16955
+ this.touched = false;
16825
16956
  }
16826
16957
 
16827
16958
  /**
@@ -16830,6 +16961,11 @@ class AuroCombobox extends AuroElement {
16830
16961
  */
16831
16962
  clear() {
16832
16963
  this.input.clear();
16964
+ if (this.menu.value || this.menu.optionSelected) {
16965
+ this.menu.reset();
16966
+ }
16967
+ this.optionSelected = undefined;
16968
+ this.value = undefined;
16833
16969
  }
16834
16970
 
16835
16971
  /**
@@ -16842,7 +16978,16 @@ class AuroCombobox extends AuroElement {
16842
16978
 
16843
16979
  async updated(changedProperties) {
16844
16980
  // After the component is ready, send direct value changes to auro-menu.
16845
- if (changedProperties.has('value') && this.value !== changedProperties.get('value')) {
16981
+ if (changedProperties.has('value')) {
16982
+ if (this.value && this.value.length > 0) {
16983
+ this.hasValue = true;
16984
+ } else {
16985
+ this.hasValue = false;
16986
+ }
16987
+
16988
+ if (this.hasValue && !this.input.value && (!this.menu.availableOptions || this.menu.availableOptions.length === 0)) {
16989
+ this.input.value = this.value;
16990
+ }
16846
16991
 
16847
16992
  if (this.value) {
16848
16993
  // If the value got set programmatically make sure we hide the bib
@@ -16856,6 +17001,19 @@ class AuroCombobox extends AuroElement {
16856
17001
 
16857
17002
  // Sync the input, menu, and optionSelected states
16858
17003
  await this.syncValuesAndStates();
17004
+
17005
+ this.dispatchEvent(new CustomEvent('input', {
17006
+ bubbles: true,
17007
+ cancelable: false,
17008
+ composed: true,
17009
+ }));
17010
+
17011
+ // Deprecated, need to be removed.
17012
+ this.dispatchEvent(new CustomEvent('auroCombobox-valueSet', {
17013
+ bubbles: true,
17014
+ cancelable: false,
17015
+ composed: true,
17016
+ }));
16859
17017
  }
16860
17018
 
16861
17019
  if (changedProperties.has('availableOptions')) {
@@ -16898,6 +17056,16 @@ class AuroCombobox extends AuroElement {
16898
17056
  });
16899
17057
  }
16900
17058
 
17059
+ /**
17060
+ * Updates the active option in the menu.
17061
+ * @param {number} index - Index of the option to make active.
17062
+ */
17063
+ updateActiveOption(index) {
17064
+ if (this.menu) {
17065
+ this.menu.updateActiveOption(index);
17066
+ }
17067
+ }
17068
+
16901
17069
  /**
16902
17070
  * Watch for slot changes and recalculate the menuoptions.
16903
17071
  * @private
@@ -16907,6 +17075,10 @@ class AuroCombobox extends AuroElement {
16907
17075
  handleSlotChange(event) {
16908
17076
  switch (event.target.name) {
16909
17077
  case '':
17078
+ if (!this.menu || this.menu !== this.querySelector('auro-menu, [auro-menu]')) {
17079
+ this.configureMenu();
17080
+ }
17081
+
16910
17082
  // Treat only generic menuoptions.
16911
17083
  this.options = this.menu.querySelectorAll('auro-menuoption, [auro-menuoption]');
16912
17084
  this.options.forEach((opt) => {
@@ -16983,14 +17155,16 @@ class AuroCombobox extends AuroElement {
16983
17155
  .inputmode="${this.inputmode}"
16984
17156
  .placeholder="${this.placeholder}"
16985
17157
  .type="${this.type}"
17158
+ .value="${this.typedValue}"
16986
17159
  ?disabled="${this.disabled}"
16987
17160
  ?icon="${this.triggerIcon}"
16988
- ?noValidate="${this.noValidate}"
17161
+ ?dvInputOnly="${this.dvInputOnly}"
16989
17162
  ?onDark="${this.onDark}"
16990
17163
  ?required="${this.required}"
16991
17164
  a11yRole="combobox"
16992
17165
  id="${this.id}"
16993
17166
  layout="${this.layout}"
17167
+ noValidate="true"
16994
17168
  setCustomValidity="${this.setCustomValidity}"
16995
17169
  setCustomValidityCustomError="${this.setCustomValidityCustomError}"
16996
17170
  setCustomValidityValueMissing="${this.setCustomValidityValueMissing}"
@@ -17006,7 +17180,7 @@ class AuroCombobox extends AuroElement {
17006
17180
  <${this.bibtemplateTag} ?large="${this.largeFullscreenHeadline}">
17007
17181
  <slot name="bib.fullscreen.headline" slot="header"></slot>
17008
17182
  <slot name="ariaLabel.bib.close" slot="ariaLabel.close">Close</slot>
17009
- <slot></slot>
17183
+ <slot @slotchange="${this.handleSlotChange}"></slot>
17010
17184
  <${this.inputTag}
17011
17185
  id="inputInBib"
17012
17186
  @input="${this.handleInputValueChange}"
@@ -17016,6 +17190,7 @@ class AuroCombobox extends AuroElement {
17016
17190
  .inputmode="${this.inputmode}"
17017
17191
  .placeholder="${this.placeholder}"
17018
17192
  .type="${this.type}"
17193
+ .value="${this.typedValue}"
17019
17194
  ?disabled="${this.disabled}"
17020
17195
  ?icon="${this.triggerIcon}"
17021
17196
  ?required="${this.required}"