material-react-table 0.4.5 → 0.4.6
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 +4 -2
- package/dist/icons.d.ts +25 -0
- package/dist/{utils/localization.d.ts → localization.d.ts} +1 -1
- package/dist/material-react-table.cjs.development.js +156 -130
- 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 +156 -130
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/useMRT.d.ts +6 -2
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +7 -3
- package/src/body/MRT_TableBodyRow.tsx +8 -6
- package/src/buttons/MRT_EditActionButtons.tsx +5 -6
- package/src/buttons/MRT_ExpandAllButton.tsx +17 -18
- package/src/buttons/MRT_ExpandButton.tsx +18 -19
- package/src/buttons/MRT_FullScreenToggleButton.tsx +9 -6
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +9 -6
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +6 -4
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +8 -5
- package/src/buttons/MRT_ToggleFiltersButton.tsx +8 -5
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +6 -7
- package/src/buttons/MRT_ToggleSearchButton.tsx +8 -5
- package/src/head/MRT_TableHeadCell.tsx +5 -5
- package/src/head/MRT_TableHeadCellActions.tsx +1 -1
- package/src/icons.tsx +72 -0
- package/src/inputs/MRT_FilterTextField.tsx +12 -13
- package/src/inputs/MRT_SearchTextField.tsx +4 -5
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -4
- package/src/{utils/localization.ts → localization.ts} +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +14 -12
- package/src/menus/MRT_RowActionMenu.tsx +2 -2
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -3
- package/src/useMRT.tsx +6 -2
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC, useState } from 'react';
|
|
2
2
|
import { IconButton, InputAdornment, TextField, Tooltip } from '@mui/material';
|
|
3
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
4
|
-
import FilterIcon from '@mui/icons-material/FilterList';
|
|
5
3
|
import { HeaderGroup, useAsyncDebounce } from 'react-table';
|
|
6
4
|
import { useMRT } from '../useMRT';
|
|
7
5
|
|
|
@@ -10,7 +8,10 @@ interface Props {
|
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
13
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
icons: { FilterListIcon, CloseIcon },
|
|
13
|
+
localization,
|
|
14
|
+
} = useMRT();
|
|
14
15
|
|
|
15
16
|
const [filterValue, setFilterValue] = useState('');
|
|
16
17
|
|
|
@@ -37,7 +38,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
37
38
|
},
|
|
38
39
|
}}
|
|
39
40
|
margin="dense"
|
|
40
|
-
placeholder={localization
|
|
41
|
+
placeholder={localization.filterTextFieldPlaceholder?.replace(
|
|
41
42
|
'{column}',
|
|
42
43
|
String(column.Header),
|
|
43
44
|
)}
|
|
@@ -52,15 +53,13 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
52
53
|
startAdornment: (
|
|
53
54
|
<Tooltip
|
|
54
55
|
arrow
|
|
55
|
-
title={
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
) ?? ''
|
|
60
|
-
}
|
|
56
|
+
title={localization.filterTextFieldPlaceholder?.replace(
|
|
57
|
+
'{column}',
|
|
58
|
+
String(column.Header),
|
|
59
|
+
)}
|
|
61
60
|
>
|
|
62
61
|
<InputAdornment position="start">
|
|
63
|
-
<
|
|
62
|
+
<FilterListIcon />
|
|
64
63
|
</InputAdornment>
|
|
65
64
|
</Tooltip>
|
|
66
65
|
),
|
|
@@ -68,11 +67,11 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
68
67
|
<InputAdornment position="end">
|
|
69
68
|
<Tooltip
|
|
70
69
|
arrow
|
|
71
|
-
title={localization
|
|
70
|
+
title={localization.filterTextFieldClearButtonTitle ?? ''}
|
|
72
71
|
>
|
|
73
72
|
<span>
|
|
74
73
|
<IconButton
|
|
75
|
-
aria-label={localization
|
|
74
|
+
aria-label={localization.filterTextFieldClearButtonTitle}
|
|
76
75
|
disabled={filterValue?.length === 0}
|
|
77
76
|
onClick={handleClear}
|
|
78
77
|
size="small"
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
styled,
|
|
7
7
|
TextField as MuiTextField,
|
|
8
8
|
} from '@mui/material';
|
|
9
|
-
import SearchIcon from '@mui/icons-material/Search';
|
|
10
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
11
9
|
import { useMRT } from '../useMRT';
|
|
12
10
|
import { useAsyncDebounce } from 'react-table';
|
|
13
11
|
|
|
@@ -19,6 +17,7 @@ interface Props {}
|
|
|
19
17
|
|
|
20
18
|
export const MRT_SearchTextField: FC<Props> = () => {
|
|
21
19
|
const {
|
|
20
|
+
icons: { SearchIcon, CloseIcon },
|
|
22
21
|
showSearch,
|
|
23
22
|
localization,
|
|
24
23
|
muiSearchTextFieldProps,
|
|
@@ -45,7 +44,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
45
44
|
<Collapse in={showSearch} orientation="horizontal">
|
|
46
45
|
<TextField
|
|
47
46
|
id="global-search-text-field"
|
|
48
|
-
placeholder={localization
|
|
47
|
+
placeholder={localization.searchTextFieldPlaceholder}
|
|
49
48
|
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
|
50
49
|
setSearchValue(event.target.value);
|
|
51
50
|
handleChange(event);
|
|
@@ -61,11 +60,11 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
61
60
|
endAdornment: (
|
|
62
61
|
<InputAdornment position="end">
|
|
63
62
|
<IconButton
|
|
64
|
-
aria-label={localization
|
|
63
|
+
aria-label={localization.searchTextFieldClearButtonTitle}
|
|
65
64
|
disabled={searchValue?.length === 0}
|
|
66
65
|
onClick={handleClear}
|
|
67
66
|
size="small"
|
|
68
|
-
title={localization
|
|
67
|
+
title={localization.searchTextFieldClearButtonTitle}
|
|
69
68
|
>
|
|
70
69
|
<CloseIcon fontSize="small" />
|
|
71
70
|
</IconButton>
|
|
@@ -40,15 +40,15 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
|
40
40
|
enterNextDelay={1000}
|
|
41
41
|
title={
|
|
42
42
|
selectAll
|
|
43
|
-
? localization
|
|
44
|
-
: localization
|
|
43
|
+
? localization.selectAllCheckboxTitle
|
|
44
|
+
: localization.selectCheckboxTitle
|
|
45
45
|
}
|
|
46
46
|
>
|
|
47
47
|
<Checkbox
|
|
48
48
|
inputProps={{
|
|
49
49
|
'aria-label': selectAll
|
|
50
|
-
? localization
|
|
51
|
-
: localization
|
|
50
|
+
? localization.selectAllCheckboxTitle
|
|
51
|
+
: localization.selectCheckboxTitle,
|
|
52
52
|
}}
|
|
53
53
|
onChange={onSelectChange}
|
|
54
54
|
{...checkboxProps}
|
|
@@ -32,7 +32,7 @@ export interface MRT_Localization {
|
|
|
32
32
|
toolbarAlertGroupedThenByMessage: string;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export const
|
|
35
|
+
export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
36
36
|
actionsHeadColumnTitle: 'Actions',
|
|
37
37
|
columnActionMenuButtonTitle: 'Column Actions',
|
|
38
38
|
columnActionMenuItemClearSort: 'Clear sort',
|
|
@@ -2,11 +2,6 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { Divider, Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { HeaderGroup } from 'react-table';
|
|
5
|
-
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
6
|
-
import SortIcon from '@mui/icons-material/Sort';
|
|
7
|
-
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
8
|
-
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
|
9
|
-
import FilterIcon from '@mui/icons-material/FilterList';
|
|
10
5
|
|
|
11
6
|
const MenuItem = styled(MuiMenuItem)({
|
|
12
7
|
display: 'flex',
|
|
@@ -31,6 +26,13 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
31
26
|
enableColumnGrouping,
|
|
32
27
|
localization,
|
|
33
28
|
setShowFilters,
|
|
29
|
+
icons: {
|
|
30
|
+
FilterListIcon,
|
|
31
|
+
SortIcon,
|
|
32
|
+
ClearAllIcon,
|
|
33
|
+
DynamicFeedIcon,
|
|
34
|
+
VisibilityOffIcon,
|
|
35
|
+
},
|
|
34
36
|
} = useMRT();
|
|
35
37
|
|
|
36
38
|
const handleClearSort = () => {
|
|
@@ -87,7 +89,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
87
89
|
disabled={!column.isSorted}
|
|
88
90
|
onClick={handleClearSort}
|
|
89
91
|
>
|
|
90
|
-
<ClearAllIcon /> {localization
|
|
92
|
+
<ClearAllIcon /> {localization.columnActionMenuItemClearSort}
|
|
91
93
|
</MenuItem>,
|
|
92
94
|
<MenuItem
|
|
93
95
|
key={2}
|
|
@@ -95,7 +97,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
95
97
|
onClick={handleSortAsc}
|
|
96
98
|
>
|
|
97
99
|
<SortIcon />{' '}
|
|
98
|
-
{localization
|
|
100
|
+
{localization.columnActionMenuItemSortAsc?.replace(
|
|
99
101
|
'{column}',
|
|
100
102
|
String(column.Header),
|
|
101
103
|
)}
|
|
@@ -106,7 +108,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
106
108
|
onClick={handleSortDesc}
|
|
107
109
|
>
|
|
108
110
|
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />{' '}
|
|
109
|
-
{localization
|
|
111
|
+
{localization.columnActionMenuItemSortDesc?.replace(
|
|
110
112
|
'{column}',
|
|
111
113
|
String(column.Header),
|
|
112
114
|
)}
|
|
@@ -116,8 +118,8 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
116
118
|
column.canFilter && [
|
|
117
119
|
<Divider key={0} />,
|
|
118
120
|
<MenuItem key={1} onClick={handleFilterByColumn}>
|
|
119
|
-
<
|
|
120
|
-
{localization
|
|
121
|
+
<FilterListIcon />{' '}
|
|
122
|
+
{localization.filterTextFieldPlaceholder?.replace(
|
|
121
123
|
'{column}',
|
|
122
124
|
String(column.Header),
|
|
123
125
|
)}
|
|
@@ -128,7 +130,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
128
130
|
<Divider key={1} />,
|
|
129
131
|
<MenuItem key={2} onClick={handleGroupByColumn}>
|
|
130
132
|
<DynamicFeedIcon />{' '}
|
|
131
|
-
{localization
|
|
133
|
+
{localization[
|
|
132
134
|
column.isGrouped
|
|
133
135
|
? 'columnActionMenuItemUnGroupBy'
|
|
134
136
|
: 'columnActionMenuItemGroupBy'
|
|
@@ -139,7 +141,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
139
141
|
<Divider key={0} />,
|
|
140
142
|
<MenuItem key={1} onClick={handleHideColumn}>
|
|
141
143
|
<VisibilityOffIcon />{' '}
|
|
142
|
-
{localization
|
|
144
|
+
{localization.columnActionMenuItemHideColumn?.replace(
|
|
143
145
|
'{column}',
|
|
144
146
|
String(column.Header),
|
|
145
147
|
)}
|
|
@@ -2,7 +2,6 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { Row } from 'react-table';
|
|
5
|
-
import EditIcon from '@mui/icons-material/Edit';
|
|
6
5
|
|
|
7
6
|
const MenuItem = styled(MuiMenuItem)({
|
|
8
7
|
display: 'flex',
|
|
@@ -23,6 +22,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
23
22
|
setAnchorEl,
|
|
24
23
|
}) => {
|
|
25
24
|
const {
|
|
25
|
+
icons: { EditIcon },
|
|
26
26
|
enableRowEditing,
|
|
27
27
|
localization,
|
|
28
28
|
renderRowActionMenuItems,
|
|
@@ -37,7 +37,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
37
37
|
>
|
|
38
38
|
{enableRowEditing && (
|
|
39
39
|
<MenuItem onClick={handleEdit}>
|
|
40
|
-
<EditIcon /> {localization
|
|
40
|
+
<EditIcon /> {localization.rowActionMenuItemEdit}
|
|
41
41
|
</MenuItem>
|
|
42
42
|
)}
|
|
43
43
|
{renderRowActionMenuItems?.(row, tableInstance, () =>
|
|
@@ -47,7 +47,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
|
|
|
47
47
|
|
|
48
48
|
const selectMessage =
|
|
49
49
|
tableInstance.selectedFlatRows.length > 0
|
|
50
|
-
? localization
|
|
50
|
+
? localization.toolbarAlertSelectionMessage
|
|
51
51
|
?.replace(
|
|
52
52
|
'{selectedCount}',
|
|
53
53
|
tableInstance.selectedFlatRows.length.toString(),
|
|
@@ -58,10 +58,10 @@ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
|
|
|
58
58
|
const groupedByMessage =
|
|
59
59
|
tableInstance.state.groupBy.length > 0 ? (
|
|
60
60
|
<span>
|
|
61
|
-
{localization
|
|
61
|
+
{localization.toolbarAlertGroupedByMessage}{' '}
|
|
62
62
|
{tableInstance.state.groupBy.map((columnId, index) => (
|
|
63
63
|
<Fragment key={`${index}-${columnId}`}>
|
|
64
|
-
{index > 0 ? localization
|
|
64
|
+
{index > 0 ? localization.toolbarAlertGroupedThenByMessage : ''}
|
|
65
65
|
<Chip
|
|
66
66
|
color="secondary"
|
|
67
67
|
label={
|
package/src/useMRT.tsx
CHANGED
|
@@ -21,14 +21,18 @@ import {
|
|
|
21
21
|
useSortBy,
|
|
22
22
|
useTable,
|
|
23
23
|
} from 'react-table';
|
|
24
|
+
import { MRT_Icons } from './icons';
|
|
25
|
+
import { MRT_Localization } from './localization';
|
|
24
26
|
import { MaterialReactTableProps } from './MaterialReactTable';
|
|
25
27
|
|
|
26
|
-
export
|
|
28
|
+
export type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
27
29
|
anyRowsCanExpand: boolean;
|
|
28
30
|
anyRowsExpanded: boolean;
|
|
29
31
|
currentEditingRow: Row<D> | null;
|
|
30
32
|
densePadding: boolean;
|
|
31
33
|
fullScreen: boolean;
|
|
34
|
+
icons: MRT_Icons;
|
|
35
|
+
localization: MRT_Localization;
|
|
32
36
|
setCurrentEditingRow: (currentRowEditingId: Row<D> | null) => void;
|
|
33
37
|
setDensePadding: (densePadding: boolean) => void;
|
|
34
38
|
setFullScreen: (fullScreen: boolean) => void;
|
|
@@ -37,7 +41,7 @@ export interface UseMRT<D extends {} = {}> extends MaterialReactTableProps<D> {
|
|
|
37
41
|
showFilters: boolean;
|
|
38
42
|
showSearch: boolean;
|
|
39
43
|
tableInstance: TableInstance<D>;
|
|
40
|
-
}
|
|
44
|
+
};
|
|
41
45
|
|
|
42
46
|
const MaterialReactTableContext = (<D extends {}>() =>
|
|
43
47
|
createContext<UseMRT<D>>({} as UseMRT<D>) as Context<UseMRT<D>>)();
|