UNPKG

1.14 kBTypeScriptView Raw
1import { BoxProps } from "../Box";
2import * as React from "react";
3
4export interface UseFormControlProps {
5 /**
6 * If `true` set the form control to the invalid state.
7 */
8 isInvalid?: boolean;
9 /**
10 * If `true` set the form control to be required.
11 */
12 isRequired?: boolean;
13 /**
14 * If `true` set the form control to the disabled state.
15 */
16 isDisabled?: boolean;
17 /**
18 * If `true` set the form control to the read only state.
19 */
20 isReadOnly?: boolean;
21}
22
23/**
24 * React hook to read from props passed to the `FormControl` component
25 * It's mostly used to design custom form control components.
26 *
27 * @param props props passed to the input control
28 */
29export function useFormControl(props: UseFormControlProps): UseFormControlProps;
30
31export interface IFormControl extends UseFormControlProps {
32 /**
33 * Content of the form control.
34 */
35 children?: React.ReactNode;
36}
37
38export type FormControlProps = IFormControl & BoxProps;
39
40/**
41 * FormControl provides context such as `isInvalid`, `isRequired`, `isDisabled` to it's children.
42 */
43declare const FormControl: React.FC<FormControlProps>;
44
45export default FormControl;