synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
233 lines (232 loc) • 7.87 kB
JavaScript
import { jsxs as i, jsx as t } from "react/jsx-runtime";
import "../../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 s } from "../../utils/functions/getEndpoint.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "@tanstack/react-query";
import "../../utils/PermissionLevelToAccessType.js";
import "../../utils/SynapseConstants.js";
import { useRef as I } from "react";
import "../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import { Box as n, Link as p, Chip as T, Stack as g, Typography as r, styled as w, Paper as D } from "@mui/material";
import "../../utils/hooks/useCookiePreferences.js";
import "../../utils/hooks/useSourceAppConfigs.js";
import "universal-cookie";
import "../../utils/AppUtils/session/ApplicationSessionContext.js";
import "../../utils/context/FullContextProvider.js";
import "../../utils/context/DocumentMetadataContext.js";
import '../../style/components/_spinner.css';/* empty css */
import "@tanstack/query-core";
import "lodash-es/isEmpty";
import "lodash-es/isEqual";
import "lodash-es/xorWith";
import "react-router";
import { EntityType as N } from "@sage-bionetworks/synapse-client";
import "../../utils/types/IsType.js";
import S from "../../synapse-queries/entity/useEntityBundle.js";
import { calculateFriendlyFileSize as C } from "../../utils/functions/calculateFriendlyFileSize.js";
import { formatDate as M } from "../../utils/functions/DateFormatter.js";
import { Update as R, ArticleOutlined as O, InfoOutline as E, DashboardTwoTone as b } from "@mui/icons-material";
import L from "dayjs";
import { useInView as P } from "react-intersection-observer";
import { EntityDownloadButton as B } from "../EntityDownloadButton/EntityDownloadButton.js";
import { EntityTypeIcon as $ } from "../EntityIcon.js";
import k from "../favorites/FavoriteButton.js";
import { markdownToPlainText as v } from "../Markdown/MarkdownUtils.js";
import { searchResultsCardChipStyles as z } from "./chipStyles.js";
import { HasAccessChip as F } from "./HasAccessChip.js";
import { HighlightedTypography as y } from "./HighlightedTypography.js";
import a from "./SynapseSearchResultsCard.module.scss.js";
const H = w(
D,
{
label: "SynapseSearchResultsCardContainer"
}
)({
display: "flex",
flexDirection: "column",
minHeight: "250px",
width: "100%",
borderRadius: "10px",
padding: "32px",
gap: "15px"
});
function Le(e) {
const o = I(null), { ref: f, inView: h } = P({
triggerOnce: !0,
rootMargin: "250px 0px"
}), { data: x } = S(
e.entityId,
void 0,
{ includeFileHandles: !0 },
{ enabled: e.entityType === N.file && h }
), d = x?.fileHandles.find(
(u) => u.isPreview !== !0
), l = d?.contentSize ? C(d?.contentSize) : "", m = e.description ? v(e.description) : "";
return /* @__PURE__ */ i(H, { ref: f, children: [
/* @__PURE__ */ i(
n,
{
sx: {
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
width: "100%"
},
children: [
/* @__PURE__ */ t(
p,
{
href: `${c(
s.PORTAL_ENDPOINT
)}Synapse:${e.entityId}`,
sx: {
textDecoration: "underline 2px",
textUnderlineOffset: "9px"
},
children: /* @__PURE__ */ t(
y,
{
className: a.cardTitle,
variant: "headline3",
text: e.name,
searchTerms: e.searchTerms ?? []
}
)
}
),
/* @__PURE__ */ i(
n,
{
sx: {
display: "flex",
gap: "16px",
alignItems: "center"
},
children: [
/* @__PURE__ */ t(k, { entityId: e.entityId }),
/* @__PURE__ */ t(
B,
{
entityId: e.entityId,
name: e.name,
entityType: e.entityType,
downloadConfirmationContainer: o
}
)
]
}
)
]
}
),
/* @__PURE__ */ t("div", { ref: o }),
/* @__PURE__ */ i(
n,
{
sx: {
display: "flex",
flexDirection: "row"
},
children: [
/* @__PURE__ */ t(
T,
{
icon: /* @__PURE__ */ t(
$,
{
type: e.entityType,
wrap: !1,
sx: { color: "#265149", width: "18px" }
}
),
label: e.entityType,
sx: { ...z }
}
),
/* @__PURE__ */ t(F, { entityId: e.entityId })
]
}
),
/* @__PURE__ */ t(
n,
{
sx: {
display: "flex",
flexDirection: "row",
gap: "8px"
},
children: /* @__PURE__ */ i(g, { sx: { gap: "20px", minWidth: 0, width: "100%" }, children: [
/* @__PURE__ */ i(n, { sx: { display: "flex" }, children: [
/* @__PURE__ */ t(R, { className: a.cardMetadataIcon }),
/* @__PURE__ */ i(r, { className: a.cardMetadataTypographyWithIcon, children: [
"Last updated:",
" ",
M(L.unix(e.modifiedOn), "M/D/YYYY")
] })
] }),
m && /* @__PURE__ */ i(n, { sx: { display: "flex" }, children: [
/* @__PURE__ */ t(O, { className: a.cardMetadataIcon }),
/* @__PURE__ */ t(
y,
{
className: `${a.cardMetadataTypographyWithIcon} ${a.cardDescription}`,
text: m,
searchTerms: e.searchTerms ?? []
}
)
] }),
l && /* @__PURE__ */ i(n, { sx: { display: "flex" }, children: [
/* @__PURE__ */ t(E, { className: a.cardMetadataIcon }),
/* @__PURE__ */ i(r, { className: a.cardMetadataTypographyWithIcon, children: [
"File size: ",
/* @__PURE__ */ t("b", { children: l })
] })
] }),
e.locatedIn && /* @__PURE__ */ i(
n,
{
sx: { display: "flex", marginLeft: "24px", alignItems: "center" },
children: [
/* @__PURE__ */ i(r, { className: a.cardMetadataTypographyWithIcon, children: [
"Located in:",
" "
] }),
/* @__PURE__ */ t(
b,
{
className: a.cardMetadataIcon,
sx: {
marginRight: "4px"
}
}
),
/* @__PURE__ */ t(
p,
{
className: a.locatedInLink,
href: `${c(
s.PORTAL_ENDPOINT
)}Synapse:${e.locatedIn?.id}`,
children: e.locatedIn?.name
}
)
]
}
)
] })
}
)
] });
}
export {
Le as SynapseSearchResultsCard,
Le as default
};
//# sourceMappingURL=SynapseSearchResultsCard.js.map