Files
xin-procurement/public/assets/checkbox-BInXsQR0.js
T
2026-09-16 23:53:05 +08:00

4 lines
6.2 KiB
JavaScript

import{o as e}from"./request-DWqS4XYU.js";import{$n as t,Bn as n,Ct as r,Er as i,Hn as a,Ln as o,Ot as s,Pr as c,Un as l,Wn as u,Xt as d,at as f,en as p,jr as m,jt as h,nr as g,p as _,qt as v,rr as y,wn as b,wt as x,yr as S,yt as C}from"./jsx-runtime-Dk2XcqH2.js";import{a as w,i as T}from"./ColorPresets-BZbQ_VEs.js";import{i as E,r as D}from"./button-CdrnzceP.js";import{n as O,t as k}from"./useBubbleLock-TNrx0Zlu.js";var A=e(c()),j=e=>{let{checkboxCls:t,checkboxSize:n,lineWidth:r}=e,i=`${t}-wrapper`,a=`@media (hover: hover) and (pointer: fine)`;return[{[`${t}-group`]:{...p(e),display:`inline-flex`,flexWrap:`wrap`,columnGap:e.marginXS,[`> ${e.antCls}-row`]:{flex:1}},[i]:{...p(e),display:`inline-flex`,alignItems:`baseline`,cursor:`pointer`,"&:after":{display:`inline-block`,width:0,overflow:`hidden`,content:`'\\a0'`},[`& + ${i}`]:{marginInlineStart:0}},[t]:{...p(e),position:`relative`,whiteSpace:`nowrap`,lineHeight:1,cursor:`pointer`,alignSelf:`center`,boxSizing:`border-box`,display:`block`,width:n,height:n,direction:`ltr`,backgroundColor:e.colorBgContainer,border:`${o(r)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,borderCollapse:`separate`,transition:`all ${e.motionDurationSlow}`,flex:`none`,...E(),"&:after":{boxSizing:`border-box`,position:`absolute`,top:`calc(${n} / 2 - ${r})`,insetInlineStart:`calc(${n} / 4 - ${r})`,display:`table`,width:e.calc(n).div(14).mul(5).equal(),height:e.calc(n).div(14).mul(8).equal(),border:`${o(e.lineWidthBold)} solid ${e.colorWhite}`,borderTop:0,borderInlineStart:0,transform:`rotate(45deg) scale(0) translate(-50%,-50%)`,opacity:0,content:`""`,transition:`all ${e.motionDurationFast} ${e.motionEaseInBack}, opacity ${e.motionDurationFast}`,...D()},[`${t}-input`]:{position:`absolute`,inset:`calc(-1 * (${r}))`,zIndex:1,cursor:`pointer`,opacity:0,margin:0},[`&:has(${t}-input:focus-visible)`]:d(e),"& + span":{paddingInlineStart:e.paddingXS,paddingInlineEnd:e.paddingXS}}},{[a]:{[`
${i}:not(${i}-disabled),
${t}:not(${t}-disabled)
`]:{[`&:hover ${t}`]:{borderColor:e.colorPrimary}},[`${i}:not(${i}-disabled)`]:{[`&:hover ${t}-checked:not(${t}-disabled)`]:{backgroundColor:e.colorPrimaryHover,borderColor:`transparent`}}}},{[`${t}-checked`]:{backgroundColor:e.colorPrimary,borderColor:e.colorPrimary,"&:after":{opacity:1,transform:`rotate(45deg) scale(1) translate(-50%,-50%)`,transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack} ${e.motionDurationFast}`,...D()},[a]:{[`&:not(${t}-disabled):hover`]:{backgroundColor:e.colorPrimaryHover,borderColor:`transparent`}}}},{[t]:{"&-indeterminate":{backgroundColor:e.colorBgContainer,borderColor:e.colorBorder,"&:after":{top:`50%`,insetInlineStart:`50%`,width:e.calc(e.fontSizeLG).div(2).equal(),height:e.calc(e.fontSizeLG).div(2).equal(),backgroundColor:e.colorPrimary,border:0,transform:`translate(-50%, -50%) scale(1)`,opacity:1,content:`""`},[a]:{[`&:not(${t}-disabled):hover`]:{backgroundColor:e.colorBgContainer,borderColor:e.colorPrimary}}}}},{[`${i}-disabled`]:{cursor:`not-allowed`},[`${t}-disabled`]:{[`&, ${t}-input`]:{cursor:`not-allowed`,pointerEvents:`none`},background:e.colorBgContainerDisabled,borderColor:e.colorBorder,"&:after":{borderColor:e.colorTextDisabled},"& + span":{color:e.colorTextDisabled},[`&${t}-indeterminate::after`]:{background:e.colorTextDisabled}}}]};function M(e,t){return j(b(t,{checkboxCls:`.${e}`,checkboxSize:t.controlInteractiveSize}))}var N=v(`Checkbox`,(e,{prefixCls:t})=>[M(t,e)]),P=A.createContext(null),F=A.forwardRef((e,t)=>{let{prefixCls:n,children:o,indeterminate:s=!1,onMouseEnter:c,onMouseLeave:l,skipGroup:d=!1,disabled:p,rootClassName:h,className:g,style:v,classNames:b,styles:E,name:D,value:j,checked:M,defaultChecked:F,onChange:I,...L}=e,{getPrefixCls:R,direction:z,className:B,style:V,classNames:H,styles:U}=a(`checkbox`),W=A.useContext(P),{isFormItemInput:ee}=A.useContext(_),te=A.useContext(f),G=p??W?.disabled??te,[ne,re]=i(F,M),K=ne,ie=m(e=>{re(e.target.checked),I?.(e),!d&&W?.toggleOption&&W.toggleOption({label:o,value:j})});W&&!d&&(K=W.value.includes(j));let q=A.useRef(null),ae=S(t,q);A.useEffect(()=>{if(!d&&W)return W.registerValue(j),()=>{W.cancelValue(j)}},[j,d]),A.useEffect(()=>{q.current?.input&&(q.current.input.indeterminate=s)},[s]);let J=R(`checkbox`,n),Y=C(J),[X,oe]=N(J,Y),Z={...L},se={...e,indeterminate:s,disabled:G,checked:K},ce=x(V),le=x(v),[Q,$]=r([H,b],[U,ce,E,le],{props:se}),ue=u(`${J}-wrapper`,{[`${J}-rtl`]:z===`rtl`,[`${J}-wrapper-checked`]:K,[`${J}-wrapper-disabled`]:G,[`${J}-wrapper-in-form-item`]:ee},B,g,Q.root,h,oe,Y,X),de=u(Q.icon,{[`${J}-indeterminate`]:s},w,X),[fe,pe]=k(Z.onClick);return A.createElement(T,{component:`Checkbox`,disabled:G},A.createElement(`label`,{className:ue,style:$.root,onMouseEnter:c,onMouseLeave:l,onClick:fe},A.createElement(O,{...Z,name:!d&&W?W.name:D,checked:K,onClick:pe,onChange:ie,prefixCls:J,className:de,style:$.icon,disabled:G,ref:ae,value:j}),y(o)&&A.createElement(`span`,{className:u(`${J}-label`,Q.label),style:$.label},o)))}),I=A.forwardRef((e,r)=>{let{defaultValue:a,children:o,options:c=[],prefixCls:d,className:f,rootClassName:p,style:m,onChange:_,role:v=`group`,...y}=e,{getPrefixCls:b,direction:x}=A.useContext(n),[S,w]=i(a||[],y.value),T=S||[],[E,D]=A.useState([]),O=A.useMemo(()=>c.map(e=>h(e)||s(e)?{label:e,value:e}:e).filter(e=>g(e)&&g(e.value)),[c]),k=e=>{D(t=>t.filter(t=>t!==e))},j=e=>{D(t=>[].concat(l(t),[e]))},M=e=>{let t=T.indexOf(e.value),n=l(T);t===-1?n.push(e.value):n.splice(t,1),w(n),_?.(n.filter(e=>E.includes(e)).sort((e,t)=>O.findIndex(t=>t.value===e)-O.findIndex(e=>e.value===t)))},I=b(`checkbox`,d),L=`${I}-group`,R=C(I),[z,B]=N(I,R),V=t(y,[`value`,`disabled`]),H=Array.isArray(O)&&O.length>0?O.map(e=>A.createElement(F,{prefixCls:I,key:e.value.toString(),disabled:`disabled`in e?e.disabled:y.disabled,value:e.value,checked:T.includes(e.value),onChange:e.onChange,className:u(`${L}-item`,e.className),style:e.style,title:e.title,id:e.id,required:e.required},e.label)):o,U=A.useMemo(()=>({toggleOption:M,value:T,disabled:y.disabled,name:y.name,registerValue:j,cancelValue:k}),[M,T,y.disabled,y.name,j,k]),W=u(L,{[`${L}-rtl`]:x===`rtl`},f,p,B,R,z);return A.createElement(`div`,{className:W,style:m,role:v,...V,ref:r},A.createElement(P.Provider,{value:U},H))}),L=F;L.Group=I,L.__ANT_CHECKBOX=!0;export{M as n,L as t};