jiku-ui
Version:
A Component Library for Vue.js.
2 lines (1 loc) • 6.11 kB
JavaScript
module.exports=function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},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=94)}({0:function(t,e,n){"use strict";function i(t,e,n,i,o,s,r,a){var c,l="function"==typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=n,l._compiled=!0),i&&(l.functional=!0),s&&(l._scopeId="data-v-"+s),r?(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__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(r)},l._ssrRegister=c):o&&(c=a?function(){o.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:o),c)if(l.functional){l._injectStyles=c;var u=l.render;l.render=function(t,e){return c.call(e),u(t,e)}}else{var f=l.beforeCreate;l.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:l}}n.d(e,"a",(function(){return i}))},14:function(t,e){t.exports=require("jiku-ui/lib/utils/popup")},25:function(t,e){t.exports=require("jiku-ui/lib/utils/vdom")},7:function(t,e){t.exports=require("vue")},9:function(t,e){t.exports=require("jiku-ui/lib/utils/merge")},94:function(t,e,n){"use strict";n.r(e);var i=n(7),o=n.n(i),s=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("transition",{attrs:{name:"hn-notification-fade"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:t.visible,expression:"visible"}],class:["hn-notification",t.customClass,t.horizontalClass],style:t.positionStyle,attrs:{role:"alert"},on:{mouseenter:function(e){return t.clearTimer()},mouseleave:function(e){return t.startTimer()},click:t.click}},[t.type||t.iconClass?n("i",{staticClass:"hn-notification__icon",class:[t.typeClass,t.iconClass]}):t._e(),n("div",{staticClass:"hn-notification__group",class:{"is-with-icon":t.typeClass||t.iconClass}},[n("h2",{staticClass:"hn-notification__title",domProps:{textContent:t._s(t.title)}}),n("div",{directives:[{name:"show",rawName:"v-show",value:t.message,expression:"message"}],staticClass:"hn-notification__content"},[t._t("default",[t.dangerouslyUseHTMLString?n("p",{domProps:{innerHTML:t._s(t.message)}}):n("p",[t._v(t._s(t.message))])])],2),t.showClose?n("div",{staticClass:"hn-notification__closeBtn hn-icon-close",on:{click:function(e){return e.stopPropagation(),t.close(e)}}}):t._e()])])])};s._withStripped=!0;var r={success:"success",info:"info",warning:"warning",error:"error"},a={data:function(){return{visible:!1,title:"",message:"",duration:4500,type:"",showClose:!0,customClass:"",iconClass:"",onClose:null,onClick:null,closed:!1,verticalOffset:0,timer:null,dangerouslyUseHTMLString:!1,position:"top-right"}},computed:{typeClass:function(){return this.type&&r[this.type]?"hn-icon-"+r[this.type]:""},horizontalClass:function(){return this.position.indexOf("right")>-1?"right":"left"},verticalProperty:function(){return/^top-/.test(this.position)?"top":"bottom"},positionStyle:function(){var t;return(t={})[this.verticalProperty]=this.verticalOffset+"px",t}},watch:{closed:function(t){t&&(this.visible=!1,this.$el.addEventListener("transitionend",this.destroyElement))}},methods:{destroyElement:function(){this.$el.removeEventListener("transitionend",this.destroyElement),this.$destroy(!0),this.$el.parentNode.removeChild(this.$el)},click:function(){"function"==typeof this.onClick&&this.onClick()},close:function(){this.closed=!0,"function"==typeof this.onClose&&this.onClose()},clearTimer:function(){clearTimeout(this.timer)},startTimer:function(){var t=this;this.duration>0&&(this.timer=setTimeout((function(){t.closed||t.close()}),this.duration))},keydown:function(t){46===t.keyCode||8===t.keyCode?this.clearTimer():27===t.keyCode?this.closed||this.close():this.startTimer()}},mounted:function(){var t=this;this.duration>0&&(this.timer=setTimeout((function(){t.closed||t.close()}),this.duration)),document.addEventListener("keydown",this.keydown)},beforeDestroy:function(){document.removeEventListener("keydown",this.keydown)}},c=n(0),l=Object(c.a)(a,s,[],!1,null,null,null);l.options.__file="packages/notification/src/main.vue";var u=l.exports,f=n(9),d=n.n(f),p=n(14),h=n(25),m=o.a.extend(u),v=void 0,y=[],_=1,C=function t(e){if(!o.a.prototype.$isServer){var n=(e=d()({},e)).onClose,i="notification_"+_++,s=e.position||"top-right";e.onClose=function(){t.close(i,n)},v=new m({data:e}),Object(h.isVNode)(e.message)&&(v.$slots.default=[e.message],e.message="REPLACED_BY_VNODE"),v.id=i,v.$mount(),document.body.appendChild(v.$el),v.visible=!0,v.dom=v.$el,v.dom.style.zIndex=p.PopupManager.nextZIndex();var r=e.offset||0;return y.filter((function(t){return t.position===s})).forEach((function(t){r+=t.$el.offsetHeight+16})),r+=16,v.verticalOffset=r,y.push(v),v}};["success","warning","info","error"].forEach((function(t){C[t]=function(e){return("string"==typeof e||Object(h.isVNode)(e))&&(e={message:e}),e.type=t,C(e)}})),C.close=function(t,e){var n=-1,i=y.length,o=y.filter((function(e,i){return e.id===t&&(n=i,!0)}))[0];if(o&&("function"==typeof e&&e(o),y.splice(n,1),!(i<=1)))for(var s=o.position,r=o.dom.offsetHeight,a=n;a<i-1;a++)y[a].position===s&&(y[a].dom.style[o.verticalProperty]=parseInt(y[a].dom.style[o.verticalProperty],10)-r-16+"px")},C.closeAll=function(){for(var t=y.length-1;t>=0;t--)y[t].close()};var g=C;e.default=g}}).default;