@tanstack/solid-router 2.0.0-alpha.5 → 2.0.0-alpha.7
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/dist/cjs/Asset.cjs +2 -2
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/HeadContent.cjs +11 -1
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.dev.cjs +11 -1
- package/dist/cjs/HeadContent.dev.cjs.map +1 -1
- package/dist/cjs/Match.cjs +265 -248
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Match.d.cts +1 -3
- package/dist/cjs/Matches.cjs +35 -34
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/RouterProvider.cjs +12 -8
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +1 -1
- package/dist/cjs/Scripts.cjs +23 -12
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/Scripts.d.cts +2 -1
- package/dist/cjs/Transitioner.cjs +57 -36
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +26 -23
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/headContentUtils.d.cts +2 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.dev.cjs +1 -1
- package/dist/cjs/link.cjs +143 -101
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/matchContext.cjs +7 -5
- package/dist/cjs/matchContext.cjs.map +1 -1
- package/dist/cjs/matchContext.d.cts +8 -2
- package/dist/cjs/not-found.cjs +8 -4
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +1 -1
- package/dist/cjs/router.cjs +2 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/routerStores.cjs +75 -0
- package/dist/cjs/routerStores.cjs.map +1 -0
- package/dist/cjs/routerStores.d.cts +10 -0
- package/dist/cjs/ssr/RouterClient.cjs +1 -1
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/useBlocker.cjs +12 -3
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.cjs +6 -2
- package/dist/cjs/useCanGoBack.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.d.cts +2 -1
- package/dist/cjs/useLoaderDeps.cjs +2 -3
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLocation.cjs +13 -2
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +27 -15
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useParams.cjs +1 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs +12 -30
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs +2 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/utils.cjs +3 -17
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +0 -5
- package/dist/esm/Asset.js +6 -6
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/HeadContent.dev.js +12 -2
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +12 -2
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Match.d.ts +1 -3
- package/dist/esm/Match.js +267 -250
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +40 -39
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +1 -1
- package/dist/esm/RouterProvider.js +10 -7
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.js +2 -2
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.d.ts +2 -1
- package/dist/esm/Scripts.js +21 -11
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.js +58 -37
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/headContentUtils.d.ts +2 -1
- package/dist/esm/headContentUtils.js +26 -23
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/link.js +146 -104
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.d.ts +8 -2
- package/dist/esm/matchContext.js +7 -4
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.d.ts +1 -1
- package/dist/esm/not-found.js +6 -3
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/router.js +2 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerStores.d.ts +10 -0
- package/dist/esm/routerStores.js +73 -0
- package/dist/esm/routerStores.js.map +1 -0
- package/dist/esm/scroll-restoration.js +2 -2
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +1 -1
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +1 -1
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +1 -1
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/useBlocker.js +12 -3
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.d.ts +2 -1
- package/dist/esm/useCanGoBack.js +4 -2
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +2 -3
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +11 -2
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +28 -16
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useParams.js +1 -1
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouterState.js +11 -30
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +2 -1
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +0 -5
- package/dist/esm/utils.js +4 -17
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/Asset.jsx +3 -3
- package/dist/source/Asset.jsx.map +1 -1
- package/dist/source/HeadContent.dev.jsx +5 -1
- package/dist/source/HeadContent.dev.jsx.map +1 -1
- package/dist/source/HeadContent.jsx +5 -1
- package/dist/source/HeadContent.jsx.map +1 -1
- package/dist/source/Match.d.ts +1 -3
- package/dist/source/Match.jsx +260 -264
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +46 -46
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/RouterProvider.d.ts +1 -1
- package/dist/source/RouterProvider.jsx +13 -9
- package/dist/source/RouterProvider.jsx.map +1 -1
- package/dist/source/Scripts.d.ts +2 -1
- package/dist/source/Scripts.jsx +46 -47
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +80 -44
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/headContentUtils.d.ts +2 -1
- package/dist/source/headContentUtils.jsx +79 -80
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/link.jsx +145 -112
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/matchContext.d.ts +8 -2
- package/dist/source/matchContext.jsx +7 -3
- package/dist/source/matchContext.jsx.map +1 -1
- package/dist/source/not-found.d.ts +1 -1
- package/dist/source/not-found.jsx +6 -5
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/router.js +2 -1
- package/dist/source/router.js.map +1 -1
- package/dist/source/routerStores.d.ts +10 -0
- package/dist/source/routerStores.js +82 -0
- package/dist/source/routerStores.js.map +1 -0
- package/dist/source/ssr/RouterClient.jsx +1 -1
- package/dist/source/ssr/RouterClient.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToString.jsx +1 -1
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -1
- package/dist/source/useBlocker.jsx +19 -8
- package/dist/source/useBlocker.jsx.map +1 -1
- package/dist/source/useCanGoBack.d.ts +2 -1
- package/dist/source/useCanGoBack.js +4 -2
- package/dist/source/useCanGoBack.js.map +1 -1
- package/dist/source/useLoaderDeps.jsx +2 -3
- package/dist/source/useLoaderDeps.jsx.map +1 -1
- package/dist/source/useLocation.jsx +13 -3
- package/dist/source/useLocation.jsx.map +1 -1
- package/dist/source/useMatch.jsx +33 -23
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useParams.jsx +1 -1
- package/dist/source/useParams.jsx.map +1 -1
- package/dist/source/useRouterState.jsx +14 -55
- package/dist/source/useRouterState.jsx.map +1 -1
- package/dist/source/useSearch.jsx +2 -1
- package/dist/source/useSearch.jsx.map +1 -1
- package/dist/source/utils.d.ts +0 -5
- package/dist/source/utils.js +2 -15
- package/dist/source/utils.js.map +1 -1
- package/package.json +7 -7
- package/skills/solid-router/SKILL.md +2 -0
- package/src/Asset.tsx +3 -3
- package/src/HeadContent.dev.tsx +10 -1
- package/src/HeadContent.tsx +10 -1
- package/src/Match.tsx +395 -349
- package/src/Matches.tsx +55 -54
- package/src/RouterProvider.tsx +13 -10
- package/src/Scripts.tsx +55 -54
- package/src/Transitioner.tsx +103 -60
- package/src/headContentUtils.tsx +104 -96
- package/src/link.tsx +188 -146
- package/src/matchContext.tsx +16 -7
- package/src/not-found.tsx +6 -6
- package/src/router.ts +2 -1
- package/src/routerStores.ts +119 -0
- package/src/ssr/RouterClient.tsx +1 -1
- package/src/ssr/renderRouterToStream.tsx +1 -1
- package/src/ssr/renderRouterToString.tsx +1 -1
- package/src/useBlocker.tsx +80 -63
- package/src/useCanGoBack.ts +6 -2
- package/src/useLoaderDeps.tsx +2 -3
- package/src/useLocation.tsx +18 -5
- package/src/useMatch.tsx +37 -38
- package/src/useParams.tsx +2 -3
- package/src/useRouterState.tsx +21 -67
- package/src/useSearch.tsx +2 -1
- package/src/utils.ts +2 -24
package/dist/esm/link.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useHydrated } from "./ClientOnly.js";
|
|
2
2
|
import { useRouter } from "./useRouter.js";
|
|
3
|
-
import { useRouterState } from "./useRouterState.js";
|
|
4
3
|
import { useIntersectionObserver } from "./utils.js";
|
|
5
4
|
import { deepEqual, exactPathTest, functionalUpdate, isDangerousProtocol, preloadWarning, removeTrailingSlash } from "@tanstack/router-core";
|
|
6
|
-
import { Dynamic, createComponent, insert,
|
|
5
|
+
import { Dynamic, createComponent, insert, mergeProps, spread, template } from "@solidjs/web";
|
|
7
6
|
import * as Solid from "solid-js";
|
|
8
|
-
import { isServer } from "@tanstack/router-core/isServer";
|
|
7
|
+
import { isServer as isServer$1 } from "@tanstack/router-core/isServer";
|
|
9
8
|
//#region src/link.tsx
|
|
10
|
-
var _tmpl$ = /* @__PURE__ */ template(`<svg><a>`);
|
|
9
|
+
var _tmpl$ = /* @__PURE__ */ template(`<svg><a>`), _tmpl$2 = /* @__PURE__ */ template(`<a>`);
|
|
11
10
|
function mergeRefs(...refs) {
|
|
12
11
|
return (el) => {
|
|
13
12
|
for (const ref of refs) if (typeof ref === "function") ref(el);
|
|
@@ -20,12 +19,12 @@ var timeoutMap = /* @__PURE__ */ new WeakMap();
|
|
|
20
19
|
function useLinkProps(options) {
|
|
21
20
|
const router = useRouter();
|
|
22
21
|
const [isTransitioning, setIsTransitioning] = Solid.createSignal(false);
|
|
23
|
-
const shouldHydrateHash = !isServer && !!router.options.ssr;
|
|
22
|
+
const shouldHydrateHash = !isServer$1 && !!router.options.ssr;
|
|
24
23
|
const hasHydrated = useHydrated();
|
|
25
24
|
let hasRenderFetched = false;
|
|
26
25
|
const [local, rest] = splitProps(Solid.merge({
|
|
27
|
-
activeProps:
|
|
28
|
-
inactiveProps:
|
|
26
|
+
activeProps: STATIC_ACTIVE_PROPS_GET,
|
|
27
|
+
inactiveProps: STATIC_INACTIVE_PROPS_GET
|
|
29
28
|
}, options), [
|
|
30
29
|
"activeProps",
|
|
31
30
|
"inactiveProps",
|
|
@@ -61,25 +60,14 @@ function useLinkProps(options) {
|
|
|
61
60
|
"reloadDocument",
|
|
62
61
|
"unsafeRelative"
|
|
63
62
|
]);
|
|
64
|
-
const currentLocation =
|
|
65
|
-
const
|
|
66
|
-
const leaf = s.matches[s.matches.length - 1];
|
|
67
|
-
return {
|
|
68
|
-
search: leaf?.search,
|
|
69
|
-
hash: s.location.hash,
|
|
70
|
-
path: leaf?.pathname
|
|
71
|
-
};
|
|
72
|
-
} });
|
|
73
|
-
const from = options.from;
|
|
74
|
-
const _options = () => {
|
|
75
|
-
return {
|
|
76
|
-
...options,
|
|
77
|
-
from
|
|
78
|
-
};
|
|
79
|
-
};
|
|
63
|
+
const currentLocation = Solid.createMemo(() => router.stores.location.state, void 0, { equals: (prev, next) => prev?.href === next?.href });
|
|
64
|
+
const _options = () => options;
|
|
80
65
|
const next = Solid.createMemo(() => {
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
const options = {
|
|
67
|
+
_fromLocation: currentLocation(),
|
|
68
|
+
..._options()
|
|
69
|
+
};
|
|
70
|
+
return Solid.untrack(() => router.buildLocation(options));
|
|
83
71
|
});
|
|
84
72
|
const hrefOption = Solid.createMemo(() => {
|
|
85
73
|
if (_options().disabled) return void 0;
|
|
@@ -104,7 +92,8 @@ function useLinkProps(options) {
|
|
|
104
92
|
return _href.href;
|
|
105
93
|
}
|
|
106
94
|
const to = _options().to;
|
|
107
|
-
if (
|
|
95
|
+
if (isSafeInternal(to)) return void 0;
|
|
96
|
+
if (typeof to !== "string" || to.indexOf(":") === -1) return void 0;
|
|
108
97
|
try {
|
|
109
98
|
new URL(to);
|
|
110
99
|
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
@@ -121,22 +110,29 @@ function useLinkProps(options) {
|
|
|
121
110
|
const preloadDelay = () => local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
|
122
111
|
const isActive = Solid.createMemo(() => {
|
|
123
112
|
if (externalLink()) return false;
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
const activeOptions = local.activeOptions;
|
|
114
|
+
const current = currentLocation();
|
|
115
|
+
const nextLocation = next();
|
|
116
|
+
if (activeOptions?.exact) {
|
|
117
|
+
if (!exactPathTest(current.pathname, nextLocation.pathname, router.basepath)) return false;
|
|
126
118
|
} else {
|
|
127
|
-
const
|
|
128
|
-
|
|
119
|
+
const currentPath = removeTrailingSlash(current.pathname, router.basepath);
|
|
120
|
+
const nextPath = removeTrailingSlash(nextLocation.pathname, router.basepath);
|
|
121
|
+
if (!(currentPath.startsWith(nextPath) && (currentPath.length === nextPath.length || currentPath[nextPath.length] === "/"))) return false;
|
|
129
122
|
}
|
|
130
|
-
if (
|
|
131
|
-
if (!deepEqual(
|
|
132
|
-
partial: !
|
|
133
|
-
ignoreUndefined: !
|
|
123
|
+
if (activeOptions?.includeSearch ?? true) {
|
|
124
|
+
if (!deepEqual(current.search, nextLocation.search, {
|
|
125
|
+
partial: !activeOptions?.exact,
|
|
126
|
+
ignoreUndefined: !activeOptions?.explicitUndefined
|
|
134
127
|
})) return false;
|
|
135
128
|
}
|
|
136
|
-
if (
|
|
129
|
+
if (activeOptions?.includeHash) return (shouldHydrateHash && !hasHydrated() ? "" : current.hash) === nextLocation.hash;
|
|
137
130
|
return true;
|
|
138
131
|
});
|
|
139
|
-
const doPreload = () => router.preloadRoute(
|
|
132
|
+
const doPreload = () => router.preloadRoute({
|
|
133
|
+
..._options(),
|
|
134
|
+
_builtLocation: next()
|
|
135
|
+
}).catch((err) => {
|
|
140
136
|
console.warn(err);
|
|
141
137
|
console.warn(preloadWarning);
|
|
142
138
|
});
|
|
@@ -153,33 +149,40 @@ function useLinkProps(options) {
|
|
|
153
149
|
Solid.createEffect(preload, (preloadValue) => {
|
|
154
150
|
if (hasRenderFetched) return;
|
|
155
151
|
if (!local.disabled && preloadValue === "render") {
|
|
156
|
-
doPreload();
|
|
152
|
+
Solid.untrack(() => doPreload());
|
|
157
153
|
hasRenderFetched = true;
|
|
158
154
|
}
|
|
159
155
|
});
|
|
160
|
-
if (Solid.untrack(externalLink))
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
156
|
+
if (Solid.untrack(externalLink)) {
|
|
157
|
+
const externalHref = Solid.untrack(externalLink);
|
|
158
|
+
return Solid.merge(propsSafeToSpread, { href: externalHref }, splitProps(local, [
|
|
159
|
+
"target",
|
|
160
|
+
"disabled",
|
|
161
|
+
"style",
|
|
162
|
+
"class",
|
|
163
|
+
"onClick",
|
|
164
|
+
"onBlur",
|
|
165
|
+
"onFocus",
|
|
166
|
+
"onMouseEnter",
|
|
167
|
+
"onMouseLeave",
|
|
168
|
+
"onMouseOut",
|
|
169
|
+
"onMouseOver",
|
|
170
|
+
"onTouchStart"
|
|
171
|
+
])[0]);
|
|
172
|
+
}
|
|
174
173
|
const handleClick = (e) => {
|
|
175
174
|
const elementTarget = e.currentTarget.getAttribute("target");
|
|
176
175
|
const effectiveTarget = local.target !== void 0 ? local.target : elementTarget;
|
|
177
176
|
if (!local.disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
|
|
178
177
|
e.preventDefault();
|
|
179
|
-
|
|
178
|
+
Solid.runWithOwner(null, () => {
|
|
179
|
+
setIsTransitioning(true);
|
|
180
|
+
});
|
|
180
181
|
const unsub = router.subscribe("onResolved", () => {
|
|
181
182
|
unsub();
|
|
182
|
-
|
|
183
|
+
Solid.runWithOwner(null, () => {
|
|
184
|
+
setIsTransitioning(false);
|
|
185
|
+
});
|
|
183
186
|
});
|
|
184
187
|
router.navigate({
|
|
185
188
|
..._options(),
|
|
@@ -218,62 +221,89 @@ function useLinkProps(options) {
|
|
|
218
221
|
timeoutMap.delete(eventTarget);
|
|
219
222
|
}
|
|
220
223
|
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const resolvedInactiveProps = () => isActive() ? {} : functionalUpdate(local.inactiveProps, {});
|
|
234
|
-
const resolvedClassName = () => [
|
|
235
|
-
local.class,
|
|
236
|
-
resolvedActiveProps().class,
|
|
237
|
-
resolvedInactiveProps().class
|
|
238
|
-
].filter(Boolean).join(" ");
|
|
239
|
-
const resolvedStyle = () => ({
|
|
240
|
-
...local.style,
|
|
241
|
-
...resolvedActiveProps().style,
|
|
242
|
-
...resolvedInactiveProps().style
|
|
243
|
-
});
|
|
244
|
-
return Solid.merge(propsSafeToSpread, resolvedActiveProps, resolvedInactiveProps, () => {
|
|
245
|
-
return {
|
|
224
|
+
const simpleStyling = Solid.createMemo(() => local.activeProps === STATIC_ACTIVE_PROPS_GET && local.inactiveProps === STATIC_INACTIVE_PROPS_GET && local.class === void 0 && local.style === void 0);
|
|
225
|
+
const onClick = createComposedHandler(() => local.onClick, handleClick);
|
|
226
|
+
const onBlur = createComposedHandler(() => local.onBlur, handleLeave);
|
|
227
|
+
const onFocus = createComposedHandler(() => local.onFocus, enqueueIntentPreload);
|
|
228
|
+
const onMouseEnter = createComposedHandler(() => local.onMouseEnter, enqueueIntentPreload);
|
|
229
|
+
const onMouseOver = createComposedHandler(() => local.onMouseOver, enqueueIntentPreload);
|
|
230
|
+
const onMouseLeave = createComposedHandler(() => local.onMouseLeave, handleLeave);
|
|
231
|
+
const onMouseOut = createComposedHandler(() => local.onMouseOut, handleLeave);
|
|
232
|
+
const onTouchStart = createComposedHandler(() => local.onTouchStart, handleTouchStart);
|
|
233
|
+
const resolvedProps = Solid.createMemo(() => {
|
|
234
|
+
const active = isActive();
|
|
235
|
+
const base = {
|
|
246
236
|
href: hrefOption()?.href,
|
|
247
237
|
ref: mergeRefs(setRef, _options().ref),
|
|
248
|
-
onClick
|
|
249
|
-
onBlur
|
|
250
|
-
onFocus
|
|
251
|
-
onMouseEnter
|
|
252
|
-
onMouseOver
|
|
253
|
-
onMouseLeave
|
|
254
|
-
onMouseOut
|
|
255
|
-
onTouchStart
|
|
238
|
+
onClick,
|
|
239
|
+
onBlur,
|
|
240
|
+
onFocus,
|
|
241
|
+
onMouseEnter,
|
|
242
|
+
onMouseOver,
|
|
243
|
+
onMouseLeave,
|
|
244
|
+
onMouseOut,
|
|
245
|
+
onTouchStart,
|
|
256
246
|
disabled: !!local.disabled,
|
|
257
247
|
target: local.target,
|
|
258
|
-
...
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
...
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
...
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
248
|
+
...local.disabled && STATIC_DISABLED_PROPS,
|
|
249
|
+
...isTransitioning() && STATIC_TRANSITIONING_ATTRIBUTES
|
|
250
|
+
};
|
|
251
|
+
if (simpleStyling()) return {
|
|
252
|
+
...base,
|
|
253
|
+
...active && STATIC_DEFAULT_ACTIVE_ATTRIBUTES
|
|
254
|
+
};
|
|
255
|
+
const activeProps = active ? functionalUpdate(local.activeProps, {}) ?? EMPTY_OBJECT : EMPTY_OBJECT;
|
|
256
|
+
const inactiveProps = active ? EMPTY_OBJECT : functionalUpdate(local.inactiveProps, {});
|
|
257
|
+
const style = {
|
|
258
|
+
...local.style,
|
|
259
|
+
...activeProps.style,
|
|
260
|
+
...inactiveProps.style
|
|
261
|
+
};
|
|
262
|
+
const className = [
|
|
263
|
+
local.class,
|
|
264
|
+
activeProps.class,
|
|
265
|
+
inactiveProps.class
|
|
266
|
+
].filter(Boolean).join(" ");
|
|
267
|
+
return {
|
|
268
|
+
...activeProps,
|
|
269
|
+
...inactiveProps,
|
|
270
|
+
...base,
|
|
271
|
+
...Object.keys(style).length ? { style } : void 0,
|
|
272
|
+
...className ? { class: className } : void 0,
|
|
273
|
+
...active && STATIC_ACTIVE_ATTRIBUTES
|
|
275
274
|
};
|
|
276
275
|
});
|
|
276
|
+
return Solid.merge(propsSafeToSpread, resolvedProps);
|
|
277
|
+
}
|
|
278
|
+
var STATIC_ACTIVE_PROPS = { class: "active" };
|
|
279
|
+
var STATIC_ACTIVE_PROPS_GET = () => STATIC_ACTIVE_PROPS;
|
|
280
|
+
var EMPTY_OBJECT = {};
|
|
281
|
+
var STATIC_INACTIVE_PROPS_GET = () => EMPTY_OBJECT;
|
|
282
|
+
var STATIC_DEFAULT_ACTIVE_ATTRIBUTES = {
|
|
283
|
+
class: "active",
|
|
284
|
+
"data-status": "active",
|
|
285
|
+
"aria-current": "page"
|
|
286
|
+
};
|
|
287
|
+
var STATIC_DISABLED_PROPS = {
|
|
288
|
+
role: "link",
|
|
289
|
+
"aria-disabled": "true"
|
|
290
|
+
};
|
|
291
|
+
var STATIC_ACTIVE_ATTRIBUTES = {
|
|
292
|
+
"data-status": "active",
|
|
293
|
+
"aria-current": "page"
|
|
294
|
+
};
|
|
295
|
+
var STATIC_TRANSITIONING_ATTRIBUTES = { "data-transitioning": "transitioning" };
|
|
296
|
+
/** Call a JSX.EventHandlerUnion with the event. */
|
|
297
|
+
function callHandler(event, handler) {
|
|
298
|
+
if (typeof handler === "function") handler(event);
|
|
299
|
+
else handler[0](handler[1], event);
|
|
300
|
+
return event.defaultPrevented;
|
|
301
|
+
}
|
|
302
|
+
function createComposedHandler(getHandler, fallback) {
|
|
303
|
+
return (event) => {
|
|
304
|
+
const handler = getHandler();
|
|
305
|
+
if (!handler || !callHandler(event, handler)) fallback(event);
|
|
306
|
+
};
|
|
277
307
|
}
|
|
278
308
|
function createLink(Comp) {
|
|
279
309
|
return (props) => createComponent(Link, mergeProps(props, { _asChild: Comp }));
|
|
@@ -303,8 +333,14 @@ var Link = (props) => {
|
|
|
303
333
|
return _el$;
|
|
304
334
|
})();
|
|
305
335
|
}
|
|
336
|
+
if (!local._asChild) return (() => {
|
|
337
|
+
var _el$3 = _tmpl$2();
|
|
338
|
+
spread(_el$3, linkProps, false, true);
|
|
339
|
+
insert(_el$3, children);
|
|
340
|
+
return _el$3;
|
|
341
|
+
})();
|
|
306
342
|
return createComponent(Dynamic, mergeProps({ get component() {
|
|
307
|
-
return
|
|
343
|
+
return local._asChild;
|
|
308
344
|
} }, linkProps, { get children() {
|
|
309
345
|
return children();
|
|
310
346
|
} }));
|
|
@@ -312,6 +348,12 @@ var Link = (props) => {
|
|
|
312
348
|
function isCtrlEvent(e) {
|
|
313
349
|
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
314
350
|
}
|
|
351
|
+
function isSafeInternal(to) {
|
|
352
|
+
if (typeof to !== "string") return false;
|
|
353
|
+
const zero = to.charCodeAt(0);
|
|
354
|
+
if (zero === 47) return to.charCodeAt(1) !== 47;
|
|
355
|
+
return zero === 46;
|
|
356
|
+
}
|
|
315
357
|
var linkOptions = (options) => {
|
|
316
358
|
return options;
|
|
317
359
|
};
|
package/dist/esm/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","names":["Solid","deepEqual","exactPathTest","functionalUpdate","isDangerousProtocol","preloadWarning","removeTrailingSlash","isServer","Dynamic","useRouterState","useRouter","useIntersectionObserver","useHydrated","AnyRouter","Constrain","LinkOptions","RegisteredRouter","RoutePaths","ValidateLinkOptions","ValidateLinkOptionsArray","mergeRefs","refs","Array","el","T","ref","splitProps","Record","props","keys","ReadonlyArray","TKey","Pick","Omit","_local","_rest","omit","timeoutMap","WeakMap","EventTarget","ReturnType","setTimeout","useLinkProps","TRouter","TFrom","options","UseLinkPropsOptions","TTo","TMaskFrom","TMaskTo","ComponentProps","router","isTransitioning","setIsTransitioning","createSignal","shouldHydrateHash","ssr","hasHydrated","hasRenderFetched","local","rest","merge","activeProps","class","inactiveProps","_","propsSafeToSpread","currentLocation","select","s","location","buildLocationKey","leaf","matches","length","search","hash","path","pathname","from","_options","result","next","createMemo","buildLocation","hrefOption","disabled","undefined","maskedLocation","publicHref","external","href","history","createHref","externalLink","_href","protocolAllowlist","process","env","NODE_ENV","console","warn","to","isSafeInternal","charCodeAt","URL","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","exact","testExact","basepath","currentPathSplit","split","nextPathSplit","pathIsFuzzyEqual","every","d","i","includeSearch","searchTest","partial","ignoreUndefined","explicitUndefined","includeHash","currentHash","doPreload","preloadRoute","catch","err","preloadViewportIoCallback","entry","IntersectionObserverEntry","isIntersecting","setRefSignal","Element","setRef","runWithOwner","rootMargin","untrack","createEffect","preloadValue","handleClick","e","MouseEvent","elementTarget","currentTarget","HTMLAnchorElement","SVGAElement","getAttribute","effectiveTarget","target","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","enqueueIntentPreload","FocusEvent","eventTarget","has","set","delete","handleTouchStart","TouchEvent","handleLeave","id","get","clearTimeout","callHandler","Event","event","TEvent","handler","JSX","EventHandlerUnion","composeEventHandlers","handlers","resolvedActiveProps","style","CSSProperties","resolvedInactiveProps","resolvedClassName","filter","Boolean","join","resolvedStyle","onClick","onBlur","onFocus","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onTouchStart","Object","c","role","ActiveLinkOptions","ActiveLinkOptionProps","TComp","ActiveLinkProps","Partial","LinkComponentSolidProps","key","LinkProps","LinkPropsChildren","children","state","ValidComponent","CreateLinkProps","LinkComponentProps","LinkComponent","TDefaultFrom","LinkComponentRoute","defaultFrom","createLink","Comp","_$createComponent","Link","_$mergeProps","_asChild","linkProps","resolvedChildren","ch","Function","svgLinkProps","_el$","_tmpl$","_el$2","firstChild","_$spread","_$insert","component","_$memo","metaKey","altKey","ctrlKey","shiftKey","LinkOptionsFnOptions","TOptions","LinkOptionsFn","linkOptions"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from '@solidjs/web'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useHydrated } from './ClientOnly'\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\nfunction mergeRefs<T>(\n ...refs: Array<((el: T) => void) | undefined>\n): (el: T) => void {\n return (el: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(el)\n }\n }\n }\n}\n\nfunction splitProps<T extends Record<string, any>, TKey extends keyof T>(\n props: T,\n keys: ReadonlyArray<TKey>,\n): [Pick<T, TKey>, Omit<T, TKey>] {\n const _local = {} as Pick<T, TKey>\n const _rest = {} as Omit<T, TKey>\n\n // A safe way to polyfill splitProps if native getter copy is too complex\n // is just to return [props, Solid.omit(props, keys)] but it modifies typing.\n // Actually, Solid.omit exists!\n // Note: Solid.omit uses rest params (...keys), so we must spread the array.\n return [props as any, Solid.omit(props, ...(keys as any)) as any]\n}\nconst timeoutMap = new WeakMap<EventTarget, ReturnType<typeof setTimeout>>()\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)\n const shouldHydrateHash = !isServer && !!router.options.ssr\n const hasHydrated = useHydrated()\n\n let hasRenderFetched = false\n\n const [local, rest] = splitProps(\n Solid.merge(\n {\n activeProps: () => ({ class: 'active' }),\n inactiveProps: () => ({}),\n },\n options,\n ),\n [\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n ],\n )\n\n const [_, propsSafeToSpread] = splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n ] as any)\n\n const currentLocation = useRouterState({\n select: (s) => s.location,\n })\n\n const buildLocationKey = useRouterState({\n select: (s) => {\n const leaf = s.matches[s.matches.length - 1]\n return {\n search: leaf?.search,\n hash: s.location.hash,\n path: leaf?.pathname, // path + params\n }\n },\n })\n\n const from = options.from\n\n const _options = () => {\n const result = {\n ...options,\n from,\n }\n return result\n }\n\n const next = Solid.createMemo(() => {\n buildLocationKey()\n return router.buildLocation(_options() as any)\n })\n\n const hrefOption = Solid.createMemo(() => {\n if (_options().disabled) return undefined\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const location = next().maskedLocation ?? next()\n const publicHref = location.publicHref\n const external = location.external\n\n if (external) {\n return { href: publicHref, external: true }\n }\n\n return {\n href: router.history.createHref(publicHref) || '/',\n external: false,\n }\n })\n\n const externalLink = Solid.createMemo(() => {\n const _href = hrefOption()\n if (_href?.external) {\n // Block dangerous protocols for external links\n if (isDangerousProtocol(_href.href, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${_href.href}`)\n }\n return undefined\n }\n return _href.href\n }\n const to = _options().to\n const isSafeInternal =\n typeof to === 'string' &&\n to.charCodeAt(0) === 47 && // '/'\n to.charCodeAt(1) !== 47 // but not '//'\n if (isSafeInternal) return undefined\n try {\n new URL(to as any)\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(to as string, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${to}`)\n }\n return undefined\n }\n return to\n } catch {}\n return undefined\n })\n\n const preload = Solid.createMemo(() => {\n if (_options().reloadDocument || externalLink()) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = Solid.createMemo(() => {\n if (externalLink()) return false\n if (local.activeOptions?.exact) {\n const testExact = exactPathTest(\n currentLocation().pathname,\n next().pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPathSplit = removeTrailingSlash(\n currentLocation().pathname,\n router.basepath,\n ).split('/')\n const nextPathSplit = removeTrailingSlash(\n next()?.pathname,\n router.basepath,\n )?.split('/')\n\n const pathIsFuzzyEqual = nextPathSplit?.every(\n (d, i) => d === currentPathSplit[i],\n )\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (local.activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(currentLocation().search, next().search, {\n partial: !local.activeOptions?.exact,\n ignoreUndefined: !local.activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (local.activeOptions?.includeHash) {\n const currentHash =\n shouldHydrateHash && !hasHydrated() ? '' : currentLocation().hash\n return currentHash === next().hash\n }\n return true\n })\n\n const doPreload = () =>\n router.preloadRoute(_options() as any).catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const [ref, setRefSignal] = Solid.createSignal<Element | null>(null)\n\n const setRef = (el: Element | null) => {\n Solid.runWithOwner(null, () => {\n setRefSignal(el)\n })\n }\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!local.disabled || !(Solid.untrack(preload) === 'viewport') },\n )\n\n Solid.createEffect(preload, (preloadValue) => {\n if (hasRenderFetched) {\n return\n }\n if (!local.disabled && preloadValue === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n if (Solid.untrack(externalLink)) {\n return Solid.merge(\n propsSafeToSpread,\n {\n // ref: mergeRefs(setRef, _options().ref),\n href: externalLink(),\n },\n splitProps(local, [\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n ).getAttribute('target')\n const effectiveTarget =\n local.target !== undefined ? local.target : elementTarget\n\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n setIsTransitioning(true)\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n setIsTransitioning(false)\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n router.navigate({\n ..._options(),\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n })\n }\n }\n\n const enqueueIntentPreload = (e: MouseEvent | FocusEvent) => {\n if (local.disabled || preload() !== 'intent') return\n\n if (!preloadDelay()) {\n doPreload()\n return\n }\n\n const eventTarget = e.currentTarget || e.target\n\n if (!eventTarget || timeoutMap.has(eventTarget)) return\n\n timeoutMap.set(\n eventTarget,\n setTimeout(() => {\n timeoutMap.delete(eventTarget)\n doPreload()\n }, preloadDelay()),\n )\n }\n\n const handleTouchStart = (_: TouchEvent) => {\n if (local.disabled || preload() !== 'intent') return\n doPreload()\n }\n\n const handleLeave = (e: MouseEvent | FocusEvent) => {\n if (local.disabled) return\n const eventTarget = e.currentTarget || e.target\n\n if (eventTarget) {\n const id = timeoutMap.get(eventTarget)\n clearTimeout(id)\n timeoutMap.delete(eventTarget)\n }\n }\n\n /** Call a JSX.EventHandlerUnion with the event. */\n function callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n ) {\n if (handler) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n }\n\n return event.defaultPrevented\n }\n\n function composeEventHandlers<T>(\n handlers: Array<Solid.JSX.EventHandlerUnion<T, any> | undefined>,\n ) {\n return (event: any) => {\n for (const handler of handlers) {\n callHandler(event, handler)\n }\n }\n }\n\n // Get the active props\n const resolvedActiveProps: () => Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n } = () =>\n isActive() ? (functionalUpdate(local.activeProps as any, {}) ?? {}) : {}\n\n // Get the inactive props\n const resolvedInactiveProps: () => Omit<\n Solid.ComponentProps<'a'>,\n 'style'\n > & { style?: Solid.JSX.CSSProperties } = () =>\n isActive() ? {} : functionalUpdate(local.inactiveProps, {})\n\n const resolvedClassName = () =>\n [local.class, resolvedActiveProps().class, resolvedInactiveProps().class]\n .filter(Boolean)\n .join(' ')\n\n const resolvedStyle = () => ({\n ...local.style,\n ...resolvedActiveProps().style,\n ...resolvedInactiveProps().style,\n })\n\n return Solid.merge(\n propsSafeToSpread,\n resolvedActiveProps,\n resolvedInactiveProps,\n () => {\n return {\n href: hrefOption()?.href,\n ref: mergeRefs(setRef, (_options() as any).ref),\n onClick: composeEventHandlers([local.onClick, handleClick]),\n onBlur: composeEventHandlers([local.onBlur, handleLeave]),\n onFocus: composeEventHandlers([local.onFocus, enqueueIntentPreload]),\n onMouseEnter: composeEventHandlers([\n local.onMouseEnter,\n enqueueIntentPreload,\n ]),\n onMouseOver: composeEventHandlers([\n local.onMouseOver,\n enqueueIntentPreload,\n ]),\n onMouseLeave: composeEventHandlers([local.onMouseLeave, handleLeave]),\n onMouseOut: composeEventHandlers([local.onMouseOut, handleLeave]),\n onTouchStart: composeEventHandlers([\n local.onTouchStart,\n handleTouchStart,\n ]),\n disabled: !!local.disabled,\n target: local.target,\n ...(() => {\n const s = resolvedStyle()\n return Object.keys(s).length ? { style: s } : {}\n })(),\n ...(() => {\n const c = resolvedClassName()\n return c ? { class: c } : {}\n })(),\n ...(local.disabled && {\n role: 'link',\n 'aria-disabled': 'true',\n }),\n ...(isActive() && { 'data-status': 'active', 'aria-current': 'page' }),\n ...(isTransitioning() && { 'data-transitioning': 'transitioning' }),\n }\n },\n ) as any\n}\n\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n LinkComponentSolidProps<TComp> & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | Solid.JSX.Element\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n : never\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentSolidProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Solid.JSX.Element\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = splitProps(props as typeof props & { _asChild: any }, [\n '_asChild',\n 'children',\n ])\n\n const [_, linkProps] = splitProps(useLinkProps(rest as unknown as any), [\n 'type',\n ])\n\n // Resolve children once using Solid.children to avoid\n // re-accessing the children getter (which in Solid 2.0 would\n // re-invoke createComponent each time for JSX children).\n const resolvedChildren = Solid.children(\n () => local.children as Solid.JSX.Element,\n )\n\n const children = () => {\n const ch = resolvedChildren()\n if (typeof ch === 'function') {\n return (ch as Function)({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n get isTransitioning() {\n return (linkProps as any)['data-transitioning'] === 'transitioning'\n },\n })\n }\n\n return ch\n }\n\n if (local._asChild === 'svg') {\n const [_, svgLinkProps] = splitProps(linkProps as any, ['class'])\n return (\n <svg>\n <a {...svgLinkProps}>{children()}</a>\n </svg>\n )\n }\n\n return (\n <Dynamic component={local._asChild ? local._asChild : 'a'} {...linkProps}>\n {children()}\n </Dynamic>\n )\n}\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"mappings":";;;;;;;;;;AA+BA,SAASoB,UACP,GAAGC,MACc;AACjB,SAAQE,OAAU;AAChB,OAAK,MAAME,OAAOJ,KAChB,KAAI,OAAOI,QAAQ,WACjBA,KAAIF,GAAG;;;AAMf,SAASG,WACPE,OACAC,MACgC;AAQhC,QAAO,CAACD,OAAc5B,MAAMoC,KAAKR,OAAO,GAAIC,KAAa,CAAQ;;AAEnE,IAAMQ,6BAAa,IAAIC,SAAqD;AAE5E,SAAgBI,aAOdG,SAC2B;CAC3B,MAAMM,SAASzC,WAAW;CAC1B,MAAM,CAAC0C,iBAAiBC,sBAAsBrD,MAAMsD,aAAa,MAAM;CACvE,MAAMC,oBAAoB,CAAChD,YAAY,CAAC,CAAC4C,OAAON,QAAQW;CACxD,MAAMC,cAAc7C,aAAa;CAEjC,IAAI8C,mBAAmB;CAEvB,MAAM,CAACC,OAAOC,QAAQlC,WACpB1B,MAAM6D,MACJ;EACEC,oBAAoB,EAAEC,OAAO,UAAU;EACvCC,sBAAsB,EAAE;EACzB,EACDnB,QACD,EACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;E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AM8K,SAAQ,EAAA,GAAG9K,MAAM8K,WAAW;IAAG,EAAMC,WAAS,EAAA,IAAAf,WAAA;AAAA,SACrEA,UAAU;IAAA,CAAA,CAAA;;AAKjB,SAAS/D,YAAYT,GAAe;AAClC,QAAO,CAAC,EAAEA,EAAEoG,WAAWpG,EAAEqG,UAAUrG,EAAEsG,WAAWtG,EAAEuG;;AAmBpD,IAAaI,eAAmCjN,YAAY;AAC1D,QAAOA"}
|
|
1
|
+
{"version":3,"file":"link.js","names":["Solid","deepEqual","exactPathTest","functionalUpdate","isDangerousProtocol","preloadWarning","removeTrailingSlash","isServer","Dynamic","useRouter","useIntersectionObserver","useHydrated","AnyRouter","Constrain","LinkOptions","RegisteredRouter","RoutePaths","ValidateLinkOptions","ValidateLinkOptionsArray","mergeRefs","refs","Array","el","T","ref","splitProps","Record","props","keys","ReadonlyArray","TKey","Pick","Omit","_local","_rest","omit","timeoutMap","WeakMap","EventTarget","ReturnType","setTimeout","useLinkProps","TRouter","TFrom","options","UseLinkPropsOptions","TTo","TMaskFrom","TMaskTo","ComponentProps","router","isTransitioning","setIsTransitioning","createSignal","shouldHydrateHash","ssr","hasHydrated","hasRenderFetched","local","rest","merge","activeProps","STATIC_ACTIVE_PROPS_GET","inactiveProps","STATIC_INACTIVE_PROPS_GET","_","propsSafeToSpread","currentLocation","createMemo","stores","location","state","undefined","equals","prev","next","href","_options","_fromLocation","untrack","buildLocation","hrefOption","disabled","maskedLocation","publicHref","external","history","createHref","externalLink","_href","protocolAllowlist","process","env","NODE_ENV","console","warn","to","safeInternal","isSafeInternal","indexOf","URL","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","current","nextLocation","exact","testExact","pathname","basepath","currentPath","nextPath","pathIsFuzzyEqual","startsWith","length","includeSearch","searchTest","search","partial","ignoreUndefined","explicitUndefined","includeHash","currentHash","hash","doPreload","preloadRoute","_builtLocation","catch","err","preloadViewportIoCallback","entry","IntersectionObserverEntry","isIntersecting","setRefSignal","Element","setRef","runWithOwner","rootMargin","createEffect","preloadValue","externalHref","handleClick","e","MouseEvent","elementTarget","currentTarget","HTMLAnchorElement","SVGAElement","getAttribute","effectiveTarget","target","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","enqueueIntentPreload","FocusEvent","eventTarget","has","set","delete","handleTouchStart","TouchEvent","handleLeave","id","get","clearTimeout","simpleStyling","class","style","onClick","createComposedHandler","onBlur","onFocus","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onTouchStart","ResolvedLinkStateProps","JSX","CSSProperties","resolvedProps","active","base","STATIC_DISABLED_PROPS","STATIC_TRANSITIONING_ATTRIBUTES","STATIC_DEFAULT_ACTIVE_ATTRIBUTES","EMPTY_OBJECT","className","filter","Boolean","join","Object","STATIC_ACTIVE_ATTRIBUTES","STATIC_ACTIVE_PROPS","role","callHandler","Event","event","TEvent","handler","EventHandlerUnion","getHandler","fallback","ActiveLinkOptions","ActiveLinkOptionProps","TComp","ActiveLinkProps","Partial","LinkComponentSolidProps","key","LinkProps","LinkPropsChildren","children","ValidComponent","CreateLinkProps","LinkComponentProps","LinkComponent","TDefaultFrom","LinkComponentRoute","defaultFrom","createLink","Comp","_$createComponent","Link","_$mergeProps","_asChild","linkProps","resolvedChildren","ch","Function","svgLinkProps","_el$","_tmpl$","_el$2","firstChild","_$spread","_$insert","_el$3","_tmpl$2","component","metaKey","altKey","ctrlKey","shiftKey","zero","charCodeAt","LinkOptionsFnOptions","TOptions","LinkOptionsFn","linkOptions"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from '@solidjs/web'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useHydrated } from './ClientOnly'\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\nfunction mergeRefs<T>(\n ...refs: Array<((el: T) => void) | undefined>\n): (el: T) => void {\n return (el: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(el)\n }\n }\n }\n}\n\nfunction splitProps<T extends Record<string, any>, TKey extends keyof T>(\n props: T,\n keys: ReadonlyArray<TKey>,\n): [Pick<T, TKey>, Omit<T, TKey>] {\n const _local = {} as Pick<T, TKey>\n const _rest = {} as Omit<T, TKey>\n\n // A safe way to polyfill splitProps if native getter copy is too complex\n // is just to return [props, Solid.omit(props, keys)] but it modifies typing.\n // Actually, Solid.omit exists!\n // Note: Solid.omit uses rest params (...keys), so we must spread the array.\n return [props as any, Solid.omit(props, ...(keys as any)) as any]\n}\nconst timeoutMap = new WeakMap<EventTarget, ReturnType<typeof setTimeout>>()\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)\n const shouldHydrateHash = !isServer && !!router.options.ssr\n const hasHydrated = useHydrated()\n\n let hasRenderFetched = false\n\n const [local, rest] = splitProps(\n Solid.merge(\n {\n activeProps: STATIC_ACTIVE_PROPS_GET,\n inactiveProps: STATIC_INACTIVE_PROPS_GET,\n },\n options,\n ),\n [\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n ],\n )\n\n const [_, propsSafeToSpread] = splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n ] as any)\n\n const currentLocation = Solid.createMemo(\n () => router.stores.location.state,\n undefined,\n { equals: (prev, next) => prev?.href === next?.href },\n )\n\n const _options = () => options\n\n const next = Solid.createMemo(() => {\n // Rebuild when inherited search/hash or the current route context changes.\n const _fromLocation = currentLocation()\n const options = { _fromLocation, ..._options() } as any\n // untrack because router-core will also access stores, which are signals in solid\n return Solid.untrack(() => router.buildLocation(options))\n })\n\n const hrefOption = Solid.createMemo(() => {\n if (_options().disabled) return undefined\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const location = next().maskedLocation ?? next()\n const publicHref = location.publicHref\n const external = location.external\n\n if (external) {\n return { href: publicHref, external: true }\n }\n\n return {\n href: router.history.createHref(publicHref) || '/',\n external: false,\n }\n })\n\n const externalLink = Solid.createMemo(() => {\n const _href = hrefOption()\n if (_href?.external) {\n // Block dangerous protocols for external links\n if (isDangerousProtocol(_href.href, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${_href.href}`)\n }\n return undefined\n }\n return _href.href\n }\n const to = _options().to\n const safeInternal = isSafeInternal(to)\n if (safeInternal) return undefined\n if (typeof to !== 'string' || to.indexOf(':') === -1) return undefined\n try {\n new URL(to as any)\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(to, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${to}`)\n }\n return undefined\n }\n return to\n } catch {}\n return undefined\n })\n\n const preload = Solid.createMemo(() => {\n if (_options().reloadDocument || externalLink()) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = Solid.createMemo(() => {\n if (externalLink()) return false\n const activeOptions = local.activeOptions\n const current = currentLocation()\n const nextLocation = next()\n\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n current.pathname,\n nextLocation.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPath = removeTrailingSlash(current.pathname, router.basepath)\n const nextPath = removeTrailingSlash(\n nextLocation.pathname,\n router.basepath,\n )\n\n const pathIsFuzzyEqual =\n currentPath.startsWith(nextPath) &&\n (currentPath.length === nextPath.length ||\n currentPath[nextPath.length] === '/')\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(current.search, nextLocation.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n const currentHash =\n shouldHydrateHash && !hasHydrated() ? '' : current.hash\n return currentHash === nextLocation.hash\n }\n return true\n })\n\n const doPreload = () =>\n router\n .preloadRoute({ ..._options(), _builtLocation: next() } as any)\n .catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const [ref, setRefSignal] = Solid.createSignal<Element | null>(null)\n\n const setRef = (el: Element | null) => {\n Solid.runWithOwner(null, () => {\n setRefSignal(el)\n })\n }\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!local.disabled || !(Solid.untrack(preload) === 'viewport') },\n )\n\n Solid.createEffect(preload, (preloadValue) => {\n if (hasRenderFetched) {\n return\n }\n if (!local.disabled && preloadValue === 'render') {\n Solid.untrack(() => doPreload())\n hasRenderFetched = true\n }\n })\n\n if (Solid.untrack(externalLink)) {\n const externalHref = Solid.untrack(externalLink)\n return Solid.merge(\n propsSafeToSpread,\n {\n // ref: mergeRefs(setRef, _options().ref),\n href: externalHref,\n },\n splitProps(local, [\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n ).getAttribute('target')\n const effectiveTarget =\n local.target !== undefined ? local.target : elementTarget\n\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n Solid.runWithOwner(null, () => {\n setIsTransitioning(true)\n })\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n Solid.runWithOwner(null, () => {\n setIsTransitioning(false)\n })\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n router.navigate({\n ..._options(),\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n })\n }\n }\n\n const enqueueIntentPreload = (e: MouseEvent | FocusEvent) => {\n if (local.disabled || preload() !== 'intent') return\n\n if (!preloadDelay()) {\n doPreload()\n return\n }\n\n const eventTarget = e.currentTarget || e.target\n\n if (!eventTarget || timeoutMap.has(eventTarget)) return\n\n timeoutMap.set(\n eventTarget,\n setTimeout(() => {\n timeoutMap.delete(eventTarget)\n doPreload()\n }, preloadDelay()),\n )\n }\n\n const handleTouchStart = (_: TouchEvent) => {\n if (local.disabled || preload() !== 'intent') return\n doPreload()\n }\n\n const handleLeave = (e: MouseEvent | FocusEvent) => {\n if (local.disabled) return\n const eventTarget = e.currentTarget || e.target\n\n if (eventTarget) {\n const id = timeoutMap.get(eventTarget)\n clearTimeout(id)\n timeoutMap.delete(eventTarget)\n }\n }\n\n const simpleStyling = Solid.createMemo(\n () =>\n local.activeProps === STATIC_ACTIVE_PROPS_GET &&\n local.inactiveProps === STATIC_INACTIVE_PROPS_GET &&\n local.class === undefined &&\n local.style === undefined,\n )\n\n const onClick = createComposedHandler(() => local.onClick, handleClick)\n const onBlur = createComposedHandler(() => local.onBlur, handleLeave)\n const onFocus = createComposedHandler(\n () => local.onFocus,\n enqueueIntentPreload,\n )\n const onMouseEnter = createComposedHandler(\n () => local.onMouseEnter,\n enqueueIntentPreload,\n )\n const onMouseOver = createComposedHandler(\n () => local.onMouseOver,\n enqueueIntentPreload,\n )\n const onMouseLeave = createComposedHandler(\n () => local.onMouseLeave,\n handleLeave,\n )\n const onMouseOut = createComposedHandler(() => local.onMouseOut, handleLeave)\n const onTouchStart = createComposedHandler(\n () => local.onTouchStart,\n handleTouchStart,\n )\n\n type ResolvedLinkStateProps = Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n }\n\n const resolvedProps = Solid.createMemo(() => {\n const active = isActive()\n\n const base = {\n href: hrefOption()?.href,\n ref: mergeRefs(setRef, _options().ref as any),\n onClick,\n onBlur,\n onFocus,\n onMouseEnter,\n onMouseOver,\n onMouseLeave,\n onMouseOut,\n onTouchStart,\n disabled: !!local.disabled,\n target: local.target,\n ...(local.disabled && STATIC_DISABLED_PROPS),\n ...(isTransitioning() && STATIC_TRANSITIONING_ATTRIBUTES),\n }\n\n if (simpleStyling()) {\n return {\n ...base,\n ...(active && STATIC_DEFAULT_ACTIVE_ATTRIBUTES),\n }\n }\n\n const activeProps: ResolvedLinkStateProps = active\n ? (functionalUpdate(local.activeProps as any, {}) ?? EMPTY_OBJECT)\n : EMPTY_OBJECT\n const inactiveProps: ResolvedLinkStateProps = active\n ? EMPTY_OBJECT\n : functionalUpdate(local.inactiveProps, {})\n const style = {\n ...local.style,\n ...activeProps.style,\n ...inactiveProps.style,\n }\n const className = [local.class, activeProps.class, inactiveProps.class]\n .filter(Boolean)\n .join(' ')\n\n return {\n ...activeProps,\n ...inactiveProps,\n ...base,\n ...(Object.keys(style).length ? { style } : undefined),\n ...(className ? { class: className } : undefined),\n ...(active && STATIC_ACTIVE_ATTRIBUTES),\n } as ResolvedLinkStateProps\n })\n\n return Solid.merge(propsSafeToSpread, resolvedProps) as any\n}\n\nconst STATIC_ACTIVE_PROPS = { class: 'active' }\nconst STATIC_ACTIVE_PROPS_GET = () => STATIC_ACTIVE_PROPS\nconst EMPTY_OBJECT = {}\nconst STATIC_INACTIVE_PROPS_GET = () => EMPTY_OBJECT\nconst STATIC_DEFAULT_ACTIVE_ATTRIBUTES = {\n class: 'active',\n 'data-status': 'active',\n 'aria-current': 'page',\n}\nconst STATIC_DISABLED_PROPS = {\n role: 'link',\n 'aria-disabled': 'true',\n}\nconst STATIC_ACTIVE_ATTRIBUTES = {\n 'data-status': 'active',\n 'aria-current': 'page',\n}\nconst STATIC_TRANSITIONING_ATTRIBUTES = {\n 'data-transitioning': 'transitioning',\n}\n\n/** Call a JSX.EventHandlerUnion with the event. */\nfunction callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.JSX.EventHandlerUnion<T, TEvent>,\n) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n return event.defaultPrevented\n}\n\nfunction createComposedHandler<T, TEvent extends Event>(\n getHandler: () => Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n fallback: (event: TEvent) => void,\n) {\n return (event: TEvent & { currentTarget: T; target: Element }) => {\n const handler = getHandler()\n if (!handler || !callHandler(event, handler)) fallback(event)\n }\n}\n\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n LinkComponentSolidProps<TComp> & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | Solid.JSX.Element\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n : never\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentSolidProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Solid.JSX.Element\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = splitProps(props as typeof props & { _asChild: any }, [\n '_asChild',\n 'children',\n ])\n\n const [_, linkProps] = splitProps(useLinkProps(rest as unknown as any), [\n 'type',\n ])\n\n // Resolve children once using Solid.children to avoid\n // re-accessing the children getter (which in Solid 2.0 would\n // re-invoke createComponent each time for JSX children).\n const resolvedChildren = Solid.children(\n () => local.children as Solid.JSX.Element,\n )\n\n const children = () => {\n const ch = resolvedChildren()\n if (typeof ch === 'function') {\n return (ch as Function)({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n get isTransitioning() {\n return (linkProps as any)['data-transitioning'] === 'transitioning'\n },\n })\n }\n\n return ch\n }\n\n if (local._asChild === 'svg') {\n const [_, svgLinkProps] = splitProps(linkProps as any, ['class'])\n return (\n <svg>\n <a {...svgLinkProps}>{children()}</a>\n </svg>\n )\n }\n\n if (!local._asChild) {\n return <a {...linkProps}>{children()}</a>\n }\n\n return (\n <Dynamic component={local._asChild as Solid.ValidComponent} {...linkProps}>\n {children()}\n </Dynamic>\n )\n}\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nfunction isSafeInternal(to: unknown) {\n if (typeof to !== 'string') return false\n const zero = to.charCodeAt(0)\n if (zero === 47) return to.charCodeAt(1) !== 47 // '/' but not '//'\n return zero === 46 // '.', '..', './', '../'\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"mappings":";;;;;;;;;AA8BA,SAASmB,UACP,GAAGC,MACc;AACjB,SAAQE,OAAU;AAChB,OAAK,MAAME,OAAOJ,KAChB,KAAI,OAAOI,QAAQ,WACjBA,KAAIF,GAAG;;;AAMf,SAASG,WACPE,OACAC,MACgC;AAQhC,QAAO,CAACD,OAAc3B,MAAMmC,KAAKR,OAAO,GAA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A,UAAU;IAAA,CAAA,CAAA;;AAKjB,SAASxE,YAAYT,GAAe;AAClC,QAAO,CAAC,EAAEA,EAAE6G,WAAW7G,EAAE8G,UAAU9G,EAAE+G,WAAW/G,EAAEgH;;AAGpD,SAAShK,eAAeF,IAAa;AACnC,KAAI,OAAOA,OAAO,SAAU,QAAO;CACnC,MAAMmK,OAAOnK,GAAGoK,WAAW,EAAE;AAC7B,KAAID,SAAS,GAAI,QAAOnK,GAAGoK,WAAW,EAAE,KAAK;AAC7C,QAAOD,SAAS;;AAmBlB,IAAaK,eAAmC5N,YAAY;AAC1D,QAAOA"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { AnyRouteMatch } from '@tanstack/router-core';
|
|
1
2
|
import * as Solid from 'solid-js';
|
|
2
|
-
export
|
|
3
|
-
|
|
3
|
+
export type NearestMatchContextValue = {
|
|
4
|
+
matchId: Solid.Accessor<string | undefined>;
|
|
5
|
+
routeId: Solid.Accessor<string | undefined>;
|
|
6
|
+
match: Solid.Accessor<AnyRouteMatch | undefined>;
|
|
7
|
+
hasPending: Solid.Accessor<boolean>;
|
|
8
|
+
};
|
|
9
|
+
export declare const nearestMatchContext: Solid.Context<NearestMatchContextValue>;
|
package/dist/esm/matchContext.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as Solid from "solid-js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var nearestMatchContext = Solid.createContext({
|
|
3
|
+
matchId: () => void 0,
|
|
4
|
+
routeId: () => void 0,
|
|
5
|
+
match: () => void 0,
|
|
6
|
+
hasPending: () => false
|
|
7
|
+
});
|
|
5
8
|
//#endregion
|
|
6
|
-
export {
|
|
9
|
+
export { nearestMatchContext };
|
|
7
10
|
|
|
8
11
|
//# sourceMappingURL=matchContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchContext.js","names":["Solid","
|
|
1
|
+
{"version":3,"file":"matchContext.js","names":["Solid","AnyRouteMatch","NearestMatchContextValue","matchId","Accessor","routeId","match","hasPending","defaultNearestMatchContext","undefined","nearestMatchContext","createContext"],"sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport type { AnyRouteMatch } from '@tanstack/router-core'\n\nexport type NearestMatchContextValue = {\n matchId: Solid.Accessor<string | undefined>\n routeId: Solid.Accessor<string | undefined>\n match: Solid.Accessor<AnyRouteMatch | undefined>\n hasPending: Solid.Accessor<boolean>\n}\n\nconst defaultNearestMatchContext: NearestMatchContextValue = {\n matchId: () => undefined,\n routeId: () => undefined,\n match: () => undefined,\n hasPending: () => false,\n}\n\nexport const nearestMatchContext =\n Solid.createContext<NearestMatchContextValue>(defaultNearestMatchContext)\n"],"mappings":";AAiBA,IAAaU,sBACXV,MAAMW,cARqD;CAC3DR,eAAeM,KAAAA;CACfJ,eAAeI,KAAAA;CACfH,aAAaG,KAAAA;CACbF,kBAAkB;CACnB,CAG0E"}
|
package/dist/esm/not-found.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NotFoundError } from '@tanstack/router-core';
|
|
2
|
-
import
|
|
2
|
+
import * as Solid from 'solid-js';
|
|
3
3
|
export declare function CatchNotFound(props: {
|
|
4
4
|
fallback?: (error: NotFoundError) => Solid.JSX.Element;
|
|
5
5
|
onCatch?: (error: Error) => void;
|
package/dist/esm/not-found.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { CatchBoundary } from "./CatchBoundary.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useRouter } from "./useRouter.js";
|
|
3
3
|
import { isNotFound } from "@tanstack/router-core";
|
|
4
4
|
import { createComponent, template } from "@solidjs/web";
|
|
5
|
+
import * as Solid from "solid-js";
|
|
5
6
|
//#region src/not-found.tsx
|
|
6
7
|
var _tmpl$ = /* @__PURE__ */ template(`<p>Not Found`);
|
|
7
8
|
function CatchNotFound(props) {
|
|
8
|
-
const
|
|
9
|
+
const router = useRouter();
|
|
10
|
+
const pathname = Solid.createMemo(() => router.stores.location.state.pathname);
|
|
11
|
+
const status = Solid.createMemo(() => router.stores.status.state);
|
|
9
12
|
return createComponent(CatchBoundary, {
|
|
10
|
-
getResetKey: () =>
|
|
13
|
+
getResetKey: () => `not-found-${pathname()}-${status()}`,
|
|
11
14
|
onCatch: (error) => {
|
|
12
15
|
if (isNotFound(error)) props.onCatch?.(error);
|
|
13
16
|
else throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.js","names":["isNotFound","
|
|
1
|
+
{"version":3,"file":"not-found.js","names":["isNotFound","Solid","CatchBoundary","useRouter","NotFoundError","CatchNotFound","props","fallback","error","JSX","Element","onCatch","Error","children","router","pathname","createMemo","stores","location","state","status","_$createComponent","getResetKey","errorComponent","DefaultGlobalNotFound","_tmpl$"],"sources":["../../src/not-found.tsx"],"sourcesContent":["import { isNotFound } from '@tanstack/router-core'\nimport * as Solid from 'solid-js'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport type { NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Solid.JSX.Element\n onCatch?: (error: Error) => void\n children: Solid.JSX.Element\n}) {\n const router = useRouter()\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const pathname = Solid.createMemo(() => router.stores.location.state.pathname)\n const status = Solid.createMemo(() => router.stores.status.state)\n\n return (\n <CatchBoundary\n getResetKey={() => `not-found-${pathname()}-${status()}`}\n onCatch={(error) => {\n if (isNotFound(error)) {\n props.onCatch?.(error)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"mappings":";;;;;;;AAMA,SAAgBK,cAAcC,OAI3B;CACD,MAAMQ,SAASX,WAAW;CAE1B,MAAMY,WAAWd,MAAMe,iBAAiBF,OAAOG,OAAOC,SAASC,MAAMJ,SAAS;CAC9E,MAAMK,SAASnB,MAAMe,iBAAiBF,OAAOG,OAAOG,OAAOD,MAAM;AAEjE,QAAAE,gBACGnB,eAAa;EACZoB,mBAAmB,aAAaP,UAAU,CAAA,GAAIK,QAAQ;EACtDT,UAAUH,UAAU;AAClB,OAAIR,WAAWQ,MAAM,CACnBF,OAAMK,UAAUH,MAAM;OAEtB,OAAMA;;EAGVe,iBAAiB,EAAEf,YAAY;AAC7B,OAAIR,WAAWQ,MAAM,CACnB,QAAOF,MAAMC,WAAWC,MAAM;OAE9B,OAAMA;;EAET,IAAAK,WAAA;AAAA,UAEAP,MAAMO;;EAAQ,CAAA;;AAKrB,SAAgBW,wBAAwB;AACtC,QAAAC,QAAA"}
|
package/dist/esm/router.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createFileRoute, createLazyFileRoute } from "./fileRoute.js";
|
|
2
|
+
import { getStoreFactory } from "./routerStores.js";
|
|
2
3
|
import { RouterCore } from "@tanstack/router-core";
|
|
3
4
|
//#region src/router.ts
|
|
4
5
|
var createRouter = (options) => {
|
|
@@ -6,7 +7,7 @@ var createRouter = (options) => {
|
|
|
6
7
|
};
|
|
7
8
|
var Router = class extends RouterCore {
|
|
8
9
|
constructor(options) {
|
|
9
|
-
super(options);
|
|
10
|
+
super(options, getStoreFactory);
|
|
10
11
|
}
|
|
11
12
|
};
|
|
12
13
|
if (typeof globalThis !== "undefined") {
|