import React from "react";
import { List } from "@rmwc/list";
import { MenuSurfaceAnchor, MenuSurface } from "@rmwc/menu";
import { RootContainer, ListContainer, DropdownContainer, OpenerIcon, } from "./styled";
export const Dropdown = ({ title, children, className, renderTitle, isOpen = false, onMenuToggle, anchorCorner = "bottomStart", renderOpener, }) => {
    const handleOpenState = () => {
        onMenuToggle(!isOpen);
    };
    const handleClose = () => {
        onMenuToggle(false);
    };
    return (React.createElement(DropdownContainer, { className: className },
        React.createElement(MenuSurfaceAnchor, null,
            React.createElement(MenuSurface, { open: isOpen, onClose: handleClose, anchorCorner: anchorCorner },
                React.createElement(ListContainer, null,
                    React.createElement(List, null, children))),
            React.createElement(RootContainer, { onClick: handleOpenState },
                title || (renderTitle && renderTitle()),
                renderOpener ? (renderOpener()) : (React.createElement(OpenerIcon, { name: "triangle_down", noMargin: Boolean(renderTitle) }))))));
};
//# sourceMappingURL=dropdown.js.map