|
1 |
| -declare module 'vue-router/composables' { |
2 |
| - import type { ComputedRef, Ref } from 'vue' |
3 |
| - import type { Route, NavigationGuard, default as VueRouter } from 'vue-router' |
| 1 | +import type { ComputedRef, Ref } from 'vue' |
| 2 | +import type { Route, NavigationGuard, default as VueRouter } from './index' |
4 | 3 |
|
5 |
| - /** |
6 |
| - * Returns the current route location. Equivalent to using `$route` inside templates. |
7 |
| - */ |
8 |
| - export function useRoute(): Route |
| 4 | +/** |
| 5 | + * Returns the current route location. Equivalent to using `$route` inside templates. |
| 6 | + */ |
| 7 | +export function useRoute(): Route |
9 | 8 |
|
10 |
| - /** |
11 |
| - * Returns the router instance. Equivalent to using `$router` inside templates. |
12 |
| - */ |
13 |
| - export function useRouter(): VueRouter |
| 9 | +/** |
| 10 | + * Returns the router instance. Equivalent to using `$router` inside templates. |
| 11 | + */ |
| 12 | +export function useRouter(): VueRouter |
14 | 13 |
|
15 |
| - /** |
16 |
| - * Add a navigation guard that triggers whenever the current location is about to be updated. Similar to beforeRouteUpdate but can be used in any component. The guard is removed when the component is unmounted. |
17 |
| - * |
18 |
| - * @param updateGuard |
19 |
| - */ |
20 |
| - export function onBeforeRouteUpdate(updateGuard: NavigationGuard): void |
| 14 | +/** |
| 15 | + * Add a navigation guard that triggers whenever the current location is about to be updated. Similar to beforeRouteUpdate but can be used in any component. The guard is removed when the component is unmounted. |
| 16 | + * |
| 17 | + * @param updateGuard |
| 18 | + */ |
| 19 | +export function onBeforeRouteUpdate(updateGuard: NavigationGuard): void |
21 | 20 |
|
| 21 | +/** |
| 22 | + * Add a navigation guard that triggers whenever the component for the current location is about to be left. Similar to beforeRouteLeave but can be used in any component. The guard is removed when the component is unmounted. |
| 23 | + * |
| 24 | + * @param leaveGuard |
| 25 | + */ |
| 26 | +export function onBeforeRouteLeave(leaveGuard: NavigationGuard): void |
| 27 | + |
| 28 | +export interface RouterLinkOptions { |
22 | 29 | /**
|
23 |
| - * Add a navigation guard that triggers whenever the component for the current location is about to be left. Similar to beforeRouteLeave but can be used in any component. The guard is removed when the component is unmounted. |
24 |
| - * |
25 |
| - * @param leaveGuard |
| 30 | + * Route Location the link should navigate to when clicked on. |
26 | 31 | */
|
27 |
| - export function onBeforeRouteLeave(leaveGuard: NavigationGuard): void |
28 |
| - |
29 |
| - export interface RouterLinkOptions { |
30 |
| - /** |
31 |
| - * Route Location the link should navigate to when clicked on. |
32 |
| - */ |
33 |
| - to: Route | Ref<Route> |
34 |
| - /** |
35 |
| - * Calls `router.replace` instead of `router.push`. |
36 |
| - */ |
37 |
| - replace?: boolean |
38 |
| - } |
39 |
| - |
| 32 | + to: Route | Ref<Route> |
40 | 33 | /**
|
41 |
| - * Vue Router 4 `useLink()` function. Note the active behavior is different from Vue Router 3 as highlighted in the |
42 |
| - * migration guide (https://router.vuejs.org/guide/migration/index.html#removal-of-the-exact-prop-in-router-link) |
43 |
| - * |
44 |
| - * @param props - object containing a `to` property with the location |
| 34 | + * Calls `router.replace` instead of `router.push`. |
45 | 35 | */
|
46 |
| - export function useLink(props: RouterLinkOptions): { |
47 |
| - route: ComputedRef<Route>, |
48 |
| - isActive: ComputedRef<boolean>, |
49 |
| - isExactActive: ComputedRef<boolean>, |
50 |
| - href: ComputedRef<string>, |
51 |
| - navigate: () => Promise<void>, |
52 |
| - } |
| 36 | + replace?: boolean |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * Vue Router 4 `useLink()` function. Note the active behavior is different from Vue Router 3 as highlighted in the |
| 41 | + * migration guide (https://router.vuejs.org/guide/migration/index.html#removal-of-the-exact-prop-in-router-link) |
| 42 | + * |
| 43 | + * @param props - object containing a `to` property with the location |
| 44 | + */ |
| 45 | +export function useLink({ to, replace }: RouterLinkOptions): { |
| 46 | + route: ComputedRef<Route>, |
| 47 | + isActive: ComputedRef<boolean>, |
| 48 | + isExactActive: ComputedRef<boolean>, |
| 49 | + href: ComputedRef<string>, |
| 50 | + navigate: () => Promise<void>, |
53 | 51 | }
|
0 commit comments