@spectrum-web-components/tabs 0.9.0 → 0.9.1
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/README.md +154 -36
- package/custom-elements.json +41 -13
- package/package.json +3 -2
- package/sp-tab-panel.dev.js +1 -0
- package/sp-tab-panel.dev.js.map +1 -1
- package/sp-tab-panel.js +1 -1
- package/sp-tab-panel.js.map +2 -2
- package/sp-tab.dev.js +1 -0
- package/sp-tab.dev.js.map +1 -1
- package/sp-tab.js +1 -1
- package/sp-tab.js.map +2 -2
- package/sp-tabs.dev.js +1 -0
- package/sp-tabs.dev.js.map +1 -1
- package/sp-tabs.js +1 -1
- package/sp-tabs.js.map +2 -2
- package/src/Tab.dev.js +18 -7
- package/src/Tab.dev.js.map +1 -1
- package/src/Tab.js +5 -5
- package/src/Tab.js.map +2 -2
- package/src/TabPanel.dev.js +1 -0
- package/src/TabPanel.dev.js.map +1 -1
- package/src/TabPanel.js +2 -2
- package/src/TabPanel.js.map +2 -2
- package/src/Tabs.d.ts +9 -2
- package/src/Tabs.dev.js +52 -12
- package/src/Tabs.dev.js.map +2 -2
- package/src/Tabs.js +4 -4
- package/src/Tabs.js.map +3 -3
- package/src/index.dev.js +1 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-tab.css.dev.js +1 -0
- package/src/spectrum-tab.css.dev.js.map +1 -1
- package/src/spectrum-tab.css.js +1 -1
- package/src/spectrum-tab.css.js.map +2 -2
- package/src/spectrum-tabs.css.dev.js +1 -0
- package/src/spectrum-tabs.css.dev.js.map +1 -1
- package/src/spectrum-tabs.css.js +1 -1
- package/src/spectrum-tabs.css.js.map +2 -2
- package/src/tab-panel.css.dev.js +1 -0
- package/src/tab-panel.css.dev.js.map +1 -1
- package/src/tab-panel.css.js +1 -1
- package/src/tab-panel.css.js.map +2 -2
- package/src/tab.css.dev.js +1 -0
- package/src/tab.css.dev.js.map +1 -1
- package/src/tab.css.js +1 -1
- package/src/tab.css.js.map +2 -2
- package/src/tabs.css.dev.js +2 -1
- package/src/tabs.css.dev.js.map +2 -2
- package/src/tabs.css.js +2 -2
- package/src/tabs.css.js.map +3 -3
- package/stories/tabs-horizontal-sizes.stories.js +77 -7
- package/stories/tabs-horizontal-sizes.stories.js.map +1 -1
- package/stories/tabs-vertical-right-sizes.stories.js +74 -7
- package/stories/tabs-vertical-right-sizes.stories.js.map +1 -1
- package/stories/tabs-vertical-sizes.stories.js +74 -7
- package/stories/tabs-vertical-sizes.stories.js.map +1 -1
- package/stories/tabs.stories.js +279 -75
- package/stories/tabs.stories.js.map +2 -2
- package/test/benchmark/basic-test.js +6 -1
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/tab.test.js +37 -4
- package/test/tab.test.js.map +1 -1
- package/test/tabs-horizontal-sizes.test-vrt.js +4 -1
- package/test/tabs-horizontal-sizes.test-vrt.js.map +1 -1
- package/test/tabs-vertical-right-sizes.test-vrt.js +4 -1
- package/test/tabs-vertical-right-sizes.test-vrt.js.map +1 -1
- package/test/tabs-vertical-sizes.test-vrt.js +4 -1
- package/test/tabs-vertical-sizes.test-vrt.js.map +1 -1
- package/test/tabs.test-vrt.js +4 -1
- package/test/tabs.test-vrt.js.map +1 -1
- package/test/tabs.test.js +428 -17
- package/test/tabs.test.js.map +1 -1
package/src/TabPanel.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["TabPanel.ts"],
|
|
4
4
|
"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 html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport panelStyles from './tab-panel.css.js';\n\n/**\n * @element sp-tab-panel\n *\n * @slot - content of the Tab Panel\n */\nexport class TabPanel extends SpectrumElement {\n static override styles = [panelStyles];\n\n /**\n * @private\n */\n static instanceCount = 0;\n\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n @property({ type: String, reflect: true })\n public value = '';\n\n protected override render(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected override firstUpdated(): void {\n this.slot = 'tab-panel';\n this.setAttribute('role', 'tabpanel');\n this.tabIndex = 0;\n if (!this.hasAttribute('id')) {\n this.id = `sp-tab-panel-${TabPanel.instanceCount++}`;\n }\n }\n\n protected override updated(changes: PropertyValues<this>): void {\n if (changes.has('selected')) {\n if (this.selected) {\n this.removeAttribute('aria-hidden');\n this.tabIndex = 0;\n } else {\n this.setAttribute('aria-hidden', 'true');\n this.tabIndex = -1;\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "qNAYA,OACI,QAAAA,EAEA,mBAAAC,MAEG,gCACP,OAAS,YAAAC,MAAgB,kDAEzB,OAAOC,MAAiB,qBAOjB,MAAMC,EAAN,cAAuBH,CAAgB,CAAvC,kCASH,KAAO,SAAW,GAGlB,KAAO,MAAQ,GAEI,QAAyB,CACxC,OAAOD;AAAA;AAAA,SAGX,CAEmB,cAAqB,CACpC,KAAK,KAAO,YACZ,KAAK,aAAa,OAAQ,UAAU,EACpC,KAAK,SAAW,EACX,KAAK,aAAa,IAAI,IACvB,KAAK,GAAK,gBAAgBI,EAAS,kBAE3C,CAEmB,QAAQC,EAAqC,CACxDA,EAAQ,IAAI,UAAU,IAClB,KAAK,UACL,KAAK,gBAAgB,aAAa,EAClC,KAAK,SAAW,IAEhB,KAAK,aAAa,cAAe,MAAM,EACvC,KAAK,SAAW,IAG5B,CACJ,EAxCO,WAAM,SAAND,EAAM,SACO,OAAS,CAACD,CAAW,EAD5B,SAMF,cAAgB,EAGhBG,EAAA,CADNJ,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GARjC,SASF,wBAGAI,EAAA,CADNJ,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAXhC,SAYF",
|
|
6
|
+
"names": ["html", "SpectrumElement", "property", "panelStyles", "_TabPanel", "changes", "__decorateClass"]
|
|
7
7
|
}
|
package/src/Tabs.d.ts
CHANGED
|
@@ -11,8 +11,6 @@ declare const Tabs_base: typeof Focusable & {
|
|
|
11
11
|
*
|
|
12
12
|
* @slot - Tab elements to manage as a group
|
|
13
13
|
* @slot tab-panel - Tab Panel elements related to the listed Tab elements
|
|
14
|
-
* @attr {Boolean} quiet - The tabs border is a lot smaller
|
|
15
|
-
* @attr {Boolean} compact - The collection of tabs take up less space
|
|
16
14
|
* @csspart tablist - Container element for the slotted sp-tab elements
|
|
17
15
|
*
|
|
18
16
|
* @fires change - The selected Tab child has changed.
|
|
@@ -28,9 +26,17 @@ export declare class Tabs extends Tabs_base {
|
|
|
28
26
|
* https://w3c.github.io/aria-practices/#kbd_selection_follows_focus
|
|
29
27
|
*/
|
|
30
28
|
auto: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The tab items are displayed closer together.
|
|
31
|
+
*/
|
|
32
|
+
compact: boolean;
|
|
31
33
|
direction: 'vertical' | 'vertical-right' | 'horizontal';
|
|
32
34
|
emphasized: boolean;
|
|
33
35
|
label: string;
|
|
36
|
+
/**
|
|
37
|
+
* The tab list is displayed without a border.
|
|
38
|
+
*/
|
|
39
|
+
quiet: boolean;
|
|
34
40
|
selectionIndicatorStyle: string;
|
|
35
41
|
shouldAnimate: boolean;
|
|
36
42
|
private tabList;
|
|
@@ -40,6 +46,7 @@ export declare class Tabs extends Tabs_base {
|
|
|
40
46
|
private set tabs(value);
|
|
41
47
|
private get tabs();
|
|
42
48
|
private _tabs;
|
|
49
|
+
constructor();
|
|
43
50
|
rovingTabindexController: RovingTabindexController<Tab>;
|
|
44
51
|
/**
|
|
45
52
|
* @private
|
package/src/Tabs.dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -18,17 +19,20 @@ import {
|
|
|
18
19
|
query
|
|
19
20
|
} from "@spectrum-web-components/base/src/decorators.js";
|
|
20
21
|
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
22
|
+
import { IntersectionController } from "@lit-labs/observers/intersection_controller.js";
|
|
21
23
|
import { Focusable } from "@spectrum-web-components/shared";
|
|
22
24
|
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
23
25
|
import tabStyles from "./tabs.css.js";
|
|
24
26
|
const noSelectionStyle = "transform: translateX(0px) scaleX(0) scaleY(0)";
|
|
25
27
|
export class Tabs extends SizedMixin(Focusable) {
|
|
26
28
|
constructor() {
|
|
27
|
-
super(
|
|
29
|
+
super();
|
|
28
30
|
this.auto = false;
|
|
31
|
+
this.compact = false;
|
|
29
32
|
this.direction = "horizontal";
|
|
30
33
|
this.emphasized = false;
|
|
31
34
|
this.label = "";
|
|
35
|
+
this.quiet = false;
|
|
32
36
|
this.selectionIndicatorStyle = noSelectionStyle;
|
|
33
37
|
this.shouldAnimate = false;
|
|
34
38
|
this._selected = "";
|
|
@@ -82,7 +86,9 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
82
86
|
element.removeAttribute("selected");
|
|
83
87
|
});
|
|
84
88
|
if (this.selected) {
|
|
85
|
-
const currentChecked = this.tabs.find(
|
|
89
|
+
const currentChecked = this.tabs.find(
|
|
90
|
+
(el) => el.value === this.selected
|
|
91
|
+
);
|
|
86
92
|
if (currentChecked) {
|
|
87
93
|
currentChecked.selected = true;
|
|
88
94
|
} else {
|
|
@@ -122,6 +128,16 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
122
128
|
this.tabChangeResolver = function() {
|
|
123
129
|
return;
|
|
124
130
|
};
|
|
131
|
+
new IntersectionController(this, {
|
|
132
|
+
config: {
|
|
133
|
+
root: null,
|
|
134
|
+
rootMargin: "0px",
|
|
135
|
+
threshold: [0, 1]
|
|
136
|
+
},
|
|
137
|
+
callback: () => {
|
|
138
|
+
this.updateSelectionIndicator();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
125
141
|
}
|
|
126
142
|
static get styles() {
|
|
127
143
|
return [tabStyles];
|
|
@@ -188,7 +204,9 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
188
204
|
<slot @slotchange=${this.onSlotChange}></slot>
|
|
189
205
|
<div
|
|
190
206
|
id="selection-indicator"
|
|
191
|
-
class=${ifDefined(
|
|
207
|
+
class=${ifDefined(
|
|
208
|
+
this.shouldAnimate ? void 0 : "first-position"
|
|
209
|
+
)}
|
|
192
210
|
style=${this.selectionIndicatorStyle}
|
|
193
211
|
role="presentation"
|
|
194
212
|
></div>
|
|
@@ -198,7 +216,9 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
198
216
|
}
|
|
199
217
|
willUpdate(changes) {
|
|
200
218
|
if (!this.hasUpdated) {
|
|
201
|
-
const selectedChild = this.querySelector(
|
|
219
|
+
const selectedChild = this.querySelector(
|
|
220
|
+
":scope > [selected]"
|
|
221
|
+
);
|
|
202
222
|
if (selectedChild) {
|
|
203
223
|
this.selectTarget(selectedChild);
|
|
204
224
|
}
|
|
@@ -206,11 +226,15 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
206
226
|
super.updated(changes);
|
|
207
227
|
if (changes.has("selected")) {
|
|
208
228
|
if (changes.get("selected")) {
|
|
209
|
-
const previous = this.querySelector(
|
|
229
|
+
const previous = this.querySelector(
|
|
230
|
+
`[role="tabpanel"][value="${changes.get("selected")}"]`
|
|
231
|
+
);
|
|
210
232
|
if (previous)
|
|
211
233
|
previous.selected = false;
|
|
212
234
|
}
|
|
213
|
-
const next = this.querySelector(
|
|
235
|
+
const next = this.querySelector(
|
|
236
|
+
`[role="tabpanel"][value="${this.selected}"]`
|
|
237
|
+
);
|
|
214
238
|
if (next)
|
|
215
239
|
next.selected = true;
|
|
216
240
|
}
|
|
@@ -240,9 +264,11 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
240
264
|
if (value) {
|
|
241
265
|
const selected = this.selected;
|
|
242
266
|
this.selected = value;
|
|
243
|
-
const applyDefault = this.dispatchEvent(
|
|
244
|
-
|
|
245
|
-
|
|
267
|
+
const applyDefault = this.dispatchEvent(
|
|
268
|
+
new Event("change", {
|
|
269
|
+
cancelable: true
|
|
270
|
+
})
|
|
271
|
+
);
|
|
246
272
|
if (!applyDefault) {
|
|
247
273
|
this.selected = selected;
|
|
248
274
|
}
|
|
@@ -254,7 +280,9 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
254
280
|
}
|
|
255
281
|
shouldUpdateCheckedState() {
|
|
256
282
|
this.tabChangeResolver();
|
|
257
|
-
this.tabChangePromise = new Promise(
|
|
283
|
+
this.tabChangePromise = new Promise(
|
|
284
|
+
(res) => this.tabChangeResolver = res
|
|
285
|
+
);
|
|
258
286
|
setTimeout(this.updateCheckedState);
|
|
259
287
|
}
|
|
260
288
|
async getUpdateComplete() {
|
|
@@ -266,13 +294,19 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
266
294
|
super.connectedCallback();
|
|
267
295
|
window.addEventListener("resize", this.updateSelectionIndicator);
|
|
268
296
|
if ("fonts" in document) {
|
|
269
|
-
document.fonts.addEventListener(
|
|
297
|
+
document.fonts.addEventListener(
|
|
298
|
+
"loadingdone",
|
|
299
|
+
this.updateSelectionIndicator
|
|
300
|
+
);
|
|
270
301
|
}
|
|
271
302
|
}
|
|
272
303
|
disconnectedCallback() {
|
|
273
304
|
window.removeEventListener("resize", this.updateSelectionIndicator);
|
|
274
305
|
if ("fonts" in document) {
|
|
275
|
-
document.fonts.removeEventListener(
|
|
306
|
+
document.fonts.removeEventListener(
|
|
307
|
+
"loadingdone",
|
|
308
|
+
this.updateSelectionIndicator
|
|
309
|
+
);
|
|
276
310
|
}
|
|
277
311
|
super.disconnectedCallback();
|
|
278
312
|
}
|
|
@@ -280,6 +314,9 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
280
314
|
__decorateClass([
|
|
281
315
|
property({ type: Boolean })
|
|
282
316
|
], Tabs.prototype, "auto", 2);
|
|
317
|
+
__decorateClass([
|
|
318
|
+
property({ type: Boolean, reflect: true })
|
|
319
|
+
], Tabs.prototype, "compact", 2);
|
|
283
320
|
__decorateClass([
|
|
284
321
|
property({ reflect: true })
|
|
285
322
|
], Tabs.prototype, "direction", 2);
|
|
@@ -289,6 +326,9 @@ __decorateClass([
|
|
|
289
326
|
__decorateClass([
|
|
290
327
|
property()
|
|
291
328
|
], Tabs.prototype, "label", 2);
|
|
329
|
+
__decorateClass([
|
|
330
|
+
property({ type: Boolean, reflect: true })
|
|
331
|
+
], Tabs.prototype, "quiet", 2);
|
|
292
332
|
__decorateClass([
|
|
293
333
|
property({ attribute: false })
|
|
294
334
|
], Tabs.prototype, "selectionIndicatorStyle", 2);
|
package/src/Tabs.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Tabs.ts"],
|
|
4
|
-
"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.dev.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.dev.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 * @csspart tablist - Container element for the slotted sp-tab elements\n *\n * @fires change - The selected Tab child has changed.\n */\nexport class Tabs extends SizedMixin(Focusable) {\n public static override 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({ type: Boolean, reflect: true })\n public emphasized = false;\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 override get focusElement(): Tab | this {\n return this.rovingTabindexController.focusInElement || this;\n }\n\n protected override 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 override 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 part=\"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 override willUpdate(changes: PropertyValues): void {\n if (!this.hasUpdated) {\n const selectedChild = this.querySelector(\n ':scope > [selected]'\n ) as Tab;\n if (selectedChild) {\n this.selectTarget(selectedChild);\n }\n }\n\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\n if (this.direction === 'horizontal') {\n const width = tabBoundingClientRect.width;\n const offset = selectedElement.offsetLeft;\n\n this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${width});`;\n } else {\n const height = tabBoundingClientRect.height;\n const offset = selectedElement.offsetTop;\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 override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.tabChangePromise;\n return complete;\n }\n\n public override 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 override 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"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"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 { IntersectionController } from '@lit-labs/observers/intersection_controller.js';\nimport { Tab } from './Tab.dev.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.dev.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 * @csspart tablist - Container element for the slotted sp-tab elements\n *\n * @fires change - The selected Tab child has changed.\n */\nexport class Tabs extends SizedMixin(Focusable) {\n public static override 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 /**\n * The tab items are displayed closer together.\n */\n @property({ type: Boolean, reflect: true })\n public compact = false;\n\n @property({ reflect: true })\n public direction: 'vertical' | 'vertical-right' | 'horizontal' =\n 'horizontal';\n\n @property({ type: Boolean, reflect: true })\n public emphasized = false;\n\n @property()\n public label = '';\n\n /**\n * The tab list is displayed without a border.\n */\n @property({ type: Boolean, reflect: true })\n public quiet = false;\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 constructor() {\n super();\n new IntersectionController(this, {\n config: {\n root: null,\n rootMargin: \"0px\",\n threshold: [0, 1]\n },\n callback: () => {\n this.updateSelectionIndicator();\n }\n });\n }\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 override get focusElement(): Tab | this {\n return this.rovingTabindexController.focusInElement || this;\n }\n\n protected override 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 override 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 part=\"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 override willUpdate(changes: PropertyValues): void {\n if (!this.hasUpdated) {\n const selectedChild = this.querySelector(\n ':scope > [selected]'\n ) as Tab;\n if (selectedChild) {\n this.selectTarget(selectedChild);\n }\n }\n\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\n if (this.direction === 'horizontal') {\n const width = tabBoundingClientRect.width;\n const offset = selectedElement.offsetLeft;\n\n this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${width});`;\n } else {\n const height = tabBoundingClientRect.height;\n const offset = selectedElement.offsetTop;\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 override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.tabChangePromise;\n return complete;\n }\n\n public override 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 override 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EAEA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AAEvC,SAAS,iBAAiB;AAC1B,SAAS,gCAAgC;AAEzC,OAAO,eAAe;AAGtB,MAAM,mBAAmB;AAWlB,aAAM,aAAa,WAAW,SAAS,EAAE;AAAA,EA8E5C,cAAc;AACV,UAAM;AAjEV,SAAO,OAAO;AAMd,SAAO,UAAU;AAGjB,SAAO,YACH;AAGJ,SAAO,aAAa;AAGpB,SAAO,QAAQ;AAMf,SAAO,QAAQ;AAGf,SAAO,0BAA0B;AAGjC,SAAO,gBAAgB;AAsBvB,SAAQ,YAAY;AAYpB,SAAQ,QAAe,CAAC;AAgBxB,oCAA2B,IAAI,yBAA8B,MAAM;AAAA,MAC/D,cAAc,CAAC,aAAa;AACxB,YAAI,eAAe;AACnB,cAAM,wBAAwB,SAAS,KAAK,CAAC,IAAI,UAAU;AACvD,gBAAM,iBAAiB,KAAK,WACtB,CAAC,GAAG,YAAY,GAAG,UAAU,KAAK,WAClC,CAAC,GAAG;AACV,yBAAe;AACf,iBAAO;AAAA,QACX,CAAC;AACD,eAAO,wBAAwB,eAAe;AAAA,MAClD;AAAA,MACA,WAAW,MACP,KAAK,cAAc,eAAe,eAAe;AAAA,MACrD,oBAAoB,CAAC,OAAO;AACxB,YAAI,CAAC,KAAK;AAAM;AAEhB,aAAK,gBAAgB;AACrB,aAAK,aAAa,EAAE;AAAA,MACxB;AAAA,MACA,UAAU,MAAM,KAAK;AAAA,MACrB,oBAAoB,CAAC,OAAO,CAAC,GAAG;AAAA,MAChC,eAAe,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M,OAAO;AAAA,GA5CL,KA6CD;AAGG;AAAA,EADV,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GA/ClB,KAgDE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Tabs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
1
|
+
"use strict";var h=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var a=(d,l,e,t)=>{for(var i=t>1?void 0:t?p(l,e):l,s=d.length-1,r;s>=0;s--)(r=d[s])&&(i=(t?r(l,e,i):r(i))||i);return t&&i&&h(l,e,i),i};import{html as b,SizedMixin as f}from"@spectrum-web-components/base";import{property as o,query as m}from"@spectrum-web-components/base/src/decorators.js";import{ifDefined as c}from"@spectrum-web-components/base/src/directives.js";import{IntersectionController as v}from"@lit-labs/observers/intersection_controller.js";import{Focusable as g}from"@spectrum-web-components/shared";import{RovingTabindexController as C}from"@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";import S from"./tabs.css.js";const u="transform: translateX(0px) scaleX(0) scaleY(0)";export class Tabs extends f(g){constructor(){super();this.auto=!1;this.compact=!1;this.direction="horizontal";this.emphasized=!1;this.label="";this.quiet=!1;this.selectionIndicatorStyle=u;this.shouldAnimate=!1;this._selected="";this._tabs=[];this.rovingTabindexController=new C(this,{focusInIndex:e=>{let t=0;return e.find((s,r)=>{const n=this.selected?!s.disabled&&s.value===this.selected:!s.disabled;return t=r,n})?t:-1},direction:()=>this.direction==="horizontal"?"horizontal":"vertical",elementEnterAction:e=>{!this.auto||(this.shouldAnimate=!0,this.selectTarget(e))},elements:()=>this.tabs,isFocusableElement:e=>!e.disabled,listenerScope:()=>this.tabList});this.onClick=e=>{if(this.disabled)return;const t=e.composedPath().find(i=>i.parentElement===this);!t||t.disabled||(this.shouldAnimate=!0,this.selectTarget(t))};this.onKeyDown=e=>{if(e.code==="Enter"||e.code==="Space"){e.preventDefault();const t=e.target;t&&this.selectTarget(t)}};this.updateCheckedState=()=>{if(this.tabs.length||(this.tabs=[...this.querySelectorAll('[role="tab"]')]),this.tabs.forEach(e=>{e.removeAttribute("selected")}),this.selected){const e=this.tabs.find(t=>t.value===this.selected);e?e.selected=!0:this.selected=""}else{const e=this.tabs[0];e&&e.setAttribute("tabindex","0")}this.updateSelectionIndicator(),this.tabChangeResolver()};this.updateSelectionIndicator=async()=>{const e=this.tabs.find(i=>i.selected);if(!e){this.selectionIndicatorStyle=u;return}await Promise.all([e.updateComplete,document.fonts?document.fonts.ready:Promise.resolve()]);const t=e.getBoundingClientRect();if(this.direction==="horizontal"){const i=t.width,s=e.offsetLeft;this.selectionIndicatorStyle=`transform: translateX(${s}px) scaleX(${i});`}else{const i=t.height,s=e.offsetTop;this.selectionIndicatorStyle=`transform: translateY(${s}px) scaleY(${i});`}};this.tabChangePromise=Promise.resolve();this.tabChangeResolver=function(){};new v(this,{config:{root:null,rootMargin:"0px",threshold:[0,1]},callback:()=>{this.updateSelectionIndicator()}})}static get styles(){return[S]}get selected(){return this._selected}set selected(e){const t=this.selected;e!==t&&(this._selected=e,this.shouldUpdateCheckedState(),this.requestUpdate("selected",t))}set tabs(e){e!==this.tabs&&(this._tabs=e,this.rovingTabindexController.clearElementCache())}get tabs(){return this._tabs}get focusElement(){return this.rovingTabindexController.focusInElement||this}manageAutoFocus(){const t=[...this.children].map(i=>typeof i.updateComplete!="undefined"?i.updateComplete:Promise.resolve(!0));Promise.all(t).then(()=>super.manageAutoFocus())}managePanels({target:e}){e.assignedElements().map(i=>{const{value:s,id:r}=i,n=this.querySelector(`[role="tab"][value="${s}"]`);n&&(n.setAttribute("aria-controls",r),i.setAttribute("aria-labelledby",n.id)),i.selected=s===this.selected})}render(){return b`
|
|
2
2
|
<div
|
|
3
|
-
aria-label=${
|
|
3
|
+
aria-label=${c(this.label?this.label:void 0)}
|
|
4
4
|
@click=${this.onClick}
|
|
5
5
|
@keydown=${this.onKeyDown}
|
|
6
6
|
@sp-tab-contentchange=${this.updateSelectionIndicator}
|
|
@@ -11,11 +11,11 @@ var u=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var o=(n,e,t,i
|
|
|
11
11
|
<slot @slotchange=${this.onSlotChange}></slot>
|
|
12
12
|
<div
|
|
13
13
|
id="selection-indicator"
|
|
14
|
-
class=${
|
|
14
|
+
class=${c(this.shouldAnimate?void 0:"first-position")}
|
|
15
15
|
style=${this.selectionIndicatorStyle}
|
|
16
16
|
role="presentation"
|
|
17
17
|
></div>
|
|
18
18
|
</div>
|
|
19
19
|
<slot name="tab-panel" @slotchange=${this.managePanels}></slot>
|
|
20
|
-
`}willUpdate(e){if(!this.hasUpdated){const t=this.querySelector(":scope > [selected]");t&&this.selectTarget(t)}if(super.updated(e),e.has("selected")){if(e.get("selected")){const i=this.querySelector(`[role="tabpanel"][value="${e.get("selected")}"]`);i&&(i.selected=!1)}const t=this.querySelector(`[role="tabpanel"][value="${this.selected}"]`);t&&(t.selected=!0)}e.has("direction")&&(this.direction==="horizontal"?this.removeAttribute("aria-orientation"):this.setAttribute("aria-orientation","vertical")),e.has("dir")&&this.updateSelectionIndicator(),e.has("disabled")&&(this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")),!this.shouldAnimate&&typeof e.get("shouldAnimate")!="undefined"&&(this.shouldAnimate=!0)}selectTarget(e){const t=e.getAttribute("value");if(t){const i=this.selected;this.selected=t,this.dispatchEvent(new Event("change",{cancelable:!0}))||(this.selected=i)}}onSlotChange(){this.tabs=[...this.querySelectorAll('[role="tab"]')],this.shouldUpdateCheckedState()}shouldUpdateCheckedState(){this.tabChangeResolver(),this.tabChangePromise=new Promise(e=>this.tabChangeResolver=e),setTimeout(this.updateCheckedState)}async getUpdateComplete(){const e=await super.getUpdateComplete();return await this.tabChangePromise,e}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.updateSelectionIndicator),"fonts"in document&&document.fonts.addEventListener("loadingdone",this.updateSelectionIndicator)}disconnectedCallback(){window.removeEventListener("resize",this.updateSelectionIndicator),"fonts"in document&&document.fonts.removeEventListener("loadingdone",this.updateSelectionIndicator),super.disconnectedCallback()}}
|
|
20
|
+
`}willUpdate(e){if(!this.hasUpdated){const t=this.querySelector(":scope > [selected]");t&&this.selectTarget(t)}if(super.updated(e),e.has("selected")){if(e.get("selected")){const i=this.querySelector(`[role="tabpanel"][value="${e.get("selected")}"]`);i&&(i.selected=!1)}const t=this.querySelector(`[role="tabpanel"][value="${this.selected}"]`);t&&(t.selected=!0)}e.has("direction")&&(this.direction==="horizontal"?this.removeAttribute("aria-orientation"):this.setAttribute("aria-orientation","vertical")),e.has("dir")&&this.updateSelectionIndicator(),e.has("disabled")&&(this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")),!this.shouldAnimate&&typeof e.get("shouldAnimate")!="undefined"&&(this.shouldAnimate=!0)}selectTarget(e){const t=e.getAttribute("value");if(t){const i=this.selected;this.selected=t,this.dispatchEvent(new Event("change",{cancelable:!0}))||(this.selected=i)}}onSlotChange(){this.tabs=[...this.querySelectorAll('[role="tab"]')],this.shouldUpdateCheckedState()}shouldUpdateCheckedState(){this.tabChangeResolver(),this.tabChangePromise=new Promise(e=>this.tabChangeResolver=e),setTimeout(this.updateCheckedState)}async getUpdateComplete(){const e=await super.getUpdateComplete();return await this.tabChangePromise,e}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.updateSelectionIndicator),"fonts"in document&&document.fonts.addEventListener("loadingdone",this.updateSelectionIndicator)}disconnectedCallback(){window.removeEventListener("resize",this.updateSelectionIndicator),"fonts"in document&&document.fonts.removeEventListener("loadingdone",this.updateSelectionIndicator),super.disconnectedCallback()}}a([o({type:Boolean})],Tabs.prototype,"auto",2),a([o({type:Boolean,reflect:!0})],Tabs.prototype,"compact",2),a([o({reflect:!0})],Tabs.prototype,"direction",2),a([o({type:Boolean,reflect:!0})],Tabs.prototype,"emphasized",2),a([o()],Tabs.prototype,"label",2),a([o({type:Boolean,reflect:!0})],Tabs.prototype,"quiet",2),a([o({attribute:!1})],Tabs.prototype,"selectionIndicatorStyle",2),a([o({attribute:!1})],Tabs.prototype,"shouldAnimate",2),a([m("#list")],Tabs.prototype,"tabList",2),a([o({reflect:!0})],Tabs.prototype,"selected",1);
|
|
21
21
|
//# sourceMappingURL=Tabs.js.map
|
package/src/Tabs.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Tabs.ts"],
|
|
4
|
-
"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 * @csspart tablist - Container element for the slotted sp-tab elements\n *\n * @fires change - The selected Tab child has changed.\n */\nexport class Tabs extends SizedMixin(Focusable) {\n public static override 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({ type: Boolean, reflect: true })\n public emphasized = false;\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 override get focusElement(): Tab | this {\n return this.rovingTabindexController.focusInElement || this;\n }\n\n protected override 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 override 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 part=\"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 override willUpdate(changes: PropertyValues): void {\n if (!this.hasUpdated) {\n const selectedChild = this.querySelector(\n ':scope > [selected]'\n ) as Tab;\n if (selectedChild) {\n this.selectTarget(selectedChild);\n }\n }\n\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\n if (this.direction === 'horizontal') {\n const width = tabBoundingClientRect.width;\n const offset = selectedElement.offsetLeft;\n\n this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${width});`;\n } else {\n const height = tabBoundingClientRect.height;\n const offset = selectedElement.offsetTop;\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 override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.tabChangePromise;\n return complete;\n }\n\n public override 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 override 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"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"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 { IntersectionController } from '@lit-labs/observers/intersection_controller.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 * @csspart tablist - Container element for the slotted sp-tab elements\n *\n * @fires change - The selected Tab child has changed.\n */\nexport class Tabs extends SizedMixin(Focusable) {\n public static override 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 /**\n * The tab items are displayed closer together.\n */\n @property({ type: Boolean, reflect: true })\n public compact = false;\n\n @property({ reflect: true })\n public direction: 'vertical' | 'vertical-right' | 'horizontal' =\n 'horizontal';\n\n @property({ type: Boolean, reflect: true })\n public emphasized = false;\n\n @property()\n public label = '';\n\n /**\n * The tab list is displayed without a border.\n */\n @property({ type: Boolean, reflect: true })\n public quiet = false;\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 constructor() {\n super();\n new IntersectionController(this, {\n config: {\n root: null,\n rootMargin: \"0px\",\n threshold: [0, 1]\n },\n callback: () => {\n this.updateSelectionIndicator();\n }\n });\n }\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 override get focusElement(): Tab | this {\n return this.rovingTabindexController.focusInElement || this;\n }\n\n protected override 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 override 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 part=\"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 override willUpdate(changes: PropertyValues): void {\n if (!this.hasUpdated) {\n const selectedChild = this.querySelector(\n ':scope > [selected]'\n ) as Tab;\n if (selectedChild) {\n this.selectTarget(selectedChild);\n }\n }\n\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\n if (this.direction === 'horizontal') {\n const width = tabBoundingClientRect.width;\n const offset = selectedElement.offsetLeft;\n\n this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${width});`;\n } else {\n const height = tabBoundingClientRect.height;\n const offset = selectedElement.offsetTop;\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 override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.tabChangePromise;\n return complete;\n }\n\n public override 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 override 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"],
|
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,EAEA,cAAAC,MAEG,gCACP,OACI,YAAAC,EACA,SAAAC,MACG,kDACP,OAAS,aAAAC,MAAiB,kDAC1B,OAAS,0BAAAC,MAA8B,iDAEvC,OAAS,aAAAC,MAAiB,kCAC1B,OAAS,4BAAAC,MAAgC,sEAEzC,OAAOC,MAAe,gBAGtB,MAAMC,EAAmB,iDAWlB,aAAM,aAAaR,EAAWK,CAAS,CAAE,CA8E5C,aAAc,CACV,MAAM,EAjEV,KAAO,KAAO,GAMd,KAAO,QAAU,GAGjB,KAAO,UACH,aAGJ,KAAO,WAAa,GAGpB,KAAO,MAAQ,GAMf,KAAO,MAAQ,GAGf,KAAO,wBAA0BG,EAGjC,KAAO,cAAgB,GAsBvB,KAAQ,UAAY,GAYpB,KA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,CAC/B,CACJ,CA9WWC,EAAA,CADNrC,EAAS,CAAE,KAAM,OAAQ,CAAC,GAblB,KAcF,oBAMAqC,EAAA,CADNrC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAnBjC,KAoBF,uBAGAqC,EAAA,CADNrC,EAAS,CAAE,QAAS,EAAK,CAAC,GAtBlB,KAuBF,yBAIAqC,EAAA,CADNrC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GA1BjC,KA2BF,0BAGAqC,EAAA,CADNrC,EAAS,GA7BD,KA8BF,qBAMAqC,EAAA,CADNrC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAnCjC,KAoCF,qBAGAqC,EAAA,CADNrC,EAAS,CAAE,UAAW,EAAM,CAAC,GAtCrB,KAuCF,uCAGAqC,EAAA,CADNrC,EAAS,CAAE,UAAW,EAAM,CAAC,GAzCrB,KA0CF,6BAGCqC,EAAA,CADPpC,EAAM,OAAO,GA5CL,KA6CD,uBAGGoC,EAAA,CADVrC,EAAS,CAAE,QAAS,EAAK,CAAC,GA/ClB,KAgDE",
|
|
6
|
+
"names": ["html", "SizedMixin", "property", "query", "ifDefined", "IntersectionController", "Focusable", "RovingTabindexController", "tabStyles", "noSelectionStyle", "elements", "focusInIndex", "el", "index", "focusInElement", "event", "target", "element", "currentChecked", "firstTab", "selectedElement", "tabBoundingClientRect", "width", "offset", "height", "value", "oldValue", "tabs", "tabUpdateCompletes", "tab", "panel", "id", "changes", "selectedChild", "previous", "next", "selected", "res", "complete", "__decorateClass"]
|
|
7
7
|
}
|
package/src/index.dev.js
CHANGED
package/src/index.dev.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
4
|
"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.dev.js'\nexport * from './Tab.dev.js'\nexport * from './TabPanel.dev.js'\n"],
|
|
5
|
-
"mappings": "AAYA;
|
|
5
|
+
"mappings": ";AAYA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./Tabs.js";export*from"./Tab.js";export*from"./TabPanel.js";
|
|
1
|
+
"use strict";export*from"./Tabs.js";export*from"./Tab.js";export*from"./TabPanel.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
4
|
"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"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "aAYA,WAAc,YACd,WAAc,WACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
import { css } from "@spectrum-web-components/base";
|
|
2
3
|
const styles = css`
|
|
3
4
|
: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(
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["spectrum-tab.css.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2022 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}::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)}::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;"],
|
|
5
|
-
"mappings": "AAWA;
|
|
5
|
+
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCf,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/spectrum-tab.css.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{css as t}from"@spectrum-web-components/base";const e=t`
|
|
1
|
+
"use strict";import{css as t}from"@spectrum-web-components/base";const e=t`
|
|
2
2
|
: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(
|
|
3
3
|
--spectrum-tabs-texticon-tabitem-selection-indicator-animation-duration
|
|
4
4
|
) ease-out;white-space:nowrap;z-index:1}:host([disabled]){cursor:default}:host([disabled]) #item-label{cursor:default}::slotted([slot=icon]){height:var(
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["spectrum-tab.css.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2022 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}::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)}::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;"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqCf,eAAeC",
|
|
6
|
+
"names": ["css", "styles"]
|
|
7
7
|
}
|