@aurodesignsystem-dev/auro-formkit 0.0.0-pr1052.0 → 0.0.0-pr1052.10

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 (42) hide show
  1. package/components/combobox/README.md +2 -0
  2. package/components/combobox/demo/api.md +96 -57
  3. package/components/combobox/demo/api.min.js +353 -144
  4. package/components/combobox/demo/index.md +2 -0
  5. package/components/combobox/demo/index.min.js +332 -133
  6. package/components/combobox/demo/readme.md +2 -0
  7. package/components/combobox/dist/auro-combobox.d.ts +81 -33
  8. package/components/combobox/dist/index.js +294 -118
  9. package/components/combobox/dist/registered.js +294 -118
  10. package/components/counter/demo/api.min.js +2 -2
  11. package/components/counter/demo/index.min.js +2 -2
  12. package/components/counter/dist/index.js +2 -2
  13. package/components/counter/dist/registered.js +2 -2
  14. package/components/datepicker/demo/api.min.js +54 -14
  15. package/components/datepicker/demo/index.min.js +54 -14
  16. package/components/datepicker/dist/index.js +54 -14
  17. package/components/datepicker/dist/registered.js +54 -14
  18. package/components/dropdown/demo/api.min.js +1 -1
  19. package/components/dropdown/demo/index.min.js +1 -1
  20. package/components/dropdown/dist/index.js +1 -1
  21. package/components/dropdown/dist/registered.js +1 -1
  22. package/components/input/demo/api.md +48 -46
  23. package/components/input/demo/api.min.js +52 -12
  24. package/components/input/demo/index.md +6 -1
  25. package/components/input/demo/index.min.js +52 -12
  26. package/components/input/dist/auro-input.d.ts +4 -0
  27. package/components/input/dist/base-input.d.ts +9 -1
  28. package/components/input/dist/index.js +52 -12
  29. package/components/input/dist/registered.js +52 -12
  30. package/components/layoutElement/dist/index.js +1 -1
  31. package/components/layoutElement/dist/registered.js +1 -1
  32. package/components/menu/demo/api.md +4 -3
  33. package/components/menu/demo/api.min.js +39 -16
  34. package/components/menu/demo/index.min.js +39 -16
  35. package/components/menu/dist/auro-menu.d.ts +3 -3
  36. package/components/menu/dist/index.js +39 -16
  37. package/components/menu/dist/registered.js +39 -16
  38. package/components/select/demo/api.min.js +40 -17
  39. package/components/select/demo/index.min.js +40 -17
  40. package/components/select/dist/index.js +2 -2
  41. package/components/select/dist/registered.js +2 -2
  42. 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() {
@@ -10147,7 +10147,7 @@ let AuroElement$2$1 = class AuroElement extends LitElement {
10147
10147
  * @returns {boolean} - Returns true if the element has focus.
10148
10148
  */
10149
10149
  get componentHasFocus() {
10150
- return this.matches(':focus');
10150
+ return this.matches(':focus') || this.matches(':focus-within');
10151
10151
  }
10152
10152
 
10153
10153
  resetShapeClasses() {
@@ -10221,7 +10221,7 @@ let AuroElement$2$1 = class AuroElement extends LitElement {
10221
10221
  * @prop {string} id - The id global attribute defines an identifier (ID) which must be unique in the whole document.
10222
10222
  * @attr id
10223
10223
  *
10224
- * @slot ariaLabel.clear - Sets aria-label on clear button for screenreader to read
10224
+ * @slot ariaLabel.clear - Sets aria-label on clear button for screen reader to read
10225
10225
  * @slot ariaLabel.password.show - Sets aria-label on password button to toggle on showing password
10226
10226
  * @slot ariaLabel.password.hide - Sets aria-label on password button to toggle off showing password
10227
10227
  * @slot helpText - Sets the help text displayed below the input.
@@ -10249,6 +10249,7 @@ class BaseInput extends AuroElement$2$1 {
10249
10249
  this.activeLabel = false;
10250
10250
  this.icon = false;
10251
10251
  this.disabled = false;
10252
+ this.dvInputOnly = false;
10252
10253
  this.max = undefined;
10253
10254
  this.maxLength = undefined;
10254
10255
  this.min = undefined;
@@ -10342,6 +10343,14 @@ class BaseInput extends AuroElement$2$1 {
10342
10343
  return {
10343
10344
  ...super.properties,
10344
10345
 
10346
+ /**
10347
+ * If defined, the display value slot content will only mask the HTML5 input element. The inputs label will not be masked.
10348
+ */
10349
+ dvInputOnly: {
10350
+ type: Boolean,
10351
+ reflect: true
10352
+ },
10353
+
10345
10354
  /**
10346
10355
  * The value for the role attribute.
10347
10356
  */
@@ -13107,7 +13116,13 @@ class AuroInput extends BaseInput {
13107
13116
  * @private
13108
13117
  */
13109
13118
  get inputHidden() {
13110
- return (this.hasDisplayValueContent && !this.hasFocus && this.hasValue) || ((!this.value || this.value.length === 0) && !this.hasFocus && (!this.placeholder || this.placeholder === ''));
13119
+ return (
13120
+ this.hasDisplayValueContent && !this.hasFocus && this.hasValue) ||
13121
+ (
13122
+ (!this.value || this.value.length === 0) &&
13123
+ !this.hasFocus &&
13124
+ (!this.placeholder || this.placeholder === '')
13125
+ );
13111
13126
  }
13112
13127
 
13113
13128
  /**
@@ -13127,7 +13142,7 @@ class AuroInput extends BaseInput {
13127
13142
  * @private
13128
13143
  */
13129
13144
  get labelHidden() {
13130
- return this.hasDisplayValueContent && !this.hasFocus && this.hasValue;
13145
+ return this.hasDisplayValueContent && !this.dvInputOnly && !this.hasFocus && this.hasValue;
13131
13146
  }
13132
13147
 
13133
13148
  /**
@@ -13136,18 +13151,26 @@ class AuroInput extends BaseInput {
13136
13151
  * @returns {string} - The font class for the label.
13137
13152
  */
13138
13153
  get labelFontClass() {
13139
- const isHidden = this.inputHidden;
13140
-
13141
13154
  if (this.layout.startsWith('emphasized')) {
13142
- return this.noFocusOrValue ? 'accent-xl' : 'body-sm';
13155
+ let typeSize = 'body-sm';
13156
+
13157
+ if (this.hasDisplayValueContent) {
13158
+ if (!this.hasValue) {
13159
+ typeSize = 'accent-xl';
13160
+ }
13161
+ } else if (this.noFocusOrValue) {
13162
+ typeSize = 'accent-xl';
13163
+ }
13164
+
13165
+ return typeSize;
13143
13166
  }
13144
13167
 
13145
13168
  if (this.layout === 'snowflake') {
13146
- return isHidden ? 'body-lg' : 'body-xs';
13169
+ return this.hasValue || this.hasFocus || this.placeholder ? 'body-xs' : 'body-lg';
13147
13170
  }
13148
13171
 
13149
13172
  // classic layout (default)
13150
- return isHidden ? 'body-default' : 'body-xs';
13173
+ return ((!this.value || this.value.length === 0) && !this.placeholder && !this.hasFocus) ? 'body-default' : 'body-xs';
13151
13174
  }
13152
13175
 
13153
13176
  /**
@@ -13157,7 +13180,17 @@ class AuroInput extends BaseInput {
13157
13180
  */
13158
13181
  get inputFontClass() {
13159
13182
  if (this.layout.startsWith('emphasized')) {
13160
- return this.noFocusOrValue ? 'body-sm' : 'accent-xl';
13183
+ let typeSize = 'accent-xl';
13184
+
13185
+ if (this.hasDisplayValueContent) {
13186
+ if (!this.hasValue) {
13187
+ typeSize = 'body-sm';
13188
+ }
13189
+ } else if (this.noFocusOrValue) {
13190
+ typeSize = 'body-sm';
13191
+ }
13192
+
13193
+ return typeSize;
13161
13194
  }
13162
13195
 
13163
13196
  if (this.layout === 'snowflake') {
@@ -13200,6 +13233,13 @@ class AuroInput extends BaseInput {
13200
13233
  };
13201
13234
  }
13202
13235
 
13236
+ get commonDisplayValueWrapperClasses() {
13237
+ return {
13238
+ 'displayValueWrapper': true,
13239
+ [this.inputFontClass]: true,
13240
+ };
13241
+ }
13242
+
13203
13243
  /**
13204
13244
  * Returns classmap configuration for html5 inputs in each layout.
13205
13245
  * @private
@@ -13272,7 +13312,7 @@ class AuroInput extends BaseInput {
13272
13312
  let nodes = this.shadowRoot.querySelector('slot[name="displayValue"]').assignedNodes();
13273
13313
 
13274
13314
  // Handle when DisplayValue is multi-level slot content (e.g. combobox passing displayValue to input)
13275
- if (nodes[0].tagName === 'SLOT') {
13315
+ if (nodes && nodes[0] && nodes[0].tagName === 'SLOT') {
13276
13316
  nodes = nodes[0].assignedNodes();
13277
13317
  }
13278
13318
 
@@ -13363,7 +13403,7 @@ class AuroInput extends BaseInput {
13363
13403
  type="${this.type === "password" && this.showPassword ? "text" : this.getInputType(this.type)}"
13364
13404
  />
13365
13405
  <div class="${classMap(displayValueClasses)}" aria-hidden="true" part="displayValue">
13366
- <div class="displayValueWrapper">
13406
+ <div class="${classMap(this.commonDisplayValueWrapperClasses)}">
13367
13407
  <slot name="displayValue" @slotchange=${this.checkDisplayValueSlotChange}></slot>
13368
13408
  </div>
13369
13409
  </div>
@@ -15625,7 +15665,7 @@ class AuroElement extends LitElement {
15625
15665
  * @returns {boolean} - Returns true if the element has focus.
15626
15666
  */
15627
15667
  get componentHasFocus() {
15628
- return this.matches(':focus');
15668
+ return this.matches(':focus') || this.matches(':focus-within');
15629
15669
  }
15630
15670
 
15631
15671
  resetShapeClasses() {
@@ -15907,7 +15947,9 @@ class AuroHelpText extends LitElement {
15907
15947
  * @slot label - Defines the content of the label.
15908
15948
  * @slot helpText - Defines the content of the helpText.
15909
15949
  * @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.
15950
+ * @event auroCombobox-valueSet - (Deprecated) Notifies that the component has a new value set.
15951
+ * @event input - Notifies that the component has a new value set.
15952
+ * @event inputValue - Notifies that the components internal HTML5 input value has changed.
15911
15953
  * @event auroFormElement-validated - Notifies that the component value(s) have been validated.
15912
15954
  */
15913
15955
 
@@ -15917,75 +15959,60 @@ class AuroCombobox extends AuroElement {
15917
15959
  constructor() {
15918
15960
  super();
15919
15961
 
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;
15962
+ // Defaults that effect the combobox behavior and state
15940
15963
  this.disabled = false;
15964
+ this.msgSelectionMissing = 'Please select an option.';
15965
+ this.noFilter = false;
15941
15966
  this.noValidate = false;
15942
- this.required = false;
15943
- this.triggerIcon = false;
15944
-
15945
- this.availableOptions = [];
15946
15967
  this.optionActive = null;
15947
- this.msgSelectionMissing = 'Please select an option.';
15968
+ this.persistInput = false;
15969
+ this.required = false;
15970
+ this.value = undefined;
15971
+ this.typedValue = undefined;
15948
15972
 
15973
+ // Defaults that effect the overall layout of the combobox
15974
+ this.checkmark = false;
15975
+ this.dvInputOnly = false;
15949
15976
  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
15977
  this.layout = 'classic';
15966
-
15967
- /**
15968
- * @private
15969
- */
15978
+ this.matchWidth = true;
15970
15979
  this.shape = 'classic';
15971
-
15972
- /**
15973
- * @private
15974
- */
15975
15980
  this.size = 'xl';
15981
+ this.triggerIcon = false;
15976
15982
 
15977
- // floaterConfig
15983
+ // Defaults that effect the dropdown
15978
15984
  this.placement = 'bottom-start';
15979
15985
  this.offset = 0;
15980
15986
  this.noFlip = false;
15981
15987
  this.autoPlacement = false;
15982
15988
 
15989
+ this.privateDefaults();
15990
+ }
15991
+
15992
+ /**
15993
+ * @private
15994
+ * @returns {void} Internal defaults.
15995
+ */
15996
+ privateDefaults() {
15983
15997
  const versioning = new AuroDependencyVersioning$3();
15984
15998
 
15985
15999
  this.dropdownTag = versioning.generateTag('auro-formkit-combobox-dropdown', dropdownVersion, AuroDropdown);
15986
16000
  this.bibtemplateTag = versioning.generateTag('auro-formkit-combobox-bibtemplate', bibTemplateVersion, AuroBibtemplate);
15987
16001
  this.inputTag = versioning.generateTag('auro-formkit-combobox-input', inputVersion, AuroInput);
15988
16002
  this.helpTextTag = versioning.generateTag('auro-formkit-input-helptext', '1.0.0', AuroHelpText);
16003
+
16004
+ this.availableOptions = [];
16005
+ this.dropdownId = undefined;
16006
+ this.dropdownOpen = false;
16007
+ this.errorMessage = null;
16008
+ this.isHiddenWhileLoading = false;
16009
+ this.largeFullscreenHeadline = false;
16010
+ this.onDark = false;
16011
+ this.optionSelected = undefined;
16012
+ this.runtimeUtils = new AuroLibraryRuntimeUtils$6();
16013
+ this.touched = false;
16014
+ this.validation = new AuroFormValidation$1();
16015
+ this.validity = undefined;
15989
16016
  }
15990
16017
 
15991
16018
  // This function is to define props used within the scope of this component
@@ -16023,7 +16050,7 @@ class AuroCombobox extends AuroElement {
16023
16050
  },
16024
16051
 
16025
16052
  /**
16026
- * When attribute is present auro-menu will apply checkmarks to selected options.
16053
+ * When attribute is present auro-menu will apply check marks to selected options.
16027
16054
  */
16028
16055
  checkmark: {
16029
16056
  type: Boolean,
@@ -16058,6 +16085,14 @@ class AuroCombobox extends AuroElement {
16058
16085
  attribute: false
16059
16086
  },
16060
16087
 
16088
+ /**
16089
+ * If defined, the display value slot content will only mask the HTML5 input element. The inputs label will not be masked.
16090
+ */
16091
+ dvInputOnly: {
16092
+ type: Boolean,
16093
+ reflect: true
16094
+ },
16095
+
16061
16096
  /**
16062
16097
  * When defined, sets persistent validity to `customError` and sets the validation message to the attribute value.
16063
16098
  */
@@ -16140,6 +16175,17 @@ class AuroCombobox extends AuroElement {
16140
16175
  type: Object
16141
16176
  },
16142
16177
 
16178
+ /**
16179
+ * If declared, selecting a menu option will not change the input value. By doing so,
16180
+ * the current menu filter will be preserved and the user can continue from their last
16181
+ * filter state. It is recommended to use this in combination with the `displayValue` slot.
16182
+ * @type {Boolean}
16183
+ */
16184
+ persistInput: {
16185
+ type: Boolean,
16186
+ reflect: true
16187
+ },
16188
+
16143
16189
  /* eslint-disable jsdoc/require-description-complete-sentence */
16144
16190
  /**
16145
16191
  * Position where the bib should appear relative to the trigger.
@@ -16193,6 +16239,18 @@ class AuroCombobox extends AuroElement {
16193
16239
  type: String
16194
16240
  },
16195
16241
 
16242
+ /**
16243
+ * Indicates whether the combobox is in a dirty state (has been interacted with).
16244
+ * @type {boolean}
16245
+ * @default false
16246
+ * @private
16247
+ */
16248
+ touched: {
16249
+ type: Boolean,
16250
+ reflect: true,
16251
+ attribute: false
16252
+ },
16253
+
16196
16254
  /**
16197
16255
  * If set, the `icon` attribute will be applied to the trigger `auro-input` element.
16198
16256
  */
@@ -16209,6 +16267,14 @@ class AuroCombobox extends AuroElement {
16209
16267
  reflect: true
16210
16268
  },
16211
16269
 
16270
+ /**
16271
+ * Specifies the value of the input element within the combobox.
16272
+ */
16273
+ typedValue: {
16274
+ type: String,
16275
+ reflect: true
16276
+ },
16277
+
16212
16278
  /**
16213
16279
  * Specifies the `validityState` this element is in.
16214
16280
  */
@@ -16268,6 +16334,24 @@ class AuroCombobox extends AuroElement {
16268
16334
  ];
16269
16335
  }
16270
16336
 
16337
+ /**
16338
+ * Returns the current value of the input element within the combobox.
16339
+ * @returns {string|undefined} The value of the input element, or undefined if the input is not present.
16340
+ */
16341
+ get inputValue() {
16342
+ if (!this.input) {
16343
+ return undefined;
16344
+ }
16345
+ return this.input.value;
16346
+ }
16347
+
16348
+ // /**
16349
+ // * Sets the value of the input element within the combobox.
16350
+ // */
16351
+ // set inputValue(value) {
16352
+ // this.input.value = value;
16353
+ // }
16354
+
16271
16355
  /**
16272
16356
  * Checks if the element is valid.
16273
16357
  * @returns {boolean} - Returns true if the element is valid, false otherwise.
@@ -16353,13 +16437,43 @@ class AuroCombobox extends AuroElement {
16353
16437
  this.menu.value = this.value;
16354
16438
  this.menu.matchWord = this.input.value;
16355
16439
 
16440
+ console.warn('syncValuesAndStates()');
16441
+ console.info('this.value', this.value);
16442
+ console.info('this.input.value', this.input.value);
16443
+ console.info('this.menu.value', this.menu.value);
16444
+
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
  }
16364
16478
  }
16365
16479
 
@@ -16382,11 +16496,16 @@ class AuroCombobox extends AuroElement {
16382
16496
  * @returns {void}
16383
16497
  */
16384
16498
  handleMenuOptions() {
16385
-
16499
+ console.warn('handleMenuOptions()');
16386
16500
  this.resetMenuMatchword();
16501
+
16387
16502
  this.generateOptionsArray();
16388
16503
  this.availableOptions = [];
16389
16504
  this.updateFilter();
16505
+
16506
+ if (this.value && this.input.value && !this.menu.value) {
16507
+ this.syncValuesAndStates();
16508
+ }
16390
16509
  }
16391
16510
 
16392
16511
  /**
@@ -16484,14 +16603,29 @@ class AuroCombobox extends AuroElement {
16484
16603
  });
16485
16604
  }
16486
16605
 
16606
+ /**
16607
+ * @private
16608
+ */
16609
+ setClearBtnFocus() {
16610
+ const clearBtn = this.input.shadowRoot.querySelector('.clearBtn');
16611
+ if (clearBtn) {
16612
+ clearBtn.focus();
16613
+ }
16614
+ }
16615
+
16487
16616
  /**
16488
16617
  * @private
16489
16618
  */
16490
16619
  setInputFocus() {
16491
16620
  if (this.dropdown.isBibFullscreen && this.dropdown.isPopoverVisible) {
16492
16621
  this.inputInBib.focus();
16493
- } else {
16622
+ } else if (!this.input.componentHasFocus) {
16623
+ const focusedEl = this.querySelector(":focus");
16494
16624
  this.input.focus();
16625
+ // current focus is on a menuoption, after clicking on it.
16626
+ if (this.persistInput && focusedEl && (focusedEl.tagName.toLowerCase() === 'auro-menuoption' || focusedEl.hasAttribute('auro-menuoption'))) {
16627
+ this.setClearBtnFocus();
16628
+ }
16495
16629
  }
16496
16630
  }
16497
16631
 
@@ -16527,6 +16661,8 @@ class AuroCombobox extends AuroElement {
16527
16661
  configureMenu() {
16528
16662
  this.menu = this.querySelector('auro-menu, [auro-menu]');
16529
16663
 
16664
+ this.menu.value = this.value;
16665
+
16530
16666
  this.updateMenuShapeSize();
16531
16667
 
16532
16668
  // a racing condition on custom-combobox with custom-menu
@@ -16547,7 +16683,8 @@ class AuroCombobox extends AuroElement {
16547
16683
  }
16548
16684
 
16549
16685
  // handle the menu event for an option selection
16550
- this.menu.addEventListener('auroMenu-selectedOption', () => {
16686
+ this.menu.addEventListener('auroMenu-selectedOption', (evt) => {
16687
+ console.warn('event 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
 
@@ -16662,6 +16789,7 @@ class AuroCombobox extends AuroElement {
16662
16789
  * @returns {void}
16663
16790
  */
16664
16791
  handleInputValueChange(event) {
16792
+ console.warn('handleInputValueChange', event);
16665
16793
  if (event.target === this.inputInBib) {
16666
16794
  this.input.value = this.inputInBib.value;
16667
16795
  return;
@@ -16672,29 +16800,9 @@ class AuroCombobox extends AuroElement {
16672
16800
  this.menu.matchWord = this.input.value;
16673
16801
  this.optionActive = null;
16674
16802
 
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;
16803
+ if (!this.input.value) {
16804
+ this.clear();
16695
16805
  }
16696
-
16697
- this.menu.clearSelection();
16698
16806
  this.handleMenuOptions();
16699
16807
 
16700
16808
  // Validate only if the value was set programmatically
@@ -16719,10 +16827,16 @@ class AuroCombobox extends AuroElement {
16719
16827
  * @returns {void}
16720
16828
  */
16721
16829
  configureCombobox() {
16722
- this.addEventListener('keydown', (evt) => {
16830
+ this.addEventListener('keydown', async (evt) => {
16723
16831
  if (evt.key === 'Enter') {
16724
16832
  if (this.dropdown.isPopoverVisible && this.optionActive) {
16725
16833
  this.menu.makeSelection();
16834
+
16835
+ await this.updateComplete;
16836
+
16837
+ evt.preventDefault();
16838
+ evt.stopPropagation();
16839
+ this.setClearBtnFocus();
16726
16840
  } else {
16727
16841
  this.showBib();
16728
16842
  }
@@ -16737,6 +16851,10 @@ class AuroCombobox extends AuroElement {
16737
16851
  this.dropdown.focus();
16738
16852
  }
16739
16853
  } else {
16854
+ if (this.menu.optionActive && this.menu.optionActive.value) {
16855
+ this.menu.value = this.menu.optionActive.value;
16856
+ }
16857
+
16740
16858
  setTimeout(() => {
16741
16859
  if (!this.componentHasFocus) {
16742
16860
  this.hideBib();
@@ -16766,8 +16884,15 @@ class AuroCombobox extends AuroElement {
16766
16884
  });
16767
16885
 
16768
16886
  this.addEventListener('focusin', () => {
16887
+ this.touched = true;
16888
+
16769
16889
  this.focus();
16770
16890
  });
16891
+
16892
+ this.addEventListener('auroFormElement-validated', (evt) => {
16893
+ this.input.validity = evt.detail.validity;
16894
+ this.input.errorMessage = evt.detail.message;
16895
+ });
16771
16896
  }
16772
16897
 
16773
16898
  /**
@@ -16812,7 +16937,9 @@ class AuroCombobox extends AuroElement {
16812
16937
  * @returns {void}
16813
16938
  */
16814
16939
  focus() {
16815
- this.input.focus();
16940
+ if (!this.componentHasFocus) {
16941
+ this.input.focus();
16942
+ }
16816
16943
  }
16817
16944
 
16818
16945
  /**
@@ -16821,7 +16948,11 @@ class AuroCombobox extends AuroElement {
16821
16948
  */
16822
16949
  reset() {
16823
16950
  this.input.reset();
16951
+ this.menu.reset();
16952
+ this.optionSelected = undefined;
16953
+ this.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
@@ -16905,8 +17073,13 @@ class AuroCombobox extends AuroElement {
16905
17073
  * @returns {void}
16906
17074
  */
16907
17075
  handleSlotChange(event) {
17076
+ console.warn('handleSlotChange', event);
16908
17077
  switch (event.target.name) {
16909
17078
  case '':
17079
+ if (!this.menu || this.menu !== this.querySelector('auro-menu, [auro-menu]')) {
17080
+ this.configureMenu();
17081
+ }
17082
+
16910
17083
  // Treat only generic menuoptions.
16911
17084
  this.options = this.menu.querySelectorAll('auro-menuoption, [auro-menuoption]');
16912
17085
  this.options.forEach((opt) => {
@@ -16983,14 +17156,16 @@ class AuroCombobox extends AuroElement {
16983
17156
  .inputmode="${this.inputmode}"
16984
17157
  .placeholder="${this.placeholder}"
16985
17158
  .type="${this.type}"
17159
+ .value="${this.typedValue}"
16986
17160
  ?disabled="${this.disabled}"
16987
17161
  ?icon="${this.triggerIcon}"
16988
- ?noValidate="${this.noValidate}"
17162
+ ?dvInputOnly="${this.dvInputOnly}"
16989
17163
  ?onDark="${this.onDark}"
16990
17164
  ?required="${this.required}"
16991
17165
  a11yRole="combobox"
16992
17166
  id="${this.id}"
16993
17167
  layout="${this.layout}"
17168
+ noValidate="true"
16994
17169
  setCustomValidity="${this.setCustomValidity}"
16995
17170
  setCustomValidityCustomError="${this.setCustomValidityCustomError}"
16996
17171
  setCustomValidityValueMissing="${this.setCustomValidityValueMissing}"
@@ -17006,7 +17181,7 @@ class AuroCombobox extends AuroElement {
17006
17181
  <${this.bibtemplateTag} ?large="${this.largeFullscreenHeadline}">
17007
17182
  <slot name="bib.fullscreen.headline" slot="header"></slot>
17008
17183
  <slot name="ariaLabel.bib.close" slot="ariaLabel.close">Close</slot>
17009
- <slot></slot>
17184
+ <slot @slotchange="${this.handleSlotChange}"></slot>
17010
17185
  <${this.inputTag}
17011
17186
  id="inputInBib"
17012
17187
  @input="${this.handleInputValueChange}"
@@ -17016,6 +17191,7 @@ class AuroCombobox extends AuroElement {
17016
17191
  .inputmode="${this.inputmode}"
17017
17192
  .placeholder="${this.placeholder}"
17018
17193
  .type="${this.type}"
17194
+ .value="${this.typedValue}"
17019
17195
  ?disabled="${this.disabled}"
17020
17196
  ?icon="${this.triggerIcon}"
17021
17197
  ?required="${this.required}"