material-react-table 0.23.5 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/MaterialReactTable.d.ts +61 -28
- package/dist/body/MRT_TableBodyCell.d.ts +2 -1
- package/dist/body/MRT_TableBodyRowGrabHandle.d.ts +9 -0
- package/dist/buttons/MRT_GrabHandleButton.d.ts +4 -2
- package/dist/head/MRT_TableHeadCellGrabHandle.d.ts +9 -0
- package/dist/localization.d.ts +1 -0
- package/dist/material-react-table.cjs.development.js +334 -221
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +335 -222
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/utils.d.ts +3 -3
- package/package.json +3 -3
- package/src/MaterialReactTable.tsx +95 -35
- package/src/body/MRT_TableBodyCell.tsx +20 -4
- package/src/body/MRT_TableBodyRow.tsx +37 -3
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +48 -0
- package/src/buttons/MRT_GrabHandleButton.tsx +12 -8
- package/src/head/MRT_TableHeadCell.tsx +40 -57
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +77 -0
- package/src/inputs/MRT_FilterTextField.tsx +4 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +13 -18
- package/src/localization.ts +2 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +17 -16
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -3
- package/src/table/MRT_TableRoot.tsx +61 -25
- package/src/utils.ts +11 -9
@@ -1,19 +1,12 @@
|
|
1
|
-
import { ChangeEvent, Dispatch, FC, FocusEvent, ReactNode, SetStateAction } from 'react';
|
2
|
-
import { AlertProps, ButtonProps, CheckboxProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
3
|
-
import { Cell, Column, ColumnDef, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
|
4
|
-
import { Options as VirtualizerOptions } from 'react-virtual';
|
1
|
+
import { ChangeEvent, Dispatch, DragEvent, FC, FocusEvent, ReactNode, SetStateAction } from 'react';
|
2
|
+
import type { AlertProps, ButtonProps, CheckboxProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
3
|
+
import type { Cell, Column, ColumnDef, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
|
4
|
+
import type { Options as VirtualizerOptions } from 'react-virtual';
|
5
5
|
import { MRT_Localization } from './localization';
|
6
6
|
import { MRT_Icons } from './icons';
|
7
7
|
import { MRT_FilterFns } from './filtersFns';
|
8
8
|
import { MRT_SortingFns } from './sortingFns';
|
9
9
|
declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
|
10
|
-
export declare type MRT_TableOptions<TData extends Record<string, any> = {}> = Partial<Omit<TableOptions<TData>, 'columns' | 'data' | 'initialState' | 'state' | 'expandRowsFn'>> & {
|
11
|
-
columns: MRT_ColumnDef<TData>[];
|
12
|
-
data: TData[];
|
13
|
-
expandRowsFn?: (dataRow: TData) => TData[];
|
14
|
-
initialState?: Partial<MRT_TableState<TData>>;
|
15
|
-
state?: Partial<MRT_TableState<TData>>;
|
16
|
-
};
|
17
10
|
export interface MRT_RowModel<TData extends Record<string, any> = {}> {
|
18
11
|
flatRows: MRT_Row<TData>[];
|
19
12
|
rows: MRT_Row<TData>[];
|
@@ -43,6 +36,7 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
|
|
43
36
|
localization: MRT_Localization;
|
44
37
|
};
|
45
38
|
setCurrentDraggingColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
39
|
+
setCurrentDraggingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
|
46
40
|
setCurrentEditingCell: Dispatch<SetStateAction<MRT_Cell | null>>;
|
47
41
|
setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row | null>>;
|
48
42
|
setCurrentFilterFns: Dispatch<SetStateAction<{
|
@@ -50,6 +44,7 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
|
|
50
44
|
}>>;
|
51
45
|
setCurrentGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterOption>>;
|
52
46
|
setCurrentHoveredColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
47
|
+
setCurrentHoveredRow: Dispatch<SetStateAction<MRT_Row | null>>;
|
53
48
|
setDensity: Dispatch<SetStateAction<'comfortable' | 'compact' | 'spacious'>>;
|
54
49
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
55
50
|
setShowAlertBanner: Dispatch<SetStateAction<boolean>>;
|
@@ -58,11 +53,13 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
|
|
58
53
|
};
|
59
54
|
export declare type MRT_TableState<TData extends Record<string, any> = {}> = TableState & {
|
60
55
|
currentDraggingColumn: MRT_Column<TData> | null;
|
56
|
+
currentDraggingRow: MRT_Row<TData> | null;
|
61
57
|
currentEditingCell: MRT_Cell<TData> | null;
|
62
58
|
currentEditingRow: MRT_Row<TData> | null;
|
63
59
|
currentFilterFns: Record<string, MRT_FilterOption>;
|
64
60
|
currentGlobalFilterFn: Record<string, MRT_FilterOption>;
|
65
61
|
currentHoveredColumn: MRT_Column<TData> | null;
|
62
|
+
currentHoveredRow: MRT_Row<TData> | null;
|
66
63
|
density: 'comfortable' | 'compact' | 'spacious';
|
67
64
|
isFullScreen: boolean;
|
68
65
|
isLoading: boolean;
|
@@ -110,7 +107,7 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
110
107
|
*
|
111
108
|
* @example accessorKey: 'username'
|
112
109
|
*/
|
113
|
-
accessorKey?:
|
110
|
+
accessorKey?: string & keyof TData;
|
114
111
|
/**
|
115
112
|
* Specify what type of column this is. Either `data`, `display`, or `group`. Defaults to `data`.
|
116
113
|
* Leave this blank if you are just creating a normal data column.
|
@@ -123,6 +120,7 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
123
120
|
columns?: MRT_ColumnDef<TData>[];
|
124
121
|
enableClickToCopy?: boolean;
|
125
122
|
enableColumnActions?: boolean;
|
123
|
+
enableColumnDragging?: boolean;
|
126
124
|
enableColumnFilterChangeMode?: boolean;
|
127
125
|
enableColumnOrdering?: boolean;
|
128
126
|
enableEditing?: boolean;
|
@@ -170,6 +168,10 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
170
168
|
table: MRT_TableInstance<TData>;
|
171
169
|
column: MRT_Column<TData>;
|
172
170
|
}) => IconButtonProps);
|
171
|
+
muiTableHeadCellDragHandleProps?: IconButtonProps | (({ table, column, }: {
|
172
|
+
table: MRT_TableInstance<TData>;
|
173
|
+
column: MRT_Column<TData>;
|
174
|
+
}) => IconButtonProps);
|
173
175
|
muiTableHeadCellFilterTextFieldProps?: TextFieldProps | (({ table, column, }: {
|
174
176
|
table: MRT_TableInstance<TData>;
|
175
177
|
column: MRT_Column<TData>;
|
@@ -206,11 +208,10 @@ export declare type MRT_Header<TData extends Record<string, any> = {}> = Omit<He
|
|
206
208
|
export declare type MRT_HeaderGroup<TData extends Record<string, any> = {}> = Omit<HeaderGroup<TData>, 'headers'> & {
|
207
209
|
headers: MRT_Header<TData>[];
|
208
210
|
};
|
209
|
-
export declare type MRT_Row<TData extends Record<string, any> = {}> = Omit<Row<TData>, 'getVisibleCells' | 'getAllCells' | 'subRows' | '
|
211
|
+
export declare type MRT_Row<TData extends Record<string, any> = {}> = Omit<Row<TData>, 'getVisibleCells' | 'getAllCells' | 'subRows' | '_valuesCache'> & {
|
210
212
|
getAllCells: () => MRT_Cell<TData>[];
|
211
213
|
getVisibleCells: () => MRT_Cell<TData>[];
|
212
214
|
subRows?: MRT_Row<TData>[];
|
213
|
-
original: TData;
|
214
215
|
_valuesCache?: TData;
|
215
216
|
};
|
216
217
|
export declare type MRT_Cell<TData extends Record<string, any> = {}> = Omit<Cell<TData, unknown>, 'column' | 'row'> & {
|
@@ -221,10 +222,26 @@ export declare type MRT_SortingOption = keyof typeof MRT_SortingFns;
|
|
221
222
|
export declare type MRT_SortingFn<TData extends Record<string, any> = {}> = SortingFn<TData> | MRT_SortingOption;
|
222
223
|
export declare type MRT_FilterOption = keyof typeof MRT_FilterFns;
|
223
224
|
export declare type MRT_FilterFn<TData extends Record<string, any> = {}> = FilterFn<TData> | MRT_FilterOption;
|
224
|
-
export declare type
|
225
|
+
export declare type MRT_DisplayColumnIds = 'mrt-row-drag' | 'mrt-row-actions' | 'mrt-row-expand' | 'mrt-row-select' | 'mrt-row-numbers';
|
226
|
+
/**
|
227
|
+
* `columns` and `data` props are the only required props, but there are over 150 other optional props.
|
228
|
+
*
|
229
|
+
* See more info on creating columns and data on the official docs site:
|
230
|
+
* @link https://www.material-react-table.com/docs/usage
|
231
|
+
*
|
232
|
+
* See the full props list on the official docs site:
|
233
|
+
* @link https://www.material-react-table.com/docs/api/props
|
234
|
+
*/
|
235
|
+
export declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = Omit<Partial<TableOptions<TData>>, 'columns' | 'data' | 'initialState' | 'state' | 'expandRowsFn'> & {
|
236
|
+
displayColumnDefOptions?: Partial<{
|
237
|
+
[key in MRT_DisplayColumnIds]: Partial<MRT_ColumnDef>;
|
238
|
+
}>;
|
239
|
+
columns: MRT_ColumnDef<TData>[];
|
240
|
+
data: TData[];
|
225
241
|
editingMode?: 'table' | 'row' | 'cell';
|
226
242
|
enableClickToCopy?: boolean;
|
227
243
|
enableColumnActions?: boolean;
|
244
|
+
enableColumnDragging?: boolean;
|
228
245
|
enableColumnFilterChangeMode?: boolean;
|
229
246
|
enableColumnOrdering?: boolean;
|
230
247
|
enableDensityToggle?: boolean;
|
@@ -235,7 +252,9 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
235
252
|
enableGlobalFilterRankedResults?: boolean;
|
236
253
|
enablePagination?: boolean;
|
237
254
|
enableRowActions?: boolean;
|
255
|
+
enableRowDragging?: boolean;
|
238
256
|
enableRowNumbers?: boolean;
|
257
|
+
enableRowOrdering?: boolean;
|
239
258
|
enableRowVirtualization?: boolean;
|
240
259
|
enableSelectAll?: boolean;
|
241
260
|
enableStickyHeader?: boolean;
|
@@ -246,7 +265,9 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
246
265
|
enableToolbarTop?: boolean;
|
247
266
|
enabledColumnFilterOptions?: (MRT_FilterOption | string)[] | null;
|
248
267
|
enabledGlobalFilterOptions?: (MRT_FilterOption | string)[] | null;
|
268
|
+
expandRowsFn?: (dataRow: TData) => TData[];
|
249
269
|
icons?: Partial<MRT_Icons>;
|
270
|
+
initialState?: Partial<MRT_TableState<TData>>;
|
250
271
|
localization?: Partial<MRT_Localization>;
|
251
272
|
muiExpandAllButtonProps?: IconButtonProps | (({ table }: {
|
252
273
|
table: MRT_TableInstance<TData>;
|
@@ -288,6 +309,10 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
288
309
|
muiTableBodyProps?: TableBodyProps | (({ table }: {
|
289
310
|
table: MRT_TableInstance<TData>;
|
290
311
|
}) => TableBodyProps);
|
312
|
+
muiTableBodyRowDragHandleProps?: IconButtonProps | (({ table, row, }: {
|
313
|
+
table: MRT_TableInstance<TData>;
|
314
|
+
row: MRT_Row<TData>;
|
315
|
+
}) => IconButtonProps);
|
291
316
|
muiTableBodyRowProps?: TableRowProps | (({ table, row, }: {
|
292
317
|
table: MRT_TableInstance<TData>;
|
293
318
|
row: MRT_Row<TData>;
|
@@ -314,6 +339,10 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
314
339
|
table: MRT_TableInstance<TData>;
|
315
340
|
column: MRT_Column<TData>;
|
316
341
|
}) => IconButtonProps);
|
342
|
+
muiTableHeadCellDragHandleProps?: IconButtonProps | (({ table, column, }: {
|
343
|
+
table: MRT_TableInstance<TData>;
|
344
|
+
column: MRT_Column<TData>;
|
345
|
+
}) => IconButtonProps);
|
317
346
|
muiTableHeadCellFilterTextFieldProps?: TextFieldProps | (({ table, column, }: {
|
318
347
|
table: MRT_TableInstance<TData>;
|
319
348
|
column: MRT_Column<TData>;
|
@@ -357,7 +386,13 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
357
386
|
cell: MRT_Cell<TData>;
|
358
387
|
table: MRT_TableInstance<TData>;
|
359
388
|
}) => void;
|
389
|
+
onColumnDrop?: ({ event, draggedColumn, targetColumn, }: {
|
390
|
+
event: DragEvent<HTMLButtonElement>;
|
391
|
+
draggedColumn: MRT_Column<TData>;
|
392
|
+
targetColumn: MRT_Column<TData> | null;
|
393
|
+
}) => void;
|
360
394
|
onCurrentDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
395
|
+
onCurrentDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
361
396
|
onCurrentEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
362
397
|
onCurrentEditingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
363
398
|
onCurrentFilterFnsChange?: OnChangeFn<{
|
@@ -365,12 +400,18 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
365
400
|
}>;
|
366
401
|
onCurrentGlobalFilterFnChange?: OnChangeFn<MRT_FilterOption>;
|
367
402
|
onCurrentHoveredColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
403
|
+
onCurrentHoveredRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
404
|
+
onDensityChange?: OnChangeFn<boolean>;
|
368
405
|
onEditRowSubmit?: ({ row, table, }: {
|
369
406
|
row: MRT_Row<TData>;
|
370
407
|
table: MRT_TableInstance<TData>;
|
371
408
|
}) => Promise<void> | void;
|
372
|
-
onDensityChange?: OnChangeFn<boolean>;
|
373
409
|
onIsFullScreenChange?: OnChangeFn<boolean>;
|
410
|
+
onRowDrop?: ({ event, draggedRow, targetRow, }: {
|
411
|
+
event: DragEvent<HTMLButtonElement>;
|
412
|
+
draggedRow: MRT_Row<TData>;
|
413
|
+
targetRow: MRT_Row<TData> | null;
|
414
|
+
}) => void;
|
374
415
|
onShowAlertBannerChange?: OnChangeFn<boolean>;
|
375
416
|
onShowFiltersChange?: OnChangeFn<boolean>;
|
376
417
|
onShowGlobalFilterChange?: OnChangeFn<boolean>;
|
@@ -394,9 +435,6 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
394
435
|
renderToolbarBottomCustomActions?: ({ table, }: {
|
395
436
|
table: MRT_TableInstance<TData>;
|
396
437
|
}) => ReactNode;
|
397
|
-
renderToolbarTopCustomActions?: ({ table, }: {
|
398
|
-
table: MRT_TableInstance<TData>;
|
399
|
-
}) => ReactNode;
|
400
438
|
renderToolbarInternalActions?: ({ table, MRT_ToggleGlobalFilterButton, MRT_ToggleFiltersButton, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_FullScreenToggleButton, }: {
|
401
439
|
table: MRT_TableInstance<TData>;
|
402
440
|
MRT_ToggleGlobalFilterButton: FC<IconButtonProps & {
|
@@ -415,20 +453,15 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
415
453
|
table: MRT_TableInstance<TData>;
|
416
454
|
}>;
|
417
455
|
}) => ReactNode;
|
456
|
+
renderToolbarTopCustomActions?: ({ table, }: {
|
457
|
+
table: MRT_TableInstance<TData>;
|
458
|
+
}) => ReactNode;
|
418
459
|
rowCount?: number;
|
419
460
|
rowNumberMode?: 'original' | 'static';
|
420
461
|
selectAllMode?: 'all' | 'page';
|
462
|
+
state?: Partial<MRT_TableState<TData>>;
|
421
463
|
tableId?: string;
|
422
464
|
virtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement>>;
|
423
465
|
};
|
424
466
|
declare const _default: <TData extends Record<string, any> = {}>({ autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableColumnActions, enableColumnFilterChangeMode, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterChangeMode, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarBottom, enableToolbarInternalActions, enableToolbarTop, icons, localization, positionActionsColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, rowNumberMode, selectAllMode, ...rest }: MaterialReactTableProps<TData>) => JSX.Element;
|
425
|
-
/**
|
426
|
-
* `columns` and `data` props are the only required props, but there are over 150 other optional props.
|
427
|
-
*
|
428
|
-
* See more info on creating columns and data on the official docs site:
|
429
|
-
* @link https://www.material-react-table.com/docs/usage
|
430
|
-
*
|
431
|
-
* See the full props list on the official docs site:
|
432
|
-
* @link https://www.material-react-table.com/docs/api/props
|
433
|
-
*/
|
434
467
|
export default _default;
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import { FC } from 'react';
|
1
|
+
import { FC, RefObject } from 'react';
|
2
2
|
import type { MRT_Cell, MRT_TableInstance } from '..';
|
3
3
|
interface Props {
|
4
4
|
cell: MRT_Cell;
|
5
5
|
enableHover?: boolean;
|
6
6
|
rowIndex: number;
|
7
|
+
rowRef: RefObject<HTMLTableRowElement>;
|
7
8
|
table: MRT_TableInstance;
|
8
9
|
}
|
9
10
|
export declare const MRT_TableBodyCell: FC<Props>;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { FC, RefObject } from 'react';
|
2
|
+
import { MRT_Cell, MRT_TableInstance } from '..';
|
3
|
+
interface Props {
|
4
|
+
cell: MRT_Cell;
|
5
|
+
rowRef: RefObject<HTMLTableRowElement>;
|
6
|
+
table: MRT_TableInstance;
|
7
|
+
}
|
8
|
+
export declare const MRT_TableBodyRowGrabHandle: FC<Props>;
|
9
|
+
export {};
|
@@ -1,8 +1,10 @@
|
|
1
|
+
import { IconButtonProps } from '@mui/material';
|
1
2
|
import { DragEventHandler, FC } from 'react';
|
2
3
|
import { MRT_TableInstance } from '..';
|
3
4
|
interface Props {
|
4
|
-
|
5
|
-
|
5
|
+
iconButtonProps?: IconButtonProps;
|
6
|
+
onDragStart: DragEventHandler<HTMLButtonElement>;
|
7
|
+
onDragEnd: DragEventHandler<HTMLButtonElement>;
|
6
8
|
table: MRT_TableInstance;
|
7
9
|
}
|
8
10
|
export declare const MRT_GrabHandleButton: FC<Props>;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { FC, RefObject } from 'react';
|
2
|
+
import type { MRT_Column, MRT_TableInstance } from '..';
|
3
|
+
interface Props {
|
4
|
+
column: MRT_Column;
|
5
|
+
table: MRT_TableInstance;
|
6
|
+
tableHeadCellRef: RefObject<HTMLTableCellElement>;
|
7
|
+
}
|
8
|
+
export declare const MRT_TableHeadCellGrabHandle: FC<Props>;
|
9
|
+
export {};
|