@aurodesignsystem-dev/auro-formkit 0.0.0-pr1508.0 → 0.0.0-pr1509.1

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 (46) hide show
  1. package/components/checkbox/demo/customize.min.js +1 -1
  2. package/components/checkbox/demo/getting-started.min.js +1 -1
  3. package/components/checkbox/demo/index.min.js +1 -1
  4. package/components/checkbox/dist/index.js +1 -1
  5. package/components/checkbox/dist/registered.js +1 -1
  6. package/components/combobox/demo/customize.min.js +279 -142
  7. package/components/combobox/demo/getting-started.min.js +279 -142
  8. package/components/combobox/demo/index.min.js +279 -142
  9. package/components/combobox/dist/auro-combobox.d.ts +0 -9
  10. package/components/combobox/dist/index.js +279 -142
  11. package/components/combobox/dist/registered.js +279 -142
  12. package/components/counter/demo/customize.min.js +2 -2
  13. package/components/counter/demo/index.min.js +2 -2
  14. package/components/counter/dist/index.js +2 -2
  15. package/components/counter/dist/registered.js +2 -2
  16. package/components/datepicker/demo/customize.min.js +153 -45
  17. package/components/datepicker/demo/index.min.js +153 -45
  18. package/components/datepicker/dist/index.js +153 -45
  19. package/components/datepicker/dist/registered.js +153 -45
  20. package/components/dropdown/demo/customize.min.js +1 -1
  21. package/components/dropdown/demo/getting-started.min.js +1 -1
  22. package/components/dropdown/demo/index.min.js +1 -1
  23. package/components/dropdown/dist/index.js +1 -1
  24. package/components/dropdown/dist/registered.js +1 -1
  25. package/components/form/demo/customize.min.js +589 -235
  26. package/components/form/demo/getting-started.min.js +589 -235
  27. package/components/form/demo/index.min.js +589 -235
  28. package/components/form/demo/registerDemoDeps.min.js +589 -235
  29. package/components/input/demo/customize.min.js +151 -42
  30. package/components/input/demo/getting-started.min.js +151 -42
  31. package/components/input/demo/index.min.js +151 -42
  32. package/components/input/dist/base-input.d.ts +49 -1
  33. package/components/input/dist/index.js +151 -42
  34. package/components/input/dist/registered.js +151 -42
  35. package/components/radio/demo/customize.min.js +1 -1
  36. package/components/radio/demo/getting-started.min.js +1 -1
  37. package/components/radio/demo/index.min.js +1 -1
  38. package/components/radio/dist/index.js +1 -1
  39. package/components/radio/dist/registered.js +1 -1
  40. package/components/select/demo/customize.min.js +2 -2
  41. package/components/select/demo/getting-started.min.js +2 -2
  42. package/components/select/demo/index.min.js +2 -2
  43. package/components/select/dist/index.js +2 -2
  44. package/components/select/dist/registered.js +2 -2
  45. package/custom-elements.json +264 -20
  46. package/package.json +1 -1
@@ -767,8 +767,6 @@ function navigateArrow(component, direction, options = {}) {
767
767
  }
768
768
  }
769
769
 
770
- /* eslint-disable no-underscore-dangle */
771
-
772
770
  /**
773
771
  * Returns the clear button element from the active input's shadow
774
772
  * DOM, if available.
@@ -804,9 +802,11 @@ function isClearBtnFocused(ctx, clearBtn = getClearBtn(ctx)) {
804
802
  * @param {Object} menu - The menu component.
805
803
  */
806
804
  function reconcileMenuIndex(menu) {
805
+ // eslint-disable-next-line no-underscore-dangle
807
806
  if (menu._index < 0 && menu.optionActive && menu.items) {
808
807
  const idx = menu.items.indexOf(menu.optionActive);
809
808
  if (idx >= 0) {
809
+ // eslint-disable-next-line no-underscore-dangle
810
810
  menu._index = idx;
811
811
  }
812
812
  }
@@ -4806,7 +4806,7 @@ let AuroHelpText$2 = class AuroHelpText extends LitElement {
4806
4806
  }
4807
4807
  };
4808
4808
 
4809
- var formkitVersion$2 = '202606231948';
4809
+ var formkitVersion$2 = '202606241801';
4810
4810
 
4811
4811
  let AuroElement$2 = class AuroElement extends LitElement {
4812
4812
  static get properties() {
@@ -16528,7 +16528,6 @@ class AuroInputUtilities {
16528
16528
  const maskOptions = this.getMaskOptions('date', normalizedFormat);
16529
16529
 
16530
16530
  if (!(valueObject instanceof Date) || Number.isNaN(valueObject.getTime()) || !maskOptions || typeof maskOptions.format !== 'function') {
16531
- console.debug('Invalid date object or mask options for formatting', { valueObject, maskOptions }); // eslint-disable-line no-console
16532
16531
  return undefined;
16533
16532
  }
16534
16533
 
@@ -16680,8 +16679,10 @@ class BaseInput extends AuroElement$1 {
16680
16679
  this.layout = 'classic';
16681
16680
  this.locale = 'en-US';
16682
16681
  this.max = undefined;
16682
+ this._maxObject = undefined;
16683
16683
  this.maxLength = undefined;
16684
16684
  this.min = undefined;
16685
+ this._minObject = undefined;
16685
16686
  this.minLength = undefined;
16686
16687
  this.required = false;
16687
16688
  this.onDark = false;
@@ -16689,6 +16690,7 @@ class BaseInput extends AuroElement$1 {
16689
16690
  this.size = 'lg';
16690
16691
  this.shape = 'classic';
16691
16692
  this.value = undefined;
16693
+ this._valueObject = undefined;
16692
16694
 
16693
16695
  this._initializePrivateDefaults();
16694
16696
  }
@@ -17228,7 +17230,7 @@ class BaseInput extends AuroElement$1 {
17228
17230
  * @returns {Date|undefined}
17229
17231
  */
17230
17232
  get valueObject() {
17231
- return this.value && dateFormatter.isValidDate(this.value) ? dateFormatter.stringToDateInstance(this.value) : undefined;
17233
+ return this._valueObject || this._computeDateObjectFallback(this.value);
17232
17234
  }
17233
17235
 
17234
17236
  /**
@@ -17236,7 +17238,7 @@ class BaseInput extends AuroElement$1 {
17236
17238
  * @returns {Date|undefined}
17237
17239
  */
17238
17240
  get minObject() {
17239
- return this.min && dateFormatter.isValidDate(this.min) ? dateFormatter.stringToDateInstance(this.min) : undefined;
17241
+ return this._minObject || this._computeDateObjectFallback(this.min);
17240
17242
  }
17241
17243
 
17242
17244
  /**
@@ -17244,7 +17246,50 @@ class BaseInput extends AuroElement$1 {
17244
17246
  * @returns {Date|undefined}
17245
17247
  */
17246
17248
  get maxObject() {
17247
- return this.max && dateFormatter.isValidDate(this.max) ? dateFormatter.stringToDateInstance(this.max) : undefined;
17249
+ return this._maxObject || this._computeDateObjectFallback(this.max);
17250
+ }
17251
+
17252
+ /**
17253
+ * Parses a date string into a Date object when the corresponding `_*Object`
17254
+ * field hasn't been synced yet by `updated()`. Returns undefined when the
17255
+ * input type/format isn't a full date or the string is not a valid date.
17256
+ *
17257
+ * Why this exists: a parent (datepicker) can call `inputN.validate()` from
17258
+ * inside its own `updated()` before this input's `updated()` has run
17259
+ * `syncDateValues()` — so `_valueObject`/`_maxObject` are still `undefined`
17260
+ * and range checks would otherwise silently no-op (flipping the result to
17261
+ * `valid` or `patternMismatch`).
17262
+ * @private
17263
+ * @param {string|undefined} dateStr - ISO date string from `value`/`min`/`max`.
17264
+ * @returns {Date|undefined}
17265
+ */
17266
+ _computeDateObjectFallback(dateStr) {
17267
+ if (!dateStr || !this.util || !this.util.isFullDateFormat(this.type, this.format)) {
17268
+ return undefined;
17269
+ }
17270
+ if (!dateFormatter.isValidDate(dateStr)) {
17271
+ return undefined;
17272
+ }
17273
+ return dateFormatter.stringToDateInstance(dateStr);
17274
+ }
17275
+
17276
+ /**
17277
+ * Internal setter for readonly date object properties.
17278
+ * @private
17279
+ * @param {'valueObject'|'minObject'|'maxObject'} propertyName - Public object property name.
17280
+ * @param {Date|undefined} propertyValue - Value to assign.
17281
+ * @returns {void}
17282
+ */
17283
+ setDateObjectProperty(propertyName, propertyValue) {
17284
+ const internalPropertyName = `_${propertyName}`;
17285
+ const previousValue = this[internalPropertyName];
17286
+
17287
+ if (previousValue === propertyValue) {
17288
+ return;
17289
+ }
17290
+
17291
+ this[internalPropertyName] = propertyValue;
17292
+ this.requestUpdate(propertyName, previousValue);
17248
17293
  }
17249
17294
 
17250
17295
  connectedCallback() {
@@ -17273,6 +17318,7 @@ class BaseInput extends AuroElement$1 {
17273
17318
  format: this.format
17274
17319
  });
17275
17320
  this.configureDataForType();
17321
+ this.syncDateValues();
17276
17322
  }
17277
17323
 
17278
17324
  disconnectedCallback() {
@@ -17302,6 +17348,7 @@ class BaseInput extends AuroElement$1 {
17302
17348
  this.setCustomHelpTextMessage();
17303
17349
  this.configureAutoFormatting();
17304
17350
  this.configureDataForType();
17351
+ this.syncDateValues();
17305
17352
  }
17306
17353
 
17307
17354
  /**
@@ -17377,6 +17424,13 @@ class BaseInput extends AuroElement$1 {
17377
17424
 
17378
17425
  if (typeToI18n.includes(this.type)) {
17379
17426
  this.setCustomValidityForType = i18n(this.lang, this.type);
17427
+ // COVERAGE: this `else if` branch is unreachable in WTR. connectedCallback
17428
+ // (L682) calls configureDataForType, which at L1266-1268 assigns
17429
+ // `this.format = this.util.getDateMaskFromLocale().toLowerCase()` for any
17430
+ // type=date input whose `format` attribute is unset. That runs before
17431
+ // firstUpdated invokes setCustomHelpTextMessage, so `!this.format` is
17432
+ // always false here. Retained as a defensive fallback; the whole function
17433
+ // is @deprecated per AB#1557296 and slated for removal.
17380
17434
  } else if (!this.format && this.type === 'date') {
17381
17435
  this.setCustomValidityForType = i18n(this.lang, 'dateMMDDYYYY');
17382
17436
  } else if (this.dateFormatMap[this.format]) {
@@ -17438,6 +17492,8 @@ class BaseInput extends AuroElement$1 {
17438
17492
  this.configureDataForType();
17439
17493
  }
17440
17494
 
17495
+ this.syncDateValues(changedProperties);
17496
+
17441
17497
  if (changedProperties.has('value')) {
17442
17498
  if (this.value && this.value.length > 0) {
17443
17499
  this.hasValue = true;
@@ -17459,14 +17515,14 @@ class BaseInput extends AuroElement$1 {
17459
17515
 
17460
17516
  if (formattedValue !== this.inputElement.value) {
17461
17517
  this.skipNextProgrammaticInputEvent = true;
17462
- if (this.maskInstance && this.type !== 'date') {
17518
+ if (this.maskInstance && this.type === 'credit-card') {
17463
17519
  // Route through the mask so its _value and el.value stay in lock-step
17464
17520
  // (set value calls updateControl which writes el.value = displayValue).
17465
17521
  // Writing el.value directly leaves the mask thinking displayValue is
17466
- // stale; _saveSelection on the next focus/click then warns. Date is
17467
- // excluded because its formattedValue can be raw ISO when the calendar
17468
- // is invalid, and re-masking through mm/dd/yyyy would truncate it and
17469
- // flip validity from patternMismatch to tooShort.
17522
+ // stale; _saveSelection on the next focus/click then warns. Scoped to
17523
+ // credit-card so date's own formattedValue (raw ISO when calendar-invalid)
17524
+ // isn't re-masked through the mm/dd/yyyy mask, which would truncate it
17525
+ // and flip validity from patternMismatch to tooShort.
17470
17526
  this.maskInstance.value = formattedValue || '';
17471
17527
  } else if (formattedValue) {
17472
17528
  this.inputElement.value = formattedValue;
@@ -17508,65 +17564,120 @@ class BaseInput extends AuroElement$1 {
17508
17564
  }));
17509
17565
  }
17510
17566
 
17567
+
17568
+ /**
17569
+ * Synchronizes the ISO string values and Date object representations for date-related properties.
17570
+ * This keeps the model and display values aligned when either side changes.
17571
+ *
17572
+ * When a full date format is in use, this method updates `value`, `min`, and `max` from their corresponding
17573
+ * Date objects or vice versa, based on which properties have changed. It only runs when the current configuration
17574
+ * represents a full year/month/day date format.
17575
+ *
17576
+ * @param {Map<string, unknown>|undefined} [changedProperties=undefined] - Optional map of changed properties used to limit which values are synchronized.
17577
+ * @returns {void}
17578
+ * @private
17579
+ */
17580
+ syncDateValues(changedProperties = undefined) {
17581
+ if (!this.util.isFullDateFormat(this.type, this.format)) {
17582
+ return;
17583
+ }
17584
+
17585
+ this.syncSingleDateValue(changedProperties, 'valueObject', 'value');
17586
+ this.syncSingleDateValue(changedProperties, 'minObject', 'min');
17587
+ this.syncSingleDateValue(changedProperties, 'maxObject', 'max');
17588
+ }
17589
+
17590
+ /**
17591
+ * Synchronizes one date object/string property pair.
17592
+ * @private
17593
+ * @param {Map<string, unknown>|undefined} changedProperties - Map of changed properties from Lit.
17594
+ * @param {string} objectProperty - Date object property name.
17595
+ * @param {string} valueProperty - ISO string property name.
17596
+ * @returns {void}
17597
+ */
17598
+ syncSingleDateValue(changedProperties, objectProperty, valueProperty) {
17599
+ const objectPropertyChanged = !changedProperties || changedProperties.has(objectProperty);
17600
+
17601
+ // objectProperty wins over valueProperty when both changed
17602
+ if (objectPropertyChanged && this[objectProperty]) {
17603
+ this[valueProperty] = dateFormatter.toISOFormatString(this[objectProperty]);
17604
+ return;
17605
+ }
17606
+
17607
+ const valuePropertyChanged = !changedProperties || changedProperties.has(valueProperty);
17608
+ if (!valuePropertyChanged) {
17609
+ return;
17610
+ }
17611
+
17612
+ // when value is newly set to the same ISO string that corresponds to the existing Date object, do not clear the Date object (avoid unnecessary updates)
17613
+ if (
17614
+ changedProperties &&
17615
+ valueProperty === 'value' &&
17616
+ changedProperties.get('value') === undefined &&
17617
+ this[objectProperty] instanceof Date &&
17618
+ this[valueProperty] === dateFormatter.toISOFormatString(this[objectProperty])
17619
+ ) {
17620
+ return;
17621
+ }
17622
+
17623
+ if (dateFormatter.isValidDate(this[valueProperty])) {
17624
+ this.setDateObjectProperty(objectProperty, dateFormatter.stringToDateInstance(this[valueProperty]));
17625
+ } else {
17626
+ this.setDateObjectProperty(objectProperty, undefined);
17627
+ }
17628
+ }
17629
+
17511
17630
  /**
17512
17631
  * Sets up IMasks and logic based on auto-formatting requirements.
17513
17632
  * @private
17514
17633
  * @returns {void}
17515
17634
  */
17516
17635
  configureAutoFormatting() {
17517
- // _configuringMask gates two things: external re-entry into this method
17518
- // while setup is mid-flight (from property changes that call back here),
17519
- // and the accept/complete listeners below both need to ignore the mask
17520
- // events fired by our own value-restore step.
17636
+ // Re-entrancy guard. The patched-setter's synthetic input event (suppressed
17637
+ // by _configuringMask above) could otherwise trigger handleInput
17638
+ // processCreditCard configureAutoFormatting before the outer call's
17639
+ // set value has finished its alignCursor pass.
17521
17640
  if (this._configuringMask) return;
17522
17641
  this._configuringMask = true;
17523
17642
  try {
17524
- // Destroy any prior mask so IMask can attach fresh under the new format.
17525
- // Null the reference too — if the new maskOptions.mask is falsy (e.g.
17526
- // type switched from credit-card to text) the IMask() reassignment
17527
- // below is skipped, and downstream writes at line ~823 would otherwise
17528
- // route through the destroyed instance.
17529
17643
  if (this.maskInstance) {
17530
17644
  this.maskInstance.destroy();
17531
- this.maskInstance = null;
17532
17645
  }
17533
17646
 
17647
+ // Pass new format to util
17534
17648
  this.util.updateFormat(this.format);
17535
17649
 
17536
17650
  const maskOptions = this.util.getMaskOptions(this.type, this.format);
17537
17651
 
17538
17652
  if (this.inputElement && maskOptions.mask) {
17539
- // Capture the current display so it can be re-applied after IMask
17540
- // attaches. The restore at the bottom goes through maskInstance.value
17541
- // (not inputElement.value directly) so the mask's internal state and
17542
- // the input's displayed text stay in lock-step.
17543
- let existingValue = this.inputElement.value;
17544
17653
 
17545
- // Format-change case (e.g. locale switch): existingValue is the OLD
17546
- // mask's display string and may not parse under the new mask. When
17547
- // we have a valid date model, rebuild the display from valueObject
17548
- // (the canonical source) using the new mask's format function.
17654
+ // Stash and clear any existing value before IMask init.
17655
+ // IMask's constructor processes the current input value which requires
17656
+ // selection state clearing first avoids that scenario entirely.
17657
+ // When the format changes (e.g. locale switch) and we have a valid ISO
17658
+ // model value, compute the display string for the NEW format instead of
17659
+ // re-using the old display string, which may be invalid in the new mask.
17660
+ let existingValue = this.inputElement.value;
17549
17661
  if (
17550
17662
  this.util.isFullDateFormat(this.type, this.format) &&
17551
17663
  this.value &&
17552
- this.valueObject &&
17664
+ dateFormatter.isValidDate(this.value) &&
17665
+ this.valueObject instanceof Date &&
17666
+ !Number.isNaN(this.valueObject.getTime()) &&
17553
17667
  typeof maskOptions.format === 'function'
17554
17668
  ) {
17555
17669
  existingValue = maskOptions.format(this.valueObject);
17556
17670
  }
17557
17671
 
17558
- // Clear before IMask attaches so the constructor seeds an empty
17559
- // internal value. Otherwise IMask reads the stale unmasked string
17560
- // and emits a spurious 'accept' before the restore below runs.
17561
17672
  this.skipNextProgrammaticInputEvent = true;
17562
17673
  this.inputElement.value = '';
17563
17674
 
17564
17675
  this.maskInstance = IMask(this.inputElement, maskOptions);
17565
17676
 
17566
- // Mask fires 'accept' on every value change, including the restore
17567
- // step below. Skip events fired during configureAutoFormatting so
17568
- // we don't overwrite a value the parent just pushed.
17569
17677
  this.maskInstance.on('accept', () => {
17678
+ // Suppress propagation during configureAutoFormatting's own value-restoration
17679
+ // (line below) — the mask emits 'accept' on every value-set, including ours,
17680
+ // and we don't want to overwrite a value the parent just pushed.
17570
17681
  if (this._configuringMask) return;
17571
17682
  this.value = this.util.toModelValue(this.maskInstance.value, this.format);
17572
17683
  if (this.type === "date") {
@@ -17574,8 +17685,6 @@ class BaseInput extends AuroElement$1 {
17574
17685
  }
17575
17686
  });
17576
17687
 
17577
- // Mask fires 'complete' on the restore step below for any value that
17578
- // happens to be a complete match. Same setup-suppression as 'accept'.
17579
17688
  this.maskInstance.on('complete', () => {
17580
17689
  if (this._configuringMask) return;
17581
17690
  this.value = this.util.toModelValue(this.maskInstance.value, this.format);
@@ -17584,9 +17693,7 @@ class BaseInput extends AuroElement$1 {
17584
17693
  }
17585
17694
  });
17586
17695
 
17587
- // Write existingValue through the mask (not the input directly) so
17588
- // the mask reformats it under the new rules and keeps its internal
17589
- // _value aligned with the input's displayed text.
17696
+ // Restore the stashed value through IMask so it's properly masked
17590
17697
  if (existingValue) {
17591
17698
  this.maskInstance.value = existingValue;
17592
17699
  }
@@ -17754,6 +17861,7 @@ class BaseInput extends AuroElement$1 {
17754
17861
  */
17755
17862
  reset() {
17756
17863
  this.value = undefined;
17864
+ this.setDateObjectProperty('valueObject', undefined);
17757
17865
  this.validation.reset(this);
17758
17866
  }
17759
17867
 
@@ -17762,6 +17870,7 @@ class BaseInput extends AuroElement$1 {
17762
17870
  */
17763
17871
  clear() {
17764
17872
  this.value = undefined;
17873
+ this.setDateObjectProperty('valueObject', undefined);
17765
17874
  }
17766
17875
 
17767
17876
  /**
@@ -17799,7 +17908,7 @@ class BaseInput extends AuroElement$1 {
17799
17908
  */
17800
17909
  get placeholderStr() {
17801
17910
  if (!this.placeholder && this.type === 'date') {
17802
- return this.format ? this.format.toUpperCase() : 'MM/DD/YYYY';
17911
+ return this.format.toUpperCase();
17803
17912
  }
17804
17913
  return this.placeholder || "";
17805
17914
  }
@@ -18290,7 +18399,7 @@ let AuroHelpText$1 = class AuroHelpText extends LitElement {
18290
18399
  }
18291
18400
  };
18292
18401
 
18293
- var formkitVersion$1 = '202606231948';
18402
+ var formkitVersion$1 = '202606241801';
18294
18403
 
18295
18404
  // Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
18296
18405
  // See LICENSE in the project root for license information.
@@ -19411,7 +19520,7 @@ class AuroBibtemplate extends LitElement {
19411
19520
  }
19412
19521
  }
19413
19522
 
19414
- var formkitVersion = '202606231948';
19523
+ var formkitVersion = '202606241801';
19415
19524
 
19416
19525
  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([layout*=classic]) [auro-input]{width:100%}:host([layout*=classic]) [auro-input]::part(helpText){display:none}:host([layout*=classic]) #slotHolder{display:none}`;
19417
19526
 
@@ -20398,7 +20507,7 @@ class AuroCombobox extends AuroElement {
20398
20507
  if (this.menu) {
20399
20508
  this.menu.matchWord = normalizeFilterValue(this.input.value);
20400
20509
  }
20401
- const label = getOptionLabel(this.menu.optionSelected);
20510
+ const label = getOptionLabel(this.menu.optionSelected) || this.menu.currentLabel;
20402
20511
  this.updateTriggerTextDisplay(label || this.value);
20403
20512
  }
20404
20513
 
@@ -20412,9 +20521,40 @@ class AuroCombobox extends AuroElement {
20412
20521
  // in suggestion mode, do not override input value if no selection has been made and the input currently has focus
20413
20522
  const isInputFocusedWithNoSelection = !this.menu.value && (this.input.matches(':focus-within') || (this.inputInBib && this.inputInBib.matches(':focus-within')));
20414
20523
 
20415
- const suppressed = this.persistInput || (this.behavior === 'suggestion' && isInputFocusedWithNoSelection);
20416
- if (!suppressed) {
20417
- this.syncInputValuesAcrossTriggerAndBib(label || this.value);
20524
+ if (!this.persistInput && !(this.behavior === 'suggestion' && isInputFocusedWithNoSelection)) {
20525
+ const nextValue = label || this.value;
20526
+ // Only set the flag when there's an actual write to suppress —
20527
+ // syncValuesAndStates re-enters here during typing when both inputs
20528
+ // already match, and a no-op flag flip would make the bib branch's
20529
+ // bail eat legitimate user-input events.
20530
+ const triggerNeedsSync = this.input.value !== nextValue;
20531
+ const bibNeedsSync = Boolean(this.inputInBib && this.inputInBib !== this.input && this.inputInBib.value !== nextValue);
20532
+ if (triggerNeedsSync || bibNeedsSync) {
20533
+ this._syncingDisplayValue = true;
20534
+ if (triggerNeedsSync) {
20535
+ this.input.value = nextValue;
20536
+ }
20537
+ if (bibNeedsSync) {
20538
+ this.inputInBib.value = nextValue;
20539
+ }
20540
+ const pending = [];
20541
+ if (triggerNeedsSync) {
20542
+ pending.push(this.input.updateComplete);
20543
+ }
20544
+ if (bibNeedsSync) {
20545
+ pending.push(this.inputInBib.updateComplete);
20546
+ }
20547
+ Promise.all(pending).then(() => {
20548
+ // imask reasserts otherwise, and handleBlur reverts to its stale value.
20549
+ if (triggerNeedsSync && this.input.maskInstance && typeof this.input.maskInstance.updateValue === 'function') {
20550
+ this.input.maskInstance.updateValue();
20551
+ }
20552
+ if (bibNeedsSync && this.inputInBib && this.inputInBib.maskInstance && typeof this.inputInBib.maskInstance.updateValue === 'function') {
20553
+ this.inputInBib.maskInstance.updateValue();
20554
+ }
20555
+ this._syncingDisplayValue = false;
20556
+ });
20557
+ }
20418
20558
  }
20419
20559
 
20420
20560
  // update the displayValue in the trigger if displayValue slot content is present
@@ -20442,48 +20582,6 @@ class AuroCombobox extends AuroElement {
20442
20582
  this.requestUpdate();
20443
20583
  }
20444
20584
 
20445
- /**
20446
- * Writes nextValue to the trigger input and the bib input when their current
20447
- * value differs, then re-asserts imask after Lit's update flushes.
20448
- * @param {string} nextValue - The value to write to both inputs.
20449
- * @returns {Promise<void> | null} Promise that resolves after the inputs flush,
20450
- * or null when no sync was needed (so callers can skip post-flush work).
20451
- * @private
20452
- */
20453
- syncInputValuesAcrossTriggerAndBib(nextValue) {
20454
- // Only set the flag when there's an actual write to suppress —
20455
- // syncValuesAndStates re-enters here during typing when both inputs
20456
- // already match, and a no-op flag flip would make the bib branch's
20457
- // bail eat legitimate user-input events.
20458
- const triggerNeedsSync = this.input.value !== nextValue;
20459
- const bibNeedsSync = this.inputInBib.value !== nextValue;
20460
- if (!triggerNeedsSync && !bibNeedsSync) {
20461
- return null;
20462
- }
20463
-
20464
- this._syncingDisplayValue = true;
20465
-
20466
- const pending = [];
20467
- if (triggerNeedsSync) {
20468
- this.input.value = nextValue;
20469
- pending.push(this.input.updateComplete);
20470
- }
20471
- if (bibNeedsSync) {
20472
- this.inputInBib.value = nextValue;
20473
- pending.push(this.inputInBib.updateComplete);
20474
- }
20475
- return Promise.all(pending).then(() => {
20476
- // imask reasserts otherwise, and handleBlur reverts to its stale value.
20477
- if (triggerNeedsSync && this.input.maskInstance && typeof this.input.maskInstance.updateValue === 'function') {
20478
- this.input.maskInstance.updateValue();
20479
- }
20480
- if (bibNeedsSync && this.inputInBib && this.inputInBib.maskInstance && typeof this.inputInBib.maskInstance.updateValue === 'function') {
20481
- this.inputInBib.maskInstance.updateValue();
20482
- }
20483
- this._syncingDisplayValue = false;
20484
- });
20485
- }
20486
-
20487
20585
  /**
20488
20586
  * Processes hidden state of all menu options and determines if there are any available options not hidden.
20489
20587
  * @private
@@ -20511,9 +20609,9 @@ class AuroCombobox extends AuroElement {
20511
20609
  this.syncValuesAndStates();
20512
20610
  }
20513
20611
 
20514
- // Re-activate when optionActive is not in the current scrollable viewport,
20515
- // or when _index has been reset (e.g. by clearSelection in an async update)
20516
- // so that makeSelection() can find the correct option.
20612
+ // Re-activate when optionActive is no longer visible, or when _index has
20613
+ // been reset (e.g. by clearSelection in an async update) so that
20614
+ // makeSelection() can find the correct option.
20517
20615
  if (!this.availableOptions.includes(this.menu.optionActive) || this.menu._index < 0) {
20518
20616
  this.activateFirstEnabledAvailableOption();
20519
20617
  }
@@ -20647,25 +20745,28 @@ class AuroCombobox extends AuroElement {
20647
20745
 
20648
20746
  guardTouchPassthrough(this.menu);
20649
20747
 
20650
- // showModal() takes focus away from the trigger. Early focus once
20651
- // the dialog has painted; the shared doubleRaf below is the fallback
20652
- // for when the dialog needs an extra frame and also clears the
20653
- // validation guard.
20748
+ // The dialog's showModal() steals focus from the trigger.
20749
+ // A single rAF is enough for the dialog DOM to be painted and
20750
+ // focusable, then doubleRaf finalizes the transition.
20654
20751
  requestAnimationFrame(() => {
20655
20752
  this.setInputFocus();
20656
20753
  });
20657
- }
20658
- // else (desktop popover-open): Chrome resets the trigger caret to
20659
- // [0, 0] when its floating <label for="…"> overlay receives focus.
20660
- // The shared doubleRaf below parks the caret back at end-of-text
20661
- // after the dropdown layout settles.
20662
-
20663
- doubleRaf(() => {
20664
- this.setInputFocus();
20665
- if (this._inFullscreenTransition) {
20754
+
20755
+ doubleRaf(() => {
20756
+ this.setInputFocus();
20666
20757
  this._inFullscreenTransition = false;
20667
- }
20668
- });
20758
+ });
20759
+ } else {
20760
+ // Desktop popover-open: restore the trigger caret to end-of-text.
20761
+ // Clicking the trigger lands on auro-input's floating <label for="…">
20762
+ // overlay; Chrome resets the native input's selection to [0, 0] on
20763
+ // label-focus before any JS runs. setInputFocus()'s non-fullscreen
20764
+ // branch parks the caret at end. doubleRaf lets the dropdown layout
20765
+ // settle first, matching the fullscreen branch timing.
20766
+ doubleRaf(() => {
20767
+ this.setInputFocus();
20768
+ });
20769
+ }
20669
20770
  }
20670
20771
  });
20671
20772
 
@@ -20876,7 +20977,7 @@ class AuroCombobox extends AuroElement {
20876
20977
  if (this.menu.optionSelected) {
20877
20978
  const selected = this.menu.optionSelected;
20878
20979
 
20879
- if (this.optionSelected !== selected) {
20980
+ if (!this.optionSelected || this.optionSelected !== selected) {
20880
20981
  this.optionSelected = selected;
20881
20982
  }
20882
20983
 
@@ -20889,7 +20990,7 @@ class AuroCombobox extends AuroElement {
20889
20990
  }
20890
20991
 
20891
20992
  // Update display
20892
- this.updateTriggerTextDisplay(getOptionLabel(this.optionSelected));
20993
+ this.updateTriggerTextDisplay(getOptionLabel(this.optionSelected) || this.menu.value);
20893
20994
 
20894
20995
  // Update match word for filtering
20895
20996
  const trimmedInput = normalizeFilterValue(this.input.value);
@@ -20905,22 +21006,13 @@ class AuroCombobox extends AuroElement {
20905
21006
  this.hideBib();
20906
21007
  }
20907
21008
 
20908
- // Move focus to the clear button when the user makes a selection.
20909
- if (!isEcho && this.menu.value !== undefined) {
20910
- this.setClearBtnFocus();
20911
- }
20912
-
20913
21009
  // Announce the selection after the dropdown closes so it isn't
20914
21010
  // overridden by VoiceOver's "collapsed" announcement from aria-expanded.
20915
- // Skip when there's no selected value (e.g. menu.clearSelection() from
20916
- // the unmatched-value path), otherwise VoiceOver reads "undefined".
20917
21011
  const selectedValue = this.menu.value;
20918
- if (selectedValue) {
20919
- const announcementDelay = 300;
20920
- setTimeout(() => {
20921
- announceToScreenReader(this._getAnnouncementRoot(), `${selectedValue}, selected`);
20922
- }, announcementDelay);
20923
- }
21012
+ const announcementDelay = 300;
21013
+ setTimeout(() => {
21014
+ announceToScreenReader(this._getAnnouncementRoot(), `${selectedValue}, selected`);
21015
+ }, announcementDelay);
20924
21016
  }
20925
21017
 
20926
21018
  // Programmatic value syncs leave availableOptions stale because
@@ -20934,6 +21026,18 @@ class AuroCombobox extends AuroElement {
20934
21026
  this._programmaticFilterRefresh = false;
20935
21027
  }, 0);
20936
21028
  }
21029
+
21030
+ // base-input skips auto-validate when focus is inside its own shadow,
21031
+ // which it is after setTriggerInputFocus — re-run so prior tooShort
21032
+ // clears. processCreditCard reasserts errorMessage on every render.
21033
+ if (!isEcho && this.menu.optionSelected && this.input.validate) {
21034
+ this.input.updateComplete.then(() => {
21035
+ this.input.validate(true);
21036
+ if (this.input.validity === 'valid') {
21037
+ this.input.errorMessage = '';
21038
+ }
21039
+ });
21040
+ }
20937
21041
  });
20938
21042
 
20939
21043
  this.menu.addEventListener('auroMenu-customEventFired', () => {
@@ -21268,7 +21372,15 @@ class AuroCombobox extends AuroElement {
21268
21372
  this.menu.value = undefined;
21269
21373
  this.validation.reset(this);
21270
21374
  this.touched = false;
21375
+ // Force validity back to the cleared state. validation.reset() calls
21376
+ // validate() at the end, and (post-credit-card-fix) the trigger input's
21377
+ // residual validity may still be copied into the combobox by the
21378
+ // auroInputElements loop. Explicitly clear here so reset() actually
21379
+ // leaves the component in a "no validity" state.
21271
21380
  this.validity = undefined;
21381
+ this.errorMessage = '';
21382
+ this.input.validity = undefined;
21383
+ this.input.errorMessage = '';
21272
21384
  }
21273
21385
 
21274
21386
  /**
@@ -21321,27 +21433,52 @@ class AuroCombobox extends AuroElement {
21321
21433
  this.input.value = this.value;
21322
21434
  }
21323
21435
 
21324
- // Sync menu.value only when an option actually matches, or when filter
21325
- // mode needs setMenuValue to dispatch auroMenu-selectValueFailure (the
21326
- // listener at line 1206 clears combobox.value, mirroring select's
21327
- // pattern). Otherwise sync the input display for freeform values.
21436
+ // Sync menu.value only when an option actually matches; otherwise clear it.
21328
21437
  if (this.menu.options && this.menu.options.length > 0) {
21329
- if (this.menu.options.some((opt) => opt.value === this.value) || this.behavior === 'filter') {
21438
+ if (this.menu.options.some((opt) => opt.value === this.value)) {
21439
+ this.setMenuValue(this.value);
21440
+ } else if (this.behavior === 'filter') {
21441
+ // In filter mode, freeform values aren't allowed. Push the unmatched
21442
+ // value through setMenuValue so menu dispatches auroMenu-selectValueFailure
21443
+ // and the listener at line 1206 clears combobox.value (mirrors select's
21444
+ // pattern). Bypassing setMenuValue here would skip the failure cascade.
21330
21445
  this.setMenuValue(this.value);
21331
21446
  } else {
21332
- // Clear menu.value AND menu.optionSelected together. Clearing only
21333
- // menu.value leaves the previously-selected option element pinned
21334
- // as menu.optionSelected; a later auroMenu-selectedOption event
21335
- // would then write its stale .value back into combobox.value.
21336
- if (this.menu.value || this.menu.optionSelected) {
21337
- this.menu.clearSelection();
21447
+ if (this.menu.value) {
21448
+ this.menu.value = undefined;
21338
21449
  }
21339
- // Suggestion-mode freeform value: sync the trigger + bib to show it,
21340
- // then refresh the filter once the inputs flush (handleInputValueChange
21341
- // bailed on _syncingDisplayValue).
21342
- const syncPromise = this.syncInputValuesAcrossTriggerAndBib(this.value || '');
21343
- if (syncPromise) {
21344
- syncPromise.then(() => {
21450
+ // Sync the display for programmatic freeform value changes (e.g. the
21451
+ // swap-values pattern). Guard with _syncingDisplayValue so that the
21452
+ // re-entrant input event from base-input.notifyValueChanged() is
21453
+ // ignored by handleInputValueChange. Skip the sync when input already
21454
+ // matches to avoid spurious events during the normal typing path.
21455
+ const nextValue = this.value || '';
21456
+ const triggerNeedsSync = this.input.value !== nextValue;
21457
+ const bibNeedsSync = Boolean(this.inputInBib && this.inputInBib !== this.input && this.inputInBib.value !== nextValue);
21458
+ if (triggerNeedsSync || bibNeedsSync) {
21459
+ this._syncingDisplayValue = true;
21460
+ if (triggerNeedsSync) {
21461
+ this.input.value = nextValue;
21462
+ }
21463
+ if (bibNeedsSync) {
21464
+ this.inputInBib.value = nextValue;
21465
+ }
21466
+ const pending = [];
21467
+ if (triggerNeedsSync) {
21468
+ pending.push(this.input.updateComplete);
21469
+ }
21470
+ if (bibNeedsSync) {
21471
+ pending.push(this.inputInBib.updateComplete);
21472
+ }
21473
+ Promise.all(pending).then(() => {
21474
+ if (triggerNeedsSync && this.input.maskInstance && typeof this.input.maskInstance.updateValue === 'function') {
21475
+ this.input.maskInstance.updateValue();
21476
+ }
21477
+ if (bibNeedsSync && this.inputInBib && this.inputInBib.maskInstance && typeof this.inputInBib.maskInstance.updateValue === 'function') {
21478
+ this.inputInBib.maskInstance.updateValue();
21479
+ }
21480
+ this._syncingDisplayValue = false;
21481
+ // handleInputValueChange bailed on the flag — refresh the filter.
21345
21482
  this._programmaticFilterRefresh = true;
21346
21483
  this.handleMenuOptions();
21347
21484
  setTimeout(() => {