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 +27 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/menus/MRT_RowActionMenu.d.ts +2 -2
- package/dist/esm/material-react-table.esm.js +27 -10
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_RowActionMenu.d.ts +2 -2
- package/package.json +1 -1
- 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_RowActionMenu.tsx +2 -2
|
@@ -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;
|
|
@@ -274,12 +274,15 @@ const MRT_ExpandButton = ({ row, table }) => {
|
|
|
274
274
|
const iconButtonProps = muiExpandButtonProps instanceof Function
|
|
275
275
|
? muiExpandButtonProps({ table, row })
|
|
276
276
|
: muiExpandButtonProps;
|
|
277
|
-
const handleToggleExpand = () => {
|
|
277
|
+
const handleToggleExpand = (event) => {
|
|
278
|
+
var _a;
|
|
279
|
+
event.stopPropagation();
|
|
278
280
|
row.toggleExpanded();
|
|
281
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
279
282
|
};
|
|
280
283
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.expand },
|
|
281
284
|
React.createElement("span", null,
|
|
282
|
-
React.createElement(IconButton, Object.assign({ "aria-label": localization.expand, disabled: !row.getCanExpand() && !renderDetailPanel
|
|
285
|
+
React.createElement(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
|
|
283
286
|
? iconButtonProps.sx(theme)
|
|
284
287
|
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
285
288
|
React.createElement(ExpandMoreIcon, { style: {
|
|
@@ -458,7 +461,11 @@ const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
|
|
458
461
|
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
|
459
462
|
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
460
463
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: localization.move },
|
|
461
|
-
React.createElement(IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, {
|
|
464
|
+
React.createElement(IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { onClick: (e) => {
|
|
465
|
+
var _a;
|
|
466
|
+
e.stopPropagation();
|
|
467
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
468
|
+
}, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
|
|
462
469
|
backgroundColor: 'transparent',
|
|
463
470
|
opacity: 1,
|
|
464
471
|
}, '&:active': {
|
|
@@ -909,7 +916,7 @@ const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
|
|
|
909
916
|
values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
|
|
910
917
|
});
|
|
911
918
|
};
|
|
912
|
-
return (React.createElement(Box, { sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React.createElement(React.Fragment, null,
|
|
919
|
+
return (React.createElement(Box, { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React.createElement(React.Fragment, null,
|
|
913
920
|
React.createElement(Tooltip, { arrow: true, title: localization.cancel },
|
|
914
921
|
React.createElement(IconButton, { "aria-label": localization.cancel, onClick: handleCancel },
|
|
915
922
|
React.createElement(CancelIcon, null))),
|
|
@@ -930,7 +937,7 @@ const commonIconButtonStyles = {
|
|
|
930
937
|
opacity: 1,
|
|
931
938
|
},
|
|
932
939
|
};
|
|
933
|
-
const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
|
|
940
|
+
const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
934
941
|
const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
935
942
|
const { editingRow } = getState();
|
|
936
943
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
@@ -939,7 +946,8 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
|
|
|
939
946
|
event.preventDefault();
|
|
940
947
|
setAnchorEl(event.currentTarget);
|
|
941
948
|
};
|
|
942
|
-
const handleStartEditMode = () => {
|
|
949
|
+
const handleStartEditMode = (event) => {
|
|
950
|
+
event.stopPropagation();
|
|
943
951
|
setEditingRow(Object.assign({}, row));
|
|
944
952
|
setAnchorEl(null);
|
|
945
953
|
};
|
|
@@ -971,7 +979,11 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
971
979
|
? selectAllMode === 'all'
|
|
972
980
|
? table.getToggleAllRowsSelectedHandler()
|
|
973
981
|
: table.getToggleAllPageRowsSelectedHandler()
|
|
974
|
-
: row.getToggleSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, {
|
|
982
|
+
: row.getToggleSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
|
983
|
+
var _a;
|
|
984
|
+
e.stopPropagation();
|
|
985
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
986
|
+
}, 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
|
|
975
987
|
? checkboxProps.sx(theme)
|
|
976
988
|
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) }))));
|
|
977
989
|
};
|
|
@@ -1831,7 +1843,11 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1831
1843
|
textFieldProps.inputRef = inputRef;
|
|
1832
1844
|
}
|
|
1833
1845
|
}
|
|
1834
|
-
}, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id,
|
|
1846
|
+
}, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id, placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { onClick: (e) => {
|
|
1847
|
+
var _a;
|
|
1848
|
+
e.stopPropagation();
|
|
1849
|
+
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
|
1850
|
+
}, onBlur: handleBlur, onChange: handleChange, onKeyDown: handleEnterKeyDown })));
|
|
1835
1851
|
};
|
|
1836
1852
|
|
|
1837
1853
|
const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
@@ -1839,7 +1855,8 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
|
1839
1855
|
const { column, row } = cell;
|
|
1840
1856
|
const { columnDef } = column;
|
|
1841
1857
|
const [copied, setCopied] = useState(false);
|
|
1842
|
-
const handleCopy = (text) => {
|
|
1858
|
+
const handleCopy = (event, text) => {
|
|
1859
|
+
event.stopPropagation();
|
|
1843
1860
|
navigator.clipboard.writeText(text);
|
|
1844
1861
|
setCopied(true);
|
|
1845
1862
|
setTimeout(() => setCopied(false), 4000);
|
|
@@ -1855,7 +1872,7 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
|
1855
1872
|
: columnDef.muiTableBodyCellCopyButtonProps;
|
|
1856
1873
|
const buttonProps = Object.assign(Object.assign({}, mTableBodyCellCopyButtonProps), mcTableBodyCellCopyButtonProps);
|
|
1857
1874
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: copied ? localization.copiedToClipboard : localization.clickToCopy },
|
|
1858
|
-
React.createElement(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
|
|
1875
|
+
React.createElement(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
|
|
1859
1876
|
? buttonProps.sx(theme)
|
|
1860
1877
|
: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx))) }), children)));
|
|
1861
1878
|
};
|