var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React, { forwardRef, useContext } from "react";
import { Popover } from "../../popover/index.js";
import { cl } from "../../utils/helpers/index.js";
import { consoleWarning } from "../../utils/helpers/consoleWarning.js";
import { DropdownContext } from "../context.js";
import Divider from "./Divider.js";
import GroupedList from "./GroupedList/index.js";
import List from "./List/index.js";
export const Menu = forwardRef((_a, ref) => {
    var { className, onClose, placement = "bottom-end" } = _a, rest = __rest(_a, ["className", "onClose", "placement"]);
    const context = useContext(DropdownContext);
    if (!context) {
        consoleWarning("<Dropdown.Menu /> has to be wrapped in <Dropdown />");
        return null;
    }
    const { isOpen, anchorEl, handleToggle } = context;
    return (React.createElement(Popover, Object.assign({}, rest, { placement: placement, ref: ref, className: cl("aksel-dropdown__menu", className), offset: -4, anchorEl: anchorEl, open: isOpen, onClose: () => {
            handleToggle(false);
            onClose === null || onClose === void 0 ? void 0 : onClose();
        } })));
});
Menu.List = List;
Menu.GroupedList = GroupedList;
Menu.Divider = Divider;
export default Menu;
//# sourceMappingURL=index.js.map