@databiosphere/findable-ui 29.0.2 → 30.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +22 -0
- package/lib/common/categories/config/types.d.ts +28 -0
- package/lib/common/categories/config/utils.d.ts +31 -0
- package/lib/common/categories/config/utils.js +29 -0
- package/lib/common/categories/models/range/typeGuards.d.ts +14 -0
- package/lib/common/categories/models/range/typeGuards.js +18 -0
- package/lib/common/categories/models/range/types.d.ts +15 -0
- package/lib/common/categories/models/range/types.js +1 -0
- package/lib/common/categories/models/range/utils.d.ts +23 -0
- package/lib/common/categories/models/range/utils.js +41 -0
- package/lib/common/categories/models/select/utils.d.ts +8 -0
- package/lib/common/categories/models/select/utils.js +16 -0
- package/lib/common/categories/models/types.d.ts +6 -0
- package/lib/common/categories/models/types.js +1 -0
- package/lib/common/categories/views/common/types.d.ts +10 -0
- package/lib/common/categories/views/common/types.js +1 -0
- package/lib/common/categories/views/range/typeGuards.d.ts +8 -0
- package/lib/common/categories/views/range/typeGuards.js +8 -0
- package/lib/common/categories/views/range/types.d.ts +19 -0
- package/lib/common/categories/views/range/types.js +1 -0
- package/lib/common/categories/views/range/utils.d.ts +12 -0
- package/lib/common/categories/views/range/utils.js +24 -0
- package/lib/common/categories/views/select/typeGuards.d.ts +8 -0
- package/lib/common/categories/views/select/typeGuards.js +8 -0
- package/lib/common/categories/views/select/types.d.ts +7 -0
- package/lib/common/categories/views/select/types.js +1 -0
- package/lib/common/categories/views/types.d.ts +13 -0
- package/lib/common/categories/views/types.js +8 -0
- package/lib/common/entities.d.ts +5 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.d.ts +3 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.js +6 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.d.ts +9 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.js +12 -0
- package/lib/components/DataDictionary/dataDictionary.styles.js +2 -3
- package/lib/components/Filter/components/Filter/filter.d.ts +2 -2
- package/lib/components/Filter/components/Filter/filter.js +11 -3
- package/lib/components/Filter/components/Filter/stories/args.d.ts +5 -0
- package/lib/components/Filter/components/Filter/stories/args.js +19 -0
- package/lib/components/Filter/components/Filter/stories/filter.stories.d.ts +8 -0
- package/lib/components/Filter/components/Filter/stories/filter.stories.js +21 -0
- package/lib/components/Filter/components/FilterMenu/filterMenu.js +2 -2
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.d.ts +1 -1
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.js +1 -1
- package/lib/components/Filter/components/FilterRange/constants.d.ts +0 -2
- package/lib/components/Filter/components/FilterRange/constants.js +0 -5
- package/lib/components/Filter/components/FilterRange/filterRange.d.ts +1 -1
- package/lib/components/Filter/components/FilterRange/filterRange.js +50 -21
- package/lib/components/Filter/components/FilterRange/filterRange.styles.js +58 -10
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.d.ts +5 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.js +5 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.d.ts +2 -2
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.js +32 -7
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.d.ts +6 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.js +50 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.d.ts +26 -3
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.js +6 -1
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.d.ts +15 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.js +25 -0
- package/lib/components/Filter/components/FilterRange/stories/args.d.ts +3 -0
- package/lib/components/Filter/components/FilterRange/stories/args.js +13 -0
- package/lib/components/Filter/components/FilterRange/stories/filterRange.stories.js +2 -2
- package/lib/components/Filter/components/FilterRange/types.d.ts +10 -6
- package/lib/components/Filter/components/FilterRange/types.js +1 -6
- package/lib/components/Filter/components/FilterRange/utils.d.ts +8 -0
- package/lib/components/Filter/components/FilterRange/utils.js +15 -0
- package/lib/components/Filter/components/FilterTag/stories/args.d.ts +5 -0
- package/lib/components/Filter/components/FilterTag/stories/args.js +17 -0
- package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.d.ts +8 -0
- package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.js +21 -0
- package/lib/components/Filter/components/FilterTag/utils.d.ts +10 -0
- package/lib/components/Filter/components/FilterTag/utils.js +40 -0
- package/lib/components/Filter/components/Filters/filters.d.ts +2 -2
- package/lib/components/Filter/components/Filters/filters.js +15 -8
- package/lib/components/Filter/components/Filters/stories/args.d.ts +3 -0
- package/lib/components/Filter/components/Filters/stories/args.js +15 -0
- package/lib/components/Filter/components/Filters/stories/constants.d.ts +22 -0
- package/lib/components/Filter/components/Filters/stories/constants.js +134 -0
- package/lib/components/Filter/components/Filters/stories/filters.stories.d.ts +6 -0
- package/lib/components/Filter/components/Filters/stories/filters.stories.js +15 -0
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.d.ts +1 -1
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.js +5 -5
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.js +2 -1
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.d.ts +3 -2
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.js +6 -4
- package/lib/components/Filter/components/VariableSizeListItem/variableSizeListItem.js +2 -1
- package/lib/components/Index/components/EntitiesView/components/ChartView/utils.js +2 -0
- package/lib/components/Index/table/hook.js +4 -0
- package/lib/components/Table/columnDef/accessorFn/typeGuards.d.ts +9 -0
- package/lib/components/Table/columnDef/accessorFn/typeGuards.js +10 -0
- package/lib/components/Table/common/utils.d.ts +2 -2
- package/lib/components/Table/common/utils.js +28 -13
- package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.js +8 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.js +21 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.d.ts +6 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.js +27 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.d.ts +9 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.js +18 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.js +1 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/utils.d.ts +22 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/utils.js +45 -0
- package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.d.ts +8 -0
- package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.js +46 -0
- package/lib/components/common/Link/typeGuards.d.ts +13 -0
- package/lib/components/common/Link/typeGuards.js +21 -0
- package/lib/config/entities.d.ts +2 -11
- package/lib/hooks/useCategoryFilter.d.ts +8 -13
- package/lib/hooks/useCategoryFilter.js +31 -28
- package/lib/providers/exploreState/entities.d.ts +5 -3
- package/lib/providers/exploreState/payloads/entities.d.ts +6 -2
- package/lib/providers/exploreState.d.ts +3 -2
- package/lib/providers/exploreState.js +1 -1
- package/lib/tests/utils.d.ts +24 -0
- package/lib/tests/utils.js +34 -0
- package/lib/theme/common/components.js +19 -1
- package/lib/views/ExploreView/exploreView.js +10 -8
- package/package.json +2 -1
- package/src/common/categories/config/types.ts +42 -0
- package/src/common/categories/config/utils.ts +47 -0
- package/src/common/categories/models/range/typeGuards.ts +24 -0
- package/src/common/categories/models/range/types.ts +17 -0
- package/src/common/categories/models/range/utils.ts +51 -0
- package/src/common/categories/models/select/utils.ts +23 -0
- package/src/common/categories/models/types.ts +7 -0
- package/src/common/categories/views/common/types.ts +11 -0
- package/src/common/categories/views/range/typeGuards.ts +13 -0
- package/src/common/categories/views/range/types.ts +21 -0
- package/src/common/categories/views/range/utils.ts +35 -0
- package/src/common/categories/views/select/typeGuards.ts +13 -0
- package/src/common/categories/views/select/types.ts +8 -0
- package/src/common/categories/views/types.ts +15 -0
- package/src/common/entities.ts +10 -5
- package/src/components/DataDictionary/components/Table/components/BasicCell/basicCell.tsx +12 -4
- package/src/components/DataDictionary/components/Table/components/BasicCell/utils.ts +13 -0
- package/src/components/DataDictionary/dataDictionary.styles.ts +2 -3
- package/src/components/Filter/components/Filter/filter.tsx +38 -13
- package/src/components/Filter/components/Filter/stories/args.ts +24 -0
- package/src/components/Filter/components/Filter/stories/filter.stories.tsx +32 -0
- package/src/components/Filter/components/FilterMenu/filterMenu.styles.ts +1 -1
- package/src/components/Filter/components/FilterMenu/filterMenu.tsx +7 -3
- package/src/components/Filter/components/FilterRange/constants.ts +0 -7
- package/src/components/Filter/components/FilterRange/filterRange.styles.ts +58 -14
- package/src/components/Filter/components/FilterRange/filterRange.tsx +112 -40
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.ts +5 -0
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.ts +51 -10
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.ts +60 -0
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/types.ts +34 -3
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.ts +32 -0
- package/src/components/Filter/components/FilterRange/stories/args.ts +16 -0
- package/src/components/Filter/components/FilterRange/stories/filterRange.stories.tsx +2 -2
- package/src/components/Filter/components/FilterRange/types.ts +12 -6
- package/src/components/Filter/components/FilterRange/utils.ts +16 -0
- package/src/components/Filter/components/FilterTag/stories/args.ts +22 -0
- package/src/components/Filter/components/FilterTag/stories/filterTag.stories.tsx +32 -0
- package/src/components/Filter/components/FilterTag/utils.ts +57 -0
- package/src/components/Filter/components/Filters/filters.tsx +21 -12
- package/src/components/Filter/components/Filters/stories/args.ts +24 -0
- package/src/components/Filter/components/Filters/stories/constants.ts +151 -0
- package/src/components/Filter/components/Filters/stories/filters.stories.tsx +24 -0
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.tsx +32 -29
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.tsx +9 -1
- package/src/components/Filter/components/SearchAllFilters/searchAllFilters.tsx +12 -6
- package/src/components/Filter/components/VariableSizeListItem/variableSizeListItem.tsx +2 -1
- package/src/components/Index/components/EntitiesView/components/ChartView/utils.ts +2 -0
- package/src/components/Index/table/hook.ts +4 -0
- package/src/components/Table/columnDef/accessorFn/typeGuards.ts +15 -0
- package/src/components/Table/common/utils.ts +37 -16
- package/src/components/Table/components/TableCell/components/ChipCell/chipCell.tsx +14 -0
- package/src/components/Table/components/TableCell/components/LinkCell/linkCell.tsx +64 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/args.ts +35 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.tsx +32 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/types.ts +4 -0
- package/src/components/Table/components/TableCell/components/LinkCell/utils.ts +59 -0
- package/src/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.ts +64 -0
- package/src/components/common/Link/typeGuards.ts +35 -0
- package/src/config/entities.ts +1 -14
- package/src/hooks/useCategoryFilter.ts +56 -53
- package/src/providers/exploreState/entities.ts +3 -3
- package/src/providers/exploreState/initializer/utils.ts +1 -1
- package/src/providers/exploreState/payloads/entities.ts +5 -2
- package/src/providers/exploreState.tsx +5 -3
- package/src/tests/utils.ts +44 -0
- package/src/theme/common/components.ts +19 -1
- package/src/views/ExploreView/exploreView.tsx +17 -22
- package/tests/filter.test.tsx +100 -0
- package/tests/filterRange.test.tsx +331 -46
- package/tests/filters.test.tsx +61 -0
- package/tests/getFacetedMinMaxValues.test.ts +166 -0
- package/tests/linkCell.test.tsx +89 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +0 -3
- package/lib/components/Filter/components/Filter/filter.stories.d.ts +0 -25
- package/lib/components/Filter/components/Filter/filter.stories.js +0 -42
- package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +0 -16
- package/lib/components/Filter/components/FilterTag/filterTag.stories.js +0 -17
- package/lib/components/Filter/components/Filters/filters.stories.d.ts +0 -6
- package/lib/components/Filter/components/Filters/filters.stories.js +0 -91
- package/src/components/DataDictionary/components/Table/components/BasicCell/types.ts +0 -7
- package/src/components/Filter/components/Filter/filter.stories.tsx +0 -52
- package/src/components/Filter/components/FilterTag/filterTag.stories.tsx +0 -23
- package/src/components/Filter/components/Filters/filters.stories.tsx +0 -101
- package/tests/filterRangeMock.test.tsx +0 -38
- /package/lib/{components/DataDictionary/components/Table/components/BasicCell → common/categories/config}/types.js +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Filter } from "../filter";
|
|
4
|
+
import { DISABLED_SELECT_ARGS, RANGE_ARGS, SELECT_ARGS } from "./args";
|
|
5
|
+
const meta = {
|
|
6
|
+
component: Filter,
|
|
7
|
+
decorators: [
|
|
8
|
+
(Story) => (React.createElement(Box, { sx: { width: 248 } },
|
|
9
|
+
React.createElement(Story, null))),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
export const SelectCategory = {
|
|
14
|
+
args: SELECT_ARGS,
|
|
15
|
+
};
|
|
16
|
+
export const DisabledSelectCategory = {
|
|
17
|
+
args: DISABLED_SELECT_ARGS,
|
|
18
|
+
};
|
|
19
|
+
export const RangeCategory = {
|
|
20
|
+
args: RANGE_ARGS,
|
|
21
|
+
};
|
|
@@ -6,14 +6,14 @@ import { List } from "../FilterList/filterList.styles";
|
|
|
6
6
|
import { FilterMenuSearch } from "../FilterMenuSearch/filterMenuSearch";
|
|
7
7
|
import { FilterNoResultsFound } from "../FilterNoResultsFound/filterNoResultsFound";
|
|
8
8
|
import { VariableSizeList } from "../VariableSizeList/VariableSizeList";
|
|
9
|
-
import {
|
|
9
|
+
import { FilterView, FilterViewTools, StyledButtonBase, } from "./filterMenu.styles";
|
|
10
10
|
export const FilterMenu = ({ categoryKey, categoryLabel, categorySection, isFilterDrawer, menuWidth = 312, onCloseFilter, onFilter, values, }) => {
|
|
11
11
|
const [searchTerm, setSearchTerm] = useState("");
|
|
12
12
|
const isSearchable = isFilterDrawer || values.length > MAX_DISPLAYABLE_LIST_ITEMS;
|
|
13
13
|
const matchedItems = applyMenuFilter(values, isSearchable ? searchTerm : "");
|
|
14
14
|
return (React.createElement(FilterView, { menuWidth: menuWidth },
|
|
15
15
|
React.createElement(FilterViewTools, null,
|
|
16
|
-
isFilterDrawer && (React.createElement(
|
|
16
|
+
isFilterDrawer && (React.createElement(StyledButtonBase, { onClick: onCloseFilter },
|
|
17
17
|
React.createElement(SouthIcon, { fontSize: "small" }),
|
|
18
18
|
categoryLabel)),
|
|
19
19
|
isSearchable && (React.createElement(FilterMenuSearch, { searchTerm: searchTerm, setSearchTerm: setSearchTerm }))),
|
|
@@ -9,7 +9,7 @@ export declare const FilterViewTools: import("@emotion/styled").StyledComponent<
|
|
|
9
9
|
theme?: import("@emotion/react").Theme;
|
|
10
10
|
as?: React.ElementType;
|
|
11
11
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const StyledButtonBase: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonBaseOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
13
13
|
ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
14
14
|
}, "style" | "className" | "classes" | "tabIndex" | "children" | "sx" | "disabled" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef"> & {
|
|
15
15
|
theme?: import("@emotion/react").Theme;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ButtonProps, DividerProps, InputLabelProps, OutlinedInputProps, ToggleButtonGroupProps } from "@mui/material";
|
|
2
|
-
import { RANGE_OPERATOR } from "./types";
|
|
3
2
|
export declare const BUTTON_PROPS: ButtonProps;
|
|
4
3
|
export declare const DIVIDER_PROPS: DividerProps;
|
|
5
4
|
export declare const INPUT_PROPS: OutlinedInputProps;
|
|
6
5
|
export declare const INPUT_LABEL_PROPS: InputLabelProps;
|
|
7
|
-
export declare const RANGE_OPERATOR_DISPLAY: Record<RANGE_OPERATOR, string>;
|
|
8
6
|
export declare const TOGGLE_BUTTON_GROUP_PROPS: ToggleButtonGroupProps;
|
|
@@ -16,11 +16,6 @@ export const INPUT_LABEL_PROPS = {
|
|
|
16
16
|
disableAnimation: true,
|
|
17
17
|
shrink: true,
|
|
18
18
|
};
|
|
19
|
-
export const RANGE_OPERATOR_DISPLAY = {
|
|
20
|
-
between: "From",
|
|
21
|
-
greaterThan: "Greater Than",
|
|
22
|
-
lessThan: "Less Than",
|
|
23
|
-
};
|
|
24
19
|
export const TOGGLE_BUTTON_GROUP_PROPS = {
|
|
25
20
|
exclusive: true,
|
|
26
21
|
fullWidth: true,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FilterRangeProps } from "./types";
|
|
2
|
-
export declare const FilterRange: ({ className }: FilterRangeProps) => JSX.Element;
|
|
2
|
+
export declare const FilterRange: ({ categoryKey, categoryLabel, categorySection, className, isFilterDrawer, max, min, onCloseFilter, onFilter, selectedMax, selectedMin, unit, }: FilterRangeProps) => JSX.Element;
|
|
@@ -1,26 +1,55 @@
|
|
|
1
|
-
import { Button, Divider, FormControl, Grid, InputLabel, OutlinedInput, ToggleButton, ToggleButtonGroup, } from "@mui/material";
|
|
1
|
+
import { Button, Divider, FormControl, FormHelperText, Grid, InputLabel, OutlinedInput, ToggleButton, ToggleButtonGroup, } from "@mui/material";
|
|
2
2
|
import React, { Fragment } from "react";
|
|
3
3
|
import { TEST_IDS } from "../../../../tests/testIds";
|
|
4
|
-
import {
|
|
4
|
+
import { SouthIcon } from "../../../common/CustomIcon/components/SouthIcon/southIcon";
|
|
5
|
+
import { FilterViewTools, StyledButtonBase, } from "../FilterMenu/filterMenu.styles";
|
|
6
|
+
import { BUTTON_PROPS, DIVIDER_PROPS, INPUT_LABEL_PROPS, INPUT_PROPS, TOGGLE_BUTTON_GROUP_PROPS, } from "./constants";
|
|
5
7
|
import { StyledForm } from "./filterRange.styles";
|
|
8
|
+
import { FIELD_NAME } from "./hooks/UseFilterRange/constants";
|
|
6
9
|
import { useFilterRange } from "./hooks/UseFilterRange/hook";
|
|
7
|
-
import { RANGE_OPERATOR } from "./types";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
React.createElement(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
import { RANGE_OPERATOR } from "./hooks/UseFilterRange/types";
|
|
11
|
+
import { getRangeOperator } from "./utils";
|
|
12
|
+
export const FilterRange = ({ categoryKey, categoryLabel, categorySection, className, isFilterDrawer, max, min, onCloseFilter, onFilter, selectedMax, selectedMin, unit, }) => {
|
|
13
|
+
const rangeOperator = getRangeOperator({ selectedMax, selectedMin });
|
|
14
|
+
const { clearErrors, formState: { errors }, handleSubmit, onChange, value, } = useFilterRange(rangeOperator);
|
|
15
|
+
return (React.createElement(Fragment, null,
|
|
16
|
+
isFilterDrawer && (React.createElement(FilterViewTools, null,
|
|
17
|
+
React.createElement(StyledButtonBase, { onClick: onCloseFilter },
|
|
18
|
+
React.createElement(SouthIcon, { fontSize: "small" }),
|
|
19
|
+
categoryLabel))),
|
|
20
|
+
React.createElement(StyledForm, { className: className, "data-testid": TEST_IDS.FILTER_RANGE, onSubmit: handleSubmit(onFilter, {
|
|
21
|
+
categoryKey,
|
|
22
|
+
categorySection,
|
|
23
|
+
}) },
|
|
24
|
+
React.createElement(ToggleButtonGroup, { ...TOGGLE_BUTTON_GROUP_PROPS, onChange: (e, value) => {
|
|
25
|
+
clearErrors();
|
|
26
|
+
onChange?.(e, value);
|
|
27
|
+
}, value: value },
|
|
28
|
+
React.createElement(ToggleButton, { value: RANGE_OPERATOR.BETWEEN }, "Between"),
|
|
29
|
+
React.createElement(ToggleButton, { value: RANGE_OPERATOR.LESS_THAN }, "Less Than"),
|
|
30
|
+
React.createElement(Divider, { ...DIVIDER_PROPS }),
|
|
31
|
+
React.createElement(ToggleButton, { value: RANGE_OPERATOR.GREATER_THAN }, "Greater Than")),
|
|
32
|
+
React.createElement(Grid, null,
|
|
33
|
+
value !== RANGE_OPERATOR.LESS_THAN && (React.createElement(FormControl, { error: !!errors[FIELD_NAME.MIN] },
|
|
34
|
+
React.createElement(InputLabel, { ...INPUT_LABEL_PROPS, htmlFor: FIELD_NAME.MIN },
|
|
35
|
+
value === RANGE_OPERATOR.BETWEEN ? "Min" : "Greater Than",
|
|
36
|
+
unit && ` (${unit})`),
|
|
37
|
+
React.createElement(OutlinedInput, { ...INPUT_PROPS, defaultValue: selectedMin, id: FIELD_NAME.MIN, name: FIELD_NAME.MIN, onFocus: clearErrors, placeholder: "eg. 1" }),
|
|
38
|
+
React.createElement(FormHelperText, null, errors[FIELD_NAME.MIN]
|
|
39
|
+
? errors[FIELD_NAME.MIN]
|
|
40
|
+
: value === RANGE_OPERATOR.BETWEEN
|
|
41
|
+
? `Min allowed: ${min}`
|
|
42
|
+
: `Allowed values: \u2265 ${min} and \u2264 ${max}`))),
|
|
43
|
+
value === RANGE_OPERATOR.BETWEEN && React.createElement(Divider, null),
|
|
44
|
+
value !== RANGE_OPERATOR.GREATER_THAN && (React.createElement(FormControl, { error: !!errors[FIELD_NAME.MAX] },
|
|
45
|
+
React.createElement(InputLabel, { ...INPUT_LABEL_PROPS, htmlFor: FIELD_NAME.MAX },
|
|
46
|
+
value === RANGE_OPERATOR.BETWEEN ? "Max" : "Less Than",
|
|
47
|
+
unit && ` (${unit})`),
|
|
48
|
+
React.createElement(OutlinedInput, { ...INPUT_PROPS, defaultValue: selectedMax, id: FIELD_NAME.MAX, name: FIELD_NAME.MAX, onFocus: clearErrors, placeholder: "eg. 20" }),
|
|
49
|
+
React.createElement(FormHelperText, { color: "inkLight" }, errors[FIELD_NAME.MAX]
|
|
50
|
+
? errors[FIELD_NAME.MAX]
|
|
51
|
+
: value === RANGE_OPERATOR.BETWEEN
|
|
52
|
+
? `Max allowed: ${max}`
|
|
53
|
+
: `Allowed values: \u2265 ${min} and \u2264 ${max}`)))),
|
|
54
|
+
React.createElement(Button, { ...BUTTON_PROPS }, "Filter"))));
|
|
26
55
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled from "@emotion/styled";
|
|
2
|
-
import {
|
|
2
|
+
import { PALETTE } from "../../../../styles/common/constants/palette";
|
|
3
|
+
import { mediaDesktopSmallDown } from "../../../../styles/common/mixins/breakpoints";
|
|
3
4
|
import { textBody400 } from "../../../../styles/common/mixins/fonts";
|
|
4
5
|
export const StyledForm = styled("form") `
|
|
5
6
|
padding: 16px;
|
|
@@ -10,16 +11,16 @@ export const StyledForm = styled("form") `
|
|
|
10
11
|
width: 100%;
|
|
11
12
|
|
|
12
13
|
.MuiToggleButton-root {
|
|
13
|
-
color: ${
|
|
14
|
+
color: ${PALETTE.INK_LIGHT};
|
|
14
15
|
text-transform: capitalize;
|
|
15
16
|
|
|
16
17
|
&.Mui-selected {
|
|
17
|
-
color: ${
|
|
18
|
+
color: ${PALETTE.INK_MAIN};
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
.MuiDivider-root {
|
|
22
|
-
border-color: ${
|
|
23
|
+
border-color: ${PALETTE.SMOKE_DARK};
|
|
23
24
|
border-radius: 4px;
|
|
24
25
|
margin: 6px 0;
|
|
25
26
|
}
|
|
@@ -29,31 +30,58 @@ export const StyledForm = styled("form") `
|
|
|
29
30
|
display: grid;
|
|
30
31
|
gap: 4px 0;
|
|
31
32
|
grid-auto-flow: column;
|
|
32
|
-
grid-template-rows: auto auto;
|
|
33
|
+
grid-template-rows: auto auto auto;
|
|
33
34
|
margin: 12px 0 16px 0;
|
|
34
35
|
|
|
35
36
|
.MuiFormControl-root {
|
|
36
37
|
display: grid;
|
|
37
|
-
gap:
|
|
38
|
+
gap: 4px 0;
|
|
38
39
|
grid-row: 1 / -1;
|
|
39
40
|
grid-template-rows: subgrid;
|
|
40
41
|
|
|
41
42
|
.MuiInputLabel-root {
|
|
42
43
|
${textBody400};
|
|
43
|
-
color: ${
|
|
44
|
+
color: ${PALETTE.INK_MAIN};
|
|
44
45
|
max-width: unset;
|
|
45
46
|
position: relative;
|
|
46
47
|
transform: unset;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
.MuiOutlinedInput-
|
|
50
|
-
|
|
50
|
+
.MuiOutlinedInput-root {
|
|
51
|
+
.MuiOutlinedInput-input {
|
|
52
|
+
padding-right: 10px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
input::placeholder {
|
|
56
|
+
color: ${PALETTE.INK_LIGHT};
|
|
57
|
+
opacity: 0.8;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&.Mui-focused {
|
|
61
|
+
input::placeholder {
|
|
62
|
+
opacity: 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.MuiFormLabel-filled + .MuiOutlinedInput-root {
|
|
68
|
+
.MuiOutlinedInput-input {
|
|
69
|
+
color: ${PALETTE.INK_MAIN};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.MuiFormHelperText-root {
|
|
74
|
+
color: ${PALETTE.INK_LIGHT};
|
|
75
|
+
|
|
76
|
+
&.Mui-error {
|
|
77
|
+
color: ${PALETTE.ALERT_MAIN};
|
|
78
|
+
}
|
|
51
79
|
}
|
|
52
80
|
}
|
|
53
81
|
|
|
54
82
|
.MuiDivider-root {
|
|
55
83
|
align-self: center;
|
|
56
|
-
border-color: ${
|
|
84
|
+
border-color: ${PALETTE.INK_LIGHT};
|
|
57
85
|
grid-row: 2;
|
|
58
86
|
margin: 0 4px;
|
|
59
87
|
width: 8px;
|
|
@@ -63,4 +91,24 @@ export const StyledForm = styled("form") `
|
|
|
63
91
|
.MuiButton-root {
|
|
64
92
|
grid-column: 1 / -1;
|
|
65
93
|
}
|
|
94
|
+
|
|
95
|
+
${mediaDesktopSmallDown} {
|
|
96
|
+
padding: 0 16px;
|
|
97
|
+
width: 312px;
|
|
98
|
+
|
|
99
|
+
.MuiGrid-root {
|
|
100
|
+
gap: 16px 0;
|
|
101
|
+
grid-template-rows: auto auto;
|
|
102
|
+
margin: 16px 0;
|
|
103
|
+
|
|
104
|
+
.MuiFormControl-root {
|
|
105
|
+
grid-row: unset;
|
|
106
|
+
grid-template-rows: unset;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.MuiDivider-root {
|
|
110
|
+
display: none;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
66
114
|
`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseFilterRange } from "./types";
|
|
2
|
-
export declare const useFilterRange: () => UseFilterRange;
|
|
1
|
+
import { RANGE_OPERATOR, UseFilterRange } from "./types";
|
|
2
|
+
export declare const useFilterRange: (initialValue?: RANGE_OPERATOR) => UseFilterRange;
|
|
@@ -1,14 +1,39 @@
|
|
|
1
|
-
import { useCallback } from "react";
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { VIEW_KIND } from "../../../../../../common/categories/views/types";
|
|
2
3
|
import { useToggleButtonGroup } from "../../../../../common/ToggleButtonGroup/hooks/UseToggleButtonGroup/hook";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { SCHEMA } from "./schema";
|
|
5
|
+
import { RANGE_OPERATOR, } from "./types";
|
|
6
|
+
import { getFormValues } from "./utils";
|
|
7
|
+
export const useFilterRange = (initialValue = RANGE_OPERATOR.BETWEEN) => {
|
|
8
|
+
const [errors, setErrors] = useState({});
|
|
9
|
+
const { onChange, value } = useToggleButtonGroup(initialValue);
|
|
10
|
+
const clearErrors = useCallback(() => {
|
|
11
|
+
setErrors({});
|
|
8
12
|
}, []);
|
|
13
|
+
const handleSubmit = useCallback((onSubmit, parameters) => {
|
|
14
|
+
return (e) => {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
const fieldValues = getFormValues(e.currentTarget, value); // `value` is current range operator.
|
|
17
|
+
SCHEMA.validate(fieldValues, { abortEarly: false })
|
|
18
|
+
.then((result) => {
|
|
19
|
+
setErrors({});
|
|
20
|
+
onSubmit(parameters.categoryKey, [result.min, result.max], true, parameters.categorySection, VIEW_KIND.RANGE);
|
|
21
|
+
})
|
|
22
|
+
.catch((validationError) => {
|
|
23
|
+
const fieldErrors = {};
|
|
24
|
+
for (const error of validationError.inner) {
|
|
25
|
+
if (error.path)
|
|
26
|
+
fieldErrors[error.path] = error.message;
|
|
27
|
+
}
|
|
28
|
+
setErrors(fieldErrors);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}, [value]);
|
|
9
32
|
return {
|
|
33
|
+
clearErrors,
|
|
34
|
+
formState: { errors },
|
|
35
|
+
handleSubmit,
|
|
10
36
|
onChange,
|
|
11
|
-
onSubmit,
|
|
12
37
|
value,
|
|
13
38
|
};
|
|
14
39
|
};
|
|
@@ -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;
|