<commit_before>import React, { Component } from 'react';
import Validator from '../schema/validation/validator';

export default (FormComponent) => class FieldWithState extends Component {
  constructor(props) {
    super(props);
    this.state = {
      pristine: true,
      touched: false,
      visited: false,
      valid: true,
      errors: []
    };
  }
  _validate(val) {
    let errors = [];
    if (this.props.$formr && this.props.$formr.schema) {
      const validator = new Validator(this.props.$formr.schema);
      errors = validator.validate(val);
      console.log('VAL', errors);
    } else {
      console.log('NO VAL ', this.props);
    }
    this.setState({ errors });
  }
  render() {
    console.log('STATE', this.state, this.props);
    return <FormComponent {...this.props}
      onFocus={() => this.setState({ visited: true, active: true })}
      onBlur={() => { this.setState({ touched: true, active: false }); this._validate(this.props.value); } }<commit_msg>Default state + remove logging<commit_after>import React, { Component } from 'react';
import Validator from '../schema/validation/validator';

export default (FormComponent) => class FieldWithState extends Component {
  constructor(props) {
    super(props);
    this.state = {
      pristine: props.pristine || true,
      touched: props.touched || false,
      visited: props.visited || false,
      valid: props.valid || true,
      errors: []
    };
  }
  _validate(val) {
    let errors = [];
    if (this.props.$formr && this.props.$formr.schema) {
      const validator = new Validator(this.props.$formr.schema);
      errors = validator.validate(val);
    }
    this.setState({ errors });
  }
  render() {
    return <FormComponent {...this.props}
      onFocus={() => this.setState({ visited: true, active: true })}
      onBlur={() => { this.setState({ touched: true, active: false }); this._validate(this.props.value); } }
{'fraction_non_alphanumeric': 0.1603331598125976, 'fraction_numerical': 0.0, 'mean_word_length': 3.08067940552017, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7429048', 'n_tokens_mistral': 570, 'n_tokens_neox': 581, 'n_words': 134}