1 line
8.4 KiB
JavaScript
1 line
8.4 KiB
JavaScript
import{o as e}from"./request-xrnk7ZJV.js";import{$n as t,Bn as n,Ct as r,Er as i,Et as a,Hn as o,Jt as s,Ln as c,P as l,Pr as u,Qn as d,Un as f,Wn as p,_n as m,at as h,en as g,kt as _,lt as v,qt as y,rr as b,st as x,wn as S,wt as C,yt as w}from"./jsx-runtime-OfKoVykY.js";import{S as T,n as E,r as D}from"./tooltip-DI_m69zk.js";import{n as O,r as k}from"./useClosable-kLlcGubw.js";import{i as ee,n as A}from"./ColorPresets-BWkFn7Wc.js";var j=e(u()),M=e=>{let{paddingXXS:t,lineWidth:n,tagPaddingHorizontal:r,componentCls:i,calc:a}=e,o=a(r).sub(n).equal(),s=a(t).sub(n).equal();return{[i]:{...g(e),display:`inline-block`,height:`auto`,paddingInline:o,fontSize:e.tagFontSize,lineHeight:e.tagLineHeight,whiteSpace:`nowrap`,backgroundColor:e.defaultBg,border:`${c(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,opacity:1,transition:`all ${e.motionDurationMid}`,textAlign:`start`,position:`relative`,[`&${i}-rtl`]:{direction:`rtl`},"&, a, a:hover":{color:e.defaultColor},[`${i}-close-icon`]:{marginInlineStart:s,fontSize:e.tagIconSize,color:e.colorIcon,cursor:`pointer`,transition:`all ${e.motionDurationMid}`,"&:hover":{color:e.colorTextHeading}},"&-checkable":{backgroundColor:`transparent`,borderColor:`transparent`,cursor:`pointer`,[`&:not(${i}-checkable-checked):hover`]:{color:e.colorPrimary,backgroundColor:e.colorFillSecondary},"&:active, &-checked":{color:e.colorTextLightSolid},"&-checked":{backgroundColor:e.colorPrimary,"&:hover":{backgroundColor:e.colorPrimaryHover}},"&:active":{backgroundColor:e.colorPrimaryActive},"&-disabled":{cursor:`not-allowed`,[`&:not(${i}-checkable-checked)`]:{color:e.colorTextDisabled,"&:hover":{backgroundColor:`transparent`}},[`&${i}-checkable-checked`]:{color:e.colorTextDisabled,backgroundColor:e.colorBgContainerDisabled},"&:hover, &:active":{backgroundColor:e.colorBgContainerDisabled,color:e.colorTextDisabled},[`&:not(${i}-checkable-checked):hover`]:{color:e.colorTextDisabled}},"&-group":{display:`flex`,flexWrap:`wrap`,gap:e.paddingXS}},"&-hidden":{display:`none`},"> svg":{display:`inline-block`,verticalAlign:`middle`,marginBlockEnd:`0.2em`},[`> ${e.iconCls} + span, > span + ${e.iconCls}, > svg + span, > span + svg`]:{marginInlineStart:o}},[`&${e.componentCls}-solid`]:{borderColor:`transparent`,color:e.colorTextLightSolid,backgroundColor:e.colorBgSolid,[`&${i}-default`]:{color:e.solidTextColor}},[`${i}-filled`]:{borderColor:`transparent`,backgroundColor:e.tagBorderlessBg},[`&${i}-disabled`]:{color:e.colorTextDisabled,cursor:`not-allowed`,backgroundColor:e.colorBgContainerDisabled,a:{cursor:`not-allowed`,pointerEvents:`none`,color:e.colorTextDisabled,"&:hover":{color:e.colorTextDisabled}},"a&":{"&:hover, &:active":{color:e.colorTextDisabled}},[`&${i}-outlined`]:{borderColor:e.colorBorderDisabled},[`&${i}-solid, &${i}-filled`]:{color:e.colorTextDisabled,[`${i}-close-icon`]:{color:e.colorTextDisabled}},[`${i}-close-icon`]:{cursor:`not-allowed`,color:e.colorTextDisabled,"&:hover":{color:e.colorTextDisabled}}}}},N=e=>{let{lineWidth:t,fontSizeIcon:n,calc:r}=e,i=e.fontSizeSM;return S(e,{tagFontSize:i,tagLineHeight:c(r(e.lineHeightSM).mul(i).equal()),tagIconSize:r(n).sub(r(t).mul(2)).equal(),tagPaddingHorizontal:8,tagBorderlessBg:e.defaultBg})},P=e=>{let t=A(new l(e.colorBgSolid),`#fff`)?`#000`:`#fff`;return{defaultBg:new m(e.colorFillTertiary).onBackground(e.colorBgContainer).toHexString(),defaultColor:e.colorText,solidTextColor:t}},F=y(`Tag`,e=>M(N(e)),P),I=j.forwardRef((e,t)=>{let{prefixCls:r,style:i,className:a,checked:o,children:s,icon:c,onChange:l,onClick:u,onKeyDown:d,disabled:f,...m}=e,{getPrefixCls:g,tag:_}=j.useContext(n),v=j.useContext(h),y=f??v,b=e=>{y||(l?.(!o),u?.(e))},x=e=>{d?.(e),!(e.defaultPrevented||y)&&e.key===` `&&(e.preventDefault(),e.repeat||l?.(!o))},S=g(`tag`,r),[C,w]=F(S),T=p(S,`${S}-checkable`,{[`${S}-checkable-checked`]:o,[`${S}-checkable-disabled`]:y},_?.className,a,C,w);return j.createElement(`span`,{...m,ref:t,role:`checkbox`,"aria-checked":o,"aria-disabled":y||void 0,tabIndex:y?-1:0,style:{..._?.style,...i},className:T,onClick:b,onKeyDown:x},c,j.createElement(`span`,null,s))}),L=j.forwardRef((e,t)=>{let{id:n,prefixCls:a,rootClassName:s,className:c,style:l,classNames:u,styles:m,disabled:h,options:g,value:v,defaultValue:y,onChange:b,multiple:x,...S}=e,{getPrefixCls:T,direction:E,className:D,style:O,classNames:k,styles:ee}=o(`tag`),A=T(`tag`,a),M=`${A}-checkable-group`,[N,P]=F(A,w(A)),L=C(O),R=C(l),[z,B]=r([k,u],[ee,L,m,R],{props:e}),V=(0,j.useMemo)(()=>Array.isArray(g)?g.map(e=>_(e)?e:{value:e,label:e}):[],[g]),[H,U]=i(y,v),W=(e,t)=>{let n=null;if(x){let r=H||[];n=e?[].concat(f(r),[t.value]):r.filter(e=>e!==t.value)}else n=e?t.value:null;U(n),b?.(n)},G=j.useRef(null);(0,j.useImperativeHandle)(t,()=>({nativeElement:G.current}));let K=d(S,{aria:!0,data:!0});return j.createElement(`div`,{...K,className:p(M,D,s,{[`${M}-disabled`]:h,[`${M}-rtl`]:E===`rtl`},N,P,c,z.root),style:B.root,id:n,ref:G},V.map(e=>j.createElement(I,{key:e.value,className:p(`${M}-item`,z.item,e.className),style:{...B.item,...e.style},checked:x?(H||[]).includes(e.value):H===e.value,onChange:t=>W(t,e),disabled:h},e.label)))});function R(e,t){let{color:n,variant:r,bordered:i}=e;return j.useMemo(()=>{let e=n?.endsWith(`-inverse`),a;a=r||(e?`solid`:i===!1?`filled`:t||`filled`);let o=e?n?.replace(`-inverse`,``):n;o===void 0&&a===`solid`&&(o=`default`);let s=E(o),c=D(o),l={};if(!s&&!c&&o){if(a===`solid`)l.backgroundColor=n;else{let e=new m(o).toHsl();e.l=.95,l.backgroundColor=new m(e).toHexString(),l.color=n,a===`outlined`&&(l.borderColor=n)}}return[a,o,s,c,l]},[n,r,i,t])}var z=e=>T(e,(t,{textColor:n,lightBorderColor:r,lightColor:i,darkColor:a})=>({[`${e.componentCls}${e.componentCls}-${t}:not(${e.componentCls}-disabled)`]:{[`&${e.componentCls}-outlined`]:{backgroundColor:i,borderColor:r,color:n},[`&${e.componentCls}-solid`]:{backgroundColor:a,borderColor:a,color:e.colorTextLightSolid},[`&${e.componentCls}-filled`]:{backgroundColor:i,color:n}}})),B=s([`Tag`,`preset`],e=>z(N(e)),P);function V(e){return typeof e==`string`?e.charAt(0).toUpperCase()+e.slice(1):e}var H=(e,t,n)=>{let r=V(n);return{[`${e.componentCls}${e.componentCls}-${t}:not(${e.componentCls}-disabled)`]:{[`&${e.componentCls}-outlined`]:{backgroundColor:e[`color${r}Bg`],borderColor:e[`color${r}Border`],color:e[`color${n}`]},[`&${e.componentCls}-solid`]:{backgroundColor:e[`color${n}`],borderColor:e[`color${n}`]},[`&${e.componentCls}-filled`]:{backgroundColor:e[`color${r}Bg`],color:e[`color${n}`]}}}},U=s([`Tag`,`status`],e=>{let t=N(e);return[H(t,`success`,`Success`),H(t,`processing`,`Info`),H(t,`error`,`Error`),H(t,`warning`,`Warning`)]},P),W=j.forwardRef((e,i)=>{let{prefixCls:s,className:c,rootClassName:l,style:u,children:d,icon:f,color:m,variant:g,onClose:_,bordered:y,disabled:S,href:w,target:T,styles:E,classNames:D,...A}=e,{getPrefixCls:M,direction:N,className:P,variant:I,style:L,classNames:z,styles:V}=o(`tag`),[H,W,G,K,q]=R(e,I),te=G||K,ne=j.useContext(h),J=S??ne,{tag:re}=j.useContext(n),[ie,ae]=j.useState(!0),Y=t(A,[`closeIcon`,`closable`]),oe={...e,color:W,variant:H,disabled:J},se=C(L),ce=C(u),[X,Z]=r([z,D],[V,se,E,ce],{props:oe}),le=j.useMemo(()=>{let e=Z.root;return J||(e={...q,...e}),e},[Z.root,q,J]),Q=M(`tag`,s),[ue,de]=F(Q),fe=p(Q,P,X.root,`${Q}-${H}`,{[`${Q}-${W}`]:te,[`${Q}-hidden`]:!ie,[`${Q}-rtl`]:N===`rtl`,[`${Q}-disabled`]:J},c,l,ue,de),$=e=>{J||(e.stopPropagation(),_?.(e),!e.defaultPrevented&&(w&&e.preventDefault(),ae(!1)))},pe=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.repeat||e.currentTarget.click())},[,me]=k(O(e),O(re),{closable:!1,closeIconRender:e=>{let t=j.createElement(`span`,{role:`button`,tabIndex:J?-1:0,"aria-disabled":J||void 0,className:p(`${Q}-close-icon`,X.close),onClick:$,onKeyDown:pe,style:Z.close},e);return v(e,t,e=>({onClick:t=>{e?.onClick?.(t),$(t)},onKeyDown:t=>{e?.onKeyDown?.(t),t.defaultPrevented||pe(t)},role:`button`,tabIndex:J?-1:0,"aria-disabled":J||void 0,className:p(e?.className,`${Q}-close-icon`,X.close),style:{...Z.close,...e?.style}}))}}),he=a(A.onClick)||d&&d.type===`a`,ge=x(f,{className:p(j.isValidElement(f)?f.props?.className:void 0,X.icon),style:Z.icon}),_e=ge?j.createElement(j.Fragment,null,ge,b(d)&&j.createElement(`span`,{className:X.content,style:Z.content},d)):d,ve=w?`a`:`span`,ye=j.createElement(ve,{...Y,ref:i,className:fe,style:le,href:J?void 0:w,target:T,onClick:J?void 0:Y.onClick,...w&&J?{"aria-disabled":!0}:{}},_e,me,G&&j.createElement(B,{key:`preset`,prefixCls:Q}),K&&j.createElement(U,{key:`status`,prefixCls:Q}));return he?j.createElement(ee,{component:`Tag`},ye):ye});W.CheckableTag=I,W.CheckableTagGroup=L;export{W as t}; |