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

substyle

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

substyle - npm Package Compare versions

Comparing version 6.1.4 to 6.2.0

lib/coerceSelection.js

31

lib/createSubstyle.js

@@ -19,6 +19,2 @@ 'use strict';

var _isString2 = require('lodash/isString');
var _isString3 = _interopRequireDefault(_isString2);
var _isPlainObject2 = require('lodash/isPlainObject');

@@ -66,2 +62,10 @@

var _coerceSelection = require('./coerceSelection');
var _coerceSelection2 = _interopRequireDefault(_coerceSelection);
var _memoize = require('./memoize');
var _memoize2 = _interopRequireDefault(_memoize);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -71,15 +75,2 @@

var coerceSelectedKeys = function coerceSelectedKeys(select) {
if (!select) {
return [];
} else if ((0, _isString3.default)(select)) {
return [select];
} else if ((0, _isPlainObject3.default)(select)) {
return (0, _keys3.default)(select).reduce(function (acc, key) {
return acc.concat(select[key] ? [key] : []);
}, []);
}
return select;
};
var guessBaseClassName = function guessBaseClassName(classNames) {

@@ -120,4 +111,4 @@ // all class names must start with the same prefix: the component's base class name

var substyle = styleIsFunction ? style : function (select, defaultStyle) {
var selectedKeys = coerceSelectedKeys(select);
var substyle = styleIsFunction ? style : (0, _memoize2.default)(function (select, defaultStyle) {
var selectedKeys = (0, _coerceSelection2.default)(select);

@@ -148,3 +139,3 @@ (0, _invariant2.default)((0, _isArray3.default)(selectedKeys), 'First parameter must be a string, an array of strings, ' + 'a plain object with boolean values, or a falsy value.');

}, classNames && { classNames: classNames }), propsDecorator);
};
});

@@ -151,0 +142,0 @@ var styleProps = _extends({}, styleIsFunction ? style : { style: style });

@@ -15,2 +15,6 @@ 'use strict';

var _omit2 = require('lodash/omit');
var _omit3 = _interopRequireDefault(_omit2);
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -47,2 +51,5 @@

var createDefaultStyle = function createDefaultStyle(defaultStyle, getModifiers) {
var shouldUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
return true;
};
return function (WrappedComponent) {

@@ -57,3 +64,12 @@ var WithDefaultStyle = function (_Component) {

var style = props.style,
className = props.className,
classNames = props.classNames,
rest = _objectWithoutProperties(props, ['style', 'className', 'classNames']);
_this.substyle = (0, _createSubstyle2.default)({ style: style, className: className, classNames: classNames }, _this.context[_types.PROPS_DECORATOR_CONTEXT_NAME]);
_this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
if ((0, _isFunction3.default)(defaultStyle)) {
_this.defaultStyle = defaultStyle(rest);
}
return _this;

@@ -63,17 +79,33 @@ }

_createClass(WithDefaultStyle, [{
key: 'render',
value: function render() {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(_ref) {
var style = _ref.style,
className = _ref.className,
classNames = _ref.classNames,
rest = _objectWithoutProperties(_ref, ['style', 'className', 'classNames']);
var _props = this.props,
style = _props.style,
className = _props.className,
classNames = _props.classNames,
rest = _objectWithoutProperties(_props, ['style', 'className', 'classNames']);
prevStyle = _props.style,
prevClassName = _props.className,
prevClassNames = _props.classNames,
prevRest = _objectWithoutProperties(_props, ['style', 'className', 'classNames']);
var substyle = (0, _createSubstyle2.default)({ style: style, className: className, classNames: classNames }, this.context[_types.PROPS_DECORATOR_CONTEXT_NAME]);
var modifiers = getModifiers && getModifiers(rest);
var finalDefaultStyle = (0, _isFunction3.default)(defaultStyle) ? defaultStyle(rest) : defaultStyle;
if (style !== prevStyle || className !== prevClassName || classNames !== prevClassNames) {
this.substyle = (0, _createSubstyle2.default)({ style: style, className: className, classNames: classNames }, this.context[_types.PROPS_DECORATOR_CONTEXT_NAME]);
}
if ((0, _isFunction3.default)(defaultStyle)) {
if (shouldUpdate(rest, prevRest)) {
this.defaultStyle = defaultStyle(rest);
}
}
}
}, {
key: 'render',
value: function render() {
var rest = (0, _omit3.default)(this.props, ['style', 'className', 'classNames']);
var EnhancedWrappedComponent = this.getWrappedComponent();
var modifiers = getModifiers && getModifiers(rest);
return (0, _react.createElement)(EnhancedWrappedComponent, _extends({
style: substyle(modifiers, finalDefaultStyle),
style: this.substyle(modifiers, this.defaultStyle || defaultStyle),
ref: isStatelessFunction(EnhancedWrappedComponent) ? undefined : this.setWrappedInstance

@@ -80,0 +112,0 @@ }, rest));

{
"name": "substyle",
"version": "6.1.4",
"version": "6.2.0",
"description": "Universal styling for reusable React components",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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