material-react-table 0.40.9 → 0.40.12
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.
- package/README.md +15 -13
- package/dist/cjs/MaterialReactTable.d.ts +8 -4
- package/dist/cjs/column.utils.d.ts +81 -76
- package/dist/cjs/index.js +81 -52
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +8 -4
- package/dist/esm/column.utils.d.ts +81 -76
- package/dist/esm/material-react-table.esm.js +81 -52
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +24 -2
- package/src/buttons/MRT_CopyButton.tsx +7 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +2 -1
- package/src/buttons/MRT_ExpandButton.tsx +2 -1
- package/src/buttons/MRT_FullScreenToggleButton.tsx +2 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +2 -1
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +2 -1
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -1
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -1
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +2 -2
- package/src/column.utils.ts +18 -25
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +2 -1
- package/src/inputs/MRT_FilterTextField.tsx +18 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +5 -1
- package/src/table/MRT_TableRoot.tsx +18 -13
package/README.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
# Material React Table
|
|
2
2
|
|
|
3
|
-
__Built with [Material UI <sup>V5</sup>](https://mui.com) and [TanStack Table <sup>V8</sup>](https://tanstack.com/table/v8)__
|
|
4
|
-
|
|
5
|
-
_Quickly Create React Data Tables with Material Design_
|
|
6
|
-
|
|
7
3
|
<a href="https://npmjs.com/package/material-react-table" target="_blank">
|
|
8
4
|
<img alt="" src="https://badgen.net/npm/v/material-react-table?color=blue" />
|
|
9
5
|
</a>
|
|
@@ -25,12 +21,9 @@ _Quickly Create React Data Tables with Material Design_
|
|
|
25
21
|
|
|
26
22
|
## About
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
__Built with [Material UI <sup>V5</sup>](https://mui.com) and [TanStack Table <sup>V8</sup>](https://tanstack.com/table/v8)__
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
- Inspired by material-table and the MUI X DataGrid
|
|
32
|
-
- Written from the ground up in TypeScript
|
|
33
|
-
- All internal Material UI components are easily customizable
|
|
26
|
+
_Quickly Create React Data Tables with Material Design_
|
|
34
27
|
|
|
35
28
|
Join the [Discord](https://discord.gg/5wqyRx6fnm) server to join in on the development discussion or ask questions
|
|
36
29
|
|
|
@@ -114,7 +107,7 @@ npm install material-react-table
|
|
|
114
107
|
> Read the full usage docs [here](https://www.material-react-table.com/docs/getting-started/usage/)
|
|
115
108
|
|
|
116
109
|
```jsx
|
|
117
|
-
import React, { useMemo, useState, useEffect } from 'react';
|
|
110
|
+
import React, { useMemo, useRef, useState, useEffect } from 'react';
|
|
118
111
|
import MaterialReactTable from 'material-react-table';
|
|
119
112
|
|
|
120
113
|
export default function App() {
|
|
@@ -129,7 +122,7 @@ export default function App() {
|
|
|
129
122
|
accessorFn: (row) => row.age, //alternate way
|
|
130
123
|
id: 'age', //id required if you use accessorFn instead of accessorKey
|
|
131
124
|
header: 'Age',
|
|
132
|
-
Header: <i
|
|
125
|
+
Header: <i>Age</i>, //optional custom markup
|
|
133
126
|
},
|
|
134
127
|
],
|
|
135
128
|
[],
|
|
@@ -156,15 +149,24 @@ export default function App() {
|
|
|
156
149
|
//do something when the row selection changes
|
|
157
150
|
}, [rowSelection]);
|
|
158
151
|
|
|
152
|
+
//Or, optionally, you can get a reference to the underlying table instance
|
|
153
|
+
const tableInstanceRef = useRef(null);
|
|
154
|
+
|
|
155
|
+
const someEventHandler = () => {
|
|
156
|
+
//read the table state during an event from the table instance ref
|
|
157
|
+
console.log(tableInstanceRef.current.getState().sorting);
|
|
158
|
+
}
|
|
159
|
+
|
|
159
160
|
return (
|
|
160
161
|
<MaterialReactTable
|
|
161
162
|
columns={columns}
|
|
162
163
|
data={data}
|
|
163
164
|
enableColumnOrdering //enable some features
|
|
164
165
|
enableRowSelection
|
|
165
|
-
|
|
166
|
+
enablePagination={false} //disable a default feature
|
|
166
167
|
onRowSelectionChange={setRowSelection} //hoist internal state to your own state (optional)
|
|
167
168
|
state={{ rowSelection }} //manage your own state, pass it back to the table (optional)
|
|
169
|
+
tableInstanceRef={tableInstanceRef} //get a reference to the underlying table instance (optional)
|
|
168
170
|
/>
|
|
169
171
|
);
|
|
170
172
|
}
|
|
@@ -178,4 +180,4 @@ _Open in [Code Sandbox](https://codesandbox.io/s/simple-material-react-table-exa
|
|
|
178
180
|
<img src="https://contrib.rocks/image?repo=kevinvandy/material-react-table" />
|
|
179
181
|
</a>
|
|
180
182
|
|
|
181
|
-
PRs are Welcome, but please discuss in [GitHub Discussions](https://github.com/KevinVandy/material-react-table/discussions) or the [Discord Server](https://discord.gg/5wqyRx6fnm) first!
|
|
183
|
+
PRs are Welcome, but please discuss in [GitHub Discussions](https://github.com/KevinVandy/material-react-table/discussions) or the [Discord Server](https://discord.gg/5wqyRx6fnm) first if it is a large change!
|
|
@@ -181,9 +181,11 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
181
181
|
* @default gets set to the same value as `accessorKey` by default
|
|
182
182
|
*/
|
|
183
183
|
id?: LiteralUnion<string & keyof TData>;
|
|
184
|
-
muiTableBodyCellCopyButtonProps?: ButtonProps | (({ cell, table, }: {
|
|
185
|
-
table: MRT_TableInstance<TData>;
|
|
184
|
+
muiTableBodyCellCopyButtonProps?: ButtonProps | (({ cell, column, row, table, }: {
|
|
186
185
|
cell: MRT_Cell<TData>;
|
|
186
|
+
column: MRT_Column<TData>;
|
|
187
|
+
row: MRT_Row<TData>;
|
|
188
|
+
table: MRT_TableInstance<TData>;
|
|
187
189
|
}) => ButtonProps);
|
|
188
190
|
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, column, row, table, }: {
|
|
189
191
|
cell: MRT_Cell<TData>;
|
|
@@ -229,7 +231,8 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
229
231
|
}) => ReactNode[];
|
|
230
232
|
sortingFn?: MRT_SortingFn;
|
|
231
233
|
};
|
|
232
|
-
export declare type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> = Omit<MRT_ColumnDef<TData>, 'id'> & {
|
|
234
|
+
export declare type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> = Omit<MRT_ColumnDef<TData>, 'id' | 'defaultDisplayColumn'> & {
|
|
235
|
+
defaultDisplayColumn: Partial<MRT_ColumnDef<TData>>;
|
|
233
236
|
id: string;
|
|
234
237
|
_filterFn: MRT_FilterOption;
|
|
235
238
|
};
|
|
@@ -281,6 +284,7 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
281
284
|
columns: MRT_ColumnDef<TData>[];
|
|
282
285
|
data: TData[];
|
|
283
286
|
defaultColumn?: Partial<MRT_ColumnDef<TData>>;
|
|
287
|
+
defaultDisplayColumn?: Partial<MRT_ColumnDef<TData>>;
|
|
284
288
|
displayColumnDefOptions?: Partial<{
|
|
285
289
|
[key in MRT_DisplayColumnIds]: Partial<MRT_ColumnDef>;
|
|
286
290
|
}>;
|
|
@@ -530,5 +534,5 @@ export declare type Virtualizer = {
|
|
|
530
534
|
scrollToIndex: (index: number, options?: any | undefined) => void;
|
|
531
535
|
measure: () => void;
|
|
532
536
|
};
|
|
533
|
-
declare const _default: <TData extends Record<string, any> = {}>({ aggregationFns, autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableBottomToolbar, enableColumnActions, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarInternalActions, enableTopToolbar, filterFns, icons, localization, positionActionsColumn, positionExpandColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, rowNumberMode, selectAllMode, sortingFns, ...rest }: MaterialReactTableProps<TData>) => JSX.Element;
|
|
537
|
+
declare const _default: <TData extends Record<string, any> = {}>({ aggregationFns, autoResetExpanded, columnResizeMode, defaultColumn, defaultDisplayColumn, editingMode, enableBottomToolbar, enableColumnActions, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarInternalActions, enableTopToolbar, filterFns, icons, localization, positionActionsColumn, positionExpandColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, rowNumberMode, selectAllMode, sortingFns, ...rest }: MaterialReactTableProps<TData>) => JSX.Element;
|
|
534
538
|
export default _default;
|
|
@@ -2,85 +2,90 @@ import { ColumnOrderState, GroupingState } from '@tanstack/react-table';
|
|
|
2
2
|
import { MaterialReactTableProps, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterOption } from '.';
|
|
3
3
|
import { MRT_FilterFns } from './filterFns';
|
|
4
4
|
import { MRT_SortingFns } from './sortingFns';
|
|
5
|
-
export declare const defaultDisplayColumnDefOptions: Partial<MRT_ColumnDef<{}>>;
|
|
6
5
|
export declare const getColumnId: <TData extends Record<string, any> = {}>(columnDef: MRT_ColumnDef<TData>) => string;
|
|
7
6
|
export declare const getAllLeafColumnDefs: <TData extends Record<string, any> = {}>(columns: MRT_ColumnDef<TData>[]) => MRT_ColumnDef<TData>[];
|
|
8
|
-
export declare const prepareColumns: <TData extends Record<string, any> = {}>(columnDefs
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<TData_1 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_1>, id: string, filterValues: [string | number, string | number]): boolean;
|
|
13
|
-
autoRemove(val: any): boolean;
|
|
7
|
+
export declare const prepareColumns: <TData extends Record<string, any> = {}>({ columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }: {
|
|
8
|
+
columnDefs: MRT_ColumnDef<TData>[];
|
|
9
|
+
columnFilterFns: {
|
|
10
|
+
[key: string]: MRT_FilterOption;
|
|
14
11
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
12
|
+
defaultDisplayColumn: Partial<MRT_ColumnDef<TData>>;
|
|
13
|
+
filterFns: {
|
|
14
|
+
between: {
|
|
15
|
+
<TData_1 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_1>, id: string, filterValues: [string | number, string | number]): boolean;
|
|
16
|
+
autoRemove(val: any): boolean;
|
|
17
|
+
};
|
|
18
|
+
betweenInclusive: {
|
|
19
|
+
<TData_2 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_2>, id: string, filterValues: [string | number, string | number]): boolean;
|
|
20
|
+
autoRemove(val: any): boolean;
|
|
21
|
+
};
|
|
22
|
+
contains: {
|
|
23
|
+
<TData_3 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_3>, id: string, filterValue: string | number): boolean;
|
|
24
|
+
autoRemove(val: any): boolean;
|
|
25
|
+
};
|
|
26
|
+
empty: {
|
|
27
|
+
<TData_4 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_4>, id: string, _filterValue: string | number): boolean;
|
|
28
|
+
autoRemove(val: any): boolean;
|
|
29
|
+
};
|
|
30
|
+
endsWith: {
|
|
31
|
+
<TData_5 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_5>, id: string, filterValue: string | number): boolean;
|
|
32
|
+
autoRemove(val: any): boolean;
|
|
33
|
+
};
|
|
34
|
+
equals: {
|
|
35
|
+
<TData_6 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_6>, id: string, filterValue: string | number): boolean;
|
|
36
|
+
autoRemove(val: any): boolean;
|
|
37
|
+
};
|
|
38
|
+
fuzzy: {
|
|
39
|
+
<TData_7 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_7>, columnId: string, filterValue: string | number, addMeta: (item: import("@tanstack/match-sorter-utils").RankingInfo) => void): boolean;
|
|
40
|
+
autoRemove(val: any): boolean;
|
|
41
|
+
};
|
|
42
|
+
greaterThan: {
|
|
43
|
+
<TData_8 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_8>, id: string, filterValue: string | number): boolean;
|
|
44
|
+
autoRemove(val: any): boolean;
|
|
45
|
+
};
|
|
46
|
+
greaterThanOrEqualTo: {
|
|
47
|
+
<TData_9 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_9>, id: string, filterValue: string | number): boolean;
|
|
48
|
+
autoRemove(val: any): boolean;
|
|
49
|
+
};
|
|
50
|
+
lessThan: {
|
|
51
|
+
<TData_10 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_10>, id: string, filterValue: string | number): boolean;
|
|
52
|
+
autoRemove(val: any): boolean;
|
|
53
|
+
};
|
|
54
|
+
lessThanOrEqualTo: {
|
|
55
|
+
<TData_11 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_11>, id: string, filterValue: string | number): boolean;
|
|
56
|
+
autoRemove(val: any): boolean;
|
|
57
|
+
};
|
|
58
|
+
notEmpty: {
|
|
59
|
+
<TData_12 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_12>, id: string, _filterValue: string | number): boolean;
|
|
60
|
+
autoRemove(val: any): boolean;
|
|
61
|
+
};
|
|
62
|
+
notEquals: {
|
|
63
|
+
<TData_13 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_13>, id: string, filterValue: string | number): boolean;
|
|
64
|
+
autoRemove(val: any): boolean;
|
|
65
|
+
};
|
|
66
|
+
startsWith: {
|
|
67
|
+
<TData_14 extends Record<string, any> = {}>(row: import("@tanstack/table-core").Row<TData_14>, id: string, filterValue: string | number): boolean;
|
|
68
|
+
autoRemove(val: any): boolean;
|
|
69
|
+
};
|
|
70
|
+
includesString: import("@tanstack/table-core").FilterFn<any>;
|
|
71
|
+
includesStringSensitive: import("@tanstack/table-core").FilterFn<any>;
|
|
72
|
+
equalsString: import("@tanstack/table-core").FilterFn<any>;
|
|
73
|
+
arrIncludes: import("@tanstack/table-core").FilterFn<any>;
|
|
74
|
+
arrIncludesAll: import("@tanstack/table-core").FilterFn<any>;
|
|
75
|
+
arrIncludesSome: import("@tanstack/table-core").FilterFn<any>;
|
|
76
|
+
weakEquals: import("@tanstack/table-core").FilterFn<any>;
|
|
77
|
+
inNumberRange: import("@tanstack/table-core").FilterFn<any>;
|
|
78
|
+
} & Record<string, import("@tanstack/table-core").FilterFn<any>>;
|
|
79
|
+
sortingFns: {
|
|
80
|
+
fuzzy: <TData_15 extends Record<string, any> = {}>(rowA: import("@tanstack/table-core").Row<TData_15>, rowB: import("@tanstack/table-core").Row<TData_15>, columnId: string) => number;
|
|
81
|
+
alphanumeric: import("@tanstack/table-core").SortingFn<any>;
|
|
82
|
+
alphanumericCaseSensitive: import("@tanstack/table-core").SortingFn<any>;
|
|
83
|
+
text: import("@tanstack/table-core").SortingFn<any>;
|
|
84
|
+
textCaseSensitive: import("@tanstack/table-core").SortingFn<any>;
|
|
85
|
+
datetime: import("@tanstack/table-core").SortingFn<any>;
|
|
86
|
+
basic: import("@tanstack/table-core").SortingFn<any>;
|
|
87
|
+
} & Record<string, import("@tanstack/table-core").SortingFn<any>>;
|
|
88
|
+
}) => MRT_DefinedColumnDef<TData>[];
|
|
84
89
|
export declare const reorderColumn: <TData extends Record<string, any> = {}>(draggedColumn: MRT_Column<TData>, targetColumn: MRT_Column<TData>, columnOrder: ColumnOrderState) => ColumnOrderState;
|
|
85
90
|
export declare const showExpandColumn: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>, grouping?: GroupingState) => boolean;
|
|
86
91
|
export declare const getLeadingDisplayColumnIds: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => MRT_DisplayColumnIds[];
|