1 | /**
|
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | *
|
7 | * @format
|
8 | */
|
9 |
|
10 | import type * as React from 'react';
|
11 | import {HostComponent} from '../../types/public/ReactNativeTypes';
|
12 |
|
13 | export interface LayoutRectangle {
|
14 | x: number;
|
15 | y: number;
|
16 | width: number;
|
17 | height: number;
|
18 | }
|
19 |
|
20 | // @see TextProps.onLayout
|
21 | export type LayoutChangeEvent = NativeSyntheticEvent<{layout: LayoutRectangle}>;
|
22 |
|
23 | interface TextLayoutLine {
|
24 | ascender: number;
|
25 | capHeight: number;
|
26 | descender: number;
|
27 | height: number;
|
28 | text: string;
|
29 | width: number;
|
30 | x: number;
|
31 | xHeight: number;
|
32 | y: number;
|
33 | }
|
34 |
|
35 | /**
|
36 | * @see TextProps.onTextLayout
|
37 | */
|
38 | export interface TextLayoutEventData extends TargetedEvent {
|
39 | lines: TextLayoutLine[];
|
40 | }
|
41 |
|
42 | // Similar to React.SyntheticEvent except for nativeEvent
|
43 | export interface NativeSyntheticEvent<T>
|
44 | extends React.BaseSyntheticEvent<
|
45 | T,
|
46 | React.ElementRef<HostComponent<unknown>>,
|
47 | React.ElementRef<HostComponent<unknown>>
|
48 | > {}
|
49 |
|
50 | export interface NativeTouchEvent {
|
51 | /**
|
52 | * Array of all touch events that have changed since the last event
|
53 | */
|
54 | changedTouches: NativeTouchEvent[];
|
55 |
|
56 | /**
|
57 | * The ID of the touch
|
58 | */
|
59 | identifier: string;
|
60 |
|
61 | /**
|
62 | * The X position of the touch, relative to the element
|
63 | */
|
64 | locationX: number;
|
65 |
|
66 | /**
|
67 | * The Y position of the touch, relative to the element
|
68 | */
|
69 | locationY: number;
|
70 |
|
71 | /**
|
72 | * The X position of the touch, relative to the screen
|
73 | */
|
74 | pageX: number;
|
75 |
|
76 | /**
|
77 | * The Y position of the touch, relative to the screen
|
78 | */
|
79 | pageY: number;
|
80 |
|
81 | /**
|
82 | * The node id of the element receiving the touch event
|
83 | */
|
84 | target: string;
|
85 |
|
86 | /**
|
87 | * A time identifier for the touch, useful for velocity calculation
|
88 | */
|
89 | timestamp: number;
|
90 |
|
91 | /**
|
92 | * Array of all current touches on the screen
|
93 | */
|
94 | touches: NativeTouchEvent[];
|
95 |
|
96 | /**
|
97 | * 3D Touch reported force
|
98 | * @platform ios
|
99 | */
|
100 | force?: number | undefined;
|
101 | }
|
102 |
|
103 | /**
|
104 | * https://developer.mozilla.org/en-US/docs/Web/API/UIEvent
|
105 | */
|
106 | export interface NativeUIEvent {
|
107 | /**
|
108 | * Returns a long with details about the event, depending on the event type.
|
109 | */
|
110 | readonly detail: number;
|
111 | }
|
112 |
|
113 | /**
|
114 | * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
|
115 | */
|
116 | export interface NativeMouseEvent extends NativeUIEvent {
|
117 | /**
|
118 | * The X coordinate of the mouse pointer in global (screen) coordinates.
|
119 | */
|
120 | readonly screenX: number;
|
121 | /**
|
122 | * The Y coordinate of the mouse pointer in global (screen) coordinates.
|
123 | */
|
124 | readonly screenY: number;
|
125 | /**
|
126 | * The X coordinate of the mouse pointer relative to the whole document.
|
127 | */
|
128 | readonly pageX: number;
|
129 | /**
|
130 | * The Y coordinate of the mouse pointer relative to the whole document.
|
131 | */
|
132 | readonly pageY: number;
|
133 | /**
|
134 | * The X coordinate of the mouse pointer in local (DOM content) coordinates.
|
135 | */
|
136 | readonly clientX: number;
|
137 | /**
|
138 | * The Y coordinate of the mouse pointer in local (DOM content) coordinates.
|
139 | */
|
140 | readonly clientY: number;
|
141 | /**
|
142 | * Alias for NativeMouseEvent.clientX
|
143 | */
|
144 | readonly x: number;
|
145 | /**
|
146 | * Alias for NativeMouseEvent.clientY
|
147 | */
|
148 | readonly y: number;
|
149 | /**
|
150 | * Returns true if the control key was down when the mouse event was fired.
|
151 | */
|
152 | readonly ctrlKey: boolean;
|
153 | /**
|
154 | * Returns true if the shift key was down when the mouse event was fired.
|
155 | */
|
156 | readonly shiftKey: boolean;
|
157 | /**
|
158 | * Returns true if the alt key was down when the mouse event was fired.
|
159 | */
|
160 | readonly altKey: boolean;
|
161 | /**
|
162 | * Returns true if the meta key was down when the mouse event was fired.
|
163 | */
|
164 | readonly metaKey: boolean;
|
165 | /**
|
166 | * The button number that was pressed (if applicable) when the mouse event was fired.
|
167 | */
|
168 | readonly button: number;
|
169 | /**
|
170 | * The buttons being depressed (if any) when the mouse event was fired.
|
171 | */
|
172 | readonly buttons: number;
|
173 | /**
|
174 | * The secondary target for the event, if there is one.
|
175 | */
|
176 | readonly relatedTarget:
|
177 | | null
|
178 | | number
|
179 | | React.ElementRef<HostComponent<unknown>>;
|
180 | // offset is proposed: https://drafts.csswg.org/cssom-view/#extensions-to-the-mouseevent-interface
|
181 | /**
|
182 | * The X coordinate of the mouse pointer between that event and the padding edge of the target node
|
183 | */
|
184 | readonly offsetX: number;
|
185 | /**
|
186 | * The Y coordinate of the mouse pointer between that event and the padding edge of the target node
|
187 | */
|
188 | readonly offsetY: number;
|
189 | }
|
190 |
|
191 | /**
|
192 | * https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent
|
193 | */
|
194 | export interface NativePointerEvent extends NativeMouseEvent {
|
195 | /**
|
196 | * A unique identifier for the pointer causing the event.
|
197 | */
|
198 | readonly pointerId: number;
|
199 | /**
|
200 | * The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer
|
201 | */
|
202 | readonly width: number;
|
203 | /**
|
204 | * The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer.
|
205 | */
|
206 | readonly height: number;
|
207 | /**
|
208 | * The normalized pressure of the pointer input in the range 0 to 1, where 0 and 1 represent
|
209 | * the minimum and maximum pressure the hardware is capable of detecting, respectively.
|
210 | */
|
211 | readonly pressure: number;
|
212 | /**
|
213 | * The normalized tangential pressure of the pointer input (also known as barrel pressure or
|
214 | * cylinder stress) in the range -1 to 1, where 0 is the neutral position of the control.
|
215 | */
|
216 | readonly tangentialPressure: number;
|
217 | /**
|
218 | * The plane angle (in degrees, in the range of -90 to 90) between the Y–Z plane and the plane
|
219 | * containing both the pointer (e.g. pen stylus) axis and the Y axis.
|
220 | */
|
221 | readonly tiltX: number;
|
222 | /**
|
223 | * The plane angle (in degrees, in the range of -90 to 90) between the X–Z plane and the plane
|
224 | * containing both the pointer (e.g. pen stylus) axis and the X axis.
|
225 | */
|
226 | readonly tiltY: number;
|
227 | /**
|
228 | * The clockwise rotation of the pointer (e.g. pen stylus) around its major axis in degrees,
|
229 | * with a value in the range 0 to 359.
|
230 | */
|
231 | readonly twist: number;
|
232 | /**
|
233 | * Indicates the device type that caused the event (mouse, pen, touch, etc.)
|
234 | */
|
235 | readonly pointerType: string;
|
236 | /**
|
237 | * Indicates if the pointer represents the primary pointer of this pointer type.
|
238 | */
|
239 | readonly isPrimary: boolean;
|
240 | }
|
241 |
|
242 | export type PointerEvent = NativeSyntheticEvent<NativePointerEvent>;
|
243 |
|
244 | export interface GestureResponderEvent
|
245 | extends NativeSyntheticEvent<NativeTouchEvent> {}
|
246 |
|
247 | export interface MouseEvent extends NativeSyntheticEvent<NativeMouseEvent> {}
|
248 |
|
249 | export interface TargetedEvent {
|
250 | target: number;
|
251 | }
|
252 |
|
253 | export interface PointerEvents {
|
254 | onPointerEnter?: ((event: PointerEvent) => void) | undefined;
|
255 | onPointerEnterCapture?: ((event: PointerEvent) => void) | undefined;
|
256 | onPointerLeave?: ((event: PointerEvent) => void) | undefined;
|
257 | onPointerLeaveCapture?: ((event: PointerEvent) => void) | undefined;
|
258 | onPointerMove?: ((event: PointerEvent) => void) | undefined;
|
259 | onPointerMoveCapture?: ((event: PointerEvent) => void) | undefined;
|
260 | onPointerCancel?: ((event: PointerEvent) => void) | undefined;
|
261 | onPointerCancelCapture?: ((event: PointerEvent) => void) | undefined;
|
262 | onPointerDown?: ((event: PointerEvent) => void) | undefined;
|
263 | onPointerDownCapture?: ((event: PointerEvent) => void) | undefined;
|
264 | onPointerUp?: ((event: PointerEvent) => void) | undefined;
|
265 | onPointerUpCapture?: ((event: PointerEvent) => void) | undefined;
|
266 | }
|
267 |
|
\ | No newline at end of file |