@instructure/ui-progress 11.7.3 → 11.7.4-pr-snapshot-1781695314229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +1 -0
  3. package/{lib/ProgressBar/v2/props.js → babel.config.cjs} +12 -7
  4. package/es/ProgressBar/v1/index.js +5 -4
  5. package/es/ProgressBar/v2/index.js +4 -3
  6. package/es/ProgressCircle/v1/index.js +5 -4
  7. package/es/ProgressCircle/v2/index.js +4 -3
  8. package/es/exports/a.js +3 -2
  9. package/es/exports/b.js +3 -2
  10. package/package.json +13 -18
  11. package/src/ProgressBar/v1/index.tsx +4 -3
  12. package/src/ProgressBar/v2/index.tsx +3 -2
  13. package/src/ProgressCircle/v1/index.tsx +4 -3
  14. package/src/ProgressCircle/v2/index.tsx +3 -2
  15. package/src/exports/a.ts +2 -2
  16. package/src/exports/b.ts +2 -2
  17. package/tsconfig.build.tsbuildinfo +1 -1
  18. package/types/ProgressBar/v1/index.d.ts +1 -0
  19. package/types/ProgressBar/v1/index.d.ts.map +1 -1
  20. package/types/ProgressBar/v2/index.d.ts +1 -0
  21. package/types/ProgressBar/v2/index.d.ts.map +1 -1
  22. package/types/ProgressCircle/v1/index.d.ts +1 -0
  23. package/types/ProgressCircle/v1/index.d.ts.map +1 -1
  24. package/types/ProgressCircle/v2/index.d.ts +1 -0
  25. package/types/ProgressCircle/v2/index.d.ts.map +1 -1
  26. package/types/exports/a.d.ts +2 -2
  27. package/types/exports/a.d.ts.map +1 -1
  28. package/types/exports/b.d.ts +2 -2
  29. package/types/exports/b.d.ts.map +1 -1
  30. package/lib/ProgressBar/v1/index.js +0 -137
  31. package/lib/ProgressBar/v1/props.js +0 -31
  32. package/lib/ProgressBar/v1/styles.js +0 -216
  33. package/lib/ProgressBar/v1/theme.js +0 -100
  34. package/lib/ProgressBar/v2/index.js +0 -136
  35. package/lib/ProgressBar/v2/styles.js +0 -243
  36. package/lib/ProgressCircle/v1/index.js +0 -182
  37. package/lib/ProgressCircle/v1/props.js +0 -31
  38. package/lib/ProgressCircle/v1/styles.js +0 -357
  39. package/lib/ProgressCircle/v1/theme.js +0 -146
  40. package/lib/ProgressCircle/v2/index.js +0 -181
  41. package/lib/ProgressCircle/v2/props.js +0 -31
  42. package/lib/ProgressCircle/v2/styles.js +0 -357
  43. package/lib/exports/a.js +0 -19
  44. package/lib/exports/b.js +0 -19
  45. package/lib/package.json +0 -1
@@ -1,357 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @param {Object} state the state of the component, the style is applied to
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = (componentTheme, props, state) => {
42
- const {
43
- size,
44
- color,
45
- meterColor,
46
- valueNow = 0,
47
- valueMax = 100
48
- } = props;
49
- const {
50
- shouldAnimateOnMount
51
- } = state;
52
- const getMeterColorClassName = typeof meterColor === 'function' ? meterColor({
53
- valueNow,
54
- valueMax
55
- }) : meterColor;
56
- const getCircumference = () => {
57
- const camelSize = size === 'x-small' ? 'xSmall' : size;
58
- // get the circumference of the meter circle
59
- return parseFloat(componentTheme[`${camelSize}Circumference`]);
60
- };
61
- const getRadii = () => {
62
- const camelSize = size === 'x-small' ? 'xSmall' : size;
63
- return {
64
- radius: componentTheme[`${camelSize}Radius`],
65
- borderOffsetRadius: componentTheme[`${camelSize}BorderOffset`]
66
- };
67
- };
68
- const getDashOffset = () => {
69
- // send the stroke-dashoffset to the meter circle, checking
70
- // to make sure current value doesn't exceed max value
71
- if (valueNow < valueMax) {
72
- const circumference = getCircumference();
73
- // figure out how much offset to give the stroke to show the % complete
74
- return circumference - valueNow / valueMax * circumference;
75
- } else {
76
- return 0;
77
- }
78
- };
79
-
80
- /*
81
- Using !important on the meter shouldAnimateOnMount versions
82
- to guarantee that the bars will start showing 0 if the
83
- animateOnMount prop is set
84
- */
85
- const sizeVariants = {
86
- 'x-small': {
87
- progressCircle: {
88
- width: componentTheme.xSmallSize,
89
- height: componentTheme.xSmallSize
90
- },
91
- circle: {
92
- width: componentTheme.xSmallSize,
93
- height: componentTheme.xSmallSize
94
- },
95
- value: {
96
- padding: '0.5rem'
97
- },
98
- border: {
99
- transformOrigin: `${componentTheme.xSmallTransform} ${componentTheme.xSmallTransform}`
100
- },
101
- track: {
102
- transformOrigin: `${componentTheme.xSmallTransform} ${componentTheme.xSmallTransform}`,
103
- strokeWidth: componentTheme.xSmallStrokeWidth
104
- },
105
- meter: {
106
- strokeWidth: componentTheme.xSmallStrokeWidth,
107
- strokeDasharray: componentTheme.xSmallCircumference,
108
- ...(shouldAnimateOnMount && {
109
- strokeDashoffset: `${componentTheme.xSmallCircumference} !important`
110
- })
111
- }
112
- },
113
- small: {
114
- progressCircle: {
115
- width: componentTheme.smallSize,
116
- height: componentTheme.smallSize
117
- },
118
- circle: {
119
- width: componentTheme.smallSize,
120
- height: componentTheme.smallSize
121
- },
122
- value: {},
123
- border: {
124
- transformOrigin: `${componentTheme.smallTransform} ${componentTheme.smallTransform}`
125
- },
126
- track: {
127
- transformOrigin: `${componentTheme.smallTransform} ${componentTheme.smallTransform}`,
128
- strokeWidth: componentTheme.smallStrokeWidth
129
- },
130
- meter: {
131
- strokeWidth: componentTheme.smallStrokeWidth,
132
- strokeDasharray: componentTheme.smallCircumference,
133
- ...(shouldAnimateOnMount && {
134
- strokeDashoffset: `${componentTheme.smallCircumference} !important`
135
- })
136
- }
137
- },
138
- medium: {
139
- progressCircle: {
140
- width: componentTheme.mediumSize,
141
- height: componentTheme.mediumSize
142
- },
143
- circle: {
144
- width: componentTheme.mediumSize,
145
- height: componentTheme.mediumSize
146
- },
147
- value: {},
148
- border: {
149
- transformOrigin: `${componentTheme.mediumTransform} ${componentTheme.mediumTransform}`
150
- },
151
- track: {
152
- transformOrigin: `${componentTheme.mediumTransform} ${componentTheme.mediumTransform}`,
153
- strokeWidth: componentTheme.mediumStrokeWidth
154
- },
155
- meter: {
156
- strokeWidth: componentTheme.mediumStrokeWidth,
157
- strokeDasharray: componentTheme.mediumCircumference,
158
- ...(shouldAnimateOnMount && {
159
- strokeDashoffset: `${componentTheme.mediumCircumference} !important`
160
- })
161
- }
162
- },
163
- large: {
164
- progressCircle: {
165
- width: componentTheme.largeSize,
166
- height: componentTheme.largeSize
167
- },
168
- circle: {
169
- width: componentTheme.largeSize,
170
- height: componentTheme.largeSize
171
- },
172
- value: {},
173
- border: {
174
- transformOrigin: `${componentTheme.largeTransform} ${componentTheme.largeTransform}`
175
- },
176
- track: {
177
- transformOrigin: `${componentTheme.largeTransform} ${componentTheme.largeTransform}`,
178
- strokeWidth: componentTheme.largeStrokeWidth
179
- },
180
- meter: {
181
- strokeWidth: componentTheme.largeStrokeWidth,
182
- strokeDasharray: componentTheme.largeCircumference,
183
- ...(shouldAnimateOnMount && {
184
- strokeDashoffset: `${componentTheme.largeCircumference} !important`
185
- })
186
- }
187
- }
188
- };
189
- const colorVariants = {
190
- primary: {
191
- track: {
192
- stroke: componentTheme.trackColor
193
- },
194
- value: {
195
- color: componentTheme.color
196
- },
197
- border: {
198
- stroke: componentTheme.trackBorderColor
199
- }
200
- },
201
- 'primary-inverse': {
202
- track: {
203
- stroke: componentTheme.trackColorInverse
204
- },
205
- value: {
206
- color: componentTheme.colorInverse
207
- },
208
- border: {
209
- stroke: componentTheme.trackBorderColorInverse
210
- }
211
- }
212
- };
213
- const meterColorVariants = {
214
- primary: {
215
- brand: {
216
- stroke: componentTheme.meterColorBrand
217
- },
218
- info: {
219
- stroke: componentTheme.meterColorInfo
220
- },
221
- warning: {
222
- stroke: componentTheme.meterColorWarning
223
- },
224
- danger: {
225
- stroke: componentTheme.meterColorDanger
226
- },
227
- alert: {
228
- stroke: componentTheme.meterColorAlert
229
- },
230
- success: {
231
- stroke: componentTheme.meterColorSuccess
232
- }
233
- },
234
- 'primary-inverse': {
235
- brand: {
236
- stroke: componentTheme.meterColorBrandInverse
237
- },
238
- info: {
239
- stroke: componentTheme.meterColorInfoInverse
240
- },
241
- warning: {
242
- stroke: componentTheme.meterColorWarningInverse
243
- },
244
- danger: {
245
- stroke: componentTheme.meterColorDangerInverse
246
- },
247
- alert: {
248
- stroke: componentTheme.meterColorAlertInverse
249
- },
250
- success: {
251
- stroke: componentTheme.meterColorSuccessInverse
252
- }
253
- }
254
- };
255
- return {
256
- progressCircle: {
257
- label: 'progressCircle',
258
- display: 'inline-block',
259
- verticalAlign: 'middle',
260
- position: 'relative',
261
- overflow: 'hidden',
262
- /*
263
- Seems like a good idea to reset font-size because
264
- the SVG uses ems and might inherit a container's
265
- font-size
266
- */
267
- fontSize: '1rem',
268
- fontFamily: componentTheme.fontFamily,
269
- fontWeight: componentTheme.fontWeight,
270
- lineHeight: componentTheme.lineHeight,
271
- ...sizeVariants[size].progressCircle
272
- },
273
- center: {
274
- label: 'progressCircle__center',
275
- transition: 'all 0.5s',
276
- transitionDelay: '1s',
277
- display: 'block',
278
- position: 'absolute',
279
- transform: 'translate3d(0, 0, 0)',
280
- top: 0,
281
- left: 0,
282
- height: '100%',
283
- width: '100%',
284
- borderRadius: '50%',
285
- ...(shouldAnimateOnMount && {
286
- opacity: 0,
287
- transform: 'translate3d(0, 10%, 0)'
288
- })
289
- },
290
- value: {
291
- label: 'progressCircle__value',
292
- boxSizing: 'border-box',
293
- wordWrap: 'break-word',
294
- textAlign: 'center',
295
- borderRadius: '50%',
296
- display: 'flex',
297
- alignItems: 'center',
298
- justifyContent: 'center',
299
- padding: '1.5rem',
300
- width: '100%',
301
- height: '100%',
302
- lineHeight: 1,
303
- ...sizeVariants[size].value,
304
- ...colorVariants[color].value
305
- },
306
- circle: {
307
- label: 'progressCircle__circle',
308
- transform: 'rotate(-90deg)',
309
- display: 'block',
310
- position: 'absolute',
311
- top: 0,
312
- left: 0,
313
- ...sizeVariants[size].circle
314
- },
315
- track: {
316
- label: 'progressCircle__track',
317
- fill: 'none',
318
- opacity: 1,
319
- transition: 'all 0.5s',
320
- transitionDelay: '0.2s',
321
- transform: 'translate3d(0, 0, 0)',
322
- ...sizeVariants[size].track,
323
- ...colorVariants[color].track,
324
- ...(shouldAnimateOnMount && {
325
- opacity: 0,
326
- transform: 'translate3d(0, 0, 0)'
327
- })
328
- },
329
- border: {
330
- label: 'progressCircle__border',
331
- fill: 'none',
332
- opacity: 1,
333
- transition: 'all 0.5s',
334
- transform: 'translate3d(0, 0, 0) scale(1)',
335
- ...sizeVariants[size].border,
336
- ...colorVariants[color].border,
337
- ...(shouldAnimateOnMount && {
338
- opacity: 0,
339
- transform: 'translate3d(0, 0, 0) scale(0.75)'
340
- })
341
- },
342
- meter: {
343
- label: 'progressCircle__meter',
344
- fill: 'none',
345
- transition: 'stroke-dashoffset 1s',
346
- transform: 'translate3d(0, 0, 0)',
347
- ...sizeVariants[size].meter,
348
- ...(getMeterColorClassName && meterColorVariants[color][getMeterColorClassName]),
349
- ...(shouldAnimateOnMount && {
350
- opacity: 0
351
- })
352
- },
353
- radii: getRadii(),
354
- dashOffset: getDashOffset()
355
- };
356
- };
357
- var _default = exports.default = generateStyle;
@@ -1,146 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- const radius = {
32
- xSmall: 1,
33
- small: 1.8,
34
- medium: 2.75,
35
- large: 3.5
36
- };
37
- const size = {
38
- xSmall: 3,
39
- small: 5,
40
- medium: 7,
41
- large: 9
42
- };
43
- const strokeWidth = {
44
- xSmall: 0.185,
45
- small: 0.5,
46
- medium: 0.625,
47
- large: 0.875
48
- };
49
-
50
- // Necessary to get the 1px border line to go "under" the meter
51
- // strokeWidth is divided in half because SVG strokeWidth is
52
- // centered along the path of the stroke, unlike CSS
53
- const borderWidth = 0.0625;
54
- const borderOffsetRadius = {
55
- xSmall: radius.xSmall - strokeWidth.xSmall / 2 + borderWidth,
56
- small: radius.small - strokeWidth.small / 2 + borderWidth,
57
- medium: radius.medium - strokeWidth.medium / 2 + borderWidth,
58
- large: radius.large - strokeWidth.large / 2 + borderWidth
59
- };
60
- const circumference = function (r) {
61
- return (2 * Math.PI * r).toFixed(3);
62
- };
63
- const transform = function (s) {
64
- return s / 2;
65
- };
66
-
67
- /**
68
- * Generates the theme object for the component from the theme and provided additional information
69
- * @param {Object} theme The actual theme object.
70
- * @return {Object} The final theme object with the overrides and component variables
71
- */
72
- const generateComponentTheme = theme => {
73
- const {
74
- colors,
75
- typography,
76
- key: themeName
77
- } = theme;
78
- const themeSpecificStyle = {
79
- canvas: {
80
- color: theme['ic-brand-font-color-dark'],
81
- meterColorBrand: theme['ic-brand-primary']
82
- },
83
- 'canvas-high-contrast': {
84
- meterColorBrandInverse: colors?.contrasts?.white1010,
85
- meterColorSuccessInverse: colors?.contrasts?.white1010,
86
- meterColorInfoInverse: colors?.contrasts?.white1010,
87
- meterColorAlertInverse: colors?.contrasts?.white1010,
88
- meterColorWarningInverse: colors?.contrasts?.white1010,
89
- meterColorDangerInverse: colors?.contrasts?.white1010
90
- }
91
- };
92
- const componentVariables = {
93
- fontFamily: typography?.fontFamily,
94
- fontWeight: typography?.fontWeightNormal,
95
- lineHeight: typography?.lineHeightCondensed,
96
- xSmallSize: `${size.xSmall}em`,
97
- xSmallRadius: `${radius.xSmall}em`,
98
- xSmallCircumference: `${circumference(radius.xSmall)}em`,
99
- xSmallTransform: `${transform(size.xSmall)}em`,
100
- xSmallStrokeWidth: `${strokeWidth.xSmall}em`,
101
- xSmallBorderOffset: `${borderOffsetRadius.xSmall}em`,
102
- smallSize: `${size.small}em`,
103
- smallRadius: `${radius.small}em`,
104
- smallCircumference: `${circumference(radius.small)}em`,
105
- smallTransform: `${transform(size.small)}em`,
106
- smallStrokeWidth: `${strokeWidth.small}em`,
107
- smallBorderOffset: `${borderOffsetRadius.small}em`,
108
- mediumSize: `${size.medium}em`,
109
- mediumRadius: `${radius.medium}em`,
110
- mediumCircumference: `${circumference(radius.medium)}em`,
111
- mediumTransform: `${transform(size.medium)}em`,
112
- mediumStrokeWidth: `${strokeWidth.medium}em`,
113
- mediumBorderOffset: `${borderOffsetRadius.medium}em`,
114
- largeSize: `${size.large}em`,
115
- largeRadius: `${radius.large}em`,
116
- largeCircumference: `${circumference(radius.large)}em`,
117
- largeTransform: `${transform(size.large)}em`,
118
- largeStrokeWidth: `${strokeWidth.large}em`,
119
- largeBorderOffset: `${borderOffsetRadius.large}em`,
120
- color: colors?.contrasts?.grey125125,
121
- colorInverse: colors?.contrasts?.white1010,
122
- trackColor: colors?.contrasts?.white1010,
123
- trackColorInverse: 'transparent',
124
- trackBorderColor: colors?.contrasts?.grey3045,
125
- trackBorderColorInverse: colors?.contrasts?.white1010,
126
- // variables are split out for inverse to allow
127
- // color value changes for inverse-high-contrast
128
- meterColorBrand: colors?.contrasts?.blue4570,
129
- meterColorBrandInverse: colors?.contrasts?.blue4570,
130
- meterColorInfo: colors?.contrasts?.blue4570,
131
- meterColorInfoInverse: colors?.contrasts?.blue4570,
132
- meterColorSuccess: colors?.contrasts?.green4570,
133
- meterColorSuccessInverse: colors?.contrasts?.green4570,
134
- meterColorDanger: colors?.contrasts?.red4570,
135
- meterColorDangerInverse: colors?.contrasts?.red4570,
136
- meterColorAlert: colors?.contrasts?.blue4570,
137
- meterColorAlertInverse: colors?.contrasts?.blue4570,
138
- meterColorWarning: colors?.contrasts?.orange4570,
139
- meterColorWarningInverse: colors?.contrasts?.orange4570
140
- };
141
- return {
142
- ...componentVariables,
143
- ...themeSpecificStyle[themeName]
144
- };
145
- };
146
- var _default = exports.default = generateComponentTheme;
@@ -1,181 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.ProgressCircle = void 0;
8
- var _react = require("react");
9
- var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
10
- var _latest = require("@instructure/ui-view/latest");
11
- var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
12
- var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
13
- var _emotion = require("@instructure/emotion");
14
- var _styles = _interopRequireDefault(require("./styles"));
15
- var _props = require("./props");
16
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
- var _dec, _class;
18
- /*
19
- * The MIT License (MIT)
20
- *
21
- * Copyright (c) 2015 - present Instructure, Inc.
22
- *
23
- * Permission is hereby granted, free of charge, to any person obtaining a copy
24
- * of this software and associated documentation files (the "Software"), to deal
25
- * in the Software without restriction, including without limitation the rights
26
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
- * copies of the Software, and to permit persons to whom the Software is
28
- * furnished to do so, subject to the following conditions:
29
- *
30
- * The above copyright notice and this permission notice shall be included in all
31
- * copies or substantial portions of the Software.
32
- *
33
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
- * SOFTWARE.
40
- */
41
- /**
42
- ---
43
- category: components
44
- ---
45
- **/
46
- let ProgressCircle = exports.ProgressCircle = (_dec = (0, _emotion.withStyleNew)(_styles.default), _dec(_class = class ProgressCircle extends _react.Component {
47
- static displayName = "ProgressCircle";
48
- static componentId = 'ProgressCircle';
49
- static allowedProps = _props.allowedProps;
50
- static defaultProps = {
51
- formatScreenReaderValue: ({
52
- valueNow,
53
- valueMax
54
- }) => `${valueNow} / ${valueMax}`,
55
- size: 'medium',
56
- valueMax: 100,
57
- valueNow: 0,
58
- as: 'div',
59
- color: 'primary',
60
- shouldAnimateOnMount: false,
61
- // default to showing `success` color on completion
62
- meterColor: ({
63
- valueNow,
64
- valueMax
65
- }) => valueNow / valueMax >= 1 ? 'success' : 'brand'
66
- };
67
- _timeouts = [];
68
- ref = null;
69
- constructor(props) {
70
- super(props);
71
- this.state = {
72
- shouldAnimateOnMount: props.shouldAnimateOnMount
73
- };
74
- }
75
- handleRef = el => {
76
- const {
77
- elementRef
78
- } = this.props;
79
- this.ref = el;
80
- if (typeof elementRef === 'function') {
81
- elementRef(el);
82
- }
83
- };
84
- get makeStylesVariables() {
85
- return {
86
- shouldAnimateOnMount: this.state.shouldAnimateOnMount
87
- };
88
- }
89
- componentDidMount() {
90
- if (this.state.shouldAnimateOnMount) {
91
- this._timeouts.push(setTimeout(() => {
92
- this.setState({
93
- shouldAnimateOnMount: false
94
- });
95
- }, this.props.animationDelay || 500));
96
- }
97
- this.props.makeStyles?.(this.makeStylesVariables);
98
- }
99
- componentDidUpdate() {
100
- this.props.makeStyles?.(this.makeStylesVariables);
101
- }
102
- componentWillUnmount() {
103
- this._timeouts.forEach(timeout => clearTimeout(timeout));
104
- }
105
- render() {
106
- const {
107
- color,
108
- renderValue,
109
- formatScreenReaderValue,
110
- meterColor,
111
- valueNow,
112
- valueMax,
113
- screenReaderLabel,
114
- size,
115
- styles,
116
- ...props
117
- } = this.props;
118
- const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
119
- valueNow: valueNow,
120
- valueMax: valueMax
121
- }) : undefined;
122
- // consolidating the label and aria-valuetext to put in aria-label because
123
- // NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
124
- // But leaving aria-valuetext because JAWS ignores aria-label
125
- const labelAndValueText = `${screenReaderLabel} ${valueText}`;
126
- const value = (0, _callRenderProp.callRenderProp)(renderValue, {
127
- valueNow: valueNow,
128
- valueMax: valueMax
129
- });
130
- const style = {
131
- strokeDashoffset: `${styles?.dashOffset}em`
132
- };
133
- return (0, _jsxRuntime.jsxs)(_latest.View, {
134
- ...(0, _passthroughProps.passthroughProps)(props),
135
- as: this.props.as,
136
- elementRef: this.handleRef,
137
- css: styles?.progressCircle,
138
- margin: this.props.margin,
139
- "data-cid": "ProgressCircle",
140
- children: [(0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
141
- children: (0, _jsxRuntime.jsx)("progress", {
142
- max: valueMax,
143
- value: valueNow,
144
- "aria-valuetext": labelAndValueText
145
- })
146
- }), value && (0, _jsxRuntime.jsx)("span", {
147
- css: styles?.center,
148
- "aria-hidden": "true",
149
- children: (0, _jsxRuntime.jsx)("span", {
150
- css: styles?.value,
151
- children: value
152
- })
153
- }), (0, _jsxRuntime.jsxs)("svg", {
154
- css: styles?.circle,
155
- role: "presentation",
156
- focusable: "false",
157
- children: [(0, _jsxRuntime.jsx)("circle", {
158
- css: styles?.track,
159
- role: "presentation",
160
- cx: "50%",
161
- cy: "50%",
162
- r: styles?.radii?.radius
163
- }), (0, _jsxRuntime.jsx)("circle", {
164
- css: styles?.border,
165
- role: "presentation",
166
- cx: "50%",
167
- cy: "50%",
168
- r: styles?.radii?.borderOffsetRadius
169
- }), (0, _jsxRuntime.jsx)("circle", {
170
- css: styles?.meter,
171
- role: "presentation",
172
- style: style,
173
- cx: "50%",
174
- cy: "50%",
175
- r: styles?.radii?.radius
176
- })]
177
- })]
178
- });
179
- }
180
- }) || _class);
181
- var _default = exports.default = ProgressCircle;