mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-08 11:40:54 +01:00
d9a5548762
- Logo DOM sctrucutre now valid, no longer <a/> within </a> - `data-wd-key` not longer required - `maputnik-doc-popup` not longer hidden by LayerEditor accordion
32 lines
841 B
JavaScript
32 lines
841 B
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
|
|
class SelectInput extends React.Component {
|
|
static propTypes = {
|
|
value: PropTypes.string.isRequired,
|
|
"data-wd-key": PropTypes.string,
|
|
options: PropTypes.array.isRequired,
|
|
style: PropTypes.object,
|
|
onChange: PropTypes.func.isRequired,
|
|
}
|
|
|
|
|
|
render() {
|
|
let options = this.props.options
|
|
if(options.length > 0 && !Array.isArray(options[0])) {
|
|
options = options.map(v => [v, v])
|
|
}
|
|
|
|
return <select
|
|
className="maputnik-select"
|
|
data-wd-key={this.props["data-wd-key"]}
|
|
style={this.props.style}
|
|
value={this.props.value}
|
|
onChange={e => this.props.onChange(e.target.value)}
|
|
>
|
|
{ options.map(([val, label]) => <option key={val} value={val}>{label}</option>) }
|
|
</select>
|
|
}
|
|
}
|
|
|
|
export default SelectInput
|