@behivetech/forms.form-field-managed 1.0.1 → 1.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/docs.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
3
3
  "version": 2,
4
- "generatedAt": "2026-11-26T05:48:56.127Z",
4
+ "generatedAt": "2026-11-30T23:24:20.096Z",
5
5
  "docs": [
6
6
  {
7
7
  "displayName": "FormFieldManaged",
@@ -5,6 +5,9 @@ import { Toggle } from "@behivetech/atoms.toggle";
5
5
  import { Form, useForm } from "@behivetech/forms.form-provider";
6
6
  import { FormFieldManaged } from "./form-field-managed.js";
7
7
 
8
+ /** `Form` is a bare `<form>`: an example puts the space between its fields on the element. */
9
+ const FORM_LAYOUT = { display: "grid", gap: "1rem" } as const;
10
+
8
11
  interface DemoValues {
9
12
  email: string;
10
13
  role: string;
@@ -27,6 +30,10 @@ const ROLES = [
27
30
  * works too, but then the field type has to be named — `<FormFieldManaged<
28
31
  * DemoValues, "email">` — because supplying one type argument stops TypeScript
29
32
  * inferring the other.
33
+ *
34
+ * The render prop's second argument is the field's state: each control takes
35
+ * `invalid` from it, so a field that fails its rule shows the error color and
36
+ * is announced as invalid, beside the message the field prints.
30
37
  */
31
38
  export const ManagedForm = () => {
32
39
  const methods = useForm<DemoValues>({
@@ -34,7 +41,11 @@ export const ManagedForm = () => {
34
41
  });
35
42
 
36
43
  return (
37
- <Form methods={methods} onSubmit={(values) => console.log(values)}>
44
+ <Form
45
+ methods={methods}
46
+ onSubmit={(values) => console.log(values)}
47
+ style={FORM_LAYOUT}
48
+ >
38
49
  <FormFieldManaged
39
50
  control={methods.control}
40
51
  name="email"
@@ -43,7 +54,9 @@ export const ManagedForm = () => {
43
54
  required
44
55
  rules={{ required: "Email is required" }}
45
56
  >
46
- {(field) => <TextField {...field} type="email" />}
57
+ {(field, fieldState) => (
58
+ <TextField {...field} type="email" invalid={fieldState.invalid} />
59
+ )}
47
60
  </FormFieldManaged>
48
61
 
49
62
  <FormFieldManaged
@@ -52,7 +65,7 @@ export const ManagedForm = () => {
52
65
  label="Role"
53
66
  rules={{ required: "Pick a role" }}
54
67
  >
55
- {(field) => (
68
+ {(field, fieldState) => (
56
69
  <Select
57
70
  id={field.id}
58
71
  name={field.name}
@@ -60,6 +73,7 @@ export const ManagedForm = () => {
60
73
  value={field.value}
61
74
  onValueChange={field.onChange}
62
75
  placeholder="Pick one"
76
+ invalid={fieldState.invalid}
63
77
  />
64
78
  )}
65
79
  </FormFieldManaged>
@@ -75,9 +89,11 @@ export const ManagedForm = () => {
75
89
  )}
76
90
  </FormFieldManaged>
77
91
 
78
- <Button type="submit" variant="primary" size="sm">
79
- Save
80
- </Button>
92
+ <div>
93
+ <Button type="submit" variant="primary" size="sm">
94
+ Save
95
+ </Button>
96
+ </div>
81
97
  </Form>
82
98
  );
83
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behivetech/forms.form-field-managed",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "license": "MIT",
5
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.",
6
6
  "type": "module",
@@ -29,22 +29,22 @@
29
29
  "tags": []
30
30
  },
31
31
  "dependencies": {
32
- "@behivetech/forms.form-field": "1.1.0",
33
- "@behivetech/forms.form-provider": "1.0.1"
32
+ "@behivetech/forms.form-field": "1.1.2",
33
+ "@behivetech/forms.form-provider": "1.0.3"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^19.2.7",
37
37
  "react-dom": "^19.2.7"
38
38
  },
39
39
  "devDependencies": {
40
- "@behivetech/atoms.checkbox": "1.1.0",
41
- "@behivetech/atoms.select": "1.1.0",
42
- "@behivetech/atoms.text-field": "1.1.0",
43
- "@behivetech/atoms.textarea": "1.1.0",
44
- "@behivetech/atoms.toggle": "1.1.0",
40
+ "@behivetech/atoms.checkbox": "1.1.2",
41
+ "@behivetech/atoms.select": "1.1.2",
42
+ "@behivetech/atoms.text-field": "1.1.2",
43
+ "@behivetech/atoms.textarea": "1.2.0",
44
+ "@behivetech/atoms.toggle": "1.1.2",
45
45
  "@bht-component-registry/env": "0.3.0",
46
- "@types/react": "19.2.17",
47
- "@types/react-dom": "19.2.3",
46
+ "@types/react": "19.3.3",
47
+ "@types/react-dom": "19.3.0",
48
48
  "eslint": "^9.39.5",
49
49
  "tsup": "^8.5.1",
50
50
  "typescript": "^6.0.3",