UNPKG

@konstructio/ui

Version:

A set of reusable and customizable React components built for konstruct.io

27 lines (26 loc) 679 B
import { jsx as i } from "react/jsx-runtime"; import { useState as t, useCallback as n } from "react"; import { ModalContext as f } from "./Modal.context.js"; import { useToggle as h } from "../../../hooks/useToggle.js"; const x = ({ children: s }) => { const [r, l] = t(!0), [a, o] = h(!1), [u, c] = t(), e = n(() => o(!0), [o]), d = n(() => o(!1), [o]), p = (m, C = !0) => { c(m), e(), l(C); }; return /* @__PURE__ */ i( f.Provider, { value: { content: u, isOpen: a, shouldShowClose: r, onClose: d, onOpen: e, setContentAndOpen: p }, children: s } ); }; export { x as ModalProvider };