UNPKG

@pdf-viewer/react

Version:

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

28 lines (27 loc) 1.84 kB
import { jsx as o } from "react/jsx-runtime"; import { useCallback as u } from "react"; import { MoonIcon as f } from "../../icons/MoonIcon.js"; import { SunIcon as a } from "../../icons/SunIcon.js"; import { UIButton as s } from "../../ui/Button.js"; import { useDarkModeContext as I } from "../../../contexts/DarkModeContext.js"; import { useToolbarComponentContext as k } from "../../../contexts/ToolbarComponentContext.js"; import { useIconContext as l } from "../../../contexts/IconContext.js"; import m from "../../ui/RPTooltip.js"; import { useLocalizationContext as C } from "../../../contexts/LocalizationContext.js"; import { useIconToolContext as d } from "../../../contexts/IconToolContext.js"; import { useToolComponentContext as T } from "../../../contexts/ToolComponentContext.js"; const M = () => { const { lightModeIcon: t } = l(), { lightModeIcon: n } = d(); return t || n || /* @__PURE__ */ o(f, {}); }, x = () => { const { darkModeIcon: t } = l(), { darkModeIcon: n } = d(); return t || n || /* @__PURE__ */ o(a, {}); }, P = () => { const { darkMode: t, setDarkMode: n } = I(), { themeSwitcher: c = !0 } = k(), { themeSwitcher: i = !0 } = T(), { localeMessages: e } = C(), r = t ? e == null ? void 0 : e.themeEnableLightTooltip : e == null ? void 0 : e.themeEnableDarkTooltip, p = u(() => { n((h) => !h); }, [n]); return !c || !i ? null : typeof c == "function" ? /* @__PURE__ */ o(m, { content: r, children: /* @__PURE__ */ o(c, { darkMode: t, setDarkMode: n }) }) : typeof i == "function" ? /* @__PURE__ */ o(m, { content: r, children: /* @__PURE__ */ o(i, { darkMode: t, setDarkMode: n }) }) : /* @__PURE__ */ o(m, { content: r, children: /* @__PURE__ */ o(s, { onClick: p, "aria-label": r, children: t ? /* @__PURE__ */ o(x, {}) : /* @__PURE__ */ o(M, {}) }) }); }; export { P as DarkModeTool };