@tanstack/react-router 1.0.8 → 1.1.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/build/cjs/RouterProvider.js.map +1 -1
- package/build/cjs/fileRoute.js.map +1 -1
- package/build/cjs/link.js.map +1 -1
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/useNavigate.js.map +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +351 -351
- package/build/types/RouterProvider.d.ts +1 -1
- package/build/types/fileRoute.d.ts +3 -3
- package/build/types/link.d.ts +14 -13
- package/build/types/route.d.ts +33 -17
- package/build/types/routeInfo.d.ts +1 -1
- package/build/types/useNavigate.d.ts +5 -5
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/RouterProvider.tsx +2 -2
- package/src/fileRoute.ts +20 -0
- package/src/link.tsx +26 -23
- package/src/route.ts +95 -10
- package/src/routeInfo.ts +3 -0
- package/src/useNavigate.tsx +10 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@tanstack/store": "^0.1.3",
|
|
45
45
|
"tiny-invariant": "^1.3.1",
|
|
46
46
|
"tiny-warning": "^1.0.3",
|
|
47
|
-
"@tanstack/history": "1.0
|
|
47
|
+
"@tanstack/history": "1.1.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup --config rollup.config.js"
|
package/src/RouterProvider.tsx
CHANGED
|
@@ -41,9 +41,9 @@ export interface MatchLocation {
|
|
|
41
41
|
|
|
42
42
|
export type NavigateFn<TRouteTree extends AnyRoute> = <
|
|
43
43
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
44
|
-
TTo extends string
|
|
44
|
+
TTo extends string = '',
|
|
45
45
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
46
|
-
TMaskTo extends string
|
|
46
|
+
TMaskTo extends string = '',
|
|
47
47
|
>(
|
|
48
48
|
opts: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,
|
|
49
49
|
) => Promise<void>
|
package/src/fileRoute.ts
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
RootRouteId,
|
|
14
14
|
TrimPathLeft,
|
|
15
15
|
RouteConstraints,
|
|
16
|
+
ResolveFullSearchSchemaInput,
|
|
17
|
+
SearchSchemaInput,
|
|
16
18
|
} from './route'
|
|
17
19
|
import { Assign, Expand, IsAny } from './utils'
|
|
18
20
|
|
|
@@ -85,7 +87,19 @@ export class FileRoute<
|
|
|
85
87
|
constructor(public path: TFilePath) {}
|
|
86
88
|
|
|
87
89
|
createRoute = <
|
|
90
|
+
TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {},
|
|
88
91
|
TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
92
|
+
TSearchSchemaUsed extends Record<
|
|
93
|
+
string,
|
|
94
|
+
any
|
|
95
|
+
> = TSearchSchemaInput extends SearchSchemaInput
|
|
96
|
+
? TSearchSchemaInput
|
|
97
|
+
: TSearchSchema,
|
|
98
|
+
TFullSearchSchemaInput extends
|
|
99
|
+
RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<
|
|
100
|
+
TParentRoute,
|
|
101
|
+
TSearchSchemaUsed
|
|
102
|
+
>,
|
|
89
103
|
TFullSearchSchema extends
|
|
90
104
|
RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
|
|
91
105
|
TParentRoute,
|
|
@@ -115,7 +129,10 @@ export class FileRoute<
|
|
|
115
129
|
TParentRoute,
|
|
116
130
|
string,
|
|
117
131
|
TPath,
|
|
132
|
+
TSearchSchemaInput,
|
|
118
133
|
TSearchSchema,
|
|
134
|
+
TSearchSchemaUsed,
|
|
135
|
+
TFullSearchSchemaInput,
|
|
119
136
|
TFullSearchSchema,
|
|
120
137
|
TParams,
|
|
121
138
|
TAllParams,
|
|
@@ -133,7 +150,10 @@ export class FileRoute<
|
|
|
133
150
|
TFullPath,
|
|
134
151
|
TFilePath,
|
|
135
152
|
TId,
|
|
153
|
+
TSearchSchemaInput,
|
|
136
154
|
TSearchSchema,
|
|
155
|
+
TSearchSchemaUsed,
|
|
156
|
+
TFullSearchSchemaInput,
|
|
137
157
|
TFullSearchSchema,
|
|
138
158
|
TParams,
|
|
139
159
|
TAllParams,
|
package/src/link.tsx
CHANGED
|
@@ -118,9 +118,9 @@ export type RelativeToPathAutoComplete<
|
|
|
118
118
|
export type NavigateOptions<
|
|
119
119
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
120
120
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
121
|
-
TTo extends string
|
|
121
|
+
TTo extends string = '',
|
|
122
122
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
123
|
-
TMaskTo extends string
|
|
123
|
+
TMaskTo extends string = '',
|
|
124
124
|
> = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
125
125
|
// `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.
|
|
126
126
|
replace?: boolean
|
|
@@ -132,9 +132,9 @@ export type NavigateOptions<
|
|
|
132
132
|
export type ToOptions<
|
|
133
133
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
134
134
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
135
|
-
TTo extends string
|
|
135
|
+
TTo extends string = '',
|
|
136
136
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
137
|
-
TMaskTo extends string
|
|
137
|
+
TMaskTo extends string = '',
|
|
138
138
|
> = ToSubOptions<TRouteTree, TFrom, TTo> & {
|
|
139
139
|
mask?: ToMaskOptions<TRouteTree, TMaskFrom, TMaskTo>
|
|
140
140
|
}
|
|
@@ -142,7 +142,7 @@ export type ToOptions<
|
|
|
142
142
|
export type ToMaskOptions<
|
|
143
143
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
144
144
|
TMaskFrom extends RoutePaths<TRouteTree> | string = string,
|
|
145
|
-
TMaskTo extends string
|
|
145
|
+
TMaskTo extends string = '',
|
|
146
146
|
> = ToSubOptions<TRouteTree, TMaskFrom, TMaskTo> & {
|
|
147
147
|
unmaskOnReload?: boolean
|
|
148
148
|
}
|
|
@@ -150,7 +150,7 @@ export type ToMaskOptions<
|
|
|
150
150
|
export type ToSubOptions<
|
|
151
151
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
152
152
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
153
|
-
TTo extends string
|
|
153
|
+
TTo extends string = '',
|
|
154
154
|
TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
|
|
155
155
|
> = {
|
|
156
156
|
to?: ToPathOption<TRouteTree, TFrom, TTo>
|
|
@@ -167,18 +167,21 @@ export type ToSubOptions<
|
|
|
167
167
|
|
|
168
168
|
type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo)
|
|
169
169
|
|
|
170
|
+
type ParamVariant = 'PATH' | 'SEARCH';
|
|
170
171
|
export type ParamOptions<
|
|
171
172
|
TRouteTree extends AnyRoute,
|
|
172
173
|
TFrom,
|
|
173
174
|
TTo,
|
|
174
175
|
TResolved,
|
|
175
|
-
TParamVariant extends
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
TParamVariant extends ParamVariant,
|
|
177
|
+
TFromRouteType extends 'allParams' | 'fullSearchSchema' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema',
|
|
178
|
+
TToRouteType extends 'allParams' | 'fullSearchSchemaInput' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput',
|
|
179
|
+
TFromParams = Expand<RouteByPath<TRouteTree, TFrom>['types'][TFromRouteType]>,
|
|
180
|
+
TToParams = TTo extends ''
|
|
178
181
|
? TFromParams
|
|
179
182
|
: never extends TResolved
|
|
180
|
-
? Expand<RouteByPath<TRouteTree, TTo>['types'][
|
|
181
|
-
: Expand<RouteByPath<TRouteTree, TResolved>['types'][
|
|
183
|
+
? Expand<RouteByPath<TRouteTree, TTo>['types'][TToRouteType]>
|
|
184
|
+
: Expand<RouteByPath<TRouteTree, TResolved>['types'][TToRouteType]>,
|
|
182
185
|
TReducer = ParamsReducer<TFromParams, TToParams>,
|
|
183
186
|
> = Expand<WithoutEmpty<PickRequired<TToParams>>> extends never
|
|
184
187
|
? Partial<MakeParamOption<TParamVariant, true | TReducer>>
|
|
@@ -187,9 +190,9 @@ export type ParamOptions<
|
|
|
187
190
|
: MakeParamOption<TParamVariant, TReducer>
|
|
188
191
|
|
|
189
192
|
type MakeParamOption<
|
|
190
|
-
TParamVariant extends
|
|
193
|
+
TParamVariant extends ParamVariant,
|
|
191
194
|
T,
|
|
192
|
-
> = TParamVariant extends '
|
|
195
|
+
> = TParamVariant extends 'PATH'
|
|
193
196
|
? MakePathParamOptions<T>
|
|
194
197
|
: MakeSearchParamOptions<T>
|
|
195
198
|
type MakeSearchParamOptions<T> = { search: T }
|
|
@@ -200,19 +203,19 @@ export type SearchParamOptions<
|
|
|
200
203
|
TFrom,
|
|
201
204
|
TTo,
|
|
202
205
|
TResolved,
|
|
203
|
-
> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, '
|
|
206
|
+
> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, 'SEARCH'>
|
|
204
207
|
|
|
205
208
|
export type PathParamOptions<
|
|
206
209
|
TRouteTree extends AnyRoute,
|
|
207
210
|
TFrom,
|
|
208
211
|
TTo,
|
|
209
212
|
TResolved,
|
|
210
|
-
> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, '
|
|
213
|
+
> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, 'PATH'>
|
|
211
214
|
|
|
212
215
|
export type ToPathOption<
|
|
213
216
|
TRouteTree extends AnyRoute = AnyRoute,
|
|
214
217
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
215
|
-
TTo extends string
|
|
218
|
+
TTo extends string = '',
|
|
216
219
|
> =
|
|
217
220
|
| TTo
|
|
218
221
|
| RelativeToPathAutoComplete<
|
|
@@ -224,7 +227,7 @@ export type ToPathOption<
|
|
|
224
227
|
export type ToIdOption<
|
|
225
228
|
TRouteTree extends AnyRoute = AnyRoute,
|
|
226
229
|
TFrom extends RoutePaths<TRouteTree> | undefined = undefined,
|
|
227
|
-
TTo extends string
|
|
230
|
+
TTo extends string = '',
|
|
228
231
|
> =
|
|
229
232
|
| TTo
|
|
230
233
|
| RelativeToPathAutoComplete<
|
|
@@ -242,9 +245,9 @@ export interface ActiveOptions {
|
|
|
242
245
|
export type LinkOptions<
|
|
243
246
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
244
247
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
245
|
-
TTo extends string
|
|
248
|
+
TTo extends string = '',
|
|
246
249
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
247
|
-
TMaskTo extends string
|
|
250
|
+
TMaskTo extends string = '',
|
|
248
251
|
> = NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
249
252
|
// The standard anchor tag target attribute
|
|
250
253
|
target?: HTMLAnchorElement['target']
|
|
@@ -334,9 +337,9 @@ const preloadWarning = 'Error preloading route! ☝️'
|
|
|
334
337
|
export function useLinkProps<
|
|
335
338
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
336
339
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
337
|
-
TTo extends string
|
|
340
|
+
TTo extends string = '',
|
|
338
341
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
339
|
-
TMaskTo extends string
|
|
342
|
+
TMaskTo extends string = '',
|
|
340
343
|
>(
|
|
341
344
|
options: UseLinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,
|
|
342
345
|
): React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
@@ -553,9 +556,9 @@ export interface LinkComponent<TProps extends Record<string, any> = {}> {
|
|
|
553
556
|
<
|
|
554
557
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
555
558
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
556
|
-
TTo extends string
|
|
559
|
+
TTo extends string = '',
|
|
557
560
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
558
|
-
TMaskTo extends string
|
|
561
|
+
TMaskTo extends string = '',
|
|
559
562
|
>(
|
|
560
563
|
props: LinkProps<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &
|
|
561
564
|
TProps &
|
package/src/route.ts
CHANGED
|
@@ -23,6 +23,10 @@ export const rootRouteId = '__root__' as const
|
|
|
23
23
|
export type RootRouteId = typeof rootRouteId
|
|
24
24
|
export type AnyPathParams = {}
|
|
25
25
|
|
|
26
|
+
export type SearchSchemaInput = {
|
|
27
|
+
__TSearchSchemaInput__: 'TSearchSchemaInput'
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
export type AnySearchSchema = {}
|
|
27
31
|
|
|
28
32
|
export type AnyContext = {}
|
|
@@ -56,7 +60,10 @@ export type RouteOptions<
|
|
|
56
60
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
57
61
|
TCustomId extends string = string,
|
|
58
62
|
TPath extends string = string,
|
|
63
|
+
TSearchSchemaInput extends Record<string, any> = {},
|
|
59
64
|
TSearchSchema extends Record<string, any> = {},
|
|
65
|
+
TSearchSchemaUsed extends Record<string, any> = {},
|
|
66
|
+
TFullSearchSchemaInput extends Record<string, any> = TSearchSchemaUsed,
|
|
60
67
|
TFullSearchSchema extends Record<string, any> = TSearchSchema,
|
|
61
68
|
TParams extends AnyPathParams = AnyPathParams,
|
|
62
69
|
TAllParams extends AnyPathParams = TParams,
|
|
@@ -68,7 +75,10 @@ export type RouteOptions<
|
|
|
68
75
|
TParentRoute,
|
|
69
76
|
TCustomId,
|
|
70
77
|
TPath,
|
|
78
|
+
TSearchSchemaInput,
|
|
71
79
|
TSearchSchema,
|
|
80
|
+
TSearchSchemaUsed,
|
|
81
|
+
TFullSearchSchemaInput,
|
|
72
82
|
TFullSearchSchema,
|
|
73
83
|
TParams,
|
|
74
84
|
TAllParams,
|
|
@@ -88,7 +98,10 @@ export type BaseRouteOptions<
|
|
|
88
98
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
89
99
|
TCustomId extends string = string,
|
|
90
100
|
TPath extends string = string,
|
|
101
|
+
TSearchSchemaInput extends Record<string, any> = {},
|
|
91
102
|
TSearchSchema extends Record<string, any> = {},
|
|
103
|
+
TSearchSchemaUsed extends Record<string, any> = {},
|
|
104
|
+
TFullSearchSchemaInput extends Record<string, any> = TSearchSchemaUsed,
|
|
92
105
|
TFullSearchSchema extends Record<string, any> = TSearchSchema,
|
|
93
106
|
TParams extends AnyPathParams = {},
|
|
94
107
|
TAllParams = ParamsFallback<TPath, TParams>,
|
|
@@ -98,7 +111,7 @@ export type BaseRouteOptions<
|
|
|
98
111
|
TLoaderData extends any = unknown,
|
|
99
112
|
> = RoutePathOptions<TCustomId, TPath> & {
|
|
100
113
|
getParentRoute: () => TParentRoute
|
|
101
|
-
validateSearch?: SearchSchemaValidator<TSearchSchema>
|
|
114
|
+
validateSearch?: SearchSchemaValidator<TSearchSchemaInput, TSearchSchema>
|
|
102
115
|
shouldReload?:
|
|
103
116
|
| boolean
|
|
104
117
|
| ((
|
|
@@ -221,16 +234,16 @@ export type ParseParamsObj<TPath extends string, TParams> = {
|
|
|
221
234
|
}
|
|
222
235
|
|
|
223
236
|
// The parse type here allows a zod schema to be passed directly to the validator
|
|
224
|
-
export type SearchSchemaValidator<TReturn> =
|
|
225
|
-
| SearchSchemaValidatorObj<TReturn>
|
|
226
|
-
| SearchSchemaValidatorFn<TReturn>
|
|
237
|
+
export type SearchSchemaValidator<TInput, TReturn> =
|
|
238
|
+
| SearchSchemaValidatorObj<TInput, TReturn>
|
|
239
|
+
| SearchSchemaValidatorFn<TInput, TReturn>
|
|
227
240
|
|
|
228
|
-
export type SearchSchemaValidatorObj<TReturn> = {
|
|
229
|
-
parse?: SearchSchemaValidatorFn<TReturn>
|
|
241
|
+
export type SearchSchemaValidatorObj<TInput, TReturn> = {
|
|
242
|
+
parse?: SearchSchemaValidatorFn<TInput, TReturn>
|
|
230
243
|
}
|
|
231
244
|
|
|
232
|
-
export type SearchSchemaValidatorFn<TReturn> = (
|
|
233
|
-
searchObj:
|
|
245
|
+
export type SearchSchemaValidatorFn<TInput, TReturn> = (
|
|
246
|
+
searchObj: TInput,
|
|
234
247
|
) => TReturn
|
|
235
248
|
|
|
236
249
|
export type DefinedPathParamWarning =
|
|
@@ -287,10 +300,21 @@ export type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
|
287
300
|
? TFullSearchSchema
|
|
288
301
|
: {}
|
|
289
302
|
|
|
303
|
+
export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
304
|
+
types: {
|
|
305
|
+
fullSearchSchemaInput: infer TFullSearchSchemaInput
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
? TFullSearchSchemaInput
|
|
309
|
+
: {}
|
|
310
|
+
|
|
290
311
|
export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<
|
|
291
312
|
Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>
|
|
292
313
|
>
|
|
293
314
|
|
|
315
|
+
export type ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed> =
|
|
316
|
+
Expand<Assign<InferFullSearchSchemaInput<TParentRoute>, TSearchSchemaUsed>>
|
|
317
|
+
|
|
294
318
|
export interface AnyRoute
|
|
295
319
|
extends Route<
|
|
296
320
|
any,
|
|
@@ -308,6 +332,9 @@ export interface AnyRoute
|
|
|
308
332
|
any,
|
|
309
333
|
any,
|
|
310
334
|
any,
|
|
335
|
+
any,
|
|
336
|
+
any,
|
|
337
|
+
any,
|
|
311
338
|
any
|
|
312
339
|
> {}
|
|
313
340
|
|
|
@@ -412,7 +439,18 @@ export class Route<
|
|
|
412
439
|
TCustomId,
|
|
413
440
|
TPath
|
|
414
441
|
>,
|
|
442
|
+
TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {},
|
|
415
443
|
TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
444
|
+
TSearchSchemaUsed extends Record<
|
|
445
|
+
string,
|
|
446
|
+
any
|
|
447
|
+
> = TSearchSchemaInput extends SearchSchemaInput
|
|
448
|
+
? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
|
|
449
|
+
: TSearchSchema,
|
|
450
|
+
TFullSearchSchemaInput extends Record<
|
|
451
|
+
string,
|
|
452
|
+
any
|
|
453
|
+
> = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>,
|
|
416
454
|
TFullSearchSchema extends
|
|
417
455
|
RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
|
|
418
456
|
TParentRoute,
|
|
@@ -442,7 +480,10 @@ export class Route<
|
|
|
442
480
|
TParentRoute,
|
|
443
481
|
TCustomId,
|
|
444
482
|
TPath,
|
|
483
|
+
TSearchSchemaInput,
|
|
445
484
|
TSearchSchema,
|
|
485
|
+
TSearchSchemaUsed,
|
|
486
|
+
TFullSearchSchemaInput,
|
|
446
487
|
TFullSearchSchema,
|
|
447
488
|
TParams,
|
|
448
489
|
TAllParams,
|
|
@@ -475,7 +516,10 @@ export class Route<
|
|
|
475
516
|
TParentRoute,
|
|
476
517
|
TCustomId,
|
|
477
518
|
TPath,
|
|
519
|
+
TSearchSchemaInput,
|
|
478
520
|
TSearchSchema,
|
|
521
|
+
TSearchSchemaUsed,
|
|
522
|
+
TFullSearchSchemaInput,
|
|
479
523
|
TFullSearchSchema,
|
|
480
524
|
TParams,
|
|
481
525
|
TAllParams,
|
|
@@ -502,7 +546,10 @@ export class Route<
|
|
|
502
546
|
customId: TCustomId
|
|
503
547
|
id: TId
|
|
504
548
|
searchSchema: TSearchSchema
|
|
549
|
+
searchSchemaInput: TSearchSchemaInput
|
|
550
|
+
searchSchemaUsed: TSearchSchemaUsed
|
|
505
551
|
fullSearchSchema: TFullSearchSchema
|
|
552
|
+
fullSearchSchemaInput: TFullSearchSchemaInput
|
|
506
553
|
params: TParams
|
|
507
554
|
allParams: TAllParams
|
|
508
555
|
routeContext: TRouteContext
|
|
@@ -521,7 +568,10 @@ export class Route<
|
|
|
521
568
|
TParentRoute,
|
|
522
569
|
TCustomId,
|
|
523
570
|
TPath,
|
|
571
|
+
TSearchSchemaInput,
|
|
524
572
|
TSearchSchema,
|
|
573
|
+
TSearchSchemaUsed,
|
|
574
|
+
TFullSearchSchemaInput,
|
|
525
575
|
TFullSearchSchema,
|
|
526
576
|
TParams,
|
|
527
577
|
TAllParams,
|
|
@@ -590,7 +640,10 @@ export class Route<
|
|
|
590
640
|
TFullPath,
|
|
591
641
|
TCustomId,
|
|
592
642
|
TId,
|
|
643
|
+
TSearchSchemaInput,
|
|
593
644
|
TSearchSchema,
|
|
645
|
+
TSearchSchemaUsed,
|
|
646
|
+
TFullSearchSchemaInput,
|
|
594
647
|
TFullSearchSchema,
|
|
595
648
|
TParams,
|
|
596
649
|
TAllParams,
|
|
@@ -652,11 +705,13 @@ export class Route<
|
|
|
652
705
|
}
|
|
653
706
|
}
|
|
654
707
|
|
|
655
|
-
export type AnyRootRoute = RootRoute<any, any, any, any>
|
|
708
|
+
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>
|
|
656
709
|
|
|
657
710
|
export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
658
711
|
return <
|
|
712
|
+
TSearchSchemaInput extends Record<string, any> = {},
|
|
659
713
|
TSearchSchema extends Record<string, any> = {},
|
|
714
|
+
TSearchSchemaUsed extends Record<string, any> = {},
|
|
660
715
|
TRouteContext extends RouteContext = RouteContext,
|
|
661
716
|
TLoaderDeps extends Record<string, any> = {},
|
|
662
717
|
TLoaderData extends any = unknown,
|
|
@@ -666,7 +721,10 @@ export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
|
666
721
|
AnyRoute, // TParentRoute
|
|
667
722
|
RootRouteId, // TCustomId
|
|
668
723
|
'', // TPath
|
|
724
|
+
TSearchSchemaInput, // TSearchSchemaInput
|
|
669
725
|
TSearchSchema, // TSearchSchema
|
|
726
|
+
TSearchSchemaUsed,
|
|
727
|
+
TSearchSchemaUsed, //TFullSearchSchemaInput
|
|
670
728
|
TSearchSchema, // TFullSearchSchema
|
|
671
729
|
{}, // TParams
|
|
672
730
|
{}, // TAllParams
|
|
@@ -682,13 +740,21 @@ export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
|
682
740
|
| 'parseParams'
|
|
683
741
|
| 'stringifyParams'
|
|
684
742
|
>,
|
|
685
|
-
): RootRoute<
|
|
743
|
+
): RootRoute<
|
|
744
|
+
TSearchSchemaInput,
|
|
745
|
+
TSearchSchema,
|
|
746
|
+
TSearchSchemaUsed,
|
|
747
|
+
TRouteContext,
|
|
748
|
+
TRouterContext
|
|
749
|
+
> => {
|
|
686
750
|
return new RootRoute(options) as any
|
|
687
751
|
}
|
|
688
752
|
}
|
|
689
753
|
|
|
690
754
|
export class RootRoute<
|
|
755
|
+
TSearchSchemaInput extends Record<string, any> = {},
|
|
691
756
|
TSearchSchema extends Record<string, any> = {},
|
|
757
|
+
TSearchSchemaUsed extends Record<string, any> = {},
|
|
692
758
|
TRouteContext extends RouteContext = RouteContext,
|
|
693
759
|
TRouterContext extends {} = {},
|
|
694
760
|
TLoaderDeps extends Record<string, any> = {},
|
|
@@ -699,7 +765,10 @@ export class RootRoute<
|
|
|
699
765
|
'/', // TFullPath
|
|
700
766
|
string, // TCustomId
|
|
701
767
|
RootRouteId, // TId
|
|
768
|
+
TSearchSchemaInput, // TSearchSchemaInput
|
|
702
769
|
TSearchSchema, // TSearchSchema
|
|
770
|
+
TSearchSchemaUsed,
|
|
771
|
+
TSearchSchemaUsed, // TFullSearchSchemaInput
|
|
703
772
|
TSearchSchema, // TFullSearchSchema
|
|
704
773
|
{}, // TParams
|
|
705
774
|
{}, // TAllParams
|
|
@@ -717,7 +786,10 @@ export class RootRoute<
|
|
|
717
786
|
AnyRoute, // TParentRoute
|
|
718
787
|
RootRouteId, // TCustomId
|
|
719
788
|
'', // TPath
|
|
789
|
+
TSearchSchemaInput, // TSearchSchemaInput
|
|
720
790
|
TSearchSchema, // TSearchSchema
|
|
791
|
+
TSearchSchemaUsed,
|
|
792
|
+
TSearchSchemaUsed, // TFullSearchSchemaInput
|
|
721
793
|
TSearchSchema, // TFullSearchSchema
|
|
722
794
|
{}, // TParams
|
|
723
795
|
{}, // TAllParams
|
|
@@ -821,7 +893,14 @@ export type ErrorRouteComponent = RouteComponent<ErrorRouteProps>
|
|
|
821
893
|
|
|
822
894
|
export class NotFoundRoute<
|
|
823
895
|
TParentRoute extends AnyRootRoute,
|
|
896
|
+
TSearchSchemaInput extends Record<string, any> = {},
|
|
824
897
|
TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
898
|
+
TSearchSchemaUsed extends RouteConstraints['TSearchSchema'] = {},
|
|
899
|
+
TFullSearchSchemaInput extends
|
|
900
|
+
RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<
|
|
901
|
+
TParentRoute,
|
|
902
|
+
TSearchSchemaUsed
|
|
903
|
+
>,
|
|
825
904
|
TFullSearchSchema extends
|
|
826
905
|
RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
|
|
827
906
|
TParentRoute,
|
|
@@ -844,7 +923,10 @@ export class NotFoundRoute<
|
|
|
844
923
|
'/404',
|
|
845
924
|
'404',
|
|
846
925
|
'404',
|
|
926
|
+
TSearchSchemaInput,
|
|
847
927
|
TSearchSchema,
|
|
928
|
+
TSearchSchemaUsed,
|
|
929
|
+
TFullSearchSchemaInput,
|
|
848
930
|
TFullSearchSchema,
|
|
849
931
|
{},
|
|
850
932
|
{},
|
|
@@ -862,7 +944,10 @@ export class NotFoundRoute<
|
|
|
862
944
|
TParentRoute,
|
|
863
945
|
string,
|
|
864
946
|
string,
|
|
947
|
+
TSearchSchemaInput,
|
|
865
948
|
TSearchSchema,
|
|
949
|
+
TSearchSchemaUsed,
|
|
950
|
+
TFullSearchSchemaInput,
|
|
866
951
|
TFullSearchSchema,
|
|
867
952
|
{},
|
|
868
953
|
{},
|
package/src/routeInfo.ts
CHANGED
package/src/useNavigate.tsx
CHANGED
|
@@ -20,9 +20,9 @@ export function useNavigate<
|
|
|
20
20
|
return React.useCallback(
|
|
21
21
|
<
|
|
22
22
|
TFrom extends RoutePaths<TRouteTree> | string = TDefaultFrom,
|
|
23
|
-
TTo extends string
|
|
23
|
+
TTo extends string = '',
|
|
24
24
|
TMaskFrom extends RoutePaths<TRouteTree>| string = TFrom,
|
|
25
|
-
TMaskTo extends string
|
|
25
|
+
TMaskTo extends string = '',
|
|
26
26
|
>({
|
|
27
27
|
from,
|
|
28
28
|
...rest
|
|
@@ -54,9 +54,9 @@ export function useNavigate<
|
|
|
54
54
|
export function Navigate<
|
|
55
55
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
56
56
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
57
|
-
TTo extends string
|
|
57
|
+
TTo extends string = '',
|
|
58
58
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
59
|
-
TMaskTo extends string
|
|
59
|
+
TMaskTo extends string = '',
|
|
60
60
|
>(props: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): null {
|
|
61
61
|
const { navigate } = useRouter()
|
|
62
62
|
const match = useMatch({ strict: false })
|
|
@@ -74,18 +74,18 @@ export function Navigate<
|
|
|
74
74
|
export type UseLinkPropsOptions<
|
|
75
75
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
76
76
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
77
|
-
TTo extends string
|
|
77
|
+
TTo extends string = '',
|
|
78
78
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
79
|
-
TMaskTo extends string
|
|
79
|
+
TMaskTo extends string = '',
|
|
80
80
|
> = ActiveLinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &
|
|
81
81
|
React.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
82
82
|
|
|
83
83
|
export type LinkProps<
|
|
84
84
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
85
85
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
86
|
-
TTo extends string
|
|
86
|
+
TTo extends string = '',
|
|
87
87
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
88
|
-
TMaskTo extends string
|
|
88
|
+
TMaskTo extends string = '',
|
|
89
89
|
> = ActiveLinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &
|
|
90
90
|
Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
91
91
|
// If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns
|
|
@@ -97,9 +97,9 @@ export type LinkProps<
|
|
|
97
97
|
export type ActiveLinkOptions<
|
|
98
98
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
99
99
|
TFrom extends RoutePaths<TRouteTree> | string = string,
|
|
100
|
-
TTo extends string
|
|
100
|
+
TTo extends string = '',
|
|
101
101
|
TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
|
|
102
|
-
TMaskTo extends string
|
|
102
|
+
TMaskTo extends string = '',
|
|
103
103
|
> = LinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
104
104
|
// A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
|
|
105
105
|
activeProps?:
|