1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
import{o as e}from"./request-DWqS4XYU.js";import{Bn as t,Cr as n,Ct as r,Er as i,Hn as a,Ln as o,Ot as s,Pr as c,Q as l,Qn as u,Wn as d,Xt as f,at as p,en as m,mr as h,p as g,qt as _,rr as v,tt as y,wn as b,wt as x,yt as S}from"./jsx-runtime-Dk2XcqH2.js";import{t as C}from"./useForm-C1hpoRKe.js";import{a as w,i as T}from"./ColorPresets-BZbQ_VEs.js";import{n as E,t as D}from"./useBubbleLock-TNrx0Zlu.js";var O=e(c()),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`,d=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]:{...m(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},...d(i),[`&${c}-large`]:{...d(a)},[`&${c}-small`]:{...d(o)}}}}},P=e=>{let{componentCls:t,wrapperMarginInlineEnd:n,colorPrimary:r,colorPrimaryHover:i,radioSize:a,motionDurationSlow:s,motionDurationMid:c,motionEaseInOutCirc:l,colorBgContainer:u,colorBorder:d,lineWidth:p,colorBgContainerDisabled:h,colorTextDisabled:g,paddingXS:_,dotColorDisabled:v,dotSize:y,lineType:b,radioColor:x,radioBgColor:S}=e;return{[`${t}-wrapper`]:{...m(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]:{...m(e),position:`relative`,whiteSpace:`nowrap`,lineHeight:1,cursor:`pointer`,alignSelf:`center`,boxSizing:`border-box`,display:`block`,width:`calc(${a} * 1px)`,height:`calc(${a} * 1px)`,backgroundColor:u,border:`${o(p)} ${b} ${d}`,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)`]:f(e)},[`&:hover:not(${t}-wrapper-disabled) ${t}`]:{borderColor:r},[`&:hover ${t}-checked:not(${t}-disabled)`]:{backgroundColor:i,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:d,"&::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:i,lineType:a,colorBorder:s,motionDurationMid:c,buttonPaddingInline:l,fontSize:u,buttonBg:d,fontSizeLG:p,controlHeightLG:m,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:o(M(n).sub(M(i).mul(2)).equal()),background:d,border:`${o(i)} ${a} ${s}`,borderBlockStartWidth:M(i).add(.02).equal(),borderInlineEndWidth:i,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(i).mul(-1).equal()},"&:first-child":{borderInlineStart:`${o(i)} ${a} ${s}`,borderStartStartRadius:_,borderEndStartRadius:_},"&:last-child":{borderStartEndRadius:_,borderEndEndRadius:_},"&:first-child:last-child":{borderRadius:_},[`${r}-group-large &`]:{height:m,fontSize:p,lineHeight:o(M(m).sub(M(i).mul(2)).equal()),"&:first-child":{borderStartStartRadius:y,borderEndStartRadius:y},"&:last-child":{borderStartEndRadius:y,borderEndEndRadius:y}},[`${r}-group-small &`]:{height:h,paddingInline:M(g).sub(i).equal(),paddingBlock:0,lineHeight:o(M(h).sub(M(i).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(i).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)":f(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`}}}},ee=_(`Radio`,e=>{let{controlOutline:t,controlOutlineWidth:n}=e,r=`0 0 0 ${o(n)} ${t}`,i=b(e,{radioFocusShadow:r,radioButtonFocusShadow:r});return[N(i),P(i),F(i)]},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}}),I=O.forwardRef((e,t)=>{let n=O.useContext(k),i=O.useContext(j),{getPrefixCls:o,direction:s,className:c,style:l,classNames:u,styles:f}=a(`radio`),m=O.useRef(null),_=h(t,m),{isFormItemInput:y}=O.useContext(g),b=t=>{e.onChange?.(t),n?.onChange?.(t)},{prefixCls:C,className:A,rootClassName:M,children:N,style:P,title:F,classNames:I,styles:L,checked:R,...z}=e,B=o(`radio`,C),V=(n?.optionType||i)===`button`,H=V?`${B}-button`:B,U=S(B),[W,G]=ee(B,U),K={...z},q=O.useContext(p),J=`checked`in e,Y=R;n&&(K.name=n.name,K.onChange=b,Y=e.value===n.value,K.disabled=K.disabled??n.disabled),(J||n)&&(K.checked=Y),K.disabled=K.disabled??q;let te={...e,...K,checked:Y},X=x(l),Z=x(P),[Q,$]=r([u,I],[f,X,L,Z],{props:te}),ne=d(`${H}-wrapper`,{[`${H}-wrapper-checked`]:Y,[`${H}-wrapper-disabled`]:K.disabled,[`${H}-wrapper-rtl`]:s===`rtl`,[`${H}-wrapper-in-form-item`]:y,[`${H}-wrapper-block`]:!!n?.block},c,A,M,Q.root,W,G,U),[re,ie]=D(K.onClick);return O.createElement(T,{component:`Radio`,disabled:K.disabled},O.createElement(`label`,{className:ne,style:$.root,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,title:F,onClick:re},O.createElement(E,{...K,className:d(Q.icon,{[w]:!V}),style:$.icon,type:`radio`,prefixCls:H,ref:_,onClick:ie}),v(N)?O.createElement(`span`,{className:d(`${H}-label`,Q.label),style:$.label},N):null))}),L=O.forwardRef((e,r)=>{let{getPrefixCls:a,direction:o}=O.useContext(t),{name:c}=O.useContext(g),f=n(C(c)),{prefixCls:p,className:m,rootClassName:h,options:_,buttonStyle:v=`outline`,disabled:b,children:x,size:w,style:T,id:E,optionType:D,name:k=f,defaultValue:j,value:M,block:N=!1,onChange:P,onMouseEnter:F,onMouseLeave:L,onFocus:R,onBlur:z,orientation:B,vertical:V,role:H=`radiogroup`}=e,[U,W]=i(j,M),G=O.useCallback(e=>{let t=U,n=e.target.value;W(n),n!==t&&P?.(e)},[U,W,P]),K=a(`radio`,p),q=`${K}-group`,J=S(K),[Y,te]=ee(K,J),X=x;_&&_.length>0&&(X=_.map(e=>typeof e==`string`||s(e)?O.createElement(I,{key:e.toString(),prefixCls:K,disabled:b,value:e,checked:U===e},e):O.createElement(I,{key:`radio-group-value-options-${e.value}`,prefixCls:K,disabled:e.disabled||b,value:e.value,checked:U===e.value,title:e.title,style:e.style,className:e.className,id:e.id,required:e.required,onChange:e.onChange},e.label)));let Z=l(w),[,Q]=y(B,V),$=d(q,`${q}-${v}`,{[`${q}-large`]:Z===`large`,[`${q}-small`]:Z===`small`,[`${q}-rtl`]:o===`rtl`,[`${q}-block`]:N},m,h,Y,te,J),ne=O.useMemo(()=>({onChange:G,value:U,disabled:b,name:k,optionType:D,block:N}),[G,U,b,k,D,N]);return O.createElement(`div`,{...u(e,{aria:!0,data:!0}),role:H,className:d($,{[`${K}-group-vertical`]:Q}),style:T,onMouseEnter:F,onMouseLeave:L,onFocus:R,onBlur:z,id:E,ref:r},O.createElement(A,{value:ne},X))}),R=O.memo(L),z=O.forwardRef((e,n)=>{let{getPrefixCls:r}=O.useContext(t),{prefixCls:i,...a}=e,o=r(`radio`,i);return O.createElement(M,{value:`button`},O.createElement(I,{prefixCls:o,...a,type:`radio`,ref:n}))}),B=I;B.Button=z,B.Group=R,B.__ANT_RADIO=!0;export{B as t}; |