1- import * as React from 'react ' ;
2- import PropTypes from 'prop-types ' ;
1+ import { unstable_composeClasses as composeClasses } from '@material-ui/unstyled ' ;
2+ import { deepmerge } from '@material-ui/utils ' ;
33import clsx from 'clsx' ;
4- import withStyles from '../styles/withStyles' ;
4+ import PropTypes from 'prop-types' ;
5+ import * as React from 'react' ;
6+ import experimentalStyled from '../styles/experimentalStyled' ;
7+ import useThemeProps from '../styles/useThemeProps' ;
8+ import { getImageListUtilityClass } from './imageListClasses' ;
59import ImageListContext from './ImageListContext' ;
610
7- export const styles = {
11+ const overridesResolver = ( props , styles ) => {
12+ const { styleProps } = props ;
13+
14+ return deepmerge ( styles . root || { } , {
15+ ...styles [ styleProps . variant ] ,
16+ } ) ;
17+ } ;
18+
19+ const useUtilityClasses = ( styleProps ) => {
20+ const { classes, variant } = styleProps ;
21+
22+ const slots = {
23+ root : [ 'root' , variant ] ,
24+ } ;
25+
26+ return composeClasses ( slots , getImageListUtilityClass , classes ) ;
27+ } ;
28+
29+ const ImageListRoot = experimentalStyled (
30+ 'ul' ,
31+ { } ,
32+ {
33+ name : 'MuiImageList' ,
34+ slot : 'Root' ,
35+ overridesResolver,
36+ } ,
37+ ) ( ( { theme, styleProps } ) => {
838 /* Styles applied to the root element. */
9- root : {
39+ return {
1040 display : 'grid' ,
1141 overflowY : 'auto' ,
1242 listStyle : 'none' ,
1343 padding : 0 ,
1444 WebkitOverflowScrolling : 'touch' , // Add iOS momentum scrolling.
15- } ,
16- /* Styles applied to the root element if `variant="masonry"`. */
17- masonry : {
18- display : 'block' ,
19- } ,
20- /* Styles applied to the root element if `variant="quilted"`. */
21- quilted : { } ,
22- /* Styles applied to the root element if `variant="standard"`. */
23- standard : { } ,
24- /* Styles applied to the root element if `variant="woven"`. */
25- woven : { } ,
26- } ;
45+ /* Styles applied to the root element if `variant="masonry"`. */
46+ ...( styleProps . variant === 'masonry' && {
47+ position : 'absolute' ,
48+ zIndex : theme . zIndex . appBar ,
49+ top : 0 ,
50+ left : 'auto' ,
51+ right : 0 ,
52+ } ) ,
53+ /* Styles applied to the root element if `variant="quilted"`. */
54+ ...( styleProps . variant === 'quilted' && { } ) ,
55+ /* Styles applied to the root element if `variant="standard"`. */
56+ ...( styleProps . variant === 'standard' && { } ) ,
57+ /* Styles applied to the root element if `variant="woven"`. */
58+ ...( styleProps . variant === 'woven' && { } ) ,
59+ } ;
60+ } ) ;
61+
62+ const ImageList = React . forwardRef ( function ImageList ( inProps , ref ) {
63+ const props = useThemeProps ( {
64+ props : inProps ,
65+ name : 'MuiImageList' ,
66+ } ) ;
2767
28- const ImageList = React . forwardRef ( function ImageList ( props , ref ) {
2968 const {
3069 children,
31- classes,
3270 className,
3371 cols = 2 ,
34- component : Component = 'ul' ,
72+ component = 'ul' ,
3573 rowHeight = 'auto' ,
3674 gap = 4 ,
3775 style : styleProp ,
@@ -64,15 +102,21 @@ const ImageList = React.forwardRef(function ImageList(props, ref) {
64102 ? { columnCount : cols , columnGap : gap , ...styleProp }
65103 : { gridTemplateColumns : `repeat(${ cols } , 1fr)` , gap, ...styleProp } ;
66104
105+ const styleProps = { ...props , component, variant } ;
106+
107+ const classes = useUtilityClasses ( styleProps ) ;
108+
67109 return (
68- < Component
110+ < ImageListRoot
111+ as = { component }
69112 className = { clsx ( classes . root , classes [ variant ] , className ) }
70113 ref = { ref }
71114 style = { style }
115+ styleProps = { styleProps }
72116 { ...other }
73117 >
74118 < ImageListContext . Provider value = { contextValue } > { children } </ ImageListContext . Provider >
75- </ Component >
119+ </ ImageListRoot >
76120 ) ;
77121} ) ;
78122
@@ -117,6 +161,10 @@ ImageList.propTypes = {
117161 * @ignore
118162 */
119163 style : PropTypes . object ,
164+ /**
165+ * The system prop that allows defining system overrides as well as additional CSS styles.
166+ */
167+ sx : PropTypes . object ,
120168 /**
121169 * The variant to use.
122170 * @default 'standard'
@@ -127,4 +175,4 @@ ImageList.propTypes = {
127175 ] ) ,
128176} ;
129177
130- export default withStyles ( styles , { name : 'MuiImageList' } ) ( ImageList ) ;
178+ export default ImageList ;
0 commit comments