@tanstack/react-router 1.83.1 → 1.84.2
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/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +1 -1
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +2 -2
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +2 -2
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +6 -6
- package/dist/cjs/router.cjs +16 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +6 -2
- package/dist/esm/Matches.d.ts +1 -1
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +2 -2
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/link.d.ts +2 -2
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/route.d.ts +6 -6
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +6 -2
- package/dist/esm/router.js +16 -1
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/Matches.tsx +7 -7
- package/src/RouterProvider.tsx +2 -1
- package/src/link.tsx +7 -2
- package/src/route.ts +29 -17
- package/src/router.ts +35 -4
package/package.json
CHANGED
package/src/Matches.tsx
CHANGED
|
@@ -136,13 +136,13 @@ export type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<
|
|
|
136
136
|
>
|
|
137
137
|
|
|
138
138
|
export interface RouteMatch<
|
|
139
|
-
TRouteId,
|
|
140
|
-
TFullPath,
|
|
141
|
-
TAllParams,
|
|
142
|
-
TFullSearchSchema,
|
|
143
|
-
TLoaderData,
|
|
144
|
-
TAllContext,
|
|
145
|
-
TLoaderDeps,
|
|
139
|
+
out TRouteId,
|
|
140
|
+
out TFullPath,
|
|
141
|
+
out TAllParams,
|
|
142
|
+
out TFullSearchSchema,
|
|
143
|
+
out TLoaderData,
|
|
144
|
+
out TAllContext,
|
|
145
|
+
out TLoaderDeps,
|
|
146
146
|
> {
|
|
147
147
|
id: string
|
|
148
148
|
routeId: TRouteId
|
package/src/RouterProvider.tsx
CHANGED
|
@@ -9,12 +9,13 @@ import type {
|
|
|
9
9
|
RegisteredRouter,
|
|
10
10
|
Router,
|
|
11
11
|
RouterOptions,
|
|
12
|
+
ViewTransitionOptions,
|
|
12
13
|
} from './router'
|
|
13
14
|
|
|
14
15
|
export interface CommitLocationOptions {
|
|
15
16
|
replace?: boolean
|
|
16
17
|
resetScroll?: boolean
|
|
17
|
-
viewTransition?: boolean
|
|
18
|
+
viewTransition?: boolean | ViewTransitionOptions
|
|
18
19
|
/**
|
|
19
20
|
* @deprecated All navigations use React transitions under the hood now
|
|
20
21
|
**/
|
package/src/link.tsx
CHANGED
|
@@ -28,7 +28,11 @@ import type {
|
|
|
28
28
|
RouteToPath,
|
|
29
29
|
TrailingSlashOptionByRouter,
|
|
30
30
|
} from './routeInfo'
|
|
31
|
-
import type {
|
|
31
|
+
import type {
|
|
32
|
+
AnyRouter,
|
|
33
|
+
RegisteredRouter,
|
|
34
|
+
ViewTransitionOptions,
|
|
35
|
+
} from './router'
|
|
32
36
|
import type {
|
|
33
37
|
Constrain,
|
|
34
38
|
Expand,
|
|
@@ -212,7 +216,8 @@ export interface NavigateOptionProps {
|
|
|
212
216
|
/** @deprecated All navigations now use startTransition under the hood */
|
|
213
217
|
startTransition?: boolean
|
|
214
218
|
// if set to `true`, the router will wrap the resulting navigation in a document.startViewTransition() call.
|
|
215
|
-
viewTransition
|
|
219
|
+
// if set to `ViewTransitionOptions`, the router will pass the `types` field to document.startViewTransition({update: fn, types: viewTransition.types}) call
|
|
220
|
+
viewTransition?: boolean | ViewTransitionOptions
|
|
216
221
|
ignoreBlocker?: boolean
|
|
217
222
|
}
|
|
218
223
|
|
package/src/route.ts
CHANGED
|
@@ -127,17 +127,17 @@ export type ResolveParams<TPath extends string> =
|
|
|
127
127
|
? Record<ParsePathParams<TPath>, string>
|
|
128
128
|
: Record<ParsePathParams<TPath>, string> & SplatParams
|
|
129
129
|
|
|
130
|
-
export type ParseParamsFn<TPath extends string, TParams> = (
|
|
130
|
+
export type ParseParamsFn<in out TPath extends string, in out TParams> = (
|
|
131
131
|
rawParams: ResolveParams<TPath>,
|
|
132
132
|
) => TParams extends Record<ParsePathParams<TPath>, any>
|
|
133
133
|
? TParams
|
|
134
134
|
: Record<ParsePathParams<TPath>, any>
|
|
135
135
|
|
|
136
|
-
export type StringifyParamsFn<TPath extends string, TParams> = (
|
|
136
|
+
export type StringifyParamsFn<in out TPath extends string, in out TParams> = (
|
|
137
137
|
params: TParams,
|
|
138
138
|
) => ResolveParams<TPath>
|
|
139
139
|
|
|
140
|
-
export type ParamsOptions<TPath extends string, TParams> = {
|
|
140
|
+
export type ParamsOptions<in out TPath extends string, in out TParams> = {
|
|
141
141
|
params?: {
|
|
142
142
|
parse?: ParseParamsFn<TPath, TParams>
|
|
143
143
|
stringify?: StringifyParamsFn<TPath, TParams>
|
|
@@ -1083,12 +1083,11 @@ export class Route<
|
|
|
1083
1083
|
this._ssr = options?.ssr ?? opts.defaultSsr ?? true
|
|
1084
1084
|
}
|
|
1085
1085
|
|
|
1086
|
-
addChildren<
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
|
1090
|
-
|
|
1091
|
-
children: TNewChildren,
|
|
1086
|
+
addChildren<const TNewChildren>(
|
|
1087
|
+
children: Constrain<
|
|
1088
|
+
TNewChildren,
|
|
1089
|
+
ReadonlyArray<AnyRoute> | Record<string, AnyRoute>
|
|
1090
|
+
>,
|
|
1092
1091
|
): Route<
|
|
1093
1092
|
TParentRoute,
|
|
1094
1093
|
TPath,
|
|
@@ -1104,7 +1103,21 @@ export class Route<
|
|
|
1104
1103
|
TLoaderFn,
|
|
1105
1104
|
TNewChildren
|
|
1106
1105
|
> {
|
|
1107
|
-
return this._addFileChildren(children)
|
|
1106
|
+
return this._addFileChildren(children) as Route<
|
|
1107
|
+
TParentRoute,
|
|
1108
|
+
TPath,
|
|
1109
|
+
TFullPath,
|
|
1110
|
+
TCustomId,
|
|
1111
|
+
TId,
|
|
1112
|
+
TSearchValidator,
|
|
1113
|
+
TParams,
|
|
1114
|
+
TRouterContext,
|
|
1115
|
+
TRouteContextFn,
|
|
1116
|
+
TBeforeLoadFn,
|
|
1117
|
+
TLoaderDeps,
|
|
1118
|
+
TLoaderFn,
|
|
1119
|
+
TNewChildren
|
|
1120
|
+
>
|
|
1108
1121
|
}
|
|
1109
1122
|
|
|
1110
1123
|
_addFileChildren<const TNewChildren>(
|
|
@@ -1302,7 +1315,7 @@ export function createRoute<
|
|
|
1302
1315
|
>(options)
|
|
1303
1316
|
}
|
|
1304
1317
|
|
|
1305
|
-
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>
|
|
1318
|
+
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>
|
|
1306
1319
|
|
|
1307
1320
|
export type RootRouteOptions<
|
|
1308
1321
|
TSearchValidator = undefined,
|
|
@@ -1408,12 +1421,11 @@ export class RootRoute<
|
|
|
1408
1421
|
super(options as any)
|
|
1409
1422
|
}
|
|
1410
1423
|
|
|
1411
|
-
addChildren<
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
|
1415
|
-
|
|
1416
|
-
children: TNewChildren,
|
|
1424
|
+
addChildren<const TNewChildren>(
|
|
1425
|
+
children: Constrain<
|
|
1426
|
+
TNewChildren,
|
|
1427
|
+
ReadonlyArray<AnyRoute> | Record<string, AnyRoute>
|
|
1428
|
+
>,
|
|
1417
1429
|
): RootRoute<
|
|
1418
1430
|
TSearchValidator,
|
|
1419
1431
|
TRouterContext,
|
package/src/router.ts
CHANGED
|
@@ -299,7 +299,7 @@ export interface RouterOptions<
|
|
|
299
299
|
*
|
|
300
300
|
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)
|
|
301
301
|
*/
|
|
302
|
-
defaultViewTransition?: boolean
|
|
302
|
+
defaultViewTransition?: boolean | ViewTransitionOptions
|
|
303
303
|
/**
|
|
304
304
|
* @default 'fuzzy'
|
|
305
305
|
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)
|
|
@@ -544,6 +544,10 @@ export interface DehydratedRouter {
|
|
|
544
544
|
manifest?: Manifest
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
+
export interface ViewTransitionOptions {
|
|
548
|
+
types: Array<string>
|
|
549
|
+
}
|
|
550
|
+
|
|
547
551
|
export type RouterConstructorOptions<
|
|
548
552
|
TRouteTree extends AnyRoute,
|
|
549
553
|
TTrailingSlashOption extends TrailingSlashOption,
|
|
@@ -689,7 +693,8 @@ export class Router<
|
|
|
689
693
|
Math.random() * 10000000,
|
|
690
694
|
)}`
|
|
691
695
|
resetNextScroll = true
|
|
692
|
-
shouldViewTransition?: boolean = undefined
|
|
696
|
+
shouldViewTransition?: boolean | ViewTransitionOptions = undefined
|
|
697
|
+
isViewTransitionTypesSupported?: boolean = undefined
|
|
693
698
|
subscribers = new Set<RouterListener<RouterEvent>>()
|
|
694
699
|
dehydratedData?: TDehydrated
|
|
695
700
|
viewTransitionPromise?: ControlledPromise<true>
|
|
@@ -853,6 +858,16 @@ export class Router<
|
|
|
853
858
|
},
|
|
854
859
|
})
|
|
855
860
|
}
|
|
861
|
+
|
|
862
|
+
if (
|
|
863
|
+
typeof window !== 'undefined' &&
|
|
864
|
+
'CSS' in window &&
|
|
865
|
+
typeof window.CSS.supports === 'function'
|
|
866
|
+
) {
|
|
867
|
+
this.isViewTransitionTypesSupported = window.CSS.supports(
|
|
868
|
+
'selector(:active-view-transition-type(a)',
|
|
869
|
+
)
|
|
870
|
+
}
|
|
856
871
|
}
|
|
857
872
|
|
|
858
873
|
get state() {
|
|
@@ -1061,7 +1076,7 @@ export class Router<
|
|
|
1061
1076
|
return this.routesById as Record<string, AnyRoute>
|
|
1062
1077
|
}
|
|
1063
1078
|
|
|
1064
|
-
/**
|
|
1079
|
+
/**
|
|
1065
1080
|
@deprecated use the following signature instead
|
|
1066
1081
|
```ts
|
|
1067
1082
|
matchRoutes (
|
|
@@ -2054,7 +2069,23 @@ export class Router<
|
|
|
2054
2069
|
'startViewTransition' in document &&
|
|
2055
2070
|
typeof document.startViewTransition === 'function'
|
|
2056
2071
|
) {
|
|
2057
|
-
|
|
2072
|
+
// lib.dom.ts doesn't support viewTransition types variant yet.
|
|
2073
|
+
// TODO: Fix this when dom types are updated
|
|
2074
|
+
let startViewTransitionParams: any
|
|
2075
|
+
|
|
2076
|
+
if (
|
|
2077
|
+
typeof shouldViewTransition === 'object' &&
|
|
2078
|
+
this.isViewTransitionTypesSupported
|
|
2079
|
+
) {
|
|
2080
|
+
startViewTransitionParams = {
|
|
2081
|
+
update: fn,
|
|
2082
|
+
types: shouldViewTransition.types,
|
|
2083
|
+
}
|
|
2084
|
+
} else {
|
|
2085
|
+
startViewTransitionParams = fn
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
document.startViewTransition(startViewTransitionParams)
|
|
2058
2089
|
} else {
|
|
2059
2090
|
fn()
|
|
2060
2091
|
}
|