mirror of
https://github.com/maputnik/editor.git
synced 2026-08-30 17:07:26 +00:00
2fef0467b6
## Summary - convert all remaining Field components to const arrow functions - document the refactor in the CHANGELOG ## Testing - `npm run lint` - `npm run build` ------ https://chatgpt.com/codex/tasks/task_e_68684db1b6b88331837307a54e3f9dc1
42 lines
1.1 KiB
TypeScript
42 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;
|
|
|
|
const FieldSourceLayerInternal: React.FC<FieldSourceLayerInternalProps> = (props) => {
|
|
const t = props.t;
|
|
return (
|
|
<Block
|
|
label={t('Source Layer')}
|
|
fieldSpec={latest.layer['source-layer']}
|
|
data-wd-key="layer-source-layer"
|
|
error={props.error}
|
|
>
|
|
<InputAutocomplete
|
|
value={props.value}
|
|
onChange={props.onChange}
|
|
options={props.sourceLayerIds?.map((l) => [l, l])}
|
|
/>
|
|
</Block>
|
|
);
|
|
};
|
|
|
|
FieldSourceLayerInternal.defaultProps = {
|
|
onChange: () => {},
|
|
sourceLayerIds: [],
|
|
isFixed: false,
|
|
};
|
|
|
|
const FieldSourceLayer = withTranslation()(FieldSourceLayerInternal);
|
|
export default FieldSourceLayer;
|