"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
// TODO @grsmto: might be worth migrating to react-pose once https://github.com/reach/reach-ui/issues/126 is fixed
const renderprops_1 = require("react-spring/renderprops");
const polished_1 = require("polished");
const styles_1 = require("../../styles");
const sc = __importStar(require("./styles"));
exports.ModalBaseComponent = ({ children, isOpen: isOpenProps, isCloseable, isCentered, onClose, theme, }) => {
    const handleCloseRequest = () => {
        if (!isCloseable) {
            return;
        }
        if (onClose) {
            onClose();
        }
    };
    return (react_1.default.createElement(renderprops_1.Transition, { items: isOpenProps, from: { background: polished_1.transparentize(1, theme.colors.gray[4]) }, enter: { background: polished_1.transparentize(0.99, theme.colors.gray[4]) }, leave: { background: polished_1.transparentize(1, theme.colors.gray[4]) } }, isOpen => isOpen &&
        (styles => (react_1.default.createElement(sc.Overlay, { style: styles, onDismiss: handleCloseRequest, isCentered: isCentered }, children)))));
};
exports.ModalBase = styles_1.withTheme(exports.ModalBaseComponent);
exports.ModalBase.defaultProps = {
    isOpen: false,
    isCloseable: true,
    isCentered: true,
};
//# sourceMappingURL=ModalBase.js.map