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

var _JSONLike2 = _interopRequireDefault(_JSONLike);

var _List = require('./List.scss');

var _List2 = _interopRequireDefault(_List);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

function List(_ref) {
	var data = _ref.data,
	    props = _objectWithoutProperties(_ref, ['data']);

	if (!Array.isArray(data)) {
		return null;
	}
	return _react2.default.createElement(
		'ul',
		{ className: _List2.default.container + ' tc-object-viewer list-unstyled' },
		data.map(function (obj, index) {
			return _react2.default.createElement(
				'li',
				{ key: index },
				_react2.default.createElement(_JSONLike2.default, _extends({
					data: obj
				}, props, {
					jsonpath: '$[' + index + ']'
				}))
			);
		})
	);
}

List.propTypes = {
	data: _react.PropTypes.arrayOf(_react.PropTypes.object)
};

exports.default = List;