import z from"./Icon.fe8c0e68.js";import{E as G,G as c,g as M,j as l,r as T,s as U,N as d,o as m,c as p,a as E,K as L,H as y,y as s,b as S,l as N}from"./entry.9e31e8a4.js";import{t as H}from"./tw-merge.27ca352e.js";import{x as J,u as K}from"./ui.config.7ae255de.js";import{u as P}from"./useFormGroup.38d9f2fe.js";import{_ as D}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.87a09f8b.js";const i=G(c.ui.strategy,c.ui.input,J),Q=M({components:{UIcon:z},inheritAttrs:!1,props:{modelValue:{type:[String,Number],default:""},type:{type:String,default:"text"},id:{type:String,default:null},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:()=>i.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:()=>i.default.size,validator(e){return Object.keys(i.size).includes(e)}},color:{type:String,default:()=>i.default.color,validator(e){return[...c.ui.colors,...Object.keys(i.color)].includes(e)}},variant:{type:String,default:()=>i.default.variant,validator(e){return[...Object.keys(i.variant),...Object.values(i.color).flatMap(n=>Object.keys(n))].includes(e)}},inputClass:{type:String,default:null},ui:{type:Object,default:void 0}},emits:["update:modelValue","blur"],setup(e,{emit:n,slots:v}){const{ui:a,attrs:I}=K("input",e.ui,i,{mergeWrapper:!0}),{emitFormBlur:b,emitFormInput:g,formGroup:o}=P(e),u=l(()=>o?.error?.value?"red":e.color),t=l(()=>o?.size?.value??e.size),$=o?.labelFor,C=T(null),k=()=>{e.autofocus&&C.value?.focus()},j=r=>{n("update:modelValue",r.target.value),g()},V=r=>{b(),n("blur",r)};U(()=>{setTimeout(()=>{k()},100)});const O=l(()=>{const r=a.value.color?.[u.value]?.[e.variant]||a.value.variant[e.variant];return H(d(a.value.base,a.value.rounded,a.value.placeholder,a.value.size[t.value],e.padded?a.value.padding[t.value]:"p-0",r?.replaceAll("{color}",u.value),(f.value||v.leading)&&a.value.leading.padding[t.value],(B.value||v.trailing)&&a.value.trailing.padding[t.value]),e.inputClass)}),f=l(()=>e.icon&&e.leading||e.icon&&!e.trailing||e.loading&&!e.trailing||e.leadingIcon),B=l(()=>e.icon&&e.trailing||e.loading&&e.trailing||e.trailingIcon),w=l(()=>e.loading?e.loadingIcon:e.leadingIcon||e.icon),F=l(()=>e.loading&&!f.value?e.loadingIcon:e.trailingIcon||e.icon),W=l(()=>d(a.value.icon.leading.wrapper,a.value.icon.leading.pointer,a.value.icon.leading.padding[t.value])),h=l(()=>d(a.value.icon.base,c.ui.colors.includes(u.value)&&a.value.icon.color.replaceAll("{color}",u.value),a.value.icon.size[t.value],e.loading&&"animate-spin")),q=l(()=>d(a.value.icon.trailing.wrapper,a.value.icon.trailing.pointer,a.value.icon.trailing.padding[t.value])),A=l(()=>d(a.value.icon.base,c.ui.colors.includes(u.value)&&a.value.icon.color.replaceAll("{color}",u.value),a.value.icon.size[t.value],e.loading&&!f.value&&"animate-spin"));return{ui:a,attrs:I,id:$,input:C,isLeading:f,isTrailing:B,inputClass:O,leadingIconName:w,leadingIconClass:h,leadingWrapperIconClass:W,trailingIconName:F,trailingIconClass:A,trailingWrapperIconClass:q,onInput:j,onBlur:V}}}),R=["id","name","value","type","required","placeholder","disabled"];function X(e,n,v,a,I,b){const g=z;return m(),p("div",{class:s(e.ui.wrapper)},[E("input",L({id:e.id,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:n[0]||(n[0]=(...o)=>e.onInput&&e.onInput(...o)),onBlur:n[1]||(n[1]=(...o)=>e.onBlur&&e.onBlur(...o))}),null,16,R),y(e.$slots,"default"),e.isLeading&&e.leadingIconName||e.$slots.leading?(m(),p("span",{key:0,class:s(e.leadingWrapperIconClass)},[y(e.$slots,"leading",{disabled:e.disabled,loading:e.loading},()=>[S(g,{name:e.leadingIconName,class:s(e.leadingIconClass)},null,8,["name","class"])])],2)):N("",!0),e.isTrailing&&e.trailingIconName||e.$slots.trailing?(m(),p("span",{key:1,class:s(e.trailingWrapperIconClass)},[y(e.$slots,"trailing",{disabled:e.disabled,loading:e.loading},()=>[S(g,{name:e.trailingIconName,class:s(e.trailingIconClass)},null,8,["name","class"])])],2)):N("",!0)],2)}const ne=D(Q,[["render",X]]);export{ne as default};
