'use client'; import styles from '@components/ActionListItem.module.css'; import * as React from 'react'; interface ActionListItemProps { style?: React.CSSProperties; icon?: React.ReactNode; children?: React.ReactNode; href?: string; target?: string; onClick?: React.MouseEventHandler; role?: string; } const ActionListItem: React.FC = (props) => { const { href, target, onClick, children, icon, style, role } = props; const resolvedRole = role || (href ? 'link' : 'button'); if (href) { return (
{icon}
{children}
); } //NOTE(jimmylee): When role="menuitem", the parent menu container handles keyboard activation. const handleKeyDown = role === 'menuitem' ? undefined : (e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { if (e.key === ' ') e.preventDefault(); e.currentTarget.click(); } }; return (
{icon}
{children}
); }; export default ActionListItem;