@brightspace-ui/core 2.33.0 → 2.34.2

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.
@@ -3,6 +3,8 @@ import { css, html, LitElement } from 'lit';
3
3
  import { cssEscape, getComposedChildren, getComposedParent, isVisible } from '../../helpers/dom.js';
4
4
  import { getUniqueId } from '../../helpers/uniqueId.js';
5
5
 
6
+ export const BACKDROP_ROLE = 'd2l-backdrop-role';
7
+
6
8
  const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
7
9
 
8
10
  const scrollKeys = [];
@@ -159,7 +161,7 @@ function hideAccessible(target) {
159
161
  if (child.hasAttribute('d2l-backdrop-hidden')) continue;
160
162
 
161
163
  const role = child.getAttribute('role');
162
- if (role) child.setAttribute('d2l-backdrop-role', role);
164
+ if (role) child.setAttribute(BACKDROP_ROLE, role);
163
165
  child.setAttribute('role', 'presentation');
164
166
 
165
167
  if (child.nodeName === 'FORM' || child.nodeName === 'A') {
@@ -200,10 +202,10 @@ export function preventBodyScroll() {
200
202
  function showAccessible(elems) {
201
203
  for (let i = 0; i < elems.length; i++) {
202
204
  const elem = elems[i];
203
- const role = elem.getAttribute('d2l-backdrop-role');
205
+ const role = elem.getAttribute(BACKDROP_ROLE);
204
206
  if (role) {
205
207
  elem.setAttribute('role', role);
206
- elem.removeAttribute('d2l-backdrop-role');
208
+ elem.removeAttribute(BACKDROP_ROLE);
207
209
  } else {
208
210
  elem.removeAttribute('role');
209
211
  }
@@ -193,6 +193,10 @@ If a `d2l-list-item` is selectable then it should have a `label` attribute that
193
193
  </d2l-list>
194
194
  ```
195
195
 
196
+ ## Pageable Lists
197
+
198
+ Load-More paging functionality can be implemented in lists by placing a `d2l-pager-load-more` in `d2l-list`'s `pager` slot. The consumer must handle the `d2l-pager-load-more` event by loading more items, updating the pager state, and signalling completion by calling `complete()` on the event detail. Focus will be automatically moved on the first new item once complete. See [Paging](../../components/paging) for more details.
199
+
196
200
  ## Drag & Drop Lists
197
201
 
198
202
  The `d2l-list` supports drag & drop.
@@ -516,7 +520,7 @@ This event includes a detail object with helper methods attached to it.
516
520
  <!-- docs: start hidden content -->
517
521
  ## Future Improvements
518
522
 
519
- - Paging: integration with "load more", "scroll" and "numeric" paging mechanisms
523
+ - Paging: integration with "scroll" and "numeric" paging mechanisms
520
524
 
521
525
  Looking for an enhancement not listed here? Create a GitHub issue!
522
526
  <!-- docs: end hidden content -->
@@ -0,0 +1,233 @@
1
+ /* eslint-disable indent */
2
+ import '../../button/button-icon.js';
3
+ import '../../dropdown/dropdown-button-subtle.js';
4
+ import '../../dropdown/dropdown-menu.js';
5
+ import '../../dropdown/dropdown-more.js';
6
+ import '../../menu/menu.js';
7
+ import '../../menu/menu-item.js';
8
+ import '../../paging/pager-load-more.js';
9
+ import '../../selection/selection-action.js';
10
+ import '../../selection/selection-action-dropdown.js';
11
+ import '../../selection/selection-action-menu-item.js';
12
+ import '../../tooltip/tooltip.js';
13
+ import '../list-header.js';
14
+ import '../list-item-content.js';
15
+ import '../list-item.js';
16
+ import '../list.js';
17
+ import { css, html, LitElement } from 'lit';
18
+ import { getUniqueId } from '../../../helpers/uniqueId.js';
19
+ import { repeat } from 'lit/directives/repeat.js';
20
+
21
+ const items = [{
22
+ key: '1',
23
+ primaryText: 'Introductory Earth Sciences',
24
+ supportingText: 'This course explores the geological process of the Earth\'s interior and surface. These include volcanism, earthquakes, mountains...',
25
+ imgSrc: 'https://s.brightspace.com/course-images/images/38e839b1-37fa-470c-8830-b189ce4ae134/tile-high-density-max-size.jpg',
26
+ dropNested: true,
27
+ items: [{
28
+ key: '1-1',
29
+ primaryText: 'Glaciation',
30
+ supportingText: 'Nesting Allowed',
31
+ imgSrc: 'https://s.brightspace.com/course-images/images/bf648978-6637-4fdc-815b-81572c436c0e/tile-high-density-max-size.jpg',
32
+ dropNested: true,
33
+ items: []
34
+ }, {
35
+ key: '1-2',
36
+ primaryText: 'Weathering',
37
+ supportingText: 'Nesting Allowed',
38
+ imgSrc: 'https://s.brightspace.com/course-images/images/50f91ba6-7c25-482a-bd71-1c4b7c8d2154/tile-high-density-min-size.jpg',
39
+ dropNested: true,
40
+ items: []
41
+ }, {
42
+ key: '1-3',
43
+ primaryText: 'Volcanism',
44
+ supportingText: 'Nesting Allowed',
45
+ imgSrc: 'https://s.brightspace.com/course-images/images/5eb2371d-6099-4c8d-8aad-075f357012a2/tile-high-density-min-size.jpg',
46
+ dropNested: true,
47
+ items: []
48
+ }]
49
+ }, {
50
+ key: '2',
51
+ primaryText: 'Engineering Materials for Energy Systems',
52
+ supportingText: 'Shiver me timbers to go on account lookout wherry doubloon chase. Belay yo-ho-ho keelhaul squiffy black spot yardarm spyglass sheet transom heave to.',
53
+ imgSrc: 'https://s.brightspace.com/course-images/images/c87d778f-e5f1-442b-8ac7-5d1a3d7ca725/tile-high-density-max-size.jpg',
54
+ items: [{
55
+ key: '2-1',
56
+ primaryText: 'Contaminant Transport',
57
+ supportingText: 'No Nesting Allowed',
58
+ imgSrc: 'https://s.brightspace.com/course-images/images/824fffa1-86a6-4489-84ba-91edfbc1dcc4/tile-high-density-min-size.jpg',
59
+ dropNested: false,
60
+ items: []
61
+ }, {
62
+ key: '2-2',
63
+ primaryText: 'Modelling Flow in Fractured Media',
64
+ supportingText: 'No Nesting Allowed',
65
+ imgSrc: 'https://s.brightspace.com/course-images/images/e18c92a4-b996-444f-84b5-988874feccac/tile-high-density-min-size.jpg',
66
+ dropNested: false,
67
+ items: []
68
+ }]
69
+ }, {
70
+ key: '3',
71
+ primaryText: 'Geomorphology and GIS',
72
+ supportingText: 'Trysail Sail ho Corsair red ensign hulk smartly boom jib rum gangway. Case shot Shiver me timbers gangplank crack Jennys tea cup ballast Blimey lee snow crow\'s nest rutters.',
73
+ imgSrc: 'https://s.brightspace.com/course-images/images/2f035317-5014-4095-82c8-e29f34c7f99e/tile-high-density-max-size.jpg',
74
+ items: [{
75
+ key: '3-1',
76
+ primaryText: 'Carbon & Nitrogen Cycling',
77
+ supportingText: 'Nesting Allowed',
78
+ imgSrc: 'https://s.brightspace.com/course-images/images/623b420b-a305-4762-8af8-598f0e72e956/tile-high-density-min-size.jpg',
79
+ dropNested: true,
80
+ items: []
81
+ }, {
82
+ key: '3-2',
83
+ primaryText: 'Wetland Engineering',
84
+ supportingText: 'Nesting Allowed',
85
+ imgSrc: 'https://s.brightspace.com/course-images/images/26102577-8f2a-4e24-84b5-19d76decbc7a/tile-high-density-min-size.jpg',
86
+ dropNested: true,
87
+ items: []
88
+ }]
89
+ }, {
90
+ key: '4',
91
+ primaryText: 'Pedagogy Case Studies',
92
+ supportingText: 'Belay yo-ho-ho keelhaul squiffy black spot yardarm spyglass sheet transom heave to. Deadlights jack lad schooner scallywag dance the hempen jig carouser broadside cable strike colors.',
93
+ imgSrc: 'https://s.brightspace.com/course-images/images/e5fd575a-bc14-4a80-89e1-46f349a76178/tile-high-density-max-size.jpg',
94
+ items: []
95
+ }, {
96
+ key: '5',
97
+ primaryText: 'Introduction to Painting',
98
+ supportingText: 'Fluke jib scourge of the seven seas boatswain schooner gaff booty Jack Tar transom spirits. Bring a spring upon her cable holystone blow the man down spanker.',
99
+ imgSrc: 'https://s.brightspace.com/course-images/images/63b162ab-b582-4bf9-8c1d-1dad04714121/tile-high-density-max-size.jpg',
100
+ items: []
101
+ }, {
102
+ key: '6',
103
+ primaryText: 'Analytical Chemistry',
104
+ supportingText: 'Trysail Sail ho Corsair red ensign hulk smartly boom jib rum gangway. Fluke jib scourge of the seven seas boatswain schooner gaff booty Jack Tar transom spirits.',
105
+ imgSrc: 'https://s.brightspace.com/course-images/images/85f865dd-4c73-49c5-8809-c872256f7715/tile-high-density-max-size.jpg',
106
+ items: []
107
+ }, {
108
+ key: '7',
109
+ primaryText: 'Plant Biology',
110
+ supportingText: 'Deadlights jack lad schooner scallywag dance the hempen jig carouser broadside cable strike colors. Bring a spring upon her cable holystone blow the man down spanker.',
111
+ imgSrc: 'https://s.brightspace.com/course-images/images/61f07ae4-4686-4019-8146-1604cb8ae9bf/tile-high-density-max-size.jpg',
112
+ items: []
113
+ }];
114
+
115
+ class DemoList extends LitElement {
116
+
117
+ static get properties() {
118
+ return {
119
+ grid: { type: Boolean },
120
+ _lastItemLoadedIndex: { state: true }
121
+ };
122
+ }
123
+
124
+ static get styles() {
125
+ return css`
126
+ :host {
127
+ display: block;
128
+ }
129
+ :host([hidden]) {
130
+ display: none;
131
+ }
132
+ img {
133
+ height: 500px;
134
+ object-fit: cover;
135
+ }
136
+ `;
137
+ }
138
+
139
+ constructor() {
140
+ super();
141
+ this.items = JSON.parse(JSON.stringify(items));
142
+ this._lastItemLoadedIndex = 2;
143
+ this._pageSize = 2;
144
+ }
145
+
146
+ render() {
147
+ const loadedItems = this.items.slice(0, this._lastItemLoadedIndex + 1);
148
+ const remainingItemCount = this.items.length - loadedItems.length;
149
+ return html`
150
+ <d2l-list ?grid="${this.grid}" item-count="${this.items.length}">
151
+ <d2l-list-header slot="header" select-all-pages-allowed>
152
+ <d2l-selection-action icon="tier1:plus-default" text="Add" @d2l-selection-action-click="${this._handleAddItem}"></d2l-selection-action>
153
+ <d2l-selection-action-dropdown text="Move To" requires-selection>
154
+ <d2l-dropdown-menu>
155
+ <d2l-menu label="Move To Options">
156
+ <d2l-menu-item text="Top of Quiz"></d2l-menu-item>
157
+ <d2l-menu-item text="Bottom of Quiz"></d2l-menu-item>
158
+ <d2l-menu-item text="Section">
159
+ <d2l-menu>
160
+ <d2l-menu-item text="Option 1"></d2l-menu-item>
161
+ <d2l-menu-item text="Option 2"></d2l-menu-item>
162
+ </d2l-menu>
163
+ </d2l-menu-item>
164
+ </d2l-menu>
165
+ </d2l-dropdown-menu>
166
+ </d2l-selection-action-dropdown>
167
+ <d2l-dropdown-button-subtle text="Actions">
168
+ <d2l-dropdown-menu>
169
+ <d2l-menu label="Actions">
170
+ <d2l-selection-action-menu-item text="Bookmark (requires selection)" requires-selection></d2l-selection-action-menu-item>
171
+ <d2l-selection-action-menu-item text="Advanced"></d2l-selection-action-menu-item>
172
+ </d2l-menu>
173
+ </d2l-dropdown-menu>
174
+ </d2l-dropdown-button-subtle>
175
+ <d2l-selection-action icon="tier1:gear" text="Settings" requires-selection></d2l-selection-action>
176
+ </d2l-list-header>
177
+ ${repeat(loadedItems, item => item.key, item => {
178
+ const tooltipButtonId = getUniqueId();
179
+ return html`
180
+ <d2l-list-item href="http://www.d2l.com" key="${item.key}" label="${item.primaryText}" selectable>
181
+ <img slot="illustration" src="${item.imgSrc}">
182
+ <d2l-list-item-content>
183
+ <div>${item.primaryText}</div>
184
+ <div slot="supporting-info">${item.supportingText}</div>
185
+ </d2l-list-item-content>
186
+ <div slot="actions">
187
+ <d2l-button-icon id="${tooltipButtonId}" text="My Button" icon="tier1:preview"></d2l-button-icon>
188
+ <d2l-tooltip for="${tooltipButtonId}">Preview</d2l-tooltip>
189
+ <d2l-dropdown-more text="Open!">
190
+ <d2l-dropdown-menu>
191
+ <d2l-menu label="Astronomy">
192
+ <d2l-menu-item text="Introduction"></d2l-menu-item>
193
+ <d2l-menu-item text="Searching for the Heavens "></d2l-menu-item>
194
+ </d2l-menu>
195
+ </d2l-dropdown-menu>
196
+ </d2l-dropdown-more>
197
+ </div>
198
+ </d2l-list-item>
199
+ `;
200
+ })}
201
+ <d2l-pager-load-more slot="pager"
202
+ @d2l-pager-load-more="${this._handlePagerLoadMore}"
203
+ ?has-more="${this._lastItemLoadedIndex < this.items.length - 1}"
204
+ item-count="${this.items.length}"
205
+ page-size="${remainingItemCount < this._pageSize ? remainingItemCount : this._pageSize}">
206
+ </d2l-pager-load-more>
207
+ </d2l-list>
208
+ `;
209
+ }
210
+
211
+ _handleAddItem() {
212
+ const newKey = getUniqueId();
213
+ this.items.push({
214
+ key: newKey,
215
+ primaryText: `New Item ${newKey}`,
216
+ supportingText: 'Shiver me timbers to go on account lookout wherry doubloon chase. Belay yo-ho-ho keelhaul squiffy black spot yardarm spyglass sheet transom heave to.',
217
+ imgSrc: 'https://s.brightspace.com/course-images/images/38e839b1-37fa-470c-8830-b189ce4ae134/tile-high-density-max-size.jpg',
218
+ items: []
219
+ });
220
+ this.requestUpdate();
221
+ }
222
+
223
+ _handlePagerLoadMore(e) {
224
+ // mock delay consumers might have
225
+ setTimeout(() => {
226
+ this._lastItemLoadedIndex += this._pageSize;
227
+ e.detail.complete();
228
+ }, 2000);
229
+
230
+ }
231
+
232
+ }
233
+ customElements.define('d2l-demo-list', DemoList);
@@ -7,21 +7,17 @@
7
7
  <script type="module">
8
8
  import '../../button/button-icon.js';
9
9
  import '../../demo/demo-page.js';
10
- import '../../dropdown/dropdown-button-subtle.js';
11
10
  import '../../dropdown/dropdown-menu.js';
12
11
  import '../../dropdown/dropdown-more.js';
13
12
  import '../../menu/menu.js';
14
13
  import '../../menu/menu-item.js';
15
- import '../../selection/selection-action.js';
16
- import '../../selection/selection-action-dropdown.js';
17
- import '../../selection/selection-action-menu-item.js';
18
14
  import '../../tooltip/tooltip.js';
19
- import '../list-header.js';
20
15
  import '../list-item-content.js';
21
16
  import '../list-item.js';
22
17
  import '../list.js';
23
18
  import '../../tag-list/tag-list.js';
24
19
  import '../../tag-list/tag-list-item.js';
20
+ import './demo-list.js';
25
21
  </script>
26
22
  <style>
27
23
  img {
@@ -71,108 +67,7 @@
71
67
 
72
68
  <d2l-demo-snippet>
73
69
  <template>
74
- <d2l-list id="allFeatures" item-count="50">
75
- <d2l-list-header slot="header" select-all-pages-allowed>
76
- <d2l-selection-action icon="tier1:plus-default" text="Add"></d2l-selection-action>
77
- <d2l-selection-action-dropdown text="Move To" requires-selection>
78
- <d2l-dropdown-menu>
79
- <d2l-menu label="Move To Options">
80
- <d2l-menu-item text="Top of Quiz"></d2l-menu-item>
81
- <d2l-menu-item text="Bottom of Quiz"></d2l-menu-item>
82
- <d2l-menu-item text="Section">
83
- <d2l-menu>
84
- <d2l-menu-item text="Option 1"></d2l-menu-item>
85
- <d2l-menu-item text="Option 2"></d2l-menu-item>
86
- </d2l-menu-item>
87
- </d2l-menu-item>
88
- </d2l-menu>
89
- </d2l-dropdown-menu>
90
- </d2l-selection-action-dropdown>
91
- <d2l-dropdown-button-subtle text="Actions">
92
- <d2l-dropdown-menu>
93
- <d2l-menu label="Actions">
94
- <d2l-selection-action-menu-item text="Bookmark (requires selection)" requires-selection></d2l-selection-action-menu-item>
95
- <d2l-selection-action-menu-item text="Advanced"></d2l-selection-action-menu-item>
96
- </d2l-menu>
97
- </d2l-dropdown-menu>
98
- </d2l-dropdown-button-subtle>
99
- <d2l-selection-action icon="tier1:gear" text="Settings" requires-selection></d2l-selection-action>
100
- </d2l-list-header>
101
- <d2l-list-item href="http://www.d2l.com" selectable key="1" label="Introductory Earth Sciences">
102
- <img slot="illustration" src="https://s.brightspace.com/course-images/images/38e839b1-37fa-470c-8830-b189ce4ae134/tile-high-density-max-size.jpg"></img>
103
- <d2l-list-item-content>
104
- <div>Introductory Earth Sciences</div>
105
- <div slot="supporting-info">This course explores the geological process of the Earth's interior and surface. These include volcanism, earthquakes, mountains...</div>
106
- </d2l-list-item-content>
107
- <div slot="actions">
108
- <d2l-button-icon id="tooltip-btn-1" text="My Button" icon="tier1:preview"></d2l-button-icon>
109
- <d2l-tooltip for="tooltip-btn-1">Preview</d2l-tooltip>
110
- <d2l-dropdown-more text="Open!">
111
- <d2l-dropdown-menu>
112
- <d2l-menu label="Astronomy">
113
- <d2l-menu-item text="Introduction"></d2l-menu-item>
114
- <d2l-menu-item text="Searching for the Heavens "></d2l-menu-item>
115
- </d2l-menu>
116
- </d2l-dropdown-menu>
117
- </d2l-dropdown-more>
118
- </div>
119
- </d2l-list-item>
120
- <d2l-list-item href="http://www.d2l.com" selectable key="2" selected label="Engineering Materials for Energy Systems">
121
- <img slot="illustration" src="https://s.brightspace.com/course-images/images/e5fd575a-bc14-4a80-89e1-46f349a76178/tile-high-density-max-size.jpg"></img>
122
- <d2l-list-item-content>
123
- <div>Engineering Materials for Energy Systems</div>
124
- <div slot="supporting-info">This course explores the geological processes of the Earth's interior and surface. These include volcanism, earthquakes, mountain...</div>
125
- </d2l-list-item-content>
126
- <div slot="actions">
127
- <d2l-button-icon id="tooltip-btn-1" text="My Button" icon="tier1:preview"></d2l-button-icon>
128
- <d2l-tooltip for="tooltip-btn-1">Preview</d2l-tooltip>
129
- <d2l-dropdown-more text="Open!">
130
- <d2l-dropdown-menu>
131
- <d2l-menu label="Astronomy">
132
- <d2l-menu-item text="Introduction"></d2l-menu-item>
133
- <d2l-menu-item text="Searching for the Heavens "></d2l-menu-item>
134
- </d2l-menu>
135
- </d2l-dropdown-menu>
136
- </d2l-dropdown-more>
137
- </div>
138
- </d2l-list-item>
139
- <d2l-list-item href="http://www.d2l.com" selectable key="3" label="Geomorphology and GIS">
140
- <img slot="illustration" src="https://s.brightspace.com/course-images/images/63b162ab-b582-4bf9-8c1d-1dad04714121/tile-high-density-max-size.jpg"></img>
141
- <d2l-list-item-content>
142
- <div>Geomorphology and GIS</div>
143
- <div slot="supporting-info">This course explores the geological processes of the Earth's interior and surface. These include volcanism, earthquakes, mountain...</div>
144
- </d2l-list-item-content>
145
- <div slot="actions">
146
- <d2l-button-icon id="tooltip-btn-1" text="My Button" icon="tier1:preview"></d2l-button-icon>
147
- <d2l-tooltip for="tooltip-btn-1">Preview</d2l-tooltip>
148
- <d2l-dropdown-more text="Open!">
149
- <d2l-dropdown-menu>
150
- <d2l-menu label="Astronomy">
151
- <d2l-menu-item text="Introduction"></d2l-menu-item>
152
- <d2l-menu-item text="Searching for the Heavens "></d2l-menu-item>
153
- </d2l-menu>
154
- </d2l-dropdown-menu>
155
- </d2l-dropdown-more>
156
- </div>
157
- </d2l-list-item>
158
- </d2l-list>
159
- <script>
160
- let newItemCount = 0;
161
- document.querySelector('d2l-selection-action[text="Add"]').addEventListener('d2l-selection-action-click', () => {
162
- const item = document.createElement('d2l-list-item');
163
- item.selectable = true;
164
- item.key = `${++newItemCount}`;
165
- item.label = 'New Item';
166
- item.innerHTML = `
167
- <img slot="illustration" src="https://s.brightspace.com/course-images/images/38e839b1-37fa-470c-8830-b189ce4ae134/tile-high-density-max-size.jpg"></img>
168
- <d2l-list-item-content>
169
- <div>New Item ${newItemCount}</div>
170
- <div slot="supporting-info">Supporting Info</div>
171
- </d2l-list-item-content>
172
- `;
173
- document.querySelector('#allFeatures').appendChild(item);
174
- });
175
- </script>
70
+ <d2l-demo-list></d2l-demo-list>
176
71
  </template>
177
72
  </d2l-demo-snippet>
178
73
 
@@ -180,65 +75,7 @@
180
75
 
181
76
  <d2l-demo-snippet>
182
77
  <template>
183
- <d2l-list grid>
184
- <d2l-list-item href="http://www.d2l.com" selectable key="1" label="Introductory Earth Sciences">
185
- <img slot="illustration" src="https://s.brightspace.com/course-images/images/38e839b1-37fa-470c-8830-b189ce4ae134/tile-high-density-max-size.jpg"></img>
186
- <d2l-list-item-content>
187
- <div>Introductory Earth Sciences</div>
188
- <div slot="supporting-info">This course explores the geological process of the Earth's interior and surface. These include volcanism, earthquakes, mountains...</div>
189
- </d2l-list-item-content>
190
- <div slot="actions">
191
- <d2l-button-icon id="tooltip-btn-1" text="My Button" icon="tier1:preview"></d2l-button-icon>
192
- <d2l-tooltip for="tooltip-btn-1">Preview</d2l-tooltip>
193
- <d2l-dropdown-more text="Open!">
194
- <d2l-dropdown-menu>
195
- <d2l-menu label="Astronomy">
196
- <d2l-menu-item text="Introduction"></d2l-menu-item>
197
- <d2l-menu-item text="Searching for the Heavens "></d2l-menu-item>
198
- </d2l-menu>
199
- </d2l-dropdown-menu>
200
- </d2l-dropdown-more>
201
- </div>
202
- </d2l-list-item>
203
- <d2l-list-item href="http://www.d2l.com" selectable key="2" selected label="Engineering Materials for Energy Systems">
204
- <img slot="illustration" src="https://s.brightspace.com/course-images/images/e5fd575a-bc14-4a80-89e1-46f349a76178/tile-high-density-max-size.jpg"></img>
205
- <d2l-list-item-content>
206
- <div>Engineering Materials for Energy Systems</div>
207
- <div slot="supporting-info">This course explores the geological processes of the Earth's interior and surface. These include volcanism, earthquakes, mountain...</div>
208
- </d2l-list-item-content>
209
- <div slot="actions">
210
- <d2l-button-icon id="tooltip-btn-1" text="My Button" icon="tier1:preview"></d2l-button-icon>
211
- <d2l-tooltip for="tooltip-btn-1">Preview</d2l-tooltip>
212
- <d2l-dropdown-more text="Open!">
213
- <d2l-dropdown-menu>
214
- <d2l-menu label="Astronomy">
215
- <d2l-menu-item text="Introduction"></d2l-menu-item>
216
- <d2l-menu-item text="Searching for the Heavens "></d2l-menu-item>
217
- </d2l-menu>
218
- </d2l-dropdown-menu>
219
- </d2l-dropdown-more>
220
- </div>
221
- </d2l-list-item>
222
- <d2l-list-item href="http://www.d2l.com" selectable key="3" label="Geomorphology and GIS">
223
- <img slot="illustration" src="https://s.brightspace.com/course-images/images/63b162ab-b582-4bf9-8c1d-1dad04714121/tile-high-density-max-size.jpg"></img>
224
- <d2l-list-item-content>
225
- <div>Geomorphology and GIS</div>
226
- <div slot="supporting-info">This course explores the geological processes of the Earth's interior and surface. These include volcanism, earthquakes, mountain...</div>
227
- </d2l-list-item-content>
228
- <div slot="actions">
229
- <d2l-button-icon id="tooltip-btn-1" text="My Button" icon="tier1:preview"></d2l-button-icon>
230
- <d2l-tooltip for="tooltip-btn-1">Preview</d2l-tooltip>
231
- <d2l-dropdown-more text="Open!">
232
- <d2l-dropdown-menu>
233
- <d2l-menu label="Astronomy">
234
- <d2l-menu-item text="Introduction"></d2l-menu-item>
235
- <d2l-menu-item text="Searching for the Heavens "></d2l-menu-item>
236
- </d2l-menu>
237
- </d2l-dropdown-menu>
238
- </d2l-dropdown-more>
239
- </div>
240
- </d2l-list-item>
241
- </d2l-list>
78
+ <d2l-demo-list grid></d2l-demo-list>
242
79
  </template>
243
80
  </d2l-demo-snippet>
244
81
 
@@ -247,7 +84,7 @@
247
84
  <d2l-demo-snippet>
248
85
  <template>
249
86
  <d2l-list grid>
250
- <d2l-list-item no-primary-action selectable key="1" label="Introductory Earth Sciences">
87
+ <d2l-list-item selectable key="1" label="Introductory Earth Sciences">
251
88
  <img slot="illustration" src="https://s.brightspace.com/course-images/images/38e839b1-37fa-470c-8830-b189ce4ae134/tile-high-density-max-size.jpg"></img>
252
89
  <div>
253
90
  <d2l-list-item-content>
@@ -530,6 +530,7 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
530
530
  if (!this.gridActive) return;
531
531
  const slot = (e.path || e.composedPath()).find(node =>
532
532
  node.nodeName === 'SLOT' && node.classList.contains('d2l-cell'));
533
+ if (!slot) return;
533
534
  this._cellNum = parseInt(slot.getAttribute('data-cell-num'));
534
535
  this._cellFocusedItem = this._getFocusedItemPosition(e.target);
535
536
  }
@@ -1,6 +1,7 @@
1
1
  import { css, html, LitElement } from 'lit';
2
2
  import { getNextFocusable, getPreviousFocusable } from '../../helpers/focus.js';
3
3
  import { SelectionInfo, SelectionMixin } from '../selection/selection-mixin.js';
4
+ import { PageableMixin } from '../paging/pageable-mixin.js';
4
5
 
5
6
  const keyCodes = {
6
7
  TAB: 9
@@ -12,9 +13,10 @@ export const listSelectionStates = SelectionInfo.states;
12
13
  * 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.
13
14
  * @slot - Slot for list items (ex. `d2l-list-item`, `d2l-list-item-button`, or custom items)
14
15
  * @slot header - Slot for `d2l-list-header` to be rendered above the list
16
+ * @slot pager - Slot for `d2l-pager-load-more` to be rendered below the list
15
17
  * @fires d2l-list-items-move - Dispatched when one or more items are moved. See [Event Details: d2l-list-items-move](#event-details%3A-%40d2l-list-items-move).
16
18
  */
17
- class List extends SelectionMixin(LitElement) {
19
+ class List extends PageableMixin(SelectionMixin(LitElement)) {
18
20
 
19
21
  static get properties() {
20
22
  return {
@@ -50,6 +52,9 @@ class List extends SelectionMixin(LitElement) {
50
52
  :host([hidden]) {
51
53
  display: none;
52
54
  }
55
+ slot[name="pager"]::slotted(*) {
56
+ margin-top: 12px;
57
+ }
53
58
  `;
54
59
  }
55
60
 
@@ -58,9 +63,16 @@ class List extends SelectionMixin(LitElement) {
58
63
  this.dragMultiple = false;
59
64
  this.extendSeparators = false;
60
65
  this.grid = false;
66
+ this._itemsShowingCount = 0;
67
+ this._itemsShowingTotalCount = 0;
61
68
  this._listItemChanges = [];
62
69
  }
63
70
 
71
+ connectedCallback() {
72
+ super.connectedCallback();
73
+ this.addEventListener('d2l-list-items-showing-count-change', this._handleListItemsShowingCountChange);
74
+ }
75
+
64
76
  disconnectedCallback() {
65
77
  super.disconnectedCallback();
66
78
  if (this._intersectionObserver) this._intersectionObserver.disconnect();
@@ -115,14 +127,15 @@ class List extends SelectionMixin(LitElement) {
115
127
  <div class="d2l-list-top-sentinel"></div>
116
128
  <div role="${role}" class="d2l-list-container">
117
129
  <slot name="header"></slot>
118
- <slot @keydown="${this._handleKeyDown}"></slot>
130
+ <slot @keydown="${this._handleKeyDown}" @slotchange="${this._handleSlotChange}"></slot>
131
+ ${this._renderPagerContainer()}
119
132
  </div>
120
133
  `;
121
134
  }
122
135
 
123
- getItems() {
136
+ getItems(slot) {
124
137
  if (!this.shadowRoot) return;
125
- const slot = this.shadowRoot.querySelector('slot:not([name])');
138
+ if (!slot) slot = this.shadowRoot.querySelector('slot:not([name])');
126
139
  if (!slot) return [];
127
140
  return slot.assignedNodes({ flatten: true }).filter((node) => {
128
141
  return node.nodeType === Node.ELEMENT_NODE && (node.role === 'rowgroup' || node.role === 'listitem');
@@ -175,6 +188,35 @@ class List extends SelectionMixin(LitElement) {
175
188
  return new SelectionInfo(keys, selectionInfo.state);
176
189
  }
177
190
 
191
+ _getItemByIndex(index) {
192
+ const items = this.getItems();
193
+ if (index > items.length - 1) return;
194
+ return items[index];
195
+ }
196
+
197
+ async _getItemsShowingCount() {
198
+ if (this.slot === 'nested') return this._itemsShowingCount;
199
+ else return this._getListItemsShowingTotalCount(false);
200
+ }
201
+
202
+ _getLastItemIndex() {
203
+ return this._itemsShowingCount - 1;
204
+ }
205
+
206
+ async _getListItemsShowingTotalCount(refresh) {
207
+ if (refresh) {
208
+ this._itemsShowingTotalCount = await this.getItems().reduce(async(count, item) => {
209
+ await item.updateComplete;
210
+ if (item._selectionProvider) {
211
+ return (await count + await item._selectionProvider._getListItemsShowingTotalCount(true));
212
+ } else {
213
+ return await count;
214
+ }
215
+ }, this._itemsShowingCount);
216
+ }
217
+ return this._itemsShowingTotalCount;
218
+ }
219
+
178
220
  _handleKeyDown(e) {
179
221
  if (!this.grid || this.slot === 'nested' || e.keyCode !== keyCodes.TAB) return;
180
222
  e.preventDefault();
@@ -184,6 +226,36 @@ class List extends SelectionMixin(LitElement) {
184
226
  if (focusable) focusable.focus();
185
227
  }
186
228
 
229
+ _handleListItemsShowingCountChange() {
230
+ if (this.slot === 'nested') return;
231
+
232
+ // debounce the updates for first render case
233
+ if (this._updateItemsShowingTotalCountRequested) return;
234
+
235
+ this._updateItemsShowingTotalCountRequested = true;
236
+ setTimeout(async() => {
237
+ const oldCount = this._itemsShowingTotalCount;
238
+ const newCount = await this._getListItemsShowingTotalCount(true);
239
+ if (oldCount !== newCount) this._updatePagerCount(newCount);
240
+ this._updateItemsShowingTotalCountRequested = false;
241
+ }, 0);
242
+ }
243
+
244
+ async _handleSlotChange(e) {
245
+ const items = this.getItems(e.target);
246
+ if (this._itemsShowingCount === items.length) return;
247
+ this._itemsShowingCount = items.length;
248
+
249
+ this._updatePagerCount(await this._getListItemsShowingTotalCount(true));
250
+
251
+ /** @ignore */
252
+ this.dispatchEvent(new CustomEvent('d2l-list-items-showing-count-change', {
253
+ bubbles: true,
254
+ composed: true,
255
+ detail: { count: this._itemsShowingCount }
256
+ }));
257
+ }
258
+
187
259
  }
188
260
 
189
261
  customElements.define('d2l-list', List);