[redux-form] add typings for v7.4 (#26977)

* redux-form: new API of v7.4

* [redux-from]: support redux@4
This commit is contained in:
Vincent Bel
2018-07-09 12:52:12 -07:00
committed by Ryan Cavanaugh
parent 696b8b14dd
commit 916f644758
9 changed files with 35 additions and 6 deletions
+4
View File
@@ -2,6 +2,9 @@ export {
Field,
FieldArray,
Fields,
Form,
FormName,
FormSection,
reduxForm,
reducer,
formValueSelector,
@@ -19,6 +22,7 @@ export {
isInvalid,
isPristine,
isSubmitting,
isAsyncValidating,
isValid,
SubmissionError
} from "../";
+2 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for redux-form 7.3
// Type definitions for redux-form 7.4
// Project: https://github.com/erikras/redux-form
// Definitions by: Carson Full <https://github.com/carsonf>
// Daniel Lytkin <https://github.com/aikoven>
@@ -47,6 +47,7 @@ export * from "./lib/Field";
export * from "./lib/Fields";
export * from "./lib/FieldArray";
export * from "./lib/Form";
export * from "./lib/FormName";
export * from "./lib/FormSection";
export * from "./lib/formValues";
export * from "./lib/formValueSelector";
+1
View File
@@ -46,6 +46,7 @@ export interface BaseFieldProps<P = {}> extends Partial<CommonFieldProps> {
validate?: Validator | Validator[];
warn?: Validator | Validator[];
withRef?: boolean;
immutableProps?: string[];
}
export interface GenericField<P> extends Component<BaseFieldProps<P> & P> {
-1
View File
@@ -1,5 +1,4 @@
import { Component, FormHTMLAttributes, FormEvent, FormEventHandler } from "react";
import { Dispatch } from "redux";
import { FormProps, FormErrors, FormSubmitHandler, Omit } from "../index";
interface FormSubmitProp<FormData = {}, P = {}> {
+9
View File
@@ -0,0 +1,9 @@
import { ReactNode, StatelessComponent } from "react";
export interface FormNameProps {
children: (props: { form: string }) => ReactNode,
}
export const FormName: StatelessComponent<FormNameProps>;
export default FormName;
+3 -1
View File
@@ -1,4 +1,4 @@
import { Action, Reducer } from "redux";
import { Reducer } from "redux";
import { FieldType } from "../index";
export interface FormReducer extends Reducer<FormStateMap> {
@@ -8,6 +8,8 @@ export interface FormReducer extends Reducer<FormStateMap> {
export const reducer: FormReducer;
export interface FormReducerMapObject {
// and `<any>` to make it compatible with redux@3
// tslint:disable-next-line use-default-type-parameter
[formName: string]: Reducer<any>;
}
+4 -2
View File
@@ -4,6 +4,7 @@ export type DataSelector<FormData = {}, State = {}> = (formName: string, getForm
export type ErrorSelector<FormData = {}, State = {}> = (formName: string, getFormState?: GetFormState) => (state: State) => FormErrors<FormData>;
export type BooleanSelector<State = {}> = (formName: string, getFormState?: GetFormState) => (state: State) => boolean;
export type NamesSelector<State = {}> = (getFormState?: GetFormState) => (state: State) => string[];
export type FormOrFieldsBooleanSelector<State = {}> = (formName: string, getFormState?: GetFormState) => (state: State, ...fields: string[]) => boolean;
export const getFormValues: DataSelector;
export const getFormInitialValues: DataSelector;
@@ -14,10 +15,11 @@ export const getFormSyncWarnings: ErrorSelector;
export const getFormSubmitErrors: ErrorSelector;
export const getFormError: ErrorSelector;
export const getFormNames: NamesSelector;
export const isDirty: BooleanSelector;
export const isPristine: BooleanSelector;
export const isDirty: FormOrFieldsBooleanSelector;
export const isPristine: FormOrFieldsBooleanSelector;
export const isValid: BooleanSelector;
export const isInvalid: BooleanSelector;
export const isSubmitting: BooleanSelector;
export const isAsyncValidating: BooleanSelector;
export const hasSubmitSucceeded: BooleanSelector;
export const hasSubmitFailed: BooleanSelector;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"private": true,
"dependencies": {
"redux": "^3.6.0"
"redux": "^3.6.0 || ^4.0.0"
}
}
+11
View File
@@ -4,6 +4,7 @@ import {
reduxForm,
InjectedFormProps,
Form,
FormName,
GenericForm,
FormSection,
GenericFormSection,
@@ -399,3 +400,13 @@ class HandleSubmitTest extends React.Component {
return <HandleSubmitTestForm onSubmit={this.handleSubmit} />;
}
}
class FormNameTest extends React.Component {
render() {
return (
<FormName>
{({ form }) => <span>Form Name is: {form}</span>}
</FormName>
);
}
}