@fluid-topics/ft-text-field 2.2.35 → 2.2.37
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/TextFieldMessages.d.ts +7 -0
- package/build/TextFieldMessages.js +6 -0
- package/build/ft-text-field.d.ts +8 -1
- package/build/ft-text-field.js +67 -25
- package/build/ft-text-field.light.js +154 -121
- package/build/ft-text-field.min.js +184 -151
- package/build/ft-text-field.properties.d.ts +1 -0
- package/build/ft-text-field.styles.js +20 -0
- package/package.json +9 -8
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
|
|
2
|
+
export interface FtTextFieldMessages extends I18nMessages {
|
|
3
|
+
clear(): string;
|
|
4
|
+
cleared(): string;
|
|
5
|
+
}
|
|
6
|
+
export declare const textFieldContext: I18nMessageContext<FtTextFieldMessages>;
|
|
7
|
+
export declare const defaultTextFieldMessages: DefaultI18nMessages<FtTextFieldMessages>;
|
package/build/ft-text-field.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
|
3
3
|
import { FtTextFieldProperties } from "./ft-text-field.properties";
|
|
4
4
|
import { FtTextFieldSuggestion } from "./ft-text-field-suggestion";
|
|
5
5
|
import { FtTextFieldSuggestionDefinition } from "./models";
|
|
6
|
-
declare const FtTextField_base: import("@fluid-topics/ft-wc-utils").
|
|
6
|
+
declare const FtTextField_base: typeof FtLitElement & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-wc-utils").FtFormComponentInterface> & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
7
7
|
export declare class FtTextField extends FtTextField_base implements FtTextFieldProperties {
|
|
8
8
|
static elementDefinitions: ElementDefinitionsMap;
|
|
9
9
|
static styles: import("lit").CSSResult[];
|
|
@@ -27,6 +27,8 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
|
|
|
27
27
|
passwordRevealedIcon: string;
|
|
28
28
|
iconVariant?: string;
|
|
29
29
|
filterSuggestions: boolean;
|
|
30
|
+
clearable: boolean;
|
|
31
|
+
private clearedAnnouncement;
|
|
30
32
|
maxLength?: number;
|
|
31
33
|
password: boolean;
|
|
32
34
|
autocomplete?: string;
|
|
@@ -51,6 +53,9 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
|
|
|
51
53
|
protected render(): import("lit").TemplateResult<1>;
|
|
52
54
|
private resolveInputType;
|
|
53
55
|
private renderSuggestions;
|
|
56
|
+
private get canClear();
|
|
57
|
+
private renderClearButton;
|
|
58
|
+
private onClearClick;
|
|
54
59
|
private renderPasswordIcon;
|
|
55
60
|
private renderIcon;
|
|
56
61
|
protected update(props: PropertyValues): void;
|
|
@@ -61,6 +66,7 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
|
|
|
61
66
|
private watchAutofillInterval?;
|
|
62
67
|
private setupWatchAutofill;
|
|
63
68
|
private clearWatchAutofill;
|
|
69
|
+
constructor();
|
|
64
70
|
connectedCallback(): void;
|
|
65
71
|
disconnectedCallback(): void;
|
|
66
72
|
setValue(newValue: string, fireChangeEvent?: boolean): void;
|
|
@@ -71,6 +77,7 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
|
|
|
71
77
|
private onSuggestionSelected;
|
|
72
78
|
private onSuggestionRemoved;
|
|
73
79
|
private onFocus;
|
|
80
|
+
private keepFocusOnSuggestionsScrollbar;
|
|
74
81
|
private onMainPanelBlur;
|
|
75
82
|
private togglePasswordVisibility;
|
|
76
83
|
private isPasswordField;
|
package/build/ft-text-field.js
CHANGED
|
@@ -9,37 +9,17 @@ import { property, query, queryAll, queryAssignedElements, state, } from "lit/de
|
|
|
9
9
|
import { repeat } from "lit/directives/repeat.js";
|
|
10
10
|
import { classMap } from "lit/directives/class-map.js";
|
|
11
11
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
12
|
-
import { cancelable, computeOffsetAutoPosition, FtLitElement, ignoreComposingEvents, noTextInputDefaultClearButton, numberProperty, toFtFormComponent, } from "@fluid-topics/ft-wc-utils";
|
|
12
|
+
import { cancelable, computeOffsetAutoPosition, FtLitElement, ignoreComposingEvents, noTextInputDefaultClearButton, numberProperty, toFtFormComponent, screenReaderStyles, } from "@fluid-topics/ft-wc-utils";
|
|
13
13
|
import { FtTypography, FtTypographyBody1, FtTypographyVariants, } from "@fluid-topics/ft-typography";
|
|
14
14
|
import { FtInputLabel } from "@fluid-topics/ft-input-label";
|
|
15
15
|
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
16
|
-
import { FtIcon, FtIcons, } from "@fluid-topics/ft-icon";
|
|
16
|
+
import { FtIcon, FtIcons, FtIconVariants, } from "@fluid-topics/ft-icon";
|
|
17
|
+
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
18
|
+
import { defaultTextFieldMessages, textFieldContext, } from "./TextFieldMessages";
|
|
17
19
|
import { styles } from "./ft-text-field.styles";
|
|
18
20
|
import { FtTextFieldSuggestion, } from "./ft-text-field-suggestion";
|
|
19
21
|
import { FtTextFieldChangeEvent, FtTextFieldInvalidEvent, FtTextFieldLiveChangeEvent, } from "./models";
|
|
20
|
-
export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
21
|
-
constructor() {
|
|
22
|
-
super(...arguments);
|
|
23
|
-
this._value = "";
|
|
24
|
-
this.dispatchedValue = "";
|
|
25
|
-
this.outlined = false;
|
|
26
|
-
this.disabled = false;
|
|
27
|
-
this.error = false;
|
|
28
|
-
this.fixedMenuPosition = false;
|
|
29
|
-
this.prefix = null;
|
|
30
|
-
this.passwordHiddenIcon = FtIcons.EYE_SLASH;
|
|
31
|
-
this.passwordRevealedIcon = FtIcons.EYE;
|
|
32
|
-
this.filterSuggestions = false;
|
|
33
|
-
this.password = false;
|
|
34
|
-
this.hideCurrentValueSuggestion = false;
|
|
35
|
-
this.focused = false;
|
|
36
|
-
this.inputValid = true;
|
|
37
|
-
this.hidePassword = true;
|
|
38
|
-
this.hideSuggestions = true;
|
|
39
|
-
this.visibleSuggestions = [];
|
|
40
|
-
this.providedSuggestions = [];
|
|
41
|
-
this.showSuggestionsOnFocus = true;
|
|
42
|
-
}
|
|
22
|
+
export class FtTextField extends withI18n(toFtFormComponent(FtLitElement)) {
|
|
43
23
|
/*
|
|
44
24
|
* We prevent lit from creating setter and getter to differentiate
|
|
45
25
|
* when the value change comes from inside or outside the component
|
|
@@ -129,10 +109,13 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
|
129
109
|
@keydown=${this.catchComposingEvents}
|
|
130
110
|
@focus=${this.onFocus}
|
|
131
111
|
/>
|
|
112
|
+
${this.renderClearButton()}
|
|
132
113
|
${this.renderIcon()}
|
|
114
|
+
<div class="sr-only" aria-live="polite" aria-atomic="true">${this.clearedAnnouncement}</div>
|
|
133
115
|
</div>
|
|
134
116
|
<div class="ft-text-field--suggestions"
|
|
135
117
|
part="suggestions"
|
|
118
|
+
@mousedown=${this.keepFocusOnSuggestionsScrollbar}
|
|
136
119
|
@suggestion-selected=${this.onSuggestionSelected}
|
|
137
120
|
@suggestion-removed=${this.onSuggestionRemoved}
|
|
138
121
|
>
|
|
@@ -187,6 +170,28 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
|
187
170
|
`;
|
|
188
171
|
}
|
|
189
172
|
}
|
|
173
|
+
get canClear() {
|
|
174
|
+
return this.clearable && !this.disabled && !this.isPasswordField() && !!this.value;
|
|
175
|
+
}
|
|
176
|
+
renderClearButton() {
|
|
177
|
+
return this.canClear ? html `
|
|
178
|
+
<button type="button"
|
|
179
|
+
class="ft-text-field--clear-button"
|
|
180
|
+
part="clear-button"
|
|
181
|
+
aria-label="${textFieldContext.messages.clear()}"
|
|
182
|
+
@pointerdown=${(e) => e.preventDefault()}
|
|
183
|
+
@click=${this.onClearClick}>
|
|
184
|
+
<ft-icon .variant=${FtIconVariants.fluid_topics}
|
|
185
|
+
.value=${FtIcons.CLOSE}></ft-icon>
|
|
186
|
+
</button>
|
|
187
|
+
` : nothing;
|
|
188
|
+
}
|
|
189
|
+
onClearClick() {
|
|
190
|
+
var _a;
|
|
191
|
+
this.setValue("", true);
|
|
192
|
+
this.clearedAnnouncement = textFieldContext.messages.cleared();
|
|
193
|
+
(_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
|
|
194
|
+
}
|
|
190
195
|
renderPasswordIcon() {
|
|
191
196
|
return html `
|
|
192
197
|
<ft-icon class="ft-text-field--icon"
|
|
@@ -279,6 +284,31 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
|
279
284
|
clearInterval(this.watchAutofillInterval);
|
|
280
285
|
}
|
|
281
286
|
}
|
|
287
|
+
constructor() {
|
|
288
|
+
super();
|
|
289
|
+
this._value = "";
|
|
290
|
+
this.dispatchedValue = "";
|
|
291
|
+
this.outlined = false;
|
|
292
|
+
this.disabled = false;
|
|
293
|
+
this.error = false;
|
|
294
|
+
this.fixedMenuPosition = false;
|
|
295
|
+
this.prefix = null;
|
|
296
|
+
this.passwordHiddenIcon = FtIcons.EYE_SLASH;
|
|
297
|
+
this.passwordRevealedIcon = FtIcons.EYE;
|
|
298
|
+
this.filterSuggestions = false;
|
|
299
|
+
this.clearable = false;
|
|
300
|
+
this.clearedAnnouncement = "";
|
|
301
|
+
this.password = false;
|
|
302
|
+
this.hideCurrentValueSuggestion = false;
|
|
303
|
+
this.focused = false;
|
|
304
|
+
this.inputValid = true;
|
|
305
|
+
this.hidePassword = true;
|
|
306
|
+
this.hideSuggestions = true;
|
|
307
|
+
this.visibleSuggestions = [];
|
|
308
|
+
this.providedSuggestions = [];
|
|
309
|
+
this.showSuggestionsOnFocus = true;
|
|
310
|
+
this.addI18nContext(textFieldContext, defaultTextFieldMessages);
|
|
311
|
+
}
|
|
282
312
|
connectedCallback() {
|
|
283
313
|
super.connectedCallback();
|
|
284
314
|
this.setupWatchAutofill();
|
|
@@ -352,6 +382,11 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
|
352
382
|
this.hideSuggestions = false;
|
|
353
383
|
}
|
|
354
384
|
}
|
|
385
|
+
keepFocusOnSuggestionsScrollbar(event) {
|
|
386
|
+
if (event.target === event.currentTarget) {
|
|
387
|
+
event.preventDefault();
|
|
388
|
+
}
|
|
389
|
+
}
|
|
355
390
|
onMainPanelBlur() {
|
|
356
391
|
var _a, _b;
|
|
357
392
|
if (!((_a = this.mainPanel) === null || _a === void 0 ? void 0 : _a.matches(":focus-within"))) {
|
|
@@ -390,6 +425,7 @@ FtTextField.styles = [
|
|
|
390
425
|
FtTypographyBody1,
|
|
391
426
|
noTextInputDefaultClearButton,
|
|
392
427
|
styles,
|
|
428
|
+
screenReaderStyles,
|
|
393
429
|
];
|
|
394
430
|
__decorate([
|
|
395
431
|
property()
|
|
@@ -442,6 +478,12 @@ __decorate([
|
|
|
442
478
|
__decorate([
|
|
443
479
|
property({ type: Boolean })
|
|
444
480
|
], FtTextField.prototype, "filterSuggestions", void 0);
|
|
481
|
+
__decorate([
|
|
482
|
+
property({ type: Boolean })
|
|
483
|
+
], FtTextField.prototype, "clearable", void 0);
|
|
484
|
+
__decorate([
|
|
485
|
+
state()
|
|
486
|
+
], FtTextField.prototype, "clearedAnnouncement", void 0);
|
|
445
487
|
__decorate([
|
|
446
488
|
numberProperty()
|
|
447
489
|
], FtTextField.prototype, "maxLength", void 0);
|