@tanstack/react-router 0.0.1-beta.207 → 0.0.1-beta.208
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/RouterProvider.js +12 -2
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/react.js +4 -0
- package/build/cjs/react.js.map +1 -1
- package/build/cjs/route.js.map +1 -1
- package/build/esm/index.js +16 -3
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +167 -167
- package/build/types/react.d.ts +1 -0
- package/build/types/route.d.ts +4 -1
- package/build/umd/index.development.js +16 -2
- 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/RouterProvider.tsx +4 -0
- package/src/react.tsx +14 -0
- package/src/route.ts +4 -1
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.208",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@babel/runtime": "^7.16.7",
|
|
43
43
|
"tiny-invariant": "^1.3.1",
|
|
44
44
|
"tiny-warning": "^1.0.3",
|
|
45
|
-
"@tanstack/history": "0.0.1-beta.
|
|
45
|
+
"@tanstack/history": "0.0.1-beta.208"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "rollup --config rollup.config.js"
|
package/src/RouterProvider.tsx
CHANGED
|
@@ -858,6 +858,7 @@ export function RouterProvider<
|
|
|
858
858
|
preload: !!preload,
|
|
859
859
|
meta: parentMeta,
|
|
860
860
|
location: state.location, // TODO: This might need to be latestLocationRef.current...?
|
|
861
|
+
navigate: (opts) => navigate({ ...opts, from: match.pathname }),
|
|
861
862
|
})) ?? ({} as any)
|
|
862
863
|
|
|
863
864
|
const meta = {
|
|
@@ -925,6 +926,9 @@ export function RouterProvider<
|
|
|
925
926
|
parentMatchPromise,
|
|
926
927
|
abortController: match.abortController,
|
|
927
928
|
meta: match.meta,
|
|
929
|
+
location: state.location,
|
|
930
|
+
navigate: (opts) =>
|
|
931
|
+
navigate({ ...opts, from: match.pathname }),
|
|
928
932
|
})
|
|
929
933
|
|
|
930
934
|
await Promise.all([componentsPromise, loaderPromise])
|
package/src/react.tsx
CHANGED
|
@@ -598,6 +598,20 @@ export function useNavigate<
|
|
|
598
598
|
)
|
|
599
599
|
}
|
|
600
600
|
|
|
601
|
+
export function typedNavigate<
|
|
602
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
603
|
+
TDefaultFrom extends RoutePaths<TRouteTree> = '/',
|
|
604
|
+
>(navigate: (opts: NavigateOptions<any>) => Promise<void>) {
|
|
605
|
+
return navigate as <
|
|
606
|
+
TFrom extends RoutePaths<TRouteTree> = TDefaultFrom,
|
|
607
|
+
TTo extends string = '',
|
|
608
|
+
TMaskFrom extends RoutePaths<TRouteTree> = '/',
|
|
609
|
+
TMaskTo extends string = '',
|
|
610
|
+
>(
|
|
611
|
+
opts?: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,
|
|
612
|
+
) => Promise<void>
|
|
613
|
+
}
|
|
614
|
+
|
|
601
615
|
export function useMatchRoute<
|
|
602
616
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
603
617
|
>() {
|
package/src/route.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
UnionToIntersection,
|
|
12
12
|
Assign,
|
|
13
13
|
} from './utils'
|
|
14
|
-
import { ParsePathParams, ToSubOptions } from './link'
|
|
14
|
+
import { NavigateOptions, ParsePathParams, ToSubOptions } from './link'
|
|
15
15
|
import {
|
|
16
16
|
ErrorRouteComponent,
|
|
17
17
|
PendingRouteComponent,
|
|
@@ -154,6 +154,7 @@ type BeforeLoadFn<
|
|
|
154
154
|
params: TAllParams
|
|
155
155
|
meta: TParentRoute['types']['allMeta']
|
|
156
156
|
location: ParsedLocation
|
|
157
|
+
navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>
|
|
157
158
|
}) => Promise<TRouteMeta> | TRouteMeta | void
|
|
158
159
|
|
|
159
160
|
export type UpdatableRouteOptions<
|
|
@@ -265,6 +266,8 @@ export interface LoadFnContext<
|
|
|
265
266
|
params: TAllParams
|
|
266
267
|
search: TFullSearchSchema
|
|
267
268
|
meta: Expand<Assign<TAllContext, TRouteMeta>>
|
|
269
|
+
location: ParsedLocation<TFullSearchSchema>
|
|
270
|
+
navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>
|
|
268
271
|
}
|
|
269
272
|
|
|
270
273
|
export type SearchFilter<T, U = T> = (prev: T) => U
|