1+ "use strict" ;
2+
3+ var _interopRequireDefault = require ( "@babel/runtime/helpers/interopRequireDefault" ) ;
4+
5+ Object . defineProperty ( exports , "__esModule" , {
6+ value : true
7+ } ) ;
8+ exports . default = adaptV4Theme ;
9+
10+ var _extends2 = _interopRequireDefault ( require ( "@babel/runtime/helpers/extends" ) ) ;
11+
12+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault ( require ( "@babel/runtime/helpers/objectWithoutPropertiesLoose" ) ) ;
13+
14+ var _system = require ( "@mui/system" ) ;
15+
16+ const _excluded = [ "defaultProps" , "mixins" , "overrides" , "palette" , "props" , "styleOverrides" ] ,
17+ _excluded2 = [ "type" , "mode" ] ;
18+
19+ function adaptV4Theme ( inputTheme ) {
20+ if ( process . env . NODE_ENV !== 'production' ) {
21+ console . warn ( [ 'MUI: adaptV4Theme() is deprecated.' , 'Follow the upgrade guide on https://mui.com/r/migration-v4#theme.' ] . join ( '\n' ) ) ;
22+ }
23+
24+ const {
25+ defaultProps = { } ,
26+ mixins = { } ,
27+ overrides = { } ,
28+ palette = { } ,
29+ props = { } ,
30+ styleOverrides = { }
31+ } = inputTheme ,
32+ other = ( 0 , _objectWithoutPropertiesLoose2 . default ) ( inputTheme , _excluded ) ;
33+ const theme = ( 0 , _extends2 . default ) ( { } , other , {
34+ components : { }
35+ } ) ; // default props
36+
37+ Object . keys ( defaultProps ) . forEach ( component => {
38+ const componentValue = theme . components [ component ] || { } ;
39+ componentValue . defaultProps = defaultProps [ component ] ;
40+ theme . components [ component ] = componentValue ;
41+ } ) ;
42+ Object . keys ( props ) . forEach ( component => {
43+ const componentValue = theme . components [ component ] || { } ;
44+ componentValue . defaultProps = props [ component ] ;
45+ theme . components [ component ] = componentValue ;
46+ } ) ; // CSS overrides
47+
48+ Object . keys ( styleOverrides ) . forEach ( component => {
49+ const componentValue = theme . components [ component ] || { } ;
50+ componentValue . styleOverrides = styleOverrides [ component ] ;
51+ theme . components [ component ] = componentValue ;
52+ } ) ;
53+ Object . keys ( overrides ) . forEach ( component => {
54+ const componentValue = theme . components [ component ] || { } ;
55+ componentValue . styleOverrides = overrides [ component ] ;
56+ theme . components [ component ] = componentValue ;
57+ } ) ; // theme.spacing
58+
59+ theme . spacing = ( 0 , _system . createSpacing ) ( inputTheme . spacing ) ; // theme.mixins.gutters
60+
61+ const breakpoints = ( 0 , _system . createBreakpoints ) ( inputTheme . breakpoints || { } ) ;
62+ const spacing = theme . spacing ;
63+ theme . mixins = ( 0 , _extends2 . default ) ( {
64+ gutters : ( styles = { } ) => {
65+ return ( 0 , _extends2 . default ) ( {
66+ paddingLeft : spacing ( 2 ) ,
67+ paddingRight : spacing ( 2 )
68+ } , styles , {
69+ [ breakpoints . up ( 'sm' ) ] : ( 0 , _extends2 . default ) ( {
70+ paddingLeft : spacing ( 3 ) ,
71+ paddingRight : spacing ( 3 )
72+ } , styles [ breakpoints . up ( 'sm' ) ] )
73+ } ) ;
74+ }
75+ } , mixins ) ;
76+ const {
77+ type : typeInput ,
78+ mode : modeInput
79+ } = palette ,
80+ paletteRest = ( 0 , _objectWithoutPropertiesLoose2 . default ) ( palette , _excluded2 ) ;
81+ const finalMode = modeInput || typeInput || 'light' ;
82+ theme . palette = ( 0 , _extends2 . default ) ( {
83+ // theme.palette.text.hint
84+ text : {
85+ hint : finalMode === 'dark' ? 'rgba(255, 255, 255, 0.5)' : 'rgba(0, 0, 0, 0.38)'
86+ } ,
87+ mode : finalMode ,
88+ type : finalMode
89+ } , paletteRest ) ;
90+ return theme ;
91+ }
0 commit comments