@tanstack/react-router 1.94.1 → 1.95.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/router.cjs +4 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.cjs +8 -0
- package/dist/cjs/useCanGoBack.cjs.map +1 -0
- package/dist/cjs/useCanGoBack.d.cts +1 -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/router.js +4 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useCanGoBack.d.ts +1 -0
- package/dist/esm/useCanGoBack.js +8 -0
- package/dist/esm/useCanGoBack.js.map +1 -0
- package/package.json +2 -2
- package/src/index.tsx +2 -0
- package/src/router.ts +4 -1
- package/src/useCanGoBack.ts +5 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const useRouterState = require("./useRouterState.cjs");
|
|
4
|
+
function useCanGoBack() {
|
|
5
|
+
return useRouterState.useRouterState({ select: (s) => s.location.state.__TSR_index !== 0 });
|
|
6
|
+
}
|
|
7
|
+
exports.useCanGoBack = useCanGoBack;
|
|
8
|
+
//# sourceMappingURL=useCanGoBack.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCanGoBack.cjs","sources":["../../src/useCanGoBack.ts"],"sourcesContent":["import { useRouterState } from './useRouterState'\n\nexport function useCanGoBack() {\n return useRouterState({ select: (s) => s.location.state.__TSR_index !== 0 })\n}\n"],"names":["useRouterState"],"mappings":";;;AAEO,SAAS,eAAe;AACtB,SAAAA,eAAA,eAAe,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,gBAAgB,GAAG;AAC7E;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useCanGoBack(): boolean;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export { useRouteContext } from './useRouteContext.js';
|
|
|
54
54
|
export { useRouter } from './useRouter.js';
|
|
55
55
|
export { useRouterState } from './useRouterState.js';
|
|
56
56
|
export { useLocation } from './useLocation.js';
|
|
57
|
+
export { useCanGoBack } from './useCanGoBack.js';
|
|
57
58
|
export { escapeJSON, // SSR
|
|
58
59
|
useLayoutEffect, // SSR
|
|
59
60
|
pick, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, useStableCallback, shallow, } from './utils.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -34,6 +34,7 @@ import { useRouteContext } from "./useRouteContext.js";
|
|
|
34
34
|
import { useRouter } from "./useRouter.js";
|
|
35
35
|
import { useRouterState } from "./useRouterState.js";
|
|
36
36
|
import { useLocation } from "./useLocation.js";
|
|
37
|
+
import { useCanGoBack } from "./useCanGoBack.js";
|
|
37
38
|
import { createControlledPromise, deepEqual, escapeJSON, functionalUpdate, isPlainArray, isPlainObject, pick, replaceEqualDeep, shallow, useLayoutEffect, useStableCallback } from "./utils.js";
|
|
38
39
|
import { CatchNotFound, DefaultGlobalNotFound, isNotFound, notFound } from "./not-found.js";
|
|
39
40
|
import { retainSearchParams, stripSearchParams } from "./searchMiddleware.js";
|
|
@@ -129,6 +130,7 @@ export {
|
|
|
129
130
|
trimPathRight,
|
|
130
131
|
useAwaited,
|
|
131
132
|
useBlocker,
|
|
133
|
+
useCanGoBack,
|
|
132
134
|
useChildMatches,
|
|
133
135
|
useElementScrollRestoration,
|
|
134
136
|
useLayoutEffect,
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/esm/router.js
CHANGED
|
@@ -578,7 +578,10 @@ class Router {
|
|
|
578
578
|
...rest
|
|
579
579
|
} = {}) => {
|
|
580
580
|
if (href) {
|
|
581
|
-
const
|
|
581
|
+
const currentIndex = this.history.location.state.__TSR_index;
|
|
582
|
+
const parsed = parseHref(href, {
|
|
583
|
+
__TSR_index: replace ? currentIndex : currentIndex + 1
|
|
584
|
+
});
|
|
582
585
|
rest.to = parsed.pathname;
|
|
583
586
|
rest.search = this.options.parseSearch(parsed.search);
|
|
584
587
|
rest.hash = parsed.hash.slice(1);
|