@fluid-topics/ft-button 2.0.37 → 2.1.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/build/definitions.d.ts +0 -2
- package/build/definitions.js +0 -2
- package/build/ft-button.d.ts +42 -6
- package/build/ft-button.js +205 -18
- package/build/ft-button.light.js +380 -1431
- package/build/ft-button.min.js +384 -1446
- package/build/ft-button.properties.d.ts +20 -2
- package/build/ft-button.styles.d.ts +18 -18
- package/build/ft-button.styles.js +139 -142
- package/build/index.d.ts +0 -3
- package/build/index.js +0 -3
- package/package.json +8 -9
- package/build/ft-base-button.d.ts +0 -62
- package/build/ft-base-button.js +0 -212
- package/build/ftds-button.d.ts +0 -20
- package/build/ftds-button.js +0 -69
- package/build/ftds-button.properties.d.ts +0 -6
- package/build/ftds-button.properties.js +0 -1
- package/build/ftds-button.styles.d.ts +0 -148
- package/build/ftds-button.styles.js +0 -485
package/build/definitions.d.ts
CHANGED
package/build/definitions.js
CHANGED
package/build/ft-button.d.ts
CHANGED
|
@@ -1,14 +1,50 @@
|
|
|
1
|
-
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { Position } from "@fluid-topics/ft-tooltip";
|
|
3
|
+
import { FtIconVariants } from "@fluid-topics/ft-icon";
|
|
4
|
+
import { HTMLTemplateResult } from "lit";
|
|
4
5
|
import { ClassInfo } from "lit/directives/class-map.js";
|
|
5
|
-
|
|
6
|
+
import { FtButtonProperties, HTMLAnchorElementTargetAttribute } from "./ft-button.properties";
|
|
7
|
+
declare const FtButton_base: import("@fluid-topics/ft-wc-utils").FtFormComponentType<typeof FtLitElement>;
|
|
8
|
+
export declare class FtButton extends FtButton_base implements FtButtonProperties {
|
|
6
9
|
static elementDefinitions: ElementDefinitionsMap;
|
|
7
10
|
primary: boolean;
|
|
8
11
|
outlined: boolean;
|
|
9
12
|
dense: boolean;
|
|
10
13
|
round: boolean;
|
|
11
|
-
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
icon?: string;
|
|
16
|
+
iconVariant?: FtIconVariants;
|
|
17
|
+
trailingIcon: boolean;
|
|
18
|
+
label: string;
|
|
19
|
+
type: "button" | "submit" | "reset";
|
|
20
|
+
href?: string;
|
|
21
|
+
target?: HTMLAnchorElementTargetAttribute;
|
|
22
|
+
loading: boolean;
|
|
23
|
+
ariaLabel: string | null;
|
|
24
|
+
ariaHasPopup: string | null;
|
|
25
|
+
ariaPressed: string | null;
|
|
26
|
+
tooltipPosition: Position;
|
|
27
|
+
hideTooltip: boolean;
|
|
28
|
+
forceTooltip: boolean;
|
|
29
|
+
activated: boolean;
|
|
30
|
+
private button?;
|
|
31
|
+
private slottedContent?;
|
|
32
|
+
private tooltip?;
|
|
33
|
+
static styles: import("lit").CSSResult[];
|
|
12
34
|
get buttonClasses(): ClassInfo;
|
|
13
|
-
|
|
35
|
+
constructor();
|
|
36
|
+
protected render(): HTMLTemplateResult;
|
|
37
|
+
private addTooltipIfNeeded;
|
|
38
|
+
private resolveIcon;
|
|
39
|
+
focus(): void;
|
|
40
|
+
showTooltip(): void;
|
|
41
|
+
showTemporaryTooltip(text: string, duration: number): Promise<void> | undefined;
|
|
42
|
+
private setTooltipManual;
|
|
43
|
+
click(): void;
|
|
44
|
+
private getLabel;
|
|
45
|
+
getTextContent(): string;
|
|
46
|
+
protected hasTextContent(): boolean;
|
|
47
|
+
private onSlotchange;
|
|
48
|
+
private isDisabled;
|
|
14
49
|
}
|
|
50
|
+
export {};
|
package/build/ft-button.js
CHANGED
|
@@ -4,19 +4,18 @@ 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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
7
|
+
import { FtLitElement, isSafari, noTextSelect, safariEllipsisFix, toFtFormComponent, unslotText, } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
9
|
+
import { FtTooltip, } from "@fluid-topics/ft-tooltip";
|
|
10
|
+
import { FtIcon, } from "@fluid-topics/ft-icon";
|
|
11
|
+
import { FtLoader } from "@fluid-topics/ft-loader";
|
|
12
|
+
import { html, } from "lit";
|
|
13
|
+
import { classMap, } from "lit/directives/class-map.js";
|
|
14
|
+
import { property, query, } from "lit/decorators.js";
|
|
15
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
16
|
+
import { FtTypography, FtTypographyVariants, } from "@fluid-topics/ft-typography";
|
|
17
|
+
import { buttonStyles } from "./ft-button.styles";
|
|
18
|
+
export class FtButton extends toFtFormComponent(FtLitElement) {
|
|
20
19
|
get buttonClasses() {
|
|
21
20
|
return {
|
|
22
21
|
"ft-button": true,
|
|
@@ -29,17 +28,148 @@ export class FtButton extends FtBaseButton {
|
|
|
29
28
|
"ft-no-text-select": true,
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
this.primary = false;
|
|
34
|
+
this.outlined = false;
|
|
35
|
+
this.dense = false;
|
|
36
|
+
this.round = false;
|
|
37
|
+
this.disabled = false;
|
|
38
|
+
this.icon = undefined;
|
|
39
|
+
this.trailingIcon = false;
|
|
40
|
+
this.label = "";
|
|
41
|
+
this.type = "button";
|
|
42
|
+
this.href = undefined;
|
|
43
|
+
this.target = undefined;
|
|
44
|
+
this.loading = false;
|
|
45
|
+
this.ariaLabel = null;
|
|
46
|
+
this.ariaHasPopup = null;
|
|
47
|
+
this.ariaPressed = null;
|
|
48
|
+
this.tooltipPosition = "bottom";
|
|
49
|
+
this.hideTooltip = false;
|
|
50
|
+
this.forceTooltip = false;
|
|
51
|
+
this.activated = false;
|
|
52
|
+
this.addEventListener("click", (e) => {
|
|
53
|
+
var _a;
|
|
54
|
+
if (this.isDisabled()) {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
e.stopImmediatePropagation();
|
|
58
|
+
}
|
|
59
|
+
else if (this.type == "submit") {
|
|
60
|
+
(_a = this.form) === null || _a === void 0 ? void 0 : _a.requestSubmit();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
render() {
|
|
65
|
+
var _a, _b, _c;
|
|
66
|
+
const content = html `
|
|
67
|
+
<ft-ripple part="ripple"
|
|
68
|
+
?disabled=${this.isDisabled()}
|
|
69
|
+
?activated=${this.activated}
|
|
70
|
+
></ft-ripple>
|
|
71
|
+
<ft-typography part="label"
|
|
72
|
+
variant="${FtTypographyVariants.button}"
|
|
73
|
+
element="span"
|
|
74
|
+
class="ft-button--label ${isSafari ? "ft-safari-ellipsis-fix" : ""}"
|
|
75
|
+
?hidden=${!this.hasTextContent()}>
|
|
76
|
+
<slot @slotchange=${this.onSlotchange}></slot>
|
|
77
|
+
</ft-typography>
|
|
78
|
+
${this.resolveIcon()}
|
|
79
|
+
`;
|
|
80
|
+
const href = this.href != null && this.href.trim().length > 0 ? this.href : undefined;
|
|
81
|
+
return this.addTooltipIfNeeded(href ? html `
|
|
82
|
+
<a href="${href}"
|
|
83
|
+
target="${(_a = this.target) !== null && _a !== void 0 ? _a : "_self"}"
|
|
84
|
+
part="button"
|
|
85
|
+
class="${classMap(this.buttonClasses)}"
|
|
86
|
+
aria-label="${(_b = this.ariaLabel) !== null && _b !== void 0 ? _b : this.getLabel()}"
|
|
87
|
+
?disabled=${this.isDisabled()}>
|
|
88
|
+
${content}
|
|
89
|
+
</a>
|
|
90
|
+
` : html `
|
|
91
|
+
<button part="button"
|
|
92
|
+
class="${classMap(this.buttonClasses)}"
|
|
93
|
+
aria-label="${(_c = this.ariaLabel) !== null && _c !== void 0 ? _c : this.getLabel()}"
|
|
94
|
+
aria-haspopup="${ifDefined(this.ariaHasPopup)}"
|
|
95
|
+
aria-pressed="${ifDefined(this.ariaPressed)}"
|
|
96
|
+
?disabled=${this.isDisabled()}>
|
|
97
|
+
${content}
|
|
98
|
+
</button>
|
|
99
|
+
`);
|
|
100
|
+
}
|
|
101
|
+
addTooltipIfNeeded(button) {
|
|
102
|
+
return this.getLabel().trim().length > 0 && (this.forceTooltip || (!this.hasTextContent() && !this.hideTooltip))
|
|
103
|
+
? html `
|
|
104
|
+
<ft-tooltip part="tooltip"
|
|
105
|
+
text="${this.getLabel()}"
|
|
106
|
+
position="${this.tooltipPosition}">
|
|
107
|
+
${button}
|
|
108
|
+
</ft-tooltip>
|
|
109
|
+
`
|
|
110
|
+
: button;
|
|
111
|
+
}
|
|
112
|
+
resolveIcon() {
|
|
113
|
+
if (this.loading) {
|
|
114
|
+
return html `
|
|
115
|
+
<ft-loader part="loader icon"></ft-loader> `;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return this.icon ? html `
|
|
119
|
+
<ft-icon part="icon" .variant=${this.iconVariant} .value=${this.icon}></ft-icon>
|
|
120
|
+
` : html `
|
|
121
|
+
<slot part="icon" name="icon"></slot>
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
focus() {
|
|
126
|
+
var _a;
|
|
127
|
+
(_a = this.button) === null || _a === void 0 ? void 0 : _a.focus();
|
|
128
|
+
}
|
|
129
|
+
showTooltip() {
|
|
130
|
+
var _a;
|
|
131
|
+
(_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.show();
|
|
132
|
+
}
|
|
133
|
+
showTemporaryTooltip(text, duration) {
|
|
134
|
+
var _a;
|
|
135
|
+
return (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.showTemporaryText(text, duration);
|
|
136
|
+
}
|
|
137
|
+
setTooltipManual(manualTooltip) {
|
|
138
|
+
if (this.tooltip) {
|
|
139
|
+
this.tooltip.manual = manualTooltip;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
click() {
|
|
143
|
+
var _a;
|
|
144
|
+
(_a = this.button) === null || _a === void 0 ? void 0 : _a.click();
|
|
145
|
+
}
|
|
146
|
+
getLabel() {
|
|
147
|
+
return this.label || this.getTextContent();
|
|
148
|
+
}
|
|
149
|
+
getTextContent() {
|
|
150
|
+
return unslotText(this.slottedContent).trim();
|
|
151
|
+
}
|
|
152
|
+
hasTextContent() {
|
|
153
|
+
return this.getTextContent().length > 0;
|
|
154
|
+
}
|
|
155
|
+
onSlotchange() {
|
|
156
|
+
this.requestUpdate();
|
|
157
|
+
}
|
|
158
|
+
isDisabled() {
|
|
159
|
+
return this.disabled || this.loading;
|
|
34
160
|
}
|
|
35
161
|
}
|
|
36
162
|
FtButton.elementDefinitions = {
|
|
37
|
-
|
|
38
|
-
"ft-
|
|
163
|
+
"ft-ripple": FtRipple,
|
|
164
|
+
"ft-tooltip": FtTooltip,
|
|
165
|
+
"ft-icon": FtIcon,
|
|
166
|
+
"ft-loader": FtLoader,
|
|
167
|
+
"ft-typography": FtTypography,
|
|
39
168
|
};
|
|
40
169
|
FtButton.styles = [
|
|
41
170
|
safariEllipsisFix,
|
|
42
|
-
|
|
171
|
+
buttonStyles,
|
|
172
|
+
noTextSelect,
|
|
43
173
|
];
|
|
44
174
|
__decorate([
|
|
45
175
|
property({ type: Boolean })
|
|
@@ -53,3 +183,60 @@ __decorate([
|
|
|
53
183
|
__decorate([
|
|
54
184
|
property({ type: Boolean })
|
|
55
185
|
], FtButton.prototype, "round", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
property({ type: Boolean })
|
|
188
|
+
], FtButton.prototype, "disabled", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
property()
|
|
191
|
+
], FtButton.prototype, "icon", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
property()
|
|
194
|
+
], FtButton.prototype, "iconVariant", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
property({ type: Boolean })
|
|
197
|
+
], FtButton.prototype, "trailingIcon", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
property()
|
|
200
|
+
], FtButton.prototype, "label", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
property()
|
|
203
|
+
], FtButton.prototype, "type", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
property()
|
|
206
|
+
], FtButton.prototype, "href", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property()
|
|
209
|
+
], FtButton.prototype, "target", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property({ type: Boolean })
|
|
212
|
+
], FtButton.prototype, "loading", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
property({ attribute: "aria-label" })
|
|
215
|
+
], FtButton.prototype, "ariaLabel", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
property()
|
|
218
|
+
], FtButton.prototype, "ariaHasPopup", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
property({ attribute: "aria-pressed" })
|
|
221
|
+
], FtButton.prototype, "ariaPressed", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
property()
|
|
224
|
+
], FtButton.prototype, "tooltipPosition", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
property({ type: Boolean })
|
|
227
|
+
], FtButton.prototype, "hideTooltip", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: Boolean })
|
|
230
|
+
], FtButton.prototype, "forceTooltip", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ type: Boolean })
|
|
233
|
+
], FtButton.prototype, "activated", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
query(".ft-button")
|
|
236
|
+
], FtButton.prototype, "button", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
query(".ft-button--label slot")
|
|
239
|
+
], FtButton.prototype, "slottedContent", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
query("[part=tooltip]")
|
|
242
|
+
], FtButton.prototype, "tooltip", void 0);
|