<commit_before>/** @jsx React.DOM */

define([
  "React"
], function(React) {
  return React.createClass({
    propTypes: {
      children: React.PropTypes.component.isRequired,
      model: React.PropTypes.object.isRequired
    },

    onInputChange: function(event) {
      this.props.model.set(event.target.name, event.target.value);
    },

    render: function() {
      var errorBlock, errors, helpBlock;

      var attribute = this.props.attribute;
      var className = "form-group";
      var fieldId = attribute + "-field";

      // Find any errors matching this attribute.
      if (this.props.model.validationError != null) {
        errors = this.props.model.validationError.filter(function(e) {
          return (e.attribute === attribute);
        });
      }

      if (errors != null && errors.length > 0) {
        className += " has-error";
        errorBlock = errors.map(function(error) {
          return <div className="help-block"><strong>{error.message}</strong></div>;
        });
      }

      if (this.props.help != null) {
        helpBlock = <div className="help-block">{this.props.help}</div>;
      }

      // Assume there is a single child of either <input> or <textarea>, and add
      // the needed props to make it an input for this attribute.
      var formControlChild = React.addons.cloneWithProps(
        React.Children.only(this.props.children),
        {
          className: "form-control",
          id: fieldId,
          name: attribute,
          onChange: this.onInputChange,
          value: this.props.model.get(attribute)
        }
      );

      return (
        <div className={className}>
          <label htmlFor={fieldId} className="control-label">
            {this.props.label}
          </label>
          <div>
            {formControlChild}
            {helpBlock}
            {errorBlock}
          </div>
        </div>
      );
    }
  });
});<commit_msg>Changing FormGroup to be used as an error component<commit_after>/** @jsx React.DOM */

define([
  "React"
], function(React) {
  return React.createClass({
    propTypes: {
      children: React.PropTypes.component,
      model: React.PropTypes.object.isRequired
    },

    onInputChange: function(event) {
      this.props.model.set(event.target.name, event.target.value);
    },

    render: function() {
      var errorBlock, errors, helpBlock;

      var attribute = this.props.attribute;
      var className = "form-group";
      var fieldId = attribute + "-field";

      // Find any errors matching this attribute.
      if (this.props.model.validationError != null) {
        errors = this.props.model.validationError.filter(function(e) {
          return (e.attribute === attribute);
        });
      }

      if (errors != null && errors.length > 0) {
        className += " has-error";
        errorBlock = errors.map(function(error, i) {
          return <div key={i} className="help-block"><strong>{error.message}</strong></div>;
        });
      }

      if (this.props.help != null) {
        helpBlock = <div className="help-block">{this.props.help}</div>;
      }

      // Assume there is a single child of either <input> or <textarea>, and add
      // the needed props to make it an input for this attribute.
      var formControlChild =
      this.props.children ?
        React.addons.cloneWithProps(
          React.Children.only(this.props.children),
          {
            className: "form-control",
            id: fieldId,
            name: attribute,
            onChange: this.onInputChange,
            value: this.props.model.get(attribute)
          }
        ) :
        null;

      return (
        <div className={className}>
          {
            this.props.children ?
            <div>
              <label htmlFor={fieldId} className="control-label">
                {this.props.label}
              </label>
              <div>
                {formControlChild}
                {helpBlock}
                {errorBlock}
              </div>
            </div> :
            errorBlock
          }
        </div>
      );
    }
  });
});
{'fraction_non_alphanumeric': 0.13050888726564402, 'fraction_numerical': 0.0004869734599464329, 'mean_word_length': 1.8667131891137474, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, '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': '6078406', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1134, 'n_words': 250}