primevue-mirror/components/lib/tabpanel/TabPanel.vue

57 lines
1.6 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
2024-04-19 13:51:57 +00:00
<slot v-if="!$pcTabs"></slot>
<template v-else>
<template v-if="!asChild">
<component v-if="$pcTabs?.lazy ? active : true" v-show="$pcTabs?.lazy ? true : active" :is="as" :class="cx('root')" v-bind="attrs">
<slot></slot>
</component>
</template>
<slot v-else :class="cx('root')" :active="active" :a11yAttrs="a11yAttrs"></slot>
</template>
2022-09-06 12:03:37 +00:00
</template>
<script>
2024-04-19 13:51:57 +00:00
import { ObjectUtils } from 'primevue/utils';
import { mergeProps } from 'vue';
2023-05-24 06:24:33 +00:00
import BaseTabPanel from './BaseTabPanel.vue';
2022-09-06 12:03:37 +00:00
export default {
name: 'TabPanel',
2024-04-19 13:51:57 +00:00
extends: BaseTabPanel,
inheritAttrs: false,
inject: ['$pcTabs'],
computed: {
active() {
return ObjectUtils.equals(this.$pcTabs?.d_value, this.value);
},
id() {
return `${this.$pcTabs?.id}_tabpanel_${this.value}`;
},
ariaLabelledby() {
return `${this.$pcTabs?.id}_tab_${this.value}`;
},
attrs() {
return mergeProps(this.a11yAttrs, this.ptmi('root', this.ptParams));
},
a11yAttrs() {
return {
id: this.id,
tabindex: this.$pcTabs?.tabindex,
role: 'tabpanel',
'aria-labelledby': this.ariaLabelledby,
'data-pc-name': 'tabpanel',
'data-p-active': this.active
};
},
ptParams() {
return {
context: {
active: this.active
}
};
}
}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
</script>