material-react-table 2.0.0-alpha.4 → 2.0.0-alpha.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.
Files changed (50) hide show
  1. package/dist/cjs/index.js +458 -405
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/column.utils.d.ts +2 -0
  4. package/dist/cjs/types/icons.d.ts +1 -1
  5. package/dist/cjs/types/locales/hy.d.ts +2 -0
  6. package/dist/cjs/types/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
  7. package/dist/cjs/types/types.d.ts +22 -29
  8. package/dist/esm/material-react-table.esm.js +459 -407
  9. package/dist/esm/material-react-table.esm.js.map +1 -1
  10. package/dist/esm/types/column.utils.d.ts +2 -0
  11. package/dist/esm/types/icons.d.ts +1 -1
  12. package/dist/esm/types/locales/hy.d.ts +2 -0
  13. package/dist/esm/types/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
  14. package/dist/esm/types/types.d.ts +22 -29
  15. package/dist/index.d.ts +27 -33
  16. package/locales/hy.d.ts +2 -0
  17. package/locales/hy.esm.d.ts +2 -0
  18. package/locales/hy.esm.js +93 -0
  19. package/locales/hy.esm.js.map +1 -0
  20. package/locales/hy.js +97 -0
  21. package/locales/hy.js.map +1 -0
  22. package/package.json +7 -7
  23. package/src/body/MRT_TableBody.tsx +30 -22
  24. package/src/body/MRT_TableBodyCell.tsx +2 -2
  25. package/src/body/MRT_TableBodyRow.tsx +3 -3
  26. package/src/body/MRT_TableDetailPanel.tsx +3 -3
  27. package/src/buttons/MRT_GrabHandleButton.tsx +1 -2
  28. package/src/buttons/MRT_ShowHideColumnsButton.tsx +1 -2
  29. package/src/buttons/MRT_ToggleDensePaddingButton.tsx +1 -2
  30. package/src/buttons/MRT_ToggleFiltersButton.tsx +1 -2
  31. package/src/buttons/MRT_ToggleFullScreenButton.tsx +2 -3
  32. package/src/column.utils.ts +34 -9
  33. package/src/filterFns.ts +3 -3
  34. package/src/footer/MRT_TableFooter.tsx +1 -1
  35. package/src/footer/MRT_TableFooterCell.tsx +1 -1
  36. package/src/footer/MRT_TableFooterRow.tsx +2 -2
  37. package/src/head/MRT_TableHead.tsx +36 -14
  38. package/src/head/MRT_TableHeadCell.tsx +1 -1
  39. package/src/head/MRT_TableHeadCellFilterLabel.tsx +2 -0
  40. package/src/head/MRT_TableHeadRow.tsx +2 -2
  41. package/src/hooks/useMRT_TableInstance.ts +6 -6
  42. package/src/hooks/useMRT_TableOptions.ts +7 -2
  43. package/src/icons.ts +3 -3
  44. package/src/inputs/MRT_FilterTextField.tsx +4 -3
  45. package/src/locales/hy.ts +93 -0
  46. package/src/table/MRT_Table.tsx +24 -12
  47. package/src/toolbar/MRT_TablePagination.tsx +23 -14
  48. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +53 -15
  49. package/src/toolbar/MRT_TopToolbar.tsx +1 -1
  50. package/src/types.ts +26 -25
@@ -1,5 +1,6 @@
1
- import { memo, useMemo } from 'react';
1
+ import { memo, useCallback, useMemo } from 'react';
2
2
  import {
3
+ type Range,
3
4
  type VirtualItem,
4
5
  type Virtualizer,
5
6
  useVirtualizer,
@@ -7,7 +8,11 @@ import {
7
8
  import TableBody from '@mui/material/TableBody';
8
9
  import Typography from '@mui/material/Typography';
9
10
  import { MRT_TableBodyRow, Memo_MRT_TableBodyRow } from './MRT_TableBodyRow';
10
- import { parseFromValuesOrFunc } from '../column.utils';
11
+ import {
12
+ extraIndexRangeExtractor,
13
+ getCanRankRows,
14
+ parseFromValuesOrFunc,
15
+ } from '../column.utils';
11
16
  import { rankGlobalFuzzy } from '../sortingFns';
12
17
  import { type MRT_Row, type MRT_TableInstance } from '../types';
13
18
 
@@ -60,9 +65,9 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
60
65
  const {
61
66
  columnFilters,
62
67
  density,
68
+ draggingRow,
63
69
  expanded,
64
70
  globalFilter,
65
- globalFilterFn,
66
71
  isFullScreen,
67
72
  pagination,
68
73
  rowPinning,
@@ -81,18 +86,11 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
81
86
  const tableFooterHeight =
82
87
  (enableStickyFooter && tableFooterRef.current?.clientHeight) || 0;
83
88
 
84
- const shouldRankResults = useMemo(
89
+ const shouldRankRows = useMemo(
85
90
  () =>
86
- !manualExpanding &&
87
- !manualFiltering &&
88
- !manualGrouping &&
89
- !manualSorting &&
90
- enableGlobalFilterRankedResults &&
91
- globalFilter &&
92
- globalFilterFn === 'fuzzy' &&
93
- expanded !== true &&
91
+ getCanRankRows(table) &&
94
92
  !Object.values(sorting).some(Boolean) &&
95
- !Object.values(expanded).some(Boolean),
93
+ globalFilter,
96
94
  [
97
95
  enableGlobalFilterRankedResults,
98
96
  expanded,
@@ -114,8 +112,8 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
114
112
  );
115
113
 
116
114
  const rows = useMemo(() => {
117
- let rows = [];
118
- if (!shouldRankResults) {
115
+ let rows: MRT_Row<TData>[] = [];
116
+ if (!shouldRankRows) {
119
117
  rows =
120
118
  !enableRowPinning || rowPinningDisplayMode?.includes('sticky')
121
119
  ? getRowModel().rows
@@ -139,8 +137,8 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
139
137
 
140
138
  return rows;
141
139
  }, [
142
- shouldRankResults,
143
- shouldRankResults ? getPrePaginationRowModel().rows : getRowModel().rows,
140
+ shouldRankRows,
141
+ shouldRankRows ? getPrePaginationRowModel().rows : getRowModel().rows,
144
142
  pagination.pageIndex,
145
143
  pagination.pageSize,
146
144
  rowPinning,
@@ -160,6 +158,12 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
160
158
  ? (element) => element?.getBoundingClientRect().height
161
159
  : undefined,
162
160
  overscan: 4,
161
+ rangeExtractor: useCallback(
162
+ (range: Range) => {
163
+ return extraIndexRangeExtractor(range, draggingRow?.index ?? 0);
164
+ },
165
+ [draggingRow],
166
+ ),
163
167
  ...rowVirtualizerProps,
164
168
  })
165
169
  : undefined;
@@ -179,7 +183,7 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
179
183
  <TableBody
180
184
  {...tableBodyProps}
181
185
  sx={(theme) => ({
182
- display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
186
+ display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
183
187
  position: 'sticky',
184
188
  top: tableHeadHeight - 1,
185
189
  zIndex: 1,
@@ -209,7 +213,7 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
209
213
  <TableBody
210
214
  {...tableBodyProps}
211
215
  sx={(theme) => ({
212
- display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
216
+ display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
213
217
  height: rowVirtualizer
214
218
  ? `${rowVirtualizer.getTotalSize()}px`
215
219
  : 'inherit',
@@ -221,12 +225,16 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
221
225
  {tableBodyProps?.children ??
222
226
  (!rows.length ? (
223
227
  <tr
224
- style={{ display: layoutMode === 'grid' ? 'grid' : 'table-row' }}
228
+ style={{
229
+ display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
230
+ }}
225
231
  >
226
232
  <td
227
233
  colSpan={table.getVisibleLeafColumns().length}
228
234
  style={{
229
- display: layoutMode === 'grid' ? 'grid' : 'table-cell',
235
+ display: layoutMode?.startsWith('grid')
236
+ ? 'grid'
237
+ : 'table-cell',
230
238
  }}
231
239
  >
232
240
  {renderEmptyRowsFallback?.({ table }) ?? (
@@ -285,7 +293,7 @@ export const MRT_TableBody = <TData extends Record<string, any>>({
285
293
  {...tableBodyProps}
286
294
  sx={(theme) => ({
287
295
  bottom: tableFooterHeight - 1,
288
- display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
296
+ display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
289
297
  position: 'sticky',
290
298
  zIndex: 1,
291
299
  ...(parseFromValuesOrFunc(tableBodyProps?.sx, theme) as any),
@@ -210,11 +210,11 @@ export const MRT_TableBodyCell = <TData extends Record<string, any>>({
210
210
  outlineOffset: '-1px',
211
211
  textOverflow: 'clip',
212
212
  },
213
- alignItems: layoutMode === 'grid' ? 'center' : undefined,
213
+ alignItems: layoutMode?.startsWith('grid') ? 'center' : undefined,
214
214
  cursor:
215
215
  isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit',
216
216
  justifyContent:
217
- layoutMode === 'grid' ? tableCellProps.align : undefined,
217
+ layoutMode?.startsWith('grid') ? tableCellProps.align : undefined,
218
218
  overflow: 'hidden',
219
219
  p:
220
220
  density === 'compact'
@@ -145,7 +145,7 @@ export const MRT_TableBodyRow = <TData extends Record<string, any>>({
145
145
  },
146
146
  backgroundColor: `${lighten(
147
147
  theme.palette.background.default,
148
- 0.06,
148
+ 0.05,
149
149
  )} !important`,
150
150
  bottom:
151
151
  !virtualRow && bottomPinnedIndex !== undefined && isPinned
@@ -155,7 +155,7 @@ export const MRT_TableBodyRow = <TData extends Record<string, any>>({
155
155
  }px`
156
156
  : undefined,
157
157
  boxSizing: 'border-box',
158
- display: layoutMode === 'grid' ? 'flex' : 'table-row',
158
+ display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
159
159
  opacity: isPinned
160
160
  ? 0.98
161
161
  : draggingRow?.id === row.id || hoveredRow?.id === row.id
@@ -185,7 +185,7 @@ export const MRT_TableBodyRow = <TData extends Record<string, any>>({
185
185
  width: '100%',
186
186
  zIndex:
187
187
  rowPinningDisplayMode?.includes('sticky') && isPinned
188
- ? 1
188
+ ? 2
189
189
  : undefined,
190
190
  ...(sx as any),
191
191
  })}
@@ -51,7 +51,7 @@ export const MRT_TableDetailPanel = <TData extends Record<string, any>>({
51
51
  className="Mui-TableBodyCell-DetailPanel"
52
52
  {...tableRowProps}
53
53
  sx={(theme) => ({
54
- display: layoutMode === 'grid' ? 'flex' : 'table-row',
54
+ display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
55
55
  position: virtualRow ? 'absolute' : undefined,
56
56
  top: virtualRow
57
57
  ? `${parentRowRef.current?.getBoundingClientRect()?.height}px`
@@ -70,10 +70,10 @@ export const MRT_TableDetailPanel = <TData extends Record<string, any>>({
70
70
  {...tableCellProps}
71
71
  sx={(theme) => ({
72
72
  backgroundColor: virtualRow
73
- ? lighten(theme.palette.background.default, 0.06)
73
+ ? lighten(theme.palette.background.default, 0.05)
74
74
  : undefined,
75
75
  borderBottom: !row.getIsExpanded() ? 'none' : undefined,
76
- display: layoutMode === 'grid' ? 'flex' : 'table-cell',
76
+ display: layoutMode?.startsWith('grid') ? 'flex' : 'table-cell',
77
77
  pb: row.getIsExpanded() ? '1rem' : 0,
78
78
  pt: row.getIsExpanded() ? '1rem' : 0,
79
79
  transition: 'all 150ms ease-in-out',
@@ -1,6 +1,5 @@
1
1
  import { type DragEventHandler } from 'react';
2
- import IconButton from '@mui/material/IconButton';
3
- import { type IconButtonProps } from '@mui/material/IconButton';
2
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
4
3
  import Tooltip from '@mui/material/Tooltip';
5
4
  import { parseFromValuesOrFunc } from '../column.utils';
6
5
  import { type MRT_TableInstance } from '../types';
@@ -1,6 +1,5 @@
1
1
  import { type MouseEvent, useState } from 'react';
2
- import IconButton from '@mui/material/IconButton';
3
- import { type IconButtonProps } from '@mui/material/IconButton';
2
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
4
3
  import Tooltip from '@mui/material/Tooltip';
5
4
  import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
6
5
  import { type MRT_TableInstance } from '../types';
@@ -1,5 +1,4 @@
1
- import IconButton from '@mui/material/IconButton';
2
- import { type IconButtonProps } from '@mui/material/IconButton';
1
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
3
2
  import Tooltip from '@mui/material/Tooltip';
4
3
  import { type MRT_TableInstance } from '../types';
5
4
 
@@ -1,5 +1,4 @@
1
- import IconButton from '@mui/material/IconButton';
2
- import { type IconButtonProps } from '@mui/material/IconButton';
1
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
3
2
  import Tooltip from '@mui/material/Tooltip';
4
3
  import { type MRT_TableInstance } from '../types';
5
4
 
@@ -1,6 +1,5 @@
1
1
  import { useState } from 'react';
2
- import IconButton from '@mui/material/IconButton';
3
- import { type IconButtonProps } from '@mui/material/IconButton';
2
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
4
3
  import Tooltip from '@mui/material/Tooltip';
5
4
  import { type MRT_TableInstance } from '../types';
6
5
 
@@ -36,7 +35,7 @@ export const MRT_ToggleFullScreenButton = <TData extends Record<string, any>>({
36
35
  title={rest?.title ?? localization.toggleFullScreen}
37
36
  >
38
37
  <IconButton
39
- aria-label={localization.showHideFilters}
38
+ aria-label={localization.toggleFullScreen}
40
39
  onClick={handleToggleFullScreen}
41
40
  onMouseEnter={() => setTooltipOpened(true)}
42
41
  onMouseLeave={() => setTooltipOpened(false)}
@@ -1,10 +1,11 @@
1
- import { type ReactNode } from 'react';
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
2
  import {
3
3
  createRow as _createRow,
4
4
  flexRender as _flexRender,
5
5
  type Renderable,
6
6
  type Row,
7
7
  } from '@tanstack/react-table';
8
+ import { type Range, defaultRangeExtractor } from '@tanstack/react-virtual';
8
9
  import { type TableCellProps } from '@mui/material/TableCell';
9
10
  import { alpha, lighten } from '@mui/material/styles';
10
11
  import { type Theme } from '@mui/material/styles';
@@ -295,7 +296,10 @@ export const getCommonCellStyles = <TData extends Record<string, any>>({
295
296
  tableCellProps: TableCellProps;
296
297
  theme: Theme;
297
298
  }) => {
298
- const widthStyles = {
299
+ const {
300
+ options: { layoutMode },
301
+ } = table;
302
+ const widthStyles: CSSProperties = {
299
303
  minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(
300
304
  header?.id ?? column.id,
301
305
  )}-size) * 1px), ${column.columnDef.minSize ?? 30}px)`,
@@ -303,6 +307,15 @@ export const getCommonCellStyles = <TData extends Record<string, any>>({
303
307
  header?.id ?? column.id,
304
308
  )}-size) * 1px)`,
305
309
  };
310
+
311
+ if (layoutMode === 'grid') {
312
+ widthStyles.flex = `var(--${header ? 'header' : 'col'}-${parseCSSVarId(
313
+ header?.id ?? column.id,
314
+ )}-size) 0 auto`;
315
+ } else if (layoutMode === 'grid-no-grow') {
316
+ widthStyles.flex = '0 0 auto';
317
+ }
318
+
306
319
  return {
307
320
  backgroundColor:
308
321
  column.getIsPinned() && column.columnDef.columnDefType !== 'group'
@@ -314,13 +327,7 @@ export const getCommonCellStyles = <TData extends Record<string, any>>({
314
327
  : getIsFirstRightPinnedColumn(column)
315
328
  ? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
316
329
  : undefined,
317
- display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell',
318
- flex:
319
- table.options.layoutMode === 'grid'
320
- ? `var(--${header ? 'header' : 'col'}-${parseCSSVarId(
321
- header?.id ?? column.id,
322
- )}-size) 0 auto`
323
- : undefined,
330
+ display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
324
331
  left:
325
332
  column.getIsPinned() === 'left'
326
333
  ? `${column.getStart('left')}px`
@@ -417,3 +424,21 @@ export const createRow = <TData extends Record<string, any>>(
417
424
  -1,
418
425
  0,
419
426
  ) as MRT_Row<TData>;
427
+
428
+ export const extraIndexRangeExtractor = (
429
+ range: Range,
430
+ draggingIndex: number,
431
+ ) => {
432
+ const newIndexs = defaultRangeExtractor(range);
433
+ if (
434
+ draggingIndex >= 0 &&
435
+ draggingIndex < Math.max(range.startIndex - range.overscan, 0)
436
+ ) {
437
+ newIndexs.unshift(draggingIndex);
438
+ }
439
+ if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
440
+ newIndexs.push(draggingIndex);
441
+ }
442
+ return newIndexs;
443
+ };
444
+
package/src/filterFns.ts CHANGED
@@ -68,7 +68,7 @@ const equals = <TData extends Record<string, any>>(
68
68
  filterValue: number | string,
69
69
  ) =>
70
70
  row.getValue<number | string>(id).toString().toLowerCase().trim() ===
71
- filterValue.toString().toLowerCase().trim();
71
+ filterValue?.toString().toLowerCase().trim();
72
72
 
73
73
  equals.autoRemove = (val: any) => !val;
74
74
 
@@ -90,7 +90,7 @@ const greaterThan = <TData extends Record<string, any>>(
90
90
  !isNaN(+filterValue) && !isNaN(+row.getValue<number | string>(id))
91
91
  ? +row.getValue<number | string>(id) > +filterValue
92
92
  : row.getValue<number | string>(id).toString().toLowerCase().trim() >
93
- filterValue.toString().toLowerCase().trim();
93
+ filterValue?.toString().toLowerCase().trim();
94
94
 
95
95
  greaterThan.autoRemove = (val: any) => !val;
96
96
 
@@ -110,7 +110,7 @@ const lessThan = <TData extends Record<string, any>>(
110
110
  !isNaN(+filterValue) && !isNaN(+row.getValue<number | string>(id))
111
111
  ? +row.getValue<number | string>(id) < +filterValue
112
112
  : row.getValue<number | string>(id).toString().toLowerCase().trim() <
113
- filterValue.toString().toLowerCase().trim();
113
+ filterValue?.toString().toLowerCase().trim();
114
114
 
115
115
  lessThan.autoRemove = (val: any) => !val;
116
116
 
@@ -44,7 +44,7 @@ export const MRT_TableFooter = <TData extends Record<string, any>>({
44
44
  }}
45
45
  sx={(theme) => ({
46
46
  bottom: stickFooter ? 0 : undefined,
47
- display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
47
+ display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
48
48
  opacity: stickFooter ? 0.97 : undefined,
49
49
  outline: stickFooter
50
50
  ? theme.palette.mode === 'light'
@@ -35,7 +35,7 @@ export const MRT_TableFooterCell = <TData extends Record<string, any>>({
35
35
  variant="head"
36
36
  {...tableCellProps}
37
37
  sx={(theme) => ({
38
- display: layoutMode === 'grid' ? 'grid' : 'table-cell',
38
+ display: layoutMode?.startsWith('grid') ? 'grid' : 'table-cell',
39
39
  fontWeight: 'bold',
40
40
  justifyContent: columnDefType === 'group' ? 'center' : undefined,
41
41
  p:
@@ -48,8 +48,8 @@ export const MRT_TableFooterRow = <TData extends Record<string, any>>({
48
48
  <TableRow
49
49
  {...tableRowProps}
50
50
  sx={(theme) => ({
51
- backgroundColor: lighten(theme.palette.background.default, 0.04),
52
- display: layoutMode === 'grid' ? 'flex' : 'table-row',
51
+ backgroundColor: lighten(theme.palette.background.default, 0.05),
52
+ display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
53
53
  width: '100%',
54
54
  ...(parseFromValuesOrFunc(tableRowProps?.sx, theme) as any),
55
55
  })}
@@ -2,6 +2,7 @@ import { type VirtualItem } from '@tanstack/react-virtual';
2
2
  import TableHead from '@mui/material/TableHead';
3
3
  import { MRT_TableHeadRow } from './MRT_TableHeadRow';
4
4
  import { parseFromValuesOrFunc } from '../column.utils';
5
+ import { MRT_ToolbarAlertBanner } from '../toolbar';
5
6
  import { type MRT_TableInstance } from '../types';
6
7
 
7
8
  interface Props<TData extends Record<string, any>> {
@@ -19,11 +20,17 @@ export const MRT_TableHead = <TData extends Record<string, any>>({
19
20
  }: Props<TData>) => {
20
21
  const {
21
22
  getHeaderGroups,
23
+ getSelectedRowModel,
22
24
  getState,
23
- options: { enableStickyHeader, layoutMode, muiTableHeadProps },
25
+ options: {
26
+ enableStickyHeader,
27
+ layoutMode,
28
+ muiTableHeadProps,
29
+ positionToolbarAlertBanner,
30
+ },
24
31
  refs: { tableHeadRef },
25
32
  } = table;
26
- const { isFullScreen } = getState();
33
+ const { isFullScreen, showAlertBanner } = getState();
27
34
 
28
35
  const tableHeadProps = parseFromValuesOrFunc(muiTableHeadProps, { table });
29
36
 
@@ -40,24 +47,39 @@ export const MRT_TableHead = <TData extends Record<string, any>>({
40
47
  }
41
48
  }}
42
49
  sx={(theme) => ({
43
- display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
50
+ display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
44
51
  opacity: 0.97,
45
52
  position: stickyHeader ? 'sticky' : 'relative',
46
- top: stickyHeader && layoutMode === 'grid' ? 0 : undefined,
53
+ top: stickyHeader && layoutMode?.startsWith('grid') ? 0 : undefined,
47
54
  zIndex: stickyHeader ? 2 : undefined,
48
55
  ...(parseFromValuesOrFunc(tableHeadProps?.sx, theme) as any),
49
56
  })}
50
57
  >
51
- {getHeaderGroups().map((headerGroup) => (
52
- <MRT_TableHeadRow
53
- headerGroup={headerGroup as any}
54
- key={headerGroup.id}
55
- table={table}
56
- virtualColumns={virtualColumns}
57
- virtualPaddingLeft={virtualPaddingLeft}
58
- virtualPaddingRight={virtualPaddingRight}
59
- />
60
- ))}
58
+ {positionToolbarAlertBanner === 'head-overlay' &&
59
+ (showAlertBanner || getSelectedRowModel().rows.length > 0) ? (
60
+ <tr style={{ display: layoutMode?.startsWith('grid') ? 'grid' : undefined }}>
61
+ <th
62
+ colSpan={table.getVisibleLeafColumns().length}
63
+ style={{
64
+ display: layoutMode?.startsWith('grid') ? 'grid' : 'table-cell',
65
+ padding: 0,
66
+ }}
67
+ >
68
+ <MRT_ToolbarAlertBanner table={table} />
69
+ </th>
70
+ </tr>
71
+ ) : (
72
+ getHeaderGroups().map((headerGroup) => (
73
+ <MRT_TableHeadRow
74
+ headerGroup={headerGroup as any}
75
+ key={headerGroup.id}
76
+ table={table}
77
+ virtualColumns={virtualColumns}
78
+ virtualPaddingLeft={virtualPaddingLeft}
79
+ virtualPaddingRight={virtualPaddingRight}
80
+ />
81
+ ))
82
+ )}
61
83
  </TableHead>
62
84
  );
63
85
  };
@@ -126,7 +126,7 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
126
126
  }}
127
127
  {...tableCellProps}
128
128
  sx={(theme: Theme) => ({
129
- flexDirection: layoutMode === 'grid' ? 'column' : undefined,
129
+ flexDirection: layoutMode?.startsWith('grid') ? 'column' : undefined,
130
130
  fontWeight: 'bold',
131
131
  overflow: 'visible',
132
132
  p:
@@ -122,11 +122,13 @@ export const MRT_TableHeadCellFilterLabel = <
122
122
  horizontal: 'center',
123
123
  vertical: 'top',
124
124
  }}
125
+ onClick={(event) => event.stopPropagation()}
125
126
  onClose={(event) => {
126
127
  //@ts-ignore
127
128
  event.stopPropagation();
128
129
  setAnchorEl(null);
129
130
  }}
131
+ onKeyDown={(event) => event.key === 'Enter' && setAnchorEl(null)}
130
132
  open={!!anchorEl}
131
133
  transformOrigin={{
132
134
  horizontal: 'center',
@@ -37,9 +37,9 @@ export const MRT_TableHeadRow = <TData extends Record<string, any>>({
37
37
  <TableRow
38
38
  {...tableRowProps}
39
39
  sx={(theme) => ({
40
- backgroundColor: lighten(theme.palette.background.default, 0.04),
40
+ backgroundColor: lighten(theme.palette.background.default, 0.05),
41
41
  boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`,
42
- display: layoutMode === 'grid' ? 'flex' : 'table-row',
42
+ display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
43
43
  top: 0,
44
44
  ...(parseFromValuesOrFunc(tableRowProps?.sx, theme) as any),
45
45
  })}
@@ -103,12 +103,12 @@ export const useMRT_TableInstance: <TData extends Record<string, any>>(
103
103
  const [grouping, setGrouping] = useState<MRT_GroupingState>(
104
104
  initialState.grouping ?? [],
105
105
  );
106
- const [hoveredColumn, setHoveredColumn] = useState<
107
- { id: string } | MRT_Column<TData> | null
108
- >(initialState.hoveredColumn ?? null);
109
- const [hoveredRow, setHoveredRow] = useState<
110
- { id: string } | MRT_Row<TData> | null
111
- >(initialState.hoveredRow ?? null);
106
+ const [hoveredColumn, setHoveredColumn] = useState<Partial<
107
+ MRT_Column<TData>
108
+ > | null>(initialState.hoveredColumn ?? null);
109
+ const [hoveredRow, setHoveredRow] = useState<Partial<MRT_Row<TData>> | null>(
110
+ initialState.hoveredRow ?? null,
111
+ );
112
112
  const [isFullScreen, setIsFullScreen] = useState<boolean>(
113
113
  initialState?.isFullScreen ?? false,
114
114
  );
@@ -93,8 +93,13 @@ export const useMRT_TableOptions: <TData extends Record<string, any>>(
93
93
  [defaultDisplayColumn],
94
94
  );
95
95
 
96
- if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
97
- layoutMode = 'grid';
96
+ if (layoutMode === 'semantic') {
97
+ if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
98
+ layoutMode = 'grid';
99
+ }
100
+ if (enableColumnResizing) {
101
+ layoutMode = 'grid-no-grow';
102
+ }
98
103
  }
99
104
 
100
105
  if (rest.enableRowVirtualization) {
package/src/icons.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
2
2
  import ArrowRightIcon from '@mui/icons-material/ArrowRight';
3
3
  import CancelIcon from '@mui/icons-material/Cancel';
4
- import ChevronLefIcon from '@mui/icons-material/ChevronLeft';
4
+ import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
5
5
  import ChevronRightIcon from '@mui/icons-material/ChevronRight';
6
6
  import ClearAllIcon from '@mui/icons-material/ClearAll';
7
7
  import CloseIcon from '@mui/icons-material/Close';
@@ -35,7 +35,7 @@ export interface MRT_Icons {
35
35
  ArrowDownwardIcon: any;
36
36
  ArrowRightIcon: any;
37
37
  CancelIcon: any;
38
- ChevronLefIcon: any;
38
+ ChevronLeftIcon: any;
39
39
  ChevronRightIcon: any;
40
40
  ClearAllIcon: any;
41
41
  CloseIcon: any;
@@ -70,7 +70,7 @@ export const MRT_Default_Icons: MRT_Icons = {
70
70
  ArrowDownwardIcon,
71
71
  ArrowRightIcon,
72
72
  CancelIcon,
73
- ChevronLefIcon,
73
+ ChevronLeftIcon,
74
74
  ChevronRightIcon,
75
75
  ClearAllIcon,
76
76
  CloseIcon,
@@ -133,7 +133,7 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
133
133
  if (isRangeFilter) {
134
134
  column.setFilterValue((old: Array<Date | null | number | string>) => {
135
135
  const newFilterValues = old ?? ['', ''];
136
- newFilterValues[rangeFilterIndex as number] = newValue;
136
+ newFilterValues[rangeFilterIndex as number] = newValue ?? undefined;
137
137
  return newFilterValues;
138
138
  });
139
139
  } else {
@@ -146,7 +146,7 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
146
146
  );
147
147
 
148
148
  const handleChange = (newValue: any) => {
149
- setFilterValue(newValue?.toString() ?? '');
149
+ setFilterValue(newValue ?? '');
150
150
  handleChangeDebounced(newValue);
151
151
  };
152
152
 
@@ -246,7 +246,7 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
246
246
  sx={{
247
247
  height: '2rem',
248
248
  transform: 'scale(0.9)',
249
- width: '2rem'
249
+ width: '2rem',
250
250
  }}
251
251
  >
252
252
  <CloseIcon />
@@ -364,6 +364,7 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
364
364
  />
365
365
  ) : isAutocompleteFilter ? (
366
366
  <Autocomplete
367
+ freeSolo
367
368
  getOptionLabel={(option) => option}
368
369
  onChange={(_e, newValue) => handleChange(newValue)}
369
370
  options={dropdownOptions ?? []}