UNPKG

@pdf-viewer/react

Version:

A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.

41 lines (40 loc) 1.08 kB
import { jsx as P } from "react/jsx-runtime"; import { createContext as l, useState as r, useEffect as p, useMemo as m, useContext as f } from "react"; import { appConsole as v } from "../utils/appConsole.js"; const a = l({ password: void 0, setPassword: () => { }, passwordError: void 0, setPasswordError: () => { }, passwordRequired: void 0, setPasswordRequired: () => { }, invalidPassword: !1 }), q = ({ children: s }) => { const [e, n] = r(), [o, i] = r(), [t, c] = r(!1), [d, w] = r(!1); p(() => { w(o === "Incorrect Password"); }, [o]); const u = m(() => ({ password: e, setPassword: n, passwordError: o, setPasswordError: i, passwordRequired: t, setPasswordRequired: c, invalidPassword: d }), [e, o, t, d]); return /* @__PURE__ */ P(a.Provider, { value: u, children: s }); }, D = () => { const s = f(a); return s || v.error("Please use this hooks inside children component of DocumentPasswordContext"), s; }; export { q as DocumentPasswordProvider, a as default, D as useDocumentPasswordContext };