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