@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,137 +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.ProgressBar = void 0;
8
- var _react = require("react");
9
- var _v11_ = require("@instructure/ui-view/v11_6");
10
- var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
11
- var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
12
- var _emotion = require("@instructure/emotion");
13
- var _styles = _interopRequireDefault(require("./styles"));
14
- var _theme = _interopRequireDefault(require("./theme"));
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 ProgressBar = exports.ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = class ProgressBar extends _react.Component {
47
- static displayName = "ProgressBar";
48
- static componentId = 'ProgressBar';
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
- shouldAnimate: false,
61
- // default to showing `success` color on completion
62
- meterColor: ({
63
- valueNow,
64
- valueMax
65
- }) => valueNow / valueMax >= 1 ? 'success' : 'brand'
66
- };
67
- ref = null;
68
- componentDidMount() {
69
- this.props.makeStyles?.();
70
- }
71
- componentDidUpdate() {
72
- this.props.makeStyles?.();
73
- }
74
- handleRef = el => {
75
- const {
76
- elementRef
77
- } = this.props;
78
- this.ref = el;
79
- if (typeof elementRef === 'function') {
80
- elementRef(el);
81
- }
82
- };
83
- render() {
84
- const {
85
- renderValue,
86
- formatScreenReaderValue,
87
- valueNow,
88
- valueMax,
89
- screenReaderLabel,
90
- size,
91
- color,
92
- meterColor,
93
- renderValueInside,
94
- styles,
95
- ...props
96
- } = this.props;
97
- const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
98
- valueNow: valueNow,
99
- valueMax: valueMax
100
- }) : undefined;
101
- const value = (0, _callRenderProp.callRenderProp)(renderValue, {
102
- valueNow: valueNow,
103
- valueMax: valueMax
104
- });
105
- return (0, _jsxRuntime.jsxs)(_v11_.View, {
106
- ...(0, _passthroughProps.passthroughProps)(props),
107
- as: this.props.as,
108
- css: styles?.progressBar,
109
- margin: this.props.margin,
110
- elementRef: this.handleRef,
111
- "data-cid": "ProgressBar",
112
- children: [(0, _jsxRuntime.jsxs)("span", {
113
- css: styles?.trackLayout,
114
- children: [(0, _jsxRuntime.jsx)("progress", {
115
- css: styles?.htmlProgress,
116
- max: valueMax,
117
- value: valueNow,
118
- "aria-valuetext": valueText,
119
- "aria-label": screenReaderLabel
120
- }), (0, _jsxRuntime.jsx)("span", {
121
- css: styles?.track,
122
- role: "presentation",
123
- "aria-hidden": "true",
124
- children: (0, _jsxRuntime.jsx)("span", {
125
- css: styles?.trackValue,
126
- children: renderValueInside && value
127
- })
128
- })]
129
- }), value && !renderValueInside && (0, _jsxRuntime.jsx)("span", {
130
- css: styles?.value,
131
- "aria-hidden": "true",
132
- children: value
133
- })]
134
- });
135
- }
136
- }) || _class);
137
- var _default = exports.default = ProgressBar;
@@ -1,31 +0,0 @@
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'];
@@ -1,216 +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) => {
42
- const {
43
- valueNow = 0,
44
- valueMax = 100,
45
- size,
46
- color,
47
- meterColor,
48
- shouldAnimate
49
- } = props;
50
- const meterColorClassName = typeof meterColor === 'function' ? meterColor({
51
- valueNow,
52
- valueMax
53
- }) : meterColor;
54
- const currentValue = valueNow > valueMax ? valueMax : valueNow < 0 ? 0 : valueNow;
55
- const currentValuePercent = `${currentValue / valueMax * 100}%`;
56
- const sizeVariants = {
57
- 'x-small': {
58
- track: {
59
- height: componentTheme.xSmallHeight
60
- },
61
- value: {
62
- fontSize: componentTheme.xSmallValueFontSize
63
- }
64
- },
65
- small: {
66
- track: {
67
- height: componentTheme.smallHeight
68
- },
69
- // product design wants = 18px
70
- value: {
71
- fontSize: componentTheme.smallValueFontSize
72
- }
73
- },
74
- medium: {
75
- track: {
76
- height: componentTheme.mediumHeight
77
- },
78
- value: {
79
- fontSize: componentTheme.mediumValueFontSize
80
- }
81
- },
82
- large: {
83
- track: {
84
- height: componentTheme.largeHeight
85
- },
86
- value: {
87
- fontSize: componentTheme.largeValueFontSize
88
- }
89
- }
90
- };
91
- const colorVariants = {
92
- primary: {
93
- trackLayout: {
94
- background: componentTheme.trackColor
95
- },
96
- trackBorder: {
97
- borderBottomColor: componentTheme.trackBottomBorderColor
98
- }
99
- },
100
- 'primary-inverse': {
101
- trackLayout: {
102
- background: componentTheme.trackColorInverse
103
- },
104
- trackBorder: {
105
- borderBottomColor: componentTheme.trackBottomBorderColorInverse
106
- }
107
- }
108
- };
109
- const trackBackgroundVariants = {
110
- primary: {
111
- brand: {
112
- background: componentTheme.meterColorBrand
113
- },
114
- info: {
115
- background: componentTheme.meterColorInfo
116
- },
117
- success: {
118
- background: componentTheme.meterColorSuccess
119
- },
120
- danger: {
121
- background: componentTheme.meterColorDanger
122
- },
123
- warning: {
124
- background: componentTheme.meterColorWarning
125
- },
126
- alert: {
127
- background: componentTheme.meterColorAlert
128
- }
129
- },
130
- 'primary-inverse': {
131
- brand: {
132
- background: componentTheme.meterColorBrandInverse
133
- },
134
- info: {
135
- background: componentTheme.meterColorInfoInverse
136
- },
137
- success: {
138
- background: componentTheme.meterColorSuccessInverse
139
- },
140
- danger: {
141
- background: componentTheme.meterColorDangerInverse
142
- },
143
- warning: {
144
- background: componentTheme.meterColorWarningInverse
145
- },
146
- alert: {
147
- background: componentTheme.meterColorAlertInverse
148
- }
149
- }
150
- };
151
- return {
152
- progressBar: {
153
- label: 'progressBar',
154
- display: 'flex',
155
- alignItems: 'center',
156
- fontFamily: componentTheme.fontFamily,
157
- fontWeight: componentTheme.fontWeight,
158
- lineHeight: componentTheme.lineHeight,
159
- fontSize: componentTheme.fontSize,
160
- borderRadius: componentTheme.borderRadius
161
- },
162
- trackLayout: {
163
- label: 'progressBar__trackLayout',
164
- position: 'relative',
165
- flex: 1,
166
- borderRadius: 'inherit',
167
- ...colorVariants[color].trackLayout
168
- },
169
- track: {
170
- label: 'progressBar__track',
171
- display: 'block',
172
- boxSizing: 'border-box',
173
- width: '100%',
174
- borderBottomWidth: componentTheme.trackBottomBorderWidth,
175
- borderBottomStyle: 'solid',
176
- background: 'transparent',
177
- borderRadius: 'inherit',
178
- ...sizeVariants[size].track,
179
- ...colorVariants[color].trackBorder
180
- },
181
- trackValue: {
182
- label: 'progressBar__trackValue',
183
- display: 'block',
184
- boxSizing: 'border-box',
185
- height: '100%',
186
- width: currentValuePercent,
187
- maxWidth: '100%',
188
- borderRadius: 'inherit',
189
- ...(shouldAnimate && {
190
- transition: 'all 0.5s'
191
- }),
192
- ...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
193
- },
194
- value: {
195
- label: 'progressBar__value',
196
- lineHeight: 1,
197
- boxSizing: 'border-box',
198
- paddingInlineStart: componentTheme.valuePadding,
199
- flex: '0 0 5.625rem',
200
- ...sizeVariants[size].value
201
- },
202
- htmlProgress: {
203
- label: 'progressBar__htmlProgress',
204
- display: 'block',
205
- position: 'absolute',
206
- top: '0',
207
- left: '0',
208
- width: '100%',
209
- height: '100%',
210
- boxSizing: 'border-box',
211
- zIndex: -1,
212
- opacity: 0
213
- }
214
- };
215
- };
216
- var _default = exports.default = generateStyle;
@@ -1,100 +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
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- const {
38
- borders,
39
- colors,
40
- spacing,
41
- typography,
42
- key: themeName
43
- } = theme;
44
- const themeSpecificStyle = {
45
- canvas: {
46
- meterColorBrand: theme['ic-brand-primary']
47
- },
48
- 'canvas-high-contrast': {
49
- meterColorBrandInverse: colors?.contrasts?.white1010,
50
- meterColorSuccessInverse: colors?.contrasts?.white1010,
51
- meterColorInfoInverse: colors?.contrasts?.white1010,
52
- meterColorAlertInverse: colors?.contrasts?.white1010,
53
- meterColorWarningInverse: colors?.contrasts?.white1010,
54
- meterColorDangerInverse: colors?.contrasts?.white1010
55
- }
56
- };
57
- const componentVariables = {
58
- fontFamily: typography?.fontFamily,
59
- fontWeight: typography?.fontWeightNormal,
60
- lineHeight: typography?.lineHeightCondensed,
61
- fontSize: typography?.fontSizeMedium,
62
- xSmallHeight: spacing?.xSmall,
63
- xSmallValueFontSize: typography?.fontSizeXSmall,
64
- smallHeight: '1.125rem',
65
- // product design wants = 18px
66
- smallValueFontSize: typography?.fontSizeXSmall,
67
- mediumHeight: spacing?.medium,
68
- mediumValueFontSize: typography?.fontSizeSmall,
69
- largeHeight: spacing?.large,
70
- largeValueFontSize: typography?.fontSizeMedium,
71
- valuePadding: `${spacing?.xxSmall}`,
72
- // variables are split out for inverse to allow
73
- // color value changes for inverse-high-constrast
74
- meterColorBrand: colors?.contrasts?.blue4570,
75
- meterColorBrandInverse: colors?.contrasts?.blue4570,
76
- meterColorInfo: colors?.contrasts?.blue4570,
77
- meterColorInfoInverse: colors?.contrasts?.blue4570,
78
- meterColorSuccess: colors?.contrasts?.green4570,
79
- meterColorSuccessInverse: colors?.contrasts?.green4570,
80
- meterColorDanger: colors?.contrasts?.red4570,
81
- meterColorDangerInverse: colors?.contrasts?.red4570,
82
- meterColorAlert: colors?.contrasts?.blue4570,
83
- meterColorAlertInverse: colors?.contrasts?.blue4570,
84
- meterColorWarning: colors?.contrasts?.orange4570,
85
- meterColorWarningInverse: colors?.contrasts?.orange4570,
86
- meterBorderWidthInverse: borders?.widthSmall,
87
- meterBorderColorInverse: 'transparent',
88
- trackColor: colors?.contrasts?.white1010,
89
- trackColorInverse: 'transparent',
90
- trackBottomBorderWidth: borders?.widthSmall,
91
- trackBottomBorderColor: colors?.contrasts?.grey3045,
92
- trackBottomBorderColorInverse: colors?.contrasts?.white1010,
93
- borderRadius: '0px'
94
- };
95
- return {
96
- ...componentVariables,
97
- ...themeSpecificStyle[themeName]
98
- };
99
- };
100
- var _default = exports.default = generateComponentTheme;
@@ -1,136 +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.ProgressBar = void 0;
8
- var _react = require("react");
9
- var _latest = require("@instructure/ui-view/latest");
10
- var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
11
- var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
12
- var _emotion = require("@instructure/emotion");
13
- var _styles = _interopRequireDefault(require("./styles"));
14
- var _props = require("./props");
15
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
- var _dec, _class;
17
- /*
18
- * The MIT License (MIT)
19
- *
20
- * Copyright (c) 2015 - present Instructure, Inc.
21
- *
22
- * Permission is hereby granted, free of charge, to any person obtaining a copy
23
- * of this software and associated documentation files (the "Software"), to deal
24
- * in the Software without restriction, including without limitation the rights
25
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
- * copies of the Software, and to permit persons to whom the Software is
27
- * furnished to do so, subject to the following conditions:
28
- *
29
- * The above copyright notice and this permission notice shall be included in all
30
- * copies or substantial portions of the Software.
31
- *
32
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38
- * SOFTWARE.
39
- */
40
- /**
41
- ---
42
- category: components
43
- ---
44
- **/
45
- let ProgressBar = exports.ProgressBar = (_dec = (0, _emotion.withStyleNew)(_styles.default), _dec(_class = class ProgressBar extends _react.Component {
46
- static displayName = "ProgressBar";
47
- static componentId = 'ProgressBar';
48
- static allowedProps = _props.allowedProps;
49
- static defaultProps = {
50
- formatScreenReaderValue: ({
51
- valueNow,
52
- valueMax
53
- }) => `${valueNow} / ${valueMax}`,
54
- size: 'medium',
55
- valueMax: 100,
56
- valueNow: 0,
57
- as: 'div',
58
- color: 'primary',
59
- shouldAnimate: false,
60
- // default to showing `success` color on completion
61
- meterColor: ({
62
- valueNow,
63
- valueMax
64
- }) => valueNow / valueMax >= 1 ? 'success' : 'brand'
65
- };
66
- ref = null;
67
- componentDidMount() {
68
- this.props.makeStyles?.();
69
- }
70
- componentDidUpdate() {
71
- this.props.makeStyles?.();
72
- }
73
- handleRef = el => {
74
- const {
75
- elementRef
76
- } = this.props;
77
- this.ref = el;
78
- if (typeof elementRef === 'function') {
79
- elementRef(el);
80
- }
81
- };
82
- render() {
83
- const {
84
- renderValue,
85
- formatScreenReaderValue,
86
- valueNow,
87
- valueMax,
88
- screenReaderLabel,
89
- size,
90
- color,
91
- meterColor,
92
- renderValueInside,
93
- styles,
94
- ...props
95
- } = this.props;
96
- const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
97
- valueNow: valueNow,
98
- valueMax: valueMax
99
- }) : undefined;
100
- const value = (0, _callRenderProp.callRenderProp)(renderValue, {
101
- valueNow: valueNow,
102
- valueMax: valueMax
103
- });
104
- return (0, _jsxRuntime.jsxs)(_latest.View, {
105
- ...(0, _passthroughProps.passthroughProps)(props),
106
- as: this.props.as,
107
- css: styles?.progressBar,
108
- margin: this.props.margin,
109
- elementRef: this.handleRef,
110
- "data-cid": "ProgressBar",
111
- children: [(0, _jsxRuntime.jsxs)("span", {
112
- css: styles?.trackLayout,
113
- children: [(0, _jsxRuntime.jsx)("progress", {
114
- css: styles?.htmlProgress,
115
- max: valueMax,
116
- value: valueNow,
117
- "aria-valuetext": valueText,
118
- "aria-label": screenReaderLabel
119
- }), (0, _jsxRuntime.jsx)("span", {
120
- css: styles?.track,
121
- role: "presentation",
122
- "aria-hidden": "true",
123
- children: (0, _jsxRuntime.jsx)("span", {
124
- css: styles?.trackValue,
125
- children: renderValueInside && value
126
- })
127
- })]
128
- }), value && !renderValueInside && (0, _jsxRuntime.jsx)("span", {
129
- css: styles?.value,
130
- "aria-hidden": "true",
131
- children: value
132
- })]
133
- });
134
- }
135
- }) || _class);
136
- var _default = exports.default = ProgressBar;