From 95158ec692f6d72c69fe81a6f601417a10fb99a2 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 31 Oct 2019 23:41:50 -0700 Subject: [PATCH] RN: Export Focus / Blur / Mouse Events Summary: Exports these events in a canonical manner so that they can be used in future refactors. Changelog: [Internal] Reviewed By: TheSavior Differential Revision: D18257693 fbshipit-source-id: aac40277df8a88224c8df29caa04ffc9a6db0a22 --- .../Touchable/TouchableWithoutFeedback.js | 20 +++++++---------- Libraries/Types/CoreEventTypes.js | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index a8982f81b07065..1adc2d14bd4ec9 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -25,7 +25,12 @@ const { DeprecatedAccessibilityRoles, } = require('../../DeprecatedPropTypes/DeprecatedViewAccessibility'); -import type {LayoutEvent, PressEvent} from '../../Types/CoreEventTypes'; +import type { + BlurEvent, + FocusEvent, + LayoutEvent, + PressEvent, +} from '../../Types/CoreEventTypes'; import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; import type { AccessibilityRole, @@ -54,18 +59,7 @@ const OVERRIDE_PROPS = [ 'testID', ]; -type TVEvent = { - dispatchConfig: {}, - tag: number, -}; - -type TVTouchableProps = $ReadOnly<{| - onBlur?: ?(event: TVEvent) => mixed, - onFocus?: ?(event: TVEvent) => mixed, -|}>; - export type Props = $ReadOnly<{| - ...TVTouchableProps, accessibilityActions?: ?$ReadOnlyArray, accessibilityHint?: ?Stringish, accessibilityIgnoresInvertColors?: ?boolean, @@ -83,6 +77,8 @@ export type Props = $ReadOnly<{| hitSlop?: ?EdgeInsetsProp, nativeID?: ?string, onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, onLayout?: ?(event: LayoutEvent) => mixed, onLongPress?: ?(event: PressEvent) => mixed, onPress?: ?(event: PressEvent) => mixed, diff --git a/Libraries/Types/CoreEventTypes.js b/Libraries/Types/CoreEventTypes.js index a8dd79ea17f5d6..04a1cc96575b5b 100644 --- a/Libraries/Types/CoreEventTypes.js +++ b/Libraries/Types/CoreEventTypes.js @@ -129,3 +129,25 @@ export type ScrollEvent = SyntheticEvent< responderIgnoreScroll?: boolean, |}>, >; + +export type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, +>; + +export type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, +>; + +export type MouseEvent = SyntheticEvent< + $ReadOnly<{| + clientX: number, + clientY: number, + pageX: number, + pageY: number, + timestamp: number, + |}>, +>;