@instructure/ui-progress 11.6.0 → 11.6.1-snapshot-129

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