2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
import{aq as G,ar as J,as as q,at as K,a_ as Y,r as n,an as F,ao as N,dq as M,ef as Z,a$ as ee,eg as oe,eh as re,ei as _,d4 as te,ej as le,cN as ne}from"./index-BGI3tmtB.js";const ae=e=>{const{paddingXXS:t,lineWidth:l,tagPaddingHorizontal:o,componentCls:r,calc:a}=e,c=a(o).sub(l).equal(),m=a(t).sub(l).equal();return{[r]:Object.assign(Object.assign({},K(e)),{display:"inline-block",height:"auto",marginInlineEnd:e.marginXS,paddingInline:c,fontSize:e.tagFontSize,lineHeight:e.tagLineHeight,whiteSpace:"nowrap",background:e.defaultBg,border:`${q(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,opacity:1,transition:`all ${e.motionDurationMid}`,textAlign:"start",position:"relative",[`&${r}-rtl`]:{direction:"rtl"},"&, a, a:hover":{color:e.defaultColor},[`${r}-close-icon`]:{marginInlineStart:m,fontSize:e.tagIconSize,color:e.colorIcon,cursor:"pointer",transition:`all ${e.motionDurationMid}`,"&:hover":{color:e.colorTextHeading}},[`&${r}-has-color`]:{borderColor:"transparent",[`&, a, a:hover, ${e.iconCls}-close, ${e.iconCls}-close:hover`]:{color:e.colorTextLightSolid}},"&-checkable":{backgroundColor:"transparent",borderColor:"transparent",cursor:"pointer",[`&:not(${r}-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}},"&-hidden":{display:"none"},[`> ${e.iconCls} + span, > span + ${e.iconCls}`]:{marginInlineStart:c}}),[`${r}-borderless`]:{borderColor:"transparent",background:e.tagBorderlessBg}}},P=e=>{const{lineWidth:t,fontSizeIcon:l,calc:o}=e,r=e.fontSizeSM;return J(e,{tagFontSize:r,tagLineHeight:q(o(e.lineHeightSM).mul(r).equal()),tagIconSize:o(l).sub(o(t).mul(2)).equal(),tagPaddingHorizontal:8,tagBorderlessBg:e.defaultBg})},j=e=>({defaultBg:new Y(e.colorFillQuaternary).onBackground(e.colorBgContainer).toHexString(),defaultColor:e.colorText}),V=G("Tag",e=>{const t=P(e);return ae(t)},j);var se=function(e,t){var l={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(l[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(l[o[r]]=e[o[r]]);return l};const ce=n.forwardRef((e,t)=>{const{prefixCls:l,style:o,className:r,checked:a,children:c,icon:m,onChange:i,onClick:u}=e,S=se(e,["prefixCls","style","className","checked","children","icon","onChange","onClick"]),{getPrefixCls:f,tag:d}=n.useContext(F),$=v=>{i==null||i(!a),u==null||u(v)},p=f("tag",l),[g,x,h]=V(p),O=N(p,`${p}-checkable`,{[`${p}-checkable-checked`]:a},d==null?void 0:d.className,r,x,h);return g(n.createElement("span",Object.assign({},S,{ref:t,style:Object.assign(Object.assign({},o),d==null?void 0:d.style),className:O,onClick:$}),m,n.createElement("span",null,c)))}),ie=e=>Z(e,(t,{textColor:l,lightBorderColor:o,lightColor:r,darkColor:a})=>({[`${e.componentCls}${e.componentCls}-${t}`]:{color:l,background:r,borderColor:o,"&-inverse":{color:e.colorTextLightSolid,background:a,borderColor:a},[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}})),de=M(["Tag","preset"],e=>{const t=P(e);return ie(t)},j);function ge(e){return typeof e!="string"?e:e.charAt(0).toUpperCase()+e.slice(1)}const y=(e,t,l)=>{const o=ge(l);return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:e[`color${l}`],background:e[`color${o}Bg`],borderColor:e[`color${o}Border`],[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}},ue=M(["Tag","status"],e=>{const t=P(e);return[y(t,"success","Success"),y(t,"processing","Info"),y(t,"error","Error"),y(t,"warning","Warning")]},j);var Ce=function(e,t){var l={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(l[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(l[o[r]]=e[o[r]]);return l};const pe=n.forwardRef((e,t)=>{const{prefixCls:l,className:o,rootClassName:r,style:a,children:c,icon:m,color:i,onClose:u,bordered:S=!0,visible:f}=e,d=Ce(e,["prefixCls","className","rootClassName","style","children","icon","color","onClose","bordered","visible"]),{getPrefixCls:$,direction:p,tag:g}=n.useContext(F),[x,h]=n.useState(!0),O=ee(d,["closeIcon","closable"]);n.useEffect(()=>{f!==void 0&&h(f)},[f]);const v=oe(i),E=le(i),T=v||E,W=Object.assign(Object.assign({backgroundColor:i&&!T?i:void 0},g==null?void 0:g.style),a),s=$("tag",l),[L,R,k]=V(s),A=N(s,g==null?void 0:g.className,{[`${s}-${i}`]:T,[`${s}-has-color`]:i&&!T,[`${s}-hidden`]:!x,[`${s}-rtl`]:p==="rtl",[`${s}-borderless`]:!S},o,r,R,k),w=b=>{b.stopPropagation(),u==null||u(b),!b.defaultPrevented&&h(!1)},[,X]=re(_(e),_(g),{closable:!1,closeIconRender:b=>{const U=n.createElement("span",{className:`${s}-close-icon`,onClick:w},b);return ne(b,U,C=>({onClick:H=>{var I;(I=C==null?void 0:C.onClick)===null||I===void 0||I.call(C,H),w(H)},className:N(C==null?void 0:C.className,`${s}-close-icon`)}))}}),D=typeof d.onClick=="function"||c&&c.type==="a",z=m||null,Q=z?n.createElement(n.Fragment,null,z,c&&n.createElement("span",null,c)):c,B=n.createElement("span",Object.assign({},O,{ref:t,className:A,style:W}),Q,X,v&&n.createElement(de,{key:"preset",prefixCls:s}),E&&n.createElement(ue,{key:"status",prefixCls:s}));return L(D?n.createElement(te,{component:"Tag"},B):B)}),be=pe;be.CheckableTag=ce;export{be as T};
|