-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
/
Copy pathInputBase.d.ts
264 lines (258 loc) · 8.88 KB
/
InputBase.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import * as React from 'react';
import { SxProps } from '@mui/system';
import { OverridableStringUnion } from '@mui/types';
import { Theme } from '../styles';
import { InternalStandardProps as StandardProps } from '..';
import { InputBaseClasses } from './inputBaseClasses';
export interface InputBasePropsSizeOverrides {}
export interface InputBasePropsColorOverrides {}
export interface InputBaseComponentsPropsOverrides {}
export interface InputBaseProps
extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
/*
* `onBlur`, `onChange`, `onFocus`, `onInvalid`, `onKeyDown`, `onKeyUp` are applied to the inner `InputComponent`,
* which by default is an input or textarea. Since these handlers differ from the
* ones inherited by `React.HTMLAttributes<HTMLDivElement>` we need to omit them.
*/
| 'children'
| 'defaultValue'
| 'onBlur'
| 'onChange'
| 'onFocus'
| 'onInvalid'
| 'onKeyDown'
| 'onKeyUp'
> {
'aria-describedby'?: string;
/**
* This prop helps users to fill forms faster, especially on mobile devices.
* The name can be confusing, as it's more like an autofill.
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
*/
autoComplete?: string;
/**
* If `true`, the `input` element is focused during the first mount.
*/
autoFocus?: boolean;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<InputBaseClasses>;
/**
* The color of the component.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
* The prop defaults to the value (`'primary'`) inherited from the parent FormControl component.
*/
color?: OverridableStringUnion<
'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning',
InputBasePropsColorOverrides
>;
/**
* The components used for each slot inside.
*
* @deprecated use the `slots` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*
* @default {}
*/
components?: {
Root?: React.ElementType;
Input?: React.ElementType;
};
/**
* The extra props for the slot components.
* You can override the existing props or add new ones.
*
* @deprecated use the `slotProps` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*
* @default {}
*/
componentsProps?: {
root?: React.HTMLAttributes<HTMLDivElement> & InputBaseComponentsPropsOverrides;
input?: React.InputHTMLAttributes<HTMLInputElement> & InputBaseComponentsPropsOverrides;
};
/**
* The default value. Use when the component is not controlled.
*/
defaultValue?: unknown;
/**
* If `true`, the component is disabled.
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
disabled?: boolean;
/**
* If `true`, GlobalStyles for the auto-fill keyframes will not be injected/removed on mount/unmount. Make sure to inject them at the top of your application.
* This option is intended to help with boosting the initial rendering performance if you are loading a big amount of Input components at once.
* @default false
*/
disableInjectingGlobalStyles?: boolean;
/**
* End `InputAdornment` for this component.
*/
endAdornment?: React.ReactNode;
/**
* If `true`, the `input` will indicate an error.
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
error?: boolean;
/**
* If `true`, the `input` will take up the full width of its container.
* @default false
*/
fullWidth?: boolean;
/**
* The id of the `input` element.
*/
id?: string;
/**
* The component used for the `input` element.
* Either a string to use a HTML element or a component.
* @default 'input'
*/
inputComponent?: React.ElementType<InputBaseComponentProps>;
/**
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
* @default {}
*/
inputProps?: InputBaseComponentProps;
/**
* Pass a ref to the `input` element.
*/
inputRef?: React.Ref<any>;
/**
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
* FormControl.
* The prop defaults to the value (`'none'`) inherited from the parent FormControl component.
*/
margin?: 'dense' | 'none';
/**
* If `true`, a [TextareaAutosize](https://mui.com/material-ui/react-textarea-autosize/) element is rendered.
* @default false
*/
multiline?: boolean;
/**
* Name attribute of the `input` element.
*/
name?: string;
/**
* Callback fired when the `input` is blurred.
*
* Notice that the first argument (event) might be undefined.
*/
onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
/**
* Callback fired when the value is changed.
*
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
* You can pull out the new value by accessing `event.target.value` (string).
*/
onChange?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
onFocus?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement | HTMLInputElement>;
onKeyUp?: React.KeyboardEventHandler<HTMLTextAreaElement | HTMLInputElement>;
/**
* Callback fired when the `input` doesn't satisfy its constraints.
*/
onInvalid?: React.FormEventHandler<HTMLInputElement | HTMLTextAreaElement>;
/**
* The short hint displayed in the `input` before the user enters a value.
*/
placeholder?: string;
/**
* It prevents the user from changing the value of the field
* (not from interacting with the field).
*/
readOnly?: boolean;
/**
* If `true`, the `input` element is required.
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
required?: boolean;
renderSuffix?: (state: {
disabled?: boolean;
error?: boolean;
filled?: boolean;
focused?: boolean;
margin?: 'dense' | 'none' | 'normal';
required?: boolean;
startAdornment?: React.ReactNode;
}) => React.ReactNode;
/**
* Number of rows to display when multiline option is set to true.
*/
rows?: string | number;
/**
* Maximum number of rows to display when multiline option is set to true.
*/
maxRows?: string | number;
/**
* Minimum number of rows to display when multiline option is set to true.
*/
minRows?: string | number;
/**
* The size of the component.
*/
size?: OverridableStringUnion<'small' | 'medium', InputBasePropsSizeOverrides>;
/**
* The extra props for the slot components.
* You can override the existing props or add new ones.
*
* This prop is an alias for the `componentsProps` prop, which will be deprecated in the future.
*
* @default {}
*/
slotProps?: {
root?: React.HTMLAttributes<HTMLDivElement> &
InputBaseComponentsPropsOverrides & { sx?: SxProps<Theme> };
input?: React.InputHTMLAttributes<HTMLInputElement> &
InputBaseComponentsPropsOverrides & { sx?: SxProps<Theme> };
};
/**
* The components used for each slot inside.
*
* This prop is an alias for the `components` prop, which will be deprecated in the future.
*
* @default {}
*/
slots?: {
root?: React.ElementType;
input?: React.ElementType;
};
/**
* Start `InputAdornment` for this component.
*/
startAdornment?: React.ReactNode;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
/**
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
* @default 'text'
*/
type?: string;
/**
* The value of the `input` element, required for a controlled component.
*/
value?: unknown;
}
export interface InputBaseComponentProps
extends React.HTMLAttributes<HTMLInputElement | HTMLTextAreaElement> {
// Accommodate arbitrary additional props coming from the `inputProps` prop
[arbitrary: string]: any;
}
/**
* `InputBase` contains as few styles as possible.
* It aims to be a simple building block for creating an input.
* It contains a load of style reset and some state logic.
*
* Demos:
*
* - [Text Field](https://mui.com/material-ui/react-text-field/)
*
* API:
*
* - [InputBase API](https://mui.com/material-ui/api/input-base/)
*/
export default function InputBase(props: InputBaseProps): React.JSX.Element;