diff --git a/Libraries/Components/Pressable/Pressable.js b/Libraries/Components/Pressable/Pressable.js index d8dc1e1d619bef..6f1e6001cfec11 100644 --- a/Libraries/Components/Pressable/Pressable.js +++ b/Libraries/Components/Pressable/Pressable.js @@ -23,7 +23,11 @@ import type { import {PressabilityDebugView} from '../../Pressability/PressabilityDebug'; import usePressability from '../../Pressability/usePressability'; import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect'; -import type {LayoutEvent, PressEvent} from '../../Types/CoreEventTypes'; +import type { + LayoutEvent, + MouseEvent, + PressEvent, +} from '../../Types/CoreEventTypes'; import View from '../View/View'; type ViewStyleProp = $ElementType, 'style'>; @@ -63,6 +67,16 @@ type Props = $ReadOnly<{| */ children: React.Node | ((state: StateCallbackType) => React.Node), + /** + * Duration to wait after hover in before calling `onHoverIn`. + */ + delayHoverIn?: ?number, + + /** + * Duration to wait after hover out before calling `onHoverOut`. + */ + delayHoverOut?: ?number, + /** * Duration (in milliseconds) from `onPressIn` before `onLongPress` is called. */ @@ -89,6 +103,16 @@ type Props = $ReadOnly<{| */ onLayout?: ?(event: LayoutEvent) => mixed, + /** + * Called when the hover is activated to provide visual feedback. + */ + onHoverIn?: ?(event: MouseEvent) => mixed, + + /** + * Called when the hover is deactivated to undo visual feedback. + */ + onHoverOut?: ?(event: MouseEvent) => mixed, + /** * Called when a long-tap gesture is detected. */ @@ -152,9 +176,13 @@ function Pressable(props: Props, forwardedRef): React.Node { android_ripple, cancelable, children, + delayHoverIn, + delayHoverOut, delayLongPress, disabled, focusable, + onHoverIn, + onHoverOut, onLongPress, onPress, onPressIn, @@ -196,8 +224,12 @@ function Pressable(props: Props, forwardedRef): React.Node { hitSlop, pressRectOffset: pressRetentionOffset, android_disableSound, + delayHoverIn, + delayHoverOut, delayLongPress, delayPressIn: unstable_pressDelay, + onHoverIn, + onHoverOut, onLongPress, onPress, onPressIn(event: PressEvent): void { @@ -224,9 +256,13 @@ function Pressable(props: Props, forwardedRef): React.Node { android_disableSound, android_rippleConfig, cancelable, + delayHoverIn, + delayHoverOut, delayLongPress, disabled, hitSlop, + onHoverIn, + onHoverOut, onLongPress, onPress, onPressIn,