@zeit-ui/vue
Version:
A popular UI framework for Vue
2 lines • 6.63 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["tabs"]=e():t["tabs"]=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")}({"7bf1":function(t,e,n){},"7ce0":function(t,e,n){},ba8f:function(t,e,n){"use strict";var i=n("7ce0"),r=n.n(i);r.a},ca19:function(t,e,n){"use strict";var i=n("7bf1"),r=n.n(i);r.a},f54e:function(t,e,n){"use strict";var i=n("f69c"),r=n.n(i);r.a},f69c:function(t,e,n){},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,"warning",(function(){return v})),n.d(r,"error",(function(){return b})),"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",[n("div",{staticClass:"zi-tabs-container"},t._l(t.titles,(function(e,i){return n("div",{key:e.value+i,staticClass:"zi-item-wrapper",class:{disabled:t.disabled},on:{click:function(n){return t.select(e)}}},[n("div",{staticClass:"zi-tabs-item",class:{active:t.isSelected(e.value)}},[n(e.icon,{directives:[{name:"show",rawName:"v-show",value:e.icon,expression:"item.icon"}],tag:"component",staticClass:"icon"}),n("div",[t._v(t._s(e.label))])],1)])})),0),t._t("default")],2)},s=[],a={name:"zi-tabs",data:function(){return{titles:[],selected:"",subscribers:[]}},props:{disabled:Boolean},mounted:function(){this.appendTabs(!0)},methods:{appendTabs:function(t){this.titles=[],this.titles=this.$children.filter((function(t){return"zi-tabs-item"===t.$options.name})).map((function(t){var e=t.label,n=t.value,i=t.active,r=t.icon;return{label:e,value:n,active:i,icon:r}}));var e=this.titles.find((function(t){return t.active}));e?this.select(e,t):this.select(this.titles[0],t)},appendSubscriber:function(t){this.subscribers.push(t)},isSelected:function(t){return t===this.selected},select:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.disabled||e){var n=t.value,i=t.label;e||this.selected===t.value||this.$emit("label-selected",{label:i,value:n}),this.selected=t.value,this.subscribers.forEach((function(t){"function"===typeof t&&t()}))}}}},c=a;n("f54e");function u(t,e,n,i,r,o,s,a){var c,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),s?(c=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(s)},u._ssrRegister=c):r&&(c=a?function(){r.call(this,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}}var l=u(c,o,s,!1,null,"5eca3cd2",null),f=l.exports,d=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{directives:[{name:"show",rawName:"v-show",value:t.isActive,expression:"isActive"}],staticClass:"zi-tabs-content"},[t._t("default")],2)},p=[],h=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)}},v=function(t){console.warn(t)},b=function(t){console.error(t)},m=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)},y=[],_={name:"zi-transition-expand",methods:{enter:function(t){var e=h(t),n=e.width;t.style.width="".concat(n,"px"),t.style.position="absolute",t.style.visibility="hidden",t.style.height="auto";var i=h(t),r=i.height;t.style.width=null,t.style.position=null,t.style.visibility=null,t.style.height=0,h(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=h(t),n=e.height;t.style.height="".concat(n,"px"),h(t);var i=setTimeout((function(){t.style.height=0,clearTimeout(i)}),0)},afterLeave:function(t){t.style.height=null}}},g=_,w=(n("ba8f"),u(g,m,y,!1,null,null,null)),x=(w.exports,new Map,{name:"zi-tabs-item",props:{label:[String,Number],value:[String,Number],active:Boolean,icon:Object},data:function(){return{isActive:!1}},computed:{inGroup:function(){var t=this.$parent;while(t){if("zi-tabs"===t.$options.name)return this._group=t,!0;t=t.$parent}return!1}},mounted:function(){if(!this.inGroup)return r.error("".concat(this.$options.name," required parent component: [zi-tabs]"));this.updateSubscription(),this._group.appendSubscriber(this.updateSubscription.bind(this))},watch:{title:function(){this._group.appendTabs(!1)},value:function(){this._group.appendTabs(!1)}},methods:{updateSubscription:function(){this.isActive=this._group.isSelected(this.value)}}}),S=x,$=(n("ca19"),u(S,d,p,!1,null,"7b3ea867",null)),C=$.exports;f.install=function(t){t.component(f.name,f),t.component(C.name,C)};var T=f;e["default"]=T}})["default"]}));
//# sourceMappingURL=tabs.umd.min.js.map