48 lines
6.9 KiB
JavaScript
48 lines
6.9 KiB
JavaScript
import{Pt as e,Q as t,U as n,W as r,Z as i,_ as a,at as o,ct as s,f as c,jt as l,m as u,nt as d,ot as f,rt as p,xt as m,yn as h,zt as g}from"./client-Be0b5AZU.js";import{s as _}from"./ui-DePKLhY8.js";import{i as v,o as y}from"./_plugin-vue_export-helper-C_Iw6R3j.js";import{F as b,J as x,K as S,P as C,Q as w,U as T,W as E,Y as D,q as O}from"./index-DpxjEbFc.js";function k(e){let{lineHeight:n,borderRadius:r,fontWeightStrong:a,baseColor:o,dividerColor:s,actionColor:c,textColor1:l,textColor2:u,closeColorHover:d,closeColorPressed:f,closeIconColor:p,closeIconColorHover:m,closeIconColorPressed:h,infoColor:g,successColor:_,warningColor:v,errorColor:y,fontSize:x}=e;return Object.assign(Object.assign({},b),{fontSize:x,lineHeight:n,titleFontWeight:a,borderRadius:r,border:`1px solid ${s}`,color:c,titleTextColor:l,iconColor:u,contentTextColor:u,closeBorderRadius:r,closeColorHover:d,closeColorPressed:f,closeIconColor:p,closeIconColorHover:m,closeIconColorPressed:h,borderInfo:`1px solid ${t(o,i(g,{alpha:.25}))}`,colorInfo:t(o,i(g,{alpha:.08})),titleTextColorInfo:l,iconColorInfo:g,contentTextColorInfo:u,closeColorHoverInfo:d,closeColorPressedInfo:f,closeIconColorInfo:p,closeIconColorHoverInfo:m,closeIconColorPressedInfo:h,borderSuccess:`1px solid ${t(o,i(_,{alpha:.25}))}`,colorSuccess:t(o,i(_,{alpha:.08})),titleTextColorSuccess:l,iconColorSuccess:_,contentTextColorSuccess:u,closeColorHoverSuccess:d,closeColorPressedSuccess:f,closeIconColorSuccess:p,closeIconColorHoverSuccess:m,closeIconColorPressedSuccess:h,borderWarning:`1px solid ${t(o,i(v,{alpha:.33}))}`,colorWarning:t(o,i(v,{alpha:.08})),titleTextColorWarning:l,iconColorWarning:v,contentTextColorWarning:u,closeColorHoverWarning:d,closeColorPressedWarning:f,closeIconColorWarning:p,closeIconColorHoverWarning:m,closeIconColorPressedWarning:h,borderError:`1px solid ${t(o,i(y,{alpha:.25}))}`,colorError:t(o,i(y,{alpha:.08})),titleTextColorError:l,iconColorError:y,contentTextColorError:u,closeColorHoverError:d,closeColorPressedError:f,closeIconColorError:p,closeIconColorHoverError:m,closeIconColorPressedError:h})}var A={name:`Alert`,common:c,self:k},j=p(`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;
|
|
`,[o(`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;
|
|
`),f(`closable`,[p(`alert-body`,[o(`title`,`
|
|
padding-right: 24px;
|
|
`)])]),o(`icon`,{color:`var(--n-icon-color)`}),p(`alert-body`,{padding:`var(--n-padding)`},[o(`title`,{color:`var(--n-title-text-color)`}),o(`content`,{color:`var(--n-content-text-color)`})]),C({originalTransition:`transform .3s var(--n-bezier)`,enterToProps:{transform:`scale(1)`},leaveToProps:{transform:`scale(0.9)`}}),o(`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);
|
|
`),o(`close`,`
|
|
transition:
|
|
color .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier);
|
|
position: absolute;
|
|
right: 0;
|
|
top: 0;
|
|
margin: var(--n-close-margin);
|
|
`),f(`show-icon`,[p(`alert-body`,{paddingLeft:`calc(var(--n-icon-margin-left) + var(--n-icon-size) + var(--n-icon-margin-right))`})]),f(`right-adjust`,[p(`alert-body`,{paddingRight:`calc(var(--n-close-size) + var(--n-padding) + 2px)`})]),p(`alert-body`,`
|
|
border-radius: var(--n-border-radius);
|
|
transition: border-color .3s var(--n-bezier);
|
|
`,[o(`title`,`
|
|
transition: color .3s var(--n-bezier);
|
|
font-size: 16px;
|
|
line-height: 19px;
|
|
font-weight: var(--n-title-font-weight);
|
|
`,[d(`& +`,[o(`content`,{marginTop:`9px`})])]),o(`content`,{transition:`color .3s var(--n-bezier)`,fontSize:`var(--n-font-size)`})]),o(`icon`,{transition:`color .3s var(--n-bezier)`})]),M=l({name:`Alert`,inheritAttrs:!1,props:Object.assign(Object.assign({},u.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:i,inlineThemeDisabled:o,mergedRtlRef:c}=r(e),l=u(`Alert`,`-alert`,j,A,e,t),d=a(`Alert`,c,t),f=m(()=>{let{common:{cubicBezierEaseInOut:t},self:n}=l.value,{fontSize:r,borderRadius:i,titleFontWeight:a,lineHeight:o,iconSize:c,iconMargin:u,iconMarginRtl:d,closeIconSize:f,closeBorderRadius:p,closeSize:m,closeMargin:h,closeMarginRtl:g,padding:v}=n,{type:y}=e,{left:b,right:x}=_(u);return{"--n-bezier":t,"--n-color":n[s(`color`,y)],"--n-close-icon-size":f,"--n-close-border-radius":p,"--n-close-color-hover":n[s(`closeColorHover`,y)],"--n-close-color-pressed":n[s(`closeColorPressed`,y)],"--n-close-icon-color":n[s(`closeIconColor`,y)],"--n-close-icon-color-hover":n[s(`closeIconColorHover`,y)],"--n-close-icon-color-pressed":n[s(`closeIconColorPressed`,y)],"--n-icon-color":n[s(`iconColor`,y)],"--n-border":n[s(`border`,y)],"--n-title-text-color":n[s(`titleTextColor`,y)],"--n-content-text-color":n[s(`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":u,"--n-icon-margin-rtl":d,"--n-close-size":m,"--n-close-margin":h,"--n-close-margin-rtl":g,"--n-padding":v,"--n-icon-margin-left":b,"--n-icon-margin-right":x}}),p=o?n(`alert`,m(()=>e.type[0]),f,e):void 0,g=h(!0),v=()=>{let{onAfterLeave:t,onAfterHide:n}=e;t&&t(),n&&n()};return{rtlEnabled:d,mergedClsPrefix:t,mergedBordered:i,visible:g,handleCloseClick:()=>{Promise.resolve(e.onClose?.call(e)).then(e=>{e!==!1&&(g.value=!1)})},handleAfterLeave:()=>{v()},mergedTheme:l,cssVars:o?void 0:f,themeClass:p?.themeClass,onRender:p?.onRender}},render(){var t;return(t=this.onRender)==null||t.call(this),e(T,{onAfterLeave:this.handleAfterLeave},{default:()=>{let{mergedClsPrefix:t,$slots:n}=this,r={class:[`${t}-alert`,this.themeClass,this.closable&&`${t}-alert--closable`,this.showIcon&&`${t}-alert--show-icon`,!this.title&&this.closable&&`${t}-alert--right-adjust`,this.rtlEnabled&&`${t}-alert--rtl`],style:this.cssVars,role:`alert`};return this.visible?e(`div`,Object.assign({},g(this.$attrs,r)),this.closable&&e(E,{clsPrefix:t,class:`${t}-alert__close`,onClick:this.handleCloseClick}),this.bordered&&e(`div`,{class:`${t}-alert__border`}),this.showIcon&&e(`div`,{class:`${t}-alert__icon`,"aria-hidden":`true`},v(n.icon,()=>[e(w,{clsPrefix:t},{default:()=>{switch(this.type){case`success`:return e(O,null);case`info`:return e(x,null);case`warning`:return e(S,null);case`error`:return e(D,null);default:return null}}})])),e(`div`,{class:[`${t}-alert-body`,this.mergedBordered&&`${t}-alert-body--bordered`]},y(n.header,n=>{let r=n||this.title;return r?e(`div`,{class:`${t}-alert-body__title`},r):null}),n.default&&e(`div`,{class:`${t}-alert-body__content`},n))):null}})}});export{M as t}; |