react-jss
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -29,5 +29,7 @@ 'use strict'; | ||
function decorate(_jss, DecoratedComponent, rules, options) { | ||
function decorate(DecoratedComponent, rules, options) { | ||
var _class, _temp; | ||
var _jss = arguments.length <= 3 || arguments[3] === undefined ? _jss3.default : arguments[3]; | ||
var refs = 0; | ||
@@ -100,20 +102,31 @@ var sheet = null; | ||
function useSheet(_jss, DecoratedComponent, rules, options) { | ||
/** | ||
* It has 3 different use cases: | ||
* | ||
* - binding to a specific jss version `useSheet(jss)`, returns a bound useSheet | ||
* function, default is the global jss instance | ||
* - manual decoration `useSheet(Component, rules, options)` | ||
* - decoration by @decorator, which produces `useSheet(rules, options)(Component)` | ||
*/ | ||
function useSheet(DecoratedComponent, rules, options) { | ||
// User creates a useSheet function bound to a specific jss version. | ||
if (_jss instanceof _jss3.default.constructor && !DecoratedComponent) { | ||
return useSheet.bind(null, _jss3.default); | ||
// DecoratedComponent is Jss instance. | ||
if (DecoratedComponent instanceof _jss3.default.constructor && !rules) { | ||
return useSheet.bind(DecoratedComponent); | ||
} | ||
// Manually called by user: `useSheet(DecoratedComponent, rules, options)` | ||
var _jss = this instanceof _jss3.default.constructor ? this : undefined; | ||
// Manually called by user: `useSheet(DecoratedComponent, rules, options)`. | ||
if (typeof DecoratedComponent === 'function') { | ||
return decorate.apply(undefined, arguments); | ||
return decorate.apply(undefined, Array.prototype.slice.call(arguments).concat([_jss])); | ||
} | ||
// Used a decorator: `useSheet(rules, options)(DecoratedComponent)` | ||
// Used as a decorator: `useSheet(rules, options)(DecoratedComponent)`. | ||
options = rules; | ||
rules = DecoratedComponent; | ||
options = rules; | ||
return function (_DecoratedComponent) { | ||
return decorate(_jss, _DecoratedComponent, rules, options); | ||
return decorate(_DecoratedComponent, rules, options, _jss); | ||
}; | ||
} |
{ | ||
"name": "react-jss", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "JSS mixin for React components", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13252
101