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.29 kB
this.primevue=this.primevue||{},this.primevue.tabmenu=function(e,t,n){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i={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,l){this.disabled(t)?e.preventDefault():(t.command&&t.command({originalEvent:e,item:t}),t.to&&l&&l(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,label:e=>"function"==typeof e.label?e.label():e.label,updateInkBar(){let t=this.$refs.nav.children,n=!1;for(let l=0;l<t.length;l++){let i=t[l];e.DomHandler.hasClass(i,"p-highlight")&&(this.$refs.inkbar.style.width=e.DomHandler.getWidth(i)+"px",this.$refs.inkbar.style.left=e.DomHandler.getOffset(i).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:l(t).default}};const a={class:"p-tabmenu p-component"},o={ref:"nav",class:"p-tabmenu-nav p-reset",role:"tablist"},s=["href","onClick"],r={class:"p-menuitem-text"},c=["href","target","onClick","tabindex"],m={class:"p-menuitem-text"},d={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 l=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&l.firstChild?l.insertBefore(i,l.firstChild):l.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.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"),i.render=function(e,t,l,i,p,u){const b=n.resolveComponent("router-link"),h=n.resolveDirective("ripple");return n.openBlock(),n.createElementBlock("div",a,[n.createElementVNode("ul",o,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(l.model,((t,l)=>(n.openBlock(),n.createElementBlock(n.Fragment,{key:u.label(t)+"_"+l.toString()},[t.to&&!u.disabled(t)?(n.openBlock(),n.createBlock(b,{key:0,to:t.to,custom:""},{default:n.withCtx((({navigate:i,href:a,isActive:o,isExactActive:c})=>[u.visible(t)?(n.openBlock(),n.createElementBlock("li",{key:0,class:n.normalizeClass(u.getRouteItemClass(t,o,c)),style:n.normalizeStyle(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.createElementBlock("a",{key:0,href:a,class:"p-menuitem-link",onClick:e=>u.onItemClick(e,t,l,i),role:"presentation"},[t.icon?(n.openBlock(),n.createElementBlock("span",{key:0,class:n.normalizeClass(u.getItemIcon(t))},null,2)):n.createCommentVNode("",!0),n.createElementVNode("span",r,n.toDisplayString(u.label(t)),1)],8,s)),[[h]])],6)):n.createCommentVNode("",!0)])),_:2},1032,["to"])):u.visible(t)?(n.openBlock(),n.createElementBlock("li",{key:1,class:n.normalizeClass(u.getItemClass(t,l)),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.createElementBlock("a",{key:0,href:t.url,class:"p-menuitem-link",target:t.target,onClick:e=>u.onItemClick(e,t,l),role:"presentation",tabindex:u.disabled(t)?null:"0"},[t.icon?(n.openBlock(),n.createElementBlock("span",{key:0,class:n.normalizeClass(u.getItemIcon(t))},null,2)):n.createCommentVNode("",!0),n.createElementVNode("span",m,n.toDisplayString(u.label(t)),1)],8,c)),[[h]])],2)):n.createCommentVNode("",!0)],64)))),128)),n.createElementVNode("li",d,null,512)],512)])},i}(primevue.utils,primevue.ripple,Vue);