"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = useModal;
const tslib_1 = require("tslib");
const react_1 = require("react");
const React = tslib_1.__importStar(require("react"));
const Modal_1 = tslib_1.__importDefault(require("../ui/Modal"));
function useModal() {
    const [modalContent, setModalContent] = (0, react_1.useState)(null);
    const onClose = (0, react_1.useCallback)(() => {
        setModalContent(null);
    }, []);
    const modal = (0, react_1.useMemo)(() => {
        if (modalContent === null) {
            return null;
        }
        const { closeOnClickOutside, content, title } = modalContent;
        return (React.createElement(Modal_1.default, { closeOnClickOutside: closeOnClickOutside, onClose: onClose, title: title }, content));
    }, [modalContent, onClose]);
    const showModal = (0, react_1.useCallback)((title, 
    // eslint-disable-next-line no-shadow
    getContent, closeOnClickOutside = false) => {
        setModalContent({
            closeOnClickOutside,
            content: getContent(onClose),
            title,
        });
    }, [onClose]);
    return [modal, showModal];
}
//# sourceMappingURL=useModal.js.map