<commit_before>// @flow
import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';

import CellCreatorButtons from './cell-creator-buttons';

export default class CellCreator extends React.Component {
  props: {
    above: boolean,
    id: string,
  };

  constructor() {
    super();
    this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
    this.setHoverElement = this.setHoverElement.bind(this);
    this.updateVisibility = this.updateVisibility.bind(this);
  }

  state = {
    show: false,
  };

  componentDidMount() {
    // Listen to the page level mouse move event and manually check for
    // intersection because we don't want the hover region to actually capture
    // any mouse events.  The hover region is an invisible element that
    // describes the "hot region" that toggles the creator buttons.
    document.addEventListener('mousemove', this.updateVisibility, false);
  }

  componentWillUnmount() {
    document.removeEventListener('mousemove', this.updateVisibility);
  }

  setHoverElement(el) {
    this.hoverElement = el;
  }

  updateVisibility(mouseEvent) {
    if (this.hoverElement) {
      const x = mouseEvent.clientX;
      const y = mouseEvent.clientY;
      const regionRect = this.hoverElement.getBoundingClientRect();
      const show = (regionRect.left < x && x < regionRect.right) &&
                   (regionRect.top < y && y < regionRect.bottom);
      this.setState({ show });
    }
  }


  render() {
    return (
      <div className="creator-hover-mask">
        <div className="creator-hover-region" ref={this.setHoverElement}>
          {this.state.show || this.props.id === null ?
            (<CellCreatorButtons above={this.props.above} id={this.props.id} />) :
            ''}
        </div>
      </div>);
  }

}<commit_msg>chore(CellCreator): Add Flow types to CellCreator<commit_after>// @flow
import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';

import CellCreatorButtons from './cell-creator-buttons';

export default class CellCreator extends React.Component {


  constructor() {
    super();
    this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
    this.setHoverElement = this.setHoverElement.bind(this);
    this.updateVisibility = this.updateVisibility.bind(this);
  }

  state = {
    show: false,
  };

  componentDidMount() {
    // Listen to the page level mouse move event and manually check for
    // intersection because we don't want the hover region to actually capture
    // any mouse events.  The hover region is an invisible element that
    // describes the "hot region" that toggles the creator buttons.
    document.addEventListener('mousemove', this.updateVisibility, false);
  }

  componentWillUnmount() {
    document.removeEventListener('mousemove', this.updateVisibility);
  }

  setHoverElement(el) {
    this.hoverElement = el;
  }

  props: {
    above: boolean,
    id: string,
  };

  updateVisibility(mouseEvent) {
    if (this.hoverElement) {
      const x = mouseEvent.clientX;
      const y = mouseEvent.clientY;
      const regionRect = this.hoverElement.getBoundingClientRect();
      const show = (regionRect.left < x && x < regionRect.right) &&
                   (regionRect.top < y && y < regionRect.bottom);
      this.setState({ show });
    }
  }


  render() {
    return (
      <div className="creator-hover-mask">
        <div className="creator-hover-region" ref={this.setHoverElement}>
          {this.state.show || this.props.id === null ?
            (<CellCreatorButtons above={this.props.above} id={this.props.id} />) :
            ''}
        </div>
      </div>);
  }

}
{'fraction_non_alphanumeric': 0.11988146551724138, 'fraction_numerical': 0.0, 'mean_word_length': 3.009719222462203, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 13, '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': '6261833', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1068, 'n_words': 261}