@databiosphere/findable-ui 29.0.2 → 31.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 +35 -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 +8 -23
- package/lib/components/DataDictionary/components/Entities/entities.d.ts +3 -1
- package/lib/components/DataDictionary/components/Entities/entities.js +1 -1
- package/lib/components/DataDictionary/components/Entities/types.d.ts +5 -5
- package/lib/components/DataDictionary/components/Entity/entity.d.ts +3 -1
- package/lib/components/DataDictionary/components/Entity/entity.js +6 -6
- package/lib/components/DataDictionary/components/Entity/types.d.ts +5 -5
- package/lib/components/DataDictionary/components/Outline/utils.d.ts +3 -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/components/Table/hook.d.ts +3 -3
- package/lib/components/DataDictionary/components/Table/hook.js +3 -1
- package/lib/components/DataDictionary/components/Table/options/core/constants.d.ts +2 -3
- package/lib/components/DataDictionary/components/Table/options/hook.d.ts +2 -2
- package/lib/components/DataDictionary/components/Table/options/sorting/constants.d.ts +2 -3
- package/lib/components/DataDictionary/components/Table/table.d.ts +2 -1
- package/lib/components/DataDictionary/components/Table/table.js +1 -1
- package/lib/components/DataDictionary/components/Table/types.d.ts +3 -4
- package/lib/components/DataDictionary/dataDictionary.d.ts +3 -1
- package/lib/components/DataDictionary/dataDictionary.styles.js +2 -3
- package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.d.ts +3 -1
- package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +5 -5
- 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/MarkdownRenderer/components/Anchor/anchor.d.ts +19 -0
- package/lib/components/MarkdownRenderer/components/Anchor/anchor.js +21 -0
- package/lib/components/MarkdownRenderer/components/Table/table.d.ts +3 -0
- package/lib/components/MarkdownRenderer/components/Table/table.js +5 -0
- package/lib/components/MarkdownRenderer/components/Table/table.styles.d.ts +4 -0
- package/lib/components/MarkdownRenderer/components/Table/table.styles.js +40 -0
- package/lib/components/MarkdownRenderer/constants.d.ts +2 -0
- package/lib/components/MarkdownRenderer/constants.js +6 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.d.ts +2 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.js +45 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.styles.d.ts +4 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.styles.js +13 -0
- package/lib/components/MarkdownRenderer/types.d.ts +6 -0
- package/lib/components/MarkdownRenderer/types.js +1 -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 +4 -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/components/TableCell/components/MarkdownCell/markdownCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.js +13 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.js +30 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/args.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/args.js +10 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/constants.d.ts +5 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/constants.js +9 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.d.ts +7 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.js +25 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.js +1 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/types.js +1 -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/styles/common/mui/typography.js +1 -0
- 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 +7 -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 +8 -26
- package/src/components/DataDictionary/components/Entities/entities.tsx +7 -5
- package/src/components/DataDictionary/components/Entities/types.ts +5 -9
- package/src/components/DataDictionary/components/Entity/entity.tsx +9 -7
- package/src/components/DataDictionary/components/Entity/types.ts +5 -9
- package/src/components/DataDictionary/components/Outline/utils.ts +5 -2
- 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/components/Table/hook.ts +16 -8
- package/src/components/DataDictionary/components/Table/options/core/constants.ts +2 -3
- package/src/components/DataDictionary/components/Table/options/hook.ts +3 -3
- package/src/components/DataDictionary/components/Table/options/sorting/constants.ts +2 -6
- package/src/components/DataDictionary/components/Table/table.tsx +4 -1
- package/src/components/DataDictionary/components/Table/types.ts +3 -4
- package/src/components/DataDictionary/dataDictionary.styles.ts +2 -3
- package/src/components/DataDictionary/dataDictionary.tsx +4 -2
- package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +9 -2
- package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +5 -9
- 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/MarkdownRenderer/components/Anchor/anchor.tsx +34 -0
- package/src/components/MarkdownRenderer/components/Table/table.styles.ts +41 -0
- package/src/components/MarkdownRenderer/components/Table/table.tsx +13 -0
- package/src/components/MarkdownRenderer/constants.ts +8 -0
- package/src/components/MarkdownRenderer/markdownRenderer.styles.ts +16 -0
- package/src/components/MarkdownRenderer/markdownRenderer.tsx +62 -0
- package/src/components/MarkdownRenderer/types.ts +7 -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 +16 -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/components/TableCell/components/MarkdownCell/markdownCell.styles.ts +31 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/markdownCell.tsx +29 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/args.ts +17 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/constants.ts +11 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.tsx +37 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/types.ts +4 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/types.ts +3 -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/styles/common/mui/typography.ts +1 -0
- 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/tests/markdownCell.test.tsx +53 -0
- package/types/data-explorer-ui.d.ts +2 -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,50 @@
|
|
|
1
|
+
import { mixed, number, object } from "yup";
|
|
2
|
+
import { FIELD_NAME } from "./constants";
|
|
3
|
+
import { RANGE_OPERATOR } from "./types";
|
|
4
|
+
export const SCHEMA = object({
|
|
5
|
+
[FIELD_NAME.MAX]: number()
|
|
6
|
+
.typeError("Value must be a number")
|
|
7
|
+
.when(FIELD_NAME.RANGE_OPERATOR, {
|
|
8
|
+
is: RANGE_OPERATOR.BETWEEN,
|
|
9
|
+
then: (schema) => schema.notRequired(),
|
|
10
|
+
})
|
|
11
|
+
.when(FIELD_NAME.RANGE_OPERATOR, {
|
|
12
|
+
is: RANGE_OPERATOR.LESS_THAN,
|
|
13
|
+
then: (schema) => schema.required("Value is required"),
|
|
14
|
+
})
|
|
15
|
+
.when(FIELD_NAME.RANGE_OPERATOR, {
|
|
16
|
+
is: RANGE_OPERATOR.GREATER_THAN,
|
|
17
|
+
then: (schema) => schema.notRequired(),
|
|
18
|
+
}),
|
|
19
|
+
[FIELD_NAME.MIN]: number()
|
|
20
|
+
.typeError("Value must be a number")
|
|
21
|
+
.when(FIELD_NAME.RANGE_OPERATOR, {
|
|
22
|
+
is: RANGE_OPERATOR.BETWEEN,
|
|
23
|
+
then: (schema) => schema
|
|
24
|
+
.notRequired()
|
|
25
|
+
.test("min-less-than-max", "Min must be less than max", function (min) {
|
|
26
|
+
const max = this.parent[FIELD_NAME.MAX];
|
|
27
|
+
// If either value is not a number, skip validation.
|
|
28
|
+
if (!min || !max)
|
|
29
|
+
return true;
|
|
30
|
+
if (Number.isNaN(min) || Number.isNaN(max))
|
|
31
|
+
return true;
|
|
32
|
+
return min < max;
|
|
33
|
+
})
|
|
34
|
+
.test("at-least-min-or-max", "Min or Max is required", function (min) {
|
|
35
|
+
const max = this.parent[FIELD_NAME.MAX];
|
|
36
|
+
// If both values are null, validation fails.
|
|
37
|
+
return !(min === null && max === null);
|
|
38
|
+
}),
|
|
39
|
+
})
|
|
40
|
+
.when(FIELD_NAME.RANGE_OPERATOR, {
|
|
41
|
+
is: RANGE_OPERATOR.LESS_THAN,
|
|
42
|
+
then: (schema) => schema.notRequired(),
|
|
43
|
+
})
|
|
44
|
+
.when(FIELD_NAME.RANGE_OPERATOR, {
|
|
45
|
+
is: RANGE_OPERATOR.GREATER_THAN,
|
|
46
|
+
otherwise: (schema) => schema.notRequired(),
|
|
47
|
+
then: (schema) => schema.required("Value is required"),
|
|
48
|
+
}),
|
|
49
|
+
[FIELD_NAME.RANGE_OPERATOR]: mixed().default(RANGE_OPERATOR.BETWEEN),
|
|
50
|
+
});
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import { ToggleButtonGroupProps } from "@mui/material";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { OnFilterFn } from "hooks/useCategoryFilter";
|
|
3
|
+
import { FormEventHandler } from "react";
|
|
4
|
+
import { FIELD_NAME } from "./constants";
|
|
5
|
+
export type FieldErrors = Partial<Record<FieldName, string>>;
|
|
6
|
+
export type FieldName = (typeof FIELD_NAME)[keyof typeof FIELD_NAME];
|
|
7
|
+
export interface FieldValues {
|
|
8
|
+
max: FormDataEntryValue | null;
|
|
9
|
+
min: FormDataEntryValue | null;
|
|
10
|
+
rangeOperator: RANGE_OPERATOR;
|
|
11
|
+
}
|
|
12
|
+
export type OnSubmitFn = OnFilterFn;
|
|
13
|
+
export type OnSubmitParams = Parameters<OnSubmitFn>;
|
|
14
|
+
export declare enum RANGE_OPERATOR {
|
|
15
|
+
BETWEEN = "between",
|
|
16
|
+
GREATER_THAN = "greaterThan",
|
|
17
|
+
LESS_THAN = "lessThan"
|
|
18
|
+
}
|
|
19
|
+
export type SubmitParams = {
|
|
20
|
+
categoryKey: OnSubmitParams[0];
|
|
21
|
+
categorySection?: OnSubmitParams[3];
|
|
22
|
+
};
|
|
4
23
|
export interface UseFilterRange {
|
|
24
|
+
clearErrors: () => void;
|
|
25
|
+
formState: {
|
|
26
|
+
errors: FieldErrors;
|
|
27
|
+
};
|
|
28
|
+
handleSubmit: (onSubmit: OnSubmitFn, parameters: SubmitParams) => FormEventHandler;
|
|
5
29
|
onChange: ToggleButtonGroupProps["onChange"];
|
|
6
|
-
onSubmit: (e: FormEvent) => void;
|
|
7
30
|
value: RANGE_OPERATOR;
|
|
8
31
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FieldValues, RANGE_OPERATOR } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the min and max field values from a form.
|
|
4
|
+
* @param e - The form element to retrieve values from.
|
|
5
|
+
* @param rangeOperator - The range operator value in use.
|
|
6
|
+
* @returns The values from the form.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getFormValues(e: HTMLFormElement, rangeOperator: RANGE_OPERATOR): FieldValues;
|
|
9
|
+
/**
|
|
10
|
+
* Parses a form data value null or empty string to null.
|
|
11
|
+
* Schema validation will handle the rest.
|
|
12
|
+
* @param value - The value to parse.
|
|
13
|
+
* @returns The parsed value, or null if the value is null or empty string.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseMinMaxValue(value: FormDataEntryValue | null): FormDataEntryValue | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the min and max field values from a form.
|
|
3
|
+
* @param e - The form element to retrieve values from.
|
|
4
|
+
* @param rangeOperator - The range operator value in use.
|
|
5
|
+
* @returns The values from the form.
|
|
6
|
+
*/
|
|
7
|
+
export function getFormValues(e, rangeOperator) {
|
|
8
|
+
const formData = new FormData(e);
|
|
9
|
+
const fieldValues = {};
|
|
10
|
+
fieldValues.max = parseMinMaxValue(formData.get("max"));
|
|
11
|
+
fieldValues.min = parseMinMaxValue(formData.get("min"));
|
|
12
|
+
fieldValues.rangeOperator = rangeOperator;
|
|
13
|
+
return fieldValues;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parses a form data value null or empty string to null.
|
|
17
|
+
* Schema validation will handle the rest.
|
|
18
|
+
* @param value - The value to parse.
|
|
19
|
+
* @returns The parsed value, or null if the value is null or empty string.
|
|
20
|
+
*/
|
|
21
|
+
export function parseMinMaxValue(value) {
|
|
22
|
+
if (value === null || value === "")
|
|
23
|
+
return null;
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { fn } from "@storybook/test";
|
|
2
|
+
export const DEFAULT_ARGS = {
|
|
3
|
+
categoryKey: "Weight",
|
|
4
|
+
categoryLabel: "Weight",
|
|
5
|
+
isFilterDrawer: false,
|
|
6
|
+
max: 2100,
|
|
7
|
+
min: 100,
|
|
8
|
+
onCloseFilter: fn(),
|
|
9
|
+
onFilter: fn(),
|
|
10
|
+
selectedMax: null,
|
|
11
|
+
selectedMin: null,
|
|
12
|
+
unit: "kg",
|
|
13
|
+
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { RangeCategoryView } from "../../../../common/categories/views/range/types";
|
|
2
|
+
import { CategoryKey } from "../../../../common/entities";
|
|
3
|
+
import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
|
|
1
4
|
import { BaseComponentProps } from "../../../types";
|
|
2
|
-
export interface FilterRangeProps extends BaseComponentProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export interface FilterRangeProps extends Omit<RangeCategoryView, "key" | "label">, BaseComponentProps {
|
|
6
|
+
categoryKey: CategoryKey;
|
|
7
|
+
categoryLabel: string;
|
|
8
|
+
categorySection?: string;
|
|
9
|
+
isFilterDrawer: boolean;
|
|
10
|
+
onCloseFilter: () => void;
|
|
11
|
+
onFilter: OnFilterFn;
|
|
8
12
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RangeCategoryView } from "../../../../common/categories/views/range/types";
|
|
2
|
+
import { RANGE_OPERATOR } from "./hooks/UseFilterRange/types";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the range operator based on the selected values.
|
|
5
|
+
* @param categoryView - View model of range category.
|
|
6
|
+
* @returns The range operator or undefined if no valid range is selected.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getRangeOperator(categoryView: Pick<RangeCategoryView, "selectedMax" | "selectedMin">): RANGE_OPERATOR | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RANGE_OPERATOR } from "./hooks/UseFilterRange/types";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the range operator based on the selected values.
|
|
4
|
+
* @param categoryView - View model of range category.
|
|
5
|
+
* @returns The range operator or undefined if no valid range is selected.
|
|
6
|
+
*/
|
|
7
|
+
export function getRangeOperator(categoryView) {
|
|
8
|
+
const { selectedMax, selectedMin } = categoryView;
|
|
9
|
+
if (selectedMin && selectedMax)
|
|
10
|
+
return RANGE_OPERATOR.BETWEEN;
|
|
11
|
+
if (selectedMin)
|
|
12
|
+
return RANGE_OPERATOR.GREATER_THAN;
|
|
13
|
+
if (selectedMax)
|
|
14
|
+
return RANGE_OPERATOR.LESS_THAN;
|
|
15
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { FilterTag } from "../filterTag";
|
|
3
|
+
export declare const DEFAULT_ARGS: ComponentProps<typeof FilterTag>;
|
|
4
|
+
export declare const WITH_ELLIPSIS_ARGS: ComponentProps<typeof FilterTag>;
|
|
5
|
+
export declare const WITH_RANGE_ARGS: ComponentProps<typeof FilterTag>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fn } from "@storybook/test";
|
|
2
|
+
import { LOREM_IPSUM } from "storybook/loremIpsum";
|
|
3
|
+
export const DEFAULT_ARGS = {
|
|
4
|
+
label: "male",
|
|
5
|
+
onRemove: fn(),
|
|
6
|
+
superseded: false,
|
|
7
|
+
};
|
|
8
|
+
export const WITH_ELLIPSIS_ARGS = {
|
|
9
|
+
label: LOREM_IPSUM.LONG,
|
|
10
|
+
onRemove: fn(),
|
|
11
|
+
superseded: false,
|
|
12
|
+
};
|
|
13
|
+
export const WITH_RANGE_ARGS = {
|
|
14
|
+
label: "10 - 34",
|
|
15
|
+
onRemove: fn(),
|
|
16
|
+
superseded: false,
|
|
17
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { FilterTag } from "../filterTag";
|
|
3
|
+
declare const meta: Meta<typeof FilterTag>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithEllipsis: Story;
|
|
8
|
+
export declare const WithRange: Story;
|
|
@@ -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) => ({
|