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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/package.json +41 -14
  2. package/sp-tab-panel.dev.js +3 -0
  3. package/sp-tab-panel.dev.js.map +7 -0
  4. package/sp-tab-panel.js +3 -14
  5. package/sp-tab-panel.js.map +7 -1
  6. package/sp-tab.dev.js +3 -0
  7. package/sp-tab.dev.js.map +7 -0
  8. package/sp-tab.js +3 -14
  9. package/sp-tab.js.map +7 -1
  10. package/sp-tabs.dev.js +3 -0
  11. package/sp-tabs.dev.js.map +7 -0
  12. package/sp-tabs.js +3 -14
  13. package/sp-tabs.js.map +7 -1
  14. package/src/Tab.dev.js +101 -0
  15. package/src/Tab.dev.js.map +7 -0
  16. package/src/Tab.js +92 -103
  17. package/src/Tab.js.map +7 -1
  18. package/src/TabPanel.dev.js +58 -0
  19. package/src/TabPanel.dev.js.map +7 -0
  20. package/src/TabPanel.js +51 -57
  21. package/src/TabPanel.js.map +7 -1
  22. package/src/Tabs.dev.js +304 -0
  23. package/src/Tabs.dev.js.map +7 -0
  24. package/src/Tabs.js +275 -302
  25. package/src/Tabs.js.map +7 -1
  26. package/src/index.dev.js +4 -0
  27. package/src/index.dev.js.map +7 -0
  28. package/src/index.js +4 -15
  29. package/src/index.js.map +7 -1
  30. package/src/spectrum-tab.css.dev.js +40 -0
  31. package/src/spectrum-tab.css.dev.js.map +7 -0
  32. package/src/spectrum-tab.css.js +3 -14
  33. package/src/spectrum-tab.css.js.map +7 -1
  34. package/src/spectrum-tabs.css.dev.js +392 -0
  35. package/src/spectrum-tabs.css.dev.js.map +7 -0
  36. package/src/spectrum-tabs.css.js +3 -14
  37. package/src/spectrum-tabs.css.js.map +7 -1
  38. package/src/tab-panel.css.dev.js +6 -0
  39. package/src/tab-panel.css.dev.js.map +7 -0
  40. package/src/tab-panel.css.js +3 -14
  41. package/src/tab-panel.css.js.map +7 -1
  42. package/src/tab.css.dev.js +54 -0
  43. package/src/tab.css.dev.js.map +7 -0
  44. package/src/tab.css.js +3 -14
  45. package/src/tab.css.js.map +7 -1
  46. package/src/tabs.css.dev.js +406 -0
  47. package/src/tabs.css.dev.js.map +7 -0
  48. package/src/tabs.css.js +3 -14
  49. package/src/tabs.css.js.map +7 -1
  50. package/stories/tabs-horizontal-sizes.stories.js +53 -64
  51. package/stories/tabs-horizontal-sizes.stories.js.map +7 -1
  52. package/stories/tabs-vertical-right-sizes.stories.js +50 -61
  53. package/stories/tabs-vertical-right-sizes.stories.js.map +7 -1
  54. package/stories/tabs-vertical-sizes.stories.js +50 -61
  55. package/stories/tabs-vertical-sizes.stories.js.map +7 -1
  56. package/stories/tabs.stories.js +79 -81
  57. package/stories/tabs.stories.js.map +7 -1
  58. package/test/benchmark/basic-test.js +6 -17
  59. package/test/benchmark/basic-test.js.map +7 -1
  60. package/test/tab.test.js +21 -34
  61. package/test/tab.test.js.map +7 -1
  62. package/test/tabs-horizontal-sizes.test-vrt.js +4 -15
  63. package/test/tabs-horizontal-sizes.test-vrt.js.map +7 -1
  64. package/test/tabs-vertical-right-sizes.test-vrt.js +4 -15
  65. package/test/tabs-vertical-right-sizes.test-vrt.js.map +7 -1
  66. package/test/tabs-vertical-sizes.test-vrt.js +4 -15
  67. package/test/tabs-vertical-sizes.test-vrt.js.map +7 -1
  68. package/test/tabs.test-vrt.js +4 -15
  69. package/test/tabs.test-vrt.js.map +7 -1
  70. package/test/tabs.test.js +375 -383
  71. package/test/tabs.test.js.map +7 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/tabs",
3
- "version": "0.8.13",
3
+ "version": "0.8.15-devmode.7+8303f3a2a",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,15 +20,42 @@
20
20
  "module": "./src/index.js",
21
21
  "type": "module",
22
22
  "exports": {
23
- ".": "./src/index.js",
24
- "./src/*": "./src/*",
23
+ ".": {
24
+ "development": "./src/index.dev.js",
25
+ "default": "./src/index.js"
26
+ },
25
27
  "./package.json": "./package.json",
26
- "./sp-tabs": "./sp-tabs.js",
27
- "./sp-tabs.js": "./sp-tabs.js",
28
- "./sp-tab": "./sp-tab.js",
29
- "./sp-tab.js": "./sp-tab.js",
30
- "./sp-tab-panel": "./sp-tab-panel.js",
31
- "./sp-tab-panel.js": "./sp-tab-panel.js"
28
+ "./src/Tab.js": {
29
+ "development": "./src/Tab.dev.js",
30
+ "default": "./src/Tab.js"
31
+ },
32
+ "./src/TabPanel.js": {
33
+ "development": "./src/TabPanel.dev.js",
34
+ "default": "./src/TabPanel.js"
35
+ },
36
+ "./src/Tabs.js": {
37
+ "development": "./src/Tabs.dev.js",
38
+ "default": "./src/Tabs.js"
39
+ },
40
+ "./src/index.js": {
41
+ "development": "./src/index.dev.js",
42
+ "default": "./src/index.js"
43
+ },
44
+ "./src/tab-panel.css.js": "./src/tab-panel.css.js",
45
+ "./src/tab.css.js": "./src/tab.css.js",
46
+ "./src/tabs.css.js": "./src/tabs.css.js",
47
+ "./sp-tabs.js": {
48
+ "development": "./sp-tabs.dev.js",
49
+ "default": "./sp-tabs.js"
50
+ },
51
+ "./sp-tab.js": {
52
+ "development": "./sp-tab.dev.js",
53
+ "default": "./sp-tab.js"
54
+ },
55
+ "./sp-tab-panel.js": {
56
+ "development": "./sp-tab-panel.dev.js",
57
+ "default": "./sp-tab-panel.js"
58
+ }
32
59
  },
33
60
  "scripts": {
34
61
  "test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
@@ -48,18 +75,18 @@
48
75
  "lit-html"
49
76
  ],
50
77
  "dependencies": {
51
- "@spectrum-web-components/base": "^0.5.8",
52
- "@spectrum-web-components/reactive-controllers": "^0.2.4",
53
- "@spectrum-web-components/shared": "^0.14.3",
78
+ "@spectrum-web-components/base": "^0.5.9-devmode.31+8303f3a2a",
79
+ "@spectrum-web-components/reactive-controllers": "^0.2.5-devmode.86+8303f3a2a",
80
+ "@spectrum-web-components/shared": "^0.14.5-devmode.7+8303f3a2a",
54
81
  "tslib": "^2.0.0"
55
82
  },
56
83
  "devDependencies": {
57
- "@spectrum-css/tabs": "^3.2.14"
84
+ "@spectrum-css/tabs": "^3.2.18"
58
85
  },
59
86
  "types": "./src/index.d.ts",
60
87
  "customElements": "custom-elements.json",
61
88
  "sideEffects": [
62
89
  "./sp-*.js"
63
90
  ],
64
- "gitHead": "e5cd4a0db2201b8126eb9133ac3c24172d086359"
91
+ "gitHead": "8303f3a2a90b0aedc15158797662ccfa8f4a2031"
65
92
  }
@@ -0,0 +1,3 @@
1
+ import { TabPanel } from "./src/TabPanel.dev.js";
2
+ customElements.define("sp-tab-panel", TabPanel);
3
+ //# sourceMappingURL=sp-tab-panel.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-tab-panel.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 { TabPanel } from './src/TabPanel.dev.js'\n\ncustomElements.define('sp-tab-panel', TabPanel);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tab-panel': TabPanel;\n }\n}\n"],
5
+ "mappings": "AAYA;AAEA,eAAe,OAAO,gBAAgB,QAAQ;",
6
+ "names": []
7
+ }
package/sp-tab-panel.js CHANGED
@@ -1,14 +1,3 @@
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
1
+ import { TabPanel } from "./src/TabPanel.js";
2
+ customElements.define("sp-tab-panel", TabPanel);
3
+ //# sourceMappingURL=sp-tab-panel.js.map
@@ -1 +1,7 @@
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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-tab-panel.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 { 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"],
5
+ "mappings": "AAYA;AAEA,eAAe,OAAO,gBAAgB,QAAQ;",
6
+ "names": []
7
+ }
package/sp-tab.dev.js ADDED
@@ -0,0 +1,3 @@
1
+ import { Tab } from "./src/Tab.dev.js";
2
+ customElements.define("sp-tab", Tab);
3
+ //# sourceMappingURL=sp-tab.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-tab.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 { Tab } from './src/Tab.dev.js'\n\ncustomElements.define('sp-tab', Tab);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tab': Tab;\n }\n}\n"],
5
+ "mappings": "AAYA;AAEA,eAAe,OAAO,UAAU,GAAG;",
6
+ "names": []
7
+ }
package/sp-tab.js CHANGED
@@ -1,14 +1,3 @@
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
1
+ import { Tab } from "./src/Tab.js";
2
+ customElements.define("sp-tab", Tab);
3
+ //# sourceMappingURL=sp-tab.js.map
package/sp-tab.js.map CHANGED
@@ -1 +1,7 @@
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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-tab.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 { Tab } from './src/Tab.js';\n\ncustomElements.define('sp-tab', Tab);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tab': Tab;\n }\n}\n"],
5
+ "mappings": "AAYA;AAEA,eAAe,OAAO,UAAU,GAAG;",
6
+ "names": []
7
+ }
package/sp-tabs.dev.js ADDED
@@ -0,0 +1,3 @@
1
+ import { Tabs } from "./src/Tabs.dev.js";
2
+ customElements.define("sp-tabs", Tabs);
3
+ //# sourceMappingURL=sp-tabs.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-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 { Tabs } from './src/Tabs.dev.js'\n\ncustomElements.define('sp-tabs', Tabs);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tabs': Tabs;\n }\n}\n"],
5
+ "mappings": "AAYA;AAEA,eAAe,OAAO,WAAW,IAAI;",
6
+ "names": []
7
+ }
package/sp-tabs.js CHANGED
@@ -1,14 +1,3 @@
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
1
+ import { Tabs } from "./src/Tabs.js";
2
+ customElements.define("sp-tabs", Tabs);
3
+ //# sourceMappingURL=sp-tabs.js.map
package/sp-tabs.js.map CHANGED
@@ -1 +1,7 @@
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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-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 { Tabs } from './src/Tabs.js';\n\ncustomElements.define('sp-tabs', Tabs);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tabs': Tabs;\n }\n}\n"],
5
+ "mappings": "AAYA;AAEA,eAAe,OAAO,WAAW,IAAI;",
6
+ "names": []
7
+ }
package/src/Tab.dev.js ADDED
@@ -0,0 +1,101 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import {
13
+ html,
14
+ SpectrumElement
15
+ } from "@spectrum-web-components/base";
16
+ import { property } from "@spectrum-web-components/base/src/decorators.js";
17
+ import {
18
+ FocusVisiblePolyfillMixin,
19
+ ObserveSlotPresence,
20
+ ObserveSlotText
21
+ } from "@spectrum-web-components/shared";
22
+ import tabItemStyles from "./tab.css.js";
23
+ const _Tab = class 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
+ this.dispatchEvent(new Event("sp-tab-contentchange", {
43
+ bubbles: true,
44
+ composed: true
45
+ }));
46
+ }
47
+ render() {
48
+ return html`
49
+ ${this.hasIcon ? html`
50
+ <slot name="icon"></slot>
51
+ ` : html``}
52
+ <label id="item-label" ?hidden=${!this.hasLabel}>
53
+ ${this.slotHasContent ? html`` : this.label}
54
+ <slot>${this.label}</slot>
55
+ </label>
56
+ `;
57
+ }
58
+ firstUpdated(changes) {
59
+ super.firstUpdated(changes);
60
+ this.setAttribute("role", "tab");
61
+ if (!this.hasAttribute("id")) {
62
+ this.id = `sp-tab-${_Tab.instanceCount++}`;
63
+ }
64
+ this.shadowRoot.addEventListener("slotchange", this.handleContentChange);
65
+ }
66
+ updated(changes) {
67
+ super.updated(changes);
68
+ if (changes.has("label") && typeof changes.get("label") !== "undefined") {
69
+ this.handleContentChange();
70
+ }
71
+ if (changes.has("selected")) {
72
+ this.setAttribute("aria-selected", this.selected ? "true" : "false");
73
+ this.setAttribute("tabindex", this.selected ? "0" : "-1");
74
+ }
75
+ if (changes.has("disabled")) {
76
+ if (this.disabled) {
77
+ this.setAttribute("aria-disabled", "true");
78
+ } else {
79
+ this.removeAttribute("aria-disabled");
80
+ }
81
+ }
82
+ }
83
+ };
84
+ export let Tab = _Tab;
85
+ Tab.instanceCount = 0;
86
+ __decorateClass([
87
+ property({ type: Boolean, reflect: true })
88
+ ], Tab.prototype, "disabled", 2);
89
+ __decorateClass([
90
+ property({ reflect: true })
91
+ ], Tab.prototype, "label", 2);
92
+ __decorateClass([
93
+ property({ type: Boolean, reflect: true })
94
+ ], Tab.prototype, "selected", 2);
95
+ __decorateClass([
96
+ property({ type: Boolean, reflect: true })
97
+ ], Tab.prototype, "vertical", 2);
98
+ __decorateClass([
99
+ property({ type: String, reflect: true })
100
+ ], Tab.prototype, "value", 2);
101
+ //# sourceMappingURL=Tab.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["Tab.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 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 override 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 override 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 override 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 override 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"],
5
+ "mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAOA;AACA;AAAA;AAAA;AAAA;AAAA;AAMA;AAQO,2BAAkB,0BACrB,gBAAgB,oBAAoB,iBAAiB,eAAe,GAAG,EAAE,CAC7E,EAAE;AAAA,EAFK;AAAA;AAqBI,oBAAW;AAGX,iBAAQ;AAGR,oBAAW;AAGX,oBAAW;AAGX,iBAAQ;AAAA;AAAA,aA9BY,SAAyB;AAChD,WAAO,CAAC,aAAa;AAAA,EACzB;AAAA,MAOc,UAAmB;AAC7B,WAAO,KAAK;AAAA,EAChB;AAAA,MAEc,WAAoB;AAC9B,WAAO,CAAC,CAAC,KAAK,SAAS,KAAK;AAAA,EAChC;AAAA,EAiBU,sBAA4B;AAIlC,SAAK,cACD,IAAI,MAAM,wBAAwB;AAAA,MAC9B,SAAS;AAAA,MACT,UAAU;AAAA,IACd,CAAC,CACL;AAAA,EACJ;AAAA,EAEmB,SAAyB;AACxC,WAAO;AAAA,cACD,KAAK,UACD;AAAA;AAAA,sBAGA;AAAA,6CAC2B,CAAC,KAAK;AAAA,kBACjC,KAAK,iBAAiB,SAAS,KAAK;AAAA,wBAC9B,KAAK;AAAA;AAAA;AAAA,EAGzB;AAAA,EAEmB,aAAa,SAA+B;AAC3D,UAAM,aAAa,OAAO;AAC1B,S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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 `
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import {
13
+ html,
14
+ SpectrumElement
15
+ } from "@spectrum-web-components/base";
16
+ import { property } from "@spectrum-web-components/base/src/decorators.js";
17
+ import {
18
+ FocusVisiblePolyfillMixin,
19
+ ObserveSlotPresence,
20
+ ObserveSlotText
21
+ } from "@spectrum-web-components/shared";
22
+ import tabItemStyles from "./tab.css.js";
23
+ const _Tab = class 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
+ this.dispatchEvent(new Event("sp-tab-contentchange", {
43
+ bubbles: true,
44
+ composed: true
45
+ }));
46
+ }
47
+ render() {
48
+ return html`
49
+ ${this.hasIcon ? html`
54
50
  <slot name="icon"></slot>
55
- `
56
- : html ``}
51
+ ` : html``}
57
52
  <label id="item-label" ?hidden=${!this.hasLabel}>
58
- ${this.slotHasContent ? html `` : this.label}
53
+ ${this.slotHasContent ? html`` : this.label}
59
54
  <slot>${this.label}</slot>
60
55
  </label>
61
56
  `;
57
+ }
58
+ firstUpdated(changes) {
59
+ super.firstUpdated(changes);
60
+ this.setAttribute("role", "tab");
61
+ if (!this.hasAttribute("id")) {
62
+ this.id = `sp-tab-${_Tab.instanceCount++}`;
63
+ }
64
+ this.shadowRoot.addEventListener("slotchange", this.handleContentChange);
65
+ }
66
+ updated(changes) {
67
+ super.updated(changes);
68
+ if (changes.has("label") && typeof changes.get("label") !== "undefined") {
69
+ this.handleContentChange();
62
70
  }
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);
71
+ if (changes.has("selected")) {
72
+ this.setAttribute("aria-selected", this.selected ? "true" : "false");
73
+ this.setAttribute("tabindex", this.selected ? "0" : "-1");
72
74
  }
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
- }
75
+ if (changes.has("disabled")) {
76
+ if (this.disabled) {
77
+ this.setAttribute("aria-disabled", "true");
78
+ } else {
79
+ this.removeAttribute("aria-disabled");
80
+ }
91
81
  }
92
- }
93
- /**
94
- * @private
95
- */
82
+ }
83
+ };
84
+ export let Tab = _Tab;
96
85
  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
86
+ __decorateClass([
87
+ property({ type: Boolean, reflect: true })
88
+ ], Tab.prototype, "disabled", 2);
89
+ __decorateClass([
90
+ property({ reflect: true })
91
+ ], Tab.prototype, "label", 2);
92
+ __decorateClass([
93
+ property({ type: Boolean, reflect: true })
94
+ ], Tab.prototype, "selected", 2);
95
+ __decorateClass([
96
+ property({ type: Boolean, reflect: true })
97
+ ], Tab.prototype, "vertical", 2);
98
+ __decorateClass([
99
+ property({ type: String, reflect: true })
100
+ ], Tab.prototype, "value", 2);
101
+ //# sourceMappingURL=Tab.js.map
package/src/Tab.js.map CHANGED
@@ -1 +1,7 @@
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;QAGjB,UAAK,GAAG,EAAE,CAAC;IAiEtB,CAAC;IA/FU,MAAM,KAAc,MAAM;QAC7B,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3B,CAAC;IAOD,IAAc,OAAO;QACjB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED,IAAc,QAAQ;QAClB,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC;IAC/C,CAAC;IAiBS,mBAAm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AAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CACnC,CAAC;YACF,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC7D;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACzB,IAAI,IAAI,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 override 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 override 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 override 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 override 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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["Tab.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 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 override 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 override 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 override 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 override 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"],
5
+ "mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAOA;AACA;AAAA;AAAA;AAAA;AAAA;AAMA;AAQO,2BAAkB,0BACrB,gBAAgB,oBAAoB,iBAAiB,eAAe,GAAG,EAAE,CAC7E,EAAE;AAAA,EAFK;AAAA;AAqBI,oBAAW;AAGX,iBAAQ;AAGR,oBAAW;AAGX,oBAA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