@fluid-topics/ft-text-field 1.2.49 → 1.2.50

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.
@@ -46,6 +46,7 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
46
46
  protected render(): import("lit-html").TemplateResult<1>;
47
47
  private resolveInputType;
48
48
  private renderSuggestions;
49
+ private onSuggestionClick;
49
50
  private renderPasswordIcon;
50
51
  private renderIcon;
51
52
  protected update(props: PropertyValues): void;
@@ -143,7 +143,7 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
143
143
  if (this.suggestionsProvider) {
144
144
  return html `
145
145
  ${repeat(this.providedSuggestions, suggestion => html `
146
- <ft-text-field-suggestion value=${suggestion.value} @click=${suggestion.clickHandler}>
146
+ <ft-text-field-suggestion value=${suggestion.value} @click=${(e) => this.onSuggestionClick(e, suggestion.clickHandler)}>
147
147
  ${suggestion.icon ? html `
148
148
  <ft-icon .value=${suggestion.icon}></ft-icon>
149
149
  `
@@ -158,6 +158,12 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
158
158
  `;
159
159
  }
160
160
  }
161
+ onSuggestionClick(event, handler) {
162
+ if (handler) {
163
+ event.preventDefault();
164
+ handler(event);
165
+ }
166
+ }
161
167
  renderPasswordIcon() {
162
168
  return html `
163
169
  <ft-icon class="ft-text-field--icon"
@@ -682,7 +682,7 @@ Also for action icons.`,t.colorGray200),contentGlobalSubtle:e.extend("--ft-conte
682
682
  </div>
683
683
  `}resolveInputType(){var r;return this.isPasswordField()?this.hidePassword?"password":"text":(r=this.type)!==null&&r!==void 0?r:"text"}renderSuggestions(){return this.suggestionsProvider?A.html`
684
684
  ${(0,To.repeat)(this.providedSuggestions,r=>A.html`
685
- <ft-text-field-suggestion value=${r.value} @click=${r.clickHandler}>
685
+ <ft-text-field-suggestion value=${r.value} @click=${i=>this.onSuggestionClick(i,r.clickHandler)}>
686
686
  ${r.icon?A.html`
687
687
  <ft-icon .value=${r.icon}></ft-icon>
688
688
  `:A.nothing}
@@ -690,7 +690,7 @@ Also for action icons.`,t.colorGray200),contentGlobalSubtle:e.extend("--ft-conte
690
690
  </ft-text-field-suggestion>`)}
691
691
  `:A.html`
692
692
  <slot @slotchange=${()=>this.filterSuggestionsIfNeeded()}></slot>
693
- `}renderPasswordIcon(){return A.html`
693
+ `}onSuggestionClick(r,i){i&&(r.preventDefault(),i(r))}renderPasswordIcon(){return A.html`
694
694
  <ft-icon class="ft-text-field--icon"
695
695
  .variant=${this.iconVariant}
696
696
  .value=${this.hidePassword?this.passwordHiddenIcon:this.passwordRevealedIcon}
@@ -726,7 +726,7 @@ Also for action icons.`,l.colorGray200),contentGlobalSubtle:r.extend("--ft-conte
726
726
  </div>
727
727
  `}resolveInputType(){var e;return this.isPasswordField()?this.hidePassword?"password":"text":(e=this.type)!==null&&e!==void 0?e:"text"}renderSuggestions(){return this.suggestionsProvider?Z`
728
728
  ${go(this.providedSuggestions,e=>Z`
729
- <ft-text-field-suggestion value=${e.value} @click=${e.clickHandler}>
729
+ <ft-text-field-suggestion value=${e.value} @click=${o=>this.onSuggestionClick(o,e.clickHandler)}>
730
730
  ${e.icon?Z`
731
731
  <ft-icon .value=${e.icon}></ft-icon>
732
732
  `:M}
@@ -734,7 +734,7 @@ Also for action icons.`,l.colorGray200),contentGlobalSubtle:r.extend("--ft-conte
734
734
  </ft-text-field-suggestion>`)}
735
735
  `:Z`
736
736
  <slot @slotchange=${()=>this.filterSuggestionsIfNeeded()}></slot>
737
- `}renderPasswordIcon(){return Z`
737
+ `}onSuggestionClick(e,o){o&&(e.preventDefault(),o(e))}renderPasswordIcon(){return Z`
738
738
  <ft-icon class="ft-text-field--icon"
739
739
  .variant=${this.iconVariant}
740
740
  .value=${this.hidePassword?this.passwordHiddenIcon:this.passwordRevealedIcon}
@@ -1,3 +1,4 @@
1
+ import { FtTextFieldSuggestionDefinition } from "./models";
1
2
  export interface FtTextFieldProperties {
2
3
  label?: string;
3
4
  value?: string;
@@ -15,5 +16,5 @@ export interface FtTextFieldProperties {
15
16
  suggestionsHelper?: string;
16
17
  maxLength?: number;
17
18
  password?: boolean;
18
- suggestionsProvider?: Function;
19
+ suggestionsProvider?: (query: string) => FtTextFieldSuggestionDefinition[] | Promise<FtTextFieldSuggestionDefinition[]>;
19
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-text-field",
3
- "version": "1.2.49",
3
+ "version": "1.2.50",
4
4
  "description": "A fluidtopics text field",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,12 +19,12 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-icon": "1.2.49",
23
- "@fluid-topics/ft-input-label": "1.2.49",
24
- "@fluid-topics/ft-ripple": "1.2.49",
25
- "@fluid-topics/ft-typography": "1.2.49",
26
- "@fluid-topics/ft-wc-utils": "1.2.49",
22
+ "@fluid-topics/ft-icon": "1.2.50",
23
+ "@fluid-topics/ft-input-label": "1.2.50",
24
+ "@fluid-topics/ft-ripple": "1.2.50",
25
+ "@fluid-topics/ft-typography": "1.2.50",
26
+ "@fluid-topics/ft-wc-utils": "1.2.50",
27
27
  "lit": "3.1.0"
28
28
  },
29
- "gitHead": "eac6d1d34424e5f5ca7e20068e646caeba2e15a7"
29
+ "gitHead": "2cc419b6e01ae50f6ecba171e7b700507a6a85a0"
30
30
  }