react-form-action 1.2.0 → 1.2.1
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/README.md +1 -1
- package/dist/client.d.mts +14 -1
- package/dist/client.mjs +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
package/dist/client.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import React__default, { FormHTMLAttributes } from 'react';
|
|
|
3
3
|
import { RenderProp } from 'react-render-prop-type';
|
|
4
4
|
import { F as FormState, b as InitialState, I as InvalidState, a as FailureState, S as SuccessState } from './createFormAction-3a51310f.js';
|
|
5
5
|
import { useFormStatus } from 'react-dom';
|
|
6
|
+
import { ZodFormattedError } from 'zod';
|
|
6
7
|
|
|
7
8
|
type FormStateProps<Data, Error, ValidationError, Payload> = {
|
|
8
9
|
action: (state: FormState<Data, Error, ValidationError>, payload: Payload) => Promise<FormState<Data, Error, ValidationError>>;
|
|
@@ -24,4 +25,16 @@ declare function Form<Data, Error, ValidationError>({ children, action, initialD
|
|
|
24
25
|
|
|
25
26
|
declare function FormStatus({ children, }: RenderProp<ReturnType<typeof useFormStatus>>): React.ReactNode;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
declare const SEPARATOR: ".";
|
|
29
|
+
type Paths<Err extends object> = {
|
|
30
|
+
[k in keyof Err]: k extends string ? Err[k] extends object ? `${k}${typeof SEPARATOR}${Paths<Err[k]>}` : k : never;
|
|
31
|
+
}[keyof Err];
|
|
32
|
+
type ZodFieldErrorProps<Errors extends ZodFormattedError<any>> = Errors extends ZodFormattedError<infer E extends object> ? {
|
|
33
|
+
errors: Errors;
|
|
34
|
+
name?: "" | Paths<E>;
|
|
35
|
+
} & Partial<RenderProp<{
|
|
36
|
+
errors: readonly string[];
|
|
37
|
+
}>> : any;
|
|
38
|
+
declare function ZodFieldError<Errors extends ZodFormattedError<any>>({ errors, name, children, }: ZodFieldErrorProps<Errors>): React__default.ReactNode;
|
|
39
|
+
|
|
40
|
+
export { Form, FormProps, FormStateProps, FormStatus, ZodFieldError, ZodFieldErrorProps, initial };
|
package/dist/client.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import
|
|
1
|
+
"use client";import l from"react";import{useActionState as F}from"react";import{useFormStatus as c}from"react-dom";function s({children:t}){return t(c())}function f(t){return{type:"initial",data:t,error:null,validationError:null}}var i={isInitial:!1,isInvalid:!1,isFailure:!1,isSuccess:!1};function T({children:t,action:a,initialData:n,permalink:e,...o}){let[r,m]=F(a,f(n),e),d=r.type==="initial"?{...r,...i,isInitial:!0}:r.type==="invalid"?{...r,...i,isInvalid:!0}:r.type==="failure"?{...r,...i,isFailure:!0}:{...r,...i,isSuccess:!0};return l.createElement("form",{action:m,...o},l.createElement(s,null,({pending:u})=>t({...d,isPending:u})))}import p from"react";var E=".",S=Object.freeze({_errors:Object.freeze([])});function v({errors:t,name:a="",children:n=({errors:e})=>p.createElement(p.Fragment,null,e[0])}){if(a.length===0)return n({errors:t._errors});let e=a.split(E),o=t;for(;e.length;){let r=e.shift();o=o[r]??S}return n({errors:o._errors})}export{T as Form,s as FormStatus,v as ZodFieldError,f as initial};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-form-action",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "State management helpers for the react form actions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"@types/react-dom": "^19.0.1",
|
|
59
59
|
"@vitejs/plugin-react": "^4.3.4",
|
|
60
60
|
"happy-dom": "^15.11.7",
|
|
61
|
-
"next": "^14.0.2",
|
|
62
61
|
"npm-check-updates": "^17.1.11",
|
|
63
62
|
"prettier": "^3.3.3",
|
|
64
63
|
"react": "^19.0.0",
|