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.
package/dist/cjs/index.js CHANGED
@@ -282,12 +282,15 @@ const MRT_ExpandButton = ({ row, table }) => {
282
282
  const iconButtonProps = muiExpandButtonProps instanceof Function
283
283
  ? muiExpandButtonProps({ table, row })
284
284
  : muiExpandButtonProps;
285
- const handleToggleExpand = () => {
285
+ const handleToggleExpand = (event) => {
286
+ var _a;
287
+ event.stopPropagation();
286
288
  row.toggleExpanded();
289
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
287
290
  };
288
291
  return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.expand },
289
292
  React__default["default"].createElement("span", null,
290
- React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expand, disabled: !row.getCanExpand() && !renderDetailPanel, onClick: handleToggleExpand }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
293
+ React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expand, disabled: !row.getCanExpand() && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
291
294
  ? iconButtonProps.sx(theme)
292
295
  : iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
293
296
  React__default["default"].createElement(ExpandMoreIcon, { style: {
@@ -466,7 +469,11 @@ const MRT_ColumnPinningButtons = ({ column, table, }) => {
466
469
  const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
467
470
  const { options: { icons: { DragHandleIcon }, localization, }, } = table;
468
471
  return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: localization.move },
469
- React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
472
+ React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { onClick: (e) => {
473
+ var _a;
474
+ e.stopPropagation();
475
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
476
+ }, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
470
477
  backgroundColor: 'transparent',
471
478
  opacity: 1,
472
479
  }, '&:active': {
@@ -917,7 +924,7 @@ const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
917
924
  values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
918
925
  });
919
926
  };
920
- return (React__default["default"].createElement(material.Box, { sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React__default["default"].createElement(React__default["default"].Fragment, null,
927
+ return (React__default["default"].createElement(material.Box, { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React__default["default"].createElement(React__default["default"].Fragment, null,
921
928
  React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.cancel },
922
929
  React__default["default"].createElement(material.IconButton, { "aria-label": localization.cancel, onClick: handleCancel },
923
930
  React__default["default"].createElement(CancelIcon, null))),
@@ -938,7 +945,7 @@ const commonIconButtonStyles = {
938
945
  opacity: 1,
939
946
  },
940
947
  };
941
- const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
948
+ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
942
949
  const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
943
950
  const { editingRow } = getState();
944
951
  const [anchorEl, setAnchorEl] = React.useState(null);
@@ -947,7 +954,8 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
947
954
  event.preventDefault();
948
955
  setAnchorEl(event.currentTarget);
949
956
  };
950
- const handleStartEditMode = () => {
957
+ const handleStartEditMode = (event) => {
958
+ event.stopPropagation();
951
959
  setEditingRow(Object.assign({}, row));
952
960
  setAnchorEl(null);
953
961
  };
@@ -979,7 +987,11 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
979
987
  ? selectAllMode === 'all'
980
988
  ? table.getToggleAllRowsSelectedHandler()
981
989
  : table.getToggleAllPageRowsSelectedHandler()
982
- : row.getToggleSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
990
+ : row.getToggleSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
991
+ var _a;
992
+ e.stopPropagation();
993
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
994
+ }, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
983
995
  ? checkboxProps.sx(theme)
984
996
  : checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) }))));
985
997
  };
@@ -1839,7 +1851,11 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
1839
1851
  textFieldProps.inputRef = inputRef;
1840
1852
  }
1841
1853
  }
1842
- }, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { onBlur: handleBlur, onChange: handleChange, onKeyDown: handleEnterKeyDown })));
1854
+ }, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id, placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { onClick: (e) => {
1855
+ var _a;
1856
+ e.stopPropagation();
1857
+ (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
1858
+ }, onBlur: handleBlur, onChange: handleChange, onKeyDown: handleEnterKeyDown })));
1843
1859
  };
1844
1860
 
1845
1861
  const MRT_CopyButton = ({ cell, children, table, }) => {
@@ -1847,7 +1863,8 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
1847
1863
  const { column, row } = cell;
1848
1864
  const { columnDef } = column;
1849
1865
  const [copied, setCopied] = React.useState(false);
1850
- const handleCopy = (text) => {
1866
+ const handleCopy = (event, text) => {
1867
+ event.stopPropagation();
1851
1868
  navigator.clipboard.writeText(text);
1852
1869
  setCopied(true);
1853
1870
  setTimeout(() => setCopied(false), 4000);
@@ -1863,7 +1880,7 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
1863
1880
  : columnDef.muiTableBodyCellCopyButtonProps;
1864
1881
  const buttonProps = Object.assign(Object.assign({}, mTableBodyCellCopyButtonProps), mcTableBodyCellCopyButtonProps);
1865
1882
  return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: copied ? localization.copiedToClipboard : localization.clickToCopy },
1866
- React__default["default"].createElement(material.Button, Object.assign({ onClick: () => handleCopy(cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, ((buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx) instanceof Function
1883
+ React__default["default"].createElement(material.Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, ((buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx) instanceof Function
1867
1884
  ? buttonProps.sx(theme)
1868
1885
  : buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx))) }), children)));
1869
1886
  };