UNPKG

@payfit/unity-components

Version:

42 lines (41 loc) 1.22 kB
import { UnityFormProvider as e } from "./Form.context.js"; import { Suspense as t, forwardRef as n, lazy as r } from "react"; import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime"; import { FormProvider as s } from "react-hook-form"; //#region src/components/form/Form.tsx var c = r(() => import("@hookform/devtools").then((e) => ({ default: e.DevTool }))), l = ({ form: n, schema: r, onSuccess: l, onError: u, onInvalid: d, action: f, children: p, className: m, onReset: h, debug: g = !1, ..._ }, v) => { let y = n.handleSubmit((e) => { Promise.resolve().then(() => f(e)).then((t) => { l?.(t, e); }).catch((t) => { u?.(t, e); }); }, (e) => { d?.(e); }); return /* @__PURE__ */ a(e, { schema: r, children: /* @__PURE__ */ o(s, { ...n, children: [g && /* @__PURE__ */ a(t, { fallback: /* @__PURE__ */ a(i, {}), children: /* @__PURE__ */ a(c, { control: n.control }) }), /* @__PURE__ */ a("form", { ..._, ref: v, onSubmit: (e) => { y(e); }, className: m, onReset: h, "data-dd-privacy": "mask", children: p })] }) }); }, u = n(function(e, t) { return l(e, t); }); u.displayName = "Form"; //#endregion export { u as Form };