next-safe-form 1.0.6 → 1.0.7
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/index.cjs +21 -25
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
|
|
3
1
|
"use strict";
|
|
4
2
|
var __create = Object.create;
|
|
5
3
|
var __defProp = Object.defineProperty;
|
|
@@ -8,41 +6,40 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
8
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
8
|
var __export = (target, all) => {
|
|
11
|
-
for (var name in all)
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
11
|
};
|
|
13
12
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
14
|
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
mod
|
|
29
|
-
)
|
|
30
|
-
);
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
30
|
// src/index.ts
|
|
34
31
|
var index_exports = {};
|
|
35
32
|
__export(index_exports, {
|
|
36
|
-
|
|
33
|
+
useSafeActionForm: () => use_action_form_default
|
|
37
34
|
});
|
|
38
35
|
module.exports = __toCommonJS(index_exports);
|
|
39
36
|
|
|
40
37
|
// src/hooks/use-action-form.ts
|
|
41
38
|
var import_react = __toESM(require("react"), 1);
|
|
42
|
-
function
|
|
39
|
+
function useSafeActionForm({ action, initialValues, onSuccess, onError }) {
|
|
43
40
|
const [state, formAction, isPending] = import_react.default.useActionState(action, {
|
|
44
41
|
success: false,
|
|
45
|
-
data: initialValues
|
|
42
|
+
data: initialValues
|
|
46
43
|
});
|
|
47
44
|
const [fieldsErrors, setFieldsErrors] = import_react.default.useState(void 0);
|
|
48
45
|
const [serverError, setServerError] = import_react.default.useState(void 0);
|
|
@@ -74,12 +71,11 @@ function useActionForm({ action, initialValues, onSuccess, onError }) {
|
|
|
74
71
|
serverError,
|
|
75
72
|
data,
|
|
76
73
|
isSuccess: state?.success ?? false,
|
|
77
|
-
reset
|
|
74
|
+
reset
|
|
78
75
|
};
|
|
79
76
|
}
|
|
80
|
-
var use_action_form_default =
|
|
77
|
+
var use_action_form_default = useSafeActionForm;
|
|
81
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
-
0 &&
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
useSafeActionForm
|
|
81
|
+
});
|
package/dist/index.d.cts
CHANGED
|
@@ -21,7 +21,7 @@ interface UseActionFormOptions<T> {
|
|
|
21
21
|
* @format
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
declare function
|
|
24
|
+
declare function useSafeActionForm<T>({ action, initialValues, onSuccess, onError }: UseActionFormOptions<T>): {
|
|
25
25
|
formAction: (payload: FormData) => void;
|
|
26
26
|
isPending: boolean;
|
|
27
27
|
fieldsErrors: Record<string, string> | undefined;
|
|
@@ -31,4 +31,4 @@ declare function useActionForm<T>({ action, initialValues, onSuccess, onError }:
|
|
|
31
31
|
reset: () => void;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export { type TSafeActionResult,
|
|
34
|
+
export { type TSafeActionResult, useSafeActionForm };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ interface UseActionFormOptions<T> {
|
|
|
21
21
|
* @format
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
declare function
|
|
24
|
+
declare function useSafeActionForm<T>({ action, initialValues, onSuccess, onError }: UseActionFormOptions<T>): {
|
|
25
25
|
formAction: (payload: FormData) => void;
|
|
26
26
|
isPending: boolean;
|
|
27
27
|
fieldsErrors: Record<string, string> | undefined;
|
|
@@ -31,4 +31,4 @@ declare function useActionForm<T>({ action, initialValues, onSuccess, onError }:
|
|
|
31
31
|
reset: () => void;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export { type TSafeActionResult,
|
|
34
|
+
export { type TSafeActionResult, useSafeActionForm };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
|
|
3
1
|
// src/hooks/use-action-form.ts
|
|
4
2
|
import React from "react";
|
|
5
|
-
function
|
|
3
|
+
function useSafeActionForm({ action, initialValues, onSuccess, onError }) {
|
|
6
4
|
const [state, formAction, isPending] = React.useActionState(action, {
|
|
7
5
|
success: false,
|
|
8
|
-
data: initialValues
|
|
6
|
+
data: initialValues
|
|
9
7
|
});
|
|
10
8
|
const [fieldsErrors, setFieldsErrors] = React.useState(void 0);
|
|
11
9
|
const [serverError, setServerError] = React.useState(void 0);
|
|
@@ -37,8 +35,10 @@ function useActionForm({ action, initialValues, onSuccess, onError }) {
|
|
|
37
35
|
serverError,
|
|
38
36
|
data,
|
|
39
37
|
isSuccess: state?.success ?? false,
|
|
40
|
-
reset
|
|
38
|
+
reset
|
|
41
39
|
};
|
|
42
40
|
}
|
|
43
|
-
var use_action_form_default =
|
|
44
|
-
export {
|
|
41
|
+
var use_action_form_default = useSafeActionForm;
|
|
42
|
+
export {
|
|
43
|
+
use_action_form_default as useSafeActionForm
|
|
44
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-safe-form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Simplify React 19 Server Actions forms in Next.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
33
33
|
"publish-public": "npm publish --access public",
|
|
34
34
|
"publish-private": "npm publish --access restricted",
|
|
35
|
-
"patch": "npm version patch && npm publish --access public",
|
|
36
|
-
"minor": "npm version minor && npm publish --access public",
|
|
37
|
-
"major": "npm version major && npm publish --access public"
|
|
35
|
+
"patch": "npm version patch && bun run build && npm publish --access public",
|
|
36
|
+
"minor": "npm version minor && bun run build && npm publish --access public",
|
|
37
|
+
"major": "npm version major && bun run build && npm publish --access public"
|
|
38
38
|
}
|
|
39
39
|
}
|