@tanstack/react-router 1.20.1 → 1.20.3-alpha.1
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/README.md +31 -0
- package/dist/cjs/Asset.cjs +41 -0
- package/dist/cjs/Asset.cjs.map +1 -0
- package/dist/cjs/Asset.d.cts +2 -0
- package/dist/cjs/CatchBoundary.cjs +16 -12
- package/dist/cjs/CatchBoundary.cjs.map +1 -1
- package/dist/cjs/CatchBoundary.d.cts +8 -32
- package/dist/cjs/ClientOnly.cjs +20 -0
- package/dist/cjs/ClientOnly.cjs.map +1 -0
- package/dist/cjs/ClientOnly.d.cts +29 -0
- package/dist/cjs/HeadContent.cjs +155 -0
- package/dist/cjs/HeadContent.cjs.map +1 -0
- package/dist/cjs/HeadContent.d.cts +7 -0
- package/dist/cjs/Match.cjs +252 -0
- package/dist/cjs/Match.cjs.map +1 -0
- package/dist/cjs/Match.d.cts +8 -0
- package/dist/cjs/Matches.cjs +39 -287
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +23 -83
- package/dist/cjs/RouterProvider.cjs +17 -140
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +8 -27
- package/dist/cjs/SafeFragment.cjs +8 -0
- package/dist/cjs/SafeFragment.cjs.map +1 -0
- package/dist/cjs/SafeFragment.d.cts +1 -0
- package/dist/cjs/ScriptOnce.cjs +28 -0
- package/dist/cjs/ScriptOnce.cjs.map +1 -0
- package/dist/cjs/ScriptOnce.d.cts +5 -0
- package/dist/cjs/Scripts.cjs +51 -0
- package/dist/cjs/Scripts.cjs.map +1 -0
- package/dist/cjs/Scripts.d.cts +1 -0
- package/dist/cjs/ScrollRestoration.cjs +39 -0
- package/dist/cjs/ScrollRestoration.cjs.map +1 -0
- package/dist/cjs/ScrollRestoration.d.cts +14 -0
- package/dist/cjs/Transitioner.cjs +115 -0
- package/dist/cjs/Transitioner.cjs.map +1 -0
- package/dist/cjs/Transitioner.d.cts +1 -0
- package/dist/cjs/awaited.cjs +12 -65
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/awaited.d.cts +4 -4
- package/dist/cjs/fileRoute.cjs +41 -15
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +33 -108
- package/dist/cjs/history.d.cts +1 -0
- package/dist/cjs/index.cjs +216 -73
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +52 -29
- package/dist/cjs/lazyRouteComponent.cjs +40 -29
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
- package/dist/cjs/lazyRouteComponent.d.cts +1 -1
- package/dist/cjs/link.cjs +212 -106
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +41 -86
- package/dist/cjs/matchContext.cjs +27 -0
- package/dist/cjs/matchContext.cjs.map +1 -0
- package/dist/cjs/matchContext.d.cts +3 -0
- package/dist/cjs/not-found.cjs +9 -15
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +5 -22
- package/dist/cjs/renderRouteNotFound.cjs +22 -0
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -0
- package/dist/cjs/renderRouteNotFound.d.cts +2 -0
- package/dist/cjs/route.cjs +110 -79
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +64 -361
- package/dist/cjs/router.cjs +12 -1237
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +69 -237
- package/dist/cjs/routerContext.cjs +1 -1
- package/dist/cjs/routerContext.cjs.map +1 -1
- package/dist/cjs/routerContext.d.cts +7 -2
- package/dist/cjs/scroll-restoration.cjs +16 -177
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.d.cts +1 -18
- package/dist/cjs/serializer.d.cts +6 -0
- package/dist/cjs/structuralSharing.d.cts +8 -0
- package/dist/cjs/typePrimitives.d.cts +16 -0
- package/dist/cjs/useBlocker.cjs +138 -9
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useBlocker.d.cts +64 -7
- 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/cjs/useLoaderData.cjs +15 -0
- package/dist/cjs/useLoaderData.cjs.map +1 -0
- package/dist/cjs/useLoaderData.d.cts +8 -0
- package/dist/cjs/useLoaderDeps.cjs +14 -0
- package/dist/cjs/useLoaderDeps.cjs.map +1 -0
- package/dist/cjs/useLoaderDeps.d.cts +8 -0
- package/dist/cjs/useLocation.cjs +10 -0
- package/dist/cjs/useLocation.cjs.map +1 -0
- package/dist/cjs/useLocation.d.cts +7 -0
- package/dist/cjs/useMatch.cjs +47 -0
- package/dist/cjs/useMatch.cjs.map +1 -0
- package/dist/cjs/useMatch.d.cts +10 -0
- package/dist/cjs/useNavigate.cjs +18 -19
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +4 -8
- package/dist/cjs/useParams.cjs +8 -8
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +9 -8
- package/dist/cjs/useRouteContext.cjs +3 -3
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouteContext.d.cts +3 -7
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouter.d.cts +3 -4
- package/dist/cjs/useRouterState.cjs +18 -1
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useRouterState.d.cts +8 -6
- package/dist/cjs/useSearch.cjs +7 -4
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +9 -7
- package/dist/cjs/utils.cjs +40 -122
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +46 -50
- package/dist/esm/Asset.d.ts +2 -0
- package/dist/esm/Asset.js +41 -0
- package/dist/esm/Asset.js.map +1 -0
- package/dist/esm/CatchBoundary.d.ts +8 -32
- package/dist/esm/CatchBoundary.js +16 -12
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.d.ts +29 -0
- package/dist/esm/ClientOnly.js +20 -0
- package/dist/esm/ClientOnly.js.map +1 -0
- package/dist/esm/HeadContent.d.ts +7 -0
- package/dist/esm/HeadContent.js +139 -0
- package/dist/esm/HeadContent.js.map +1 -0
- package/dist/esm/Match.d.ts +8 -0
- package/dist/esm/Match.js +235 -0
- package/dist/esm/Match.js.map +1 -0
- package/dist/esm/Matches.d.ts +23 -83
- package/dist/esm/Matches.js +36 -284
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +8 -27
- package/dist/esm/RouterProvider.js +20 -126
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/SafeFragment.d.ts +1 -0
- package/dist/esm/SafeFragment.js +8 -0
- package/dist/esm/SafeFragment.js.map +1 -0
- package/dist/esm/ScriptOnce.d.ts +5 -0
- package/dist/esm/ScriptOnce.js +28 -0
- package/dist/esm/ScriptOnce.js.map +1 -0
- package/dist/esm/Scripts.d.ts +1 -0
- package/dist/esm/Scripts.js +51 -0
- package/dist/esm/Scripts.js.map +1 -0
- package/dist/esm/ScrollRestoration.d.ts +14 -0
- package/dist/esm/ScrollRestoration.js +39 -0
- package/dist/esm/ScrollRestoration.js.map +1 -0
- package/dist/esm/Transitioner.d.ts +1 -0
- package/dist/esm/Transitioner.js +98 -0
- package/dist/esm/Transitioner.js.map +1 -0
- package/dist/esm/awaited.d.ts +4 -4
- package/dist/esm/awaited.js +12 -65
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +33 -108
- package/dist/esm/fileRoute.js +38 -12
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/history.d.ts +1 -0
- package/dist/esm/index.d.ts +52 -29
- package/dist/esm/index.js +41 -29
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lazyRouteComponent.d.ts +1 -1
- package/dist/esm/lazyRouteComponent.js +40 -29
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.d.ts +41 -86
- package/dist/esm/link.js +212 -106
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.d.ts +3 -0
- package/dist/esm/matchContext.js +10 -0
- package/dist/esm/matchContext.js.map +1 -0
- package/dist/esm/not-found.d.ts +5 -22
- package/dist/esm/not-found.js +9 -15
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.d.ts +2 -0
- package/dist/esm/renderRouteNotFound.js +22 -0
- package/dist/esm/renderRouteNotFound.js.map +1 -0
- package/dist/esm/route.d.ts +64 -361
- package/dist/esm/route.js +103 -72
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +69 -237
- package/dist/esm/router.js +13 -1238
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +7 -2
- package/dist/esm/routerContext.js +1 -1
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.d.ts +1 -18
- package/dist/esm/scroll-restoration.js +17 -161
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/serializer.d.ts +6 -0
- package/dist/esm/structuralSharing.d.ts +8 -0
- package/dist/esm/typePrimitives.d.ts +16 -0
- package/dist/esm/useBlocker.d.ts +64 -7
- package/dist/esm/useBlocker.js +138 -9
- package/dist/esm/useBlocker.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/dist/esm/useLoaderData.d.ts +8 -0
- package/dist/esm/useLoaderData.js +15 -0
- package/dist/esm/useLoaderData.js.map +1 -0
- package/dist/esm/useLoaderDeps.d.ts +8 -0
- package/dist/esm/useLoaderDeps.js +14 -0
- package/dist/esm/useLoaderDeps.js.map +1 -0
- package/dist/esm/useLocation.d.ts +7 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/dist/esm/useMatch.d.ts +10 -0
- package/dist/esm/useMatch.js +30 -0
- package/dist/esm/useMatch.js.map +1 -0
- package/dist/esm/useNavigate.d.ts +4 -8
- package/dist/esm/useNavigate.js +18 -19
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +9 -8
- package/dist/esm/useParams.js +8 -8
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.d.ts +3 -7
- package/dist/esm/useRouteContext.js +2 -2
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.d.ts +3 -4
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.d.ts +8 -6
- package/dist/esm/useRouterState.js +18 -1
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.d.ts +9 -7
- package/dist/esm/useSearch.js +6 -3
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +46 -50
- package/dist/esm/utils.js +41 -123
- package/dist/esm/utils.js.map +1 -1
- package/package.json +30 -31
- package/src/Asset.tsx +40 -0
- package/src/CatchBoundary.tsx +35 -19
- package/src/ClientOnly.tsx +68 -0
- package/src/HeadContent.tsx +174 -0
- package/src/Match.tsx +330 -0
- package/src/Matches.tsx +149 -558
- package/src/RouterProvider.tsx +58 -212
- package/src/SafeFragment.tsx +5 -0
- package/src/ScriptOnce.tsx +32 -0
- package/src/Scripts.tsx +65 -0
- package/src/ScrollRestoration.tsx +69 -0
- package/src/Transitioner.tsx +130 -0
- package/src/awaited.tsx +16 -87
- package/src/fileRoute.ts +145 -248
- package/src/history.ts +2 -1
- package/src/index.tsx +368 -30
- package/src/lazyRouteComponent.tsx +68 -54
- package/src/link.tsx +397 -522
- package/src/matchContext.tsx +8 -0
- package/src/not-found.tsx +13 -34
- package/src/renderRouteNotFound.tsx +27 -0
- package/src/route.tsx +572 -0
- package/src/router.ts +99 -2067
- package/src/routerContext.tsx +8 -2
- package/src/scroll-restoration.tsx +23 -224
- package/src/serializer.ts +7 -0
- package/src/structuralSharing.ts +47 -0
- package/src/typePrimitives.ts +84 -0
- package/src/useBlocker.tsx +297 -15
- package/src/useCanGoBack.ts +5 -0
- package/src/useLoaderData.tsx +80 -0
- package/src/useLoaderDeps.tsx +58 -0
- package/src/useLocation.tsx +41 -0
- package/src/useMatch.tsx +119 -0
- package/src/useNavigate.tsx +41 -61
- package/src/useParams.tsx +88 -23
- package/src/useRouteContext.ts +24 -18
- package/src/useRouter.tsx +4 -5
- package/src/useRouterState.tsx +52 -10
- package/src/useSearch.tsx +87 -24
- package/src/utils.ts +97 -312
- package/dist/cjs/createServerFn.cjs +0 -40
- package/dist/cjs/createServerFn.cjs.map +0 -1
- package/dist/cjs/createServerFn.d.cts +0 -44
- package/dist/cjs/defer.cjs +0 -30
- package/dist/cjs/defer.cjs.map +0 -1
- package/dist/cjs/defer.d.cts +0 -25
- package/dist/cjs/location.d.cts +0 -12
- package/dist/cjs/path.cjs +0 -213
- package/dist/cjs/path.cjs.map +0 -1
- package/dist/cjs/path.d.cts +0 -24
- package/dist/cjs/qss.cjs +0 -45
- package/dist/cjs/qss.cjs.map +0 -1
- package/dist/cjs/qss.d.cts +0 -2
- package/dist/cjs/redirects.cjs +0 -16
- package/dist/cjs/redirects.cjs.map +0 -1
- package/dist/cjs/redirects.d.cts +0 -18
- package/dist/cjs/routeInfo.d.cts +0 -31
- package/dist/cjs/searchParams.cjs +0 -63
- package/dist/cjs/searchParams.cjs.map +0 -1
- package/dist/cjs/searchParams.d.cts +0 -7
- package/dist/esm/createServerFn.d.ts +0 -44
- package/dist/esm/createServerFn.js +0 -40
- package/dist/esm/createServerFn.js.map +0 -1
- package/dist/esm/defer.d.ts +0 -25
- package/dist/esm/defer.js +0 -30
- package/dist/esm/defer.js.map +0 -1
- package/dist/esm/location.d.ts +0 -12
- package/dist/esm/path.d.ts +0 -24
- package/dist/esm/path.js +0 -213
- package/dist/esm/path.js.map +0 -1
- package/dist/esm/qss.d.ts +0 -2
- package/dist/esm/qss.js +0 -45
- package/dist/esm/qss.js.map +0 -1
- package/dist/esm/redirects.d.ts +0 -18
- package/dist/esm/redirects.js +0 -16
- package/dist/esm/redirects.js.map +0 -1
- package/dist/esm/routeInfo.d.ts +0 -31
- package/dist/esm/searchParams.d.ts +0 -7
- package/dist/esm/searchParams.js +0 -63
- package/dist/esm/searchParams.js.map +0 -1
- package/src/createServerFn.ts +0 -107
- package/src/defer.ts +0 -70
- package/src/location.ts +0 -13
- package/src/path.ts +0 -280
- package/src/qss.ts +0 -53
- package/src/redirects.ts +0 -56
- package/src/route.ts +0 -1356
- package/src/routeInfo.ts +0 -63
- package/src/searchParams.ts +0 -79
package/dist/cjs/link.d.cts
CHANGED
|
@@ -1,93 +1,48 @@
|
|
|
1
|
+
import { AnyRouter, Constrain, LinkOptions, RegisteredRouter, RoutePaths } from '@tanstack/router-core';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ValidateLinkOptions, ValidateLinkOptionsArray } from './typePrimitives.cjs';
|
|
1
4
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
[
|
|
12
|
-
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
replace?: boolean;
|
|
25
|
-
resetScroll?: boolean;
|
|
26
|
-
startTransition?: boolean;
|
|
27
|
-
};
|
|
28
|
-
export type ToOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ToSubOptions<TRouteTree, TFrom, TTo> & {
|
|
29
|
-
mask?: ToMaskOptions<TRouteTree, TMaskFrom, TMaskTo>;
|
|
30
|
-
};
|
|
31
|
-
export type ToMaskOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TMaskFrom extends RoutePaths<TRouteTree> | string = string, TMaskTo extends string = ''> = ToSubOptions<TRouteTree, TMaskFrom, TMaskTo> & {
|
|
32
|
-
unmaskOnReload?: boolean;
|
|
33
|
-
};
|
|
34
|
-
export type ToSubOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = ''> = {
|
|
35
|
-
to?: ToPathOption<TRouteTree, TFrom, TTo>;
|
|
36
|
-
hash?: true | Updater<string>;
|
|
37
|
-
state?: true | NonNullableUpdater<HistoryState>;
|
|
38
|
-
from?: RoutePathsAutoComplete<TRouteTree, TFrom>;
|
|
39
|
-
} & CheckPath<TRouteTree, {}, TFrom, TTo> & SearchParamOptions<TRouteTree, TFrom, TTo> & PathParamOptions<TRouteTree, TFrom, TTo>;
|
|
40
|
-
type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
|
|
41
|
-
type ParamVariant = 'PATH' | 'SEARCH';
|
|
42
|
-
type ExcludeRootSearchSchema<T, Excluded = Exclude<T, RootSearchSchema>> = [
|
|
43
|
-
Excluded
|
|
44
|
-
] extends [never] ? {} : Excluded;
|
|
45
|
-
export type ResolveRoute<TRouteTree extends AnyRoute, TFrom, TTo, TPath = RemoveTrailingSlashes<string extends TTo ? TFrom : ResolveRelativePath<TFrom, TTo>>> = RouteByPath<TRouteTree, `${TPath & string}/`> extends never ? RouteByPath<TRouteTree, TPath> : RouteByPath<TRouteTree, `${TPath & string}/`>;
|
|
46
|
-
type PostProcessParams<T, TParamVariant extends ParamVariant> = TParamVariant extends 'SEARCH' ? ExcludeRootSearchSchema<T> : T;
|
|
47
|
-
export type ParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string, TParamVariant extends ParamVariant, TFromRouteType extends 'allParams' | 'fullSearchSchema' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema', TToRouteType extends 'allParams' | 'fullSearchSchemaInput' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput', TFromParams = PostProcessParams<RouteByPath<TRouteTree, TFrom>['types'][TFromRouteType], TParamVariant>, TToParams = PostProcessParams<ResolveRoute<TRouteTree, TFrom, TTo>['types'][TToRouteType], TParamVariant>, TRelativeToParams = TParamVariant extends 'SEARCH' ? TToParams : true extends IsUnion<TFromParams> ? TToParams : MakeDifferenceOptional<TFromParams, TToParams>, TReducer = ParamsReducer<TFromParams, TRelativeToParams>> = Expand<WithoutEmpty<PickRequired<TRelativeToParams>>> extends never ? Partial<MakeParamOption<TParamVariant, true | TReducer>> : TFromParams extends Expand<WithoutEmpty<PickRequired<TRelativeToParams>>> ? MakeParamOption<TParamVariant, true | TReducer> : MakeParamOption<TParamVariant, TReducer>;
|
|
48
|
-
type MakeParamOption<TParamVariant extends ParamVariant, T> = TParamVariant extends 'PATH' ? MakePathParamOptions<T> : MakeSearchParamOptions<T>;
|
|
49
|
-
type MakeSearchParamOptions<T> = {
|
|
50
|
-
search: T;
|
|
51
|
-
};
|
|
52
|
-
type MakePathParamOptions<T> = {
|
|
53
|
-
params: T;
|
|
54
|
-
};
|
|
55
|
-
export type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string> = ParamOptions<TRouteTree, TFrom, TTo, 'SEARCH'>;
|
|
56
|
-
export type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string> = ParamOptions<TRouteTree, TFrom, TTo, 'PATH'>;
|
|
57
|
-
export type ToPathOption<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = ''> = TTo | RelativeToPathAutoComplete<TRouteTree, NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
|
|
58
|
-
export interface ActiveOptions {
|
|
59
|
-
exact?: boolean;
|
|
60
|
-
includeHash?: boolean;
|
|
61
|
-
includeSearch?: boolean;
|
|
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: infer TRef;
|
|
8
|
+
}> | React.Component<{
|
|
9
|
+
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>);
|
|
62
27
|
}
|
|
63
|
-
export type
|
|
64
|
-
|
|
65
|
-
activeOptions?: ActiveOptions;
|
|
66
|
-
preload?: false | 'intent';
|
|
67
|
-
preloadDelay?: number;
|
|
68
|
-
disabled?: boolean;
|
|
69
|
-
};
|
|
70
|
-
export type CheckPath<TRouteTree extends AnyRoute, TPass, TFrom, TTo> = ResolveRoute<TRouteTree, TFrom, TTo> extends never ? string extends TFrom ? RemoveTrailingSlashes<TTo> extends '.' | '..' ? TPass : CheckPathError<TRouteTree> : CheckPathError<TRouteTree> : TPass;
|
|
71
|
-
export type CheckPathError<TRouteTree extends AnyRoute> = {
|
|
72
|
-
to: RoutePaths<TRouteTree>;
|
|
73
|
-
};
|
|
74
|
-
export type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string ? TTo extends string ? TTo extends '.' ? TFrom : TTo extends `./` ? Join<[TFrom, '/']> : TTo extends `./${infer TRest}` ? ResolveRelativePath<TFrom, TRest> : TTo extends `/${infer TRest}` ? TTo : Split<TTo> extends ['..', ...infer ToRest] ? Split<TFrom> extends [...infer FromRest, infer FromTail] ? ToRest extends ['/'] ? Join<['/', ...FromRest, '/']> : ResolveRelativePath<Join<FromRest>, Join<ToRest>> : never : Split<TTo> extends ['.', ...infer ToRest] ? ToRest extends ['/'] ? Join<[TFrom, '/']> : ResolveRelativePath<TFrom, Join<ToRest>> : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>> : never : never;
|
|
75
|
-
export declare function useLinkProps<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''>(options: UseLinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
76
|
-
export type UseLinkPropsOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ActiveLinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
77
|
-
export type ActiveLinkOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = LinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
78
|
-
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
79
|
-
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
80
|
-
};
|
|
81
|
-
export type LinkProps<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ActiveLinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
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 {
|
|
82
30
|
children?: React.ReactNode | ((state: {
|
|
83
31
|
isActive: boolean;
|
|
32
|
+
isTransitioning: boolean;
|
|
84
33
|
}) => React.ReactNode);
|
|
85
|
-
}
|
|
86
|
-
type
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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>;
|
|
92
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'>;
|
|
93
48
|
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
function _interopNamespaceDefault(e) {
|
|
5
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
+
if (e) {
|
|
7
|
+
for (const k in e) {
|
|
8
|
+
if (k !== "default") {
|
|
9
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
10
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: () => e[k]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
n.default = e;
|
|
18
|
+
return Object.freeze(n);
|
|
19
|
+
}
|
|
20
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
21
|
+
const matchContext = React__namespace.createContext(void 0);
|
|
22
|
+
const dummyMatchContext = React__namespace.createContext(
|
|
23
|
+
void 0
|
|
24
|
+
);
|
|
25
|
+
exports.dummyMatchContext = dummyMatchContext;
|
|
26
|
+
exports.matchContext = matchContext;
|
|
27
|
+
//# sourceMappingURL=matchContext.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchContext.cjs","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":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEa,MAAA,eAAeA,iBAAM,cAAkC,MAAS;AAGtE,MAAM,oBAAoBA,iBAAM;AAAA,EACrC;AACF;;;"}
|
package/dist/cjs/not-found.cjs
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const routerCore = require("@tanstack/router-core");
|
|
4
5
|
const CatchBoundary = require("./CatchBoundary.cjs");
|
|
5
6
|
const useRouterState = require("./useRouterState.cjs");
|
|
6
|
-
function notFound(options = {}) {
|
|
7
|
-
options.isNotFound = true;
|
|
8
|
-
if (options.throw)
|
|
9
|
-
throw options;
|
|
10
|
-
return options;
|
|
11
|
-
}
|
|
12
|
-
function isNotFound(obj) {
|
|
13
|
-
return !!(obj == null ? void 0 : obj.isNotFound);
|
|
14
|
-
}
|
|
15
7
|
function CatchNotFound(props) {
|
|
16
8
|
const resetKey = useRouterState.useRouterState({
|
|
17
9
|
select: (s) => `not-found-${s.location.pathname}-${s.status}`
|
|
@@ -20,17 +12,21 @@ function CatchNotFound(props) {
|
|
|
20
12
|
CatchBoundary.CatchBoundary,
|
|
21
13
|
{
|
|
22
14
|
getResetKey: () => resetKey,
|
|
23
|
-
onCatch: (error) => {
|
|
15
|
+
onCatch: (error, errorInfo) => {
|
|
24
16
|
var _a;
|
|
25
|
-
if (isNotFound(error)) {
|
|
26
|
-
(_a = props.onCatch) == null ? void 0 : _a.call(props, error);
|
|
17
|
+
if (routerCore.isNotFound(error)) {
|
|
18
|
+
(_a = props.onCatch) == null ? void 0 : _a.call(props, error, errorInfo);
|
|
27
19
|
} else {
|
|
28
20
|
throw error;
|
|
29
21
|
}
|
|
30
22
|
},
|
|
31
23
|
errorComponent: ({ error }) => {
|
|
32
24
|
var _a;
|
|
33
|
-
|
|
25
|
+
if (routerCore.isNotFound(error)) {
|
|
26
|
+
return (_a = props.fallback) == null ? void 0 : _a.call(props, error);
|
|
27
|
+
} else {
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
34
30
|
},
|
|
35
31
|
children: props.children
|
|
36
32
|
}
|
|
@@ -41,6 +37,4 @@ function DefaultGlobalNotFound() {
|
|
|
41
37
|
}
|
|
42
38
|
exports.CatchNotFound = CatchNotFound;
|
|
43
39
|
exports.DefaultGlobalNotFound = DefaultGlobalNotFound;
|
|
44
|
-
exports.isNotFound = isNotFound;
|
|
45
|
-
exports.notFound = notFound;
|
|
46
40
|
//# sourceMappingURL=not-found.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import * as React from 'react'\nimport {
|
|
1
|
+
{"version":3,"file":"not-found.cjs","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":["useRouterState","jsx","CatchBoundary","isNotFound"],"mappings":";;;;;;AAOO,SAAS,cAAc,OAI3B;AAED,QAAM,WAAWA,eAAAA,eAAe;AAAA,IAC9B,QAAQ,CAAC,MAAM,aAAa,EAAE,SAAS,QAAQ,IAAI,EAAE,MAAM;AAAA,EAAA,CAC5D;AAGC,SAAAC,2BAAA;AAAA,IAACC,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,SAAS,CAAC,OAAO,cAAc;;AACzB,YAAAC,WAAAA,WAAW,KAAK,GAAG;AACf,sBAAA,YAAA,+BAAU,OAAO;AAAA,QAAS,OAC3B;AACC,gBAAA;AAAA,QAAA;AAAA,MAEV;AAAA,MACA,gBAAgB,CAAC,EAAE,YAA8B;;AAC3C,YAAAA,WAAAA,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,SAAAF,2BAAA,IAAC,OAAE,UAAS,YAAA,CAAA;AACrB;;;"}
|
package/dist/cjs/not-found.d.cts
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
|
+
import { ErrorInfo } from 'react';
|
|
2
|
+
import { NotFoundError } from '@tanstack/router-core';
|
|
1
3
|
import * as React from 'react';
|
|
2
|
-
import { RegisteredRouter } from './router.cjs';
|
|
3
|
-
import { RouteIds } from './routeInfo.cjs';
|
|
4
|
-
export type NotFoundError = {
|
|
5
|
-
/**
|
|
6
|
-
@deprecated
|
|
7
|
-
Use `routeId: rootRouteId` instead
|
|
8
|
-
*/
|
|
9
|
-
global?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
@private
|
|
12
|
-
Do not use this. It's used internally to indicate a path matching error
|
|
13
|
-
*/
|
|
14
|
-
_global?: boolean;
|
|
15
|
-
data?: any;
|
|
16
|
-
throw?: boolean;
|
|
17
|
-
routeId?: RouteIds<RegisteredRouter['routeTree']>;
|
|
18
|
-
};
|
|
19
|
-
export declare function notFound(options?: NotFoundError): NotFoundError;
|
|
20
|
-
export declare function isNotFound(obj: any): obj is NotFoundError;
|
|
21
4
|
export declare function CatchNotFound(props: {
|
|
22
5
|
fallback?: (error: NotFoundError) => React.ReactElement;
|
|
23
|
-
onCatch?: (error:
|
|
6
|
+
onCatch?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
24
7
|
children: React.ReactNode;
|
|
25
|
-
}):
|
|
26
|
-
export declare function DefaultGlobalNotFound():
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function DefaultGlobalNotFound(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const warning = require("tiny-warning");
|
|
5
|
+
const notFound = require("./not-found.cjs");
|
|
6
|
+
function renderRouteNotFound(router, route, data) {
|
|
7
|
+
if (!route.options.notFoundComponent) {
|
|
8
|
+
if (router.options.defaultNotFoundComponent) {
|
|
9
|
+
return /* @__PURE__ */ jsxRuntime.jsx(router.options.defaultNotFoundComponent, { data });
|
|
10
|
+
}
|
|
11
|
+
if (process.env.NODE_ENV === "development") {
|
|
12
|
+
warning(
|
|
13
|
+
route.options.notFoundComponent,
|
|
14
|
+
`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>)`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsx(notFound.DefaultGlobalNotFound, {});
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(route.options.notFoundComponent, { data });
|
|
20
|
+
}
|
|
21
|
+
exports.renderRouteNotFound = renderRouteNotFound;
|
|
22
|
+
//# sourceMappingURL=renderRouteNotFound.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderRouteNotFound.cjs","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":["jsx","DefaultGlobalNotFound"],"mappings":";;;;;AAKgB,SAAA,oBACd,QACA,OACA,MACA;AACI,MAAA,CAAC,MAAM,QAAQ,mBAAmB;AAChC,QAAA,OAAO,QAAQ,0BAA0B;AAC3C,aAAQA,2BAAAA,IAAA,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,0CAAQC,SAAsB,uBAAA,EAAA;AAAA,EAAA;AAGhC,SAAQD,2BAAAA,IAAA,MAAM,QAAQ,mBAAd,EAAgC,KAAY,CAAA;AACtD;;"}
|
package/dist/cjs/route.cjs
CHANGED
|
@@ -1,130 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const routerCore = require("@tanstack/router-core");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const useLoaderData = require("./useLoaderData.cjs");
|
|
7
|
+
const useLoaderDeps = require("./useLoaderDeps.cjs");
|
|
6
8
|
const useParams = require("./useParams.cjs");
|
|
7
9
|
const useSearch = require("./useSearch.cjs");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
+
const useNavigate = require("./useNavigate.cjs");
|
|
11
|
+
const useMatch = require("./useMatch.cjs");
|
|
12
|
+
const useRouter = require("./useRouter.cjs");
|
|
13
|
+
const link = require("./link.cjs");
|
|
10
14
|
function getRouteApi(id) {
|
|
11
15
|
return new RouteApi({ id });
|
|
12
16
|
}
|
|
13
|
-
class RouteApi {
|
|
17
|
+
class RouteApi extends routerCore.BaseRouteApi {
|
|
14
18
|
/**
|
|
15
19
|
* @deprecated Use the `getRouteApi` function instead.
|
|
16
20
|
*/
|
|
17
21
|
constructor({ id }) {
|
|
22
|
+
super({ id });
|
|
18
23
|
this.useMatch = (opts) => {
|
|
19
|
-
return
|
|
24
|
+
return useMatch.useMatch({
|
|
25
|
+
select: opts == null ? void 0 : opts.select,
|
|
26
|
+
from: this.id,
|
|
27
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
28
|
+
});
|
|
20
29
|
};
|
|
21
30
|
this.useRouteContext = (opts) => {
|
|
22
|
-
return
|
|
31
|
+
return useMatch.useMatch({
|
|
23
32
|
from: this.id,
|
|
24
33
|
select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
|
|
25
34
|
});
|
|
26
35
|
};
|
|
27
36
|
this.useSearch = (opts) => {
|
|
28
|
-
return useSearch.useSearch({
|
|
37
|
+
return useSearch.useSearch({
|
|
38
|
+
select: opts == null ? void 0 : opts.select,
|
|
39
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
40
|
+
from: this.id
|
|
41
|
+
});
|
|
29
42
|
};
|
|
30
43
|
this.useParams = (opts) => {
|
|
31
|
-
return useParams.useParams({
|
|
44
|
+
return useParams.useParams({
|
|
45
|
+
select: opts == null ? void 0 : opts.select,
|
|
46
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
47
|
+
from: this.id
|
|
48
|
+
});
|
|
32
49
|
};
|
|
33
50
|
this.useLoaderDeps = (opts) => {
|
|
34
|
-
return
|
|
51
|
+
return useLoaderDeps.useLoaderDeps({ ...opts, from: this.id, strict: false });
|
|
35
52
|
};
|
|
36
53
|
this.useLoaderData = (opts) => {
|
|
37
|
-
return
|
|
54
|
+
return useLoaderData.useLoaderData({ ...opts, from: this.id, strict: false });
|
|
55
|
+
};
|
|
56
|
+
this.useNavigate = () => {
|
|
57
|
+
const router = useRouter.useRouter();
|
|
58
|
+
return useNavigate.useNavigate({ from: router.routesById[this.id].fullPath });
|
|
38
59
|
};
|
|
39
60
|
this.notFound = (opts) => {
|
|
40
|
-
return
|
|
61
|
+
return routerCore.notFound({ routeId: this.id, ...opts });
|
|
41
62
|
};
|
|
42
|
-
this.
|
|
63
|
+
this.Link = React.forwardRef((props, ref) => {
|
|
64
|
+
const router = useRouter.useRouter();
|
|
65
|
+
const fullPath = router.routesById[this.id].fullPath;
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsx(link.Link, { ref, from: fullPath, ...props });
|
|
67
|
+
});
|
|
43
68
|
}
|
|
44
69
|
}
|
|
45
|
-
class Route {
|
|
70
|
+
class Route extends routerCore.BaseRoute {
|
|
46
71
|
/**
|
|
47
72
|
* @deprecated Use the `createRoute` function instead.
|
|
48
73
|
*/
|
|
49
74
|
constructor(options) {
|
|
50
|
-
|
|
51
|
-
var _a, _b;
|
|
52
|
-
this.originalIndex = opts.originalIndex;
|
|
53
|
-
const options2 = this.options;
|
|
54
|
-
const isRoot = !(options2 == null ? void 0 : options2.path) && !(options2 == null ? void 0 : options2.id);
|
|
55
|
-
this.parentRoute = (_b = (_a = this.options) == null ? void 0 : _a.getParentRoute) == null ? void 0 : _b.call(_a);
|
|
56
|
-
if (isRoot) {
|
|
57
|
-
this.path = rootRouteId;
|
|
58
|
-
} else {
|
|
59
|
-
invariant(
|
|
60
|
-
this.parentRoute,
|
|
61
|
-
`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
let path$1 = isRoot ? rootRouteId : options2.path;
|
|
65
|
-
if (path$1 && path$1 !== "/") {
|
|
66
|
-
path$1 = path.trimPathLeft(path$1);
|
|
67
|
-
}
|
|
68
|
-
const customId = (options2 == null ? void 0 : options2.id) || path$1;
|
|
69
|
-
let id = isRoot ? rootRouteId : path.joinPaths([
|
|
70
|
-
this.parentRoute.id === rootRouteId ? "" : this.parentRoute.id,
|
|
71
|
-
customId
|
|
72
|
-
]);
|
|
73
|
-
if (path$1 === rootRouteId) {
|
|
74
|
-
path$1 = "/";
|
|
75
|
-
}
|
|
76
|
-
if (id !== rootRouteId) {
|
|
77
|
-
id = path.joinPaths(["/", id]);
|
|
78
|
-
}
|
|
79
|
-
const fullPath = id === rootRouteId ? "/" : path.joinPaths([this.parentRoute.fullPath, path$1]);
|
|
80
|
-
this.path = path$1;
|
|
81
|
-
this.id = id;
|
|
82
|
-
this.fullPath = fullPath;
|
|
83
|
-
this.to = fullPath;
|
|
84
|
-
};
|
|
85
|
-
this.addChildren = (children) => {
|
|
86
|
-
this.children = children;
|
|
87
|
-
return this;
|
|
88
|
-
};
|
|
89
|
-
this.updateLoader = (options2) => {
|
|
90
|
-
Object.assign(this.options, options2);
|
|
91
|
-
return this;
|
|
92
|
-
};
|
|
93
|
-
this.update = (options2) => {
|
|
94
|
-
Object.assign(this.options, options2);
|
|
95
|
-
return this;
|
|
96
|
-
};
|
|
97
|
-
this.lazy = (lazyFn) => {
|
|
98
|
-
this.lazyFn = lazyFn;
|
|
99
|
-
return this;
|
|
100
|
-
};
|
|
75
|
+
super(options);
|
|
101
76
|
this.useMatch = (opts) => {
|
|
102
|
-
return
|
|
77
|
+
return useMatch.useMatch({
|
|
78
|
+
select: opts == null ? void 0 : opts.select,
|
|
79
|
+
from: this.id,
|
|
80
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
81
|
+
});
|
|
103
82
|
};
|
|
104
83
|
this.useRouteContext = (opts) => {
|
|
105
|
-
return
|
|
84
|
+
return useMatch.useMatch({
|
|
106
85
|
...opts,
|
|
107
86
|
from: this.id,
|
|
108
87
|
select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
|
|
109
88
|
});
|
|
110
89
|
};
|
|
111
90
|
this.useSearch = (opts) => {
|
|
112
|
-
return useSearch.useSearch({
|
|
91
|
+
return useSearch.useSearch({
|
|
92
|
+
select: opts == null ? void 0 : opts.select,
|
|
93
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
94
|
+
from: this.id
|
|
95
|
+
});
|
|
113
96
|
};
|
|
114
97
|
this.useParams = (opts) => {
|
|
115
|
-
return useParams.useParams({
|
|
98
|
+
return useParams.useParams({
|
|
99
|
+
select: opts == null ? void 0 : opts.select,
|
|
100
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
101
|
+
from: this.id
|
|
102
|
+
});
|
|
116
103
|
};
|
|
117
104
|
this.useLoaderDeps = (opts) => {
|
|
118
|
-
return
|
|
105
|
+
return useLoaderDeps.useLoaderDeps({ ...opts, from: this.id });
|
|
119
106
|
};
|
|
120
107
|
this.useLoaderData = (opts) => {
|
|
121
|
-
return
|
|
108
|
+
return useLoaderData.useLoaderData({ ...opts, from: this.id });
|
|
109
|
+
};
|
|
110
|
+
this.useNavigate = () => {
|
|
111
|
+
return useNavigate.useNavigate({ from: this.fullPath });
|
|
122
112
|
};
|
|
123
|
-
this.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
`Route cannot have both an 'id' and a 'path' option.`
|
|
113
|
+
this.Link = React.forwardRef(
|
|
114
|
+
(props, ref) => {
|
|
115
|
+
return /* @__PURE__ */ jsxRuntime.jsx(link.Link, { ref, from: this.fullPath, ...props });
|
|
116
|
+
}
|
|
128
117
|
);
|
|
129
118
|
this.$$typeof = Symbol.for("react.memo");
|
|
130
119
|
}
|
|
@@ -138,12 +127,55 @@ function createRootRouteWithContext() {
|
|
|
138
127
|
};
|
|
139
128
|
}
|
|
140
129
|
const rootRouteWithContext = createRootRouteWithContext;
|
|
141
|
-
class RootRoute extends
|
|
130
|
+
class RootRoute extends routerCore.BaseRootRoute {
|
|
142
131
|
/**
|
|
143
132
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
144
133
|
*/
|
|
145
134
|
constructor(options) {
|
|
146
135
|
super(options);
|
|
136
|
+
this.useMatch = (opts) => {
|
|
137
|
+
return useMatch.useMatch({
|
|
138
|
+
select: opts == null ? void 0 : opts.select,
|
|
139
|
+
from: this.id,
|
|
140
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
this.useRouteContext = (opts) => {
|
|
144
|
+
return useMatch.useMatch({
|
|
145
|
+
...opts,
|
|
146
|
+
from: this.id,
|
|
147
|
+
select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
this.useSearch = (opts) => {
|
|
151
|
+
return useSearch.useSearch({
|
|
152
|
+
select: opts == null ? void 0 : opts.select,
|
|
153
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
154
|
+
from: this.id
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
this.useParams = (opts) => {
|
|
158
|
+
return useParams.useParams({
|
|
159
|
+
select: opts == null ? void 0 : opts.select,
|
|
160
|
+
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
161
|
+
from: this.id
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
this.useLoaderDeps = (opts) => {
|
|
165
|
+
return useLoaderDeps.useLoaderDeps({ ...opts, from: this.id });
|
|
166
|
+
};
|
|
167
|
+
this.useLoaderData = (opts) => {
|
|
168
|
+
return useLoaderData.useLoaderData({ ...opts, from: this.id });
|
|
169
|
+
};
|
|
170
|
+
this.useNavigate = () => {
|
|
171
|
+
return useNavigate.useNavigate({ from: this.fullPath });
|
|
172
|
+
};
|
|
173
|
+
this.Link = React.forwardRef(
|
|
174
|
+
(props, ref) => {
|
|
175
|
+
return /* @__PURE__ */ jsxRuntime.jsx(link.Link, { ref, from: this.fullPath, ...props });
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
this.$$typeof = Symbol.for("react.memo");
|
|
147
179
|
}
|
|
148
180
|
}
|
|
149
181
|
function createRootRoute(options) {
|
|
@@ -169,6 +201,5 @@ exports.createRootRouteWithContext = createRootRouteWithContext;
|
|
|
169
201
|
exports.createRoute = createRoute;
|
|
170
202
|
exports.createRouteMask = createRouteMask;
|
|
171
203
|
exports.getRouteApi = getRouteApi;
|
|
172
|
-
exports.rootRouteId = rootRouteId;
|
|
173
204
|
exports.rootRouteWithContext = rootRouteWithContext;
|
|
174
205
|
//# sourceMappingURL=route.cjs.map
|