Skip to content

Commit

Permalink
Merge pull request #141 from flexn-io/fix/improve-rnw-types
Browse files Browse the repository at this point in the history
fix: rnw mouse, hover, accessibilityLevel types
  • Loading branch information
mihaiblaga89 authored Jul 21, 2023
2 parents a38a09c + d2fbc65 commit 69ae6cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/create/src/focusManager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
ColorValue,
View as RNView,
} from 'react-native';
import type { MouseEvent, PointerEvent } from 'react';
import type { FlashListProps as FLProps, ListRenderItemInfo } from '@flexn/shopify-flash-list';

import FocusModel from './model/abstractFocusModel';
Expand Down Expand Up @@ -113,7 +114,17 @@ export type RecyclableListFocusOptions = {
autoLayoutSize?: number;
};

export interface ViewProps extends RNViewProps {
type MouseEvents = {
onMouseDown?: (e: MouseEvent) => void;
onMouseEnter?: (e: MouseEvent) => void;
onMouseLeave?: (e: MouseEvent) => void;
onMouseMove?: (e: MouseEvent) => void;
onMouseOver?: (e: MouseEvent) => void;
onMouseOut?: (e: MouseEvent) => void;
onMouseUp?: (e: MouseEvent) => void;
};

export interface ViewProps extends RNViewProps, MouseEvents {
focusOptions?: {
group?: string;
focusKey?: string;
Expand All @@ -140,7 +151,7 @@ export interface ViewGroupProps extends RNViewProps {
ref?: React.ForwardedRef<RNView> | React.MutableRefObject<RNView>;
}

export interface PressableProps extends RNPressableProps {
export interface PressableProps extends RNPressableProps, MouseEvents {
focus?: boolean;
focusOptions?: PressableFocusOptions;
focusContext?: FocusContext;
Expand All @@ -150,8 +161,8 @@ export interface PressableProps extends RNPressableProps {
onFocus?: () => void;
className?: string;
style?: ViewProps['style'];
onHoverIn?: null | ((event: MouseEvent) => void) | undefined;
onHoverOut?: null | ((event: MouseEvent) => void) | undefined;
onHoverIn?: (e: PointerEvent) => void;
onHoverOut?: (e: PointerEvent) => void;
}

export interface TouchableOpacityProps extends RNTouchableOpacityProps {
Expand Down
8 changes: 8 additions & 0 deletions packages/create/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ export {
RemoteHandlerCallback,
ClassRemoteHandlerCallback,
} from './remoteHandler';

// Type declarations
import 'react-native';
declare module 'react-native' {
interface AccessibilityProps {
accessibilityLevel?: number;
}
}

0 comments on commit 69ae6cc

Please sign in to comment.