<commit_before>import React, { Component, PropTypes } from 'react'
import Star from './star'

export { Star } from './star'

export default class Rater extends Component {
  constructor(props) {
    super(props)
    this.state = {
      lastRating: props.rating,
      rating: props.rating,
      isRating: false
    }
  }
  componentWillReceiveProps(nextProps) {
    this.setState({
      rating: nextProps.rating
    })
  }
  handleMouseEnter(e) {
    let { rating } = getRatingFromDOMEvent(e, this.props)
    if (rating > 0) {
      this.setState({
        rating: 0,
        isRating: true
      })
    }
  }
  handleMouseMove(e) {
    let { rating } = getRatingFromDOMEvent(e, this.props)
      , callback = this.props.onRate
    if (rating > 0) {
      this.setState({
        rating: rating,
        isRating: true
      })
      callback && callback(rating)
    }
  }
  handleMouseLeave() {
    let callback = this.props.onRate
      , state = this.state
    callback && callback(state.lastRating)
    this.setState({
      rating: state.lastRating,
      isRating: false
    })
  }
  handleClick(e) {
    let { index, rating } = getRatingFromDOMEvent(e, this.props)
      , lastRating = Number(this.state.lastRating)
      , callback = this.props.onRate
    if (rating < 0 || this.refs[`star-${index}`].props.isDisabled) {
      return
    }
    this.setState({
      rating,
      lastRating: rating
    })
    callback && callback(rating, lastRating)
  }
  render() {
    let total = Number(this.props.total)
      , limit = Number(this.props.limit)
      , rating = Number(this.state.rating)
      , interactive = this.props.interactive
      , children = Array.prototype.concat(this.props.children).filter(Boolean)
      , nodes
    limit = (this.props.limit === void 0)? total: limit
    nodes = Array(total).join(',').split(',').map((_, i) => {
      let starProps = {
        isActive: (!this.state.isRating && i < rating) ? true: false,
        willBeActive: (this.state.isRating && i < rating)? true: false,
        isDisabled: (i < limit) ? false: true,
        key: `star-${i}`,
        ref: `star-${i}`
      }
      if (children.length) {
        return React.cloneElement(children[i % children.length], starProps)
      } else {
        return (<Star {...starProps} />)
      }
    })
    if (interactive) {
      return (
        <div className="react-rater"
             onMouseEnter={this.handleMouseEnter.bind(this)}
             onMouseLeave={this.handleMouseLeave.bind(this)}
             onMouseMove={this.handleMouseMove.bind(this)}
             onClick={this.handleClick.bind(this)}
             {...this.props}>{nodes}</div>
      )
    } else {
      return (
        <div className="react-rater is-disabled" {...this.props}>{nodes}</div>
      )
    }
  }
}

Rater.defaultProps = {
  total: 5,
  rating: 0,
  interactive: true
}<commit_msg>Fixed unknown prop issue<commit_after>import React, { Component, PropTypes } from 'react'
import Star from './star'

export { Star } from './star'

export default class Rater extends Component {
  constructor(props) {
    super(props)
    this.state = {
      lastRating: props.rating,
      rating: props.rating,
      isRating: false
    }
  }
  componentWillReceiveProps(nextProps) {
    this.setState({
      rating: nextProps.rating
    })
  }
  handleMouseEnter(e) {
    let { rating } = getRatingFromDOMEvent(e, this.props)
    if (rating > 0) {
      this.setState({
        rating: 0,
        isRating: true
      })
    }
  }
  handleMouseMove(e) {
    let { rating } = getRatingFromDOMEvent(e, this.props)
      , callback = this.props.onRate
    if (rating > 0) {
      this.setState({
        rating: rating,
        isRating: true
      })
      callback && callback(rating)
    }
  }
  handleMouseLeave() {
    let callback = this.props.onRate
      , state = this.state
    callback && callback(state.lastRating)
    this.setState({
      rating: state.lastRating,
      isRating: false
    })
  }
  handleClick(e) {
    let { index, rating } = getRatingFromDOMEvent(e, this.props)
      , lastRating = Number(this.state.lastRating)
      , callback = this.props.onRate
    if (rating < 0 || this.refs[`star-${index}`].props.isDisabled) {
      return
    }
    this.setState({
      rating,
      lastRating: rating
    })
    callback && callback(rating, lastRating)
  }
  render() {
    let {total, limit, rating, interactive, children, ...others} = this.props
    total = Number(total)
    limit = Number(limit)
    rating = Number(this.state.rating)
    children = Array.prototype.concat(children).filter(Boolean)
    limit = (this.props.limit === void 0)? total: limit
    let nodes = Array(total).join(',').split(',').map((_, i) => {
      let starProps = {
        isActive: (!this.state.isRating && i < rating) ? true: false,
        willBeActive: (this.state.isRating && i < rating)? true: false,
        isDisabled: (i < limit) ? false: true,
        key: `star-${i}`,
        ref: `star-${i}`
      }
      if (children.length) {
        return React.cloneElement(children[i % children.length], starProps)
      } else {
        return (<Star {...starProps} />)
      }
    })
    if (interactive) {
      return (
        <div className="react-rater"
             onMouseEnter={this.handleMouseEnter.bind(this)}
             onMouseLeave={this.handleMouseLeave.bind(this)}
             onMouseMove={this.handleMouseMove.bind(this)}
             onClick={this.handleClick.bind(this)}
             {...others}>{nodes}</div>
      )
    } else {
      return (
        <div className="react-rater is-disabled" {...this.props}>{nodes}</div>
      )
    }
  }
}

Rater.defaultProps = {
  total: 5,
  rating: 0,
  interactive: true
}
{'fraction_non_alphanumeric': 0.14186005932647008, 'fraction_numerical': 0.002442854650148316, 'mean_word_length': 2.319050376375217, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '1245728', 'n_tokens_mistral': 1833, 'n_tokens_neox': 1793, 'n_words': 360}