import { jsx as _jsx } from "react/jsx-runtime";
import React, { useCallback } from 'react';
import ReactFocusLock from 'react-focus-lock';
/**
 * Traps the focus within the provided content.
 *
 * Tabbing using the keyboard will only cycle through the children and won't leave the boundary of the FocusLock wrapper.
 */
export const FocusLock = props => {
    const { autoFocus, children, crossFrame, finalFocusRef, initialFocusRef, isDisabled, persistentFocus, returnFocus: returnFocusProp, } = props;
    const onActivation = React.useCallback(() => {
        initialFocusRef?.current?.focus();
    }, [initialFocusRef]);
    const onDeactivation = useCallback(() => {
        finalFocusRef?.current?.focus();
    }, [finalFocusRef]);
    const returnFocus = returnFocusProp && !finalFocusRef;
    return (_jsx(ReactFocusLock, { autoFocus: autoFocus, crossFrame: crossFrame, disabled: isDisabled, onActivation: onActivation, onDeactivation: onDeactivation, persistentFocus: persistentFocus, returnFocus: returnFocus, children: children }));
};
FocusLock.displayName = 'FocusLock';
export default FocusLock;
//# sourceMappingURL=focusLock.js.map