import{defineComponent as G,ref as C,watch as P,computed as f,createVNode as c,nextTick as V}from"vue";import j from"../_util/classNames.mjs";import{functionType as h,stringType as m,booleanType as w,arrayType as z}from"../_util/type.mjs";import A from"../_util/vue-types/index.mjs";import F from"../config-provider/hooks/useConfigInject.mjs";import{useInjectFormItemContext as N}from"../form/FormItemContext.mjs";import b from"./Radio.mjs";import{useProvideRadioGroupContext as D}from"./context.mjs";import E from"./style/index.mjs";const M=()=>({prefixCls:String,value:A.any,size:m(),options:z(),disabled:w(),name:String,buttonStyle:m("outline"),id:String,optionType:m("default"),onChange:h(),"onUpdate:value":h()}),X=G({compatConfig:{MODE:3},name:"ARadioGroup",inheritAttrs:!1,props:M(),setup(e,{slots:x,emit:v,attrs:p}){const g=N(),{prefixCls:n,direction:S,size:y}=F("radio",e),[T,$]=E(n),l=C(e.value),u=C(!1);return P(()=>e.value,a=>{l.value=a,u.value=!1}),D({onChange:a=>{const r=l.value,{value:o}=a.target;"value"in e||(l.value=o),!u.value&&o!==r&&(u.value=!0,v("update:value",o),v("change",a),g.onFieldChange()),V(()=>{u.value=!1})},value:l,disabled:f(()=>e.disabled),name:f(()=>e.name),optionType:f(()=>e.optionType)}),()=>{const{options:a,buttonStyle:r,id:o=g.id.value}=e,i=`${n.value}-group`,R=j(i,`${i}-${r}`,{[`${i}-${y.value}`]:y.value,[`${i}-rtl`]:S.value==="rtl"},p.class,$.value);let s=null;return a&&a.length>0?s=a.map(t=>{if(typeof t=="string"||typeof t=="number")return c(b,{key:t,prefixCls:n.value,disabled:e.disabled,value:t,checked:l.value===t},{default:()=>[t]});const{value:d,disabled:k,label:I}=t;return c(b,{key:`radio-group-value-options-${d}`,prefixCls:n.value,disabled:k||e.disabled,value:d,checked:l.value===d},{default:()=>[I]})}):s=x.default?.(),T(c("div",{...p,class:R,id:o},[s]))}}});export{X as default,M as radioGroupProps};
