@depup/tanstack__react-router 1.167.0-depup.0 → 1.167.3-depup.0

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.
Files changed (197) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/Asset.cjs +115 -174
  3. package/dist/cjs/Asset.cjs.map +1 -1
  4. package/dist/cjs/CatchBoundary.cjs +92 -108
  5. package/dist/cjs/CatchBoundary.cjs.map +1 -1
  6. package/dist/cjs/ClientOnly.cjs +47 -13
  7. package/dist/cjs/ClientOnly.cjs.map +1 -1
  8. package/dist/cjs/HeadContent.cjs +23 -12
  9. package/dist/cjs/HeadContent.cjs.map +1 -1
  10. package/dist/cjs/HeadContent.dev.cjs +33 -38
  11. package/dist/cjs/HeadContent.dev.cjs.map +1 -1
  12. package/dist/cjs/Match.cjs +190 -247
  13. package/dist/cjs/Match.cjs.map +1 -1
  14. package/dist/cjs/Matches.cjs +131 -118
  15. package/dist/cjs/Matches.cjs.map +1 -1
  16. package/dist/cjs/RouterProvider.cjs +43 -27
  17. package/dist/cjs/RouterProvider.cjs.map +1 -1
  18. package/dist/cjs/SafeFragment.cjs +9 -5
  19. package/dist/cjs/SafeFragment.cjs.map +1 -1
  20. package/dist/cjs/ScriptOnce.cjs +17 -19
  21. package/dist/cjs/ScriptOnce.cjs.map +1 -1
  22. package/dist/cjs/Scripts.cjs +56 -54
  23. package/dist/cjs/Scripts.cjs.map +1 -1
  24. package/dist/cjs/ScrollRestoration.cjs +26 -30
  25. package/dist/cjs/ScrollRestoration.cjs.map +1 -1
  26. package/dist/cjs/Transitioner.cjs +109 -116
  27. package/dist/cjs/Transitioner.cjs.map +1 -1
  28. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  29. package/dist/cjs/awaited.cjs +28 -43
  30. package/dist/cjs/awaited.cjs.map +1 -1
  31. package/dist/cjs/fileRoute.cjs +133 -95
  32. package/dist/cjs/fileRoute.cjs.map +1 -1
  33. package/dist/cjs/headContentUtils.cjs +144 -181
  34. package/dist/cjs/headContentUtils.cjs.map +1 -1
  35. package/dist/cjs/index.cjs +249 -178
  36. package/dist/cjs/index.dev.cjs +249 -178
  37. package/dist/cjs/lazyRouteComponent.cjs +52 -67
  38. package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
  39. package/dist/cjs/link.cjs +462 -556
  40. package/dist/cjs/link.cjs.map +1 -1
  41. package/dist/cjs/matchContext.cjs +9 -25
  42. package/dist/cjs/matchContext.cjs.map +1 -1
  43. package/dist/cjs/not-found.cjs +25 -32
  44. package/dist/cjs/not-found.cjs.map +1 -1
  45. package/dist/cjs/renderRouteNotFound.cjs +25 -19
  46. package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
  47. package/dist/cjs/route.cjs +258 -178
  48. package/dist/cjs/route.cjs.map +1 -1
  49. package/dist/cjs/router.cjs +29 -16
  50. package/dist/cjs/router.cjs.map +1 -1
  51. package/dist/cjs/routerContext.cjs +8 -22
  52. package/dist/cjs/routerContext.cjs.map +1 -1
  53. package/dist/cjs/scroll-restoration.cjs +23 -36
  54. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  55. package/dist/cjs/ssr/RouterClient.cjs +16 -22
  56. package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
  57. package/dist/cjs/ssr/RouterServer.cjs +10 -6
  58. package/dist/cjs/ssr/RouterServer.cjs.map +1 -1
  59. package/dist/cjs/ssr/client.cjs +10 -10
  60. package/dist/cjs/ssr/defaultRenderHandler.cjs +13 -14
  61. package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -1
  62. package/dist/cjs/ssr/defaultStreamHandler.cjs +14 -15
  63. package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -1
  64. package/dist/cjs/ssr/renderRouterToStream.cjs +51 -71
  65. package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
  66. package/dist/cjs/ssr/renderRouterToString.cjs +26 -29
  67. package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
  68. package/dist/cjs/ssr/server.cjs +18 -18
  69. package/dist/cjs/useBlocker.cjs +126 -162
  70. package/dist/cjs/useBlocker.cjs.map +1 -1
  71. package/dist/cjs/useCanGoBack.cjs +6 -5
  72. package/dist/cjs/useCanGoBack.cjs.map +1 -1
  73. package/dist/cjs/useLoaderData.cjs +24 -12
  74. package/dist/cjs/useLoaderData.cjs.map +1 -1
  75. package/dist/cjs/useLoaderDeps.cjs +23 -11
  76. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  77. package/dist/cjs/useLocation.cjs +17 -7
  78. package/dist/cjs/useLocation.cjs.map +1 -1
  79. package/dist/cjs/useMatch.cjs +25 -44
  80. package/dist/cjs/useMatch.cjs.map +1 -1
  81. package/dist/cjs/useNavigate.cjs +53 -43
  82. package/dist/cjs/useNavigate.cjs.map +1 -1
  83. package/dist/cjs/useParams.cjs +27 -14
  84. package/dist/cjs/useParams.cjs.map +1 -1
  85. package/dist/cjs/useRouteContext.cjs +9 -8
  86. package/dist/cjs/useRouteContext.cjs.map +1 -1
  87. package/dist/cjs/useRouter.cjs +23 -29
  88. package/dist/cjs/useRouter.cjs.map +1 -1
  89. package/dist/cjs/useRouterState.cjs +40 -35
  90. package/dist/cjs/useRouterState.cjs.map +1 -1
  91. package/dist/cjs/useSearch.cjs +26 -13
  92. package/dist/cjs/useSearch.cjs.map +1 -1
  93. package/dist/cjs/utils.cjs +81 -51
  94. package/dist/cjs/utils.cjs.map +1 -1
  95. package/dist/esm/Asset.js +112 -156
  96. package/dist/esm/Asset.js.map +1 -1
  97. package/dist/esm/CatchBoundary.js +90 -92
  98. package/dist/esm/CatchBoundary.js.map +1 -1
  99. package/dist/esm/ClientOnly.js +45 -14
  100. package/dist/esm/ClientOnly.js.map +1 -1
  101. package/dist/esm/HeadContent.dev.js +31 -21
  102. package/dist/esm/HeadContent.dev.js.map +1 -1
  103. package/dist/esm/HeadContent.js +20 -11
  104. package/dist/esm/HeadContent.js.map +1 -1
  105. package/dist/esm/Match.js +181 -226
  106. package/dist/esm/Match.js.map +1 -1
  107. package/dist/esm/Matches.js +125 -103
  108. package/dist/esm/Matches.js.map +1 -1
  109. package/dist/esm/RouterProvider.js +41 -28
  110. package/dist/esm/RouterProvider.js.map +1 -1
  111. package/dist/esm/SafeFragment.js +8 -6
  112. package/dist/esm/SafeFragment.js.map +1 -1
  113. package/dist/esm/ScriptOnce.js +15 -18
  114. package/dist/esm/ScriptOnce.js.map +1 -1
  115. package/dist/esm/Scripts.js +55 -54
  116. package/dist/esm/Scripts.js.map +1 -1
  117. package/dist/esm/ScrollRestoration.js +25 -31
  118. package/dist/esm/ScrollRestoration.js.map +1 -1
  119. package/dist/esm/Transitioner.js +106 -98
  120. package/dist/esm/Transitioner.js.map +1 -1
  121. package/dist/esm/awaited.js +26 -27
  122. package/dist/esm/awaited.js.map +1 -1
  123. package/dist/esm/fileRoute.js +127 -96
  124. package/dist/esm/fileRoute.js.map +1 -1
  125. package/dist/esm/headContentUtils.js +141 -163
  126. package/dist/esm/headContentUtils.js.map +1 -1
  127. package/dist/esm/index.dev.js +16 -117
  128. package/dist/esm/index.js +18 -118
  129. package/dist/esm/lazyRouteComponent.js +50 -50
  130. package/dist/esm/lazyRouteComponent.js.map +1 -1
  131. package/dist/esm/link.js +459 -541
  132. package/dist/esm/link.js.map +1 -1
  133. package/dist/esm/matchContext.js +8 -10
  134. package/dist/esm/matchContext.js.map +1 -1
  135. package/dist/esm/not-found.js +22 -32
  136. package/dist/esm/not-found.js.map +1 -1
  137. package/dist/esm/renderRouteNotFound.js +21 -18
  138. package/dist/esm/renderRouteNotFound.js.map +1 -1
  139. package/dist/esm/route.js +249 -180
  140. package/dist/esm/route.js.map +1 -1
  141. package/dist/esm/router.js +28 -17
  142. package/dist/esm/router.js.map +1 -1
  143. package/dist/esm/routerContext.js +7 -6
  144. package/dist/esm/routerContext.js.map +1 -1
  145. package/dist/esm/scroll-restoration.js +21 -35
  146. package/dist/esm/scroll-restoration.js.map +1 -1
  147. package/dist/esm/ssr/RouterClient.js +14 -21
  148. package/dist/esm/ssr/RouterClient.js.map +1 -1
  149. package/dist/esm/ssr/RouterServer.js +8 -6
  150. package/dist/esm/ssr/RouterServer.js.map +1 -1
  151. package/dist/esm/ssr/client.js +1 -4
  152. package/dist/esm/ssr/defaultRenderHandler.js +12 -13
  153. package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
  154. package/dist/esm/ssr/defaultStreamHandler.js +13 -14
  155. package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
  156. package/dist/esm/ssr/renderRouterToStream.js +48 -70
  157. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  158. package/dist/esm/ssr/renderRouterToString.js +24 -29
  159. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  160. package/dist/esm/ssr/server.js +3 -10
  161. package/dist/esm/useBlocker.js +124 -146
  162. package/dist/esm/useBlocker.js.map +1 -1
  163. package/dist/esm/useCanGoBack.js +6 -5
  164. package/dist/esm/useCanGoBack.js.map +1 -1
  165. package/dist/esm/useLoaderData.js +24 -12
  166. package/dist/esm/useLoaderData.js.map +1 -1
  167. package/dist/esm/useLoaderDeps.js +23 -11
  168. package/dist/esm/useLoaderDeps.js.map +1 -1
  169. package/dist/esm/useLocation.js +17 -7
  170. package/dist/esm/useLocation.js.map +1 -1
  171. package/dist/esm/useMatch.js +21 -26
  172. package/dist/esm/useMatch.js.map +1 -1
  173. package/dist/esm/useNavigate.js +50 -26
  174. package/dist/esm/useNavigate.js.map +1 -1
  175. package/dist/esm/useParams.js +27 -14
  176. package/dist/esm/useParams.js.map +1 -1
  177. package/dist/esm/useRouteContext.js +9 -8
  178. package/dist/esm/useRouteContext.js.map +1 -1
  179. package/dist/esm/useRouter.js +20 -12
  180. package/dist/esm/useRouter.js.map +1 -1
  181. package/dist/esm/useRouterState.js +38 -34
  182. package/dist/esm/useRouterState.js.map +1 -1
  183. package/dist/esm/useSearch.js +26 -13
  184. package/dist/esm/useSearch.js.map +1 -1
  185. package/dist/esm/utils.js +80 -39
  186. package/dist/esm/utils.js.map +1 -1
  187. package/dist/llms/rules/guide.d.ts +1 -1
  188. package/dist/llms/rules/guide.js +2 -2
  189. package/package.json +5 -5
  190. package/dist/cjs/index.cjs.map +0 -1
  191. package/dist/cjs/index.dev.cjs.map +0 -1
  192. package/dist/cjs/ssr/client.cjs.map +0 -1
  193. package/dist/cjs/ssr/server.cjs.map +0 -1
  194. package/dist/esm/index.dev.js.map +0 -1
  195. package/dist/esm/index.js.map +0 -1
  196. package/dist/esm/ssr/client.js.map +0 -1
  197. package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/link.js CHANGED
@@ -1,556 +1,474 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { flushSync } from "react-dom";
4
- import { isDangerousProtocol, exactPathTest, removeTrailingSlash, deepEqual, functionalUpdate, preloadWarning } from "@tanstack/router-core";
5
- import { isServer } from "@tanstack/router-core/isServer";
6
- import { useRouterState } from "./useRouterState.js";
7
- import { useRouter } from "./useRouter.js";
8
1
  import { useForwardedRef, useIntersectionObserver } from "./utils.js";
9
2
  import { useHydrated } from "./ClientOnly.js";
3
+ import { useRouter } from "./useRouter.js";
4
+ import { useRouterState } from "./useRouterState.js";
5
+ import { deepEqual, exactPathTest, functionalUpdate, isDangerousProtocol, preloadWarning, removeTrailingSlash } from "@tanstack/router-core";
6
+ import * as React$1 from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import { isServer } from "@tanstack/router-core/isServer";
9
+ import { flushSync } from "react-dom";
10
+ //#region src/link.tsx
11
+ /**
12
+ * Build anchor-like props for declarative navigation and preloading.
13
+ *
14
+ * Returns stable `href`, event handlers and accessibility props derived from
15
+ * router options and active state. Used internally by `Link` and custom links.
16
+ *
17
+ * Options cover `to`, `params`, `search`, `hash`, `state`, `preload`,
18
+ * `activeProps`, `inactiveProps`, and more.
19
+ *
20
+ * @returns React anchor props suitable for `<a>` or custom components.
21
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLinkPropsHook
22
+ */
10
23
  function useLinkProps(options, forwardedRef) {
11
- const router = useRouter();
12
- const innerRef = useForwardedRef(forwardedRef);
13
- const _isServer = isServer ?? router.isServer;
14
- const {
15
- // custom props
16
- activeProps,
17
- inactiveProps,
18
- activeOptions,
19
- to,
20
- preload: userPreload,
21
- preloadDelay: userPreloadDelay,
22
- hashScrollIntoView,
23
- replace,
24
- startTransition,
25
- resetScroll,
26
- viewTransition,
27
- // element props
28
- children,
29
- target,
30
- disabled,
31
- style,
32
- className,
33
- onClick,
34
- onBlur,
35
- onFocus,
36
- onMouseEnter,
37
- onMouseLeave,
38
- onTouchStart,
39
- ignoreBlocker,
40
- // prevent these from being returned
41
- params: _params,
42
- search: _search,
43
- hash: _hash,
44
- state: _state,
45
- mask: _mask,
46
- reloadDocument: _reloadDocument,
47
- unsafeRelative: _unsafeRelative,
48
- from: _from,
49
- _fromLocation,
50
- ...propsSafeToSpread
51
- } = options;
52
- if (_isServer) {
53
- const safeInternal = isSafeInternal(to);
54
- if (typeof to === "string" && !safeInternal && // Quick checks to avoid `new URL` in common internal-like cases
55
- to.indexOf(":") > -1) {
56
- try {
57
- new URL(to);
58
- if (isDangerousProtocol(to, router.protocolAllowlist)) {
59
- if (process.env.NODE_ENV !== "production") {
60
- console.warn(`Blocked Link with dangerous protocol: ${to}`);
61
- }
62
- return {
63
- ...propsSafeToSpread,
64
- ref: innerRef,
65
- href: void 0,
66
- ...children && { children },
67
- ...target && { target },
68
- ...disabled && { disabled },
69
- ...style && { style },
70
- ...className && { className }
71
- };
72
- }
73
- return {
74
- ...propsSafeToSpread,
75
- ref: innerRef,
76
- href: to,
77
- ...children && { children },
78
- ...target && { target },
79
- ...disabled && { disabled },
80
- ...style && { style },
81
- ...className && { className }
82
- };
83
- } catch {
84
- }
85
- }
86
- const next2 = router.buildLocation({ ...options, from: options.from });
87
- const hrefOptionPublicHref2 = next2.maskedLocation ? next2.maskedLocation.publicHref : next2.publicHref;
88
- const hrefOptionExternal2 = next2.maskedLocation ? next2.maskedLocation.external : next2.external;
89
- const hrefOption2 = getHrefOption(
90
- hrefOptionPublicHref2,
91
- hrefOptionExternal2,
92
- router.history,
93
- disabled
94
- );
95
- const externalLink2 = (() => {
96
- if (hrefOption2?.external) {
97
- if (isDangerousProtocol(hrefOption2.href, router.protocolAllowlist)) {
98
- if (process.env.NODE_ENV !== "production") {
99
- console.warn(
100
- `Blocked Link with dangerous protocol: ${hrefOption2.href}`
101
- );
102
- }
103
- return void 0;
104
- }
105
- return hrefOption2.href;
106
- }
107
- if (safeInternal) return void 0;
108
- if (typeof to === "string" && to.indexOf(":") > -1) {
109
- try {
110
- new URL(to);
111
- if (isDangerousProtocol(to, router.protocolAllowlist)) {
112
- if (process.env.NODE_ENV !== "production") {
113
- console.warn(`Blocked Link with dangerous protocol: ${to}`);
114
- }
115
- return void 0;
116
- }
117
- return to;
118
- } catch {
119
- }
120
- }
121
- return void 0;
122
- })();
123
- const isActive2 = (() => {
124
- if (externalLink2) return false;
125
- const currentLocation = router.state.location;
126
- const exact = activeOptions?.exact ?? false;
127
- if (exact) {
128
- const testExact = exactPathTest(
129
- currentLocation.pathname,
130
- next2.pathname,
131
- router.basepath
132
- );
133
- if (!testExact) {
134
- return false;
135
- }
136
- } else {
137
- const currentPathSplit = removeTrailingSlash(
138
- currentLocation.pathname,
139
- router.basepath
140
- );
141
- const nextPathSplit = removeTrailingSlash(
142
- next2.pathname,
143
- router.basepath
144
- );
145
- const pathIsFuzzyEqual = currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/");
146
- if (!pathIsFuzzyEqual) {
147
- return false;
148
- }
149
- }
150
- const includeSearch = activeOptions?.includeSearch ?? true;
151
- if (includeSearch) {
152
- if (currentLocation.search !== next2.search) {
153
- const currentSearchEmpty = !currentLocation.search || typeof currentLocation.search === "object" && Object.keys(currentLocation.search).length === 0;
154
- const nextSearchEmpty = !next2.search || typeof next2.search === "object" && Object.keys(next2.search).length === 0;
155
- if (!(currentSearchEmpty && nextSearchEmpty)) {
156
- const searchTest = deepEqual(currentLocation.search, next2.search, {
157
- partial: !exact,
158
- ignoreUndefined: !activeOptions?.explicitUndefined
159
- });
160
- if (!searchTest) {
161
- return false;
162
- }
163
- }
164
- }
165
- }
166
- if (activeOptions?.includeHash) {
167
- return false;
168
- }
169
- return true;
170
- })();
171
- if (externalLink2) {
172
- return {
173
- ...propsSafeToSpread,
174
- ref: innerRef,
175
- href: externalLink2,
176
- ...children && { children },
177
- ...target && { target },
178
- ...disabled && { disabled },
179
- ...style && { style },
180
- ...className && { className }
181
- };
182
- }
183
- const resolvedActiveProps2 = isActive2 ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
184
- const resolvedInactiveProps2 = isActive2 ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
185
- const resolvedStyle2 = (() => {
186
- const baseStyle = style;
187
- const activeStyle = resolvedActiveProps2.style;
188
- const inactiveStyle = resolvedInactiveProps2.style;
189
- if (!baseStyle && !activeStyle && !inactiveStyle) {
190
- return void 0;
191
- }
192
- if (baseStyle && !activeStyle && !inactiveStyle) {
193
- return baseStyle;
194
- }
195
- if (!baseStyle && activeStyle && !inactiveStyle) {
196
- return activeStyle;
197
- }
198
- if (!baseStyle && !activeStyle && inactiveStyle) {
199
- return inactiveStyle;
200
- }
201
- return {
202
- ...baseStyle,
203
- ...activeStyle,
204
- ...inactiveStyle
205
- };
206
- })();
207
- const resolvedClassName2 = (() => {
208
- const baseClassName = className;
209
- const activeClassName = resolvedActiveProps2.className;
210
- const inactiveClassName = resolvedInactiveProps2.className;
211
- if (!baseClassName && !activeClassName && !inactiveClassName) {
212
- return "";
213
- }
214
- let out = "";
215
- if (baseClassName) {
216
- out = baseClassName;
217
- }
218
- if (activeClassName) {
219
- out = out ? `${out} ${activeClassName}` : activeClassName;
220
- }
221
- if (inactiveClassName) {
222
- out = out ? `${out} ${inactiveClassName}` : inactiveClassName;
223
- }
224
- return out;
225
- })();
226
- return {
227
- ...propsSafeToSpread,
228
- ...resolvedActiveProps2,
229
- ...resolvedInactiveProps2,
230
- href: hrefOption2?.href,
231
- ref: innerRef,
232
- disabled: !!disabled,
233
- target,
234
- ...resolvedStyle2 && { style: resolvedStyle2 },
235
- ...resolvedClassName2 && { className: resolvedClassName2 },
236
- ...disabled && STATIC_DISABLED_PROPS,
237
- ...isActive2 && STATIC_ACTIVE_PROPS
238
- };
239
- }
240
- const isHydrated = useHydrated();
241
- const currentLocationState = useRouterState({
242
- select: (s) => {
243
- const leaf = s.matches[s.matches.length - 1];
244
- return {
245
- search: leaf?.search,
246
- hash: s.location.hash,
247
- path: leaf?.pathname
248
- // path + params
249
- };
250
- },
251
- structuralSharing: true
252
- });
253
- const from = options.from;
254
- const _options = React.useMemo(
255
- () => {
256
- return { ...options, from };
257
- },
258
- // eslint-disable-next-line react-hooks/exhaustive-deps
259
- [
260
- router,
261
- currentLocationState,
262
- from,
263
- options._fromLocation,
264
- options.hash,
265
- options.to,
266
- options.search,
267
- options.params,
268
- options.state,
269
- options.mask,
270
- options.unsafeRelative
271
- ]
272
- );
273
- const next = React.useMemo(
274
- () => router.buildLocation({ ..._options }),
275
- [router, _options]
276
- );
277
- const hrefOptionPublicHref = next.maskedLocation ? next.maskedLocation.publicHref : next.publicHref;
278
- const hrefOptionExternal = next.maskedLocation ? next.maskedLocation.external : next.external;
279
- const hrefOption = React.useMemo(
280
- () => getHrefOption(
281
- hrefOptionPublicHref,
282
- hrefOptionExternal,
283
- router.history,
284
- disabled
285
- ),
286
- [disabled, hrefOptionExternal, hrefOptionPublicHref, router.history]
287
- );
288
- const externalLink = React.useMemo(() => {
289
- if (hrefOption?.external) {
290
- if (isDangerousProtocol(hrefOption.href, router.protocolAllowlist)) {
291
- if (process.env.NODE_ENV !== "production") {
292
- console.warn(
293
- `Blocked Link with dangerous protocol: ${hrefOption.href}`
294
- );
295
- }
296
- return void 0;
297
- }
298
- return hrefOption.href;
299
- }
300
- const safeInternal = isSafeInternal(to);
301
- if (safeInternal) return void 0;
302
- if (typeof to !== "string" || to.indexOf(":") === -1) return void 0;
303
- try {
304
- new URL(to);
305
- if (isDangerousProtocol(to, router.protocolAllowlist)) {
306
- if (process.env.NODE_ENV !== "production") {
307
- console.warn(`Blocked Link with dangerous protocol: ${to}`);
308
- }
309
- return void 0;
310
- }
311
- return to;
312
- } catch {
313
- }
314
- return void 0;
315
- }, [to, hrefOption, router.protocolAllowlist]);
316
- const isActive = useRouterState({
317
- select: (s) => {
318
- if (externalLink) return false;
319
- if (activeOptions?.exact) {
320
- const testExact = exactPathTest(
321
- s.location.pathname,
322
- next.pathname,
323
- router.basepath
324
- );
325
- if (!testExact) {
326
- return false;
327
- }
328
- } else {
329
- const currentPathSplit = removeTrailingSlash(
330
- s.location.pathname,
331
- router.basepath
332
- );
333
- const nextPathSplit = removeTrailingSlash(
334
- next.pathname,
335
- router.basepath
336
- );
337
- const pathIsFuzzyEqual = currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/");
338
- if (!pathIsFuzzyEqual) {
339
- return false;
340
- }
341
- }
342
- if (activeOptions?.includeSearch ?? true) {
343
- const searchTest = deepEqual(s.location.search, next.search, {
344
- partial: !activeOptions?.exact,
345
- ignoreUndefined: !activeOptions?.explicitUndefined
346
- });
347
- if (!searchTest) {
348
- return false;
349
- }
350
- }
351
- if (activeOptions?.includeHash) {
352
- return isHydrated && s.location.hash === next.hash;
353
- }
354
- return true;
355
- }
356
- });
357
- const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
358
- const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
359
- const resolvedClassName = [
360
- className,
361
- resolvedActiveProps.className,
362
- resolvedInactiveProps.className
363
- ].filter(Boolean).join(" ");
364
- const resolvedStyle = (style || resolvedActiveProps.style || resolvedInactiveProps.style) && {
365
- ...style,
366
- ...resolvedActiveProps.style,
367
- ...resolvedInactiveProps.style
368
- };
369
- const [isTransitioning, setIsTransitioning] = React.useState(false);
370
- const hasRenderFetched = React.useRef(false);
371
- const preload = options.reloadDocument || externalLink ? false : userPreload ?? router.options.defaultPreload;
372
- const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
373
- const doPreload = React.useCallback(() => {
374
- router.preloadRoute({ ..._options, _builtLocation: next }).catch((err) => {
375
- console.warn(err);
376
- console.warn(preloadWarning);
377
- });
378
- }, [router, _options, next]);
379
- const preloadViewportIoCallback = React.useCallback(
380
- (entry) => {
381
- if (entry?.isIntersecting) {
382
- doPreload();
383
- }
384
- },
385
- [doPreload]
386
- );
387
- useIntersectionObserver(
388
- innerRef,
389
- preloadViewportIoCallback,
390
- intersectionObserverOptions,
391
- { disabled: !!disabled || !(preload === "viewport") }
392
- );
393
- React.useEffect(() => {
394
- if (hasRenderFetched.current) {
395
- return;
396
- }
397
- if (!disabled && preload === "render") {
398
- doPreload();
399
- hasRenderFetched.current = true;
400
- }
401
- }, [disabled, doPreload, preload]);
402
- const handleClick = (e) => {
403
- const elementTarget = e.currentTarget.getAttribute("target");
404
- const effectiveTarget = target !== void 0 ? target : elementTarget;
405
- if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
406
- e.preventDefault();
407
- flushSync(() => {
408
- setIsTransitioning(true);
409
- });
410
- const unsub = router.subscribe("onResolved", () => {
411
- unsub();
412
- setIsTransitioning(false);
413
- });
414
- router.navigate({
415
- ..._options,
416
- replace,
417
- resetScroll,
418
- hashScrollIntoView,
419
- startTransition,
420
- viewTransition,
421
- ignoreBlocker
422
- });
423
- }
424
- };
425
- if (externalLink) {
426
- return {
427
- ...propsSafeToSpread,
428
- ref: innerRef,
429
- href: externalLink,
430
- ...children && { children },
431
- ...target && { target },
432
- ...disabled && { disabled },
433
- ...style && { style },
434
- ...className && { className },
435
- ...onClick && { onClick },
436
- ...onBlur && { onBlur },
437
- ...onFocus && { onFocus },
438
- ...onMouseEnter && { onMouseEnter },
439
- ...onMouseLeave && { onMouseLeave },
440
- ...onTouchStart && { onTouchStart }
441
- };
442
- }
443
- const enqueueIntentPreload = (e) => {
444
- if (disabled || preload !== "intent") return;
445
- if (!preloadDelay) {
446
- doPreload();
447
- return;
448
- }
449
- const eventTarget = e.currentTarget;
450
- if (timeoutMap.has(eventTarget)) {
451
- return;
452
- }
453
- const id = setTimeout(() => {
454
- timeoutMap.delete(eventTarget);
455
- doPreload();
456
- }, preloadDelay);
457
- timeoutMap.set(eventTarget, id);
458
- };
459
- const handleTouchStart = (_) => {
460
- if (disabled || preload !== "intent") return;
461
- doPreload();
462
- };
463
- const handleLeave = (e) => {
464
- if (disabled || !preload || !preloadDelay) return;
465
- const eventTarget = e.currentTarget;
466
- const id = timeoutMap.get(eventTarget);
467
- if (id) {
468
- clearTimeout(id);
469
- timeoutMap.delete(eventTarget);
470
- }
471
- };
472
- return {
473
- ...propsSafeToSpread,
474
- ...resolvedActiveProps,
475
- ...resolvedInactiveProps,
476
- href: hrefOption?.href,
477
- ref: innerRef,
478
- onClick: composeHandlers([onClick, handleClick]),
479
- onBlur: composeHandlers([onBlur, handleLeave]),
480
- onFocus: composeHandlers([onFocus, enqueueIntentPreload]),
481
- onMouseEnter: composeHandlers([onMouseEnter, enqueueIntentPreload]),
482
- onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
483
- onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
484
- disabled: !!disabled,
485
- target,
486
- ...resolvedStyle && { style: resolvedStyle },
487
- ...resolvedClassName && { className: resolvedClassName },
488
- ...disabled && STATIC_DISABLED_PROPS,
489
- ...isActive && STATIC_ACTIVE_PROPS,
490
- ...isHydrated && isTransitioning && STATIC_TRANSITIONING_PROPS
491
- };
24
+ const router = useRouter();
25
+ const innerRef = useForwardedRef(forwardedRef);
26
+ const _isServer = isServer ?? router.isServer;
27
+ const { activeProps, inactiveProps, activeOptions, to, preload: userPreload, preloadDelay: userPreloadDelay, hashScrollIntoView, replace, startTransition, resetScroll, viewTransition, children, target, disabled, style, className, onClick, onBlur, onFocus, onMouseEnter, onMouseLeave, onTouchStart, ignoreBlocker, params: _params, search: _search, hash: _hash, state: _state, mask: _mask, reloadDocument: _reloadDocument, unsafeRelative: _unsafeRelative, from: _from, _fromLocation, ...propsSafeToSpread } = options;
28
+ if (_isServer) {
29
+ const safeInternal = isSafeInternal(to);
30
+ if (typeof to === "string" && !safeInternal && to.indexOf(":") > -1) try {
31
+ new URL(to);
32
+ if (isDangerousProtocol(to, router.protocolAllowlist)) {
33
+ if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${to}`);
34
+ return {
35
+ ...propsSafeToSpread,
36
+ ref: innerRef,
37
+ href: void 0,
38
+ ...children && { children },
39
+ ...target && { target },
40
+ ...disabled && { disabled },
41
+ ...style && { style },
42
+ ...className && { className }
43
+ };
44
+ }
45
+ return {
46
+ ...propsSafeToSpread,
47
+ ref: innerRef,
48
+ href: to,
49
+ ...children && { children },
50
+ ...target && { target },
51
+ ...disabled && { disabled },
52
+ ...style && { style },
53
+ ...className && { className }
54
+ };
55
+ } catch {}
56
+ const next = router.buildLocation({
57
+ ...options,
58
+ from: options.from
59
+ });
60
+ const hrefOption = getHrefOption(next.maskedLocation ? next.maskedLocation.publicHref : next.publicHref, next.maskedLocation ? next.maskedLocation.external : next.external, router.history, disabled);
61
+ const externalLink = (() => {
62
+ if (hrefOption?.external) {
63
+ if (isDangerousProtocol(hrefOption.href, router.protocolAllowlist)) {
64
+ if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${hrefOption.href}`);
65
+ return;
66
+ }
67
+ return hrefOption.href;
68
+ }
69
+ if (safeInternal) return void 0;
70
+ if (typeof to === "string" && to.indexOf(":") > -1) try {
71
+ new URL(to);
72
+ if (isDangerousProtocol(to, router.protocolAllowlist)) {
73
+ if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${to}`);
74
+ return;
75
+ }
76
+ return to;
77
+ } catch {}
78
+ })();
79
+ const isActive = (() => {
80
+ if (externalLink) return false;
81
+ const currentLocation = router.state.location;
82
+ const exact = activeOptions?.exact ?? false;
83
+ if (exact) {
84
+ if (!exactPathTest(currentLocation.pathname, next.pathname, router.basepath)) return false;
85
+ } else {
86
+ const currentPathSplit = removeTrailingSlash(currentLocation.pathname, router.basepath);
87
+ const nextPathSplit = removeTrailingSlash(next.pathname, router.basepath);
88
+ if (!(currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/"))) return false;
89
+ }
90
+ if (activeOptions?.includeSearch ?? true) {
91
+ if (currentLocation.search !== next.search) {
92
+ const currentSearchEmpty = !currentLocation.search || typeof currentLocation.search === "object" && Object.keys(currentLocation.search).length === 0;
93
+ const nextSearchEmpty = !next.search || typeof next.search === "object" && Object.keys(next.search).length === 0;
94
+ if (!(currentSearchEmpty && nextSearchEmpty)) {
95
+ if (!deepEqual(currentLocation.search, next.search, {
96
+ partial: !exact,
97
+ ignoreUndefined: !activeOptions?.explicitUndefined
98
+ })) return false;
99
+ }
100
+ }
101
+ }
102
+ if (activeOptions?.includeHash) return false;
103
+ return true;
104
+ })();
105
+ if (externalLink) return {
106
+ ...propsSafeToSpread,
107
+ ref: innerRef,
108
+ href: externalLink,
109
+ ...children && { children },
110
+ ...target && { target },
111
+ ...disabled && { disabled },
112
+ ...style && { style },
113
+ ...className && { className }
114
+ };
115
+ const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
116
+ const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
117
+ const resolvedStyle = (() => {
118
+ const baseStyle = style;
119
+ const activeStyle = resolvedActiveProps.style;
120
+ const inactiveStyle = resolvedInactiveProps.style;
121
+ if (!baseStyle && !activeStyle && !inactiveStyle) return;
122
+ if (baseStyle && !activeStyle && !inactiveStyle) return baseStyle;
123
+ if (!baseStyle && activeStyle && !inactiveStyle) return activeStyle;
124
+ if (!baseStyle && !activeStyle && inactiveStyle) return inactiveStyle;
125
+ return {
126
+ ...baseStyle,
127
+ ...activeStyle,
128
+ ...inactiveStyle
129
+ };
130
+ })();
131
+ const resolvedClassName = (() => {
132
+ const baseClassName = className;
133
+ const activeClassName = resolvedActiveProps.className;
134
+ const inactiveClassName = resolvedInactiveProps.className;
135
+ if (!baseClassName && !activeClassName && !inactiveClassName) return "";
136
+ let out = "";
137
+ if (baseClassName) out = baseClassName;
138
+ if (activeClassName) out = out ? `${out} ${activeClassName}` : activeClassName;
139
+ if (inactiveClassName) out = out ? `${out} ${inactiveClassName}` : inactiveClassName;
140
+ return out;
141
+ })();
142
+ return {
143
+ ...propsSafeToSpread,
144
+ ...resolvedActiveProps,
145
+ ...resolvedInactiveProps,
146
+ href: hrefOption?.href,
147
+ ref: innerRef,
148
+ disabled: !!disabled,
149
+ target,
150
+ ...resolvedStyle && { style: resolvedStyle },
151
+ ...resolvedClassName && { className: resolvedClassName },
152
+ ...disabled && STATIC_DISABLED_PROPS,
153
+ ...isActive && STATIC_ACTIVE_PROPS
154
+ };
155
+ }
156
+ const isHydrated = useHydrated();
157
+ const currentLocationState = useRouterState({
158
+ select: (s) => {
159
+ const leaf = s.matches[s.matches.length - 1];
160
+ return {
161
+ search: leaf?.search,
162
+ hash: s.location.hash,
163
+ path: leaf?.pathname
164
+ };
165
+ },
166
+ structuralSharing: true
167
+ });
168
+ const from = options.from;
169
+ const _options = React$1.useMemo(() => {
170
+ return {
171
+ ...options,
172
+ from
173
+ };
174
+ }, [
175
+ router,
176
+ currentLocationState,
177
+ from,
178
+ options._fromLocation,
179
+ options.hash,
180
+ options.to,
181
+ options.search,
182
+ options.params,
183
+ options.state,
184
+ options.mask,
185
+ options.unsafeRelative
186
+ ]);
187
+ const next = React$1.useMemo(() => router.buildLocation({ ..._options }), [router, _options]);
188
+ const hrefOptionPublicHref = next.maskedLocation ? next.maskedLocation.publicHref : next.publicHref;
189
+ const hrefOptionExternal = next.maskedLocation ? next.maskedLocation.external : next.external;
190
+ const hrefOption = React$1.useMemo(() => getHrefOption(hrefOptionPublicHref, hrefOptionExternal, router.history, disabled), [
191
+ disabled,
192
+ hrefOptionExternal,
193
+ hrefOptionPublicHref,
194
+ router.history
195
+ ]);
196
+ const externalLink = React$1.useMemo(() => {
197
+ if (hrefOption?.external) {
198
+ if (isDangerousProtocol(hrefOption.href, router.protocolAllowlist)) {
199
+ if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${hrefOption.href}`);
200
+ return;
201
+ }
202
+ return hrefOption.href;
203
+ }
204
+ if (isSafeInternal(to)) return void 0;
205
+ if (typeof to !== "string" || to.indexOf(":") === -1) return void 0;
206
+ try {
207
+ new URL(to);
208
+ if (isDangerousProtocol(to, router.protocolAllowlist)) {
209
+ if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${to}`);
210
+ return;
211
+ }
212
+ return to;
213
+ } catch {}
214
+ }, [
215
+ to,
216
+ hrefOption,
217
+ router.protocolAllowlist
218
+ ]);
219
+ const isActive = useRouterState({ select: (s) => {
220
+ if (externalLink) return false;
221
+ if (activeOptions?.exact) {
222
+ if (!exactPathTest(s.location.pathname, next.pathname, router.basepath)) return false;
223
+ } else {
224
+ const currentPathSplit = removeTrailingSlash(s.location.pathname, router.basepath);
225
+ const nextPathSplit = removeTrailingSlash(next.pathname, router.basepath);
226
+ if (!(currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/"))) return false;
227
+ }
228
+ if (activeOptions?.includeSearch ?? true) {
229
+ if (!deepEqual(s.location.search, next.search, {
230
+ partial: !activeOptions?.exact,
231
+ ignoreUndefined: !activeOptions?.explicitUndefined
232
+ })) return false;
233
+ }
234
+ if (activeOptions?.includeHash) return isHydrated && s.location.hash === next.hash;
235
+ return true;
236
+ } });
237
+ const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
238
+ const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
239
+ const resolvedClassName = [
240
+ className,
241
+ resolvedActiveProps.className,
242
+ resolvedInactiveProps.className
243
+ ].filter(Boolean).join(" ");
244
+ const resolvedStyle = (style || resolvedActiveProps.style || resolvedInactiveProps.style) && {
245
+ ...style,
246
+ ...resolvedActiveProps.style,
247
+ ...resolvedInactiveProps.style
248
+ };
249
+ const [isTransitioning, setIsTransitioning] = React$1.useState(false);
250
+ const hasRenderFetched = React$1.useRef(false);
251
+ const preload = options.reloadDocument || externalLink ? false : userPreload ?? router.options.defaultPreload;
252
+ const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
253
+ const doPreload = React$1.useCallback(() => {
254
+ router.preloadRoute({
255
+ ..._options,
256
+ _builtLocation: next
257
+ }).catch((err) => {
258
+ console.warn(err);
259
+ console.warn(preloadWarning);
260
+ });
261
+ }, [
262
+ router,
263
+ _options,
264
+ next
265
+ ]);
266
+ useIntersectionObserver(innerRef, React$1.useCallback((entry) => {
267
+ if (entry?.isIntersecting) doPreload();
268
+ }, [doPreload]), intersectionObserverOptions, { disabled: !!disabled || !(preload === "viewport") });
269
+ React$1.useEffect(() => {
270
+ if (hasRenderFetched.current) return;
271
+ if (!disabled && preload === "render") {
272
+ doPreload();
273
+ hasRenderFetched.current = true;
274
+ }
275
+ }, [
276
+ disabled,
277
+ doPreload,
278
+ preload
279
+ ]);
280
+ const handleClick = (e) => {
281
+ const elementTarget = e.currentTarget.getAttribute("target");
282
+ const effectiveTarget = target !== void 0 ? target : elementTarget;
283
+ if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
284
+ e.preventDefault();
285
+ flushSync(() => {
286
+ setIsTransitioning(true);
287
+ });
288
+ const unsub = router.subscribe("onResolved", () => {
289
+ unsub();
290
+ setIsTransitioning(false);
291
+ });
292
+ router.navigate({
293
+ ..._options,
294
+ replace,
295
+ resetScroll,
296
+ hashScrollIntoView,
297
+ startTransition,
298
+ viewTransition,
299
+ ignoreBlocker
300
+ });
301
+ }
302
+ };
303
+ if (externalLink) return {
304
+ ...propsSafeToSpread,
305
+ ref: innerRef,
306
+ href: externalLink,
307
+ ...children && { children },
308
+ ...target && { target },
309
+ ...disabled && { disabled },
310
+ ...style && { style },
311
+ ...className && { className },
312
+ ...onClick && { onClick },
313
+ ...onBlur && { onBlur },
314
+ ...onFocus && { onFocus },
315
+ ...onMouseEnter && { onMouseEnter },
316
+ ...onMouseLeave && { onMouseLeave },
317
+ ...onTouchStart && { onTouchStart }
318
+ };
319
+ const enqueueIntentPreload = (e) => {
320
+ if (disabled || preload !== "intent") return;
321
+ if (!preloadDelay) {
322
+ doPreload();
323
+ return;
324
+ }
325
+ const eventTarget = e.currentTarget;
326
+ if (timeoutMap.has(eventTarget)) return;
327
+ const id = setTimeout(() => {
328
+ timeoutMap.delete(eventTarget);
329
+ doPreload();
330
+ }, preloadDelay);
331
+ timeoutMap.set(eventTarget, id);
332
+ };
333
+ const handleTouchStart = (_) => {
334
+ if (disabled || preload !== "intent") return;
335
+ doPreload();
336
+ };
337
+ const handleLeave = (e) => {
338
+ if (disabled || !preload || !preloadDelay) return;
339
+ const eventTarget = e.currentTarget;
340
+ const id = timeoutMap.get(eventTarget);
341
+ if (id) {
342
+ clearTimeout(id);
343
+ timeoutMap.delete(eventTarget);
344
+ }
345
+ };
346
+ return {
347
+ ...propsSafeToSpread,
348
+ ...resolvedActiveProps,
349
+ ...resolvedInactiveProps,
350
+ href: hrefOption?.href,
351
+ ref: innerRef,
352
+ onClick: composeHandlers([onClick, handleClick]),
353
+ onBlur: composeHandlers([onBlur, handleLeave]),
354
+ onFocus: composeHandlers([onFocus, enqueueIntentPreload]),
355
+ onMouseEnter: composeHandlers([onMouseEnter, enqueueIntentPreload]),
356
+ onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
357
+ onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
358
+ disabled: !!disabled,
359
+ target,
360
+ ...resolvedStyle && { style: resolvedStyle },
361
+ ...resolvedClassName && { className: resolvedClassName },
362
+ ...disabled && STATIC_DISABLED_PROPS,
363
+ ...isActive && STATIC_ACTIVE_PROPS,
364
+ ...isHydrated && isTransitioning && STATIC_TRANSITIONING_PROPS
365
+ };
492
366
  }
493
- const STATIC_EMPTY_OBJECT = {};
494
- const STATIC_ACTIVE_OBJECT = { className: "active" };
495
- const STATIC_DISABLED_PROPS = { role: "link", "aria-disabled": true };
496
- const STATIC_ACTIVE_PROPS = { "data-status": "active", "aria-current": "page" };
497
- const STATIC_TRANSITIONING_PROPS = { "data-transitioning": "transitioning" };
498
- const timeoutMap = /* @__PURE__ */ new WeakMap();
499
- const intersectionObserverOptions = {
500
- rootMargin: "100px"
367
+ var STATIC_EMPTY_OBJECT = {};
368
+ var STATIC_ACTIVE_OBJECT = { className: "active" };
369
+ var STATIC_DISABLED_PROPS = {
370
+ role: "link",
371
+ "aria-disabled": true
372
+ };
373
+ var STATIC_ACTIVE_PROPS = {
374
+ "data-status": "active",
375
+ "aria-current": "page"
501
376
  };
502
- const composeHandlers = (handlers) => (e) => {
503
- for (const handler of handlers) {
504
- if (!handler) continue;
505
- if (e.defaultPrevented) return;
506
- handler(e);
507
- }
377
+ var STATIC_TRANSITIONING_PROPS = { "data-transitioning": "transitioning" };
378
+ var timeoutMap = /* @__PURE__ */ new WeakMap();
379
+ var intersectionObserverOptions = { rootMargin: "100px" };
380
+ var composeHandlers = (handlers) => (e) => {
381
+ for (const handler of handlers) {
382
+ if (!handler) continue;
383
+ if (e.defaultPrevented) return;
384
+ handler(e);
385
+ }
508
386
  };
509
387
  function getHrefOption(publicHref, external, history, disabled) {
510
- if (disabled) return void 0;
511
- if (external) {
512
- return { href: publicHref, external: true };
513
- }
514
- return {
515
- href: history.createHref(publicHref) || "/",
516
- external: false
517
- };
388
+ if (disabled) return void 0;
389
+ if (external) return {
390
+ href: publicHref,
391
+ external: true
392
+ };
393
+ return {
394
+ href: history.createHref(publicHref) || "/",
395
+ external: false
396
+ };
518
397
  }
519
398
  function isSafeInternal(to) {
520
- if (typeof to !== "string") return false;
521
- const zero = to.charCodeAt(0);
522
- if (zero === 47) return to.charCodeAt(1) !== 47;
523
- return zero === 46;
399
+ if (typeof to !== "string") return false;
400
+ const zero = to.charCodeAt(0);
401
+ if (zero === 47) return to.charCodeAt(1) !== 47;
402
+ return zero === 46;
524
403
  }
404
+ /**
405
+ * Creates a typed Link-like component that preserves TanStack Router's
406
+ * navigation semantics and type-safety while delegating rendering to the
407
+ * provided host component.
408
+ *
409
+ * Useful for integrating design system anchors/buttons while keeping
410
+ * router-aware props (eg. `to`, `params`, `search`, `preload`).
411
+ *
412
+ * @param Comp The host component to render (eg. a design-system Link/Button)
413
+ * @returns A router-aware component with the same API as `Link`.
414
+ * @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-link
415
+ */
525
416
  function createLink(Comp) {
526
- return React.forwardRef(function CreatedLink(props, ref) {
527
- return /* @__PURE__ */ jsx(Link, { ...props, _asChild: Comp, ref });
528
- });
417
+ return React$1.forwardRef(function CreatedLink(props, ref) {
418
+ return /* @__PURE__ */ jsx(Link, {
419
+ ...props,
420
+ _asChild: Comp,
421
+ ref
422
+ });
423
+ });
529
424
  }
530
- const Link = React.forwardRef(
531
- (props, ref) => {
532
- const { _asChild, ...rest } = props;
533
- const { type: _type, ...linkProps } = useLinkProps(rest, ref);
534
- const children = typeof rest.children === "function" ? rest.children({
535
- isActive: linkProps["data-status"] === "active"
536
- }) : rest.children;
537
- if (!_asChild) {
538
- const { disabled: _, ...rest2 } = linkProps;
539
- return React.createElement("a", rest2, children);
540
- }
541
- return React.createElement(_asChild, linkProps, children);
542
- }
543
- );
425
+ /**
426
+ * A strongly-typed anchor component for declarative navigation.
427
+ * Handles path, search, hash and state updates with optional route preloading
428
+ * and active-state styling.
429
+ *
430
+ * Props:
431
+ * - `preload`: Controls route preloading (eg. 'intent', 'render', 'viewport', true/false)
432
+ * - `preloadDelay`: Delay in ms before preloading on hover
433
+ * - `activeProps`/`inactiveProps`: Additional props merged when link is active/inactive
434
+ * - `resetScroll`/`hashScrollIntoView`: Control scroll behavior on navigation
435
+ * - `viewTransition`/`startTransition`: Use View Transitions/React transitions for navigation
436
+ * - `ignoreBlocker`: Bypass registered blockers
437
+ *
438
+ * @returns An anchor-like element that navigates without full page reloads.
439
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkComponent
440
+ */
441
+ var Link = React$1.forwardRef((props, ref) => {
442
+ const { _asChild, ...rest } = props;
443
+ const { type: _type, ...linkProps } = useLinkProps(rest, ref);
444
+ const children = typeof rest.children === "function" ? rest.children({ isActive: linkProps["data-status"] === "active" }) : rest.children;
445
+ if (!_asChild) {
446
+ const { disabled: _, ...rest } = linkProps;
447
+ return React$1.createElement("a", rest, children);
448
+ }
449
+ return React$1.createElement(_asChild, linkProps, children);
450
+ });
544
451
  function isCtrlEvent(e) {
545
- return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
452
+ return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
546
453
  }
547
- const linkOptions = (options) => {
548
- return options;
549
- };
550
- export {
551
- Link,
552
- createLink,
553
- linkOptions,
554
- useLinkProps
454
+ /**
455
+ * Validate and reuse navigation options for `Link`, `navigate` or `redirect`.
456
+ * Accepts a literal options object and returns it typed for later spreading.
457
+ * @example
458
+ * const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } })
459
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions
460
+ */
461
+ var linkOptions = (options) => {
462
+ return options;
555
463
  };
556
- //# sourceMappingURL=link.js.map
464
+ /**
465
+ * Type-check a literal object for use with `Link`, `navigate` or `redirect`.
466
+ * Use to validate and reuse navigation options across your app.
467
+ * @example
468
+ * const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } })
469
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions
470
+ */
471
+ //#endregion
472
+ export { Link, createLink, linkOptions, useLinkProps };
473
+
474
+ //# sourceMappingURL=link.js.map