'use strict';

exports.__esModule = 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 _reactSeeds = require('react-seeds');

var _reactSeeds2 = _interopRequireDefault(_reactSeeds);

var _default = require('react-sow/default');

var _default2 = _interopRequireDefault(_default);

var _colors = require('../colors');

var colors = _interopRequireWildcard(_colors);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

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 Choice = _react2.default.createClass({
	displayName: 'Choice',
	getDefaultProps: function getDefaultProps() {
		return {
			styler: function styler() {
				return _default2.default;
			}
		};
	},
	onChange: function onChange(event) {
		var el = event.target;
		var value = el.value;
		this.props.onChange(value);
	},
	render: function render() {
		var _props = this.props,
		    value = _props.value,
		    items = _props.items,
		    onChange = _props.onChange,
		    styler = _props.styler,
		    rest = _objectWithoutProperties(_props, ['value', 'items', 'onChange', 'styler']);

		return _react2.default.createElement(
			_reactSeeds.Seed,
			_extends({ Component: 'select'
			}, rest, {
				value: value,
				onChange: this.onChange,
				padding: { top: 0, bottom: 0, left: '0.5em', right: '0.5em' },
				font: { size: 16 },
				cornerRadius: 0
			}, (0, _reactSeeds.appearanceNone)(), styler(rest)),
			items.map(function (_ref) {
				var value = _ref.value,
				    title = _ref.title;
				return _react2.default.createElement('option', { key: value,
					value: value, children: title
				});
			})
		);
	}
});

exports.default = Choice;
module.exports = exports['default'];