import { ProgramInterop } from './Program'; import { Cmd, Dispatcher, Sub, Task, Maybe } from 'tea-cup-fp'; import * as React from 'react'; import { ReactNode } from 'react'; /** * Props for the ProgramWithNav. */ export interface NavProps extends ProgramInterop { readonly onUrlChange: (l: Location) => Msg; readonly init: (l: Location) => [Model, Cmd]; readonly view: (dispatch: Dispatcher, m: Model) => ReactNode; readonly update: (msg: Msg, model: Model) => [Model, Cmd]; readonly subscriptions: (model: Model) => Sub; flushSyncDefault?: boolean; } export declare function ProgramWithNav(props: NavProps): React.JSX.Element; export declare function onPopState(toMsg: (l: Location) => M): Sub; /** * Return a Task that will eventually change the browser location via historty.pushState, * and send back a Msg into the Program * @param url the url to navigate to */ export declare function newUrl(url: string): Task; export declare abstract class PathElem { abstract mapPart(part: string): Maybe; } export declare function str(s?: string): PathElem; export declare function int(): PathElem; export declare function regex(r: RegExp, converter: (s: string) => Maybe): PathElem; export declare class Path0 { map(f: (query: QueryParams) => R): RouteDef; } export declare class QueryParams { private readonly store; private readonly hash; private constructor(); getValues(name: string): Maybe>; getValue(name: string): Maybe; getHash(): Maybe; static empty(): QueryParams; static fromQueryStringAndHash(queryString?: string, hash?: string): QueryParams; } export declare class Path1 { readonly e: PathElem; constructor(e: PathElem); map(f: (t: T, query: QueryParams) => R): RouteDef; } export declare class Path2 { readonly e1: PathElem; readonly e2: PathElem; constructor(e1: PathElem, e2: PathElem); map(f: (t1: T1, t2: T2, query: QueryParams) => R): RouteDef; } export declare class Path3 { readonly e1: PathElem; readonly e2: PathElem; readonly e3: PathElem; constructor(e1: PathElem, e2: PathElem, e3: PathElem); map(f: (t1: T1, t2: T2, t3: T3, query: QueryParams) => R): RouteDef; } export declare const route0: Path0; export declare function route1(e: PathElem): Path1; export declare function route2(e1: PathElem, e2: PathElem): Path2; export declare function route3(e1: PathElem, e2: PathElem, e3: PathElem): Path3; export interface RouteBase { checkRoute(pathname: string, query: QueryParams): Maybe; } export declare class RouteDef implements RouteBase { readonly pathElems: ReadonlyArray>; readonly f: Function; constructor(pathElems: ReadonlyArray>, f: Function); static sanitizePath(path: string): string; static splitPath(path: string): ReadonlyArray; checkRoute(pathname: string, query: QueryParams): Maybe; } export declare class Router { readonly routes: ReadonlyArray>; constructor(...routeDefs: RouteBase[]); parse(pathname: string, query: QueryParams): Maybe; parseLocation(location: Location): Maybe; }