Skip to content

Commit

Permalink
Fix pressable types - drop invalid Children props
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejSWM committed Dec 14, 2023
1 parent bbe82dc commit e5d8ea7
Showing 1 changed file with 47 additions and 48 deletions.
95 changes: 47 additions & 48 deletions src/components/PressableWithSecondaryInteraction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,52 @@ import {GestureResponderEvent, StyleProp, TextStyle, ViewStyle} from 'react-nati
import {PressableWithFeedbackProps} from '@components/Pressable/PressableWithFeedback';
import ChildrenProps from '@src/types/utils/ChildrenProps';

type PressableWithSecondaryInteractionProps = PressableWithFeedbackProps &
ChildrenProps & {
/** The function that should be called when this pressable is pressed */
onPress: (event?: GestureResponderEvent) => void;

/** The function that should be called when this pressable is pressedIn */
onPressIn?: (event?: GestureResponderEvent) => void;

/** The function that should be called when this pressable is pressedOut */
onPressOut?: (event?: GestureResponderEvent) => void;

/**
* The function that should be called when this pressable is LongPressed or right-clicked.
*
* This function should be stable, preferably wrapped in a `useCallback` so that it does not
* cause several re-renders.
*/
onSecondaryInteraction?: (event: GestureResponderEvent | MouseEvent) => void;

/** Prevent the default ContextMenu on web/Desktop */
preventDefaultContextMenu?: boolean;

/** Use Text instead of Pressable to create inline layout.
* It has few limitations in comparison to Pressable.
*
* - No support for delayLongPress.
* - No support for pressIn and pressOut events.
* - No support for opacity
*
* Note: Web uses styling instead of Text due to no support of LongPress. Thus above pointers are not valid for web.
*/
inline?: boolean;

/** Disable focus trap for the element on secondary interaction */
withoutFocusOnSecondaryInteraction?: boolean;

/** Opacity to reduce to when active */
activeOpacity?: number;

/** Used to apply styles to the Pressable */
style?: StyleProp<ViewStyle & TextStyle>;

/** Whether the long press with hover behavior is enabled */
enableLongPressWithHover?: boolean;

/** Whether the text has a gray highlights on press down (for IOS only) */
suppressHighlighting?: boolean;
};
type PressableWithSecondaryInteractionProps = PressableWithFeedbackProps & {
/** The function that should be called when this pressable is pressed */
onPress: (event?: GestureResponderEvent) => void;

/** The function that should be called when this pressable is pressedIn */
onPressIn?: (event?: GestureResponderEvent) => void;

/** The function that should be called when this pressable is pressedOut */
onPressOut?: (event?: GestureResponderEvent) => void;

/**
* The function that should be called when this pressable is LongPressed or right-clicked.
*
* This function should be stable, preferably wrapped in a `useCallback` so that it does not
* cause several re-renders.
*/
onSecondaryInteraction?: (event: GestureResponderEvent | MouseEvent) => void;

/** Prevent the default ContextMenu on web/Desktop */
preventDefaultContextMenu?: boolean;

/** Use Text instead of Pressable to create inline layout.
* It has few limitations in comparison to Pressable.
*
* - No support for delayLongPress.
* - No support for pressIn and pressOut events.
* - No support for opacity
*
* Note: Web uses styling instead of Text due to no support of LongPress. Thus above pointers are not valid for web.
*/
inline?: boolean;

/** Disable focus trap for the element on secondary interaction */
withoutFocusOnSecondaryInteraction?: boolean;

/** Opacity to reduce to when active */
activeOpacity?: number;

/** Used to apply styles to the Pressable */
style?: StyleProp<ViewStyle & TextStyle>;

/** Whether the long press with hover behavior is enabled */
enableLongPressWithHover?: boolean;

/** Whether the text has a gray highlights on press down (for IOS only) */
suppressHighlighting?: boolean;
};

export default PressableWithSecondaryInteractionProps;

0 comments on commit e5d8ea7

Please sign in to comment.