Comparing version 2.4.0 to 2.4.1
@@ -9,2 +9,3 @@ import Form, { FormEventName, FormErrors } from './Form'; | ||
readonly forceUpdate: "force update"; | ||
readonly submit: "submit"; | ||
}; | ||
@@ -11,0 +12,0 @@ export declare type FormGroupEventName = typeof eventNames[keyof typeof eventNames]; |
@@ -592,3 +592,3 @@ import equal from 'fast-deep-equal'; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var values, result, errors; | ||
var values, isValid, result, errors; | ||
return __generator(this, function (_a) { | ||
@@ -598,14 +598,12 @@ switch (_a.label) { | ||
values = this.getValues(); | ||
// TODO don't validate if all fields are changed and valid | ||
return [4 /*yield*/, this.validate()]; | ||
case 1: | ||
// TODO don't validate if all fields are changed and valid | ||
_a.sent(); | ||
if (!this.state.isValid) { | ||
isValid = _a.sent(); | ||
if (isValid) { | ||
result = Promise.resolve(values); | ||
} | ||
else { | ||
errors = this.getErrors(); | ||
result = Promise.reject(errors); | ||
} | ||
else { | ||
result = Promise.resolve(values); | ||
} | ||
this._events.dispatch(eventNames$1.submit, errors, values); | ||
@@ -633,2 +631,3 @@ return [2 /*return*/, result]; | ||
forceUpdate: 'force update', | ||
submit: 'submit', | ||
}; | ||
@@ -724,3 +723,3 @@ var FormGroup = /** @class */ (function () { | ||
}); | ||
this._events.dispatch('set values'); | ||
this._events.dispatch(eventNames$2.setValues); | ||
}; | ||
@@ -744,3 +743,3 @@ FormGroup.prototype.getValues = function () { | ||
}); | ||
this._events.dispatch('unset values'); | ||
this._events.dispatch(eventNames$2.unsetValues); | ||
}; | ||
@@ -763,13 +762,19 @@ // TODO looks like getValues() if we need rewrite it? Write getKeyValues(key) | ||
return __awaiter(this, void 0, void 0, function () { | ||
var isValid, errors; | ||
var values, isValid, result, errors; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.validate()]; | ||
case 0: | ||
values = this.getValues(); | ||
return [4 /*yield*/, this.validate()]; | ||
case 1: | ||
isValid = _a.sent(); | ||
if (!isValid) { | ||
if (isValid) { | ||
result = Promise.resolve(values); | ||
} | ||
else { | ||
errors = this.getErrors(); | ||
return [2 /*return*/, Promise.reject(errors)]; | ||
result = Promise.reject(errors); | ||
} | ||
return [2 /*return*/, this.getValues()]; | ||
this._events.dispatch(eventNames$2.submit, errors, values); | ||
return [2 /*return*/, result]; | ||
} | ||
@@ -776,0 +781,0 @@ }); |
@@ -9,2 +9,3 @@ import Form, { FormEventName, FormErrors } from './Form'; | ||
readonly forceUpdate: "force update"; | ||
readonly submit: "submit"; | ||
}; | ||
@@ -11,0 +12,0 @@ export declare type FormGroupEventName = typeof eventNames[keyof typeof eventNames]; |
@@ -598,3 +598,3 @@ 'use strict'; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var values, result, errors; | ||
var values, isValid, result, errors; | ||
return __generator(this, function (_a) { | ||
@@ -604,14 +604,12 @@ switch (_a.label) { | ||
values = this.getValues(); | ||
// TODO don't validate if all fields are changed and valid | ||
return [4 /*yield*/, this.validate()]; | ||
case 1: | ||
// TODO don't validate if all fields are changed and valid | ||
_a.sent(); | ||
if (!this.state.isValid) { | ||
isValid = _a.sent(); | ||
if (isValid) { | ||
result = Promise.resolve(values); | ||
} | ||
else { | ||
errors = this.getErrors(); | ||
result = Promise.reject(errors); | ||
} | ||
else { | ||
result = Promise.resolve(values); | ||
} | ||
this._events.dispatch(eventNames$1.submit, errors, values); | ||
@@ -639,2 +637,3 @@ return [2 /*return*/, result]; | ||
forceUpdate: 'force update', | ||
submit: 'submit', | ||
}; | ||
@@ -730,3 +729,3 @@ var FormGroup = /** @class */ (function () { | ||
}); | ||
this._events.dispatch('set values'); | ||
this._events.dispatch(eventNames$2.setValues); | ||
}; | ||
@@ -750,3 +749,3 @@ FormGroup.prototype.getValues = function () { | ||
}); | ||
this._events.dispatch('unset values'); | ||
this._events.dispatch(eventNames$2.unsetValues); | ||
}; | ||
@@ -769,13 +768,19 @@ // TODO looks like getValues() if we need rewrite it? Write getKeyValues(key) | ||
return __awaiter(this, void 0, void 0, function () { | ||
var isValid, errors; | ||
var values, isValid, result, errors; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.validate()]; | ||
case 0: | ||
values = this.getValues(); | ||
return [4 /*yield*/, this.validate()]; | ||
case 1: | ||
isValid = _a.sent(); | ||
if (!isValid) { | ||
if (isValid) { | ||
result = Promise.resolve(values); | ||
} | ||
else { | ||
errors = this.getErrors(); | ||
return [2 /*return*/, Promise.reject(errors)]; | ||
result = Promise.reject(errors); | ||
} | ||
return [2 /*return*/, this.getValues()]; | ||
this._events.dispatch(eventNames$2.submit, errors, values); | ||
return [2 /*return*/, result]; | ||
} | ||
@@ -782,0 +787,0 @@ }); |
{ | ||
"name": "formular", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Pavel Ivanov", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
113007
2217