mirror of
https://github.com/maputnik/editor.git
synced 2026-02-10 22:50:00 +00:00
Keeps the repo clean, same as several other of our repos --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import React from 'react'
|
|
|
|
import {latest} from '@maplibre/maplibre-gl-style-spec'
|
|
import Block from './Block'
|
|
import InputAutocomplete from './InputAutocomplete'
|
|
import { WithTranslation, withTranslation } from 'react-i18next';
|
|
|
|
type FieldSourceLayerInternalProps = {
|
|
value?: string
|
|
onChange?(...args: unknown[]): unknown
|
|
sourceLayerIds?: unknown[]
|
|
isFixed?: boolean
|
|
error?: {message: string}
|
|
} & WithTranslation;
|
|
|
|
class FieldSourceLayerInternal extends React.Component<FieldSourceLayerInternalProps> {
|
|
static defaultProps = {
|
|
onChange: () => {},
|
|
sourceLayerIds: [],
|
|
isFixed: false
|
|
}
|
|
|
|
render() {
|
|
const t = this.props.t;
|
|
return <Block
|
|
label={t("Source Layer")}
|
|
fieldSpec={latest.layer['source-layer']}
|
|
data-wd-key="layer-source-layer"
|
|
error={this.props.error}
|
|
>
|
|
<InputAutocomplete
|
|
keepMenuWithinWindowBounds={!!this.props.isFixed}
|
|
value={this.props.value}
|
|
onChange={this.props.onChange}
|
|
options={this.props.sourceLayerIds?.map(l => [l, l])}
|
|
/>
|
|
</Block>
|
|
}
|
|
}
|
|
|
|
const FieldSourceLayer = withTranslation()(FieldSourceLayerInternal);
|
|
export default FieldSourceLayer;
|