@brightspace-ui/core 3.137.3 → 3.138.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.
- package/components/card/card.js +20 -17
- package/components/tabs/README.md +2 -2
- package/components/tabs/tab.js +12 -2
- package/custom-elements.json +2 -2
- package/package.json +1 -1
package/components/card/card.js
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
import '../colors/colors.js';
|
2
2
|
import { css, html, LitElement, nothing } from 'lit';
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
4
|
-
import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
|
5
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
6
5
|
import { offscreenStyles } from '../offscreen/offscreen.js';
|
7
6
|
import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
|
8
|
-
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
|
9
7
|
import { styleMap } from 'lit/directives/style-map.js';
|
10
8
|
|
11
9
|
/**
|
@@ -16,7 +14,7 @@ import { styleMap } from 'lit/directives/style-map.js';
|
|
16
14
|
* @slot footer - Slot for footer content, such secondary actions
|
17
15
|
* @slot header - Slot for header content, such as course image (no actionable elements)
|
18
16
|
*/
|
19
|
-
class Card extends
|
17
|
+
class Card extends LitElement {
|
20
18
|
|
21
19
|
static get properties() {
|
22
20
|
return {
|
@@ -142,22 +140,14 @@ class Card extends FocusMixin(RtlMixin(LitElement)) {
|
|
142
140
|
padding-bottom: 1.2rem;
|
143
141
|
}
|
144
142
|
.d2l-card-actions {
|
143
|
+
inset-inline-end: 0.6rem;
|
145
144
|
position: absolute;
|
146
|
-
right: 0.6rem;
|
147
145
|
top: 0.6rem;
|
148
146
|
/* this must be higher than footer z-index so dropdowns will be on top */
|
149
147
|
z-index: 3;
|
150
148
|
}
|
151
|
-
:host([dir="rtl"]) .d2l-card-actions {
|
152
|
-
left: 0.6rem;
|
153
|
-
right: auto;
|
154
|
-
}
|
155
149
|
.d2l-card-actions ::slotted(*) {
|
156
|
-
margin-
|
157
|
-
}
|
158
|
-
:host([dir="rtl"]) .d2l-card-actions ::slotted(*) {
|
159
|
-
margin-left: 0;
|
160
|
-
margin-right: 0.3rem;
|
150
|
+
margin-inline-start: 0.3rem;
|
161
151
|
}
|
162
152
|
.d2l-card-badge {
|
163
153
|
line-height: 0;
|
@@ -237,6 +227,7 @@ class Card extends FocusMixin(RtlMixin(LitElement)) {
|
|
237
227
|
this.subtle = false;
|
238
228
|
this._active = false;
|
239
229
|
this._dropdownActionOpen = false;
|
230
|
+
this._focusOnFirstRender = false;
|
240
231
|
this._footerHidden = true;
|
241
232
|
this._hover = false;
|
242
233
|
this._tooltipShowing = false;
|
@@ -244,16 +235,17 @@ class Card extends FocusMixin(RtlMixin(LitElement)) {
|
|
244
235
|
this._onFooterResize = this._onFooterResize.bind(this);
|
245
236
|
}
|
246
237
|
|
247
|
-
static get focusElementSelector() {
|
248
|
-
return 'a';
|
249
|
-
}
|
250
|
-
|
251
238
|
firstUpdated(changedProperties) {
|
252
239
|
super.firstUpdated(changedProperties);
|
253
240
|
const badgeObserver = new ResizeObserver(this._onBadgeResize);
|
254
241
|
badgeObserver.observe(this.shadowRoot.querySelector('.d2l-card-badge'));
|
255
242
|
const footerObserver = new ResizeObserver(this._onFooterResize);
|
256
243
|
footerObserver.observe(this.shadowRoot.querySelector('.d2l-card-footer'));
|
244
|
+
|
245
|
+
if (this._focusOnFirstRender) {
|
246
|
+
this._focusOnFirstRender = false;
|
247
|
+
this.focus();
|
248
|
+
}
|
257
249
|
}
|
258
250
|
|
259
251
|
render() {
|
@@ -308,6 +300,17 @@ class Card extends FocusMixin(RtlMixin(LitElement)) {
|
|
308
300
|
`;
|
309
301
|
}
|
310
302
|
|
303
|
+
focus() {
|
304
|
+
if (!this.hasUpdated) {
|
305
|
+
this._focusOnFirstRender = true;
|
306
|
+
return;
|
307
|
+
}
|
308
|
+
|
309
|
+
const elem = this.shadowRoot.querySelector('a[href]');
|
310
|
+
if (elem) elem.focus();
|
311
|
+
else super.focus();
|
312
|
+
}
|
313
|
+
|
311
314
|
_onBadgeResize(entries) {
|
312
315
|
if (!entries || entries.length === 0) return;
|
313
316
|
const entry = entries[0];
|
@@ -129,8 +129,8 @@ An element that displays the corresponding tab panel when selected.
|
|
129
129
|
|
130
130
|
| Slot | Description |
|
131
131
|
|--|--|
|
132
|
-
| `before` | Slot for content to be displayed before the tab text |
|
133
|
-
| `after` | Slot for content to be displayed after the tab text |
|
132
|
+
| `before` | Slot for content to be displayed before the tab text. Supports `d2l-icon`, `d2l-icon-custom`, and `d2l-count-badge`. Only the *first* item assigned to this slot will be shown. |
|
133
|
+
| `after` | Slot for content to be displayed after the tab text. Supports `d2l-icon`, `d2l-icon-custom`, and `d2l-count-badge`. Only the *last* item assigned to this slot will be shown. |
|
134
134
|
|
135
135
|
### Events
|
136
136
|
- `d2l-tab-content-change`: Dispatched when the text attribute is changed. Triggers virtual scrolling calculations in parent `d2l-tabs`.
|
package/components/tabs/tab.js
CHANGED
@@ -6,8 +6,8 @@ import { TabMixin } from './tab-mixin.js';
|
|
6
6
|
/**
|
7
7
|
* @attr {string} id - REQUIRED: Unique identifier for the tab
|
8
8
|
* @fires d2l-tab-content-change - Dispatched when the text attribute is changed. Triggers virtual scrolling calculations in parent d2l-tabs.
|
9
|
-
* @slot before - Slot for content to be displayed before the tab text
|
10
|
-
* @slot after - Slot for content to be displayed after the tab text
|
9
|
+
* @slot before - Slot for content to be displayed before the tab text. Supports `d2l-icon`, `d2l-icon-custom`, and `d2l-count-badge`. Only the *first* item assigned to this slot will be shown.
|
10
|
+
* @slot after - Slot for content to be displayed after the tab text. Supports `d2l-icon`, `d2l-icon-custom`, and `d2l-count-badge`. Only the *last* item assigned to this slot will be shown.
|
11
11
|
*/
|
12
12
|
class Tab extends TabMixin(LitElement) {
|
13
13
|
|
@@ -59,6 +59,16 @@ class Tab extends TabMixin(LitElement) {
|
|
59
59
|
:host([skeleton]) .d2l-tab-content.d2l-skeletize::before {
|
60
60
|
inset-block: 0.15rem;
|
61
61
|
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Only allow d2l-icon, d2l-count-badge, and d2l-icon-custom in the before/after slots
|
65
|
+
* Only show the first item in the before slot and the last item in the after slot
|
66
|
+
*/
|
67
|
+
::slotted([slot]:not(d2l-icon):not(d2l-count-badge):not(d2l-icon-custom)),
|
68
|
+
::slotted([slot="before"]:not(:first-child)),
|
69
|
+
::slotted([slot="after"]:not(:last-child)) {
|
70
|
+
display: none;
|
71
|
+
}
|
62
72
|
`];
|
63
73
|
|
64
74
|
super.styles && styles.unshift(super.styles);
|
package/custom-elements.json
CHANGED
@@ -13799,11 +13799,11 @@
|
|
13799
13799
|
"slots": [
|
13800
13800
|
{
|
13801
13801
|
"name": "before",
|
13802
|
-
"description": "Slot for content to be displayed before the tab text"
|
13802
|
+
"description": "Slot for content to be displayed before the tab text. Supports `d2l-icon`, `d2l-icon-custom`, and `d2l-count-badge`. Only the *first* item assigned to this slot will be shown."
|
13803
13803
|
},
|
13804
13804
|
{
|
13805
13805
|
"name": "after",
|
13806
|
-
"description": "Slot for content to be displayed after the tab text"
|
13806
|
+
"description": "Slot for content to be displayed after the tab text. Supports `d2l-icon`, `d2l-icon-custom`, and `d2l-count-badge`. Only the *last* item assigned to this slot will be shown."
|
13807
13807
|
}
|
13808
13808
|
]
|
13809
13809
|
},
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.138.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",
|