import React, { forwardRef, type ReactNode } from 'react' import { MenuItem as RACMenuItem, type MenuItemProps as RACMenuItemProps, } from 'react-aria-components' import { mergeClassNames } from '~components/utils/mergeClassNames' import styles from './MenuItem.module.css' export type MenuItemProps = RACMenuItemProps & { /** * Provides positioning for an icon to the left of the menu item content */ icon?: ReactNode } /** * A MenuItem represents an individual action in a Menu. */ export const MenuItem = forwardRef( ({ className, icon, children, textValue, ...props }, ref): JSX.Element => { const determinedTextValue = textValue ?? (typeof children === 'string' ? children : undefined) return ( {typeof children === 'string' && icon ? (
{icon} {children}
) : ( children )}
) }, ) MenuItem.displayName = 'MenuItem'