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) 3.78 kB
import{DomHandler as e}from"primevue/utils";import t from"primevue/ripple";import{resolveDirective as n,openBlock as i,createBlock as a,createVNode as s,Fragment as l,renderList as d,withDirectives as r,toDisplayString as p,createCommentVNode as o,resolveDynamicComponent as c,vShow as b}from"vue";var h={name:"TabView",emits:["update:activeIndex","tab-change","tab-click"],props:{activeIndex:{type:Number,default:0},lazy:{type:Boolean,default:!1}},data(){return{d_activeIndex:this.activeIndex}},watch:{activeIndex(e){this.d_activeIndex=e}},updated(){this.updateInkBar()},mounted(){this.updateInkBar()},methods:{onTabClick(e,t){this.isTabDisabled(this.tabs[t])||t===this.d_activeIndex||(this.d_activeIndex=t,this.$emit("update:activeIndex",this.d_activeIndex),this.$emit("tab-change",{originalEvent:e,index:t})),this.$emit("tab-click",{originalEvent:e,index:t})},onTabKeydown(e,t){13===e.which&&this.onTabClick(e,t)},updateInkBar(){let t=this.$refs.nav.children[this.d_activeIndex];this.$refs.inkbar.style.width=e.getWidth(t)+"px",this.$refs.inkbar.style.left=e.getOffset(t).left-e.getOffset(this.$refs.nav).left+"px"},getKey:(e,t)=>e.props&&e.props.header?e.props.header:t,isTabDisabled:e=>e.props&&e.props.disabled,isTabPanel:e=>"TabPanel"===e.type.name},computed:{tabs(){const e=[];return this.$slots.default().forEach((t=>{this.isTabPanel(t)?e.push(t):t.children&&t.children instanceof Array&&t.children.forEach((t=>{this.isTabPanel(t)&&e.push(t)}))})),e}},directives:{ripple:t}};const v={class:"p-tabview p-component"},u={ref:"nav",class:"p-tabview-nav",role:"tablist"},f={key:0,class:"p-tabview-title"},x={ref:"inkbar",class:"p-tabview-ink-bar"},y={class:"p-tabview-panels"},m={key:0,class:"p-tabview-panel",role:"tabpanel"};!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-tabview-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: wrap;\n flex-wrap: wrap;\n}\n.p-tabview-nav-link {\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 overflow: hidden;\n}\n.p-tabview-ink-bar {\n display: none;\n z-index: 1;\n}\n.p-tabview-nav-link:focus {\n z-index: 1;\n}\n.p-tabview-title {\n line-height: 1;\n}\n"),h.render=function(e,t,h,w,k,g){const I=n("ripple");return i(),a("div",v,[s("ul",u,[(i(!0),a(l,null,d(g.tabs,((e,t)=>(i(),a("li",{role:"presentation",key:g.getKey(e,t),class:[{"p-highlight":k.d_activeIndex===t,"p-disabled":g.isTabDisabled(e)}]},[r(s("a",{role:"tab",class:"p-tabview-nav-link",onClick:e=>g.onTabClick(e,t),onKeydown:e=>g.onTabKeydown(e,t),tabindex:g.isTabDisabled(e)?null:"0","aria-selected":k.d_activeIndex===t},[e.props&&e.props.header?(i(),a("span",f,p(e.props.header),1)):o("",!0),e.children&&e.children.header?(i(),a(c(e.children.header),{key:1})):o("",!0)],40,["onClick","onKeydown","tabindex","aria-selected"]),[[I]])],2)))),128)),s("li",x,null,512)],512),s("div",y,[(i(!0),a(l,null,d(g.tabs,((e,t)=>(i(),a(l,{key:g.getKey(e,t)},[h.lazy&&k.d_activeIndex!==t?o("",!0):r((i(),a("div",m,[(i(),a(c(e)))],512)),[[b,!!h.lazy||k.d_activeIndex===t]])],64)))),128))])])};export default h;