Comparing version 2.1.7 to 2.1.8
@@ -5,7 +5,8 @@ import Field, { FieldOpts, Validator } from './Field'; | ||
}; | ||
declare type FormFieldOpts<T> = { | ||
[K in keyof T]: FieldOpts<T[K]> | Validator[]; | ||
}; | ||
export declare type FormOpts<T extends Object> = { | ||
name?: string; | ||
fields: { | ||
[K in keyof T]: FieldOpts<T[K]> | Validator[]; | ||
}; | ||
fields: FormFieldOpts<T>; | ||
initialValues?: Partial<{ | ||
@@ -32,3 +33,4 @@ [K in keyof T]: T[K]; | ||
constructor(opts: FormOpts<FieldValues>); | ||
private _setupFields; | ||
attachFields(fieldOpts: FormFieldOpts<FieldValues> | Partial<FormFieldOpts<FieldValues>>): void; | ||
detachFields(fieldNames: Array<keyof FieldValues>): void; | ||
setState(values: Partial<State>): void; | ||
@@ -35,0 +37,0 @@ setValues(values: Obj): void; |
@@ -67,7 +67,7 @@ var __assign = (this && this.__assign) || function () { | ||
this._events = new Events(); | ||
this._setupFields(); | ||
this.attachFields(this.opts.fields); | ||
} | ||
Form.prototype._setupFields = function () { | ||
Form.prototype.attachFields = function (fieldOpts) { | ||
var _this = this; | ||
var fieldNames = Object.keys(this.opts.fields); | ||
var fieldNames = Object.keys(fieldOpts); | ||
fieldNames.forEach(function (fieldName) { | ||
@@ -91,2 +91,8 @@ var initialValue = _this.opts.initialValues && _this.opts.initialValues[fieldName]; | ||
}; | ||
Form.prototype.detachFields = function (fieldNames) { | ||
var _this = this; | ||
fieldNames.forEach(function (fieldName) { | ||
delete _this.fields[fieldName]; | ||
}); | ||
}; | ||
Form.prototype.setState = function (values) { | ||
@@ -93,0 +99,0 @@ this.state = __assign(__assign({}, this.state), values); |
{ | ||
"name": "formular", | ||
"version": "2.1.7", | ||
"version": "2.1.8", | ||
"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
79657
1241