@brightspace-ui/core 2.116.0 → 2.117.1

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.
@@ -115,6 +115,7 @@ The `d2l-collapsible-panel` element is a container that provides specific layout
115
115
 
116
116
  | Slot | Type | Description |
117
117
  |--|--|--|
118
+ | `before` | optional | Slot for content to be placed at the left side of the header, aligned with the title and header slot |
118
119
  | `header` | optional | Supporting header content |
119
120
  | `actions` | optional | Buttons and dropdown openers to be placed in top right corner of header |
120
121
  | `summary` | optional | Summary of the expanded content. Only accepts `d2l-collapsible-panel-summary-item` |
@@ -132,6 +133,7 @@ The `d2l-collapsible-panel` element is a container that provides specific layout
132
133
  | `no-sticky` | Boolean | Disables sticky positioning for the header |
133
134
  | `padding-type` | String | Optionally set horizontal padding of inline panels |
134
135
  | `panel-title` | String | The title of the panel |
136
+ | `skeleton` | Boolean | Renders the panel title and the expand/collapse icon as skeleton loaders |
135
137
  | `type` | String | The type of collapsible panel |
136
138
  <!-- docs: end hidden content -->
137
139
 
@@ -20,6 +20,7 @@ const defaultHeading = 3;
20
20
 
21
21
  /**
22
22
  * A container with a title that can be expanded/collapsed to show/hide content.
23
+ * @slot before - Slot for content to be placed at the left side of the header, aligned with the title and header slot
23
24
  * @slot header - Slot for supporting header content
24
25
  * @slot summary - Slot for the summary of the expanded content. Only accepts `d2l-collapsible-panel-summary-item`
25
26
  * @slot default - Slot for the expanded content
@@ -77,6 +78,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
77
78
  */
78
79
  noSticky: { attribute: 'no-sticky', type: Boolean },
79
80
  _focused: { state: true },
81
+ _hasBefore: { state: true },
80
82
  _hasSummary: { state: true },
81
83
  _scrolled: { state: true },
82
84
  };
@@ -122,8 +124,19 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
122
124
  :host([heading-style="4"]) {
123
125
  --d2l-collapsible-panel-header-spacing: 0.3rem;
124
126
  }
127
+ .d2l-collapsible-panel-before {
128
+ grid-row: 1/-1;
129
+ }
130
+ .d2l-collapsible-panel.has-before .d2l-collapsible-panel-before {
131
+ margin: 0.3rem 0;
132
+ margin-inline-start: var(--d2l-collapsible-panel-spacing-inline);
133
+ }
125
134
  .d2l-collapsible-panel-header {
126
135
  border-radius: 0.4rem;
136
+ cursor: pointer;
137
+ display: grid;
138
+ grid-template-columns: auto 1fr;
139
+ grid-template-rows: auto auto;
127
140
  padding: var(--d2l-collapsible-panel-header-spacing) 0;
128
141
  }
129
142
  :host(:not([skeleton])) .d2l-collapsible-panel-header {
@@ -155,6 +168,9 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
155
168
  overflow-y: hidden;
156
169
  user-select: none;
157
170
  }
171
+ .d2l-collapsible-panel.has-before .d2l-collapsible-panel-title {
172
+ margin-inline-start: 0.75rem;
173
+ }
158
174
 
159
175
  .d2l-collapsible-panel.focused {
160
176
  outline: var(--d2l-collapsible-panel-focus-outline);
@@ -172,8 +188,12 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
172
188
  }
173
189
  .d2l-collapsible-panel-header-secondary {
174
190
  display: flex;
191
+ margin-inline-end: var(--d2l-collapsible-panel-spacing-inline);
175
192
  margin-inline-start: var(--d2l-collapsible-panel-spacing-inline);
176
193
  }
194
+ .d2l-collapsible-panel.has-before .d2l-collapsible-panel-header-secondary {
195
+ margin-inline-start: 0.75rem;
196
+ }
177
197
  .d2l-collapsible-panel-header-secondary ::slotted(*) {
178
198
  cursor: default;
179
199
  }
@@ -289,6 +309,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
289
309
  'd2l-collapsible-panel': true,
290
310
  'focused': this._focused,
291
311
  'has-summary': this._hasSummary,
312
+ 'has-before': this._hasBefore,
292
313
  'scrolled': this._scrolled,
293
314
  };
294
315
  const expandCollapseLabel = this.expandCollapseLabel || this.panelTitle;
@@ -344,6 +365,12 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
344
365
  }
345
366
  }
346
367
 
368
+ _handleBeforeSlotChange(e) {
369
+ const content = e.target.assignedNodes({ flatten: true });
370
+
371
+ this._hasBefore = content?.length > 0;
372
+ }
373
+
347
374
  _handleExpandCollapse(e) {
348
375
  const eventPromise = this.expanded ? e.detail.expandComplete : e.detail.collapseComplete;
349
376
  const event = `d2l-collapsible-panel-${this.expanded ? 'expand' : 'collapse' }`;
@@ -390,6 +417,9 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
390
417
  _renderHeader() {
391
418
  return html`
392
419
  <div class="d2l-collapsible-panel-header" @click="${this._handleHeaderClick}">
420
+ <div class="d2l-collapsible-panel-before">
421
+ <slot name="before" @slotchange="${this._handleBeforeSlotChange}"></slot>
422
+ </div>
393
423
  <div class="d2l-collapsible-panel-header-primary">
394
424
  ${this._renderPanelTitle()}
395
425
  <div class="d2l-collapsible-panel-header-actions" @click="${this._handleActionsClick}">
@@ -106,9 +106,10 @@
106
106
  </d2l-collapsible-panel>
107
107
  </d2l-demo-snippet>
108
108
 
109
- <h2>With custom action and header content</h2>
109
+ <h2>With custom action, before and header content</h2>
110
110
  <d2l-demo-snippet>
111
111
  <d2l-collapsible-panel panel-title="Session: January 1, 2021: 10:00 AM" expand-collapse-label="Session on January 1">
112
+ <d2l-icon icon="tier3:assignments" slot="before"></d2l-icon>
112
113
  <d2l-button-icon slot="actions" icon="tier1:fullscreen"></d2l-button-icon><d2l-button-icon slot="actions" icon="tier1:download"></d2l-button-icon><d2l-dropdown-more slot="actions">
113
114
  <d2l-dropdown-menu>
114
115
  <d2l-menu>
@@ -24,6 +24,7 @@
24
24
  <d2l-demo-snippet>
25
25
  <template>
26
26
  <d2l-tabs>
27
+ <d2l-tab-panel text="All">Tab content for All</d2l-tab-panel>
27
28
  <d2l-tab-panel text="Biology">Tab content for Biology</d2l-tab-panel>
28
29
  <d2l-tab-panel text="Chemistry">Tab content for Chemistry</d2l-tab-panel>
29
30
  <d2l-tab-panel text="Earth &amp; Planetary Sciences">Tab content for Earth &amp; Planetary Sciences</d2l-tab-panel>
@@ -39,6 +40,7 @@
39
40
  <d2l-button-subtle id="add" text="Add"></d2l-button-subtle>
40
41
  <d2l-button-subtle id="add-selected" text="Add Selected"></d2l-button-subtle>
41
42
  <d2l-button-subtle id="remove" text="Remove"></d2l-button-subtle>
43
+ <d2l-button-subtle id="remove-multiple" text="Remove Multiple"></d2l-button-subtle>
42
44
  </div>
43
45
  <script>
44
46
  let newPanelId = 0;
@@ -58,10 +60,20 @@
58
60
  if (panels.length === 1) tabs.removeChild(panels[0]);
59
61
  else tabs.removeChild(panels[1]);
60
62
  };
63
+ const removePanels = (tabs) => {
64
+ const panels = [...tabs.querySelectorAll('d2l-tab-panel')];
65
+ if (panels.length === 0) return;
66
+ if (panels.length === 1) tabs.removeChild(panels[0]);
67
+ else {
68
+ tabs.removeChild(panels[1]);
69
+ tabs.removeChild(panels[0]);
70
+ }
71
+ };
61
72
 
62
73
  document.querySelector('#add').addEventListener('click', () => addPanel(false, document.querySelector('#withSlot').querySelector('d2l-tabs')));
63
74
  document.querySelector('#add-selected').addEventListener('click', () => addPanel(true, document.querySelector('#withSlot').querySelector('d2l-tabs')));
64
75
  document.querySelector('#remove').addEventListener('click', () => removePanel(document.querySelector('#withSlot').querySelector('d2l-tabs')));
76
+ document.querySelector('#remove-multiple').addEventListener('click', () => removePanels(document.querySelector('#withSlot').querySelector('d2l-tabs')));
65
77
  </script>
66
78
 
67
79
  <d2l-demo-snippet id="withSlot">
@@ -611,6 +611,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
611
611
  // if a tab was removed, include old info to animate it away
612
612
  if (newTabInfos.findIndex(newInfo => newInfo.id === info.id) === -1) {
613
613
  info.state = 'removing';
614
+ info.selected = false;
614
615
  newTabInfos.splice(index, 0, info);
615
616
  }
616
617
  });
@@ -618,9 +619,11 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
618
619
  this._tabInfos = newTabInfos;
619
620
 
620
621
  if (this._tabInfos.length > 0 && !selectedTabInfo) {
621
- this._tabInfos[0].activeFocusable = true;
622
- this._tabInfos[0].selected = true;
623
- selectedTabInfo = this._tabInfos[0];
622
+ selectedTabInfo = this._tabInfos.find(tabInfo => tabInfo.state !== 'removing');
623
+ if (selectedTabInfo) {
624
+ selectedTabInfo.activeFocusable = true;
625
+ selectedTabInfo.selected = true;
626
+ }
624
627
  }
625
628
 
626
629
  await this.updateComplete;
@@ -1313,6 +1313,10 @@
1313
1313
  }
1314
1314
  ],
1315
1315
  "slots": [
1316
+ {
1317
+ "name": "before",
1318
+ "description": "Slot for content to be placed at the left side of the header, aligned with the title and header slot"
1319
+ },
1316
1320
  {
1317
1321
  "name": "header",
1318
1322
  "description": "Slot for supporting header content"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.116.0",
3
+ "version": "2.117.1",
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",