hookform-action-standalone 4.0.1 → 4.0.3
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.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/use-action-form.ts"],"names":["useCallback","useActionFormCore"],"mappings":";;;;;AA2GO,SAAS,cAKd,OAAA,EACmE;AACnE,EAAA,MAAM,EAAE,MAAA,EAAQ,GAAG,WAAA,EAAY,GAAI,OAAA;AAGnC,EAAA,MAAM,QAAA,GAAkDA,iBAAA;AAAA,IACtD,OAAO,IAAA,KAAuB;AAC5B,MAAA,OAAO,OAAO,IAAI,CAAA;AAAA,IACpB,CAAA;AAAA,IACA,CAAC,MAAM;AAAA,GACT;AAEA,EAAA,OAAOC,oCAAA,CAAsD,UAAU,WAAW,CAAA;AACpF","file":"index.js","sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/use-action-form.ts"],"names":["useCallback","useActionFormCore"],"mappings":";;;;;AA2GO,SAAS,cAKd,OAAA,EACmE;AACnE,EAAA,MAAM,EAAE,MAAA,EAAQ,GAAG,WAAA,EAAY,GAAI,OAAA;AAGnC,EAAA,MAAM,QAAA,GAAkDA,iBAAA;AAAA,IACtD,OAAO,IAAA,KAAuB;AAC5B,MAAA,OAAO,OAAO,IAAI,CAAA;AAAA,IACpB,CAAA;AAAA,IACA,CAAC,MAAM;AAAA,GACT;AAEA,EAAA,OAAOC,oCAAA,CAAsD,UAAU,WAAW,CAAA;AACpF","file":"index.js","sourcesContent":["'use client'\n\nimport { useCallback } from 'react'\nimport type { FieldValues } from 'react-hook-form'\n\nimport {\n type ActionResult,\n type SubmitFunction,\n type UseActionFormCoreOptions,\n type UseActionFormCoreReturn,\n useActionFormCore,\n} from 'hookform-action-core'\n\n// ---------------------------------------------------------------------------\n// Standalone-specific types\n// ---------------------------------------------------------------------------\n\n/**\n * A generic async submit function provided by the user.\n * In standalone mode there are no Server Actions — the user provides\n * a plain async function (e.g. wrapping fetch, axios, etc.).\n */\nexport type StandaloneSubmitFunction<TFieldValues extends FieldValues, TResult> = (\n data: TFieldValues,\n) => Promise<TResult>\n\n/**\n * Options for `useActionForm` in standalone mode.\n * Identical to the core options but with `submit` as a required top-level option.\n */\nexport interface UseStandaloneActionFormOptions<\n TFieldValues extends FieldValues = FieldValues,\n TResult = ActionResult,\n TOptimistic = undefined,\n> extends UseActionFormCoreOptions<TFieldValues, TResult, TOptimistic> {\n /**\n * The async function that handles form submission.\n *\n * @example\n * ```ts\n * submit: async (data) => {\n * const res = await fetch('/api/submit', {\n * method: 'POST',\n * body: JSON.stringify(data),\n * headers: { 'Content-Type': 'application/json' },\n * })\n * return res.json()\n * }\n * ```\n */\n submit: StandaloneSubmitFunction<TFieldValues, TResult>\n}\n\n/**\n * Return type of `useActionForm` in standalone mode.\n * Same as core return (no `formAction` since there are no Server Actions).\n */\nexport type UseStandaloneActionFormReturn<\n TFieldValues extends FieldValues = FieldValues,\n TResult = ActionResult,\n TOptimistic = undefined,\n> = UseActionFormCoreReturn<TFieldValues, TResult, TOptimistic>\n\n// ---------------------------------------------------------------------------\n// useActionForm – Standalone adapter (v3)\n// ---------------------------------------------------------------------------\n\n/**\n * `useActionForm` for standalone React apps (Vite, Remix, Astro, SPAs).\n *\n * Provides the same API as the Next.js version but instead of a Server Action,\n * you pass a plain `submit` function.\n *\n * @example\n * ```tsx\n * import { useActionForm } from 'hookform-action-standalone'\n * import { z } from 'zod'\n *\n * const schema = z.object({\n * email: z.string().email(),\n * password: z.string().min(8),\n * })\n *\n * function LoginForm() {\n * const { register, handleSubmit, formState } = useActionForm({\n * submit: async (data) => {\n * const res = await fetch('/api/login', {\n * method: 'POST',\n * body: JSON.stringify(data),\n * headers: { 'Content-Type': 'application/json' },\n * })\n * return res.json()\n * },\n * schema,\n * validationMode: 'onChange',\n * })\n *\n * return (\n * <form onSubmit={handleSubmit()}>\n * <input {...register('email')} />\n * <input {...register('password')} type=\"password\" />\n * <button disabled={formState.isPending}>Login</button>\n * </form>\n * )\n * }\n * ```\n */\nexport function useActionForm<\n TFieldValues extends FieldValues = FieldValues,\n TResult = ActionResult,\n TOptimistic = undefined,\n>(\n options: UseStandaloneActionFormOptions<TFieldValues, TResult, TOptimistic>,\n): UseStandaloneActionFormReturn<TFieldValues, TResult, TOptimistic> {\n const { submit, ...coreOptions } = options\n\n // The submit function is already in the right shape for the core\n const submitFn: SubmitFunction<TFieldValues, TResult> = useCallback(\n async (data: TFieldValues) => {\n return submit(data)\n },\n [submit],\n )\n\n return useActionFormCore<TFieldValues, TResult, TOptimistic>(submitFn, coreOptions)\n}\n"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/use-action-form.ts"],"names":[],"mappings":";;;;AA2GO,SAAS,cAKd,OAAA,EACmE;AACnE,EAAA,MAAM,EAAE,MAAA,EAAQ,GAAG,WAAA,EAAY,GAAI,OAAA;AAGnC,EAAA,MAAM,QAAA,GAAkD,WAAA;AAAA,IACtD,OAAO,IAAA,KAAuB;AAC5B,MAAA,OAAO,OAAO,IAAI,CAAA;AAAA,IACpB,CAAA;AAAA,IACA,CAAC,MAAM;AAAA,GACT;AAEA,EAAA,OAAO,iBAAA,CAAsD,UAAU,WAAW,CAAA;AACpF","file":"index.mjs","sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/use-action-form.ts"],"names":[],"mappings":";;;;AA2GO,SAAS,cAKd,OAAA,EACmE;AACnE,EAAA,MAAM,EAAE,MAAA,EAAQ,GAAG,WAAA,EAAY,GAAI,OAAA;AAGnC,EAAA,MAAM,QAAA,GAAkD,WAAA;AAAA,IACtD,OAAO,IAAA,KAAuB;AAC5B,MAAA,OAAO,OAAO,IAAI,CAAA;AAAA,IACpB,CAAA;AAAA,IACA,CAAC,MAAM;AAAA,GACT;AAEA,EAAA,OAAO,iBAAA,CAAsD,UAAU,WAAW,CAAA;AACpF","file":"index.mjs","sourcesContent":["'use client'\n\nimport { useCallback } from 'react'\nimport type { FieldValues } from 'react-hook-form'\n\nimport {\n type ActionResult,\n type SubmitFunction,\n type UseActionFormCoreOptions,\n type UseActionFormCoreReturn,\n useActionFormCore,\n} from 'hookform-action-core'\n\n// ---------------------------------------------------------------------------\n// Standalone-specific types\n// ---------------------------------------------------------------------------\n\n/**\n * A generic async submit function provided by the user.\n * In standalone mode there are no Server Actions — the user provides\n * a plain async function (e.g. wrapping fetch, axios, etc.).\n */\nexport type StandaloneSubmitFunction<TFieldValues extends FieldValues, TResult> = (\n data: TFieldValues,\n) => Promise<TResult>\n\n/**\n * Options for `useActionForm` in standalone mode.\n * Identical to the core options but with `submit` as a required top-level option.\n */\nexport interface UseStandaloneActionFormOptions<\n TFieldValues extends FieldValues = FieldValues,\n TResult = ActionResult,\n TOptimistic = undefined,\n> extends UseActionFormCoreOptions<TFieldValues, TResult, TOptimistic> {\n /**\n * The async function that handles form submission.\n *\n * @example\n * ```ts\n * submit: async (data) => {\n * const res = await fetch('/api/submit', {\n * method: 'POST',\n * body: JSON.stringify(data),\n * headers: { 'Content-Type': 'application/json' },\n * })\n * return res.json()\n * }\n * ```\n */\n submit: StandaloneSubmitFunction<TFieldValues, TResult>\n}\n\n/**\n * Return type of `useActionForm` in standalone mode.\n * Same as core return (no `formAction` since there are no Server Actions).\n */\nexport type UseStandaloneActionFormReturn<\n TFieldValues extends FieldValues = FieldValues,\n TResult = ActionResult,\n TOptimistic = undefined,\n> = UseActionFormCoreReturn<TFieldValues, TResult, TOptimistic>\n\n// ---------------------------------------------------------------------------\n// useActionForm – Standalone adapter (v3)\n// ---------------------------------------------------------------------------\n\n/**\n * `useActionForm` for standalone React apps (Vite, Remix, Astro, SPAs).\n *\n * Provides the same API as the Next.js version but instead of a Server Action,\n * you pass a plain `submit` function.\n *\n * @example\n * ```tsx\n * import { useActionForm } from 'hookform-action-standalone'\n * import { z } from 'zod'\n *\n * const schema = z.object({\n * email: z.string().email(),\n * password: z.string().min(8),\n * })\n *\n * function LoginForm() {\n * const { register, handleSubmit, formState } = useActionForm({\n * submit: async (data) => {\n * const res = await fetch('/api/login', {\n * method: 'POST',\n * body: JSON.stringify(data),\n * headers: { 'Content-Type': 'application/json' },\n * })\n * return res.json()\n * },\n * schema,\n * validationMode: 'onChange',\n * })\n *\n * return (\n * <form onSubmit={handleSubmit()}>\n * <input {...register('email')} />\n * <input {...register('password')} type=\"password\" />\n * <button disabled={formState.isPending}>Login</button>\n * </form>\n * )\n * }\n * ```\n */\nexport function useActionForm<\n TFieldValues extends FieldValues = FieldValues,\n TResult = ActionResult,\n TOptimistic = undefined,\n>(\n options: UseStandaloneActionFormOptions<TFieldValues, TResult, TOptimistic>,\n): UseStandaloneActionFormReturn<TFieldValues, TResult, TOptimistic> {\n const { submit, ...coreOptions } = options\n\n // The submit function is already in the right shape for the core\n const submitFn: SubmitFunction<TFieldValues, TResult> = useCallback(\n async (data: TFieldValues) => {\n return submit(data)\n },\n [submit],\n )\n\n return useActionFormCore<TFieldValues, TResult, TOptimistic>(submitFn, coreOptions)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hookform-action-standalone",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Standalone React adapter for hookform-action – use the same API without Next.js (Vite, Remix, Astro, SPAs).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"hookform-action-core": "4.0.
|
|
45
|
+
"hookform-action-core": "4.0.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "^18.0.0 || ^19.0.0",
|