tycho-components 0.0.18-SNAPSHOT-1 → 0.0.18-SNAPSHOT-3
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/dist/AppTable/AppTable.js +25 -15
- package/package.json +1 -1
|
@@ -8,7 +8,6 @@ import TableContainer from '@mui/material/TableContainer';
|
|
|
8
8
|
import TableHead from '@mui/material/TableHead';
|
|
9
9
|
import TableRow from '@mui/material/TableRow';
|
|
10
10
|
import { flexRender, getCoreRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
11
|
-
import { useEffect } from 'react';
|
|
12
11
|
import AppPagination from '../AppPagination';
|
|
13
12
|
import { tableTheme } from './AppTableTheme';
|
|
14
13
|
import './styles.scss';
|
|
@@ -28,22 +27,33 @@ export default function AppTable({ columns, data, pagination, setPagination, sor
|
|
|
28
27
|
columnVisibility,
|
|
29
28
|
},
|
|
30
29
|
manualPagination: true,
|
|
31
|
-
manualSorting: true,
|
|
32
30
|
getCoreRowModel: getCoreRowModel(),
|
|
33
31
|
getPaginationRowModel: getPaginationRowModel(),
|
|
34
32
|
getSortedRowModel: getSortedRowModel(),
|
|
33
|
+
onSortingChange: (updaterOrValue) => {
|
|
34
|
+
const newSorting = typeof updaterOrValue === 'function'
|
|
35
|
+
? updaterOrValue(sorting)
|
|
36
|
+
: updaterOrValue;
|
|
37
|
+
if (newSorting &&
|
|
38
|
+
sorting &&
|
|
39
|
+
JSON.stringify(newSorting) !== JSON.stringify(sorting)) {
|
|
40
|
+
setSorting(newSorting);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
35
43
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
?
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
return (_jsx(ThemeProvider, { theme: tableTheme, children: _jsxs(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) => {
|
|
45
|
+
const toggleSortingHandler = header.column.getToggleSortingHandler();
|
|
46
|
+
return (_jsxs(TableCell, { onClick: (event) => {
|
|
47
|
+
if (toggleSortingHandler) {
|
|
48
|
+
toggleSortingHandler(event);
|
|
49
|
+
}
|
|
50
|
+
}, style: {
|
|
51
|
+
cursor: 'pointer',
|
|
52
|
+
width: `${header.column.columnDef.size}%`,
|
|
53
|
+
}, children: [flexRender(header.column.columnDef.header, header.getContext()), header.column.getIsSorted()
|
|
54
|
+
? header.column.getIsSorted() === 'desc'
|
|
55
|
+
? ' 🔽'
|
|
56
|
+
: ' 🔼'
|
|
57
|
+
: null] }, header.id));
|
|
58
|
+
}) }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row) => (_jsx(TableRow, { onMouseEnter: () => onMouseEnter && onMouseEnter(row), onMouseLeave: () => onMouseLeave && onMouseLeave(row), children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { onClick: () => onClickRow && onClickRow(row.original, cell.column), className: cell.id.includes('__') ? cell.id.split('__')[1] : '', children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }), _jsx(AppPagination, { totalElements: totalElements, pagination: pagination, setPagination: setPagination })] }) }));
|
|
49
59
|
}
|