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

1 line
8.3 KiB
JavaScript

import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{Bn as t,Ct as n,Dr as r,Et as i,Gt as a,Ln as o,P as s,Pn as c,St as l,Vn as u,Wt as d,Xn as f,Zn as p,Zt as m,at as h,lt as g,mn as _,st as v,xn as y,xt as b,yr as x,yt as S,zn as C}from"./jsx-runtime-ADHq9IcL.js";import{S as w,n as T,r as E}from"./tooltip-CRuv8UNz.js";import{n as D,r as O}from"./useClosable-CCgKioKg.js";import{i as k,n as A}from"./ColorPresets-wH0crouI.js";var j=e(r()),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]:{...m(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`},[`> ${e.iconCls} + span, > span + ${e.iconCls}`]:{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 y(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 s(e.colorBgSolid),`#fff`)?`#000`:`#fff`;return{defaultBg:new _(e.colorFillTertiary).onBackground(e.colorBgContainer).toHexString(),defaultColor:e.colorText,solidTextColor:t}},F=d(`Tag`,e=>M(N(e)),P),I=j.forwardRef((e,t)=>{let{prefixCls:n,style:r,className:i,checked:a,children:s,icon:c,onChange:l,onClick:d,onKeyDown:f,disabled:p,...m}=e,{getPrefixCls:g,tag:_}=j.useContext(o),v=j.useContext(h),y=p??v,b=e=>{y||(l?.(!a),d?.(e))},x=e=>{f?.(e),!(e.defaultPrevented||y)&&e.key===` `&&(e.preventDefault(),l?.(!a))},S=g(`tag`,n),[C,w]=F(S),T=u(S,`${S}-checkable`,{[`${S}-checkable-checked`]:a,[`${S}-checkable-disabled`]:y},_?.className,i,C,w);return j.createElement(`span`,{...m,ref:t,role:`checkbox`,"aria-checked":a,"aria-disabled":y||void 0,tabIndex:y?-1:0,style:{...r,..._?.style},className:T,onClick:b,onKeyDown:x},c,j.createElement(`span`,null,s))}),L=j.forwardRef((e,n)=>{let{id:r,prefixCls:a,rootClassName:o,className:s,style:c,classNames:d,styles:p,disabled:m,options:h,value:g,defaultValue:_,onChange:v,multiple:y,...w}=e,{getPrefixCls:T,direction:E,className:D,style:O,classNames:k,styles:A}=C(`tag`),M=T(`tag`,a),N=`${M}-checkable-group`,[P,L]=F(M,S(M)),R=l(O),z=l(c),[B,V]=b([k,d],[A,R,p,z],{props:e}),H=(0,j.useMemo)(()=>Array.isArray(h)?h.map(e=>i(e)?e:{value:e,label:e}):[],[h]),[U,W]=x(_,g),G=(e,n)=>{let r=null;if(y){let i=U||[];r=e?[].concat(t(i),[n.value]):i.filter(e=>e!==n.value)}else r=e?n.value:null;W(r),v?.(r)},K=j.useRef(null);(0,j.useImperativeHandle)(n,()=>({nativeElement:K.current}));let q=f(w,{aria:!0,data:!0});return j.createElement(`div`,{...q,className:u(N,D,o,{[`${N}-disabled`]:m,[`${N}-rtl`]:E===`rtl`},P,L,s,B.root),style:V.root,id:r,ref:K},H.map(e=>j.createElement(I,{key:e.value,className:u(`${N}-item`,B.item,e.className),style:{...V.item,...e.style},checked:y?(U||[]).includes(e.value):U===e.value,onChange:t=>G(t,e),disabled:m},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=T(o),c=E(o),l={};if(!s&&!c&&o)if(a===`solid`)l.backgroundColor=n;else{let e=new _(o).toHsl();e.l=.95,l.backgroundColor=new _(e).toHexString(),l.color=n,a===`outlined`&&(l.borderColor=n)}return[a,o,s,c,l]},[n,r,i,t])}var z=e=>w(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=a([`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=a([`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,t)=>{let{prefixCls:r,className:i,rootClassName:a,style:s,children:c,icon:l,color:d,variant:f,onClose:m,bordered:_,disabled:y,href:x,target:S,styles:w,classNames:T,...E}=e,{getPrefixCls:A,direction:M,className:N,variant:P,style:I,classNames:L,styles:z}=C(`tag`),[V,H,W,G,K]=R(e,P),q=W||G,ee=j.useContext(h),J=y??ee,{tag:te}=j.useContext(o),[ne,re]=j.useState(!0),Y=p(E,[`closeIcon`,`closable`]),ie={...e,color:H,variant:V,disabled:J},[X,Z]=b([L,T],[z,w],{props:ie}),ae=j.useMemo(()=>{let e={...Z.root,...I,...s};return J||(e={...K,...e}),e},[Z.root,I,s,K,J]),Q=A(`tag`,r),[oe,se]=F(Q),ce=u(Q,N,X.root,`${Q}-${V}`,{[`${Q}-${H}`]:q,[`${Q}-hidden`]:!ne,[`${Q}-rtl`]:M===`rtl`,[`${Q}-disabled`]:J},i,a,oe,se),$=e=>{J||(e.stopPropagation(),m?.(e),!e.defaultPrevented&&re(!1))},le=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.currentTarget.click())},[,ue]=O(D(e),D(te),{closable:!1,closeIconRender:e=>g(e,j.createElement(`span`,{role:`button`,tabIndex:J?-1:0,"aria-disabled":J||void 0,className:u(`${Q}-close-icon`,X.close),onClick:$,onKeyDown:le,style:Z.close},e),e=>({onClick:t=>{e?.onClick?.(t),$(t)},onKeyDown:t=>{e?.onKeyDown?.(t),t.defaultPrevented||le(t)},role:`button`,tabIndex:J?-1:0,"aria-disabled":J||void 0,className:u(e?.className,`${Q}-close-icon`,X.close),style:{...Z.close,...e?.style}}))}),de=n(E.onClick)||c&&c.type===`a`,fe=v(l,{className:u(j.isValidElement(l)?l.props?.className:void 0,X.icon),style:Z.icon}),pe=fe?j.createElement(j.Fragment,null,fe,c&&j.createElement(`span`,{className:X.content,style:Z.content},c)):c,me=x?`a`:`span`,he=j.createElement(me,{...Y,ref:t,className:ce,style:ae,href:J?void 0:x,target:S,onClick:J?void 0:Y.onClick,...x&&J?{"aria-disabled":!0}:{}},pe,ue,W&&j.createElement(B,{key:`preset`,prefixCls:Q}),G&&j.createElement(U,{key:`status`,prefixCls:Q}));return de?j.createElement(k,{component:`Tag`},he):he});W.CheckableTag=I,W.CheckableTagGroup=L;export{W as t};