synapse-react-client 4.0.20 → 4.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SWC.index.d.ts +1 -0
- package/dist/SWC.index.d.ts.map +1 -1
- package/dist/SWC.index.js +2 -1
- package/dist/SWC.index.js.map +1 -1
- package/dist/components/CardContainer/CardConfiguration.d.ts +2 -0
- package/dist/components/CardContainer/CardConfiguration.d.ts.map +1 -1
- package/dist/components/CardContainer/CardContainer.d.ts.map +1 -1
- package/dist/components/CardContainer/CardContainer.js +44 -50
- package/dist/components/CardContainer/CardContainer.js.map +1 -1
- package/dist/components/CardContainerLogic/CardContainerLogic.d.ts +14 -0
- package/dist/components/CardContainerLogic/CardContainerLogic.d.ts.map +1 -1
- package/dist/components/CardContainerLogic/CardContainerLogic.js +64 -40
- package/dist/components/CardContainerLogic/CardContainerLogic.js.map +1 -1
- package/dist/components/ChallengeSubmission/ChallengeSubmissionStepper.js +1 -1
- package/dist/components/ChallengeSubmission/ChallengeSubmissionStepper.js.map +1 -1
- package/dist/components/DataExplorer/DataExplorer.css +1 -1
- package/dist/components/DataExplorer/DataExplorer.module.js +16 -16
- package/dist/components/DataExplorer/DataExplorer.module.js.map +1 -1
- package/dist/components/DataExplorer/DataExplorer.module.scss +26 -7
- package/dist/components/DataGrid/DataGrid.d.ts +1 -0
- package/dist/components/DataGrid/DataGrid.d.ts.map +1 -1
- package/dist/components/DataGrid/DataGrid.js +72 -72
- package/dist/components/DataGrid/DataGrid.js.map +1 -1
- package/dist/components/DataGrid/SynapseGrid.d.ts.map +1 -1
- package/dist/components/DataGrid/SynapseGrid.js +209 -206
- package/dist/components/DataGrid/SynapseGrid.js.map +1 -1
- package/dist/components/DataGrid/components/ColumnHeaderWithTooltip.d.ts +6 -3
- package/dist/components/DataGrid/components/ColumnHeaderWithTooltip.d.ts.map +1 -1
- package/dist/components/DataGrid/components/ColumnHeaderWithTooltip.js +54 -46
- package/dist/components/DataGrid/components/ColumnHeaderWithTooltip.js.map +1 -1
- package/dist/components/DataGrid/hooks/useColumnResizeHandles.d.ts.map +1 -1
- package/dist/components/DataGrid/hooks/useColumnResizeHandles.js +1 -1
- package/dist/components/DataGrid/hooks/useColumnResizeHandles.js.map +1 -1
- package/dist/components/DataGrid/useDataGridWebsocket.d.ts.map +1 -1
- package/dist/components/DataGrid/useDataGridWebsocket.js +68 -67
- package/dist/components/DataGrid/useDataGridWebsocket.js.map +1 -1
- package/dist/components/DataGrid/utils/columnFactory.d.ts +1 -0
- package/dist/components/DataGrid/utils/columnFactory.d.ts.map +1 -1
- package/dist/components/DataGrid/utils/columnFactory.js +5 -3
- package/dist/components/DataGrid/utils/columnFactory.js.map +1 -1
- package/dist/components/DataGrid/utils/modelColsToGrid.d.ts +1 -1
- package/dist/components/DataGrid/utils/modelColsToGrid.d.ts.map +1 -1
- package/dist/components/DataGrid/utils/modelColsToGrid.js +15 -14
- package/dist/components/DataGrid/utils/modelColsToGrid.js.map +1 -1
- package/dist/components/DataGrid/utils/normalizeWebsocketError.d.ts +7 -0
- package/dist/components/DataGrid/utils/normalizeWebsocketError.d.ts.map +1 -0
- package/dist/components/DataGrid/utils/normalizeWebsocketError.js +8 -0
- package/dist/components/DataGrid/utils/normalizeWebsocketError.js.map +1 -0
- package/dist/components/GenericCard/GenericCard.d.ts +2 -0
- package/dist/components/GenericCard/GenericCard.d.ts.map +1 -1
- package/dist/components/GenericCard/GenericCard.js +76 -64
- package/dist/components/GenericCard/GenericCard.js.map +1 -1
- package/dist/components/GenericCard/TableRowGenericCard.d.ts.map +1 -1
- package/dist/components/GenericCard/TableRowGenericCard.js +33 -25
- package/dist/components/GenericCard/TableRowGenericCard.js.map +1 -1
- package/dist/components/Goals/Goals.d.ts +8 -0
- package/dist/components/Goals/Goals.d.ts.map +1 -1
- package/dist/components/Goals/Goals.js +54 -40
- package/dist/components/Goals/Goals.js.map +1 -1
- package/dist/components/Plot/SynapseSankeyPlot.css +1 -0
- package/dist/components/Plot/SynapseSankeyPlot.d.ts +44 -2
- package/dist/components/Plot/SynapseSankeyPlot.d.ts.map +1 -1
- package/dist/components/Plot/SynapseSankeyPlot.js +343 -38
- package/dist/components/Plot/SynapseSankeyPlot.js.map +1 -1
- package/dist/components/Plot/SynapseSankeyPlot.module.js +15 -0
- package/dist/components/Plot/SynapseSankeyPlot.module.js.map +1 -0
- package/dist/components/Plot/SynapseSankeyPlot.module.scss +63 -0
- package/dist/components/ProjectVisibilityChip/ProjectVisibilityChip.d.ts +9 -0
- package/dist/components/ProjectVisibilityChip/ProjectVisibilityChip.d.ts.map +1 -0
- package/dist/components/ProjectVisibilityChip/ProjectVisibilityChip.js +69 -0
- package/dist/components/ProjectVisibilityChip/ProjectVisibilityChip.js.map +1 -0
- package/dist/components/ProjectVisibilityChip/getProjectVisibilityFromACL.d.ts +13 -0
- package/dist/components/ProjectVisibilityChip/getProjectVisibilityFromACL.d.ts.map +1 -0
- package/dist/components/ProjectVisibilityChip/getProjectVisibilityFromACL.js +11 -0
- package/dist/components/ProjectVisibilityChip/getProjectVisibilityFromACL.js.map +1 -0
- package/dist/components/ProjectVisibilityChip/index.d.ts +5 -0
- package/dist/components/ProjectVisibilityChip/index.d.ts.map +1 -0
- package/dist/components/ProjectVisibilityChip/index.js +7 -0
- package/dist/components/ProjectVisibilityChip/index.js.map +1 -0
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.d.ts.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.js +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.js.map +1 -1
- package/dist/components/QueryWrapperPlotNav/RowSetView.d.ts.map +1 -1
- package/dist/components/QueryWrapperPlotNav/RowSetView.js +9 -12
- package/dist/components/QueryWrapperPlotNav/RowSetView.js.map +1 -1
- package/dist/components/RssFeedCards/RssFeedCards.d.ts +7 -15
- package/dist/components/RssFeedCards/RssFeedCards.d.ts.map +1 -1
- package/dist/components/RssFeedCards/RssFeedCards.js +114 -123
- package/dist/components/RssFeedCards/RssFeedCards.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.d.ts +13 -12
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js +88 -77
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js.map +1 -1
- package/dist/components/SynapseTable/TopLevelControls/TopLevelControls.d.ts.map +1 -1
- package/dist/components/SynapseTable/TopLevelControls/TopLevelControls.js +63 -74
- package/dist/components/SynapseTable/TopLevelControls/TopLevelControls.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/ColumnModelForm.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/ColumnModelForm.js +72 -68
- package/dist/components/TableColumnSchemaEditor/ColumnModelForm.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaEditorUtils.d.ts +27 -1
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaEditorUtils.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaEditorUtils.js +47 -36
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaEditorUtils.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaForm.js +1 -1
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaForm.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaFormReducer.d.ts +12 -12
- package/dist/components/TableColumnSchemaEditor/Validators/BooleanSchema.d.ts +4 -1
- package/dist/components/TableColumnSchemaEditor/Validators/BooleanSchema.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/ColumnModelValidator.d.ts +167 -517
- package/dist/components/TableColumnSchemaEditor/Validators/ColumnModelValidator.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/ColumnModelValidator.js +65 -65
- package/dist/components/TableColumnSchemaEditor/Validators/ColumnModelValidator.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/DatetimeSchema.d.ts +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/DatetimeSchema.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/DoubleSchema.d.ts +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/DoubleSchema.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/DoubleSchema.js +6 -13
- package/dist/components/TableColumnSchemaEditor/Validators/DoubleSchema.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/EntityIdSchema.d.ts +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/EntityIdSchema.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/IntegerSchema.d.ts +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/IntegerSchema.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/IntegerSchema.js +2 -2
- package/dist/components/TableColumnSchemaEditor/Validators/IntegerSchema.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/OptionalStringSchema.d.ts +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/OptionalStringSchema.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/getZodSchemaForColumnType.d.ts +2 -2
- package/dist/components/TableColumnSchemaEditor/Validators/getZodSchemaForColumnType.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/Validators/getZodSchemaForColumnType.js +15 -16
- package/dist/components/TableColumnSchemaEditor/Validators/getZodSchemaForColumnType.js.map +1 -1
- package/dist/components/UserCardList/UserCardList.d.ts +2 -20
- package/dist/components/UserCardList/UserCardList.d.ts.map +1 -1
- package/dist/components/UserCardList/UserCardList.js +49 -72
- package/dist/components/UserCardList/UserCardList.js.map +1 -1
- package/dist/components/UserCardList/UserCardListRotate.d.ts +13 -0
- package/dist/components/UserCardList/UserCardListRotate.d.ts.map +1 -1
- package/dist/components/UserCardList/UserCardListRotate.js +82 -57
- package/dist/components/UserCardList/UserCardListRotate.js.map +1 -1
- package/dist/mocks/mockSearchQueryData.js +2 -2
- package/dist/mocks/mockSearchQueryData.js.map +1 -1
- package/dist/mocks/msw/handlers/searchQueryHandlers.d.ts +1 -1
- package/dist/mocks/msw/handlers/searchQueryHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/searchQueryHandlers.js +6 -3
- package/dist/mocks/msw/handlers/searchQueryHandlers.js.map +1 -1
- package/dist/mocks/query/mockUserCardTableQueryResultBundle.d.ts +13 -0
- package/dist/mocks/query/mockUserCardTableQueryResultBundle.d.ts.map +1 -1
- package/dist/mocks/query/mockUserCardTableQueryResultBundle.js +27 -0
- package/dist/mocks/query/mockUserCardTableQueryResultBundle.js.map +1 -1
- package/dist/style/abstracts/_cssVariables.scss +1 -0
- package/dist/style/components/_cards.scss +10 -0
- package/dist/style/components/_data-grid-extra.css +1 -1
- package/dist/style/components/_data-grid-extra.scss +7 -1
- package/dist/style/main.css +1 -1
- package/dist/synapse-client/SynapseClient.d.ts.map +1 -1
- package/dist/synapse-client/SynapseClient.js +497 -495
- package/dist/synapse-client/SynapseClient.js.map +1 -1
- package/dist/synapse-queries/KeyFactory.d.ts +1 -0
- package/dist/synapse-queries/KeyFactory.d.ts.map +1 -1
- package/dist/synapse-queries/KeyFactory.js +3 -0
- package/dist/synapse-queries/KeyFactory.js.map +1 -1
- package/dist/synapse-queries/index.js +46 -44
- package/dist/synapse-queries/user/index.js +3 -3
- package/dist/synapse-queries/user/useUserBundle.d.ts +12 -0
- package/dist/synapse-queries/user/useUserBundle.d.ts.map +1 -1
- package/dist/synapse-queries/user/useUserBundle.js +50 -36
- package/dist/synapse-queries/user/useUserBundle.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/AppUtils/session/SessionInitializedGuard.d.ts +10 -5
- package/dist/utils/AppUtils/session/SessionInitializedGuard.d.ts.map +1 -1
- package/dist/utils/AppUtils/session/SessionInitializedGuard.js +13 -9
- package/dist/utils/AppUtils/session/SessionInitializedGuard.js.map +1 -1
- package/dist/utils/functions/SqlFunctions.d.ts +1 -1
- package/dist/utils/functions/SqlFunctions.d.ts.map +1 -1
- package/dist/utils/functions/SqlFunctions.js +1 -1
- package/dist/utils/functions/SqlFunctions.js.map +1 -1
- package/package.json +7 -5
|
@@ -1,53 +1,59 @@
|
|
|
1
1
|
import "../../utils/SynapseConstants.js";
|
|
2
|
-
import
|
|
3
|
-
import t from "
|
|
2
|
+
import e from "../../synapse-client/index.js";
|
|
3
|
+
import { ErrorBanner as t } from "../error/ErrorBanner.js";
|
|
4
|
+
import { KeyFactory as n } from "../../synapse-queries/KeyFactory.js";
|
|
5
|
+
import r from "../../utils/hooks/useShowDesktop.js";
|
|
4
6
|
import "../../utils/index.js";
|
|
5
|
-
import { getFieldIndex as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { useMemo as
|
|
11
|
-
import { Box as
|
|
12
|
-
import { Fragment as
|
|
7
|
+
import { getFieldIndex as i } from "../../utils/functions/queryUtils.js";
|
|
8
|
+
import a, { tableQueryUseQueryDefaults as o } from "../../synapse-queries/entity/useGetQueryResultBundle.js";
|
|
9
|
+
import s from "../../utils/hooks/useGetGoalData.js";
|
|
10
|
+
import c from "./Goals.Desktop.js";
|
|
11
|
+
import l from "./Goals.Mobile.js";
|
|
12
|
+
import { useMemo as u } from "react";
|
|
13
|
+
import { Box as d } from "@mui/material";
|
|
14
|
+
import { Fragment as f, jsx as p } from "react/jsx-runtime";
|
|
13
15
|
//#region src/components/Goals/Goals.tsx
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
|
|
16
|
+
var m = 1200;
|
|
17
|
+
function h(e) {
|
|
18
|
+
return {
|
|
17
19
|
concreteType: "org.sagebionetworks.repo.model.table.QueryBundleRequest",
|
|
18
|
-
entityId:
|
|
20
|
+
entityId: e,
|
|
19
21
|
partMask: 5,
|
|
20
22
|
query: { sql: `select *
|
|
21
|
-
from ${
|
|
23
|
+
from ${e}
|
|
22
24
|
order by ItemOrder` }
|
|
23
|
-
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function g(e) {
|
|
28
|
+
let { entityId: n, isAssetIcon: o = !1, linkText: g, itemsPerRow: _ = 3 } = e, v = r(m), { data: y } = a(h(n)), { assets: b, error: x } = s(n, y), S = i("TableId", y), C = i("CountSql", y), w = i("Title", y), T = i("Summary", y), E = i("Link", y), D = u(() => y?.queryResult.queryResults.rows.map((e, t) => {
|
|
24
29
|
let n = e.values;
|
|
25
30
|
n.some((e) => e === null) && console.warn("Row has null value(s) when no nulls expected");
|
|
26
|
-
let r =
|
|
27
|
-
|
|
28
|
-
let a = n[
|
|
31
|
+
let r = S > -1 ? n[S] : void 0, i;
|
|
32
|
+
C > -1 && n[C] ? i = n[C] : r && (i = `SELECT * FROM ${r}`);
|
|
33
|
+
let a = n[w], s = n[T], c = n[E], l = b?.[t] ?? "";
|
|
29
34
|
return {
|
|
30
35
|
countSql: i,
|
|
31
36
|
title: a,
|
|
32
|
-
summary:
|
|
33
|
-
link:
|
|
34
|
-
asset:
|
|
35
|
-
isAssetIcon:
|
|
37
|
+
summary: s,
|
|
38
|
+
link: c,
|
|
39
|
+
asset: l,
|
|
40
|
+
isAssetIcon: o
|
|
36
41
|
};
|
|
37
42
|
}), [
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
C,
|
|
44
|
+
b,
|
|
45
|
+
o,
|
|
46
|
+
E,
|
|
47
|
+
y?.queryResult,
|
|
40
48
|
T,
|
|
41
|
-
|
|
42
|
-
w
|
|
43
|
-
x,
|
|
44
|
-
C
|
|
49
|
+
S,
|
|
50
|
+
w
|
|
45
51
|
]);
|
|
46
|
-
if (
|
|
47
|
-
if (!
|
|
48
|
-
if (
|
|
49
|
-
let e = `calc((100% - ${
|
|
50
|
-
return /* @__PURE__ */
|
|
52
|
+
if (x) return /* @__PURE__ */ p(t, { error: x });
|
|
53
|
+
if (!D) return /* @__PURE__ */ p(f, {});
|
|
54
|
+
if (v) {
|
|
55
|
+
let e = `calc((100% - ${_ * 20 + (_ - 1) * 7}px) / ${_} - 0.5px)`;
|
|
56
|
+
return /* @__PURE__ */ p(d, {
|
|
51
57
|
className: "Goals",
|
|
52
58
|
sx: {
|
|
53
59
|
display: "flex",
|
|
@@ -56,21 +62,29 @@ function f(f) {
|
|
|
56
62
|
justifyContent: "center",
|
|
57
63
|
alignItems: "stretch"
|
|
58
64
|
},
|
|
59
|
-
children:
|
|
65
|
+
children: D.map((t, n) => /* @__PURE__ */ p(c, {
|
|
60
66
|
...t,
|
|
61
|
-
linkText:
|
|
67
|
+
linkText: g,
|
|
62
68
|
cardWidth: e
|
|
63
69
|
}, n))
|
|
64
70
|
});
|
|
65
|
-
} else return /* @__PURE__ */
|
|
71
|
+
} else return /* @__PURE__ */ p("div", {
|
|
66
72
|
className: "Goals",
|
|
67
|
-
children:
|
|
73
|
+
children: D.map((e, t) => /* @__PURE__ */ p(l, {
|
|
68
74
|
...e,
|
|
69
|
-
linkText:
|
|
75
|
+
linkText: g
|
|
70
76
|
}, t))
|
|
71
77
|
});
|
|
72
78
|
}
|
|
79
|
+
async function _(t, r) {
|
|
80
|
+
let i = new n(void 0), a = h(r);
|
|
81
|
+
await t.prefetchQuery({
|
|
82
|
+
...o,
|
|
83
|
+
queryKey: i.getEntityTableQueryResultQueryKey(a, !1),
|
|
84
|
+
queryFn: () => e.getQueryTableResults(a, void 0)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
73
87
|
//#endregion
|
|
74
|
-
export {
|
|
88
|
+
export { g as Goals, g as default, h as buildGoalsQueryBundleRequest, _ as prefetchGoals };
|
|
75
89
|
|
|
76
90
|
//# sourceMappingURL=Goals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Goals.js","names":[],"sources":["../../../src/components/Goals/Goals.tsx"],"sourcesContent":["import useGetQueryResultBundle from '@/synapse-queries/entity/useGetQueryResultBundle'\nimport { SynapseConstants } from '@/utils'\nimport { getFieldIndex } from '@/utils/functions/queryUtils'\nimport useGetGoalData from '@/utils/hooks/useGetGoalData'\nimport useShowDesktop from '@/utils/hooks/useShowDesktop'\nimport { QueryBundleRequest } from '@sage-bionetworks/synapse-types'\nimport { useMemo } from 'react'\nimport { ErrorBanner } from '../error/ErrorBanner'\nimport GoalsDesktop from './Goals.Desktop'\nimport GoalsMobile from './Goals.Mobile'\nimport { Box } from '@mui/material'\n\nexport type GoalsProps = {\n entityId: string\n isAssetIcon?: boolean // If true, the asset will be used as an icon instead of a background image.\n linkText?: string\n itemsPerRow?: number\n}\n\nexport type GoalsDataProps = {\n countSql?: string\n title: string\n summary: string\n link: string\n asset: string\n isAssetIcon: boolean\n linkText?: string\n}\n\nenum ExpectedColumns {\n TABLEID = 'TableId', // Both TableId or CountSql are used to indicate what Table rows to count.\n COUNT_SQL = 'CountSql', // Code uses CountSql over TableId if defined (if the CountSql column is in the schema and filled in).\n TITLE = 'Title',\n SUMMARY = 'Summary',\n LINK = 'Link',\n ASSET = 'Asset',\n}\n\n// PORTALS-2367\nconst GOALS_DESKTOP_MIN_BREAKPOINT = 1200\n\nexport function
|
|
1
|
+
{"version":3,"file":"Goals.js","names":[],"sources":["../../../src/components/Goals/Goals.tsx"],"sourcesContent":["import SynapseClient from '@/synapse-client'\nimport useGetQueryResultBundle, {\n tableQueryUseQueryDefaults,\n} from '@/synapse-queries/entity/useGetQueryResultBundle'\nimport { KeyFactory } from '@/synapse-queries/KeyFactory'\nimport { SynapseConstants } from '@/utils'\nimport { getFieldIndex } from '@/utils/functions/queryUtils'\nimport useGetGoalData from '@/utils/hooks/useGetGoalData'\nimport useShowDesktop from '@/utils/hooks/useShowDesktop'\nimport { QueryBundleRequest } from '@sage-bionetworks/synapse-types'\nimport { QueryClient } from '@tanstack/react-query'\nimport { useMemo } from 'react'\nimport { ErrorBanner } from '../error/ErrorBanner'\nimport GoalsDesktop from './Goals.Desktop'\nimport GoalsMobile from './Goals.Mobile'\nimport { Box } from '@mui/material'\n\nexport type GoalsProps = {\n entityId: string\n isAssetIcon?: boolean // If true, the asset will be used as an icon instead of a background image.\n linkText?: string\n itemsPerRow?: number\n}\n\nexport type GoalsDataProps = {\n countSql?: string\n title: string\n summary: string\n link: string\n asset: string\n isAssetIcon: boolean\n linkText?: string\n}\n\nenum ExpectedColumns {\n TABLEID = 'TableId', // Both TableId or CountSql are used to indicate what Table rows to count.\n COUNT_SQL = 'CountSql', // Code uses CountSql over TableId if defined (if the CountSql column is in the schema and filled in).\n TITLE = 'Title',\n SUMMARY = 'Summary',\n LINK = 'Link',\n ASSET = 'Asset',\n}\n\n// PORTALS-2367\nconst GOALS_DESKTOP_MIN_BREAKPOINT = 1200\n\nexport function buildGoalsQueryBundleRequest(\n entityId: string,\n): QueryBundleRequest {\n return {\n concreteType: 'org.sagebionetworks.repo.model.table.QueryBundleRequest',\n entityId,\n partMask:\n SynapseConstants.BUNDLE_MASK_QUERY_SELECT_COLUMNS |\n SynapseConstants.BUNDLE_MASK_QUERY_RESULTS,\n query: {\n sql: `select *\n from ${entityId}\n order by ItemOrder`,\n },\n }\n}\n\nexport function Goals(props: GoalsProps) {\n const { entityId, isAssetIcon = false, linkText, itemsPerRow = 3 } = props\n const showDesktop = useShowDesktop(GOALS_DESKTOP_MIN_BREAKPOINT)\n const queryBundleRequest = buildGoalsQueryBundleRequest(entityId)\n const { data: queryResultBundle } =\n useGetQueryResultBundle(queryBundleRequest)\n\n const { assets: goalAssets, error: goalError } = useGetGoalData(\n entityId,\n queryResultBundle,\n )\n\n const tableIdColumnIndex = getFieldIndex(\n ExpectedColumns.TABLEID,\n queryResultBundle,\n )\n const countSqlColumnIndex = getFieldIndex(\n ExpectedColumns.COUNT_SQL,\n queryResultBundle,\n )\n\n const titleColumnIndex = getFieldIndex(\n ExpectedColumns.TITLE,\n queryResultBundle,\n )\n const summaryColumnIndex = getFieldIndex(\n ExpectedColumns.SUMMARY,\n queryResultBundle,\n )\n const linkColumnIndex = getFieldIndex(ExpectedColumns.LINK, queryResultBundle)\n\n const goalsDataProps = useMemo(() => {\n return queryResultBundle?.queryResult!.queryResults.rows.map(\n (el, index): GoalsDataProps => {\n const values = el.values as string[]\n if (values.some(value => value === null)) {\n // We cast values above assuming there are no null values, emit a warning just in case.\n console.warn('Row has null value(s) when no nulls expected')\n }\n const tableId =\n tableIdColumnIndex > -1 ? values[tableIdColumnIndex] : undefined\n let countSql\n if (countSqlColumnIndex > -1 && values[countSqlColumnIndex]) {\n countSql = values[countSqlColumnIndex]\n } else if (tableId) {\n countSql = `SELECT * FROM ${tableId}`\n }\n const title = values[titleColumnIndex]\n const summary = values[summaryColumnIndex]\n const link = values[linkColumnIndex]\n // assume that we recieve assets in order of rows and there is an asset for each item\n // can revisit if this isn't the case.\n const asset = goalAssets?.[index] ?? ''\n return {\n countSql,\n title,\n summary,\n link,\n asset,\n isAssetIcon,\n }\n },\n )\n }, [\n countSqlColumnIndex,\n goalAssets,\n isAssetIcon,\n linkColumnIndex,\n queryResultBundle?.queryResult,\n summaryColumnIndex,\n tableIdColumnIndex,\n titleColumnIndex,\n ])\n\n if (goalError) {\n return <ErrorBanner error={goalError} />\n }\n\n if (!goalsDataProps) {\n return <></>\n }\n\n if (showDesktop) {\n // Each card has margin:10px (20px horizontal) from .Goals__Card CSS.\n // flex-basis must be the content width only; total row = N*(flex-basis+20) + (N-1)*gap.\n // Subtract 0.5px epsilon to absorb sub-pixel rounding and prevent wrapping.\n const horizontalMarginPerCard = 20\n const cardWidth = `calc((100% - ${\n itemsPerRow * horizontalMarginPerCard + (itemsPerRow - 1) * 7\n }px) / ${itemsPerRow} - 0.5px)`\n return (\n <Box\n className={`Goals`}\n sx={{\n display: 'flex',\n flexWrap: 'wrap',\n gap: '7px',\n justifyContent: 'center',\n alignItems: 'stretch',\n }}\n >\n {goalsDataProps.map((props, index) => (\n <GoalsDesktop\n key={index}\n {...props}\n linkText={linkText}\n cardWidth={cardWidth}\n />\n ))}\n </Box>\n )\n } else {\n return (\n <div className={`Goals`}>\n {goalsDataProps.map((props, index) => (\n <GoalsMobile key={index} {...props} linkText={linkText} />\n ))}\n </div>\n )\n }\n}\nexport default Goals\n\n/**\n * Prefetches the Goals table query into a QueryClient for use with HydrationBoundary.\n * Uses anonymous access; warm-caches for unauthenticated users.\n */\nexport async function prefetchGoals(\n queryClient: QueryClient,\n entityId: string,\n): Promise<void> {\n const keyFactory = new KeyFactory(undefined)\n const queryBundleRequest = buildGoalsQueryBundleRequest(entityId)\n await queryClient.prefetchQuery({\n ...tableQueryUseQueryDefaults,\n queryKey: keyFactory.getEntityTableQueryResultQueryKey(\n queryBundleRequest,\n false,\n ),\n queryFn: () =>\n SynapseClient.getQueryTableResults(queryBundleRequest, undefined),\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4CA,IAAM,IAA+B;AAErC,SAAgB,EACd,GACoB;CACpB,OAAO;EACL,cAAc;EACd;EACA,UACE;EAEF,OAAO,EACL,KAAK;mBACQ,EAAS;gCAExB;CACF;AACF;AAEA,SAAgB,EAAM,GAAmB;CACvC,IAAM,EAAE,aAAU,iBAAc,IAAO,aAAU,iBAAc,MAAM,GAC/D,IAAc,EAAe,CAA4B,GAEzD,EAAE,MAAM,MACZ,EAFyB,EAA6B,CAE9B,CAAkB,GAEtC,EAAE,QAAQ,GAAY,OAAO,MAAc,EAC/C,GACA,CACF,GAEM,IAAqB,EAAA,WAEzB,CACF,GACM,IAAsB,EAAA,YAE1B,CACF,GAEM,IAAmB,EAAA,SAEvB,CACF,GACM,IAAqB,EAAA,WAEzB,CACF,GACM,IAAkB,EAAA,QAAoC,CAAiB,GAEvE,IAAiB,QACd,GAAmB,YAAa,aAAa,KAAK,KACtD,GAAI,MAA0B;EAC7B,IAAM,IAAS,EAAG;EAClB,AAAI,EAAO,MAAK,MAAS,MAAU,IAAI,KAErC,QAAQ,KAAK,8CAA8C;EAE7D,IAAM,IACJ,IAAqB,KAAK,EAAO,KAAsB,KAAA,GACrD;EACJ,AAAI,IAAsB,MAAM,EAAO,KACrC,IAAW,EAAO,KACT,MACT,IAAW,iBAAiB;EAE9B,IAAM,IAAQ,EAAO,IACf,IAAU,EAAO,IACjB,IAAO,EAAO,IAGd,IAAQ,IAAa,MAAU;EACrC,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;EACF;CACF,CACF,GACC;EACD;EACA;EACA;EACA;EACA,GAAmB;EACnB;EACA;EACA;CACF,CAAC;CAED,IAAI,GACF,OAAO,kBAAC,GAAD,EAAa,OAAO,EAAY,CAAA;CAGzC,IAAI,CAAC,GACH,OAAO,kBAAA,GAAA,CAAI,CAAA;CAGb,IAAI,GAAa;EAKf,IAAM,IAAY,gBAChB,IAAc,MAA2B,IAAc,KAAK,EAC7D,QAAQ,EAAY;EACrB,OACE,kBAAC,GAAD;GACE,WAAW;GACX,IAAI;IACF,SAAS;IACT,UAAU;IACV,KAAK;IACL,gBAAgB;IAChB,YAAY;GACd;aAEC,EAAe,KAAK,GAAO,MAC1B,kBAAC,GAAD;IAEE,GAAI;IACM;IACC;GACZ,GAJM,CAIN,CACF;EACE,CAAA;CAET,OACE,OACE,kBAAC,OAAD;EAAK,WAAW;YACb,EAAe,KAAK,GAAO,MAC1B,kBAAC,GAAD;GAAyB,GAAI;GAAiB;EAAW,GAAvC,CAAuC,CAC1D;CACE,CAAA;AAGX;AAOA,eAAsB,EACpB,GACA,GACe;CACf,IAAM,IAAa,IAAI,EAAW,KAAA,CAAS,GACrC,IAAqB,EAA6B,CAAQ;CAChE,MAAM,EAAY,cAAc;EAC9B,GAAG;EACH,UAAU,EAAW,kCACnB,GACA,EACF;EACA,eACE,EAAc,qBAAqB,GAAoB,KAAA,CAAS;CACpE,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._root_244go_1{opacity:0;width:100%;margin-top:48px;transition:opacity .6s}._rootVisible_244go_8{opacity:1}._title_244go_12{text-align:center;margin-bottom:12px;font-size:20px;font-weight:600}._svg_244go_19{outline:none;width:100%;height:auto;margin:0 auto;display:block;overflow:visible}._ribbon_244go_28{transition:stroke-opacity .25s,stroke-width .25s}._node_244go_32{transition:fill-opacity .25s}._categoryLabel_244go_36{transition:opacity .2s}._tabularNums_244go_40{font-variant-numeric:tabular-nums}._haloText_244go_44{paint-order:stroke;stroke-width:3px;stroke-linejoin:round}@media (prefers-reduced-motion:reduce){._root_244go_1{transition:none}}
|
|
@@ -1,11 +1,53 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export type SynapseSankeyPlotProps = {
|
|
3
|
-
/** SQL query
|
|
3
|
+
/** SQL query providing the node labels and link values (see labelColumn/valueColumn) */
|
|
4
4
|
sql: string;
|
|
5
|
-
/** Label for the
|
|
5
|
+
/** Label for the left end node that links to every row returned by the query */
|
|
6
6
|
rootLabel: string;
|
|
7
7
|
/** Optional plot title */
|
|
8
8
|
title?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Column supplying each category's label. Either a column name (matched
|
|
11
|
+
* against the query result headers) or a zero-based index. Defaults to the
|
|
12
|
+
* first column.
|
|
13
|
+
*/
|
|
14
|
+
labelColumn?: string | number;
|
|
15
|
+
/**
|
|
16
|
+
* Column supplying each link's value. Either a column name or a zero-based
|
|
17
|
+
* index. Defaults to the second column.
|
|
18
|
+
*/
|
|
19
|
+
valueColumn?: string | number;
|
|
20
|
+
/**
|
|
21
|
+
* Noun for the left end total caption, e.g. "datasets" renders
|
|
22
|
+
* "datasets total". Defaults to "items".
|
|
23
|
+
*/
|
|
24
|
+
unitLabel?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Phrase describing the breakdown, used in the chart's accessible label,
|
|
27
|
+
* e.g. "by source" renders "All Datasets broken down by source".
|
|
28
|
+
*/
|
|
29
|
+
breakdownLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Invoked with a category's label when its left flow, center node, or label
|
|
32
|
+
* is clicked. When provided, those become interactive (pointer cursor).
|
|
33
|
+
*/
|
|
34
|
+
onCategoryClick?: (categoryLabel: string) => void;
|
|
35
|
+
/** Invoked when the left end node (rootLabel) is clicked. */
|
|
36
|
+
onRootClick?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Enables "butterfly" mode: a second value per category drawn as a mirrored
|
|
39
|
+
* flow from each center node to a right end node. Either a column name or a
|
|
40
|
+
* zero-based index (defaults to the third column when a right end is shown).
|
|
41
|
+
*/
|
|
42
|
+
rightValueColumn?: string | number;
|
|
43
|
+
/** Label for the right end node (butterfly mode). Defaults to "Files". */
|
|
44
|
+
rightLabel?: string;
|
|
45
|
+
/** Noun for the right end total caption, e.g. "files". Defaults to "items". */
|
|
46
|
+
rightUnitLabel?: string;
|
|
47
|
+
/** Invoked with a category's label when its right flow is clicked. */
|
|
48
|
+
onRightCategoryClick?: (categoryLabel: string) => void;
|
|
49
|
+
/** Invoked when the right end node (rightLabel) is clicked. */
|
|
50
|
+
onRightEndClick?: () => void;
|
|
9
51
|
};
|
|
10
52
|
export declare const SynapseSankeyPlot: (props: SynapseSankeyPlotProps) => React.ReactNode;
|
|
11
53
|
export default SynapseSankeyPlot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SynapseSankeyPlot.d.ts","sourceRoot":"","sources":["../../../src/components/Plot/SynapseSankeyPlot.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SynapseSankeyPlot.d.ts","sourceRoot":"","sources":["../../../src/components/Plot/SynapseSankeyPlot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsD,MAAM,OAAO,CAAA;AAe1E,MAAM,MAAM,sBAAsB,GAAG;IACnC,wFAAwF;IACxF,GAAG,EAAE,MAAM,CAAA;IACX,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAA;IACjB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAA;IACjD,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAClC,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAA;IACtD,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;CAC7B,CAAA;AAiPD,eAAO,MAAM,iBAAiB,GAC5B,OAAO,sBAAsB,KAC5B,KAAK,CAAC,SAibR,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -3,52 +3,357 @@ import { parseEntityIdFromSqlStatement as e } from "../../utils/functions/SqlFun
|
|
|
3
3
|
import "../../utils/index.js";
|
|
4
4
|
import { useGetFullTableQueryResults as t } from "../../synapse-queries/entity/useGetQueryResultBundle.js";
|
|
5
5
|
import "../../synapse-queries/index.js";
|
|
6
|
-
import
|
|
7
|
-
import "react";
|
|
8
|
-
import { Skeleton as
|
|
9
|
-
import { Fragment as
|
|
6
|
+
import n from "./SynapseSankeyPlot.module.js";
|
|
7
|
+
import { useEffect as r, useId as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
8
|
+
import { Skeleton as c, useTheme as l } from "@mui/material";
|
|
9
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
10
|
+
import p from "tinycolor2";
|
|
11
|
+
import { sankey as m, sankeyLinkHorizontal as h } from "d3-sankey";
|
|
12
|
+
import g from "classnames";
|
|
10
13
|
//#region src/components/Plot/SynapseSankeyPlot.tsx
|
|
11
|
-
var
|
|
12
|
-
|
|
14
|
+
var _ = 920, ee = 124, te = 286, v = 22, ne = 13, re = 34, ie = 46, y = 14, b = 70, x = 64, S = 4.5, ae = 64, oe = 56, se = 44, C = 160, w = (e) => ((e.y0 ?? 0) + (e.y1 ?? 0)) / 2, T = (e) => ((e.x0 ?? 0) + (e.x1 ?? 0)) / 2;
|
|
15
|
+
function E(e) {
|
|
16
|
+
let { node: t, total: r, unitLabel: i, align: a, onMouseEnter: o, interactiveProps: s } = e, c = l(), u = w(t), p = a === "left" ? (t.x0 ?? 0) - y : (t.x1 ?? 0) + y, m = a === "left" ? "end" : "start";
|
|
17
|
+
return /* @__PURE__ */ f("g", {
|
|
18
|
+
onMouseEnter: o,
|
|
19
|
+
...s,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ d("text", {
|
|
22
|
+
x: p,
|
|
23
|
+
y: u - 22,
|
|
24
|
+
textAnchor: m,
|
|
25
|
+
fontSize: 10,
|
|
26
|
+
fontWeight: 600,
|
|
27
|
+
letterSpacing: 1.2,
|
|
28
|
+
fill: c.palette.grey[700],
|
|
29
|
+
children: t.name.toUpperCase()
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ d("text", {
|
|
32
|
+
x: p,
|
|
33
|
+
y: u + 6,
|
|
34
|
+
textAnchor: m,
|
|
35
|
+
fontSize: 26,
|
|
36
|
+
fontWeight: 600,
|
|
37
|
+
fill: c.palette.primary.dark,
|
|
38
|
+
className: n.tabularNums,
|
|
39
|
+
children: r.toLocaleString()
|
|
40
|
+
}),
|
|
41
|
+
/* @__PURE__ */ d("text", {
|
|
42
|
+
x: p,
|
|
43
|
+
y: u + 23,
|
|
44
|
+
textAnchor: m,
|
|
45
|
+
fontSize: 11,
|
|
46
|
+
fontWeight: 500,
|
|
47
|
+
fill: c.palette.text.secondary,
|
|
48
|
+
children: `${i} total`
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function ce(e) {
|
|
54
|
+
let { node: t, total: r, opacity: i, onMouseEnter: a, interactiveProps: o } = e, s = l(), c = w(t), u = (t.x1 ?? 0) + y, p = t.value ?? 0, m = r > 0 ? p / r : 0, h = u + b, g = c + 6;
|
|
55
|
+
return /* @__PURE__ */ f("g", {
|
|
56
|
+
opacity: i,
|
|
57
|
+
className: n.categoryLabel,
|
|
58
|
+
onMouseEnter: a,
|
|
59
|
+
...o,
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ d("text", {
|
|
62
|
+
x: u,
|
|
63
|
+
y: c - 4,
|
|
64
|
+
fontSize: 13,
|
|
65
|
+
fontWeight: 600,
|
|
66
|
+
fill: s.palette.text.primary,
|
|
67
|
+
children: t.name
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ d("text", {
|
|
70
|
+
x: u,
|
|
71
|
+
y: c + 14,
|
|
72
|
+
fontSize: 13,
|
|
73
|
+
fontWeight: 600,
|
|
74
|
+
fill: t.color,
|
|
75
|
+
className: n.tabularNums,
|
|
76
|
+
children: p.toLocaleString()
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ d("rect", {
|
|
79
|
+
x: h,
|
|
80
|
+
y: g,
|
|
81
|
+
width: x,
|
|
82
|
+
height: S,
|
|
83
|
+
rx: S / 2,
|
|
84
|
+
fill: s.palette.grey[300]
|
|
85
|
+
}),
|
|
86
|
+
/* @__PURE__ */ d("rect", {
|
|
87
|
+
x: h,
|
|
88
|
+
y: g,
|
|
89
|
+
width: x * m,
|
|
90
|
+
height: S,
|
|
91
|
+
rx: S / 2,
|
|
92
|
+
fill: t.color
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ f("text", {
|
|
95
|
+
x: h + x + 7,
|
|
96
|
+
y: c + 13,
|
|
97
|
+
fontSize: 11,
|
|
98
|
+
fontWeight: 500,
|
|
99
|
+
fill: s.palette.grey[700],
|
|
100
|
+
className: n.tabularNums,
|
|
101
|
+
children: [(m * 100).toFixed(1), "%"]
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function le(e) {
|
|
107
|
+
let { node: t, leftValue: r, rightValue: i, unitLabel: a, rightUnitLabel: o, opacity: s, onMouseEnter: c, interactiveProps: u } = e, p = l(), m = T(t), h = t.y0 ?? 0;
|
|
108
|
+
return /* @__PURE__ */ f("g", {
|
|
109
|
+
opacity: s,
|
|
110
|
+
className: n.categoryLabel,
|
|
111
|
+
onMouseEnter: c,
|
|
112
|
+
...u,
|
|
113
|
+
children: [/* @__PURE__ */ d("text", {
|
|
114
|
+
x: m,
|
|
115
|
+
y: h - 20,
|
|
116
|
+
textAnchor: "middle",
|
|
117
|
+
fontSize: 13,
|
|
118
|
+
fontWeight: 600,
|
|
119
|
+
fill: p.palette.text.primary,
|
|
120
|
+
stroke: p.palette.background.paper,
|
|
121
|
+
className: n.haloText,
|
|
122
|
+
children: t.name
|
|
123
|
+
}), /* @__PURE__ */ d("text", {
|
|
124
|
+
x: m,
|
|
125
|
+
y: h - 6,
|
|
126
|
+
textAnchor: "middle",
|
|
127
|
+
fontSize: 11,
|
|
128
|
+
fontWeight: 600,
|
|
129
|
+
fill: p.palette.text.secondary,
|
|
130
|
+
stroke: p.palette.background.paper,
|
|
131
|
+
className: g(n.tabularNums, n.haloText),
|
|
132
|
+
children: `${r.toLocaleString()} ${a} · ${i.toLocaleString()} ${o}`
|
|
133
|
+
})]
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
var D = (y) => {
|
|
137
|
+
let { sql: b, rootLabel: x, title: S, labelColumn: w, valueColumn: T, unitLabel: D = "items", breakdownLabel: O, onCategoryClick: k, onRootClick: A, rightValueColumn: j, rightLabel: ue = "Files", rightUnitLabel: de = "items", onRightCategoryClick: fe, onRightEndClick: M } = y, N = l(), P = i(), F = j !== void 0, [pe, I] = s(null), [L, R] = s(null), [me, he] = s(!1);
|
|
138
|
+
r(() => {
|
|
139
|
+
let e = requestAnimationFrame(() => he(!0));
|
|
140
|
+
return () => cancelAnimationFrame(e);
|
|
141
|
+
}, []);
|
|
142
|
+
let z = o(void 0);
|
|
143
|
+
r(() => () => {
|
|
144
|
+
z.current !== void 0 && window.clearTimeout(z.current);
|
|
145
|
+
}, []);
|
|
146
|
+
let { data: B, isLoading: ge } = t({
|
|
13
147
|
concreteType: "org.sagebionetworks.repo.model.table.QueryBundleRequest",
|
|
14
148
|
partMask: 1,
|
|
15
|
-
entityId: e(
|
|
16
|
-
query: { sql:
|
|
17
|
-
})
|
|
18
|
-
|
|
149
|
+
entityId: e(b),
|
|
150
|
+
query: { sql: b }
|
|
151
|
+
}), V = a(() => B?.queryResult?.queryResults.rows ?? [], [B]), { labelIndex: H, valueIndex: U, rightValueIndex: W } = a(() => {
|
|
152
|
+
let e = B?.queryResult?.queryResults.headers ?? [], t = (t, n) => {
|
|
153
|
+
if (typeof t == "number") return t;
|
|
154
|
+
if (typeof t == "string") {
|
|
155
|
+
let r = e.findIndex((e) => e.name === t);
|
|
156
|
+
return r >= 0 ? r : n;
|
|
157
|
+
}
|
|
158
|
+
return n;
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
labelIndex: t(w, 0),
|
|
162
|
+
valueIndex: t(T, 1),
|
|
163
|
+
rightValueIndex: F ? t(j, 2) : -1
|
|
164
|
+
};
|
|
165
|
+
}, [
|
|
166
|
+
B,
|
|
167
|
+
w,
|
|
168
|
+
T,
|
|
169
|
+
j,
|
|
170
|
+
F
|
|
171
|
+
]), G = N.typography.fontFamily ?? "inherit", K = N.palette.primary.dark, _e = N.palette.text.primary, q = F ? se : v, ve = F ? ae : ie, J = Math.max(320, q + v + V.length * ve), ye = a(() => {
|
|
172
|
+
if (V.length === 0) return null;
|
|
173
|
+
let e = p(N.palette.primary.main).lighten(18), t = p(N.palette.primary.main).darken(12), n = (n) => V.length <= 1 ? N.palette.primary.main : p.mix(e, t, n / (V.length - 1) * 100).toHexString(), r = V.map((e, t) => ({
|
|
174
|
+
name: String(e.values[H] ?? ""),
|
|
175
|
+
leftValue: Number(e.values[U] ?? 0),
|
|
176
|
+
rightValue: F ? Number(e.values[W] ?? 0) : 0,
|
|
177
|
+
color: n(t)
|
|
178
|
+
})), i = r.reduce((e, t) => e + t.leftValue, 0), a = r.reduce((e, t) => e + t.rightValue, 0), o = r.length + 1, s = F && i > 0 && a > 0 ? a / i : 1, c = (e, t) => t === "left" ? e * s : e, l = [
|
|
179
|
+
{
|
|
180
|
+
name: x,
|
|
181
|
+
value: i,
|
|
182
|
+
color: K,
|
|
183
|
+
kind: "leftEnd"
|
|
184
|
+
},
|
|
185
|
+
...r.map((e) => ({
|
|
186
|
+
name: e.name,
|
|
187
|
+
value: e.leftValue,
|
|
188
|
+
color: e.color,
|
|
189
|
+
kind: "source",
|
|
190
|
+
leftValue: e.leftValue,
|
|
191
|
+
rightValue: e.rightValue
|
|
192
|
+
})),
|
|
193
|
+
...F ? [{
|
|
194
|
+
name: ue,
|
|
195
|
+
value: a,
|
|
196
|
+
color: K,
|
|
197
|
+
kind: "rightEnd"
|
|
198
|
+
}] : []
|
|
199
|
+
], u = [...r.map((e, t) => ({
|
|
200
|
+
source: 0,
|
|
201
|
+
target: t + 1,
|
|
202
|
+
value: c(e.leftValue, "left"),
|
|
203
|
+
sourceIndex: t,
|
|
204
|
+
side: "left"
|
|
205
|
+
})), ...F ? r.map((e, t) => ({
|
|
206
|
+
source: t + 1,
|
|
207
|
+
target: o,
|
|
208
|
+
value: c(e.rightValue, "right"),
|
|
209
|
+
sourceIndex: t,
|
|
210
|
+
side: "right"
|
|
211
|
+
})) : []], d = F ? oe : re, f = F ? C : ee, h = F ? C : te;
|
|
212
|
+
return {
|
|
213
|
+
graph: m().nodeWidth(ne).nodePadding(d).nodeSort(null).extent([[f, q], [_ - h, J - v]])({
|
|
214
|
+
nodes: l.map((e) => ({ ...e })),
|
|
215
|
+
links: u.map((e) => ({ ...e }))
|
|
216
|
+
}),
|
|
217
|
+
totalLeft: i,
|
|
218
|
+
totalRight: a
|
|
219
|
+
};
|
|
220
|
+
}, [
|
|
221
|
+
V,
|
|
222
|
+
H,
|
|
223
|
+
U,
|
|
224
|
+
W,
|
|
225
|
+
F,
|
|
226
|
+
x,
|
|
227
|
+
ue,
|
|
228
|
+
K,
|
|
229
|
+
N.palette.primary.main,
|
|
230
|
+
J,
|
|
231
|
+
q
|
|
232
|
+
]);
|
|
233
|
+
if (ge) return /* @__PURE__ */ d(c, {
|
|
19
234
|
width: "100%",
|
|
20
235
|
height: "500px"
|
|
21
236
|
});
|
|
22
|
-
if (!
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
237
|
+
if (!ye) return /* @__PURE__ */ d(u, {});
|
|
238
|
+
let { graph: Y, totalLeft: be, totalRight: xe } = ye, Se = h(), X = L ?? pe, Ce = L === null ? .07 : .05, we = L === null ? .16 : .1, Te = L === null ? .32 : .15, Ee = (e) => X === null ? .6 : e === X ? L === null ? .95 : 1 : Ce, De = (e) => X === null || e.kind !== "source" || (e.index ?? 1) - 1 === X ? 1 : we, Oe = (e) => X === null || X === e ? 1 : Te, ke = (e, t) => {
|
|
239
|
+
z.current !== void 0 && window.clearTimeout(z.current), R(e), z.current = window.setTimeout(() => {
|
|
240
|
+
z.current = void 0, R(null), t();
|
|
241
|
+
}, 320);
|
|
242
|
+
}, Z = (e, t) => t ? {
|
|
243
|
+
cursor: "pointer",
|
|
244
|
+
onClick: () => ke(e, t)
|
|
245
|
+
} : {}, Q = (e) => e ? {
|
|
246
|
+
cursor: "pointer",
|
|
247
|
+
onClick: e
|
|
248
|
+
} : {}, $ = (e) => k ? () => k(e) : void 0;
|
|
249
|
+
return /* @__PURE__ */ f("div", {
|
|
250
|
+
className: g(n.root, { [n.rootVisible]: me }),
|
|
251
|
+
children: [S && /* @__PURE__ */ d("div", {
|
|
252
|
+
className: n.title,
|
|
253
|
+
style: {
|
|
254
|
+
fontFamily: G,
|
|
255
|
+
color: _e
|
|
256
|
+
},
|
|
257
|
+
children: S
|
|
258
|
+
}), /* @__PURE__ */ f("svg", {
|
|
259
|
+
viewBox: `0 0 ${_} ${J}`,
|
|
260
|
+
role: "img",
|
|
261
|
+
"aria-label": O ? `${x} broken down ${O}` : `${x} breakdown`,
|
|
262
|
+
className: n.svg,
|
|
263
|
+
style: {
|
|
264
|
+
fontFamily: G,
|
|
265
|
+
maxWidth: _
|
|
266
|
+
},
|
|
267
|
+
onMouseLeave: () => I(null),
|
|
268
|
+
children: [
|
|
269
|
+
/* @__PURE__ */ d("defs", { children: Y.links.map((e, t) => {
|
|
270
|
+
let n = e.source, r = e.target;
|
|
271
|
+
return /* @__PURE__ */ f("linearGradient", {
|
|
272
|
+
id: `${P}-grad-${t}`,
|
|
273
|
+
gradientUnits: "userSpaceOnUse",
|
|
274
|
+
x1: n.x1,
|
|
275
|
+
x2: r.x0,
|
|
276
|
+
children: [/* @__PURE__ */ d("stop", {
|
|
277
|
+
offset: "0%",
|
|
278
|
+
stopColor: n.color
|
|
279
|
+
}), /* @__PURE__ */ d("stop", {
|
|
280
|
+
offset: "100%",
|
|
281
|
+
stopColor: r.color
|
|
282
|
+
})]
|
|
283
|
+
}, t);
|
|
284
|
+
}) }),
|
|
285
|
+
/* @__PURE__ */ d("g", {
|
|
286
|
+
fill: "none",
|
|
287
|
+
children: Y.links.map((e, t) => {
|
|
288
|
+
let r = e.side === "left" ? e.target : e.source, i = Math.max(1, e.width ?? 1), a = e.side === "left" ? k : fe, o = a ? () => a(r.name) : void 0;
|
|
289
|
+
return /* @__PURE__ */ d("path", {
|
|
290
|
+
d: Se(e) ?? void 0,
|
|
291
|
+
stroke: `url(#${P}-grad-${t})`,
|
|
292
|
+
strokeWidth: L === e.sourceIndex ? i * 1.25 : i,
|
|
293
|
+
strokeOpacity: Ee(e.sourceIndex),
|
|
294
|
+
className: n.ribbon,
|
|
295
|
+
onMouseEnter: () => I(e.sourceIndex),
|
|
296
|
+
...Z(e.sourceIndex, o)
|
|
297
|
+
}, t);
|
|
298
|
+
})
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ d("g", { children: Y.nodes.map((e, t) => {
|
|
301
|
+
let r = (e.index ?? 1) - 1, i = e.kind === "leftEnd" ? Q(A) : e.kind === "rightEnd" ? Q(M) : Z(r, $(e.name));
|
|
302
|
+
return /* @__PURE__ */ d("rect", {
|
|
303
|
+
x: e.x0,
|
|
304
|
+
y: e.y0,
|
|
305
|
+
width: (e.x1 ?? 0) - (e.x0 ?? 0),
|
|
306
|
+
height: Math.max(1, (e.y1 ?? 0) - (e.y0 ?? 0)),
|
|
307
|
+
rx: 4,
|
|
308
|
+
fill: e.color,
|
|
309
|
+
fillOpacity: De(e),
|
|
310
|
+
stroke: N.palette.background.paper,
|
|
311
|
+
strokeWidth: 1,
|
|
312
|
+
className: n.node,
|
|
313
|
+
onMouseEnter: () => I(e.kind === "source" ? r : null),
|
|
314
|
+
...i
|
|
315
|
+
}, t);
|
|
316
|
+
}) }),
|
|
317
|
+
Y.nodes.map((e, t) => {
|
|
318
|
+
if (e.kind === "leftEnd") return /* @__PURE__ */ d(E, {
|
|
319
|
+
node: e,
|
|
320
|
+
total: be,
|
|
321
|
+
unitLabel: D,
|
|
322
|
+
align: "left",
|
|
323
|
+
onMouseEnter: () => I(null),
|
|
324
|
+
interactiveProps: Q(A)
|
|
325
|
+
}, `lab-${t}`);
|
|
326
|
+
if (e.kind === "rightEnd") return /* @__PURE__ */ d(E, {
|
|
327
|
+
node: e,
|
|
328
|
+
total: xe,
|
|
329
|
+
unitLabel: de,
|
|
330
|
+
align: "right",
|
|
331
|
+
onMouseEnter: () => I(null),
|
|
332
|
+
interactiveProps: Q(M)
|
|
333
|
+
}, `lab-${t}`);
|
|
334
|
+
let n = (e.index ?? 1) - 1, r = $(e.name);
|
|
335
|
+
return F ? /* @__PURE__ */ d(le, {
|
|
336
|
+
node: e,
|
|
337
|
+
leftValue: e.leftValue ?? 0,
|
|
338
|
+
rightValue: e.rightValue ?? 0,
|
|
339
|
+
unitLabel: D,
|
|
340
|
+
rightUnitLabel: de,
|
|
341
|
+
opacity: Oe(n),
|
|
342
|
+
onMouseEnter: () => I(n),
|
|
343
|
+
interactiveProps: Z(n, r)
|
|
344
|
+
}, `lab-${t}`) : /* @__PURE__ */ d(ce, {
|
|
345
|
+
node: e,
|
|
346
|
+
total: be,
|
|
347
|
+
opacity: Oe(n),
|
|
348
|
+
onMouseEnter: () => I(n),
|
|
349
|
+
interactiveProps: Z(n, r)
|
|
350
|
+
}, `lab-${t}`);
|
|
351
|
+
})
|
|
352
|
+
]
|
|
353
|
+
})]
|
|
49
354
|
});
|
|
50
355
|
};
|
|
51
356
|
//#endregion
|
|
52
|
-
export {
|
|
357
|
+
export { D as SynapseSankeyPlot, D as default };
|
|
53
358
|
|
|
54
359
|
//# sourceMappingURL=SynapseSankeyPlot.js.map
|