"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef } from "react";
import { getIcon } from "../icon/iconConfig.js";
import { MenuItem } from "../menu/MenuItem.js";
import { useEnsuredId } from "../useEnsuredId.js";
const noop = ()=>{
// do nothing
};
/**
 * **Client Component**
 *
 * A wrapper for the `<input type="file">` element that works within menus.
 *
 * @remarks
 * \@since 5.0.0
 * \@since 6.0.0 No longer creates an invisible file input element within the
 * menu item. This allows the menu to be closed immediately when this menu item
 * is clicked.
 */ export const MenuItemFileInput = /*#__PURE__*/ forwardRef(function MenuItemFileInput(props, ref) {
    const { id: propId, onClick = noop, onChange, accept = "", multiple = false, children, leftAddon: propLeftAddon, preventMenuHideOnClick = false, ...remaining } = props;
    const id = useEnsuredId(propId, "menu-item");
    const leftAddon = getIcon("upload", propLeftAddon);
    return /*#__PURE__*/ _jsx(MenuItem, {
        ...remaining,
        id: id,
        ref: ref,
        leftAddon: leftAddon,
        onClick: (event)=>{
            onClick(event);
            if (preventMenuHideOnClick) {
                event.stopPropagation();
            }
            // create a temporary file input element and click it to trigger the
            // file upload behavior.
            let input = document.createElement("input");
            input.type = "file";
            input.accept = accept;
            input.multiple = multiple;
            // eslint-disable-next-line @typescript-eslint/ban-ts-comment
            // @ts-expect-error
            input.onchange = onChange;
            input.click();
            input = null;
        },
        children: children
    });
});

//# sourceMappingURL=MenuItemFileInput.js.map