@tanstack/react-router 1.121.16 → 1.121.17
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/package.json +2 -2
- package/dist/cjs/Asset.cjs +0 -41
- package/dist/cjs/Asset.cjs.map +0 -1
- package/dist/cjs/Asset.d.cts +0 -2
- package/dist/cjs/CatchBoundary.cjs +0 -114
- package/dist/cjs/CatchBoundary.cjs.map +0 -1
- package/dist/cjs/CatchBoundary.d.cts +0 -12
- package/dist/cjs/ClientOnly.cjs +0 -20
- package/dist/cjs/ClientOnly.cjs.map +0 -1
- package/dist/cjs/ClientOnly.d.cts +0 -29
- package/dist/cjs/HeadContent.cjs +0 -155
- package/dist/cjs/HeadContent.cjs.map +0 -1
- package/dist/cjs/HeadContent.d.cts +0 -7
- package/dist/cjs/Match.cjs +0 -257
- package/dist/cjs/Match.cjs.map +0 -1
- package/dist/cjs/Match.d.cts +0 -8
- package/dist/cjs/Matches.cjs +0 -136
- package/dist/cjs/Matches.cjs.map +0 -1
- package/dist/cjs/Matches.d.cts +0 -26
- package/dist/cjs/RouterProvider.cjs +0 -33
- package/dist/cjs/RouterProvider.cjs.map +0 -1
- package/dist/cjs/RouterProvider.d.cts +0 -10
- package/dist/cjs/SafeFragment.cjs +0 -8
- package/dist/cjs/SafeFragment.cjs.map +0 -1
- package/dist/cjs/SafeFragment.d.cts +0 -1
- package/dist/cjs/ScriptOnce.cjs +0 -28
- package/dist/cjs/ScriptOnce.cjs.map +0 -1
- package/dist/cjs/ScriptOnce.d.cts +0 -5
- package/dist/cjs/Scripts.cjs +0 -51
- package/dist/cjs/Scripts.cjs.map +0 -1
- package/dist/cjs/Scripts.d.cts +0 -1
- package/dist/cjs/ScrollRestoration.cjs +0 -39
- package/dist/cjs/ScrollRestoration.cjs.map +0 -1
- package/dist/cjs/ScrollRestoration.d.cts +0 -14
- package/dist/cjs/Transitioner.cjs +0 -115
- package/dist/cjs/Transitioner.cjs.map +0 -1
- package/dist/cjs/Transitioner.d.cts +0 -1
- package/dist/cjs/awaited.cjs +0 -48
- package/dist/cjs/awaited.cjs.map +0 -1
- package/dist/cjs/awaited.d.cts +0 -10
- package/dist/cjs/fileRoute.cjs +0 -107
- package/dist/cjs/fileRoute.cjs.map +0 -1
- package/dist/cjs/fileRoute.d.cts +0 -54
- package/dist/cjs/history.d.cts +0 -8
- package/dist/cjs/index.cjs +0 -289
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -55
- package/dist/cjs/lazyRouteComponent.cjs +0 -78
- package/dist/cjs/lazyRouteComponent.cjs.map +0 -1
- package/dist/cjs/lazyRouteComponent.d.cts +0 -2
- package/dist/cjs/link.cjs +0 -324
- package/dist/cjs/link.cjs.map +0 -1
- package/dist/cjs/link.d.cts +0 -48
- package/dist/cjs/matchContext.cjs +0 -27
- package/dist/cjs/matchContext.cjs.map +0 -1
- package/dist/cjs/matchContext.d.cts +0 -3
- package/dist/cjs/not-found.cjs +0 -40
- package/dist/cjs/not-found.cjs.map +0 -1
- package/dist/cjs/not-found.d.cts +0 -9
- package/dist/cjs/renderRouteNotFound.cjs +0 -22
- package/dist/cjs/renderRouteNotFound.cjs.map +0 -1
- package/dist/cjs/renderRouteNotFound.d.cts +0 -2
- package/dist/cjs/route.cjs +0 -205
- package/dist/cjs/route.cjs.map +0 -1
- package/dist/cjs/route.d.cts +0 -95
- package/dist/cjs/router.cjs +0 -22
- package/dist/cjs/router.cjs.map +0 -1
- package/dist/cjs/router.d.cts +0 -72
- package/dist/cjs/routerContext.cjs +0 -33
- package/dist/cjs/routerContext.cjs.map +0 -1
- package/dist/cjs/routerContext.d.cts +0 -8
- package/dist/cjs/scroll-restoration.cjs +0 -24
- package/dist/cjs/scroll-restoration.cjs.map +0 -1
- package/dist/cjs/scroll-restoration.d.cts +0 -1
- package/dist/cjs/serializer.d.cts +0 -6
- package/dist/cjs/structuralSharing.d.cts +0 -8
- package/dist/cjs/typePrimitives.d.cts +0 -16
- package/dist/cjs/useBlocker.cjs +0 -165
- package/dist/cjs/useBlocker.cjs.map +0 -1
- package/dist/cjs/useBlocker.d.cts +0 -66
- package/dist/cjs/useCanGoBack.cjs +0 -8
- package/dist/cjs/useCanGoBack.cjs.map +0 -1
- package/dist/cjs/useCanGoBack.d.cts +0 -1
- package/dist/cjs/useLoaderData.cjs +0 -15
- package/dist/cjs/useLoaderData.cjs.map +0 -1
- package/dist/cjs/useLoaderData.d.cts +0 -8
- package/dist/cjs/useLoaderDeps.cjs +0 -14
- package/dist/cjs/useLoaderDeps.cjs.map +0 -1
- package/dist/cjs/useLoaderDeps.d.cts +0 -8
- package/dist/cjs/useLocation.cjs +0 -10
- package/dist/cjs/useLocation.cjs.map +0 -1
- package/dist/cjs/useLocation.d.cts +0 -7
- package/dist/cjs/useMatch.cjs +0 -47
- package/dist/cjs/useMatch.cjs.map +0 -1
- package/dist/cjs/useMatch.d.cts +0 -10
- package/dist/cjs/useNavigate.cjs +0 -55
- package/dist/cjs/useNavigate.cjs.map +0 -1
- package/dist/cjs/useNavigate.d.cts +0 -5
- package/dist/cjs/useParams.cjs +0 -16
- package/dist/cjs/useParams.cjs.map +0 -1
- package/dist/cjs/useParams.d.cts +0 -9
- package/dist/cjs/useRouteContext.cjs +0 -11
- package/dist/cjs/useRouteContext.cjs.map +0 -1
- package/dist/cjs/useRouteContext.d.cts +0 -3
- package/dist/cjs/useRouter.cjs +0 -32
- package/dist/cjs/useRouter.cjs.map +0 -1
- package/dist/cjs/useRouter.d.cts +0 -4
- package/dist/cjs/useRouterState.cjs +0 -29
- package/dist/cjs/useRouterState.cjs.map +0 -1
- package/dist/cjs/useRouterState.d.cts +0 -8
- package/dist/cjs/useSearch.cjs +0 -16
- package/dist/cjs/useSearch.cjs.map +0 -1
- package/dist/cjs/useSearch.d.cts +0 -9
- package/dist/cjs/utils.cjs +0 -72
- package/dist/cjs/utils.cjs.map +0 -1
- package/dist/cjs/utils.d.cts +0 -49
- package/dist/esm/Asset.d.ts +0 -2
- package/dist/esm/Asset.js +0 -41
- package/dist/esm/Asset.js.map +0 -1
- package/dist/esm/CatchBoundary.d.ts +0 -12
- package/dist/esm/CatchBoundary.js +0 -97
- package/dist/esm/CatchBoundary.js.map +0 -1
- package/dist/esm/ClientOnly.d.ts +0 -29
- package/dist/esm/ClientOnly.js +0 -20
- package/dist/esm/ClientOnly.js.map +0 -1
- package/dist/esm/HeadContent.d.ts +0 -7
- package/dist/esm/HeadContent.js +0 -139
- package/dist/esm/HeadContent.js.map +0 -1
- package/dist/esm/Match.d.ts +0 -8
- package/dist/esm/Match.js +0 -240
- package/dist/esm/Match.js.map +0 -1
- package/dist/esm/Matches.d.ts +0 -26
- package/dist/esm/Matches.js +0 -119
- package/dist/esm/Matches.js.map +0 -1
- package/dist/esm/RouterProvider.d.ts +0 -10
- package/dist/esm/RouterProvider.js +0 -33
- package/dist/esm/RouterProvider.js.map +0 -1
- package/dist/esm/SafeFragment.d.ts +0 -1
- package/dist/esm/SafeFragment.js +0 -8
- package/dist/esm/SafeFragment.js.map +0 -1
- package/dist/esm/ScriptOnce.d.ts +0 -5
- package/dist/esm/ScriptOnce.js +0 -28
- package/dist/esm/ScriptOnce.js.map +0 -1
- package/dist/esm/Scripts.d.ts +0 -1
- package/dist/esm/Scripts.js +0 -51
- package/dist/esm/Scripts.js.map +0 -1
- package/dist/esm/ScrollRestoration.d.ts +0 -14
- package/dist/esm/ScrollRestoration.js +0 -39
- package/dist/esm/ScrollRestoration.js.map +0 -1
- package/dist/esm/Transitioner.d.ts +0 -1
- package/dist/esm/Transitioner.js +0 -98
- package/dist/esm/Transitioner.js.map +0 -1
- package/dist/esm/awaited.d.ts +0 -10
- package/dist/esm/awaited.js +0 -31
- package/dist/esm/awaited.js.map +0 -1
- package/dist/esm/fileRoute.d.ts +0 -54
- package/dist/esm/fileRoute.js +0 -107
- package/dist/esm/fileRoute.js.map +0 -1
- package/dist/esm/history.d.ts +0 -8
- package/dist/esm/index.d.ts +0 -55
- package/dist/esm/index.js +0 -151
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lazyRouteComponent.d.ts +0 -2
- package/dist/esm/lazyRouteComponent.js +0 -61
- package/dist/esm/lazyRouteComponent.js.map +0 -1
- package/dist/esm/link.d.ts +0 -48
- package/dist/esm/link.js +0 -307
- package/dist/esm/link.js.map +0 -1
- package/dist/esm/matchContext.d.ts +0 -3
- package/dist/esm/matchContext.js +0 -10
- package/dist/esm/matchContext.js.map +0 -1
- package/dist/esm/not-found.d.ts +0 -9
- package/dist/esm/not-found.js +0 -40
- package/dist/esm/not-found.js.map +0 -1
- package/dist/esm/renderRouteNotFound.d.ts +0 -2
- package/dist/esm/renderRouteNotFound.js +0 -22
- package/dist/esm/renderRouteNotFound.js.map +0 -1
- package/dist/esm/route.d.ts +0 -95
- package/dist/esm/route.js +0 -205
- package/dist/esm/route.js.map +0 -1
- package/dist/esm/router.d.ts +0 -72
- package/dist/esm/router.js +0 -22
- package/dist/esm/router.js.map +0 -1
- package/dist/esm/routerContext.d.ts +0 -8
- package/dist/esm/routerContext.js +0 -16
- package/dist/esm/routerContext.js.map +0 -1
- package/dist/esm/scroll-restoration.d.ts +0 -1
- package/dist/esm/scroll-restoration.js +0 -24
- package/dist/esm/scroll-restoration.js.map +0 -1
- package/dist/esm/serializer.d.ts +0 -6
- package/dist/esm/structuralSharing.d.ts +0 -8
- package/dist/esm/typePrimitives.d.ts +0 -16
- package/dist/esm/useBlocker.d.ts +0 -66
- package/dist/esm/useBlocker.js +0 -148
- package/dist/esm/useBlocker.js.map +0 -1
- package/dist/esm/useCanGoBack.d.ts +0 -1
- package/dist/esm/useCanGoBack.js +0 -8
- package/dist/esm/useCanGoBack.js.map +0 -1
- package/dist/esm/useLoaderData.d.ts +0 -8
- package/dist/esm/useLoaderData.js +0 -15
- package/dist/esm/useLoaderData.js.map +0 -1
- package/dist/esm/useLoaderDeps.d.ts +0 -8
- package/dist/esm/useLoaderDeps.js +0 -14
- package/dist/esm/useLoaderDeps.js.map +0 -1
- package/dist/esm/useLocation.d.ts +0 -7
- package/dist/esm/useLocation.js +0 -10
- package/dist/esm/useLocation.js.map +0 -1
- package/dist/esm/useMatch.d.ts +0 -10
- package/dist/esm/useMatch.js +0 -30
- package/dist/esm/useMatch.js.map +0 -1
- package/dist/esm/useNavigate.d.ts +0 -5
- package/dist/esm/useNavigate.js +0 -38
- package/dist/esm/useNavigate.js.map +0 -1
- package/dist/esm/useParams.d.ts +0 -9
- package/dist/esm/useParams.js +0 -16
- package/dist/esm/useParams.js.map +0 -1
- package/dist/esm/useRouteContext.d.ts +0 -3
- package/dist/esm/useRouteContext.js +0 -11
- package/dist/esm/useRouteContext.js.map +0 -1
- package/dist/esm/useRouter.d.ts +0 -4
- package/dist/esm/useRouter.js +0 -15
- package/dist/esm/useRouter.js.map +0 -1
- package/dist/esm/useRouterState.d.ts +0 -8
- package/dist/esm/useRouterState.js +0 -29
- package/dist/esm/useRouterState.js.map +0 -1
- package/dist/esm/useSearch.d.ts +0 -9
- package/dist/esm/useSearch.js +0 -16
- package/dist/esm/useSearch.js.map +0 -1
- package/dist/esm/utils.d.ts +0 -49
- package/dist/esm/utils.js +0 -55
- package/dist/esm/utils.js.map +0 -1
- package/dist/llms/index.d.ts +0 -3
- package/dist/llms/index.js +0 -35
- package/dist/llms/rules/api.d.ts +0 -2
- package/dist/llms/rules/api.js +0 -4241
- package/dist/llms/rules/guide.d.ts +0 -2
- package/dist/llms/rules/guide.js +0 -6225
- package/dist/llms/rules/routing.d.ts +0 -2
- package/dist/llms/rules/routing.js +0 -1946
- package/dist/llms/rules/setup-and-architecture.d.ts +0 -2
- package/dist/llms/rules/setup-and-architecture.js +0 -932
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { Outlet } from "./Match.js";
|
|
4
|
-
import { ClientOnly } from "./ClientOnly.js";
|
|
5
|
-
function isModuleNotFoundError(error) {
|
|
6
|
-
if (typeof (error == null ? void 0 : error.message) !== "string") return false;
|
|
7
|
-
return error.message.startsWith("Failed to fetch dynamically imported module") || error.message.startsWith("error loading dynamically imported module") || error.message.startsWith("Importing a module script failed");
|
|
8
|
-
}
|
|
9
|
-
function lazyRouteComponent(importer, exportName, ssr) {
|
|
10
|
-
let loadPromise;
|
|
11
|
-
let comp;
|
|
12
|
-
let error;
|
|
13
|
-
let reload;
|
|
14
|
-
const load = () => {
|
|
15
|
-
if (typeof document === "undefined" && (ssr == null ? void 0 : ssr()) === false) {
|
|
16
|
-
comp = () => null;
|
|
17
|
-
return Promise.resolve();
|
|
18
|
-
}
|
|
19
|
-
if (!loadPromise) {
|
|
20
|
-
loadPromise = importer().then((res) => {
|
|
21
|
-
loadPromise = void 0;
|
|
22
|
-
comp = res[exportName ?? "default"];
|
|
23
|
-
}).catch((err) => {
|
|
24
|
-
error = err;
|
|
25
|
-
if (isModuleNotFoundError(error)) {
|
|
26
|
-
if (error instanceof Error && typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
|
|
27
|
-
const storageKey = `tanstack_router_reload:${error.message}`;
|
|
28
|
-
if (!sessionStorage.getItem(storageKey)) {
|
|
29
|
-
sessionStorage.setItem(storageKey, "1");
|
|
30
|
-
reload = true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return loadPromise;
|
|
37
|
-
};
|
|
38
|
-
const lazyComp = function Lazy(props) {
|
|
39
|
-
if (reload) {
|
|
40
|
-
window.location.reload();
|
|
41
|
-
throw new Promise(() => {
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
if (error) {
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
if (!comp) {
|
|
48
|
-
throw load();
|
|
49
|
-
}
|
|
50
|
-
if ((ssr == null ? void 0 : ssr()) === false) {
|
|
51
|
-
return /* @__PURE__ */ jsx(ClientOnly, { fallback: /* @__PURE__ */ jsx(Outlet, {}), children: React.createElement(comp, props) });
|
|
52
|
-
}
|
|
53
|
-
return React.createElement(comp, props);
|
|
54
|
-
};
|
|
55
|
-
lazyComp.preload = load;
|
|
56
|
-
return lazyComp;
|
|
57
|
-
}
|
|
58
|
-
export {
|
|
59
|
-
lazyRouteComponent
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=lazyRouteComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lazyRouteComponent.js","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Outlet } from './Match'\nimport { ClientOnly } from './ClientOnly'\nimport type { AsyncRouteComponent } from './route'\n\n// If the load fails due to module not found, it may mean a new version of\n// the build was deployed and the user's browser is still using an old version.\n// If this happens, the old version in the user's browser would have an outdated\n// URL to the lazy module.\n// In that case, we want to attempt one window refresh to get the latest.\nfunction isModuleNotFoundError(error: any): boolean {\n // chrome: \"Failed to fetch dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split\"\n // firefox: \"error loading dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split\"\n // safari: \"Importing a module script failed.\"\n if (typeof error?.message !== 'string') return false\n return (\n error.message.startsWith('Failed to fetch dynamically imported module') ||\n error.message.startsWith('error loading dynamically imported module') ||\n error.message.startsWith('Importing a module script failed')\n )\n}\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n ssr?: () => boolean,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default']\n let error: any\n let reload: boolean\n\n const load = () => {\n if (typeof document === 'undefined' && ssr?.() === false) {\n comp = (() => null) as any\n return Promise.resolve()\n }\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n })\n .catch((err) => {\n // We don't want an error thrown from preload in this case, because\n // there's nothing we want to do about module not found during preload.\n // Record the error, the rest is handled during the render path.\n error = err\n if (isModuleNotFoundError(error)) {\n if (\n error instanceof Error &&\n typeof window !== 'undefined' &&\n typeof sessionStorage !== 'undefined'\n ) {\n // Again, we want to reload one time on module not found error and not enter\n // a reload loop if there is some other issue besides an old deploy.\n // That's why we store our reload attempt in sessionStorage.\n // Use error.message as key because it contains the module path that failed.\n const storageKey = `tanstack_router_reload:${error.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n reload = true\n }\n }\n }\n })\n }\n\n return loadPromise\n }\n\n const lazyComp = function Lazy(props: any) {\n // Now that we're out of preload and into actual render path,\n if (reload) {\n // If it was a module loading error,\n // throw eternal suspense while we wait for window to reload\n window.location.reload()\n throw new Promise(() => {})\n }\n if (error) {\n // Otherwise, just throw the error\n throw error\n }\n\n if (!comp) {\n throw load()\n }\n\n if (ssr?.() === false) {\n return (\n <ClientOnly fallback={<Outlet />}>\n {React.createElement(comp, props)}\n </ClientOnly>\n )\n }\n return React.createElement(comp, props)\n }\n\n ;(lazyComp as any).preload = load\n\n return lazyComp as any\n}\n"],"names":[],"mappings":";;;;AAUA,SAAS,sBAAsB,OAAqB;AAIlD,MAAI,QAAO,+BAAO,aAAY,SAAiB,QAAA;AAC/C,SACE,MAAM,QAAQ,WAAW,6CAA6C,KACtE,MAAM,QAAQ,WAAW,2CAA2C,KACpE,MAAM,QAAQ,WAAW,kCAAkC;AAE/D;AAEgB,SAAA,mBAId,UACA,YACA,KAGQ;AACJ,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AAEJ,QAAM,OAAO,MAAM;AACjB,QAAI,OAAO,aAAa,gBAAe,kCAAY,OAAO;AACxD,aAAQ,MAAM;AACd,aAAO,QAAQ,QAAQ;AAAA,IAAA;AAEzB,QAAI,CAAC,aAAa;AAChB,oBAAc,SAAS,EACpB,KAAK,CAAC,QAAQ;AACC,sBAAA;AACP,eAAA,IAAI,cAAc,SAAS;AAAA,MAAA,CACnC,EACA,MAAM,CAAC,QAAQ;AAIN,gBAAA;AACJ,YAAA,sBAAsB,KAAK,GAAG;AAChC,cACE,iBAAiB,SACjB,OAAO,WAAW,eAClB,OAAO,mBAAmB,aAC1B;AAKM,kBAAA,aAAa,0BAA0B,MAAM,OAAO;AAC1D,gBAAI,CAAC,eAAe,QAAQ,UAAU,GAAG;AACxB,6BAAA,QAAQ,YAAY,GAAG;AAC7B,uBAAA;AAAA,YAAA;AAAA,UACX;AAAA,QACF;AAAA,MACF,CACD;AAAA,IAAA;AAGE,WAAA;AAAA,EACT;AAEM,QAAA,WAAW,SAAS,KAAK,OAAY;AAEzC,QAAI,QAAQ;AAGV,aAAO,SAAS,OAAO;AACjB,YAAA,IAAI,QAAQ,MAAM;AAAA,MAAA,CAAE;AAAA,IAAA;AAE5B,QAAI,OAAO;AAEH,YAAA;AAAA,IAAA;AAGR,QAAI,CAAC,MAAM;AACT,YAAM,KAAK;AAAA,IAAA;AAGT,SAAA,kCAAY,OAAO;AAEnB,aAAA,oBAAC,YAAW,EAAA,UAAW,oBAAA,QAAA,CAAA,CAAO,GAC3B,UAAM,MAAA,cAAc,MAAM,KAAK,EAClC,CAAA;AAAA,IAAA;AAGG,WAAA,MAAM,cAAc,MAAM,KAAK;AAAA,EACxC;AAEE,WAAiB,UAAU;AAEtB,SAAA;AACT;"}
|
package/dist/esm/link.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { AnyRouter, Constrain, LinkOptions, RegisteredRouter, RoutePaths } from '@tanstack/router-core';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import { ValidateLinkOptions, ValidateLinkOptionsArray } from './typePrimitives.js';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
export declare function useLinkProps<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>, forwardedRef?: React.ForwardedRef<Element>): React.ComponentPropsWithRef<'a'>;
|
|
6
|
-
type UseLinkReactProps<TComp> = TComp extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[TComp] : React.PropsWithoutRef<TComp extends React.ComponentType<infer TProps> ? TProps : never> & React.RefAttributes<TComp extends React.FC<{
|
|
7
|
-
ref: React.Ref<infer TRef>;
|
|
8
|
-
}> | React.Component<{
|
|
9
|
-
ref: React.Ref<infer TRef>;
|
|
10
|
-
}> ? TRef : never>;
|
|
11
|
-
export type UseLinkPropsOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string | undefined = '.', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & UseLinkReactProps<'a'>;
|
|
12
|
-
export type ActiveLinkOptions<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & ActiveLinkOptionProps<TComp>;
|
|
13
|
-
type ActiveLinkProps<TComp> = Partial<LinkComponentReactProps<TComp> & {
|
|
14
|
-
[key: `data-${string}`]: unknown;
|
|
15
|
-
}>;
|
|
16
|
-
export interface ActiveLinkOptionProps<TComp = 'a'> {
|
|
17
|
-
/**
|
|
18
|
-
* A function that returns additional props for the `active` state of this link.
|
|
19
|
-
* These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
|
|
20
|
-
*/
|
|
21
|
-
activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>);
|
|
22
|
-
/**
|
|
23
|
-
* A function that returns additional props for the `inactive` state of this link.
|
|
24
|
-
* These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
|
|
25
|
-
*/
|
|
26
|
-
inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>);
|
|
27
|
-
}
|
|
28
|
-
export type LinkProps<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkPropsChildren;
|
|
29
|
-
export interface LinkPropsChildren {
|
|
30
|
-
children?: React.ReactNode | ((state: {
|
|
31
|
-
isActive: boolean;
|
|
32
|
-
isTransitioning: boolean;
|
|
33
|
-
}) => React.ReactNode);
|
|
34
|
-
}
|
|
35
|
-
type LinkComponentReactProps<TComp> = Omit<UseLinkReactProps<TComp>, keyof CreateLinkProps>;
|
|
36
|
-
export type LinkComponentProps<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkComponentReactProps<TComp> & LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
|
|
37
|
-
export type CreateLinkProps = LinkProps<any, any, string, string, string, string>;
|
|
38
|
-
export type LinkComponent<in out TComp, in out TDefaultFrom extends string = string> = <TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = TDefaultFrom, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => React.ReactElement;
|
|
39
|
-
export interface LinkComponentRoute<in out TDefaultFrom extends string = string> {
|
|
40
|
-
defaultFrom: TDefaultFrom;
|
|
41
|
-
<TRouter extends AnyRouter = RegisteredRouter, const TTo extends string | undefined = undefined, const TMaskTo extends string = ''>(props: LinkComponentProps<'a', TRouter, this['defaultFrom'], TTo, this['defaultFrom'], TMaskTo>): React.ReactElement;
|
|
42
|
-
}
|
|
43
|
-
export declare function createLink<const TComp>(Comp: Constrain<TComp, any, (props: CreateLinkProps) => ReactNode>): LinkComponent<TComp>;
|
|
44
|
-
export declare const Link: LinkComponent<'a'>;
|
|
45
|
-
export type LinkOptionsFnOptions<TOptions, TComp, TRouter extends AnyRouter = RegisteredRouter> = TOptions extends ReadonlyArray<any> ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp> : ValidateLinkOptions<TRouter, TOptions, string, TComp>;
|
|
46
|
-
export type LinkOptionsFn<TComp> = <const TOptions, TRouter extends AnyRouter = RegisteredRouter>(options: LinkOptionsFnOptions<TOptions, TComp, TRouter>) => TOptions;
|
|
47
|
-
export declare const linkOptions: LinkOptionsFn<'a'>;
|
|
48
|
-
export {};
|
package/dist/esm/link.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { flushSync } from "react-dom";
|
|
4
|
-
import { preloadWarning, functionalUpdate, exactPathTest, removeTrailingSlash, deepEqual } from "@tanstack/router-core";
|
|
5
|
-
import { useRouterState } from "./useRouterState.js";
|
|
6
|
-
import { useRouter } from "./useRouter.js";
|
|
7
|
-
import { useForwardedRef, useIntersectionObserver, useLayoutEffect } from "./utils.js";
|
|
8
|
-
import { useMatch } from "./useMatch.js";
|
|
9
|
-
function useLinkProps(options, forwardedRef) {
|
|
10
|
-
const router = useRouter();
|
|
11
|
-
const [isTransitioning, setIsTransitioning] = React.useState(false);
|
|
12
|
-
const hasRenderFetched = React.useRef(false);
|
|
13
|
-
const innerRef = useForwardedRef(forwardedRef);
|
|
14
|
-
const {
|
|
15
|
-
// custom props
|
|
16
|
-
activeProps = () => ({ className: "active" }),
|
|
17
|
-
inactiveProps = () => ({}),
|
|
18
|
-
activeOptions,
|
|
19
|
-
to,
|
|
20
|
-
preload: userPreload,
|
|
21
|
-
preloadDelay: userPreloadDelay,
|
|
22
|
-
hashScrollIntoView,
|
|
23
|
-
replace,
|
|
24
|
-
startTransition,
|
|
25
|
-
resetScroll,
|
|
26
|
-
viewTransition,
|
|
27
|
-
// element props
|
|
28
|
-
children,
|
|
29
|
-
target,
|
|
30
|
-
disabled,
|
|
31
|
-
style,
|
|
32
|
-
className,
|
|
33
|
-
onClick,
|
|
34
|
-
onFocus,
|
|
35
|
-
onMouseEnter,
|
|
36
|
-
onMouseLeave,
|
|
37
|
-
onTouchStart,
|
|
38
|
-
ignoreBlocker,
|
|
39
|
-
...rest
|
|
40
|
-
} = options;
|
|
41
|
-
const {
|
|
42
|
-
// prevent these from being returned
|
|
43
|
-
params: _params,
|
|
44
|
-
search: _search,
|
|
45
|
-
hash: _hash,
|
|
46
|
-
state: _state,
|
|
47
|
-
mask: _mask,
|
|
48
|
-
reloadDocument: _reloadDocument,
|
|
49
|
-
...propsSafeToSpread
|
|
50
|
-
} = rest;
|
|
51
|
-
const type = React.useMemo(() => {
|
|
52
|
-
try {
|
|
53
|
-
new URL(`${to}`);
|
|
54
|
-
return "external";
|
|
55
|
-
} catch {
|
|
56
|
-
}
|
|
57
|
-
return "internal";
|
|
58
|
-
}, [to]);
|
|
59
|
-
const currentSearch = useRouterState({
|
|
60
|
-
select: (s) => s.location.search,
|
|
61
|
-
structuralSharing: true
|
|
62
|
-
});
|
|
63
|
-
const nearestFrom = useMatch({
|
|
64
|
-
strict: false,
|
|
65
|
-
select: (match) => match.fullPath
|
|
66
|
-
});
|
|
67
|
-
const from = options.from ?? nearestFrom;
|
|
68
|
-
options = { ...options, from };
|
|
69
|
-
const next = React.useMemo(
|
|
70
|
-
() => router.buildLocation(options),
|
|
71
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
-
[router, options, currentSearch]
|
|
73
|
-
);
|
|
74
|
-
const preload = React.useMemo(() => {
|
|
75
|
-
if (options.reloadDocument) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
return userPreload ?? router.options.defaultPreload;
|
|
79
|
-
}, [router.options.defaultPreload, userPreload, options.reloadDocument]);
|
|
80
|
-
const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
|
81
|
-
const isActive = useRouterState({
|
|
82
|
-
select: (s) => {
|
|
83
|
-
if (activeOptions == null ? void 0 : activeOptions.exact) {
|
|
84
|
-
const testExact = exactPathTest(
|
|
85
|
-
s.location.pathname,
|
|
86
|
-
next.pathname,
|
|
87
|
-
router.basepath
|
|
88
|
-
);
|
|
89
|
-
if (!testExact) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
const currentPathSplit = removeTrailingSlash(
|
|
94
|
-
s.location.pathname,
|
|
95
|
-
router.basepath
|
|
96
|
-
).split("/");
|
|
97
|
-
const nextPathSplit = removeTrailingSlash(
|
|
98
|
-
next.pathname,
|
|
99
|
-
router.basepath
|
|
100
|
-
).split("/");
|
|
101
|
-
const pathIsFuzzyEqual = nextPathSplit.every(
|
|
102
|
-
(d, i) => d === currentPathSplit[i]
|
|
103
|
-
);
|
|
104
|
-
if (!pathIsFuzzyEqual) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if ((activeOptions == null ? void 0 : activeOptions.includeSearch) ?? true) {
|
|
109
|
-
const searchTest = deepEqual(s.location.search, next.search, {
|
|
110
|
-
partial: !(activeOptions == null ? void 0 : activeOptions.exact),
|
|
111
|
-
ignoreUndefined: !(activeOptions == null ? void 0 : activeOptions.explicitUndefined)
|
|
112
|
-
});
|
|
113
|
-
if (!searchTest) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (activeOptions == null ? void 0 : activeOptions.includeHash) {
|
|
118
|
-
return s.location.hash === next.hash;
|
|
119
|
-
}
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
const doPreload = React.useCallback(() => {
|
|
124
|
-
router.preloadRoute(options).catch((err) => {
|
|
125
|
-
console.warn(err);
|
|
126
|
-
console.warn(preloadWarning);
|
|
127
|
-
});
|
|
128
|
-
}, [options, router]);
|
|
129
|
-
const preloadViewportIoCallback = React.useCallback(
|
|
130
|
-
(entry) => {
|
|
131
|
-
if (entry == null ? void 0 : entry.isIntersecting) {
|
|
132
|
-
doPreload();
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
[doPreload]
|
|
136
|
-
);
|
|
137
|
-
useIntersectionObserver(
|
|
138
|
-
innerRef,
|
|
139
|
-
preloadViewportIoCallback,
|
|
140
|
-
{ rootMargin: "100px" },
|
|
141
|
-
{ disabled: !!disabled || !(preload === "viewport") }
|
|
142
|
-
);
|
|
143
|
-
useLayoutEffect(() => {
|
|
144
|
-
if (hasRenderFetched.current) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (!disabled && preload === "render") {
|
|
148
|
-
doPreload();
|
|
149
|
-
hasRenderFetched.current = true;
|
|
150
|
-
}
|
|
151
|
-
}, [disabled, doPreload, preload]);
|
|
152
|
-
if (type === "external") {
|
|
153
|
-
return {
|
|
154
|
-
...propsSafeToSpread,
|
|
155
|
-
ref: innerRef,
|
|
156
|
-
type,
|
|
157
|
-
href: to,
|
|
158
|
-
...children && { children },
|
|
159
|
-
...target && { target },
|
|
160
|
-
...disabled && { disabled },
|
|
161
|
-
...style && { style },
|
|
162
|
-
...className && { className },
|
|
163
|
-
...onClick && { onClick },
|
|
164
|
-
...onFocus && { onFocus },
|
|
165
|
-
...onMouseEnter && { onMouseEnter },
|
|
166
|
-
...onMouseLeave && { onMouseLeave },
|
|
167
|
-
...onTouchStart && { onTouchStart }
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
const handleClick = (e) => {
|
|
171
|
-
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!target || target === "_self") && e.button === 0) {
|
|
172
|
-
e.preventDefault();
|
|
173
|
-
flushSync(() => {
|
|
174
|
-
setIsTransitioning(true);
|
|
175
|
-
});
|
|
176
|
-
const unsub = router.subscribe("onResolved", () => {
|
|
177
|
-
unsub();
|
|
178
|
-
setIsTransitioning(false);
|
|
179
|
-
});
|
|
180
|
-
return router.navigate({
|
|
181
|
-
...options,
|
|
182
|
-
replace,
|
|
183
|
-
resetScroll,
|
|
184
|
-
hashScrollIntoView,
|
|
185
|
-
startTransition,
|
|
186
|
-
viewTransition,
|
|
187
|
-
ignoreBlocker
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
const handleFocus = (_) => {
|
|
192
|
-
if (disabled) return;
|
|
193
|
-
if (preload) {
|
|
194
|
-
doPreload();
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
const handleTouchStart = handleFocus;
|
|
198
|
-
const handleEnter = (e) => {
|
|
199
|
-
if (disabled) return;
|
|
200
|
-
const eventTarget = e.target || {};
|
|
201
|
-
if (preload) {
|
|
202
|
-
if (eventTarget.preloadTimeout) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
if (!preloadDelay) {
|
|
206
|
-
doPreload();
|
|
207
|
-
} else {
|
|
208
|
-
eventTarget.preloadTimeout = setTimeout(() => {
|
|
209
|
-
eventTarget.preloadTimeout = null;
|
|
210
|
-
doPreload();
|
|
211
|
-
}, preloadDelay);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
const handleLeave = (e) => {
|
|
216
|
-
if (disabled) return;
|
|
217
|
-
const eventTarget = e.target || {};
|
|
218
|
-
if (eventTarget.preloadTimeout) {
|
|
219
|
-
clearTimeout(eventTarget.preloadTimeout);
|
|
220
|
-
eventTarget.preloadTimeout = null;
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
const composeHandlers = (handlers) => (e) => {
|
|
224
|
-
var _a;
|
|
225
|
-
(_a = e.persist) == null ? void 0 : _a.call(e);
|
|
226
|
-
handlers.filter(Boolean).forEach((handler) => {
|
|
227
|
-
if (e.defaultPrevented) return;
|
|
228
|
-
handler(e);
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? {} : {};
|
|
232
|
-
const resolvedInactiveProps = isActive ? {} : functionalUpdate(inactiveProps, {});
|
|
233
|
-
const resolvedClassName = [
|
|
234
|
-
className,
|
|
235
|
-
resolvedActiveProps.className,
|
|
236
|
-
resolvedInactiveProps.className
|
|
237
|
-
].filter(Boolean).join(" ");
|
|
238
|
-
const resolvedStyle = {
|
|
239
|
-
...style,
|
|
240
|
-
...resolvedActiveProps.style,
|
|
241
|
-
...resolvedInactiveProps.style
|
|
242
|
-
};
|
|
243
|
-
return {
|
|
244
|
-
...propsSafeToSpread,
|
|
245
|
-
...resolvedActiveProps,
|
|
246
|
-
...resolvedInactiveProps,
|
|
247
|
-
href: disabled ? void 0 : next.maskedLocation ? router.history.createHref(next.maskedLocation.href) : router.history.createHref(next.href),
|
|
248
|
-
ref: innerRef,
|
|
249
|
-
onClick: composeHandlers([onClick, handleClick]),
|
|
250
|
-
onFocus: composeHandlers([onFocus, handleFocus]),
|
|
251
|
-
onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
|
|
252
|
-
onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
|
|
253
|
-
onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
|
|
254
|
-
disabled: !!disabled,
|
|
255
|
-
target,
|
|
256
|
-
...Object.keys(resolvedStyle).length && { style: resolvedStyle },
|
|
257
|
-
...resolvedClassName && { className: resolvedClassName },
|
|
258
|
-
...disabled && {
|
|
259
|
-
role: "link",
|
|
260
|
-
"aria-disabled": true
|
|
261
|
-
},
|
|
262
|
-
...isActive && { "data-status": "active", "aria-current": "page" },
|
|
263
|
-
...isTransitioning && { "data-transitioning": "transitioning" }
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
function createLink(Comp) {
|
|
267
|
-
return React.forwardRef(function CreatedLink(props, ref) {
|
|
268
|
-
return /* @__PURE__ */ jsx(Link, { ...props, _asChild: Comp, ref });
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
const Link = React.forwardRef(
|
|
272
|
-
(props, ref) => {
|
|
273
|
-
const { _asChild, ...rest } = props;
|
|
274
|
-
const {
|
|
275
|
-
type: _type,
|
|
276
|
-
ref: innerRef,
|
|
277
|
-
...linkProps
|
|
278
|
-
} = useLinkProps(rest, ref);
|
|
279
|
-
const children = typeof rest.children === "function" ? rest.children({
|
|
280
|
-
isActive: linkProps["data-status"] === "active"
|
|
281
|
-
}) : rest.children;
|
|
282
|
-
if (typeof _asChild === "undefined") {
|
|
283
|
-
delete linkProps.disabled;
|
|
284
|
-
}
|
|
285
|
-
return React.createElement(
|
|
286
|
-
_asChild ? _asChild : "a",
|
|
287
|
-
{
|
|
288
|
-
...linkProps,
|
|
289
|
-
ref: innerRef
|
|
290
|
-
},
|
|
291
|
-
children
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
);
|
|
295
|
-
function isCtrlEvent(e) {
|
|
296
|
-
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
297
|
-
}
|
|
298
|
-
const linkOptions = (options) => {
|
|
299
|
-
return options;
|
|
300
|
-
};
|
|
301
|
-
export {
|
|
302
|
-
Link,
|
|
303
|
-
createLink,
|
|
304
|
-
linkOptions,
|
|
305
|
-
useLinkProps
|
|
306
|
-
};
|
|
307
|
-
//# sourceMappingURL=link.js.map
|
package/dist/esm/link.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../src/link.tsx"],"sourcesContent":["import * as React from 'react'\nimport { flushSync } from 'react-dom'\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\n\nimport {\n useForwardedRef,\n useIntersectionObserver,\n useLayoutEffect,\n} from './utils'\n\nimport { useMatch } from './useMatch'\nimport type {\n AnyRouter,\n Constrain,\n LinkCurrentTargetElement,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type { ReactNode } from 'react'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n forwardedRef?: React.ForwardedRef<Element>,\n): React.ComponentPropsWithRef<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = React.useState(false)\n const hasRenderFetched = React.useRef(false)\n const innerRef = useForwardedRef(forwardedRef)\n\n const {\n // custom props\n activeProps = () => ({ className: 'active' }),\n inactiveProps = () => ({}),\n activeOptions,\n to,\n preload: userPreload,\n preloadDelay: userPreloadDelay,\n hashScrollIntoView,\n replace,\n startTransition,\n resetScroll,\n viewTransition,\n // element props\n children,\n target,\n disabled,\n style,\n className,\n onClick,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchStart,\n ignoreBlocker,\n ...rest\n } = options\n\n const {\n // prevent these from being returned\n params: _params,\n search: _search,\n hash: _hash,\n state: _state,\n mask: _mask,\n reloadDocument: _reloadDocument,\n ...propsSafeToSpread\n } = rest\n\n // If this link simply reloads the current route,\n // make sure it has a new key so it will trigger a data refresh\n\n // If this `to` is a valid external URL, return\n // null for LinkUtils\n\n const type: 'internal' | 'external' = React.useMemo(() => {\n try {\n new URL(`${to}`)\n return 'external'\n } catch {}\n return 'internal'\n }, [to])\n\n // subscribe to search params to re-build location if it changes\n const currentSearch = useRouterState({\n select: (s) => s.location.search,\n structuralSharing: true as any,\n })\n\n const nearestFrom = useMatch({\n strict: false,\n select: (match) => match.fullPath,\n })\n\n const from = options.from ?? nearestFrom\n\n // Use it as the default `from` location\n options = { ...options, from }\n\n const next = React.useMemo(\n () => router.buildLocation(options as any),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [router, options, currentSearch],\n )\n\n const preload = React.useMemo(() => {\n if (options.reloadDocument) {\n return false\n }\n return userPreload ?? router.options.defaultPreload\n }, [router.options.defaultPreload, userPreload, options.reloadDocument])\n const preloadDelay =\n userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = useRouterState({\n select: (s) => {\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n s.location.pathname,\n next.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPathSplit = removeTrailingSlash(\n s.location.pathname,\n router.basepath,\n ).split('/')\n const nextPathSplit = removeTrailingSlash(\n next.pathname,\n router.basepath,\n ).split('/')\n\n const pathIsFuzzyEqual = nextPathSplit.every(\n (d, i) => d === currentPathSplit[i],\n )\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(s.location.search, next.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n return s.location.hash === next.hash\n }\n return true\n },\n })\n\n const doPreload = React.useCallback(() => {\n router.preloadRoute(options as any).catch((err) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n }, [options, router])\n\n const preloadViewportIoCallback = React.useCallback(\n (entry: IntersectionObserverEntry | undefined) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n },\n [doPreload],\n )\n\n useIntersectionObserver(\n innerRef,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!disabled || !(preload === 'viewport') },\n )\n\n useLayoutEffect(() => {\n if (hasRenderFetched.current) {\n return\n }\n if (!disabled && preload === 'render') {\n doPreload()\n hasRenderFetched.current = true\n }\n }, [disabled, doPreload, preload])\n\n if (type === 'external') {\n return {\n ...propsSafeToSpread,\n ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'],\n type,\n href: to,\n ...(children && { children }),\n ...(target && { target }),\n ...(disabled && { disabled }),\n ...(style && { style }),\n ...(className && { className }),\n ...(onClick && { onClick }),\n ...(onFocus && { onFocus }),\n ...(onMouseEnter && { onMouseEnter }),\n ...(onMouseLeave && { onMouseLeave }),\n ...(onTouchStart && { onTouchStart }),\n }\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n if (\n !disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!target || target === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n flushSync(() => {\n setIsTransitioning(true)\n })\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n setIsTransitioning(false)\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n return router.navigate({\n ...options,\n replace,\n resetScroll,\n hashScrollIntoView,\n startTransition,\n viewTransition,\n ignoreBlocker,\n })\n }\n }\n\n // The click handler\n const handleFocus = (_: MouseEvent) => {\n if (disabled) return\n if (preload) {\n doPreload()\n }\n }\n\n const handleTouchStart = handleFocus\n\n const handleEnter = (e: MouseEvent) => {\n if (disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (preload) {\n if (eventTarget.preloadTimeout) {\n return\n }\n\n if (!preloadDelay) {\n doPreload()\n } else {\n eventTarget.preloadTimeout = setTimeout(() => {\n eventTarget.preloadTimeout = null\n doPreload()\n }, preloadDelay)\n }\n }\n }\n\n const handleLeave = (e: MouseEvent) => {\n if (disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (eventTarget.preloadTimeout) {\n clearTimeout(eventTarget.preloadTimeout)\n eventTarget.preloadTimeout = null\n }\n }\n\n const composeHandlers =\n (handlers: Array<undefined | ((e: any) => void)>) =>\n (e: { persist?: () => void; defaultPrevented: boolean }) => {\n e.persist?.()\n handlers.filter(Boolean).forEach((handler) => {\n if (e.defaultPrevented) return\n handler!(e)\n })\n }\n\n // Get the active props\n const resolvedActiveProps: React.HTMLAttributes<HTMLAnchorElement> = isActive\n ? (functionalUpdate(activeProps as any, {}) ?? {})\n : {}\n\n // Get the inactive props\n const resolvedInactiveProps: React.HTMLAttributes<HTMLAnchorElement> =\n isActive ? {} : functionalUpdate(inactiveProps, {})\n\n const resolvedClassName = [\n className,\n resolvedActiveProps.className,\n resolvedInactiveProps.className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const resolvedStyle = {\n ...style,\n ...resolvedActiveProps.style,\n ...resolvedInactiveProps.style,\n }\n\n return {\n ...propsSafeToSpread,\n ...resolvedActiveProps,\n ...resolvedInactiveProps,\n href: disabled\n ? undefined\n : next.maskedLocation\n ? router.history.createHref(next.maskedLocation.href)\n : router.history.createHref(next.href),\n ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'],\n onClick: composeHandlers([onClick, handleClick]),\n onFocus: composeHandlers([onFocus, handleFocus]),\n onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),\n onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),\n onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),\n disabled: !!disabled,\n target,\n ...(Object.keys(resolvedStyle).length && { style: resolvedStyle }),\n ...(resolvedClassName && { className: resolvedClassName }),\n ...(disabled && {\n role: 'link',\n 'aria-disabled': true,\n }),\n ...(isActive && { 'data-status': 'active', 'aria-current': 'page' }),\n ...(isTransitioning && { 'data-transitioning': 'transitioning' }),\n }\n}\n\ntype UseLinkReactProps<TComp> = TComp extends keyof React.JSX.IntrinsicElements\n ? React.JSX.IntrinsicElements[TComp]\n : React.PropsWithoutRef<\n TComp extends React.ComponentType<infer TProps> ? TProps : never\n > &\n React.RefAttributes<\n TComp extends\n | React.FC<{ ref: React.Ref<infer TRef> }>\n | React.Component<{ ref: React.Ref<infer TRef> }>\n ? TRef\n : never\n >\n\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n UseLinkReactProps<'a'>\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n LinkComponentReactProps<TComp> & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | React.ReactNode\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => React.ReactNode)\n}\n\ntype LinkComponentReactProps<TComp> = Omit<\n UseLinkReactProps<TComp>,\n keyof CreateLinkProps\n>\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentReactProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => React.ReactElement\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): React.ReactElement\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => ReactNode>,\n): LinkComponent<TComp> {\n return React.forwardRef(function CreatedLink(props, ref) {\n return <Link {...(props as any)} _asChild={Comp} ref={ref} />\n }) as any\n}\n\nexport const Link: LinkComponent<'a'> = React.forwardRef<Element, any>(\n (props, ref) => {\n const { _asChild, ...rest } = props\n const {\n type: _type,\n ref: innerRef,\n ...linkProps\n } = useLinkProps(rest as any, ref)\n\n const children =\n typeof rest.children === 'function'\n ? rest.children({\n isActive: (linkProps as any)['data-status'] === 'active',\n })\n : rest.children\n\n if (typeof _asChild === 'undefined') {\n // the ReturnType of useLinkProps returns the correct type for a <a> element, not a general component that has a disabled prop\n // @ts-expect-error\n delete linkProps.disabled\n }\n\n return React.createElement(\n _asChild ? _asChild : 'a',\n {\n ...linkProps,\n ref: innerRef,\n },\n children,\n )\n },\n) as any\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"names":[],"mappings":";;;;;;;;AAiCgB,SAAA,aAOd,SACA,cACkC;AAClC,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,MAAM,SAAS,KAAK;AAC5D,QAAA,mBAAmB,MAAM,OAAO,KAAK;AACrC,QAAA,WAAW,gBAAgB,YAAY;AAEvC,QAAA;AAAA;AAAA,IAEJ,cAAc,OAAO,EAAE,WAAW;IAClC,gBAAgB,OAAO,CAAA;AAAA,IACvB;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEE,QAAA;AAAA;AAAA,IAEJ,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,gBAAgB;AAAA,IAChB,GAAG;AAAA,EAAA,IACD;AAQE,QAAA,OAAgC,MAAM,QAAQ,MAAM;AACpD,QAAA;AACE,UAAA,IAAI,GAAG,EAAE,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A,GAAI,OAAO,KAAK,aAAa,EAAE,UAAU,EAAE,OAAO,cAAc;AAAA,IAChE,GAAI,qBAAqB,EAAE,WAAW,kBAAkB;AAAA,IACxD,GAAI,YAAY;AAAA,MACd,MAAM;AAAA,MACN,iBAAiB;AAAA,IACnB;AAAA,IACA,GAAI,YAAY,EAAE,eAAe,UAAU,gBAAgB,OAAO;AAAA,IAClE,GAAI,mBAAmB,EAAE,sBAAsB,gBAAgB;AAAA,EACjE;AACF;AAkIO,SAAS,WACd,MACsB;AACtB,SAAO,MAAM,WAAW,SAAS,YAAY,OAAO,KAAK;AACvD,+BAAQ,MAAM,EAAA,GAAI,OAAe,UAAU,MAAM,KAAU;AAAA,EAAA,CAC5D;AACH;AAEO,MAAM,OAA2B,MAAM;AAAA,EAC5C,CAAC,OAAO,QAAQ;AACd,UAAM,EAAE,UAAU,GAAG,KAAA,IAAS;AACxB,UAAA;AAAA,MACJ,MAAM;AAAA,MACN,KAAK;AAAA,MACL,GAAG;AAAA,IAAA,IACD,aAAa,MAAa,GAAG;AAEjC,UAAM,WACJ,OAAO,KAAK,aAAa,aACrB,KAAK,SAAS;AAAA,MACZ,UAAW,UAAkB,aAAa,MAAM;AAAA,IAAA,CACjD,IACD,KAAK;AAEP,QAAA,OAAO,aAAa,aAAa;AAGnC,aAAO,UAAU;AAAA,IAAA;AAGnB,WAAO,MAAM;AAAA,MACX,WAAW,WAAW;AAAA,MACtB;AAAA,QACE,GAAG;AAAA,QACH,KAAK;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAEJ;AAEA,SAAS,YAAY,GAAe;AAC3B,SAAA,CAAC,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE;AACpD;AAkBa,MAAA,cAAkC,CAAC,YAAY;AACnD,SAAA;AACT;"}
|
package/dist/esm/matchContext.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matchContext.js","sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\n// N.B. this only exists so we can conditionally call useContext on it when we are not interested in the nearest match\nexport const dummyMatchContext = React.createContext<string | undefined>(\n undefined,\n)\n"],"names":[],"mappings":";AAEa,MAAA,eAAe,MAAM,cAAkC,MAAS;AAGtE,MAAM,oBAAoB,MAAM;AAAA,EACrC;AACF;"}
|
package/dist/esm/not-found.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ErrorInfo } from 'react';
|
|
2
|
-
import { NotFoundError } from '@tanstack/router-core';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
export declare function CatchNotFound(props: {
|
|
5
|
-
fallback?: (error: NotFoundError) => React.ReactElement;
|
|
6
|
-
onCatch?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export declare function DefaultGlobalNotFound(): import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/not-found.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isNotFound } from "@tanstack/router-core";
|
|
3
|
-
import { CatchBoundary } from "./CatchBoundary.js";
|
|
4
|
-
import { useRouterState } from "./useRouterState.js";
|
|
5
|
-
function CatchNotFound(props) {
|
|
6
|
-
const resetKey = useRouterState({
|
|
7
|
-
select: (s) => `not-found-${s.location.pathname}-${s.status}`
|
|
8
|
-
});
|
|
9
|
-
return /* @__PURE__ */ jsx(
|
|
10
|
-
CatchBoundary,
|
|
11
|
-
{
|
|
12
|
-
getResetKey: () => resetKey,
|
|
13
|
-
onCatch: (error, errorInfo) => {
|
|
14
|
-
var _a;
|
|
15
|
-
if (isNotFound(error)) {
|
|
16
|
-
(_a = props.onCatch) == null ? void 0 : _a.call(props, error, errorInfo);
|
|
17
|
-
} else {
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
errorComponent: ({ error }) => {
|
|
22
|
-
var _a;
|
|
23
|
-
if (isNotFound(error)) {
|
|
24
|
-
return (_a = props.fallback) == null ? void 0 : _a.call(props, error);
|
|
25
|
-
} else {
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
children: props.children
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
function DefaultGlobalNotFound() {
|
|
34
|
-
return /* @__PURE__ */ jsx("p", { children: "Not Found" });
|
|
35
|
-
}
|
|
36
|
-
export {
|
|
37
|
-
CatchNotFound,
|
|
38
|
-
DefaultGlobalNotFound
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=not-found.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.js","sources":["../../src/not-found.tsx"],"sourcesContent":["import * as React from 'react'\nimport { isNotFound } from '@tanstack/router-core'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type { ErrorInfo } from 'react'\nimport type { NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => React.ReactElement\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n children: React.ReactNode\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey}\n onCatch={(error, errorInfo) => {\n if (isNotFound(error)) {\n props.onCatch?.(error, errorInfo)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }: { error: Error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"names":[],"mappings":";;;;AAOO,SAAS,cAAc,OAI3B;AAED,QAAM,WAAW,eAAe;AAAA,IAC9B,QAAQ,CAAC,MAAM,aAAa,EAAE,SAAS,QAAQ,IAAI,EAAE,MAAM;AAAA,EAAA,CAC5D;AAGC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,SAAS,CAAC,OAAO,cAAc;;AACzB,YAAA,WAAW,KAAK,GAAG;AACf,sBAAA,YAAA,+BAAU,OAAO;AAAA,QAAS,OAC3B;AACC,gBAAA;AAAA,QAAA;AAAA,MAEV;AAAA,MACA,gBAAgB,CAAC,EAAE,YAA8B;;AAC3C,YAAA,WAAW,KAAK,GAAG;AACd,kBAAA,WAAM,aAAN,+BAAiB;AAAA,QAAK,OACxB;AACC,gBAAA;AAAA,QAAA;AAAA,MAEV;AAAA,MAEC,UAAM,MAAA;AAAA,IAAA;AAAA,EACT;AAEJ;AAEO,SAAS,wBAAwB;AAC/B,SAAA,oBAAC,OAAE,UAAS,YAAA,CAAA;AACrB;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import warning from "tiny-warning";
|
|
3
|
-
import { DefaultGlobalNotFound } from "./not-found.js";
|
|
4
|
-
function renderRouteNotFound(router, route, data) {
|
|
5
|
-
if (!route.options.notFoundComponent) {
|
|
6
|
-
if (router.options.defaultNotFoundComponent) {
|
|
7
|
-
return /* @__PURE__ */ jsx(router.options.defaultNotFoundComponent, { data });
|
|
8
|
-
}
|
|
9
|
-
if (process.env.NODE_ENV === "development") {
|
|
10
|
-
warning(
|
|
11
|
-
route.options.notFoundComponent,
|
|
12
|
-
`A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
return /* @__PURE__ */ jsx(DefaultGlobalNotFound, {});
|
|
16
|
-
}
|
|
17
|
-
return /* @__PURE__ */ jsx(route.options.notFoundComponent, { data });
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
renderRouteNotFound
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=renderRouteNotFound.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouteNotFound.js","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\n\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent data={data} />\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`,\n )\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent data={data} />\n}\n"],"names":[],"mappings":";;;AAKgB,SAAA,oBACd,QACA,OACA,MACA;AACI,MAAA,CAAC,MAAM,QAAQ,mBAAmB;AAChC,QAAA,OAAO,QAAQ,0BAA0B;AAC3C,aAAQ,oBAAA,OAAO,QAAQ,0BAAf,EAAwC,KAAY,CAAA;AAAA,IAAA;AAG1D,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC1C;AAAA,QACE,MAAM,QAAQ;AAAA,QACd,yDAAyD,MAAM,EAAE;AAAA,MACnE;AAAA,IAAA;AAGF,+BAAQ,uBAAsB,EAAA;AAAA,EAAA;AAGhC,SAAQ,oBAAA,MAAM,QAAQ,mBAAd,EAAgC,KAAY,CAAA;AACtD;"}
|