PromucFlow_constructor/app/client/src/components/propertyControls/CodeEditorControl.tsx

34 lines
1000 B
TypeScript
Raw Normal View History

2020-01-02 13:36:35 +00:00
import React, { ChangeEvent } from "react";
2019-11-05 05:09:50 +00:00
import BaseControl, { ControlProps } from "./BaseControl";
2019-11-25 05:07:27 +00:00
import { ControlType } from "constants/PropertyControlConstants";
2019-12-30 07:35:16 +00:00
import DynamicAutocompleteInput from "components/editorComponents/DynamicAutocompleteInput";
2020-01-02 13:36:35 +00:00
import { EventOrValueHandler } from "redux-form";
2019-11-05 05:09:50 +00:00
class CodeEditorControl extends BaseControl<ControlProps> {
render() {
const { validationMessage, propertyValue, isValid } = this.props;
2019-11-05 05:09:50 +00:00
return (
<DynamicAutocompleteInput
theme={"DARK"}
input={{ value: propertyValue, onChange: this.onChange }}
meta={{
error: isValid ? "" : validationMessage,
touched: true,
}}
singleLine={false}
/>
2019-11-05 05:09:50 +00:00
);
}
2020-01-02 13:36:35 +00:00
onChange: EventOrValueHandler<ChangeEvent<any>> = (
value: string | ChangeEvent,
) => {
2019-11-05 05:09:50 +00:00
this.updateProperty(this.props.propertyName, value);
};
getControlType(): ControlType {
return "CODE_EDITOR";
}
}
export default CodeEditorControl;