From 4cce589580576b275938c3888fb1ac6eac04501f Mon Sep 17 00:00:00 2001 From: Zhang Yijiang Date: Fri, 1 Jun 2018 11:06:16 +0800 Subject: [PATCH 1/2] Revert "Add missing properties in InitializeOptions" This reverts commit 6345e48b3521d5858a9417becd09324e47d61318. --- types/redux-form/v6/lib/actionTypes.d.ts | 1 - types/redux-form/v6/lib/actions.d.ts | 21 ++++----------------- types/redux-form/v6/lib/reduxForm.d.ts | 5 ----- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/types/redux-form/v6/lib/actionTypes.d.ts b/types/redux-form/v6/lib/actionTypes.d.ts index 02b47849d3..ce1ba5d208 100644 --- a/types/redux-form/v6/lib/actionTypes.d.ts +++ b/types/redux-form/v6/lib/actionTypes.d.ts @@ -20,7 +20,6 @@ export interface ActionTypes { INITIALIZE: string; REGISTER_FIELD: string; RESET: string; - RESET_SECTION: string; SET_SUBMIT_FAILED: string; SET_SUBMIT_SUCCEEDED: string; START_ASYNC_VALIDATION: string; diff --git a/types/redux-form/v6/lib/actions.d.ts b/types/redux-form/v6/lib/actions.d.ts index 67638a2784..7e7ea5762a 100644 --- a/types/redux-form/v6/lib/actions.d.ts +++ b/types/redux-form/v6/lib/actions.d.ts @@ -84,22 +84,14 @@ export function destroy(...form: string[]): FormAction; export function focus(form: string, field: string): FormAction; /** - * Sets the initial values in the form with which future data values will be compared to calculate dirty and pristine. - * - * If the keepDirty parameter is true, the values of currently dirty fields will be retained to avoid overwriting user edits. - * - * If the keepSubmitSucceeded parameter is true, it will not clear the submitSucceeded flag if it is set. - * - * If the updateUnregisteredFields parameter is true, it will update every initialValue if still pristine instead of only - * registered fields. Highly recommended, defaults to false because of non-breaking backwards compatibility. - * - * If the keepValues parameter is true, it will keep the old values and initial values. + * Sets the initial values in the form with which future data values will be compared to calculate dirty and pristine. + * The data parameter may contain deep nested array and object values that match the shape of your form fields. + * If the keepDirty parameter is true, the values of the currently dirty fields will be retained to avoid overwriting + * user edits. */ interface InitializeOptions { keepDirty: boolean; keepSubmitSucceeded: boolean; - updateUnregisteredFields: boolean; - keepValues: boolean; } export function initialize(form: string, data: any, keepDirty?: boolean | InitializeOptions, options?: InitializeOptions): FormAction; @@ -114,11 +106,6 @@ export function registerField(form: string, name: string, type: FieldType): Form */ export function reset(form: string): FormAction; -/** - * Resets the values in the form sections back to the values past in with the most recent initialize action. - */ -export function resetSection(form: string, ...sections: string[]): FormAction; - /** * Flips the asyncValidating flag true */ diff --git a/types/redux-form/v6/lib/reduxForm.d.ts b/types/redux-form/v6/lib/reduxForm.d.ts index 2900137019..53ad871c0c 100644 --- a/types/redux-form/v6/lib/reduxForm.d.ts +++ b/types/redux-form/v6/lib/reduxForm.d.ts @@ -518,11 +518,6 @@ export interface StrictFormProps { */ reset(): void; - /** - * Resets the form sections to the initialValues. It will be pristine after reset. - */ - resetSection(...sections: string[]) : void; - /** * Whether or not your form is currently submitting. This prop will only * work if you have passed an onSubmit function that returns a promise. It From eac6ce3cabc0be6d539f9d3d8b9e7c85a44bbf3c Mon Sep 17 00:00:00 2001 From: Zhang Yijiang Date: Fri, 1 Jun 2018 11:10:17 +0800 Subject: [PATCH 2/2] Add resetSection action, initialize props --- types/redux-form/lib/actionTypes.d.ts | 1 + types/redux-form/lib/actions.d.ts | 3 +++ types/redux-form/lib/reduxForm.d.ts | 1 + 3 files changed, 5 insertions(+) diff --git a/types/redux-form/lib/actionTypes.d.ts b/types/redux-form/lib/actionTypes.d.ts index ac0256456c..7718ba74ab 100644 --- a/types/redux-form/lib/actionTypes.d.ts +++ b/types/redux-form/lib/actionTypes.d.ts @@ -21,6 +21,7 @@ export interface ActionTypes { INITIALIZE: string; REGISTER_FIELD: string; RESET: string; + RESET_SECTION: string; SET_SUBMIT_FAILED: string; SET_SUBMIT_SUCCEEDED: string; START_ASYNC_VALIDATION: string; diff --git a/types/redux-form/lib/actions.d.ts b/types/redux-form/lib/actions.d.ts index 80fbc3a234..adc6e9842b 100644 --- a/types/redux-form/lib/actions.d.ts +++ b/types/redux-form/lib/actions.d.ts @@ -26,11 +26,14 @@ export declare function focus(form: string, field: string): FormAction; export interface InitializeOptions { keepDirty: boolean; keepSubmitSucceeded: boolean; + updateUnregisteredFields: boolean; + keepValues: boolean; } export declare function initialize(form: string, data: any, keepDirty?: boolean | InitializeOptions, options?: InitializeOptions): FormAction; export declare function registerField(form: string, name: string, type: FieldType): FormAction; export declare function reset(form: string): FormAction; +export declare function resetSection(form: string, ...sections: string[]): FormAction; export declare function startAsyncValidation(form: string): FormAction; export declare function stopAsyncValidation(form: string, errors?: any): FormAction; export declare function setSubmitFailed(form: string, ...fields: string[]): FormAction; diff --git a/types/redux-form/lib/reduxForm.d.ts b/types/redux-form/lib/reduxForm.d.ts index 29b6ca24ae..128845f08f 100644 --- a/types/redux-form/lib/reduxForm.d.ts +++ b/types/redux-form/lib/reduxForm.d.ts @@ -133,6 +133,7 @@ export interface FormInstance extends Component

{ pristine: boolean; registeredFields: RegisteredFieldState[]; reset(): void; + resetSection(...sections: string[]): void; submit(): Promise; valid: boolean; values: Partial;