material-react-table 0.5.1 → 0.5.4

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 (45) hide show
  1. package/dist/MaterialReactTable.d.ts +15 -9
  2. package/dist/filtersFNs.d.ts +67 -0
  3. package/dist/localization.d.ts +10 -1
  4. package/dist/material-react-table.cjs.development.js +455 -147
  5. package/dist/material-react-table.cjs.development.js.map +1 -1
  6. package/dist/material-react-table.cjs.production.min.js +1 -1
  7. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  8. package/dist/material-react-table.esm.js +457 -149
  9. package/dist/material-react-table.esm.js.map +1 -1
  10. package/dist/menus/MRT_FilterMenu.d.ts +10 -0
  11. package/dist/useMRT.d.ts +13 -14
  12. package/package.json +6 -2
  13. package/src/@types/react-table-config.d.ts +3 -3
  14. package/src/MaterialReactTable.tsx +30 -9
  15. package/src/body/MRT_TableBody.tsx +7 -2
  16. package/src/body/MRT_TableBodyCell.tsx +3 -2
  17. package/src/body/MRT_TableBodyRow.tsx +11 -8
  18. package/src/buttons/MRT_EditActionButtons.tsx +4 -2
  19. package/src/buttons/MRT_ExpandAllButton.tsx +3 -4
  20. package/src/buttons/MRT_ExpandButton.tsx +3 -1
  21. package/src/buttons/MRT_FullScreenToggleButton.tsx +3 -1
  22. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +4 -3
  23. package/src/buttons/MRT_ToggleDensePaddingButton.tsx +3 -1
  24. package/src/buttons/MRT_ToggleFiltersButton.tsx +4 -2
  25. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +17 -11
  26. package/src/buttons/MRT_ToggleSearchButton.tsx +5 -2
  27. package/src/filtersFNs.ts +112 -0
  28. package/src/footer/MRT_TableFooter.tsx +6 -1
  29. package/src/footer/MRT_TableFooterCell.tsx +7 -2
  30. package/src/head/MRT_TableHeadCell.tsx +49 -47
  31. package/src/head/MRT_TableHeadCellActions.tsx +6 -1
  32. package/src/head/MRT_TableHeadRow.tsx +7 -2
  33. package/src/index.tsx +0 -2
  34. package/src/inputs/MRT_EditCellTextField.tsx +3 -1
  35. package/src/inputs/MRT_FilterTextField.tsx +117 -52
  36. package/src/inputs/MRT_SearchTextField.tsx +3 -3
  37. package/src/inputs/MRT_SelectCheckbox.tsx +5 -8
  38. package/src/localization.ts +20 -2
  39. package/src/menus/MRT_ColumnActionMenu.tsx +125 -85
  40. package/src/menus/MRT_FilterMenu.tsx +109 -0
  41. package/src/table/MRT_Table.tsx +7 -2
  42. package/src/table/MRT_TableContainer.tsx +16 -3
  43. package/src/toolbar/MRT_ToolbarBottom.tsx +2 -3
  44. package/src/toolbar/MRT_ToolbarTop.tsx +2 -3
  45. package/src/useMRT.tsx +104 -35
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ import { MRT_HeaderGroup } from '..';
3
+ interface Props {
4
+ anchorEl: HTMLElement | null;
5
+ column: MRT_HeaderGroup;
6
+ setAnchorEl: (anchorEl: HTMLElement | null) => void;
7
+ onSelect?: () => void;
8
+ }
9
+ export declare const MRT_FilterMenu: FC<Props>;
10
+ export {};
package/dist/useMRT.d.ts CHANGED
@@ -1,24 +1,23 @@
1
- import React, { PropsWithChildren } from 'react';
2
- import { MRT_Row, MRT_TableInstance } from '.';
1
+ import React, { PropsWithChildren, Dispatch, SetStateAction } from 'react';
2
+ import { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
3
3
  import { MRT_Icons } from './icons';
4
4
  import { MRT_Localization } from './localization';
5
5
  import { MaterialReactTableProps } from './MaterialReactTable';
6
6
  export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
7
7
  anyRowsCanExpand: boolean;
8
8
  anyRowsExpanded: boolean;
9
- currentEditingRow: MRT_Row<D> | null;
10
- densePadding: boolean;
11
- fullScreen: boolean;
12
9
  icons: MRT_Icons;
10
+ idPrefix: string;
13
11
  localization: MRT_Localization;
14
- setCurrentEditingRow: (currentRowEditingId: MRT_Row<D> | null) => void;
15
- setDensePadding: (densePadding: boolean) => void;
16
- setFullScreen: (fullScreen: boolean) => void;
17
- setShowFilters: (showFilters: boolean) => void;
18
- setShowSearch: (showSearch: boolean) => void;
19
- showFilters: boolean;
20
- showSearch: boolean;
12
+ setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
13
+ setCurrentFilterTypes: Dispatch<SetStateAction<{
14
+ [key: string]: MRT_FilterType;
15
+ }>>;
16
+ setDensePadding: Dispatch<SetStateAction<boolean>>;
17
+ setFullScreen: Dispatch<SetStateAction<boolean>>;
18
+ setShowFilters: Dispatch<SetStateAction<boolean>>;
19
+ setShowSearch: Dispatch<SetStateAction<boolean>>;
21
20
  tableInstance: MRT_TableInstance<D>;
22
21
  };
23
- export declare const MaterialReactTableProvider: <D extends {}>(props: React.PropsWithChildren<MaterialReactTableProps<D>>) => JSX.Element;
24
- export declare const useMRT: <D extends {}>() => UseMRT<D>;
22
+ export declare const MaterialReactTableProvider: <D extends {} = {}>(props: React.PropsWithChildren<MaterialReactTableProps<D>>) => JSX.Element;
23
+ export declare const useMRT: <D extends {} = {}>() => UseMRT<D>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.1",
2
+ "version": "0.5.4",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material-UI implementation of react-table, inspired by material-table and the mui DataGrid, written from the ground up in TypeScript.",
@@ -75,7 +75,7 @@
75
75
  "@storybook/react": "^6.4.19",
76
76
  "@types/faker": "^6.6.8",
77
77
  "@types/react": "^17.0.39",
78
- "@types/react-dom": "^17.0.11",
78
+ "@types/react-dom": "^17.0.13",
79
79
  "@types/react-table": "^7.7.9",
80
80
  "babel-loader": "^8.2.3",
81
81
  "husky": "^7.0.4",
@@ -93,9 +93,13 @@
93
93
  },
94
94
  "peerDependencies": {
95
95
  "@emotion/react": ">=11",
96
+ "@emotion/styled": ">=11",
96
97
  "@mui/icons-material": ">=5",
97
98
  "@mui/material": ">=5",
98
99
  "react": ">=16.8",
99
100
  "react-table": ">=7"
101
+ },
102
+ "dependencies": {
103
+ "match-sorter": "^6.3.1"
100
104
  }
101
105
  }
@@ -14,8 +14,6 @@ import {
14
14
  } from '..';
15
15
 
16
16
  declare module 'react-table' {
17
- // take this file as-is, or comment out the sections that don't apply to your plugin configuration
18
-
19
17
  export interface TableOptions<D extends Record<string, unknown>>
20
18
  extends MRT_TableOptions<D> {}
21
19
 
@@ -28,7 +26,9 @@ declare module 'react-table' {
28
26
 
29
27
  export interface TableInstance<
30
28
  D extends Record<string, unknown> = Record<string, unknown>,
31
- > extends MRT_TableInstance<D> {}
29
+ > extends MRT_TableInstance<D> {
30
+ rows: MRT_Row<D>[];
31
+ }
32
32
 
33
33
  export interface TableState<
34
34
  D extends Record<string, unknown> = Record<string, unknown>,
@@ -181,6 +181,16 @@ export type MRT_Cell<D extends {} = {}, _V = any> = Cell<D> &
181
181
  UseGroupByCellProps<D> &
182
182
  UseRowStateCellProps<D> & {};
183
183
 
184
+ export type MRT_FilterType =
185
+ | 'contains'
186
+ | 'empty'
187
+ | 'endsWith'
188
+ | 'equals'
189
+ | 'fuzzy'
190
+ | 'notEmpty'
191
+ | 'notEquals'
192
+ | 'startsWith';
193
+
184
194
  export type MRT_TableState<D extends {} = {}> = TableState<D> &
185
195
  UseColumnOrderState<D> &
186
196
  UseExpandedState<D> &
@@ -192,10 +202,12 @@ export type MRT_TableState<D extends {} = {}> = TableState<D> &
192
202
  UseRowSelectState<D> &
193
203
  UseRowStateState<D> &
194
204
  UseSortByState<D> & {
195
- densePadding?: boolean;
196
- fullScreen?: boolean;
197
- showFilters?: boolean;
198
- showSearchTextField?: boolean;
205
+ currentEditingRow: MRT_Row<D> | null;
206
+ currentFilterTypes: { [key: string]: MRT_FilterType };
207
+ densePadding: boolean;
208
+ fullScreen: boolean;
209
+ showFilters: boolean;
210
+ showSearch: boolean;
199
211
  };
200
212
 
201
213
  export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
@@ -228,6 +240,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
228
240
  hideToolbarInternalActions?: boolean;
229
241
  hideToolbarTop?: boolean;
230
242
  icons?: Partial<MRT_Icons>;
243
+ idPrefix?: string;
231
244
  isFetching?: boolean;
232
245
  isLoading?: boolean;
233
246
  localization?: Partial<MRT_Localization>;
@@ -238,18 +251,22 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
238
251
  muiTableBodyCellProps?:
239
252
  | TableCellProps
240
253
  | ((cell?: MRT_Cell<D>) => TableCellProps);
241
- muiTableBodyProps?: TableBodyProps;
254
+ muiTableBodyProps?:
255
+ | TableBodyProps
256
+ | ((tableInstance: MRT_TableInstance<D>) => TableBodyProps);
242
257
  muiTableBodyRowProps?: TableRowProps | ((row: Row<D>) => TableRowProps);
243
258
  muiTableContainerProps?:
244
259
  | TableContainerProps
245
- | ((table: MRT_TableInstance<D>) => TableContainerProps);
260
+ | ((tableInstance: MRT_TableInstance<D>) => TableContainerProps);
246
261
  muiTableDetailPanelProps?:
247
262
  | TableCellProps
248
263
  | ((row: Row<D>) => TableCellProps);
249
264
  muiTableFooterCellProps?:
250
265
  | TableCellProps
251
266
  | ((column: Column<D>) => TableCellProps);
252
- muiTableFooterProps?: TableFooterProps;
267
+ muiTableFooterProps?:
268
+ | TableFooterProps
269
+ | ((tableInstance: MRT_TableInstance<D>) => TableFooterProps);
253
270
  muiTableFooterRowProps?:
254
271
  | TableRowProps
255
272
  | ((footerGroup: MRT_HeaderGroup<D>) => TableRowProps);
@@ -259,7 +276,9 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
259
276
  muiTableHeadCellProps?:
260
277
  | TableCellProps
261
278
  | ((column: Column<D>) => TableCellProps);
262
- muiTableHeadProps?: TableHeadProps;
279
+ muiTableHeadProps?:
280
+ | TableHeadProps
281
+ | ((tableInstance: MRT_TableInstance<D>) => TableHeadProps);
263
282
  muiTableHeadRowProps?:
264
283
  | TableRowProps
265
284
  | ((row: MRT_HeaderGroup<D>) => TableRowProps);
@@ -268,7 +287,9 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
268
287
  | ((
269
288
  tableInstance: MRT_TableInstance<D>,
270
289
  ) => Partial<TablePaginationProps>);
271
- muiTableProps?: TableProps;
290
+ muiTableProps?:
291
+ | TableProps
292
+ | ((tableInstance: MRT_TableInstance<D>) => TableProps);
272
293
  muiTableToolbarAlertBannerProps?:
273
294
  | AlertProps
274
295
  | ((tableInstance: MRT_TableInstance<D>) => AlertProps);
@@ -11,12 +11,17 @@ export const MRT_TableBody: FC<Props> = () => {
11
11
 
12
12
  const rows = manualPagination ? tableInstance.rows : tableInstance.page;
13
13
 
14
+ const mTableBodyProps =
15
+ muiTableBodyProps instanceof Function
16
+ ? muiTableBodyProps(tableInstance)
17
+ : muiTableBodyProps;
18
+
14
19
  const tableBodyProps = {
15
- ...muiTableBodyProps,
20
+ ...mTableBodyProps,
16
21
  ...tableInstance.getTableBodyProps(),
17
22
  style: {
18
23
  ...tableInstance.getTableBodyProps().style,
19
- ...muiTableBodyProps?.style,
24
+ ...mTableBodyProps?.style,
20
25
  },
21
26
  };
22
27
 
@@ -24,8 +24,9 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
24
24
  const {
25
25
  onCellClick,
26
26
  muiTableBodyCellProps,
27
- densePadding,
28
- currentEditingRow,
27
+ tableInstance: {
28
+ state: { currentEditingRow, densePadding },
29
+ },
29
30
  } = useMRT();
30
31
 
31
32
  const mTableCellBodyProps =
@@ -18,7 +18,6 @@ interface Props {
18
18
  export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
19
19
  const {
20
20
  anyRowsCanExpand,
21
- densePadding,
22
21
  enableRowActions,
23
22
  enableRowEditing,
24
23
  enableRowNumbers,
@@ -27,6 +26,9 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
27
26
  onRowClick,
28
27
  positionActionsColumn,
29
28
  renderDetailPanel,
29
+ tableInstance: {
30
+ state: { densePadding },
31
+ },
30
32
  } = useMRT();
31
33
 
32
34
  const mTableBodyRowProps =
@@ -51,13 +53,14 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
51
53
  onRowClick?.(event, row)
52
54
  }
53
55
  {...tableRowProps}
54
- //@ts-ignore
55
- sx={(theme) => ({
56
- backgroundColor: row.isSelected
57
- ? alpha(theme.palette.primary.light, 0.1)
58
- : 'transparent',
59
- ...tableRowProps?.sx,
60
- })}
56
+ sx={(theme) =>
57
+ ({
58
+ backgroundColor: row.isSelected
59
+ ? alpha(theme.palette.primary.light, 0.1)
60
+ : 'transparent',
61
+ ...tableRowProps?.sx,
62
+ } as any)
63
+ }
61
64
  >
62
65
  {enableRowNumbers && (
63
66
  <TableCell sx={{ ...commonTableBodyCellStyles(densePadding) }}>
@@ -11,9 +11,11 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
11
11
  const {
12
12
  icons: { CancelIcon, SaveIcon },
13
13
  localization,
14
- setCurrentEditingRow,
15
14
  onRowEditSubmit,
16
- currentEditingRow,
15
+ setCurrentEditingRow,
16
+ tableInstance: {
17
+ state: { currentEditingRow },
18
+ },
17
19
  } = useMRT();
18
20
 
19
21
  const handleCancel = () => {
@@ -7,18 +7,17 @@ interface Props {}
7
7
 
8
8
  export const MRT_ExpandAllButton: FC<Props> = () => {
9
9
  const {
10
- tableInstance,
11
- localization,
12
10
  anyRowsExpanded,
13
- densePadding,
14
11
  icons: { DoubleArrowDownIcon },
12
+ localization,
13
+ tableInstance,
15
14
  } = useMRT();
16
15
 
17
16
  return (
18
17
  <TableCell
19
18
  size="small"
20
19
  {...tableInstance.getToggleAllRowsExpandedProps()}
21
- sx={commonTableBodyButtonCellStyles(densePadding)}
20
+ sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
22
21
  >
23
22
  <IconButton
24
23
  aria-label={localization.expandAllButtonTitle}
@@ -10,10 +10,12 @@ interface Props {
10
10
 
11
11
  export const MRT_ExpandButton: FC<Props> = ({ row }) => {
12
12
  const {
13
- densePadding,
14
13
  icons: { ExpandMoreIcon },
15
14
  localization,
16
15
  renderDetailPanel,
16
+ tableInstance: {
17
+ state: { densePadding },
18
+ },
17
19
  } = useMRT();
18
20
 
19
21
  return (
@@ -6,10 +6,12 @@ interface Props extends IconButtonProps {}
6
6
 
7
7
  export const MRT_FullScreenToggleButton: FC<Props> = ({ ...rest }) => {
8
8
  const {
9
- fullScreen,
10
9
  icons: { FullscreenExitIcon, FullscreenIcon },
11
10
  localization,
12
11
  setFullScreen,
12
+ tableInstance: {
13
+ state: { fullScreen },
14
+ },
13
15
  } = useMRT();
14
16
 
15
17
  return (
@@ -35,11 +35,12 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
35
35
  onClick={handleClick}
36
36
  size="small"
37
37
  sx={{
38
+ height: '2rem',
39
+ mr: '2px',
40
+ mt: '-0.2rem',
38
41
  opacity: 0.5,
39
42
  transition: 'opacity 0.2s',
40
- marginRight: '2px',
41
- height: '1.6rem',
42
- width: '1.6rem',
43
+ width: '2rem',
43
44
  '&:hover': {
44
45
  opacity: 1,
45
46
  },
@@ -6,10 +6,12 @@ interface Props extends IconButtonProps {}
6
6
 
7
7
  export const MRT_ToggleDensePaddingButton: FC<Props> = ({ ...rest }) => {
8
8
  const {
9
- densePadding,
10
9
  setDensePadding,
11
10
  localization,
12
11
  icons: { DensityMediumIcon, DensitySmallIcon },
12
+ tableInstance: {
13
+ state: { densePadding },
14
+ },
13
15
  } = useMRT();
14
16
 
15
17
  return (
@@ -6,10 +6,12 @@ interface Props extends IconButtonProps {}
6
6
 
7
7
  export const MRT_ToggleFiltersButton: FC<Props> = ({ ...rest }) => {
8
8
  const {
9
+ icons: { FilterListIcon, FilterListOffIcon },
9
10
  localization,
10
11
  setShowFilters,
11
- showFilters,
12
- icons: { FilterListIcon, FilterListOffIcon },
12
+ tableInstance: {
13
+ state: { showFilters },
14
+ },
13
15
  } = useMRT();
14
16
 
15
17
  return (
@@ -23,8 +23,6 @@ interface Props {
23
23
 
24
24
  export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
25
25
  const {
26
- currentEditingRow,
27
- densePadding,
28
26
  enableRowEditing,
29
27
  icons: { EditIcon, MoreHorizIcon },
30
28
  localization,
@@ -48,10 +46,12 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
48
46
  };
49
47
 
50
48
  return (
51
- <TableCell sx={commonTableBodyButtonCellStyles(densePadding)}>
49
+ <TableCell
50
+ sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
51
+ >
52
52
  {renderRowActions ? (
53
53
  <>{renderRowActions(row, tableInstance)}</>
54
- ) : row.id === currentEditingRow?.id ? (
54
+ ) : row.id === tableInstance.state.currentEditingRow?.id ? (
55
55
  <MRT_EditActionButtons row={row} />
56
56
  ) : !renderRowActionMenuItems && enableRowEditing ? (
57
57
  <Tooltip
@@ -65,15 +65,21 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
65
65
  </Tooltip>
66
66
  ) : renderRowActionMenuItems ? (
67
67
  <>
68
- <IconButton
69
- aria-label={localization.rowActionMenuButtonTitle}
70
- onClick={handleOpenRowActionMenu}
71
- size="small"
72
- sx={commonIconButtonStyles}
68
+ <Tooltip
69
+ arrow
70
+ enterDelay={1000}
71
+ enterNextDelay={1000}
73
72
  title={localization.rowActionMenuButtonTitle}
74
73
  >
75
- <MoreHorizIcon />
76
- </IconButton>
74
+ <IconButton
75
+ aria-label={localization.rowActionMenuButtonTitle}
76
+ onClick={handleOpenRowActionMenu}
77
+ size="small"
78
+ sx={commonIconButtonStyles}
79
+ >
80
+ <MoreHorizIcon />
81
+ </IconButton>
82
+ </Tooltip>
77
83
  <MRT_RowActionMenu
78
84
  anchorEl={anchorEl}
79
85
  handleEdit={handleEdit}
@@ -7,10 +7,13 @@ interface Props extends IconButtonProps {}
7
7
  export const MRT_ToggleSearchButton: FC<Props> = ({ ...rest }) => {
8
8
  const {
9
9
  icons: { SearchIcon, SearchOffIcon },
10
+ idPrefix,
10
11
  localization,
11
12
  muiSearchTextFieldProps,
12
13
  setShowSearch,
13
- showSearch,
14
+ tableInstance: {
15
+ state: { showSearch },
16
+ },
14
17
  } = useMRT();
15
18
 
16
19
  const handleToggleSearch = () => {
@@ -19,7 +22,7 @@ export const MRT_ToggleSearchButton: FC<Props> = ({ ...rest }) => {
19
22
  () =>
20
23
  document
21
24
  .getElementById(
22
- muiSearchTextFieldProps?.id ?? `global-search-text-field`,
25
+ muiSearchTextFieldProps?.id ?? `mrt-${idPrefix}-search-text-field`,
23
26
  )
24
27
  ?.focus(),
25
28
  200,
@@ -0,0 +1,112 @@
1
+ import { matchSorter } from 'match-sorter';
2
+ import { MRT_Row } from '.';
3
+
4
+ export const fuzzyFilterFN = (
5
+ rows: MRT_Row[],
6
+ id: string,
7
+ filterValue: string | number,
8
+ ) =>
9
+ matchSorter(rows, filterValue.toString().trim(), {
10
+ keys: [`values.${id}`],
11
+ sorter: (rankedItems) => rankedItems,
12
+ });
13
+
14
+ fuzzyFilterFN.autoRemove = (val: any) => !val;
15
+
16
+ export const containsFilterFN = (
17
+ rows: MRT_Row[],
18
+ id: string,
19
+ filterValue: string | number,
20
+ ) =>
21
+ rows.filter((row) =>
22
+ row.values[id]
23
+ .toString()
24
+ .toLowerCase()
25
+ .trim()
26
+ .includes(filterValue.toString().toLowerCase().trim()),
27
+ );
28
+
29
+ containsFilterFN.autoRemove = (val: any) => !val;
30
+
31
+ export const startsWithFilterFN = (
32
+ rows: MRT_Row[],
33
+ id: string,
34
+ filterValue: string | number,
35
+ ) =>
36
+ rows.filter((row) =>
37
+ row.values[id]
38
+ .toString()
39
+ .toLowerCase()
40
+ .trim()
41
+ .startsWith(filterValue.toString().toLowerCase().trim()),
42
+ );
43
+
44
+ startsWithFilterFN.autoRemove = (val: any) => !val;
45
+
46
+ export const endsWithFilterFN = (
47
+ rows: MRT_Row[],
48
+ id: string,
49
+ filterValue: string | number,
50
+ ) =>
51
+ rows.filter((row) =>
52
+ row.values[id]
53
+ .toString()
54
+ .toLowerCase()
55
+ .trim()
56
+ .endsWith(filterValue.toString().toLowerCase().trim()),
57
+ );
58
+
59
+ endsWithFilterFN.autoRemove = (val: any) => !val;
60
+
61
+ export const equalsFilterFN = (
62
+ rows: MRT_Row[],
63
+ id: string,
64
+ filterValue: string | number,
65
+ ) =>
66
+ rows.filter(
67
+ (row) =>
68
+ row.values[id].toString().toLowerCase().trim() ===
69
+ filterValue.toString().toLowerCase().trim(),
70
+ );
71
+
72
+ equalsFilterFN.autoRemove = (val: any) => !val;
73
+
74
+ export const notEqualsFilterFN = (
75
+ rows: MRT_Row[],
76
+ id: string,
77
+ filterValue: string | number,
78
+ ) =>
79
+ rows.filter(
80
+ (row) =>
81
+ row.values[id].toString().toLowerCase().trim() !==
82
+ filterValue.toString().toLowerCase().trim(),
83
+ );
84
+
85
+ notEqualsFilterFN.autoRemove = (val: any) => !val;
86
+
87
+ export const emptyFilterFN = (
88
+ rows: MRT_Row[],
89
+ id: string,
90
+ _filterValue: string | number,
91
+ ) => rows.filter((row) => !row.values[id].toString().toLowerCase().trim());
92
+
93
+ emptyFilterFN.autoRemove = (val: any) => !val;
94
+
95
+ export const notEmptyFilterFN = (
96
+ rows: MRT_Row[],
97
+ id: string,
98
+ _filterValue: string | number,
99
+ ) => rows.filter((row) => !!row.values[id].toString().toLowerCase().trim());
100
+
101
+ notEmptyFilterFN.autoRemove = (val: any) => !val;
102
+
103
+ export const defaultFilterFNs = {
104
+ contains: containsFilterFN,
105
+ empty: emptyFilterFN,
106
+ endsWith: endsWithFilterFN,
107
+ equals: equalsFilterFN,
108
+ fuzzy: fuzzyFilterFN,
109
+ notEmpty: notEmptyFilterFN,
110
+ notEquals: notEqualsFilterFN,
111
+ startsWith: startsWithFilterFN,
112
+ };
@@ -9,8 +9,13 @@ interface Props {}
9
9
  export const MRT_TableFooter: FC<Props> = () => {
10
10
  const { muiTableFooterProps, tableInstance } = useMRT();
11
11
 
12
+ const tableFooterProps =
13
+ muiTableFooterProps instanceof Function
14
+ ? muiTableFooterProps(tableInstance)
15
+ : muiTableFooterProps;
16
+
12
17
  return (
13
- <TableFooter {...muiTableFooterProps}>
18
+ <TableFooter {...tableFooterProps}>
14
19
  {tableInstance.footerGroups.map((footerGroup: MRT_HeaderGroup) => (
15
20
  <MRT_TableFooterRow
16
21
  key={footerGroup.getFooterGroupProps().key}
@@ -8,8 +8,13 @@ interface Props {
8
8
  }
9
9
 
10
10
  export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
11
- const { muiTableFooterCellProps, densePadding, enableColumnResizing } =
12
- useMRT();
11
+ const {
12
+ muiTableFooterCellProps,
13
+ enableColumnResizing,
14
+ tableInstance: {
15
+ state: { densePadding },
16
+ },
17
+ } = useMRT();
13
18
 
14
19
  const isParentHeader = (column?.columns?.length ?? 0) > 0;
15
20