"use strict";const t=require("vue"),o=require("./base-iCmnU-fv.js"),b=["name","placeholder","disabled"],H=t.defineComponent({name:"ClInputTextarea",__name:"Index",props:{value:{type:String,default:""},className:{type:String,default:""},width:{type:String,default:""},height:{type:String,default:"100px"},name:{type:String,default:""},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},isClean:{type:Boolean,default:!1},isAutoHeight:{type:Boolean,default:!1},changDelayTime:{type:Number,default:200},heightMax:{type:String,default:""}},emits:["update:value","onChange","onInit","onKeydownEnter","onKeyupEnter","onFocus","onBlur","onChangeDelay"],setup(h,{expose:g,emit:v}){const n=h,s=v,c=t.ref(null),r=t.reactive({height:n.height||"100px"}),i=t.ref(n.value||""),l={lastValue:n.value||"",prevDelayValue:n.value||"",valueDelayRun:!1},C=t.computed(()=>{let e=n.name;return o.CommonBase.isEmpty(e)&&(e=`textarea_${o.CommonBase.getRandom(8)}`),e}),x=t.computed(()=>n.isClean&&!n.disabled&&!o.CommonBase.isEmpty(i.value)),E=t.computed(()=>{const e={"panel-textarea":!0,"box-width":!0,"textarea-clean":n.isClean};return n.className&&!o.CommonBase.isEmpty(n.className)&&n.className.split(" ").forEach(a=>{o.CommonBase.isEmpty(a)||(e[a]=!0)}),e}),B=t.computed(()=>{const{width:e,heightMax:a}=n,u={};return o.CommonBase.isEmpty(e)||(u.width=e),o.CommonBase.isEmpty(r.height)||(u.height=r.height),a&&!o.CommonBase.isEmpty(a)&&(u["max-height"]=a),u}),p=()=>{if(n.isAutoHeight){const e=c.value;if(e){e.style.height=n.height||"100px";const a=e.scrollHeight+e.scrollTop+(e.offsetHeight-e.clientHeight);e.style.height="100%",r.height=a>0?`${a}px`:n.height||"100px"}}},d=()=>{c.value?.focus()},y=e=>{e!==l.lastValue&&(l.lastValue=e,s("update:value",e),s("onChange",e),D(e))};let m;const D=e=>{m&&(clearTimeout(m),m=null),l.valueDelayRun=!0,m=setTimeout(()=>{l.valueDelayRun=!1,l.prevDelayValue!==e&&(l.prevDelayValue=e,s("onChangeDelay",e))},n.changDelayTime||200)},V=()=>{t.nextTick(()=>{s("onInit")})};t.watch(()=>n.value,(e,a)=>{e!==a&&(i.value=e||"",l.lastValue=e||"",p(),l.valueDelayRun||(l.prevDelayValue=e||""))}),t.onMounted(()=>{t.nextTick(()=>{V()})});const k=e=>{const a=e.target.value;p(),y(a)},T=e=>{e.key==="Enter"&&s("onKeydownEnter",e)},_=e=>{e.key==="Enter"&&s("onKeyupEnter",e)},w=()=>{i.value="",y(""),d()},I=()=>{s("onFocus")},S=()=>{s("onBlur")},f=()=>o.CommonBase.trim(i.value);return g({getValue:f,getValueData:()=>({value:f(),show:i.value}),setValue:e=>{const a=o.CommonBase.isEmpty(e)?"":e;l.lastValue=a,l.prevDelayValue=a,i.value=a,p()},initHeight:()=>{r.height=n.height||"100px"},focus:()=>{d()},getParentElement:()=>c.value?.parentElement||null}),(e,a)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(E.value),style:t.normalizeStyle(B.value)},[t.withDirectives(t.createElementVNode("textarea",{ref_key:"refElTextarea",ref:c,class:"form-control text-area","onUpdate:modelValue":a[0]||(a[0]=u=>i.value=u),name:C.value,placeholder:h.placeholder,disabled:h.disabled,onInput:k,onKeydown:T,onKeyup:_,onFocus:I,onBlur:S},null,40,b),[[t.vModelText,i.value]]),x.value?(t.openBlock(),t.createElementBlock("i",{key:0,class:"textarea-clear-icon clIconFont clIcon-close-circle-fill",onClick:t.withModifiers(w,["stop"])})):t.createCommentVNode("",!0)],6))}});exports._sfc_main=H;
//# sourceMappingURL=Index.vue_vue_type_script_setup_true_lang-Ds2Q0eNQ.js.map
