diff --git a/types/__typetests__/index.tsx b/types/__typetests__/index.tsx index a55c2992edab69..b3982784ff8f56 100644 --- a/types/__typetests__/index.tsx +++ b/types/__typetests__/index.tsx @@ -66,6 +66,7 @@ import { LogBox, MaskedViewIOS, Modal, + MouseEvent, NativeEventEmitter, NativeModule, // Not actually exported, not sure why NativeModules, @@ -496,6 +497,12 @@ export class PressableTest extends React.Component<{}> { e.isDefaultPrevented(); }; + onHoverButton = (e: MouseEvent) => { + e.persist(); + e.isPropagationStopped(); + e.isDefaultPrevented(); + }; + render() { return ( <> @@ -550,6 +557,15 @@ export class PressableTest extends React.Component<{}> { Button + {/* onHoverIn */} + + + Button + + ); } diff --git a/types/index.d.ts b/types/index.d.ts index 96d95e1bbaec9f..3d643f31aafafb 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -49,6 +49,7 @@ // Zihan Chen // Lorenzo Sciandra // Mateusz Wit +// Saad Najmi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 @@ -579,6 +580,8 @@ export type PointerEvent = NativeSyntheticEvent; export interface GestureResponderEvent extends NativeSyntheticEvent {} +export interface MouseEvent extends NativeSyntheticEvent {} + // See https://reactnative.dev/docs/scrollview#contentoffset export interface PointProp { x: number; @@ -606,6 +609,16 @@ export interface PressableAndroidRippleConfig { export interface PressableProps extends AccessibilityProps, Omit { + /** + * Called when the hover is activated to provide visual feedback. + */ + onHoverIn?: null | ((event: MouseEvent) => void) | undefined; + + /** + * Called when the hover is deactivated to undo visual feedback. + */ + onHoverOut?: null | ((event: MouseEvent) => void) | undefined; + /** * Called when a single tap gesture is detected. */ @@ -628,7 +641,7 @@ export interface PressableProps /** * Called after the element loses focus. - * @platform windows + * @platform macos windows */ onBlur?: | null @@ -637,7 +650,7 @@ export interface PressableProps /** * Called after the element is focused. - * @platform windows + * @platform macos windows */ onFocus?: | null @@ -659,6 +672,18 @@ export interface PressableProps */ cancelable?: null | boolean | undefined; + /** + * Duration to wait after hover in before calling `onHoverIn`. + * @platform macos windows + */ + delayHoverIn?: number | null | undefined; + + /** + * Duration to wait after hover out before calling `onHoverOut`. + * @platform macos windows + */ + delayHoverOut?: number | null | undefined; + /** * Duration (in milliseconds) from `onPressIn` before `onLongPress` is called. */