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

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.
@@ -43,9 +43,11 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
43
43
  providedSuggestionsInDom: FtTextFieldSuggestion[];
44
44
  slottedSuggestions: FtTextFieldSuggestion[];
45
45
  focus(): void;
46
+ blur(): void;
46
47
  protected render(): import("lit-html").TemplateResult<1>;
47
48
  private resolveInputType;
48
49
  private renderSuggestions;
50
+ private onSuggestionClick;
49
51
  private renderPasswordIcon;
50
52
  private renderIcon;
51
53
  protected update(props: PropertyValues): void;
@@ -60,6 +60,10 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
60
60
  var _a;
61
61
  (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
62
62
  }
63
+ blur() {
64
+ var _a;
65
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.blur();
66
+ }
63
67
  render() {
64
68
  const classes = {
65
69
  "ft-text-field": true,
@@ -143,7 +147,7 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
143
147
  if (this.suggestionsProvider) {
144
148
  return html `
145
149
  ${repeat(this.providedSuggestions, suggestion => html `
146
- <ft-text-field-suggestion value=${suggestion.value} @click=${suggestion.clickHandler}>
150
+ <ft-text-field-suggestion value=${suggestion.value} @click=${(e) => this.onSuggestionClick(e, suggestion.clickHandler)}>
147
151
  ${suggestion.icon ? html `
148
152
  <ft-icon .value=${suggestion.icon}></ft-icon>
149
153
  `
@@ -158,6 +162,12 @@ class FtTextField extends toFtFormComponent(FtLitElement, "textbox") {
158
162
  `;
159
163
  }
160
164
  }
165
+ onSuggestionClick(event, handler) {
166
+ if (handler) {
167
+ event.preventDefault();
168
+ handler(event);
169
+ }
170
+ }
161
171
  renderPasswordIcon() {
162
172
  return html `
163
173
  <ft-icon class="ft-text-field--icon"
@@ -631,7 +631,7 @@ Also for action icons.`,t.colorGray200),contentGlobalSubtle:e.extend("--ft-conte
631
631
  <slot></slot>
632
632
  </ft-typography>
633
633
  </div>
634
- `}focus(r){var i;(i=this.container)===null||i===void 0||i.focus(r)}click(){var r;(r=this.container)===null||r===void 0||r.click()}confirmSuggestion(){this.dispatchEvent(new Qe(this.getValue()))}getValue(){return this.value||this.textContent}get textContent(){return this.assignedNodes.map(r=>r.textContent).join("").trim()}onKeyDown(r){["Enter"," "].includes(r.key)&&(r.preventDefault(),r.stopPropagation(),this.confirmSuggestion())}};_.elementDefinitions={"ft-ripple":E,"ft-typography":T,"ft-icon":B};_.styles=$o;_e([(0,ae.property)()],_.prototype,"value",void 0);_e([(0,ae.property)()],_.prototype,"helper",void 0);_e([(0,ae.query)(".ft-text-field-suggestion")],_.prototype,"container",void 0);_e([(0,ae.queryAssignedNodes)()],_.prototype,"assignedNodes",void 0);var C=function(o,r,i,n){var l=arguments.length,c=l<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,i):n,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(o,r,i,n);else for(var f=o.length-1;f>=0;f--)(d=o[f])&&(c=(l<3?d(c):l>3?d(r,i,c):d(r,i))||c);return l>3&&c&&Object.defineProperty(r,i,c),c},m=class extends(0,Q.toFtFormComponent)(Q.FtLitElement,"textbox"){constructor(){super(...arguments),this._value="",this.dispatchedValue="",this.outlined=!1,this.disabled=!1,this.error=!1,this.fixedMenuPosition=!1,this.prefix=null,this.passwordHiddenIcon=re.EYE_SLASH,this.passwordRevealedIcon=re.EYE,this.filterSuggestions=!1,this.password=!1,this.focused=!1,this.hidePassword=!0,this.hideSuggestions=!1,this.visibleSuggestions=[],this.providedSuggestions=[]}get value(){return this._value||""}set value(r){this.setInternalValue(r||""),this.dispatchedValue=r||""}setInternalValue(r){let i=this._value;this._value=r||"",this.setFormValue(this._value),this.requestUpdate("value",i)}focus(){var r;(r=this.input)===null||r===void 0||r.focus()}render(){let r={"ft-text-field":!0,"ft-text-field--filled":!this.outlined,"ft-text-field--outlined":this.outlined,"ft-text-field--disabled":this.disabled,"ft-text-field--has-value":!!this.value,"ft-text-field--with-label":!!this.label,"ft-text-field--in-error":this.error,"ft-text-field--fixed":this.fixedMenuPosition,"ft-text-field--with-prefix":!!this.prefix,"ft-text-field--hide-suggestions":!this.suggestionsShouldBeDisplayed(),"ft-text-field--raised-label":this.focused||this.value!="","ft-text-field--with-icon":!!this.icon,"ft-text-field--with-password":this.isPasswordField()},i=this.suggestionsProvider&&this.value&&this.value!=""&&!this.providedSuggestions.map(c=>c.label).includes(this.value),l=!this.suggestionsProvider&&this.filterSuggestions&&this.value&&this.value!=""||i;return A.html`
634
+ `}focus(r){var i;(i=this.container)===null||i===void 0||i.focus(r)}click(){var r;(r=this.container)===null||r===void 0||r.click()}confirmSuggestion(){this.dispatchEvent(new Qe(this.getValue()))}getValue(){return this.value||this.textContent}get textContent(){return this.assignedNodes.map(r=>r.textContent).join("").trim()}onKeyDown(r){["Enter"," "].includes(r.key)&&(r.preventDefault(),r.stopPropagation(),this.confirmSuggestion())}};_.elementDefinitions={"ft-ripple":E,"ft-typography":T,"ft-icon":B};_.styles=$o;_e([(0,ae.property)()],_.prototype,"value",void 0);_e([(0,ae.property)()],_.prototype,"helper",void 0);_e([(0,ae.query)(".ft-text-field-suggestion")],_.prototype,"container",void 0);_e([(0,ae.queryAssignedNodes)()],_.prototype,"assignedNodes",void 0);var C=function(o,r,i,n){var l=arguments.length,c=l<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,i):n,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(o,r,i,n);else for(var f=o.length-1;f>=0;f--)(d=o[f])&&(c=(l<3?d(c):l>3?d(r,i,c):d(r,i))||c);return l>3&&c&&Object.defineProperty(r,i,c),c},m=class extends(0,Q.toFtFormComponent)(Q.FtLitElement,"textbox"){constructor(){super(...arguments),this._value="",this.dispatchedValue="",this.outlined=!1,this.disabled=!1,this.error=!1,this.fixedMenuPosition=!1,this.prefix=null,this.passwordHiddenIcon=re.EYE_SLASH,this.passwordRevealedIcon=re.EYE,this.filterSuggestions=!1,this.password=!1,this.focused=!1,this.hidePassword=!0,this.hideSuggestions=!1,this.visibleSuggestions=[],this.providedSuggestions=[]}get value(){return this._value||""}set value(r){this.setInternalValue(r||""),this.dispatchedValue=r||""}setInternalValue(r){let i=this._value;this._value=r||"",this.setFormValue(this._value),this.requestUpdate("value",i)}focus(){var r;(r=this.input)===null||r===void 0||r.focus()}blur(){var r;(r=this.input)===null||r===void 0||r.blur()}render(){let r={"ft-text-field":!0,"ft-text-field--filled":!this.outlined,"ft-text-field--outlined":this.outlined,"ft-text-field--disabled":this.disabled,"ft-text-field--has-value":!!this.value,"ft-text-field--with-label":!!this.label,"ft-text-field--in-error":this.error,"ft-text-field--fixed":this.fixedMenuPosition,"ft-text-field--with-prefix":!!this.prefix,"ft-text-field--hide-suggestions":!this.suggestionsShouldBeDisplayed(),"ft-text-field--raised-label":this.focused||this.value!="","ft-text-field--with-icon":!!this.icon,"ft-text-field--with-password":this.isPasswordField()},i=this.suggestionsProvider&&this.value&&this.value!=""&&!this.providedSuggestions.map(c=>c.label).includes(this.value),l=!this.suggestionsProvider&&this.filterSuggestions&&this.value&&this.value!=""||i;return A.html`
635
635
  <div class="${(0,Uo.classMap)(r)}">
636
636
  <div class="ft-text-field--main-panel"
637
637
  @keydown=${this.handleKeyboardNavigation}
@@ -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}