import React, { Fragment, PureComponent } from 'react';
import PropTypes from 'prop-types';
import Input from '../input';
import Box from '../box';
import { TextBody, TextDisplay, TextSmall } from '../typography';
import theme from './theme.css';
import isComponentOfType from '../utils/is-component-of-type';
import cx from 'classnames';

export default class Label extends PureComponent {
  static propTypes = {
    className: PropTypes.string,
    children: PropTypes.oneOfType([PropTypes.element, PropTypes.string, PropTypes.array]),
    for: PropTypes.string,
    inverse: PropTypes.bool,
    helpText: PropTypes.string,
    required: PropTypes.bool,
    size: PropTypes.oneOf(['small', 'medium', 'large']),
  };

  static defaultProps = {
    inverse: false,
    helpText: 'Optional',
    required: false,
    size: 'medium',
  };

  render() {
    const { children, className, inverse, helpText, required, size } = this.props;
    const childProps = {
      inverse,
      marginTop: 1,
      size,
    };
    const classNames = cx(
      theme['label'],
      {
        [theme['is-inverse']]: inverse,
      },
      className,
    );
    const Element = size === 'large' ? TextDisplay : TextBody;

    return (
      <Box element="label" htmlFor={this.props.for} marginBottom={3} className={classNames}>
        {React.Children.map(children, child => {
          if (isComponentOfType(Input, child)) {
            return React.cloneElement(child, childProps);
          }

          return (
            <Fragment>
              <Element color={inverse ? 'white' : 'teal'} element="span">
                {child}
              </Element>
              {!required && (
                <TextSmall element="span" marginLeft={1} color={inverse ? 'white' : 'neutral'} soft>
                  {helpText}
                </TextSmall>
              )}
            </Fragment>
          );
        })}
      </Box>
    );
  }
}

@@ -531,16 +531,93 @@
 rray%5D),%0A
+    connectedLeft: PropTypes.element,%0A    connectedRight: PropTypes.element,%0A
     for:
@@ -631,24 +631,24 @@
 pes.string,%0A
-
     inverse:
@@ -942,16 +942,47 @@
 hildren,
+ connectedLeft, connectedRight,
  classNa
@@ -1617,32 +1617,104 @@
      %3CFragment%3E%0A
+              %3CBox element=%22span%22 marginRight=%7B1%7D%3E%7BconnectedLeft%7D%3C/Box%3E%0A
               %3CE
@@ -2009,16 +2009,16 @@
 tSmall%3E%0A
-
         
@@ -2026,16 +2026,88 @@
      )%7D%0A
+              %3CBox element=%22span%22 marginLeft=%7B1%7D%3E%7BconnectedRight%7D%3C/Box%3E%0A
         

Add connectLeft & connectedRight to the Label component