@tanstack/react-router 1.31.29 → 1.32.0
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.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/useLocation.cjs +10 -0
- package/dist/cjs/useLocation.cjs.map +1 -0
- package/dist/cjs/useLocation.d.cts +4 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/useLocation.d.ts +4 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/package.json +1 -1
- package/src/index.tsx +1 -0
- package/src/useLocation.tsx +15 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ const routerContext = require("./routerContext.cjs");
|
|
|
26
26
|
const useRouteContext = require("./useRouteContext.cjs");
|
|
27
27
|
const useRouter = require("./useRouter.cjs");
|
|
28
28
|
const useRouterState = require("./useRouterState.cjs");
|
|
29
|
+
const useLocation = require("./useLocation.cjs");
|
|
29
30
|
const utils = require("./utils.cjs");
|
|
30
31
|
const notFound = require("./not-found.cjs");
|
|
31
32
|
Object.defineProperty(exports, "createBrowserHistory", {
|
|
@@ -130,6 +131,7 @@ exports.getRouterContext = routerContext.getRouterContext;
|
|
|
130
131
|
exports.useRouteContext = useRouteContext.useRouteContext;
|
|
131
132
|
exports.useRouter = useRouter.useRouter;
|
|
132
133
|
exports.useRouterState = useRouterState.useRouterState;
|
|
134
|
+
exports.useLocation = useLocation.useLocation;
|
|
133
135
|
exports.deepEqual = utils.deepEqual;
|
|
134
136
|
exports.escapeJSON = utils.escapeJSON;
|
|
135
137
|
exports.functionalUpdate = utils.functionalUpdate;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -27,6 +27,7 @@ export { getRouterContext, } from './routerContext.cjs';
|
|
|
27
27
|
export { useRouteContext } from './useRouteContext.cjs';
|
|
28
28
|
export { useRouter } from './useRouter.cjs';
|
|
29
29
|
export { useRouterState } from './useRouterState.cjs';
|
|
30
|
+
export { useLocation } from './useLocation.cjs';
|
|
30
31
|
export { escapeJSON, // SSR
|
|
31
32
|
useLayoutEffect, // SSR
|
|
32
33
|
pick, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, useStableCallback, shallow, } from './utils';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const useRouterState = require("./useRouterState.cjs");
|
|
4
|
+
function useLocation(opts) {
|
|
5
|
+
return useRouterState.useRouterState({
|
|
6
|
+
select: (state) => (opts == null ? void 0 : opts.select) ? opts.select(state.location) : state.location
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
exports.useLocation = useLocation;
|
|
10
|
+
//# sourceMappingURL=useLocation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocation.cjs","sources":["../../src/useLocation.tsx"],"sourcesContent":["import { useRouterState } from './useRouterState'\nimport type { AnyRouter, RegisteredRouter, RouterState } from './router'\n\nexport function useLocation<\n TRouter extends AnyRouter = RegisteredRouter,\n TLocationState = RouterState<TRouter['routeTree']>['location'],\n TSelected = TLocationState,\n>(opts?: { select?: (state: TLocationState) => TSelected }): TSelected {\n return useRouterState({\n select: (state) =>\n opts?.select\n ? opts.select(state.location as TLocationState)\n : (state.location as TSelected),\n })\n}\n"],"names":["useRouterState"],"mappings":";;;AAGO,SAAS,YAId,MAAqE;AACrE,SAAOA,8BAAe;AAAA,IACpB,QAAQ,CAAC,WACP,6BAAM,UACF,KAAK,OAAO,MAAM,QAA0B,IAC3C,MAAM;AAAA,EAAA,CACd;AACH;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyRouter, RegisteredRouter, RouterState } from './router.cjs';
|
|
2
|
+
export declare function useLocation<TRouter extends AnyRouter = RegisteredRouter, TLocationState = RouterState<TRouter['routeTree']>['location'], TSelected = TLocationState>(opts?: {
|
|
3
|
+
select?: (state: TLocationState) => TSelected;
|
|
4
|
+
}): TSelected;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { getRouterContext, } from './routerContext.js';
|
|
|
27
27
|
export { useRouteContext } from './useRouteContext.js';
|
|
28
28
|
export { useRouter } from './useRouter.js';
|
|
29
29
|
export { useRouterState } from './useRouterState.js';
|
|
30
|
+
export { useLocation } from './useLocation.js';
|
|
30
31
|
export { escapeJSON, // SSR
|
|
31
32
|
useLayoutEffect, // SSR
|
|
32
33
|
pick, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, useStableCallback, shallow, } from './utils';
|
package/dist/esm/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { getRouterContext } from "./routerContext.js";
|
|
|
24
24
|
import { useRouteContext } from "./useRouteContext.js";
|
|
25
25
|
import { useRouter } from "./useRouter.js";
|
|
26
26
|
import { useRouterState } from "./useRouterState.js";
|
|
27
|
+
import { useLocation } from "./useLocation.js";
|
|
27
28
|
import { deepEqual, escapeJSON, functionalUpdate, isPlainArray, isPlainObject, pick, replaceEqualDeep, shallow, useLayoutEffect, useStableCallback } from "./utils.js";
|
|
28
29
|
import { CatchNotFound, DefaultGlobalNotFound, isNotFound, notFound } from "./not-found.js";
|
|
29
30
|
export {
|
|
@@ -118,6 +119,7 @@ export {
|
|
|
118
119
|
useLinkProps,
|
|
119
120
|
useLoaderData,
|
|
120
121
|
useLoaderDeps,
|
|
122
|
+
useLocation,
|
|
121
123
|
useMatch,
|
|
122
124
|
useMatchRoute,
|
|
123
125
|
useMatches,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyRouter, RegisteredRouter, RouterState } from './router.js';
|
|
2
|
+
export declare function useLocation<TRouter extends AnyRouter = RegisteredRouter, TLocationState = RouterState<TRouter['routeTree']>['location'], TSelected = TLocationState>(opts?: {
|
|
3
|
+
select?: (state: TLocationState) => TSelected;
|
|
4
|
+
}): TSelected;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useRouterState } from "./useRouterState.js";
|
|
2
|
+
function useLocation(opts) {
|
|
3
|
+
return useRouterState({
|
|
4
|
+
select: (state) => (opts == null ? void 0 : opts.select) ? opts.select(state.location) : state.location
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
useLocation
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useLocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocation.js","sources":["../../src/useLocation.tsx"],"sourcesContent":["import { useRouterState } from './useRouterState'\nimport type { AnyRouter, RegisteredRouter, RouterState } from './router'\n\nexport function useLocation<\n TRouter extends AnyRouter = RegisteredRouter,\n TLocationState = RouterState<TRouter['routeTree']>['location'],\n TSelected = TLocationState,\n>(opts?: { select?: (state: TLocationState) => TSelected }): TSelected {\n return useRouterState({\n select: (state) =>\n opts?.select\n ? opts.select(state.location as TLocationState)\n : (state.location as TSelected),\n })\n}\n"],"names":[],"mappings":";AAGO,SAAS,YAId,MAAqE;AACrE,SAAO,eAAe;AAAA,IACpB,QAAQ,CAAC,WACP,6BAAM,UACF,KAAK,OAAO,MAAM,QAA0B,IAC3C,MAAM;AAAA,EAAA,CACd;AACH;"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -258,6 +258,7 @@ export {
|
|
|
258
258
|
export { useRouteContext } from './useRouteContext'
|
|
259
259
|
export { useRouter } from './useRouter'
|
|
260
260
|
export { useRouterState } from './useRouterState'
|
|
261
|
+
export { useLocation } from './useLocation'
|
|
261
262
|
export {
|
|
262
263
|
escapeJSON, // SSR
|
|
263
264
|
useLayoutEffect, // SSR
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useRouterState } from './useRouterState'
|
|
2
|
+
import type { AnyRouter, RegisteredRouter, RouterState } from './router'
|
|
3
|
+
|
|
4
|
+
export function useLocation<
|
|
5
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
6
|
+
TLocationState = RouterState<TRouter['routeTree']>['location'],
|
|
7
|
+
TSelected = TLocationState,
|
|
8
|
+
>(opts?: { select?: (state: TLocationState) => TSelected }): TSelected {
|
|
9
|
+
return useRouterState({
|
|
10
|
+
select: (state) =>
|
|
11
|
+
opts?.select
|
|
12
|
+
? opts.select(state.location as TLocationState)
|
|
13
|
+
: (state.location as TSelected),
|
|
14
|
+
})
|
|
15
|
+
}
|