@tanstack/react-router 0.0.1-beta.193 → 0.0.1-beta.195
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/build/cjs/react.js +3 -14
- package/build/cjs/react.js.map +1 -1
- package/build/esm/index.js +3 -14
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +98 -98
- package/build/types/react.d.ts +24 -26
- package/build/umd/index.development.js +94 -30
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/react.tsx +24 -76
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.195",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"tiny-warning": "^1.0.3",
|
|
45
45
|
"@tanstack/react-store": "^0.0.1",
|
|
46
46
|
"@gisatcz/cross-package-react-context": "^0.2.0",
|
|
47
|
-
"@tanstack/router-core": "0.0.1-beta.
|
|
47
|
+
"@tanstack/router-core": "0.0.1-beta.195"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup --config rollup.config.js"
|
package/src/react.tsx
CHANGED
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
ResolveId,
|
|
23
23
|
AnySearchSchema,
|
|
24
24
|
ParsePathParams,
|
|
25
|
-
MergeFromFromParent,
|
|
26
25
|
RouteContext,
|
|
27
26
|
AnyContext,
|
|
28
27
|
UseLoaderResult,
|
|
@@ -39,8 +38,13 @@ import {
|
|
|
39
38
|
AnyPathParams,
|
|
40
39
|
Expand,
|
|
41
40
|
ResolveAllParams,
|
|
41
|
+
DeepMergeAll,
|
|
42
|
+
IsAny,
|
|
42
43
|
} from '@tanstack/router-core'
|
|
43
44
|
|
|
45
|
+
const useLayoutEffect =
|
|
46
|
+
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect
|
|
47
|
+
|
|
44
48
|
declare module '@tanstack/router-core' {
|
|
45
49
|
interface RouterOptions<
|
|
46
50
|
TRouteTree extends AnyRoute,
|
|
@@ -56,44 +60,30 @@ declare module '@tanstack/router-core' {
|
|
|
56
60
|
TLoader = unknown,
|
|
57
61
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
58
62
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
59
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
60
63
|
TAllContext extends Record<string, any> = AnyContext,
|
|
61
64
|
> {
|
|
62
65
|
RouteComponent: RouteComponent<
|
|
63
|
-
RouteProps<
|
|
64
|
-
TLoader,
|
|
65
|
-
TFullSearchSchema,
|
|
66
|
-
TAllParams,
|
|
67
|
-
TRouteContext,
|
|
68
|
-
TAllContext
|
|
69
|
-
>
|
|
66
|
+
RouteProps<TLoader, TFullSearchSchema, TAllParams, TAllContext>
|
|
70
67
|
>
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
interface RegisterErrorRouteComponent<
|
|
74
71
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
75
72
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
76
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
77
73
|
TAllContext extends Record<string, any> = AnyContext,
|
|
78
74
|
> {
|
|
79
75
|
ErrorRouteComponent: RouteComponent<
|
|
80
|
-
ErrorRouteProps<TFullSearchSchema, TAllParams,
|
|
76
|
+
ErrorRouteProps<TFullSearchSchema, TAllParams, TAllContext>
|
|
81
77
|
>
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
interface RegisterPendingRouteComponent<
|
|
85
81
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
86
82
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
87
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
88
83
|
TAllContext extends Record<string, any> = AnyContext,
|
|
89
84
|
> {
|
|
90
85
|
PendingRouteComponent: RouteComponent<
|
|
91
|
-
PendingRouteProps<
|
|
92
|
-
TFullSearchSchema,
|
|
93
|
-
TAllParams,
|
|
94
|
-
TRouteContext,
|
|
95
|
-
TAllContext
|
|
96
|
-
>
|
|
86
|
+
PendingRouteProps<TFullSearchSchema, TAllParams, TAllContext>
|
|
97
87
|
>
|
|
98
88
|
}
|
|
99
89
|
|
|
@@ -124,12 +114,15 @@ declare module '@tanstack/router-core' {
|
|
|
124
114
|
TParentRoute,
|
|
125
115
|
TParams
|
|
126
116
|
>,
|
|
127
|
-
TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'],
|
|
128
|
-
TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['types']['context'],
|
|
129
117
|
TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
|
|
130
|
-
TAllContext extends RouteConstraints['TAllContext'] =
|
|
131
|
-
|
|
132
|
-
|
|
118
|
+
TAllContext extends RouteConstraints['TAllContext'] = Expand<
|
|
119
|
+
DeepMergeAll<
|
|
120
|
+
[
|
|
121
|
+
IsAny<TParentRoute['types']['context'], {}>,
|
|
122
|
+
TLoaderContext,
|
|
123
|
+
TRouteContext,
|
|
124
|
+
]
|
|
125
|
+
>
|
|
133
126
|
>,
|
|
134
127
|
TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
|
|
135
128
|
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
@@ -141,12 +134,9 @@ declare module '@tanstack/router-core' {
|
|
|
141
134
|
useLoader: <TSelected = TLoader>(opts?: {
|
|
142
135
|
select?: (search: TLoader) => TSelected
|
|
143
136
|
}) => UseLoaderResult<TSelected>
|
|
144
|
-
|
|
137
|
+
useRouteContext: <TSelected = TAllContext>(opts?: {
|
|
145
138
|
select?: (search: TAllContext) => TSelected
|
|
146
139
|
}) => TSelected
|
|
147
|
-
useRouteContext: <TSelected = TRouteContext>(opts?: {
|
|
148
|
-
select?: (search: TRouteContext) => TSelected
|
|
149
|
-
}) => TSelected
|
|
150
140
|
useSearch: <TSelected = TFullSearchSchema>(opts?: {
|
|
151
141
|
select?: (search: TFullSearchSchema) => TSelected
|
|
152
142
|
}) => TSelected
|
|
@@ -159,28 +149,19 @@ declare module '@tanstack/router-core' {
|
|
|
159
149
|
TLoader = unknown,
|
|
160
150
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
161
151
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
162
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
163
152
|
TAllContext extends Record<string, any> = AnyContext,
|
|
164
153
|
> {
|
|
165
|
-
RouteProps: RouteProps<
|
|
166
|
-
TLoader,
|
|
167
|
-
TFullSearchSchema,
|
|
168
|
-
TAllParams,
|
|
169
|
-
TRouteContext,
|
|
170
|
-
TAllContext
|
|
171
|
-
>
|
|
154
|
+
RouteProps: RouteProps<TLoader, TFullSearchSchema, TAllParams, TAllContext>
|
|
172
155
|
}
|
|
173
156
|
|
|
174
157
|
interface RegisterPendingRouteProps<
|
|
175
158
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
176
159
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
177
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
178
160
|
TAllContext extends Record<string, any> = AnyContext,
|
|
179
161
|
> {
|
|
180
162
|
PendingRouteProps: PendingRouteProps<
|
|
181
163
|
TFullSearchSchema,
|
|
182
164
|
TAllParams,
|
|
183
|
-
TRouteContext,
|
|
184
165
|
TAllContext
|
|
185
166
|
>
|
|
186
167
|
}
|
|
@@ -188,7 +169,6 @@ declare module '@tanstack/router-core' {
|
|
|
188
169
|
interface RegisterErrorRouteProps<
|
|
189
170
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
190
171
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
191
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
192
172
|
TAllContext extends Record<string, any> = AnyContext,
|
|
193
173
|
> {
|
|
194
174
|
ErrorRouteProps: ErrorRouteProps
|
|
@@ -199,7 +179,6 @@ export type RouteProps<
|
|
|
199
179
|
TLoader = unknown,
|
|
200
180
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
201
181
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
202
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
203
182
|
TAllContext extends Record<string, any> = AnyContext,
|
|
204
183
|
> = {
|
|
205
184
|
useLoader: <TSelected = TLoader>(opts?: {
|
|
@@ -208,12 +187,9 @@ export type RouteProps<
|
|
|
208
187
|
useMatch: <TSelected = TAllContext>(opts?: {
|
|
209
188
|
select?: (search: TAllContext) => TSelected
|
|
210
189
|
}) => TSelected
|
|
211
|
-
|
|
190
|
+
useRouteContext: <TSelected = TAllContext>(opts?: {
|
|
212
191
|
select?: (search: TAllContext) => TSelected
|
|
213
192
|
}) => TSelected
|
|
214
|
-
useRouteContext: <TSelected = TRouteContext>(opts?: {
|
|
215
|
-
select?: (search: TRouteContext) => TSelected
|
|
216
|
-
}) => TSelected
|
|
217
193
|
useSearch: <TSelected = TFullSearchSchema>(opts?: {
|
|
218
194
|
select?: (search: TFullSearchSchema) => TSelected
|
|
219
195
|
}) => TSelected
|
|
@@ -225,35 +201,21 @@ export type RouteProps<
|
|
|
225
201
|
export type ErrorRouteProps<
|
|
226
202
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
227
203
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
228
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
229
204
|
TAllContext extends Record<string, any> = AnyContext,
|
|
230
205
|
> = {
|
|
231
206
|
error: unknown
|
|
232
207
|
info: { componentStack: string }
|
|
233
208
|
} & Omit<
|
|
234
|
-
RouteProps<
|
|
235
|
-
unknown,
|
|
236
|
-
TFullSearchSchema,
|
|
237
|
-
TAllParams,
|
|
238
|
-
TRouteContext,
|
|
239
|
-
TAllContext
|
|
240
|
-
>,
|
|
209
|
+
RouteProps<unknown, TFullSearchSchema, TAllParams, TAllContext>,
|
|
241
210
|
'useLoader'
|
|
242
211
|
>
|
|
243
212
|
|
|
244
213
|
export type PendingRouteProps<
|
|
245
214
|
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
246
215
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
247
|
-
TRouteContext extends Record<string, any> = AnyContext,
|
|
248
216
|
TAllContext extends Record<string, any> = AnyContext,
|
|
249
217
|
> = Omit<
|
|
250
|
-
RouteProps<
|
|
251
|
-
unknown,
|
|
252
|
-
TFullSearchSchema,
|
|
253
|
-
TAllParams,
|
|
254
|
-
TRouteContext,
|
|
255
|
-
TAllContext
|
|
256
|
-
>,
|
|
218
|
+
RouteProps<unknown, TFullSearchSchema, TAllParams, TAllContext>,
|
|
257
219
|
'useLoader'
|
|
258
220
|
>
|
|
259
221
|
|
|
@@ -265,19 +227,11 @@ Route.__onInit = (route) => {
|
|
|
265
227
|
useLoader: (opts = {}) => {
|
|
266
228
|
return useLoader({ ...opts, from: route.id }) as any
|
|
267
229
|
},
|
|
268
|
-
useContext: (opts: any = {}) => {
|
|
269
|
-
return useMatch({
|
|
270
|
-
...opts,
|
|
271
|
-
from: route.id,
|
|
272
|
-
select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),
|
|
273
|
-
} as any)
|
|
274
|
-
},
|
|
275
230
|
useRouteContext: (opts: any = {}) => {
|
|
276
231
|
return useMatch({
|
|
277
232
|
...opts,
|
|
278
233
|
from: route.id,
|
|
279
|
-
select: (d: any) =>
|
|
280
|
-
opts?.select ? opts.select(d.routeContext) : d.routeContext,
|
|
234
|
+
select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),
|
|
281
235
|
} as any)
|
|
282
236
|
},
|
|
283
237
|
useSearch: (opts = {}) => {
|
|
@@ -369,8 +323,7 @@ export type MakeUseMatchRouteOptions<
|
|
|
369
323
|
TTo extends string = '',
|
|
370
324
|
TMaskFrom extends RoutePaths<TRouteTree> = '/',
|
|
371
325
|
TMaskTo extends string = '',
|
|
372
|
-
> = ToOptions<
|
|
373
|
-
MatchRouteOptions
|
|
326
|
+
> = ToOptions<AnyRoute, TFrom, TTo, TMaskFrom, TMaskTo> & MatchRouteOptions
|
|
374
327
|
|
|
375
328
|
export type MakeMatchRouteOptions<
|
|
376
329
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
@@ -587,7 +540,7 @@ export function Navigate<
|
|
|
587
540
|
>(props: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): null {
|
|
588
541
|
const router = useRouter()
|
|
589
542
|
|
|
590
|
-
|
|
543
|
+
useLayoutEffect(() => {
|
|
591
544
|
router.navigate(props as any)
|
|
592
545
|
}, [])
|
|
593
546
|
|
|
@@ -659,7 +612,6 @@ function Matches() {
|
|
|
659
612
|
return React.createElement(ErrorComponent, {
|
|
660
613
|
...props,
|
|
661
614
|
useMatch: route.useMatch,
|
|
662
|
-
useContext: route.useContext,
|
|
663
615
|
useRouteContext: route.useRouteContext,
|
|
664
616
|
useSearch: route.useSearch,
|
|
665
617
|
useParams: route.useParams,
|
|
@@ -999,7 +951,6 @@ function Match({ matchIds }: { matchIds: string[] }) {
|
|
|
999
951
|
return React.createElement(routeErrorComponent, {
|
|
1000
952
|
...props,
|
|
1001
953
|
useMatch: route.useMatch,
|
|
1002
|
-
useContext: route.useContext,
|
|
1003
954
|
useRouteContext: route.useRouteContext,
|
|
1004
955
|
useSearch: route.useSearch,
|
|
1005
956
|
useParams: route.useParams,
|
|
@@ -1013,7 +964,6 @@ function Match({ matchIds }: { matchIds: string[] }) {
|
|
|
1013
964
|
<ResolvedSuspenseBoundary
|
|
1014
965
|
fallback={React.createElement(PendingComponent, {
|
|
1015
966
|
useMatch: route.useMatch,
|
|
1016
|
-
useContext: route.useContext,
|
|
1017
967
|
useRouteContext: route.useRouteContext,
|
|
1018
968
|
useSearch: route.useSearch,
|
|
1019
969
|
useParams: route.useParams,
|
|
@@ -1059,7 +1009,6 @@ function MatchInner({
|
|
|
1059
1009
|
return React.createElement(PendingComponent, {
|
|
1060
1010
|
useLoader: route.useLoader,
|
|
1061
1011
|
useMatch: route.useMatch,
|
|
1062
|
-
useContext: route.useContext,
|
|
1063
1012
|
useRouteContext: route.useRouteContext,
|
|
1064
1013
|
useSearch: route.useSearch,
|
|
1065
1014
|
useParams: route.useParams,
|
|
@@ -1073,7 +1022,6 @@ function MatchInner({
|
|
|
1073
1022
|
return React.createElement(comp, {
|
|
1074
1023
|
useLoader: route.useLoader,
|
|
1075
1024
|
useMatch: route.useMatch,
|
|
1076
|
-
useContext: route.useContext as any,
|
|
1077
1025
|
useRouteContext: route.useRouteContext as any,
|
|
1078
1026
|
useSearch: route.useSearch,
|
|
1079
1027
|
useParams: route.useParams as any,
|