'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

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; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _RowTableSelection = require('./RowTableSelection.scss');

var _RowTableSelection2 = _interopRequireDefault(_RowTableSelection);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/**
 * Row renderer that wrap the default table row renderer
 * It manages row selection classname
 */
function RowTableSelectionRenderer(WrappedComponent, _ref) {
	var isSelected = _ref.isSelected;

	function RowTableSelection(props) {
		var className = props.className,
		    rowData = props.rowData;

		var enhancedClassNames = (0, _classnames2.default)(className, _RowTableSelection2.default['row-table-selection'], _defineProperty({}, _RowTableSelection2.default.selected, isSelected(rowData)), { selected: isSelected(rowData) });
		return _react2.default.createElement(WrappedComponent, _extends({}, props, { className: enhancedClassNames }));
	}
	RowTableSelection.propTypes = WrappedComponent.propTypes;

	return RowTableSelection;
}

exports.default = RowTableSelectionRenderer;