164 lines
6.2 KiB
JavaScript
164 lines
6.2 KiB
JavaScript
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel"],
|
|
_excluded2 = ["ownerState"],
|
|
_excluded3 = ["ownerState"];
|
|
import * as React from 'react';
|
|
import clsx from 'clsx';
|
|
import Typography from '@mui/material/Typography';
|
|
import { useTheme, styled, useThemeProps } from '@mui/material/styles';
|
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
import { useSlotProps } from '@mui/base/utils';
|
|
import IconButton from '@mui/material/IconButton';
|
|
import { ArrowLeftIcon, ArrowRightIcon } from '../../../icons';
|
|
import { getPickersArrowSwitcherUtilityClass } from './pickersArrowSwitcherClasses';
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
const PickersArrowSwitcherRoot = styled('div', {
|
|
name: 'MuiPickersArrowSwitcher',
|
|
slot: 'Root',
|
|
overridesResolver: (props, styles) => styles.root
|
|
})({
|
|
display: 'flex'
|
|
});
|
|
const PickersArrowSwitcherSpacer = styled('div', {
|
|
name: 'MuiPickersArrowSwitcher',
|
|
slot: 'Spacer',
|
|
overridesResolver: (props, styles) => styles.spacer
|
|
})(({
|
|
theme
|
|
}) => ({
|
|
width: theme.spacing(3)
|
|
}));
|
|
const PickersArrowSwitcherButton = styled(IconButton, {
|
|
name: 'MuiPickersArrowSwitcher',
|
|
slot: 'Button',
|
|
overridesResolver: (props, styles) => styles.button
|
|
})(({
|
|
ownerState
|
|
}) => _extends({}, ownerState.hidden && {
|
|
visibility: 'hidden'
|
|
}));
|
|
const useUtilityClasses = ownerState => {
|
|
const {
|
|
classes
|
|
} = ownerState;
|
|
const slots = {
|
|
root: ['root'],
|
|
spacer: ['spacer'],
|
|
button: ['button']
|
|
};
|
|
return composeClasses(slots, getPickersArrowSwitcherUtilityClass, classes);
|
|
};
|
|
export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function PickersArrowSwitcher(inProps, ref) {
|
|
var _slots$previousIconBu, _slots$nextIconButton, _slots$leftArrowIcon, _slots$rightArrowIcon;
|
|
const theme = useTheme();
|
|
const isRTL = theme.direction === 'rtl';
|
|
const props = useThemeProps({
|
|
props: inProps,
|
|
name: 'MuiPickersArrowSwitcher'
|
|
});
|
|
const {
|
|
children,
|
|
className,
|
|
slots,
|
|
slotProps,
|
|
isNextDisabled,
|
|
isNextHidden,
|
|
onGoToNext,
|
|
nextLabel,
|
|
isPreviousDisabled,
|
|
isPreviousHidden,
|
|
onGoToPrevious,
|
|
previousLabel
|
|
} = props,
|
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
const ownerState = props;
|
|
const classes = useUtilityClasses(ownerState);
|
|
const nextProps = {
|
|
isDisabled: isNextDisabled,
|
|
isHidden: isNextHidden,
|
|
goTo: onGoToNext,
|
|
label: nextLabel
|
|
};
|
|
const previousProps = {
|
|
isDisabled: isPreviousDisabled,
|
|
isHidden: isPreviousHidden,
|
|
goTo: onGoToPrevious,
|
|
label: previousLabel
|
|
};
|
|
const PreviousIconButton = (_slots$previousIconBu = slots == null ? void 0 : slots.previousIconButton) != null ? _slots$previousIconBu : PickersArrowSwitcherButton;
|
|
const previousIconButtonProps = useSlotProps({
|
|
elementType: PreviousIconButton,
|
|
externalSlotProps: slotProps == null ? void 0 : slotProps.previousIconButton,
|
|
additionalProps: {
|
|
size: 'medium',
|
|
title: previousProps.label,
|
|
'aria-label': previousProps.label,
|
|
disabled: previousProps.isDisabled,
|
|
edge: 'end',
|
|
onClick: previousProps.goTo
|
|
},
|
|
ownerState: _extends({}, ownerState, {
|
|
hidden: previousProps.isHidden
|
|
}),
|
|
className: classes.button
|
|
});
|
|
const NextIconButton = (_slots$nextIconButton = slots == null ? void 0 : slots.nextIconButton) != null ? _slots$nextIconButton : PickersArrowSwitcherButton;
|
|
const nextIconButtonProps = useSlotProps({
|
|
elementType: NextIconButton,
|
|
externalSlotProps: slotProps == null ? void 0 : slotProps.nextIconButton,
|
|
additionalProps: {
|
|
size: 'medium',
|
|
title: nextProps.label,
|
|
'aria-label': nextProps.label,
|
|
disabled: nextProps.isDisabled,
|
|
edge: 'start',
|
|
onClick: nextProps.goTo
|
|
},
|
|
ownerState: _extends({}, ownerState, {
|
|
hidden: nextProps.isHidden
|
|
}),
|
|
className: classes.button
|
|
});
|
|
const LeftArrowIcon = (_slots$leftArrowIcon = slots == null ? void 0 : slots.leftArrowIcon) != null ? _slots$leftArrowIcon : ArrowLeftIcon;
|
|
// The spread is here to avoid this bug mui/material-ui#34056
|
|
const _useSlotProps = useSlotProps({
|
|
elementType: LeftArrowIcon,
|
|
externalSlotProps: slotProps == null ? void 0 : slotProps.leftArrowIcon,
|
|
additionalProps: {
|
|
fontSize: 'inherit'
|
|
},
|
|
ownerState: undefined
|
|
}),
|
|
leftArrowIconProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
const RightArrowIcon = (_slots$rightArrowIcon = slots == null ? void 0 : slots.rightArrowIcon) != null ? _slots$rightArrowIcon : ArrowRightIcon;
|
|
// The spread is here to avoid this bug mui/material-ui#34056
|
|
const _useSlotProps2 = useSlotProps({
|
|
elementType: RightArrowIcon,
|
|
externalSlotProps: slotProps == null ? void 0 : slotProps.rightArrowIcon,
|
|
additionalProps: {
|
|
fontSize: 'inherit'
|
|
},
|
|
ownerState: undefined
|
|
}),
|
|
rightArrowIconProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded3);
|
|
return /*#__PURE__*/_jsxs(PickersArrowSwitcherRoot, _extends({
|
|
ref: ref,
|
|
className: clsx(classes.root, className),
|
|
ownerState: ownerState
|
|
}, other, {
|
|
children: [/*#__PURE__*/_jsx(PreviousIconButton, _extends({}, previousIconButtonProps, {
|
|
children: isRTL ? /*#__PURE__*/_jsx(RightArrowIcon, _extends({}, rightArrowIconProps)) : /*#__PURE__*/_jsx(LeftArrowIcon, _extends({}, leftArrowIconProps))
|
|
})), children ? /*#__PURE__*/_jsx(Typography, {
|
|
variant: "subtitle1",
|
|
component: "span",
|
|
children: children
|
|
}) : /*#__PURE__*/_jsx(PickersArrowSwitcherSpacer, {
|
|
className: classes.spacer,
|
|
ownerState: ownerState
|
|
}), /*#__PURE__*/_jsx(NextIconButton, _extends({}, nextIconButtonProps, {
|
|
children: isRTL ? /*#__PURE__*/_jsx(LeftArrowIcon, _extends({}, leftArrowIconProps)) : /*#__PURE__*/_jsx(RightArrowIcon, _extends({}, rightArrowIconProps))
|
|
}))]
|
|
}));
|
|
}); |