"use strict";var x=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var v=(e,a)=>{var r={};for(var o in e)D.call(e,o)&&a.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&x)for(var o of x(e))a.indexOf(o)<0&&A.call(e,o)&&(r[o]=e[o]);return r};const t=require("vue"),q=require("./Icon.js"),M=require("./useSplitAttributes.cjs"),z=require("./useModelWrapper.cjs"),F=require("./useFieldData.cjs"),i=require("./constants.js"),T=require("./_plugin-vue_export-helper.js"),w=i.makeStringTypeValidator(i.ValidationStatusTypes),E=t.defineComponent({name:"CdxTextArea",components:{CdxIcon:q.CdxIcon},inheritAttrs:!1,props:{modelValue:{type:String,default:""},status:{type:String,default:"default",validator:w},disabled:{type:Boolean,default:!1},autosize:{type:Boolean,default:!1},startIcon:{type:[String,Object],default:void 0},endIcon:{type:[String,Object],default:void 0}},emits:["update:modelValue","input","change","focus","blur","invalid"],setup(e,{attrs:a,emit:r}){const o=t.ref(),d=z(t.toRef(e,"modelValue"),r),u=a.id,{computedDisabled:l,computedStatus:n,computedInputId:I}=F(t.toRef(e,"disabled"),t.toRef(e,"status"),u),m=t.inject(i.FieldDescriptionIdKey,void 0),y=t.computed(()=>({"cdx-text-area__textarea--has-value":!!d.value,"cdx-text-area__textarea--is-autosize":e.autosize})),h=t.computed(()=>({"cdx-text-area--status-default":n.value==="default","cdx-text-area--status-error":n.value==="error","cdx-text-area--has-start-icon":!!e.startIcon,"cdx-text-area--has-end-icon":!!e.endIcon})),{rootClasses:C,rootStyle:b,otherAttrs:g}=M(a,h),V=t.computed(()=>{const f=g.value,{id:s}=f;return v(f,["id"])});function B(s){o.value&&e.autosize&&(o.value.style.height="auto",o.value.style.height="".concat(o.value.scrollHeight,"px")),r("input",s)}const k=s=>{r("change",s)},S=s=>{r("focus",s)},$=s=>{r("blur",s)},c=t.ref(!0);return{textarea:o,rootClasses:C,rootStyle:b,wrappedModel:d,computedDisabled:l,computedInputId:I,descriptionId:m,textareaClasses:y,otherAttrsMinusId:V,onInput:B,onChange:k,onFocus:S,onBlur:$,onInvalid:(s,p)=>{p&&s.preventDefault(),r("invalid",s),c.value=!0},shouldPreventDefault:c}},methods:{focus(){this.$refs.textarea.focus()},blur(){this.$refs.textarea.blur()},checkValidity(){return this.$refs.textarea.checkValidity()},reportValidity(){return this.shouldPreventDefault=!1,this.$refs.textarea.reportValidity()},setCustomValidity(e){this.$refs.textarea.setCustomValidity(e)}}}),P=["id","aria-describedby","disabled"];function j(e,a,r,o,d,u){const l=t.resolveComponent("cdx-icon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["cdx-text-area",e.rootClasses]),style:t.normalizeStyle(e.rootStyle)},[t.withDirectives(t.createElementVNode("textarea",t.mergeProps({id:e.computedInputId,ref:"textarea"},e.otherAttrsMinusId,{"onUpdate:modelValue":a[0]||(a[0]=n=>e.wrappedModel=n),class:[e.textareaClasses,"cdx-text-area__textarea"],"aria-describedby":e.descriptionId,disabled:e.computedDisabled,onInput:a[1]||(a[1]=(...n)=>e.onInput&&e.onInput(...n)),onChange:a[2]||(a[2]=(...n)=>e.onChange&&e.onChange(...n)),onFocus:a[3]||(a[3]=(...n)=>e.onFocus&&e.onFocus(...n)),onBlur:a[4]||(a[4]=(...n)=>e.onBlur&&e.onBlur(...n)),onInvalid:a[5]||(a[5]=n=>e.onInvalid(n,e.shouldPreventDefault))}),null,16,P),[[t.vModelText,e.wrappedModel]]),e.startIcon?(t.openBlock(),t.createBlock(l,{key:0,icon:e.startIcon,class:"cdx-text-area__icon-vue cdx-text-area__start-icon"},null,8,["icon"])):t.createCommentVNode("v-if",!0),e.endIcon?(t.openBlock(),t.createBlock(l,{key:1,icon:e.endIcon,class:"cdx-text-area__icon-vue cdx-text-area__end-icon"},null,8,["icon"])):t.createCommentVNode("v-if",!0)],6)}const N=T._export_sfc(E,[["render",j]]);module.exports=N;
