import{defineComponent as G,ref as N,computed as A,onMounted as J,onBeforeUpdate as K,onBeforeUnmount as L,createVNode as r,Fragment as Q}from"vue";import X from"@ant-design/icons-vue/CloseCircleFilled";import f from"../_util/classNames.mjs";import Y from"../_util/omit.mjs";import{getMergedStatus as Z,getStatusClassNames as I}from"../_util/statusUtils.mjs";import{useInjectDisabled as _}from"../config-provider/DisabledContext.mjs";import ee from"../config-provider/hooks/useConfigInject.mjs";import{useInjectFormItemContext as te,FormItemInputContext as ae,NoFormStatus as B}from"../form/FormItemContext.mjs";import{useCompactItemContext as re,NoCompactStyle as R}from"../space/Compact.mjs";import oe from"../vc-input/Input.mjs";import{hasPrefixSuffix as le}from"../vc-input/utils/commonUtils.mjs";import ue from"./inputProps.mjs";import ne from"./style/index.mjs";const Fe=G({compatConfig:{MODE:3},name:"AInput",inheritAttrs:!1,props:ue(),setup(s,{slots:o,attrs:b,expose:P,emit:u}){const a=N(),i=te(),h=ae.useInject(),c=A(()=>Z(h.status,s.status)),{direction:n,prefixCls:m,size:T,autocomplete:j}=ee("input",s),{compactSize:y,compactItemClassnames:z}=re(m,n),l=A(()=>y.value||T.value),[E,p]=ne(m),M=_();P({focus:e=>{a.value?.focus(e)},blur:()=>{a.value?.blur()},input:a,setSelectionRange:(e,g,C)=>{a.value?.setSelectionRange(e,g,C)},select:()=>{a.value?.select()}});const d=N([]),v=()=>{d.value.push(setTimeout(()=>{a.value?.input&&a.value?.input.getAttribute("type")==="password"&&a.value?.input.hasAttribute("value")&&a.value?.input.removeAttribute("value")}))};J(()=>{v()}),K(()=>{d.value.forEach(e=>clearTimeout(e))}),L(()=>{d.value.forEach(e=>clearTimeout(e))});const U=e=>{v(),u("blur",e),i.onFieldBlur()},V=e=>{v(),u("focus",e)},k=e=>{u("update:value",e.target.value),u("change",e),u("input",e),i.onFieldChange()};return()=>{const{hasFeedback:e,feedbackIcon:g}=h,{allowClear:C,bordered:w=!0,prefix:S=o.prefix?.(),suffix:x=o.suffix?.(),addonAfter:$=o.addonAfter?.(),addonBefore:F=o.addonBefore?.(),id:D=i.id?.value,...H}=s,O=(e||x)&&r(Q,null,[x,e&&g]),t=m.value,W=le({prefix:S,suffix:x})||!!e,q=o.clearIcon||(()=>r(X,null,null));return E(r(oe,{...b,...Y(H,["onUpdate:value","onChange","onInput"]),onChange:k,id:D,disabled:s.disabled??M.value,ref:a,prefixCls:t,autocomplete:j.value,onBlur:U,onFocus:V,prefix:S,suffix:O,allowClear:C,addonAfter:$&&r(R,null,{default:()=>[r(B,null,{default:()=>[$]})]}),addonBefore:F&&r(R,null,{default:()=>[r(B,null,{default:()=>[F]})]}),class:[b.class,z.value],inputClassName:f({[`${t}-sm`]:l.value==="small",[`${t}-lg`]:l.value==="large",[`${t}-rtl`]:n.value==="rtl",[`${t}-borderless`]:!w},!W&&I(t,c.value),p.value),affixWrapperClassName:f({[`${t}-affix-wrapper-sm`]:l.value==="small",[`${t}-affix-wrapper-lg`]:l.value==="large",[`${t}-affix-wrapper-rtl`]:n.value==="rtl",[`${t}-affix-wrapper-borderless`]:!w},I(`${t}-affix-wrapper`,c.value,e),p.value),wrapperClassName:f({[`${t}-group-rtl`]:n.value==="rtl"},p.value),groupClassName:f({[`${t}-group-wrapper-sm`]:l.value==="small",[`${t}-group-wrapper-lg`]:l.value==="large",[`${t}-group-wrapper-rtl`]:n.value==="rtl"},I(`${t}-group-wrapper`,c.value,e),p.value)},{...o,clearIcon:q}))}}});export{Fe as default};
