stackpress
Version:
Incept is a content management framework.
21 lines (20 loc) • 911 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState, useEffect } from 'react';
import Modal from 'frui/element/Modal';
import ModalContext from './ModalContext.js';
const ModalProvider = ({ children, ...config }) => {
const [ready, isReady] = useState(false);
const [opened, open] = useState(false);
const [_title, title] = useState(config.title || '');
const [_className, className] = useState(config.className || '');
const [_body, body] = useState();
const value = {
_title, _className, _body, opened,
className, title, body, open
};
useEffect(() => {
isReady(true);
}, []);
return (_jsxs(ModalContext.Provider, { value: value, children: [children, ready && (_jsx(Modal, { title: _title, className: _className, opened: opened, onClose: () => open(false), children: _body }))] }));
};
export default ModalProvider;