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