@tanstack/react-router 0.0.1-beta.3 → 0.0.1-beta.31
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/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -5
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/index.js +448 -0
- package/build/cjs/index.js.map +1 -0
- package/build/esm/index.js +204 -2660
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +115 -33
- package/build/types/index.d.ts +66 -36
- package/build/umd/index.development.js +585 -691
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +4 -3
- package/src/index.tsx +357 -211
- package/build/cjs/react-router/src/index.js +0 -465
- package/build/cjs/react-router/src/index.js.map +0 -1
- package/build/cjs/router-core/build/esm/index.js +0 -2493
- package/build/cjs/router-core/build/esm/index.js.map +0 -1
package/build/types/index.d.ts
CHANGED
|
@@ -9,61 +9,91 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import { AnyRouteConfig, RouteConfig, AnyAllRouteInfo, AllRouteInfo, RouterState, RouteMatch,
|
|
12
|
+
import { AnyRouteConfig, RouteConfig, AnyAllRouteInfo, AllRouteInfo, RouterState, RouteMatch, DefaultAllRouteInfo, AnyRouteInfo, RouteInfo, ResolveRelativePath, NoInfer, CheckId, ToIdOption, ValidFromPath, ToOptions, MatchRouteOptions, RouteInfoByPath, RegisteredAllRouteInfo, RegisteredRouter, RouterOptions, Router, Route, LinkOptions } from '@tanstack/router-core';
|
|
13
13
|
export * from '@tanstack/router-core';
|
|
14
14
|
|
|
15
|
+
type SyncRouteComponent<TProps = {}> = (props: TProps) => JSX.Element | React.ReactNode;
|
|
16
|
+
type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {
|
|
17
|
+
preload?: () => Promise<SyncRouteComponent<TProps>>;
|
|
18
|
+
};
|
|
19
|
+
declare function lazy(importer: () => Promise<{
|
|
20
|
+
default: SyncRouteComponent;
|
|
21
|
+
}>): RouteComponent;
|
|
22
|
+
type LinkPropsOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo>, TTo extends string> = LinkOptions<TAllRouteInfo, TFrom, TTo> & {
|
|
23
|
+
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
24
|
+
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
25
|
+
};
|
|
26
|
+
type MakeMatchRouteOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo>, TTo extends string> = ToOptions<TAllRouteInfo, TFrom, TTo> & MatchRouteOptions & {
|
|
27
|
+
children?: React.ReactNode | ((params: RouteInfoByPath<TAllRouteInfo, ResolveRelativePath<TFrom, NoInfer<TTo>>>['allParams']) => React.ReactNode);
|
|
28
|
+
};
|
|
29
|
+
type MakeLinkPropsOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo>, TTo extends string> = LinkPropsOptions<TAllRouteInfo, TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
30
|
+
type MakeLinkOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo>, TTo extends string> = LinkPropsOptions<TAllRouteInfo, TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
31
|
+
children?: React.ReactNode | ((state: {
|
|
32
|
+
isActive: boolean;
|
|
33
|
+
}) => React.ReactNode);
|
|
34
|
+
};
|
|
15
35
|
declare module '@tanstack/router-core' {
|
|
16
36
|
interface FrameworkGenerics {
|
|
17
|
-
|
|
18
|
-
|
|
37
|
+
Component: RouteComponent;
|
|
38
|
+
ErrorComponent: RouteComponent<{
|
|
39
|
+
error: unknown;
|
|
40
|
+
info: {
|
|
41
|
+
componentStack: string;
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
interface RouterOptions<TRouteConfig, TRouterContext> {
|
|
19
46
|
}
|
|
20
47
|
interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> {
|
|
21
48
|
useState: () => RouterState;
|
|
22
49
|
useRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
23
|
-
useMatch: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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;
|
|
50
|
+
useMatch: <TId extends keyof TAllRouteInfo['routeInfoById'], TStrict extends boolean = true>(routeId: TId, opts?: {
|
|
51
|
+
strict?: TStrict;
|
|
52
|
+
}) => TStrict extends true ? RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]> : RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]> | undefined;
|
|
53
|
+
linkProps: <TTo extends string = '.'>(props: MakeLinkPropsOptions<TAllRouteInfo, '/', TTo>) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
54
|
+
Link: <TTo extends string = '.'>(props: MakeLinkOptions<TAllRouteInfo, '/', TTo>) => JSX.Element;
|
|
55
|
+
MatchRoute: <TTo extends string = '.'>(props: MakeMatchRouteOptions<TAllRouteInfo, '/', TTo>) => JSX.Element;
|
|
33
56
|
}
|
|
34
57
|
interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
|
|
35
|
-
useRoute: <TTo extends string = '.', TResolved extends string = ResolveRelativePath<TRouteInfo['id'], NoInfer<TTo>>>(routeId: CheckId<TAllRouteInfo, TResolved, ToIdOption<TAllRouteInfo, TRouteInfo['id'], TTo
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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;
|
|
58
|
+
useRoute: <TTo extends string = '.', TResolved extends string = ResolveRelativePath<TRouteInfo['id'], NoInfer<TTo>>>(routeId: CheckId<TAllRouteInfo, TResolved, ToIdOption<TAllRouteInfo, TRouteInfo['id'], TTo>>, opts?: {
|
|
59
|
+
strict?: boolean;
|
|
60
|
+
}) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TResolved]>;
|
|
61
|
+
linkProps: <TTo extends string = '.'>(props: MakeLinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
62
|
+
Link: <TTo extends string = '.'>(props: MakeLinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>) => JSX.Element;
|
|
63
|
+
MatchRoute: <TTo extends string = '.'>(props: MakeMatchRouteOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>) => JSX.Element;
|
|
45
64
|
}
|
|
46
65
|
}
|
|
47
|
-
|
|
48
|
-
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
49
|
-
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
50
|
-
};
|
|
51
|
-
declare type PromptProps = {
|
|
66
|
+
type PromptProps = {
|
|
52
67
|
message: string;
|
|
53
68
|
when?: boolean | any;
|
|
54
69
|
children?: React.ReactNode;
|
|
55
70
|
};
|
|
56
|
-
declare
|
|
57
|
-
|
|
71
|
+
declare function Link<TTo extends string = '.'>(props: MakeLinkOptions<RegisteredAllRouteInfo, '/', TTo>): JSX.Element;
|
|
72
|
+
type MatchesContextValue = RouteMatch[];
|
|
73
|
+
declare const matchesContext: React.Context<MatchesContextValue>;
|
|
74
|
+
declare const routerContext: React.Context<{
|
|
75
|
+
router: RegisteredRouter;
|
|
76
|
+
}>;
|
|
77
|
+
type MatchesProviderProps = {
|
|
78
|
+
value: MatchesContextValue;
|
|
58
79
|
children: React.ReactNode;
|
|
59
80
|
};
|
|
60
81
|
declare function MatchesProvider(props: MatchesProviderProps): JSX.Element;
|
|
61
|
-
declare function createReactRouter<TRouteConfig extends AnyRouteConfig = RouteConfig>(opts: RouterOptions<TRouteConfig>): Router<TRouteConfig>;
|
|
62
|
-
|
|
63
|
-
router: Router<TRouteConfig, TAllRouteInfo>;
|
|
64
|
-
children?: React.ReactNode;
|
|
82
|
+
declare function createReactRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(opts: RouterOptions<TRouteConfig, TRouterContext>): Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
83
|
+
type RouterProps<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouterContext = unknown> = RouterOptions<TRouteConfig, TRouterContext> & {
|
|
84
|
+
router: Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
65
85
|
};
|
|
66
|
-
declare function RouterProvider<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo>({
|
|
86
|
+
declare function RouterProvider<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouterContext = unknown>({ router, ...rest }: RouterProps<TRouteConfig, TAllRouteInfo, TRouterContext>): JSX.Element;
|
|
87
|
+
declare function useRouter(): RegisteredRouter;
|
|
88
|
+
declare function useMatches(): RouteMatch[];
|
|
89
|
+
declare function useMatch<TId extends keyof RegisteredAllRouteInfo['routeInfoById'], TStrict extends boolean = true>(routeId: TId, opts?: {
|
|
90
|
+
strict?: TStrict;
|
|
91
|
+
}): TStrict extends true ? RouteMatch<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]> : RouteMatch<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]> | undefined;
|
|
92
|
+
declare function useNearestMatch(): RouteMatch<RegisteredAllRouteInfo, RouteInfo>;
|
|
93
|
+
declare function useRoute<TId extends keyof RegisteredAllRouteInfo['routeInfoById']>(routeId: TId): Route<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]>;
|
|
94
|
+
declare function useSearch<TId extends keyof RegisteredAllRouteInfo['routeInfoById'] = keyof RegisteredAllRouteInfo['routeInfoById']>(_routeId?: TId): RegisteredAllRouteInfo['fullSearchSchema'];
|
|
95
|
+
declare function linkProps<TTo extends string = '.'>(props: MakeLinkPropsOptions<RegisteredAllRouteInfo, '/', TTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
96
|
+
declare function MatchRoute<TTo extends string = '.'>(props: MakeMatchRouteOptions<RegisteredAllRouteInfo, '/', TTo>): JSX.Element;
|
|
67
97
|
declare function Outlet(): JSX.Element | null;
|
|
68
98
|
declare function DefaultErrorBoundary({ error }: {
|
|
69
99
|
error: any;
|
|
@@ -71,4 +101,4 @@ declare function DefaultErrorBoundary({ error }: {
|
|
|
71
101
|
declare function usePrompt(message: string, when: boolean | any): void;
|
|
72
102
|
declare function Prompt({ message, when, children }: PromptProps): React.ReactNode;
|
|
73
103
|
|
|
74
|
-
export { DefaultErrorBoundary, MatchesProvider, MatchesProviderProps, Outlet, Prompt, PromptProps, RouterProps, RouterProvider, createReactRouter, usePrompt };
|
|
104
|
+
export { DefaultErrorBoundary, Link, MatchRoute, MatchesProvider, MatchesProviderProps, Outlet, Prompt, PromptProps, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, createReactRouter, lazy, linkProps, matchesContext, routerContext, useMatch, useMatches, useNearestMatch, usePrompt, useRoute, useRouter, useSearch };
|