import React, { PropTypes } from 'react'; import ReactDOM from 'react-dom'; import classNames from 'classnames'; import styles from './dropdown.scss'; import FormComponent from './FormComponent'; export default class Dropdown extends FormComponent { static displayName = 'Dropdown'; static propTypes = { label: PropTypes.oneOfType([ PropTypes.shape({ id: PropTypes.string }), PropTypes.string ]).isRequired, items: PropTypes.arrayOf(PropTypes.string).isRequired, block: PropTypes.bool, color: PropTypes.oneOf(['green', 'blue', 'red', 'lightViolet', 'darkBlue', 'violet', 'orange']) }; state = { isActive: false, activeItem: this.props.label }; componentDidMount() { document.addEventListener('click', this.onBodyClick); } componentWillUnmount() { document.removeEventListener('click', this.onBodyClick); } render() { const { color = 'green', block, items } = this.props; const {isActive, activeItem} = this.state; const label = this.formatMessage(activeItem); return (