import React, { Component } from 'react' import PropTypes from 'prop-types' PureBooleanOption.PropTypes = { value: PropTypes.bool.isRequired, onChange: PropTypes.func.isRequired, } function PureBooleanOption({ value, onChange, ...props}) { let onFocus = () => { props.onFocus() }, onBlur = () => { props.onBlur() }, onMouseEnter = () => { props.onMouseEnter() }, onMouseLeave = () => { props.onMouseLeave() } return ( ) } PureStringOption.PropTypes = { value: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, } function PureStringOption( { value, onChange, ...props }) { let onKeyDown = (e) => {e.stopPropagation()}, onFocus = () => { props.onFocus() }, onBlur = () => { props.onBlur() }, onMouseEnter = () => { props.onMouseEnter() }, onMouseLeave = () => { props.onMouseLeave() } return ( ) } PureNumberOption.PropTypes = { value: PropTypes.number.isRequired, onChange: PropTypes.func.isRequired, } function PureNumberOption( {value, onChange, ...props }) { let onKeyDown = (e) => {e.stopPropagation()}, onFocus = () => { props.onFocus() }, onBlur = () => { props.onBlur() }, onMouseEnter = () => { props.onMouseEnter() }, onMouseLeave = () => { props.onMouseLeave() } return ( ) } PureChoicesOption.PropTypes = { value: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, } function PureChoicesOption( { value, onChange, name, choices, ...props}) { let onFocus = () => { props.onFocus() }, onBlur = () => { props.onBlur() }, onMouseEnter = () => { props.onMouseEnter() }, onMouseLeave = () => { props.onMouseLeave() } return ( ) } class PureStringSequenceOption extends Component { constructor(props, context) { super(props, context) this.state = { height: 1, focus: false, value: this.props.value} this.onFocus = this.onFocus.bind(this) this.onBlur = this.onBlur.bind(this) this.onKeyDown = this.onKeyDown.bind(this) this.onChange = this.onChange.bind(this) } onFocus() { this.setState( {focus: true, height: 3 }) this.props.onFocus() } onBlur() { this.setState( {focus: false, height: 1}) this.props.onBlur() } onKeyDown(e) { e.stopPropagation() } onChange(e) { const value = e.target.value.split("\n") console.log(value) this.props.onChange(e) this.setState({ value }) } render() { const {height, value} = this.state return (