'use strict';

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

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

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

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