@databiosphere/findable-ui 17.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.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +22 -0
- package/lib/apis/azul/common/filterTransformer.js +1 -1
- package/lib/apis/azul/common/utils.d.ts +1 -1
- package/lib/apis/azul/common/utils.js +5 -1
- package/lib/common/entities.d.ts +3 -3
- package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +2 -0
- package/lib/components/Detail/components/Table/components/TableRows/tableRows.js +1 -15
- package/lib/components/Export/components/ExportForm/components/ExportFileSummaryForm/exportFileSummaryForm.js +9 -10
- package/lib/components/Filter/common/utils.js +1 -1
- package/lib/components/Filter/components/VariableSizeList/VariableSizeList.d.ts +1 -1
- package/lib/components/Filter/components/VariableSizeListItem/variableSizeListItem.d.ts +1 -1
- package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +23 -12
- package/lib/components/Table/common/columnDef.js +1 -0
- package/lib/components/Table/common/gridTable.styles.js +5 -11
- package/lib/components/Table/common/utils.d.ts +3 -29
- package/lib/components/Table/common/utils.js +26 -61
- package/lib/components/Table/components/TableBody/hooks/virtualizer/constants.d.ts +3 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/constants.js +3 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/hook.d.ts +8 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/hook.js +18 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/types.d.ts +4 -0
- package/lib/components/Table/components/TableBody/tableBody.d.ts +3 -2
- package/lib/components/Table/components/TableBody/tableBody.js +7 -28
- package/lib/components/Table/components/TableBody/utils.d.ts +12 -0
- package/lib/components/Table/components/TableBody/utils.js +17 -0
- package/lib/components/Table/components/TableCell/components/CollapsableCell/collapsableCell.d.ts +3 -1
- package/lib/components/Table/components/TableCell/components/CollapsableCell/collapsableCell.js +6 -14
- package/lib/components/Table/components/TableFeatures/ColumnGrouping/utils.d.ts +28 -0
- package/lib/components/Table/components/TableFeatures/ColumnGrouping/utils.js +52 -0
- package/lib/components/Table/components/TableFeatures/ColumnVisibility/utils.d.ts +21 -0
- package/lib/components/Table/components/TableFeatures/ColumnVisibility/utils.js +37 -0
- package/lib/components/Table/components/TableFeatures/RowSorting/utils.d.ts +29 -0
- package/lib/components/Table/components/TableFeatures/RowSorting/utils.js +68 -0
- package/lib/components/Table/components/TableHead/tableHead.d.ts +2 -6
- package/lib/components/Table/components/TableHead/tableHead.js +6 -4
- package/lib/components/Table/components/TableHead/types.d.ts +6 -0
- package/lib/components/Table/components/TableHead/types.js +1 -0
- package/lib/components/Table/components/TableHead/utils.d.ts +19 -0
- package/lib/components/Table/components/TableHead/utils.js +34 -0
- package/lib/components/Table/components/TableRow/tableRow.styles.d.ts +1 -0
- package/lib/components/Table/components/TableRow/tableRow.styles.js +14 -2
- package/lib/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.d.ts +3 -2
- package/lib/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +8 -4
- package/lib/components/Table/components/TableRows/components/CollapsableRows/hook.d.ts +9 -0
- package/lib/components/Table/components/TableRows/components/CollapsableRows/hook.js +17 -0
- package/lib/components/Table/components/TableRows/tableRows.d.ts +3 -3
- package/lib/components/Table/components/TableRows/tableRows.js +9 -5
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.js +26 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.styles.d.ts +2 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.styles.js +16 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.js +12 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.d.ts +7 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.js +1 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/constants.d.ts +4 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/constants.js +13 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/types.d.ts +4 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/types.js +1 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/utils.d.ts +17 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/utils.js +36 -0
- package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.d.ts +2 -3
- package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.js +3 -11
- package/lib/components/Table/components/TableToolbar/tableToolbar.js +4 -2
- package/lib/components/Table/features/RowPosition/constants.js +2 -2
- package/lib/components/Table/features/RowPosition/utils.d.ts +2 -2
- package/lib/components/Table/features/RowPosition/utils.js +12 -5
- package/lib/components/Table/options/updater.d.ts +10 -0
- package/lib/components/Table/options/updater.js +24 -0
- package/lib/components/Table/table.js +22 -17
- package/lib/components/TableCreator/common/constants.d.ts +2 -2
- package/lib/components/TableCreator/common/constants.js +2 -1
- package/lib/components/TableCreator/common/utils.d.ts +5 -2
- package/lib/components/TableCreator/common/utils.js +11 -4
- package/lib/components/TableCreator/options/expanded/constants.d.ts +2 -0
- package/lib/components/TableCreator/options/expanded/constants.js +6 -0
- package/lib/components/TableCreator/options/expanded/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/expanded/hook.js +4 -0
- package/lib/components/TableCreator/options/grouping/constants.d.ts +2 -0
- package/lib/components/TableCreator/options/grouping/constants.js +5 -0
- package/lib/components/TableCreator/options/grouping/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/grouping/hook.js +9 -0
- package/lib/components/TableCreator/options/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/hook.js +25 -0
- package/lib/components/TableCreator/options/rowSelection/constants.d.ts +2 -0
- package/lib/components/TableCreator/options/rowSelection/constants.js +5 -0
- package/lib/components/TableCreator/options/rowSelection/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/rowSelection/hook.js +4 -0
- package/lib/components/TableCreator/options/sorting/constants.d.ts +2 -0
- package/lib/components/TableCreator/options/sorting/constants.js +5 -0
- package/lib/components/TableCreator/options/sorting/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/sorting/hook.js +4 -0
- package/lib/components/TableCreator/tableCreator.d.ts +3 -5
- package/lib/components/TableCreator/tableCreator.js +4 -2
- package/lib/components/common/DropdownMenu/dropdownMenu.d.ts +2 -3
- package/lib/components/common/DropdownMenu/dropdownMenu.js +7 -7
- package/lib/components/common/DropdownMenu/dropdownMenu.styles.d.ts +1 -1
- package/lib/components/common/DropdownMenu/dropdownMenu.styles.js +1 -1
- package/lib/components/common/Menu/hooks/useMenu.d.ts +5 -6
- package/lib/config/entities.d.ts +7 -7
- package/lib/config/utils.d.ts +0 -7
- package/lib/config/utils.js +0 -12
- package/lib/hooks/useCategoryFilter.js +5 -1
- package/lib/providers/exploreState/actions/updateGrouping/action.d.ts +10 -0
- package/lib/providers/exploreState/actions/updateGrouping/action.js +16 -0
- package/lib/providers/exploreState/actions/updateGrouping/dispatch.d.ts +7 -0
- package/lib/providers/exploreState/actions/updateGrouping/dispatch.js +12 -0
- package/lib/providers/exploreState/actions/updateGrouping/types.d.ts +9 -0
- package/lib/providers/exploreState/actions/updateGrouping/types.js +1 -0
- package/lib/providers/exploreState/actions/updateGrouping/utils.d.ts +10 -0
- package/lib/providers/exploreState/actions/updateGrouping/utils.js +26 -0
- package/lib/providers/exploreState/entities.d.ts +3 -4
- package/lib/providers/exploreState/initializer/utils.js +41 -8
- package/lib/providers/exploreState/payloads/entities.d.ts +2 -1
- package/lib/providers/exploreState/utils.d.ts +6 -4
- package/lib/providers/exploreState/utils.js +7 -4
- package/lib/providers/exploreState.d.ts +3 -1
- package/lib/providers/exploreState.js +15 -5
- package/lib/providers/fileManifestState.js +2 -4
- package/lib/viewModelBuilders/common/utils.d.ts +6 -6
- package/lib/viewModelBuilders/common/utils.js +10 -10
- package/lib/views/ExploreView/exploreView.js +3 -3
- package/package.json +1 -1
- package/src/apis/azul/common/filterTransformer.ts +1 -1
- package/src/apis/azul/common/utils.ts +4 -2
- package/src/common/entities.ts +3 -3
- package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +2 -0
- package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +3 -18
- package/src/components/Export/components/ExportForm/components/ExportFileSummaryForm/exportFileSummaryForm.tsx +28 -32
- package/src/components/Filter/common/utils.ts +1 -1
- package/src/components/Filter/components/VariableSizeList/VariableSizeList.tsx +1 -1
- package/src/components/Filter/components/VariableSizeListItem/variableSizeListItem.tsx +1 -1
- package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +27 -13
- package/src/components/Table/common/columnDef.ts +1 -0
- package/src/components/Table/common/gridTable.styles.ts +5 -11
- package/src/components/Table/common/utils.ts +45 -108
- package/src/components/Table/components/TableBody/hooks/virtualizer/constants.ts +3 -0
- package/src/components/Table/components/TableBody/hooks/virtualizer/hook.ts +23 -0
- package/src/components/Table/components/TableBody/hooks/virtualizer/types.ts +5 -0
- package/src/components/Table/components/TableBody/tableBody.tsx +14 -30
- package/src/components/Table/components/TableBody/utils.ts +21 -0
- package/src/components/Table/components/TableCell/components/CollapsableCell/collapsableCell.tsx +14 -15
- package/src/components/Table/components/TableFeatures/ColumnGrouping/utils.ts +70 -0
- package/src/components/Table/components/TableFeatures/ColumnVisibility/utils.ts +52 -0
- package/src/components/Table/components/TableFeatures/RowSorting/utils.ts +87 -0
- package/src/components/Table/components/TableHead/tableHead.tsx +21 -29
- package/src/components/Table/components/TableHead/types.ts +7 -0
- package/src/components/Table/components/TableHead/utils.ts +42 -0
- package/src/components/Table/components/TableRow/tableRow.styles.ts +19 -2
- package/src/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +8 -2
- package/src/components/Table/components/TableRows/components/CollapsableRows/hook.ts +20 -0
- package/src/components/Table/components/TableRows/tableRows.tsx +18 -15
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.styles.ts +17 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.tsx +54 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.tsx +28 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.ts +8 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/constants.ts +17 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/types.ts +5 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/utils.ts +45 -0
- package/src/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.tsx +7 -20
- package/src/components/Table/components/TableToolbar/tableToolbar.tsx +8 -2
- package/src/components/Table/features/RowPosition/constants.ts +2 -2
- package/src/components/Table/features/RowPosition/utils.ts +10 -5
- package/src/components/Table/options/updater.ts +29 -0
- package/src/components/Table/table.tsx +43 -25
- package/src/components/TableCreator/common/constants.ts +4 -6
- package/src/components/TableCreator/common/utils.ts +14 -7
- package/src/components/TableCreator/options/expanded/constants.ts +14 -0
- package/src/components/TableCreator/options/expanded/hook.ts +6 -0
- package/src/components/TableCreator/options/grouping/constants.ts +6 -0
- package/src/components/TableCreator/options/grouping/hook.ts +17 -0
- package/src/components/TableCreator/options/hook.ts +31 -0
- package/src/components/TableCreator/options/rowSelection/constants.ts +10 -0
- package/src/components/TableCreator/options/rowSelection/hook.ts +8 -0
- package/src/components/TableCreator/options/sorting/constants.ts +10 -0
- package/src/components/TableCreator/options/sorting/hook.ts +6 -0
- package/src/components/TableCreator/tableCreator.tsx +4 -11
- package/src/components/common/DropdownMenu/dropdownMenu.styles.ts +1 -1
- package/src/components/common/DropdownMenu/dropdownMenu.tsx +19 -17
- package/src/components/common/Menu/hooks/useMenu.ts +8 -9
- package/src/config/entities.ts +11 -10
- package/src/config/utils.ts +0 -14
- package/src/hooks/useCategoryFilter.ts +5 -1
- package/src/hooks/useFileManifest/common/utils.ts +2 -2
- package/src/providers/exploreState/actions/updateGrouping/action.ts +26 -0
- package/src/providers/exploreState/actions/updateGrouping/dispatch.ts +16 -0
- package/src/providers/exploreState/actions/updateGrouping/types.ts +11 -0
- package/src/providers/exploreState/actions/updateGrouping/utils.ts +33 -0
- package/src/providers/exploreState/entities.ts +3 -3
- package/src/providers/exploreState/initializer/utils.ts +58 -10
- package/src/providers/exploreState/payloads/entities.ts +2 -0
- package/src/providers/exploreState/utils.ts +10 -7
- package/src/providers/exploreState.tsx +29 -6
- package/src/providers/fileManifestState.tsx +2 -4
- package/src/viewModelBuilders/common/utils.ts +10 -10
- package/src/views/ExploreView/exploreView.tsx +2 -4
- package/types/data-explorer-ui.d.ts +8 -1
- package/lib/components/TableCreator/common/entities.d.ts +0 -5
- package/src/components/TableCreator/common/entities.ts +0 -6
- /package/lib/components/{TableCreator/common/entities.js → Table/components/TableBody/hooks/virtualizer/types.js} +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GroupingOptions, GroupingState, Updater } from "@tanstack/react-table";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useExploreState } from "../../../../hooks/useExploreState";
|
|
4
|
+
import { updateGrouping } from "../../../../providers/exploreState/actions/updateGrouping/dispatch";
|
|
5
|
+
import { GROUPING_OPTIONS } from "./constants";
|
|
6
|
+
|
|
7
|
+
export function useGroupingOptions(): GroupingOptions {
|
|
8
|
+
const { exploreDispatch } = useExploreState();
|
|
9
|
+
|
|
10
|
+
const onGroupingChange = useCallback(
|
|
11
|
+
(updaterOrValue: Updater<GroupingState>): void =>
|
|
12
|
+
exploreDispatch(updateGrouping({ updaterOrValue })),
|
|
13
|
+
[exploreDispatch]
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return { ...GROUPING_OPTIONS, onGroupingChange };
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RowData, TableOptions } from "@tanstack/react-table";
|
|
2
|
+
import { useConfig } from "../../../hooks/useConfig";
|
|
3
|
+
import { useExpandedOptions } from "./expanded/hook";
|
|
4
|
+
import { useGroupingOptions } from "./grouping/hook";
|
|
5
|
+
import { useRowSelectionOptions } from "./rowSelection/hook";
|
|
6
|
+
import { useSortingOptions } from "./sorting/hook";
|
|
7
|
+
|
|
8
|
+
export function useTableOptions<T extends RowData>(): Partial<TableOptions<T>> {
|
|
9
|
+
const {
|
|
10
|
+
entityConfig: {
|
|
11
|
+
list: { defaultSort, tableOptions },
|
|
12
|
+
},
|
|
13
|
+
} = useConfig();
|
|
14
|
+
const expandedOptions = useExpandedOptions<T>();
|
|
15
|
+
const groupingOptions = useGroupingOptions();
|
|
16
|
+
const rowSelectionOptions = useRowSelectionOptions<T>();
|
|
17
|
+
const sortingOptions = useSortingOptions<T>();
|
|
18
|
+
return {
|
|
19
|
+
...expandedOptions,
|
|
20
|
+
...groupingOptions,
|
|
21
|
+
...rowSelectionOptions,
|
|
22
|
+
...sortingOptions, // TODO(cc) merge of all sorting options.
|
|
23
|
+
...tableOptions,
|
|
24
|
+
initialState: {
|
|
25
|
+
...tableOptions?.initialState,
|
|
26
|
+
sorting: defaultSort
|
|
27
|
+
? [defaultSort] // TODO(cc) deprecate `defaultSort` in favor of `initialState.sorting`.
|
|
28
|
+
: tableOptions?.initialState?.sorting,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RowData, RowSelectionOptions } from "@tanstack/react-table";
|
|
2
|
+
|
|
3
|
+
export const ROW_SELECTION_OPTIONS: Pick<
|
|
4
|
+
RowSelectionOptions<RowData>,
|
|
5
|
+
"enableRowSelection" | "enableSubRowSelection" | "enableMultiRowSelection"
|
|
6
|
+
> = {
|
|
7
|
+
enableMultiRowSelection: false,
|
|
8
|
+
enableRowSelection: false,
|
|
9
|
+
enableSubRowSelection: false,
|
|
10
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RowData, RowSelectionOptions } from "@tanstack/react-table";
|
|
2
|
+
import { ROW_SELECTION_OPTIONS } from "./constants";
|
|
3
|
+
|
|
4
|
+
export function useRowSelectionOptions<
|
|
5
|
+
T extends RowData
|
|
6
|
+
>(): RowSelectionOptions<T> {
|
|
7
|
+
return { ...(ROW_SELECTION_OPTIONS as RowSelectionOptions<T>) };
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RowData, SortingOptions } from "@tanstack/react-table";
|
|
2
|
+
|
|
3
|
+
export const SORTING_OPTIONS: Pick<
|
|
4
|
+
SortingOptions<RowData>,
|
|
5
|
+
"enableSorting" | "enableSortingInteraction" | "enableSortingRemoval"
|
|
6
|
+
> = {
|
|
7
|
+
enableSorting: true,
|
|
8
|
+
enableSortingInteraction: true,
|
|
9
|
+
enableSortingRemoval: false, // false i.e. toggling the sorting on a column will not remove sorting on the column.
|
|
10
|
+
};
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CellContext,
|
|
3
3
|
ColumnDef,
|
|
4
|
-
ColumnSort,
|
|
5
4
|
CoreOptions,
|
|
6
5
|
HeaderContext,
|
|
7
6
|
RowData,
|
|
8
7
|
} from "@tanstack/react-table";
|
|
9
8
|
import React, { useMemo } from "react";
|
|
10
|
-
import {
|
|
11
|
-
ColumnConfig,
|
|
12
|
-
ListConfig,
|
|
13
|
-
ListViewConfig,
|
|
14
|
-
} from "../../config/entities";
|
|
9
|
+
import { ColumnConfig, ListViewConfig } from "../../config/entities";
|
|
15
10
|
import { PAPER_PANEL_STYLE } from "../common/Paper/paper";
|
|
16
11
|
import { ComponentCreator } from "../ComponentCreator/ComponentCreator";
|
|
17
12
|
import { Loading } from "../Loading/loading";
|
|
@@ -26,16 +21,15 @@ import { HeadSelectionCell } from "../Table/components/TableHead/components/Head
|
|
|
26
21
|
import { Table } from "../Table/table";
|
|
27
22
|
import { COLUMN_CONFIGS } from "./common/constants";
|
|
28
23
|
import { buildBaseColumnDef } from "./common/utils";
|
|
24
|
+
import { useTableOptions } from "./options/hook";
|
|
29
25
|
import { TableCreator as TableCreatorContainer } from "./tableCreator.styles";
|
|
30
26
|
|
|
31
27
|
export interface TableCreatorProps<T> {
|
|
32
28
|
columns: ColumnConfig<T>[];
|
|
33
|
-
defaultSort: ColumnSort | undefined;
|
|
34
29
|
getRowId?: CoreOptions<T>["getRowId"];
|
|
35
30
|
items: T[];
|
|
36
31
|
listView?: ListViewConfig;
|
|
37
32
|
loading?: boolean;
|
|
38
|
-
tableOptions?: ListConfig<T>["tableOptions"];
|
|
39
33
|
}
|
|
40
34
|
|
|
41
35
|
const createCell = <T extends RowData = RowData, TData = unknown>(
|
|
@@ -63,13 +57,12 @@ const createRowSelectionCell = <T extends RowData>() =>
|
|
|
63
57
|
|
|
64
58
|
export const TableCreator = <T extends RowData>({
|
|
65
59
|
columns,
|
|
66
|
-
defaultSort,
|
|
67
60
|
getRowId,
|
|
68
61
|
items,
|
|
69
62
|
listView,
|
|
70
63
|
loading,
|
|
71
|
-
tableOptions,
|
|
72
64
|
}: TableCreatorProps<T>): JSX.Element => {
|
|
65
|
+
const tableOptions = useTableOptions<T>();
|
|
73
66
|
const columnDefs: ColumnDef<T>[] = useMemo(
|
|
74
67
|
() =>
|
|
75
68
|
columns.reduce(
|
|
@@ -95,7 +88,7 @@ export const TableCreator = <T extends RowData>({
|
|
|
95
88
|
),
|
|
96
89
|
[columns]
|
|
97
90
|
);
|
|
98
|
-
const initialState = getInitialState(columns
|
|
91
|
+
const initialState = getInitialState(columns);
|
|
99
92
|
return (
|
|
100
93
|
<TableCreatorContainer>
|
|
101
94
|
<Loading
|
|
@@ -1,48 +1,50 @@
|
|
|
1
1
|
import { MenuProps as MMenuProps } from "@mui/material";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { Fragment } from "react";
|
|
3
|
+
import { useMenu } from "../Menu/hooks/useMenu";
|
|
3
4
|
import { DEFAULT_DROPDOWN_MENU_PROPS } from "./common/constants";
|
|
4
5
|
import {
|
|
5
6
|
DropdownMenuButtonProps,
|
|
6
7
|
DropdownMenuIconButtonProps,
|
|
7
8
|
DropdownMenuItemProps,
|
|
8
9
|
} from "./common/entities";
|
|
9
|
-
import {
|
|
10
|
+
import { StyledMenu } from "./dropdownMenu.styles";
|
|
10
11
|
|
|
11
12
|
export interface DropdownMenuProps
|
|
12
13
|
extends Omit<MMenuProps, "children" | "open"> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
button: (
|
|
15
|
+
props:
|
|
16
|
+
| Pick<DropdownMenuButtonProps, "onClick" | "open">
|
|
17
|
+
| Pick<DropdownMenuIconButtonProps, "onClick" | "open">
|
|
18
|
+
) => JSX.Element;
|
|
16
19
|
children?: ({ closeMenu }: DropdownMenuItemProps) => JSX.Element[];
|
|
17
20
|
className?: string;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export const DropdownMenu = ({
|
|
21
|
-
|
|
24
|
+
button,
|
|
22
25
|
children,
|
|
23
26
|
className,
|
|
24
27
|
...props /* Spread props to allow for Mui Menu specific prop overrides e.g. "anchorOrigin". */
|
|
25
28
|
}: DropdownMenuProps): JSX.Element => {
|
|
26
|
-
const
|
|
27
|
-
|
|
29
|
+
const {
|
|
30
|
+
anchorEl,
|
|
31
|
+
onClose: closeMenu,
|
|
32
|
+
onOpen: openMenu,
|
|
33
|
+
open,
|
|
34
|
+
} = useMenu<HTMLButtonElement>();
|
|
28
35
|
return (
|
|
29
36
|
<Fragment>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setAnchorEl(event.currentTarget)
|
|
33
|
-
}
|
|
34
|
-
open={Boolean(anchorEl)}
|
|
35
|
-
/>
|
|
36
|
-
<Menu
|
|
37
|
+
{button({ onClick: openMenu, open })}
|
|
38
|
+
<StyledMenu
|
|
37
39
|
{...DEFAULT_DROPDOWN_MENU_PROPS}
|
|
38
40
|
anchorEl={anchorEl}
|
|
39
41
|
className={className}
|
|
40
42
|
onClose={closeMenu}
|
|
41
|
-
open={
|
|
43
|
+
open={open}
|
|
42
44
|
{...props}
|
|
43
45
|
>
|
|
44
46
|
{children ? children({ closeMenu }) : null}
|
|
45
|
-
</
|
|
47
|
+
</StyledMenu>
|
|
46
48
|
</Fragment>
|
|
47
49
|
);
|
|
48
50
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { PopperProps as MPopperProps } from "@mui/material";
|
|
2
1
|
import { MouseEvent, useCallback, useMemo, useState } from "react";
|
|
3
2
|
|
|
4
|
-
export interface UseMenu {
|
|
5
|
-
anchorEl:
|
|
3
|
+
export interface UseMenu<E extends HTMLElement> {
|
|
4
|
+
anchorEl: E | null;
|
|
6
5
|
onClose: () => void;
|
|
7
6
|
onDisableScrollLock: () => void;
|
|
8
7
|
onEnableScrollLock: () => void;
|
|
9
|
-
onOpen: (event: MouseEvent<
|
|
10
|
-
onToggleOpen: (event: MouseEvent<
|
|
8
|
+
onOpen: (event: MouseEvent<E>) => void;
|
|
9
|
+
onToggleOpen: (event: MouseEvent<E>) => void;
|
|
11
10
|
open: boolean;
|
|
12
11
|
}
|
|
13
12
|
|
|
@@ -15,8 +14,8 @@ export interface UseMenu {
|
|
|
15
14
|
* Menu functionality for menu dropdown, with menu position.
|
|
16
15
|
* @returns menu functionality.
|
|
17
16
|
*/
|
|
18
|
-
export const useMenu = (): UseMenu => {
|
|
19
|
-
const [anchorEl, setAnchorEl] = useState<
|
|
17
|
+
export const useMenu = <E extends HTMLElement>(): UseMenu<E> => {
|
|
18
|
+
const [anchorEl, setAnchorEl] = useState<E | null>(null);
|
|
20
19
|
const open = useMemo(() => Boolean(anchorEl), [anchorEl]);
|
|
21
20
|
|
|
22
21
|
// Closes menu.
|
|
@@ -35,13 +34,13 @@ export const useMenu = (): UseMenu => {
|
|
|
35
34
|
}, []);
|
|
36
35
|
|
|
37
36
|
// Opens menu.
|
|
38
|
-
const onOpen = useCallback((event: MouseEvent<
|
|
37
|
+
const onOpen = useCallback((event: MouseEvent<E>): void => {
|
|
39
38
|
setAnchorEl(event.currentTarget);
|
|
40
39
|
}, []);
|
|
41
40
|
|
|
42
41
|
// Toggles menu open/close.
|
|
43
42
|
const onToggleOpen = useCallback(
|
|
44
|
-
(event: MouseEvent<
|
|
43
|
+
(event: MouseEvent<E>): void => {
|
|
45
44
|
if (open) {
|
|
46
45
|
setAnchorEl(null);
|
|
47
46
|
} else {
|
package/src/config/entities.ts
CHANGED
|
@@ -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
|
|
92
|
-
|
|
93
|
-
|
|
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
|
}
|
|
@@ -324,7 +325,7 @@ export interface TrackFilterAppliedPayload {
|
|
|
324
325
|
searchTerm: string;
|
|
325
326
|
section: string;
|
|
326
327
|
selected: boolean;
|
|
327
|
-
value:
|
|
328
|
+
value: unknown;
|
|
328
329
|
}
|
|
329
330
|
|
|
330
331
|
/**
|
package/src/config/utils.ts
CHANGED
|
@@ -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.
|
|
@@ -273,7 +273,11 @@ function sortCategoryValueViews(
|
|
|
273
273
|
cvv0: SelectCategoryValueView,
|
|
274
274
|
cvv1: SelectCategoryValueView
|
|
275
275
|
): number {
|
|
276
|
-
return
|
|
276
|
+
return !cvv0.label
|
|
277
|
+
? 1
|
|
278
|
+
: !cvv1.label
|
|
279
|
+
? -1
|
|
280
|
+
: COLLATOR_CASE_INSENSITIVE.compare(cvv0.label, cvv1.label);
|
|
277
281
|
}
|
|
278
282
|
|
|
279
283
|
/**
|
|
@@ -70,7 +70,7 @@ function bindFacets(
|
|
|
70
70
|
function bindFacetTerms(
|
|
71
71
|
facetName: string,
|
|
72
72
|
responseTerms: AzulTerm[],
|
|
73
|
-
searchTermNames:
|
|
73
|
+
searchTermNames: unknown[]
|
|
74
74
|
): Term[] {
|
|
75
75
|
return responseTerms.reduce((accum: Term[], responseTerm) => {
|
|
76
76
|
// Default term name to "Unspecified" if term name is null.
|
|
@@ -203,7 +203,7 @@ export function isFacetTermSelected(
|
|
|
203
203
|
function listFacetSearchTermNames(
|
|
204
204
|
facetName: string,
|
|
205
205
|
searchTermsBySearchKey: SelectedSearchTermsBySearchKey
|
|
206
|
-
):
|
|
206
|
+
): unknown[] {
|
|
207
207
|
return [...(searchTermsBySearchKey.get(facetName) ?? [])];
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -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
|
|
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 {
|
|
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, {
|
|
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: {
|
|
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 `
|
|
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:
|
|
191
|
+
enableRowSelection: initEnableRowSelection(entity),
|
|
192
|
+
grouping: initGrouping(entity),
|
|
173
193
|
rowPreview: undefined,
|
|
174
194
|
rowSelection: {},
|
|
175
|
-
sorting:
|
|
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
|
/**
|