import { jsx as _jsx } from "react/jsx-runtime";
import { cnb } from "cnbuilder";
import { forwardRef } from "react";
import { ListItemChildren } from "../list/ListItemChildren.js";
import { listItem } from "../list/listItemStyles.js";
import { CircularProgress } from "../progress/CircularProgress.js";
/**
 * @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 (
 *     <DropdownMenu buttonChildren="Options" visible={visible} setVisible={setVisible}>
 *       {pending && <MenuItemCircularProgress />}
 *       <MenuItem
 *         onClick={handleAsync(async (event) => {
 *           // prevent menu from closing until action completes
 *           event.stopPropagation()
 *
 *           // do something async
 *           await ...
 *
 *           // close menu once completed
 *           setVisible(false)
 *         })}
 *       >
 *         Some Action
 *       </MenuItem>
 *     </DropdownMenu>
 *   )
 * }
 * ```
 *
 * @since 6.0.0
 */ export const MenuItemCircularProgress = /*#__PURE__*/ forwardRef(function MenuItemCircularProgress(props, ref) {
    const { "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 /*#__PURE__*/ _jsx("li", {
        ...liProps,
        ref: ref,
        role: role,
        className: cnb(listItem({
            height,
            className
        }), liProps?.className),
        children: /*#__PURE__*/ _jsx(ListItemChildren, {
            ...listItemChildrenProps,
            leftAddon: leftAddon,
            rightAddon: rightAddon,
            children: /*#__PURE__*/ _jsx(CircularProgress, {
                "aria-label": ariaLabel,
                "aria-labelledby": ariaLabelledBy,
                dense: true,
                ...remaining
            })
        })
    });
});

//# sourceMappingURL=MenuItemCircularProgress.js.map