@databiosphere/findable-ui 33.0.0 → 34.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.
Files changed (180) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +11 -0
  3. package/jest.config.js +4 -0
  4. package/lib/common/entities.d.ts +3 -1
  5. package/lib/components/DataDictionary/components/Entities/entities.d.ts +1 -1
  6. package/lib/components/DataDictionary/components/Entities/entities.js +3 -2
  7. package/lib/components/DataDictionary/components/Entities/types.d.ts +3 -4
  8. package/lib/components/DataDictionary/components/Entity/entity.d.ts +1 -1
  9. package/lib/components/DataDictionary/components/Entity/entity.js +12 -6
  10. package/lib/components/DataDictionary/components/Entity/entity.styles.js +7 -1
  11. package/lib/components/DataDictionary/components/Entity/types.d.ts +4 -4
  12. package/lib/components/DataDictionary/components/Entity/utils.d.ts +9 -0
  13. package/lib/components/DataDictionary/components/Entity/utils.js +18 -0
  14. package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.d.ts +4 -0
  15. package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.js +9 -0
  16. package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/types.d.ts +5 -0
  17. package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/types.js +1 -0
  18. package/lib/components/DataDictionary/components/Filters/filters.d.ts +4 -0
  19. package/lib/components/DataDictionary/components/Filters/filters.js +7 -0
  20. package/lib/components/DataDictionary/components/Filters/filters.styles.d.ts +7 -0
  21. package/lib/components/DataDictionary/components/Filters/filters.styles.js +13 -0
  22. package/lib/components/DataDictionary/components/Filters/stories/constants.d.ts +4 -0
  23. package/lib/components/DataDictionary/components/Filters/stories/constants.js +25 -0
  24. package/lib/components/DataDictionary/components/Filters/stories/filters.stories.d.ts +6 -0
  25. package/lib/components/DataDictionary/components/Filters/stories/filters.stories.js +31 -0
  26. package/lib/components/DataDictionary/components/Filters/stories/hook.d.ts +5 -0
  27. package/lib/components/DataDictionary/components/Filters/stories/hook.js +5 -0
  28. package/lib/components/DataDictionary/components/Filters/stories/types.d.ts +4 -0
  29. package/lib/components/DataDictionary/components/Filters/stories/types.js +1 -0
  30. package/lib/components/DataDictionary/components/Filters/types.d.ts +5 -0
  31. package/lib/components/DataDictionary/components/Filters/types.js +1 -0
  32. package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.js +3 -1
  33. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.d.ts +2 -0
  34. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.js +5 -0
  35. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.d.ts +5 -0
  36. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.js +24 -0
  37. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/types.d.ts +5 -0
  38. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/types.js +1 -0
  39. package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.js +1 -1
  40. package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.js +1 -0
  41. package/lib/components/DataDictionary/components/Layout/constants.d.ts +4 -0
  42. package/lib/components/DataDictionary/components/Layout/constants.js +4 -0
  43. package/lib/components/DataDictionary/components/Outline/utils.d.ts +5 -5
  44. package/lib/components/DataDictionary/components/Outline/utils.js +23 -6
  45. package/lib/components/DataDictionary/components/Table/hook.d.ts +3 -3
  46. package/lib/components/DataDictionary/components/Table/hook.js +11 -3
  47. package/lib/components/DataDictionary/components/Table/options/columnFilters/constants.d.ts +2 -0
  48. package/lib/components/DataDictionary/components/Table/options/columnFilters/constants.js +8 -0
  49. package/lib/components/DataDictionary/components/Table/options/columnFilters/hook.d.ts +6 -0
  50. package/lib/components/DataDictionary/components/Table/options/columnFilters/hook.js +14 -0
  51. package/lib/components/DataDictionary/components/Table/options/expanded/constants.d.ts +2 -0
  52. package/lib/components/DataDictionary/components/Table/options/expanded/constants.js +5 -0
  53. package/lib/components/DataDictionary/components/Table/options/faceted/constants.d.ts +2 -0
  54. package/lib/components/DataDictionary/components/Table/options/faceted/constants.js +6 -0
  55. package/lib/components/DataDictionary/components/Table/options/grouping/constants.d.ts +2 -0
  56. package/lib/components/DataDictionary/components/Table/options/grouping/constants.js +5 -0
  57. package/lib/components/DataDictionary/components/Table/options/hook.d.ts +1 -1
  58. package/lib/components/DataDictionary/components/Table/options/hook.js +17 -0
  59. package/lib/components/DataDictionary/components/Table/options/visibility/constants.d.ts +2 -0
  60. package/lib/components/DataDictionary/components/Table/options/visibility/constants.js +3 -0
  61. package/lib/components/DataDictionary/components/Table/table.d.ts +1 -1
  62. package/lib/components/DataDictionary/components/Table/table.js +2 -2
  63. package/lib/components/DataDictionary/components/Table/types.d.ts +4 -1
  64. package/lib/components/DataDictionary/components/Table/utils.d.ts +18 -0
  65. package/lib/components/DataDictionary/components/Table/utils.js +27 -0
  66. package/lib/components/DataDictionary/dataDictionary.d.ts +1 -1
  67. package/lib/components/DataDictionary/dataDictionary.js +8 -6
  68. package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.js +16 -5
  69. package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +5 -4
  70. package/lib/components/DataDictionary/types.d.ts +1 -0
  71. package/lib/components/Detail/components/Table/components/TableBody/tableBody.d.ts +8 -2
  72. package/lib/components/Detail/components/Table/components/TableBody/tableBody.js +2 -2
  73. package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.d.ts +8 -2
  74. package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +2 -2
  75. package/lib/components/Detail/components/Table/components/TableRows/tableRows.d.ts +8 -2
  76. package/lib/components/Detail/components/Table/components/TableRows/tableRows.js +2 -2
  77. package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
  78. package/lib/components/Filter/components/FilterList/filterList.styles.d.ts +2 -0
  79. package/lib/components/Filter/components/FilterList/filterList.styles.js +28 -15
  80. package/lib/components/Filter/components/SearchAllFiltersSearch/searchAllFiltersSearch.styles.d.ts +1 -1
  81. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/Button/button.styles.d.ts +1 -1
  82. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/Button/button.styles.d.ts +1 -1
  83. package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +1 -1
  84. package/lib/components/Layout/components/Outline/outline.styles.d.ts +1 -1
  85. package/lib/components/Login/components/Button/button.styles.d.ts +1 -1
  86. package/lib/components/Table/common/utils.d.ts +6 -0
  87. package/lib/components/Table/common/utils.js +14 -0
  88. package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.d.ts +7 -0
  89. package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.js +33 -0
  90. package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.d.ts +3 -0
  91. package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.js +19 -0
  92. package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.d.ts +2 -0
  93. package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.js +14 -0
  94. package/lib/components/Table/components/TableFeatures/ColumnFilter/types.d.ts +7 -0
  95. package/lib/components/Table/components/TableFeatures/ColumnFilter/types.js +1 -0
  96. package/lib/components/Table/components/TableFeatures/ColumnFilter/utils.d.ts +6 -0
  97. package/lib/components/Table/components/TableFeatures/ColumnFilter/utils.js +23 -0
  98. package/lib/components/Table/featureOptions/facetedColumn/utils.d.ts +6 -0
  99. package/lib/components/Table/featureOptions/facetedColumn/utils.js +9 -0
  100. package/lib/components/common/ButtonGroup/constants.d.ts +2 -0
  101. package/lib/components/common/ButtonGroup/constants.js +11 -0
  102. package/lib/components/common/Tabs/tabs.styles.d.ts +1 -1
  103. package/lib/mocks/@storybook/addon-actions.d.ts +9 -0
  104. package/lib/mocks/@storybook/addon-actions.js +9 -0
  105. package/lib/styles/common/mui/buttonGroup.d.ts +13 -0
  106. package/lib/styles/common/mui/buttonGroup.js +34 -0
  107. package/lib/styles/common/mui/typography.js +2 -0
  108. package/lib/tests/mui/constants.d.ts +1 -0
  109. package/lib/tests/mui/constants.js +1 -0
  110. package/lib/tests/utils.d.ts +6 -0
  111. package/lib/tests/utils.js +8 -0
  112. package/lib/theme/common/components.d.ts +0 -6
  113. package/lib/theme/common/components.js +17 -31
  114. package/lib/theme/components/index.d.ts +1 -0
  115. package/lib/theme/components/index.js +1 -0
  116. package/lib/theme/components/muiButtonGroup.d.ts +2 -0
  117. package/lib/theme/components/muiButtonGroup.js +76 -0
  118. package/lib/theme/theme.js +1 -1
  119. package/package.json +1 -1
  120. package/src/common/entities.ts +3 -1
  121. package/src/components/DataDictionary/components/Entities/entities.tsx +5 -9
  122. package/src/components/DataDictionary/components/Entities/types.ts +3 -4
  123. package/src/components/DataDictionary/components/Entity/entity.styles.ts +9 -1
  124. package/src/components/DataDictionary/components/Entity/entity.tsx +18 -8
  125. package/src/components/DataDictionary/components/Entity/types.ts +4 -4
  126. package/src/components/DataDictionary/components/Entity/utils.ts +25 -0
  127. package/src/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.tsx +21 -0
  128. package/src/components/DataDictionary/components/Filters/components/ColumnFilters/types.ts +6 -0
  129. package/src/components/DataDictionary/components/Filters/filters.styles.ts +14 -0
  130. package/src/components/DataDictionary/components/Filters/filters.tsx +16 -0
  131. package/src/components/DataDictionary/components/Filters/stories/constants.ts +31 -0
  132. package/src/components/DataDictionary/components/Filters/stories/filters.stories.tsx +42 -0
  133. package/src/components/DataDictionary/components/Filters/stories/hook.ts +9 -0
  134. package/src/components/DataDictionary/components/Filters/stories/types.ts +3 -0
  135. package/src/components/DataDictionary/components/Filters/types.ts +6 -0
  136. package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.ts +4 -1
  137. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.ts +27 -0
  138. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.tsx +10 -0
  139. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/types.ts +6 -0
  140. package/src/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.ts +1 -1
  141. package/src/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.ts +1 -0
  142. package/src/components/DataDictionary/components/Layout/constants.ts +4 -0
  143. package/src/components/DataDictionary/components/Outline/utils.ts +35 -13
  144. package/src/components/DataDictionary/components/Table/hook.ts +17 -5
  145. package/src/components/DataDictionary/components/Table/options/columnFilters/constants.ts +16 -0
  146. package/src/components/DataDictionary/components/Table/options/columnFilters/hook.ts +32 -0
  147. package/src/components/DataDictionary/components/Table/options/expanded/constants.ts +13 -0
  148. package/src/components/DataDictionary/components/Table/options/faceted/constants.ts +14 -0
  149. package/src/components/DataDictionary/components/Table/options/grouping/constants.ts +9 -0
  150. package/src/components/DataDictionary/components/Table/options/hook.ts +26 -3
  151. package/src/components/DataDictionary/components/Table/options/visibility/constants.ts +5 -0
  152. package/src/components/DataDictionary/components/Table/table.tsx +2 -0
  153. package/src/components/DataDictionary/components/Table/types.ts +8 -1
  154. package/src/components/DataDictionary/components/Table/utils.ts +40 -0
  155. package/src/components/DataDictionary/dataDictionary.tsx +9 -5
  156. package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +19 -5
  157. package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +5 -4
  158. package/src/components/DataDictionary/types.ts +1 -0
  159. package/src/components/Detail/components/Table/components/TableBody/tableBody.tsx +14 -3
  160. package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +9 -2
  161. package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +9 -2
  162. package/src/components/Filter/components/FilterList/filterList.styles.ts +34 -15
  163. package/src/components/Table/common/utils.ts +16 -0
  164. package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.ts +23 -0
  165. package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.tsx +98 -0
  166. package/src/components/Table/components/TableFeatures/ColumnFilter/constants.ts +16 -0
  167. package/src/components/Table/components/TableFeatures/ColumnFilter/types.ts +10 -0
  168. package/src/components/Table/components/TableFeatures/ColumnFilter/utils.ts +27 -0
  169. package/src/components/Table/featureOptions/facetedColumn/utils.ts +14 -0
  170. package/src/components/common/ButtonGroup/constants.ts +13 -0
  171. package/src/mocks/@storybook/addon-actions.ts +10 -0
  172. package/src/styles/common/mui/buttonGroup.ts +46 -0
  173. package/src/styles/common/mui/typography.ts +2 -0
  174. package/src/tests/mui/constants.ts +1 -0
  175. package/src/tests/utils.ts +9 -0
  176. package/src/theme/common/components.ts +17 -32
  177. package/src/theme/components/index.ts +1 -0
  178. package/src/theme/components/muiButtonGroup.ts +79 -0
  179. package/src/theme/theme.ts +1 -1
  180. package/tests/dataDictionaryColumnFilters.test.tsx +101 -0
@@ -0,0 +1,2 @@
1
+ import { FacetedOptions, RowData } from "@tanstack/react-table";
2
+ export declare const FACETED_OPTIONS: Pick<FacetedOptions<RowData>, "getFacetedRowModel" | "getFacetedUniqueValues">;
@@ -0,0 +1,6 @@
1
+ import { getFacetedRowModel, } from "@tanstack/react-table";
2
+ import { getFacetedUniqueValuesWithArrayValues } from "../../../../../Table/common/utils";
3
+ export const FACETED_OPTIONS = {
4
+ getFacetedRowModel: getFacetedRowModel(),
5
+ getFacetedUniqueValues: getFacetedUniqueValuesWithArrayValues(),
6
+ };
@@ -0,0 +1,2 @@
1
+ import { GroupingOptions } from "@tanstack/react-table";
2
+ export declare const GROUPING_OPTIONS: Pick<GroupingOptions, "enableGrouping" | "getGroupedRowModel">;
@@ -0,0 +1,5 @@
1
+ import { getGroupedRowModel } from "@tanstack/react-table";
2
+ export const GROUPING_OPTIONS = {
3
+ enableGrouping: true,
4
+ getGroupedRowModel: getGroupedRowModel(),
5
+ };
@@ -1,3 +1,3 @@
1
1
  import { RowData, TableOptions } from "@tanstack/react-table";
2
2
  import { Attribute } from "../../../../../common/entities";
3
- export declare const useTableOptions: <T extends RowData = Attribute>() => Omit<TableOptions<T>, "columns" | "data">;
3
+ export declare const useTableOptions: <T extends RowData = Attribute>() => Omit<TableOptions<T>, "columns" | "data" | "initialState">;
@@ -1,8 +1,25 @@
1
+ import { useState } from "react";
2
+ import { useColumnFiltersOptions } from "./columnFilters/hook";
1
3
  import { CORE_OPTIONS } from "./core/constants";
4
+ import { EXPANDED_OPTIONS } from "./expanded/constants";
5
+ import { FACETED_OPTIONS } from "./faceted/constants";
6
+ import { GROUPING_OPTIONS } from "./grouping/constants";
2
7
  import { SORTING_OPTIONS } from "./sorting/constants";
8
+ import { VISIBILITY_OPTIONS } from "./visibility/constants";
3
9
  export const useTableOptions = () => {
10
+ // Column filters state - to be moved to a provider with a reducer.
11
+ const [columnFilters, setColumnFilters] = useState([]);
12
+ // Column filters options.
13
+ const columnFiltersOptions = useColumnFiltersOptions({ setColumnFilters });
14
+ // Table options.
4
15
  return {
16
+ ...columnFiltersOptions,
5
17
  ...CORE_OPTIONS,
18
+ ...EXPANDED_OPTIONS,
19
+ ...FACETED_OPTIONS,
20
+ ...GROUPING_OPTIONS,
6
21
  ...SORTING_OPTIONS,
22
+ ...VISIBILITY_OPTIONS,
23
+ state: { columnFilters },
7
24
  };
8
25
  };
@@ -0,0 +1,2 @@
1
+ import { VisibilityOptions } from "@tanstack/react-table";
2
+ export declare const VISIBILITY_OPTIONS: Pick<VisibilityOptions, "enableHiding">;
@@ -0,0 +1,3 @@
1
+ export const VISIBILITY_OPTIONS = {
2
+ enableHiding: true,
3
+ };
@@ -1,3 +1,3 @@
1
1
  import { RowData } from "@tanstack/react-table";
2
2
  import { TableProps } from "./types";
3
- export declare const Table: <T extends RowData>({ table, }: TableProps<T>) => JSX.Element;
3
+ export declare const Table: <T extends RowData>({ row, table, }: TableProps<T>) => JSX.Element;
@@ -7,11 +7,11 @@ 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 = ({ row, table, }) => {
11
11
  return (React.createElement(StyledRoundedPaper, { variant: "table" },
12
12
  React.createElement(GridPaper, null,
13
13
  React.createElement(TableContainer, null,
14
14
  React.createElement(GridTable, { gridTemplateColumns: getColumnTrackSizing(table.getVisibleFlatColumns()) },
15
15
  React.createElement(TableHead, { rowDirection: ROW_DIRECTION.DEFAULT, tableInstance: table }),
16
- React.createElement(TableBody, { rowDirection: ROW_DIRECTION.DEFAULT, tableInstance: table }))))));
16
+ React.createElement(TableBody, { rowDirection: ROW_DIRECTION.DEFAULT, rows: row.getLeafRows(), tableInstance: table }))))));
17
17
  };
@@ -1,4 +1,7 @@
1
- import { RowData, Table } from "@tanstack/react-table";
1
+ import { Row, RowData, Table } from "@tanstack/react-table";
2
+ import { Class } from "common/entities";
3
+ export type ClassMeta = Record<Class["name"], Pick<Class, "description" | "title">>;
2
4
  export interface TableProps<T extends RowData> {
5
+ row: Row<T>;
3
6
  table: Table<T>;
4
7
  }
@@ -0,0 +1,18 @@
1
+ import { RowData } from "@tanstack/react-table";
2
+ import { Attribute, Class } from "../../../../common/entities";
3
+ import { ClassMeta } from "./types";
4
+ /**
5
+ * Builds class meta data from classes.
6
+ * Metadata is used to display class title and description above each "grouped" table.
7
+ * @param classes - Class entities.
8
+ * @returns Class meta data.
9
+ */
10
+ export declare const buildClassMeta: <T extends RowData = Attribute>(classes: Class<T>[]) => ClassMeta;
11
+ /**
12
+ * Builds table data from classes.
13
+ * RowData contains attributes of a class and a classKey property `Class["name"]` to identify the class the row belongs to.
14
+ * `classKey` is used to group rows by class.
15
+ * @param classes - Class entities.
16
+ * @returns Table data.
17
+ */
18
+ export declare const buildTableData: <T extends RowData = Attribute>(classes: Class<T>[]) => T[];
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Builds class meta data from classes.
3
+ * Metadata is used to display class title and description above each "grouped" table.
4
+ * @param classes - Class entities.
5
+ * @returns Class meta data.
6
+ */
7
+ export const buildClassMeta = (classes) => {
8
+ return Object.fromEntries(classes.map(({ description, name, title }) => [
9
+ name,
10
+ { description, title },
11
+ ]));
12
+ };
13
+ /**
14
+ * Builds table data from classes.
15
+ * RowData contains attributes of a class and a classKey property `Class["name"]` to identify the class the row belongs to.
16
+ * `classKey` is used to group rows by class.
17
+ * @param classes - Class entities.
18
+ * @returns Table data.
19
+ */
20
+ export const buildTableData = (classes) => {
21
+ return classes
22
+ .map(({ attributes, name: classKey }) => attributes.map((attribute) => ({
23
+ ...attribute,
24
+ classKey,
25
+ })))
26
+ .flat();
27
+ };
@@ -1,4 +1,4 @@
1
1
  import { RowData } from "@tanstack/react-table";
2
2
  import { Attribute } from "../../common/entities";
3
3
  import { DataDictionaryProps } from "./types";
4
- export declare const DataDictionary: <T extends RowData = Attribute>({ className, EntitiesLayout, Outline, OutlineLayout, Title, TitleLayout, }: DataDictionaryProps) => JSX.Element;
4
+ export declare const DataDictionary: <T extends RowData = Attribute>({ className, EntitiesLayout, FiltersLayout, Outline, OutlineLayout, Title, TitleLayout, }: DataDictionaryProps) => JSX.Element;
@@ -1,23 +1,25 @@
1
- import React, { useMemo } from "react";
1
+ import React from "react";
2
2
  import { Entities } from "./components/Entities/entities";
3
+ import { Filters } from "./components/Filters/filters";
3
4
  import { EntitiesLayout as DefaultEntitiesLayout } from "./components/Layout/components/EntitiesLayout/entitiesLayout";
5
+ import { FiltersLayout as DefaultFiltersLayout } from "./components/Layout/components/FiltersLayout/filtersLayout";
4
6
  import { OutlineLayout as DefaultOutlineLayout } from "./components/Layout/components/OutlineLayout/outlineLayout";
5
7
  import { TitleLayout as DefaultTitleLayout } from "./components/Layout/components/TitleLayout/titleLayout";
6
8
  import { Outline as DefaultOutline } from "./components/Outline/outline";
7
- import { buildClassesOutline } from "./components/Outline/utils";
8
9
  import { Title as DefaultTitle } from "./components/Title/title";
9
10
  import { View } from "./dataDictionary.styles";
10
11
  import { useDataDictionary } from "./hooks/UseDataDictionary/hook";
11
12
  import { useLayoutSpacing } from "./hooks/UseLayoutSpacing/hook";
12
- export const DataDictionary = ({ className, EntitiesLayout = DefaultEntitiesLayout, Outline = DefaultOutline, OutlineLayout = DefaultOutlineLayout, Title = DefaultTitle, TitleLayout = DefaultTitleLayout, }) => {
13
- const { classes, columnDefs, title } = useDataDictionary();
13
+ export const DataDictionary = ({ className, EntitiesLayout = DefaultEntitiesLayout, FiltersLayout = DefaultFiltersLayout, Outline = DefaultOutline, OutlineLayout = DefaultOutlineLayout, Title = DefaultTitle, TitleLayout = DefaultTitleLayout, }) => {
14
+ const { outline, table, title } = useDataDictionary();
14
15
  const { spacing } = useLayoutSpacing();
15
- const outline = useMemo(() => buildClassesOutline(classes), [classes]);
16
16
  return (React.createElement(View, { className: className },
17
17
  React.createElement(TitleLayout, { ...spacing },
18
18
  React.createElement(Title, { title: title })),
19
19
  React.createElement(OutlineLayout, { ...spacing },
20
20
  React.createElement(Outline, { outline: outline })),
21
+ React.createElement(FiltersLayout, { ...spacing },
22
+ React.createElement(Filters, { table: table })),
21
23
  React.createElement(EntitiesLayout, { ...spacing },
22
- React.createElement(Entities, { classes: classes, columnDefs: columnDefs, spacing: spacing }))));
24
+ React.createElement(Entities, { spacing: spacing, table: table }))));
23
25
  };
@@ -1,12 +1,23 @@
1
1
  import { useMemo } from "react";
2
2
  import { useConfig } from "../../../../hooks/useConfig";
3
+ import { buildClassesOutline } from "../../components/Outline/utils";
4
+ import { useTable } from "../../components/Table/hook";
3
5
  export const useDataDictionary = () => {
4
6
  const { config: { dataDictionaries: dataDictionaryConfigs }, } = useConfig();
7
+ // Get dictionary config.
5
8
  const dataDictionaryConfig = dataDictionaryConfigs?.[0]; // TODO: Handle multiple data dictionaries
6
- return useMemo(() => {
7
- const classes = dataDictionaryConfig?.dataDictionary?.classes || [];
8
- const columnDefs = dataDictionaryConfig?.columnDefs || [];
9
- const title = dataDictionaryConfig?.dataDictionary?.title || "";
10
- return { classes, columnDefs, title };
9
+ // Get configured dictionary classes, column definitions and table options.
10
+ const { classes, columnDefs, tableOptions, title } = useMemo(() => {
11
+ return {
12
+ classes: dataDictionaryConfig?.dataDictionary?.classes || [],
13
+ columnDefs: dataDictionaryConfig?.columnDefs || [],
14
+ tableOptions: dataDictionaryConfig?.tableOptions || {},
15
+ title: dataDictionaryConfig?.dataDictionary?.title || "",
16
+ };
11
17
  }, [dataDictionaryConfig]);
18
+ // Build table instance.
19
+ const table = useTable(classes, columnDefs, tableOptions);
20
+ // Build outline.
21
+ const outline = buildClassesOutline(table);
22
+ return { outline, table, title };
12
23
  };
@@ -1,7 +1,8 @@
1
- import { ColumnDef, RowData } from "@tanstack/react-table";
2
- import { Attribute, Class } from "../../../../common/entities";
1
+ import { RowData, Table } from "@tanstack/react-table";
2
+ import { Attribute } from "../../../../common/entities";
3
+ import { OutlineItem } from "../../../Layout/components/Outline/types";
3
4
  export interface UseDataDictionary<T extends RowData = Attribute> {
4
- classes: Class<T>[];
5
- columnDefs: ColumnDef<T, T[keyof T]>[];
5
+ outline: OutlineItem[];
6
+ table: Table<T>;
6
7
  title: string;
7
8
  }
@@ -2,6 +2,7 @@ import { ElementType } from "react";
2
2
  import { BaseComponentProps } from "../types";
3
3
  export interface DataDictionaryProps extends BaseComponentProps {
4
4
  EntitiesLayout?: ElementType;
5
+ FiltersLayout?: ElementType;
5
6
  Outline?: ElementType;
6
7
  OutlineLayout?: ElementType;
7
8
  Title?: ElementType;
@@ -1,9 +1,15 @@
1
- import { RowData, Table } from "@tanstack/react-table";
1
+ import { Row, RowData, Table } from "@tanstack/react-table";
2
2
  import { ROW_DIRECTION } from "../../../../../Table/common/entities";
3
3
  import { TableView } from "../../table";
4
4
  export interface TableBodyProps<T extends RowData> {
5
5
  rowDirection: ROW_DIRECTION;
6
+ /**
7
+ * Optional override for the rows rendered by <TableBody>.
8
+ * - Omit to show the table’s full leaf-level row model.
9
+ * - Pass `group.subRows` (or any other subset) to display a “mini-table” for a single group e.g. the rows that belong to one Data-Dictionary entity.
10
+ */
11
+ rows?: Row<T>[];
6
12
  tableInstance: Table<T>;
7
13
  tableView?: TableView;
8
14
  }
9
- export declare const TableBody: <T extends RowData>({ rowDirection, tableInstance, tableView, }: TableBodyProps<T>) => JSX.Element;
15
+ export declare const TableBody: <T extends RowData>({ rowDirection, rows, tableInstance, tableView, }: TableBodyProps<T>) => JSX.Element;
@@ -3,6 +3,6 @@ import React from "react";
3
3
  import { ROW_DIRECTION } from "../../../../../Table/common/entities";
4
4
  import { CollapsableRows } from "../TableRows/components/CollapsableRows/collapsableRows";
5
5
  import { TableRows } from "../TableRows/tableRows";
6
- export const TableBody = ({ rowDirection, tableInstance, tableView, }) => {
7
- return (React.createElement(MTableBody, null, rowDirection === ROW_DIRECTION.DEFAULT ? (React.createElement(TableRows, { tableInstance: tableInstance, tableView: tableView })) : (React.createElement(CollapsableRows, { tableInstance: tableInstance }))));
6
+ export const TableBody = ({ rowDirection, rows, tableInstance, tableView, }) => {
7
+ return (React.createElement(MTableBody, null, rowDirection === ROW_DIRECTION.DEFAULT ? (React.createElement(TableRows, { rows: rows, tableInstance: tableInstance, tableView: tableView })) : (React.createElement(CollapsableRows, { rows: rows, tableInstance: tableInstance }))));
8
8
  };
@@ -1,5 +1,11 @@
1
- import { RowData, Table } from "@tanstack/react-table";
1
+ import { Row, RowData, Table } from "@tanstack/react-table";
2
2
  export interface CollapsableRowsProps<T extends RowData> {
3
+ /**
4
+ * Optional override for the rows rendered by <CollapsableRows>.
5
+ * - Omit to show the table’s full leaf-level row model.
6
+ * - Pass `group.subRows` (or any other subset) to display a “mini-table” for a single group e.g. the rows that belong to one Data-Dictionary entity.
7
+ */
8
+ rows?: Row<T>[];
3
9
  tableInstance: Table<T>;
4
10
  }
5
- export declare const CollapsableRows: <T extends RowData>({ tableInstance, }: CollapsableRowsProps<T>) => JSX.Element;
11
+ export declare const CollapsableRows: <T extends RowData>({ rows: leafOrSubRows, tableInstance, }: CollapsableRowsProps<T>) => JSX.Element;
@@ -3,11 +3,11 @@ import { isCollapsableRowDisabled } from "../../../../../../../Table/common/util
3
3
  import { CollapsableCell } from "../../../../../../../Table/components/TableCell/components/CollapsableCell/collapsableCell";
4
4
  import { TableRow } from "../../../../../../../Table/components/TableRow/tableRow.styles";
5
5
  import { useCollapsableRows } from "../../../../../../../Table/components/TableRows/components/CollapsableRows/hook";
6
- export const CollapsableRows = ({ tableInstance, }) => {
6
+ export const CollapsableRows = ({ rows: leafOrSubRows, tableInstance, }) => {
7
7
  const { getRowModel } = tableInstance;
8
8
  const { rows } = getRowModel();
9
9
  useCollapsableRows(tableInstance);
10
- return (React.createElement(Fragment, null, rows.map((row) => {
10
+ return (React.createElement(Fragment, null, (leafOrSubRows || rows).map((row) => {
11
11
  if (row.depth > 0)
12
12
  return null; // Hide sub rows.
13
13
  return (React.createElement(TableRow, { key: row.id, isPreview: row.getIsPreview() },
@@ -1,7 +1,13 @@
1
- import { RowData, Table } from "@tanstack/react-table";
1
+ import { Row, RowData, Table } from "@tanstack/react-table";
2
2
  import { TableView } from "../../table";
3
3
  export interface TableRowsProps<T extends RowData> {
4
+ /**
5
+ * Optional override for the rows rendered by <TableRows>.
6
+ * - Omit to show the table’s full leaf-level row model.
7
+ * - Pass `group.subRows` (or any other subset) to display a “mini-table” for a single group e.g. the rows that belong to one Data-Dictionary entity.
8
+ */
9
+ rows?: Row<T>[];
4
10
  tableInstance: Table<T>;
5
11
  tableView?: TableView;
6
12
  }
7
- export declare const TableRows: <T extends RowData>({ tableInstance, tableView, }: TableRowsProps<T>) => JSX.Element;
13
+ export declare const TableRows: <T extends RowData>({ rows: leafOrSubRows, tableInstance, tableView, }: TableRowsProps<T>) => JSX.Element;
@@ -3,12 +3,12 @@ import { flexRender } from "@tanstack/react-table";
3
3
  import React, { Fragment } from "react";
4
4
  import { getTableCellAlign, getTableCellPadding, } from "../../../../../Table/components/TableCell/common/utils";
5
5
  import { TableRow } from "../../../../../Table/components/TableRow/tableRow.styles";
6
- export const TableRows = ({ tableInstance, tableView, }) => {
6
+ export const TableRows = ({ rows: leafOrSubRows, tableInstance, tableView, }) => {
7
7
  const { getRowModel } = tableInstance;
8
8
  const { rows } = getRowModel();
9
9
  const { tableCell } = tableView || {};
10
10
  const { size: tableCellSize = "medium" } = tableCell || {};
11
- return (React.createElement(Fragment, null, rows.map((row) => {
11
+ return (React.createElement(Fragment, null, (leafOrSubRows || rows).map((row) => {
12
12
  return (React.createElement(TableRow, { key: row.id, isGrouped: row.getIsGrouped(), isPreview: row.getIsPreview() }, row.getVisibleCells().map((cell) => {
13
13
  if (cell.getIsAggregated())
14
14
  return null; // Display of aggregated cells is currently not supported.
@@ -3,7 +3,7 @@ interface Props {
3
3
  }
4
4
  export declare const FilterLabel: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
5
5
  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;
6
- }, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "variant" | "disabled" | "href" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "fullWidth" | "disableElevation" | "disableFocusRipple" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & {
6
+ }, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "variant" | "disabled" | "href" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "loadingIndicator" | "loadingPosition" | "startIcon"> & {
7
7
  theme?: import("@emotion/react").Theme;
8
8
  } & Props, {}, {}>;
9
9
  export {};
@@ -1,3 +1,5 @@
1
+ export declare const MuiListItemButtonRoot: import("@emotion/react").SerializedStyles;
2
+ export declare const MuiListItemTextRoot: import("@emotion/react").SerializedStyles;
1
3
  export declare const List: import("@emotion/styled").StyledComponent<import("@mui/material").ListOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & {
2
4
  ref?: ((instance: HTMLUListElement | 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<HTMLUListElement> | null | undefined;
3
5
  }, "style" | "className" | "classes" | "children" | "sx" | "dense" | "subheader" | "disablePadding"> & {
@@ -1,6 +1,31 @@
1
+ import { css } from "@emotion/react";
1
2
  import styled from "@emotion/styled";
2
- import { List as MList } from "@mui/material";
3
+ import { listItemButtonClasses, listItemTextClasses, List as MList, } from "@mui/material";
4
+ import { PALETTE } from "../../../../styles/common/constants/palette";
3
5
  import { LIST_MARGIN } from "../../common/constants";
6
+ export const MuiListItemButtonRoot = css `
7
+ .${listItemButtonClasses.root} {
8
+ gap: 8px;
9
+ padding: 10px 16px;
10
+
11
+ &.Mui-disabled {
12
+ color: ${PALETTE.SMOKE_MAIN};
13
+ opacity: 1;
14
+ }
15
+ }
16
+ `;
17
+ export const MuiListItemTextRoot = css `
18
+ .${listItemTextClasses.root} {
19
+ align-items: center;
20
+ display: grid;
21
+ gap: 8px;
22
+ grid-template-columns: 1fr auto;
23
+
24
+ > span {
25
+ min-width: 0; /* required; flexbox child min-width property is "auto" by default making overflow-wrap ineffectual */
26
+ }
27
+ }
28
+ `;
4
29
  export const List = styled(MList) `
5
30
  && {
6
31
  overflow-wrap: break-word;
@@ -19,20 +44,8 @@ export const List = styled(MList) `
19
44
  }
20
45
 
21
46
  // List item
22
- .MuiListItemButton-root {
23
- gap: 8px;
24
- padding: 10px 16px;
25
- }
47
+ ${MuiListItemButtonRoot}
26
48
 
27
49
  // List item text
28
- .MuiListItemText-root {
29
- align-items: center;
30
- display: grid;
31
- gap: 8px;
32
- grid-template-columns: 1fr auto;
33
-
34
- > span {
35
- min-width: 0; /* required; flexbox child min-width property is "auto" by default making overflow-wrap ineffectual */
36
- }
37
- }
50
+ ${MuiListItemTextRoot}
38
51
  `;
@@ -1,5 +1,5 @@
1
1
  export declare const InputField: import("@emotion/styled").StyledComponent<{
2
2
  variant?: import("@mui/material").TextFieldVariants | undefined;
3
- } & Omit<import("@mui/material").FilledTextFieldProps | import("@mui/material").OutlinedTextFieldProps | import("@mui/material").StandardTextFieldProps, "variant"> & {
3
+ } & Omit<import("@mui/material").OutlinedTextFieldProps | import("@mui/material").FilledTextFieldProps | import("@mui/material").StandardTextFieldProps, "variant"> & {
4
4
  theme?: import("@emotion/react").Theme;
5
5
  }, {}, {}>;
@@ -1,5 +1,5 @@
1
1
  export declare const StyledButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
2
2
  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;
3
- }, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "variant" | "disabled" | "href" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "fullWidth" | "disableElevation" | "disableFocusRipple" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & {
3
+ }, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "variant" | "disabled" | "href" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "loadingIndicator" | "loadingPosition" | "startIcon"> & {
4
4
  theme?: import("@emotion/react").Theme;
5
5
  }, {}, {}>;
@@ -1,5 +1,5 @@
1
1
  export declare const StyledButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
2
2
  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;
3
- }, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "variant" | "disabled" | "href" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "fullWidth" | "disableElevation" | "disableFocusRipple" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & {
3
+ }, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "variant" | "disabled" | "href" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "loadingIndicator" | "loadingPosition" | "startIcon"> & {
4
4
  theme?: import("@emotion/react").Theme;
5
5
  }, {}, {}>;
@@ -1,5 +1,5 @@
1
1
  export declare const StyledTab: import("@emotion/styled").StyledComponent<import("@mui/material").TabOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
2
2
  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;
3
- }, "label" | "style" | "className" | "classes" | "tabIndex" | "children" | "sx" | "disabled" | "value" | "action" | "icon" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "wrapped" | "iconPosition"> & {
3
+ }, "label" | "style" | "className" | "classes" | "tabIndex" | "children" | "sx" | "disabled" | "value" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "icon" | "wrapped" | "iconPosition"> & {
4
4
  theme?: import("@emotion/react").Theme;
5
5
  }, {}, {}>;
@@ -10,7 +10,7 @@ export declare const StyledTabs: import("@emotion/styled").StyledComponent<impor
10
10
  }, {}, {}>;
11
11
  export declare const StyledTab: import("@emotion/styled").StyledComponent<import("@mui/material").TabOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
12
12
  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;
13
- }, "label" | "style" | "className" | "classes" | "tabIndex" | "children" | "sx" | "disabled" | "value" | "action" | "icon" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "wrapped" | "iconPosition"> & {
13
+ }, "label" | "style" | "className" | "classes" | "tabIndex" | "children" | "sx" | "disabled" | "value" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "icon" | "wrapped" | "iconPosition"> & {
14
14
  theme?: import("@emotion/react").Theme;
15
15
  } & Props, {}, {}>;
16
16
  export {};
@@ -1,5 +1,5 @@
1
1
  export declare const StyledButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
2
2
  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;
3
- }, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "variant" | "disabled" | "href" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "fullWidth" | "disableElevation" | "disableFocusRipple" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & {
3
+ }, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "variant" | "disabled" | "href" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "loadingIndicator" | "loadingPosition" | "startIcon"> & {
4
4
  theme?: import("@emotion/react").Theme;
5
5
  }, {}, {}>;
@@ -16,6 +16,12 @@ type PinnedCell<T extends RowData> = [Cell<T, unknown>, number];
16
16
  * @returns Array of category views objects.
17
17
  */
18
18
  export declare function buildCategoryViews<T extends RowData>(columns: Column<T>[], columnFilters: ColumnFiltersState): Category[];
19
+ /**
20
+ * Returns the header for a column as a string.
21
+ * @param column - Column.
22
+ * @returns column header.
23
+ */
24
+ export declare function getColumnHeader<T extends RowData>(column: Column<T>): string;
19
25
  /**
20
26
  * Returns filtered entity results as a blob.
21
27
  * @param rows - Table rows.
@@ -46,6 +46,20 @@ export function buildCategoryViews(columns, columnFilters) {
46
46
  }
47
47
  return categoryViews;
48
48
  }
49
+ /**
50
+ * Returns the header for a column as a string.
51
+ * @param column - Column.
52
+ * @returns column header.
53
+ */
54
+ export function getColumnHeader(column) {
55
+ const { columnDef, id = "" } = column;
56
+ const { header, meta } = columnDef;
57
+ // Return header if it is a string.
58
+ if (typeof header === "string")
59
+ return header;
60
+ // Return header from meta or id.
61
+ return meta?.header || id;
62
+ }
49
63
  /**
50
64
  * Format data to TSV string.
51
65
  * @param data - Table data.
@@ -0,0 +1,7 @@
1
+ import { RowData } from "@tanstack/react-table";
2
+ import { ColumnFilterProps } from "./types";
3
+ /**
4
+ * Column filter component with supported filter functions:
5
+ * - `arrIncludesSome`
6
+ */
7
+ export declare const ColumnFilter: <T extends RowData>({ Button, className, column, ...props }: ColumnFilterProps<T>) => JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { Checkbox, ListItemButton, ListItemText, Button as MButton, Typography, } from "@mui/material";
2
+ import React, { Fragment } from "react";
3
+ import { SVG_ICON_PROPS } from "../../../../../styles/common/mui/svgIcon";
4
+ import { TYPOGRAPHY_PROPS } from "../../../../../styles/common/mui/typography";
5
+ import { CheckedIcon } from "../../../../common/CustomIcon/components/CheckedIcon/checkedIcon";
6
+ import { UncheckedIcon } from "../../../../common/CustomIcon/components/UncheckedIcon/uncheckedIcon";
7
+ import { DropDownIcon } from "../../../../common/Form/components/Select/components/DropDownIcon/dropDownIcon";
8
+ import { useMenu } from "../../../../common/Menu/hooks/useMenu";
9
+ import { getColumnHeader } from "../../../common/utils";
10
+ import { getSortedFacetedValues } from "../../../featureOptions/facetedColumn/utils";
11
+ import { StyledMenu } from "./columnFilter.styles";
12
+ import { MENU_PROPS } from "./constants";
13
+ import { updater } from "./utils";
14
+ /**
15
+ * Column filter component with supported filter functions:
16
+ * - `arrIncludesSome`
17
+ */
18
+ export const ColumnFilter = ({ Button = MButton, className, column, ...props /* MuiMenuProps */ }) => {
19
+ const { anchorEl, onClose, onOpen, open } = useMenu();
20
+ const facetedUniqueValues = column.getFacetedUniqueValues();
21
+ const sortedValues = getSortedFacetedValues(facetedUniqueValues);
22
+ const filterValue = (column.getFilterValue() || []);
23
+ return (React.createElement(Fragment, null,
24
+ React.createElement(Button, { key: column.id, endIcon: React.createElement(DropDownIcon, { color: SVG_ICON_PROPS.COLOR.INK_LIGHT }), onClick: onOpen }, getColumnHeader(column)),
25
+ React.createElement(StyledMenu, { ...MENU_PROPS, ...props, className: className, anchorEl: anchorEl, onClose: onClose, open: open },
26
+ sortedValues.map(([value, occurrence]) => (React.createElement(ListItemButton, { key: String(value), selected: filterValue.includes(value), onClick: () => column.setFilterValue(updater(value)) },
27
+ React.createElement(Checkbox, { checked: filterValue.includes(value), checkedIcon: React.createElement(CheckedIcon, null), icon: React.createElement(UncheckedIcon, null) }),
28
+ React.createElement(ListItemText, { disableTypography: true, primary: React.createElement("span", null, String(value)), secondary: React.createElement(Typography, { color: TYPOGRAPHY_PROPS.COLOR.INK_LIGHT, variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_SMALL_400 }, occurrence) })))),
29
+ React.createElement(ListItemButton, { disabled: !column.getIsFiltered(), onClick: () => column.setFilterValue(undefined) },
30
+ React.createElement(Typography, { color: column.getIsFiltered()
31
+ ? TYPOGRAPHY_PROPS.COLOR.PRIMARY
32
+ : TYPOGRAPHY_PROPS.COLOR.INHERIT, variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_500 }, "Clear All")))));
33
+ };
@@ -0,0 +1,3 @@
1
+ export declare const StyledMenu: import("@emotion/styled").StyledComponent<import("@mui/material").MenuProps & {
2
+ theme?: import("@emotion/react").Theme;
3
+ }, {}, {}>;
@@ -0,0 +1,19 @@
1
+ import styled from "@emotion/styled";
2
+ import { Menu, menuClasses, paperClasses } from "@mui/material";
3
+ import { MAX_LIST_HEIGHT_PX } from "../../../../Filter/common/constants";
4
+ import { MuiListItemButtonRoot, MuiListItemTextRoot, } from "../../../../Filter/components/FilterList/filterList.styles";
5
+ export const StyledMenu = styled(Menu) `
6
+ .${paperClasses.root} {
7
+ margin: 4px 0;
8
+ width: 288px;
9
+
10
+ .${menuClasses.list} {
11
+ max-height: ${MAX_LIST_HEIGHT_PX}px;
12
+ overflow-wrap: break-word;
13
+
14
+ ${MuiListItemButtonRoot}
15
+
16
+ ${MuiListItemTextRoot}
17
+ }
18
+ }
19
+ `;
@@ -0,0 +1,2 @@
1
+ import { MenuProps } from "@mui/material";
2
+ export declare const MENU_PROPS: Omit<MenuProps, "anchorEl" | "onClose" | "open">;
@@ -0,0 +1,14 @@
1
+ export const MENU_PROPS = {
2
+ anchorOrigin: {
3
+ horizontal: "right",
4
+ vertical: "bottom",
5
+ },
6
+ marginThreshold: 8,
7
+ slotProps: {
8
+ paper: { variant: "menu" },
9
+ },
10
+ transformOrigin: {
11
+ horizontal: "right",
12
+ vertical: "top",
13
+ },
14
+ };