diff --git a/packages/material-ui-lab/src/internal/pickers/PickersPopper.tsx b/packages/material-ui-lab/src/internal/pickers/PickersPopper.tsx index 54f7f9cfe461b2..425b82f345e263 100644 --- a/packages/material-ui-lab/src/internal/pickers/PickersPopper.tsx +++ b/packages/material-ui-lab/src/internal/pickers/PickersPopper.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import clsx from 'clsx'; import Grow from '@material-ui/core/Grow'; import Paper, { PaperProps as MuiPaperProps } from '@material-ui/core/Paper'; import Popper, { PopperProps as MuiPopperProps } from '@material-ui/core/Popper'; @@ -7,7 +6,7 @@ import TrapFocus, { TrapFocusProps as MuiTrapFocusProps, } from '@material-ui/core/Unstable_TrapFocus'; import { useForkRef, useEventCallback, ownerDocument } from '@material-ui/core/utils'; -import { MuiStyles, StyleRules, WithStyles, withStyles } from '@material-ui/core/styles'; +import { experimentalStyled as styled } from '@material-ui/core/styles'; import { TransitionProps as MuiTransitionProps } from '@material-ui/core/transitions'; export interface ExportedPickerPopperProps { @@ -30,22 +29,19 @@ export interface PickerPopperProps extends ExportedPickerPopperProps, MuiPaperPr onClose: () => void; } -export type PickersPopperClassKey = 'root' | 'paper' | 'topTransition'; - -export const styles: MuiStyles = ( - theme, -): StyleRules => ({ - root: { - zIndex: theme.zIndex.modal, - }, - paper: { - transformOrigin: 'top center', - outline: 0, - }, - topTransition: { +const PickersPopperRoot = styled(Popper, { skipSx: true })(({ theme }) => ({ + zIndex: theme.zIndex.modal, +})); + +const PickersPopperPaper = styled(Paper, { skipSx: true })<{ + styleProps: Pick; +}>(({ styleProps }) => ({ + transformOrigin: 'top center', + outline: 0, + ...(styleProps.placement === 'top' && { transformOrigin: 'bottom center', - }, -}); + }), +})); function clickedRootScrollbar(event: MouseEvent, doc: Document) { return ( @@ -188,11 +184,10 @@ function useClickAwayListener( return [nodeRef, handleSynthetic, handleSynthetic]; } -const PickersPopper: React.FC> = (props) => { +const PickersPopper = (props: PickerPopperProps) => { const { anchorEl, children, - classes, containerRef = null, onClose, open, @@ -238,13 +233,16 @@ const PickersPopper: React.FC> = ( const handleRef = useForkRef(paperRef, containerRef); const handlePaperRef = useForkRef(handleRef, clickAwayRef as React.Ref); + // TODO: convert to simple assignment after the type error in defaultPropsHandler.js:60:6 is fixed + const styleProps = { ...props }; + return ( - {({ TransitionProps, placement }) => ( @@ -257,23 +255,21 @@ const PickersPopper: React.FC> = ( {...TrapFocusProps} > - {children} - + )} - + ); }; -export default withStyles(styles, { name: 'PrivatePickersPopper' })(PickersPopper); +export default PickersPopper;