5
5
</template >
6
6
7
7
<script lang="ts">
8
- import {resolveBooleanish } from ' ../../utils'
8
+ import {isLink , resolveBooleanish } from ' ../../utils'
9
9
import {computed , defineComponent , PropType } from ' vue'
10
10
import type {Booleanish , ButtonVariant , InputSize , LinkTarget } from ' ../../types'
11
11
import {BLINK_PROPS } from ' ../BLink/BLink.vue'
@@ -34,12 +34,11 @@ export default defineComponent({
34
34
const pressedBoolean = computed <boolean >(() => resolveBooleanish (props .pressed ))
35
35
const squaredBoolean = computed <boolean >(() => resolveBooleanish (props .squared ))
36
36
37
- // TODO none of these are computed values. Meaning they will not react if any of these are changed?
38
- const isToggle = pressedBoolean .value !== null
39
- const isButton = props .tag === ' button' && ! props .href && ! props .to
40
- const isLink = !! (props .href || props .to )
41
- const isBLink = !! props .to
42
- const nonStandardTag = props .href ? false : ! isButton
37
+ const isToggle = computed (() => pressedBoolean .value !== null )
38
+ const isButton = computed (() => props .tag === ' button' && ! props .href && ! props .to )
39
+ const link = computed (() => isLink (props ))
40
+ const isBLink = computed (() => !! props .to )
41
+ const nonStandardTag = computed (() => (props .href ? false : ! isButton .value ))
43
42
44
43
const classes = computed (() => ({
45
44
[` btn-${props .variant } ` ]: props .variant ,
@@ -51,28 +50,28 @@ export default defineComponent({
51
50
}))
52
51
53
52
const attrs = computed (() => ({
54
- ' aria-disabled' : nonStandardTag ? String (disabledBoolean .value ) : null ,
55
- ' aria-pressed' : isToggle ? String (pressedBoolean .value ) : null ,
56
- ' autocomplete' : isToggle ? ' off' : null ,
57
- ' disabled' : isButton ? disabledBoolean .value : null ,
53
+ ' aria-disabled' : nonStandardTag . value ? String (disabledBoolean .value ) : null ,
54
+ ' aria-pressed' : isToggle . value ? String (pressedBoolean .value ) : null ,
55
+ ' autocomplete' : isToggle . value ? ' off' : null ,
56
+ ' disabled' : isButton . value ? disabledBoolean .value : null ,
58
57
' href' : props .href ,
59
- ' rel' : isLink ? props .rel : null ,
60
- ' role' : nonStandardTag || isLink ? ' button' : null ,
61
- ' target' : isLink ? props .target : null ,
62
- ' type' : isButton ? props .type : null ,
63
- ' to' : ! isButton ? props .to : null ,
64
- ' append' : isLink ? props .append : null ,
65
- ' activeClass' : isBLink ? props .activeClass : null ,
66
- ' event' : isBLink ? props .event : null ,
67
- ' exact' : isBLink ? props .exact : null ,
68
- ' exactActiveClass' : isBLink ? props .exactActiveClass : null ,
69
- ' replace' : isBLink ? props .replace : null ,
70
- ' routerComponentName' : isBLink ? props .routerComponentName : null ,
71
- ' routerTag' : isBLink ? props .routerTag : null ,
58
+ ' rel' : link . value ? props .rel : null ,
59
+ ' role' : nonStandardTag . value || link . value ? ' button' : null ,
60
+ ' target' : link . value ? props .target : null ,
61
+ ' type' : isButton . value ? props .type : null ,
62
+ ' to' : ! isButton . value ? props .to : null ,
63
+ ' append' : link . value ? props .append : null ,
64
+ ' activeClass' : isBLink . value ? props .activeClass : null ,
65
+ ' event' : isBLink . value ? props .event : null ,
66
+ ' exact' : isBLink . value ? props .exact : null ,
67
+ ' exactActiveClass' : isBLink . value ? props .exactActiveClass : null ,
68
+ ' replace' : isBLink . value ? props .replace : null ,
69
+ ' routerComponentName' : isBLink . value ? props .routerComponentName : null ,
70
+ ' routerTag' : isBLink . value ? props .routerTag : null ,
72
71
}))
73
72
74
73
const computedTag = computed <string >(() => {
75
- if (isBLink ) return ' b-link'
74
+ if (isBLink . value ) return ' b-link'
76
75
return props .href ? ' a' : props .tag
77
76
})
78
77
@@ -83,7 +82,7 @@ export default defineComponent({
83
82
return
84
83
}
85
84
emit (' click' , e )
86
- if (isToggle ) {
85
+ if (isToggle . value ) {
87
86
emit (' update:pressed' , ! pressedBoolean .value )
88
87
}
89
88
}
0 commit comments