Skip to content

Commit 095c071

Browse files
author
issayah
committed
BTabs script setup conversion
1 parent c1dc4ee commit 095c071

File tree

4 files changed

+282
-269
lines changed

4 files changed

+282
-269
lines changed

src/components/BTabs/BTab.vue

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,45 @@
1111
</component>
1212
</template>
1313

14-
<script lang="ts">
15-
import {computed, defineComponent, inject} from 'vue'
16-
import {injectionKey, ParentData} from './BTabs.vue'
14+
<script setup lang="ts">
15+
// import type {BTabProps} from '@/types/components'
16+
import {computed, inject} from 'vue'
17+
import {injectionKey} from './BTabs.vue'
1718
18-
export default defineComponent({
19-
name: 'BTab',
20-
props: {
21-
active: {type: Boolean, default: false},
22-
buttonId: {type: String, default: null},
23-
disabled: {type: Boolean, default: false},
24-
id: {type: String},
25-
lazy: {type: Boolean, default: false},
26-
noBody: {type: [Boolean, String], default: false},
27-
tag: {type: String, default: 'div'},
28-
title: {type: String},
29-
titleItemClass: {type: [Array, Object, String], default: null},
30-
titleLinkAttributes: {type: Object, default: null},
31-
titleLinkClass: {type: [Array, Object, String], default: null},
32-
},
33-
setup(props) {
34-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
35-
const parentData: ParentData = inject(injectionKey)!
19+
interface BTabProps {
20+
id: string
21+
title: string
22+
active?: boolean
23+
buttonId?: string
24+
disabled?: boolean
25+
lazy?: boolean
26+
noBody?: boolean | string
27+
tag?: string
28+
titleItemClass?: Array<unknown> | Record<string, unknown> | string
29+
titleLinkAttributes?: Record<string, unknown>
30+
titleLinkClass?: Array<unknown> | Record<string, unknown> | string
31+
}
3632
37-
const computedLazy = computed(() => parentData?.lazy || props.lazy)
38-
const computedActive = computed(() => props.active && !props.disabled)
39-
const showSlot = computed(() => computedActive.value || !computedLazy.value)
40-
const classes = computed(() => ({
41-
'active': props.active,
42-
'show': props.active,
43-
'card-body': parentData.card && props.noBody === false,
44-
}))
45-
46-
return {
47-
classes,
48-
computedLazy,
49-
computedActive,
50-
showSlot,
51-
}
52-
},
33+
const props = withDefaults(defineProps<BTabProps>(), {
34+
active: false,
35+
buttonId: undefined,
36+
disabled: false,
37+
lazy: false,
38+
noBody: false,
39+
tag: 'div',
40+
titleItemClass: undefined,
41+
titleLinkAttributes: undefined,
42+
titleLinkClass: undefined,
5343
})
44+
45+
const parentData = inject(injectionKey, null)
46+
47+
const computedLazy = computed<boolean>(() => parentData?.lazy || props.lazy)
48+
const computedActive = computed<boolean>(() => props.active && !props.disabled)
49+
const showSlot = computed<boolean>(() => computedActive.value || !computedLazy.value)
50+
const classes = computed(() => ({
51+
'active': props.active,
52+
'show': props.active,
53+
'card-body': parentData?.card && props.noBody === false,
54+
}))
5455
</script>

0 commit comments

Comments
 (0)