@spectrum-web-components/tabs 0.8.16-devmode.0 → 0.9.0
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/package.json +5 -5
- package/sp-tab-panel.js +1 -2
- package/sp-tab-panel.js.map +1 -1
- package/sp-tab.js +1 -2
- package/sp-tab.js.map +1 -1
- package/sp-tabs.js +1 -2
- package/sp-tabs.js.map +1 -1
- package/src/Tab.js +5 -96
- package/src/Tab.js.map +1 -1
- package/src/TabPanel.js +2 -56
- package/src/TabPanel.js.map +1 -1
- package/src/Tabs.js +4 -287
- package/src/Tabs.js.map +1 -1
- package/src/index.js +1 -3
- package/src/index.js.map +1 -1
- package/src/spectrum-tab.css.js +2 -4
- package/src/spectrum-tab.css.js.map +1 -1
- package/src/spectrum-tabs.css.js +2 -4
- package/src/spectrum-tabs.css.js.map +1 -1
- package/src/tab-panel.css.js +2 -4
- package/src/tab-panel.css.js.map +1 -1
- package/src/tab.css.js +2 -4
- package/src/tab.css.js.map +1 -1
- package/src/tabs.css.js +2 -4
- package/src/tabs.css.js.map +1 -1
- package/stories/tabs-horizontal-sizes.stories.js +7 -76
- package/stories/tabs-horizontal-sizes.stories.js.map +1 -1
- package/stories/tabs-vertical-right-sizes.stories.js +7 -73
- package/stories/tabs-vertical-right-sizes.stories.js.map +1 -1
- package/stories/tabs-vertical-sizes.stories.js +7 -73
- package/stories/tabs-vertical-sizes.stories.js.map +1 -1
- package/stories/tabs.stories.js +75 -196
- package/stories/tabs.stories.js.map +1 -1
- package/test/benchmark/basic-test.js +1 -5
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/tab.test.js +4 -26
- package/test/tab.test.js.map +1 -1
- package/test/tabs-horizontal-sizes.test-vrt.js +1 -3
- package/test/tabs-horizontal-sizes.test-vrt.js.map +1 -1
- package/test/tabs-vertical-right-sizes.test-vrt.js +1 -3
- package/test/tabs-vertical-right-sizes.test-vrt.js.map +1 -1
- package/test/tabs-vertical-sizes.test-vrt.js +1 -3
- package/test/tabs-vertical-sizes.test-vrt.js.map +1 -1
- package/test/tabs.test-vrt.js +1 -3
- package/test/tabs.test-vrt.js.map +1 -1
- package/test/tabs.test.js +17 -396
- package/test/tabs.test.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/tabs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"lit-html"
|
|
76
76
|
],
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@spectrum-web-components/base": "^0.
|
|
79
|
-
"@spectrum-web-components/reactive-controllers": "^0.
|
|
80
|
-
"@spectrum-web-components/shared": "^0.
|
|
78
|
+
"@spectrum-web-components/base": "^0.7.0",
|
|
79
|
+
"@spectrum-web-components/reactive-controllers": "^0.3.0",
|
|
80
|
+
"@spectrum-web-components/shared": "^0.15.0",
|
|
81
81
|
"tslib": "^2.0.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"./sp-*.js",
|
|
90
90
|
"./**/*.dev.js"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "05c81318844160db3f8156144106e643507fef97"
|
|
93
93
|
}
|
package/sp-tab-panel.js
CHANGED
package/sp-tab-panel.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-tab-panel.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { 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
|
|
5
|
+
"mappings": "AAYA,6CAEA,eAAe,OAAO,eAAgB,CAAQ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-tab.js
CHANGED
package/sp-tab.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-tab.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { 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
|
|
5
|
+
"mappings": "AAYA,mCAEA,eAAe,OAAO,SAAU,CAAG",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-tabs.js
CHANGED
package/sp-tabs.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-tabs.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { 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
|
|
5
|
+
"mappings": "AAYA,qCAEA,eAAe,OAAO,UAAW,CAAI",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Tab.js
CHANGED
|
@@ -1,101 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
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`
|
|
1
|
+
var p=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var s=(u,e,o,i)=>{for(var t=i>1?void 0:i?h(e,o):e,a=u.length-1,d;a>=0;a--)(d=u[a])&&(t=(i?d(e,o,t):d(t))||t);return i&&t&&p(e,o,t),t};import{html as r,SpectrumElement as c}from"@spectrum-web-components/base";import{property as l}from"@spectrum-web-components/base/src/decorators.js";import{FocusVisiblePolyfillMixin as b,ObserveSlotPresence as f,ObserveSlotText as m}from"@spectrum-web-components/shared";import v from"./tab.css.js";const n=class extends b(m(f(c,'[slot="icon"]'),"")){constructor(){super(...arguments);this.disabled=!1;this.label="";this.selected=!1;this.vertical=!1;this.value=""}static get styles(){return[v]}get hasIcon(){return this.slotContentIsPresent}get hasLabel(){return!!this.label||this.slotHasContent}handleContentChange(){this.dispatchEvent(new Event("sp-tab-contentchange",{bubbles:!0,composed:!0}))}render(){return r`
|
|
2
|
+
${this.hasIcon?r`
|
|
50
3
|
<slot name="icon"></slot>
|
|
51
|
-
|
|
4
|
+
`:r``}
|
|
52
5
|
<label id="item-label" ?hidden=${!this.hasLabel}>
|
|
53
|
-
${this.slotHasContent
|
|
6
|
+
${this.slotHasContent?r``:this.label}
|
|
54
7
|
<slot>${this.label}</slot>
|
|
55
8
|
</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);
|
|
9
|
+
`}firstUpdated(e){super.firstUpdated(e),this.setAttribute("role","tab"),this.hasAttribute("id")||(this.id=`sp-tab-${n.instanceCount++}`),this.shadowRoot.addEventListener("slotchange",this.handleContentChange)}updated(e){super.updated(e),e.has("label")&&typeof e.get("label")!="undefined"&&this.handleContentChange(),e.has("selected")&&(this.setAttribute("aria-selected",this.selected?"true":"false"),this.setAttribute("tabindex",this.selected?"0":"-1")),e.has("disabled")&&(this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"))}};export let Tab=n;Tab.instanceCount=0,s([l({type:Boolean,reflect:!0})],Tab.prototype,"disabled",2),s([l({reflect:!0})],Tab.prototype,"label",2),s([l({type:Boolean,reflect:!0})],Tab.prototype,"selected",2),s([l({type:Boolean,reflect:!0})],Tab.prototype,"vertical",2),s([l({type:String,reflect:!0})],Tab.prototype,"value",2);
|
|
101
10
|
//# sourceMappingURL=Tab.js.map
|
package/src/Tab.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Tab.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n 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": "
|
|
5
|
+
"mappings": "wMAYA,0EAOA,2EACA,0HAMA,4BAQO,qBAAkB,GACrB,EAAgB,EAAoB,EAAiB,eAAe,EAAG,EAAE,CAC7E,CAAE,CAFK,kCAqBI,cAAW,GAGX,WAAQ,GAGR,cAAW,GAGX,cAAW,GAGX,WAAQ,aA9BY,SAAyB,CAChD,MAAO,CAAC,CAAa,CACzB,IAOc,UAAmB,CAC7B,MAAO,MAAK,oBAChB,IAEc,WAAoB,CAC9B,MAAO,CAAC,CAAC,KAAK,OAAS,KAAK,cAChC,CAiBU,qBAA4B,CAIlC,KAAK,cACD,GAAI,OAAM,uBAAwB,CAC9B,QAAS,GACT,SAAU,EACd,CAAC,CACL,CACJ,CAEmB,QAAyB,CACxC,MAAO;AAAA,cACD,KAAK,QACD;AAAA;AAAA,oBAGA;AAAA,6CAC2B,CAAC,KAAK;AAAA,kBACjC,KAAK,eAAiB,IAAS,KAAK;AAAA,wBAC9B,KAAK;AAAA;AAAA,SAGzB,CAEmB,aAAa,EAA+B,CAC3D,MAAM,aAAa,CAAO,EAC1B,KAAK,aAAa,OAAQ,KAAK,EAC1B,KAAK,aAAa,IAAI,GACvB,MAAK,GAAK,UAAU,EAAI,mBAI5B,KAAK,WAAW,iBACZ,aACA,KAAK,mBACT,CACJ,CAEmB,QAAQ,EAA+B,CACtD,MAAM,QAAQ,CAAO,EAEjB,EAAQ,IAAI,OAAO,GACnB,MAAO,GAAQ,IAAI,OAAO,GAAM,aAEhC,KAAK,oBAAoB,EAEzB,EAAQ,IAAI,UAAU,GACtB,MAAK,aACD,gBACA,KAAK,SAAW,OAAS,OAC7B,EACA,KAAK,aAAa,WAAY,KAAK,SAAW,IAAM,IAAI,GAExD,EAAQ,IAAI,UAAU,GACtB,CAAI,KAAK,SACL,KAAK,aAAa,gBAAiB,MAAM,EAEzC,KAAK,gBAAgB,eAAe,EAGhD,CACJ,EAlGO,iBAUI,AAVJ,IAUI,cAAgB,EAWhB,GADP,AAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GACnC,AArBJ,IAqBI,wBAGA,GADP,AAAC,EAAS,CAAE,QAAS,EAAK,CAAC,GACpB,AAxBJ,IAwBI,qBAGA,GADP,AAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GACnC,AA3BJ,IA2BI,wBAGA,GADP,AAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GACnC,AA9BJ,IA8BI,wBAGA,GADP,AAAC,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAClC,AAjCJ,IAiCI",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/TabPanel.js
CHANGED
|
@@ -1,58 +1,4 @@
|
|
|
1
|
-
var
|
|
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 panelStyles from "./tab-panel.css.js";
|
|
18
|
-
const _TabPanel = class extends SpectrumElement {
|
|
19
|
-
constructor() {
|
|
20
|
-
super(...arguments);
|
|
21
|
-
this.selected = false;
|
|
22
|
-
this.value = "";
|
|
23
|
-
}
|
|
24
|
-
render() {
|
|
25
|
-
return html`
|
|
1
|
+
var u=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var d=(p,e,i,r)=>{for(var t=r>1?void 0:r?n(e,i):e,s=p.length-1,o;s>=0;s--)(o=p[s])&&(t=(r?o(e,i,t):o(t))||t);return r&&t&&u(e,i,t),t};import{html as c,SpectrumElement as h}from"@spectrum-web-components/base";import{property as a}from"@spectrum-web-components/base/src/decorators.js";import m from"./tab-panel.css.js";const l=class extends h{constructor(){super(...arguments);this.selected=!1;this.value=""}render(){return c`
|
|
26
2
|
<slot></slot>
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
firstUpdated() {
|
|
30
|
-
this.slot = "tab-panel";
|
|
31
|
-
this.setAttribute("role", "tabpanel");
|
|
32
|
-
this.tabIndex = 0;
|
|
33
|
-
if (!this.hasAttribute("id")) {
|
|
34
|
-
this.id = `sp-tab-panel-${_TabPanel.instanceCount++}`;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
updated(changes) {
|
|
38
|
-
if (changes.has("selected")) {
|
|
39
|
-
if (this.selected) {
|
|
40
|
-
this.removeAttribute("aria-hidden");
|
|
41
|
-
this.tabIndex = 0;
|
|
42
|
-
} else {
|
|
43
|
-
this.setAttribute("aria-hidden", "true");
|
|
44
|
-
this.tabIndex = -1;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
export let TabPanel = _TabPanel;
|
|
50
|
-
TabPanel.styles = [panelStyles];
|
|
51
|
-
TabPanel.instanceCount = 0;
|
|
52
|
-
__decorateClass([
|
|
53
|
-
property({ type: Boolean, reflect: true })
|
|
54
|
-
], TabPanel.prototype, "selected", 2);
|
|
55
|
-
__decorateClass([
|
|
56
|
-
property({ type: String, reflect: true })
|
|
57
|
-
], TabPanel.prototype, "value", 2);
|
|
3
|
+
`}firstUpdated(){this.slot="tab-panel",this.setAttribute("role","tabpanel"),this.tabIndex=0,this.hasAttribute("id")||(this.id=`sp-tab-panel-${l.instanceCount++}`)}updated(e){e.has("selected")&&(this.selected?(this.removeAttribute("aria-hidden"),this.tabIndex=0):(this.setAttribute("aria-hidden","true"),this.tabIndex=-1))}};export let TabPanel=l;TabPanel.styles=[m],TabPanel.instanceCount=0,d([a({type:Boolean,reflect:!0})],TabPanel.prototype,"selected",2),d([a({type:String,reflect:!0})],TabPanel.prototype,"value",2);
|
|
58
4
|
//# sourceMappingURL=TabPanel.js.map
|
package/src/TabPanel.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["TabPanel.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport panelStyles from './tab-panel.css.js';\n\n/**\n * @element sp-tab-panel\n *\n * @slot - content of the Tab Panel\n */\nexport class TabPanel extends SpectrumElement {\n static override styles = [panelStyles];\n\n /**\n * @private\n */\n static instanceCount = 0;\n\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n @property({ type: String, reflect: true })\n public value = '';\n\n protected override render(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected override firstUpdated(): void {\n this.slot = 'tab-panel';\n this.setAttribute('role', 'tabpanel');\n this.tabIndex = 0;\n if (!this.hasAttribute('id')) {\n this.id = `sp-tab-panel-${TabPanel.instanceCount++}`;\n }\n }\n\n protected override updated(changes: PropertyValues<this>): void {\n if (changes.has('selected')) {\n if (this.selected) {\n this.removeAttribute('aria-hidden');\n this.tabIndex = 0;\n } else {\n this.setAttribute('aria-hidden', 'true');\n this.tabIndex = -1;\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "wMAYA,0EAMA,2EAEA,kCAOO,qBAAuB,EAAgB,CAAvC,kCASI,cAAW,GAGX,WAAQ,GAEI,QAAyB,CACxC,MAAO;AAAA;AAAA,SAGX,CAEmB,cAAqB,CACpC,KAAK,KAAO,YACZ,KAAK,aAAa,OAAQ,UAAU,EACpC,KAAK,SAAW,EACX,KAAK,aAAa,IAAI,GACvB,MAAK,GAAK,gBAAgB,EAAS,kBAE3C,CAEmB,QAAQ,EAAqC,CAC5D,AAAI,EAAQ,IAAI,UAAU,GACtB,CAAI,KAAK,SACL,MAAK,gBAAgB,aAAa,EAClC,KAAK,SAAW,GAEhB,MAAK,aAAa,cAAe,MAAM,EACvC,KAAK,SAAW,IAG5B,CACJ,EAxCO,sBACa,AADb,SACa,OAAS,CAAC,CAAW,EAK9B,AANJ,SAMI,cAAgB,EAGhB,GADP,AAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GACnC,AATJ,SASI,wBAGA,GADP,AAAC,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAClC,AAZJ,SAYI",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Tabs.js
CHANGED
|
@@ -1,183 +1,6 @@
|
|
|
1
|
-
var
|
|
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
|
-
SizedMixin
|
|
15
|
-
} from "@spectrum-web-components/base";
|
|
16
|
-
import {
|
|
17
|
-
property,
|
|
18
|
-
query
|
|
19
|
-
} from "@spectrum-web-components/base/src/decorators.js";
|
|
20
|
-
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
21
|
-
import { Focusable } from "@spectrum-web-components/shared";
|
|
22
|
-
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
23
|
-
import tabStyles from "./tabs.css.js";
|
|
24
|
-
const noSelectionStyle = "transform: translateX(0px) scaleX(0) scaleY(0)";
|
|
25
|
-
export class Tabs extends SizedMixin(Focusable) {
|
|
26
|
-
constructor() {
|
|
27
|
-
super(...arguments);
|
|
28
|
-
this.auto = false;
|
|
29
|
-
this.direction = "horizontal";
|
|
30
|
-
this.emphasized = false;
|
|
31
|
-
this.label = "";
|
|
32
|
-
this.selectionIndicatorStyle = noSelectionStyle;
|
|
33
|
-
this.shouldAnimate = false;
|
|
34
|
-
this._selected = "";
|
|
35
|
-
this._tabs = [];
|
|
36
|
-
this.rovingTabindexController = new RovingTabindexController(this, {
|
|
37
|
-
focusInIndex: (elements) => {
|
|
38
|
-
let focusInIndex = 0;
|
|
39
|
-
const firstFocusableElement = elements.find((el, index) => {
|
|
40
|
-
const focusInElement = this.selected ? !el.disabled && el.value === this.selected : !el.disabled;
|
|
41
|
-
focusInIndex = index;
|
|
42
|
-
return focusInElement;
|
|
43
|
-
});
|
|
44
|
-
return firstFocusableElement ? focusInIndex : -1;
|
|
45
|
-
},
|
|
46
|
-
direction: () => this.direction === "horizontal" ? "horizontal" : "vertical",
|
|
47
|
-
elementEnterAction: (el) => {
|
|
48
|
-
if (!this.auto)
|
|
49
|
-
return;
|
|
50
|
-
this.shouldAnimate = true;
|
|
51
|
-
this.selectTarget(el);
|
|
52
|
-
},
|
|
53
|
-
elements: () => this.tabs,
|
|
54
|
-
isFocusableElement: (el) => !el.disabled,
|
|
55
|
-
listenerScope: () => this.tabList
|
|
56
|
-
});
|
|
57
|
-
this.onClick = (event) => {
|
|
58
|
-
if (this.disabled) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const target = event.composedPath().find((el) => el.parentElement === this);
|
|
62
|
-
if (!target || target.disabled) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
this.shouldAnimate = true;
|
|
66
|
-
this.selectTarget(target);
|
|
67
|
-
};
|
|
68
|
-
this.onKeyDown = (event) => {
|
|
69
|
-
if (event.code === "Enter" || event.code === "Space") {
|
|
70
|
-
event.preventDefault();
|
|
71
|
-
const target = event.target;
|
|
72
|
-
if (target) {
|
|
73
|
-
this.selectTarget(target);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
this.updateCheckedState = () => {
|
|
78
|
-
if (!this.tabs.length) {
|
|
79
|
-
this.tabs = [...this.querySelectorAll('[role="tab"]')];
|
|
80
|
-
}
|
|
81
|
-
this.tabs.forEach((element) => {
|
|
82
|
-
element.removeAttribute("selected");
|
|
83
|
-
});
|
|
84
|
-
if (this.selected) {
|
|
85
|
-
const currentChecked = this.tabs.find((el) => el.value === this.selected);
|
|
86
|
-
if (currentChecked) {
|
|
87
|
-
currentChecked.selected = true;
|
|
88
|
-
} else {
|
|
89
|
-
this.selected = "";
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
const firstTab = this.tabs[0];
|
|
93
|
-
if (firstTab) {
|
|
94
|
-
firstTab.setAttribute("tabindex", "0");
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
this.updateSelectionIndicator();
|
|
98
|
-
this.tabChangeResolver();
|
|
99
|
-
};
|
|
100
|
-
this.updateSelectionIndicator = async () => {
|
|
101
|
-
const selectedElement = this.tabs.find((el) => el.selected);
|
|
102
|
-
if (!selectedElement) {
|
|
103
|
-
this.selectionIndicatorStyle = noSelectionStyle;
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
await Promise.all([
|
|
107
|
-
selectedElement.updateComplete,
|
|
108
|
-
document.fonts ? document.fonts.ready : Promise.resolve()
|
|
109
|
-
]);
|
|
110
|
-
const tabBoundingClientRect = selectedElement.getBoundingClientRect();
|
|
111
|
-
if (this.direction === "horizontal") {
|
|
112
|
-
const width = tabBoundingClientRect.width;
|
|
113
|
-
const offset = selectedElement.offsetLeft;
|
|
114
|
-
this.selectionIndicatorStyle = `transform: translateX(${offset}px) scaleX(${width});`;
|
|
115
|
-
} else {
|
|
116
|
-
const height = tabBoundingClientRect.height;
|
|
117
|
-
const offset = selectedElement.offsetTop;
|
|
118
|
-
this.selectionIndicatorStyle = `transform: translateY(${offset}px) scaleY(${height});`;
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
this.tabChangePromise = Promise.resolve();
|
|
122
|
-
this.tabChangeResolver = function() {
|
|
123
|
-
return;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
static get styles() {
|
|
127
|
-
return [tabStyles];
|
|
128
|
-
}
|
|
129
|
-
get selected() {
|
|
130
|
-
return this._selected;
|
|
131
|
-
}
|
|
132
|
-
set selected(value) {
|
|
133
|
-
const oldValue = this.selected;
|
|
134
|
-
if (value === oldValue) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
this._selected = value;
|
|
138
|
-
this.shouldUpdateCheckedState();
|
|
139
|
-
this.requestUpdate("selected", oldValue);
|
|
140
|
-
}
|
|
141
|
-
set tabs(tabs) {
|
|
142
|
-
if (tabs === this.tabs)
|
|
143
|
-
return;
|
|
144
|
-
this._tabs = tabs;
|
|
145
|
-
this.rovingTabindexController.clearElementCache();
|
|
146
|
-
}
|
|
147
|
-
get tabs() {
|
|
148
|
-
return this._tabs;
|
|
149
|
-
}
|
|
150
|
-
get focusElement() {
|
|
151
|
-
return this.rovingTabindexController.focusInElement || this;
|
|
152
|
-
}
|
|
153
|
-
manageAutoFocus() {
|
|
154
|
-
const tabs = [...this.children];
|
|
155
|
-
const tabUpdateCompletes = tabs.map((tab) => {
|
|
156
|
-
if (typeof tab.updateComplete !== "undefined") {
|
|
157
|
-
return tab.updateComplete;
|
|
158
|
-
}
|
|
159
|
-
return Promise.resolve(true);
|
|
160
|
-
});
|
|
161
|
-
Promise.all(tabUpdateCompletes).then(() => super.manageAutoFocus());
|
|
162
|
-
}
|
|
163
|
-
managePanels({
|
|
164
|
-
target
|
|
165
|
-
}) {
|
|
166
|
-
const panels = target.assignedElements();
|
|
167
|
-
panels.map((panel) => {
|
|
168
|
-
const { value, id } = panel;
|
|
169
|
-
const tab = this.querySelector(`[role="tab"][value="${value}"]`);
|
|
170
|
-
if (tab) {
|
|
171
|
-
tab.setAttribute("aria-controls", id);
|
|
172
|
-
panel.setAttribute("aria-labelledby", tab.id);
|
|
173
|
-
}
|
|
174
|
-
panel.selected = value === this.selected;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
render() {
|
|
178
|
-
return html`
|
|
1
|
+
var u=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var o=(n,e,t,i)=>{for(var s=i>1?void 0:i?h(e,t):e,r=n.length-1,a;r>=0;r--)(a=n[r])&&(s=(i?a(e,t,s):a(s))||s);return i&&s&&u(e,t,s),s};import{html as p,SizedMixin as b}from"@spectrum-web-components/base";import{property as l,query as f}from"@spectrum-web-components/base/src/decorators.js";import{ifDefined as d}from"@spectrum-web-components/base/src/directives.js";import{Focusable as m}from"@spectrum-web-components/shared";import{RovingTabindexController as v}from"@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";import g from"./tabs.css.js";const c="transform: translateX(0px) scaleX(0) scaleY(0)";export class Tabs extends b(m){constructor(){super(...arguments);this.auto=!1;this.direction="horizontal";this.emphasized=!1;this.label="";this.selectionIndicatorStyle=c;this.shouldAnimate=!1;this._selected="";this._tabs=[];this.rovingTabindexController=new v(this,{focusInIndex:e=>{let t=0;return e.find((s,r)=>{const a=this.selected?!s.disabled&&s.value===this.selected:!s.disabled;return t=r,a})?t:-1},direction:()=>this.direction==="horizontal"?"horizontal":"vertical",elementEnterAction:e=>{!this.auto||(this.shouldAnimate=!0,this.selectTarget(e))},elements:()=>this.tabs,isFocusableElement:e=>!e.disabled,listenerScope:()=>this.tabList});this.onClick=e=>{if(this.disabled)return;const t=e.composedPath().find(i=>i.parentElement===this);!t||t.disabled||(this.shouldAnimate=!0,this.selectTarget(t))};this.onKeyDown=e=>{if(e.code==="Enter"||e.code==="Space"){e.preventDefault();const t=e.target;t&&this.selectTarget(t)}};this.updateCheckedState=()=>{if(this.tabs.length||(this.tabs=[...this.querySelectorAll('[role="tab"]')]),this.tabs.forEach(e=>{e.removeAttribute("selected")}),this.selected){const e=this.tabs.find(t=>t.value===this.selected);e?e.selected=!0:this.selected=""}else{const e=this.tabs[0];e&&e.setAttribute("tabindex","0")}this.updateSelectionIndicator(),this.tabChangeResolver()};this.updateSelectionIndicator=async()=>{const e=this.tabs.find(i=>i.selected);if(!e){this.selectionIndicatorStyle=c;return}await Promise.all([e.updateComplete,document.fonts?document.fonts.ready:Promise.resolve()]);const t=e.getBoundingClientRect();if(this.direction==="horizontal"){const i=t.width,s=e.offsetLeft;this.selectionIndicatorStyle=`transform: translateX(${s}px) scaleX(${i});`}else{const i=t.height,s=e.offsetTop;this.selectionIndicatorStyle=`transform: translateY(${s}px) scaleY(${i});`}};this.tabChangePromise=Promise.resolve();this.tabChangeResolver=function(){}}static get styles(){return[g]}get selected(){return this._selected}set selected(e){const t=this.selected;e!==t&&(this._selected=e,this.shouldUpdateCheckedState(),this.requestUpdate("selected",t))}set tabs(e){e!==this.tabs&&(this._tabs=e,this.rovingTabindexController.clearElementCache())}get tabs(){return this._tabs}get focusElement(){return this.rovingTabindexController.focusInElement||this}manageAutoFocus(){const t=[...this.children].map(i=>typeof i.updateComplete!="undefined"?i.updateComplete:Promise.resolve(!0));Promise.all(t).then(()=>super.manageAutoFocus())}managePanels({target:e}){e.assignedElements().map(i=>{const{value:s,id:r}=i,a=this.querySelector(`[role="tab"][value="${s}"]`);a&&(a.setAttribute("aria-controls",r),i.setAttribute("aria-labelledby",a.id)),i.selected=s===this.selected})}render(){return p`
|
|
179
2
|
<div
|
|
180
|
-
aria-label=${
|
|
3
|
+
aria-label=${d(this.label?this.label:void 0)}
|
|
181
4
|
@click=${this.onClick}
|
|
182
5
|
@keydown=${this.onKeyDown}
|
|
183
6
|
@sp-tab-contentchange=${this.updateSelectionIndicator}
|
|
@@ -188,117 +11,11 @@ export class Tabs extends SizedMixin(Focusable) {
|
|
|
188
11
|
<slot @slotchange=${this.onSlotChange}></slot>
|
|
189
12
|
<div
|
|
190
13
|
id="selection-indicator"
|
|
191
|
-
class=${
|
|
14
|
+
class=${d(this.shouldAnimate?void 0:"first-position")}
|
|
192
15
|
style=${this.selectionIndicatorStyle}
|
|
193
16
|
role="presentation"
|
|
194
17
|
></div>
|
|
195
18
|
</div>
|
|
196
19
|
<slot name="tab-panel" @slotchange=${this.managePanels}></slot>
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
willUpdate(changes) {
|
|
200
|
-
if (!this.hasUpdated) {
|
|
201
|
-
const selectedChild = this.querySelector(":scope > [selected]");
|
|
202
|
-
if (selectedChild) {
|
|
203
|
-
this.selectTarget(selectedChild);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
super.updated(changes);
|
|
207
|
-
if (changes.has("selected")) {
|
|
208
|
-
if (changes.get("selected")) {
|
|
209
|
-
const previous = this.querySelector(`[role="tabpanel"][value="${changes.get("selected")}"]`);
|
|
210
|
-
if (previous)
|
|
211
|
-
previous.selected = false;
|
|
212
|
-
}
|
|
213
|
-
const next = this.querySelector(`[role="tabpanel"][value="${this.selected}"]`);
|
|
214
|
-
if (next)
|
|
215
|
-
next.selected = true;
|
|
216
|
-
}
|
|
217
|
-
if (changes.has("direction")) {
|
|
218
|
-
if (this.direction === "horizontal") {
|
|
219
|
-
this.removeAttribute("aria-orientation");
|
|
220
|
-
} else {
|
|
221
|
-
this.setAttribute("aria-orientation", "vertical");
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (changes.has("dir")) {
|
|
225
|
-
this.updateSelectionIndicator();
|
|
226
|
-
}
|
|
227
|
-
if (changes.has("disabled")) {
|
|
228
|
-
if (this.disabled) {
|
|
229
|
-
this.setAttribute("aria-disabled", "true");
|
|
230
|
-
} else {
|
|
231
|
-
this.removeAttribute("aria-disabled");
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (!this.shouldAnimate && typeof changes.get("shouldAnimate") !== "undefined") {
|
|
235
|
-
this.shouldAnimate = true;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
selectTarget(target) {
|
|
239
|
-
const value = target.getAttribute("value");
|
|
240
|
-
if (value) {
|
|
241
|
-
const selected = this.selected;
|
|
242
|
-
this.selected = value;
|
|
243
|
-
const applyDefault = this.dispatchEvent(new Event("change", {
|
|
244
|
-
cancelable: true
|
|
245
|
-
}));
|
|
246
|
-
if (!applyDefault) {
|
|
247
|
-
this.selected = selected;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
onSlotChange() {
|
|
252
|
-
this.tabs = [...this.querySelectorAll('[role="tab"]')];
|
|
253
|
-
this.shouldUpdateCheckedState();
|
|
254
|
-
}
|
|
255
|
-
shouldUpdateCheckedState() {
|
|
256
|
-
this.tabChangeResolver();
|
|
257
|
-
this.tabChangePromise = new Promise((res) => this.tabChangeResolver = res);
|
|
258
|
-
setTimeout(this.updateCheckedState);
|
|
259
|
-
}
|
|
260
|
-
async getUpdateComplete() {
|
|
261
|
-
const complete = await super.getUpdateComplete();
|
|
262
|
-
await this.tabChangePromise;
|
|
263
|
-
return complete;
|
|
264
|
-
}
|
|
265
|
-
connectedCallback() {
|
|
266
|
-
super.connectedCallback();
|
|
267
|
-
window.addEventListener("resize", this.updateSelectionIndicator);
|
|
268
|
-
if ("fonts" in document) {
|
|
269
|
-
document.fonts.addEventListener("loadingdone", this.updateSelectionIndicator);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
disconnectedCallback() {
|
|
273
|
-
window.removeEventListener("resize", this.updateSelectionIndicator);
|
|
274
|
-
if ("fonts" in document) {
|
|
275
|
-
document.fonts.removeEventListener("loadingdone", this.updateSelectionIndicator);
|
|
276
|
-
}
|
|
277
|
-
super.disconnectedCallback();
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
__decorateClass([
|
|
281
|
-
property({ type: Boolean })
|
|
282
|
-
], Tabs.prototype, "auto", 2);
|
|
283
|
-
__decorateClass([
|
|
284
|
-
property({ reflect: true })
|
|
285
|
-
], Tabs.prototype, "direction", 2);
|
|
286
|
-
__decorateClass([
|
|
287
|
-
property({ type: Boolean, reflect: true })
|
|
288
|
-
], Tabs.prototype, "emphasized", 2);
|
|
289
|
-
__decorateClass([
|
|
290
|
-
property()
|
|
291
|
-
], Tabs.prototype, "label", 2);
|
|
292
|
-
__decorateClass([
|
|
293
|
-
property({ attribute: false })
|
|
294
|
-
], Tabs.prototype, "selectionIndicatorStyle", 2);
|
|
295
|
-
__decorateClass([
|
|
296
|
-
property({ attribute: false })
|
|
297
|
-
], Tabs.prototype, "shouldAnimate", 2);
|
|
298
|
-
__decorateClass([
|
|
299
|
-
query("#list")
|
|
300
|
-
], Tabs.prototype, "tabList", 2);
|
|
301
|
-
__decorateClass([
|
|
302
|
-
property({ reflect: true })
|
|
303
|
-
], Tabs.prototype, "selected", 1);
|
|
20
|
+
`}willUpdate(e){if(!this.hasUpdated){const t=this.querySelector(":scope > [selected]");t&&this.selectTarget(t)}if(super.updated(e),e.has("selected")){if(e.get("selected")){const i=this.querySelector(`[role="tabpanel"][value="${e.get("selected")}"]`);i&&(i.selected=!1)}const t=this.querySelector(`[role="tabpanel"][value="${this.selected}"]`);t&&(t.selected=!0)}e.has("direction")&&(this.direction==="horizontal"?this.removeAttribute("aria-orientation"):this.setAttribute("aria-orientation","vertical")),e.has("dir")&&this.updateSelectionIndicator(),e.has("disabled")&&(this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")),!this.shouldAnimate&&typeof e.get("shouldAnimate")!="undefined"&&(this.shouldAnimate=!0)}selectTarget(e){const t=e.getAttribute("value");if(t){const i=this.selected;this.selected=t,this.dispatchEvent(new Event("change",{cancelable:!0}))||(this.selected=i)}}onSlotChange(){this.tabs=[...this.querySelectorAll('[role="tab"]')],this.shouldUpdateCheckedState()}shouldUpdateCheckedState(){this.tabChangeResolver(),this.tabChangePromise=new Promise(e=>this.tabChangeResolver=e),setTimeout(this.updateCheckedState)}async getUpdateComplete(){const e=await super.getUpdateComplete();return await this.tabChangePromise,e}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.updateSelectionIndicator),"fonts"in document&&document.fonts.addEventListener("loadingdone",this.updateSelectionIndicator)}disconnectedCallback(){window.removeEventListener("resize",this.updateSelectionIndicator),"fonts"in document&&document.fonts.removeEventListener("loadingdone",this.updateSelectionIndicator),super.disconnectedCallback()}}o([l({type:Boolean})],Tabs.prototype,"auto",2),o([l({reflect:!0})],Tabs.prototype,"direction",2),o([l({type:Boolean,reflect:!0})],Tabs.prototype,"emphasized",2),o([l()],Tabs.prototype,"label",2),o([l({attribute:!1})],Tabs.prototype,"selectionIndicatorStyle",2),o([l({attribute:!1})],Tabs.prototype,"shouldAnimate",2),o([f("#list")],Tabs.prototype,"tabList",2),o([l({reflect:!0})],Tabs.prototype,"selected",1);
|
|
304
21
|
//# sourceMappingURL=Tabs.js.map
|