@beignet/react-hook-form 0.0.52 → 0.0.54

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @beignet/react-hook-form
2
2
 
3
+ ## 0.0.54
4
+
5
+ ## 0.0.53
6
+
7
+ ### Patch Changes
8
+
9
+ - a05562d: Align form and provider documentation with the generated starter's contracts, cache invalidation, and existing server wiring.
10
+
3
11
  ## 0.0.52
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -35,6 +35,10 @@ boundaries, or field/server error mapping in a Beignet app.
35
35
 
36
36
  ### Basic form
37
37
 
38
+ These examples use the Todos contracts from the Beignet starter. Create accepts
39
+ `title`; completion belongs to the update contract. For a working form with
40
+ verification steps, follow the [form guide](https://beignetjs.com/react-hook-form).
41
+
38
42
  ```tsx
39
43
  "use client";
40
44
 
@@ -48,12 +52,11 @@ function CreateTodoForm() {
48
52
  const form = useForm({
49
53
  defaultValues: {
50
54
  title: "",
51
- completed: false,
52
55
  },
53
56
  });
54
57
 
55
58
  const onSubmit = form.handleSubmit((values) => {
56
- // values is the parsed schema output: { title: string; completed?: boolean }
59
+ // values is the parsed schema output: { title: string }
57
60
  console.log("Creating todo:", values);
58
61
  });
59
62
 
@@ -67,11 +70,6 @@ function CreateTodoForm() {
67
70
  <p className="error">{form.formState.errors.title.message}</p>
68
71
  )}
69
72
 
70
- <label>
71
- <input type="checkbox" {...form.register("completed")} />
72
- Completed
73
- </label>
74
-
75
73
  <button type="submit" disabled={form.formState.isSubmitting}>
76
74
  Create Todo
77
75
  </button>
@@ -88,7 +86,7 @@ function CreateTodoForm() {
88
86
  import { createReactHookForm, rootFormError } from "@beignet/react-hook-form";
89
87
  import { useMutation } from "@tanstack/react-query";
90
88
  import { rq } from "@/client";
91
- import { createTodo } from "@/features/todos/contracts";
89
+ import { createTodo, listTodos } from "@/features/todos/contracts";
92
90
 
93
91
  const rhf = createReactHookForm();
94
92
 
@@ -100,6 +98,7 @@ function CreateTodoForm() {
100
98
 
101
99
  const mutation = useMutation(
102
100
  rq(createTodo).mutationOptions({
101
+ invalidates: () => [rq(listTodos).contractFilter()],
103
102
  onSuccess: () => form.reset(),
104
103
  onError: (error) => {
105
104
  form.setError("root", rootFormError(error, "Could not create the todo."));
@@ -114,7 +113,7 @@ function CreateTodoForm() {
114
113
 
115
114
  return (
116
115
  <form onSubmit={onSubmit}>
117
- <input {...form.register("title")} placeholder="Title" />
116
+ <input {...form.register("title")} placeholder="Title" readOnly={mutation.isPending} />
118
117
  {form.formState.errors.title && (
119
118
  <p>{form.formState.errors.title.message}</p>
120
119
  )}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beignet/react-hook-form",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "type": "module",
5
5
  "description": "React Hook Form integration for Beignet with Standard Schema support",
6
6
  "main": "./dist/index.js",