2016-12-21 14:36:09 +01:00
|
|
|
import React from 'react'
|
|
|
|
import input from '../../config/input.js'
|
|
|
|
|
|
|
|
class SelectInput extends React.Component {
|
|
|
|
static propTypes = {
|
|
|
|
value: React.PropTypes.string.isRequired,
|
|
|
|
options: React.PropTypes.array.isRequired,
|
|
|
|
style: React.PropTypes.object,
|
|
|
|
onChange: React.PropTypes.func.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
2017-01-09 17:47:35 +01:00
|
|
|
let options = this.props.options
|
|
|
|
if(options.length > 0 && !Array.isArray(options[0])) {
|
|
|
|
options = options.map(v => [v, v])
|
|
|
|
}
|
2016-12-21 14:36:09 +01:00
|
|
|
|
|
|
|
return <select
|
2017-01-10 21:28:30 +01:00
|
|
|
className="maputnik-select"
|
2017-01-11 11:35:33 +01:00
|
|
|
style={this.props.style}
|
2016-12-21 14:36:09 +01:00
|
|
|
value={this.props.value}
|
|
|
|
onChange={e => this.props.onChange(e.target.value)}
|
|
|
|
>
|
2017-01-09 17:47:35 +01:00
|
|
|
{ options.map(([val, label]) => <option key={val} value={val}>{label}</option>) }
|
2016-12-21 14:36:09 +01:00
|
|
|
</select>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SelectInput
|