@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
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { CategoryConfig } from "../common/categories/config/types";
|
|
2
|
+
import { findSelectCategoryConfig } from "../common/categories/config/utils";
|
|
3
|
+
import { isRangeCategory } from "../common/categories/models/range/typeGuards";
|
|
4
|
+
import { buildNextRangeFilterState } from "../common/categories/models/range/utils";
|
|
5
|
+
import { buildNextSelectFilterState } from "../common/categories/models/select/utils";
|
|
6
|
+
import { Category } from "../common/categories/models/types";
|
|
7
|
+
import { buildRangeCategoryView } from "../common/categories/views/range/utils";
|
|
8
|
+
import { CategoryView, VIEW_KIND } from "../common/categories/views/types";
|
|
1
9
|
import { COLLATOR_CASE_INSENSITIVE } from "../common/constants";
|
|
2
10
|
import {
|
|
3
11
|
CategoryKey,
|
|
@@ -9,22 +17,12 @@ import {
|
|
|
9
17
|
SelectCategoryView,
|
|
10
18
|
SelectedFilter,
|
|
11
19
|
} from "../common/entities";
|
|
12
|
-
import { CategoryConfig } from "../config/entities";
|
|
13
20
|
|
|
14
21
|
/**
|
|
15
22
|
* State backing filter functionality and calculations. Converted to view model for display.
|
|
16
23
|
*/
|
|
17
24
|
export type FilterState = Filters;
|
|
18
25
|
|
|
19
|
-
/**
|
|
20
|
-
* Shape of return value from this useCategoryFilter hook.
|
|
21
|
-
*/
|
|
22
|
-
export interface FilterInstance {
|
|
23
|
-
categories: SelectCategoryView[];
|
|
24
|
-
filter: FilterState;
|
|
25
|
-
onFilter: OnFilterFn;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
26
|
/**
|
|
29
27
|
* Function invoked when selected state of a category value is toggled or range is selected.
|
|
30
28
|
*/
|
|
@@ -33,6 +31,7 @@ export type OnFilterFn = (
|
|
|
33
31
|
selectedCategoryValue: CategoryValueKey,
|
|
34
32
|
selected: boolean,
|
|
35
33
|
categorySection?: string,
|
|
34
|
+
viewKind?: VIEW_KIND,
|
|
36
35
|
searchTerm?: string
|
|
37
36
|
) => void;
|
|
38
37
|
|
|
@@ -62,27 +61,30 @@ function buildCategoryValueView(
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
|
-
* Build the view-specific model of the given category, including the category label pulled from the config.
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
64
|
+
* Build the view-specific model of the given select category, including the category label pulled from the config.
|
|
65
|
+
* @param selectCategory - The select category to build a view model of.
|
|
66
|
+
* @param selectCategoryValueViews - Set of select category value view models for the given category.
|
|
68
67
|
* @param categoryConfigs - Category configs indicating accept list as well as label configuration.
|
|
69
|
-
* @returns Full built category
|
|
68
|
+
* @returns Full built select category view, ready for display.
|
|
70
69
|
*/
|
|
71
70
|
function buildCategoryView(
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
selectCategory: SelectCategory,
|
|
72
|
+
selectCategoryValueViews: SelectCategoryValueView[],
|
|
74
73
|
categoryConfigs: CategoryConfig[]
|
|
75
74
|
): SelectCategoryView {
|
|
76
|
-
const
|
|
75
|
+
const selectCategoryConfig = findSelectCategoryConfig(
|
|
76
|
+
selectCategory.key,
|
|
77
|
+
categoryConfigs
|
|
78
|
+
);
|
|
77
79
|
const mapSelectCategoryValue =
|
|
78
|
-
|
|
80
|
+
selectCategoryConfig?.mapSelectCategoryValue || getSelectCategoryValue;
|
|
79
81
|
return {
|
|
80
|
-
annotation:
|
|
81
|
-
enableChartView:
|
|
82
|
+
annotation: selectCategoryConfig?.annotation,
|
|
83
|
+
enableChartView: selectCategoryConfig?.enableChartView,
|
|
82
84
|
isDisabled: false,
|
|
83
|
-
key:
|
|
84
|
-
label: getCategoryLabel(
|
|
85
|
-
values:
|
|
85
|
+
key: selectCategory.key,
|
|
86
|
+
label: getCategoryLabel(selectCategory.key, selectCategoryConfig),
|
|
87
|
+
values: selectCategoryValueViews.map(mapSelectCategoryValue),
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -94,10 +96,10 @@ function buildCategoryView(
|
|
|
94
96
|
* @returns Array of category view objects.
|
|
95
97
|
*/
|
|
96
98
|
export function buildCategoryViews(
|
|
97
|
-
categories:
|
|
99
|
+
categories: Category[],
|
|
98
100
|
categoryConfigs: CategoryConfig[] | undefined,
|
|
99
101
|
filterState: FilterState
|
|
100
|
-
):
|
|
102
|
+
): CategoryView[] {
|
|
101
103
|
if (!categories || !categoryConfigs) {
|
|
102
104
|
return [];
|
|
103
105
|
}
|
|
@@ -115,7 +117,16 @@ export function buildCategoryViews(
|
|
|
115
117
|
filterState
|
|
116
118
|
);
|
|
117
119
|
|
|
118
|
-
// Build view
|
|
120
|
+
// Build view model for range categories.
|
|
121
|
+
if (isRangeCategory(category)) {
|
|
122
|
+
return buildRangeCategoryView(
|
|
123
|
+
category,
|
|
124
|
+
categoryConfigs,
|
|
125
|
+
categorySelectedFilter
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Build view model for single or multiselect categories.
|
|
119
130
|
const categoryValueViews = category.values.map((categoryValue) =>
|
|
120
131
|
buildCategoryValueView(categoryValue, categorySelectedFilter)
|
|
121
132
|
);
|
|
@@ -136,13 +147,15 @@ export function buildCategoryViews(
|
|
|
136
147
|
* @param categoryKey - Key of category that has been de/selected.
|
|
137
148
|
* @param selectedValue - Key of category value that has been de/selected
|
|
138
149
|
* @param selected - True if value is selected, false if de-selected.
|
|
150
|
+
* @param viewKind - View kind.
|
|
139
151
|
* @returns New filter state generated from the current set of selected values and the newly selected value.
|
|
140
152
|
*/
|
|
141
153
|
export function buildNextFilterState(
|
|
142
154
|
filterState: FilterState,
|
|
143
155
|
categoryKey: CategoryKey,
|
|
144
156
|
selectedValue: CategoryValueKey,
|
|
145
|
-
selected: boolean
|
|
157
|
+
selected: boolean,
|
|
158
|
+
viewKind?: VIEW_KIND
|
|
146
159
|
): FilterState {
|
|
147
160
|
// Check if the selected category already has selected values.
|
|
148
161
|
const categorySelectedFilter = getCategorySelectedFilter(
|
|
@@ -162,14 +175,20 @@ export function buildNextFilterState(
|
|
|
162
175
|
value: categorySelectedFilter ? [...categorySelectedFilter.value] : [],
|
|
163
176
|
};
|
|
164
177
|
|
|
165
|
-
//
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
// Build next filter state for category.
|
|
179
|
+
if (viewKind === VIEW_KIND.RANGE) {
|
|
180
|
+
// Handle range category.
|
|
181
|
+
buildNextRangeFilterState(
|
|
182
|
+
nextCategorySelectedFilter,
|
|
183
|
+
selectedValue,
|
|
184
|
+
selected
|
|
185
|
+
);
|
|
186
|
+
} else {
|
|
187
|
+
// Handle select category.
|
|
188
|
+
buildNextSelectFilterState(
|
|
189
|
+
nextCategorySelectedFilter,
|
|
190
|
+
selectedValue,
|
|
191
|
+
selected
|
|
173
192
|
);
|
|
174
193
|
}
|
|
175
194
|
|
|
@@ -221,19 +240,6 @@ export function getSelectCategoryValue(
|
|
|
221
240
|
return selectCategoryValue;
|
|
222
241
|
}
|
|
223
242
|
|
|
224
|
-
/**
|
|
225
|
-
* Returns the category config for the given category config key.
|
|
226
|
-
* @param key - Category config key.
|
|
227
|
-
* @param categoryConfigs - Category configs.
|
|
228
|
-
* @returns category config.
|
|
229
|
-
*/
|
|
230
|
-
function findCategoryConfig(
|
|
231
|
-
key: string,
|
|
232
|
-
categoryConfigs: CategoryConfig[]
|
|
233
|
-
): CategoryConfig | undefined {
|
|
234
|
-
return categoryConfigs.find((categoryConfig) => categoryConfig.key === key);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
243
|
/**
|
|
238
244
|
* Determine if given category value is selected.
|
|
239
245
|
* @param categoryValueKey - The key of the category value to check if selected in the filter state.
|
|
@@ -257,7 +263,7 @@ function isCategoryValueSelected(
|
|
|
257
263
|
* @returns true if category is to be included in filter.
|
|
258
264
|
*/
|
|
259
265
|
function isCategoryAcceptListed(
|
|
260
|
-
category:
|
|
266
|
+
category: Category,
|
|
261
267
|
categoryConfigs: CategoryConfig[]
|
|
262
268
|
): boolean {
|
|
263
269
|
return categoryConfigs.some(
|
|
@@ -288,9 +294,6 @@ function sortCategoryValueViews(
|
|
|
288
294
|
* @param c1 - Second category view to compare.
|
|
289
295
|
* @returns Number indicating sort precedence of c0 vs c1.
|
|
290
296
|
*/
|
|
291
|
-
function sortCategoryViews(
|
|
292
|
-
c0: SelectCategoryView,
|
|
293
|
-
c1: SelectCategoryView
|
|
294
|
-
): number {
|
|
297
|
+
function sortCategoryViews(c0: CategoryView, c1: CategoryView): number {
|
|
295
298
|
return COLLATOR_CASE_INSENSITIVE.compare(c0.label, c1.label);
|
|
296
299
|
}
|
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
RowSelectionState,
|
|
5
5
|
VisibilityState,
|
|
6
6
|
} from "@tanstack/react-table";
|
|
7
|
+
import { CategoryConfig } from "../../common/categories/config/types";
|
|
8
|
+
import { CategoryView } from "../../common/categories/views/types";
|
|
7
9
|
import {
|
|
8
10
|
CategoryValueKey,
|
|
9
11
|
SelectCategory,
|
|
10
|
-
SelectCategoryView,
|
|
11
12
|
SelectedFilter,
|
|
12
13
|
} from "../../common/entities";
|
|
13
14
|
import { RowPreviewState } from "../../components/Table/features/RowPreview/entities";
|
|
14
15
|
import {
|
|
15
|
-
CategoryConfig,
|
|
16
16
|
CategoryGroup,
|
|
17
17
|
CategoryGroupConfig,
|
|
18
18
|
EntityPath,
|
|
@@ -36,7 +36,7 @@ export interface EntityPageStateMapper {
|
|
|
36
36
|
export interface EntityState {
|
|
37
37
|
categoryConfigs?: CategoryConfig[];
|
|
38
38
|
categoryGroups?: CategoryGroup[];
|
|
39
|
-
categoryViews:
|
|
39
|
+
categoryViews: CategoryView[];
|
|
40
40
|
filterState: SelectedFilter[];
|
|
41
41
|
savedFilterByCategoryValueKey?: SavedFilterByCategoryValueKey;
|
|
42
42
|
savedFilterState: SelectedFilter[];
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
GroupingState,
|
|
4
4
|
VisibilityState,
|
|
5
5
|
} from "@tanstack/react-table";
|
|
6
|
+
import { CategoryConfig } from "../../../common/categories/config/types";
|
|
6
7
|
import { SelectCategory, SelectedFilter } from "../../../common/entities";
|
|
7
8
|
import { getInitialColumnVisibilityState } from "../../../components/TableCreator/options/initialState/columnVisibility";
|
|
8
9
|
import {
|
|
9
|
-
CategoryConfig,
|
|
10
10
|
CategoryGroup,
|
|
11
11
|
CategoryGroupConfig,
|
|
12
12
|
EntityConfig,
|
|
@@ -3,11 +3,12 @@ import {
|
|
|
3
3
|
GroupingState,
|
|
4
4
|
RowSelectionState,
|
|
5
5
|
} from "@tanstack/react-table";
|
|
6
|
+
import { Category } from "../../../common/categories/models/types";
|
|
7
|
+
import { VIEW_KIND } from "../../../common/categories/views/types";
|
|
6
8
|
import {
|
|
7
9
|
CategoryKey,
|
|
8
10
|
CategoryValueKey,
|
|
9
11
|
PaginationDirectionType,
|
|
10
|
-
SelectCategory,
|
|
11
12
|
SelectedFilter,
|
|
12
13
|
} from "../../../common/entities";
|
|
13
14
|
import { RowPreviewState } from "../../../components/Table/features/RowPreview/entities";
|
|
@@ -21,6 +22,7 @@ export interface ApplySavedFilterPayload {
|
|
|
21
22
|
categoryKey: CategoryKey;
|
|
22
23
|
selected: boolean;
|
|
23
24
|
selectedValue: CategoryValueKey;
|
|
25
|
+
viewKind?: VIEW_KIND; // viewKind is included here because this payload shares a dispatch with UpdateFilter.
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -43,7 +45,7 @@ export interface ProcessExploreResponsePayload {
|
|
|
43
45
|
listItems: ListItems;
|
|
44
46
|
loading: boolean;
|
|
45
47
|
paginationResponse: PaginationResponse;
|
|
46
|
-
selectCategories?:
|
|
48
|
+
selectCategories?: Category[];
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
/**
|
|
@@ -74,6 +76,7 @@ export interface UpdateFilterPayload {
|
|
|
74
76
|
categoryKey: CategoryKey;
|
|
75
77
|
selected: boolean;
|
|
76
78
|
selectedValue: CategoryValueKey;
|
|
79
|
+
viewKind?: VIEW_KIND;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
/**
|
|
@@ -9,7 +9,8 @@ import React, {
|
|
|
9
9
|
useState,
|
|
10
10
|
} from "react";
|
|
11
11
|
import { AzulSearchIndex } from "../apis/azul/common/entities";
|
|
12
|
-
import {
|
|
12
|
+
import { CategoryView } from "../common/categories/views/types";
|
|
13
|
+
import { SelectedFilter } from "../common/entities";
|
|
13
14
|
import { RowPreviewState } from "../components/Table/features/RowPreview/entities";
|
|
14
15
|
import { CategoryGroup, SiteConfig } from "../config/entities";
|
|
15
16
|
import { useToken } from "../hooks/authentication/token/useToken";
|
|
@@ -78,7 +79,7 @@ export interface ExploreContext {
|
|
|
78
79
|
export type ExploreState = {
|
|
79
80
|
catalogState: CatalogState;
|
|
80
81
|
categoryGroups?: CategoryGroup[];
|
|
81
|
-
categoryViews:
|
|
82
|
+
categoryViews: CategoryView[];
|
|
82
83
|
entityPageState: EntityPageStateMapper;
|
|
83
84
|
entityStateByCategoryGroupConfigKey: EntityStateByCategoryGroupConfigKey;
|
|
84
85
|
featureFlagState: FeatureFlagState;
|
|
@@ -638,7 +639,8 @@ function exploreReducer(
|
|
|
638
639
|
state.filterState,
|
|
639
640
|
payload.categoryKey,
|
|
640
641
|
payload.selectedValue,
|
|
641
|
-
payload.selected
|
|
642
|
+
payload.selected,
|
|
643
|
+
payload.viewKind
|
|
642
644
|
);
|
|
643
645
|
const rowPreview = closeRowPreview(state.rowPreview);
|
|
644
646
|
const rowSelection: RowSelectionState = {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { screen } from "@testing-library/react";
|
|
2
|
+
import { escapeRegExp } from "../common/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves a button by its name.
|
|
6
|
+
* @param name - The name of the button.
|
|
7
|
+
* @returns The button element.
|
|
8
|
+
*/
|
|
9
|
+
export function getButton<T extends HTMLElement = HTMLElement>(
|
|
10
|
+
name: string | RegExp
|
|
11
|
+
): T {
|
|
12
|
+
return screen.getByRole("button", { name });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves an input element by its label text.
|
|
17
|
+
* @param text - The label text of the input element.
|
|
18
|
+
* @returns The input element.
|
|
19
|
+
*/
|
|
20
|
+
export function getLabelText<T extends HTMLElement = HTMLElement>(
|
|
21
|
+
text: string
|
|
22
|
+
): T {
|
|
23
|
+
return screen.getByLabelText(text);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns regex that matches the start of the given text.
|
|
28
|
+
* @param text - Text to match.
|
|
29
|
+
* @returns RegExp.
|
|
30
|
+
*/
|
|
31
|
+
export function getStartsWithRegex(text: string): RegExp {
|
|
32
|
+
return new RegExp(`^${escapeRegExp(text)}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves an element by its text content.
|
|
37
|
+
* @param text - The text content of the element.
|
|
38
|
+
* @returns The element.
|
|
39
|
+
*/
|
|
40
|
+
export function getText<T extends HTMLElement = HTMLElement>(
|
|
41
|
+
text: string | RegExp
|
|
42
|
+
): T {
|
|
43
|
+
return screen.getByText(text);
|
|
44
|
+
}
|
|
@@ -410,6 +410,14 @@ export const MuiChip = (theme: Theme): Components["MuiChip"] => {
|
|
|
410
410
|
},
|
|
411
411
|
label: {
|
|
412
412
|
...theme.typography[TEXT_BODY_SMALL_400],
|
|
413
|
+
variants: [
|
|
414
|
+
{
|
|
415
|
+
props: { variant: "status" },
|
|
416
|
+
style: {
|
|
417
|
+
...theme.typography[TEXT_BODY_SMALL_500],
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
],
|
|
413
421
|
},
|
|
414
422
|
},
|
|
415
423
|
variants: [
|
|
@@ -489,13 +497,18 @@ export const MuiChip = (theme: Theme): Components["MuiChip"] => {
|
|
|
489
497
|
{
|
|
490
498
|
props: { variant: "status" },
|
|
491
499
|
style: {
|
|
492
|
-
...theme.typography[TEXT_BODY_SMALL_500],
|
|
493
500
|
boxShadow: `0 0 0 2px ${PALETTE.COMMON_WHITE}`,
|
|
494
501
|
height: 20,
|
|
495
502
|
maxWidth: "fit-content",
|
|
496
503
|
minWidth: 0,
|
|
497
504
|
},
|
|
498
505
|
},
|
|
506
|
+
{
|
|
507
|
+
props: { color: "default", variant: "status" },
|
|
508
|
+
style: {
|
|
509
|
+
color: PALETTE.INK_LIGHT,
|
|
510
|
+
},
|
|
511
|
+
},
|
|
499
512
|
],
|
|
500
513
|
};
|
|
501
514
|
};
|
|
@@ -902,6 +915,11 @@ export const MuiLink: Components["MuiLink"] = {
|
|
|
902
915
|
textDecorationSkipInk: "none",
|
|
903
916
|
textUnderlinePosition: "from-font",
|
|
904
917
|
},
|
|
918
|
+
underlineNone: {
|
|
919
|
+
"&:hover": {
|
|
920
|
+
textDecoration: "none",
|
|
921
|
+
},
|
|
922
|
+
},
|
|
905
923
|
},
|
|
906
924
|
};
|
|
907
925
|
|
|
@@ -5,11 +5,8 @@ import {
|
|
|
5
5
|
} from "../../apis/azul/common/entities";
|
|
6
6
|
import { track } from "../../common/analytics/analytics";
|
|
7
7
|
import { EVENT_NAME, EVENT_PARAM } from "../../common/analytics/entities";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
CategoryValueKey,
|
|
11
|
-
SelectCategoryView,
|
|
12
|
-
} from "../../common/entities";
|
|
8
|
+
import { CategoryView, VIEW_KIND } from "../../common/categories/views/types";
|
|
9
|
+
import { CategoryKey, CategoryValueKey } from "../../common/entities";
|
|
13
10
|
import { ComponentCreator } from "../../components/ComponentCreator/ComponentCreator";
|
|
14
11
|
import { ClearAllFilters } from "../../components/Filter/components/ClearAllFilters/clearAllFilters";
|
|
15
12
|
import {
|
|
@@ -76,6 +73,7 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
|
|
|
76
73
|
* @param selectedCategoryValue - The value to set or clear.
|
|
77
74
|
* @param selected - Indication of whether the selected value is being set or cleared.
|
|
78
75
|
* @param categorySection - Name of group the category is in.
|
|
76
|
+
* @param viewKind - View kind.
|
|
79
77
|
* @param searchTerm - Search term used to find the value.
|
|
80
78
|
*/
|
|
81
79
|
const onFilterChange = (
|
|
@@ -84,6 +82,7 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
|
|
|
84
82
|
selectedCategoryValue: CategoryValueKey,
|
|
85
83
|
selected: boolean,
|
|
86
84
|
categorySection?: string,
|
|
85
|
+
viewKind?: VIEW_KIND,
|
|
87
86
|
searchTerm?: string
|
|
88
87
|
): void => {
|
|
89
88
|
const dispatchType =
|
|
@@ -96,6 +95,7 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
|
|
|
96
95
|
categoryKey,
|
|
97
96
|
selected,
|
|
98
97
|
selectedValue: selectedCategoryValue,
|
|
98
|
+
viewKind,
|
|
99
99
|
},
|
|
100
100
|
type: dispatchType,
|
|
101
101
|
});
|
|
@@ -188,33 +188,28 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
|
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
190
|
* Builds the category views into category views grouped by the given category group configuration.
|
|
191
|
-
* @param
|
|
191
|
+
* @param categoryViews - View models of categories to display.
|
|
192
192
|
* @param categoryGroups - Category groups.
|
|
193
193
|
* @returns category filters.
|
|
194
194
|
*/
|
|
195
195
|
function buildCategoryFilters(
|
|
196
|
-
|
|
196
|
+
categoryViews: CategoryView[],
|
|
197
197
|
categoryGroups?: CategoryGroup[]
|
|
198
198
|
): CategoryFilter[] {
|
|
199
199
|
if (!categoryGroups) {
|
|
200
|
-
return [{ categoryViews
|
|
200
|
+
return [{ categoryViews }];
|
|
201
201
|
}
|
|
202
202
|
return categoryGroups.reduce((accGroups, { categoryConfigs, label }) => {
|
|
203
203
|
// Grab the category views for the configured grouped categories.
|
|
204
|
-
const
|
|
205
|
-
(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
},
|
|
214
|
-
[] as SelectCategoryView[]
|
|
215
|
-
);
|
|
216
|
-
if (categoryViews.length > 0) {
|
|
217
|
-
accGroups.push({ categoryViews, label });
|
|
204
|
+
const views = categoryConfigs.reduce((accViews, { key: categoryKey }) => {
|
|
205
|
+
const categoryView = categoryViews.find(({ key }) => key === categoryKey);
|
|
206
|
+
if (categoryView) {
|
|
207
|
+
accViews.push(categoryView);
|
|
208
|
+
}
|
|
209
|
+
return accViews;
|
|
210
|
+
}, [] as CategoryView[]);
|
|
211
|
+
if (views.length > 0) {
|
|
212
|
+
accGroups.push({ categoryViews: views, label });
|
|
218
213
|
}
|
|
219
214
|
return accGroups;
|
|
220
215
|
}, [] as CategoryFilter[]);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jest } from "@jest/globals";
|
|
2
|
+
import { composeStories } from "@storybook/react";
|
|
3
|
+
import { render, screen, waitFor, within } from "@testing-library/react";
|
|
4
|
+
import { userEvent } from "@testing-library/user-event";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { VIEW_KIND } from "../src/common/categories/views/types";
|
|
7
|
+
import * as stories from "../src/components/Filter/components/Filter/stories/filter.stories";
|
|
8
|
+
import { TEST_IDS } from "../src/tests/testIds";
|
|
9
|
+
import { getButton } from "../src/tests/utils";
|
|
10
|
+
|
|
11
|
+
const { RangeCategory } = composeStories(stories);
|
|
12
|
+
|
|
13
|
+
const TEST_VALUES = {
|
|
14
|
+
ON_FILTER_BY_RANGE: RangeCategory.args.onFilter,
|
|
15
|
+
RANGE_CATEGORY: RangeCategory.args.categoryView,
|
|
16
|
+
RANGE_CATEGORY_KEY: RangeCategory.args.categoryView?.key,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Tests for the Filter component.
|
|
21
|
+
* TODO(cc) add tests:
|
|
22
|
+
* - selected values (rending of tags) for select and range categories
|
|
23
|
+
* - disabled state
|
|
24
|
+
* - select category view
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
describe("Filter", () => {
|
|
28
|
+
describe("RANGE Category", () => {
|
|
29
|
+
let buttonEl: HTMLButtonElement;
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
jest.clearAllMocks();
|
|
33
|
+
render(<RangeCategory />);
|
|
34
|
+
const expectedLabel = TEST_VALUES.RANGE_CATEGORY?.label;
|
|
35
|
+
buttonEl = screen.getByRole("button", { name: expectedLabel });
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("renders filter label", () => {
|
|
39
|
+
expect(buttonEl).toBeDefined();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("opens popover when filter button is clicked", async () => {
|
|
43
|
+
await openPopover(buttonEl);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("calls onFilter with correct values", async () => {
|
|
47
|
+
await openPopover(buttonEl);
|
|
48
|
+
const popoverEl = getPopoverEl();
|
|
49
|
+
const inputEl = within(popoverEl).getByLabelText("Min");
|
|
50
|
+
await userEvent.type(inputEl, "100");
|
|
51
|
+
await userEvent.click(getButton("Filter"));
|
|
52
|
+
await waitFor(() => {
|
|
53
|
+
expect(TEST_VALUES.ON_FILTER_BY_RANGE).toHaveBeenCalledTimes(1);
|
|
54
|
+
expect(TEST_VALUES.ON_FILTER_BY_RANGE).toHaveBeenCalledWith(
|
|
55
|
+
TEST_VALUES.RANGE_CATEGORY_KEY,
|
|
56
|
+
[100, null],
|
|
57
|
+
true,
|
|
58
|
+
undefined,
|
|
59
|
+
VIEW_KIND.RANGE
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("closes popover with keyboard escape", async () => {
|
|
65
|
+
await openPopover(buttonEl);
|
|
66
|
+
await closePopover();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves the popover element.
|
|
73
|
+
* @returns The popover element.
|
|
74
|
+
*/
|
|
75
|
+
function getPopoverEl(): HTMLElement {
|
|
76
|
+
return screen.getByTestId(TEST_IDS.FILTER_POPOVER);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Closes the popover with keyboard escape.
|
|
81
|
+
* @returns A promise that resolves when the popover is closed.
|
|
82
|
+
*/
|
|
83
|
+
async function closePopover(): Promise<void> {
|
|
84
|
+
await userEvent.keyboard("{Escape}");
|
|
85
|
+
await waitFor(() => {
|
|
86
|
+
expect(screen.queryByTestId(TEST_IDS.FILTER_POPOVER)).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Opens the popover by clicking the button.
|
|
92
|
+
* @param buttonEl - The button element to click.
|
|
93
|
+
* @returns A promise that resolves when the popover is opened.
|
|
94
|
+
*/
|
|
95
|
+
async function openPopover(buttonEl: HTMLButtonElement): Promise<void> {
|
|
96
|
+
await userEvent.click(buttonEl);
|
|
97
|
+
await waitFor(() => {
|
|
98
|
+
expect(screen.getByTestId(TEST_IDS.FILTER_POPOVER)).toBeDefined();
|
|
99
|
+
});
|
|
100
|
+
}
|