"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteDropdown = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const core_1 = require("@material-ui/core");
const react_1 = tslib_1.__importDefault(require("react"));
const DeleteGrayIcon_1 = require("../../CommonUI/Icon/DeleteGrayIcon");
const CommonStyles_1 = require("../Builder/CommonStyles");
const UndefinedDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/UndefinedDataDefinition");
const StateManager_1 = require("@appglue/common/dist/Common/StateManager");
const DeleteDropdown = ({ mappingRule, definition, }) => {
    const [selectedEl, setSelectedEl] = react_1.default.useState(null);
    const onClose = () => {
        setSelectedEl(null);
    };
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CommonStyles_1.ActionButton, { onClick: (event) => {
                    event.stopPropagation();
                    event.preventDefault();
                    setSelectedEl(event.currentTarget);
                }, children: (0, jsx_runtime_1.jsx)(DeleteGrayIcon_1.DeleteGrayIcon, {}) }), (0, jsx_runtime_1.jsxs)(core_1.Menu, { anchorEl: selectedEl, open: Boolean(selectedEl), keepMounted: true, onClose: onClose, disableRestoreFocus: true, children: [(0, jsx_runtime_1.jsx)(core_1.MenuItem, { onClick: (event) => {
                            event.stopPropagation();
                            mappingRule.targetPath = "";
                            mappingRule.mapping.executionResult = new UndefinedDataDefinition_1.UndefinedDataDefinition();
                            onClose();
                            StateManager_1.StateManager.changed(definition);
                        }, children: "Delete Destination" }), (0, jsx_runtime_1.jsx)(core_1.MenuItem, { onClick: (event) => {
                            event.stopPropagation();
                            definition.removeMappingRule(mappingRule.id);
                            onClose();
                            StateManager_1.StateManager.changed(definition);
                        }, children: "Delete Expression" })] })] }));
};
exports.DeleteDropdown = DeleteDropdown;
//# sourceMappingURL=DeleteDropdown.js.map