@uform/core
Advanced tools
Comparing version 1.0.0-alpha.8 to 1.0.0-alpha.9
@@ -193,3 +193,3 @@ "use strict"; | ||
if (isEmptyValue_1 || isEmptyInitialValue_1) { | ||
field.setState(function (state) { | ||
field.setSourceState(function (state) { | ||
if (isEmptyValue_1) | ||
@@ -199,3 +199,3 @@ state.value = getFormValuesIn(state.name); | ||
state.initialValue = getFormInitialValuesIn(state.name); | ||
}, true); | ||
}); | ||
} | ||
@@ -367,3 +367,2 @@ } | ||
var formInitialValue = getFormInitialValuesIn(dataPath); | ||
state.initialized = true; | ||
if (shared_1.isValid(value)) { | ||
@@ -384,7 +383,18 @@ state.value = value; | ||
} | ||
state.props = props; | ||
state.required = required; | ||
state.rules = rules; | ||
state.selfEditable = editable; | ||
state.formEditable = options.editable; | ||
if (shared_1.isValid(props)) { | ||
state.props = props; | ||
} | ||
if (shared_1.isValid(required)) { | ||
state.required = required; | ||
} | ||
if (shared_1.isValid(rules)) { | ||
state.rules = rules; | ||
} | ||
if (shared_1.isValid(editable)) { | ||
state.selfEditable = editable; | ||
} | ||
if (shared_1.isValid(options.editable)) { | ||
state.formEditable = options.editable; | ||
} | ||
state.initialized = true; | ||
}); | ||
@@ -559,3 +569,2 @@ batchRunTaskQueue(field, nodePath); | ||
heart.publish(types_1.LifeCycleTypes.ON_FORM_INPUT_CHANGE, state); | ||
heart.publish(types_1.LifeCycleTypes.ON_FIELD_CHANGE, field); | ||
} | ||
@@ -748,3 +757,3 @@ function getValue() { | ||
env.submittingTask = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var validateResult, errors, validated, payload; | ||
var validateResult, errors, validated, payload, values; | ||
return __generator(this, function (_a) { | ||
@@ -775,4 +784,5 @@ switch (_a.label) { | ||
heart.publish(types_1.LifeCycleTypes.ON_FORM_SUBMIT, state); | ||
values = state.getState(function (state) { return shared_1.clone(state.values); }); | ||
if (!shared_1.isFn(onSubmit)) return [3, 3]; | ||
return [4, Promise.resolve(onSubmit(state.getState(function (state) { return shared_1.clone(state.values); })))]; | ||
return [4, Promise.resolve(onSubmit(values))]; | ||
case 2: | ||
@@ -787,2 +797,3 @@ payload = _a.sent(); | ||
return [2, { | ||
values: values, | ||
validated: validated, | ||
@@ -789,0 +800,0 @@ payload: payload |
@@ -195,2 +195,3 @@ import { FormPath, FormPathPattern, Subscribable } from '@uform/shared'; | ||
export interface IFormSubmitResult { | ||
values: any; | ||
validated: IFormValidateResult; | ||
@@ -197,0 +198,0 @@ payload: any; |
{ | ||
"name": "@uform/core", | ||
"version": "1.0.0-alpha.8", | ||
"version": "1.0.0-alpha.9", | ||
"license": "MIT", | ||
@@ -29,5 +29,5 @@ "main": "lib", | ||
"dependencies": { | ||
"@uform/shared": "^1.0.0-alpha.8", | ||
"@uform/shared": "^1.0.0-alpha.9", | ||
"@uform/types": "^0.4.0", | ||
"@uform/validator": "^1.0.0-alpha.8", | ||
"@uform/validator": "^1.0.0-alpha.9", | ||
"immer": "^3.2.0" | ||
@@ -38,3 +38,3 @@ }, | ||
}, | ||
"gitHead": "45850c788d7bc816ec4d0132c6b660463afc9a98" | ||
"gitHead": "e78e1d01810988d6198ee76a174353e47fb52041" | ||
} |
@@ -190,7 +190,7 @@ import { | ||
if (isEmptyValue || isEmptyInitialValue) { | ||
field.setState((state: IFieldState<FieldProps>) => { | ||
field.setSourceState((state: IFieldState<FieldProps>) => { | ||
if (isEmptyValue) state.value = getFormValuesIn(state.name) | ||
if (isEmptyInitialValue) | ||
state.initialValue = getFormInitialValuesIn(state.name) | ||
}, true) | ||
}) | ||
} | ||
@@ -390,3 +390,2 @@ } | ||
const formInitialValue = getFormInitialValuesIn(dataPath) | ||
state.initialized = true | ||
if (isValid(value)) { | ||
@@ -408,7 +407,18 @@ // value > formValue > initialValue | ||
} | ||
state.props = props | ||
state.required = required | ||
state.rules = rules as any | ||
state.selfEditable = editable | ||
state.formEditable = options.editable | ||
if (isValid(props)) { | ||
state.props = props | ||
} | ||
if (isValid(required)) { | ||
state.required = required | ||
} | ||
if (isValid(rules)) { | ||
state.rules = rules | ||
} | ||
if (isValid(editable)) { | ||
state.selfEditable = editable | ||
} | ||
if (isValid(options.editable)) { | ||
state.formEditable = options.editable | ||
} | ||
state.initialized = true | ||
}) | ||
@@ -610,3 +620,2 @@ batchRunTaskQueue(field, nodePath) | ||
heart.publish(LifeCycleTypes.ON_FORM_INPUT_CHANGE, state) | ||
heart.publish(LifeCycleTypes.ON_FIELD_CHANGE, field) | ||
} | ||
@@ -821,7 +830,6 @@ | ||
let payload | ||
let payload, | ||
values = state.getState(state => clone(state.values)) | ||
if (isFn(onSubmit)) { | ||
payload = await Promise.resolve( | ||
onSubmit(state.getState(state => clone(state.values))) | ||
) | ||
payload = await Promise.resolve(onSubmit(values)) | ||
} | ||
@@ -834,2 +842,3 @@ | ||
return { | ||
values, | ||
validated, | ||
@@ -836,0 +845,0 @@ payload |
@@ -268,2 +268,3 @@ import { FormPath, FormPathPattern, isFn, Subscribable } from '@uform/shared' | ||
export interface IFormSubmitResult { | ||
values: any | ||
validated: IFormValidateResult | ||
@@ -270,0 +271,0 @@ payload: any |
224691
4764