Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-jss

Package Overview
Dependencies
Maintainers
2
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-jss - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

changelog.md

107

lib/index.js

@@ -11,3 +11,3 @@ 'use strict';

exports.default = useSheet;
exports.create = create;

@@ -18,6 +18,8 @@ var _react = require('react');

var _jss2 = require('jss');
var _jss = require('jss');
var _jss3 = _interopRequireDefault(_jss2);
var _jssPresetDefault = require('jss-preset-default');
var _jssPresetDefault2 = _interopRequireDefault(_jssPresetDefault);
var _hoistNonReactStatics = require('hoist-non-react-statics');

@@ -35,10 +37,25 @@

function decorate(DecoratedComponent, rules, options) {
var _jss = arguments.length <= 3 || arguments[3] === undefined ? _jss3.default : arguments[3];
/**
* Wrap a Component into a JSS Container Component.
*
* @param {Jss} jss
* @param {Component} WrappedComponent
* @param {Object} styles
* @param {Object} [options]
* @return {Component}
*/
function wrap(jss, WrappedComponent, styles) {
var _class, _temp;
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var refs = 0;
var sheet = null;
var displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
if (!options.meta) options.meta = displayName;
function attach() {
if (!sheet) sheet = _jss.createStyleSheet(rules, options);
if (!sheet) sheet = jss.createStyleSheet(styles, options);
sheet.attach();

@@ -62,14 +79,12 @@ }

var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component';
return _temp = _class = function (_Component) {
_inherits(Jss, _Component);
var StyleSheetWrapper = function (_React$Component) {
_inherits(StyleSheetWrapper, _React$Component);
function Jss() {
_classCallCheck(this, Jss);
function StyleSheetWrapper() {
_classCallCheck(this, StyleSheetWrapper);
return _possibleConstructorReturn(this, Object.getPrototypeOf(StyleSheetWrapper).apply(this, arguments));
return _possibleConstructorReturn(this, (Jss.__proto__ || Object.getPrototypeOf(Jss)).apply(this, arguments));
}
_createClass(StyleSheetWrapper, [{
_createClass(Jss, [{
key: 'componentWillMount',

@@ -99,47 +114,37 @@ value: function componentWillMount() {

value: function render() {
return _react2.default.createElement(DecoratedComponent, _extends({}, this.props, { sheet: this.sheet }));
return _react2.default.createElement(WrappedComponent, _extends({}, this.props, { sheet: this.sheet }));
}
}]);
return StyleSheetWrapper;
}(_react2.default.Component);
return Jss;
}(_react.Component), _class.wrapped = WrappedComponent, _class.displayName = 'Jss(' + displayName + ')', _temp;
}
StyleSheetWrapper.wrapped = DecoratedComponent;
StyleSheetWrapper.displayName = 'JSS(' + displayName + ')';
return (0, _hoistNonReactStatics2.default)(StyleSheetWrapper, DecoratedComponent, {
wrapped: true
});
/**
* Create a `injectSheet` function that will use the passed JSS instance.
*
* @param {Jss} jss
* @return {Function}
* @api public
*/
function create(jss) {
return function injectSheet(styles, options) {
return function (WrappedComponent) {
var Jss = wrap(jss, WrappedComponent, styles, options);
return (0, _hoistNonReactStatics2.default)(Jss, WrappedComponent, { wrapped: true });
};
};
}
/**
* It has 3 different use cases:
* Exports injectSheet function as default.
* Returns a function which needs to be invoked with a Component.
*
* - 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)`
* `injectSheet(styles, [options])(Component)`
*
* @param {Object} styles
* @param {Object} [options]
* @return {Function}
* @api public
*/
function useSheet(DecoratedComponent, rules, options) {
// User creates a useSheet function bound to a specific jss version.
// DecoratedComponent is Jss instance.
if (DecoratedComponent instanceof _jss3.default.constructor && !rules) {
return useSheet.bind(DecoratedComponent);
}
var customJss = this instanceof _jss3.default.constructor ? this : undefined;
// Manually called by user: `useSheet(DecoratedComponent, rules, options)`.
if (typeof DecoratedComponent === 'function') {
return decorate(DecoratedComponent, rules, options, customJss);
}
// Used as a decorator: `useSheet(rules, options)(DecoratedComponent)`.
options = rules;
rules = DecoratedComponent;
return function (_DecoratedComponent) {
return decorate(_DecoratedComponent, rules, options, customJss);
};
}
exports.default = create((0, _jss.create)((0, _jssPresetDefault2.default)()));
{
"name": "react-jss",
"version": "3.0.1",
"description": "JSS mixin for React components",
"version": "4.0.0",
"description": "Integration of JSS for react.",
"main": "lib/index.js",
"scripts": {
"build": "cross-env NODE_ENV=production BABEL_ENV=commonjs babel src --out-dir lib",
"prepublish": "npm run lint && npm run build",
"lint": "eslint ./src"
"all": "npm run lint && npm run test && npm run build",
"build": "npm run clean && npm run build:lib && npm run build:max && npm run build:min",
"clean": "rimraf ./lib/*",
"build:lib": "babel src --out-dir lib",
"build:max": "cross-env NODE_ENV=development webpack src/index.js dist/react-jss.js",
"build:min": "cross-env NODE_ENV=production webpack src/index.js dist/react-jss.min.js",
"build:test": "cross-env NODE_ENV=test webpack src/index.test.js tmp/tests.js",
"lint": "eslint ./src",
"lint:staged": "lint-staged",
"test": "cross-env NODE_ENV=test karma start --single-run ",
"test:watch": "cross-env NODE_ENV=test karma start",
"prepublish": "npm run all"
},

@@ -31,3 +40,2 @@ "repository": {

"peerDependencies": {
"jss": "^5.2.0",
"react": ">=0.13"

@@ -39,19 +47,41 @@ },

"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"cross-env": "^1.0.8",
"eslint": "^2.12.0",
"eslint-config-airbnb": "^8.0.0",
"eslint-config-jss": "^1.1.0",
"cross-env": "^2.0.1",
"eslint": "^3.6.0",
"eslint-config-airbnb": "^11.2.0",
"eslint-config-jss": "^2.2.0",
"eslint-plugin-import": "^1.8.1",
"eslint-plugin-jsx-a11y": "^1.4.2",
"eslint-plugin-react": "^5.1.1",
"jss": "^5.2.0",
"react": "^15.1.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-react": "^6.3.0",
"expect.js": "^0.3.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.1.1",
"karma-mocha-reporter": "^2.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"lint-staged": "^3.0.3",
"mocha": "^3.0.2",
"pre-commit": "^1.1.3",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"rimraf": "^2.5.4",
"webpack": "^1.13.1"
},
"dependencies": {
"hoist-non-react-statics": "1.1.0"
}
"hoist-non-react-statics": "^1.2.0",
"jss": "^5.5.5",
"jss-preset-default": "^0.4.0"
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
]
},
"pre-commit": "lint:staged"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc