'use strict';

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

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

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

    controlLabelFallback() {
        return false;
    }

    renderInput(hasError) {
        let {label, children, ...props} = this.props;
        let ariaDescProps = this.getAriaDescProps(hasError);
        return (
            <ToggleControl
                {...this.getSafeProps(props)}
                ref="control"
                {...ariaDescProps}
                hasFormGroupContainer>
                {children || label}
            </ToggleControl>
        );
    }
}
