Open History to see the last commit
1import type { HistoryState, ParsedHistoryState } from '@tanstack/history'
2import type {
3 AllParams,
4 CatchAllPaths,
5 CurrentPath,
6 FullSearchSchema,
7 FullSearchSchemaInput,
8 ParentPath,
9 RouteByPath,
10 RouteByToPath,
11 RoutePaths,
12 RouteToPath,
13 ToPath,
14} from './routeInfo'
15import type {
16 AnyRouter,
17 RegisteredRouter,
18 ViewTransitionOptions,
19} from './router'
20import type {
21 ConstrainLiteral,
22 Expand,
23 MakeDifferenceOptional,
24 NoInfer,
25 NonNullableUpdater,
26 Updater,
27} from './utils'
28import type { ParsedLocation } from './location'
29β
30export type IsRequiredParams<TParams> =
31 Record<never, never> extends TParams ? never : true
32β
33export interface ParsePathParamsResult<
34 in out TRequired,
35 in out TOptional,
36 in out TRest,
37> {
38 required: TRequired
39 optional: TOptional
40 rest: TRest
41}
42β
43export type AnyParsePathParamsResult = ParsePathParamsResult<
44 string,
45 string,
46 string
47>
48β
49export type ParsePathParamsBoundaryStart<T extends string> =
50 T extends `${infer TLeft}{-${infer TRight}`
51 ? ParsePathParamsResult<
52 ParsePathParams<TLeft>['required'],
53 | ParsePathParams<TLeft>['optional']
54 | ParsePathParams<TRight>['required']
55 | ParsePathParams<TRight>['optional'],
56 ParsePathParams<TRight>['rest']
57 >
58 : T extends `${infer TLeft}{${infer TRight}`
59 ? ParsePathParamsResult<
60 | ParsePathParams<TLeft>['required']
61 | ParsePathParams<TRight>['required'],
62 | ParsePathParams<TLeft>['optional']
63 | ParsePathParams<TRight>['optional'],
64 ParsePathParams<TRight>['rest']
65 >
66 : never
67β
68export type ParsePathParamsSymbol<T extends string> =
69 T extends `${string}$${infer TRight}`
70 ? TRight extends `${string}/${string}`
71 ? TRight extends `${infer TParam}/${infer TRest}`
72 ? TParam extends ''
73 ? ParsePathParamsResult<
74 ParsePathParams<TRest>['required'],
75 '_splat' | ParsePathParams<TRest>['optional'],
76 ParsePathParams<TRest>['rest']
77 >
78 : ParsePathParamsResult<
79 TParam | ParsePathParams<TRest>['required'],
80 ParsePathParams<TRest>['optional'],
81 ParsePathParams<TRest>['rest']
82 >
83 : never
84 : TRight extends ''
85 ? ParsePathParamsResult<never, '_splat', never>
86 : ParsePathParamsResult<TRight, never, never>
87 : never
88β
89export type ParsePathParamsBoundaryEnd<T extends string> =
90 T extends `${infer TLeft}}${infer TRight}`
91 ? ParsePathParamsResult<
92 | ParsePathParams<TLeft>['required']
93 | ParsePathParams<TRight>['required'],
94 | ParsePathParams<TLeft>['optional']
95 | ParsePathParams<TRight>['optional'],
96 ParsePathParams<TRight>['rest']
97 >
98 : never
99β
100export type ParsePathParamsEscapeStart<T extends string> =
101 T extends `${infer TLeft}[${infer TRight}`
102 ? ParsePathParamsResult<
103 | ParsePathParams<TLeft>['required']
104 | ParsePathParams<TRight>['required'],
105 | ParsePathParams<TLeft>['optional']
106 | ParsePathParams<TRight>['optional'],
107 ParsePathParams<TRight>['rest']
108 >
109 : never
110β
111export type ParsePathParamsEscapeEnd<T extends string> =
112 T extends `${string}]${infer TRight}` ? ParsePathParams<TRight> : never
113β
114export type ParsePathParams<T extends string> = T extends `${string}[${string}`
115 ? ParsePathParamsEscapeStart<T>
116 : T extends `${string}]${string}`
117 ? ParsePathParamsEscapeEnd<T>
118 : T extends `${string}}${string}`
119 ? ParsePathParamsBoundaryEnd<T>
120 : T extends `${string}{${string}`
121 ? ParsePathParamsBoundaryStart<T>
122 : T extends `${string}$${string}`
123 ? ParsePathParamsSymbol<T>
124 : never
125β
126export type AddTrailingSlash<T> = T extends `${string}/` ? T : `${T & string}/`
127β
128export type RemoveTrailingSlashes<T> = T & `${string}/` extends never
129 ? T
130 : T extends `${infer R}/`
131 ? R
132 : T
133β
134export type AddLeadingSlash<T> = T & `/${string}` extends never
135 ? `/${T & string}`
136 : T
137β
138export type RemoveLeadingSlashes<T> = T & `/${string}` extends never
139 ? T
140 : T extends `/${infer R}`
141 ? R
142 : T
143β
144type JoinPath<TLeft extends string, TRight extends string> = TRight extends ''
145 ? TLeft
146 : TLeft extends ''
147 ? TRight
148 : `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`
149β
150type RemoveLastSegment<
151 T extends string,
152 TAcc extends string = '',
153> = T extends `${infer TSegment}/${infer TRest}`
154 ? TRest & `${string}/${string}` extends never
155 ? TRest extends ''
156 ? TAcc
157 : `${TAcc}${TSegment}`
158 : RemoveLastSegment<TRest, `${TAcc}${TSegment}/`>
159 : TAcc
160β
161export type ResolveCurrentPath<
162 TFrom extends string,
163 TTo extends string,
164> = TTo extends '.'
165 ? TFrom
166 : TTo extends './'
167 ? AddTrailingSlash<TFrom>
168 : TTo & `./${string}` extends never
169 ? never
170 : TTo extends `./${infer TRest}`
171 ? AddLeadingSlash<JoinPath<TFrom, TRest>>
172 : never
173β
174export type ResolveParentPath<
175 TFrom extends string,
176 TTo extends string,
177> = TTo extends '../' | '..'
178 ? TFrom extends '' | '/'
179 ? never
180 : AddLeadingSlash<RemoveLastSegment<TFrom>>
181 : TTo & `../${string}` extends never
182 ? AddLeadingSlash<JoinPath<TFrom, TTo>>
183 : TFrom extends '' | '/'
184 ? never
185 : TTo extends `../${infer ToRest}`
186 ? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest>
187 : AddLeadingSlash<JoinPath<TFrom, TTo>>
188β
189export type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom
190 ? TTo
191 : string extends TTo
192 ? TFrom
193 : undefined extends TTo
194 ? TFrom
195 : TTo extends string
196 ? TFrom extends string
197 ? TTo extends `/${string}`
198 ? TTo
199 : TTo extends `..${string}`
200 ? ResolveParentPath<TFrom, TTo>
201 : TTo extends `.${string}`
202 ? ResolveCurrentPath<TFrom, TTo>
203 : AddLeadingSlash<JoinPath<TFrom, TTo>>
204 : never
205 : never
206β
207export type FindDescendantToPaths<
208 TRouter extends AnyRouter,
209 TPrefix extends string,
210> = `${TPrefix}/${string}` & RouteToPath<TRouter>
211β
212export type InferDescendantToPaths<
213 TRouter extends AnyRouter,
214 TPrefix extends string,
215 TPaths = FindDescendantToPaths<TRouter, TPrefix>,
216> = TPaths extends `${TPrefix}/`
217 ? never
218 : TPaths extends `${TPrefix}/${infer TRest}`
219 ? TRest
220 : never
221β
222export type RelativeToPath<
223 TRouter extends AnyRouter,
224 TTo extends string,
225 TResolvedPath extends string,
226> =
227 | (TResolvedPath & RouteToPath<TRouter> extends never
228 ? never
229 : ToPath<TRouter, TTo>)
230 | `${RemoveTrailingSlashes<TTo>}/${InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>>}`
231β
232export type RelativeToParentPath<
233 TRouter extends AnyRouter,
234 TFrom extends string,
235 TTo extends string,
236 TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,
237> =
238 | RelativeToPath<TRouter, TTo, TResolvedPath>
239 | (TTo extends `${string}..` | `${string}../`
240 ? TResolvedPath extends '/' | ''
241 ? never
242 : FindDescendantToPaths<
243 TRouter,
244 RemoveTrailingSlashes<TResolvedPath>
245 > extends never
246 ? never
247 : `${RemoveTrailingSlashes<TTo>}/${ParentPath<TRouter>}`
248 : never)
249β
250export type RelativeToCurrentPath<
251 TRouter extends AnyRouter,
252 TFrom extends string,
253 TTo extends string,
254 TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,
255> = RelativeToPath<TRouter, TTo, TResolvedPath> | CurrentPath<TRouter>
256β
257export type AbsoluteToPath<TRouter extends AnyRouter, TFrom extends string> =
258 | (string extends TFrom
259 ? CurrentPath<TRouter>
260 : TFrom extends `/`
261 ? never
262 : CurrentPath<TRouter>)
263 | (string extends TFrom
264 ? ParentPath<TRouter>
265 : TFrom extends `/`
266 ? never
267 : ParentPath<TRouter>)
268 | RouteToPath<TRouter>
269 | (TFrom extends '/'
270 ? never
271 : string extends TFrom
272 ? never
273 : InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TFrom>>)
274β
275export type RelativeToPathAutoComplete<
276 TRouter extends AnyRouter,
277 TFrom extends string,
278 TTo extends string,
279> = string extends TTo
280 ? string
281 : string extends TFrom
282 ? AbsoluteToPath<TRouter, TFrom>
283 : TTo & `..${string}` extends never
284 ? TTo & `.${string}` extends never
285 ? AbsoluteToPath<TRouter, TFrom>
286 : RelativeToCurrentPath<TRouter, TFrom, TTo>
287 : RelativeToParentPath<TRouter, TFrom, TTo>
288β
289export type NavigateOptions<
290 TRouter extends AnyRouter = RegisteredRouter,
291 TFrom extends string = string,
292 TTo extends string | undefined = '.',
293 TMaskFrom extends string = TFrom,
294 TMaskTo extends string = '.',
295> = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps
296β
297/**
298 * The NavigateOptions type is used to describe the options that can be used when describing a navigation action in TanStack Router.
299 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType)
300 */
301export interface NavigateOptionProps {
302 /**
303 * If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`.
304 * If set to `false`, the router will not scroll the element with an id matching the hash into view.
305 * If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.
306 * @default true
307 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#hashscrollintoview)
308 * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)
309 */
310 hashScrollIntoView?: boolean | ScrollIntoViewOptions
311 /**
312 * `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.
313 * @default false
314 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#replace)
315 */
316 replace?: boolean
317 /**
318 * Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history.
319 * If `false`, the scroll position will not be reset to 0,0 after the location is committed to history.
320 * @default true
321 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#resetscroll)
322 */
323 resetScroll?: boolean
324 /** @deprecated All navigations now use startTransition under the hood */
325 startTransition?: boolean
326 /**
327 * If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call.
328 * If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})`
329 * where `types` will be the strings array passed with `ViewTransitionOptions["types"]`.
330 * If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.
331 *
332 * If the browser does not support this api, this option will be ignored.
333 * @default false
334 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#viewtransition)
335 * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)
336 * @see [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types)
337 */
338 viewTransition?: boolean | ViewTransitionOptions
339 /**
340 * If `true`, navigation will ignore any blockers that might prevent it.
341 * @default false
342 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#ignoreblocker)
343 */
344 ignoreBlocker?: boolean
345 /**
346 * If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation.
347 * @default false
348 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#reloaddocument)
349 */
350 reloadDocument?: boolean
351 /**
352 * This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target.
353 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)
354 */
355 href?: string
356}
357β
358export type ToOptions<
359 TRouter extends AnyRouter = RegisteredRouter,
360 TFrom extends string = string,
361 TTo extends string | undefined = '.',
362 TMaskFrom extends string = TFrom,
363 TMaskTo extends string = '.',
364> = ToSubOptions<TRouter, TFrom, TTo> & MaskOptions<TRouter, TMaskFrom, TMaskTo>
365β
366export interface MaskOptions<
367 in out TRouter extends AnyRouter,
368 in out TMaskFrom extends string,
369 in out TMaskTo extends string,
370> {
371 _fromLocation?: ParsedLocation
372 mask?: ToMaskOptions<TRouter, TMaskFrom, TMaskTo>
373}
374β
375export type ToMaskOptions<
376 TRouter extends AnyRouter = RegisteredRouter,
377 TMaskFrom extends string = string,
378 TMaskTo extends string = '.',
379> = ToSubOptions<TRouter, TMaskFrom, TMaskTo> & {
380 unmaskOnReload?: boolean
381}
382β
383export type ToSubOptions<
384 TRouter extends AnyRouter = RegisteredRouter,
385 TFrom extends string = string,
386 TTo extends string | undefined = '.',
387> = ToSubOptionsProps<TRouter, TFrom, TTo> &
388 SearchParamOptions<TRouter, TFrom, TTo> &
389 PathParamOptions<TRouter, TFrom, TTo>
390β
391export interface RequiredToOptions<
392 in out TRouter extends AnyRouter,
393 in out TFrom extends string,
394 in out TTo extends string | undefined,
395> {
396 /**
397 * The internal route path to navigate to. This should be a relative or absolute path within your application.
398 * For external URLs, use the `href` property instead.
399 * @example "/dashboard" or "../profile"
400 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)
401 */
402 to: ToPathOption<TRouter, TFrom, TTo> & {}
403}
404β
405export interface OptionalToOptions<
406 in out TRouter extends AnyRouter,
407 in out TFrom extends string,
408 in out TTo extends string | undefined,
409> {
410 /**
411 * The internal route path to navigate to. This should be a relative or absolute path within your application.
412 * For external URLs, use the `href` property instead.
413 * @example "/dashboard" or "../profile"
414 * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)
415 */
416 to?: ToPathOption<TRouter, TFrom, TTo> & {}
417}
418β
419export type MakeToRequired<
420 TRouter extends AnyRouter,
421 TFrom extends string,
422 TTo extends string | undefined,
423> = string extends TFrom
424 ? string extends TTo
425 ? OptionalToOptions<TRouter, TFrom, TTo>
426 : TTo & CatchAllPaths<TRouter> extends never
427 ? RequiredToOptions<TRouter, TFrom, TTo>
428 : OptionalToOptions<TRouter, TFrom, TTo>
429 : OptionalToOptions<TRouter, TFrom, TTo>
430β
431export type ToSubOptionsProps<
432 TRouter extends AnyRouter = RegisteredRouter,
433 TFrom extends RoutePaths<TRouter['routeTree']> | string = string,
434 TTo extends string | undefined = '.',
435> = MakeToRequired<TRouter, TFrom, TTo> & {
436 hash?: true | Updater<string>
437 state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
438 from?: FromPathOption<TRouter, TFrom> & {}
439 unsafeRelative?: 'path'
440}
441β
442export type ParamsReducerFn<
443 in out TRouter extends AnyRouter,
444 in out TParamVariant extends ParamVariant,
445 in out TFrom,
446 in out TTo,
447> = (
448 current: Expand<ResolveFromParams<TRouter, TParamVariant, TFrom>>,
449) => Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>
450β
451type ParamsReducer<
452 TRouter extends AnyRouter,
453 TParamVariant extends ParamVariant,
454 TFrom,
455 TTo,
456> =
457 | Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>
458 | (ParamsReducerFn<TRouter, TParamVariant, TFrom, TTo> & {})
459β
460type ParamVariant = 'PATH' | 'SEARCH'
461β
462export type ResolveRoute<
463 TRouter extends AnyRouter,
464 TFrom,
465 TTo,
466 TPath = ResolveRelativePath<TFrom, TTo>,
467> = TPath extends string
468 ? TFrom extends TPath
469 ? RouteByPath<TRouter['routeTree'], TPath>
470 : RouteByToPath<TRouter, TPath>
471 : never
472β
473type ResolveFromParamType<TParamVariant extends ParamVariant> =
474 TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema'
475β
476type ResolveFromAllParams<
477 TRouter extends AnyRouter,
478 TParamVariant extends ParamVariant,
479> = TParamVariant extends 'PATH'
480 ? AllParams<TRouter['routeTree']>
481 : FullSearchSchema<TRouter['routeTree']>
482β
483type ResolveFromParams<
484 TRouter extends AnyRouter,
485 TParamVariant extends ParamVariant,
486 TFrom,
487> = string extends TFrom
488 ? ResolveFromAllParams<TRouter, TParamVariant>
489 : RouteByPath<
490 TRouter['routeTree'],
491 TFrom
492 >['types'][ResolveFromParamType<TParamVariant>]
493β
494type ResolveToParamType<TParamVariant extends ParamVariant> =
495 TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput'
496β
497type ResolveAllToParams<
498 TRouter extends AnyRouter,
499 TParamVariant extends ParamVariant,
500> = TParamVariant extends 'PATH'
501 ? AllParams<TRouter['routeTree']>
502 : FullSearchSchemaInput<TRouter['routeTree']>
503β
504export type ResolveToParams<
505 TRouter extends AnyRouter,
506 TParamVariant extends ParamVariant,
507 TFrom,
508 TTo,
509> =
510 ResolveRelativePath<TFrom, TTo> extends infer TPath
511 ? undefined extends TPath
512 ? never
513 : string extends TPath
514 ? ResolveAllToParams<TRouter, TParamVariant>
515 : TPath extends CatchAllPaths<TRouter>
516 ? ResolveAllToParams<TRouter, TParamVariant>
517 : ResolveRoute<
518 TRouter,
519 TFrom,
520 TTo
521 >['types'][ResolveToParamType<TParamVariant>]
522 : never
523β
524type ResolveRelativeToParams<
525 TRouter extends AnyRouter,
526 TParamVariant extends ParamVariant,
527 TFrom,
528 TTo,
529 TToParams = ResolveToParams<TRouter, TParamVariant, TFrom, TTo>,
530> = TParamVariant extends 'SEARCH'
531 ? TToParams
532 : string extends TFrom
533 ? TToParams
534 : MakeDifferenceOptional<
535 ResolveFromParams<TRouter, TParamVariant, TFrom>,
536 TToParams
537 >
538β
539export interface MakeOptionalSearchParams<
540 in out TRouter extends AnyRouter,
541 in out TFrom,
542 in out TTo,
543> {
544 search?: true | (ParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {})
545}
546β
547export interface MakeOptionalPathParams<
548 in out TRouter extends AnyRouter,
549 in out TFrom,
550 in out TTo,
551> {
552 params?: true | (ParamsReducer<TRouter, 'PATH', TFrom, TTo> & {})
553}
554β
555type MakeRequiredParamsReducer<
556 TRouter extends AnyRouter,
557 TParamVariant extends ParamVariant,
558 TFrom,
559 TTo,
560> =
561 | (string extends TFrom
562 ? never
563 : ResolveFromParams<
564 TRouter,
565 TParamVariant,
566 TFrom
567 > extends ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>
568 ? true
569 : never)
570 | (ParamsReducer<TRouter, TParamVariant, TFrom, TTo> & {})
571β
572export interface MakeRequiredPathParams<
573 in out TRouter extends AnyRouter,
574 in out TFrom,
575 in out TTo,
576> {
577 params: MakeRequiredParamsReducer<TRouter, 'PATH', TFrom, TTo> & {}
578}
579β
580export interface MakeRequiredSearchParams<
581 in out TRouter extends AnyRouter,
582 in out TFrom,
583 in out TTo,
584> {
585 search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {}
586}
587β
588export type IsRequired<
589 TRouter extends AnyRouter,
590 TParamVariant extends ParamVariant,
591 TFrom,
592 TTo,
593> =
594 ResolveRelativePath<TFrom, TTo> extends infer TPath
595 ? undefined extends TPath
596 ? never
597 : TPath extends CatchAllPaths<TRouter>
598 ? never
599 : IsRequiredParams<
600 ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>
601 >
602 : never
603β
604export type SearchParamOptions<TRouter extends AnyRouter, TFrom, TTo> =
605 IsRequired<TRouter, 'SEARCH', TFrom, TTo> extends never
606 ? MakeOptionalSearchParams<TRouter, TFrom, TTo>
607 : MakeRequiredSearchParams<TRouter, TFrom, TTo>
608β
609export type PathParamOptions<TRouter extends AnyRouter, TFrom, TTo> =
610 IsRequired<TRouter, 'PATH', TFrom, TTo> extends never
611 ? MakeOptionalPathParams<TRouter, TFrom, TTo>
612 : MakeRequiredPathParams<TRouter, TFrom, TTo>
613β
614export type ToPathOption<
615 TRouter extends AnyRouter = AnyRouter,
616 TFrom extends string = string,
617 TTo extends string | undefined = string,
618> = ConstrainLiteral<
619 TTo,
620 RelativeToPathAutoComplete<
621 TRouter,
622 NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',
623 NoInfer<TTo> & string
624 >
625>
626β
627export type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<
628 TFrom,
629 RoutePaths<TRouter['routeTree']>
630>
631β
632/**
633 * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options)
634 */
635export interface ActiveOptions {
636 /**
637 * If true, the link will be active if the current route matches the `to` route path exactly (no children routes)
638 * @default false
639 */
640 exact?: boolean
641 /**
642 * If true, the link will only be active if the current URL hash matches the `hash` prop
643 * @default false
644 */
645 includeHash?: boolean
646 /**
647 * If true, the link will only be active if the current URL search params inclusively match the `search` prop
648 * @default true
649 */
650 includeSearch?: boolean
651 /**
652 * This modifies the `includeSearch` behavior.
653 * If true, properties in `search` that are explicitly `undefined` must NOT be present in the current URL search params for the link to be active.
654 * @default false
655 */
656 explicitUndefined?: boolean
657}
658β
659export interface LinkOptionsProps {
660 /**
661 * The standard anchor tag target attribute
662 */
663 target?: HTMLAnchorElement['target']
664 /**
665 * Configurable options to determine if the link should be considered active or not
666 * @default {exact:true,includeHash:true}
667 */
668 activeOptions?: ActiveOptions
669 /**
670 * The preloading strategy for this link
671 * - `false` - No preloading
672 * - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
673 * - `'viewport'` - Preload the linked route when it enters the viewport
674 */
675 preload?: false | 'intent' | 'viewport' | 'render'
676 /**
677 * When a preload strategy is set, this delays the preload by this many milliseconds.
678 * If the user exits the link before this delay, the preload will be cancelled.
679 */
680 preloadDelay?: number
681 /**
682 * Control whether the link should be disabled or not
683 * If set to `true`, the link will be rendered without an `href` attribute
684 * @default false
685 */
686 disabled?: boolean
687 /**
688 * When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded.
689 * If the user exits this proximity before this delay, the preload will be cancelled.
690 */
691 preloadIntentProximity?: number
692}
693β
694export type LinkOptions<
695 TRouter extends AnyRouter = RegisteredRouter,
696 TFrom extends string = string,
697 TTo extends string | undefined = '.',
698 TMaskFrom extends string = TFrom,
699 TMaskTo extends string = '.',
700> = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps
701β
702export type LinkCurrentTargetElement = {
703 preloadTimeout?: null | ReturnType<typeof setTimeout>
704}
705β
706export const preloadWarning = 'Error preloading route! βοΈ'