/* * Copyright 2025 New Vector Ltd * * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial * Please see LICENSE files in the repository root for full details. */ import React, { type ComponentProps, forwardRef, useCallback, useId, } from "react"; import { MenuItem } from "./MenuItem"; import { RadioInput } from "../Form"; type Props = Pick< ComponentProps, "className" | "label" | "onSelect" | "disabled" > & { /** * Whether the radio is checked. */ checked: boolean; }; /** * A menu item with a radio control. * Must be used within a compound Menu or other `menu` or `menubar` aria role subtree. */ export const RadioMenuItem = forwardRef( function RadioMenuItem( { className, label, onSelect, checked, disabled }, ref, ) { const toggleId = useId(); // The radio is controlled and we intend to ignore its events. We do need // to at least set onChange though to make React happy. const onChange = useCallback(() => {}, []); //