@tanstack/react-router 0.0.1-beta.7 → 0.0.1-beta.71
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/LICENSE +21 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -18
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/index.js +465 -0
- package/build/cjs/index.js.map +1 -0
- package/build/esm/index.js +350 -2828
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +142 -35
- package/build/types/index.d.ts +84 -48
- package/build/umd/index.development.js +1895 -2683
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +23 -3
- package/build/umd/index.production.js.map +1 -1
- package/package.json +6 -6
- package/src/index.tsx +617 -487
- package/build/cjs/react-router/src/index.js +0 -459
- package/build/cjs/react-router/src/index.js.map +0 -1
- package/build/cjs/router-core/build/esm/index.js +0 -2524
- package/build/cjs/router-core/build/esm/index.js.map +0 -1
package/build/types/index.d.ts
CHANGED
|
@@ -9,66 +9,102 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import {
|
|
13
|
-
export * from '@tanstack/router
|
|
12
|
+
import { RegisteredRoutesInfo, LinkOptions, ToOptions, MatchRouteOptions, RouteByPath, ResolveRelativePath, NoInfer, ValidFromPath, NavigateOptions, RegisteredRouter, AnyRootRoute, RootRoute, AnyRoutesInfo, RoutesInfo, Router, RouterConstructorOptions, DefaultRoutesInfo, RouterOptions, RouterStore, RouteMatch, AnyRouteMatch } from '@tanstack/router';
|
|
13
|
+
export * from '@tanstack/router';
|
|
14
|
+
export { useStore } from '@tanstack/react-store';
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
type ReactNode = any;
|
|
17
|
+
type SyncRouteComponent<TProps = {}> = (props: TProps) => ReactNode;
|
|
18
|
+
type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {
|
|
19
|
+
preload?: () => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
declare function lazy(importer: () => Promise<{
|
|
22
|
+
default: SyncRouteComponent;
|
|
23
|
+
}>): RouteComponent;
|
|
24
|
+
type LinkPropsOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = LinkOptions<RegisteredRoutesInfo, TFrom, TTo> & {
|
|
25
|
+
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
26
|
+
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
27
|
+
};
|
|
28
|
+
type MakeUseMatchRouteOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions;
|
|
29
|
+
type MakeMatchRouteOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions & {
|
|
30
|
+
children?: ReactNode | ((params: RouteByPath<RegisteredRoutesInfo, ResolveRelativePath<TFrom, NoInfer<TTo>>>['__types']['allParams']) => ReactNode);
|
|
31
|
+
};
|
|
32
|
+
type MakeLinkPropsOptions<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
33
|
+
type MakeLinkOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
34
|
+
children?: ReactNode | ((state: {
|
|
35
|
+
isActive: boolean;
|
|
36
|
+
}) => ReactNode);
|
|
37
|
+
};
|
|
38
|
+
declare module '@tanstack/router' {
|
|
16
39
|
interface FrameworkGenerics {
|
|
17
|
-
|
|
18
|
-
|
|
40
|
+
Component: RouteComponent;
|
|
41
|
+
ErrorComponent: RouteComponent<{
|
|
42
|
+
error: Error;
|
|
43
|
+
info: {
|
|
44
|
+
componentStack: string;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
19
47
|
}
|
|
20
|
-
interface
|
|
21
|
-
useState: () => RouterState;
|
|
22
|
-
useRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
23
|
-
useMatch: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId) => RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
24
|
-
linkProps: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, '/', TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
25
|
-
Link: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, '/', TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
26
|
-
children?: React.ReactNode | ((state: {
|
|
27
|
-
isActive: boolean;
|
|
28
|
-
}) => React.ReactNode);
|
|
29
|
-
}) => JSX.Element;
|
|
30
|
-
MatchRoute: <TTo extends string = '.'>(props: ToOptions<TAllRouteInfo, '/', TTo> & MatchRouteOptions & {
|
|
31
|
-
children?: React.ReactNode | ((params: RouteInfoByPath<TAllRouteInfo, ResolveRelativePath<'/', NoInfer<TTo>>>['allParams']) => React.ReactNode);
|
|
32
|
-
}) => JSX.Element;
|
|
48
|
+
interface RouterOptions<TRouteTree> {
|
|
33
49
|
}
|
|
34
|
-
interface
|
|
35
|
-
|
|
36
|
-
linkProps: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
37
|
-
Link: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
38
|
-
children?: React.ReactNode | ((state: {
|
|
39
|
-
isActive: boolean;
|
|
40
|
-
}) => React.ReactNode);
|
|
41
|
-
}) => JSX.Element;
|
|
42
|
-
MatchRoute: <TTo extends string = '.'>(props: ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> & MatchRouteOptions & {
|
|
43
|
-
children?: React.ReactNode | ((params: RouteInfoByPath<TAllRouteInfo, ResolveRelativePath<TRouteInfo['fullPath'], NoInfer<TTo>>>['allParams']) => React.ReactNode);
|
|
44
|
-
}) => JSX.Element;
|
|
50
|
+
interface FrameworkRouteOptions {
|
|
51
|
+
wrapInSuspense?: boolean;
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
49
|
-
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
50
|
-
};
|
|
51
|
-
declare type PromptProps = {
|
|
54
|
+
type PromptProps = {
|
|
52
55
|
message: string;
|
|
53
56
|
when?: boolean | any;
|
|
54
|
-
children?:
|
|
57
|
+
children?: ReactNode;
|
|
55
58
|
};
|
|
56
|
-
declare
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
declare function useLinkProps<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''>(options: MakeLinkPropsOptions<TFrom, TTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
60
|
+
interface LinkFn<TDefaultFrom extends RegisteredRoutesInfo['routePaths'] = '/', TDefaultTo extends string = ''> {
|
|
61
|
+
<TFrom extends RegisteredRoutesInfo['routePaths'] = TDefaultFrom, TTo extends string = TDefaultTo>(props: MakeLinkOptions<TFrom, TTo> & React.RefAttributes<HTMLAnchorElement>): ReactNode;
|
|
62
|
+
}
|
|
63
|
+
declare const Link: LinkFn;
|
|
64
|
+
declare function Navigate<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''>(props: NavigateOptions<RegisteredRoutesInfo, TFrom, TTo>): null;
|
|
65
|
+
type MatchesContextValue = AnyRouteMatch[];
|
|
66
|
+
declare const matchesContext: React.Context<MatchesContextValue>;
|
|
67
|
+
declare const routerContext: React.Context<{
|
|
68
|
+
router: RegisteredRouter;
|
|
69
|
+
}>;
|
|
70
|
+
type MatchesProviderProps = {
|
|
71
|
+
value: MatchesContextValue;
|
|
72
|
+
children: ReactNode;
|
|
59
73
|
};
|
|
60
|
-
declare
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
declare class ReactRouter<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteConfig>> extends Router<TRouteConfig, TRoutesInfo> {
|
|
75
|
+
constructor(opts: RouterConstructorOptions<TRouteConfig>);
|
|
76
|
+
}
|
|
77
|
+
type RouterProps<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo> = RouterOptions<TRouteConfig> & {
|
|
78
|
+
router: Router<TRouteConfig, TRoutesInfo>;
|
|
65
79
|
};
|
|
66
|
-
declare function RouterProvider<TRouteConfig extends
|
|
80
|
+
declare function RouterProvider<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo>): JSX.Element;
|
|
81
|
+
declare function useRouterContext(): RegisteredRouter;
|
|
82
|
+
declare function useRouter<T = RouterStore>(track?: (state: Router['store']) => T, shallow?: boolean): RegisteredRouter;
|
|
83
|
+
declare function useMatches(): RouteMatch[];
|
|
84
|
+
declare function useMatch<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TRouteMatch = RouteMatch<RegisteredRoutesInfo, RegisteredRoutesInfo['routesById'][TFrom]>>(opts?: {
|
|
85
|
+
from: TFrom;
|
|
86
|
+
strict?: TStrict;
|
|
87
|
+
track?: (match: TRouteMatch) => any;
|
|
88
|
+
shallow?: boolean;
|
|
89
|
+
}): TStrict extends true ? TRouteMatch : TRouteMatch | undefined;
|
|
90
|
+
declare function useRoute<TId extends keyof RegisteredRoutesInfo['routesById'] = '/'>(routeId: TId): RegisteredRoutesInfo['routesById'][TId];
|
|
91
|
+
declare function useSearch<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TSearch = RegisteredRoutesInfo['routesById'][TFrom]['__types']['fullSearchSchema'], TSelected = TSearch>(opts?: {
|
|
92
|
+
from: TFrom;
|
|
93
|
+
strict?: TStrict;
|
|
94
|
+
track?: (search: TSearch) => TSelected;
|
|
95
|
+
}): TStrict extends true ? TSelected : TSelected | undefined;
|
|
96
|
+
declare function useParams<TFrom extends keyof RegisteredRoutesInfo['routesById'] = '/', TDefaultSelected = RegisteredRoutesInfo['allParams'] & RegisteredRoutesInfo['routesById'][TFrom]['__types']['allParams'], TSelected = TDefaultSelected>(opts?: {
|
|
97
|
+
from: TFrom;
|
|
98
|
+
track?: (search: TDefaultSelected) => TSelected;
|
|
99
|
+
}): TSelected;
|
|
100
|
+
declare function useNavigate<TDefaultFrom extends keyof RegisteredRoutesInfo['routesById'] = '/'>(defaultOpts?: {
|
|
101
|
+
from?: TDefaultFrom;
|
|
102
|
+
}): <TFrom extends string = TDefaultFrom, TTo extends string = "">(opts?: MakeLinkOptions<TFrom, TTo> | undefined) => Promise<void>;
|
|
103
|
+
declare function useMatchRoute(): <TFrom extends ValidFromPath<AnyRoutesInfo> = "/", TTo extends string = "">(opts: MakeUseMatchRouteOptions<TFrom, TTo>) => false | {};
|
|
104
|
+
declare function MatchRoute<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''>(props: MakeMatchRouteOptions<TFrom, TTo>): any;
|
|
67
105
|
declare function Outlet(): JSX.Element | null;
|
|
68
|
-
declare function
|
|
106
|
+
declare function ErrorComponent({ error }: {
|
|
69
107
|
error: any;
|
|
70
108
|
}): JSX.Element;
|
|
71
|
-
declare function usePrompt(message: string, when: boolean | any): void;
|
|
72
|
-
declare function Prompt({ message, when, children }: PromptProps): React.ReactNode;
|
|
73
109
|
|
|
74
|
-
export {
|
|
110
|
+
export { ErrorComponent, Link, LinkFn, LinkPropsOptions, MakeLinkOptions, MakeLinkPropsOptions, MakeMatchRouteOptions, MakeUseMatchRouteOptions, MatchRoute, MatchesProviderProps, Navigate, Outlet, PromptProps, ReactRouter, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, lazy, matchesContext, routerContext, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterContext, useSearch };
|