import C from"./Icon.30f6becb.js";import{g as A,E as n,G as h,j as l,H as q,r as W,s as w,O as r,o as f,c as m,a as E,L as F,I as v,y as d,b as p,l as b}from"./entry.eb978f24.js";import{u as L}from"./useFormEvents.4d081bc0.js";import{_ as T}from"./_plugin-vue_export-helper.c27b6911.js";const M=A({components:{UIcon:C},inheritAttrs:!1,props:{modelValue:{type:[String,Number],default:""},type:{type:String,default:"text"},name:{type:String,default:null},placeholder:{type:String,default:null},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},icon:{type:String,default:null},loadingIcon:{type:String,default:()=>n.ui.input.default.loadingIcon},leadingIcon:{type:String,default:null},trailingIcon:{type:String,default:null},trailing:{type:Boolean,default:!1},leading:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},padded:{type:Boolean,default:!0},size:{type:String,default:()=>n.ui.input.default.size,validator(e){return Object.keys(n.ui.input.size).includes(e)}},color:{type:String,default:()=>n.ui.input.default.color,validator(e){return[...n.ui.colors,...Object.keys(n.ui.input.color)].includes(e)}},variant:{type:String,default:()=>n.ui.input.default.variant,validator(e){return[...Object.keys(n.ui.input.variant),...Object.values(n.ui.input.color).flatMap(i=>Object.keys(i))].includes(e)}},ui:{type:Object,default:()=>n.ui.input}},emits:["update:modelValue","blur"],setup(e,{emit:i,slots:g}){const s=h(),a=l(()=>q({},e.ui,s.ui.input)),{emitFormBlur:I}=L(),t=W(null),o=()=>{e.autofocus&&t.value?.focus()},z=u=>{i("update:modelValue",u.target.value)},B=u=>{I(),i("blur",u)};w(()=>{setTimeout(()=>{o()},100)});const S=l(()=>{const u=a.value.color?.[e.color]?.[e.variant]||a.value.variant[e.variant];return r(a.value.base,a.value.rounded,a.value.placeholder,a.value.size[e.size],e.padded?a.value.padding[e.size]:"p-0",u?.replaceAll("{color}",e.color),(c.value||g.leading)&&a.value.leading.padding[e.size],(y.value||g.trailing)&&a.value.trailing.padding[e.size])}),c=l(()=>e.icon&&e.leading||e.icon&&!e.trailing||e.loading&&!e.trailing||e.leadingIcon),y=l(()=>e.icon&&e.trailing||e.loading&&e.trailing||e.trailingIcon),N=l(()=>e.loading?e.loadingIcon:e.leadingIcon||e.icon),$=l(()=>e.loading&&!c.value?e.loadingIcon:e.trailingIcon||e.icon),k=l(()=>r(a.value.icon.leading.wrapper,a.value.icon.leading.pointer,a.value.icon.leading.padding[e.size])),j=l(()=>r(a.value.icon.base,s.ui.colors.includes(e.color)&&a.value.icon.color.replaceAll("{color}",e.color),a.value.icon.size[e.size],e.loading&&"animate-spin")),O=l(()=>r(a.value.icon.trailing.wrapper,a.value.icon.trailing.pointer,a.value.icon.trailing.padding[e.size])),V=l(()=>r(a.value.icon.base,s.ui.colors.includes(e.color)&&a.value.icon.color.replaceAll("{color}",e.color),a.value.icon.size[e.size],e.loading&&!c.value&&"animate-spin"));return{ui:a,input:t,isLeading:c,isTrailing:y,inputClass:S,leadingIconName:N,leadingIconClass:j,leadingWrapperIconClass:k,trailingIconName:$,trailingIconClass:V,trailingWrapperIconClass:O,onInput:z,onBlur:B}}}),U=["id","name","value","type","required","placeholder","disabled"];function G(e,i,g,s,a,I){const t=C;return f(),m("div",{class:d(e.ui.wrapper)},[E("input",F({id:e.name,ref:"input",name:e.name,value:e.modelValue,type:e.type,required:e.required,placeholder:e.placeholder,disabled:e.disabled||e.loading,class:["form-input",e.inputClass]},e.$attrs,{onInput:i[0]||(i[0]=(...o)=>e.onInput&&e.onInput(...o)),onBlur:i[1]||(i[1]=(...o)=>e.onBlur&&e.onBlur(...o))}),null,16,U),v(e.$slots,"default"),e.isLeading&&e.leadingIconName||e.$slots.leading?(f(),m("span",{key:0,class:d(e.leadingWrapperIconClass)},[v(e.$slots,"leading",{disabled:e.disabled,loading:e.loading},()=>[p(t,{name:e.leadingIconName,class:d(e.leadingIconClass)},null,8,["name","class"])])],2)):b("",!0),e.isTrailing&&e.trailingIconName||e.$slots.trailing?(f(),m("span",{key:1,class:d(e.trailingWrapperIconClass)},[v(e.$slots,"trailing",{disabled:e.disabled,loading:e.loading},()=>[p(t,{name:e.trailingIconName,class:d(e.trailingIconClass)},null,8,["name","class"])])],2)):b("",!0)],2)}const K=T(M,[["render",G]]);export{K as default};
