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 _Typography = _interopRequireDefault(require("../Typography"));
|
23 |
|
24 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
25 |
|
26 | var _FormControlContext = _interopRequireWildcard(require("../FormControl/FormControlContext"));
|
27 |
|
28 | var styles = {
|
29 |
|
30 | root: {
|
31 | display: 'flex',
|
32 | height: '0.01em',
|
33 |
|
34 | maxHeight: '2em',
|
35 | alignItems: 'center',
|
36 | whiteSpace: 'nowrap'
|
37 | },
|
38 |
|
39 |
|
40 | filled: {
|
41 | '&$positionStart:not($hiddenLabel)': {
|
42 | marginTop: 16
|
43 | }
|
44 | },
|
45 |
|
46 |
|
47 | positionStart: {
|
48 | marginRight: 8
|
49 | },
|
50 |
|
51 |
|
52 | positionEnd: {
|
53 | marginLeft: 8
|
54 | },
|
55 |
|
56 |
|
57 | disablePointerEvents: {
|
58 | pointerEvents: 'none'
|
59 | },
|
60 |
|
61 |
|
62 | hiddenLabel: {},
|
63 |
|
64 |
|
65 | marginDense: {}
|
66 | };
|
67 | exports.styles = styles;
|
68 | var InputAdornment = React.forwardRef(function InputAdornment(props, ref) {
|
69 | var children = props.children,
|
70 | classes = props.classes,
|
71 | className = props.className,
|
72 | _props$component = props.component,
|
73 | Component = _props$component === void 0 ? 'div' : _props$component,
|
74 | _props$disablePointer = props.disablePointerEvents,
|
75 | disablePointerEvents = _props$disablePointer === void 0 ? false : _props$disablePointer,
|
76 | _props$disableTypogra = props.disableTypography,
|
77 | disableTypography = _props$disableTypogra === void 0 ? false : _props$disableTypogra,
|
78 | position = props.position,
|
79 | variantProp = props.variant,
|
80 | other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "component", "disablePointerEvents", "disableTypography", "position", "variant"]);
|
81 | var muiFormControl = (0, _FormControlContext.useFormControl)() || {};
|
82 | var variant = variantProp;
|
83 |
|
84 | if (variantProp && muiFormControl.variant) {
|
85 | if (process.env.NODE_ENV !== 'production') {
|
86 | if (variantProp === muiFormControl.variant) {
|
87 | console.error('Material-UI: The `InputAdornment` variant infers the variant prop ' + 'you do not have to provide one.');
|
88 | }
|
89 | }
|
90 | }
|
91 |
|
92 | if (muiFormControl && !variant) {
|
93 | variant = muiFormControl.variant;
|
94 | }
|
95 |
|
96 | return React.createElement(_FormControlContext.default.Provider, {
|
97 | value: null
|
98 | }, React.createElement(Component, (0, _extends2.default)({
|
99 | className: (0, _clsx.default)(classes.root, className, disablePointerEvents && classes.disablePointerEvents, muiFormControl.hiddenLabel && classes.hiddenLabel, variant === 'filled' && classes.filled, {
|
100 | 'start': classes.positionStart,
|
101 | 'end': classes.positionEnd
|
102 | }[position], muiFormControl.margin === 'dense' && classes.marginDense),
|
103 | ref: ref
|
104 | }, other), typeof children === 'string' && !disableTypography ? React.createElement(_Typography.default, {
|
105 | color: "textSecondary"
|
106 | }, children) : children));
|
107 | });
|
108 | process.env.NODE_ENV !== "production" ? InputAdornment.propTypes = {
|
109 | |
110 |
|
111 |
|
112 | children: _propTypes.default.node.isRequired,
|
113 |
|
114 | |
115 |
|
116 |
|
117 |
|
118 | classes: _propTypes.default.object.isRequired,
|
119 |
|
120 | |
121 |
|
122 |
|
123 | className: _propTypes.default.string,
|
124 |
|
125 | |
126 |
|
127 |
|
128 |
|
129 | component: _propTypes.default
|
130 |
|
131 | .elementType,
|
132 |
|
133 | |
134 |
|
135 |
|
136 |
|
137 | disablePointerEvents: _propTypes.default.bool,
|
138 |
|
139 | |
140 |
|
141 |
|
142 | disableTypography: _propTypes.default.bool,
|
143 |
|
144 | |
145 |
|
146 |
|
147 | muiFormControl: _propTypes.default.object,
|
148 |
|
149 | |
150 |
|
151 |
|
152 | position: _propTypes.default.oneOf(['start', 'end']),
|
153 |
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 | variant: _propTypes.default.oneOf(['standard', 'outlined', 'filled'])
|
160 | } : void 0;
|
161 |
|
162 | var _default = (0, _withStyles.default)(styles, {
|
163 | name: 'MuiInputAdornment'
|
164 | })(InputAdornment);
|
165 |
|
166 | exports.default = _default; |
\ | No newline at end of file |