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-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() {
|
2020-06-04 13:49:22 +00:00
|
|
|
const {
|
2020-06-10 12:16:50 +00:00
|
|
|
validationMessage,
|
2020-06-04 13:49:22 +00:00
|
|
|
expected,
|
|
|
|
|
propertyValue,
|
|
|
|
|
isValid,
|
|
|
|
|
dataTreePath,
|
2020-06-10 12:16:50 +00:00
|
|
|
evaluatedValue,
|
2020-06-04 13:49:22 +00:00
|
|
|
} = this.props;
|
2020-06-10 12:16:50 +00:00
|
|
|
|
2019-11-05 05:09:50 +00:00
|
|
|
return (
|
2020-02-26 12:44:56 +00:00
|
|
|
<DynamicAutocompleteInput
|
|
|
|
|
theme={"DARK"}
|
|
|
|
|
input={{ value: propertyValue, onChange: this.onChange }}
|
2020-06-04 13:49:22 +00:00
|
|
|
dataTreePath={dataTreePath}
|
|
|
|
|
expected={expected}
|
2020-06-10 12:16:50 +00:00
|
|
|
evaluatedValue={evaluatedValue}
|
2020-02-26 12:44:56 +00:00
|
|
|
meta={{
|
2020-06-10 12:16:50 +00:00
|
|
|
error: isValid ? "" : validationMessage,
|
2020-02-26 12:44:56 +00:00
|
|
|
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);
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-14 05:35:16 +00:00
|
|
|
static getControlType() {
|
2019-11-05 05:09:50 +00:00
|
|
|
return "CODE_EDITOR";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default CodeEditorControl;
|