1 "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"),d=require("./constants.js"),T=require("./_plugin-vue_export-helper.js"),w=d.makeStringTypeValidator(d.ValidationStatusTypes),E=t.defineComponent({name:"CdxTextArea",components:{CdxIcon:q.CdxIcon},inheritAttrs:!1,expose:["focus","blur","checkValidity","reportValidity","setCustomValidity"],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(),l=z(t.toRef(e,"modelValue"),r),u=a.id,{computedDisabled:i,computedStatus:n,computedInputId:y}=F(t.toRef(e,"disabled"),t.toRef(e,"status"),u),m=t.inject(d.FieldDescriptionIdKey,void 0),I=t.computed(()=>({"cdx-text-area__textarea--has-value":!!l.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:V,otherAttrs:b}=M(a,h),g=t.computed(()=>{const f=b.value,{id:s}=f;return v(f,["id"])});function k(s){o.value&&e.autosize&&(o.value.style.height="auto",o.value.style.height="".concat(o.value.scrollHeight,"px")),r("input",s)}const B=s=>{r("change",s)},S=s=>{r("focus",s)},$=s=>{r("blur",s)},c=t.ref(!0);return{textarea:o,rootClasses:C,rootStyle:V,wrappedModel:l,computedDisabled:i,computedInputId:y,descriptionId:m,textareaClasses:I,otherAttrsMinusId:g,onInput:k,onChange:B,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,l,u){const i=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(i,{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(i,{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;