@fluid-topics/ft-tabs 0.3.31 → 0.3.32

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.
@@ -62,10 +62,15 @@ export const styles = css `
62
62
  color: ${FtTabsCssVariables.colorOnSurfaceDisabled};
63
63
  }
64
64
 
65
- .ft-tabs--align-justify [role='tab'] {
65
+ .ft-tabs--align-justify [role='tab'],
66
+ .ft-tabs--align-justify .ft-tabs--tab-tooltip {
66
67
  flex-grow: 1;
67
68
  }
68
69
 
70
+ .ft-tabs--align-justify .ft-tabs--tab-tooltip [role='tab'] {
71
+ width: 100%;
72
+ }
73
+
69
74
  [role='tab'] .ft-tabs--tab-label {
70
75
  width: 100%;
71
76
  white-space: nowrap;
@@ -1,4 +1,4 @@
1
- import { PropertyValues } from "lit";
1
+ import { PropertyValues, TemplateResult } from "lit";
2
2
  import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtTabsAlignment, FtTabsProperties } from "./ft-tabs.properties";
4
4
  export declare class IndexChangeEvent extends CustomEvent<number> {
@@ -15,7 +15,7 @@ export declare class FtTabs extends FtLitElement implements FtTabsProperties {
15
15
  private activeTab?;
16
16
  private activeTabIndicator?;
17
17
  activeIndex: number;
18
- protected render(): import("lit-html").TemplateResult<1>;
18
+ protected render(): TemplateResult<1>;
19
19
  private updateDebouncer;
20
20
  private scheduleRequestUpdate;
21
21
  private onContentChange;
@@ -24,5 +24,6 @@ export declare class FtTabs extends FtLitElement implements FtTabsProperties {
24
24
  protected contentAvailableCallback(props: PropertyValues): void;
25
25
  private placeIndicator;
26
26
  private updateTabs;
27
+ private addTooltipIfNecessary;
27
28
  }
28
29
  //# sourceMappingURL=ft-tabs.d.ts.map
package/build/ft-tabs.js CHANGED
@@ -15,6 +15,7 @@ import { FtTypography, FtTypographyVariants } from "@fluid-topics/ft-typography"
15
15
  import { FtIcon } from "@fluid-topics/ft-icon";
16
16
  import { FtTabsAlignment } from "./ft-tabs.properties";
17
17
  import { styles } from "./ft-tabs.css";
18
+ import { FtTooltip } from "@fluid-topics/ft-tooltip";
18
19
  export class IndexChangeEvent extends CustomEvent {
19
20
  constructor(index) {
20
21
  super("index-change", { detail: index });
@@ -41,12 +42,11 @@ export class FtTabs extends FtLitElement {
41
42
  return html `
42
43
  <div class="${classMap(classes)}" part="container">
43
44
  <div class="ft-tabs--align-${this.alignTabs}" role="tablist" part="tablist">
44
- ${repeat(this.ftTabs, (tab, index) => html `
45
+ ${repeat(this.ftTabs, (tab, index) => this.addTooltipIfNecessary(tab, html `
45
46
  <button class="${classMap({
46
47
  "ft-tabs--tab-with-icon": !!tab.icon,
47
48
  "ft-tabs--tab-with-label": !!tab.label,
48
49
  })}"
49
- title="${tab.label}"
50
50
  ?disabled=${tab.disabled}
51
51
  @click=${() => this.activeIndex = index}
52
52
  role="tab"
@@ -67,7 +67,7 @@ export class FtTabs extends FtLitElement {
67
67
  ${tab.label}
68
68
  </ft-typography>
69
69
  </button>
70
- `)}
70
+ `))}
71
71
  <div class="ft-tabs--active-tab-indicator" part="active-tab-indicator"></div>
72
72
  </div>
73
73
  <div class="ft-tabs--content" part="content">
@@ -102,15 +102,16 @@ export class FtTabs extends FtLitElement {
102
102
  this.placeIndicator();
103
103
  }
104
104
  placeIndicator() {
105
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
105
+ var _a, _b, _c, _d, _e, _f, _g;
106
106
  if (this.activeTabIndicator) {
107
- this.activeTabIndicator.style.width = ((_b = (_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 0) + "px";
108
- this.activeTabIndicator.style.left = ((_d = (_c = this.activeTab) === null || _c === void 0 ? void 0 : _c.offsetLeft) !== null && _d !== void 0 ? _d : 0) + "px";
107
+ 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;
108
+ this.activeTabIndicator.style.width = ((_c = target === null || target === void 0 ? void 0 : target.clientWidth) !== null && _c !== void 0 ? _c : 0) + "px";
109
+ this.activeTabIndicator.style.left = ((_d = target === null || target === void 0 ? void 0 : target.offsetLeft) !== null && _d !== void 0 ? _d : 0) + "px";
109
110
  if (this.contentBefore) {
110
- this.activeTabIndicator.style.top = ((_f = (_e = this.activeTab) === null || _e === void 0 ? void 0 : _e.offsetTop) !== null && _f !== void 0 ? _f : 0) + "px";
111
+ this.activeTabIndicator.style.top = ((_e = target === null || target === void 0 ? void 0 : target.offsetTop) !== null && _e !== void 0 ? _e : 0) + "px";
111
112
  }
112
113
  else {
113
- this.activeTabIndicator.style.top = (((_h = (_g = this.activeTab) === null || _g === void 0 ? void 0 : _g.offsetTop) !== null && _h !== void 0 ? _h : 0) + ((_k = (_j = this.activeTab) === null || _j === void 0 ? void 0 : _j.clientHeight) !== null && _k !== void 0 ? _k : 0) - this.activeTabIndicator.clientHeight) + "px";
114
+ this.activeTabIndicator.style.top = (((_f = target === null || target === void 0 ? void 0 : target.offsetTop) !== null && _f !== void 0 ? _f : 0) + ((_g = target === null || target === void 0 ? void 0 : target.clientHeight) !== null && _g !== void 0 ? _g : 0) - this.activeTabIndicator.clientHeight) + "px";
114
115
  }
115
116
  }
116
117
  }
@@ -119,10 +120,24 @@ export class FtTabs extends FtLitElement {
119
120
  tab.active = index == this.activeIndex;
120
121
  });
121
122
  }
123
+ addTooltipIfNecessary(tab, button) {
124
+ if (this.dense && tab.label && tab.icon) {
125
+ return html `
126
+ <ft-tooltip class="ft-tabs--tab-tooltip"
127
+ part="tab-tooltip"
128
+ text="${tab.label}"
129
+ position="${this.contentBefore ? "top" : "bottom"}">
130
+ ${button}
131
+ </ft-tooltip>
132
+ `;
133
+ }
134
+ return button;
135
+ }
122
136
  }
123
137
  FtTabs.elementDefinitions = {
124
138
  "ft-tab": FtTab,
125
139
  "ft-ripple": FtRipple,
140
+ "ft-tooltip": FtTooltip,
126
141
  "ft-typography": FtTypography,
127
142
  "ft-icon": FtIcon,
128
143
  };