import { jsx as _jsx } from "react/jsx-runtime";
import { Ellipsis } from '@gravity-ui/icons';
import { DropdownMenu, Icon, Popup } from '@gravity-ui/uikit';
import "./floating.css";
export const TableCellFloatingButton = ({ dom, actions }) => {
    if (!dom) {
        return null;
    }
    return (_jsx(Popup, { open: true, keepMounted: false, hasArrow: false, anchorElement: dom, offset: { crossAxis: 2, mainAxis: -12 }, placement: "left-start", children: _jsx(DropdownMenu, { icon: _jsx(Icon, { data: Ellipsis, size: 12, className: "table-cell-floating-icon" }), defaultSwitcherClassName: "table-cell-floating-button", items: actions.map(buildMenuItem) }) }));
};
TableCellFloatingButton.displayName = 'TableCellFloatingButton';
function buildMenuItem(floatingAction) {
    if (Array.isArray(floatingAction)) {
        // @ts-expect-error
        return floatingAction.map(buildMenuItem);
    }
    const { action, text } = floatingAction;
    const active = action.isActive();
    const disabled = !active && !action.isEnable();
    return {
        text,
        action: () => action.run({}),
        active,
        disabled,
    };
}
//# sourceMappingURL=floating.js.map
