Files
2026-07-31 18:51:41 +08:00

1 line
11 KiB
JavaScript

import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{Dr as t,Ln as n,Ot as r,Pn as i,Q as a,St as o,Tt as s,Vn as c,Wt as l,Xn as u,Zt as d,at as f,p,qt as m,tt as h,ur as g,vr as _,xn as v,xt as y,yr as b,yt as x,zn as S}from"./jsx-runtime-ADHq9IcL.js";import{t as C}from"./useForm-CvzzkaGD.js";import{a as w,i as T}from"./ColorPresets-wH0crouI.js";import{n as E,t as D}from"./useBubbleLock-CoAwAGkH.js";var O=e(t()),k=O.createContext(void 0),A=k.Provider,j=O.createContext(void 0),M=j.Provider,N=e=>{let{componentCls:t,antCls:n,lineWidth:r,borderRadius:i,borderRadiusLG:a,borderRadiusSM:o,calc:s}=e,c=`${t}-group`,l=`${t}-button-wrapper`,u=`${n}-badge`,f=e=>({[`> ${u}`]:{width:`auto`},[`> ${u} > ${l}`]:{width:`100%`},[`> ${u}:not(:last-child)`]:{marginBlockEnd:s(r).mul(-1).equal()},[`> ${u} > ${l}:not(:last-child)`]:{marginBlockEnd:0},[`> ${u}:first-child > ${l}`]:{borderStartStartRadius:e,borderStartEndRadius:e,borderEndStartRadius:0,borderEndEndRadius:0},[`> ${u}:last-child > ${l}`]:{borderStartStartRadius:0,borderStartEndRadius:0,borderEndStartRadius:e,borderEndEndRadius:e},[`> ${u}:not(:first-child):not(:last-child) > ${l}`]:{borderRadius:0},[`> ${u}:first-child:last-child > ${l}`]:{borderRadius:e}});return{[c]:{...d(e),display:`inline-block`,fontSize:0,[`&${c}-rtl`]:{direction:`rtl`},[`&${c}-block`]:{display:`flex`},[`${n}-badge ${n}-badge-count`]:{zIndex:1},[`> ${n}-badge:not(:first-child) > ${n}-button-wrapper`]:{borderInlineStart:`none`},"&-vertical":{display:`flex`,flexDirection:`column`,rowGap:e.marginXS,[`&:has(> ${l}, > ${u} > ${l})`]:{rowGap:0},[`${t}-wrapper`]:{marginInlineEnd:0},...f(i),[`&${c}-large`]:{...f(a)},[`&${c}-small`]:{...f(o)}}}}},P=e=>{let{componentCls:t,wrapperMarginInlineEnd:n,colorPrimary:r,colorPrimaryHover:a,radioSize:o,motionDurationSlow:s,motionDurationMid:c,motionEaseInOutCirc:l,colorBgContainer:u,colorBorder:f,lineWidth:p,colorBgContainerDisabled:h,colorTextDisabled:g,paddingXS:_,dotColorDisabled:v,dotSize:y,lineType:b,radioColor:x,radioBgColor:S}=e;return{[`${t}-wrapper`]:{...d(e),display:`inline-flex`,alignItems:`baseline`,marginInlineStart:0,marginInlineEnd:n,cursor:`pointer`,"&:last-child":{marginInlineEnd:0},[`&${t}-wrapper-rtl`]:{direction:`rtl`},"&-disabled":{cursor:`not-allowed`,color:e.colorTextDisabled},"&::after":{display:`inline-block`,width:0,overflow:`hidden`,content:`"\\a0"`},"&-block":{flex:1,justifyContent:`center`},[t]:{...d(e),position:`relative`,whiteSpace:`nowrap`,lineHeight:1,cursor:`pointer`,alignSelf:`center`,boxSizing:`border-box`,display:`block`,width:`calc(${o} * 1px)`,height:`calc(${o} * 1px)`,backgroundColor:u,border:`${i(p)} ${b} ${f}`,borderRadius:`50%`,transition:`all ${c}`,flex:`none`,"&:after":{content:`""`,position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%) scale(0)`,width:`calc(${y} * 1px)`,height:`calc(${y} * 1px)`,backgroundColor:x,borderRadius:`50%`,transformOrigin:`50% 50%`,opacity:0,transition:`all ${s} ${l}`},[`${t}-input`]:{position:`absolute`,inset:0,zIndex:1,cursor:`pointer`,opacity:0,margin:0},[`&:has(${t}-input:focus-visible)`]:m(e)},[`&:hover:not(${t}-wrapper-disabled) ${t}`]:{borderColor:r},[`&:hover ${t}-checked:not(${t}-disabled)`]:{backgroundColor:a,borderColor:`transparent`},[`${t}-checked`]:{backgroundColor:S,borderColor:r,"&::after":{transform:`translate(-50%, -50%)`,opacity:1}},[`${t}-disabled`]:{[`&, ${t}-input`]:{cursor:`not-allowed`,pointerEvents:`none`},background:h,borderColor:f,"&::after":{backgroundColor:v}},[`${t}-disabled + span`]:{color:g,cursor:`not-allowed`},[`span${t} + *`]:{paddingInlineStart:_,paddingInlineEnd:_}}}},F=e=>{let{buttonColor:t,controlHeight:n,componentCls:r,lineWidth:a,lineType:o,colorBorder:s,motionDurationMid:c,buttonPaddingInline:l,fontSize:u,buttonBg:d,fontSizeLG:f,controlHeightLG:p,controlHeightSM:h,paddingXS:g,borderRadius:_,borderRadiusSM:v,borderRadiusLG:y,buttonCheckedBg:b,buttonSolidCheckedColor:x,colorTextDisabled:S,colorBgContainerDisabled:C,buttonCheckedBgDisabled:w,buttonCheckedColorDisabled:T,colorPrimary:E,colorPrimaryHover:D,colorPrimaryActive:O,buttonSolidCheckedBg:k,buttonSolidCheckedHoverBg:A,buttonSolidCheckedActiveBg:j,calc:M}=e;return{[`${r}-button-wrapper`]:{position:`relative`,display:`inline-block`,height:n,margin:0,paddingInline:l,paddingBlock:0,color:t,fontSize:u,lineHeight:i(M(n).sub(M(a).mul(2)).equal()),background:d,border:`${i(a)} ${o} ${s}`,borderBlockStartWidth:M(a).add(.02).equal(),borderInlineEndWidth:a,cursor:`pointer`,transition:[`color`,`background-color`,`box-shadow`].map(e=>`${e} ${c}`).join(`,`),a:{color:t},[`> ${r}-button`]:{position:`absolute`,insetBlockStart:0,insetInlineStart:0,zIndex:-1,width:`100%`,height:`100%`},"&:not(:last-child)":{marginInlineEnd:M(a).mul(-1).equal()},"&:first-child":{borderInlineStart:`${i(a)} ${o} ${s}`,borderStartStartRadius:_,borderEndStartRadius:_},"&:last-child":{borderStartEndRadius:_,borderEndEndRadius:_},"&:first-child:last-child":{borderRadius:_},[`${r}-group-large &`]:{height:p,fontSize:f,lineHeight:i(M(p).sub(M(a).mul(2)).equal()),"&:first-child":{borderStartStartRadius:y,borderEndStartRadius:y},"&:last-child":{borderStartEndRadius:y,borderEndEndRadius:y}},[`${r}-group-small &`]:{height:h,paddingInline:M(g).sub(a).equal(),paddingBlock:0,lineHeight:i(M(h).sub(M(a).mul(2)).equal()),"&:first-child":{borderStartStartRadius:v,borderEndStartRadius:v},"&:last-child":{borderStartEndRadius:v,borderEndEndRadius:v}},[`${r}-group-vertical > &`]:{marginInlineEnd:0,borderRadius:0,"&:not(:last-child)":{marginBlockEnd:M(a).mul(-1).equal()},"&:first-child":{borderStartStartRadius:_,borderStartEndRadius:_,borderEndStartRadius:0,borderEndEndRadius:0},"&:last-child":{borderStartStartRadius:0,borderStartEndRadius:0,borderEndStartRadius:_,borderEndEndRadius:_},"&:first-child:last-child":{borderRadius:_}},[`${r}-group-vertical${r}-group-large > &`]:{"&:first-child":{borderStartStartRadius:y,borderStartEndRadius:y},"&:last-child":{borderEndStartRadius:y,borderEndEndRadius:y},"&:first-child:last-child":{borderRadius:y}},[`${r}-group-vertical${r}-group-small > &`]:{"&:first-child":{borderStartStartRadius:v,borderStartEndRadius:v},"&:last-child":{borderEndStartRadius:v,borderEndEndRadius:v},"&:first-child:last-child":{borderRadius:v}},"&:hover":{position:`relative`,color:E},"&:has(:focus-visible)":m(e),[`${r}, input[type='checkbox'], input[type='radio']`]:{width:0,height:0,opacity:0,pointerEvents:`none`},[`&-checked:not(${r}-button-wrapper-disabled)`]:{zIndex:1,color:E,background:b,borderColor:E,"&::before":{backgroundColor:E},"&:first-child":{borderColor:E},"&:hover":{color:D,borderColor:D,"&::before":{backgroundColor:D}},"&:active":{color:O,borderColor:O,"&::before":{backgroundColor:O}}},[`${r}-group-solid &-checked:not(${r}-button-wrapper-disabled)`]:{color:x,background:k,borderColor:k,"&:hover":{color:x,background:A,borderColor:A},"&:active":{color:x,background:j,borderColor:j}},"&-disabled":{color:S,backgroundColor:C,borderColor:s,cursor:`not-allowed`,"&:first-child, &:hover":{color:S,backgroundColor:C,borderColor:s}},[`&-disabled${r}-button-wrapper-checked`]:{color:T,backgroundColor:w,borderColor:s,boxShadow:`none`},"&-block":{flex:1,textAlign:`center`}}}},I=l(`Radio`,e=>{let{controlOutline:t,controlOutlineWidth:n}=e,r=`0 0 0 ${i(n)} ${t}`,a=v(e,{radioFocusShadow:r,radioButtonFocusShadow:r});return[N(a),P(a),F(a)]},e=>{let{wireframe:t,padding:n,marginXS:r,lineWidth:i,fontSizeLG:a,colorText:o,colorBgContainer:s,colorTextDisabled:c,controlItemBgActiveDisabled:l,colorTextLightSolid:u,colorPrimary:d,colorPrimaryHover:f,colorPrimaryActive:p,colorWhite:m}=e,h=a;return{radioSize:h,dotSize:t?h-8:h-(4+i)*2,dotColorDisabled:c,buttonSolidCheckedColor:u,buttonSolidCheckedBg:d,buttonSolidCheckedHoverBg:f,buttonSolidCheckedActiveBg:p,buttonBg:s,buttonCheckedBg:s,buttonColor:o,buttonCheckedBgDisabled:l,buttonCheckedColorDisabled:c,buttonPaddingInline:n-i,wrapperMarginInlineEnd:r,radioColor:t?d:m,radioBgColor:t?s:d}},{unitless:{radioSize:!0,dotSize:!0}}),L=O.forwardRef((e,t)=>{let n=O.useContext(k),i=O.useContext(j),{getPrefixCls:a,direction:s,className:l,style:u,classNames:d,styles:m}=S(`radio`),h=g(t,O.useRef(null)),{isFormItemInput:_}=O.useContext(p),v=t=>{e.onChange?.(t),n?.onChange?.(t)},{prefixCls:b,className:C,rootClassName:A,children:M,style:N,title:P,classNames:F,styles:L,checked:R,...z}=e,B=a(`radio`,b),V=(n?.optionType||i)===`button`,H=V?`${B}-button`:B,U=x(B),[W,G]=I(B,U),K={...z},q=O.useContext(f),J=`checked`in e,Y=R;n&&(K.name=n.name,K.onChange=v,Y=e.value===n.value,K.disabled=K.disabled??n.disabled),(J||n)&&(K.checked=Y),K.disabled=K.disabled??q;let X={...e,...K,checked:Y},ee=o(u),Z=o(N),[Q,$]=y([d,F],[m,ee,L,Z],{props:X}),te=c(`${H}-wrapper`,{[`${H}-wrapper-checked`]:Y,[`${H}-wrapper-disabled`]:K.disabled,[`${H}-wrapper-rtl`]:s===`rtl`,[`${H}-wrapper-in-form-item`]:_,[`${H}-wrapper-block`]:!!n?.block},l,C,A,Q.root,W,G,U),[ne,re]=D(K.onClick);return O.createElement(T,{component:`Radio`,disabled:K.disabled},O.createElement(`label`,{className:te,style:$.root,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,title:P,onClick:ne},O.createElement(E,{...K,className:c(Q.icon,{[w]:!V}),style:$.icon,type:`radio`,prefixCls:H,ref:h,onClick:re}),r(M)?O.createElement(`span`,{className:c(`${H}-label`,Q.label),style:$.label},M):null))}),R=O.forwardRef((e,t)=>{let{getPrefixCls:r,direction:i}=O.useContext(n),{name:o}=O.useContext(p),l=_(C(o)),{prefixCls:d,className:f,rootClassName:m,options:g,buttonStyle:v=`outline`,disabled:y,children:S,size:w,style:T,id:E,optionType:D,name:k=l,defaultValue:j,value:M,block:N=!1,onChange:P,onMouseEnter:F,onMouseLeave:R,onFocus:z,onBlur:B,orientation:V,vertical:H,role:U=`radiogroup`}=e,[W,G]=b(j,M),K=O.useCallback(t=>{let n=W,r=t.target.value;`value`in e||G(r),r!==n&&P?.(t)},[W,G,P]),q=r(`radio`,d),J=`${q}-group`,Y=x(q),[X,ee]=I(q,Y),Z=S;g&&g.length>0&&(Z=g.map(e=>typeof e==`string`||s(e)?O.createElement(L,{key:e.toString(),prefixCls:q,disabled:y,value:e,checked:W===e},e):O.createElement(L,{key:`radio-group-value-options-${e.value}`,prefixCls:q,disabled:e.disabled||y,value:e.value,checked:W===e.value,title:e.title,style:e.style,className:e.className,id:e.id,required:e.required},e.label)));let Q=a(w),[,$]=h(V,H),te=c(J,`${J}-${v}`,{[`${J}-large`]:Q===`large`,[`${J}-small`]:Q===`small`,[`${J}-rtl`]:i===`rtl`,[`${J}-block`]:N},f,m,X,ee,Y),ne=O.useMemo(()=>({onChange:K,value:W,disabled:y,name:k,optionType:D,block:N}),[K,W,y,k,D,N]);return O.createElement(`div`,{...u(e,{aria:!0,data:!0}),role:U,className:c(te,{[`${q}-group-vertical`]:$}),style:T,onMouseEnter:F,onMouseLeave:R,onFocus:z,onBlur:B,id:E,ref:t},O.createElement(A,{value:ne},Z))}),z=O.memo(R),B=O.forwardRef((e,t)=>{let{getPrefixCls:r}=O.useContext(n),{prefixCls:i,...a}=e,o=r(`radio`,i);return O.createElement(M,{value:`button`},O.createElement(L,{prefixCls:o,...a,type:`radio`,ref:t}))}),V=L;V.Button=B,V.Group=z,V.__ANT_RADIO=!0;export{V as t};