@brightspace-ui/core 3.93.1 → 3.93.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.
@@ -42,7 +42,7 @@
|
|
42
42
|
<template>
|
43
43
|
<d2l-tabs>
|
44
44
|
<d2l-tab id="all" text="All" slot="tabs"></d2l-tab>
|
45
|
-
<d2l-tab id="biology" text="Biology" slot="tabs"></d2l-tab>
|
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
47
|
<d2l-tab-panel labelled-by="all" slot="panels">Tab content for All</d2l-tab-panel>
|
48
48
|
<d2l-tab-panel labelled-by="biology" slot="panels">Tab content for Biology</d2l-tab-panel>
|
@@ -13,7 +13,8 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
|
|
13
13
|
return {
|
14
14
|
selected: { type: Boolean, reflect: true },
|
15
15
|
// eslint-disable-next-line lit/no-native-attributes
|
16
|
-
role: { type: String, reflect: true }
|
16
|
+
role: { type: String, reflect: true },
|
17
|
+
tabIndex: { type: Number, reflect: true, attribute: 'tabindex' }
|
17
18
|
};
|
18
19
|
}
|
19
20
|
|
@@ -42,18 +43,18 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
|
|
42
43
|
margin-inline-start: 0;
|
43
44
|
width: calc(100% - 0.6rem);
|
44
45
|
}
|
45
|
-
:host([
|
46
|
+
:host([selected]:focus) {
|
46
47
|
text-decoration: none;
|
47
48
|
}
|
48
49
|
:host(:hover) {
|
49
50
|
color: var(--d2l-color-celestine);
|
50
51
|
cursor: pointer;
|
51
52
|
}
|
52
|
-
:host([
|
53
|
+
:host([selected]:hover) {
|
53
54
|
color: inherit;
|
54
55
|
cursor: default;
|
55
56
|
}
|
56
|
-
:host([
|
57
|
+
:host([selected]) .d2l-tab-selected-indicator {
|
57
58
|
display: block;
|
58
59
|
}
|
59
60
|
`];
|
@@ -66,6 +67,7 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
|
|
66
67
|
super();
|
67
68
|
this.role = 'tab';
|
68
69
|
this.selected = false;
|
70
|
+
this.tabIndex = -1;
|
69
71
|
}
|
70
72
|
|
71
73
|
connectedCallback() {
|
@@ -101,7 +103,7 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
|
|
101
103
|
super.update(changedProperties);
|
102
104
|
|
103
105
|
if (changedProperties.has('selected')) {
|
104
|
-
this.ariaSelected = this.selected
|
106
|
+
this.ariaSelected = `${this.selected}`;
|
105
107
|
if (this.selected) {
|
106
108
|
this.dispatchEvent(new CustomEvent(
|
107
109
|
'd2l-tab-selected', { bubbles: true, composed: true }
|
package/components/tabs/tabs.js
CHANGED
@@ -725,32 +725,14 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
725
725
|
|
726
726
|
}
|
727
727
|
|
728
|
-
|
728
|
+
_handleTabSelected(e) {
|
729
729
|
if (this._defaultSlotBehavior) {
|
730
730
|
this._handleTabSelectedDefaultSlotBehavior(e);
|
731
731
|
return;
|
732
732
|
}
|
733
733
|
|
734
734
|
const selectedTab = e.target;
|
735
|
-
|
736
|
-
selectedTab.tabIndex = 0;
|
737
|
-
|
738
|
-
await this.updateComplete;
|
739
|
-
|
740
|
-
selectedPanel.selected = true;
|
741
|
-
this._tabs.forEach((tab) => {
|
742
|
-
if (tab.id !== selectedTab.id) {
|
743
|
-
if (tab.selected) {
|
744
|
-
tab.selected = false;
|
745
|
-
const panel = this._getPanel(tab.id);
|
746
|
-
// panel may not exist if it's being removed
|
747
|
-
if (panel) panel.selected = false;
|
748
|
-
}
|
749
|
-
if (tab.tabIndex === 0) tab.tabIndex = -1;
|
750
|
-
}
|
751
|
-
});
|
752
|
-
|
753
|
-
this.requestUpdate();
|
735
|
+
this.#updateSelectedTab(selectedTab);
|
754
736
|
}
|
755
737
|
|
756
738
|
// remove after d2l-tab/d2l-tab-panel backport
|
@@ -791,13 +773,13 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
791
773
|
|
792
774
|
if (!this._initialized && this._tabs.length === 0) return;
|
793
775
|
|
794
|
-
let selectedTab;
|
795
|
-
if (
|
776
|
+
let selectedTab = this._tabs.find((tab) => tab.selected && tab.state !== 'removing');
|
777
|
+
if (!selectedTab) {
|
796
778
|
selectedTab = this._tabs.find((tab) => tab.state !== 'removing');
|
797
|
-
if (selectedTab)
|
798
|
-
|
799
|
-
|
800
|
-
|
779
|
+
if (selectedTab) selectedTab.selected = true;
|
780
|
+
}
|
781
|
+
if (selectedTab) {
|
782
|
+
this.#updateSelectedTab(selectedTab);
|
801
783
|
}
|
802
784
|
|
803
785
|
await this.updateComplete;
|
@@ -1015,6 +997,26 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
1015
997
|
return document.documentElement.getAttribute('dir') === 'rtl';
|
1016
998
|
}
|
1017
999
|
|
1000
|
+
async #updateSelectedTab(selectedTab) {
|
1001
|
+
const selectedPanel = this._getPanel(selectedTab.id);
|
1002
|
+
selectedTab.tabIndex = 0;
|
1003
|
+
|
1004
|
+
await this.updateComplete;
|
1005
|
+
|
1006
|
+
selectedPanel.selected = true;
|
1007
|
+
this._tabs.forEach((tab) => {
|
1008
|
+
if (tab.id !== selectedTab.id) {
|
1009
|
+
if (tab.selected) {
|
1010
|
+
tab.selected = false;
|
1011
|
+
const panel = this._getPanel(tab.id);
|
1012
|
+
// panel may not exist if it's being removed
|
1013
|
+
if (panel) panel.selected = false;
|
1014
|
+
}
|
1015
|
+
if (tab.tabIndex === 0) tab.tabIndex = -1;
|
1016
|
+
}
|
1017
|
+
});
|
1018
|
+
}
|
1019
|
+
|
1018
1020
|
}
|
1019
1021
|
|
1020
1022
|
customElements.define('d2l-tabs', Tabs);
|
package/custom-elements.json
CHANGED
@@ -12848,6 +12848,11 @@
|
|
12848
12848
|
"type": "boolean",
|
12849
12849
|
"default": "false"
|
12850
12850
|
},
|
12851
|
+
{
|
12852
|
+
"name": "tabindex",
|
12853
|
+
"type": "number",
|
12854
|
+
"default": "-1"
|
12855
|
+
},
|
12851
12856
|
{
|
12852
12857
|
"name": "skeleton",
|
12853
12858
|
"description": "Render the component as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton).",
|
@@ -12873,6 +12878,12 @@
|
|
12873
12878
|
"type": "boolean",
|
12874
12879
|
"default": "false"
|
12875
12880
|
},
|
12881
|
+
{
|
12882
|
+
"name": "tabIndex",
|
12883
|
+
"attribute": "tabindex",
|
12884
|
+
"type": "number",
|
12885
|
+
"default": "-1"
|
12886
|
+
},
|
12876
12887
|
{
|
12877
12888
|
"name": "skeleton",
|
12878
12889
|
"attribute": "skeleton",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.93.
|
3
|
+
"version": "3.93.2",
|
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",
|