7
7
:aria-disabled =" disabled ? true : null"
8
8
:target =" link ? target : null"
9
9
:href =" !button ? href : null"
10
+ :to =" !button ? to : null"
10
11
v-bind =" computedAttrs"
11
12
>
12
13
<slot />
16
17
<script setup lang="ts">
17
18
// import type {BListGroupItemProps} from '../../types/components'
18
19
import {computed , inject , useAttrs } from ' vue'
20
+ import type {RouteLocationRaw } from ' vue-router'
19
21
import type {ColorVariant , LinkTarget } from ' ../../types'
22
+ import BLink from ' ../BLink/BLink.vue'
20
23
import {injectionKey } from ' ./BListGroup.vue'
21
24
22
25
interface BListGroupItemProps {
@@ -36,7 +39,7 @@ interface BListGroupItemProps {
36
39
// routerComponentName?: String
37
40
tag? : string
38
41
target? : LinkTarget
39
- // to?: string | Record<string, unknown>
42
+ to? : RouteLocationRaw
40
43
variant? : ColorVariant
41
44
}
42
45
@@ -53,17 +56,10 @@ const attrs = useAttrs()
53
56
54
57
const parentData = inject (injectionKey , null )
55
58
56
- const link = computed <boolean >(() => ! props .button && !! props .href )
59
+ const link = computed <boolean >(() => ! props .button && ( !! props .href || !! props . to ) )
57
60
58
- const tagComputed = computed <string >(
59
- () =>
60
- parentData ?.numbered
61
- ? ' li'
62
- : props .button
63
- ? ' button'
64
- : ! link .value
65
- ? props .tag
66
- : ' a' /* BLink */
61
+ const tagComputed = computed <string | typeof BLink >(() =>
62
+ parentData ?.numbered ? ' li' : props .button ? ' button' : ! link .value ? props .tag : BLink
67
63
)
68
64
69
65
const classes = computed (() => {
0 commit comments