@fluid-topics/ft-tabs 2.0.38 → 2.1.1
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/build/definitions.d.ts +0 -2
- package/build/definitions.js +0 -2
- package/build/ft-tabs.d.ts +26 -14
- package/build/ft-tabs.js +140 -12
- package/build/ft-tabs.light.js +182 -958
- package/build/ft-tabs.min.js +194 -969
- package/build/ft-tabs.properties.d.ts +15 -0
- package/build/ft-tabs.properties.js +8 -0
- package/build/ft-tabs.styles.d.ts +8 -8
- package/build/ft-tabs.styles.js +2 -2
- package/build/index.d.ts +1 -3
- package/build/index.js +1 -3
- package/package.json +7 -7
- package/build/ft-base-tabs.d.ts +0 -42
- package/build/ft-base-tabs.js +0 -191
- package/build/ftds-tabs.d.ts +0 -19
- package/build/ftds-tabs.js +0 -48
- package/build/ftds-tabs.styles.d.ts +0 -2
- package/build/ftds-tabs.styles.js +0 -182
package/build/definitions.d.ts
CHANGED
package/build/definitions.js
CHANGED
package/build/ft-tabs.d.ts
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
|
+
import { PropertyValues, TemplateResult } from "lit";
|
|
1
2
|
import { ClassInfo } from "lit/directives/class-map.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface FtTabsProperties extends FtBaseTabsProperties {
|
|
7
|
-
dense: boolean;
|
|
8
|
-
collapsible: boolean;
|
|
9
|
-
contentBefore: boolean;
|
|
3
|
+
import { ElementDefinitionsMap, FtLitElement, Optional } from "@fluid-topics/ft-wc-utils";
|
|
4
|
+
import { FtTabsAlignment, FtTabsProperties } from "./ft-tabs.properties";
|
|
5
|
+
export declare class IndexChangeEvent extends CustomEvent<Optional<number>> {
|
|
6
|
+
constructor(index: Optional<number>);
|
|
10
7
|
}
|
|
11
|
-
export declare class FtTabs extends
|
|
8
|
+
export declare class FtTabs extends FtLitElement implements FtTabsProperties {
|
|
12
9
|
static elementDefinitions: ElementDefinitionsMap;
|
|
10
|
+
static styles: import("lit").CSSResult[];
|
|
11
|
+
activeIndex?: number;
|
|
12
|
+
alignTabs: FtTabsAlignment;
|
|
13
|
+
horizontal: boolean;
|
|
13
14
|
dense: boolean;
|
|
14
15
|
collapsible: boolean;
|
|
15
16
|
contentBefore: boolean;
|
|
16
|
-
|
|
17
|
+
private ftTabs;
|
|
18
|
+
private tabsContainer?;
|
|
19
|
+
private activeTab?;
|
|
20
|
+
private activeTabIndicator?;
|
|
17
21
|
get tabsClasses(): ClassInfo;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
protected render(): TemplateResult<1>;
|
|
23
|
+
private updateDebouncer;
|
|
24
|
+
private onTabUpdated;
|
|
25
|
+
private onContentChange;
|
|
26
|
+
protected update(props: PropertyValues): void;
|
|
27
|
+
private resizeObserver;
|
|
28
|
+
protected contentAvailableCallback(props: PropertyValues): void;
|
|
29
|
+
private placeIndicator;
|
|
30
|
+
private placeActiveTabIndicator;
|
|
31
|
+
private toggleTab;
|
|
32
|
+
private updateTabs;
|
|
33
|
+
private addTooltipIfNecessary;
|
|
22
34
|
}
|
package/build/ft-tabs.js
CHANGED
|
@@ -4,18 +4,39 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
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, numberProperty, PostResizeEvent, PreResizeEvent, safariEllipsisFix, } from "@fluid-topics/ft-wc-utils";
|
|
12
|
+
import { FtTab } from "./ft-tab";
|
|
13
|
+
import { FtRipple, FtRippleCssVariables, } from "@fluid-topics/ft-ripple";
|
|
14
|
+
import { FtIcon } from "@fluid-topics/ft-icon";
|
|
15
|
+
import { FtTooltip } from "@fluid-topics/ft-tooltip";
|
|
16
|
+
import { FtTabsAlignment, } from "./ft-tabs.properties";
|
|
17
|
+
import { FtTypography, FtTypographyVariants, } from "@fluid-topics/ft-typography";
|
|
18
|
+
import { tabsStyles } from "./ft-tabs.styles";
|
|
19
|
+
export class IndexChangeEvent extends CustomEvent {
|
|
20
|
+
constructor(index) {
|
|
21
|
+
super("index-change", { detail: index });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class FtTabs extends FtLitElement {
|
|
14
25
|
constructor() {
|
|
15
26
|
super(...arguments);
|
|
27
|
+
this.activeIndex = 0;
|
|
28
|
+
this.alignTabs = FtTabsAlignment.justify;
|
|
29
|
+
this.horizontal = false;
|
|
16
30
|
this.dense = false;
|
|
17
31
|
this.collapsible = false;
|
|
18
32
|
this.contentBefore = false;
|
|
33
|
+
this.ftTabs = [];
|
|
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());
|
|
19
40
|
}
|
|
20
41
|
get tabsClasses() {
|
|
21
42
|
return {
|
|
@@ -27,8 +48,86 @@ export class FtTabs extends FtBaseTabs {
|
|
|
27
48
|
["ft-tabs--align-" + this.alignTabs]: true,
|
|
28
49
|
};
|
|
29
50
|
}
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
render() {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
const activeTabColor = (_b = this.ftTabs[(_a = this.activeIndex) !== null && _a !== void 0 ? _a : 0]) === null || _b === void 0 ? void 0 : _b.color;
|
|
54
|
+
return html `
|
|
55
|
+
<div class="${classMap(this.tabsClasses)}" part="container">
|
|
56
|
+
<div role="tablist" part="tablist">
|
|
57
|
+
${repeat(this.ftTabs, (tab, index) => this.addTooltipIfNecessary(tab, html `
|
|
58
|
+
<button class="${classMap({
|
|
59
|
+
"ft-tabs--tab-with-icon": !!tab.icon,
|
|
60
|
+
"ft-tabs--tab-with-label": !!tab.label,
|
|
61
|
+
})}"
|
|
62
|
+
?disabled=${tab.disabled}
|
|
63
|
+
@click=${() => this.toggleTab(index)}
|
|
64
|
+
role="tab"
|
|
65
|
+
part="tab tab-${tab.id}${tab.active ? " active-tab" : ""}"
|
|
66
|
+
id="${tab.ariaLabelledBy}"
|
|
67
|
+
aria-label="${tab.label}"
|
|
68
|
+
aria-selected="${tab.active ? "true" : "false"}"
|
|
69
|
+
tabindex="${tab.disabled ? "-1" : "0"}"
|
|
70
|
+
aria-controls="${tab.id}"
|
|
71
|
+
style="${tab.color ? `color: ${tab.color} !important;` : ""}">
|
|
72
|
+
<ft-ripple primary
|
|
73
|
+
?disabled=${tab.disabled}
|
|
74
|
+
part="tab-ripple${tab.active ? " active-tab-ripple" : ""}"
|
|
75
|
+
style="${(tab.color || tab.rippleColor)
|
|
76
|
+
? FtRippleCssVariables.color.set(tab.color || tab.rippleColor)
|
|
77
|
+
: ""}"></ft-ripple>
|
|
78
|
+
<ft-icon class="ft-tabs--tab-icon"
|
|
79
|
+
part="tab-icon${tab.active ? " active-tab-icon" : ""}"
|
|
80
|
+
.variant=${tab.iconVariant}>
|
|
81
|
+
${tab.icon}
|
|
82
|
+
</ft-icon>
|
|
83
|
+
<ft-typography class="ft-tabs--tab-label"
|
|
84
|
+
part="tab-label${tab.active ? " active-tab-label" : ""}"
|
|
85
|
+
variant="${FtTypographyVariants.body2}">
|
|
86
|
+
${tab.label}
|
|
87
|
+
</ft-typography>
|
|
88
|
+
</button>
|
|
89
|
+
`))}
|
|
90
|
+
<div class="ft-tabs--active-tab-indicator"
|
|
91
|
+
part="active-tab-indicator"
|
|
92
|
+
style="${activeTabColor ? `background-color: ${activeTabColor} !important;` : ""}">
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
<div class="ft-tabs--content" part="content">
|
|
96
|
+
<slot @slotchange=${this.onContentChange}></slot>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
onContentChange(e) {
|
|
102
|
+
const slot = e.composedPath()[0];
|
|
103
|
+
this.ftTabs = slot.assignedElements().map((n) => n);
|
|
104
|
+
this.ftTabs.forEach((tab) => {
|
|
105
|
+
tab.removeEventListener("updated", this.onTabUpdated);
|
|
106
|
+
tab.addEventListener("updated", this.onTabUpdated);
|
|
107
|
+
});
|
|
108
|
+
this.updateTabs();
|
|
109
|
+
}
|
|
110
|
+
update(props) {
|
|
111
|
+
super.update(props);
|
|
112
|
+
if (props.has("activeIndex")) {
|
|
113
|
+
this.dispatchEvent(new PreResizeEvent());
|
|
114
|
+
}
|
|
115
|
+
if (props.has("ftTabs") || props.has("activeIndex")) {
|
|
116
|
+
this.updateTabs();
|
|
117
|
+
}
|
|
118
|
+
if (props.has("activeIndex")) {
|
|
119
|
+
this.dispatchEvent(new IndexChangeEvent(this.activeIndex));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
contentAvailableCallback(props) {
|
|
123
|
+
super.contentAvailableCallback(props);
|
|
124
|
+
if (this.tabsContainer) {
|
|
125
|
+
this.resizeObserver.observe(this.tabsContainer);
|
|
126
|
+
}
|
|
127
|
+
this.placeIndicator();
|
|
128
|
+
}
|
|
129
|
+
placeIndicator() {
|
|
130
|
+
this.placeActiveTabIndicator(this.activeTabIndicator, this.activeTab);
|
|
32
131
|
}
|
|
33
132
|
placeActiveTabIndicator(activeTabIndicator, activeTab) {
|
|
34
133
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -69,6 +168,11 @@ export class FtTabs extends FtBaseTabs {
|
|
|
69
168
|
toggleTab(index) {
|
|
70
169
|
this.activeIndex = this.collapsible && index === this.activeIndex ? undefined : index;
|
|
71
170
|
}
|
|
171
|
+
updateTabs() {
|
|
172
|
+
this.ftTabs.forEach((tab, index) => {
|
|
173
|
+
tab.active = index == this.activeIndex;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
72
176
|
addTooltipIfNecessary(tab, button) {
|
|
73
177
|
if (tab.label && tab.icon && (this.dense || this.horizontal)) {
|
|
74
178
|
const tooltipPosition = this.horizontal
|
|
@@ -87,13 +191,25 @@ export class FtTabs extends FtBaseTabs {
|
|
|
87
191
|
}
|
|
88
192
|
}
|
|
89
193
|
FtTabs.elementDefinitions = {
|
|
90
|
-
|
|
91
|
-
"ft-
|
|
194
|
+
"ft-tab": FtTab,
|
|
195
|
+
"ft-ripple": FtRipple,
|
|
196
|
+
"ft-tooltip": FtTooltip,
|
|
197
|
+
"ft-icon": FtIcon,
|
|
198
|
+
"ft-typography": FtTypography,
|
|
92
199
|
};
|
|
93
200
|
FtTabs.styles = [
|
|
94
201
|
safariEllipsisFix,
|
|
95
|
-
|
|
202
|
+
tabsStyles,
|
|
96
203
|
];
|
|
204
|
+
__decorate([
|
|
205
|
+
numberProperty({ reflect: true })
|
|
206
|
+
], FtTabs.prototype, "activeIndex", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property()
|
|
209
|
+
], FtTabs.prototype, "alignTabs", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property({ type: Boolean })
|
|
212
|
+
], FtTabs.prototype, "horizontal", void 0);
|
|
97
213
|
__decorate([
|
|
98
214
|
property({ type: Boolean })
|
|
99
215
|
], FtTabs.prototype, "dense", void 0);
|
|
@@ -103,3 +219,15 @@ __decorate([
|
|
|
103
219
|
__decorate([
|
|
104
220
|
property({ type: Boolean })
|
|
105
221
|
], FtTabs.prototype, "contentBefore", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
state()
|
|
224
|
+
], FtTabs.prototype, "ftTabs", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
query("[role='tablist']")
|
|
227
|
+
], FtTabs.prototype, "tabsContainer", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
query("[aria-selected='true']")
|
|
230
|
+
], FtTabs.prototype, "activeTab", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
query(".ft-tabs--active-tab-indicator")
|
|
233
|
+
], FtTabs.prototype, "activeTabIndicator", void 0);
|