import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { useNavigate } from 'react-router-dom';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import IconButton from '../IconButton';
/**
 * BackToButton allow users to navigate to a provided path.
 *
 * Props of the [Material-UI Button](https://mui.com/material-ui/api/button/#props) component are also available.
 */
const BackToButton = ({ path, fontSize = 'small', size = 'medium', ...rest }) => {
    const navigate = useNavigate();
    const onBackToList = useCallback(() => {
        return path && navigate(path);
    }, [navigate, path]);
    return (React.createElement(IconButton, { "aria-label": "back", onClick: onBackToList, size: size, ...rest },
        React.createElement(ArrowBackIcon, { fontSize: fontSize })));
};
BackToButton.propTypes = {
    /**
     * @default 'medium'
     * Size of the button
     */
    size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large']),
    /**
     * @default 'small'
     * Size of the icon.
     */
    fontSize: PropTypes.oneOf(['inherit', 'small', 'medium', 'large']),
    /**
     * Path where browser will be directed to when the button is clicked.
     */
    path: PropTypes.string
};
export default BackToButton;
//# sourceMappingURL=BackToButton.js.map