'use strict';

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

export class InputCounter extends FormGroup<any> {
    static propTypes: any = {
        ...FormGroup.propTypes
    };

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

    renderInput(hasError) {
        let {minValue, maxValue, ...props} = this.props;
        let ariaDescProps = this.getAriaDescProps(hasError);
        return (
            <InputCounterControl
                {...this.getSafeProps(props) as any}
                ref="control"
                hasFormGroupContainer
                minValue={minValue}
                maxValue={maxValue}
                {...ariaDescProps}
            />
        );
    }
}
