@zeit-ui/vue
Version:
A popular UI framework for Vue
2 lines • 6.13 kB
JavaScript
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["switcher"]=t():e["switcher"]=t()})("undefined"!==typeof self?self:this,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="fb15")}({"39f4":function(e,t,n){"use strict";var i=n("5b75"),r=n.n(i);r.a},"5b75":function(e,t,n){},"7ce0":function(e,t,n){},ba8f:function(e,t,n){"use strict";var i=n("7ce0"),r=n.n(i);r.a},f6fd:function(e,t){(function(e){var t="currentScript",n=e.getElementsByTagName("script");t in e||Object.defineProperty(e,t,{get:function(){try{throw new Error}catch(i){var e,t=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(i.stack)||[!1])[1];for(e in n)if(n[e].src==t||"interactive"==n[e].readyState)return n[e];return null}}})})(document)},fb15:function(e,t,n){"use strict";n.r(t);var i,r={};(n.r(r),n.d(r,"warning",(function(){return u})),n.d(r,"error",(function(){return a})),"undefined"!==typeof window)&&(n("f6fd"),(i=window.document.currentScript)&&(i=i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=i[1]));var o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{staticClass:"zi-switcher"},e._l(e.labels,(function(t,i){return n("a",{key:t+i,class:{active:e.isSelected(t)},on:{click:function(n){return e.select(t)}}},[e._v(e._s(t))])})),0),n("div",{staticClass:"zi-switcher-content"},[e._t("default")],2)])},s=[],c=function(e){var t=e.getBoundingClientRect(),n=window.getComputedStyle(e),i=n.width,r=n.height,o=function(e,t){if(!e)return 0;var n=e.includes("px")?+e.split("px")[0]:e.includes("%")?+e.split("%")[0]*t*.01:e;return Number.isNaN(+n)?0:+n};return{width:o("".concat(i),t.width),height:o("".concat(r),t.height)}},u=function(e){console.warn(e)},a=function(e){console.error(e)},l=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("transition",{attrs:{name:"expand"},on:{enter:e.enter,"after-enter":e.afterEnter,leave:e.leave}},[e._t("default")],2)},f=[],d={name:"zi-transition-expand",methods:{enter:function(e){var t=c(e),n=t.width;e.style.width="".concat(n,"px"),e.style.position="absolute",e.style.visibility="hidden",e.style.height="auto";var i=c(e),r=i.height;e.style.width=null,e.style.position=null,e.style.visibility=null,e.style.height=0,c(e);var o=setTimeout((function(){e.style.height="".concat(r,"px"),clearTimeout(o)}),0)},afterEnter:function(e){e.style.height="auto"},leave:function(e){var t=c(e),n=t.height;e.style.height="".concat(n,"px"),c(e);var i=setTimeout((function(){e.style.height=0,clearTimeout(i)}),0)},afterLeave:function(e){e.style.height=null}}},p=d;n("ba8f");function h(e,t,n,i,r,o,s,c){var u,a="function"===typeof e?e.options:e;if(t&&(a.render=t,a.staticRenderFns=n,a._compiled=!0),i&&(a.functional=!0),o&&(a._scopeId="data-v-"+o),s?(u=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},a._ssrRegister=u):r&&(u=c?function(){r.call(this,this.$root.$options.shadowRoot)}:r),u)if(a.functional){a._injectStyles=u;var l=a.render;a.render=function(e,t){return u.call(t),l(e,t)}}else{var f=a.beforeCreate;a.beforeCreate=f?[].concat(f,u):[u]}return{exports:e,options:a}}var v=h(p,l,f,!1,null,null,null),b=(v.exports,new Map,{name:"zi-switcher",data:function(){return{labels:[],currentActive:"",subscribers:[]}},created:function(){console.warn("[zeit-ui]: **DEPRECATION**: <zi-switcher> will be discarded. Please use <zi-tabs> instead of it")},methods:{appendLabel:function(e){if(this.labels.find((function(t){return t===e})))return r.error("[zi-switcher] > Duplicate label (".concat(e,")"));this.labels.push(e),1===this.labels.length&&this.select(e,!0)},appendSubscriber:function(e){this.subscribers.push(e)},isSelected:function(e){return this.currentActive===e},select:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t||this.currentActive===e||this.$emit("label-selected",e),this.currentActive=e,this.subscribers.forEach((function(e){"function"===typeof e&&e()}))}}}),m=b,y=(n("39f4"),h(m,o,s,!1,null,null,null)),_=y.exports,g=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{directives:[{name:"show",rawName:"v-show",value:e.isActive,expression:"isActive"}]},[e._t("default")],2)},w=[],x={name:"zi-switcher-item",props:{label:[String,Number],active:Boolean,disabled:Boolean},data:function(){return{isActive:!1}},computed:{inGroup:function(){var e=this.$parent;while(e){if("zi-switcher"===e.$options.name)return this._group=e,!0;e=e.$parent}return!1}},mounted:function(){if(!this.inGroup)return print.error("".concat(this.$options.name," required parent component: [zi-switcher]"));this._group.appendSubscriber(this.updateSubscription.bind(this)),this._group.appendLabel(this.label),this.active&&this._group.select(this.label,!0)},methods:{updateSubscription:function(){this.isActive=this._group.isSelected(this.label)}}},S=x,$=h(S,g,w,!1,null,null,null),E=$.exports;_.install=function(e){e.component(_.name,_),e.component(E.name,E)};var j=_;t["default"]=j}})["default"]}));
//# sourceMappingURL=switcher.umd.min.js.map