Merge pull request #26190 from ZhangYiJiang/fix-redux-form-initialize

[redux-form] Revert #26026 and reapply to correct version
This commit is contained in:
Benjamin Lichtman
2018-05-31 20:42:56 -07:00
committed by GitHub
6 changed files with 9 additions and 23 deletions
+1
View File
@@ -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;
+3
View File
@@ -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;
+1
View File
@@ -133,6 +133,7 @@ export interface FormInstance<FormData, P> extends Component<P> {
pristine: boolean;
registeredFields: RegisteredFieldState[];
reset(): void;
resetSection(...sections: string[]): void;
submit(): Promise<any>;
valid: boolean;
values: Partial<FormData>;
-1
View File
@@ -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;
+4 -17
View File
@@ -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
*/
-5
View File
@@ -518,11 +518,6 @@ export interface StrictFormProps<FormData extends DataShape, P, S> {
*/
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