@tanstack/react-router 1.57.16 → 1.57.18
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/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +14 -13
- package/dist/cjs/router.cjs +4 -4
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/route.d.ts +14 -13
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +4 -4
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/route.ts +38 -38
- package/src/router.ts +1 -1
package/package.json
CHANGED
package/src/route.ts
CHANGED
|
@@ -750,37 +750,21 @@ export type RouteConstraints = {
|
|
|
750
750
|
TRouteTree: AnyRoute
|
|
751
751
|
}
|
|
752
752
|
|
|
753
|
+
export type RouteTypesById<
|
|
754
|
+
TRouter extends RegisteredRouter,
|
|
755
|
+
TId extends RouteIds<TRouter['routeTree']>,
|
|
756
|
+
> = RouteById<TRouter['routeTree'], TId>['types']
|
|
757
|
+
|
|
753
758
|
export function getRouteApi<
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,
|
|
757
|
-
TFullSearchSchema = TRoute['types']['fullSearchSchema'],
|
|
758
|
-
TAllParams = TRoute['types']['allParams'],
|
|
759
|
-
TAllContext = TRoute['types']['allContext'],
|
|
760
|
-
TLoaderDeps = TRoute['types']['loaderDeps'],
|
|
761
|
-
TLoaderData = TRoute['types']['loaderData'],
|
|
759
|
+
TRouter extends RegisteredRouter,
|
|
760
|
+
TId extends RouteIds<TRouter['routeTree']>,
|
|
762
761
|
>(id: TId) {
|
|
763
|
-
return new RouteApi<
|
|
764
|
-
TId,
|
|
765
|
-
TRouter,
|
|
766
|
-
TRoute,
|
|
767
|
-
TFullSearchSchema,
|
|
768
|
-
TAllParams,
|
|
769
|
-
TAllContext,
|
|
770
|
-
TLoaderDeps,
|
|
771
|
-
TLoaderData
|
|
772
|
-
>({ id })
|
|
762
|
+
return new RouteApi<TRouter, TId>({ id })
|
|
773
763
|
}
|
|
774
764
|
|
|
775
765
|
export class RouteApi<
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,
|
|
779
|
-
TFullSearchSchema = TRoute['types']['fullSearchSchema'],
|
|
780
|
-
TAllParams = TRoute['types']['allParams'],
|
|
781
|
-
TAllContext = TRoute['types']['allContext'],
|
|
782
|
-
TLoaderDeps = TRoute['types']['loaderDeps'],
|
|
783
|
-
TLoaderData = TRoute['types']['loaderData'],
|
|
766
|
+
TRouter extends RegisteredRouter,
|
|
767
|
+
TId extends RouteIds<TRouter['routeTree']>,
|
|
784
768
|
> {
|
|
785
769
|
id: TId
|
|
786
770
|
|
|
@@ -801,8 +785,12 @@ export class RouteApi<
|
|
|
801
785
|
return useMatch({ select: opts?.select, from: this.id })
|
|
802
786
|
}
|
|
803
787
|
|
|
804
|
-
useRouteContext = <
|
|
805
|
-
|
|
788
|
+
useRouteContext = <
|
|
789
|
+
TSelected = Expand<RouteTypesById<TRouter, TId>['allContext']>,
|
|
790
|
+
>(opts?: {
|
|
791
|
+
select?: (
|
|
792
|
+
s: Expand<RouteTypesById<TRouter, TId>['allContext']>,
|
|
793
|
+
) => TSelected
|
|
806
794
|
}): TSelected => {
|
|
807
795
|
return useMatch({
|
|
808
796
|
from: this.id,
|
|
@@ -810,32 +798,44 @@ export class RouteApi<
|
|
|
810
798
|
})
|
|
811
799
|
}
|
|
812
800
|
|
|
813
|
-
useSearch = <
|
|
814
|
-
|
|
801
|
+
useSearch = <
|
|
802
|
+
TSelected = Expand<RouteTypesById<TRouter, TId>['fullSearchSchema']>,
|
|
803
|
+
>(opts?: {
|
|
804
|
+
select?: (
|
|
805
|
+
s: Expand<RouteTypesById<TRouter, TId>['fullSearchSchema']>,
|
|
806
|
+
) => TSelected
|
|
815
807
|
}): TSelected => {
|
|
816
808
|
return useSearch({ ...opts, from: this.id })
|
|
817
809
|
}
|
|
818
810
|
|
|
819
|
-
useParams = <
|
|
820
|
-
|
|
811
|
+
useParams = <
|
|
812
|
+
TSelected = Expand<RouteTypesById<TRouter, TId>['allParams']>,
|
|
813
|
+
>(opts?: {
|
|
814
|
+
select?: (s: Expand<RouteTypesById<TRouter, TId>['allParams']>) => TSelected
|
|
821
815
|
}): TSelected => {
|
|
822
816
|
return useParams({ ...opts, from: this.id })
|
|
823
817
|
}
|
|
824
818
|
|
|
825
|
-
useLoaderDeps = <
|
|
826
|
-
|
|
819
|
+
useLoaderDeps = <
|
|
820
|
+
TSelected = RouteTypesById<TRouter, TId>['loaderDeps'],
|
|
821
|
+
>(opts?: {
|
|
822
|
+
select?: (s: RouteTypesById<TRouter, TId>['loaderDeps']) => TSelected
|
|
827
823
|
}): TSelected => {
|
|
828
824
|
return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)
|
|
829
825
|
}
|
|
830
826
|
|
|
831
|
-
useLoaderData = <
|
|
832
|
-
|
|
827
|
+
useLoaderData = <
|
|
828
|
+
TSelected = RouteTypesById<TRouter, TId>['loaderData'],
|
|
829
|
+
>(opts?: {
|
|
830
|
+
select?: (s: RouteTypesById<TRouter, TId>['loaderData']) => TSelected
|
|
833
831
|
}): TSelected => {
|
|
834
832
|
return useLoaderData({ ...opts, from: this.id, strict: false } as any)
|
|
835
833
|
}
|
|
836
834
|
|
|
837
|
-
useNavigate = (): UseNavigateResult<
|
|
838
|
-
|
|
835
|
+
useNavigate = (): UseNavigateResult<
|
|
836
|
+
RouteTypesById<TRouter, TId>['fullPath']
|
|
837
|
+
> => {
|
|
838
|
+
return useNavigate({ from: this.id as string })
|
|
839
839
|
}
|
|
840
840
|
|
|
841
841
|
notFound = (opts?: NotFoundError) => {
|
package/src/router.ts
CHANGED
|
@@ -1326,7 +1326,7 @@ export class Router<
|
|
|
1326
1326
|
'Could not find match for from: ' + dest.from,
|
|
1327
1327
|
)
|
|
1328
1328
|
|
|
1329
|
-
const fromSearch = this.state.pendingMatches
|
|
1329
|
+
const fromSearch = this.state.pendingMatches?.length
|
|
1330
1330
|
? last(this.state.pendingMatches)?.search
|
|
1331
1331
|
: last(fromMatches)?.search || this.latestLocation.search
|
|
1332
1332
|
|