|
1 | 1 | <template>
|
2 |
| - <component :is="computedTag" v-bind="attrs"> |
| 2 | + <component :is="computedTag" class="navbar-brand" v-bind="props"> |
3 | 3 | <slot />
|
4 | 4 | </component>
|
5 | 5 | </template>
|
6 | 6 |
|
7 |
| -<script setup lang="ts"> |
8 |
| -// TODO refactor this to use old setup containing BLINKPROPS and pluckprops utility |
9 |
| -import type {LinkTarget} from '../../types' |
10 |
| -import {computed} from 'vue' |
11 |
| -import type {RouteLocationRaw} from 'vue-router' |
12 |
| -// TODO this components is not done |
13 |
| -interface Props { |
14 |
| - active?: boolean |
15 |
| - activeClass?: string |
16 |
| - append?: boolean |
17 |
| - disabled?: boolean |
18 |
| - exact?: boolean |
19 |
| - exactActiveClass?: string |
20 |
| - exactPath?: boolean |
21 |
| - exactPathActiveClass?: string |
22 |
| - href?: string |
23 |
| - noPrefetch?: boolean |
24 |
| - prefetch?: boolean |
25 |
| - rel?: string |
26 |
| - replace?: boolean |
27 |
| - routerComponentName?: string |
28 |
| - tag?: string |
29 |
| - target?: LinkTarget |
30 |
| - to?: RouteLocationRaw |
31 |
| -} |
| 7 | +<script lang="ts"> |
| 8 | +import {isLink, omit, pluckProps} from '../../utils' |
| 9 | +import {computed, defineComponent} from 'vue' |
| 10 | +import {BLINK_PROPS} from '../BLink/BLink.vue' |
32 | 11 |
|
33 |
| -const props = withDefaults(defineProps<Props>(), { |
34 |
| - active: false, |
35 |
| - append: false, |
36 |
| - disabled: false, |
37 |
| - exact: false, |
38 |
| - exactPath: false, |
39 |
| - noPrefetch: false, |
40 |
| - replace: false, |
41 |
| - target: '_self', |
42 |
| - tag: 'div', |
43 |
| -}) |
| 12 | +const linkProps = omit(BLINK_PROPS, ['event', 'routerTag']) |
44 | 13 |
|
45 |
| -const computedTag = computed<string>(() => (props.to ? 'b-link' : props.href ? 'a' : props.tag)) |
| 14 | +export default defineComponent({ |
| 15 | + props: { |
| 16 | + tag: {type: String, default: 'div'}, |
| 17 | + ...linkProps, |
| 18 | + }, |
| 19 | + setup(props) { |
| 20 | + const link = computed<boolean>(() => isLink(props)) |
| 21 | + const computedTag = computed<string>(() => (link.value ? 'b-link' : props.tag)) |
46 | 22 |
|
47 |
| -const attrs = computed(() => ({target: props.target, href: props.href, to: props.to})) |
| 23 | + return { |
| 24 | + props: link.value ? pluckProps(linkProps, props) : {}, |
| 25 | + computedTag, |
| 26 | + } |
| 27 | + }, |
| 28 | +}) |
48 | 29 | </script>
|
0 commit comments