@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/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.191",
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.191"
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 AnySearchSchema = AnySearchSchema,
57
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
58
58
  TAllParams extends AnyPathParams = AnyPathParams,
59
- TRouteContext extends AnyContext = AnyContext,
60
- TAllContext extends AnyContext = AnyContext,
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 AnySearchSchema = AnySearchSchema,
74
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
75
75
  TAllParams extends AnyPathParams = AnyPathParams,
76
- TRouteContext extends AnyContext = AnyContext,
77
- TAllContext extends AnyContext = AnyContext,
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 AnySearchSchema = AnySearchSchema,
85
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
86
86
  TAllParams extends AnyPathParams = AnyPathParams,
87
- TRouteContext extends AnyContext = AnyContext,
88
- TAllContext extends AnyContext = AnyContext,
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 AnySearchSchema = AnySearchSchema,
160
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
160
161
  TAllParams extends AnyPathParams = AnyPathParams,
161
- TRouteContext extends AnyContext = AnyContext,
162
- TAllContext extends AnyContext = AnyContext,
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 AnySearchSchema = AnySearchSchema,
175
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
175
176
  TAllParams extends AnyPathParams = AnyPathParams,
176
- TRouteContext extends AnyContext = AnyContext,
177
- TAllContext extends AnyContext = AnyContext,
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 AnySearchSchema = AnySearchSchema,
189
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
189
190
  TAllParams extends AnyPathParams = AnyPathParams,
190
- TRouteContext extends AnyContext = AnyContext,
191
- TAllContext extends AnyContext = AnyContext,
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 AnySearchSchema = AnySearchSchema,
200
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
200
201
  TAllParams extends AnyPathParams = AnyPathParams,
201
- TRouteContext extends AnyContext = AnyContext,
202
- TAllContext extends AnyContext = AnyContext,
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 AnySearchSchema = AnySearchSchema,
226
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
226
227
  TAllParams extends AnyPathParams = AnyPathParams,
227
- TRouteContext extends AnyContext = AnyContext,
228
- TAllContext extends AnyContext = AnyContext,
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 AnySearchSchema = AnySearchSchema,
245
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
245
246
  TAllParams extends AnyPathParams = AnyPathParams,
246
- TRouteContext extends AnyContext = AnyContext,
247
- TAllContext extends AnyContext = AnyContext,
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<RegisteredRouter['routeTree'], TFrom, TTo, TMaskFrom, TMaskTo> &
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
- RegisteredRouter['routeTree'],
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
- TFrom extends RouteIds<RegisteredRouter['routeTree']>,
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<T> = T extends ParseRoute<
796
- RegisteredRouter['routeTree']
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<RegisteredRouter['routeTree']>
800
- ? RoutesById<RegisteredRouter['routeTree']>[T]
785
+ : T extends RouteIds<TRouteTree>
786
+ ? RoutesById<TRouteTree>[T]
801
787
  : T extends string
802
- ? RouteIds<RegisteredRouter['routeTree']>
788
+ ? RouteIds<TRouteTree>
803
789
  : never
804
790
 
805
791
  export function useLoader<
806
- TFrom extends RouteIds<RegisteredRouter['routeTree']>,
792
+ TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
793
+ TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
807
794
  TStrict extends boolean = true,
808
- TLoader = RouteById<RegisteredRouter['routeTree'], TFrom>['types']['loader'],
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
- TFrom extends RouteIds<RegisteredRouter['routeTree']>,
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
- TFrom extends RouteIds<RegisteredRouter['routeTree']>,
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.routeContext as TRouteContext)
862
- : match.routeContext,
844
+ ? opts.select(match.context as TRouteContext)
845
+ : match.context,
863
846
  })
864
847
  }
865
848
 
866
849
  export function useSearch<
867
- TFrom extends RouteIds<RegisteredRouter['routeTree']>,
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
- TFrom extends RouteIds<RegisteredRouter['routeTree']> = '/',
889
- TDefaultSelected = AllParams<RegisteredRouter['routeTree']> &
890
- RouteById<RegisteredRouter['routeTree'], TFrom>['types']['allParams'],
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> & {