@spectrum-web-components/tabs 0.8.4 → 0.8.6
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/custom-elements.json +5 -5
- package/package.json +6 -6
- package/sp-tab-panel.d.ts +0 -6
- package/sp-tab-panel.js +0 -14
- package/sp-tab-panel.js.map +0 -1
- package/sp-tab.d.ts +0 -6
- package/sp-tab.js +0 -14
- package/sp-tab.js.map +0 -1
- package/sp-tabs.d.ts +0 -6
- package/sp-tabs.js +0 -14
- package/sp-tabs.js.map +0 -1
- package/src/Tab.d.ts +0 -33
- package/src/Tab.js +0 -112
- package/src/Tab.js.map +0 -1
- package/src/TabPanel.d.ts +0 -18
- package/src/TabPanel.js +0 -64
- package/src/TabPanel.js.map +0 -1
- package/src/Tabs.d.ts +0 -66
- package/src/Tabs.js +0 -322
- package/src/Tabs.js.map +0 -1
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -15
- package/src/index.js.map +0 -1
- package/src/spectrum-tab.css.d.ts +0 -2
- package/src/spectrum-tab.css.js +0 -47
- package/src/spectrum-tab.css.js.map +0 -1
- package/src/spectrum-tabs.css.d.ts +0 -2
- package/src/spectrum-tabs.css.js +0 -207
- package/src/spectrum-tabs.css.js.map +0 -1
- package/src/tab-panel.css.d.ts +0 -2
- package/src/tab-panel.css.js +0 -17
- package/src/tab-panel.css.js.map +0 -1
- package/src/tab.css.d.ts +0 -2
- package/src/tab.css.js +0 -57
- package/src/tab.css.js.map +0 -1
- package/src/tabs.css.d.ts +0 -2
- package/src/tabs.css.js +0 -221
- package/src/tabs.css.js.map +0 -1
- package/stories/tabs-horizontal-sizes.stories.js +0 -101
- package/stories/tabs-horizontal-sizes.stories.js.map +0 -1
- package/stories/tabs-vertical-right-sizes.stories.js +0 -98
- package/stories/tabs-vertical-right-sizes.stories.js.map +0 -1
- package/stories/tabs-vertical-sizes.stories.js +0 -98
- package/stories/tabs-vertical-sizes.stories.js.map +0 -1
- package/stories/tab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,CAAC,QAAQ,EAAE;gBACf,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;aAC9C;iBAAM;gBACH,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;aACzC;SACJ;IACL,CAAC;;AA1FD;;GAEG;AACI,iBAAa,GAAG,CAAC,CAAC;AAWzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCACnB;AAGxB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kCACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCACnB;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCACnB;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kCACxB","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 SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport {\n FocusVisiblePolyfillMixin,\n ObserveSlotPresence,\n ObserveSlotText,\n} from '@spectrum-web-components/shared';\n\nimport tabItemStyles from './tab.css.js';\n\n/**\n * @element sp-tab\n *\n * @slot - text label of the Tab\n * @slot icon - The icon that appears on the left of the label\n */\nexport class Tab extends FocusVisiblePolyfillMixin(\n ObserveSlotText(ObserveSlotPresence(SpectrumElement, '[slot=\"icon\"]'), '')\n) {\n public static get styles(): CSSResultArray {\n return [tabItemStyles];\n }\n\n /**\n * @private\n */\n static instanceCount = 0;\n\n protected get hasIcon(): boolean {\n return this.slotContentIsPresent;\n }\n\n protected get hasLabel(): boolean {\n return !!this.label || this.slotHasContent;\n }\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ reflect: true })\n public label = '';\n\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n @property({ type: Boolean, reflect: true })\n public vertical = false;\n\n @property({ type: String, reflect: true })\n public value = '';\n\n protected handleContentChange(): void {\n /**\n * When the content in a tab has changed, JS powered layout related to that content may also need to be changed.\n */\n this.dispatchEvent(\n new Event('sp-tab-contentchange', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n protected render(): TemplateResult {\n return html`\n ${this.hasIcon\n ? html`\n <slot name=\"icon\"></slot>\n `\n : html``}\n <label id=\"item-label\" ?hidden=${!this.hasLabel}>\n ${this.slotHasContent ? html`` : this.label}\n <slot>${this.label}</slot>\n </label>\n `;\n }\n\n protected firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('role', 'tab');\n if (!this.hasAttribute('id')) {\n this.id = `sp-tab-${Tab.instanceCount++}`;\n }\n // @TODO - refactor this as a ResizeObserver up to `sp-tabs` so that it can be more\n // resiliant to Tab content changes, as well as other content slotted into the \"tablist\".\n this.shadowRoot.addEventListener(\n 'slotchange',\n this.handleContentChange\n );\n }\n\n protected updated(changes: PropertyValues): void {\n super.updated(changes);\n if (\n changes.has('label') &&\n typeof changes.get('label') !== 'undefined'\n ) {\n this.handleContentChange();\n }\n if (changes.has('selected')) {\n this.setAttribute(\n 'aria-selected',\n this.selected ? 'true' : 'false'\n );\n this.setAttribute('tabindex', this.selected ? '0' : '-1');\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 }\n}\n"]}
|
package/src/TabPanel.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
-
/**
|
|
3
|
-
* @element sp-tab-panel
|
|
4
|
-
*
|
|
5
|
-
* @slot - content of the Tab Panel
|
|
6
|
-
*/
|
|
7
|
-
export declare class TabPanel extends SpectrumElement {
|
|
8
|
-
static styles: import("@spectrum-web-components/base").CSSResult[];
|
|
9
|
-
/**
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
12
|
-
static instanceCount: number;
|
|
13
|
-
selected: boolean;
|
|
14
|
-
value: string;
|
|
15
|
-
protected render(): TemplateResult;
|
|
16
|
-
protected firstUpdated(): void;
|
|
17
|
-
protected updated(changes: PropertyValues<this>): void;
|
|
18
|
-
}
|
package/src/TabPanel.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
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, SpectrumElement, } from '@spectrum-web-components/base';
|
|
14
|
-
import { property } from '@spectrum-web-components/base/src/decorators.js';
|
|
15
|
-
import panelStyles from './tab-panel.css.js';
|
|
16
|
-
/**
|
|
17
|
-
* @element sp-tab-panel
|
|
18
|
-
*
|
|
19
|
-
* @slot - content of the Tab Panel
|
|
20
|
-
*/
|
|
21
|
-
export class TabPanel extends SpectrumElement {
|
|
22
|
-
constructor() {
|
|
23
|
-
super(...arguments);
|
|
24
|
-
this.selected = false;
|
|
25
|
-
this.value = '';
|
|
26
|
-
}
|
|
27
|
-
render() {
|
|
28
|
-
return html `
|
|
29
|
-
<slot></slot>
|
|
30
|
-
`;
|
|
31
|
-
}
|
|
32
|
-
firstUpdated() {
|
|
33
|
-
this.slot = 'tab-panel';
|
|
34
|
-
this.setAttribute('role', 'tabpanel');
|
|
35
|
-
this.tabIndex = 0;
|
|
36
|
-
if (!this.hasAttribute('id')) {
|
|
37
|
-
this.id = `sp-tab-panel-${TabPanel.instanceCount++}`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
updated(changes) {
|
|
41
|
-
if (changes.has('selected')) {
|
|
42
|
-
if (this.selected) {
|
|
43
|
-
this.removeAttribute('aria-hidden');
|
|
44
|
-
this.tabIndex = 0;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
this.setAttribute('aria-hidden', 'true');
|
|
48
|
-
this.tabIndex = -1;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
TabPanel.styles = [panelStyles];
|
|
54
|
-
/**
|
|
55
|
-
* @private
|
|
56
|
-
*/
|
|
57
|
-
TabPanel.instanceCount = 0;
|
|
58
|
-
__decorate([
|
|
59
|
-
property({ type: Boolean, reflect: true })
|
|
60
|
-
], TabPanel.prototype, "selected", void 0);
|
|
61
|
-
__decorate([
|
|
62
|
-
property({ type: String, reflect: true })
|
|
63
|
-
], TabPanel.prototype, "value", void 0);
|
|
64
|
-
//# sourceMappingURL=TabPanel.js.map
|
package/src/TabPanel.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanel.js","sourceRoot":"","sources":["TabPanel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EACH,IAAI,E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,OAAO,EAAE,IAAI,EAAE,CAAC;uCACxB","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 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 render(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected 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 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"]}
|
package/src/Tabs.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { CSSResultArray, PropertyValues, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
-
import { Tab } from './Tab.js';
|
|
3
|
-
import { Focusable } from '@spectrum-web-components/shared';
|
|
4
|
-
import { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';
|
|
5
|
-
declare const Tabs_base: typeof Focusable & {
|
|
6
|
-
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
|
7
|
-
prototype: import("@spectrum-web-components/base").SizedElementInterface;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* @element sp-tabs
|
|
11
|
-
*
|
|
12
|
-
* @slot - Tab elements to manage as a group
|
|
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
|
-
*
|
|
17
|
-
* @fires change - The selected Tab child has changed.
|
|
18
|
-
*/
|
|
19
|
-
export declare class Tabs extends Tabs_base {
|
|
20
|
-
static get styles(): CSSResultArray;
|
|
21
|
-
/**
|
|
22
|
-
* Whether to activate a tab on keyboard focus or not.
|
|
23
|
-
*
|
|
24
|
-
* By default a tab is activated via a "click" interaction. This is specifically intended for when
|
|
25
|
-
* tab content cannot be displayed instantly, e.g. not all of the DOM content is available, etc.
|
|
26
|
-
* To learn more about "Deciding When to Make Selection Automatically Follow Focus", visit:
|
|
27
|
-
* https://w3c.github.io/aria-practices/#kbd_selection_follows_focus
|
|
28
|
-
*/
|
|
29
|
-
auto: boolean;
|
|
30
|
-
direction: 'vertical' | 'vertical-right' | 'horizontal';
|
|
31
|
-
label: string;
|
|
32
|
-
selectionIndicatorStyle: string;
|
|
33
|
-
shouldAnimate: boolean;
|
|
34
|
-
private tabList;
|
|
35
|
-
get selected(): string;
|
|
36
|
-
set selected(value: string);
|
|
37
|
-
private _selected;
|
|
38
|
-
private set tabs(value);
|
|
39
|
-
private get tabs();
|
|
40
|
-
private _tabs;
|
|
41
|
-
rovingTabindexController: RovingTabindexController<Tab>;
|
|
42
|
-
/**
|
|
43
|
-
* @private
|
|
44
|
-
*/
|
|
45
|
-
get focusElement(): Tab | this;
|
|
46
|
-
protected manageAutoFocus(): void;
|
|
47
|
-
protected managePanels({ target, }: Event & {
|
|
48
|
-
target: HTMLSlotElement;
|
|
49
|
-
}): void;
|
|
50
|
-
protected render(): TemplateResult;
|
|
51
|
-
protected firstUpdated(changes: PropertyValues): void;
|
|
52
|
-
protected updated(changes: PropertyValues<this>): void;
|
|
53
|
-
private onClick;
|
|
54
|
-
private onKeyDown;
|
|
55
|
-
private selectTarget;
|
|
56
|
-
private onSlotChange;
|
|
57
|
-
private shouldUpdateCheckedState;
|
|
58
|
-
private updateCheckedState;
|
|
59
|
-
private updateSelectionIndicator;
|
|
60
|
-
private tabChangePromise;
|
|
61
|
-
private tabChangeResolver;
|
|
62
|
-
protected getUpdateComplete(): Promise<boolean>;
|
|
63
|
-
connectedCallback(): void;
|
|
64
|
-
disconnectedCallback(): void;
|
|
65
|
-
}
|
|
66
|
-
export {};
|
package/src/Tabs.js
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
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
|
-
elements: () => this.tabs,
|
|
62
|
-
isFocusableElement: (el) => !el.disabled,
|
|
63
|
-
listenerScope: () => this.tabList,
|
|
64
|
-
});
|
|
65
|
-
this.onClick = (event) => {
|
|
66
|
-
if (this.disabled) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const target = event
|
|
70
|
-
.composedPath()
|
|
71
|
-
.find((el) => el.parentElement === this);
|
|
72
|
-
if (!target || target.disabled) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
this.shouldAnimate = true;
|
|
76
|
-
this.selectTarget(target);
|
|
77
|
-
};
|
|
78
|
-
this.onKeyDown = (event) => {
|
|
79
|
-
if (event.code === 'Enter' || event.code === 'Space') {
|
|
80
|
-
event.preventDefault();
|
|
81
|
-
const target = event.target;
|
|
82
|
-
if (target) {
|
|
83
|
-
this.selectTarget(target);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
this.updateCheckedState = () => {
|
|
88
|
-
if (!this.tabs.length) {
|
|
89
|
-
this.tabs = [...this.querySelectorAll('[role="tab"]')];
|
|
90
|
-
}
|
|
91
|
-
this.tabs.forEach((element) => {
|
|
92
|
-
element.removeAttribute('selected');
|
|
93
|
-
});
|
|
94
|
-
if (this.selected) {
|
|
95
|
-
const currentChecked = this.tabs.find((el) => el.value === this.selected);
|
|
96
|
-
if (currentChecked) {
|
|
97
|
-
currentChecked.selected = true;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
this.selected = '';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
const firstTab = this.tabs[0];
|
|
105
|
-
if (firstTab) {
|
|
106
|
-
firstTab.setAttribute('tabindex', '0');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
this.updateSelectionIndicator();
|
|
110
|
-
this.tabChangeResolver();
|
|
111
|
-
};
|
|
112
|
-
this.updateSelectionIndicator = async () => {
|
|
113
|
-
const selectedElement = this.tabs.find((el) => el.selected);
|
|
114
|
-
if (!selectedElement) {
|
|
115
|
-
this.selectionIndicatorStyle = noSelectionStyle;
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
await Promise.all([
|
|
119
|
-
selectedElement.updateComplete,
|
|
120
|
-
document.fonts ? document.fonts.ready : Promise.resolve(),
|
|
121
|
-
]);
|
|
122
|
-
const tabBoundingClientRect = selectedElement.getBoundingClientRect();
|
|
123
|
-
const parentBoundingClientRect = this.getBoundingClientRect();
|
|
124
|
-
if (this.direction === 'horizontal') {
|
|
125
|
-
const width = tabBoundingClientRect.width;
|
|
126
|
-
const offset = this.dir === 'ltr'
|
|
127
|
-
? tabBoundingClientRect.left - parentBoundingClientRect.left
|
|
128
|
-
: tabBoundingClientRect.right -
|
|
129
|
-
parentBoundingClientRect.right;
|
|
130
|
-
this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${this.dir === 'ltr' ? width : -1 * width});`;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
const height = tabBoundingClientRect.height;
|
|
134
|
-
const offset = tabBoundingClientRect.top - parentBoundingClientRect.top;
|
|
135
|
-
this.selectionIndicatorStyle = `transform: translateY(${offset}px) scaleY(${height});`;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
this.tabChangePromise = Promise.resolve();
|
|
139
|
-
this.tabChangeResolver = function () {
|
|
140
|
-
return;
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
static get styles() {
|
|
144
|
-
return [tabStyles];
|
|
145
|
-
}
|
|
146
|
-
get selected() {
|
|
147
|
-
return this._selected;
|
|
148
|
-
}
|
|
149
|
-
set selected(value) {
|
|
150
|
-
const oldValue = this.selected;
|
|
151
|
-
if (value === oldValue) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
this._selected = value;
|
|
155
|
-
this.shouldUpdateCheckedState();
|
|
156
|
-
this.requestUpdate('selected', oldValue);
|
|
157
|
-
}
|
|
158
|
-
set tabs(tabs) {
|
|
159
|
-
if (tabs === this.tabs)
|
|
160
|
-
return;
|
|
161
|
-
this._tabs = tabs;
|
|
162
|
-
this.rovingTabindexController.clearElementCache();
|
|
163
|
-
}
|
|
164
|
-
get tabs() {
|
|
165
|
-
return this._tabs;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* @private
|
|
169
|
-
*/
|
|
170
|
-
get focusElement() {
|
|
171
|
-
return this.rovingTabindexController.focusInElement || this;
|
|
172
|
-
}
|
|
173
|
-
manageAutoFocus() {
|
|
174
|
-
const tabs = [...this.children];
|
|
175
|
-
const tabUpdateCompletes = tabs.map((tab) => {
|
|
176
|
-
if (typeof tab.updateComplete !== 'undefined') {
|
|
177
|
-
return tab.updateComplete;
|
|
178
|
-
}
|
|
179
|
-
return Promise.resolve(true);
|
|
180
|
-
});
|
|
181
|
-
Promise.all(tabUpdateCompletes).then(() => super.manageAutoFocus());
|
|
182
|
-
}
|
|
183
|
-
managePanels({ target, }) {
|
|
184
|
-
const panels = target.assignedElements();
|
|
185
|
-
panels.map((panel) => {
|
|
186
|
-
const { value, id } = panel;
|
|
187
|
-
const tab = this.querySelector(`[role="tab"][value="${value}"]`);
|
|
188
|
-
if (tab) {
|
|
189
|
-
tab.setAttribute('aria-controls', id);
|
|
190
|
-
panel.setAttribute('aria-labelledby', tab.id);
|
|
191
|
-
}
|
|
192
|
-
panel.selected = value === this.selected;
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
render() {
|
|
196
|
-
return html `
|
|
197
|
-
<div
|
|
198
|
-
aria-label=${ifDefined(this.label ? this.label : undefined)}
|
|
199
|
-
@click=${this.onClick}
|
|
200
|
-
@keydown=${this.onKeyDown}
|
|
201
|
-
@sp-tab-contentchange=${this.updateSelectionIndicator}
|
|
202
|
-
id="list"
|
|
203
|
-
role="tablist"
|
|
204
|
-
>
|
|
205
|
-
<slot @slotchange=${this.onSlotChange}></slot>
|
|
206
|
-
<div
|
|
207
|
-
id="selection-indicator"
|
|
208
|
-
class=${ifDefined(this.shouldAnimate ? undefined : 'first-position')}
|
|
209
|
-
style=${this.selectionIndicatorStyle}
|
|
210
|
-
role="presentation"
|
|
211
|
-
></div>
|
|
212
|
-
</div>
|
|
213
|
-
<slot name="tab-panel" @slotchange=${this.managePanels}></slot>
|
|
214
|
-
`;
|
|
215
|
-
}
|
|
216
|
-
firstUpdated(changes) {
|
|
217
|
-
super.firstUpdated(changes);
|
|
218
|
-
const selectedChild = this.querySelector(':scope > [selected]');
|
|
219
|
-
if (selectedChild) {
|
|
220
|
-
this.selectTarget(selectedChild);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
updated(changes) {
|
|
224
|
-
super.updated(changes);
|
|
225
|
-
if (changes.has('selected')) {
|
|
226
|
-
if (changes.get('selected')) {
|
|
227
|
-
const previous = this.querySelector(`[role="tabpanel"][value="${changes.get('selected')}"]`);
|
|
228
|
-
if (previous)
|
|
229
|
-
previous.selected = false;
|
|
230
|
-
}
|
|
231
|
-
const next = this.querySelector(`[role="tabpanel"][value="${this.selected}"]`);
|
|
232
|
-
if (next)
|
|
233
|
-
next.selected = true;
|
|
234
|
-
}
|
|
235
|
-
if (changes.has('direction')) {
|
|
236
|
-
if (this.direction === 'horizontal') {
|
|
237
|
-
this.removeAttribute('aria-orientation');
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
this.setAttribute('aria-orientation', 'vertical');
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (changes.has('dir')) {
|
|
244
|
-
this.updateSelectionIndicator();
|
|
245
|
-
}
|
|
246
|
-
if (changes.has('disabled')) {
|
|
247
|
-
if (this.disabled) {
|
|
248
|
-
this.setAttribute('aria-disabled', 'true');
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
this.removeAttribute('aria-disabled');
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
if (!this.shouldAnimate &&
|
|
255
|
-
typeof changes.get('shouldAnimate') !== 'undefined') {
|
|
256
|
-
this.shouldAnimate = true;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
selectTarget(target) {
|
|
260
|
-
const value = target.getAttribute('value');
|
|
261
|
-
if (value) {
|
|
262
|
-
const selected = this.selected;
|
|
263
|
-
this.selected = value;
|
|
264
|
-
const applyDefault = this.dispatchEvent(new Event('change', {
|
|
265
|
-
cancelable: true,
|
|
266
|
-
}));
|
|
267
|
-
if (!applyDefault) {
|
|
268
|
-
this.selected = selected;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
onSlotChange() {
|
|
273
|
-
this.tabs = [...this.querySelectorAll('[role="tab"]')];
|
|
274
|
-
this.shouldUpdateCheckedState();
|
|
275
|
-
}
|
|
276
|
-
shouldUpdateCheckedState() {
|
|
277
|
-
this.tabChangeResolver();
|
|
278
|
-
this.tabChangePromise = new Promise((res) => (this.tabChangeResolver = res));
|
|
279
|
-
setTimeout(this.updateCheckedState);
|
|
280
|
-
}
|
|
281
|
-
async getUpdateComplete() {
|
|
282
|
-
const complete = (await super.getUpdateComplete());
|
|
283
|
-
await this.tabChangePromise;
|
|
284
|
-
return complete;
|
|
285
|
-
}
|
|
286
|
-
connectedCallback() {
|
|
287
|
-
super.connectedCallback();
|
|
288
|
-
window.addEventListener('resize', this.updateSelectionIndicator);
|
|
289
|
-
if ('fonts' in document) {
|
|
290
|
-
document.fonts.addEventListener('loadingdone', this.updateSelectionIndicator);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
disconnectedCallback() {
|
|
294
|
-
window.removeEventListener('resize', this.updateSelectionIndicator);
|
|
295
|
-
if ('fonts' in document) {
|
|
296
|
-
document.fonts.removeEventListener('loadingdone', this.updateSelectionIndicator);
|
|
297
|
-
}
|
|
298
|
-
super.disconnectedCallback();
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
__decorate([
|
|
302
|
-
property({ type: Boolean })
|
|
303
|
-
], Tabs.prototype, "auto", void 0);
|
|
304
|
-
__decorate([
|
|
305
|
-
property({ reflect: true })
|
|
306
|
-
], Tabs.prototype, "direction", void 0);
|
|
307
|
-
__decorate([
|
|
308
|
-
property()
|
|
309
|
-
], Tabs.prototype, "label", void 0);
|
|
310
|
-
__decorate([
|
|
311
|
-
property({ attribute: false })
|
|
312
|
-
], Tabs.prototype, "selectionIndicatorStyle", void 0);
|
|
313
|
-
__decorate([
|
|
314
|
-
property({ attribute: false })
|
|
315
|
-
], Tabs.prototype, "shouldAnimate", void 0);
|
|
316
|
-
__decorate([
|
|
317
|
-
query('#list')
|
|
318
|
-
], Tabs.prototype, "tabList", void 0);
|
|
319
|
-
__decorate([
|
|
320
|
-
property({ reflect: true })
|
|
321
|
-
], Tabs.prototype, "selected", null);
|
|
322
|
-
//# sourceMappingURL=Tabs.js.map
|
package/src/Tabs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,U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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: Tab[]) => {\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 elements: () => this.tabs,\n isFocusableElement: (el: Tab) => !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
DELETED
package/src/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
package/src/spectrum-tab.css.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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-item-height);line-height:var(--spectrum-tabs-item-height);outline:none;position:relative;text-decoration:none;transition:color var(--spectrum-global-animation-duration-100,.13s) 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(
|
|
15
|
-
--spectrum-tabs-item-height
|
|
16
|
-
)}:host([dir=ltr]) slot[name=icon]+#item-label{margin-left:calc(var(--spectrum-tabs-icon-gap) - var(--spectrum-global-dimension-size-40))}:host([dir=rtl]) slot[name=icon]+#item-label{margin-right:calc(var(--spectrum-tabs-icon-gap) - var(--spectrum-global-dimension-size-40))}:host([dir=ltr]):before{left:calc(var(--spectrum-tabs-focus-ring-padding-x)*-1)}:host([dir=rtl]):before{right:calc(var(--spectrum-tabs-focus-ring-padding-x)*-1)}:host([dir=ltr]):before{right:calc(var(--spectrum-tabs-focus-ring-padding-x)*-1)}:host([dir=rtl]):before{left:calc(var(--spectrum-tabs-focus-ring-padding-x)*-1)}:host:before{border:var(--spectrum-tabs-focus-ring-size) solid transparent;border-radius:var(--spectrum-tabs-focus-ring-border-radius);box-sizing:border-box;content:"";height:var(--spectrum-tabs-focus-ring-height);margin-top:calc(var(--spectrum-tabs-focus-ring-height)/-2 + var(--spectrum-tabs-divider-size)/2);pointer-events:none;position:absolute;top:50%}#item-label{cursor:pointer;display:inline-block;font-size:var(--spectrum-tabs-text-size);font-weight:var(--spectrum-tabs-text-font-weight);text-decoration:none;vertical-align:top}#item-label:empty{display:none}:host{color:var(
|
|
17
|
-
--spectrum-tabs-m-text-color,var(--spectrum-alias-label-text-color)
|
|
18
|
-
)}:host(:not([vertical])) ::slotted([slot=icon]){color:var(
|
|
19
|
-
--spectrum-tabs-m-icon-color,var(--spectrum-alias-icon-color)
|
|
20
|
-
)}:host(:hover){color:var(
|
|
21
|
-
--spectrum-tabs-m-text-color-hover,var(--spectrum-alias-text-color-hover)
|
|
22
|
-
)}:host(:hover) ::slotted([slot=icon]){color:var(
|
|
23
|
-
--spectrum-tabs-m-icon-color-hover,var(--spectrum-alias-icon-color-hover)
|
|
24
|
-
)}:host([selected]){color:var(
|
|
25
|
-
--spectrum-tabs-m-text-color-selected,var(--spectrum-global-color-gray-900)
|
|
26
|
-
)}:host([selected]) ::slotted([slot=icon]){color:var(
|
|
27
|
-
--spectrum-tabs-m-icon-color-selected,var(--spectrum-global-color-gray-900)
|
|
28
|
-
)}:host(.focus-visible){color:var(
|
|
29
|
-
--spectrum-tabs-m-text-color-key-focus,var(--spectrum-alias-text-color-hover)
|
|
30
|
-
)}:host(:focus-visible){color:var(
|
|
31
|
-
--spectrum-tabs-m-text-color-key-focus,var(--spectrum-alias-text-color-hover)
|
|
32
|
-
)}:host(.focus-visible):before{border-color:var(
|
|
33
|
-
--spectrum-tabs-m-focus-ring-color,var(--spectrum-alias-border-color-key-focus)
|
|
34
|
-
)}:host(:focus-visible):before{border-color:var(
|
|
35
|
-
--spectrum-tabs-m-focus-ring-color,var(--spectrum-alias-border-color-key-focus)
|
|
36
|
-
)}:host(.focus-visible) ::slotted([slot=icon]){color:var(
|
|
37
|
-
--spectrum-tabs-m-icon-color-key-focus,var(--spectrum-alias-icon-color-key-focus)
|
|
38
|
-
)}:host(:focus-visible) ::slotted([slot=icon]){color:var(
|
|
39
|
-
--spectrum-tabs-m-icon-color-key-focus,var(--spectrum-alias-icon-color-key-focus)
|
|
40
|
-
)}:host([disabled]){color:var(
|
|
41
|
-
--spectrum-tabs-m-text-color-disabled,var(--spectrum-alias-text-color-disabled)
|
|
42
|
-
)}:host([disabled]) ::slotted([slot=icon]){color:var(
|
|
43
|
-
--spectrum-tabs-m-icon-color-disabled,var(--spectrum-alias-icon-color-disabled)
|
|
44
|
-
)}
|
|
45
|
-
`;
|
|
46
|
-
export default styles;
|
|
47
|
-
//# sourceMappingURL=spectrum-tab.css.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCjB,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-item-height);line-height:var(--spectrum-tabs-item-height);outline:none;position:relative;text-decoration:none;transition:color var(--spectrum-global-animation-duration-100,.13s) 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-item-height\n)}:host([dir=ltr]) slot[name=icon]+#item-label{margin-left:calc(var(--spectrum-tabs-icon-gap) - var(--spectrum-global-dimension-size-40))}:host([dir=rtl]) slot[name=icon]+#item-label{margin-right:calc(var(--spectrum-tabs-icon-gap) - var(--spectrum-global-dimension-size-40))}:host([dir=ltr]):before{left:calc(var(--spectrum-tabs-focus-ring-padding-x)*-1)}:host([dir=rtl]):before{right:calc(var(--spectrum-tabs-focus-ring-padding-x)*-1)}:host([dir=ltr]):before{right:calc(var(--spectrum-tabs-focus-ring-padding-x)*-1)}:host([dir=rtl]):before{left:calc(var(--spectrum-tabs-focus-ring-padding-x)*-1)}:host:before{border:var(--spectrum-tabs-focus-ring-size) solid transparent;border-radius:var(--spectrum-tabs-focus-ring-border-radius);box-sizing:border-box;content:\"\";height:var(--spectrum-tabs-focus-ring-height);margin-top:calc(var(--spectrum-tabs-focus-ring-height)/-2 + var(--spectrum-tabs-divider-size)/2);pointer-events:none;position:absolute;top:50%}#item-label{cursor:pointer;display:inline-block;font-size:var(--spectrum-tabs-text-size);font-weight:var(--spectrum-tabs-text-font-weight);text-decoration:none;vertical-align:top}#item-label:empty{display:none}:host{color:var(\n--spectrum-tabs-m-text-color,var(--spectrum-alias-label-text-color)\n)}:host(:not([vertical])) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-m-icon-color,var(--spectrum-alias-icon-color)\n)}:host(:hover){color:var(\n--spectrum-tabs-m-text-color-hover,var(--spectrum-alias-text-color-hover)\n)}:host(:hover) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-m-icon-color-hover,var(--spectrum-alias-icon-color-hover)\n)}:host([selected]){color:var(\n--spectrum-tabs-m-text-color-selected,var(--spectrum-global-color-gray-900)\n)}:host([selected]) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-m-icon-color-selected,var(--spectrum-global-color-gray-900)\n)}:host(.focus-visible){color:var(\n--spectrum-tabs-m-text-color-key-focus,var(--spectrum-alias-text-color-hover)\n)}:host(:focus-visible){color:var(\n--spectrum-tabs-m-text-color-key-focus,var(--spectrum-alias-text-color-hover)\n)}:host(.focus-visible):before{border-color:var(\n--spectrum-tabs-m-focus-ring-color,var(--spectrum-alias-border-color-key-focus)\n)}:host(:focus-visible):before{border-color:var(\n--spectrum-tabs-m-focus-ring-color,var(--spectrum-alias-border-color-key-focus)\n)}:host(.focus-visible) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-m-icon-color-key-focus,var(--spectrum-alias-icon-color-key-focus)\n)}:host(:focus-visible) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-m-icon-color-key-focus,var(--spectrum-alias-icon-color-key-focus)\n)}:host([disabled]){color:var(\n--spectrum-tabs-m-text-color-disabled,var(--spectrum-alias-text-color-disabled)\n)}:host([disabled]) ::slotted([slot=icon]){color:var(\n--spectrum-tabs-m-icon-color-disabled,var(--spectrum-alias-icon-color-disabled)\n)}\n`;\nexport default styles;"]}
|