import{r as t,c as e,h as i,g as s}from"./p-78e3ebb9.js";const h="taro-textarea-core{display:block;width:300px}taro-textarea-core .auto-height{height:auto}.taro-textarea{display:block;position:relative;border:0;width:100%;height:inherit;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:auto;line-height:1.5}.taro-textarea:focus{outline:none}";function a(t){return t!==null&&t!==void 0?t:""}const n=class{constructor(i){t(this,i);this.onInput=e(this,"input",7);this.onFocus=e(this,"focus",7);this.onBlur=e(this,"blur",7);this.onChange=e(this,"change",7);this.onLineChange=e(this,"linechange",7);this.handleInput=t=>{t.stopPropagation();this.handleLineChange();const e=t.target.value||"";this.onInput.emit({value:e,cursor:e.length})};this.handleFocus=t=>{t.stopPropagation();this.onFocus.emit({value:t.target.value})};this.handleBlur=t=>{t.stopPropagation();this.onBlur.emit({value:t.target.value})};this.handleChange=t=>{t.stopPropagation();this.onChange.emit({value:t.target.value})};this.handleLineChange=()=>{const t=this.getNumberOfLines();if(t!==this.line){this.line=t;this.onLineChange.emit({height:this.textareaRef.clientHeight,lineCount:this.line})}};this.calculateContentHeight=(t,e)=>{let i=t.style.height,s=t.offsetHeight,h=t.scrollHeight,a=t.style.overflow,n=t.style.minHeight||null;if(s>=h){t.style.minHeight=0;t.style.height=s+e+"px";t.style.overflow="hidden";if(h<t.scrollHeight){while(t.offsetHeight>=t.scrollHeight){t.style.height=(s-=e)+"px"}while(t.offsetHeight<t.scrollHeight){t.style.height=s+++"px"}t.style.height=i;t.style.overflow=a;t.style.minHeight=n;return s}}else{return h}};this.getNumberOfLines=()=>{const t=this.textareaRef,e=window.getComputedStyle?window.getComputedStyle(t):t.style,i=parseInt(e.lineHeight,10),s=this.calculateContentHeight(t,i),h=Math.floor(s/i);return h};this.value=undefined;this.placeholder=undefined;this.disabled=false;this.maxlength=140;this.autoFocus=false;this.autoHeight=false;this.name=undefined;this.nativeProps={};this.line=1}focus(){this.textareaRef.focus()}componentDidLoad(){Object.defineProperty(this.el,"value",{get:()=>this.textareaRef.value,set:t=>this.value=t,configurable:true});this.autoFocus&&this.textareaRef.focus()}render(){const{value:t,placeholder:e,disabled:s,maxlength:h,autoFocus:n,autoHeight:o,name:r,nativeProps:l,handleInput:u,handleFocus:c,handleBlur:d,handleChange:p}=this;const f={};if(o){f.rows=this.line}return i("textarea",Object.assign({ref:t=>{if(t){this.textareaRef=t}},class:`taro-textarea ${o?"auto-height":""}`,value:a(t),placeholder:e,name:r,disabled:s,maxlength:h,autofocus:n,onInput:u,onFocus:c,onBlur:d,onChange:p},l,f))}get el(){return s(this)}};n.style=h;export{n as taro_textarea_core};
//# sourceMappingURL=p-ef4c1fd4.entry.js.map