mirror of
https://github.com/maputnik/editor.git
synced 2026-01-06 05:20:01 +00:00
This is to continue the work of migrating all the jsx files into tsx files. The MO is basically described here: #848. About 7 files to go...
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import React from 'react'
|
|
|
|
import SpecField, {SpecFieldProps} from './SpecField'
|
|
import FunctionButtons from './_FunctionButtons'
|
|
|
|
import labelFromFieldName from './_labelFromFieldName'
|
|
|
|
|
|
type SpecPropertyProps = SpecFieldProps & {
|
|
onZoomClick(...args: unknown[]): unknown
|
|
onDataClick(...args: unknown[]): unknown
|
|
fieldName?: string
|
|
fieldType?: string
|
|
fieldSpec?: any
|
|
value?: any
|
|
errors?: unknown[]
|
|
onExpressionClick?(...args: unknown[]): unknown
|
|
};
|
|
|
|
|
|
export default class SpecProperty extends React.Component<SpecPropertyProps> {
|
|
static defaultProps = {
|
|
errors: {},
|
|
}
|
|
|
|
render() {
|
|
const {errors, fieldName, fieldType} = this.props;
|
|
|
|
const functionBtn = <FunctionButtons
|
|
fieldSpec={this.props.fieldSpec}
|
|
onZoomClick={this.props.onZoomClick}
|
|
onDataClick={this.props.onDataClick}
|
|
onExpressionClick={this.props.onExpressionClick}
|
|
/>
|
|
|
|
const error = errors![fieldType+"."+fieldName as any] as any;
|
|
|
|
return <SpecField
|
|
{...this.props}
|
|
error={error}
|
|
fieldSpec={this.props.fieldSpec}
|
|
label={labelFromFieldName(this.props.fieldName || '')}
|
|
action={functionBtn}
|
|
/>
|
|
}
|
|
}
|