'use strict';

import React from 'react';
import {FormGroup} from './FormGroup';
import {TextAreaControl} from './TextAreaControl';

export class TextArea extends FormGroup {
    static propTypes = {
        ...FormGroup.propTypes
    };

    static defaultProps = {
        ...FormGroup.defaultProps,
        testAutomationId: 'textArea'
    };

    renderInput(hasError) {
        let {readOnly, ...props} = this.props;
        let readOnlyProp = readOnly === undefined ? {} : {readOnly};
        let ariaDescProps = this.getAriaDescProps(hasError);
        return (
            <TextAreaControl
                {...this.getSafeProps(props)}
                ref="control"
                {...ariaDescProps}
                hasFormGroupContainer
                {...readOnlyProp}
            />
        );
    }
}
