@ni/nimble-components 30.1.2 → 30.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.
@@ -16333,7 +16333,7 @@
16333
16333
 
16334
16334
  /**
16335
16335
  * Do not edit directly
16336
- * Generated on Wed, 24 Jul 2024 15:55:56 GMT
16336
+ * Generated on Tue, 30 Jul 2024 16:37:39 GMT
16337
16337
  */
16338
16338
 
16339
16339
  const Information100DarkUi = "#a46eff";
@@ -21376,16 +21376,16 @@ so this becomes the fallback color for the slot */ ''}
21376
21376
  return this._value;
21377
21377
  }
21378
21378
  set value(next) {
21379
- const prev = `${this._value}`;
21379
+ const prev = this._value;
21380
21380
  let updatedValue = next;
21381
21381
  if (this.$fastController.isConnected && this.options) {
21382
- const selectedIndex = this.options.findIndex(el => el.text.toLowerCase() === next.toLowerCase());
21382
+ const selectedIndex = this.findIndexOfValidOption(next);
21383
21383
  const prevSelectedValue = this.options[this.selectedIndex]?.text;
21384
21384
  const nextSelectedValue = this.options[selectedIndex]?.text;
21385
- this.selectedIndex = prevSelectedValue !== nextSelectedValue
21386
- ? selectedIndex
21387
- : this.selectedIndex;
21388
- updatedValue = this.firstSelectedOption?.text || next;
21385
+ if (prevSelectedValue !== nextSelectedValue) {
21386
+ this.selectedIndex = selectedIndex;
21387
+ }
21388
+ updatedValue = this.firstSelectedOption?.text || updatedValue;
21389
21389
  }
21390
21390
  if (prev !== updatedValue) {
21391
21391
  this._value = updatedValue;
@@ -21395,9 +21395,7 @@ so this becomes the fallback color for the slot */ ''}
21395
21395
  // Can remove when following resolved: https://github.com/microsoft/fast/issues/6749
21396
21396
  this.filter = next;
21397
21397
  this.filterOptions();
21398
- this.selectedIndex = this.options
21399
- .map(option => option.text)
21400
- .indexOf(this.value);
21398
+ this.selectedIndex = this.findIndexOfValidOption(this.value);
21401
21399
  }
21402
21400
  /**
21403
21401
  * The list of options.
@@ -21406,7 +21404,7 @@ so this becomes the fallback color for the slot */ ''}
21406
21404
  */
21407
21405
  get options() {
21408
21406
  Observable.track(this, 'options');
21409
- return this.filteredOptions?.length
21407
+ return this.filteredOptions && this.filter
21410
21408
  ? this.filteredOptions
21411
21409
  : this._options;
21412
21410
  }
@@ -21510,8 +21508,6 @@ so this becomes the fallback color for the slot */ ''}
21510
21508
  o.visuallyHidden = !this.filteredOptions.includes(o);
21511
21509
  });
21512
21510
  }
21513
- const enabledOptions = this.filteredOptions.filter(o => !o.disabled);
21514
- this.filteredOptions = enabledOptions;
21515
21511
  }
21516
21512
  /**
21517
21513
  * @internal
@@ -21520,11 +21516,9 @@ so this becomes the fallback color for the slot */ ''}
21520
21516
  this.filter = this.control.value;
21521
21517
  this.filterOptions();
21522
21518
  if (!this.isAutocompleteInline) {
21523
- this.selectedIndex = this.options
21524
- .map(option => option.text)
21525
- .indexOf(this.control.value);
21519
+ this.selectedIndex = this.findIndexOfValidOption(this.control.value);
21526
21520
  }
21527
- if (!(e.inputType.includes('deleteContent') || !this.filter.length)) {
21521
+ if (!e.inputType.includes('deleteContent') && this.filter.length) {
21528
21522
  if (this.isAutocompleteList && !this.open) {
21529
21523
  this.open = true;
21530
21524
  }
@@ -21669,7 +21663,8 @@ so this becomes the fallback color for the slot */ ''}
21669
21663
  */
21670
21664
  setDefaultSelectedOption() {
21671
21665
  if (this.$fastController.isConnected && this.options) {
21672
- const selectedIndex = this.options.findIndex(el => el.getAttribute('selected') !== null || el.selected);
21666
+ const selectedIndex = this.options.findIndex(el => !el.disabled
21667
+ && (el.getAttribute('selected') !== null || el.selected));
21673
21668
  this.selectedIndex = selectedIndex;
21674
21669
  if (!this.dirtyValue && this.firstSelectedOption) {
21675
21670
  this.value = this.firstSelectedOption.text;
@@ -21682,13 +21677,21 @@ so this becomes the fallback color for the slot */ ''}
21682
21677
  */
21683
21678
  selectedIndexChanged(prev, next) {
21684
21679
  if (this.$fastController.isConnected) {
21685
- const pinnedSelectedIndex = limit(-1, this.options.length - 1, next);
21680
+ let pinnedSelectedIndex = limit(-1, this.options.length - 1, next);
21681
+ // Ensure selectedIndex doesn't get set to a disabled option
21682
+ if (this.options[pinnedSelectedIndex]?.disabled) {
21683
+ pinnedSelectedIndex = -1;
21684
+ }
21686
21685
  // we only want to call the super method when the selectedIndex is in range
21687
21686
  if (pinnedSelectedIndex !== this.selectedIndex) {
21688
21687
  this.selectedIndex = pinnedSelectedIndex;
21689
21688
  return;
21690
21689
  }
21691
21690
  super.selectedIndexChanged(prev, pinnedSelectedIndex);
21691
+ // the base class doesn't call this when no option is selected, but we need to,
21692
+ // otherwise selectedOptions, ariaActiveDescendant, and the previously selected
21693
+ // option's selected state won't be updated
21694
+ this.setSelectedOptions();
21692
21695
  }
21693
21696
  }
21694
21697
  /**
@@ -21702,16 +21705,42 @@ so this becomes the fallback color for the slot */ ''}
21702
21705
  }
21703
21706
  this.ariaDisabled = this.disabled ? 'true' : 'false';
21704
21707
  }
21708
+ /**
21709
+ * Move focus to the next selectable option.
21710
+ *
21711
+ * @internal
21712
+ * @remarks Has the same behavior as `Listbox.selectNextOption` except it skips disabled options.
21713
+ * Overrides `Listbox.selectNextOption`
21714
+ */
21715
+ selectNextOption() {
21716
+ if (!this.disabled) {
21717
+ let newIndex = this.selectedIndex;
21718
+ do {
21719
+ if (newIndex + 1 >= this.options.length) {
21720
+ return;
21721
+ }
21722
+ newIndex += 1;
21723
+ } while (this.options[newIndex].disabled);
21724
+ this.selectedIndex = newIndex;
21725
+ }
21726
+ }
21705
21727
  /**
21706
21728
  * Move focus to the previous selectable option.
21707
21729
  *
21708
21730
  * @internal
21709
- * @remarks
21731
+ * @remarks Has the same behavior as `Listbox.selectPreviousOption` except it skips disabled options and allows moving focus to the input.
21710
21732
  * Overrides `Listbox.selectPreviousOption`
21711
21733
  */
21712
21734
  selectPreviousOption() {
21713
- if (!this.disabled && this.selectedIndex >= 0) {
21714
- this.selectedIndex -= 1;
21735
+ if (!this.disabled) {
21736
+ let newIndex = this.selectedIndex;
21737
+ do {
21738
+ newIndex -= 1;
21739
+ if (newIndex < 0) {
21740
+ break;
21741
+ }
21742
+ } while (this.options[newIndex].disabled);
21743
+ this.selectedIndex = newIndex;
21715
21744
  }
21716
21745
  }
21717
21746
  /**
@@ -21786,6 +21815,17 @@ so this becomes the fallback color for the slot */ ''}
21786
21815
  this.proxy.placeholder = this.placeholder ?? '';
21787
21816
  }
21788
21817
  }
21818
+ /**
21819
+ * Need to update even when options is empty.
21820
+ * @internal
21821
+ * @remarks Same as `Listbox.setSelectedOptions` except does not check if options is non-empty.
21822
+ * Overrides: `Listbox.setSelectedOptions`
21823
+ */
21824
+ setSelectedOptions() {
21825
+ this.selectedOptions = this.selectedIndex > -1 ? [this.options[this.selectedIndex]] : [];
21826
+ this.ariaActiveDescendant = this.firstSelectedOption?.id ?? '';
21827
+ this.focusAndScrollOptionIntoView();
21828
+ }
21789
21829
  /**
21790
21830
  * Ensure that the entire list of options is used when setting the selected property.
21791
21831
  * @internal
@@ -21887,6 +21927,9 @@ so this becomes the fallback color for the slot */ ''}
21887
21927
  this.valueUpdatedByInput = false;
21888
21928
  }
21889
21929
  }
21930
+ findIndexOfValidOption(optionText) {
21931
+ return this.options.findIndex(o => !o.disabled && o.text === optionText);
21932
+ }
21890
21933
  }
21891
21934
  __decorate$1([
21892
21935
  attr