Socket
Socket
Sign inDemoInstall

carbon-components-react

Package Overview
Dependencies
35
Maintainers
1
Versions
1155
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.7 to 3.2.0

50

cjs/components/TableBody.js

@@ -30,2 +30,27 @@ 'use strict';

/**
* Adds striping to TableRows if the `even` prop wasn’t explicitly set.
* @param {array} rows React elements that are children of the TableBody
* @return {array} the updated child elements
*/
var handleRowStriping = function handleRowStriping(rows) {
var count = 0;
return rows.map(function (child) {
// Only make changes if it's a TableRow
if (child.type.name === 'TableRow') {
// manually increase the TableRow count
count++;
// Don’t override user-set `even` prop
var even = 'even' in child.props ? child.props.even : count % 2 === 1;
// Return a clone of the element with the `even` prop set.
return _react2.default.cloneElement(child, { even: even });
}
return child;
});
};
var TableBody = function TableBody(props) {

@@ -39,27 +64,4 @@ var children = props.children,

var childArray = _react2.default.Children.toArray(children);
var hasExpandedRows = childArray.some(function (child) {
return child.type.name === 'TableRowExpanded';
});
var childrenWithProps = handleRowStriping(childArray);
var childrenWithProps = hasExpandedRows ? childArray.map(function (child, index) {
if (Math.floor(index / 2) % 2 === 0) {
// eslint-disable-line
return _react2.default.cloneElement(child, {
even: true
});
}
return child; // eslint-disable-line
}) // eslint-disable-line
: childArray.map(function (child, index) {
if (index % 2 === 0) {
// eslint-disable-line
return _react2.default.cloneElement(child, {
even: true
});
}
return child; // eslint-disable-line
}); // eslint-disable-line
return _react2.default.createElement(

@@ -66,0 +68,0 @@ 'tbody',

@@ -14,2 +14,27 @@ 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; };

/**
* Adds striping to TableRows if the `even` prop wasn’t explicitly set.
* @param {array} rows React elements that are children of the TableBody
* @return {array} the updated child elements
*/
var handleRowStriping = function handleRowStriping(rows) {
var count = 0;
return rows.map(function (child) {
// Only make changes if it's a TableRow
if (child.type.name === 'TableRow') {
// manually increase the TableRow count
count++;
// Don’t override user-set `even` prop
var even = 'even' in child.props ? child.props.even : count % 2 === 1;
// Return a clone of the element with the `even` prop set.
return React.cloneElement(child, { even: even });
}
return child;
});
};
var TableBody = function TableBody(props) {

@@ -23,27 +48,4 @@ var children = props.children,

var childArray = React.Children.toArray(children);
var hasExpandedRows = childArray.some(function (child) {
return child.type.name === 'TableRowExpanded';
});
var childrenWithProps = handleRowStriping(childArray);
var childrenWithProps = hasExpandedRows ? childArray.map(function (child, index) {
if (Math.floor(index / 2) % 2 === 0) {
// eslint-disable-line
return React.cloneElement(child, {
even: true
});
}
return child; // eslint-disable-line
}) // eslint-disable-line
: childArray.map(function (child, index) {
if (index % 2 === 0) {
// eslint-disable-line
return React.cloneElement(child, {
even: true
});
}
return child; // eslint-disable-line
}); // eslint-disable-line
return React.createElement(

@@ -50,0 +52,0 @@ 'tbody',

@@ -172,3 +172,3 @@ {

},
"version": "3.1.7"
"version": "3.2.0"
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc