@spectrum-web-components/tabs 0.8.14 → 0.8.15-devmode.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/package.json +40 -13
- package/sp-tab-panel.dev.js +3 -0
- package/sp-tab-panel.dev.js.map +7 -0
- package/sp-tab-panel.js +3 -14
- package/sp-tab-panel.js.map +7 -1
- package/sp-tab.dev.js +3 -0
- package/sp-tab.dev.js.map +7 -0
- package/sp-tab.js +3 -14
- package/sp-tab.js.map +7 -1
- package/sp-tabs.dev.js +3 -0
- package/sp-tabs.dev.js.map +7 -0
- package/sp-tabs.js +3 -14
- package/sp-tabs.js.map +7 -1
- package/src/Tab.dev.js +101 -0
- package/src/Tab.dev.js.map +7 -0
- package/src/Tab.js +92 -103
- package/src/Tab.js.map +7 -1
- package/src/TabPanel.dev.js +58 -0
- package/src/TabPanel.dev.js.map +7 -0
- package/src/TabPanel.js +51 -57
- package/src/TabPanel.js.map +7 -1
- package/src/Tabs.dev.js +304 -0
- package/src/Tabs.dev.js.map +7 -0
- package/src/Tabs.js +275 -302
- package/src/Tabs.js.map +7 -1
- package/src/index.dev.js +4 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +4 -15
- package/src/index.js.map +7 -1
- package/src/spectrum-tab.css.dev.js +40 -0
- package/src/spectrum-tab.css.dev.js.map +7 -0
- package/src/spectrum-tab.css.js +3 -14
- package/src/spectrum-tab.css.js.map +7 -1
- package/src/spectrum-tabs.css.dev.js +392 -0
- package/src/spectrum-tabs.css.dev.js.map +7 -0
- package/src/spectrum-tabs.css.js +3 -14
- package/src/spectrum-tabs.css.js.map +7 -1
- package/src/tab-panel.css.dev.js +6 -0
- package/src/tab-panel.css.dev.js.map +7 -0
- package/src/tab-panel.css.js +3 -14
- package/src/tab-panel.css.js.map +7 -1
- package/src/tab.css.dev.js +54 -0
- package/src/tab.css.dev.js.map +7 -0
- package/src/tab.css.js +3 -14
- package/src/tab.css.js.map +7 -1
- package/src/tabs.css.dev.js +406 -0
- package/src/tabs.css.dev.js.map +7 -0
- package/src/tabs.css.js +3 -14
- package/src/tabs.css.js.map +7 -1
- package/stories/tabs-horizontal-sizes.stories.js +53 -64
- package/stories/tabs-horizontal-sizes.stories.js.map +7 -1
- package/stories/tabs-vertical-right-sizes.stories.js +50 -61
- package/stories/tabs-vertical-right-sizes.stories.js.map +7 -1
- package/stories/tabs-vertical-sizes.stories.js +50 -61
- package/stories/tabs-vertical-sizes.stories.js.map +7 -1
- package/stories/tabs.stories.js +79 -75
- package/stories/tabs.stories.js.map +7 -1
- package/test/benchmark/basic-test.js +6 -17
- package/test/benchmark/basic-test.js.map +7 -1
- package/test/tab.test.js +21 -34
- package/test/tab.test.js.map +7 -1
- package/test/tabs-horizontal-sizes.test-vrt.js +4 -15
- package/test/tabs-horizontal-sizes.test-vrt.js.map +7 -1
- package/test/tabs-vertical-right-sizes.test-vrt.js +4 -15
- package/test/tabs-vertical-right-sizes.test-vrt.js.map +7 -1
- package/test/tabs-vertical-sizes.test-vrt.js +4 -15
- package/test/tabs-vertical-sizes.test-vrt.js.map +7 -1
- package/test/tabs.test-vrt.js +4 -15
- package/test/tabs.test-vrt.js.map +7 -1
- package/test/tabs.test.js +375 -383
- package/test/tabs.test.js.map +7 -1
package/src/Tabs.js
CHANGED
|
@@ -1,208 +1,184 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* @attr {Boolean} quiet - The tabs border is a lot smaller
|
|
26
|
-
* @attr {Boolean} compact - The collection of tabs take up less space
|
|
27
|
-
*
|
|
28
|
-
* @fires change - The selected Tab child has changed.
|
|
29
|
-
*/
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html,
|
|
14
|
+
SizedMixin
|
|
15
|
+
} from "@spectrum-web-components/base";
|
|
16
|
+
import {
|
|
17
|
+
property,
|
|
18
|
+
query
|
|
19
|
+
} from "@spectrum-web-components/base/src/decorators.js";
|
|
20
|
+
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
21
|
+
import { Focusable } from "@spectrum-web-components/shared";
|
|
22
|
+
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
23
|
+
import tabStyles from "./tabs.css.js";
|
|
24
|
+
const noSelectionStyle = "transform: translateX(0px) scaleX(0) scaleY(0)";
|
|
30
25
|
export class Tabs extends SizedMixin(Focusable) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this._tabs = [];
|
|
49
|
-
this.rovingTabindexController = new RovingTabindexController(this, {
|
|
50
|
-
focusInIndex: (elements) => {
|
|
51
|
-
let focusInIndex = 0;
|
|
52
|
-
const firstFocusableElement = elements.find((el, index) => {
|
|
53
|
-
const focusInElement = this.selected
|
|
54
|
-
? !el.disabled && el.value === this.selected
|
|
55
|
-
: !el.disabled;
|
|
56
|
-
focusInIndex = index;
|
|
57
|
-
return focusInElement;
|
|
58
|
-
});
|
|
59
|
-
return firstFocusableElement ? focusInIndex : -1;
|
|
60
|
-
},
|
|
61
|
-
direction: () => this.direction === 'horizontal' ? 'horizontal' : 'vertical',
|
|
62
|
-
elementEnterAction: (el) => {
|
|
63
|
-
if (!this.auto)
|
|
64
|
-
return;
|
|
65
|
-
this.shouldAnimate = true;
|
|
66
|
-
this.selectTarget(el);
|
|
67
|
-
},
|
|
68
|
-
elements: () => this.tabs,
|
|
69
|
-
isFocusableElement: (el) => !el.disabled,
|
|
70
|
-
listenerScope: () => this.tabList,
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.auto = false;
|
|
29
|
+
this.direction = "horizontal";
|
|
30
|
+
this.emphasized = false;
|
|
31
|
+
this.label = "";
|
|
32
|
+
this.selectionIndicatorStyle = noSelectionStyle;
|
|
33
|
+
this.shouldAnimate = false;
|
|
34
|
+
this._selected = "";
|
|
35
|
+
this._tabs = [];
|
|
36
|
+
this.rovingTabindexController = new RovingTabindexController(this, {
|
|
37
|
+
focusInIndex: (elements) => {
|
|
38
|
+
let focusInIndex = 0;
|
|
39
|
+
const firstFocusableElement = elements.find((el, index) => {
|
|
40
|
+
const focusInElement = this.selected ? !el.disabled && el.value === this.selected : !el.disabled;
|
|
41
|
+
focusInIndex = index;
|
|
42
|
+
return focusInElement;
|
|
71
43
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const currentChecked = this.tabs.find((el) => el.value === this.selected);
|
|
103
|
-
if (currentChecked) {
|
|
104
|
-
currentChecked.selected = true;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
this.selected = '';
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
const firstTab = this.tabs[0];
|
|
112
|
-
if (firstTab) {
|
|
113
|
-
firstTab.setAttribute('tabindex', '0');
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
this.updateSelectionIndicator();
|
|
117
|
-
this.tabChangeResolver();
|
|
118
|
-
};
|
|
119
|
-
this.updateSelectionIndicator = async () => {
|
|
120
|
-
const selectedElement = this.tabs.find((el) => el.selected);
|
|
121
|
-
if (!selectedElement) {
|
|
122
|
-
this.selectionIndicatorStyle = noSelectionStyle;
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
await Promise.all([
|
|
126
|
-
selectedElement.updateComplete,
|
|
127
|
-
document.fonts ? document.fonts.ready : Promise.resolve(),
|
|
128
|
-
]);
|
|
129
|
-
const tabBoundingClientRect = selectedElement.getBoundingClientRect();
|
|
130
|
-
const parentBoundingClientRect = this.getBoundingClientRect();
|
|
131
|
-
if (this.direction === 'horizontal') {
|
|
132
|
-
const width = tabBoundingClientRect.width;
|
|
133
|
-
const offset = this.dir === 'ltr'
|
|
134
|
-
? tabBoundingClientRect.left - parentBoundingClientRect.left
|
|
135
|
-
: tabBoundingClientRect.right -
|
|
136
|
-
parentBoundingClientRect.right;
|
|
137
|
-
this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${this.dir === 'ltr' ? width : -1 * width});`;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
const height = tabBoundingClientRect.height;
|
|
141
|
-
const offset = tabBoundingClientRect.top - parentBoundingClientRect.top;
|
|
142
|
-
this.selectionIndicatorStyle = `transform: translateY(${offset}px) scaleY(${height});`;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
this.tabChangePromise = Promise.resolve();
|
|
146
|
-
this.tabChangeResolver = function () {
|
|
147
|
-
return;
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
static get styles() {
|
|
151
|
-
return [tabStyles];
|
|
152
|
-
}
|
|
153
|
-
get selected() {
|
|
154
|
-
return this._selected;
|
|
155
|
-
}
|
|
156
|
-
set selected(value) {
|
|
157
|
-
const oldValue = this.selected;
|
|
158
|
-
if (value === oldValue) {
|
|
159
|
-
return;
|
|
44
|
+
return firstFocusableElement ? focusInIndex : -1;
|
|
45
|
+
},
|
|
46
|
+
direction: () => this.direction === "horizontal" ? "horizontal" : "vertical",
|
|
47
|
+
elementEnterAction: (el) => {
|
|
48
|
+
if (!this.auto)
|
|
49
|
+
return;
|
|
50
|
+
this.shouldAnimate = true;
|
|
51
|
+
this.selectTarget(el);
|
|
52
|
+
},
|
|
53
|
+
elements: () => this.tabs,
|
|
54
|
+
isFocusableElement: (el) => !el.disabled,
|
|
55
|
+
listenerScope: () => this.tabList
|
|
56
|
+
});
|
|
57
|
+
this.onClick = (event) => {
|
|
58
|
+
if (this.disabled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const target = event.composedPath().find((el) => el.parentElement === this);
|
|
62
|
+
if (!target || target.disabled) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.shouldAnimate = true;
|
|
66
|
+
this.selectTarget(target);
|
|
67
|
+
};
|
|
68
|
+
this.onKeyDown = (event) => {
|
|
69
|
+
if (event.code === "Enter" || event.code === "Space") {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
const target = event.target;
|
|
72
|
+
if (target) {
|
|
73
|
+
this.selectTarget(target);
|
|
160
74
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
this.updateCheckedState = () => {
|
|
78
|
+
if (!this.tabs.length) {
|
|
79
|
+
this.tabs = [...this.querySelectorAll('[role="tab"]')];
|
|
80
|
+
}
|
|
81
|
+
this.tabs.forEach((element) => {
|
|
82
|
+
element.removeAttribute("selected");
|
|
83
|
+
});
|
|
84
|
+
if (this.selected) {
|
|
85
|
+
const currentChecked = this.tabs.find((el) => el.value === this.selected);
|
|
86
|
+
if (currentChecked) {
|
|
87
|
+
currentChecked.selected = true;
|
|
88
|
+
} else {
|
|
89
|
+
this.selected = "";
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
const firstTab = this.tabs[0];
|
|
93
|
+
if (firstTab) {
|
|
94
|
+
firstTab.setAttribute("tabindex", "0");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this.updateSelectionIndicator();
|
|
98
|
+
this.tabChangeResolver();
|
|
99
|
+
};
|
|
100
|
+
this.updateSelectionIndicator = async () => {
|
|
101
|
+
const selectedElement = this.tabs.find((el) => el.selected);
|
|
102
|
+
if (!selectedElement) {
|
|
103
|
+
this.selectionIndicatorStyle = noSelectionStyle;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
await Promise.all([
|
|
107
|
+
selectedElement.updateComplete,
|
|
108
|
+
document.fonts ? document.fonts.ready : Promise.resolve()
|
|
109
|
+
]);
|
|
110
|
+
const tabBoundingClientRect = selectedElement.getBoundingClientRect();
|
|
111
|
+
const parentBoundingClientRect = this.getBoundingClientRect();
|
|
112
|
+
if (this.direction === "horizontal") {
|
|
113
|
+
const width = tabBoundingClientRect.width;
|
|
114
|
+
const offset = this.dir === "ltr" ? tabBoundingClientRect.left - parentBoundingClientRect.left : tabBoundingClientRect.right - parentBoundingClientRect.right;
|
|
115
|
+
this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${this.dir === "ltr" ? width : -1 * width});`;
|
|
116
|
+
} else {
|
|
117
|
+
const height = tabBoundingClientRect.height;
|
|
118
|
+
const offset = tabBoundingClientRect.top - parentBoundingClientRect.top;
|
|
119
|
+
this.selectionIndicatorStyle = `transform: translateY(${offset}px) scaleY(${height});`;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
this.tabChangePromise = Promise.resolve();
|
|
123
|
+
this.tabChangeResolver = function() {
|
|
124
|
+
return;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
static get styles() {
|
|
128
|
+
return [tabStyles];
|
|
129
|
+
}
|
|
130
|
+
get selected() {
|
|
131
|
+
return this._selected;
|
|
132
|
+
}
|
|
133
|
+
set selected(value) {
|
|
134
|
+
const oldValue = this.selected;
|
|
135
|
+
if (value === oldValue) {
|
|
136
|
+
return;
|
|
201
137
|
}
|
|
202
|
-
|
|
203
|
-
|
|
138
|
+
this._selected = value;
|
|
139
|
+
this.shouldUpdateCheckedState();
|
|
140
|
+
this.requestUpdate("selected", oldValue);
|
|
141
|
+
}
|
|
142
|
+
set tabs(tabs) {
|
|
143
|
+
if (tabs === this.tabs)
|
|
144
|
+
return;
|
|
145
|
+
this._tabs = tabs;
|
|
146
|
+
this.rovingTabindexController.clearElementCache();
|
|
147
|
+
}
|
|
148
|
+
get tabs() {
|
|
149
|
+
return this._tabs;
|
|
150
|
+
}
|
|
151
|
+
get focusElement() {
|
|
152
|
+
return this.rovingTabindexController.focusInElement || this;
|
|
153
|
+
}
|
|
154
|
+
manageAutoFocus() {
|
|
155
|
+
const tabs = [...this.children];
|
|
156
|
+
const tabUpdateCompletes = tabs.map((tab) => {
|
|
157
|
+
if (typeof tab.updateComplete !== "undefined") {
|
|
158
|
+
return tab.updateComplete;
|
|
159
|
+
}
|
|
160
|
+
return Promise.resolve(true);
|
|
161
|
+
});
|
|
162
|
+
Promise.all(tabUpdateCompletes).then(() => super.manageAutoFocus());
|
|
163
|
+
}
|
|
164
|
+
managePanels({
|
|
165
|
+
target
|
|
166
|
+
}) {
|
|
167
|
+
const panels = target.assignedElements();
|
|
168
|
+
panels.map((panel) => {
|
|
169
|
+
const { value, id } = panel;
|
|
170
|
+
const tab = this.querySelector(`[role="tab"][value="${value}"]`);
|
|
171
|
+
if (tab) {
|
|
172
|
+
tab.setAttribute("aria-controls", id);
|
|
173
|
+
panel.setAttribute("aria-labelledby", tab.id);
|
|
174
|
+
}
|
|
175
|
+
panel.selected = value === this.selected;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
render() {
|
|
179
|
+
return html`
|
|
204
180
|
<div
|
|
205
|
-
aria-label=${ifDefined(this.label ? this.label :
|
|
181
|
+
aria-label=${ifDefined(this.label ? this.label : void 0)}
|
|
206
182
|
@click=${this.onClick}
|
|
207
183
|
@keydown=${this.onKeyDown}
|
|
208
184
|
@sp-tab-contentchange=${this.updateSelectionIndicator}
|
|
@@ -212,120 +188,117 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
212
188
|
<slot @slotchange=${this.onSlotChange}></slot>
|
|
213
189
|
<div
|
|
214
190
|
id="selection-indicator"
|
|
215
|
-
class=${ifDefined(this.shouldAnimate ?
|
|
191
|
+
class=${ifDefined(this.shouldAnimate ? void 0 : "first-position")}
|
|
216
192
|
style=${this.selectionIndicatorStyle}
|
|
217
193
|
role="presentation"
|
|
218
194
|
></div>
|
|
219
195
|
</div>
|
|
220
196
|
<slot name="tab-panel" @slotchange=${this.managePanels}></slot>
|
|
221
197
|
`;
|
|
198
|
+
}
|
|
199
|
+
willUpdate(changes) {
|
|
200
|
+
if (!this.hasUpdated) {
|
|
201
|
+
const selectedChild = this.querySelector(":scope > [selected]");
|
|
202
|
+
if (selectedChild) {
|
|
203
|
+
this.selectTarget(selectedChild);
|
|
204
|
+
}
|
|
222
205
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const previous = this.querySelector(`[role="tabpanel"][value="${changes.get('selected')}"]`);
|
|
234
|
-
if (previous)
|
|
235
|
-
previous.selected = false;
|
|
236
|
-
}
|
|
237
|
-
const next = this.querySelector(`[role="tabpanel"][value="${this.selected}"]`);
|
|
238
|
-
if (next)
|
|
239
|
-
next.selected = true;
|
|
240
|
-
}
|
|
241
|
-
if (changes.has('direction')) {
|
|
242
|
-
if (this.direction === 'horizontal') {
|
|
243
|
-
this.removeAttribute('aria-orientation');
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
this.setAttribute('aria-orientation', 'vertical');
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (changes.has('dir')) {
|
|
250
|
-
this.updateSelectionIndicator();
|
|
251
|
-
}
|
|
252
|
-
if (changes.has('disabled')) {
|
|
253
|
-
if (this.disabled) {
|
|
254
|
-
this.setAttribute('aria-disabled', 'true');
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
this.removeAttribute('aria-disabled');
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (!this.shouldAnimate &&
|
|
261
|
-
typeof changes.get('shouldAnimate') !== 'undefined') {
|
|
262
|
-
this.shouldAnimate = true;
|
|
263
|
-
}
|
|
206
|
+
super.updated(changes);
|
|
207
|
+
if (changes.has("selected")) {
|
|
208
|
+
if (changes.get("selected")) {
|
|
209
|
+
const previous = this.querySelector(`[role="tabpanel"][value="${changes.get("selected")}"]`);
|
|
210
|
+
if (previous)
|
|
211
|
+
previous.selected = false;
|
|
212
|
+
}
|
|
213
|
+
const next = this.querySelector(`[role="tabpanel"][value="${this.selected}"]`);
|
|
214
|
+
if (next)
|
|
215
|
+
next.selected = true;
|
|
264
216
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
cancelable: true,
|
|
272
|
-
}));
|
|
273
|
-
if (!applyDefault) {
|
|
274
|
-
this.selected = selected;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
217
|
+
if (changes.has("direction")) {
|
|
218
|
+
if (this.direction === "horizontal") {
|
|
219
|
+
this.removeAttribute("aria-orientation");
|
|
220
|
+
} else {
|
|
221
|
+
this.setAttribute("aria-orientation", "vertical");
|
|
222
|
+
}
|
|
277
223
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
this.shouldUpdateCheckedState();
|
|
224
|
+
if (changes.has("dir")) {
|
|
225
|
+
this.updateSelectionIndicator();
|
|
281
226
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
this.
|
|
285
|
-
|
|
227
|
+
if (changes.has("disabled")) {
|
|
228
|
+
if (this.disabled) {
|
|
229
|
+
this.setAttribute("aria-disabled", "true");
|
|
230
|
+
} else {
|
|
231
|
+
this.removeAttribute("aria-disabled");
|
|
232
|
+
}
|
|
286
233
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
await this.tabChangePromise;
|
|
290
|
-
return complete;
|
|
234
|
+
if (!this.shouldAnimate && typeof changes.get("shouldAnimate") !== "undefined") {
|
|
235
|
+
this.shouldAnimate = true;
|
|
291
236
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
237
|
+
}
|
|
238
|
+
selectTarget(target) {
|
|
239
|
+
const value = target.getAttribute("value");
|
|
240
|
+
if (value) {
|
|
241
|
+
const selected = this.selected;
|
|
242
|
+
this.selected = value;
|
|
243
|
+
const applyDefault = this.dispatchEvent(new Event("change", {
|
|
244
|
+
cancelable: true
|
|
245
|
+
}));
|
|
246
|
+
if (!applyDefault) {
|
|
247
|
+
this.selected = selected;
|
|
248
|
+
}
|
|
298
249
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
250
|
+
}
|
|
251
|
+
onSlotChange() {
|
|
252
|
+
this.tabs = [...this.querySelectorAll('[role="tab"]')];
|
|
253
|
+
this.shouldUpdateCheckedState();
|
|
254
|
+
}
|
|
255
|
+
shouldUpdateCheckedState() {
|
|
256
|
+
this.tabChangeResolver();
|
|
257
|
+
this.tabChangePromise = new Promise((res) => this.tabChangeResolver = res);
|
|
258
|
+
setTimeout(this.updateCheckedState);
|
|
259
|
+
}
|
|
260
|
+
async getUpdateComplete() {
|
|
261
|
+
const complete = await super.getUpdateComplete();
|
|
262
|
+
await this.tabChangePromise;
|
|
263
|
+
return complete;
|
|
264
|
+
}
|
|
265
|
+
connectedCallback() {
|
|
266
|
+
super.connectedCallback();
|
|
267
|
+
window.addEventListener("resize", this.updateSelectionIndicator);
|
|
268
|
+
if ("fonts" in document) {
|
|
269
|
+
document.fonts.addEventListener("loadingdone", this.updateSelectionIndicator);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
disconnectedCallback() {
|
|
273
|
+
window.removeEventListener("resize", this.updateSelectionIndicator);
|
|
274
|
+
if ("fonts" in document) {
|
|
275
|
+
document.fonts.removeEventListener("loadingdone", this.updateSelectionIndicator);
|
|
305
276
|
}
|
|
277
|
+
super.disconnectedCallback();
|
|
278
|
+
}
|
|
306
279
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
], Tabs.prototype, "auto",
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
], Tabs.prototype, "direction",
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
], Tabs.prototype, "emphasized",
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
], Tabs.prototype, "label",
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
], Tabs.prototype, "selectionIndicatorStyle",
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
], Tabs.prototype, "shouldAnimate",
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
], Tabs.prototype, "tabList",
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
], Tabs.prototype, "selected",
|
|
331
|
-
//# sourceMappingURL=Tabs.js.map
|
|
280
|
+
__decorateClass([
|
|
281
|
+
property({ type: Boolean })
|
|
282
|
+
], Tabs.prototype, "auto", 2);
|
|
283
|
+
__decorateClass([
|
|
284
|
+
property({ reflect: true })
|
|
285
|
+
], Tabs.prototype, "direction", 2);
|
|
286
|
+
__decorateClass([
|
|
287
|
+
property({ type: Boolean, reflect: true })
|
|
288
|
+
], Tabs.prototype, "emphasized", 2);
|
|
289
|
+
__decorateClass([
|
|
290
|
+
property()
|
|
291
|
+
], Tabs.prototype, "label", 2);
|
|
292
|
+
__decorateClass([
|
|
293
|
+
property({ attribute: false })
|
|
294
|
+
], Tabs.prototype, "selectionIndicatorStyle", 2);
|
|
295
|
+
__decorateClass([
|
|
296
|
+
property({ attribute: false })
|
|
297
|
+
], Tabs.prototype, "shouldAnimate", 2);
|
|
298
|
+
__decorateClass([
|
|
299
|
+
query("#list")
|
|
300
|
+
], Tabs.prototype, "tabList", 2);
|
|
301
|
+
__decorateClass([
|
|
302
|
+
property({ reflect: true })
|
|
303
|
+
], Tabs.prototype, "selected", 1);
|
|
304
|
+
//# sourceMappingURL=Tabs.js.map
|