tycho-components 0.0.17-SNAPSHOT-6 → 0.0.17-SNAPSHOT-8
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.
|
@@ -24,7 +24,31 @@ export default function AppPagination({ totalElements, pagination, setPagination
|
|
|
24
24
|
const menuProps = {
|
|
25
25
|
PaperProps: {
|
|
26
26
|
style: {
|
|
27
|
-
maxHeight:
|
|
27
|
+
maxHeight: 200,
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
|
+
anchorOrigin: {
|
|
31
|
+
vertical: 'top',
|
|
32
|
+
horizontal: 'left',
|
|
33
|
+
},
|
|
34
|
+
transformOrigin: {
|
|
35
|
+
vertical: 'bottom',
|
|
36
|
+
horizontal: 'left',
|
|
37
|
+
},
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
39
|
+
// @ts-expect-error -- PopperProps is not typed but works at runtime
|
|
40
|
+
PopperProps: {
|
|
41
|
+
modifiers: [
|
|
42
|
+
{
|
|
43
|
+
name: 'flip',
|
|
44
|
+
enabled: false,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'offset',
|
|
48
|
+
options: {
|
|
49
|
+
offset: [0, -4],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
30
54
|
};
|
|
@@ -8,6 +8,7 @@ type Props = {
|
|
|
8
8
|
onMouseEnter?: (row: any) => void;
|
|
9
9
|
onMouseLeave?: (row: any) => void;
|
|
10
10
|
hiddenColumns?: string[];
|
|
11
|
+
filter?: [string, string];
|
|
11
12
|
};
|
|
12
|
-
export default function AppListTable({ columns, data, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default function AppListTable({ columns, data, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, filter, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Paper, TableBody, TableCell, TableContainer, TableHead, TableRow, } from '@mui/material';
|
|
3
|
-
import { flexRender, getCoreRowModel, useReactTable, } from '@tanstack/react-table';
|
|
3
|
+
import { flexRender, getCoreRowModel, getFilteredRowModel, useReactTable, } from '@tanstack/react-table';
|
|
4
4
|
import { Table, ThemeProvider } from 'react-bootstrap';
|
|
5
5
|
import { tableTheme } from './AppTableTheme';
|
|
6
6
|
import './styles.scss';
|
|
7
|
-
|
|
7
|
+
import { useEffect } from 'react';
|
|
8
|
+
export default function AppListTable({ columns, data, className = '', onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, filter, }) {
|
|
8
9
|
const columnVisibility = hiddenColumns?.reduce((acc, key) => {
|
|
9
10
|
acc[key] = false;
|
|
10
11
|
return acc;
|
|
@@ -16,11 +17,22 @@ export default function AppListTable({ columns, data, className = '', onClickRow
|
|
|
16
17
|
columnVisibility,
|
|
17
18
|
},
|
|
18
19
|
getCoreRowModel: getCoreRowModel(),
|
|
20
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
19
21
|
});
|
|
20
22
|
const handleClickRow = (row) => {
|
|
21
23
|
if (onClickRow)
|
|
22
24
|
onClickRow(row.original);
|
|
23
25
|
};
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!filter)
|
|
28
|
+
return;
|
|
29
|
+
if (filter[1]) {
|
|
30
|
+
table.getColumn(filter[0])?.setFilterValue(filter[1]);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
table.getColumn(filter[0])?.setFilterValue(undefined);
|
|
34
|
+
}
|
|
35
|
+
}, [filter]);
|
|
24
36
|
return (_jsx(ThemeProvider, { theme: tableTheme, children: _jsx(Paper, { className: `ds-table ${className}`, children: _jsx(TableContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header) => (_jsx(TableCell, { style: { width: header.getSize() }, children: header.isPlaceholder
|
|
25
37
|
? null
|
|
26
38
|
: flexRender(header.column.columnDef.header, header.getContext()) }, header.id))) }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row) => (_jsx(TableRow, { onClick: () => handleClickRow(row), onMouseEnter: () => onMouseEnter?.(row), onMouseLeave: () => onMouseLeave?.(row), children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }) }) }));
|