UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 5.04 kB
this.primevue=this.primevue||{},this.primevue.tabmenu=function(e,t,n){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a={name:"TabMenu",emits:["update:activeIndex","tab-change"],props:{model:{type:Array,default:null},exact:{type:Boolean,default:!0},activeIndex:{type:Number,default:0}},timeout:null,data(){return{d_activeIndex:this.activeIndex}},mounted(){this.updateInkBar()},updated(){this.updateInkBar()},beforeUnmount(){clearTimeout(this.timeout)},watch:{$route(){this.timeout=setTimeout((()=>this.updateInkBar()),50)},activeIndex(e){this.d_activeIndex=e}},methods:{onItemClick(e,t,n,i){this.disabled(t)?e.preventDefault():(t.command&&t.command({originalEvent:e,item:t}),t.to&&i&&i(e),n!==this.d_activeIndex&&(this.d_activeIndex=n,this.$emit("update:activeIndex",this.d_activeIndex)),this.$emit("tab-change",{originalEvent:e,index:n}))},getItemClass(e,t){return["p-tabmenuitem",e.class,{"p-highlight":this.d_activeIndex===t,"p-disabled":this.disabled(e)}]},getRouteItemClass(e,t,n){return["p-tabmenuitem",e.class,{"p-highlight":this.exact?n:t,"p-disabled":this.disabled(e)}]},getItemIcon:e=>["p-menuitem-icon",e.icon],visible:e=>"function"==typeof e.visible?e.visible():!1!==e.visible,disabled:e=>"function"==typeof e.disabled?e.disabled():e.disabled,updateInkBar(){let t=this.$refs.nav.children,n=!1;for(let i=0;i<t.length;i++){let a=t[i];e.DomHandler.hasClass(a,"p-highlight")&&(this.$refs.inkbar.style.width=e.DomHandler.getWidth(a)+"px",this.$refs.inkbar.style.left=e.DomHandler.getOffset(a).left-e.DomHandler.getOffset(this.$refs.nav).left+"px",n=!0)}n||(this.$refs.inkbar.style.width="0px",this.$refs.inkbar.style.left="0px")}},directives:{ripple:i(t).default}};const l={class:"p-tabmenu p-component"},o={ref:"nav",class:"p-tabmenu-nav p-reset",role:"tablist"},s={class:"p-menuitem-text"},r={class:"p-menuitem-text"},c={ref:"inkbar",class:"p-tabmenu-ink-bar"};return function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&i.firstChild?i.insertBefore(a,i.firstChild):i.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}("\n.p-tabmenu {\n overflow-x: auto;\n}\n.p-tabmenu-nav {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n margin: 0;\n padding: 0;\n list-style-type: none;\n -ms-flex-wrap: nowrap;\n flex-wrap: nowrap;\n}\n.p-tabmenu-nav a {\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n position: relative;\n text-decoration: none;\n text-decoration: none;\n overflow: hidden;\n}\n.p-tabmenu-nav a:focus {\n z-index: 1;\n}\n.p-tabmenu-nav .p-menuitem-text {\n line-height: 1;\n}\n.p-tabmenu-ink-bar {\n display: none;\n z-index: 1;\n}\n.p-tabmenu::-webkit-scrollbar {\n display: none;\n}\n"),a.render=function(e,t,i,a,d,m){const p=n.resolveComponent("router-link"),u=n.resolveDirective("ripple");return n.openBlock(),n.createBlock("div",l,[n.createVNode("ul",o,[(n.openBlock(!0),n.createBlock(n.Fragment,null,n.renderList(i.model,((t,i)=>(n.openBlock(),n.createBlock(n.Fragment,{key:t.label+"_"+i.toString()},[t.to&&!m.disabled(t)?(n.openBlock(),n.createBlock(p,{key:0,to:t.to,custom:""},{default:n.withCtx((({navigate:a,href:l,isActive:o,isExactActive:r})=>[m.visible(t)?(n.openBlock(),n.createBlock("li",{key:0,class:m.getRouteItemClass(t,o,r),style:t.style,role:"tab"},[e.$slots.item?(n.openBlock(),n.createBlock(n.resolveDynamicComponent(e.$slots.item),{key:1,item:t},null,8,["item"])):n.withDirectives((n.openBlock(),n.createBlock("a",{key:0,href:l,class:"p-menuitem-link",onClick:e=>m.onItemClick(e,t,i,a),role:"presentation"},[t.icon?(n.openBlock(),n.createBlock("span",{key:0,class:m.getItemIcon(t)},null,2)):n.createCommentVNode("",!0),n.createVNode("span",s,n.toDisplayString(t.label),1)],8,["href","onClick"])),[[u]])],6)):n.createCommentVNode("",!0)])),_:2},1032,["to"])):m.visible(t)?(n.openBlock(),n.createBlock("li",{key:1,class:m.getItemClass(t,i),role:"tab"},[e.$slots.item?(n.openBlock(),n.createBlock(n.resolveDynamicComponent(e.$slots.item),{key:1,item:t},null,8,["item"])):n.withDirectives((n.openBlock(),n.createBlock("a",{key:0,href:t.url,class:"p-menuitem-link",target:t.target,onClick:e=>m.onItemClick(e,t,i),role:"presentation",tabindex:m.disabled(t)?null:"0"},[t.icon?(n.openBlock(),n.createBlock("span",{key:0,class:m.getItemIcon(t)},null,2)):n.createCommentVNode("",!0),n.createVNode("span",r,n.toDisplayString(t.label),1)],8,["href","target","onClick","tabindex"])),[[u]])],2)):n.createCommentVNode("",!0)],64)))),128)),n.createVNode("li",c,null,512)],512)])},a}(primevue.utils,primevue.ripple,Vue);