1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import { unstable_composeClasses as composeClasses } from '@mui/base';
|
7 | import { refType, unstable_useId as useId } from '@mui/utils';
|
8 | import styled from '../styles/styled';
|
9 | import useThemeProps from '../styles/useThemeProps';
|
10 | import Input from '../Input';
|
11 | import FilledInput from '../FilledInput';
|
12 | import OutlinedInput from '../OutlinedInput';
|
13 | import InputLabel from '../InputLabel';
|
14 | import FormControl from '../FormControl';
|
15 | import FormHelperText from '../FormHelperText';
|
16 | import Select from '../Select';
|
17 | import { getTextFieldUtilityClass } from './textFieldClasses';
|
18 | import { jsx as _jsx } from "react/jsx-runtime";
|
19 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
20 | var variantComponent = {
|
21 | standard: Input,
|
22 | filled: FilledInput,
|
23 | outlined: OutlinedInput
|
24 | };
|
25 |
|
26 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
27 | var classes = ownerState.classes;
|
28 | var slots = {
|
29 | root: ['root']
|
30 | };
|
31 | return composeClasses(slots, getTextFieldUtilityClass, classes);
|
32 | };
|
33 |
|
34 | var TextFieldRoot = styled(FormControl, {
|
35 | name: 'MuiTextField',
|
36 | slot: 'Root',
|
37 | overridesResolver: function overridesResolver(props, styles) {
|
38 | return styles.root;
|
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 | var TextField = React.forwardRef(function TextField(inProps, ref) {
|
75 | var props = useThemeProps({
|
76 | props: inProps,
|
77 | name: 'MuiTextField'
|
78 | });
|
79 |
|
80 | var autoComplete = props.autoComplete,
|
81 | _props$autoFocus = props.autoFocus,
|
82 | autoFocus = _props$autoFocus === void 0 ? false : _props$autoFocus,
|
83 | children = props.children,
|
84 | className = props.className,
|
85 | _props$color = props.color,
|
86 | color = _props$color === void 0 ? 'primary' : _props$color,
|
87 | defaultValue = props.defaultValue,
|
88 | _props$disabled = props.disabled,
|
89 | disabled = _props$disabled === void 0 ? false : _props$disabled,
|
90 | _props$error = props.error,
|
91 | error = _props$error === void 0 ? false : _props$error,
|
92 | FormHelperTextProps = props.FormHelperTextProps,
|
93 | _props$fullWidth = props.fullWidth,
|
94 | fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
|
95 | helperText = props.helperText,
|
96 | idOverride = props.id,
|
97 | InputLabelProps = props.InputLabelProps,
|
98 | inputProps = props.inputProps,
|
99 | InputProps = props.InputProps,
|
100 | inputRef = props.inputRef,
|
101 | label = props.label,
|
102 | maxRows = props.maxRows,
|
103 | minRows = props.minRows,
|
104 | _props$multiline = props.multiline,
|
105 | multiline = _props$multiline === void 0 ? false : _props$multiline,
|
106 | name = props.name,
|
107 | onBlur = props.onBlur,
|
108 | onChange = props.onChange,
|
109 | onFocus = props.onFocus,
|
110 | placeholder = props.placeholder,
|
111 | _props$required = props.required,
|
112 | required = _props$required === void 0 ? false : _props$required,
|
113 | rows = props.rows,
|
114 | _props$select = props.select,
|
115 | select = _props$select === void 0 ? false : _props$select,
|
116 | SelectProps = props.SelectProps,
|
117 | type = props.type,
|
118 | value = props.value,
|
119 | _props$variant = props.variant,
|
120 | variant = _props$variant === void 0 ? 'outlined' : _props$variant,
|
121 | other = _objectWithoutProperties(props, ["autoComplete", "autoFocus", "children", "className", "color", "defaultValue", "disabled", "error", "FormHelperTextProps", "fullWidth", "helperText", "id", "InputLabelProps", "inputProps", "InputProps", "inputRef", "label", "maxRows", "minRows", "multiline", "name", "onBlur", "onChange", "onFocus", "placeholder", "required", "rows", "select", "SelectProps", "type", "value", "variant"]);
|
122 |
|
123 | var ownerState = _extends({}, props, {
|
124 | autoFocus: autoFocus,
|
125 | color: color,
|
126 | disabled: disabled,
|
127 | error: error,
|
128 | fullWidth: fullWidth,
|
129 | multiline: multiline,
|
130 | required: required,
|
131 | select: select,
|
132 | variant: variant
|
133 | });
|
134 |
|
135 | var classes = useUtilityClasses(ownerState);
|
136 |
|
137 | if (process.env.NODE_ENV !== 'production') {
|
138 | if (select && !children) {
|
139 | console.error('MUI: `children` must be passed when using the `TextField` component with `select`.');
|
140 | }
|
141 | }
|
142 |
|
143 | var InputMore = {};
|
144 |
|
145 | if (variant === 'outlined') {
|
146 | if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') {
|
147 | InputMore.notched = InputLabelProps.shrink;
|
148 | }
|
149 |
|
150 | InputMore.label = label;
|
151 | }
|
152 |
|
153 | if (select) {
|
154 |
|
155 | if (!SelectProps || !SelectProps.native) {
|
156 | InputMore.id = undefined;
|
157 | }
|
158 |
|
159 | InputMore['aria-describedby'] = undefined;
|
160 | }
|
161 |
|
162 | var id = useId(idOverride);
|
163 | var helperTextId = helperText && id ? "".concat(id, "-helper-text") : undefined;
|
164 | var inputLabelId = label && id ? "".concat(id, "-label") : undefined;
|
165 | var InputComponent = variantComponent[variant];
|
166 |
|
167 | var InputElement = _jsx(InputComponent, _extends({
|
168 | "aria-describedby": helperTextId,
|
169 | autoComplete: autoComplete,
|
170 | autoFocus: autoFocus,
|
171 | defaultValue: defaultValue,
|
172 | fullWidth: fullWidth,
|
173 | multiline: multiline,
|
174 | name: name,
|
175 | rows: rows,
|
176 | maxRows: maxRows,
|
177 | minRows: minRows,
|
178 | type: type,
|
179 | value: value,
|
180 | id: id,
|
181 | inputRef: inputRef,
|
182 | onBlur: onBlur,
|
183 | onChange: onChange,
|
184 | onFocus: onFocus,
|
185 | placeholder: placeholder,
|
186 | inputProps: inputProps
|
187 | }, InputMore, InputProps));
|
188 |
|
189 | return _jsxs(TextFieldRoot, _extends({
|
190 | className: clsx(classes.root, className),
|
191 | disabled: disabled,
|
192 | error: error,
|
193 | fullWidth: fullWidth,
|
194 | ref: ref,
|
195 | required: required,
|
196 | color: color,
|
197 | variant: variant,
|
198 | ownerState: ownerState
|
199 | }, other, {
|
200 | children: [label != null && label !== '' && _jsx(InputLabel, _extends({
|
201 | htmlFor: id,
|
202 | id: inputLabelId
|
203 | }, InputLabelProps, {
|
204 | children: label
|
205 | })), select ? _jsx(Select, _extends({
|
206 | "aria-describedby": helperTextId,
|
207 | id: id,
|
208 | labelId: inputLabelId,
|
209 | value: value,
|
210 | input: InputElement
|
211 | }, SelectProps, {
|
212 | children: children
|
213 | })) : InputElement, helperText && _jsx(FormHelperText, _extends({
|
214 | id: helperTextId
|
215 | }, FormHelperTextProps, {
|
216 | children: helperText
|
217 | }))]
|
218 | }));
|
219 | });
|
220 | process.env.NODE_ENV !== "production" ? TextField.propTypes
|
221 |
|
222 | = {
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 | |
229 |
|
230 |
|
231 |
|
232 |
|
233 | autoComplete: PropTypes.string,
|
234 |
|
235 | |
236 |
|
237 |
|
238 |
|
239 | autoFocus: PropTypes.bool,
|
240 |
|
241 | |
242 |
|
243 |
|
244 | children: PropTypes.node,
|
245 |
|
246 | |
247 |
|
248 |
|
249 | classes: PropTypes.object,
|
250 |
|
251 | |
252 |
|
253 |
|
254 | className: PropTypes.string,
|
255 |
|
256 | |
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 | color: PropTypes
|
263 |
|
264 | .oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
265 |
|
266 | |
267 |
|
268 |
|
269 | defaultValue: PropTypes.any,
|
270 |
|
271 | |
272 |
|
273 |
|
274 |
|
275 | disabled: PropTypes.bool,
|
276 |
|
277 | |
278 |
|
279 |
|
280 |
|
281 | error: PropTypes.bool,
|
282 |
|
283 | |
284 |
|
285 |
|
286 | FormHelperTextProps: PropTypes.object,
|
287 |
|
288 | |
289 |
|
290 |
|
291 |
|
292 | fullWidth: PropTypes.bool,
|
293 |
|
294 | |
295 |
|
296 |
|
297 | helperText: PropTypes.node,
|
298 |
|
299 | |
300 |
|
301 |
|
302 |
|
303 | id: PropTypes.string,
|
304 |
|
305 | |
306 |
|
307 |
|
308 |
|
309 | InputLabelProps: PropTypes.object,
|
310 |
|
311 | |
312 |
|
313 |
|
314 | inputProps: PropTypes.object,
|
315 |
|
316 | |
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 | InputProps: PropTypes.object,
|
323 |
|
324 | |
325 |
|
326 |
|
327 | inputRef: refType,
|
328 |
|
329 | |
330 |
|
331 |
|
332 | label: PropTypes.node,
|
333 |
|
334 | |
335 |
|
336 |
|
337 |
|
338 | margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
339 |
|
340 | |
341 |
|
342 |
|
343 | maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
344 |
|
345 | |
346 |
|
347 |
|
348 | minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
349 |
|
350 | |
351 |
|
352 |
|
353 |
|
354 | multiline: PropTypes.bool,
|
355 |
|
356 | |
357 |
|
358 |
|
359 | name: PropTypes.string,
|
360 |
|
361 | |
362 |
|
363 |
|
364 | onBlur: PropTypes.func,
|
365 |
|
366 | |
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 | onChange: PropTypes.func,
|
373 |
|
374 | |
375 |
|
376 |
|
377 | onFocus: PropTypes.func,
|
378 |
|
379 | |
380 |
|
381 |
|
382 | placeholder: PropTypes.string,
|
383 |
|
384 | |
385 |
|
386 |
|
387 |
|
388 | required: PropTypes.bool,
|
389 |
|
390 | |
391 |
|
392 |
|
393 | rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
394 |
|
395 | |
396 |
|
397 |
|
398 |
|
399 |
|
400 | select: PropTypes.bool,
|
401 |
|
402 | |
403 |
|
404 |
|
405 | SelectProps: PropTypes.object,
|
406 |
|
407 | |
408 |
|
409 |
|
410 | size: PropTypes
|
411 |
|
412 | .oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
413 |
|
414 | |
415 |
|
416 |
|
417 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
418 |
|
419 | |
420 |
|
421 |
|
422 | type: PropTypes
|
423 |
|
424 | .string,
|
425 |
|
426 | |
427 |
|
428 |
|
429 | value: PropTypes.any,
|
430 |
|
431 | |
432 |
|
433 |
|
434 |
|
435 | variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
436 | } : void 0;
|
437 | export default TextField; |
\ | No newline at end of file |