@tanstack/react-router 1.47.5 → 1.48.1
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/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +3 -3
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +64 -67
- package/dist/cjs/router.cjs +1 -0
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +11 -4
- package/dist/esm/fileRoute.d.ts +3 -3
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/route.d.ts +64 -67
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +11 -4
- package/dist/esm/router.js +1 -0
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/fileRoute.ts +10 -25
- package/src/index.tsx +1 -3
- package/src/route.ts +202 -202
- package/src/router.ts +11 -5
package/src/route.ts
CHANGED
|
@@ -54,9 +54,7 @@ export type RouteOptions<
|
|
|
54
54
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
55
55
|
TCustomId extends string = string,
|
|
56
56
|
TPath extends string = string,
|
|
57
|
-
|
|
58
|
-
TSearchSchema = {},
|
|
59
|
-
TFullSearchSchema = TSearchSchema,
|
|
57
|
+
TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
|
|
60
58
|
TParams = AnyPathParams,
|
|
61
59
|
TAllParams = TParams,
|
|
62
60
|
TRouteContextReturn = RouteContext,
|
|
@@ -70,9 +68,7 @@ export type RouteOptions<
|
|
|
70
68
|
TParentRoute,
|
|
71
69
|
TCustomId,
|
|
72
70
|
TPath,
|
|
73
|
-
|
|
74
|
-
TSearchSchema,
|
|
75
|
-
TFullSearchSchema,
|
|
71
|
+
TSearchValidator,
|
|
76
72
|
TParams,
|
|
77
73
|
TAllParams,
|
|
78
74
|
TRouteContextReturn,
|
|
@@ -82,9 +78,10 @@ export type RouteOptions<
|
|
|
82
78
|
TLoaderDataReturn
|
|
83
79
|
> &
|
|
84
80
|
UpdatableRouteOptions<
|
|
81
|
+
NoInfer<TParentRoute>,
|
|
85
82
|
NoInfer<TCustomId>,
|
|
86
83
|
NoInfer<TAllParams>,
|
|
87
|
-
NoInfer<
|
|
84
|
+
NoInfer<TSearchValidator>,
|
|
88
85
|
NoInfer<TLoaderData>,
|
|
89
86
|
NoInfer<TAllContext>,
|
|
90
87
|
NoInfer<TRouteContext>,
|
|
@@ -123,10 +120,9 @@ export interface FullSearchSchemaOption<TFullSearchSchema> {
|
|
|
123
120
|
}
|
|
124
121
|
|
|
125
122
|
export type FileBaseRouteOptions<
|
|
123
|
+
TParentRoute extends AnyRoute = AnyRoute,
|
|
126
124
|
TPath extends string = string,
|
|
127
|
-
|
|
128
|
-
TSearchSchema = {},
|
|
129
|
-
TFullSearchSchema = TSearchSchema,
|
|
125
|
+
TSearchValidator extends AnySearchValidator = undefined,
|
|
130
126
|
TParams = {},
|
|
131
127
|
TAllParams = {},
|
|
132
128
|
TRouteContextReturn = RouteContext,
|
|
@@ -135,22 +131,32 @@ export type FileBaseRouteOptions<
|
|
|
135
131
|
TLoaderDeps extends Record<string, any> = {},
|
|
136
132
|
TLoaderDataReturn = {},
|
|
137
133
|
> = {
|
|
138
|
-
validateSearch?:
|
|
139
|
-
| ((input: TSearchSchemaInput) => TSearchSchema)
|
|
140
|
-
| { parse: (input: TSearchSchemaInput) => TSearchSchema }
|
|
134
|
+
validateSearch?: TSearchValidator
|
|
141
135
|
shouldReload?:
|
|
142
136
|
| boolean
|
|
143
137
|
| ((
|
|
144
|
-
match: LoaderFnContext<
|
|
138
|
+
match: LoaderFnContext<
|
|
139
|
+
TAllParams,
|
|
140
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
141
|
+
TAllContext
|
|
142
|
+
>,
|
|
145
143
|
) => any)
|
|
146
144
|
// This async function is called before a route is loaded.
|
|
147
145
|
// If an error is thrown here, the route's loader will not be called.
|
|
148
146
|
// If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.
|
|
149
147
|
// If thrown during a preload event, the error will be logged to the console.
|
|
150
148
|
beforeLoad?: (
|
|
151
|
-
ctx: BeforeLoadContext<
|
|
149
|
+
ctx: BeforeLoadContext<
|
|
150
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
151
|
+
TAllParams,
|
|
152
|
+
TParentAllContext
|
|
153
|
+
>,
|
|
152
154
|
) => Promise<TRouteContextReturn> | TRouteContextReturn | void
|
|
153
|
-
loaderDeps?: (
|
|
155
|
+
loaderDeps?: (
|
|
156
|
+
opts: FullSearchSchemaOption<
|
|
157
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>
|
|
158
|
+
>,
|
|
159
|
+
) => TLoaderDeps
|
|
154
160
|
loader?: (
|
|
155
161
|
ctx: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,
|
|
156
162
|
) => TLoaderDataReturn | Promise<TLoaderDataReturn>
|
|
@@ -160,9 +166,7 @@ export type BaseRouteOptions<
|
|
|
160
166
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
161
167
|
TCustomId extends string = string,
|
|
162
168
|
TPath extends string = string,
|
|
163
|
-
|
|
164
|
-
TSearchSchema = {},
|
|
165
|
-
TFullSearchSchema = TSearchSchema,
|
|
169
|
+
TSearchValidator extends AnySearchValidator = undefined,
|
|
166
170
|
TParams = {},
|
|
167
171
|
TAllParams = {},
|
|
168
172
|
TRouteContextReturn = RouteContext,
|
|
@@ -172,10 +176,9 @@ export type BaseRouteOptions<
|
|
|
172
176
|
TLoaderDataReturn = {},
|
|
173
177
|
> = RoutePathOptions<TCustomId, TPath> &
|
|
174
178
|
FileBaseRouteOptions<
|
|
179
|
+
TParentRoute,
|
|
175
180
|
TPath,
|
|
176
|
-
|
|
177
|
-
TSearchSchema,
|
|
178
|
-
TFullSearchSchema,
|
|
181
|
+
TSearchValidator,
|
|
179
182
|
TParams,
|
|
180
183
|
TAllParams,
|
|
181
184
|
TRouteContextReturn,
|
|
@@ -206,22 +209,14 @@ export interface BeforeLoadContext<
|
|
|
206
209
|
}
|
|
207
210
|
|
|
208
211
|
export type UpdatableRouteOptions<
|
|
212
|
+
TParentRoute extends AnyRoute,
|
|
209
213
|
TRouteId,
|
|
210
214
|
TAllParams,
|
|
211
|
-
|
|
215
|
+
TSearchValidator extends AnySearchValidator,
|
|
212
216
|
TLoaderData,
|
|
213
217
|
TAllContext,
|
|
214
218
|
TRouteContext,
|
|
215
219
|
TLoaderDeps,
|
|
216
|
-
TRouteMatch = RouteMatch<
|
|
217
|
-
TRouteId,
|
|
218
|
-
TAllParams,
|
|
219
|
-
TFullSearchSchema,
|
|
220
|
-
TLoaderData,
|
|
221
|
-
TAllContext,
|
|
222
|
-
TRouteContext,
|
|
223
|
-
TLoaderDeps
|
|
224
|
-
>,
|
|
225
220
|
> = {
|
|
226
221
|
// test?: (args: TAllContext) => void
|
|
227
222
|
// If true, this route will be matched as case-sensitive
|
|
@@ -241,20 +236,72 @@ export type UpdatableRouteOptions<
|
|
|
241
236
|
preloadGcTime?: number
|
|
242
237
|
// Filter functions that can manipulate search params *before* they are passed to links and navigate
|
|
243
238
|
// calls that match this route.
|
|
244
|
-
preSearchFilters?: Array<
|
|
239
|
+
preSearchFilters?: Array<
|
|
240
|
+
SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
241
|
+
>
|
|
245
242
|
// Filter functions that can manipulate search params *after* they are passed to links and navigate
|
|
246
243
|
// calls that match this route.
|
|
247
|
-
postSearchFilters?: Array<
|
|
244
|
+
postSearchFilters?: Array<
|
|
245
|
+
SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
246
|
+
>
|
|
248
247
|
onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void
|
|
249
248
|
onError?: (err: any) => void
|
|
250
249
|
// These functions are called as route matches are loaded, stick around and leave the active
|
|
251
250
|
// matches
|
|
252
|
-
onEnter?: (
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
onEnter?: (
|
|
252
|
+
match: RouteMatch<
|
|
253
|
+
TRouteId,
|
|
254
|
+
TAllParams,
|
|
255
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
256
|
+
TLoaderData,
|
|
257
|
+
TAllContext,
|
|
258
|
+
TRouteContext,
|
|
259
|
+
TLoaderDeps
|
|
260
|
+
>,
|
|
261
|
+
) => void
|
|
262
|
+
onStay?: (
|
|
263
|
+
match: RouteMatch<
|
|
264
|
+
TRouteId,
|
|
265
|
+
TAllParams,
|
|
266
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
267
|
+
TLoaderData,
|
|
268
|
+
TAllContext,
|
|
269
|
+
TRouteContext,
|
|
270
|
+
TLoaderDeps
|
|
271
|
+
>,
|
|
272
|
+
) => void
|
|
273
|
+
onLeave?: (
|
|
274
|
+
match: RouteMatch<
|
|
275
|
+
TRouteId,
|
|
276
|
+
TAllParams,
|
|
277
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
278
|
+
TLoaderData,
|
|
279
|
+
TAllContext,
|
|
280
|
+
TRouteContext,
|
|
281
|
+
TLoaderDeps
|
|
282
|
+
>,
|
|
283
|
+
) => void
|
|
255
284
|
meta?: (ctx: {
|
|
256
|
-
matches: Array<
|
|
257
|
-
|
|
285
|
+
matches: Array<
|
|
286
|
+
RouteMatch<
|
|
287
|
+
TRouteId,
|
|
288
|
+
TAllParams,
|
|
289
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
290
|
+
TLoaderData,
|
|
291
|
+
TAllContext,
|
|
292
|
+
TRouteContext,
|
|
293
|
+
TLoaderDeps
|
|
294
|
+
>
|
|
295
|
+
>
|
|
296
|
+
match: RouteMatch<
|
|
297
|
+
TRouteId,
|
|
298
|
+
TAllParams,
|
|
299
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
300
|
+
TLoaderData,
|
|
301
|
+
TAllContext,
|
|
302
|
+
TRouteContext,
|
|
303
|
+
TLoaderDeps
|
|
304
|
+
>
|
|
258
305
|
params: TAllParams
|
|
259
306
|
loaderData: TLoaderData
|
|
260
307
|
}) => Array<React.JSX.IntrinsicElements['meta']>
|
|
@@ -291,18 +338,38 @@ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray
|
|
|
291
338
|
|
|
292
339
|
export type RouteLinkEntry = {}
|
|
293
340
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
341
|
+
export interface SearchValidatorObj<TInput, TOutput> {
|
|
342
|
+
parse: SearchValidatorFn<TInput, TOutput>
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export type AnySearchValidatorObj = SearchValidatorObj<any, any>
|
|
298
346
|
|
|
299
|
-
export
|
|
300
|
-
|
|
347
|
+
export interface SearchValidatorAdapter<TInput, TOutput> {
|
|
348
|
+
types: {
|
|
349
|
+
input: TInput
|
|
350
|
+
output: TOutput
|
|
351
|
+
}
|
|
352
|
+
parse: (input: unknown) => TOutput
|
|
301
353
|
}
|
|
302
354
|
|
|
303
|
-
export type
|
|
304
|
-
|
|
305
|
-
|
|
355
|
+
export type AnySearchValidatorAdapter = SearchValidatorAdapter<any, any>
|
|
356
|
+
|
|
357
|
+
export type AnySearchValidatorFn = SearchValidatorFn<any, any>
|
|
358
|
+
|
|
359
|
+
export type SearchValidatorFn<TInput, TOutput> = (input: TInput) => TOutput
|
|
360
|
+
|
|
361
|
+
export type SearchValidator<TInput, TOutput> =
|
|
362
|
+
| SearchValidatorObj<TInput, TOutput>
|
|
363
|
+
| SearchValidatorFn<TInput, TOutput>
|
|
364
|
+
| SearchValidatorAdapter<TInput, TOutput>
|
|
365
|
+
| undefined
|
|
366
|
+
|
|
367
|
+
export type AnySearchValidator = SearchValidator<any, any>
|
|
368
|
+
|
|
369
|
+
export type DefaultSearchValidator = SearchValidator<
|
|
370
|
+
Record<string, unknown>,
|
|
371
|
+
AnySearchSchema
|
|
372
|
+
>
|
|
306
373
|
|
|
307
374
|
export type RouteLoaderFn<
|
|
308
375
|
in out TAllParams = {},
|
|
@@ -375,20 +442,53 @@ export type InferAllContext<TRoute> = TRoute extends {
|
|
|
375
442
|
? TAllContext
|
|
376
443
|
: {}
|
|
377
444
|
|
|
378
|
-
export type
|
|
379
|
-
|
|
445
|
+
export type ResolveSearchSchemaFnInput<
|
|
446
|
+
TSearchValidator extends AnySearchValidator,
|
|
447
|
+
> = TSearchValidator extends (input: infer TSearchSchemaInput) => any
|
|
448
|
+
? TSearchSchemaInput extends SearchSchemaInput
|
|
380
449
|
? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
|
|
381
|
-
:
|
|
450
|
+
: ResolveSearchSchemaFn<TSearchValidator>
|
|
451
|
+
: AnySearchSchema
|
|
452
|
+
|
|
453
|
+
export type ResolveSearchSchemaInput<
|
|
454
|
+
TSearchValidator extends AnySearchValidator,
|
|
455
|
+
> = TSearchValidator extends AnySearchValidatorAdapter
|
|
456
|
+
? TSearchValidator['types']['input']
|
|
457
|
+
: TSearchValidator extends AnySearchValidatorObj
|
|
458
|
+
? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
|
|
459
|
+
: ResolveSearchSchemaFnInput<TSearchValidator>
|
|
460
|
+
|
|
461
|
+
export type ResolveSearchSchemaFn<TSearchValidator extends AnySearchValidator> =
|
|
462
|
+
TSearchValidator extends (...args: any) => infer TSearchSchema
|
|
463
|
+
? TSearchSchema
|
|
464
|
+
: AnySearchSchema
|
|
465
|
+
|
|
466
|
+
export type ResolveSearchSchema<TSearchValidator extends AnySearchValidator> =
|
|
467
|
+
unknown extends TSearchValidator
|
|
468
|
+
? TSearchValidator
|
|
469
|
+
: TSearchValidator extends AnySearchValidatorAdapter
|
|
470
|
+
? TSearchValidator['types']['output']
|
|
471
|
+
: TSearchValidator extends AnySearchValidatorObj
|
|
472
|
+
? ResolveSearchSchemaFn<TSearchValidator['parse']>
|
|
473
|
+
: ResolveSearchSchemaFn<TSearchValidator>
|
|
382
474
|
|
|
383
475
|
export type ResolveFullSearchSchema<
|
|
384
476
|
TParentRoute extends AnyRoute,
|
|
385
|
-
|
|
386
|
-
> =
|
|
477
|
+
TSearchValidator extends AnySearchValidator,
|
|
478
|
+
> = unknown extends TParentRoute
|
|
479
|
+
? ResolveSearchSchema<TSearchValidator>
|
|
480
|
+
: Assign<
|
|
481
|
+
InferFullSearchSchema<TParentRoute>,
|
|
482
|
+
ResolveSearchSchema<TSearchValidator>
|
|
483
|
+
>
|
|
387
484
|
|
|
388
485
|
export type ResolveFullSearchSchemaInput<
|
|
389
486
|
TParentRoute extends AnyRoute,
|
|
390
|
-
|
|
391
|
-
> = Assign<
|
|
487
|
+
TSearchValidator extends AnySearchValidator,
|
|
488
|
+
> = Assign<
|
|
489
|
+
InferFullSearchSchemaInput<TParentRoute>,
|
|
490
|
+
ResolveSearchSchemaInput<TSearchValidator>
|
|
491
|
+
>
|
|
392
492
|
|
|
393
493
|
export type ResolveRouteContext<TRouteContextReturn> = [
|
|
394
494
|
TRouteContextReturn,
|
|
@@ -423,10 +523,6 @@ export interface AnyRoute
|
|
|
423
523
|
any,
|
|
424
524
|
any,
|
|
425
525
|
any,
|
|
426
|
-
any,
|
|
427
|
-
any,
|
|
428
|
-
any,
|
|
429
|
-
any,
|
|
430
526
|
any
|
|
431
527
|
> {}
|
|
432
528
|
|
|
@@ -443,12 +539,8 @@ export type AnyRouteWithContext<TContext> = Route<
|
|
|
443
539
|
any,
|
|
444
540
|
any,
|
|
445
541
|
any,
|
|
446
|
-
any,
|
|
447
|
-
any,
|
|
448
542
|
TContext,
|
|
449
543
|
any,
|
|
450
|
-
any,
|
|
451
|
-
any,
|
|
452
544
|
any
|
|
453
545
|
>
|
|
454
546
|
|
|
@@ -581,20 +673,7 @@ export class Route<
|
|
|
581
673
|
TCustomId,
|
|
582
674
|
TPath
|
|
583
675
|
>,
|
|
584
|
-
in out
|
|
585
|
-
in out TSearchSchema = {},
|
|
586
|
-
in out TSearchSchemaUsed = ResolveSearchSchemaUsed<
|
|
587
|
-
TSearchSchemaInput,
|
|
588
|
-
TSearchSchema
|
|
589
|
-
>,
|
|
590
|
-
in out TFullSearchSchemaInput = ResolveFullSearchSchemaInput<
|
|
591
|
-
TParentRoute,
|
|
592
|
-
TSearchSchemaUsed
|
|
593
|
-
>,
|
|
594
|
-
in out TFullSearchSchema = ResolveFullSearchSchema<
|
|
595
|
-
TParentRoute,
|
|
596
|
-
TSearchSchema
|
|
597
|
-
>,
|
|
676
|
+
in out TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
|
|
598
677
|
in out TParams = Record<ParsePathParams<TPath>, string>,
|
|
599
678
|
in out TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
600
679
|
TRouteContextReturn = RouteContext,
|
|
@@ -610,9 +689,7 @@ export class Route<
|
|
|
610
689
|
TParentRoute,
|
|
611
690
|
TCustomId,
|
|
612
691
|
TPath,
|
|
613
|
-
|
|
614
|
-
TSearchSchema,
|
|
615
|
-
TFullSearchSchema,
|
|
692
|
+
TSearchValidator,
|
|
616
693
|
TParams,
|
|
617
694
|
TAllParams,
|
|
618
695
|
TRouteContextReturn,
|
|
@@ -648,9 +725,7 @@ export class Route<
|
|
|
648
725
|
TParentRoute,
|
|
649
726
|
TCustomId,
|
|
650
727
|
TPath,
|
|
651
|
-
|
|
652
|
-
TSearchSchema,
|
|
653
|
-
TFullSearchSchema,
|
|
728
|
+
TSearchValidator,
|
|
654
729
|
TParams,
|
|
655
730
|
TAllParams,
|
|
656
731
|
TRouteContextReturn,
|
|
@@ -679,11 +754,14 @@ export class Route<
|
|
|
679
754
|
fullPath: TFullPath
|
|
680
755
|
customId: TCustomId
|
|
681
756
|
id: TId
|
|
682
|
-
searchSchema:
|
|
683
|
-
searchSchemaInput:
|
|
684
|
-
|
|
685
|
-
fullSearchSchema:
|
|
686
|
-
fullSearchSchemaInput:
|
|
757
|
+
searchSchema: ResolveSearchSchema<TSearchValidator>
|
|
758
|
+
searchSchemaInput: ResolveSearchSchemaInput<TSearchValidator>
|
|
759
|
+
searchValidator: TSearchValidator
|
|
760
|
+
fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>
|
|
761
|
+
fullSearchSchemaInput: ResolveFullSearchSchemaInput<
|
|
762
|
+
TParentRoute,
|
|
763
|
+
TSearchValidator
|
|
764
|
+
>
|
|
687
765
|
params: TParams
|
|
688
766
|
allParams: TAllParams
|
|
689
767
|
routeContext: TRouteContext
|
|
@@ -701,9 +779,7 @@ export class Route<
|
|
|
701
779
|
TParentRoute,
|
|
702
780
|
TCustomId,
|
|
703
781
|
TPath,
|
|
704
|
-
|
|
705
|
-
TSearchSchema,
|
|
706
|
-
TFullSearchSchema,
|
|
782
|
+
TSearchValidator,
|
|
707
783
|
TParams,
|
|
708
784
|
TAllParams,
|
|
709
785
|
TRouteContextReturn,
|
|
@@ -778,11 +854,7 @@ export class Route<
|
|
|
778
854
|
TFullPath,
|
|
779
855
|
TCustomId,
|
|
780
856
|
TId,
|
|
781
|
-
|
|
782
|
-
TSearchSchema,
|
|
783
|
-
TSearchSchemaUsed,
|
|
784
|
-
TFullSearchSchemaInput,
|
|
785
|
-
TFullSearchSchema,
|
|
857
|
+
TSearchValidator,
|
|
786
858
|
TParams,
|
|
787
859
|
TAllParams,
|
|
788
860
|
TRouteContextReturn,
|
|
@@ -809,11 +881,7 @@ export class Route<
|
|
|
809
881
|
TFullPath,
|
|
810
882
|
TCustomId,
|
|
811
883
|
TId,
|
|
812
|
-
|
|
813
|
-
TSearchSchema,
|
|
814
|
-
TSearchSchemaUsed,
|
|
815
|
-
TFullSearchSchemaInput,
|
|
816
|
-
TFullSearchSchema,
|
|
884
|
+
TSearchValidator,
|
|
817
885
|
TParams,
|
|
818
886
|
TAllParams,
|
|
819
887
|
TRouteContextReturn,
|
|
@@ -827,9 +895,10 @@ export class Route<
|
|
|
827
895
|
|
|
828
896
|
update = (
|
|
829
897
|
options: UpdatableRouteOptions<
|
|
898
|
+
TParentRoute,
|
|
830
899
|
TCustomId,
|
|
831
900
|
TAllParams,
|
|
832
|
-
|
|
901
|
+
TSearchValidator,
|
|
833
902
|
TLoaderData,
|
|
834
903
|
TAllContext,
|
|
835
904
|
TRouteContext,
|
|
@@ -866,8 +935,12 @@ export class Route<
|
|
|
866
935
|
})
|
|
867
936
|
}
|
|
868
937
|
|
|
869
|
-
useSearch = <
|
|
870
|
-
|
|
938
|
+
useSearch = <
|
|
939
|
+
TSelected = Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>,
|
|
940
|
+
>(opts?: {
|
|
941
|
+
select?: (
|
|
942
|
+
search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>,
|
|
943
|
+
) => TSelected
|
|
871
944
|
}): TSelected => {
|
|
872
945
|
return useSearch({ ...opts, from: this.id })
|
|
873
946
|
}
|
|
@@ -908,17 +981,7 @@ export function createRoute<
|
|
|
908
981
|
TCustomId,
|
|
909
982
|
TPath
|
|
910
983
|
>,
|
|
911
|
-
|
|
912
|
-
TSearchSchema = {},
|
|
913
|
-
TSearchSchemaUsed = ResolveSearchSchemaUsed<
|
|
914
|
-
TSearchSchemaInput,
|
|
915
|
-
TSearchSchema
|
|
916
|
-
>,
|
|
917
|
-
TFullSearchSchemaInput = ResolveFullSearchSchemaInput<
|
|
918
|
-
TParentRoute,
|
|
919
|
-
TSearchSchemaUsed
|
|
920
|
-
>,
|
|
921
|
-
TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,
|
|
984
|
+
TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
|
|
922
985
|
TParams = Record<ParsePathParams<TPath>, string>,
|
|
923
986
|
TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
924
987
|
TRouteContextReturn = RouteContext,
|
|
@@ -933,9 +996,7 @@ export function createRoute<
|
|
|
933
996
|
TParentRoute,
|
|
934
997
|
TCustomId,
|
|
935
998
|
TPath,
|
|
936
|
-
|
|
937
|
-
TSearchSchema,
|
|
938
|
-
TFullSearchSchema,
|
|
999
|
+
TSearchValidator,
|
|
939
1000
|
TParams,
|
|
940
1001
|
TAllParams,
|
|
941
1002
|
TRouteContextReturn,
|
|
@@ -953,11 +1014,7 @@ export function createRoute<
|
|
|
953
1014
|
TFullPath,
|
|
954
1015
|
TCustomId,
|
|
955
1016
|
TId,
|
|
956
|
-
|
|
957
|
-
TSearchSchema,
|
|
958
|
-
TSearchSchemaUsed,
|
|
959
|
-
TFullSearchSchemaInput,
|
|
960
|
-
TFullSearchSchema,
|
|
1017
|
+
TSearchValidator,
|
|
961
1018
|
TParams,
|
|
962
1019
|
TAllParams,
|
|
963
1020
|
TRouteContextReturn,
|
|
@@ -973,8 +1030,7 @@ export function createRoute<
|
|
|
973
1030
|
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>
|
|
974
1031
|
|
|
975
1032
|
export type RootRouteOptions<
|
|
976
|
-
|
|
977
|
-
TSearchSchema = {},
|
|
1033
|
+
TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
|
|
978
1034
|
TRouteContextReturn = RouteContext,
|
|
979
1035
|
TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
980
1036
|
TRouterContext = {},
|
|
@@ -986,9 +1042,7 @@ export type RootRouteOptions<
|
|
|
986
1042
|
any, // TParentRoute
|
|
987
1043
|
RootRouteId, // TCustomId
|
|
988
1044
|
'', // TPath
|
|
989
|
-
|
|
990
|
-
TSearchSchema, // TSearchSchema
|
|
991
|
-
TSearchSchema, // TFullSearchSchema
|
|
1045
|
+
TSearchValidator,
|
|
992
1046
|
{}, // TParams
|
|
993
1047
|
{}, // TAllParams
|
|
994
1048
|
TRouteContextReturn, // TRouteContextReturn
|
|
@@ -1010,12 +1064,7 @@ export type RootRouteOptions<
|
|
|
1010
1064
|
|
|
1011
1065
|
export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
1012
1066
|
return <
|
|
1013
|
-
|
|
1014
|
-
TSearchSchema = {},
|
|
1015
|
-
TSearchSchemaUsed = ResolveSearchSchemaUsed<
|
|
1016
|
-
TSearchSchemaInput,
|
|
1017
|
-
TSearchSchema
|
|
1018
|
-
>,
|
|
1067
|
+
TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
|
|
1019
1068
|
TRouteContextReturn extends RouteContext = RouteContext,
|
|
1020
1069
|
TRouteContext extends
|
|
1021
1070
|
RouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
@@ -1024,8 +1073,7 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1024
1073
|
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1025
1074
|
>(
|
|
1026
1075
|
options?: RootRouteOptions<
|
|
1027
|
-
|
|
1028
|
-
TSearchSchema,
|
|
1076
|
+
TSearchValidator,
|
|
1029
1077
|
TRouteContextReturn,
|
|
1030
1078
|
TRouteContext,
|
|
1031
1079
|
TRouterContext,
|
|
@@ -1035,9 +1083,7 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1035
1083
|
>,
|
|
1036
1084
|
) => {
|
|
1037
1085
|
return createRootRoute<
|
|
1038
|
-
|
|
1039
|
-
TSearchSchema,
|
|
1040
|
-
TSearchSchemaUsed,
|
|
1086
|
+
TSearchValidator,
|
|
1041
1087
|
TRouteContextReturn,
|
|
1042
1088
|
TRouteContext,
|
|
1043
1089
|
TRouterContext,
|
|
@@ -1053,9 +1099,7 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1053
1099
|
export const rootRouteWithContext = createRootRouteWithContext
|
|
1054
1100
|
|
|
1055
1101
|
export class RootRoute<
|
|
1056
|
-
in out
|
|
1057
|
-
in out TSearchSchema = {},
|
|
1058
|
-
in out TSearchSchemaUsed = {},
|
|
1102
|
+
in out TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
|
|
1059
1103
|
TRouteContextReturn = RouteContext,
|
|
1060
1104
|
in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
1061
1105
|
in out TRouterContext = {},
|
|
@@ -1069,11 +1113,7 @@ export class RootRoute<
|
|
|
1069
1113
|
'/', // TFullPath
|
|
1070
1114
|
string, // TCustomId
|
|
1071
1115
|
RootRouteId, // TId
|
|
1072
|
-
|
|
1073
|
-
TSearchSchema, // TSearchSchema
|
|
1074
|
-
TSearchSchemaUsed,
|
|
1075
|
-
TSearchSchemaUsed, // TFullSearchSchemaInput
|
|
1076
|
-
TSearchSchema, // TFullSearchSchema
|
|
1116
|
+
TSearchValidator, // TSearchValidator
|
|
1077
1117
|
{}, // TParams
|
|
1078
1118
|
{}, // TAllParams
|
|
1079
1119
|
TRouteContextReturn, // TRouteContextReturn
|
|
@@ -1089,8 +1129,7 @@ export class RootRoute<
|
|
|
1089
1129
|
*/
|
|
1090
1130
|
constructor(
|
|
1091
1131
|
options?: RootRouteOptions<
|
|
1092
|
-
|
|
1093
|
-
TSearchSchema,
|
|
1132
|
+
TSearchValidator,
|
|
1094
1133
|
TRouteContextReturn,
|
|
1095
1134
|
TRouteContext,
|
|
1096
1135
|
TRouterContext,
|
|
@@ -1109,9 +1148,7 @@ export class RootRoute<
|
|
|
1109
1148
|
>(
|
|
1110
1149
|
children: TNewChildren,
|
|
1111
1150
|
): RootRoute<
|
|
1112
|
-
|
|
1113
|
-
TSearchSchema,
|
|
1114
|
-
TSearchSchemaUsed,
|
|
1151
|
+
TSearchValidator,
|
|
1115
1152
|
TRouteContextReturn,
|
|
1116
1153
|
TRouteContext,
|
|
1117
1154
|
TRouterContext,
|
|
@@ -1125,12 +1162,7 @@ export class RootRoute<
|
|
|
1125
1162
|
}
|
|
1126
1163
|
|
|
1127
1164
|
export function createRootRoute<
|
|
1128
|
-
|
|
1129
|
-
TSearchSchema = {},
|
|
1130
|
-
TSearchSchemaUsed = ResolveSearchSchemaUsed<
|
|
1131
|
-
TSearchSchemaInput,
|
|
1132
|
-
TSearchSchema
|
|
1133
|
-
>,
|
|
1165
|
+
TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
|
|
1134
1166
|
TRouteContextReturn = RouteContext,
|
|
1135
1167
|
TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
1136
1168
|
TRouterContext = {},
|
|
@@ -1138,37 +1170,18 @@ export function createRootRoute<
|
|
|
1138
1170
|
TLoaderDataReturn = {},
|
|
1139
1171
|
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1140
1172
|
>(
|
|
1141
|
-
options?:
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
{}, // TParams
|
|
1150
|
-
{}, // TAllParams
|
|
1151
|
-
TRouteContextReturn, // TRouteContextReturn
|
|
1152
|
-
TRouteContext, // TRouteContext
|
|
1153
|
-
TRouterContext,
|
|
1154
|
-
Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
1155
|
-
TLoaderDeps,
|
|
1156
|
-
TLoaderDataReturn,
|
|
1157
|
-
TLoaderData
|
|
1158
|
-
>,
|
|
1159
|
-
| 'path'
|
|
1160
|
-
| 'id'
|
|
1161
|
-
| 'getParentRoute'
|
|
1162
|
-
| 'caseSensitive'
|
|
1163
|
-
| 'parseParams'
|
|
1164
|
-
| 'stringifyParams'
|
|
1165
|
-
| 'params'
|
|
1173
|
+
options?: RootRouteOptions<
|
|
1174
|
+
TSearchValidator,
|
|
1175
|
+
TRouteContextReturn,
|
|
1176
|
+
TRouteContext,
|
|
1177
|
+
TRouterContext,
|
|
1178
|
+
TLoaderDeps,
|
|
1179
|
+
TLoaderDataReturn,
|
|
1180
|
+
TLoaderData
|
|
1166
1181
|
>,
|
|
1167
1182
|
) {
|
|
1168
1183
|
return new RootRoute<
|
|
1169
|
-
|
|
1170
|
-
TSearchSchema,
|
|
1171
|
-
TSearchSchemaUsed,
|
|
1184
|
+
TSearchValidator,
|
|
1172
1185
|
TRouteContextReturn,
|
|
1173
1186
|
TRouteContext,
|
|
1174
1187
|
TRouterContext,
|
|
@@ -1276,14 +1289,7 @@ export type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>
|
|
|
1276
1289
|
|
|
1277
1290
|
export class NotFoundRoute<
|
|
1278
1291
|
TParentRoute extends AnyRootRoute,
|
|
1279
|
-
|
|
1280
|
-
TSearchSchema = {},
|
|
1281
|
-
TSearchSchemaUsed = {},
|
|
1282
|
-
TFullSearchSchemaInput = ResolveFullSearchSchemaInput<
|
|
1283
|
-
TParentRoute,
|
|
1284
|
-
TSearchSchemaUsed
|
|
1285
|
-
>,
|
|
1286
|
-
TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,
|
|
1292
|
+
TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
|
|
1287
1293
|
TRouteContextReturn = AnyContext,
|
|
1288
1294
|
TRouteContext = RouteContext,
|
|
1289
1295
|
TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,
|
|
@@ -1297,11 +1303,7 @@ export class NotFoundRoute<
|
|
|
1297
1303
|
'/404',
|
|
1298
1304
|
'404',
|
|
1299
1305
|
'404',
|
|
1300
|
-
|
|
1301
|
-
TSearchSchema,
|
|
1302
|
-
TSearchSchemaUsed,
|
|
1303
|
-
TFullSearchSchemaInput,
|
|
1304
|
-
TFullSearchSchema,
|
|
1306
|
+
TSearchValidator,
|
|
1305
1307
|
{},
|
|
1306
1308
|
{},
|
|
1307
1309
|
TRouteContextReturn,
|
|
@@ -1318,9 +1320,7 @@ export class NotFoundRoute<
|
|
|
1318
1320
|
TParentRoute,
|
|
1319
1321
|
string,
|
|
1320
1322
|
string,
|
|
1321
|
-
|
|
1322
|
-
TSearchSchema,
|
|
1323
|
-
TFullSearchSchema,
|
|
1323
|
+
TSearchValidator,
|
|
1324
1324
|
{},
|
|
1325
1325
|
{},
|
|
1326
1326
|
TRouteContextReturn,
|