@tanstack/react-router 1.35.2 → 1.35.5
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/index.d.cts +1 -1
- package/dist/cjs/link.cjs +2 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +1 -4
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +15 -21
- package/dist/cjs/routeInfo.d.cts +3 -3
- package/dist/cjs/router.cjs +7 -14
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/useNavigate.cjs +4 -2
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +3 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/link.d.ts +1 -4
- package/dist/esm/link.js +2 -1
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/route.d.ts +15 -21
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +3 -3
- package/dist/esm/router.js +7 -14
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useNavigate.js +4 -2
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useSearch.d.ts +3 -3
- package/dist/esm/useSearch.js.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +0 -1
- package/src/link.tsx +6 -17
- package/src/route.ts +25 -63
- package/src/routeInfo.ts +3 -6
- package/src/router.ts +6 -17
- package/src/useNavigate.tsx +2 -0
- package/src/useSearch.tsx +3 -6
package/dist/cjs/routeInfo.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyRoute
|
|
1
|
+
import { AnyRoute } from './route.cjs';
|
|
2
2
|
import { AnyRouter, TrailingSlashOption } from './router.cjs';
|
|
3
3
|
import { MergeUnion } from './utils.cjs';
|
|
4
4
|
|
|
@@ -34,8 +34,8 @@ export type RoutesByToPath<TRouter extends AnyRouter> = {
|
|
|
34
34
|
[TRoute in ParseRouteWithoutBranches<TRouter['routeTree']> as RouteToByRouter<TRouter, TRoute>]: TRoute;
|
|
35
35
|
};
|
|
36
36
|
export type RouteByToPath<TRouter extends AnyRouter, TTo> = Extract<RoutesByToPath<TRouter>[TTo], AnyRoute>;
|
|
37
|
-
export type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<
|
|
38
|
-
export type FullSearchSchemaInput<TRouteTree extends AnyRoute> = MergeUnion<
|
|
37
|
+
export type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchema']>;
|
|
38
|
+
export type FullSearchSchemaInput<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchemaInput']>;
|
|
39
39
|
export type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allParams']>;
|
|
40
40
|
export type AllContext<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allContext']>;
|
|
41
41
|
export type AllLoaderData<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['loaderData']>;
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -398,31 +398,24 @@ class Router {
|
|
|
398
398
|
};
|
|
399
399
|
this.buildLocation = (opts) => {
|
|
400
400
|
const build = (dest = {}, matches) => {
|
|
401
|
-
var _a, _b, _c;
|
|
401
|
+
var _a, _b, _c, _d;
|
|
402
402
|
let fromPath = this.latestLocation.pathname;
|
|
403
403
|
let fromSearch = dest.fromSearch || this.latestLocation.search;
|
|
404
|
-
const looseRoutesByPath = this.routesByPath;
|
|
405
|
-
const fromRoute = dest.from !== void 0 ? looseRoutesByPath[path.trimPathRight(dest.from)] : void 0;
|
|
406
404
|
const fromMatches = this.matchRoutes(
|
|
407
405
|
this.latestLocation.pathname,
|
|
408
406
|
fromSearch
|
|
409
407
|
);
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
invariant(
|
|
413
|
-
dest.from == null || fromMatch != null,
|
|
414
|
-
"Could not find match for from: " + dest.from
|
|
415
|
-
);
|
|
416
|
-
fromSearch = ((_a = utils.last(fromMatches)) == null ? void 0 : _a.search) || this.latestLocation.search;
|
|
408
|
+
fromPath = ((_a = fromMatches.find((d) => d.id === dest.from)) == null ? void 0 : _a.pathname) || fromPath;
|
|
409
|
+
fromSearch = ((_b = utils.last(fromMatches)) == null ? void 0 : _b.search) || this.latestLocation.search;
|
|
417
410
|
const stayingMatches = matches == null ? void 0 : matches.filter(
|
|
418
411
|
(d) => fromMatches.find((e) => e.routeId === d.routeId)
|
|
419
412
|
);
|
|
420
|
-
const fromRouteByFromPathRouteId = this.routesById[(
|
|
413
|
+
const fromRouteByFromPathRouteId = this.routesById[(_c = stayingMatches == null ? void 0 : stayingMatches.find((d) => d.pathname === fromPath)) == null ? void 0 : _c.routeId];
|
|
421
414
|
let pathname = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(
|
|
422
415
|
fromPath,
|
|
423
416
|
(fromRouteByFromPathRouteId == null ? void 0 : fromRouteByFromPathRouteId.to) ?? fromPath
|
|
424
417
|
);
|
|
425
|
-
const prevParams = { ...(
|
|
418
|
+
const prevParams = { ...(_d = utils.last(fromMatches)) == null ? void 0 : _d.params };
|
|
426
419
|
let nextParams = (dest.params ?? true) === true ? prevParams : { ...prevParams, ...utils.functionalUpdate(dest.params, prevParams) };
|
|
427
420
|
if (Object.keys(nextParams).length > 0) {
|
|
428
421
|
matches == null ? void 0 : matches.map((d) => this.looseRoutesById[d.routeId].options.stringifyParams).filter(Boolean).forEach((fn) => {
|
|
@@ -849,7 +842,7 @@ class Router {
|
|
|
849
842
|
preload: !!preload,
|
|
850
843
|
context: parentContext,
|
|
851
844
|
location,
|
|
852
|
-
navigate: (opts) => this.navigate({ ...opts }),
|
|
845
|
+
navigate: (opts) => this.navigate({ ...opts, from: match.pathname }),
|
|
853
846
|
buildLocation: this.buildLocation,
|
|
854
847
|
cause: preload ? "preload" : match.cause
|
|
855
848
|
})) ?? {};
|
|
@@ -891,7 +884,7 @@ class Router {
|
|
|
891
884
|
abortController: match.abortController,
|
|
892
885
|
context: match.context,
|
|
893
886
|
location,
|
|
894
|
-
navigate: (opts) => this.navigate({ ...opts }),
|
|
887
|
+
navigate: (opts) => this.navigate({ ...opts, from: match.pathname }),
|
|
895
888
|
cause: preload ? "preload" : match.cause,
|
|
896
889
|
route
|
|
897
890
|
};
|