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 _formControlState = _interopRequireDefault(require("../FormControl/formControlState"));
|
23 |
|
24 | var _useFormControl = _interopRequireDefault(require("../FormControl/useFormControl"));
|
25 |
|
26 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
27 |
|
28 | var _FormLabel = _interopRequireDefault(require("../FormLabel"));
|
29 |
|
30 | var styles = function styles(theme) {
|
31 | return {
|
32 |
|
33 | root: {
|
34 | display: 'block',
|
35 | transformOrigin: 'top left'
|
36 | },
|
37 |
|
38 |
|
39 | focused: {},
|
40 |
|
41 |
|
42 | disabled: {},
|
43 |
|
44 |
|
45 | error: {},
|
46 |
|
47 |
|
48 | required: {},
|
49 |
|
50 |
|
51 | asterisk: {},
|
52 |
|
53 |
|
54 | formControl: {
|
55 | position: 'absolute',
|
56 | left: 0,
|
57 | top: 0,
|
58 |
|
59 | transform: 'translate(0, 24px) scale(1)'
|
60 | },
|
61 |
|
62 |
|
63 | marginDense: {
|
64 |
|
65 | transform: 'translate(0, 21px) scale(1)'
|
66 | },
|
67 |
|
68 |
|
69 | shrink: {
|
70 | transform: 'translate(0, 1.5px) scale(0.75)',
|
71 | transformOrigin: 'top left'
|
72 | },
|
73 |
|
74 |
|
75 | animated: {
|
76 | transition: theme.transitions.create(['color', 'transform'], {
|
77 | duration: theme.transitions.duration.shorter,
|
78 | easing: theme.transitions.easing.easeOut
|
79 | })
|
80 | },
|
81 |
|
82 |
|
83 | filled: {
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | zIndex: 1,
|
89 | pointerEvents: 'none',
|
90 | transform: 'translate(12px, 20px) scale(1)',
|
91 | '&$marginDense': {
|
92 | transform: 'translate(12px, 17px) scale(1)'
|
93 | },
|
94 | '&$shrink': {
|
95 | transform: 'translate(12px, 10px) scale(0.75)',
|
96 | '&$marginDense': {
|
97 | transform: 'translate(12px, 7px) scale(0.75)'
|
98 | }
|
99 | }
|
100 | },
|
101 |
|
102 |
|
103 | outlined: {
|
104 |
|
105 | zIndex: 1,
|
106 | pointerEvents: 'none',
|
107 | transform: 'translate(14px, 20px) scale(1)',
|
108 | '&$marginDense': {
|
109 | transform: 'translate(14px, 12px) scale(1)'
|
110 | },
|
111 | '&$shrink': {
|
112 | transform: 'translate(14px, -6px) scale(0.75)'
|
113 | }
|
114 | }
|
115 | };
|
116 | };
|
117 |
|
118 | exports.styles = styles;
|
119 | var InputLabel = React.forwardRef(function InputLabel(props, ref) {
|
120 | var classes = props.classes,
|
121 | className = props.className,
|
122 | _props$disableAnimati = props.disableAnimation,
|
123 | disableAnimation = _props$disableAnimati === void 0 ? false : _props$disableAnimati,
|
124 | margin = props.margin,
|
125 | shrinkProp = props.shrink,
|
126 | variant = props.variant,
|
127 | other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "disableAnimation", "margin", "shrink", "variant"]);
|
128 | var muiFormControl = (0, _useFormControl.default)();
|
129 | var shrink = shrinkProp;
|
130 |
|
131 | if (typeof shrink === 'undefined' && muiFormControl) {
|
132 | shrink = muiFormControl.filled || muiFormControl.focused || muiFormControl.adornedStart;
|
133 | }
|
134 |
|
135 | var fcs = (0, _formControlState.default)({
|
136 | props: props,
|
137 | muiFormControl: muiFormControl,
|
138 | states: ['margin', 'variant']
|
139 | });
|
140 | return React.createElement(_FormLabel.default, (0, _extends2.default)({
|
141 | "data-shrink": shrink,
|
142 | className: (0, _clsx.default)(classes.root, className, muiFormControl && classes.formControl, !disableAnimation && classes.animated, shrink && classes.shrink, fcs.margin === 'dense' && classes.marginDense, {
|
143 | 'filled': classes.filled,
|
144 | 'outlined': classes.outlined
|
145 | }[fcs.variant]),
|
146 | classes: {
|
147 | focused: classes.focused,
|
148 | disabled: classes.disabled,
|
149 | error: classes.error,
|
150 | required: classes.required,
|
151 | asterisk: classes.asterisk
|
152 | },
|
153 | ref: ref
|
154 | }, other));
|
155 | });
|
156 | process.env.NODE_ENV !== "production" ? InputLabel.propTypes = {
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | |
163 |
|
164 |
|
165 | children: _propTypes.default.node,
|
166 |
|
167 | |
168 |
|
169 |
|
170 |
|
171 | classes: _propTypes.default.object,
|
172 |
|
173 | |
174 |
|
175 |
|
176 | className: _propTypes.default.string,
|
177 |
|
178 | |
179 |
|
180 |
|
181 | color: _propTypes.default.oneOf(['primary', 'secondary']),
|
182 |
|
183 | |
184 |
|
185 |
|
186 | disableAnimation: _propTypes.default.bool,
|
187 |
|
188 | |
189 |
|
190 |
|
191 | disabled: _propTypes.default.bool,
|
192 |
|
193 | |
194 |
|
195 |
|
196 | error: _propTypes.default.bool,
|
197 |
|
198 | |
199 |
|
200 |
|
201 | focused: _propTypes.default.bool,
|
202 |
|
203 | |
204 |
|
205 |
|
206 |
|
207 | margin: _propTypes.default.oneOf(['dense']),
|
208 |
|
209 | |
210 |
|
211 |
|
212 | required: _propTypes.default.bool,
|
213 |
|
214 | |
215 |
|
216 |
|
217 | shrink: _propTypes.default.bool,
|
218 |
|
219 | |
220 |
|
221 |
|
222 | variant: _propTypes.default.oneOf(['filled', 'outlined', 'standard'])
|
223 | } : void 0;
|
224 |
|
225 | var _default = (0, _withStyles.default)(styles, {
|
226 | name: 'MuiInputLabel'
|
227 | })(InputLabel);
|
228 |
|
229 | exports.default = _default; |
\ | No newline at end of file |