'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _Action = require('../../Actions/Action');

var _Action2 = _interopRequireDefault(_Action);

var _Header = require('./Header.scss');

var _Header2 = _interopRequireDefault(_Header);

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

function headerClasses() {
	var _classNames;

	return (0, _classnames2.default)((_classNames = {}, _defineProperty(_classNames, _Header2.default['tc-enumeration-header'], true), _defineProperty(_classNames, 'tc-enumeration-header', true), _classNames));
}

function getAction(action, index) {
	function onClick(event) {
		if (action.onClick) {
			action.onClick(event);
		}
	}

	return _react2.default.createElement(_Action2.default, {
		key: index + '-enum-header-action',
		label: action.label,
		icon: action.icon,
		onClick: onClick,
		disabled: action.disabled,
		tooltipPlacement: 'bottom',
		inProgress: action.inProgress,
		hideLabel: true,
		link: true
	});
}

function HeaderSelected(_ref) {
	var headerSelected = _ref.headerSelected,
	    nbItemsSelected = _ref.nbItemsSelected;

	var txtHeader = nbItemsSelected + ' selected value';
	txtHeader = nbItemsSelected > 1 ? txtHeader + 's' : txtHeader;

	return _react2.default.createElement(
		'header',
		{ className: headerClasses() },
		_react2.default.createElement(
			'span',
			null,
			txtHeader
		),
		headerSelected.map(getAction)
	);
}

HeaderSelected.propTypes = {
	headerSelected: _react.PropTypes.arrayOf(_react.PropTypes.shape(_Action2.default.propTypes)).isRequired,
	nbItemsSelected: _react.PropTypes.number
};

exports.default = HeaderSelected;