import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { Menu, MenuItem } from "@material-ui/core";
import { InheritLabel } from "./InlineTextEdit";
export function InlineOptionSelect(props) {
    const [anchorEl, setAnchorEl] = React.useState(null);
    const handleClick = (event) => {
        if (!props.readOnly) {
            setAnchorEl(event.currentTarget);
        }
    };
    const handleClose = () => {
        setAnchorEl(null);
    };
    function renderMenuItem(option) {
        return (_jsx(MenuItem, Object.assign({ onClick: () => {
                setAnchorEl(null);
                if (props.onEdit)
                    props.onEdit(option);
            } }, { children: option }), option));
    }
    return (_jsxs(_Fragment, { children: [_jsx(InheritLabel, Object.assign({ onClick: handleClick }, { children: props.text }), void 0),
            _jsx(Menu, Object.assign({ anchorEl: anchorEl, open: Boolean(anchorEl), keepMounted: true, onClose: handleClose }, { children: props.options.map((option, index) => {
                    return renderMenuItem(option);
                }) }), void 0)] }, void 0));
}
//# sourceMappingURL=InlineOptionSelect.js.map