@native-form/core 0.1.2 → 0.1.4

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.
Files changed (2) hide show
  1. package/README.md +54 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -160,6 +160,60 @@ Attach `@native-form/core` via Svelte's `onMount` or action directive:
160
160
 
161
161
  ---
162
162
 
163
+ ### 4. React (React 18 & 19)
164
+
165
+ For React applications, use the official [`@native-form/react`](../react/README.md) package:
166
+
167
+ ```bash
168
+ npm install @native-form/react
169
+ ```
170
+
171
+ ```tsx
172
+ import React from "react";
173
+ import { useForm } from "@native-form/react";
174
+ import { zodResolver } from "@native-form/zod";
175
+ import { z } from "zod";
176
+
177
+ const schema = z.object({
178
+ email: z.string().email("Enter a valid email"),
179
+ age: z.number().min(18, "Must be at least 18"),
180
+ });
181
+
182
+ export function LoginForm() {
183
+ const { formRef, formState } = useForm({
184
+ schema: zodResolver(schema),
185
+ serializationMode: "typed", // automatically coerces type="number" and range to numbers
186
+ onSubmit: (values) => console.log("Submitted:", values),
187
+ });
188
+
189
+ return (
190
+ <form ref={formRef} noValidate>
191
+ <div>
192
+ <label>Email</label>
193
+ <input name="email" type="email" placeholder="jane@example.com" />
194
+ {formState.errors.email && (
195
+ <p style={{ color: "red" }}>{formState.errors.email}</p>
196
+ )}
197
+ </div>
198
+
199
+ <div>
200
+ <label>Age</label>
201
+ <input name="age" type="number" placeholder="25" />
202
+ {formState.errors.age && (
203
+ <p style={{ color: "red" }}>{formState.errors.age}</p>
204
+ )}
205
+ </div>
206
+
207
+ <button type="submit" disabled={formState.submitting}>
208
+ {formState.submitting ? "Submitting..." : "Submit"}
209
+ </button>
210
+ </form>
211
+ );
212
+ }
213
+ ```
214
+
215
+ ---
216
+
163
217
  ## Configuration Options
164
218
 
165
219
  When instantiating `new Runtime(options)`, the following options are available:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-form/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Framework-agnostic native HTML-first form runtime, discovery, and validation contracts.",
5
5
  "license": "MIT",
6
6
  "type": "module",