@tanstack/react-router 0.0.1-alpha.1 → 0.0.1-alpha.3
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/react-router/src/index.js +105 -100
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/esm/index.js +105 -100
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +129 -0
- package/build/types/index.d.ts +77 -0
- package/build/umd/index.development.js +105 -100
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +3 -3
- package/src/index.tsx +174 -166
package/build/stats-html.html
CHANGED
|
@@ -4014,7 +4014,7 @@ var drawChart = (function (exports) {
|
|
|
4014
4014
|
</script>
|
|
4015
4015
|
<script>
|
|
4016
4016
|
/*<!--*/
|
|
4017
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"
|
|
4017
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"b6e9-21","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"router-core/build/esm/index.js","uid":"b6e9-23"},{"name":"react-router/src/index.tsx","uid":"b6e9-25"}]}]}],"isRoot":true},"nodeParts":{"b6e9-21":{"renderedLength":798,"gzipLength":366,"brotliLength":0,"mainUid":"b6e9-20"},"b6e9-23":{"renderedLength":68622,"gzipLength":14235,"brotliLength":0,"mainUid":"b6e9-22"},"b6e9-25":{"renderedLength":11932,"gzipLength":3067,"brotliLength":0,"mainUid":"b6e9-24"}},"nodeMetas":{"b6e9-20":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"b6e9-21"},"imported":[],"importedBy":[{"uid":"b6e9-24"}]},"b6e9-22":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"b6e9-23"},"imported":[],"importedBy":[{"uid":"b6e9-24"}]},"b6e9-24":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"b6e9-25"},"imported":[{"uid":"b6e9-20"},{"uid":"b6e9-26"},{"uid":"b6e9-27"},{"uid":"b6e9-22"}],"importedBy":[],"isEntry":true},"b6e9-26":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"b6e9-24"}],"isExternal":true},"b6e9-27":{"id":"use-sync-external-store/shim","moduleParts":{},"imported":[],"importedBy":[{"uid":"b6e9-24"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
4018
4018
|
|
|
4019
4019
|
const run = () => {
|
|
4020
4020
|
const width = window.innerWidth;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"tree": {
|
|
4
|
+
"name": "root",
|
|
5
|
+
"children": [
|
|
6
|
+
{
|
|
7
|
+
"name": "index.production.js",
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"uid": "b6e9-29",
|
|
11
|
+
"name": "\u0000rollupPluginBabelHelpers.js"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "packages",
|
|
15
|
+
"children": [
|
|
16
|
+
{
|
|
17
|
+
"name": "router-core/build/esm/index.js",
|
|
18
|
+
"uid": "b6e9-31"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "react-router/src/index.tsx",
|
|
22
|
+
"uid": "b6e9-33"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"isRoot": true
|
|
30
|
+
},
|
|
31
|
+
"nodeParts": {
|
|
32
|
+
"b6e9-29": {
|
|
33
|
+
"renderedLength": 798,
|
|
34
|
+
"gzipLength": 366,
|
|
35
|
+
"brotliLength": 0,
|
|
36
|
+
"mainUid": "b6e9-28"
|
|
37
|
+
},
|
|
38
|
+
"b6e9-31": {
|
|
39
|
+
"renderedLength": 68622,
|
|
40
|
+
"gzipLength": 14235,
|
|
41
|
+
"brotliLength": 0,
|
|
42
|
+
"mainUid": "b6e9-30"
|
|
43
|
+
},
|
|
44
|
+
"b6e9-33": {
|
|
45
|
+
"renderedLength": 11932,
|
|
46
|
+
"gzipLength": 3067,
|
|
47
|
+
"brotliLength": 0,
|
|
48
|
+
"mainUid": "b6e9-32"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"nodeMetas": {
|
|
52
|
+
"b6e9-28": {
|
|
53
|
+
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
54
|
+
"moduleParts": {
|
|
55
|
+
"index.production.js": "b6e9-29"
|
|
56
|
+
},
|
|
57
|
+
"imported": [],
|
|
58
|
+
"importedBy": [
|
|
59
|
+
{
|
|
60
|
+
"uid": "b6e9-32"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"b6e9-30": {
|
|
65
|
+
"id": "/packages/router-core/build/esm/index.js",
|
|
66
|
+
"moduleParts": {
|
|
67
|
+
"index.production.js": "b6e9-31"
|
|
68
|
+
},
|
|
69
|
+
"imported": [],
|
|
70
|
+
"importedBy": [
|
|
71
|
+
{
|
|
72
|
+
"uid": "b6e9-32"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"b6e9-32": {
|
|
77
|
+
"id": "/packages/react-router/src/index.tsx",
|
|
78
|
+
"moduleParts": {
|
|
79
|
+
"index.production.js": "b6e9-33"
|
|
80
|
+
},
|
|
81
|
+
"imported": [
|
|
82
|
+
{
|
|
83
|
+
"uid": "b6e9-28"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"uid": "b6e9-34"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"uid": "b6e9-35"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"uid": "b6e9-30"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"importedBy": [],
|
|
96
|
+
"isEntry": true
|
|
97
|
+
},
|
|
98
|
+
"b6e9-34": {
|
|
99
|
+
"id": "react",
|
|
100
|
+
"moduleParts": {},
|
|
101
|
+
"imported": [],
|
|
102
|
+
"importedBy": [
|
|
103
|
+
{
|
|
104
|
+
"uid": "b6e9-32"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"isExternal": true
|
|
108
|
+
},
|
|
109
|
+
"b6e9-35": {
|
|
110
|
+
"id": "use-sync-external-store/shim",
|
|
111
|
+
"moduleParts": {},
|
|
112
|
+
"imported": [],
|
|
113
|
+
"importedBy": [
|
|
114
|
+
{
|
|
115
|
+
"uid": "b6e9-32"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"isExternal": true
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"env": {
|
|
122
|
+
"rollup": "2.77.2"
|
|
123
|
+
},
|
|
124
|
+
"options": {
|
|
125
|
+
"gzip": true,
|
|
126
|
+
"brotli": false,
|
|
127
|
+
"sourcemap": false
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) TanStack
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { AnyRouteConfig, RouteConfig, AnyAllRouteInfo, AllRouteInfo, RootRouteId, RouteMatch, ToOptions, MatchRouteOptions, RouteInfoByPath, ResolveRelativePath, NoInfer, DefaultAllRouteInfo, AnyRouteInfo, RouteInfo, ValidFromPath, LinkOptions, RouterOptions, Router } from '@tanstack/router-core';
|
|
13
|
+
export * from '@tanstack/router-core';
|
|
14
|
+
|
|
15
|
+
declare module '@tanstack/router-core' {
|
|
16
|
+
interface FrameworkGenerics {
|
|
17
|
+
Element: React.ReactNode;
|
|
18
|
+
AsyncElement: (opts: {
|
|
19
|
+
params: Record<string, string>;
|
|
20
|
+
}) => Promise<React.ReactNode>;
|
|
21
|
+
SyncOrAsyncElement: React.ReactNode | FrameworkGenerics['AsyncElement'];
|
|
22
|
+
}
|
|
23
|
+
interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> extends Pick<Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][RootRouteId]>, 'linkProps' | 'Link' | 'MatchRoute'> {
|
|
24
|
+
useRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
25
|
+
useMatch: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId) => RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
26
|
+
linkProps: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, '/', TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
27
|
+
Link: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, '/', TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
28
|
+
children?: React.ReactNode | ((state: {
|
|
29
|
+
isActive: boolean;
|
|
30
|
+
}) => React.ReactNode);
|
|
31
|
+
}) => JSX.Element;
|
|
32
|
+
MatchRoute: <TTo extends string = '.'>(props: ToOptions<TAllRouteInfo, '/', TTo> & MatchRouteOptions & {
|
|
33
|
+
children?: React.ReactNode | ((params: RouteInfoByPath<TAllRouteInfo, ResolveRelativePath<'/', NoInfer<TTo>>>['allParams']) => React.ReactNode);
|
|
34
|
+
}) => JSX.Element;
|
|
35
|
+
}
|
|
36
|
+
interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
|
|
37
|
+
linkProps: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
38
|
+
Link: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
39
|
+
children?: React.ReactNode | ((state: {
|
|
40
|
+
isActive: boolean;
|
|
41
|
+
}) => React.ReactNode);
|
|
42
|
+
}) => JSX.Element;
|
|
43
|
+
MatchRoute: <TTo extends string = '.'>(props: ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> & MatchRouteOptions & {
|
|
44
|
+
children?: React.ReactNode | ((params: RouteInfoByPath<TAllRouteInfo, ResolveRelativePath<TRouteInfo['fullPath'], NoInfer<TTo>>>['allParams']) => React.ReactNode);
|
|
45
|
+
}) => JSX.Element;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
declare type LinkPropsOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = LinkOptions<TAllRouteInfo, TFrom, TTo> & {
|
|
49
|
+
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
50
|
+
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
51
|
+
};
|
|
52
|
+
declare type PromptProps = {
|
|
53
|
+
message: string;
|
|
54
|
+
when?: boolean | any;
|
|
55
|
+
children?: React.ReactNode;
|
|
56
|
+
};
|
|
57
|
+
declare type MatchesProviderProps = {
|
|
58
|
+
value: RouteMatch[];
|
|
59
|
+
children: React.ReactNode;
|
|
60
|
+
};
|
|
61
|
+
declare function MatchesProvider(props: MatchesProviderProps): JSX.Element;
|
|
62
|
+
declare function createReactRouter<TRouteConfig extends AnyRouteConfig = RouteConfig>(opts: RouterOptions<TRouteConfig>): Router<TRouteConfig>;
|
|
63
|
+
declare type RouterProps<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo> = RouterOptions<TRouteConfig> & {
|
|
64
|
+
router: Router<TRouteConfig, TAllRouteInfo>;
|
|
65
|
+
children?: React.ReactNode;
|
|
66
|
+
};
|
|
67
|
+
declare function RouterProvider<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo>({ children, router, ...rest }: RouterProps<TRouteConfig, TAllRouteInfo>): JSX.Element;
|
|
68
|
+
declare function useRouter(): Router;
|
|
69
|
+
declare function useMatches(): RouteMatch[];
|
|
70
|
+
declare function useParentMatches(): RouteMatch[];
|
|
71
|
+
declare function useMatch<T>(): RouteMatch;
|
|
72
|
+
declare function Outlet(): JSX.Element | null;
|
|
73
|
+
declare function DefaultCatchBoundary({ error }: {
|
|
74
|
+
error: any;
|
|
75
|
+
}): JSX.Element;
|
|
76
|
+
|
|
77
|
+
export { DefaultCatchBoundary, MatchesProvider, MatchesProviderProps, Outlet, PromptProps, RouterProps, RouterProvider, createReactRouter, useMatch, useMatches, useParentMatches, useRouter };
|
|
@@ -2375,6 +2375,108 @@
|
|
|
2375
2375
|
};
|
|
2376
2376
|
|
|
2377
2377
|
function createReactRouter(opts) {
|
|
2378
|
+
const makeRouteExt = (route, router) => {
|
|
2379
|
+
return {
|
|
2380
|
+
linkProps: options => {
|
|
2381
|
+
var _functionalUpdate, _functionalUpdate2;
|
|
2382
|
+
|
|
2383
|
+
const {
|
|
2384
|
+
// custom props
|
|
2385
|
+
target,
|
|
2386
|
+
activeProps = () => ({
|
|
2387
|
+
className: 'active'
|
|
2388
|
+
}),
|
|
2389
|
+
inactiveProps = () => ({}),
|
|
2390
|
+
disabled,
|
|
2391
|
+
// element props
|
|
2392
|
+
style,
|
|
2393
|
+
className,
|
|
2394
|
+
onClick,
|
|
2395
|
+
onFocus,
|
|
2396
|
+
onMouseEnter,
|
|
2397
|
+
onMouseLeave
|
|
2398
|
+
} = options,
|
|
2399
|
+
rest = _objectWithoutPropertiesLoose(options, _excluded);
|
|
2400
|
+
|
|
2401
|
+
const linkInfo = route.buildLink(options);
|
|
2402
|
+
|
|
2403
|
+
if (linkInfo.type === 'external') {
|
|
2404
|
+
const {
|
|
2405
|
+
href
|
|
2406
|
+
} = linkInfo;
|
|
2407
|
+
return {
|
|
2408
|
+
href
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
const {
|
|
2413
|
+
handleClick,
|
|
2414
|
+
handleFocus,
|
|
2415
|
+
handleEnter,
|
|
2416
|
+
handleLeave,
|
|
2417
|
+
isActive,
|
|
2418
|
+
next
|
|
2419
|
+
} = linkInfo;
|
|
2420
|
+
|
|
2421
|
+
const composeHandlers = handlers => e => {
|
|
2422
|
+
e.persist();
|
|
2423
|
+
handlers.forEach(handler => {
|
|
2424
|
+
if (handler) handler(e);
|
|
2425
|
+
});
|
|
2426
|
+
}; // Get the active props
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
const resolvedActiveProps = isActive ? (_functionalUpdate = functionalUpdate(activeProps)) != null ? _functionalUpdate : {} : {}; // Get the inactive props
|
|
2430
|
+
|
|
2431
|
+
const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = functionalUpdate(inactiveProps)) != null ? _functionalUpdate2 : {};
|
|
2432
|
+
return _extends$2({}, resolvedActiveProps, resolvedInactiveProps, rest, {
|
|
2433
|
+
href: disabled ? undefined : next.href,
|
|
2434
|
+
onClick: composeHandlers([handleClick, onClick]),
|
|
2435
|
+
onFocus: composeHandlers([handleFocus, onFocus]),
|
|
2436
|
+
onMouseEnter: composeHandlers([handleEnter, onMouseEnter]),
|
|
2437
|
+
onMouseLeave: composeHandlers([handleLeave, onMouseLeave]),
|
|
2438
|
+
target,
|
|
2439
|
+
style: _extends$2({}, style, resolvedActiveProps.style, resolvedInactiveProps.style),
|
|
2440
|
+
className: [className, resolvedActiveProps.className, resolvedInactiveProps.className].filter(Boolean).join(' ') || undefined
|
|
2441
|
+
}, disabled ? {
|
|
2442
|
+
role: 'link',
|
|
2443
|
+
'aria-disabled': true
|
|
2444
|
+
} : undefined, {
|
|
2445
|
+
['data-status']: isActive ? 'active' : undefined
|
|
2446
|
+
});
|
|
2447
|
+
},
|
|
2448
|
+
Link: /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
|
|
2449
|
+
const linkProps = route.linkProps(props);
|
|
2450
|
+
useRouterSubscription(router);
|
|
2451
|
+
return /*#__PURE__*/React__namespace.createElement("a", _extends$2({
|
|
2452
|
+
ref: ref
|
|
2453
|
+
}, linkProps, {
|
|
2454
|
+
children: typeof props.children === 'function' ? props.children({
|
|
2455
|
+
isActive: linkProps['data-status'] === 'active'
|
|
2456
|
+
}) : props.children
|
|
2457
|
+
}));
|
|
2458
|
+
}),
|
|
2459
|
+
MatchRoute: opts => {
|
|
2460
|
+
const {
|
|
2461
|
+
pending,
|
|
2462
|
+
caseSensitive
|
|
2463
|
+
} = opts,
|
|
2464
|
+
rest = _objectWithoutPropertiesLoose(opts, _excluded2);
|
|
2465
|
+
|
|
2466
|
+
const params = route.matchRoute(rest, {
|
|
2467
|
+
pending,
|
|
2468
|
+
caseSensitive
|
|
2469
|
+
}); // useRouterSubscription(router)
|
|
2470
|
+
|
|
2471
|
+
if (!params) {
|
|
2472
|
+
return null;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
return typeof opts.children === 'function' ? opts.children(params) : opts.children;
|
|
2476
|
+
}
|
|
2477
|
+
};
|
|
2478
|
+
};
|
|
2479
|
+
|
|
2378
2480
|
const coreRouter = createRouter(_extends$2({}, opts, {
|
|
2379
2481
|
createRouter: router => {
|
|
2380
2482
|
const routerExt = {
|
|
@@ -2414,112 +2516,15 @@
|
|
|
2414
2516
|
return match;
|
|
2415
2517
|
}
|
|
2416
2518
|
};
|
|
2417
|
-
|
|
2519
|
+
const routeExt = makeRouteExt(router.getRoute('/'), router);
|
|
2520
|
+
Object.assign(router, routerExt, routeExt);
|
|
2418
2521
|
},
|
|
2419
2522
|
createRoute: _ref => {
|
|
2420
2523
|
let {
|
|
2421
2524
|
router,
|
|
2422
2525
|
route
|
|
2423
2526
|
} = _ref;
|
|
2424
|
-
const routeExt =
|
|
2425
|
-
linkProps: options => {
|
|
2426
|
-
var _functionalUpdate, _functionalUpdate2;
|
|
2427
|
-
|
|
2428
|
-
const {
|
|
2429
|
-
// custom props
|
|
2430
|
-
target,
|
|
2431
|
-
activeProps = () => ({
|
|
2432
|
-
className: 'active'
|
|
2433
|
-
}),
|
|
2434
|
-
inactiveProps = () => ({}),
|
|
2435
|
-
disabled,
|
|
2436
|
-
// element props
|
|
2437
|
-
style,
|
|
2438
|
-
className,
|
|
2439
|
-
onClick,
|
|
2440
|
-
onFocus,
|
|
2441
|
-
onMouseEnter,
|
|
2442
|
-
onMouseLeave
|
|
2443
|
-
} = options,
|
|
2444
|
-
rest = _objectWithoutPropertiesLoose(options, _excluded);
|
|
2445
|
-
|
|
2446
|
-
const linkInfo = route.buildLink(options);
|
|
2447
|
-
|
|
2448
|
-
if (linkInfo.type === 'external') {
|
|
2449
|
-
const {
|
|
2450
|
-
href
|
|
2451
|
-
} = linkInfo;
|
|
2452
|
-
return {
|
|
2453
|
-
href
|
|
2454
|
-
};
|
|
2455
|
-
}
|
|
2456
|
-
|
|
2457
|
-
const {
|
|
2458
|
-
handleClick,
|
|
2459
|
-
handleFocus,
|
|
2460
|
-
handleEnter,
|
|
2461
|
-
handleLeave,
|
|
2462
|
-
isActive,
|
|
2463
|
-
next
|
|
2464
|
-
} = linkInfo;
|
|
2465
|
-
|
|
2466
|
-
const composeHandlers = handlers => e => {
|
|
2467
|
-
e.persist();
|
|
2468
|
-
handlers.forEach(handler => {
|
|
2469
|
-
if (handler) handler(e);
|
|
2470
|
-
});
|
|
2471
|
-
}; // Get the active props
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
const resolvedActiveProps = isActive ? (_functionalUpdate = functionalUpdate(activeProps)) != null ? _functionalUpdate : {} : {}; // Get the inactive props
|
|
2475
|
-
|
|
2476
|
-
const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = functionalUpdate(inactiveProps)) != null ? _functionalUpdate2 : {};
|
|
2477
|
-
return _extends$2({}, resolvedActiveProps, resolvedInactiveProps, rest, {
|
|
2478
|
-
href: disabled ? undefined : next.href,
|
|
2479
|
-
onClick: composeHandlers([handleClick, onClick]),
|
|
2480
|
-
onFocus: composeHandlers([handleFocus, onFocus]),
|
|
2481
|
-
onMouseEnter: composeHandlers([handleEnter, onMouseEnter]),
|
|
2482
|
-
onMouseLeave: composeHandlers([handleLeave, onMouseLeave]),
|
|
2483
|
-
target,
|
|
2484
|
-
style: _extends$2({}, style, resolvedActiveProps.style, resolvedInactiveProps.style),
|
|
2485
|
-
className: [className, resolvedActiveProps.className, resolvedInactiveProps.className].filter(Boolean).join(' ') || undefined
|
|
2486
|
-
}, disabled ? {
|
|
2487
|
-
role: 'link',
|
|
2488
|
-
'aria-disabled': true
|
|
2489
|
-
} : undefined, {
|
|
2490
|
-
['data-status']: isActive ? 'active' : undefined
|
|
2491
|
-
});
|
|
2492
|
-
},
|
|
2493
|
-
Link: /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
|
|
2494
|
-
const linkProps = route.linkProps(props);
|
|
2495
|
-
useRouterSubscription(router);
|
|
2496
|
-
return /*#__PURE__*/React__namespace.createElement("a", _extends$2({
|
|
2497
|
-
ref: ref
|
|
2498
|
-
}, linkProps, {
|
|
2499
|
-
children: typeof props.children === 'function' ? props.children({
|
|
2500
|
-
isActive: linkProps['data-status'] === 'active'
|
|
2501
|
-
}) : props.children
|
|
2502
|
-
}));
|
|
2503
|
-
}),
|
|
2504
|
-
MatchRoute: opts => {
|
|
2505
|
-
const {
|
|
2506
|
-
pending,
|
|
2507
|
-
caseSensitive
|
|
2508
|
-
} = opts,
|
|
2509
|
-
rest = _objectWithoutPropertiesLoose(opts, _excluded2);
|
|
2510
|
-
|
|
2511
|
-
const params = route.matchRoute(rest, {
|
|
2512
|
-
pending,
|
|
2513
|
-
caseSensitive
|
|
2514
|
-
}); // useRouterSubscription(router)
|
|
2515
|
-
|
|
2516
|
-
if (!params) {
|
|
2517
|
-
return null;
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
return typeof opts.children === 'function' ? opts.children(params) : opts.children;
|
|
2521
|
-
}
|
|
2522
|
-
};
|
|
2527
|
+
const routeExt = makeRouteExt(route, router);
|
|
2523
2528
|
Object.assign(route, routeExt);
|
|
2524
2529
|
}
|
|
2525
2530
|
}));
|