@tanstack/react-router 0.0.1-beta.263 → 0.0.1-beta.264
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/Matches.js.map +1 -1
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/route.js +39 -0
- package/build/cjs/route.js.map +1 -1
- package/build/esm/index.js +39 -1
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +353 -353
- package/build/types/Matches.d.ts +1 -1
- package/build/types/route.d.ts +23 -2
- package/build/umd/index.development.js +39 -0
- 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/Matches.tsx +1 -1
- package/src/route.ts +58 -2
package/build/types/Matches.d.ts
CHANGED
|
@@ -52,6 +52,6 @@ export declare function useMatch<TRouteTree extends AnyRoute = RegisteredRouter[
|
|
|
52
52
|
export declare function useMatches<T = RouteMatch[]>(opts?: {
|
|
53
53
|
select?: (matches: RouteMatch[]) => T;
|
|
54
54
|
}): T;
|
|
55
|
-
export declare function useLoaderData<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TStrict extends boolean = true, TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<TRouteTree, TFrom>, TSelected = TRouteMatch['loaderData']>(opts: StrictOrFrom<TFrom> & {
|
|
55
|
+
export declare function useLoaderData<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TStrict extends boolean = true, TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<TRouteTree, TFrom>, TSelected = Required<TRouteMatch>['loaderData']>(opts: StrictOrFrom<TFrom> & {
|
|
56
56
|
select?: (match: TRouteMatch) => TSelected;
|
|
57
57
|
}): TStrict extends true ? TSelected : TSelected | undefined;
|
package/build/types/route.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
import { AnyRouteMatch } from './Matches';
|
|
3
3
|
import { NavigateOptions, ParsePathParams, ToSubOptions } from './link';
|
|
4
4
|
import { ParsedLocation } from './location';
|
|
5
|
-
import { RoutePaths } from './routeInfo';
|
|
6
|
-
import { AnyRouter } from './router';
|
|
5
|
+
import { RouteById, RouteIds, RoutePaths } from './routeInfo';
|
|
6
|
+
import { AnyRouter, RegisteredRouter } from './router';
|
|
7
7
|
import { Assign, Expand, IsAny, NoInfer, PickRequired, UnionToIntersection } from './utils';
|
|
8
8
|
import { BuildLocationFn, NavigateFn } from './RouterProvider';
|
|
9
9
|
export declare const rootRouteId: "__root__";
|
|
@@ -141,6 +141,27 @@ export type RouteConstraints = {
|
|
|
141
141
|
TChildren: unknown;
|
|
142
142
|
TRouteTree: AnyRoute;
|
|
143
143
|
};
|
|
144
|
+
export declare class RouteApi<TId extends RouteIds<RegisteredRouter['routeTree']>, TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>, TFullSearchSchema extends Record<string, any> = TRoute['types']['fullSearchSchema'], TAllParams extends AnyPathParams = TRoute['types']['allParams'], TAllContext extends Record<string, any> = TRoute['types']['allContext'], TLoaderData extends any = TRoute['types']['loaderData']> {
|
|
145
|
+
id: TId;
|
|
146
|
+
constructor({ id }: {
|
|
147
|
+
id: TId;
|
|
148
|
+
});
|
|
149
|
+
useMatch: <TSelected = TAllContext>(opts?: {
|
|
150
|
+
select?: ((search: TAllContext) => TSelected) | undefined;
|
|
151
|
+
} | undefined) => TSelected;
|
|
152
|
+
useRouteContext: <TSelected = TAllContext>(opts?: {
|
|
153
|
+
select?: ((search: TAllContext) => TSelected) | undefined;
|
|
154
|
+
} | undefined) => TSelected;
|
|
155
|
+
useSearch: <TSelected = TFullSearchSchema>(opts?: {
|
|
156
|
+
select?: ((search: TFullSearchSchema) => TSelected) | undefined;
|
|
157
|
+
} | undefined) => TSelected;
|
|
158
|
+
useParams: <TSelected = TAllParams>(opts?: {
|
|
159
|
+
select?: ((search: TAllParams) => TSelected) | undefined;
|
|
160
|
+
} | undefined) => TSelected;
|
|
161
|
+
useLoaderData: <TSelected = TLoaderData>(opts?: {
|
|
162
|
+
select?: ((search: TLoaderData) => TSelected) | undefined;
|
|
163
|
+
} | undefined) => TSelected;
|
|
164
|
+
}
|
|
144
165
|
export declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends RouteConstraints['TAllParams'] = ResolveAllParams<TParentRoute, TParams>, TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext extends Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderData extends any = unknown, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> {
|
|
145
166
|
isRoot: TParentRoute extends Route<any> ? true : false;
|
|
146
167
|
options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderData>;
|
|
@@ -1122,6 +1122,44 @@
|
|
|
1122
1122
|
|
|
1123
1123
|
// The parse type here allows a zod schema to be passed directly to the validator
|
|
1124
1124
|
|
|
1125
|
+
class RouteApi {
|
|
1126
|
+
constructor({
|
|
1127
|
+
id
|
|
1128
|
+
}) {
|
|
1129
|
+
this.id = id;
|
|
1130
|
+
}
|
|
1131
|
+
useMatch = opts => {
|
|
1132
|
+
return useMatch({
|
|
1133
|
+
...opts,
|
|
1134
|
+
from: this.id
|
|
1135
|
+
});
|
|
1136
|
+
};
|
|
1137
|
+
useRouteContext = opts => {
|
|
1138
|
+
return useMatch({
|
|
1139
|
+
...opts,
|
|
1140
|
+
from: this.id,
|
|
1141
|
+
select: d => opts?.select ? opts.select(d.context) : d.context
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1144
|
+
useSearch = opts => {
|
|
1145
|
+
return useSearch({
|
|
1146
|
+
...opts,
|
|
1147
|
+
from: this.id
|
|
1148
|
+
});
|
|
1149
|
+
};
|
|
1150
|
+
useParams = opts => {
|
|
1151
|
+
return useParams({
|
|
1152
|
+
...opts,
|
|
1153
|
+
from: this.id
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1156
|
+
useLoaderData = opts => {
|
|
1157
|
+
return useLoaderData({
|
|
1158
|
+
...opts,
|
|
1159
|
+
from: this.id
|
|
1160
|
+
});
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1125
1163
|
class Route {
|
|
1126
1164
|
// Set up in this.init()
|
|
1127
1165
|
|
|
@@ -3186,6 +3224,7 @@
|
|
|
3186
3224
|
exports.PathParamError = PathParamError;
|
|
3187
3225
|
exports.RootRoute = RootRoute;
|
|
3188
3226
|
exports.Route = Route;
|
|
3227
|
+
exports.RouteApi = RouteApi;
|
|
3189
3228
|
exports.Router = Router;
|
|
3190
3229
|
exports.RouterProvider = RouterProvider;
|
|
3191
3230
|
exports.ScrollRestoration = ScrollRestoration;
|