remix-hook-form
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -5,27 +5,27 @@ import V from "react"; | ||
const U = async (t, e) => { | ||
const o = await P(t); | ||
return await I(o, e); | ||
const a = await P(t); | ||
return await I(a, e); | ||
}, I = async (t, e) => { | ||
const { errors: o, values: a } = await e(t, {}, { shouldUseNativeValidation: !1, fields: {} }); | ||
return Object.keys(o).length > 0 ? { errors: o, data: void 0 } : { errors: void 0, data: a }; | ||
const { errors: a, values: o } = await e(t, {}, { shouldUseNativeValidation: !1, fields: {} }); | ||
return Object.keys(a).length > 0 ? { errors: a, data: void 0 } : { errors: void 0, data: o }; | ||
}, J = (t, e = "formData") => { | ||
const o = new FormData(), a = JSON.stringify(t); | ||
return o.append(e, a), o; | ||
const a = new FormData(), o = JSON.stringify(t); | ||
return a.append(e, o), a; | ||
}, P = async (t, e = "formData") => { | ||
const a = (await t.formData()).get(e); | ||
if (!a) | ||
const o = (await t.formData()).get(e); | ||
if (!o) | ||
throw new Error("No data found"); | ||
if (typeof a != "string") | ||
if (typeof o != "string") | ||
throw new Error("Data is not a string"); | ||
return JSON.parse(a); | ||
return JSON.parse(o); | ||
}, s = (t, e) => { | ||
if (!e) | ||
return t; | ||
for (const [o, a] of Object.entries(e)) | ||
typeof a == "object" && !Array.isArray(a) ? (t[o] || (t[o] = {}), s(t[o], a)) : t[o] = a; | ||
for (const [a, o] of Object.entries(e)) | ||
typeof o == "object" && !Array.isArray(o) ? (t[a] || (t[a] = {}), s(t[a], o)) : o && (t[a] = o); | ||
return t; | ||
}, q = ({ submitHandlers: t, submitConfig: e, submitData: o, ...a }) => { | ||
}, q = ({ submitHandlers: t, submitConfig: e, submitData: a, ...o }) => { | ||
var i, r; | ||
const m = N(), u = R(), n = j(a), c = (O) => { | ||
m(J({ ...O, ...o }), { | ||
const m = N(), u = R(), n = j(o), c = (O) => { | ||
m(J({ ...O, ...a }), { | ||
method: "post", | ||
@@ -32,0 +32,0 @@ ...e |
@@ -54,7 +54,7 @@ import { FieldValues, Resolver, FieldErrors, FieldErrorsImpl, DeepRequired } from "react-hook-form"; | ||
@template T - The generic type of the object. | ||
@param {Partial<FieldErrorsImpl<DeepRequired<T>>>} frontendErrors - The frontend errors | ||
@param {Partial<FieldErrorsImpl<DeepRequired<T>>>} backendErrors - The backend errors | ||
@returns {Partial<FieldErrorsImpl<DeepRequired<T>>>} - The merged errors of type Partial<FieldErrorsImpl<DeepRequired<T>>>. | ||
@param frontendErrors - The frontend errors | ||
@param backendErrors - The backend errors | ||
@returns The merged errors of type Partial<FieldErrorsImpl<DeepRequired<T>>>. | ||
*/ | ||
export declare const mergeErrors: <T extends FieldValues>(frontendErrors: Partial<FieldErrorsImpl<DeepRequired<T>>>, backendErrors: Partial<FieldErrorsImpl<DeepRequired<T>>>) => Partial<FieldErrorsImpl<DeepRequired<T>>>; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "remix-hook-form", | ||
"version": "1.0.4", | ||
"description": "Utility wrapper around react-hook-form", | ||
"version": "1.0.5", | ||
"description": "Utility wrapper around react-hook-form for use with Remix.run", | ||
"type": "module", | ||
@@ -20,2 +20,3 @@ "main": "./dist/index.umd.cjs", | ||
"prepare": "vite build", | ||
"build": "vite build", | ||
"test": "vitest run" | ||
@@ -51,4 +52,6 @@ }, | ||
"@remix-run/react": "^1.15.0", | ||
"@testing-library/react": "^14.0.0", | ||
"@types/node": "^18.15.11", | ||
"@types/react": "^18.0.34", | ||
"happy-dom": "^9.5.0", | ||
"react": "^18.2.0", | ||
@@ -55,0 +58,0 @@ "react-dom": "^18.2.0", |
Sorry, the diff of this file is not supported yet
28389
14