<commit_before>import * as React from 'react';
import Dpad from './Dpad';

export default class Chat extends React.Component < any,
any > {
  constructor(props) {
    super(props);
    this.state = {
      input: ''
    };
  }

  public _onChange(event : any) : void {
    this.setState({input: event.target.value});
  }

  private _submitChat(message : String) {
    this
      .props
      .addChat({
        text: message,
        user: this.props.user || 'Guest',
        date: JSON.stringify(new Date())
      });
  }

  onSubmit(e : any) {
    e.preventDefault();
    this._submitChat(this.state.input);
    this.setState({input: ''});
  }

  onKeyDown(e : any) {
    const fakeKeyDown = id => {
      const btn = document
        .getElementById(id)
        .classList
      btn.add('fakeHover');
      setTimeout(() => btn.remove('fakeHover'), 200);
    }
    if (e.keyCode === 37) {
      fakeKeyDown('d-left');
      return this._submitChat('\\left');
    }
    if (e.keyCode === 38) {
      fakeKeyDown('d-up');
      return this._submitChat('\\up');
    }
    if (e.keyCode === 39) {
      fakeKeyDown('d-right');
      return this._submitChat('\\right');
    }
    if (e.keyCode === 40) {
      fakeKeyDown('d-down');
      return this._submitChat('\\down');
    }
    if (e.keyCode === 65) {
      fakeKeyDown('control-a');
      return this._submitChat('\\A');
    }
    if (e.keyCode === 66) {
      fakeKeyDown('control-b');
      return this._submitChat('\\B');
    }
  }

  public render() {
    return (
      <div
        className='inputForm'
        onKeyDown={this
        .onKeyDown
        .bind(this)}>
        <Dpad
          move={function (dir) {this._submitChat('\\' + dir)}.bind(this)}
          action = {function(l) {this._submitChat('\\' + l)}.bind(this)}/>
        <form onSubmit={this
          .onSubmit
          .bind(this)}>
          <input value={this.state.input} onChange={e => this._onChange(e)} autoFocus/>
          <input className='submitButton' type='submit'/>
        </form>
      </div>
    )
  }
}<commit_msg>feat (emojis): add the emoji component<commit_after>import * as React from 'react';
import Dpad from './Dpad';
const EmojiPicker = require('emojione-picker');
const emojione = require('emojione');

export default class Chat extends React.Component < any,
any > {
  constructor(props) {
    super(props);
    this.state = {
      input: '',
      emojiToggle: false
    };
  }

  public _onChange(event : any) : void {
    this.setState({input: event.target.value});
  }

  private _submitChat(message : String) {
    this
      .props
      .addChat({
        text: message,
        user: this.props.user || 'Guest',
        date: JSON.stringify(new Date())
      });
  }

  onSubmit(e : any) {
    e.preventDefault();
    this._submitChat(this.state.input);
    this.setState({input: ''});
  }

  onKeyDown(e : any) {
    const fakeKeyDown = id => {
      const btn = document
        .getElementById(id)
        .classList
      btn.add('fakeHover');
      setTimeout(() => btn.remove('fakeHover'), 200);
    }
    if (e.keyCode === 37) {
      fakeKeyDown('d-left');
      return this._submitChat('\\left');
    }
    if (e.keyCode === 38) {
      fakeKeyDown('d-up');
      return this._submitChat('\\up');
    }
    if (e.keyCode === 39) {
      fakeKeyDown('d-right');
      return this._submitChat('\\right');
    }
    if (e.keyCode === 40) {
      fakeKeyDown('d-down');
      return this._submitChat('\\down');
    }
    if (e.keyCode === 65) {
      fakeKeyDown('control-a');
      return this._submitChat('\\A');
    }
    if (e.keyCode === 66) {
      fakeKeyDown('control-b');
      return this._submitChat('\\B');
    }
  }

  onPressEmojiToggle() {
    this.setState( {emojiToggle: this.state.emojiToggle ? false : true} );
  }

  public render() {
    return (
      <div
        className='inputForm'
        onKeyDown={this
        .onKeyDown
        .bind(this)}>
        <Dpad
          move={function (dir) {this._submitChat('\\' + dir)}.bind(this)}
          //action = {function(l) {this._submitChat('\\' + l)}.bind(this)}/>
          action = {this.onPressEmojiToggle.bind(this)}/>
        <form onSubmit={this
          .onSubmit
          .bind(this)}>
          <input value={this.state.input} onChange={e => this._onChange(e)} autoFocus/>
          <input className='submitButton' type='submit'/>
        </form> 
        { this.state.emojiToggle ? 
          <div className='emojiContainer'>
            <EmojiPicker 
              onChange={ data => {
                const emoji = emojione.toImage(data.shortname).split(' ')[2].substring(5,7); 
                this.setState( {input: this.state.input + " " + emoji})}}/>
          </div> : null}
      </div>
    )
  }
}
{'fraction_non_alphanumeric': 0.1726814939152329, 'fraction_numerical': 0.0069240453210239195, 'mean_word_length': 2.1382488479262673, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 30, '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': '3287389', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1550, 'n_words': 291}