@brightspace-ui/core 1.197.4 → 1.200.0

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.
@@ -60,11 +60,7 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
60
60
  this._isHovering = false;
61
61
  this._isFading = false;
62
62
 
63
- this.__onWholeKeypress = this.__onKeypress.bind(this);
64
- this.__onMouseUp = this.__onMouseUp.bind(this);
65
- this.__onMouseEnter = this.__onMouseEnter.bind(this);
66
- this.__onMouseLeave = this.__onMouseLeave.bind(this);
67
- this.__onTouchStart = this.__onTouchStart.bind(this);
63
+ this._onOutsideClick = this._onOutsideClick.bind(this);
68
64
  this._contentRendered = null;
69
65
  this._openerRendered = null;
70
66
  }
@@ -77,7 +73,6 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
77
73
  this.addEventListener('mouseup', this.__onMouseUp);
78
74
  this.addEventListener('mouseenter', this.__onMouseEnter);
79
75
  this.addEventListener('mouseleave', this.__onMouseLeave);
80
- this.addEventListener('touchstart', this.__onTouchStart);
81
76
 
82
77
  if (this.openOnHover) {
83
78
  document.body.addEventListener('mouseup', this._onOutsideClick);
@@ -91,7 +86,6 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
91
86
  this.removeEventListener('mouseup', this.__onMouseUp);
92
87
  this.removeEventListener('mouseenter', this.__onMouseEnter);
93
88
  this.removeEventListener('mouseleave', this.__onMouseLeave);
94
- this.removeEventListener('touchstart', this.__onTouchStart);
95
89
 
96
90
  if (this.openOnHover) {
97
91
  document.body.removeEventListener('mouseup', this._onOutsideClick);
@@ -172,6 +166,7 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
172
166
  return;
173
167
  }
174
168
  content.toggleOpen(applyFocus);
169
+ this._isOpen = !this._isOpen;
175
170
  }
176
171
 
177
172
  __getContentElement() {
@@ -190,47 +185,57 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
190
185
  this._isOpenedViaClick = false;
191
186
  }
192
187
 
193
- /* used by open-on-hover option */
194
- __onDropdownMouseEnter() {
188
+ __onDropdownMouseUp() {
195
189
  this._isOpen = true;
196
190
  this._isFading = false;
191
+ this._isHovering = false;
192
+ this._isOpenedViaClick = true;
197
193
  this._closeTimerStop();
198
194
  }
199
195
 
200
- /* used by open-on-hover option */
201
- __onDropdownMouseLeave(e) {
202
- if (this.__getContentElement() !== e.target) return;
203
- if (!this._isOpenedViaClick) this._isOpen = false;
204
- this._closeTimerStart();
205
- }
206
-
207
196
  __onKeypress(e) {
208
- if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
209
- this.__onOpenerKeyPress(e);
197
+ if (e.srcElement === this || isComposedAncestor(this.getOpenerElement(), e.srcElement)) {
198
+ if (e.keyCode !== 13 && e.keyCode !== 32) return;
199
+ if (this.noAutoOpen) return;
200
+ if (!this.openOnHover) {
201
+ this.toggleOpen(true);
202
+ } else {
203
+ this._closeTimerStop();
204
+ e.preventDefault();
205
+ this._isOpenedViaClick = true;
206
+ this.openDropdown(true);
207
+ }
210
208
  }
211
209
  }
212
210
 
213
- __onMouseEnter(e) {
211
+ async __onMouseEnter() {
214
212
  if (!this.openOnHover) return;
215
- if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
216
- this.__onOpenerMouseEnter(e);
217
- } else if (isComposedAncestor(this.__getContentElement(), e.srcElement)) {
218
- this.__onDropdownMouseEnter(e);
219
- }
213
+ // do not respond to hover events on mobile screens
214
+ const dropdownContent = this.__getContentElement();
215
+ if (dropdownContent._useMobileStyling) return;
216
+ clearTimeout(this._dismissTimerId);
217
+ if (!this._isOpen) await this.openDropdown(false);
218
+ this._closeTimerStop();
219
+ if (!this._isOpenedViaClick) this._isHovering = true;
220
220
  }
221
221
 
222
- __onMouseLeave(e) {
222
+ async __onMouseLeave() {
223
223
  if (!this.openOnHover) return;
224
- if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
225
- this.__onOpenerMouseLeave(e);
226
- } else if (isComposedAncestor(this.__getContentElement(), e.srcElement)) {
227
- this.__onDropdownMouseLeave(e);
228
- }
224
+ // do not respond to hover events on mobile screens
225
+ const dropdownContent = this.__getContentElement();
226
+ if (dropdownContent._useMobileStyling) return;
227
+ this._isHovering = false;
228
+ if (this._isOpenedViaClick) return;
229
+ //Wait before closing so we don't lose hover when we jump from opener to card
230
+ clearTimeout(this._dismissTimerId);
231
+ await this.closeDropdown(true);
229
232
  }
230
233
 
231
234
  __onMouseUp(e) {
232
- if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
235
+ if (e.srcElement === this || isComposedAncestor(this.getOpenerElement(), e.srcElement)) {
233
236
  this.__onOpenerMouseUp(e);
237
+ } else if (this.openOnHover && isComposedAncestor(this.__getContentElement(), e.srcElement)) {
238
+ this.__onDropdownMouseUp();
234
239
  }
235
240
  }
236
241
 
@@ -244,42 +249,6 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
244
249
  this._isFading = false;
245
250
  }
246
251
 
247
- __onOpenerKeyPress(e) {
248
- if (e.keyCode !== 13 && e.keyCode !== 32) return;
249
- if (this.noAutoOpen) return;
250
- if (!this.openOnHover) {
251
- this.toggleOpen(true);
252
- } else {
253
- this._closeTimerStop();
254
- e.preventDefault();
255
- this._isOpenedViaClick = true;
256
- this.openDropdown(true);
257
- }
258
- }
259
-
260
- /* used by open-on-hover option */
261
- async __onOpenerMouseEnter() {
262
- // do not respond to hover events on mobile screens
263
- const dropdownContent = this.__getContentElement();
264
- if (dropdownContent._useMobileStyling) return;
265
- clearTimeout(this._dismissTimerId);
266
- if (!this._isOpen) await this.openDropdown(false);
267
- this._closeTimerStop();
268
- this._isHovering = true;
269
- }
270
-
271
- /* used by open-on-hover option */
272
- async __onOpenerMouseLeave() {
273
- // do not respond to hover events on mobile screens
274
- const dropdownContent = this.__getContentElement();
275
- if (dropdownContent._useMobileStyling) return;
276
- this._isHovering = false;
277
- if (this._isOpenedViaClick) return;
278
- //Wait before closing so we don't lose hover when we jump from opener to card
279
- clearTimeout(this._dismissTimerId);
280
- await this.closeDropdown(true);
281
- }
282
-
283
252
  __onOpenerMouseUp(e) {
284
253
  if (this.noAutoOpen) return;
285
254
  if (this.openOnHover) {
@@ -296,27 +265,6 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
296
265
  } else this.toggleOpen(false);
297
266
  }
298
267
 
299
- /* used by open-on-hover option */
300
- __onOpenerTouch(e) {
301
- //Prevents touch from triggering mouseover/hover behavior
302
- e.preventDefault();
303
- this._closeTimerStop();
304
- if (this._isOpen) {
305
- this.closeDropdown();
306
- }
307
- else {
308
- this._isOpenedViaClick = true;
309
- this.openDropdown(true);
310
- }
311
- }
312
-
313
- __onTouchStart(e) {
314
- if (!this.openOnHover) return;
315
- if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
316
- this.__onOpenerTouch(e);
317
- }
318
- }
319
-
320
268
  /* used by open-on-hover option */
321
269
  _closeTimerStart() {
322
270
  if (this._isOpen) return;
@@ -339,10 +287,11 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
339
287
  _onOutsideClick(e) {
340
288
  if (!this._isOpen) return;
341
289
  const isWithinDropdown = isComposedAncestor(this.__getContentElement(), e.composedPath()[0]);
290
+ const isWithinOpener = isComposedAncestor(this.getOpenerElement(), e.composedPath()[0]);
342
291
  const isBackdropClick = isWithinDropdown
343
292
  && this.__getContentElement()._useMobileStyling
344
293
  && e.composedPath().find(node => node.nodeName === 'D2L-BACKDROP');
345
- if (!isWithinDropdown || isBackdropClick) {
294
+ if (!isWithinOpener && (!isWithinDropdown || isBackdropClick)) {
346
295
  this.closeDropdown();
347
296
  }
348
297
  }
@@ -244,10 +244,10 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
244
244
  const countBadgeId = `filters-applied-count-${dimension.key}`;
245
245
  const filtersAppliedText = `${this.localize('components.filter.filterCountDescription', { number: dimension.appliedCount })}`;
246
246
  return html`<d2l-menu-item text="${dimension.text}" description="${dimension.text}." aria-describedby="${countBadgeId}">
247
- ${builtDimension}
248
247
  <div slot="supporting">
249
248
  <d2l-count-badge id="${countBadgeId}" number="${dimension.appliedCount}" max-digits="2" text="${filtersAppliedText}" hide-zero></d2l-count-badge>
250
249
  </div>
250
+ ${builtDimension}
251
251
  </d2l-menu-item>`;
252
252
  });
253
253
  }
@@ -364,6 +364,7 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
364
364
  id="${SET_DIMENSION_ID_PREFIX}${dimension.key}"
365
365
  @d2l-list-selection-change="${this._handleChangeSetDimension}"
366
366
  extend-separators
367
+ grid
367
368
  ?selection-single="${dimension.selectionSingle}">
368
369
  ${dimension.values.map(item => html`
369
370
  <d2l-list-item
@@ -2,50 +2,84 @@
2
2
 
3
3
  The selection components (`d2l-selection-action`, `d2l-selection-input`, `d2l-selection-select-all`, `d2l-selection-summary`, `d2l-selection-action`) are low-level components that provide the ability to create selection interfaces with select-all and bulk-action behaviours.
4
4
 
5
+ <!-- docs: start hidden content -->
5
6
  ![Selection](./screenshots/selection-multiple.png?raw=true)
6
7
 
7
8
  ![Selection](./screenshots/selection-single.png?raw=true)
9
+ <!-- docs: end hidden content -->
8
10
 
9
11
  ## SelectionMixin
10
12
 
11
- The selection components above work with a component that extends the `SelectionMixin`, which acts like a controller for the checkboxes, radios, actions, etc. The `d2l-selection-input` component must be placed _within_ the component that extends the `SelectionMixin`. The other selection components may also be placed inside the `SelectionMixin` component, or in the same DOM scope with the `selection-for` attribute set to the id of that component.
12
-
13
- The `d2l-list` already extends `SelectionMixin` and should always be used for lists, however a custom selection control can be easily defined to enable the use of these selection controls in different semantic contexts or radically different layouts. The `SelectionMixin` defines the `selection-single` attribute that consumers can specify for single selection behaviour.
14
-
15
- ```javascript
16
- import { html, LitElement } from 'lit-element/lit-element.js';
17
- import { SelectionMixin } from '@brightspace-ui/core/components/selection-mixin.js';
18
-
19
- class CustomSelection extends SelectionMixin(LitElement) {
20
- render() {
21
- return html`
22
- <slot></slot>
23
- `;
24
- }
25
- }
26
- customElements.define('d2l-custom-selection', CustomSelection);
27
- ```
28
-
29
- **Properties:**
30
-
31
- | Property | Type | Description |
32
- |--|--|--|
33
- | `selection-single` | Boolean | Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item. |
34
-
35
- The selection components can then be used within the custom selection component as shown below.
13
+ The selection components below work with a component that extends the `SelectionMixin`, which acts like a controller for the checkboxes, radios, actions, etc. The `d2l-selection-input` component must be placed _within_ the component that extends the `SelectionMixin`. The other selection components may also be placed inside the `SelectionMixin` component, or in the same DOM scope with the `selection-for` attribute set to the id of that component.
36
14
 
15
+ <!-- docs: demo live name:d2l-demo-selection display:block -->
37
16
  ```html
17
+ <script type="module">
18
+ import { css, html, LitElement } from 'lit-element/lit-element.js';
19
+ import { SelectionMixin } from '@brightspace-ui/core/components/selection/selection-mixin.js';
20
+
21
+ class CustomSelection extends SelectionMixin(LitElement) {
22
+ static get styles() {
23
+ return css`
24
+ :host {
25
+ display: block;
26
+ }
27
+ `;
28
+ }
29
+ render() {
30
+ return html`
31
+ <slot></slot>
32
+ `;
33
+ }
34
+ }
35
+ customElements.define('d2l-demo-selection', CustomSelection);
36
+ </script>
38
37
  <script type="module">
39
38
  import '@brightspace-ui/core/components/selection/selection-action.js';
40
39
  import '@brightspace-ui/core/components/selection/selection-input.js';
41
40
  import '@brightspace-ui/core/components/selection/selection-select-all.js';
42
41
  import '@brightspace-ui/core/components/selection/selection-summary.js';
43
42
  </script>
44
- <d2l-custom-selection>
45
- <div>
46
- <d2l-selection-select-all></d2l-selection-select-all>
47
- <d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
48
- <d2l-selection-action text="Settings" icon="tier1:gear"></d2l-selection-action>
43
+ <!-- docs: start hidden content -->
44
+ <script type="module">
45
+ import '@brightspace-ui/core/components/selection/demo/demo-selection.js';
46
+ </script>
47
+ <style>
48
+ ul {
49
+ padding: 0;
50
+ }
51
+ li {
52
+ list-style-type: none;
53
+ }
54
+ li, .d2l-selection-header, .d2l-selection-header-wrapper {
55
+ align-items: center;
56
+ display: flex;
57
+ }
58
+ d2l-selection-input {
59
+ margin-right: 10px;
60
+ }
61
+ [dir="rtl"] d2l-selection-input {
62
+ margin-left: 10px;
63
+ margin-right: 0;
64
+ }
65
+ .d2l-selection-header-wrapper {
66
+ flex-wrap: wrap;
67
+ }
68
+ .d2l-selection-header {
69
+ flex: auto;
70
+ }
71
+ d2l-selection-summary {
72
+ flex: none;
73
+ }
74
+ </style>
75
+ <!-- docs: end hidden content -->
76
+ <d2l-demo-selection>
77
+ <div class="d2l-selection-header-wrapper">
78
+ <div class="d2l-selection-header">
79
+ <d2l-selection-select-all></d2l-selection-select-all>
80
+ <d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
81
+ <d2l-selection-action text="Settings" icon="tier1:gear"></d2l-selection-action>
82
+ </div>
49
83
  <d2l-selection-summary></d2l-selection-summary>
50
84
  </div>
51
85
  <ul>
@@ -53,21 +87,26 @@ The selection components can then be used within the custom selection component
53
87
  <li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
54
88
  <li><d2l-selection-input key="mth" label="Math"></d2l-selection-input>Math</li>
55
89
  </ul>
56
- </d2l-custom-selection>
90
+ </d2l-demo-selection>
57
91
  ```
58
92
 
59
- Or, the non-`d2l-selection-input` components can be used outside the custom selection component as long as they are in the same DOM scope:
93
+ The `d2l-list` already extends `SelectionMixin` and should always be used for lists, however a custom selection control can be easily defined to enable the use of these selection controls in different semantic contexts or radically different layouts. The `SelectionMixin` defines the `selection-single` attribute that consumers can specify for single selection behaviour.
94
+
95
+ <!-- docs: start hidden content -->
96
+ ### Properties
97
+
98
+ | Property | Type | Description |
99
+ |---|---|---|
100
+ | `selection-single` | Boolean | Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item. |
101
+ <!-- docs: end hidden content -->
102
+
103
+ ### Usage
104
+
105
+ The selection components can then be used within the custom selection component as shown above, or the non-`d2l-selection-input` components can be used outside the custom selection component as long as they are in the same DOM scope:
60
106
 
61
107
  ```html
62
- <script type="module">
63
- import '@brightspace-ui/core/components/selection/selection-action.js';
64
- import '@brightspace-ui/core/components/selection/selection-input.js';
65
- import '@brightspace-ui/core/components/selection/selection-select-all.js';
66
- import '@brightspace-ui/core/components/selection/selection-summary.js';
67
- </script>
68
108
  <div>
69
109
  <d2l-selection-select-all selection-for="custom"></d2l-selection-select-all>
70
- <d2l-selection-action selection-for="custom" text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
71
110
  <d2l-selection-action selection-for="custom" text="Settings" icon="tier1:gear"></d2l-selection-action>
72
111
  <d2l-selection-summary selection-for="custom"></d2l-selection-summary>
73
112
  </div>
@@ -75,73 +114,216 @@ Or, the non-`d2l-selection-input` components can be used outside the custom sele
75
114
  <ul>
76
115
  <li><d2l-selection-input key="geo" label="Geography" selected></d2l-selection-input>Geography</li>
77
116
  <li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
78
- <li><d2l-selection-input key="mth" label="Math"></d2l-selection-input>Math</li>
79
117
  </ul>
80
118
  </d2l-custom-selection>
81
119
  ```
82
120
 
83
- ## d2l-selection-action
121
+ ## Selection Action [d2l-selection-action]
84
122
 
85
123
  The `d2l-selection-action` is an optional component that provides a button for actions associated with the selection component (ex. bulk actions). The `requires-selection` attribute may be specified to indicate that the button should be non-interactive if nothing is selected.
86
124
 
87
- **Properties:**
125
+ <!-- docs: demo live name:d2l-selection-action -->
126
+ ```html
127
+ <script type="module">
128
+ import '@brightspace-ui/core/components/selection/selection-action.js';
129
+ </script>
130
+ <d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow"></d2l-selection-action>
131
+ ```
132
+
133
+ <!-- docs: start hidden content -->
134
+ ### Properties
88
135
 
89
136
  | Property | Type | Description |
90
- |--|--|--|
137
+ |---|---|---|
91
138
  | `icon` | String | Preset icon key (e.g. "tier1:gear"). |
92
139
  | `requires-selection` | Boolean | Whether the action requires one or more selected items. If no items are selected, the action button will be focusable and a hint displayed in a tooltip. |
93
140
  | `selection-for` | String | Id of the corresponding `SelectionMixin` component, if not placed within it. |
94
141
  | `text` | String, required | Text to be shown for the action. |
95
142
 
96
- **Events:**
143
+ ### Events
97
144
 
98
145
  | Event | Description |
99
- |--|--|
146
+ |---|---|
100
147
  | `d2l-selection-action-click` | Dispatched when the user clicks the action button. The `SelectionInfo` is provided as the event `detail`. If `requires-selection` was specified then the event will only be dispatched if items are selected. |
148
+ <!-- docs: end hidden content -->
101
149
 
102
- ## d2l-selection-input
150
+ ## Selection Input [d2l-selection-input]
103
151
 
104
152
  The `d2l-selection-input` is a required component in selection controls - without it, there wouldn't be anything for the user to select! Note: `d2l-list-item` already provides a selection input for selectable list items. If `d2l-selection-input` is placed within a selection control that specifies `selection-single`, then radios will be rendered instead of checkboxes.
105
153
 
106
- **Properties:**
154
+ <!-- docs: demo live name:d2l-selection-input display:block -->
155
+ ```html
156
+ <script type="module">
157
+ import '@brightspace-ui/core/components/selection/selection-input.js';
158
+ import '@brightspace-ui/core/components/selection/demo/demo-selection.js';
159
+ </script>
160
+ <!-- docs: start hidden content -->
161
+ <style>
162
+ ul {
163
+ padding: 0;
164
+ }
165
+ li {
166
+ list-style-type: none;
167
+ align-items: center;
168
+ display: flex;
169
+ }
170
+ d2l-selection-input {
171
+ margin-right: 10px;
172
+ }
173
+ </style>
174
+ <!-- docs: end hidden content -->
175
+ <d2l-demo-selection>
176
+ <ul>
177
+ <li><d2l-selection-input key="geo" label="Geography" selected></d2l-selection-input>Geography</li>
178
+ <li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
179
+ </ul>
180
+ </d2l-demo-selection>
181
+ ```
182
+
183
+ <!-- docs: start hidden content -->
184
+ ### Properties
107
185
 
108
186
  | Property | Type | Description |
109
- |--|--|--|
110
- | `key` | String, required | Key to identify the the selectable. |
187
+ |---|---|---|
188
+ | `key` | String, required | Key to identify the selectable. |
111
189
  | `label` | String | Accessible hidden label for the input. |
112
190
  | `labelled-by` | String | Id reference to the accessible label for the input. **Note:** if specified, it must reference an element in the same DOM context. |
113
191
  | `selected` | Boolean | State of the input. |
114
192
 
115
- **Accessibility:** either `label` or `labelled-by` is required.
116
-
117
- **Events:**
193
+ ### Events
118
194
 
119
195
  | Event | Description |
120
- |--|--|
196
+ |---|---|
121
197
  | `d2l-selection-change` | Dispatched when the state of the input changes. |
198
+ <!-- docs: end hidden content -->
122
199
 
123
- ## d2l-selection-select-all
200
+ ### Accessibility Properties
201
+
202
+ Either `label` or `labelled-by` is **required**.
203
+
204
+ ## Select All [d2l-selection-select-all]
124
205
 
125
206
  The `d2l-selection-select-all` is an optional component that provides a checkbox for bulk selecting the selectable elements within the selection control. Its state will also be automatically updated when the state of the selectable elements change.
126
207
 
127
- **Properties:**
208
+ In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-select-all` for `d2l-select-input` outside of the custom selection element.
209
+
210
+ <!-- docs: demo live name:d2l-selection-select-all display:block -->
211
+ ```html
212
+ <script type="module">
213
+ import '@brightspace-ui/core/components/selection/selection-action.js';
214
+ import '@brightspace-ui/core/components/selection/selection-input.js';
215
+ import '@brightspace-ui/core/components/selection/selection-select-all.js';
216
+ import '@brightspace-ui/core/components/selection/demo/demo-selection.js';
217
+ </script>
218
+ <!-- docs: start hidden content -->
219
+ <style>
220
+ ul {
221
+ margin: 0;
222
+ padding: 0;
223
+ }
224
+ li {
225
+ align-items: center;
226
+ display: flex;
227
+ list-style-type: none;
228
+ }
229
+ div {
230
+ align-items: center;
231
+ display: flex;
232
+ }
233
+ d2l-selection-input {
234
+ margin-right: 10px;
235
+ }
236
+ #other-list {
237
+ padding-top: 1rem;
238
+ }
239
+ </style>
240
+ <!-- docs: end hidden content -->
241
+ <d2l-demo-selection>
242
+ <div>
243
+ <d2l-selection-select-all></d2l-selection-select-all>
244
+ <d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
245
+ </div>
246
+ <ul>
247
+ <li><d2l-selection-input key="geo" label="Geography"></d2l-selection-input>List 1 item 1</li>
248
+ <li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>List 1 item 2</li>
249
+ </ul>
250
+ </d2l-demo-selection>
251
+ <d2l-demo-selection id="other-list">
252
+ <ul>
253
+ <li><d2l-selection-input key="geo" label="Geography"></d2l-selection-input>List 2 item 1</li>
254
+ <li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>List 2 item 2</li>
255
+ </ul>
256
+ </d2l-demo-selection>
257
+ ```
258
+
259
+ <!-- docs: start hidden content -->
260
+ ### Properties
128
261
 
129
262
  | Property | Type | Description |
130
- |--|--|--|
263
+ |---|---|---|
131
264
  | `disabled` | Boolean | Disables the select all checkbox |
132
265
  | `selection-for` | String | Id of the corresponding `SelectionMixin` component, if not placed within it. |
266
+ <!-- docs: end hidden content -->
133
267
 
134
- ## d2l-selection-summary
268
+ ## Selection Summary [d2l-selection-summary]
135
269
 
136
270
  The `d2l-selection-summary` is an optional component that shows a simple count of the selected items within the selection control.
137
271
 
138
- **Properties:**
272
+ In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-summary` for `d2l-select-input` outside of the custom selection element.
273
+
274
+ <!-- docs: demo live name:d2l-selection-summary display:block -->
275
+ ```html
276
+ <script type="module">
277
+ import '@brightspace-ui/core/components/selection/selection-input.js';
278
+ import '@brightspace-ui/core/components/selection/selection-summary.js';
279
+ import '@brightspace-ui/core/components/selection/demo/demo-selection.js';
280
+ </script>
281
+ <!-- docs: start hidden content -->
282
+ <style>
283
+ ul {
284
+ margin: 0;
285
+ padding: 0;
286
+ }
287
+ li {
288
+ align-items: center;
289
+ display: flex;
290
+ list-style-type: none;
291
+ }
292
+ div {
293
+ align-items: center;
294
+ display: flex;
295
+ }
296
+ d2l-selection-input {
297
+ margin-right: 10px;
298
+ }
299
+ #other-list {
300
+ padding-top: 1rem;
301
+ }
302
+ </style>
303
+ <!-- docs: end hidden content -->
304
+ <d2l-demo-selection>
305
+ <div>
306
+ <d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
307
+ <d2l-selection-summary></d2l-selection-summary>
308
+ </div>
309
+ <ul>
310
+ <li><d2l-selection-input key="geo" label="Geography"></d2l-selection-input>List 1 item 1</li>
311
+ <li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>List 1 item 2</li>
312
+ </ul>
313
+ </d2l-demo-selection>
314
+ <d2l-demo-selection id="other-list">
315
+ <ul>
316
+ <li><d2l-selection-input key="geo" label="Geography"></d2l-selection-input>List 2 item 1</li>
317
+ <li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>List 2 item 2</li>
318
+ </ul>
319
+ </d2l-demo-selection>
320
+ ```
321
+
322
+ <!-- docs: start hidden content -->
323
+ ### Properties
139
324
 
140
325
  | Property | Type | Description |
141
- |--|--|--|
326
+ |---|---|---|
142
327
  | `no-selection-text` | String | Text to display if no items are selected. By default, the "0 selected" message is displayed. |
143
328
  | `selection-for` | String | Id of the corresponding `SelectionMixin` component, if not placed within it. |
144
-
145
- ## Future Enhancements
146
-
147
- Looking for an enhancement not listed here? Create a GitHub issue!
329
+ <!-- docs: end hidden content -->
@@ -0,0 +1,18 @@
1
+ import { css, html, LitElement } from 'lit-element/lit-element.js';
2
+ import { SelectionMixin } from '../selection-mixin.js';
3
+
4
+ class DemoSelection extends SelectionMixin(LitElement) {
5
+ static get styles() {
6
+ return css`
7
+ :host {
8
+ display: block;
9
+ }
10
+ `;
11
+ }
12
+ render() {
13
+ return html`
14
+ <slot></slot>
15
+ `;
16
+ }
17
+ }
18
+ customElements.define('d2l-demo-selection', DemoSelection);
@@ -10,25 +10,7 @@
10
10
  import '../selection-input.js';
11
11
  import '../selection-select-all.js';
12
12
  import '../selection-summary.js';
13
- import { css, html, LitElement } from 'lit-element/lit-element.js';
14
- import { SelectionMixin } from '../selection-mixin.js';
15
-
16
- class DemoSelection extends SelectionMixin(LitElement) {
17
- static get styles() {
18
- return css`
19
- :host {
20
- display: block;
21
- }
22
- `;
23
- }
24
- render() {
25
- return html`
26
- <slot></slot>
27
- `;
28
- }
29
- }
30
- customElements.define('d2l-demo-selection', DemoSelection);
31
-
13
+ import './demo-selection.js';
32
14
  </script>
33
15
  <style>
34
16
  ul {
@@ -131,7 +113,7 @@
131
113
  </div>
132
114
 
133
115
  <div class="d2l-selection-collection">
134
- Pick Your Bread
116
+ Pick Your Bread
135
117
  <div class="d2l-selection-header">
136
118
  <d2l-selection-select-all selection-for="collection-2"></d2l-selection-select-all>
137
119
  <d2l-selection-action selection-for="collection-2" text="Add Note" icon="tier1:add-message"></d2l-selection-action>
@@ -11,7 +11,7 @@ import { SelectionObserverMixin } from './selection-observer-mixin.js';
11
11
 
12
12
  /**
13
13
  * An action associated with a selection component.
14
- * @fires d2l-selection-action-click - Dispatched when the user clicks the action; provides the selection info
14
+ * @fires d2l-selection-action-click - Dispatched when the user clicks the action button. The `SelectionInfo` is provided as the event `detail`. If `requires-selection` was specified then the event will only be dispatched if items are selected.
15
15
  * @fires d2l-selection-observer-subscribe - Internal event
16
16
  */
17
17
  class Action extends LocalizeCoreElement(SelectionObserverMixin(ButtonMixin(RtlMixin(LitElement)))) {
@@ -19,7 +19,7 @@ class Action extends LocalizeCoreElement(SelectionObserverMixin(ButtonMixin(RtlM
19
19
  static get properties() {
20
20
  return {
21
21
  /**
22
- * Preset icon key (e.g. "tier1:gear")
22
+ * Preset icon key (e.g. `tier1:gear`)
23
23
  * @type {string}
24
24
  */
25
25
  icon: { type: String, reflect: true },
@@ -31,11 +31,12 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
31
31
  disabled: { type: Boolean },
32
32
  /**
33
33
  * Private. Force hovering state of input
34
+ * @ignore
34
35
  * @type {boolean}
35
36
  */
36
37
  hovering: { type: Boolean },
37
38
  /**
38
- * Key for the selectable
39
+ * REQUIRED: Key for the selectable
39
40
  * @type {string}
40
41
  */
41
42
  key: { type: String },
@@ -39,7 +39,7 @@ export const SelectionMixin = superclass => class extends RtlMixin(superclass) {
39
39
  static get properties() {
40
40
  return {
41
41
  /**
42
- * Whether the selection control is limited to single selection
42
+ * Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item.
43
43
  * @type {boolean}
44
44
  */
45
45
  selectionSingle: { type: Boolean, attribute: 'selection-single' }
@@ -6,12 +6,13 @@ export const SelectionObserverMixin = superclass => class extends superclass {
6
6
  static get properties() {
7
7
  return {
8
8
  /**
9
- * Id of the SelectionMixin component this component wants to observe (if not located within that component)
9
+ * Id of the `SelectionMixin` component this component wants to observe (if not located within that component)
10
10
  * @type {string}
11
11
  */
12
12
  selectionFor: { type: String, reflect: true, attribute: 'selection-for' },
13
13
  /**
14
14
  * The selection info (set by the selection component)
15
+ * @ignore
15
16
  * @type {object}
16
17
  */
17
18
  selectionInfo: { type: Object },
@@ -6954,7 +6954,7 @@
6954
6954
  },
6955
6955
  {
6956
6956
  "name": "selection-single",
6957
- "description": "Whether the selection control is limited to single selection",
6957
+ "description": "Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item.",
6958
6958
  "type": "boolean",
6959
6959
  "default": "false"
6960
6960
  }
@@ -6984,7 +6984,7 @@
6984
6984
  {
6985
6985
  "name": "selectionSingle",
6986
6986
  "attribute": "selection-single",
6987
- "description": "Whether the selection control is limited to single selection",
6987
+ "description": "Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item.",
6988
6988
  "type": "boolean",
6989
6989
  "default": "false"
6990
6990
  }
@@ -7966,6 +7966,27 @@
7966
7966
  }
7967
7967
  ]
7968
7968
  },
7969
+ {
7970
+ "name": "d2l-demo-selection",
7971
+ "path": "./components/selection/demo/demo-selection.js",
7972
+ "attributes": [
7973
+ {
7974
+ "name": "selection-single",
7975
+ "description": "Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item.",
7976
+ "type": "boolean",
7977
+ "default": "false"
7978
+ }
7979
+ ],
7980
+ "properties": [
7981
+ {
7982
+ "name": "selectionSingle",
7983
+ "attribute": "selection-single",
7984
+ "description": "Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item.",
7985
+ "type": "boolean",
7986
+ "default": "false"
7987
+ }
7988
+ ]
7989
+ },
7969
7990
  {
7970
7991
  "name": "d2l-selection-action",
7971
7992
  "path": "./components/selection/selection-action.js",
@@ -7973,7 +7994,7 @@
7973
7994
  "attributes": [
7974
7995
  {
7975
7996
  "name": "icon",
7976
- "description": "Preset icon key (e.g. \"tier1:gear\")",
7997
+ "description": "Preset icon key (e.g. `tier1:gear`)",
7977
7998
  "type": "string"
7978
7999
  },
7979
8000
  {
@@ -7988,14 +8009,9 @@
7988
8009
  },
7989
8010
  {
7990
8011
  "name": "selection-for",
7991
- "description": "Id of the SelectionMixin component this component wants to observe (if not located within that component)",
8012
+ "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
7992
8013
  "type": "string"
7993
8014
  },
7994
- {
7995
- "name": "selectionInfo",
7996
- "description": "The selection info (set by the selection component)",
7997
- "type": "object"
7998
- },
7999
8015
  {
8000
8016
  "name": "disabled-tooltip",
8001
8017
  "description": "Tooltip text when disabled",
@@ -8012,7 +8028,7 @@
8012
8028
  {
8013
8029
  "name": "icon",
8014
8030
  "attribute": "icon",
8015
- "description": "Preset icon key (e.g. \"tier1:gear\")",
8031
+ "description": "Preset icon key (e.g. `tier1:gear`)",
8016
8032
  "type": "string"
8017
8033
  },
8018
8034
  {
@@ -8030,14 +8046,11 @@
8030
8046
  {
8031
8047
  "name": "selectionFor",
8032
8048
  "attribute": "selection-for",
8033
- "description": "Id of the SelectionMixin component this component wants to observe (if not located within that component)",
8049
+ "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
8034
8050
  "type": "string"
8035
8051
  },
8036
8052
  {
8037
- "name": "selectionInfo",
8038
- "attribute": "selectionInfo",
8039
- "description": "The selection info (set by the selection component)",
8040
- "type": "object"
8053
+ "name": "selectionInfo"
8041
8054
  },
8042
8055
  {
8043
8056
  "name": "disabledTooltip",
@@ -8056,7 +8069,7 @@
8056
8069
  "events": [
8057
8070
  {
8058
8071
  "name": "d2l-selection-action-click",
8059
- "description": "Dispatched when the user clicks the action; provides the selection info"
8072
+ "description": "Dispatched when the user clicks the action button. The `SelectionInfo` is provided as the event `detail`. If `requires-selection` was specified then the event will only be dispatched if items are selected."
8060
8073
  },
8061
8074
  {
8062
8075
  "name": "d2l-selection-observer-subscribe",
@@ -8074,14 +8087,9 @@
8074
8087
  "description": "Disables the input",
8075
8088
  "type": "boolean"
8076
8089
  },
8077
- {
8078
- "name": "hovering",
8079
- "description": "Private. Force hovering state of input",
8080
- "type": "boolean"
8081
- },
8082
8090
  {
8083
8091
  "name": "key",
8084
- "description": "Key for the selectable",
8092
+ "description": "REQUIRED: Key for the selectable",
8085
8093
  "type": "string"
8086
8094
  },
8087
8095
  {
@@ -8114,16 +8122,10 @@
8114
8122
  "description": "Disables the input",
8115
8123
  "type": "boolean"
8116
8124
  },
8117
- {
8118
- "name": "hovering",
8119
- "attribute": "hovering",
8120
- "description": "Private. Force hovering state of input",
8121
- "type": "boolean"
8122
- },
8123
8125
  {
8124
8126
  "name": "key",
8125
8127
  "attribute": "key",
8126
- "description": "Key for the selectable",
8128
+ "description": "REQUIRED: Key for the selectable",
8127
8129
  "type": "string"
8128
8130
  },
8129
8131
  {
@@ -8182,13 +8184,8 @@
8182
8184
  },
8183
8185
  {
8184
8186
  "name": "selection-for",
8185
- "description": "Id of the SelectionMixin component this component wants to observe (if not located within that component)",
8187
+ "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
8186
8188
  "type": "string"
8187
- },
8188
- {
8189
- "name": "selectionInfo",
8190
- "description": "The selection info (set by the selection component)",
8191
- "type": "object"
8192
8189
  }
8193
8190
  ],
8194
8191
  "properties": [
@@ -8202,14 +8199,11 @@
8202
8199
  {
8203
8200
  "name": "selectionFor",
8204
8201
  "attribute": "selection-for",
8205
- "description": "Id of the SelectionMixin component this component wants to observe (if not located within that component)",
8202
+ "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
8206
8203
  "type": "string"
8207
8204
  },
8208
8205
  {
8209
- "name": "selectionInfo",
8210
- "attribute": "selectionInfo",
8211
- "description": "The selection info (set by the selection component)",
8212
- "type": "object"
8206
+ "name": "selectionInfo"
8213
8207
  }
8214
8208
  ],
8215
8209
  "events": [
@@ -8231,13 +8225,8 @@
8231
8225
  },
8232
8226
  {
8233
8227
  "name": "selection-for",
8234
- "description": "Id of the SelectionMixin component this component wants to observe (if not located within that component)",
8228
+ "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
8235
8229
  "type": "string"
8236
- },
8237
- {
8238
- "name": "selectionInfo",
8239
- "description": "The selection info (set by the selection component)",
8240
- "type": "object"
8241
8230
  }
8242
8231
  ],
8243
8232
  "properties": [
@@ -8250,14 +8239,11 @@
8250
8239
  {
8251
8240
  "name": "selectionFor",
8252
8241
  "attribute": "selection-for",
8253
- "description": "Id of the SelectionMixin component this component wants to observe (if not located within that component)",
8242
+ "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
8254
8243
  "type": "string"
8255
8244
  },
8256
8245
  {
8257
- "name": "selectionInfo",
8258
- "attribute": "selectionInfo",
8259
- "description": "The selection info (set by the selection component)",
8260
- "type": "object"
8246
+ "name": "selectionInfo"
8261
8247
  }
8262
8248
  ],
8263
8249
  "events": [
@@ -8273,7 +8259,7 @@
8273
8259
  "attributes": [
8274
8260
  {
8275
8261
  "name": "selection-single",
8276
- "description": "Whether the selection control is limited to single selection",
8262
+ "description": "Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item.",
8277
8263
  "type": "boolean",
8278
8264
  "default": "false"
8279
8265
  }
@@ -8282,7 +8268,7 @@
8282
8268
  {
8283
8269
  "name": "selectionSingle",
8284
8270
  "attribute": "selection-single",
8285
- "description": "Whether the selection control is limited to single selection",
8271
+ "description": "Whether to render with single selection behaviour. If `selection-single` is specified, the nested `d2l-selection-input` elements will render radios instead of checkboxes, and the selection component will maintain a single selected item.",
8286
8272
  "type": "boolean",
8287
8273
  "default": "false"
8288
8274
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.197.4",
3
+ "version": "1.200.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "repository": "https://github.com/BrightspaceUI/core.git",
6
6
  "publishConfig": {