@tanstack/react-router 0.0.1-beta.9 → 1.0.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/LICENSE +21 -0
- package/build/cjs/CatchBoundary.js +128 -0
- package/build/cjs/CatchBoundary.js.map +1 -0
- package/build/cjs/Matches.js +233 -0
- package/build/cjs/Matches.js.map +1 -0
- package/build/cjs/RouterProvider.js +172 -0
- package/build/cjs/RouterProvider.js.map +1 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +2 -22
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/awaited.js +43 -0
- package/build/cjs/awaited.js.map +1 -0
- package/build/cjs/defer.js +37 -0
- package/build/cjs/defer.js.map +1 -0
- package/build/cjs/fileRoute.js +27 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/index.js +130 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/lazyRouteComponent.js +54 -0
- package/build/cjs/lazyRouteComponent.js.map +1 -0
- package/build/cjs/link.js +223 -0
- package/build/cjs/link.js.map +1 -0
- package/build/cjs/path.js +214 -0
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/qss.js +63 -0
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/redirects.js +28 -0
- package/build/cjs/redirects.js.map +1 -0
- package/build/cjs/route.js +191 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/router.js +1085 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/scroll-restoration.js +202 -0
- package/build/cjs/scroll-restoration.js.map +1 -0
- package/build/cjs/searchParams.js +81 -0
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/useBlocker.js +55 -0
- package/build/cjs/useBlocker.js.map +1 -0
- package/build/cjs/useNavigate.js +86 -0
- package/build/cjs/useNavigate.js.map +1 -0
- package/build/cjs/useParams.js +26 -0
- package/build/cjs/useParams.js.map +1 -0
- package/build/cjs/useSearch.js +25 -0
- package/build/cjs/useSearch.js.map +1 -0
- package/build/cjs/utils.js +241 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +2302 -2534
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +3498 -2694
- package/build/stats-react.json +1204 -44
- package/build/types/CatchBoundary.d.ts +36 -0
- package/build/types/Matches.d.ts +64 -0
- package/build/types/RouterProvider.d.ts +35 -0
- package/build/types/awaited.d.ts +9 -0
- package/build/types/defer.d.ts +19 -0
- package/build/types/fileRoute.d.ts +38 -0
- package/build/types/history.d.ts +7 -0
- package/build/types/index.d.ts +27 -74
- package/build/types/lazyRouteComponent.d.ts +2 -0
- package/build/types/link.d.ts +93 -0
- package/build/types/location.d.ts +12 -0
- package/build/types/path.d.ts +17 -0
- package/build/types/qss.d.ts +2 -0
- package/build/types/redirects.d.ts +11 -0
- package/build/types/route.d.ts +283 -0
- package/build/types/routeInfo.d.ts +31 -0
- package/build/types/router.d.ts +186 -0
- package/build/types/scroll-restoration.d.ts +18 -0
- package/build/types/searchParams.d.ts +7 -0
- package/build/types/useBlocker.d.ts +9 -0
- package/build/types/useNavigate.d.ts +19 -0
- package/build/types/useParams.d.ts +7 -0
- package/build/types/useSearch.d.ts +7 -0
- package/build/types/utils.d.ts +69 -0
- package/build/umd/index.development.js +2899 -2493
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +4 -4
- package/build/umd/index.production.js.map +1 -1
- package/package.json +12 -10
- package/src/CatchBoundary.tsx +101 -0
- package/src/Matches.tsx +423 -0
- package/src/RouterProvider.tsx +254 -0
- package/src/awaited.tsx +40 -0
- package/src/defer.ts +55 -0
- package/src/fileRoute.ts +152 -0
- package/src/history.ts +8 -0
- package/src/index.tsx +28 -619
- package/src/lazyRouteComponent.tsx +33 -0
- package/src/link.tsx +603 -0
- package/src/location.ts +13 -0
- package/src/path.ts +261 -0
- package/src/qss.ts +53 -0
- package/src/redirects.ts +39 -0
- package/src/route.ts +882 -0
- package/src/routeInfo.ts +84 -0
- package/src/router.ts +1671 -0
- package/src/scroll-restoration.tsx +230 -0
- package/src/searchParams.ts +79 -0
- package/src/useBlocker.tsx +27 -0
- package/src/useNavigate.tsx +111 -0
- package/src/useParams.tsx +25 -0
- package/src/useSearch.tsx +25 -0
- package/src/utils.ts +360 -0
- package/build/cjs/react-router/src/index.js +0 -458
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router
|
|
2
|
+
* @tanstack/react-router/src/index.tsx
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) TanStack
|
|
5
5
|
*
|
|
@@ -10,40 +10,20 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
13
|
function _extends() {
|
|
16
14
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
15
|
for (var i = 1; i < arguments.length; i++) {
|
|
18
16
|
var source = arguments[i];
|
|
19
|
-
|
|
20
17
|
for (var key in source) {
|
|
21
18
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
19
|
target[key] = source[key];
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
return target;
|
|
28
24
|
};
|
|
29
25
|
return _extends.apply(this, arguments);
|
|
30
26
|
}
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
if (source == null) return {};
|
|
34
|
-
var target = {};
|
|
35
|
-
var sourceKeys = Object.keys(source);
|
|
36
|
-
var key, i;
|
|
37
|
-
|
|
38
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
39
|
-
key = sourceKeys[i];
|
|
40
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
41
|
-
target[key] = source[key];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return target;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
exports["extends"] = _extends;
|
|
48
|
-
exports.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose;
|
|
28
|
+
exports.extends = _extends;
|
|
49
29
|
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tanstack/react-router/src/index.tsx
|
|
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
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var RouterProvider = require('./RouterProvider.js');
|
|
14
|
+
var defer = require('./defer.js');
|
|
15
|
+
|
|
16
|
+
function useAwaited({
|
|
17
|
+
promise
|
|
18
|
+
}) {
|
|
19
|
+
const router = RouterProvider.useRouter();
|
|
20
|
+
let state = promise.__deferredState;
|
|
21
|
+
const key = `__TSR__DEFERRED__${state.uid}`;
|
|
22
|
+
if (defer.isDehydratedDeferred(promise)) {
|
|
23
|
+
state = router.hydrateData(key);
|
|
24
|
+
promise = Promise.resolve(state.data);
|
|
25
|
+
promise.__deferredState = state;
|
|
26
|
+
}
|
|
27
|
+
if (state.status === 'pending') {
|
|
28
|
+
throw new Promise(r => setTimeout(r, 1)).then(() => promise);
|
|
29
|
+
}
|
|
30
|
+
if (state.status === 'error') {
|
|
31
|
+
throw state.error;
|
|
32
|
+
}
|
|
33
|
+
router.dehydrateData(key, state);
|
|
34
|
+
return [state.data];
|
|
35
|
+
}
|
|
36
|
+
function Await(props) {
|
|
37
|
+
const awaited = useAwaited(props);
|
|
38
|
+
return props.children(...awaited);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.Await = Await;
|
|
42
|
+
exports.useAwaited = useAwaited;
|
|
43
|
+
//# sourceMappingURL=awaited.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"awaited.js","sources":["../../src/awaited.tsx"],"sourcesContent":["import { useRouter } from './RouterProvider'\nimport { DeferredPromise, isDehydratedDeferred } from './defer'\n\nexport type AwaitOptions<T> = {\n promise: DeferredPromise<T>\n}\n\nexport function useAwaited<T>({ promise }: AwaitOptions<T>): [T] {\n const router = useRouter()\n\n let state = promise.__deferredState\n const key = `__TSR__DEFERRED__${state.uid}`\n\n if (isDehydratedDeferred(promise)) {\n state = router.hydrateData(key)!\n promise = Promise.resolve(state.data) as DeferredPromise<any>\n promise.__deferredState = state\n }\n\n if (state.status === 'pending') {\n throw new Promise((r) => setTimeout(r, 1)).then(() => promise)\n }\n\n if (state.status === 'error') {\n throw state.error\n }\n\n router.dehydrateData(key, state)\n\n return [state.data]\n}\n\nexport function Await<T>(\n props: AwaitOptions<T> & {\n children: (result: T) => JSX.Element\n },\n) {\n const awaited = useAwaited(props)\n return props.children(...awaited)\n}\n"],"names":["useAwaited","promise","router","useRouter","state","__deferredState","key","uid","isDehydratedDeferred","hydrateData","Promise","resolve","data","status","r","setTimeout","then","error","dehydrateData","Await","props","awaited","children"],"mappings":";;;;;;;;;;;;;;;AAOO,SAASA,UAAUA,CAAI;AAAEC,EAAAA,OAAAA;AAAyB,CAAC,EAAO;AAC/D,EAAA,MAAMC,MAAM,GAAGC,wBAAS,EAAE,CAAA;AAE1B,EAAA,IAAIC,KAAK,GAAGH,OAAO,CAACI,eAAe,CAAA;AACnC,EAAA,MAAMC,GAAG,GAAI,CAAA,iBAAA,EAAmBF,KAAK,CAACG,GAAI,CAAC,CAAA,CAAA;AAE3C,EAAA,IAAIC,0BAAoB,CAACP,OAAO,CAAC,EAAE;AACjCG,IAAAA,KAAK,GAAGF,MAAM,CAACO,WAAW,CAACH,GAAG,CAAE,CAAA;IAChCL,OAAO,GAAGS,OAAO,CAACC,OAAO,CAACP,KAAK,CAACQ,IAAI,CAAyB,CAAA;IAC7DX,OAAO,CAACI,eAAe,GAAGD,KAAK,CAAA;AACjC,GAAA;AAEA,EAAA,IAAIA,KAAK,CAACS,MAAM,KAAK,SAAS,EAAE;AAC9B,IAAA,MAAM,IAAIH,OAAO,CAAEI,CAAC,IAAKC,UAAU,CAACD,CAAC,EAAE,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,MAAMf,OAAO,CAAC,CAAA;AAChE,GAAA;AAEA,EAAA,IAAIG,KAAK,CAACS,MAAM,KAAK,OAAO,EAAE;IAC5B,MAAMT,KAAK,CAACa,KAAK,CAAA;AACnB,GAAA;AAEAf,EAAAA,MAAM,CAACgB,aAAa,CAACZ,GAAG,EAAEF,KAAK,CAAC,CAAA;AAEhC,EAAA,OAAO,CAACA,KAAK,CAACQ,IAAI,CAAC,CAAA;AACrB,CAAA;AAEO,SAASO,KAAKA,CACnBC,KAEC,EACD;AACA,EAAA,MAAMC,OAAO,GAAGrB,UAAU,CAACoB,KAAK,CAAC,CAAA;AACjC,EAAA,OAAOA,KAAK,CAACE,QAAQ,CAAC,GAAGD,OAAO,CAAC,CAAA;AACnC;;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tanstack/react-router/src/index.tsx
|
|
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
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
function defer(_promise) {
|
|
14
|
+
const promise = _promise;
|
|
15
|
+
if (!promise.__deferredState) {
|
|
16
|
+
promise.__deferredState = {
|
|
17
|
+
uid: Math.random().toString(36).slice(2),
|
|
18
|
+
status: 'pending'
|
|
19
|
+
};
|
|
20
|
+
const state = promise.__deferredState;
|
|
21
|
+
promise.then(data => {
|
|
22
|
+
state.status = 'success';
|
|
23
|
+
state.data = data;
|
|
24
|
+
}).catch(error => {
|
|
25
|
+
state.status = 'error';
|
|
26
|
+
state.error = error;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return promise;
|
|
30
|
+
}
|
|
31
|
+
function isDehydratedDeferred(obj) {
|
|
32
|
+
return typeof obj === 'object' && obj !== null && !(obj instanceof Promise) && !obj.then && '__deferredState' in obj;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.defer = defer;
|
|
36
|
+
exports.isDehydratedDeferred = isDehydratedDeferred;
|
|
37
|
+
//# sourceMappingURL=defer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defer.js","sources":["../../src/defer.ts"],"sourcesContent":["export type DeferredPromiseState<T> = { uid: string } & (\n | {\n status: 'pending'\n data?: T\n error?: unknown\n }\n | {\n status: 'success'\n data: T\n }\n | {\n status: 'error'\n data?: T\n error: unknown\n }\n)\n\nexport type DeferredPromise<T> = Promise<T> & {\n __deferredState: DeferredPromiseState<T>\n}\n\nexport function defer<T>(_promise: Promise<T>) {\n const promise = _promise as DeferredPromise<T>\n\n if (!promise.__deferredState) {\n promise.__deferredState = {\n uid: Math.random().toString(36).slice(2),\n status: 'pending',\n }\n\n const state = promise.__deferredState\n\n promise\n .then((data) => {\n state.status = 'success' as any\n state.data = data\n })\n .catch((error) => {\n state.status = 'error' as any\n state.error = error\n })\n }\n\n return promise\n}\n\nexport function isDehydratedDeferred(obj: any): boolean {\n return (\n typeof obj === 'object' &&\n obj !== null &&\n !(obj instanceof Promise) &&\n !obj.then &&\n '__deferredState' in obj\n )\n}\n"],"names":["defer","_promise","promise","__deferredState","uid","Math","random","toString","slice","status","state","then","data","catch","error","isDehydratedDeferred","obj","Promise"],"mappings":";;;;;;;;;;;;AAqBO,SAASA,KAAKA,CAAIC,QAAoB,EAAE;EAC7C,MAAMC,OAAO,GAAGD,QAA8B,CAAA;AAE9C,EAAA,IAAI,CAACC,OAAO,CAACC,eAAe,EAAE;IAC5BD,OAAO,CAACC,eAAe,GAAG;AACxBC,MAAAA,GAAG,EAAEC,IAAI,CAACC,MAAM,EAAE,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC;AACxCC,MAAAA,MAAM,EAAE,SAAA;KACT,CAAA;AAED,IAAA,MAAMC,KAAK,GAAGR,OAAO,CAACC,eAAe,CAAA;AAErCD,IAAAA,OAAO,CACJS,IAAI,CAAEC,IAAI,IAAK;MACdF,KAAK,CAACD,MAAM,GAAG,SAAgB,CAAA;MAC/BC,KAAK,CAACE,IAAI,GAAGA,IAAI,CAAA;AACnB,KAAC,CAAC,CACDC,KAAK,CAAEC,KAAK,IAAK;MAChBJ,KAAK,CAACD,MAAM,GAAG,OAAc,CAAA;MAC7BC,KAAK,CAACI,KAAK,GAAGA,KAAK,CAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;AAEA,EAAA,OAAOZ,OAAO,CAAA;AAChB,CAAA;AAEO,SAASa,oBAAoBA,CAACC,GAAQ,EAAW;EACtD,OACE,OAAOA,GAAG,KAAK,QAAQ,IACvBA,GAAG,KAAK,IAAI,IACZ,EAAEA,GAAG,YAAYC,OAAO,CAAC,IACzB,CAACD,GAAG,CAACL,IAAI,IACT,iBAAiB,IAAIK,GAAG,CAAA;AAE5B;;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tanstack/react-router/src/index.tsx
|
|
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
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var route = require('./route.js');
|
|
14
|
+
|
|
15
|
+
class FileRoute {
|
|
16
|
+
constructor(path) {
|
|
17
|
+
this.path = path;
|
|
18
|
+
}
|
|
19
|
+
createRoute = options => {
|
|
20
|
+
const route$1 = new route.Route(options);
|
|
21
|
+
route$1.isRoot = false;
|
|
22
|
+
return route$1;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.FileRoute = FileRoute;
|
|
27
|
+
//# sourceMappingURL=fileRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import { ParsePathParams } from './link'\nimport {\n AnyRoute,\n ResolveFullPath,\n ResolveFullSearchSchema,\n MergeFromFromParent,\n RouteContext,\n AnyContext,\n RouteOptions,\n UpdatableRouteOptions,\n Route,\n AnyPathParams,\n RootRouteId,\n TrimPathLeft,\n RouteConstraints,\n} from './route'\nimport { Assign, Expand, IsAny } from './utils'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n S extends string,\n From extends string,\n To extends string,\n> = S extends `${infer Start}${From}${infer Rest}`\n ? `${Start}${To}${Replace<Rest, From, To>}`\n : S\n\nexport type TrimLeft<\n T extends string,\n S extends string,\n> = T extends `${S}${infer U}` ? U : T\n\nexport type TrimRight<\n T extends string,\n S extends string,\n> = T extends `${infer U}${S}` ? U : T\n\nexport type Trim<T extends string, S extends string> = TrimLeft<\n TrimRight<T, S>,\n S\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : Replace<\n TrimPathLeft<TFilePath>,\n TrimPathLeft<TParentRoute['types']['customId']>,\n ''\n >\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`\n ? string\n : ResolveFilePath<TParentRoute, TFilePath>\n\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = TFilePath,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n RemoveUnderScores<TPath>\n >,\n> {\n constructor(public path: TFilePath) {}\n\n createRoute = <\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = MergeFromFromParent<\n TParentRoute['types']['allParams'],\n TParams\n >,\n TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,\n TContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n >(\n options?: Omit<\n RouteOptions<\n TParentRoute,\n string,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TContext,\n TLoaderDeps,\n TLoaderData\n >,\n 'getParentRoute' | 'path' | 'id'\n > &\n UpdatableRouteOptions<TFullSearchSchema>,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData,\n TChildren,\n TRouteTree\n > => {\n const route = new Route(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n"],"names":["FileRoute","constructor","path","createRoute","options","route","Route","isRoot"],"mappings":";;;;;;;;;;;;;;AAuEO,MAAMA,SAAS,CAYpB;EACAC,WAAWA,CAAQC,IAAe,EAAE;IAAA,IAAjBA,CAAAA,IAAe,GAAfA,IAAe,CAAA;AAAG,GAAA;EAErCC,WAAW,GA0BTC,OAgB0C,IAkBvC;AACH,IAAA,MAAMC,OAAK,GAAG,IAAIC,WAAK,CAACF,OAAc,CAAC,CAAA;IACrCC,OAAK,CAASE,MAAM,GAAG,KAAK,CAAA;AAC9B,IAAA,OAAOF,OAAK,CAAA;GACb,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tanstack/react-router/src/index.tsx
|
|
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
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var history = require('@tanstack/history');
|
|
14
|
+
var invariant = require('tiny-invariant');
|
|
15
|
+
var warning = require('tiny-warning');
|
|
16
|
+
var awaited = require('./awaited.js');
|
|
17
|
+
var defer = require('./defer.js');
|
|
18
|
+
var CatchBoundary = require('./CatchBoundary.js');
|
|
19
|
+
var fileRoute = require('./fileRoute.js');
|
|
20
|
+
var lazyRouteComponent = require('./lazyRouteComponent.js');
|
|
21
|
+
var link = require('./link.js');
|
|
22
|
+
var Matches = require('./Matches.js');
|
|
23
|
+
var path = require('./path.js');
|
|
24
|
+
var qss = require('./qss.js');
|
|
25
|
+
var redirects = require('./redirects.js');
|
|
26
|
+
var route = require('./route.js');
|
|
27
|
+
var router = require('./router.js');
|
|
28
|
+
var RouterProvider = require('./RouterProvider.js');
|
|
29
|
+
var scrollRestoration = require('./scroll-restoration.js');
|
|
30
|
+
var searchParams = require('./searchParams.js');
|
|
31
|
+
var useBlocker = require('./useBlocker.js');
|
|
32
|
+
var useNavigate = require('./useNavigate.js');
|
|
33
|
+
var useParams = require('./useParams.js');
|
|
34
|
+
var useSearch = require('./useSearch.js');
|
|
35
|
+
var utils = require('./utils.js');
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
exports.invariant = invariant;
|
|
40
|
+
exports.warning = warning;
|
|
41
|
+
exports.Await = awaited.Await;
|
|
42
|
+
exports.useAwaited = awaited.useAwaited;
|
|
43
|
+
exports.defer = defer.defer;
|
|
44
|
+
exports.isDehydratedDeferred = defer.isDehydratedDeferred;
|
|
45
|
+
exports.CatchBoundary = CatchBoundary.CatchBoundary;
|
|
46
|
+
exports.CatchBoundaryImpl = CatchBoundary.CatchBoundaryImpl;
|
|
47
|
+
exports.ErrorComponent = CatchBoundary.ErrorComponent;
|
|
48
|
+
exports.FileRoute = fileRoute.FileRoute;
|
|
49
|
+
exports.lazyRouteComponent = lazyRouteComponent.lazyRouteComponent;
|
|
50
|
+
exports.Link = link.Link;
|
|
51
|
+
exports.useLinkProps = link.useLinkProps;
|
|
52
|
+
exports.Match = Matches.Match;
|
|
53
|
+
exports.MatchRoute = Matches.MatchRoute;
|
|
54
|
+
exports.Matches = Matches.Matches;
|
|
55
|
+
exports.Outlet = Matches.Outlet;
|
|
56
|
+
exports.matchContext = Matches.matchContext;
|
|
57
|
+
exports.useLoaderData = Matches.useLoaderData;
|
|
58
|
+
exports.useLoaderDeps = Matches.useLoaderDeps;
|
|
59
|
+
exports.useMatch = Matches.useMatch;
|
|
60
|
+
exports.useMatchRoute = Matches.useMatchRoute;
|
|
61
|
+
exports.useMatches = Matches.useMatches;
|
|
62
|
+
exports.useParentMatches = Matches.useParentMatches;
|
|
63
|
+
exports.cleanPath = path.cleanPath;
|
|
64
|
+
exports.interpolatePath = path.interpolatePath;
|
|
65
|
+
exports.joinPaths = path.joinPaths;
|
|
66
|
+
exports.matchByPath = path.matchByPath;
|
|
67
|
+
exports.matchPathname = path.matchPathname;
|
|
68
|
+
exports.parsePathname = path.parsePathname;
|
|
69
|
+
exports.removeBasepath = path.removeBasepath;
|
|
70
|
+
exports.resolvePath = path.resolvePath;
|
|
71
|
+
exports.trimPath = path.trimPath;
|
|
72
|
+
exports.trimPathLeft = path.trimPathLeft;
|
|
73
|
+
exports.trimPathRight = path.trimPathRight;
|
|
74
|
+
exports.decode = qss.decode;
|
|
75
|
+
exports.encode = qss.encode;
|
|
76
|
+
exports.isRedirect = redirects.isRedirect;
|
|
77
|
+
exports.redirect = redirects.redirect;
|
|
78
|
+
exports.NotFoundRoute = route.NotFoundRoute;
|
|
79
|
+
exports.RootRoute = route.RootRoute;
|
|
80
|
+
exports.Route = route.Route;
|
|
81
|
+
exports.RouteApi = route.RouteApi;
|
|
82
|
+
exports.createRouteMask = route.createRouteMask;
|
|
83
|
+
exports.rootRouteId = route.rootRouteId;
|
|
84
|
+
exports.rootRouteWithContext = route.rootRouteWithContext;
|
|
85
|
+
exports.PathParamError = router.PathParamError;
|
|
86
|
+
exports.Router = router.Router;
|
|
87
|
+
exports.SearchParamError = router.SearchParamError;
|
|
88
|
+
exports.componentTypes = router.componentTypes;
|
|
89
|
+
exports.getInitialRouterState = router.getInitialRouterState;
|
|
90
|
+
exports.lazyFn = router.lazyFn;
|
|
91
|
+
exports.RouterProvider = RouterProvider.RouterProvider;
|
|
92
|
+
exports.getRouteMatch = RouterProvider.getRouteMatch;
|
|
93
|
+
Object.defineProperty(exports, 'routerContext', {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () { return RouterProvider.routerContext; }
|
|
96
|
+
});
|
|
97
|
+
exports.useRouter = RouterProvider.useRouter;
|
|
98
|
+
exports.useRouterState = RouterProvider.useRouterState;
|
|
99
|
+
exports.ScrollRestoration = scrollRestoration.ScrollRestoration;
|
|
100
|
+
exports.useElementScrollRestoration = scrollRestoration.useElementScrollRestoration;
|
|
101
|
+
exports.useScrollRestoration = scrollRestoration.useScrollRestoration;
|
|
102
|
+
exports.defaultParseSearch = searchParams.defaultParseSearch;
|
|
103
|
+
exports.defaultStringifySearch = searchParams.defaultStringifySearch;
|
|
104
|
+
exports.parseSearchWith = searchParams.parseSearchWith;
|
|
105
|
+
exports.stringifySearchWith = searchParams.stringifySearchWith;
|
|
106
|
+
exports.Block = useBlocker.Block;
|
|
107
|
+
exports.useBlocker = useBlocker.useBlocker;
|
|
108
|
+
exports.Navigate = useNavigate.Navigate;
|
|
109
|
+
exports.useNavigate = useNavigate.useNavigate;
|
|
110
|
+
exports.useParams = useParams.useParams;
|
|
111
|
+
exports.useSearch = useSearch.useSearch;
|
|
112
|
+
exports.deepEqual = utils.deepEqual;
|
|
113
|
+
exports.escapeJSON = utils.escapeJSON;
|
|
114
|
+
exports.functionalUpdate = utils.functionalUpdate;
|
|
115
|
+
exports.isPlainObject = utils.isPlainObject;
|
|
116
|
+
exports.isServer = utils.isServer;
|
|
117
|
+
exports.last = utils.last;
|
|
118
|
+
exports.pick = utils.pick;
|
|
119
|
+
exports.replaceEqualDeep = utils.replaceEqualDeep;
|
|
120
|
+
exports.shallow = utils.shallow;
|
|
121
|
+
exports.useLayoutEffect = utils.useLayoutEffect;
|
|
122
|
+
exports.useRouteContext = utils.useRouteContext;
|
|
123
|
+
exports.useStableCallback = utils.useStableCallback;
|
|
124
|
+
Object.keys(history).forEach(function (k) {
|
|
125
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () { return history[k]; }
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tanstack/react-router/src/index.tsx
|
|
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
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var React = require('react');
|
|
14
|
+
|
|
15
|
+
function _interopNamespaceDefault(e) {
|
|
16
|
+
var n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
Object.keys(e).forEach(function (k) {
|
|
19
|
+
if (k !== 'default') {
|
|
20
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return e[k]; }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n.default = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
33
|
+
|
|
34
|
+
function lazyRouteComponent(importer, exportName) {
|
|
35
|
+
let loadPromise;
|
|
36
|
+
const load = () => {
|
|
37
|
+
if (!loadPromise) {
|
|
38
|
+
loadPromise = importer();
|
|
39
|
+
}
|
|
40
|
+
return loadPromise;
|
|
41
|
+
};
|
|
42
|
+
const lazyComp = /*#__PURE__*/React__namespace.lazy(async () => {
|
|
43
|
+
const moduleExports = await load();
|
|
44
|
+
const comp = moduleExports[exportName ?? 'default'];
|
|
45
|
+
return {
|
|
46
|
+
default: comp
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
lazyComp.preload = load;
|
|
50
|
+
return lazyComp;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.lazyRouteComponent = lazyRouteComponent;
|
|
54
|
+
//# sourceMappingURL=lazyRouteComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyRouteComponent.js","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import * as React from 'react'\nimport { AsyncRouteComponent } from './route'\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any>\n\n const load = () => {\n if (!loadPromise) {\n loadPromise = importer()\n }\n\n return loadPromise\n }\n\n const lazyComp = React.lazy(async () => {\n const moduleExports = await load()\n const comp = moduleExports[exportName ?? 'default']\n return {\n default: comp,\n }\n })\n ;(lazyComp as any).preload = load\n\n return lazyComp as any\n}\n"],"names":["lazyRouteComponent","importer","exportName","loadPromise","load","lazyComp","React","lazy","moduleExports","comp","default","preload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAASA,kBAAkBA,CAIhCC,QAA0B,EAC1BC,UAAiB,EAGT;AACR,EAAA,IAAIC,WAAyB,CAAA;EAE7B,MAAMC,IAAI,GAAGA,MAAM;IACjB,IAAI,CAACD,WAAW,EAAE;MAChBA,WAAW,GAAGF,QAAQ,EAAE,CAAA;AAC1B,KAAA;AAEA,IAAA,OAAOE,WAAW,CAAA;GACnB,CAAA;AAED,EAAA,MAAME,QAAQ,gBAAGC,gBAAK,CAACC,IAAI,CAAC,YAAY;AACtC,IAAA,MAAMC,aAAa,GAAG,MAAMJ,IAAI,EAAE,CAAA;AAClC,IAAA,MAAMK,IAAI,GAAGD,aAAa,CAACN,UAAU,IAAI,SAAS,CAAC,CAAA;IACnD,OAAO;AACLQ,MAAAA,OAAO,EAAED,IAAAA;KACV,CAAA;AACH,GAAC,CAAC,CAAA;EACAJ,QAAQ,CAASM,OAAO,GAAGP,IAAI,CAAA;AAEjC,EAAA,OAAOC,QAAQ,CAAA;AACjB;;;;"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tanstack/react-router/src/index.tsx
|
|
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
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var Matches = require('./Matches.js');
|
|
16
|
+
var RouterProvider = require('./RouterProvider.js');
|
|
17
|
+
var utils = require('./utils.js');
|
|
18
|
+
|
|
19
|
+
function _interopNamespaceDefault(e) {
|
|
20
|
+
var n = Object.create(null);
|
|
21
|
+
if (e) {
|
|
22
|
+
Object.keys(e).forEach(function (k) {
|
|
23
|
+
if (k !== 'default') {
|
|
24
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
25
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return e[k]; }
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
n.default = e;
|
|
33
|
+
return Object.freeze(n);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
37
|
+
|
|
38
|
+
const preloadWarning = 'Error preloading route! ☝️';
|
|
39
|
+
function useLinkProps(options) {
|
|
40
|
+
const router = RouterProvider.useRouter();
|
|
41
|
+
const matchPathname = Matches.useMatch({
|
|
42
|
+
strict: false,
|
|
43
|
+
select: s => s.pathname
|
|
44
|
+
});
|
|
45
|
+
const {
|
|
46
|
+
// custom props
|
|
47
|
+
children,
|
|
48
|
+
target,
|
|
49
|
+
activeProps = () => ({
|
|
50
|
+
className: 'active'
|
|
51
|
+
}),
|
|
52
|
+
inactiveProps = () => ({}),
|
|
53
|
+
activeOptions,
|
|
54
|
+
disabled,
|
|
55
|
+
hash,
|
|
56
|
+
search,
|
|
57
|
+
params,
|
|
58
|
+
to,
|
|
59
|
+
state,
|
|
60
|
+
mask,
|
|
61
|
+
preload: userPreload,
|
|
62
|
+
preloadDelay: userPreloadDelay,
|
|
63
|
+
replace,
|
|
64
|
+
startTransition,
|
|
65
|
+
resetScroll,
|
|
66
|
+
// element props
|
|
67
|
+
style,
|
|
68
|
+
className,
|
|
69
|
+
onClick,
|
|
70
|
+
onFocus,
|
|
71
|
+
onMouseEnter,
|
|
72
|
+
onMouseLeave,
|
|
73
|
+
onTouchStart,
|
|
74
|
+
...rest
|
|
75
|
+
} = options;
|
|
76
|
+
|
|
77
|
+
// If this link simply reloads the current route,
|
|
78
|
+
// make sure it has a new key so it will trigger a data refresh
|
|
79
|
+
|
|
80
|
+
// If this `to` is a valid external URL, return
|
|
81
|
+
// null for LinkUtils
|
|
82
|
+
|
|
83
|
+
const dest = {
|
|
84
|
+
from: options.to ? matchPathname : undefined,
|
|
85
|
+
...options
|
|
86
|
+
};
|
|
87
|
+
let type = 'internal';
|
|
88
|
+
try {
|
|
89
|
+
new URL(`${to}`);
|
|
90
|
+
type = 'external';
|
|
91
|
+
} catch {}
|
|
92
|
+
if (type === 'external') {
|
|
93
|
+
return {
|
|
94
|
+
href: to
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const next = router.buildLocation(dest);
|
|
98
|
+
const preload = userPreload ?? router.options.defaultPreload;
|
|
99
|
+
const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
|
100
|
+
const isActive = RouterProvider.useRouterState({
|
|
101
|
+
select: s => {
|
|
102
|
+
// Compare path/hash for matches
|
|
103
|
+
const currentPathSplit = s.location.pathname.split('/');
|
|
104
|
+
const nextPathSplit = next.pathname.split('/');
|
|
105
|
+
const pathIsFuzzyEqual = nextPathSplit.every((d, i) => d === currentPathSplit[i]);
|
|
106
|
+
// Combine the matches based on user router.options
|
|
107
|
+
const pathTest = activeOptions?.exact ? s.location.pathname === next.pathname : pathIsFuzzyEqual;
|
|
108
|
+
const hashTest = activeOptions?.includeHash ? s.location.hash === next.hash : true;
|
|
109
|
+
const searchTest = activeOptions?.includeSearch ?? true ? utils.deepEqual(s.location.search, next.search, !activeOptions?.exact) : true;
|
|
110
|
+
|
|
111
|
+
// The final "active" test
|
|
112
|
+
return pathTest && hashTest && searchTest;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// The click handler
|
|
117
|
+
const handleClick = e => {
|
|
118
|
+
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!target || target === '_self') && e.button === 0) {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
|
|
121
|
+
// All is well? Navigate!
|
|
122
|
+
router.commitLocation({
|
|
123
|
+
...next,
|
|
124
|
+
replace,
|
|
125
|
+
resetScroll,
|
|
126
|
+
startTransition
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// The click handler
|
|
132
|
+
const handleFocus = e => {
|
|
133
|
+
if (preload) {
|
|
134
|
+
router.preloadRoute(dest).catch(err => {
|
|
135
|
+
console.warn(err);
|
|
136
|
+
console.warn(preloadWarning);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const handleTouchStart = e => {
|
|
141
|
+
if (preload) {
|
|
142
|
+
router.preloadRoute(dest).catch(err => {
|
|
143
|
+
console.warn(err);
|
|
144
|
+
console.warn(preloadWarning);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const handleEnter = e => {
|
|
149
|
+
const target = e.target || {};
|
|
150
|
+
if (preload) {
|
|
151
|
+
if (target.preloadTimeout) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
target.preloadTimeout = setTimeout(() => {
|
|
155
|
+
target.preloadTimeout = null;
|
|
156
|
+
router.preloadRoute(dest).catch(err => {
|
|
157
|
+
console.warn(err);
|
|
158
|
+
console.warn(preloadWarning);
|
|
159
|
+
});
|
|
160
|
+
}, preloadDelay);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const handleLeave = e => {
|
|
164
|
+
const target = e.target || {};
|
|
165
|
+
if (target.preloadTimeout) {
|
|
166
|
+
clearTimeout(target.preloadTimeout);
|
|
167
|
+
target.preloadTimeout = null;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const composeHandlers = handlers => e => {
|
|
171
|
+
if (e.persist) e.persist();
|
|
172
|
+
handlers.filter(Boolean).forEach(handler => {
|
|
173
|
+
if (e.defaultPrevented) return;
|
|
174
|
+
handler(e);
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// Get the active props
|
|
179
|
+
const resolvedActiveProps = isActive ? utils.functionalUpdate(activeProps, {}) ?? {} : {};
|
|
180
|
+
|
|
181
|
+
// Get the inactive props
|
|
182
|
+
const resolvedInactiveProps = isActive ? {} : utils.functionalUpdate(inactiveProps, {}) ?? {};
|
|
183
|
+
return {
|
|
184
|
+
...resolvedActiveProps,
|
|
185
|
+
...resolvedInactiveProps,
|
|
186
|
+
...rest,
|
|
187
|
+
href: disabled ? undefined : next.maskedLocation ? next.maskedLocation.href : next.href,
|
|
188
|
+
onClick: composeHandlers([onClick, handleClick]),
|
|
189
|
+
onFocus: composeHandlers([onFocus, handleFocus]),
|
|
190
|
+
onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
|
|
191
|
+
onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
|
|
192
|
+
onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
|
|
193
|
+
target,
|
|
194
|
+
style: {
|
|
195
|
+
...style,
|
|
196
|
+
...resolvedActiveProps.style,
|
|
197
|
+
...resolvedInactiveProps.style
|
|
198
|
+
},
|
|
199
|
+
className: [className, resolvedActiveProps.className, resolvedInactiveProps.className].filter(Boolean).join(' ') || undefined,
|
|
200
|
+
...(disabled ? {
|
|
201
|
+
role: 'link',
|
|
202
|
+
'aria-disabled': true
|
|
203
|
+
} : undefined),
|
|
204
|
+
['data-status']: isActive ? 'active' : undefined
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const Link = /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
|
|
208
|
+
const linkProps = useLinkProps(props);
|
|
209
|
+
return /*#__PURE__*/React__namespace.createElement("a", _rollupPluginBabelHelpers.extends({
|
|
210
|
+
ref: ref
|
|
211
|
+
}, linkProps, {
|
|
212
|
+
children: typeof props.children === 'function' ? props.children({
|
|
213
|
+
isActive: linkProps['data-status'] === 'active'
|
|
214
|
+
}) : props.children
|
|
215
|
+
}));
|
|
216
|
+
});
|
|
217
|
+
function isCtrlEvent(e) {
|
|
218
|
+
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
exports.Link = Link;
|
|
222
|
+
exports.useLinkProps = useLinkProps;
|
|
223
|
+
//# sourceMappingURL=link.js.map
|