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 _utils = require("@material-ui/utils");
|
23 |
|
24 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
25 |
|
26 | var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
27 |
|
28 | var SIZE = 44;
|
29 |
|
30 | var styles = function styles(theme) {
|
31 | return {
|
32 |
|
33 | root: {
|
34 | display: 'inline-block'
|
35 | },
|
36 |
|
37 |
|
38 | static: {
|
39 | transition: theme.transitions.create('transform')
|
40 | },
|
41 |
|
42 |
|
43 | indeterminate: {
|
44 | animation: '$circular-rotate 1.4s linear infinite'
|
45 | },
|
46 |
|
47 |
|
48 | determinate: {
|
49 | transition: theme.transitions.create('transform')
|
50 | },
|
51 |
|
52 |
|
53 | colorPrimary: {
|
54 | color: theme.palette.primary.main
|
55 | },
|
56 |
|
57 |
|
58 | colorSecondary: {
|
59 | color: theme.palette.secondary.main
|
60 | },
|
61 |
|
62 |
|
63 | svg: {
|
64 | display: 'block'
|
65 |
|
66 | },
|
67 |
|
68 |
|
69 | circle: {
|
70 | stroke: 'currentColor'
|
71 |
|
72 |
|
73 | },
|
74 |
|
75 |
|
76 | circleStatic: {
|
77 | transition: theme.transitions.create('stroke-dashoffset')
|
78 | },
|
79 |
|
80 |
|
81 | circleIndeterminate: {
|
82 | animation: '$circular-dash 1.4s ease-in-out infinite',
|
83 |
|
84 | strokeDasharray: '80px, 200px',
|
85 | strokeDashoffset: '0px'
|
86 |
|
87 | },
|
88 |
|
89 |
|
90 | circleDeterminate: {
|
91 | transition: theme.transitions.create('stroke-dashoffset')
|
92 | },
|
93 | '@keyframes circular-rotate': {
|
94 | '0%': {
|
95 |
|
96 | transformOrigin: '50% 50%'
|
97 | },
|
98 | '100%': {
|
99 | transform: 'rotate(360deg)'
|
100 | }
|
101 | },
|
102 | '@keyframes circular-dash': {
|
103 | '0%': {
|
104 | strokeDasharray: '1px, 200px',
|
105 | strokeDashoffset: '0px'
|
106 | },
|
107 | '50%': {
|
108 | strokeDasharray: '100px, 200px',
|
109 | strokeDashoffset: '-15px'
|
110 | },
|
111 | '100%': {
|
112 | strokeDasharray: '100px, 200px',
|
113 | strokeDashoffset: '-125px'
|
114 | }
|
115 | },
|
116 |
|
117 |
|
118 | circleDisableShrink: {
|
119 | animation: 'none'
|
120 | }
|
121 | };
|
122 | };
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 | exports.styles = styles;
|
133 | var CircularProgress = React.forwardRef(function CircularProgress(props, ref) {
|
134 | var classes = props.classes,
|
135 | className = props.className,
|
136 | _props$color = props.color,
|
137 | color = _props$color === void 0 ? 'primary' : _props$color,
|
138 | _props$disableShrink = props.disableShrink,
|
139 | disableShrink = _props$disableShrink === void 0 ? false : _props$disableShrink,
|
140 | _props$size = props.size,
|
141 | size = _props$size === void 0 ? 40 : _props$size,
|
142 | style = props.style,
|
143 | _props$thickness = props.thickness,
|
144 | thickness = _props$thickness === void 0 ? 3.6 : _props$thickness,
|
145 | _props$value = props.value,
|
146 | value = _props$value === void 0 ? 0 : _props$value,
|
147 | _props$variant = props.variant,
|
148 | variant = _props$variant === void 0 ? 'indeterminate' : _props$variant,
|
149 | other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "color", "disableShrink", "size", "style", "thickness", "value", "variant"]);
|
150 | var circleStyle = {};
|
151 | var rootStyle = {};
|
152 | var rootProps = {};
|
153 |
|
154 | if (variant === 'determinate' || variant === 'static') {
|
155 | var circumference = 2 * Math.PI * ((SIZE - thickness) / 2);
|
156 | circleStyle.strokeDasharray = circumference.toFixed(3);
|
157 | rootProps['aria-valuenow'] = Math.round(value);
|
158 | circleStyle.strokeDashoffset = "".concat(((100 - value) / 100 * circumference).toFixed(3), "px");
|
159 | rootStyle.transform = 'rotate(-90deg)';
|
160 | }
|
161 |
|
162 | return React.createElement("div", (0, _extends2.default)({
|
163 | className: (0, _clsx.default)(classes.root, className, color !== 'inherit' && classes["color".concat((0, _capitalize.default)(color))], {
|
164 | 'determinate': classes.determinate,
|
165 | 'indeterminate': classes.indeterminate,
|
166 | 'static': classes.static
|
167 | }[variant]),
|
168 | style: (0, _extends2.default)({
|
169 | width: size,
|
170 | height: size
|
171 | }, rootStyle, style),
|
172 | ref: ref,
|
173 | role: "progressbar"
|
174 | }, rootProps, other), React.createElement("svg", {
|
175 | className: classes.svg,
|
176 | viewBox: "".concat(SIZE / 2, " ").concat(SIZE / 2, " ").concat(SIZE, " ").concat(SIZE)
|
177 | }, React.createElement("circle", {
|
178 | className: (0, _clsx.default)(classes.circle, disableShrink && classes.circleDisableShrink, {
|
179 | 'determinate': classes.circleDeterminate,
|
180 | 'indeterminate': classes.circleIndeterminate,
|
181 | 'static': classes.circleStatic
|
182 | }[variant]),
|
183 | style: circleStyle,
|
184 | cx: SIZE,
|
185 | cy: SIZE,
|
186 | r: (SIZE - thickness) / 2,
|
187 | fill: "none",
|
188 | strokeWidth: thickness
|
189 | })));
|
190 | });
|
191 | process.env.NODE_ENV !== "production" ? CircularProgress.propTypes = {
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | |
198 |
|
199 |
|
200 |
|
201 | classes: _propTypes.default.object,
|
202 |
|
203 | |
204 |
|
205 |
|
206 | className: _propTypes.default.string,
|
207 |
|
208 | |
209 |
|
210 |
|
211 | color: _propTypes.default.oneOf(['inherit', 'primary', 'secondary']),
|
212 |
|
213 | |
214 |
|
215 |
|
216 |
|
217 | disableShrink: (0, _utils.chainPropTypes)(_propTypes.default.bool, function (props) {
|
218 | if (props.disableShrink && props.variant && props.variant !== 'indeterminate') {
|
219 | return new Error('Material-UI: You have provided the `disableShrink` prop ' + 'with a variant other than `indeterminate`. This will have no effect.');
|
220 | }
|
221 |
|
222 | return null;
|
223 | }),
|
224 |
|
225 | |
226 |
|
227 |
|
228 |
|
229 |
|
230 | size: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
231 |
|
232 | |
233 |
|
234 |
|
235 | style: _propTypes.default.object,
|
236 |
|
237 | |
238 |
|
239 |
|
240 | thickness: _propTypes.default.number,
|
241 |
|
242 | |
243 |
|
244 |
|
245 |
|
246 | value: _propTypes.default.number,
|
247 |
|
248 | |
249 |
|
250 |
|
251 |
|
252 | variant: (0, _utils.chainPropTypes)(_propTypes.default.oneOf(['determinate', 'indeterminate', 'static']), function (props) {
|
253 | var variant = props.variant;
|
254 |
|
255 | if (variant === 'static') {
|
256 | throw new Error('Material-UI: `variant="static"` was deprecated. Use `variant="determinate"` instead.');
|
257 | }
|
258 |
|
259 | return null;
|
260 | })
|
261 | } : void 0;
|
262 |
|
263 | var _default = (0, _withStyles.default)(styles, {
|
264 | name: 'MuiCircularProgress',
|
265 | flip: false
|
266 | })(CircularProgress);
|
267 |
|
268 | exports.default = _default; |
\ | No newline at end of file |