import{defineComponent as de,computed as h,shallowRef as N,watch as ie,createVNode as a}from"vue";import{DownOutlined as pe,UpOutlined as ce}from"@antsoo-lib/icons";import m from"../_util/classNames.mjs";import y from"../_util/isValidValue.mjs";import me from"../_util/omit.mjs";import{getMergedStatus as fe,getStatusClassNames as S}from"../_util/statusUtils.mjs";import{stringType as T,booleanType as E}from"../_util/type.mjs";import{cloneElement as ve}from"../_util/vnode.mjs";import F from"../_util/vue-types/index.mjs";import{useInjectDisabled as ge}from"../config-provider/DisabledContext.mjs";import $e from"../config-provider/hooks/useConfigInject.mjs";import{useInjectFormItemContext as be,FormItemInputContext as Ce,NoFormStatus as H}from"../form/FormItemContext.mjs";import{useCompactItemContext as xe,NoCompactStyle as U}from"../space/Compact.mjs";import we,{inputNumberProps as Ie}from"./src/InputNumber.mjs";import he from"./style/index.mjs";const W=Ie(),Ne=()=>({...W,size:T(),bordered:E(!0),placeholder:String,name:String,id:String,controls:E(!1),type:String,addonBefore:F.any,addonAfter:F.any,prefix:F.any,"onUpdate:value":W.onChange,valueModifiers:Object,status:T()}),j=de({compatConfig:{MODE:3},name:"AInputNumber",inheritAttrs:!1,props:Ne(),slots:Object,setup(r,{emit:d,expose:G,attrs:q,slots:n}){const f=be(),z=Ce.useInject(),v=h(()=>fe(z.status,r.status)),{prefixCls:i,size:J,direction:o,disabled:K}=$e("input-number",r),{compactSize:L,compactItemClassnames:Q}=xe(i,o),X=ge(),A=h(()=>K.value??X.value),[Y,p]=he(i),t=h(()=>L.value||J.value),g=N(r.value??r.defaultValue),$=N(!1);ie(()=>r.value,()=>{g.value=r.value});const b=N(null),B=()=>{b.value?.focus()};G({focus:B,blur:()=>{b.value?.blur()}});const Z=l=>{r.value===void 0&&(g.value=l),d("update:value",l),d("change",l),f.onFieldChange()},_=l=>{$.value=!1,d("blur",l),f.onFieldBlur()},ee=l=>{$.value=!0,d("focus",l)};return()=>{const{hasFeedback:l,isFormItemInput:ae,feedbackIcon:re}=z,le=r.id??f.id.value,{class:c,bordered:V,readonly:C,style:x,addonBefore:w=n.addonBefore?.(),addonAfter:I=n.addonAfter?.(),prefix:O=n.prefix?.(),valueModifiers:ne={},...te}={...q,...r,id:le,disabled:A.value},e=i.value,oe=m({[`${e}-lg`]:t.value==="large",[`${e}-sm`]:t.value==="small",[`${e}-rtl`]:o.value==="rtl",[`${e}-readonly`]:C,[`${e}-borderless`]:!V,[`${e}-in-form-item`]:ae},S(e,v.value),c,Q.value,p.value);let s=a(we,{...me(te,["size","defaultValue"]),ref:b,lazy:!!ne.lazy,value:g.value,class:oe,prefixCls:e,readonly:C,onChange:Z,onBlur:_,onFocus:ee},{upHandler:n.upIcon?()=>a("span",{class:`${e}-handler-up-inner`},[n.upIcon()]):()=>a(ce,{class:`${e}-handler-up-inner`},null),downHandler:n.downIcon?()=>a("span",{class:`${e}-handler-down-inner`},[n.downIcon()]):()=>a(pe,{class:`${e}-handler-down-inner`},null)});const P=y(w)||y(I),D=y(O);if(D||l){const u=m(`${e}-affix-wrapper`,S(`${e}-affix-wrapper`,v.value,l),{[`${e}-affix-wrapper-focused`]:$.value,[`${e}-affix-wrapper-disabled`]:A.value,[`${e}-affix-wrapper-sm`]:t.value==="small",[`${e}-affix-wrapper-lg`]:t.value==="large",[`${e}-affix-wrapper-rtl`]:o.value==="rtl",[`${e}-affix-wrapper-readonly`]:C,[`${e}-affix-wrapper-borderless`]:!V,[`${c}`]:!P&&c},p.value);s=a("div",{class:u,style:x,onClick:B},[D&&a("span",{class:`${e}-prefix`},[O]),s,l&&a("span",{class:`${e}-suffix`},[re])])}if(P){const u=`${e}-group`,M=`${u}-addon`,k=w?a("div",{class:M},[w]):null,R=I?a("div",{class:M},[I]):null,se=m(`${e}-wrapper`,u,{[`${u}-rtl`]:o.value==="rtl"},p.value),ue=m(`${e}-group-wrapper`,{[`${e}-group-wrapper-sm`]:t.value==="small",[`${e}-group-wrapper-lg`]:t.value==="large",[`${e}-group-wrapper-rtl`]:o.value==="rtl"},S(`${i}-group-wrapper`,v.value,l),c,p.value);s=a("div",{class:ue,style:x},[a("div",{class:se},[k&&a(U,null,{default:()=>[a(H,null,{default:()=>[k]})]}),s,R&&a(U,null,{default:()=>[a(H,null,{default:()=>[R]})]})])])}return Y(ve(s,{style:x}))}}}),He=Object.assign(j,{install:r=>(r.component(j.name,j),r)});export{He as default,Ne as inputNumberProps};
