@fluid-topics/ft-text-field 1.2.4 → 1.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.
@@ -6,6 +6,7 @@ export declare class SuggestionSelectedEvent extends CustomEvent<string> {
6
6
  export declare class FtTextFieldSuggestion extends FtLitElement implements FtTextFieldSuggestionProperties {
7
7
  static elementDefinitions: ElementDefinitionsMap;
8
8
  value?: string;
9
+ helper?: string;
9
10
  private container?;
10
11
  private assignedNodes;
11
12
  static styles: import("lit").CSSResult;
@@ -5,12 +5,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { FtLitElement } from "@fluid-topics/ft-wc-utils";
8
- import { html } from "lit";
8
+ import { html, nothing } from "lit";
9
9
  import { property, query, queryAssignedNodes } from "lit/decorators.js";
10
10
  import { FtRipple } from "@fluid-topics/ft-ripple";
11
11
  import { FtTypography } from "@fluid-topics/ft-typography";
12
12
  import { suggestionStyles } from "./ft-text-field-suggestion.styles";
13
13
  import { FtIcon } from "@fluid-topics/ft-icon";
14
+ import { classMap } from "lit/directives/class-map.js";
14
15
  export class SuggestionSelectedEvent extends CustomEvent {
15
16
  constructor(value) {
16
17
  super("suggestion-selected", { detail: value, bubbles: true, composed: true });
@@ -18,12 +19,20 @@ export class SuggestionSelectedEvent extends CustomEvent {
18
19
  }
19
20
  class FtTextFieldSuggestion extends FtLitElement {
20
21
  render() {
22
+ const classes = {
23
+ "ft-text-field-suggestion": true,
24
+ "ft-text-field-suggestion--with-helper": !!this.helper
25
+ };
21
26
  return html `
22
- <div class="ft-text-field-suggestion"
27
+ <div class=${classMap(classes)}
23
28
  tabindex="-1"
24
29
  @keydown=${this.onKeyDown}
25
30
  @click=${this.confirmSuggestion}>
26
31
  <ft-ripple></ft-ripple>
32
+ ${this.helper ? html `
33
+ <ft-typography class="ft-text-field-suggestion--helper-text" variant="caption">
34
+ ${this.helper}
35
+ </ft-typography>` : nothing}
27
36
  <ft-typography part="label"
28
37
  variant="body1"
29
38
  class="ft-text-field-suggestion--label">
@@ -66,6 +75,9 @@ FtTextFieldSuggestion.styles = suggestionStyles;
66
75
  __decorate([
67
76
  property()
68
77
  ], FtTextFieldSuggestion.prototype, "value", void 0);
78
+ __decorate([
79
+ property()
80
+ ], FtTextFieldSuggestion.prototype, "helper", void 0);
69
81
  __decorate([
70
82
  query(".ft-text-field-suggestion")
71
83
  ], FtTextFieldSuggestion.prototype, "container", void 0);
@@ -1,4 +1,5 @@
1
1
  import { css } from "lit";
2
+ import { FtTextFieldCssVariables } from "./ft-text-field.styles";
2
3
  // language=CSS
3
4
  export const suggestionStyles = css `
4
5
  .ft-text-field-suggestion {
@@ -21,7 +22,18 @@ export const suggestionStyles = css `
21
22
  flex-grow: 1;
22
23
  flex-shrink: 1;
23
24
  }
24
-
25
+
26
+ .ft-text-field-suggestion--with-helper {
27
+ display: flex;
28
+ flex-direction: column;
29
+ align-items: flex-start;
30
+ gap: 0;
31
+ }
32
+
33
+ .ft-text-field-suggestion--helper-text {
34
+ color: ${FtTextFieldCssVariables.helperColor};
35
+ }
36
+
25
37
  slot {
26
38
  pointer-events: none;
27
39
  }
@@ -1,7 +1,7 @@
1
1
  import { PropertyValues } from "lit";
2
2
  import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtTextFieldProperties } from "./ft-text-field.properties";
4
- import type { FtTextFieldSuggestion } from "./ft-text-field-suggestion";
4
+ import { FtTextFieldSuggestion } from "./ft-text-field-suggestion";
5
5
  declare const FtTextField_base: import("@fluid-topics/ft-wc-utils").FtFormComponentType<typeof FtLitElement>;
6
6
  export declare class FtTextField extends FtTextField_base implements FtTextFieldProperties {
7
7
  static elementDefinitions: ElementDefinitionsMap;
@@ -13,6 +13,7 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
13
13
  private setInternalValue;
14
14
  dispatchedValue: string;
15
15
  helper?: string;
16
+ suggestionsHelper?: string;
16
17
  outlined: boolean;
17
18
  disabled: boolean;
18
19
  error: boolean;
@@ -33,9 +34,11 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
33
34
  visibleSuggestions: FtTextFieldSuggestion[];
34
35
  mainPanel?: HTMLElement;
35
36
  input?: HTMLInputElement;
37
+ newValueSuggestion?: FtTextFieldSuggestion;
36
38
  suggestionsContainer?: HTMLElement;
37
39
  suggestions: FtTextFieldSuggestion[];
38
40
  focus(): void;
41
+ constructor();
39
42
  protected render(): import("lit").TemplateResult<1>;
40
43
  private renderPasswordIcon;
41
44
  private renderIcon;
@@ -14,26 +14,9 @@ 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
+ import { FtTextFieldSuggestion } from "./ft-text-field-suggestion";
17
18
  import { computeOffsetPosition } from "@fluid-topics/ft-wc-utils/build/floating";
18
19
  class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
19
- constructor() {
20
- super(...arguments);
21
- this._value = "";
22
- this.dispatchedValue = "";
23
- this.outlined = false;
24
- this.disabled = false;
25
- this.error = false;
26
- this.fixedMenuPosition = false;
27
- this.prefix = null;
28
- this.passwordHiddenIcon = FtIcons.EYE_SLASH;
29
- this.passwordRevealedIcon = FtIcons.EYE;
30
- this.filterSuggestions = false;
31
- this.password = false;
32
- this.focused = false;
33
- this.hidePassword = true;
34
- this.hideSuggestions = false;
35
- this.visibleSuggestions = [];
36
- }
37
20
  /*
38
21
  * We prevent lit from creating setter and getter to differentiate
39
22
  * when the value change comes from inside or outside the component
@@ -58,6 +41,24 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
58
41
  var _a;
59
42
  (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
60
43
  }
44
+ constructor() {
45
+ super();
46
+ this._value = "";
47
+ this.dispatchedValue = "";
48
+ this.outlined = false;
49
+ this.disabled = false;
50
+ this.error = false;
51
+ this.fixedMenuPosition = false;
52
+ this.prefix = null;
53
+ this.passwordHiddenIcon = FtIcons.EYE_SLASH;
54
+ this.passwordRevealedIcon = FtIcons.EYE;
55
+ this.filterSuggestions = false;
56
+ this.password = false;
57
+ this.focused = false;
58
+ this.hidePassword = true;
59
+ this.hideSuggestions = false;
60
+ this.visibleSuggestions = [];
61
+ }
61
62
  render() {
62
63
  var _a;
63
64
  const classes = {
@@ -70,7 +71,7 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
70
71
  "ft-text-field--in-error": this.error,
71
72
  "ft-text-field--fixed": this.fixedMenuPosition,
72
73
  "ft-text-field--with-prefix": !!this.prefix,
73
- "ft-text-field--hide-suggestions": this.visibleSuggestions.length === 0 || this.hideSuggestions,
74
+ "ft-text-field--hide-suggestions": this.hideSuggestions,
74
75
  "ft-text-field--raised-label": this.focused || this.value != "",
75
76
  "ft-text-field--with-icon": !!this.icon,
76
77
  "ft-text-field--with-password": this.password
@@ -110,6 +111,11 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
110
111
  <div class="ft-text-field--suggestions"
111
112
  @suggestion-selected=${this.onSuggestionSelected}>
112
113
  <slot @slotchange=${() => this.filterSuggestionsIfNeeded()}></slot>
114
+ ${this.filterSuggestions && this.value ? html `
115
+ <ft-text-field-suggestion class="ft-text-field-suggestion--new-value" helper="${this.suggestionsHelper}">
116
+ ${this.value}
117
+ </ft-text-field-suggestion>
118
+ ` : nothing}
113
119
  </div>
114
120
  </div>
115
121
  ${this.helper ? html `
@@ -159,6 +165,9 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
159
165
  else {
160
166
  this.visibleSuggestions = this.suggestions;
161
167
  }
168
+ if (this.newValueSuggestion) {
169
+ this.visibleSuggestions = [...this.visibleSuggestions, this.newValueSuggestion];
170
+ }
162
171
  }
163
172
  contentAvailableCallback(props) {
164
173
  super.contentAvailableCallback(props);
@@ -235,6 +244,7 @@ FtTextField.elementDefinitions = {
235
244
  "ft-ripple": FtRipple,
236
245
  "ft-typography": FtTypography,
237
246
  "ft-icon": FtIcon,
247
+ "ft-text-field-suggestion": FtTextFieldSuggestion
238
248
  };
239
249
  // language=CSS
240
250
  FtTextField.styles = [
@@ -254,6 +264,9 @@ __decorate([
254
264
  __decorate([
255
265
  property()
256
266
  ], FtTextField.prototype, "helper", void 0);
267
+ __decorate([
268
+ property()
269
+ ], FtTextField.prototype, "suggestionsHelper", void 0);
257
270
  __decorate([
258
271
  property({ type: Boolean })
259
272
  ], FtTextField.prototype, "outlined", void 0);
@@ -314,6 +327,9 @@ __decorate([
314
327
  __decorate([
315
328
  query(".ft-text-field--input")
316
329
  ], FtTextField.prototype, "input", void 0);
330
+ __decorate([
331
+ query(".ft-text-field-suggestion--new-value")
332
+ ], FtTextField.prototype, "newValueSuggestion", void 0);
317
333
  __decorate([
318
334
  query(".ft-text-field--suggestions")
319
335
  ], FtTextField.prototype, "suggestionsContainer", void 0);