mirror of
https://github.com/maputnik/editor.git
synced 2026-09-10 22:37:27 +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
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import React from 'react'
|
|
|
|
import latest from '@maplibre/maplibre-gl-style-spec/dist/latest.json'
|
|
import Block from './Block'
|
|
import InputAutocomplete from './InputAutocomplete'
|
|
import { WithTranslation, withTranslation } from 'react-i18next';
|
|
|
|
type FieldSourceInternalProps = {
|
|
value?: string
|
|
wdKey?: string
|
|
onChange?(value: string| undefined): unknown
|
|
sourceIds?: unknown[]
|
|
error?: {message: string}
|
|
} & WithTranslation;
|
|
|
|
const FieldSourceInternal: React.FC<FieldSourceInternalProps> = (props) => {
|
|
const t = props.t;
|
|
return (
|
|
<Block
|
|
label={t('Source')}
|
|
fieldSpec={latest.layer.source}
|
|
error={props.error}
|
|
data-wd-key={props.wdKey}
|
|
>
|
|
<InputAutocomplete
|
|
value={props.value}
|
|
onChange={props.onChange}
|
|
options={props.sourceIds?.map((src) => [src, src])}
|
|
/>
|
|
</Block>
|
|
);
|
|
};
|
|
|
|
FieldSourceInternal.defaultProps = {
|
|
onChange: () => {},
|
|
sourceIds: [],
|
|
};
|
|
|
|
const FieldSource = withTranslation()(FieldSourceInternal);
|
|
export default FieldSource;
|