UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

108 lines (107 loc) 2.95 kB
import { jsx as a } from "react/jsx-runtime"; import { useMemo as B } from "react"; import F from "./EntityTreeTable.module.scss.js"; import { useReactTable as I, getCoreRowModel as R } from "@tanstack/react-table"; import { Box as j } from "@mui/material"; import { useEntityTreeState as z } from "./hooks/useEntityTreeState.js"; import { useTreeOperationsWithDirectFetch as A } from "./hooks/useTreeOperationsWithDirectFetch.js"; import { useTableColumns as H } from "./hooks/useTableColumns.js"; import { useTableData as N } from "./hooks/useTableData.js"; import { EntityTreeTableView as O } from "./components/EntityTreeTableView.js"; import { EntityTreeTableContext as V } from "./components/EntityTreeTableContext.js"; import W from "../SynapseTable/NoContentAvailable.js"; const te = ({ rootId: t, expandRootByDefault: m = !0, showRootNode: n = !0, enableSorting: s = !0, onEntityIdClicked: p }) => { const { expanded: r, setExpanded: u, tree: o, setTree: g, loadingIds: d, setLoadingIds: T, loadedChildren: i, setLoadedChildren: f, nextPageTokens: l, setNextPageTokens: c, loadingPageTokens: h, setLoadingPageTokens: C, sorting: x, setSorting: y, sortBy: b, sortDirection: E } = z(t, m, n), { handleToggleExpanded: M, loadMoreChildren: k, flattenTree: $ } = A( r, u, o, g, i, f, d, T, c, C, h, l, b, E ), v = H(s), P = N( o, t, n, r, l, $ ), L = B(() => { const e = o[t]; return !e || n ? !1 : i.has(t) ? !e.children || e.children.length === 0 : !1; }, [o, t, n, i]), D = I({ data: P, columns: v, getCoreRowModel: R(), columnResizeMode: "onChange", state: { expanded: r, sorting: x }, // Make row ids robust: include parent/depth for normal rows so that the // same entity appearing in different places (or synthetic rows) won't // collide. For load-more rows, use parentId and depth to create unique identifier. getRowId: (e) => e.isLoadMore ? `loadmore::${e.parentId}::${e.depth}::${e.pageToken || "no-token"}` : `${e.entityId || e.entityHeader.id}::${e.parentId ?? "root"}::${e.depth}`, manualExpanding: !0, manualSorting: !0, enableSorting: s, onSortingChange: y, enableColumnFilters: !1 }); return /* @__PURE__ */ a(j, { children: /* @__PURE__ */ a( V.Provider, { value: { expanded: r, loadingIds: d, handleToggleExpanded: (e) => { M(e); }, loadMoreChildren: (e, S) => { k(e, S); }, nextPageTokens: l, onEntityIdClicked: p }, children: L ? /* @__PURE__ */ a(W, {}) : /* @__PURE__ */ a( O, { table: D, className: F.entityTreeTable } ) } ) }); }; export { te as EntityTreeTable, te as default }; //# sourceMappingURL=EntityTreeTable.js.map