<commit_before>import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import {
  ControlLabel,
  InputGroup,
  FormGroup,
  FormControl,
  HelpBlock,
} from 'patternfly-react';
import { rawComponents } from '@data-driven-forms/pf3-component-mapper';

import RequiredLabel from './required-label';

const DataDrivenInputWithPrefix = ({
  FieldProvider,
  prefixOptions,
  validate,
  prefixSeparator,
  ...rest
}) => {
  const [prefix, setPrefix] = useState();
  /**
   * get string prefix from initial value on after initial component mount
   */
  useEffect(() => {
    const value = rest.formOptions.getFieldState(rest.name);
    if (value.initial) {
      setPrefix(value.initial.substring(0, value.initial.indexOf(prefixSeparator) + prefixSeparator.length));
    }
  }, []);

  /**
   * create regular expression to strip the value of its prefix
   */
  const prefixMatcher = new RegExp(`.*${prefixSeparator}`);
  return (
    <FieldProvider
      {...rest}
      validate={(value) => {
        let implicitValidator;
        let missingPrefix;
        if (validate) {
          implicitValidator = validate(value);
        }
        if (prefix) {
          missingPrefix = (value && value.replace(prefixMatcher, '') === '') || (value === prefix) ? __('Required') : undefined;
        }
        return implicitValidator || missingPrefix;
      }}
    >
      {({
        isRequired,
        label,
        input: { name, onChange, value },
        meta: { error },
      }) => (
        <FormGroup name={name} validationState={error && 'error'}>
          <div>
            <ControlLabel>
              {isRequired ? <RequiredLabel label={label} /> : label }
            </ControlLabel>
          </div>
          <div className="dynamic-prefix-input">
            <rawComponents.Select<commit_msg>Add missing class to select<commit_after>import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import {
  ControlLabel,
  InputGroup,
  FormGroup,
  FormControl,
  HelpBlock,
} from 'patternfly-react';
import { rawComponents } from '@data-driven-forms/pf3-component-mapper';

import RequiredLabel from './required-label';

const DataDrivenInputWithPrefix = ({
  FieldProvider,
  prefixOptions,
  validate,
  prefixSeparator,
  ...rest
}) => {
  const [prefix, setPrefix] = useState();
  /**
   * get string prefix from initial value on after initial component mount
   */
  useEffect(() => {
    const value = rest.formOptions.getFieldState(rest.name);
    if (value.initial) {
      setPrefix(value.initial.substring(0, value.initial.indexOf(prefixSeparator) + prefixSeparator.length));
    }
  }, []);

  /**
   * create regular expression to strip the value of its prefix
   */
  const prefixMatcher = new RegExp(`.*${prefixSeparator}`);
  return (
    <FieldProvider
      {...rest}
      validate={(value) => {
        let implicitValidator;
        let missingPrefix;
        if (validate) {
          implicitValidator = validate(value);
        }
        if (prefix) {
          missingPrefix = (value && value.replace(prefixMatcher, '') === '') || (value === prefix) ? __('Required') : undefined;
        }
        return implicitValidator || missingPrefix;
      }}
    >
      {({
        isRequired,
        label,
        input: { name, onChange, value },
        meta: { error },
      }) => (
        <FormGroup name={name} validationState={error && 'error'}>
          <div>
            <ControlLabel>
              {isRequired ? <RequiredLabel label={label} /> : label }
            </ControlLabel>
          </div>
          <div className="dynamic-prefix-input">
            <rawComponents.Select
              classNamePrefix="ddorg__pf3-component-mapper__select"
{'fraction_non_alphanumeric': 0.13459488272921108, 'fraction_numerical': 0.0013326226012793177, 'mean_word_length': 2.567490494296578, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '6196085', 'n_tokens_mistral': 1023, 'n_tokens_neox': 1042, 'n_words': 240}