import { forwardRef } from "react"; /** * Menu * * size: "sm" | (default) * search: boolean - renders a search input above the item list * searchProps: object - forwarded to the search (value, onChange, placeholder, etc.) * items: MenuItem[] * * MenuItem shape: * label: string | ReactNode * type: "button" | "checkbox" (default: "button") * icon: ReactNode - leading icon; add aria-hidden="true" if decorative * selected: boolean - shows check icon (button) or checked state (checkbox) * disabled: boolean * onClick: function - button items * onChange: function - checkbox items * itemProps: object - forwarded to the or */ const Menu = forwardRef(function Menu( { size, search = false, searchProps = {}, items = [], className = "", ...props }, ref ) { const classes = [ "prs-menu", size === "sm" && "prs-menu-sm", className, ] .filter(Boolean) .join(" "); return ( {search && ( )} {items.map((item, index) => ( {item.type === "checkbox" ? ( ) : ( )} ))} ); }); export default Menu; // --------------------------------------------------------------------------- // Internal item renderers // --------------------------------------------------------------------------- function ButtonItem({ item }) { const { label, icon, selected, disabled, onClick, itemProps = {} } = item; return ( {icon && ( {icon} )} {label} {selected && ( )} ); } function CheckboxItem({ item }) { const { label, selected, disabled, onChange, itemProps = {} } = item; return ( {label} ); } // Internal check icon - always decorative (aria-label is on the wrapper span) const CheckIcon = () => ( );