"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolbarButtonPopup = ToolbarButtonPopup;
const jsx_runtime_1 = require("react/jsx-runtime");
const hooks_1 = require("../react-utils/hooks.js");
const ToolbarButton_1 = require("./ToolbarButton.js");
const hooks_2 = require("./hooks.js");
function ToolbarButtonPopup(props) {
    const { className, editor, renderPopup, disableTooltip, ...buttonProps } = props;
    const [anchorElement, setAnchorElement] = (0, hooks_1.useElementState)();
    const [isOpen, , close, toggle] = (0, hooks_1.useBooleanState)(false);
    const { active, enabled } = (0, hooks_2.useActionState)(editor, props);
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ToolbarButton_1.ToolbarButtonView, { ...buttonProps, ref: setAnchorElement, active: active, enabled: enabled, className: className, onClick: toggle, disableTooltip: disableTooltip || isOpen }), isOpen &&
                renderPopup({
                    ...props,
                    anchorElement,
                    hide: close,
                })] }));
}
//# sourceMappingURL=ToolbarButtonPopup.js.map
