material-react-table 0.8.13 → 0.8.14
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/dist/MaterialReactTable.d.ts +2 -1
- package/dist/material-react-table.cjs.development.js +32 -22
- 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 +33 -23
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +3 -0
- package/src/inputs/MRT_SelectCheckbox.tsx +6 -1
- package/src/table/MRT_TableRoot.tsx +21 -14
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.8.
|
|
2
|
+
"version": "0.8.14",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -760,6 +760,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
760
760
|
IconButtonProps & { tableInstance: MRT_TableInstance<D> }
|
|
761
761
|
>;
|
|
762
762
|
}) => ReactNode;
|
|
763
|
+
selectAllMode?: 'all' | 'page';
|
|
763
764
|
};
|
|
764
765
|
|
|
765
766
|
export default <D extends Record<string, any> = {}>({
|
|
@@ -796,6 +797,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
796
797
|
positionPagination = 'bottom',
|
|
797
798
|
positionToolbarActions = 'top',
|
|
798
799
|
positionToolbarAlertBanner = 'top',
|
|
800
|
+
selectAllMode = 'all',
|
|
799
801
|
...rest
|
|
800
802
|
}: MaterialReactTableProps<D>) => (
|
|
801
803
|
<MRT_TableRoot
|
|
@@ -832,6 +834,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
832
834
|
positionPagination={positionPagination}
|
|
833
835
|
positionToolbarActions={positionToolbarActions}
|
|
834
836
|
positionToolbarAlertBanner={positionToolbarAlertBanner}
|
|
837
|
+
selectAllMode={selectAllMode}
|
|
835
838
|
{...rest}
|
|
836
839
|
/>
|
|
837
840
|
);
|
|
@@ -22,6 +22,7 @@ export const MRT_SelectCheckbox: FC<Props> = ({
|
|
|
22
22
|
muiSelectCheckboxProps,
|
|
23
23
|
onSelectChange,
|
|
24
24
|
onSelectAllChange,
|
|
25
|
+
selectAllMode,
|
|
25
26
|
},
|
|
26
27
|
} = tableInstance;
|
|
27
28
|
|
|
@@ -29,7 +30,11 @@ export const MRT_SelectCheckbox: FC<Props> = ({
|
|
|
29
30
|
|
|
30
31
|
const handleSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
31
32
|
if (selectAll) {
|
|
32
|
-
|
|
33
|
+
if (selectAllMode === 'all') {
|
|
34
|
+
tableInstance.getToggleAllRowsSelectedHandler()(event as any);
|
|
35
|
+
} else if (selectAllMode === 'page') {
|
|
36
|
+
tableInstance.getToggleAllPageRowsSelectedHandler()(event as any);
|
|
37
|
+
}
|
|
33
38
|
onSelectAllChange?.({
|
|
34
39
|
event,
|
|
35
40
|
selectedRows: event.target.checked ? getRowModel().flatRows : [],
|
|
@@ -133,7 +133,24 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
133
133
|
MRT_FILTER_OPTION | FilterFn<ReactTableGenerics> | string | number | symbol
|
|
134
134
|
>(props.globalFilterFn ?? MRT_FILTER_OPTION.FUZZY);
|
|
135
135
|
|
|
136
|
-
const table = useMemo(
|
|
136
|
+
const table = useMemo(
|
|
137
|
+
() =>
|
|
138
|
+
createTable().setOptions({
|
|
139
|
+
//@ts-ignore
|
|
140
|
+
filterFns: defaultFilterFNs,
|
|
141
|
+
getCoreRowModel: getCoreRowModel(),
|
|
142
|
+
getExpandedRowModel: getExpandedRowModel(),
|
|
143
|
+
getFacetedRowModel: getFacetedRowModel(),
|
|
144
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
145
|
+
getGroupedRowModel: getGroupedRowModel(),
|
|
146
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
147
|
+
getSortedRowModel: getSortedRowModel(),
|
|
148
|
+
getSubRows: (row) => (row as MRT_Row)?.subRows,
|
|
149
|
+
idPrefix,
|
|
150
|
+
initialState,
|
|
151
|
+
}),
|
|
152
|
+
[],
|
|
153
|
+
);
|
|
137
154
|
|
|
138
155
|
const displayColumns = useMemo(
|
|
139
156
|
() =>
|
|
@@ -238,24 +255,14 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
238
255
|
|
|
239
256
|
//@ts-ignore
|
|
240
257
|
const tableInstance = {
|
|
258
|
+
//@ts-ignore
|
|
241
259
|
...useTableInstance(table, {
|
|
242
|
-
filterFns: defaultFilterFNs,
|
|
243
|
-
getCoreRowModel: getCoreRowModel(),
|
|
244
|
-
getExpandedRowModel: getExpandedRowModel(),
|
|
245
|
-
getFacetedRowModel: getFacetedRowModel(),
|
|
246
|
-
getFilteredRowModel: getFilteredRowModel(),
|
|
247
|
-
getGroupedRowModel: getGroupedRowModel(),
|
|
248
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
249
|
-
getSortedRowModel: getSortedRowModel(),
|
|
250
|
-
getSubRows: (row) => (row as MRT_Row)?.subRows,
|
|
251
|
-
//@ts-ignore
|
|
252
|
-
globalFilterFn: currentGlobalFilterFn,
|
|
253
260
|
...props,
|
|
254
261
|
//@ts-ignore
|
|
255
262
|
columns,
|
|
256
263
|
data,
|
|
257
|
-
|
|
258
|
-
|
|
264
|
+
//@ts-ignore
|
|
265
|
+
globalFilterFn: currentGlobalFilterFn,
|
|
259
266
|
state: {
|
|
260
267
|
currentEditingCell,
|
|
261
268
|
currentEditingRow,
|