@fluixi/forms 1.0.0-alpha.109 → 1.0.0-alpha.111

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/llms.txt +53 -0
  2. package/package.json +7 -6
package/llms.txt ADDED
@@ -0,0 +1,53 @@
1
+ # Fluixi Forms
2
+
3
+ > @fluixi/forms is the form library for Fluixi: every field is its own reactive cell, with sync and
4
+ > async validation, groups, arrays, and schema validators (Standard Schema, Zod, Valibot).
5
+
6
+ The framework rules come first: https://docs.fluixi.com/llms.txt. For the form components
7
+ (`Form`, `FormField`, inputs), read https://ui.fluixi.com/llms.txt.
8
+
9
+ ## Rules for writing forms
10
+
11
+ ### State and validation
12
+
13
+ - Build the form with `createForm({ ... })` and `createField(initial, { validators })`, imported
14
+ from `@fluixi/forms`. Do not hold form state in hand-made signals.
15
+ - Validate with a schema: `standardValidator(schema)` takes any Standard Schema (Zod 4, Valibot,
16
+ ArkType), on a field or on the whole form; its first issue becomes the error. An async schema
17
+ goes in `asyncValidators` through `standardAsyncValidator(schema)`. `fromZod(schema)` builds a
18
+ typed form from a Zod object, one field per key.
19
+ - Built-in validators: `required()`, `email()`, `minLength(n)`, `sameAs('otherField', message)`.
20
+ - Async validators take `(value, ctx, signal)`; pass `signal` to `fetch` so a stale check is
21
+ aborted. `debounce: 300` on the field spaces them out; `field.pending()` is true while one runs.
22
+ - Reads are signals: `form.get('email').value()`, `.valid()`, `.error()`, `.touched()`;
23
+ `form.valid()` for the whole form.
24
+ - `field.setValue(v)` marks the field touched, so its error shows at once. To prefill or clear a
25
+ form, use `field.reset(v)`.
26
+ - `createField` widens a literal start value: `createField('fr')` is a `string` field. Narrow at
27
+ submit.
28
+ - Lists of fields: `createFormArray([...])` with `push`, `move`, `removeAt`.
29
+ - Schemas live with the app's shared types, not in the route file. Messages are i18n keys,
30
+ translated where they are shown.
31
+
32
+ ### Rendering and submitting
33
+
34
+ - Render with `Form` and `FormField` from `@fluixi-ui/form`, and the inputs from `@fluixi-ui/*`:
35
+
36
+ ```tsx
37
+ <Form form={form} action={signUp} novalidate>
38
+ <FormField control={form.get('email')} label="Email">
39
+ {(b) => <Input type="email" name="email" value={b.value()} onInput={b.onInput} onBlur={b.onBlur} />}
40
+ </FormField>
41
+ </Form>
42
+ ```
43
+
44
+ - `Form` validates first, then calls its `action` (a router `action(fn, 'name')`) with the checked
45
+ values only, and keeps `method="post"` and the action URL so the form also works without
46
+ script. Use `onSubmit` for a plain async function. Read pending and error state with
47
+ `useSubmission`.
48
+ - The router's `ActionForm` posts the fields as they are, unchecked: use it only when nothing
49
+ needs validating.
50
+ - Without fluixi-ui, `Field` and `bindField` from `@fluixi/forms` give the same bindings
51
+ (`value`, `onInput`, `onBlur`, `aria-invalid`).
52
+ - A server refusal is thrown as an i18n key (`new Error('auth.error.tooMany')`) and shown like a
53
+ validation error.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluixi/forms",
3
- "version": "1.0.0-alpha.109",
3
+ "version": "1.0.0-alpha.111",
4
4
  "license": "MIT",
5
5
  "description": "Umbrella package — re-exports all @fluixi/forms-* packages (core, framework, zod, valibot, devtools).",
6
6
  "type": "module",
@@ -35,15 +35,16 @@
35
35
  },
36
36
  "files": [
37
37
  "README.md",
38
+ "llms.txt",
38
39
  "dist",
39
40
  "LICENSE"
40
41
  ],
41
42
  "dependencies": {
42
- "@fluixi/forms-core": "1.0.0-alpha.109",
43
- "@fluixi/forms-framework": "1.0.0-alpha.109",
44
- "@fluixi/forms-zod": "1.0.0-alpha.109",
45
- "@fluixi/forms-valibot": "1.0.0-alpha.109",
46
- "@fluixi/forms-devtools": "1.0.0-alpha.109"
43
+ "@fluixi/forms-core": "1.0.0-alpha.111",
44
+ "@fluixi/forms-framework": "1.0.0-alpha.111",
45
+ "@fluixi/forms-zod": "1.0.0-alpha.111",
46
+ "@fluixi/forms-valibot": "1.0.0-alpha.111",
47
+ "@fluixi/forms-devtools": "1.0.0-alpha.111"
47
48
  },
48
49
  "publishConfig": {
49
50
  "registry": "https://registry.npmjs.org/",