material-react-table 3.0.2 → 3.1.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 (36) hide show
  1. package/dist/index.d.ts +22 -73
  2. package/dist/index.esm.js +95 -97
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +95 -97
  5. package/dist/index.js.map +1 -1
  6. package/package.json +31 -32
  7. package/src/components/body/MRT_TableBodyCell.tsx +2 -2
  8. package/src/components/body/MRT_TableBodyCellValue.tsx +1 -1
  9. package/src/components/body/MRT_TableBodyRow.tsx +1 -1
  10. package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +1 -1
  11. package/src/components/body/MRT_TableDetailPanel.tsx +1 -1
  12. package/src/components/buttons/MRT_EditActionButtons.tsx +2 -2
  13. package/src/components/footer/MRT_TableFooter.tsx +1 -1
  14. package/src/components/head/MRT_TableHead.tsx +1 -1
  15. package/src/components/head/MRT_TableHeadCell.tsx +2 -2
  16. package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +8 -10
  17. package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +1 -1
  18. package/src/components/inputs/MRT_EditCellTextField.tsx +5 -3
  19. package/src/components/inputs/MRT_FilterRangeSlider.tsx +12 -5
  20. package/src/components/inputs/MRT_FilterTextField.tsx +89 -67
  21. package/src/components/menus/MRT_ColumnActionMenu.tsx +3 -2
  22. package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +12 -0
  23. package/src/components/table/MRT_TableContainer.tsx +1 -1
  24. package/src/components/table/MRT_TablePaper.tsx +1 -1
  25. package/src/components/toolbar/MRT_BottomToolbar.tsx +1 -1
  26. package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +2 -2
  27. package/src/components/toolbar/MRT_TopToolbar.tsx +1 -1
  28. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -1
  29. package/src/hooks/useMRT_ColumnVirtualizer.ts +1 -1
  30. package/src/hooks/useMRT_Effects.ts +2 -2
  31. package/src/hooks/useMRT_RowVirtualizer.ts +1 -1
  32. package/src/hooks/useMRT_TableInstance.ts +1 -1
  33. package/src/types.ts +15 -67
  34. package/src/utils/cell.utils.ts +2 -2
  35. package/src/utils/column.utils.ts +1 -1
  36. package/src/utils/tanstack.helpers.ts +1 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { MutableRefObject, Dispatch, SetStateAction, ReactNode, RefObject, ChangeEvent, MouseEvent, DragEventHandler } from 'react';
2
+ import { RefObject, Dispatch, SetStateAction, ReactNode, JSX, ChangeEvent, MouseEvent, DragEventHandler } from 'react';
3
3
  import * as _tanstack_react_table from '@tanstack/react-table';
4
4
  import { Row, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowSelectionState, SortingState, Updater, VisibilityState, AccessorFn, DeepKeys, DeepValue, Table, TableState, ColumnDef, Column, Header, HeaderGroup, Cell, AggregationFn, SortingFn, FilterFn, TableOptions, OnChangeFn, Renderable, RowPinningPosition } from '@tanstack/react-table';
5
5
  import { VirtualItem, VirtualizerOptions, Virtualizer } from '@tanstack/react-virtual';
@@ -412,18 +412,18 @@ type MRT_TableInstance<TData extends MRT_RowData> = Omit<Table<TData>, 'getAllCo
412
412
  getTopRows: () => MRT_Row<TData>[];
413
413
  options: MRT_StatefulTableOptions<TData>;
414
414
  refs: {
415
- actionCellRef: MutableRefObject<HTMLTableCellElement | null>;
416
- bottomToolbarRef: MutableRefObject<HTMLDivElement | null>;
417
- editInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
418
- filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
419
- lastSelectedRowId: MutableRefObject<null | string>;
420
- searchInputRef: MutableRefObject<HTMLInputElement | null>;
421
- tableContainerRef: MutableRefObject<HTMLDivElement | null>;
422
- tableFooterRef: MutableRefObject<HTMLTableSectionElement | null>;
423
- tableHeadCellRefs: MutableRefObject<Record<string, HTMLTableCellElement>>;
424
- tableHeadRef: MutableRefObject<HTMLTableSectionElement | null>;
425
- tablePaperRef: MutableRefObject<HTMLDivElement | null>;
426
- topToolbarRef: MutableRefObject<HTMLDivElement | null>;
415
+ actionCellRef: RefObject<HTMLTableCellElement | null>;
416
+ bottomToolbarRef: RefObject<HTMLDivElement | null>;
417
+ editInputRefs: RefObject<Record<string, HTMLInputElement> | null>;
418
+ filterInputRefs: RefObject<Record<string, HTMLInputElement> | null>;
419
+ lastSelectedRowId: RefObject<null | string>;
420
+ searchInputRef: RefObject<HTMLInputElement | null>;
421
+ tableContainerRef: RefObject<HTMLDivElement | null>;
422
+ tableFooterRef: RefObject<HTMLTableSectionElement | null>;
423
+ tableHeadCellRefs: RefObject<Record<string, HTMLTableCellElement> | null>;
424
+ tableHeadRef: RefObject<HTMLTableSectionElement | null>;
425
+ tablePaperRef: RefObject<HTMLDivElement | null>;
426
+ topToolbarRef: RefObject<HTMLDivElement | null>;
427
427
  };
428
428
  setActionCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
429
429
  setColumnFilterFns: Dispatch<SetStateAction<MRT_ColumnFilterFnsState>>;
@@ -504,7 +504,7 @@ interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> extends Omi
504
504
  column: MRT_Column<TData, TValue>;
505
505
  renderedCellValue: ReactNode;
506
506
  row: MRT_Row<TData>;
507
- rowRef?: RefObject<HTMLTableRowElement>;
507
+ rowRef?: RefObject<HTMLTableRowElement | null>;
508
508
  staticColumnIndex?: number;
509
509
  staticRowIndex?: number;
510
510
  table: MRT_TableInstance<TData>;
@@ -757,7 +757,7 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
757
757
  * @link https://www.material-react-table.com/docs/api/column-options
758
758
  */
759
759
  columns: MRT_ColumnDef<TData, any>[];
760
- columnVirtualizerInstanceRef?: MutableRefObject<MRT_ColumnVirtualizer | null>;
760
+ columnVirtualizerInstanceRef?: RefObject<MRT_ColumnVirtualizer | null>;
761
761
  columnVirtualizerOptions?: ((props: {
762
762
  table: MRT_TableInstance<TData>;
763
763
  }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>) | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>;
@@ -849,23 +849,14 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
849
849
  }) | (CircularProgressProps & {
850
850
  Component?: ReactNode;
851
851
  });
852
- /**
853
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
854
- */
855
852
  muiColumnActionsButtonProps?: ((props: {
856
853
  column: MRT_Column<TData>;
857
854
  table: MRT_TableInstance<TData>;
858
855
  }) => IconButtonProps) | IconButtonProps;
859
- /**
860
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
861
- */
862
856
  muiColumnDragHandleProps?: ((props: {
863
857
  column: MRT_Column<TData>;
864
858
  table: MRT_TableInstance<TData>;
865
859
  }) => IconButtonProps) | IconButtonProps;
866
- /**
867
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
868
- */
869
860
  muiCopyButtonProps?: ((props: {
870
861
  cell: MRT_Cell<TData>;
871
862
  column: MRT_Column<TData>;
@@ -884,9 +875,6 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
884
875
  row: MRT_Row<TData>;
885
876
  table: MRT_TableInstance<TData>;
886
877
  }) => DialogProps) | DialogProps;
887
- /**
888
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
889
- */
890
878
  muiEditTextFieldProps?: ((props: {
891
879
  cell: MRT_Cell<TData>;
892
880
  column: MRT_Column<TData>;
@@ -901,54 +889,33 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
901
889
  staticRowIndex?: number;
902
890
  table: MRT_TableInstance<TData>;
903
891
  }) => IconButtonProps) | IconButtonProps;
904
- /**
905
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
906
- */
907
892
  muiFilterAutocompleteProps?: ((props: {
908
893
  column: MRT_Column<TData>;
909
894
  table: MRT_TableInstance<TData>;
910
895
  }) => AutocompleteProps<any, any, any, any>) | AutocompleteProps<any, any, any, any>;
911
- /**
912
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
913
- */
914
896
  muiFilterCheckboxProps?: ((props: {
915
897
  column: MRT_Column<TData>;
916
898
  table: MRT_TableInstance<TData>;
917
899
  }) => CheckboxProps) | CheckboxProps;
918
- /**
919
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
920
- */
921
900
  muiFilterDatePickerProps?: ((props: {
922
901
  column: MRT_Column<TData>;
923
902
  rangeFilterIndex?: number;
924
903
  table: MRT_TableInstance<TData>;
925
904
  }) => DatePickerProps<never>) | DatePickerProps<never>;
926
- /**
927
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
928
- */
929
905
  muiFilterDateTimePickerProps?: ((props: {
930
906
  column: MRT_Column<TData>;
931
907
  rangeFilterIndex?: number;
932
908
  table: MRT_TableInstance<TData>;
933
909
  }) => DateTimePickerProps<never>) | DateTimePickerProps<never>;
934
- /**
935
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
936
- */
937
910
  muiFilterSliderProps?: ((props: {
938
911
  column: MRT_Column<TData>;
939
912
  table: MRT_TableInstance<TData>;
940
913
  }) => SliderProps) | SliderProps;
941
- /**
942
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
943
- */
944
914
  muiFilterTextFieldProps?: ((props: {
945
915
  column: MRT_Column<TData>;
946
916
  rangeFilterIndex?: number;
947
917
  table: MRT_TableInstance<TData>;
948
918
  }) => TextFieldProps) | TextFieldProps;
949
- /**
950
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
951
- */
952
919
  muiFilterTimePickerProps?: ((props: {
953
920
  column: MRT_Column<TData>;
954
921
  rangeFilterIndex?: number;
@@ -998,9 +965,6 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
998
965
  row: MRT_Row<TData>;
999
966
  table: MRT_TableInstance<TData>;
1000
967
  }) => SkeletonProps) | SkeletonProps;
1001
- /**
1002
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
1003
- */
1004
968
  muiTableBodyCellProps?: ((props: {
1005
969
  cell: MRT_Cell<TData>;
1006
970
  column: MRT_Column<TData>;
@@ -1019,9 +983,6 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
1019
983
  muiTableContainerProps?: ((props: {
1020
984
  table: MRT_TableInstance<TData>;
1021
985
  }) => TableContainerProps) | TableContainerProps;
1022
- /**
1023
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
1024
- */
1025
986
  muiTableFooterCellProps?: ((props: {
1026
987
  column: MRT_Column<TData>;
1027
988
  table: MRT_TableInstance<TData>;
@@ -1033,9 +994,6 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
1033
994
  footerGroup: MRT_HeaderGroup<TData>;
1034
995
  table: MRT_TableInstance<TData>;
1035
996
  }) => TableRowProps) | TableRowProps;
1036
- /**
1037
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
1038
- */
1039
997
  muiTableHeadCellProps?: ((props: {
1040
998
  column: MRT_Column<TData>;
1041
999
  table: MRT_TableInstance<TData>;
@@ -1117,9 +1075,6 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
1117
1075
  renderCaption?: ((props: {
1118
1076
  table: MRT_TableInstance<TData>;
1119
1077
  }) => ReactNode) | ReactNode;
1120
- /**
1121
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
1122
- */
1123
1078
  renderCellActionMenuItems?: (props: {
1124
1079
  cell: MRT_Cell<TData>;
1125
1080
  closeMenu: () => void;
@@ -1130,18 +1085,12 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
1130
1085
  staticRowIndex?: number;
1131
1086
  table: MRT_TableInstance<TData>;
1132
1087
  }) => ReactNode[];
1133
- /**
1134
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
1135
- */
1136
1088
  renderColumnActionsMenuItems?: (props: {
1137
1089
  closeMenu: () => void;
1138
1090
  column: MRT_Column<TData>;
1139
1091
  internalColumnMenuItems: ReactNode[];
1140
1092
  table: MRT_TableInstance<TData>;
1141
1093
  }) => ReactNode[];
1142
- /**
1143
- * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
1144
- */
1145
1094
  renderColumnFilterModeMenuItems?: (props: {
1146
1095
  column: MRT_Column<TData>;
1147
1096
  internalFilterOptions: MRT_InternalFilterOption[];
@@ -1198,7 +1147,7 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
1198
1147
  }) => ReactNode;
1199
1148
  rowNumberDisplayMode?: 'original' | 'static';
1200
1149
  rowPinningDisplayMode?: 'bottom' | 'select-bottom' | 'select-sticky' | 'select-top' | 'sticky' | 'top' | 'top-and-bottom';
1201
- rowVirtualizerInstanceRef?: MutableRefObject<MRT_RowVirtualizer | null>;
1150
+ rowVirtualizerInstanceRef?: RefObject<MRT_RowVirtualizer | null>;
1202
1151
  rowVirtualizerOptions?: ((props: {
1203
1152
  table: MRT_TableInstance<TData>;
1204
1153
  }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>) | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>;
@@ -1302,7 +1251,7 @@ declare function defaultDisplayColumnProps<TData extends MRT_RowData>({ header,
1302
1251
  column: MRT_Column<TData, unknown>;
1303
1252
  renderedCellValue: react.ReactNode;
1304
1253
  row: MRT_Row<TData>;
1305
- rowRef?: react.RefObject<HTMLTableRowElement>;
1254
+ rowRef?: react.RefObject<HTMLTableRowElement | null>;
1306
1255
  staticColumnIndex?: number;
1307
1256
  staticRowIndex?: number;
1308
1257
  table: MRT_TableInstance<TData>;
@@ -1534,7 +1483,7 @@ declare const Memo_MRT_TableBody: typeof MRT_TableBody;
1534
1483
  interface MRT_TableBodyCellProps<TData extends MRT_RowData> extends TableCellProps {
1535
1484
  cell: MRT_Cell<TData>;
1536
1485
  numRows?: number;
1537
- rowRef: RefObject<HTMLTableRowElement>;
1486
+ rowRef: RefObject<HTMLTableRowElement | null>;
1538
1487
  staticColumnIndex?: number;
1539
1488
  staticRowIndex: number;
1540
1489
  table: MRT_TableInstance<TData>;
@@ -1544,7 +1493,7 @@ declare const Memo_MRT_TableBodyCell: typeof MRT_TableBodyCell;
1544
1493
 
1545
1494
  interface MRT_TableBodyCellValueProps<TData extends MRT_RowData> {
1546
1495
  cell: MRT_Cell<TData>;
1547
- rowRef?: RefObject<HTMLTableRowElement>;
1496
+ rowRef?: RefObject<HTMLTableRowElement | null>;
1548
1497
  staticColumnIndex?: number;
1549
1498
  staticRowIndex?: number;
1550
1499
  table: MRT_TableInstance<TData>;
@@ -1566,7 +1515,7 @@ declare const Memo_MRT_TableBodyRow: typeof MRT_TableBodyRow;
1566
1515
 
1567
1516
  interface MRT_TableBodyRowGrabHandleProps<TData extends MRT_RowData> extends IconButtonProps {
1568
1517
  row: MRT_Row<TData>;
1569
- rowRef: RefObject<HTMLTableRowElement>;
1518
+ rowRef: RefObject<HTMLTableRowElement | null>;
1570
1519
  table: MRT_TableInstance<TData>;
1571
1520
  }
1572
1521
  declare const MRT_TableBodyRowGrabHandle: <TData extends MRT_RowData>({ row, rowRef, table, ...rest }: MRT_TableBodyRowGrabHandleProps<TData>) => react_jsx_runtime.JSX.Element;
@@ -1578,7 +1527,7 @@ interface MRT_TableBodyRowPinButtonProps<TData extends MRT_RowData> extends Icon
1578
1527
  declare const MRT_TableBodyRowPinButton: <TData extends MRT_RowData>({ row, table, ...rest }: MRT_TableBodyRowPinButtonProps<TData>) => react_jsx_runtime.JSX.Element | null;
1579
1528
 
1580
1529
  interface MRT_TableDetailPanelProps<TData extends MRT_RowData> extends TableCellProps {
1581
- parentRowRef: RefObject<HTMLTableRowElement>;
1530
+ parentRowRef: RefObject<HTMLTableRowElement | null>;
1582
1531
  row: MRT_Row<TData>;
1583
1532
  rowVirtualizer?: MRT_RowVirtualizer;
1584
1533
  staticRowIndex: number;
@@ -1722,7 +1671,7 @@ declare const MRT_TableHeadCellFilterLabel: <TData extends MRT_RowData = {}>({ h
1722
1671
  interface MRT_TableHeadCellGrabHandleProps<TData extends MRT_RowData> extends IconButtonProps {
1723
1672
  column: MRT_Column<TData>;
1724
1673
  table: MRT_TableInstance<TData>;
1725
- tableHeadCellRef: RefObject<HTMLTableCellElement>;
1674
+ tableHeadCellRef: RefObject<HTMLTableCellElement | null>;
1726
1675
  }
1727
1676
  declare const MRT_TableHeadCellGrabHandle: <TData extends MRT_RowData>({ column, table, tableHeadCellRef, ...rest }: MRT_TableHeadCellGrabHandleProps<TData>) => react_jsx_runtime.JSX.Element;
1728
1677