@databiosphere/findable-ui 40.0.0 → 41.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/entities.d.ts +8 -0
- package/lib/common/entities.js +4 -1
- package/lib/components/DataDictionary/components/Description/description.js +2 -2
- package/lib/components/DataDictionary/components/Description/description.styles.d.ts +1 -1
- package/lib/components/DataDictionary/components/Description/description.styles.js +2 -2
- package/lib/components/DataDictionary/components/Entity/entity.styles.js +5 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilterTags/columnFilterTags.js +4 -1
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.js +6 -1
- package/lib/components/DataDictionary/components/Filters/filters.styles.js +0 -5
- package/lib/components/DataDictionary/components/Filters/stories/constants.d.ts +1 -0
- package/lib/components/DataDictionary/components/Filters/stories/constants.js +1 -0
- package/lib/components/DataDictionary/components/Filters/stories/filters.stories.js +9 -3
- package/lib/components/DataDictionary/components/Filters/stories/utils.d.ts +7 -0
- package/lib/components/DataDictionary/components/Filters/stories/utils.js +12 -0
- package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.js +2 -2
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.js +6 -2
- package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.js +2 -2
- package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.js +6 -2
- package/lib/components/DataDictionary/components/Table/table.js +7 -4
- package/lib/components/DataDictionary/components/Table/table.styles.d.ts +1 -1
- package/lib/components/DataDictionary/components/Table/table.styles.js +2 -2
- package/lib/components/DataDictionary/components/Title/title.styles.js +2 -2
- package/lib/components/DataDictionary/dataDictionary.styles.d.ts +0 -1
- package/lib/components/DataDictionary/dataDictionary.styles.js +8 -8
- package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +2 -2
- package/lib/components/Filter/components/Filter/filter.d.ts +3 -2
- package/lib/components/Filter/components/Filter/filter.js +13 -11
- package/lib/components/Filter/components/Filter/filter.styles.d.ts +3 -5
- package/lib/components/Filter/components/Filter/filter.styles.js +16 -19
- package/lib/components/Filter/components/Filter/stories/args.js +3 -2
- package/lib/components/Filter/components/FilterLabel/filterLabel.d.ts +3 -1
- package/lib/components/Filter/components/FilterLabel/filterLabel.js +3 -3
- package/lib/components/Filter/components/FilterLabel/filterLabel.stories.d.ts +3 -1
- package/lib/components/Filter/components/FilterLabel/filterLabel.stories.js +2 -0
- package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +3 -6
- package/lib/components/Filter/components/FilterLabel/filterLabel.styles.js +16 -13
- package/lib/components/Filter/components/FilterList/filterList.styles.d.ts +1 -1
- package/lib/components/Filter/components/FilterList/filterList.styles.js +1 -1
- package/lib/components/Filter/components/FilterMenu/filterMenu.d.ts +3 -2
- package/lib/components/Filter/components/FilterMenu/filterMenu.js +11 -11
- package/lib/components/Filter/components/FilterMenu/filterMenu.stories.d.ts +3 -2
- package/lib/components/Filter/components/FilterMenu/filterMenu.stories.js +2 -1
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.d.ts +2 -6
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.js +7 -17
- package/lib/components/Filter/components/FilterMenuSearch/filterMenuSearch.d.ts +3 -1
- package/lib/components/Filter/components/FilterMenuSearch/filterMenuSearch.js +3 -3
- package/lib/components/Filter/components/FilterMenuSearch/filterMenuSearch.styles.d.ts +3 -2
- package/lib/components/Filter/components/FilterMenuSearch/filterMenuSearch.styles.js +9 -5
- package/lib/components/Filter/components/FilterRange/filterRange.d.ts +1 -1
- package/lib/components/Filter/components/FilterRange/filterRange.js +7 -8
- package/lib/components/Filter/components/FilterRange/filterRange.styles.d.ts +2 -1
- package/lib/components/Filter/components/FilterRange/filterRange.styles.js +20 -16
- package/lib/components/Filter/components/FilterRange/stories/args.js +2 -1
- package/lib/components/Filter/components/FilterRange/types.d.ts +2 -1
- package/lib/components/Filter/components/Filters/filters.d.ts +5 -2
- package/lib/components/Filter/components/Filters/filters.js +7 -8
- package/lib/components/Filter/components/Filters/filters.styles.d.ts +6 -5
- package/lib/components/Filter/components/Filters/filters.styles.js +11 -11
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.js +2 -2
- package/lib/components/Filter/components/VariableSizeList/VariableSizeList.d.ts +3 -2
- package/lib/components/Filter/components/VariableSizeList/VariableSizeList.js +9 -8
- package/lib/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/columnFiltersAdapter.d.ts +3 -0
- package/lib/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/columnFiltersAdapter.js +24 -0
- package/lib/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/types.d.ts +6 -0
- package/lib/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/types.js +1 -0
- package/lib/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.d.ts +14 -0
- package/lib/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.js +67 -0
- package/lib/components/Filter/components/controls/Controls/controls.d.ts +6 -0
- package/lib/components/Filter/components/controls/Controls/controls.js +14 -0
- package/lib/components/Filter/components/controls/Controls/controls.styles.d.ts +7 -0
- package/lib/components/Filter/components/controls/Controls/controls.styles.js +9 -0
- package/lib/components/Filter/components/surfaces/drawer/Drawer/constants.d.ts +2 -0
- package/lib/components/Filter/components/surfaces/drawer/Drawer/constants.js +5 -0
- package/lib/components/Filter/components/surfaces/drawer/Drawer/drawer.d.ts +2 -0
- package/lib/components/Filter/components/surfaces/drawer/Drawer/drawer.js +17 -0
- package/lib/components/Filter/components/surfaces/drawer/Drawer/drawer.styles.d.ts +3 -0
- package/lib/components/Filter/components/surfaces/drawer/Drawer/drawer.styles.js +19 -0
- package/lib/components/Filter/components/surfaces/drawer/Drawer/types.d.ts +7 -0
- package/lib/components/Filter/components/surfaces/drawer/Drawer/types.js +1 -0
- package/lib/components/Filter/components/surfaces/drawer/components/Button/button.d.ts +7 -0
- package/lib/components/Filter/components/surfaces/drawer/components/Button/button.js +16 -0
- package/lib/components/Filter/components/surfaces/drawer/components/ButtonBase/buttonBase.d.ts +6 -0
- package/lib/components/Filter/components/surfaces/drawer/components/ButtonBase/buttonBase.js +14 -0
- package/lib/components/Filter/components/surfaces/drawer/components/ButtonBase/buttonBase.styles.d.ts +5 -0
- package/lib/components/Filter/components/surfaces/drawer/components/ButtonBase/buttonBase.styles.js +12 -0
- package/lib/components/Filter/components/surfaces/drawer/components/IconButton/constants.d.ts +3 -0
- package/lib/components/Filter/components/surfaces/drawer/components/IconButton/constants.js +9 -0
- package/lib/components/Filter/components/surfaces/drawer/components/IconButton/iconButton.d.ts +6 -0
- package/lib/components/Filter/components/surfaces/drawer/components/IconButton/iconButton.js +13 -0
- package/lib/components/Filter/components/surfaces/drawer/components/IconButton/iconButton.styles.d.ts +5 -0
- package/lib/components/Filter/components/surfaces/drawer/components/IconButton/iconButton.styles.js +9 -0
- package/lib/components/Filter/components/surfaces/types.d.ts +11 -0
- package/lib/components/Filter/components/surfaces/types.js +5 -0
- package/lib/components/Filter/components/views/select/SelectListItem/selectListItem.d.ts +3 -0
- package/lib/components/Filter/components/views/select/SelectListItem/selectListItem.js +9 -0
- package/lib/components/Filter/components/views/select/SelectListItem/types.d.ts +12 -0
- package/lib/components/Filter/components/views/select/SelectListItem/types.js +1 -0
- package/lib/components/Filter/components/views/select/components/Checkbox/checkbox.d.ts +3 -0
- package/lib/components/Filter/components/views/select/components/Checkbox/checkbox.js +7 -0
- package/lib/components/Filter/components/views/select/components/ListItemButton/listItemButton.d.ts +7 -0
- package/lib/components/Filter/components/views/select/components/ListItemButton/listItemButton.js +5 -0
- package/lib/components/Filter/components/views/select/components/ListItemButton/listItemButton.styles.d.ts +5 -0
- package/lib/components/Filter/components/views/select/components/ListItemButton/listItemButton.styles.js +11 -0
- package/lib/components/Filter/components/views/select/components/ListItemText/components/Count/count.d.ts +3 -0
- package/lib/components/Filter/components/views/select/components/ListItemText/components/Count/count.js +6 -0
- package/lib/components/Filter/components/views/select/components/ListItemText/components/Term/term.d.ts +3 -0
- package/lib/components/Filter/components/views/select/components/ListItemText/components/Term/term.js +6 -0
- package/lib/components/Filter/components/views/select/components/ListItemText/listItemText.d.ts +3 -0
- package/lib/components/Filter/components/views/select/components/ListItemText/listItemText.js +26 -0
- package/lib/components/Filter/components/views/select/components/ListItemText/listItemText.styles.d.ts +3 -0
- package/lib/components/Filter/components/views/select/components/ListItemText/listItemText.styles.js +12 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.js +23 -8
- package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.js +5 -0
- package/lib/components/common/Button/constants.js +4 -0
- package/lib/components/common/Drawer/provider/provider.d.ts +2 -4
- package/lib/components/common/Drawer/provider/provider.js +4 -2
- package/lib/components/common/Drawer/provider/types.d.ts +5 -1
- package/lib/hooks/useCategoryFilter.d.ts +2 -2
- package/lib/styles/common/mixins/breakpoints.d.ts +2 -0
- package/lib/styles/common/mixins/breakpoints.js +2 -0
- package/lib/styles/common/mui/typography.js +2 -0
- package/lib/utils/typeGuards.d.ts +6 -0
- package/lib/utils/typeGuards.js +8 -0
- package/lib/views/ExploreView/exploreView.js +4 -1
- package/package.json +1 -1
- package/src/common/entities.ts +10 -0
- package/src/components/DataDictionary/components/Description/description.styles.ts +2 -2
- package/src/components/DataDictionary/components/Description/description.tsx +3 -6
- package/src/components/DataDictionary/components/Entity/entity.styles.ts +5 -0
- package/src/components/DataDictionary/components/Filters/components/ColumnFilterTags/columnFilterTags.tsx +4 -1
- package/src/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.tsx +12 -1
- package/src/components/DataDictionary/components/Filters/filters.styles.ts +0 -5
- package/src/components/DataDictionary/components/Filters/stories/constants.ts +2 -0
- package/src/components/DataDictionary/components/Filters/stories/filters.stories.tsx +11 -4
- package/src/components/DataDictionary/components/Filters/stories/utils.ts +15 -0
- package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.ts +2 -2
- package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.ts +9 -2
- package/src/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.ts +2 -2
- package/src/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.ts +9 -2
- package/src/components/DataDictionary/components/Table/table.styles.ts +2 -2
- package/src/components/DataDictionary/components/Table/table.tsx +8 -4
- package/src/components/DataDictionary/components/Title/title.styles.ts +2 -2
- package/src/components/DataDictionary/dataDictionary.styles.ts +11 -9
- package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +1 -1
- package/src/components/Filter/components/Filter/filter.styles.ts +18 -20
- package/src/components/Filter/components/Filter/filter.tsx +17 -19
- package/src/components/Filter/components/Filter/stories/args.ts +3 -2
- package/src/components/Filter/components/FilterLabel/filterLabel.stories.tsx +2 -0
- package/src/components/Filter/components/FilterLabel/filterLabel.styles.ts +20 -19
- package/src/components/Filter/components/FilterLabel/filterLabel.tsx +7 -3
- package/src/components/Filter/components/FilterList/filterList.styles.ts +1 -1
- package/src/components/Filter/components/FilterMenu/filterMenu.stories.tsx +2 -1
- package/src/components/Filter/components/FilterMenu/filterMenu.styles.ts +9 -18
- package/src/components/Filter/components/FilterMenu/filterMenu.tsx +15 -19
- package/src/components/Filter/components/FilterMenuSearch/filterMenuSearch.styles.ts +11 -5
- package/src/components/Filter/components/FilterMenuSearch/filterMenuSearch.tsx +5 -1
- package/src/components/Filter/components/FilterRange/filterRange.styles.ts +25 -19
- package/src/components/Filter/components/FilterRange/filterRange.tsx +8 -12
- package/src/components/Filter/components/FilterRange/stories/args.ts +2 -1
- package/src/components/Filter/components/FilterRange/types.ts +2 -1
- package/src/components/Filter/components/Filters/filters.styles.ts +16 -16
- package/src/components/Filter/components/Filters/filters.tsx +19 -13
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.tsx +2 -2
- package/src/components/Filter/components/VariableSizeList/VariableSizeList.tsx +10 -9
- package/src/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/columnFiltersAdapter.tsx +44 -0
- package/src/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/types.ts +7 -0
- package/src/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.ts +90 -0
- package/src/components/Filter/components/controls/Controls/controls.styles.ts +10 -0
- package/src/components/Filter/components/controls/Controls/controls.tsx +31 -0
- package/src/components/Filter/components/surfaces/drawer/Drawer/constants.ts +7 -0
- package/src/components/Filter/components/surfaces/drawer/Drawer/drawer.styles.ts +20 -0
- package/src/components/Filter/components/surfaces/drawer/Drawer/drawer.tsx +46 -0
- package/src/components/Filter/components/surfaces/drawer/Drawer/types.ts +11 -0
- package/src/components/Filter/components/surfaces/drawer/components/Button/button.tsx +40 -0
- package/src/components/Filter/components/surfaces/drawer/components/ButtonBase/buttonBase.styles.ts +13 -0
- package/src/components/Filter/components/surfaces/drawer/components/ButtonBase/buttonBase.tsx +25 -0
- package/src/components/Filter/components/surfaces/drawer/components/IconButton/constants.ts +12 -0
- package/src/components/Filter/components/surfaces/drawer/components/IconButton/iconButton.styles.ts +10 -0
- package/src/components/Filter/components/surfaces/drawer/components/IconButton/iconButton.tsx +28 -0
- package/src/components/Filter/components/surfaces/types.ts +13 -0
- package/src/components/Filter/components/views/select/SelectListItem/selectListItem.tsx +19 -0
- package/src/components/Filter/components/views/select/SelectListItem/types.ts +14 -0
- package/src/components/Filter/components/views/select/components/Checkbox/checkbox.tsx +19 -0
- package/src/components/Filter/components/views/select/components/ListItemButton/listItemButton.styles.ts +12 -0
- package/src/components/Filter/components/views/select/components/ListItemButton/listItemButton.tsx +25 -0
- package/src/components/Filter/components/views/select/components/ListItemText/components/Count/count.tsx +20 -0
- package/src/components/Filter/components/views/select/components/ListItemText/components/Term/term.tsx +19 -0
- package/src/components/Filter/components/views/select/components/ListItemText/listItemText.styles.ts +13 -0
- package/src/components/Filter/components/views/select/components/ListItemText/listItemText.tsx +48 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.tsx +34 -35
- package/src/components/Table/components/TableFeatures/ColumnFilter/constants.ts +5 -0
- package/src/components/common/Button/constants.ts +4 -0
- package/src/components/common/Drawer/provider/provider.tsx +7 -8
- package/src/components/common/Drawer/provider/types.ts +6 -4
- package/src/hooks/useCategoryFilter.ts +2 -1
- package/src/styles/common/mixins/breakpoints.ts +6 -0
- package/src/styles/common/mui/typography.ts +2 -0
- package/src/utils/typeGuards.ts +8 -0
- package/src/views/ExploreView/exploreView.tsx +4 -0
|
@@ -2,6 +2,7 @@ import { RangeCategoryView } from "../../../../common/categories/views/range/typ
|
|
|
2
2
|
import { CategoryKey } from "../../../../common/entities";
|
|
3
3
|
import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
|
|
4
4
|
import { BaseComponentProps } from "../../../types";
|
|
5
|
+
import { SURFACE_TYPE } from "../surfaces/types";
|
|
5
6
|
|
|
6
7
|
export interface FilterRangeProps
|
|
7
8
|
extends Omit<RangeCategoryView, "key" | "label">,
|
|
@@ -9,7 +10,7 @@ export interface FilterRangeProps
|
|
|
9
10
|
categoryKey: CategoryKey;
|
|
10
11
|
categoryLabel: string;
|
|
11
12
|
categorySection?: string;
|
|
12
|
-
isFilterDrawer: boolean;
|
|
13
13
|
onCloseFilter: () => void;
|
|
14
14
|
onFilter: OnFilterFn;
|
|
15
|
+
surfaceType: SURFACE_TYPE;
|
|
15
16
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { css } from "@emotion/react";
|
|
2
2
|
import styled from "@emotion/styled";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "../../../../styles/common/mixins/fonts";
|
|
3
|
+
import { Typography } from "@mui/material";
|
|
4
|
+
import { inkMain } from "../../../../styles/common/mixins/colors";
|
|
5
|
+
import { textBody500 } from "../../../../styles/common/mixins/fonts";
|
|
6
|
+
import { SURFACE_TYPE } from "../surfaces/types";
|
|
7
|
+
import { FiltersProps } from "./filters";
|
|
9
8
|
|
|
10
9
|
interface Props {
|
|
11
|
-
disabled: boolean;
|
|
12
10
|
height: number;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
export const Filters = styled("div")<
|
|
13
|
+
export const Filters = styled("div")<
|
|
14
|
+
Props & Pick<FiltersProps, "disabled" | "surfaceType">
|
|
15
|
+
>`
|
|
16
16
|
${textBody500};
|
|
17
17
|
color: ${inkMain};
|
|
18
18
|
height: ${({ height }) => height}px;
|
|
@@ -31,15 +31,15 @@ export const Filters = styled("div")<Props>`
|
|
|
31
31
|
margin: 8px;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
${
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
${({ surfaceType }) =>
|
|
35
|
+
surfaceType === SURFACE_TYPE.MENU &&
|
|
36
|
+
css`
|
|
37
|
+
height: unset;
|
|
38
|
+
overflow: unset;
|
|
39
|
+
padding: 0 8px;
|
|
40
|
+
`}
|
|
39
41
|
`;
|
|
40
42
|
|
|
41
|
-
export const
|
|
42
|
-
${textUppercase500};
|
|
43
|
-
color: ${inkLight};
|
|
43
|
+
export const StyledTypography = styled(Typography)`
|
|
44
44
|
padding: 8px;
|
|
45
45
|
`;
|
|
@@ -4,29 +4,28 @@ import { isRangeCategoryView } from "../../../../common/categories/views/range/t
|
|
|
4
4
|
import { CategoryView } from "../../../../common/categories/views/types";
|
|
5
5
|
import { CategoryTag } from "../../../../common/entities";
|
|
6
6
|
import { TrackFilterOpenedFunction } from "../../../../config/entities";
|
|
7
|
-
import {
|
|
8
|
-
BREAKPOINT_FN_NAME,
|
|
9
|
-
useBreakpointHelper,
|
|
10
|
-
} from "../../../../hooks/useBreakpointHelper";
|
|
11
7
|
import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
|
|
12
8
|
import { useWindowResize } from "../../../../hooks/useWindowResize";
|
|
9
|
+
import { TYPOGRAPHY_PROPS } from "../../../../styles/common/mui/typography";
|
|
13
10
|
import { TEST_IDS } from "../../../../tests/testIds";
|
|
14
|
-
import { DESKTOP_SM } from "../../../../theme/common/breakpoints";
|
|
15
11
|
import { useDrawer } from "../../../common/Drawer/provider/hook";
|
|
12
|
+
import { BaseComponentProps } from "../../../types";
|
|
16
13
|
import { Filter } from "../Filter/filter";
|
|
17
14
|
import { buildRangeTag } from "../FilterTag/utils";
|
|
18
15
|
import { FilterTags } from "../FilterTags/filterTags";
|
|
19
|
-
import {
|
|
16
|
+
import { SURFACE_TYPE } from "../surfaces/types";
|
|
17
|
+
import { Filters as FilterList, StyledTypography } from "./filters.styles";
|
|
20
18
|
|
|
21
19
|
export interface CategoryFilter {
|
|
22
20
|
categoryViews: CategoryView[];
|
|
23
21
|
label?: string;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
export interface FiltersProps {
|
|
24
|
+
export interface FiltersProps extends BaseComponentProps {
|
|
27
25
|
categoryFilters: CategoryFilter[];
|
|
28
26
|
disabled?: boolean; // Global disabling of filters.
|
|
29
27
|
onFilter: OnFilterFn;
|
|
28
|
+
surfaceType?: SURFACE_TYPE;
|
|
30
29
|
trackFilterOpened?: TrackFilterOpenedFunction;
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -74,15 +73,13 @@ function renderFilterTags(
|
|
|
74
73
|
|
|
75
74
|
export const Filters = ({
|
|
76
75
|
categoryFilters,
|
|
76
|
+
className,
|
|
77
77
|
disabled = false,
|
|
78
78
|
onFilter,
|
|
79
|
+
surfaceType = SURFACE_TYPE.MENU,
|
|
79
80
|
trackFilterOpened,
|
|
80
81
|
}: FiltersProps): JSX.Element => {
|
|
81
82
|
const { onClose } = useDrawer();
|
|
82
|
-
const isFilterDrawer = useBreakpointHelper(
|
|
83
|
-
BREAKPOINT_FN_NAME.DOWN,
|
|
84
|
-
DESKTOP_SM
|
|
85
|
-
);
|
|
86
83
|
const { height: windowHeight } = useWindowResize();
|
|
87
84
|
const filterListRef = useRef<HTMLDivElement>(null);
|
|
88
85
|
const [height, setHeight] = useState<number>(0);
|
|
@@ -93,23 +90,32 @@ export const Filters = ({
|
|
|
93
90
|
|
|
94
91
|
return (
|
|
95
92
|
<FilterList
|
|
93
|
+
className={className}
|
|
96
94
|
data-testid={TEST_IDS.FILTERS}
|
|
97
95
|
disabled={disabled}
|
|
98
96
|
height={height}
|
|
99
97
|
ref={filterListRef}
|
|
98
|
+
surfaceType={surfaceType}
|
|
100
99
|
>
|
|
101
100
|
{categoryFilters.map(({ categoryViews, label }, i) => (
|
|
102
101
|
<Fragment key={i}>
|
|
103
102
|
{i !== 0 && <Divider />}
|
|
104
|
-
{label &&
|
|
103
|
+
{label && (
|
|
104
|
+
<StyledTypography
|
|
105
|
+
color={TYPOGRAPHY_PROPS.COLOR.INK_LIGHT}
|
|
106
|
+
variant={TYPOGRAPHY_PROPS.VARIANT.TEXT_UPPERCASE_500}
|
|
107
|
+
>
|
|
108
|
+
{label}
|
|
109
|
+
</StyledTypography>
|
|
110
|
+
)}
|
|
105
111
|
{categoryViews.map((categoryView) => (
|
|
106
112
|
<Filter
|
|
107
113
|
key={categoryView.key}
|
|
108
114
|
categorySection={label}
|
|
109
115
|
categoryView={categoryView}
|
|
110
116
|
closeAncestor={onClose}
|
|
111
|
-
isFilterDrawer={isFilterDrawer}
|
|
112
117
|
onFilter={onFilter}
|
|
118
|
+
surfaceType={surfaceType}
|
|
113
119
|
trackFilterOpened={trackFilterOpened}
|
|
114
120
|
tags={renderFilterTags(categoryView, onFilter)}
|
|
115
121
|
/>
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
MAX_LIST_HEIGHT_PX,
|
|
30
30
|
} from "../../../../common/constants";
|
|
31
31
|
import { getSortMatchesFn } from "../../../../common/utils";
|
|
32
|
-
import {
|
|
32
|
+
import { StyledList } from "../../../FilterList/filterList.styles";
|
|
33
33
|
import {
|
|
34
34
|
DIVIDER_HEIGHT,
|
|
35
35
|
DIVIDER_ITEM,
|
|
@@ -174,7 +174,7 @@ export const VariableSizeList = forwardRef<
|
|
|
174
174
|
>
|
|
175
175
|
<List
|
|
176
176
|
height={height}
|
|
177
|
-
innerElementType={
|
|
177
|
+
innerElementType={StyledList}
|
|
178
178
|
innerRef={innerRef}
|
|
179
179
|
itemCount={filteredItems.length}
|
|
180
180
|
itemData={{
|
|
@@ -14,8 +14,9 @@ import {
|
|
|
14
14
|
MAX_LIST_HEIGHT_PX,
|
|
15
15
|
} from "../../common/constants";
|
|
16
16
|
import { FilterMenuSearchMatch } from "../../common/entities";
|
|
17
|
-
import {
|
|
17
|
+
import { StyledList } from "../FilterList/filterList.styles";
|
|
18
18
|
import VariableSizeListItem from "../VariableSizeListItem/variableSizeListItem";
|
|
19
|
+
import { SURFACE_TYPE } from "../surfaces/types";
|
|
19
20
|
|
|
20
21
|
export type ItemSizeByItemKey = Map<unknown, number>;
|
|
21
22
|
|
|
@@ -23,11 +24,11 @@ export interface VariableSizeListProps {
|
|
|
23
24
|
categoryKey: CategoryKey;
|
|
24
25
|
categorySection?: string;
|
|
25
26
|
height?: number; // Height of list; vertical list must be a number.
|
|
26
|
-
isFilterDrawer: boolean;
|
|
27
27
|
itemSize?: number; // Default item size.
|
|
28
28
|
matchedItems: FilterMenuSearchMatch[];
|
|
29
29
|
onFilter: OnFilterFn;
|
|
30
30
|
overscanCount?: ListProps["overscanCount"];
|
|
31
|
+
surfaceType: SURFACE_TYPE;
|
|
31
32
|
width?: ListProps["width"]; // Width of list; default to 100% width of parent element.
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -61,11 +62,11 @@ export const VariableSizeList = ({
|
|
|
61
62
|
categoryKey,
|
|
62
63
|
categorySection,
|
|
63
64
|
height: initHeight = MAX_LIST_HEIGHT_PX,
|
|
64
|
-
isFilterDrawer,
|
|
65
65
|
itemSize = LIST_ITEM_HEIGHT,
|
|
66
66
|
matchedItems,
|
|
67
67
|
onFilter,
|
|
68
68
|
overscanCount = MAX_DISPLAYABLE_LIST_ITEMS * 2,
|
|
69
|
+
surfaceType,
|
|
69
70
|
width = "100%",
|
|
70
71
|
}: VariableSizeListProps): JSX.Element => {
|
|
71
72
|
const { height: windowHeight } = useWindowResize();
|
|
@@ -87,12 +88,12 @@ export const VariableSizeList = ({
|
|
|
87
88
|
initHeight,
|
|
88
89
|
matchedItems,
|
|
89
90
|
itemSizeByItemKeyRef.current,
|
|
90
|
-
|
|
91
|
+
surfaceType,
|
|
91
92
|
windowHeight,
|
|
92
93
|
outerRef.current
|
|
93
94
|
)
|
|
94
95
|
);
|
|
95
|
-
}, [initHeight,
|
|
96
|
+
}, [initHeight, matchedItems, surfaceType, windowHeight]);
|
|
96
97
|
|
|
97
98
|
// Clears VariableSizeList cache (offsets and measurements) when values are updated (filtered).
|
|
98
99
|
// Facilitates correct positioning of list items when list is updated.
|
|
@@ -104,7 +105,7 @@ export const VariableSizeList = ({
|
|
|
104
105
|
<List
|
|
105
106
|
height={height}
|
|
106
107
|
outerRef={outerRef}
|
|
107
|
-
innerElementType={
|
|
108
|
+
innerElementType={StyledList}
|
|
108
109
|
itemCount={matchedItems.length}
|
|
109
110
|
itemData={{
|
|
110
111
|
categoryKey,
|
|
@@ -132,7 +133,7 @@ export const VariableSizeList = ({
|
|
|
132
133
|
* @param height - Specified height of list.
|
|
133
134
|
* @param matchedItems - Set of search results for category value view models in the given category.
|
|
134
135
|
* @param itemSizeByItemKey - Map of item size by item key.
|
|
135
|
-
* @param
|
|
136
|
+
* @param surfaceType - Surface type is "Drawer" or "Menu".
|
|
136
137
|
* @param windowHeight - Window height.
|
|
137
138
|
* @param outerListElem - Outer list element to reference list position from.
|
|
138
139
|
* @returns calculated height.
|
|
@@ -141,11 +142,11 @@ function calculateListHeight(
|
|
|
141
142
|
height: number,
|
|
142
143
|
matchedItems: FilterMenuSearchMatch[],
|
|
143
144
|
itemSizeByItemKey: ItemSizeByItemKey,
|
|
144
|
-
|
|
145
|
+
surfaceType: SURFACE_TYPE,
|
|
145
146
|
windowHeight: number,
|
|
146
147
|
outerListElem: HTMLDivElement | null
|
|
147
148
|
): number {
|
|
148
|
-
if (
|
|
149
|
+
if (surfaceType === SURFACE_TYPE.DRAWER && outerListElem) {
|
|
149
150
|
return windowHeight - outerListElem.getBoundingClientRect().top;
|
|
150
151
|
}
|
|
151
152
|
if (matchedItems.length > MAX_DISPLAYABLE_LIST_ITEMS) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RowData } from "@tanstack/react-table";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import {
|
|
4
|
+
CategoryKey,
|
|
5
|
+
CategoryValueKey,
|
|
6
|
+
CLEAR_ALL,
|
|
7
|
+
ClearAll,
|
|
8
|
+
} from "../../../../../../common/entities";
|
|
9
|
+
import { updater } from "../../../../../Table/components/TableFeatures/ColumnFilter/utils";
|
|
10
|
+
import { ColumnFiltersAdapterProps } from "./types";
|
|
11
|
+
import { buildColumnFilters, getColumnFiltersCount } from "./utils";
|
|
12
|
+
|
|
13
|
+
export const ColumnFiltersAdapter = <T extends RowData>({
|
|
14
|
+
renderSurface,
|
|
15
|
+
table,
|
|
16
|
+
}: ColumnFiltersAdapterProps<T>): JSX.Element | null => {
|
|
17
|
+
const categoryFilters = buildColumnFilters(table);
|
|
18
|
+
const count = getColumnFiltersCount(table);
|
|
19
|
+
|
|
20
|
+
const onFilter = useCallback(
|
|
21
|
+
(
|
|
22
|
+
categoryKey: CategoryKey | ClearAll,
|
|
23
|
+
selectedCategoryValue: CategoryValueKey,
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- `selected` is not required by TanStack adapter.
|
|
25
|
+
_selected: boolean
|
|
26
|
+
) => {
|
|
27
|
+
if (categoryKey === CLEAR_ALL) {
|
|
28
|
+
table.resetColumnFilters();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
table
|
|
33
|
+
.getColumn(categoryKey)
|
|
34
|
+
?.setFilterValue(updater(selectedCategoryValue));
|
|
35
|
+
},
|
|
36
|
+
[table]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return renderSurface({
|
|
40
|
+
categoryFilters,
|
|
41
|
+
count,
|
|
42
|
+
onFilter,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Column, RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import { CategoryView } from "../../../../../../common/categories/views/types";
|
|
3
|
+
import { SelectCategoryValueView } from "../../../../../../common/entities";
|
|
4
|
+
import { getColumnHeader } from "../../../../../Table/common/utils";
|
|
5
|
+
import { getSortedFacetedValues } from "../../../../../Table/featureOptions/facetedColumn/utils";
|
|
6
|
+
import { SurfaceProps } from "../../../surfaces/types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Adapter for TanStack table column filters to category filters.
|
|
10
|
+
* @param table - Table.
|
|
11
|
+
* @returns Category filters.
|
|
12
|
+
*/
|
|
13
|
+
export function buildColumnFilters<T extends RowData>(
|
|
14
|
+
table: Table<T>
|
|
15
|
+
): SurfaceProps["categoryFilters"] {
|
|
16
|
+
// Build the category views; single category filter.
|
|
17
|
+
const categoryViews = table
|
|
18
|
+
.getAllColumns()
|
|
19
|
+
.filter((column) => column.getCanFilter())
|
|
20
|
+
.map(mapColumnToCategoryView);
|
|
21
|
+
|
|
22
|
+
return [{ categoryViews }];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Adapter for TanStack table column filters to selected count.
|
|
27
|
+
* @param table - Table.
|
|
28
|
+
* @returns Selected count.
|
|
29
|
+
*/
|
|
30
|
+
export function getColumnFiltersCount<T extends RowData>(
|
|
31
|
+
table: Table<T>
|
|
32
|
+
): number {
|
|
33
|
+
return table
|
|
34
|
+
.getState()
|
|
35
|
+
.columnFilters.reduce(
|
|
36
|
+
(acc, columnFilter) => acc + (columnFilter.value as unknown[]).length,
|
|
37
|
+
0
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Adapter for TanStack column to category view.
|
|
43
|
+
* Currently supports only select category views.
|
|
44
|
+
* @param column - Column.
|
|
45
|
+
* @returns Category view.
|
|
46
|
+
*/
|
|
47
|
+
function mapColumnToCategoryView<T extends RowData>(
|
|
48
|
+
column: Column<T>
|
|
49
|
+
): CategoryView {
|
|
50
|
+
const facetedUniqueValues = column.getFacetedUniqueValues();
|
|
51
|
+
const isDisabled = facetedUniqueValues.size === 0;
|
|
52
|
+
const values = mapColumnToSelectCategoryValueView(column);
|
|
53
|
+
return {
|
|
54
|
+
annotation: undefined,
|
|
55
|
+
enableChartView: false,
|
|
56
|
+
isDisabled,
|
|
57
|
+
key: column.id,
|
|
58
|
+
label: getColumnHeader(column),
|
|
59
|
+
values,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Adapter for TanStack column to select category value view.
|
|
65
|
+
* @param column - Column.
|
|
66
|
+
* @returns Select category value view.
|
|
67
|
+
*/
|
|
68
|
+
function mapColumnToSelectCategoryValueView<T extends RowData>(
|
|
69
|
+
column: Column<T>
|
|
70
|
+
): SelectCategoryValueView[] {
|
|
71
|
+
// Get the faceted unique values and sort them.
|
|
72
|
+
const facetedUniqueValues = column.getFacetedUniqueValues();
|
|
73
|
+
const sortedFacetsValues = getSortedFacetedValues(facetedUniqueValues);
|
|
74
|
+
|
|
75
|
+
// Selected values for the column.
|
|
76
|
+
const filterValue = (column.getFilterValue() || []) as unknown[];
|
|
77
|
+
|
|
78
|
+
// Build the select category values.
|
|
79
|
+
const selectCategoryValues: SelectCategoryValueView[] = [];
|
|
80
|
+
for (const [label, count] of sortedFacetsValues) {
|
|
81
|
+
selectCategoryValues.push({
|
|
82
|
+
count,
|
|
83
|
+
key: String(label),
|
|
84
|
+
label: String(label),
|
|
85
|
+
selected: filterValue.includes(label),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return selectCategoryValues;
|
|
90
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Button as MButton, Typography } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CLEAR_ALL } from "../../../../../common/entities";
|
|
4
|
+
import { TYPOGRAPHY_PROPS } from "../../../../../styles/common/mui/typography";
|
|
5
|
+
import { BUTTON_PROPS } from "../../../../common/Button/constants";
|
|
6
|
+
import { BaseComponentProps } from "../../../../types";
|
|
7
|
+
import { SurfaceProps } from "../../surfaces/types";
|
|
8
|
+
import { StyledGrid } from "./controls.styles";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Renders filter title and "Clear All" button.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export const Controls = ({
|
|
15
|
+
className,
|
|
16
|
+
onFilter,
|
|
17
|
+
}: BaseComponentProps & Pick<SurfaceProps, "onFilter">): JSX.Element | null => {
|
|
18
|
+
return (
|
|
19
|
+
<StyledGrid className={className} container>
|
|
20
|
+
<Typography variant={TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_LARGE_500}>
|
|
21
|
+
Filters
|
|
22
|
+
</Typography>
|
|
23
|
+
<MButton
|
|
24
|
+
{...BUTTON_PROPS.PRIMARY_TEXT}
|
|
25
|
+
onClick={() => onFilter(CLEAR_ALL, undefined, false)}
|
|
26
|
+
>
|
|
27
|
+
Clear All
|
|
28
|
+
</MButton>
|
|
29
|
+
</StyledGrid>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { Drawer } from "@mui/material";
|
|
3
|
+
import { PALETTE } from "../../../../../../styles/common/constants/palette";
|
|
4
|
+
|
|
5
|
+
export const StyledDrawer = styled(Drawer)`
|
|
6
|
+
&.MuiDrawer-root {
|
|
7
|
+
.MuiPaper-root {
|
|
8
|
+
background-color: ${PALETTE.SMOKE_LIGHT};
|
|
9
|
+
max-height: 100vh;
|
|
10
|
+
padding: 16px 0;
|
|
11
|
+
width: 312px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
+ .MuiDrawer-root {
|
|
15
|
+
.MuiBackdrop-root {
|
|
16
|
+
background-color: transparent;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { DrawerProvider } from "../../../../../common/Drawer/provider/provider";
|
|
3
|
+
import { Controls } from "../../../controls/Controls/controls";
|
|
4
|
+
import { Filters } from "../../../Filters/filters";
|
|
5
|
+
import { SURFACE_TYPE } from "../../types";
|
|
6
|
+
import { Button as BaseButton } from "../components/Button/button";
|
|
7
|
+
import { IconButton } from "../components/IconButton/iconButton";
|
|
8
|
+
import { DRAWER_PROPS } from "./constants";
|
|
9
|
+
import { StyledDrawer } from "./drawer.styles";
|
|
10
|
+
import { DrawerProps } from "./types";
|
|
11
|
+
|
|
12
|
+
export const Drawer = ({
|
|
13
|
+
Button = BaseButton,
|
|
14
|
+
categoryFilters,
|
|
15
|
+
className,
|
|
16
|
+
count,
|
|
17
|
+
onFilter,
|
|
18
|
+
...props /* MuiDrawerProps */
|
|
19
|
+
}: DrawerProps): JSX.Element | null => {
|
|
20
|
+
return (
|
|
21
|
+
<DrawerProvider>
|
|
22
|
+
{({ onClose, open }) => (
|
|
23
|
+
<Fragment>
|
|
24
|
+
<Button count={count} />
|
|
25
|
+
<StyledDrawer
|
|
26
|
+
{...DRAWER_PROPS}
|
|
27
|
+
className={className}
|
|
28
|
+
onClose={onClose}
|
|
29
|
+
open={open}
|
|
30
|
+
{...props}
|
|
31
|
+
>
|
|
32
|
+
{/* Closes drawer */}
|
|
33
|
+
<IconButton />
|
|
34
|
+
{/* Clear all button */}
|
|
35
|
+
<Controls onFilter={onFilter} />
|
|
36
|
+
<Filters
|
|
37
|
+
categoryFilters={categoryFilters}
|
|
38
|
+
onFilter={onFilter}
|
|
39
|
+
surfaceType={SURFACE_TYPE.DRAWER}
|
|
40
|
+
/>
|
|
41
|
+
</StyledDrawer>
|
|
42
|
+
</Fragment>
|
|
43
|
+
)}
|
|
44
|
+
</DrawerProvider>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DrawerProps as MDrawerProps } from "@mui/material";
|
|
2
|
+
import { BaseComponentProps } from "../../../../../types";
|
|
3
|
+
import { SurfaceProps } from "../../types";
|
|
4
|
+
import { Button } from "../components/Button/button";
|
|
5
|
+
|
|
6
|
+
export interface DrawerProps
|
|
7
|
+
extends BaseComponentProps,
|
|
8
|
+
Omit<MDrawerProps, "children">,
|
|
9
|
+
SurfaceProps {
|
|
10
|
+
Button?: typeof Button;
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FilterListRounded } from "@mui/icons-material";
|
|
2
|
+
import { ButtonProps, Button as MButton } from "@mui/material";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { SVG_ICON_PROPS } from "../../../../../../../styles/common/mui/svgIcon";
|
|
5
|
+
import { BUTTON_PROPS } from "../../../../../../common/Button/constants";
|
|
6
|
+
import { useDrawer } from "../../../../../../common/Drawer/provider/hook";
|
|
7
|
+
import { BaseComponentProps } from "../../../../../../types";
|
|
8
|
+
import { FilterCountChip } from "../../../../FilterCountChip/filterCountChip";
|
|
9
|
+
import { FilterCountChipProps } from "../../../../FilterCountChip/types";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Opens facet-filters drawer.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const Button = ({
|
|
16
|
+
className,
|
|
17
|
+
count = 0,
|
|
18
|
+
...props
|
|
19
|
+
}: BaseComponentProps &
|
|
20
|
+
ButtonProps &
|
|
21
|
+
Pick<FilterCountChipProps, "count">): JSX.Element => {
|
|
22
|
+
const { onOpen } = useDrawer();
|
|
23
|
+
return (
|
|
24
|
+
<MButton
|
|
25
|
+
{...BUTTON_PROPS.SECONDARY_CONTAINED}
|
|
26
|
+
className={className}
|
|
27
|
+
onClick={onOpen}
|
|
28
|
+
startIcon={
|
|
29
|
+
<FilterListRounded
|
|
30
|
+
color={SVG_ICON_PROPS.COLOR.INK_LIGHT}
|
|
31
|
+
fontSize={SVG_ICON_PROPS.FONT_SIZE.SMALL}
|
|
32
|
+
/>
|
|
33
|
+
}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
Filter
|
|
37
|
+
<FilterCountChip count={count} />
|
|
38
|
+
</MButton>
|
|
39
|
+
);
|
|
40
|
+
};
|
package/src/components/Filter/components/surfaces/drawer/components/ButtonBase/buttonBase.styles.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { ButtonBase } from "@mui/material";
|
|
3
|
+
import { textBodyLarge500 } from "../../../../../../../styles/common/mixins/fonts";
|
|
4
|
+
|
|
5
|
+
export const StyledButtonBase = styled(ButtonBase)`
|
|
6
|
+
${textBodyLarge500}
|
|
7
|
+
align-items: center;
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: 8px;
|
|
10
|
+
justify-content: flex-start;
|
|
11
|
+
padding: 12px 16px;
|
|
12
|
+
width: 100%;
|
|
13
|
+
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ButtonProps } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { SVG_ICON_PROPS } from "../../../../../../../styles/common/mui/svgIcon";
|
|
4
|
+
import { SouthIcon } from "../../../../../../common/CustomIcon/components/SouthIcon/southIcon";
|
|
5
|
+
import { useDrawer } from "../../../../../../common/Drawer/provider/hook";
|
|
6
|
+
import { BaseComponentProps } from "../../../../../../types";
|
|
7
|
+
import { StyledButtonBase } from "./buttonBase.styles";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Closes facet-filter drawer.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const ButtonBase = ({
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
...props
|
|
17
|
+
}: BaseComponentProps & ButtonProps): JSX.Element => {
|
|
18
|
+
const { onClose } = useDrawer();
|
|
19
|
+
return (
|
|
20
|
+
<StyledButtonBase className={className} onClick={onClose} {...props}>
|
|
21
|
+
<SouthIcon fontSize={SVG_ICON_PROPS.FONT_SIZE.SMALL} />
|
|
22
|
+
{children}
|
|
23
|
+
</StyledButtonBase>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IconButtonProps, SvgIconProps } from "@mui/material";
|
|
2
|
+
import { ICON_BUTTON_PROPS as MUI_ICON_BUTTON_PROPS } from "../../../../../../../styles/common/mui/iconButton";
|
|
3
|
+
import { SVG_ICON_PROPS as MUI_SVG_ICON_PROPS } from "../../../../../../../styles/common/mui/svgIcon";
|
|
4
|
+
|
|
5
|
+
export const ICON_BUTTON_PROPS: IconButtonProps = {
|
|
6
|
+
color: MUI_ICON_BUTTON_PROPS.COLOR.INHERIT,
|
|
7
|
+
size: MUI_ICON_BUTTON_PROPS.SIZE.MEDIUM,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const SVG_ICON_PROPS: SvgIconProps = {
|
|
11
|
+
fontSize: MUI_SVG_ICON_PROPS.FONT_SIZE.SMALL,
|
|
12
|
+
};
|
package/src/components/Filter/components/surfaces/drawer/components/IconButton/iconButton.styles.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { IconButton } from "@mui/material";
|
|
3
|
+
import { PALETTE } from "../../../../../../../styles/common/constants/palette";
|
|
4
|
+
|
|
5
|
+
export const StyledIconButton = styled(IconButton)`
|
|
6
|
+
color: ${PALETTE.COMMON_WHITE};
|
|
7
|
+
left: calc(100% + 4px);
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: 4px;
|
|
10
|
+
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CloseRounded } from "@mui/icons-material";
|
|
2
|
+
import { IconButtonProps } from "@mui/material";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useDrawer } from "../../../../../../common/Drawer/provider/hook";
|
|
5
|
+
import { BaseComponentProps } from "../../../../../../types";
|
|
6
|
+
import { ICON_BUTTON_PROPS, SVG_ICON_PROPS } from "./constants";
|
|
7
|
+
import { StyledIconButton } from "./iconButton.styles";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Closes facet-filters drawer.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const IconButton = ({
|
|
14
|
+
className,
|
|
15
|
+
...props /* MuiIconButtonProps */
|
|
16
|
+
}: BaseComponentProps & IconButtonProps): JSX.Element | null => {
|
|
17
|
+
const { onClose } = useDrawer();
|
|
18
|
+
return (
|
|
19
|
+
<StyledIconButton
|
|
20
|
+
{...ICON_BUTTON_PROPS}
|
|
21
|
+
className={className}
|
|
22
|
+
onClick={onClose}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
<CloseRounded {...SVG_ICON_PROPS} />
|
|
26
|
+
</StyledIconButton>
|
|
27
|
+
);
|
|
28
|
+
};
|