material-react-table 0.40.1 → 0.40.4
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/cjs/MaterialReactTable.d.ts +5 -3
- package/dist/cjs/index.js +37 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +1 -1
- package/dist/cjs/menus/MRT_RowActionMenu.d.ts +2 -2
- package/dist/esm/MaterialReactTable.d.ts +5 -3
- package/dist/esm/material-react-table.esm.js +37 -15
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +1 -1
- package/dist/esm/menus/MRT_RowActionMenu.d.ts +2 -2
- package/dist/index.d.ts +5 -3
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +7 -5
- package/src/buttons/MRT_CopyButton.tsx +4 -3
- package/src/buttons/MRT_EditActionButtons.tsx +4 -1
- package/src/buttons/MRT_ExpandButton.tsx +5 -3
- package/src/buttons/MRT_GrabHandleButton.tsx +4 -0
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +8 -3
- package/src/inputs/MRT_EditCellTextField.tsx +4 -2
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -0
- package/src/menus/MRT_FilterOptionMenu.tsx +9 -3
- package/src/menus/MRT_RowActionMenu.tsx +2 -2
|
@@ -4,7 +4,7 @@ import { MRT_Localization } from '../localization';
|
|
|
4
4
|
export declare const mrtFilterOptions: (localization: MRT_Localization) => MRT_InternalFilterOption[];
|
|
5
5
|
interface Props<TData extends Record<string, any> = {}> {
|
|
6
6
|
anchorEl: HTMLElement | null;
|
|
7
|
-
header?: MRT_Header
|
|
7
|
+
header?: MRT_Header<TData>;
|
|
8
8
|
onSelect?: () => void;
|
|
9
9
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
10
10
|
table: MRT_TableInstance<TData>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, MouseEvent } from 'react';
|
|
2
2
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
3
3
|
interface Props {
|
|
4
4
|
anchorEl: HTMLElement | null;
|
|
5
|
-
handleEdit: () => void;
|
|
5
|
+
handleEdit: (event: MouseEvent) => void;
|
|
6
6
|
row: MRT_Row;
|
|
7
7
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
8
8
|
table: MRT_TableInstance;
|
package/dist/index.d.ts
CHANGED
|
@@ -408,10 +408,12 @@ declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<Column
|
|
|
408
408
|
table: MRT_TableInstance<TData>;
|
|
409
409
|
column: MRT_Column<TData>;
|
|
410
410
|
}) => TableCellProps);
|
|
411
|
-
renderColumnFilterModeMenuItems?: ({
|
|
412
|
-
table: MRT_TableInstance<TData>;
|
|
411
|
+
renderColumnFilterModeMenuItems?: ({ column, internalFilterOptions, onSelectFilterMode, table, }: {
|
|
413
412
|
column: MRT_Column<TData>;
|
|
414
|
-
|
|
413
|
+
internalFilterOptions: MRT_InternalFilterOption[];
|
|
414
|
+
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
415
|
+
table: MRT_TableInstance<TData>;
|
|
416
|
+
}) => ReactNode;
|
|
415
417
|
sortingFn?: MRT_SortingFn;
|
|
416
418
|
};
|
|
417
419
|
declare type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> = Omit<MRT_ColumnDef<TData>, 'id'> & {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.40.
|
|
2
|
+
"version": "0.40.4",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"storybook": "start-storybook -p 6006"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@babel/core": "^7.18.
|
|
52
|
+
"@babel/core": "^7.18.13",
|
|
53
53
|
"@babel/preset-react": "^7.18.6",
|
|
54
54
|
"@emotion/react": "^11.10.0",
|
|
55
55
|
"@emotion/styled": "^11.10.0",
|
|
56
56
|
"@faker-js/faker": "^7.4.0",
|
|
57
|
-
"@mui/icons-material": "^5.
|
|
58
|
-
"@mui/material": "^5.10.
|
|
57
|
+
"@mui/icons-material": "^5.10.2",
|
|
58
|
+
"@mui/material": "^5.10.2",
|
|
59
59
|
"@rollup/plugin-babel": "^5.3.1",
|
|
60
60
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
61
61
|
"@rollup/plugin-typescript": "^8.3.4",
|
|
@@ -363,12 +363,16 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
363
363
|
column: MRT_Column<TData>;
|
|
364
364
|
}) => TableCellProps);
|
|
365
365
|
renderColumnFilterModeMenuItems?: ({
|
|
366
|
-
table,
|
|
367
366
|
column,
|
|
367
|
+
internalFilterOptions,
|
|
368
|
+
onSelectFilterMode,
|
|
369
|
+
table,
|
|
368
370
|
}: {
|
|
369
|
-
table: MRT_TableInstance<TData>;
|
|
370
371
|
column: MRT_Column<TData>;
|
|
371
|
-
|
|
372
|
+
internalFilterOptions: MRT_InternalFilterOption[];
|
|
373
|
+
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
374
|
+
table: MRT_TableInstance<TData>;
|
|
375
|
+
}) => ReactNode;
|
|
372
376
|
sortingFn?: MRT_SortingFn;
|
|
373
377
|
};
|
|
374
378
|
|
|
@@ -920,7 +924,6 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
920
924
|
editingMode={editingMode}
|
|
921
925
|
enableBottomToolbar={enableBottomToolbar}
|
|
922
926
|
enableColumnActions={enableColumnActions}
|
|
923
|
-
enableColumnFilterModes={enableColumnFilterModes}
|
|
924
927
|
enableColumnFilters={enableColumnFilters}
|
|
925
928
|
enableColumnOrdering={enableColumnOrdering}
|
|
926
929
|
enableColumnResizing={enableColumnResizing}
|
|
@@ -929,7 +932,6 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
929
932
|
enableFilters={enableFilters}
|
|
930
933
|
enableFullScreenToggle={enableFullScreenToggle}
|
|
931
934
|
enableGlobalFilter={enableGlobalFilter}
|
|
932
|
-
enableGlobalFilterModes={enableGlobalFilterModes}
|
|
933
935
|
enableGlobalFilterRankedResults={enableGlobalFilterRankedResults}
|
|
934
936
|
enableGrouping={enableGrouping}
|
|
935
937
|
enableHiding={enableHiding}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactNode, useState } from 'react';
|
|
1
|
+
import React, { MouseEvent, ReactNode, useState } from 'react';
|
|
2
2
|
import { Button, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_Cell, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -21,7 +21,8 @@ export const MRT_CopyButton = <TData extends Record<string, any> = {}>({
|
|
|
21
21
|
|
|
22
22
|
const [copied, setCopied] = useState(false);
|
|
23
23
|
|
|
24
|
-
const handleCopy = (text: unknown) => {
|
|
24
|
+
const handleCopy = (event: MouseEvent, text: unknown) => {
|
|
25
|
+
event.stopPropagation();
|
|
25
26
|
navigator.clipboard.writeText(text as string);
|
|
26
27
|
setCopied(true);
|
|
27
28
|
setTimeout(() => setCopied(false), 4000);
|
|
@@ -54,7 +55,7 @@ export const MRT_CopyButton = <TData extends Record<string, any> = {}>({
|
|
|
54
55
|
title={copied ? localization.copiedToClipboard : localization.clickToCopy}
|
|
55
56
|
>
|
|
56
57
|
<Button
|
|
57
|
-
onClick={() => handleCopy(cell.getValue())}
|
|
58
|
+
onClick={(e) => handleCopy(e, cell.getValue())}
|
|
58
59
|
size="small"
|
|
59
60
|
type="button"
|
|
60
61
|
variant="text"
|
|
@@ -47,7 +47,10 @@ export const MRT_EditActionButtons = <TData extends Record<string, any> = {}>({
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
<Box
|
|
50
|
+
<Box
|
|
51
|
+
onClick={(e) => e.stopPropagation()}
|
|
52
|
+
sx={{ display: 'flex', gap: '0.75rem' }}
|
|
53
|
+
>
|
|
51
54
|
{variant === 'icon' ? (
|
|
52
55
|
<>
|
|
53
56
|
<Tooltip arrow title={localization.cancel}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -24,8 +24,10 @@ export const MRT_ExpandButton: FC<Props> = ({ row, table }) => {
|
|
|
24
24
|
? muiExpandButtonProps({ table, row })
|
|
25
25
|
: muiExpandButtonProps;
|
|
26
26
|
|
|
27
|
-
const handleToggleExpand = () => {
|
|
27
|
+
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
28
|
+
event.stopPropagation();
|
|
28
29
|
row.toggleExpanded();
|
|
30
|
+
iconButtonProps?.onClick?.(event);
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
return (
|
|
@@ -39,8 +41,8 @@ export const MRT_ExpandButton: FC<Props> = ({ row, table }) => {
|
|
|
39
41
|
<IconButton
|
|
40
42
|
aria-label={localization.expand}
|
|
41
43
|
disabled={!row.getCanExpand() && !renderDetailPanel}
|
|
42
|
-
onClick={handleToggleExpand}
|
|
43
44
|
{...iconButtonProps}
|
|
45
|
+
onClick={handleToggleExpand}
|
|
44
46
|
sx={(theme) => ({
|
|
45
47
|
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
46
48
|
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
@@ -37,6 +37,10 @@ export const MRT_GrabHandleButton = <TData extends Record<string, any> = {}>({
|
|
|
37
37
|
onDragEnd={onDragEnd}
|
|
38
38
|
size="small"
|
|
39
39
|
{...iconButtonProps}
|
|
40
|
+
onClick={(e) => {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
iconButtonProps?.onClick?.(e);
|
|
43
|
+
}}
|
|
40
44
|
sx={(theme) => ({
|
|
41
45
|
cursor: 'grab',
|
|
42
46
|
m: 0,
|
|
@@ -16,12 +16,16 @@ const commonIconButtonStyles = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
interface Props {
|
|
19
|
-
cell: MRT_Cell
|
|
19
|
+
cell: MRT_Cell;
|
|
20
20
|
row: MRT_Row;
|
|
21
21
|
table: MRT_TableInstance;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({
|
|
24
|
+
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({
|
|
25
|
+
cell,
|
|
26
|
+
row,
|
|
27
|
+
table,
|
|
28
|
+
}) => {
|
|
25
29
|
const {
|
|
26
30
|
getState,
|
|
27
31
|
options: {
|
|
@@ -45,7 +49,8 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ cell, row, table }) =
|
|
|
45
49
|
setAnchorEl(event.currentTarget);
|
|
46
50
|
};
|
|
47
51
|
|
|
48
|
-
const handleStartEditMode = () => {
|
|
52
|
+
const handleStartEditMode = (event: MouseEvent) => {
|
|
53
|
+
event.stopPropagation();
|
|
49
54
|
setEditingRow({ ...row });
|
|
50
55
|
setAnchorEl(null);
|
|
51
56
|
};
|
|
@@ -2,7 +2,6 @@ import React, {
|
|
|
2
2
|
ChangeEvent,
|
|
3
3
|
FocusEvent,
|
|
4
4
|
KeyboardEvent,
|
|
5
|
-
MouseEvent,
|
|
6
5
|
useState,
|
|
7
6
|
} from 'react';
|
|
8
7
|
import { TextField, TextFieldProps } from '@mui/material';
|
|
@@ -101,11 +100,14 @@ export const MRT_EditCellTextField = <TData extends Record<string, any> = {}>({
|
|
|
101
100
|
label={showLabel ? column.columnDef.header : undefined}
|
|
102
101
|
margin="none"
|
|
103
102
|
name={column.id}
|
|
104
|
-
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
|
105
103
|
placeholder={columnDef.header}
|
|
106
104
|
value={value}
|
|
107
105
|
variant="standard"
|
|
108
106
|
{...textFieldProps}
|
|
107
|
+
onClick={(e) => {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
textFieldProps?.onClick?.(e);
|
|
110
|
+
}}
|
|
109
111
|
onBlur={handleBlur}
|
|
110
112
|
onChange={handleChange}
|
|
111
113
|
onKeyDown={handleEnterKeyDown}
|
|
@@ -58,6 +58,10 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
|
58
58
|
}
|
|
59
59
|
size={density === 'compact' ? 'small' : 'medium'}
|
|
60
60
|
{...checkboxProps}
|
|
61
|
+
onClick={(e) => {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
checkboxProps?.onClick?.(e);
|
|
64
|
+
}}
|
|
61
65
|
sx={(theme) => ({
|
|
62
66
|
height: density === 'compact' ? '1.75rem' : '2.5rem',
|
|
63
67
|
width: density === 'compact' ? '1.75rem' : '2.5rem',
|
|
@@ -99,7 +99,7 @@ export const mrtFilterOptions = (
|
|
|
99
99
|
|
|
100
100
|
interface Props<TData extends Record<string, any> = {}> {
|
|
101
101
|
anchorEl: HTMLElement | null;
|
|
102
|
-
header?: MRT_Header
|
|
102
|
+
header?: MRT_Header<TData>;
|
|
103
103
|
onSelect?: () => void;
|
|
104
104
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
105
105
|
table: MRT_TableInstance<TData>;
|
|
@@ -177,8 +177,14 @@ export const MRT_FilterOptionMenu = <TData extends Record<string, any> = {}>({
|
|
|
177
177
|
dense: density === 'compact',
|
|
178
178
|
}}
|
|
179
179
|
>
|
|
180
|
-
{(header && column
|
|
181
|
-
? renderColumnFilterModeMenuItems?.({
|
|
180
|
+
{(header && column && columnDef
|
|
181
|
+
? columnDef.renderColumnFilterModeMenuItems?.({
|
|
182
|
+
column: column as any,
|
|
183
|
+
internalFilterOptions,
|
|
184
|
+
onSelectFilterMode: handleSelectFilterMode,
|
|
185
|
+
table,
|
|
186
|
+
}) ??
|
|
187
|
+
renderColumnFilterModeMenuItems?.({
|
|
182
188
|
column: column as any,
|
|
183
189
|
internalFilterOptions,
|
|
184
190
|
onSelectFilterMode: handleSelectFilterMode,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { Box, ListItemIcon, Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
4
4
|
import {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
anchorEl: HTMLElement | null;
|
|
11
|
-
handleEdit: () => void;
|
|
11
|
+
handleEdit: (event: MouseEvent) => void;
|
|
12
12
|
row: MRT_Row;
|
|
13
13
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
14
14
|
table: MRT_TableInstance;
|