1 | import * as React from 'react';
|
2 | import { PropTypes } from '..';
|
3 | import { OverridableComponent, OverrideProps } from '../OverridableComponent';
|
4 |
|
5 | export interface FormControlTypeMap<P = {}, D extends React.ElementType = 'div'> {
|
6 | props: P & {
|
7 | /**
|
8 | * The contents of the form control.
|
9 | */
|
10 | children?: React.ReactNode;
|
11 | /**
|
12 | * The color of the component. It supports those theme colors that make sense for this component.
|
13 | */
|
14 | color?: 'primary' | 'secondary';
|
15 | /**
|
16 | * If `true`, the label, input and helper text should be displayed in a disabled state.
|
17 | */
|
18 | disabled?: boolean;
|
19 | /**
|
20 | * If `true`, the label should be displayed in an error state.
|
21 | */
|
22 | error?: boolean;
|
23 | /**
|
24 | * If `true`, the component will take up the full width of its container.
|
25 | */
|
26 | fullWidth?: boolean;
|
27 | /**
|
28 | * If `true`, the component will be displayed in focused state.
|
29 | */
|
30 | focused?: boolean;
|
31 | /**
|
32 | * If `true`, the label will be hidden.
|
33 | * This is used to increase density for a `FilledInput`.
|
34 | * Be sure to add `aria-label` to the `input` element.
|
35 | */
|
36 | hiddenLabel?: boolean;
|
37 | /**
|
38 | * If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
39 | */
|
40 | margin?: PropTypes.Margin;
|
41 | /**
|
42 | * If `true`, the label will indicate that the input is required.
|
43 | */
|
44 | required?: boolean;
|
45 | /**
|
46 | * The size of the text field.
|
47 | */
|
48 | size?: 'small' | 'medium';
|
49 | /**
|
50 | * The variant to use.
|
51 | */
|
52 | variant?: 'standard' | 'outlined' | 'filled';
|
53 | };
|
54 | defaultComponent: D;
|
55 | classKey: FormControlClassKey;
|
56 | }
|
57 |
|
58 | /**
|
59 | * Provides context such as filled/focused/error/required for form inputs.
|
60 | * Relying on the context provides high flexibility and ensures that the state always stays
|
61 | * consistent across the children of the `FormControl`.
|
62 | * This context is used by the following components:
|
63 | *
|
64 | * - FormLabel
|
65 | * - FormHelperText
|
66 | * - Input
|
67 | * - InputLabel
|
68 | *
|
69 | * You can find one composition example below and more going to [the demos](https://mui.com/components/text-fields/#components).
|
70 | *
|
71 | * ```jsx
|
72 | * <FormControl>
|
73 | * <InputLabel htmlFor="my-input">Email address</InputLabel>
|
74 | * <Input id="my-input" aria-describedby="my-helper-text" />
|
75 | * <FormHelperText id="my-helper-text">We'll never share your email.</FormHelperText>
|
76 | * </FormControl>
|
77 | * ```
|
78 | *
|
79 | * ⚠️Only one input can be used within a FormControl.
|
80 | * Demos:
|
81 | *
|
82 | * - [Checkboxes](https://mui.com/components/checkboxes/)
|
83 | * - [Radio Buttons](https://mui.com/components/radio-buttons/)
|
84 | * - [Switches](https://mui.com/components/switches/)
|
85 | * - [Text Fields](https://mui.com/components/text-fields/)
|
86 | *
|
87 | * API:
|
88 | *
|
89 | * - [FormControl API](https://mui.com/api/form-control/)
|
90 | */
|
91 | declare const FormControl: OverridableComponent<FormControlTypeMap>;
|
92 |
|
93 | export type FormControlClassKey = 'root' | 'marginNormal' | 'marginDense' | 'fullWidth';
|
94 |
|
95 | export type FormControlProps<
|
96 | D extends React.ElementType = FormControlTypeMap['defaultComponent'],
|
97 | P = {}
|
98 | > = OverrideProps<FormControlTypeMap<P, D>, D>;
|
99 |
|
100 | export default FormControl;
|