@pdf-viewer/react
Version:
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
29 lines (28 loc) • 1.07 kB
JavaScript
import { jsx as l } from "react/jsx-runtime";
import { createContext as m, 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";
const r = m({
columnCount: 1,
setSinglePage: () => {
},
setDualPage: () => {
},
viewMode: e.SINGLE_PAGE
}), w = () => {
const o = d(r);
return typeof o.columnCount > "u" && p.error("Please use this hooks inside children component of RPProvider"), o;
}, g = ({ 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);
}, []), a = C(() => t === 1 ? e.SINGLE_PAGE : e.DUAL_PAGE, [t]);
return /* @__PURE__ */ l(r.Provider, { value: { columnCount: t, setSinglePage: u, setDualPage: c, viewMode: a }, children: o });
};
export {
r as ViewModeContext,
g as ViewModeProvider,
w as useViewModeContext
};