@zeit-ui/vue
Version:
A popular UI framework for Vue
2 lines • 7.55 kB
JavaScript
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["popover"]=e():t["popover"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));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="fb15")}({"23fb":function(t,e,n){},"7ce0":function(t,e,n){},"8efa":function(t,e,n){},a271:function(t,e,n){"use strict";var i=n("23fb"),r=n.n(i);r.a},ba8f:function(t,e,n){"use strict";var i=n("7ce0"),r=n.n(i);r.a},c6ba:function(t,e,n){"use strict";var i=n("8efa"),r=n.n(i);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(i){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(i.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";n.r(e);var i,r={};(n.r(r),n.d(r,"enums",(function(){return h})),n.d(r,"isMac",(function(){return v})),"undefined"!==typeof window)&&(n("f6fd"),(i=window.document.currentScript)&&(i=i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=i[1]));var o=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"popover",on:{click:function(t){t.stopPropagation()},mousemove:function(e){return t.hoverToggle(!0)},mouseleave:function(e){return t.hoverToggle(!1)}}},[n("span",{staticClass:"host",on:{click:function(e){return e.stopPropagation(),t.toggle(e)}}},[t._t("default")],2),n("transition",{attrs:{name:"zi-fade-in"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:t.visible,expression:"visible"}],staticClass:"dropdown",class:t.align},[n("PopoverIcon",{staticClass:"icon"}),n("div",{staticClass:"slot-container"},[t._t("dropdown")],2)],1)])],1)},a=[],s=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("svg",{attrs:{width:"24",height:"12",viewBox:"0 0 24 12"}},[n("path",{attrs:{fill:"var(--geist-background)","stroke-width":"1px",stroke:"var(--accents-2)","fill-rule":"evenodd",d:"M20 12l-8-8-12 12"}})])},l=[],u={name:"zi-popover-icon"},c=u;function f(t,e,n,i,r,o,a,s){var l,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),a?(l=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(a)},u._ssrRegister=l):r&&(l=s?function(){r.call(this,this.$root.$options.shadowRoot)}:r),l)if(u.functional){u._injectStyles=l;var c=u.render;u.render=function(t,e){return l.call(e),c(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,l):[l]}return{exports:t,options:u}}var d=f(c,s,l,!1,null,null,null),p=d.exports,h=function(t){return function(e){return!!Array.isArray(t)&&!!t.find((function(t){return t===e}))}},v=function(){if("undefined"===typeof window||!window.navigator)return!1;var t=navigator.userAgent.toLowerCase();return/macintosh|mac os x/i.test(t)},m=function(t){var e=t.getBoundingClientRect(),n=window.getComputedStyle(t),i=n.width,r=n.height,o=function(t,e){if(!t)return 0;var n=t.includes("px")?+t.split("px")[0]:t.includes("%")?+t.split("%")[0]*e*.01:t;return Number.isNaN(+n)?0:+n};return{width:o("".concat(i),e.width),height:o("".concat(r),e.height)}},g=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("transition",{attrs:{name:"expand"},on:{enter:t.enter,"after-enter":t.afterEnter,leave:t.leave}},[t._t("default")],2)},b=[],y={name:"zi-transition-expand",methods:{enter:function(t){var e=m(t),n=e.width;t.style.width="".concat(n,"px"),t.style.position="absolute",t.style.visibility="hidden",t.style.height="auto";var i=m(t),r=i.height;t.style.width=null,t.style.position=null,t.style.visibility=null,t.style.height=0,m(t);var o=setTimeout((function(){t.style.height="".concat(r,"px"),clearTimeout(o)}),0)},afterEnter:function(t){t.style.height="auto"},leave:function(t){var e=m(t),n=e.height;t.style.height="".concat(n,"px"),m(t);var i=setTimeout((function(){t.style.height=0,clearTimeout(i)}),0)},afterLeave:function(t){t.style.height=null}}},_=y,w=(n("ba8f"),f(_,g,b,!1,null,null,null)),x=(w.exports,new Map,{name:"zi-popover",components:{PopoverIcon:p},data:function(){return{visible:!1}},props:{align:{type:String,validator:r.enums(["left","right","center"]),default:"center"},hideOnClick:{type:Boolean,default:!0},hoverable:Boolean,delay:[Number,String]},methods:{toggle:function(){this.hoverable||(this.visible=!this.visible,document.removeEventListener("click",this.globalHandler),this.visible&&document.addEventListener("click",this.globalHandler))},hoverToggle:function(t){var e=this;if(this.hoverable){var n=Number.isNaN(+this.delay)?300:+this.delay;if(t)return this.timer&&clearTimeout(this.timer),void(this.visible=!0);this.timer=setTimeout((function(){e.visible=!1,clearTimeout(e.timer)}),n)}},globalHandler:function(){this.visible=!1},childTrigger:function(t){this.$emit("command",t),this.hideOnClick&&(document.removeEventListener("click",this.globalHandler),this.visible=!1)}}}),C=x,S=(n("c6ba"),f(C,o,a,!1,null,"418930c8",null)),T=S.exports,$=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"popover-item",class:{primary:t.primary,nohover:t.nohover,line:t.line,disabled:t.disabled},on:{click:function(e){return e.stopPropagation(),t.clickHandler(e)}}},[t.nohover?t._e():n("span",{staticClass:"text"},[t._t("default")],2),!t.line&&t.title?n("span",{staticClass:"title"},[t._t("default")],2):t._e(),!t.line&&t.subtitle?n("span",{staticClass:"subtitle"},[t._t("default")],2):t._e()])},E=[],j={name:"zi-popover-item",props:{line:Boolean,title:Boolean,subtitle:Boolean,primary:Boolean,disabled:Boolean,href:String,to:String,command:[String,Number,Object]},mounted:function(){if(!this.inGroup)return print.error("".concat(this.$options.name," required parent component: [zi-popover]"))},computed:{nohover:function(){return this.line||this.title||this.subtitle},inGroup:function(){var t=this.$parent;while(t){if("zi-popover"===t.$options.name)return this._group=t,!0;t=t.$parent}return!1}},methods:{clickHandler:function(){this.disabled||(this.href&&(window.location.href=this.href),this.to&&this.$router&&this.$router.push(this.to),this._group&&this._group.childTrigger(this.command))}}},k=j,O=(n("a271"),f(k,$,E,!1,null,"5cb74712",null)),N=O.exports;T.install=function(t){t.component(T.name,T),t.component(N.name,N)};var P=T;e["default"]=P}})["default"]}));
//# sourceMappingURL=popover.umd.min.js.map