@brightspace-ui/core 2.150.2 → 2.150.3
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.
- package/components/list/README.md +19 -20
- package/components/list/demo/list.html +46 -0
- package/components/list/list-item-mixin.js +12 -102
- package/components/list/list.js +82 -1
- package/custom-elements.json +13 -39
- package/package.json +1 -1
@@ -100,7 +100,7 @@ When using `d2l-list`, the `grid` attribute will enable the table-like keyboard
|
|
100
100
|
|
101
101
|
## List [d2l-list]
|
102
102
|
|
103
|
-
The `d2l-list` is the container to create a styled list of items using `d2l-list-item` or `d2l-list-item-button`. It provides the appropriate `list` semantics as well as options for displaying separators, etc.
|
103
|
+
The `d2l-list` is the container to create a styled list of items using `d2l-list-item` or `d2l-list-item-button`. It provides the appropriate `list` semantics as well as options for displaying separators, breakpoints for responsiveness, etc.
|
104
104
|
|
105
105
|
<!-- docs: demo code properties name:d2l-list display:block autoSize:false size:medium -->
|
106
106
|
```html
|
@@ -133,6 +133,7 @@ The `d2l-list` is the container to create a styled list of items using `d2l-list
|
|
133
133
|
|
134
134
|
| Property | Type | Description |
|
135
135
|
|---|---|---|
|
136
|
+
| `breakpoints` | Array | Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used. |
|
136
137
|
| `drag-multiple` | Boolean | Whether the user can drag multiple items |
|
137
138
|
| `grid` | Boolean | Enables keyboard grid for supported list items. See [Accessibility](#accessibility). |
|
138
139
|
| `label` | String | Sets an accessible label. For use when the list context is unclear. This property is only valid on top-level lists and will have no effect on nested lists. |
|
@@ -146,6 +147,22 @@ The `d2l-list` is the container to create a styled list of items using `d2l-list
|
|
146
147
|
- `d2l-list-selection-changes`: dispatched once for a set of selection state changes (ex. select-all); event detail includes an array of objects where each object contains the `key` and `selected` state for each changed item
|
147
148
|
<!-- docs: end hidden content -->
|
148
149
|
|
150
|
+
### Breakpoints Property
|
151
|
+
|
152
|
+
- `breakpoints` (Array): Breakpoints for responsiveness (`[842, 636, 580, 0]`), in pixels. There are four different breakpoints and only the four largest breakpoints will be used. If less breakpoints are used, then skip a middle breakpoint so that the first and last breakpoints will map to the largest and smallest layouts.
|
153
|
+
- Breakpoint 0
|
154
|
+
- Image: max dimensions: `width: 90px` and `height: 52px` and has `18px margin` from the main content;
|
155
|
+
- default break: `x < 580px` where `x` is the width of the component.
|
156
|
+
- Breakpoint 1
|
157
|
+
- Image: max dimensions: `width: 120px` and `height: 71px` and has `20px margin` from the main content;
|
158
|
+
- default break: `581px < x < 636px` where `x` is the width of the component.
|
159
|
+
- Breakpoint 2
|
160
|
+
- Image: max dimensions: `width: 180px` and `height: 102px` and has `20px margin` from the main content;
|
161
|
+
- default break: `637px < x < 842px` where `x` is the width of the component.
|
162
|
+
- Breakpoint 3
|
163
|
+
- Image: max dimensions: `width: 216px` and `height: 120px` and has `20px margin` from the main content;
|
164
|
+
- default break: `843px < x` where `x` is the width of the component.
|
165
|
+
|
149
166
|
### Methods
|
150
167
|
|
151
168
|
- `getItems()` (Array): returns the list items within the list
|
@@ -380,7 +397,7 @@ The `d2l-list-controls` component can be placed in the `d2l-list`'s `controls` s
|
|
380
397
|
|
381
398
|
## List Item [d2l-list-item]
|
382
399
|
|
383
|
-
The `d2l-list-item` provides the appropriate `listitem` semantics for children within a list. It also provides some basic layout,
|
400
|
+
The `d2l-list-item` provides the appropriate `listitem` semantics for children within a list. It also provides some basic layout, a navigation link for the primary action, and selection.
|
384
401
|
|
385
402
|
<!-- docs: demo code properties name:d2l-list-item autoSize:false size:small -->
|
386
403
|
```html
|
@@ -410,7 +427,6 @@ The `d2l-list-item` provides the appropriate `listitem` semantics for children w
|
|
410
427
|
|
411
428
|
| Property | Type | Description |
|
412
429
|
|---|---|---|
|
413
|
-
| `breakpoints` | Array | Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used. |
|
414
430
|
| `draggable` | Boolean | Whether the item is draggable |
|
415
431
|
| `drag-handle-text` | String | The drag-handle label for assistive technology. If implementing drag & drop, you should change this to dynamically announce what the drag-handle is moving for assistive technology in keyboard mode. |
|
416
432
|
| `drag-target-handle-only` | Boolean | Make the drag target the drag handle only. |
|
@@ -441,22 +457,6 @@ The `d2l-list-item` provides the appropriate `listitem` semantics for children w
|
|
441
457
|
- `d2l-list-item-expand-collapse-toggled`: dispatched when the item's expand/collapse toggle is clicked
|
442
458
|
<!-- docs: end hidden content -->
|
443
459
|
|
444
|
-
### Breakpoints Property
|
445
|
-
|
446
|
-
- `breakpoints` (Array): Breakpoints for responsiveness (`[842, 636, 580, 0]`), in pixels. There are four different breakpoints and only the four largest breakpoints will be used. If less breakpoints are used, then skip a middle breakpoint so that the first and last breakpoints will map to the largest and smallest layouts.
|
447
|
-
- Breakpoint 0
|
448
|
-
- Image: max dimensions: `width: 90px` and `height: 52px` and has `18px margin` from the main content;
|
449
|
-
- default break: `x < 580px` where `x` is the width of the component.
|
450
|
-
- Breakpoint 1
|
451
|
-
- Image: max dimensions: `width: 120px` and `height: 71px` and has `20px margin` from the main content;
|
452
|
-
- default break: `581px < x < 636px` where `x` is the width of the component.
|
453
|
-
- Breakpoint 2
|
454
|
-
- Image: max dimensions: `width: 180px` and `height: 102px` and has `20px margin` from the main content;
|
455
|
-
- default break: `637px < x < 842px` where `x` is the width of the component.
|
456
|
-
- Breakpoint 3
|
457
|
-
- Image: max dimensions: `width: 216px` and `height: 120px` and has `20px margin` from the main content;
|
458
|
-
- default break: `843px < x` where `x` is the width of the component.
|
459
|
-
|
460
460
|
## Button List Item [d2l-list-item-button]
|
461
461
|
|
462
462
|
The `d2l-list-item-button` provides the same functionality as `d2l-list-item` except with button semantics for its primary action.
|
@@ -484,7 +484,6 @@ The `d2l-list-item-button` provides the same functionality as `d2l-list-item` ex
|
|
484
484
|
|
485
485
|
| Property | Type | Description |
|
486
486
|
|---|---|---|
|
487
|
-
| `breakpoints` | Array | Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used. |
|
488
487
|
| `button-disabled` | Boolean | Disables the primary action button |
|
489
488
|
| `draggable` | Boolean | Whether the item is draggable |
|
490
489
|
| `drag-handle-text` | String | The drag-handle label for assistive technology. If implementing drag & drop, you should change this to dynamically announce what the drag-handle is moving for assistive technology in keyboard mode. |
|
@@ -162,6 +162,52 @@
|
|
162
162
|
</template>
|
163
163
|
</d2l-demo-snippet>
|
164
164
|
|
165
|
+
<h2>Breakpoints on List</h2>
|
166
|
+
|
167
|
+
<d2l-demo-snippet>
|
168
|
+
<template>
|
169
|
+
<d2l-list breakpoints="[1170, 391, 0, 0]">
|
170
|
+
<d2l-list-item color="#00ff00">
|
171
|
+
<div style="background: blue; height: 400px; width: 400px;" slot="illustration"></div>
|
172
|
+
<d2l-list-item-content>
|
173
|
+
<div>Introductory Pirate Ipsum</div>
|
174
|
+
<div slot="supporting-info">Case shot Shiver me timbers gangplank crack Jennys tea cup ballast Blimey lee snow crow's nest rutters.</div>
|
175
|
+
</d2l-list-item-content>
|
176
|
+
</d2l-list-item>
|
177
|
+
<d2l-list-item>
|
178
|
+
<div style="background: blue; height: 400px; width: 400px;" slot="illustration"></div>
|
179
|
+
<d2l-list-item-content>
|
180
|
+
<div>Introductory Pirate Ipsum</div>
|
181
|
+
<div slot="supporting-info">Case shot Shiver me timbers gangplank crack Jennys tea cup ballast Blimey lee snow crow's nest rutters.</div>
|
182
|
+
</d2l-list-item-content>
|
183
|
+
</d2l-list-item>
|
184
|
+
</d2l-list>
|
185
|
+
</template>
|
186
|
+
</d2l-demo-snippet>
|
187
|
+
|
188
|
+
<h2>Breakpoints on List Item</h2>
|
189
|
+
|
190
|
+
<d2l-demo-snippet>
|
191
|
+
<template>
|
192
|
+
<d2l-list>
|
193
|
+
<d2l-list-item color="#00ff00" breakpoints="[1170, 391, 0, 0]">
|
194
|
+
<div style="background: blue; height: 400px; width: 400px;" slot="illustration"></div>
|
195
|
+
<d2l-list-item-content>
|
196
|
+
<div>Introductory Pirate Ipsum</div>
|
197
|
+
<div slot="supporting-info">Case shot Shiver me timbers gangplank crack Jennys tea cup ballast Blimey lee snow crow's nest rutters.</div>
|
198
|
+
</d2l-list-item-content>
|
199
|
+
</d2l-list-item>
|
200
|
+
<d2l-list-item>
|
201
|
+
<div style="background: blue; height: 400px; width: 400px;" slot="illustration"></div>
|
202
|
+
<d2l-list-item-content>
|
203
|
+
<div>Introductory Pirate Ipsum</div>
|
204
|
+
<div slot="supporting-info">Case shot Shiver me timbers gangplank crack Jennys tea cup ballast Blimey lee snow crow's nest rutters.</div>
|
205
|
+
</d2l-list-item-content>
|
206
|
+
</d2l-list-item>
|
207
|
+
</d2l-list>
|
208
|
+
</template>
|
209
|
+
</d2l-demo-snippet>
|
210
|
+
|
165
211
|
</d2l-demo-page>
|
166
212
|
|
167
213
|
</body>
|
@@ -17,7 +17,6 @@ import { ListItemDragDropMixin } from './list-item-drag-drop-mixin.js';
|
|
17
17
|
import { ListItemExpandCollapseMixin } from './list-item-expand-collapse-mixin.js';
|
18
18
|
import { ListItemRoleMixin } from './list-item-role-mixin.js';
|
19
19
|
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
|
20
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
21
20
|
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
|
22
21
|
import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
|
23
22
|
import { styleMap } from 'lit-html/directives/style-map.js';
|
@@ -39,18 +38,6 @@ function addTabListener() {
|
|
39
38
|
|
40
39
|
let hasDisplayedKeyboardTooltip = false;
|
41
40
|
|
42
|
-
const ro = new ResizeObserver(entries => {
|
43
|
-
entries.forEach(entry => {
|
44
|
-
if (!entry || !entry.target || !entry.target.resizedCallback) {
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
entry.target.resizedCallback(entry.contentRect && entry.contentRect.width);
|
48
|
-
});
|
49
|
-
});
|
50
|
-
|
51
|
-
const defaultBreakpoints = [842, 636, 580, 0];
|
52
|
-
const SLIM_COLOR_BREAKPOINT = 400;
|
53
|
-
|
54
41
|
/**
|
55
42
|
* @property label - The hidden label for the checkbox and expand collapse control
|
56
43
|
*/
|
@@ -68,8 +55,7 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
68
55
|
static get properties() {
|
69
56
|
return {
|
70
57
|
/**
|
71
|
-
*
|
72
|
-
* @type {array}
|
58
|
+
* @ignore
|
73
59
|
*/
|
74
60
|
breakpoints: { type: Array },
|
75
61
|
/**
|
@@ -92,7 +78,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
92
78
|
* @type {'normal'|'none'}
|
93
79
|
*/
|
94
80
|
paddingType: { type: String, attribute: 'padding-type' },
|
95
|
-
_breakpoint: { type: Number },
|
96
81
|
_displayKeyboardTooltip: { type: Boolean },
|
97
82
|
_hasColorSlot: { type: Boolean, reflect: true, attribute: '_has-color-slot' },
|
98
83
|
_hovering: { type: Boolean, reflect: true },
|
@@ -103,7 +88,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
103
88
|
_highlighting: { type: Boolean, reflect: true },
|
104
89
|
_hasNestedList: { state: true },
|
105
90
|
_siblingHasColor: { state: true },
|
106
|
-
_slimColor: { state: true }
|
107
91
|
};
|
108
92
|
}
|
109
93
|
|
@@ -219,16 +203,11 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
219
203
|
border-radius: 6px;
|
220
204
|
flex-grow: 0;
|
221
205
|
flex-shrink: 0;
|
222
|
-
margin-
|
223
|
-
max-height: 2.6rem;
|
224
|
-
max-width: 4.5rem;
|
206
|
+
margin-inline-end: var(--d2l-list-item-illustration-margin-inline-end, 0.9rem);
|
207
|
+
max-height: var(--d2l-list-item-illustration-max-height, 2.6rem);
|
208
|
+
max-width: var(--d2l-list-item-illustration-max-width, 4.5rem);
|
225
209
|
overflow: hidden;
|
226
210
|
}
|
227
|
-
:host([dir="rtl"]) [slot="content"] ::slotted([slot="illustration"]),
|
228
|
-
:host([dir="rtl"]) [slot="content"] .d2l-list-item-illustration > * {
|
229
|
-
margin-left: 0.9rem;
|
230
|
-
margin-right: 0;
|
231
|
-
}
|
232
211
|
[slot="content"] ::slotted(d2l-icon[slot="illustration"]),
|
233
212
|
[slot="content"] .d2l-list-item-illustration d2l-icon {
|
234
213
|
border-radius: 0;
|
@@ -257,40 +236,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
257
236
|
margin-right: 0;
|
258
237
|
}
|
259
238
|
|
260
|
-
[data-breakpoint="1"] ::slotted([slot="illustration"]),
|
261
|
-
[data-breakpoint="1"] .d2l-list-item-illustration > * {
|
262
|
-
margin-right: 1rem;
|
263
|
-
max-height: 3.55rem;
|
264
|
-
max-width: 6rem;
|
265
|
-
}
|
266
|
-
:host([dir="rtl"]) [data-breakpoint="1"] ::slotted([slot="illustration"]),
|
267
|
-
:host([dir="rtl"]) [data-breakpoint="1"] .d2l-list-item-illustration > * {
|
268
|
-
margin-left: 1rem;
|
269
|
-
margin-right: 0;
|
270
|
-
}
|
271
|
-
[data-breakpoint="2"] ::slotted([slot="illustration"]),
|
272
|
-
[data-breakpoint="2"] .d2l-list-item-illustration > * {
|
273
|
-
margin-right: 1rem;
|
274
|
-
max-height: 5.1rem;
|
275
|
-
max-width: 9rem;
|
276
|
-
}
|
277
|
-
:host([dir="rtl"]) [data-breakpoint="2"] ::slotted([slot="illustration"]),
|
278
|
-
:host([dir="rtl"]) [data-breakpoint="2"] .d2l-list-item-illustration > * {
|
279
|
-
margin-left: 1rem;
|
280
|
-
margin-right: 0;
|
281
|
-
}
|
282
|
-
[data-breakpoint="3"] ::slotted([slot="illustration"]),
|
283
|
-
[data-breakpoint="3"] .d2l-list-item-illustration > * {
|
284
|
-
margin-right: 1rem;
|
285
|
-
max-height: 6rem;
|
286
|
-
max-width: 10.8rem;
|
287
|
-
}
|
288
|
-
:host([dir="rtl"]) [data-breakpoint="3"] ::slotted([slot="illustration"]),
|
289
|
-
:host([dir="rtl"]) [data-breakpoint="3"] .d2l-list-item-illustration > * {
|
290
|
-
margin-left: 1rem;
|
291
|
-
margin-right: 0;
|
292
|
-
}
|
293
|
-
|
294
239
|
d2l-selection-input {
|
295
240
|
margin: 0.55rem 0.55rem 0.55rem 0;
|
296
241
|
}
|
@@ -394,13 +339,9 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
394
339
|
}
|
395
340
|
|
396
341
|
.d2l-list-item-color-inner {
|
397
|
-
border-radius: 6px;
|
342
|
+
border-radius: var(--d2l-list-item-color-border-radius, 6px);
|
398
343
|
height: 100%;
|
399
|
-
width: 6px;
|
400
|
-
}
|
401
|
-
.d2l-list-item-color-inner.d2l-list-item-color-slim {
|
402
|
-
border-radius: 3px;
|
403
|
-
width: 3px;
|
344
|
+
width: var(--d2l-list-item-color-width, 6px);
|
404
345
|
}
|
405
346
|
.d2l-list-item-color-outer {
|
406
347
|
padding: 2px 12px 1px 0;
|
@@ -437,27 +378,13 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
437
378
|
|
438
379
|
constructor() {
|
439
380
|
super();
|
440
|
-
this.breakpoints = defaultBreakpoints;
|
441
381
|
this.noPrimaryAction = false;
|
442
382
|
this.paddingType = 'normal';
|
443
|
-
this._breakpoint = 0;
|
444
383
|
this._contentId = getUniqueId();
|
445
384
|
this._displayKeyboardTooltip = false;
|
446
385
|
this._hasColorSlot = false;
|
447
386
|
this._hasNestedList = false;
|
448
387
|
this._siblingHasColor = false;
|
449
|
-
this._slimColor = false;
|
450
|
-
}
|
451
|
-
|
452
|
-
get breakpoints() {
|
453
|
-
return this._breakpoints;
|
454
|
-
}
|
455
|
-
|
456
|
-
set breakpoints(value) {
|
457
|
-
const oldValue = this._breakpoints;
|
458
|
-
if (value !== defaultBreakpoints) this._breakpoints = value.sort((a, b) => b - a).slice(0, 4);
|
459
|
-
else this._breakpoints = defaultBreakpoints;
|
460
|
-
this.requestUpdate('breakpoints', oldValue);
|
461
388
|
}
|
462
389
|
|
463
390
|
get color() {
|
@@ -474,7 +401,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
474
401
|
|
475
402
|
connectedCallback() {
|
476
403
|
super.connectedCallback();
|
477
|
-
ro.observe(this);
|
478
404
|
if (this.role === 'rowgroup') {
|
479
405
|
addTabListener();
|
480
406
|
}
|
@@ -483,15 +409,13 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
483
409
|
}
|
484
410
|
}
|
485
411
|
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
}
|
412
|
+
/** TODO: remove this once usage of breakpoints on d2l-list-item has been moved to the list */
|
413
|
+
firstUpdated(changedProperties) {
|
414
|
+
super.firstUpdated(changedProperties);
|
490
415
|
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
this.resizedCallback(this.offsetWidth);
|
416
|
+
if (changedProperties.has('breakpoints') && this.breakpoints) {
|
417
|
+
const parentList = this.getRootList();
|
418
|
+
if (!parentList.getAttribute('breakpoints')) parentList.breakpoints = this.breakpoints;
|
495
419
|
}
|
496
420
|
}
|
497
421
|
|
@@ -524,18 +448,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
524
448
|
this._highlighting = true;
|
525
449
|
}
|
526
450
|
|
527
|
-
resizedCallback(width) {
|
528
|
-
this._slimColor = (width < SLIM_COLOR_BREAKPOINT);
|
529
|
-
|
530
|
-
const lastBreakpointIndexToCheck = 3;
|
531
|
-
this.breakpoints.some((breakpoint, index) => {
|
532
|
-
if (width >= breakpoint || index > lastBreakpointIndexToCheck) {
|
533
|
-
this._breakpoint = lastBreakpointIndexToCheck - index - (lastBreakpointIndexToCheck - this.breakpoints.length + 1) * index;
|
534
|
-
return true;
|
535
|
-
}
|
536
|
-
});
|
537
|
-
}
|
538
|
-
|
539
451
|
scrollToAndHighlight(alignToTop = true) {
|
540
452
|
this.scrollToItem(alignToTop);
|
541
453
|
setTimeout(() => {
|
@@ -691,7 +603,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
691
603
|
};
|
692
604
|
const colorClasses = {
|
693
605
|
'd2l-list-item-color-inner': true,
|
694
|
-
'd2l-list-item-color-slim': this._slimColor,
|
695
606
|
'd2l-skeletize': this.color
|
696
607
|
};
|
697
608
|
|
@@ -704,7 +615,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
|
|
704
615
|
@focusin="${this._onFocusIn}"
|
705
616
|
@focusout="${this._onFocusOut}"
|
706
617
|
class="${classMap(classes)}"
|
707
|
-
data-breakpoint="${this._breakpoint}"
|
708
618
|
data-separators="${ifDefined(this._separators)}"
|
709
619
|
?grid-active="${this.role === 'rowgroup'}"
|
710
620
|
?no-primary-action="${this.noPrimaryAction}">
|
package/components/list/list.js
CHANGED
@@ -3,6 +3,7 @@ import { getNextFocusable, getPreviousFocusable } from '../../helpers/focus.js';
|
|
3
3
|
import { SelectionInfo, SelectionMixin } from '../selection/selection-mixin.js';
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
5
5
|
import { PageableMixin } from '../paging/pageable-mixin.js';
|
6
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
6
7
|
import { SubscriberRegistryController } from '../../controllers/subscriber/subscriberControllers.js';
|
7
8
|
|
8
9
|
const keyCodes = {
|
@@ -10,6 +11,15 @@ const keyCodes = {
|
|
10
11
|
};
|
11
12
|
|
12
13
|
export const listSelectionStates = SelectionInfo.states;
|
14
|
+
const DEFAULT_BREAKPOINTS = [842, 636, 580, 0];
|
15
|
+
const SLIM_COLOR_BREAKPOINT = 400;
|
16
|
+
|
17
|
+
const ro = new ResizeObserver(entries => {
|
18
|
+
entries.forEach(entry => {
|
19
|
+
if (!entry?.target?.resizedCallback) return;
|
20
|
+
entry.target.resizedCallback(entry.contentRect?.width);
|
21
|
+
});
|
22
|
+
});
|
13
23
|
|
14
24
|
/**
|
15
25
|
* A container for a styled list of items ("d2l-list-item"). It provides the appropriate "list" semantics as well as options for displaying separators, etc.
|
@@ -22,6 +32,11 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
|
|
22
32
|
|
23
33
|
static get properties() {
|
24
34
|
return {
|
35
|
+
/**
|
36
|
+
* Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.
|
37
|
+
* @type {array}
|
38
|
+
*/
|
39
|
+
breakpoints: { type: Array },
|
25
40
|
/**
|
26
41
|
* Whether the user can drag multiple items
|
27
42
|
* @type {boolean}
|
@@ -47,13 +62,20 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
|
|
47
62
|
* @type {'all'|'between'|'none'}
|
48
63
|
* @default "all"
|
49
64
|
*/
|
50
|
-
separators: { type: String, reflect: true }
|
65
|
+
separators: { type: String, reflect: true },
|
66
|
+
_breakpoint: { type: Number, reflect: true },
|
67
|
+
_slimColor: { type: Boolean, reflect: true, attribute: '_slim-color' }
|
51
68
|
};
|
52
69
|
}
|
53
70
|
|
54
71
|
static get styles() {
|
55
72
|
return css`
|
56
73
|
:host {
|
74
|
+
--d2l-list-item-color-border-radius: 6px;
|
75
|
+
--d2l-list-item-color-width: 6px;
|
76
|
+
--d2l-list-item-illustration-margin-inline-end: 0.9rem;
|
77
|
+
--d2l-list-item-illustration-max-height: 2.6rem;
|
78
|
+
--d2l-list-item-illustration-max-width: 4.5rem;
|
57
79
|
display: block;
|
58
80
|
}
|
59
81
|
:host(:not([slot="nested"])) > .d2l-list-content {
|
@@ -69,11 +91,31 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
|
|
69
91
|
margin-left: 0.9rem;
|
70
92
|
margin-right: 0.9rem;
|
71
93
|
}
|
94
|
+
:host([_breakpoint="1"]) {
|
95
|
+
--d2l-list-item-illustration-margin-inline-end: 1rem;
|
96
|
+
--d2l-list-item-illustration-max-height: 3.55rem;
|
97
|
+
--d2l-list-item-illustration-max-width: 6rem;
|
98
|
+
}
|
99
|
+
:host([_breakpoint="2"]) {
|
100
|
+
--d2l-list-item-illustration-margin-inline-end: 1rem;
|
101
|
+
--d2l-list-item-illustration-max-height: 5.1rem;
|
102
|
+
--d2l-list-item-illustration-max-width: 9rem;
|
103
|
+
}
|
104
|
+
:host([_breakpoint="3"]) {
|
105
|
+
--d2l-list-item-illustration-margin-inline-end: 1rem;
|
106
|
+
--d2l-list-item-illustration-max-height: 6rem;
|
107
|
+
--d2l-list-item-illustration-max-width: 10.8rem;
|
108
|
+
}
|
109
|
+
:host([_slim-color]) {
|
110
|
+
--d2l-list-item-color-border-radius: 3px;
|
111
|
+
--d2l-list-item-color-width: 3px;
|
112
|
+
}
|
72
113
|
`;
|
73
114
|
}
|
74
115
|
|
75
116
|
constructor() {
|
76
117
|
super();
|
118
|
+
this.breakpoints = DEFAULT_BREAKPOINTS;
|
77
119
|
this.dragMultiple = false;
|
78
120
|
this.extendSeparators = false;
|
79
121
|
this.grid = false;
|
@@ -81,22 +123,39 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
|
|
81
123
|
this._childHasColor = false;
|
82
124
|
this._childHasExpandCollapseToggle = false;
|
83
125
|
|
126
|
+
this._breakpoint = 0;
|
127
|
+
this._slimColor = false;
|
128
|
+
this._width = 0;
|
129
|
+
|
84
130
|
this._listChildrenUpdatedSubscribers = new SubscriberRegistryController(this, 'list-child-status', {
|
85
131
|
onSubscribe: this._updateActiveSubscriber.bind(this),
|
86
132
|
updateSubscribers: this._updateActiveSubscribers.bind(this)
|
87
133
|
});
|
88
134
|
}
|
89
135
|
|
136
|
+
get breakpoints() {
|
137
|
+
return this._breakpoints;
|
138
|
+
}
|
139
|
+
|
140
|
+
set breakpoints(value) {
|
141
|
+
const oldValue = this._breakpoints;
|
142
|
+
if (value !== DEFAULT_BREAKPOINTS) this._breakpoints = value.sort((a, b) => b - a).slice(0, 4);
|
143
|
+
else this._breakpoints = DEFAULT_BREAKPOINTS;
|
144
|
+
this.requestUpdate('breakpoints', oldValue);
|
145
|
+
}
|
146
|
+
|
90
147
|
connectedCallback() {
|
91
148
|
super.connectedCallback();
|
92
149
|
this.addEventListener('d2l-list-item-showing-count-change', this._handleListItemShowingCountChange);
|
93
150
|
this.addEventListener('d2l-list-item-nested-change', (e) => this._handleListIemNestedChange(e));
|
94
151
|
this.addEventListener('d2l-list-item-property-change', (e) => this._handleListItemPropertyChange(e));
|
152
|
+
ro.observe(this);
|
95
153
|
}
|
96
154
|
|
97
155
|
disconnectedCallback() {
|
98
156
|
super.disconnectedCallback();
|
99
157
|
if (this._intersectionObserver) this._intersectionObserver.disconnect();
|
158
|
+
ro.unobserve(this);
|
100
159
|
}
|
101
160
|
|
102
161
|
firstUpdated(changedProperties) {
|
@@ -143,6 +202,13 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
|
|
143
202
|
`;
|
144
203
|
}
|
145
204
|
|
205
|
+
updated(changedProperties) {
|
206
|
+
super.updated(changedProperties);
|
207
|
+
if (changedProperties.has('breakpoints') && changedProperties.get('breakpoints') !== undefined) {
|
208
|
+
this.resizedCallback(this.offsetWidth, true);
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
146
212
|
getItems(slot) {
|
147
213
|
if (!this.shadowRoot) return;
|
148
214
|
if (!slot) slot = this.shadowRoot.querySelector('slot:not([name])');
|
@@ -198,6 +264,21 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
|
|
198
264
|
return new SelectionInfo(keys, selectionInfo.state);
|
199
265
|
}
|
200
266
|
|
267
|
+
resizedCallback(width, breakpointsChanged) {
|
268
|
+
if (this._width === width && !breakpointsChanged) return;
|
269
|
+
this._width = width;
|
270
|
+
|
271
|
+
this._slimColor = (width < SLIM_COLOR_BREAKPOINT);
|
272
|
+
|
273
|
+
const lastBreakpointIndexToCheck = 3;
|
274
|
+
this.breakpoints.some((breakpoint, index) => {
|
275
|
+
if (width >= breakpoint || index > lastBreakpointIndexToCheck) {
|
276
|
+
this._breakpoint = lastBreakpointIndexToCheck - index - (lastBreakpointIndexToCheck - this.breakpoints.length + 1) * index;
|
277
|
+
return true;
|
278
|
+
}
|
279
|
+
});
|
280
|
+
}
|
281
|
+
|
201
282
|
_getItemByIndex(index) {
|
202
283
|
const items = this.getItems() || [];
|
203
284
|
return items[index];
|
package/custom-elements.json
CHANGED
@@ -7904,12 +7904,6 @@
|
|
7904
7904
|
"description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
|
7905
7905
|
"type": "string"
|
7906
7906
|
},
|
7907
|
-
{
|
7908
|
-
"name": "breakpoints",
|
7909
|
-
"description": "Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.",
|
7910
|
-
"type": "array",
|
7911
|
-
"default": "[842,636,580,0]"
|
7912
|
-
},
|
7913
7907
|
{
|
7914
7908
|
"name": "no-primary-action",
|
7915
7909
|
"description": "Whether to disable rendering the entire item as the primary action. Required if slotted content is interactive.",
|
@@ -8006,13 +8000,6 @@
|
|
8006
8000
|
"description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
|
8007
8001
|
"type": "string"
|
8008
8002
|
},
|
8009
|
-
{
|
8010
|
-
"name": "breakpoints",
|
8011
|
-
"attribute": "breakpoints",
|
8012
|
-
"description": "Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.",
|
8013
|
-
"type": "array",
|
8014
|
-
"default": "[842,636,580,0]"
|
8015
|
-
},
|
8016
8003
|
{
|
8017
8004
|
"name": "noPrimaryAction",
|
8018
8005
|
"attribute": "no-primary-action",
|
@@ -8258,12 +8245,6 @@
|
|
8258
8245
|
"description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
|
8259
8246
|
"type": "string"
|
8260
8247
|
},
|
8261
|
-
{
|
8262
|
-
"name": "breakpoints",
|
8263
|
-
"description": "Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.",
|
8264
|
-
"type": "array",
|
8265
|
-
"default": "[842,636,580,0]"
|
8266
|
-
},
|
8267
8248
|
{
|
8268
8249
|
"name": "no-primary-action",
|
8269
8250
|
"description": "Whether to disable rendering the entire item as the primary action. Required if slotted content is interactive.",
|
@@ -8367,13 +8348,6 @@
|
|
8367
8348
|
"description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
|
8368
8349
|
"type": "string"
|
8369
8350
|
},
|
8370
|
-
{
|
8371
|
-
"name": "breakpoints",
|
8372
|
-
"attribute": "breakpoints",
|
8373
|
-
"description": "Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.",
|
8374
|
-
"type": "array",
|
8375
|
-
"default": "[842,636,580,0]"
|
8376
|
-
},
|
8377
8351
|
{
|
8378
8352
|
"name": "noPrimaryAction",
|
8379
8353
|
"attribute": "no-primary-action",
|
@@ -8741,12 +8715,6 @@
|
|
8741
8715
|
"description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
|
8742
8716
|
"type": "string"
|
8743
8717
|
},
|
8744
|
-
{
|
8745
|
-
"name": "breakpoints",
|
8746
|
-
"description": "Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.",
|
8747
|
-
"type": "array",
|
8748
|
-
"default": "[842,636,580,0]"
|
8749
|
-
},
|
8750
8718
|
{
|
8751
8719
|
"name": "no-primary-action",
|
8752
8720
|
"description": "Whether to disable rendering the entire item as the primary action. Required if slotted content is interactive.",
|
@@ -8855,13 +8823,6 @@
|
|
8855
8823
|
"description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
|
8856
8824
|
"type": "string"
|
8857
8825
|
},
|
8858
|
-
{
|
8859
|
-
"name": "breakpoints",
|
8860
|
-
"attribute": "breakpoints",
|
8861
|
-
"description": "Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.",
|
8862
|
-
"type": "array",
|
8863
|
-
"default": "[842,636,580,0]"
|
8864
|
-
},
|
8865
8826
|
{
|
8866
8827
|
"name": "noPrimaryAction",
|
8867
8828
|
"attribute": "no-primary-action",
|
@@ -9025,6 +8986,12 @@
|
|
9025
8986
|
"type": "'all'|'between'|'none'",
|
9026
8987
|
"default": "\"\\\"all\\\"\""
|
9027
8988
|
},
|
8989
|
+
{
|
8990
|
+
"name": "breakpoints",
|
8991
|
+
"description": "Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.",
|
8992
|
+
"type": "array",
|
8993
|
+
"default": "[842,636,580,0]"
|
8994
|
+
},
|
9028
8995
|
{
|
9029
8996
|
"name": "drag-multiple",
|
9030
8997
|
"description": "Whether the user can drag multiple items",
|
@@ -9074,6 +9041,13 @@
|
|
9074
9041
|
"type": "'all'|'between'|'none'",
|
9075
9042
|
"default": "\"\\\"all\\\"\""
|
9076
9043
|
},
|
9044
|
+
{
|
9045
|
+
"name": "breakpoints",
|
9046
|
+
"attribute": "breakpoints",
|
9047
|
+
"description": "Breakpoints for responsiveness in pixels. There are four different breakpoints and only the four largest breakpoints will be used.",
|
9048
|
+
"type": "array",
|
9049
|
+
"default": "[842,636,580,0]"
|
9050
|
+
},
|
9077
9051
|
{
|
9078
9052
|
"name": "dragMultiple",
|
9079
9053
|
"attribute": "drag-multiple",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "2.150.
|
3
|
+
"version": "2.150.3",
|
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",
|