remix-hook-form
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -1,4 +0,4 @@ | ||
import I from "react"; | ||
import { useSubmit as N, useActionData as G } from "@remix-run/react"; | ||
import { useForm as J, FormProvider as L, useFormContext as U } from "react-hook-form"; | ||
import G from "react"; | ||
import { useSubmit as J, useActionData as L } from "@remix-run/react"; | ||
import { useForm as U, FormProvider as K, useFormContext as T } from "react-hook-form"; | ||
const g = (t) => { | ||
@@ -21,15 +21,15 @@ const a = {}; | ||
return a; | ||
}, K = (t) => { | ||
}, z = (t) => { | ||
const a = new URL(t.url).searchParams; | ||
return g(a); | ||
}, T = (t) => t.method === "GET" || t.method === "get", Y = async (t, a) => { | ||
const e = T(t) ? K(t) : await M(t); | ||
return { ...await z(e, a), receivedValues: e }; | ||
}, z = async (t, a) => { | ||
}, B = (t) => t.method === "GET" || t.method === "get", E = async (t, a) => { | ||
const e = B(t) ? z(t) : await W(t); | ||
return { ...await M(e, a), receivedValues: e }; | ||
}, M = async (t, a) => { | ||
const { errors: e, values: o } = await a(t, {}, { shouldUseNativeValidation: !1, fields: {} }); | ||
return Object.keys(e).length > 0 ? { errors: e, data: void 0 } : { errors: void 0, data: o }; | ||
}, B = (t, a = "formData") => { | ||
}, Q = (t, a = "formData") => { | ||
const e = new FormData(), o = JSON.stringify(t); | ||
return e.append(a, o), e; | ||
}, M = async (t, a = "formData") => { | ||
}, W = async (t, a = "formData") => { | ||
const e = await t.formData(), o = e.get(a); | ||
@@ -47,18 +47,18 @@ if (!o) | ||
return t; | ||
}, Z = ({ submitHandlers: t, submitConfig: a, submitData: e, fetcher: o, ...r }) => { | ||
}, q = ({ submitHandlers: t, submitConfig: a, submitData: e, fetcher: o, ...r }) => { | ||
var i, n, u, s; | ||
const c = (i = o == null ? void 0 : o.submit) !== null && i !== void 0 ? i : N(), l = (n = o == null ? void 0 : o.data) !== null && n !== void 0 ? n : G(), d = J(r), p = (m) => { | ||
c(B({ ...m, ...e }), { | ||
const c = J(), S = L(), p = (i = o == null ? void 0 : o.submit) !== null && i !== void 0 ? i : c, l = (n = o == null ? void 0 : o.data) !== null && n !== void 0 ? n : S, d = U(r), D = (m) => { | ||
p(Q({ ...m, ...e }), { | ||
method: "post", | ||
...a | ||
}); | ||
}, S = d.getValues(), h = Object.keys(S), D = () => { | ||
}, F = d.formState, { dirtyFields: b, isDirty: V, isSubmitSuccessful: O, isSubmitted: P, isSubmitting: w, isValid: j, isValidating: k, touchedFields: x, submitCount: _, errors: $, isLoading: R } = F, A = y($, l != null && l.errors ? l.errors : l, h); | ||
}, h = d.getValues(), F = Object.keys(h), b = () => { | ||
}, V = d.formState, { dirtyFields: O, isDirty: P, isSubmitSuccessful: w, isSubmitted: j, isSubmitting: k, isValid: x, isValidating: _, touchedFields: $, submitCount: R, errors: A, isLoading: C } = V, I = y(A, l != null && l.errors ? l.errors : l, F); | ||
return { | ||
...d, | ||
handleSubmit: d.handleSubmit((u = t == null ? void 0 : t.onValid) !== null && u !== void 0 ? u : p, (s = t == null ? void 0 : t.onInvalid) !== null && s !== void 0 ? s : D), | ||
register: (m, C) => { | ||
handleSubmit: d.handleSubmit((u = t == null ? void 0 : t.onValid) !== null && u !== void 0 ? u : D, (s = t == null ? void 0 : t.onInvalid) !== null && s !== void 0 ? s : b), | ||
register: (m, N) => { | ||
var v, f; | ||
return { | ||
...d.register(m, C), | ||
...d.register(m, N), | ||
defaultValue: (f = (v = l == null ? void 0 : l.defaultValues) === null || v === void 0 ? void 0 : v[m]) !== null && f !== void 0 ? f : "" | ||
@@ -68,17 +68,17 @@ }; | ||
formState: { | ||
dirtyFields: b, | ||
isDirty: V, | ||
isSubmitSuccessful: O, | ||
isSubmitted: P, | ||
isSubmitting: w, | ||
isValid: j, | ||
isValidating: k, | ||
touchedFields: x, | ||
submitCount: _, | ||
isLoading: R, | ||
errors: A | ||
dirtyFields: O, | ||
isDirty: P, | ||
isSubmitSuccessful: w, | ||
isSubmitted: j, | ||
isSubmitting: k, | ||
isValid: x, | ||
isValidating: _, | ||
touchedFields: $, | ||
submitCount: R, | ||
isLoading: C, | ||
errors: I | ||
} | ||
}; | ||
}, E = ({ children: t, ...a }) => I.createElement(L, { ...a }, t), q = () => { | ||
const t = U(); | ||
}, H = ({ children: t, ...a }) => G.createElement(K, { ...a }, t), tt = () => { | ||
const t = T(); | ||
return { | ||
@@ -90,10 +90,10 @@ ...t, | ||
export { | ||
E as RemixFormProvider, | ||
B as createFormData, | ||
K as getFormDataFromSearchParams, | ||
Y as getValidatedFormData, | ||
M as parseFormData, | ||
Z as useRemixForm, | ||
q as useRemixFormContext, | ||
z as validateFormData | ||
H as RemixFormProvider, | ||
Q as createFormData, | ||
z as getFormDataFromSearchParams, | ||
E as getValidatedFormData, | ||
W as parseFormData, | ||
q as useRemixForm, | ||
tt as useRemixFormContext, | ||
M as validateFormData | ||
}; |
{ | ||
"name": "remix-hook-form", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Utility wrapper around react-hook-form for use with Remix.run", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36544