"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionPopup = ActionPopup;
const jsx_runtime_1 = require("react/jsx-runtime");
const icons_1 = require("@gravity-ui/icons");
const uikit_1 = require("@gravity-ui/uikit");
const cn_1 = require("../../../utils/cn.js");
const i18n_1 = require("./i18n/index.js");
require("./ActionPopup.css");
const b = (0, cn_1.block)('action-popup');
/**
 * ActionPopup - Universal anchored popup container for displaying content near action buttons
 *
 * This component provides a flexible popup container that can be anchored to any element
 * (typically action buttons). It supports optional title and subtitle, and can contain
 * any React content as children.
 *
 * @returns React element with anchored popup
 */
function ActionPopup({ open, onOpenChange, anchorElement, title, subtitle, children, placement = 'bottom-start', className, qa, }) {
    const hasHeader = title || subtitle;
    const handleClose = () => {
        onOpenChange(false);
    };
    return ((0, jsx_runtime_1.jsx)(uikit_1.Popup, { open: open, onOpenChange: onOpenChange, anchorElement: anchorElement, placement: placement, className: b(null, className), qa: qa, children: (0, jsx_runtime_1.jsxs)("div", { className: b('container'), children: [hasHeader && ((0, jsx_runtime_1.jsxs)("div", { className: b('header'), children: [(0, jsx_runtime_1.jsxs)("div", { className: b('header-content'), children: [title && (0, jsx_runtime_1.jsx)(uikit_1.Text, { variant: "subheader-2", children: title }), subtitle && ((0, jsx_runtime_1.jsx)(uikit_1.Text, { variant: "body-1", color: "secondary", children: subtitle }))] }), (0, jsx_runtime_1.jsx)(uikit_1.Button, { view: "flat-secondary", size: "s", onClick: handleClose, className: b('close-button'), qa: qa ? `${qa}-close` : undefined, "aria-label": (0, i18n_1.i18n)('close'), children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Xmark, size: 16 }) })] })), children] }) }));
}
//# sourceMappingURL=ActionPopup.js.map
