import { __assign } from "tslib";
import React, { useContext, useEffect } from 'react';
import classNames from 'classnames';
import Portal from '../portal';
import { CSSTransition } from 'react-transition-group';
import { ConfigContext } from '../config-provider/config-context';
import { getPrefixCls } from '../_utils/general';
var Overlay = function (props) {
    var _a;
    var _b = props.isShow, isShow = _b === void 0 ? false : _b, _c = props.blurred, blurred = _c === void 0 ? false : _c, _d = props.unmountOnExit, unmountOnExit = _d === void 0 ? true : _d, _e = props.zIndex, zIndex = _e === void 0 ? 1000 : _e, _f = props.type, type = _f === void 0 ? 'default' : _f, clickCallback = props.clickCallback, onEnter = props.onEnter, onEntered = props.onEntered, onExit = props.onExit, onExited = props.onExited, children = props.children, style = props.style, customisedCls = props.prefixCls;
    var configContext = useContext(ConfigContext);
    var prefixCls = getPrefixCls('overlay', configContext.prefixCls, customisedCls);
    var cls = classNames(prefixCls, prefixCls + "_" + type, (_a = {}, _a[prefixCls + "_blurred"] = blurred, _a));
    useEffect(function () {
        if (isShow) {
            document.body.style.overflow = 'hidden';
        }
        else {
            document.body.style.overflow = '';
        }
    });
    return (React.createElement(Portal, null,
        React.createElement(CSSTransition, { appear: true, onEnter: onEnter, onEntered: onEntered, onExit: onExit, onExited: onExited, in: isShow, mountOnEnter: true, unmountOnExit: unmountOnExit, classNames: prefixCls + "_fade", timeout: { exit: 300, enter: 0 } },
            React.createElement("div", { tabIndex: -1, className: cls, onClick: clickCallback, style: __assign({ zIndex: zIndex }, style) }, children))));
};
Overlay.displayName = 'Overlay';
export default Overlay;
//# sourceMappingURL=index.js.map