@fluid-topics/ft-text-field 2.2.4 → 2.2.6
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 +2 -0
- package/build/ft-text-field.js +25 -7
- package/build/ft-text-field.light.js +117 -103
- package/build/ft-text-field.min.js +183 -169
- package/package.json +7 -7
package/build/ft-text-field.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
|
|
|
31
31
|
password: boolean;
|
|
32
32
|
autocomplete?: string;
|
|
33
33
|
suggestionsProvider?: (query: string) => FtTextFieldSuggestionDefinition[] | Promise<FtTextFieldSuggestionDefinition[]>;
|
|
34
|
+
hideCurrentValueSuggestion: boolean;
|
|
34
35
|
focused: boolean;
|
|
35
36
|
inputValid: boolean;
|
|
36
37
|
hidePassword: boolean;
|
|
@@ -52,6 +53,7 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
|
|
|
52
53
|
private renderPasswordIcon;
|
|
53
54
|
private renderIcon;
|
|
54
55
|
protected update(props: PropertyValues): void;
|
|
56
|
+
private cancelableSuggest?;
|
|
55
57
|
private updateSuggestions;
|
|
56
58
|
private filterSuggestionsIfNeeded;
|
|
57
59
|
protected contentAvailableCallback(props: PropertyValues): void;
|
package/build/ft-text-field.js
CHANGED
|
@@ -9,7 +9,7 @@ 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 { computeOffsetAutoPosition, FtLitElement, ignoreComposingEvents, noTextInputDefaultClearButton, numberProperty, toFtFormComponent, } from "@fluid-topics/ft-wc-utils";
|
|
12
|
+
import { cancelable, computeOffsetAutoPosition, FtLitElement, ignoreComposingEvents, noTextInputDefaultClearButton, numberProperty, toFtFormComponent, } 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";
|
|
@@ -31,6 +31,7 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
|
31
31
|
this.passwordRevealedIcon = FtIcons.EYE;
|
|
32
32
|
this.filterSuggestions = false;
|
|
33
33
|
this.password = false;
|
|
34
|
+
this.hideCurrentValueSuggestion = false;
|
|
34
35
|
this.focused = false;
|
|
35
36
|
this.inputValid = true;
|
|
36
37
|
this.hidePassword = true;
|
|
@@ -118,18 +119,22 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
|
118
119
|
?disabled=${this.disabled}
|
|
119
120
|
.value=${this.value}
|
|
120
121
|
@click=${this.handleClick}
|
|
121
|
-
@
|
|
122
|
-
@
|
|
122
|
+
@keyup=${this.handleInput}
|
|
123
|
+
@keydown=${this.catchComposingEvents}
|
|
123
124
|
@focus=${this.onFocus}
|
|
124
125
|
/>
|
|
125
126
|
${this.renderIcon()}
|
|
126
127
|
</div>
|
|
127
128
|
<div class="ft-text-field--suggestions"
|
|
129
|
+
part="suggestions"
|
|
128
130
|
@suggestion-selected=${this.onSuggestionSelected}>
|
|
129
131
|
${this.renderSuggestions()}
|
|
130
|
-
${shouldDisplayQueryAsNewSuggestion
|
|
132
|
+
${!this.hideCurrentValueSuggestion && shouldDisplayQueryAsNewSuggestion
|
|
131
133
|
? html `
|
|
132
|
-
<ft-text-field-suggestion
|
|
134
|
+
<ft-text-field-suggestion
|
|
135
|
+
class="ft-text-field-suggestion--new-value"
|
|
136
|
+
part="suggestion current-value-suggestion"
|
|
137
|
+
helper="${this.suggestionsHelper}">
|
|
133
138
|
${this.value}
|
|
134
139
|
</ft-text-field-suggestion>
|
|
135
140
|
`
|
|
@@ -155,7 +160,7 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
|
155
160
|
if (this.suggestionsProvider) {
|
|
156
161
|
return html `
|
|
157
162
|
${repeat(this.providedSuggestions, (suggestion) => html `
|
|
158
|
-
<ft-text-field-suggestion value="${suggestion.value}" @click=${(e) => this.onSuggestionClick(e, suggestion.clickHandler)}>
|
|
163
|
+
<ft-text-field-suggestion part="suggestion" value="${suggestion.value}" @click=${(e) => this.onSuggestionClick(e, suggestion.clickHandler)}>
|
|
159
164
|
${suggestion.icon ? html `
|
|
160
165
|
<ft-icon .value=${suggestion.icon}></ft-icon>
|
|
161
166
|
`
|
|
@@ -211,8 +216,18 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
|
|
|
211
216
|
}
|
|
212
217
|
}
|
|
213
218
|
async updateSuggestions() {
|
|
219
|
+
var _a;
|
|
214
220
|
if (this.suggestionsProvider) {
|
|
215
|
-
this.
|
|
221
|
+
(_a = this.cancelableSuggest) === null || _a === void 0 ? void 0 : _a.cancel();
|
|
222
|
+
const result = this.suggestionsProvider(this.value);
|
|
223
|
+
if (result instanceof Promise) {
|
|
224
|
+
this.cancelableSuggest = cancelable(result);
|
|
225
|
+
this.providedSuggestions = await this.cancelableSuggest;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
this.cancelableSuggest = undefined;
|
|
229
|
+
this.providedSuggestions = result;
|
|
230
|
+
}
|
|
216
231
|
}
|
|
217
232
|
else {
|
|
218
233
|
this.filterSuggestionsIfNeeded();
|
|
@@ -432,6 +447,9 @@ __decorate([
|
|
|
432
447
|
__decorate([
|
|
433
448
|
property({ attribute: false })
|
|
434
449
|
], FtTextField.prototype, "suggestionsProvider", void 0);
|
|
450
|
+
__decorate([
|
|
451
|
+
property({ type: Boolean })
|
|
452
|
+
], FtTextField.prototype, "hideCurrentValueSuggestion", void 0);
|
|
435
453
|
__decorate([
|
|
436
454
|
state()
|
|
437
455
|
], FtTextField.prototype, "focused", void 0);
|