48 lines
6.9 KiB
JavaScript
48 lines
6.9 KiB
JavaScript
import{B as e,I as t,N as n,gt as r,w as i}from"./client-D_MtAleQ.js";import{G as a,H as o,I as s,L as c,M as l,N as u,V as d,W as f,o as p,q as m,r as h,t as g}from"./light-BDkw2ied.js";import{r as _}from"./css-DEmdllcC.js";import{a as v,r as y}from"./resolve-slot-CImSyQWK.js";import{B as b,E as x,F as S,L as C,P as w,R as T,T as E,U as D,z as O}from"./index-CMbLECgJ.js";function k(e){let{lineHeight:t,borderRadius:n,fontWeightStrong:r,baseColor:i,dividerColor:a,actionColor:o,textColor1:l,textColor2:u,closeColorHover:d,closeColorPressed:f,closeIconColor:p,closeIconColorHover:m,closeIconColorPressed:h,infoColor:g,successColor:_,warningColor:v,errorColor:y,fontSize:b}=e;return Object.assign(Object.assign({},x),{fontSize:b,lineHeight:t,titleFontWeight:r,borderRadius:n,border:`1px solid ${a}`,color:o,titleTextColor:l,iconColor:u,contentTextColor:u,closeBorderRadius:n,closeColorHover:d,closeColorPressed:f,closeIconColor:p,closeIconColorHover:m,closeIconColorPressed:h,borderInfo:`1px solid ${c(i,s(g,{alpha:.25}))}`,colorInfo:c(i,s(g,{alpha:.08})),titleTextColorInfo:l,iconColorInfo:g,contentTextColorInfo:u,closeColorHoverInfo:d,closeColorPressedInfo:f,closeIconColorInfo:p,closeIconColorHoverInfo:m,closeIconColorPressedInfo:h,borderSuccess:`1px solid ${c(i,s(_,{alpha:.25}))}`,colorSuccess:c(i,s(_,{alpha:.08})),titleTextColorSuccess:l,iconColorSuccess:_,contentTextColorSuccess:u,closeColorHoverSuccess:d,closeColorPressedSuccess:f,closeIconColorSuccess:p,closeIconColorHoverSuccess:m,closeIconColorPressedSuccess:h,borderWarning:`1px solid ${c(i,s(v,{alpha:.33}))}`,colorWarning:c(i,s(v,{alpha:.08})),titleTextColorWarning:l,iconColorWarning:v,contentTextColorWarning:u,closeColorHoverWarning:d,closeColorPressedWarning:f,closeIconColorWarning:p,closeIconColorHoverWarning:m,closeIconColorPressedWarning:h,borderError:`1px solid ${c(i,s(y,{alpha:.25}))}`,colorError:c(i,s(y,{alpha:.08})),titleTextColorError:l,iconColorError:y,contentTextColorError:u,closeColorHoverError:d,closeColorPressedError:f,closeIconColorError:p,closeIconColorHoverError:m,closeIconColorPressedError:h})}var A={name:`Alert`,common:g,self:k},j=o(`alert`,`
|
|
line-height: var(--n-line-height);
|
|
border-radius: var(--n-border-radius);
|
|
position: relative;
|
|
transition: background-color .3s var(--n-bezier);
|
|
background-color: var(--n-color);
|
|
text-align: start;
|
|
word-break: break-word;
|
|
`,[f(`border`,`
|
|
border-radius: inherit;
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
transition: border-color .3s var(--n-bezier);
|
|
border: var(--n-border);
|
|
pointer-events: none;
|
|
`),a(`closable`,[o(`alert-body`,[f(`title`,`
|
|
padding-right: 24px;
|
|
`)])]),f(`icon`,{color:`var(--n-icon-color)`}),o(`alert-body`,{padding:`var(--n-padding)`},[f(`title`,{color:`var(--n-title-text-color)`}),f(`content`,{color:`var(--n-content-text-color)`})]),E({originalTransition:`transform .3s var(--n-bezier)`,enterToProps:{transform:`scale(1)`},leaveToProps:{transform:`scale(0.9)`}}),f(`icon`,`
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
align-items: center;
|
|
justify-content: center;
|
|
display: flex;
|
|
width: var(--n-icon-size);
|
|
height: var(--n-icon-size);
|
|
font-size: var(--n-icon-size);
|
|
margin: var(--n-icon-margin);
|
|
`),f(`close`,`
|
|
transition:
|
|
color .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier);
|
|
position: absolute;
|
|
right: 0;
|
|
top: 0;
|
|
margin: var(--n-close-margin);
|
|
`),a(`show-icon`,[o(`alert-body`,{paddingLeft:`calc(var(--n-icon-margin-left) + var(--n-icon-size) + var(--n-icon-margin-right))`})]),a(`right-adjust`,[o(`alert-body`,{paddingRight:`calc(var(--n-close-size) + var(--n-padding) + 2px)`})]),o(`alert-body`,`
|
|
border-radius: var(--n-border-radius);
|
|
transition: border-color .3s var(--n-bezier);
|
|
`,[f(`title`,`
|
|
transition: color .3s var(--n-bezier);
|
|
font-size: 16px;
|
|
line-height: 19px;
|
|
font-weight: var(--n-title-font-weight);
|
|
`,[d(`& +`,[f(`content`,{marginTop:`9px`})])]),f(`content`,{transition:`color .3s var(--n-bezier)`,fontSize:`var(--n-font-size)`})]),f(`icon`,{transition:`color .3s var(--n-bezier)`})]),M=n({name:`Alert`,inheritAttrs:!1,props:Object.assign(Object.assign({},h.props),{title:String,showIcon:{type:Boolean,default:!0},type:{type:String,default:`default`},bordered:{type:Boolean,default:!0},closable:Boolean,onClose:Function,onAfterLeave:Function,onAfterHide:Function}),slots:Object,setup(e){let{mergedClsPrefixRef:t,mergedBorderedRef:n,inlineThemeDisabled:a,mergedRtlRef:o}=u(e),s=h(`Alert`,`-alert`,j,A,e,t),c=p(`Alert`,o,t),d=i(()=>{let{common:{cubicBezierEaseInOut:t},self:n}=s.value,{fontSize:r,borderRadius:i,titleFontWeight:a,lineHeight:o,iconSize:c,iconMargin:l,iconMarginRtl:u,closeIconSize:d,closeBorderRadius:f,closeSize:p,closeMargin:h,closeMarginRtl:g,padding:v}=n,{type:y}=e,{left:b,right:x}=_(l);return{"--n-bezier":t,"--n-color":n[m(`color`,y)],"--n-close-icon-size":d,"--n-close-border-radius":f,"--n-close-color-hover":n[m(`closeColorHover`,y)],"--n-close-color-pressed":n[m(`closeColorPressed`,y)],"--n-close-icon-color":n[m(`closeIconColor`,y)],"--n-close-icon-color-hover":n[m(`closeIconColorHover`,y)],"--n-close-icon-color-pressed":n[m(`closeIconColorPressed`,y)],"--n-icon-color":n[m(`iconColor`,y)],"--n-border":n[m(`border`,y)],"--n-title-text-color":n[m(`titleTextColor`,y)],"--n-content-text-color":n[m(`contentTextColor`,y)],"--n-line-height":o,"--n-border-radius":i,"--n-font-size":r,"--n-title-font-weight":a,"--n-icon-size":c,"--n-icon-margin":l,"--n-icon-margin-rtl":u,"--n-close-size":p,"--n-close-margin":h,"--n-close-margin-rtl":g,"--n-padding":v,"--n-icon-margin-left":b,"--n-icon-margin-right":x}}),f=a?l(`alert`,i(()=>e.type[0]),d,e):void 0,g=r(!0),v=()=>{let{onAfterLeave:t,onAfterHide:n}=e;t&&t(),n&&n()};return{rtlEnabled:c,mergedClsPrefix:t,mergedBordered:n,visible:g,handleCloseClick:()=>{Promise.resolve(e.onClose?.call(e)).then(e=>{e!==!1&&(g.value=!1)})},handleAfterLeave:()=>{v()},mergedTheme:s,cssVars:a?void 0:d,themeClass:f?.themeClass,onRender:f?.onRender}},render(){var n;return(n=this.onRender)==null||n.call(this),t(w,{onAfterLeave:this.handleAfterLeave},{default:()=>{let{mergedClsPrefix:n,$slots:r}=this,i={class:[`${n}-alert`,this.themeClass,this.closable&&`${n}-alert--closable`,this.showIcon&&`${n}-alert--show-icon`,!this.title&&this.closable&&`${n}-alert--right-adjust`,this.rtlEnabled&&`${n}-alert--rtl`],style:this.cssVars,role:`alert`};return this.visible?t(`div`,Object.assign({},e(this.$attrs,i)),this.closable&&t(S,{clsPrefix:n,class:`${n}-alert__close`,onClick:this.handleCloseClick}),this.bordered&&t(`div`,{class:`${n}-alert__border`}),this.showIcon&&t(`div`,{class:`${n}-alert__icon`,"aria-hidden":`true`},y(r.icon,()=>[t(D,{clsPrefix:n},{default:()=>{switch(this.type){case`success`:return t(T,null);case`info`:return t(O,null);case`warning`:return t(C,null);case`error`:return t(b,null);default:return null}}})])),t(`div`,{class:[`${n}-alert-body`,this.mergedBordered&&`${n}-alert-body--bordered`]},v(r.header,e=>{let r=e||this.title;return r?t(`div`,{class:`${n}-alert-body__title`},r):null}),r.default&&t(`div`,{class:`${n}-alert-body__content`},r))):null}})}});export{M as t}; |