UNPKG

dear-toast

Version:

一个基于Vue的通用Toast组件

1 lines 16.7 kB
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.DearToast=n():t.DearToast=n()}(window,function(){return function(e){var r={};function o(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=r,o.d=function(t,n,e){o.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(n,t){if(1&t&&(n=o(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(o.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var r in n)o.d(e,r,function(t){return n[t]}.bind(null,r));return e},o.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(n,"a",n),n},o.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},o.p="",o(o.s=17)}([function(t,n){var e=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=e)},function(t,n,e){t.exports=!e(7)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,e){"use strict";e.r(n);var r=e(3),o=e.n(r);for(var i in r)"default"!==i&&function(t){e.d(n,t,function(){return r[t]})}(i);n.default=o.a},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default={name:"toast",data:function(){return{theme:null,show:!1,type:"info",content:null,duration:null,onShow:null,onClose:null}},methods:{onHidden:function(t){"toastAnimateHidden"===t.animationName&&(document.body.removeChild(this.$el),this.onClose&&this.onClose({content:this.content}))}},mounted:function(){this.onShow&&this.onShow({content:this.content})}}},function(t,n,e){var r=e(49);"string"==typeof r&&(r=[[t.i,r,""]]);var o={hmr:!0,transform:void 0,insertInto:void 0};e(51)(r,o);r.locals&&(t.exports=r.locals)},function(t,n){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n,e){"use strict";var r=function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("div",{staticClass:"dear-toast-widget show-toast",style:"animation-delay: 0s, "+t.duration+"ms;",on:{animationend:t.onHidden,webkitAnimationEnd:t.onHidden}},[e("div",{staticClass:"toast-content",class:t.type,domProps:{textContent:t._s(t.content)}})])},o=[];r._withStripped=!0,e.d(n,"a",function(){return r}),e.d(n,"b",function(){return o})},function(t,n,e){var h=e(5),b=e(0),y=e(21),m=e(23),x=e(11),w="prototype",g=function(t,n,e){var r,o,i,a=t&g.F,u=t&g.G,s=t&g.S,c=t&g.P,f=t&g.B,l=t&g.W,p=u?b:b[n]||(b[n]={}),d=p[w],v=u?h:s?h[n]:(h[n]||{})[w];for(r in u&&(e=n),e)(o=!a&&v&&void 0!==v[r])&&x(p,r)||(i=o?v[r]:e[r],p[r]=u&&"function"!=typeof v[r]?e[r]:f&&o?y(i,h):l&&v[r]==i?function(r){var t=function(t,n,e){if(this instanceof r){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,e)}return r.apply(this,arguments)};return t[w]=r[w],t}(i):c&&"function"==typeof i?y(Function.call,i):i,c&&((p.virtual||(p.virtual={}))[r]=i,t&g.R&&d&&!d[r]&&m(d,r,i)))};g.F=1,g.G=2,g.S=4,g.P=8,g.B=16,g.W=32,g.U=64,g.R=128,t.exports=g},function(t,n,e){var r=e(24),o=e(25),i=e(27),a=Object.defineProperty;n.f=e(1)?Object.defineProperty:function(t,n,e){if(r(t),n=i(n,!0),r(e),o)try{return a(t,n,e)}catch(t){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(t[n]=e.value),t}},function(t,n){var e={}.hasOwnProperty;t.exports=function(t,n){return e.call(t,n)}},function(t,n,e){var r=e(13),o=e(14);t.exports=function(t){return r(o(t))}},function(t,n,e){var r=e(32);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},function(t,n){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,n){var e=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(0<t?r:e)(t)}},function(t,n,e){"use strict";function r(t,n,e,r,o,i,a,u){var s,c="function"==typeof t?t.options:t;if(n&&(c.render=n,c.staticRenderFns=e,c._compiled=!0),r&&(c.functional=!0),i&&(c._scopeId="data-v-"+i),a?(s=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},c._ssrRegister=s):o&&(s=u?function(){o.call(this,this.$root.$options.shadowRoot)}:o),s)if(c.functional){c._injectStyles=s;var f=c.render;c.render=function(t,n){return s.call(n),f(t,n)}}else{var l=c.beforeCreate;c.beforeCreate=l?[].concat(l,s):[s]}return{exports:t,options:c}}e.d(n,"a",function(){return r})},function(t,n,i){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var a=e(i(18)),u=e(i(44));function e(t){return t&&t.__esModule?t:{default:t}}n.default={install:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=1,o=t.extend(i(47).default);(0,u.default)(t.prototype,e.prefix||"$toast",{value:function(t){"string"!=typeof t&&"number"!=typeof t||(t={content:t});var n=new o({data:(0,a.default)({},{show:!0,duration:e.duration||1400},t)});return n.id="dear-toast-"+r,n.vm=n.$mount(),n.dom=n.vm.$el,n.dom.style.zIndex=1e3+r,document.body.appendChild(n.dom),r++,n}})}}},function(t,n,e){t.exports={default:e(19),__esModule:!0}},function(t,n,e){e(20),t.exports=e(0).Object.assign},function(t,n,e){var r=e(9);r(r.S+r.F,"Object",{assign:e(29)})},function(t,n,e){var i=e(22);t.exports=function(r,o,t){if(i(r),void 0===o)return r;switch(t){case 1:return function(t){return r.call(o,t)};case 2:return function(t,n){return r.call(o,t,n)};case 3:return function(t,n,e){return r.call(o,t,n,e)}}return function(){return r.apply(o,arguments)}}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,e){var r=e(10),o=e(28);t.exports=e(1)?function(t,n,e){return r.f(t,n,o(1,e))}:function(t,n,e){return t[n]=e,t}},function(t,n,e){var r=e(6);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,n,e){t.exports=!e(1)&&!e(7)(function(){return 7!=Object.defineProperty(e(26)("div"),"a",{get:function(){return 7}}).a})},function(t,n,e){var r=e(6),o=e(5).document,i=r(o)&&r(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,n,e){var o=e(6);t.exports=function(t,n){if(!o(t))return t;var e,r;if(n&&"function"==typeof(e=t.toString)&&!o(r=e.call(t)))return r;if("function"==typeof(e=t.valueOf)&&!o(r=e.call(t)))return r;if(!n&&"function"==typeof(e=t.toString)&&!o(r=e.call(t)))return r;throw TypeError("Can't convert object to primitive value")}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,e){"use strict";var p=e(30),d=e(41),v=e(42),h=e(43),b=e(13),o=Object.assign;t.exports=!o||e(7)(function(){var t={},n={},e=Symbol(),r="abcdefghijklmnopqrst";return t[e]=7,r.split("").forEach(function(t){n[t]=t}),7!=o({},t)[e]||Object.keys(o({},n)).join("")!=r})?function(t,n){for(var e=h(t),r=arguments.length,o=1,i=d.f,a=v.f;o<r;)for(var u,s=b(arguments[o++]),c=i?p(s).concat(i(s)):p(s),f=c.length,l=0;l<f;)a.call(s,u=c[l++])&&(e[u]=s[u]);return e}:o},function(t,n,e){var r=e(31),o=e(40);t.exports=Object.keys||function(t){return r(t,o)}},function(t,n,e){var a=e(11),u=e(12),s=e(33)(!1),c=e(36)("IE_PROTO");t.exports=function(t,n){var e,r=u(t),o=0,i=[];for(e in r)e!=c&&a(r,e)&&i.push(e);for(;n.length>o;)a(r,e=n[o++])&&(~s(i,e)||i.push(e));return i}},function(t,n){var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},function(t,n,e){var s=e(12),c=e(34),f=e(35);t.exports=function(u){return function(t,n,e){var r,o=s(t),i=c(o.length),a=f(e,i);if(u&&n!=n){for(;a<i;)if((r=o[a++])!=r)return!0}else for(;a<i;a++)if((u||a in o)&&o[a]===n)return u||a||0;return!u&&-1}}},function(t,n,e){var r=e(15),o=Math.min;t.exports=function(t){return 0<t?o(r(t),9007199254740991):0}},function(t,n,e){var r=e(15),o=Math.max,i=Math.min;t.exports=function(t,n){return(t=r(t))<0?o(t+n,0):i(t,n)}},function(t,n,e){var r=e(37)("keys"),o=e(39);t.exports=function(t){return r[t]||(r[t]=o(t))}},function(t,n,e){var r=e(0),o=e(5),i="__core-js_shared__",a=o[i]||(o[i]={});(t.exports=function(t,n){return a[t]||(a[t]=void 0!==n?n:{})})("versions",[]).push({version:r.version,mode:e(38)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(t,n){t.exports=!0},function(t,n){var e=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++e+r).toString(36))}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,e){var r=e(14);t.exports=function(t){return Object(r(t))}},function(t,n,e){t.exports={default:e(45),__esModule:!0}},function(t,n,e){e(46);var r=e(0).Object;t.exports=function(t,n,e){return r.defineProperty(t,n,e)}},function(t,n,e){var r=e(9);r(r.S+r.F*!e(1),"Object",{defineProperty:e(10).f})},function(t,n,e){"use strict";e.r(n);var r=e(8),o=e(2);for(var i in o)"default"!==i&&function(t){e.d(n,t,function(){return o[t]})}(i);e(48);var a=e(16),u=Object(a.a)(o.default,r.a,r.b,!1,null,null,null);u.options.__file="src/toast.vue",n.default=u.exports},function(t,n,e){"use strict";var r=e(4);e.n(r).a},function(t,n,e){(t.exports=e(50)(!1)).push([t.i,"\n.dear-toast-widget{position:fixed;top:60%;left:50%;margin:0 auto;will-change:auto;text-align:center;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);-webkit-animation-name:toastAnimateShow,toastAnimateHidden;animation-name:toastAnimateShow,toastAnimateHidden;-webkit-animation-duration:.5s,.4s;animation-duration:.5s,.4s\n}\n@-webkit-keyframes toastAnimateShow{\n0%{opacity:0;top:65%\n}\nto{opacity:1;top:60%\n}\n}\n@keyframes toastAnimateShow{\n0%{opacity:0;top:65%\n}\nto{opacity:1;top:60%\n}\n}\n@-webkit-keyframes toastAnimateHidden{\nto{opacity:0;top:65%\n}\n}\n@keyframes toastAnimateHidden{\nto{opacity:0;top:65%\n}\n}\n.dear-toast-widget .toast-content{max-width:80vw;max-height:30vh;padding:8px 10px;color:#fff;overflow:auto;border-radius:18px;-webkit-box-shadow:0 0 15px 4px rgba(0,0,0,.1);box-shadow:0 0 15px 4px rgba(0,0,0,.1)\n}\n.dear-toast-widget .toast-content.info{background-color:rgba(58,58,58,.9)\n}\n.dear-toast-widget .toast-content.error{background-color:rgba(244,129,73,.9)\n}",""])},function(t,n){t.exports=function(e){var a=[];return a.toString=function(){return this.map(function(t){var n=function(t,n){var e=t[1]||"",r=t[3];if(!r)return e;if(n&&"function"==typeof btoa){var o=(a=r,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */"),i=r.sources.map(function(t){return"/*# sourceURL="+r.sourceRoot+t+" */"});return[e].concat(i).concat([o]).join("\n")}var a;return[e].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},a.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var e={},r=0;r<this.length;r++){var o=this[r][0];"number"==typeof o&&(e[o]=!0)}for(r=0;r<t.length;r++){var i=t[r];"number"==typeof i[0]&&e[i[0]]||(n&&!i[2]?i[2]=n:n&&(i[2]="("+i[2]+") and ("+n+")"),a.push(i))}},a}},function(t,n,e){var r,o,i,s={},c=(r=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===o&&(o=r.apply(this,arguments)),o}),a=(i={},function(t){if("function"==typeof t)return t();if(void 0===i[t]){var n=function(t){return document.querySelector(t)}.call(this,t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}i[t]=n}return i[t]}),f=null,l=0,u=[],p=e(52);function d(t,n){for(var e=0;e<t.length;e++){var r=t[e],o=s[r.id];if(o){o.refs++;for(var i=0;i<o.parts.length;i++)o.parts[i](r.parts[i]);for(;i<r.parts.length;i++)o.parts.push(x(r.parts[i],n))}else{var a=[];for(i=0;i<r.parts.length;i++)a.push(x(r.parts[i],n));s[r.id]={id:r.id,refs:1,parts:a}}}}function v(t,n){for(var e=[],r={},o=0;o<t.length;o++){var i=t[o],a=n.base?i[0]+n.base:i[0],u={css:i[1],media:i[2],sourceMap:i[3]};r[a]?r[a].parts.push(u):e.push(r[a]={id:a,parts:[u]})}return e}function h(t,n){var e=a(t.insertInto);if(!e)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var r=u[u.length-1];if("top"===t.insertAt)r?r.nextSibling?e.insertBefore(n,r.nextSibling):e.appendChild(n):e.insertBefore(n,e.firstChild),u.push(n);else if("bottom"===t.insertAt)e.appendChild(n);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var o=a(t.insertInto+" "+t.insertAt.before);e.insertBefore(n,o)}}function b(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var n=u.indexOf(t);0<=n&&u.splice(n,1)}function y(t){var n=document.createElement("style");return void 0===t.attrs.type&&(t.attrs.type="text/css"),m(n,t.attrs),h(t,n),n}function m(n,e){Object.keys(e).forEach(function(t){n.setAttribute(t,e[t])})}function x(n,t){var e,r,o,i,a,u;if(t.transform&&n.css){if(!(i=t.transform(n.css)))return function(){};n.css=i}if(t.singleton){var s=l++;e=f||(f=y(t)),r=_.bind(null,e,s,!1),o=_.bind(null,e,s,!0)}else o=n.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(a=t,u=document.createElement("link"),void 0===a.attrs.type&&(a.attrs.type="text/css"),a.attrs.rel="stylesheet",m(u,a.attrs),h(a,u),r=function(t,n,e){var r=e.css,o=e.sourceMap,i=void 0===n.convertToAbsoluteUrls&&o;(n.convertToAbsoluteUrls||i)&&(r=p(r));o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var a=new Blob([r],{type:"text/css"}),u=t.href;t.href=URL.createObjectURL(a),u&&URL.revokeObjectURL(u)}.bind(null,e=u,t),function(){b(e),e.href&&URL.revokeObjectURL(e.href)}):(e=y(t),r=function(t,n){var e=n.css,r=n.media;r&&t.setAttribute("media",r);if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}.bind(null,e),function(){b(e)});return r(n),function(t){if(t){if(t.css===n.css&&t.media===n.media&&t.sourceMap===n.sourceMap)return;r(n=t)}else o()}}t.exports=function(t,a){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(a=a||{}).attrs="object"==typeof a.attrs?a.attrs:{},a.singleton||"boolean"==typeof a.singleton||(a.singleton=c()),a.insertInto||(a.insertInto="head"),a.insertAt||(a.insertAt="bottom");var u=v(t,a);return d(u,a),function(t){for(var n=[],e=0;e<u.length;e++){var r=u[e];(o=s[r.id]).refs--,n.push(o)}t&&d(v(t,a),a);for(e=0;e<n.length;e++){var o;if(0===(o=n[e]).refs){for(var i=0;i<o.parts.length;i++)o.parts[i]();delete s[o.id]}}}};var w,g=(w=[],function(t,n){return w[t]=n,w.filter(Boolean).join("\n")});function _(t,n,e,r){var o=e?"":r.css;if(t.styleSheet)t.styleSheet.cssText=g(n,o);else{var i=document.createTextNode(o),a=t.childNodes;a[n]&&t.removeChild(a[n]),a.length?t.insertBefore(i,a[n]):t.appendChild(i)}}},function(t,n){t.exports=function(t){var n="undefined"!=typeof window&&window.location;if(!n)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var o=n.protocol+"//"+n.host,i=o+n.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(t,n){var e,r=n.trim().replace(/^"(.*)"$/,function(t,n){return n}).replace(/^'(.*)'$/,function(t,n){return n});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(r)?t:(e=0===r.indexOf("//")?r:0===r.indexOf("/")?o+r:i+r.replace(/^\.\//,""),"url("+JSON.stringify(e)+")")})}}]).default});