import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation, Trans } from 'react-i18next'; import ExpandIcon from 'react-feather/dist/icons/chevrons-down'; import style from './style.module.css'; class Form extends React.PureComponent { static propTypes = { expr: PropTypes.string, syntax: PropTypes.string, syntaxList: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.string, label: PropTypes.string })), onSubmit: PropTypes.func.isRequired, children: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.node), PropTypes.node ]), t: PropTypes.func.isRequired } state = { expr: this.props.expr, syntax: this.props.syntax } handleSubmit = event => { event.preventDefault(); const { expr, syntax } = this.state; this.props.onSubmit({ expr, syntax }); } handleKeyPress = event => { if (event.charCode === 13 && event.shiftKey) { this.handleSubmit(event); } } handleChange = event => this.setState({ [event.target.name]: event.target.value }) render() { const { syntaxList, children, t } = this.props; const { expr, syntax } = this.state; return