material-react-table 2.3.0 → 2.4.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.
@@ -5,6 +5,7 @@ import MenuItem from '@mui/material/MenuItem';
5
5
  import Pagination, { type PaginationProps } from '@mui/material/Pagination';
6
6
  import PaginationItem from '@mui/material/PaginationItem';
7
7
  import Select from '@mui/material/Select';
8
+ import Tooltip from '@mui/material/Tooltip';
8
9
  import Typography from '@mui/material/Typography';
9
10
  import { parseFromValuesOrFunc } from '../column.utils';
10
11
  import { type MRT_RowData, type MRT_TableInstance } from '../types';
@@ -164,40 +165,48 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
164
165
  } ${totalRowCount.toLocaleString()}`}</Typography>
165
166
  <Box gap="xs">
166
167
  {showFirstButton && (
168
+ <Tooltip title={localization.goToFirstPage}>
169
+ <IconButton
170
+ aria-label={localization.goToFirstPage}
171
+ disabled={pageIndex <= 0 || disabled}
172
+ onClick={() => setPageIndex(0)}
173
+ size="small"
174
+ >
175
+ <FirstPageIcon />
176
+ </IconButton>
177
+ </Tooltip>
178
+ )}
179
+ <Tooltip title={localization.goToPreviousPage}>
167
180
  <IconButton
168
- aria-label={localization.goToFirstPage}
181
+ aria-label={localization.goToPreviousPage}
169
182
  disabled={pageIndex <= 0 || disabled}
170
- onClick={() => setPageIndex(0)}
183
+ onClick={() => setPageIndex(pageIndex - 1)}
171
184
  size="small"
172
185
  >
173
- <FirstPageIcon />
186
+ <ChevronLeftIcon />
174
187
  </IconButton>
175
- )}
176
- <IconButton
177
- aria-label={localization.goToPreviousPage}
178
- disabled={pageIndex <= 0 || disabled}
179
- onClick={() => setPageIndex(pageIndex - 1)}
180
- size="small"
181
- >
182
- <ChevronLeftIcon />
183
- </IconButton>
184
- <IconButton
185
- aria-label={localization.goToNextPage}
186
- disabled={lastRowIndex >= totalRowCount || disabled}
187
- onClick={() => setPageIndex(pageIndex + 1)}
188
- size="small"
189
- >
190
- <ChevronRightIcon />
191
- </IconButton>
192
- {showLastButton && (
188
+ </Tooltip>
189
+ <Tooltip title={localization.goToNextPage}>
193
190
  <IconButton
194
- aria-label={localization.goToLastPage}
191
+ aria-label={localization.goToNextPage}
195
192
  disabled={lastRowIndex >= totalRowCount || disabled}
196
- onClick={() => setPageIndex(numberOfPages - 1)}
193
+ onClick={() => setPageIndex(pageIndex + 1)}
197
194
  size="small"
198
195
  >
199
- <LastPageIcon />
196
+ <ChevronRightIcon />
200
197
  </IconButton>
198
+ </Tooltip>
199
+ {showLastButton && (
200
+ <Tooltip title={localization.goToLastPage}>
201
+ <IconButton
202
+ aria-label={localization.goToLastPage}
203
+ disabled={lastRowIndex >= totalRowCount || disabled}
204
+ onClick={() => setPageIndex(numberOfPages - 1)}
205
+ size="small"
206
+ >
207
+ <LastPageIcon />
208
+ </IconButton>
209
+ </Tooltip>
201
210
  )}
202
211
  </Box>
203
212
  </>
package/src/types.ts CHANGED
@@ -66,7 +66,11 @@ import { type TableHeadProps } from '@mui/material/TableHead';
66
66
  import { type TableRowProps } from '@mui/material/TableRow';
67
67
  import { type TextFieldProps } from '@mui/material/TextField';
68
68
  import { type Theme } from '@mui/material/styles';
69
- import { type DatePickerProps } from '@mui/x-date-pickers';
69
+ import {
70
+ type DatePickerProps,
71
+ type DateTimePickerProps,
72
+ type TimePickerProps,
73
+ } from '@mui/x-date-pickers';
70
74
  import { type MRT_AggregationFns } from './aggregationFns';
71
75
  import { type MRT_FilterFns } from './filterFns';
72
76
  import { type MRT_Icons } from './icons';
@@ -107,6 +111,19 @@ export type {
107
111
  VisibilityState as MRT_VisibilityState,
108
112
  };
109
113
 
114
+ export type MRT_ColumnVirtualizer<
115
+ TScrollElement extends Element | Window = HTMLDivElement,
116
+ TItemElement extends Element = HTMLTableCellElement,
117
+ > = Virtualizer<TScrollElement, TItemElement> & {
118
+ virtualPaddingLeft?: number;
119
+ virtualPaddingRight?: number;
120
+ };
121
+
122
+ export type MRT_RowVirtualizer<
123
+ TScrollElement extends Element | Window = HTMLDivElement,
124
+ TItemElement extends Element = HTMLTableRowElement,
125
+ > = Virtualizer<TScrollElement, TItemElement>;
126
+
110
127
  export type MRT_ColumnHelper<TData extends MRT_RowData> = {
111
128
  accessor: <
112
129
  TAccessor extends AccessorFn<TData> | DeepKeys<TData>,
@@ -463,11 +480,15 @@ export type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<
463
480
  | 'checkbox'
464
481
  | 'date'
465
482
  | 'date-range'
483
+ | 'datetime'
484
+ | 'datetime-range'
466
485
  | 'multi-select'
467
486
  | 'range'
468
487
  | 'range-slider'
469
488
  | 'select'
470
- | 'text';
489
+ | 'text'
490
+ | 'time'
491
+ | 'time-range';
471
492
  /**
472
493
  * footer must be a string. If you want custom JSX to render the footer, you can also specify a `Footer` option. (Capital F)
473
494
  */
@@ -533,6 +554,13 @@ export type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<
533
554
  table: MRT_TableInstance<TData>;
534
555
  }) => DatePickerProps<any>)
535
556
  | DatePickerProps<any>;
557
+ muiFilterDateTimePickerProps?:
558
+ | ((props: {
559
+ column: MRT_Column<TData>;
560
+ rangeFilterIndex?: number;
561
+ table: MRT_TableInstance<TData>;
562
+ }) => DateTimePickerProps<any>)
563
+ | DateTimePickerProps<any>;
536
564
  muiFilterSliderProps?:
537
565
  | ((props: {
538
566
  column: MRT_Column<TData>;
@@ -546,6 +574,13 @@ export type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<
546
574
  table: MRT_TableInstance<TData>;
547
575
  }) => TextFieldProps)
548
576
  | TextFieldProps;
577
+ muiFilterTimePickerProps?:
578
+ | ((props: {
579
+ column: MRT_Column<TData>;
580
+ rangeFilterIndex?: number;
581
+ table: MRT_TableInstance<TData>;
582
+ }) => TimePickerProps<any>)
583
+ | TimePickerProps<any>;
549
584
  muiTableBodyCellProps?:
550
585
  | ((props: {
551
586
  cell: MRT_Cell<TData, TValue>;
@@ -708,10 +743,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
708
743
  columnFilterModeOptions?: Array<
709
744
  LiteralUnion<string & MRT_FilterOption>
710
745
  > | null;
711
- columnVirtualizerInstanceRef?: MutableRefObject<Virtualizer<
712
- HTMLDivElement,
713
- HTMLTableCellElement
714
- > | null>;
746
+ columnVirtualizerInstanceRef?: MutableRefObject<MRT_ColumnVirtualizer | null>;
715
747
  columnVirtualizerOptions?:
716
748
  | ((props: {
717
749
  table: MRT_TableInstance<TData>;
@@ -886,6 +918,13 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
886
918
  table: MRT_TableInstance<TData>;
887
919
  }) => DatePickerProps<any>)
888
920
  | DatePickerProps<any>;
921
+ muiFilterDateTimePickerProps?:
922
+ | ((props: {
923
+ column: MRT_Column<TData>;
924
+ rangeFilterIndex?: number;
925
+ table: MRT_TableInstance<TData>;
926
+ }) => DateTimePickerProps<any>)
927
+ | DateTimePickerProps<any>;
889
928
  muiFilterSliderProps?:
890
929
  | ((props: {
891
930
  column: MRT_Column<TData>;
@@ -899,6 +938,13 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
899
938
  table: MRT_TableInstance<TData>;
900
939
  }) => TextFieldProps)
901
940
  | TextFieldProps;
941
+ muiFilterTimePickerProps?:
942
+ | ((props: {
943
+ column: MRT_Column<TData>;
944
+ rangeFilterIndex?: number;
945
+ table: MRT_TableInstance<TData>;
946
+ }) => TimePickerProps<any>)
947
+ | TimePickerProps<any>;
902
948
  muiLinearProgressProps?:
903
949
  | ((props: {
904
950
  isTopToolbar: boolean;
@@ -1129,10 +1175,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
1129
1175
  | 'sticky'
1130
1176
  | 'top'
1131
1177
  | 'top-and-bottom';
1132
- rowVirtualizerInstanceRef?: MutableRefObject<Virtualizer<
1133
- HTMLDivElement,
1134
- HTMLTableRowElement
1135
- > | null>;
1178
+ rowVirtualizerInstanceRef?: MutableRefObject<MRT_RowVirtualizer | null>;
1136
1179
  rowVirtualizerOptions?:
1137
1180
  | ((props: {
1138
1181
  table: MRT_TableInstance<TData>;