@spectrum-web-components/tabs 0.8.13 → 0.8.15-devmode.7

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.
Files changed (71) hide show
  1. package/package.json +41 -14
  2. package/sp-tab-panel.dev.js +3 -0
  3. package/sp-tab-panel.dev.js.map +7 -0
  4. package/sp-tab-panel.js +3 -14
  5. package/sp-tab-panel.js.map +7 -1
  6. package/sp-tab.dev.js +3 -0
  7. package/sp-tab.dev.js.map +7 -0
  8. package/sp-tab.js +3 -14
  9. package/sp-tab.js.map +7 -1
  10. package/sp-tabs.dev.js +3 -0
  11. package/sp-tabs.dev.js.map +7 -0
  12. package/sp-tabs.js +3 -14
  13. package/sp-tabs.js.map +7 -1
  14. package/src/Tab.dev.js +101 -0
  15. package/src/Tab.dev.js.map +7 -0
  16. package/src/Tab.js +92 -103
  17. package/src/Tab.js.map +7 -1
  18. package/src/TabPanel.dev.js +58 -0
  19. package/src/TabPanel.dev.js.map +7 -0
  20. package/src/TabPanel.js +51 -57
  21. package/src/TabPanel.js.map +7 -1
  22. package/src/Tabs.dev.js +304 -0
  23. package/src/Tabs.dev.js.map +7 -0
  24. package/src/Tabs.js +275 -302
  25. package/src/Tabs.js.map +7 -1
  26. package/src/index.dev.js +4 -0
  27. package/src/index.dev.js.map +7 -0
  28. package/src/index.js +4 -15
  29. package/src/index.js.map +7 -1
  30. package/src/spectrum-tab.css.dev.js +40 -0
  31. package/src/spectrum-tab.css.dev.js.map +7 -0
  32. package/src/spectrum-tab.css.js +3 -14
  33. package/src/spectrum-tab.css.js.map +7 -1
  34. package/src/spectrum-tabs.css.dev.js +392 -0
  35. package/src/spectrum-tabs.css.dev.js.map +7 -0
  36. package/src/spectrum-tabs.css.js +3 -14
  37. package/src/spectrum-tabs.css.js.map +7 -1
  38. package/src/tab-panel.css.dev.js +6 -0
  39. package/src/tab-panel.css.dev.js.map +7 -0
  40. package/src/tab-panel.css.js +3 -14
  41. package/src/tab-panel.css.js.map +7 -1
  42. package/src/tab.css.dev.js +54 -0
  43. package/src/tab.css.dev.js.map +7 -0
  44. package/src/tab.css.js +3 -14
  45. package/src/tab.css.js.map +7 -1
  46. package/src/tabs.css.dev.js +406 -0
  47. package/src/tabs.css.dev.js.map +7 -0
  48. package/src/tabs.css.js +3 -14
  49. package/src/tabs.css.js.map +7 -1
  50. package/stories/tabs-horizontal-sizes.stories.js +53 -64
  51. package/stories/tabs-horizontal-sizes.stories.js.map +7 -1
  52. package/stories/tabs-vertical-right-sizes.stories.js +50 -61
  53. package/stories/tabs-vertical-right-sizes.stories.js.map +7 -1
  54. package/stories/tabs-vertical-sizes.stories.js +50 -61
  55. package/stories/tabs-vertical-sizes.stories.js.map +7 -1
  56. package/stories/tabs.stories.js +79 -81
  57. package/stories/tabs.stories.js.map +7 -1
  58. package/test/benchmark/basic-test.js +6 -17
  59. package/test/benchmark/basic-test.js.map +7 -1
  60. package/test/tab.test.js +21 -34
  61. package/test/tab.test.js.map +7 -1
  62. package/test/tabs-horizontal-sizes.test-vrt.js +4 -15
  63. package/test/tabs-horizontal-sizes.test-vrt.js.map +7 -1
  64. package/test/tabs-vertical-right-sizes.test-vrt.js +4 -15
  65. package/test/tabs-vertical-right-sizes.test-vrt.js.map +7 -1
  66. package/test/tabs-vertical-sizes.test-vrt.js +4 -15
  67. package/test/tabs-vertical-sizes.test-vrt.js.map +7 -1
  68. package/test/tabs.test-vrt.js +4 -15
  69. package/test/tabs.test-vrt.js.map +7 -1
  70. package/test/tabs.test.js +375 -383
  71. package/test/tabs.test.js.map +7 -1
package/src/Tabs.js CHANGED
@@ -1,208 +1,184 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { __decorate } from "tslib";
13
- import { html, SizedMixin, } from '@spectrum-web-components/base';
14
- import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
15
- import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
16
- import { Focusable } from '@spectrum-web-components/shared';
17
- import { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';
18
- import tabStyles from './tabs.css.js';
19
- const noSelectionStyle = 'transform: translateX(0px) scaleX(0) scaleY(0)';
20
- /**
21
- * @element sp-tabs
22
- *
23
- * @slot - Tab elements to manage as a group
24
- * @slot tab-panel - Tab Panel elements related to the listed Tab elements
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
- constructor() {
32
- super(...arguments);
33
- /**
34
- * Whether to activate a tab on keyboard focus or not.
35
- *
36
- * By default a tab is activated via a "click" interaction. This is specifically intended for when
37
- * tab content cannot be displayed instantly, e.g. not all of the DOM content is available, etc.
38
- * To learn more about "Deciding When to Make Selection Automatically Follow Focus", visit:
39
- * https://w3c.github.io/aria-practices/#kbd_selection_follows_focus
40
- */
41
- this.auto = false;
42
- this.direction = 'horizontal';
43
- this.emphasized = false;
44
- this.label = '';
45
- this.selectionIndicatorStyle = noSelectionStyle;
46
- this.shouldAnimate = false;
47
- this._selected = '';
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
- this.onClick = (event) => {
73
- if (this.disabled) {
74
- return;
75
- }
76
- const target = event
77
- .composedPath()
78
- .find((el) => el.parentElement === this);
79
- if (!target || target.disabled) {
80
- return;
81
- }
82
- this.shouldAnimate = true;
83
- this.selectTarget(target);
84
- };
85
- this.onKeyDown = (event) => {
86
- if (event.code === 'Enter' || event.code === 'Space') {
87
- event.preventDefault();
88
- const target = event.target;
89
- if (target) {
90
- this.selectTarget(target);
91
- }
92
- }
93
- };
94
- this.updateCheckedState = () => {
95
- if (!this.tabs.length) {
96
- this.tabs = [...this.querySelectorAll('[role="tab"]')];
97
- }
98
- this.tabs.forEach((element) => {
99
- element.removeAttribute('selected');
100
- });
101
- if (this.selected) {
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
- this._selected = value;
162
- this.shouldUpdateCheckedState();
163
- this.requestUpdate('selected', oldValue);
164
- }
165
- set tabs(tabs) {
166
- if (tabs === this.tabs)
167
- return;
168
- this._tabs = tabs;
169
- this.rovingTabindexController.clearElementCache();
170
- }
171
- get tabs() {
172
- return this._tabs;
173
- }
174
- /**
175
- * @private
176
- */
177
- get focusElement() {
178
- return this.rovingTabindexController.focusInElement || this;
179
- }
180
- manageAutoFocus() {
181
- const tabs = [...this.children];
182
- const tabUpdateCompletes = tabs.map((tab) => {
183
- if (typeof tab.updateComplete !== 'undefined') {
184
- return tab.updateComplete;
185
- }
186
- return Promise.resolve(true);
187
- });
188
- Promise.all(tabUpdateCompletes).then(() => super.manageAutoFocus());
189
- }
190
- managePanels({ target, }) {
191
- const panels = target.assignedElements();
192
- panels.map((panel) => {
193
- const { value, id } = panel;
194
- const tab = this.querySelector(`[role="tab"][value="${value}"]`);
195
- if (tab) {
196
- tab.setAttribute('aria-controls', id);
197
- panel.setAttribute('aria-labelledby', tab.id);
198
- }
199
- panel.selected = value === this.selected;
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
- render() {
203
- return html `
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 : undefined)}
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 ? undefined : 'first-position')}
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
- willUpdate(changes) {
224
- if (!this.hasUpdated) {
225
- const selectedChild = this.querySelector(':scope > [selected]');
226
- if (selectedChild) {
227
- this.selectTarget(selectedChild);
228
- }
229
- }
230
- super.updated(changes);
231
- if (changes.has('selected')) {
232
- if (changes.get('selected')) {
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
- selectTarget(target) {
266
- const value = target.getAttribute('value');
267
- if (value) {
268
- const selected = this.selected;
269
- this.selected = value;
270
- const applyDefault = this.dispatchEvent(new Event('change', {
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
- onSlotChange() {
279
- this.tabs = [...this.querySelectorAll('[role="tab"]')];
280
- this.shouldUpdateCheckedState();
224
+ if (changes.has("dir")) {
225
+ this.updateSelectionIndicator();
281
226
  }
282
- shouldUpdateCheckedState() {
283
- this.tabChangeResolver();
284
- this.tabChangePromise = new Promise((res) => (this.tabChangeResolver = res));
285
- setTimeout(this.updateCheckedState);
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
- async getUpdateComplete() {
288
- const complete = (await super.getUpdateComplete());
289
- await this.tabChangePromise;
290
- return complete;
234
+ if (!this.shouldAnimate && typeof changes.get("shouldAnimate") !== "undefined") {
235
+ this.shouldAnimate = true;
291
236
  }
292
- connectedCallback() {
293
- super.connectedCallback();
294
- window.addEventListener('resize', this.updateSelectionIndicator);
295
- if ('fonts' in document) {
296
- document.fonts.addEventListener('loadingdone', this.updateSelectionIndicator);
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
- disconnectedCallback() {
300
- window.removeEventListener('resize', this.updateSelectionIndicator);
301
- if ('fonts' in document) {
302
- document.fonts.removeEventListener('loadingdone', this.updateSelectionIndicator);
303
- }
304
- super.disconnectedCallback();
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
- __decorate([
308
- property({ type: Boolean })
309
- ], Tabs.prototype, "auto", void 0);
310
- __decorate([
311
- property({ reflect: true })
312
- ], Tabs.prototype, "direction", void 0);
313
- __decorate([
314
- property({ type: Boolean, reflect: true })
315
- ], Tabs.prototype, "emphasized", void 0);
316
- __decorate([
317
- property()
318
- ], Tabs.prototype, "label", void 0);
319
- __decorate([
320
- property({ attribute: false })
321
- ], Tabs.prototype, "selectionIndicatorStyle", void 0);
322
- __decorate([
323
- property({ attribute: false })
324
- ], Tabs.prototype, "shouldAnimate", void 0);
325
- __decorate([
326
- query('#list')
327
- ], Tabs.prototype, "tabList", void 0);
328
- __decorate([
329
- property({ reflect: true })
330
- ], Tabs.prototype, "selected", null);
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