@fluid-topics/ft-tabs 1.1.78 → 1.1.80

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.
@@ -0,0 +1,46 @@
1
+ import { PropertyValues, TemplateResult } from "lit";
2
+ import { ElementDefinitionsMap, FtLitElement, Optional } from "@fluid-topics/ft-wc-utils";
3
+ import { ClassInfo } from "lit/directives/class-map";
4
+ export declare enum FtTabsAlignment {
5
+ left = "left",
6
+ right = "right",
7
+ start = "start",
8
+ end = "end",
9
+ justify = "justify"
10
+ }
11
+ export interface FtBaseTabsProperties {
12
+ dense: boolean;
13
+ collapsible: boolean;
14
+ horizontal: boolean;
15
+ contentBefore: boolean;
16
+ activeIndex?: number;
17
+ alignTabs: FtTabsAlignment;
18
+ }
19
+ export declare class IndexChangeEvent extends CustomEvent<Optional<number>> {
20
+ constructor(index: Optional<number>);
21
+ }
22
+ export declare abstract class FtBaseTabs extends FtLitElement implements FtBaseTabsProperties {
23
+ static elementDefinitions: ElementDefinitionsMap;
24
+ dense: boolean;
25
+ collapsible: boolean;
26
+ horizontal: boolean;
27
+ contentBefore: boolean;
28
+ alignTabs: FtTabsAlignment;
29
+ private ftTabs;
30
+ private tabsContainer?;
31
+ private activeTab?;
32
+ private activeTabIndicator?;
33
+ activeIndex?: number;
34
+ abstract get tabsClasses(): ClassInfo;
35
+ protected render(): TemplateResult<1>;
36
+ private updateDebouncer;
37
+ private onTabUpdated;
38
+ private onContentChange;
39
+ protected update(props: PropertyValues): void;
40
+ private resizeObserver;
41
+ protected contentAvailableCallback(props: PropertyValues): void;
42
+ private placeIndicator;
43
+ private toggleTab;
44
+ private updateTabs;
45
+ private addTooltipIfNecessary;
46
+ }
@@ -0,0 +1,223 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html } from "lit";
8
+ import { property, query, state } from "lit/decorators.js";
9
+ import { repeat } from "lit/directives/repeat.js";
10
+ import { classMap } from "lit/directives/class-map.js";
11
+ import { Debouncer, FtLitElement, optionalNumberProperty, PostResizeEvent, PreResizeEvent } from "@fluid-topics/ft-wc-utils";
12
+ import { FtTab } from "./ft-tab";
13
+ import { FtRipple } from "@fluid-topics/ft-ripple";
14
+ import { FtTypography, FtTypographyVariants } from "@fluid-topics/ft-typography";
15
+ import { FtIcon } from "@fluid-topics/ft-icon";
16
+ import { FtTooltip } from "@fluid-topics/ft-tooltip";
17
+ export var FtTabsAlignment;
18
+ (function (FtTabsAlignment) {
19
+ FtTabsAlignment["left"] = "left";
20
+ FtTabsAlignment["right"] = "right";
21
+ FtTabsAlignment["start"] = "start";
22
+ FtTabsAlignment["end"] = "end";
23
+ FtTabsAlignment["justify"] = "justify";
24
+ })(FtTabsAlignment || (FtTabsAlignment = {}));
25
+ export class IndexChangeEvent extends CustomEvent {
26
+ constructor(index) {
27
+ super("index-change", { detail: index });
28
+ }
29
+ }
30
+ class FtBaseTabs extends FtLitElement {
31
+ constructor() {
32
+ super(...arguments);
33
+ this.dense = false;
34
+ this.collapsible = false;
35
+ this.horizontal = false;
36
+ this.contentBefore = false;
37
+ this.alignTabs = FtTabsAlignment.justify;
38
+ this.ftTabs = [];
39
+ this.activeIndex = 0;
40
+ this.updateDebouncer = new Debouncer(2);
41
+ this.onTabUpdated = () => this.updateDebouncer.run(() => {
42
+ this.requestUpdate();
43
+ this.dispatchEvent(new PostResizeEvent());
44
+ });
45
+ this.resizeObserver = new ResizeObserver(() => this.placeIndicator());
46
+ }
47
+ render() {
48
+ var _a, _b;
49
+ const activeTabColor = (_b = this.ftTabs[(_a = this.activeIndex) !== null && _a !== void 0 ? _a : 0]) === null || _b === void 0 ? void 0 : _b.color;
50
+ return html `
51
+ <div class="${classMap(this.tabsClasses)}" part="container">
52
+ <div role="tablist" part="tablist">
53
+ ${repeat(this.ftTabs, (tab, index) => this.addTooltipIfNecessary(tab, html `
54
+ <button class="${classMap({
55
+ "ft-tabs--tab-with-icon": !!tab.icon,
56
+ "ft-tabs--tab-with-label": !!tab.label,
57
+ })}"
58
+ ?disabled=${tab.disabled}
59
+ @click=${() => this.toggleTab(index)}
60
+ role="tab"
61
+ part="tab tab-${tab.id}${tab.active ? " active-tab" : ""}"
62
+ id="${tab.ariaLabelledBy}"
63
+ aria-label="${tab.label}"
64
+ aria-selected="${tab.active ? "true" : "false"}"
65
+ tabindex="${tab.disabled ? "-1" : "0"}"
66
+ aria-controls="${tab.id}"
67
+ style="${tab.color ? `color: ${tab.color} !important;` : ""}">
68
+ <ft-ripple primary
69
+ ?disabled=${tab.disabled}
70
+ part="tab-ripple${tab.active ? " active-tab-ripple" : ""}"
71
+ style="${(tab.color || tab.rippleColor)
72
+ ? `--ft-ripple-color: ${tab.color || tab.rippleColor};`
73
+ : ""}"></ft-ripple>
74
+ <ft-icon class="ft-tabs--tab-icon"
75
+ part="tab-icon${tab.active ? " active-tab-icon" : ""}"
76
+ .variant=${tab.iconVariant}>
77
+ ${tab.icon}
78
+ </ft-icon>
79
+ <ft-typography class="ft-tabs--tab-label"
80
+ part="tab-label${tab.active ? " active-tab-label" : ""}"
81
+ variant="${FtTypographyVariants.body2}">
82
+ ${tab.label}
83
+ </ft-typography>
84
+ </button>
85
+ `))}
86
+ <div class="ft-tabs--active-tab-indicator"
87
+ part="active-tab-indicator"
88
+ style="${activeTabColor ? `background-color: ${activeTabColor} !important;` : ""}">
89
+ </div>
90
+ </div>
91
+ <div class="ft-tabs--content" part="content">
92
+ <slot @slotchange=${this.onContentChange}></slot>
93
+ </div>
94
+ </div>
95
+ `;
96
+ }
97
+ onContentChange(e) {
98
+ const slot = e.composedPath()[0];
99
+ this.ftTabs = slot.assignedElements().map(n => n);
100
+ this.ftTabs.forEach(tab => {
101
+ tab.removeEventListener("updated", this.onTabUpdated);
102
+ tab.addEventListener("updated", this.onTabUpdated);
103
+ });
104
+ this.updateTabs();
105
+ }
106
+ update(props) {
107
+ super.update(props);
108
+ if (props.has("activeIndex")) {
109
+ this.dispatchEvent(new PreResizeEvent());
110
+ }
111
+ if (props.has("ftTabs") || props.has("activeIndex")) {
112
+ this.updateTabs();
113
+ }
114
+ if (props.has("activeIndex")) {
115
+ this.dispatchEvent(new IndexChangeEvent(this.activeIndex));
116
+ }
117
+ }
118
+ contentAvailableCallback(props) {
119
+ super.contentAvailableCallback(props);
120
+ if (this.tabsContainer) {
121
+ this.resizeObserver.observe(this.tabsContainer);
122
+ }
123
+ this.placeIndicator();
124
+ }
125
+ placeIndicator() {
126
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
127
+ if (this.activeTabIndicator) {
128
+ const target = (_b = (_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.closest(".ft-tabs--tab-tooltip")) !== null && _b !== void 0 ? _b : this.activeTab;
129
+ if (target) {
130
+ const targetHeight = (_d = (_c = target === null || target === void 0 ? void 0 : target.getBoundingClientRect()) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 0;
131
+ const targetWidth = (_f = (_e = target === null || target === void 0 ? void 0 : target.getBoundingClientRect()) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : 0;
132
+ if (this.horizontal) {
133
+ this.activeTabIndicator.style.height = targetHeight + "px";
134
+ this.activeTabIndicator.style.width = "3px";
135
+ this.activeTabIndicator.style.top = ((_g = target === null || target === void 0 ? void 0 : target.offsetTop) !== null && _g !== void 0 ? _g : 0) + "px";
136
+ if (this.contentBefore) {
137
+ this.activeTabIndicator.style.left = ((_h = target === null || target === void 0 ? void 0 : target.offsetLeft) !== null && _h !== void 0 ? _h : 0) + "px";
138
+ }
139
+ else {
140
+ this.activeTabIndicator.style.left = (((_j = target === null || target === void 0 ? void 0 : target.offsetLeft) !== null && _j !== void 0 ? _j : 0) + targetWidth - 3) + "px";
141
+ }
142
+ }
143
+ else {
144
+ this.activeTabIndicator.style.height = "3px";
145
+ this.activeTabIndicator.style.width = targetWidth + "px";
146
+ this.activeTabIndicator.style.left = ((_k = target === null || target === void 0 ? void 0 : target.offsetLeft) !== null && _k !== void 0 ? _k : 0) + "px";
147
+ if (this.contentBefore) {
148
+ this.activeTabIndicator.style.top = ((_l = target === null || target === void 0 ? void 0 : target.offsetTop) !== null && _l !== void 0 ? _l : 0) + "px";
149
+ }
150
+ else {
151
+ this.activeTabIndicator.style.top = (((_m = target === null || target === void 0 ? void 0 : target.offsetTop) !== null && _m !== void 0 ? _m : 0) + targetHeight - 3) + "px";
152
+ }
153
+ }
154
+ }
155
+ else {
156
+ this.activeTabIndicator.style.height = "0px";
157
+ this.activeTabIndicator.style.width = "0px";
158
+ }
159
+ }
160
+ }
161
+ toggleTab(index) {
162
+ this.activeIndex = this.collapsible && index === this.activeIndex ? undefined : index;
163
+ }
164
+ updateTabs() {
165
+ this.ftTabs.forEach((tab, index) => {
166
+ tab.active = index == this.activeIndex;
167
+ });
168
+ }
169
+ addTooltipIfNecessary(tab, button) {
170
+ if (tab.label && tab.icon && (this.dense || this.horizontal)) {
171
+ let tooltipPosition = this.horizontal
172
+ ? this.contentBefore ? "left" : "right"
173
+ : this.contentBefore ? "top" : "bottom";
174
+ return html `
175
+ <ft-tooltip class="ft-tabs--tab-tooltip"
176
+ part="tab-tooltip"
177
+ text="${tab.label}"
178
+ position="${tooltipPosition}">
179
+ ${button}
180
+ </ft-tooltip>
181
+ `;
182
+ }
183
+ return button;
184
+ }
185
+ }
186
+ FtBaseTabs.elementDefinitions = {
187
+ "ft-tab": FtTab,
188
+ "ft-ripple": FtRipple,
189
+ "ft-tooltip": FtTooltip,
190
+ "ft-typography": FtTypography,
191
+ "ft-icon": FtIcon,
192
+ };
193
+ __decorate([
194
+ property({ type: Boolean })
195
+ ], FtBaseTabs.prototype, "dense", void 0);
196
+ __decorate([
197
+ property({ type: Boolean })
198
+ ], FtBaseTabs.prototype, "collapsible", void 0);
199
+ __decorate([
200
+ property({ type: Boolean })
201
+ ], FtBaseTabs.prototype, "horizontal", void 0);
202
+ __decorate([
203
+ property({ type: Boolean })
204
+ ], FtBaseTabs.prototype, "contentBefore", void 0);
205
+ __decorate([
206
+ property()
207
+ ], FtBaseTabs.prototype, "alignTabs", void 0);
208
+ __decorate([
209
+ state()
210
+ ], FtBaseTabs.prototype, "ftTabs", void 0);
211
+ __decorate([
212
+ query("[role='tablist']")
213
+ ], FtBaseTabs.prototype, "tabsContainer", void 0);
214
+ __decorate([
215
+ query("[aria-selected='true']")
216
+ ], FtBaseTabs.prototype, "activeTab", void 0);
217
+ __decorate([
218
+ query(".ft-tabs--active-tab-indicator")
219
+ ], FtBaseTabs.prototype, "activeTabIndicator", void 0);
220
+ __decorate([
221
+ optionalNumberProperty({ reflect: true })
222
+ ], FtBaseTabs.prototype, "activeIndex", void 0);
223
+ export { FtBaseTabs };
@@ -1,31 +1,6 @@
1
- import { PropertyValues, TemplateResult } from "lit";
2
- import { ElementDefinitionsMap, FtLitElement, Optional } from "@fluid-topics/ft-wc-utils";
3
- import { FtTabsAlignment, FtTabsProperties } from "./ft-tabs.properties";
4
- export declare class IndexChangeEvent extends CustomEvent<Optional<number>> {
5
- constructor(index: Optional<number>);
6
- }
7
- export declare class FtTabs extends FtLitElement implements FtTabsProperties {
8
- static elementDefinitions: ElementDefinitionsMap;
9
- static styles: import("lit").CSSResult;
10
- dense: boolean;
11
- collapsible: boolean;
12
- horizontal: boolean;
13
- contentBefore: boolean;
14
- alignTabs: FtTabsAlignment;
15
- private ftTabs;
16
- private tabsContainer?;
17
- private activeTab?;
18
- private activeTabIndicator?;
19
- activeIndex?: number;
20
- protected render(): TemplateResult<1>;
21
- private updateDebouncer;
22
- private onTabUpdated;
23
- private onContentChange;
24
- protected update(props: PropertyValues): void;
25
- private resizeObserver;
26
- protected contentAvailableCallback(props: PropertyValues): void;
27
- private placeIndicator;
28
- private toggleTab;
29
- private updateTabs;
30
- private addTooltipIfNecessary;
1
+ import { ClassInfo } from "lit/directives/class-map";
2
+ import { FtBaseTabs } from "./ft-base-tabs";
3
+ export declare class FtTabs extends FtBaseTabs {
4
+ static styles: import("lit").CSSResult[];
5
+ get tabsClasses(): ClassInfo;
31
6
  }
package/build/ft-tabs.js CHANGED
@@ -1,46 +1,9 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { html } from "lit";
8
- import { property, query, state } from "lit/decorators.js";
9
- import { repeat } from "lit/directives/repeat.js";
10
- import { classMap } from "lit/directives/class-map.js";
11
- import { Debouncer, FtLitElement, optionalNumberProperty, PostResizeEvent, PreResizeEvent } from "@fluid-topics/ft-wc-utils";
12
- import { FtTab } from "./ft-tab";
13
- import { FtRipple } from "@fluid-topics/ft-ripple";
14
- import { FtTypography, FtTypographyVariants } from "@fluid-topics/ft-typography";
15
- import { FtIcon } from "@fluid-topics/ft-icon";
16
- import { FtTabsAlignment } from "./ft-tabs.properties";
1
+ import { FtBaseTabs } from "./ft-base-tabs";
2
+ import { safariEllipsisFix } from "@fluid-topics/ft-wc-utils";
17
3
  import { styles } from "./ft-tabs.styles";
18
- import { FtTooltip } from "@fluid-topics/ft-tooltip";
19
- export class IndexChangeEvent extends CustomEvent {
20
- constructor(index) {
21
- super("index-change", { detail: index });
22
- }
23
- }
24
- class FtTabs extends FtLitElement {
25
- constructor() {
26
- super(...arguments);
27
- this.dense = false;
28
- this.collapsible = false;
29
- this.horizontal = false;
30
- this.contentBefore = false;
31
- this.alignTabs = FtTabsAlignment.justify;
32
- this.ftTabs = [];
33
- this.activeIndex = 0;
34
- this.updateDebouncer = new Debouncer(2);
35
- this.onTabUpdated = () => this.updateDebouncer.run(() => {
36
- this.requestUpdate();
37
- this.dispatchEvent(new PostResizeEvent());
38
- });
39
- this.resizeObserver = new ResizeObserver(() => this.placeIndicator());
40
- }
41
- render() {
42
- var _a, _b;
43
- const classes = {
4
+ class FtTabs extends FtBaseTabs {
5
+ get tabsClasses() {
6
+ return {
44
7
  "ft-tabs": true,
45
8
  "ft-tabs--collapsed": this.collapsible && this.activeIndex == null,
46
9
  "ft-tabs--horizontal": this.horizontal,
@@ -48,178 +11,10 @@ class FtTabs extends FtLitElement {
48
11
  "ft-tabs--dense": this.dense,
49
12
  ["ft-tabs--align-" + this.alignTabs]: true
50
13
  };
51
- const activeTabColor = (_b = this.ftTabs[(_a = this.activeIndex) !== null && _a !== void 0 ? _a : 0]) === null || _b === void 0 ? void 0 : _b.color;
52
- return html `
53
- <div class="${classMap(classes)}" part="container">
54
- <div role="tablist" part="tablist">
55
- ${repeat(this.ftTabs, (tab, index) => this.addTooltipIfNecessary(tab, html `
56
- <button class="${classMap({
57
- "ft-tabs--tab-with-icon": !!tab.icon,
58
- "ft-tabs--tab-with-label": !!tab.label,
59
- })}"
60
- ?disabled=${tab.disabled}
61
- @click=${() => this.toggleTab(index)}
62
- role="tab"
63
- part="tab tab-${tab.id}${tab.active ? " active-tab" : ""}"
64
- id="${tab.ariaLabelledBy}"
65
- aria-label="${tab.label}"
66
- aria-selected="${tab.active ? "true" : "false"}"
67
- tabindex="${tab.disabled ? "-1" : "0"}"
68
- aria-controls="${tab.id}"
69
- style="${tab.color ? `color: ${tab.color} !important;` : ""}">
70
- <ft-ripple primary
71
- ?disabled=${tab.disabled}
72
- part="tab-ripple${tab.active ? " active-tab-ripple" : ""}"
73
- style="${(tab.color || tab.rippleColor)
74
- ? `--ft-ripple-color: ${tab.color || tab.rippleColor};`
75
- : ""}"></ft-ripple>
76
- <ft-icon class="ft-tabs--tab-icon"
77
- part="tab-icon${tab.active ? " active-tab-icon" : ""}"
78
- .variant=${tab.iconVariant}>
79
- ${tab.icon}
80
- </ft-icon>
81
- <ft-typography class="ft-tabs--tab-label"
82
- part="tab-label${tab.active ? " active-tab-label" : ""}"
83
- variant="${FtTypographyVariants.body2}">
84
- ${tab.label}
85
- </ft-typography>
86
- </button>
87
- `))}
88
- <div class="ft-tabs--active-tab-indicator"
89
- part="active-tab-indicator"
90
- style="${activeTabColor ? `background-color: ${activeTabColor} !important;` : ""}">
91
- </div>
92
- </div>
93
- <div class="ft-tabs--content" part="content">
94
- <slot @slotchange=${this.onContentChange}></slot>
95
- </div>
96
- </div>
97
- `;
98
- }
99
- onContentChange(e) {
100
- const slot = e.composedPath()[0];
101
- this.ftTabs = slot.assignedElements().map(n => n);
102
- this.ftTabs.forEach(tab => {
103
- tab.removeEventListener("updated", this.onTabUpdated);
104
- tab.addEventListener("updated", this.onTabUpdated);
105
- });
106
- this.updateTabs();
107
- }
108
- update(props) {
109
- super.update(props);
110
- if (props.has("activeIndex")) {
111
- this.dispatchEvent(new PreResizeEvent());
112
- }
113
- if (props.has("ftTabs") || props.has("activeIndex")) {
114
- this.updateTabs();
115
- }
116
- if (props.has("activeIndex")) {
117
- this.dispatchEvent(new IndexChangeEvent(this.activeIndex));
118
- }
119
- }
120
- contentAvailableCallback(props) {
121
- super.contentAvailableCallback(props);
122
- if (this.tabsContainer) {
123
- this.resizeObserver.observe(this.tabsContainer);
124
- }
125
- this.placeIndicator();
126
- }
127
- placeIndicator() {
128
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
129
- if (this.activeTabIndicator) {
130
- const target = (_b = (_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.closest(".ft-tabs--tab-tooltip")) !== null && _b !== void 0 ? _b : this.activeTab;
131
- if (target) {
132
- if (this.horizontal) {
133
- this.activeTabIndicator.style.height = ((_c = target === null || target === void 0 ? void 0 : target.clientHeight) !== null && _c !== void 0 ? _c : 0) + "px";
134
- this.activeTabIndicator.style.width = "3px";
135
- this.activeTabIndicator.style.top = ((_d = target === null || target === void 0 ? void 0 : target.offsetTop) !== null && _d !== void 0 ? _d : 0) + "px";
136
- if (this.contentBefore) {
137
- this.activeTabIndicator.style.left = ((_e = target === null || target === void 0 ? void 0 : target.offsetLeft) !== null && _e !== void 0 ? _e : 0) + "px";
138
- }
139
- else {
140
- this.activeTabIndicator.style.left = (((_f = target === null || target === void 0 ? void 0 : target.offsetLeft) !== null && _f !== void 0 ? _f : 0) + ((_g = target === null || target === void 0 ? void 0 : target.clientWidth) !== null && _g !== void 0 ? _g : 0) - 3) + "px";
141
- }
142
- }
143
- else {
144
- this.activeTabIndicator.style.height = "3px";
145
- this.activeTabIndicator.style.width = ((_h = target === null || target === void 0 ? void 0 : target.clientWidth) !== null && _h !== void 0 ? _h : 0) + "px";
146
- this.activeTabIndicator.style.left = ((_j = target === null || target === void 0 ? void 0 : target.offsetLeft) !== null && _j !== void 0 ? _j : 0) + "px";
147
- if (this.contentBefore) {
148
- this.activeTabIndicator.style.top = ((_k = target === null || target === void 0 ? void 0 : target.offsetTop) !== null && _k !== void 0 ? _k : 0) + "px";
149
- }
150
- else {
151
- this.activeTabIndicator.style.top = (((_l = target === null || target === void 0 ? void 0 : target.offsetTop) !== null && _l !== void 0 ? _l : 0) + ((_m = target === null || target === void 0 ? void 0 : target.clientHeight) !== null && _m !== void 0 ? _m : 0) - 3) + "px";
152
- }
153
- }
154
- }
155
- else {
156
- this.activeTabIndicator.style.height = "0px";
157
- this.activeTabIndicator.style.width = "0px";
158
- }
159
- }
160
- }
161
- toggleTab(index) {
162
- this.activeIndex = this.collapsible && index === this.activeIndex ? undefined : index;
163
- }
164
- updateTabs() {
165
- this.ftTabs.forEach((tab, index) => {
166
- tab.active = index == this.activeIndex;
167
- });
168
- }
169
- addTooltipIfNecessary(tab, button) {
170
- if (tab.label && tab.icon && (this.dense || this.horizontal)) {
171
- let tooltipPosition = this.horizontal
172
- ? this.contentBefore ? "left" : "right"
173
- : this.contentBefore ? "top" : "bottom";
174
- return html `
175
- <ft-tooltip class="ft-tabs--tab-tooltip"
176
- part="tab-tooltip"
177
- text="${tab.label}"
178
- position="${tooltipPosition}">
179
- ${button}
180
- </ft-tooltip>
181
- `;
182
- }
183
- return button;
184
14
  }
185
15
  }
186
- FtTabs.elementDefinitions = {
187
- "ft-tab": FtTab,
188
- "ft-ripple": FtRipple,
189
- "ft-tooltip": FtTooltip,
190
- "ft-typography": FtTypography,
191
- "ft-icon": FtIcon,
192
- };
193
- // language=CSS
194
- FtTabs.styles = styles;
195
- __decorate([
196
- property({ type: Boolean })
197
- ], FtTabs.prototype, "dense", void 0);
198
- __decorate([
199
- property({ type: Boolean })
200
- ], FtTabs.prototype, "collapsible", void 0);
201
- __decorate([
202
- property({ type: Boolean })
203
- ], FtTabs.prototype, "horizontal", void 0);
204
- __decorate([
205
- property({ type: Boolean })
206
- ], FtTabs.prototype, "contentBefore", void 0);
207
- __decorate([
208
- property()
209
- ], FtTabs.prototype, "alignTabs", void 0);
210
- __decorate([
211
- state()
212
- ], FtTabs.prototype, "ftTabs", void 0);
213
- __decorate([
214
- query("[role='tablist']")
215
- ], FtTabs.prototype, "tabsContainer", void 0);
216
- __decorate([
217
- query("[aria-selected='true']")
218
- ], FtTabs.prototype, "activeTab", void 0);
219
- __decorate([
220
- query(".ft-tabs--active-tab-indicator")
221
- ], FtTabs.prototype, "activeTabIndicator", void 0);
222
- __decorate([
223
- optionalNumberProperty({ reflect: true })
224
- ], FtTabs.prototype, "activeIndex", void 0);
16
+ FtTabs.styles = [
17
+ safariEllipsisFix,
18
+ styles
19
+ ];
225
20
  export { FtTabs };