@brightspace-ui/core 3.28.5 → 3.28.6

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.
@@ -29,7 +29,6 @@
29
29
 
30
30
  <d2l-demo-page page-title="d2l-list (nested)">
31
31
 
32
- <h2>Nested</h2>
33
32
 
34
33
  <d2l-demo-snippet>
35
34
  <template>
@@ -12,13 +12,19 @@ const keyCodes = {
12
12
 
13
13
  export class SelectionInfo {
14
14
 
15
- constructor(keys, state) {
15
+ constructor(keys, state, allEnabledSelected) {
16
+ if (!allEnabledSelected) allEnabledSelected = false;
16
17
  if (!keys) keys = [];
17
18
  if (!state) state = SelectionInfo.states.none;
19
+ this._allEnabledSelected = allEnabledSelected;
18
20
  this._keys = keys;
19
21
  this._state = state;
20
22
  }
21
23
 
24
+ get allEnabledSelected() {
25
+ return this._allEnabledSelected;
26
+ }
27
+
22
28
  get keys() {
23
29
  return this._keys;
24
30
  }
@@ -87,6 +93,7 @@ export const SelectionMixin = superclass => class extends RtlMixin(CollectionMix
87
93
  }
88
94
 
89
95
  getSelectionInfo() {
96
+ let allEnabledSelected = true;
90
97
  let state = SelectionInfo.states.none;
91
98
  const keys = [];
92
99
 
@@ -95,6 +102,7 @@ export const SelectionMixin = superclass => class extends RtlMixin(CollectionMix
95
102
  } else {
96
103
  this._selectionSelectables.forEach(selectable => {
97
104
  if (selectable.selected) keys.push(selectable.key);
105
+ if (!selectable.disabled && !selectable.selected) allEnabledSelected = false;
98
106
  if (selectable._indeterminate) state = SelectionInfo.states.some;
99
107
  });
100
108
 
@@ -104,19 +112,23 @@ export const SelectionMixin = superclass => class extends RtlMixin(CollectionMix
104
112
  }
105
113
  }
106
114
 
107
- return new SelectionInfo(keys, state);
115
+ return new SelectionInfo(keys, state, allEnabledSelected);
108
116
  }
109
117
 
110
118
  setSelectionForAll(selected, selectAllPages) {
111
119
  if (this.selectionSingle && selected) return;
112
-
113
120
  this._selectAllPages = (selected && selectAllPages);
114
121
 
122
+ const { allEnabledSelected } = this.getSelectionInfo();
123
+
115
124
  this._selectionSelectables.forEach(selectable => {
116
- if (!selectable.disabled && !!selectable.selected !== selected) {
117
- selectable.selected = selected;
125
+ if (this.selectionSingle || this._selectAllPages) {
126
+ if (selectable.selected !== selected) selectable.selected = selected;
127
+ } else if (!selectable.disabled && selectable.selected !== !allEnabledSelected) {
128
+ selectable.selected = !allEnabledSelected;
118
129
  }
119
130
  });
131
+
120
132
  this._updateSelectionObservers();
121
133
  }
122
134
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.28.5",
3
+ "version": "3.28.6",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",