react-form-action 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +10 -6
- package/dist/client.mjs +1 -1
- package/dist/formAction-0eiUHrXx.d.mts +90 -0
- package/dist/index.d.mts +4 -59
- package/package.json +1 -1
- package/dist/createFormAction-4p5Fvn2A.d.mts +0 -35
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as FormAction, c as SuccessState, i as FailureState, o as InitialState, r as ActionState, s as InvalidState, t as Flatten } from "./formAction-0eiUHrXx.mjs";
|
|
2
2
|
import React$1, { JSX, PropsWithChildren } from "react";
|
|
3
3
|
import { $ZodErrorTree } from "zod/v4/core";
|
|
4
4
|
//#region src/Action.d.ts
|
|
@@ -21,13 +21,13 @@ type ActionStatusFlags<T extends ActionState<unknown, unknown, unknown>["type"]
|
|
|
21
21
|
isFailure: T extends "failure" ? true : false;
|
|
22
22
|
isSuccess: T extends "success" ? true : false;
|
|
23
23
|
};
|
|
24
|
-
type ActionContextState<T extends ActionState<unknown, unknown, unknown>> = T & ActionStatusFlags<T["type"]> & {
|
|
24
|
+
type ActionContextState<T extends ActionState<unknown, unknown, unknown>> = Flatten<T & ActionStatusFlags<T["type"]> & {
|
|
25
25
|
/**
|
|
26
26
|
* The dispatch function returned from React.useActionState()
|
|
27
27
|
*/
|
|
28
28
|
action: (payload: FormData) => void;
|
|
29
29
|
isPending: boolean;
|
|
30
|
-
}
|
|
30
|
+
}>;
|
|
31
31
|
/**
|
|
32
32
|
* NOTE: ActionContextState<ActionState<...>> would not allow discriminate the union inside of the ActionState.
|
|
33
33
|
*/
|
|
@@ -58,13 +58,17 @@ declare const noError: Readonly<{
|
|
|
58
58
|
declare function ZodFieldError<Errors extends $ZodErrorTree<object>, Name extends "" | InferZodErrorPaths<Errors> = "">({ errors, name, children }: ZodFieldErrorProps<Errors, Name>): React$1.ReactNode;
|
|
59
59
|
//#endregion
|
|
60
60
|
//#region src/createComponents.d.ts
|
|
61
|
+
type Reducers<State = unknown> = Record<string, (state: State) => unknown>;
|
|
62
|
+
type InferFieldProps<T extends Reducers<any>> = { [K in keyof T]: ReturnType<T[K]>; };
|
|
61
63
|
/**
|
|
62
64
|
* Creates a typed components for actions created with the formAction builder.
|
|
63
65
|
*/
|
|
64
|
-
declare function createComponents<Data, Error, ValidationError extends $ZodErrorTree<any>, Args extends unknown[] = []
|
|
66
|
+
declare function createComponents<Data, Error, ValidationError extends $ZodErrorTree<any>, Args extends unknown[] = [], FieldReducers extends Reducers<SpreadActionContext<Data, Error, ValidationError>> = Reducers<SpreadActionContext<Data, Error, ValidationError>>>(action: FormAction<Data, Error, ValidationError, FormData, Args>, options?: {
|
|
67
|
+
fieldProps?: FieldReducers;
|
|
68
|
+
}): {
|
|
65
69
|
FieldError: <Name extends "" | InferZodErrorPaths<ValidationError>>({ name, children }: {
|
|
66
70
|
name: Name;
|
|
67
|
-
children?: (props: ZodFieldErrorChildrenProps<Name>) => React$1.ReactNode;
|
|
71
|
+
children?: (props: Flatten<ZodFieldErrorChildrenProps<Name> & InferFieldProps<FieldReducers>>) => React$1.ReactNode;
|
|
68
72
|
}) => React$1.JSX.Element;
|
|
69
73
|
Success: ({ children }: PropsWithChildren | {
|
|
70
74
|
children?: (props: {
|
|
@@ -108,4 +112,4 @@ declare function Pending({ children }: PropsWithChildren | {
|
|
|
108
112
|
}) => React.ReactNode;
|
|
109
113
|
}): import("react").ReactNode;
|
|
110
114
|
//#endregion
|
|
111
|
-
export { Action, ActionContextState, ActionProps, Form, FormProps, InferZodErrorPaths, Paths, Pending, ZodFieldError, ZodFieldErrorChildrenProps, ZodFieldErrorProps, createComponents, noError, useActionContext };
|
|
115
|
+
export { Action, ActionContextState, ActionProps, Form, FormProps, InferZodErrorPaths, Paths, Pending, SpreadActionContext, ZodFieldError, ZodFieldErrorChildrenProps, ZodFieldErrorProps, createComponents, noError, useActionContext };
|
package/dist/client.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{n as e,t}from"./createFormAction-BwMYAzm2.mjs";import{createContext as n,startTransition as r,use as i,useActionState as a}from"react";import{Fragment as o,jsx as s}from"react/jsx-runtime";const c={isInitial:!1,isInvalid:!1,isFailure:!1,isSuccess:!1},l=n(null);function u(e){let t=i(l);if(!t)throw Error(`ActionContext must be initialized before use. Is your useActionContext hook wrapped with an <Action> Component?`);return t}function d({children:n,action:r,initialData:i,args:o,permalink:u,validate:d}){let f=o?r.bind(null,...o):r,[p,m,h]=a(async(e,n)=>{if(d){let r=await t(({invalid:e,success:t})=>async(n,r)=>{let i=d(r);return i?e(i):t(!0)})(e,n);if(r.type===`invalid`)return r}return f(e,n)},e(i),u),g=p.type===`initial`?{...p,...c,action:m,isPending:h,isInitial:!0}:p.type===`invalid`?{...p,...c,action:m,isPending:h,isInvalid:!0}:p.type===`failure`?{...p,...c,action:m,isPending:h,isFailure:!0}:{...p,...c,action:m,isPending:h,isSuccess:!0};return s(l,{value:g,children:n})}const f=Object.freeze({errors:Object.freeze([])});function p({errors:e,name:t,children:n=({error:e})=>s(o,{children:e})}){if(t.length===0)return n({name:t,error:e.errors[0],errors:e.errors});let r=t.split(`.`),i=e;for(let e of r){if(!i.properties){i=f;break}i=i.properties[e]??f}return n({name:t,error:i.errors[0],errors:i.errors})}function m(e){function
|
|
1
|
+
"use client";import{n as e,t}from"./createFormAction-BwMYAzm2.mjs";import{createContext as n,startTransition as r,use as i,useActionState as a}from"react";import{Fragment as o,jsx as s}from"react/jsx-runtime";const c={isInitial:!1,isInvalid:!1,isFailure:!1,isSuccess:!1},l=n(null);function u(e){let t=i(l);if(!t)throw Error(`ActionContext must be initialized before use. Is your useActionContext hook wrapped with an <Action> Component?`);return t}function d({children:n,action:r,initialData:i,args:o,permalink:u,validate:d}){let f=o?r.bind(null,...o):r,[p,m,h]=a(async(e,n)=>{if(d){let r=await t(({invalid:e,success:t})=>async(n,r)=>{let i=d(r);return i?e(i):t(!0)})(e,n);if(r.type===`invalid`)return r}return f(e,n)},e(i),u),g=p.type===`initial`?{...p,...c,action:m,isPending:h,isInitial:!0}:p.type===`invalid`?{...p,...c,action:m,isPending:h,isInvalid:!0}:p.type===`failure`?{...p,...c,action:m,isPending:h,isFailure:!0}:{...p,...c,action:m,isPending:h,isSuccess:!0};return s(l,{value:g,children:n})}const f=Object.freeze({errors:Object.freeze([])});function p({errors:e,name:t,children:n=({error:e})=>s(o,{children:e})}){if(t.length===0)return n({name:t,error:e.errors[0],errors:e.errors});let r=t.split(`.`),i=e;for(let e of r){if(!i.properties){i=f;break}i=i.properties[e]??f}return n({name:t,error:i.errors[0],errors:i.errors})}function m(e,t={}){function n({name:n,children:r}){let i=u(e),{isInvalid:a,validationError:c}=i,l=({error:e})=>a&&s(o,{children:e}),d=Object.fromEntries(Object.entries(t.fieldProps??{}).map(([e,t])=>[e,t(i)])),m=r??l;return s(p,{errors:c??f,name:n,children:e=>m({...e,...d})})}function r({children:t}){let{isSuccess:n,data:r}=u(e);return typeof t==`function`?t({isSuccess:n,data:r}):n&&t}function i({children:t}){let{isInvalid:n,validationError:r}=u(e);return typeof t==`function`?t({isInvalid:n,validationError:r}):n&&t}return{FieldError:n,Success:r,Invalid:i}}function h({autoReset:e=!1,...t}){let{action:n}=u();return s(`form`,{...e?{action:n}:{onSubmit:e=>{e.preventDefault();let t=e.currentTarget;r(()=>{n(new FormData(t))})}},...t})}function g({children:e}){let{isPending:t}=u();return typeof e==`function`?e({isPending:t}):t&&e}export{d as Action,h as Form,g as Pending,p as ZodFieldError,m as createComponents,f as noError,u as useActionContext};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ZodObject, ZodTuple, ZodType, z } from "zod/v4";
|
|
2
|
+
import { $ZodErrorTree, $ZodShape, $ZodType } from "zod/v4/core";
|
|
3
|
+
//#region src/createFormAction.d.ts
|
|
4
|
+
type InitialState<T> = {
|
|
5
|
+
type: "initial";
|
|
6
|
+
data: T;
|
|
7
|
+
error: null;
|
|
8
|
+
validationError: null;
|
|
9
|
+
};
|
|
10
|
+
type InvalidState<T> = {
|
|
11
|
+
type: "invalid";
|
|
12
|
+
data: null;
|
|
13
|
+
error: null;
|
|
14
|
+
validationError: T;
|
|
15
|
+
};
|
|
16
|
+
type FailureState<T> = {
|
|
17
|
+
type: "failure";
|
|
18
|
+
data: null;
|
|
19
|
+
error: T;
|
|
20
|
+
validationError: null;
|
|
21
|
+
};
|
|
22
|
+
type SuccessState<T> = {
|
|
23
|
+
type: "success";
|
|
24
|
+
data: T;
|
|
25
|
+
error: null;
|
|
26
|
+
validationError: null;
|
|
27
|
+
};
|
|
28
|
+
type ActionState<Data, Error, ValidationError = Record<string, never>> = InitialState<Data> | InvalidState<ValidationError> | FailureState<Error> | SuccessState<Data>;
|
|
29
|
+
type FormAction<Data, Error = Data, ValidationError = Record<string, never>, Payload = FormData, Arguments extends unknown[] = []> = (...args: [...Arguments, state: ActionState<Data, Error, ValidationError>, payload: Payload]) => Promise<ActionState<Data, Error, ValidationError>>;
|
|
30
|
+
declare function initial<Data>(data: Data): InitialState<Data>;
|
|
31
|
+
declare function createFormAction<Data, Error = Data, ValidationError = Record<string, never>, Payload = FormData, Arguments extends [...unknown[]] = []>(formAction: (params: {
|
|
32
|
+
success: (data: Data) => SuccessState<Data>;
|
|
33
|
+
failure: (error: Error) => FailureState<Error>;
|
|
34
|
+
invalid: (validationError: ValidationError) => InvalidState<ValidationError>;
|
|
35
|
+
}, ...args: Arguments) => FormAction<Data, Error, ValidationError, Payload>): (...args: [...Arguments, state: ActionState<Data, Error, ValidationError>, payload: Payload]) => Promise<ActionState<Data, Error, ValidationError>>;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/formAction.d.ts
|
|
38
|
+
declare const emptyInput: unique symbol;
|
|
39
|
+
type EmptyInput = typeof emptyInput;
|
|
40
|
+
type Flatten<T> = Identity<{ [K in keyof T]: T[K]; }>;
|
|
41
|
+
type Identity<T> = T;
|
|
42
|
+
type ErrorHandler<Context, Err, Args> = (params: {
|
|
43
|
+
error: unknown;
|
|
44
|
+
ctx: Context;
|
|
45
|
+
args: Args;
|
|
46
|
+
}) => Promise<Err>;
|
|
47
|
+
type InitialContext = Record<"formData", FormData>;
|
|
48
|
+
/**
|
|
49
|
+
* Action without schema has no input.
|
|
50
|
+
*/
|
|
51
|
+
type Action<Data, Context, Args extends unknown[]> = (params: {
|
|
52
|
+
args: Args;
|
|
53
|
+
ctx: Context;
|
|
54
|
+
}) => Promise<Data>;
|
|
55
|
+
/**
|
|
56
|
+
* Action with schema will get parsed formData as the input.
|
|
57
|
+
*/
|
|
58
|
+
type SchemaAction<Data, Context, Args extends unknown[], Schema extends ZodType> = (params: {
|
|
59
|
+
args: Args;
|
|
60
|
+
ctx: Context;
|
|
61
|
+
input: z.output<Schema>;
|
|
62
|
+
}) => Promise<Data>;
|
|
63
|
+
type FormActionBuilder<Schema extends ZodType | EmptyInput, Args extends $ZodType[] = [], TErr = unknown, Context = InitialContext, PlainArgs extends unknown[] = z.output<ZodTuple<Args, null>>> = {
|
|
64
|
+
args: <T extends [$ZodType, ...$ZodType[]]>(args: T) => FormActionBuilder<Schema, [...Args, ...T], TErr, Context>;
|
|
65
|
+
input: <T extends ZodObject>(newInput: T extends ZodObject ? T : "The schema output must be an object.") => FormActionBuilder<Schema extends ZodObject<infer O1 extends $ZodShape> ? T extends ZodObject<infer O2 extends $ZodShape> ? ZodObject<O1 & O2> : never : T, Args, TErr, Context>;
|
|
66
|
+
/**
|
|
67
|
+
* A finishing call on the builder completing your action.
|
|
68
|
+
* @param action async function to execute. It will receive parsed formData as input, when the builder was initialized with a schema.
|
|
69
|
+
* @returns runnable server action exportable from a module.
|
|
70
|
+
*/
|
|
71
|
+
run: Schema extends ZodType ? <Data>(action: SchemaAction<Data, Flatten<Context>, PlainArgs, Schema>) => (...args: [...PlainArgs, state: ActionState<Data, TErr, $ZodErrorTree<z.output<Schema>> & $ZodErrorTree<PlainArgs>>, payload: FormData]) => Promise<Flatten<InvalidState<$ZodErrorTree<z.output<Schema>> & $ZodErrorTree<PlainArgs>> | FailureState<TErr> | SuccessState<Data>>> : <Data>(action: Action<Data, Flatten<Context>, PlainArgs>) => (...args: [...PlainArgs, state: ActionState<Data, TErr, $ZodErrorTree<PlainArgs>>, payload: FormData]) => Promise<Flatten<InvalidState<$ZodErrorTree<PlainArgs>> | FailureState<TErr> | SuccessState<Data>>>;
|
|
72
|
+
/**
|
|
73
|
+
* A chainable context enhancing helper.
|
|
74
|
+
* @param middleware A function which receives the current context, and returns an object which will be added to the context.
|
|
75
|
+
* @returns FormActionBuilder
|
|
76
|
+
*/
|
|
77
|
+
use: <NewContext extends Record<string, unknown>>(middleware: ({ ctx }: {
|
|
78
|
+
ctx: Context;
|
|
79
|
+
}) => Promise<NewContext>) => FormActionBuilder<Schema, Args, TErr, Context & NewContext>;
|
|
80
|
+
/**
|
|
81
|
+
* A chainable error handler to handle errors thrown while running the action passed to .run().
|
|
82
|
+
* It does not receive errors thrown from the context/middleware.
|
|
83
|
+
* @param processError A function which receives action's errors.
|
|
84
|
+
* @returns FormActionBuilder
|
|
85
|
+
*/
|
|
86
|
+
error: <TErr>(processError: ErrorHandler<Context, TErr, PlainArgs>) => FormActionBuilder<Schema, Args, TErr, Context>;
|
|
87
|
+
};
|
|
88
|
+
declare const formAction: FormActionBuilder<typeof emptyInput, [], unknown, InitialContext, []>;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { FormAction as a, SuccessState as c, FailureState as i, createFormAction as l, formAction as n, InitialState as o, ActionState as r, InvalidState as s, Flatten as t, initial as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,66 +1,11 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { ZodObject,
|
|
3
|
-
import { ZodObject as ZodObject$1, z as z$1 } from "zod";
|
|
4
|
-
import { $ZodErrorTree, $ZodShape, $ZodType } from "zod/v4/core";
|
|
5
|
-
//#region src/formAction.d.ts
|
|
6
|
-
declare const emptyInput: unique symbol;
|
|
7
|
-
type EmptyInput = typeof emptyInput;
|
|
8
|
-
type Flatten<T> = Identity<{ [K in keyof T]: T[K]; }>;
|
|
9
|
-
type Identity<T> = T;
|
|
10
|
-
type ErrorHandler<Context, Err, Args> = (params: {
|
|
11
|
-
error: unknown;
|
|
12
|
-
ctx: Context;
|
|
13
|
-
args: Args;
|
|
14
|
-
}) => Promise<Err>;
|
|
15
|
-
type InitialContext = Record<"formData", FormData>;
|
|
16
|
-
/**
|
|
17
|
-
* Action without schema has no input.
|
|
18
|
-
*/
|
|
19
|
-
type Action<Data, Context, Args extends unknown[]> = (params: {
|
|
20
|
-
args: Args;
|
|
21
|
-
ctx: Context;
|
|
22
|
-
}) => Promise<Data>;
|
|
23
|
-
/**
|
|
24
|
-
* Action with schema will get parsed formData as the input.
|
|
25
|
-
*/
|
|
26
|
-
type SchemaAction<Data, Context, Args extends unknown[], Schema extends ZodType> = (params: {
|
|
27
|
-
args: Args;
|
|
28
|
-
ctx: Context;
|
|
29
|
-
input: z.output<Schema>;
|
|
30
|
-
}) => Promise<Data>;
|
|
31
|
-
type FormActionBuilder<Schema extends ZodType | EmptyInput, Args extends $ZodType[] = [], TErr = unknown, Context = InitialContext, PlainArgs extends unknown[] = z.output<ZodTuple<Args, null>>> = {
|
|
32
|
-
args: <T extends [$ZodType, ...$ZodType[]]>(args: T) => FormActionBuilder<Schema, [...Args, ...T], TErr, Context>;
|
|
33
|
-
input: <T extends ZodObject>(newInput: T extends ZodObject ? T : "The schema output must be an object.") => FormActionBuilder<Schema extends ZodObject<infer O1 extends $ZodShape> ? T extends ZodObject<infer O2 extends $ZodShape> ? ZodObject<O1 & O2> : never : T, Args, TErr, Context>;
|
|
34
|
-
/**
|
|
35
|
-
* A finishing call on the builder completing your action.
|
|
36
|
-
* @param action async function to execute. It will receive parsed formData as input, when the builder was initialized with a schema.
|
|
37
|
-
* @returns runnable server action exportable from a module.
|
|
38
|
-
*/
|
|
39
|
-
run: Schema extends ZodType ? <Data>(action: SchemaAction<Data, Flatten<Context>, PlainArgs, Schema>) => (...args: [...PlainArgs, state: ActionState<Data, TErr, $ZodErrorTree<z.output<Schema>> & $ZodErrorTree<PlainArgs>>, payload: FormData]) => Promise<Flatten<InvalidState<$ZodErrorTree<z.output<Schema>> & $ZodErrorTree<PlainArgs>> | FailureState<TErr> | SuccessState<Data>>> : <Data>(action: Action<Data, Flatten<Context>, PlainArgs>) => (...args: [...PlainArgs, state: ActionState<Data, TErr, $ZodErrorTree<PlainArgs>>, payload: FormData]) => Promise<Flatten<InvalidState<$ZodErrorTree<PlainArgs>> | FailureState<TErr> | SuccessState<Data>>>;
|
|
40
|
-
/**
|
|
41
|
-
* A chainable context enhancing helper.
|
|
42
|
-
* @param middleware A function which receives the current context, and returns an object which will be added to the context.
|
|
43
|
-
* @returns FormActionBuilder
|
|
44
|
-
*/
|
|
45
|
-
use: <NewContext extends Record<string, unknown>>(middleware: ({ ctx }: {
|
|
46
|
-
ctx: Context;
|
|
47
|
-
}) => Promise<NewContext>) => FormActionBuilder<Schema, Args, TErr, Context & NewContext>;
|
|
48
|
-
/**
|
|
49
|
-
* A chainable error handler to handle errors thrown while running the action passed to .run().
|
|
50
|
-
* It does not receive errors thrown from the context/middleware.
|
|
51
|
-
* @param processError A function which receives action's errors.
|
|
52
|
-
* @returns FormActionBuilder
|
|
53
|
-
*/
|
|
54
|
-
error: <TErr>(processError: ErrorHandler<Context, TErr, PlainArgs>) => FormActionBuilder<Schema, Args, TErr, Context>;
|
|
55
|
-
};
|
|
56
|
-
declare const formAction: FormActionBuilder<typeof emptyInput, [], unknown, InitialContext, []>;
|
|
57
|
-
//#endregion
|
|
1
|
+
import { a as FormAction, c as SuccessState, i as FailureState, l as createFormAction, n as formAction, o as InitialState, r as ActionState, s as InvalidState, t as Flatten, u as initial } from "./formAction-0eiUHrXx.mjs";
|
|
2
|
+
import { ZodObject, z } from "zod";
|
|
58
3
|
//#region src/validateSchema.d.ts
|
|
59
4
|
/**
|
|
60
5
|
* A helper to make a validate function for the client validation with <Action validate={} /> prop.
|
|
61
6
|
* @param schema z.object(...) schema
|
|
62
7
|
* @returns validate function
|
|
63
8
|
*/
|
|
64
|
-
declare function validateSchema<T extends ZodObject
|
|
9
|
+
declare function validateSchema<T extends ZodObject>(schema: T): (formData: FormData) => z.core.$ZodErrorTree<z.TypeOf<T>, string> | null;
|
|
65
10
|
//#endregion
|
|
66
|
-
export { ActionState, FailureState, FormAction, InitialState, InvalidState, SuccessState, createFormAction, formAction, initial, validateSchema };
|
|
11
|
+
export { ActionState, FailureState, Flatten, FormAction, InitialState, InvalidState, SuccessState, createFormAction, formAction, initial, validateSchema };
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region src/createFormAction.d.ts
|
|
2
|
-
type InitialState<T> = {
|
|
3
|
-
type: "initial";
|
|
4
|
-
data: T;
|
|
5
|
-
error: null;
|
|
6
|
-
validationError: null;
|
|
7
|
-
};
|
|
8
|
-
type InvalidState<T> = {
|
|
9
|
-
type: "invalid";
|
|
10
|
-
data: null;
|
|
11
|
-
error: null;
|
|
12
|
-
validationError: T;
|
|
13
|
-
};
|
|
14
|
-
type FailureState<T> = {
|
|
15
|
-
type: "failure";
|
|
16
|
-
data: null;
|
|
17
|
-
error: T;
|
|
18
|
-
validationError: null;
|
|
19
|
-
};
|
|
20
|
-
type SuccessState<T> = {
|
|
21
|
-
type: "success";
|
|
22
|
-
data: T;
|
|
23
|
-
error: null;
|
|
24
|
-
validationError: null;
|
|
25
|
-
};
|
|
26
|
-
type ActionState<Data, Error, ValidationError = Record<string, never>> = InitialState<Data> | InvalidState<ValidationError> | FailureState<Error> | SuccessState<Data>;
|
|
27
|
-
type FormAction<Data, Error = Data, ValidationError = Record<string, never>, Payload = FormData, Arguments extends unknown[] = []> = (...args: [...Arguments, state: ActionState<Data, Error, ValidationError>, payload: Payload]) => Promise<ActionState<Data, Error, ValidationError>>;
|
|
28
|
-
declare function initial<Data>(data: Data): InitialState<Data>;
|
|
29
|
-
declare function createFormAction<Data, Error = Data, ValidationError = Record<string, never>, Payload = FormData, Arguments extends [...unknown[]] = []>(formAction: (params: {
|
|
30
|
-
success: (data: Data) => SuccessState<Data>;
|
|
31
|
-
failure: (error: Error) => FailureState<Error>;
|
|
32
|
-
invalid: (validationError: ValidationError) => InvalidState<ValidationError>;
|
|
33
|
-
}, ...args: Arguments) => FormAction<Data, Error, ValidationError, Payload>): (...args: [...Arguments, state: ActionState<Data, Error, ValidationError>, payload: Payload]) => Promise<ActionState<Data, Error, ValidationError>>;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { InvalidState as a, initial as c, InitialState as i, FailureState as n, SuccessState as o, FormAction as r, createFormAction as s, ActionState as t };
|