"use strict";var p=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var x=(e,o)=>{var r={};for(var a in e)g.call(e,a)&&o.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&p)for(var a of p(e))o.indexOf(a)<0&&h.call(e,a)&&(r[a]=e[a]);return r};const t=require("vue"),S=require("./Icon.js"),V=require("./useSplitAttributes.cjs"),q=require("./useModelWrapper.cjs"),k=require("./useFieldData.cjs"),i=require("./constants.js"),A=require("./_plugin-vue_export-helper.js");require("./useComputedDirection.cjs");require("./useComputedLanguage.cjs");require("./useComputedDisabled.cjs");const B=i.makeStringTypeValidator(i.ValidationStatusTypes),M=t.defineComponent({name:"CdxTextArea",components:{CdxIcon:S.CdxIcon},inheritAttrs:!1,props:{modelValue:{type:String,default:""},status:{type:String,default:"default",validator:B},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"],setup(e,{attrs:o,emit:r}){const a=q(t.toRef(e,"modelValue"),r),l=o.id,{computedDisabled:u,computedStatus:n,computedInputId:s}=k(t.toRef(e,"disabled"),t.toRef(e,"status"),l),m=t.inject(i.FieldDescriptionIdKey,void 0),f=t.computed(()=>({"cdx-text-area__textarea--has-value":!!a.value,"cdx-text-area__textarea--is-autosize":e.autosize})),v=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:I,rootStyle:y,otherAttrs:_}=V(o,v),b=t.computed(()=>{const c=_.value,{id:$}=c;return x(c,["id"])}),d=t.ref();function C(){d.value&&e.autosize&&(d.value.style.height="auto",d.value.style.height="".concat(d.value.scrollHeight,"px"))}return{rootClasses:I,rootStyle:y,wrappedModel:a,computedDisabled:u,computedInputId:s,descriptionId:m,textareaClasses:f,otherAttrsMinusId:b,textarea:d,onInput:C}}});const z=["id","aria-describedby","disabled"];function T(e,o,r,a,l,u){const n=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":o[0]||(o[0]=s=>e.wrappedModel=s),class:[e.textareaClasses,"cdx-text-area__textarea"],"aria-describedby":e.descriptionId,disabled:e.computedDisabled,onInput:o[1]||(o[1]=(...s)=>e.onInput&&e.onInput(...s))}),null,16,z),[[t.vModelText,e.wrappedModel]]),e.startIcon?(t.openBlock(),t.createBlock(n,{key:0,icon:e.startIcon,class:"cdx-text-area__icon-vue cdx-text-area__start-icon"},null,8,["icon"])):t.createCommentVNode("",!0),e.endIcon?(t.openBlock(),t.createBlock(n,{key:1,icon:e.endIcon,class:"cdx-text-area__icon-vue cdx-text-area__end-icon"},null,8,["icon"])):t.createCommentVNode("",!0)],6)}const D=A._export_sfc(M,[["render",T]]);module.exports=D;
