1 | "use strict";
|
2 | 'use client';
|
3 |
|
4 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
5 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
6 | Object.defineProperty(exports, "__esModule", {
|
7 | value: true
|
8 | });
|
9 | exports.default = void 0;
|
10 | var React = _interopRequireWildcard(require("react"));
|
11 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
12 | var _clsx = _interopRequireDefault(require("clsx"));
|
13 | var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
14 | var _colorManipulator = require("@mui/system/colorManipulator");
|
15 | var _RtlProvider = require("@mui/system/RtlProvider");
|
16 | var _zeroStyled = require("../zero-styled");
|
17 | var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
|
18 | var _createSimplePaletteValueFilter = _interopRequireDefault(require("../utils/createSimplePaletteValueFilter"));
|
19 | var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
20 | var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
21 | var _linearProgressClasses = require("./linearProgressClasses");
|
22 | var _jsxRuntime = require("react/jsx-runtime");
|
23 | const TRANSITION_DURATION = 4;
|
24 | const indeterminate1Keyframe = (0, _zeroStyled.keyframes)`
|
25 | 0% {
|
26 | left: -35%;
|
27 | right: 100%;
|
28 | }
|
29 |
|
30 | 60% {
|
31 | left: 100%;
|
32 | right: -90%;
|
33 | }
|
34 |
|
35 | 100% {
|
36 | left: 100%;
|
37 | right: -90%;
|
38 | }
|
39 | `;
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | const indeterminate1Animation = typeof indeterminate1Keyframe !== 'string' ? (0, _zeroStyled.css)`
|
45 | animation: ${indeterminate1Keyframe} 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
|
46 | ` : null;
|
47 | const indeterminate2Keyframe = (0, _zeroStyled.keyframes)`
|
48 | 0% {
|
49 | left: -200%;
|
50 | right: 100%;
|
51 | }
|
52 |
|
53 | 60% {
|
54 | left: 107%;
|
55 | right: -8%;
|
56 | }
|
57 |
|
58 | 100% {
|
59 | left: 107%;
|
60 | right: -8%;
|
61 | }
|
62 | `;
|
63 | const indeterminate2Animation = typeof indeterminate2Keyframe !== 'string' ? (0, _zeroStyled.css)`
|
64 | animation: ${indeterminate2Keyframe} 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) 1.15s infinite;
|
65 | ` : null;
|
66 | const bufferKeyframe = (0, _zeroStyled.keyframes)`
|
67 | 0% {
|
68 | opacity: 1;
|
69 | background-position: 0 -23px;
|
70 | }
|
71 |
|
72 | 60% {
|
73 | opacity: 0;
|
74 | background-position: 0 -23px;
|
75 | }
|
76 |
|
77 | 100% {
|
78 | opacity: 1;
|
79 | background-position: -200px -23px;
|
80 | }
|
81 | `;
|
82 | const bufferAnimation = typeof bufferKeyframe !== 'string' ? (0, _zeroStyled.css)`
|
83 | animation: ${bufferKeyframe} 3s infinite linear;
|
84 | ` : null;
|
85 | const useUtilityClasses = ownerState => {
|
86 | const {
|
87 | classes,
|
88 | variant,
|
89 | color
|
90 | } = ownerState;
|
91 | const slots = {
|
92 | root: ['root', `color${(0, _capitalize.default)(color)}`, variant],
|
93 | dashed: ['dashed', `dashedColor${(0, _capitalize.default)(color)}`],
|
94 | bar1: ['bar', `barColor${(0, _capitalize.default)(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar1Indeterminate', variant === 'determinate' && 'bar1Determinate', variant === 'buffer' && 'bar1Buffer'],
|
95 | bar2: ['bar', variant !== 'buffer' && `barColor${(0, _capitalize.default)(color)}`, variant === 'buffer' && `color${(0, _capitalize.default)(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar2Indeterminate', variant === 'buffer' && 'bar2Buffer']
|
96 | };
|
97 | return (0, _composeClasses.default)(slots, _linearProgressClasses.getLinearProgressUtilityClass, classes);
|
98 | };
|
99 | const getColorShade = (theme, color) => {
|
100 | if (theme.vars) {
|
101 | return theme.vars.palette.LinearProgress[`${color}Bg`];
|
102 | }
|
103 | return theme.palette.mode === 'light' ? (0, _colorManipulator.lighten)(theme.palette[color].main, 0.62) : (0, _colorManipulator.darken)(theme.palette[color].main, 0.5);
|
104 | };
|
105 | const LinearProgressRoot = (0, _zeroStyled.styled)('span', {
|
106 | name: 'MuiLinearProgress',
|
107 | slot: 'Root',
|
108 | overridesResolver: (props, styles) => {
|
109 | const {
|
110 | ownerState
|
111 | } = props;
|
112 | return [styles.root, styles[`color${(0, _capitalize.default)(ownerState.color)}`], styles[ownerState.variant]];
|
113 | }
|
114 | })((0, _memoTheme.default)(({
|
115 | theme
|
116 | }) => ({
|
117 | position: 'relative',
|
118 | overflow: 'hidden',
|
119 | display: 'block',
|
120 | height: 4,
|
121 |
|
122 | zIndex: 0,
|
123 | '@media print': {
|
124 | colorAdjust: 'exact'
|
125 | },
|
126 | variants: [...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)()).map(([color]) => ({
|
127 | props: {
|
128 | color
|
129 | },
|
130 | style: {
|
131 | backgroundColor: getColorShade(theme, color)
|
132 | }
|
133 | })), {
|
134 | props: ({
|
135 | ownerState
|
136 | }) => ownerState.color === 'inherit' && ownerState.variant !== 'buffer',
|
137 | style: {
|
138 | '&::before': {
|
139 | content: '""',
|
140 | position: 'absolute',
|
141 | left: 0,
|
142 | top: 0,
|
143 | right: 0,
|
144 | bottom: 0,
|
145 | backgroundColor: 'currentColor',
|
146 | opacity: 0.3
|
147 | }
|
148 | }
|
149 | }, {
|
150 | props: {
|
151 | variant: 'buffer'
|
152 | },
|
153 | style: {
|
154 | backgroundColor: 'transparent'
|
155 | }
|
156 | }, {
|
157 | props: {
|
158 | variant: 'query'
|
159 | },
|
160 | style: {
|
161 | transform: 'rotate(180deg)'
|
162 | }
|
163 | }]
|
164 | })));
|
165 | const LinearProgressDashed = (0, _zeroStyled.styled)('span', {
|
166 | name: 'MuiLinearProgress',
|
167 | slot: 'Dashed',
|
168 | overridesResolver: (props, styles) => {
|
169 | const {
|
170 | ownerState
|
171 | } = props;
|
172 | return [styles.dashed, styles[`dashedColor${(0, _capitalize.default)(ownerState.color)}`]];
|
173 | }
|
174 | })((0, _memoTheme.default)(({
|
175 | theme
|
176 | }) => ({
|
177 | position: 'absolute',
|
178 | marginTop: 0,
|
179 | height: '100%',
|
180 | width: '100%',
|
181 | backgroundSize: '10px 10px',
|
182 | backgroundPosition: '0 -23px',
|
183 | variants: [{
|
184 | props: {
|
185 | color: 'inherit'
|
186 | },
|
187 | style: {
|
188 | opacity: 0.3,
|
189 | backgroundImage: `radial-gradient(currentColor 0%, currentColor 16%, transparent 42%)`
|
190 | }
|
191 | }, ...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)()).map(([color]) => {
|
192 | const backgroundColor = getColorShade(theme, color);
|
193 | return {
|
194 | props: {
|
195 | color
|
196 | },
|
197 | style: {
|
198 | backgroundImage: `radial-gradient(${backgroundColor} 0%, ${backgroundColor} 16%, transparent 42%)`
|
199 | }
|
200 | };
|
201 | })]
|
202 | })), bufferAnimation || {
|
203 |
|
204 | animation: `${bufferKeyframe} 3s infinite linear`
|
205 | });
|
206 | const LinearProgressBar1 = (0, _zeroStyled.styled)('span', {
|
207 | name: 'MuiLinearProgress',
|
208 | slot: 'Bar1',
|
209 | overridesResolver: (props, styles) => {
|
210 | const {
|
211 | ownerState
|
212 | } = props;
|
213 | return [styles.bar, styles[`barColor${(0, _capitalize.default)(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar1Indeterminate, ownerState.variant === 'determinate' && styles.bar1Determinate, ownerState.variant === 'buffer' && styles.bar1Buffer];
|
214 | }
|
215 | })((0, _memoTheme.default)(({
|
216 | theme
|
217 | }) => ({
|
218 | width: '100%',
|
219 | position: 'absolute',
|
220 | left: 0,
|
221 | bottom: 0,
|
222 | top: 0,
|
223 | transition: 'transform 0.2s linear',
|
224 | transformOrigin: 'left',
|
225 | variants: [{
|
226 | props: {
|
227 | color: 'inherit'
|
228 | },
|
229 | style: {
|
230 | backgroundColor: 'currentColor'
|
231 | }
|
232 | }, ...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)()).map(([color]) => ({
|
233 | props: {
|
234 | color
|
235 | },
|
236 | style: {
|
237 | backgroundColor: (theme.vars || theme).palette[color].main
|
238 | }
|
239 | })), {
|
240 | props: {
|
241 | variant: 'determinate'
|
242 | },
|
243 | style: {
|
244 | transition: `transform .${TRANSITION_DURATION}s linear`
|
245 | }
|
246 | }, {
|
247 | props: {
|
248 | variant: 'buffer'
|
249 | },
|
250 | style: {
|
251 | zIndex: 1,
|
252 | transition: `transform .${TRANSITION_DURATION}s linear`
|
253 | }
|
254 | }, {
|
255 | props: ({
|
256 | ownerState
|
257 | }) => ownerState.variant === 'indeterminate' || ownerState.variant === 'query',
|
258 | style: {
|
259 | width: 'auto'
|
260 | }
|
261 | }, {
|
262 | props: ({
|
263 | ownerState
|
264 | }) => ownerState.variant === 'indeterminate' || ownerState.variant === 'query',
|
265 | style: indeterminate1Animation || {
|
266 | animation: `${indeterminate1Keyframe} 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite`
|
267 | }
|
268 | }]
|
269 | })));
|
270 | const LinearProgressBar2 = (0, _zeroStyled.styled)('span', {
|
271 | name: 'MuiLinearProgress',
|
272 | slot: 'Bar2',
|
273 | overridesResolver: (props, styles) => {
|
274 | const {
|
275 | ownerState
|
276 | } = props;
|
277 | return [styles.bar, styles[`barColor${(0, _capitalize.default)(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar2Indeterminate, ownerState.variant === 'buffer' && styles.bar2Buffer];
|
278 | }
|
279 | })((0, _memoTheme.default)(({
|
280 | theme
|
281 | }) => ({
|
282 | width: '100%',
|
283 | position: 'absolute',
|
284 | left: 0,
|
285 | bottom: 0,
|
286 | top: 0,
|
287 | transition: 'transform 0.2s linear',
|
288 | transformOrigin: 'left',
|
289 | variants: [...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)()).map(([color]) => ({
|
290 | props: {
|
291 | color
|
292 | },
|
293 | style: {
|
294 | '--LinearProgressBar2-barColor': (theme.vars || theme).palette[color].main
|
295 | }
|
296 | })), {
|
297 | props: ({
|
298 | ownerState
|
299 | }) => ownerState.variant !== 'buffer' && ownerState.color !== 'inherit',
|
300 | style: {
|
301 | backgroundColor: 'var(--LinearProgressBar2-barColor, currentColor)'
|
302 | }
|
303 | }, {
|
304 | props: ({
|
305 | ownerState
|
306 | }) => ownerState.variant !== 'buffer' && ownerState.color === 'inherit',
|
307 | style: {
|
308 | backgroundColor: 'currentColor'
|
309 | }
|
310 | }, {
|
311 | props: {
|
312 | color: 'inherit'
|
313 | },
|
314 | style: {
|
315 | opacity: 0.3
|
316 | }
|
317 | }, ...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)()).map(([color]) => ({
|
318 | props: {
|
319 | color,
|
320 | variant: 'buffer'
|
321 | },
|
322 | style: {
|
323 | backgroundColor: getColorShade(theme, color),
|
324 | transition: `transform .${TRANSITION_DURATION}s linear`
|
325 | }
|
326 | })), {
|
327 | props: ({
|
328 | ownerState
|
329 | }) => ownerState.variant === 'indeterminate' || ownerState.variant === 'query',
|
330 | style: {
|
331 | width: 'auto'
|
332 | }
|
333 | }, {
|
334 | props: ({
|
335 | ownerState
|
336 | }) => ownerState.variant === 'indeterminate' || ownerState.variant === 'query',
|
337 | style: indeterminate2Animation || {
|
338 | animation: `${indeterminate2Keyframe} 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) 1.15s infinite`
|
339 | }
|
340 | }]
|
341 | })));
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 | const LinearProgress = React.forwardRef(function LinearProgress(inProps, ref) {
|
351 | const props = (0, _DefaultPropsProvider.useDefaultProps)({
|
352 | props: inProps,
|
353 | name: 'MuiLinearProgress'
|
354 | });
|
355 | const {
|
356 | className,
|
357 | color = 'primary',
|
358 | value,
|
359 | valueBuffer,
|
360 | variant = 'indeterminate',
|
361 | ...other
|
362 | } = props;
|
363 | const ownerState = {
|
364 | ...props,
|
365 | color,
|
366 | variant
|
367 | };
|
368 | const classes = useUtilityClasses(ownerState);
|
369 | const isRtl = (0, _RtlProvider.useRtl)();
|
370 | const rootProps = {};
|
371 | const inlineStyles = {
|
372 | bar1: {},
|
373 | bar2: {}
|
374 | };
|
375 | if (variant === 'determinate' || variant === 'buffer') {
|
376 | if (value !== undefined) {
|
377 | rootProps['aria-valuenow'] = Math.round(value);
|
378 | rootProps['aria-valuemin'] = 0;
|
379 | rootProps['aria-valuemax'] = 100;
|
380 | let transform = value - 100;
|
381 | if (isRtl) {
|
382 | transform = -transform;
|
383 | }
|
384 | inlineStyles.bar1.transform = `translateX(${transform}%)`;
|
385 | } else if (process.env.NODE_ENV !== 'production') {
|
386 | console.error('MUI: You need to provide a value prop ' + 'when using the determinate or buffer variant of LinearProgress .');
|
387 | }
|
388 | }
|
389 | if (variant === 'buffer') {
|
390 | if (valueBuffer !== undefined) {
|
391 | let transform = (valueBuffer || 0) - 100;
|
392 | if (isRtl) {
|
393 | transform = -transform;
|
394 | }
|
395 | inlineStyles.bar2.transform = `translateX(${transform}%)`;
|
396 | } else if (process.env.NODE_ENV !== 'production') {
|
397 | console.error('MUI: You need to provide a valueBuffer prop ' + 'when using the buffer variant of LinearProgress.');
|
398 | }
|
399 | }
|
400 | return (0, _jsxRuntime.jsxs)(LinearProgressRoot, {
|
401 | className: (0, _clsx.default)(classes.root, className),
|
402 | ownerState: ownerState,
|
403 | role: "progressbar",
|
404 | ...rootProps,
|
405 | ref: ref,
|
406 | ...other,
|
407 | children: [variant === 'buffer' ? (0, _jsxRuntime.jsx)(LinearProgressDashed, {
|
408 | className: classes.dashed,
|
409 | ownerState: ownerState
|
410 | }) : null, (0, _jsxRuntime.jsx)(LinearProgressBar1, {
|
411 | className: classes.bar1,
|
412 | ownerState: ownerState,
|
413 | style: inlineStyles.bar1
|
414 | }), variant === 'determinate' ? null : (0, _jsxRuntime.jsx)(LinearProgressBar2, {
|
415 | className: classes.bar2,
|
416 | ownerState: ownerState,
|
417 | style: inlineStyles.bar2
|
418 | })]
|
419 | });
|
420 | });
|
421 | process.env.NODE_ENV !== "production" ? LinearProgress.propTypes = {
|
422 |
|
423 |
|
424 |
|
425 |
|
426 | |
427 |
|
428 |
|
429 | classes: _propTypes.default.object,
|
430 | |
431 |
|
432 |
|
433 | className: _propTypes.default.string,
|
434 | |
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 | color: _propTypes.default .oneOfType([_propTypes.default.oneOf(['inherit', 'primary', 'secondary']), _propTypes.default.string]),
|
441 | |
442 |
|
443 |
|
444 | sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
445 | |
446 |
|
447 |
|
448 |
|
449 | value: _propTypes.default.number,
|
450 | |
451 |
|
452 |
|
453 |
|
454 | valueBuffer: _propTypes.default.number,
|
455 | |
456 |
|
457 |
|
458 |
|
459 |
|
460 | variant: _propTypes.default.oneOf(['buffer', 'determinate', 'indeterminate', 'query'])
|
461 | } : void 0;
|
462 | var _default = exports.default = LinearProgress; |
\ | No newline at end of file |