@fluid-topics/ft-text-field 1.2.24 → 1.2.25
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 +1 -0
- package/build/ft-text-field.js +17 -10
- package/build/ft-text-field.light.js +205 -205
- package/build/ft-text-field.min.js +4 -4
- package/package.json +7 -7
package/build/ft-text-field.d.ts
CHANGED
package/build/ft-text-field.js
CHANGED
|
@@ -8,14 +8,13 @@ import { html, nothing } from "lit";
|
|
|
8
8
|
import { property, query, queryAssignedElements, state } from "lit/decorators.js";
|
|
9
9
|
import { classMap } from "lit/directives/class-map.js";
|
|
10
10
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
11
|
-
import { FtLitElement, noTextInputDefaultClearButton, toFtFormComponent } from "@fluid-topics/ft-wc-utils";
|
|
11
|
+
import { computeFlipOffsetPosition, FtLitElement, noTextInputDefaultClearButton, toFtFormComponent } from "@fluid-topics/ft-wc-utils";
|
|
12
12
|
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
16
|
import { styles } from "./ft-text-field.styles";
|
|
17
17
|
import { FtTextFieldSuggestion } from "./ft-text-field-suggestion";
|
|
18
|
-
import { computeOffsetPosition } from "@fluid-topics/ft-wc-utils/build/floating";
|
|
19
18
|
class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
20
19
|
/*
|
|
21
20
|
* We prevent lit from creating setter and getter to differentiate
|
|
@@ -71,7 +70,7 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
71
70
|
"ft-text-field--in-error": this.error,
|
|
72
71
|
"ft-text-field--fixed": this.fixedMenuPosition,
|
|
73
72
|
"ft-text-field--with-prefix": !!this.prefix,
|
|
74
|
-
"ft-text-field--hide-suggestions": this.hideSuggestions,
|
|
73
|
+
"ft-text-field--hide-suggestions": this.hideSuggestions || this.visibleSuggestions.length == 0,
|
|
75
74
|
"ft-text-field--raised-label": this.focused || this.value != "",
|
|
76
75
|
"ft-text-field--with-icon": !!this.icon,
|
|
77
76
|
"ft-text-field--with-password": this.password
|
|
@@ -112,7 +111,7 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
112
111
|
<div class="ft-text-field--suggestions"
|
|
113
112
|
@suggestion-selected=${this.onSuggestionSelected}>
|
|
114
113
|
<slot @slotchange=${() => this.filterSuggestionsIfNeeded()}></slot>
|
|
115
|
-
${this.filterSuggestions && this.value ? html `
|
|
114
|
+
${this.filterSuggestions && (this.value && this.value != "") ? html `
|
|
116
115
|
<ft-text-field-suggestion class="ft-text-field-suggestion--new-value" helper="${this.suggestionsHelper}">
|
|
117
116
|
${this.value}
|
|
118
117
|
</ft-text-field-suggestion>
|
|
@@ -157,6 +156,9 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
157
156
|
if (props.has("dispatchedValue") && props.get("dispatchedValue") != null) {
|
|
158
157
|
this.hideSuggestions = true;
|
|
159
158
|
}
|
|
159
|
+
if (props.has("visibleSuggestions") && this.visibleSuggestions.length) {
|
|
160
|
+
this.setSuggestionPosition();
|
|
161
|
+
}
|
|
160
162
|
}
|
|
161
163
|
filterSuggestionsIfNeeded() {
|
|
162
164
|
if (this.filterSuggestions) {
|
|
@@ -169,16 +171,12 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
169
171
|
if (this.newValueSuggestion) {
|
|
170
172
|
this.visibleSuggestions = [...this.visibleSuggestions, this.newValueSuggestion];
|
|
171
173
|
}
|
|
174
|
+
this.hideSuggestions = this.visibleSuggestions.length <= 0;
|
|
172
175
|
}
|
|
173
176
|
contentAvailableCallback(props) {
|
|
174
177
|
super.contentAvailableCallback(props);
|
|
175
178
|
if (props.has("focused") && !this.hideSuggestions && this.visibleSuggestions.length > 0) {
|
|
176
|
-
this.
|
|
177
|
-
computeOffsetPosition(this.mainPanel, this.suggestionsContainer, "bottom")
|
|
178
|
-
.then(({ x, y }) => {
|
|
179
|
-
this.suggestionsContainer.style.left = `${x}px`;
|
|
180
|
-
this.suggestionsContainer.style.top = `${y}px`;
|
|
181
|
-
});
|
|
179
|
+
this.setSuggestionPosition();
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
setValue(newValue, fireChangeEvent = false) {
|
|
@@ -239,6 +237,15 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
|
|
|
239
237
|
togglePasswordVisibility() {
|
|
240
238
|
this.hidePassword = !this.hidePassword;
|
|
241
239
|
}
|
|
240
|
+
setSuggestionPosition() {
|
|
241
|
+
this.suggestionsContainer.style.width = this.mainPanel.getBoundingClientRect().width + "px";
|
|
242
|
+
const fallbackPlacements = ["bottom", "top"];
|
|
243
|
+
computeFlipOffsetPosition(this.mainPanel, this.suggestionsContainer, "bottom", fallbackPlacements, "fixed", 0)
|
|
244
|
+
.then(({ x, y }) => {
|
|
245
|
+
this.suggestionsContainer.style.left = `${x}px`;
|
|
246
|
+
this.suggestionsContainer.style.top = `${y}px`;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
242
249
|
}
|
|
243
250
|
FtTextField.elementDefinitions = {
|
|
244
251
|
"ft-input-label": FtInputLabel,
|