@payfit/unity-components
Version:
43 lines (42 loc) • 2.32 kB
TypeScript
import { ComponentProps, PropsWithChildren } from 'react';
import { RouterProvider as AriaRouterProvider } from 'react-aria-components';
export interface ExtendedRouterContextValue {
/**
* Function to determine if a route is active
*/
isActive: (to: string, isExact?: boolean) => boolean;
}
/**
* Hook to access the extended ARIA router context. For internal use in Unity only.
*/
export declare const useRouter: () => ExtendedRouterContextValue | null;
type AriaRouterProviderProps = ComponentProps<typeof AriaRouterProvider>;
export interface RouterProviderProps extends ComponentProps<typeof AriaRouterProvider> {
/**
* function received from a client-side routing library to perform a client-side navigation programmatically
*/
navigate: AriaRouterProviderProps['navigate'];
/**
* Optional function to convert a router-specific href to a native HTML href, e.g. prepending a base path
*/
useHref?: AriaRouterProviderProps['useHref'];
/**
* Function to determine if a route is active
*/
isActive: (to: string) => boolean;
}
/**
* The `RouterProvider` component is a provider that allows for integrations between Unity components that render links (such as `RawLink`, `RawNavItem`, etc.) and any client-side routing library in a single or multi-page application.
*
* By default, links perform native browser navigation when they are interacted with. However, many apps and frameworks use client side routers to avoid a full page reload when navigating between pages. The `RouterProvider` component configures all Unity components that support it to navigate using the client side router you provide. Set this up once in the root of your app, and any component with the href prop will automatically navigate using your router.
*/
export declare function RouterProvider({ isActive, children, ...routerProps }: RouterProviderProps): import("react/jsx-runtime").JSX.Element;
export declare namespace RouterProvider {
var displayName: string;
}
/**
* The `NoopRouterProvider` should only be use when transitioning between routers to bail out of the previous provider
* that is rendered upper in the react tree.
*/
export declare function NoopRouterProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
export {};