material-react-table 1.8.1 → 1.8.3

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 (43) hide show
  1. package/dist/cjs/index.js +37 -30
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/MaterialReactTable.d.ts +38 -23
  4. package/dist/cjs/types/body/MRT_TableBody.d.ts +4 -3
  5. package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +3 -2
  6. package/dist/cjs/types/body/MRT_TableBodyRow.d.ts +5 -4
  7. package/dist/cjs/types/body/MRT_TableDetailPanel.d.ts +3 -2
  8. package/dist/cjs/types/column.utils.d.ts +17 -1
  9. package/dist/cjs/types/footer/MRT_TableFooter.d.ts +3 -2
  10. package/dist/cjs/types/footer/MRT_TableFooterRow.d.ts +3 -2
  11. package/dist/cjs/types/head/MRT_TableHead.d.ts +3 -2
  12. package/dist/cjs/types/head/MRT_TableHeadRow.d.ts +3 -2
  13. package/dist/cjs/types/sortingFns.d.ts +117 -1
  14. package/dist/esm/material-react-table.esm.js +37 -30
  15. package/dist/esm/material-react-table.esm.js.map +1 -1
  16. package/dist/esm/types/MaterialReactTable.d.ts +38 -23
  17. package/dist/esm/types/body/MRT_TableBody.d.ts +4 -3
  18. package/dist/esm/types/body/MRT_TableBodyCell.d.ts +3 -2
  19. package/dist/esm/types/body/MRT_TableBodyRow.d.ts +5 -4
  20. package/dist/esm/types/body/MRT_TableDetailPanel.d.ts +3 -2
  21. package/dist/esm/types/column.utils.d.ts +17 -1
  22. package/dist/esm/types/footer/MRT_TableFooter.d.ts +3 -2
  23. package/dist/esm/types/footer/MRT_TableFooterRow.d.ts +3 -2
  24. package/dist/esm/types/head/MRT_TableHead.d.ts +3 -2
  25. package/dist/esm/types/head/MRT_TableHeadRow.d.ts +3 -2
  26. package/dist/esm/types/sortingFns.d.ts +117 -1
  27. package/dist/index.d.ts +39 -24
  28. package/package.json +15 -15
  29. package/src/MaterialReactTable.tsx +655 -624
  30. package/src/body/MRT_TableBody.tsx +10 -11
  31. package/src/body/MRT_TableBodyCell.tsx +3 -2
  32. package/src/body/MRT_TableBodyRow.tsx +7 -14
  33. package/src/body/MRT_TableDetailPanel.tsx +3 -2
  34. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
  35. package/src/footer/MRT_TableFooter.tsx +3 -2
  36. package/src/footer/MRT_TableFooterRow.tsx +3 -7
  37. package/src/head/MRT_TableHead.tsx +3 -2
  38. package/src/head/MRT_TableHeadRow.tsx +3 -7
  39. package/src/inputs/MRT_EditCellTextField.tsx +28 -27
  40. package/src/inputs/MRT_FilterTextField.tsx +36 -35
  41. package/src/menus/MRT_FilterOptionMenu.tsx +8 -3
  42. package/src/table/MRT_Table.tsx +4 -3
  43. package/src/table/MRT_TableRoot.tsx +6 -0
@@ -70,6 +70,10 @@ export { MRT_AggregationFns, MRT_FilterFns, MRT_SortingFns };
70
70
  * Most of this file is just TypeScript types
71
71
  */
72
72
 
73
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
74
+
75
+ type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
76
+
73
77
  export type MRT_DensityState = 'comfortable' | 'compact' | 'spacious';
74
78
 
75
79
  export type {
@@ -89,8 +93,6 @@ export type {
89
93
  VisibilityState as MRT_VisibilityState,
90
94
  };
91
95
 
92
- type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
93
-
94
96
  export interface MRT_Localization {
95
97
  actions: string;
96
98
  and: string;
@@ -189,77 +191,82 @@ export interface MRT_RowModel<TData extends Record<string, any> = {}> {
189
191
  rowsById: { [key: string]: MRT_Row<TData> };
190
192
  }
191
193
 
192
- export type MRT_TableInstance<TData extends Record<string, any> = {}> = Omit<
193
- Table<TData>,
194
- | 'getAllColumns'
195
- | 'getAllFlatColumns'
196
- | 'getAllLeafColumns'
197
- | 'getCenterLeafColumns'
198
- | 'getColumn'
199
- | 'getExpandedRowModel'
200
- | 'getFlatHeaders'
201
- | 'getLeftLeafColumns'
202
- | 'getPaginationRowModel'
203
- | 'getPreFilteredRowModel'
204
- | 'getPrePaginationRowModel'
205
- | 'getRightLeafColumns'
206
- | 'getRowModel'
207
- | 'getSelectedRowModel'
208
- | 'getState'
209
- | 'options'
210
- > & {
211
- getAllColumns: () => MRT_Column<TData>[];
212
- getAllFlatColumns: () => MRT_Column<TData>[];
213
- getAllLeafColumns: () => MRT_Column<TData>[];
214
- getCenterLeafColumns: () => MRT_Column<TData>[];
215
- getColumn: (columnId: string) => MRT_Column<TData>;
216
- getExpandedRowModel: () => MRT_RowModel<TData>;
217
- getFlatHeaders: () => MRT_Header<TData>[];
218
- getLeftLeafColumns: () => MRT_Column<TData>[];
219
- getPaginationRowModel: () => MRT_RowModel<TData>;
220
- getPreFilteredRowModel: () => MRT_RowModel<TData>;
221
- getPrePaginationRowModel: () => MRT_RowModel<TData>;
222
- getRightLeafColumns: () => MRT_Column<TData>[];
223
- getRowModel: () => MRT_RowModel<TData>;
224
- getSelectedRowModel: () => MRT_RowModel<TData>;
225
- getState: () => MRT_TableState<TData>;
226
- options: MaterialReactTableProps<TData> & {
227
- icons: MRT_Icons;
228
- localization: MRT_Localization;
229
- };
230
- refs: {
231
- bottomToolbarRef: MutableRefObject<HTMLDivElement>;
232
- editInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
233
- filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
234
- searchInputRef: MutableRefObject<HTMLInputElement>;
235
- tableContainerRef: MutableRefObject<HTMLDivElement>;
236
- tableHeadCellRefs: MutableRefObject<Record<string, HTMLTableCellElement>>;
237
- tablePaperRef: MutableRefObject<HTMLDivElement>;
238
- topToolbarRef: MutableRefObject<HTMLDivElement>;
239
- };
240
- setColumnFilterFns: Dispatch<
241
- SetStateAction<{ [key: string]: MRT_FilterOption }>
242
- >;
243
- setDensity: Dispatch<SetStateAction<MRT_DensityState>>;
244
- setDraggingColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
245
- setDraggingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
246
- setEditingCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
247
- setEditingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
248
- setGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterOption>>;
249
- setHoveredColumn: Dispatch<
250
- SetStateAction<MRT_Column<TData> | { id: string } | null>
251
- >;
252
- setHoveredRow: Dispatch<
253
- SetStateAction<MRT_Row<TData> | { id: string } | null>
194
+ export type MRT_TableInstance<TData extends Record<string, any> = {}> =
195
+ Prettify<
196
+ Omit<
197
+ Table<TData>,
198
+ | 'getAllColumns'
199
+ | 'getAllFlatColumns'
200
+ | 'getAllLeafColumns'
201
+ | 'getCenterLeafColumns'
202
+ | 'getColumn'
203
+ | 'getExpandedRowModel'
204
+ | 'getFlatHeaders'
205
+ | 'getLeftLeafColumns'
206
+ | 'getPaginationRowModel'
207
+ | 'getPreFilteredRowModel'
208
+ | 'getPrePaginationRowModel'
209
+ | 'getRightLeafColumns'
210
+ | 'getRowModel'
211
+ | 'getSelectedRowModel'
212
+ | 'getState'
213
+ | 'options'
214
+ > & {
215
+ getAllColumns: () => MRT_Column<TData>[];
216
+ getAllFlatColumns: () => MRT_Column<TData>[];
217
+ getAllLeafColumns: () => MRT_Column<TData>[];
218
+ getCenterLeafColumns: () => MRT_Column<TData>[];
219
+ getColumn: (columnId: string) => MRT_Column<TData>;
220
+ getExpandedRowModel: () => MRT_RowModel<TData>;
221
+ getFlatHeaders: () => MRT_Header<TData>[];
222
+ getLeftLeafColumns: () => MRT_Column<TData>[];
223
+ getPaginationRowModel: () => MRT_RowModel<TData>;
224
+ getPreFilteredRowModel: () => MRT_RowModel<TData>;
225
+ getPrePaginationRowModel: () => MRT_RowModel<TData>;
226
+ getRightLeafColumns: () => MRT_Column<TData>[];
227
+ getRowModel: () => MRT_RowModel<TData>;
228
+ getSelectedRowModel: () => MRT_RowModel<TData>;
229
+ getState: () => MRT_TableState<TData>;
230
+ options: MaterialReactTableProps<TData> & {
231
+ icons: MRT_Icons;
232
+ localization: MRT_Localization;
233
+ };
234
+ refs: {
235
+ bottomToolbarRef: MutableRefObject<HTMLDivElement>;
236
+ editInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
237
+ filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
238
+ searchInputRef: MutableRefObject<HTMLInputElement>;
239
+ tableContainerRef: MutableRefObject<HTMLDivElement>;
240
+ tableHeadCellRefs: MutableRefObject<
241
+ Record<string, HTMLTableCellElement>
242
+ >;
243
+ tablePaperRef: MutableRefObject<HTMLDivElement>;
244
+ topToolbarRef: MutableRefObject<HTMLDivElement>;
245
+ };
246
+ setColumnFilterFns: Dispatch<
247
+ SetStateAction<{ [key: string]: MRT_FilterOption }>
248
+ >;
249
+ setDensity: Dispatch<SetStateAction<MRT_DensityState>>;
250
+ setDraggingColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
251
+ setDraggingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
252
+ setEditingCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
253
+ setEditingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
254
+ setGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterOption>>;
255
+ setHoveredColumn: Dispatch<
256
+ SetStateAction<MRT_Column<TData> | { id: string } | null>
257
+ >;
258
+ setHoveredRow: Dispatch<
259
+ SetStateAction<MRT_Row<TData> | { id: string } | null>
260
+ >;
261
+ setIsFullScreen: Dispatch<SetStateAction<boolean>>;
262
+ setShowAlertBanner: Dispatch<SetStateAction<boolean>>;
263
+ setShowFilters: Dispatch<SetStateAction<boolean>>;
264
+ setShowGlobalFilter: Dispatch<SetStateAction<boolean>>;
265
+ setShowToolbarDropZone: Dispatch<SetStateAction<boolean>>;
266
+ }
254
267
  >;
255
- setIsFullScreen: Dispatch<SetStateAction<boolean>>;
256
- setShowAlertBanner: Dispatch<SetStateAction<boolean>>;
257
- setShowFilters: Dispatch<SetStateAction<boolean>>;
258
- setShowGlobalFilter: Dispatch<SetStateAction<boolean>>;
259
- setShowToolbarDropZone: Dispatch<SetStateAction<boolean>>;
260
- };
261
268
 
262
- export type MRT_TableState<TData extends Record<string, any> = {}> =
269
+ export type MRT_TableState<TData extends Record<string, any> = {}> = Prettify<
263
270
  TableState & {
264
271
  columnFilterFns: Record<string, MRT_FilterOption>;
265
272
  density: MRT_DensityState;
@@ -278,437 +285,135 @@ export type MRT_TableState<TData extends Record<string, any> = {}> =
278
285
  showProgressBars: boolean;
279
286
  showSkeletons: boolean;
280
287
  showToolbarDropZone: boolean;
281
- };
282
-
283
- export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
284
- ColumnDef<TData, unknown>,
285
- | 'accessorKey'
286
- | 'aggregatedCell'
287
- | 'aggregationFn'
288
- | 'cell'
289
- | 'columns'
290
- | 'filterFn'
291
- | 'footer'
292
- | 'header'
293
- | 'id'
294
- | 'sortingFn'
295
- > & {
296
- AggregatedCell?: (props: {
297
- cell: MRT_Cell<TData>;
298
- column: MRT_Column<TData>;
299
- row: MRT_Row<TData>;
300
- table: MRT_TableInstance<TData>;
301
- }) => ReactNode;
302
- Cell?: (props: {
303
- cell: MRT_Cell<TData>;
304
- renderedCellValue: number | string | ReactNode;
305
- column: MRT_Column<TData>;
306
- row: MRT_Row<TData>;
307
- table: MRT_TableInstance<TData>;
308
- }) => ReactNode;
309
- Edit?: (props: {
310
- cell: MRT_Cell<TData>;
311
- column: MRT_Column<TData>;
312
- row: MRT_Row<TData>;
313
- table: MRT_TableInstance<TData>;
314
- }) => ReactNode;
315
- Filter?: (props: {
316
- column: MRT_Column<TData>;
317
- header: MRT_Header<TData>;
318
- rangeFilterIndex?: number;
319
- table: MRT_TableInstance<TData>;
320
- }) => ReactNode;
321
- Footer?:
322
- | ReactNode
323
- | ((props: {
324
- column: MRT_Column<TData>;
325
- footer: MRT_Header<TData>;
326
- table: MRT_TableInstance<TData>;
327
- }) => ReactNode);
328
- GroupedCell?: (props: {
329
- cell: MRT_Cell<TData>;
330
- column: MRT_Column<TData>;
331
- row: MRT_Row<TData>;
332
- table: MRT_TableInstance<TData>;
333
- }) => ReactNode;
334
- Header?:
335
- | ReactNode
336
- | ((props: {
337
- column: MRT_Column<TData>;
338
- header: MRT_Header<TData>;
339
- table: MRT_TableInstance<TData>;
340
- }) => ReactNode);
341
- PlaceholderCell?: (props: {
342
- cell: MRT_Cell<TData>;
343
- column: MRT_Column<TData>;
344
- row: MRT_Row<TData>;
345
- table: MRT_TableInstance<TData>;
346
- }) => ReactNode;
347
- /**
348
- * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
349
- * Specify a function here to point to the correct property in the data object.
350
- *
351
- * @example accessorFn: (row) => row.username
352
- */
353
- accessorFn?: (originalRow: TData) => any;
354
- /**
355
- * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
356
- * Specify which key in the row this column should use to access the correct data.
357
- * Also supports Deep Key Dot Notation.
358
- *
359
- * @example accessorKey: 'username' //simple
360
- * @example accessorKey: 'name.firstName' //deep key dot notation
361
- */
362
- accessorKey?: DeepKeys<TData>;
363
- aggregationFn?: MRT_AggregationFn<TData> | Array<MRT_AggregationFn<TData>>;
364
- /**
365
- * Specify what type of column this is. Either `data`, `display`, or `group`. Defaults to `data`.
366
- * Leave this blank if you are just creating a normal data column.
367
- *
368
- * @default 'data'
369
- *
370
- * @example columnDefType: 'display'
371
- */
372
- columnDefType?: 'data' | 'display' | 'group';
373
- columnFilterModeOptions?: Array<
374
- LiteralUnion<string & MRT_FilterOption>
375
- > | null;
376
- columns?: MRT_ColumnDef<TData>[];
377
- editSelectOptions?: (string | { text: string; value: any })[];
378
- editVariant?: 'text' | 'select';
379
- enableClickToCopy?: boolean;
380
- enableColumnActions?: boolean;
381
- enableColumnDragging?: boolean;
382
- enableColumnFilterModes?: boolean;
383
- enableColumnOrdering?: boolean;
384
- enableEditing?: boolean | ((row: MRT_Row<TData>) => boolean);
385
- enableFilterMatchHighlighting?: boolean;
386
- filterFn?: MRT_FilterFn<TData>;
387
- filterSelectOptions?: (string | { text: string; value: any })[];
388
- filterVariant?: 'text' | 'select' | 'multi-select' | 'range' | 'checkbox';
389
- /**
390
- * footer must be a string. If you want custom JSX to render the footer, you can also specify a `Footer` option. (Capital F)
391
- */
392
- footer?: string;
393
- /**
394
- * header must be a string. If you want custom JSX to render the header, you can also specify a `Header` option. (Capital H)
395
- */
396
- header: string;
397
- /**
398
- * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
399
- *
400
- * If you have also specified an `accessorFn`, MRT still needs to have a valid `id` to be able to identify the column uniquely.
401
- *
402
- * `id` defaults to the `accessorKey` or `header` if not specified.
403
- *
404
- * @default gets set to the same value as `accessorKey` by default
405
- */
406
- id?: LiteralUnion<string & keyof TData>;
407
- muiTableBodyCellCopyButtonProps?:
408
- | ButtonProps
409
- | ((props: {
410
- cell: MRT_Cell<TData>;
411
- column: MRT_Column<TData>;
412
- row: MRT_Row<TData>;
413
- table: MRT_TableInstance<TData>;
414
- }) => ButtonProps);
415
- muiTableBodyCellEditTextFieldProps?:
416
- | TextFieldProps
417
- | ((props: {
418
- cell: MRT_Cell<TData>;
419
- column: MRT_Column<TData>;
420
- row: MRT_Row<TData>;
421
- table: MRT_TableInstance<TData>;
422
- }) => TextFieldProps);
423
- muiTableBodyCellProps?:
424
- | TableCellProps
425
- | ((props: {
426
- cell: MRT_Cell<TData>;
427
- column: MRT_Column<TData>;
428
- row: MRT_Row<TData>;
429
- table: MRT_TableInstance<TData>;
430
- }) => TableCellProps);
431
- muiTableFooterCellProps?:
432
- | TableCellProps
433
- | ((props: {
434
- table: MRT_TableInstance<TData>;
435
- column: MRT_Column<TData>;
436
- }) => TableCellProps);
437
- muiTableHeadCellColumnActionsButtonProps?:
438
- | IconButtonProps
439
- | ((props: {
440
- table: MRT_TableInstance<TData>;
441
- column: MRT_Column<TData>;
442
- }) => IconButtonProps);
443
- muiTableHeadCellDragHandleProps?:
444
- | IconButtonProps
445
- | ((props: {
446
- table: MRT_TableInstance<TData>;
447
- column: MRT_Column<TData>;
448
- }) => IconButtonProps);
449
- muiTableHeadCellFilterCheckboxProps?:
450
- | CheckboxProps
451
- | ((props: {
452
- column: MRT_Column<TData>;
453
- table: MRT_TableInstance<TData>;
454
- }) => CheckboxProps);
455
- muiTableHeadCellFilterTextFieldProps?:
456
- | TextFieldProps
457
- | ((props: {
458
- table: MRT_TableInstance<TData>;
459
- column: MRT_Column<TData>;
460
- rangeFilterIndex?: number;
461
- }) => TextFieldProps);
462
- muiTableHeadCellProps?:
463
- | TableCellProps
464
- | ((props: {
465
- table: MRT_TableInstance<TData>;
466
- column: MRT_Column<TData>;
467
- }) => TableCellProps);
468
- renderColumnActionsMenuItems?: (props: {
469
- closeMenu: () => void;
470
- column: MRT_Column<TData>;
471
- table: MRT_TableInstance<TData>;
472
- }) => ReactNode[];
473
- renderColumnFilterModeMenuItems?: (props: {
474
- column: MRT_Column<TData>;
475
- internalFilterOptions: MRT_InternalFilterOption[];
476
- onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
477
- table: MRT_TableInstance<TData>;
478
- }) => ReactNode[];
479
- sortingFn?: MRT_SortingFn<TData>;
480
- };
481
-
482
- export type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> = Omit<
483
- MRT_ColumnDef<TData>,
484
- 'id' | 'defaultDisplayColumn'
485
- > & {
486
- defaultDisplayColumn: Partial<MRT_ColumnDef<TData>>;
487
- id: string;
488
- _filterFn: MRT_FilterOption;
489
- };
490
-
491
- export type MRT_Column<TData extends Record<string, any> = {}> = Omit<
492
- Column<TData, unknown>,
493
- 'header' | 'footer' | 'columns' | 'columnDef' | 'filterFn'
494
- > & {
495
- columnDef: MRT_DefinedColumnDef<TData>;
496
- columns?: MRT_Column<TData>[];
497
- filterFn?: MRT_FilterFn<TData>;
498
- footer: string;
499
- header: string;
500
- };
501
-
502
- export type MRT_Header<TData extends Record<string, any> = {}> = Omit<
503
- Header<TData, unknown>,
504
- 'column'
505
- > & {
506
- column: MRT_Column<TData>;
507
- };
508
-
509
- export type MRT_HeaderGroup<TData extends Record<string, any> = {}> = Omit<
510
- HeaderGroup<TData>,
511
- 'headers'
512
- > & {
513
- headers: MRT_Header<TData>[];
514
- };
515
-
516
- export type MRT_Row<TData extends Record<string, any> = {}> = Omit<
517
- Row<TData>,
518
- 'getVisibleCells' | 'getAllCells' | 'subRows' | '_valuesCache'
519
- > & {
520
- getAllCells: () => MRT_Cell<TData>[];
521
- getVisibleCells: () => MRT_Cell<TData>[];
522
- subRows?: MRT_Row<TData>[];
523
- _valuesCache: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
524
- };
525
-
526
- export type MRT_Cell<TData extends Record<string, any> = {}> = Omit<
527
- Cell<TData, unknown>,
528
- 'column' | 'row'
529
- > & {
530
- column: MRT_Column<TData>;
531
- row: MRT_Row<TData>;
532
- };
533
-
534
- export type MRT_AggregationOption = string & keyof typeof MRT_AggregationFns;
535
-
536
- export type MRT_AggregationFn<TData extends Record<string, any> = {}> =
537
- | AggregationFn<TData>
538
- | MRT_AggregationOption;
539
-
540
- export type MRT_SortingOption = LiteralUnion<
541
- string & keyof typeof MRT_SortingFns
542
- >;
543
-
544
- export type MRT_SortingFn<TData extends Record<string, any> = {}> =
545
- | SortingFn<TData>
546
- | MRT_SortingOption;
547
-
548
- export type MRT_FilterOption = LiteralUnion<
549
- string & keyof typeof MRT_FilterFns
288
+ }
550
289
  >;
551
290
 
552
- export type MRT_FilterFn<TData extends Record<string, any> = {}> =
553
- | FilterFn<TData>
554
- | MRT_FilterOption;
555
-
556
- export type MRT_InternalFilterOption = {
557
- option: string;
558
- symbol: string;
559
- label: string;
560
- divider: boolean;
561
- };
562
-
563
- export type MRT_DisplayColumnIds =
564
- | 'mrt-row-actions'
565
- | 'mrt-row-drag'
566
- | 'mrt-row-expand'
567
- | 'mrt-row-numbers'
568
- | 'mrt-row-select';
569
-
570
- /**
571
- * `columns` and `data` props are the only required props, but there are over 150 other optional props.
572
- *
573
- * See more info on creating columns and data on the official docs site:
574
- * @link https://www.material-react-table.com/docs/getting-started/usage
575
- *
576
- * See the full props list on the official docs site:
577
- * @link https://www.material-react-table.com/docs/api/props
578
- */
579
- export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
291
+ export type MRT_ColumnDef<TData extends Record<string, any> = {}> =
292
+ // Prettify<
580
293
  Omit<
581
- Partial<TableOptions<TData>>,
294
+ ColumnDef<TData, unknown>,
295
+ | 'accessorKey'
296
+ | 'aggregatedCell'
297
+ | 'aggregationFn'
298
+ | 'cell'
582
299
  | 'columns'
583
- | 'data'
584
- | 'defaultColumn'
585
- | 'enableRowSelection'
586
- | 'expandRowsFn'
587
- | 'getRowId'
588
- | 'globalFilterFn'
589
- | 'initialState'
590
- | 'onStateChange'
591
- | 'state'
300
+ | 'filterFn'
301
+ | 'footer'
302
+ | 'header'
303
+ | 'id'
304
+ | 'sortingFn'
592
305
  > & {
593
- columnFilterModeOptions?: Array<
594
- LiteralUnion<string & MRT_FilterOption>
595
- > | null;
306
+ AggregatedCell?: (props: {
307
+ cell: MRT_Cell<TData>;
308
+ column: MRT_Column<TData>;
309
+ row: MRT_Row<TData>;
310
+ table: MRT_TableInstance<TData>;
311
+ }) => ReactNode;
312
+ Cell?: (props: {
313
+ cell: MRT_Cell<TData>;
314
+ renderedCellValue: number | string | ReactNode;
315
+ column: MRT_Column<TData>;
316
+ row: MRT_Row<TData>;
317
+ table: MRT_TableInstance<TData>;
318
+ }) => ReactNode;
319
+ Edit?: (props: {
320
+ cell: MRT_Cell<TData>;
321
+ column: MRT_Column<TData>;
322
+ row: MRT_Row<TData>;
323
+ table: MRT_TableInstance<TData>;
324
+ }) => ReactNode;
325
+ Filter?: (props: {
326
+ column: MRT_Column<TData>;
327
+ header: MRT_Header<TData>;
328
+ rangeFilterIndex?: number;
329
+ table: MRT_TableInstance<TData>;
330
+ }) => ReactNode;
331
+ Footer?:
332
+ | ReactNode
333
+ | ((props: {
334
+ column: MRT_Column<TData>;
335
+ footer: MRT_Header<TData>;
336
+ table: MRT_TableInstance<TData>;
337
+ }) => ReactNode);
338
+ GroupedCell?: (props: {
339
+ cell: MRT_Cell<TData>;
340
+ column: MRT_Column<TData>;
341
+ row: MRT_Row<TData>;
342
+ table: MRT_TableInstance<TData>;
343
+ }) => ReactNode;
344
+ Header?:
345
+ | ReactNode
346
+ | ((props: {
347
+ column: MRT_Column<TData>;
348
+ header: MRT_Header<TData>;
349
+ table: MRT_TableInstance<TData>;
350
+ }) => ReactNode);
351
+ PlaceholderCell?: (props: {
352
+ cell: MRT_Cell<TData>;
353
+ column: MRT_Column<TData>;
354
+ row: MRT_Row<TData>;
355
+ table: MRT_TableInstance<TData>;
356
+ }) => ReactNode;
596
357
  /**
597
- * The columns to display in the table. `accessorKey`s or `accessorFn`s must match keys in the `data` prop.
598
- *
599
- * See more info on creating columns on the official docs site:
600
- * @link https://www.material-react-table.com/docs/guides/data-columns
601
- * @link https://www.material-react-table.com/docs/guides/display-columns
358
+ * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
359
+ * Specify a function here to point to the correct property in the data object.
602
360
  *
603
- * See all Columns Options on the official docs site:
604
- * @link https://www.material-react-table.com/docs/api/column-options
361
+ * @example accessorFn: (row) => row.username
605
362
  */
606
- columns: MRT_ColumnDef<TData>[];
363
+ accessorFn?: (originalRow: TData) => any;
607
364
  /**
608
- * Pass your data as an array of objects. Objects can theoretically be any shape, but it's best to keep them consistent.
365
+ * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
366
+ * Specify which key in the row this column should use to access the correct data.
367
+ * Also supports Deep Key Dot Notation.
609
368
  *
610
- * See the usage guide for more info on creating columns and data:
611
- * @link https://www.material-react-table.com/docs/getting-started/usage
369
+ * @example accessorKey: 'username' //simple
370
+ * @example accessorKey: 'name.firstName' //deep key dot notation
612
371
  */
613
- data: TData[];
372
+ accessorKey?: DeepKeys<TData>;
373
+ aggregationFn?: MRT_AggregationFn<TData> | Array<MRT_AggregationFn<TData>>;
614
374
  /**
615
- * Instead of specifying a bunch of the same options for each column, you can just change an option in the `defaultColumn` prop to change a default option for all columns.
616
- */
617
- defaultColumn?: Partial<MRT_ColumnDef<TData>>;
618
- /**
619
- * Change the default options for display columns.
375
+ * Specify what type of column this is. Either `data`, `display`, or `group`. Defaults to `data`.
376
+ * Leave this blank if you are just creating a normal data column.
377
+ *
378
+ * @default 'data'
379
+ *
380
+ * @example columnDefType: 'display'
620
381
  */
621
- defaultDisplayColumn?: Partial<MRT_ColumnDef<TData>>;
622
- displayColumnDefOptions?: Partial<{
623
- [key in MRT_DisplayColumnIds]: Partial<MRT_ColumnDef>;
624
- }>;
625
- editingMode?: 'table' | 'modal' | 'row' | 'cell';
626
- enableBottomToolbar?: boolean;
382
+ columnDefType?: 'data' | 'display' | 'group';
383
+ columnFilterModeOptions?: Array<
384
+ LiteralUnion<string & MRT_FilterOption>
385
+ > | null;
386
+ columns?: MRT_ColumnDef<TData>[];
387
+ editSelectOptions?: (string | { text: string; value: any })[];
388
+ editVariant?: 'text' | 'select';
627
389
  enableClickToCopy?: boolean;
628
390
  enableColumnActions?: boolean;
629
391
  enableColumnDragging?: boolean;
630
392
  enableColumnFilterModes?: boolean;
631
393
  enableColumnOrdering?: boolean;
632
- enableColumnVirtualization?: boolean;
633
- enableDensityToggle?: boolean;
634
394
  enableEditing?: boolean | ((row: MRT_Row<TData>) => boolean);
635
- enableExpandAll?: boolean;
636
395
  enableFilterMatchHighlighting?: boolean;
637
- enableFullScreenToggle?: boolean;
638
- enableGlobalFilterModes?: boolean;
639
- enableGlobalFilterRankedResults?: boolean;
640
- enablePagination?: boolean;
641
- enableRowActions?: boolean;
642
- enableRowDragging?: boolean;
643
- enableRowNumbers?: boolean;
644
- enableRowOrdering?: boolean;
645
- enableRowSelection?: boolean | ((row: MRT_Row<TData>) => boolean);
646
- enableRowVirtualization?: boolean;
647
- enableSelectAll?: boolean;
648
- enableStickyFooter?: boolean;
649
- enableStickyHeader?: boolean;
650
- enableTableFooter?: boolean;
651
- enableTableHead?: boolean;
652
- enableToolbarInternalActions?: boolean;
653
- enableTopToolbar?: boolean;
654
- expandRowsFn?: (dataRow: TData) => TData[];
655
- getRowId?: (
656
- originalRow: TData,
657
- index: number,
658
- parentRow: MRT_Row<TData>,
659
- ) => string;
660
- globalFilterFn?: MRT_FilterOption;
661
- globalFilterModeOptions?: MRT_FilterOption[] | null;
662
- icons?: Partial<MRT_Icons>;
663
- initialState?: Partial<MRT_TableState<TData>>;
396
+ filterFn?: MRT_FilterFn<TData>;
397
+ filterSelectOptions?: (string | { text: string; value: any })[];
398
+ filterVariant?: 'text' | 'select' | 'multi-select' | 'range' | 'checkbox';
664
399
  /**
665
- * Changes which kind of CSS layout is used to render the table. `semantic` uses default semantic HTML elements, while `grid` adds CSS grid and flexbox styles
400
+ * footer must be a string. If you want custom JSX to render the footer, you can also specify a `Footer` option. (Capital F)
666
401
  */
667
- layoutMode?: 'semantic' | 'grid';
402
+ footer?: string;
668
403
  /**
669
- * Pass in either a locale imported from `material-react-table/locales/*` or a custom locale object.
670
- *
671
- * See the localization (i18n) guide for more info:
672
- * @link https://www.material-react-table.com/docs/guides/localization
404
+ * header must be a string. If you want custom JSX to render the header, you can also specify a `Header` option. (Capital H)
673
405
  */
674
- localization?: Partial<MRT_Localization>;
406
+ header: string;
675
407
  /**
676
- * Memoize cells, rows, or the entire table body to potentially improve render performance.
408
+ * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
409
+ *
410
+ * If you have also specified an `accessorFn`, MRT still needs to have a valid `id` to be able to identify the column uniquely.
411
+ *
412
+ * `id` defaults to the `accessorKey` or `header` if not specified.
677
413
  *
678
- * @warning This will break some dynamic rendering features. See the memoization guide for more info:
679
- * @link https://www.material-react-table.com/docs/guides/memoize-components
414
+ * @default gets set to the same value as `accessorKey` by default
680
415
  */
681
- memoMode?: 'cells' | 'rows' | 'table-body';
682
- muiBottomToolbarProps?:
683
- | ToolbarProps
684
- | ((props: { table: MRT_TableInstance<TData> }) => ToolbarProps);
685
- muiExpandAllButtonProps?:
686
- | IconButtonProps
687
- | ((props: { table: MRT_TableInstance<TData> }) => IconButtonProps);
688
- muiExpandButtonProps?:
689
- | IconButtonProps
690
- | ((props: {
691
- table: MRT_TableInstance<TData>;
692
- row: MRT_Row<TData>;
693
- }) => IconButtonProps);
694
- muiLinearProgressProps?:
695
- | LinearProgressProps
696
- | ((props: {
697
- isTopToolbar: boolean;
698
- table: MRT_TableInstance<TData>;
699
- }) => LinearProgressProps);
700
- muiSearchTextFieldProps?:
701
- | TextFieldProps
702
- | ((props: { table: MRT_TableInstance<TData> }) => TextFieldProps);
703
- muiSelectAllCheckboxProps?:
704
- | CheckboxProps
705
- | ((props: { table: MRT_TableInstance<TData> }) => CheckboxProps);
706
- muiSelectCheckboxProps?:
707
- | (CheckboxProps | RadioProps)
708
- | ((props: {
709
- table: MRT_TableInstance<TData>;
710
- row: MRT_Row<TData>;
711
- }) => CheckboxProps | RadioProps);
416
+ id?: LiteralUnion<string & keyof TData>;
712
417
  muiTableBodyCellCopyButtonProps?:
713
418
  | ButtonProps
714
419
  | ((props: {
@@ -733,54 +438,12 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
733
438
  row: MRT_Row<TData>;
734
439
  table: MRT_TableInstance<TData>;
735
440
  }) => TableCellProps);
736
- muiTableBodyCellSkeletonProps?:
737
- | SkeletonProps
738
- | ((props: {
739
- cell: MRT_Cell<TData>;
740
- column: MRT_Column<TData>;
741
- row: MRT_Row<TData>;
742
- table: MRT_TableInstance<TData>;
743
- }) => SkeletonProps);
744
- muiTableBodyProps?:
745
- | TableBodyProps
746
- | ((props: { table: MRT_TableInstance<TData> }) => TableBodyProps);
747
- muiTableBodyRowDragHandleProps?:
748
- | IconButtonProps
749
- | ((props: {
750
- table: MRT_TableInstance<TData>;
751
- row: MRT_Row<TData>;
752
- }) => IconButtonProps);
753
- muiTableBodyRowProps?:
754
- | TableRowProps
755
- | ((props: {
756
- isDetailPanel?: boolean;
757
- row: MRT_Row<TData>;
758
- table: MRT_TableInstance<TData>;
759
- }) => TableRowProps);
760
- muiTableContainerProps?:
761
- | TableContainerProps
762
- | ((props: { table: MRT_TableInstance<TData> }) => TableContainerProps);
763
- muiTableDetailPanelProps?:
764
- | TableCellProps
765
- | ((props: {
766
- table: MRT_TableInstance<TData>;
767
- row: MRT_Row<TData>;
768
- }) => TableCellProps);
769
441
  muiTableFooterCellProps?:
770
442
  | TableCellProps
771
443
  | ((props: {
772
444
  table: MRT_TableInstance<TData>;
773
445
  column: MRT_Column<TData>;
774
446
  }) => TableCellProps);
775
- muiTableFooterProps?:
776
- | TableFooterProps
777
- | ((props: { table: MRT_TableInstance<TData> }) => TableFooterProps);
778
- muiTableFooterRowProps?:
779
- | TableRowProps
780
- | ((props: {
781
- table: MRT_TableInstance<TData>;
782
- footerGroup: MRT_HeaderGroup<TData>;
783
- }) => TableRowProps);
784
447
  muiTableHeadCellColumnActionsButtonProps?:
785
448
  | IconButtonProps
786
449
  | ((props: {
@@ -812,74 +475,9 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
812
475
  table: MRT_TableInstance<TData>;
813
476
  column: MRT_Column<TData>;
814
477
  }) => TableCellProps);
815
- muiTableHeadProps?:
816
- | TableHeadProps
817
- | ((props: { table: MRT_TableInstance<TData> }) => TableHeadProps);
818
- muiTableHeadRowProps?:
819
- | TableRowProps
820
- | ((props: {
821
- table: MRT_TableInstance<TData>;
822
- headerGroup: MRT_HeaderGroup<TData>;
823
- }) => TableRowProps);
824
- muiTablePaginationProps?:
825
- | Partial<TablePaginationProps>
826
- | ((props: {
827
- table: MRT_TableInstance<TData>;
828
- }) => Partial<TablePaginationProps>);
829
- muiTablePaperProps?:
830
- | PaperProps
831
- | ((props: { table: MRT_TableInstance<TData> }) => PaperProps);
832
- muiTableProps?:
833
- | TableProps
834
- | ((props: { table: MRT_TableInstance<TData> }) => TableProps);
835
- muiToolbarAlertBannerChipProps?:
836
- | ChipProps
837
- | ((props: { table: MRT_TableInstance<TData> }) => ChipProps);
838
- muiToolbarAlertBannerProps?:
839
- | AlertProps
840
- | ((props: { table: MRT_TableInstance<TData> }) => AlertProps);
841
- muiTopToolbarProps?:
842
- | ToolbarProps
843
- | ((props: { table: MRT_TableInstance<TData> }) => ToolbarProps);
844
- onDensityChange?: OnChangeFn<MRT_DensityState>;
845
- onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
846
- onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
847
- onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
848
- onEditingRowCancel?: (props: {
849
- row: MRT_Row<TData>;
850
- table: MRT_TableInstance<TData>;
851
- }) => void;
852
- onEditingRowSave?: (props: {
853
- exitEditingMode: () => void;
854
- row: MRT_Row<TData>;
855
- table: MRT_TableInstance<TData>;
856
- values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
857
- }) => Promise<void> | void;
858
- onEditingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
859
- onColumnFilterFnsChange?: OnChangeFn<{ [key: string]: MRT_FilterOption }>;
860
- onGlobalFilterFnChange?: OnChangeFn<MRT_FilterOption>;
861
- onHoveredColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
862
- onHoveredRowChange?: OnChangeFn<MRT_Row<TData> | null>;
863
- onIsFullScreenChange?: OnChangeFn<boolean>;
864
- onShowAlertBannerChange?: OnChangeFn<boolean>;
865
- onShowFiltersChange?: OnChangeFn<boolean>;
866
- onShowGlobalFilterChange?: OnChangeFn<boolean>;
867
- onShowToolbarDropZoneChange?: OnChangeFn<boolean>;
868
- positionActionsColumn?: 'first' | 'last';
869
- positionExpandColumn?: 'first' | 'last';
870
- positionGlobalFilter?: 'left' | 'right' | 'none';
871
- positionPagination?: 'bottom' | 'top' | 'both' | 'none';
872
- positionToolbarAlertBanner?: 'bottom' | 'top' | 'none';
873
- positionToolbarDropZone?: 'bottom' | 'top' | 'none' | 'both';
874
- renderBottomToolbar?:
875
- | ReactNode
876
- | ((props: { table: MRT_TableInstance<TData> }) => ReactNode);
877
- renderBottomToolbarCustomActions?: (props: {
878
- table: MRT_TableInstance<TData>;
879
- }) => ReactNode;
880
478
  renderColumnActionsMenuItems?: (props: {
881
- column: MRT_Column<TData>;
882
479
  closeMenu: () => void;
480
+ column: MRT_Column<TData>;
883
481
  table: MRT_TableInstance<TData>;
884
482
  }) => ReactNode[];
885
483
  renderColumnFilterModeMenuItems?: (props: {
@@ -888,38 +486,480 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
888
486
  onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
889
487
  table: MRT_TableInstance<TData>;
890
488
  }) => ReactNode[];
891
- renderDetailPanel?: (props: {
892
- row: MRT_Row<TData>;
893
- table: MRT_TableInstance<TData>;
894
- }) => ReactNode;
895
- renderGlobalFilterModeMenuItems?: (props: {
896
- internalFilterOptions: MRT_InternalFilterOption[];
897
- onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
898
- table: MRT_TableInstance<TData>;
899
- }) => ReactNode[];
900
- renderRowActionMenuItems?: (props: {
901
- closeMenu: () => void;
902
- row: MRT_Row<TData>;
903
- table: MRT_TableInstance<TData>;
904
- }) => ReactNode[];
905
- renderRowActions?: (props: {
906
- cell: MRT_Cell<TData>;
907
- row: MRT_Row<TData>;
908
- table: MRT_TableInstance<TData>;
909
- }) => ReactNode;
910
- renderToolbarInternalActions?: (props: {
911
- table: MRT_TableInstance<TData>;
912
- }) => ReactNode;
913
- renderTopToolbar?:
914
- | ReactNode
915
- | ((props: { table: MRT_TableInstance<TData> }) => ReactNode);
916
- renderTopToolbarCustomActions?: (props: {
917
- table: MRT_TableInstance<TData>;
918
- }) => ReactNode;
919
- rowCount?: number;
920
- rowNumberMode?: 'original' | 'static';
921
- selectAllMode?: 'all' | 'page';
922
- state?: Partial<MRT_TableState<TData>>;
489
+ sortingFn?: MRT_SortingFn<TData>;
490
+ };
491
+ // >
492
+
493
+ export type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> =
494
+ // Prettify<
495
+ Omit<MRT_ColumnDef<TData>, 'id' | 'defaultDisplayColumn'> & {
496
+ defaultDisplayColumn: Partial<MRT_ColumnDef<TData>>;
497
+ id: string;
498
+ _filterFn: MRT_FilterOption;
499
+ };
500
+ // >
501
+
502
+ export type MRT_Column<TData extends Record<string, any> = {}> =
503
+ // Prettify<
504
+ Omit<
505
+ Column<TData, unknown>,
506
+ 'header' | 'footer' | 'columns' | 'columnDef' | 'filterFn'
507
+ > & {
508
+ columnDef: MRT_DefinedColumnDef<TData>;
509
+ columns?: MRT_Column<TData>[];
510
+ filterFn?: MRT_FilterFn<TData>;
511
+ footer: string;
512
+ header: string;
513
+ };
514
+ // >;
515
+
516
+ export type MRT_Header<TData extends Record<string, any> = {}> = Prettify<
517
+ Omit<Header<TData, unknown>, 'column'> & {
518
+ column: MRT_Column<TData>;
519
+ }
520
+ >;
521
+
522
+ export type MRT_HeaderGroup<TData extends Record<string, any> = {}> = Prettify<
523
+ Omit<HeaderGroup<TData>, 'headers'> & {
524
+ headers: MRT_Header<TData>[];
525
+ }
526
+ >;
527
+
528
+ export type MRT_Row<TData extends Record<string, any> = {}> = Prettify<
529
+ Omit<
530
+ Row<TData>,
531
+ 'getVisibleCells' | 'getAllCells' | 'subRows' | '_valuesCache'
532
+ > & {
533
+ getAllCells: () => MRT_Cell<TData>[];
534
+ getVisibleCells: () => MRT_Cell<TData>[];
535
+ subRows?: MRT_Row<TData>[];
536
+ _valuesCache: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
537
+ }
538
+ >;
539
+
540
+ export type MRT_Cell<TData extends Record<string, any> = {}> = Prettify<
541
+ Omit<Cell<TData, unknown>, 'column' | 'row'> & {
542
+ column: MRT_Column<TData>;
543
+ row: MRT_Row<TData>;
544
+ }
545
+ >;
546
+
547
+ export type MRT_AggregationOption = string & keyof typeof MRT_AggregationFns;
548
+
549
+ export type MRT_AggregationFn<TData extends Record<string, any> = {}> =
550
+ | AggregationFn<TData>
551
+ | MRT_AggregationOption;
552
+
553
+ export type MRT_SortingOption = LiteralUnion<
554
+ string & keyof typeof MRT_SortingFns
555
+ >;
556
+
557
+ export type MRT_SortingFn<TData extends Record<string, any> = {}> =
558
+ | SortingFn<TData>
559
+ | MRT_SortingOption;
560
+
561
+ export type MRT_FilterOption = LiteralUnion<
562
+ string & keyof typeof MRT_FilterFns
563
+ >;
564
+
565
+ export type MRT_FilterFn<TData extends Record<string, any> = {}> =
566
+ | FilterFn<TData>
567
+ | MRT_FilterOption;
568
+
569
+ export type MRT_InternalFilterOption = {
570
+ option: string;
571
+ symbol: string;
572
+ label: string;
573
+ divider: boolean;
574
+ };
575
+
576
+ export type MRT_DisplayColumnIds =
577
+ | 'mrt-row-actions'
578
+ | 'mrt-row-drag'
579
+ | 'mrt-row-expand'
580
+ | 'mrt-row-numbers'
581
+ | 'mrt-row-select';
582
+
583
+ export type MRT_CreateTableFeature<
584
+ TData extends Record<string, any> = {},
585
+ TFeature = any,
586
+ > = (table: MRT_TableInstance<TData>) => TFeature;
587
+
588
+ /**
589
+ * `columns` and `data` props are the only required props, but there are over 170 other optional props.
590
+ *
591
+ * See more info on creating columns and data on the official docs site:
592
+ * @link https://www.material-react-table.com/docs/getting-started/usage
593
+ *
594
+ * See the full props list on the official docs site:
595
+ * @link https://www.material-react-table.com/docs/api/props
596
+ */
597
+ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
598
+ Prettify<
599
+ Omit<
600
+ Partial<TableOptions<TData>>,
601
+ | 'columns'
602
+ | 'data'
603
+ | 'defaultColumn'
604
+ | 'enableRowSelection'
605
+ | 'expandRowsFn'
606
+ | 'getRowId'
607
+ | 'globalFilterFn'
608
+ | 'initialState'
609
+ | 'onStateChange'
610
+ | 'state'
611
+ > & {
612
+ columnFilterModeOptions?: Array<
613
+ LiteralUnion<string & MRT_FilterOption>
614
+ > | null;
615
+ /**
616
+ * The columns to display in the table. `accessorKey`s or `accessorFn`s must match keys in the `data` prop.
617
+ *
618
+ * See more info on creating columns on the official docs site:
619
+ * @link https://www.material-react-table.com/docs/guides/data-columns
620
+ * @link https://www.material-react-table.com/docs/guides/display-columns
621
+ *
622
+ * See all Columns Options on the official docs site:
623
+ * @link https://www.material-react-table.com/docs/api/column-options
624
+ */
625
+ columns: MRT_ColumnDef<TData>[];
626
+ /**
627
+ * Pass your data as an array of objects. Objects can theoretically be any shape, but it's best to keep them consistent.
628
+ *
629
+ * See the usage guide for more info on creating columns and data:
630
+ * @link https://www.material-react-table.com/docs/getting-started/usage
631
+ */
632
+ data: TData[];
633
+ /**
634
+ * Instead of specifying a bunch of the same options for each column, you can just change an option in the `defaultColumn` prop to change a default option for all columns.
635
+ */
636
+ defaultColumn?: Partial<MRT_ColumnDef<TData>>;
637
+ /**
638
+ * Change the default options for display columns.
639
+ */
640
+ defaultDisplayColumn?: Partial<MRT_ColumnDef<TData>>;
641
+ displayColumnDefOptions?: Partial<{
642
+ [key in MRT_DisplayColumnIds]: Partial<MRT_ColumnDef>;
643
+ }>;
644
+ editingMode?: 'table' | 'modal' | 'row' | 'cell';
645
+ enableBottomToolbar?: boolean;
646
+ enableClickToCopy?: boolean;
647
+ enableColumnActions?: boolean;
648
+ enableColumnDragging?: boolean;
649
+ enableColumnFilterModes?: boolean;
650
+ enableColumnOrdering?: boolean;
651
+ enableColumnVirtualization?: boolean;
652
+ enableDensityToggle?: boolean;
653
+ enableEditing?: boolean | ((row: MRT_Row<TData>) => boolean);
654
+ enableExpandAll?: boolean;
655
+ enableFilterMatchHighlighting?: boolean;
656
+ enableFullScreenToggle?: boolean;
657
+ enableGlobalFilterModes?: boolean;
658
+ enableGlobalFilterRankedResults?: boolean;
659
+ enablePagination?: boolean;
660
+ enableRowActions?: boolean;
661
+ enableRowDragging?: boolean;
662
+ enableRowNumbers?: boolean;
663
+ enableRowOrdering?: boolean;
664
+ enableRowSelection?: boolean | ((row: MRT_Row<TData>) => boolean);
665
+ enableRowVirtualization?: boolean;
666
+ enableSelectAll?: boolean;
667
+ enableStickyFooter?: boolean;
668
+ enableStickyHeader?: boolean;
669
+ enableTableFooter?: boolean;
670
+ enableTableHead?: boolean;
671
+ enableToolbarInternalActions?: boolean;
672
+ enableTopToolbar?: boolean;
673
+ expandRowsFn?: (dataRow: TData) => TData[];
674
+ getRowId?: (
675
+ originalRow: TData,
676
+ index: number,
677
+ parentRow: MRT_Row<TData>,
678
+ ) => string;
679
+ globalFilterFn?: MRT_FilterOption;
680
+ globalFilterModeOptions?: MRT_FilterOption[] | null;
681
+ icons?: Partial<MRT_Icons>;
682
+ initialState?: Partial<MRT_TableState<TData>>;
683
+ /**
684
+ * Changes which kind of CSS layout is used to render the table. `semantic` uses default semantic HTML elements, while `grid` adds CSS grid and flexbox styles
685
+ */
686
+ layoutMode?: 'semantic' | 'grid';
687
+ /**
688
+ * Pass in either a locale imported from `material-react-table/locales/*` or a custom locale object.
689
+ *
690
+ * See the localization (i18n) guide for more info:
691
+ * @link https://www.material-react-table.com/docs/guides/localization
692
+ */
693
+ localization?: Partial<MRT_Localization>;
694
+ /**
695
+ * Memoize cells, rows, or the entire table body to potentially improve render performance.
696
+ *
697
+ * @warning This will break some dynamic rendering features. See the memoization guide for more info:
698
+ * @link https://www.material-react-table.com/docs/guides/memoize-components
699
+ */
700
+ memoMode?: 'cells' | 'rows' | 'table-body';
701
+ muiBottomToolbarProps?:
702
+ | ToolbarProps
703
+ | ((props: { table: MRT_TableInstance<TData> }) => ToolbarProps);
704
+ muiExpandAllButtonProps?:
705
+ | IconButtonProps
706
+ | ((props: { table: MRT_TableInstance<TData> }) => IconButtonProps);
707
+ muiExpandButtonProps?:
708
+ | IconButtonProps
709
+ | ((props: {
710
+ table: MRT_TableInstance<TData>;
711
+ row: MRT_Row<TData>;
712
+ }) => IconButtonProps);
713
+ muiLinearProgressProps?:
714
+ | LinearProgressProps
715
+ | ((props: {
716
+ isTopToolbar: boolean;
717
+ table: MRT_TableInstance<TData>;
718
+ }) => LinearProgressProps);
719
+ muiSearchTextFieldProps?:
720
+ | TextFieldProps
721
+ | ((props: { table: MRT_TableInstance<TData> }) => TextFieldProps);
722
+ muiSelectAllCheckboxProps?:
723
+ | CheckboxProps
724
+ | ((props: { table: MRT_TableInstance<TData> }) => CheckboxProps);
725
+ muiSelectCheckboxProps?:
726
+ | (CheckboxProps | RadioProps)
727
+ | ((props: {
728
+ table: MRT_TableInstance<TData>;
729
+ row: MRT_Row<TData>;
730
+ }) => CheckboxProps | RadioProps);
731
+ muiTableBodyCellCopyButtonProps?:
732
+ | ButtonProps
733
+ | ((props: {
734
+ cell: MRT_Cell<TData>;
735
+ column: MRT_Column<TData>;
736
+ row: MRT_Row<TData>;
737
+ table: MRT_TableInstance<TData>;
738
+ }) => ButtonProps);
739
+ muiTableBodyCellEditTextFieldProps?:
740
+ | TextFieldProps
741
+ | ((props: {
742
+ cell: MRT_Cell<TData>;
743
+ column: MRT_Column<TData>;
744
+ row: MRT_Row<TData>;
745
+ table: MRT_TableInstance<TData>;
746
+ }) => TextFieldProps);
747
+ muiTableBodyCellProps?:
748
+ | TableCellProps
749
+ | ((props: {
750
+ cell: MRT_Cell<TData>;
751
+ column: MRT_Column<TData>;
752
+ row: MRT_Row<TData>;
753
+ table: MRT_TableInstance<TData>;
754
+ }) => TableCellProps);
755
+ muiTableBodyCellSkeletonProps?:
756
+ | SkeletonProps
757
+ | ((props: {
758
+ cell: MRT_Cell<TData>;
759
+ column: MRT_Column<TData>;
760
+ row: MRT_Row<TData>;
761
+ table: MRT_TableInstance<TData>;
762
+ }) => SkeletonProps);
763
+ muiTableBodyProps?:
764
+ | TableBodyProps
765
+ | ((props: { table: MRT_TableInstance<TData> }) => TableBodyProps);
766
+ muiTableBodyRowDragHandleProps?:
767
+ | IconButtonProps
768
+ | ((props: {
769
+ table: MRT_TableInstance<TData>;
770
+ row: MRT_Row<TData>;
771
+ }) => IconButtonProps);
772
+ muiTableBodyRowProps?:
773
+ | TableRowProps
774
+ | ((props: {
775
+ isDetailPanel?: boolean;
776
+ row: MRT_Row<TData>;
777
+ table: MRT_TableInstance<TData>;
778
+ }) => TableRowProps);
779
+ muiTableContainerProps?:
780
+ | TableContainerProps
781
+ | ((props: { table: MRT_TableInstance<TData> }) => TableContainerProps);
782
+ muiTableDetailPanelProps?:
783
+ | TableCellProps
784
+ | ((props: {
785
+ table: MRT_TableInstance<TData>;
786
+ row: MRT_Row<TData>;
787
+ }) => TableCellProps);
788
+ muiTableFooterCellProps?:
789
+ | TableCellProps
790
+ | ((props: {
791
+ table: MRT_TableInstance<TData>;
792
+ column: MRT_Column<TData>;
793
+ }) => TableCellProps);
794
+ muiTableFooterProps?:
795
+ | TableFooterProps
796
+ | ((props: { table: MRT_TableInstance<TData> }) => TableFooterProps);
797
+ muiTableFooterRowProps?:
798
+ | TableRowProps
799
+ | ((props: {
800
+ table: MRT_TableInstance<TData>;
801
+ footerGroup: MRT_HeaderGroup<TData>;
802
+ }) => TableRowProps);
803
+ muiTableHeadCellColumnActionsButtonProps?:
804
+ | IconButtonProps
805
+ | ((props: {
806
+ table: MRT_TableInstance<TData>;
807
+ column: MRT_Column<TData>;
808
+ }) => IconButtonProps);
809
+ muiTableHeadCellDragHandleProps?:
810
+ | IconButtonProps
811
+ | ((props: {
812
+ table: MRT_TableInstance<TData>;
813
+ column: MRT_Column<TData>;
814
+ }) => IconButtonProps);
815
+ muiTableHeadCellFilterCheckboxProps?:
816
+ | CheckboxProps
817
+ | ((props: {
818
+ column: MRT_Column<TData>;
819
+ table: MRT_TableInstance<TData>;
820
+ }) => CheckboxProps);
821
+ muiTableHeadCellFilterTextFieldProps?:
822
+ | TextFieldProps
823
+ | ((props: {
824
+ table: MRT_TableInstance<TData>;
825
+ column: MRT_Column<TData>;
826
+ rangeFilterIndex?: number;
827
+ }) => TextFieldProps);
828
+ muiTableHeadCellProps?:
829
+ | TableCellProps
830
+ | ((props: {
831
+ table: MRT_TableInstance<TData>;
832
+ column: MRT_Column<TData>;
833
+ }) => TableCellProps);
834
+ muiTableHeadProps?:
835
+ | TableHeadProps
836
+ | ((props: { table: MRT_TableInstance<TData> }) => TableHeadProps);
837
+ muiTableHeadRowProps?:
838
+ | TableRowProps
839
+ | ((props: {
840
+ table: MRT_TableInstance<TData>;
841
+ headerGroup: MRT_HeaderGroup<TData>;
842
+ }) => TableRowProps);
843
+ muiTablePaginationProps?:
844
+ | Partial<TablePaginationProps>
845
+ | ((props: {
846
+ table: MRT_TableInstance<TData>;
847
+ }) => Partial<TablePaginationProps>);
848
+ muiTablePaperProps?:
849
+ | PaperProps
850
+ | ((props: { table: MRT_TableInstance<TData> }) => PaperProps);
851
+ muiTableProps?:
852
+ | TableProps
853
+ | ((props: { table: MRT_TableInstance<TData> }) => TableProps);
854
+ muiToolbarAlertBannerChipProps?:
855
+ | ChipProps
856
+ | ((props: { table: MRT_TableInstance<TData> }) => ChipProps);
857
+ muiToolbarAlertBannerProps?:
858
+ | AlertProps
859
+ | ((props: { table: MRT_TableInstance<TData> }) => AlertProps);
860
+ muiTopToolbarProps?:
861
+ | ToolbarProps
862
+ | ((props: { table: MRT_TableInstance<TData> }) => ToolbarProps);
863
+ onDensityChange?: OnChangeFn<MRT_DensityState>;
864
+ onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
865
+ onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
866
+ onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
867
+ onEditingRowCancel?: (props: {
868
+ row: MRT_Row<TData>;
869
+ table: MRT_TableInstance<TData>;
870
+ }) => void;
871
+ onEditingRowSave?: (props: {
872
+ exitEditingMode: () => void;
873
+ row: MRT_Row<TData>;
874
+ table: MRT_TableInstance<TData>;
875
+ values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
876
+ }) => Promise<void> | void;
877
+ onEditingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
878
+ onColumnFilterFnsChange?: OnChangeFn<{ [key: string]: MRT_FilterOption }>;
879
+ onGlobalFilterFnChange?: OnChangeFn<MRT_FilterOption>;
880
+ onHoveredColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
881
+ onHoveredRowChange?: OnChangeFn<MRT_Row<TData> | null>;
882
+ onIsFullScreenChange?: OnChangeFn<boolean>;
883
+ onShowAlertBannerChange?: OnChangeFn<boolean>;
884
+ onShowFiltersChange?: OnChangeFn<boolean>;
885
+ onShowGlobalFilterChange?: OnChangeFn<boolean>;
886
+ onShowToolbarDropZoneChange?: OnChangeFn<boolean>;
887
+ positionActionsColumn?: 'first' | 'last';
888
+ positionExpandColumn?: 'first' | 'last';
889
+ positionGlobalFilter?: 'left' | 'right' | 'none';
890
+ positionPagination?: 'bottom' | 'top' | 'both' | 'none';
891
+ positionToolbarAlertBanner?: 'bottom' | 'top' | 'none';
892
+ positionToolbarDropZone?: 'bottom' | 'top' | 'none' | 'both';
893
+ renderBottomToolbar?:
894
+ | ReactNode
895
+ | ((props: { table: MRT_TableInstance<TData> }) => ReactNode);
896
+ renderBottomToolbarCustomActions?: (props: {
897
+ table: MRT_TableInstance<TData>;
898
+ }) => ReactNode;
899
+ renderColumnActionsMenuItems?: (props: {
900
+ column: MRT_Column<TData>;
901
+ closeMenu: () => void;
902
+ table: MRT_TableInstance<TData>;
903
+ }) => ReactNode[];
904
+ renderColumnFilterModeMenuItems?: (props: {
905
+ column: MRT_Column<TData>;
906
+ internalFilterOptions: MRT_InternalFilterOption[];
907
+ onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
908
+ table: MRT_TableInstance<TData>;
909
+ }) => ReactNode[];
910
+ renderDetailPanel?: (props: {
911
+ row: MRT_Row<TData>;
912
+ table: MRT_TableInstance<TData>;
913
+ }) => ReactNode;
914
+ renderGlobalFilterModeMenuItems?: (props: {
915
+ internalFilterOptions: MRT_InternalFilterOption[];
916
+ onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
917
+ table: MRT_TableInstance<TData>;
918
+ }) => ReactNode[];
919
+ renderRowActionMenuItems?: (props: {
920
+ closeMenu: () => void;
921
+ row: MRT_Row<TData>;
922
+ table: MRT_TableInstance<TData>;
923
+ }) => ReactNode[];
924
+ renderRowActions?: (props: {
925
+ cell: MRT_Cell<TData>;
926
+ row: MRT_Row<TData>;
927
+ table: MRT_TableInstance<TData>;
928
+ }) => ReactNode;
929
+ renderToolbarInternalActions?: (props: {
930
+ table: MRT_TableInstance<TData>;
931
+ }) => ReactNode;
932
+ renderTopToolbar?:
933
+ | ReactNode
934
+ | ((props: { table: MRT_TableInstance<TData> }) => ReactNode);
935
+ renderTopToolbarCustomActions?: (props: {
936
+ table: MRT_TableInstance<TData>;
937
+ }) => ReactNode;
938
+ rowCount?: number;
939
+ rowNumberMode?: 'original' | 'static';
940
+ selectAllMode?: 'all' | 'page';
941
+ /**
942
+ * Manage state externally any way you want, then pass it back into MRT.
943
+ */
944
+ state?: Partial<MRT_TableState<TData>>;
945
+ /**
946
+ * Sequence of features important any dependent feature must be defined first
947
+ */
948
+ tableFeatures?: Array<MRT_CreateTableFeature<TData>>;
949
+ /**
950
+ * Get access to the table instance via a ref to read state or call built-in methods
951
+ */
952
+ tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
953
+ /**
954
+ * @deprecated Use `rowVirtualizerInstanceRef` instead
955
+ */
956
+ virtualizerInstanceRef?: any;
957
+ /**
958
+ * @deprecated Use `rowVirtualizerProps` instead
959
+ */
960
+ virtualizerProps?: any;
961
+ }
962
+ > & {
923
963
  columnVirtualizerInstanceRef?: MutableRefObject<Virtualizer<
924
964
  HTMLDivElement,
925
965
  HTMLTableCellElement
@@ -940,15 +980,6 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
940
980
  | ((props: {
941
981
  table: MRT_TableInstance<TData>;
942
982
  }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>);
943
- tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
944
- /**
945
- * @deprecated Use `rowVirtualizerInstanceRef` instead
946
- */
947
- virtualizerInstanceRef?: any;
948
- /**
949
- * @deprecated Use `rowVirtualizerProps` instead
950
- */
951
- virtualizerProps?: any;
952
983
  };
953
984
 
954
985
  const MaterialReactTable = <TData extends Record<string, any> = {}>({