@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/build/types/react.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ export declare function useParams<TRouteTree extends AnyRoute = RegisteredRouter
|
|
|
98
98
|
export declare function useNavigate<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TDefaultFrom extends RoutePaths<TRouteTree> = '/'>(defaultOpts?: {
|
|
99
99
|
from?: TDefaultFrom;
|
|
100
100
|
}): <TFrom extends RoutePaths<TRouteTree> = TDefaultFrom, TTo extends string = "", TMaskFrom extends RoutePaths<TRouteTree> = "/", TMaskTo extends string = "">(opts?: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> | undefined) => Promise<void>;
|
|
101
|
+
export declare function typedNavigate<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TDefaultFrom extends RoutePaths<TRouteTree> = '/'>(navigate: (opts: NavigateOptions<any>) => Promise<void>): <TFrom extends RoutePaths<TRouteTree> = TDefaultFrom, TTo extends string = "", TMaskFrom extends RoutePaths<TRouteTree> = "/", TMaskTo extends string = "">(opts?: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> | undefined) => Promise<void>;
|
|
101
102
|
export declare function useMatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree']>(): <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TMaskFrom extends RoutePaths<TRouteTree> = "/", TMaskTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(opts: MakeUseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
102
103
|
export declare function Matches(): JSX.Element;
|
|
103
104
|
export declare function MatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = '/', TMaskTo extends string = ''>(props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): any;
|
package/build/types/route.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { RoutePaths } from './routeInfo';
|
|
|
2
2
|
import { AnyRouter } from './router';
|
|
3
3
|
import { AnyRouteMatch } from './RouteMatch';
|
|
4
4
|
import { Expand, IsAny, NoInfer, PickRequired, UnionToIntersection, Assign } from './utils';
|
|
5
|
-
import { ParsePathParams, ToSubOptions } from './link';
|
|
5
|
+
import { NavigateOptions, ParsePathParams, ToSubOptions } from './link';
|
|
6
6
|
import { ErrorRouteComponent, PendingRouteComponent, RouteComponent } from './react';
|
|
7
7
|
import { ParsedLocation } from './location';
|
|
8
8
|
export declare const rootRouteId: "__root__";
|
|
@@ -46,6 +46,7 @@ type BeforeLoadFn<TFullSearchSchema extends Record<string, any>, TParentRoute ex
|
|
|
46
46
|
params: TAllParams;
|
|
47
47
|
meta: TParentRoute['types']['allMeta'];
|
|
48
48
|
location: ParsedLocation;
|
|
49
|
+
navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>;
|
|
49
50
|
}) => Promise<TRouteMeta> | TRouteMeta | void;
|
|
50
51
|
export type UpdatableRouteOptions<TFullSearchSchema extends Record<string, any>, TAllParams extends AnyPathParams, TAllContext extends AnyContext> = {
|
|
51
52
|
caseSensitive?: boolean;
|
|
@@ -84,6 +85,8 @@ export interface LoadFnContext<TAllParams = {}, TFullSearchSchema extends Record
|
|
|
84
85
|
params: TAllParams;
|
|
85
86
|
search: TFullSearchSchema;
|
|
86
87
|
meta: Expand<Assign<TAllContext, TRouteMeta>>;
|
|
88
|
+
location: ParsedLocation<TFullSearchSchema>;
|
|
89
|
+
navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>;
|
|
87
90
|
}
|
|
88
91
|
export type SearchFilter<T, U = T> = (prev: T) => U;
|
|
89
92
|
export type ResolveId<TParentRoute, TCustomId extends string, TPath extends string> = TParentRoute extends {
|
|
@@ -1498,7 +1498,12 @@
|
|
|
1498
1498
|
params: match.params,
|
|
1499
1499
|
preload: !!preload,
|
|
1500
1500
|
meta: parentMeta,
|
|
1501
|
-
location: state.location
|
|
1501
|
+
location: state.location,
|
|
1502
|
+
// TODO: This might need to be latestLocationRef.current...?
|
|
1503
|
+
navigate: opts => navigate({
|
|
1504
|
+
...opts,
|
|
1505
|
+
from: match.pathname
|
|
1506
|
+
})
|
|
1502
1507
|
})) ?? {};
|
|
1503
1508
|
const meta = {
|
|
1504
1509
|
...parentMeta,
|
|
@@ -1552,7 +1557,12 @@
|
|
|
1552
1557
|
preload: !!preload,
|
|
1553
1558
|
parentMatchPromise,
|
|
1554
1559
|
abortController: match.abortController,
|
|
1555
|
-
meta: match.meta
|
|
1560
|
+
meta: match.meta,
|
|
1561
|
+
location: state.location,
|
|
1562
|
+
navigate: opts => navigate({
|
|
1563
|
+
...opts,
|
|
1564
|
+
from: match.pathname
|
|
1565
|
+
})
|
|
1556
1566
|
});
|
|
1557
1567
|
await Promise.all([componentsPromise, loaderPromise]);
|
|
1558
1568
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
@@ -2139,6 +2149,9 @@
|
|
|
2139
2149
|
});
|
|
2140
2150
|
}, []);
|
|
2141
2151
|
}
|
|
2152
|
+
function typedNavigate(navigate) {
|
|
2153
|
+
return navigate;
|
|
2154
|
+
}
|
|
2142
2155
|
function useMatchRoute() {
|
|
2143
2156
|
const {
|
|
2144
2157
|
state,
|
|
@@ -2627,6 +2640,7 @@
|
|
|
2627
2640
|
exports.trimPath = trimPath;
|
|
2628
2641
|
exports.trimPathLeft = trimPathLeft;
|
|
2629
2642
|
exports.trimPathRight = trimPathRight;
|
|
2643
|
+
exports.typedNavigate = typedNavigate;
|
|
2630
2644
|
exports.useBlocker = useBlocker;
|
|
2631
2645
|
exports.useLinkProps = useLinkProps;
|
|
2632
2646
|
exports.useMatch = useMatch;
|