mirror of
https://github.com/maputnik/editor.git
synced 2026-01-24 22:30:02 +00:00
36 lines
822 B
JavaScript
36 lines
822 B
JavaScript
import React from 'react'
|
|
import inputStyle from './input.js'
|
|
|
|
class EnumField extends React.Component {
|
|
static propTypes = {
|
|
onChange: React.PropTypes.func.isRequired,
|
|
name: React.PropTypes.string.isRequired,
|
|
value: React.PropTypes.string,
|
|
allowedValues: React.PropTypes.array.isRequired,
|
|
doc: React.PropTypes.string,
|
|
}
|
|
|
|
onChange(e) {
|
|
return this.props.onChange(e.target.value)
|
|
}
|
|
|
|
render() {
|
|
const options = this.props.allowedValues.map(val => {
|
|
return <option key={val} value={val}>{val}</option>
|
|
})
|
|
|
|
return <div style={inputStyle.property}>
|
|
<label style={inputStyle.label}>{this.props.name}</label>
|
|
<select
|
|
style={inputStyle.select}
|
|
value={this.props.value}
|
|
onChange={this.onChange.bind(this)}
|
|
>
|
|
{options}
|
|
</select>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
export default EnumField
|