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

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

import React from 'react';
import seeds, { Seed, appearanceNone } from 'react-seeds';
import defaultStyler from 'react-sow/default';

import * as colors from '../colors';

var Choice = React.createClass({
	displayName: 'Choice',
	getDefaultProps: function getDefaultProps() {
		return {
			styler: function styler() {
				return defaultStyler;
			}
		};
	},
	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 React.createElement(
			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
			}, appearanceNone(), styler(rest)),
			items.map(function (_ref) {
				var value = _ref.value,
				    title = _ref.title;
				return React.createElement('option', { key: value,
					value: value, children: title
				});
			})
		);
	}
});

export default Choice;