@databiosphere/findable-ui 29.0.2 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +35 -0
- package/lib/common/categories/config/types.d.ts +28 -0
- package/lib/common/categories/config/utils.d.ts +31 -0
- package/lib/common/categories/config/utils.js +29 -0
- package/lib/common/categories/models/range/typeGuards.d.ts +14 -0
- package/lib/common/categories/models/range/typeGuards.js +18 -0
- package/lib/common/categories/models/range/types.d.ts +15 -0
- package/lib/common/categories/models/range/types.js +1 -0
- package/lib/common/categories/models/range/utils.d.ts +23 -0
- package/lib/common/categories/models/range/utils.js +41 -0
- package/lib/common/categories/models/select/utils.d.ts +8 -0
- package/lib/common/categories/models/select/utils.js +16 -0
- package/lib/common/categories/models/types.d.ts +6 -0
- package/lib/common/categories/models/types.js +1 -0
- package/lib/common/categories/views/common/types.d.ts +10 -0
- package/lib/common/categories/views/common/types.js +1 -0
- package/lib/common/categories/views/range/typeGuards.d.ts +8 -0
- package/lib/common/categories/views/range/typeGuards.js +8 -0
- package/lib/common/categories/views/range/types.d.ts +19 -0
- package/lib/common/categories/views/range/types.js +1 -0
- package/lib/common/categories/views/range/utils.d.ts +12 -0
- package/lib/common/categories/views/range/utils.js +24 -0
- package/lib/common/categories/views/select/typeGuards.d.ts +8 -0
- package/lib/common/categories/views/select/typeGuards.js +8 -0
- package/lib/common/categories/views/select/types.d.ts +7 -0
- package/lib/common/categories/views/select/types.js +1 -0
- package/lib/common/categories/views/types.d.ts +13 -0
- package/lib/common/categories/views/types.js +8 -0
- package/lib/common/entities.d.ts +8 -23
- package/lib/components/DataDictionary/components/Entities/entities.d.ts +3 -1
- package/lib/components/DataDictionary/components/Entities/entities.js +1 -1
- package/lib/components/DataDictionary/components/Entities/types.d.ts +5 -5
- package/lib/components/DataDictionary/components/Entity/entity.d.ts +3 -1
- package/lib/components/DataDictionary/components/Entity/entity.js +6 -6
- package/lib/components/DataDictionary/components/Entity/types.d.ts +5 -5
- package/lib/components/DataDictionary/components/Outline/utils.d.ts +3 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.d.ts +3 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.js +6 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.d.ts +9 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.js +12 -0
- package/lib/components/DataDictionary/components/Table/hook.d.ts +3 -3
- package/lib/components/DataDictionary/components/Table/hook.js +3 -1
- package/lib/components/DataDictionary/components/Table/options/core/constants.d.ts +2 -3
- package/lib/components/DataDictionary/components/Table/options/hook.d.ts +2 -2
- package/lib/components/DataDictionary/components/Table/options/sorting/constants.d.ts +2 -3
- package/lib/components/DataDictionary/components/Table/table.d.ts +2 -1
- package/lib/components/DataDictionary/components/Table/table.js +1 -1
- package/lib/components/DataDictionary/components/Table/types.d.ts +3 -4
- package/lib/components/DataDictionary/dataDictionary.d.ts +3 -1
- package/lib/components/DataDictionary/dataDictionary.styles.js +2 -3
- package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.d.ts +3 -1
- package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +5 -5
- package/lib/components/Filter/components/Filter/filter.d.ts +2 -2
- package/lib/components/Filter/components/Filter/filter.js +11 -3
- package/lib/components/Filter/components/Filter/stories/args.d.ts +5 -0
- package/lib/components/Filter/components/Filter/stories/args.js +19 -0
- package/lib/components/Filter/components/Filter/stories/filter.stories.d.ts +8 -0
- package/lib/components/Filter/components/Filter/stories/filter.stories.js +21 -0
- package/lib/components/Filter/components/FilterMenu/filterMenu.js +2 -2
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.d.ts +1 -1
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.js +1 -1
- package/lib/components/Filter/components/FilterRange/constants.d.ts +0 -2
- package/lib/components/Filter/components/FilterRange/constants.js +0 -5
- package/lib/components/Filter/components/FilterRange/filterRange.d.ts +1 -1
- package/lib/components/Filter/components/FilterRange/filterRange.js +50 -21
- package/lib/components/Filter/components/FilterRange/filterRange.styles.js +58 -10
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.d.ts +5 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.js +5 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.d.ts +2 -2
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.js +32 -7
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.d.ts +6 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.js +50 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.d.ts +26 -3
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.js +6 -1
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.d.ts +15 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.js +25 -0
- package/lib/components/Filter/components/FilterRange/stories/args.d.ts +3 -0
- package/lib/components/Filter/components/FilterRange/stories/args.js +13 -0
- package/lib/components/Filter/components/FilterRange/stories/filterRange.stories.js +2 -2
- package/lib/components/Filter/components/FilterRange/types.d.ts +10 -6
- package/lib/components/Filter/components/FilterRange/types.js +1 -6
- package/lib/components/Filter/components/FilterRange/utils.d.ts +8 -0
- package/lib/components/Filter/components/FilterRange/utils.js +15 -0
- package/lib/components/Filter/components/FilterTag/stories/args.d.ts +5 -0
- package/lib/components/Filter/components/FilterTag/stories/args.js +17 -0
- package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.d.ts +8 -0
- package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.js +21 -0
- package/lib/components/Filter/components/FilterTag/utils.d.ts +10 -0
- package/lib/components/Filter/components/FilterTag/utils.js +40 -0
- package/lib/components/Filter/components/Filters/filters.d.ts +2 -2
- package/lib/components/Filter/components/Filters/filters.js +15 -8
- package/lib/components/Filter/components/Filters/stories/args.d.ts +3 -0
- package/lib/components/Filter/components/Filters/stories/args.js +15 -0
- package/lib/components/Filter/components/Filters/stories/constants.d.ts +22 -0
- package/lib/components/Filter/components/Filters/stories/constants.js +134 -0
- package/lib/components/Filter/components/Filters/stories/filters.stories.d.ts +6 -0
- package/lib/components/Filter/components/Filters/stories/filters.stories.js +15 -0
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.d.ts +1 -1
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.js +5 -5
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.js +2 -1
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.d.ts +3 -2
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.js +6 -4
- package/lib/components/Filter/components/VariableSizeListItem/variableSizeListItem.js +2 -1
- package/lib/components/Index/components/EntitiesView/components/ChartView/utils.js +2 -0
- package/lib/components/Index/table/hook.js +4 -0
- package/lib/components/MarkdownRenderer/components/Anchor/anchor.d.ts +19 -0
- package/lib/components/MarkdownRenderer/components/Anchor/anchor.js +21 -0
- package/lib/components/MarkdownRenderer/components/Table/table.d.ts +3 -0
- package/lib/components/MarkdownRenderer/components/Table/table.js +5 -0
- package/lib/components/MarkdownRenderer/components/Table/table.styles.d.ts +4 -0
- package/lib/components/MarkdownRenderer/components/Table/table.styles.js +40 -0
- package/lib/components/MarkdownRenderer/constants.d.ts +2 -0
- package/lib/components/MarkdownRenderer/constants.js +6 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.d.ts +2 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.js +45 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.styles.d.ts +4 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.styles.js +13 -0
- package/lib/components/MarkdownRenderer/types.d.ts +6 -0
- package/lib/components/MarkdownRenderer/types.js +1 -0
- package/lib/components/Table/columnDef/accessorFn/typeGuards.d.ts +9 -0
- package/lib/components/Table/columnDef/accessorFn/typeGuards.js +10 -0
- package/lib/components/Table/common/utils.d.ts +2 -2
- package/lib/components/Table/common/utils.js +28 -13
- package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.js +8 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.js +21 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.d.ts +6 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.js +27 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.d.ts +9 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.js +18 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.js +1 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/utils.d.ts +22 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/utils.js +45 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.js +13 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.js +30 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/args.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/args.js +10 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/constants.d.ts +5 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/constants.js +9 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.d.ts +7 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.js +25 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.js +1 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/types.js +1 -0
- package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.d.ts +8 -0
- package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.js +46 -0
- package/lib/components/common/Link/typeGuards.d.ts +13 -0
- package/lib/components/common/Link/typeGuards.js +21 -0
- package/lib/config/entities.d.ts +2 -11
- package/lib/hooks/useCategoryFilter.d.ts +8 -13
- package/lib/hooks/useCategoryFilter.js +31 -28
- package/lib/providers/exploreState/entities.d.ts +5 -3
- package/lib/providers/exploreState/payloads/entities.d.ts +6 -2
- package/lib/providers/exploreState.d.ts +3 -2
- package/lib/providers/exploreState.js +1 -1
- package/lib/styles/common/mui/typography.js +1 -0
- package/lib/tests/utils.d.ts +24 -0
- package/lib/tests/utils.js +34 -0
- package/lib/theme/common/components.js +19 -1
- package/lib/views/ExploreView/exploreView.js +10 -8
- package/package.json +7 -1
- package/src/common/categories/config/types.ts +42 -0
- package/src/common/categories/config/utils.ts +47 -0
- package/src/common/categories/models/range/typeGuards.ts +24 -0
- package/src/common/categories/models/range/types.ts +17 -0
- package/src/common/categories/models/range/utils.ts +51 -0
- package/src/common/categories/models/select/utils.ts +23 -0
- package/src/common/categories/models/types.ts +7 -0
- package/src/common/categories/views/common/types.ts +11 -0
- package/src/common/categories/views/range/typeGuards.ts +13 -0
- package/src/common/categories/views/range/types.ts +21 -0
- package/src/common/categories/views/range/utils.ts +35 -0
- package/src/common/categories/views/select/typeGuards.ts +13 -0
- package/src/common/categories/views/select/types.ts +8 -0
- package/src/common/categories/views/types.ts +15 -0
- package/src/common/entities.ts +8 -26
- package/src/components/DataDictionary/components/Entities/entities.tsx +7 -5
- package/src/components/DataDictionary/components/Entities/types.ts +5 -9
- package/src/components/DataDictionary/components/Entity/entity.tsx +9 -7
- package/src/components/DataDictionary/components/Entity/types.ts +5 -9
- package/src/components/DataDictionary/components/Outline/utils.ts +5 -2
- package/src/components/DataDictionary/components/Table/components/BasicCell/basicCell.tsx +12 -4
- package/src/components/DataDictionary/components/Table/components/BasicCell/utils.ts +13 -0
- package/src/components/DataDictionary/components/Table/hook.ts +16 -8
- package/src/components/DataDictionary/components/Table/options/core/constants.ts +2 -3
- package/src/components/DataDictionary/components/Table/options/hook.ts +3 -3
- package/src/components/DataDictionary/components/Table/options/sorting/constants.ts +2 -6
- package/src/components/DataDictionary/components/Table/table.tsx +4 -1
- package/src/components/DataDictionary/components/Table/types.ts +3 -4
- package/src/components/DataDictionary/dataDictionary.styles.ts +2 -3
- package/src/components/DataDictionary/dataDictionary.tsx +4 -2
- package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +9 -2
- package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +5 -9
- package/src/components/Filter/components/Filter/filter.tsx +38 -13
- package/src/components/Filter/components/Filter/stories/args.ts +24 -0
- package/src/components/Filter/components/Filter/stories/filter.stories.tsx +32 -0
- package/src/components/Filter/components/FilterMenu/filterMenu.styles.ts +1 -1
- package/src/components/Filter/components/FilterMenu/filterMenu.tsx +7 -3
- package/src/components/Filter/components/FilterRange/constants.ts +0 -7
- package/src/components/Filter/components/FilterRange/filterRange.styles.ts +58 -14
- package/src/components/Filter/components/FilterRange/filterRange.tsx +112 -40
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.ts +5 -0
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.ts +51 -10
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.ts +60 -0
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/types.ts +34 -3
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.ts +32 -0
- package/src/components/Filter/components/FilterRange/stories/args.ts +16 -0
- package/src/components/Filter/components/FilterRange/stories/filterRange.stories.tsx +2 -2
- package/src/components/Filter/components/FilterRange/types.ts +12 -6
- package/src/components/Filter/components/FilterRange/utils.ts +16 -0
- package/src/components/Filter/components/FilterTag/stories/args.ts +22 -0
- package/src/components/Filter/components/FilterTag/stories/filterTag.stories.tsx +32 -0
- package/src/components/Filter/components/FilterTag/utils.ts +57 -0
- package/src/components/Filter/components/Filters/filters.tsx +21 -12
- package/src/components/Filter/components/Filters/stories/args.ts +24 -0
- package/src/components/Filter/components/Filters/stories/constants.ts +151 -0
- package/src/components/Filter/components/Filters/stories/filters.stories.tsx +24 -0
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.tsx +32 -29
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.tsx +9 -1
- package/src/components/Filter/components/SearchAllFilters/searchAllFilters.tsx +12 -6
- package/src/components/Filter/components/VariableSizeListItem/variableSizeListItem.tsx +2 -1
- package/src/components/Index/components/EntitiesView/components/ChartView/utils.ts +2 -0
- package/src/components/Index/table/hook.ts +4 -0
- package/src/components/MarkdownRenderer/components/Anchor/anchor.tsx +34 -0
- package/src/components/MarkdownRenderer/components/Table/table.styles.ts +41 -0
- package/src/components/MarkdownRenderer/components/Table/table.tsx +13 -0
- package/src/components/MarkdownRenderer/constants.ts +8 -0
- package/src/components/MarkdownRenderer/markdownRenderer.styles.ts +16 -0
- package/src/components/MarkdownRenderer/markdownRenderer.tsx +62 -0
- package/src/components/MarkdownRenderer/types.ts +7 -0
- package/src/components/Table/columnDef/accessorFn/typeGuards.ts +15 -0
- package/src/components/Table/common/utils.ts +37 -16
- package/src/components/Table/components/TableCell/components/ChipCell/chipCell.tsx +16 -0
- package/src/components/Table/components/TableCell/components/LinkCell/linkCell.tsx +64 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/args.ts +35 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.tsx +32 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/types.ts +4 -0
- package/src/components/Table/components/TableCell/components/LinkCell/utils.ts +59 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.ts +31 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/markdownCell.tsx +29 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/args.ts +17 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/constants.ts +11 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.tsx +37 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/types.ts +4 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/types.ts +3 -0
- package/src/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.ts +64 -0
- package/src/components/common/Link/typeGuards.ts +35 -0
- package/src/config/entities.ts +1 -14
- package/src/hooks/useCategoryFilter.ts +56 -53
- package/src/providers/exploreState/entities.ts +3 -3
- package/src/providers/exploreState/initializer/utils.ts +1 -1
- package/src/providers/exploreState/payloads/entities.ts +5 -2
- package/src/providers/exploreState.tsx +5 -3
- package/src/styles/common/mui/typography.ts +1 -0
- package/src/tests/utils.ts +44 -0
- package/src/theme/common/components.ts +19 -1
- package/src/views/ExploreView/exploreView.tsx +17 -22
- package/tests/filter.test.tsx +100 -0
- package/tests/filterRange.test.tsx +331 -46
- package/tests/filters.test.tsx +61 -0
- package/tests/getFacetedMinMaxValues.test.ts +166 -0
- package/tests/linkCell.test.tsx +89 -0
- package/tests/markdownCell.test.tsx +53 -0
- package/types/data-explorer-ui.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +0 -3
- package/lib/components/Filter/components/Filter/filter.stories.d.ts +0 -25
- package/lib/components/Filter/components/Filter/filter.stories.js +0 -42
- package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +0 -16
- package/lib/components/Filter/components/FilterTag/filterTag.stories.js +0 -17
- package/lib/components/Filter/components/Filters/filters.stories.d.ts +0 -6
- package/lib/components/Filter/components/Filters/filters.stories.js +0 -91
- package/src/components/DataDictionary/components/Table/components/BasicCell/types.ts +0 -7
- package/src/components/Filter/components/Filter/filter.stories.tsx +0 -52
- package/src/components/Filter/components/FilterTag/filterTag.stories.tsx +0 -23
- package/src/components/Filter/components/Filters/filters.stories.tsx +0 -101
- package/tests/filterRangeMock.test.tsx +0 -38
- /package/lib/{components/DataDictionary/components/Table/components/BasicCell → common/categories/config}/types.js +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a parsed value based on the original value.
|
|
4
|
+
* If the value is a boolean, it is converted to its string representation ("true" or "false").
|
|
5
|
+
* For all other types of ReactNode, the value is returned unchanged.
|
|
6
|
+
* @param value - The original value.
|
|
7
|
+
* @returns Parsed value or original value.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseValue(value: ReactNode): ReactNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a parsed value based on the original value.
|
|
3
|
+
* If the value is a boolean, it is converted to its string representation ("true" or "false").
|
|
4
|
+
* For all other types of ReactNode, the value is returned unchanged.
|
|
5
|
+
* @param value - The original value.
|
|
6
|
+
* @returns Parsed value or original value.
|
|
7
|
+
*/
|
|
8
|
+
export function parseValue(value) {
|
|
9
|
+
if (typeof value === "boolean")
|
|
10
|
+
return value.toString();
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ColumnDef, Table } from "@tanstack/react-table";
|
|
2
|
-
import { Attribute
|
|
3
|
-
export declare const useTable: (data:
|
|
1
|
+
import { ColumnDef, RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute } from "../../../../common/entities";
|
|
3
|
+
export declare const useTable: <T extends RowData = Attribute>(data: T[], columnDefs: ColumnDef<T, T[keyof T]>[]) => Table<T>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { useReactTable } from "@tanstack/react-table";
|
|
1
|
+
import { useReactTable, } from "@tanstack/react-table";
|
|
2
2
|
import { useTableOptions } from "./options/hook";
|
|
3
3
|
export const useTable = (data, columnDefs) => {
|
|
4
|
+
// Table options.
|
|
4
5
|
const tableOptions = useTableOptions();
|
|
6
|
+
// Table instance.
|
|
5
7
|
return useReactTable({
|
|
6
8
|
...tableOptions,
|
|
7
9
|
columns: columnDefs,
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { CoreOptions } from "@tanstack/react-table";
|
|
2
|
-
|
|
3
|
-
export declare const CORE_OPTIONS: Pick<CoreOptions<Attribute>, "_features" | "getCoreRowModel">;
|
|
1
|
+
import { CoreOptions, RowData } from "@tanstack/react-table";
|
|
2
|
+
export declare const CORE_OPTIONS: Pick<CoreOptions<RowData>, "_features" | "getCoreRowModel">;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TableOptions } from "@tanstack/react-table";
|
|
1
|
+
import { RowData, TableOptions } from "@tanstack/react-table";
|
|
2
2
|
import { Attribute } from "../../../../../common/entities";
|
|
3
|
-
export declare const useTableOptions: () => Omit<TableOptions<
|
|
3
|
+
export declare const useTableOptions: <T extends RowData = Attribute>() => Omit<TableOptions<T>, "columns" | "data">;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { SortingOptions } from "@tanstack/react-table";
|
|
2
|
-
|
|
3
|
-
export declare const SORTING_OPTIONS: Pick<SortingOptions<Attribute>, "enableSorting">;
|
|
1
|
+
import { RowData, SortingOptions } from "@tanstack/react-table";
|
|
2
|
+
export declare const SORTING_OPTIONS: Pick<SortingOptions<RowData>, "enableSorting">;
|
|
@@ -7,7 +7,7 @@ import { GridTable } from "../../../Table/table.styles";
|
|
|
7
7
|
import { getColumnTrackSizing } from "../../../TableCreator/options/columnTrackSizing/utils";
|
|
8
8
|
import { GridPaper } from "../../../common/Paper/paper.styles";
|
|
9
9
|
import { StyledRoundedPaper } from "./table.styles";
|
|
10
|
-
export const Table = ({ table }) => {
|
|
10
|
+
export const Table = ({ table, }) => {
|
|
11
11
|
return (React.createElement(StyledRoundedPaper, { variant: "table" },
|
|
12
12
|
React.createElement(GridPaper, null,
|
|
13
13
|
React.createElement(TableContainer, null,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Table } from "@tanstack/react-table";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
table: Table<Attribute>;
|
|
1
|
+
import { RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
export interface TableProps<T extends RowData> {
|
|
3
|
+
table: Table<T>;
|
|
5
4
|
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { RowData } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute } from "../../common/entities";
|
|
1
3
|
import { DataDictionaryProps } from "./types";
|
|
2
|
-
export declare const DataDictionary: ({ className, EntitiesLayout, Outline, OutlineLayout, Title, TitleLayout, }: DataDictionaryProps) => JSX.Element;
|
|
4
|
+
export declare const DataDictionary: <T extends RowData = Attribute>({ className, EntitiesLayout, Outline, OutlineLayout, Title, TitleLayout, }: DataDictionaryProps) => JSX.Element;
|
|
@@ -9,12 +9,11 @@ export const grid = css `
|
|
|
9
9
|
export const View = styled("div") `
|
|
10
10
|
${grid};
|
|
11
11
|
flex: 1;
|
|
12
|
-
margin: 0
|
|
13
|
-
max-width: min(calc(100vw - 48px), 1392px);
|
|
12
|
+
margin: 0 24px;
|
|
14
13
|
position: relative;
|
|
15
14
|
|
|
16
15
|
${mediaTabletDown} {
|
|
17
16
|
grid-template-columns: 1fr;
|
|
18
|
-
|
|
17
|
+
margin: 0 16px;
|
|
19
18
|
}
|
|
20
19
|
`;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { RowData } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute } from "../../../../common/entities";
|
|
1
3
|
import { UseDataDictionary } from "./types";
|
|
2
|
-
export declare const useDataDictionary: () => UseDataDictionary
|
|
4
|
+
export declare const useDataDictionary: <T extends RowData = Attribute>() => UseDataDictionary<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
-
import { Attribute,
|
|
3
|
-
export interface UseDataDictionary {
|
|
4
|
-
classes: Class[];
|
|
5
|
-
columnDefs: ColumnDef<
|
|
1
|
+
import { ColumnDef, RowData } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute, Class } from "../../../../common/entities";
|
|
3
|
+
export interface UseDataDictionary<T extends RowData = Attribute> {
|
|
4
|
+
classes: Class<T>[];
|
|
5
|
+
columnDefs: ColumnDef<T, T[keyof T]>[];
|
|
6
6
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { CategoryView } from "../../../../common/categories/views/types";
|
|
3
3
|
import { TrackFilterOpenedFunction } from "../../../../config/entities";
|
|
4
4
|
import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
|
|
5
5
|
export interface FilterProps {
|
|
6
6
|
categorySection?: string;
|
|
7
|
-
categoryView:
|
|
7
|
+
categoryView: CategoryView;
|
|
8
8
|
closeAncestor?: () => void;
|
|
9
9
|
isFilterDrawer: boolean;
|
|
10
10
|
onFilter: OnFilterFn;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { CloseRounded } from "@mui/icons-material";
|
|
2
2
|
import { Grow } from "@mui/material";
|
|
3
3
|
import React, { useState } from "react";
|
|
4
|
+
import { isRangeCategoryView } from "../../../../common/categories/views/range/typeGuards";
|
|
4
5
|
import { TEST_IDS } from "../../../../tests/testIds";
|
|
5
6
|
import { FilterLabel } from "../FilterLabel/filterLabel";
|
|
6
7
|
import { FilterMenu } from "../FilterMenu/filterMenu";
|
|
8
|
+
import { FilterRange } from "../FilterRange/filterRange";
|
|
7
9
|
import { DrawerTransition } from "./components/DrawerTransition/drawerTransition";
|
|
8
10
|
import { FilterPopover, IconButton } from "./filter.styles";
|
|
11
|
+
/**
|
|
12
|
+
* Filter component.
|
|
13
|
+
* TODO(cc) refactor: build tags from categoryView for selected values.
|
|
14
|
+
* TODO(cc) tests: add tests for selected values (rending of tags) for select and range categories.
|
|
15
|
+
*/
|
|
9
16
|
const DEFAULT_POSITION = { left: 0, top: 0 };
|
|
10
17
|
const DEFAULT_SLOT_PROPS = {
|
|
11
18
|
paper: { variant: "menu" },
|
|
@@ -21,6 +28,7 @@ export const Filter = ({ categorySection, categoryView, closeAncestor, isFilterD
|
|
|
21
28
|
const TransitionComponent = isFilterDrawer ? DrawerTransition : Grow;
|
|
22
29
|
const transitionDuration = isOpen ? 250 : 300;
|
|
23
30
|
const TransitionDuration = isFilterDrawer ? transitionDuration : undefined;
|
|
31
|
+
const isRangeView = isRangeCategoryView(categoryView);
|
|
24
32
|
/**
|
|
25
33
|
* Closes filter popover.
|
|
26
34
|
*/
|
|
@@ -49,9 +57,9 @@ export const Filter = ({ categorySection, categoryView, closeAncestor, isFilterD
|
|
|
49
57
|
trackFilterOpened?.({ category: categoryView.key });
|
|
50
58
|
};
|
|
51
59
|
return (React.createElement(React.Fragment, null,
|
|
52
|
-
React.createElement(FilterLabel, { annotation: categoryView.annotation, count: categoryView.values.length, disabled: categoryView.isDisabled, isOpen: isOpen, label: categoryView.label, onClick: onOpenFilter }),
|
|
53
|
-
React.createElement(FilterPopover, { anchorPosition: anchorPosition, anchorReference: "anchorPosition", "data-testid": TEST_IDS.FILTER_POPOVER, marginThreshold: 0, onClose: onCloseFilters, open: isOpen, slotProps: slotProps,
|
|
60
|
+
React.createElement(FilterLabel, { annotation: categoryView.annotation, count: isRangeView ? undefined : categoryView.values.length, disabled: categoryView.isDisabled, isOpen: isOpen, label: categoryView.label, onClick: onOpenFilter }),
|
|
61
|
+
React.createElement(FilterPopover, { anchorPosition: anchorPosition, anchorReference: "anchorPosition", "data-testid": TEST_IDS.FILTER_POPOVER, marginThreshold: 0, onClose: onCloseFilters, open: isOpen, slotProps: slotProps, slots: { transition: TransitionComponent }, transitionDuration: TransitionDuration },
|
|
54
62
|
isOpen && isFilterDrawer && (React.createElement(IconButton, { Icon: CloseRounded, onClick: onCloseFilters, size: "medium" })),
|
|
55
|
-
React.createElement(
|
|
63
|
+
isRangeView ? (React.createElement(FilterRange, { categoryKey: categoryView.key, categoryLabel: categoryView.label, categorySection: categorySection, isFilterDrawer: isFilterDrawer, max: categoryView.max, min: categoryView.min, selectedMax: categoryView.selectedMax, selectedMin: categoryView.selectedMin, onCloseFilter: onCloseFilter, onFilter: onFilter, unit: categoryView.unit })) : (React.createElement(FilterMenu, { categoryKey: categoryView.key, categoryLabel: categoryView.label, categorySection: categorySection, isFilterDrawer: isFilterDrawer, onCloseFilter: onCloseFilter, onFilter: onFilter, values: categoryView.values }))),
|
|
56
64
|
tags));
|
|
57
65
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Filter } from "../filter";
|
|
3
|
+
export declare const SELECT_ARGS: ComponentProps<typeof Filter>;
|
|
4
|
+
export declare const DISABLED_SELECT_ARGS: ComponentProps<typeof Filter>;
|
|
5
|
+
export declare const RANGE_ARGS: ComponentProps<typeof Filter>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { fn } from "@storybook/test";
|
|
2
|
+
import { DONOR_COUNT, GENUS_SPECIES } from "../../Filters/stories/constants";
|
|
3
|
+
export const SELECT_ARGS = {
|
|
4
|
+
categoryView: GENUS_SPECIES,
|
|
5
|
+
isFilterDrawer: false,
|
|
6
|
+
onFilter: fn(),
|
|
7
|
+
};
|
|
8
|
+
export const DISABLED_SELECT_ARGS = {
|
|
9
|
+
...SELECT_ARGS,
|
|
10
|
+
categoryView: {
|
|
11
|
+
...SELECT_ARGS.categoryView,
|
|
12
|
+
isDisabled: true,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const RANGE_ARGS = {
|
|
16
|
+
categoryView: DONOR_COUNT,
|
|
17
|
+
isFilterDrawer: false,
|
|
18
|
+
onFilter: fn(),
|
|
19
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Filter } from "../filter";
|
|
3
|
+
declare const meta: Meta<typeof Filter>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const SelectCategory: Story;
|
|
7
|
+
export declare const DisabledSelectCategory: Story;
|
|
8
|
+
export declare const RangeCategory: Story;
|
|
@@ -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
|
};
|