material-react-table 1.9.4 → 1.11.0

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/cjs/index.js +216 -215
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/MaterialReactTable.d.ts +4 -0
  4. package/dist/cjs/types/_locales/fi.d.ts +2 -0
  5. package/dist/cjs/types/_locales/id.d.ts +2 -0
  6. package/dist/cjs/types/body/MRT_TableDetailPanel.d.ts +2 -1
  7. package/dist/cjs/types/column.utils.d.ts +1 -1
  8. package/dist/cjs/types/menus/MRT_ShowHideColumnsMenu.d.ts +1 -1
  9. package/dist/cjs/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -2
  10. package/dist/esm/material-react-table.esm.js +213 -212
  11. package/dist/esm/material-react-table.esm.js.map +1 -1
  12. package/dist/esm/types/MaterialReactTable.d.ts +4 -0
  13. package/dist/esm/types/_locales/fi.d.ts +2 -0
  14. package/dist/esm/types/_locales/id.d.ts +2 -0
  15. package/dist/esm/types/body/MRT_TableDetailPanel.d.ts +2 -1
  16. package/dist/esm/types/column.utils.d.ts +1 -1
  17. package/dist/esm/types/menus/MRT_ShowHideColumnsMenu.d.ts +1 -1
  18. package/dist/esm/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -2
  19. package/dist/index.d.ts +4 -0
  20. package/locales/fi.d.ts +2 -0
  21. package/locales/fi.esm.d.ts +2 -0
  22. package/locales/fi.esm.js +94 -0
  23. package/locales/fi.esm.js.map +1 -0
  24. package/locales/fi.js +98 -0
  25. package/locales/fi.js.map +1 -0
  26. package/locales/id.d.ts +2 -0
  27. package/locales/id.esm.d.ts +2 -0
  28. package/locales/id.esm.js +94 -0
  29. package/locales/id.esm.js.map +1 -0
  30. package/locales/id.js +98 -0
  31. package/locales/id.js.map +1 -0
  32. package/package.json +10 -8
  33. package/src/MaterialReactTable.tsx +4 -0
  34. package/src/_locales/fi.ts +94 -0
  35. package/src/_locales/id.ts +95 -0
  36. package/src/body/MRT_TableBody.tsx +22 -17
  37. package/src/body/MRT_TableBodyRow.tsx +2 -1
  38. package/src/body/MRT_TableDetailPanel.tsx +3 -1
  39. package/src/column.utils.ts +95 -83
  40. package/src/head/MRT_TableHeadCell.tsx +2 -2
  41. package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
  42. package/src/menus/MRT_ColumnActionMenu.tsx +3 -26
  43. package/src/menus/MRT_ShowHideColumnsMenu.tsx +4 -6
  44. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -8
  45. package/src/toolbar/MRT_ToolbarDropZone.tsx +1 -0
@@ -0,0 +1,94 @@
1
+ import type { MRT_Localization } from '../MaterialReactTable';
2
+
3
+ export const MRT_Localization_FI: MRT_Localization = {
4
+ actions: 'Toiminnot',
5
+ and: 'ja',
6
+ cancel: 'Peruuta',
7
+ changeFilterMode: 'Muuta suodattimen tilaa',
8
+ changeSearchMode: 'Muuta hakutapaa',
9
+ clearFilter: 'Tyhjennä suodatin',
10
+ clearSearch: 'Tyhjennä haku',
11
+ clearSort: 'Tyhjennä lajittelu',
12
+ clickToCopy: 'Kopioi napsauttamalla',
13
+ collapse: 'Supista',
14
+ collapseAll: 'Supista kaikki',
15
+ columnActions: 'Saraketoiminnot',
16
+ copiedToClipboard: 'Kopioitu leikepöydälle',
17
+ dropToGroupBy: 'Pudota tähän ryhmitelläksesi sarakkeen {column} mukaan',
18
+ edit: 'Muokkaa',
19
+ expand: 'Laajenna',
20
+ expandAll: 'Laajenna kaikki',
21
+ filterArrIncludes: 'Sisältää',
22
+ filterArrIncludesAll: 'Sisältää kaikki',
23
+ filterArrIncludesSome: 'Sisältää',
24
+ filterBetween: 'Välillä',
25
+ filterBetweenInclusive: 'Välillä mukaan lukien',
26
+ filterByColumn: 'Suodata sarakkeen {column} mukaan',
27
+ filterContains: 'Sisältää',
28
+ filterEmpty: 'Tyhjä',
29
+ filterEndsWith: 'Loppuu',
30
+ filterEquals: 'On yhtä kuin',
31
+ filterEqualsString: 'On yhtä kuin',
32
+ filterFuzzy: 'Sumea',
33
+ filterGreaterThan: 'Enemmän kuin',
34
+ filterGreaterThanOrEqualTo: 'Enemmän tai yhtä paljon kuin',
35
+ filterInNumberRange: 'Välillä',
36
+ filterIncludesString: 'Sisältää',
37
+ filterIncludesStringSensitive: 'Sisältää',
38
+ filterLessThan: 'Vähemmän kuin',
39
+ filterLessThanOrEqualTo: 'Vähemmän tai yhtä paljon kuin',
40
+ filterMode: 'Suodattimen tila: {filterType}',
41
+ filterNotEmpty: 'Ei tyhjä',
42
+ filterNotEquals: 'Ei ole yhtä kuin',
43
+ filterStartsWith: 'Alkaa',
44
+ filterWeakEquals: 'On yhtä kuin',
45
+ filteringByColumn: 'Suodatetaan sarakkeen {column} mukaan - {filterType} {filterValue}',
46
+ goToFirstPage: 'Siirry ensimmäiselle sivulle',
47
+ goToLastPage: 'Siirry viimeiselle sivulle',
48
+ goToNextPage: 'Siirry seuraavalle sivulle',
49
+ goToPreviousPage: 'Siirry edelliselle sivulle',
50
+ grab: 'Nappaa',
51
+ groupByColumn: 'Ryhmittele sarakkeen {column} mukaan',
52
+ groupedBy: 'Ryhmitelty sarakkeella ',
53
+ hideAll: 'Piilota kaikki',
54
+ hideColumn: 'Piilota sarake {column}',
55
+ max: 'Maksimi',
56
+ min: 'Minimi',
57
+ move: 'Siirrä',
58
+ noRecordsToDisplay: 'Ei näytettäviä tietueita',
59
+ noResultsFound: 'Ei tuloksia',
60
+ of: '/',
61
+ or: 'tai',
62
+ pinToLeft: 'Kiinnitä vasemmalle',
63
+ pinToRight: 'Kiinnitä oikealle',
64
+ resetColumnSize: 'Nollaa sarakkeen koko',
65
+ resetOrder: 'Nollaa järjestys',
66
+ rowActions: 'Rivitoiminnot',
67
+ rowNumber: '#',
68
+ rowNumbers: 'Rivinumerot',
69
+ rowsPerPage: 'Rivejä per sivu',
70
+ save: 'Tallenna',
71
+ search: 'Etsi',
72
+ selectedCountOfRowCountRowsSelected:
73
+ '{selectedCount}/{rowCount} rivi(ä) valittu',
74
+ select: 'Valitse',
75
+ showAll: 'Näytä kaikki',
76
+ showAllColumns: 'Näytä kaikki sarakkeet',
77
+ showHideColumns: 'Näytä/piilota sarakkeita',
78
+ showHideFilters: 'Näytä/piilota suodattimet',
79
+ showHideSearch: 'Näytä/piilota haku',
80
+ sortByColumnAsc: 'Järjestä sarakkeen {column} mukaan nousevasti',
81
+ sortByColumnDesc: 'Järjestä sarakkeen {column} mukaan laskevasti',
82
+ sortedByColumnAsc: 'Järjestetty sarakkeen {column} mukaan nousevasti',
83
+ sortedByColumnDesc: 'Järjestetty sarakkeen {column} mukaan laskevasti',
84
+ thenBy: ', sitten ',
85
+ toggleDensity: 'Vaihda tiheyttä',
86
+ toggleFullScreen: 'Vaihda kokoruututila',
87
+ toggleSelectAll: 'Vaihda valitse kaikki',
88
+ toggleSelectRow: 'Vaihda valitse rivi',
89
+ toggleVisibility: 'Vaihda näkyvyys',
90
+ ungroupByColumn: 'Poista ryhmittely sarakkeen {column} mukaan',
91
+ unpin: 'Poista kiinnitys',
92
+ unpinAll: 'Poista kiinnitys kaikilta',
93
+ unsorted: 'Järjestämätön',
94
+ };
@@ -0,0 +1,95 @@
1
+ import type { MRT_Localization } from '../MaterialReactTable';
2
+
3
+ export const MRT_Localization_ID: MRT_Localization = {
4
+ actions: 'Aksi',
5
+ and: 'dan',
6
+ cancel: 'Batal',
7
+ changeFilterMode: 'Ubah mode filter',
8
+ changeSearchMode: 'Ubah mode pencarian',
9
+ clearFilter: 'Hapus filter',
10
+ clearSearch: 'Hapus pencarian',
11
+ clearSort: 'Hapus urutan',
12
+ clickToCopy: 'Klik untuk menyalin',
13
+ collapse: 'Ciutkan',
14
+ collapseAll: 'Ciutkan semua',
15
+ columnActions: 'Aksi Kolom',
16
+ copiedToClipboard: 'Disalin ke papan klip',
17
+ dropToGroupBy: 'Jatuhkan untuk mengelompokkan berdasarkan {column}',
18
+ edit: 'Ubah',
19
+ expand: 'Bentangkan',
20
+ expandAll: 'Bentangkan semua',
21
+ filterArrIncludes: 'Termasuk',
22
+ filterArrIncludesAll: 'Termasuk semua',
23
+ filterArrIncludesSome: 'Termasuk',
24
+ filterBetween: 'Antara',
25
+ filterBetweenInclusive: 'Antara Inklusif',
26
+ filterByColumn: 'Filter berdasarkan {column}',
27
+ filterContains: 'Berisi',
28
+ filterEmpty: 'Kosong',
29
+ filterEndsWith: 'Berakhir Dengan',
30
+ filterEquals: 'Sama dengan',
31
+ filterEqualsString: 'Sama dengan',
32
+ filterFuzzy: 'Fuzzy',
33
+ filterGreaterThan: 'Lebih Dari',
34
+ filterGreaterThanOrEqualTo: 'Lebih Dari Atau Sama Dengan',
35
+ filterInNumberRange: 'Antara',
36
+ filterIncludesString: 'Berisi',
37
+ filterIncludesStringSensitive: 'Berisi',
38
+ filterLessThan: 'Kurang Dari',
39
+ filterLessThanOrEqualTo: 'Kurang Dari Atau Sama Dengan',
40
+ filterMode: 'Mode Filter: {filterType}',
41
+ filterNotEmpty: 'Tidak Kosong',
42
+ filterNotEquals: 'Tidak Sama Dengan',
43
+ filterStartsWith: 'Dimulai Dengan',
44
+ filterWeakEquals: 'Sama Dengan',
45
+ filteringByColumn:
46
+ 'Memfilter berdasarkan {column} - {filterType} {filterValue}',
47
+ goToFirstPage: 'Pergi ke halaman pertama',
48
+ goToLastPage: 'Pergi ke halaman terakhir',
49
+ goToNextPage: 'Pergi ke halaman berikutnya',
50
+ goToPreviousPage: 'Pergi ke halaman sebelumnya',
51
+ grab: 'Ambil',
52
+ groupByColumn: 'Kelompokkan berdasarkan {column}',
53
+ groupedBy: 'Dikelompokkan berdasarkan ',
54
+ hideAll: 'Sembunyikan semua',
55
+ hideColumn: 'Sembunyikan kolom {column}',
56
+ max: 'Maks',
57
+ min: 'Min',
58
+ move: 'Pindah',
59
+ noRecordsToDisplay: 'Tidak ada data untuk ditampilkan',
60
+ noResultsFound: 'Tidak ada hasil yang ditemukan',
61
+ of: 'dari',
62
+ or: 'atau',
63
+ pinToLeft: 'Sematkan ke kiri',
64
+ pinToRight: 'Sematkan ke kanan',
65
+ resetColumnSize: 'Reset ukuran kolom',
66
+ resetOrder: 'Reset urutan',
67
+ rowActions: 'Aksi Baris',
68
+ rowNumber: '#',
69
+ rowNumbers: 'Nomor Baris',
70
+ rowsPerPage: 'Baris per halaman',
71
+ save: 'Simpan',
72
+ search: 'Cari',
73
+ selectedCountOfRowCountRowsSelected:
74
+ '{selectedCount} dari {rowCount} baris dipilih',
75
+ select: 'Pilih',
76
+ showAll: 'Tampilkan semua',
77
+ showAllColumns: 'Tampilkan semua kolom',
78
+ showHideColumns: 'Tampilkan/Sembunyikan kolom',
79
+ showHideFilters: 'Tampilkan/Sembunyikan filter',
80
+ showHideSearch: 'Tampilkan/Sembunyikan pencarian',
81
+ sortByColumnAsc: 'Urutkan berdasarkan {column} menaik',
82
+ sortByColumnDesc: 'Urutkan berdasarkan {column} menurun',
83
+ sortedByColumnAsc: 'Diurutkan berdasarkan {column} menaik',
84
+ sortedByColumnDesc: 'Diurutkan berdasarkan {column} menurun',
85
+ thenBy: ', lalu berdasarkan ',
86
+ toggleDensity: 'Beralih kepadatan',
87
+ toggleFullScreen: 'Beralih layar penuh',
88
+ toggleSelectAll: 'Beralih pilih semua',
89
+ toggleSelectRow: 'Beralih pilih baris',
90
+ toggleVisibility: 'Beralih visibilitas',
91
+ ungroupByColumn: 'Batalkan pengelompokan berdasarkan {column}',
92
+ unpin: 'Lepaskan sematan',
93
+ unpinAll: 'Lepaskan semua sematan',
94
+ unsorted: 'Tidak diurutkan',
95
+ };
@@ -42,6 +42,7 @@ export const MRT_TableBody = ({
42
42
  manualSorting,
43
43
  memoMode,
44
44
  muiTableBodyProps,
45
+ renderEmptyRowsFallback,
45
46
  rowVirtualizerInstanceRef,
46
47
  rowVirtualizerProps,
47
48
  virtualizerInstanceRef,
@@ -163,24 +164,28 @@ export const MRT_TableBody = ({
163
164
  <tr style={{ display: layoutMode === 'grid' ? 'grid' : 'table-row' }}>
164
165
  <td
165
166
  colSpan={table.getVisibleLeafColumns().length}
166
- style={{ display: layoutMode === 'grid' ? 'grid' : 'table-cell' }}
167
+ style={{
168
+ display: layoutMode === 'grid' ? 'grid' : 'table-cell',
169
+ }}
167
170
  >
168
- <Typography
169
- sx={{
170
- color: 'text.secondary',
171
- fontStyle: 'italic',
172
- maxWidth: `min(100vw, ${
173
- tablePaperRef.current?.clientWidth ?? 360
174
- }px)`,
175
- py: '2rem',
176
- textAlign: 'center',
177
- width: '100%',
178
- }}
179
- >
180
- {globalFilter || columnFilters.length
181
- ? localization.noResultsFound
182
- : localization.noRecordsToDisplay}
183
- </Typography>
171
+ {renderEmptyRowsFallback?.({ table }) ?? (
172
+ <Typography
173
+ sx={{
174
+ color: 'text.secondary',
175
+ fontStyle: 'italic',
176
+ maxWidth: `min(100vw, ${
177
+ tablePaperRef.current?.clientWidth ?? 360
178
+ }px)`,
179
+ py: '2rem',
180
+ textAlign: 'center',
181
+ width: '100%',
182
+ }}
183
+ >
184
+ {globalFilter || columnFilters.length
185
+ ? localization.noResultsFound
186
+ : localization.noRecordsToDisplay}
187
+ </Typography>
188
+ )}
184
189
  </td>
185
190
  </tr>
186
191
  ) : (
@@ -47,7 +47,7 @@ export const MRT_TableBodyRow = ({
47
47
 
48
48
  const tableRowProps =
49
49
  muiTableBodyRowProps instanceof Function
50
- ? muiTableBodyRowProps({ row, table })
50
+ ? muiTableBodyRowProps({ row, staticRowIndex: rowIndex, table })
51
51
  : muiTableBodyRowProps;
52
52
 
53
53
  const handleDragEnter = (_e: DragEvent) => {
@@ -136,6 +136,7 @@ export const MRT_TableBodyRow = ({
136
136
  <MRT_TableDetailPanel
137
137
  parentRowRef={rowRef}
138
138
  row={row}
139
+ rowIndex={rowIndex}
139
140
  table={table}
140
141
  virtualRow={virtualRow}
141
142
  />
@@ -9,6 +9,7 @@ import type { MRT_Row, MRT_TableInstance } from '..';
9
9
  interface Props {
10
10
  parentRowRef: React.RefObject<HTMLTableRowElement>;
11
11
  row: MRT_Row;
12
+ rowIndex: number;
12
13
  table: MRT_TableInstance;
13
14
  virtualRow?: VirtualItem;
14
15
  }
@@ -16,6 +17,7 @@ interface Props {
16
17
  export const MRT_TableDetailPanel = ({
17
18
  parentRowRef,
18
19
  row,
20
+ rowIndex,
19
21
  table,
20
22
  virtualRow,
21
23
  }: Props) => {
@@ -33,7 +35,7 @@ export const MRT_TableDetailPanel = ({
33
35
 
34
36
  const tableRowProps =
35
37
  muiTableBodyRowProps instanceof Function
36
- ? muiTableBodyRowProps({ isDetailPanel: true, row, table })
38
+ ? muiTableBodyRowProps({ isDetailPanel: true, row, staticRowIndex: rowIndex, table })
37
39
  : muiTableBodyRowProps;
38
40
 
39
41
  const tableCellProps =
@@ -164,29 +164,34 @@ export const getTrailingDisplayColumnIds = <
164
164
  TData extends Record<string, any> = {},
165
165
  >(
166
166
  props: MaterialReactTableProps<TData>,
167
- ) => [
168
- props.positionActionsColumn === 'last' &&
169
- (props.enableRowActions ||
170
- (props.enableEditing &&
171
- ['row', 'modal'].includes(props.editingMode ?? ''))) &&
172
- 'mrt-row-actions',
173
- props.positionExpandColumn === 'last' &&
174
- showExpandColumn(props) &&
175
- 'mrt-row-expand',
176
- ];
167
+ ) =>
168
+ [
169
+ props.positionActionsColumn === 'last' &&
170
+ (props.enableRowActions ||
171
+ (props.enableEditing &&
172
+ ['row', 'modal'].includes(props.editingMode ?? ''))) &&
173
+ 'mrt-row-actions',
174
+ props.positionExpandColumn === 'last' &&
175
+ showExpandColumn(props) &&
176
+ 'mrt-row-expand',
177
+ ].filter(Boolean) as MRT_DisplayColumnIds[];
177
178
 
178
179
  export const getDefaultColumnOrderIds = <
179
180
  TData extends Record<string, any> = {},
180
181
  >(
181
182
  props: MaterialReactTableProps<TData>,
182
- ) =>
183
- [
184
- ...getLeadingDisplayColumnIds(props),
185
- ...getAllLeafColumnDefs(props.columns).map((columnDef) =>
186
- getColumnId(columnDef),
187
- ),
188
- ...getTrailingDisplayColumnIds(props),
189
- ].filter(Boolean) as string[];
183
+ ) => {
184
+ const leadingDisplayCols: string[] = getLeadingDisplayColumnIds(props);
185
+ const trailingDisplayCols: string[] = getTrailingDisplayColumnIds(props);
186
+ const allLeafColumnDefs = getAllLeafColumnDefs(props.columns)
187
+ .map((columnDef) => getColumnId(columnDef))
188
+ .filter(
189
+ (columnId) =>
190
+ !leadingDisplayCols.includes(columnId) &&
191
+ !trailingDisplayCols.includes(columnId),
192
+ );
193
+ return [...leadingDisplayCols, ...allLeafColumnDefs, ...trailingDisplayCols];
194
+ };
190
195
 
191
196
  export const getDefaultColumnFilterFn = <
192
197
  TData extends Record<string, any> = {},
@@ -250,72 +255,79 @@ export const getCommonCellStyles = ({
250
255
  table: MRT_TableInstance;
251
256
  tableCellProps: TableCellProps;
252
257
  theme: Theme;
253
- }) => ({
254
- backgroundColor:
255
- column.getIsPinned() && column.columnDef.columnDefType !== 'group'
256
- ? alpha(lighten(theme.palette.background.default, 0.04), 0.97)
257
- : 'inherit',
258
- backgroundImage: 'inherit',
259
- boxShadow: getIsLastLeftPinnedColumn(table, column)
260
- ? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
261
- : getIsFirstRightPinnedColumn(column)
262
- ? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
263
- : undefined,
264
- display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell',
265
- flex:
266
- table.options.layoutMode === 'grid'
267
- ? `var(--${header ? 'header' : 'col'}-${parseCSSVarId(
268
- header?.id ?? column.id,
269
- )}-size) 0 auto`
270
- : undefined,
271
- left:
272
- column.getIsPinned() === 'left'
273
- ? `${column.getStart('left')}px`
274
- : undefined,
275
- ml:
276
- table.options.enableColumnVirtualization &&
277
- column.getIsPinned() === 'left' &&
278
- column.getPinnedIndex() === 0
279
- ? `-${
280
- column.getSize() * (table.getState().columnPinning.left?.length ?? 1)
281
- }px`
282
- : undefined,
283
- mr:
284
- table.options.enableColumnVirtualization &&
285
- column.getIsPinned() === 'right' &&
286
- column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
287
- ? `-${
288
- column.getSize() *
289
- (table.getState().columnPinning.right?.length ?? 1) *
290
- 1.2
291
- }px`
292
- : undefined,
293
- opacity:
294
- table.getState().draggingColumn?.id === column.id ||
295
- table.getState().hoveredColumn?.id === column.id
296
- ? 0.5
297
- : 1,
298
- position:
299
- column.getIsPinned() && column.columnDef.columnDefType !== 'group'
300
- ? 'sticky'
301
- : undefined,
302
- right:
303
- column.getIsPinned() === 'right'
304
- ? `${getTotalRight(table, column)}px`
258
+ }) => {
259
+ const widthStyles = {
260
+ minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(
261
+ header?.id ?? column.id,
262
+ )}-size) * 1px), ${column.columnDef.minSize ?? 30}px)`,
263
+ width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(
264
+ header?.id ?? column.id,
265
+ )}-size) * 1px)`,
266
+ };
267
+ return {
268
+ backgroundColor:
269
+ column.getIsPinned() && column.columnDef.columnDefType !== 'group'
270
+ ? alpha(lighten(theme.palette.background.default, 0.04), 0.97)
271
+ : 'inherit',
272
+ backgroundImage: 'inherit',
273
+ boxShadow: getIsLastLeftPinnedColumn(table, column)
274
+ ? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
275
+ : getIsFirstRightPinnedColumn(column)
276
+ ? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
305
277
  : undefined,
306
- transition: table.options.enableColumnVirtualization
307
- ? 'none'
308
- : `padding 150ms ease-in-out`,
309
- ...(tableCellProps?.sx instanceof Function
310
- ? tableCellProps.sx(theme)
311
- : (tableCellProps?.sx as any)),
312
- minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(
313
- header?.id ?? column.id,
314
- )}-size) * 1px), ${column.columnDef.minSize ?? 30}px)`,
315
- width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(
316
- header?.id ?? column.id,
317
- )}-size) * 1px)`,
318
- });
278
+ display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell',
279
+ flex:
280
+ table.options.layoutMode === 'grid'
281
+ ? `var(--${header ? 'header' : 'col'}-${parseCSSVarId(
282
+ header?.id ?? column.id,
283
+ )}-size) 0 auto`
284
+ : undefined,
285
+ left:
286
+ column.getIsPinned() === 'left'
287
+ ? `${column.getStart('left')}px`
288
+ : undefined,
289
+ ml:
290
+ table.options.enableColumnVirtualization &&
291
+ column.getIsPinned() === 'left' &&
292
+ column.getPinnedIndex() === 0
293
+ ? `-${
294
+ column.getSize() *
295
+ (table.getState().columnPinning.left?.length ?? 1)
296
+ }px`
297
+ : undefined,
298
+ mr:
299
+ table.options.enableColumnVirtualization &&
300
+ column.getIsPinned() === 'right' &&
301
+ column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
302
+ ? `-${
303
+ column.getSize() *
304
+ (table.getState().columnPinning.right?.length ?? 1) *
305
+ 1.2
306
+ }px`
307
+ : undefined,
308
+ opacity:
309
+ table.getState().draggingColumn?.id === column.id ||
310
+ table.getState().hoveredColumn?.id === column.id
311
+ ? 0.5
312
+ : 1,
313
+ position:
314
+ column.getIsPinned() && column.columnDef.columnDefType !== 'group'
315
+ ? 'sticky'
316
+ : undefined,
317
+ right:
318
+ column.getIsPinned() === 'right'
319
+ ? `${getTotalRight(table, column)}px`
320
+ : undefined,
321
+ transition: table.options.enableColumnVirtualization
322
+ ? 'none'
323
+ : `padding 150ms ease-in-out`,
324
+ ...(!table.options.enableColumnResizing && widthStyles), //let devs pass in width styles if column resizing is disabled
325
+ ...(tableCellProps?.sx instanceof Function
326
+ ? tableCellProps.sx(theme)
327
+ : (tableCellProps?.sx as any)),
328
+ ...(table.options.enableColumnResizing && widthStyles), //don't let devs pass in width styles if column resizing is enabled
329
+ };
330
+ };
319
331
 
320
332
  export const MRT_DefaultColumn = {
321
333
  filterVariant: 'text',
@@ -177,7 +177,7 @@ export const MRT_TableHeadCell = ({ header, table }: Props) => {
177
177
  <Box
178
178
  className="Mui-TableHeadCell-Content"
179
179
  sx={{
180
- alignItems: 'flex-start',
180
+ alignItems: 'center',
181
181
  display: 'flex',
182
182
  flexDirection:
183
183
  tableCellProps?.align === 'right' ? 'row-reverse' : 'row',
@@ -213,7 +213,7 @@ export const MRT_TableHeadCell = ({ header, table }: Props) => {
213
213
  <Box
214
214
  className="Mui-TableHeadCell-Content-Wrapper"
215
215
  sx={{
216
- minWidth: '5ch',
216
+ minWidth: `${Math.min(columnDef.header.length, 5)}ch`,
217
217
  overflow: columnDefType === 'data' ? 'hidden' : undefined,
218
218
  textOverflow: 'ellipsis',
219
219
  whiteSpace:
@@ -33,7 +33,7 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
33
33
  cursor: 'col-resize',
34
34
  mr: density === 'compact' ? '-0.75rem' : '-1rem',
35
35
  position: 'absolute',
36
- right: '1px',
36
+ right: '4px',
37
37
  px: '4px',
38
38
  '&:active > hr': {
39
39
  backgroundColor: theme.palette.info.main,
@@ -5,7 +5,6 @@ import ListItemIcon from '@mui/material/ListItemIcon';
5
5
  import Menu from '@mui/material/Menu';
6
6
  import MenuItem from '@mui/material/MenuItem';
7
7
  import { MRT_FilterOptionMenu } from './MRT_FilterOptionMenu';
8
- import { MRT_ShowHideColumnsMenu } from './MRT_ShowHideColumnsMenu';
9
8
  import type { MRT_Header, MRT_TableInstance } from '..';
10
9
 
11
10
  export const commonMenuItemStyles = {
@@ -67,12 +66,11 @@ export const MRT_ColumnActionMenu = ({
67
66
  } = table;
68
67
  const { column } = header;
69
68
  const { columnDef } = column;
70
- const { columnSizing, columnVisibility, density } = getState();
69
+ const { columnSizing, columnVisibility, density, showColumnFilters } =
70
+ getState();
71
71
 
72
72
  const [filterMenuAnchorEl, setFilterMenuAnchorEl] =
73
73
  useState<null | HTMLElement>(null);
74
- const [showHideColumnsMenuAnchorEl, setShowHideColumnsMenuAnchorEl] =
75
- useState<null | HTMLElement>(null);
76
74
 
77
75
  const handleClearSort = () => {
78
76
  column.clearSorting();
@@ -132,13 +130,6 @@ export const MRT_ColumnActionMenu = ({
132
130
  setFilterMenuAnchorEl(event.currentTarget);
133
131
  };
134
132
 
135
- const handleOpenShowHideColumnsMenu = (
136
- event: React.MouseEvent<HTMLElement>,
137
- ) => {
138
- event.stopPropagation();
139
- setShowHideColumnsMenuAnchorEl(event.currentTarget);
140
- };
141
-
142
133
  const isSelectFilter = !!columnDef.filterSelectOptions;
143
134
 
144
135
  const allowedColumnFilterOptions =
@@ -238,6 +229,7 @@ export const MRT_ColumnActionMenu = ({
238
229
  </Box>
239
230
  </MenuItem>,
240
231
  <MenuItem
232
+ disabled={showColumnFilters && !enableColumnFilterModes}
241
233
  divider={enableGrouping || enableHiding}
242
234
  key={1}
243
235
  onClick={handleFilterByColumn}
@@ -386,22 +378,7 @@ export const MRT_ColumnActionMenu = ({
386
378
  String(columnDef.header),
387
379
  )}
388
380
  </Box>
389
- <IconButton
390
- onClick={handleOpenShowHideColumnsMenu}
391
- onMouseEnter={handleOpenShowHideColumnsMenu}
392
- size="small"
393
- sx={{ p: 0 }}
394
- >
395
- <ArrowRightIcon />
396
- </IconButton>
397
381
  </MenuItem>,
398
- <MRT_ShowHideColumnsMenu
399
- anchorEl={showHideColumnsMenuAnchorEl}
400
- isSubMenu
401
- key={2}
402
- setAnchorEl={setShowHideColumnsMenuAnchorEl}
403
- table={table}
404
- />,
405
382
  ]}
406
383
  </Menu>
407
384
  );
@@ -18,7 +18,6 @@ export const MRT_ShowHideColumnsMenu = <
18
18
  TData extends Record<string, any> = {},
19
19
  >({
20
20
  anchorEl,
21
- isSubMenu,
22
21
  setAnchorEl,
23
22
  table,
24
23
  }: Props<TData>) => {
@@ -88,12 +87,12 @@ export const MRT_ShowHideColumnsMenu = <
88
87
  <Box
89
88
  sx={{
90
89
  display: 'flex',
91
- justifyContent: isSubMenu ? 'center' : 'space-between',
90
+ justifyContent: 'space-between',
92
91
  p: '0.5rem',
93
92
  pt: 0,
94
93
  }}
95
94
  >
96
- {!isSubMenu && enableHiding && (
95
+ {enableHiding && (
97
96
  <Button
98
97
  disabled={!getIsSomeColumnsVisible()}
99
98
  onClick={hideAllColumns}
@@ -101,7 +100,7 @@ export const MRT_ShowHideColumnsMenu = <
101
100
  {localization.hideAll}
102
101
  </Button>
103
102
  )}
104
- {!isSubMenu && enableColumnOrdering && (
103
+ {enableColumnOrdering && (
105
104
  <Button
106
105
  onClick={() =>
107
106
  table.setColumnOrder(
@@ -112,7 +111,7 @@ export const MRT_ShowHideColumnsMenu = <
112
111
  {localization.resetOrder}
113
112
  </Button>
114
113
  )}
115
- {!isSubMenu && enablePinning && (
114
+ {enablePinning && (
116
115
  <Button
117
116
  disabled={!getIsSomeColumnsPinned()}
118
117
  onClick={() => table.resetColumnPinning(true)}
@@ -135,7 +134,6 @@ export const MRT_ShowHideColumnsMenu = <
135
134
  allColumns={allColumns}
136
135
  column={column}
137
136
  hoveredColumn={hoveredColumn}
138
- isSubMenu={isSubMenu}
139
137
  key={`${index}-${column.id}`}
140
138
  setHoveredColumn={setHoveredColumn}
141
139
  table={table}