@tanstack/react-router 1.99.13 → 1.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +1 -0
- package/dist/cjs/typePrimitives.d.cts +8 -2
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +4 -5
- package/dist/cjs/useParams.cjs +1 -0
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +7 -5
- package/dist/cjs/useSearch.cjs +1 -0
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +7 -5
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/route.d.ts +1 -0
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/typePrimitives.d.ts +8 -2
- package/dist/esm/useMatch.d.ts +4 -5
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useParams.d.ts +7 -5
- package/dist/esm/useParams.js +1 -0
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useSearch.d.ts +7 -5
- package/dist/esm/useSearch.js +1 -0
- package/dist/esm/useSearch.js.map +1 -1
- package/package.json +1 -1
- package/src/fileRoute.ts +4 -2
- package/src/route.ts +17 -4
- package/src/typePrimitives.ts +11 -0
- package/src/useMatch.tsx +4 -4
- package/src/useParams.tsx +23 -5
- package/src/useSearch.tsx +23 -5
package/src/useParams.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMatch } from './useMatch'
|
|
2
|
+
import type { ThrowConstraint } from './useMatch'
|
|
2
3
|
import type {
|
|
3
4
|
StructuralSharingOption,
|
|
4
5
|
ValidateSelected,
|
|
@@ -6,28 +7,38 @@ import type {
|
|
|
6
7
|
import type { AllParams, RouteById } from './routeInfo'
|
|
7
8
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
8
9
|
import type { StrictOrFrom } from './utils'
|
|
9
|
-
import type { Expand } from '@tanstack/router-core'
|
|
10
|
+
import type { Expand, ThrowOrOptional } from '@tanstack/router-core'
|
|
10
11
|
|
|
11
12
|
export interface UseParamsBaseOptions<
|
|
12
13
|
TRouter extends AnyRouter,
|
|
13
14
|
TFrom,
|
|
14
15
|
TStrict extends boolean,
|
|
16
|
+
TThrow extends boolean,
|
|
15
17
|
TSelected,
|
|
16
18
|
TStructuralSharing,
|
|
17
19
|
> {
|
|
18
20
|
select?: (
|
|
19
21
|
params: ResolveParams<TRouter, TFrom, TStrict>,
|
|
20
22
|
) => ValidateSelected<TRouter, TSelected, TStructuralSharing>
|
|
23
|
+
shouldThrow?: TThrow
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export type UseParamsOptions<
|
|
24
27
|
TRouter extends AnyRouter,
|
|
25
28
|
TFrom extends string | undefined,
|
|
26
29
|
TStrict extends boolean,
|
|
30
|
+
TThrow extends boolean,
|
|
27
31
|
TSelected,
|
|
28
32
|
TStructuralSharing,
|
|
29
33
|
> = StrictOrFrom<TRouter, TFrom, TStrict> &
|
|
30
|
-
UseParamsBaseOptions<
|
|
34
|
+
UseParamsBaseOptions<
|
|
35
|
+
TRouter,
|
|
36
|
+
TFrom,
|
|
37
|
+
TStrict,
|
|
38
|
+
TThrow,
|
|
39
|
+
TSelected,
|
|
40
|
+
TStructuralSharing
|
|
41
|
+
> &
|
|
31
42
|
StructuralSharingOption<TRouter, TSelected, TStructuralSharing>
|
|
32
43
|
|
|
33
44
|
export type ResolveParams<
|
|
@@ -55,7 +66,8 @@ export type UseParamsRoute<out TFrom> = <
|
|
|
55
66
|
opts?: UseParamsBaseOptions<
|
|
56
67
|
TRouter,
|
|
57
68
|
TFrom,
|
|
58
|
-
true,
|
|
69
|
+
/* TStrict */ true,
|
|
70
|
+
/* TThrow */ true,
|
|
59
71
|
TSelected,
|
|
60
72
|
TStructuralSharing
|
|
61
73
|
> &
|
|
@@ -66,6 +78,7 @@ export function useParams<
|
|
|
66
78
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
67
79
|
const TFrom extends string | undefined = undefined,
|
|
68
80
|
TStrict extends boolean = true,
|
|
81
|
+
TThrow extends boolean = true,
|
|
69
82
|
TSelected = unknown,
|
|
70
83
|
TStructuralSharing extends boolean = boolean,
|
|
71
84
|
>(
|
|
@@ -73,16 +86,21 @@ export function useParams<
|
|
|
73
86
|
TRouter,
|
|
74
87
|
TFrom,
|
|
75
88
|
TStrict,
|
|
89
|
+
ThrowConstraint<TStrict, TThrow>,
|
|
76
90
|
TSelected,
|
|
77
91
|
TStructuralSharing
|
|
78
92
|
>,
|
|
79
|
-
):
|
|
93
|
+
): ThrowOrOptional<
|
|
94
|
+
UseParamsResult<TRouter, TFrom, TStrict, TSelected>,
|
|
95
|
+
TThrow
|
|
96
|
+
> {
|
|
80
97
|
return useMatch({
|
|
81
98
|
from: opts.from!,
|
|
82
99
|
strict: opts.strict,
|
|
100
|
+
shouldThrow: opts.shouldThrow,
|
|
83
101
|
structuralSharing: opts.structuralSharing,
|
|
84
102
|
select: (match: any) => {
|
|
85
103
|
return opts.select ? opts.select(match.params) : match.params
|
|
86
104
|
},
|
|
87
|
-
} as any
|
|
105
|
+
}) as any
|
|
88
106
|
}
|
package/src/useSearch.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMatch } from './useMatch'
|
|
2
|
+
import type { ThrowConstraint } from './useMatch'
|
|
2
3
|
import type {
|
|
3
4
|
StructuralSharingOption,
|
|
4
5
|
ValidateSelected,
|
|
@@ -6,28 +7,38 @@ import type {
|
|
|
6
7
|
import type { FullSearchSchema, RouteById } from './routeInfo'
|
|
7
8
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
8
9
|
import type { StrictOrFrom } from './utils'
|
|
9
|
-
import type { Expand } from '@tanstack/router-core'
|
|
10
|
+
import type { Expand, ThrowOrOptional } from '@tanstack/router-core'
|
|
10
11
|
|
|
11
12
|
export interface UseSearchBaseOptions<
|
|
12
13
|
TRouter extends AnyRouter,
|
|
13
14
|
TFrom,
|
|
14
15
|
TStrict extends boolean,
|
|
16
|
+
TThrow extends boolean,
|
|
15
17
|
TSelected,
|
|
16
18
|
TStructuralSharing,
|
|
17
19
|
> {
|
|
18
20
|
select?: (
|
|
19
21
|
state: ResolveSearch<TRouter, TFrom, TStrict>,
|
|
20
22
|
) => ValidateSelected<TRouter, TSelected, TStructuralSharing>
|
|
23
|
+
shouldThrow?: TThrow
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export type UseSearchOptions<
|
|
24
27
|
TRouter extends AnyRouter,
|
|
25
28
|
TFrom,
|
|
26
29
|
TStrict extends boolean,
|
|
30
|
+
TThrow extends boolean,
|
|
27
31
|
TSelected,
|
|
28
32
|
TStructuralSharing,
|
|
29
33
|
> = StrictOrFrom<TRouter, TFrom, TStrict> &
|
|
30
|
-
UseSearchBaseOptions<
|
|
34
|
+
UseSearchBaseOptions<
|
|
35
|
+
TRouter,
|
|
36
|
+
TFrom,
|
|
37
|
+
TStrict,
|
|
38
|
+
TThrow,
|
|
39
|
+
TSelected,
|
|
40
|
+
TStructuralSharing
|
|
41
|
+
> &
|
|
31
42
|
StructuralSharingOption<TRouter, TSelected, TStructuralSharing>
|
|
32
43
|
|
|
33
44
|
export type UseSearchResult<
|
|
@@ -55,7 +66,8 @@ export type UseSearchRoute<out TFrom> = <
|
|
|
55
66
|
opts?: UseSearchBaseOptions<
|
|
56
67
|
TRouter,
|
|
57
68
|
TFrom,
|
|
58
|
-
true,
|
|
69
|
+
/* TStrict */ true,
|
|
70
|
+
/* TThrow */ true,
|
|
59
71
|
TSelected,
|
|
60
72
|
TStructuralSharing
|
|
61
73
|
> &
|
|
@@ -66,6 +78,7 @@ export function useSearch<
|
|
|
66
78
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
67
79
|
const TFrom extends string | undefined = undefined,
|
|
68
80
|
TStrict extends boolean = true,
|
|
81
|
+
TThrow extends boolean = true,
|
|
69
82
|
TSelected = unknown,
|
|
70
83
|
TStructuralSharing extends boolean = boolean,
|
|
71
84
|
>(
|
|
@@ -73,16 +86,21 @@ export function useSearch<
|
|
|
73
86
|
TRouter,
|
|
74
87
|
TFrom,
|
|
75
88
|
TStrict,
|
|
89
|
+
ThrowConstraint<TStrict, TThrow>,
|
|
76
90
|
TSelected,
|
|
77
91
|
TStructuralSharing
|
|
78
92
|
>,
|
|
79
|
-
):
|
|
93
|
+
): ThrowOrOptional<
|
|
94
|
+
UseSearchResult<TRouter, TFrom, TStrict, TSelected>,
|
|
95
|
+
TThrow
|
|
96
|
+
> {
|
|
80
97
|
return useMatch({
|
|
81
98
|
from: opts.from!,
|
|
82
99
|
strict: opts.strict,
|
|
100
|
+
shouldThrow: opts.shouldThrow,
|
|
83
101
|
structuralSharing: opts.structuralSharing,
|
|
84
102
|
select: (match: any) => {
|
|
85
103
|
return opts.select ? opts.select(match.search) : match.search
|
|
86
104
|
},
|
|
87
|
-
}) as
|
|
105
|
+
}) as any
|
|
88
106
|
}
|