Skip to content

Commit da83663

Browse files
committed
Field documentation
1 parent 6403f68 commit da83663

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Field.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,39 @@ export type ElementProps<C extends React.FunctionComponent<any> | keyof JSX.Intr
99
: never;
1010

1111
export type FieldProps<T extends object, K extends keyof T, C> = {
12+
/**
13+
* The form to make a field for
14+
*/
1215
form: FormState<T>;
16+
/**
17+
* The name of the field
18+
*/
1319
name: K;
20+
/**
21+
* The element to create, this can be a string specifying "input", "select", "textarea" or a custom component. Is "input" by default. The props of the passed component are available on this field.
22+
*
23+
* **Examples**
24+
*
25+
* `<Field as="textarea" rows={10} />`
26+
*
27+
* `<Field as={CustomInput} {...} />`
28+
*/
1429
as?: C;
30+
/**
31+
* Wheter to hide this field if is set to undefined or null.
32+
*/
1533
hideWhenNull?: boolean;
34+
/**
35+
* A serializer is a function that converts the field value to a string/boolean value that can be passed to input. Leave undefined to use the default serializer.
36+
*
37+
* You can change the behaviour of the default serializer using the `type` prop.
38+
*/
1639
serializer?: Serializer<T[K]>;
40+
/**
41+
* A deserializer is a function that converts the string/boolean input value to the real form value. Leave undefined to use the default deserializer.
42+
*
43+
* You can change the behaviour of the default deserializer using the `type` prop.
44+
*/
1745
deserializer?: Deserializer<T[K]>;
1846
};
1947

0 commit comments

Comments
 (0)