synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
47 lines (46 loc) • 1.74 kB
JavaScript
import { jsxs as a, jsx as i, Fragment as f } from "react/jsx-runtime";
import * as p from "../../synapse-client/SynapseClient.js";
import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode";
import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse";
import "@sage-bionetworks/synapse-client/util/SynapseClientError";
import "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import { getEndpoint as c, BackendDestinationEnum as d } from "../../utils/functions/getEndpoint.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import { calculateFriendlyFileSize as r } from "../../utils/functions/calculateFriendlyFileSize.js";
import { Alert as h } from "@mui/material";
import { useRef as u } from "react";
const o = Math.pow(1024, 2) * 30, x = r(o);
function I(n) {
const { fileHandle: t, fileHandleAssociation: e } = n, l = u(null), m = r(t.contentSize);
if (t.contentSize > o)
return /* @__PURE__ */ a(h, { severity: "error", sx: { marginBottom: "20px" }, children: [
"The PDF preview was not shown because the file size (",
m,
") exceeds the maximum preview size (",
x,
")"
] });
const s = p.getPortalFileHandleServletUrl(
e.fileHandleId,
e.associateObjectId,
e.associateObjectType
);
return /* @__PURE__ */ i(f, { children: /* @__PURE__ */ i(
"iframe",
{
ref: l,
src: `${c(
d.PORTAL_ENDPOINT
)}pdf.js/web/viewer.html?file=${encodeURIComponent(s)}`,
height: "800px",
style: { border: 0, width: "100%" }
}
) });
}
export {
I as default,
o as maxPdfSize
};
//# sourceMappingURL=PdfPreview.js.map