1 line
18 KiB
JavaScript
1 line
18 KiB
JavaScript
import{a8 as T,x as pt,B as ht,o as i,_ as u,H as j,F as y,c as h,w as I,ao as P,aK as A,a5 as N,I as G,aI as b,Z as S,$ as C,M as D,aS as gt,bp as _t,r as vt,b7 as Tt,aH as $,a6 as bt,ad as yt,aj as Vt,ap as Ct,b9 as Bt}from"./@vue.861e8bf0.js";var xt=Object.defineProperty,Y=Object.getOwnPropertySymbols,Ot=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,H=(t,e,a)=>e in t?xt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,W=(t,e)=>{for(var a in e||(e={}))Ot.call(e,a)&&H(t,a,e[a]);if(Y)for(var a of Y(e))It.call(e,a)&&H(t,a,e[a]);return t},w=t=>typeof t=="function",R=t=>typeof t=="string",q=t=>R(t)&&t.trim().length>0,wt=t=>typeof t=="number",v=t=>typeof t=="undefined",V=t=>typeof t=="object"&&t!==null,Rt=t=>d(t,"tag")&&q(t.tag),Z=t=>window.TouchEvent&&t instanceof TouchEvent,K=t=>d(t,"component")&&J(t.component),St=t=>w(t)||V(t),J=t=>!v(t)&&(R(t)||St(t)||K(t)),F=t=>V(t)&&["height","width","right","left","top","bottom"].every(e=>wt(t[e])),d=(t,e)=>(V(t)||w(t))&&e in t,Et=(t=>()=>t++)(0);function E(t){return Z(t)?t.targetTouches[0].clientX:t.clientX}function z(t){return Z(t)?t.targetTouches[0].clientY:t.clientY}var Dt=t=>{v(t.remove)?t.parentNode&&t.parentNode.removeChild(t):t.remove()},B=t=>K(t)?B(t.component):Rt(t)?T({render(){return t}}):typeof t=="string"?t:pt(ht(t)),kt=t=>{if(typeof t=="string")return t;const e=d(t,"props")&&V(t.props)?t.props:{},a=d(t,"listeners")&&V(t.listeners)?t.listeners:{};return{component:B(t),props:e,listeners:a}},Lt=()=>typeof window!="undefined",M=class{constructor(){this.allHandlers={}}getHandlers(t){return this.allHandlers[t]||[]}on(t,e){const a=this.getHandlers(t);a.push(e),this.allHandlers[t]=a}off(t,e){const a=this.getHandlers(t);a.splice(a.indexOf(e)>>>0,1)}emit(t,e){this.getHandlers(t).forEach(n=>n(e))}},Pt=t=>["on","off","emit"].every(e=>d(t,e)&&w(t[e])),r;(function(t){t.SUCCESS="success",t.ERROR="error",t.WARNING="warning",t.INFO="info",t.DEFAULT="default"})(r||(r={}));var O;(function(t){t.TOP_LEFT="top-left",t.TOP_CENTER="top-center",t.TOP_RIGHT="top-right",t.BOTTOM_LEFT="bottom-left",t.BOTTOM_CENTER="bottom-center",t.BOTTOM_RIGHT="bottom-right"})(O||(O={}));var c;(function(t){t.ADD="add",t.DISMISS="dismiss",t.UPDATE="update",t.CLEAR="clear",t.UPDATE_DEFAULTS="update_defaults"})(c||(c={}));var f="Vue-Toastification",l={type:{type:String,default:r.DEFAULT},classNames:{type:[String,Array],default:()=>[]},trueBoolean:{type:Boolean,default:!0}},Q={type:l.type,customIcon:{type:[String,Boolean,Object,Function],default:!0}},x={component:{type:[String,Object,Function,Boolean],default:"button"},classNames:l.classNames,showOnHover:{type:Boolean,default:!1},ariaLabel:{type:String,default:"close"}},k={timeout:{type:[Number,Boolean],default:5e3},hideProgressBar:{type:Boolean,default:!1},isRunning:{type:Boolean,default:!1}},tt={transition:{type:[Object,String],default:`${f}__bounce`}},At={position:{type:String,default:O.TOP_RIGHT},draggable:l.trueBoolean,draggablePercent:{type:Number,default:.6},pauseOnFocusLoss:l.trueBoolean,pauseOnHover:l.trueBoolean,closeOnClick:l.trueBoolean,timeout:k.timeout,hideProgressBar:k.hideProgressBar,toastClassName:l.classNames,bodyClassName:l.classNames,icon:Q.customIcon,closeButton:x.component,closeButtonClassName:x.classNames,showCloseButtonOnHover:x.showOnHover,accessibility:{type:Object,default:()=>({toastRole:"alert",closeButtonLabel:"close"})},rtl:{type:Boolean,default:!1},eventBus:{type:Object,required:!1,default:()=>new M}},Nt={id:{type:[String,Number],required:!0,default:0},type:l.type,content:{type:[String,Object,Function],required:!0,default:""},onClick:{type:Function,default:void 0},onClose:{type:Function,default:void 0}},Mt={container:{type:[Object,Function],default:()=>document.body},newestOnTop:l.trueBoolean,maxToasts:{type:Number,default:20},transition:tt.transition,toastDefaults:Object,filterBeforeCreate:{type:Function,default:t=>t},filterToasts:{type:Function,default:t=>t},containerClassName:l.classNames,onMounted:Function,shareAppContext:[Boolean,Object]},m={CORE_TOAST:At,TOAST:Nt,CONTAINER:Mt,PROGRESS_BAR:k,ICON:Q,TRANSITION:tt,CLOSE_BUTTON:x},et=T({name:"VtProgressBar",props:m.PROGRESS_BAR,data(){return{hasClass:!0}},computed:{style(){return{animationDuration:`${this.timeout}ms`,animationPlayState:this.isRunning?"running":"paused",opacity:this.hideProgressBar?0:1}},cpClass(){return this.hasClass?`${f}__progress-bar`:""}},watch:{timeout(){this.hasClass=!1,this.$nextTick(()=>this.hasClass=!0)}},mounted(){this.$el.addEventListener("animationend",this.animationEnded)},beforeUnmount(){this.$el.removeEventListener("animationend",this.animationEnded)},methods:{animationEnded(){this.$emit("close-toast")}}});function $t(t,e){return i(),u("div",{style:j(t.style),class:y(t.cpClass)},null,6)}et.render=$t;var Yt=et,at=T({name:"VtCloseButton",props:m.CLOSE_BUTTON,computed:{buttonComponent(){return this.component!==!1?B(this.component):"button"},classes(){const t=[`${f}__close-button`];return this.showOnHover&&t.push("show-on-hover"),t.concat(this.classNames)}}}),Ht=N(" \xD7 ");function Ft(t,e){return i(),h(A(t.buttonComponent),P({"aria-label":t.ariaLabel,class:t.classes},t.$attrs),{default:I(()=>[Ht]),_:1},16,["aria-label","class"])}at.render=Ft;var zt=at,ot={},Ut={"aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"check-circle",class:"svg-inline--fa fa-check-circle fa-w-16",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},Xt=C("path",{fill:"currentColor",d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"},null,-1),jt=[Xt];function Gt(t,e){return i(),u("svg",Ut,jt)}ot.render=Gt;var Wt=ot,nt={},qt={"aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"info-circle",class:"svg-inline--fa fa-info-circle fa-w-16",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},Zt=C("path",{fill:"currentColor",d:"M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"},null,-1),Kt=[Zt];function Jt(t,e){return i(),u("svg",qt,Kt)}nt.render=Jt;var U=nt,it={},Qt={"aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"exclamation-circle",class:"svg-inline--fa fa-exclamation-circle fa-w-16",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},te=C("path",{fill:"currentColor",d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},null,-1),ee=[te];function ae(t,e){return i(),u("svg",Qt,ee)}it.render=ae;var oe=it,st={},ne={"aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"exclamation-triangle",class:"svg-inline--fa fa-exclamation-triangle fa-w-18",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512"},ie=C("path",{fill:"currentColor",d:"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},null,-1),se=[ie];function re(t,e){return i(),u("svg",ne,se)}st.render=re;var ce=st,rt=T({name:"VtIcon",props:m.ICON,computed:{customIconChildren(){return d(this.customIcon,"iconChildren")?this.trimValue(this.customIcon.iconChildren):""},customIconClass(){return R(this.customIcon)?this.trimValue(this.customIcon):d(this.customIcon,"iconClass")?this.trimValue(this.customIcon.iconClass):""},customIconTag(){return d(this.customIcon,"iconTag")?this.trimValue(this.customIcon.iconTag,"i"):"i"},hasCustomIcon(){return this.customIconClass.length>0},component(){return this.hasCustomIcon?this.customIconTag:J(this.customIcon)?B(this.customIcon):this.iconTypeComponent},iconTypeComponent(){return{[r.DEFAULT]:U,[r.INFO]:U,[r.SUCCESS]:Wt,[r.ERROR]:ce,[r.WARNING]:oe}[this.type]},iconClasses(){const t=[`${f}__icon`];return this.hasCustomIcon?t.concat(this.customIconClass):t}},methods:{trimValue(t,e=""){return q(t)?t.trim():e}}});function le(t,e){return i(),h(A(t.component),{class:y(t.iconClasses)},{default:I(()=>[N(G(t.customIconChildren),1)]),_:1},8,["class"])}rt.render=le;var ue=rt,ct=T({name:"VtToast",components:{ProgressBar:Yt,CloseButton:zt,Icon:ue},inheritAttrs:!1,props:Object.assign({},m.CORE_TOAST,m.TOAST),data(){return{isRunning:!0,disableTransitions:!1,beingDragged:!1,dragStart:0,dragPos:{x:0,y:0},dragRect:{}}},computed:{classes(){const t=[`${f}__toast`,`${f}__toast--${this.type}`,`${this.position}`].concat(this.toastClassName);return this.disableTransitions&&t.push("disable-transition"),this.rtl&&t.push(`${f}__toast--rtl`),t},bodyClasses(){return[`${f}__toast-${R(this.content)?"body":"component-body"}`].concat(this.bodyClassName)},draggableStyle(){return this.dragStart===this.dragPos.x?{}:this.beingDragged?{transform:`translateX(${this.dragDelta}px)`,opacity:1-Math.abs(this.dragDelta/this.removalDistance)}:{transition:"transform 0.2s, opacity 0.2s",transform:"translateX(0)",opacity:1}},dragDelta(){return this.beingDragged?this.dragPos.x-this.dragStart:0},removalDistance(){return F(this.dragRect)?(this.dragRect.right-this.dragRect.left)*this.draggablePercent:0}},mounted(){this.draggable&&this.draggableSetup(),this.pauseOnFocusLoss&&this.focusSetup()},beforeUnmount(){this.draggable&&this.draggableCleanup(),this.pauseOnFocusLoss&&this.focusCleanup()},methods:{hasProp:d,getVueComponentFromObj:B,closeToast(){this.eventBus.emit(c.DISMISS,this.id)},clickHandler(){this.onClick&&this.onClick(this.closeToast),this.closeOnClick&&(!this.beingDragged||this.dragStart===this.dragPos.x)&&this.closeToast()},timeoutHandler(){this.closeToast()},hoverPause(){this.pauseOnHover&&(this.isRunning=!1)},hoverPlay(){this.pauseOnHover&&(this.isRunning=!0)},focusPause(){this.isRunning=!1},focusPlay(){this.isRunning=!0},focusSetup(){addEventListener("blur",this.focusPause),addEventListener("focus",this.focusPlay)},focusCleanup(){removeEventListener("blur",this.focusPause),removeEventListener("focus",this.focusPlay)},draggableSetup(){const t=this.$el;t.addEventListener("touchstart",this.onDragStart,{passive:!0}),t.addEventListener("mousedown",this.onDragStart),addEventListener("touchmove",this.onDragMove,{passive:!1}),addEventListener("mousemove",this.onDragMove),addEventListener("touchend",this.onDragEnd),addEventListener("mouseup",this.onDragEnd)},draggableCleanup(){const t=this.$el;t.removeEventListener("touchstart",this.onDragStart),t.removeEventListener("mousedown",this.onDragStart),removeEventListener("touchmove",this.onDragMove),removeEventListener("mousemove",this.onDragMove),removeEventListener("touchend",this.onDragEnd),removeEventListener("mouseup",this.onDragEnd)},onDragStart(t){this.beingDragged=!0,this.dragPos={x:E(t),y:z(t)},this.dragStart=E(t),this.dragRect=this.$el.getBoundingClientRect()},onDragMove(t){this.beingDragged&&(t.preventDefault(),this.isRunning&&(this.isRunning=!1),this.dragPos={x:E(t),y:z(t)})},onDragEnd(){this.beingDragged&&(Math.abs(this.dragDelta)>=this.removalDistance?(this.disableTransitions=!0,this.$nextTick(()=>this.closeToast())):setTimeout(()=>{this.beingDragged=!1,F(this.dragRect)&&this.pauseOnHover&&this.dragRect.bottom>=this.dragPos.y&&this.dragPos.y>=this.dragRect.top&&this.dragRect.left<=this.dragPos.x&&this.dragPos.x<=this.dragRect.right?this.isRunning=!1:this.isRunning=!0}))}}}),fe=["role"];function de(t,e){const a=b("Icon"),n=b("CloseButton"),g=b("ProgressBar");return i(),u("div",{class:y(t.classes),style:j(t.draggableStyle),onClick:e[0]||(e[0]=(...o)=>t.clickHandler&&t.clickHandler(...o)),onMouseenter:e[1]||(e[1]=(...o)=>t.hoverPause&&t.hoverPause(...o)),onMouseleave:e[2]||(e[2]=(...o)=>t.hoverPlay&&t.hoverPlay(...o))},[t.icon?(i(),h(a,{key:0,"custom-icon":t.icon,type:t.type},null,8,["custom-icon","type"])):S("v-if",!0),C("div",{role:t.accessibility.toastRole||"alert",class:y(t.bodyClasses)},[typeof t.content=="string"?(i(),u(D,{key:0},[N(G(t.content),1)],2112)):(i(),h(A(t.getVueComponentFromObj(t.content)),P({key:1,"toast-id":t.id},t.hasProp(t.content,"props")?t.content.props:{},gt(t.hasProp(t.content,"listeners")?t.content.listeners:{}),{onCloseToast:t.closeToast}),null,16,["toast-id","onCloseToast"]))],10,fe),t.closeButton?(i(),h(n,{key:1,component:t.closeButton,"class-names":t.closeButtonClassName,"show-on-hover":t.showCloseButtonOnHover,"aria-label":t.accessibility.closeButtonLabel,onClick:_t(t.closeToast,["stop"])},null,8,["component","class-names","show-on-hover","aria-label","onClick"])):S("v-if",!0),t.timeout?(i(),h(g,{key:2,"is-running":t.isRunning,"hide-progress-bar":t.hideProgressBar,timeout:t.timeout,onCloseToast:t.timeoutHandler},null,8,["is-running","hide-progress-bar","timeout","onCloseToast"])):S("v-if",!0)],38)}ct.render=de;var me=ct,lt=T({name:"VtTransition",props:m.TRANSITION,emits:["leave"],methods:{hasProp:d,leave(t){t instanceof HTMLElement&&(t.style.left=t.offsetLeft+"px",t.style.top=t.offsetTop+"px",t.style.width=getComputedStyle(t).width,t.style.position="absolute")}}});function pe(t,e){return i(),h(Tt,{tag:"div","enter-active-class":t.transition.enter?t.transition.enter:`${t.transition}-enter-active`,"move-class":t.transition.move?t.transition.move:`${t.transition}-move`,"leave-active-class":t.transition.leave?t.transition.leave:`${t.transition}-leave-active`,onLeave:t.leave},{default:I(()=>[vt(t.$slots,"default")]),_:3},8,["enter-active-class","move-class","leave-active-class","onLeave"])}lt.render=pe;var he=lt,ut=T({name:"VueToastification",devtools:{hide:!0},components:{Toast:me,VtTransition:he},props:Object.assign({},m.CORE_TOAST,m.CONTAINER,m.TRANSITION),data(){return{count:0,positions:Object.values(O),toasts:{},defaults:{}}},computed:{toastArray(){return Object.values(this.toasts)},filteredToasts(){return this.defaults.filterToasts(this.toastArray)}},beforeMount(){const t=this.eventBus;t.on(c.ADD,this.addToast),t.on(c.CLEAR,this.clearToasts),t.on(c.DISMISS,this.dismissToast),t.on(c.UPDATE,this.updateToast),t.on(c.UPDATE_DEFAULTS,this.updateDefaults),this.defaults=this.$props},mounted(){this.setup(this.container)},methods:{async setup(t){w(t)&&(t=await t()),Dt(this.$el),t.appendChild(this.$el)},setToast(t){v(t.id)||(this.toasts[t.id]=t)},addToast(t){t.content=kt(t.content);const e=Object.assign({},this.defaults,t.type&&this.defaults.toastDefaults&&this.defaults.toastDefaults[t.type],t),a=this.defaults.filterBeforeCreate(e,this.toastArray);a&&this.setToast(a)},dismissToast(t){const e=this.toasts[t];!v(e)&&!v(e.onClose)&&e.onClose(),delete this.toasts[t]},clearToasts(){Object.keys(this.toasts).forEach(t=>{this.dismissToast(t)})},getPositionToasts(t){const e=this.filteredToasts.filter(a=>a.position===t).slice(0,this.defaults.maxToasts);return this.defaults.newestOnTop?e.reverse():e},updateDefaults(t){v(t.container)||this.setup(t.container),this.defaults=Object.assign({},this.defaults,t)},updateToast({id:t,options:e,create:a}){this.toasts[t]?(e.timeout&&e.timeout===this.toasts[t].timeout&&e.timeout++,this.setToast(Object.assign({},this.toasts[t],e))):a&&this.addToast(Object.assign({},{id:t},e))},getClasses(t){return[`${f}__container`,t].concat(this.defaults.containerClassName)}}});function ge(t,e){const a=b("Toast"),n=b("VtTransition");return i(),u("div",null,[(i(!0),u(D,null,$(t.positions,g=>(i(),u("div",{key:g},[bt(n,{transition:t.defaults.transition,class:y(t.getClasses(g))},{default:I(()=>[(i(!0),u(D,null,$(t.getPositionToasts(g),o=>(i(),h(a,P({key:o.id},o),null,16))),128))]),_:2},1032,["transition","class"])]))),128))])}ut.render=ge;var _e=ut,X=(t={},e=!0)=>{const a=t.eventBus=t.eventBus||new M;e&&Ct(()=>{const o=Bt(_e,W({},t)),s=o.mount(document.createElement("div")),_=t.onMounted;if(v(_)||_(s,o),t.shareAppContext){const p=t.shareAppContext;p===!0?console.warn(`[${f}] App to share context with was not provided.`):(o._context.components=p._context.components,o._context.directives=p._context.directives,o._context.mixins=p._context.mixins,o._context.provides=p._context.provides,o.config.globalProperties=p.config.globalProperties)}});const n=(o,s)=>{const _=Object.assign({},{id:Et(),type:r.DEFAULT},s,{content:o});return a.emit(c.ADD,_),_.id};n.clear=()=>a.emit(c.CLEAR,void 0),n.updateDefaults=o=>{a.emit(c.UPDATE_DEFAULTS,o)},n.dismiss=o=>{a.emit(c.DISMISS,o)};function g(o,{content:s,options:_},p=!1){const mt=Object.assign({},_,{content:s});a.emit(c.UPDATE,{id:o,options:mt,create:p})}return n.update=g,n.success=(o,s)=>n(o,Object.assign({},s,{type:r.SUCCESS})),n.info=(o,s)=>n(o,Object.assign({},s,{type:r.INFO})),n.error=(o,s)=>n(o,Object.assign({},s,{type:r.ERROR})),n.warning=(o,s)=>n(o,Object.assign({},s,{type:r.WARNING})),n},ve=()=>{const t=()=>console.warn(`[${f}] This plugin does not support SSR!`);return new Proxy(t,{get(){return t}})};function L(t){return Lt()?Pt(t)?X({eventBus:t},!1):X(t,!0):ve()}var ft=Symbol("VueToastification"),dt=new M,Te=(t,e)=>{(e==null?void 0:e.shareAppContext)===!0&&(e.shareAppContext=t);const a=L(W({eventBus:dt},e));t.provide(ft,a)},ye=t=>{if(t)return L(t);const e=yt()?Vt(ft,void 0):void 0;return e||L(dt)},Ve=Te;export{Ve as s,ye as u};
|