This repository has been archived by the owner on Dec 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
/
index.d.ts
230 lines (203 loc) · 6.26 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// Type definitions for redux-little-router 15.0.0
// Project: https://github.com/FormidableLabs/redux-little-router
// Definitions by: priecint <https://github.com/priecint>
// parkerziegler <https://github.com/parkerziegler>
// TypeScript version: 2.4
import * as React from "react";
import { Reducer, Middleware, StoreEnhancer } from "redux";
export type ObjectLiteral<T> = { [key: string]: T };
export type Query = ObjectLiteral<string>;
export type Params = ObjectLiteral<string>;
/* check out https://basarat.gitbooks.io/typescript/docs/types/index-signatures.html to read more
about what is happening here. */
export type Routes = ObjectLiteral<ObjectLiteral<any>>;
export type LocationOptions = {
persistQuery?: boolean;
updateRoutes?: boolean;
};
export interface HistoryLocation {
hash?: string,
key?: string
pathname?: string,
search?: string,
state?: ObjectLiteral<any>,
}
export interface Location extends HistoryLocation {
basename?: string;
options?: LocationOptions;
params?: Params;
previous?: Location;
query?: Query;
queue?: Array<Location>;
result?: ObjectLiteral<any>;
routes?: Routes;
}
export interface State {
router: Location;
}
export type Href = string | Location;
export const LOCATION_CHANGED = 'ROUTER_LOCATION_CHANGED';
export const PUSH = 'ROUTER_PUSH';
export const REPLACE = 'ROUTER_REPLACE';
export const GO = 'ROUTER_GO';
export const GO_BACK = 'ROUTER_GO_BACK';
export const GO_FORWARD = 'ROUTER_GO_FORWARD';
export const POP = 'ROUTER_POP';
export const BLOCK = 'ROUTER_BLOCK';
export const UNBLOCK = 'ROUTER_UNBLOCK';
export const REPLACE_ROUTES = 'ROUTER_REPLACE_ROUTES';
export const DID_REPLACE_ROUTES = 'ROUTER_DID_REPLACE_ROUTES';
export type LocationChangedAction = {
type: typeof LOCATION_CHANGED;
payload: Location;
};
export type PushAction = {
type: typeof PUSH;
payload: Location;
}
export type ReplaceAction = {
type: typeof REPLACE;
payload: Location;
};
export type GoAction = {
type: typeof GO;
payload: number;
};
export type GoBackAction = {
type: typeof GO_BACK;
};
export type GoForwardAction = {
type: typeof GO_FORWARD;
};
export type BlockAction = {
type: typeof BLOCK;
payload: BlockCallback;
};
export type UnblockAction = {
type: typeof UNBLOCK;
};
export type ReplaceRoutesAction = {
type: typeof REPLACE_ROUTES;
payload: {
routes: Routes;
options: {
updateRoutes: boolean
};
};
};
export type RouterActions =
| LocationChangedAction
| PushAction
| ReplaceAction
| GoAction
| GoBackAction
| GoForwardAction
| BlockAction
| UnblockAction
| ReplaceRoutesAction;
export function initializeCurrentLocation(location: Location): LocationChangedAction;
export function push(href: Href, options?: LocationOptions): PushAction;
export function replace(href: Href, options?: LocationOptions): ReplaceAction;
export function go(index: number): GoAction;
export function goBack(): GoBackAction;
export function goForward(): GoForwardAction;
export function block(historyShouldBlock: BlockCallback): BlockAction;
export function unblock(): UnblockAction;
export function replaceRoutes(routes: Routes): ReplaceRoutesAction;
type HistoryAction = 'PUSH' | 'POP' | 'REPLACE';
type ListenCallback = (location: Location, action?: HistoryAction) => void;
type BlockCallback = (location: Location, action?: HistoryAction) => string;
type Unsubscribe = () => void;
export interface History {
length: number;
location: Location;
action: HistoryAction;
listen(callback: ListenCallback): Unsubscribe;
push(path: string, state?: ObjectLiteral<any>): void;
push(location: Location): void;
replace(path: string, state?: ObjectLiteral<any>): void;
replace(location: Location): void;
go(n: number): void;
goBack(): void;
goForward(): void;
block(message: string): void;
block(callback: BlockCallback): Unsubscribe;
}
export interface Router {
reducer: Reducer<Location>;
middleware: Middleware;
enhancer: StoreEnhancer<Location>;
}
export interface BrowserRouterArgs {
routes: Routes;
basename?: string;
history?: History;
}
export interface HashRouterArgs {
routes: Routes;
basename?: string;
hashType?: string;
history?: History;
}
export interface ExpressRouterArgs {
routes: Routes;
request: {
path: string;
baseUrl: string;
url: string;
query: ObjectLiteral<string>;
passRouterStateToReducer?: boolean;
};
}
export interface HapiRouterArgs {
routes: Routes;
request: {
path: string;
url: string;
query: ObjectLiteral<string>;
};
}
export function routerForBrowser(options: BrowserRouterArgs): Router;
export function routerForExpress(options: ExpressRouterArgs): Router;
export function routerForHapi(options: HapiRouterArgs): Router;
export function routerForHash(options: HashRouterArgs): Router;
export function immutableRouterForBrowser(options: BrowserRouterArgs): Router;
export function immutableRouterForExpress(options: ExpressRouterArgs): Router;
export function immutableRouterForHapi(options: HapiRouterArgs): Router;
export function immutableRouterForHash(options: HashRouterArgs): Router;
export interface LinkProps {
className?: string;
href: Href;
persistQuery?: boolean;
replaceState?: boolean;
target?: string;
onClick?: (event: Event) => any;
style?: ObjectLiteral<any>;
location?: Location;
push?: (href: Href, options: LocationOptions) => {
type: string;
payload: Location;
};
replace?: (href: Href, options: LocationOptions) => {
type: string;
payload: Location;
};
activeProps?: ObjectLiteral<any>;
}
export declare class Link extends React.Component<LinkProps, {}> {}
export declare class ImmutableLink extends React.Component<LinkProps, {}> {}
export declare class PersistentQueryLink extends React.Component<LinkProps, {}> {}
export declare class ImmutablePersistentQueryLink extends React.Component<LinkProps, {}> {}
export interface FragmentProps {
location?: Location;
matchRoute?: Function;
matchWildcardRoute?: Function;
forRoute?: string;
parentRoute?: string;
withConditions?: (location: Location) => boolean;
forNoMatch?: boolean;
parentId?: string;
style?: ObjectLiteral<any>;
}
export declare class Fragment extends React.Component<FragmentProps, {}> {}
export declare class ImmutableFragment extends React.Component<FragmentProps, {}> {}