import { jsx as _jsx } from "react/jsx-runtime";
import { memo, useMemo } from 'react';
import { FloatingPlusButton } from "../FloatingPlusButton/index.js";
export const FloatingPlusControl = memo(function YfmTableRowFloatingPlusControl({ type, index, cellElem, tableElem, onClick }) {
    const anchor = useMemo(() => ({
        contextElement: tableElem,
        getBoundingClientRect() {
            const cellRect = cellElem.getBoundingClientRect();
            const tableRect = tableElem.getBoundingClientRect();
            return type === 'row'
                ? {
                    x: tableRect.x,
                    y: cellRect.y,
                    width: tableRect.width,
                    height: cellRect.height,
                    top: cellRect.top,
                    left: tableRect.left,
                    right: tableRect.right,
                    bottom: cellRect.top,
                }
                : {
                    x: cellRect.x,
                    y: tableRect.y,
                    width: cellRect.width,
                    height: tableRect.height,
                    top: tableRect.top,
                    left: cellRect.left,
                    right: cellRect.right,
                    bottom: tableRect.top,
                };
        },
    }), [cellElem, tableElem, type]);
    return _jsx(FloatingPlusButton, { anchor: anchor, type: type, onClick: () => onClick(index) });
});
//# sourceMappingURL=FloatingPlusControl.js.map
