import { jsx as _jsx } from "react/jsx-runtime";
import { FocusTrap } from "focus-trap-react";
import { useRef } from "react";
import { useOnClickOutside } from "usehooks-ts";
import { useInternalTableState } from "./table-provider/table-provider.js";
const TableFocusTrap = ({ children }) => {
    const { state: { selectedCellIndex }, api, } = useInternalTableState();
    const ref = useRef(null);
    useOnClickOutside(ref, () => {
        api.selection.clear();
    });
    //   return children;
    return (_jsx("div", { ref: ref, children: _jsx(FocusTrap, { active: !!selectedCellIndex, focusTrapOptions: { allowOutsideClick: true }, children: children }) }));
};
export { TableFocusTrap };
//# sourceMappingURL=table-focus-trap.js.map