@beeapi/nutui
Version:
一套轻量级移动端Vue组件库
7 lines • 7.13 kB
JavaScript
/*!
* @beeapi/nutui v2.2.10 - toast.js, 451ed2404bee284b891e, Sat Dec 19 2020 12:06:10 GMT+0800 (中国标准时间)
* (c) 2017-2020 JDC
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define("toast",["vue"],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=151)}({0:function(t,e,n){"use strict";function o(t,e,n,o,r,i,s,a){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),o&&(u.functional=!0),i&&(u._scopeId="data-v-"+i),s?(c=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__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},u._ssrRegister=c):r&&(c=a?function(){r.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:r),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:u}}n.d(e,"a",(function(){return o}))},1:function(e,n){e.exports=t},151:function(t,e,n){"use strict";n.r(e);var o=n(2),r=n.n(o),i=n(3),s=n.n(i),a=n(1),c=n.n(a),u={name:"nut-toast",props:{},data:function(){return{id:"",msg:"",visible:!1,duration:2e3,timer:null,center:!0,type:"",customClass:"",bottom:30,size:"base",icon:null,textAlignCenter:!0,loadingRotate:!0,bgColor:"rgba(46, 46, 46, 0.7)",onClose:null,textTimer:null,cover:!1,coverColor:"rgba(0, 0, 0, 0)",toastStyle:{},toastClass:"",timeStamp:null,closeOnClickOverlay:!1}},watch:{visible:function(t){t&&this.show()}},computed:{cusIcon:function(){return this.icon?'url("'.concat(this.icon,'")'):""},toastBodyClass:function(){return["nut-toast",{"nut-toast-center":this.center},{"nut-toast-has-icon":this.hasIcon},{"nut-toast-cover":this.cover},{"nut-loading":"loading"==this.type},this.customClass,"nut-toast-"+this.size]},hasIcon:function(){return"text"!==this.type||this.cusIcon}},methods:{show:function(t){var e=this;this.clearTimer(),clearTimeout(this.textTimer),this.duration&&(this.timer=setTimeout((function(){e.hide(t)}),this.duration))},hide:function(t){var e=this;this.clearTimer(),this.visible=!1,t?clearTimeout(this.textTimer):this.textTimer=setTimeout((function(){clearTimeout(e.textTimer),e.msg=""}),300),"function"==typeof this.onClose&&this.onClose()},clearTimer:function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},clickCover:function(){this.closeOnClickOverlay&&this.hide()}},destroyed:function(){this.textTimer=null,this.timer=null}},l=n(0),f=Object(l.a)(u,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("transition",{attrs:{name:"toastfade"}},[t.visible?n("div",{class:t.toastBodyClass,style:{bottom:t.center?"auto":t.bottom+"px","background-color":t.coverColor},attrs:{id:t.id},on:{click:t.clickCover}},[n("div",{staticClass:"nut-toast-inner",class:t.toastClass,style:Object.assign({},{"text-align":t.textAlignCenter?"center":"left","background-color":t.bgColor},t.toastStyle)},[t.hasIcon?n("span",{staticClass:"nut-toast-icon-wrapper"},[n("i",{class:["nut-toast-icon",t.type,{"nut-toast-icon-rotate":"loading"===t.type&&t.loadingRotate}],style:{"background-image":t.cusIcon}})]):t._e(),t._v(" "),n("span",{staticClass:"nut-toast-text",domProps:{innerHTML:t._s(t.msg)}})])]):t._e()])}),[],!1,null,null,null).exports;function d(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function p(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?d(Object(n),!0).forEach((function(e){s()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var m,v=c.a.extend(f),h=[],b={},y={msg:"",visible:!1,duration:2e3,timer:null,center:!0,type:"",customClass:"",bottom:30,size:"base",icon:null,textAlignCenter:!0,loadingRotate:!0,bgColor:"rgba(36, 36, 36, 0.8)",onClose:null,textTimer:null,cover:!1,coverColor:"rgba(0, 0, 0, 0)",timeStamp:null,closeOnClickOverlay:!1},g=p({},y);function O(t){var e=p(p(p({id:(new Date).getTime()},g),b[t.type]),t);return e.id&&h[e.id]?((m=h[e.id]).hide(!0),m=r()(m,e)):(m=new v({data:r()(e,t)}),e.id&&(h[e.id]=m)),m.vm=m.$mount(),document.body.appendChild(m.$el),c.a.nextTick((function(){m.visible=!0})),m}function C(t){t||console.warn("[NutUI Toast]: msg不能为空")}var x={text:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return C(t),O(p(p({},e),{},{msg:t,type:"text"}))},success:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return C(t),O(p(p({},e),{},{msg:t,type:"success"}))},fail:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return C(t),O(p(p({},e),{},{msg:t,type:"fail"}))},warn:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return C(t),O(p(p({},e),{},{msg:t,type:"warn"}))},loading:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(e=p(p({},e),{},{id:e.id||"loading",msg:t,type:"loading"})).cover=void 0===e.cover||e.cover,e.duration=e.duration||0,O(e)},setDefaultOptions:function(t,e){"string"==typeof t?b[t]=e:r()(g,t)},resetDefaultOptions:function(t){"string"==typeof t?b[t]=null:(g=p({},y),b={})}};n(80);x.install=function(t){t.prototype.$toast=x};e.default=x},2:function(t,e){function n(){return t.exports=n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},n.apply(this,arguments)}t.exports=n},3:function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},80:function(t,e,n){}})}));
//# sourceMappingURL=toast.js.map