Skip to content

Commit

Permalink
RN: Export Focus / Blur / Mouse Events
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Nov 1, 2019
1 parent 1a520e7 commit 95158ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<AccessibilityActionInfo>,
accessibilityHint?: ?Stringish,
accessibilityIgnoresInvertColors?: ?boolean,
Expand All @@ -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,
Expand Down
22 changes: 22 additions & 0 deletions Libraries/Types/CoreEventTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
|}>,
>;

0 comments on commit 95158ec

Please sign in to comment.