1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = exports.styles = void 0;
|
9 |
|
10 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11 |
|
12 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13 |
|
14 | var _react = _interopRequireDefault(require("react"));
|
15 |
|
16 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
17 |
|
18 | var _clsx = _interopRequireDefault(require("clsx"));
|
19 |
|
20 | var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
21 |
|
22 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
23 |
|
24 | var _colorManipulator = require("../styles/colorManipulator");
|
25 |
|
26 | var _useTheme = _interopRequireDefault(require("../styles/useTheme"));
|
27 |
|
28 | var TRANSITION_DURATION = 4;
|
29 |
|
30 | var styles = function styles(theme) {
|
31 | var getColor = function getColor(color) {
|
32 | return theme.palette.type === 'light' ? (0, _colorManipulator.lighten)(color, 0.62) : (0, _colorManipulator.darken)(color, 0.5);
|
33 | };
|
34 |
|
35 | var backgroundPrimary = getColor(theme.palette.primary.main);
|
36 | var backgroundSecondary = getColor(theme.palette.secondary.main);
|
37 | return {
|
38 |
|
39 | root: {
|
40 | position: 'relative',
|
41 | overflow: 'hidden',
|
42 | height: 4
|
43 | },
|
44 |
|
45 |
|
46 | colorPrimary: {
|
47 | backgroundColor: backgroundPrimary
|
48 | },
|
49 |
|
50 |
|
51 | colorSecondary: {
|
52 | backgroundColor: backgroundSecondary
|
53 | },
|
54 |
|
55 |
|
56 | determinate: {},
|
57 |
|
58 |
|
59 | indeterminate: {},
|
60 |
|
61 |
|
62 | buffer: {
|
63 | backgroundColor: 'transparent'
|
64 | },
|
65 |
|
66 |
|
67 | query: {
|
68 | transform: 'rotate(180deg)'
|
69 | },
|
70 |
|
71 |
|
72 | dashed: {
|
73 | position: 'absolute',
|
74 | marginTop: 0,
|
75 | height: '100%',
|
76 | width: '100%',
|
77 | animation: '$buffer 3s infinite linear'
|
78 | },
|
79 |
|
80 |
|
81 | dashedColorPrimary: {
|
82 | backgroundImage: "radial-gradient(".concat(backgroundPrimary, " 0%, ").concat(backgroundPrimary, " 16%, transparent 42%)"),
|
83 | backgroundSize: '10px 10px',
|
84 | backgroundPosition: '0px -23px'
|
85 | },
|
86 |
|
87 |
|
88 | dashedColorSecondary: {
|
89 | backgroundImage: "radial-gradient(".concat(backgroundSecondary, " 0%, ").concat(backgroundSecondary, " 16%, transparent 42%)"),
|
90 | backgroundSize: '10px 10px',
|
91 | backgroundPosition: '0px -23px'
|
92 | },
|
93 |
|
94 |
|
95 | bar: {
|
96 | width: '100%',
|
97 | position: 'absolute',
|
98 | left: 0,
|
99 | bottom: 0,
|
100 | top: 0,
|
101 | transition: 'transform 0.2s linear',
|
102 | transformOrigin: 'left'
|
103 | },
|
104 |
|
105 |
|
106 | barColorPrimary: {
|
107 | backgroundColor: theme.palette.primary.main
|
108 | },
|
109 |
|
110 |
|
111 | barColorSecondary: {
|
112 | backgroundColor: theme.palette.secondary.main
|
113 | },
|
114 |
|
115 |
|
116 | bar1Indeterminate: {
|
117 | width: 'auto',
|
118 | animation: '$indeterminate1 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite'
|
119 | },
|
120 |
|
121 |
|
122 | bar1Determinate: {
|
123 | transition: "transform .".concat(TRANSITION_DURATION, "s linear")
|
124 | },
|
125 |
|
126 |
|
127 | bar1Buffer: {
|
128 | zIndex: 1,
|
129 | transition: "transform .".concat(TRANSITION_DURATION, "s linear")
|
130 | },
|
131 |
|
132 |
|
133 | bar2Indeterminate: {
|
134 | width: 'auto',
|
135 | animation: '$indeterminate2 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite',
|
136 | animationDelay: '1.15s'
|
137 | },
|
138 |
|
139 |
|
140 | bar2Buffer: {
|
141 | transition: "transform .".concat(TRANSITION_DURATION, "s linear")
|
142 | },
|
143 |
|
144 |
|
145 |
|
146 |
|
147 | '@keyframes indeterminate1': {
|
148 |
|
149 | '0%': {
|
150 | left: '-35%',
|
151 | right: '100%'
|
152 | },
|
153 |
|
154 | '60%': {
|
155 | left: '100%',
|
156 | right: '-90%'
|
157 | },
|
158 | '100%': {
|
159 | left: '100%',
|
160 | right: '-90%'
|
161 | }
|
162 | },
|
163 | '@keyframes indeterminate2': {
|
164 |
|
165 | '0%': {
|
166 | left: '-200%',
|
167 | right: '100%'
|
168 | },
|
169 |
|
170 | '60%': {
|
171 | left: '107%',
|
172 | right: '-8%'
|
173 | },
|
174 | '100%': {
|
175 | left: '107%',
|
176 | right: '-8%'
|
177 | }
|
178 | },
|
179 | '@keyframes buffer': {
|
180 | '0%': {
|
181 | opacity: 1,
|
182 | backgroundPosition: '0px -23px'
|
183 | },
|
184 | '50%': {
|
185 | opacity: 0,
|
186 | backgroundPosition: '0px -23px'
|
187 | },
|
188 | '100%': {
|
189 | opacity: 1,
|
190 | backgroundPosition: '-200px -23px'
|
191 | }
|
192 | }
|
193 | };
|
194 | };
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 | exports.styles = styles;
|
205 |
|
206 | var LinearProgress = _react.default.forwardRef(function LinearProgress(props, ref) {
|
207 | var classes = props.classes,
|
208 | className = props.className,
|
209 | _props$color = props.color,
|
210 | color = _props$color === void 0 ? 'primary' : _props$color,
|
211 | value = props.value,
|
212 | valueBuffer = props.valueBuffer,
|
213 | _props$variant = props.variant,
|
214 | variant = _props$variant === void 0 ? 'indeterminate' : _props$variant,
|
215 | other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "color", "value", "valueBuffer", "variant"]);
|
216 | var theme = (0, _useTheme.default)();
|
217 | var rootProps = {};
|
218 | var inlineStyles = {
|
219 | bar1: {},
|
220 | bar2: {}
|
221 | };
|
222 |
|
223 | if (variant === 'determinate' || variant === 'buffer') {
|
224 | if (value !== undefined) {
|
225 | rootProps['aria-valuenow'] = Math.round(value);
|
226 | var transform = value - 100;
|
227 |
|
228 | if (theme.direction === 'rtl') {
|
229 | transform = -transform;
|
230 | }
|
231 |
|
232 | inlineStyles.bar1.transform = "translateX(".concat(transform, "%)");
|
233 | } else if (process.env.NODE_ENV !== 'production') {
|
234 | console.error('Material-UI: you need to provide a value prop ' + 'when using the determinate or buffer variant of LinearProgress .');
|
235 | }
|
236 | }
|
237 |
|
238 | if (variant === 'buffer') {
|
239 | if (valueBuffer !== undefined) {
|
240 | var _transform = (valueBuffer || 0) - 100;
|
241 |
|
242 | if (theme.direction === 'rtl') {
|
243 | _transform = -_transform;
|
244 | }
|
245 |
|
246 | inlineStyles.bar2.transform = "translateX(".concat(_transform, "%)");
|
247 | } else if (process.env.NODE_ENV !== 'production') {
|
248 | console.error('Material-UI: you need to provide a valueBuffer prop ' + 'when using the buffer variant of LinearProgress.');
|
249 | }
|
250 | }
|
251 |
|
252 | return _react.default.createElement("div", (0, _extends2.default)({
|
253 | className: (0, _clsx.default)(classes.root, classes["color".concat((0, _capitalize.default)(color))], className, {
|
254 | determinate: classes.determinate,
|
255 | indeterminate: classes.indeterminate,
|
256 | buffer: classes.buffer,
|
257 | query: classes.query
|
258 | }[variant]),
|
259 | role: "progressbar"
|
260 | }, rootProps, {
|
261 | ref: ref
|
262 | }, other), variant === 'buffer' ? _react.default.createElement("div", {
|
263 | className: (0, _clsx.default)(classes.dashed, classes["dashedColor".concat((0, _capitalize.default)(color))])
|
264 | }) : null, _react.default.createElement("div", {
|
265 | className: (0, _clsx.default)(classes.bar, classes["barColor".concat((0, _capitalize.default)(color))], (variant === 'indeterminate' || variant === 'query') && classes.bar1Indeterminate, {
|
266 | determinate: classes.bar1Determinate,
|
267 | buffer: classes.bar1Buffer
|
268 | }[variant]),
|
269 | style: inlineStyles.bar1
|
270 | }), variant === 'determinate' ? null : _react.default.createElement("div", {
|
271 | className: (0, _clsx.default)(classes.bar, (variant === 'indeterminate' || variant === 'query') && classes.bar2Indeterminate, variant === 'buffer' ? [classes["color".concat((0, _capitalize.default)(color))], classes.bar2Buffer] : classes["barColor".concat((0, _capitalize.default)(color))]),
|
272 | style: inlineStyles.bar2
|
273 | }));
|
274 | });
|
275 |
|
276 | process.env.NODE_ENV !== "production" ? LinearProgress.propTypes = {
|
277 | |
278 |
|
279 |
|
280 |
|
281 | classes: _propTypes.default.object.isRequired,
|
282 |
|
283 | |
284 |
|
285 |
|
286 | className: _propTypes.default.string,
|
287 |
|
288 | |
289 |
|
290 |
|
291 | color: _propTypes.default.oneOf(['primary', 'secondary']),
|
292 |
|
293 | |
294 |
|
295 |
|
296 |
|
297 | value: _propTypes.default.number,
|
298 |
|
299 | |
300 |
|
301 |
|
302 |
|
303 | valueBuffer: _propTypes.default.number,
|
304 |
|
305 | |
306 |
|
307 |
|
308 |
|
309 | variant: _propTypes.default.oneOf(['determinate', 'indeterminate', 'buffer', 'query'])
|
310 | } : void 0;
|
311 |
|
312 | var _default = (0, _withStyles.default)(styles, {
|
313 | name: 'MuiLinearProgress'
|
314 | })(LinearProgress);
|
315 |
|
316 | exports.default = _default; |
\ | No newline at end of file |