@@ -63,98 +63,97 @@ function getWindowWidth() {
6363 * HOC to supply a 'media' prop to its enhanced component, based on current browser width
6464 * Value will be one of: 'xs' (default), 'sm', 'md', 'lg', 'xl'
6565 */
66- var withMedia = function withMedia ( ) {
67- var userTheme = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
68- return function ( EnhancedComponent ) {
69- var _THEME$userTheme = _extends ( { } , _THEME2 . default , userTheme ) ,
70- MEDIA_SM = _THEME$userTheme . MEDIA_SM ,
71- MEDIA_MD = _THEME$userTheme . MEDIA_MD ,
72- MEDIA_LG = _THEME$userTheme . MEDIA_LG ,
73- MEDIA_XL = _THEME$userTheme . MEDIA_XL ;
74-
75- var mediaRanges = {
76- xs : [ 0 , MEDIA_SM - 1 ] ,
77- sm : [ MEDIA_SM , MEDIA_MD - 1 ] ,
78- md : [ MEDIA_MD , MEDIA_LG - 1 ] ,
79- lg : [ MEDIA_LG , MEDIA_XL - 1 ] ,
80- xl : [ MEDIA_XL , Infinity ]
81- } ;
82-
83- return function ( _React$Component ) {
84- _inherits ( _class2 , _React$Component ) ;
85-
86- function _class2 ( ) {
87- var _ref ;
88-
89- var _temp , _this , _ret ;
90-
91- _classCallCheck ( this , _class2 ) ;
92-
93- for ( var _len = arguments . length , args = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
94- args [ _key ] = arguments [ _key ] ;
95- }
66+ var withMedia = function withMedia ( EnhancedComponent ) {
67+ var userTheme = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ;
68+
69+ var _THEME$userTheme = _extends ( { } , _THEME2 . default , userTheme ) ,
70+ MEDIA_SM = _THEME$userTheme . MEDIA_SM ,
71+ MEDIA_MD = _THEME$userTheme . MEDIA_MD ,
72+ MEDIA_LG = _THEME$userTheme . MEDIA_LG ,
73+ MEDIA_XL = _THEME$userTheme . MEDIA_XL ;
74+
75+ var mediaRanges = {
76+ xs : [ 0 , MEDIA_SM - 1 ] ,
77+ sm : [ MEDIA_SM , MEDIA_MD - 1 ] ,
78+ md : [ MEDIA_MD , MEDIA_LG - 1 ] ,
79+ lg : [ MEDIA_LG , MEDIA_XL - 1 ] ,
80+ xl : [ MEDIA_XL , Infinity ]
81+ } ;
82+
83+ return function ( _React$Component ) {
84+ _inherits ( _class2 , _React$Component ) ;
85+
86+ function _class2 ( ) {
87+ var _ref ;
9688
97- return _ret = ( _temp = ( _this = _possibleConstructorReturn ( this , ( _ref = _class2 . __proto__ || Object . getPrototypeOf ( _class2 ) ) . call . apply ( _ref , [ this ] . concat ( args ) ) ) , _this ) , _this . state = {
98- media : ''
99- } , _this . handleResize = function ( ) {
100- var media = getCurrentMedia ( mediaRanges , getWindowWidth ( ) ) ;
101- _this . setState ( { media : media } ) ;
102- } , _temp ) , _possibleConstructorReturn ( _this , _ret ) ;
89+ var _temp , _this , _ret ;
90+
91+ _classCallCheck ( this , _class2 ) ;
92+
93+ for ( var _len = arguments . length , args = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
94+ args [ _key ] = arguments [ _key ] ;
10395 }
10496
105- _createClass ( _class2 , [ {
106- key : 'componentDidMount' ,
107- value : function ( ) {
108- var _ref2 = _asyncToGenerator ( /*#__PURE__*/ regeneratorRuntime . mark ( function _callee ( ) {
109- return regeneratorRuntime . wrap ( function _callee$ ( _context ) {
110- while ( 1 ) {
111- switch ( _context . prev = _context . next ) {
112- case 0 :
113- if ( window ) {
114- ( 0 , _utils . throttleEvent ) ( 'resize' , 'throttledWindowResize' , window ) ;
115- window . addEventListener ( 'throttledWindowResize' , this . handleResize ) ;
116- this . handleResize ( ) ;
117- }
118-
119- case 1 :
120- case 'end' :
121- return _context . stop ( ) ;
122- }
97+ return _ret = ( _temp = ( _this = _possibleConstructorReturn ( this , ( _ref = _class2 . __proto__ || Object . getPrototypeOf ( _class2 ) ) . call . apply ( _ref , [ this ] . concat ( args ) ) ) , _this ) , _this . state = {
98+ media : ''
99+ } , _this . handleResize = function ( ) {
100+ var media = getCurrentMedia ( mediaRanges , getWindowWidth ( ) ) ;
101+ _this . setState ( { media : media } ) ;
102+ } , _temp ) , _possibleConstructorReturn ( _this , _ret ) ;
103+ }
104+
105+ _createClass ( _class2 , [ {
106+ key : 'componentDidMount' ,
107+ value : function ( ) {
108+ var _ref2 = _asyncToGenerator ( /*#__PURE__*/ regeneratorRuntime . mark ( function _callee ( ) {
109+ return regeneratorRuntime . wrap ( function _callee$ ( _context ) {
110+ while ( 1 ) {
111+ switch ( _context . prev = _context . next ) {
112+ case 0 :
113+ if ( window ) {
114+ ( 0 , _utils . throttleEvent ) ( 'resize' , 'throttledWindowResize' , window ) ;
115+ window . addEventListener ( 'throttledWindowResize' , this . handleResize ) ;
116+ this . handleResize ( ) ;
117+ }
118+
119+ case 1 :
120+ case 'end' :
121+ return _context . stop ( ) ;
123122 }
124- } , _callee , this ) ;
125- } ) ) ;
126-
127- function componentDidMount ( ) {
128- return _ref2 . apply ( this , arguments ) ;
129- }
130-
131- return componentDidMount ;
132- } ( )
133- } , {
134- key : 'componentWillUnmount' ,
135- value : function componentWillUnmount ( ) {
136- if ( window ) {
137- window . removeEventListener ( 'throttledWindowResize' , this . handleResize ) ;
138- }
123+ }
124+ } , _callee , this ) ;
125+ } ) ) ;
126+
127+ function componentDidMount ( ) {
128+ return _ref2 . apply ( this , arguments ) ;
139129 }
140- } , {
141- key : 'render' ,
142- value : function render ( ) {
143- if ( window && ! this . state . media ) return null ;
144- return _react2 . default . createElement ( EnhancedComponent , _extends ( { media : this . state . media || 'xs' } , this . props ) ) ;
130+
131+ return componentDidMount ;
132+ } ( )
133+ } , {
134+ key : 'componentWillUnmount' ,
135+ value : function componentWillUnmount ( ) {
136+ if ( window ) {
137+ window . removeEventListener ( 'throttledWindowResize' , this . handleResize ) ;
145138 }
146- } , {
147- key : '__reactstandin__regenerateByEval' ,
139+ }
140+ } , {
141+ key : 'render' ,
142+ value : function render ( ) {
143+ if ( window && ! this . state . media ) return null ;
144+ return _react2 . default . createElement ( EnhancedComponent , _extends ( { media : this . state . media || 'xs' } , this . props ) ) ;
145+ }
146+ } , {
147+ key : '__reactstandin__regenerateByEval' ,
148+ // @ts -ignore
149+ value : function __reactstandin__regenerateByEval ( key , code ) {
148150 // @ts -ignore
149- value : function __reactstandin__regenerateByEval ( key , code ) {
150- // @ts -ignore
151- this [ key ] = eval ( code ) ;
152- }
153- } ] ) ;
151+ this [ key ] = eval ( code ) ;
152+ }
153+ } ] ) ;
154154
155- return _class2 ;
156- } ( _react2 . default . Component ) ;
157- } ;
155+ return _class2 ;
156+ } ( _react2 . default . Component ) ;
158157} ;
159158
160159var _default = withMedia ;
0 commit comments