vue-toast-notification
Advanced tools
Comparing version 3.0.4 to 3.1.0
@@ -15,3 +15,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/***/ 831: | ||
/***/ 661: | ||
/***/ ((__unused_webpack_module, exports) => { | ||
@@ -114,9 +114,7 @@ | ||
var external_commonjs_vue_commonjs2_vue_amd_vue_root_Vue_ = __webpack_require__(976); | ||
;// CONCATENATED MODULE: ./node_modules/.pnpm/babel-loader@8.2.5_rb5fcebzp6kx3hqg3ucus54t3m/node_modules/babel-loader/lib/index.js!./node_modules/.pnpm/vue-loader@17.0.0_webpack@5.72.0/node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/.pnpm/vue-loader@17.0.0_webpack@5.72.0/node_modules/vue-loader/dist/index.js??ruleSet[1].rules[6].use[0]!./src/js/Component.vue?vue&type=template&id=f73c8b4e | ||
;// CONCATENATED MODULE: ./node_modules/.pnpm/babel-loader@9.1.2_la66t7xldg4uecmyawueag5wkm/node_modules/babel-loader/lib/index.js!./node_modules/.pnpm/vue-loader@17.0.1_ceoavo7i67lvjzxxtqa4yhrx7m/node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/.pnpm/vue-loader@17.0.1_ceoavo7i67lvjzxxtqa4yhrx7m/node_modules/vue-loader/dist/index.js??ruleSet[1].rules[6].use[0]!./src/js/Component.vue?vue&type=template&id=f73c8b4e | ||
const _hoisted_1 = /*#__PURE__*/(0,external_commonjs_vue_commonjs2_vue_amd_vue_root_Vue_.createElementVNode)("div", { | ||
class: "v-toast__icon" | ||
}, null, -1); | ||
const _hoisted_2 = ["innerHTML"]; | ||
@@ -131,3 +129,3 @@ function render(_ctx, _cache, $props, $setup, $data, $options) { | ||
role: "alert", | ||
class: (0,external_commonjs_vue_commonjs2_vue_amd_vue_root_Vue_.normalizeClass)(["v-toast__item", ["v-toast__item--".concat(_ctx.type), "v-toast__item--".concat(_ctx.position)]]), | ||
class: (0,external_commonjs_vue_commonjs2_vue_amd_vue_root_Vue_.normalizeClass)(["v-toast__item", [`v-toast__item--${_ctx.type}`, `v-toast__item--${_ctx.position}`]]), | ||
onMouseover: _cache[0] || (_cache[0] = $event => _ctx.toggleTimer(true)), | ||
@@ -153,5 +151,3 @@ onMouseleave: _cache[1] || (_cache[1] = $event => _ctx.toggleTimer(false)), | ||
} else { | ||
var _el$parentNode; | ||
(_el$parentNode = el.parentNode) === null || _el$parentNode === void 0 ? void 0 : _el$parentNode.removeChild(el); | ||
el.parentNode?.removeChild(el); | ||
} | ||
@@ -177,3 +173,2 @@ } | ||
} | ||
pause() { | ||
@@ -183,3 +178,2 @@ this.stop(); | ||
} | ||
resume() { | ||
@@ -190,7 +184,5 @@ this.stop(); | ||
} | ||
stop() { | ||
clearTimeout(this.timer); | ||
} | ||
} | ||
@@ -214,3 +206,3 @@ ;// CONCATENATED MODULE: ./src/js/positions.js | ||
/* harmony default export */ const bus = (eventBus); | ||
;// CONCATENATED MODULE: ./node_modules/.pnpm/babel-loader@8.2.5_rb5fcebzp6kx3hqg3ucus54t3m/node_modules/babel-loader/lib/index.js!./node_modules/.pnpm/vue-loader@17.0.0_webpack@5.72.0/node_modules/vue-loader/dist/index.js??ruleSet[1].rules[6].use[0]!./src/js/Component.vue?vue&type=script&lang=js | ||
;// CONCATENATED MODULE: ./node_modules/.pnpm/babel-loader@9.1.2_la66t7xldg4uecmyawueag5wkm/node_modules/babel-loader/lib/index.js!./node_modules/.pnpm/vue-loader@17.0.1_ceoavo7i67lvjzxxtqa4yhrx7m/node_modules/vue-loader/dist/index.js??ruleSet[1].rules[6].use[0]!./src/js/Component.vue?vue&type=script&lang=js | ||
@@ -235,7 +227,5 @@ | ||
default: positions.BOTTOM_RIGHT, | ||
validator(value) { | ||
return Object.values(positions).includes(value); | ||
} | ||
}, | ||
@@ -264,3 +254,2 @@ duration: { | ||
}, | ||
data() { | ||
@@ -274,7 +263,5 @@ return { | ||
}, | ||
beforeMount() { | ||
this.setupContainer(); | ||
}, | ||
mounted() { | ||
@@ -284,10 +271,8 @@ this.showNotice(); | ||
}, | ||
methods: { | ||
setupContainer() { | ||
this.parentTop = document.querySelector('.v-toast.v-toast--top'); | ||
this.parentBottom = document.querySelector('.v-toast.v-toast--bottom'); // No need to create them, they already exists | ||
this.parentBottom = document.querySelector('.v-toast.v-toast--bottom'); | ||
// No need to create them, they already exists | ||
if (this.parentTop && this.parentBottom) return; | ||
if (!this.parentTop) { | ||
@@ -297,3 +282,2 @@ this.parentTop = document.createElement('div'); | ||
} | ||
if (!this.parentBottom) { | ||
@@ -303,3 +287,2 @@ this.parentBottom = document.createElement('div'); | ||
} | ||
const container = document.body; | ||
@@ -309,3 +292,2 @@ container.appendChild(this.parentTop); | ||
}, | ||
shouldQueue() { | ||
@@ -315,12 +297,12 @@ if (!this.queue) return false; | ||
}, | ||
dismiss() { | ||
if (this.timer) this.timer.stop(); | ||
clearTimeout(this.queueTimer); | ||
this.isActive = false; // Timeout for the animation complete before destroying | ||
this.isActive = false; | ||
// Timeout for the animation complete before destroying | ||
setTimeout(() => { | ||
this.onDismiss.apply(null, arguments); | ||
const wrapper = this.$refs.root; // unmount the component | ||
const wrapper = this.$refs.root; | ||
// unmount the component | ||
(0,external_commonjs_vue_commonjs2_vue_amd_vue_root_Vue_.render)(null, wrapper); | ||
@@ -330,3 +312,2 @@ removeElement(wrapper); | ||
}, | ||
showNotice() { | ||
@@ -338,3 +319,2 @@ if (this.shouldQueue()) { | ||
} | ||
const wrapper = this.$refs.root.parentElement; | ||
@@ -344,3 +324,2 @@ this.correctParent.insertAdjacentElement('afterbegin', this.$refs.root); | ||
this.isActive = true; | ||
if (this.duration) { | ||
@@ -350,3 +329,2 @@ this.timer = new Timer(this.dismiss, this.duration); | ||
}, | ||
whenClicked() { | ||
@@ -357,3 +335,2 @@ if (!this.dismissible) return; | ||
}, | ||
toggleTimer(newVal) { | ||
@@ -363,3 +340,2 @@ if (!this.pauseOnHover || !this.timer) return; | ||
} | ||
}, | ||
@@ -373,3 +349,2 @@ computed: { | ||
return this.parentTop; | ||
case positions.BOTTOM: | ||
@@ -381,3 +356,2 @@ case positions.BOTTOM_RIGHT: | ||
}, | ||
transition() { | ||
@@ -392,3 +366,2 @@ switch (this.position) { | ||
}; | ||
case positions.BOTTOM: | ||
@@ -403,14 +376,11 @@ case positions.BOTTOM_RIGHT: | ||
} | ||
}, | ||
beforeUnmount() { | ||
bus.off('toast-clear', this.dismiss); | ||
} | ||
})); | ||
;// CONCATENATED MODULE: ./src/js/Component.vue?vue&type=script&lang=js | ||
// EXTERNAL MODULE: ./node_modules/.pnpm/vue-loader@17.0.0_webpack@5.72.0/node_modules/vue-loader/dist/exportHelper.js | ||
var exportHelper = __webpack_require__(831); | ||
// EXTERNAL MODULE: ./node_modules/.pnpm/vue-loader@17.0.1_ceoavo7i67lvjzxxtqa4yhrx7m/node_modules/vue-loader/dist/exportHelper.js | ||
var exportHelper = __webpack_require__(661); | ||
;// CONCATENATED MODULE: ./src/js/Component.vue | ||
@@ -444,7 +414,5 @@ | ||
}, | ||
clear() { | ||
bus.emit('toast-clear'); | ||
}, | ||
success(message) { | ||
@@ -457,3 +425,2 @@ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
}, | ||
error(message) { | ||
@@ -466,3 +433,2 @@ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
}, | ||
info(message) { | ||
@@ -475,3 +441,2 @@ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
}, | ||
warning(message) { | ||
@@ -484,3 +449,2 @@ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
}, | ||
default(message) { | ||
@@ -493,3 +457,2 @@ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
} | ||
}; | ||
@@ -496,0 +459,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define("VueToast",["vue"],e):"object"==typeof exports?exports.VueToast=e(require("vue")):t.VueToast=e(t.Vue)}(this,(t=>(()=>{"use strict";var e={831:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{const s=t.__vccOpts||t;for(const[t,o]of e)s[t]=o;return s}},976:e=>{e.exports=t}},s={};function o(t){var i=s[t];if(void 0!==i)return i.exports;var n=s[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var s in e)o.o(e,s)&&!o.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{ToastComponent:()=>d,ToastPlugin:()=>h,ToastPositions:()=>l,default:()=>v,useToast:()=>m});var t=o(976);const e=(0,t.createElementVNode)("div",{class:"v-toast__icon"},null,-1),s=["innerHTML"];function n(t){var e;void 0!==t.remove?t.remove():null===(e=t.parentNode)||void 0===e||e.removeChild(t)}function r(e,s,o){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=(0,t.h)(e,s,i),r=document.createElement("div");return r.classList.add("v-toast--pending"),o.appendChild(r),(0,t.render)(n,r),n.component}class a{constructor(t,e){this.startedAt=Date.now(),this.callback=t,this.delay=e,this.timer=setTimeout(t,e)}pause(){this.stop(),this.delay-=Date.now()-this.startedAt}resume(){this.stop(),this.startedAt=Date.now(),this.timer=setTimeout(this.callback,this.delay)}stop(){clearTimeout(this.timer)}}const l=Object.freeze({TOP_RIGHT:"top-right",TOP:"top",TOP_LEFT:"top-left",BOTTOM_RIGHT:"bottom-right",BOTTOM:"bottom",BOTTOM_LEFT:"bottom-left"});var c;const u={all:c=c||new Map,on:function(t,e){var s=c.get(t);s?s.push(e):c.set(t,[e])},off:function(t,e){var s=c.get(t);s&&(e?s.splice(s.indexOf(e)>>>0,1):c.set(t,[]))},emit:function(t,e){var s=c.get(t);s&&s.slice().map((function(t){t(e)})),(s=c.get("*"))&&s.slice().map((function(s){s(t,e)}))}},p=(0,t.defineComponent)({name:"Toast",props:{message:{type:String,required:!0},type:{type:String,default:"success"},position:{type:String,default:l.BOTTOM_RIGHT,validator:t=>Object.values(l).includes(t)},duration:{type:Number,default:3e3},dismissible:{type:Boolean,default:!0},onDismiss:{type:Function,default:()=>{}},onClick:{type:Function,default:()=>{}},queue:Boolean,pauseOnHover:{type:Boolean,default:!0}},data:()=>({isActive:!1,parentTop:null,parentBottom:null,isHovered:!1}),beforeMount(){this.setupContainer()},mounted(){this.showNotice(),u.on("toast-clear",this.dismiss)},methods:{setupContainer(){if(this.parentTop=document.querySelector(".v-toast.v-toast--top"),this.parentBottom=document.querySelector(".v-toast.v-toast--bottom"),this.parentTop&&this.parentBottom)return;this.parentTop||(this.parentTop=document.createElement("div"),this.parentTop.className="v-toast v-toast--top"),this.parentBottom||(this.parentBottom=document.createElement("div"),this.parentBottom.className="v-toast v-toast--bottom");const t=document.body;t.appendChild(this.parentTop),t.appendChild(this.parentBottom)},shouldQueue(){return!!this.queue&&(this.parentTop.childElementCount>0||this.parentBottom.childElementCount>0)},dismiss(){this.timer&&this.timer.stop(),clearTimeout(this.queueTimer),this.isActive=!1,setTimeout((()=>{this.onDismiss.apply(null,arguments);const e=this.$refs.root;(0,t.render)(null,e),n(e)}),150)},showNotice(){if(this.shouldQueue())return void(this.queueTimer=setTimeout(this.showNotice,250));const t=this.$refs.root.parentElement;this.correctParent.insertAdjacentElement("afterbegin",this.$refs.root),n(t),this.isActive=!0,this.duration&&(this.timer=new a(this.dismiss,this.duration))},whenClicked(){this.dismissible&&(this.onClick.apply(null,arguments),this.dismiss())},toggleTimer(t){this.pauseOnHover&&this.timer&&(t?this.timer.pause():this.timer.resume())}},computed:{correctParent(){switch(this.position){case l.TOP:case l.TOP_RIGHT:case l.TOP_LEFT:return this.parentTop;case l.BOTTOM:case l.BOTTOM_RIGHT:case l.BOTTOM_LEFT:return this.parentBottom}},transition(){switch(this.position){case l.TOP:case l.TOP_RIGHT:case l.TOP_LEFT:return{enter:"v-toast--fade-in-down",leave:"v-toast--fade-out"};case l.BOTTOM:case l.BOTTOM_RIGHT:case l.BOTTOM_LEFT:return{enter:"v-toast--fade-in-up",leave:"v-toast--fade-out"}}}},beforeUnmount(){u.off("toast-clear",this.dismiss)}});const d=(0,o(831).default)(p,[["render",function(o,i,n,r,a,l){return(0,t.openBlock)(),(0,t.createBlock)(t.Transition,{"enter-active-class":o.transition.enter,"leave-active-class":o.transition.leave},{default:(0,t.withCtx)((()=>[(0,t.withDirectives)((0,t.createElementVNode)("div",{ref:"root",role:"alert",class:(0,t.normalizeClass)(["v-toast__item",["v-toast__item--".concat(o.type),"v-toast__item--".concat(o.position)]]),onMouseover:i[0]||(i[0]=t=>o.toggleTimer(!0)),onMouseleave:i[1]||(i[1]=t=>o.toggleTimer(!1)),onClick:i[2]||(i[2]=function(){return o.whenClicked&&o.whenClicked(...arguments)})},[e,(0,t.createElementVNode)("p",{class:"v-toast__text",innerHTML:o.message},null,8,s)],34),[[t.vShow,o.isActive]])])),_:1},8,["enter-active-class","leave-active-class"])}]]),m=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{open(e){let s=null;"string"==typeof e&&(s=e);const o={message:s},i=Object.assign({},o,t,e);return{dismiss:r(d,i,document.body).ctx.dismiss}},clear(){u.emit("toast-clear")},success(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"success"},e))},error(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"error"},e))},info(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"info"},e))},warning(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"warning"},e))},default(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"default"},e))}}},h={install:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=m(e);t.config.globalProperties.$toast=s,t.provide("$toast",s)}},v=h})(),i})())); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define("VueToast",["vue"],e):"object"==typeof exports?exports.VueToast=e(require("vue")):t.VueToast=e(t.Vue)}(this,(t=>(()=>{"use strict";var e={661:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{const s=t.__vccOpts||t;for(const[t,o]of e)s[t]=o;return s}},976:e=>{e.exports=t}},s={};function o(t){var i=s[t];if(void 0!==i)return i.exports;var n=s[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var s in e)o.o(e,s)&&!o.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{ToastComponent:()=>d,ToastPlugin:()=>h,ToastPositions:()=>l,default:()=>v,useToast:()=>m});var t=o(976);const e=(0,t.createElementVNode)("div",{class:"v-toast__icon"},null,-1),s=["innerHTML"];function n(t){void 0!==t.remove?t.remove():t.parentNode?.removeChild(t)}function r(e,s,o){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=(0,t.h)(e,s,i),r=document.createElement("div");return r.classList.add("v-toast--pending"),o.appendChild(r),(0,t.render)(n,r),n.component}class a{constructor(t,e){this.startedAt=Date.now(),this.callback=t,this.delay=e,this.timer=setTimeout(t,e)}pause(){this.stop(),this.delay-=Date.now()-this.startedAt}resume(){this.stop(),this.startedAt=Date.now(),this.timer=setTimeout(this.callback,this.delay)}stop(){clearTimeout(this.timer)}}const l=Object.freeze({TOP_RIGHT:"top-right",TOP:"top",TOP_LEFT:"top-left",BOTTOM_RIGHT:"bottom-right",BOTTOM:"bottom",BOTTOM_LEFT:"bottom-left"});var c;const u={all:c=c||new Map,on:function(t,e){var s=c.get(t);s?s.push(e):c.set(t,[e])},off:function(t,e){var s=c.get(t);s&&(e?s.splice(s.indexOf(e)>>>0,1):c.set(t,[]))},emit:function(t,e){var s=c.get(t);s&&s.slice().map((function(t){t(e)})),(s=c.get("*"))&&s.slice().map((function(s){s(t,e)}))}},p=(0,t.defineComponent)({name:"Toast",props:{message:{type:String,required:!0},type:{type:String,default:"success"},position:{type:String,default:l.BOTTOM_RIGHT,validator:t=>Object.values(l).includes(t)},duration:{type:Number,default:3e3},dismissible:{type:Boolean,default:!0},onDismiss:{type:Function,default:()=>{}},onClick:{type:Function,default:()=>{}},queue:Boolean,pauseOnHover:{type:Boolean,default:!0}},data:()=>({isActive:!1,parentTop:null,parentBottom:null,isHovered:!1}),beforeMount(){this.setupContainer()},mounted(){this.showNotice(),u.on("toast-clear",this.dismiss)},methods:{setupContainer(){if(this.parentTop=document.querySelector(".v-toast.v-toast--top"),this.parentBottom=document.querySelector(".v-toast.v-toast--bottom"),this.parentTop&&this.parentBottom)return;this.parentTop||(this.parentTop=document.createElement("div"),this.parentTop.className="v-toast v-toast--top"),this.parentBottom||(this.parentBottom=document.createElement("div"),this.parentBottom.className="v-toast v-toast--bottom");const t=document.body;t.appendChild(this.parentTop),t.appendChild(this.parentBottom)},shouldQueue(){return!!this.queue&&(this.parentTop.childElementCount>0||this.parentBottom.childElementCount>0)},dismiss(){this.timer&&this.timer.stop(),clearTimeout(this.queueTimer),this.isActive=!1,setTimeout((()=>{this.onDismiss.apply(null,arguments);const e=this.$refs.root;(0,t.render)(null,e),n(e)}),150)},showNotice(){if(this.shouldQueue())return void(this.queueTimer=setTimeout(this.showNotice,250));const t=this.$refs.root.parentElement;this.correctParent.insertAdjacentElement("afterbegin",this.$refs.root),n(t),this.isActive=!0,this.duration&&(this.timer=new a(this.dismiss,this.duration))},whenClicked(){this.dismissible&&(this.onClick.apply(null,arguments),this.dismiss())},toggleTimer(t){this.pauseOnHover&&this.timer&&(t?this.timer.pause():this.timer.resume())}},computed:{correctParent(){switch(this.position){case l.TOP:case l.TOP_RIGHT:case l.TOP_LEFT:return this.parentTop;case l.BOTTOM:case l.BOTTOM_RIGHT:case l.BOTTOM_LEFT:return this.parentBottom}},transition(){switch(this.position){case l.TOP:case l.TOP_RIGHT:case l.TOP_LEFT:return{enter:"v-toast--fade-in-down",leave:"v-toast--fade-out"};case l.BOTTOM:case l.BOTTOM_RIGHT:case l.BOTTOM_LEFT:return{enter:"v-toast--fade-in-up",leave:"v-toast--fade-out"}}}},beforeUnmount(){u.off("toast-clear",this.dismiss)}});const d=(0,o(661).default)(p,[["render",function(o,i,n,r,a,l){return(0,t.openBlock)(),(0,t.createBlock)(t.Transition,{"enter-active-class":o.transition.enter,"leave-active-class":o.transition.leave},{default:(0,t.withCtx)((()=>[(0,t.withDirectives)((0,t.createElementVNode)("div",{ref:"root",role:"alert",class:(0,t.normalizeClass)(["v-toast__item",[`v-toast__item--${o.type}`,`v-toast__item--${o.position}`]]),onMouseover:i[0]||(i[0]=t=>o.toggleTimer(!0)),onMouseleave:i[1]||(i[1]=t=>o.toggleTimer(!1)),onClick:i[2]||(i[2]=function(){return o.whenClicked&&o.whenClicked(...arguments)})},[e,(0,t.createElementVNode)("p",{class:"v-toast__text",innerHTML:o.message},null,8,s)],34),[[t.vShow,o.isActive]])])),_:1},8,["enter-active-class","leave-active-class"])}]]),m=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{open(e){let s=null;"string"==typeof e&&(s=e);const o={message:s},i=Object.assign({},o,t,e);return{dismiss:r(d,i,document.body).ctx.dismiss}},clear(){u.emit("toast-clear")},success(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"success"},e))},error(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"error"},e))},info(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"info"},e))},warning(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"warning"},e))},default(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.open(Object.assign({},{message:t,type:"default"},e))}}},h={install:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=m(e);t.config.globalProperties.$toast=s,t.provide("$toast",s)}},v=h})(),i})())); |
{ | ||
"name": "vue-toast-notification", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"description": "Vue.js toast notification plugin", | ||
"main": "dist/index.js", | ||
"types": "./types/toast.d.ts", | ||
"browser": "dist/index.min.js", | ||
"style": "dist/theme-default.css", | ||
"style": "dist/theme-bootstrap.css", | ||
"files": [ | ||
@@ -41,28 +40,28 @@ "src", | ||
"devDependencies": { | ||
"@babel/core": "^7.17.10", | ||
"@babel/preset-env": "^7.17.10", | ||
"@vue/compiler-sfc": "^3.2.33", | ||
"@vue/test-utils": "^2.0.0-rc.21", | ||
"@vue/vue3-jest": "^27.0.0", | ||
"babel-jest": "^27.4.2", | ||
"babel-loader": "^8.2.5", | ||
"bootstrap": "^4.5.3", | ||
"clean-webpack-plugin": "^4.0.0", | ||
"@babel/core": "^7.20.12", | ||
"@babel/preset-env": "^7.20.2", | ||
"@vue/compiler-sfc": "^3.2.45", | ||
"@vue/test-utils": "^2.2.7", | ||
"@vue/vue3-jest": "^29.2.2", | ||
"babel-jest": "^29.3.1", | ||
"babel-loader": "^9.1.2", | ||
"bootstrap": "^4.6.2", | ||
"cross-env": "^7.0.3", | ||
"css-loader": "^6.7.1", | ||
"css-loader": "^6.7.3", | ||
"file-loader": "^6.2.0", | ||
"html-webpack-plugin": "^5.3.2", | ||
"jest": "^27.0.6", | ||
"mini-css-extract-plugin": "^2.6.0", | ||
"html-webpack-plugin": "^5.5.0", | ||
"jest": "^29.3.1", | ||
"jest-environment-jsdom": "^29.3.1", | ||
"mini-css-extract-plugin": "^2.7.2", | ||
"mitt": "^3.0.0", | ||
"sass": "~1.51.0", | ||
"sass-loader": "^12.6.0", | ||
"style-loader": "^3.0.0", | ||
"svg-url-loader": "^7.1.1", | ||
"vue": "^3.2.33", | ||
"vue-loader": "^17.0.0", | ||
"webpack": "^5.72.0", | ||
"webpack-cli": "^4.9.2", | ||
"webpack-dev-server": "^4.8.1", | ||
"webpack-remove-empty-scripts": "^0.8.0" | ||
"sass": "~1.57.1", | ||
"sass-loader": "^13.2.0", | ||
"style-loader": "^3.3.1", | ||
"svg-url-loader": "^8.0.0", | ||
"vue": "^3.2.45", | ||
"vue-loader": "^17.0.1", | ||
"webpack": "^5.75.0", | ||
"webpack-cli": "^5.0.1", | ||
"webpack-dev-server": "^4.11.1", | ||
"webpack-remove-empty-scripts": "^1.0.1" | ||
}, | ||
@@ -69,0 +68,0 @@ "peerDependencies": { |
@@ -30,14 +30,15 @@ # Vue Toast Notification | ||
### Plugin usage | ||
```js | ||
import {createApp} from 'vue'; | ||
import VueToast from 'vue-toast-notification'; | ||
import ToastPlugin from 'vue-toast-notification'; | ||
// Import one of the available themes | ||
//import 'vue-toast-notification/dist/theme-default.css'; | ||
import 'vue-toast-notification/dist/theme-sugar.css'; | ||
import 'vue-toast-notification/dist/theme-bootstrap.css'; | ||
const app = createApp({}); | ||
app.use(VueToast); | ||
app.use(ToastPlugin); | ||
app.mount('#app'); | ||
//Vue.$toast.open({/* options */}); | ||
let instance = app.$toast.open('You did it!'); | ||
@@ -47,2 +48,3 @@ | ||
instance.dismiss(); | ||
// Dismiss all opened toast immediately | ||
@@ -52,2 +54,22 @@ app.$toast.clear(); | ||
### Composition API usage | ||
```js | ||
import {createApp} from 'vue'; | ||
import {useToast} from 'vue-toast-notification'; | ||
import 'vue-toast-notification/dist/theme-sugar.css'; | ||
const app = createApp({}); | ||
app.mount('#app'); | ||
const $toast = useToast(); | ||
let instance = $toast.success('You did it!'); | ||
// Force dismiss specific toast | ||
instance.dismiss(); | ||
// Dismiss all opened toast immediately | ||
$toast.clear(); | ||
``` | ||
## Available options | ||
@@ -144,5 +166,5 @@ | ||
* Clone this repo | ||
* Make sure you have node-js `>=16.9` and [pnpm](https://pnpm.io/) `>=7.0` pre-installed | ||
* Make sure you have node-js `>=18.14` and [pnpm](https://pnpm.io/) `>=7.25` pre-installed | ||
* Install dependencies - `pnpm install` | ||
* Run webpack dev server - `npm start` | ||
* Run webpack dev server - `pnpm start` | ||
* This should open the demo page in your default web browser | ||
@@ -149,0 +171,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55292
29
607
175