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.3.0 to 6.3.1

lib/utils.js

9

lib/coerceSelection.js

@@ -7,8 +7,4 @@ 'use strict';

var _keys2 = require('lodash/keys');
var _utils = require('./utils');
var _keys3 = _interopRequireDefault(_keys2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var coerceSelection = function coerceSelection(select) {

@@ -21,3 +17,3 @@ if (!select) {

var objSelect = select; // workaround for https://github.com/facebook/flow/issues/5781
return (0, _keys3.default)(select).reduce(function (acc, key) {
return (0, _utils.keys)(select).reduce(function (acc, key) {
return acc.concat(objSelect[key] ? [key] : []);

@@ -28,4 +24,3 @@ }, []);

};
exports.default = coerceSelection;
module.exports = exports['default'];

@@ -7,34 +7,2 @@ 'use strict';

var _compose2 = require('lodash/fp/compose');
var _compose3 = _interopRequireDefault(_compose2);
var _filter2 = require('lodash/fp/filter');
var _filter3 = _interopRequireDefault(_filter2);
var _isPlainObject2 = require('lodash/isPlainObject');
var _isPlainObject3 = _interopRequireDefault(_isPlainObject2);
var _compact2 = require('lodash/compact');
var _compact3 = _interopRequireDefault(_compact2);
var _assign2 = require('lodash/assign');
var _assign3 = _interopRequireDefault(_assign2);
var _merge2 = require('lodash/merge');
var _merge3 = _interopRequireDefault(_merge2);
var _values2 = require('lodash/values');
var _values3 = _interopRequireDefault(_values2);
var _keys2 = require('lodash/keys');
var _keys3 = _interopRequireDefault(_keys2);
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; };

@@ -46,2 +14,4 @@

var _utils = require('./utils');
var _defaultPropsDecorator = require('./defaultPropsDecorator');

@@ -70,3 +40,3 @@

// which will finally go to the container element
var firstKey = classNames && (0, _keys3.default)(classNames)[0];
var firstKey = classNames && (0, _utils.keys)(classNames)[0];
return firstKey && firstKey.split('__')[0].split('--')[0];

@@ -106,9 +76,9 @@ };

(0, _invariant2.default)(!defaultStyle || (0, _isPlainObject3.default)(defaultStyle), 'Optional second parameter must be a plain object.');
(0, _invariant2.default)(!defaultStyle || (0, _utils.isPlainObject)(defaultStyle), 'Optional second parameter must be a plain object.');
var modifierKeys = (0, _filter3.default)(_filterKeys.isModifier, selectedKeys);
var elementKeys = (0, _filter3.default)(_filterKeys.isElement, selectedKeys);
var modifierKeys = selectedKeys.filter(_filterKeys.isModifier);
var elementKeys = selectedKeys.filter(_filterKeys.isElement);
var collectElementStyles = elementKeys.length > 0 ? function (fromStyle) {
return (0, _values3.default)((0, _pickStyles.pickNestedStyles)(fromStyle, elementKeys));
return (0, _utils.values)((0, _pickStyles.pickNestedStyles)(fromStyle, elementKeys));
} : function (fromStyle) {

@@ -118,10 +88,12 @@ return [fromStyle];

var collectSelectedStyles = (0, _compose3.default)(collectElementStyles, function (fromStyle) {
return (0, _pickStyles.hoistModifierStylesRecursive)(fromStyle, modifierKeys);
});
var collectSelectedStyles = function collectSelectedStyles() {
var fromStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return collectElementStyles((0, _pickStyles.hoistModifierStylesRecursive)(fromStyle, modifierKeys));
};
var derivedClassNames = deriveClassNames(baseClassName, elementKeys, modifierKeys);
return createSubstyle(_extends({}, (style || defaultStyle) && {
style: _merge3.default.apply(undefined, [{}].concat(_toConsumableArray(collectSelectedStyles(defaultStyle)), _toConsumableArray(collectSelectedStyles(style))))
style: _utils.merge.apply(undefined, [{}].concat(_toConsumableArray(collectSelectedStyles(defaultStyle)), _toConsumableArray(collectSelectedStyles(style))))
}, derivedClassNames && {

@@ -136,3 +108,3 @@ className: derivedClassNames.join(' ')

var classNameSplit = [].concat(_toConsumableArray(styleProps.className ? styleProps.className.split(' ') : []), _toConsumableArray(baseClassName ? baseClassName.split(' ') : []));
var mappedClassNames = classNames ? (0, _compact3.default)(classNameSplit.map(function (singleClassName) {
var mappedClassNames = classNames ? (0, _utils.compact)(classNameSplit.map(function (singleClassName) {
return classNames[singleClassName];

@@ -146,3 +118,3 @@ })) : classNameSplit;

// assign `style` and/or `className` props to the return function object
(0, _assign3.default)(substyle, propsForSpread);
(0, _utils.assign)(substyle, propsForSpread);
return substyle;

@@ -149,0 +121,0 @@ }

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

var _identity2 = require('lodash/identity');
var _identity3 = _interopRequireDefault(_identity2);
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; };

@@ -26,2 +22,4 @@

var _utils = require('./utils');
var _createSubstyle = require('./createSubstyle');

@@ -136,3 +134,3 @@

var _context$ENHANCER_CON = this.context[_types.ENHANCER_CONTEXT_NAME],
enhance = _context$ENHANCER_CON === undefined ? _identity3.default : _context$ENHANCER_CON;
enhance = _context$ENHANCER_CON === undefined ? _utils.identity : _context$ENHANCER_CON;

@@ -139,0 +137,0 @@

@@ -6,13 +6,7 @@ 'use strict';

});
exports.isElement = exports.isModifier = undefined;
var _negate2 = require('lodash/negate');
var _negate3 = _interopRequireDefault(_negate2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var isModifier = exports.isModifier = function isModifier(key) {
return key[0] === '&';
};
var isElement = exports.isElement = (0, _negate3.default)(isModifier);
var isElement = exports.isElement = function isElement(key) {
return !isModifier(key);
};

@@ -8,26 +8,6 @@ 'use strict';

var _filter2 = require('lodash/filter');
var _utils = require('./utils');
var _filter3 = _interopRequireDefault(_filter2);
var _values2 = require('lodash/values');
var _values3 = _interopRequireDefault(_values2);
var _omit2 = require('lodash/omit');
var _omit3 = _interopRequireDefault(_omit2);
var _merge2 = require('lodash/merge');
var _merge3 = _interopRequireDefault(_merge2);
var _keys2 = require('lodash/keys');
var _keys3 = _interopRequireDefault(_keys2);
var _filterKeys = require('./filterKeys');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

@@ -44,3 +24,3 @@

var styleKeys = (0, _keys3.default)(style);
var styleKeys = (0, _utils.keys)(style);
var result = {};

@@ -63,3 +43,3 @@ for (var i = 0, l = styleKeys.length; i < l; i += 1) {

var camelizedKeysToPick = keysToPick.map(camelize);
var styleKeys = (0, _keys3.default)(style);
var styleKeys = (0, _utils.keys)(style);
var result = {};

@@ -79,6 +59,6 @@ for (var i = 0, l = styleKeys.length; i < l; i += 1) {

// hoist styles for selected modifiers on current level
var result = _merge3.default.apply(undefined, [{}, (0, _omit3.default)(style, modifierKeysToPick)].concat(_toConsumableArray((0, _values3.default)(pickNestedStyles(style, modifierKeysToPick)))));
var result = _utils.merge.apply(undefined, [{}, (0, _utils.omit)(style, modifierKeysToPick)].concat(_toConsumableArray((0, _utils.values)(pickNestedStyles(style, modifierKeysToPick)))));
// traverse nested styled for ALL modifiers
var modifierKeys = (0, _filter3.default)((0, _keys3.default)(result), _filterKeys.isModifier);
var modifierKeys = (0, _utils.keys)(result).filter(_filterKeys.isModifier);
for (var i = 0, l = modifierKeys.length; i < l; i += 1) {

@@ -90,3 +70,3 @@ var key = modifierKeys[i];

delete result[key];
result = (0, _merge3.default)({}, result, subresult);
result = (0, _utils.merge)({}, result, subresult);
} else {

@@ -93,0 +73,0 @@ // non-selected modifier: replace with subresult

@@ -35,5 +35,7 @@ 'use strict';

classNames: ClassNamesPT,
innerRef: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.shape({ current: _propTypes2.default.instanceOf(Element) })])
innerRef: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.shape({
current: typeof Element === 'undefined' ? _propTypes2.default.any : _propTypes2.default.instanceOf(Element)
})])
};
var ContextTypes = exports.ContextTypes = (_ContextTypes = {}, _defineProperty(_ContextTypes, ENHANCER_CONTEXT_NAME, _propTypes2.default.func), _defineProperty(_ContextTypes, PROPS_DECORATOR_CONTEXT_NAME, _propTypes2.default.func), _ContextTypes);
{
"name": "substyle",
"version": "6.3.0",
"version": "6.3.1",
"description": "Universal styling for reusable React components",

@@ -34,3 +34,2 @@ "main": "lib/index.js",

"invariant": "^2.2.0",
"lodash": "^4.3.0",
"prop-types": "^15.5.8",

@@ -37,0 +36,0 @@ "warning": "^2.1.0"

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