remix-forms
Advanced tools
Comparing version 3.0.0-alpha.2 to 3.0.0-alpha.3
@@ -5,3 +5,3 @@ import * as React$1 from 'react'; | ||
import { ComposableWithSchema } from 'composable-functions'; | ||
import { Form, FetcherWithComponents, FormProps } from 'react-router'; | ||
import { data, Form, FetcherWithComponents, FormProps } from 'react-router'; | ||
@@ -15,2 +15,3 @@ type FormSchema<T extends z.ZodTypeAny = z.SomeZodObject | z.ZodEffects<any>> = z.ZodEffects<T> | z.SomeZodObject; | ||
type DataWithResponseInit<T> = ReturnType<typeof data<T>>; | ||
type FormActionFailure<SchemaType> = { | ||
@@ -40,3 +41,3 @@ errors: FormErrors<SchemaType>; | ||
declare function performMutation<Schema extends FormSchema, D extends unknown>({ request, schema, mutation, context, transformResult, transformValues, }: PerformMutationProps<Schema, D>): Promise<MutationResult<z.infer<Schema>, D>>; | ||
declare function formAction<Schema extends FormSchema, D extends unknown>({ request, schema, mutation, context, successPath, ...performMutationOptions }: FormActionProps<Schema, D>): Promise<D>; | ||
declare function formAction<Schema extends FormSchema, D extends unknown>({ successPath, ...performMutationOptions }: FormActionProps<Schema, D>): Promise<DataWithResponseInit<MutationResult<z.infer<Schema>, D>>>; | ||
@@ -43,0 +44,0 @@ type Option = { |
@@ -887,3 +887,3 @@ // src/schema-form.tsx | ||
import { inputFromForm, isInputError } from "composable-functions"; | ||
import { redirect } from "react-router"; | ||
import { data, redirect } from "react-router"; | ||
function errorMessagesForSchema(errors, _schema) { | ||
@@ -955,16 +955,6 @@ const inputErrors = errors.filter(isInputError); | ||
async function formAction({ | ||
request, | ||
schema, | ||
mutation, | ||
context, | ||
successPath, | ||
...performMutationOptions | ||
}) { | ||
const result = await performMutation({ | ||
request, | ||
schema, | ||
mutation, | ||
context, | ||
...performMutationOptions | ||
}); | ||
const result = await performMutation(performMutationOptions); | ||
if (result.success) { | ||
@@ -975,5 +965,5 @@ const path = typeof successPath === "function" ? await successPath(result.data) : successPath; | ||
} | ||
return result.data; | ||
return data(result); | ||
} else { | ||
return { errors: result.errors, values: result.values }; | ||
return data(result, { status: 422 }); | ||
} | ||
@@ -980,0 +970,0 @@ } |
{ | ||
"name": "remix-forms", | ||
"version": "3.0.0-alpha.2", | ||
"version": "3.0.0-alpha.3", | ||
"description": "The full-stack form library for React Router v7", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
85590
2110