Skip to content

Commit 8ed6257

Browse files
committed
Complete the extern
1 parent 3f62b36 commit 8ed6257

11 files changed

+121
-46
lines changed

src/react/ReactRouter.hx

-46
This file was deleted.

src/react/router/IndexLink.hx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package react.router;
2+
3+
@:jsRequire('react-router', 'IndexLink')
4+
extern class IndexLink extends react.ReactComponent {}

src/react/router/IndexRedirect.hx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package react.router;
2+
3+
@:jsRequire('react-router', 'IndexRedirect')
4+
extern class IndexRedirect extends react.ReactComponent {}

src/react/router/IndexRoute.hx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package react.router;
2+
3+
@:jsRequire('react-router', 'IndexRoute')
4+
extern class IndexRoute extends react.ReactComponent {}

src/react/router/Link.hx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package react.router;
2+
3+
@:jsRequire('react-router','Link')
4+
extern class Link extends react.ReactComponent {}

src/react/router/Redirect.hx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package react.router;
2+
3+
@:jsRequire('react-router', 'Redirect')
4+
extern class Redirect extends react.ReactComponent {}

src/react/router/Route.hx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package react.router;
2+
3+
@:jsRequire('react-router', 'Route')
4+
extern class Route extends react.ReactComponent {}

src/react/router/Router.hx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package react.router;
2+
3+
@:jsRequire('react-router', 'Router')
4+
extern class Router extends react.ReactComponent {}

src/react/router/RouterContext.hx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package react.router;
2+
3+
@:jsRequire('react-router', 'RouterContext')
4+
extern class RouterContext extends react.ReactComponent {}

src/react/router/Statics.hx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package react.router;
2+
3+
import react.router.Types;
4+
5+
@:jsRequire('react-router')
6+
extern class Statics {
7+
static public var hashHistory:HashHistory;
8+
static public var browserHistory:BrowserHistory;
9+
static public var withRouter:Dynamic->Dynamic;
10+
}

src/react/router/Types.hx

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package react.router;
2+
3+
import haxe.extern.EitherType;
4+
import haxe.Constraints;
5+
import react.ReactComponent;
6+
7+
typedef HashHistory = Router;
8+
typedef BrowserHistory = Router;
9+
typedef RoutePropsOfParams<P> = RoutePropsOf<P, Dynamic>;
10+
typedef RoutePropsOfQuery<Q> = RoutePropsOf<Dynamic, Q>;
11+
12+
typedef RoutePropsOf<P, Q> = {
13+
params:P,
14+
location:{
15+
query:Q,
16+
}
17+
}
18+
19+
private typedef Object = Dynamic;
20+
@:enum
21+
private abstract Action(String) {
22+
var Push = 'PUSH';
23+
var Replace = 'REPLACE';
24+
var Pop = 'POP';
25+
}
26+
private typedef Component = EitherType<Class<ReactComponent>, String>;
27+
private typedef EnterHook = RouterState->RedirectFunction->?Function->Any;
28+
private typedef Hash = String;
29+
private typedef LeaveHook = RouterState->Any;
30+
private typedef Location = {
31+
pathname:Pathname,
32+
search:QueryString,
33+
query:Query,
34+
state:LocationState,
35+
action:Action,
36+
key:LocationKey,
37+
};
38+
private typedef LocationDescriptorObject = {
39+
pathname:Pathname,
40+
search:QueryString,
41+
query:Query,
42+
state:LocationState,
43+
};
44+
private typedef LocationDescriptor = EitherType<LocationDescriptorObject, Path>;
45+
private typedef LocationKey = String;
46+
private typedef LocationState = Object;
47+
private typedef Params = Object;
48+
private typedef Path = String; // Pathname + QueryString + Hash;
49+
private typedef Pathname = String;
50+
private typedef Query = Object;
51+
private typedef QueryString = String;
52+
private typedef RedirectFunction = ?LocationState->EitherType<Pathname, Path>->?Query->Void;
53+
54+
private typedef Route = {
55+
component:RouteComponent,
56+
?path:RoutePattern,
57+
?onEnter:EnterHook,
58+
?onLeave:LeaveHook,
59+
}
60+
61+
private typedef RouteComponent = Component;
62+
private typedef RouteConfig = Array<Route>;
63+
private typedef RouteHook = ?Location->Any;
64+
private typedef RoutePattern = String;
65+
private typedef Router = {
66+
push:LocationDescriptor->Void,
67+
replace:LocationDescriptor->Void,
68+
go:Int->Void,
69+
goBack:Void->Void,
70+
goForward:Void->Void,
71+
setRouteLeaveHook:Route->RouteHook->Function,
72+
isActive:LocationDescriptor->Bool->Void,
73+
}
74+
private typedef RouterState = {
75+
location:Location,
76+
routes:Array<Route>,
77+
params:Params,
78+
components:Array<Component>,
79+
}

0 commit comments

Comments
 (0)