material-react-table 0.3.1 → 0.3.5

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.
Files changed (72) hide show
  1. package/README.md +32 -162
  2. package/dist/MaterialReactTable.d.ts +17 -7
  3. package/dist/body/MRT_TableBodyCell.d.ts +3 -0
  4. package/dist/body/MRT_TableBodyRow.d.ts +16 -1
  5. package/dist/buttons/MRT_FullScreenToggleButton.d.ts +4 -0
  6. package/dist/buttons/MRT_ToggleSearchButton.d.ts +4 -0
  7. package/dist/head/MRT_TableHeadCell.d.ts +4 -1
  8. package/dist/head/MRT_TableHeadCellActions.d.ts +5 -0
  9. package/dist/inputs/MRT_EditCellTextField.d.ts +7 -0
  10. package/dist/inputs/MRT_FilterTextField.d.ts +1 -1
  11. package/dist/material-react-table.cjs.development.js +799 -441
  12. package/dist/material-react-table.cjs.development.js.map +1 -1
  13. package/dist/material-react-table.cjs.production.min.js +1 -1
  14. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  15. package/dist/material-react-table.esm.js +800 -442
  16. package/dist/material-react-table.esm.js.map +1 -1
  17. package/dist/menus/MRT_ColumnActionMenu.d.ts +2 -2
  18. package/dist/menus/MRT_RowActionMenu.d.ts +1 -0
  19. package/dist/table/MRT_TableButtonCell.d.ts +3 -0
  20. package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +5 -0
  21. package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +5 -0
  22. package/dist/useMRT.d.ts +20 -0
  23. package/dist/utils/localization.d.ts +12 -3
  24. package/package.json +26 -23
  25. package/src/@types/faker.d.ts +4 -0
  26. package/src/@types/react-table-config.d.ts +156 -0
  27. package/src/MaterialReactTable.tsx +29 -9
  28. package/src/body/MRT_TableBody.tsx +3 -25
  29. package/src/body/MRT_TableBodyCell.tsx +30 -9
  30. package/src/body/MRT_TableBodyRow.tsx +22 -14
  31. package/src/body/MRT_TableDetailPanel.tsx +19 -8
  32. package/src/buttons/MRT_EditActionButtons.tsx +11 -6
  33. package/src/buttons/MRT_ExpandAllButton.tsx +19 -25
  34. package/src/buttons/MRT_ExpandButton.tsx +28 -26
  35. package/src/buttons/MRT_FullScreenToggleButton.tsx +23 -0
  36. package/src/buttons/MRT_ShowHideColumnsButton.tsx +34 -3
  37. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -5
  38. package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
  39. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +48 -26
  40. package/src/buttons/MRT_ToggleSearchButton.tsx +33 -0
  41. package/src/footer/MRT_TableFooter.tsx +4 -4
  42. package/src/footer/MRT_TableFooterCell.tsx +23 -7
  43. package/src/footer/MRT_TableFooterRow.tsx +9 -4
  44. package/src/head/MRT_TableHead.tsx +4 -4
  45. package/src/head/MRT_TableHeadCell.tsx +41 -20
  46. package/src/head/MRT_TableHeadCellActions.tsx +18 -0
  47. package/src/head/MRT_TableHeadRow.tsx +17 -11
  48. package/src/inputs/MRT_DensePaddingSwitch.tsx +5 -3
  49. package/src/inputs/MRT_EditCellTextField.tsx +64 -0
  50. package/src/inputs/MRT_FilterTextField.tsx +43 -18
  51. package/src/inputs/MRT_SearchTextField.tsx +39 -34
  52. package/src/inputs/MRT_SelectAllCheckbox.tsx +10 -14
  53. package/src/inputs/MRT_SelectCheckbox.tsx +11 -13
  54. package/src/menus/MRT_ColumnActionMenu.tsx +66 -23
  55. package/src/menus/MRT_RowActionMenu.tsx +4 -8
  56. package/src/menus/MRT_ShowHideColumnsMenu.tsx +24 -15
  57. package/src/table/MRT_Table.tsx +2 -2
  58. package/src/table/MRT_TableButtonCell.tsx +9 -0
  59. package/src/table/MRT_TableContainer.tsx +52 -5
  60. package/src/table/MRT_TableSpacerCell.tsx +5 -5
  61. package/src/toolbar/MRT_TablePagination.tsx +3 -2
  62. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +102 -0
  63. package/src/toolbar/MRT_ToolbarBottom.tsx +11 -22
  64. package/src/toolbar/{MRT_ToolbarButtons.tsx → MRT_ToolbarInternalButtons.tsx} +13 -4
  65. package/src/toolbar/MRT_ToolbarTop.tsx +16 -30
  66. package/src/useMRT.tsx +112 -0
  67. package/src/utils/localization.ts +30 -12
  68. package/dist/toolbar/MRT_ToolbarButtons.d.ts +0 -5
  69. package/dist/useMaterialReactTable.d.ts +0 -15
  70. package/dist/utils/useMRTCalcs.d.ts +0 -11
  71. package/src/useMaterialReactTable.tsx +0 -96
  72. package/src/utils/useMRTCalcs.tsx +0 -42
@@ -3,7 +3,7 @@ import { TableRow } from '@mui/material';
3
3
  import { HeaderGroup } from 'react-table';
4
4
  import { MRT_TableFooterCell } from './MRT_TableFooterCell';
5
5
  import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
6
- import { useMaterialReactTable } from '../useMaterialReactTable';
6
+ import { useMRT } from '../useMRT';
7
7
 
8
8
  interface Props {
9
9
  footerGroup: HeaderGroup;
@@ -16,10 +16,11 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
16
16
  anyRowsCanExpand,
17
17
  enableSelection,
18
18
  enableRowActions,
19
+ enableRowNumbers,
19
20
  positionActionsColumn,
20
21
  tableInstance,
21
22
  muiTableFooterRowProps,
22
- } = useMaterialReactTable();
23
+ } = useMRT();
23
24
 
24
25
  //if no content in row, skip row
25
26
  if (!columns?.some((c) => c.Footer)) return null;
@@ -40,6 +41,7 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
40
41
 
41
42
  return (
42
43
  <TableRow {...tableRowProps}>
44
+ {enableRowNumbers && <MRT_TableSpacerCell />}
43
45
  {enableRowActions && positionActionsColumn === 'first' && (
44
46
  <MRT_TableSpacerCell />
45
47
  )}
@@ -51,8 +53,11 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
51
53
  />
52
54
  )}
53
55
  {enableSelection && <MRT_TableSpacerCell width="1rem" />}
54
- {footerGroup.headers.map((column, index) => (
55
- <MRT_TableFooterCell key={`${index}-${column.id}`} column={column} />
56
+ {footerGroup.headers.map((column) => (
57
+ <MRT_TableFooterCell
58
+ key={column.getFooterProps().key}
59
+ column={column}
60
+ />
56
61
  ))}
57
62
  {enableRowActions && positionActionsColumn === 'last' && (
58
63
  <MRT_TableSpacerCell />
@@ -1,12 +1,12 @@
1
1
  import React, { FC } from 'react';
2
2
  import { TableHead } from '@mui/material';
3
3
  import { MRT_TableHeadRow } from './MRT_TableHeadRow';
4
- import { useMaterialReactTable } from '../useMaterialReactTable';
4
+ import { useMRT } from '../useMRT';
5
5
 
6
6
  interface Props {}
7
7
 
8
8
  export const MRT_TableHead: FC<Props> = () => {
9
- const { tableInstance, muiTableHeadProps } = useMaterialReactTable();
9
+ const { tableInstance, muiTableHeadProps } = useMRT();
10
10
 
11
11
  const tableHeadProps =
12
12
  muiTableHeadProps instanceof Function
@@ -15,9 +15,9 @@ export const MRT_TableHead: FC<Props> = () => {
15
15
 
16
16
  return (
17
17
  <TableHead {...tableHeadProps}>
18
- {tableInstance.headerGroups.map((headerGroup, index) => (
18
+ {tableInstance.headerGroups.map((headerGroup) => (
19
19
  <MRT_TableHeadRow
20
- key={`${index}-${headerGroup.id}`}
20
+ key={headerGroup.getHeaderGroupProps().key}
21
21
  headerGroup={headerGroup}
22
22
  />
23
23
  ))}
@@ -7,29 +7,41 @@ import {
7
7
  Collapse,
8
8
  } from '@mui/material';
9
9
  import { HeaderGroup } from 'react-table';
10
- import { useMaterialReactTable } from '../useMaterialReactTable';
11
- import { MRT_FilterTextfield } from '../inputs/MRT_FilterTextField';
10
+ import { useMRT } from '../useMRT';
11
+ import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
12
12
  import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
13
13
 
14
- export const StyledTableHeadCell = styled(MuiTableCell)({
15
- fontWeight: 'bold',
16
- verticalAlign: 'text-top',
17
- });
14
+ export const MRT_StyledTableHeadCell = styled(MuiTableCell, {
15
+ shouldForwardProp: (prop) =>
16
+ prop !== 'densePadding' && prop !== 'enableColumnResizing',
17
+ })<{ densePadding?: boolean; enableColumnResizing?: boolean }>(
18
+ ({ densePadding, enableColumnResizing }) => ({
19
+ fontWeight: 'bold',
20
+ height: '100%',
21
+ padding: densePadding ? '0.5rem' : '1rem',
22
+ paddingTop: densePadding ? '0.75rem' : '1.25rem',
23
+ transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
24
+ verticalAlign: 'text-top',
25
+ }),
26
+ );
18
27
 
19
- const TableCellContents = styled('div')({
28
+ const TableCellWrapper = styled('div')({
29
+ alignContent: 'space-between',
20
30
  display: 'grid',
31
+ height: '100%',
21
32
  });
22
33
 
23
- const TableCellText = styled('div')({
34
+ const TableCellTopContents = styled('div')({
24
35
  width: '100%',
25
36
  display: 'flex',
26
37
  justifyContent: 'space-between',
38
+ alignItems: 'flex-start',
27
39
  });
28
40
 
29
41
  const CellFlexItem = styled('span')({
42
+ alignItems: 'center',
30
43
  display: 'flex',
31
44
  flexWrap: 'nowrap',
32
- alignItems: 'center',
33
45
  });
34
46
 
35
47
  const Divider = styled(MuiDivider)({
@@ -52,7 +64,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
52
64
  muiTableHeadCellProps,
53
65
  showFilters,
54
66
  tableInstance,
55
- } = useMaterialReactTable();
67
+ } = useMRT();
56
68
 
57
69
  const isParentHeader = (column?.columns?.length ?? 0) > 0;
58
70
 
@@ -61,21 +73,31 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
61
73
  ? muiTableHeadCellProps(column)
62
74
  : muiTableHeadCellProps;
63
75
 
76
+ const mcTableHeadCellProps =
77
+ column.muiTableHeadCellProps instanceof Function
78
+ ? column.muiTableHeadCellProps(column)
79
+ : column.muiTableHeadCellProps;
80
+
64
81
  const tableCellProps = {
65
82
  ...mTableHeadCellProps,
83
+ ...mcTableHeadCellProps,
66
84
  ...column.getHeaderProps(),
67
85
  style: {
68
- padding: densePadding ? '0.5rem' : '1rem',
69
- transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
70
86
  ...column.getHeaderProps().style,
71
87
  ...(mTableHeadCellProps?.style ?? {}),
88
+ ...(mcTableHeadCellProps?.style ?? {}),
72
89
  },
73
90
  };
74
91
 
75
92
  return (
76
- <StyledTableHeadCell align={isParentHeader ? 'center' : 'left'} {...tableCellProps}>
77
- <TableCellContents>
78
- <TableCellText
93
+ <MRT_StyledTableHeadCell
94
+ align={isParentHeader ? 'center' : 'left'}
95
+ densePadding={densePadding}
96
+ enableColumnResizing={enableColumnResizing}
97
+ {...tableCellProps}
98
+ >
99
+ <TableCellWrapper>
100
+ <TableCellTopContents
79
101
  style={{ justifyContent: isParentHeader ? 'center' : undefined }}
80
102
  >
81
103
  <CellFlexItem {...column.getSortByToggleProps()}>
@@ -91,7 +113,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
91
113
  }
92
114
  active={column.isSorted}
93
115
  direction={column.isSortedDesc ? 'desc' : 'asc'}
94
- style={{ margin: 0 }}
95
116
  />
96
117
  )}
97
118
  </CellFlexItem>
@@ -108,13 +129,13 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
108
129
  />
109
130
  )}
110
131
  </CellFlexItem>
111
- </TableCellText>
132
+ </TableCellTopContents>
112
133
  {!disableFilters && column.canFilter && (
113
134
  <Collapse in={showFilters}>
114
- <MRT_FilterTextfield column={column} />
135
+ <MRT_FilterTextField column={column} />
115
136
  </Collapse>
116
137
  )}
117
- </TableCellContents>
118
- </StyledTableHeadCell>
138
+ </TableCellWrapper>
139
+ </MRT_StyledTableHeadCell>
119
140
  );
120
141
  };
@@ -0,0 +1,18 @@
1
+ import React, { FC } from 'react';
2
+ import { useMRT } from '../useMRT';
3
+ import { MRT_StyledTableHeadCell } from './MRT_TableHeadCell';
4
+
5
+ interface Props {}
6
+
7
+ export const MRT_TableHeadCellActions: FC<Props> = () => {
8
+ const { densePadding, localization } = useMRT();
9
+
10
+ return (
11
+ <MRT_StyledTableHeadCell
12
+ densePadding={densePadding}
13
+ style={{ textAlign: 'center' }}
14
+ >
15
+ {localization?.actionsHeadColumnTitle}
16
+ </MRT_StyledTableHeadCell>
17
+ );
18
+ };
@@ -1,11 +1,15 @@
1
1
  import React, { FC, useMemo } from 'react';
2
2
  import { TableRow } from '@mui/material';
3
3
  import { HeaderGroup } from 'react-table';
4
- import { MRT_TableHeadCell, StyledTableHeadCell } from './MRT_TableHeadCell';
5
- import { useMaterialReactTable } from '../useMaterialReactTable';
4
+ import {
5
+ MRT_StyledTableHeadCell,
6
+ MRT_TableHeadCell,
7
+ } from './MRT_TableHeadCell';
8
+ import { useMRT } from '../useMRT';
6
9
  import { MRT_SelectAllCheckbox } from '../inputs/MRT_SelectAllCheckbox';
7
10
  import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
8
11
  import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
12
+ import { MRT_TableHeadCellActions } from './MRT_TableHeadCellActions';
9
13
 
10
14
  interface Props {
11
15
  headerGroup: HeaderGroup;
@@ -15,14 +19,14 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
15
19
  const {
16
20
  anyRowsCanExpand,
17
21
  disableExpandAll,
22
+ enableRowNumbers,
18
23
  enableRowActions,
19
24
  enableSelection,
20
- localization,
21
25
  muiTableHeadRowProps,
22
26
  positionActionsColumn,
23
27
  renderDetailPanel,
24
28
  tableInstance,
25
- } = useMaterialReactTable();
29
+ } = useMRT();
26
30
 
27
31
  const isParentHeader = useMemo(
28
32
  () => headerGroup.headers.some((h) => (h.columns?.length ?? 0) > 0),
@@ -45,14 +49,18 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
45
49
 
46
50
  return (
47
51
  <TableRow {...tableRowProps}>
52
+ {enableRowNumbers &&
53
+ (isParentHeader ? (
54
+ <MRT_TableSpacerCell />
55
+ ) : (
56
+ <MRT_StyledTableHeadCell>#</MRT_StyledTableHeadCell>
57
+ ))}
48
58
  {enableRowActions &&
49
59
  positionActionsColumn === 'first' &&
50
60
  (isParentHeader ? (
51
61
  <MRT_TableSpacerCell />
52
62
  ) : (
53
- <StyledTableHeadCell>
54
- {localization?.actionsHeadColumnTitle}
55
- </StyledTableHeadCell>
63
+ <MRT_TableHeadCellActions />
56
64
  ))}
57
65
  {anyRowsCanExpand || renderDetailPanel ? (
58
66
  !disableExpandAll && !isParentHeader ? (
@@ -72,7 +80,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
72
80
  <MRT_TableSpacerCell width="1rem" />
73
81
  )
74
82
  ) : null}
75
- {headerGroup.headers.map((column) => (
83
+ {headerGroup.headers.map((column: HeaderGroup) => (
76
84
  <MRT_TableHeadCell key={column.getHeaderProps().key} column={column} />
77
85
  ))}
78
86
  {enableRowActions &&
@@ -80,9 +88,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
80
88
  (isParentHeader ? (
81
89
  <MRT_TableSpacerCell />
82
90
  ) : (
83
- <StyledTableHeadCell>
84
- {localization?.actionsHeadColumnTitle}
85
- </StyledTableHeadCell>
91
+ <MRT_TableHeadCellActions />
86
92
  ))}
87
93
  </TableRow>
88
94
  );
@@ -1,16 +1,18 @@
1
1
  import React, { FC } from 'react';
2
2
  import { Switch, Tooltip } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
3
+ import { useMRT } from '../useMRT';
4
4
 
5
5
  interface Props {}
6
6
 
7
7
  export const MRT_DensePaddingSwitch: FC<Props> = () => {
8
- const { densePadding, setDensePadding, localization } =
9
- useMaterialReactTable();
8
+ const { densePadding, setDensePadding, localization } = useMRT();
10
9
 
11
10
  return (
12
11
  <Tooltip arrow title={localization?.toggleDensePaddingSwitchTitle ?? ''}>
13
12
  <Switch
13
+ inputProps={{
14
+ 'aria-label': localization?.toggleDensePaddingSwitchTitle ?? '',
15
+ }}
14
16
  color="default"
15
17
  checked={densePadding}
16
18
  size="small"
@@ -0,0 +1,64 @@
1
+ import React, { ChangeEvent, FC } from 'react';
2
+ import { TextField } from '@mui/material';
3
+ import { Cell } from 'react-table';
4
+ import { useMRT } from '../useMRT';
5
+
6
+ interface Props {
7
+ cell: Cell;
8
+ }
9
+
10
+ export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
11
+ const {
12
+ currentEditingRow,
13
+ localization,
14
+ muiTableBodyCellEditTextFieldProps,
15
+ setCurrentEditingRow,
16
+ } = useMRT();
17
+
18
+ const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
19
+ if (currentEditingRow) {
20
+ cell.row.values[cell.column.id] = event.target.value;
21
+ setCurrentEditingRow({
22
+ ...currentEditingRow,
23
+ });
24
+ }
25
+ cell.column.onCellEditChange?.(event, cell);
26
+ };
27
+
28
+ const mTableBodyCellEditTextFieldProps =
29
+ muiTableBodyCellEditTextFieldProps instanceof Function
30
+ ? muiTableBodyCellEditTextFieldProps(cell)
31
+ : muiTableBodyCellEditTextFieldProps;
32
+
33
+ const mcTableBodyCellEditTextFieldProps =
34
+ cell.column.muiTableBodyCellEditTextFieldProps instanceof Function
35
+ ? cell.column.muiTableBodyCellEditTextFieldProps(cell)
36
+ : cell.column.muiTableBodyCellEditTextFieldProps;
37
+
38
+ const textFieldProps = {
39
+ ...mTableBodyCellEditTextFieldProps,
40
+ ...mcTableBodyCellEditTextFieldProps,
41
+ style: {
42
+ //@ts-ignore
43
+ ...muiTableBodyCellEditTextFieldProps?.style,
44
+ //@ts-ignore
45
+ ...cell.column.muiTableBodyCellEditTextFieldProps?.style,
46
+ },
47
+ };
48
+
49
+ if (cell.column.editable && cell.column.Edit) {
50
+ return <>{cell.column.Edit({ ...textFieldProps, cell })}</>;
51
+ }
52
+
53
+ return (
54
+ <TextField
55
+ margin="dense"
56
+ onChange={handleChange}
57
+ onClick={(e) => e.stopPropagation()}
58
+ placeholder={localization?.filterTextFieldPlaceholder}
59
+ value={cell.value}
60
+ variant="standard"
61
+ {...textFieldProps}
62
+ />
63
+ );
64
+ };
@@ -1,16 +1,16 @@
1
1
  import React, { ChangeEvent, FC, useState } from 'react';
2
- import { IconButton, InputAdornment, TextField } from '@mui/material';
2
+ import { IconButton, InputAdornment, TextField, Tooltip } from '@mui/material';
3
3
  import CloseIcon from '@mui/icons-material/Close';
4
4
  import FilterIcon from '@mui/icons-material/FilterList';
5
5
  import { HeaderGroup, useAsyncDebounce } from 'react-table';
6
- import { useMaterialReactTable } from '../useMaterialReactTable';
6
+ import { useMRT } from '../useMRT';
7
7
 
8
8
  interface Props {
9
9
  column: HeaderGroup;
10
10
  }
11
11
 
12
- export const MRT_FilterTextfield: FC<Props> = ({ column }) => {
13
- const { localization } = useMaterialReactTable();
12
+ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
13
+ const { localization } = useMRT();
14
14
 
15
15
  const [filterValue, setFilterValue] = useState('');
16
16
 
@@ -24,14 +24,23 @@ export const MRT_FilterTextfield: FC<Props> = ({ column }) => {
24
24
  };
25
25
 
26
26
  if (column.Filter) {
27
- //@ts-ignore
28
- return <>{column.Filter({ column })}</>;
27
+ return <>{column.Filter?.({ column })}</>;
29
28
  }
30
29
 
31
30
  return (
32
31
  <TextField
32
+ fullWidth
33
+ id={`filter-${column.id}-column`}
34
+ inputProps={{
35
+ style: {
36
+ textOverflow: 'ellipsis',
37
+ },
38
+ }}
33
39
  margin="dense"
34
- placeholder={localization?.filterTextFieldPlaceholder}
40
+ placeholder={localization?.filterTextFieldPlaceholder?.replace(
41
+ '{column}',
42
+ String(column.Header),
43
+ )}
35
44
  onChange={(e: ChangeEvent<HTMLInputElement>) => {
36
45
  setFilterValue(e.target.value);
37
46
  handleChange(e.target.value);
@@ -41,21 +50,37 @@ export const MRT_FilterTextfield: FC<Props> = ({ column }) => {
41
50
  variant="standard"
42
51
  InputProps={{
43
52
  startAdornment: (
44
- <InputAdornment position="start">
45
- <FilterIcon />
46
- </InputAdornment>
53
+ <Tooltip
54
+ arrow
55
+ title={
56
+ localization?.filterTextFieldPlaceholder?.replace(
57
+ '{column}',
58
+ String(column.Header),
59
+ ) ?? ''
60
+ }
61
+ >
62
+ <InputAdornment position="start">
63
+ <FilterIcon />
64
+ </InputAdornment>
65
+ </Tooltip>
47
66
  ),
48
67
  endAdornment: (
49
68
  <InputAdornment position="end">
50
- <IconButton
51
- aria-label={localization?.filterTextFieldClearButtonTitle}
52
- disabled={filterValue?.length === 0}
53
- onClick={handleClear}
54
- size="small"
55
- title={localization?.filterTextFieldClearButtonTitle}
69
+ <Tooltip
70
+ arrow
71
+ title={localization?.filterTextFieldClearButtonTitle ?? ''}
56
72
  >
57
- <CloseIcon fontSize="small" />
58
- </IconButton>
73
+ <span>
74
+ <IconButton
75
+ aria-label={localization?.filterTextFieldClearButtonTitle}
76
+ disabled={filterValue?.length === 0}
77
+ onClick={handleClear}
78
+ size="small"
79
+ >
80
+ <CloseIcon fontSize="small" />
81
+ </IconButton>
82
+ </span>
83
+ </Tooltip>
59
84
  </InputAdornment>
60
85
  ),
61
86
  }}
@@ -1,5 +1,6 @@
1
1
  import React, { ChangeEvent, FC, useState } from 'react';
2
2
  import {
3
+ Collapse,
3
4
  IconButton,
4
5
  InputAdornment,
5
6
  styled,
@@ -7,7 +8,7 @@ import {
7
8
  } from '@mui/material';
8
9
  import SearchIcon from '@mui/icons-material/Search';
9
10
  import CloseIcon from '@mui/icons-material/Close';
10
- import { useMaterialReactTable } from '../useMaterialReactTable';
11
+ import { useMRT } from '../useMRT';
11
12
  import { useAsyncDebounce } from 'react-table';
12
13
 
13
14
  const TextField = styled(MuiTextField)({
@@ -18,11 +19,12 @@ interface Props {}
18
19
 
19
20
  export const MRT_SearchTextField: FC<Props> = () => {
20
21
  const {
21
- tableInstance,
22
- muiSearchTextFieldProps,
22
+ showSearch,
23
23
  localization,
24
+ muiSearchTextFieldProps,
24
25
  onGlobalFilterChange,
25
- } = useMaterialReactTable();
26
+ tableInstance,
27
+ } = useMRT();
26
28
 
27
29
  const [searchValue, setSearchValue] = useState('');
28
30
 
@@ -40,35 +42,38 @@ export const MRT_SearchTextField: FC<Props> = () => {
40
42
  };
41
43
 
42
44
  return (
43
- <TextField
44
- placeholder={localization?.searchTextFieldPlaceholder}
45
- onChange={(event: ChangeEvent<HTMLInputElement>) => {
46
- setSearchValue(event.target.value);
47
- handleChange(event);
48
- }}
49
- value={searchValue ?? ''}
50
- variant="standard"
51
- InputProps={{
52
- startAdornment: (
53
- <InputAdornment position="start">
54
- <SearchIcon fontSize="small" />
55
- </InputAdornment>
56
- ),
57
- endAdornment: (
58
- <InputAdornment position="end">
59
- <IconButton
60
- aria-label={localization?.searchTextFieldClearButtonTitle}
61
- disabled={searchValue?.length === 0}
62
- onClick={handleClear}
63
- size="small"
64
- title={localization?.searchTextFieldClearButtonTitle}
65
- >
66
- <CloseIcon fontSize="small" />
67
- </IconButton>
68
- </InputAdornment>
69
- ),
70
- }}
71
- {...muiSearchTextFieldProps}
72
- />
45
+ <Collapse in={showSearch} orientation="horizontal">
46
+ <TextField
47
+ id="global-search-text-field"
48
+ placeholder={localization?.searchTextFieldPlaceholder}
49
+ onChange={(event: ChangeEvent<HTMLInputElement>) => {
50
+ setSearchValue(event.target.value);
51
+ handleChange(event);
52
+ }}
53
+ value={searchValue ?? ''}
54
+ variant="standard"
55
+ InputProps={{
56
+ startAdornment: (
57
+ <InputAdornment position="start">
58
+ <SearchIcon fontSize="small" />
59
+ </InputAdornment>
60
+ ),
61
+ endAdornment: (
62
+ <InputAdornment position="end">
63
+ <IconButton
64
+ aria-label={localization?.searchTextFieldClearButtonTitle}
65
+ disabled={searchValue?.length === 0}
66
+ onClick={handleClear}
67
+ size="small"
68
+ title={localization?.searchTextFieldClearButtonTitle}
69
+ >
70
+ <CloseIcon fontSize="small" />
71
+ </IconButton>
72
+ </InputAdornment>
73
+ ),
74
+ }}
75
+ {...muiSearchTextFieldProps}
76
+ />
77
+ </Collapse>
73
78
  );
74
79
  };
@@ -1,26 +1,22 @@
1
1
  import React from 'react';
2
- import { Checkbox, TableCell } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
2
+ import { Checkbox } from '@mui/material';
3
+ import { useMRT } from '../useMRT';
4
+ import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
4
5
 
5
6
  export const MRT_SelectAllCheckbox = () => {
6
- const { tableInstance, disableSelectAll, densePadding } =
7
- useMaterialReactTable();
7
+ const { tableInstance, disableSelectAll, densePadding, localization } =
8
+ useMRT();
8
9
 
9
10
  return (
10
- <TableCell
11
- style={{
12
- width: '2rem',
13
- padding: densePadding ? '0' : '0.6rem',
14
- transition: 'all 0.2s ease-in-out',
15
- }}
16
- variant="head"
17
- >
11
+ <MRT_TableButtonCell densePadding={densePadding} variant="head">
18
12
  {!disableSelectAll ? (
19
13
  <Checkbox
20
- aria-label=""
14
+ inputProps={{
15
+ 'aria-label': localization?.selectAllCheckboxTitle ?? '',
16
+ }}
21
17
  {...tableInstance.getToggleAllPageRowsSelectedProps()}
22
18
  />
23
19
  ) : null}
24
- </TableCell>
20
+ </MRT_TableButtonCell>
25
21
  );
26
22
  };
@@ -1,15 +1,16 @@
1
1
  import React, { ChangeEvent, FC } from 'react';
2
- import { Checkbox, TableCell } from '@mui/material';
2
+ import { Checkbox } from '@mui/material';
3
3
  import { Row } from 'react-table';
4
- import { useMaterialReactTable } from '../useMaterialReactTable';
4
+ import { useMRT } from '../useMRT';
5
+ import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
5
6
 
6
7
  interface Props {
7
8
  row: Row;
8
9
  }
9
10
 
10
11
  export const MRT_SelectCheckbox: FC<Props> = ({ row }) => {
11
- const { tableInstance, onRowSelectChange, densePadding } =
12
- useMaterialReactTable();
12
+ const { tableInstance, onRowSelectChange, densePadding, localization } =
13
+ useMRT();
13
14
 
14
15
  const onSelectChange = (event: ChangeEvent) => {
15
16
  row.getToggleRowSelectedProps()?.onChange?.(event);
@@ -17,17 +18,14 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row }) => {
17
18
  };
18
19
 
19
20
  return (
20
- <TableCell
21
- style={{
22
- width: '2rem',
23
- padding: densePadding ? '0' : '0.6rem',
24
- transition: 'all 0.2s ease-in-out',
25
- }}
26
- >
21
+ <MRT_TableButtonCell densePadding={densePadding}>
27
22
  <Checkbox
28
- {...row.getToggleRowSelectedProps()}
23
+ inputProps={{
24
+ 'aria-label': localization?.selectCheckboxTitle,
25
+ }}
29
26
  onChange={onSelectChange}
27
+ {...row.getToggleRowSelectedProps()}
30
28
  />
31
- </TableCell>
29
+ </MRT_TableButtonCell>
32
30
  );
33
31
  };