<commit_before>// Type definitions for react-redux-form
// Project: https://github.com/davidkpiano/react-redux-form
// Definitions by: <NAME> (Flavorus) <https://github.com/hsrobflavorus>, Flavorus <http://www.flavorus.com>, <NAME> (@asvetliakov), <NAME> <https://github.com/zach-waggoner>

import * as React from 'react';
import * as Redux from 'redux';

interface Action {
    type: any;
}
type Reducer<S> = <A extends Action>(state: S, action: A) => S;

interface AsyncValidatorFn {
    (val: any, done: Function): void;
}
interface AsyncValidators {
    [key: string]: AsyncValidatorFn;
}

interface ValidatorFn {
    (val: any): boolean;
}
interface Validators {
    [key: string]: ValidatorFn;
}
interface ValidityObject {
    [key: string]: boolean;
}

interface ErrorFn {
    (val: any): boolean | string;
}

interface ErrorValidators {
    [key: string]: ErrorFn;
}

interface ErrorsObject {
    [key: string]: boolean | string;
}
interface ErrorsMessageSelector {
    (val: any): string;
}
interface ErrorsComponentMessages {
    [key: string]: string | ErrorsMessageSelector;
}

interface FormValidators {
    [key: string]: Validators;
}
interface FormValidatorsFn {
    (val: any): FormValidationErrors
}
interface ValidationErrors {
    [key: string]: any;
}
interface FormValidationErrors {
    [key: string]: ValidationErrors
}
/**
 * Internal interface
 */
interface FieldsObject<T> {
    [key: string]: T;
}

/**
 * Used for the <Errors> `show` prop
 */
interface FieldStatePredicate {
    (field: FieldState): boolean;
}

/**
 * A function that, when called with state, will return the first full model string (with the sub-model) that matches the predicate iteratee.
 */
interface ModelGetterFn {
    (state: any): string;
}

/**
 * Additional props when specifying a SFC Wrapper (ex. in <Errors>)
 */
interface WrapperProps {
    modelValue: any;
    fieldValue: FieldState;
}

/**
 * Additional props when specifying a SFC Custom Component (ex. in <Errors>)
 */
interface CustomComponentProps extends WrapperProps {
    children: any;
}

interface MapPropsProps {
    onChange: (event: any) => void;
    onBlur: (event: any) => void;
    onFocus: (event: any) => void;
    fieldValue: FieldState;
    modelValue: any;
    viewValue: any;
}

type MapPropsFunc = (props: MapPropsProps) => any;
type MapPropsObject = { [key: string]: (props: MapPropsProps) => any };

type MapProps = MapPropsFunc | MapPropsObject;

type UpdateOn = 'change' | 'blur' | 'focus';
type ValidateOn = 'change' | 'blur' | 'focus';

export interface ControlProps<T> extends React.HTMLProps<T> {
    /**
     * Wrap field into custom component
     */
    component?: React.ReactType;

    /**
     * The string representing the store model value
     * OR
     * A function that, when called with state, will return the first full model string (with the sub-model) that matches the predicate iteratee.
     */
    model: string | ModelGetterFn;
    /**
     * A string/array of strings specifying when the component should dispatch a change(...) action, with one of these values:
     *
     * change - will dispatch in onChange
     * blur - will dispatch in onBlur
     * focus - will dispatch in onFocus
     *<commit_msg>Add Control component render property type definition<commit_after>// Type definitions for react-redux-form
// Project: https://github.com/davidkpiano/react-redux-form
// Definitions by: <NAME> (Flavorus) <https://github.com/hsrobflavorus>, Flavorus <http://www.flavorus.com>, <NAME> (@asvetliakov), <NAME> <https://github.com/zach-waggoner>

import * as React from 'react';
import * as Redux from 'redux';

interface Action {
    type: any;
}
type Reducer<S> = <A extends Action>(state: S, action: A) => S;

interface AsyncValidatorFn {
    (val: any, done: Function): void;
}
interface AsyncValidators {
    [key: string]: AsyncValidatorFn;
}

interface ValidatorFn {
    (val: any): boolean;
}
interface Validators {
    [key: string]: ValidatorFn;
}
interface ValidityObject {
    [key: string]: boolean;
}

interface ErrorFn {
    (val: any): boolean | string;
}

interface ErrorValidators {
    [key: string]: ErrorFn;
}

interface ErrorsObject {
    [key: string]: boolean | string;
}
interface ErrorsMessageSelector {
    (val: any): string;
}
interface ErrorsComponentMessages {
    [key: string]: string | ErrorsMessageSelector;
}

interface FormValidators {
    [key: string]: Validators;
}
interface FormValidatorsFn {
    (val: any): FormValidationErrors
}
interface ValidationErrors {
    [key: string]: any;
}
interface FormValidationErrors {
    [key: string]: ValidationErrors
}
/**
 * Internal interface
 */
interface FieldsObject<T> {
    [key: string]: T;
}

/**
 * Used for the <Errors> `show` prop
 */
interface FieldStatePredicate {
    (field: FieldState): boolean;
}

/**
 * A function that, when called with state, will return the first full model string (with the sub-model) that matches the predicate iteratee.
 */
interface ModelGetterFn {
    (state: any): string;
}

/**
 * Additional props when specifying a SFC Wrapper (ex. in <Errors>)
 */
interface WrapperProps {
    modelValue: any;
    fieldValue: FieldState;
}

/**
 * Additional props when specifying a SFC Custom Component (ex. in <Errors>)
 */
interface CustomComponentProps extends WrapperProps {
    children: any;
}

interface MapPropsProps {
    onChange: (event: any) => void;
    onBlur: (event: any) => void;
    onFocus: (event: any) => void;
    onKeyPress: (event: any) => void;
    fieldValue: FieldState;
    modelValue: any;
    viewValue: any;
}

type MapPropsFunc = (props: MapPropsProps) => any;
type MapPropsObject = { [key: string]: (props: MapPropsProps) => any };

type MapProps = MapPropsFunc | MapPropsObject;

type UpdateOn = 'change' | 'blur' | 'focus';
type ValidateOn = 'change' | 'blur' | 'focus';

export interface ControlProps<T> extends React.HTMLProps<T> {
    /**
     * Wrap field into custom component
     */
    component?: React.ReactType;

    /**
     * Function that receives a field props and returns a custom component
     */
    render?: (props: MapPropsProps) => React.ReactNode;

    /**
     * The string representing the store model value
     * OR
     * A function that, when called with state, will return the first full model string (with the sub-model) that matches the predicate iteratee.
     */
    model: string | ModelGetterFn;
    /**
     * A string/array of strings specifying when the component should dispatch a change(...) action, with one of these values:
     *
     * change - will dispatch in onChange
     * blur - will dispatch in onBlur
     * focus - will dispatch in onFocus
     *
{'fraction_non_alphanumeric': 0.12061206120612061, 'fraction_numerical': 0.0, 'mean_word_length': 3.613840830449827, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 45, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, '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': '2319683', 'n_tokens_mistral': 2009, 'n_tokens_neox': 1988, 'n_words': 661}