<commit_before>const React = require('react')

const Result = React.createClass({

  propTypes: {
    active: React.PropTypes.bool.isRequired,
    value: React.PropTypes.object.isRequired,
    activate: React.PropTypes.func.isRequired,
    onClick: React.PropTypes.func.isRequired,
  },

  click () {
    this.props.onClick(this.props.value)
  },

  activate () {
    this.props.activate(this.props.value)
  },

  render () {
    const { active, value } = this.props
    return React.createElement(
      'li',
      {
        onClick: this.click,
        onMouseOver: this.activate,
        className: active ? 'active' : 'inactive',
      },
      React.createElement('img', { src: value.icon, alt: '' }),
      React.createElement('h2', null, value.title),
      value.subtitle && React.createElement('h3', null, value.subtitle)
    )
  },
})

module.exports = Result<commit_msg>Force the active element to always be in view.<commit_after>const React = require('react')

const Result = React.createClass({

  propTypes: {
    active: React.PropTypes.bool.isRequired,
    value: React.PropTypes.object.isRequired,
    activate: React.PropTypes.func.isRequired,
    onClick: React.PropTypes.func.isRequired,
  },

  click () {
    this.props.onClick(this.props.value)
  },

  activate () {
    this.props.activate(this.props.value)
  },

  componentDidUpdate () {
    if (this.props.active) {
      const list = this.el.parentElement
      const listTop = list.offsetTop
      const listHeight = list.offsetHeight
      const elementTop = this.el.getBoundingClientRect().top - listTop
      const elementBottom = elementTop + this.el.offsetHeight
      if (listHeight < elementBottom) {
        this.el.scrollIntoView(false)
      } else if (elementTop < 0) {
        this.el.scrollIntoView(true)
      }
    }
  },

  setReference (el) {
    this.el = el
  },

  render () {
    const { active, value } = this.props
    return React.createElement(
      'li',
      {
        onClick: this.click,
        onMouseOver: this.activate,
        className: active ? 'active' : 'inactive',
        ref: this.setReference,
      },
      React.createElement('img', { src: value.icon, alt: '' }),
      React.createElement('h2', null, value.title),
      value.subtitle && React.createElement('h3', null, value.subtitle)
    )
  },
})

module.exports = Result
{'fraction_non_alphanumeric': 0.13514662133446664, 'fraction_numerical': 0.0021249468763280916, 'mean_word_length': 2.748407643312102, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6477036', 'n_tokens_mistral': 731, 'n_tokens_neox': 729, 'n_words': 138}