@tanstack/react-router 0.0.1-beta.171 → 0.0.1-beta.173
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.map +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +94 -94
- package/build/types/index.d.ts +24 -34
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +3 -3
- package/src/react.tsx +52 -58
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.173",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"tiny-invariant": "^1.3.1",
|
|
44
44
|
"tiny-warning": "^1.0.3",
|
|
45
45
|
"@gisatcz/cross-package-react-context": "^0.2.0",
|
|
46
|
-
"@tanstack/router-core": "0.0.1-beta.
|
|
47
|
-
"@tanstack/react-store": "0.0.1-beta.
|
|
46
|
+
"@tanstack/router-core": "0.0.1-beta.173",
|
|
47
|
+
"@tanstack/react-store": "0.0.1-beta.173"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup --config rollup.config.js"
|
package/src/react.tsx
CHANGED
|
@@ -123,41 +123,24 @@ declare module '@tanstack/router-core' {
|
|
|
123
123
|
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
124
124
|
TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,
|
|
125
125
|
> {
|
|
126
|
-
useMatch: <
|
|
127
|
-
strict?: TStrict
|
|
126
|
+
useMatch: <TSelected = TAllContext>(opts?: {
|
|
128
127
|
select?: (search: TAllContext) => TSelected
|
|
129
|
-
}) =>
|
|
130
|
-
useLoader: <
|
|
131
|
-
strict?: TStrict
|
|
128
|
+
}) => TSelected
|
|
129
|
+
useLoader: <TSelected = TLoader>(opts?: {
|
|
132
130
|
select?: (search: TLoader) => TSelected
|
|
133
|
-
}) =>
|
|
134
|
-
|
|
135
|
-
: UseLoaderResult<TSelected> | undefined
|
|
136
|
-
useContext: <
|
|
137
|
-
TStrict extends boolean = true,
|
|
138
|
-
TSelected = TAllContext,
|
|
139
|
-
>(opts?: {
|
|
140
|
-
strict?: TStrict
|
|
131
|
+
}) => UseLoaderResult<TSelected>
|
|
132
|
+
useContext: <TSelected = TAllContext>(opts?: {
|
|
141
133
|
select?: (search: TAllContext) => TSelected
|
|
142
|
-
}) =>
|
|
143
|
-
useRouteContext: <
|
|
144
|
-
TStrict extends boolean = true,
|
|
145
|
-
TSelected = TRouteContext,
|
|
146
|
-
>(opts?: {
|
|
147
|
-
strict?: TStrict
|
|
134
|
+
}) => TSelected
|
|
135
|
+
useRouteContext: <TSelected = TRouteContext>(opts?: {
|
|
148
136
|
select?: (search: TRouteContext) => TSelected
|
|
149
|
-
}) =>
|
|
150
|
-
useSearch: <
|
|
151
|
-
TStrict extends boolean = true,
|
|
152
|
-
TSelected = TFullSearchSchema,
|
|
153
|
-
>(opts?: {
|
|
154
|
-
strict?: TStrict
|
|
137
|
+
}) => TSelected
|
|
138
|
+
useSearch: <TSelected = TFullSearchSchema>(opts?: {
|
|
155
139
|
select?: (search: TFullSearchSchema) => TSelected
|
|
156
|
-
}) =>
|
|
157
|
-
useParams: <
|
|
158
|
-
strict?: TStrict
|
|
140
|
+
}) => TSelected
|
|
141
|
+
useParams: <TSelected = TAllParams>(opts?: {
|
|
159
142
|
select?: (search: TAllParams) => TSelected
|
|
160
|
-
}) =>
|
|
143
|
+
}) => TSelected
|
|
161
144
|
}
|
|
162
145
|
|
|
163
146
|
interface RegisterRouteProps<
|
|
@@ -682,6 +665,16 @@ export function useMatches<T = RouteMatch[]>(opts?: {
|
|
|
682
665
|
})
|
|
683
666
|
}
|
|
684
667
|
|
|
668
|
+
type StrictOrFrom<TFrom> =
|
|
669
|
+
| {
|
|
670
|
+
from: TFrom
|
|
671
|
+
strict?: true
|
|
672
|
+
}
|
|
673
|
+
| {
|
|
674
|
+
from?: never
|
|
675
|
+
strict: false
|
|
676
|
+
}
|
|
677
|
+
|
|
685
678
|
export function useMatch<
|
|
686
679
|
TFrom extends RouteIds<RegisteredRouter['routeTree']>,
|
|
687
680
|
TStrict extends boolean = true,
|
|
@@ -690,11 +683,11 @@ export function useMatch<
|
|
|
690
683
|
RouteById<RegisteredRouter['routeTree'], TFrom>
|
|
691
684
|
>,
|
|
692
685
|
TSelected = TRouteMatchState,
|
|
693
|
-
>(
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
686
|
+
>(
|
|
687
|
+
opts: StrictOrFrom<TFrom> & {
|
|
688
|
+
select?: (match: TRouteMatchState) => TSelected
|
|
689
|
+
},
|
|
690
|
+
): TStrict extends true ? TRouteMatchState : TRouteMatchState | undefined {
|
|
698
691
|
const router = useRouter()
|
|
699
692
|
const nearestMatchId = React.useContext(matchIdsContext)[0]!
|
|
700
693
|
const nearestMatchRouteId = router.getRouteMatch(nearestMatchId)?.routeId
|
|
@@ -761,11 +754,11 @@ export function useLoader<
|
|
|
761
754
|
TStrict extends boolean = true,
|
|
762
755
|
TLoader = RouteById<RegisteredRouter['routeTree'], TFrom>['types']['loader'],
|
|
763
756
|
TSelected = TLoader,
|
|
764
|
-
>(
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
757
|
+
>(
|
|
758
|
+
opts: StrictOrFrom<TFrom> & {
|
|
759
|
+
select?: (search: TLoader) => TSelected
|
|
760
|
+
},
|
|
761
|
+
): TStrict extends true ? TSelected : TSelected | undefined {
|
|
769
762
|
return useMatch({
|
|
770
763
|
...(opts as any),
|
|
771
764
|
select: (match: RouteMatch) =>
|
|
@@ -782,11 +775,11 @@ export function useRouterContext<
|
|
|
782
775
|
TFrom
|
|
783
776
|
>['types']['context'],
|
|
784
777
|
TSelected = TContext,
|
|
785
|
-
>(
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
778
|
+
>(
|
|
779
|
+
opts: StrictOrFrom<TFrom> & {
|
|
780
|
+
select?: (search: TContext) => TSelected
|
|
781
|
+
},
|
|
782
|
+
): TStrict extends true ? TSelected : TSelected | undefined {
|
|
790
783
|
return useMatch({
|
|
791
784
|
...(opts as any),
|
|
792
785
|
select: (match: RouteMatch) =>
|
|
@@ -802,11 +795,11 @@ export function useRouteContext<
|
|
|
802
795
|
TFrom
|
|
803
796
|
>['types']['routeContext'],
|
|
804
797
|
TSelected = TRouteContext,
|
|
805
|
-
>(
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
798
|
+
>(
|
|
799
|
+
opts: StrictOrFrom<TFrom> & {
|
|
800
|
+
select?: (search: TRouteContext) => TSelected
|
|
801
|
+
},
|
|
802
|
+
): TStrict extends true ? TSelected : TSelected | undefined {
|
|
810
803
|
return useMatch({
|
|
811
804
|
...(opts as any),
|
|
812
805
|
select: (match: RouteMatch) =>
|
|
@@ -823,11 +816,11 @@ export function useSearch<
|
|
|
823
816
|
TFrom
|
|
824
817
|
>['types']['fullSearchSchema'],
|
|
825
818
|
TSelected = TSearch,
|
|
826
|
-
>(
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
819
|
+
>(
|
|
820
|
+
opts: StrictOrFrom<TFrom> & {
|
|
821
|
+
select?: (search: TSearch) => TSelected
|
|
822
|
+
},
|
|
823
|
+
): TStrict extends true ? TSelected : TSelected | undefined {
|
|
831
824
|
return useMatch({
|
|
832
825
|
...(opts as any),
|
|
833
826
|
select: (match: RouteMatch) => {
|
|
@@ -842,10 +835,11 @@ export function useParams<
|
|
|
842
835
|
TDefaultSelected = AllParams<RegisteredRouter['routeTree']> &
|
|
843
836
|
RouteById<RegisteredRouter['routeTree'], TFrom>['types']['allParams'],
|
|
844
837
|
TSelected = TDefaultSelected,
|
|
845
|
-
>(
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
}
|
|
838
|
+
>(
|
|
839
|
+
opts: StrictOrFrom<TFrom> & {
|
|
840
|
+
select?: (search: TDefaultSelected) => TSelected
|
|
841
|
+
},
|
|
842
|
+
): TSelected {
|
|
849
843
|
return useRouterState({
|
|
850
844
|
select: (state: any) => {
|
|
851
845
|
const params = (last(state.matches) as any)?.params
|