@databiosphere/findable-ui 29.0.2 → 30.0.0
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +22 -0
- package/lib/common/categories/config/types.d.ts +28 -0
- package/lib/common/categories/config/utils.d.ts +31 -0
- package/lib/common/categories/config/utils.js +29 -0
- package/lib/common/categories/models/range/typeGuards.d.ts +14 -0
- package/lib/common/categories/models/range/typeGuards.js +18 -0
- package/lib/common/categories/models/range/types.d.ts +15 -0
- package/lib/common/categories/models/range/types.js +1 -0
- package/lib/common/categories/models/range/utils.d.ts +23 -0
- package/lib/common/categories/models/range/utils.js +41 -0
- package/lib/common/categories/models/select/utils.d.ts +8 -0
- package/lib/common/categories/models/select/utils.js +16 -0
- package/lib/common/categories/models/types.d.ts +6 -0
- package/lib/common/categories/models/types.js +1 -0
- package/lib/common/categories/views/common/types.d.ts +10 -0
- package/lib/common/categories/views/common/types.js +1 -0
- package/lib/common/categories/views/range/typeGuards.d.ts +8 -0
- package/lib/common/categories/views/range/typeGuards.js +8 -0
- package/lib/common/categories/views/range/types.d.ts +19 -0
- package/lib/common/categories/views/range/types.js +1 -0
- package/lib/common/categories/views/range/utils.d.ts +12 -0
- package/lib/common/categories/views/range/utils.js +24 -0
- package/lib/common/categories/views/select/typeGuards.d.ts +8 -0
- package/lib/common/categories/views/select/typeGuards.js +8 -0
- package/lib/common/categories/views/select/types.d.ts +7 -0
- package/lib/common/categories/views/select/types.js +1 -0
- package/lib/common/categories/views/types.d.ts +13 -0
- package/lib/common/categories/views/types.js +8 -0
- package/lib/common/entities.d.ts +5 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.d.ts +3 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.js +6 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.d.ts +9 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.js +12 -0
- package/lib/components/DataDictionary/dataDictionary.styles.js +2 -3
- package/lib/components/Filter/components/Filter/filter.d.ts +2 -2
- package/lib/components/Filter/components/Filter/filter.js +11 -3
- package/lib/components/Filter/components/Filter/stories/args.d.ts +5 -0
- package/lib/components/Filter/components/Filter/stories/args.js +19 -0
- package/lib/components/Filter/components/Filter/stories/filter.stories.d.ts +8 -0
- package/lib/components/Filter/components/Filter/stories/filter.stories.js +21 -0
- package/lib/components/Filter/components/FilterMenu/filterMenu.js +2 -2
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.d.ts +1 -1
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.js +1 -1
- package/lib/components/Filter/components/FilterRange/constants.d.ts +0 -2
- package/lib/components/Filter/components/FilterRange/constants.js +0 -5
- package/lib/components/Filter/components/FilterRange/filterRange.d.ts +1 -1
- package/lib/components/Filter/components/FilterRange/filterRange.js +50 -21
- package/lib/components/Filter/components/FilterRange/filterRange.styles.js +58 -10
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.d.ts +5 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.js +5 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.d.ts +2 -2
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.js +32 -7
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.d.ts +6 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.js +50 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.d.ts +26 -3
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.js +6 -1
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.d.ts +15 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.js +25 -0
- package/lib/components/Filter/components/FilterRange/stories/args.d.ts +3 -0
- package/lib/components/Filter/components/FilterRange/stories/args.js +13 -0
- package/lib/components/Filter/components/FilterRange/stories/filterRange.stories.js +2 -2
- package/lib/components/Filter/components/FilterRange/types.d.ts +10 -6
- package/lib/components/Filter/components/FilterRange/types.js +1 -6
- package/lib/components/Filter/components/FilterRange/utils.d.ts +8 -0
- package/lib/components/Filter/components/FilterRange/utils.js +15 -0
- package/lib/components/Filter/components/FilterTag/stories/args.d.ts +5 -0
- package/lib/components/Filter/components/FilterTag/stories/args.js +17 -0
- package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.d.ts +8 -0
- package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.js +21 -0
- package/lib/components/Filter/components/FilterTag/utils.d.ts +10 -0
- package/lib/components/Filter/components/FilterTag/utils.js +40 -0
- package/lib/components/Filter/components/Filters/filters.d.ts +2 -2
- package/lib/components/Filter/components/Filters/filters.js +15 -8
- package/lib/components/Filter/components/Filters/stories/args.d.ts +3 -0
- package/lib/components/Filter/components/Filters/stories/args.js +15 -0
- package/lib/components/Filter/components/Filters/stories/constants.d.ts +22 -0
- package/lib/components/Filter/components/Filters/stories/constants.js +134 -0
- package/lib/components/Filter/components/Filters/stories/filters.stories.d.ts +6 -0
- package/lib/components/Filter/components/Filters/stories/filters.stories.js +15 -0
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.d.ts +1 -1
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.js +5 -5
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.js +2 -1
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.d.ts +3 -2
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.js +6 -4
- package/lib/components/Filter/components/VariableSizeListItem/variableSizeListItem.js +2 -1
- package/lib/components/Index/components/EntitiesView/components/ChartView/utils.js +2 -0
- package/lib/components/Index/table/hook.js +4 -0
- package/lib/components/Table/columnDef/accessorFn/typeGuards.d.ts +9 -0
- package/lib/components/Table/columnDef/accessorFn/typeGuards.js +10 -0
- package/lib/components/Table/common/utils.d.ts +2 -2
- package/lib/components/Table/common/utils.js +28 -13
- package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.js +8 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.js +21 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.d.ts +6 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.js +27 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.d.ts +9 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.js +18 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.js +1 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/utils.d.ts +22 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/utils.js +45 -0
- package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.d.ts +8 -0
- package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.js +46 -0
- package/lib/components/common/Link/typeGuards.d.ts +13 -0
- package/lib/components/common/Link/typeGuards.js +21 -0
- package/lib/config/entities.d.ts +2 -11
- package/lib/hooks/useCategoryFilter.d.ts +8 -13
- package/lib/hooks/useCategoryFilter.js +31 -28
- package/lib/providers/exploreState/entities.d.ts +5 -3
- package/lib/providers/exploreState/payloads/entities.d.ts +6 -2
- package/lib/providers/exploreState.d.ts +3 -2
- package/lib/providers/exploreState.js +1 -1
- package/lib/tests/utils.d.ts +24 -0
- package/lib/tests/utils.js +34 -0
- package/lib/theme/common/components.js +19 -1
- package/lib/views/ExploreView/exploreView.js +10 -8
- package/package.json +2 -1
- package/src/common/categories/config/types.ts +42 -0
- package/src/common/categories/config/utils.ts +47 -0
- package/src/common/categories/models/range/typeGuards.ts +24 -0
- package/src/common/categories/models/range/types.ts +17 -0
- package/src/common/categories/models/range/utils.ts +51 -0
- package/src/common/categories/models/select/utils.ts +23 -0
- package/src/common/categories/models/types.ts +7 -0
- package/src/common/categories/views/common/types.ts +11 -0
- package/src/common/categories/views/range/typeGuards.ts +13 -0
- package/src/common/categories/views/range/types.ts +21 -0
- package/src/common/categories/views/range/utils.ts +35 -0
- package/src/common/categories/views/select/typeGuards.ts +13 -0
- package/src/common/categories/views/select/types.ts +8 -0
- package/src/common/categories/views/types.ts +15 -0
- package/src/common/entities.ts +10 -5
- package/src/components/DataDictionary/components/Table/components/BasicCell/basicCell.tsx +12 -4
- package/src/components/DataDictionary/components/Table/components/BasicCell/utils.ts +13 -0
- package/src/components/DataDictionary/dataDictionary.styles.ts +2 -3
- package/src/components/Filter/components/Filter/filter.tsx +38 -13
- package/src/components/Filter/components/Filter/stories/args.ts +24 -0
- package/src/components/Filter/components/Filter/stories/filter.stories.tsx +32 -0
- package/src/components/Filter/components/FilterMenu/filterMenu.styles.ts +1 -1
- package/src/components/Filter/components/FilterMenu/filterMenu.tsx +7 -3
- package/src/components/Filter/components/FilterRange/constants.ts +0 -7
- package/src/components/Filter/components/FilterRange/filterRange.styles.ts +58 -14
- package/src/components/Filter/components/FilterRange/filterRange.tsx +112 -40
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.ts +5 -0
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.ts +51 -10
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.ts +60 -0
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/types.ts +34 -3
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.ts +32 -0
- package/src/components/Filter/components/FilterRange/stories/args.ts +16 -0
- package/src/components/Filter/components/FilterRange/stories/filterRange.stories.tsx +2 -2
- package/src/components/Filter/components/FilterRange/types.ts +12 -6
- package/src/components/Filter/components/FilterRange/utils.ts +16 -0
- package/src/components/Filter/components/FilterTag/stories/args.ts +22 -0
- package/src/components/Filter/components/FilterTag/stories/filterTag.stories.tsx +32 -0
- package/src/components/Filter/components/FilterTag/utils.ts +57 -0
- package/src/components/Filter/components/Filters/filters.tsx +21 -12
- package/src/components/Filter/components/Filters/stories/args.ts +24 -0
- package/src/components/Filter/components/Filters/stories/constants.ts +151 -0
- package/src/components/Filter/components/Filters/stories/filters.stories.tsx +24 -0
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.tsx +32 -29
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.tsx +9 -1
- package/src/components/Filter/components/SearchAllFilters/searchAllFilters.tsx +12 -6
- package/src/components/Filter/components/VariableSizeListItem/variableSizeListItem.tsx +2 -1
- package/src/components/Index/components/EntitiesView/components/ChartView/utils.ts +2 -0
- package/src/components/Index/table/hook.ts +4 -0
- package/src/components/Table/columnDef/accessorFn/typeGuards.ts +15 -0
- package/src/components/Table/common/utils.ts +37 -16
- package/src/components/Table/components/TableCell/components/ChipCell/chipCell.tsx +14 -0
- package/src/components/Table/components/TableCell/components/LinkCell/linkCell.tsx +64 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/args.ts +35 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.tsx +32 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/types.ts +4 -0
- package/src/components/Table/components/TableCell/components/LinkCell/utils.ts +59 -0
- package/src/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.ts +64 -0
- package/src/components/common/Link/typeGuards.ts +35 -0
- package/src/config/entities.ts +1 -14
- package/src/hooks/useCategoryFilter.ts +56 -53
- package/src/providers/exploreState/entities.ts +3 -3
- package/src/providers/exploreState/initializer/utils.ts +1 -1
- package/src/providers/exploreState/payloads/entities.ts +5 -2
- package/src/providers/exploreState.tsx +5 -3
- package/src/tests/utils.ts +44 -0
- package/src/theme/common/components.ts +19 -1
- package/src/views/ExploreView/exploreView.tsx +17 -22
- package/tests/filter.test.tsx +100 -0
- package/tests/filterRange.test.tsx +331 -46
- package/tests/filters.test.tsx +61 -0
- package/tests/getFacetedMinMaxValues.test.ts +166 -0
- package/tests/linkCell.test.tsx +89 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +0 -3
- package/lib/components/Filter/components/Filter/filter.stories.d.ts +0 -25
- package/lib/components/Filter/components/Filter/filter.stories.js +0 -42
- package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +0 -16
- package/lib/components/Filter/components/FilterTag/filterTag.stories.js +0 -17
- package/lib/components/Filter/components/Filters/filters.stories.d.ts +0 -6
- package/lib/components/Filter/components/Filters/filters.stories.js +0 -91
- package/src/components/DataDictionary/components/Table/components/BasicCell/types.ts +0 -7
- package/src/components/Filter/components/Filter/filter.stories.tsx +0 -52
- package/src/components/Filter/components/FilterTag/filterTag.stories.tsx +0 -23
- package/src/components/Filter/components/Filters/filters.stories.tsx +0 -101
- package/tests/filterRangeMock.test.tsx +0 -38
- /package/lib/{components/DataDictionary/components/Table/components/BasicCell → common/categories/config}/types.js +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FilterTag } from "../filterTag";
|
|
4
|
+
import { DEFAULT_ARGS, WITH_ELLIPSIS_ARGS, WITH_RANGE_ARGS } from "./args";
|
|
5
|
+
const meta = {
|
|
6
|
+
component: FilterTag,
|
|
7
|
+
decorators: [
|
|
8
|
+
(Story) => (React.createElement(Box, { sx: { width: 232 } },
|
|
9
|
+
React.createElement(Story, null))),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
export const Default = {
|
|
14
|
+
args: DEFAULT_ARGS,
|
|
15
|
+
};
|
|
16
|
+
export const WithEllipsis = {
|
|
17
|
+
args: WITH_ELLIPSIS_ARGS,
|
|
18
|
+
};
|
|
19
|
+
export const WithRange = {
|
|
20
|
+
args: WITH_RANGE_ARGS,
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RangeCategoryView } from "../../../../common/categories/views/range/types";
|
|
2
|
+
import { CategoryTag } from "../../../../common/entities";
|
|
3
|
+
import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
|
|
4
|
+
/**
|
|
5
|
+
* Returns set of filter tags with tag label (the selected range values) and corresponding Tag onRemove function.
|
|
6
|
+
* @param categoryView - View model of range category.
|
|
7
|
+
* @param onFilter - Function to execute on selection or removal of category value.
|
|
8
|
+
* @returns Array of selected filter tags.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildRangeTag(categoryView: RangeCategoryView, onFilter: OnFilterFn): CategoryTag[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { VIEW_KIND } from "../../../../common/categories/views/types";
|
|
2
|
+
import { RANGE_OPERATOR } from "../FilterRange/hooks/UseFilterRange/types";
|
|
3
|
+
import { getRangeOperator } from "../FilterRange/utils";
|
|
4
|
+
/**
|
|
5
|
+
* Returns set of filter tags with tag label (the selected range values) and corresponding Tag onRemove function.
|
|
6
|
+
* @param categoryView - View model of range category.
|
|
7
|
+
* @param onFilter - Function to execute on selection or removal of category value.
|
|
8
|
+
* @returns Array of selected filter tags.
|
|
9
|
+
*/
|
|
10
|
+
export function buildRangeTag(categoryView, onFilter) {
|
|
11
|
+
const rangeOperator = getRangeOperator(categoryView);
|
|
12
|
+
if (!rangeOperator)
|
|
13
|
+
return [];
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
label: buildRangeTagLabel(categoryView, rangeOperator),
|
|
17
|
+
onRemove: () => onFilter(categoryView.key, undefined, false, undefined, VIEW_KIND.RANGE),
|
|
18
|
+
superseded: false,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the label for the range tag based on the selected values.
|
|
24
|
+
* @param categoryView - View model of range category.
|
|
25
|
+
* @param rangeOperator - The range operator.
|
|
26
|
+
* @returns The label for the range tag.
|
|
27
|
+
*/
|
|
28
|
+
function buildRangeTagLabel(categoryView, rangeOperator) {
|
|
29
|
+
const { selectedMax, selectedMin } = categoryView;
|
|
30
|
+
switch (rangeOperator) {
|
|
31
|
+
case RANGE_OPERATOR.BETWEEN:
|
|
32
|
+
return `${selectedMin} - ${selectedMax}`;
|
|
33
|
+
case RANGE_OPERATOR.GREATER_THAN:
|
|
34
|
+
return `> ${selectedMin}`;
|
|
35
|
+
case RANGE_OPERATOR.LESS_THAN:
|
|
36
|
+
return `< ${selectedMax}`;
|
|
37
|
+
default:
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CategoryView } from "../../../../common/categories/views/types";
|
|
2
2
|
import { TrackFilterOpenedFunction } from "../../../../config/entities";
|
|
3
3
|
import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
|
|
4
4
|
export interface CategoryFilter {
|
|
5
|
-
categoryViews:
|
|
5
|
+
categoryViews: CategoryView[];
|
|
6
6
|
label?: string;
|
|
7
7
|
}
|
|
8
8
|
export interface FiltersProps {
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { Divider } from "@mui/material";
|
|
2
2
|
import React, { Fragment, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { isRangeCategoryView } from "../../../../common/categories/views/range/typeGuards";
|
|
3
4
|
import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../hooks/useBreakpointHelper";
|
|
4
5
|
import { useWindowResize } from "../../../../hooks/useWindowResize";
|
|
5
6
|
import { TEST_IDS } from "../../../../tests/testIds";
|
|
6
7
|
import { DESKTOP_SM } from "../../../../theme/common/breakpoints";
|
|
7
8
|
import { Filter } from "../Filter/filter";
|
|
9
|
+
import { buildRangeTag } from "../FilterTag/utils";
|
|
8
10
|
import { FilterTags } from "../FilterTags/filterTags";
|
|
9
11
|
import { CategoryViewsLabel, Filters as FilterList } from "./filters.styles";
|
|
10
12
|
/**
|
|
11
|
-
* Returns
|
|
13
|
+
* Returns filter tags for the given category view.
|
|
12
14
|
* @param categoryView - View model of category to display.
|
|
13
|
-
* @param onFilter - Function to execute on
|
|
14
|
-
* @returns Array of
|
|
15
|
+
* @param onFilter - Function to execute on selection or removal of category value.
|
|
16
|
+
* @returns Array of filter tags.
|
|
15
17
|
*/
|
|
16
|
-
function
|
|
18
|
+
function buildFilterTags(categoryView, onFilter) {
|
|
19
|
+
// Handle range category views
|
|
20
|
+
if (isRangeCategoryView(categoryView)) {
|
|
21
|
+
return buildRangeTag(categoryView, onFilter);
|
|
22
|
+
}
|
|
23
|
+
// Handle select category views.
|
|
17
24
|
const { key: categoryKey, values } = categoryView;
|
|
18
25
|
return values
|
|
19
26
|
.filter(({ selected }) => selected)
|
|
@@ -26,13 +33,13 @@ function buildSelectCategoryTags(categoryView, onFilter) {
|
|
|
26
33
|
});
|
|
27
34
|
}
|
|
28
35
|
/**
|
|
29
|
-
*
|
|
36
|
+
* Returns filter tags element for the given category view.
|
|
30
37
|
* @param categoryView - View model of category to display.
|
|
31
|
-
* @param onFilter - Function to execute on
|
|
32
|
-
* @returns Filter tags element
|
|
38
|
+
* @param onFilter - Function to execute on selection or removal of category value.
|
|
39
|
+
* @returns Filter tags element.
|
|
33
40
|
*/
|
|
34
41
|
function renderFilterTags(categoryView, onFilter) {
|
|
35
|
-
const tags =
|
|
42
|
+
const tags = buildFilterTags(categoryView, onFilter);
|
|
36
43
|
return React.createElement(FilterTags, { tags: tags });
|
|
37
44
|
}
|
|
38
45
|
export const Filters = ({ categoryFilters, closeAncestor, disabled = false, onFilter, trackFilterOpened, }) => {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fn } from "@storybook/test";
|
|
2
|
+
import { BIOLOGICAL_SEX, DONOR_COUNT, FILE_FORMAT, FILE_TYPE, GENUS_SPECIES, } from "./constants";
|
|
3
|
+
export const DEFAULT_ARGS = {
|
|
4
|
+
categoryFilters: [
|
|
5
|
+
{
|
|
6
|
+
categoryViews: [BIOLOGICAL_SEX, GENUS_SPECIES, DONOR_COUNT],
|
|
7
|
+
label: "Donor",
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
categoryViews: [FILE_FORMAT, FILE_TYPE],
|
|
11
|
+
label: "File",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
onFilter: fn(),
|
|
15
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RangeCategoryView } from "../../../../../common/categories/views/range/types";
|
|
2
|
+
import { SelectCategoryView } from "../../../../../common/entities";
|
|
3
|
+
/**
|
|
4
|
+
* Biological Sex select category view
|
|
5
|
+
*/
|
|
6
|
+
export declare const BIOLOGICAL_SEX: SelectCategoryView;
|
|
7
|
+
/**
|
|
8
|
+
* Genus Species select category view
|
|
9
|
+
*/
|
|
10
|
+
export declare const GENUS_SPECIES: SelectCategoryView;
|
|
11
|
+
/**
|
|
12
|
+
* Donor Count range category view
|
|
13
|
+
*/
|
|
14
|
+
export declare const DONOR_COUNT: RangeCategoryView;
|
|
15
|
+
/**
|
|
16
|
+
* File Format select category view
|
|
17
|
+
*/
|
|
18
|
+
export declare const FILE_FORMAT: SelectCategoryView;
|
|
19
|
+
/**
|
|
20
|
+
* File Type select category view
|
|
21
|
+
*/
|
|
22
|
+
export declare const FILE_TYPE: SelectCategoryView;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Biological Sex
|
|
3
|
+
*/
|
|
4
|
+
const MALE = {
|
|
5
|
+
count: 14,
|
|
6
|
+
key: "male",
|
|
7
|
+
label: "Male",
|
|
8
|
+
selected: false,
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Biological Sex
|
|
12
|
+
*/
|
|
13
|
+
const FEMALE = {
|
|
14
|
+
count: 12,
|
|
15
|
+
key: "female",
|
|
16
|
+
label: "Female",
|
|
17
|
+
selected: false,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Genus Species
|
|
21
|
+
*/
|
|
22
|
+
const HOMO_SAPIENS = {
|
|
23
|
+
count: 471,
|
|
24
|
+
key: "Homo sapiens",
|
|
25
|
+
label: "Homo sapiens",
|
|
26
|
+
selected: false,
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Genus Species
|
|
30
|
+
*/
|
|
31
|
+
const MUS_MUSCLES = {
|
|
32
|
+
count: 55,
|
|
33
|
+
key: "Mus musculus",
|
|
34
|
+
label: "Mus musculus",
|
|
35
|
+
selected: false,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* File Format
|
|
39
|
+
*/
|
|
40
|
+
const BAM = {
|
|
41
|
+
count: 7,
|
|
42
|
+
key: "bam",
|
|
43
|
+
label: "bam",
|
|
44
|
+
selected: false,
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* File Format
|
|
48
|
+
*/
|
|
49
|
+
const CSV = {
|
|
50
|
+
count: 5,
|
|
51
|
+
key: "csv",
|
|
52
|
+
label: "csv",
|
|
53
|
+
selected: false,
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* File Format
|
|
57
|
+
*/
|
|
58
|
+
const FASTQ = {
|
|
59
|
+
count: 38,
|
|
60
|
+
key: "fastq",
|
|
61
|
+
label: "fastq",
|
|
62
|
+
selected: false,
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* File Format
|
|
66
|
+
*/
|
|
67
|
+
const TSV = {
|
|
68
|
+
count: 3,
|
|
69
|
+
key: "tsv",
|
|
70
|
+
label: "tsv",
|
|
71
|
+
selected: false,
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* File Type
|
|
75
|
+
*/
|
|
76
|
+
const RAW = {
|
|
77
|
+
count: 1,
|
|
78
|
+
key: "raw",
|
|
79
|
+
label: "raw",
|
|
80
|
+
selected: false,
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* File Type
|
|
84
|
+
*/
|
|
85
|
+
const PROCESSED = {
|
|
86
|
+
count: 1,
|
|
87
|
+
key: "processed",
|
|
88
|
+
label: "processed",
|
|
89
|
+
selected: false,
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Biological Sex select category view
|
|
93
|
+
*/
|
|
94
|
+
export const BIOLOGICAL_SEX = {
|
|
95
|
+
key: "biologicalSex",
|
|
96
|
+
label: "Biological Sex",
|
|
97
|
+
values: [MALE, FEMALE],
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Genus Species select category view
|
|
101
|
+
*/
|
|
102
|
+
export const GENUS_SPECIES = {
|
|
103
|
+
key: "genusSpecies",
|
|
104
|
+
label: "Genus Species",
|
|
105
|
+
values: [HOMO_SAPIENS, MUS_MUSCLES],
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Donor Count range category view
|
|
109
|
+
*/
|
|
110
|
+
export const DONOR_COUNT = {
|
|
111
|
+
key: "Donor Count",
|
|
112
|
+
label: "Donor Count",
|
|
113
|
+
max: 200,
|
|
114
|
+
min: 10,
|
|
115
|
+
selectedMax: null,
|
|
116
|
+
selectedMin: null,
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* File Format select category view
|
|
120
|
+
*/
|
|
121
|
+
export const FILE_FORMAT = {
|
|
122
|
+
key: "fileFormat",
|
|
123
|
+
label: "File Format",
|
|
124
|
+
values: [BAM, CSV, FASTQ, TSV],
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* File Type select category view
|
|
128
|
+
*/
|
|
129
|
+
export const FILE_TYPE = {
|
|
130
|
+
isDisabled: true,
|
|
131
|
+
key: "fileType",
|
|
132
|
+
label: "File Type",
|
|
133
|
+
values: [RAW, PROCESSED],
|
|
134
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Filters } from "../filters";
|
|
4
|
+
import { DEFAULT_ARGS } from "./args";
|
|
5
|
+
const meta = {
|
|
6
|
+
component: Filters,
|
|
7
|
+
decorators: [
|
|
8
|
+
(Story) => (React.createElement(Box, { sx: { width: 264 } },
|
|
9
|
+
React.createElement(Story, null))),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
export const Default = {
|
|
14
|
+
args: DEFAULT_ARGS,
|
|
15
|
+
};
|
|
@@ -6,12 +6,12 @@ import { OnFilterFn } from "../../../../../../hooks/useCategoryFilter";
|
|
|
6
6
|
export type ItemSizeByItemKey = Map<string, number>;
|
|
7
7
|
export interface VariableSizeListProps {
|
|
8
8
|
autocompleteListProps: Omit<MListProps, "children">;
|
|
9
|
-
categoryViews: SelectCategoryView[];
|
|
10
9
|
height?: number;
|
|
11
10
|
itemSize?: number;
|
|
12
11
|
onFilter: OnFilterFn;
|
|
13
12
|
overscanCount?: ListProps["overscanCount"];
|
|
14
13
|
searchTerm: string;
|
|
14
|
+
selectCategoryViews: SelectCategoryView[];
|
|
15
15
|
width?: ListProps["width"];
|
|
16
16
|
}
|
|
17
17
|
export declare const VariableSizeList: React.ForwardRefExoticComponent<VariableSizeListProps & React.RefAttributes<HTMLUListElement>>;
|
|
@@ -33,8 +33,8 @@ const OuterElement = forwardRef(function OuterElement({ children, ...props }, re
|
|
|
33
33
|
return (React.createElement("div", { ref: ref, ...props },
|
|
34
34
|
React.createElement(MList, { ref: autocompleteListRef, style: { maxHeight: "none", padding: 0 }, ...autocompleteListProps }, children)));
|
|
35
35
|
});
|
|
36
|
-
export const VariableSizeList = forwardRef(function VariableSizeList({ autocompleteListProps,
|
|
37
|
-
const filteredItems = applyMenuFilter(
|
|
36
|
+
export const VariableSizeList = forwardRef(function VariableSizeList({ autocompleteListProps, height: initHeight = MAX_LIST_HEIGHT_PX, itemSize = LIST_ITEM_HEIGHT, onFilter, overscanCount = MAX_DISPLAYABLE_LIST_ITEMS * 2, searchTerm, selectCategoryViews, width = "100%", }, autocompleteListRef) {
|
|
37
|
+
const filteredItems = applyMenuFilter(selectCategoryViews, searchTerm);
|
|
38
38
|
let resizeRequired = true;
|
|
39
39
|
const desktopSmDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, DESKTOP_SM);
|
|
40
40
|
const { height: windowHeight } = useWindowResize();
|
|
@@ -81,13 +81,13 @@ export const VariableSizeList = forwardRef(function VariableSizeList({ autocompl
|
|
|
81
81
|
});
|
|
82
82
|
/**
|
|
83
83
|
* Filter categories' values by a search term and return model of list items
|
|
84
|
-
* @param
|
|
84
|
+
* @param selectCategoryViews - Select category views
|
|
85
85
|
* @param inputValue - Search term
|
|
86
86
|
* @returns array of objects representing list items to be rendered
|
|
87
87
|
*/
|
|
88
|
-
function applyMenuFilter(
|
|
88
|
+
function applyMenuFilter(selectCategoryViews, inputValue) {
|
|
89
89
|
const sortMatches = getSortMatchesFn(inputValue);
|
|
90
|
-
const filteredItems =
|
|
90
|
+
const filteredItems = selectCategoryViews.reduce((filteredItems, category) => {
|
|
91
91
|
if (!category.isDisabled) {
|
|
92
92
|
const categoryValueKeyPrefix = "value_" + category.key.replaceAll(";", ";;") + ";_"; // Terminating the category key with a semicolon (and escaping preceding semicolons) ensures a unique prefix
|
|
93
93
|
const filteredCategoryValues = sortMatches(category.values).map((match) => ({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Checkbox, ListItemButton, ListItemText, ListSubheader, Typography, } from "@mui/material";
|
|
2
2
|
import React, { useEffect, useRef } from "react";
|
|
3
|
+
import { VIEW_KIND } from "../../../../../../common/categories/views/types";
|
|
3
4
|
import { TEST_IDS } from "../../../../../../tests/testIds";
|
|
4
5
|
import { TEXT_BODY_SMALL_400 } from "../../../../../../theme/common/typography";
|
|
5
6
|
import { CheckedIcon } from "../../../../../common/CustomIcon/components/CheckedIcon/checkedIcon";
|
|
@@ -19,7 +20,7 @@ export default function VariableSizeListItem({ item, onFilter, onUpdateItemSizeB
|
|
|
19
20
|
}, [key, onUpdateItemSizeByItemKey]);
|
|
20
21
|
if (item.type === ITEM_TYPE.VALUE) {
|
|
21
22
|
const { categoryKey, matchRanges, value: { count, key: valueKey, label, selected }, } = item;
|
|
22
|
-
return (React.createElement(ListItemButton, { "data-testid": TEST_IDS.FILTER_ITEM, ref: setRef, key: key, onClick: () => onFilter(categoryKey, valueKey, !selected, undefined, searchTerm), selected: selected, style: style },
|
|
23
|
+
return (React.createElement(ListItemButton, { "data-testid": TEST_IDS.FILTER_ITEM, ref: setRef, key: key, onClick: () => onFilter(categoryKey, valueKey, !selected, undefined, VIEW_KIND.SELECT, searchTerm), selected: selected, style: style },
|
|
23
24
|
React.createElement(Checkbox, { checked: selected, checkedIcon: React.createElement(CheckedIcon, null), icon: React.createElement(UncheckedIcon, null) }),
|
|
24
25
|
React.createElement(ListItemText, { disableTypography: true, primary: React.createElement(HighlightedLabel, { label: label, ranges: matchRanges, testId: TEST_IDS.FILTER_TERM }), secondary: React.createElement(Typography, { color: "ink.light", "data-testid": TEST_IDS.FILTER_COUNT, variant: TEXT_BODY_SMALL_400 }, count) })));
|
|
25
26
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { CategoryView } from "../../../../common/categories/views/types";
|
|
2
3
|
import { SelectCategoryView } from "../../../../common/entities";
|
|
3
4
|
import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
|
|
4
5
|
export interface SearchAllFiltersProps {
|
|
5
|
-
categoryViews:
|
|
6
|
+
categoryViews: CategoryView[];
|
|
6
7
|
drawerOpen?: boolean;
|
|
7
8
|
onFilter: OnFilterFn;
|
|
8
9
|
}
|
|
9
10
|
interface ListboxContextValue {
|
|
10
|
-
categoryViews: SelectCategoryView[];
|
|
11
11
|
onClearSearch: () => void;
|
|
12
12
|
onCloseSearch: () => void;
|
|
13
13
|
onFilter: OnFilterFn;
|
|
14
14
|
open: boolean;
|
|
15
15
|
searchTerm: string;
|
|
16
|
+
selectCategoryViews: SelectCategoryView[];
|
|
16
17
|
}
|
|
17
18
|
export declare const ListboxContext: React.Context<ListboxContextValue>;
|
|
18
19
|
export declare const SearchAllFilters: ({ categoryViews, drawerOpen, onFilter, }: SearchAllFiltersProps) => JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { createContext, useContext, useEffect, useRef, useState, } from "react";
|
|
2
|
+
import { isSelectCategoryView } from "../../../../common/categories/views/select/typeGuards";
|
|
2
3
|
import { SELECTOR } from "../../../../common/selectors";
|
|
3
4
|
import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../hooks/useBreakpointHelper";
|
|
4
5
|
import { TEST_IDS } from "../../../../tests/testIds";
|
|
@@ -13,25 +14,26 @@ import { VariableSizeList } from "./components/VariableSizeList/VariableSizeList
|
|
|
13
14
|
import { Autocomplete } from "./searchAllFilters.styles";
|
|
14
15
|
const renderInput = (params) => (React.createElement(SearchAllFiltersSearch, { ...params }));
|
|
15
16
|
export const ListboxContext = createContext({
|
|
16
|
-
categoryViews: [],
|
|
17
17
|
onClearSearch: () => undefined,
|
|
18
18
|
onCloseSearch: () => undefined,
|
|
19
19
|
onFilter: () => undefined,
|
|
20
20
|
open: false,
|
|
21
21
|
searchTerm: "",
|
|
22
|
+
selectCategoryViews: [],
|
|
22
23
|
});
|
|
23
24
|
const Listbox = React.forwardRef(function Listbox(props, ref) {
|
|
24
25
|
props = Object.assign({}, props, {
|
|
25
26
|
children: undefined, // Content is controlled by VariableSizeList
|
|
26
27
|
});
|
|
27
|
-
const {
|
|
28
|
-
return (React.createElement(VariableSizeList, { autocompleteListProps: props,
|
|
28
|
+
const { onFilter, searchTerm, selectCategoryViews } = useContext(ListboxContext);
|
|
29
|
+
return (React.createElement(VariableSizeList, { autocompleteListProps: props, onFilter: onFilter, ref: ref, searchTerm: searchTerm, selectCategoryViews: selectCategoryViews }));
|
|
29
30
|
});
|
|
30
31
|
export const SearchAllFilters = ({ categoryViews, drawerOpen = false, onFilter, }) => {
|
|
31
32
|
const desktopSmUp = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
|
|
32
33
|
const autocompleteRef = useRef(null);
|
|
33
34
|
const [open, setOpen] = useState(false);
|
|
34
35
|
const [searchTerm, setSearchTerm] = useState("");
|
|
36
|
+
const selectCategoryViews = categoryViews.filter((view) => isSelectCategoryView(view));
|
|
35
37
|
// Handles background scroll action (desktop only).
|
|
36
38
|
const handleBackgroundScroll = (overflowStyle) => {
|
|
37
39
|
if (desktopSmUp) {
|
|
@@ -79,12 +81,12 @@ export const SearchAllFilters = ({ categoryViews, drawerOpen = false, onFilter,
|
|
|
79
81
|
}
|
|
80
82
|
}, [drawerOpen]);
|
|
81
83
|
return (React.createElement(ListboxContext.Provider, { value: {
|
|
82
|
-
categoryViews,
|
|
83
84
|
onClearSearch,
|
|
84
85
|
onCloseSearch,
|
|
85
86
|
onFilter,
|
|
86
87
|
open,
|
|
87
88
|
searchTerm,
|
|
89
|
+
selectCategoryViews,
|
|
88
90
|
} },
|
|
89
91
|
React.createElement(Autocomplete, { clearOnBlur: desktopSmUp, "data-testid": TEST_IDS.SEARCH_ALL_FILTERS, filterOptions: (options) => options, freeSolo: true, ListboxComponent: Listbox, onBlur: desktopSmUp ? onCloseSearch : undefined, onClose: desktopSmUp ? onCloseSearch : undefined, onFocus: onOpenSearch, onOpen: onOpen, open: open, options: [""], PopperComponent: AutocompletePopper, ref: autocompleteRef, renderInput: (props) => renderInput({
|
|
90
92
|
...props,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Checkbox, ListItemButton, ListItemText, Typography, } from "@mui/material";
|
|
2
2
|
import React, { useEffect, useRef } from "react";
|
|
3
|
+
import { VIEW_KIND } from "../../../../common/categories/views/types";
|
|
3
4
|
import { SELECT_CATEGORY_KEY } from "../../../../providers/exploreState/constants";
|
|
4
5
|
import { TEST_IDS } from "../../../../tests/testIds";
|
|
5
6
|
import { TEXT_BODY_SMALL_400 } from "../../../../theme/common/typography";
|
|
@@ -15,7 +16,7 @@ export default function VariableSizeListItem({ categoryKey, categorySection, mat
|
|
|
15
16
|
onUpdateItemSizeByItemKey(key, listItemRef.current?.clientHeight || 0);
|
|
16
17
|
}, [key, onUpdateItemSizeByItemKey]);
|
|
17
18
|
const handleItemClicked = () => {
|
|
18
|
-
onFilter(categoryKey, key, !selected, categorySection);
|
|
19
|
+
onFilter(categoryKey, key, !selected, categorySection, VIEW_KIND.SELECT);
|
|
19
20
|
};
|
|
20
21
|
return (React.createElement(ListItemButton, { "data-testid": TEST_IDS.FILTER_ITEM, ref: listItemRef, onClick: handleItemClicked, selected: selected, style: style },
|
|
21
22
|
React.createElement(Checkbox, { checked: selected, checkedIcon: React.createElement(CheckedIcon, null), icon: React.createElement(UncheckedIcon, null) }),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isSelectCategoryView } from "../../../../../../common/categories/views/select/typeGuards";
|
|
1
2
|
/**
|
|
2
3
|
* Returns the set of select category views that have chart view enabled.
|
|
3
4
|
* @param categoryFilters - Category filters.
|
|
@@ -6,6 +7,7 @@
|
|
|
6
7
|
export function getSelectCategoryViews(categoryFilters) {
|
|
7
8
|
return categoryFilters
|
|
8
9
|
.flatMap(({ categoryViews }) => categoryViews)
|
|
10
|
+
.filter(isSelectCategoryView)
|
|
9
11
|
.filter(({ enableChartView = true }) => enableChartView)
|
|
10
12
|
.filter(({ values }) => values.length > 0);
|
|
11
13
|
}
|
|
@@ -10,6 +10,7 @@ import { DEFAULT_PAGINATION_STATE } from "../../../providers/exploreState/initia
|
|
|
10
10
|
import { arrIncludesSome } from "../../Table/columnDef/columnFilters/filterFn";
|
|
11
11
|
import { COLUMN_DEF } from "../../Table/common/columnDef";
|
|
12
12
|
import { buildCategoryViews, getFacetedUniqueValuesWithArrayValues, getTableStatePagination, isClientFilteringEnabled, sortingFn, } from "../../Table/common/utils";
|
|
13
|
+
import { getFacetedMinMaxValues } from "../../Table/featureOptions/facetedColumn/getFacetedMinMaxValues";
|
|
13
14
|
import { ROW_POSITION } from "../../Table/features/RowPosition/constants";
|
|
14
15
|
import { ROW_PREVIEW } from "../../Table/features/RowPreview/constants";
|
|
15
16
|
import { buildBaseColumnDef } from "../../TableCreator/common/utils";
|
|
@@ -105,6 +106,9 @@ export const useTable = () => {
|
|
|
105
106
|
enableMultiSort: clientFiltering, // TODO(cc) move to sorting options; default to false and let the table options in config flag this value.
|
|
106
107
|
filterFns: { arrIncludesSome },
|
|
107
108
|
getCoreRowModel: getCoreRowModel(),
|
|
109
|
+
getFacetedMinMaxValues: clientFiltering
|
|
110
|
+
? getFacetedMinMaxValues()
|
|
111
|
+
: undefined,
|
|
108
112
|
getFacetedRowModel: clientFiltering ? getFacetedRowModel() : undefined,
|
|
109
113
|
getFacetedUniqueValues: clientFiltering
|
|
110
114
|
? getFacetedUniqueValuesWithArrayValues()
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RowData } from "@tanstack/react-table";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a row has a specific key.
|
|
4
|
+
* Useful for generic accessor functions.
|
|
5
|
+
* @param row - The row to check.
|
|
6
|
+
* @param key - The key to check.
|
|
7
|
+
* @returns True if the row has the specified key, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rowHasKey<T extends RowData, K extends PropertyKey, TValue>(row: T, key: K): row is T & Record<K, TValue>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if a row has a specific key.
|
|
3
|
+
* Useful for generic accessor functions.
|
|
4
|
+
* @param row - The row to check.
|
|
5
|
+
* @param key - The key to check.
|
|
6
|
+
* @returns True if the row has the specified key, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export function rowHasKey(row, key) {
|
|
9
|
+
return row != null && typeof row === "object" && key in row;
|
|
10
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cell, Column, ColumnFiltersState, PaginationState, Row, RowData, Table } from "@tanstack/react-table";
|
|
2
|
-
import {
|
|
2
|
+
import { Category } from "../../../common/categories/models/types";
|
|
3
3
|
import { ExploreMode } from "../../../hooks/useExploreMode/types";
|
|
4
4
|
/**
|
|
5
5
|
* Internal model of a category term count keyed by category term.
|
|
@@ -15,7 +15,7 @@ type PinnedCell<T extends RowData> = [Cell<T, unknown>, number];
|
|
|
15
15
|
* @param columnFilters - Column filters state.
|
|
16
16
|
* @returns Array of category views objects.
|
|
17
17
|
*/
|
|
18
|
-
export declare function buildCategoryViews<T extends RowData>(columns: Column<T>[], columnFilters: ColumnFiltersState):
|
|
18
|
+
export declare function buildCategoryViews<T extends RowData>(columns: Column<T>[], columnFilters: ColumnFiltersState): Category[];
|
|
19
19
|
/**
|
|
20
20
|
* Returns filtered entity results as a blob.
|
|
21
21
|
* @param rows - Table rows.
|
|
@@ -10,23 +10,38 @@ import { COLUMN_IDENTIFIER } from "./columnIdentifier";
|
|
|
10
10
|
export function buildCategoryViews(columns, columnFilters) {
|
|
11
11
|
const categoryViews = [];
|
|
12
12
|
for (const column of columns) {
|
|
13
|
-
const { columnDef, getCanFilter, getFacetedUniqueValues, id } = column;
|
|
13
|
+
const { columnDef, getCanFilter, getFacetedMinMaxValues, getFacetedUniqueValues, id, } = column;
|
|
14
14
|
const { header: columnHeader } = columnDef;
|
|
15
15
|
if (getCanFilter()) {
|
|
16
|
-
updateFacetedUniqueValues(getFacetedUniqueValues(), columnFilters, id);
|
|
17
16
|
const key = id;
|
|
18
17
|
const label = columnHeader;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
// Handle range categories.
|
|
19
|
+
if (columnDef.filterFn === "inNumberRange") {
|
|
20
|
+
const minMax = getFacetedMinMaxValues();
|
|
21
|
+
categoryViews.push({
|
|
22
|
+
key,
|
|
23
|
+
label,
|
|
24
|
+
max: minMax?.[1] || Infinity,
|
|
25
|
+
min: minMax?.[0] || -Infinity,
|
|
26
|
+
selectedMax: null, // Selected state updated in reducer.
|
|
27
|
+
selectedMin: null, // Selected state updated in reducer.
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Handle select categories.
|
|
31
|
+
if (columnDef.filterFn === "arrIncludesSome") {
|
|
32
|
+
updateFacetedUniqueValues(getFacetedUniqueValues(), columnFilters, id);
|
|
33
|
+
const values = [...getFacetedUniqueValues()].map(([value, count]) => ({
|
|
34
|
+
count,
|
|
35
|
+
key: value,
|
|
36
|
+
label: String(value ?? ""),
|
|
37
|
+
selected: false, // Selected state updated in reducer.
|
|
38
|
+
}));
|
|
39
|
+
categoryViews.push({
|
|
40
|
+
key,
|
|
41
|
+
label,
|
|
42
|
+
values: values,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
30
45
|
}
|
|
31
46
|
}
|
|
32
47
|
return categoryViews;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LinkProps } from "@mui/material";
|
|
2
|
+
import { CellContext, RowData } from "@tanstack/react-table";
|
|
3
|
+
import { BaseComponentProps } from "components/types";
|
|
4
|
+
export declare const LinkCell: <T extends RowData, TValue extends LinkProps = LinkProps>({ getValue, }: BaseComponentProps & CellContext<T, TValue>) => JSX.Element | null;
|