'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 _Item = require('./Item');

var _Item2 = _interopRequireDefault(_Item);

var _Column = require('./Column.properties');

var _Column2 = _interopRequireDefault(_Column);

var _Content = require('./Content.scss');

var _Content2 = _interopRequireDefault(_Content);

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

function Content(props) {
	var id = props.id,
	    displayMode = props.displayMode,
	    columns = props.columns,
	    actions = props.actions,
	    items = props.items,
	    itemProps = props.itemProps;

	var itemsClasses = (0, _classnames2.default)(_Content2.default['tc-list-content'], 'tc-list-content', _Content2.default[displayMode], displayMode);
	return _react2.default.createElement(
		'div',
		null,
		_react2.default.createElement(
			'ul',
			{ className: itemsClasses },
			_react2.default.createElement(
				'li',
				{ className: 'tc-list-header' },
				itemProps.onSelect && itemProps.isSelected && _react2.default.createElement('div', { className: 'tc-list-header-item action' }),
				columns.map(function (column, index) {
					return _react2.default.createElement(
						'div',
						{ key: index, className: (0, _classnames2.default)('tc-list-header-item', column.type || 'text') },
						column.label
					);
				})
			),
			items.map(function (item, index) {
				return _react2.default.createElement(
					'li',
					{ key: index },
					_react2.default.createElement(_Item2.default, {
						id: id && id + '-' + index,
						columns: columns,
						actions: actions,
						item: item,
						itemProps: itemProps
					})
				);
			})
		)
	);
}

Content.propTypes = {
	id: _react2.default.PropTypes.string,
	displayMode: _react2.default.PropTypes.string,
	columns: _react2.default.PropTypes.arrayOf(_Column2.default.propTypes).isRequired,
	actions: _Item2.default.propTypes.actions,
	items: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.object),
	itemProps: _Item2.default.propTypes.itemProps
};

Content.defaultProps = {
	items: [],
	displayMode: 'table',
	itemProps: {}
};

exports.default = Content;