@gen3/frontend 0.12.45 → 0.12.46

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 (54) hide show
  1. package/dist/dts/features/Workspace/WorkspaceNotebook.d.ts +1 -1
  2. package/dist/dts/features/Workspace/WorkspaceNotebook.d.ts.map +1 -1
  3. package/dist/dts/features/Workspace/WorkspaceNotebook.js +69 -5
  4. package/dist/dts/features/Workspace/WorkspaceNotebook.js.map +1 -1
  5. package/dist/dts/index.d.ts +2 -1
  6. package/dist/dts/index.d.ts.map +1 -1
  7. package/dist/dts/index.js +2 -1
  8. package/dist/dts/index.js.map +1 -1
  9. package/dist/dts/lib/session/constants.d.ts +2 -0
  10. package/dist/dts/lib/session/constants.d.ts.map +1 -0
  11. package/dist/dts/lib/session/constants.js +2 -0
  12. package/dist/dts/lib/session/constants.js.map +1 -0
  13. package/dist/dts/lib/session/session.d.ts.map +1 -1
  14. package/dist/dts/lib/session/session.js +1 -1
  15. package/dist/dts/lib/session/session.js.map +1 -1
  16. package/dist/index/cjs/QueryPanel-C6_EtaDO.js +39 -0
  17. package/dist/index/cjs/QueryPanel-C6_EtaDO.js.map +1 -0
  18. package/dist/index/cjs/QueryPanel-Dpn_GGDU.js +39 -0
  19. package/dist/index/cjs/QueryPanel-Dpn_GGDU.js.map +1 -0
  20. package/dist/index/cjs/index-CSXtX5eA.js +38902 -0
  21. package/dist/index/cjs/index-CSXtX5eA.js.map +1 -0
  22. package/dist/index/cjs/index-rCd246Nh.js +38893 -0
  23. package/dist/index/cjs/index-rCd246Nh.js.map +1 -0
  24. package/dist/index/cjs/index.js +2 -1
  25. package/dist/index/cjs/index.js.map +1 -1
  26. package/dist/index/esm/QueryPanel-BFecvXaF.js +37 -0
  27. package/dist/index/esm/QueryPanel-BFecvXaF.js.map +1 -0
  28. package/dist/index/esm/QueryPanel-DZ_DkGW8.js +37 -0
  29. package/dist/index/esm/QueryPanel-DZ_DkGW8.js.map +1 -0
  30. package/dist/index/esm/index-C2wxUU0I.js +38645 -0
  31. package/dist/index/esm/index-C2wxUU0I.js.map +1 -0
  32. package/dist/index/esm/index-XWpB4JSs.js +38636 -0
  33. package/dist/index/esm/index-XWpB4JSs.js.map +1 -0
  34. package/dist/index/esm/index.js +1 -1
  35. package/dist/index.d.ts +3 -1
  36. package/dist/pages/cjs/CohortBuilder-DSb4NbaV.js +570 -0
  37. package/dist/pages/cjs/CohortBuilder-DSb4NbaV.js.map +1 -0
  38. package/dist/pages/cjs/CohortBuilder-DZfy_UsD.js +570 -0
  39. package/dist/pages/cjs/CohortBuilder-DZfy_UsD.js.map +1 -0
  40. package/dist/pages/cjs/index-BoO7NZz4.js +29027 -0
  41. package/dist/pages/cjs/index-BoO7NZz4.js.map +1 -0
  42. package/dist/pages/cjs/index-LxlqqT9v.js +29018 -0
  43. package/dist/pages/cjs/index-LxlqqT9v.js.map +1 -0
  44. package/dist/pages/cjs/index.js +1 -1
  45. package/dist/pages/esm/CohortBuilder-BtRdgox5.js +567 -0
  46. package/dist/pages/esm/CohortBuilder-BtRdgox5.js.map +1 -0
  47. package/dist/pages/esm/CohortBuilder-CRvBOJOa.js +567 -0
  48. package/dist/pages/esm/CohortBuilder-CRvBOJOa.js.map +1 -0
  49. package/dist/pages/esm/index-BM37HQIq.js +28942 -0
  50. package/dist/pages/esm/index-BM37HQIq.js.map +1 -0
  51. package/dist/pages/esm/index-CaxiVweb.js +28933 -0
  52. package/dist/pages/esm/index-CaxiVweb.js.map +1 -0
  53. package/dist/pages/esm/index.js +1 -1
  54. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CohortBuilder-DSb4NbaV.js","sources":["../../../src/utils/strings.ts","../../../src/features/Sower/useSowerJobEventBus.ts","../../../src/features/CohortBuilder/CohortPanel.tsx","../../../src/utils/layout.tsx","../../../src/features/CohortBuilder/CohortBuilder.tsx"],"sourcesContent":["import { capitalize } from 'lodash';\n\nexport const stripTrailingSlash = (str: string): string => {\n return str.endsWith('/') ? str.slice(0, -1) : str;\n};\n\nexport const SPECIAL_CASE_FIELDS = {\n icd_10_code: 'ICD-10 Code',\n};\n\nexport const toDisplayName = (field: string): string => {\n const parsed = field.split('.');\n const fieldName = parsed.at(-1);\n\n if (!fieldName) return 'NotSet';\n\n return fieldName\n .split('_')\n .map((w) => capitalize(w))\n .join(' ');\n};\n\nexport const removeMultipleSlashes = (str: string): string => {\n return str.replace(/\\/+/g, '/');\n};\n","import { useEffect, useState } from 'react';\nimport { useLazyGetMultipleSowerJobStatusQuery } from '@gen3/core';\n\n/**\n * Hook that sets up an event bus for components to subscribe to and fire off events\n * when an active Sower job is completed.\n */\nconst useSowerJobEventBus = () => {\n const [listeners, setListeners] = useState<Record<string, any>>({});\n const [pollers, setPollers] = useState<Set<string>>(new Set());\n const [trigger, statusResult] = useLazyGetMultipleSowerJobStatusQuery({\n pollingInterval: 10000,\n skipPollingIfUnfocused: true,\n });\n\n /**\n * Function for component to subscribe to sower job updates\n * @param listenerKey unique key for component\n * @param newPollers list of jobs to poll the status of\n * @param callback function to call when a job completes\n */\n\n const on = (\n listenerKey: string,\n newPollers: string[],\n callback: (uid: string) => void,\n ) => {\n setListeners({ ...listeners, [listenerKey]: callback });\n setPollers(new Set([...pollers, ...newPollers]));\n };\n\n /**\n * Function for component to unsubscribe to updates\n * @param listenerKey unique key for component\n */\n const off = (listenerKey: string) => {\n setListeners(\n Object.fromEntries(\n Object.entries(listeners).filter(([key]) => key === listenerKey),\n ),\n );\n };\n\n /**\n * Function to update the jobs that are polling\n * @param job new job to add to pollers\n */\n const update = (job: string) => {\n setPollers(new Set([...pollers, job]));\n };\n\n useEffect(() => {\n trigger(Array.from(pollers));\n }, [pollers]);\n\n useEffect(() => {\n if (statusResult.isSuccess) {\n Object.entries(statusResult.currentData || {}).map(([job, response]) => {\n if (response.status === 'Completed') {\n Object.values(listeners).forEach((callback) => callback(job));\n // Remove job from pollers after it has completed\n setPollers(new Set([...pollers].filter((poller) => poller !== job)));\n }\n });\n }\n }, [statusResult]);\n\n return { on, off, update };\n};\n\nexport default useSowerJobEventBus;\n","import React, { JSX, useCallback, useEffect, useMemo, useState } from 'react';\nimport { partial } from 'lodash';\nimport {\n Accessibility,\n AggregationsData,\n clearCohortFilters,\n CombineMode,\n CoreState,\n extractEnumFilterValue,\n FacetDefinition,\n FacetType,\n isIntersection,\n selectAllCohortFiltersCollapsed,\n selectCurrentCohortId,\n selectIndexFilters,\n selectSharedFilters,\n toggleCohortBuilderAllFilters,\n useCoreDispatch,\n useCoreSelector,\n useGetAggsQuery,\n useGetCountsQuery,\n useSubmitSowerJobMutation,\n} from '@gen3/core';\nimport { type CohortPanelConfiguration } from './types';\nimport { Charts, CollapsableCharts, type SummaryChart, } from '../../components/charts';\nimport { ErrorCard } from '../../components/MessageCards';\nimport { useMediaQuery } from '@mantine/hooks';\nimport {\n classifyFacets,\n EnumFacetDataHooks,\n extractRangeValues,\n FacetDataHooks,\n getAllFieldsFromFilterConfigs,\n processBucketData,\n processRangeData,\n removeIntersectionFromEnum,\n useGetFacetFilters,\n useUpdateFilters,\n} from '../../components/facets';\nimport { useClearFilters, useFieldNameToLabel, } from '../../components/facets/hooks';\nimport ExplorerTable from './ExplorerTable/ExplorerTable';\nimport CountsValue from '../../components/counts/CountsValue';\nimport DownloadsPanel from './DownloadsPanel';\nimport { useDeepCompareCallback, useDeepCompareEffect, useDeepCompareMemo, } from 'use-deep-compare';\nimport { toDisplayName } from '../../utils';\nimport {\n useCohortFilterCombineState,\n useFilterExpandedState,\n useSetCohortFilterCombineState,\n useToggleExpandFilter,\n} from './hooks';\nimport DropdownPanel from '../../components/facets/Panels/DropdownPanel';\nimport QueryExpression from './QueryExpression';\nimport useSowerJobEventBus from '../Sower/useSowerJobEventBus';\n\nconst EmptyData = {};\n\n/**\n * The main component that houses the charts, tabs, modal\n * filters, tables, buttons of the exploration page.\n *\n * All of these params come directly from the top level exploration page configuration file or\n * explorer config in a legacy gitops.json file.\n * @example see packages/sampleCommons/config/gen3/explorer.json\n */\n\ninterface CohortPanelConfigurationWithAccessLevel extends CohortPanelConfiguration {\n showAccessLevel?: boolean;\n}\n\n/**\n * CohortPanel is a React component that provides an interactive interface for cohort exploration and filtering.\n * It integrates with data services and facilitates visualization, filtering, and analysis tasks.\n *\n * @param {Object} props The properties required to configure the CohortPanel component.\n * @param {Object} props.guppyConfig Configuration object for Guppy, including field mappings and data type information.\n * @param {Object} props.filters Configuration for filter tabs, including filter fields and layout.\n * @param {Object} [props.charts={}] Optional set of chart configuration objects for rendering summaries.\n * @param {Object} [props.chartsSection] Optional configuration for an additional section of charts.\n * @param {Object} props.table Reference to the table configuration or component for displaying data.\n * @param {string} props.tabTitle Title for the filter tab section.\n * @param {Object[]|undefined} props.dropdowns Dropdown menu configuration, allowing for additional filter options or actions.\n * @param {Object[]|undefined} props.buttons List of button configurations for actions such as downloads.\n * @param {boolean} props.loginForDownload Determines whether login is required to enable download functionality.\n * @param {boolean} [props.showAccessLevel=false] Indicates if the user access level should be displayed on the panel.\n *\n * @returns {JSX.Element} Returns a JSX element rendering the CohortPanel. This includes filter options,\n * summary charts, cohort manager, and data display components.\n */\nexport const CohortPanel = ({\n guppyConfig,\n filters,\n charts = {},\n chartsSection = undefined,\n table,\n tabTitle,\n dropdowns,\n buttons,\n loginForDownload,\n showAccessLevel = false,\n}: CohortPanelConfigurationWithAccessLevel): JSX.Element => {\n const isSm = useMediaQuery('(min-width: 639px)');\n const isMd = useMediaQuery('(min-width: 1373px)');\n const isXl = useMediaQuery('(min-width: 1600px)');\n const [accessLevel, setAccessLevel] = useState<Accessibility>(\n Accessibility.ALL,\n );\n const sharedFiltersMap = useCoreSelector((state: CoreState) =>\n selectSharedFilters(state),\n );\n\n const defaultDropdowns = useMemo(() => dropdowns ?? {}, [dropdowns]);\n const defaultButtons = useMemo(() => buttons ?? [], [buttons]);\n\n const numCols = useMemo(() => {\n if (isSm) return 1;\n if (isMd) return 2;\n if (isXl) return 4;\n return 3;\n }, [isSm, isMd, isXl]);\n\n const index = guppyConfig.dataType;\n const indexPrefix = guppyConfig?.indexPrefix ?? '';\n const fields = useMemo(\n () => getAllFieldsFromFilterConfigs(filters?.tabs ?? []),\n [filters?.tabs],\n );\n\n const coreDispatch = useCoreDispatch();\n\n const [facetDefinitions, setFacetDefinitions] = useState<\n Record<string, FacetDefinition>\n >({});\n\n const [summaryCharts, setSummaryCharts] = useState<\n Record<string, SummaryChart>\n >({});\n\n const cohortFilters = useCoreSelector((state: CoreState) =>\n selectIndexFilters(state, index),\n );\n\n const cohortId = useCoreSelector((state: CoreState) =>\n selectCurrentCohortId(state),\n );\n\n const allFiltersCollapsed = useCoreSelector((state) =>\n selectAllCohortFiltersCollapsed(state, index),\n );\n\n const toggleAllFiltersExpanded = (expand: boolean) => {\n coreDispatch(toggleCohortBuilderAllFilters({ expand, index }));\n };\n\n const clearAllFilters = useCallback(() => {\n coreDispatch(clearCohortFilters({ index }));\n }, [coreDispatch, index]);\n\n const {\n data,\n isSuccess,\n isFetching: isAggsQueryFetching,\n isError: isAggsQueryError,\n } = useGetAggsQuery({\n type: index,\n fields: fields,\n filters: cohortFilters,\n accessibility: accessLevel,\n queryId: cohortId,\n indexPrefix: indexPrefix,\n });\n\n const chartKeys = useDeepCompareMemo(\n () => [...Object.keys(chartsSection?.charts ?? {}), ...Object.keys(charts)],\n [chartsSection?.charts, charts],\n );\n\n const {\n data: chartData,\n isSuccess: isChartSuccess,\n isFetching: isChartFetching,\n isError: isChartError,\n } = useGetAggsQuery(\n {\n type: index,\n fields: chartKeys,\n filters: cohortFilters,\n accessibility: accessLevel,\n filterSelf: true,\n queryId: cohortId,\n indexPrefix: indexPrefix,\n },\n {\n skip: chartKeys.length === 0,\n },\n );\n\n const cleanChartData = useDeepCompareMemo(() => {\n if (isChartSuccess && chartData) {\n const cleanedData: AggregationsData = {};\n const totalCount = chartData._totalCount[0]?.count;\n Object.keys(summaryCharts).forEach((key) => {\n if (!(key in chartData)) {\n return;\n } // handle missing key in data\n // remove empty keys\n cleanedData[key] = chartData[key].filter((x) =>\n typeof x.key !== 'string' ? true : x.key !== '',\n );\n\n const facetDef = facetDefinitions?.[key];\n if (facetDef?.excludeValues) {\n cleanedData[key] = cleanedData[key].filter((x) =>\n typeof x.key !== 'string'\n ? true\n : facetDef?.excludeValues?.includes(String(x.key)) === false,\n );\n }\n\n if (cleanedData[key].length === 0 && totalCount) {\n // if no keys adds back no data\n cleanedData[key] = [{ key: 'no data', count: totalCount }];\n }\n });\n return cleanedData;\n }\n return chartData;\n }, [chartData, isChartSuccess, summaryCharts]);\n\n const getEnumFacetData = useDeepCompareCallback(\n (field: string) => {\n let filters = undefined;\n let combineMode: CombineMode = 'or';\n if (field in cohortFilters.root) {\n if (isIntersection(cohortFilters.root[field])) {\n const intersectionFilters = removeIntersectionFromEnum(\n cohortFilters.root[field],\n );\n if (intersectionFilters) {\n filters = extractEnumFilterValue(intersectionFilters);\n combineMode = 'and';\n }\n } else {\n filters = extractEnumFilterValue(cohortFilters.root[field]);\n }\n }\n\n return {\n data: processBucketData(data?.[field]),\n enumFilters: filters,\n combineMode: combineMode,\n isSuccess: isSuccess,\n };\n },\n [cohortFilters.root, data, isSuccess],\n );\n\n const getRangeFacetData = useDeepCompareCallback(\n (field: string) => {\n return {\n data: processRangeData(data?.[field]),\n filters: extractRangeValues(cohortFilters.root[field]),\n isSuccess: isSuccess,\n };\n },\n [data, cohortFilters.root, isSuccess],\n );\n\n // Set up the hooks for the facet components to use based on the required index\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const facetDataHooks: Record<FacetType, FacetDataHooks | EnumFacetDataHooks> =\n useDeepCompareMemo(() => {\n return {\n // TODO: see if there a better way to do this\n enum: {\n useGetFacetData: getEnumFacetData,\n useUpdateFacetFilters: partial(useUpdateFilters, index),\n useGetFacetFilters: partial(useGetFacetFilters, index),\n useClearFilter: partial(useClearFilters, index),\n useFilterExpanded: partial(useFilterExpandedState, index),\n useToggleExpandFilter: partial(useToggleExpandFilter, index),\n useGetCombineMode: partial(useCohortFilterCombineState, index),\n useSetCombineMode: partial(useSetCohortFilterCombineState, index),\n useFieldNameToLabel: useFieldNameToLabel,\n useTotalCounts: undefined,\n },\n exact: {\n useGetFacetData: getEnumFacetData,\n useUpdateFacetFilters: partial(useUpdateFilters, index),\n useGetFacetFilters: partial(useGetFacetFilters, index),\n useClearFilter: partial(useClearFilters, index),\n useFilterExpanded: partial(useFilterExpandedState, index),\n useToggleExpandFilter: partial(useToggleExpandFilter, index),\n useFieldNameToLabel: useFieldNameToLabel,\n useTotalCounts: undefined,\n },\n multiselect: {\n useGetFacetData: getEnumFacetData,\n useUpdateFacetFilters: partial(useUpdateFilters, index),\n useGetFacetFilters: partial(useGetFacetFilters, index),\n useClearFilter: partial(useClearFilters, index),\n useFilterExpanded: partial(useFilterExpandedState, index),\n useToggleExpandFilter: partial(useToggleExpandFilter, index),\n useFieldNameToLabel: useFieldNameToLabel,\n useTotalCounts: undefined,\n },\n range: {\n useGetFacetData: getRangeFacetData,\n useUpdateFacetFilters: partial(useUpdateFilters, index),\n useGetFacetFilters: partial(useGetFacetFilters, index),\n useClearFilter: partial(useClearFilters, index),\n useFilterExpanded: partial(useFilterExpandedState, index),\n useToggleExpandFilter: partial(useToggleExpandFilter, index),\n useFieldNameToLabel: useFieldNameToLabel,\n useTotalCounts: undefined,\n },\n };\n }, [getEnumFacetData, getRangeFacetData, index]);\n\n // Set the facet definitions based on the data only the first time the data is loaded\n useDeepCompareEffect(() => {\n if (isSuccess && Object.keys(facetDefinitions).length === 0) {\n const configFacetDefs = filters?.tabs.reduce(\n (acc: Record<string, FacetDefinition>, tab) => {\n return { ...tab.fieldsConfig, ...acc };\n },\n {},\n );\n\n const facetDefs = classifyFacets(\n data,\n index,\n guppyConfig?.fieldMapping ?? [],\n configFacetDefs ?? {},\n sharedFiltersMap,\n );\n setFacetDefinitions(facetDefs);\n\n // setup summary charts since nested fields can be listed by the split field name\n const chartDefinitions = chartsSection?.charts ?? charts;\n\n const summaryCharts = Object.keys(chartDefinitions).reduce(\n (acc, field) => {\n let chartField = field;\n if (facetDefs?.[field] === undefined) {\n const res = Object.values(facetDefs).filter((def) => {\n return def.dataField === field;\n });\n if (res.length > 0) {\n chartField = res[0].field;\n }\n }\n return {\n ...acc,\n [chartField]: chartDefinitions[field],\n };\n },\n {},\n );\n\n setSummaryCharts(summaryCharts);\n }\n }, [\n isSuccess,\n data,\n facetDefinitions,\n index,\n guppyConfig.fieldMapping,\n charts,\n chartsSection,\n ]);\n\n const {\n data: counts,\n isFetching: isCountsFetching,\n isError: isCountsError,\n } = useGetCountsQuery({\n type: index,\n filters: cohortFilters,\n accessibility: accessLevel,\n queryId: cohortId,\n });\n\n const [submitJob, result] = useSubmitSowerJobMutation();\n const { update } = useSowerJobEventBus();\n\n useEffect(() => {\n if (result?.data) {\n update(result.data?.uid);\n }\n }, [result]);\n\n if (isCountsError || isAggsQueryError) {\n return <ErrorCard message=\"Unable to fetch data from server\" />; // TODO: replace with configurable message\n }\n\n return (\n <div className=\"flex flex-col mt-3 relative px-4 bg-base-lightest w-full\">\n <QueryExpression index={index} />\n\n {/* Flex container to ensure proper 25/75 split */}\n <div className=\"flex w-full\">\n {/* Left panel - 25% */}\n <div\n id=\"cohort-builder-filters\"\n className=\"flex-shrink-0 md:w-1/4 lg:w-1/5\"\n >\n {filters?.tabs && (\n <DropdownPanel\n filters={filters}\n tabTitle={tabTitle}\n facetDefinitions={facetDefinitions}\n facetDataHooks={facetDataHooks}\n onAccessChange={setAccessLevel}\n accessLevel={accessLevel}\n showAccessLevel={showAccessLevel}\n allFiltersCollapsed={allFiltersCollapsed}\n toggleAllFiltersExpanded={toggleAllFiltersExpanded}\n clearAllFilters={clearAllFilters}\n />\n )}\n </div>\n\n {/* Right content - 75% */}\n <div\n id=\"cohort-builder-content\"\n className=\"flex flex-col md:w-3/4 lg:w-4/5 pl-4\"\n >\n {/* Top row with DownloadsPanel and CountsValue */}\n <div className=\"flex justify-between mb-2 ml-2\">\n <DownloadsPanel\n dropdowns={defaultDropdowns}\n buttons={defaultButtons}\n loginForDownload={loginForDownload}\n index={index}\n totalCount={counts ?? 0}\n fields={table?.fields ?? []}\n filter={cohortFilters}\n />\n <CountsValue\n label={guppyConfig?.nodeCountTitle || toDisplayName(index)}\n counts={counts}\n isFetching={isCountsFetching}\n isError={isCountsError}\n />\n </div>\n\n {/* Charts Section */}\n {chartsSection?.enabled ? (\n <CollapsableCharts\n config={{ ...chartsSection, charts: summaryCharts }}\n data={cleanChartData ?? EmptyData}\n isSuccess={isChartSuccess}\n isFetching={isChartFetching}\n isError={isChartError}\n />\n ) : (\n <Charts\n charts={summaryCharts}\n data={cleanChartData ?? EmptyData}\n counts={counts}\n isSuccess={isChartSuccess}\n isError={isChartError}\n numCols={numCols}\n />\n )}\n\n {/* Table Section */}\n {table?.enabled && (\n <>\n {/* TODO: replace this with JobActionButton\n <Button\n onClick={() =>\n submitJob({\n action: 'export',\n input: {\n filter: convertFilterSetToGqlFilter(cohortFilters),\n },\n })\n }\n >\n Export\n </Button>\n */}\n <div className=\"mt-2 flex flex-col\">\n <ExplorerTable\n index={index}\n tableConfig={table}\n accessibility={accessLevel}\n />\n </div>\n </>\n )}\n </div>\n </div>\n </div>\n );\n};\n","export const TabsLayoutToComponentProp = (\n tabsLayout?: 'left' | 'right' | 'center',\n) => {\n if (!tabsLayout) {\n return 'flex-start';\n }\n switch (tabsLayout) {\n case 'left': {\n return 'flex-start';\n }\n case 'right': {\n return 'flex-end';\n }\n case 'center': {\n return 'center';\n }\n default: {\n return 'flex-start';\n }\n }\n};\n","import React from 'react';\nimport { useDeepCompareMemo } from 'use-deep-compare';\nimport { CohortBuilderProps, CohortPanelConfiguration } from './types';\nimport { Tabs } from '@mantine/core';\nimport { CohortPanel } from './CohortPanel';\nimport {\n selectCurrentCohortId,\n setSharedFilters,\n useCoreDispatch,\n useCoreSelector,\n} from '@gen3/core';\nimport { TabsLayoutToComponentProp } from '../../utils/layout';\nimport CohortManager from './CohortManager/CohortManager';\n\nexport const useGetCurrentCohort = () => {\n return useCoreSelector((state) => selectCurrentCohortId(state));\n};\n\nconst CohortBuilder = ({\n explorerConfig,\n sharedFiltersMap = null,\n tabsLayout = 'left',\n enableCohortManager = true,\n activeTab,\n}: CohortBuilderProps) => {\n const dispatch = useCoreDispatch();\n dispatch(setSharedFilters(sharedFiltersMap ?? {}));\n\n const configuration = useDeepCompareMemo(\n () => explorerConfig,\n [explorerConfig],\n );\n\n return (\n <div className=\"flex flex-col w-full mt-2\">\n {enableCohortManager ? <CohortManager /> : null}\n <Tabs\n color=\"primary.5\"\n variant={explorerConfig[0]?.tabType}\n keepMounted={true}\n defaultValue={activeTab ?? explorerConfig[0].tabTitle}\n >\n <Tabs.List\n className=\"w-full\"\n justify={TabsLayoutToComponentProp(tabsLayout)}\n >\n {configuration.map((panelConfig: CohortPanelConfiguration) => (\n <Tabs.Tab\n value={panelConfig.tabTitle}\n key={`${panelConfig.tabTitle}-tabList`}\n >\n {panelConfig.tabTitle}\n </Tabs.Tab>\n ))}\n </Tabs.List>\n\n {configuration.map((panelConfig: CohortPanelConfiguration) => (\n <Tabs.Panel\n value={panelConfig.tabTitle}\n key={`${panelConfig.tabTitle}-tabPanel`}\n >\n <CohortPanel\n guppyConfig={panelConfig.guppyConfig}\n key={`${panelConfig.tabTitle}-CohortPanel`}\n chartsSection={panelConfig?.chartsSection}\n charts={panelConfig?.charts}\n filters={panelConfig.filters}\n tabTitle={panelConfig.tabTitle}\n table={panelConfig.table}\n dropdowns={panelConfig.dropdowns}\n buttons={panelConfig.buttons}\n loginForDownload={panelConfig.loginForDownload}\n sharedFiltersMap={panelConfig.sharedFiltersMap}\n />\n </Tabs.Panel>\n ))}\n </Tabs>\n </div>\n );\n};\n\nexport default CohortBuilder;\n"],"names":["toDisplayName","field","parsed","split","fieldName","at","map","w","capitalize","join","useSowerJobEventBus","listeners","setListeners","useState","pollers","setPollers","Set","trigger","statusResult","useLazyGetMultipleSowerJobStatusQuery","pollingInterval","skipPollingIfUnfocused","on","listenerKey","newPollers","callback","off","Object","fromEntries","entries","filter","key","update","job","useEffect","Array","from","isSuccess","currentData","response","status","values","forEach","poller","EmptyData","CohortPanel","guppyConfig","filters","charts","chartsSection","undefined","table","tabTitle","dropdowns","buttons","loginForDownload","showAccessLevel","isSm","useMediaQuery","isMd","isXl","accessLevel","setAccessLevel","Accessibility","ALL","sharedFiltersMap","useCoreSelector","state","selectSharedFilters","defaultDropdowns","useMemo","defaultButtons","numCols","index","dataType","indexPrefix","fields","getAllFieldsFromFilterConfigs","tabs","coreDispatch","useCoreDispatch","facetDefinitions","setFacetDefinitions","summaryCharts","setSummaryCharts","cohortFilters","selectIndexFilters","cohortId","selectCurrentCohortId","allFiltersCollapsed","selectAllCohortFiltersCollapsed","toggleAllFiltersExpanded","expand","toggleCohortBuilderAllFilters","clearAllFilters","useCallback","clearCohortFilters","data","isFetching","isAggsQueryFetching","isError","isAggsQueryError","useGetAggsQuery","type","accessibility","queryId","chartKeys","useDeepCompareMemo","keys","chartData","isChartSuccess","isChartFetching","isChartError","filterSelf","skip","length","cleanChartData","cleanedData","totalCount","_totalCount","count","x","facetDef","excludeValues","includes","String","getEnumFacetData","useDeepCompareCallback","combineMode","root","isIntersection","intersectionFilters","removeIntersectionFromEnum","extractEnumFilterValue","processBucketData","enumFilters","getRangeFacetData","processRangeData","extractRangeValues","facetDataHooks","enum","useGetFacetData","useUpdateFacetFilters","partial","useUpdateFilters","useGetFacetFilters","useClearFilter","useClearFilters","useFilterExpanded","useFilterExpandedState","useToggleExpandFilter","useGetCombineMode","useCohortFilterCombineState","useSetCombineMode","useSetCohortFilterCombineState","useFieldNameToLabel","useTotalCounts","exact","multiselect","range","useDeepCompareEffect","configFacetDefs","reduce","acc","tab","fieldsConfig","facetDefs","classifyFacets","fieldMapping","chartDefinitions","chartField","res","def","dataField","counts","isCountsFetching","isCountsError","useGetCountsQuery","submitJob","result","useSubmitSowerJobMutation","uid","_jsx","ErrorCard","message","_jsxs","div","className","QueryExpression","id","DropdownPanel","onAccessChange","DownloadsPanel","CountsValue","label","nodeCountTitle","enabled","CollapsableCharts","config","Charts","_Fragment","ExplorerTable","tableConfig","TabsLayoutToComponentProp","tabsLayout","useGetCurrentCohort","CohortBuilder","explorerConfig","enableCohortManager","activeTab","dispatch","setSharedFilters","configuration","CohortManager","Tabs","color","variant","tabType","keepMounted","defaultValue","List","justify","panelConfig","Tab","value","Panel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAMA,gBAAgB,CAACC,KAAAA,GAAAA;IAC5B,MAAMC,MAAAA,GAASD,KAAAA,CAAME,KAAK,CAAC,GAAA,CAAA;AAC3B,IAAA,MAAMC,SAAAA,GAAYF,MAAAA,CAAOG,EAAE,CAAC,EAAC,CAAA;IAE7B,IAAI,CAACD,WAAW,OAAO,QAAA;IAEvB,OAAOA,SAAAA,CACJD,KAAK,CAAC,GAAA,CAAA,CACNG,GAAG,CAAC,CAACC,CAAAA,GAAMC,YAAAA,CAAWD,CAAAA,CAAAA,CAAAA,CACtBE,IAAI,CAAC,GAAA,CAAA;AACV,CAAA;;ACjBA;;;AAGC,IACD,MAAMC,mBAAAA,GAAsB,IAAA;AAC1B,IAAA,MAAM,CAACC,SAAAA,EAAWC,YAAAA,CAAa,GAAGC,eAA8B,EAAC,CAAA;AACjE,IAAA,MAAM,CAACC,OAAAA,EAASC,UAAAA,CAAW,GAAGF,eAAsB,IAAIG,GAAAA,EAAAA,CAAAA;AACxD,IAAA,MAAM,CAACC,OAAAA,EAASC,YAAAA,CAAa,GAAGC,0CAAAA,CAAsC;QACpEC,eAAAA,EAAiB,KAAA;QACjBC,sBAAAA,EAAwB;AAC1B,KAAA,CAAA;AAEA;;;;;AAKC,MAED,MAAMC,EAAAA,GAAK,CACTC,WAAAA,EACAC,UAAAA,EACAC,QAAAA,GAAAA;QAEAb,YAAAA,CAAa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AA,EAAOF,YAAY1K,QAAQ;AAG1B0K,gCAAAA,QAAAA,EAAAA,WAAAA,CAAY1K;AAFR,6BAAA,EAAA,CAAA,EAAG0K,WAAAA,CAAY1K,QAAQ,CAAC,QAAQ,CAAC,CAAA;;AAO3CgK,oBAAAA,aAAAA,CAAc9M,GAAG,CAAC,CAACwN,WAAAA,iBAClBxC,cAAA,CAACgC,YAAKW,KAAK,EAAA;AACTD,4BAAAA,KAAAA,EAAOF,YAAY1K,QAAQ;AAG3B,4BAAA,QAAA,gBAAAkI,cAAA,CAACzI,WAAAA,EAAAA;AACCC,gCAAAA,WAAAA,EAAagL,YAAYhL,WAAW;AAEpCG,gCAAAA,aAAAA,EAAe6K,WAAAA,EAAa7K,aAAAA;AAC5BD,gCAAAA,MAAAA,EAAQ8K,WAAAA,EAAa9K,MAAAA;AACrBD,gCAAAA,OAAAA,EAAS+K,YAAY/K,OAAO;AAC5BK,gCAAAA,QAAAA,EAAU0K,YAAY1K,QAAQ;AAC9BD,gCAAAA,KAAAA,EAAO2K,YAAY3K,KAAK;AACxBE,gCAAAA,SAAAA,EAAWyK,YAAYzK,SAAS;AAChCC,gCAAAA,OAAAA,EAASwK,YAAYxK,OAAO;AAC5BC,gCAAAA,gBAAAA,EAAkBuK,YAAYvK,gBAAgB;AAC9CU,gCAAAA,gBAAAA,EAAkB6J,YAAY7J;AATzB,6BAAA,EAAA,CAAA,EAAG6J,WAAAA,CAAY1K,QAAQ,CAAC,YAAY,CAAC;AAJvC,yBAAA,EAAA,CAAA,EAAG0K,WAAAA,CAAY1K,QAAQ,CAAC,SAAS,CAAC,CAAA;;;;;AAoBnD;;;;;"}
@@ -0,0 +1,570 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var useDeepCompare = require('use-deep-compare');
6
+ var core$1 = require('@mantine/core');
7
+ var _ = require('lodash');
8
+ var core = require('@gen3/core');
9
+ var index = require('./index-LxlqqT9v.js');
10
+ require('echarts');
11
+ var hooks = require('@mantine/hooks');
12
+ require('victory');
13
+ require('react-icons/bs');
14
+ require('react-icons/io');
15
+ require('@mantine/form');
16
+ require('react-icons/md');
17
+ require('react-icons/ri');
18
+ require('react-icons/fa');
19
+ require('react-icons/pi');
20
+ require('@iconify-icon/react');
21
+ require('@mantine/modals');
22
+ require('tailwind-merge');
23
+ require('next/navigation');
24
+ require('next/image');
25
+ require('next/link');
26
+ require('next/router');
27
+ require('cookies-next');
28
+ require('swr');
29
+ require('jose');
30
+ require('cookie');
31
+ require('@gen3/core/server');
32
+ require('@mantine/notifications');
33
+ require('react-markdown');
34
+ require('react-icons/ai');
35
+ require('next/head');
36
+ require('remark-gfm');
37
+ require('rehype-sanitize');
38
+ require('fs');
39
+ require('path');
40
+ require('mantine-react-table-open');
41
+ require('react-icons/ti');
42
+ require('react-icons/fi');
43
+ require('react-minisearch');
44
+ require('minisearch');
45
+ require('file-saver');
46
+ require('tailwind-styled-components');
47
+ require('jsonpath-plus');
48
+ require('react-icons/lu');
49
+ require('react-dom');
50
+ require('lodash/uniq');
51
+ require('lodash/sum');
52
+ require('react-icons/fa6');
53
+ require('@tanstack/react-table');
54
+ require('@theothergothamdev/pluralize-ts');
55
+ require('next/dynamic');
56
+ require('react-cookie');
57
+ require('default-composer');
58
+ require('filesize');
59
+ require('@dnd-kit/core');
60
+ require('@dnd-kit/sortable');
61
+ require('@dnd-kit/utilities');
62
+ require('@dnd-kit/modifiers');
63
+ require('universal-cookie');
64
+
65
+ const toDisplayName = (field)=>{
66
+ const parsed = field.split('.');
67
+ const fieldName = parsed.at(-1);
68
+ if (!fieldName) return 'NotSet';
69
+ return fieldName.split('_').map((w)=>_.capitalize(w)).join(' ');
70
+ };
71
+
72
+ /**
73
+ * Hook that sets up an event bus for components to subscribe to and fire off events
74
+ * when an active Sower job is completed.
75
+ */ const useSowerJobEventBus = ()=>{
76
+ const [listeners, setListeners] = React.useState({});
77
+ const [pollers, setPollers] = React.useState(new Set());
78
+ const [trigger, statusResult] = core.useLazyGetMultipleSowerJobStatusQuery({
79
+ pollingInterval: 10000,
80
+ skipPollingIfUnfocused: true
81
+ });
82
+ /**
83
+ * Function for component to subscribe to sower job updates
84
+ * @param listenerKey unique key for component
85
+ * @param newPollers list of jobs to poll the status of
86
+ * @param callback function to call when a job completes
87
+ */ const on = (listenerKey, newPollers, callback)=>{
88
+ setListeners({
89
+ ...listeners,
90
+ [listenerKey]: callback
91
+ });
92
+ setPollers(new Set([
93
+ ...pollers,
94
+ ...newPollers
95
+ ]));
96
+ };
97
+ /**
98
+ * Function for component to unsubscribe to updates
99
+ * @param listenerKey unique key for component
100
+ */ const off = (listenerKey)=>{
101
+ setListeners(Object.fromEntries(Object.entries(listeners).filter(([key])=>key === listenerKey)));
102
+ };
103
+ /**
104
+ * Function to update the jobs that are polling
105
+ * @param job new job to add to pollers
106
+ */ const update = (job)=>{
107
+ setPollers(new Set([
108
+ ...pollers,
109
+ job
110
+ ]));
111
+ };
112
+ React.useEffect(()=>{
113
+ trigger(Array.from(pollers));
114
+ }, [
115
+ pollers
116
+ ]);
117
+ React.useEffect(()=>{
118
+ if (statusResult.isSuccess) {
119
+ Object.entries(statusResult.currentData || {}).map(([job, response])=>{
120
+ if (response.status === 'Completed') {
121
+ Object.values(listeners).forEach((callback)=>callback(job));
122
+ // Remove job from pollers after it has completed
123
+ setPollers(new Set([
124
+ ...pollers
125
+ ].filter((poller)=>poller !== job)));
126
+ }
127
+ });
128
+ }
129
+ }, [
130
+ statusResult
131
+ ]);
132
+ return {
133
+ on,
134
+ off,
135
+ update
136
+ };
137
+ };
138
+
139
+ const EmptyData = {};
140
+ /**
141
+ * CohortPanel is a React component that provides an interactive interface for cohort exploration and filtering.
142
+ * It integrates with data services and facilitates visualization, filtering, and analysis tasks.
143
+ *
144
+ * @param {Object} props The properties required to configure the CohortPanel component.
145
+ * @param {Object} props.guppyConfig Configuration object for Guppy, including field mappings and data type information.
146
+ * @param {Object} props.filters Configuration for filter tabs, including filter fields and layout.
147
+ * @param {Object} [props.charts={}] Optional set of chart configuration objects for rendering summaries.
148
+ * @param {Object} [props.chartsSection] Optional configuration for an additional section of charts.
149
+ * @param {Object} props.table Reference to the table configuration or component for displaying data.
150
+ * @param {string} props.tabTitle Title for the filter tab section.
151
+ * @param {Object[]|undefined} props.dropdowns Dropdown menu configuration, allowing for additional filter options or actions.
152
+ * @param {Object[]|undefined} props.buttons List of button configurations for actions such as downloads.
153
+ * @param {boolean} props.loginForDownload Determines whether login is required to enable download functionality.
154
+ * @param {boolean} [props.showAccessLevel=false] Indicates if the user access level should be displayed on the panel.
155
+ *
156
+ * @returns {JSX.Element} Returns a JSX element rendering the CohortPanel. This includes filter options,
157
+ * summary charts, cohort manager, and data display components.
158
+ */ const CohortPanel = ({ guppyConfig, filters, charts = {}, chartsSection = undefined, table, tabTitle, dropdowns, buttons, loginForDownload, showAccessLevel = false })=>{
159
+ const isSm = hooks.useMediaQuery('(min-width: 639px)');
160
+ const isMd = hooks.useMediaQuery('(min-width: 1373px)');
161
+ const isXl = hooks.useMediaQuery('(min-width: 1600px)');
162
+ const [accessLevel, setAccessLevel] = React.useState(core.Accessibility.ALL);
163
+ const sharedFiltersMap = core.useCoreSelector((state)=>core.selectSharedFilters(state));
164
+ const defaultDropdowns = React.useMemo(()=>dropdowns ?? {}, [
165
+ dropdowns
166
+ ]);
167
+ const defaultButtons = React.useMemo(()=>buttons ?? [], [
168
+ buttons
169
+ ]);
170
+ const numCols = React.useMemo(()=>{
171
+ if (isSm) return 1;
172
+ if (isMd) return 2;
173
+ if (isXl) return 4;
174
+ return 3;
175
+ }, [
176
+ isSm,
177
+ isMd,
178
+ isXl
179
+ ]);
180
+ const index$1 = guppyConfig.dataType;
181
+ const indexPrefix = guppyConfig?.indexPrefix ?? '';
182
+ const fields = React.useMemo(()=>index.getAllFieldsFromFilterConfigs(filters?.tabs ?? []), [
183
+ filters?.tabs
184
+ ]);
185
+ const coreDispatch = core.useCoreDispatch();
186
+ const [facetDefinitions, setFacetDefinitions] = React.useState({});
187
+ const [summaryCharts, setSummaryCharts] = React.useState({});
188
+ const cohortFilters = core.useCoreSelector((state)=>core.selectIndexFilters(state, index$1));
189
+ const cohortId = core.useCoreSelector((state)=>core.selectCurrentCohortId(state));
190
+ const allFiltersCollapsed = core.useCoreSelector((state)=>core.selectAllCohortFiltersCollapsed(state, index$1));
191
+ const toggleAllFiltersExpanded = (expand)=>{
192
+ coreDispatch(core.toggleCohortBuilderAllFilters({
193
+ expand,
194
+ index: index$1
195
+ }));
196
+ };
197
+ const clearAllFilters = React.useCallback(()=>{
198
+ coreDispatch(core.clearCohortFilters({
199
+ index: index$1
200
+ }));
201
+ }, [
202
+ coreDispatch,
203
+ index$1
204
+ ]);
205
+ const { data, isSuccess, isFetching: isAggsQueryFetching, isError: isAggsQueryError } = core.useGetAggsQuery({
206
+ type: index$1,
207
+ fields: fields,
208
+ filters: cohortFilters,
209
+ accessibility: accessLevel,
210
+ queryId: cohortId,
211
+ indexPrefix: indexPrefix
212
+ });
213
+ const chartKeys = useDeepCompare.useDeepCompareMemo(()=>[
214
+ ...Object.keys(chartsSection?.charts ?? {}),
215
+ ...Object.keys(charts)
216
+ ], [
217
+ chartsSection?.charts,
218
+ charts
219
+ ]);
220
+ const { data: chartData, isSuccess: isChartSuccess, isFetching: isChartFetching, isError: isChartError } = core.useGetAggsQuery({
221
+ type: index$1,
222
+ fields: chartKeys,
223
+ filters: cohortFilters,
224
+ accessibility: accessLevel,
225
+ filterSelf: true,
226
+ queryId: cohortId,
227
+ indexPrefix: indexPrefix
228
+ }, {
229
+ skip: chartKeys.length === 0
230
+ });
231
+ const cleanChartData = useDeepCompare.useDeepCompareMemo(()=>{
232
+ if (isChartSuccess && chartData) {
233
+ const cleanedData = {};
234
+ const totalCount = chartData._totalCount[0]?.count;
235
+ Object.keys(summaryCharts).forEach((key)=>{
236
+ if (!(key in chartData)) {
237
+ return;
238
+ } // handle missing key in data
239
+ // remove empty keys
240
+ cleanedData[key] = chartData[key].filter((x)=>typeof x.key !== 'string' ? true : x.key !== '');
241
+ const facetDef = facetDefinitions?.[key];
242
+ if (facetDef?.excludeValues) {
243
+ cleanedData[key] = cleanedData[key].filter((x)=>typeof x.key !== 'string' ? true : facetDef?.excludeValues?.includes(String(x.key)) === false);
244
+ }
245
+ if (cleanedData[key].length === 0 && totalCount) {
246
+ // if no keys adds back no data
247
+ cleanedData[key] = [
248
+ {
249
+ key: 'no data',
250
+ count: totalCount
251
+ }
252
+ ];
253
+ }
254
+ });
255
+ return cleanedData;
256
+ }
257
+ return chartData;
258
+ }, [
259
+ chartData,
260
+ isChartSuccess,
261
+ summaryCharts
262
+ ]);
263
+ const getEnumFacetData = useDeepCompare.useDeepCompareCallback((field)=>{
264
+ let filters = undefined;
265
+ let combineMode = 'or';
266
+ if (field in cohortFilters.root) {
267
+ if (core.isIntersection(cohortFilters.root[field])) {
268
+ const intersectionFilters = index.removeIntersectionFromEnum(cohortFilters.root[field]);
269
+ if (intersectionFilters) {
270
+ filters = core.extractEnumFilterValue(intersectionFilters);
271
+ combineMode = 'and';
272
+ }
273
+ } else {
274
+ filters = core.extractEnumFilterValue(cohortFilters.root[field]);
275
+ }
276
+ }
277
+ return {
278
+ data: index.processBucketData(data?.[field]),
279
+ enumFilters: filters,
280
+ combineMode: combineMode,
281
+ isSuccess: isSuccess
282
+ };
283
+ }, [
284
+ cohortFilters.root,
285
+ data,
286
+ isSuccess
287
+ ]);
288
+ const getRangeFacetData = useDeepCompare.useDeepCompareCallback((field)=>{
289
+ return {
290
+ data: index.processRangeData(data?.[field]),
291
+ filters: index.extractRangeValues(cohortFilters.root[field]),
292
+ isSuccess: isSuccess
293
+ };
294
+ }, [
295
+ data,
296
+ cohortFilters.root,
297
+ isSuccess
298
+ ]);
299
+ // Set up the hooks for the facet components to use based on the required index
300
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
301
+ // @ts-ignore
302
+ const facetDataHooks = useDeepCompare.useDeepCompareMemo(()=>{
303
+ return {
304
+ // TODO: see if there a better way to do this
305
+ enum: {
306
+ useGetFacetData: getEnumFacetData,
307
+ useUpdateFacetFilters: _.partial(index.useUpdateFilters, index$1),
308
+ useGetFacetFilters: _.partial(index.useGetFacetFilters, index$1),
309
+ useClearFilter: _.partial(index.useClearFilters, index$1),
310
+ useFilterExpanded: _.partial(index.useFilterExpandedState, index$1),
311
+ useToggleExpandFilter: _.partial(index.useToggleExpandFilter, index$1),
312
+ useGetCombineMode: _.partial(index.useCohortFilterCombineState, index$1),
313
+ useSetCombineMode: _.partial(index.useSetCohortFilterCombineState, index$1),
314
+ useFieldNameToLabel: index.useFieldNameToLabel,
315
+ useTotalCounts: undefined
316
+ },
317
+ exact: {
318
+ useGetFacetData: getEnumFacetData,
319
+ useUpdateFacetFilters: _.partial(index.useUpdateFilters, index$1),
320
+ useGetFacetFilters: _.partial(index.useGetFacetFilters, index$1),
321
+ useClearFilter: _.partial(index.useClearFilters, index$1),
322
+ useFilterExpanded: _.partial(index.useFilterExpandedState, index$1),
323
+ useToggleExpandFilter: _.partial(index.useToggleExpandFilter, index$1),
324
+ useFieldNameToLabel: index.useFieldNameToLabel,
325
+ useTotalCounts: undefined
326
+ },
327
+ multiselect: {
328
+ useGetFacetData: getEnumFacetData,
329
+ useUpdateFacetFilters: _.partial(index.useUpdateFilters, index$1),
330
+ useGetFacetFilters: _.partial(index.useGetFacetFilters, index$1),
331
+ useClearFilter: _.partial(index.useClearFilters, index$1),
332
+ useFilterExpanded: _.partial(index.useFilterExpandedState, index$1),
333
+ useToggleExpandFilter: _.partial(index.useToggleExpandFilter, index$1),
334
+ useFieldNameToLabel: index.useFieldNameToLabel,
335
+ useTotalCounts: undefined
336
+ },
337
+ range: {
338
+ useGetFacetData: getRangeFacetData,
339
+ useUpdateFacetFilters: _.partial(index.useUpdateFilters, index$1),
340
+ useGetFacetFilters: _.partial(index.useGetFacetFilters, index$1),
341
+ useClearFilter: _.partial(index.useClearFilters, index$1),
342
+ useFilterExpanded: _.partial(index.useFilterExpandedState, index$1),
343
+ useToggleExpandFilter: _.partial(index.useToggleExpandFilter, index$1),
344
+ useFieldNameToLabel: index.useFieldNameToLabel,
345
+ useTotalCounts: undefined
346
+ }
347
+ };
348
+ }, [
349
+ getEnumFacetData,
350
+ getRangeFacetData,
351
+ index$1
352
+ ]);
353
+ // Set the facet definitions based on the data only the first time the data is loaded
354
+ useDeepCompare.useDeepCompareEffect(()=>{
355
+ if (isSuccess && Object.keys(facetDefinitions).length === 0) {
356
+ const configFacetDefs = filters?.tabs.reduce((acc, tab)=>{
357
+ return {
358
+ ...tab.fieldsConfig,
359
+ ...acc
360
+ };
361
+ }, {});
362
+ const facetDefs = index.classifyFacets(data, index$1, guppyConfig?.fieldMapping ?? [], configFacetDefs ?? {}, sharedFiltersMap);
363
+ setFacetDefinitions(facetDefs);
364
+ // setup summary charts since nested fields can be listed by the split field name
365
+ const chartDefinitions = chartsSection?.charts ?? charts;
366
+ const summaryCharts = Object.keys(chartDefinitions).reduce((acc, field)=>{
367
+ let chartField = field;
368
+ if (facetDefs?.[field] === undefined) {
369
+ const res = Object.values(facetDefs).filter((def)=>{
370
+ return def.dataField === field;
371
+ });
372
+ if (res.length > 0) {
373
+ chartField = res[0].field;
374
+ }
375
+ }
376
+ return {
377
+ ...acc,
378
+ [chartField]: chartDefinitions[field]
379
+ };
380
+ }, {});
381
+ setSummaryCharts(summaryCharts);
382
+ }
383
+ }, [
384
+ isSuccess,
385
+ data,
386
+ facetDefinitions,
387
+ index$1,
388
+ guppyConfig.fieldMapping,
389
+ charts,
390
+ chartsSection
391
+ ]);
392
+ const { data: counts, isFetching: isCountsFetching, isError: isCountsError } = core.useGetCountsQuery({
393
+ type: index$1,
394
+ filters: cohortFilters,
395
+ accessibility: accessLevel,
396
+ queryId: cohortId
397
+ });
398
+ const [submitJob, result] = core.useSubmitSowerJobMutation();
399
+ const { update } = useSowerJobEventBus();
400
+ React.useEffect(()=>{
401
+ if (result?.data) {
402
+ update(result.data?.uid);
403
+ }
404
+ }, [
405
+ result
406
+ ]);
407
+ if (isCountsError || isAggsQueryError) {
408
+ return /*#__PURE__*/ jsxRuntime.jsx(index.ErrorCard, {
409
+ message: "Unable to fetch data from server"
410
+ }); // TODO: replace with configurable message
411
+ }
412
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
413
+ className: "flex flex-col mt-3 relative px-4 bg-base-lightest w-full",
414
+ children: [
415
+ /*#__PURE__*/ jsxRuntime.jsx(index.QueryExpression, {
416
+ index: index$1
417
+ }),
418
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
419
+ className: "flex w-full",
420
+ children: [
421
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
422
+ id: "cohort-builder-filters",
423
+ className: "flex-shrink-0 md:w-1/4 lg:w-1/5",
424
+ children: filters?.tabs && /*#__PURE__*/ jsxRuntime.jsx(index.DropdownPanel, {
425
+ filters: filters,
426
+ tabTitle: tabTitle,
427
+ facetDefinitions: facetDefinitions,
428
+ facetDataHooks: facetDataHooks,
429
+ onAccessChange: setAccessLevel,
430
+ accessLevel: accessLevel,
431
+ showAccessLevel: showAccessLevel,
432
+ allFiltersCollapsed: allFiltersCollapsed,
433
+ toggleAllFiltersExpanded: toggleAllFiltersExpanded,
434
+ clearAllFilters: clearAllFilters
435
+ })
436
+ }),
437
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
438
+ id: "cohort-builder-content",
439
+ className: "flex flex-col md:w-3/4 lg:w-4/5 pl-4",
440
+ children: [
441
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
442
+ className: "flex justify-between mb-2 ml-2",
443
+ children: [
444
+ /*#__PURE__*/ jsxRuntime.jsx(index.DownloadsPanel, {
445
+ dropdowns: defaultDropdowns,
446
+ buttons: defaultButtons,
447
+ loginForDownload: loginForDownload,
448
+ index: index$1,
449
+ totalCount: counts ?? 0,
450
+ fields: table?.fields ?? [],
451
+ filter: cohortFilters
452
+ }),
453
+ /*#__PURE__*/ jsxRuntime.jsx(index.CountsValue, {
454
+ label: guppyConfig?.nodeCountTitle || toDisplayName(index$1),
455
+ counts: counts,
456
+ isFetching: isCountsFetching,
457
+ isError: isCountsError
458
+ })
459
+ ]
460
+ }),
461
+ chartsSection?.enabled ? /*#__PURE__*/ jsxRuntime.jsx(index.CollapsableCharts, {
462
+ config: {
463
+ ...chartsSection,
464
+ charts: summaryCharts
465
+ },
466
+ data: cleanChartData ?? EmptyData,
467
+ isSuccess: isChartSuccess,
468
+ isFetching: isChartFetching,
469
+ isError: isChartError
470
+ }) : /*#__PURE__*/ jsxRuntime.jsx(index.Charts, {
471
+ charts: summaryCharts,
472
+ data: cleanChartData ?? EmptyData,
473
+ counts: counts,
474
+ isSuccess: isChartSuccess,
475
+ isError: isChartError,
476
+ numCols: numCols
477
+ }),
478
+ table?.enabled && /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
479
+ children: /*#__PURE__*/ jsxRuntime.jsx("div", {
480
+ className: "mt-2 flex flex-col",
481
+ children: /*#__PURE__*/ jsxRuntime.jsx(index.ExplorerTable, {
482
+ index: index$1,
483
+ tableConfig: table,
484
+ accessibility: accessLevel
485
+ })
486
+ })
487
+ })
488
+ ]
489
+ })
490
+ ]
491
+ })
492
+ ]
493
+ });
494
+ };
495
+
496
+ const TabsLayoutToComponentProp = (tabsLayout)=>{
497
+ if (!tabsLayout) {
498
+ return 'flex-start';
499
+ }
500
+ switch(tabsLayout){
501
+ case 'left':
502
+ {
503
+ return 'flex-start';
504
+ }
505
+ case 'right':
506
+ {
507
+ return 'flex-end';
508
+ }
509
+ case 'center':
510
+ {
511
+ return 'center';
512
+ }
513
+ default:
514
+ {
515
+ return 'flex-start';
516
+ }
517
+ }
518
+ };
519
+
520
+ const useGetCurrentCohort = ()=>{
521
+ return core.useCoreSelector((state)=>core.selectCurrentCohortId(state));
522
+ };
523
+ const CohortBuilder = ({ explorerConfig, sharedFiltersMap = null, tabsLayout = 'left', enableCohortManager = true, activeTab })=>{
524
+ const dispatch = core.useCoreDispatch();
525
+ dispatch(core.setSharedFilters(sharedFiltersMap ?? {}));
526
+ const configuration = useDeepCompare.useDeepCompareMemo(()=>explorerConfig, [
527
+ explorerConfig
528
+ ]);
529
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
530
+ className: "flex flex-col w-full mt-2",
531
+ children: [
532
+ enableCohortManager ? /*#__PURE__*/ jsxRuntime.jsx(index.CohortManager, {}) : null,
533
+ /*#__PURE__*/ jsxRuntime.jsxs(core$1.Tabs, {
534
+ color: "primary.5",
535
+ variant: explorerConfig[0]?.tabType,
536
+ keepMounted: true,
537
+ defaultValue: activeTab ?? explorerConfig[0].tabTitle,
538
+ children: [
539
+ /*#__PURE__*/ jsxRuntime.jsx(core$1.Tabs.List, {
540
+ className: "w-full",
541
+ justify: TabsLayoutToComponentProp(tabsLayout),
542
+ children: configuration.map((panelConfig)=>/*#__PURE__*/ jsxRuntime.jsx(core$1.Tabs.Tab, {
543
+ value: panelConfig.tabTitle,
544
+ children: panelConfig.tabTitle
545
+ }, `${panelConfig.tabTitle}-tabList`))
546
+ }),
547
+ configuration.map((panelConfig)=>/*#__PURE__*/ jsxRuntime.jsx(core$1.Tabs.Panel, {
548
+ value: panelConfig.tabTitle,
549
+ children: /*#__PURE__*/ jsxRuntime.jsx(CohortPanel, {
550
+ guppyConfig: panelConfig.guppyConfig,
551
+ chartsSection: panelConfig?.chartsSection,
552
+ charts: panelConfig?.charts,
553
+ filters: panelConfig.filters,
554
+ tabTitle: panelConfig.tabTitle,
555
+ table: panelConfig.table,
556
+ dropdowns: panelConfig.dropdowns,
557
+ buttons: panelConfig.buttons,
558
+ loginForDownload: panelConfig.loginForDownload,
559
+ sharedFiltersMap: panelConfig.sharedFiltersMap
560
+ }, `${panelConfig.tabTitle}-CohortPanel`)
561
+ }, `${panelConfig.tabTitle}-tabPanel`))
562
+ ]
563
+ })
564
+ ]
565
+ });
566
+ };
567
+
568
+ exports.default = CohortBuilder;
569
+ exports.useGetCurrentCohort = useGetCurrentCohort;
570
+ //# sourceMappingURL=CohortBuilder-DZfy_UsD.js.map