c.0a3ec415.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import{f as t,i as e,e as i,y as a,k as s,p as l,d as o,_ as r,E as d,G as n,n as h}from"./main-ec7846c8.js";import{T as p,l as u,b as c}from"./c.0e3055bd.js";const m={fromAttribute:t=>null!==t&&(""===t||t),toAttribute:t=>"boolean"==typeof t?t?"":null:t};class x extends p{constructor(){super(...arguments),this.rows=2,this.cols=20,this.charCounter=!1}render(){const t=this.charCounter&&-1!==this.maxLength,e=t&&"internal"===this.charCounter,i=t&&!e,l=!!this.helper||!!this.validationMessage||i,o={"mdc-text-field--disabled":this.disabled,"mdc-text-field--no-label":!this.label,"mdc-text-field--filled":!this.outlined,"mdc-text-field--outlined":this.outlined,"mdc-text-field--end-aligned":this.endAligned,"mdc-text-field--with-internal-counter":e};return a`
  2. <label class="mdc-text-field mdc-text-field--textarea ${s(o)}">
  3. ${this.renderRipple()}
  4. ${this.outlined?this.renderOutline():this.renderLabel()}
  5. ${this.renderInput()}
  6. ${this.renderCharCounter(e)}
  7. ${this.renderLineRipple()}
  8. </label>
  9. ${this.renderHelperText(l,i)}
  10. `}renderInput(){const t=this.label?"label":void 0,e=-1===this.minLength?void 0:this.minLength,i=-1===this.maxLength?void 0:this.maxLength,s=this.autocapitalize?this.autocapitalize:void 0;return a`
  11. <textarea
  12. aria-labelledby=${l(t)}
  13. class="mdc-text-field__input"
  14. .value="${u(this.value)}"
  15. rows="${this.rows}"
  16. cols="${this.cols}"
  17. ?disabled="${this.disabled}"
  18. placeholder="${this.placeholder}"
  19. ?required="${this.required}"
  20. ?readonly="${this.readOnly}"
  21. minlength="${l(e)}"
  22. maxlength="${l(i)}"
  23. name="${l(""===this.name?void 0:this.name)}"
  24. inputmode="${l(this.inputMode)}"
  25. autocapitalize="${l(s)}"
  26. @input="${this.handleInputChange}"
  27. @blur="${this.onInputBlur}">
  28. </textarea>`}}t([e("textarea")],x.prototype,"formElement",void 0),t([i({type:Number})],x.prototype,"rows",void 0),t([i({type:Number})],x.prototype,"cols",void 0),t([i({converter:m})],x.prototype,"charCounter",void 0);const g=o`.mdc-text-field{height:100%}.mdc-text-field__input{resize:none}`;r([h("ha-textarea")],(function(t,e){class a extends e{constructor(...e){super(...e),t(this)}}return{F:a,d:[{kind:"field",decorators:[i({type:Boolean,reflect:!0})],key:"autogrow",value:()=>!1},{kind:"method",key:"updated",value:function(t){d(n(a.prototype),"updated",this).call(this,t),this.autogrow&&t.has("value")&&(this.mdcRoot.dataset.value=this.value+'=​"')}},{kind:"field",static:!0,key:"styles",value:()=>[c,g,o`
  29. :host([autogrow]) .mdc-text-field {
  30. position: relative;
  31. min-height: 74px;
  32. min-width: 178px;
  33. max-height: 200px;
  34. }
  35. :host([autogrow]) .mdc-text-field:after {
  36. content: attr(data-value);
  37. margin-top: 23px;
  38. margin-bottom: 9px;
  39. line-height: 1.5rem;
  40. min-height: 42px;
  41. padding: 0px 32px 0 16px;
  42. letter-spacing: var(
  43. --mdc-typography-subtitle1-letter-spacing,
  44. 0.009375em
  45. );
  46. visibility: hidden;
  47. white-space: pre-wrap;
  48. }
  49. :host([autogrow]) .mdc-text-field__input {
  50. position: absolute;
  51. height: calc(100% - 32px);
  52. }
  53. :host([autogrow]) .mdc-text-field.mdc-text-field--no-label:after {
  54. margin-top: 16px;
  55. margin-bottom: 16px;
  56. }
  57. `]}]}}),x);