Line data Source code
1 : <template>
2 : <div
3 280 : v-if="isActive"
4 : :id="`tabpanel-${value}`"
5 : role="tabpanel"
6 : tabindex="0"
7 : :aria-labelledby="`tab-${value}`"
8 : >
9 : <slot />
10 : </div>
11 : </template>
12 :
13 : <script setup lang="ts" generic="T extends string = string">
14 : import { computed, inject } from 'vue'
15 :
16 : import { TAB_LIST_INJECTION_KEY } from './tabKeys'
17 :
18 : const { value, modelValue } = defineProps<{
19 : value: T
20 : modelValue?: T
21 : }>()
22 :
23 24 : const context = inject(TAB_LIST_INJECTION_KEY, undefined)
24 24 : const isActive = computed(() =>
25 : modelValue !== undefined
26 : ? modelValue === value
27 : : context?.modelValue.value === value
28 : )
29 : </script>
|