import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2023-2025 GoodData Corporation
import { useRef, useState } from "react";
import { Button } from "@gooddata/sdk-ui-kit";
import { AddActionMenu } from "./AddActionMenu.js";
import { useAttributeHierarchyDialog } from "./AttributeHierarchyDialogProvider.js";
export function AttributeItemActions({ rowIndex }) {
    const [shouldDisplayAddActions, setDisplayAddActions] = useState(false);
    const { onDeleteAttribute } = useAttributeHierarchyDialog();
    const addAttributeRef = useRef(null);
    const handleAddAttribute = () => {
        setDisplayAddActions(true);
    };
    const handleDeleteAttribute = () => {
        onDeleteAttribute(rowIndex);
    };
    const handleCloseAddActionMenu = () => {
        setDisplayAddActions(false);
    };
    return (_jsxs("div", { className: "attribute-item-actions s-attribute-item-actions", children: [
            _jsx("div", { ref: addAttributeRef, children: _jsx(Button, { className: "gd-button-link gd-button-icon-only gd-icon-plus attribute-item-add-action s-attribute-item-add-action", onClick: handleAddAttribute }) }), _jsx(Button, { className: "gd-button-link gd-button-icon-only gd-icon-trash attribute-item-delete-action s-attribute-item-delete-action", onClick: handleDeleteAttribute }), shouldDisplayAddActions ? (_jsx(AddActionMenu, { rowIndex: rowIndex, alignTo: addAttributeRef.current, onClose: handleCloseAddActionMenu })) : null] }));
}
//# sourceMappingURL=AttributeItemActions.js.map