@@ -6,8 +6,6 @@ module React
6
6
, ReactThis
7
7
, TagName
8
8
9
- , EventHandler
10
-
11
9
, Read
12
10
, Write
13
11
, Disallowed
@@ -30,18 +28,11 @@ module React
30
28
, ReactClass
31
29
, Ref
32
30
33
- , Event
34
- , MouseEvent
35
- , KeyboardEvent
36
-
37
- , EventHandlerContext
38
-
39
31
, component
40
32
, pureComponent
41
33
, statelessComponent
42
34
43
35
, getProps
44
-
45
36
, readState
46
37
, writeState
47
38
, writeStateWithCallback
@@ -50,16 +41,16 @@ module React
50
41
, forceUpdate
51
42
, forceUpdateCb
52
43
53
- , handle
54
- , preventDefault
55
- , stopPropagation
56
-
57
44
, createElement
58
45
, createElementDynamic
59
46
, createElementTagName
60
47
, createElementTagNameDynamic
61
48
, createLeafElement
62
49
50
+ , SyntheticEventHandler
51
+ , SyntheticEventHandlerContext
52
+ , handle
53
+
63
54
, Children
64
55
, childrenToArray
65
56
, childrenCount
@@ -68,14 +59,20 @@ module React
68
59
, class IsReactElement
69
60
, toElement
70
61
, fragmentWithKey
62
+
63
+ , module SyntheticEvent
71
64
) where
72
65
73
66
import Prelude
74
67
75
68
import Control.Monad.Eff (kind Effect , Eff )
76
69
import Control.Monad.Eff.Exception (Error )
77
70
import Control.Monad.Eff.Uncurried (EffFn2 , runEffFn2 )
71
+
78
72
import Data.Nullable (Nullable )
73
+
74
+ import React.SyntheticEvent (preventDefault , isDefaultPrevented , stopPropagation , isPropagationStopped , persist ) as SyntheticEvent
75
+
79
76
import Unsafe.Coerce (unsafeCoerce )
80
77
81
78
-- | Name of a tag.
@@ -91,7 +88,7 @@ foreign import data ReactComponent :: Type
91
88
foreign import data ReactThis :: Type -> Type -> Type
92
89
93
90
-- | An event handler. The type argument represents the type of the event.
94
- foreign import data EventHandler :: Type -> Type
91
+ foreign import data SyntheticEventHandler :: Type -> Type
95
92
96
93
-- | This phantom type indicates that read access to a resource is allowed.
97
94
foreign import data Read :: Effect
@@ -116,32 +113,8 @@ foreign import data ReactState :: # Effect -> Effect
116
113
-- | This effect indicates that a computation may read the component props.
117
114
foreign import data ReactProps :: Effect
118
115
119
- -- | The type of DOM events.
120
- foreign import data Event :: Type
121
-
122
- -- | The type of mouse events.
123
- type MouseEvent =
124
- { pageX :: Number
125
- , pageY :: Number
126
- }
127
-
128
- -- | The type of keyboard events.
129
- type KeyboardEvent =
130
- { altKey :: Boolean
131
- , ctrlKey :: Boolean
132
- , charCode :: Int
133
- , key :: String
134
- , keyCode :: Int
135
- , locale :: String
136
- , location :: Int
137
- , metaKey :: Boolean
138
- , repeat :: Boolean
139
- , shiftKey :: Boolean
140
- , which :: Int
141
- }
142
-
143
116
-- | A function which handles events.
144
- type EventHandlerContext eff props state result =
117
+ type SyntheticEventHandlerContext eff props state result =
145
118
Eff
146
119
( props :: ReactProps
147
120
, state :: ReactState ReadWrite
@@ -355,13 +328,13 @@ forceUpdateCb this m = runEffFn2 forceUpdateCbImpl this m
355
328
356
329
-- | Create an event handler.
357
330
foreign import handle :: forall eff ev props state result .
358
- (ev -> EventHandlerContext eff props state result ) -> EventHandler ev
331
+ (ev -> SyntheticEventHandlerContext eff props state result ) -> SyntheticEventHandler ev
359
332
360
333
class ReactPropFields (required :: # Type ) (given :: # Type )
361
334
362
335
type ReservedReactPropFields r =
363
336
( key :: String
364
- , ref :: EventHandler (Nullable Ref )
337
+ , ref :: SyntheticEventHandler (Nullable Ref )
365
338
| r
366
339
)
367
340
@@ -423,10 +396,6 @@ foreign import childrenToArray :: Children -> Array ReactElement
423
396
-- | Returns the number of children.
424
397
foreign import childrenCount :: Children -> Int
425
398
426
- foreign import preventDefault :: forall eff . Event -> Eff eff Unit
427
-
428
- foreign import stopPropagation :: forall eff . Event -> Eff eff Unit
429
-
430
399
class IsReactElement a where
431
400
toElement :: a -> ReactElement
432
401
0 commit comments