'use strict';

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

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

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

    getInputDOMNode() {
        return this.refs.control.refs.autoSuggest.input;
    }

    renderInput(hasError) {
        let ariaDescProps = this.getAriaDescProps(hasError);
        return (
            <AutosuggestControl
                {...this.getSafeProps(this.props)}
                ref="control"
                hasFormGroupContainer
                {...ariaDescProps}
            />
        );
    }
}
