server-act 1.5.3 → 1.6.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/README.md CHANGED
@@ -111,7 +111,7 @@ export const sayHelloAction = serverAct
111
111
  ),
112
112
  }),
113
113
  )
114
- .formAction(async ({ formData, input, formErrors, ctx }) => {
114
+ .stateAction(async ({ formData, input, formErrors, ctx }) => {
115
115
  if (formErrors) {
116
116
  return { formData, formErrors: formErrors.fieldErrors };
117
117
  }
package/dist/index.d.mts CHANGED
@@ -47,7 +47,7 @@ interface ActionBuilder<TParams extends ActionParams> {
47
47
  /**
48
48
  * Create an action for React `useActionState`
49
49
  */
50
- formAction: <TState, TPrevState = UnsetMarker>(action: (params: Prettify<{
50
+ stateAction: <TState, TPrevState = UnsetMarker>(action: (params: Prettify<{
51
51
  ctx: InferContextType<TParams["_context"]>;
52
52
  prevState: RemoveUnsetMarker<TPrevState>;
53
53
  formData: FormData;
package/dist/index.d.ts CHANGED
@@ -47,7 +47,7 @@ interface ActionBuilder<TParams extends ActionParams> {
47
47
  /**
48
48
  * Create an action for React `useActionState`
49
49
  */
50
- formAction: <TState, TPrevState = UnsetMarker>(action: (params: Prettify<{
50
+ stateAction: <TState, TPrevState = UnsetMarker>(action: (params: Prettify<{
51
51
  ctx: InferContextType<TParams["_context"]>;
52
52
  prevState: RemoveUnsetMarker<TPrevState>;
53
53
  formData: FormData;
package/dist/index.js CHANGED
@@ -83,7 +83,7 @@ function createServerActionBuilder(initDef = {}) {
83
83
  });
84
84
  };
85
85
  },
86
- formAction: (action) => {
86
+ stateAction: (action) => {
87
87
  return async (prevState, formData) => {
88
88
  const ctx = await _def.middleware?.();
89
89
  if (_def.input) {
package/dist/index.mjs CHANGED
@@ -60,7 +60,7 @@ function createServerActionBuilder(initDef = {}) {
60
60
  });
61
61
  };
62
62
  },
63
- formAction: (action) => {
63
+ stateAction: (action) => {
64
64
  return async (prevState, formData) => {
65
65
  const ctx = await _def.middleware?.();
66
66
  if (_def.input) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "server-act",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
4
4
  "homepage": "https://github.com/chungweileong94/server-act#readme",
5
5
  "author": "chungweileong94",
6
6
  "license": "MIT",