@@ -7,7 +7,94 @@ wip: true
77``` reason
88// see https://github.com/facebook/react-native/blob/master/Libraries/Types/CoreEventTypes.js
99
10- type event('a) = {. "nativeEvent": 'a};
10+ type syntheticEvent('a) = {
11+ .
12+ "bubbles": Js.Nullable.t(bool),
13+ "cancelable": Js.Nullable.t(bool),
14+ "currentTarget": float,
15+ "defaultPrevented": Js.Nullable.t(bool),
16+ "dispatchConfig": {. "registrationName": string},
17+ "eventPhase": Js.Nullable.t(float),
18+ "preventDefault": unit => unit,
19+ "isDefaultPrevented": unit => bool,
20+ "stopPropagation": unit => unit,
21+ "isPropagationStopped": unit => bool,
22+ "isTrusted": Js.Nullable.t(bool),
23+ "nativeEvent": 'a,
24+ "persist": unit => unit,
25+ "target": Js.Nullable.t(float),
26+ "timeStamp": float,
27+ "_type": Js.Nullable.t(string),
28+ };
29+
30+ type responderSyntheticEvent('a) = {
31+ .
32+ // synthethicEvent keys
33+ "bubbles": Js.Nullable.t(bool),
34+ "cancelable": Js.Nullable.t(bool),
35+ "currentTarget": float,
36+ "defaultPrevented": Js.Nullable.t(bool),
37+ "dispatchConfig": {. "registrationName": string},
38+ "eventPhase": Js.Nullable.t(float),
39+ "preventDefault": unit => unit,
40+ "isDefaultPrevented": unit => bool,
41+ "stopPropagation": unit => unit,
42+ "isPropagationStopped": unit => bool,
43+ "isTrusted": Js.Nullable.t(bool),
44+ "nativeEvent": 'a,
45+ "persist": unit => unit,
46+ "target": Js.Nullable.t(float),
47+ "timeStamp": float,
48+ "_type": Js.Nullable.t(string),
49+ // responderSyntheticEvent additional key
50+ "touchHistory": {
51+ .
52+ "indexOfSingleActiveTouch": float,
53+ "mostRecentTimeStamp": float,
54+ "numberActiveTouches": float,
55+ "touchBank":
56+ array({
57+ .
58+ "touchActive": bool,
59+ "startPageX": float,
60+ "startPageY": float,
61+ "startTimeStamp": float,
62+ "currentPageX": float,
63+ "currentPageY": float,
64+ "currentTimeStamp": float,
65+ "previousPageX": float,
66+ "previousPageY": float,
67+ "previousTimeStamp": float,
68+ }),
69+ },
70+ };
71+
72+ type textLayout = {
73+ .
74+ "x": float,
75+ "y": float,
76+ "width": float,
77+ "height": float,
78+ "ascender": float, // verify
79+ "capHeight": float, // verify
80+ "descender": float, // verify
81+ "text": string,
82+ "xHeight": float // verify
83+ };
84+
85+ type layoutEvent =
86+ syntheticEvent({
87+ .
88+ "layout": {
89+ .
90+ "x": float,
91+ "y": float,
92+ "width": float,
93+ "height": float,
94+ },
95+ });
96+
97+ type textLayoutEvent = syntheticEvent({. "lines": array(textLayout)});
1198
1299type pressEventPayload = {
13100 .
@@ -23,7 +110,7 @@ type pressEventPayload = {
23110 "touches": array(pressEventPayload),
24111};
25112
26- type pressEvent = event (pressEventPayload);
113+ type pressEvent = responderSyntheticEvent (pressEventPayload);
27114
28115type position = {
29116 .
@@ -38,7 +125,7 @@ type dimensions = {
38125};
39126
40127type scrollEvent =
41- event ({
128+ syntheticEvent ({
42129 .
43130 "contentInset": {
44131 .
@@ -52,16 +139,6 @@ type scrollEvent =
52139 "layoutMeasurement": dimensions,
53140 });
54141
55- type layoutEvent =
56- event({
57- .
58- "layout": {
59- .
60- "x": float,
61- "y": float,
62- "width": float,
63- "height": float,
64- },
65- });
142+ type switchChangeEvent = syntheticEvent({. "value": bool});
66143
67144```
0 commit comments