@databiosphere/findable-ui 15.0.2 → 16.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 +13 -0
- package/lib/components/Detail/components/Table/components/TableRows/tableRows.js +3 -3
- package/lib/components/Detail/components/Table/table.js +7 -2
- package/lib/components/Export/components/ExportForm/exportForm.styles.js +1 -3
- package/lib/components/Layout/components/ContentLayout/contentLayout.d.ts +2 -2
- package/lib/components/Layout/components/ContentLayout/contentLayout.js +1 -1
- package/lib/components/Layout/components/ContentLayout/contentLayout.styles.d.ts +1 -0
- package/lib/components/Layout/components/ContentLayout/contentLayout.styles.js +11 -4
- package/lib/components/Table/common/columnDef.d.ts +2 -0
- package/lib/components/Table/common/columnDef.js +17 -0
- package/lib/components/Table/common/gridTable.styles.js +1 -2
- package/lib/components/Table/components/TableCell/common/utils.d.ts +9 -3
- package/lib/components/Table/components/TableCell/common/utils.js +16 -2
- package/lib/components/Table/components/TableCell/components/RowPositionCell/constants.d.ts +2 -0
- package/lib/components/Table/components/TableCell/components/RowPositionCell/constants.js +5 -0
- package/lib/components/Table/components/TableCell/components/RowPositionCell/rowPositionCell.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/RowPositionCell/rowPositionCell.js +6 -0
- package/lib/components/Table/components/TableHead/tableHead.js +3 -3
- package/lib/components/Table/components/TableRows/tableRows.js +3 -3
- package/lib/components/Table/features/RowPosition/constants.d.ts +2 -0
- package/lib/components/Table/features/RowPosition/constants.js +17 -0
- package/lib/components/Table/features/RowPosition/types.d.ts +3 -0
- package/lib/components/Table/features/RowPosition/types.js +1 -0
- package/lib/components/Table/features/RowPosition/utils.d.ts +21 -0
- package/lib/components/Table/features/RowPosition/utils.js +55 -0
- package/lib/components/Table/features/constants.d.ts +6 -0
- package/lib/components/Table/features/constants.js +8 -0
- package/lib/components/Table/features/entities.d.ts +2 -1
- package/lib/components/Table/table.d.ts +4 -2
- package/lib/components/Table/table.js +21 -3
- package/lib/components/TableCreator/common/constants.d.ts +1 -0
- package/lib/components/TableCreator/common/constants.js +1 -0
- package/lib/components/TableCreator/tableCreator.d.ts +3 -2
- package/lib/components/TableCreator/tableCreator.js +5 -2
- package/lib/components/common/Breadcrumbs/breadcrumbs.js +2 -1
- package/lib/components/common/Breadcrumbs/constants.d.ts +2 -0
- package/lib/components/common/Breadcrumbs/constants.js +4 -0
- package/lib/config/entities.d.ts +5 -3
- package/lib/providers/exploreState/initializer/utils.js +3 -1
- package/lib/styles/common/mui/link.d.ts +7 -0
- package/lib/styles/common/mui/link.js +8 -0
- package/lib/styles/common/mui/tableCell.d.ts +13 -0
- package/lib/styles/common/mui/tableCell.js +27 -0
- package/lib/styles/common/mui/typography.d.ts +2 -0
- package/lib/styles/common/mui/typography.js +3 -0
- package/lib/theme/common/components.d.ts +0 -6
- package/lib/theme/common/components.js +0 -31
- package/lib/theme/components/index.d.ts +1 -0
- package/lib/theme/components/index.js +1 -0
- package/lib/theme/components/muiTableCell.d.ts +2 -0
- package/lib/theme/components/muiTableCell.js +48 -0
- package/lib/theme/theme.js +1 -1
- package/lib/views/ContentView/contentView.d.ts +2 -1
- package/lib/views/ContentView/contentView.js +2 -2
- package/lib/views/ExploreView/exploreView.js +2 -2
- package/package.json +1 -1
- package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +8 -4
- package/src/components/Detail/components/Table/table.tsx +7 -2
- package/src/components/Export/components/ExportForm/exportForm.styles.ts +1 -7
- package/src/components/Layout/components/ContentLayout/contentLayout.styles.ts +13 -4
- package/src/components/Layout/components/ContentLayout/contentLayout.tsx +7 -3
- package/src/components/Table/common/columnDef.ts +19 -0
- package/src/components/Table/common/gridTable.styles.ts +1 -2
- package/src/components/Table/components/TableCell/common/utils.ts +22 -5
- package/src/components/Table/components/TableCell/components/RowPositionCell/constants.ts +7 -0
- package/src/components/Table/components/TableCell/components/RowPositionCell/rowPositionCell.tsx +16 -0
- package/src/components/Table/components/TableHead/tableHead.tsx +8 -4
- package/src/components/Table/components/TableRows/tableRows.tsx +8 -4
- package/src/components/Table/features/RowPosition/constants.ts +34 -0
- package/src/components/Table/features/RowPosition/types.ts +3 -0
- package/src/components/Table/features/RowPosition/utils.ts +80 -0
- package/src/components/Table/features/constants.ts +10 -0
- package/src/components/Table/features/entities.ts +2 -1
- package/src/components/Table/table.tsx +24 -3
- package/src/components/TableCreator/common/constants.ts +1 -0
- package/src/components/TableCreator/tableCreator.tsx +11 -1
- package/src/components/common/Breadcrumbs/breadcrumbs.tsx +2 -1
- package/src/components/common/Breadcrumbs/constants.ts +6 -0
- package/src/config/entities.ts +12 -3
- package/src/providers/exploreState/initializer/utils.ts +6 -1
- package/src/styles/common/mui/link.ts +15 -0
- package/src/styles/common/mui/tableCell.ts +40 -0
- package/src/styles/common/mui/typography.ts +5 -0
- package/src/theme/common/components.ts +0 -32
- package/src/theme/components/index.ts +1 -0
- package/src/theme/components/muiTableCell.ts +50 -0
- package/src/theme/theme.ts +1 -1
- package/src/views/ContentView/contentView.tsx +4 -1
- package/src/views/ExploreView/exploreView.tsx +2 -1
- package/types/data-explorer-ui.d.ts +2 -0
package/lib/config/entities.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TabProps as MTabProps, Theme, ThemeOptions } from "@mui/material";
|
|
2
|
-
import { CellContext, ColumnSort, RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import { CellContext, ColumnMeta, ColumnSort, RowData, Table, TableOptions } from "@tanstack/react-table";
|
|
3
3
|
import { JSXElementConstructor, ReactNode } from "react";
|
|
4
4
|
import { SelectCategoryValueView, SelectedFilter } from "../common/entities";
|
|
5
5
|
import { HeroTitle } from "../components/common/Title/title";
|
|
@@ -79,6 +79,7 @@ export interface ColumnConfig<T = any, C extends keyof JSX.IntrinsicElements | J
|
|
|
79
79
|
disableSorting?: boolean;
|
|
80
80
|
header: string;
|
|
81
81
|
id: string;
|
|
82
|
+
meta?: ColumnMeta<T, unknown>;
|
|
82
83
|
tooltip?: string;
|
|
83
84
|
width: GridTrackSize;
|
|
84
85
|
}
|
|
@@ -130,7 +131,7 @@ export interface EntityConfig<T = any, I = any> extends TabConfig {
|
|
|
130
131
|
explorerTitle?: SiteConfig["explorerTitle"];
|
|
131
132
|
getId?: GetIdFunction<T>;
|
|
132
133
|
getTitle?: GetTitleFunction<T>;
|
|
133
|
-
list: ListConfig
|
|
134
|
+
list: ListConfig<T>;
|
|
134
135
|
listView?: ListViewConfig;
|
|
135
136
|
options?: Options;
|
|
136
137
|
overrides?: Override[];
|
|
@@ -200,9 +201,10 @@ export type GridTrackSize = GridTrackAuto | GridTrackLength | GridTrackFlex | Gr
|
|
|
200
201
|
/**
|
|
201
202
|
* List configuration.
|
|
202
203
|
*/
|
|
203
|
-
export interface ListConfig<T
|
|
204
|
+
export interface ListConfig<T extends RowData> {
|
|
204
205
|
columns: ColumnConfig<T>[];
|
|
205
206
|
defaultSort?: ColumnSort;
|
|
207
|
+
tableOptions?: Omit<TableOptions<T>, "columns" | "data" | "getCoreRowModel">;
|
|
206
208
|
}
|
|
207
209
|
/**
|
|
208
210
|
* List view configuration.
|
|
@@ -95,10 +95,12 @@ function initCategoryGroups(entityStateByCategoryGroupConfigKey, categoryGroupCo
|
|
|
95
95
|
* @returns column visibility.
|
|
96
96
|
*/
|
|
97
97
|
function initColumnVisibility(entityConfig) {
|
|
98
|
-
const { list: { columns }, listView: { enableRowSelection = false } = {}, } = entityConfig;
|
|
98
|
+
const { list: { columns, tableOptions: { initialState: { columnVisibility = {} } = {} } = {}, }, listView: { enableRowSelection = false } = {}, } = entityConfig;
|
|
99
99
|
return {
|
|
100
|
+
[ACCESSOR_KEYS.ROW_POSITION]: false, // Explicitly setting row position to false; required - currently `columnVisibilty` is initialized from columns configuration.
|
|
100
101
|
[ACCESSOR_KEYS.SELECT]: enableRowSelection,
|
|
101
102
|
...getInitialTableColumnVisibility(columns),
|
|
103
|
+
...columnVisibility, // `columnVisibility` is managed by ExploreState; use table options to override this setting.
|
|
102
104
|
};
|
|
103
105
|
}
|
|
104
106
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TableCellProps } from "@mui/material";
|
|
2
|
+
type TableCellPropsOptions = {
|
|
3
|
+
ALIGN: typeof ALIGN;
|
|
4
|
+
PADDING: typeof PADDING;
|
|
5
|
+
SIZE: typeof SIZE;
|
|
6
|
+
VARIANT: typeof VARIANT;
|
|
7
|
+
};
|
|
8
|
+
declare const ALIGN: Record<string, TableCellProps["align"]>;
|
|
9
|
+
declare const PADDING: Record<string, TableCellProps["padding"]>;
|
|
10
|
+
declare const SIZE: Record<string, TableCellProps["size"]>;
|
|
11
|
+
declare const VARIANT: Record<string, TableCellProps["variant"]>;
|
|
12
|
+
export declare const TABLE_CELL_PROPS: TableCellPropsOptions;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const ALIGN = {
|
|
2
|
+
CENTER: "center",
|
|
3
|
+
INHERIT: "inherit",
|
|
4
|
+
JUSTIFY: "justify",
|
|
5
|
+
LEFT: "left",
|
|
6
|
+
RIGHT: "right",
|
|
7
|
+
};
|
|
8
|
+
const PADDING = {
|
|
9
|
+
CHECKBOX: "checkbox",
|
|
10
|
+
NONE: "none",
|
|
11
|
+
NORMAL: "normal",
|
|
12
|
+
};
|
|
13
|
+
const SIZE = {
|
|
14
|
+
MEDIUM: "medium",
|
|
15
|
+
SMALL: "small",
|
|
16
|
+
};
|
|
17
|
+
const VARIANT = {
|
|
18
|
+
BODY: "body",
|
|
19
|
+
FOOTER: "footer",
|
|
20
|
+
HEAD: "head",
|
|
21
|
+
};
|
|
22
|
+
export const TABLE_CELL_PROPS = {
|
|
23
|
+
ALIGN,
|
|
24
|
+
PADDING,
|
|
25
|
+
SIZE,
|
|
26
|
+
VARIANT,
|
|
27
|
+
};
|
|
@@ -195,12 +195,6 @@ export declare const MuiSvgIcon: (theme: Theme) => Components["MuiSvgIcon"];
|
|
|
195
195
|
* @returns MuiTab component theme styles.
|
|
196
196
|
*/
|
|
197
197
|
export declare const MuiTab: (theme: Theme) => Components["MuiTab"];
|
|
198
|
-
/**
|
|
199
|
-
* MuiTableCell Component
|
|
200
|
-
* @param theme - Theme.
|
|
201
|
-
* @returns MuiTableCell component theme styles.
|
|
202
|
-
*/
|
|
203
|
-
export declare const MuiTableCell: (theme: Theme) => Components["MuiTableCell"];
|
|
204
198
|
/**
|
|
205
199
|
* MuiTableSortLabel Component
|
|
206
200
|
*/
|
|
@@ -1233,37 +1233,6 @@ export const MuiTab = (theme) => {
|
|
|
1233
1233
|
},
|
|
1234
1234
|
};
|
|
1235
1235
|
};
|
|
1236
|
-
/**
|
|
1237
|
-
* MuiTableCell Component
|
|
1238
|
-
* @param theme - Theme.
|
|
1239
|
-
* @returns MuiTableCell component theme styles.
|
|
1240
|
-
*/
|
|
1241
|
-
export const MuiTableCell = (theme) => {
|
|
1242
|
-
return {
|
|
1243
|
-
styleOverrides: {
|
|
1244
|
-
body: {
|
|
1245
|
-
...theme.typography[TEXT_BODY_400],
|
|
1246
|
-
},
|
|
1247
|
-
head: {
|
|
1248
|
-
...theme.typography[TEXT_BODY_SMALL_500],
|
|
1249
|
-
padding: "20px",
|
|
1250
|
-
},
|
|
1251
|
-
paddingCheckbox: {
|
|
1252
|
-
paddingRight: 0,
|
|
1253
|
-
width: "unset",
|
|
1254
|
-
},
|
|
1255
|
-
root: {
|
|
1256
|
-
padding: "18px 20px",
|
|
1257
|
-
},
|
|
1258
|
-
sizeSmall: {
|
|
1259
|
-
padding: "14px 20px",
|
|
1260
|
-
},
|
|
1261
|
-
stickyHeader: {
|
|
1262
|
-
boxShadow: `0 1px 0 ${theme.palette.smoke.main}`,
|
|
1263
|
-
},
|
|
1264
|
-
},
|
|
1265
|
-
};
|
|
1266
|
-
};
|
|
1267
1236
|
/**
|
|
1268
1237
|
* MuiTableSortLabel Component
|
|
1269
1238
|
*/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { TABLE_CELL_PROPS } from "../../styles/common/mui/tableCell";
|
|
2
|
+
import { TEXT_BODY_400, TEXT_BODY_SMALL_500 } from "../common/typography";
|
|
3
|
+
export const MuiTableCell = (theme) => {
|
|
4
|
+
const paletteSmoke = theme.palette.smoke;
|
|
5
|
+
const typography = theme.typography;
|
|
6
|
+
return {
|
|
7
|
+
defaultProps: {},
|
|
8
|
+
styleOverrides: {
|
|
9
|
+
root: {
|
|
10
|
+
minHeight: 56,
|
|
11
|
+
stickyHeader: {
|
|
12
|
+
boxShadow: `0 1px 0 ${paletteSmoke.main}`,
|
|
13
|
+
},
|
|
14
|
+
variants: [
|
|
15
|
+
{
|
|
16
|
+
props: { size: TABLE_CELL_PROPS.SIZE.MEDIUM },
|
|
17
|
+
style: { padding: "10px 16px" },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
props: { size: TABLE_CELL_PROPS.SIZE.SMALL },
|
|
21
|
+
style: { padding: "8px 16px" },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
props: { padding: TABLE_CELL_PROPS.PADDING.CHECKBOX },
|
|
25
|
+
style: { paddingRight: 0, width: "unset" },
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
props: { padding: TABLE_CELL_PROPS.PADDING.NONE },
|
|
29
|
+
style: { padding: 0 },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
props: { variant: TABLE_CELL_PROPS.VARIANT.BODY },
|
|
33
|
+
style: {
|
|
34
|
+
...typography[TEXT_BODY_400],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
props: { variant: TABLE_CELL_PROPS.VARIANT.HEAD },
|
|
39
|
+
style: {
|
|
40
|
+
...typography[TEXT_BODY_SMALL_500],
|
|
41
|
+
backgroundColor: paletteSmoke.lightest,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
package/lib/theme/theme.js
CHANGED
|
@@ -95,7 +95,7 @@ export function createAppTheme(customOptions) {
|
|
|
95
95
|
MuiSelect: C.MuiSelect,
|
|
96
96
|
MuiSvgIcon: C.MuiSvgIcon(theme),
|
|
97
97
|
MuiTab: C.MuiTab(theme),
|
|
98
|
-
MuiTableCell:
|
|
98
|
+
MuiTableCell: M.MuiTableCell(theme),
|
|
99
99
|
MuiTableSortLabel: C.MuiTableSortLabel,
|
|
100
100
|
MuiTabs: C.MuiTabs(theme),
|
|
101
101
|
MuiToggleButton: C.MuiToggleButton(theme),
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { LayoutStyle } from "../../components/Layout/components/ContentLayout/common/entities";
|
|
3
|
+
import { BaseComponentProps } from "../../components/types";
|
|
3
4
|
export interface ContentViewProps {
|
|
4
5
|
content: ReactNode;
|
|
5
6
|
layoutStyle?: LayoutStyle;
|
|
6
7
|
navigation?: ReactNode;
|
|
7
8
|
outline?: ReactNode;
|
|
8
9
|
}
|
|
9
|
-
export declare const ContentView: ({ content, layoutStyle, navigation, outline, }: ContentViewProps) => JSX.Element;
|
|
10
|
+
export declare const ContentView: ({ className, content, layoutStyle, navigation, outline, }: BaseComponentProps & ContentViewProps) => JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ContentLayout } from "../../components/Layout/components/ContentLayout/contentLayout";
|
|
3
|
-
export const ContentView = ({ content, layoutStyle, navigation, outline, }) => {
|
|
4
|
-
return (React.createElement(ContentLayout, { content: content, layoutStyle: layoutStyle, navigation: navigation, outline: outline }));
|
|
3
|
+
export const ContentView = ({ className, content, layoutStyle, navigation, outline, }) => {
|
|
4
|
+
return (React.createElement(ContentLayout, { className: className, content: content, layoutStyle: layoutStyle, navigation: navigation, outline: outline }));
|
|
5
5
|
};
|
|
@@ -152,7 +152,7 @@ function renderComponent(componentsConfig, response) {
|
|
|
152
152
|
function renderList(exploreState, entityConfig, entityListType) {
|
|
153
153
|
const { listItems, loading, tabValue } = exploreState;
|
|
154
154
|
const { getId: getRowId, list, listView } = entityConfig;
|
|
155
|
-
const { columns: columnsConfig, defaultSort } = list;
|
|
155
|
+
const { columns: columnsConfig, defaultSort, tableOptions } = list;
|
|
156
156
|
if (!exploreState || !tabValue) {
|
|
157
157
|
return React.createElement(React.Fragment, null); //TODO: return the loading UI component
|
|
158
158
|
}
|
|
@@ -161,7 +161,7 @@ function renderList(exploreState, entityConfig, entityListType) {
|
|
|
161
161
|
// loads with the previous tabs data on the first render after switching tabs. (or similar)
|
|
162
162
|
return React.createElement(React.Fragment, null);
|
|
163
163
|
}
|
|
164
|
-
return (React.createElement(TableCreator, { columns: columnsConfig, defaultSort: defaultSort, getRowId: getRowId, items: listItems ?? [], listView: listView, loading: loading }));
|
|
164
|
+
return (React.createElement(TableCreator, { columns: columnsConfig, defaultSort: defaultSort, getRowId: getRowId, items: listItems ?? [], listView: listView, loading: loading, tableOptions: tableOptions }));
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
167
167
|
* Renders Summaries component when all the following requirements are fulfilled:
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { TableCell
|
|
1
|
+
import { TableCell } from "@mui/material";
|
|
2
2
|
import { flexRender, Row, RowData, Table } from "@tanstack/react-table";
|
|
3
3
|
import React, { Fragment } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getTableCellAlign,
|
|
6
|
+
getTableCellPadding,
|
|
7
|
+
} from "../../../../../Table/components/TableCell/common/utils";
|
|
5
8
|
import { TableRow } from "../../../../../Table/components/TableRow/tableRow.styles";
|
|
6
9
|
import { TableView } from "../../table";
|
|
7
10
|
|
|
@@ -31,13 +34,14 @@ export const TableRows = <T extends RowData>({
|
|
|
31
34
|
if (cell.getIsAggregated()) return null; // Display of aggregated cells is currently not supported.
|
|
32
35
|
if (cell.getIsPlaceholder()) return null; // Display of placeholder cells is currently not supported.
|
|
33
36
|
return (
|
|
34
|
-
<
|
|
37
|
+
<TableCell
|
|
35
38
|
key={cell.id}
|
|
39
|
+
align={getTableCellAlign(cell.column)}
|
|
36
40
|
padding={getTableCellPadding(cell.column.id)}
|
|
37
41
|
size={tableCellSize}
|
|
38
42
|
>
|
|
39
43
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
40
|
-
</
|
|
44
|
+
</TableCell>
|
|
41
45
|
);
|
|
42
46
|
})}
|
|
43
47
|
</TableRow>
|
|
@@ -17,8 +17,10 @@ import {
|
|
|
17
17
|
useBreakpointHelper,
|
|
18
18
|
} from "../../../../hooks/useBreakpointHelper";
|
|
19
19
|
import { TABLET } from "../../../../theme/common/breakpoints";
|
|
20
|
+
import { COLUMN_DEF } from "../../../Table/common/columnDef";
|
|
20
21
|
import { ROW_DIRECTION } from "../../../Table/common/entities";
|
|
21
22
|
import { TableHead } from "../../../Table/components/TableHead/tableHead";
|
|
23
|
+
import { ROW_POSITION } from "../../../Table/features/RowPosition/constants";
|
|
22
24
|
import { ROW_PREVIEW } from "../../../Table/features/RowPreview/constants";
|
|
23
25
|
import { GridTable } from "../../../Table/table.styles";
|
|
24
26
|
import { generateColumnDefinitions } from "./common/utils";
|
|
@@ -56,8 +58,11 @@ export const Table = <T extends RowData>({
|
|
|
56
58
|
const { stickyHeader = false } = table || {};
|
|
57
59
|
const { sx: tableContainerSx } = tableContainer || {};
|
|
58
60
|
const tableInstance = useReactTable({
|
|
59
|
-
_features: [ROW_PREVIEW],
|
|
60
|
-
columns: generateColumnDefinitions(
|
|
61
|
+
_features: [ROW_POSITION, ROW_PREVIEW],
|
|
62
|
+
columns: generateColumnDefinitions([
|
|
63
|
+
COLUMN_DEF.ROW_POSITION as ColumnDef<T>,
|
|
64
|
+
...columns,
|
|
65
|
+
]),
|
|
61
66
|
data: items,
|
|
62
67
|
enableSorting: false,
|
|
63
68
|
getCoreRowModel: getCoreRowModel(),
|
|
@@ -2,11 +2,7 @@ import { css } from "@emotion/react";
|
|
|
2
2
|
import styled from "@emotion/styled";
|
|
3
3
|
import { FormControl as MFormControl } from "@mui/material";
|
|
4
4
|
import { mediaTabletUp } from "../../../../styles/common/mixins/breakpoints";
|
|
5
|
-
import {
|
|
6
|
-
inkMain,
|
|
7
|
-
smokeLightest,
|
|
8
|
-
smokeMain,
|
|
9
|
-
} from "../../../../styles/common/mixins/colors";
|
|
5
|
+
import { inkMain, smokeMain } from "../../../../styles/common/mixins/colors";
|
|
10
6
|
import { textBodyLarge500 } from "../../../../styles/common/mixins/fonts";
|
|
11
7
|
import { ThemeProps } from "../../../../theme/theme";
|
|
12
8
|
import {
|
|
@@ -75,8 +71,6 @@ export const TableFormControl = styled(FormControl)`
|
|
|
75
71
|
|
|
76
72
|
.MuiTable-root {
|
|
77
73
|
th {
|
|
78
|
-
background-color: ${smokeLightest};
|
|
79
|
-
|
|
80
74
|
.MuiFormControlLabel-label {
|
|
81
75
|
font: inherit;
|
|
82
76
|
}
|
|
@@ -30,6 +30,7 @@ const COLOR: Record<
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
interface LayoutProps {
|
|
33
|
+
hasNavigation?: boolean;
|
|
33
34
|
panelColor?: PanelBackgroundColor;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -49,10 +50,18 @@ export const ContentLayout = styled.div<LayoutProps>`
|
|
|
49
50
|
margin: 0 auto;
|
|
50
51
|
|
|
51
52
|
${mediaDesktopSmallUp} {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
${({ hasNavigation }) =>
|
|
54
|
+
hasNavigation
|
|
55
|
+
? css`
|
|
56
|
+
grid-template-areas: "navigation content";
|
|
57
|
+
grid-template-columns:
|
|
58
|
+
${NAV_GRID_WIDTH}px
|
|
59
|
+
1fr;
|
|
60
|
+
`
|
|
61
|
+
: css`
|
|
62
|
+
grid-template-areas: "content";
|
|
63
|
+
grid-template-columns: 1fr;
|
|
64
|
+
`};
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
${media1366Up} {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useRouter } from "next/router";
|
|
2
2
|
import React, { ReactNode } from "react";
|
|
3
3
|
import { useLayoutState } from "../../../../hooks/useLayoutState";
|
|
4
|
+
import { BaseComponentProps } from "../../../types";
|
|
4
5
|
import { LayoutStyle } from "./common/entities";
|
|
5
6
|
import {
|
|
6
7
|
Content,
|
|
@@ -14,7 +15,6 @@ import {
|
|
|
14
15
|
} from "./contentLayout.styles";
|
|
15
16
|
|
|
16
17
|
export interface ContentLayoutProps {
|
|
17
|
-
className?: string;
|
|
18
18
|
content: ReactNode;
|
|
19
19
|
layoutStyle?: LayoutStyle;
|
|
20
20
|
navigation?: ReactNode;
|
|
@@ -27,13 +27,17 @@ export const ContentLayout = ({
|
|
|
27
27
|
layoutStyle,
|
|
28
28
|
navigation,
|
|
29
29
|
outline,
|
|
30
|
-
}: ContentLayoutProps): JSX.Element => {
|
|
30
|
+
}: BaseComponentProps & ContentLayoutProps): JSX.Element => {
|
|
31
31
|
const { asPath } = useRouter();
|
|
32
32
|
const {
|
|
33
33
|
layoutState: { headerHeight },
|
|
34
34
|
} = useLayoutState();
|
|
35
35
|
return (
|
|
36
|
-
<Layout
|
|
36
|
+
<Layout
|
|
37
|
+
className={className}
|
|
38
|
+
hasNavigation={Boolean(navigation)}
|
|
39
|
+
panelColor={layoutStyle?.content}
|
|
40
|
+
>
|
|
37
41
|
{navigation && (
|
|
38
42
|
<NavigationGrid
|
|
39
43
|
headerHeight={headerHeight}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnDef, RowData } from "@tanstack/react-table";
|
|
2
|
+
import { TABLE_CELL_PROPS } from "../../../styles/common/mui/tableCell";
|
|
3
|
+
import { ACCESSOR_KEYS } from "../../TableCreator/common/constants";
|
|
4
|
+
import { RowPositionCell } from "../components/TableCell/components/RowPositionCell/rowPositionCell";
|
|
5
|
+
|
|
6
|
+
export const COLUMN_DEF: Record<string, ColumnDef<RowData>> = {
|
|
7
|
+
ROW_POSITION: {
|
|
8
|
+
cell: RowPositionCell,
|
|
9
|
+
enableHiding: false,
|
|
10
|
+
enableSorting: false,
|
|
11
|
+
header: "",
|
|
12
|
+
id: ACCESSOR_KEYS.ROW_POSITION,
|
|
13
|
+
meta: {
|
|
14
|
+
align: TABLE_CELL_PROPS.ALIGN.RIGHT,
|
|
15
|
+
header: "",
|
|
16
|
+
width: "max-content",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { TableCellProps
|
|
2
|
-
import { CoreCell, CoreHeader, RowData } from "@tanstack/react-table";
|
|
1
|
+
import { TableCellProps } from "@mui/material";
|
|
2
|
+
import { Column, CoreCell, CoreHeader, RowData } from "@tanstack/react-table";
|
|
3
|
+
import { TABLE_CELL_PROPS } from "../../../../../styles/common/mui/tableCell";
|
|
3
4
|
import { ACCESSOR_KEYS } from "../../../../TableCreator/common/constants";
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Returns table cell alignment based on the cell.
|
|
8
|
+
* @param column - Column.
|
|
9
|
+
* @returns table cell alignment.
|
|
10
|
+
*/
|
|
11
|
+
export function getTableCellAlign<T extends RowData, TValue>(
|
|
12
|
+
column: Column<T, TValue>
|
|
13
|
+
): TableCellProps["align"] {
|
|
14
|
+
return column.columnDef.meta?.align;
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
/**
|
|
6
18
|
* Returns table cell padding based on the cell ID.
|
|
7
19
|
* @param id - Cell ID.
|
|
@@ -9,8 +21,13 @@ import { ACCESSOR_KEYS } from "../../../../TableCreator/common/constants";
|
|
|
9
21
|
*/
|
|
10
22
|
export function getTableCellPadding<T extends RowData, TValue>(
|
|
11
23
|
id: CoreHeader<T, TValue>["id"] | CoreCell<T, TValue>["id"]
|
|
12
|
-
):
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
): TableCellProps["padding"] {
|
|
25
|
+
switch (id) {
|
|
26
|
+
case ACCESSOR_KEYS.ROW_POSITION:
|
|
27
|
+
return TABLE_CELL_PROPS.PADDING.NORMAL;
|
|
28
|
+
case ACCESSOR_KEYS.SELECT:
|
|
29
|
+
return TABLE_CELL_PROPS.PADDING.CHECKBOX;
|
|
30
|
+
default:
|
|
31
|
+
return TABLE_CELL_PROPS.PADDING.NORMAL;
|
|
15
32
|
}
|
|
16
33
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TypographyOwnProps } from "@mui/material";
|
|
2
|
+
import { VARIANT } from "../../../../../../styles/common/mui/typography";
|
|
3
|
+
|
|
4
|
+
export const TYPOGRAPHY_PROPS: Partial<TypographyOwnProps> = {
|
|
5
|
+
sx: { marginRight: -2, paddingLeft: 2 },
|
|
6
|
+
variant: VARIANT.INHERIT,
|
|
7
|
+
};
|
package/src/components/Table/components/TableCell/components/RowPositionCell/rowPositionCell.tsx
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Typography } from "@mui/material";
|
|
2
|
+
import { CellContext, RowData } from "@tanstack/react-table";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { BaseComponentProps } from "../../../../../types";
|
|
5
|
+
import { TYPOGRAPHY_PROPS } from "./constants";
|
|
6
|
+
|
|
7
|
+
export const RowPositionCell = <TData extends RowData, TValue>({
|
|
8
|
+
className,
|
|
9
|
+
...cellContext
|
|
10
|
+
}: BaseComponentProps & CellContext<TData, TValue>): JSX.Element => {
|
|
11
|
+
return (
|
|
12
|
+
<Typography {...TYPOGRAPHY_PROPS} className={className} component="div">
|
|
13
|
+
{cellContext.row.getRowPosition()}
|
|
14
|
+
</Typography>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
TableCell as MTableCell,
|
|
3
2
|
TableHead as MTableHead,
|
|
4
3
|
TableRow as MTableRow,
|
|
4
|
+
TableCell,
|
|
5
5
|
TableSortLabel,
|
|
6
6
|
} from "@mui/material";
|
|
7
7
|
import { flexRender, RowData, Table } from "@tanstack/react-table";
|
|
8
8
|
import React, { Fragment } from "react";
|
|
9
9
|
import { ROW_DIRECTION } from "../../common/entities";
|
|
10
10
|
import { getTableSortLabelProps } from "../../common/utils";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getTableCellAlign,
|
|
13
|
+
getTableCellPadding,
|
|
14
|
+
} from "../TableCell/common/utils";
|
|
12
15
|
|
|
13
16
|
export interface TableHeadProps<T extends RowData> {
|
|
14
17
|
rowDirection: ROW_DIRECTION;
|
|
@@ -34,8 +37,9 @@ export const TableHead = <T extends RowData>({
|
|
|
34
37
|
},
|
|
35
38
|
} = header;
|
|
36
39
|
return header.column.getIsGrouped() ? null : (
|
|
37
|
-
<
|
|
40
|
+
<TableCell
|
|
38
41
|
key={header.id}
|
|
42
|
+
align={getTableCellAlign(header.column)}
|
|
39
43
|
padding={getTableCellPadding(header.id)}
|
|
40
44
|
>
|
|
41
45
|
{header.column.getCanSort() && enableSortingInteraction ? (
|
|
@@ -53,7 +57,7 @@ export const TableHead = <T extends RowData>({
|
|
|
53
57
|
header.getContext()
|
|
54
58
|
)
|
|
55
59
|
)}
|
|
56
|
-
</
|
|
60
|
+
</TableCell>
|
|
57
61
|
);
|
|
58
62
|
})}
|
|
59
63
|
</MTableRow>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { TableCell
|
|
1
|
+
import { TableCell } from "@mui/material";
|
|
2
2
|
import { flexRender, Row, RowData, Table } from "@tanstack/react-table";
|
|
3
3
|
import { Virtualizer } from "@tanstack/react-virtual";
|
|
4
4
|
import React, { Fragment } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getTableCellAlign,
|
|
7
|
+
getTableCellPadding,
|
|
8
|
+
} from "../TableCell/common/utils";
|
|
6
9
|
import { TableRow } from "../TableRow/tableRow.styles";
|
|
7
10
|
|
|
8
11
|
export interface TableRowsProps<T extends RowData> {
|
|
@@ -30,12 +33,13 @@ export const TableRows = <T extends RowData>({
|
|
|
30
33
|
ref={virtualizer.measureElement}
|
|
31
34
|
>
|
|
32
35
|
{row.getVisibleCells().map((cell) => (
|
|
33
|
-
<
|
|
36
|
+
<TableCell
|
|
34
37
|
key={cell.id}
|
|
38
|
+
align={getTableCellAlign(cell.column)}
|
|
35
39
|
padding={getTableCellPadding(cell.column.id)}
|
|
36
40
|
>
|
|
37
41
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
38
|
-
</
|
|
42
|
+
</TableCell>
|
|
39
43
|
))}
|
|
40
44
|
</TableRow>
|
|
41
45
|
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Cell,
|
|
3
|
+
Column,
|
|
4
|
+
Row,
|
|
5
|
+
RowData,
|
|
6
|
+
RowModel,
|
|
7
|
+
Table,
|
|
8
|
+
TableFeature,
|
|
9
|
+
TableState,
|
|
10
|
+
} from "@tanstack/react-table";
|
|
11
|
+
import { InitialTableState } from "@tanstack/table-core/src/types";
|
|
12
|
+
import { getRowModel, getRowPosition, initInitialState } from "./utils";
|
|
13
|
+
|
|
14
|
+
export const ROW_POSITION: TableFeature = {
|
|
15
|
+
createCell: <T extends RowData, TValue>(
|
|
16
|
+
cell: Cell<T, TValue>,
|
|
17
|
+
column: Column<T>,
|
|
18
|
+
row: Row<T>,
|
|
19
|
+
table: Table<T>
|
|
20
|
+
): void => {
|
|
21
|
+
row.getRowPosition = (): number => {
|
|
22
|
+
return getRowPosition(row.id, table);
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
createTable: <T extends RowData>(table: Table<T>): void => {
|
|
26
|
+
const originalGetRowModel = table.getRowModel.bind(table);
|
|
27
|
+
table.getRowModel = (): RowModel<T> => {
|
|
28
|
+
return getRowModel(table, originalGetRowModel);
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
getInitialState: (initialState?: InitialTableState): Partial<TableState> => {
|
|
32
|
+
return initInitialState(initialState);
|
|
33
|
+
},
|
|
34
|
+
};
|