<commit_before>import React, {PropTypes} from 'react'
import styles from 'style:@sanity/components/menus/default'
import Ink from 'react-ink'
// import enhanceWithClickOutside from 'react-click-outside'

class DefaultMenu extends React.Component {
  static propTypes = {
    onAction: PropTypes.func.isRequired,
    opened: PropTypes.bool,
    origin: PropTypes.oneOf(['top-left', 'top-right', 'bottom-left', 'bottom-right']),
    ripple: PropTypes.bool,
    fullWidth: PropTypes.bool,
    className: PropTypes.string,
    items: PropTypes.arrayOf(
      PropTypes.shape({
        title: PropTypes.string.isRequired,
        index: PropTypes.string.isRequired,
        icon: PropTypes.node
      })
    )
  }

  static defaultProps = {
    menuOpened: false,
    origin: 'top-left',
    icon: false,
    ripple: true
  }

  constructor(props, context) {
    super(props, context)
    this.handleItemClick = this.handleItemClick.bind(this)
  }

  handleClickOutside() {
    this.setState({menuOpened: false})
  }

  handleItemClick(event) {
    const actionId = event.currentTarget.getAttribute('data-action-id')
    this.props.onAction(
      this.props.items.find(item => item.index === actionId)
    )
  }

  render() {
    const {items, origin, ripple, fullWidth, className} = this.props
    const originStyle = styles[`origin__${origin}`]

    return (
      <div className={`${this.props.opened ? styles.opened : styles.closed} ${originStyle} ${fullWidth && styles.fullWidth} ${className}`}>
        <ul className={styles.list}>
          {
            items.map((item, i) => {
              const Icon = item.icon
              return (
                <li key={i} className={`${styles.item} ${item.divider && styles.divider}`}>
                  <a
                    onClick={this.handleItemClick}
                    data-action-id={item.index}<commit_msg>fixing menus<commit_after>import React, {PropTypes} from 'react'
import styles from 'style:@sanity/components/menus/default'
import Ink from 'react-ink'
// import enhanceWithClickOutside from 'react-click-outside'

class DefaultMenu extends React.Component {
  static propTypes = {
    onAction: PropTypes.func.isRequired,
    opened: PropTypes.bool,
    origin: PropTypes.oneOf(['top-left', 'top-right', 'bottom-left', 'bottom-right']),
    ripple: PropTypes.bool,
    fullWidth: PropTypes.bool,
    className: PropTypes.string,
    items: PropTypes.arrayOf(
      PropTypes.shape({
        title: PropTypes.string.isRequired,
        icon: PropTypes.node
      })
    )
  }

  static defaultProps = {
    menuOpened: false,
    origin: 'top-left',
    icon: false,
    ripple: true
  }

  constructor(props, context) {
    super(props, context)
    this.handleItemClick = this.handleItemClick.bind(this)
  }

  handleClickOutside() {
    this.setState({menuOpened: false})
  }

  handleItemClick(event) {
    const actionId = event.currentTarget.getAttribute('data-action-id')
    this.props.onAction(this.props.items[actionId])
  }

  render() {
    const {items, origin, ripple, fullWidth, className} = this.props
    const originStyle = styles[`origin__${origin}`]

    return (
      <div className={`${this.props.opened ? styles.opened : styles.closed} ${originStyle} ${fullWidth && styles.fullWidth} ${className}`}>
        <ul className={styles.list}>
          {
            items.map((item, i) => {
              const Icon = item.icon
              return (
                <li key={i} className={`${styles.item} ${item.divider && styles.divider}`}>
                  <a
                    onClick={this.handleItemClick}
                    data-action-id={i}
{'fraction_non_alphanumeric': 0.13358988455195162, 'fraction_numerical': 0.0, 'mean_word_length': 2.794577685088634, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, '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': '2726490', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1092, 'n_words': 215}