element-gui
Version:
A Component Library for Vue.js.
1 lines • 8.46 kB
JavaScript
module.exports=function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/dist/",o(o.s=84)}({0:function(e,t,o){"use strict";function n(e,t,o,n,i,r,s,c){var a,l="function"==typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=o,l._compiled=!0),n&&(l.functional=!0),r&&(l._scopeId="data-v-"+r),s?(a=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},l._ssrRegister=a):i&&(a=c?function(){i.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:i),a)if(l.functional){l._injectStyles=a;var u=l.render;l.render=function(e,t){return a.call(t),u(e,t)}}else{var h=l.beforeCreate;l.beforeCreate=h?[].concat(h,a):[a]}return{exports:e,options:l}}o.d(t,"a",(function(){return n}))},2:function(e,t){e.exports=require("element-gui/lib/utils/util")},3:function(e,t){e.exports=require("element-gui/lib/utils/dom")},5:function(e,t){e.exports=require("element-gui/lib/utils/vue-popper")},8:function(e,t){e.exports=require("vue")},84:function(e,t,o){"use strict";o.r(t);var n=function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("span",[o("transition",{attrs:{name:e.transition},on:{"after-enter":e.handleAfterEnter,"after-leave":e.handleAfterLeave}},[o("div",{directives:[{name:"show",rawName:"v-show",value:!e.disabled&&e.showPopper,expression:"!disabled && showPopper"}],ref:"popper",staticClass:"el-popover el-popper",class:[e.popperClass,e.content&&"el-popover--plain"],style:{width:e.formateWidth,maxWidth:e.formateMaxWidth},attrs:{role:"tooltip",id:e.tooltipId,"aria-hidden":e.disabled||!e.showPopper?"true":"false"}},[e.title?o("div",{staticClass:"el-popover__title",domProps:{textContent:e._s(e.title)}}):e._e(),e._t("default",[e._v(e._s(e.content))])],2)]),o("span",{ref:"wrapper",staticClass:"el-popover__reference-wrapper"},[e._t("reference")],2)],1)};n._withStripped=!0;var i=o(5),r=o.n(i),s=o(3),c=o(2),a={name:"ElPopover",mixins:[r.a],props:{trigger:{type:String,default:"click",validator:function(e){return["click","focus","hover","contextmenu","manual"].indexOf(e)>-1}},openDelay:{type:Number,default:0},closeDelay:{type:Number,default:200},title:String,disabled:Boolean,content:String,reference:{},popperClass:String,width:String,maxWidth:String,visibleArrow:{default:!0},arrowOffset:{type:Number,default:0},transition:{type:String,default:"fade-in-linear"},tabindex:{type:Number,default:0}},computed:{tooltipId:function(){return"el-popover-"+Object(c.generateId)()},formateWidth:function(){return/(%|px)/.test(this.width)?this.width:this.width+"px"},formateMaxWidth:function(){return/(%|px)/.test(this.maxWidth)?this.maxWidth:this.maxWidth+"px"}},watch:{showPopper:function(e){this.disabled||(e?this.$emit("show"):this.$emit("hide"))},disabled:function(e){!e&&this.showPopper&&this.updatePopper()}},mounted:function(){var e=this.referenceElm=this.reference||this.$refs.reference,t=this.popper||this.$refs.popper;!e&&this.$refs.wrapper.children&&(e=this.referenceElm=this.$refs.wrapper.children[0]),e&&(Object(s.addClass)(e,"el-popover__reference"),e.setAttribute("aria-describedby",this.tooltipId),e.setAttribute("tabindex",this.tabindex),t.setAttribute("tabindex",0),"click"!==this.trigger&&(Object(s.on)(e,"focusin",this.handleRefrenceFocus),Object(s.on)(t,"focusin",this.handlePopperFocus),Object(s.on)(e,"focusout",this.handleBlur),Object(s.on)(t,"focusout",this.handleBlur)),Object(s.on)(e,"keydown",this.handleKeydown),Object(s.on)(e,"click",this.handleClick),Object(s.on)(e,"contextmenu",this.handleClick)),"click"===this.trigger?(Object(s.on)(e,"click",this.doToggle),Object(s.on)(document,"click",this.handleDocumentClick)):"hover"===this.trigger?(Object(s.on)(e,"mouseenter",this.handleMouseEnter),Object(s.on)(t,"mouseenter",this.handleMouseEnter),Object(s.on)(e,"mouseleave",this.handleMouseLeave),Object(s.on)(t,"mouseleave",this.handleMouseLeave)):"contextmenu"===this.trigger?(Object(s.on)(e,"contextmenu",this.doToggle),Object(s.on)(document,"click",this.handleDocumentClick)):"focus"===this.trigger&&(this.tabindex<0&&console.warn("[Element Warn][Popover]a negative taindex means that the element cannot be focused by tab key"),e.querySelector("input, textarea")?(Object(s.on)(e,"focusin",this.doShow),Object(s.on)(e,"focusout",this.doClose)):(Object(s.on)(e,"mousedown",this.doShow),Object(s.on)(e,"mouseup",this.doClose)))},beforeDestroy:function(){this.cleanup()},deactivated:function(){this.cleanup(),this.doClose()},methods:{update:function(){this.$nextTick(this.updatePopper)},doToggle:function(e){"contextmenu"===this.trigger&&e.preventDefault(),this.showPopper=!this.showPopper},doShow:function(){this.showPopper=!0},doClose:function(){this.showPopper=!1},handleRefrenceFocus:function(){if(this.handlePopperFocus(),this.referenceElm){var e=this.referenceElm.__vue__;e&&"function"==typeof e.focus&&e.focus()}},handlePopperFocus:function(){Object(s.addClass)(this.referenceElm,"focusing"),"click"!==this.trigger&&"focus"!==this.trigger||(this.showPopper=!0)},handleClick:function(){Object(s.removeClass)(this.referenceElm,"focusing")},handleBlur:function(){Object(s.removeClass)(this.referenceElm,"focusing"),"click"!==this.trigger&&"focus"!==this.trigger||(this.showPopper=!1)},handleMouseEnter:function(){var e=this;clearTimeout(this._timer),this.openDelay?this._timer=setTimeout((function(){e.showPopper=!0}),this.openDelay):this.showPopper=!0},handleKeydown:function(e){27===e.keyCode&&"manual"!==this.trigger&&this.doClose()},handleMouseLeave:function(){var e=this;clearTimeout(this._timer),this.closeDelay?this._timer=setTimeout((function(){e.showPopper=!1}),this.closeDelay):this.showPopper=!1},handleDocumentClick:function(e){var t=this.reference||this.$refs.reference,o=this.popper||this.$refs.popper;!t&&this.$refs.wrapper.children&&(t=this.$refs.wrapper.children[0]),this.$el&&t&&!this.$el.contains(e.target)&&!t.contains(e.target)&&o&&!o.contains(e.target)&&(this.showPopper=!1)},handleAfterEnter:function(){this.$emit("after-enter")},handleAfterLeave:function(){this.$emit("after-leave"),this.doDestroy()},cleanup:function(){(this.openDelay||this.closeDelay)&&clearTimeout(this._timer)}},destroyed:function(){var e=this.referenceElm,t=this.popper||this.$refs.popper;Object(s.off)(document,"click",this.handleDocumentClick),Object(s.off)(e,"focusin",this.handleRefrenceFocus),Object(s.off)(e,"focusout",this.handleBlur),Object(s.off)(e,"keydown",this.handleKeydown),Object(s.off)(e,"click",this.handleClick),Object(s.off)(e,"click",this.doToggle),Object(s.off)(e,"contextmenu",this.handleClick),Object(s.off)(e,"contextmenu",this.doToggle),Object(s.off)(e,"mouseenter",this.handleMouseEnter),Object(s.off)(e,"mouseleave",this.handleMouseLeave),Object(s.off)(e,"focusin",this.doShow),Object(s.off)(e,"focusout",this.doClose),Object(s.off)(e,"mousedown",this.doShow),Object(s.off)(e,"mouseup",this.doClose),Object(s.off)(t,"focusin",this.handlePopperFocus),Object(s.off)(t,"focusout",this.handleBlur),Object(s.off)(t,"mouseenter",this.handleMouseEnter),Object(s.off)(t,"mouseleave",this.handleMouseLeave),this.referenceElm=void 0}},l=o(0),u=Object(l.a)(a,n,[],!1,null,null,null).exports,h=function(e,t,o){var n=t.expression?t.value:t.arg,i=o.context.$refs[n];i&&(Array.isArray(i)?i[0].$refs.reference=e:i.$refs.reference=e)},f={bind:function(e,t,o){h(e,t,o)},inserted:function(e,t,o){h(e,t,o)}},d=o(8);o.n(d).a.directive("popover",f),u.install=function(e){e.directive("popover",f),e.component(u.name,u)},u.directive=f;t.default=u}});