@material-ui/lab
Version:
Material-UI Lab - Incubator for Material-UI React components.
82 lines (77 loc) • 3.14 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 var styles = function styles(theme) {
var 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 _ref2 = /*#__PURE__*/React.createElement(CalendarIcon, {
color: "inherit"
});
var _ref3 = /*#__PURE__*/React.createElement(PenIcon, {
color: "inherit"
});
var PickerToolbar = function PickerToolbar(_ref) {
var children = _ref.children,
classes = _ref.classes,
className = _ref.className,
_ref$getMobileKeyboar = _ref.getMobileKeyboardInputViewButtonText,
getMobileKeyboardInputViewButtonText = _ref$getMobileKeyboar === void 0 ? defaultGetKeyboardInputSwitchingButtonText : _ref$getMobileKeyboar,
isLandscape = _ref.isLandscape,
isMobileKeyboardViewOpen = _ref.isMobileKeyboardViewOpen,
_ref$landscapeDirecti = _ref.landscapeDirection,
landscapeDirection = _ref$landscapeDirecti === void 0 ? 'column' : _ref$landscapeDirecti,
penIconClassName = _ref.penIconClassName,
toggleMobileKeyboardView = _ref.toggleMobileKeyboardView,
toolbarTitle = _ref.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 ? _ref2 : _ref3)));
};
export default withStyles(styles, {
name: 'MuiPickersToolbar'
})(PickerToolbar);