@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.
Files changed (213) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +18 -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/providers/exploreState/entities.d.ts +1 -1
  106. package/lib/providers/exploreState.js +10 -10
  107. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.d.ts +10 -0
  108. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.js +18 -0
  109. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.d.ts +1 -0
  110. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.js +33 -0
  111. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.d.ts +11 -0
  112. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.js +5 -0
  113. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/utils.d.ts +34 -0
  114. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/utils.js +59 -0
  115. package/lib/providers/exploreStateSync/provider.d.ts +19 -0
  116. package/lib/providers/exploreStateSync/provider.js +22 -0
  117. package/lib/styles/common/mui/buttonGroup.d.ts +13 -0
  118. package/lib/styles/common/mui/buttonGroup.js +34 -0
  119. package/lib/styles/common/mui/typography.js +2 -0
  120. package/lib/tests/mui/constants.d.ts +1 -0
  121. package/lib/tests/mui/constants.js +1 -0
  122. package/lib/tests/utils.d.ts +6 -0
  123. package/lib/tests/utils.js +8 -0
  124. package/lib/theme/common/components.d.ts +0 -6
  125. package/lib/theme/common/components.js +17 -31
  126. package/lib/theme/components/index.d.ts +1 -0
  127. package/lib/theme/components/index.js +1 -0
  128. package/lib/theme/components/muiButtonGroup.d.ts +2 -0
  129. package/lib/theme/components/muiButtonGroup.js +76 -0
  130. package/lib/theme/theme.js +1 -1
  131. package/lib/views/ExploreView/exploreView.js +2 -1
  132. package/package.json +1 -1
  133. package/src/common/entities.ts +3 -1
  134. package/src/components/DataDictionary/components/Entities/entities.tsx +5 -9
  135. package/src/components/DataDictionary/components/Entities/types.ts +3 -4
  136. package/src/components/DataDictionary/components/Entity/entity.styles.ts +9 -1
  137. package/src/components/DataDictionary/components/Entity/entity.tsx +18 -8
  138. package/src/components/DataDictionary/components/Entity/types.ts +4 -4
  139. package/src/components/DataDictionary/components/Entity/utils.ts +25 -0
  140. package/src/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.tsx +21 -0
  141. package/src/components/DataDictionary/components/Filters/components/ColumnFilters/types.ts +6 -0
  142. package/src/components/DataDictionary/components/Filters/filters.styles.ts +14 -0
  143. package/src/components/DataDictionary/components/Filters/filters.tsx +16 -0
  144. package/src/components/DataDictionary/components/Filters/stories/constants.ts +31 -0
  145. package/src/components/DataDictionary/components/Filters/stories/filters.stories.tsx +42 -0
  146. package/src/components/DataDictionary/components/Filters/stories/hook.ts +9 -0
  147. package/src/components/DataDictionary/components/Filters/stories/types.ts +3 -0
  148. package/src/components/DataDictionary/components/Filters/types.ts +6 -0
  149. package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.ts +4 -1
  150. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.ts +27 -0
  151. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.tsx +10 -0
  152. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/types.ts +6 -0
  153. package/src/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.ts +1 -1
  154. package/src/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.ts +1 -0
  155. package/src/components/DataDictionary/components/Layout/constants.ts +4 -0
  156. package/src/components/DataDictionary/components/Outline/utils.ts +35 -13
  157. package/src/components/DataDictionary/components/Table/hook.ts +17 -5
  158. package/src/components/DataDictionary/components/Table/options/columnFilters/constants.ts +16 -0
  159. package/src/components/DataDictionary/components/Table/options/columnFilters/hook.ts +32 -0
  160. package/src/components/DataDictionary/components/Table/options/expanded/constants.ts +13 -0
  161. package/src/components/DataDictionary/components/Table/options/faceted/constants.ts +14 -0
  162. package/src/components/DataDictionary/components/Table/options/grouping/constants.ts +9 -0
  163. package/src/components/DataDictionary/components/Table/options/hook.ts +26 -3
  164. package/src/components/DataDictionary/components/Table/options/visibility/constants.ts +5 -0
  165. package/src/components/DataDictionary/components/Table/table.tsx +2 -0
  166. package/src/components/DataDictionary/components/Table/types.ts +8 -1
  167. package/src/components/DataDictionary/components/Table/utils.ts +40 -0
  168. package/src/components/DataDictionary/dataDictionary.tsx +9 -5
  169. package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +19 -5
  170. package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +5 -4
  171. package/src/components/DataDictionary/types.ts +1 -0
  172. package/src/components/Detail/components/Table/components/TableBody/tableBody.tsx +14 -3
  173. package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +9 -2
  174. package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +9 -2
  175. package/src/components/Filter/components/FilterList/filterList.styles.ts +34 -15
  176. package/src/components/Table/common/utils.ts +16 -0
  177. package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.ts +23 -0
  178. package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.tsx +98 -0
  179. package/src/components/Table/components/TableFeatures/ColumnFilter/constants.ts +16 -0
  180. package/src/components/Table/components/TableFeatures/ColumnFilter/types.ts +10 -0
  181. package/src/components/Table/components/TableFeatures/ColumnFilter/utils.ts +27 -0
  182. package/src/components/Table/featureOptions/facetedColumn/utils.ts +14 -0
  183. package/src/components/common/ButtonGroup/constants.ts +13 -0
  184. package/src/mocks/@storybook/addon-actions.ts +10 -0
  185. package/src/providers/exploreState/entities.ts +1 -1
  186. package/src/providers/exploreState.tsx +10 -11
  187. package/src/providers/exploreStateSync/hooks/UseMetaCommands/handlers.ts +25 -0
  188. package/src/providers/exploreStateSync/hooks/UseMetaCommands/hook.ts +38 -0
  189. package/src/providers/exploreStateSync/hooks/UseMetaCommands/types.ts +13 -0
  190. package/src/providers/exploreStateSync/hooks/UseMetaCommands/utils.ts +69 -0
  191. package/src/providers/exploreStateSync/provider.tsx +29 -0
  192. package/src/styles/common/mui/buttonGroup.ts +46 -0
  193. package/src/styles/common/mui/typography.ts +2 -0
  194. package/src/tests/mui/constants.ts +1 -0
  195. package/src/tests/utils.ts +9 -0
  196. package/src/theme/common/components.ts +17 -32
  197. package/src/theme/components/index.ts +1 -0
  198. package/src/theme/components/muiButtonGroup.ts +79 -0
  199. package/src/theme/theme.ts +1 -1
  200. package/src/views/ExploreView/exploreView.tsx +3 -2
  201. package/tests/dataDictionaryColumnFilters.test.tsx +101 -0
  202. package/lib/providers/exploreState/hooks/UseMetaCommands/actions.d.ts +0 -13
  203. package/lib/providers/exploreState/hooks/UseMetaCommands/actions.js +0 -24
  204. package/lib/providers/exploreState/hooks/UseMetaCommands/types.d.ts +0 -4
  205. package/lib/providers/exploreState/hooks/UseMetaCommands/types.js +0 -5
  206. package/lib/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.d.ts +0 -2
  207. package/lib/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.js +0 -21
  208. package/lib/providers/exploreState/hooks/UseMetaCommands/utils.d.ts +0 -9
  209. package/lib/providers/exploreState/hooks/UseMetaCommands/utils.js +0 -25
  210. package/src/providers/exploreState/hooks/UseMetaCommands/actions.ts +0 -29
  211. package/src/providers/exploreState/hooks/UseMetaCommands/types.ts +0 -4
  212. package/src/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.ts +0 -27
  213. package/src/providers/exploreState/hooks/UseMetaCommands/utils.ts +0 -33
@@ -0,0 +1,16 @@
1
+ import {
2
+ ColumnFiltersOptions,
3
+ RowData,
4
+ getFilteredRowModel,
5
+ } from "@tanstack/react-table";
6
+ import { arrIncludesSome } from "../../../../../Table/columnDef/columnFilters/filterFn";
7
+
8
+ export const COLUMN_FILTERS_OPTIONS: Pick<
9
+ ColumnFiltersOptions<RowData>,
10
+ "enableColumnFilters" | "enableFilters" | "filterFns" | "getFilteredRowModel"
11
+ > = {
12
+ enableColumnFilters: true,
13
+ enableFilters: true,
14
+ filterFns: { arrIncludesSome },
15
+ getFilteredRowModel: getFilteredRowModel(),
16
+ };
@@ -0,0 +1,32 @@
1
+ import {
2
+ ColumnFiltersOptions,
3
+ ColumnFiltersState,
4
+ RowData,
5
+ Updater,
6
+ } from "@tanstack/react-table";
7
+ import { Dispatch, SetStateAction, useCallback } from "react";
8
+ import { Attribute } from "../../../../../../common/entities";
9
+ import { resolveUpdater } from "../../../../../Table/options/updater";
10
+ import { COLUMN_FILTERS_OPTIONS } from "./constants";
11
+
12
+ export const useColumnFiltersOptions = <T extends RowData = Attribute>({
13
+ setColumnFilters,
14
+ }: {
15
+ setColumnFilters: Dispatch<SetStateAction<ColumnFiltersState>>;
16
+ }): ColumnFiltersOptions<T> => {
17
+ // Column filters change handler.
18
+ // TODO dispatch to provider with reducer.
19
+ const onColumnFiltersChange = useCallback(
20
+ (updaterOrValue: Updater<ColumnFiltersState>): void => {
21
+ setColumnFilters((old) =>
22
+ resolveUpdater<ColumnFiltersState>(updaterOrValue, old)
23
+ );
24
+ },
25
+ [setColumnFilters]
26
+ );
27
+
28
+ return {
29
+ ...COLUMN_FILTERS_OPTIONS,
30
+ onColumnFiltersChange,
31
+ };
32
+ };
@@ -0,0 +1,13 @@
1
+ import {
2
+ ExpandedOptions,
3
+ getExpandedRowModel,
4
+ RowData,
5
+ } from "@tanstack/react-table";
6
+
7
+ export const EXPANDED_OPTIONS: Pick<
8
+ ExpandedOptions<RowData>,
9
+ "enableExpanding" | "getExpandedRowModel"
10
+ > = {
11
+ enableExpanding: true,
12
+ getExpandedRowModel: getExpandedRowModel(),
13
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ FacetedOptions,
3
+ getFacetedRowModel,
4
+ RowData,
5
+ } from "@tanstack/react-table";
6
+ import { getFacetedUniqueValuesWithArrayValues } from "../../../../../Table/common/utils";
7
+
8
+ export const FACETED_OPTIONS: Pick<
9
+ FacetedOptions<RowData>,
10
+ "getFacetedRowModel" | "getFacetedUniqueValues"
11
+ > = {
12
+ getFacetedRowModel: getFacetedRowModel(),
13
+ getFacetedUniqueValues: getFacetedUniqueValuesWithArrayValues(),
14
+ };
@@ -0,0 +1,9 @@
1
+ import { GroupingOptions, getGroupedRowModel } from "@tanstack/react-table";
2
+
3
+ export const GROUPING_OPTIONS: Pick<
4
+ GroupingOptions,
5
+ "enableGrouping" | "getGroupedRowModel"
6
+ > = {
7
+ enableGrouping: true,
8
+ getGroupedRowModel: getGroupedRowModel(),
9
+ };
@@ -1,14 +1,37 @@
1
- import { RowData, TableOptions } from "@tanstack/react-table";
1
+ import {
2
+ ColumnFiltersState,
3
+ RowData,
4
+ TableOptions,
5
+ } from "@tanstack/react-table";
6
+ import { useState } from "react";
2
7
  import { Attribute } from "../../../../../common/entities";
8
+ import { useColumnFiltersOptions } from "./columnFilters/hook";
3
9
  import { CORE_OPTIONS } from "./core/constants";
10
+ import { EXPANDED_OPTIONS } from "./expanded/constants";
11
+ import { FACETED_OPTIONS } from "./faceted/constants";
12
+ import { GROUPING_OPTIONS } from "./grouping/constants";
4
13
  import { SORTING_OPTIONS } from "./sorting/constants";
14
+ import { VISIBILITY_OPTIONS } from "./visibility/constants";
5
15
 
6
16
  export const useTableOptions = <T extends RowData = Attribute>(): Omit<
7
17
  TableOptions<T>,
8
- "columns" | "data"
18
+ "columns" | "data" | "initialState"
9
19
  > => {
20
+ // Column filters state - to be moved to a provider with a reducer.
21
+ const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
22
+
23
+ // Column filters options.
24
+ const columnFiltersOptions = useColumnFiltersOptions<T>({ setColumnFilters });
25
+
26
+ // Table options.
10
27
  return {
28
+ ...columnFiltersOptions,
11
29
  ...CORE_OPTIONS,
30
+ ...EXPANDED_OPTIONS,
31
+ ...FACETED_OPTIONS,
32
+ ...GROUPING_OPTIONS,
12
33
  ...SORTING_OPTIONS,
13
- };
34
+ ...VISIBILITY_OPTIONS,
35
+ state: { columnFilters },
36
+ } as TableOptions<T>;
14
37
  };
@@ -0,0 +1,5 @@
1
+ import { VisibilityOptions } from "@tanstack/react-table";
2
+
3
+ export const VISIBILITY_OPTIONS: Pick<VisibilityOptions, "enableHiding"> = {
4
+ enableHiding: true,
5
+ };
@@ -11,6 +11,7 @@ import { StyledRoundedPaper } from "./table.styles";
11
11
  import { TableProps } from "./types";
12
12
 
13
13
  export const Table = <T extends RowData>({
14
+ row,
14
15
  table,
15
16
  }: TableProps<T>): JSX.Element => {
16
17
  return (
@@ -28,6 +29,7 @@ export const Table = <T extends RowData>({
28
29
  />
29
30
  <TableBody
30
31
  rowDirection={ROW_DIRECTION.DEFAULT}
32
+ rows={row.getLeafRows()}
31
33
  tableInstance={table}
32
34
  />
33
35
  </GridTable>
@@ -1,5 +1,12 @@
1
- import { RowData, Table } from "@tanstack/react-table";
1
+ import { Row, RowData, Table } from "@tanstack/react-table";
2
+ import { Class } from "common/entities";
3
+
4
+ export type ClassMeta = Record<
5
+ Class["name"],
6
+ Pick<Class, "description" | "title">
7
+ >;
2
8
 
3
9
  export interface TableProps<T extends RowData> {
10
+ row: Row<T>;
4
11
  table: Table<T>;
5
12
  }
@@ -0,0 +1,40 @@
1
+ import { RowData } from "@tanstack/react-table";
2
+ import { Attribute, Class } from "../../../../common/entities";
3
+ import { ClassMeta } from "./types";
4
+
5
+ /**
6
+ * Builds class meta data from classes.
7
+ * Metadata is used to display class title and description above each "grouped" table.
8
+ * @param classes - Class entities.
9
+ * @returns Class meta data.
10
+ */
11
+ export const buildClassMeta = <T extends RowData = Attribute>(
12
+ classes: Class<T>[]
13
+ ): ClassMeta => {
14
+ return Object.fromEntries(
15
+ classes.map(({ description, name, title }) => [
16
+ name,
17
+ { description, title },
18
+ ])
19
+ );
20
+ };
21
+
22
+ /**
23
+ * Builds table data from classes.
24
+ * RowData contains attributes of a class and a classKey property `Class["name"]` to identify the class the row belongs to.
25
+ * `classKey` is used to group rows by class.
26
+ * @param classes - Class entities.
27
+ * @returns Table data.
28
+ */
29
+ export const buildTableData = <T extends RowData = Attribute>(
30
+ classes: Class<T>[]
31
+ ): T[] => {
32
+ return classes
33
+ .map(({ attributes, name: classKey }) =>
34
+ attributes.map((attribute) => ({
35
+ ...(attribute as unknown as Attribute),
36
+ classKey,
37
+ }))
38
+ )
39
+ .flat() as T[];
40
+ };
@@ -1,12 +1,13 @@
1
1
  import { RowData } from "@tanstack/react-table";
2
- import React, { useMemo } from "react";
2
+ import React from "react";
3
3
  import { Attribute } from "../../common/entities";
4
4
  import { Entities } from "./components/Entities/entities";
5
+ import { Filters } from "./components/Filters/filters";
5
6
  import { EntitiesLayout as DefaultEntitiesLayout } from "./components/Layout/components/EntitiesLayout/entitiesLayout";
7
+ import { FiltersLayout as DefaultFiltersLayout } from "./components/Layout/components/FiltersLayout/filtersLayout";
6
8
  import { OutlineLayout as DefaultOutlineLayout } from "./components/Layout/components/OutlineLayout/outlineLayout";
7
9
  import { TitleLayout as DefaultTitleLayout } from "./components/Layout/components/TitleLayout/titleLayout";
8
10
  import { Outline as DefaultOutline } from "./components/Outline/outline";
9
- import { buildClassesOutline } from "./components/Outline/utils";
10
11
  import { Title as DefaultTitle } from "./components/Title/title";
11
12
  import { View } from "./dataDictionary.styles";
12
13
  import { useDataDictionary } from "./hooks/UseDataDictionary/hook";
@@ -16,14 +17,14 @@ import { DataDictionaryProps } from "./types";
16
17
  export const DataDictionary = <T extends RowData = Attribute>({
17
18
  className,
18
19
  EntitiesLayout = DefaultEntitiesLayout,
20
+ FiltersLayout = DefaultFiltersLayout,
19
21
  Outline = DefaultOutline,
20
22
  OutlineLayout = DefaultOutlineLayout,
21
23
  Title = DefaultTitle,
22
24
  TitleLayout = DefaultTitleLayout,
23
25
  }: DataDictionaryProps): JSX.Element => {
24
- const { classes, columnDefs, title } = useDataDictionary<T>();
26
+ const { outline, table, title } = useDataDictionary<T>();
25
27
  const { spacing } = useLayoutSpacing();
26
- const outline = useMemo(() => buildClassesOutline(classes), [classes]);
27
28
  return (
28
29
  <View className={className}>
29
30
  <TitleLayout {...spacing}>
@@ -32,8 +33,11 @@ export const DataDictionary = <T extends RowData = Attribute>({
32
33
  <OutlineLayout {...spacing}>
33
34
  <Outline outline={outline} />
34
35
  </OutlineLayout>
36
+ <FiltersLayout {...spacing}>
37
+ <Filters table={table} />
38
+ </FiltersLayout>
35
39
  <EntitiesLayout {...spacing}>
36
- <Entities classes={classes} columnDefs={columnDefs} spacing={spacing} />
40
+ <Entities spacing={spacing} table={table} />
37
41
  </EntitiesLayout>
38
42
  </View>
39
43
  );
@@ -2,6 +2,8 @@ import { RowData } from "@tanstack/react-table";
2
2
  import { useMemo } from "react";
3
3
  import { Attribute, DataDictionaryConfig } from "../../../../common/entities";
4
4
  import { useConfig } from "../../../../hooks/useConfig";
5
+ import { buildClassesOutline } from "../../components/Outline/utils";
6
+ import { useTable } from "../../components/Table/hook";
5
7
  import { UseDataDictionary } from "./types";
6
8
 
7
9
  export const useDataDictionary = <
@@ -11,14 +13,26 @@ export const useDataDictionary = <
11
13
  config: { dataDictionaries: dataDictionaryConfigs },
12
14
  } = useConfig();
13
15
 
16
+ // Get dictionary config.
14
17
  const dataDictionaryConfig = dataDictionaryConfigs?.[0] as
15
18
  | DataDictionaryConfig<T>
16
19
  | undefined; // TODO: Handle multiple data dictionaries
17
20
 
18
- return useMemo(() => {
19
- const classes = dataDictionaryConfig?.dataDictionary?.classes || [];
20
- const columnDefs = dataDictionaryConfig?.columnDefs || [];
21
- const title = dataDictionaryConfig?.dataDictionary?.title || "";
22
- return { classes, columnDefs, title };
21
+ // Get configured dictionary classes, column definitions and table options.
22
+ const { classes, columnDefs, tableOptions, title } = useMemo(() => {
23
+ return {
24
+ classes: dataDictionaryConfig?.dataDictionary?.classes || [],
25
+ columnDefs: dataDictionaryConfig?.columnDefs || [],
26
+ tableOptions: dataDictionaryConfig?.tableOptions || {},
27
+ title: dataDictionaryConfig?.dataDictionary?.title || "",
28
+ };
23
29
  }, [dataDictionaryConfig]);
30
+
31
+ // Build table instance.
32
+ const table = useTable<T>(classes, columnDefs, tableOptions);
33
+
34
+ // Build outline.
35
+ const outline = buildClassesOutline<T>(table);
36
+
37
+ return { outline, table, title };
24
38
  };
@@ -1,8 +1,9 @@
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
 
4
5
  export interface UseDataDictionary<T extends RowData = Attribute> {
5
- classes: Class<T>[];
6
- columnDefs: ColumnDef<T, T[keyof T]>[];
6
+ outline: OutlineItem[];
7
+ table: Table<T>;
7
8
  title: string;
8
9
  }
@@ -3,6 +3,7 @@ import { BaseComponentProps } from "../types";
3
3
 
4
4
  export interface DataDictionaryProps extends BaseComponentProps {
5
5
  EntitiesLayout?: ElementType;
6
+ FiltersLayout?: ElementType;
6
7
  Outline?: ElementType;
7
8
  OutlineLayout?: ElementType;
8
9
  Title?: ElementType;
@@ -1,5 +1,5 @@
1
1
  import { TableBody as MTableBody } from "@mui/material";
2
- import { RowData, Table } from "@tanstack/react-table";
2
+ import { Row, RowData, Table } from "@tanstack/react-table";
3
3
  import React from "react";
4
4
  import { ROW_DIRECTION } from "../../../../../Table/common/entities";
5
5
  import { TableView } from "../../table";
@@ -8,21 +8,32 @@ import { TableRows } from "../TableRows/tableRows";
8
8
 
9
9
  export interface TableBodyProps<T extends RowData> {
10
10
  rowDirection: ROW_DIRECTION;
11
+ /**
12
+ * Optional override for the rows rendered by <TableBody>.
13
+ * - Omit to show the table’s full leaf-level row model.
14
+ * - 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.
15
+ */
16
+ rows?: Row<T>[];
11
17
  tableInstance: Table<T>;
12
18
  tableView?: TableView;
13
19
  }
14
20
 
15
21
  export const TableBody = <T extends RowData>({
16
22
  rowDirection,
23
+ rows,
17
24
  tableInstance,
18
25
  tableView,
19
26
  }: TableBodyProps<T>): JSX.Element => {
20
27
  return (
21
28
  <MTableBody>
22
29
  {rowDirection === ROW_DIRECTION.DEFAULT ? (
23
- <TableRows tableInstance={tableInstance} tableView={tableView} />
30
+ <TableRows
31
+ rows={rows}
32
+ tableInstance={tableInstance}
33
+ tableView={tableView}
34
+ />
24
35
  ) : (
25
- <CollapsableRows tableInstance={tableInstance} />
36
+ <CollapsableRows rows={rows} tableInstance={tableInstance} />
26
37
  )}
27
38
  </MTableBody>
28
39
  );
@@ -1,4 +1,4 @@
1
- import { RowData, Table } from "@tanstack/react-table";
1
+ import { Row, RowData, Table } from "@tanstack/react-table";
2
2
  import React, { Fragment } from "react";
3
3
  import { isCollapsableRowDisabled } from "../../../../../../../Table/common/utils";
4
4
  import { CollapsableCell } from "../../../../../../../Table/components/TableCell/components/CollapsableCell/collapsableCell";
@@ -6,10 +6,17 @@ import { TableRow } from "../../../../../../../Table/components/TableRow/tableRo
6
6
  import { useCollapsableRows } from "../../../../../../../Table/components/TableRows/components/CollapsableRows/hook";
7
7
 
8
8
  export interface CollapsableRowsProps<T extends RowData> {
9
+ /**
10
+ * Optional override for the rows rendered by <CollapsableRows>.
11
+ * - Omit to show the table’s full leaf-level row model.
12
+ * - 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.
13
+ */
14
+ rows?: Row<T>[];
9
15
  tableInstance: Table<T>;
10
16
  }
11
17
 
12
18
  export const CollapsableRows = <T extends RowData>({
19
+ rows: leafOrSubRows,
13
20
  tableInstance,
14
21
  }: CollapsableRowsProps<T>): JSX.Element => {
15
22
  const { getRowModel } = tableInstance;
@@ -17,7 +24,7 @@ export const CollapsableRows = <T extends RowData>({
17
24
  useCollapsableRows(tableInstance);
18
25
  return (
19
26
  <Fragment>
20
- {rows.map((row) => {
27
+ {(leafOrSubRows || rows).map((row) => {
21
28
  if (row.depth > 0) return null; // Hide sub rows.
22
29
  return (
23
30
  <TableRow key={row.id} isPreview={row.getIsPreview()}>
@@ -1,5 +1,5 @@
1
1
  import { TableCell } from "@mui/material";
2
- import { flexRender, RowData, Table } from "@tanstack/react-table";
2
+ import { flexRender, Row, RowData, Table } from "@tanstack/react-table";
3
3
  import React, { Fragment } from "react";
4
4
  import {
5
5
  getTableCellAlign,
@@ -9,11 +9,18 @@ import { TableRow } from "../../../../../Table/components/TableRow/tableRow.styl
9
9
  import { TableView } from "../../table";
10
10
 
11
11
  export interface TableRowsProps<T extends RowData> {
12
+ /**
13
+ * Optional override for the rows rendered by <TableRows>.
14
+ * - Omit to show the table’s full leaf-level row model.
15
+ * - 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.
16
+ */
17
+ rows?: Row<T>[];
12
18
  tableInstance: Table<T>;
13
19
  tableView?: TableView;
14
20
  }
15
21
 
16
22
  export const TableRows = <T extends RowData>({
23
+ rows: leafOrSubRows,
17
24
  tableInstance,
18
25
  tableView,
19
26
  }: TableRowsProps<T>): JSX.Element => {
@@ -23,7 +30,7 @@ export const TableRows = <T extends RowData>({
23
30
  const { size: tableCellSize = "medium" } = tableCell || {};
24
31
  return (
25
32
  <Fragment>
26
- {rows.map((row) => {
33
+ {(leafOrSubRows || rows).map((row) => {
27
34
  return (
28
35
  <TableRow
29
36
  key={row.id}
@@ -1,7 +1,38 @@
1
+ import { css } from "@emotion/react";
1
2
  import styled from "@emotion/styled";
2
- import { List as MList } from "@mui/material";
3
+ import {
4
+ listItemButtonClasses,
5
+ listItemTextClasses,
6
+ List as MList,
7
+ } from "@mui/material";
8
+ import { PALETTE } from "../../../../styles/common/constants/palette";
3
9
  import { LIST_MARGIN } from "../../common/constants";
4
10
 
11
+ export const MuiListItemButtonRoot = css`
12
+ .${listItemButtonClasses.root} {
13
+ gap: 8px;
14
+ padding: 10px 16px;
15
+
16
+ &.Mui-disabled {
17
+ color: ${PALETTE.SMOKE_MAIN};
18
+ opacity: 1;
19
+ }
20
+ }
21
+ `;
22
+
23
+ export const MuiListItemTextRoot = css`
24
+ .${listItemTextClasses.root} {
25
+ align-items: center;
26
+ display: grid;
27
+ gap: 8px;
28
+ grid-template-columns: 1fr auto;
29
+
30
+ > span {
31
+ min-width: 0; /* required; flexbox child min-width property is "auto" by default making overflow-wrap ineffectual */
32
+ }
33
+ }
34
+ `;
35
+
5
36
  export const List = styled(MList)`
6
37
  && {
7
38
  overflow-wrap: break-word;
@@ -20,20 +51,8 @@ export const List = styled(MList)`
20
51
  }
21
52
 
22
53
  // List item
23
- .MuiListItemButton-root {
24
- gap: 8px;
25
- padding: 10px 16px;
26
- }
54
+ ${MuiListItemButtonRoot}
27
55
 
28
56
  // List item text
29
- .MuiListItemText-root {
30
- align-items: center;
31
- display: grid;
32
- gap: 8px;
33
- grid-template-columns: 1fr auto;
34
-
35
- > span {
36
- min-width: 0; /* required; flexbox child min-width property is "auto" by default making overflow-wrap ineffectual */
37
- }
38
- }
57
+ ${MuiListItemTextRoot}
39
58
  `;
@@ -84,6 +84,22 @@ export function buildCategoryViews<T extends RowData>(
84
84
  return categoryViews;
85
85
  }
86
86
 
87
+ /**
88
+ * Returns the header for a column as a string.
89
+ * @param column - Column.
90
+ * @returns column header.
91
+ */
92
+ export function getColumnHeader<T extends RowData>(column: Column<T>): string {
93
+ const { columnDef, id = "" } = column;
94
+ const { header, meta } = columnDef;
95
+
96
+ // Return header if it is a string.
97
+ if (typeof header === "string") return header;
98
+
99
+ // Return header from meta or id.
100
+ return meta?.header || id;
101
+ }
102
+
87
103
  /**
88
104
  * Format data to TSV string.
89
105
  * @param data - Table data.
@@ -0,0 +1,23 @@
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 {
5
+ MuiListItemButtonRoot,
6
+ MuiListItemTextRoot,
7
+ } from "../../../../Filter/components/FilterList/filterList.styles";
8
+
9
+ export const StyledMenu = styled(Menu)`
10
+ .${paperClasses.root} {
11
+ margin: 4px 0;
12
+ width: 288px;
13
+
14
+ .${menuClasses.list} {
15
+ max-height: ${MAX_LIST_HEIGHT_PX}px;
16
+ overflow-wrap: break-word;
17
+
18
+ ${MuiListItemButtonRoot}
19
+
20
+ ${MuiListItemTextRoot}
21
+ }
22
+ }
23
+ `;
@@ -0,0 +1,98 @@
1
+ import {
2
+ Checkbox,
3
+ ListItemButton,
4
+ ListItemText,
5
+ Button as MButton,
6
+ Typography,
7
+ } from "@mui/material";
8
+ import { RowData } from "@tanstack/react-table";
9
+ import React, { Fragment } from "react";
10
+ import { SVG_ICON_PROPS } from "../../../../../styles/common/mui/svgIcon";
11
+ import { TYPOGRAPHY_PROPS } from "../../../../../styles/common/mui/typography";
12
+ import { CheckedIcon } from "../../../../common/CustomIcon/components/CheckedIcon/checkedIcon";
13
+ import { UncheckedIcon } from "../../../../common/CustomIcon/components/UncheckedIcon/uncheckedIcon";
14
+ import { DropDownIcon } from "../../../../common/Form/components/Select/components/DropDownIcon/dropDownIcon";
15
+ import { useMenu } from "../../../../common/Menu/hooks/useMenu";
16
+ import { getColumnHeader } from "../../../common/utils";
17
+ import { getSortedFacetedValues } from "../../../featureOptions/facetedColumn/utils";
18
+ import { StyledMenu } from "./columnFilter.styles";
19
+ import { MENU_PROPS } from "./constants";
20
+ import { ColumnFilterProps } from "./types";
21
+ import { updater } from "./utils";
22
+
23
+ /**
24
+ * Column filter component with supported filter functions:
25
+ * - `arrIncludesSome`
26
+ */
27
+
28
+ export const ColumnFilter = <T extends RowData>({
29
+ Button = MButton,
30
+ className,
31
+ column,
32
+ ...props /* MuiMenuProps */
33
+ }: ColumnFilterProps<T>): JSX.Element => {
34
+ const { anchorEl, onClose, onOpen, open } = useMenu();
35
+ const facetedUniqueValues = column.getFacetedUniqueValues();
36
+ const sortedValues = getSortedFacetedValues(facetedUniqueValues);
37
+ const filterValue = (column.getFilterValue() || []) as unknown[];
38
+ return (
39
+ <Fragment>
40
+ <Button
41
+ key={column.id}
42
+ endIcon={<DropDownIcon color={SVG_ICON_PROPS.COLOR.INK_LIGHT} />}
43
+ onClick={onOpen}
44
+ >
45
+ {getColumnHeader(column)}
46
+ </Button>
47
+ <StyledMenu
48
+ {...MENU_PROPS}
49
+ {...props}
50
+ className={className}
51
+ anchorEl={anchorEl}
52
+ onClose={onClose}
53
+ open={open}
54
+ >
55
+ {sortedValues.map(([value, occurrence]) => (
56
+ <ListItemButton
57
+ key={String(value)}
58
+ selected={filterValue.includes(value)}
59
+ onClick={() => column.setFilterValue(updater(value))}
60
+ >
61
+ <Checkbox
62
+ checked={filterValue.includes(value)}
63
+ checkedIcon={<CheckedIcon />}
64
+ icon={<UncheckedIcon />}
65
+ />
66
+ <ListItemText
67
+ disableTypography
68
+ primary={<span>{String(value)}</span>}
69
+ secondary={
70
+ <Typography
71
+ color={TYPOGRAPHY_PROPS.COLOR.INK_LIGHT}
72
+ variant={TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_SMALL_400}
73
+ >
74
+ {occurrence}
75
+ </Typography>
76
+ }
77
+ />
78
+ </ListItemButton>
79
+ ))}
80
+ <ListItemButton
81
+ disabled={!column.getIsFiltered()}
82
+ onClick={() => column.setFilterValue(undefined)}
83
+ >
84
+ <Typography
85
+ color={
86
+ column.getIsFiltered()
87
+ ? TYPOGRAPHY_PROPS.COLOR.PRIMARY
88
+ : TYPOGRAPHY_PROPS.COLOR.INHERIT
89
+ }
90
+ variant={TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_500}
91
+ >
92
+ Clear All
93
+ </Typography>
94
+ </ListItemButton>
95
+ </StyledMenu>
96
+ </Fragment>
97
+ );
98
+ };
@@ -0,0 +1,16 @@
1
+ import { MenuProps } from "@mui/material";
2
+
3
+ export const MENU_PROPS: Omit<MenuProps, "anchorEl" | "onClose" | "open"> = {
4
+ anchorOrigin: {
5
+ horizontal: "right",
6
+ vertical: "bottom",
7
+ },
8
+ marginThreshold: 8,
9
+ slotProps: {
10
+ paper: { variant: "menu" },
11
+ },
12
+ transformOrigin: {
13
+ horizontal: "right",
14
+ vertical: "top",
15
+ },
16
+ };