Comparing version 2.2.8 to 2.2.9
@@ -6,2 +6,4 @@ import Form, { FormEventName } from './Form'; | ||
readonly unsetValues: "unset values"; | ||
readonly attachForms: "attach forms"; | ||
readonly detachForms: "detach forms"; | ||
}; | ||
@@ -18,6 +20,8 @@ export declare type FormGroupEventName = typeof eventNames[keyof typeof eventNames]; | ||
constructor(forms?: Forms); | ||
private _handleFormEvent; | ||
private _subscribe; | ||
private _unsubscribe; | ||
attachForms(forms: Forms): void; | ||
detachForms(formNames: Array<keyof Forms>): void; | ||
replace(newForms: Forms): void; | ||
_handleFormEvent: (eventName: "state change" | "attach fields" | "detach fields" | "update" | "change" | "focus" | "blur" | "submit") => (this: unknown) => void; | ||
_subscribe(): void; | ||
_unsubscribe(): void; | ||
validate(): Promise<boolean>; | ||
@@ -24,0 +28,0 @@ setValues(values: FormsValues<Forms>): void; |
@@ -626,2 +626,4 @@ import equal from 'fast-deep-equal'; | ||
unsetValues: 'unset values', | ||
attachForms: 'attach forms', | ||
detachForms: 'detach forms', | ||
}; | ||
@@ -631,3 +633,2 @@ var FormGroup = /** @class */ (function () { | ||
var _this = this; | ||
// Private methods ------------------------------------ / | ||
this._handleFormEvent = function (eventName) { return debounce(function () { | ||
@@ -641,8 +642,2 @@ _this._events.dispatch(eventName); | ||
} | ||
FormGroup.prototype.replace = function (newForms) { | ||
this._unsubscribe(); | ||
this.forms = newForms; | ||
this._subscribe(); | ||
this._events.dispatch(eventNames$2.replace); | ||
}; | ||
FormGroup.prototype._subscribe = function () { | ||
@@ -668,3 +663,28 @@ var _this = this; | ||
}; | ||
// Public methods ------------------------------------- / | ||
FormGroup.prototype.attachForms = function (forms) { | ||
var _this = this; | ||
var formNames = Object.keys(forms); | ||
formNames.forEach(function (formName) { | ||
if (formName in _this.forms) { | ||
console.error("Form with name \"" + formName + "\" already exists in FormGroup"); | ||
} | ||
else { | ||
_this.forms[formName] = forms[formName]; | ||
} | ||
}); | ||
this._events.dispatch(eventNames$2.attachForms); | ||
}; | ||
FormGroup.prototype.detachForms = function (formNames) { | ||
var _this = this; | ||
formNames.forEach(function (fieldName) { | ||
delete _this.forms[fieldName]; | ||
}); | ||
this._events.dispatch(eventNames$2.detachForms); | ||
}; | ||
FormGroup.prototype.replace = function (newForms) { | ||
this._unsubscribe(); | ||
this.forms = newForms; | ||
this._subscribe(); | ||
this._events.dispatch(eventNames$2.replace); | ||
}; | ||
FormGroup.prototype.validate = function () { | ||
@@ -671,0 +691,0 @@ return __awaiter(this, void 0, void 0, function () { |
@@ -6,2 +6,4 @@ import Form, { FormEventName } from './Form'; | ||
readonly unsetValues: "unset values"; | ||
readonly attachForms: "attach forms"; | ||
readonly detachForms: "detach forms"; | ||
}; | ||
@@ -18,6 +20,8 @@ export declare type FormGroupEventName = typeof eventNames[keyof typeof eventNames]; | ||
constructor(forms?: Forms); | ||
private _handleFormEvent; | ||
private _subscribe; | ||
private _unsubscribe; | ||
attachForms(forms: Forms): void; | ||
detachForms(formNames: Array<keyof Forms>): void; | ||
replace(newForms: Forms): void; | ||
_handleFormEvent: (eventName: "state change" | "attach fields" | "detach fields" | "update" | "change" | "focus" | "blur" | "submit") => (this: unknown) => void; | ||
_subscribe(): void; | ||
_unsubscribe(): void; | ||
validate(): Promise<boolean>; | ||
@@ -24,0 +28,0 @@ setValues(values: FormsValues<Forms>): void; |
@@ -632,2 +632,4 @@ 'use strict'; | ||
unsetValues: 'unset values', | ||
attachForms: 'attach forms', | ||
detachForms: 'detach forms', | ||
}; | ||
@@ -637,3 +639,2 @@ var FormGroup = /** @class */ (function () { | ||
var _this = this; | ||
// Private methods ------------------------------------ / | ||
this._handleFormEvent = function (eventName) { return debounce(function () { | ||
@@ -647,8 +648,2 @@ _this._events.dispatch(eventName); | ||
} | ||
FormGroup.prototype.replace = function (newForms) { | ||
this._unsubscribe(); | ||
this.forms = newForms; | ||
this._subscribe(); | ||
this._events.dispatch(eventNames$2.replace); | ||
}; | ||
FormGroup.prototype._subscribe = function () { | ||
@@ -674,3 +669,28 @@ var _this = this; | ||
}; | ||
// Public methods ------------------------------------- / | ||
FormGroup.prototype.attachForms = function (forms) { | ||
var _this = this; | ||
var formNames = Object.keys(forms); | ||
formNames.forEach(function (formName) { | ||
if (formName in _this.forms) { | ||
console.error("Form with name \"" + formName + "\" already exists in FormGroup"); | ||
} | ||
else { | ||
_this.forms[formName] = forms[formName]; | ||
} | ||
}); | ||
this._events.dispatch(eventNames$2.attachForms); | ||
}; | ||
FormGroup.prototype.detachForms = function (formNames) { | ||
var _this = this; | ||
formNames.forEach(function (fieldName) { | ||
delete _this.forms[fieldName]; | ||
}); | ||
this._events.dispatch(eventNames$2.detachForms); | ||
}; | ||
FormGroup.prototype.replace = function (newForms) { | ||
this._unsubscribe(); | ||
this.forms = newForms; | ||
this._subscribe(); | ||
this._events.dispatch(eventNames$2.replace); | ||
}; | ||
FormGroup.prototype.validate = function () { | ||
@@ -677,0 +697,0 @@ return __awaiter(this, void 0, void 0, function () { |
{ | ||
"name": "formular", | ||
"version": "2.2.8", | ||
"version": "2.2.9", | ||
"author": "Pavel Ivanov", | ||
@@ -5,0 +5,0 @@ "description": "Build forms in React. Easy-Peasy!", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
112115
2215