import React from 'react'; import type { IMenuContextProps } from './props'; import { MenuContext } from './Menu'; import { Text } from '../../primitives'; import { usePropsConfig, themeTools } from '../../../theme'; import { TouchableItem } from './TouchableItem'; import type { IMenuItemProps } from './props'; export const MenuItem = ({ children, onPress, style, textStyle, ...props }: IMenuItemProps) => { const { closeMenu, closeOnSelect }: IMenuContextProps = React.useContext( MenuContext ); const newProps = usePropsConfig('MenuItem', props); let allProps = { ...newProps, ...(newProps.isDisabled ? newProps._disabled : {}), }; const [textProps, touchProps] = themeTools.extractInObject(allProps, [ 'color', 'fontWeight', 'fontStyle', 'fontFamily', 'fontSize', 'padding', 'px', 'py', 'textAlign', ]); return ( { if (!props.isDisabled) { onPress && onPress(e); if (closeOnSelect) { closeMenu(); } } }} > <> {React.Children.map(children, (child) => { if (typeof child === 'string') { return ( {child} ); } else { return child; } })} ); };