+39
-34
@@ -1,9 +0,9 @@ | ||
| import { createContext as b, useContext as v, useMemo as d, useCallback as c, useSyncExternalStore as F } from "react"; | ||
| const l = b(null), y = l.Provider, x = () => v(l); | ||
| function i(t) { | ||
| const e = x(); | ||
| import { createContext as d, useContext as v, useMemo as F, useCallback as c, useSyncExternalStore as x } from "react"; | ||
| const a = d(null), S = a.Provider, C = () => v(a); | ||
| function f(t) { | ||
| const e = C(); | ||
| return t || e; | ||
| } | ||
| function f(t, e) { | ||
| const r = d( | ||
| function m(t, e) { | ||
| const r = F( | ||
| () => ({ | ||
@@ -16,8 +16,8 @@ immutable: { | ||
| ), n = c( | ||
| (u) => e((o) => { | ||
| r.immutable = { ...r.immutable }, r.immutable.value = o, u(o); | ||
| (o) => e((s) => { | ||
| r.immutable = { ...r.immutable }, r.immutable.value = s, o(s); | ||
| }), | ||
| [t, e] | ||
| ); | ||
| return F( | ||
| return x( | ||
| n, | ||
@@ -28,12 +28,12 @@ () => r.immutable, | ||
| } | ||
| function S(t) { | ||
| const e = i(t), r = c( | ||
| (u) => e.on("valid", u), | ||
| function E(t) { | ||
| const e = f(t), r = c( | ||
| (o) => e.on("valid", o), | ||
| [e] | ||
| ), n = c(() => e.getValid(), [e]); | ||
| return f(n, r); | ||
| return m(n, r); | ||
| } | ||
| function C(t) { | ||
| function l(t) { | ||
| const e = t; | ||
| e.react = { | ||
| return e.react = { | ||
| getFieldHelpers: () => ({ | ||
@@ -44,30 +44,35 @@ value: t.value, | ||
| }) | ||
| }; | ||
| }, e; | ||
| } | ||
| const E = () => (t) => { | ||
| const e = t.createField; | ||
| t.createField = function(...r) { | ||
| const n = e.apply(t, r); | ||
| return C(n), n; | ||
| const p = (t) => { | ||
| const e = t, r = t.createField; | ||
| t.createField = function(...n) { | ||
| const u = r.apply(t, n); | ||
| return l(u); | ||
| }; | ||
| }; | ||
| function p(t, e) { | ||
| for (const n in t.fields) { | ||
| const u = t.fields[n]; | ||
| l(u); | ||
| } | ||
| return e; | ||
| }, P = () => (t) => p(t); | ||
| function g(t, e) { | ||
| return t = typeof t == "function" ? t(e) : t, t.map((n) => typeof n == "string" ? e.fields[n] : n); | ||
| } | ||
| function P(t = [], e) { | ||
| const r = i(e), n = p(t, r), s = c(() => n, n), u = c((o) => (n.forEach( | ||
| (a) => a.on("*", () => { | ||
| o(n); | ||
| function R(t = [], e) { | ||
| const r = f(e), n = g(t, r), u = c(() => n, n), o = c((s) => (n.forEach( | ||
| (i) => i.on("*", () => { | ||
| s(n); | ||
| }) | ||
| ), () => { | ||
| n.forEach((a) => a.off("*", o)); | ||
| n.forEach((i) => i.off("*", s)); | ||
| }), n); | ||
| return f(s, u); | ||
| return m(u, o); | ||
| } | ||
| export { | ||
| y as FfwProvider, | ||
| E as addReactPlugin, | ||
| P as useFields, | ||
| i as useForm, | ||
| S as useFormValid | ||
| S as FfwProvider, | ||
| P as addReactPlugin, | ||
| R as useFields, | ||
| f as useForm, | ||
| E as useFormValid | ||
| }; |
+39
-34
@@ -1,9 +0,9 @@ | ||
| import { createContext as b, useContext as v, useMemo as d, useCallback as c, useSyncExternalStore as F } from "react"; | ||
| const l = b(null), y = l.Provider, x = () => v(l); | ||
| function i(t) { | ||
| const e = x(); | ||
| import { createContext as d, useContext as v, useMemo as F, useCallback as c, useSyncExternalStore as x } from "react"; | ||
| const a = d(null), S = a.Provider, C = () => v(a); | ||
| function f(t) { | ||
| const e = C(); | ||
| return t || e; | ||
| } | ||
| function f(t, e) { | ||
| const r = d( | ||
| function m(t, e) { | ||
| const r = F( | ||
| () => ({ | ||
@@ -16,8 +16,8 @@ immutable: { | ||
| ), n = c( | ||
| (u) => e((o) => { | ||
| r.immutable = { ...r.immutable }, r.immutable.value = o, u(o); | ||
| (o) => e((s) => { | ||
| r.immutable = { ...r.immutable }, r.immutable.value = s, o(s); | ||
| }), | ||
| [t, e] | ||
| ); | ||
| return F( | ||
| return x( | ||
| n, | ||
@@ -28,12 +28,12 @@ () => r.immutable, | ||
| } | ||
| function S(t) { | ||
| const e = i(t), r = c( | ||
| (u) => e.on("valid", u), | ||
| function E(t) { | ||
| const e = f(t), r = c( | ||
| (o) => e.on("valid", o), | ||
| [e] | ||
| ), n = c(() => e.getValid(), [e]); | ||
| return f(n, r); | ||
| return m(n, r); | ||
| } | ||
| function C(t) { | ||
| function l(t) { | ||
| const e = t; | ||
| e.react = { | ||
| return e.react = { | ||
| getFieldHelpers: () => ({ | ||
@@ -44,30 +44,35 @@ value: t.value, | ||
| }) | ||
| }; | ||
| }, e; | ||
| } | ||
| const E = () => (t) => { | ||
| const e = t.createField; | ||
| t.createField = function(...r) { | ||
| const n = e.apply(t, r); | ||
| return C(n), n; | ||
| const p = (t) => { | ||
| const e = t, r = t.createField; | ||
| t.createField = function(...n) { | ||
| const u = r.apply(t, n); | ||
| return l(u); | ||
| }; | ||
| }; | ||
| function p(t, e) { | ||
| for (const n in t.fields) { | ||
| const u = t.fields[n]; | ||
| l(u); | ||
| } | ||
| return e; | ||
| }, P = () => (t) => p(t); | ||
| function g(t, e) { | ||
| return t = typeof t == "function" ? t(e) : t, t.map((n) => typeof n == "string" ? e.fields[n] : n); | ||
| } | ||
| function P(t = [], e) { | ||
| const r = i(e), n = p(t, r), s = c(() => n, n), u = c((o) => (n.forEach( | ||
| (a) => a.on("*", () => { | ||
| o(n); | ||
| function R(t = [], e) { | ||
| const r = f(e), n = g(t, r), u = c(() => n, n), o = c((s) => (n.forEach( | ||
| (i) => i.on("*", () => { | ||
| s(n); | ||
| }) | ||
| ), () => { | ||
| n.forEach((a) => a.off("*", o)); | ||
| n.forEach((i) => i.off("*", s)); | ||
| }), n); | ||
| return f(s, u); | ||
| return m(u, o); | ||
| } | ||
| export { | ||
| y as FfwProvider, | ||
| E as addReactPlugin, | ||
| P as useFields, | ||
| i as useForm, | ||
| S as useFormValid | ||
| S as FfwProvider, | ||
| P as addReactPlugin, | ||
| R as useFields, | ||
| f as useForm, | ||
| E as useFormValid | ||
| }; |
@@ -12,2 +12,2 @@ import { Field, Form } from 'ffw'; | ||
| export type FormReact = Form<FieldReact>; | ||
| export declare const addReactPlugin: () => (form: Form) => void; | ||
| export declare const addReactPlugin: () => (form: Form) => FormReact; |
+2
-2
| { | ||
| "name": "ffw-react", | ||
| "version": "1.1.3", | ||
| "version": "1.1.4", | ||
| "description": "", | ||
@@ -13,3 +13,3 @@ "type": "module", | ||
| "react": "*", | ||
| "ffw": "1.1.7" | ||
| "ffw": "1.1.8" | ||
| }, | ||
@@ -16,0 +16,0 @@ "author": "", |
5350
4.55%188
5.62%