@spectrum-web-components/tabs 0.8.6 → 0.8.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 (45) hide show
  1. package/package.json +5 -5
  2. package/sp-tab-panel.d.ts +6 -0
  3. package/sp-tab-panel.js +14 -0
  4. package/sp-tab-panel.js.map +1 -0
  5. package/sp-tab.d.ts +6 -0
  6. package/sp-tab.js +14 -0
  7. package/sp-tab.js.map +1 -0
  8. package/sp-tabs.d.ts +6 -0
  9. package/sp-tabs.js +14 -0
  10. package/sp-tabs.js.map +1 -0
  11. package/src/Tab.d.ts +33 -0
  12. package/src/Tab.js +112 -0
  13. package/src/Tab.js.map +1 -0
  14. package/src/TabPanel.d.ts +18 -0
  15. package/src/TabPanel.js +64 -0
  16. package/src/TabPanel.js.map +1 -0
  17. package/src/Tabs.d.ts +66 -0
  18. package/src/Tabs.js +328 -0
  19. package/src/Tabs.js.map +1 -0
  20. package/src/index.d.ts +3 -0
  21. package/src/index.js +15 -0
  22. package/src/index.js.map +1 -0
  23. package/src/spectrum-tab.css.d.ts +2 -0
  24. package/src/spectrum-tab.css.js +51 -0
  25. package/src/spectrum-tab.css.js.map +1 -0
  26. package/src/spectrum-tabs.css.d.ts +2 -0
  27. package/src/spectrum-tabs.css.js +399 -0
  28. package/src/spectrum-tabs.css.js.map +1 -0
  29. package/src/tab-panel.css.d.ts +2 -0
  30. package/src/tab-panel.css.js +17 -0
  31. package/src/tab-panel.css.js.map +1 -0
  32. package/src/tab.css.d.ts +2 -0
  33. package/src/tab.css.js +61 -0
  34. package/src/tab.css.js.map +1 -0
  35. package/src/tabs.css.d.ts +2 -0
  36. package/src/tabs.css.js +413 -0
  37. package/src/tabs.css.js.map +1 -0
  38. package/stories/tabs-horizontal-sizes.stories.js +101 -0
  39. package/stories/tabs-horizontal-sizes.stories.js.map +1 -0
  40. package/stories/tabs-vertical-right-sizes.stories.js +98 -0
  41. package/stories/tabs-vertical-right-sizes.stories.js.map +1 -0
  42. package/stories/tabs-vertical-sizes.stories.js +98 -0
  43. package/stories/tabs-vertical-sizes.stories.js.map +1 -0
  44. package/stories/tabs.stories.js +385 -0
  45. package/stories/tabs.stories.js.map +1 -0
package/src/Tabs.js ADDED
@@ -0,0 +1,328 @@
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
+ */
30
+ 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.label = '';
44
+ this.selectionIndicatorStyle = noSelectionStyle;
45
+ this.shouldAnimate = false;
46
+ this._selected = '';
47
+ this._tabs = [];
48
+ this.rovingTabindexController = new RovingTabindexController(this, {
49
+ focusInIndex: (elements) => {
50
+ let focusInIndex = 0;
51
+ const firstFocusableElement = elements.find((el, index) => {
52
+ const focusInElement = this.selected
53
+ ? !el.disabled && el.value === this.selected
54
+ : !el.disabled;
55
+ focusInIndex = index;
56
+ return focusInElement;
57
+ });
58
+ return firstFocusableElement ? focusInIndex : -1;
59
+ },
60
+ direction: () => this.direction === 'horizontal' ? 'horizontal' : 'vertical',
61
+ elementEnterAction: (el) => {
62
+ if (!this.auto)
63
+ return;
64
+ this.shouldAnimate = true;
65
+ this.selectTarget(el);
66
+ },
67
+ elements: () => this.tabs,
68
+ isFocusableElement: (el) => !el.disabled,
69
+ listenerScope: () => this.tabList,
70
+ });
71
+ this.onClick = (event) => {
72
+ if (this.disabled) {
73
+ return;
74
+ }
75
+ const target = event
76
+ .composedPath()
77
+ .find((el) => el.parentElement === this);
78
+ if (!target || target.disabled) {
79
+ return;
80
+ }
81
+ this.shouldAnimate = true;
82
+ this.selectTarget(target);
83
+ };
84
+ this.onKeyDown = (event) => {
85
+ if (event.code === 'Enter' || event.code === 'Space') {
86
+ event.preventDefault();
87
+ const target = event.target;
88
+ if (target) {
89
+ this.selectTarget(target);
90
+ }
91
+ }
92
+ };
93
+ this.updateCheckedState = () => {
94
+ if (!this.tabs.length) {
95
+ this.tabs = [...this.querySelectorAll('[role="tab"]')];
96
+ }
97
+ this.tabs.forEach((element) => {
98
+ element.removeAttribute('selected');
99
+ });
100
+ if (this.selected) {
101
+ const currentChecked = this.tabs.find((el) => el.value === this.selected);
102
+ if (currentChecked) {
103
+ currentChecked.selected = true;
104
+ }
105
+ else {
106
+ this.selected = '';
107
+ }
108
+ }
109
+ else {
110
+ const firstTab = this.tabs[0];
111
+ if (firstTab) {
112
+ firstTab.setAttribute('tabindex', '0');
113
+ }
114
+ }
115
+ this.updateSelectionIndicator();
116
+ this.tabChangeResolver();
117
+ };
118
+ this.updateSelectionIndicator = async () => {
119
+ const selectedElement = this.tabs.find((el) => el.selected);
120
+ if (!selectedElement) {
121
+ this.selectionIndicatorStyle = noSelectionStyle;
122
+ return;
123
+ }
124
+ await Promise.all([
125
+ selectedElement.updateComplete,
126
+ document.fonts ? document.fonts.ready : Promise.resolve(),
127
+ ]);
128
+ const tabBoundingClientRect = selectedElement.getBoundingClientRect();
129
+ const parentBoundingClientRect = this.getBoundingClientRect();
130
+ if (this.direction === 'horizontal') {
131
+ const width = tabBoundingClientRect.width;
132
+ const offset = this.dir === 'ltr'
133
+ ? tabBoundingClientRect.left - parentBoundingClientRect.left
134
+ : tabBoundingClientRect.right -
135
+ parentBoundingClientRect.right;
136
+ this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${this.dir === 'ltr' ? width : -1 * width});`;
137
+ }
138
+ else {
139
+ const height = tabBoundingClientRect.height;
140
+ const offset = tabBoundingClientRect.top - parentBoundingClientRect.top;
141
+ this.selectionIndicatorStyle = `transform: translateY(${offset}px) scaleY(${height});`;
142
+ }
143
+ };
144
+ this.tabChangePromise = Promise.resolve();
145
+ this.tabChangeResolver = function () {
146
+ return;
147
+ };
148
+ }
149
+ static get styles() {
150
+ return [tabStyles];
151
+ }
152
+ get selected() {
153
+ return this._selected;
154
+ }
155
+ set selected(value) {
156
+ const oldValue = this.selected;
157
+ if (value === oldValue) {
158
+ return;
159
+ }
160
+ this._selected = value;
161
+ this.shouldUpdateCheckedState();
162
+ this.requestUpdate('selected', oldValue);
163
+ }
164
+ set tabs(tabs) {
165
+ if (tabs === this.tabs)
166
+ return;
167
+ this._tabs = tabs;
168
+ this.rovingTabindexController.clearElementCache();
169
+ }
170
+ get tabs() {
171
+ return this._tabs;
172
+ }
173
+ /**
174
+ * @private
175
+ */
176
+ get focusElement() {
177
+ return this.rovingTabindexController.focusInElement || this;
178
+ }
179
+ manageAutoFocus() {
180
+ const tabs = [...this.children];
181
+ const tabUpdateCompletes = tabs.map((tab) => {
182
+ if (typeof tab.updateComplete !== 'undefined') {
183
+ return tab.updateComplete;
184
+ }
185
+ return Promise.resolve(true);
186
+ });
187
+ Promise.all(tabUpdateCompletes).then(() => super.manageAutoFocus());
188
+ }
189
+ managePanels({ target, }) {
190
+ const panels = target.assignedElements();
191
+ panels.map((panel) => {
192
+ const { value, id } = panel;
193
+ const tab = this.querySelector(`[role="tab"][value="${value}"]`);
194
+ if (tab) {
195
+ tab.setAttribute('aria-controls', id);
196
+ panel.setAttribute('aria-labelledby', tab.id);
197
+ }
198
+ panel.selected = value === this.selected;
199
+ });
200
+ }
201
+ render() {
202
+ return html `
203
+ <div
204
+ aria-label=${ifDefined(this.label ? this.label : undefined)}
205
+ @click=${this.onClick}
206
+ @keydown=${this.onKeyDown}
207
+ @sp-tab-contentchange=${this.updateSelectionIndicator}
208
+ id="list"
209
+ role="tablist"
210
+ >
211
+ <slot @slotchange=${this.onSlotChange}></slot>
212
+ <div
213
+ id="selection-indicator"
214
+ class=${ifDefined(this.shouldAnimate ? undefined : 'first-position')}
215
+ style=${this.selectionIndicatorStyle}
216
+ role="presentation"
217
+ ></div>
218
+ </div>
219
+ <slot name="tab-panel" @slotchange=${this.managePanels}></slot>
220
+ `;
221
+ }
222
+ firstUpdated(changes) {
223
+ super.firstUpdated(changes);
224
+ const selectedChild = this.querySelector(':scope > [selected]');
225
+ if (selectedChild) {
226
+ this.selectTarget(selectedChild);
227
+ }
228
+ }
229
+ updated(changes) {
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
+ }
264
+ }
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
+ }
277
+ }
278
+ onSlotChange() {
279
+ this.tabs = [...this.querySelectorAll('[role="tab"]')];
280
+ this.shouldUpdateCheckedState();
281
+ }
282
+ shouldUpdateCheckedState() {
283
+ this.tabChangeResolver();
284
+ this.tabChangePromise = new Promise((res) => (this.tabChangeResolver = res));
285
+ setTimeout(this.updateCheckedState);
286
+ }
287
+ async getUpdateComplete() {
288
+ const complete = (await super.getUpdateComplete());
289
+ await this.tabChangePromise;
290
+ return complete;
291
+ }
292
+ connectedCallback() {
293
+ super.connectedCallback();
294
+ window.addEventListener('resize', this.updateSelectionIndicator);
295
+ if ('fonts' in document) {
296
+ document.fonts.addEventListener('loadingdone', this.updateSelectionIndicator);
297
+ }
298
+ }
299
+ disconnectedCallback() {
300
+ window.removeEventListener('resize', this.updateSelectionIndicator);
301
+ if ('fonts' in document) {
302
+ document.fonts.removeEventListener('loadingdone', this.updateSelectionIndicator);
303
+ }
304
+ super.disconnectedCallback();
305
+ }
306
+ }
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()
315
+ ], Tabs.prototype, "label", void 0);
316
+ __decorate([
317
+ property({ attribute: false })
318
+ ], Tabs.prototype, "selectionIndicatorStyle", void 0);
319
+ __decorate([
320
+ property({ attribute: false })
321
+ ], Tabs.prototype, "shouldAnimate", void 0);
322
+ __decorate([
323
+ query('#list')
324
+ ], Tabs.prototype, "tabList", void 0);
325
+ __decorate([
326
+ property({ reflect: true })
327
+ ], Tabs.prototype, "selected", null);
328
+ //# sourceMappingURL=Tabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tabs.js","sourceRoot":"","sources":["Tabs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,UAAU,GAEb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qEAAqE,CAAC;AAE/G,OAAO,SAAS,MAAM,eAAe,CAAC;AAGtC,MAAM,gBAAgB,GAAG,gDAAgD,CAAC;AAE1E;;;;;;;;;GASG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU,CAAC,SAAS,CAAC;IAA/C;;QAKI;;;;;;;WAOG;QAEI,SAAI,GAAG,KAAK,CAAC;QAGb,cAAS,GACZ,YAAY,CAAC;QAGV,UAAK,GAAG,EAAE,CAAC;QAGX,4BAAuB,GAAG,gBAAgB,CAAC;QAG3C,kBAAa,GAAG,KAAK,CAAC;QAsBrB,cAAS,GAAG,EAAE,CAAC;QAYf,UAAK,GAAU,EAAE,CAAC;QAE1B,6BAAwB,GAAG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AG3B","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { Tab } from './Tab.js';\nimport { Focusable } from '@spectrum-web-components/shared';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\n\nimport tabStyles from './tabs.css.js';\nimport { TabPanel } from './TabPanel.js';\n\nconst noSelectionStyle = 'transform: translateX(0px) scaleX(0) scaleY(0)';\n\n/**\n * @element sp-tabs\n *\n * @slot - Tab elements to manage as a group\n * @slot tab-panel - Tab Panel elements related to the listed Tab elements\n * @attr {Boolean} quiet - The tabs border is a lot smaller\n * @attr {Boolean} compact - The collection of tabs take up less space\n *\n * @fires change - The selected Tab child has changed.\n */\nexport class Tabs extends SizedMixin(Focusable) {\n public static get styles(): CSSResultArray {\n return [tabStyles];\n }\n\n /**\n * Whether to activate a tab on keyboard focus or not.\n *\n * By default a tab is activated via a \"click\" interaction. This is specifically intended for when\n * tab content cannot be displayed instantly, e.g. not all of the DOM content is available, etc.\n * To learn more about \"Deciding When to Make Selection Automatically Follow Focus\", visit:\n * https://w3c.github.io/aria-practices/#kbd_selection_follows_focus\n */\n @property({ type: Boolean })\n public auto = false;\n\n @property({ reflect: true })\n public direction: 'vertical' | 'vertical-right' | 'horizontal' =\n 'horizontal';\n\n @property()\n public label = '';\n\n @property({ attribute: false })\n public selectionIndicatorStyle = noSelectionStyle;\n\n @property({ attribute: false })\n public shouldAnimate = false;\n\n @query('#list')\n private tabList!: HTMLDivElement;\n\n @property({ reflect: true })\n public get selected(): string {\n return this._selected;\n }\n\n public set selected(value: string) {\n const oldValue = this.selected;\n\n if (value === oldValue) {\n return;\n }\n\n this._selected = value;\n this.shouldUpdateCheckedState();\n this.requestUpdate('selected', oldValue);\n }\n\n private _selected = '';\n\n private set tabs(tabs: Tab[]) {\n if (tabs === this.tabs) return;\n this._tabs = tabs;\n this.rovingTabindexController.clearElementCache();\n }\n\n private get tabs(): Tab[] {\n return this._tabs;\n }\n\n private _tabs: Tab[] = [];\n\n rovingTabindexController = new RovingTabindexController<Tab>(this, {\n focusInIndex: (elements) => {\n let focusInIndex = 0;\n const firstFocusableElement = elements.find((el, index) => {\n const focusInElement = this.selected\n ? !el.disabled && el.value === this.selected\n : !el.disabled;\n focusInIndex = index;\n return focusInElement;\n });\n return firstFocusableElement ? focusInIndex : -1;\n },\n direction: () =>\n this.direction === 'horizontal' ? 'horizontal' : 'vertical',\n elementEnterAction: (el) => {\n if (!this.auto) return;\n\n this.shouldAnimate = true;\n this.selectTarget(el);\n },\n elements: () => this.tabs,\n isFocusableElement: (el) => !el.disabled,\n listenerScope: () => this.tabList,\n });\n\n /**\n * @private\n */\n public get focusElement(): Tab | this {\n return this.rovingTabindexController.focusInElement || this;\n }\n\n protected manageAutoFocus(): void {\n const tabs = [...this.children] as Tab[];\n const tabUpdateCompletes = tabs.map((tab) => {\n if (typeof tab.updateComplete !== 'undefined') {\n return tab.updateComplete;\n }\n return Promise.resolve(true);\n });\n Promise.all(tabUpdateCompletes).then(() => super.manageAutoFocus());\n }\n\n protected managePanels({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n const panels = target.assignedElements() as TabPanel[];\n panels.map((panel) => {\n const { value, id } = panel;\n const tab = this.querySelector(`[role=\"tab\"][value=\"${value}\"]`);\n if (tab) {\n tab.setAttribute('aria-controls', id);\n panel.setAttribute('aria-labelledby', tab.id);\n }\n panel.selected = value === this.selected;\n });\n }\n\n protected render(): TemplateResult {\n return html`\n <div\n aria-label=${ifDefined(this.label ? this.label : undefined)}\n @click=${this.onClick}\n @keydown=${this.onKeyDown}\n @sp-tab-contentchange=${this.updateSelectionIndicator}\n id=\"list\"\n role=\"tablist\"\n >\n <slot @slotchange=${this.onSlotChange}></slot>\n <div\n id=\"selection-indicator\"\n class=${ifDefined(\n this.shouldAnimate ? undefined : 'first-position'\n )}\n style=${this.selectionIndicatorStyle}\n role=\"presentation\"\n ></div>\n </div>\n <slot name=\"tab-panel\" @slotchange=${this.managePanels}></slot>\n `;\n }\n\n protected firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n const selectedChild = this.querySelector(':scope > [selected]') as Tab;\n if (selectedChild) {\n this.selectTarget(selectedChild);\n }\n }\n\n protected updated(changes: PropertyValues<this>): void {\n super.updated(changes);\n if (changes.has('selected')) {\n if (changes.get('selected')) {\n const previous = this.querySelector(\n `[role=\"tabpanel\"][value=\"${changes.get('selected')}\"]`\n ) as TabPanel;\n if (previous) previous.selected = false;\n }\n const next = this.querySelector(\n `[role=\"tabpanel\"][value=\"${this.selected}\"]`\n ) as TabPanel;\n if (next) next.selected = true;\n }\n if (changes.has('direction')) {\n if (this.direction === 'horizontal') {\n this.removeAttribute('aria-orientation');\n } else {\n this.setAttribute('aria-orientation', 'vertical');\n }\n }\n if (changes.has('dir')) {\n this.updateSelectionIndicator();\n }\n if (changes.has('disabled')) {\n if (this.disabled) {\n this.setAttribute('aria-disabled', 'true');\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n if (\n !this.shouldAnimate &&\n typeof changes.get('shouldAnimate') !== 'undefined'\n ) {\n this.shouldAnimate = true;\n }\n }\n\n private onClick = (event: Event): void => {\n if (this.disabled) {\n return;\n }\n const target = event\n .composedPath()\n .find((el) => (el as Tab).parentElement === this) as Tab;\n if (!target || target.disabled) {\n return;\n }\n this.shouldAnimate = true;\n this.selectTarget(target);\n };\n\n private onKeyDown = (event: KeyboardEvent): void => {\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n const target = event.target as HTMLElement;\n if (target) {\n this.selectTarget(target);\n }\n }\n };\n\n private selectTarget(target: HTMLElement): void {\n const value = target.getAttribute('value');\n if (value) {\n const selected = this.selected;\n this.selected = value;\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.selected = selected;\n }\n }\n }\n\n private onSlotChange(): void {\n this.tabs = [...this.querySelectorAll('[role=\"tab\"]')] as Tab[];\n this.shouldUpdateCheckedState();\n }\n\n private shouldUpdateCheckedState(): void {\n this.tabChangeResolver();\n this.tabChangePromise = new Promise(\n (res) => (this.tabChangeResolver = res)\n );\n setTimeout(this.updateCheckedState);\n }\n\n private updateCheckedState = (): void => {\n if (!this.tabs.length) {\n this.tabs = [...this.querySelectorAll('[role=\"tab\"]')] as Tab[];\n }\n this.tabs.forEach((element) => {\n element.removeAttribute('selected');\n });\n\n if (this.selected) {\n const currentChecked = this.tabs.find(\n (el) => el.value === this.selected\n );\n\n if (currentChecked) {\n currentChecked.selected = true;\n } else {\n this.selected = '';\n }\n } else {\n const firstTab = this.tabs[0];\n if (firstTab) {\n firstTab.setAttribute('tabindex', '0');\n }\n }\n\n this.updateSelectionIndicator();\n this.tabChangeResolver();\n };\n\n private updateSelectionIndicator = async (): Promise<void> => {\n const selectedElement = this.tabs.find((el) => el.selected);\n if (!selectedElement) {\n this.selectionIndicatorStyle = noSelectionStyle;\n return;\n }\n await Promise.all([\n selectedElement.updateComplete,\n document.fonts ? document.fonts.ready : Promise.resolve(),\n ]);\n const tabBoundingClientRect = selectedElement.getBoundingClientRect();\n const parentBoundingClientRect = this.getBoundingClientRect();\n\n if (this.direction === 'horizontal') {\n const width = tabBoundingClientRect.width;\n const offset =\n this.dir === 'ltr'\n ? tabBoundingClientRect.left - parentBoundingClientRect.left\n : tabBoundingClientRect.right -\n parentBoundingClientRect.right;\n\n this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${\n this.dir === 'ltr' ? width : -1 * width\n });`;\n } else {\n const height = tabBoundingClientRect.height;\n const offset =\n tabBoundingClientRect.top - parentBoundingClientRect.top;\n\n this.selectionIndicatorStyle = `transform: translateY(${offset}px) scaleY(${height});`;\n }\n };\n\n private tabChangePromise = Promise.resolve();\n private tabChangeResolver: () => void = function () {\n return;\n };\n\n protected async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.tabChangePromise;\n return complete;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n window.addEventListener('resize', this.updateSelectionIndicator);\n if ('fonts' in document) {\n (\n document as unknown as {\n fonts: {\n addEventListener: (\n name: string,\n callback: () => void\n ) => void;\n };\n }\n ).fonts.addEventListener(\n 'loadingdone',\n this.updateSelectionIndicator\n );\n }\n }\n\n public disconnectedCallback(): void {\n window.removeEventListener('resize', this.updateSelectionIndicator);\n if ('fonts' in document) {\n (\n document as unknown as {\n fonts: {\n removeEventListener: (\n name: string,\n callback: () => void\n ) => void;\n };\n }\n ).fonts.removeEventListener(\n 'loadingdone',\n this.updateSelectionIndicator\n );\n }\n super.disconnectedCallback();\n }\n}\n"]}
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './Tabs.js';
2
+ export * from './Tab.js';
3
+ export * from './TabPanel.js';
package/src/index.js ADDED
@@ -0,0 +1,15 @@
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
+ export * from './Tabs.js';
13
+ export * from './Tab.js';
14
+ export * from './TabPanel.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nexport * from './Tabs.js';\nexport * from './Tab.js';\nexport * from './TabPanel.js';\n"]}
@@ -0,0 +1,2 @@
1
+ declare const styles: import("@spectrum-web-components/base").CSSResult;
2
+ export default styles;
@@ -0,0 +1,51 @@
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 { css } from '@spectrum-web-components/base';
13
+ const styles = css `
14
+ :host{box-sizing:border-box;cursor:pointer;height:var(--spectrum-tabs-quiet-textonly-tabitem-height);line-height:var(--spectrum-tabs-quiet-textonly-tabitem-height);outline:none;position:relative;text-decoration:none;transition:color var(
15
+ --spectrum-tabs-texticon-tabitem-selection-indicator-animation-duration
16
+ ) ease-out;white-space:nowrap;z-index:1}:host([disabled]){cursor:default}:host([disabled]) #item-label{cursor:default}:host(:not([vertical])) ::slotted([slot=icon]){height:var(
17
+ --spectrum-tabs-quiet-textonly-tabitem-height
18
+ )}:host([dir=ltr]) slot[name=icon]+#item-label{margin-left:calc(var(--spectrum-tabs-quiet-textonly-tabitem-icon-gap) - var(--spectrum-global-dimension-size-40))}:host([dir=rtl]) slot[name=icon]+#item-label{margin-right:calc(var(--spectrum-tabs-quiet-textonly-tabitem-icon-gap) - var(--spectrum-global-dimension-size-40))}:host([dir=ltr]):before{left:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-padding-x)*-1)}:host([dir=rtl]):before{right:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-padding-x)*-1)}:host([dir=ltr]):before{right:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-padding-x)*-1)}:host([dir=rtl]):before{left:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-padding-x)*-1)}:host:before{border:var(--spectrum-tabs-textonly-tabitem-focus-ring-size) solid transparent;border-radius:var(
19
+ --spectrum-tabs-textonly-tabitem-focus-ring-border-radius
20
+ );box-sizing:border-box;content:"";height:var(--spectrum-tabs-textonly-tabitem-focus-ring-height);margin-top:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-height)/-2);pointer-events:none;position:absolute;top:50%}#item-label{cursor:pointer;display:inline-block;font-size:var(--spectrum-tabs-texticon-tabitem-text-size);font-weight:var(--spectrum-tabs-textonly-tabitem-text-font-weight);text-decoration:none;vertical-align:top}#item-label:empty{display:none}:host{color:var(
21
+ --spectrum-tabs-textonly-tabitem-text-color
22
+ )}:host(:not([vertical])) ::slotted([slot=icon]){color:var(
23
+ --spectrum-tabs-textonly-tabitem-icon-color
24
+ )}:host(:hover){color:var(
25
+ --spectrum-tabs-textonly-tabitem-text-color-hover
26
+ )}:host(:hover) ::slotted([slot=icon]){color:var(
27
+ --spectrum-tabs-textonly-tabitem-icon-color-hover
28
+ )}:host([selected]){color:var(
29
+ --spectrum-tabs-textonly-tabitem-text-color-selected
30
+ )}:host([selected]) ::slotted([slot=icon]){color:var(
31
+ --spectrum-tabs-textonly-tabitem-icon-color-selected
32
+ )}:host(.focus-visible){color:var(
33
+ --spectrum-tabs-textonly-tabitem-text-color-selected-key-focus
34
+ )}:host(:focus-visible){color:var(
35
+ --spectrum-tabs-textonly-tabitem-text-color-selected-key-focus
36
+ )}:host(.focus-visible):before{border-color:var(
37
+ --spectrum-tabs-textonly-tabitem-focus-ring-border-color-key-focus
38
+ )}:host(:focus-visible):before{border-color:var(
39
+ --spectrum-tabs-textonly-tabitem-focus-ring-border-color-key-focus
40
+ )}:host(.focus-visible) ::slotted([slot=icon]){color:var(
41
+ --spectrum-tabs-textonly-tabitem-icon-color-selected-key-focus
42
+ )}:host(:focus-visible) ::slotted([slot=icon]){color:var(
43
+ --spectrum-tabs-textonly-tabitem-icon-color-selected-key-focus
44
+ )}:host([disabled]){color:var(
45
+ --spectrum-tabs-textonly-tabitem-text-color-disabled
46
+ )}:host([disabled]) ::slotted([slot=icon]){color:var(
47
+ --spectrum-tabs-textonly-tabitem-icon-color-disabled
48
+ )}
49
+ `;
50
+ export default styles;
51
+ //# sourceMappingURL=spectrum-tab.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spectrum-tab.css.js","sourceRoot":"","sources":["spectrum-tab.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{box-sizing:border-box;cursor:pointer;height:var(--spectrum-tabs-quiet-textonly-tabitem-height);line-height:var(--spectrum-tabs-quiet-textonly-tabitem-height);outline:none;position:relative;text-decoration:none;transition:color var(\n--spectrum-tabs-texticon-tabitem-selection-indicator-animation-duration\n) ease-out;white-space:nowrap;z-index:1}:host([disabled]){cursor:default}:host([disabled]) #item-label{cursor:default}:host(:not([vertical])) ::slotted([slot=icon]){height:var(\n--spectrum-tabs-quiet-textonly-tabitem-height\n)}:host([dir=ltr]) slot[name=icon]+#item-label{margin-left:calc(var(--spectrum-tabs-quiet-textonly-tabitem-icon-gap) - var(--spectrum-global-dimension-size-40))}:host([dir=rtl]) slot[name=icon]+#item-label{margin-right:calc(var(--spectrum-tabs-quiet-textonly-tabitem-icon-gap) - var(--spectrum-global-dimension-size-40))}:host([dir=ltr]):before{left:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-padding-x)*-1)}:host([dir=rtl]):before{right:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-padding-x)*-1)}:host([dir=ltr]):before{right:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-padding-x)*-1)}:host([dir=rtl]):before{left:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-padding-x)*-1)}:host:before{border:var(--spectrum-tabs-textonly-tabitem-focus-ring-size) solid transparent;border-radius:var(\n--spectrum-tabs-textonly-tabitem-focus-ring-border-radius\n);box-sizing:border-box;content:\"\";height:var(--spectrum-tabs-textonly-tabitem-focus-ring-height);margin-top:calc(var(--spectrum-tabs-textonly-tabitem-focus-ring-height)/-2);pointer-events:none;position:absolute;top:50%}#item-label{cursor:pointer;display:inline-block;font-size:var(--spectrum-tabs-texticon-tabitem-text-size);font-weight:var(--spectrum-tabs-textonly-tabitem-text-font-weight);text-decoration:none;vertical-align:top}#item-label:empty{display:none}:host{color:var(\n--spectrum-tabs-textonly-tabitem-text-color\n)}:host(:not([vertical])) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-textonly-tabitem-icon-color\n)}:host(:hover){color:var(\n--spectrum-tabs-textonly-tabitem-text-color-hover\n)}:host(:hover) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-textonly-tabitem-icon-color-hover\n)}:host([selected]){color:var(\n--spectrum-tabs-textonly-tabitem-text-color-selected\n)}:host([selected]) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-textonly-tabitem-icon-color-selected\n)}:host(.focus-visible){color:var(\n--spectrum-tabs-textonly-tabitem-text-color-selected-key-focus\n)}:host(:focus-visible){color:var(\n--spectrum-tabs-textonly-tabitem-text-color-selected-key-focus\n)}:host(.focus-visible):before{border-color:var(\n--spectrum-tabs-textonly-tabitem-focus-ring-border-color-key-focus\n)}:host(:focus-visible):before{border-color:var(\n--spectrum-tabs-textonly-tabitem-focus-ring-border-color-key-focus\n)}:host(.focus-visible) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-textonly-tabitem-icon-color-selected-key-focus\n)}:host(:focus-visible) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-textonly-tabitem-icon-color-selected-key-focus\n)}:host([disabled]){color:var(\n--spectrum-tabs-textonly-tabitem-text-color-disabled\n)}:host([disabled]) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-textonly-tabitem-icon-color-disabled\n)}\n`;\nexport default styles;"]}
@@ -0,0 +1,2 @@
1
+ declare const styles: import("@spectrum-web-components/base").CSSResult;
2
+ export default styles;