1 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
4 |
|
5 | var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
6 |
|
7 | import * as React from 'react';
|
8 | import PropTypes from 'prop-types';
|
9 | import clsx from 'clsx';
|
10 | import { unstable_composeClasses as composeClasses } from '@mui/base';
|
11 | import { keyframes, css, darken, lighten } from '@mui/system';
|
12 | import capitalize from '../utils/capitalize';
|
13 | import useTheme from '../styles/useTheme';
|
14 | import styled from '../styles/styled';
|
15 | import useThemeProps from '../styles/useThemeProps';
|
16 | import { getLinearProgressUtilityClass } from './linearProgressClasses';
|
17 | import { jsx as _jsx } from "react/jsx-runtime";
|
18 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
19 | var TRANSITION_DURATION = 4;
|
20 |
|
21 | var indeterminate1Keyframe = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n left: -35%;\n right: 100%;\n }\n\n 60% {\n left: 100%;\n right: -90%;\n }\n\n 100% {\n left: 100%;\n right: -90%;\n }\n"])));
|
22 | var indeterminate2Keyframe = keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n 0% {\n left: -200%;\n right: 100%;\n }\n\n 60% {\n left: 107%;\n right: -8%;\n }\n\n 100% {\n left: 107%;\n right: -8%;\n }\n"])));
|
23 | var bufferKeyframe = keyframes(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n 0% {\n opacity: 1;\n background-position: 0 -23px;\n }\n\n 60% {\n opacity: 0;\n background-position: 0 -23px;\n }\n\n 100% {\n opacity: 1;\n background-position: -200px -23px;\n }\n"])));
|
24 |
|
25 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
26 | var classes = ownerState.classes,
|
27 | variant = ownerState.variant,
|
28 | color = ownerState.color;
|
29 | var slots = {
|
30 | root: ['root', "color".concat(capitalize(color)), variant],
|
31 | dashed: ['dashed', "dashedColor".concat(capitalize(color))],
|
32 | bar1: ['bar', "barColor".concat(capitalize(color)), (variant === 'indeterminate' || variant === 'query') && 'bar1Indeterminate', variant === 'determinate' && 'bar1Determinate', variant === 'buffer' && 'bar1Buffer'],
|
33 | bar2: ['bar', variant !== 'buffer' && "barColor".concat(capitalize(color)), variant === 'buffer' && "color".concat(capitalize(color)), (variant === 'indeterminate' || variant === 'query') && 'bar2Indeterminate', variant === 'buffer' && 'bar2Buffer']
|
34 | };
|
35 | return composeClasses(slots, getLinearProgressUtilityClass, classes);
|
36 | };
|
37 |
|
38 | var getColorShade = function getColorShade(theme, color) {
|
39 | if (color === 'inherit') {
|
40 | return 'currentColor';
|
41 | }
|
42 |
|
43 | if (theme.vars) {
|
44 | return theme.vars.palette.LinearProgress["".concat(color, "Bg")];
|
45 | }
|
46 |
|
47 | return theme.palette.mode === 'light' ? lighten(theme.palette[color].main, 0.62) : darken(theme.palette[color].main, 0.5);
|
48 | };
|
49 |
|
50 | var LinearProgressRoot = styled('span', {
|
51 | name: 'MuiLinearProgress',
|
52 | slot: 'Root',
|
53 | overridesResolver: function overridesResolver(props, styles) {
|
54 | var ownerState = props.ownerState;
|
55 | return [styles.root, styles["color".concat(capitalize(ownerState.color))], styles[ownerState.variant]];
|
56 | }
|
57 | })(function (_ref) {
|
58 | var ownerState = _ref.ownerState,
|
59 | theme = _ref.theme;
|
60 | return _extends({
|
61 | position: 'relative',
|
62 | overflow: 'hidden',
|
63 | display: 'block',
|
64 | height: 4,
|
65 | zIndex: 0,
|
66 |
|
67 | '@media print': {
|
68 | colorAdjust: 'exact'
|
69 | },
|
70 | backgroundColor: getColorShade(theme, ownerState.color)
|
71 | }, ownerState.color === 'inherit' && ownerState.variant !== 'buffer' && {
|
72 | backgroundColor: 'none',
|
73 | '&::before': {
|
74 | content: '""',
|
75 | position: 'absolute',
|
76 | left: 0,
|
77 | top: 0,
|
78 | right: 0,
|
79 | bottom: 0,
|
80 | backgroundColor: 'currentColor',
|
81 | opacity: 0.3
|
82 | }
|
83 | }, ownerState.variant === 'buffer' && {
|
84 | backgroundColor: 'transparent'
|
85 | }, ownerState.variant === 'query' && {
|
86 | transform: 'rotate(180deg)'
|
87 | });
|
88 | });
|
89 | var LinearProgressDashed = styled('span', {
|
90 | name: 'MuiLinearProgress',
|
91 | slot: 'Dashed',
|
92 | overridesResolver: function overridesResolver(props, styles) {
|
93 | var ownerState = props.ownerState;
|
94 | return [styles.dashed, styles["dashedColor".concat(capitalize(ownerState.color))]];
|
95 | }
|
96 | })(function (_ref2) {
|
97 | var ownerState = _ref2.ownerState,
|
98 | theme = _ref2.theme;
|
99 | var backgroundColor = getColorShade(theme, ownerState.color);
|
100 | return _extends({
|
101 | position: 'absolute',
|
102 | marginTop: 0,
|
103 | height: '100%',
|
104 | width: '100%'
|
105 | }, ownerState.color === 'inherit' && {
|
106 | opacity: 0.3
|
107 | }, {
|
108 | backgroundImage: "radial-gradient(".concat(backgroundColor, " 0%, ").concat(backgroundColor, " 16%, transparent 42%)"),
|
109 | backgroundSize: '10px 10px',
|
110 | backgroundPosition: '0 -23px'
|
111 | });
|
112 | }, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n animation: ", " 3s infinite linear;\n "])), bufferKeyframe));
|
113 | var LinearProgressBar1 = styled('span', {
|
114 | name: 'MuiLinearProgress',
|
115 | slot: 'Bar1',
|
116 | overridesResolver: function overridesResolver(props, styles) {
|
117 | var ownerState = props.ownerState;
|
118 | return [styles.bar, styles["barColor".concat(capitalize(ownerState.color))], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar1Indeterminate, ownerState.variant === 'determinate' && styles.bar1Determinate, ownerState.variant === 'buffer' && styles.bar1Buffer];
|
119 | }
|
120 | })(function (_ref3) {
|
121 | var ownerState = _ref3.ownerState,
|
122 | theme = _ref3.theme;
|
123 | return _extends({
|
124 | width: '100%',
|
125 | position: 'absolute',
|
126 | left: 0,
|
127 | bottom: 0,
|
128 | top: 0,
|
129 | transition: 'transform 0.2s linear',
|
130 | transformOrigin: 'left',
|
131 | backgroundColor: ownerState.color === 'inherit' ? 'currentColor' : (theme.vars || theme).palette[ownerState.color].main
|
132 | }, ownerState.variant === 'determinate' && {
|
133 | transition: "transform .".concat(TRANSITION_DURATION, "s linear")
|
134 | }, ownerState.variant === 'buffer' && {
|
135 | zIndex: 1,
|
136 | transition: "transform .".concat(TRANSITION_DURATION, "s linear")
|
137 | });
|
138 | }, function (_ref4) {
|
139 | var ownerState = _ref4.ownerState;
|
140 | return (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n width: auto;\n animation: ", " 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;\n "])), indeterminate1Keyframe);
|
141 | });
|
142 | var LinearProgressBar2 = styled('span', {
|
143 | name: 'MuiLinearProgress',
|
144 | slot: 'Bar2',
|
145 | overridesResolver: function overridesResolver(props, styles) {
|
146 | var ownerState = props.ownerState;
|
147 | return [styles.bar, styles["barColor".concat(capitalize(ownerState.color))], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar2Indeterminate, ownerState.variant === 'buffer' && styles.bar2Buffer];
|
148 | }
|
149 | })(function (_ref5) {
|
150 | var ownerState = _ref5.ownerState,
|
151 | theme = _ref5.theme;
|
152 | return _extends({
|
153 | width: '100%',
|
154 | position: 'absolute',
|
155 | left: 0,
|
156 | bottom: 0,
|
157 | top: 0,
|
158 | transition: 'transform 0.2s linear',
|
159 | transformOrigin: 'left'
|
160 | }, ownerState.variant !== 'buffer' && {
|
161 | backgroundColor: ownerState.color === 'inherit' ? 'currentColor' : (theme.vars || theme).palette[ownerState.color].main
|
162 | }, ownerState.color === 'inherit' && {
|
163 | opacity: 0.3
|
164 | }, ownerState.variant === 'buffer' && {
|
165 | backgroundColor: getColorShade(theme, ownerState.color),
|
166 | transition: "transform .".concat(TRANSITION_DURATION, "s linear")
|
167 | });
|
168 | }, function (_ref6) {
|
169 | var ownerState = _ref6.ownerState;
|
170 | return (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n width: auto;\n animation: ", " 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) 1.15s infinite;\n "])), indeterminate2Keyframe);
|
171 | });
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 | var LinearProgress = React.forwardRef(function LinearProgress(inProps, ref) {
|
181 | var props = useThemeProps({
|
182 | props: inProps,
|
183 | name: 'MuiLinearProgress'
|
184 | });
|
185 |
|
186 | var className = props.className,
|
187 | _props$color = props.color,
|
188 | color = _props$color === void 0 ? 'primary' : _props$color,
|
189 | value = props.value,
|
190 | valueBuffer = props.valueBuffer,
|
191 | _props$variant = props.variant,
|
192 | variant = _props$variant === void 0 ? 'indeterminate' : _props$variant,
|
193 | other = _objectWithoutProperties(props, ["className", "color", "value", "valueBuffer", "variant"]);
|
194 |
|
195 | var ownerState = _extends({}, props, {
|
196 | color: color,
|
197 | variant: variant
|
198 | });
|
199 |
|
200 | var classes = useUtilityClasses(ownerState);
|
201 | var theme = useTheme();
|
202 | var rootProps = {};
|
203 | var inlineStyles = {
|
204 | bar1: {},
|
205 | bar2: {}
|
206 | };
|
207 |
|
208 | if (variant === 'determinate' || variant === 'buffer') {
|
209 | if (value !== undefined) {
|
210 | rootProps['aria-valuenow'] = Math.round(value);
|
211 | rootProps['aria-valuemin'] = 0;
|
212 | rootProps['aria-valuemax'] = 100;
|
213 | var transform = value - 100;
|
214 |
|
215 | if (theme.direction === 'rtl') {
|
216 | transform = -transform;
|
217 | }
|
218 |
|
219 | inlineStyles.bar1.transform = "translateX(".concat(transform, "%)");
|
220 | } else if (process.env.NODE_ENV !== 'production') {
|
221 | console.error('MUI: You need to provide a value prop ' + 'when using the determinate or buffer variant of LinearProgress .');
|
222 | }
|
223 | }
|
224 |
|
225 | if (variant === 'buffer') {
|
226 | if (valueBuffer !== undefined) {
|
227 | var _transform = (valueBuffer || 0) - 100;
|
228 |
|
229 | if (theme.direction === 'rtl') {
|
230 | _transform = -_transform;
|
231 | }
|
232 |
|
233 | inlineStyles.bar2.transform = "translateX(".concat(_transform, "%)");
|
234 | } else if (process.env.NODE_ENV !== 'production') {
|
235 | console.error('MUI: You need to provide a valueBuffer prop ' + 'when using the buffer variant of LinearProgress.');
|
236 | }
|
237 | }
|
238 |
|
239 | return _jsxs(LinearProgressRoot, _extends({
|
240 | className: clsx(classes.root, className),
|
241 | ownerState: ownerState,
|
242 | role: "progressbar"
|
243 | }, rootProps, {
|
244 | ref: ref
|
245 | }, other, {
|
246 | children: [variant === 'buffer' ? _jsx(LinearProgressDashed, {
|
247 | className: classes.dashed,
|
248 | ownerState: ownerState
|
249 | }) : null, _jsx(LinearProgressBar1, {
|
250 | className: classes.bar1,
|
251 | ownerState: ownerState,
|
252 | style: inlineStyles.bar1
|
253 | }), variant === 'determinate' ? null : _jsx(LinearProgressBar2, {
|
254 | className: classes.bar2,
|
255 | ownerState: ownerState,
|
256 | style: inlineStyles.bar2
|
257 | })]
|
258 | }));
|
259 | });
|
260 | process.env.NODE_ENV !== "production" ? LinearProgress.propTypes
|
261 |
|
262 | = {
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 | |
269 |
|
270 |
|
271 | classes: PropTypes.object,
|
272 |
|
273 | |
274 |
|
275 |
|
276 | className: PropTypes.string,
|
277 |
|
278 | |
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 | color: PropTypes
|
285 |
|
286 | .oneOfType([PropTypes.oneOf(['inherit', 'primary', 'secondary']), PropTypes.string]),
|
287 |
|
288 | |
289 |
|
290 |
|
291 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
292 |
|
293 | |
294 |
|
295 |
|
296 |
|
297 | value: PropTypes.number,
|
298 |
|
299 | |
300 |
|
301 |
|
302 |
|
303 | valueBuffer: PropTypes.number,
|
304 |
|
305 | |
306 |
|
307 |
|
308 |
|
309 |
|
310 | variant: PropTypes.oneOf(['buffer', 'determinate', 'indeterminate', 'query'])
|
311 | } : void 0;
|
312 | export default LinearProgress; |
\ | No newline at end of file |