import type { ReactNode } from 'react'; import type { LazyRouteFunction, RouteObject, UIMatch } from 'react-router'; export { useRouteTitles } from './useRouteTitles'; export { usePrompt } from './usePrompt'; declare module 'react-router' { export interface IndexRouteObject { meta?: KnownRouteObjectMeta; } export interface NonIndexRouteObject { meta?: KnownRouteObjectMeta; } } export interface KnownRouteObjectHandle { title?: RouteHandleTitle; [key: string]: any; } type RouteHandleTitle = string | ((data: any, match: UIMatch) => string); export interface KnownRouteObjectMeta { id?: string; title?: string; icon?: ReactNode; menu?: Record; [key: string]: any; } export type RouteObjects = RouteObject[]; export type LazyRouteObject = Awaited>>; export function lazyRoute( loader: () => Promise< | Awaited | { default: any; } | { route: object } >, ): LazyRouteFunction { return () => loader().then((v) => { if ('route' in v) { return v.route; } if ('default' in v) { return v.default; } return v; }); }