UNPKG

@pdf-viewer/react

Version:

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

30 lines (29 loc) 1.1 kB
import { jsx as a } from "react/jsx-runtime"; import { createContext as l, useContext as d, useState as P, useCallback as i, useMemo as C } from "react"; import { appConsole as p } from "../utils/appConsole.js"; import { ViewMode as e } from "../utils/types.js"; import { useInitialStateContext as f } from "./InitialStateContext.js"; import "../th_TH-d627cd51.js"; const r = l({ columnCount: 1, setSinglePage: () => { }, setDualPage: () => { }, viewMode: e.SINGLE_PAGE }), g = () => { const o = d(r); return typeof o.columnCount > "u" && p.error("Please use this hooks inside children component of RPProvider"), o; }, v = ({ children: o }) => { const { initialViewMode: s = e.SINGLE_PAGE } = f(), [t, n] = P(s === e.SINGLE_PAGE ? 1 : 2), u = i(() => { n(1); }, []), c = i(() => { n(2); }, []), m = C(() => t === 1 ? e.SINGLE_PAGE : e.DUAL_PAGE, [t]); return /* @__PURE__ */ a(r.Provider, { value: { columnCount: t, setSinglePage: u, setDualPage: c, viewMode: m }, children: o }); }; export { r as ViewModeContext, v as ViewModeProvider, g as useViewModeContext };