material-react-table 0.7.0-alpha.8 → 0.7.1
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 +3 -5
- package/dist/MaterialReactTable.d.ts +65 -46
- package/dist/buttons/{MRT_ToggleSearchButton.d.ts → MRT_ToggleGlobalFilterButton.d.ts} +1 -1
- package/dist/localization.d.ts +3 -0
- package/dist/material-react-table.cjs.development.js +228 -167
- 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 +231 -170
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -2
- package/dist/utils.d.ts +5 -5
- package/package.json +5 -5
- package/src/MaterialReactTable.tsx +103 -57
- package/src/body/MRT_TableBodyCell.tsx +5 -3
- package/src/buttons/MRT_EditActionButtons.tsx +1 -1
- package/src/buttons/MRT_FullScreenToggleButton.tsx +13 -4
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +0 -1
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +13 -4
- package/src/buttons/MRT_ToggleFiltersButton.tsx +13 -4
- package/src/buttons/{MRT_ToggleSearchButton.tsx → MRT_ToggleGlobalFilterButton.tsx} +14 -8
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +8 -9
- package/src/inputs/MRT_EditCellTextField.tsx +2 -5
- package/src/inputs/MRT_FilterTextField.tsx +2 -2
- package/src/inputs/MRT_SearchTextField.tsx +6 -6
- package/src/localization.ts +6 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +4 -4
- package/src/menus/MRT_FilterTypeMenu.tsx +5 -8
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -7
- package/src/table/MRT_Table.tsx +5 -5
- package/src/table/MRT_TableContainer.tsx +4 -4
- package/src/table/MRT_TablePaper.tsx +9 -13
- package/src/table/MRT_TableRoot.tsx +96 -79
- package/src/toolbar/MRT_ToolbarBottom.tsx +2 -2
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -9
- package/src/toolbar/MRT_ToolbarTop.tsx +2 -2
- package/src/utils.ts +10 -10
|
@@ -15,7 +15,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ tableInstance }) => {
|
|
|
15
15
|
const {
|
|
16
16
|
getState,
|
|
17
17
|
options: {
|
|
18
|
-
|
|
18
|
+
enableToolbarInternalActions,
|
|
19
19
|
idPrefix,
|
|
20
20
|
enablePagination,
|
|
21
21
|
muiTableToolbarBottomProps,
|
|
@@ -51,7 +51,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ tableInstance }) => {
|
|
|
51
51
|
<Box
|
|
52
52
|
sx={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}
|
|
53
53
|
>
|
|
54
|
-
{
|
|
54
|
+
{enableToolbarInternalActions && positionToolbarActions === 'bottom' ? (
|
|
55
55
|
<MRT_ToolbarInternalButtons tableInstance={tableInstance} />
|
|
56
56
|
) : (
|
|
57
57
|
<span />
|
|
@@ -4,7 +4,7 @@ import { MRT_FullScreenToggleButton } from '../buttons/MRT_FullScreenToggleButto
|
|
|
4
4
|
import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
|
|
5
5
|
import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingButton';
|
|
6
6
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
|
7
|
-
import {
|
|
7
|
+
import { MRT_ToggleGlobalFilterButton } from '../buttons/MRT_ToggleGlobalFilterButton';
|
|
8
8
|
import { MRT_TableInstance } from '..';
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
@@ -15,10 +15,11 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ tableInstance }) => {
|
|
|
15
15
|
const {
|
|
16
16
|
options: {
|
|
17
17
|
enableColumnFilters,
|
|
18
|
-
enableHiding,
|
|
19
18
|
enableDensePaddingToggle,
|
|
20
|
-
|
|
19
|
+
enableFilters,
|
|
21
20
|
enableFullScreenToggle,
|
|
21
|
+
enableGlobalFilter,
|
|
22
|
+
enableHiding,
|
|
22
23
|
renderToolbarInternalActions,
|
|
23
24
|
},
|
|
24
25
|
} = tableInstance;
|
|
@@ -31,7 +32,7 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ tableInstance }) => {
|
|
|
31
32
|
MRT_ShowHideColumnsButton,
|
|
32
33
|
MRT_ToggleDensePaddingButton,
|
|
33
34
|
MRT_ToggleFiltersButton,
|
|
34
|
-
|
|
35
|
+
MRT_ToggleGlobalFilterButton,
|
|
35
36
|
tableInstance,
|
|
36
37
|
})}
|
|
37
38
|
</>
|
|
@@ -42,15 +43,13 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ tableInstance }) => {
|
|
|
42
43
|
<Box
|
|
43
44
|
sx={{
|
|
44
45
|
display: 'flex',
|
|
45
|
-
gap: '0.5rem',
|
|
46
46
|
alignItems: 'center',
|
|
47
|
-
p: '0 0.5rem',
|
|
48
47
|
}}
|
|
49
48
|
>
|
|
50
|
-
{enableGlobalFilter && (
|
|
51
|
-
<
|
|
49
|
+
{enableFilters && enableGlobalFilter && (
|
|
50
|
+
<MRT_ToggleGlobalFilterButton tableInstance={tableInstance} />
|
|
52
51
|
)}
|
|
53
|
-
{enableColumnFilters && (
|
|
52
|
+
{enableFilters && enableColumnFilters && (
|
|
54
53
|
<MRT_ToggleFiltersButton tableInstance={tableInstance} />
|
|
55
54
|
)}
|
|
56
55
|
{enableHiding && (
|
|
@@ -29,7 +29,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
|
|
|
29
29
|
options: {
|
|
30
30
|
enableGlobalFilter,
|
|
31
31
|
enablePagination,
|
|
32
|
-
|
|
32
|
+
enableToolbarInternalActions,
|
|
33
33
|
idPrefix,
|
|
34
34
|
muiTableToolbarTopProps,
|
|
35
35
|
positionPagination,
|
|
@@ -82,7 +82,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
|
|
|
82
82
|
{enableGlobalFilter && (
|
|
83
83
|
<MRT_SearchTextField tableInstance={tableInstance} />
|
|
84
84
|
)}
|
|
85
|
-
{
|
|
85
|
+
{enableToolbarInternalActions && positionToolbarActions === 'top' && (
|
|
86
86
|
<MRT_ToolbarInternalButtons tableInstance={tableInstance} />
|
|
87
87
|
)}
|
|
88
88
|
</Box>
|
package/src/utils.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ColumnDef, Table } from '@tanstack/react-table';
|
|
2
|
-
import {
|
|
2
|
+
import { MRT_ColumnDef, MRT_FilterType } from '.';
|
|
3
3
|
import { MRT_FILTER_TYPE } from './enums';
|
|
4
4
|
|
|
5
5
|
export const getAllLeafColumnDefs = (
|
|
6
|
-
columns:
|
|
7
|
-
):
|
|
8
|
-
let lowestLevelColumns:
|
|
9
|
-
let currentCols:
|
|
6
|
+
columns: MRT_ColumnDef[],
|
|
7
|
+
): MRT_ColumnDef[] => {
|
|
8
|
+
let lowestLevelColumns: MRT_ColumnDef[] = columns;
|
|
9
|
+
let currentCols: MRT_ColumnDef[] | undefined = columns;
|
|
10
10
|
while (!!currentCols?.length && currentCols.some((col) => col.columns)) {
|
|
11
|
-
const nextCols:
|
|
11
|
+
const nextCols: MRT_ColumnDef[] = currentCols
|
|
12
12
|
.filter((col) => !!col.columns)
|
|
13
13
|
.map((col) => col.columns)
|
|
14
|
-
.flat() as
|
|
14
|
+
.flat() as MRT_ColumnDef[];
|
|
15
15
|
if (nextCols.every((col) => !col?.columns)) {
|
|
16
16
|
lowestLevelColumns = [...lowestLevelColumns, ...nextCols];
|
|
17
17
|
}
|
|
@@ -22,7 +22,7 @@ export const getAllLeafColumnDefs = (
|
|
|
22
22
|
|
|
23
23
|
export const createGroup = <D extends Record<string, any> = {}>(
|
|
24
24
|
table: Table<D>,
|
|
25
|
-
column:
|
|
25
|
+
column: MRT_ColumnDef<D>,
|
|
26
26
|
currentFilterTypes: { [key: string]: MRT_FilterType },
|
|
27
27
|
): ColumnDef<D> =>
|
|
28
28
|
table.createGroup({
|
|
@@ -36,7 +36,7 @@ export const createGroup = <D extends Record<string, any> = {}>(
|
|
|
36
36
|
|
|
37
37
|
export const createDataColumn = <D extends Record<string, any> = {}>(
|
|
38
38
|
table: Table<D>,
|
|
39
|
-
column:
|
|
39
|
+
column: MRT_ColumnDef<D>,
|
|
40
40
|
currentFilterTypes: { [key: string]: MRT_FilterType },
|
|
41
41
|
): ColumnDef<D> => // @ts-ignore
|
|
42
42
|
table.createDataColumn(column.id, {
|
|
@@ -46,5 +46,5 @@ export const createDataColumn = <D extends Record<string, any> = {}>(
|
|
|
46
46
|
|
|
47
47
|
export const createDisplayColumn = <D extends Record<string, any> = {}>(
|
|
48
48
|
table: Table<D>,
|
|
49
|
-
column: Omit<
|
|
49
|
+
column: Omit<MRT_ColumnDef<D>, 'header'> & { header?: string },
|
|
50
50
|
): ColumnDef<D> => table.createDisplayColumn(column);
|