<commit_before>import { FieldStore } from '../stores';
import { ReactComponent } from '../types';
import { IFieldData, IWithStoreParamProps, createWithStore, withFieldsRegistered, withParentStore } from '../wrappers';
import { observer } from 'mobx-react';
import { Component, ComponentClass } from 'react';
import * as React from 'react';

export interface IWrappedFieldProps {
  field: FieldStore;
  name?: string;
}

function generateClass<Props>(
  FieldComponent: ReactComponent<Props & IWrappedFieldProps> | string
) {
  if (typeof FieldComponent !== 'string') {
    const WrappedComponent = observer(FieldComponent as ComponentClass<Props & IWrappedFieldProps>);

    return class extends Component<Props & IWithStoreParamProps<FieldStore>, {}> {
      public render() {
        const { __formobx } = this.props;
        const props = {
          field: __formobx.store,
          ...this.props as any,
          __formobx: undefined
        };

        return <WrappedComponent {...props} />;
      }
    };
  } else if (FieldComponent === 'input') {
    return class extends Component<Props & IWithStoreParamProps<FieldStore>, {}> {
      public render() {
        const { __formobx } = this.props;
        const props = {
          ...__formobx.store.asProps,
          ...this.props as any,
          __formobx: undefined
        };

        return <input {...props} />;
      }
    };
  } else {
    throw new Error(`Unsupported string component type '${FieldComponent}'`);
  }
}

export function field<Props>(
  FieldComponent: ReactComponent<Props & IWrappedFieldProps> | string<commit_msg>fix error on regular input field<commit_after>import { FieldStore } from '../stores';
import { ReactComponent } from '../types';
import { IFieldData, IWithStoreParamProps, createWithStore, withFieldsRegistered, withParentStore } from '../wrappers';
import { observer } from 'mobx-react';
import { Component, ComponentClass } from 'react';
import * as React from 'react';

export interface IWrappedFieldProps {
  field: FieldStore;
  name?: string;
}

function generateClass<Props>(
  FieldComponent: ReactComponent<Props & IWrappedFieldProps> | string
) {
  if (typeof FieldComponent !== 'string') {
    const WrappedComponent = observer(FieldComponent as ComponentClass<Props & IWrappedFieldProps>);

    return class extends Component<Props & IWithStoreParamProps<FieldStore>, {}> {
      public render() {
        const { __formobx } = this.props;
        const props = {
          field: __formobx.store,
          ...this.props as any,
          __formobx: undefined
        };

        return <WrappedComponent {...props} />;
      }
    };
  } else if (FieldComponent === 'input') {
    return class extends Component<Props & IWithStoreParamProps<FieldStore>, {}> {
      public render() {
        const { __formobx } = this.props;
        const props = {
          ...__formobx.store.asProps,
          ...this.props as any
        };
        delete props.__formobx;

        return <input {...props} />;
      }
    };
  } else {
    throw new Error(`Unsupported string component type '${FieldComponent}'`);
  }
}

export function field<Props>(
  FieldComponent: ReactComponent<Props & IWrappedFieldProps> | string
{'fraction_non_alphanumeric': 0.12209482491478153, 'fraction_numerical': 0.0, 'mean_word_length': 3.0299625468164795, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '5413762', 'n_tokens_mistral': 896, 'n_tokens_neox': 895, 'n_words': 234}