c.d2723eef.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import{_ as e,j as t,e as i,t as s,y as a,a6 as l,a7 as o,J as d,d as r,n}from"./main-ec7846c8.js";import"./c.0a3ec415.js";import"./c.0e3055bd.js";import"./c.8e28b461.js";import"./c.eea05cf6.js";let h=e([n("ha-selector-text")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[i()],key:"hass",value:void 0},{kind:"field",decorators:[i()],key:"value",value:void 0},{kind:"field",decorators:[i()],key:"label",value:void 0},{kind:"field",decorators:[i()],key:"placeholder",value:void 0},{kind:"field",decorators:[i()],key:"helper",value:void 0},{kind:"field",decorators:[i()],key:"selector",value:void 0},{kind:"field",decorators:[i({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[i({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[s()],key:"_unmaskedPassword",value:()=>!1},{kind:"method",key:"render",value:function(){var e,t,i,s,d;return null!==(e=this.selector.text)&&void 0!==e&&e.multiline?a`<ha-textarea
  2. .label=${this.label}
  3. .placeholder=${this.placeholder}
  4. .value=${this.value||""}
  5. .helper=${this.helper}
  6. helperPersistent
  7. .disabled=${this.disabled}
  8. @input=${this._handleChange}
  9. autocapitalize="none"
  10. .autocomplete=${this.selector.text.autofill}
  11. spellcheck="false"
  12. .required=${this.required}
  13. autogrow
  14. ></ha-textarea>`:a`<ha-textfield
  15. .value=${this.value||""}
  16. .placeholder=${this.placeholder||""}
  17. .helper=${this.helper}
  18. helperPersistent
  19. .disabled=${this.disabled}
  20. .type=${this._unmaskedPassword?"text":null===(t=this.selector.text)||void 0===t?void 0:t.type}
  21. @input=${this._handleChange}
  22. .label=${this.label||""}
  23. .suffix=${"password"===(null===(i=this.selector.text)||void 0===i?void 0:i.type)?a`<div style="width: 24px"></div>`:null===(s=this.selector.text)||void 0===s?void 0:s.suffix}
  24. .required=${this.required}
  25. .autocomplete=${this.selector.text.autofill}
  26. ></ha-textfield>
  27. ${"password"===(null===(d=this.selector.text)||void 0===d?void 0:d.type)?a`<ha-icon-button
  28. toggles
  29. .label=${(this._unmaskedPassword?"Hide":"Show")+" password"}
  30. @click=${this._toggleUnmaskedPassword}
  31. .path=${this._unmaskedPassword?l:o}
  32. ></ha-icon-button>`:""}`}},{kind:"method",key:"_toggleUnmaskedPassword",value:function(){this._unmaskedPassword=!this._unmaskedPassword}},{kind:"method",key:"_handleChange",value:function(e){let t=e.target.value;this.value!==t&&(""!==t||this.required||(t=void 0),d(this,"value-changed",{value:t}))}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  33. :host {
  34. display: block;
  35. position: relative;
  36. }
  37. ha-textarea,
  38. ha-textfield {
  39. width: 100%;
  40. }
  41. ha-icon-button {
  42. position: absolute;
  43. top: 10px;
  44. right: 10px;
  45. --mdc-icon-button-size: 36px;
  46. --mdc-icon-size: 20px;
  47. color: var(--secondary-text-color);
  48. inset-inline-start: initial;
  49. inset-inline-end: 10px;
  50. direction: var(--direction);
  51. }
  52. `}}]}}),t);export{h as HaTextSelector};