@databiosphere/findable-ui 4.0.0 → 6.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 (184) hide show
  1. package/README.md +5 -1
  2. package/lib/components/ComponentCreator/ComponentCreator.d.ts +4 -2
  3. package/lib/components/ComponentCreator/ComponentCreator.js +6 -8
  4. package/lib/components/Detail/components/DetailViewTable/detailViewTable.d.ts +3 -3
  5. package/lib/components/Detail/components/DetailViewTable/detailViewTable.js +1 -1
  6. package/lib/components/Detail/components/Table/common/utils.d.ts +2 -2
  7. package/lib/components/Detail/components/Table/components/TableBody/tableBody.d.ts +3 -3
  8. package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.d.ts +3 -3
  9. package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +2 -4
  10. package/lib/components/Detail/components/Table/components/TableRows/tableRows.d.ts +2 -2
  11. package/lib/components/Detail/components/Table/components/TableRows/tableRows.js +2 -1
  12. package/lib/components/Detail/components/Table/table.d.ts +3 -4
  13. package/lib/components/Detail/components/Table/table.js +2 -1
  14. package/lib/components/Filter/components/Filters/filters.d.ts +1 -1
  15. package/lib/components/Index/components/Cell/cell.d.ts +3 -0
  16. package/lib/components/Index/components/Cell/cell.js +3 -0
  17. package/lib/components/Index/components/NTag/components/Tooltip/tooltip.d.ts +3 -0
  18. package/lib/components/Index/components/NTag/components/Tooltip/tooltip.js +3 -0
  19. package/lib/components/Index/components/NTag/nTag.d.ts +3 -0
  20. package/lib/components/Index/components/NTag/nTag.js +3 -0
  21. package/lib/components/Index/components/NTagCell/nTagCell.d.ts +6 -1
  22. package/lib/components/Index/components/NTagCell/nTagCell.js +6 -2
  23. package/lib/components/Layout/components/Outline/common/constants.d.ts +1 -1
  24. package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.d.ts +1 -1
  25. package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +13 -1
  26. package/lib/components/Links/components/Link/link.d.ts +3 -1
  27. package/lib/components/Links/components/Link/link.js +4 -4
  28. package/lib/components/Table/common/gridTable.styles.js +8 -2
  29. package/lib/components/Table/common/utils.d.ts +19 -14
  30. package/lib/components/Table/common/utils.js +26 -11
  31. package/lib/components/Table/components/DownloadEntityResults/downloadEntityResults.d.ts +3 -3
  32. package/lib/components/Table/components/PaginationSummary/paginationSummary.js +9 -8
  33. package/lib/components/Table/components/TableBody/tableBody.d.ts +3 -3
  34. package/lib/components/Table/components/TableCell/common/utils.d.ts +3 -3
  35. package/lib/components/Table/components/TableCell/components/BasicCell/basicCell.d.ts +7 -0
  36. package/lib/components/Table/components/TableCell/components/BasicCell/basicCell.js +55 -0
  37. package/lib/components/Table/components/TableCell/components/NTagCell/components/NTag/components/Tooltip/tooltip.d.ts +6 -0
  38. package/lib/components/Table/components/TableCell/components/NTagCell/components/NTag/components/Tooltip/tooltip.js +93 -0
  39. package/lib/components/Table/components/TableCell/components/NTagCell/components/NTag/components/Tooltip/tooltip.styles.d.ts +5 -0
  40. package/lib/components/Table/components/TableCell/components/NTagCell/components/NTag/components/Tooltip/tooltip.styles.js +16 -0
  41. package/lib/components/Table/components/TableCell/components/NTagCell/components/NTag/nTag.d.ts +7 -0
  42. package/lib/components/Table/components/TableCell/components/NTagCell/components/NTag/nTag.js +24 -0
  43. package/lib/components/Table/components/TableCell/components/NTagCell/nTagCell.d.ts +9 -0
  44. package/lib/components/Table/components/TableCell/components/NTagCell/nTagCell.js +53 -0
  45. package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.d.ts +2 -2
  46. package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.d.ts +2 -2
  47. package/lib/components/Table/components/TableHead/tableHead.d.ts +3 -3
  48. package/lib/components/Table/components/TableRow/tableRow.styles.d.ts +16 -0
  49. package/lib/components/Table/components/TableRow/tableRow.styles.js +22 -0
  50. package/lib/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.d.ts +3 -3
  51. package/lib/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +3 -2
  52. package/lib/components/Table/components/TableRows/tableRows.d.ts +3 -3
  53. package/lib/components/Table/components/TableRows/tableRows.js +3 -1
  54. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/common/constants.d.ts +2 -0
  55. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/common/constants.js +12 -0
  56. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/rowDrawer.d.ts +9 -0
  57. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/rowDrawer.js +32 -0
  58. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/rowDrawer.styles.d.ts +6 -0
  59. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/rowDrawer.styles.js +35 -0
  60. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/Section/components/RowDetail/rowDetail.d.ts +12 -0
  61. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/Section/components/RowDetail/rowDetail.js +32 -0
  62. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/Section/components/RowDetail/rowDetail.styles.d.ts +5 -0
  63. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/Section/components/RowDetail/rowDetail.styles.js +50 -0
  64. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/Section/section.d.ts +7 -0
  65. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/Section/section.js +16 -0
  66. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/Section/section.styles.d.ts +5 -0
  67. package/lib/components/Table/components/TableToolbar/components/RowPreview/components/Section/section.styles.js +17 -0
  68. package/lib/components/Table/components/TableToolbar/components/RowPreview/rowPreview.d.ts +8 -0
  69. package/lib/components/Table/components/TableToolbar/components/RowPreview/rowPreview.js +14 -0
  70. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.d.ts +3 -3
  71. package/lib/components/Table/components/TableToolbar/tableToolbar.d.ts +3 -3
  72. package/lib/components/Table/components/TableToolbar/tableToolbar.js +9 -6
  73. package/lib/components/Table/features/RowPreview/constants.d.ts +2 -0
  74. package/lib/components/Table/features/RowPreview/constants.js +45 -0
  75. package/lib/components/Table/features/RowPreview/entities.d.ts +22 -0
  76. package/lib/components/Table/features/RowPreview/entities.js +2 -0
  77. package/lib/components/Table/features/RowPreview/utils.d.ts +33 -0
  78. package/lib/components/Table/features/RowPreview/utils.js +89 -0
  79. package/lib/components/Table/features/entities.d.ts +7 -0
  80. package/lib/components/Table/features/entities.js +2 -0
  81. package/lib/components/Table/table.d.ts +4 -12
  82. package/lib/components/Table/table.js +27 -39
  83. package/lib/components/TableCreator/common/entities.d.ts +1 -1
  84. package/lib/components/TableCreator/tableCreator.d.ts +2 -9
  85. package/lib/components/TableCreator/tableCreator.js +4 -4
  86. package/lib/components/common/Button/button.d.ts +1 -1
  87. package/lib/components/common/Drawer/components/DrawerTitle/drawerTitle.d.ts +7 -0
  88. package/lib/components/common/Drawer/components/DrawerTitle/drawerTitle.js +17 -0
  89. package/lib/components/common/Drawer/components/DrawerTitle/drawerTitle.styles.d.ts +5 -0
  90. package/lib/components/common/Drawer/components/DrawerTitle/drawerTitle.styles.js +17 -0
  91. package/lib/components/common/Drawer/components/drawer.styles.d.ts +5 -0
  92. package/lib/components/common/Drawer/components/drawer.styles.js +11 -0
  93. package/lib/components/common/Drawer/drawer.d.ts +7 -0
  94. package/lib/components/common/Drawer/drawer.js +24 -0
  95. package/lib/components/common/Grid/grid.d.ts +1 -1
  96. package/lib/components/common/Typography/common/entities.d.ts +2 -0
  97. package/lib/components/common/Typography/common/entities.js +2 -0
  98. package/lib/config/entities.d.ts +8 -26
  99. package/lib/providers/exploreState/entities.d.ts +3 -2
  100. package/lib/providers/exploreState/initializer/constants.js +1 -3
  101. package/lib/providers/exploreState/initializer/utils.js +2 -2
  102. package/lib/providers/exploreState/payloads/entities.d.ts +7 -11
  103. package/lib/providers/exploreState/utils.d.ts +12 -10
  104. package/lib/providers/exploreState/utils.js +20 -24
  105. package/lib/providers/exploreState.d.ts +12 -32
  106. package/lib/providers/exploreState.js +48 -36
  107. package/lib/styles/common/mixins/colors.d.ts +2 -1
  108. package/lib/styles/common/mixins/colors.js +3 -1
  109. package/lib/theme/common/components.js +11 -2
  110. package/lib/theme/common/palette.d.ts +3 -1
  111. package/lib/theme/common/palette.js +4 -1
  112. package/lib/views/ExploreView/exploreView.js +4 -6
  113. package/package.json +2 -2
  114. package/src/components/ComponentCreator/ComponentCreator.tsx +6 -1
  115. package/src/components/Detail/components/DetailViewTable/detailViewTable.tsx +4 -4
  116. package/src/components/Detail/components/Table/common/utils.ts +2 -2
  117. package/src/components/Detail/components/Table/components/TableBody/tableBody.tsx +3 -3
  118. package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +5 -7
  119. package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +10 -6
  120. package/src/components/Detail/components/Table/table.tsx +6 -3
  121. package/src/components/Filter/components/Filters/filters.tsx +1 -1
  122. package/src/components/Index/components/Cell/cell.tsx +4 -0
  123. package/src/components/Index/components/NTag/components/Tooltip/tooltip.tsx +4 -0
  124. package/src/components/Index/components/NTag/nTag.tsx +4 -0
  125. package/src/components/Index/components/NTagCell/nTagCell.tsx +22 -3
  126. package/src/components/Layout/components/Outline/common/constants.ts +1 -1
  127. package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +18 -2
  128. package/src/components/Links/components/Link/link.tsx +15 -2
  129. package/src/components/Table/common/gridTable.styles.ts +8 -2
  130. package/src/components/Table/common/utils.ts +55 -24
  131. package/src/components/Table/components/DownloadEntityResults/downloadEntityResults.tsx +3 -3
  132. package/src/components/Table/components/PaginationSummary/paginationSummary.tsx +11 -9
  133. package/src/components/Table/components/TableBody/tableBody.tsx +3 -3
  134. package/src/components/Table/components/TableCell/common/utils.ts +3 -3
  135. package/src/components/Table/components/TableCell/components/BasicCell/basicCell.tsx +52 -0
  136. package/src/components/Table/components/TableCell/components/NTagCell/components/NTag/components/Tooltip/tooltip.styles.ts +11 -0
  137. package/src/components/Table/components/TableCell/components/NTagCell/components/NTag/components/Tooltip/tooltip.tsx +86 -0
  138. package/src/components/Table/components/TableCell/components/NTagCell/components/NTag/nTag.tsx +21 -0
  139. package/src/components/Table/components/TableCell/components/NTagCell/nTagCell.tsx +70 -0
  140. package/src/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.tsx +2 -3
  141. package/src/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.tsx +2 -3
  142. package/src/components/Table/components/TableHead/tableHead.tsx +3 -3
  143. package/src/components/Table/components/TableRow/tableRow.styles.ts +22 -0
  144. package/src/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +8 -6
  145. package/src/components/Table/components/TableRows/tableRows.tsx +9 -6
  146. package/src/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/common/constants.ts +11 -0
  147. package/src/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/rowDrawer.styles.ts +31 -0
  148. package/src/components/Table/components/TableToolbar/components/RowPreview/components/RowDrawer/rowDrawer.tsx +52 -0
  149. package/src/components/Table/components/TableToolbar/components/RowPreview/components/Section/components/RowDetail/rowDetail.styles.ts +48 -0
  150. package/src/components/Table/components/TableToolbar/components/RowPreview/components/Section/components/RowDetail/rowDetail.tsx +53 -0
  151. package/src/components/Table/components/TableToolbar/components/RowPreview/components/Section/section.styles.ts +12 -0
  152. package/src/components/Table/components/TableToolbar/components/RowPreview/components/Section/section.tsx +25 -0
  153. package/src/components/Table/components/TableToolbar/components/RowPreview/rowPreview.tsx +19 -0
  154. package/src/components/Table/components/TableToolbar/components/RowSelection/rowSelection.tsx +3 -3
  155. package/src/components/Table/components/TableToolbar/tableToolbar.tsx +9 -4
  156. package/src/components/Table/features/RowPreview/constants.ts +65 -0
  157. package/src/components/Table/features/RowPreview/entities.ts +25 -0
  158. package/src/components/Table/features/RowPreview/utils.ts +93 -0
  159. package/src/components/Table/features/entities.ts +13 -0
  160. package/src/components/Table/table.tsx +41 -51
  161. package/src/components/TableCreator/common/entities.ts +1 -1
  162. package/src/components/TableCreator/tableCreator.tsx +15 -22
  163. package/src/components/common/Button/button.tsx +1 -2
  164. package/src/components/common/Drawer/components/DrawerTitle/drawerTitle.styles.ts +12 -0
  165. package/src/components/common/Drawer/components/DrawerTitle/drawerTitle.tsx +27 -0
  166. package/src/components/common/Drawer/components/drawer.styles.ts +6 -0
  167. package/src/components/common/Drawer/drawer.tsx +21 -0
  168. package/src/components/common/Grid/grid.tsx +1 -3
  169. package/src/components/common/Section/components/CollapsableSection/collapsableSection.tsx +1 -2
  170. package/src/components/common/Typography/common/entities.ts +5 -0
  171. package/src/config/entities.ts +8 -38
  172. package/src/providers/exploreState/entities.ts +7 -2
  173. package/src/providers/exploreState/initializer/constants.ts +1 -3
  174. package/src/providers/exploreState/initializer/utils.ts +3 -3
  175. package/src/providers/exploreState/payloads/entities.ts +8 -18
  176. package/src/providers/exploreState/utils.ts +25 -36
  177. package/src/providers/exploreState.tsx +95 -69
  178. package/src/styles/common/mixins/colors.ts +4 -1
  179. package/src/theme/common/components.ts +12 -0
  180. package/src/theme/common/palette.ts +4 -5
  181. package/src/theme/theme.ts +1 -2
  182. package/src/views/ExploreView/exploreView.tsx +3 -25
  183. package/types/data-explorer-ui.d.ts +21 -2
  184. package/src/hooks/useEntityListRelatedView.ts +0 -78
@@ -0,0 +1,25 @@
1
+ import { Typography } from "@mui/material";
2
+ import React, { ReactNode } from "react";
3
+ import { TEXT_HEADING_SMALL } from "../../../../../../../../theme/common/typography";
4
+ import { Section as PreviewSection } from "./section.styles";
5
+
6
+ export interface SectionProps {
7
+ children?: ReactNode | ReactNode[];
8
+ className?: string;
9
+ title?: ReactNode;
10
+ }
11
+
12
+ export const Section = ({
13
+ children,
14
+ className,
15
+ title,
16
+ }: SectionProps): JSX.Element => {
17
+ return (
18
+ <PreviewSection className={className}>
19
+ <Typography component="div" variant={TEXT_HEADING_SMALL}>
20
+ {title}
21
+ </Typography>
22
+ {children}
23
+ </PreviewSection>
24
+ );
25
+ };
@@ -0,0 +1,19 @@
1
+ import { RowData, Table } from "@tanstack/react-table";
2
+ import React from "react";
3
+ import { ComponentsConfig } from "../../../../../../config/entities";
4
+ import { ComponentCreator } from "../../../../../ComponentCreator/ComponentCreator";
5
+
6
+ export interface RowPreviewProps<T extends RowData> {
7
+ rowPreviewView?: ComponentsConfig;
8
+ tableInstance: Table<T>;
9
+ }
10
+
11
+ export const RowPreview = <T extends RowData>({
12
+ rowPreviewView,
13
+ tableInstance,
14
+ }: RowPreviewProps<T>): JSX.Element | null => {
15
+ if (!rowPreviewView) return null;
16
+ return (
17
+ <ComponentCreator components={rowPreviewView} response={tableInstance} />
18
+ );
19
+ };
@@ -1,18 +1,18 @@
1
1
  import { Typography } from "@mui/material";
2
- import { Row } from "@tanstack/react-table";
2
+ import { Row, RowData } from "@tanstack/react-table";
3
3
  import React from "react";
4
4
  import { ComponentsConfig } from "../../../../../../config/entities";
5
5
  import { TEXT_BODY_400 } from "../../../../../../theme/common/typography";
6
6
  import { ComponentCreator } from "../../../../../ComponentCreator/ComponentCreator";
7
7
  import { RowSelection as RowSelectionActions } from "./rowSelection.styles";
8
8
 
9
- export interface RowSelectionProps<T> {
9
+ export interface RowSelectionProps<T extends RowData> {
10
10
  className?: string;
11
11
  rows: Row<T>[];
12
12
  rowSelectionView?: ComponentsConfig;
13
13
  }
14
14
 
15
- export const RowSelection = <T extends object>({
15
+ export const RowSelection = <T extends RowData>({
16
16
  className,
17
17
  rows,
18
18
  rowSelectionView,
@@ -1,4 +1,4 @@
1
- import { Table } from "@tanstack/react-table";
1
+ import { RowData, Table } from "@tanstack/react-table";
2
2
  import React, { Fragment } from "react";
3
3
  import { ListViewConfig } from "../../../../config/entities";
4
4
  import { useExploreState } from "../../../../hooks/useExploreState";
@@ -7,16 +7,17 @@ import { getEditColumnOptions, isAnyRowSelected } from "../../common/utils";
7
7
  import { CheckboxMenu } from "../CheckboxMenu/checkboxMenu";
8
8
  import { DownloadEntityResults } from "../DownloadEntityResults/downloadEntityResults";
9
9
  import { PaginationSummary } from "../PaginationSummary/paginationSummary";
10
+ import { RowPreview } from "./components/RowPreview/rowPreview";
10
11
  import { RowSelection } from "./components/RowSelection/rowSelection";
11
12
  import { Toolbar, ToolbarActions } from "./tableToolbar.styles";
12
13
 
13
- export interface TableToolbarProps<T> {
14
+ export interface TableToolbarProps<T extends RowData> {
14
15
  listView?: ListViewConfig;
15
16
  rowDirection: ROW_DIRECTION;
16
17
  tableInstance: Table<T>;
17
18
  }
18
19
 
19
- export const TableToolbar = <T extends object>({
20
+ export const TableToolbar = <T extends RowData>({
20
21
  listView,
21
22
  rowDirection,
22
23
  tableInstance,
@@ -25,7 +26,7 @@ export const TableToolbar = <T extends object>({
25
26
  const { paginationState } = exploreState;
26
27
  const { currentPage, pages, pageSize, rows } = paginationState;
27
28
  const { getSelectedRowModel, resetColumnVisibility } = tableInstance;
28
- const { enableDownload } = listView || {};
29
+ const { enableDownload, rowPreviewView } = listView || {};
29
30
  const isLastPage = currentPage === pages;
30
31
  const editColumnOptions = getEditColumnOptions(tableInstance);
31
32
  const showToolbar =
@@ -70,6 +71,10 @@ export const TableToolbar = <T extends object>({
70
71
  </ToolbarActions>
71
72
  </Toolbar>
72
73
  )}
74
+ <RowPreview
75
+ rowPreviewView={rowPreviewView}
76
+ tableInstance={tableInstance}
77
+ />
73
78
  </Fragment>
74
79
  );
75
80
  };
@@ -0,0 +1,65 @@
1
+ import {
2
+ functionalUpdate,
3
+ InitialTableState,
4
+ makeStateUpdater,
5
+ Row,
6
+ RowData,
7
+ Table,
8
+ TableFeature,
9
+ TableOptionsResolved,
10
+ TableState,
11
+ Updater,
12
+ } from "@tanstack/react-table";
13
+ import { RowPreviewState } from "./entities";
14
+ import {
15
+ getIsPreview,
16
+ getIsRowPreview,
17
+ getRowPreviewRow,
18
+ togglePreview,
19
+ toggleRowPreview,
20
+ } from "./utils";
21
+
22
+ export const ROW_PREVIEW: TableFeature = {
23
+ createRow: <T extends RowData>(row: Row<T>, table: Table<T>): void => {
24
+ row.getIsPreview = (): boolean => {
25
+ return getIsPreview(row, table);
26
+ };
27
+ row.togglePreview = (): void => {
28
+ togglePreview(row, table);
29
+ };
30
+ },
31
+ createTable: <T extends RowData>(table: Table<T>): void => {
32
+ table.getIsRowPreview = (): boolean => {
33
+ return getIsRowPreview(table);
34
+ };
35
+ table.getRowPreviewRow = (): Row<T> | undefined => {
36
+ return getRowPreviewRow(table);
37
+ };
38
+ table.resetRowPreview = (): void => {
39
+ table.setRowPreview(undefined);
40
+ };
41
+ table.setRowPreview = (updater: Updater<RowPreviewState>): void => {
42
+ const safeUpdater: Updater<RowPreviewState> = (old: RowPreviewState) => {
43
+ return functionalUpdate(updater, old);
44
+ };
45
+ return table.options.onRowPreviewChange?.(safeUpdater);
46
+ };
47
+ table.toggleRowPreview = (): void => {
48
+ toggleRowPreview(table);
49
+ };
50
+ },
51
+ getDefaultOptions: <T extends RowData>(
52
+ table: Table<T>
53
+ ): Partial<TableOptionsResolved<T>> => {
54
+ return {
55
+ enableRowPreview: true,
56
+ onRowPreviewChange: makeStateUpdater("rowPreview", table),
57
+ };
58
+ },
59
+ getInitialState: (initialState?: InitialTableState): Partial<TableState> => {
60
+ return {
61
+ ...initialState,
62
+ rowPreview: undefined,
63
+ } as Partial<TableState>;
64
+ },
65
+ };
@@ -0,0 +1,25 @@
1
+ import { OnChangeFn, Row, RowData, Updater } from "@tanstack/react-table";
2
+
3
+ export interface RowPreviewInstance<T extends RowData> {
4
+ getIsRowPreview: () => boolean /* Is row preview open */;
5
+ getRowPreviewRow: () => Row<T> | undefined;
6
+ resetRowPreview: () => void;
7
+ setRowPreview: (updater: Updater<RowPreviewState>) => void;
8
+ toggleRowPreview: () => void;
9
+ }
10
+
11
+ export interface RowPreviewOptions {
12
+ enableRowPreview?: boolean;
13
+ onRowPreviewChange?: OnChangeFn<RowPreviewState>;
14
+ }
15
+
16
+ export interface RowPreviewRow {
17
+ getIsPreview: () => boolean /* Is row previewed */;
18
+ togglePreview: () => void;
19
+ }
20
+
21
+ export type RowPreviewState = { [id: string]: boolean } | undefined;
22
+
23
+ export interface RowPreviewTableState {
24
+ rowPreview: RowPreviewState;
25
+ }
@@ -0,0 +1,93 @@
1
+ import { Row, RowData, Table } from "@tanstack/react-table";
2
+
3
+ /**
4
+ * Returns true if the row is selected for preview.
5
+ * @param row - Row.
6
+ * @param table - Table.
7
+ * @returns true if the row is selected for preview.
8
+ */
9
+ export function getIsPreview<T extends RowData>(
10
+ row: Row<T>,
11
+ table: Table<T>
12
+ ): boolean {
13
+ const keyValue = getRowPreviewKeyValue(table);
14
+ if (!keyValue) return false;
15
+ const [key, value] = keyValue;
16
+ if (!value) return false;
17
+ return key === row.id;
18
+ }
19
+
20
+ /**
21
+ * Returns true if any row is selected for preview.
22
+ * @param table - Table.
23
+ * @returns true if any row is selected for preview.
24
+ */
25
+ export function getIsRowPreview<T extends RowData>(table: Table<T>): boolean {
26
+ const keyValue = getRowPreviewKeyValue(table);
27
+ if (!keyValue) return false;
28
+ const [, value] = keyValue;
29
+ return value;
30
+ }
31
+
32
+ /**
33
+ * Returns row selected for preview. Row data is returned even if the row is no longer "previewed" i.e. selected for preview.
34
+ * @param table - Table.
35
+ * @returns row selected for preview.
36
+ */
37
+ export function getRowPreviewRow<T extends RowData>(
38
+ table: Table<T>
39
+ ): Row<T> | undefined {
40
+ const keyValue = getRowPreviewKeyValue(table);
41
+ if (!keyValue) return;
42
+ const [key] = keyValue;
43
+ // We return the original row data, even if the row is no longer "previewed" i.e. selected for preview.
44
+ // This is to ensure any drawer or modal that is still open can display the row data, until the modal or drawer is closed.
45
+ const rowsById = table.getRowModel().rowsById;
46
+ return rowsById[key];
47
+ }
48
+
49
+ /**
50
+ * Returns the key, value tuple of the row selected for preview.
51
+ * @param table - Table.
52
+ * @returns row preview key, value tuple.
53
+ */
54
+ function getRowPreviewKeyValue<T extends RowData>(
55
+ table: Table<T>
56
+ ): [string, boolean] | undefined {
57
+ const { getState } = table;
58
+ const { rowPreview } = getState();
59
+ if (!rowPreview) return;
60
+ const [[key, value]] = Object.entries(rowPreview);
61
+ return [key, value];
62
+ }
63
+
64
+ /**
65
+ * Toggles the preview state of the row.
66
+ * If the row is already selected for preview, the preview state is toggled off.
67
+ * If the row is not selected for preview, the preview state is updated.
68
+ * @param row - Row.
69
+ * @param table - Table.
70
+ */
71
+ export function togglePreview<T extends RowData>(
72
+ row: Row<T>,
73
+ table: Table<T>
74
+ ): void {
75
+ if (row.getIsPreview()) {
76
+ table.toggleRowPreview();
77
+ return;
78
+ }
79
+ table.setRowPreview({ [row.id]: true });
80
+ }
81
+
82
+ /**
83
+ * Toggles the preview state of any row selected for preview.
84
+ * @param table - Table.
85
+ */
86
+ export function toggleRowPreview<T extends RowData>(table: Table<T>): void {
87
+ const keyValue = getRowPreviewKeyValue(table);
88
+ if (!keyValue) {
89
+ return;
90
+ }
91
+ const [key, value] = keyValue;
92
+ table.setRowPreview({ [key]: !value });
93
+ }
@@ -0,0 +1,13 @@
1
+ import { RowData } from "@tanstack/react-table";
2
+ import {
3
+ RowPreviewInstance,
4
+ RowPreviewOptions,
5
+ RowPreviewRow,
6
+ RowPreviewTableState,
7
+ } from "./RowPreview/entities";
8
+
9
+ export type CustomFeatureInitialTableState = Partial<RowPreviewTableState>;
10
+ export type CustomFeatureInstance<T extends RowData> = RowPreviewInstance<T>;
11
+ export type CustomFeatureOptions = RowPreviewOptions;
12
+ export type CustomFeatureRow = RowPreviewRow;
13
+ export type CustomFeatureTableState = RowPreviewTableState;
@@ -2,20 +2,21 @@ import { TableContainer } from "@mui/material";
2
2
  import {
3
3
  ColumnDef,
4
4
  ColumnSort,
5
+ CoreOptions,
5
6
  getCoreRowModel,
6
7
  getFacetedRowModel,
7
8
  getFilteredRowModel,
8
9
  getPaginationRowModel,
9
10
  getSortedRowModel,
10
11
  InitialTableState,
12
+ RowData,
11
13
  RowSelectionState,
12
14
  TableState,
13
15
  Updater,
14
16
  useReactTable,
15
17
  VisibilityState,
16
18
  } from "@tanstack/react-table";
17
- import { CoreOptions } from "@tanstack/table-core";
18
- import React, { useEffect } from "react";
19
+ import React, { useEffect, useMemo } from "react";
19
20
  import { track } from "../../common/analytics/analytics";
20
21
  import {
21
22
  EVENT_NAME,
@@ -23,7 +24,6 @@ import {
23
24
  PAGINATION_DIRECTION,
24
25
  SORT_DIRECTION,
25
26
  } from "../../common/analytics/entities";
26
- import { Pagination } from "../../common/entities";
27
27
  import { ListViewConfig } from "../../config/entities";
28
28
  import {
29
29
  BREAKPOINT_FN_NAME,
@@ -32,7 +32,7 @@ import {
32
32
  import { useExploreMode } from "../../hooks/useExploreMode";
33
33
  import { useExploreState } from "../../hooks/useExploreState";
34
34
  import { useScroll } from "../../hooks/useScroll";
35
- import { ENTITY_VIEW, ExploreActionKind } from "../../providers/exploreState";
35
+ import { ExploreActionKind } from "../../providers/exploreState";
36
36
  import { DEFAULT_PAGINATION_STATE } from "../../providers/exploreState/initializer/constants";
37
37
  import { TABLET } from "../../theme/common/breakpoints";
38
38
  import { FluidPaper, GridPaper } from "../common/Paper/paper.styles";
@@ -42,26 +42,24 @@ import {
42
42
  buildCategoryViews,
43
43
  getFacetedUniqueValuesWithArrayValues,
44
44
  getGridTemplateColumns,
45
+ getTableStatePagination,
45
46
  isClientFilteringEnabled,
46
47
  } from "./common/utils";
47
48
  import { Pagination as DXPagination } from "./components/Pagination/pagination";
48
49
  import { TableBody } from "./components/TableBody/tableBody";
49
50
  import { TableHead } from "./components/TableHead/tableHead";
50
51
  import { TableToolbar } from "./components/TableToolbar/tableToolbar";
52
+ import { ROW_PREVIEW } from "./features/RowPreview/constants";
53
+ import { RowPreviewState } from "./features/RowPreview/entities";
51
54
  import { GridTable } from "./table.styles";
52
55
 
53
- export interface TableProps<T extends object> {
56
+ export interface TableProps<T extends RowData> {
54
57
  columns: ColumnDef<T>[];
55
- count?: number;
56
58
  getRowId?: CoreOptions<T>["getRowId"];
57
59
  initialState: InitialTableState;
58
60
  items: T[];
59
61
  listView?: ListViewConfig;
60
62
  loading?: boolean;
61
- pages?: number;
62
- pageSize: number;
63
- pagination?: Pagination;
64
- total?: number;
65
63
  }
66
64
 
67
65
  /**
@@ -74,16 +72,14 @@ export interface TableProps<T extends object> {
74
72
  * @param tableProps.initialState - Initial table state.
75
73
  * @param tableProps.items - Row data to display.
76
74
  * @param tableProps.listView - List view configuration.
77
- * @param tableProps.total - Total number of rows in the result set.
78
75
  * @returns Configured table element for display.
79
76
  */
80
- export const TableComponent = <T extends object>({
77
+ export const TableComponent = <T extends RowData>({
81
78
  columns,
82
79
  getRowId,
83
80
  initialState,
84
81
  items,
85
82
  listView,
86
- total,
87
83
  }: // eslint-disable-next-line sonarjs/cognitive-complexity -- TODO fix component length / complexity
88
84
  TableProps<T>): JSX.Element => {
89
85
  const tabletDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, TABLET);
@@ -92,20 +88,25 @@ TableProps<T>): JSX.Element => {
92
88
  const {
93
89
  entityPageState,
94
90
  filterState,
95
- isRelatedView,
96
91
  listItems,
97
92
  loading,
98
93
  paginationState,
94
+ rowPreview,
99
95
  tabValue,
100
96
  } = exploreState;
101
97
  const { columnsVisibility, enableRowSelection, rowSelection, sorting } =
102
98
  entityPageState[tabValue];
103
- const { currentPage, pages, pageSize } = paginationState;
104
- const { disablePagination = false } = listView || {};
99
+ const { currentPage, pages, pageSize, rows: pageCount } = paginationState;
100
+ const { disablePagination = false, enableRowPreview = false } =
101
+ listView || {};
105
102
  const clientFiltering = isClientFilteringEnabled(exploreMode);
106
103
  const rowDirection = tabletDown
107
104
  ? ROW_DIRECTION.VERTICAL
108
105
  : ROW_DIRECTION.DEFAULT;
106
+ const pagination = useMemo(
107
+ () => getTableStatePagination(currentPage - 1, pageSize),
108
+ [currentPage, pageSize]
109
+ );
109
110
 
110
111
  const onSortingChange = (updater: Updater<ColumnSort[]>): void => {
111
112
  exploreDispatch({
@@ -132,6 +133,13 @@ TableProps<T>): JSX.Element => {
132
133
  });
133
134
  };
134
135
 
136
+ const onRowPreviewChange = (updater: Updater<RowPreviewState>): void => {
137
+ exploreDispatch({
138
+ payload: typeof updater === "function" ? updater(rowPreview) : updater,
139
+ type: ExploreActionKind.UpdateRowPreview,
140
+ });
141
+ };
142
+
135
143
  const onRowSelectionChange = (updater: Updater<RowSelectionState>): void => {
136
144
  exploreDispatch({
137
145
  payload: typeof updater === "function" ? updater(rowSelection) : updater,
@@ -141,19 +149,19 @@ TableProps<T>): JSX.Element => {
141
149
 
142
150
  const state: Partial<TableState> = {
143
151
  columnVisibility: columnsVisibility,
144
- pagination: {
145
- pageIndex: 0,
146
- pageSize: disablePagination ? Number.MAX_SAFE_INTEGER : pageSize,
147
- },
152
+ pagination,
153
+ rowPreview,
148
154
  rowSelection,
149
155
  sorting,
150
156
  };
151
157
  const tableInstance = useReactTable({
158
+ _features: [ROW_PREVIEW],
152
159
  columns,
153
160
  data: items,
154
161
  enableColumnFilters: true, // client-side filtering.
155
162
  enableFilters: true, // client-side filtering.
156
- enableMultiSort: false,
163
+ enableMultiSort: clientFiltering,
164
+ enableRowPreview,
157
165
  enableRowSelection,
158
166
  enableSorting: true, // client-side filtering.
159
167
  enableSortingRemoval: false, // client-side filtering.
@@ -167,12 +175,13 @@ TableProps<T>): JSX.Element => {
167
175
  getRowId,
168
176
  getSortedRowModel: clientFiltering ? getSortedRowModel() : undefined,
169
177
  initialState,
170
- manualPagination: clientFiltering,
178
+ manualPagination: true,
171
179
  manualSorting: !clientFiltering,
172
180
  onColumnVisibilityChange,
181
+ onRowPreviewChange,
173
182
  onRowSelectionChange,
174
183
  onSortingChange,
175
- pageCount: total,
184
+ pageCount,
176
185
  state,
177
186
  });
178
187
  const {
@@ -206,7 +215,6 @@ TableProps<T>): JSX.Element => {
206
215
  [EVENT_PARAM.PAGINATION_DIRECTION]: PAGINATION_DIRECTION.NEXT,
207
216
  });
208
217
  }
209
- // const nextPage = pagination?.nextPage ?? tableNextPage;
210
218
  nextPage();
211
219
  scrollTop();
212
220
  };
@@ -229,27 +237,20 @@ TableProps<T>): JSX.Element => {
229
237
  scrollTop();
230
238
  };
231
239
 
232
- // Sets or resets react table column filters `columnFilters` state - for client-side filtering only - with update of filterState.
233
- // - `columnFilters` state is "cleared" for related view, and
234
- // - `columnFilters` state is "set" for all other views.
240
+ // Sets react table column filters `columnFilters` state - for client-side filtering only - with update of filterState.
235
241
  useEffect(() => {
236
242
  if (clientFiltering) {
237
- if (isRelatedView) {
238
- tableInstance.resetColumnFilters();
239
- } else {
240
- tableInstance.setColumnFilters(
241
- filterState.map(({ categoryKey, value }) => ({
242
- id: categoryKey,
243
- value,
244
- }))
245
- );
246
- }
243
+ tableInstance.setColumnFilters(
244
+ filterState.map(({ categoryKey, value }) => ({
245
+ id: categoryKey,
246
+ value,
247
+ }))
248
+ );
247
249
  }
248
- }, [clientFiltering, filterState, isRelatedView, tableInstance]);
250
+ }, [clientFiltering, filterState, tableInstance]);
249
251
 
250
252
  // Process explore response - client-side filtering only.
251
253
  useEffect(() => {
252
- if (isRelatedView) return;
253
254
  if (!listItems || listItems.length === 0) return;
254
255
  if (clientFiltering) {
255
256
  exploreDispatch({
@@ -271,21 +272,10 @@ TableProps<T>): JSX.Element => {
271
272
  clientFiltering,
272
273
  columnFilters,
273
274
  exploreDispatch,
274
- isRelatedView,
275
275
  listItems,
276
276
  results,
277
277
  ]);
278
278
 
279
- // Unmount - reset entity view to "exact".
280
- useEffect(() => {
281
- return () => {
282
- exploreDispatch({
283
- payload: ENTITY_VIEW.EXACT,
284
- type: ExploreActionKind.ToggleEntityView,
285
- });
286
- };
287
- }, [exploreDispatch]);
288
-
289
279
  function canNextPage(): boolean {
290
280
  return currentPage < pages;
291
281
  }
@@ -297,7 +287,7 @@ TableProps<T>): JSX.Element => {
297
287
  return noResults ? (
298
288
  <NoResults Paper={FluidPaper} title={"No Results found"} />
299
289
  ) : (
300
- <FluidPaper>
290
+ <FluidPaper variant="table">
301
291
  <GridPaper>
302
292
  <TableToolbar
303
293
  listView={listView}
@@ -1,4 +1,4 @@
1
- import { ColumnMeta } from "@tanstack/table-core";
1
+ import { ColumnMeta } from "@tanstack/react-table";
2
2
  import { ColumnConfig } from "../../../config/entities";
3
3
 
4
4
  export interface BaseColumnConfig<T, TValue> extends ColumnConfig<T> {
@@ -1,7 +1,12 @@
1
- import { CellContext, ColumnDef, ColumnSort } from "@tanstack/react-table";
2
- import { CoreOptions, HeaderContext, RowData } from "@tanstack/table-core";
1
+ import {
2
+ CellContext,
3
+ ColumnDef,
4
+ ColumnSort,
5
+ CoreOptions,
6
+ HeaderContext,
7
+ RowData,
8
+ } from "@tanstack/react-table";
3
9
  import React, { useMemo } from "react";
4
- import { Pagination } from "../../common/entities";
5
10
  import { ColumnConfig, ListViewConfig } from "../../config/entities";
6
11
  import { PAPER_PANEL_STYLE } from "../common/Paper/paper";
7
12
  import { ComponentCreator } from "../ComponentCreator/ComponentCreator";
@@ -25,19 +30,17 @@ export interface TableCreatorProps<T> {
25
30
  items: T[];
26
31
  listView?: ListViewConfig;
27
32
  loading?: boolean;
28
- pageCount?: number;
29
- pages: number;
30
- pageSize: number;
31
- pagination?: Pagination;
32
- total?: number;
33
33
  }
34
34
 
35
- const createCell = <T extends RowData>(config: ColumnConfig<T>) =>
36
- function CellCreator({ row }: CellContext<T, unknown>): JSX.Element {
35
+ const createCell = <T extends RowData = RowData, TData = unknown>(
36
+ config: ColumnConfig<T>
37
+ ) =>
38
+ function CellCreator(cellContext: CellContext<T, TData>): JSX.Element {
37
39
  return (
38
40
  <ComponentCreator
39
41
  components={[config.componentConfig]}
40
- response={row.original}
42
+ response={cellContext.row.original}
43
+ viewContext={{ cellContext }}
41
44
  />
42
45
  );
43
46
  };
@@ -52,18 +55,13 @@ const createRowSelectionCell = <T extends RowData>() =>
52
55
  return <RowSelectionCell row={row} />;
53
56
  };
54
57
 
55
- export const TableCreator = <T extends object>({
58
+ export const TableCreator = <T extends RowData>({
56
59
  columns,
57
60
  defaultSort,
58
61
  getRowId,
59
62
  items,
60
63
  listView,
61
64
  loading,
62
- pageCount,
63
- pages,
64
- pageSize,
65
- pagination,
66
- total,
67
65
  }: TableCreatorProps<T>): JSX.Element => {
68
66
  const columnDefs: ColumnDef<T>[] = useMemo(
69
67
  () =>
@@ -98,16 +96,11 @@ export const TableCreator = <T extends object>({
98
96
  />
99
97
  <Table<T>
100
98
  columns={columnDefs}
101
- count={pageCount}
102
99
  getRowId={getRowId}
103
100
  initialState={initialState}
104
101
  items={items}
105
102
  listView={listView}
106
103
  loading={loading}
107
- pages={pages}
108
- pageSize={pageSize}
109
- pagination={pagination}
110
- total={total}
111
104
  />
112
105
  </TableCreatorContainer>
113
106
  );
@@ -1,5 +1,4 @@
1
- import { Button as MButton } from "@mui/material";
2
- import { ButtonProps as MButtonProps } from "@mui/material/Button/Button";
1
+ import { Button as MButton, ButtonProps as MButtonProps } from "@mui/material";
3
2
  import React, { ElementType, forwardRef } from "react";
4
3
 
5
4
  /**
@@ -0,0 +1,12 @@
1
+ import styled from "@emotion/styled";
2
+
3
+ export const DrawerTitle = styled.div`
4
+ align-items: center;
5
+ display: flex;
6
+ justify-content: space-between;
7
+ padding: 14px 24px;
8
+
9
+ .MuiIconButton-root {
10
+ margin-right: -12px;
11
+ }
12
+ `;