@@ -21,9 +21,10 @@ const DEFAULT_OPTIONS = {
2121 mapThemrProps : defaultMapThemrProps
2222}
2323
24- const THEMR_CONFIG = typeof Symbol !== 'undefined' ?
25- Symbol ( 'THEMR_CONFIG' ) :
26- '__REACT_CSS_THEMR_CONFIG__'
24+ const THEMR_CONFIG =
25+ typeof Symbol !== 'undefined'
26+ ? Symbol ( 'THEMR_CONFIG' )
27+ : '__REACT_CSS_THEMR_CONFIG__'
2728
2829/**
2930 * Themr decorator
@@ -32,7 +33,7 @@ const THEMR_CONFIG = typeof Symbol !== 'undefined' ?
3233 * @param {{} } [options] - Themr options
3334 * @returns {function(ThemedComponent:Function):Function } - ThemedComponent
3435 */
35- export default ( componentName , localTheme , options = { } ) => ( ThemedComponent ) => {
36+ export default ( componentName , localTheme , options = { } ) => ThemedComponent => {
3637 const {
3738 composeTheme : optionComposeTheme ,
3839 mapThemrProps : optionMapThemrProps
@@ -54,15 +55,21 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
5455 * @property {{wrappedInstance: *} } refs
5556 */
5657 class Themed extends Component {
57- static displayName = `Themed${ ( ThemedComponent . displayName || ThemedComponent . name || "Component" ) } ` ;
58+ static displayName = `Themed${ ThemedComponent . displayName ||
59+ ThemedComponent . name ||
60+ 'Component' } `
5861
5962 static contextTypes = {
6063 themr : PropTypes . object
6164 }
6265
6366 static propTypes = {
6467 ...ThemedComponent . propTypes ,
65- composeTheme : PropTypes . oneOf ( [ COMPOSE_DEEPLY , COMPOSE_SOFTLY , DONT_COMPOSE ] ) ,
68+ composeTheme : PropTypes . oneOf ( [
69+ COMPOSE_DEEPLY ,
70+ COMPOSE_SOFTLY ,
71+ DONT_COMPOSE
72+ ] ) ,
6673 innerRef : PropTypes . func ,
6774 theme : PropTypes . object ,
6875 themeNamespace : PropTypes . string ,
@@ -81,9 +88,10 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
8188 }
8289
8390 getWrappedInstance ( ) {
84- invariant ( true ,
91+ invariant (
92+ true ,
8593 'DEPRECATED: To access the wrapped instance, you have to pass ' +
86- '{ innerRef: fn } and retrieve with a callback ref style.'
94+ '{ innerRef: fn } and retrieve with a callback ref style.'
8795 )
8896
8997 return this . refs . wrappedInstance
@@ -94,13 +102,21 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
94102 if ( ! themeNamespace ) return theme
95103
96104 if ( themeNamespace && ! theme ) {
97- throw new Error ( 'Invalid themeNamespace use in friendsofreactjs/react-css-themr. ' +
98- 'themeNamespace prop should be used only with theme prop.' )
105+ throw new Error (
106+ 'Invalid themeNamespace use in friendsofreactjs/react-css-themr. ' +
107+ 'themeNamespace prop should be used only with theme prop.'
108+ )
99109 }
100110
101111 return Object . keys ( theme )
102112 . filter ( key => key . startsWith ( themeNamespace ) )
103- . reduce ( ( result , key ) => ( { ...result , [ removeNamespace ( key , themeNamespace ) ] : theme [ key ] } ) , { } )
113+ . reduce (
114+ ( result , key ) => ( {
115+ ...result ,
116+ [ removeNamespace ( key , themeNamespace ) ] : theme [ key ]
117+ } ) ,
118+ { }
119+ )
104120 }
105121
106122 getThemeNotComposed ( props ) {
@@ -118,14 +134,14 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
118134 getTheme ( props ) {
119135 return props . composeTheme === COMPOSE_SOFTLY
120136 ? {
121- ...this . getContextTheme ( ) ,
122- ...config . localTheme ,
123- ...this . getNamespacedTheme ( props )
124- }
137+ ...this . getContextTheme ( ) ,
138+ ...config . localTheme ,
139+ ...this . getNamespacedTheme ( props )
140+ }
125141 : themeable (
126- themeable ( this . getContextTheme ( ) , config . localTheme ) ,
127- this . getNamespacedTheme ( props )
128- )
142+ themeable ( this . getContextTheme ( ) , config . localTheme ) ,
143+ this . getNamespacedTheme ( props )
144+ )
129145 }
130146
131147 calcTheme ( props ) {
@@ -208,7 +224,9 @@ function merge(original = {}, mixin = {}) {
208224
209225 default : {
210226 //can't merge an object with a non-object
211- throw new Error ( `You are merging object ${ key } with a non-object ${ originalValue } ` )
227+ throw new Error (
228+ `You are merging object ${ key } with a non-object ${ originalValue } `
229+ )
212230 }
213231 }
214232 break
@@ -225,7 +243,9 @@ function merge(original = {}, mixin = {}) {
225243 switch ( typeof originalValue ) {
226244 case 'object' : {
227245 //can't merge a non-object with an object
228- throw new Error ( `You are merging non-object ${ mixinValue } with an object ${ key } , (can occur when using empty or :global only base theme stylesheet)` )
246+ throw new Error (
247+ `You are merging non-object ${ mixinValue } with an object ${ key } , (can occur when using empty or :global only base theme stylesheet)`
248+ )
229249 }
230250
231251 case 'undefined' : {
@@ -240,9 +260,12 @@ function merge(original = {}, mixin = {}) {
240260
241261 default : {
242262 //finally we can merge
243- result [ key ] = originalValue . split ( ' ' )
263+ result [ key ] = originalValue
264+ . split ( ' ' )
244265 . concat ( mixinValue . split ( ' ' ) )
245- . filter ( ( item , pos , self ) => self . indexOf ( item ) === pos && item !== '' )
266+ . filter (
267+ ( item , pos , self ) => self . indexOf ( item ) === pos && item !== ''
268+ )
246269 . join ( ' ' )
247270 break
248271 }
@@ -263,7 +286,9 @@ function merge(original = {}, mixin = {}) {
263286 * @returns {undefined }
264287 */
265288function validateComposeOption ( composeTheme ) {
266- if ( [ COMPOSE_DEEPLY , COMPOSE_SOFTLY , DONT_COMPOSE ] . indexOf ( composeTheme ) === - 1 ) {
289+ if (
290+ [ COMPOSE_DEEPLY , COMPOSE_SOFTLY , DONT_COMPOSE ] . indexOf ( composeTheme ) === - 1
291+ ) {
267292 throw new Error (
268293 `Invalid composeTheme option for friendsofreactjs/react-css-themr. Valid composition options\
269294 are ${ COMPOSE_DEEPLY } , ${ COMPOSE_SOFTLY } and ${ DONT_COMPOSE } . The given\
@@ -294,10 +319,10 @@ function removeNamespace(key, themeNamespace) {
294319 */
295320function defaultMapThemrProps ( ownProps , theme ) {
296321 const {
297- composeTheme, //eslint-disable-line no-unused-vars
322+ composeTheme, //eslint-disable-line no-unused-vars
298323 innerRef,
299324 themeNamespace, //eslint-disable-line no-unused-vars
300- mapThemrProps, //eslint-disable-line no-unused-vars
325+ mapThemrProps, //eslint-disable-line no-unused-vars
301326 ...rest
302327 } = ownProps
303328
0 commit comments