4 lines
6.2 KiB
JavaScript
4 lines
6.2 KiB
JavaScript
import{aq as U,at as Y,as as R,r as s,au as Z,ao as v,bf as ee,bp as oe,cM as ne,cN as te,cO as re,b0 as se,cP as ce,b2 as ie,b1 as ae,cQ as B,cR as le,cS as de,b9 as ue,be as pe,bb as me}from"./index-BGI3tmtB.js";const S=(e,o,n,t,r)=>({background:e,border:`${R(t.lineWidth)} ${t.lineType} ${o}`,[`${r}-icon`]:{color:n}}),fe=e=>{const{componentCls:o,motionDurationSlow:n,marginXS:t,marginSM:r,fontSize:c,fontSizeLG:l,lineHeight:d,borderRadiusLG:p,motionEaseInOutCirc:u,withDescriptionIconSize:g,colorText:b,colorTextHeading:$,withDescriptionPadding:C,defaultPadding:i}=e;return{[o]:Object.assign(Object.assign({},Y(e)),{position:"relative",display:"flex",alignItems:"center",padding:i,wordWrap:"break-word",borderRadius:p,[`&${o}-rtl`]:{direction:"rtl"},[`${o}-content`]:{flex:1,minWidth:0},[`${o}-icon`]:{marginInlineEnd:t,lineHeight:0},"&-description":{display:"none",fontSize:c,lineHeight:d},"&-message":{color:$},[`&${o}-motion-leave`]:{overflow:"hidden",opacity:1,transition:`max-height ${n} ${u}, opacity ${n} ${u},
|
|
padding-top ${n} ${u}, padding-bottom ${n} ${u},
|
|
margin-bottom ${n} ${u}`},[`&${o}-motion-leave-active`]:{maxHeight:0,marginBottom:"0 !important",paddingTop:0,paddingBottom:0,opacity:0}}),[`${o}-with-description`]:{alignItems:"flex-start",padding:C,[`${o}-icon`]:{marginInlineEnd:r,fontSize:g,lineHeight:0},[`${o}-message`]:{display:"block",marginBottom:t,color:$,fontSize:l},[`${o}-description`]:{display:"block",color:b}},[`${o}-banner`]:{marginBottom:0,border:"0 !important",borderRadius:0}}},ge=e=>{const{componentCls:o,colorSuccess:n,colorSuccessBorder:t,colorSuccessBg:r,colorWarning:c,colorWarningBorder:l,colorWarningBg:d,colorError:p,colorErrorBorder:u,colorErrorBg:g,colorInfo:b,colorInfoBorder:$,colorInfoBg:C}=e;return{[o]:{"&-success":S(r,t,n,e,o),"&-info":S(C,$,b,e,o),"&-warning":S(d,l,c,e,o),"&-error":Object.assign(Object.assign({},S(g,u,p,e,o)),{[`${o}-description > pre`]:{margin:0,padding:0}})}}},be=e=>{const{componentCls:o,iconCls:n,motionDurationMid:t,marginXS:r,fontSizeIcon:c,colorIcon:l,colorIconHover:d}=e;return{[o]:{"&-action":{marginInlineStart:r},[`${o}-close-icon`]:{marginInlineStart:r,padding:0,overflow:"hidden",fontSize:c,lineHeight:R(c),backgroundColor:"transparent",border:"none",outline:"none",cursor:"pointer",[`${n}-close`]:{color:l,transition:`color ${t}`,"&:hover":{color:d}}},"&-close-text":{color:l,transition:`color ${t}`,"&:hover":{color:d}}}}},ye=e=>({withDescriptionIconSize:e.fontSizeHeading3,defaultPadding:`${e.paddingContentVerticalSM}px 12px`,withDescriptionPadding:`${e.paddingMD}px ${e.paddingContentHorizontalLG}px`}),$e=U("Alert",e=>[fe(e),ge(e),be(e)],ye);var M=function(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]]);return n};const Ce={success:ie,info:ce,error:se,warning:re},Ie=e=>{const{icon:o,prefixCls:n,type:t}=e,r=Ce[t]||null;return o?te(o,s.createElement("span",{className:`${n}-icon`},o),()=>({className:v(`${n}-icon`,o.props.className)})):s.createElement(r,{className:`${n}-icon`})},he=e=>{const{isClosable:o,prefixCls:n,closeIcon:t,handleClose:r,ariaProps:c}=e,l=t===!0||t===void 0?s.createElement(ae,null):t;return o?s.createElement("button",Object.assign({type:"button",onClick:r,className:`${n}-close-icon`,tabIndex:0},c),l):null},H=s.forwardRef((e,o)=>{const{description:n,prefixCls:t,message:r,banner:c,className:l,rootClassName:d,style:p,onMouseEnter:u,onMouseLeave:g,onClick:b,afterClose:$,showIcon:C,closable:i,closeText:h,closeIcon:y,action:x,id:z}=e,_=M(e,["description","prefixCls","message","banner","className","rootClassName","style","onMouseEnter","onMouseLeave","onClick","afterClose","showIcon","closable","closeText","closeIcon","action","id"]),[E,D]=s.useState(!1),w=s.useRef(null);s.useImperativeHandle(o,()=>({nativeElement:w.current}));const{getPrefixCls:T,direction:A,closable:f,closeIcon:N,className:L,style:k}=Z("alert"),a=T("alert",t),[W,G,V]=$e(a),X=m=>{var I;D(!0),(I=e.onClose)===null||I===void 0||I.call(e,m)},O=s.useMemo(()=>e.type!==void 0?e.type:c?"warning":"info",[e.type,c]),q=s.useMemo(()=>typeof i=="object"&&i.closeIcon||h?!0:typeof i=="boolean"?i:y!==!1&&y!==null&&y!==void 0?!0:!!f,[h,y,i,f]),P=c&&C===void 0?!0:C,F=v(a,`${a}-${O}`,{[`${a}-with-description`]:!!n,[`${a}-no-icon`]:!P,[`${a}-banner`]:!!c,[`${a}-rtl`]:A==="rtl"},L,l,d,V,G),Q=ee(_,{aria:!0,data:!0}),J=s.useMemo(()=>typeof i=="object"&&i.closeIcon?i.closeIcon:h||(y!==void 0?y:typeof f=="object"&&f.closeIcon?f.closeIcon:N),[y,i,f,h,N]),K=s.useMemo(()=>{const m=i??f;if(typeof m=="object"){const{closeIcon:I}=m;return M(m,["closeIcon"])}return{}},[i,f]);return W(s.createElement(oe,{visible:!E,motionName:`${a}-motion`,motionAppear:!1,motionEnter:!1,onLeaveStart:m=>({maxHeight:m.offsetHeight}),onLeaveEnd:$},({className:m,style:I},j)=>s.createElement("div",Object.assign({id:z,ref:ne(w,j),"data-show":!E,className:v(F,m),style:Object.assign(Object.assign(Object.assign({},k),p),I),onMouseEnter:u,onMouseLeave:g,onClick:b,role:"alert"},Q),P?s.createElement(Ie,{description:n,icon:e.icon,prefixCls:a,type:O}):null,s.createElement("div",{className:`${a}-content`},r?s.createElement("div",{className:`${a}-message`},r):null,n?s.createElement("div",{className:`${a}-description`},n):null),x?s.createElement("div",{className:`${a}-action`},x):null,s.createElement(he,{isClosable:q,prefixCls:a,closeIcon:J,handleClose:X,ariaProps:K}))))});function Se(e,o,n){return o=B(o),le(e,de()?Reflect.construct(o,n||[],B(e).constructor):o.apply(e,n))}let ve=function(e){function o(){var n;return me(this,o),n=Se(this,o,arguments),n.state={error:void 0,info:{componentStack:""}},n}return ue(o,e),pe(o,[{key:"componentDidCatch",value:function(t,r){this.setState({error:t,info:r})}},{key:"render",value:function(){const{message:t,description:r,id:c,children:l}=this.props,{error:d,info:p}=this.state,u=(p==null?void 0:p.componentStack)||null,g=typeof t>"u"?(d||"").toString():t,b=typeof r>"u"?u:r;return d?s.createElement(H,{id:c,type:"error",message:g,description:s.createElement("pre",{style:{fontSize:"0.9em",overflowX:"auto"}},b)}):l}}])}(s.Component);const xe=H;xe.ErrorBoundary=ve;export{xe as A};
|