@proximus/lavender-tabs 2.0.0-alpha.12 → 2.0.0-alpha.121
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/dist/PxTabs.d.ts +1 -0
- package/dist/Tab.d.ts +7 -5
- package/dist/TabPanel.d.ts +3 -2
- package/dist/Tabs.d.ts +14 -11
- package/dist/index.es.js +194 -149
- package/package.json +1 -1
package/dist/PxTabs.d.ts
CHANGED
package/dist/Tab.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const TAB_SELECTED_EVENT = "px.lavender.tab.selected";
|
|
2
|
+
export declare const TAB_CONNECTED_EVENT = "px-tab-connected";
|
|
1
3
|
export declare class Tab extends HTMLElement {
|
|
2
4
|
internals: ElementInternals;
|
|
3
5
|
template: () => string;
|
|
@@ -5,13 +7,13 @@ export declare class Tab extends HTMLElement {
|
|
|
5
7
|
constructor();
|
|
6
8
|
connectedCallback(): void;
|
|
7
9
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
8
|
-
get $
|
|
10
|
+
get $tabBtn(): HTMLSpanElement;
|
|
9
11
|
get selected(): boolean;
|
|
10
12
|
set selected(value: boolean);
|
|
11
13
|
get inverted(): boolean;
|
|
12
|
-
set
|
|
13
|
-
get
|
|
14
|
-
set
|
|
15
|
-
get
|
|
14
|
+
set id(value: string);
|
|
15
|
+
get id(): string;
|
|
16
|
+
set target(value: string);
|
|
17
|
+
get target(): string;
|
|
16
18
|
handleSelected(value: string): void;
|
|
17
19
|
}
|
package/dist/TabPanel.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export declare class TabPanel extends HTMLElement {
|
|
|
4
4
|
constructor();
|
|
5
5
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
6
6
|
connectedCallback(): void;
|
|
7
|
-
get
|
|
8
|
-
set
|
|
7
|
+
get panelId(): string;
|
|
8
|
+
set panelId(value: string);
|
|
9
9
|
set selected(value: boolean);
|
|
10
|
+
get selected(): boolean;
|
|
10
11
|
get $panel(): HTMLElement;
|
|
11
12
|
}
|
package/dist/Tabs.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import '@proximus/lavender-button-icon';
|
|
2
|
-
import { Tab } from './Tab.ts';
|
|
3
|
-
import { TabPanel } from './TabPanel.ts';
|
|
2
|
+
import { type Tab } from './Tab.ts';
|
|
3
|
+
import { type TabPanel } from './TabPanel.ts';
|
|
4
4
|
export declare class Tabs extends HTMLElement {
|
|
5
|
-
private
|
|
5
|
+
#private;
|
|
6
6
|
internals: ElementInternals;
|
|
7
|
-
tabsConnected: number;
|
|
8
7
|
template: () => string;
|
|
9
8
|
static get observedAttributes(): string[];
|
|
10
9
|
constructor();
|
|
11
10
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
12
11
|
connectedCallback(): void;
|
|
13
|
-
|
|
12
|
+
disconnectedCallback(): void;
|
|
14
13
|
navigateToTab(direction: 'left' | 'right'): void;
|
|
15
|
-
handleNextPreviousDisplay()
|
|
16
|
-
allTabsConnected(): boolean;
|
|
14
|
+
handleNextPreviousDisplay: () => void;
|
|
17
15
|
shouldDisplayScrollRightButton(): boolean;
|
|
18
16
|
shouldDisplayScrollLeftButton(): boolean;
|
|
19
17
|
get $activeTab(): Tab;
|
|
@@ -21,11 +19,16 @@ export declare class Tabs extends HTMLElement {
|
|
|
21
19
|
get $previousTab(): Tab;
|
|
22
20
|
get $activePanel(): TabPanel;
|
|
23
21
|
get $tabList(): HTMLElement;
|
|
22
|
+
get $tabs(): NodeListOf<Tab>;
|
|
23
|
+
get $tabPanels(): NodeListOf<TabPanel>;
|
|
24
24
|
get $prefixButton(): HTMLButtonElement;
|
|
25
25
|
get $suffixButton(): HTMLButtonElement;
|
|
26
|
-
get
|
|
27
|
-
set
|
|
26
|
+
get hideControls(): boolean;
|
|
27
|
+
set hideControls(value: boolean);
|
|
28
28
|
get inverted(): boolean;
|
|
29
|
-
|
|
30
|
-
get
|
|
29
|
+
set inverted(value: boolean);
|
|
30
|
+
get nextAriaLabel(): string;
|
|
31
|
+
set nextAriaLabel(value: string);
|
|
32
|
+
get previousAriaLabel(): string;
|
|
33
|
+
set previousAriaLabel(value: string);
|
|
31
34
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,20 +1,90 @@
|
|
|
1
|
+
var f = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
|
+
};
|
|
4
|
+
var S = (r, e, t) => e.has(r) || f("Cannot " + t);
|
|
5
|
+
var x = (r, e, t) => e.has(r) ? f("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t);
|
|
6
|
+
var n = (r, e, t) => (S(r, e, "access private method"), t);
|
|
1
7
|
import "@proximus/lavender-button-icon";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class
|
|
8
|
+
const k = "*{font-family:var(--px-font-family)}:host{background-color:var(--px-color-background-container-default-default)}:host(:first-child),:host(:first-child) .tab-btn{border-radius:var(--px-radius-main) var(--px-radius-none) var(--px-radius-none) var(--px-radius-main)}:host(:last-of-type),:host(:last-of-type) .tab-btn{border-radius:var(--px-radius-none) var(--px-radius-main) var(--px-radius-main) var(--px-radius-none)}:host([selected]){background-color:var(--px-color-background-state-active-default);border-radius:var(--px-radius-main)!important}:host([selected])>.tab-btn{cursor:auto;padding-block:var(--px-padding-m-mobile);color:var(--px-color-text-neutral-inverted)}.tab-btn{background:none;border:none;margin:0;padding:var(--px-padding-s-mobile);cursor:pointer;height:inherit;width:inherit;font-size:var(--px-text-size-label-l-mobile);font-weight:var(--px-font-weight-title);text-wrap:nowrap;color:var(--px-color-text-neutral-default);outline:none}:host(:focus-visible){outline-offset:var(--px-focus-offset-mobile);outline:var(--px-focus-outline-mobile) solid var(--px-color-border-focus-outline-default)}:host(:not([selected])) .tab-btn:hover{background-color:var(--px-color-background-state-hover-default)}:host([inverted]) .tab-btn{color:var(--px-color-text-neutral-inverted)}:host([inverted]:not([selected])) .tab-btn:hover{background-color:var(--px-color-background-state-hover-inverted)}:host([inverted][selected]) .tab-btn{color:var(--px-color-text-brand-default)}:host([inverted]:focus-visible){outline-color:var(--px-color-border-focus-outline-inverted)}@media screen and (min-width: 48rem){.tab-btn{padding:var(--px-padding-s-desktop);font-size:var(--px-text-size-label-l-desktop)}:host[selected]>.tab-btn{padding-block:var(--px-padding-m-desktop)}}@media screen and (min-width: 64.0625rem){.tab-btn{padding:var(--px-padding-s-desktop);font-size:var(--px-text-size-label-l-desktop)}:host[selected]>.tab-btn{padding-block:var(--px-padding-m-desktop)}}", g = new CSSStyleSheet();
|
|
9
|
+
g.replaceSync(k);
|
|
10
|
+
const m = "px.lavender.tab.selected", A = "px-tab-connected";
|
|
11
|
+
class L extends HTMLElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
var e;
|
|
14
|
+
super(), this.template = () => `
|
|
15
|
+
<div class="tab-btn"><slot></slot></div>
|
|
16
|
+
`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template(), this.shadowRoot.adoptedStyleSheets = [g], this.internals = (e = this.attachInternals) == null ? void 0 : e.call(this);
|
|
17
|
+
}
|
|
18
|
+
static get observedAttributes() {
|
|
19
|
+
return ["selected", "target", "id", "inverted"];
|
|
20
|
+
}
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
this.role = "tab", this.internals && (this.internals.role = "tab"), this.ariaSelected = `${this.selected}`, this.slot = "tabs", this.dispatchEvent(
|
|
23
|
+
new CustomEvent(A, { bubbles: !0, composed: !0 })
|
|
24
|
+
), this.addEventListener("click", () => {
|
|
25
|
+
this.selected = !0;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
attributeChangedCallback(e, t, s) {
|
|
29
|
+
e === "selected" ? this.handleSelected(s) : e === "id" ? this.$tabBtn.setAttribute("id", s) : e === "target" ? this.setAttribute("aria-controls", s) : e === "inverted" && (s === "" ? this.$tabBtn.setAttribute("inverted", "") : this.$tabBtn.removeAttribute("inverted"));
|
|
30
|
+
}
|
|
31
|
+
get $tabBtn() {
|
|
32
|
+
return this.shadowRoot.querySelector(".tab-btn");
|
|
33
|
+
}
|
|
34
|
+
get selected() {
|
|
35
|
+
return this.hasAttribute("selected");
|
|
36
|
+
}
|
|
37
|
+
set selected(e) {
|
|
38
|
+
e ? this.setAttribute("selected", "") : this.removeAttribute("selected");
|
|
39
|
+
}
|
|
40
|
+
get inverted() {
|
|
41
|
+
return this.hasAttribute("inverted");
|
|
42
|
+
}
|
|
43
|
+
set id(e) {
|
|
44
|
+
this.setAttribute("id", e);
|
|
45
|
+
}
|
|
46
|
+
get id() {
|
|
47
|
+
return this.getAttribute("id");
|
|
48
|
+
}
|
|
49
|
+
set target(e) {
|
|
50
|
+
this.setAttribute("target", e);
|
|
51
|
+
}
|
|
52
|
+
get target() {
|
|
53
|
+
return this.getAttribute("target");
|
|
54
|
+
}
|
|
55
|
+
handleSelected(e) {
|
|
56
|
+
e !== "" ? (this.tabIndex = -1, this.internals && (this.internals.ariaSelected = "false"), this.ariaSelected = "false") : (setTimeout(() => {
|
|
57
|
+
this.dispatchEvent(
|
|
58
|
+
new CustomEvent(m, {
|
|
59
|
+
bubbles: !0,
|
|
60
|
+
composed: !0,
|
|
61
|
+
detail: {
|
|
62
|
+
tabId: this.id,
|
|
63
|
+
targetId: this.target
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
}), this.focus(), this.tabIndex = 0, this.internals && (this.internals.ariaSelected = "true"), this.ariaSelected = "true");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const T = '*{font-family:var(--px-font-family)}#container{display:flex;flex-direction:column;align-items:flex-start;gap:var(--px-spacing-default-mobile)}#tab-container{position:relative;width:100%}#tab-container>#previous{position:absolute;top:12px;left:-24px}#tab-container>#next{position:absolute;top:12px;right:-24px}#panels{width:100%}#tablist{display:flex;align-items:center;scrollbar-width:none;overflow:scroll;width:100%;box-sizing:border-box;margin:calc(calc(var(--px-focus-outline-mobile) + var(--px-focus-offset-mobile)) * -1);padding:calc(var(--px-focus-outline-mobile) + var(--px-focus-offset-mobile))}#tablist::-webkit-scrollbar{display:none}:host([inverted]) #tablist ::slotted(px-tab){background-color:var(--px-color-background-container-default-inverted)}:host([inverted]) #tablist ::slotted(px-tab[selected=""]){background-color:var(--px-color-background-state-active-inverted)}:host([inverted]) #tablist ::slotted(px-tab[selected=""])>button{color:var(--px-color-text-brand-default)}:host([inverted]) button[role=tab]{color:var(--px-color-text-neutral-inverted)}:host([inverted]) button[aria-selected=""]{color:var(--px-color-text-brand-default)}@media screen and (min-width: 48rem){#container{gap:var(--px-spacing-default-desktop)}#tablist{margin:calc(calc(var(--px-focus-outline-tablet) + var(--px-focus-offset-tablet)) * -1);padding:calc(var(--px-focus-outline-tablet) + var(--px-focus-offset-tablet))}}@media screen and (min-width: 64.0625rem){#container{gap:var(--px-spacing-default-desktop)}#tablist{margin:calc(calc(var(--px-focus-outline-desktop) + var(--px-focus-offset-desktop)) * -1);padding:calc(var(--px-focus-outline-desktop) + var(--px-focus-offset-desktop))}}', b = new CSSStyleSheet();
|
|
71
|
+
b.replaceSync(T);
|
|
72
|
+
var o, d, $;
|
|
73
|
+
class E extends HTMLElement {
|
|
6
74
|
constructor() {
|
|
7
75
|
var t;
|
|
8
|
-
super()
|
|
76
|
+
super();
|
|
77
|
+
x(this, o);
|
|
78
|
+
this.template = () => `
|
|
9
79
|
<div id="container">
|
|
10
80
|
<div id="tab-container">
|
|
11
|
-
<px-button-icon id="previous"
|
|
81
|
+
<px-button-icon id="previous">
|
|
12
82
|
<px-icon name="chevron_left" from="lavender"></px-icon>
|
|
13
83
|
</px-button-icon>
|
|
14
|
-
<div id="tablist"
|
|
84
|
+
<div id="tablist">
|
|
15
85
|
<slot name="tabs"></slot>
|
|
16
86
|
</div>
|
|
17
|
-
<px-button-icon id="next"
|
|
87
|
+
<px-button-icon id="next" >
|
|
18
88
|
<px-icon name="chevron_right" from="lavender"></px-icon>
|
|
19
89
|
</px-button-icon>
|
|
20
90
|
</div>
|
|
@@ -22,78 +92,71 @@ class u extends HTMLElement {
|
|
|
22
92
|
<slot name="tabpanels"></slot>
|
|
23
93
|
</div>
|
|
24
94
|
</div>
|
|
25
|
-
`, this.
|
|
26
|
-
this.
|
|
27
|
-
}
|
|
28
|
-
this.handleNextPreviousDisplay();
|
|
29
|
-
}), this.$tabList.addEventListener("scroll", () => {
|
|
30
|
-
this.handleNextPreviousDisplay();
|
|
31
|
-
});
|
|
95
|
+
`, this.handleNextPreviousDisplay = () => {
|
|
96
|
+
this.$prefixButton && this.$suffixButton && (this.$prefixButton.style.display = this.shouldDisplayScrollLeftButton() ? "" : "none", this.$suffixButton.style.display = this.shouldDisplayScrollRightButton() ? "" : "none");
|
|
97
|
+
}, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template(), this.shadowRoot.adoptedStyleSheets = [b], this.internals = (t = this.attachInternals) == null ? void 0 : t.call(this);
|
|
32
98
|
}
|
|
33
99
|
static get observedAttributes() {
|
|
34
|
-
return [
|
|
35
|
-
|
|
36
|
-
|
|
100
|
+
return [
|
|
101
|
+
"inverted",
|
|
102
|
+
"next-aria-label",
|
|
103
|
+
"previous-aria-label",
|
|
104
|
+
"hide-controls"
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
attributeChangedCallback(t, s, i) {
|
|
37
108
|
switch (t) {
|
|
38
|
-
case "label":
|
|
39
|
-
this.label
|
|
109
|
+
case "next-aria-label":
|
|
110
|
+
this.hasAttribute("hide-controls") || this.$suffixButton.setAttribute("aria-label", i);
|
|
40
111
|
break;
|
|
41
|
-
case "aria-label
|
|
42
|
-
this.hasAttribute("hide-controls") || this.$
|
|
112
|
+
case "previous-aria-label":
|
|
113
|
+
this.hasAttribute("hide-controls") || this.$prefixButton.setAttribute("aria-label", i);
|
|
43
114
|
break;
|
|
44
|
-
case "
|
|
45
|
-
this
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
115
|
+
case "hide-controls":
|
|
116
|
+
n(this, o, $).call(this, i);
|
|
117
|
+
break;
|
|
118
|
+
case "inverted":
|
|
119
|
+
n(this, o, d).call(this, i);
|
|
49
120
|
break;
|
|
50
121
|
}
|
|
51
122
|
}
|
|
52
123
|
connectedCallback() {
|
|
53
|
-
var t,
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.$
|
|
58
|
-
|
|
59
|
-
|
|
124
|
+
var t, s;
|
|
125
|
+
this.$tabList.role = "tablist", this.addEventListener(
|
|
126
|
+
m,
|
|
127
|
+
(i) => {
|
|
128
|
+
[...this.$tabPanels].forEach((a) => {
|
|
129
|
+
a.getAttribute("panel-id") !== i.detail.targetId && a.hasAttribute("selected") && (a.removeAttribute("selected"), a.removeAttribute("aria-labelledby")), a.getAttribute("panel-id") === i.detail.targetId && (a.setAttribute("selected", ""), a.setAttribute("aria-labelledby", i.detail.tabId));
|
|
130
|
+
}), [...this.$tabs].forEach((a) => {
|
|
131
|
+
a.getAttribute("id") !== i.detail.tabId && a.hasAttribute("selected") && a.removeAttribute("selected");
|
|
132
|
+
});
|
|
60
133
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
134
|
+
), this.addEventListener(A, () => {
|
|
135
|
+
this.handleNextPreviousDisplay(), this.inverted && n(this, o, d).call(this, this.getAttribute("inverted"));
|
|
136
|
+
}), this.handleNextPreviousDisplay(), n(this, o, d).call(this, this.getAttribute("inverted")), this.addEventListener("keydown", (i) => {
|
|
137
|
+
var a, l;
|
|
138
|
+
(i.key === "ArrowRight" || i.key === "ArrowLeft") && ((l = (a = document.activeElement) == null ? void 0 : a.localName) != null && l.endsWith("-tab")) && this.navigateToTab(i.key === "ArrowRight" ? "right" : "left");
|
|
139
|
+
}), (t = this.$prefixButton) == null || t.addEventListener("click", (i) => {
|
|
140
|
+
i.stopPropagation(), this.$tabList.scrollTo({
|
|
66
141
|
left: this.$tabList.scrollLeft - 100,
|
|
67
142
|
behavior: "smooth"
|
|
68
143
|
});
|
|
69
|
-
}), (
|
|
70
|
-
|
|
144
|
+
}), (s = this.$suffixButton) == null || s.addEventListener("click", (i) => {
|
|
145
|
+
i.stopPropagation(), this.$tabList.scrollTo({
|
|
71
146
|
left: this.$tabList.scrollLeft + 100,
|
|
72
147
|
behavior: "smooth"
|
|
73
148
|
});
|
|
74
|
-
}),
|
|
75
|
-
"aria-label",
|
|
76
|
-
this.ariaLabelNext || "Next tab"
|
|
77
|
-
), this.$prefixButton.setAttribute(
|
|
78
|
-
"aria-label",
|
|
79
|
-
this.ariaLabelPrevious || "Previous tab"
|
|
80
|
-
));
|
|
149
|
+
}), window.addEventListener("resize", this.handleNextPreviousDisplay), this.$tabList.addEventListener("scroll", this.handleNextPreviousDisplay);
|
|
81
150
|
}
|
|
82
|
-
|
|
83
|
-
|
|
151
|
+
disconnectedCallback() {
|
|
152
|
+
window.addEventListener("resize", this.handleNextPreviousDisplay);
|
|
84
153
|
}
|
|
85
154
|
navigateToTab(t) {
|
|
86
|
-
const
|
|
87
|
-
this.$activePanel.selected = !1, this.$activeTab.selected = !1, t === "right" ? (
|
|
88
|
-
}
|
|
89
|
-
handleNextPreviousDisplay() {
|
|
90
|
-
this.allTabsConnected() && this.$prefixButton && this.$suffixButton && (this.$prefixButton.style.display = this.shouldDisplayScrollLeftButton() ? "" : "none", this.$suffixButton.style.display = this.shouldDisplayScrollRightButton() ? "" : "none");
|
|
91
|
-
}
|
|
92
|
-
allTabsConnected() {
|
|
93
|
-
return this.tabsConnected === this.querySelectorAll('[slot="tabs"]').length;
|
|
155
|
+
const s = this.$nextTab, i = this.$previousTab;
|
|
156
|
+
this.$activePanel.selected = !1, this.$activeTab.selected = !1, t === "right" ? (s.selected = !0, s.focus()) : t === "left" && (i.selected = !0, i.focus()), this.$activePanel.selected = !0;
|
|
94
157
|
}
|
|
95
158
|
shouldDisplayScrollRightButton() {
|
|
96
|
-
return this
|
|
159
|
+
return this.$tabList.scrollWidth > this.$tabList.clientWidth && this.$tabList.scrollWidth - this.$tabList.scrollLeft !== this.$tabList.clientWidth;
|
|
97
160
|
}
|
|
98
161
|
shouldDisplayScrollLeftButton() {
|
|
99
162
|
return this.$tabList.scrollLeft > 0;
|
|
@@ -110,146 +173,128 @@ class u extends HTMLElement {
|
|
|
110
173
|
return t || Array.from(this.querySelectorAll('[slot="tabs"]')).pop();
|
|
111
174
|
}
|
|
112
175
|
get $activePanel() {
|
|
113
|
-
|
|
176
|
+
var t;
|
|
177
|
+
return this.querySelector(
|
|
178
|
+
`[panel-id="${(t = this.$activeTab) == null ? void 0 : t.target}"]`
|
|
179
|
+
);
|
|
114
180
|
}
|
|
115
181
|
get $tabList() {
|
|
116
182
|
return this.shadowRoot.querySelector("#tablist");
|
|
117
183
|
}
|
|
184
|
+
get $tabs() {
|
|
185
|
+
return this.querySelectorAll('[slot="tabs"]');
|
|
186
|
+
}
|
|
187
|
+
get $tabPanels() {
|
|
188
|
+
return this.querySelectorAll('[slot="tabpanels"]');
|
|
189
|
+
}
|
|
118
190
|
get $prefixButton() {
|
|
119
191
|
return this.shadowRoot.querySelector("#previous");
|
|
120
192
|
}
|
|
121
193
|
get $suffixButton() {
|
|
122
194
|
return this.shadowRoot.querySelector("#next");
|
|
123
195
|
}
|
|
124
|
-
get
|
|
125
|
-
return this
|
|
126
|
-
}
|
|
127
|
-
set label(t) {
|
|
128
|
-
this.$tabList.setAttribute("aria-labelledby", t);
|
|
129
|
-
}
|
|
130
|
-
get inverted() {
|
|
131
|
-
return this.hasAttribute("inverted");
|
|
132
|
-
}
|
|
133
|
-
get ariaLabelNext() {
|
|
134
|
-
return this.getAttribute("aria-label-next");
|
|
135
|
-
}
|
|
136
|
-
get ariaLabelPrevious() {
|
|
137
|
-
return this.getAttribute("aria-label-previous");
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const h = "*{font-family:var(--px-font-family)}:host{background-color:var(--px-color-background-container-default-default)}:host(:first-child),:host(:first-child) button{border-radius:var(--px-radius-main) var(--px-radius-none) var(--px-radius-none) var(--px-radius-main)}:host(:last-of-type),:host(:last-of-type) button{border-radius:var(--px-radius-none) var(--px-radius-main) var(--px-radius-main) var(--px-radius-none)}:host([selected]){background-color:var(--px-color-background-state-active-default);border-radius:var(--px-radius-main)!important}:host([selected])>button{cursor:auto;padding-block:var(--px-padding-m-mobile);color:var(--px-color-text-neutral-inverted)}button{background:none;border:none;margin:0;padding:var(--px-padding-s-mobile);cursor:pointer;height:inherit;width:inherit;font-size:var(--px-text-size-label-l-mobile);font-weight:var(--px-font-weight-title);text-wrap:nowrap;color:var(--px-color-text-neutral-default);outline:none}:host(:focus-visible){outline-offset:var(--px-focus-offset-mobile);outline:var(--px-focus-outline-mobile) solid var(--px-color-border-focus-outline-default)}:host(:not([selected])) button:hover{background-color:var(--px-color-background-state-hover-default)}:host([inverted]) button{color:var(--px-color-text-neutral-inverted)}:host([inverted]:not([selected])) button:hover{background-color:var(--px-color-background-state-hover-inverted)}:host([inverted][selected]) button{color:var(--px-color-text-brand-default)}:host([inverted]:focus-visible){outline-color:var(--px-color-border-focus-outline-inverted)}@media only screen and (min-width: 768px){button{padding:var(--px-padding-s-desktop);font-size:var(--px-text-size-label-l-desktop)}:host[selected]>button{padding-block:var(--px-padding-m-desktop)}}@media only screen and (min-width: 1025px){button{padding:var(--px-padding-s-desktop);font-size:var(--px-text-size-label-l-desktop)}:host[selected]>button{padding-block:var(--px-padding-m-desktop)}}", d = new CSSStyleSheet();
|
|
141
|
-
d.replaceSync(h);
|
|
142
|
-
class p extends HTMLElement {
|
|
143
|
-
constructor() {
|
|
144
|
-
var t;
|
|
145
|
-
super(), this.template = () => `
|
|
146
|
-
<button type="button" tabindex="-1" >
|
|
147
|
-
<span><slot></slot></span>
|
|
148
|
-
</button>
|
|
149
|
-
`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template(), this.shadowRoot.adoptedStyleSheets = [d], this.internals = (t = this.attachInternals) == null ? void 0 : t.call(this), this.role = "tab", this.internals && (this.internals.role = "tab"), this.ariaSelected = `${this.selected}`;
|
|
150
|
-
}
|
|
151
|
-
static get observedAttributes() {
|
|
152
|
-
return ["selected", "for", "name"];
|
|
153
|
-
}
|
|
154
|
-
connectedCallback() {
|
|
155
|
-
this.name || console.error("Tab needs a name attribute"), this.for || console.error("Tab needs a for attribute"), this.slot = "tabs", this.parentElement.inverted && (this.setAttribute("inverted", ""), this.$button.setAttribute("inverted", "")), this.dispatchEvent(
|
|
156
|
-
new CustomEvent("px-tab-connected", { bubbles: !0, composed: !0 })
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
attributeChangedCallback(t, i, e) {
|
|
160
|
-
t === "selected" ? this.handleSelected(e) : t === "name" ? this.$button.setAttribute("id", e) : t === "for" && this.setAttribute("aria-controls", e);
|
|
196
|
+
get hideControls() {
|
|
197
|
+
return this.hasAttribute("hide-controls");
|
|
161
198
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
get selected() {
|
|
166
|
-
return !!this.hasAttribute("selected");
|
|
167
|
-
}
|
|
168
|
-
set selected(t) {
|
|
169
|
-
t ? this.setAttribute("selected", "") : this.removeAttribute("selected");
|
|
199
|
+
set hideControls(t) {
|
|
200
|
+
t ? this.setAttribute("hide-controls", "") : this.removeAttribute("hide-controls");
|
|
170
201
|
}
|
|
171
202
|
get inverted() {
|
|
172
203
|
return this.hasAttribute("inverted");
|
|
173
204
|
}
|
|
174
|
-
set
|
|
175
|
-
this.setAttribute("
|
|
205
|
+
set inverted(t) {
|
|
206
|
+
t ? this.setAttribute("inverted", "") : this.removeAttribute("inverted");
|
|
176
207
|
}
|
|
177
|
-
get
|
|
178
|
-
return this.getAttribute("
|
|
208
|
+
get nextAriaLabel() {
|
|
209
|
+
return this.getAttribute("next-aria-label");
|
|
179
210
|
}
|
|
180
|
-
set
|
|
181
|
-
this.setAttribute("
|
|
211
|
+
set nextAriaLabel(t) {
|
|
212
|
+
this.setAttribute("next-aria-label", t);
|
|
182
213
|
}
|
|
183
|
-
get
|
|
184
|
-
return this.getAttribute("
|
|
214
|
+
get previousAriaLabel() {
|
|
215
|
+
return this.getAttribute("previous-aria-label");
|
|
185
216
|
}
|
|
186
|
-
|
|
187
|
-
|
|
217
|
+
set previousAriaLabel(t) {
|
|
218
|
+
this.setAttribute("previous-aria-label", t);
|
|
188
219
|
}
|
|
189
220
|
}
|
|
190
|
-
|
|
221
|
+
o = new WeakSet(), d = function(t) {
|
|
222
|
+
var s, i, a, l, h, u, p, v;
|
|
223
|
+
t === "" ? ((s = this.$prefixButton) == null || s.setAttribute("inverted", ""), (i = this.$suffixButton) == null || i.setAttribute("inverted", ""), (a = this.$activePanel) == null || a.setAttribute("inverted", ""), (l = this.$activeTab) == null || l.setAttribute("inverted", ""), [...this.$tabs].forEach((c) => {
|
|
224
|
+
c.setAttribute("inverted", "");
|
|
225
|
+
})) : ((h = this.$prefixButton) == null || h.removeAttribute("inverted"), (u = this.$suffixButton) == null || u.removeAttribute("inverted"), (p = this.$activePanel) == null || p.removeAttribute("inverted"), (v = this.$activeTab) == null || v.removeAttribute("inverted"), [...this.$tabs].forEach((c) => {
|
|
226
|
+
c.removeAttribute("inverted");
|
|
227
|
+
}));
|
|
228
|
+
}, $ = function(t) {
|
|
229
|
+
t === "" ? (this.$prefixButton.remove(), this.$suffixButton.remove()) : (this.$suffixButton.setAttribute(
|
|
230
|
+
"aria-label",
|
|
231
|
+
this.nextAriaLabel || "Next tab"
|
|
232
|
+
), this.$prefixButton.setAttribute(
|
|
233
|
+
"aria-label",
|
|
234
|
+
this.previousAriaLabel || "Previous tab"
|
|
235
|
+
));
|
|
236
|
+
};
|
|
237
|
+
const w = ":host [role=tabpanel]{overflow-x:auto}", y = new CSSStyleSheet();
|
|
238
|
+
y.replaceSync(w);
|
|
239
|
+
class B extends HTMLElement {
|
|
191
240
|
constructor() {
|
|
192
241
|
super(), this.template = () => `
|
|
193
|
-
<div role="tabpanel"
|
|
242
|
+
<div role="tabpanel" id="${this.panelId}" tabindex="0">
|
|
194
243
|
<slot></slot>
|
|
195
244
|
</div>
|
|
196
|
-
`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template(), this.shadowRoot.adoptedStyleSheets = [
|
|
245
|
+
`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template(), this.shadowRoot.adoptedStyleSheets = [b, y];
|
|
197
246
|
}
|
|
198
247
|
static get observedAttributes() {
|
|
199
|
-
return ["
|
|
248
|
+
return ["id", "selected"];
|
|
200
249
|
}
|
|
201
|
-
attributeChangedCallback(
|
|
202
|
-
|
|
250
|
+
attributeChangedCallback(e, t, s) {
|
|
251
|
+
e === "panel-id" ? this.$panel.setAttribute("id", s) : e === "selected" && (s === "" ? this.$panel.style.display = "block" : this.$panel.style.display = "none");
|
|
203
252
|
}
|
|
204
253
|
connectedCallback() {
|
|
205
|
-
this.
|
|
206
|
-
const t = this.parentElement.querySelector(
|
|
207
|
-
`[for="${this.getAttribute("name")}"]`
|
|
208
|
-
);
|
|
209
|
-
t ? this.$panel.setAttribute(
|
|
210
|
-
"aria-labelledby",
|
|
211
|
-
t.getAttribute("name")
|
|
212
|
-
) : console.error("No tab found for this panel");
|
|
213
|
-
const i = this.parentElement.querySelector(
|
|
214
|
-
`[for="${this.name}"]`
|
|
215
|
-
);
|
|
216
|
-
c(i.selected) ? this.selected = !1 : this.selected = !0;
|
|
254
|
+
this.slot = "tabpanels", this.$panel.style.display = "none";
|
|
217
255
|
}
|
|
218
|
-
get
|
|
219
|
-
return this.getAttribute("
|
|
256
|
+
get panelId() {
|
|
257
|
+
return this.getAttribute("panel-id");
|
|
220
258
|
}
|
|
221
|
-
set
|
|
222
|
-
this.setAttribute("
|
|
259
|
+
set panelId(e) {
|
|
260
|
+
this.setAttribute("panel-id", e);
|
|
223
261
|
}
|
|
224
|
-
set selected(
|
|
225
|
-
|
|
262
|
+
set selected(e) {
|
|
263
|
+
e ? this.setAttribute("selected", "") : this.removeAttribute("selected");
|
|
264
|
+
}
|
|
265
|
+
get selected() {
|
|
266
|
+
return this.hasAttribute("selected");
|
|
226
267
|
}
|
|
227
268
|
get $panel() {
|
|
228
269
|
return this.shadowRoot.querySelector('[role="tabpanel"]');
|
|
229
270
|
}
|
|
230
271
|
}
|
|
231
|
-
class
|
|
272
|
+
class C extends E {
|
|
232
273
|
constructor() {
|
|
233
|
-
super()
|
|
274
|
+
super();
|
|
275
|
+
}
|
|
276
|
+
connectedCallback() {
|
|
277
|
+
var e;
|
|
278
|
+
(e = super.connectedCallback) == null || e.call(this), this.querySelectorAll("px-tab").forEach((t) => {
|
|
234
279
|
t.setAttribute("slot", "tabs");
|
|
235
280
|
});
|
|
236
281
|
}
|
|
237
282
|
}
|
|
238
|
-
customElements.get("px-tabs") || customElements.define("px-tabs",
|
|
239
|
-
class
|
|
283
|
+
customElements.get("px-tabs") || customElements.define("px-tabs", C);
|
|
284
|
+
class P extends L {
|
|
240
285
|
constructor() {
|
|
241
286
|
super();
|
|
242
287
|
}
|
|
243
288
|
}
|
|
244
|
-
customElements.get("px-tab") || customElements.define("px-tab",
|
|
245
|
-
class
|
|
289
|
+
customElements.get("px-tab") || customElements.define("px-tab", P);
|
|
290
|
+
class R extends B {
|
|
246
291
|
constructor() {
|
|
247
292
|
super();
|
|
248
293
|
}
|
|
249
294
|
}
|
|
250
|
-
customElements.get("px-tab-panel") || customElements.define("px-tab-panel",
|
|
295
|
+
customElements.get("px-tab-panel") || customElements.define("px-tab-panel", R);
|
|
251
296
|
export {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
297
|
+
P as PxTab,
|
|
298
|
+
R as PxTabPanel,
|
|
299
|
+
C as PxTabs
|
|
255
300
|
};
|