@tanstack/react-router 0.0.1-beta.191 → 0.0.1-beta.193
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/react.js +1 -1
- package/build/cjs/react.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +98 -98
- package/build/types/react.d.ts +21 -21
- package/build/umd/index.development.js +30 -19
- 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/react.tsx +60 -78
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.193",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"tiny-warning": "^1.0.3",
|
|
45
45
|
"@tanstack/react-store": "^0.0.1",
|
|
46
46
|
"@gisatcz/cross-package-react-context": "^0.2.0",
|
|
47
|
-
"@tanstack/router-core": "0.0.1-beta.
|
|
47
|
+
"@tanstack/router-core": "0.0.1-beta.193"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup --config rollup.config.js"
|
package/src/react.tsx
CHANGED
|
@@ -54,10 +54,10 @@ declare module '@tanstack/router-core' {
|
|
|
54
54
|
|
|
55
55
|
interface RegisterRouteComponent<
|
|
56
56
|
TLoader = unknown,
|
|
57
|
-
TFullSearchSchema extends
|
|
57
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
58
58
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
59
|
-
TRouteContext extends
|
|
60
|
-
TAllContext extends
|
|
59
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
60
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
61
61
|
> {
|
|
62
62
|
RouteComponent: RouteComponent<
|
|
63
63
|
RouteProps<
|
|
@@ -71,10 +71,10 @@ declare module '@tanstack/router-core' {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
interface RegisterErrorRouteComponent<
|
|
74
|
-
TFullSearchSchema extends
|
|
74
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
75
75
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
76
|
-
TRouteContext extends
|
|
77
|
-
TAllContext extends
|
|
76
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
77
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
78
78
|
> {
|
|
79
79
|
ErrorRouteComponent: RouteComponent<
|
|
80
80
|
ErrorRouteProps<TFullSearchSchema, TAllParams, TRouteContext, TAllContext>
|
|
@@ -82,10 +82,10 @@ declare module '@tanstack/router-core' {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
interface RegisterPendingRouteComponent<
|
|
85
|
-
TFullSearchSchema extends
|
|
85
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
86
86
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
87
|
-
TRouteContext extends
|
|
88
|
-
TAllContext extends
|
|
87
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
88
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
89
89
|
> {
|
|
90
90
|
PendingRouteComponent: RouteComponent<
|
|
91
91
|
PendingRouteProps<
|
|
@@ -110,6 +110,7 @@ declare module '@tanstack/router-core' {
|
|
|
110
110
|
TCustomId,
|
|
111
111
|
TPath
|
|
112
112
|
>,
|
|
113
|
+
TLoaderContext extends RouteConstraints['TLoaderContext'] = AnyContext,
|
|
113
114
|
TLoader = unknown,
|
|
114
115
|
TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
115
116
|
TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
|
|
@@ -156,10 +157,10 @@ declare module '@tanstack/router-core' {
|
|
|
156
157
|
|
|
157
158
|
interface RegisterRouteProps<
|
|
158
159
|
TLoader = unknown,
|
|
159
|
-
TFullSearchSchema extends
|
|
160
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
160
161
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
161
|
-
TRouteContext extends
|
|
162
|
-
TAllContext extends
|
|
162
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
163
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
163
164
|
> {
|
|
164
165
|
RouteProps: RouteProps<
|
|
165
166
|
TLoader,
|
|
@@ -171,10 +172,10 @@ declare module '@tanstack/router-core' {
|
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
interface RegisterPendingRouteProps<
|
|
174
|
-
TFullSearchSchema extends
|
|
175
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
175
176
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
176
|
-
TRouteContext extends
|
|
177
|
-
TAllContext extends
|
|
177
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
178
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
178
179
|
> {
|
|
179
180
|
PendingRouteProps: PendingRouteProps<
|
|
180
181
|
TFullSearchSchema,
|
|
@@ -185,10 +186,10 @@ declare module '@tanstack/router-core' {
|
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
interface RegisterErrorRouteProps<
|
|
188
|
-
TFullSearchSchema extends
|
|
189
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
189
190
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
190
|
-
TRouteContext extends
|
|
191
|
-
TAllContext extends
|
|
191
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
192
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
192
193
|
> {
|
|
193
194
|
ErrorRouteProps: ErrorRouteProps
|
|
194
195
|
}
|
|
@@ -196,10 +197,10 @@ declare module '@tanstack/router-core' {
|
|
|
196
197
|
|
|
197
198
|
export type RouteProps<
|
|
198
199
|
TLoader = unknown,
|
|
199
|
-
TFullSearchSchema extends
|
|
200
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
200
201
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
201
|
-
TRouteContext extends
|
|
202
|
-
TAllContext extends
|
|
202
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
203
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
203
204
|
> = {
|
|
204
205
|
useLoader: <TSelected = TLoader>(opts?: {
|
|
205
206
|
select?: (search: TLoader) => TSelected
|
|
@@ -222,10 +223,10 @@ export type RouteProps<
|
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
export type ErrorRouteProps<
|
|
225
|
-
TFullSearchSchema extends
|
|
226
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
226
227
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
227
|
-
TRouteContext extends
|
|
228
|
-
TAllContext extends
|
|
228
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
229
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
229
230
|
> = {
|
|
230
231
|
error: unknown
|
|
231
232
|
info: { componentStack: string }
|
|
@@ -241,10 +242,10 @@ export type ErrorRouteProps<
|
|
|
241
242
|
>
|
|
242
243
|
|
|
243
244
|
export type PendingRouteProps<
|
|
244
|
-
TFullSearchSchema extends
|
|
245
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
245
246
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
246
|
-
TRouteContext extends
|
|
247
|
-
TAllContext extends
|
|
247
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
248
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
248
249
|
> = Omit<
|
|
249
250
|
RouteProps<
|
|
250
251
|
unknown,
|
|
@@ -349,13 +350,7 @@ export type LinkPropsOptions<
|
|
|
349
350
|
TTo extends string = '',
|
|
350
351
|
TMaskFrom extends RoutePaths<TRouteTree> = '/',
|
|
351
352
|
TMaskTo extends string = '',
|
|
352
|
-
> = LinkOptions<
|
|
353
|
-
RegisteredRouter['routeTree'],
|
|
354
|
-
TFrom,
|
|
355
|
-
TTo,
|
|
356
|
-
TMaskFrom,
|
|
357
|
-
TMaskTo
|
|
358
|
-
> & {
|
|
353
|
+
> = LinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
359
354
|
// 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)
|
|
360
355
|
activeProps?:
|
|
361
356
|
| React.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
@@ -383,13 +378,13 @@ export type MakeMatchRouteOptions<
|
|
|
383
378
|
TTo extends string = '',
|
|
384
379
|
TMaskFrom extends RoutePaths<TRouteTree> = '/',
|
|
385
380
|
TMaskTo extends string = '',
|
|
386
|
-
> = ToOptions<
|
|
381
|
+
> = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &
|
|
387
382
|
MatchRouteOptions & {
|
|
388
383
|
// 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
|
|
389
384
|
children?:
|
|
390
385
|
| ((
|
|
391
386
|
params?: RouteByPath<
|
|
392
|
-
|
|
387
|
+
TRouteTree,
|
|
393
388
|
ResolveRelativePath<TFrom, NoInfer<TTo>>
|
|
394
389
|
>['types']['allParams'],
|
|
395
390
|
) => ReactNode)
|
|
@@ -589,15 +584,7 @@ export function Navigate<
|
|
|
589
584
|
TTo extends string = '',
|
|
590
585
|
TMaskFrom extends RoutePaths<TRouteTree> = '/',
|
|
591
586
|
TMaskTo extends string = '',
|
|
592
|
-
>(
|
|
593
|
-
props: NavigateOptions<
|
|
594
|
-
RegisteredRouter['routeTree'],
|
|
595
|
-
TFrom,
|
|
596
|
-
TTo,
|
|
597
|
-
TMaskFrom,
|
|
598
|
-
TMaskTo
|
|
599
|
-
>,
|
|
600
|
-
): null {
|
|
587
|
+
>(props: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): null {
|
|
601
588
|
const router = useRouter()
|
|
602
589
|
|
|
603
590
|
React.useLayoutEffect(() => {
|
|
@@ -731,12 +718,10 @@ type StrictOrFrom<TFrom> =
|
|
|
731
718
|
}
|
|
732
719
|
|
|
733
720
|
export function useMatch<
|
|
734
|
-
|
|
721
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
722
|
+
TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
|
|
735
723
|
TStrict extends boolean = true,
|
|
736
|
-
TRouteMatchState = RouteMatch<
|
|
737
|
-
RegisteredRouter['routeTree'],
|
|
738
|
-
RouteById<RegisteredRouter['routeTree'], TFrom>
|
|
739
|
-
>,
|
|
724
|
+
TRouteMatchState = RouteMatch<TRouteTree, TFrom>,
|
|
740
725
|
TSelected = TRouteMatchState,
|
|
741
726
|
>(
|
|
742
727
|
opts: StrictOrFrom<TFrom> & {
|
|
@@ -792,20 +777,22 @@ export function useMatch<
|
|
|
792
777
|
return matchSelection as any
|
|
793
778
|
}
|
|
794
779
|
|
|
795
|
-
export type RouteFromIdOrRoute<
|
|
796
|
-
|
|
797
|
-
|
|
780
|
+
export type RouteFromIdOrRoute<
|
|
781
|
+
T,
|
|
782
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
783
|
+
> = T extends ParseRoute<TRouteTree>
|
|
798
784
|
? T
|
|
799
|
-
: T extends RouteIds<
|
|
800
|
-
? RoutesById<
|
|
785
|
+
: T extends RouteIds<TRouteTree>
|
|
786
|
+
? RoutesById<TRouteTree>[T]
|
|
801
787
|
: T extends string
|
|
802
|
-
? RouteIds<
|
|
788
|
+
? RouteIds<TRouteTree>
|
|
803
789
|
: never
|
|
804
790
|
|
|
805
791
|
export function useLoader<
|
|
806
|
-
|
|
792
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
793
|
+
TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
|
|
807
794
|
TStrict extends boolean = true,
|
|
808
|
-
TLoader = RouteById<
|
|
795
|
+
TLoader = RouteById<TRouteTree, TFrom>['types']['loader'],
|
|
809
796
|
TSelected = TLoader,
|
|
810
797
|
>(
|
|
811
798
|
opts: StrictOrFrom<TFrom> & {
|
|
@@ -822,12 +809,10 @@ export function useLoader<
|
|
|
822
809
|
}
|
|
823
810
|
|
|
824
811
|
export function useRouterContext<
|
|
825
|
-
|
|
812
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
813
|
+
TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
|
|
826
814
|
TStrict extends boolean = true,
|
|
827
|
-
TContext = RouteById<
|
|
828
|
-
RegisteredRouter['routeTree'],
|
|
829
|
-
TFrom
|
|
830
|
-
>['types']['context'],
|
|
815
|
+
TContext = RouteById<TRouteTree, TFrom>['types']['context'],
|
|
831
816
|
TSelected = TContext,
|
|
832
817
|
>(
|
|
833
818
|
opts: StrictOrFrom<TFrom> & {
|
|
@@ -842,12 +827,10 @@ export function useRouterContext<
|
|
|
842
827
|
}
|
|
843
828
|
|
|
844
829
|
export function useRouteContext<
|
|
845
|
-
|
|
830
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
831
|
+
TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
|
|
846
832
|
TStrict extends boolean = true,
|
|
847
|
-
TRouteContext = RouteById<
|
|
848
|
-
RegisteredRouter['routeTree'],
|
|
849
|
-
TFrom
|
|
850
|
-
>['types']['routeContext'],
|
|
833
|
+
TRouteContext = RouteById<TRouteTree, TFrom>['types']['context'],
|
|
851
834
|
TSelected = TRouteContext,
|
|
852
835
|
>(
|
|
853
836
|
opts: StrictOrFrom<TFrom> & {
|
|
@@ -858,18 +841,16 @@ export function useRouteContext<
|
|
|
858
841
|
...(opts as any),
|
|
859
842
|
select: (match: RouteMatch) =>
|
|
860
843
|
opts?.select
|
|
861
|
-
? opts.select(match.
|
|
862
|
-
: match.
|
|
844
|
+
? opts.select(match.context as TRouteContext)
|
|
845
|
+
: match.context,
|
|
863
846
|
})
|
|
864
847
|
}
|
|
865
848
|
|
|
866
849
|
export function useSearch<
|
|
867
|
-
|
|
850
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
851
|
+
TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
|
|
868
852
|
TStrict extends boolean = true,
|
|
869
|
-
TSearch = RouteById<
|
|
870
|
-
RegisteredRouter['routeTree'],
|
|
871
|
-
TFrom
|
|
872
|
-
>['types']['fullSearchSchema'],
|
|
853
|
+
TSearch = RouteById<TRouteTree, TFrom>['types']['fullSearchSchema'],
|
|
873
854
|
TSelected = TSearch,
|
|
874
855
|
>(
|
|
875
856
|
opts: StrictOrFrom<TFrom> & {
|
|
@@ -885,9 +866,10 @@ export function useSearch<
|
|
|
885
866
|
}
|
|
886
867
|
|
|
887
868
|
export function useParams<
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
869
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
870
|
+
TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
|
|
871
|
+
TDefaultSelected = AllParams<TRouteTree> &
|
|
872
|
+
RouteById<TRouteTree, TFrom>['types']['allParams'],
|
|
891
873
|
TSelected = TDefaultSelected,
|
|
892
874
|
>(
|
|
893
875
|
opts: StrictOrFrom<TFrom> & {
|