diff --git a/redux-form/index.d.ts b/redux-form/index.d.ts index 77a3004710..4c73f3e489 100644 --- a/redux-form/index.d.ts +++ b/redux-form/index.d.ts @@ -1,476 +1,38 @@ -// Type definitions for redux-form v4.0.3 +// Type definitions for redux-form v6.3.1 // Project: https://github.com/erikras/redux-form -// Definitions by: Daniel Lytkin +// Definitions by: Carson Full , Daniel Lytkin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as React from 'react'; -import { Component, SyntheticEvent, FormEventHandler } from 'react'; -import { Dispatch, ActionCreator, Reducer } from 'redux'; +/// -export const actionTypes: {[actionName:string]: string}; +import { + ComponentClass, + StatelessComponent, +} from 'react'; export type FieldValue = any; -export type FormData = { [fieldName: string]: FieldValue }; +export type FieldType = 'Field' | 'FieldArray'; -export interface FieldProp { - /** - * true if this field currently has focus. It will only work if you are - * passing onFocus to your input element. - */ - active: boolean; +export type DataShape = {[fieldName:string]: FieldValue}; - /** - * An alias for value only when value is a boolean. Provided for - * convenience of destructuring the whole field object into the props of a - * form element. - */ - checked?: boolean; +export type FormErrors = FormData & { _error?: string }; - /** - * true if the field value has changed from its initialized value. - * Opposite of pristine. - */ - dirty: boolean; - - /** - * The error for this field if its value is not passing validation. Both - * synchronous and asynchronous validation errors will be reported here. - */ - error?: any; - - /** - * The value for this field as supplied in initialValues to the form. - */ - initialValue: FieldValue; - - /** - * true if the field value fails validation (has a validation error). - * Opposite of valid. - */ - invalid: boolean; - - /** - * The name of the field. It will be the same as the key in the fields - * Object, but useful if bundling up a field to send down to a specialized - * input component. - */ - name: string; - - /** - * A function to call when the form field loses focus. It expects to - * either receive the React SyntheticEvent or the current value of the - * field. - */ - onBlur(eventOrValue: SyntheticEvent | FieldValue): void; - - /** - * A function to call when the form field is changed. It expects to either - * receive the React SyntheticEvent or the new value of the field. - * @param eventOrValue - */ - onChange(eventOrValue: SyntheticEvent | FieldValue): void; - - /** - * A function to call when the form field receives a 'dragStart' event. - * Saves the field value in the event for giving the field it is dropped - * into. - */ - onDragStart(): void; - - /** - * A function to call when the form field receives a drop event. - */ - onDrop(): void; - - /** - * A function to call when the form field receives focus. - */ - onFocus(): void; - - /** - * An alias for onChange. Provided for convenience of destructuring the - * whole field object into the props of a form element. Added to provide - * out-of-the-box support for Belle components' onUpdate API. - */ - onUpdate(): void; - - /** - * true if the field value is the same as its initialized value. Opposite - * of dirty. - */ - pristine: boolean; - - /** - * true if the field has been touched. By default this will be set when - * the field is blurred. - */ - touched: boolean; - - /** - * true if the field value passes validation (has no validation errors). - * Opposite of invalid. - */ - valid: boolean; - - /** - * The value of this form field. It will be a boolean for checkboxes, and - * a string for all other input types. - */ - value: FieldValue; - - /** - * true if this field has ever had focus. It will only work if you are - * passing onFocus to your input element. - */ - visited: boolean; -} - -export interface ReduxFormProps { - /** - * The name of the currently active (with focus) field. - */ - active?: string; - - /** - * A function that may be called to initiate asynchronous validation if - * asynchronous validation is enabled. - */ - asyncValidate?: Function; - - /** - * true if the asynchronous validation function has been called but has not - * yet returned. - */ - asyncValidating?: boolean; - - /** - * Destroys the form state in the Redux store. By default, this will be - * called for you in componentWillUnmount(). - */ - destroyForm?(): void; - - /** - * true if the form data has changed from its initialized values. Opposite - * of pristine. - */ - dirty?: boolean; - - /** - * A generic error for the entire form given by the _error key in the - * result from the synchronous validation function, the asynchronous - * validation, or the rejected promise from onSubmit. - */ - error?: any; - - /** - * The form data, in the form { field1: , field2: }. The - * field objects are meant to be destructured into your input component as - * props, e.g. . Each field Object has - * the following properties: - */ - fields?: { [field: string]: FieldProp }; - - /** - * A function meant to be passed to
or to - *