"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TooltipButton = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const uikit_1 = require("@gravity-ui/uikit");
const react_utils_1 = require("../../react-utils/index.js");
/** @deprecated */
const TooltipButton = ({ domRef, buttonTitle = 'Settings', items, onUpdate, withSearch, onOutsideClick, }) => {
    const [width, setWidth] = (0, react_1.useState)(0);
    const [open, , , toggleOpen] = (0, react_utils_1.useBooleanState)(false);
    const ref = (0, react_1.useRef)(null);
    (0, react_1.useLayoutEffect)(() => {
        if (ref.current?.clientWidth) {
            setWidth(ref.current?.clientWidth);
        }
    }, [ref.current?.clientWidth, buttonTitle]);
    return ((0, jsx_runtime_1.jsx)(uikit_1.Popup, { open: true, keepMounted: false, hasArrow: false, anchorElement: domRef, placement: 'right-start', offset: { crossAxis: 10, mainAxis: -(width + 10) }, onOutsideClick: onOutsideClick, children: (0, jsx_runtime_1.jsx)(uikit_1.Select, { onOpenChange: toggleOpen, renderControl: () => ((0, jsx_runtime_1.jsxs)(uikit_1.Button, { ref: ref, view: 'flat', children: [buttonTitle, (0, jsx_runtime_1.jsx)(uikit_1.ArrowToggle, { direction: open ? 'top' : 'bottom' })] })), options: items, onUpdate: (v) => onUpdate(v[0]), filterable: withSearch }) }));
};
exports.TooltipButton = TooltipButton;
//# sourceMappingURL=TooltipSelect.js.map
