@gen3/frontend 0.12.63 → 0.12.64
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/dts/components/Content/Form.d.ts +5 -5
- package/dist/dts/components/Content/Form.d.ts.map +1 -1
- package/dist/dts/components/Content/Form.js +9 -1
- package/dist/dts/components/Content/Form.js.map +1 -1
- package/dist/dts/components/Content/FormContent.d.ts +16 -5
- package/dist/dts/components/Content/FormContent.d.ts.map +1 -1
- package/dist/dts/components/Content/FormContent.js +26 -4
- package/dist/dts/components/Content/FormContent.js.map +1 -1
- package/dist/dts/components/Content/formValidators.d.ts +7 -0
- package/dist/dts/components/Content/formValidators.d.ts.map +1 -0
- package/dist/dts/components/Content/formValidators.js +52 -0
- package/dist/dts/components/Content/formValidators.js.map +1 -0
- package/dist/dts/components/Providers/Gen3Provider.d.ts +7 -7
- package/dist/dts/features/Analysis/AnalysisCardCompact.stories.d.ts +22 -22
- package/dist/dts/features/CohortBuilder/ExplorerTable/ArrayCellRenderer.d.ts +1 -1
- package/dist/dts/features/CohortSimilarity/cohortSimilarityApi.d.ts +4 -4
- package/dist/dts/features/DiscoveryForms/StudyRegistration/FormContentViews.d.ts +16 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/FormContentViews.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/FormContentViews.js +18 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/FormContentViews.js.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/FormContentViews.stories.d.ts +30 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/FormContentViews.stories.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/FormContentViews.stories.js +367 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/FormContentViews.stories.js.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/StudyRegistrationAccessRequestOutcome.d.ts +7 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/StudyRegistrationAccessRequestOutcome.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/StudyRegistrationAccessRequestOutcome.js +14 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/StudyRegistrationAccessRequestOutcome.js.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/index.d.ts +8 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/index.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/index.js +11 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/index.js.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/types.d.ts +55 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/types.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/types.js +8 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/types.js.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/getClinicalTrialMetadata.d.ts +2 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/getClinicalTrialMetadata.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/getClinicalTrialMetadata.js +17 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/getClinicalTrialMetadata.js.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/preprocessStudyRegistrationMetadata.d.ts +10 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/preprocessStudyRegistrationMetadata.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/preprocessStudyRegistrationMetadata.js +77 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/preprocessStudyRegistrationMetadata.js.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/useStudyRegistration.d.ts +12 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/useStudyRegistration.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/useStudyRegistration.js +160 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/useStudyRegistration/useStudyRegistration.js.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/userCanRegisterStudy.d.ts +6 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/userCanRegisterStudy.d.ts.map +1 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/userCanRegisterStudy.js +10 -0
- package/dist/dts/features/DiscoveryForms/StudyRegistration/userCanRegisterStudy.js.map +1 -0
- package/dist/dts/features/Navigation/FixedNavPageLayout.js +1 -1
- package/dist/dts/features/Navigation/FixedNavPageLayout.js.map +1 -1
- package/dist/dts/features/Study/StudyDetails/StudyDetailsHeaderButtons.d.ts.map +1 -1
- package/dist/dts/features/Study/StudyDetails/StudyDetailsHeaderButtons.js +26 -8
- package/dist/dts/features/Study/StudyDetails/StudyDetailsHeaderButtons.js.map +1 -1
- package/dist/dts/pages/StudyForms/StudyRegistration/data.d.ts +4 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/data.d.ts.map +1 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/data.js +32 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/data.js.map +1 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/index.d.ts +10 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/index.d.ts.map +1 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/index.js +12 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/index.js.map +1 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/types.d.ts +28 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/types.d.ts.map +1 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/types.js +2 -0
- package/dist/dts/pages/StudyForms/StudyRegistration/types.js.map +1 -0
- package/dist/index/cjs/QueryPanel-DNGXxrpC.js +43 -0
- package/dist/index/cjs/QueryPanel-DNGXxrpC.js.map +1 -0
- package/dist/index/cjs/index-7sUtTikC.js +42117 -0
- package/dist/index/cjs/index-7sUtTikC.js.map +1 -0
- package/dist/index/cjs/index.js +1 -1
- package/dist/index/esm/QueryPanel-C3JVntIb.js +37 -0
- package/dist/index/esm/QueryPanel-C3JVntIb.js.map +1 -0
- package/dist/index/esm/index-B_0ks9Pi.js +41830 -0
- package/dist/index/esm/index-B_0ks9Pi.js.map +1 -0
- package/dist/index/esm/index.js +1 -1
- package/dist/index.d.ts +22 -12
- package/dist/pages/cjs/CohortBuilder-DircXqXL.js +576 -0
- package/dist/pages/cjs/CohortBuilder-DircXqXL.js.map +1 -0
- package/dist/pages/cjs/QueryPanel-qYWbo2Cb.js +43 -0
- package/dist/pages/cjs/QueryPanel-qYWbo2Cb.js.map +1 -0
- package/dist/pages/cjs/index-BQzYPjdE.js +32499 -0
- package/dist/pages/cjs/index-BQzYPjdE.js.map +1 -0
- package/dist/pages/cjs/index.js +1 -1
- package/dist/pages/esm/CohortBuilder-CI9PAFLd.js +573 -0
- package/dist/pages/esm/CohortBuilder-CI9PAFLd.js.map +1 -0
- package/dist/pages/esm/QueryPanel-BEqldpr5.js +37 -0
- package/dist/pages/esm/QueryPanel-BEqldpr5.js.map +1 -0
- package/dist/pages/esm/index-BoZwM5wd.js +32389 -0
- package/dist/pages/esm/index-BoZwM5wd.js.map +1 -0
- package/dist/pages/esm/index.js +1 -1
- package/dist/pages.d.ts +15 -5
- package/package.json +2 -2
package/dist/pages/cjs/index.js
CHANGED
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, useMemo, useCallback } from 'react';
|
|
3
|
+
import { useDeepCompareMemo, useDeepCompareCallback, useDeepCompareEffect } from 'use-deep-compare';
|
|
4
|
+
import { Tabs } from '@mantine/core';
|
|
5
|
+
import { partial } from 'lodash';
|
|
6
|
+
import { useLazyGetMultipleSowerJobStatusQuery, Accessibility, useCoreSelector, selectSharedFilters, useCoreDispatch, selectIndexFilters, selectCurrentCohortId, selectAllCohortFiltersCollapsed, clearCohortFilters, useGetAggsQuery, isIntersection, extractEnumFilterValue, useGetCountsQuery, useSubmitSowerJobMutation, toggleCohortBuilderAllFilters, setSharedFilters } from '@gen3/core';
|
|
7
|
+
import { g as getAllFieldsFromFilterConfigs, r as removeIntersectionFromEnum, p as processBucketData, e as extractRangeValues, a as processRangeData, u as useFieldNameToLabel, b as useToggleExpandFilter, c as useFilterExpandedState, d as useClearFilters, f as useGetFacetFilters, h as useUpdateFilters, i as useSetCohortFilterCombineState, j as useCohortFilterCombineState, k as classifyFacets, E as ErrorCard, Q as QueryExpression, D as DropdownPanel, l as DownloadsPanel, C as CountsValue, t as toDisplayName, m as CollapsableCharts, n as Charts, o as ExplorerTable, q as CohortManager } from './index-BoZwM5wd.js';
|
|
8
|
+
import 'echarts';
|
|
9
|
+
import { useMediaQuery } from '@mantine/hooks';
|
|
10
|
+
import 'victory';
|
|
11
|
+
import 'react-icons/bs';
|
|
12
|
+
import 'react-icons/io';
|
|
13
|
+
import '@mantine/form';
|
|
14
|
+
import 'react-icons/md';
|
|
15
|
+
import 'react-icons/ri';
|
|
16
|
+
import 'react-icons/fa';
|
|
17
|
+
import 'react-icons/pi';
|
|
18
|
+
import '@iconify-icon/react';
|
|
19
|
+
import '@mantine/modals';
|
|
20
|
+
import 'tailwind-merge';
|
|
21
|
+
import 'next/navigation';
|
|
22
|
+
import 'next/image';
|
|
23
|
+
import 'next/router';
|
|
24
|
+
import 'next/link';
|
|
25
|
+
import 'swr';
|
|
26
|
+
import 'cookies-next';
|
|
27
|
+
import 'jose';
|
|
28
|
+
import '@gen3/core/server';
|
|
29
|
+
import 'cookie';
|
|
30
|
+
import '@mantine/notifications';
|
|
31
|
+
import 'react-markdown';
|
|
32
|
+
import 'react-icons/ai';
|
|
33
|
+
import 'next/head';
|
|
34
|
+
import 'remark-gfm';
|
|
35
|
+
import 'rehype-sanitize';
|
|
36
|
+
import 'fs';
|
|
37
|
+
import 'path';
|
|
38
|
+
import 'tailwind-styled-components';
|
|
39
|
+
import 'file-saver';
|
|
40
|
+
import '@tanstack/react-table';
|
|
41
|
+
import 'mantine-react-table-open';
|
|
42
|
+
import 'react-icons/ti';
|
|
43
|
+
import 'react-icons/fi';
|
|
44
|
+
import '@theothergothamdev/pluralize-ts';
|
|
45
|
+
import 'jsonpath-plus';
|
|
46
|
+
import 'redux-persist/integration/react';
|
|
47
|
+
import 'redux-persist';
|
|
48
|
+
import 'redux';
|
|
49
|
+
import '@reduxjs/toolkit';
|
|
50
|
+
import 'redux-persist/lib/storage/createWebStorage';
|
|
51
|
+
import 'filesize';
|
|
52
|
+
import 'react-icons/lu';
|
|
53
|
+
import 'react-dom';
|
|
54
|
+
import 'react-minisearch';
|
|
55
|
+
import 'minisearch';
|
|
56
|
+
import 'lodash/uniq';
|
|
57
|
+
import 'lodash/sum';
|
|
58
|
+
import 'react-icons/fa6';
|
|
59
|
+
import '@dnd-kit/core';
|
|
60
|
+
import '@dnd-kit/sortable';
|
|
61
|
+
import '@dnd-kit/utilities';
|
|
62
|
+
import '@dnd-kit/modifiers';
|
|
63
|
+
import 'universal-cookie';
|
|
64
|
+
import 'next/dist/client/router';
|
|
65
|
+
import 'react-cookie';
|
|
66
|
+
import 'default-composer';
|
|
67
|
+
import 'next/dynamic';
|
|
68
|
+
import 'yaml';
|
|
69
|
+
import '@hello-pangea/dnd';
|
|
70
|
+
import 'tailwindcss/plugin';
|
|
71
|
+
import 'tailwindcss/colors';
|
|
72
|
+
import 'postcss-selector-parser';
|
|
73
|
+
import '@tabler/icons-react';
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Hook that sets up an event bus for components to subscribe to and fire off events
|
|
77
|
+
* when an active Sower job is completed.
|
|
78
|
+
*/ const useSowerJobEventBus = ()=>{
|
|
79
|
+
const [listeners, setListeners] = useState({});
|
|
80
|
+
const [pollers, setPollers] = useState(new Set());
|
|
81
|
+
const [trigger, statusResult] = useLazyGetMultipleSowerJobStatusQuery({
|
|
82
|
+
pollingInterval: 10000,
|
|
83
|
+
skipPollingIfUnfocused: true
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Function for component to subscribe to sower job updates
|
|
87
|
+
* @param listenerKey unique key for component
|
|
88
|
+
* @param newPollers list of jobs to poll the status of
|
|
89
|
+
* @param callback function to call when a job completes
|
|
90
|
+
*/ const on = (listenerKey, newPollers, callback)=>{
|
|
91
|
+
setListeners({
|
|
92
|
+
...listeners,
|
|
93
|
+
[listenerKey]: callback
|
|
94
|
+
});
|
|
95
|
+
setPollers(new Set([
|
|
96
|
+
...pollers,
|
|
97
|
+
...newPollers
|
|
98
|
+
]));
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Function for component to unsubscribe to updates
|
|
102
|
+
* @param listenerKey unique key for component
|
|
103
|
+
*/ const off = (listenerKey)=>{
|
|
104
|
+
setListeners(Object.fromEntries(Object.entries(listeners).filter(([key])=>key === listenerKey)));
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Function to update the jobs that are polling
|
|
108
|
+
* @param job new job to add to pollers
|
|
109
|
+
*/ const update = (job)=>{
|
|
110
|
+
setPollers(new Set([
|
|
111
|
+
...pollers,
|
|
112
|
+
job
|
|
113
|
+
]));
|
|
114
|
+
};
|
|
115
|
+
useEffect(()=>{
|
|
116
|
+
void trigger(Array.from(pollers));
|
|
117
|
+
}, [
|
|
118
|
+
pollers
|
|
119
|
+
]);
|
|
120
|
+
useEffect(()=>{
|
|
121
|
+
if (statusResult.isSuccess) {
|
|
122
|
+
Object.entries(statusResult.currentData || {}).map(([job, response])=>{
|
|
123
|
+
if (response.status === 'Completed') {
|
|
124
|
+
Object.values(listeners).forEach((callback)=>callback(job));
|
|
125
|
+
// Remove job from pollers after it has completed
|
|
126
|
+
setPollers(new Set([
|
|
127
|
+
...pollers
|
|
128
|
+
].filter((poller)=>poller !== job)));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}, [
|
|
133
|
+
statusResult
|
|
134
|
+
]);
|
|
135
|
+
return {
|
|
136
|
+
on,
|
|
137
|
+
off,
|
|
138
|
+
update
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const EmptyData = {};
|
|
143
|
+
/**
|
|
144
|
+
* CohortPanel is a React component that provides an interactive interface for cohort exploration and filtering.
|
|
145
|
+
* It integrates with data services and facilitates visualization, filtering, and analysis tasks.
|
|
146
|
+
*
|
|
147
|
+
* @param {Object} props The properties required to configure the CohortPanel component.
|
|
148
|
+
* @param {Object} props.guppyConfig Configuration object for Guppy, including field mappings and data type information.
|
|
149
|
+
* @param {Object} props.filters Configuration for filter tabs, including filter fields and layout.
|
|
150
|
+
* @param {Object} [props.charts={}] Optional set of chart configuration objects for rendering summaries.
|
|
151
|
+
* @param {Object} [props.chartsSection] Optional configuration for an additional section of charts.
|
|
152
|
+
* @param {Object} props.table Reference to the table configuration or component for displaying data.
|
|
153
|
+
* @param {string} props.tabTitle Title for the filter tab section.
|
|
154
|
+
* @param {Object[]|undefined} props.dropdowns Dropdown menu configuration, allowing for additional filter options or actions.
|
|
155
|
+
* @param {Object[]|undefined} props.buttons List of button configurations for actions such as downloads.
|
|
156
|
+
* @param {boolean} props.loginForDownload Determines whether login is required to enable download functionality.
|
|
157
|
+
* @param {boolean} [props.showAccessLevel=false] Indicates if the user access level should be displayed on the panel.
|
|
158
|
+
*
|
|
159
|
+
* @returns {JSX.Element} Returns a JSX element rendering the CohortPanel. This includes filter options,
|
|
160
|
+
* summary charts, cohort manager, and data display components.
|
|
161
|
+
*/ const CohortPanel = ({ guppyConfig, filters, charts = {}, chartsSection = undefined, table, tabTitle, dropdowns, buttons, loginForDownload, showAccessLevel = false })=>{
|
|
162
|
+
const isSm = useMediaQuery('(min-width: 639px)');
|
|
163
|
+
const isMd = useMediaQuery('(min-width: 1373px)');
|
|
164
|
+
const isXl = useMediaQuery('(min-width: 1600px)');
|
|
165
|
+
const [accessLevel, setAccessLevel] = useState(Accessibility.ALL);
|
|
166
|
+
const sharedFiltersMap = useCoreSelector((state)=>selectSharedFilters(state));
|
|
167
|
+
const defaultDropdowns = useMemo(()=>dropdowns ?? {}, [
|
|
168
|
+
dropdowns
|
|
169
|
+
]);
|
|
170
|
+
const defaultButtons = useMemo(()=>buttons ?? [], [
|
|
171
|
+
buttons
|
|
172
|
+
]);
|
|
173
|
+
const numCols = useMemo(()=>{
|
|
174
|
+
if (isSm) return 1;
|
|
175
|
+
if (isMd) return 2;
|
|
176
|
+
if (isXl) return 4;
|
|
177
|
+
return 3;
|
|
178
|
+
}, [
|
|
179
|
+
isSm,
|
|
180
|
+
isMd,
|
|
181
|
+
isXl
|
|
182
|
+
]);
|
|
183
|
+
const index = guppyConfig.dataType;
|
|
184
|
+
const indexPrefix = guppyConfig?.indexPrefix ?? '';
|
|
185
|
+
const fields = useMemo(()=>getAllFieldsFromFilterConfigs(filters?.tabs ?? []), [
|
|
186
|
+
filters?.tabs
|
|
187
|
+
]);
|
|
188
|
+
const coreDispatch = useCoreDispatch();
|
|
189
|
+
const [facetDefinitions, setFacetDefinitions] = useState({});
|
|
190
|
+
const [summaryCharts, setSummaryCharts] = useState({});
|
|
191
|
+
const cohortFilters = useCoreSelector((state)=>selectIndexFilters(state, index));
|
|
192
|
+
const cohortId = useCoreSelector((state)=>selectCurrentCohortId(state));
|
|
193
|
+
const allFiltersCollapsed = useCoreSelector((state)=>selectAllCohortFiltersCollapsed(state, index));
|
|
194
|
+
const toggleAllFiltersExpanded = (expand)=>{
|
|
195
|
+
coreDispatch(toggleCohortBuilderAllFilters({
|
|
196
|
+
expand,
|
|
197
|
+
index
|
|
198
|
+
}));
|
|
199
|
+
};
|
|
200
|
+
const clearAllFilters = useCallback(()=>{
|
|
201
|
+
coreDispatch(clearCohortFilters({
|
|
202
|
+
index
|
|
203
|
+
}));
|
|
204
|
+
}, [
|
|
205
|
+
coreDispatch,
|
|
206
|
+
index
|
|
207
|
+
]);
|
|
208
|
+
const { data, isSuccess, isError: isAggsQueryError } = useGetAggsQuery({
|
|
209
|
+
type: index,
|
|
210
|
+
fields: fields,
|
|
211
|
+
filters: cohortFilters,
|
|
212
|
+
accessibility: accessLevel,
|
|
213
|
+
queryId: cohortId,
|
|
214
|
+
indexPrefix: indexPrefix
|
|
215
|
+
});
|
|
216
|
+
const chartKeys = useDeepCompareMemo(()=>[
|
|
217
|
+
...Object.keys(chartsSection?.charts ?? {}),
|
|
218
|
+
...Object.keys(charts)
|
|
219
|
+
], [
|
|
220
|
+
chartsSection?.charts,
|
|
221
|
+
charts
|
|
222
|
+
]);
|
|
223
|
+
const { data: chartData, isSuccess: isChartSuccess, isFetching: isChartFetching, isError: isChartError } = useGetAggsQuery({
|
|
224
|
+
type: index,
|
|
225
|
+
fields: chartKeys,
|
|
226
|
+
filters: cohortFilters,
|
|
227
|
+
accessibility: accessLevel,
|
|
228
|
+
filterSelf: true,
|
|
229
|
+
queryId: cohortId,
|
|
230
|
+
indexPrefix: indexPrefix
|
|
231
|
+
}, {
|
|
232
|
+
skip: chartKeys.length === 0
|
|
233
|
+
});
|
|
234
|
+
const cleanChartData = useDeepCompareMemo(()=>{
|
|
235
|
+
if (isChartSuccess && chartData) {
|
|
236
|
+
const cleanedData = {};
|
|
237
|
+
const totalCount = chartData._totalCount[0]?.count;
|
|
238
|
+
Object.keys(summaryCharts).forEach((key)=>{
|
|
239
|
+
if (!(key in chartData)) {
|
|
240
|
+
return;
|
|
241
|
+
} // handle missing key in data
|
|
242
|
+
// remove empty keys
|
|
243
|
+
cleanedData[key] = chartData[key].filter((x)=>typeof x.key !== 'string' ? true : x.key !== '');
|
|
244
|
+
const facetDef = facetDefinitions?.[key];
|
|
245
|
+
if (facetDef?.excludeValues) {
|
|
246
|
+
cleanedData[key] = cleanedData[key].filter((x)=>typeof x.key !== 'string' ? true : facetDef?.excludeValues?.includes(String(x.key)) === false);
|
|
247
|
+
}
|
|
248
|
+
if (cleanedData[key].length === 0 && totalCount) {
|
|
249
|
+
// if no keys adds back no data
|
|
250
|
+
cleanedData[key] = [
|
|
251
|
+
{
|
|
252
|
+
key: 'no data',
|
|
253
|
+
count: totalCount
|
|
254
|
+
}
|
|
255
|
+
];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
return cleanedData;
|
|
259
|
+
}
|
|
260
|
+
return chartData;
|
|
261
|
+
}, [
|
|
262
|
+
chartData,
|
|
263
|
+
isChartSuccess,
|
|
264
|
+
summaryCharts
|
|
265
|
+
]);
|
|
266
|
+
const getEnumFacetData = useDeepCompareCallback((field)=>{
|
|
267
|
+
let filters = undefined;
|
|
268
|
+
let combineMode = 'or';
|
|
269
|
+
if (field in cohortFilters.root) {
|
|
270
|
+
if (isIntersection(cohortFilters.root[field])) {
|
|
271
|
+
const intersectionFilters = removeIntersectionFromEnum(cohortFilters.root[field]);
|
|
272
|
+
if (intersectionFilters) {
|
|
273
|
+
filters = extractEnumFilterValue(intersectionFilters);
|
|
274
|
+
combineMode = 'and';
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
filters = extractEnumFilterValue(cohortFilters.root[field]);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
data: processBucketData(data?.[field]),
|
|
282
|
+
enumFilters: filters,
|
|
283
|
+
combineMode: combineMode,
|
|
284
|
+
isSuccess: isSuccess
|
|
285
|
+
};
|
|
286
|
+
}, [
|
|
287
|
+
cohortFilters.root,
|
|
288
|
+
data,
|
|
289
|
+
isSuccess
|
|
290
|
+
]);
|
|
291
|
+
const getRangeFacetData = useDeepCompareCallback((field)=>{
|
|
292
|
+
return {
|
|
293
|
+
data: processRangeData(data?.[field]),
|
|
294
|
+
filters: extractRangeValues(cohortFilters.root[field]),
|
|
295
|
+
isSuccess: isSuccess
|
|
296
|
+
};
|
|
297
|
+
}, [
|
|
298
|
+
data,
|
|
299
|
+
cohortFilters.root,
|
|
300
|
+
isSuccess
|
|
301
|
+
]);
|
|
302
|
+
// Set up the hooks for the facet components to use based on the required index
|
|
303
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
304
|
+
// @ts-ignore
|
|
305
|
+
const facetDataHooks = useDeepCompareMemo(()=>{
|
|
306
|
+
return {
|
|
307
|
+
// TODO: see if there a better way to do this
|
|
308
|
+
enum: {
|
|
309
|
+
useGetFacetData: getEnumFacetData,
|
|
310
|
+
useUpdateFacetFilters: partial(useUpdateFilters, index),
|
|
311
|
+
useGetFacetFilters: partial(useGetFacetFilters, index),
|
|
312
|
+
useClearFilter: partial(useClearFilters, index),
|
|
313
|
+
useFilterExpanded: partial(useFilterExpandedState, index),
|
|
314
|
+
useToggleExpandFilter: partial(useToggleExpandFilter, index),
|
|
315
|
+
useGetCombineMode: partial(useCohortFilterCombineState, index),
|
|
316
|
+
useSetCombineMode: partial(useSetCohortFilterCombineState, index),
|
|
317
|
+
useFieldNameToLabel: useFieldNameToLabel,
|
|
318
|
+
useTotalCounts: undefined
|
|
319
|
+
},
|
|
320
|
+
exact: {
|
|
321
|
+
useGetFacetData: getEnumFacetData,
|
|
322
|
+
useUpdateFacetFilters: partial(useUpdateFilters, index),
|
|
323
|
+
useGetFacetFilters: partial(useGetFacetFilters, index),
|
|
324
|
+
useClearFilter: partial(useClearFilters, index),
|
|
325
|
+
useFilterExpanded: partial(useFilterExpandedState, index),
|
|
326
|
+
useToggleExpandFilter: partial(useToggleExpandFilter, index),
|
|
327
|
+
useFieldNameToLabel: useFieldNameToLabel,
|
|
328
|
+
useTotalCounts: undefined
|
|
329
|
+
},
|
|
330
|
+
multiselect: {
|
|
331
|
+
useGetFacetData: getEnumFacetData,
|
|
332
|
+
useUpdateFacetFilters: partial(useUpdateFilters, index),
|
|
333
|
+
useGetFacetFilters: partial(useGetFacetFilters, index),
|
|
334
|
+
useClearFilter: partial(useClearFilters, index),
|
|
335
|
+
useFilterExpanded: partial(useFilterExpandedState, index),
|
|
336
|
+
useToggleExpandFilter: partial(useToggleExpandFilter, index),
|
|
337
|
+
useFieldNameToLabel: useFieldNameToLabel,
|
|
338
|
+
useTotalCounts: undefined
|
|
339
|
+
},
|
|
340
|
+
range: {
|
|
341
|
+
useGetFacetData: getRangeFacetData,
|
|
342
|
+
useUpdateFacetFilters: partial(useUpdateFilters, index),
|
|
343
|
+
useGetFacetFilters: partial(useGetFacetFilters, index),
|
|
344
|
+
useClearFilter: partial(useClearFilters, index),
|
|
345
|
+
useFilterExpanded: partial(useFilterExpandedState, index),
|
|
346
|
+
useToggleExpandFilter: partial(useToggleExpandFilter, index),
|
|
347
|
+
useFieldNameToLabel: useFieldNameToLabel,
|
|
348
|
+
useTotalCounts: undefined
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}, [
|
|
352
|
+
getEnumFacetData,
|
|
353
|
+
getRangeFacetData,
|
|
354
|
+
index
|
|
355
|
+
]);
|
|
356
|
+
// Set the facet definitions based on the data only the first time the data is loaded
|
|
357
|
+
useDeepCompareEffect(()=>{
|
|
358
|
+
if (isSuccess && Object.keys(facetDefinitions).length === 0) {
|
|
359
|
+
const configFacetDefs = filters?.tabs.reduce((acc, tab)=>{
|
|
360
|
+
return {
|
|
361
|
+
...tab.fieldsConfig,
|
|
362
|
+
...acc
|
|
363
|
+
};
|
|
364
|
+
}, {});
|
|
365
|
+
const facetDefs = classifyFacets(data, index, guppyConfig?.fieldMapping ?? [], configFacetDefs ?? {}, sharedFiltersMap);
|
|
366
|
+
setFacetDefinitions(facetDefs);
|
|
367
|
+
// setup summary charts since nested fields can be listed by the split field name
|
|
368
|
+
const chartDefinitions = chartsSection?.charts ?? charts;
|
|
369
|
+
const summaryCharts = Object.keys(chartDefinitions).reduce((acc, field)=>{
|
|
370
|
+
let chartField = field;
|
|
371
|
+
if (facetDefs?.[field] === undefined) {
|
|
372
|
+
const res = Object.values(facetDefs).filter((def)=>{
|
|
373
|
+
return def.dataField === field;
|
|
374
|
+
});
|
|
375
|
+
if (res.length > 0) {
|
|
376
|
+
chartField = res[0].field;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
...acc,
|
|
381
|
+
[chartField]: chartDefinitions[field]
|
|
382
|
+
};
|
|
383
|
+
}, {});
|
|
384
|
+
setSummaryCharts(summaryCharts);
|
|
385
|
+
}
|
|
386
|
+
}, [
|
|
387
|
+
isSuccess,
|
|
388
|
+
data,
|
|
389
|
+
facetDefinitions,
|
|
390
|
+
index,
|
|
391
|
+
guppyConfig.fieldMapping,
|
|
392
|
+
charts,
|
|
393
|
+
chartsSection
|
|
394
|
+
]);
|
|
395
|
+
const { data: counts, isFetching: isCountsFetching, isError: isCountsError } = useGetCountsQuery({
|
|
396
|
+
type: index,
|
|
397
|
+
filters: cohortFilters,
|
|
398
|
+
accessibility: accessLevel,
|
|
399
|
+
queryId: cohortId
|
|
400
|
+
});
|
|
401
|
+
// oxlint-disable-next-line no-unused-vars
|
|
402
|
+
const [submitJob, result] = useSubmitSowerJobMutation();
|
|
403
|
+
const { update } = useSowerJobEventBus();
|
|
404
|
+
useEffect(()=>{
|
|
405
|
+
if (result?.data) {
|
|
406
|
+
update(result.data?.uid);
|
|
407
|
+
}
|
|
408
|
+
}, [
|
|
409
|
+
result
|
|
410
|
+
]);
|
|
411
|
+
if (isCountsError || isAggsQueryError) {
|
|
412
|
+
return /*#__PURE__*/ jsx(ErrorCard, {
|
|
413
|
+
message: "Unable to fetch data from server"
|
|
414
|
+
}); // TODO: replace with configurable message
|
|
415
|
+
}
|
|
416
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
417
|
+
className: "flex flex-col mt-3 relative px-4 bg-base-lightest w-full",
|
|
418
|
+
children: [
|
|
419
|
+
/*#__PURE__*/ jsx(QueryExpression, {
|
|
420
|
+
index: index
|
|
421
|
+
}),
|
|
422
|
+
/*#__PURE__*/ jsxs("div", {
|
|
423
|
+
className: "flex w-full",
|
|
424
|
+
children: [
|
|
425
|
+
/*#__PURE__*/ jsx("div", {
|
|
426
|
+
id: "cohort-builder-filters",
|
|
427
|
+
className: "flex-shrink-0 md:w-1/4 lg:w-1/5",
|
|
428
|
+
children: filters?.tabs && /*#__PURE__*/ jsx(DropdownPanel, {
|
|
429
|
+
filters: filters,
|
|
430
|
+
tabTitle: tabTitle,
|
|
431
|
+
facetDefinitions: facetDefinitions,
|
|
432
|
+
facetDataHooks: facetDataHooks,
|
|
433
|
+
onAccessChange: setAccessLevel,
|
|
434
|
+
accessLevel: accessLevel,
|
|
435
|
+
showAccessLevel: showAccessLevel,
|
|
436
|
+
allFiltersCollapsed: allFiltersCollapsed,
|
|
437
|
+
toggleAllFiltersExpanded: toggleAllFiltersExpanded,
|
|
438
|
+
clearAllFilters: clearAllFilters
|
|
439
|
+
})
|
|
440
|
+
}),
|
|
441
|
+
/*#__PURE__*/ jsxs("div", {
|
|
442
|
+
id: "cohort-builder-content",
|
|
443
|
+
className: "flex flex-col md:w-3/4 lg:w-4/5 pl-4",
|
|
444
|
+
children: [
|
|
445
|
+
/*#__PURE__*/ jsxs("div", {
|
|
446
|
+
className: "flex justify-between mb-2 ml-2",
|
|
447
|
+
children: [
|
|
448
|
+
/*#__PURE__*/ jsx(DownloadsPanel, {
|
|
449
|
+
dropdowns: defaultDropdowns,
|
|
450
|
+
buttons: defaultButtons,
|
|
451
|
+
loginForDownload: loginForDownload,
|
|
452
|
+
index: index,
|
|
453
|
+
totalCount: counts ?? 0,
|
|
454
|
+
fields: table?.fields ?? [],
|
|
455
|
+
filter: cohortFilters
|
|
456
|
+
}),
|
|
457
|
+
/*#__PURE__*/ jsx(CountsValue, {
|
|
458
|
+
label: guppyConfig?.nodeCountTitle || toDisplayName(index),
|
|
459
|
+
counts: counts,
|
|
460
|
+
isFetching: isCountsFetching,
|
|
461
|
+
isError: isCountsError
|
|
462
|
+
})
|
|
463
|
+
]
|
|
464
|
+
}),
|
|
465
|
+
chartsSection?.enabled ? /*#__PURE__*/ jsx(CollapsableCharts, {
|
|
466
|
+
config: {
|
|
467
|
+
...chartsSection,
|
|
468
|
+
charts: summaryCharts
|
|
469
|
+
},
|
|
470
|
+
data: cleanChartData ?? EmptyData,
|
|
471
|
+
isSuccess: isChartSuccess,
|
|
472
|
+
isFetching: isChartFetching,
|
|
473
|
+
isError: isChartError
|
|
474
|
+
}) : /*#__PURE__*/ jsx(Charts, {
|
|
475
|
+
charts: summaryCharts,
|
|
476
|
+
data: cleanChartData ?? EmptyData,
|
|
477
|
+
counts: counts,
|
|
478
|
+
isSuccess: isChartSuccess,
|
|
479
|
+
isError: isChartError,
|
|
480
|
+
numCols: numCols
|
|
481
|
+
}),
|
|
482
|
+
table?.enabled && /*#__PURE__*/ jsx(Fragment, {
|
|
483
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
484
|
+
className: "mt-2 flex flex-col",
|
|
485
|
+
children: /*#__PURE__*/ jsx(ExplorerTable, {
|
|
486
|
+
index: index,
|
|
487
|
+
tableConfig: table,
|
|
488
|
+
accessibility: accessLevel
|
|
489
|
+
})
|
|
490
|
+
})
|
|
491
|
+
})
|
|
492
|
+
]
|
|
493
|
+
})
|
|
494
|
+
]
|
|
495
|
+
})
|
|
496
|
+
]
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
const TabsLayoutToComponentProp = (tabsLayout)=>{
|
|
501
|
+
if (!tabsLayout) {
|
|
502
|
+
return 'flex-start';
|
|
503
|
+
}
|
|
504
|
+
switch(tabsLayout){
|
|
505
|
+
case 'left':
|
|
506
|
+
{
|
|
507
|
+
return 'flex-start';
|
|
508
|
+
}
|
|
509
|
+
case 'right':
|
|
510
|
+
{
|
|
511
|
+
return 'flex-end';
|
|
512
|
+
}
|
|
513
|
+
case 'center':
|
|
514
|
+
{
|
|
515
|
+
return 'center';
|
|
516
|
+
}
|
|
517
|
+
default:
|
|
518
|
+
{
|
|
519
|
+
return 'flex-start';
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
const useGetCurrentCohort = ()=>{
|
|
525
|
+
return useCoreSelector((state)=>selectCurrentCohortId(state));
|
|
526
|
+
};
|
|
527
|
+
const CohortBuilder = ({ explorerConfig, sharedFiltersMap, tabsLayout = 'left', enableCohortManager = true, activeTab })=>{
|
|
528
|
+
const dispatch = useCoreDispatch();
|
|
529
|
+
dispatch(setSharedFilters(sharedFiltersMap ?? {}));
|
|
530
|
+
const configuration = useDeepCompareMemo(()=>explorerConfig, [
|
|
531
|
+
explorerConfig
|
|
532
|
+
]);
|
|
533
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
534
|
+
className: "flex flex-col w-full mt-2",
|
|
535
|
+
children: [
|
|
536
|
+
enableCohortManager ? /*#__PURE__*/ jsx(CohortManager, {}) : null,
|
|
537
|
+
/*#__PURE__*/ jsxs(Tabs, {
|
|
538
|
+
color: "primary.5",
|
|
539
|
+
variant: explorerConfig[0]?.tabType,
|
|
540
|
+
keepMounted: true,
|
|
541
|
+
defaultValue: activeTab ?? explorerConfig[0].tabTitle,
|
|
542
|
+
children: [
|
|
543
|
+
/*#__PURE__*/ jsx(Tabs.List, {
|
|
544
|
+
className: "w-full",
|
|
545
|
+
justify: TabsLayoutToComponentProp(tabsLayout),
|
|
546
|
+
children: configuration.map((panelConfig)=>/*#__PURE__*/ jsx(Tabs.Tab, {
|
|
547
|
+
value: panelConfig.tabTitle,
|
|
548
|
+
children: panelConfig.tabTitle
|
|
549
|
+
}, `${panelConfig.tabTitle}-tabList`))
|
|
550
|
+
}),
|
|
551
|
+
configuration.map((panelConfig)=>/*#__PURE__*/ jsx(Tabs.Panel, {
|
|
552
|
+
value: panelConfig.tabTitle,
|
|
553
|
+
children: /*#__PURE__*/ jsx(CohortPanel, {
|
|
554
|
+
guppyConfig: panelConfig.guppyConfig,
|
|
555
|
+
chartsSection: panelConfig?.chartsSection,
|
|
556
|
+
charts: panelConfig?.charts,
|
|
557
|
+
filters: panelConfig.filters,
|
|
558
|
+
tabTitle: panelConfig.tabTitle,
|
|
559
|
+
table: panelConfig.table,
|
|
560
|
+
dropdowns: panelConfig.dropdowns,
|
|
561
|
+
buttons: panelConfig.buttons,
|
|
562
|
+
loginForDownload: panelConfig.loginForDownload,
|
|
563
|
+
sharedFiltersMap: panelConfig.sharedFiltersMap
|
|
564
|
+
}, `${panelConfig.tabTitle}-CohortPanel`)
|
|
565
|
+
}, `${panelConfig.tabTitle}-tabPanel`))
|
|
566
|
+
]
|
|
567
|
+
})
|
|
568
|
+
]
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
export { CohortBuilder as default, useGetCurrentCohort };
|
|
573
|
+
//# sourceMappingURL=CohortBuilder-CI9PAFLd.js.map
|