material-react-table 0.2.0 → 0.3.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/dist/MaterialReactTable.d.ts +26 -25
- package/dist/head/MRT_TableHeadCell.d.ts +0 -1
- package/dist/index.d.ts +3 -1
- package/dist/material-react-table.cjs.development.js +147 -104
- 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 +149 -106
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/useMaterialReactTable.d.ts +3 -4
- package/dist/utils/localization.d.ts +2 -0
- package/dist/utils/overrideWarnings.d.ts +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +48 -43
- package/src/body/MRT_TableBody.tsx +3 -3
- package/src/body/MRT_TableBodyCell.tsx +21 -9
- package/src/body/MRT_TableBodyRow.tsx +8 -6
- package/src/body/MRT_TableDetailPanel.tsx +3 -3
- package/src/buttons/MRT_ExpandAllButton.tsx +2 -2
- package/src/buttons/MRT_ExpandButton.tsx +5 -2
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +2 -0
- package/src/footer/MRT_TableFooter.tsx +3 -3
- package/src/footer/MRT_TableFooterCell.tsx +3 -3
- package/src/footer/MRT_TableFooterRow.tsx +9 -5
- package/src/footer/MRT_TablePagination.tsx +7 -4
- package/src/head/MRT_TableHead.tsx +5 -5
- package/src/head/MRT_TableHeadCell.tsx +22 -16
- package/src/head/MRT_TableHeadRow.tsx +7 -9
- package/src/index.tsx +6 -1
- package/src/inputs/MRT_SearchTextField.tsx +16 -7
- package/src/inputs/MRT_SelectAllCheckbox.tsx +4 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +43 -23
- package/src/toolbar/MRT_Toolbar.tsx +3 -3
- package/src/useMaterialReactTable.tsx +24 -11
- package/src/utils/localization.ts +5 -1
- package/src/utils/overrideWarnings.ts +12 -12
|
@@ -10,17 +10,18 @@ import {
|
|
|
10
10
|
useFilters,
|
|
11
11
|
useFlexLayout,
|
|
12
12
|
useGlobalFilter,
|
|
13
|
+
useGroupBy,
|
|
13
14
|
usePagination,
|
|
14
15
|
useResizeColumns,
|
|
15
16
|
useRowSelect,
|
|
16
17
|
useSortBy,
|
|
17
18
|
useTable,
|
|
18
19
|
} from 'react-table';
|
|
19
|
-
import { MaterialReactTableProps } from '
|
|
20
|
+
import { MaterialReactTableProps } from './MaterialReactTable';
|
|
20
21
|
import { UseMRTCalcs, useMRTCalcs } from './utils/useMRTCalcs';
|
|
21
|
-
import {
|
|
22
|
+
import { showoverrideWarnings } from './utils/overrideWarnings';
|
|
22
23
|
|
|
23
|
-
interface UseMaterialReactTable<D extends {}>
|
|
24
|
+
export interface UseMaterialReactTable<D extends {}>
|
|
24
25
|
extends MaterialReactTableProps<D>,
|
|
25
26
|
UseMRTCalcs {
|
|
26
27
|
tableInstance: TableInstance<D>;
|
|
@@ -35,15 +36,29 @@ export const MaterialReactTableProvider = <D extends {}>({
|
|
|
35
36
|
children,
|
|
36
37
|
columns,
|
|
37
38
|
data,
|
|
38
|
-
|
|
39
|
+
defaultColumn,
|
|
40
|
+
getRowId,
|
|
41
|
+
getSubRows,
|
|
42
|
+
initialState,
|
|
43
|
+
stateReducer,
|
|
44
|
+
surpressoverrideWarnings,
|
|
39
45
|
...rest
|
|
40
46
|
}: PropsWithChildren<MaterialReactTableProps<D>>) => {
|
|
41
|
-
const tableInstance = useTable(
|
|
42
|
-
{
|
|
47
|
+
const tableInstance = useTable<D>(
|
|
48
|
+
{
|
|
49
|
+
columns,
|
|
50
|
+
data,
|
|
51
|
+
defaultColumn,
|
|
52
|
+
getRowId,
|
|
53
|
+
getSubRows,
|
|
54
|
+
initialState,
|
|
55
|
+
stateReducer,
|
|
56
|
+
},
|
|
43
57
|
useFlexLayout,
|
|
44
58
|
useResizeColumns,
|
|
45
59
|
useFilters,
|
|
46
60
|
useGlobalFilter,
|
|
61
|
+
useGroupBy,
|
|
47
62
|
useSortBy,
|
|
48
63
|
useExpanded,
|
|
49
64
|
usePagination,
|
|
@@ -52,16 +67,14 @@ export const MaterialReactTableProvider = <D extends {}>({
|
|
|
52
67
|
|
|
53
68
|
const mrtCalcs = useMRTCalcs({ tableInstance });
|
|
54
69
|
|
|
55
|
-
if (process.env.NODE_ENV !== 'production' && !
|
|
56
|
-
|
|
70
|
+
if (process.env.NODE_ENV !== 'production' && !surpressoverrideWarnings) {
|
|
71
|
+
showoverrideWarnings(rest);
|
|
57
72
|
}
|
|
58
73
|
|
|
59
74
|
return (
|
|
60
75
|
<MaterialReactTableContext.Provider
|
|
61
|
-
//@ts-ignore
|
|
62
76
|
value={{
|
|
63
|
-
|
|
64
|
-
data,
|
|
77
|
+
//@ts-ignore
|
|
65
78
|
tableInstance,
|
|
66
79
|
...mrtCalcs,
|
|
67
80
|
...rest,
|
|
@@ -4,6 +4,8 @@ export interface MRT_Localization {
|
|
|
4
4
|
columnActionMenuItemSortAsc?: string;
|
|
5
5
|
columnActionMenuItemClearSort?: string;
|
|
6
6
|
columnActionMenuItemSortDesc?: string;
|
|
7
|
+
columnActionMenuItemGroupBy?: string;
|
|
8
|
+
columnActionMenuItemUnGroupBy?: string;
|
|
7
9
|
expandAllButtonTitle?: string;
|
|
8
10
|
expandButtonTitle?: string;
|
|
9
11
|
filterTextFieldClearButtonTitle?: string;
|
|
@@ -19,11 +21,13 @@ export const defaultLocalization: MRT_Localization = {
|
|
|
19
21
|
columnActionMenuItemSortAsc: 'Sort ascending',
|
|
20
22
|
columnActionMenuItemClearSort: 'Clear sorting',
|
|
21
23
|
columnActionMenuItemSortDesc: 'Sort descending',
|
|
24
|
+
columnActionMenuItemGroupBy: 'Group by column',
|
|
25
|
+
columnActionMenuItemUnGroupBy: 'Ungroup column',
|
|
22
26
|
expandAllButtonTitle: 'Expand all',
|
|
23
27
|
expandButtonTitle: 'Expand',
|
|
24
28
|
filterTextFieldClearButtonTitle: 'Clear filter',
|
|
25
29
|
filterTextFieldPlaceholder: 'Filter',
|
|
26
30
|
searchTextFieldClearButtonTitle: 'Clear search',
|
|
27
31
|
searchTextFieldPlaceholder: 'Search',
|
|
28
|
-
showHideColumnsButtonTitle: 'Show/Hide columns'
|
|
32
|
+
showHideColumnsButtonTitle: 'Show/Hide columns',
|
|
29
33
|
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
export const
|
|
2
|
-
if (props.
|
|
1
|
+
export const showoverrideWarnings = (props: any) => {
|
|
2
|
+
if (props.overrideTableBodyCellComponent) {
|
|
3
3
|
showWarning('TableCell', 'props');
|
|
4
4
|
}
|
|
5
|
-
if (props.
|
|
5
|
+
if (props.overrideTableBodyComponent) {
|
|
6
6
|
showWarning('TableBody', 'tableBodyProps');
|
|
7
7
|
}
|
|
8
|
-
if (props.
|
|
8
|
+
if (props.overrideTableBodyRowComponent) {
|
|
9
9
|
showWarning('TableRow', 'props');
|
|
10
10
|
}
|
|
11
|
-
if (props.
|
|
11
|
+
if (props.overrideTableDetailPanelComponent) {
|
|
12
12
|
showWarning('Detail Panel', 'tableDetailPanelProps');
|
|
13
13
|
}
|
|
14
|
-
if (props.
|
|
14
|
+
if (props.overrideTableFooterComponent) {
|
|
15
15
|
showWarning('TableFooter', 'tableFooterProps');
|
|
16
16
|
}
|
|
17
|
-
if (props.
|
|
17
|
+
if (props.overrideTableFooterCellComponent) {
|
|
18
18
|
showWarning('TableCell', 'props');
|
|
19
19
|
}
|
|
20
|
-
if (props.
|
|
20
|
+
if (props.overrideTableFooterRowComponent) {
|
|
21
21
|
showWarning('TableRow', 'props');
|
|
22
22
|
}
|
|
23
|
-
if (props.
|
|
23
|
+
if (props.overrideTableHeadComponent) {
|
|
24
24
|
showWarning('TableHead', 'tableHeadProps');
|
|
25
25
|
}
|
|
26
|
-
if (props.
|
|
26
|
+
if (props.overrideTableHeadRowComponent) {
|
|
27
27
|
showWarning('TableRow', 'props');
|
|
28
28
|
}
|
|
29
|
-
if (props.
|
|
29
|
+
if (props.overrideTablePaginationComponent) {
|
|
30
30
|
showWarning('', 'props');
|
|
31
31
|
}
|
|
32
|
-
if (props.
|
|
32
|
+
if (props.overrideTableToolbarComponent) {
|
|
33
33
|
showWarning('TableBodyCell', 'props');
|
|
34
34
|
}
|
|
35
35
|
};
|