import * as React from 'react'; import clsx from 'clsx'; import Typography from '@material-ui/core/Typography'; import { makeStyles, useTheme } from '@material-ui/core/styles'; import IconButton, { IconButtonProps } from '@material-ui/core/IconButton'; import { ArrowLeftIcon } from './icons/ArrowLeft'; import { ArrowRightIcon } from './icons/ArrowRight'; export interface ExportedArrowSwitcherProps { /** * Left arrow icon. */ leftArrowIcon?: React.ReactNode; /** * Right arrow icon. */ rightArrowIcon?: React.ReactNode; /** * Left arrow icon aria-label text. */ leftArrowButtonText?: string; /** * Right arrow icon aria-label text. */ rightArrowButtonText?: string; /** * Props to pass to left arrow button. * @type {Partial} */ leftArrowButtonProps?: Partial; /** * Props to pass to right arrow button. * @type {Partial} */ rightArrowButtonProps?: Partial; } interface ArrowSwitcherProps extends ExportedArrowSwitcherProps, React.HTMLProps { isLeftDisabled: boolean; isLeftHidden?: boolean; isRightDisabled: boolean; isRightHidden?: boolean; onLeftClick: () => void; onRightClick: () => void; text?: string; } export const useStyles = makeStyles( (theme) => ({ root: {}, iconButton: { zIndex: 1, backgroundColor: theme.palette.background.paper, }, previousMonthButtonMargin: { marginRight: 24, }, hidden: { visibility: 'hidden', }, }), { name: 'MuiPickersArrowSwitcher' } ); const PureArrowSwitcher = React.forwardRef((props, ref) => { const { className, isLeftDisabled, isLeftHidden, isRightDisabled, isRightHidden, leftArrowButtonProps, leftArrowButtonText, leftArrowIcon = , onLeftClick, onRightClick, rightArrowButtonProps, rightArrowButtonText, rightArrowIcon = , text, ...other } = props; const classes = useStyles(); const theme = useTheme(); const isRtl = theme.direction === 'rtl'; return (
{isRtl ? rightArrowIcon : leftArrowIcon} {text && ( {text} )} {isRtl ? leftArrowIcon : rightArrowIcon}
); }); PureArrowSwitcher.displayName = 'ArrowSwitcher'; export const ArrowSwitcher = React.memo(PureArrowSwitcher);