material-react-table 0.1.0 → 0.3.2
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/README.md +32 -162
- package/dist/MaterialReactTable.d.ts +62 -26
- package/dist/{MRT_TableBody.d.ts → body/MRT_TableBody.d.ts} +0 -0
- package/dist/{MRT_TableBodyCell.d.ts → body/MRT_TableBodyCell.d.ts} +1 -1
- package/dist/body/MRT_TableBodyRow.d.ts +22 -0
- package/dist/{MRT_TableDetailPanel.d.ts → body/MRT_TableDetailPanel.d.ts} +1 -1
- package/dist/{MRT_TableBodyRow.d.ts → buttons/MRT_EditActionButtons.d.ts} +2 -2
- package/dist/buttons/MRT_ExpandAllButton.d.ts +5 -0
- package/dist/{MRT_TableExpandButton.d.ts → buttons/MRT_ExpandButton.d.ts} +2 -2
- package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +5 -0
- package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +7 -0
- package/dist/buttons/MRT_ToggleFiltersButton.d.ts +4 -0
- package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +7 -0
- package/dist/{MRT_TableFooter.d.ts → footer/MRT_TableFooter.d.ts} +0 -0
- package/dist/{MRT_TableFooterCell.d.ts → footer/MRT_TableFooterCell.d.ts} +0 -0
- package/dist/{MRT_TableFooterRow.d.ts → footer/MRT_TableFooterRow.d.ts} +1 -1
- package/dist/{MRT_TableHead.d.ts → head/MRT_TableHead.d.ts} +0 -0
- package/dist/head/MRT_TableHeadCell.d.ts +11 -0
- package/dist/{MRT_TableHeadRow.d.ts → head/MRT_TableHeadRow.d.ts} +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/inputs/MRT_DensePaddingSwitch.d.ts +5 -0
- package/dist/inputs/MRT_EditCellTextfield.d.ts +7 -0
- package/dist/{MRT_TableHeadCell.d.ts → inputs/MRT_FilterTextField.d.ts} +1 -1
- package/dist/inputs/MRT_SearchTextField.d.ts +5 -0
- package/dist/inputs/MRT_SelectAllCheckbox.d.ts +2 -0
- package/dist/inputs/MRT_SelectCheckbox.d.ts +7 -0
- package/dist/material-react-table.cjs.development.js +2083 -191
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +2087 -195
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +9 -0
- package/dist/menus/MRT_RowActionMenu.d.ts +9 -0
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +7 -0
- package/dist/{MRT_Table.d.ts → table/MRT_Table.d.ts} +0 -0
- package/dist/{MRT_TableContainer.d.ts → table/MRT_TableContainer.d.ts} +0 -0
- package/dist/table/MRT_TableSpacerCell.d.ts +6 -0
- package/dist/{MRT_TablePagination.d.ts → toolbar/MRT_TablePagination.d.ts} +0 -0
- package/dist/toolbar/MRT_ToolbarBottom.d.ts +5 -0
- package/dist/toolbar/MRT_ToolbarButtons.d.ts +5 -0
- package/dist/toolbar/MRT_ToolbarTop.d.ts +5 -0
- package/dist/useMaterialReactTable.d.ts +14 -12
- package/dist/utils/localization.d.ts +26 -0
- package/dist/utils/useMRTCalcs.d.ts +11 -0
- package/package.json +26 -21
- package/src/@types/faker.d.ts +4 -0
- package/src/@types/react-table-config.d.ts +153 -0
- package/src/MaterialReactTable.tsx +151 -37
- package/src/body/MRT_TableBody.tsx +35 -0
- package/src/body/MRT_TableBodyCell.tsx +69 -0
- package/src/body/MRT_TableBodyRow.tsx +84 -0
- package/src/body/MRT_TableDetailPanel.tsx +73 -0
- package/src/buttons/MRT_EditActionButtons.tsx +55 -0
- package/src/buttons/MRT_ExpandAllButton.tsx +47 -0
- package/src/buttons/MRT_ExpandButton.tsx +51 -0
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +43 -0
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +51 -0
- package/src/buttons/MRT_ToggleFiltersButton.tsx +23 -0
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +65 -0
- package/src/footer/MRT_TableFooter.tsx +21 -0
- package/src/footer/MRT_TableFooterCell.tsx +60 -0
- package/src/footer/MRT_TableFooterRow.tsx +62 -0
- package/src/head/MRT_TableHead.tsx +26 -0
- package/src/head/MRT_TableHeadCell.tsx +137 -0
- package/src/head/MRT_TableHeadRow.tsx +90 -0
- package/src/index.tsx +2 -0
- package/src/inputs/MRT_DensePaddingSwitch.tsx +21 -0
- package/src/inputs/MRT_EditCellTextfield.tsx +57 -0
- package/src/inputs/MRT_FilterTextField.tsx +63 -0
- package/src/inputs/MRT_SearchTextField.tsx +74 -0
- package/src/inputs/MRT_SelectAllCheckbox.tsx +26 -0
- package/src/inputs/MRT_SelectCheckbox.tsx +34 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +107 -0
- package/src/menus/MRT_RowActionMenu.tsx +52 -0
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +34 -0
- package/src/table/MRT_Table.tsx +30 -0
- package/src/table/MRT_TableContainer.tsx +50 -0
- package/src/table/MRT_TableSpacerCell.tsx +26 -0
- package/src/toolbar/MRT_TablePagination.tsx +37 -0
- package/src/toolbar/MRT_ToolbarBottom.tsx +43 -0
- package/src/toolbar/MRT_ToolbarButtons.tsx +27 -0
- package/src/toolbar/MRT_ToolbarTop.tsx +68 -0
- package/src/useMaterialReactTable.tsx +70 -32
- package/src/utils/localization.ts +51 -0
- package/src/utils/useMRTCalcs.tsx +42 -0
- package/dist/defaults.d.ts +0 -2
- package/src/MRT_Table.tsx +0 -20
- package/src/MRT_TableBody.tsx +0 -19
- package/src/MRT_TableBodyCell.tsx +0 -15
- package/src/MRT_TableBodyRow.tsx +0 -27
- package/src/MRT_TableContainer.tsx +0 -16
- package/src/MRT_TableDetailPanel.tsx +0 -27
- package/src/MRT_TableExpandButton.tsx +0 -25
- package/src/MRT_TableFooter.tsx +0 -31
- package/src/MRT_TableFooterCell.tsx +0 -25
- package/src/MRT_TableFooterRow.tsx +0 -22
- package/src/MRT_TableHead.tsx +0 -25
- package/src/MRT_TableHeadCell.tsx +0 -27
- package/src/MRT_TableHeadRow.tsx +0 -22
- package/src/MRT_TablePagination.tsx +0 -34
- package/src/defaults.ts +0 -11
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton, TableCell } from '@mui/material';
|
|
3
|
-
import { Row } from 'react-table';
|
|
4
|
-
import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
|
|
5
|
-
// import { useMaterialReactTable } from './useMaterialReactTable';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
row: Row<object>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const MRT_TableExpandButton: FC<Props> = ({ row }) => {
|
|
12
|
-
return (
|
|
13
|
-
<TableCell style={{ width: '2rem' }} size="small" variant="head">
|
|
14
|
-
<IconButton onClick={() => row.toggleRowExpanded()} size="small">
|
|
15
|
-
<ArrowForwardIosIcon
|
|
16
|
-
fontSize="small"
|
|
17
|
-
style={{
|
|
18
|
-
transform: row.isExpanded ? 'rotate(90deg)' : 'rotate(0)',
|
|
19
|
-
transition: 'transform 0.2s',
|
|
20
|
-
}}
|
|
21
|
-
/>
|
|
22
|
-
</IconButton>
|
|
23
|
-
</TableCell>
|
|
24
|
-
);
|
|
25
|
-
};
|
package/src/MRT_TableFooter.tsx
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { TableFooter } from '@mui/material';
|
|
3
|
-
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
|
4
|
-
import { useMaterialReactTable } from './useMaterialReactTable';
|
|
5
|
-
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
6
|
-
|
|
7
|
-
interface Props {}
|
|
8
|
-
|
|
9
|
-
export const MRT_TableFooter: FC<Props> = () => {
|
|
10
|
-
const { tableInstance, tableFooterProps, options } = useMaterialReactTable();
|
|
11
|
-
|
|
12
|
-
const hasFooterGroups = tableInstance.columns.some(
|
|
13
|
-
(c) => c.depth === 0 && !!c.Footer,
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<TableFooter {...tableFooterProps}>
|
|
18
|
-
{hasFooterGroups &&
|
|
19
|
-
tableInstance.footerGroups.map((footerGroup, index) => (
|
|
20
|
-
<MRT_TableFooterRow
|
|
21
|
-
key={`${index}-${footerGroup.id}`}
|
|
22
|
-
footerGroup={footerGroup}
|
|
23
|
-
/>
|
|
24
|
-
))}
|
|
25
|
-
{options.enablePagination === true ||
|
|
26
|
-
(['bottom', 'both'].includes(options.enablePagination.toString()) && (
|
|
27
|
-
<MRT_TablePagination />
|
|
28
|
-
))}
|
|
29
|
-
</TableFooter>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { styled, TableCell as MuiTableCell } from '@mui/material';
|
|
3
|
-
import { HeaderGroup } from 'react-table';
|
|
4
|
-
|
|
5
|
-
const TableCell = styled(MuiTableCell)({
|
|
6
|
-
fontWeight: 'bold',
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
column: HeaderGroup;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
14
|
-
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<TableCell
|
|
18
|
-
align={isParentHeader ? 'center' : 'left'}
|
|
19
|
-
variant="head"
|
|
20
|
-
{...column.getFooterProps()}
|
|
21
|
-
>
|
|
22
|
-
{column.render('Footer')}
|
|
23
|
-
</TableCell>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { TableCell, TableRow } from '@mui/material';
|
|
3
|
-
import { HeaderGroup } from 'react-table';
|
|
4
|
-
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
|
5
|
-
import { useMaterialReactTable } from './useMaterialReactTable';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
footerGroup: HeaderGroup<object>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
12
|
-
const { renderDetailPanel } = useMaterialReactTable();
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<TableRow {...footerGroup.getFooterGroupProps()}>
|
|
16
|
-
{renderDetailPanel && <TableCell style={{ width: '2rem' }} />}
|
|
17
|
-
{footerGroup.headers.map((column, index) => (
|
|
18
|
-
<MRT_TableFooterCell key={`${index}-${column.id}`} column={column} />
|
|
19
|
-
))}
|
|
20
|
-
</TableRow>
|
|
21
|
-
);
|
|
22
|
-
};
|
package/src/MRT_TableHead.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { TableHead } from '@mui/material';
|
|
3
|
-
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
|
4
|
-
import { useMaterialReactTable } from './useMaterialReactTable';
|
|
5
|
-
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
6
|
-
|
|
7
|
-
interface Props {}
|
|
8
|
-
|
|
9
|
-
export const MRT_TableHead: FC<Props> = () => {
|
|
10
|
-
const { tableInstance, tableHeadProps, options } = useMaterialReactTable();
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<TableHead {...tableHeadProps}>
|
|
14
|
-
{['top', 'both'].includes(options.enablePagination.toString()) && (
|
|
15
|
-
<MRT_TablePagination />
|
|
16
|
-
)}
|
|
17
|
-
{tableInstance.headerGroups.map((headerGroup, index) => (
|
|
18
|
-
<MRT_TableHeadRow
|
|
19
|
-
key={`${index}-${headerGroup.id}`}
|
|
20
|
-
headerGroup={headerGroup}
|
|
21
|
-
/>
|
|
22
|
-
))}
|
|
23
|
-
</TableHead>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { TableCell, TableSortLabel } from '@mui/material';
|
|
3
|
-
import { HeaderGroup } from 'react-table';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
column: HeaderGroup;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
10
|
-
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<TableCell
|
|
14
|
-
align={isParentHeader ? 'center' : 'left'}
|
|
15
|
-
style={{ fontWeight: 'bold !important' }}
|
|
16
|
-
variant="head"
|
|
17
|
-
{...column.getHeaderProps(column.getSortByToggleProps())}
|
|
18
|
-
>
|
|
19
|
-
<TableSortLabel
|
|
20
|
-
active={column.isSorted}
|
|
21
|
-
direction={column.isSortedDesc && column.isSortedDesc ? 'desc' : 'asc'}
|
|
22
|
-
>
|
|
23
|
-
{column.render('Header')}
|
|
24
|
-
</TableSortLabel>
|
|
25
|
-
</TableCell>
|
|
26
|
-
);
|
|
27
|
-
};
|
package/src/MRT_TableHeadRow.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { TableCell, TableRow } from '@mui/material';
|
|
3
|
-
import { HeaderGroup } from 'react-table';
|
|
4
|
-
import { MRT_TableHeadCell } from './MRT_TableHeadCell';
|
|
5
|
-
import { useMaterialReactTable } from './useMaterialReactTable';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
headerGroup: HeaderGroup<object>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
12
|
-
const { renderDetailPanel } = useMaterialReactTable();
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<TableRow {...headerGroup.getHeaderGroupProps()}>
|
|
16
|
-
{renderDetailPanel && <TableCell style={{ width: '2rem' }} />}
|
|
17
|
-
{headerGroup.headers.map((column, index) => (
|
|
18
|
-
<MRT_TableHeadCell key={`${index}-${column.id}`} column={column} />
|
|
19
|
-
))}
|
|
20
|
-
</TableRow>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React, { ChangeEvent, FC } from 'react';
|
|
2
|
-
import { TablePagination, TableRow } from '@mui/material';
|
|
3
|
-
import { useMaterialReactTable } from './useMaterialReactTable';
|
|
4
|
-
|
|
5
|
-
interface Props {}
|
|
6
|
-
|
|
7
|
-
export const MRT_TablePagination: FC<Props> = () => {
|
|
8
|
-
const { tableInstance, tablePaginationProps } = useMaterialReactTable();
|
|
9
|
-
|
|
10
|
-
const handleChangeRowsPerPage = (event: ChangeEvent<HTMLInputElement>) => {
|
|
11
|
-
tableInstance.setPageSize(+event.target.value);
|
|
12
|
-
tableInstance.gotoPage(0);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<TableRow>
|
|
17
|
-
<TablePagination
|
|
18
|
-
colSpan={tableInstance.visibleColumns.length + 10}
|
|
19
|
-
count={tableInstance.rows.length}
|
|
20
|
-
onPageChange={(_, newPage) => tableInstance.gotoPage(newPage)}
|
|
21
|
-
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
22
|
-
page={tableInstance.state.pageIndex}
|
|
23
|
-
rowsPerPage={tableInstance.state.pageSize}
|
|
24
|
-
showFirstButton={
|
|
25
|
-
tableInstance.rows.length / tableInstance.state.pageSize > 2
|
|
26
|
-
}
|
|
27
|
-
showLastButton={
|
|
28
|
-
tableInstance.rows.length / tableInstance.state.pageSize > 2
|
|
29
|
-
}
|
|
30
|
-
{...tablePaginationProps}
|
|
31
|
-
/>
|
|
32
|
-
</TableRow>
|
|
33
|
-
);
|
|
34
|
-
};
|
package/src/defaults.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MaterialReactTableOptions } from '.';
|
|
2
|
-
|
|
3
|
-
export const defaultOptions: MaterialReactTableOptions = {
|
|
4
|
-
enableFilters: false,
|
|
5
|
-
enablePagination: 'bottom',
|
|
6
|
-
enableSearch: true,
|
|
7
|
-
enableSorting: true,
|
|
8
|
-
showFooter: true,
|
|
9
|
-
showHead: true,
|
|
10
|
-
showToolbar: true,
|
|
11
|
-
};
|