2016-12-29 14:44:46 +01:00
|
|
|
import React from 'react'
|
2017-11-06 16:32:04 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2016-12-29 14:44:46 +01:00
|
|
|
|
2017-11-07 11:21:39 +01:00
|
|
|
import styleSpec from '@mapbox/mapbox-gl-style-spec/style-spec'
|
2016-12-29 14:44:46 +01:00
|
|
|
import InputBlock from '../inputs/InputBlock'
|
|
|
|
import StringInput from '../inputs/StringInput'
|
2016-12-30 20:38:50 +01:00
|
|
|
import AutocompleteInput from '../inputs/AutocompleteInput'
|
2016-12-29 14:44:46 +01:00
|
|
|
|
|
|
|
class LayerSourceLayer extends React.Component {
|
|
|
|
static propTypes = {
|
2017-11-06 16:32:04 +01:00
|
|
|
value: PropTypes.string,
|
|
|
|
onChange: PropTypes.func,
|
|
|
|
sourceLayerIds: PropTypes.array,
|
2017-11-29 11:20:07 +01:00
|
|
|
isFixed: PropTypes.bool,
|
2016-12-31 10:39:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
onChange: () => {},
|
|
|
|
sourceLayerIds: [],
|
2017-11-29 11:20:07 +01:00
|
|
|
isFixed: false
|
2016-12-29 14:44:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-01-05 18:45:55 +01:00
|
|
|
return <InputBlock label={"Source Layer"} doc={styleSpec.latest.layer['source-layer'].doc}
|
|
|
|
data-wd-key="layer-source-layer"
|
|
|
|
>
|
2016-12-30 20:38:50 +01:00
|
|
|
<AutocompleteInput
|
2017-11-29 11:20:07 +01:00
|
|
|
keepMenuWithinWindowBounds={!!this.props.isFixed}
|
2016-12-29 14:44:46 +01:00
|
|
|
value={this.props.value}
|
|
|
|
onChange={this.props.onChange}
|
|
|
|
options={this.props.sourceLayerIds.map(l => [l, l])}
|
|
|
|
/>
|
|
|
|
</InputBlock>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LayerSourceLayer
|