<commit_before>import { PropTypes } from 'react';
import { BEM } from 'rebem';

const ESC_KEYCODE = 27;
const block = 'popup';

export default function Popup({ children, ...props }) {
    return BEM(
        {
            ...props,
            block,
            mods: {
                ...props.mods,
                visible: props.visible
            },
            tabIndex: -1,
            ref(ref) {
                if (props.hideWithEsc && ref) {
                    if (props.visible) {
                        ref.focus();
                    } else {
                        ref.blur();
                    }
                }
            },
            onKeyUp(e) {
                if (props.hideWithEsc && e.keyCode === ESC_KEYCODE) {
                    props.onHide();
                }

                if (props.onKeyUp) {
                    props.onKeyUp(e);
                }
            }
        },
        BEM({
            block,
            elem: 'overlay'
        }),
        BEM(
            {
                block,
                elem: 'content'
            },
            children
        )
    );
}<commit_msg>:heavy_check_mark: hide Popup on overlay click<commit_after>import { PropTypes } from 'react';
import { BEM } from 'rebem';

const ESC_KEYCODE = 27;
const block = 'popup';

export default function Popup({ children, ...props }) {
    return BEM(
        {
            ...props,
            block,
            mods: {
                ...props.mods,
                visible: props.visible
            },
            tabIndex: -1,
            ref(ref) {
                if (props.hideWithEsc && ref) {
                    if (props.visible) {
                        ref.focus();
                    } else {
                        ref.blur();
                    }
                }
            },
            onKeyUp(e) {
                if (props.hideWithEsc && e.keyCode === ESC_KEYCODE) {
                    props.onHide();
                }

                if (props.onKeyUp) {
                    props.onKeyUp(e);
                }
            }
        },
        BEM({
            block,
            elem: 'overlay',
            onClick: props.onHide
        }),
        BEM(
            {
                block,
                elem: 'content'
            },
            children
        )
    );
}
{'fraction_non_alphanumeric': 0.11030664395229983, 'fraction_numerical': 0.002555366269165247, 'mean_word_length': 0.7863117870722434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2803931', 'n_tokens_mistral': 642, 'n_tokens_neox': 591, 'n_words': 121}