import { h } from 'preact' import type { ComponentChildren } from 'preact' export type MenuItemProps = { icon?: ComponentChildren children: ComponentChildren onClick: () => void disabled?: boolean } export default function MenuItem ({ icon, children, onClick, disabled = false }: MenuItemProps) { return (
{ if (!disabled && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault() onClick() } }} > {icon && (
{icon}
)}
{children}
) }