material-react-table 0.40.2 → 0.40.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.
@@ -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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.40.2",
2
+ "version": "0.40.3",
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.",
@@ -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 sx={{ display: 'flex', gap: '0.75rem' }}>
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> = ({ cell, row, table }) => {
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',
@@ -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;