@material-ui/lab
Version:
Material-UI Lab - Incubator for Material-UI React components.
81 lines (76 loc) • 2.65 kB
JavaScript
import * as React from 'react';
import clsx from 'clsx';
import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography';
import IconButton from '@material-ui/core/IconButton';
import { createStyles, withStyles } from '@material-ui/core/styles';
import Toolbar from '@material-ui/core/Toolbar';
import PenIcon from '../svg-icons/Pen';
import CalendarIcon from '../svg-icons/Calendar';
export const styles = theme => {
const toolbarBackground = theme.palette.mode === 'light' ? theme.palette.primary.main : theme.palette.background.default;
return createStyles({
root: {
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-start',
justifyContent: 'space-between',
paddingTop: 16,
paddingBottom: 16,
backgroundColor: toolbarBackground,
color: theme.palette.getContrastText(toolbarBackground)
},
toolbarLandscape: {
height: 'auto',
maxWidth: 160,
padding: 16,
justifyContent: 'flex-start',
flexWrap: 'wrap'
},
dateTitleContainer: {
flex: 1
}
});
};
function defaultGetKeyboardInputSwitchingButtonText(isKeyboardInputOpen) {
return isKeyboardInputOpen ? 'text input view is open, go to calendar view' : 'calendar view is open, go to text input view';
}
var _ref = /*#__PURE__*/React.createElement(CalendarIcon, {
color: "inherit"
});
var _ref2 = /*#__PURE__*/React.createElement(PenIcon, {
color: "inherit"
});
const PickerToolbar = ({
children,
classes,
className,
getMobileKeyboardInputViewButtonText = defaultGetKeyboardInputSwitchingButtonText,
isLandscape,
isMobileKeyboardViewOpen,
landscapeDirection = 'column',
penIconClassName,
toggleMobileKeyboardView,
toolbarTitle
}) => {
return /*#__PURE__*/React.createElement(Toolbar, {
className: clsx(classes.root, className, isLandscape && classes.toolbarLandscape)
}, /*#__PURE__*/React.createElement(Typography, {
color: "inherit",
variant: "overline"
}, toolbarTitle), /*#__PURE__*/React.createElement(Grid, {
container: true,
justifyContent: "space-between",
className: classes.dateTitleContainer,
direction: isLandscape ? landscapeDirection : 'row',
alignItems: isLandscape ? 'flex-start' : 'flex-end'
}, children, /*#__PURE__*/React.createElement(IconButton, {
onClick: toggleMobileKeyboardView,
className: penIconClassName,
color: "inherit",
"aria-label": getMobileKeyboardInputViewButtonText(isMobileKeyboardViewOpen)
}, isMobileKeyboardViewOpen ? _ref : _ref2)));
};
export default withStyles(styles, {
name: 'MuiPickersToolbar'
})(PickerToolbar);