@gen3/frontend 0.12.55 → 0.12.56

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