material-react-table 0.36.0 → 0.37.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 (33) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/MaterialReactTable.d.ts +33 -15
  3. package/dist/cjs/body/MRT_EditRowModal.d.ts +8 -0
  4. package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +5 -5
  5. package/dist/cjs/index.js +181 -108
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +5 -5
  8. package/dist/esm/MaterialReactTable.d.ts +33 -15
  9. package/dist/esm/body/MRT_EditRowModal.d.ts +8 -0
  10. package/dist/esm/buttons/MRT_EditActionButtons.d.ts +5 -5
  11. package/dist/esm/inputs/MRT_EditCellTextField.d.ts +5 -5
  12. package/dist/esm/material-react-table.esm.js +182 -109
  13. package/dist/esm/material-react-table.esm.js.map +1 -1
  14. package/dist/index.d.ts +33 -15
  15. package/package.json +1 -1
  16. package/src/MaterialReactTable.tsx +48 -12
  17. package/src/body/MRT_EditRowModal.tsx +59 -0
  18. package/src/body/MRT_TableBodyCell.tsx +22 -18
  19. package/src/body/MRT_TableBodyRow.tsx +1 -1
  20. package/src/body/MRT_TableBodyRowGrabHandle.tsx +3 -2
  21. package/src/buttons/MRT_CopyButton.tsx +2 -2
  22. package/src/buttons/MRT_EditActionButtons.tsx +49 -25
  23. package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -16
  24. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +2 -1
  25. package/src/column.utils.ts +6 -5
  26. package/src/inputs/MRT_EditCellTextField.tsx +33 -19
  27. package/src/inputs/MRT_FilterTextField.tsx +9 -6
  28. package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -2
  29. package/src/menus/MRT_ColumnActionMenu.tsx +2 -12
  30. package/src/table/MRT_TableContainer.tsx +10 -10
  31. package/src/table/MRT_TableRoot.tsx +26 -18
  32. package/src/toolbar/MRT_BottomToolbar.tsx +8 -2
  33. package/src/toolbar/MRT_TopToolbar.tsx +8 -2
@@ -1,8 +1,8 @@
1
- import { FC } from 'react';
2
1
  import type { MRT_Cell, MRT_TableInstance } from '..';
3
- interface Props {
4
- cell: MRT_Cell;
5
- table: MRT_TableInstance;
2
+ interface Props<TData extends Record<string, any> = {}> {
3
+ cell: MRT_Cell<TData>;
4
+ table: MRT_TableInstance<TData>;
5
+ showLabel?: boolean;
6
6
  }
7
- export declare const MRT_EditCellTextField: FC<Props>;
7
+ export declare const MRT_EditCellTextField: <TData extends Record<string, any> = {}>({ cell, showLabel, table, }: Props<TData>) => JSX.Element;
8
8
  export {};
@@ -1,4 +1,4 @@
1
- import { Dispatch, DragEvent, ReactNode, SetStateAction } from 'react';
1
+ import { Dispatch, DragEvent, MutableRefObject, ReactNode, SetStateAction } from 'react';
2
2
  import type { AlertProps, ButtonProps, CheckboxProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
3
3
  import type { Cell, Column, ColumnDef, DeepKeys, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
4
4
  import type { Options as VirtualizerOptions } from 'react-virtual';
@@ -32,9 +32,16 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
32
32
  getState: () => MRT_TableState<TData>;
33
33
  options: MaterialReactTableProps<TData> & {
34
34
  icons: MRT_Icons;
35
- tableId: string;
36
35
  localization: MRT_Localization;
37
36
  };
37
+ refs: {
38
+ bottomToolbarRef: MutableRefObject<HTMLDivElement>;
39
+ editInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
40
+ filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
41
+ searchInputRef: MutableRefObject<HTMLInputElement>;
42
+ tableContainerRef: MutableRefObject<HTMLDivElement>;
43
+ topToolbarRef: MutableRefObject<HTMLDivElement>;
44
+ };
38
45
  setColumnFilterFns: Dispatch<SetStateAction<{
39
46
  [key: string]: MRT_FilterOption;
40
47
  }>>;
@@ -78,19 +85,22 @@ export declare type MRT_TableState<TData extends Record<string, any> = {}> = Tab
78
85
  showSkeletons: boolean;
79
86
  };
80
87
  export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<ColumnDef<TData, unknown>, 'aggregatedCell' | 'cell' | 'columns' | 'filterFn' | 'footer' | 'header' | 'id' | 'sortingFn'> & {
81
- AggregatedCell?: ({ cell, column, table, }: {
88
+ AggregatedCell?: ({ cell, column, row, table, }: {
82
89
  cell: MRT_Cell<TData>;
83
90
  column: MRT_Column<TData>;
91
+ row: MRT_Row<TData>;
84
92
  table: MRT_TableInstance<TData>;
85
93
  }) => ReactNode;
86
- Cell?: ({ cell, column, table, }: {
94
+ Cell?: ({ cell, column, row, table, }: {
87
95
  cell: MRT_Cell<TData>;
88
96
  column: MRT_Column<TData>;
97
+ row: MRT_Row<TData>;
89
98
  table: MRT_TableInstance<TData>;
90
99
  }) => ReactNode;
91
- Edit?: ({ cell, column, table, }: {
100
+ Edit?: ({ cell, column, row, table, }: {
92
101
  cell: MRT_Cell<TData>;
93
102
  column: MRT_Column<TData>;
103
+ row: MRT_Row<TData>;
94
104
  table: MRT_TableInstance<TData>;
95
105
  }) => ReactNode;
96
106
  Filter?: ({ column, header, table, }: {
@@ -169,8 +179,10 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
169
179
  table: MRT_TableInstance<TData>;
170
180
  cell: MRT_Cell<TData>;
171
181
  }) => ButtonProps);
172
- muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, table, }: {
182
+ muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, column, row, table, }: {
173
183
  cell: MRT_Cell<TData>;
184
+ column: MRT_Column<TData>;
185
+ row: MRT_Row<TData>;
174
186
  table: MRT_TableInstance<TData>;
175
187
  }) => TextFieldProps);
176
188
  muiTableBodyCellProps?: TableCellProps | (({ cell, table, }: {
@@ -231,7 +243,7 @@ export declare type MRT_SortingOption = LiteralUnion<string & keyof typeof MRT_S
231
243
  export declare type MRT_SortingFn<TData extends Record<string, any> = {}> = SortingFn<TData> | MRT_SortingOption;
232
244
  export declare type MRT_FilterOption = LiteralUnion<string & keyof typeof MRT_FilterFns>;
233
245
  export declare type MRT_FilterFn<TData extends Record<string, any> = {}> = FilterFn<TData> | MRT_FilterOption;
234
- export declare type MRT_DisplayColumnIds = 'mrt-row-drag' | 'mrt-row-actions' | 'mrt-row-expand' | 'mrt-row-select' | 'mrt-row-numbers';
246
+ export declare type MRT_DisplayColumnIds = 'mrt-row-actions' | 'mrt-row-drag' | 'mrt-row-expand' | 'mrt-row-numbers' | 'mrt-row-select';
235
247
  /**
236
248
  * `columns` and `data` props are the only required props, but there are over 150 other optional props.
237
249
  *
@@ -249,7 +261,7 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
249
261
  displayColumnDefOptions?: Partial<{
250
262
  [key in MRT_DisplayColumnIds]: Partial<MRT_ColumnDef>;
251
263
  }>;
252
- editingMode?: 'table' | 'row' | 'cell';
264
+ editingMode?: 'table' | 'modal' | 'row' | 'cell';
253
265
  enableBottomToolbar?: boolean;
254
266
  enableClickToCopy?: boolean;
255
267
  enableColumnActions?: boolean;
@@ -301,17 +313,23 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
301
313
  table: MRT_TableInstance<TData>;
302
314
  row: MRT_Row<TData>;
303
315
  }) => CheckboxProps);
304
- muiTableBodyCellCopyButtonProps?: ButtonProps | (({ table, cell, }: {
305
- table: MRT_TableInstance<TData>;
316
+ muiTableBodyCellCopyButtonProps?: ButtonProps | (({ cell, column, row, table, }: {
306
317
  cell: MRT_Cell<TData>;
318
+ column: MRT_Column<TData>;
319
+ row: MRT_Row<TData>;
320
+ table: MRT_TableInstance<TData>;
307
321
  }) => ButtonProps);
308
- muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, table, }: {
322
+ muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, column, row, table, }: {
309
323
  cell: MRT_Cell<TData>;
324
+ column: MRT_Column<TData>;
325
+ row: MRT_Row<TData>;
310
326
  table: MRT_TableInstance<TData>;
311
327
  }) => TextFieldProps);
312
- muiTableBodyCellProps?: TableCellProps | (({ table, cell, }: {
313
- table: MRT_TableInstance<TData>;
328
+ muiTableBodyCellProps?: TableCellProps | (({ cell, column, row, table, }: {
314
329
  cell: MRT_Cell<TData>;
330
+ column: MRT_Column<TData>;
331
+ row: MRT_Row<TData>;
332
+ table: MRT_TableInstance<TData>;
315
333
  }) => TableCellProps);
316
334
  muiTableBodyCellSkeletonProps?: SkeletonProps | (({ table, cell, }: {
317
335
  table: MRT_TableInstance<TData>;
@@ -398,7 +416,8 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
398
416
  onDensityChange?: OnChangeFn<boolean>;
399
417
  onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
400
418
  onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
401
- onEditingRowSave?: ({ row, table, values, }: {
419
+ onEditingRowSave?: ({ exitEditingMode, row, table, values, }: {
420
+ exitEditingMode: () => void;
402
421
  row: MRT_Row<TData>;
403
422
  table: MRT_TableInstance<TData>;
404
423
  values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
@@ -454,7 +473,6 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
454
473
  rowNumberMode?: 'original' | 'static';
455
474
  selectAllMode?: 'all' | 'page';
456
475
  state?: Partial<MRT_TableState<TData>>;
457
- tableId?: string;
458
476
  virtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement>> | (({ table, }: {
459
477
  table: MRT_TableInstance<TData>;
460
478
  }) => Partial<VirtualizerOptions<HTMLDivElement>>);
@@ -0,0 +1,8 @@
1
+ import type { MRT_Row, MRT_TableInstance } from '..';
2
+ interface Props<TData extends Record<string, any> = {}> {
3
+ open: boolean;
4
+ row: MRT_Row<TData>;
5
+ table: MRT_TableInstance<TData>;
6
+ }
7
+ export declare const MRT_EditRowModal: <TData extends Record<string, any> = {}>({ open, row, table, }: Props<TData>) => JSX.Element;
8
+ export {};
@@ -1,8 +1,8 @@
1
- import { FC } from 'react';
2
1
  import type { MRT_Row, MRT_TableInstance } from '..';
3
- interface Props {
4
- row: MRT_Row;
5
- table: MRT_TableInstance;
2
+ interface Props<TData extends Record<string, any> = {}> {
3
+ row: MRT_Row<TData>;
4
+ table: MRT_TableInstance<TData>;
5
+ variant?: 'icon' | 'text';
6
6
  }
7
- export declare const MRT_EditActionButtons: FC<Props>;
7
+ export declare const MRT_EditActionButtons: <TData extends Record<string, any> = {}>({ row, table, variant, }: Props<TData>) => JSX.Element;
8
8
  export {};
@@ -1,8 +1,8 @@
1
- import { FC } from 'react';
2
1
  import type { MRT_Cell, MRT_TableInstance } from '..';
3
- interface Props {
4
- cell: MRT_Cell;
5
- table: MRT_TableInstance;
2
+ interface Props<TData extends Record<string, any> = {}> {
3
+ cell: MRT_Cell<TData>;
4
+ table: MRT_TableInstance<TData>;
5
+ showLabel?: boolean;
6
6
  }
7
- export declare const MRT_EditCellTextField: FC<Props>;
7
+ export declare const MRT_EditCellTextField: <TData extends Record<string, any> = {}>({ cell, showLabel, table, }: Props<TData>) => JSX.Element;
8
8
  export {};