@databiosphere/findable-ui 18.0.0 → 19.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/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +2 -0
  4. package/lib/components/Detail/components/Table/components/TableRows/tableRows.js +1 -15
  5. package/lib/components/Export/components/ExportForm/components/ExportFileSummaryForm/exportFileSummaryForm.js +9 -10
  6. package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +23 -12
  7. package/lib/components/Table/common/columnDef.js +1 -0
  8. package/lib/components/Table/common/gridTable.styles.js +5 -11
  9. package/lib/components/Table/common/utils.d.ts +3 -29
  10. package/lib/components/Table/common/utils.js +25 -60
  11. package/lib/components/Table/components/TableBody/hooks/virtualizer/constants.d.ts +3 -0
  12. package/lib/components/Table/components/TableBody/hooks/virtualizer/constants.js +3 -0
  13. package/lib/components/Table/components/TableBody/hooks/virtualizer/hook.d.ts +8 -0
  14. package/lib/components/Table/components/TableBody/hooks/virtualizer/hook.js +18 -0
  15. package/lib/components/Table/components/TableBody/hooks/virtualizer/types.d.ts +4 -0
  16. package/lib/components/Table/components/TableBody/tableBody.d.ts +3 -2
  17. package/lib/components/Table/components/TableBody/tableBody.js +7 -28
  18. package/lib/components/Table/components/TableBody/utils.d.ts +12 -0
  19. package/lib/components/Table/components/TableBody/utils.js +17 -0
  20. package/lib/components/Table/components/TableCell/components/CollapsableCell/collapsableCell.d.ts +3 -1
  21. package/lib/components/Table/components/TableCell/components/CollapsableCell/collapsableCell.js +6 -14
  22. package/lib/components/Table/components/TableFeatures/ColumnGrouping/utils.d.ts +28 -0
  23. package/lib/components/Table/components/TableFeatures/ColumnGrouping/utils.js +52 -0
  24. package/lib/components/Table/components/TableFeatures/ColumnVisibility/utils.d.ts +21 -0
  25. package/lib/components/Table/components/TableFeatures/ColumnVisibility/utils.js +37 -0
  26. package/lib/components/Table/components/TableFeatures/RowSorting/utils.d.ts +29 -0
  27. package/lib/components/Table/components/TableFeatures/RowSorting/utils.js +68 -0
  28. package/lib/components/Table/components/TableHead/tableHead.d.ts +2 -6
  29. package/lib/components/Table/components/TableHead/tableHead.js +6 -4
  30. package/lib/components/Table/components/TableHead/types.d.ts +6 -0
  31. package/lib/components/Table/components/TableHead/types.js +1 -0
  32. package/lib/components/Table/components/TableHead/utils.d.ts +19 -0
  33. package/lib/components/Table/components/TableHead/utils.js +34 -0
  34. package/lib/components/Table/components/TableRow/tableRow.styles.d.ts +1 -0
  35. package/lib/components/Table/components/TableRow/tableRow.styles.js +14 -2
  36. package/lib/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.d.ts +3 -2
  37. package/lib/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +8 -4
  38. package/lib/components/Table/components/TableRows/components/CollapsableRows/hook.d.ts +9 -0
  39. package/lib/components/Table/components/TableRows/components/CollapsableRows/hook.js +17 -0
  40. package/lib/components/Table/components/TableRows/tableRows.d.ts +3 -3
  41. package/lib/components/Table/components/TableRows/tableRows.js +9 -5
  42. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.d.ts +3 -0
  43. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.js +26 -0
  44. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.styles.d.ts +2 -0
  45. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.styles.js +16 -0
  46. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.d.ts +3 -0
  47. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.js +12 -0
  48. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.d.ts +7 -0
  49. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.js +1 -0
  50. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/constants.d.ts +4 -0
  51. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/constants.js +13 -0
  52. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/types.d.ts +4 -0
  53. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/types.js +1 -0
  54. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/utils.d.ts +17 -0
  55. package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/utils.js +36 -0
  56. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.d.ts +2 -3
  57. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.js +3 -11
  58. package/lib/components/Table/components/TableToolbar/tableToolbar.js +4 -2
  59. package/lib/components/Table/features/RowPosition/constants.js +2 -2
  60. package/lib/components/Table/features/RowPosition/utils.d.ts +2 -2
  61. package/lib/components/Table/features/RowPosition/utils.js +12 -5
  62. package/lib/components/Table/options/updater.d.ts +10 -0
  63. package/lib/components/Table/options/updater.js +24 -0
  64. package/lib/components/Table/table.js +22 -17
  65. package/lib/components/TableCreator/common/constants.d.ts +2 -2
  66. package/lib/components/TableCreator/common/constants.js +2 -1
  67. package/lib/components/TableCreator/common/utils.d.ts +5 -2
  68. package/lib/components/TableCreator/common/utils.js +11 -4
  69. package/lib/components/TableCreator/options/expanded/constants.d.ts +2 -0
  70. package/lib/components/TableCreator/options/expanded/constants.js +6 -0
  71. package/lib/components/TableCreator/options/expanded/hook.d.ts +2 -0
  72. package/lib/components/TableCreator/options/expanded/hook.js +4 -0
  73. package/lib/components/TableCreator/options/grouping/constants.d.ts +2 -0
  74. package/lib/components/TableCreator/options/grouping/constants.js +5 -0
  75. package/lib/components/TableCreator/options/grouping/hook.d.ts +2 -0
  76. package/lib/components/TableCreator/options/grouping/hook.js +9 -0
  77. package/lib/components/TableCreator/options/hook.d.ts +2 -0
  78. package/lib/components/TableCreator/options/hook.js +25 -0
  79. package/lib/components/TableCreator/options/rowSelection/constants.d.ts +2 -0
  80. package/lib/components/TableCreator/options/rowSelection/constants.js +5 -0
  81. package/lib/components/TableCreator/options/rowSelection/hook.d.ts +2 -0
  82. package/lib/components/TableCreator/options/rowSelection/hook.js +4 -0
  83. package/lib/components/TableCreator/options/sorting/constants.d.ts +2 -0
  84. package/lib/components/TableCreator/options/sorting/constants.js +5 -0
  85. package/lib/components/TableCreator/options/sorting/hook.d.ts +2 -0
  86. package/lib/components/TableCreator/options/sorting/hook.js +4 -0
  87. package/lib/components/TableCreator/tableCreator.d.ts +3 -5
  88. package/lib/components/TableCreator/tableCreator.js +4 -2
  89. package/lib/components/common/DropdownMenu/dropdownMenu.d.ts +2 -3
  90. package/lib/components/common/DropdownMenu/dropdownMenu.js +7 -7
  91. package/lib/components/common/DropdownMenu/dropdownMenu.styles.d.ts +1 -1
  92. package/lib/components/common/DropdownMenu/dropdownMenu.styles.js +1 -1
  93. package/lib/components/common/Menu/hooks/useMenu.d.ts +5 -6
  94. package/lib/config/entities.d.ts +6 -6
  95. package/lib/config/utils.d.ts +0 -7
  96. package/lib/config/utils.js +0 -12
  97. package/lib/providers/exploreState/actions/updateGrouping/action.d.ts +10 -0
  98. package/lib/providers/exploreState/actions/updateGrouping/action.js +16 -0
  99. package/lib/providers/exploreState/actions/updateGrouping/dispatch.d.ts +7 -0
  100. package/lib/providers/exploreState/actions/updateGrouping/dispatch.js +12 -0
  101. package/lib/providers/exploreState/actions/updateGrouping/types.d.ts +9 -0
  102. package/lib/providers/exploreState/actions/updateGrouping/types.js +1 -0
  103. package/lib/providers/exploreState/actions/updateGrouping/utils.d.ts +10 -0
  104. package/lib/providers/exploreState/actions/updateGrouping/utils.js +26 -0
  105. package/lib/providers/exploreState/entities.d.ts +3 -4
  106. package/lib/providers/exploreState/initializer/utils.js +41 -8
  107. package/lib/providers/exploreState/payloads/entities.d.ts +2 -1
  108. package/lib/providers/exploreState/utils.d.ts +6 -4
  109. package/lib/providers/exploreState/utils.js +7 -4
  110. package/lib/providers/exploreState.d.ts +3 -1
  111. package/lib/providers/exploreState.js +15 -5
  112. package/lib/views/ExploreView/exploreView.js +2 -2
  113. package/package.json +1 -1
  114. package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +2 -0
  115. package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +3 -18
  116. package/src/components/Export/components/ExportForm/components/ExportFileSummaryForm/exportFileSummaryForm.tsx +28 -32
  117. package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +27 -13
  118. package/src/components/Table/common/columnDef.ts +1 -0
  119. package/src/components/Table/common/gridTable.styles.ts +5 -11
  120. package/src/components/Table/common/utils.ts +44 -107
  121. package/src/components/Table/components/TableBody/hooks/virtualizer/constants.ts +3 -0
  122. package/src/components/Table/components/TableBody/hooks/virtualizer/hook.ts +23 -0
  123. package/src/components/Table/components/TableBody/hooks/virtualizer/types.ts +5 -0
  124. package/src/components/Table/components/TableBody/tableBody.tsx +14 -30
  125. package/src/components/Table/components/TableBody/utils.ts +21 -0
  126. package/src/components/Table/components/TableCell/components/CollapsableCell/collapsableCell.tsx +14 -15
  127. package/src/components/Table/components/TableFeatures/ColumnGrouping/utils.ts +70 -0
  128. package/src/components/Table/components/TableFeatures/ColumnVisibility/utils.ts +52 -0
  129. package/src/components/Table/components/TableFeatures/RowSorting/utils.ts +87 -0
  130. package/src/components/Table/components/TableHead/tableHead.tsx +21 -29
  131. package/src/components/Table/components/TableHead/types.ts +7 -0
  132. package/src/components/Table/components/TableHead/utils.ts +42 -0
  133. package/src/components/Table/components/TableRow/tableRow.styles.ts +19 -2
  134. package/src/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +8 -2
  135. package/src/components/Table/components/TableRows/components/CollapsableRows/hook.ts +20 -0
  136. package/src/components/Table/components/TableRows/tableRows.tsx +18 -15
  137. package/src/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.styles.ts +17 -0
  138. package/src/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.tsx +54 -0
  139. package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.tsx +28 -0
  140. package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.ts +8 -0
  141. package/src/components/Table/components/TableToolbar/components/ColumnGrouping/constants.ts +17 -0
  142. package/src/components/Table/components/TableToolbar/components/ColumnGrouping/types.ts +5 -0
  143. package/src/components/Table/components/TableToolbar/components/ColumnGrouping/utils.ts +45 -0
  144. package/src/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.tsx +7 -20
  145. package/src/components/Table/components/TableToolbar/tableToolbar.tsx +8 -2
  146. package/src/components/Table/features/RowPosition/constants.ts +2 -2
  147. package/src/components/Table/features/RowPosition/utils.ts +10 -5
  148. package/src/components/Table/options/updater.ts +29 -0
  149. package/src/components/Table/table.tsx +43 -25
  150. package/src/components/TableCreator/common/constants.ts +4 -6
  151. package/src/components/TableCreator/common/utils.ts +14 -7
  152. package/src/components/TableCreator/options/expanded/constants.ts +14 -0
  153. package/src/components/TableCreator/options/expanded/hook.ts +6 -0
  154. package/src/components/TableCreator/options/grouping/constants.ts +6 -0
  155. package/src/components/TableCreator/options/grouping/hook.ts +17 -0
  156. package/src/components/TableCreator/options/hook.ts +31 -0
  157. package/src/components/TableCreator/options/rowSelection/constants.ts +10 -0
  158. package/src/components/TableCreator/options/rowSelection/hook.ts +8 -0
  159. package/src/components/TableCreator/options/sorting/constants.ts +10 -0
  160. package/src/components/TableCreator/options/sorting/hook.ts +6 -0
  161. package/src/components/TableCreator/tableCreator.tsx +4 -11
  162. package/src/components/common/DropdownMenu/dropdownMenu.styles.ts +1 -1
  163. package/src/components/common/DropdownMenu/dropdownMenu.tsx +19 -17
  164. package/src/components/common/Menu/hooks/useMenu.ts +8 -9
  165. package/src/config/entities.ts +10 -9
  166. package/src/config/utils.ts +0 -14
  167. package/src/providers/exploreState/actions/updateGrouping/action.ts +26 -0
  168. package/src/providers/exploreState/actions/updateGrouping/dispatch.ts +16 -0
  169. package/src/providers/exploreState/actions/updateGrouping/types.ts +11 -0
  170. package/src/providers/exploreState/actions/updateGrouping/utils.ts +33 -0
  171. package/src/providers/exploreState/entities.ts +3 -3
  172. package/src/providers/exploreState/initializer/utils.ts +58 -10
  173. package/src/providers/exploreState/payloads/entities.ts +2 -0
  174. package/src/providers/exploreState/utils.ts +10 -7
  175. package/src/providers/exploreState.tsx +29 -6
  176. package/src/views/ExploreView/exploreView.tsx +1 -3
  177. package/types/data-explorer-ui.d.ts +8 -1
  178. package/lib/components/TableCreator/common/entities.d.ts +0 -5
  179. package/src/components/TableCreator/common/entities.ts +0 -6
  180. /package/lib/components/{TableCreator/common/entities.js → Table/components/TableBody/hooks/virtualizer/types.js} +0 -0
@@ -1,8 +1,10 @@
1
1
  import { TabProps as MTabProps, Theme, ThemeOptions } from "@mui/material";
2
2
  import {
3
3
  CellContext,
4
+ ColumnDef,
4
5
  ColumnMeta,
5
6
  ColumnSort,
7
+ GroupingState,
6
8
  RowData,
7
9
  Table,
8
10
  TableOptions,
@@ -87,24 +89,24 @@ export interface CategoryConfig {
87
89
 
88
90
  /**
89
91
  * Column configuration.
92
+ * TanStack ColumnDef properties not currently supported include:
93
+ * - `enableMultiSort` - Note, table multi-sort is managed via table options.
90
94
  */
91
- export interface ColumnConfig<
92
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This config model is part of a generic array
93
- T = any,
95
+ export type ColumnConfig<
96
+ T extends RowData,
97
+ TValue = unknown,
94
98
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This config model is part of a generic array
95
99
  C extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = any
96
- > {
100
+ > = Omit<ColumnDef<T, TValue>, "enableMultiSort"> & {
97
101
  columnPinned?: boolean; // Column is pinned to the top when table rows are collapsable.
98
102
  columnVisible?: boolean; // Column is visible. Default is "true".
99
103
  componentConfig: ComponentConfig<C, T>;
100
104
  disableHiding?: boolean; // Disables hiding of column. Column is unavailable for "Edit Columns" functionality when "true".
101
- disableSorting?: boolean; // Disables sorting for the column.
102
105
  header: string;
103
106
  id: string; // The unique identifier for the column.
104
107
  meta?: ColumnMeta<T, unknown>;
105
- tooltip?: string; // TODO review need to define `tooltip` field - it is currently not in use.
106
108
  width: GridTrackSize;
107
- }
109
+ };
108
110
 
109
111
  /**
110
112
  * Interface used to define the configuration of a component.
@@ -256,7 +258,6 @@ export type GridTrackSize =
256
258
  /**
257
259
  * List configuration.
258
260
  */
259
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This config model can receive any model as type
260
261
  export interface ListConfig<T extends RowData> {
261
262
  columns: ColumnConfig<T>[];
262
263
  defaultSort?: ColumnSort; // Establishes initial table state "sorting" state.
@@ -270,7 +271,6 @@ export interface ListViewConfig {
270
271
  disablePagination?: boolean;
271
272
  enableDownload?: boolean;
272
273
  enableRowPreview?: boolean;
273
- enableRowSelection?: boolean;
274
274
  enableTab?: boolean;
275
275
  listHero?: ComponentsConfig;
276
276
  rowPreviewView?: ComponentsConfig; // Row preview view is expected to be a modal or drawer or similar.
@@ -312,6 +312,7 @@ export interface Override {
312
312
 
313
313
  export interface SavedFilter {
314
314
  filters: SelectedFilter[];
315
+ grouping?: GroupingState;
315
316
  sorting?: ColumnSort[];
316
317
  title: string;
317
318
  }
@@ -1,4 +1,3 @@
1
- import { ColumnSort } from "@tanstack/react-table";
2
1
  import { EXPLORE_MODE } from "../hooks/useExploreMode";
3
2
  import { getConfig } from "./config";
4
3
  import { EntityConfig, SiteConfig } from "./entities";
@@ -51,19 +50,6 @@ export function getDefaultEntityConfig(): EntityConfig {
51
50
  };
52
51
  }
53
52
 
54
- /**
55
- * Returns the initial table sorting state for the specified entity list configuration.
56
- * @param entityConfig - Entity configuration.
57
- * @returns initial sorting state.
58
- */
59
- export function getDefaultSorting(entityConfig: EntityConfig): ColumnSort[] {
60
- const columnSort = entityConfig.list.defaultSort;
61
- if (!columnSort) {
62
- return [];
63
- }
64
- return [columnSort];
65
- }
66
-
67
53
  /**
68
54
  * Returns the entity config for the given entity list type.
69
55
  * @param entities - Entities config.
@@ -0,0 +1,26 @@
1
+ import { ExploreState } from "../../../exploreState";
2
+ import { updateEntityPageState } from "../../utils";
3
+ import { UpdateGroupingPayload } from "./types";
4
+ import { buildNextGrouping } from "./utils";
5
+
6
+ /**
7
+ * Reducer function to handle the "update grouping" action.
8
+ * Updates the grouping in the state for the current entity.
9
+ * @param state - Explore State.
10
+ * @param payload - Payload.
11
+ * @returns explore state.
12
+ */
13
+ export function updateGroupingAction(
14
+ state: ExploreState,
15
+ payload: UpdateGroupingPayload
16
+ ): ExploreState {
17
+ const grouping = buildNextGrouping(state, payload.updaterOrValue);
18
+ return {
19
+ ...state,
20
+ entityPageState: updateEntityPageState(
21
+ state.tabValue,
22
+ state.entityPageState,
23
+ { grouping }
24
+ ),
25
+ };
26
+ }
@@ -0,0 +1,16 @@
1
+ import { ExploreActionKind } from "../../../exploreState";
2
+ import { UpdateGroupingAction, UpdateGroupingPayload } from "./types";
3
+
4
+ /**
5
+ * Action creator for updating grouping in the state.
6
+ * @param payload - Payload.
7
+ * @returns Action with payload and action type.
8
+ */
9
+ export function updateGrouping(
10
+ payload: UpdateGroupingPayload
11
+ ): UpdateGroupingAction {
12
+ return {
13
+ payload,
14
+ type: ExploreActionKind.UpdateGrouping,
15
+ };
16
+ }
@@ -0,0 +1,11 @@
1
+ import { GroupingState, Updater } from "@tanstack/react-table";
2
+ import { ExploreActionKind } from "../../../exploreState";
3
+
4
+ export type UpdateGroupingAction = {
5
+ payload: UpdateGroupingPayload;
6
+ type: ExploreActionKind.UpdateGrouping;
7
+ };
8
+
9
+ export type UpdateGroupingPayload = {
10
+ updaterOrValue: Updater<GroupingState>;
11
+ };
@@ -0,0 +1,33 @@
1
+ import { GroupingState, Updater } from "@tanstack/react-table";
2
+ import { resolveUpdater } from "../../../../components/Table/options/updater";
3
+ import { ExploreState } from "../../../exploreState";
4
+
5
+ /**
6
+ * Builds the next grouping state for the current entity type.
7
+ * Uses TanStack updater to update the grouping state.
8
+ * @param state - Explore state.
9
+ * @param updaterOrValue - Updater or value to update the grouping state.
10
+ * @returns grouping state.
11
+ */
12
+ export function buildNextGrouping(
13
+ state: ExploreState,
14
+ updaterOrValue: Updater<GroupingState>
15
+ ): GroupingState {
16
+ const grouping = resolveUpdater(updaterOrValue, getOldGrouping(state));
17
+ if (grouping.length > 1) {
18
+ // Explore state only supports single-column grouping.
19
+ return grouping.slice(-1);
20
+ }
21
+ return grouping;
22
+ }
23
+
24
+ /**
25
+ * Retrieves the current "old" grouping state from the explore state, for the current entity type.
26
+ * @param state - Explore state.
27
+ * @returns old grouping state.
28
+ */
29
+ function getOldGrouping(state: ExploreState): GroupingState {
30
+ const { entityPageState, tabValue } = state;
31
+ const { grouping = [] } = entityPageState[tabValue];
32
+ return grouping;
33
+ }
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  ColumnSort,
3
+ GroupingState,
3
4
  RowSelectionState,
4
5
  VisibilityState,
5
6
  } from "@tanstack/react-table";
@@ -22,6 +23,7 @@ export interface EntityPageState {
22
23
  categoryGroupConfigKey: CategoryGroupConfigKey;
23
24
  columnsVisibility: VisibilityState;
24
25
  enableRowSelection: boolean;
26
+ grouping: GroupingState;
25
27
  rowPreview: RowPreviewState;
26
28
  rowSelection: RowSelectionState;
27
29
  sorting: ColumnSort[];
@@ -48,9 +50,7 @@ export type EntityStateByCategoryGroupConfigKey = Map<
48
50
 
49
51
  export type CategoryGroupConfigKey = CategoryGroupConfig["key"];
50
52
 
51
- export interface EntityStateSavedFilter extends Omit<SavedFilter, "sort"> {
52
- sorting?: ColumnSort[];
53
- }
53
+ export type EntityStateSavedFilter = SavedFilter;
54
54
 
55
55
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO revisit when adding react query or similar
56
56
  export type ListItem = any;
@@ -1,4 +1,8 @@
1
- import { VisibilityState } from "@tanstack/react-table";
1
+ import {
2
+ ColumnSort,
3
+ GroupingState,
4
+ VisibilityState,
5
+ } from "@tanstack/react-table";
2
6
  import { SelectCategory, SelectedFilter } from "../../../common/entities";
3
7
  import { getInitialTableColumnVisibility } from "../../../components/Table/common/utils";
4
8
  import { ACCESSOR_KEYS } from "../../../components/TableCreator/common/constants";
@@ -10,7 +14,6 @@ import {
10
14
  SavedFilter,
11
15
  SiteConfig,
12
16
  } from "../../../config/entities";
13
- import { getDefaultSorting } from "../../../config/utils";
14
17
  import { ExploreState } from "../../exploreState";
15
18
  import { SELECT_CATEGORY_KEY } from "../constants";
16
19
  import {
@@ -73,8 +76,13 @@ function buildSavedFilterByCategoryValueKey(
73
76
  if (!savedFilters) return;
74
77
  const savedFilterByCategoryValueKey: SavedFilterByCategoryValueKey =
75
78
  new Map();
76
- for (const { filters, sorting, title } of savedFilters) {
77
- savedFilterByCategoryValueKey.set(title, { filters, sorting, title });
79
+ for (const { filters, grouping, sorting, title } of savedFilters) {
80
+ savedFilterByCategoryValueKey.set(title, {
81
+ filters,
82
+ grouping,
83
+ sorting,
84
+ title,
85
+ });
78
86
  }
79
87
  return savedFilterByCategoryValueKey;
80
88
  }
@@ -145,18 +153,29 @@ function initColumnVisibility(entityConfig: EntityConfig): VisibilityState {
145
153
  const {
146
154
  list: {
147
155
  columns,
148
- tableOptions: { initialState: { columnVisibility = {} } = {} } = {},
156
+ tableOptions: {
157
+ enableRowSelection,
158
+ initialState: { columnVisibility = {} } = {},
159
+ } = {},
149
160
  },
150
- listView: { enableRowSelection = false } = {},
151
161
  } = entityConfig;
152
162
  return {
153
- [ACCESSOR_KEYS.ROW_POSITION]: false, // Explicitly setting row position to false; required - currently `columnVisibilty` is initialized from columns configuration.
154
- [ACCESSOR_KEYS.SELECT]: enableRowSelection,
163
+ [ACCESSOR_KEYS.ROW_POSITION]: false, // Explicitly setting row position to false; required - currently `columnVisibility` is initialized from columns configuration.
164
+ [ACCESSOR_KEYS.SELECT]: Boolean(enableRowSelection),
155
165
  ...getInitialTableColumnVisibility(columns),
156
166
  ...columnVisibility, // `columnVisibility` is managed by ExploreState; use table options to override this setting.
157
167
  };
158
168
  }
159
169
 
170
+ /**
171
+ * Returns the initial `enableRowSelection` option for the specified entity list configuration.
172
+ * @param entityConfig - Entity configuration.
173
+ * @returns initial `enableRowSelection` option.
174
+ */
175
+ function initEnableRowSelection(entityConfig: EntityConfig): boolean {
176
+ return Boolean(entityConfig.list.tableOptions?.enableRowSelection);
177
+ }
178
+
160
179
  /**
161
180
  * Initializes entity page state.
162
181
  * @param config - Site config.
@@ -169,10 +188,11 @@ function initEntityPageState(config: SiteConfig): EntityPageStateMapper {
169
188
  [entity.route]: {
170
189
  categoryGroupConfigKey: initCategoryGroupConfigKey(config, entity),
171
190
  columnsVisibility: initColumnVisibility(entity),
172
- enableRowSelection: Boolean(entity.listView?.enableRowSelection),
191
+ enableRowSelection: initEnableRowSelection(entity),
192
+ grouping: initGrouping(entity),
173
193
  rowPreview: undefined,
174
194
  rowSelection: {},
175
- sorting: getDefaultSorting(entity),
195
+ sorting: initSorting(entity),
176
196
  },
177
197
  };
178
198
  }, {} as EntityPageStateMapper);
@@ -230,6 +250,34 @@ function initFilterState(decodedFilterParam: string): SelectedFilter[] {
230
250
  return filterState;
231
251
  }
232
252
 
253
+ /**
254
+ * Returns the initial table grouping state for the specified entity list configuration.
255
+ * @param entityConfig - Entity configuration.
256
+ * @returns initial grouping state.
257
+ */
258
+ function initGrouping(entityConfig: EntityConfig): GroupingState {
259
+ const {
260
+ list: { tableOptions: { initialState: { grouping = [] } = {} } = {} },
261
+ } = entityConfig;
262
+ return grouping;
263
+ }
264
+
265
+ /**
266
+ * Returns the initial table sorting state for the specified entity list configuration.
267
+ * @param entityConfig - Entity configuration.
268
+ * @returns initial sorting state.
269
+ */
270
+ function initSorting(entityConfig: EntityConfig): ColumnSort[] {
271
+ const {
272
+ list: {
273
+ defaultSort,
274
+ tableOptions: { initialState: { sorting = [] } = {} } = {},
275
+ },
276
+ } = entityConfig;
277
+ if (defaultSort) return [defaultSort];
278
+ return sorting;
279
+ }
280
+
233
281
  /**
234
282
  * Returns the explore state reducer initial arguments.
235
283
  * @param config - Site config.
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  ColumnSort,
3
+ GroupingState,
3
4
  RowSelectionState,
4
5
  VisibilityState,
5
6
  } from "@tanstack/react-table";
@@ -62,6 +63,7 @@ export type UpdateColumnVisibilityPayload = VisibilityState;
62
63
  export interface UpdateEntityFiltersPayload {
63
64
  entityListType: string;
64
65
  filters: SelectedFilter[];
66
+ grouping?: GroupingState;
65
67
  sorting?: ColumnSort[];
66
68
  }
67
69
  /**
@@ -1,4 +1,3 @@
1
- import { ColumnSort } from "@tanstack/react-table";
2
1
  import {
3
2
  CategoryKey,
4
3
  CategoryValueKey,
@@ -109,20 +108,24 @@ export function getEntityStateSavedFilter(
109
108
  }
110
109
 
111
110
  /**
112
- * Returns entity state "saved filter" sorting for the given category value key.
111
+ * Retrieves a specified property from the "saved filter" for the given category value key.
112
+ * This function fetches a property (e.g., "sorting" or "grouping") from the saved filter
113
+ * associated with a given `selectedValue`.
113
114
  * @param state - Explore state.
114
115
  * @param selectedValue - Key of category value that has been de/selected.
115
116
  * @param selected - True if value is selected, false if de-selected.
116
- * @returns sorting.
117
+ * @param propertyName - The name of the property to retrieve from the saved filter. Should be one of the predefined keys: "sorting" or "grouping".
118
+ * @returns value of the specified property from the saved filter, or undefined if `selected` is false.
117
119
  */
118
- export function getEntityStateSavedSorting(
120
+ export function getEntityStateSavedProperty<K extends "sorting" | "grouping">(
119
121
  state: ExploreState,
120
122
  selectedValue: CategoryValueKey,
121
- selected: boolean
122
- ): ColumnSort[] | undefined {
123
+ selected: boolean,
124
+ propertyName: K
125
+ ): EntityStateSavedFilter[K] | undefined {
123
126
  if (!selected) return;
124
127
  const savedFilter = getEntityStateSavedFilter(state, selectedValue);
125
- return savedFilter?.sorting;
128
+ return savedFilter?.[propertyName];
126
129
  }
127
130
 
128
131
  /**
@@ -19,6 +19,8 @@ import {
19
19
  } from "../hooks/useCategoryFilter";
20
20
  import { useConfig } from "../hooks/useConfig";
21
21
  import { useURLFilterParams } from "../hooks/useURLFilterParams";
22
+ import { updateGroupingAction } from "./exploreState/actions/updateGrouping/action";
23
+ import { UpdateGroupingAction } from "./exploreState/actions/updateGrouping/types";
22
24
  import {
23
25
  EntityPageStateMapper,
24
26
  EntityStateByCategoryGroupConfigKey,
@@ -49,7 +51,7 @@ import {
49
51
  closeRowPreview,
50
52
  getEntityCategoryGroupConfigKey,
51
53
  getEntityState,
52
- getEntityStateSavedSorting,
54
+ getEntityStateSavedProperty,
53
55
  getFilterCount,
54
56
  patchEntityListItems,
55
57
  resetPage,
@@ -226,6 +228,7 @@ export enum ExploreActionKind {
226
228
  UpdateEntityFilters = "UPDATE_ENTITY_FILTERS",
227
229
  UpdateEntityViewAccess = "UPDATE_ENTITY_VIEW_ACCESS",
228
230
  UpdateFilter = "UPDATE_FILTER",
231
+ UpdateGrouping = "UPDATE_GROUPING",
229
232
  UpdateRowPreview = "UPDATE_ROW_PREVIEW",
230
233
  UpdateRowSelection = "UPDATE_ROW_SELECTION",
231
234
  UpdateSorting = "UPDATE_SORTING",
@@ -247,6 +250,7 @@ export type ExploreAction =
247
250
  | UpdateEntityFiltersAction
248
251
  | UpdateEntityViewAccessAction
249
252
  | UpdateFilterAction
253
+ | UpdateGroupingAction
250
254
  | UpdateRowPreviewAction
251
255
  | UpdateRowSelectionAction
252
256
  | UpdateSortingAction;
@@ -403,11 +407,19 @@ function exploreReducer(
403
407
  payload.selectedValue,
404
408
  payload.selected
405
409
  );
406
- const savedSorting = getEntityStateSavedSorting(
410
+ const savedGrouping = getEntityStateSavedProperty(
407
411
  state,
408
412
  payload.selectedValue,
409
- payload.selected
413
+ payload.selected,
414
+ "grouping"
415
+ );
416
+ const savedSorting = getEntityStateSavedProperty(
417
+ state,
418
+ payload.selectedValue,
419
+ payload.selected,
420
+ "sorting"
410
421
  );
422
+ const grouping = savedGrouping || []; // Reset grouping to default if saved grouping is not available.
411
423
  const sorting = savedSorting || []; // Reset sorting to default if saved sorting is not available.
412
424
  updateEntityStateByCategoryGroupConfigKey(state, {
413
425
  filterState,
@@ -417,7 +429,7 @@ function exploreReducer(
417
429
  ...state,
418
430
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
419
431
  state,
420
- { rowPreview, rowSelection, sorting }
432
+ { grouping, rowPreview, rowSelection, sorting }
421
433
  ),
422
434
  filterCount: getFilterCount(filterState),
423
435
  filterState,
@@ -592,7 +604,12 @@ function exploreReducer(
592
604
  * - closes row preview, without updating the entity page state row preview.
593
605
  */
594
606
  case ExploreActionKind.UpdateEntityFilters: {
595
- const { entityListType, filters: filterState, sorting } = payload;
607
+ const {
608
+ entityListType,
609
+ filters: filterState,
610
+ grouping = [],
611
+ sorting = [],
612
+ } = payload;
596
613
  const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
597
614
  entityListType,
598
615
  state.entityPageState
@@ -614,7 +631,7 @@ function exploreReducer(
614
631
  ...state,
615
632
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
616
633
  state,
617
- { rowPreview, rowSelection, sorting },
634
+ { grouping, rowPreview, rowSelection, sorting },
618
635
  categoryGroupConfigKey
619
636
  ),
620
637
  rowPreview: closeRowPreview(state.rowPreview),
@@ -658,6 +675,12 @@ function exploreReducer(
658
675
  rowPreview,
659
676
  };
660
677
  }
678
+ /**
679
+ * Update grouping
680
+ **/
681
+ case ExploreActionKind.UpdateGrouping: {
682
+ return updateGroupingAction(state, payload);
683
+ }
661
684
  /**
662
685
  * Update row preview
663
686
  */
@@ -248,7 +248,7 @@ function renderList(
248
248
  ): JSX.Element {
249
249
  const { listItems, loading, tabValue } = exploreState;
250
250
  const { getId: getRowId, list, listView } = entityConfig;
251
- const { columns: columnsConfig, defaultSort, tableOptions } = list;
251
+ const { columns: columnsConfig } = list;
252
252
 
253
253
  if (!exploreState || !tabValue) {
254
254
  return <></>; //TODO: return the loading UI component
@@ -263,12 +263,10 @@ function renderList(
263
263
  return (
264
264
  <TableCreator
265
265
  columns={columnsConfig}
266
- defaultSort={defaultSort}
267
266
  getRowId={getRowId}
268
267
  items={listItems ?? []}
269
268
  listView={listView}
270
269
  loading={loading}
271
- tableOptions={tableOptions}
272
270
  />
273
271
  );
274
272
  }
@@ -269,7 +269,6 @@ declare module "@tanstack/react-table" {
269
269
  interface ColumnMeta<TData extends RowData, TValue> {
270
270
  align?: TableCellProps["align"];
271
271
  columnPinned?: boolean;
272
- enableSortingInteraction?: boolean; // Flag to enable sorting interaction UI (e.g. sort icon) button; defaults to true.
273
272
  header?: string;
274
273
  width?: GridTrackSize;
275
274
  }
@@ -277,6 +276,14 @@ declare module "@tanstack/react-table" {
277
276
  interface InitialTableState extends CustomFeatureInitialTableState {}
278
277
  // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-unused-vars -- empty interface is needed for extending, TData is an unused variable.
279
278
  interface Row<TData extends RowData> extends CustomFeatureRow {}
279
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- TData is an unused variables.
280
+ interface SortingOptions<TData extends RowData> {
281
+ /**
282
+ * When false, sorting can still be applied programmatically (e.g., `getSortedRowModel`),
283
+ * but user interactions or showing sort icons are disabled.
284
+ */
285
+ enableSortingInteraction?: boolean;
286
+ }
280
287
  // eslint-disable-next-line @typescript-eslint/no-empty-interface -- empty interface is needed for extending.
281
288
  interface Table<TData extends RowData> extends CustomFeatureInstance<TData> {}
282
289
  // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-unused-vars -- empty interface is needed for extending, TData is an unused variable.
@@ -1,5 +0,0 @@
1
- import { ColumnMeta } from "@tanstack/react-table";
2
- import { ColumnConfig } from "../../../config/entities";
3
- export interface BaseColumnConfig<T, TValue> extends ColumnConfig<T> {
4
- meta?: ColumnMeta<T, TValue>;
5
- }
@@ -1,6 +0,0 @@
1
- import { ColumnMeta } from "@tanstack/react-table";
2
- import { ColumnConfig } from "../../../config/entities";
3
-
4
- export interface BaseColumnConfig<T, TValue> extends ColumnConfig<T> {
5
- meta?: ColumnMeta<T, TValue>;
6
- }