Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mosha-vue-toastify

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mosha-vue-toastify - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

dist/hooks/useSwipe.d.ts

2

dist/hooks/useTransitionType.d.ts
import { Position, TransitionType } from '../types';
declare const useTransitionType: (position: Position, transition: TransitionType) => {
declare const useTransitionType: (position: Position, transition: TransitionType, swiped: any) => {
transitionType: import("vue").ComputedRef<string>;
};
export default useTransitionType;

@@ -1,1 +0,1 @@

var t=Object.assign;import{ref as e,onMounted as o,onUnmounted as n,computed as s,defineComponent as i,openBlock as l,createBlock as r,createVNode as a,watchEffect as p,resolveComponent as c,Transition as u,withCtx as h,createCommentVNode as m,toDisplayString as f,render as d}from"vue";const g={"top-left":{bounce:"mosha__bounceInLeft",flip:"mosha__flipIn",slide:"mosha__slideInLeft"},"top-right":{bounce:"mosha__bounceInRight",flip:"mosha__flipIn",slide:"mosha__slideInRight"},"top-center":{bounce:"mosha__bounceInDown",flip:"mosha__flipIn",slide:"mosha__slideInDown"},"bottom-center":{bounce:"mosha__bounceInUp",flip:"mosha__flipIn",slide:"mosha__slideInUp"},"bottom-right":{bounce:"mosha__bounceInRight",flip:"mosha__flipIn",slide:"mosha__slideInRight"},"bottom-left":{bounce:"mosha__bounceInLeft",flip:"mosha__flipIn",slide:"mosha__slideInLeft"}};var v=i({props:{type:{type:String,default:"default"}}});const _={class:"mosha__icon"},y={key:0,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},b=a("path",{d:"M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3zM12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"},null,-1),w={key:1,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},x=a("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"},null,-1),I={key:2,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},B=a("path",{d:"M0 0h24v24H0V0z",fill:"none"},null,-1),C=a("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM9.29 16.29L5.7 12.7c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0L10 14.17l6.88-6.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-7.59 7.59c-.38.39-1.02.39-1.41 0z"},null,-1),T={key:3,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#616161"},z=a("path",{d:"M0 0h24v24H0z",fill:"none"},null,-1),k=a("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1),M={key:4,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},S=a("path",{d:"M0 0h24v24H0z",fill:"none"},null,-1),H=a("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1);v.render=function(t,e,o,n,s,i){return l(),r("span",_,["warning"===t.type?(l(),r("svg",y,[b])):"danger"===t.type?(l(),r("svg",w,[x])):"success"===t.type?(l(),r("svg",I,[B,C])):"default"===t.type?(l(),r("svg",T,[z,k])):(l(),r("svg",M,[S,H]))])};var L=i({name:"MToast",components:{MIcon:v},props:{visible:Boolean,text:String,description:String,toastBackgroundColor:String,type:{type:String,default:"default"},onCloseHandler:{type:Function,required:!0},onClose:{type:Function},offset:Number,id:{type:Number,required:!0},timeout:{type:Number,default:5e3},position:{type:String,required:!0},closable:{type:Boolean,default:!0},hideProgressBar:{type:Boolean,default:!1},showIcon:{type:Boolean,default:!0},transition:{type:String,default:"bounce"}},setup(t){const i=e(),{start:l,stop:r,progress:a}=((t,s)=>{const i=e(),l=e(0),r=e(s),a=e(),p=e(100),c=()=>{clearInterval(a.value),clearTimeout(i.value)};return o((()=>{})),n((()=>{c()})),{start:()=>{l.value=Date.now(),clearTimeout(i.value),a.value=setInterval((()=>{p.value--}),s/100-2),i.value=setTimeout(t,r.value)},stop:()=>{clearInterval(a.value),clearTimeout(i.value),r.value-=Date.now()-l.value},clear:c,progress:p}})((()=>{t.onCloseHandler()}),t.timeout),c=()=>{t.timeout>0&&l()},{transitionType:u}=(h=t.position,m=t.transition,{transitionType:s((()=>g[h][m]))});var h,m;return p((()=>{const{customStyle:e}=((t,e,o)=>{const n=s((()=>{switch(t){case"top-left":return{left:"0",top:`${e}px`};case"bottom-left":return{left:"0",bottom:`${e}px`};case"bottom-right":return{right:"0",bottom:`${e}px`};case"top-center":return{top:`${e}px`,left:"0",right:"0",marginRight:"auto",marginLeft:"auto"};case"bottom-center":return{bottom:`${e}px`,left:"0",right:"0",marginRight:"auto",marginLeft:"auto"};default:return{right:"0",top:`${e}px`}}}));return o&&(n.value.backgroundColor=o),{customStyle:n}})(t.position,t.offset,t.toastBackgroundColor);i.value=e.value})),o((()=>{c()})),{style:i,transitionType:u,startTimer:c,stopTimer:()=>{t.timeout>0&&r()},progress:a}}});const V={class:"mosha__toast__content-wrapper"},N={class:"mosha__toast__content"},P={class:"mosha__toast__content__text"},$={key:0,class:"mosha__toast__content__description"};L.render=function(t,e,o,n,s,i){const p=c("MIcon");return l(),r(u,{name:t.transitionType,type:"animation"},{default:h((()=>[t.visible?(l(),r("div",{key:0,class:["mosha__toast",t.toastBackgroundColor?null:t.type],style:t.style,onMouseenter:e[2]||(e[2]=(...e)=>t.stopTimer&&t.stopTimer(...e)),onMouseleave:e[3]||(e[3]=(...e)=>t.startTimer&&t.startTimer(...e))},[a("div",V,[t.showIcon?(l(),r(p,{key:0,type:t.type},null,8,["type"])):m("",!0),a("div",N,[a("div",P,f(t.text),1),t.description?(l(),r("div",$,f(t.description),1)):m("",!0)])]),t.closable?(l(),r("div",{key:0,class:"mosha__toast__close-icon",onClick:e[1]||(e[1]=(...e)=>t.onCloseHandler&&t.onCloseHandler(...e))})):m("",!0),t.hideProgressBar?m("",!0):(l(),r("div",{key:1,class:"mosha__toast__progress",style:{width:`${t.progress}%`}},null,4))],38)):m("",!0)])),_:1},8,["name"])};const R={"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[],"top-center":[],"bottom-center":[]},D={type:"default",timeout:5e3,closable:!0,position:"top-right",transition:"bounce",hideProgressBar:!1};let q=0;const E=(e,o)=>{const n=o?(e=>{const o=t(t({},e),{type:e.type||D.type,timeout:e.timeout||D.timeout,closable:e.closable,position:e.position||D.position,showIcon:e.showIcon,transition:e.transition||D.transition});return o.hideProgressBar=void 0!==o.timeout&&o.timeout<=0,void 0!==e.hideProgressBar&&(o.hideProgressBar=e.hideProgressBar),o})(o):D,s="string"==typeof e?e:e.title,i="string"==typeof e?void 0:e.description;let l=12;const r=q++;if(!n.position)return;R[n.position].forEach((({toastVNode:t})=>{const e=t.el.offsetHeight+12;l+=e||0}));const p=document.createElement("div");document.body.appendChild(p);let c=null;c=a(L,t(t({},n),{text:s,description:i,id:r,offset:l,visible:!1,onCloseHandler:()=>{F(r,n.position?n.position:"top-right")}})),d(c,p),n.position&&(R[n.position].push({toastVNode:c,container:p}),c.component&&(c.component.props.visible=!0))},F=(t,e)=>{const o=R[e],n=o.findIndex((({toastVNode:e})=>t===e.props.id));if(-1===n)return;const{container:s,toastVNode:i}=o[n],l=i.el.offsetHeight;R[e].splice(n,1),i.component.props.visible=!1,i.component.props.onClose&&i.component.props.onClose();for(let r=n;r<o.length;r++){const{toastVNode:t}=o[r];if(!t.el)return;const n=e.split("-")[0]||"top",s=parseInt(t.el.style[n],10)-l-12;if(!t.component)return;t.component.props.offset=s}setTimeout((()=>{d(null,s),document.body.removeChild(s)}),1e3)};var U={install:(t,e)=>{t.config.globalProperties.$moshaToast=E,t.provide("moshaToast",E)}};export default U;export{E as createToast};
var e=Object.defineProperty,t=Object.prototype.hasOwnProperty,o=Object.getOwnPropertySymbols,n=Object.prototype.propertyIsEnumerable,s=(t,o,n)=>o in t?e(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,i=(e,i)=>{for(var l in i||(i={}))t.call(i,l)&&s(e,l,i[l]);if(o)for(var l of o(i))n.call(i,l)&&s(e,l,i[l]);return e};import{ref as l,onMounted as a,onUnmounted as r,computed as p,defineComponent as u,openBlock as c,createBlock as h,createVNode as v,watchEffect as d,resolveComponent as f,Transition as m,withCtx as g,createCommentVNode as _,toDisplayString as w,render as y}from"vue";const b={"top-left":{bounce:"mosha__bounceInLeft",flip:"mosha__flipIn",slide:"mosha__slideInLeft"},"top-right":{bounce:"mosha__bounceInRight",flip:"mosha__flipIn",slide:"mosha__slideInRight"},"top-center":{bounce:"mosha__bounceInDown",flip:"mosha__flipIn",slide:"mosha__slideInDown"},"bottom-center":{bounce:"mosha__bounceInUp",flip:"mosha__flipIn",slide:"mosha__slideInUp"},"bottom-right":{bounce:"mosha__bounceInRight",flip:"mosha__flipIn",slide:"mosha__slideInRight"},"bottom-left":{bounce:"mosha__bounceInLeft",flip:"mosha__flipIn",slide:"mosha__slideInLeft"}};var x=u({props:{type:{type:String,default:"default"}}});const I={class:"mosha__icon"},C={key:0,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},M=v("path",{d:"M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3zM12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"},null,-1),B={key:1,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},S=v("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"},null,-1),T={key:2,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},L=v("path",{d:"M0 0h24v24H0V0z",fill:"none"},null,-1),z=v("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM9.29 16.29L5.7 12.7c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0L10 14.17l6.88-6.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-7.59 7.59c-.38.39-1.02.39-1.41 0z"},null,-1),k={key:3,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#616161"},H=v("path",{d:"M0 0h24v24H0z",fill:"none"},null,-1),P=v("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1),D={key:4,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},V=v("path",{d:"M0 0h24v24H0z",fill:"none"},null,-1),$=v("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1);x.render=function(e,t,o,n,s,i){return c(),h("span",I,["warning"===e.type?(c(),h("svg",C,[M])):"danger"===e.type?(c(),h("svg",B,[S])):"success"===e.type?(c(),h("svg",T,[L,z])):"default"===e.type?(c(),h("svg",k,[H,P])):(c(),h("svg",D,[V,$]))])};var E=u({name:"MToast",components:{MIcon:x},props:{visible:Boolean,text:String,description:String,toastBackgroundColor:String,type:{type:String,default:"default"},onCloseHandler:{type:Function,required:!0},offset:Number,id:{type:Number,required:!0},timeout:{type:Number,default:5e3},position:{type:String,required:!0},showCloseButton:{type:Boolean,default:!0},swipeClose:{type:Boolean,default:!0},hideProgressBar:{type:Boolean,default:!1},showIcon:{type:Boolean,default:!1},transition:{type:String,default:"bounce"}},setup(e){const t=l(),{swipedDiff:o,startSwipeHandler:n,swipeStyle:s,cleanUpMove:u}=((e,t,o)=>{const n=l(),s=l(void 0),a=l(),p=e=>e instanceof MouseEvent,u=l=>{!1!==o&&n.value&&(p(l)?s.value=n.value.clientX-l.clientX:s.value=n.value.touches[0].clientX-l.touches[0].clientX,e.endsWith("left")?a.value=i(i({},a.value),{transition:"none",left:-s.value+"px"}):a.value=i(i({},a.value),{transition:"none",right:`${s.value}px`}),Math.abs(s.value)>200&&t())},c=e=>{!1!==o&&(n.value&&(n.value=void 0),s.value&&(s.value=void 0),removeEventListener(e,u))};return r((()=>{!1!==o&&(c("mousemove"),c("touchmove"))})),{swipedDiff:s,swipeStart:n,swipeStyle:a,swipeHandler:u,startSwipeHandler:t=>{if(!1===o)return;n.value=t;const s=p(t)?"mousemove":"touchmove",l=p(t)?"mouseup":"touchend";addEventListener(s,u),addEventListener(l,(()=>{n.value=void 0,e.endsWith("left")?a.value=i(i({},a.value),{transition:"left .3s ease-out",left:0}):a.value=i(i({},a.value),{transition:"right .3s ease-out",right:0}),removeEventListener(s,u)}))},cleanUpMove:c}})(e.position,e.onCloseHandler,e.swipeClose),{transitionType:c}=(h=e.position,v=e.transition,f=o,{transitionType:p((()=>f.value>0?"mosha__fadeOutLeft":f.value<0?"mosha__fadeOutRight":b[h][v]))});var h,v,f;const{start:m,stop:g,progress:_}=((e,t)=>{const o=l(),n=l(0),s=l(t),i=l(),p=l(100),u=()=>{clearInterval(i.value),clearTimeout(o.value)};return a((()=>{})),r((()=>{u()})),{start:()=>{n.value=Date.now(),clearTimeout(o.value),i.value=setInterval((()=>{p.value--}),t/100-2),o.value=setTimeout(e,s.value)},stop:()=>{clearInterval(i.value),clearTimeout(o.value),s.value-=Date.now()-n.value},clear:u,progress:p}})((()=>{e.onCloseHandler()}),e.timeout),w=()=>{e.timeout>0&&m()};return d((()=>{const{customStyle:o}=((e,t,o)=>{const n=p((()=>{switch(e){case"top-left":return{left:"0",top:`${t}px`};case"bottom-left":return{left:"0",bottom:`${t}px`};case"bottom-right":return{right:"0",bottom:`${t}px`};case"top-center":return{top:`${t}px`,left:"0",right:"0",marginRight:"auto",marginLeft:"auto"};case"bottom-center":return{bottom:`${t}px`,left:"0",right:"0",marginRight:"auto",marginLeft:"auto"};default:return{right:"0",top:`${t}px`}}}));return o&&(n.value.backgroundColor=o),{customStyle:n}})(e.position,e.offset,e.toastBackgroundColor);t.value=o.value})),a((()=>{w()})),{style:t,transitionType:c,startTimer:w,stopTimer:()=>{e.timeout>0&&g()},progress:_,onTouchStart:e=>{n(e)},onMouseLeave:()=>{u("mousemove"),w()},onMouseDown:e=>{n(e)},swipeStyle:s}}});const N={class:"mosha__toast__content-wrapper"},O={class:"mosha__toast__content"},R={class:"mosha__toast__content__text"},j={key:0,class:"mosha__toast__content__description"};E.render=function(e,t,o,n,s,i){const l=f("MIcon");return c(),h(m,{name:e.transitionType,type:"animation"},{default:g((()=>[e.visible?(c(),h("div",{key:0,class:["mosha__toast",e.toastBackgroundColor?null:e.type],style:[e.style,e.swipeStyle],onMouseenter:t[2]||(t[2]=(...t)=>e.stopTimer&&e.stopTimer(...t)),onMouseleave:t[3]||(t[3]=(...t)=>e.onMouseLeave&&e.onMouseLeave(...t)),onTouchstart:t[4]||(t[4]=(...t)=>e.onTouchStart&&e.onTouchStart(...t)),onMousedown:t[5]||(t[5]=(...t)=>e.onMouseDown&&e.onMouseDown(...t))},[v("div",N,[e.showIcon?(c(),h(l,{key:0,type:e.type},null,8,["type"])):_("",!0),v("div",O,[v("div",R,w(e.text),1),e.description?(c(),h("div",j,w(e.description),1)):_("",!0)])]),e.showCloseButton?(c(),h("div",{key:0,class:"mosha__toast__close-icon",onClick:t[1]||(t[1]=(...t)=>e.onCloseHandler&&e.onCloseHandler(...t))})):_("",!0),e.hideProgressBar?_("",!0):(c(),h("div",{key:1,class:"mosha__toast__progress",style:{width:`${e.progress}%`}},null,4))],38)):_("",!0)])),_:1},8,["name"])};const U={"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[],"top-center":[],"bottom-center":[]},X={type:"default",timeout:5e3,showCloseButton:!0,position:"top-right",transition:"bounce",hideProgressBar:!1,swipeClose:!0};let q=0;const W=(e,t)=>{const o=t?(e=>{const t=i(i({},e),{type:e.type||X.type,timeout:e.timeout||X.timeout,showCloseButton:e.showCloseButton,position:e.position||X.position,showIcon:e.showIcon,swipeClose:e.swipeClose,transition:e.transition||X.transition});return t.hideProgressBar=void 0!==t.timeout&&t.timeout<=0,void 0!==e.hideProgressBar&&(t.hideProgressBar=e.hideProgressBar),t})(t):X,n="string"==typeof e?e:e.title,s="string"==typeof e?void 0:e.description;let l=12;const a=q++;if(!o.position)return;U[o.position].forEach((({toastVNode:e})=>{const t=e.el.offsetHeight+12;l+=t||0}));const r=document.createElement("div");document.body.appendChild(r);let p=null;p=v(E,i(i({},o),{text:n,description:s,id:a,offset:l,visible:!1,onCloseHandler:()=>{F(a,o.position?o.position:"top-right")}})),y(p,r),o.position&&(U[o.position].push({toastVNode:p,container:r}),p.component&&(p.component.props.visible=!0))},F=(e,t)=>{const o=U[t],n=o.findIndex((({toastVNode:t})=>e===t.props.id));if(-1===n)return;const{container:s,toastVNode:i}=o[n],l=i.el.offsetHeight;U[t].splice(n,1),i.component.props.visible=!1,i.component.props.onClose&&i.component.props.onClose();for(let a=n;a<o.length;a++){const{toastVNode:e}=o[a];if(!e.el)return;const n=t.split("-")[0]||"top",s=parseInt(e.el.style[n],10)-l-12;if(!e.component)return;e.component.props.offset=s}setTimeout((()=>{y(null,s),document.body.removeChild(s)}),1e3)};var A={install:(e,t)=>{e.config.globalProperties.$moshaToast=W,e.provide("moshaToast",W)}};export default A;export{W as createToast};

@@ -1,1 +0,1 @@

var __assign=Object.assign;!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["mosha-vue-toastify"]={},e.Vue)}(this,(function(e,t){"use strict";const o={"top-left":{bounce:"mosha__bounceInLeft",flip:"mosha__flipIn",slide:"mosha__slideInLeft"},"top-right":{bounce:"mosha__bounceInRight",flip:"mosha__flipIn",slide:"mosha__slideInRight"},"top-center":{bounce:"mosha__bounceInDown",flip:"mosha__flipIn",slide:"mosha__slideInDown"},"bottom-center":{bounce:"mosha__bounceInUp",flip:"mosha__flipIn",slide:"mosha__slideInUp"},"bottom-right":{bounce:"mosha__bounceInRight",flip:"mosha__flipIn",slide:"mosha__slideInRight"},"bottom-left":{bounce:"mosha__bounceInLeft",flip:"mosha__flipIn",slide:"mosha__slideInLeft"}};var n=t.defineComponent({props:{type:{type:String,default:"default"}}});const s={class:"mosha__icon"},i={key:0,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},r=t.createVNode("path",{d:"M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3zM12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"},null,-1),l={key:1,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},a=t.createVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"},null,-1),c={key:2,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},p=t.createVNode("path",{d:"M0 0h24v24H0V0z",fill:"none"},null,-1),d=t.createVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM9.29 16.29L5.7 12.7c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0L10 14.17l6.88-6.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-7.59 7.59c-.38.39-1.02.39-1.41 0z"},null,-1),u={key:3,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#616161"},f=t.createVNode("path",{d:"M0 0h24v24H0z",fill:"none"},null,-1),m=t.createVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1),h={key:4,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},g=t.createVNode("path",{d:"M0 0h24v24H0z",fill:"none"},null,-1),_=t.createVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1);n.render=function(e,o,n,v,y,b){return t.openBlock(),t.createBlock("span",s,["warning"===e.type?(t.openBlock(),t.createBlock("svg",i,[r])):"danger"===e.type?(t.openBlock(),t.createBlock("svg",l,[a])):"success"===e.type?(t.openBlock(),t.createBlock("svg",c,[p,d])):"default"===e.type?(t.openBlock(),t.createBlock("svg",u,[f,m])):(t.openBlock(),t.createBlock("svg",h,[g,_]))])};var v=t.defineComponent({name:"MToast",components:{MIcon:n},props:{visible:Boolean,text:String,description:String,toastBackgroundColor:String,type:{type:String,default:"default"},onCloseHandler:{type:Function,required:!0},onClose:{type:Function},offset:Number,id:{type:Number,required:!0},timeout:{type:Number,default:5e3},position:{type:String,required:!0},closable:{type:Boolean,default:!0},hideProgressBar:{type:Boolean,default:!1},showIcon:{type:Boolean,default:!0},transition:{type:String,default:"bounce"}},setup(e){const n=t.ref(),{start:s,stop:i,progress:r}=((e,o)=>{const n=t.ref(),s=t.ref(0),i=t.ref(o),r=t.ref(),l=t.ref(100),a=()=>{clearInterval(r.value),clearTimeout(n.value)};return t.onMounted((()=>{})),t.onUnmounted((()=>{a()})),{start:()=>{s.value=Date.now(),clearTimeout(n.value),r.value=setInterval((()=>{l.value--}),o/100-2),n.value=setTimeout(e,i.value)},stop:()=>{clearInterval(r.value),clearTimeout(n.value),i.value-=Date.now()-s.value},clear:a,progress:l}})((()=>{e.onCloseHandler()}),e.timeout),l=()=>{e.timeout>0&&s()},{transitionType:a}=(c=e.position,p=e.transition,{transitionType:t.computed((()=>o[c][p]))});var c,p;return t.watchEffect((()=>{const{customStyle:o}=((e,o,n)=>{const s=t.computed((()=>{switch(e){case"top-left":return{left:"0",top:`${o}px`};case"bottom-left":return{left:"0",bottom:`${o}px`};case"bottom-right":return{right:"0",bottom:`${o}px`};case"top-center":return{top:`${o}px`,left:"0",right:"0",marginRight:"auto",marginLeft:"auto"};case"bottom-center":return{bottom:`${o}px`,left:"0",right:"0",marginRight:"auto",marginLeft:"auto"};default:return{right:"0",top:`${o}px`}}}));return n&&(s.value.backgroundColor=n),{customStyle:s}})(e.position,e.offset,e.toastBackgroundColor);n.value=o.value})),t.onMounted((()=>{l()})),{style:n,transitionType:a,startTimer:l,stopTimer:()=>{e.timeout>0&&i()},progress:r}}});const y={class:"mosha__toast__content-wrapper"},b={class:"mosha__toast__content"},w={class:"mosha__toast__content__text"},B={key:0,class:"mosha__toast__content__description"};v.render=function(e,o,n,s,i,r){const l=t.resolveComponent("MIcon");return t.openBlock(),t.createBlock(t.Transition,{name:e.transitionType,type:"animation"},{default:t.withCtx((()=>[e.visible?(t.openBlock(),t.createBlock("div",{key:0,class:["mosha__toast",e.toastBackgroundColor?null:e.type],style:e.style,onMouseenter:o[2]||(o[2]=(...t)=>e.stopTimer&&e.stopTimer(...t)),onMouseleave:o[3]||(o[3]=(...t)=>e.startTimer&&e.startTimer(...t))},[t.createVNode("div",y,[e.showIcon?(t.openBlock(),t.createBlock(l,{key:0,type:e.type},null,8,["type"])):t.createCommentVNode("",!0),t.createVNode("div",b,[t.createVNode("div",w,t.toDisplayString(e.text),1),e.description?(t.openBlock(),t.createBlock("div",B,t.toDisplayString(e.description),1)):t.createCommentVNode("",!0)])]),e.closable?(t.openBlock(),t.createBlock("div",{key:0,class:"mosha__toast__close-icon",onClick:o[1]||(o[1]=(...t)=>e.onCloseHandler&&e.onCloseHandler(...t))})):t.createCommentVNode("",!0),e.hideProgressBar?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock("div",{key:1,class:"mosha__toast__progress",style:{width:`${e.progress}%`}},null,4))],38)):t.createCommentVNode("",!0)])),_:1},8,["name"])};const k={"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[],"top-center":[],"bottom-center":[]},x={type:"default",timeout:5e3,closable:!0,position:"top-right",transition:"bounce",hideProgressBar:!1};let I=0;const C=(e,o)=>{const n=o?(e=>{const t=__assign(__assign({},e),{type:e.type||x.type,timeout:e.timeout||x.timeout,closable:e.closable,position:e.position||x.position,showIcon:e.showIcon,transition:e.transition||x.transition});return t.hideProgressBar=void 0!==t.timeout&&t.timeout<=0,void 0!==e.hideProgressBar&&(t.hideProgressBar=e.hideProgressBar),t})(o):x,s="string"==typeof e?e:e.title,i="string"==typeof e?void 0:e.description;let r=12;const l=I++;if(!n.position)return;k[n.position].forEach((({toastVNode:e})=>{const t=e.el.offsetHeight+12;r+=t||0}));const a=document.createElement("div");document.body.appendChild(a);let c=null;c=t.createVNode(v,__assign(__assign({},n),{text:s,description:i,id:l,offset:r,visible:!1,onCloseHandler:()=>{V(l,n.position?n.position:"top-right")}})),t.render(c,a),n.position&&(k[n.position].push({toastVNode:c,container:a}),c.component&&(c.component.props.visible=!0))},V=(e,o)=>{const n=k[o],s=n.findIndex((({toastVNode:t})=>e===t.props.id));if(-1===s)return;const{container:i,toastVNode:r}=n[s],l=r.el.offsetHeight;k[o].splice(s,1),r.component.props.visible=!1,r.component.props.onClose&&r.component.props.onClose();for(let t=s;t<n.length;t++){const{toastVNode:e}=n[t];if(!e.el)return;const s=o.split("-")[0]||"top",i=parseInt(e.el.style[s],10)-l-12;if(!e.component)return;e.component.props.offset=i}setTimeout((()=>{t.render(null,i),document.body.removeChild(i)}),1e3)};var N={install:(e,t)=>{e.config.globalProperties.$moshaToast=C,e.provide("moshaToast",C)}};e.createToast=C,e.default=N,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"}));
var __defProp=Object.defineProperty,__hasOwnProp=Object.prototype.hasOwnProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__assign=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e};!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["mosha-vue-toastify"]={},e.Vue)}(this,(function(e,t){"use strict";const o={"top-left":{bounce:"mosha__bounceInLeft",flip:"mosha__flipIn",slide:"mosha__slideInLeft"},"top-right":{bounce:"mosha__bounceInRight",flip:"mosha__flipIn",slide:"mosha__slideInRight"},"top-center":{bounce:"mosha__bounceInDown",flip:"mosha__flipIn",slide:"mosha__slideInDown"},"bottom-center":{bounce:"mosha__bounceInUp",flip:"mosha__flipIn",slide:"mosha__slideInUp"},"bottom-right":{bounce:"mosha__bounceInRight",flip:"mosha__flipIn",slide:"mosha__slideInRight"},"bottom-left":{bounce:"mosha__bounceInLeft",flip:"mosha__flipIn",slide:"mosha__slideInLeft"}};var n=t.defineComponent({props:{type:{type:String,default:"default"}}});const s={class:"mosha__icon"},i={key:0,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},r=t.createVNode("path",{d:"M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3zM12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"},null,-1),a={key:1,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},l=t.createVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"},null,-1),p={key:2,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},c=t.createVNode("path",{d:"M0 0h24v24H0V0z",fill:"none"},null,-1),u=t.createVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM9.29 16.29L5.7 12.7c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0L10 14.17l6.88-6.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-7.59 7.59c-.38.39-1.02.39-1.41 0z"},null,-1),d={key:3,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#616161"},f=t.createVNode("path",{d:"M0 0h24v24H0z",fill:"none"},null,-1),m=t.createVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1),h={key:4,xmlns:"http://www.w3.org/2000/svg",height:"32px",viewBox:"0 0 24 24",width:"32px",fill:"#ffffff"},v=t.createVNode("path",{d:"M0 0h24v24H0z",fill:"none"},null,-1),_=t.createVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1);n.render=function(e,o,n,g,w,y){return t.openBlock(),t.createBlock("span",s,["warning"===e.type?(t.openBlock(),t.createBlock("svg",i,[r])):"danger"===e.type?(t.openBlock(),t.createBlock("svg",a,[l])):"success"===e.type?(t.openBlock(),t.createBlock("svg",p,[c,u])):"default"===e.type?(t.openBlock(),t.createBlock("svg",d,[f,m])):(t.openBlock(),t.createBlock("svg",h,[v,_]))])};var g=t.defineComponent({name:"MToast",components:{MIcon:n},props:{visible:Boolean,text:String,description:String,toastBackgroundColor:String,type:{type:String,default:"default"},onCloseHandler:{type:Function,required:!0},offset:Number,id:{type:Number,required:!0},timeout:{type:Number,default:5e3},position:{type:String,required:!0},showCloseButton:{type:Boolean,default:!0},swipeClose:{type:Boolean,default:!0},hideProgressBar:{type:Boolean,default:!1},showIcon:{type:Boolean,default:!1},transition:{type:String,default:"bounce"}},setup(e){const n=t.ref(),{swipedDiff:s,startSwipeHandler:i,swipeStyle:r,cleanUpMove:a}=((e,o,n)=>{const s=t.ref(),i=t.ref(void 0),r=t.ref(),a=e=>e instanceof MouseEvent,l=t=>{!1!==n&&s.value&&(a(t)?i.value=s.value.clientX-t.clientX:i.value=s.value.touches[0].clientX-t.touches[0].clientX,e.endsWith("left")?r.value=__assign(__assign({},r.value),{transition:"none",left:-i.value+"px"}):r.value=__assign(__assign({},r.value),{transition:"none",right:`${i.value}px`}),Math.abs(i.value)>200&&o())},p=e=>{!1!==n&&(s.value&&(s.value=void 0),i.value&&(i.value=void 0),removeEventListener(e,l))};return t.onUnmounted((()=>{!1!==n&&(p("mousemove"),p("touchmove"))})),{swipedDiff:i,swipeStart:s,swipeStyle:r,swipeHandler:l,startSwipeHandler:t=>{if(!1===n)return;s.value=t;const o=a(t)?"mousemove":"touchmove",i=a(t)?"mouseup":"touchend";addEventListener(o,l),addEventListener(i,(()=>{s.value=void 0,e.endsWith("left")?r.value=__assign(__assign({},r.value),{transition:"left .3s ease-out",left:0}):r.value=__assign(__assign({},r.value),{transition:"right .3s ease-out",right:0}),removeEventListener(o,l)}))},cleanUpMove:p}})(e.position,e.onCloseHandler,e.swipeClose),{transitionType:l}=(p=e.position,c=e.transition,u=s,{transitionType:t.computed((()=>u.value>0?"mosha__fadeOutLeft":u.value<0?"mosha__fadeOutRight":o[p][c]))});var p,c,u;const{start:d,stop:f,progress:m}=((e,o)=>{const n=t.ref(),s=t.ref(0),i=t.ref(o),r=t.ref(),a=t.ref(100),l=()=>{clearInterval(r.value),clearTimeout(n.value)};return t.onMounted((()=>{})),t.onUnmounted((()=>{l()})),{start:()=>{s.value=Date.now(),clearTimeout(n.value),r.value=setInterval((()=>{a.value--}),o/100-2),n.value=setTimeout(e,i.value)},stop:()=>{clearInterval(r.value),clearTimeout(n.value),i.value-=Date.now()-s.value},clear:l,progress:a}})((()=>{e.onCloseHandler()}),e.timeout),h=()=>{e.timeout>0&&d()};return t.watchEffect((()=>{const{customStyle:o}=((e,o,n)=>{const s=t.computed((()=>{switch(e){case"top-left":return{left:"0",top:`${o}px`};case"bottom-left":return{left:"0",bottom:`${o}px`};case"bottom-right":return{right:"0",bottom:`${o}px`};case"top-center":return{top:`${o}px`,left:"0",right:"0",marginRight:"auto",marginLeft:"auto"};case"bottom-center":return{bottom:`${o}px`,left:"0",right:"0",marginRight:"auto",marginLeft:"auto"};default:return{right:"0",top:`${o}px`}}}));return n&&(s.value.backgroundColor=n),{customStyle:s}})(e.position,e.offset,e.toastBackgroundColor);n.value=o.value})),t.onMounted((()=>{h()})),{style:n,transitionType:l,startTimer:h,stopTimer:()=>{e.timeout>0&&f()},progress:m,onTouchStart:e=>{i(e)},onMouseLeave:()=>{a("mousemove"),h()},onMouseDown:e=>{i(e)},swipeStyle:r}}});const w={class:"mosha__toast__content-wrapper"},y={class:"mosha__toast__content"},b={class:"mosha__toast__content__text"},B={key:0,class:"mosha__toast__content__description"};g.render=function(e,o,n,s,i,r){const a=t.resolveComponent("MIcon");return t.openBlock(),t.createBlock(t.Transition,{name:e.transitionType,type:"animation"},{default:t.withCtx((()=>[e.visible?(t.openBlock(),t.createBlock("div",{key:0,class:["mosha__toast",e.toastBackgroundColor?null:e.type],style:[e.style,e.swipeStyle],onMouseenter:o[2]||(o[2]=(...t)=>e.stopTimer&&e.stopTimer(...t)),onMouseleave:o[3]||(o[3]=(...t)=>e.onMouseLeave&&e.onMouseLeave(...t)),onTouchstart:o[4]||(o[4]=(...t)=>e.onTouchStart&&e.onTouchStart(...t)),onMousedown:o[5]||(o[5]=(...t)=>e.onMouseDown&&e.onMouseDown(...t))},[t.createVNode("div",w,[e.showIcon?(t.openBlock(),t.createBlock(a,{key:0,type:e.type},null,8,["type"])):t.createCommentVNode("",!0),t.createVNode("div",y,[t.createVNode("div",b,t.toDisplayString(e.text),1),e.description?(t.openBlock(),t.createBlock("div",B,t.toDisplayString(e.description),1)):t.createCommentVNode("",!0)])]),e.showCloseButton?(t.openBlock(),t.createBlock("div",{key:0,class:"mosha__toast__close-icon",onClick:o[1]||(o[1]=(...t)=>e.onCloseHandler&&e.onCloseHandler(...t))})):t.createCommentVNode("",!0),e.hideProgressBar?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock("div",{key:1,class:"mosha__toast__progress",style:{width:`${e.progress}%`}},null,4))],38)):t.createCommentVNode("",!0)])),_:1},8,["name"])};const k={"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[],"top-center":[],"bottom-center":[]},C={type:"default",timeout:5e3,showCloseButton:!0,position:"top-right",transition:"bounce",hideProgressBar:!1,swipeClose:!0};let x=0;const I=(e,o)=>{const n=o?(e=>{const t=__assign(__assign({},e),{type:e.type||C.type,timeout:e.timeout||C.timeout,showCloseButton:e.showCloseButton,position:e.position||C.position,showIcon:e.showIcon,swipeClose:e.swipeClose,transition:e.transition||C.transition});return t.hideProgressBar=void 0!==t.timeout&&t.timeout<=0,void 0!==e.hideProgressBar&&(t.hideProgressBar=e.hideProgressBar),t})(o):C,s="string"==typeof e?e:e.title,i="string"==typeof e?void 0:e.description;let r=12;const a=x++;if(!n.position)return;k[n.position].forEach((({toastVNode:e})=>{const t=e.el.offsetHeight+12;r+=t||0}));const l=document.createElement("div");document.body.appendChild(l);let p=null;p=t.createVNode(g,__assign(__assign({},n),{text:s,description:i,id:a,offset:r,visible:!1,onCloseHandler:()=>{S(a,n.position?n.position:"top-right")}})),t.render(p,l),n.position&&(k[n.position].push({toastVNode:p,container:l}),p.component&&(p.component.props.visible=!0))},S=(e,o)=>{const n=k[o],s=n.findIndex((({toastVNode:t})=>e===t.props.id));if(-1===s)return;const{container:i,toastVNode:r}=n[s],a=r.el.offsetHeight;k[o].splice(s,1),r.component.props.visible=!1,r.component.props.onClose&&r.component.props.onClose();for(let t=s;t<n.length;t++){const{toastVNode:e}=n[t];if(!e.el)return;const s=o.split("-")[0]||"top",i=parseInt(e.el.style[s],10)-a-12;if(!e.component)return;e.component.props.offset=i}setTimeout((()=>{t.render(null,i),document.body.removeChild(i)}),1e3)};var M={install:(e,t)=>{e.config.globalProperties.$moshaToast=I,e.provide("moshaToast",I)}};e.createToast=I,e.default=M,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"}));

@@ -15,3 +15,3 @@ export declare type ToastType = 'info' | 'danger' | 'warning' | 'success' | 'default';

timeout?: number;
closable?: boolean;
showCloseButton?: boolean;
position?: Position;

@@ -22,3 +22,4 @@ showIcon?: boolean;

toastBackgroundColor?: string;
swipeClose?: boolean;
onClose?: () => void;
}
{
"name": "mosha-vue-toastify",
"version": "0.0.3",
"version": "0.0.4",
"license": "MIT",

@@ -15,2 +15,3 @@ "files": [

"build": "vite build && tsc -P tsconfig.json",
"publish": "yarn build && yarn publish",
"serve": "vite preview",

@@ -17,0 +18,0 @@ "example:update": "yarn build && cd examples/vite-sample && yarn link \"mosha-vue-toastify\"",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc