UNPKG

@hakit/components

Version:
35 lines (34 loc) 1.01 kB
import { j as m } from "../../../../emotion-react-jsx-runtime.browser.esm-Tq_btErF.js"; import { createContext as u, useRef as f, useEffect as c } from "react"; import { create as d } from "zustand"; import { MotionConfig as l } from "framer-motion"; const p = d((t) => ({ setModalAnimation: (o) => t({ modalAnimation: o }), setAnimationDuration: (o) => t({ animationDuration: o }) })), A = u({}); function C({ children: t, options: o = {} }) { const { animationDuration: n, modalAnimation: i, ...s } = o, a = f(!(typeof n == "number" || typeof i == "function")), { setAnimationDuration: e, setModalAnimation: r } = p(); return c(() => { typeof n == "number" && e(n), typeof i == "function" && r(i), a.current = !0; }, [r, e, n, i]), /* @__PURE__ */ m(l, { ...s, children: /* @__PURE__ */ m(A.Provider, { value: o, children: a.current && t }) }); } export { A as ModalContext, C as ModalProvider, p as useModalStore }; //# sourceMappingURL=index.js.map