@fluid-topics/ft-text-field 1.2.26 → 1.2.28
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-text-field.d.ts +7 -0
- package/build/ft-text-field.js +43 -6
- package/build/ft-text-field.light.js +63 -56
- package/build/ft-text-field.min.js +150 -143
- package/build/ft-text-field.styles.js +7 -0
- package/package.json +7 -7
package/build/ft-text-field.d.ts
CHANGED
|
@@ -41,11 +41,17 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
|
|
|
41
41
|
focus(): void;
|
|
42
42
|
constructor();
|
|
43
43
|
protected render(): import("lit").TemplateResult<1>;
|
|
44
|
+
private resolveInputType;
|
|
44
45
|
private renderPasswordIcon;
|
|
45
46
|
private renderIcon;
|
|
46
47
|
protected update(props: PropertyValues): void;
|
|
47
48
|
private filterSuggestionsIfNeeded;
|
|
48
49
|
protected contentAvailableCallback(props: PropertyValues): void;
|
|
50
|
+
private watchAutofillInterval?;
|
|
51
|
+
private setupWatchAutofill;
|
|
52
|
+
private clearWatchAutofill;
|
|
53
|
+
connectedCallback(): void;
|
|
54
|
+
disconnectedCallback(): void;
|
|
49
55
|
setValue(newValue: string, fireChangeEvent?: boolean): void;
|
|
50
56
|
private handleInput;
|
|
51
57
|
private handleClick;
|
|
@@ -54,6 +60,7 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
|
|
|
54
60
|
private onFocus;
|
|
55
61
|
private onMainPanelBlur;
|
|
56
62
|
private togglePasswordVisibility;
|
|
63
|
+
private isPasswordField;
|
|
57
64
|
private setSuggestionPosition;
|
|
58
65
|
}
|
|
59
66
|
export {};
|
package/build/ft-text-field.js
CHANGED
|
@@ -13,7 +13,7 @@ import { FtTypography, FtTypographyBody1 } from "@fluid-topics/ft-typography";
|
|
|
13
13
|
import { FtInputLabel } from "@fluid-topics/ft-input-label";
|
|
14
14
|
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
15
15
|
import { FtIcon, FtIcons } from "@fluid-topics/ft-icon";
|
|
16
|
-
import { styles } from "./ft-text-field.styles";
|
|
16
|
+
import { FtTextFieldCssVariables, styles } from "./ft-text-field.styles";
|
|
17
17
|
import { FtTextFieldSuggestion } from "./ft-text-field-suggestion";
|
|
18
18
|
class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
19
19
|
/*
|
|
@@ -59,7 +59,6 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
59
59
|
this.visibleSuggestions = [];
|
|
60
60
|
}
|
|
61
61
|
render() {
|
|
62
|
-
var _a;
|
|
63
62
|
const classes = {
|
|
64
63
|
"ft-text-field": true,
|
|
65
64
|
"ft-text-field--filled": !this.outlined,
|
|
@@ -73,7 +72,7 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
73
72
|
"ft-text-field--hide-suggestions": this.hideSuggestions || this.visibleSuggestions.length == 0,
|
|
74
73
|
"ft-text-field--raised-label": this.focused || this.value != "",
|
|
75
74
|
"ft-text-field--with-icon": !!this.icon,
|
|
76
|
-
"ft-text-field--with-password": this.
|
|
75
|
+
"ft-text-field--with-password": this.isPasswordField()
|
|
77
76
|
};
|
|
78
77
|
return html `
|
|
79
78
|
<div class="${classMap(classes)}">
|
|
@@ -94,7 +93,7 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
94
93
|
${this.prefix}
|
|
95
94
|
</ft-typography>
|
|
96
95
|
` : nothing}
|
|
97
|
-
<input type=${
|
|
96
|
+
<input type=${this.resolveInputType()}
|
|
98
97
|
name=${ifDefined(this.name)}
|
|
99
98
|
maxlength=${ifDefined(this.maxLength || undefined)}
|
|
100
99
|
aria-label="${this.label}"
|
|
@@ -126,6 +125,13 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
126
125
|
</div>
|
|
127
126
|
`;
|
|
128
127
|
}
|
|
128
|
+
resolveInputType() {
|
|
129
|
+
var _a;
|
|
130
|
+
if (this.isPasswordField()) {
|
|
131
|
+
return this.hidePassword ? "password" : "text";
|
|
132
|
+
}
|
|
133
|
+
return (_a = this.type) !== null && _a !== void 0 ? _a : "text";
|
|
134
|
+
}
|
|
129
135
|
renderPasswordIcon() {
|
|
130
136
|
return html `
|
|
131
137
|
<ft-icon class="ft-text-field--icon"
|
|
@@ -135,7 +141,7 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
135
141
|
`;
|
|
136
142
|
}
|
|
137
143
|
renderIcon() {
|
|
138
|
-
if (this.
|
|
144
|
+
if (this.isPasswordField()) {
|
|
139
145
|
return this.renderPasswordIcon();
|
|
140
146
|
}
|
|
141
147
|
return this.icon ? html `
|
|
@@ -178,6 +184,34 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
178
184
|
if (props.has("focused") && !this.hideSuggestions && this.visibleSuggestions.length > 0) {
|
|
179
185
|
this.setSuggestionPosition();
|
|
180
186
|
}
|
|
187
|
+
if (props.has("autocomplete")) {
|
|
188
|
+
this.setupWatchAutofill();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
setupWatchAutofill() {
|
|
192
|
+
var _a;
|
|
193
|
+
this.clearWatchAutofill();
|
|
194
|
+
if (((_a = this.autocomplete) !== null && _a !== void 0 ? _a : "off") !== "off") {
|
|
195
|
+
this.watchAutofillInterval = setInterval(() => {
|
|
196
|
+
var _a, _b, _c;
|
|
197
|
+
if (((_a = this.input) === null || _a === void 0 ? void 0 : _a.matches(":autofill")) && this.dispatchedValue !== ((_b = this.input) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
198
|
+
this.setValue((_c = this.input) === null || _c === void 0 ? void 0 : _c.value, true);
|
|
199
|
+
}
|
|
200
|
+
}, 200);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
clearWatchAutofill() {
|
|
204
|
+
if (this.watchAutofillInterval) {
|
|
205
|
+
clearInterval(this.watchAutofillInterval);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
connectedCallback() {
|
|
209
|
+
super.connectedCallback();
|
|
210
|
+
this.setupWatchAutofill();
|
|
211
|
+
}
|
|
212
|
+
disconnectedCallback() {
|
|
213
|
+
super.disconnectedCallback();
|
|
214
|
+
this.clearWatchAutofill();
|
|
181
215
|
}
|
|
182
216
|
setValue(newValue, fireChangeEvent = false) {
|
|
183
217
|
if (this.value !== newValue) {
|
|
@@ -237,10 +271,13 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
237
271
|
togglePasswordVisibility() {
|
|
238
272
|
this.hidePassword = !this.hidePassword;
|
|
239
273
|
}
|
|
274
|
+
isPasswordField() {
|
|
275
|
+
return this.password || this.type === "password";
|
|
276
|
+
}
|
|
240
277
|
setSuggestionPosition() {
|
|
241
278
|
this.suggestionsContainer.style.width = this.mainPanel.getBoundingClientRect().width + "px";
|
|
242
279
|
const fallbackPlacements = ["bottom", "top"];
|
|
243
|
-
computeFlipOffsetPosition(this.mainPanel, this.suggestionsContainer, "bottom", fallbackPlacements, "fixed", 0)
|
|
280
|
+
computeFlipOffsetPosition(this.mainPanel, this.suggestionsContainer, "bottom", fallbackPlacements, "fixed", FtTextFieldCssVariables.suggestSize.name, 0)
|
|
244
281
|
.then(({ x, y }) => {
|
|
245
282
|
this.suggestionsContainer.style.left = `${x}px`;
|
|
246
283
|
this.suggestionsContainer.style.top = `${y}px`;
|