@behivetech/forms.form-field-managed 0.1.5 → 0.1.6
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 +2 -0
- package/docs.json +77 -0
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
`FormField` with its react-hook-form wiring already done — the control's
|
|
4
4
|
value/onChange/onBlur/ref, the label association, and the error message.
|
|
5
5
|
|
|
6
|
+
Docs: https://bht-galaxy.vercel.app/behivetech/forms/form-field-managed
|
|
7
|
+
|
|
6
8
|
Use plain [`FormField`](../form-field) when you are managing state yourself;
|
|
7
9
|
use this when the field belongs to a react-hook-form form.
|
|
8
10
|
|
package/docs.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"generatedAt": "2026-10-23T19:01:35.918Z",
|
|
5
|
+
"docs": [
|
|
6
|
+
{
|
|
7
|
+
"displayName": "FormFieldManaged",
|
|
8
|
+
"description": "`FormField` with its react-hook-form wiring already done: the control's\nvalue/onChange/onBlur/ref, the label association, and the error message.\n\nUses `useController` rather than `register` because `register` only works on\ncontrols that render a native input. `TextField` and `Textarea` do;\n`Checkbox`, `Toggle` and `Select` are Radix-backed, where the ref would land\non the trigger button and the change callback is `onCheckedChange` /\n`onValueChange`, so `register` binds nothing and the field silently keeps its\ndefault. `useController` works for all of them.\n\nThe control is supplied through a render prop rather than cloned, because the\nprop a control listens on is the one thing that genuinely differs between\nthem — worth seeing at the call site, and impossible to type if hidden.\n\nPass `control` and both type parameters infer, so `field.value` is the type\nof that one field and spreads onto a control without a cast:\n\n```tsx\n<FormFieldManaged control={methods.control} name=\"email\" label=\"Email\">\n {(field) => <TextField {...field} />}\n</FormFieldManaged>\n```\n\nTaking `control` from context instead means naming both parameters. Supplying\nonly the first — `<FormFieldManaged<Values> name=\"email\">` — leaves `TName` at\nits default and widens `field.value` to a union of every field in the form,\nbecause TypeScript stops inferring the rest once any type argument is given\nexplicitly:\n\n```tsx\n<FormFieldManaged<Values, \"email\"> name=\"email\" label=\"Email\">\n {(field) => <TextField {...field} />}\n</FormFieldManaged>\n```",
|
|
9
|
+
"extendsNative": true,
|
|
10
|
+
"props": [
|
|
11
|
+
{
|
|
12
|
+
"name": "children",
|
|
13
|
+
"type": "(field: ManagedField<TFieldValues, TName>, fieldState: ControllerFieldState) => ReactNode",
|
|
14
|
+
"required": true,
|
|
15
|
+
"defaultValue": null,
|
|
16
|
+
"description": "Renders the control from the wired field"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "name",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"required": true,
|
|
22
|
+
"defaultValue": null,
|
|
23
|
+
"description": "Field path in the form values; infers the field's value type"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "className",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"required": false,
|
|
29
|
+
"defaultValue": null,
|
|
30
|
+
"description": "Additional class names to merge with the component root element"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "control",
|
|
34
|
+
"type": "Control<TFieldValues>",
|
|
35
|
+
"required": false,
|
|
36
|
+
"defaultValue": null,
|
|
37
|
+
"description": "Form control; falls back to the surrounding `useFormContext()` when omitted"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "hint",
|
|
41
|
+
"type": "ReactNode",
|
|
42
|
+
"required": false,
|
|
43
|
+
"defaultValue": null,
|
|
44
|
+
"description": "Supporting hint text; hidden while `error` is present"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "label",
|
|
48
|
+
"type": "ReactNode",
|
|
49
|
+
"required": false,
|
|
50
|
+
"defaultValue": null,
|
|
51
|
+
"description": "Field label"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "required",
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"required": false,
|
|
57
|
+
"defaultValue": null,
|
|
58
|
+
"description": "Shows a required marker next to the label"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "rules",
|
|
62
|
+
"type": "RegisterOptions<TFieldValues, TName>",
|
|
63
|
+
"required": false,
|
|
64
|
+
"defaultValue": null,
|
|
65
|
+
"description": "Validation rules passed through to react-hook-form"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"displayName": "PartialArgsStillWiden",
|
|
71
|
+
"description": "Supplying only `TFieldValues` leaves `TName` at its default, so `value` stays\nthe union — TypeScript stops inferring the remaining parameters as soon as\none is given explicitly. This is a language rule, not something the component\ncan type its way around, which is why the docstring steers callers to\n`control` or to naming both arguments.\n\nThe expected error is the guard: if a future TypeScript infers partial type\narguments, this line stops erroring and the comment above needs revisiting.",
|
|
72
|
+
"extendsNative": false,
|
|
73
|
+
"props": []
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"functions": []
|
|
77
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behivetech/forms.form-field-managed",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"description": "`FormField` with its react-hook-form wiring already done — the control's value/onChange/onBlur/ref, the label association, and the error message.",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"private": false,
|
|
7
8
|
"exports": {
|
|
@@ -25,8 +26,8 @@
|
|
|
25
26
|
"tags": []
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@behivetech/forms.form-field": "0.3.
|
|
29
|
-
"@behivetech/forms.form-provider": "0.1.
|
|
29
|
+
"@behivetech/forms.form-field": "0.3.4",
|
|
30
|
+
"@behivetech/forms.form-provider": "0.1.6"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
33
|
"react": "^19.2.7",
|
|
@@ -39,9 +40,9 @@
|
|
|
39
40
|
"tsup": "^8.5.1",
|
|
40
41
|
"typescript": "^6.0.3",
|
|
41
42
|
"vitest": "^4.1.10",
|
|
42
|
-
"@behivetech/atoms.select": "0.4.
|
|
43
|
-
"@behivetech/atoms.text-field": "0.3.
|
|
44
|
-
"@behivetech/atoms.toggle": "0.4.
|
|
43
|
+
"@behivetech/atoms.select": "0.4.4",
|
|
44
|
+
"@behivetech/atoms.text-field": "0.3.4",
|
|
45
|
+
"@behivetech/atoms.toggle": "0.4.4",
|
|
45
46
|
"@bht-component-registry/env": "0.1.0"
|
|
46
47
|
},
|
|
47
48
|
"repository": {
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"url": "https://github.com/behivetech/bht-galaxy.git",
|
|
50
51
|
"directory": "registry/behivetech/forms/form-field-managed"
|
|
51
52
|
},
|
|
53
|
+
"homepage": "https://bht-galaxy.vercel.app/behivetech/forms/form-field-managed",
|
|
52
54
|
"publishConfig": {
|
|
53
55
|
"registry": "https://registry.npmjs.org",
|
|
54
56
|
"access": "public",
|