| 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(); | ||
| return t || e; | ||
| } | ||
| function f(t, e) { | ||
| const r = d( | ||
| () => ({ | ||
| immutable: { | ||
| value: t() | ||
| } | ||
| }), | ||
| [t, e] | ||
| ), n = c( | ||
| (u) => e((o) => { | ||
| r.immutable = { ...r.immutable }, r.immutable.value = o, u(o); | ||
| }), | ||
| [t, e] | ||
| ); | ||
| return F( | ||
| n, | ||
| () => r.immutable, | ||
| () => r.immutable | ||
| ).value; | ||
| } | ||
| function S(t) { | ||
| const e = i(t), r = c( | ||
| (u) => e.on("valid", u), | ||
| [e] | ||
| ), n = c(() => e.getValid(), [e]); | ||
| return f(n, r); | ||
| } | ||
| function C(t) { | ||
| const e = t; | ||
| e.react = { | ||
| getFieldHelpers: () => ({ | ||
| value: t.value, | ||
| onInput: (r) => t.set(r.target.value), | ||
| onBlur: () => t.onBlur() | ||
| }) | ||
| }; | ||
| } | ||
| const E = () => (t) => { | ||
| const e = t.createField; | ||
| t.createField = function(...r) { | ||
| const n = e.apply(t, r); | ||
| return C(n), n; | ||
| }; | ||
| }; | ||
| function p(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); | ||
| }) | ||
| ), () => { | ||
| n.forEach((a) => a.off("*", o)); | ||
| }), n); | ||
| return f(s, u); | ||
| } | ||
| export { | ||
| y as FfwProvider, | ||
| E as addReactPlugin, | ||
| P as useFields, | ||
| i as useForm, | ||
| S as useFormValid | ||
| }; |
+3
-5
| { | ||
| "name": "ffw-react", | ||
| "version": "1.1.2", | ||
| "version": "1.1.3", | ||
| "description": "", | ||
| "type": "module", | ||
| "exports": { | ||
| "import": "./dist/ffw-react.js", | ||
| "require": "./dist/ffw-react.cjs" | ||
| }, | ||
| "types": "./dist/types/ffw-react.d.ts", | ||
| "main": "./dist/ffw-react.js", | ||
| "files": [ | ||
@@ -11,0 +9,0 @@ "dist/**/*" |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
5117
39.31%10
11.11%178
64.81%0
-100%