@spectrum-web-components/tabs 0.8.6 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/package.json +6 -6
  2. package/sp-tab-panel.d.ts +6 -0
  3. package/sp-tab-panel.js +14 -0
  4. package/sp-tab-panel.js.map +1 -0
  5. package/sp-tab.d.ts +6 -0
  6. package/sp-tab.js +14 -0
  7. package/sp-tab.js.map +1 -0
  8. package/sp-tabs.d.ts +6 -0
  9. package/sp-tabs.js +14 -0
  10. package/sp-tabs.js.map +1 -0
  11. package/src/Tab.d.ts +33 -0
  12. package/src/Tab.js +112 -0
  13. package/src/Tab.js.map +1 -0
  14. package/src/TabPanel.d.ts +18 -0
  15. package/src/TabPanel.js +64 -0
  16. package/src/TabPanel.js.map +1 -0
  17. package/src/Tabs.d.ts +66 -0
  18. package/src/Tabs.js +328 -0
  19. package/src/Tabs.js.map +1 -0
  20. package/src/index.d.ts +3 -0
  21. package/src/index.js +15 -0
  22. package/src/index.js.map +1 -0
  23. package/src/spectrum-tab.css.d.ts +2 -0
  24. package/src/spectrum-tab.css.js +51 -0
  25. package/src/spectrum-tab.css.js.map +1 -0
  26. package/src/spectrum-tabs.css.d.ts +2 -0
  27. package/src/spectrum-tabs.css.js +399 -0
  28. package/src/spectrum-tabs.css.js.map +1 -0
  29. package/src/tab-panel.css.d.ts +2 -0
  30. package/src/tab-panel.css.js +17 -0
  31. package/src/tab-panel.css.js.map +1 -0
  32. package/src/tab.css.d.ts +2 -0
  33. package/src/tab.css.js +61 -0
  34. package/src/tab.css.js.map +1 -0
  35. package/src/tabs.css.d.ts +2 -0
  36. package/src/tabs.css.js +413 -0
  37. package/src/tabs.css.js.map +1 -0
  38. package/stories/tabs-horizontal-sizes.stories.js +101 -0
  39. package/stories/tabs-horizontal-sizes.stories.js.map +1 -0
  40. package/stories/tabs-vertical-right-sizes.stories.js +98 -0
  41. package/stories/tabs-vertical-right-sizes.stories.js.map +1 -0
  42. package/stories/tabs-vertical-sizes.stories.js +98 -0
  43. package/stories/tabs-vertical-sizes.stories.js.map +1 -0
  44. package/stories/tabs.stories.js +385 -0
  45. package/stories/tabs.stories.js.map +1 -0
  46. package/test/benchmark/basic-test.js +23 -0
  47. package/test/benchmark/basic-test.js.map +1 -0
  48. package/test/tab.test.js +43 -0
  49. package/test/tab.test.js.map +1 -0
  50. package/test/tabs-horizontal-sizes.test-vrt.js +15 -0
  51. package/test/tabs-horizontal-sizes.test-vrt.js.map +1 -0
  52. package/test/tabs-vertical-right-sizes.test-vrt.js +15 -0
  53. package/test/tabs-vertical-right-sizes.test-vrt.js.map +1 -0
  54. package/test/tabs-vertical-sizes.test-vrt.js +15 -0
  55. package/test/tabs-vertical-sizes.test-vrt.js.map +1 -0
  56. package/test/tabs.test-vrt.js +15 -0
  57. package/test/tabs.test-vrt.js.map +1 -0
  58. package/test/tabs.test.js +486 -0
  59. package/test/tabs.test.js.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/tabs",
3
- "version": "0.8.6",
3
+ "version": "0.8.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -48,18 +48,18 @@
48
48
  "lit-html"
49
49
  ],
50
50
  "dependencies": {
51
- "@spectrum-web-components/base": "^0.5.3",
52
- "@spectrum-web-components/reactive-controllers": "^0.2.1",
53
- "@spectrum-web-components/shared": "^0.13.5",
51
+ "@spectrum-web-components/base": "^0.5.5",
52
+ "@spectrum-web-components/reactive-controllers": "^0.2.2",
53
+ "@spectrum-web-components/shared": "^0.14.0",
54
54
  "tslib": "^2.0.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@spectrum-css/tabs": "^3.2.4"
57
+ "@spectrum-css/tabs": "^3.2.11"
58
58
  },
59
59
  "types": "./src/index.d.ts",
60
60
  "customElements": "custom-elements.json",
61
61
  "sideEffects": [
62
62
  "./sp-*.js"
63
63
  ],
64
- "gitHead": "57aba8030b6af96af4015a0aa830e342a17dc219"
64
+ "gitHead": "bdff893e2b95aba7737c58d01c6ac68861cb8b2e"
65
65
  }
@@ -0,0 +1,6 @@
1
+ import { TabPanel } from './src/TabPanel.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-tab-panel': TabPanel;
5
+ }
6
+ }
@@ -0,0 +1,14 @@
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 { TabPanel } from './src/TabPanel.js';
13
+ customElements.define('sp-tab-panel', TabPanel);
14
+ //# sourceMappingURL=sp-tab-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sp-tab-panel.js","sourceRoot":"","sources":["sp-tab-panel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,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\nimport { TabPanel } from './src/TabPanel.js';\n\ncustomElements.define('sp-tab-panel', TabPanel);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tab-panel': TabPanel;\n }\n}\n"]}
package/sp-tab.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Tab } from './src/Tab.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-tab': Tab;
5
+ }
6
+ }
package/sp-tab.js ADDED
@@ -0,0 +1,14 @@
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 { Tab } from './src/Tab.js';
13
+ customElements.define('sp-tab', Tab);
14
+ //# sourceMappingURL=sp-tab.js.map
package/sp-tab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sp-tab.js","sourceRoot":"","sources":["sp-tab.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,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\nimport { Tab } from './src/Tab.js';\n\ncustomElements.define('sp-tab', Tab);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tab': Tab;\n }\n}\n"]}
package/sp-tabs.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Tabs } from './src/Tabs.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-tabs': Tabs;
5
+ }
6
+ }
package/sp-tabs.js ADDED
@@ -0,0 +1,14 @@
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 { Tabs } from './src/Tabs.js';
13
+ customElements.define('sp-tabs', Tabs);
14
+ //# sourceMappingURL=sp-tabs.js.map
package/sp-tabs.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sp-tabs.js","sourceRoot":"","sources":["sp-tabs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,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\nimport { Tabs } from './src/Tabs.js';\n\ncustomElements.define('sp-tabs', Tabs);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tabs': Tabs;\n }\n}\n"]}
package/src/Tab.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
+ declare const Tab_base: typeof SpectrumElement & {
3
+ new (...args: any[]): import("@spectrum-web-components/shared").SlotPresenceObservingInterface;
4
+ prototype: import("@spectrum-web-components/shared").SlotPresenceObservingInterface;
5
+ } & {
6
+ new (...args: any[]): import("@spectrum-web-components/shared").SlotTextObservingInterface;
7
+ prototype: import("@spectrum-web-components/shared").SlotTextObservingInterface;
8
+ };
9
+ /**
10
+ * @element sp-tab
11
+ *
12
+ * @slot - text label of the Tab
13
+ * @slot icon - The icon that appears on the left of the label
14
+ */
15
+ export declare class Tab extends Tab_base {
16
+ static get styles(): CSSResultArray;
17
+ /**
18
+ * @private
19
+ */
20
+ static instanceCount: number;
21
+ protected get hasIcon(): boolean;
22
+ protected get hasLabel(): boolean;
23
+ disabled: boolean;
24
+ label: string;
25
+ selected: boolean;
26
+ vertical: boolean;
27
+ value: string;
28
+ protected handleContentChange(): void;
29
+ protected render(): TemplateResult;
30
+ protected firstUpdated(changes: PropertyValues): void;
31
+ protected updated(changes: PropertyValues): void;
32
+ }
33
+ export {};
package/src/Tab.js ADDED
@@ -0,0 +1,112 @@
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 { FocusVisiblePolyfillMixin, ObserveSlotPresence, ObserveSlotText, } from '@spectrum-web-components/shared';
16
+ import tabItemStyles from './tab.css.js';
17
+ /**
18
+ * @element sp-tab
19
+ *
20
+ * @slot - text label of the Tab
21
+ * @slot icon - The icon that appears on the left of the label
22
+ */
23
+ export class Tab extends FocusVisiblePolyfillMixin(ObserveSlotText(ObserveSlotPresence(SpectrumElement, '[slot="icon"]'), '')) {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.disabled = false;
27
+ this.label = '';
28
+ this.selected = false;
29
+ this.vertical = false;
30
+ this.value = '';
31
+ }
32
+ static get styles() {
33
+ return [tabItemStyles];
34
+ }
35
+ get hasIcon() {
36
+ return this.slotContentIsPresent;
37
+ }
38
+ get hasLabel() {
39
+ return !!this.label || this.slotHasContent;
40
+ }
41
+ handleContentChange() {
42
+ /**
43
+ * When the content in a tab has changed, JS powered layout related to that content may also need to be changed.
44
+ */
45
+ this.dispatchEvent(new Event('sp-tab-contentchange', {
46
+ bubbles: true,
47
+ composed: true,
48
+ }));
49
+ }
50
+ render() {
51
+ return html `
52
+ ${this.hasIcon
53
+ ? html `
54
+ <slot name="icon"></slot>
55
+ `
56
+ : html ``}
57
+ <label id="item-label" ?hidden=${!this.hasLabel}>
58
+ ${this.slotHasContent ? html `` : this.label}
59
+ <slot>${this.label}</slot>
60
+ </label>
61
+ `;
62
+ }
63
+ firstUpdated(changes) {
64
+ super.firstUpdated(changes);
65
+ this.setAttribute('role', 'tab');
66
+ if (!this.hasAttribute('id')) {
67
+ this.id = `sp-tab-${Tab.instanceCount++}`;
68
+ }
69
+ // @TODO - refactor this as a ResizeObserver up to `sp-tabs` so that it can be more
70
+ // resiliant to Tab content changes, as well as other content slotted into the "tablist".
71
+ this.shadowRoot.addEventListener('slotchange', this.handleContentChange);
72
+ }
73
+ updated(changes) {
74
+ super.updated(changes);
75
+ if (changes.has('label') &&
76
+ typeof changes.get('label') !== 'undefined') {
77
+ this.handleContentChange();
78
+ }
79
+ if (changes.has('selected')) {
80
+ this.setAttribute('aria-selected', this.selected ? 'true' : 'false');
81
+ this.setAttribute('tabindex', this.selected ? '0' : '-1');
82
+ }
83
+ if (changes.has('disabled')) {
84
+ if (this.disabled) {
85
+ this.setAttribute('aria-disabled', 'true');
86
+ }
87
+ else {
88
+ this.removeAttribute('aria-disabled');
89
+ }
90
+ }
91
+ }
92
+ }
93
+ /**
94
+ * @private
95
+ */
96
+ Tab.instanceCount = 0;
97
+ __decorate([
98
+ property({ type: Boolean, reflect: true })
99
+ ], Tab.prototype, "disabled", void 0);
100
+ __decorate([
101
+ property({ reflect: true })
102
+ ], Tab.prototype, "label", void 0);
103
+ __decorate([
104
+ property({ type: Boolean, reflect: true })
105
+ ], Tab.prototype, "selected", void 0);
106
+ __decorate([
107
+ property({ type: Boolean, reflect: true })
108
+ ], Tab.prototype, "vertical", void 0);
109
+ __decorate([
110
+ property({ type: String, reflect: true })
111
+ ], Tab.prototype, "value", void 0);
112
+ //# sourceMappingURL=Tab.js.map
package/src/Tab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tab.js","sourceRoot":"","sources":["Tab.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,EACH,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,GAClB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,aAAa,MAAM,cAAc,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,OAAO,GAAI,SAAQ,yBAAyB,CAC9C,eAAe,CAAC,mBAAmB,CAAC,eAAe,EAAE,eAAe,CAAC,EAAE,EAAE,CAAC,CAC7E;IAFD;;QAqBW,aAAQ,GAAG,KAAK,CAAC;QAGjB,UAAK,GAAG,EAAE,CAAC;QAGX,aAAQ,GAAG,KAAK,CAAC;QAGjB,aAAQ,GAAG,KAAK,CAAC;QA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ved.\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"]}
@@ -0,0 +1,18 @@
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
+ }
@@ -0,0 +1,64 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabPanel.js","sourceRoot":"","sources":["TabPanel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EACH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAE3E,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,eAAe;IAA7C;;QASW,aAAQ,GAAG,KAAK,CAAC;QAGjB,UAAK,GAAG,EAAE,CAAC;IA4BtB,CAAC;IA1Ba,MAAM;QACZ,OAAO,IAAI,CAAA;;SAEV,CAAC;IACN,CAAC;IAES,YAAY;QAClB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;YAC1B,IAAI,CAAC,EAAE,GAAG,gBAAgB,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;SACxD;IACL,CAAC;IAES,OAAO,CAAC,OAA6B;QAC3C,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACzB,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACf,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;gBACpC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;aACrB;iBAAM;gBACH,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;gBACzC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;aACtB;SACJ;IACL,CAAC;;AAtCM,eAAM,GAAG,CAAC,WAAW,CAAC,CAAC;AAE9B;;GAEG;AACI,sBAAa,GAAG,CAAC,CAAC;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACnB;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,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 ADDED
@@ -0,0 +1,66 @@
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 {};