@mozaic-ds/angular 2.0.54 → 2.0.56

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.
@@ -16772,9 +16772,9 @@ class MozComboboxComponent {
16772
16772
  return Math.min(count * ITEM_SIZE_PX, VIEWPORT_HEIGHT_PX);
16773
16773
  }, ...(ngDevMode ? [{ debugName: "viewportHeight" }] : /* istanbul ignore next */ []));
16774
16774
  /**
16775
- * Whether a section's children are all selected. Includes disabled children
16776
- * so that the header checkbox reflects the true state even when some rows
16777
- * were pre-selected programmatically.
16775
+ * Whether all non-disabled children of a section are selected. Disabled
16776
+ * children are ignored so the header state stays aligned with what a click
16777
+ * on the section checkbox will actually toggle.
16778
16778
  */
16779
16779
  isSectionFullySelected = (sectionTitle) => {
16780
16780
  const val = this._currentValueAsArray();
@@ -16782,18 +16782,18 @@ class MozComboboxComponent {
16782
16782
  return false;
16783
16783
  const cmp = this.compareWith();
16784
16784
  const children = this.flatItems()
16785
- .filter((i) => isFlatOption(i) && i.sectionTitle === sectionTitle)
16785
+ .filter((i) => isFlatOption(i) && i.sectionTitle === sectionTitle && !i.disabled)
16786
16786
  .map((i) => i.value);
16787
16787
  return children.length > 0 && children.every((cv) => val.some((sv) => cmp(sv, cv)));
16788
16788
  };
16789
- /** Whether a section's children are partially selected (includes disabled children). */
16789
+ /** Whether a section's non-disabled children are partially selected. */
16790
16790
  isSectionPartiallySelected = (sectionTitle) => {
16791
16791
  const val = this._currentValueAsArray();
16792
16792
  if (val.length === 0)
16793
16793
  return false;
16794
16794
  const cmp = this.compareWith();
16795
16795
  const children = this.flatItems()
16796
- .filter((i) => isFlatOption(i) && i.sectionTitle === sectionTitle)
16796
+ .filter((i) => isFlatOption(i) && i.sectionTitle === sectionTitle && !i.disabled)
16797
16797
  .map((i) => i.value);
16798
16798
  const selectedCount = children.filter((cv) => val.some((sv) => cmp(sv, cv))).length;
16799
16799
  return selectedCount > 0 && selectedCount < children.length;
@@ -17040,13 +17040,34 @@ class MozComboboxComponent {
17040
17040
  selectAll() {
17041
17041
  if (!this.multiple())
17042
17042
  return;
17043
- this.value.set([...this.allSelectableValues()]);
17043
+ const cmp = this.compareWith();
17044
+ const disabledValues = this.flatItems()
17045
+ .filter((i) => isFlatOption(i) && !!i.disabled)
17046
+ .map((i) => i.value);
17047
+ const current = this._currentValueAsArray();
17048
+ const keptDisabled = current.filter((sv) => disabledValues.some((dv) => cmp(sv, dv)));
17049
+ const next = [...this.allSelectableValues()];
17050
+ for (const dv of keptDisabled) {
17051
+ if (!next.some((sv) => cmp(sv, dv)))
17052
+ next.push(dv);
17053
+ }
17054
+ this.value.set(next);
17044
17055
  }
17045
17056
  clearSelection() {
17057
+ const cmp = this.compareWith();
17058
+ const disabledValues = this.flatItems()
17059
+ .filter((i) => isFlatOption(i) && !!i.disabled)
17060
+ .map((i) => i.value);
17046
17061
  if (this.multiple()) {
17047
- this.value.set([]);
17062
+ const current = this._currentValueAsArray();
17063
+ const kept = current.filter((sv) => disabledValues.some((dv) => cmp(sv, dv)));
17064
+ this.value.set(kept);
17048
17065
  }
17049
17066
  else {
17067
+ const raw = this.value();
17068
+ if (raw != null && !Array.isArray(raw) && disabledValues.some((dv) => cmp(raw, dv))) {
17069
+ return;
17070
+ }
17050
17071
  this.value.set(null);
17051
17072
  }
17052
17073
  }