@databiosphere/findable-ui 33.0.0 → 34.1.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 +18 -0
- package/jest.config.js +4 -0
- package/lib/common/entities.d.ts +3 -1
- package/lib/components/DataDictionary/components/Entities/entities.d.ts +1 -1
- package/lib/components/DataDictionary/components/Entities/entities.js +3 -2
- package/lib/components/DataDictionary/components/Entities/types.d.ts +3 -4
- package/lib/components/DataDictionary/components/Entity/entity.d.ts +1 -1
- package/lib/components/DataDictionary/components/Entity/entity.js +12 -6
- package/lib/components/DataDictionary/components/Entity/entity.styles.js +7 -1
- package/lib/components/DataDictionary/components/Entity/types.d.ts +4 -4
- package/lib/components/DataDictionary/components/Entity/utils.d.ts +9 -0
- package/lib/components/DataDictionary/components/Entity/utils.js +18 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.d.ts +4 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.js +9 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/types.d.ts +5 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/types.js +1 -0
- package/lib/components/DataDictionary/components/Filters/filters.d.ts +4 -0
- package/lib/components/DataDictionary/components/Filters/filters.js +7 -0
- package/lib/components/DataDictionary/components/Filters/filters.styles.d.ts +7 -0
- package/lib/components/DataDictionary/components/Filters/filters.styles.js +13 -0
- package/lib/components/DataDictionary/components/Filters/stories/constants.d.ts +4 -0
- package/lib/components/DataDictionary/components/Filters/stories/constants.js +25 -0
- package/lib/components/DataDictionary/components/Filters/stories/filters.stories.d.ts +6 -0
- package/lib/components/DataDictionary/components/Filters/stories/filters.stories.js +31 -0
- package/lib/components/DataDictionary/components/Filters/stories/hook.d.ts +5 -0
- package/lib/components/DataDictionary/components/Filters/stories/hook.js +5 -0
- package/lib/components/DataDictionary/components/Filters/stories/types.d.ts +4 -0
- package/lib/components/DataDictionary/components/Filters/stories/types.js +1 -0
- package/lib/components/DataDictionary/components/Filters/types.d.ts +5 -0
- package/lib/components/DataDictionary/components/Filters/types.js +1 -0
- package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.js +3 -1
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.d.ts +2 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.js +5 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.d.ts +5 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.js +24 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/types.d.ts +5 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/types.js +1 -0
- package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.js +1 -1
- package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.js +1 -0
- package/lib/components/DataDictionary/components/Layout/constants.d.ts +4 -0
- package/lib/components/DataDictionary/components/Layout/constants.js +4 -0
- package/lib/components/DataDictionary/components/Outline/utils.d.ts +5 -5
- package/lib/components/DataDictionary/components/Outline/utils.js +23 -6
- package/lib/components/DataDictionary/components/Table/hook.d.ts +3 -3
- package/lib/components/DataDictionary/components/Table/hook.js +11 -3
- package/lib/components/DataDictionary/components/Table/options/columnFilters/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/columnFilters/constants.js +8 -0
- package/lib/components/DataDictionary/components/Table/options/columnFilters/hook.d.ts +6 -0
- package/lib/components/DataDictionary/components/Table/options/columnFilters/hook.js +14 -0
- package/lib/components/DataDictionary/components/Table/options/expanded/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/expanded/constants.js +5 -0
- package/lib/components/DataDictionary/components/Table/options/faceted/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/faceted/constants.js +6 -0
- package/lib/components/DataDictionary/components/Table/options/grouping/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/grouping/constants.js +5 -0
- package/lib/components/DataDictionary/components/Table/options/hook.d.ts +1 -1
- package/lib/components/DataDictionary/components/Table/options/hook.js +17 -0
- package/lib/components/DataDictionary/components/Table/options/visibility/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/visibility/constants.js +3 -0
- package/lib/components/DataDictionary/components/Table/table.d.ts +1 -1
- package/lib/components/DataDictionary/components/Table/table.js +2 -2
- package/lib/components/DataDictionary/components/Table/types.d.ts +4 -1
- package/lib/components/DataDictionary/components/Table/utils.d.ts +18 -0
- package/lib/components/DataDictionary/components/Table/utils.js +27 -0
- package/lib/components/DataDictionary/dataDictionary.d.ts +1 -1
- package/lib/components/DataDictionary/dataDictionary.js +8 -6
- package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.js +16 -5
- package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +5 -4
- package/lib/components/DataDictionary/types.d.ts +1 -0
- package/lib/components/Detail/components/Table/components/TableBody/tableBody.d.ts +8 -2
- package/lib/components/Detail/components/Table/components/TableBody/tableBody.js +2 -2
- package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.d.ts +8 -2
- package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +2 -2
- package/lib/components/Detail/components/Table/components/TableRows/tableRows.d.ts +8 -2
- package/lib/components/Detail/components/Table/components/TableRows/tableRows.js +2 -2
- package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
- package/lib/components/Filter/components/FilterList/filterList.styles.d.ts +2 -0
- package/lib/components/Filter/components/FilterList/filterList.styles.js +28 -15
- package/lib/components/Filter/components/SearchAllFiltersSearch/searchAllFiltersSearch.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/Button/button.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/Button/button.styles.d.ts +1 -1
- package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +1 -1
- package/lib/components/Layout/components/Outline/outline.styles.d.ts +1 -1
- package/lib/components/Login/components/Button/button.styles.d.ts +1 -1
- package/lib/components/Table/common/utils.d.ts +6 -0
- package/lib/components/Table/common/utils.js +14 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.d.ts +7 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.js +33 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.d.ts +3 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.js +19 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.d.ts +2 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.js +14 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/types.d.ts +7 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/types.js +1 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/utils.d.ts +6 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/utils.js +23 -0
- package/lib/components/Table/featureOptions/facetedColumn/utils.d.ts +6 -0
- package/lib/components/Table/featureOptions/facetedColumn/utils.js +9 -0
- package/lib/components/common/ButtonGroup/constants.d.ts +2 -0
- package/lib/components/common/ButtonGroup/constants.js +11 -0
- package/lib/components/common/Tabs/tabs.styles.d.ts +1 -1
- package/lib/mocks/@storybook/addon-actions.d.ts +9 -0
- package/lib/mocks/@storybook/addon-actions.js +9 -0
- package/lib/providers/exploreState/entities.d.ts +1 -1
- package/lib/providers/exploreState.js +10 -10
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.d.ts +10 -0
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.js +18 -0
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.d.ts +1 -0
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.js +33 -0
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.d.ts +11 -0
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.js +5 -0
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/utils.d.ts +34 -0
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/utils.js +59 -0
- package/lib/providers/exploreStateSync/provider.d.ts +19 -0
- package/lib/providers/exploreStateSync/provider.js +22 -0
- package/lib/styles/common/mui/buttonGroup.d.ts +13 -0
- package/lib/styles/common/mui/buttonGroup.js +34 -0
- package/lib/styles/common/mui/typography.js +2 -0
- package/lib/tests/mui/constants.d.ts +1 -0
- package/lib/tests/mui/constants.js +1 -0
- package/lib/tests/utils.d.ts +6 -0
- package/lib/tests/utils.js +8 -0
- package/lib/theme/common/components.d.ts +0 -6
- package/lib/theme/common/components.js +17 -31
- package/lib/theme/components/index.d.ts +1 -0
- package/lib/theme/components/index.js +1 -0
- package/lib/theme/components/muiButtonGroup.d.ts +2 -0
- package/lib/theme/components/muiButtonGroup.js +76 -0
- package/lib/theme/theme.js +1 -1
- package/lib/views/ExploreView/exploreView.js +2 -1
- package/package.json +1 -1
- package/src/common/entities.ts +3 -1
- package/src/components/DataDictionary/components/Entities/entities.tsx +5 -9
- package/src/components/DataDictionary/components/Entities/types.ts +3 -4
- package/src/components/DataDictionary/components/Entity/entity.styles.ts +9 -1
- package/src/components/DataDictionary/components/Entity/entity.tsx +18 -8
- package/src/components/DataDictionary/components/Entity/types.ts +4 -4
- package/src/components/DataDictionary/components/Entity/utils.ts +25 -0
- package/src/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.tsx +21 -0
- package/src/components/DataDictionary/components/Filters/components/ColumnFilters/types.ts +6 -0
- package/src/components/DataDictionary/components/Filters/filters.styles.ts +14 -0
- package/src/components/DataDictionary/components/Filters/filters.tsx +16 -0
- package/src/components/DataDictionary/components/Filters/stories/constants.ts +31 -0
- package/src/components/DataDictionary/components/Filters/stories/filters.stories.tsx +42 -0
- package/src/components/DataDictionary/components/Filters/stories/hook.ts +9 -0
- package/src/components/DataDictionary/components/Filters/stories/types.ts +3 -0
- package/src/components/DataDictionary/components/Filters/types.ts +6 -0
- package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.ts +4 -1
- package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.ts +27 -0
- package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.tsx +10 -0
- package/src/components/DataDictionary/components/Layout/components/FiltersLayout/types.ts +6 -0
- package/src/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.ts +1 -1
- package/src/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.ts +1 -0
- package/src/components/DataDictionary/components/Layout/constants.ts +4 -0
- package/src/components/DataDictionary/components/Outline/utils.ts +35 -13
- package/src/components/DataDictionary/components/Table/hook.ts +17 -5
- package/src/components/DataDictionary/components/Table/options/columnFilters/constants.ts +16 -0
- package/src/components/DataDictionary/components/Table/options/columnFilters/hook.ts +32 -0
- package/src/components/DataDictionary/components/Table/options/expanded/constants.ts +13 -0
- package/src/components/DataDictionary/components/Table/options/faceted/constants.ts +14 -0
- package/src/components/DataDictionary/components/Table/options/grouping/constants.ts +9 -0
- package/src/components/DataDictionary/components/Table/options/hook.ts +26 -3
- package/src/components/DataDictionary/components/Table/options/visibility/constants.ts +5 -0
- package/src/components/DataDictionary/components/Table/table.tsx +2 -0
- package/src/components/DataDictionary/components/Table/types.ts +8 -1
- package/src/components/DataDictionary/components/Table/utils.ts +40 -0
- package/src/components/DataDictionary/dataDictionary.tsx +9 -5
- package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +19 -5
- package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +5 -4
- package/src/components/DataDictionary/types.ts +1 -0
- package/src/components/Detail/components/Table/components/TableBody/tableBody.tsx +14 -3
- package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +9 -2
- package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +9 -2
- package/src/components/Filter/components/FilterList/filterList.styles.ts +34 -15
- package/src/components/Table/common/utils.ts +16 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.ts +23 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.tsx +98 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/constants.ts +16 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/types.ts +10 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/utils.ts +27 -0
- package/src/components/Table/featureOptions/facetedColumn/utils.ts +14 -0
- package/src/components/common/ButtonGroup/constants.ts +13 -0
- package/src/mocks/@storybook/addon-actions.ts +10 -0
- package/src/providers/exploreState/entities.ts +1 -1
- package/src/providers/exploreState.tsx +10 -11
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/handlers.ts +25 -0
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/hook.ts +38 -0
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/types.ts +13 -0
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/utils.ts +69 -0
- package/src/providers/exploreStateSync/provider.tsx +29 -0
- package/src/styles/common/mui/buttonGroup.ts +46 -0
- package/src/styles/common/mui/typography.ts +2 -0
- package/src/tests/mui/constants.ts +1 -0
- package/src/tests/utils.ts +9 -0
- package/src/theme/common/components.ts +17 -32
- package/src/theme/components/index.ts +1 -0
- package/src/theme/components/muiButtonGroup.ts +79 -0
- package/src/theme/theme.ts +1 -1
- package/src/views/ExploreView/exploreView.tsx +3 -2
- package/tests/dataDictionaryColumnFilters.test.tsx +101 -0
- package/lib/providers/exploreState/hooks/UseMetaCommands/actions.d.ts +0 -13
- package/lib/providers/exploreState/hooks/UseMetaCommands/actions.js +0 -24
- package/lib/providers/exploreState/hooks/UseMetaCommands/types.d.ts +0 -4
- package/lib/providers/exploreState/hooks/UseMetaCommands/types.js +0 -5
- package/lib/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.d.ts +0 -2
- package/lib/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.js +0 -21
- package/lib/providers/exploreState/hooks/UseMetaCommands/utils.d.ts +0 -9
- package/lib/providers/exploreState/hooks/UseMetaCommands/utils.js +0 -25
- package/src/providers/exploreState/hooks/UseMetaCommands/actions.ts +0 -29
- package/src/providers/exploreState/hooks/UseMetaCommands/types.ts +0 -4
- package/src/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.ts +0 -27
- package/src/providers/exploreState/hooks/UseMetaCommands/utils.ts +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [34.1.0](https://github.com/DataBiosphere/findable-ui/compare/v34.0.0...v34.1.0) (2025-05-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* entity lists do not load when page refreshes ([#506](https://github.com/DataBiosphere/findable-ui/issues/506)) ([#507](https://github.com/DataBiosphere/findable-ui/issues/507)) ([05ba8a1](https://github.com/DataBiosphere/findable-ui/commit/05ba8a17d5c94b35e35056a51d06066f337a276a))
|
|
9
|
+
|
|
10
|
+
## [34.0.0](https://github.com/DataBiosphere/findable-ui/compare/v33.0.0...v34.0.0) (2025-05-27)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* implement required filter on data dictionary ([#497](https://github.com/DataBiosphere/findable-ui/issues/497)) (#503)
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* implement required filter on data dictionary ([#497](https://github.com/DataBiosphere/findable-ui/issues/497)) ([#503](https://github.com/DataBiosphere/findable-ui/issues/503)) ([5087d0c](https://github.com/DataBiosphere/findable-ui/commit/5087d0cd0f0bab0071dc87a7e9d7894735b69512))
|
|
20
|
+
|
|
3
21
|
## [33.0.0](https://github.com/DataBiosphere/findable-ui/compare/v32.1.1...v33.0.0) (2025-05-23)
|
|
4
22
|
|
|
5
23
|
|
package/jest.config.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
2
|
module.exports = {
|
|
3
|
+
moduleNameMapper: {
|
|
4
|
+
"^@storybook/addon-actions$":
|
|
5
|
+
"<rootDir>/src/mocks/@storybook/addon-actions.ts",
|
|
6
|
+
},
|
|
3
7
|
preset: "ts-jest/presets/js-with-ts-esm",
|
|
4
8
|
setupFiles: ["<rootDir>/tests/setup.ts"],
|
|
5
9
|
testEnvironment: "jest-environment-jsdom",
|
package/lib/common/entities.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ColumnDef, RowData } from "@tanstack/react-table";
|
|
1
|
+
import { ColumnDef, RowData, TableOptions } from "@tanstack/react-table";
|
|
2
2
|
/**
|
|
3
3
|
* Model of a value of a metadata class.
|
|
4
4
|
*/
|
|
5
5
|
export interface Attribute {
|
|
6
6
|
annotations?: Record<string, string | string[] | undefined>;
|
|
7
|
+
classKey?: string;
|
|
7
8
|
description: string;
|
|
8
9
|
example?: string;
|
|
9
10
|
multivalued: boolean;
|
|
@@ -64,6 +65,7 @@ export interface DataDictionary<T extends RowData = Attribute> {
|
|
|
64
65
|
export interface DataDictionaryConfig<T extends RowData = Attribute> {
|
|
65
66
|
columnDefs: ColumnDef<T, T[keyof T]>[];
|
|
66
67
|
dataDictionary: DataDictionary<T>;
|
|
68
|
+
tableOptions?: Omit<TableOptions<T>, "columns" | "data" | "getCoreRowModel">;
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* Label and description values from a data dictionary that are added to a site
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RowData } from "@tanstack/react-table";
|
|
2
2
|
import { Attribute } from "../../../../common/entities";
|
|
3
3
|
import { ClassesProps } from "./types";
|
|
4
|
-
export declare const Entities: <T extends RowData = Attribute>({
|
|
4
|
+
export declare const Entities: <T extends RowData = Attribute>({ spacing, table, }: ClassesProps<T>) => JSX.Element;
|
|
@@ -2,6 +2,7 @@ import { Grid } from "@mui/material";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Entity } from "../Entity/entity";
|
|
4
4
|
import { GRID_PROPS } from "./constants";
|
|
5
|
-
export const Entities = ({
|
|
6
|
-
|
|
5
|
+
export const Entities = ({ spacing, table, }) => {
|
|
6
|
+
const { getGroupedRowModel } = table;
|
|
7
|
+
return (React.createElement(Grid, { ...GRID_PROPS }, getGroupedRowModel().rows.map((row) => (React.createElement(Entity, { key: row.id, row: row, spacing: spacing, table: table })))));
|
|
7
8
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Attribute
|
|
1
|
+
import { RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute } from "../../../../common/entities";
|
|
3
3
|
import { LayoutSpacing } from "../../hooks/UseLayoutSpacing/types";
|
|
4
4
|
export interface ClassesProps<T extends RowData = Attribute> {
|
|
5
|
-
classes: Class<T>[];
|
|
6
|
-
columnDefs: ColumnDef<T, T[keyof T]>[];
|
|
7
5
|
spacing?: LayoutSpacing;
|
|
6
|
+
table: Table<T>;
|
|
8
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RowData } from "@tanstack/react-table";
|
|
2
2
|
import { Attribute } from "../../../../common/entities";
|
|
3
3
|
import { EntityProps } from "./types";
|
|
4
|
-
export declare const Entity: <T extends RowData = Attribute>({
|
|
4
|
+
export declare const Entity: <T extends RowData = Attribute>({ row, spacing, table, }: EntityProps<T>) => JSX.Element | null;
|
|
@@ -2,18 +2,24 @@ import { Grid, Typography } from "@mui/material";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { TYPOGRAPHY_PROPS } from "../../../../styles/common/mui/typography";
|
|
4
4
|
import { AnchorLink } from "../../../common/AnchorLink/anchorLink";
|
|
5
|
-
import { useTable } from "../Table/hook";
|
|
6
5
|
import { Table } from "../Table/table";
|
|
7
6
|
import { GRID_PROPS } from "./constants";
|
|
8
7
|
import { StyledTypography } from "./entity.styles";
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { getClassMeta } from "./utils";
|
|
9
|
+
export const Entity = ({ row, spacing, table, }) => {
|
|
10
|
+
// Get class key from row.
|
|
11
|
+
const classKey = row.getValue("classKey");
|
|
12
|
+
// Get class metadata from table options.
|
|
13
|
+
const cls = getClassMeta(classKey, table);
|
|
14
|
+
// Class not found in table meta - return null.
|
|
15
|
+
if (!cls)
|
|
16
|
+
return null;
|
|
11
17
|
return (React.createElement(Grid, { ...GRID_PROPS, rowGap: 4 },
|
|
12
18
|
React.createElement(Grid, { ...GRID_PROPS, rowGap: 1 },
|
|
13
|
-
React.createElement(StyledTypography, { component: "h3", id:
|
|
19
|
+
React.createElement(StyledTypography, { component: "h3", id: classKey, variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_HEADING_SMALL, ...spacing },
|
|
14
20
|
cls.title,
|
|
15
21
|
" ",
|
|
16
|
-
React.createElement(AnchorLink, { anchorLink:
|
|
22
|
+
React.createElement(AnchorLink, { anchorLink: classKey })),
|
|
17
23
|
React.createElement(Typography, { color: TYPOGRAPHY_PROPS.COLOR.INK_LIGHT, component: "div", variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_400_2_LINES }, cls.description)),
|
|
18
|
-
React.createElement(Table, { table: table })));
|
|
24
|
+
React.createElement(Table, { row: row, table: table })));
|
|
19
25
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import styled from "@emotion/styled";
|
|
2
2
|
import { Typography } from "@mui/material";
|
|
3
3
|
import { ENTITIES_ROW_GAP } from "../Entities/constants";
|
|
4
|
+
import { LAYOUT_SPACING } from "../Layout/constants";
|
|
5
|
+
const TOP = ENTITIES_ROW_GAP +
|
|
6
|
+
LAYOUT_SPACING.TITLE_HEIGHT +
|
|
7
|
+
LAYOUT_SPACING.FILTERS_HEIGHT +
|
|
8
|
+
LAYOUT_SPACING.FILTERS_PADDING_TOP +
|
|
9
|
+
LAYOUT_SPACING.CONTENT_PADDING_TOP;
|
|
4
10
|
export const StyledTypography = styled(Typography) `
|
|
5
|
-
scroll-margin-top: ${({ top = 0 }) => top +
|
|
11
|
+
scroll-margin-top: ${({ top = 0 }) => top + TOP}px;
|
|
6
12
|
|
|
7
13
|
&:hover a {
|
|
8
14
|
opacity: 1;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Attribute
|
|
1
|
+
import { Row, RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute } from "../../../../common/entities";
|
|
3
3
|
import { LayoutSpacing } from "../../hooks/UseLayoutSpacing/types";
|
|
4
4
|
export interface EntityProps<T extends RowData = Attribute> {
|
|
5
|
-
|
|
6
|
-
columnDefs: ColumnDef<T, T[keyof T]>[];
|
|
5
|
+
row: Row<T>;
|
|
7
6
|
spacing?: LayoutSpacing;
|
|
7
|
+
table: Table<T>;
|
|
8
8
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute, Class } from "../../../../common/entities";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves class metadata from the table options meta.
|
|
5
|
+
* @param classKey - Class key.
|
|
6
|
+
* @param table - Table instance.
|
|
7
|
+
* @returns Class metadata or undefined.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getClassMeta<T extends RowData = Attribute>(classKey: string | undefined, table: Table<T>): Pick<Class<T>, "description" | "title"> | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves class metadata from the table options meta.
|
|
3
|
+
* @param classKey - Class key.
|
|
4
|
+
* @param table - Table instance.
|
|
5
|
+
* @returns Class metadata or undefined.
|
|
6
|
+
*/
|
|
7
|
+
export function getClassMeta(classKey, table) {
|
|
8
|
+
if (!classKey)
|
|
9
|
+
return;
|
|
10
|
+
// Grab the table meta and return if not defined.
|
|
11
|
+
const meta = table.options.meta;
|
|
12
|
+
if (!meta)
|
|
13
|
+
return;
|
|
14
|
+
// Return class metadata if defined.
|
|
15
|
+
if ("classMeta" in meta) {
|
|
16
|
+
return meta.classMeta?.[classKey];
|
|
17
|
+
}
|
|
18
|
+
}
|
package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RowData } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute } from "../../../../../../common/entities";
|
|
3
|
+
import { ColumnFiltersProps } from "./types";
|
|
4
|
+
export declare const ColumnFilters: <T extends RowData = Attribute>({ table, }: ColumnFiltersProps<T>) => JSX.Element;
|
package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ButtonGroup } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { BUTTON_GROUP_PROPS } from "../../../../../common/ButtonGroup/constants";
|
|
4
|
+
import { ColumnFilter } from "../../../../../Table/components/TableFeatures/ColumnFilter/columnFilter";
|
|
5
|
+
export const ColumnFilters = ({ table, }) => {
|
|
6
|
+
const columns = table.getAllColumns();
|
|
7
|
+
const columnFilters = columns.filter((column) => column.getCanFilter());
|
|
8
|
+
return (React.createElement(ButtonGroup, { ...BUTTON_GROUP_PROPS.SECONDARY_OUTLINED }, columnFilters.map((column) => (React.createElement(ColumnFilter, { key: column.id, column: column })))));
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ColumnFilters } from "./components/ColumnFilters/columnFilters";
|
|
3
|
+
import { StyledGrid } from "./filters.styles";
|
|
4
|
+
export const Filters = ({ table, }) => {
|
|
5
|
+
return (React.createElement(StyledGrid, null,
|
|
6
|
+
React.createElement(ColumnFilters, { table: table })));
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const StyledGrid: import("@emotion/styled").StyledComponent<import("@mui/material").GridBaseProps & {
|
|
2
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme>;
|
|
3
|
+
} & import("@mui/system").SystemProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
4
|
+
ref?: ((instance: HTMLDivElement | 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<HTMLDivElement> | null | undefined;
|
|
5
|
+
}, ("p" | "fontSize" | "fontWeight" | "lineHeight" | "letterSpacing" | "textTransform" | "color" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontStyle" | "textAlign") | "sx" | keyof import("@mui/material").GridBaseProps> & {
|
|
6
|
+
theme?: import("@emotion/react").Theme;
|
|
7
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { Grid } from "@mui/material";
|
|
3
|
+
import { BUTTON_GROUP_PROPS } from "../../../../styles/common/mui/buttonGroup";
|
|
4
|
+
export const StyledGrid = styled(Grid) `
|
|
5
|
+
align-items: center;
|
|
6
|
+
display: grid;
|
|
7
|
+
gap: 16px;
|
|
8
|
+
grid-template-columns: 1fr auto;
|
|
9
|
+
|
|
10
|
+
.${BUTTON_GROUP_PROPS.CLASSES.ROOT} {
|
|
11
|
+
grid-column: 2;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const BIONETWORK = {
|
|
2
|
+
columnDef: { header: "BioNetwork" },
|
|
3
|
+
getCanFilter: () => true,
|
|
4
|
+
getFacetedUniqueValues: () => new Map([
|
|
5
|
+
["Nervous System", 3],
|
|
6
|
+
["Brain", 2],
|
|
7
|
+
["Lung", 1],
|
|
8
|
+
]),
|
|
9
|
+
id: "bioNetwork",
|
|
10
|
+
};
|
|
11
|
+
export const EXAMPLE = {
|
|
12
|
+
columnDef: { header: "Example" },
|
|
13
|
+
getCanFilter: () => false,
|
|
14
|
+
getFacetedUniqueValues: () => new Map([["EFO:0008563", 1]]),
|
|
15
|
+
id: "example",
|
|
16
|
+
};
|
|
17
|
+
export const REQUIRED = {
|
|
18
|
+
columnDef: { header: "Required" },
|
|
19
|
+
getCanFilter: () => true,
|
|
20
|
+
getFacetedUniqueValues: () => new Map([
|
|
21
|
+
["Required", 16],
|
|
22
|
+
["Not Required", 30],
|
|
23
|
+
]),
|
|
24
|
+
id: "required",
|
|
25
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { action } from "@storybook/addon-actions";
|
|
2
|
+
import { functionalUpdate } from "@tanstack/react-table";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Filters } from "../filters";
|
|
5
|
+
import { BIONETWORK, EXAMPLE, REQUIRED } from "./constants";
|
|
6
|
+
import { useFilterStore } from "./hook";
|
|
7
|
+
const meta = {
|
|
8
|
+
component: Filters,
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
const DefaultStory = () => {
|
|
12
|
+
const { filterStore, setFilterStore } = useFilterStore();
|
|
13
|
+
const makeColumn = (column) => ({
|
|
14
|
+
...column,
|
|
15
|
+
getFilterValue: () => filterStore[column.id],
|
|
16
|
+
getIsFiltered: () => !!filterStore[column.id],
|
|
17
|
+
setFilterValue: (updaterOrValue) => {
|
|
18
|
+
const next = functionalUpdate(updaterOrValue, filterStore[column.id]);
|
|
19
|
+
setFilterStore({ ...filterStore, [column.id]: next });
|
|
20
|
+
action("setFilterValue")(next);
|
|
21
|
+
return next;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const table = {
|
|
25
|
+
getAllColumns: () => [REQUIRED, BIONETWORK, EXAMPLE].map(makeColumn),
|
|
26
|
+
};
|
|
27
|
+
return React.createElement(Filters, { table: table });
|
|
28
|
+
};
|
|
29
|
+
export const Default = {
|
|
30
|
+
render: () => React.createElement(DefaultStory, null),
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,12 +3,14 @@ import { mediaTabletDown } from "../../../../../../styles/common/mixins/breakpoi
|
|
|
3
3
|
import { LAYOUT_SPACING } from "../../constants";
|
|
4
4
|
const PB = LAYOUT_SPACING.CONTENT_PADDING_BOTTOM; /* bottom padding */
|
|
5
5
|
const PT = LAYOUT_SPACING.CONTENT_PADDING_TOP; /* top padding */
|
|
6
|
+
const FILTERS_HEIGHT = LAYOUT_SPACING.FILTERS_HEIGHT +
|
|
7
|
+
LAYOUT_SPACING.FILTERS_PADDING_TOP; /* filters height */
|
|
6
8
|
const TITLE_HEIGHT = LAYOUT_SPACING.TITLE_HEIGHT; /* title height */
|
|
7
9
|
export const Layout = styled("div") `
|
|
8
10
|
grid-column: 2;
|
|
9
11
|
grid-row: 1;
|
|
10
12
|
padding-bottom: ${PB}px;
|
|
11
|
-
padding-top: ${({ top }) => top + TITLE_HEIGHT + PT}px;
|
|
13
|
+
padding-top: ${({ top }) => top + TITLE_HEIGHT + FILTERS_HEIGHT + PT}px;
|
|
12
14
|
z-index: 1; /* not required, but helpful in that the entities are always on top */
|
|
13
15
|
|
|
14
16
|
${mediaTabletDown} {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LayoutSpacing } from "../../../../hooks/UseLayoutSpacing/types";
|
|
2
|
+
export declare const Layout: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme;
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
} & LayoutSpacing, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { PALETTE } from "../../../../../../styles/common/constants/palette";
|
|
3
|
+
import { mediaTabletDown } from "../../../../../../styles/common/mixins/breakpoints";
|
|
4
|
+
import { LAYOUT_SPACING } from "../../constants";
|
|
5
|
+
const PB = LAYOUT_SPACING.FILTERS_PADDING_BOTTOM; /* bottom padding */
|
|
6
|
+
const PT = LAYOUT_SPACING.FILTERS_PADDING_TOP; /* top padding */
|
|
7
|
+
const TITLE_HEIGHT = LAYOUT_SPACING.TITLE_HEIGHT; /* title height */
|
|
8
|
+
export const Layout = styled("div") `
|
|
9
|
+
align-self: flex-start;
|
|
10
|
+
background-color: ${PALETTE.BACKGROUND_DEFAULT};
|
|
11
|
+
grid-column: 2;
|
|
12
|
+
grid-row: 1;
|
|
13
|
+
margin-bottom: ${PB}px;
|
|
14
|
+
padding-top: ${({ top }) => top + TITLE_HEIGHT + PT}px;
|
|
15
|
+
position: sticky;
|
|
16
|
+
top: 0;
|
|
17
|
+
z-index: 2; /* required, filters should be on top of entities */
|
|
18
|
+
|
|
19
|
+
${mediaTabletDown} {
|
|
20
|
+
grid-column: 1;
|
|
21
|
+
grid-row: auto;
|
|
22
|
+
padding-top: ${PT}px;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import styled from "@emotion/styled";
|
|
|
2
2
|
import { mediaTabletDown } from "../../../../../../styles/common/mixins/breakpoints";
|
|
3
3
|
import { LAYOUT_SPACING } from "../../constants";
|
|
4
4
|
const PB = LAYOUT_SPACING.CONTENT_PADDING_BOTTOM; /* bottom padding */
|
|
5
|
-
const PT = LAYOUT_SPACING.
|
|
5
|
+
const PT = LAYOUT_SPACING.OUTLINE_PADDING_TOP; /* top padding */
|
|
6
6
|
const TITLE_HEIGHT = LAYOUT_SPACING.TITLE_HEIGHT; /* title height */
|
|
7
7
|
export const Layout = styled("div") `
|
|
8
8
|
grid-column: 1;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { RowData } from "@tanstack/react-table";
|
|
2
|
-
import { Attribute
|
|
1
|
+
import { RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute } from "../../../../common/entities";
|
|
3
3
|
import { OutlineItem } from "../../../Layout/components/Outline/types";
|
|
4
4
|
/**
|
|
5
|
-
* Returns outline items from
|
|
6
|
-
* @param
|
|
5
|
+
* Returns outline items from class metadata.
|
|
6
|
+
* @param table - Table instance.
|
|
7
7
|
* @returns Outline items.
|
|
8
8
|
*/
|
|
9
|
-
export declare function buildClassesOutline<T extends RowData = Attribute>(
|
|
9
|
+
export declare function buildClassesOutline<T extends RowData = Attribute>(table: Table<T>): OutlineItem[];
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns outline items from
|
|
3
|
-
* @param
|
|
2
|
+
* Returns outline items from class metadata.
|
|
3
|
+
* @param table - Table instance.
|
|
4
4
|
* @returns Outline items.
|
|
5
5
|
*/
|
|
6
|
-
export function buildClassesOutline(
|
|
7
|
-
|
|
6
|
+
export function buildClassesOutline(table) {
|
|
7
|
+
const meta = table.options.meta;
|
|
8
|
+
if (!meta)
|
|
9
|
+
return [];
|
|
10
|
+
if (!("classMeta" in meta))
|
|
11
|
+
return [];
|
|
12
|
+
return Object.entries(meta.classMeta).map(([classKey, { title }]) => {
|
|
8
13
|
return {
|
|
9
14
|
depth: 2,
|
|
10
|
-
disabled:
|
|
11
|
-
hash:
|
|
15
|
+
disabled: !hasGroupedRow(table, classKey),
|
|
16
|
+
hash: classKey,
|
|
12
17
|
value: title,
|
|
13
18
|
};
|
|
14
19
|
});
|
|
15
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns true if a grouped row exists for a class key.
|
|
23
|
+
* @param table - Table instance.
|
|
24
|
+
* @param classKey - Class key.
|
|
25
|
+
* @returns True if a grouped row exists, false otherwise.
|
|
26
|
+
*/
|
|
27
|
+
function hasGroupedRow(table, classKey) {
|
|
28
|
+
const groupRow = table
|
|
29
|
+
.getGroupedRowModel()
|
|
30
|
+
.rows.find((row) => row.getValue("classKey") === classKey);
|
|
31
|
+
return !!groupRow;
|
|
32
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ColumnDef, RowData, Table } from "@tanstack/react-table";
|
|
2
|
-
import { Attribute } from "../../../../common/entities";
|
|
3
|
-
export declare const useTable: <T extends RowData = Attribute>(
|
|
1
|
+
import { ColumnDef, RowData, Table, TableOptions } from "@tanstack/react-table";
|
|
2
|
+
import { Attribute, Class } from "../../../../common/entities";
|
|
3
|
+
export declare const useTable: <T extends RowData = Attribute>(classes: Class<T>[], columnDefs: ColumnDef<T, T[keyof T]>[], tableOptions?: Omit<TableOptions<T>, "columns" | "data" | "getCoreRowModel">) => Table<T>;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { useReactTable, } from "@tanstack/react-table";
|
|
2
|
+
import { useMemo } from "react";
|
|
2
3
|
import { useTableOptions } from "./options/hook";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { buildClassMeta, buildTableData } from "./utils";
|
|
5
|
+
export const useTable = (classes, columnDefs, tableOptions) => {
|
|
6
|
+
// Build table data.
|
|
7
|
+
const data = useMemo(() => buildTableData(classes), [classes]);
|
|
8
|
+
// Default table options.
|
|
9
|
+
const defaultTableOptions = useTableOptions();
|
|
10
|
+
// Build class meta.
|
|
11
|
+
const classMeta = useMemo(() => buildClassMeta(classes), [classes]);
|
|
6
12
|
// Table instance.
|
|
7
13
|
return useReactTable({
|
|
14
|
+
...defaultTableOptions,
|
|
8
15
|
...tableOptions,
|
|
9
16
|
columns: columnDefs,
|
|
10
17
|
data,
|
|
18
|
+
meta: { classMeta },
|
|
11
19
|
});
|
|
12
20
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getFilteredRowModel, } from "@tanstack/react-table";
|
|
2
|
+
import { arrIncludesSome } from "../../../../../Table/columnDef/columnFilters/filterFn";
|
|
3
|
+
export const COLUMN_FILTERS_OPTIONS = {
|
|
4
|
+
enableColumnFilters: true,
|
|
5
|
+
enableFilters: true,
|
|
6
|
+
filterFns: { arrIncludesSome },
|
|
7
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
8
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ColumnFiltersOptions, ColumnFiltersState, RowData } from "@tanstack/react-table";
|
|
2
|
+
import { Dispatch, SetStateAction } from "react";
|
|
3
|
+
import { Attribute } from "../../../../../../common/entities";
|
|
4
|
+
export declare const useColumnFiltersOptions: <T extends RowData = Attribute>({ setColumnFilters, }: {
|
|
5
|
+
setColumnFilters: Dispatch<SetStateAction<ColumnFiltersState>>;
|
|
6
|
+
}) => ColumnFiltersOptions<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { resolveUpdater } from "../../../../../Table/options/updater";
|
|
3
|
+
import { COLUMN_FILTERS_OPTIONS } from "./constants";
|
|
4
|
+
export const useColumnFiltersOptions = ({ setColumnFilters, }) => {
|
|
5
|
+
// Column filters change handler.
|
|
6
|
+
// TODO dispatch to provider with reducer.
|
|
7
|
+
const onColumnFiltersChange = useCallback((updaterOrValue) => {
|
|
8
|
+
setColumnFilters((old) => resolveUpdater(updaterOrValue, old));
|
|
9
|
+
}, [setColumnFilters]);
|
|
10
|
+
return {
|
|
11
|
+
...COLUMN_FILTERS_OPTIONS,
|
|
12
|
+
onColumnFiltersChange,
|
|
13
|
+
};
|
|
14
|
+
};
|