'use strict';

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

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

exports.default = ObjectViewer;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _Table = require('./Table');

var _Table2 = _interopRequireDefault(_Table);

var _JSONLike = require('./JSONLike');

var _JSONLike2 = _interopRequireDefault(_JSONLike);

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

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

var DISPLAY_MODES = exports.DISPLAY_MODES = {
	FLAT: 'flat',
	TABLE: 'table',
	TREE: 'tree',
	LIST: 'list'
};

function ObjectViewer(_ref) {
	var displayMode = _ref.displayMode,
	    props = _objectWithoutProperties(_ref, ['displayMode']);

	switch (displayMode) {
		case DISPLAY_MODES.TABLE:
			return _react2.default.createElement(_Table2.default, props);
		case DISPLAY_MODES.FLAT:
			return _react2.default.createElement(_Table2.default, _extends({}, props, { flat: true }));
		case DISPLAY_MODES.TREE:
			return _react2.default.createElement(_JSONLike2.default, props);
		case DISPLAY_MODES.LIST:
			return _react2.default.createElement(_List2.default, props);
		default:
			return _react2.default.createElement(_JSONLike2.default, props);
	}
}

ObjectViewer.propTypes = {
	displayMode: _react.PropTypes.oneOf(Object.keys(DISPLAY_MODES).map(function (key) {
		return DISPLAY_MODES[key];
	}))
};

ObjectViewer.Table = _Table2.default;
ObjectViewer.Tree = _JSONLike2.default;
ObjectViewer.List = _List2.default;