@brightspace-ui/core 2.24.0 → 2.25.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.
|
@@ -176,7 +176,7 @@ function hideAccessible(target) {
|
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
let parent = getComposedParent(target);
|
|
179
|
-
while (parent !== document.documentElement) {
|
|
179
|
+
while (parent !== document.documentElement && parent !== null) {
|
|
180
180
|
if (parent.nodeType === Node.ELEMENT_NODE) {
|
|
181
181
|
path.push(parent);
|
|
182
182
|
hideAccessibleChildren(parent);
|
|
@@ -8,9 +8,15 @@ The selection components (`d2l-selection-action`, `d2l-selection-input`, `d2l-se
|
|
|
8
8
|

|
|
9
9
|
<!-- docs: end hidden content -->
|
|
10
10
|
|
|
11
|
+
## Use Case
|
|
12
|
+
|
|
13
|
+
The `d2l-list` already extends `SelectionMixin` and should always be used for lists, however a custom selection control can be defined to enable the use of these selection controls in different semantic contexts or radically different layouts. See [SelectionMixin](#selectionmixin).
|
|
14
|
+
|
|
11
15
|
## SelectionMixin
|
|
12
16
|
|
|
13
|
-
The selection components below work with a component that extends the `SelectionMixin
|
|
17
|
+
The `SelectionMixin` enables the creation of custom selection control components. The selection components below work with a component that extends the `SelectionMixin` which acts like a controller for the checkboxes, radios, actions and other selection components. The selection components below must be contained within a component that extends the `SelectionMixin`. 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.
|
|
18
|
+
|
|
19
|
+
The `SelectionMixin` defines the `selection-single` attribute that consumers can specify for single selection behaviour.
|
|
14
20
|
|
|
15
21
|
<!-- docs: demo live name:d2l-demo-selection display:block -->
|
|
16
22
|
```html
|
|
@@ -18,7 +24,7 @@ The selection components below work with a component that extends the `Selection
|
|
|
18
24
|
import { css, html, LitElement } from 'lit';
|
|
19
25
|
import { SelectionMixin } from '@brightspace-ui/core/components/selection/selection-mixin.js';
|
|
20
26
|
|
|
21
|
-
class
|
|
27
|
+
class DemoSelection extends SelectionMixin(LitElement) {
|
|
22
28
|
static get styles() {
|
|
23
29
|
return css`
|
|
24
30
|
:host {
|
|
@@ -32,7 +38,7 @@ The selection components below work with a component that extends the `Selection
|
|
|
32
38
|
`;
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
|
-
customElements.define('d2l-demo-selection',
|
|
41
|
+
customElements.define('d2l-demo-selection', DemoSelection);
|
|
36
42
|
</script>
|
|
37
43
|
<script type="module">
|
|
38
44
|
import '@brightspace-ui/core/components/selection/selection-action.js';
|
|
@@ -90,8 +96,6 @@ The selection components below work with a component that extends the `Selection
|
|
|
90
96
|
</d2l-demo-selection>
|
|
91
97
|
```
|
|
92
98
|
|
|
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
99
|
<!-- docs: start hidden content -->
|
|
96
100
|
### Properties
|
|
97
101
|
|
|
@@ -103,7 +107,7 @@ The `d2l-list` already extends `SelectionMixin` and should always be used for li
|
|
|
103
107
|
|
|
104
108
|
### Usage
|
|
105
109
|
|
|
106
|
-
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:
|
|
110
|
+
Define a custom web component that extends the `SelectionMixin`. 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:
|
|
107
111
|
|
|
108
112
|
```html
|
|
109
113
|
<div>
|
|
@@ -111,17 +115,17 @@ The selection components can then be used within the custom selection component
|
|
|
111
115
|
<d2l-selection-action selection-for="custom" text="Settings" icon="tier1:gear"></d2l-selection-action>
|
|
112
116
|
<d2l-selection-summary selection-for="custom"></d2l-selection-summary>
|
|
113
117
|
</div>
|
|
114
|
-
<d2l-
|
|
118
|
+
<d2l-demo-selection id="custom">
|
|
115
119
|
<ul>
|
|
116
120
|
<li><d2l-selection-input key="geo" label="Geography" selected></d2l-selection-input>Geography</li>
|
|
117
121
|
<li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
|
|
118
122
|
</ul>
|
|
119
|
-
</d2l-
|
|
123
|
+
</d2l-demo-selection>
|
|
120
124
|
```
|
|
121
125
|
|
|
122
126
|
## Selection Action [d2l-selection-action]
|
|
123
127
|
|
|
124
|
-
The `d2l-selection-action` is an optional component that provides a button for actions associated with the selection
|
|
128
|
+
The `d2l-selection-action` is an optional component that provides a button for actions associated with the [selection control](#selectionmixin) (ex. bulk actions). The `requires-selection` attribute may be specified to indicate that the button should be non-interactive if nothing is selected.
|
|
125
129
|
|
|
126
130
|
<!-- docs: demo live name:d2l-selection-action -->
|
|
127
131
|
```html
|
|
@@ -150,21 +154,19 @@ The `d2l-selection-action` is an optional component that provides a button for a
|
|
|
150
154
|
|
|
151
155
|
## Selection Action Dropdown [d2l-selection-action-dropdown]
|
|
152
156
|
|
|
153
|
-
The `d2l-selection-action-dropdown` is an optional component that provides a button opener for dropdown content associated with the selection
|
|
157
|
+
The `d2l-selection-action-dropdown` is an optional component that provides a button opener for dropdown content associated with the [selection control](#selectionmixin) (ex. bulk actions). The `requires-selection` attribute may be specified to indicate that the opener should be non-interactive if nothing is selected.
|
|
154
158
|
|
|
155
|
-
<!-- docs: demo live name:d2l-selection-action-dropdown
|
|
159
|
+
<!-- docs: demo live name:d2l-selection-action-dropdown align:baseline -->
|
|
156
160
|
```html
|
|
157
161
|
<script type="module">
|
|
158
162
|
import '@brightspace-ui/core/components/dropdown/dropdown-menu.js';
|
|
159
163
|
import '@brightspace-ui/core/components/menu/menu.js';
|
|
160
|
-
import '@brightspace-ui/core/components/menu/menu-item.js';
|
|
161
164
|
import '@brightspace-ui/core/components/selection/selection-action-dropdown.js';
|
|
162
165
|
</script>
|
|
163
166
|
<d2l-selection-action-dropdown text="Actions" requires-selection>
|
|
164
167
|
<d2l-dropdown-menu>
|
|
165
168
|
<d2l-menu label="Actions">
|
|
166
|
-
<d2l-
|
|
167
|
-
<d2l-menu-item text="Action 2"></d2l-menu-item>
|
|
169
|
+
<!-- This is where you add instances of <d2l-selection-action-menu-item>. -->
|
|
168
170
|
</d2l-menu>
|
|
169
171
|
</d2l-dropdown-menu>
|
|
170
172
|
</d2l-selection-action-dropdown>
|
|
@@ -182,7 +184,7 @@ The `d2l-selection-action-dropdown` is an optional component that provides a but
|
|
|
182
184
|
|
|
183
185
|
## Selection Action Menu Item [d2l-selection-action-menu-item]
|
|
184
186
|
|
|
185
|
-
The `d2l-selection-action-menu-item` is an optional component that is a menu item for actions associated with the selection
|
|
187
|
+
The `d2l-selection-action-menu-item` is an optional component that is a menu item for actions associated with the [selection control](#selectionmixin) (ex. bulk actions). The `requires-selection` attribute may be specified to indicate that the menu item should be non-interactive if nothing is selected. This component enables the app to define an opener that is enabled regardless of the selection state, while having a menu containing one or more menu items that `requires-selection`.
|
|
186
188
|
|
|
187
189
|
<!-- docs: demo live name:d2l-selection-action-menu-item autoSize:false size:medium align:baseline -->
|
|
188
190
|
```html
|
|
@@ -220,7 +222,11 @@ The `d2l-selection-action-menu-item` is an optional component that is a menu ite
|
|
|
220
222
|
|
|
221
223
|
## Selection Input [d2l-selection-input]
|
|
222
224
|
|
|
223
|
-
The `d2l-selection-input` is a required component in selection controls - without it, there wouldn't be anything for the user to select!
|
|
225
|
+
The `d2l-selection-input` is a required component in selection controls - without it, there wouldn't be anything for the user to select! This component must be placed _within_ the [selection control](#selectionmixin).
|
|
226
|
+
|
|
227
|
+
If `d2l-selection-input` is placed within a selection control that specifies `selection-single`, then radios will be rendered instead of checkboxes.
|
|
228
|
+
|
|
229
|
+
Note: `d2l-list-item` already provides a selection input for selectable list items.
|
|
224
230
|
|
|
225
231
|
<!-- docs: demo live name:d2l-selection-input display:block -->
|
|
226
232
|
```html
|
|
@@ -247,6 +253,7 @@ The `d2l-selection-input` is a required component in selection controls - withou
|
|
|
247
253
|
<ul>
|
|
248
254
|
<li><d2l-selection-input key="geo" label="Geography" selected></d2l-selection-input>Geography</li>
|
|
249
255
|
<li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
|
|
256
|
+
<li><d2l-selection-input key="mat" label="Math"></d2l-selection-input>Math</li>
|
|
250
257
|
</ul>
|
|
251
258
|
</d2l-demo-selection>
|
|
252
259
|
```
|
|
@@ -274,9 +281,9 @@ Either `label` or `labelled-by` is **required**.
|
|
|
274
281
|
|
|
275
282
|
## Select All [d2l-selection-select-all]
|
|
276
283
|
|
|
277
|
-
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.
|
|
284
|
+
The `d2l-selection-select-all` is an optional component that provides a checkbox for bulk selecting the selectable elements within the [selection control](#selectionmixin). Its state will also be automatically updated when the state of the selectable elements change.
|
|
278
285
|
|
|
279
|
-
In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-select-all`
|
|
286
|
+
The `d2l-selection-select-all` component may be placed inside the selection control, or in the same DOM scope with the `selection-for` attribute set to the id of that component. In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-select-all` from outside of the selection control component.
|
|
280
287
|
|
|
281
288
|
<!-- docs: demo live name:d2l-selection-select-all display:block -->
|
|
282
289
|
```html
|
|
@@ -288,6 +295,13 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
288
295
|
</script>
|
|
289
296
|
<!-- docs: start hidden content -->
|
|
290
297
|
<style>
|
|
298
|
+
.container {
|
|
299
|
+
justify-content: center;
|
|
300
|
+
}
|
|
301
|
+
#other-list {
|
|
302
|
+
padding-top: 2.1rem;
|
|
303
|
+
margin-left: 5rem;
|
|
304
|
+
}
|
|
291
305
|
ul {
|
|
292
306
|
margin: 0;
|
|
293
307
|
padding: 0;
|
|
@@ -304,27 +318,41 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
304
318
|
d2l-selection-input {
|
|
305
319
|
margin-right: 10px;
|
|
306
320
|
}
|
|
307
|
-
|
|
308
|
-
|
|
321
|
+
@media only screen and (max-width: 350px) {
|
|
322
|
+
body {
|
|
323
|
+
overflow-y: scroll;
|
|
324
|
+
}
|
|
325
|
+
.container {
|
|
326
|
+
align-items: flex-start;
|
|
327
|
+
flex-direction: column;
|
|
328
|
+
margin-right: 15px;
|
|
329
|
+
}
|
|
330
|
+
#other-list {
|
|
331
|
+
margin-left: 0;
|
|
332
|
+
}
|
|
309
333
|
}
|
|
310
334
|
</style>
|
|
311
335
|
<!-- docs: end hidden content -->
|
|
312
|
-
<
|
|
313
|
-
<
|
|
314
|
-
<
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
<
|
|
326
|
-
|
|
327
|
-
|
|
336
|
+
<div class="container">
|
|
337
|
+
<d2l-demo-selection>
|
|
338
|
+
<div>
|
|
339
|
+
<d2l-selection-select-all></d2l-selection-select-all>
|
|
340
|
+
<d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
|
|
341
|
+
</div>
|
|
342
|
+
<ul>
|
|
343
|
+
<li><d2l-selection-input key="geo" label="Geography"></d2l-selection-input>Geography</li>
|
|
344
|
+
<li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
|
|
345
|
+
<li><d2l-selection-input key="mat" label="Math" disabled></d2l-selection-input>Math</li>
|
|
346
|
+
</ul>
|
|
347
|
+
</d2l-demo-selection>
|
|
348
|
+
<d2l-demo-selection id="other-list">
|
|
349
|
+
<ul>
|
|
350
|
+
<li><d2l-selection-input key="ear" label="Earth"></d2l-selection-input>Earth</li>
|
|
351
|
+
<li><d2l-selection-input key="mar" label="Mars"></d2l-selection-input>Mars</li>
|
|
352
|
+
<li><d2l-selection-input key="jup" label="Jupiter"></d2l-selection-input>Jupiter</li>
|
|
353
|
+
</ul>
|
|
354
|
+
</d2l-demo-selection>
|
|
355
|
+
</div>
|
|
328
356
|
```
|
|
329
357
|
|
|
330
358
|
<!-- docs: start hidden content -->
|
|
@@ -338,9 +366,9 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
338
366
|
|
|
339
367
|
## Selection Summary [d2l-selection-summary]
|
|
340
368
|
|
|
341
|
-
The `d2l-selection-summary` is an optional component that shows a simple count of the selected items within the selection control.
|
|
369
|
+
The `d2l-selection-summary` is an optional component that shows a simple count of the selected items within the [selection control](#selectionmixin).
|
|
342
370
|
|
|
343
|
-
In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-summary`
|
|
371
|
+
The `d2l-selection-summary` component may be placed inside the selection control, or in the same DOM scope with the `selection-for` attribute set to the id of that component. In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-summary` from outside of the selection control component.
|
|
344
372
|
|
|
345
373
|
<!-- docs: demo live name:d2l-selection-summary display:block -->
|
|
346
374
|
```html
|
|
@@ -351,6 +379,14 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
351
379
|
</script>
|
|
352
380
|
<!-- docs: start hidden content -->
|
|
353
381
|
<style>
|
|
382
|
+
.container {
|
|
383
|
+
display: flex;
|
|
384
|
+
justify-content: center;
|
|
385
|
+
}
|
|
386
|
+
#other-list {
|
|
387
|
+
padding-top: 1rem;
|
|
388
|
+
margin-left: 5rem;
|
|
389
|
+
}
|
|
354
390
|
ul {
|
|
355
391
|
margin: 0;
|
|
356
392
|
padding: 0;
|
|
@@ -367,27 +403,40 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
367
403
|
d2l-selection-input {
|
|
368
404
|
margin-right: 10px;
|
|
369
405
|
}
|
|
370
|
-
|
|
371
|
-
|
|
406
|
+
@media only screen and (max-width: 350px) {
|
|
407
|
+
body {
|
|
408
|
+
overflow-y: scroll;
|
|
409
|
+
}
|
|
410
|
+
.container {
|
|
411
|
+
align-items: flex-start;
|
|
412
|
+
flex-direction: column;
|
|
413
|
+
}
|
|
414
|
+
#other-list {
|
|
415
|
+
margin-left: 0;
|
|
416
|
+
}
|
|
372
417
|
}
|
|
373
418
|
</style>
|
|
374
419
|
<!-- docs: end hidden content -->
|
|
375
|
-
<
|
|
376
|
-
<
|
|
377
|
-
<
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
<
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
<
|
|
389
|
-
|
|
390
|
-
|
|
420
|
+
<div class="container">
|
|
421
|
+
<d2l-demo-selection>
|
|
422
|
+
<div>
|
|
423
|
+
<d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
|
|
424
|
+
<d2l-selection-summary></d2l-selection-summary>
|
|
425
|
+
</div>
|
|
426
|
+
<ul>
|
|
427
|
+
<li><d2l-selection-input key="geo" label="Geography"></d2l-selection-input>Geography</li>
|
|
428
|
+
<li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
|
|
429
|
+
<li><d2l-selection-input key="mat" label="Math" disabled></d2l-selection-input>Math</li>
|
|
430
|
+
</ul>
|
|
431
|
+
</d2l-demo-selection>
|
|
432
|
+
<d2l-demo-selection id="other-list">
|
|
433
|
+
<ul>
|
|
434
|
+
<li><d2l-selection-input key="ear" label="Earth"></d2l-selection-input>Earth</li>
|
|
435
|
+
<li><d2l-selection-input key="mar" label="Mars"></d2l-selection-input>Mars</li>
|
|
436
|
+
<li><d2l-selection-input key="jup" label="Jupiter"></d2l-selection-input>Jupiter</li>
|
|
437
|
+
</ul>
|
|
438
|
+
</d2l-demo-selection>
|
|
439
|
+
</div>
|
|
391
440
|
```
|
|
392
441
|
|
|
393
442
|
<!-- docs: start hidden content -->
|
|
@@ -111,7 +111,7 @@ export const SelectionMixin = superclass => class extends RtlMixin(superclass) {
|
|
|
111
111
|
this._selectAllPages = (selected && selectAllPages);
|
|
112
112
|
|
|
113
113
|
this._selectionSelectables.forEach(selectable => {
|
|
114
|
-
if (!!selectable.selected !== selected) {
|
|
114
|
+
if (!selectable.disabled && !!selectable.selected !== selected) {
|
|
115
115
|
selectable.selected = selected;
|
|
116
116
|
}
|
|
117
117
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.0",
|
|
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",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"license": "Apache-2.0",
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@babel/eslint-parser": "^7",
|
|
47
|
-
"@brightspace-ui/stylelint-config": "^0.
|
|
47
|
+
"@brightspace-ui/stylelint-config": "^0.5",
|
|
48
48
|
"@open-wc/testing": "^3",
|
|
49
49
|
"@web/dev-server": "^0.1",
|
|
50
50
|
"@web/test-runner": "^0.13",
|