+24
-21
@@ -1,3 +0,3 @@ | ||
| var l = Object.defineProperty; | ||
| var d = (s, t, e) => t in s ? l(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; | ||
| var f = Object.defineProperty; | ||
| var d = (s, t, e) => t in s ? f(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; | ||
| var i = (s, t, e) => (d(s, typeof t != "symbol" ? t + "" : t, e), e); | ||
@@ -21,7 +21,7 @@ class c { | ||
| } | ||
| function f() { | ||
| function u() { | ||
| return new c(); | ||
| } | ||
| const v = () => ""; | ||
| class n { | ||
| class h { | ||
| constructor({ | ||
@@ -33,7 +33,7 @@ value: t = "", | ||
| name: o = "", | ||
| form: h | ||
| form: n | ||
| }) { | ||
| i(this, "form"); | ||
| i(this, "name"); | ||
| i(this, "ee", f()); | ||
| i(this, "ee", u()); | ||
| i(this, "data"); | ||
@@ -55,3 +55,3 @@ i(this, "initParams"); | ||
| }); | ||
| this.form = h, this.test = a, this.name = o, this.initParams = { | ||
| this.form = n, this.test = a, this.name = o, this.initParams = { | ||
| value: t, | ||
@@ -65,6 +65,6 @@ touched: e, | ||
| touched: e | ||
| }, h.addField(this); | ||
| }, n.addField(this); | ||
| } | ||
| static new(t) { | ||
| return new n(t); | ||
| return new h(t); | ||
| } | ||
@@ -102,4 +102,4 @@ // ee = createEventEmitter(); | ||
| if (this.data[t] = e, this.notify(t, e), t === "error") { | ||
| const o = r, h = e; | ||
| h !== "" && o === "" ? (this.form._errors++, this.form._errors === 1 && this.form.notify("valid", !1)) : h === "" && o !== "" && (this.form._errors--, this.form._errors === 0 && this.form.notify("valid", !0)); | ||
| const o = r, n = e; | ||
| n !== "" && o === "" ? (this.form._errors++, this.form._errors === 1 && this.form.notify("valid", !1)) : n === "" && o !== "" && (this.form._errors--, this.form._errors === 0 && this.form.notify("valid", !0)); | ||
| } | ||
@@ -136,3 +136,3 @@ return (t === "error" || t === "touched") && a !== this.errorTouched && this.notify("errorTouched", this.errorTouched), !0; | ||
| }; | ||
| class u { | ||
| class l { | ||
| constructor(t = {}) { | ||
@@ -144,3 +144,3 @@ i(this, "options"); | ||
| i(this, "onSubmit"); | ||
| i(this, "ee", f()); | ||
| i(this, "ee", u()); | ||
| i(this, "submit", async () => { | ||
@@ -163,8 +163,8 @@ if (await this.validate()) | ||
| for (const a in r) { | ||
| const o = r[a], h = this._getFlatFieldOrCreate(a, { value: void 0 }); | ||
| h.test = o; | ||
| const o = r[a], n = this._getFlatFieldOrCreate(a, { value: void 0 }); | ||
| n.test = o; | ||
| } | ||
| } | ||
| static new(t) { | ||
| return new u(t); | ||
| return new l(t); | ||
| } | ||
@@ -175,3 +175,3 @@ notify(t, e) { | ||
| createField(t) { | ||
| return new n(t); | ||
| return new h(t); | ||
| } | ||
@@ -181,2 +181,5 @@ _getFlatFieldOrCreate(t, e) { | ||
| } | ||
| addPlugin(t) { | ||
| return t(this); | ||
| } | ||
| validate() { | ||
@@ -255,8 +258,8 @@ for (const t of this._flatFields) | ||
| export { | ||
| n as Field, | ||
| n as FieldFfw, | ||
| u as Form, | ||
| u as FormFfw, | ||
| h as Field, | ||
| h as FieldFfw, | ||
| l as Form, | ||
| l as FormFfw, | ||
| _ as prepareDesy, | ||
| p as prepareYup | ||
| }; |
+24
-21
@@ -1,3 +0,3 @@ | ||
| var l = Object.defineProperty; | ||
| var d = (s, t, e) => t in s ? l(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; | ||
| var f = Object.defineProperty; | ||
| var d = (s, t, e) => t in s ? f(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; | ||
| var i = (s, t, e) => (d(s, typeof t != "symbol" ? t + "" : t, e), e); | ||
@@ -21,7 +21,7 @@ class c { | ||
| } | ||
| function f() { | ||
| function u() { | ||
| return new c(); | ||
| } | ||
| const v = () => ""; | ||
| class n { | ||
| class h { | ||
| constructor({ | ||
@@ -33,7 +33,7 @@ value: t = "", | ||
| name: o = "", | ||
| form: h | ||
| form: n | ||
| }) { | ||
| i(this, "form"); | ||
| i(this, "name"); | ||
| i(this, "ee", f()); | ||
| i(this, "ee", u()); | ||
| i(this, "data"); | ||
@@ -55,3 +55,3 @@ i(this, "initParams"); | ||
| }); | ||
| this.form = h, this.test = a, this.name = o, this.initParams = { | ||
| this.form = n, this.test = a, this.name = o, this.initParams = { | ||
| value: t, | ||
@@ -65,6 +65,6 @@ touched: e, | ||
| touched: e | ||
| }, h.addField(this); | ||
| }, n.addField(this); | ||
| } | ||
| static new(t) { | ||
| return new n(t); | ||
| return new h(t); | ||
| } | ||
@@ -102,4 +102,4 @@ // ee = createEventEmitter(); | ||
| if (this.data[t] = e, this.notify(t, e), t === "error") { | ||
| const o = r, h = e; | ||
| h !== "" && o === "" ? (this.form._errors++, this.form._errors === 1 && this.form.notify("valid", !1)) : h === "" && o !== "" && (this.form._errors--, this.form._errors === 0 && this.form.notify("valid", !0)); | ||
| const o = r, n = e; | ||
| n !== "" && o === "" ? (this.form._errors++, this.form._errors === 1 && this.form.notify("valid", !1)) : n === "" && o !== "" && (this.form._errors--, this.form._errors === 0 && this.form.notify("valid", !0)); | ||
| } | ||
@@ -136,3 +136,3 @@ return (t === "error" || t === "touched") && a !== this.errorTouched && this.notify("errorTouched", this.errorTouched), !0; | ||
| }; | ||
| class u { | ||
| class l { | ||
| constructor(t = {}) { | ||
@@ -144,3 +144,3 @@ i(this, "options"); | ||
| i(this, "onSubmit"); | ||
| i(this, "ee", f()); | ||
| i(this, "ee", u()); | ||
| i(this, "submit", async () => { | ||
@@ -163,8 +163,8 @@ if (await this.validate()) | ||
| for (const a in r) { | ||
| const o = r[a], h = this._getFlatFieldOrCreate(a, { value: void 0 }); | ||
| h.test = o; | ||
| const o = r[a], n = this._getFlatFieldOrCreate(a, { value: void 0 }); | ||
| n.test = o; | ||
| } | ||
| } | ||
| static new(t) { | ||
| return new u(t); | ||
| return new l(t); | ||
| } | ||
@@ -175,3 +175,3 @@ notify(t, e) { | ||
| createField(t) { | ||
| return new n(t); | ||
| return new h(t); | ||
| } | ||
@@ -181,2 +181,5 @@ _getFlatFieldOrCreate(t, e) { | ||
| } | ||
| addPlugin(t) { | ||
| return t(this); | ||
| } | ||
| validate() { | ||
@@ -255,8 +258,8 @@ for (const t of this._flatFields) | ||
| export { | ||
| n as Field, | ||
| n as FieldFfw, | ||
| u as Form, | ||
| u as FormFfw, | ||
| h as Field, | ||
| h as FieldFfw, | ||
| l as Form, | ||
| l as FormFfw, | ||
| _ as prepareDesy, | ||
| p as prepareYup | ||
| }; |
@@ -8,4 +8,5 @@ import { Cb, Field, PropsField, Test } from '../field/field.js'; | ||
| type OnSubmit = (form: Form) => void; | ||
| type FormPlugin<TForm extends Form = any> = (form: TForm) => any; | ||
| type FormProps = { | ||
| plugins?: ((form: Form) => void)[]; | ||
| plugins?: FormPlugin[]; | ||
| initValues?: Record<string, any>; | ||
@@ -17,3 +18,3 @@ options?: Partial<Options>; | ||
| export declare class Form<TField extends Field = Field> { | ||
| static new(props: FormProps): Form<Field<any>>; | ||
| static new<TFormProps extends FormProps = any>(props?: TFormProps): Form<Field<any>>; | ||
| options: { | ||
@@ -32,2 +33,3 @@ validateOnChange: boolean; | ||
| _getFlatFieldOrCreate(name: string, props: Omit<PropsField, 'name' | 'form'>): TField; | ||
| addPlugin<TPlugin extends FormPlugin<typeof this>>(plugin: TPlugin): ReturnType<TPlugin>; | ||
| constructor(props?: FormProps); | ||
@@ -34,0 +36,0 @@ validate(): boolean; |
+1
-1
| { | ||
| "name": "ffw", | ||
| "version": "1.1.7", | ||
| "version": "1.1.8", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/ffw.js", |
17326
1.57%625
1.3%