@pdf-viewer/react
Version:
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
40 lines (39 loc) • 1.89 kB
JavaScript
import { jsxs as p, Fragment as i, jsx as o } from "react/jsx-runtime";
import { useCallback as u } from "react";
import { c as D } from "../clsx-0c6e471a.js";
import { useDropFileZoneContext as g } from "../contexts/DropFileZoneContext.js";
import { LightPdfIcon as h } from "./icons/LightPdfIcon.js";
import { DarkPdfIcon as C } from "./icons/DarkPdfIcon.js";
import { useDarkModeContext as x } from "../contexts/DarkModeContext.js";
import { useToolbarComponentContext as F } from "../contexts/ToolbarComponentContext.js";
import { useLocalizationContext as v } from "../contexts/LocalizationContext.js";
import { useToolComponentContext as z } from "../contexts/ToolComponentContext.js";
import '../assets/RPDropFileZone.css';const s = {
"rp-drop-zone": "_rp-drop-zone_1sc50_1",
"rp-drop-zone-transparent": "_rp-drop-zone-transparent_1sc50_15"
}, Z = {}, N = () => {
const { dragging: a, handleDragLeave: l, handleDrop: d } = g(), { darkMode: t } = x(), { dropFileZone: r = !0 } = F(), { dropFileZone: e = !0 } = z(), { localeMessages: n } = v(), m = u((f) => {
f.preventDefault();
}, []);
if (!r || !e || !a)
return null;
const c = () => typeof r == "function" ? /* @__PURE__ */ o(r, {}) : typeof e == "function" ? /* @__PURE__ */ o(e, {}) : /* @__PURE__ */ p(i, { children: [
/* @__PURE__ */ o("div", { children: t ? /* @__PURE__ */ o(C, {}) : /* @__PURE__ */ o(h, {}) }),
/* @__PURE__ */ o("p", { children: n == null ? void 0 : n.dragDropFileMessage })
] });
return /* @__PURE__ */ p(i, { children: [
/* @__PURE__ */ o("div", { className: D(s["rp-drop-zone"], t ? Z["rp-dark-mode"] : ""), children: /* @__PURE__ */ o(c, {}) }),
/* @__PURE__ */ o(
"div",
{
className: s["rp-drop-zone-transparent"],
onDragOver: m,
onDragLeave: l,
onDrop: d
}
)
] });
};
export {
N as RPDropFileZone
};