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