<commit_before>import _ from 'lodash'
import cx from 'classnames'
import React, { Component, PropTypes } from 'react'

import {
  customPropTypes,
  getElementType,
  getUnhandledProps,
  META,
  SUI,
  useKeyOnly,
  useKeyOrValueAndKey,
} from '../../lib'
import Icon from '../../elements/Icon'

const _meta = {
  name: 'MenuItem',
  type: META.TYPES.COLLECTION,
  parent: 'Menu',
  props: {
    color: SUI.COLORS,
    fitted: ['horizontally', 'vertically'],
    position: ['right'],
  },
}

export default class MenuItem extends Component {
  static propTypes = {
    /** An element type to render as (string or function). */
    as: customPropTypes.as,

    /** A menu item can be active. */
    active: PropTypes.bool,

    /** Primary content. */
    children: PropTypes.node,

    /** Additional classes. */
    className: PropTypes.string,

    /** Additional colors can be specified. */
    color: PropTypes.oneOf(_meta.props.color),

    /** Shorthand for primary content. */
    content: customPropTypes.contentShorthand,

    /** A menu item or menu can remove element padding, vertically or horizontally. */
    fitted: PropTypes.oneOfType([
      PropTypes.bool,
      PropTypes.oneOf(_meta.props.fitted),
    ]),

    /** A menu item may include a header or may itself be a header. */
    header: PropTypes.bool,

    /** MenuItem can be only icon. */
    icon: PropTypes.bool,

    /** MenuItem index inside Menu. */
    index: PropTypes.number,

    /** A menu item can be link. */
    link: PropTypes.bool,

    /** Internal name of the MenuItem. */
    name: PropTypes.string,

    /** Render as an `a` tag instead of a `div` and called with event on MenuItem click. */
    onClick: PropTypes.func,

    /** A menu item can take right position. */
    position: PropTypes.oneOf(_meta.props.position),
  }

  static _meta = _meta

  handleClick = (e) => {
    const { index, name, onClick } = this.props

    if (onClick) onClick(e, { name, index })
  }

  render() {
    const {
      active,
      children,
      className,
      color,<commit_msg>fix(MenuItem): allow bool/string icon proptype (#683)<commit_after>import _ from 'lodash'
import cx from 'classnames'
import React, { Component, PropTypes } from 'react'

import {
  customPropTypes,
  getElementType,
  getUnhandledProps,
  META,
  SUI,
  useKeyOnly,
  useKeyOrValueAndKey,
} from '../../lib'
import Icon from '../../elements/Icon'

const _meta = {
  name: 'MenuItem',
  type: META.TYPES.COLLECTION,
  parent: 'Menu',
  props: {
    color: SUI.COLORS,
    fitted: ['horizontally', 'vertically'],
    position: ['right'],
  },
}

export default class MenuItem extends Component {
  static propTypes = {
    /** An element type to render as (string or function). */
    as: customPropTypes.as,

    /** A menu item can be active. */
    active: PropTypes.bool,

    /** Primary content. */
    children: PropTypes.node,

    /** Additional classes. */
    className: PropTypes.string,

    /** Additional colors can be specified. */
    color: PropTypes.oneOf(_meta.props.color),

    /** Shorthand for primary content. */
    content: customPropTypes.contentShorthand,

    /** A menu item or menu can remove element padding, vertically or horizontally. */
    fitted: PropTypes.oneOfType([
      PropTypes.bool,
      PropTypes.oneOf(_meta.props.fitted),
    ]),

    /** A menu item may include a header or may itself be a header. */
    header: PropTypes.bool,

    /** MenuItem can be only icon. */
    icon: PropTypes.oneOfType([
      PropTypes.bool,
      customPropTypes.itemShorthand,
    ]),

    /** MenuItem index inside Menu. */
    index: PropTypes.number,

    /** A menu item can be link. */
    link: PropTypes.bool,

    /** Internal name of the MenuItem. */
    name: PropTypes.string,

    /** Render as an `a` tag instead of a `div` and called with event on MenuItem click. */
    onClick: PropTypes.func,

    /** A menu item can take right position. */
    position: PropTypes.oneOf(_meta.props.position),
  }

  static _meta = _meta

  handleClick = (e) => {
    const { index, name, onClick } = this.props

    if (onClick) onClick(e, { name, index })
  }

  render() {
    const {
      active,
      children,
      className,
      color,
{'fraction_non_alphanumeric': 0.12732407625323605, 'fraction_numerical': 0.0007060484819957637, 'mean_word_length': 2.6701208981001727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3846240', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1295, 'n_words': 402}