@tanstack/react-router 0.0.1-beta.38 → 0.0.1-beta.39
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 -13
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/index.js +306 -241
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +296 -252
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +87 -56
- package/build/types/index.d.ts +50 -42
- package/build/umd/index.development.js +1368 -858
- 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 +3 -2
- package/src/index.tsx +468 -421
- package/src/uSES/useSyncExternalStore.ts +16 -0
- package/src/uSES/useSyncExternalStoreShim.ts +20 -0
- package/src/uSES/useSyncExternalStoreShimClient.ts +87 -0
- package/src/uSES/useSyncExternalStoreShimServer.ts +20 -0
package/build/types/index.d.ts
CHANGED
|
@@ -9,28 +9,31 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import {
|
|
12
|
+
import { RegisteredAllRouteInfo, LinkOptions, ToOptions, MatchRouteOptions, RouteInfoByPath, ResolveRelativePath, NoInfer, ValidFromPath, RegisteredRouter, AnyRouteConfig, RouteConfig, AnyAllRouteInfo, AllRouteInfo, RouterOptions, Router, DefaultAllRouteInfo, RouterStore, RouteMatch, Route, Expand, Action } from '@tanstack/router-core';
|
|
13
13
|
export * from '@tanstack/router-core';
|
|
14
|
+
export * from '@solidjs/reactivity';
|
|
14
15
|
|
|
15
|
-
type
|
|
16
|
+
type ReactNode = any;
|
|
17
|
+
type SyncRouteComponent<TProps = {}> = (props: TProps) => ReactNode;
|
|
16
18
|
type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {
|
|
17
|
-
preload?: () => Promise<
|
|
19
|
+
preload?: () => Promise<void>;
|
|
18
20
|
};
|
|
19
21
|
declare function lazy(importer: () => Promise<{
|
|
20
22
|
default: SyncRouteComponent;
|
|
21
23
|
}>): RouteComponent;
|
|
22
|
-
type LinkPropsOptions<
|
|
24
|
+
type LinkPropsOptions<TFrom extends RegisteredAllRouteInfo['routePaths'] = '/', TTo extends string = '.'> = LinkOptions<RegisteredAllRouteInfo, TFrom, TTo> & {
|
|
23
25
|
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
24
26
|
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
25
27
|
};
|
|
26
|
-
type
|
|
27
|
-
|
|
28
|
+
type MakeUseMatchRouteOptions<TFrom extends RegisteredAllRouteInfo['routePaths'] = '/', TTo extends string = '.'> = ToOptions<RegisteredAllRouteInfo, TFrom, TTo> & MatchRouteOptions;
|
|
29
|
+
type MakeMatchRouteOptions<TFrom extends RegisteredAllRouteInfo['routePaths'] = '/', TTo extends string = '.'> = ToOptions<RegisteredAllRouteInfo, TFrom, TTo> & MatchRouteOptions & {
|
|
30
|
+
children?: ReactNode | ((params: RouteInfoByPath<RegisteredAllRouteInfo, ResolveRelativePath<TFrom, NoInfer<TTo>>>['allParams']) => ReactNode);
|
|
28
31
|
};
|
|
29
|
-
type MakeLinkPropsOptions<
|
|
30
|
-
type MakeLinkOptions<
|
|
31
|
-
children?:
|
|
32
|
+
type MakeLinkPropsOptions<TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/', TTo extends string = '.'> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
33
|
+
type MakeLinkOptions<TFrom extends RegisteredAllRouteInfo['routePaths'] = '/', TTo extends string = '.'> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
34
|
+
children?: ReactNode | ((state: {
|
|
32
35
|
isActive: boolean;
|
|
33
|
-
}) =>
|
|
36
|
+
}) => ReactNode);
|
|
34
37
|
};
|
|
35
38
|
declare module '@tanstack/router-core' {
|
|
36
39
|
interface FrameworkGenerics {
|
|
@@ -44,31 +47,17 @@ declare module '@tanstack/router-core' {
|
|
|
44
47
|
}
|
|
45
48
|
interface RouterOptions<TRouteConfig, TRouterContext> {
|
|
46
49
|
}
|
|
47
|
-
interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> {
|
|
48
|
-
useState: () => RouterState;
|
|
49
|
-
useRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
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;
|
|
56
|
-
}
|
|
57
|
-
interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
|
|
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;
|
|
64
|
-
}
|
|
65
50
|
}
|
|
66
51
|
type PromptProps = {
|
|
67
52
|
message: string;
|
|
68
53
|
when?: boolean | any;
|
|
69
|
-
children?:
|
|
54
|
+
children?: ReactNode;
|
|
70
55
|
};
|
|
71
|
-
declare function
|
|
56
|
+
declare function useLinkProps<TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/', TTo extends string = '.'>(options: MakeLinkPropsOptions<TFrom, TTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
57
|
+
interface LinkFn<TDefaultFrom extends RegisteredAllRouteInfo['routePaths'] = '/', TDefaultTo extends string = '.'> {
|
|
58
|
+
<TFrom extends RegisteredAllRouteInfo['routePaths'] = TDefaultFrom, TTo extends string = TDefaultTo>(props: MakeLinkOptions<TFrom, TTo>): ReactNode;
|
|
59
|
+
}
|
|
60
|
+
declare const Link: LinkFn;
|
|
72
61
|
type MatchesContextValue = RouteMatch[];
|
|
73
62
|
declare const matchesContext: React.Context<MatchesContextValue>;
|
|
74
63
|
declare const routerContext: React.Context<{
|
|
@@ -76,30 +65,49 @@ declare const routerContext: React.Context<{
|
|
|
76
65
|
}>;
|
|
77
66
|
type MatchesProviderProps = {
|
|
78
67
|
value: MatchesContextValue;
|
|
79
|
-
children:
|
|
68
|
+
children: ReactNode;
|
|
80
69
|
};
|
|
81
|
-
declare
|
|
70
|
+
declare const __useStoreValue: <TSeed, TReturn>(seed: () => TSeed, selector?: ((seed: TSeed) => TReturn) | undefined) => TReturn;
|
|
82
71
|
declare function createReactRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(opts: RouterOptions<TRouteConfig, TRouterContext>): Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
83
72
|
type RouterProps<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouterContext = unknown> = RouterOptions<TRouteConfig, TRouterContext> & {
|
|
84
73
|
router: Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
85
74
|
};
|
|
86
75
|
declare function RouterProvider<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouterContext = unknown>({ router, ...rest }: RouterProps<TRouteConfig, TAllRouteInfo, TRouterContext>): JSX.Element;
|
|
87
76
|
declare function useRouter(): RegisteredRouter;
|
|
77
|
+
declare function useRouterStore<T = RouterStore>(selector?: (state: Router['store']) => T): T;
|
|
88
78
|
declare function useMatches(): RouteMatch[];
|
|
89
|
-
declare function useMatch<
|
|
79
|
+
declare function useMatch<TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'], TStrict extends boolean = true, TRouteMatch = RouteMatch<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TFrom]>>(opts?: {
|
|
80
|
+
from: TFrom;
|
|
81
|
+
strict?: TStrict;
|
|
82
|
+
}): TStrict extends true ? TRouteMatch : TRouteMatch | undefined;
|
|
83
|
+
declare function useRoute<TId extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/'>(routeId: TId): Route<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]>;
|
|
84
|
+
declare function useLoaderData<TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/', TStrict extends boolean = true, TLoaderData = RegisteredAllRouteInfo['routeInfoById'][TFrom]['loaderData'], TSelected = TLoaderData>(opts?: {
|
|
85
|
+
from: TFrom;
|
|
86
|
+
strict?: TStrict;
|
|
87
|
+
select?: (loaderData: TLoaderData) => TSelected;
|
|
88
|
+
}): TStrict extends true ? TSelected : TSelected | undefined;
|
|
89
|
+
declare function useSearch<TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'], TStrict extends boolean = true, TSearch = RegisteredAllRouteInfo['routeInfoById'][TFrom]['fullSearchSchema'], TSelected = TSearch>(opts?: {
|
|
90
|
+
from: TFrom;
|
|
90
91
|
strict?: TStrict;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
declare function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
declare function
|
|
92
|
+
select?: (search: TSearch) => TSelected;
|
|
93
|
+
}): TStrict extends true ? TSelected : TSelected | undefined;
|
|
94
|
+
declare function useParams<TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/', TDefaultSelected = Expand<RegisteredAllRouteInfo['allParams'] & RegisteredAllRouteInfo['routeInfoById'][TFrom]['allParams']>, TSelected = TDefaultSelected>(opts?: {
|
|
95
|
+
from: TFrom;
|
|
96
|
+
select?: (search: TDefaultSelected) => TSelected;
|
|
97
|
+
}): TSelected;
|
|
98
|
+
declare function useNavigate<TDefaultFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/'>(defaultOpts: {
|
|
99
|
+
from?: TDefaultFrom;
|
|
100
|
+
}): <TFrom extends string = TDefaultFrom, TTo extends string = ".">(opts: MakeLinkOptions<TFrom, TTo>) => Promise<void>;
|
|
101
|
+
declare function useAction<TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/', TFromRoute extends RegisteredAllRouteInfo['routeInfoById'][TFrom] = RegisteredAllRouteInfo['routeInfoById'][TFrom]>(opts: {
|
|
102
|
+
from: TFrom;
|
|
103
|
+
}): Action<TFromRoute['actionPayload'], TFromRoute['actionResponse']>;
|
|
104
|
+
declare function useMatchRoute(): <TFrom extends ValidFromPath<AnyAllRouteInfo> = "/", TTo extends string = ".">(opts: MakeUseMatchRouteOptions<TFrom, TTo>) => false;
|
|
105
|
+
declare function MatchRoute<TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/', TTo extends string = '.'>(props: MakeMatchRouteOptions<TFrom, TTo>): any;
|
|
98
106
|
declare function Outlet(): JSX.Element | null;
|
|
99
107
|
declare function DefaultErrorBoundary({ error }: {
|
|
100
108
|
error: any;
|
|
101
109
|
}): JSX.Element;
|
|
102
110
|
declare function usePrompt(message: string, when: boolean | any): void;
|
|
103
|
-
declare function Prompt({ message, when, children }: PromptProps):
|
|
111
|
+
declare function Prompt({ message, when, children }: PromptProps): any;
|
|
104
112
|
|
|
105
|
-
export { DefaultErrorBoundary, Link, LinkPropsOptions, MakeLinkOptions, MakeLinkPropsOptions, MakeMatchRouteOptions,
|
|
113
|
+
export { DefaultErrorBoundary, Link, LinkFn, LinkPropsOptions, MakeLinkOptions, MakeLinkPropsOptions, MakeMatchRouteOptions, MakeUseMatchRouteOptions, MatchRoute, MatchesProviderProps, Outlet, Prompt, PromptProps, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, __useStoreValue, createReactRouter, lazy, matchesContext, routerContext, useAction, useLinkProps, useLoaderData, useMatch, useMatchRoute, useMatches, useNavigate, useParams, usePrompt, useRoute, useRouter, useRouterStore, useSearch };
|