diff --git a/src/components/management/LargeTextArea/index.jsx b/src/components/management/LargeTextArea/index.jsx new file mode 100644 index 0000000..4c36415 --- /dev/null +++ b/src/components/management/LargeTextArea/index.jsx @@ -0,0 +1,136 @@ +import Inferno from 'inferno'; +import Component from 'inferno-component'; +import PropTypes from 'prop-types'; + +import './styles.scss'; + +export class LargeTextArea extends Component { + constructor (props) { + super(props); + + PropTypes.checkPropTypes({ + label: PropTypes.string.isRequired, + value: PropTypes.string.isRequired, + placeholder: PropTypes.string, + isValid: PropTypes.bool, + invalidText: PropTypes.string, + onInput: PropTypes.func, + onChange: PropTypes.func, + }, props, 'prop', 'LargeTextArea'); + + this.state = { + isMaximized: false, + value: props.value || '', + }; + + this.textarea = null; + } + + componentWillReceiveProps (nextProps) { + this.setState({ + value: nextProps.value, + }); + } + + maximize () { + this.setState({ isMaximized: true }, () => { + this.textarea.focus(); + }); + } + + minimize () { + this.setState({ isMaximized: false }, () => { + this.textarea.focus(); + }); + } + + onInput (event) { + const val = event.currentTarget.value; + + if (val !== this.state.value) { + this.setState({ value: val }, () => { + if (this.props.onInput) { + this.props.onInput(this.state.value); + } + }); + } + } + + renderTextarea () { + const { placeholder, isValid, onChange } = this.props; + return ( +