@anguless/angulux 22.6.9 → 22.6.11

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.
@@ -1099,16 +1099,35 @@ class Select extends BaseInput {
1099
1099
  getOptionGroupChildren(optionGroup) {
1100
1100
  return this.optionGroupChildren !== undefined && this.optionGroupChildren !== null ? resolveFieldData(optionGroup, this.optionGroupChildren) : optionGroup.items;
1101
1101
  }
1102
+ /**
1103
+ * For the list `visibleOptions()` returned last: how many group headers come before each
1104
+ * index. Every option row asks for its position and for the size of the set on every check,
1105
+ * and each answer used to walk the whole list, so a panel of a thousand options walked a
1106
+ * million entries per check.
1107
+ */
1108
+ _groupHeaders;
1109
+ groupHeadersBefore(options) {
1110
+ if (this._groupHeaders?.of !== options) {
1111
+ const before = new Array(options.length + 1);
1112
+ before[0] = 0;
1113
+ for (let i = 0; i < options.length; i++)
1114
+ before[i + 1] = before[i] + (this.isOptionGroup(options[i]) ? 1 : 0);
1115
+ this._groupHeaders = { of: options, before };
1116
+ }
1117
+ return this._groupHeaders.before;
1118
+ }
1102
1119
  getAriaPosInset(index) {
1103
- return ((this.optionGroupLabel
1104
- ? index -
1105
- this.visibleOptions()
1106
- .slice(0, index)
1107
- .filter((option) => this.isOptionGroup(option)).length
1108
- : index) + 1);
1120
+ if (!this.optionGroupLabel)
1121
+ return index + 1;
1122
+ const options = this.visibleOptions();
1123
+ // Anything but a position in the list keeps the arithmetic `slice` did with it.
1124
+ if (!Number.isInteger(index) || index < 0)
1125
+ return index - options.slice(0, index).filter((option) => this.isOptionGroup(option)).length + 1;
1126
+ return index - this.groupHeadersBefore(options)[Math.min(index, options.length)] + 1;
1109
1127
  }
1110
1128
  get ariaSetSize() {
1111
- return this.visibleOptions().filter((option) => !this.isOptionGroup(option)).length;
1129
+ const options = this.visibleOptions();
1130
+ return options.length - this.groupHeadersBefore(options)[options.length];
1112
1131
  }
1113
1132
  /**
1114
1133
  * Callback to invoke on filter reset.