<commit_before>import React from 'react';
import style from 'PVWStyle/ReactWidgets/TextInputWidget.mcss';

export default React.createClass({

  displayName: 'TextInputWidget',

  propTypes: {
    className: React.PropTypes.string,
    name: React.PropTypes.string,
    onChange: React.PropTypes.func,
    value: React.PropTypes.string,
    maxWidth: React.PropTypes.string,
    icon: React.PropTypes.string,
  },

  getDefaultProps() {
    return {
      value: '',
      className: '',
      icon: `${style.checkIcon}`,
    };
  },

  getInitialState() {
    return {
      editing: false,
      valueRep: this.props.value,
    };
  },

  valueChange(e) {
    var newVal = e.target.value;
    this.setState({ editing: true, valueRep: newVal });
  },

  endEditing() {
    if (!this.state.editing) return;
    this.setState({ editing: false });

    if (!this.props.onChange) return;
    if (this.props.name) {
      this.props.onChange(this.state.valueRep, this.props.name);
    } else {
      this.props.onChange(this.state.valueRep);
    }
  },

  handleKeyUp(e) {
    if (!this.textInput) return;
    if (e.key === 'Enter' || e.key === 'Return') {
      this.textInput.blur();
    } else if (e.key === 'Escape') {
      this.setState({ valueRep: this.props.value });
    }
  },

  render() {
    const inlineStyle = this.props.maxWidth ? { maxWidth: this.props.maxWidth } : {};
    return (
      <div className={[style.container, this.props.className].join(' ')}>
        <input
          className={style.entry}
          type="text"
          value={this.state.editing ? this.state.valueRep : this.props.value}
          style={inlineStyle}
          onChange={this.valueChange}
          onBlur={this.endEditing}
          onKeyUp={this.handleKeyUp}
          ref={(c) => { this.textInput = c; }}
        />
        { // Use the check icon by default, but allow customization, for example: fa-search<commit_msg>fix(TextInputWidget): allow placeholder attr on text input via prop<commit_after>import React from 'react';
import style from 'PVWStyle/ReactWidgets/TextInputWidget.mcss';

export default React.createClass({

  displayName: 'TextInputWidget',

  propTypes: {
    className: React.PropTypes.string,
    name: React.PropTypes.string,
    onChange: React.PropTypes.func,
    placeholder: React.PropTypes.string,
    value: React.PropTypes.string,
    maxWidth: React.PropTypes.string,
    icon: React.PropTypes.string,
  },

  getDefaultProps() {
    return {
      value: '',
      className: '',
      icon: `${style.checkIcon}`,
    };
  },

  getInitialState() {
    return {
      editing: false,
      valueRep: this.props.value,
    };
  },

  valueChange(e) {
    var newVal = e.target.value;
    this.setState({ editing: true, valueRep: newVal });
  },

  endEditing() {
    if (!this.state.editing) return;
    this.setState({ editing: false });

    if (!this.props.onChange) return;
    if (this.props.name) {
      this.props.onChange(this.state.valueRep, this.props.name);
    } else {
      this.props.onChange(this.state.valueRep);
    }
  },

  handleKeyUp(e) {
    if (!this.textInput) return;
    if (e.key === 'Enter' || e.key === 'Return') {
      this.textInput.blur();
    } else if (e.key === 'Escape') {
      this.setState({ valueRep: this.props.value });
    }
  },

  render() {
    const inlineStyle = this.props.maxWidth ? { maxWidth: this.props.maxWidth } : {};
    return (
      <div className={[style.container, this.props.className].join(' ')}>
        <input
          className={style.entry}
          type="text"
          value={this.state.editing ? this.state.valueRep : this.props.value}
          placeholder={this.props.placeholder}
          style={inlineStyle}
          onChange={this.valueChange}
          onBlur={this.endEditing}
          onKeyUp={this.handleKeyUp}
          ref={(c) => { this.textInput = c; }}
        />
        { // Use the check icon by default, but allow customization, for example: fa-search
{'fraction_non_alphanumeric': 0.1496735308890005, 'fraction_numerical': 0.0, 'mean_word_length': 2.620909090909091, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4880986', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1268, 'n_words': 240}