material-react-table 0.29.1 → 0.30.2

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.29.1",
2
+ "version": "0.30.2",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -82,9 +82,6 @@
82
82
  "react": "^18.2.0",
83
83
  "react-dom": "^18.2.0",
84
84
  "react-is": "^18.2.0",
85
- "rollup-plugin-commonjs": "^10.1.0",
86
- "rollup-plugin-node-resolve": "^5.2.0",
87
- "rollup-plugin-peer-deps-external": "^2.2.4",
88
85
  "size-limit": "^7.0.8",
89
86
  "storybook-dark-mode": "^1.1.0",
90
87
  "tsdx": "^0.14.1",
@@ -100,7 +97,7 @@
100
97
  },
101
98
  "dependencies": {
102
99
  "@tanstack/match-sorter-utils": "8.1.1",
103
- "@tanstack/react-table": "8.2.6",
100
+ "@tanstack/react-table": "8.5.2",
104
101
  "@tanstack/react-virtual": "^3.0.0-beta.13"
105
102
  }
106
103
  }
@@ -390,13 +390,17 @@ export type MRT_Cell<TData extends Record<string, any> = {}> = Omit<
390
390
  row: MRT_Row<TData>;
391
391
  };
392
392
 
393
- export type MRT_SortingOption = keyof typeof MRT_SortingFns;
393
+ export type MRT_SortingOption = LiteralUnion<
394
+ string & keyof typeof MRT_SortingFns
395
+ >;
394
396
 
395
397
  export type MRT_SortingFn<TData extends Record<string, any> = {}> =
396
398
  | SortingFn<TData>
397
399
  | MRT_SortingOption;
398
400
 
399
- export type MRT_FilterOption = keyof typeof MRT_FilterFns;
401
+ export type MRT_FilterOption = LiteralUnion<
402
+ string & keyof typeof MRT_FilterFns
403
+ >;
400
404
 
401
405
  export type MRT_FilterFn<TData extends Record<string, any> = {}> =
402
406
  | FilterFn<TData>
@@ -51,6 +51,7 @@ export const prepareColumns = <TData extends Record<string, any> = {}>(
51
51
  } else if (columnDef.columnDefType === 'data') {
52
52
  if (Object.keys(MRT_FilterFns).includes(currentFilterFns[columnDef.id])) {
53
53
  columnDef.filterFn =
54
+ // @ts-ignore
54
55
  MRT_FilterFns[currentFilterFns[columnDef.id]] ?? MRT_FilterFns.fuzzy;
55
56
  //@ts-ignore
56
57
  columnDef._filterFn = currentFilterFns[columnDef.id];
@@ -28,7 +28,12 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
28
28
  },
29
29
  setCurrentHoveredColumn,
30
30
  } = table;
31
- const { density, currentDraggingColumn, currentHoveredColumn } = getState();
31
+ const {
32
+ density,
33
+ currentDraggingColumn,
34
+ currentHoveredColumn,
35
+ showColumnFilters,
36
+ } = getState();
32
37
  const { column } = header;
33
38
  const { columnDef } = column;
34
39
  const { columnDefType } = columnDef;
@@ -136,7 +141,12 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
136
141
  : columnDefType === 'display'
137
142
  ? '1rem 1.25rem'
138
143
  : '1.5rem',
139
- pb: columnDefType === 'display' ? 0 : undefined,
144
+ pb:
145
+ columnDefType === 'display'
146
+ ? 0
147
+ : showColumnFilters
148
+ ? '0.5rem'
149
+ : undefined,
140
150
  position:
141
151
  column.getIsPinned() && columnDefType !== 'group'
142
152
  ? 'sticky'
package/src/index.tsx CHANGED
@@ -1,3 +1,9 @@
1
1
  import MaterialReactTable from './MaterialReactTable';
2
2
  export default MaterialReactTable;
3
3
  export * from './MaterialReactTable';
4
+
5
+ import type { MRT_Icons } from './icons';
6
+ export type { MRT_Icons };
7
+
8
+ import type { MRT_Localization } from './localization';
9
+ export type { MRT_Localization };
@@ -250,7 +250,7 @@ export const MRT_FilterTextField: FC<Props> = ({
250
250
  )}
251
251
  </InputAdornment>
252
252
  ) : (
253
- <FilterListIcon />
253
+ <FilterListIcon style={{ marginRight: '4px' }} />
254
254
  ),
255
255
  endAdornment: !filterChipLabel && (
256
256
  <InputAdornment position="end">
@@ -297,7 +297,7 @@ export const MRT_FilterTextField: FC<Props> = ({
297
297
  sx={(theme) => ({
298
298
  p: 0,
299
299
  minWidth: !filterChipLabel ? '6rem' : 'auto',
300
- width: 'calc(100% + 0.5rem)',
300
+ width: '100%',
301
301
  '& .MuiSelect-icon': {
302
302
  mr: '1.5rem',
303
303
  },
@@ -311,30 +311,32 @@ export const MRT_FilterTextField: FC<Props> = ({
311
311
  <Box sx={{ opacity: 0.5 }}>{filterPlaceholder}</Box>
312
312
  </MenuItem>
313
313
  )}
314
- {columnDef?.filterSelectOptions?.map((option) => {
315
- let value: string;
316
- let text: string;
317
- if (typeof option !== 'object') {
318
- value = option;
319
- text = option;
320
- } else {
321
- value = option.value;
322
- text = option.text;
323
- }
324
- return (
325
- <MenuItem key={value} value={value}>
326
- {isMultiSelectFilter && (
327
- <Checkbox
328
- checked={(
329
- (column.getFilterValue() ?? []) as string[]
330
- ).includes(value)}
331
- sx={{ mr: '0.5rem' }}
332
- />
333
- )}
334
- <ListItemText>{text}</ListItemText>
335
- </MenuItem>
336
- );
337
- })}
314
+ {columnDef?.filterSelectOptions?.map(
315
+ (option: string | { text: string; value: string }) => {
316
+ let value: string;
317
+ let text: string;
318
+ if (typeof option !== 'object') {
319
+ value = option;
320
+ text = option;
321
+ } else {
322
+ value = option.value;
323
+ text = option.text;
324
+ }
325
+ return (
326
+ <MenuItem key={value} value={value}>
327
+ {isMultiSelectFilter && (
328
+ <Checkbox
329
+ checked={(
330
+ (column.getFilterValue() ?? []) as string[]
331
+ ).includes(value)}
332
+ sx={{ mr: '0.5rem' }}
333
+ />
334
+ )}
335
+ <ListItemText>{text}</ListItemText>
336
+ </MenuItem>
337
+ );
338
+ },
339
+ )}
338
340
  </TextField>
339
341
  <MRT_FilterOptionMenu
340
342
  anchorEl={anchorEl}
@@ -86,7 +86,7 @@ export const MRT_GlobalFilterTextField: FC<Props> = ({ table }) => {
86
86
  </Tooltip>
87
87
  </InputAdornment>
88
88
  ) : (
89
- <SearchIcon />
89
+ <SearchIcon style={{ marginRight: '4px' }} />
90
90
  ),
91
91
  endAdornment: (
92
92
  <InputAdornment position="end">
@@ -100,7 +100,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
100
100
 
101
101
  const handleGroupByColumn = () => {
102
102
  column.toggleGrouping();
103
- setColumnOrder((old) => ['mrt-row-expand', ...old]);
103
+ setColumnOrder((old: any) => ['mrt-row-expand', ...old]);
104
104
  setAnchorEl(null);
105
105
  };
106
106
 
@@ -186,7 +186,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
186
186
  >
187
187
  <Box sx={commonListItemStyles}>
188
188
  <ListItemIcon>
189
- <SortIcon />
189
+ <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
190
190
  </ListItemIcon>
191
191
  {localization.sortByColumnAsc?.replace(
192
192
  '{column}',
@@ -203,7 +203,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
203
203
  >
204
204
  <Box sx={commonListItemStyles}>
205
205
  <ListItemIcon>
206
- <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
206
+ <SortIcon />
207
207
  </ListItemIcon>
208
208
  {localization.sortByColumnDesc?.replace(
209
209
  '{column}',
@@ -254,6 +254,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
254
254
  data,
255
255
  getSubRows: (row) => row?.subRows,
256
256
  globalFilterFn:
257
+ //@ts-ignore
257
258
  MRT_FilterFns[currentGlobalFilterFn] ?? MRT_FilterFns.fuzzy,
258
259
  initialState,
259
260
  state: {