Repository URL to install this package:
|
Version:
7.0.0-alpha.3 ▾
|
import { match } from 'react-router';
import { ClassAttributes } from 'react';
export interface DefaultPropsWithRouter<Props = any> extends ClassAttributes<Props> {
location?: {
pathname?: string;
};
}
/**
* @see https://github.com/mjackson/history
*/
export declare type Action = 'PUSH' | 'POP' | 'REPLACE';
export declare type UnregisterCallback = () => void;
export declare type LocationDescriptor = Path | LocationDescriptorObject;
export declare type LocationKey = string;
export declare type LocationListener = (location: Location, action: Action) => void;
export declare type LocationState = any;
export declare type Path = string;
export declare type Pathname = string;
export declare type Search = string;
export declare type TransitionHook = (location: Location, callback: (result: any) => void) => any;
export interface HistoryType {
length: number;
action: Action;
location: Location;
push(path: Path, state?: LocationState): void;
push(location: LocationDescriptorObject): void;
replace(path: Path, state?: LocationState): void;
replace(location: LocationDescriptorObject): void;
go(n: number): void;
goBack(): void;
goForward(): void;
block(prompt?: boolean): UnregisterCallback;
listen(listener: LocationListener): UnregisterCallback;
createHref(location: LocationDescriptorObject): Href;
}
export interface Location {
pathname: Pathname;
search: Search;
state?: LocationState;
hash: Hash;
key?: LocationKey;
href?: string;
origin?: string;
}
export interface LocationDescriptorObject {
pathname?: Pathname;
search?: Search;
state?: LocationState;
hash?: Hash;
key?: LocationKey;
}
/**
* @see https://gist.github.com/icfantv/775a6000748384e9f77569017d67c240
* @see https://github.com/Microsoft/TypeScript/issues/6579
* @description /^(?:[a-z]+:)?/
*/
export declare type FullyQualifiedWebAddress = string;
export declare type RelativeWebAddress = '/route' | string;
export declare type StringifiedParam = '=' | '?' | '#' | String;
export declare type OneRouterParamVariations = Object | StringifiedParam;
export declare type Hash = string;
export declare type Href = string;
export interface OneRouterOptions {
shouldUseNative?: boolean;
shouldStringify?: boolean;
shouldMerge?: boolean;
}
export declare type OneRouterSubscriberOnChange = LocationListener;
export interface UpdateToObj {
pathname?: never;
[key: string]: SerializableType;
}
export declare type UpdateTo = UpdateToObj | string | Array<UpdateToObj | string>;
export declare type RouterType<Params = any> = {
history: HistoryType;
route: {
location: Location;
match: match<Params>;
};
};
export declare type SerializableType = SerializableObj | SerializableArray | string | number | undefined | null;
export interface SerializableObj {
[key: string]: SerializableType;
[key: number]: SerializableType;
}
export declare type SerializableArray = Array<SerializableObj | string | number | undefined | null>;
export declare type Serializable = SerializableObj | SerializableArray;
export interface ObjWithValuesSerialized {
[key: string]: string | ObjWithValuesSerialized | ObjWithValuesSerialized[];
}
export interface OneUrl {
protocol: string;
host: string;
pathname: '/' | string;
search: Serializable;
hash: string;
full: string;
userAgent: string;
toString?(): string;
[Symbol.toPrimitive]?(): string;
}
export interface OneRouterToRuleThemAllRehydratable {
}
export declare type ParsedSearchParams = ObjWithValuesSerialized | '' | any[];
export declare type MatchedValue = string | number | boolean | undefined;
export interface Matches {
[key: string]: MatchedValue | Matches | Matches[] | MatchedValue[];
}
export declare type MatchPathParamsType = {
params: {
[key: string]: any;
};
};
export interface AnyObj {
[key: string]: any;
}
export declare type StringArrayOrFrozenStringArray = string[] | Readonly<string[]>;
export declare type PathParamsType = AnyObj | StringArrayOrFrozenStringArray;
export interface RoutePathObjType {
path: string;
component?: any;
exact?: boolean;
key?: any;
}
export interface OneRouterConfigObjType {
pathParams: PathParamsType;
routePathsList: StringArrayOrFrozenStringArray | RoutePathObjType[];
}
export interface OneRouterConfigMap extends Map<string, any> {
get(key: 'pathParams'): PathParamsType | Readonly<PathParamsType>;
set(key: 'pathParams', value: PathParamsType | Readonly<PathParamsType>): this;
get(key: 'routePathsList'): StringArrayOrFrozenStringArray;
set(key: 'routePathsList', value: StringArrayOrFrozenStringArray): this;
}
export interface OneRouterStoreType extends Map<string, any> {
get(key: 'urlList'): StringArrayOrFrozenStringArray;
set(key: 'urlList', value: StringArrayOrFrozenStringArray): this;
get(key: 'url'): string;
set(key: 'url', value: string): this;
get(key: 'tapEntries'): TapEntriesType;
set(key: 'tapEntries', value: TapEntriesType): this;
get(key: 'hasTappedEntries'): boolean;
set(key: 'hasTappedEntries', value: boolean): this;
get(key: 'entries'): AnyObj;
set(key: 'entries', value: AnyObj): this;
get(key: 'router'): RouterType;
set(key: 'router', value: RouterType): this;
}
export declare type OneRouterEntriesType<Params = any> = Params & {
[key: string]: any;
};
export declare type TapEntriesType = (entries: OneRouterEntriesType) => any;
import { Context } from 'react';
/**
* @see https://github.com/ReactTraining/react-router/blob/90ecb355682fa548d9a469d8ce89f9423a3983fd/packages/react-router/modules/Route.js
* @see https://github.com/ReactTraining/react-router/blob/c43b8ced6ac86b872f4084f35a3c7b08e5b4c44d/packages/react-router/modules/Router.js#L8
*/
export interface ReactRouterContextValue<OneRouterType = any> {
location: Location;
match: MatchPathParamsType;
history: History;
staticContext?: any;
oneRouter?: OneRouterType;
}
export declare type ReactRouterContextType<OneRouterType = any> = Context<ReactRouterContextValue<OneRouterType>>;