material-react-table 1.14.0 → 1.15.1

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.
@@ -120,16 +120,18 @@ export const MRT_TableBodyRow = ({
120
120
  ? (cellOrVirtualCell as VirtualItem)
121
121
  : undefined,
122
122
  };
123
- return memoMode === 'cells' &&
123
+ return cell ? (
124
+ memoMode === 'cells' &&
124
125
  cell.column.columnDef.columnDefType === 'data' &&
125
126
  !draggingColumn &&
126
127
  !draggingRow &&
127
128
  editingCell?.id !== cell.id &&
128
129
  editingRow?.id !== row.id ? (
129
- <Memo_MRT_TableBodyCell key={cell.id} {...props} />
130
- ) : (
131
- <MRT_TableBodyCell key={cell.id} {...props} />
132
- );
130
+ <Memo_MRT_TableBodyCell key={cell.id} {...props} />
131
+ ) : (
132
+ <MRT_TableBodyCell key={cell.id} {...props} />
133
+ )
134
+ ) : null;
133
135
  })}
134
136
  {virtualPaddingRight ? (
135
137
  <td style={{ display: 'flex', width: virtualPaddingRight }} />
@@ -35,9 +35,8 @@ export const MRT_ExpandAllButton = ({ table }: Props) => {
35
35
  enterDelay={1000}
36
36
  enterNextDelay={1000}
37
37
  title={
38
- iconButtonProps?.title ?? isAllRowsExpanded
39
- ? localization.collapseAll
40
- : localization.expandAll
38
+ iconButtonProps?.title ??
39
+ (isAllRowsExpanded ? localization.collapseAll : localization.expandAll)
41
40
  }
42
41
  >
43
42
  <span>
@@ -44,9 +44,8 @@ export const MRT_ExpandButton = <TData extends Record<string, any> = {}>({
44
44
  enterDelay={1000}
45
45
  enterNextDelay={1000}
46
46
  title={
47
- iconButtonProps?.title ?? isExpanded
48
- ? localization.collapse
49
- : localization.expand
47
+ iconButtonProps?.title ??
48
+ (isExpanded ? localization.collapse : localization.expand)
50
49
  }
51
50
  >
52
51
  <span>
@@ -31,7 +31,7 @@ export const MRT_FullScreenToggleButton = <
31
31
  return (
32
32
  <Tooltip arrow title={rest?.title ?? localization.toggleFullScreen}>
33
33
  <IconButton
34
- aria-label={localization.showHideFilters}
34
+ aria-label={localization.toggleFullScreen}
35
35
  onClick={handleToggleFullScreen}
36
36
  {...rest}
37
37
  title={undefined}
@@ -63,9 +63,9 @@ export const MRT_TableFooterRow = ({
63
63
  ? footerGroup.headers[footerOrVirtualFooter.index]
64
64
  : (footerOrVirtualFooter as MRT_Header);
65
65
 
66
- return (
66
+ return footer ? (
67
67
  <MRT_TableFooterCell footer={footer} key={footer.id} table={table} />
68
- );
68
+ ) : null;
69
69
  })}
70
70
  {virtualPaddingRight ? (
71
71
  <th style={{ display: 'flex', width: virtualPaddingRight }} />
@@ -25,12 +25,15 @@ export const MRT_TableHeadCellSortLabel = ({
25
25
  const { column } = header;
26
26
  const { columnDef } = column;
27
27
  const { sorting } = getState();
28
+ const sorted = column.getIsSorted();
28
29
 
29
- const sortTooltip = column.getIsSorted()
30
- ? column.getIsSorted() === 'desc'
30
+ const sortTooltip = sorted
31
+ ? sorted === 'desc'
31
32
  ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
32
33
  : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
33
- : localization.unsorted;
34
+ : column.getNextSortingOrder() === 'desc'
35
+ ? localization.sortByColumnDesc.replace('{column}', columnDef.header)
36
+ : localization.sortByColumnAsc.replace('{column}', columnDef.header);
34
37
 
35
38
  return (
36
39
  <Tooltip arrow placement="top" title={sortTooltip}>
@@ -40,12 +43,8 @@ export const MRT_TableHeadCellSortLabel = ({
40
43
  >
41
44
  <TableSortLabel
42
45
  aria-label={sortTooltip}
43
- active={!!column.getIsSorted()}
44
- direction={
45
- column.getIsSorted()
46
- ? (column.getIsSorted() as 'asc' | 'desc')
47
- : undefined
48
- }
46
+ active={!!sorted}
47
+ direction={sorted ? (sorted as 'asc' | 'desc') : undefined}
49
48
  sx={{
50
49
  flex: '0 0',
51
50
  width: '2.4ch',
@@ -53,9 +53,9 @@ export const MRT_TableHeadRow = ({
53
53
  ? headerGroup.headers[headerOrVirtualHeader.index]
54
54
  : (headerOrVirtualHeader as MRT_Header);
55
55
 
56
- return (
56
+ return header ? (
57
57
  <MRT_TableHeadCell header={header} key={header.id} table={table} />
58
- );
58
+ ) : null;
59
59
  })}
60
60
  {virtualPaddingRight ? (
61
61
  <th style={{ display: 'flex', width: virtualPaddingRight }} />
package/src/sortingFns.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { compareItems, type RankingInfo } from '@tanstack/match-sorter-utils';
2
2
  import { type Row, sortingFns } from '@tanstack/react-table';
3
- import { type MRT_Row } from './types';
4
3
 
5
4
  const fuzzy = <TData extends Record<string, any> = {}>(
6
5
  rowA: Row<TData>,
@@ -25,9 +24,6 @@ export const MRT_SortingFns = {
25
24
  fuzzy,
26
25
  };
27
26
 
28
- export const rankGlobalFuzzy = <TData extends Record<string, any> = {}>(
29
- rowA: MRT_Row<TData>,
30
- rowB: MRT_Row<TData>,
31
- ) =>
27
+ export const rankGlobalFuzzy: any = (rowA: any, rowB: any) =>
32
28
  Math.max(...Object.values(rowB.columnFiltersMeta).map((v: any) => v.rank)) -
33
29
  Math.max(...Object.values(rowA.columnFiltersMeta).map((v: any) => v.rank));