@fluid-topics/ft-button 1.2.2 → 1.2.3
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/ft-base-button.d.ts +6 -0
- package/build/ft-base-button.js +37 -12
- package/build/ft-button.light.js +97 -84
- package/build/ft-button.min.js +213 -200
- package/build/ft-button.styles.js +5 -4
- package/build/ftds-button.styles.js +5 -4
- package/package.json +8 -8
|
@@ -3,9 +3,12 @@ import { Position } from "@fluid-topics/ft-tooltip";
|
|
|
3
3
|
import { FtIconVariants } from "@fluid-topics/ft-icon";
|
|
4
4
|
import { HTMLTemplateResult } from "lit";
|
|
5
5
|
import { ClassInfo } from "lit/directives/class-map.js";
|
|
6
|
+
import { HTMLAttributeAnchorTarget } from "react";
|
|
6
7
|
export interface FtBaseButtonProperties {
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
label?: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
target?: HTMLAttributeAnchorTarget;
|
|
9
12
|
icon?: string;
|
|
10
13
|
iconVariant?: FtIconVariants;
|
|
11
14
|
trailingIcon?: boolean;
|
|
@@ -18,6 +21,8 @@ export interface FtBaseButtonProperties {
|
|
|
18
21
|
declare const FtBaseButton_base: import("@fluid-topics/ft-wc-utils").FtFormComponentType<typeof FtLitElement>;
|
|
19
22
|
export declare class FtBaseButton extends FtBaseButton_base implements FtBaseButtonProperties {
|
|
20
23
|
static elementDefinitions: ElementDefinitionsMap;
|
|
24
|
+
href?: string;
|
|
25
|
+
target?: HTMLAttributeAnchorTarget;
|
|
21
26
|
role: string;
|
|
22
27
|
type: "button" | "submit" | "reset";
|
|
23
28
|
disabled: boolean;
|
|
@@ -39,6 +44,7 @@ export declare class FtBaseButton extends FtBaseButton_base implements FtBaseBut
|
|
|
39
44
|
private addTooltipIfNeeded;
|
|
40
45
|
private resolveIcon;
|
|
41
46
|
focus(): void;
|
|
47
|
+
click(): void;
|
|
42
48
|
private getLabel;
|
|
43
49
|
get textContent(): string;
|
|
44
50
|
protected hasTextContent(): boolean;
|
package/build/ft-base-button.js
CHANGED
|
@@ -22,6 +22,8 @@ class FtBaseButton extends toFtFormComponent(FtLitElement, "button") {
|
|
|
22
22
|
}
|
|
23
23
|
constructor() {
|
|
24
24
|
super();
|
|
25
|
+
this.href = undefined;
|
|
26
|
+
this.target = undefined;
|
|
25
27
|
this.role = "button";
|
|
26
28
|
this.type = "button";
|
|
27
29
|
this.disabled = false;
|
|
@@ -46,21 +48,34 @@ class FtBaseButton extends toFtFormComponent(FtLitElement, "button") {
|
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
50
|
render() {
|
|
49
|
-
var _a;
|
|
50
|
-
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
const content = html `
|
|
53
|
+
<ft-ripple part="ripple" ?disabled=${this.isDisabled()}></ft-ripple>
|
|
54
|
+
<ft-typography part="label"
|
|
55
|
+
variant=${this.typographyVariant}
|
|
56
|
+
element="span"
|
|
57
|
+
class="ft-button--label ${isSafari ? "ft-safari-ellipsis-fix" : ""}"
|
|
58
|
+
?hidden=${!this.hasTextContent()}>
|
|
59
|
+
<slot @slotchange=${this.onSlotchange}></slot>
|
|
60
|
+
</ft-typography>
|
|
61
|
+
${this.resolveIcon()}
|
|
62
|
+
`;
|
|
63
|
+
const href = this.href != null && this.href.trim().length > 0 ? this.href : undefined;
|
|
64
|
+
return this.addTooltipIfNeeded(href ? html `
|
|
65
|
+
<a href="${href}"
|
|
66
|
+
target="${(_a = this.target) !== null && _a !== void 0 ? _a : "_self"}"
|
|
67
|
+
part="button"
|
|
68
|
+
class="${classMap(this.buttonClasses)}"
|
|
69
|
+
aria-label="${(_b = this.ariaLabel) !== null && _b !== void 0 ? _b : this.getLabel()}"
|
|
70
|
+
?disabled=${this.isDisabled()}>
|
|
71
|
+
${content}
|
|
72
|
+
</a>
|
|
73
|
+
` : html `
|
|
51
74
|
<button part="button"
|
|
52
75
|
class="${classMap(this.buttonClasses)}"
|
|
53
|
-
aria-label="${(
|
|
76
|
+
aria-label="${(_c = this.ariaLabel) !== null && _c !== void 0 ? _c : this.getLabel()}"
|
|
54
77
|
?disabled=${this.isDisabled()}>
|
|
55
|
-
|
|
56
|
-
<ft-typography part="label"
|
|
57
|
-
variant=${this.typographyVariant}
|
|
58
|
-
element="span"
|
|
59
|
-
class="ft-button--label ${isSafari ? "ft-safari-ellipsis-fix" : ""}"
|
|
60
|
-
?hidden=${!this.hasTextContent()}>
|
|
61
|
-
<slot @slotchange=${this.onSlotchange}></slot>
|
|
62
|
-
</ft-typography>
|
|
63
|
-
${this.resolveIcon()}
|
|
78
|
+
${content}
|
|
64
79
|
</button>
|
|
65
80
|
`);
|
|
66
81
|
}
|
|
@@ -92,6 +107,10 @@ class FtBaseButton extends toFtFormComponent(FtLitElement, "button") {
|
|
|
92
107
|
var _a;
|
|
93
108
|
(_a = this.button) === null || _a === void 0 ? void 0 : _a.focus();
|
|
94
109
|
}
|
|
110
|
+
click() {
|
|
111
|
+
var _a;
|
|
112
|
+
(_a = this.button) === null || _a === void 0 ? void 0 : _a.click();
|
|
113
|
+
}
|
|
95
114
|
getLabel() {
|
|
96
115
|
return this.label || this.textContent;
|
|
97
116
|
}
|
|
@@ -115,6 +134,12 @@ FtBaseButton.elementDefinitions = {
|
|
|
115
134
|
"ft-icon": FtIcon,
|
|
116
135
|
"ft-loader": FtLoader,
|
|
117
136
|
};
|
|
137
|
+
__decorate([
|
|
138
|
+
property()
|
|
139
|
+
], FtBaseButton.prototype, "href", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
property()
|
|
142
|
+
], FtBaseButton.prototype, "target", void 0);
|
|
118
143
|
__decorate([
|
|
119
144
|
property({ type: String, reflect: true })
|
|
120
145
|
], FtBaseButton.prototype, "role", void 0);
|