import { cnb } from "cnbuilder"; import { type HTMLAttributes, type ReactElement, type ReactNode, type Ref, } from "react"; import { ListItemChildren } from "../list/ListItemChildren.js"; import { listItem } from "../list/listItemStyles.js"; import { type ListItemChildrenProps, type ListItemHeight, } from "../list/types.js"; import { CircularProgress, type CircularProgressProps, } from "../progress/CircularProgress.js"; /** * @since 6.0.0 */ export interface MenuItemCircularProgressProps extends CircularProgressProps { ref?: Ref; /** @defaultValue `"Loading"` */ "aria-label"?: string; /** @defaultValue `"none"` */ role?: string; /** @defaultValue `true` */ dense?: boolean; liProps?: HTMLAttributes; height?: ListItemHeight; leftAddon?: ReactNode; rightAddon?: ReactNode; listItemChildrenProps?: ListItemChildrenProps; } /** * @example Simple Example * ```tsx * "use client"; * import { DropdownMenu } from "@react-md/core/menu/DropdownMenu"; * import { MenuItem } from "@react-md/core/menu/MenuItem"; * import { MenuItemCircularProgress } from "@react-md/core/menu/MenuItemCircularProgress"; * import { useAsyncFunction } from "@react-md/core/useAsyncFunction"; * * function Example() { * const { handleAsync, pending } = useAsyncFunction(); * const [visible, setVisible] = useState(false); * * return ( * * {pending && } * { * // prevent menu from closing until action completes * event.stopPropagation() * * // do something async * await ... * * // close menu once completed * setVisible(false) * })} * > * Some Action * * * ) * } * ``` * * @since 6.0.0 */ export function MenuItemCircularProgress( props: MenuItemCircularProgressProps ): ReactElement { const { ref, "aria-label": propAriaLabel, "aria-labelledby": ariaLabelledBy, role = "none", className, height, leftAddon, rightAddon, liProps, listItemChildrenProps, ...remaining } = props; let ariaLabel = propAriaLabel; if (!ariaLabel && !ariaLabelledBy) { ariaLabel = "Loading"; } return (
  • ); }