import { AnyRouter, Constrain, LinkOptions, RegisteredRouter, RoutePaths } from '@tanstack/router-core'; import { ReactNode } from 'react'; import { ValidateLinkOptions, ValidateLinkOptionsArray } from './typePrimitives.js'; import * as React from 'react'; /** * Build anchor-like props for declarative navigation and preloading. * * Returns stable `href`, event handlers and accessibility props derived from * router options and active state. Used internally by `Link` and custom links. * * Options cover `to`, `params`, `search`, `hash`, `state`, `preload`, * `activeProps`, `inactiveProps`, and more. * * @returns React anchor props suitable for `` or custom components. * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLinkPropsHook */ export declare function useLinkProps(options: UseLinkPropsOptions, forwardedRef?: React.ForwardedRef): React.ComponentPropsWithRef<'a'>; type UseLinkReactProps = TComp extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[TComp] : TComp extends React.ComponentType ? React.ComponentPropsWithoutRef & React.RefAttributes> : never; export type UseLinkPropsOptions | string = string, TTo extends string | undefined = '.', TMaskFrom extends RoutePaths | string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & UseLinkReactProps<'a'>; export type ActiveLinkOptions = LinkOptions & ActiveLinkOptionProps; type ActiveLinkProps = Partial & { [key: `data-${string}`]: unknown; }>; export interface ActiveLinkOptionProps { /** * A function that returns additional props for the `active` state of this link. * These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated) */ activeProps?: ActiveLinkProps | (() => ActiveLinkProps); /** * A function that returns additional props for the `inactive` state of this link. * These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated) */ inactiveProps?: ActiveLinkProps | (() => ActiveLinkProps); } export type LinkProps = ActiveLinkOptions & LinkPropsChildren; export interface LinkPropsChildren { children?: React.ReactNode | ((state: { isActive: boolean; isTransitioning: boolean; }) => React.ReactNode); } type LinkComponentReactProps = Omit, keyof CreateLinkProps>; export type LinkComponentProps = LinkComponentReactProps & LinkProps; export type CreateLinkProps = LinkProps; export type LinkComponent = (props: LinkComponentProps) => React.ReactElement; export interface LinkComponentRoute { defaultFrom: TDefaultFrom; (props: LinkComponentProps<'a', TRouter, this['defaultFrom'], TTo, this['defaultFrom'], TMaskTo>): React.ReactElement; } /** * Creates a typed Link-like component that preserves TanStack Router's * navigation semantics and type-safety while delegating rendering to the * provided host component. * * Useful for integrating design system anchors/buttons while keeping * router-aware props (eg. `to`, `params`, `search`, `preload`). * * @param Comp The host component to render (eg. a design-system Link/Button) * @returns A router-aware component with the same API as `Link`. * @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-link */ export declare function createLink(Comp: Constrain ReactNode>): LinkComponent; /** * A strongly-typed anchor component for declarative navigation. * Handles path, search, hash and state updates with optional route preloading * and active-state styling. * * Props: * - `preload`: Controls route preloading (eg. 'intent', 'render', 'viewport', true/false) * - `preloadDelay`: Delay in ms before preloading on hover * - `activeProps`/`inactiveProps`: Additional props merged when link is active/inactive * - `resetScroll`/`hashScrollIntoView`: Control scroll behavior on navigation * - `viewTransition`/`startTransition`: Use View Transitions/React transitions for navigation * - `ignoreBlocker`: Bypass registered blockers * * @returns An anchor-like element that navigates without full page reloads. * @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkComponent */ export declare const Link: LinkComponent<'a'>; export type LinkOptionsFnOptions = TOptions extends ReadonlyArray ? ValidateLinkOptionsArray : ValidateLinkOptions; export type LinkOptionsFn = (options: LinkOptionsFnOptions) => TOptions; /** * Validate and reuse navigation options for `Link`, `navigate` or `redirect`. * Accepts a literal options object and returns it typed for later spreading. * @example * const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } }) * @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions */ export declare const linkOptions: LinkOptionsFn<'a'>; export {}; /** * Type-check a literal object for use with `Link`, `navigate` or `redirect`. * Use to validate and reuse navigation options across your app. * @example * const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } }) * @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions */