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

react-props-classnames

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-props-classnames - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

34

lib/createPropsTransform.js

@@ -10,4 +10,6 @@ "use strict";

var _TransformedComponent = _interopRequireDefault(require("./TransformedComponent"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _PropsTransform = _interopRequireDefault(require("./PropsTransform"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -19,15 +21,27 @@

// eslint-disable-next-line react/prop-types
var _default = function _default(options) {
return function (Component) {
return function (_ref) {
var children = _ref.children,
otherProps = _objectWithoutProperties(_ref, ["children"]);
var TransformedComponent = function TransformedComponent(_ref) {
var className = _ref.className,
children = _ref.children,
otherOrops = _objectWithoutProperties(_ref, ["className", "children"]);
return _react.default.createElement(_TransformedComponent.default, _extends({
options: options
}, otherProps), function (transformedProps) {
return _react.default.createElement(Component, transformedProps, children);
});
var propsTransform = new _PropsTransform.default(options);
var propsClassName = propsTransform.getClassNameFromProps(otherOrops);
var mergedClassName = "".concat(className, " ").concat(propsClassName).trim();
return _react.default.createElement(Component, _extends({
className: mergedClassName
}, otherOrops), children);
};
TransformedComponent.displayName = 'PropsTransformer';
TransformedComponent.propTypes = {
children: _propTypes.default.node,
className: _propTypes.default.string
};
TransformedComponent.defaultProps = {
children: '',
className: ''
};
return TransformedComponent;
};

@@ -34,0 +48,0 @@ };

@@ -29,3 +29,3 @@ "use strict";

_ref$props = _ref.props,
_props2 = _ref$props === void 0 ? [] : _ref$props,
_props = _ref$props === void 0 ? [] : _ref$props,
_ref$bool = _ref.bool,

@@ -39,6 +39,6 @@ bool = _ref$bool === void 0 ? true : _ref$bool,

_defineProperty(this, "_getTransformProps", function (props) {
var _props = _this._props,
var _transformProps = _this._transformProps,
_hasProps = _this._hasProps;
return Object.keys(props).filter(function (propsKey) {
return _hasProps && _props.includes(propsKey) || !_hasProps;
return _hasProps && _transformProps.includes(propsKey) || !_hasProps;
});

@@ -71,8 +71,8 @@ });

this._prefix = prefix;
this._props = _props2;
this._transformProps = _props;
this._transformBool = bool;
this._transformString = string;
this._hasProps = !(0, _utils.isEmptyArray)(_props2);
this._hasProps = !(0, _utils.isEmptyArray)(_props);
};
exports.default = PropsTransform;

@@ -14,3 +14,3 @@ {

},
"version": "0.2.0",
"version": "0.2.1",
"main": "lib/index.js",

@@ -17,0 +17,0 @@ "files": [

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