import{g as z,E as l,r as h,G as C,j as f,H as j,s as c,D as k,U as I,O,o as S,c as x,a as T,L as V,y as $}from"./entry.eb978f24.js";import{u as q}from"./useFormEvents.4d081bc0.js";import{_ as H}from"./_plugin-vue_export-helper.c27b6911.js";const N=z({inheritAttrs:!1,props:{modelValue:{type:[String,Number],default:""},name:{type:String,default:null},placeholder:{type:String,default:null},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},rows:{type:Number,default:3},autoresize:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},resize:{type:Boolean,default:!1},padded:{type:Boolean,default:!0},size:{type:String,default:()=>l.ui.textarea.default.size,validator(e){return Object.keys(l.ui.textarea.size).includes(e)}},color:{type:String,default:()=>l.ui.textarea.default.color,validator(e){return[...l.ui.colors,...Object.keys(l.ui.textarea.color)].includes(e)}},variant:{type:String,default:()=>l.ui.textarea.default.variant,validator(e){return[...Object.keys(l.ui.textarea.variant),...Object.values(l.ui.textarea.color).flatMap(a=>Object.keys(a))].includes(e)}},ui:{type:Object,default:()=>l.ui.textarea}},emits:["update:modelValue","blur"],setup(e,{emit:a}){const r=h(null),n=C(),t=f(()=>j({},e.ui,n.ui.textarea)),{emitFormBlur:i}=q(),u=()=>{e.autofocus&&r.value?.focus()},s=()=>{if(e.autoresize){if(!r.value)return;r.value.rows=e.rows;const o=window.getComputedStyle(r.value),g=parseInt(o.paddingTop),y=parseInt(o.paddingBottom),B=g+y,b=parseInt(o.lineHeight),{scrollHeight:w}=r.value,d=(w-B)/b;d>e.rows&&(r.value.rows=d)}},p=o=>{s(),a("update:modelValue",o.target.value)},m=o=>{i(),a("blur",o)};c(()=>{setTimeout(()=>{u()},100)}),k(()=>e.modelValue,()=>{I(s)}),c(()=>{setTimeout(()=>{u(),s()},100)});const v=f(()=>{const o=t.value.color?.[e.color]?.[e.variant]||t.value.variant[e.variant];return O(t.value.base,t.value.rounded,t.value.placeholder,t.value.size[e.size],e.padded?t.value.padding[e.size]:"p-0",o?.replaceAll("{color}",e.color),!e.resize&&"resize-none")});return{ui:t,textarea:r,textareaClass:v,onInput:p,onBlur:m}}}),A=["id","value","name","rows","required","disabled","placeholder"];function E(e,a,r,n,t,i){return S(),x("div",{class:$(e.ui.wrapper)},[T("textarea",V({id:e.name,ref:"textarea",value:e.modelValue,name:e.name,rows:e.rows,required:e.required,disabled:e.disabled,placeholder:e.placeholder,class:["form-textarea",e.textareaClass]},e.$attrs,{onInput:a[0]||(a[0]=(...u)=>e.onInput&&e.onInput(...u)),onBlur:a[1]||(a[1]=(...u)=>e.onBlur&&e.onBlur(...u))}),null,16,A)],2)}const D=H(N,[["render",E]]);export{D as default};
