import React from 'react'; import CodeMirror from '@uiw/react-codemirror'; import 'codemirror/theme/duotone-light.css'; import SelectSearch, { fuzzySearch } from 'react-select-search'; import { CodeHinter } from '../../CodeBuilder/CodeHinter'; class Elasticsearch extends React.Component { constructor(props) { super(props); this.state = { options: this.props.options }; } componentDidMount() { this.setState({ options: this.props.options }); } changeOption = (option, value) => { this.setState( { options: { ...this.state.options, [option]: value } }, () => { this.props.optionsChanged(this.state.options); } ); } changeOperation = (operation) => { this.setState( { options: { ...this.state.options, operation } }, () => { this.props.optionsChanged(this.state.options); } ); }; render() { const { options } = this.state; return (
{options && (
{ this.changeOperation(value); }} filterOptions={fuzzySearch} placeholder="Select.." />
{options.operation === 'search' && (
this.changeOption('index', value)} />
this.changeOption('query', instance.getValue())} options={{ theme: 'duotone-light', mode: 'javascript', lineWrapping: true, scrollbarStyle: null }} />
)}
)}
); } } export { Elasticsearch };