'use strict';

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

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

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

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