@databiosphere/findable-ui 2.2.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Detail/components/DetailViewTable/detailViewTable.js +1 -1
- package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
- package/lib/components/Index/index.d.ts +2 -1
- package/lib/components/Index/index.js +2 -2
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.styles.d.ts +3 -3
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/searchBar.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +1 -1
- package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +1 -1
- package/lib/components/Layout/components/Outline/outline.styles.d.ts +1 -1
- package/lib/components/Table/common/utils.d.ts +6 -0
- package/lib/components/Table/common/utils.js +12 -1
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +2 -2
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +1 -1
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +3 -3
- package/lib/components/Table/components/TableCell/common/utils.d.ts +8 -0
- package/lib/components/Table/components/TableCell/common/utils.js +15 -0
- package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.d.ts +6 -0
- package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.js +15 -0
- package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.d.ts +6 -0
- package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.js +16 -0
- package/lib/components/Table/components/TableHead/tableHead.js +2 -2
- package/lib/components/Table/components/TableRows/tableRows.js +2 -3
- package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.d.ts +10 -0
- package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.js +37 -0
- package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.js +13 -0
- package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.d.ts +9 -0
- package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.js +19 -0
- package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.d.ts +5 -0
- package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.js +13 -0
- package/lib/components/Table/components/TableToolbar/tableToolbar.js +5 -5
- package/lib/components/Table/components/TableToolbar/tableToolbar.styles.d.ts +1 -5
- package/lib/components/Table/components/TableToolbar/tableToolbar.styles.js +10 -7
- package/lib/components/Table/table.d.ts +5 -2
- package/lib/components/Table/table.js +13 -2
- package/lib/components/TableCreator/common/constants.d.ts +6 -0
- package/lib/components/TableCreator/common/constants.js +22 -0
- package/lib/components/TableCreator/common/entities.d.ts +5 -0
- package/lib/components/TableCreator/common/entities.js +2 -0
- package/lib/components/TableCreator/common/utils.d.ts +8 -0
- package/lib/components/TableCreator/common/utils.js +24 -0
- package/lib/components/TableCreator/tableCreator.d.ts +3 -1
- package/lib/components/TableCreator/tableCreator.js +19 -34
- package/lib/components/common/Alert/components/AlertText/alertText.styles.d.ts +5 -0
- package/lib/components/common/Alert/components/AlertText/alertText.styles.js +25 -0
- package/lib/components/common/Button/components/DropdownButton/dropdownButton.d.ts +4 -2
- package/lib/components/common/Button/components/DropdownButton/dropdownButton.js +2 -2
- package/lib/components/common/Button/components/DropdownButton/dropdownButton.styles.d.ts +5 -1
- package/lib/components/common/Button/components/DropdownButton/dropdownButton.styles.js +24 -1
- package/lib/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.d.ts +6 -0
- package/lib/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.js +29 -0
- package/lib/components/common/Dialog/dialog.d.ts +7 -0
- package/lib/components/common/Dialog/dialog.js +24 -0
- package/lib/components/common/DropdownMenu/common/constants.d.ts +2 -0
- package/lib/components/common/DropdownMenu/common/constants.js +8 -0
- package/lib/components/common/DropdownMenu/common/entities.d.ts +10 -0
- package/lib/components/common/DropdownMenu/common/entities.js +2 -0
- package/lib/components/common/DropdownMenu/components/MenuItem/menuItem.d.ts +7 -0
- package/lib/components/common/DropdownMenu/components/MenuItem/menuItem.js +25 -0
- package/lib/components/common/DropdownMenu/dropdownMenu.d.ts +9 -0
- package/lib/components/common/DropdownMenu/dropdownMenu.js +49 -0
- package/lib/components/common/DropdownMenu/dropdownMenu.styles.d.ts +3 -0
- package/lib/components/common/DropdownMenu/dropdownMenu.styles.js +13 -0
- package/lib/components/common/IconButton/iconButton.d.ts +4 -3
- package/lib/components/common/IconButton/iconButton.js +4 -4
- package/lib/components/common/IconButton/iconButton.styles.d.ts +34 -0
- package/lib/components/common/IconButton/iconButton.styles.js +27 -1
- package/lib/components/common/Tabs/tabs.styles.d.ts +1 -1
- package/lib/config/entities.d.ts +4 -1
- package/lib/hooks/useCategoryFilter.d.ts +7 -1
- package/lib/hooks/useCategoryFilter.js +25 -6
- package/lib/providers/exploreState/entities.d.ts +6 -2
- package/lib/providers/exploreState/initializer/utils.js +20 -7
- package/lib/providers/exploreState/payloads/entities.d.ts +24 -6
- package/lib/providers/exploreState/utils.d.ts +24 -2
- package/lib/providers/exploreState/utils.js +52 -3
- package/lib/providers/exploreState.d.ts +29 -5
- package/lib/providers/exploreState.js +28 -7
- package/lib/theme/common/components.js +4 -0
- package/lib/views/ExploreView/exploreView.d.ts +3 -1
- package/lib/views/ExploreView/exploreView.js +3 -3
- package/package.json +1 -1
- package/src/components/Detail/components/DetailViewTable/detailViewTable.tsx +2 -2
- package/src/components/Index/index.tsx +3 -1
- package/src/components/Table/common/utils.ts +17 -0
- package/src/components/Table/components/CheckboxMenu/checkboxMenu.styles.ts +3 -3
- package/src/components/Table/components/CheckboxMenu/checkboxMenu.tsx +4 -2
- package/src/components/Table/components/TableCell/common/utils.ts +16 -0
- package/src/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.tsx +24 -0
- package/src/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.tsx +31 -0
- package/src/components/Table/components/TableHead/tableHead.tsx +18 -7
- package/src/components/Table/components/TableRows/tableRows.tsx +10 -8
- package/src/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.ts +8 -0
- package/src/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.tsx +50 -0
- package/src/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.ts +8 -0
- package/src/components/Table/components/TableToolbar/components/RowSelection/rowSelection.tsx +30 -0
- package/src/components/Table/components/TableToolbar/tableToolbar.styles.ts +10 -7
- package/src/components/Table/components/TableToolbar/tableToolbar.tsx +11 -8
- package/src/components/Table/table.tsx +18 -1
- package/src/components/TableCreator/common/constants.ts +26 -0
- package/src/components/TableCreator/common/entities.ts +6 -0
- package/src/components/TableCreator/common/utils.ts +33 -0
- package/src/components/TableCreator/tableCreator.tsx +38 -17
- package/src/components/common/Alert/components/AlertText/alertText.styles.ts +20 -0
- package/src/components/common/Button/components/DropdownButton/dropdownButton.styles.ts +15 -1
- package/src/components/common/Button/components/DropdownButton/dropdownButton.tsx +10 -2
- package/src/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.tsx +23 -0
- package/src/components/common/Dialog/dialog.tsx +21 -0
- package/src/components/common/DropdownMenu/common/constants.ts +7 -0
- package/src/components/common/DropdownMenu/common/entities.ts +11 -0
- package/src/components/common/DropdownMenu/components/MenuItem/menuItem.tsx +24 -0
- package/src/components/common/DropdownMenu/dropdownMenu.styles.ts +8 -0
- package/src/components/common/DropdownMenu/dropdownMenu.tsx +48 -0
- package/src/components/common/IconButton/iconButton.styles.ts +18 -0
- package/src/components/common/IconButton/iconButton.tsx +10 -11
- package/src/config/entities.ts +6 -0
- package/src/hooks/useCategoryFilter.ts +31 -7
- package/src/providers/exploreState/entities.ts +8 -2
- package/src/providers/exploreState/initializer/utils.ts +21 -1
- package/src/providers/exploreState/payloads/entities.ts +32 -7
- package/src/providers/exploreState/utils.ts +81 -1
- package/src/providers/exploreState.tsx +88 -11
- package/src/theme/common/components.ts +4 -0
- package/src/views/ExploreView/exploreView.tsx +6 -2
- package/types/data-explorer-ui.d.ts +10 -0
- package/src/components/Table/components/EntityViewToggle/entityViewToggle.tsx +0 -36
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RowData } from "@tanstack/react-table";
|
|
2
|
+
import { RowSelectionCell } from "../../Table/components/TableCell/components/RowSelectionCell/rowSelectionCell";
|
|
3
|
+
import { BaseColumnConfig } from "./entities";
|
|
4
|
+
|
|
5
|
+
export const ACCESSOR_KEYS = {
|
|
6
|
+
SELECT: "select",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const COLUMN_CONFIGS: Record<
|
|
10
|
+
string,
|
|
11
|
+
BaseColumnConfig<RowData, unknown>
|
|
12
|
+
> = {
|
|
13
|
+
SELECT: {
|
|
14
|
+
columnPinned: false,
|
|
15
|
+
columnVisible: false,
|
|
16
|
+
componentConfig: { component: RowSelectionCell },
|
|
17
|
+
disableHiding: true,
|
|
18
|
+
disableSorting: true,
|
|
19
|
+
header: ACCESSOR_KEYS.SELECT,
|
|
20
|
+
id: ACCESSOR_KEYS.SELECT,
|
|
21
|
+
meta: {
|
|
22
|
+
header: "",
|
|
23
|
+
},
|
|
24
|
+
width: "max-content",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumnConfig } from "./entities";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds a base column definition.
|
|
6
|
+
* @param baseColumnConfig - Base column configuration.
|
|
7
|
+
* @returns column definition.
|
|
8
|
+
*/
|
|
9
|
+
export function buildBaseColumnDef<T, TValue>(
|
|
10
|
+
baseColumnConfig: BaseColumnConfig<T, TValue>
|
|
11
|
+
): ColumnDef<T> {
|
|
12
|
+
const {
|
|
13
|
+
columnPinned,
|
|
14
|
+
disableHiding,
|
|
15
|
+
disableSorting,
|
|
16
|
+
header,
|
|
17
|
+
id,
|
|
18
|
+
meta,
|
|
19
|
+
width,
|
|
20
|
+
} = baseColumnConfig;
|
|
21
|
+
return {
|
|
22
|
+
accessorKey: id,
|
|
23
|
+
enableHiding: !disableHiding,
|
|
24
|
+
enableSorting: !disableSorting,
|
|
25
|
+
header,
|
|
26
|
+
id,
|
|
27
|
+
meta: {
|
|
28
|
+
columnPinned,
|
|
29
|
+
header: meta ? meta.header : header,
|
|
30
|
+
width,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CellContext, ColumnDef, ColumnSort } from "@tanstack/react-table";
|
|
2
|
+
import { CoreOptions, HeaderContext, RowData } from "@tanstack/table-core";
|
|
2
3
|
import React, { useMemo } from "react";
|
|
3
4
|
import { Pagination } from "../../common/entities";
|
|
4
5
|
import { ColumnConfig, ListViewConfig } from "../../config/entities";
|
|
@@ -10,12 +11,17 @@ import {
|
|
|
10
11
|
getInitialState,
|
|
11
12
|
sortingFn,
|
|
12
13
|
} from "../Table/common/utils";
|
|
14
|
+
import { RowSelectionCell } from "../Table/components/TableCell/components/RowSelectionCell/rowSelectionCell";
|
|
15
|
+
import { HeadSelectionCell } from "../Table/components/TableHead/components/HeadSelectionCell/headSelectionCell";
|
|
13
16
|
import { Table } from "../Table/table";
|
|
17
|
+
import { COLUMN_CONFIGS } from "./common/constants";
|
|
18
|
+
import { buildBaseColumnDef } from "./common/utils";
|
|
14
19
|
import { TableCreator as TableCreatorContainer } from "./tableCreator.styles";
|
|
15
20
|
|
|
16
21
|
export interface TableCreatorProps<T> {
|
|
17
22
|
columns: ColumnConfig<T>[];
|
|
18
23
|
defaultSort: ColumnSort | undefined;
|
|
24
|
+
getRowId?: CoreOptions<T>["getRowId"];
|
|
19
25
|
items: T[];
|
|
20
26
|
listView?: ListViewConfig;
|
|
21
27
|
loading?: boolean;
|
|
@@ -26,9 +32,8 @@ export interface TableCreatorProps<T> {
|
|
|
26
32
|
total?: number;
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
const createCell = <T extends
|
|
30
|
-
|
|
31
|
-
function CellCreator({ row }: CellContext<T, any>): JSX.Element {
|
|
35
|
+
const createCell = <T extends RowData>(config: ColumnConfig<T>) =>
|
|
36
|
+
function CellCreator({ row }: CellContext<T, unknown>): JSX.Element {
|
|
32
37
|
return (
|
|
33
38
|
<ComponentCreator
|
|
34
39
|
components={[config.componentConfig]}
|
|
@@ -37,9 +42,20 @@ const createCell = <T extends object>(config: ColumnConfig<T>) =>
|
|
|
37
42
|
);
|
|
38
43
|
};
|
|
39
44
|
|
|
45
|
+
const createHeaderSelectionCell = <T extends RowData>() =>
|
|
46
|
+
function CellCreator({ table }: HeaderContext<T, unknown>): JSX.Element {
|
|
47
|
+
return <HeadSelectionCell tableInstance={table} />;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const createRowSelectionCell = <T extends RowData>() =>
|
|
51
|
+
function CellCreator({ row }: CellContext<T, unknown>): JSX.Element {
|
|
52
|
+
return <RowSelectionCell row={row} />;
|
|
53
|
+
};
|
|
54
|
+
|
|
40
55
|
export const TableCreator = <T extends object>({
|
|
41
56
|
columns,
|
|
42
57
|
defaultSort,
|
|
58
|
+
getRowId,
|
|
43
59
|
items,
|
|
44
60
|
listView,
|
|
45
61
|
loading,
|
|
@@ -51,21 +67,25 @@ export const TableCreator = <T extends object>({
|
|
|
51
67
|
}: TableCreatorProps<T>): JSX.Element => {
|
|
52
68
|
const columnDefs: ColumnDef<T>[] = useMemo(
|
|
53
69
|
() =>
|
|
54
|
-
columns.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
columnPinned: columnConfig.columnPinned,
|
|
64
|
-
header: columnConfig.header,
|
|
65
|
-
width: columnConfig.width,
|
|
70
|
+
columns.reduce(
|
|
71
|
+
(acc, columnConfig) => {
|
|
72
|
+
acc.push({
|
|
73
|
+
...buildBaseColumnDef(columnConfig),
|
|
74
|
+
cell: createCell(columnConfig),
|
|
75
|
+
filterFn: arrIncludesSome,
|
|
76
|
+
sortingFn: sortingFn,
|
|
77
|
+
});
|
|
78
|
+
return acc;
|
|
66
79
|
},
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
[
|
|
81
|
+
/* Initialize column definitions with the "select" column */
|
|
82
|
+
{
|
|
83
|
+
...buildBaseColumnDef(COLUMN_CONFIGS.SELECT),
|
|
84
|
+
cell: createRowSelectionCell(),
|
|
85
|
+
header: createHeaderSelectionCell(),
|
|
86
|
+
},
|
|
87
|
+
] as ColumnDef<T>[]
|
|
88
|
+
),
|
|
69
89
|
[columns]
|
|
70
90
|
);
|
|
71
91
|
const initialState = getInitialState(columns, defaultSort);
|
|
@@ -79,6 +99,7 @@ export const TableCreator = <T extends object>({
|
|
|
79
99
|
<Table<T>
|
|
80
100
|
columns={columnDefs}
|
|
81
101
|
count={pageCount}
|
|
102
|
+
getRowId={getRowId}
|
|
82
103
|
initialState={initialState}
|
|
83
104
|
items={items}
|
|
84
105
|
listView={listView}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
|
|
3
|
+
export const AlertText = styled.div`
|
|
4
|
+
ul {
|
|
5
|
+
padding-left: 24px;
|
|
6
|
+
margin: 8px 0;
|
|
7
|
+
|
|
8
|
+
li {
|
|
9
|
+
margin: 4px 0;
|
|
10
|
+
|
|
11
|
+
&:last-child {
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
*:last-child {
|
|
18
|
+
margin-bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
+
import { css } from "@emotion/react";
|
|
1
2
|
import styled from "@emotion/styled";
|
|
3
|
+
import { smokeLightest } from "../../../../../styles/common/mixins/colors";
|
|
2
4
|
import { ButtonSecondary } from "../ButtonSecondary/buttonSecondary";
|
|
3
5
|
|
|
6
|
+
interface Props {
|
|
7
|
+
open: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
// Dropdown button with "secondary" styles.
|
|
5
|
-
export const DropdownButton = styled(ButtonSecondary
|
|
11
|
+
export const DropdownButton = styled(ButtonSecondary, {
|
|
12
|
+
shouldForwardProp: (prop) => prop !== "open",
|
|
13
|
+
})<Props>`
|
|
6
14
|
padding-right: 8px;
|
|
7
15
|
|
|
8
16
|
.MuiButton-endIcon {
|
|
9
17
|
margin-left: -6px;
|
|
10
18
|
}
|
|
19
|
+
|
|
20
|
+
${({ open, ...props }) =>
|
|
21
|
+
open &&
|
|
22
|
+
css`
|
|
23
|
+
background-color: ${smokeLightest(props)};
|
|
24
|
+
`}
|
|
11
25
|
`;
|
|
@@ -3,15 +3,23 @@ import React from "react";
|
|
|
3
3
|
import { ButtonProps } from "../../button";
|
|
4
4
|
import { DropdownButton as Button } from "./dropdownButton.styles";
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export interface DropdownButtonProps extends Exclude<ButtonProps, "StartIcon"> {
|
|
7
|
+
open?: boolean;
|
|
8
|
+
}
|
|
7
9
|
|
|
8
10
|
export const DropdownButton = ({
|
|
9
11
|
children,
|
|
10
12
|
disabled = false,
|
|
13
|
+
open = false,
|
|
11
14
|
...props /* Spread props to allow for Mui ButtonProps specific prop overrides e.g. "onClick". */
|
|
12
15
|
}: DropdownButtonProps): JSX.Element => {
|
|
13
16
|
return (
|
|
14
|
-
<Button
|
|
17
|
+
<Button
|
|
18
|
+
disabled={disabled}
|
|
19
|
+
EndIcon={ArrowDropDownRoundedIcon}
|
|
20
|
+
open={open}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
15
23
|
{children}
|
|
16
24
|
</Button>
|
|
17
25
|
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvgIcon } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CustomSVGIconProps } from "../../common/entities";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Custom indeterminate icon.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const IndeterminateIcon = ({
|
|
10
|
+
fontSize = "xsmall",
|
|
11
|
+
viewBox = "0 0 18 18",
|
|
12
|
+
...props /* Spread props to allow for Mui SvgIconProps specific prop overrides e.g. "htmlColor". */
|
|
13
|
+
}: CustomSVGIconProps): JSX.Element => {
|
|
14
|
+
return (
|
|
15
|
+
<SvgIcon fontSize={fontSize} viewBox={viewBox} {...props}>
|
|
16
|
+
<path
|
|
17
|
+
d="M0 4C0 1.79086 1.79086 0 4 0H14C16.2091 0 18 1.79086 18 4V14C18 16.2091 16.2091 18 14 18H4C1.79086 18 0 16.2091 0 14V4Z"
|
|
18
|
+
fill="currentColor"
|
|
19
|
+
/>
|
|
20
|
+
<rect x="5" y="8" width="8" height="2" rx="1" fill="white" />
|
|
21
|
+
</SvgIcon>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Dialog as MDialog, DialogProps as MDialogProps } from "@mui/material";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
export interface DialogProps extends MDialogProps {
|
|
5
|
+
children: ReactNode | ReactNode[];
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const Dialog = ({
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
onClose,
|
|
13
|
+
open,
|
|
14
|
+
...props /* Spread props to allow for Mui Dialog specific prop overrides e.g. "fullWidth". */
|
|
15
|
+
}: DialogProps): JSX.Element => {
|
|
16
|
+
return (
|
|
17
|
+
<MDialog className={className} onClose={onClose} open={open} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</MDialog>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MenuProps as MMenuProps } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_DROPDOWN_MENU_PROPS: Partial<MMenuProps> = {
|
|
4
|
+
anchorOrigin: { horizontal: "right", vertical: "bottom" },
|
|
5
|
+
slotProps: { paper: { variant: "menu" } },
|
|
6
|
+
transformOrigin: { horizontal: "right", vertical: "top" },
|
|
7
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonProps as MButtonProps,
|
|
3
|
+
IconButtonProps as MIconButtonProps,
|
|
4
|
+
} from "@mui/material";
|
|
5
|
+
|
|
6
|
+
export interface DropdownMenuItemProps {
|
|
7
|
+
closeMenu: () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type DropdownMenuButtonProps = MButtonProps & { open?: boolean };
|
|
11
|
+
export type DropdownMenuIconButtonProps = MIconButtonProps & { open?: boolean };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ListItemText as MListItemText,
|
|
3
|
+
MenuItem as MMenuItem,
|
|
4
|
+
MenuItemProps as MMenuItemProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import React, { ReactNode } from "react";
|
|
7
|
+
|
|
8
|
+
export interface MenuItemProps extends MMenuItemProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const MenuItem = ({
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
onClick,
|
|
17
|
+
...props /* Spread props to allow for Mui MenuItem specific prop overrides e.g. "disableGutters". */
|
|
18
|
+
}: MenuItemProps): JSX.Element => {
|
|
19
|
+
return (
|
|
20
|
+
<MMenuItem className={className} onClick={onClick} {...props}>
|
|
21
|
+
<MListItemText disableTypography>{children}</MListItemText>
|
|
22
|
+
</MMenuItem>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MenuProps as MMenuProps } from "@mui/material";
|
|
2
|
+
import React, { ElementType, Fragment, MouseEvent, useState } from "react";
|
|
3
|
+
import { DEFAULT_DROPDOWN_MENU_PROPS } from "./common/constants";
|
|
4
|
+
import {
|
|
5
|
+
DropdownMenuButtonProps,
|
|
6
|
+
DropdownMenuIconButtonProps,
|
|
7
|
+
DropdownMenuItemProps,
|
|
8
|
+
} from "./common/entities";
|
|
9
|
+
import { Menu } from "./dropdownMenu.styles";
|
|
10
|
+
|
|
11
|
+
export interface DropdownMenuProps
|
|
12
|
+
extends Omit<MMenuProps, "children" | "open"> {
|
|
13
|
+
Button:
|
|
14
|
+
| ElementType<DropdownMenuButtonProps>
|
|
15
|
+
| ElementType<DropdownMenuIconButtonProps>;
|
|
16
|
+
children?: ({ closeMenu }: DropdownMenuItemProps) => JSX.Element[];
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const DropdownMenu = ({
|
|
21
|
+
Button,
|
|
22
|
+
children,
|
|
23
|
+
className,
|
|
24
|
+
...props /* Spread props to allow for Mui Menu specific prop overrides e.g. "anchorOrigin". */
|
|
25
|
+
}: DropdownMenuProps): JSX.Element => {
|
|
26
|
+
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
|
27
|
+
const closeMenu = (): void => setAnchorEl(null);
|
|
28
|
+
return (
|
|
29
|
+
<Fragment>
|
|
30
|
+
<Button
|
|
31
|
+
onClick={(event: MouseEvent<HTMLButtonElement>): void =>
|
|
32
|
+
setAnchorEl(event.currentTarget)
|
|
33
|
+
}
|
|
34
|
+
open={Boolean(anchorEl)}
|
|
35
|
+
/>
|
|
36
|
+
<Menu
|
|
37
|
+
{...DEFAULT_DROPDOWN_MENU_PROPS}
|
|
38
|
+
anchorEl={anchorEl}
|
|
39
|
+
className={className}
|
|
40
|
+
onClose={closeMenu}
|
|
41
|
+
open={Boolean(anchorEl)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
{children ? children({ closeMenu }) : null}
|
|
45
|
+
</Menu>
|
|
46
|
+
</Fragment>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
import { css } from "@emotion/react";
|
|
1
2
|
import styled from "@emotion/styled";
|
|
2
3
|
import { IconButton as MIconButton } from "@mui/material";
|
|
4
|
+
import { smokeLightest } from "../../../styles/common/mixins/colors";
|
|
3
5
|
import { IconButton } from "./iconButton";
|
|
4
6
|
|
|
7
|
+
interface Props {
|
|
8
|
+
open: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Button = styled(MIconButton, {
|
|
12
|
+
shouldForwardProp: (prop) => prop !== "open",
|
|
13
|
+
})<Props>`
|
|
14
|
+
${({ open, ...props }) =>
|
|
15
|
+
open &&
|
|
16
|
+
css`
|
|
17
|
+
&.MuiIconButton-root {
|
|
18
|
+
background-color: ${smokeLightest(props)};
|
|
19
|
+
}
|
|
20
|
+
`}
|
|
21
|
+
`;
|
|
22
|
+
|
|
5
23
|
// Primary icon button.
|
|
6
24
|
export const IconButtonPrimary = styled(IconButton)`
|
|
7
25
|
background-color: ${({ theme }) => theme.palette.primary.main};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
IconButton as MIconButton,
|
|
3
2
|
IconButtonProps as MIconButtonProps,
|
|
3
|
+
IconProps as MIconProps,
|
|
4
4
|
} from "@mui/material";
|
|
5
5
|
import React, { ElementType } from "react";
|
|
6
|
+
import { Button } from "./iconButton.styles";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Basic icon button component.
|
|
@@ -11,24 +12,22 @@ import React, { ElementType } from "react";
|
|
|
11
12
|
|
|
12
13
|
export interface IconButtonProps extends MIconButtonProps {
|
|
13
14
|
className?: string;
|
|
14
|
-
disabled?: boolean;
|
|
15
15
|
Icon: ElementType;
|
|
16
|
+
iconProps?: MIconProps;
|
|
17
|
+
open?: boolean;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export const IconButton = ({
|
|
19
21
|
className,
|
|
20
|
-
disabled = false,
|
|
21
22
|
Icon,
|
|
23
|
+
iconProps = { fontSize: "small" },
|
|
24
|
+
open = false,
|
|
25
|
+
size = "large",
|
|
22
26
|
...props /* Spread props to allow for Mui IconButtonProps specific prop overrides e.g. "onClick". */
|
|
23
27
|
}: IconButtonProps): JSX.Element => {
|
|
24
28
|
return (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
size="large"
|
|
29
|
-
{...props}
|
|
30
|
-
>
|
|
31
|
-
<Icon fontSize="small" />
|
|
32
|
-
</MIconButton>
|
|
29
|
+
<Button className={className} open={open} size={size} {...props}>
|
|
30
|
+
<Icon {...iconProps} />
|
|
31
|
+
</Button>
|
|
33
32
|
);
|
|
34
33
|
};
|
package/src/config/entities.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ColumnSort } from "@tanstack/react-table";
|
|
|
3
3
|
import { JSXElementConstructor, ReactNode } from "react";
|
|
4
4
|
import {
|
|
5
5
|
CategoryKey,
|
|
6
|
+
SelectCategoryValueView,
|
|
6
7
|
SelectedFilter,
|
|
7
8
|
SelectedFilterValue,
|
|
8
9
|
} from "../common/entities";
|
|
@@ -77,6 +78,9 @@ export interface CategoryGroup {
|
|
|
77
78
|
export interface CategoryConfig {
|
|
78
79
|
key: string;
|
|
79
80
|
label: string;
|
|
81
|
+
mapSelectCategoryValue?: (
|
|
82
|
+
selectCategoryValue: SelectCategoryValueView
|
|
83
|
+
) => SelectCategoryValueView;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
/**
|
|
@@ -261,8 +265,10 @@ export interface ListConfig<T = any> {
|
|
|
261
265
|
export interface ListViewConfig {
|
|
262
266
|
disablePagination?: boolean;
|
|
263
267
|
enableDownload?: boolean;
|
|
268
|
+
enableRowSelection?: boolean;
|
|
264
269
|
listHero?: ComponentsConfig;
|
|
265
270
|
relatedView?: RelatedViewConfig;
|
|
271
|
+
rowSelectionView?: ComponentsConfig;
|
|
266
272
|
subTitleHero?: ComponentsConfig;
|
|
267
273
|
}
|
|
268
274
|
|
|
@@ -73,11 +73,14 @@ function buildCategoryView(
|
|
|
73
73
|
categoryValueViews: SelectCategoryValueView[],
|
|
74
74
|
categoryConfigs: CategoryConfig[]
|
|
75
75
|
): SelectCategoryView {
|
|
76
|
+
const categoryConfig = findCategoryConfig(category.key, categoryConfigs);
|
|
77
|
+
const mapSelectCategoryValue =
|
|
78
|
+
categoryConfig?.mapSelectCategoryValue || getSelectCategoryValue;
|
|
76
79
|
return {
|
|
77
80
|
isDisabled: false,
|
|
78
81
|
key: category.key,
|
|
79
|
-
label: getCategoryLabel(category.key,
|
|
80
|
-
values: categoryValueViews,
|
|
82
|
+
label: getCategoryLabel(category.key, categoryConfig),
|
|
83
|
+
values: categoryValueViews.map(mapSelectCategoryValue),
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -192,22 +195,43 @@ function getCategorySelectedFilter(
|
|
|
192
195
|
/**
|
|
193
196
|
* Get the label for the given category key as per the config.
|
|
194
197
|
* @param key - Key of category to find label of.
|
|
195
|
-
* @param
|
|
198
|
+
* @param categoryConfig - Category.
|
|
196
199
|
* @returns the display value for the given category.
|
|
197
200
|
*/
|
|
198
201
|
function getCategoryLabel(
|
|
199
202
|
key: string,
|
|
200
|
-
|
|
203
|
+
categoryConfig?: CategoryConfig
|
|
201
204
|
): string {
|
|
202
|
-
const categoryConfig = categoryConfigs.find(
|
|
203
|
-
(categoryConfig) => categoryConfig.key === key
|
|
204
|
-
);
|
|
205
205
|
if (!categoryConfig) {
|
|
206
206
|
return key;
|
|
207
207
|
}
|
|
208
208
|
return categoryConfig.label;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Default function returning select category value, unmodified.
|
|
213
|
+
* @param selectCategoryValue - Select category value.
|
|
214
|
+
* @returns original select category value.
|
|
215
|
+
*/
|
|
216
|
+
export function getSelectCategoryValue(
|
|
217
|
+
selectCategoryValue: SelectCategoryValue
|
|
218
|
+
): SelectCategoryValue {
|
|
219
|
+
return selectCategoryValue;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Returns the category config for the given category config key.
|
|
224
|
+
* @param key - Category config key.
|
|
225
|
+
* @param categoryConfigs - Category configs.
|
|
226
|
+
* @returns category config.
|
|
227
|
+
*/
|
|
228
|
+
function findCategoryConfig(
|
|
229
|
+
key: string,
|
|
230
|
+
categoryConfigs: CategoryConfig[]
|
|
231
|
+
): CategoryConfig | undefined {
|
|
232
|
+
return categoryConfigs.find((categoryConfig) => categoryConfig.key === key);
|
|
233
|
+
}
|
|
234
|
+
|
|
211
235
|
/**
|
|
212
236
|
* Determine if given category value is selected.
|
|
213
237
|
* @param categoryValueKey - The key of the category value to check if selected in the filter state.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ColumnSort } from "@tanstack/react-table";
|
|
1
|
+
import { ColumnSort, RowSelectionState } from "@tanstack/react-table";
|
|
2
|
+
import { VisibilityState } from "@tanstack/table-core/src/features/Visibility";
|
|
2
3
|
import {
|
|
3
4
|
CategoryValueKey,
|
|
4
5
|
SelectCategory,
|
|
@@ -15,7 +16,9 @@ import {
|
|
|
15
16
|
|
|
16
17
|
export interface EntityPageState {
|
|
17
18
|
categoryGroupConfigKey: CategoryGroupConfigKey;
|
|
18
|
-
columnsVisibility:
|
|
19
|
+
columnsVisibility: VisibilityState;
|
|
20
|
+
enableRowSelection: boolean;
|
|
21
|
+
rowSelection: RowSelectionState;
|
|
19
22
|
sorting: ColumnSort[];
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -44,6 +47,9 @@ export interface EntityStateSavedFilter extends Omit<SavedFilter, "sort"> {
|
|
|
44
47
|
sorting?: ColumnSort[];
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO revisit when adding react query or similar
|
|
51
|
+
export type ListItem = any;
|
|
52
|
+
|
|
47
53
|
export type SavedFilterByCategoryValueKey = Map<
|
|
48
54
|
CategoryValueKey,
|
|
49
55
|
EntityStateSavedFilter
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { VisibilityState } from "@tanstack/table-core/src/features/Visibility";
|
|
1
2
|
import { SelectCategory, SelectedFilter } from "../../../common/entities";
|
|
2
3
|
import { getInitialTableColumnVisibility } from "../../../components/Table/common/utils";
|
|
4
|
+
import { ACCESSOR_KEYS } from "../../../components/TableCreator/common/constants";
|
|
3
5
|
import {
|
|
4
6
|
CategoryConfig,
|
|
5
7
|
CategoryGroup,
|
|
@@ -138,6 +140,22 @@ function initCategoryGroups(
|
|
|
138
140
|
?.categoryGroups;
|
|
139
141
|
}
|
|
140
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Initializes column visibility for the given entity.
|
|
145
|
+
* @param entityConfig - Entity config.
|
|
146
|
+
* @returns column visibility.
|
|
147
|
+
*/
|
|
148
|
+
function initColumnVisibility(entityConfig: EntityConfig): VisibilityState {
|
|
149
|
+
const {
|
|
150
|
+
list: { columns },
|
|
151
|
+
listView: { enableRowSelection = false } = {},
|
|
152
|
+
} = entityConfig;
|
|
153
|
+
return {
|
|
154
|
+
[ACCESSOR_KEYS.SELECT]: enableRowSelection,
|
|
155
|
+
...getInitialTableColumnVisibility(columns),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
141
159
|
/**
|
|
142
160
|
* Initializes entity page state.
|
|
143
161
|
* @param config - Site config.
|
|
@@ -149,7 +167,9 @@ function initEntityPageState(config: SiteConfig): EntityPageStateMapper {
|
|
|
149
167
|
...acc,
|
|
150
168
|
[entity.route]: {
|
|
151
169
|
categoryGroupConfigKey: initCategoryGroupConfigKey(config, entity),
|
|
152
|
-
columnsVisibility:
|
|
170
|
+
columnsVisibility: initColumnVisibility(entity),
|
|
171
|
+
enableRowSelection: Boolean(entity.listView?.enableRowSelection),
|
|
172
|
+
rowSelection: {},
|
|
153
173
|
sorting: getDefaultSorting(entity),
|
|
154
174
|
},
|
|
155
175
|
};
|