UNPKG

@zeit-ui/vue

Version:

A popular UI framework for Vue

2 lines 5.2 kB
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("vue")):"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["toast"]=e(require("vue")):t["toast"]=e(t["Vue"])})("undefined"!==typeof self?self:this,(function(t){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"8bbf":function(e,n){e.exports=t},b778:function(t,e,n){},d469:function(t,e,n){"use strict";var o=n("b778"),r=n.n(o);r.a},f6fd:function(t,e){(function(t){var e="currentScript",n=t.getElementsByTagName("script");e in t||Object.defineProperty(t,e,{get:function(){try{throw new Error}catch(o){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(o.stack)||[!1])[1];for(t in n)if(n[t].src==e||"interactive"==n[t].readyState)return n[t];return null}}})})(document)},fb15:function(t,e,n){"use strict";var o;(n.r(e),"undefined"!==typeof window)&&(n("f6fd"),(o=window.document.currentScript)&&(o=o.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=o[1]));var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"zi-toast-container"},[n("div",{staticClass:"zi-toast",class:t.type&&t.type},[n("span",{staticClass:"message",class:{action:t.action}},[t._v(t._s(t.text))]),t.action?n("zi-button",{attrs:{auto:"",ghost:"",size:"mini",type:t.type||"normal"},on:{click:function(e){t.handler&&t.handler()}}},[t._v(t._s(t.action))]):t._e()],1)])},i=[];function u(t){return u="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}var c={name:"zi-toast-template",data:function(){return{text:"",action:"",type:"",handler:function(){return{}}}},methods:{init:function(t){if("object"!==u(t))return this.text=t;var e=t.text,n=t.action,o=t.handler,r=t.type;this.text=e,this.action=n,this.handler=o,this.type=r}}},a=c;n("d469");function s(t,e,n,o,r,i,u,c){var a,s="function"===typeof t?t.options:t;if(e&&(s.render=e,s.staticRenderFns=n,s._compiled=!0),o&&(s.functional=!0),i&&(s._scopeId="data-v-"+i),u?(a=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(u)},s._ssrRegister=a):r&&(a=c?function(){r.call(this,this.$root.$options.shadowRoot)}:r),a)if(s.functional){s._injectStyles=a;var f=s.render;s.render=function(t,e){return a.call(e),f(t,e)}}else{var l=s.beforeCreate;s.beforeCreate=l?[].concat(l,a):[a]}return{exports:t,options:s}}var f=s(a,r,i,!1,null,null,null),l=f.exports,d=n("8bbf"),p=n.n(d);function y(t){return y="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}var m=p.a.extend(l),b=function(){var t=document.querySelector(".zi-toast-area");if(t)return t;var e=document.createElement("div");return e.classList.add("zi-toast-area"),document.body.appendChild(e),e},v=function(t,e,n){e.setAttribute("id","zi-toast-".concat(n)),t.appendChild(e);var o=setTimeout((function(){e.classList.add("visible"),clearTimeout(o)}),0)},h=function(t,e){var n=e?b():document.querySelector("#zi-toast-".concat(t));if(n){n.setAttribute("style","opacity: 0;");var o=setTimeout((function(){n.parentElement.removeChild(n),clearTimeout(o)}),500)}},_=function(t){var e=new m({mounted:function(){this.init(t)}});if(e.vm=e.$mount(),e.close=function(){return h(e._uid)},v(b(),e.vm.$el,e._uid),t.duration||void 0===t.duration)var n=Number.isNaN(+t.duration)?4500:t.duration,o=setTimeout((function(){e.close(),clearTimeout(o)}),n);return e},S=function(t,e){var n="object"!==y(t)?{text:t}:t;return Object.assign({},n,e)},x=function(){return{show:function(t){return _(t)},success:function(t){return this.show(S(t,{type:"success"}))},warning:function(t){return this.show(S(t,{type:"warning"}))},danger:function(t){return this.show(S(t,{type:"danger"}))},closeAll:function(){h(0,!0)}}},g={install:function(t){return t.prototype.$Toast=x(t)}};l.install=function(t){t.component(l.name,l),t.use(g)};var j=l;e["default"]=j}})["default"]})); //# sourceMappingURL=toast.umd.min.js.map