<commit_before>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import themed from 'react-themed'
import { Field } from '@rentpath/react-ui-core'

@themed(/^RequiredField/)

export default class RequiredField extends Component {
  static propTypes = {
    theme: PropTypes.object,
    name: PropTypes.string,
    type: PropTypes.string,
    placeholder: PropTypes.string,
    onChange: PropTypes.func,
  }

  static defaultProps = {
    theme: {},
  }

  constructor(props) {
    super(props)
    this.inputChange = this.inputChange.bind(this)
    this.state = { labelVisible: true }
  }

  get fieldLabel() {
    const { placeholder, theme } = this.props

    if (this.state.labelVisible) {
      return {
        text: placeholder,
        className: theme.RequiredField_Label,
      }
    }

    return null
  }

  inputChange(event) {
    if (event.target.value) {
      if (this.state.labelVisible) {
        this.setState({ labelVisible: false })
      }
    } else {
      this.setState({ labelVisible: true })
    }
    if (this.props.onChange &&
      typeof this.props.onChange === 'function') {
      this.props.onChange(event)
    }
  }

  render() {
    const {
      theme,
      placeholder,
      ...props
    } = this.props

    return (
      <Field
        className={theme.RequiredField}
        onChange={this.inputChange}
        label={this.fieldLabel}
        {...props}
      /><commit_msg>Being too cautious<commit_after>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import themed from 'react-themed'
import { Field } from '@rentpath/react-ui-core'

@themed(/^RequiredField/)

export default class RequiredField extends Component {
  static propTypes = {
    theme: PropTypes.object,
    name: PropTypes.string,
    type: PropTypes.string,
    placeholder: PropTypes.string,
    onChange: PropTypes.func,
  }

  static defaultProps = {
    theme: {},
  }

  constructor(props) {
    super(props)
    this.inputChange = this.inputChange.bind(this)
    this.state = { labelVisible: true }
  }

  get fieldLabel() {
    const { placeholder, theme } = this.props

    if (this.state.labelVisible) {
      return {
        text: placeholder,
        className: theme.RequiredField_Label,
      }
    }

    return null
  }

  inputChange(event) {
    if (event.target.value) {
      if (this.state.labelVisible) {
        this.setState({ labelVisible: false })
      }
    } else {
      this.setState({ labelVisible: true })
    }
    if (this.props.onChange) {
      this.props.onChange(event)
    }
  }

  render() {
    const {
      theme,
      placeholder,
      ...props
    } = this.props

    return (
      <Field
        className={theme.RequiredField}
        onChange={this.inputChange}
        label={this.fieldLabel}
        {...props}
      />
{'fraction_non_alphanumeric': 0.12015503875968993, 'fraction_numerical': 0.0, 'mean_word_length': 2.3878281622911692, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3106764', 'n_tokens_mistral': 860, 'n_tokens_neox': 861, 'n_words': 181}