<commit_before>var React = require('react');
var Formiojs = require('formiojs');
var FormioComponent = require('./FormioComponent.jsx');
var _ = require('lodash');

require('./components');

module.exports = React.createClass({
  displayName: 'Formio',
  getInitialState: function() {
    if (this.props.submission && this.props.submission.data) {
      this.data = _.clone(this.props.submission.data);
    }
    return {
      form: this.props.form || {},
      submission: this.props.submission || {},
      submissions: this.props.submissions || [],
      alerts: [],
      isLoading: (this.props.form ? false : true),
      isSubmitting: false,
      isValid: true
    };
  },
  getDefaultProps: function() {
    return {
      readOnly: false,
      formAction: false
    };
  },
  componentWillMount: function() {
    this.data = this.data || {};
    this.inputs = {};
  },
  attachToForm: function(component) {
    this.inputs[component.props.component.key] = component;
    this.validate(component);
  },
  detachFromForm: function(component) {
    delete this.inputs[component.props.name];
    delete this.data[component.props.name];
  },
  onChange: function(component) {
    this.data[component.props.component.key] = component.state.value;
    this.validate(component);
    if (typeof this.props.onChange === 'function') {
      this.props.onChange({data: this.data});
    }
  },
  validate: _.debounce(function(component) {
    var state = {
      isValid: true,
      errorMessage: ''
    };
    // Validate each item if multiple.
    if (component.props.component.multiple) {
      component.state.value.forEach(function(item, index) {
        if (state.isValid) {
          state = this.validateItem(item, component);
        }
      }.bind(this));
    }<commit_msg>Add more data to onChange event.<commit_after>var React = require('react');
var Formiojs = require('formiojs');
var FormioComponent = require('./FormioComponent.jsx');
var _ = require('lodash');

require('./components');

module.exports = React.createClass({
  displayName: 'Formio',
  getInitialState: function() {
    if (this.props.submission && this.props.submission.data) {
      this.data = _.clone(this.props.submission.data);
    }
    return {
      form: this.props.form || {},
      submission: this.props.submission || {},
      submissions: this.props.submissions || [],
      alerts: [],
      isLoading: (this.props.form ? false : true),
      isSubmitting: false,
      isValid: true
    };
  },
  getDefaultProps: function() {
    return {
      readOnly: false,
      formAction: false
    };
  },
  componentWillMount: function() {
    this.data = this.data || {};
    this.inputs = {};
  },
  attachToForm: function(component) {
    this.inputs[component.props.component.key] = component;
    this.validate(component);
  },
  detachFromForm: function(component) {
    delete this.inputs[component.props.name];
    delete this.data[component.props.name];
  },
  onChange: function(component) {
    this.data[component.props.component.key] = component.state.value;
    this.validate(component);
    if (typeof this.props.onChange === 'function') {
      this.props.onChange({data: this.data}, component.props.component.key, component.state.value);
    }
  },
  validate: _.debounce(function(component) {
    var state = {
      isValid: true,
      errorMessage: ''
    };
    // Validate each item if multiple.
    if (component.props.component.multiple) {
      component.state.value.forEach(function(item, index) {
        if (state.isValid) {
          state = this.validateItem(item, component);
        }
      }.bind(this));
    }
{'fraction_non_alphanumeric': 0.15122353588122078, 'fraction_numerical': 0.0, 'mean_word_length': 3.024336283185841, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4067759', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1099, 'n_words': 197}