forked from marmelab/react-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveItemButton.tsx
More file actions
28 lines (25 loc) · 918 Bytes
/
RemoveItemButton.tsx
File metadata and controls
28 lines (25 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as React from 'react';
import CloseIcon from '@mui/icons-material/RemoveCircleOutlined';
import clsx from 'clsx';
import { useSimpleFormIterator, useSimpleFormIteratorItem } from 'ra-core';
import { IconButtonWithTooltip, ButtonProps } from '../../button';
export const RemoveItemButton = (props: Omit<ButtonProps, 'onClick'>) => {
const { remove, index } = useSimpleFormIteratorItem();
const { source } = useSimpleFormIterator();
const { className, ...rest } = props;
return (
<IconButtonWithTooltip
label="ra.action.remove"
size="small"
onClick={() => remove()}
color="warning"
className={clsx(
`button-remove button-remove-${source}-${index}`,
className
)}
{...rest}
>
<CloseIcon fontSize="small" />
</IconButtonWithTooltip>
);
};