@databiosphere/findable-ui 20.0.0 → 21.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 +11 -0
- package/lib/components/Table/common/columnDef.js +18 -2
- package/lib/components/Table/common/columnIdentifier.d.ts +4 -0
- package/lib/components/Table/common/columnIdentifier.js +4 -0
- package/lib/components/Table/common/typeGuards.d.ts +11 -0
- package/lib/components/Table/common/typeGuards.js +8 -0
- package/lib/components/Table/common/utils.d.ts +1 -28
- package/lib/components/Table/common/utils.js +5 -88
- package/lib/components/Table/components/TableCell/common/utils.js +3 -3
- package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.d.ts +2 -5
- package/lib/components/Table/components/TableFeatures/ColumnVisibility/utils.d.ts +7 -18
- package/lib/components/Table/components/TableFeatures/ColumnVisibility/utils.js +20 -31
- package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.d.ts +2 -5
- package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.js +2 -2
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.js +5 -17
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/constants.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/constants.js +10 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.d.ts +1 -1
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.js +22 -10
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.d.ts +1 -2
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/utils.d.ts +27 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/utils.js +45 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/constants.d.ts +1 -3
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/constants.js +0 -10
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/utils.d.ts +3 -13
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/utils.js +22 -27
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.js +13 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.styles.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.styles.js +11 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/constants.d.ts +2 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/constants.js +7 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.js +22 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.styles.d.ts +2 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.styles.js +16 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/types.d.ts +4 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/types.js +1 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/utils.d.ts +26 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/utils.js +32 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/constants.d.ts +2 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/constants.js +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/types.d.ts +4 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/types.js +1 -0
- package/lib/components/Table/components/TableToolbar/tableToolbar.js +5 -12
- package/lib/components/Table/features/RowPosition/constants.js +5 -3
- package/lib/components/Table/features/RowPosition/types.d.ts +3 -0
- package/lib/components/Table/features/RowPosition/utils.d.ts +1 -7
- package/lib/components/Table/features/RowPosition/utils.js +0 -20
- package/lib/components/Table/features/RowPreview/constants.js +1 -1
- package/lib/components/Table/features/entities.d.ts +2 -2
- package/lib/components/Table/table.d.ts +2 -4
- package/lib/components/Table/table.js +9 -31
- package/lib/components/TableCreator/common/utils.js +1 -4
- package/lib/components/TableCreator/options/columnTrackSizing/typeGuards.d.ts +7 -0
- package/lib/components/TableCreator/options/columnTrackSizing/typeGuards.js +8 -0
- package/lib/components/TableCreator/options/columnTrackSizing/utils.d.ts +30 -0
- package/lib/components/TableCreator/options/columnTrackSizing/utils.js +83 -0
- package/lib/components/TableCreator/options/hook.js +8 -7
- package/lib/components/TableCreator/options/initialState/columnVisibility.d.ts +7 -0
- package/lib/components/TableCreator/options/initialState/columnVisibility.js +16 -0
- package/lib/components/TableCreator/options/initialState/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/initialState/hook.js +10 -0
- package/lib/components/TableCreator/options/visibility/constants.d.ts +2 -0
- package/lib/components/TableCreator/options/visibility/constants.js +3 -0
- package/lib/components/TableCreator/options/visibility/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/visibility/hook.js +11 -0
- package/lib/components/TableCreator/tableCreator.js +4 -18
- package/lib/config/entities.d.ts +0 -4
- package/lib/providers/exploreState/actions/updateVisibility/action.d.ts +10 -0
- package/lib/providers/exploreState/actions/updateVisibility/action.js +16 -0
- package/lib/providers/exploreState/actions/updateVisibility/dispatch.d.ts +7 -0
- package/lib/providers/exploreState/actions/updateVisibility/dispatch.js +12 -0
- package/lib/providers/exploreState/actions/updateVisibility/types.d.ts +9 -0
- package/lib/providers/exploreState/actions/updateVisibility/types.js +1 -0
- package/lib/providers/exploreState/actions/updateVisibility/utils.d.ts +10 -0
- package/lib/providers/exploreState/actions/updateVisibility/utils.js +21 -0
- package/lib/providers/exploreState/entities.d.ts +1 -1
- package/lib/providers/exploreState/initializer/utils.js +5 -13
- package/lib/providers/exploreState/payloads/entities.d.ts +1 -5
- package/lib/providers/exploreState/utils.d.ts +1 -1
- package/lib/providers/exploreState/utils.js +5 -5
- package/lib/providers/exploreState.d.ts +2 -8
- package/lib/providers/exploreState.js +2 -5
- package/package.json +1 -1
- package/src/components/Table/common/columnDef.ts +18 -2
- package/src/components/Table/common/columnIdentifier.ts +4 -0
- package/src/components/Table/common/typeGuards.ts +12 -0
- package/src/components/Table/common/utils.ts +5 -115
- package/src/components/Table/components/TableCell/common/utils.ts +3 -3
- package/src/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.tsx +3 -7
- package/src/components/Table/components/TableFeatures/ColumnVisibility/utils.ts +25 -44
- package/src/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.tsx +5 -9
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.tsx +4 -22
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/constants.ts +13 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.tsx +47 -20
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.ts +1 -2
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/utils.ts +58 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/constants.ts +1 -13
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/utils.ts +26 -33
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.styles.ts +12 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.tsx +28 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/constants.ts +9 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.styles.ts +17 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.tsx +53 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/types.ts +5 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/utils.ts +44 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/constants.ts +5 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/types.ts +5 -0
- package/src/components/Table/components/TableToolbar/tableToolbar.tsx +5 -19
- package/src/components/Table/features/RowPosition/constants.ts +8 -5
- package/src/components/Table/features/RowPosition/types.ts +4 -0
- package/src/components/Table/features/RowPosition/utils.ts +1 -30
- package/src/components/Table/features/RowPreview/constants.ts +1 -1
- package/src/components/Table/features/entities.ts +2 -2
- package/src/components/Table/table.tsx +8 -46
- package/src/components/TableCreator/common/utils.ts +0 -4
- package/src/components/TableCreator/options/columnTrackSizing/typeGuards.ts +12 -0
- package/src/components/TableCreator/options/columnTrackSizing/utils.ts +99 -0
- package/src/components/TableCreator/options/hook.ts +8 -11
- package/src/components/TableCreator/options/initialState/columnVisibility.ts +22 -0
- package/src/components/TableCreator/options/initialState/hook.ts +24 -0
- package/src/components/TableCreator/options/visibility/constants.ts +5 -0
- package/src/components/TableCreator/options/visibility/hook.ts +22 -0
- package/src/components/TableCreator/tableCreator.tsx +3 -27
- package/src/config/entities.ts +2 -4
- package/src/providers/exploreState/actions/updateVisibility/action.ts +29 -0
- package/src/providers/exploreState/actions/updateVisibility/dispatch.ts +19 -0
- package/src/providers/exploreState/actions/updateVisibility/types.ts +11 -0
- package/src/providers/exploreState/actions/updateVisibility/utils.ts +28 -0
- package/src/providers/exploreState/entities.ts +1 -1
- package/src/providers/exploreState/initializer/utils.ts +5 -21
- package/src/providers/exploreState/payloads/entities.ts +0 -6
- package/src/providers/exploreState/utils.ts +5 -5
- package/src/providers/exploreState.tsx +3 -18
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.d.ts +0 -16
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +0 -28
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.d.ts +0 -5
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.js +0 -46
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +0 -3
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +0 -21
- package/lib/components/Table/features/constants.d.ts +0 -6
- package/lib/components/Table/features/constants.js +0 -8
- package/lib/components/TableCreator/common/constants.d.ts +0 -7
- package/lib/components/TableCreator/common/constants.js +0 -21
- package/src/components/Table/components/CheckboxMenu/checkboxMenu.stories.tsx +0 -54
- package/src/components/Table/components/CheckboxMenu/checkboxMenu.styles.ts +0 -22
- package/src/components/Table/components/CheckboxMenu/checkboxMenu.tsx +0 -87
- package/src/components/Table/features/constants.ts +0 -10
- package/src/components/TableCreator/common/constants.ts +0 -25
- /package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/{columnGrouping.styles.d.ts → components/MenuItems/menuItems.styles.d.ts} +0 -0
- /package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/{columnGrouping.styles.js → components/MenuItems/menuItems.styles.js} +0 -0
- /package/src/components/Table/components/TableToolbar/components/ColumnGrouping/{columnGrouping.styles.ts → components/MenuItems/menuItems.styles.ts} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RowData, TableOptions, VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import { COLUMN_IDENTIFIER } from "../../../Table/common/columnIdentifier";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns initial column visibility state.
|
|
6
|
+
* @param tableOptions - Table options.
|
|
7
|
+
* @returns column visibility state.
|
|
8
|
+
*/
|
|
9
|
+
export function getInitialColumnVisibilityState<T extends RowData>(
|
|
10
|
+
tableOptions?:
|
|
11
|
+
| Partial<TableOptions<T>>
|
|
12
|
+
| Partial<Omit<TableOptions<T>, "data" | "columns" | "getCoreRowModel">>
|
|
13
|
+
): VisibilityState {
|
|
14
|
+
const { initialState } = tableOptions || {};
|
|
15
|
+
const enableRowPosition = Boolean(tableOptions?.enableRowPosition);
|
|
16
|
+
const enableRowSelection = Boolean(tableOptions?.enableRowSelection);
|
|
17
|
+
return {
|
|
18
|
+
[COLUMN_IDENTIFIER.ROW_POSITION]: enableRowPosition,
|
|
19
|
+
[COLUMN_IDENTIFIER.ROW_SELECTION]: enableRowSelection,
|
|
20
|
+
...initialState?.columnVisibility,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InitialTableState,
|
|
3
|
+
RowData,
|
|
4
|
+
TableOptions,
|
|
5
|
+
} from "@tanstack/react-table";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import { getInitialColumnVisibilityState } from "./columnVisibility";
|
|
8
|
+
|
|
9
|
+
export function useInitialState<T extends RowData>(
|
|
10
|
+
tableOptions?:
|
|
11
|
+
| Partial<TableOptions<T>>
|
|
12
|
+
| Partial<Omit<TableOptions<T>, "data" | "columns" | "getCoreRowModel">>
|
|
13
|
+
): InitialTableState {
|
|
14
|
+
const { initialState } = tableOptions || {};
|
|
15
|
+
const columnVisibility = getInitialColumnVisibilityState(tableOptions);
|
|
16
|
+
|
|
17
|
+
return useMemo(
|
|
18
|
+
() => ({
|
|
19
|
+
...initialState,
|
|
20
|
+
columnVisibility,
|
|
21
|
+
}),
|
|
22
|
+
[initialState, columnVisibility]
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Updater,
|
|
3
|
+
VisibilityOptions,
|
|
4
|
+
VisibilityState,
|
|
5
|
+
} from "@tanstack/react-table";
|
|
6
|
+
import { useCallback } from "react";
|
|
7
|
+
import { useExploreState } from "../../../../hooks/useExploreState";
|
|
8
|
+
import { updateVisibility } from "../../../../providers/exploreState/actions/updateVisibility/dispatch";
|
|
9
|
+
import { VISIBILITY_OPTIONS } from "./constants";
|
|
10
|
+
|
|
11
|
+
export function useVisibilityOptions(): VisibilityOptions {
|
|
12
|
+
const { exploreDispatch } = useExploreState();
|
|
13
|
+
|
|
14
|
+
const onColumnVisibilityChange = useCallback(
|
|
15
|
+
(updaterOrValue: Updater<VisibilityState>): void => {
|
|
16
|
+
exploreDispatch(updateVisibility({ updaterOrValue }));
|
|
17
|
+
},
|
|
18
|
+
[exploreDispatch]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
return { ...VISIBILITY_OPTIONS, onColumnVisibilityChange };
|
|
22
|
+
}
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
CellContext,
|
|
3
3
|
ColumnDef,
|
|
4
4
|
CoreOptions,
|
|
5
|
-
HeaderContext,
|
|
6
5
|
RowData,
|
|
7
6
|
} from "@tanstack/react-table";
|
|
8
7
|
import React, { useMemo } from "react";
|
|
@@ -11,15 +10,8 @@ import { PAPER_PANEL_STYLE } from "../common/Paper/paper";
|
|
|
11
10
|
import { ComponentCreator } from "../ComponentCreator/ComponentCreator";
|
|
12
11
|
import { Loading } from "../Loading/loading";
|
|
13
12
|
import { COLUMN_DEF } from "../Table/common/columnDef";
|
|
14
|
-
import {
|
|
15
|
-
arrIncludesSome,
|
|
16
|
-
getInitialState,
|
|
17
|
-
sortingFn,
|
|
18
|
-
} from "../Table/common/utils";
|
|
19
|
-
import { RowSelectionCell } from "../Table/components/TableCell/components/RowSelectionCell/rowSelectionCell";
|
|
20
|
-
import { HeadSelectionCell } from "../Table/components/TableHead/components/HeadSelectionCell/headSelectionCell";
|
|
13
|
+
import { arrIncludesSome, sortingFn } from "../Table/common/utils";
|
|
21
14
|
import { Table } from "../Table/table";
|
|
22
|
-
import { COLUMN_CONFIGS } from "./common/constants";
|
|
23
15
|
import { buildBaseColumnDef } from "./common/utils";
|
|
24
16
|
import { useTableOptions } from "./options/hook";
|
|
25
17
|
import { TableCreator as TableCreatorContainer } from "./tableCreator.styles";
|
|
@@ -45,16 +37,6 @@ const createCell = <T extends RowData = RowData, TData = unknown>(
|
|
|
45
37
|
);
|
|
46
38
|
};
|
|
47
39
|
|
|
48
|
-
const createHeaderSelectionCell = <T extends RowData>() =>
|
|
49
|
-
function CellCreator({ table }: HeaderContext<T, unknown>): JSX.Element {
|
|
50
|
-
return <HeadSelectionCell tableInstance={table} />;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const createRowSelectionCell = <T extends RowData>() =>
|
|
54
|
-
function CellCreator({ row }: CellContext<T, unknown>): JSX.Element {
|
|
55
|
-
return <RowSelectionCell row={row} />;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
40
|
export const TableCreator = <T extends RowData>({
|
|
59
41
|
columns,
|
|
60
42
|
getRowId,
|
|
@@ -78,17 +60,12 @@ export const TableCreator = <T extends RowData>({
|
|
|
78
60
|
[
|
|
79
61
|
/* Initialize column definitions with the "row position" column */
|
|
80
62
|
COLUMN_DEF.ROW_POSITION,
|
|
81
|
-
/* Initialize column definitions with the "
|
|
82
|
-
|
|
83
|
-
...buildBaseColumnDef(COLUMN_CONFIGS.SELECT),
|
|
84
|
-
cell: createRowSelectionCell(),
|
|
85
|
-
header: createHeaderSelectionCell(),
|
|
86
|
-
},
|
|
63
|
+
/* Initialize column definitions with the "row selection" column */
|
|
64
|
+
COLUMN_DEF.ROW_SELECTION,
|
|
87
65
|
] as ColumnDef<T>[]
|
|
88
66
|
),
|
|
89
67
|
[columns]
|
|
90
68
|
);
|
|
91
|
-
const initialState = getInitialState(columns);
|
|
92
69
|
return (
|
|
93
70
|
<TableCreatorContainer>
|
|
94
71
|
<Loading
|
|
@@ -99,7 +76,6 @@ export const TableCreator = <T extends RowData>({
|
|
|
99
76
|
<Table<T>
|
|
100
77
|
columns={columnDefs}
|
|
101
78
|
getRowId={getRowId}
|
|
102
|
-
initialState={initialState}
|
|
103
79
|
items={items}
|
|
104
80
|
listView={listView}
|
|
105
81
|
loading={loading}
|
package/src/config/entities.ts
CHANGED
|
@@ -105,13 +105,13 @@ export type ColumnConfig<
|
|
|
105
105
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This config model is part of a generic array
|
|
106
106
|
C extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = any
|
|
107
107
|
> = Omit<ColumnDef<T, TValue>, "enableMultiSort"> & {
|
|
108
|
+
// @deprecated - Use `meta.columnPinned` instead.
|
|
108
109
|
columnPinned?: boolean; // Column is pinned to the top when table rows are collapsable.
|
|
109
|
-
columnVisible?: boolean; // Column is visible. Default is "true".
|
|
110
110
|
componentConfig: ComponentConfig<C, T>;
|
|
111
|
-
disableHiding?: boolean; // Disables hiding of column. Column is unavailable for "Edit Columns" functionality when "true".
|
|
112
111
|
header: string;
|
|
113
112
|
id: string; // The unique identifier for the column.
|
|
114
113
|
meta?: ColumnMeta<T, unknown>;
|
|
114
|
+
// @deprecated - Use `meta.width` instead.
|
|
115
115
|
width: GridTrackSize;
|
|
116
116
|
};
|
|
117
117
|
|
|
@@ -258,7 +258,6 @@ export type GridTrackSize =
|
|
|
258
258
|
*/
|
|
259
259
|
export interface ListConfig<T extends RowData> {
|
|
260
260
|
columns: ColumnConfig<T>[];
|
|
261
|
-
defaultSort?: ColumnSort; // Establishes initial table state "sorting" state.
|
|
262
261
|
tableOptions?: Omit<TableOptions<T>, "columns" | "data" | "getCoreRowModel">; // Additional TanStack Table's options.
|
|
263
262
|
}
|
|
264
263
|
|
|
@@ -268,7 +267,6 @@ export interface ListConfig<T extends RowData> {
|
|
|
268
267
|
export interface ListViewConfig {
|
|
269
268
|
disablePagination?: boolean;
|
|
270
269
|
enableDownload?: boolean;
|
|
271
|
-
enableRowPreview?: boolean;
|
|
272
270
|
enableTab?: boolean;
|
|
273
271
|
listHero?: ComponentsConfig;
|
|
274
272
|
rowPreviewView?: ComponentsConfig; // Row preview view is expected to be a modal or drawer or similar.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ExploreState } from "../../../exploreState";
|
|
2
|
+
import { updateEntityPageState } from "../../utils";
|
|
3
|
+
import { UpdateColumnVisibilityPayload } from "./types";
|
|
4
|
+
import { buildNextColumnVisibility } from "./utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reducer function to handle the "update column visibility" action.
|
|
8
|
+
* Updates the column visibility in the state for the current entity.
|
|
9
|
+
* @param state - Explore State.
|
|
10
|
+
* @param payload - Payload.
|
|
11
|
+
* @returns explore state.
|
|
12
|
+
*/
|
|
13
|
+
export function updateColumnVisibilityAction(
|
|
14
|
+
state: ExploreState,
|
|
15
|
+
payload: UpdateColumnVisibilityPayload
|
|
16
|
+
): ExploreState {
|
|
17
|
+
const columnVisibility = buildNextColumnVisibility(
|
|
18
|
+
state,
|
|
19
|
+
payload.updaterOrValue
|
|
20
|
+
);
|
|
21
|
+
return {
|
|
22
|
+
...state,
|
|
23
|
+
entityPageState: updateEntityPageState(
|
|
24
|
+
state.tabValue,
|
|
25
|
+
state.entityPageState,
|
|
26
|
+
{ columnVisibility }
|
|
27
|
+
),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ExploreActionKind } from "../../../exploreState";
|
|
2
|
+
import {
|
|
3
|
+
UpdateColumnVisibilityAction,
|
|
4
|
+
UpdateColumnVisibilityPayload,
|
|
5
|
+
} from "./types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Action creator for updating column visibility in the state.
|
|
9
|
+
* @param payload - Payload.
|
|
10
|
+
* @returns Action with payload and action type.
|
|
11
|
+
*/
|
|
12
|
+
export function updateVisibility(
|
|
13
|
+
payload: UpdateColumnVisibilityPayload
|
|
14
|
+
): UpdateColumnVisibilityAction {
|
|
15
|
+
return {
|
|
16
|
+
payload,
|
|
17
|
+
type: ExploreActionKind.UpdateColumnVisibility,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Updater, VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import { ExploreActionKind } from "../../../exploreState";
|
|
3
|
+
|
|
4
|
+
export type UpdateColumnVisibilityAction = {
|
|
5
|
+
payload: UpdateColumnVisibilityPayload;
|
|
6
|
+
type: ExploreActionKind.UpdateColumnVisibility;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type UpdateColumnVisibilityPayload = {
|
|
10
|
+
updaterOrValue: Updater<VisibilityState>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Updater, VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import { resolveUpdater } from "../../../../components/Table/options/updater";
|
|
3
|
+
import { ExploreState } from "../../../exploreState";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Builds the next column visibility state for the current entity type.
|
|
7
|
+
* Uses TanStack updater to update the column visibility state.
|
|
8
|
+
* @param state - Explore state.
|
|
9
|
+
* @param updaterOrValue - Updater or value to update the column visibility state.
|
|
10
|
+
* @returns column visibility state.
|
|
11
|
+
*/
|
|
12
|
+
export function buildNextColumnVisibility(
|
|
13
|
+
state: ExploreState,
|
|
14
|
+
updaterOrValue: Updater<VisibilityState>
|
|
15
|
+
): VisibilityState {
|
|
16
|
+
return resolveUpdater(updaterOrValue, getOldColumnVisibility(state));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the current "old" state from the explore state, for the current entity type.
|
|
21
|
+
* @param state - Explore state.
|
|
22
|
+
* @returns old column visibility state.
|
|
23
|
+
*/
|
|
24
|
+
function getOldColumnVisibility(state: ExploreState): VisibilityState {
|
|
25
|
+
const { entityPageState, tabValue } = state;
|
|
26
|
+
const { columnVisibility = {} } = entityPageState[tabValue];
|
|
27
|
+
return columnVisibility;
|
|
28
|
+
}
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
|
|
22
22
|
export interface EntityPageState {
|
|
23
23
|
categoryGroupConfigKey: CategoryGroupConfigKey;
|
|
24
|
-
|
|
24
|
+
columnVisibility: VisibilityState;
|
|
25
25
|
enableRowSelection: boolean;
|
|
26
26
|
grouping: GroupingState;
|
|
27
27
|
rowPreview: RowPreviewState;
|
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
VisibilityState,
|
|
5
5
|
} from "@tanstack/react-table";
|
|
6
6
|
import { SelectCategory, SelectedFilter } from "../../../common/entities";
|
|
7
|
-
import {
|
|
8
|
-
import { ACCESSOR_KEYS } from "../../../components/TableCreator/common/constants";
|
|
7
|
+
import { getInitialColumnVisibilityState } from "../../../components/TableCreator/options/initialState/columnVisibility";
|
|
9
8
|
import {
|
|
10
9
|
CategoryConfig,
|
|
11
10
|
CategoryGroup,
|
|
@@ -151,20 +150,9 @@ function initCategoryGroups(
|
|
|
151
150
|
*/
|
|
152
151
|
function initColumnVisibility(entityConfig: EntityConfig): VisibilityState {
|
|
153
152
|
const {
|
|
154
|
-
list: {
|
|
155
|
-
columns,
|
|
156
|
-
tableOptions: {
|
|
157
|
-
enableRowSelection,
|
|
158
|
-
initialState: { columnVisibility = {} } = {},
|
|
159
|
-
} = {},
|
|
160
|
-
},
|
|
153
|
+
list: { tableOptions = {} },
|
|
161
154
|
} = entityConfig;
|
|
162
|
-
return
|
|
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),
|
|
165
|
-
...getInitialTableColumnVisibility(columns),
|
|
166
|
-
...columnVisibility, // `columnVisibility` is managed by ExploreState; use table options to override this setting.
|
|
167
|
-
};
|
|
155
|
+
return getInitialColumnVisibilityState(tableOptions);
|
|
168
156
|
}
|
|
169
157
|
|
|
170
158
|
/**
|
|
@@ -187,7 +175,7 @@ function initEntityPageState(config: SiteConfig): EntityPageStateMapper {
|
|
|
187
175
|
...acc,
|
|
188
176
|
[entity.route]: {
|
|
189
177
|
categoryGroupConfigKey: initCategoryGroupConfigKey(config, entity),
|
|
190
|
-
|
|
178
|
+
columnVisibility: initColumnVisibility(entity),
|
|
191
179
|
enableRowSelection: initEnableRowSelection(entity),
|
|
192
180
|
grouping: initGrouping(entity),
|
|
193
181
|
rowPreview: undefined,
|
|
@@ -269,12 +257,8 @@ function initGrouping(entityConfig: EntityConfig): GroupingState {
|
|
|
269
257
|
*/
|
|
270
258
|
function initSorting(entityConfig: EntityConfig): ColumnSort[] {
|
|
271
259
|
const {
|
|
272
|
-
list: {
|
|
273
|
-
defaultSort,
|
|
274
|
-
tableOptions: { initialState: { sorting = [] } = {} } = {},
|
|
275
|
-
},
|
|
260
|
+
list: { tableOptions: { initialState: { sorting = [] } = {} } = {} },
|
|
276
261
|
} = entityConfig;
|
|
277
|
-
if (defaultSort) return [defaultSort];
|
|
278
262
|
return sorting;
|
|
279
263
|
}
|
|
280
264
|
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
ColumnSort,
|
|
3
3
|
GroupingState,
|
|
4
4
|
RowSelectionState,
|
|
5
|
-
VisibilityState,
|
|
6
5
|
} from "@tanstack/react-table";
|
|
7
6
|
import {
|
|
8
7
|
CategoryKey,
|
|
@@ -52,11 +51,6 @@ export interface ProcessExploreResponsePayload {
|
|
|
52
51
|
*/
|
|
53
52
|
export type ResetExploreResponsePayload = undefined;
|
|
54
53
|
|
|
55
|
-
/**
|
|
56
|
-
* Update column visibility payload.
|
|
57
|
-
*/
|
|
58
|
-
export type UpdateColumnVisibilityPayload = VisibilityState;
|
|
59
|
-
|
|
60
54
|
/**
|
|
61
55
|
* Update entity filters payload.
|
|
62
56
|
*/
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
CategoryValueKey,
|
|
4
4
|
SelectedFilter,
|
|
5
5
|
} from "../../common/entities";
|
|
6
|
+
import { COLUMN_IDENTIFIER } from "../../components/Table/common/columnIdentifier";
|
|
6
7
|
import { RowPreviewState } from "../../components/Table/features/RowPreview/entities";
|
|
7
|
-
import { ACCESSOR_KEYS } from "../../components/TableCreator/common/constants";
|
|
8
8
|
import { ExploreState, ListItems, PaginationState } from "../exploreState";
|
|
9
9
|
import {
|
|
10
10
|
CategoryGroupConfigKey,
|
|
@@ -264,7 +264,7 @@ export function updateEntityStateByCategoryGroupConfigKey(
|
|
|
264
264
|
|
|
265
265
|
/**
|
|
266
266
|
* Updates the entity page state for each entity with row selection enabled,
|
|
267
|
-
* by updating the visibility of the "
|
|
267
|
+
* by updating the visibility of the "rowSelection" column based on user access and resetting row selection state.
|
|
268
268
|
* @param state - Explore state.
|
|
269
269
|
* @param canEdit - User has edit access.
|
|
270
270
|
* @returns new entity page state mapper with updated column visibility and row selection state.
|
|
@@ -280,9 +280,9 @@ export function updateSelectColumnVisibility(
|
|
|
280
280
|
...acc,
|
|
281
281
|
[entityPath]: {
|
|
282
282
|
...entityPageState,
|
|
283
|
-
|
|
284
|
-
...entityPageState.
|
|
285
|
-
[
|
|
283
|
+
columnVisibility: {
|
|
284
|
+
...entityPageState.columnVisibility,
|
|
285
|
+
[COLUMN_IDENTIFIER.ROW_SELECTION]: canEdit,
|
|
286
286
|
},
|
|
287
287
|
rowSelection: {},
|
|
288
288
|
},
|
|
@@ -21,6 +21,8 @@ import { useConfig } from "../hooks/useConfig";
|
|
|
21
21
|
import { useURLFilterParams } from "../hooks/useURLFilterParams";
|
|
22
22
|
import { updateGroupingAction } from "./exploreState/actions/updateGrouping/action";
|
|
23
23
|
import { UpdateGroupingAction } from "./exploreState/actions/updateGrouping/types";
|
|
24
|
+
import { updateColumnVisibilityAction } from "./exploreState/actions/updateVisibility/action";
|
|
25
|
+
import { UpdateColumnVisibilityAction } from "./exploreState/actions/updateVisibility/types";
|
|
24
26
|
import {
|
|
25
27
|
EntityPageStateMapper,
|
|
26
28
|
EntityStateByCategoryGroupConfigKey,
|
|
@@ -37,7 +39,6 @@ import {
|
|
|
37
39
|
PatchExploreResponsePayload,
|
|
38
40
|
ProcessExploreResponsePayload,
|
|
39
41
|
ResetExploreResponsePayload,
|
|
40
|
-
UpdateColumnVisibilityPayload,
|
|
41
42
|
UpdateEntityFiltersPayload,
|
|
42
43
|
UpdateEntityViewAccessPayload,
|
|
43
44
|
UpdateFilterPayload,
|
|
@@ -318,14 +319,6 @@ type SelectEntityTypeAction = {
|
|
|
318
319
|
type: ExploreActionKind.SelectEntityType;
|
|
319
320
|
};
|
|
320
321
|
|
|
321
|
-
/**
|
|
322
|
-
* Update column visibility action.
|
|
323
|
-
*/
|
|
324
|
-
type UpdateColumnVisibilityAction = {
|
|
325
|
-
payload: UpdateColumnVisibilityPayload;
|
|
326
|
-
type: ExploreActionKind.UpdateColumnVisibility;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
322
|
/**
|
|
330
323
|
* Update entity filters action.
|
|
331
324
|
*/
|
|
@@ -581,15 +574,7 @@ function exploreReducer(
|
|
|
581
574
|
* Update column visibility
|
|
582
575
|
**/
|
|
583
576
|
case ExploreActionKind.UpdateColumnVisibility: {
|
|
584
|
-
|
|
585
|
-
return {
|
|
586
|
-
...state,
|
|
587
|
-
entityPageState: updateEntityPageState(
|
|
588
|
-
state.tabValue,
|
|
589
|
-
state.entityPageState,
|
|
590
|
-
{ columnsVisibility }
|
|
591
|
-
),
|
|
592
|
-
};
|
|
577
|
+
return updateColumnVisibilityAction(state, payload);
|
|
593
578
|
}
|
|
594
579
|
/**
|
|
595
580
|
* Update entity filters.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
type MenuListItemOnChangeFn = (event: unknown) => void;
|
|
2
|
-
type onResetFn = () => void;
|
|
3
|
-
export interface CheckboxMenuListItem {
|
|
4
|
-
checked: boolean;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
label: string;
|
|
7
|
-
onChange: MenuListItemOnChangeFn;
|
|
8
|
-
value: string;
|
|
9
|
-
}
|
|
10
|
-
export interface CheckboxMenuProps {
|
|
11
|
-
label: string;
|
|
12
|
-
onReset: onResetFn;
|
|
13
|
-
options: CheckboxMenuListItem[];
|
|
14
|
-
}
|
|
15
|
-
export declare const CheckboxMenu: ({ label: buttonLabel, onReset, options, }: CheckboxMenuProps) => JSX.Element;
|
|
16
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Checkbox, ListItem, ListItemButton, ListItemText, } from "@mui/material";
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
import { ButtonTextPrimary } from "../../../common/Button/components/ButtonTextPrimary/buttonTextPrimary";
|
|
4
|
-
import { DropdownButton } from "../../../common/Button/components/DropdownButton/dropdownButton";
|
|
5
|
-
import { CheckedIcon } from "../../../common/CustomIcon/components/CheckedIcon/checkedIcon";
|
|
6
|
-
import { UncheckedIcon } from "../../../common/CustomIcon/components/UncheckedIcon/uncheckedIcon";
|
|
7
|
-
import { Menu } from "./checkboxMenu.styles";
|
|
8
|
-
export const CheckboxMenu = ({ label: buttonLabel, onReset, options, }) => {
|
|
9
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
10
|
-
const open = Boolean(anchorEl);
|
|
11
|
-
const onOpenMenu = (event) => {
|
|
12
|
-
setAnchorEl(event.currentTarget);
|
|
13
|
-
};
|
|
14
|
-
const onCloseMenu = () => {
|
|
15
|
-
setAnchorEl(null);
|
|
16
|
-
};
|
|
17
|
-
return (React.createElement(React.Fragment, null,
|
|
18
|
-
React.createElement(DropdownButton, { onClick: onOpenMenu, open: open }, buttonLabel),
|
|
19
|
-
React.createElement(Menu, { anchorEl: anchorEl, anchorOrigin: { horizontal: "right", vertical: "bottom" }, onClose: onCloseMenu, open: open, slotProps: { paper: { variant: "menu" } }, transformOrigin: {
|
|
20
|
-
horizontal: "right",
|
|
21
|
-
vertical: "top",
|
|
22
|
-
} },
|
|
23
|
-
options.map(({ checked, disabled = false, label, onChange, value }) => (React.createElement(ListItemButton, { disabled: disabled, key: value, onClick: onChange, role: undefined },
|
|
24
|
-
React.createElement(Checkbox, { checked: checked, checkedIcon: React.createElement(CheckedIcon, null), disabled: disabled, icon: React.createElement(UncheckedIcon, null) }),
|
|
25
|
-
React.createElement(ListItemText, { disableTypography: true, primary: React.createElement("span", null, label) })))),
|
|
26
|
-
React.createElement(ListItem, { component: "div" },
|
|
27
|
-
React.createElement(ButtonTextPrimary, { onClick: onReset }, "Reset")))));
|
|
28
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ComponentMeta } from "@storybook/react";
|
|
2
|
-
import { CheckboxMenu } from "./checkboxMenu";
|
|
3
|
-
declare const _default: ComponentMeta<typeof CheckboxMenu>;
|
|
4
|
-
export default _default;
|
|
5
|
-
export declare const CheckboxMenuStory: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("./checkboxMenu").CheckboxMenuProps>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { CheckboxMenu } from "./checkboxMenu";
|
|
3
|
-
export default {
|
|
4
|
-
argTypes: {
|
|
5
|
-
label: { control: "text" },
|
|
6
|
-
onReset: { control: { disabled: true } },
|
|
7
|
-
options: { control: "array" },
|
|
8
|
-
},
|
|
9
|
-
component: CheckboxMenu,
|
|
10
|
-
title: "Components/Common/Menu/CheckboxMenu",
|
|
11
|
-
};
|
|
12
|
-
const CheckboxMenuTemplate = (args) => (React.createElement(CheckboxMenu, { ...args }));
|
|
13
|
-
const onChange = () => {
|
|
14
|
-
// onChange function
|
|
15
|
-
};
|
|
16
|
-
const onReset = () => {
|
|
17
|
-
// onReset function
|
|
18
|
-
};
|
|
19
|
-
export const CheckboxMenuStory = CheckboxMenuTemplate.bind({});
|
|
20
|
-
CheckboxMenuStory.args = {
|
|
21
|
-
label: "Options",
|
|
22
|
-
onReset: onReset,
|
|
23
|
-
options: [
|
|
24
|
-
{
|
|
25
|
-
checked: true,
|
|
26
|
-
disabled: true,
|
|
27
|
-
label: "Item 1",
|
|
28
|
-
onChange,
|
|
29
|
-
value: "item_1",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
checked: false,
|
|
33
|
-
disabled: false,
|
|
34
|
-
label: "Item 2",
|
|
35
|
-
onChange,
|
|
36
|
-
value: "item_2",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
checked: true,
|
|
40
|
-
disabled: false,
|
|
41
|
-
label: "Item 3",
|
|
42
|
-
onChange,
|
|
43
|
-
value: "item_3",
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import styled from "@emotion/styled";
|
|
2
|
-
import { Menu as MMenu } from "@mui/material";
|
|
3
|
-
export const Menu = styled(MMenu) `
|
|
4
|
-
.MuiPaper-menu {
|
|
5
|
-
margin: 4px 0;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// List item button
|
|
9
|
-
.MuiListItemButton-root {
|
|
10
|
-
gap: 8px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// List item
|
|
14
|
-
.MuiListItem-root {
|
|
15
|
-
padding: 10px 16px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.MuiListItemButton-root.Mui-disabled {
|
|
19
|
-
opacity: 1;
|
|
20
|
-
}
|
|
21
|
-
`;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RowData } from "@tanstack/react-table";
|
|
2
|
-
import { ColumnConfig } from "../../../config/entities";
|
|
3
|
-
export declare const ACCESSOR_KEYS: {
|
|
4
|
-
ROW_POSITION: string;
|
|
5
|
-
SELECT: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const COLUMN_CONFIGS: Record<string, ColumnConfig<RowData>>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { RowSelectionCell } from "../../Table/components/TableCell/components/RowSelectionCell/rowSelectionCell";
|
|
2
|
-
export const ACCESSOR_KEYS = {
|
|
3
|
-
ROW_POSITION: "rowPosition",
|
|
4
|
-
SELECT: "select",
|
|
5
|
-
};
|
|
6
|
-
export const COLUMN_CONFIGS = {
|
|
7
|
-
SELECT: {
|
|
8
|
-
columnPinned: false,
|
|
9
|
-
columnVisible: false,
|
|
10
|
-
componentConfig: { component: RowSelectionCell },
|
|
11
|
-
disableHiding: true,
|
|
12
|
-
enableGrouping: false,
|
|
13
|
-
enableSorting: false,
|
|
14
|
-
header: ACCESSOR_KEYS.SELECT,
|
|
15
|
-
id: ACCESSOR_KEYS.SELECT,
|
|
16
|
-
meta: {
|
|
17
|
-
header: "",
|
|
18
|
-
},
|
|
19
|
-
width: "max-content",
|
|
20
|
-
},
|
|
21
|
-
};
|