UNPKG

@pdf-viewer/react

Version:

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

29 lines (28 loc) 1.13 kB
import { jsx as r, Fragment as c } from "react/jsx-runtime"; import { useCallback as f, useMemo as d } from "react"; import { useZoomContext as u } from "../../../../contexts/ZoomContext.js"; import { ZoomInIcon as I } from "../../../icons/ZoomInIcon.js"; import { UIButton as Z } from "../../../ui/Button.js"; import a from "../../../ui/RPTooltip.js"; import { useLocalizationContext as h } from "../../../../contexts/LocalizationContext.js"; import { MAX_ZOOM_SCALE as i } from "../../../../utils/constants.js"; const A = ({ icon: n }) => { const { currentZoom: t, setZoomLevel: m } = u(), { localeMessages: o } = h(), e = f(() => { m(() => { const p = Math.floor(t * 100 / 25) * 25; return Math.min(p + 25, i); }); }, [m, t]), l = d(() => t >= i, [t]); return /* @__PURE__ */ r(c, { children: /* @__PURE__ */ r(a, { content: o == null ? void 0 : o.zoomInTooltip, children: /* @__PURE__ */ r( Z, { disabled: l, onClick: e, "aria-label": o == null ? void 0 : o.zoomInTooltip, children: n || /* @__PURE__ */ r(I, {}) } ) }) }); }; export { A as ZoomInTool };