@brightspace-ui/core 3.93.2 → 3.94.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.
@@ -40,12 +40,12 @@
|
|
40
40
|
|
41
41
|
<d2l-demo-snippet>
|
42
42
|
<template>
|
43
|
-
<d2l-tabs>
|
43
|
+
<d2l-tabs text="Courses">
|
44
44
|
<d2l-tab id="all" text="All" slot="tabs"></d2l-tab>
|
45
45
|
<d2l-tab id="biology" text="Biology" slot="tabs" selected></d2l-tab>
|
46
46
|
<d2l-tab id="chemistry" text="Chemistry" slot="tabs"></d2l-tab>
|
47
|
-
<d2l-tab-panel labelled-by="all" slot="panels">Tab content for All</d2l-tab-panel>
|
48
|
-
<d2l-tab-panel labelled-by="biology" slot="panels">Tab content for Biology</d2l-tab-panel>
|
47
|
+
<d2l-tab-panel labelled-by="all" slot="panels" id="all-panel">Tab content for All</d2l-tab-panel>
|
48
|
+
<d2l-tab-panel labelled-by="biology" slot="panels" id="biology-panel">Tab content for Biology</d2l-tab-panel>
|
49
49
|
<d2l-tab-panel labelled-by="chemistry" slot="panels">Tab content for Chemistry</d2l-tab-panel>
|
50
50
|
</d2l-tabs>
|
51
51
|
</template>
|
package/components/tabs/tabs.js
CHANGED
@@ -8,6 +8,7 @@ import { ArrowKeysMixin } from '../../mixins/arrow-keys/arrow-keys-mixin.js';
|
|
8
8
|
import { bodyCompactStyles } from '../typography/styles.js';
|
9
9
|
import { classMap } from 'lit/directives/class-map.js';
|
10
10
|
import { getFocusPseudoClass } from '../../helpers/focus.js';
|
11
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
11
12
|
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
|
12
13
|
import { repeat } from 'lit/directives/repeat.js';
|
13
14
|
import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
|
@@ -32,6 +33,11 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
32
33
|
* @type {number}
|
33
34
|
*/
|
34
35
|
maxToShow: { type: Number, attribute: 'max-to-show' },
|
36
|
+
/**
|
37
|
+
* REQUIRED: ACCESSIBILITY: Accessible text for the tablist
|
38
|
+
* @type {string}
|
39
|
+
*/
|
40
|
+
text: { type: String },
|
35
41
|
_allowScrollNext: { type: Boolean },
|
36
42
|
_allowScrollPrevious: { type: Boolean },
|
37
43
|
_defaultSlotBehavior: { state: true },
|
@@ -305,6 +311,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
305
311
|
<div class="d2l-tabs-container-list"
|
306
312
|
@d2l-tab-selected="${this._handleTabSelected}"
|
307
313
|
@focusout="${this._handleFocusOut}"
|
314
|
+
aria-label="${ifDefined(this.text)}"
|
308
315
|
role="tablist"
|
309
316
|
style="${styleMap(tabsContainerListStyles)}">
|
310
317
|
${repeat(this._tabInfos, (tabInfo) => tabInfo.id, (tabInfo) => html`
|
@@ -333,7 +340,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
333
340
|
@d2l-tab-panel-selected="${this._handlePanelSelected}"
|
334
341
|
@d2l-tab-panel-text-changed="${this._handlePanelTextChange}">
|
335
342
|
<slot @slotchange="${this._handleDefaultSlotChange}"></slot>
|
336
|
-
<slot name="panels"></slot>
|
343
|
+
<slot name="panels" @slotchange="${this._handlePanelsSlotChange}"></slot>
|
337
344
|
</div>
|
338
345
|
`;
|
339
346
|
}
|
@@ -630,6 +637,12 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
630
637
|
this.requestUpdate();
|
631
638
|
}
|
632
639
|
|
640
|
+
_handlePanelsSlotChange() {
|
641
|
+
if (this._defaultSlotBehavior) return;
|
642
|
+
|
643
|
+
this.#setAriaControls();
|
644
|
+
}
|
645
|
+
|
633
646
|
async _handlePanelTextChange(e) {
|
634
647
|
const tabInfo = this._getTabInfo(e.target.id);
|
635
648
|
// event could be from nested tabs
|
@@ -781,18 +794,13 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
781
794
|
if (selectedTab) {
|
782
795
|
this.#updateSelectedTab(selectedTab);
|
783
796
|
}
|
797
|
+
this.#setAriaControls();
|
784
798
|
|
785
799
|
await this.updateComplete;
|
786
800
|
|
787
801
|
if (!this._initialized && this._tabs.length > 0) {
|
788
802
|
this._initialized = true;
|
789
803
|
}
|
790
|
-
|
791
|
-
if (selectedTab) {
|
792
|
-
// set corresponding panel to selected
|
793
|
-
const selectedPanel = this._getPanel(selectedTab.id);
|
794
|
-
if (selectedPanel) selectedPanel.selected = true;
|
795
|
-
}
|
796
804
|
}
|
797
805
|
|
798
806
|
_isPositionInLeftScrollArea(position) {
|
@@ -997,6 +1005,21 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
997
1005
|
return document.documentElement.getAttribute('dir') === 'rtl';
|
998
1006
|
}
|
999
1007
|
|
1008
|
+
#setAriaControls() {
|
1009
|
+
// debounce so only runs once when tabs/panels slots changing
|
1010
|
+
if (this._updateAriaControlsRequested) return;
|
1011
|
+
|
1012
|
+
this._updateAriaControlsRequested = true;
|
1013
|
+
setTimeout(() => {
|
1014
|
+
this._tabs?.forEach((tab) => {
|
1015
|
+
const panel = this._getPanel(tab.id);
|
1016
|
+
if (!panel) return;
|
1017
|
+
tab.setAttribute('aria-controls', `${panel.id}`);
|
1018
|
+
});
|
1019
|
+
this._updateAriaControlsRequested = false;
|
1020
|
+
}, 0);
|
1021
|
+
}
|
1022
|
+
|
1000
1023
|
async #updateSelectedTab(selectedTab) {
|
1001
1024
|
const selectedPanel = this._getPanel(selectedTab.id);
|
1002
1025
|
selectedTab.tabIndex = 0;
|
package/custom-elements.json
CHANGED
@@ -12905,6 +12905,11 @@
|
|
12905
12905
|
"path": "./components/tabs/tabs.js",
|
12906
12906
|
"description": "A component for tabbed content. It supports the \"d2l-tab-panel\" component for the content, renders tabs responsively, and provides virtual scrolling for large tab lists.",
|
12907
12907
|
"attributes": [
|
12908
|
+
{
|
12909
|
+
"name": "text",
|
12910
|
+
"description": "REQUIRED: ACCESSIBILITY: Accessible text for the tablist",
|
12911
|
+
"type": "string"
|
12912
|
+
},
|
12908
12913
|
{
|
12909
12914
|
"name": "max-to-show",
|
12910
12915
|
"description": "Limit the number of tabs to initially display",
|
@@ -12918,6 +12923,12 @@
|
|
12918
12923
|
}
|
12919
12924
|
],
|
12920
12925
|
"properties": [
|
12926
|
+
{
|
12927
|
+
"name": "text",
|
12928
|
+
"attribute": "text",
|
12929
|
+
"description": "REQUIRED: ACCESSIBILITY: Accessible text for the tablist",
|
12930
|
+
"type": "string"
|
12931
|
+
},
|
12921
12932
|
{
|
12922
12933
|
"name": "maxToShow",
|
12923
12934
|
"attribute": "max-to-show",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.94.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",
|