@tanstack/react-router 1.1.9 → 1.1.10
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/fileRoute.js.map +1 -1
- package/build/cjs/link.js.map +1 -1
- package/build/cjs/route.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/fileRoute.d.ts +3 -2
- package/build/types/link.d.ts +4 -4
- package/build/types/route.d.ts +7 -4
- 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/fileRoute.ts +12 -2
- package/src/link.tsx +9 -8
- package/src/route.ts +20 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.10",
|
|
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.1.
|
|
47
|
+
"@tanstack/history": "1.1.10"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup --config rollup.config.js"
|
package/src/fileRoute.ts
CHANGED
|
@@ -56,12 +56,20 @@ export type RemoveUnderScores<T extends string> = Replace<
|
|
|
56
56
|
'/'
|
|
57
57
|
>
|
|
58
58
|
|
|
59
|
+
type ReplaceFirstOccurrence<
|
|
60
|
+
T extends string,
|
|
61
|
+
Search extends string,
|
|
62
|
+
Replacement extends string,
|
|
63
|
+
> = T extends `${infer Prefix}${Search}${infer Suffix}`
|
|
64
|
+
? `${Prefix}${Replacement}${Suffix}`
|
|
65
|
+
: T
|
|
66
|
+
|
|
59
67
|
export type ResolveFilePath<
|
|
60
68
|
TParentRoute extends AnyRoute,
|
|
61
69
|
TFilePath extends string,
|
|
62
70
|
> = TParentRoute['id'] extends RootRouteId
|
|
63
71
|
? TrimPathLeft<TFilePath>
|
|
64
|
-
:
|
|
72
|
+
: ReplaceFirstOccurrence<
|
|
65
73
|
TrimPathLeft<TFilePath>,
|
|
66
74
|
TrimPathLeft<TParentRoute['types']['customId']>,
|
|
67
75
|
''
|
|
@@ -72,7 +80,9 @@ export type FileRoutePath<
|
|
|
72
80
|
TFilePath extends string,
|
|
73
81
|
> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`
|
|
74
82
|
? string
|
|
75
|
-
: ResolveFilePath<TParentRoute, TFilePath>
|
|
83
|
+
: ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}`
|
|
84
|
+
? string
|
|
85
|
+
: ResolveFilePath<TParentRoute, TFilePath>
|
|
76
86
|
|
|
77
87
|
export class FileRoute<
|
|
78
88
|
TFilePath extends keyof FileRoutesByPath,
|
package/src/link.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react'
|
|
|
2
2
|
import { useMatch } from './Matches'
|
|
3
3
|
import { useRouter, useRouterState } from './RouterProvider'
|
|
4
4
|
import { Trim } from './fileRoute'
|
|
5
|
-
import { AnyRoute, ReactNode } from './route'
|
|
5
|
+
import { AnyRoute, ReactNode, RootSearchSchema } from './route'
|
|
6
6
|
import {
|
|
7
7
|
AllParams,
|
|
8
8
|
FullSearchSchema,
|
|
@@ -171,7 +171,7 @@ type ParamVariant = 'PATH' | 'SEARCH'
|
|
|
171
171
|
export type ParamOptions<
|
|
172
172
|
TRouteTree extends AnyRoute,
|
|
173
173
|
TFrom,
|
|
174
|
-
TTo,
|
|
174
|
+
TTo extends string,
|
|
175
175
|
TResolved,
|
|
176
176
|
TParamVariant extends ParamVariant,
|
|
177
177
|
TFromRouteType extends
|
|
@@ -184,12 +184,13 @@ export type ParamOptions<
|
|
|
184
184
|
| 'fullSearchSchemaInput' = TParamVariant extends 'PATH'
|
|
185
185
|
? 'allParams'
|
|
186
186
|
: 'fullSearchSchemaInput',
|
|
187
|
-
TFromParams = Expand<RouteByPath<TRouteTree, TFrom>['types'][TFromRouteType]
|
|
188
|
-
|
|
187
|
+
TFromParams = Expand<Exclude<RouteByPath<TRouteTree, TFrom>['types'][TFromRouteType], RootSearchSchema>>,
|
|
188
|
+
TToIndex = RouteByPath<TRouteTree, `${TTo}/`> extends never ? TTo : `${TTo}/`,
|
|
189
|
+
TToParams = TToIndex extends ''
|
|
189
190
|
? TFromParams
|
|
190
191
|
: never extends TResolved
|
|
191
|
-
? Expand<RouteByPath<TRouteTree,
|
|
192
|
-
: Expand<RouteByPath<TRouteTree, TResolved>['types'][TToRouteType]
|
|
192
|
+
? Expand<Exclude<RouteByPath<TRouteTree, TToIndex>['types'][TToRouteType], RootSearchSchema>>
|
|
193
|
+
: Expand<Exclude<RouteByPath<TRouteTree, TResolved>['types'][TToRouteType], RootSearchSchema>>,
|
|
193
194
|
TReducer = ParamsReducer<TFromParams, TToParams>,
|
|
194
195
|
> = Expand<WithoutEmpty<PickRequired<TToParams>>> extends never
|
|
195
196
|
? Partial<MakeParamOption<TParamVariant, true | TReducer>>
|
|
@@ -209,14 +210,14 @@ type MakePathParamOptions<T> = { params: T }
|
|
|
209
210
|
export type SearchParamOptions<
|
|
210
211
|
TRouteTree extends AnyRoute,
|
|
211
212
|
TFrom,
|
|
212
|
-
TTo,
|
|
213
|
+
TTo extends string,
|
|
213
214
|
TResolved,
|
|
214
215
|
> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, 'SEARCH'>
|
|
215
216
|
|
|
216
217
|
export type PathParamOptions<
|
|
217
218
|
TRouteTree extends AnyRoute,
|
|
218
219
|
TFrom,
|
|
219
|
-
TTo,
|
|
220
|
+
TTo extends string,
|
|
220
221
|
TResolved,
|
|
221
222
|
> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, 'PATH'>
|
|
222
223
|
|
package/src/route.ts
CHANGED
|
@@ -309,11 +309,19 @@ export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
|
309
309
|
: {}
|
|
310
310
|
|
|
311
311
|
export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<
|
|
312
|
-
Assign<
|
|
312
|
+
Assign<
|
|
313
|
+
Omit<InferFullSearchSchema<TParentRoute>, keyof RootSearchSchema>,
|
|
314
|
+
TSearchSchema
|
|
315
|
+
>
|
|
313
316
|
>
|
|
314
317
|
|
|
315
318
|
export type ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed> =
|
|
316
|
-
Expand<
|
|
319
|
+
Expand<
|
|
320
|
+
Assign<
|
|
321
|
+
Omit<InferFullSearchSchemaInput<TParentRoute>, keyof RootSearchSchema>,
|
|
322
|
+
TSearchSchemaUsed
|
|
323
|
+
>
|
|
324
|
+
>
|
|
317
325
|
|
|
318
326
|
export interface AnyRoute
|
|
319
327
|
extends Route<
|
|
@@ -742,9 +750,9 @@ export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>
|
|
|
742
750
|
|
|
743
751
|
export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
744
752
|
return <
|
|
745
|
-
TSearchSchemaInput extends Record<string, any> =
|
|
746
|
-
TSearchSchema extends Record<string, any> =
|
|
747
|
-
TSearchSchemaUsed extends Record<string, any> =
|
|
753
|
+
TSearchSchemaInput extends Record<string, any> = RootSearchSchema,
|
|
754
|
+
TSearchSchema extends Record<string, any> = RootSearchSchema,
|
|
755
|
+
TSearchSchemaUsed extends Record<string, any> = RootSearchSchema,
|
|
748
756
|
TRouteContext extends RouteContext = RouteContext,
|
|
749
757
|
TLoaderDeps extends Record<string, any> = {},
|
|
750
758
|
TLoaderData extends any = unknown,
|
|
@@ -784,10 +792,14 @@ export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
|
784
792
|
}
|
|
785
793
|
}
|
|
786
794
|
|
|
795
|
+
export type RootSearchSchema = {
|
|
796
|
+
__TRootSearchSchema__: '__TRootSearchSchema__'
|
|
797
|
+
}
|
|
798
|
+
|
|
787
799
|
export class RootRoute<
|
|
788
|
-
TSearchSchemaInput extends Record<string, any> =
|
|
789
|
-
TSearchSchema extends Record<string, any> =
|
|
790
|
-
TSearchSchemaUsed extends Record<string, any> =
|
|
800
|
+
TSearchSchemaInput extends Record<string, any> = RootSearchSchema,
|
|
801
|
+
TSearchSchema extends Record<string, any> = RootSearchSchema,
|
|
802
|
+
TSearchSchemaUsed extends Record<string, any> = RootSearchSchema,
|
|
791
803
|
TRouteContext extends RouteContext = RouteContext,
|
|
792
804
|
TRouterContext extends {} = {},
|
|
793
805
|
TLoaderDeps extends Record<string, any> = {},
|