Skip to content

Commit

Permalink
[Popper] Expose the sx prop (#31833)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-ngchakming committed Mar 21, 2022
1 parent 13d3aa0 commit c843845
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/pages/api-docs/popper.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"default": "{}"
},
"popperRef": { "type": { "name": "custom", "description": "ref" } },
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
}
},
"transition": { "type": { "name": "bool" } }
},
"name": "Popper",
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/material-ui/api/popper.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"default": "{}"
},
"popperRef": { "type": { "name": "custom", "description": "ref" } },
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
}
},
"transition": { "type": { "name": "bool" } }
},
"name": "Popper",
Expand Down
1 change: 1 addition & 0 deletions docs/translations/api-docs/popper/popper.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"placement": "Popper placement.",
"popperOptions": "Options provided to the <a href=\"https://popper.js.org/docs/v2/constructors/#options\"><code>Popper.js</code></a> instance.",
"popperRef": "A ref that points to the used popper instance.",
"sx": "The system prop that allows defining system overrides as well as additional CSS styles. See the <a href=\"/system/the-sx-prop/\">`sx` page</a> for more details.",
"transition": "Help supporting a react-transition-group/Transition component.",
"direction": "Direction of the text."
},
Expand Down
31 changes: 25 additions & 6 deletions packages/mui-material/src/Popper/Popper.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import PopperUnstyled, { PopperUnstyledProps } from '@mui/base/PopperUnstyled';
import { Direction, SxProps, useThemeWithoutDefault as useTheme } from '@mui/system';
import { HTMLElementType, refType } from '@mui/utils';
import { Direction, useThemeWithoutDefault as useTheme } from '@mui/system';
import useThemeProps from '../styles/useThemeProps';
import PropTypes from 'prop-types';
import * as React from 'react';
import { styled, Theme, useThemeProps } from '../styles';

export type PopperProps = Omit<PopperUnstyledProps, 'direction'> & {
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
};

export type PopperProps = Omit<PopperUnstyledProps, 'direction'>;
const PopperRoot = styled(PopperUnstyled, {
name: 'MuiPopper',
slot: 'Root',
overridesResolver: (props, styles) => styles.root,
})({});

/**
*
Expand All @@ -25,7 +36,7 @@ const Popper = React.forwardRef(function Popper(
) {
const theme = useTheme<{ direction?: Direction }>();
const props = useThemeProps({ props: inProps, name: 'MuiPopper' });
return <PopperUnstyled direction={theme?.direction} {...props} ref={ref} />;
return <PopperRoot direction={theme?.direction} {...props} ref={ref} />;
});

Popper.propTypes /* remove-proptypes */ = {
Expand Down Expand Up @@ -161,6 +172,14 @@ Popper.propTypes /* remove-proptypes */ = {
* A ref that points to the used popper instance.
*/
popperRef: refType,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
PropTypes.func,
PropTypes.object,
]),
/**
* Help supporting a react-transition-group/Transition component.
* @default false
Expand Down

0 comments on commit c843845

Please sign in to comment.