material-react-table 0.9.2 → 0.9.3

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.9.2",
2
+ "version": "0.9.3",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
@@ -774,7 +774,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
774
774
  export default <D extends Record<string, any> = {}>({
775
775
  autoResetExpanded = false,
776
776
  columnResizeMode = 'onEnd',
777
- defaultColumn = { minSize: 50, maxSize: 1000, size: 150 },
777
+ defaultColumn = { minSize: 30, maxSize: 1000, size: 180 },
778
778
  editingMode = 'row',
779
779
  enableColumnActions = true,
780
780
  enableColumnFilters = true,
@@ -1,8 +1,8 @@
1
1
  import React, { FC, RefObject } from 'react';
2
+ import { useVirtual } from 'react-virtual';
2
3
  import { TableBody } from '@mui/material';
3
4
  import { MRT_TableBodyRow } from './MRT_TableBodyRow';
4
- import { MRT_Row, MRT_TableInstance } from '..';
5
- import { useVirtual } from 'react-virtual';
5
+ import type { MRT_Row, MRT_TableInstance } from '..';
6
6
 
7
7
  interface Props {
8
8
  tableInstance: MRT_TableInstance;
@@ -31,16 +31,18 @@ export const MRT_TableBody: FC<Props> = ({
31
31
  ? getPaginationRowModel().rows
32
32
  : getPrePaginationRowModel().rows;
33
33
 
34
- const rowVirtualizer = useVirtual({
35
- overscan: isDensePadding ? 15 : 5,
36
- size: rows.length,
37
- parentRef: tableContainerRef,
38
- });
34
+ const rowVirtualizer = enableRowVirtualization
35
+ ? useVirtual({
36
+ overscan: isDensePadding ? 15 : 5,
37
+ size: rows.length,
38
+ parentRef: tableContainerRef,
39
+ })
40
+ : ({} as any);
39
41
 
40
42
  const { virtualItems: virtualRows } = rowVirtualizer;
41
- const paddingTop = virtualRows.length > 0 ? virtualRows[0].start : 0;
43
+ const paddingTop = virtualRows?.length > 0 ? virtualRows[0].start : 0;
42
44
  const paddingBottom =
43
- virtualRows.length > 0
45
+ virtualRows?.length > 0
44
46
  ? rowVirtualizer.totalSize - virtualRows[virtualRows.length - 1].end
45
47
  : 0;
46
48
 
@@ -23,11 +23,13 @@ export const MRT_TableBodyCell: FC<Props> = ({
23
23
  editingMode,
24
24
  enableClickToCopy,
25
25
  enableColumnOrdering,
26
+ enableColumnResizing,
26
27
  enableEditing,
27
- tableId,
28
+ enableRowVirtualization,
28
29
  muiTableBodyCellProps,
29
30
  muiTableBodyCellSkeletonProps,
30
31
  onMrtCellClick,
32
+ tableId,
31
33
  },
32
34
  setColumnOrder,
33
35
  setCurrentEditingCell,
@@ -131,6 +133,15 @@ export const MRT_TableBodyCell: FC<Props> = ({
131
133
  onMrtCellClick?.({ event, cell, tableInstance })
132
134
  }
133
135
  onDoubleClick={handleDoubleClick}
136
+ title={
137
+ (enableRowVirtualization || enableColumnResizing) &&
138
+ !columnDef?.Cell &&
139
+ !cell.getIsGrouped() &&
140
+ !columnDef.enableClickToCopy &&
141
+ typeof cell.getValue() === 'string'
142
+ ? (cell.getValue() as string)
143
+ : ''
144
+ }
134
145
  {...tableCellProps}
135
146
  ref={
136
147
  columnDefType === 'data' && enableColumnOrdering ? dropRef : undefined
@@ -149,6 +160,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
149
160
  column.getIsPinned() === 'left'
150
161
  ? `${column.getStart('left')}px`
151
162
  : undefined,
163
+ overflow: 'hidden',
152
164
  p: isDensePadding
153
165
  ? columnDefType === 'display'
154
166
  ? '0 0.5rem'
@@ -163,6 +175,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
163
175
  position: column.getIsPinned() ? 'sticky' : 'relative',
164
176
  right:
165
177
  column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
178
+ textOverflow: 'ellipsis',
166
179
  transition: 'all 0.2s ease-in-out',
167
180
  whiteSpace: isDensePadding ? 'nowrap' : 'normal',
168
181
  zIndex: column.getIsPinned() ? 1 : undefined,
@@ -10,12 +10,11 @@ interface Props {
10
10
  tableInstance: MRT_TableInstance;
11
11
  }
12
12
 
13
- export const MRT_Table: FC<Props> = ({
14
- tableContainerRef,
15
- tableInstance
16
- }) => {
13
+ export const MRT_Table: FC<Props> = ({ tableContainerRef, tableInstance }) => {
17
14
  const {
18
15
  options: {
16
+ enableColumnResizing,
17
+ enableRowVirtualization,
19
18
  enableStickyHeader,
20
19
  enableTableFooter,
21
20
  enableTableHead,
@@ -29,7 +28,15 @@ export const MRT_Table: FC<Props> = ({
29
28
  : muiTableProps;
30
29
 
31
30
  return (
32
- <Table stickyHeader={enableStickyHeader} {...tableProps}>
31
+ <Table
32
+ stickyHeader={enableStickyHeader}
33
+ {...tableProps}
34
+ sx={{
35
+ tableLayout:
36
+ enableColumnResizing || enableRowVirtualization ? 'fixed' : undefined,
37
+ ...tableProps?.sx,
38
+ }}
39
+ >
33
40
  {enableTableHead && <MRT_TableHead tableInstance={tableInstance} />}
34
41
  <MRT_TableBody
35
42
  tableContainerRef={tableContainerRef}
@@ -58,7 +58,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ tableInstance }) => {
58
58
  } as any)
59
59
  }
60
60
  >
61
- <MRT_LinearProgressBar alignTo='top' tableInstance={tableInstance} />
61
+ <MRT_LinearProgressBar alignTo="top" tableInstance={tableInstance} />
62
62
  {positionToolbarAlertBanner === 'bottom' && (
63
63
  <MRT_ToolbarAlertBanner tableInstance={tableInstance} />
64
64
  )}