synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
169 lines (168 loc) • 5.92 kB
JavaScript
import { jsx as r, Fragment as Y, jsxs as Z } 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 { ColumnTypeEnum as $ } from "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import "../../utils/SynapseConstants.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "@tanstack/react-query";
import "../../utils/PermissionLevelToAccessType.js";
import { useMemo as s, useState as oo } from "react";
import { useSynapseContext as eo } from "../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import "@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 "@sage-bionetworks/synapse-client";
import "../../utils/types/IsType.js";
import { useGetEntity as to } from "../../synapse-queries/entity/useEntity.js";
import { useReactTable as no, getCoreRowModel as ro, createColumnHelper as so } from "@tanstack/react-table";
import { useAtomValue as io } from "jotai";
import { ModalDownload as lo } from "../ModalDownload/ModalDownload.js";
import { useQueryContext as ao } from "../QueryContext/QueryContext.js";
import { useQueryVisualizationContext as mo } from "../QueryVisualizationWrapper/QueryVisualizationContext.js";
import { isRowSelectionVisibleAtom as uo } from "../QueryWrapper/TableRowSelectionState.js";
import co from "../TanStackTable/StyledTanStackTable.js";
import { SynapseTableContext as po } from "./SynapseTableContext.js";
import { rowSelectionColumn as R, addToDownloadListColumn as A, directDownloadColumn as V, accessColumn as E, TableDataCell as Co, TableDataColumnHeader as wo } from "./SynapseTableRenderers.js";
import { isEntityViewOrDatasetOrCollection as fo, isFileViewOrDataset as ho, isSortableColumn as bo } from "./SynapseTableUtils.js";
import { usePrefetchResourcesInTable as yo } from "./usePrefetchTableData.js";
import { useTableSort as So } from "./useTableSort.js";
const To = [], Do = so();
function pe(i) {
const { showDownloadColumn: m, hideDownload: M } = i, {
rowSet: o,
isLoadingNewPage: N,
customColumns: C = To,
showAccessColumn: u,
showExternalAccessIcon: w,
showAccessColumnHeader: f,
showDirectDownloadColumn: O = m,
hideAddToDownloadListColumn: P = M,
columnLinks: h
} = i, {
entityId: q,
versionNumber: B,
getCurrentQueryRequest: b,
fileIdColumnName: l,
fileVersionColumnName: y
} = ao(), d = s(
() => b(),
[b]
), n = o.headers, { data: a } = to(q, B), { columnsToShowInTable: S, NoContentPlaceholder: L } = mo(), H = s(
() => ({
columnLinks: h,
showExternalAccessIcon: w
}),
[h, w]
), { isAuthenticated: z } = eo(), [F, Q] = oo(!1), { sort: U, setSort: j } = So(), c = io(uo), T = !!(u && a && (fo(a) && v(o) || l)), D = a && z && (ho(a) && v(o) || l), g = !!(D && O), x = !!(D && !P && !c), k = l ? o.headers.findIndex((e) => e.name == l) : void 0, W = y ? o.headers.findIndex((e) => e.name == y) : void 0, _ = s(
() => [
...C,
R,
A,
V,
{
...E,
header: u && f ? "Access" : ""
},
...n.map((e, t) => Do.accessor((p) => p.values[t], {
id: e.name,
enableSorting: bo(e.columnType),
enableResizing: !0,
header: wo,
cell: Co
})) ?? []
],
[C, n, u, f]
), I = s(
() => ({
[R.id]: c,
[A.id]: x,
[V.id]: g,
[E.id]: T
}),
[
c,
T,
x,
g
]
), G = s(
() => n.reduce((e, t) => ({
...e,
[t.name]: S.includes(t.name)
}), I),
[S, n, I]
), { dataHasBeenPrefetched: J } = yo(o), K = N || !J, X = no({
data: o.rows,
columns: _,
getCoreRowModel: ro(),
manualSorting: !0,
manualFiltering: !0,
onSortingChange: j,
enableMultiSort: !0,
columnResizeMode: "onChange",
state: {
sorting: U,
columnVisibility: G
},
meta: {
rowSet: o,
// make the rowEntityIDColumnIndex available to all cell renderers
rowEntityIDColumnIndex: k,
rowEntityVersionColumnIndex: W,
renderPlaceholderData: K,
getWrapInExpandableTd: (e) => {
const t = n.find(
(p) => p.name === e.column.id
);
return !!(t && /* JSON handles its own overflow*/
t.columnType !== $.JSON);
}
}
});
return o ? !((o.rows?.length ?? 0) > 0) && (d.query.offset === 0 || d.query.offset == null) ? /* @__PURE__ */ r(L, {}) : /* @__PURE__ */ r(po.Provider, { value: H, children: /* @__PURE__ */ Z("div", { children: [
F && /* @__PURE__ */ r(
lo,
{
onClose: () => {
Q(!1);
},
queryBundleRequest: d
}
),
/* @__PURE__ */ r(
co,
{
styledTableContainerProps: {
className: "SynapseTable",
"data-testid": "SynapseTable",
density: "default"
},
table: X,
fullWidth: !1,
autoColumnSizing: !0
}
)
] }) }) : /* @__PURE__ */ r(Y, {});
}
function v(i) {
return !!i.rows?.every((m) => !!m.rowId);
}
export {
pe as SynapseTable
};
//# sourceMappingURL=SynapseTable.js.map