UNPKG

@pdf-viewer/react

Version:

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

24 lines (23 loc) 1.91 kB
import { jsx as t, jsxs as m } from "react/jsx-runtime"; import { FileUploadDefaultIcon as e } from "../../icons/FileUploadDefaultIcon.js"; import { useToolbarComponentContext as u } from "../../../contexts/ToolbarComponentContext.js"; import { useIconContext as c } from "../../../contexts/IconContext.js"; import { UIButton as f } from "../../ui/Button.js"; import { MenuItem as F } from "./MenuItem.js"; import { useViewportContext as d } from "../../../contexts/ViewportContext.js"; import { useOpenFileContext as C } from "../../../contexts/FileInputContext.js"; import T from "../../ui/RPTooltip.js"; import { useLocalizationContext as x } from "../../../contexts/LocalizationContext.js"; const p = () => { const { openFileIcon: n } = c(); return n || /* @__PURE__ */ t(e, {}); }, l = ({ children: n, className: o, localeMessages: i }) => /* @__PURE__ */ t(T, { className: o, content: i == null ? void 0 : i.openLocalFileTooltip, children: n }), h = ({ onFileChange: n, localeMessages: o }) => /* @__PURE__ */ t(F, { onClick: n, children: /* @__PURE__ */ m(l, { className: "rp-menu-item", localeMessages: o, children: [ /* @__PURE__ */ t("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ t(p, {}) }), o == null ? void 0 : o.openLocalFileLabel ] }) }), U = ({ onFileChange: n, localeMessages: o }) => /* @__PURE__ */ t(l, { localeMessages: o, children: /* @__PURE__ */ t(f, { onClick: n, "aria-label": o == null ? void 0 : o.openLocalFileTooltip, children: /* @__PURE__ */ t(p, {}) }) }), w = () => { const { openFileTool: n = !0 } = u(), { openFile: o } = C(), { isSmallScreen: i } = d(), { localeMessages: r } = x(); return n ? i ? /* @__PURE__ */ t(h, { onFileChange: o, localeMessages: r }) : typeof n == "function" ? /* @__PURE__ */ t(n, { openFile: o }) : n ? /* @__PURE__ */ t(U, { onFileChange: o, localeMessages: r }) : null : null; }; export { w as FileUploadTool };