UNPKG

11.5 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _clsx = _interopRequireDefault(require("clsx"));
21
22var _utils = require("@material-ui/utils");
23
24var _InputBase = _interopRequireDefault(require("../InputBase"));
25
26var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
27
28var styles = function styles(theme) {
29 var light = theme.palette.type === 'light';
30 var bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)';
31 var backgroundColor = light ? 'rgba(0, 0, 0, 0.09)' : 'rgba(255, 255, 255, 0.09)';
32 return {
33 /* Styles applied to the root element. */
34 root: {
35 position: 'relative',
36 backgroundColor: backgroundColor,
37 borderTopLeftRadius: theme.shape.borderRadius,
38 borderTopRightRadius: theme.shape.borderRadius,
39 transition: theme.transitions.create('background-color', {
40 duration: theme.transitions.duration.shorter,
41 easing: theme.transitions.easing.easeOut
42 }),
43 '&:hover': {
44 backgroundColor: light ? 'rgba(0, 0, 0, 0.13)' : 'rgba(255, 255, 255, 0.13)',
45 // Reset on touch devices, it doesn't add specificity
46 '@media (hover: none)': {
47 backgroundColor: backgroundColor
48 }
49 },
50 '&$focused': {
51 backgroundColor: light ? 'rgba(0, 0, 0, 0.09)' : 'rgba(255, 255, 255, 0.09)'
52 },
53 '&$disabled': {
54 backgroundColor: light ? 'rgba(0, 0, 0, 0.12)' : 'rgba(255, 255, 255, 0.12)'
55 }
56 },
57
58 /* Styles applied to the root element if color secondary. */
59 colorSecondary: {
60 '&$underline:after': {
61 borderBottomColor: theme.palette.secondary.main
62 }
63 },
64
65 /* Styles applied to the root element if `disableUnderline={false}`. */
66 underline: {
67 '&:after': {
68 borderBottom: "2px solid ".concat(theme.palette.primary.main),
69 left: 0,
70 bottom: 0,
71 // Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
72 content: '""',
73 position: 'absolute',
74 right: 0,
75 transform: 'scaleX(0)',
76 transition: theme.transitions.create('transform', {
77 duration: theme.transitions.duration.shorter,
78 easing: theme.transitions.easing.easeOut
79 }),
80 pointerEvents: 'none' // Transparent to the hover style.
81
82 },
83 '&$focused:after': {
84 transform: 'scaleX(1)'
85 },
86 '&$error:after': {
87 borderBottomColor: theme.palette.error.main,
88 transform: 'scaleX(1)' // error is always underlined in red
89
90 },
91 '&:before': {
92 borderBottom: "1px solid ".concat(bottomLineColor),
93 left: 0,
94 bottom: 0,
95 // Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
96 content: '"\\00a0"',
97 position: 'absolute',
98 right: 0,
99 transition: theme.transitions.create('border-bottom-color', {
100 duration: theme.transitions.duration.shorter
101 }),
102 pointerEvents: 'none' // Transparent to the hover style.
103
104 },
105 '&:hover:before': {
106 borderBottom: "1px solid ".concat(theme.palette.text.primary)
107 },
108 '&$disabled:before': {
109 borderBottomStyle: 'dotted'
110 }
111 },
112
113 /* Pseudo-class applied to the root element if the component is focused. */
114 focused: {},
115
116 /* Pseudo-class applied to the root element if `disabled={true}`. */
117 disabled: {},
118
119 /* Styles applied to the root element if `startAdornment` is provided. */
120 adornedStart: {
121 paddingLeft: 12
122 },
123
124 /* Styles applied to the root element if `endAdornment` is provided. */
125 adornedEnd: {
126 paddingRight: 12
127 },
128
129 /* Pseudo-class applied to the root element if `error={true}`. */
130 error: {},
131
132 /* Styles applied to the `input` element if `margin="dense"`. */
133 marginDense: {},
134
135 /* Styles applied to the root element if `multiline={true}`. */
136 multiline: {
137 padding: '27px 12px 10px',
138 '&$marginDense': {
139 paddingTop: 23,
140 paddingBottom: 6
141 }
142 },
143
144 /* Styles applied to the `input` element. */
145 input: {
146 padding: '27px 12px 10px',
147 '&:-webkit-autofill': {
148 WebkitBoxShadow: theme.palette.type === 'light' ? null : '0 0 0 100px #266798 inset',
149 WebkitTextFillColor: theme.palette.type === 'light' ? null : '#fff',
150 caretColor: theme.palette.type === 'light' ? null : '#fff',
151 borderTopLeftRadius: 'inherit',
152 borderTopRightRadius: 'inherit'
153 }
154 },
155
156 /* Styles applied to the `input` element if `margin="dense"`. */
157 inputMarginDense: {
158 paddingTop: 23,
159 paddingBottom: 6
160 },
161
162 /* Styles applied to the `input` if in `<FormControl hiddenLabel />`. */
163 inputHiddenLabel: {
164 paddingTop: 18,
165 paddingBottom: 19,
166 '&$inputMarginDense': {
167 paddingTop: 10,
168 paddingBottom: 11
169 }
170 },
171
172 /* Styles applied to the `input` element if `multiline={true}`. */
173 inputMultiline: {
174 padding: 0
175 },
176
177 /* Styles applied to the `input` element if `startAdornment` is provided. */
178 inputAdornedStart: {
179 paddingLeft: 0
180 },
181
182 /* Styles applied to the `input` element if `endAdornment` is provided. */
183 inputAdornedEnd: {
184 paddingRight: 0
185 }
186 };
187};
188
189exports.styles = styles;
190var FilledInput = /*#__PURE__*/React.forwardRef(function FilledInput(props, ref) {
191 var disableUnderline = props.disableUnderline,
192 classes = props.classes,
193 _props$fullWidth = props.fullWidth,
194 fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
195 _props$inputComponent = props.inputComponent,
196 inputComponent = _props$inputComponent === void 0 ? 'input' : _props$inputComponent,
197 _props$multiline = props.multiline,
198 multiline = _props$multiline === void 0 ? false : _props$multiline,
199 _props$type = props.type,
200 type = _props$type === void 0 ? 'text' : _props$type,
201 other = (0, _objectWithoutProperties2.default)(props, ["disableUnderline", "classes", "fullWidth", "inputComponent", "multiline", "type"]);
202 return /*#__PURE__*/React.createElement(_InputBase.default, (0, _extends2.default)({
203 classes: (0, _extends2.default)({}, classes, {
204 root: (0, _clsx.default)(classes.root, !disableUnderline && classes.underline),
205 underline: null
206 }),
207 fullWidth: fullWidth,
208 inputComponent: inputComponent,
209 multiline: multiline,
210 ref: ref,
211 type: type
212 }, other));
213});
214process.env.NODE_ENV !== "production" ? FilledInput.propTypes = {
215 // ----------------------------- Warning --------------------------------
216 // | These PropTypes are generated from the TypeScript type definitions |
217 // | To update them edit the d.ts file and run "yarn proptypes" |
218 // ----------------------------------------------------------------------
219
220 /**
221 * This prop helps users to fill forms faster, especially on mobile devices.
222 * The name can be confusing, as it's more like an autofill.
223 * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
224 */
225 autoComplete: _propTypes.default.string,
226
227 /**
228 * If `true`, the `input` element will be focused during the first mount.
229 */
230 autoFocus: _propTypes.default.bool,
231
232 /**
233 * Override or extend the styles applied to the component.
234 * See [CSS API](#css) below for more details.
235 */
236 classes: _propTypes.default.object,
237
238 /**
239 * The color of the component. It supports those theme colors that make sense for this component.
240 */
241 color: _propTypes.default.oneOf(['primary', 'secondary']),
242
243 /**
244 * The default `input` element value. Use when the component is not controlled.
245 */
246 defaultValue: _propTypes.default.any,
247
248 /**
249 * If `true`, the `input` element will be disabled.
250 */
251 disabled: _propTypes.default.bool,
252
253 /**
254 * If `true`, the input will not have an underline.
255 */
256 disableUnderline: _propTypes.default.bool,
257
258 /**
259 * End `InputAdornment` for this component.
260 */
261 endAdornment: _propTypes.default.node,
262
263 /**
264 * If `true`, the input will indicate an error. This is normally obtained via context from
265 * FormControl.
266 */
267 error: _propTypes.default.bool,
268
269 /**
270 * If `true`, the input will take up the full width of its container.
271 */
272 fullWidth: _propTypes.default.bool,
273
274 /**
275 * The id of the `input` element.
276 */
277 id: _propTypes.default.string,
278
279 /**
280 * The component used for the `input` element.
281 * Either a string to use a HTML element or a component.
282 */
283 inputComponent: _propTypes.default.elementType,
284
285 /**
286 * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
287 */
288 inputProps: _propTypes.default.object,
289
290 /**
291 * Pass a ref to the `input` element.
292 */
293 inputRef: _utils.refType,
294
295 /**
296 * If `dense`, will adjust vertical spacing. This is normally obtained via context from
297 * FormControl.
298 */
299 margin: _propTypes.default.oneOf(['dense', 'none']),
300
301 /**
302 * Maximum number of rows to display when multiline option is set to true.
303 */
304 maxRows: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
305
306 /**
307 * If `true`, a textarea element will be rendered.
308 */
309 multiline: _propTypes.default.bool,
310
311 /**
312 * Name attribute of the `input` element.
313 */
314 name: _propTypes.default.string,
315
316 /**
317 * Callback fired when the value is changed.
318 *
319 * @param {object} event The event source of the callback.
320 * You can pull out the new value by accessing `event.target.value` (string).
321 */
322 onChange: _propTypes.default.func,
323
324 /**
325 * The short hint displayed in the input before the user enters a value.
326 */
327 placeholder: _propTypes.default.string,
328
329 /**
330 * It prevents the user from changing the value of the field
331 * (not from interacting with the field).
332 */
333 readOnly: _propTypes.default.bool,
334
335 /**
336 * If `true`, the `input` element will be required.
337 */
338 required: _propTypes.default.bool,
339
340 /**
341 * Number of rows to display when multiline option is set to true.
342 */
343 rows: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
344
345 /**
346 * Start `InputAdornment` for this component.
347 */
348 startAdornment: _propTypes.default.node,
349
350 /**
351 * 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).
352 */
353 type: _propTypes.default.string,
354
355 /**
356 * The value of the `input` element, required for a controlled component.
357 */
358 value: _propTypes.default.any
359} : void 0;
360FilledInput.muiName = 'Input';
361
362var _default = (0, _withStyles.default)(styles, {
363 name: 'MuiFilledInput'
364})(FilledInput);
365
366exports.default = _default;
\No newline at end of file