@instructure/ui-progress 8.12.1-snapshot.7 → 8.13.1-snapshot.9
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.
- package/CHANGELOG.md +4 -0
- package/es/ProgressBar/__examples__/ProgressBar.examples.js +7 -8
- package/es/ProgressBar/index.js +17 -15
- package/es/ProgressBar/props.js +0 -47
- package/es/ProgressBar/styles.js +4 -2
- package/es/ProgressCircle/__examples__/ProgressCircle.examples.js +7 -8
- package/es/ProgressCircle/index.js +16 -13
- package/es/ProgressCircle/props.js +1 -48
- package/es/ProgressCircle/styles.js +4 -2
- package/lib/ProgressBar/__examples__/ProgressBar.examples.js +7 -8
- package/lib/ProgressBar/index.js +18 -16
- package/lib/ProgressBar/props.js +1 -48
- package/lib/ProgressBar/styles.js +4 -2
- package/lib/ProgressCircle/__examples__/ProgressCircle.examples.js +7 -8
- package/lib/ProgressCircle/index.js +17 -14
- package/lib/ProgressCircle/props.js +2 -49
- package/lib/ProgressCircle/styles.js +4 -2
- package/package.json +14 -14
- package/src/ProgressBar/__examples__/ProgressBar.examples.tsx +6 -11
- package/src/ProgressBar/index.tsx +7 -8
- package/src/ProgressBar/props.ts +43 -41
- package/src/ProgressBar/styles.ts +1 -1
- package/src/ProgressCircle/__examples__/ProgressCircle.examples.tsx +6 -11
- package/src/ProgressCircle/index.tsx +13 -22
- package/src/ProgressCircle/props.ts +46 -48
- package/src/ProgressCircle/styles.ts +2 -2
- package/src/ProgressCircle/theme.ts +2 -5
- package/types/ProgressBar/__examples__/ProgressBar.examples.d.ts +4 -7
- package/types/ProgressBar/__examples__/ProgressBar.examples.d.ts.map +1 -1
- package/types/ProgressBar/index.d.ts +10 -15
- package/types/ProgressBar/index.d.ts.map +1 -1
- package/types/ProgressBar/props.d.ts +46 -5
- package/types/ProgressBar/props.d.ts.map +1 -1
- package/types/ProgressCircle/__examples__/ProgressCircle.examples.d.ts +4 -7
- package/types/ProgressCircle/__examples__/ProgressCircle.examples.d.ts.map +1 -1
- package/types/ProgressCircle/index.d.ts +12 -17
- package/types/ProgressCircle/index.d.ts.map +1 -1
- package/types/ProgressCircle/props.d.ts +52 -6
- package/types/ProgressCircle/props.d.ts.map +1 -1
- package/types/ProgressCircle/theme.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-progress
|
|
9
|
+
|
|
6
10
|
# [8.12.0](https://github.com/instructure/instructure-ui/compare/v8.11.1...v8.12.0) (2021-11-17)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-progress
|
|
@@ -27,13 +27,13 @@ export default {
|
|
|
27
27
|
sectionProp: 'color',
|
|
28
28
|
propValues: {
|
|
29
29
|
valueNow: [0, 40, 80, 100],
|
|
30
|
-
renderValue: [null,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
valueMax
|
|
34
|
-
}
|
|
30
|
+
renderValue: [null, _ref => {
|
|
31
|
+
let valueNow = _ref.valueNow,
|
|
32
|
+
valueMax = _ref.valueMax;
|
|
33
|
+
return /*#__PURE__*/React.createElement("span", null, Math.round(valueNow / valueMax * 100));
|
|
34
|
+
}]
|
|
35
35
|
},
|
|
36
|
-
getComponentProps:
|
|
36
|
+
getComponentProps: () => {
|
|
37
37
|
return {
|
|
38
38
|
screenReaderLabel: 'Passing students',
|
|
39
39
|
valueMax
|
|
@@ -43,6 +43,5 @@ export default {
|
|
|
43
43
|
return {
|
|
44
44
|
background: props.color.includes('inverse') ? 'primary-inverse' : 'primary'
|
|
45
45
|
};
|
|
46
|
-
}
|
|
47
|
-
filter: props => {}
|
|
46
|
+
}
|
|
48
47
|
};
|
package/es/ProgressBar/index.js
CHANGED
|
@@ -40,11 +40,12 @@ import { allowedProps, propTypes } from './props';
|
|
|
40
40
|
---
|
|
41
41
|
category: components
|
|
42
42
|
---
|
|
43
|
+
@tsProps
|
|
43
44
|
**/
|
|
44
45
|
|
|
45
46
|
let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class ProgressBar extends Component {
|
|
46
|
-
constructor(
|
|
47
|
-
super(...
|
|
47
|
+
constructor() {
|
|
48
|
+
super(...arguments);
|
|
48
49
|
this.ref = null;
|
|
49
50
|
|
|
50
51
|
this.handleRef = el => {
|
|
@@ -82,10 +83,10 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
82
83
|
styles = _this$props3.styles,
|
|
83
84
|
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
84
85
|
|
|
85
|
-
const valueText = typeof formatScreenReaderValue === 'function'
|
|
86
|
-
valueNow,
|
|
87
|
-
valueMax
|
|
88
|
-
}); // consolidating the label and aria-valuetext to put in aria-label because
|
|
86
|
+
const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
|
|
87
|
+
valueNow: valueNow,
|
|
88
|
+
valueMax: valueMax
|
|
89
|
+
}) : void 0; // consolidating the label and aria-valuetext to put in aria-label because
|
|
89
90
|
// NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
|
|
90
91
|
// But leaving aria-valuetext because JAWS ignores aria-label
|
|
91
92
|
|
|
@@ -118,24 +119,25 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
118
119
|
css: styles === null || styles === void 0 ? void 0 : styles.value,
|
|
119
120
|
"aria-hidden": "true"
|
|
120
121
|
}, value));
|
|
121
|
-
/* eslint-enable jsx-a11y/no-redundant-roles, jsx-a11y/no-noninteractive-element-to-interactive-role */
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
}, _class2.displayName = "ProgressBar", _class2.componentId = 'ProgressBar', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
125
|
-
formatScreenReaderValue:
|
|
126
|
-
valueNow,
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
formatScreenReaderValue: _ref => {
|
|
126
|
+
let valueNow = _ref.valueNow,
|
|
127
|
+
valueMax = _ref.valueMax;
|
|
128
|
+
return `${valueNow} / ${valueMax}`;
|
|
129
|
+
},
|
|
129
130
|
size: 'medium',
|
|
130
131
|
valueMax: 100,
|
|
131
132
|
valueNow: 0,
|
|
132
133
|
as: 'div',
|
|
133
134
|
color: 'primary',
|
|
134
135
|
// default to showing `success` color on completion
|
|
135
|
-
meterColor:
|
|
136
|
-
valueNow,
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
meterColor: _ref2 => {
|
|
137
|
+
let valueNow = _ref2.valueNow,
|
|
138
|
+
valueMax = _ref2.valueMax;
|
|
139
|
+
return valueNow / valueMax >= 1 ? 'success' : 'brand';
|
|
140
|
+
}
|
|
139
141
|
}, _temp)) || _class) || _class);
|
|
140
142
|
export default ProgressBar;
|
|
141
143
|
export { ProgressBar };
|
package/es/ProgressBar/props.js
CHANGED
|
@@ -24,63 +24,16 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* A label is required for accessibility
|
|
29
|
-
*/
|
|
30
27
|
screenReaderLabel: PropTypes.string.isRequired,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Control the height of the progress bar
|
|
34
|
-
*/
|
|
35
28
|
size: PropTypes.oneOf(['x-small', 'small', 'medium', 'large']),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Maximum value (defaults to 100)
|
|
39
|
-
*/
|
|
40
29
|
valueMax: PropTypes.number,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Receives the progress of the event
|
|
44
|
-
*/
|
|
45
30
|
valueNow: PropTypes.number,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* A function for formatting the text provided to screen readers via `aria-valuenow`
|
|
49
|
-
*/
|
|
50
31
|
formatScreenReaderValue: PropTypes.func,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* A function to format the displayed value. If null the value will not display.
|
|
54
|
-
* Takes `valueNow` and `valueMax` as parameters.
|
|
55
|
-
*/
|
|
56
32
|
renderValue: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Controls the overall color scheme of the component
|
|
60
|
-
*/
|
|
61
33
|
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Control the color of the progress meter. Defaults to showing theme success
|
|
65
|
-
* color on completion, based on `valueNow` and `valueMax`.
|
|
66
|
-
*/
|
|
67
34
|
meterColor: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOf(['info', 'warning', 'danger', 'alert', 'success', 'brand'])]),
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
71
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
72
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
73
|
-
*/
|
|
74
35
|
margin: ThemeablePropTypes.spacing,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Provides a reference to the component's root HTML element
|
|
78
|
-
*/
|
|
79
36
|
elementRef: PropTypes.func,
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Set the element type of the component's root
|
|
83
|
-
*/
|
|
84
37
|
as: PropTypes.elementType
|
|
85
38
|
};
|
|
86
39
|
const allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'margin', 'elementRef', 'as'];
|
package/es/ProgressBar/styles.js
CHANGED
|
@@ -33,8 +33,10 @@
|
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
|
-
const valueNow = props.valueNow,
|
|
37
|
-
|
|
36
|
+
const _props$valueNow = props.valueNow,
|
|
37
|
+
valueNow = _props$valueNow === void 0 ? 0 : _props$valueNow,
|
|
38
|
+
_props$valueMax = props.valueMax,
|
|
39
|
+
valueMax = _props$valueMax === void 0 ? 100 : _props$valueMax,
|
|
38
40
|
size = props.size,
|
|
39
41
|
color = props.color,
|
|
40
42
|
meterColor = props.meterColor;
|
|
@@ -27,13 +27,13 @@ export default {
|
|
|
27
27
|
sectionProp: 'color',
|
|
28
28
|
propValues: {
|
|
29
29
|
valueNow: [0, 40, 80, 100],
|
|
30
|
-
renderValue: [null,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
valueMax
|
|
34
|
-
}
|
|
30
|
+
renderValue: [null, _ref => {
|
|
31
|
+
let valueNow = _ref.valueNow,
|
|
32
|
+
valueMax = _ref.valueMax;
|
|
33
|
+
return /*#__PURE__*/React.createElement("span", null, Math.round(valueNow / valueMax * 100));
|
|
34
|
+
}]
|
|
35
35
|
},
|
|
36
|
-
getComponentProps:
|
|
36
|
+
getComponentProps: () => {
|
|
37
37
|
return {
|
|
38
38
|
screenReaderLabel: 'Passing students',
|
|
39
39
|
valueMax
|
|
@@ -43,6 +43,5 @@ export default {
|
|
|
43
43
|
return {
|
|
44
44
|
background: props.color.includes('inverse') ? 'primary-inverse' : 'primary'
|
|
45
45
|
};
|
|
46
|
-
}
|
|
47
|
-
filter: props => {}
|
|
46
|
+
}
|
|
48
47
|
};
|
|
@@ -41,6 +41,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
41
41
|
---
|
|
42
42
|
category: components
|
|
43
43
|
---
|
|
44
|
+
@tsProps
|
|
44
45
|
**/
|
|
45
46
|
|
|
46
47
|
let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class ProgressCircle extends Component {
|
|
@@ -108,10 +109,10 @@ let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
108
109
|
styles = _this$props3.styles,
|
|
109
110
|
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
110
111
|
|
|
111
|
-
const valueText = typeof formatScreenReaderValue === 'function'
|
|
112
|
-
valueNow,
|
|
113
|
-
valueMax
|
|
114
|
-
}); // consolidating the label and aria-valuetext to put in aria-label because
|
|
112
|
+
const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
|
|
113
|
+
valueNow: valueNow,
|
|
114
|
+
valueMax: valueMax
|
|
115
|
+
}) : void 0; // consolidating the label and aria-valuetext to put in aria-label because
|
|
115
116
|
// NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
|
|
116
117
|
// But leaving aria-valuetext because JAWS ignores aria-label
|
|
117
118
|
|
|
@@ -120,7 +121,7 @@ let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
120
121
|
valueNow,
|
|
121
122
|
valueMax
|
|
122
123
|
});
|
|
123
|
-
const style =
|
|
124
|
+
const style = {
|
|
124
125
|
strokeDashoffset: `${styles === null || styles === void 0 ? void 0 : styles.dashOffset}em`
|
|
125
126
|
};
|
|
126
127
|
return jsx(View, Object.assign({}, passthroughProps(props), {
|
|
@@ -167,10 +168,11 @@ let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
}, _class2.displayName = "ProgressCircle", _class2.componentId = 'ProgressCircle', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
170
|
-
formatScreenReaderValue:
|
|
171
|
-
valueNow,
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
formatScreenReaderValue: _ref => {
|
|
172
|
+
let valueNow = _ref.valueNow,
|
|
173
|
+
valueMax = _ref.valueMax;
|
|
174
|
+
return `${valueNow} / ${valueMax}`;
|
|
175
|
+
},
|
|
174
176
|
size: 'medium',
|
|
175
177
|
valueMax: 100,
|
|
176
178
|
valueNow: 0,
|
|
@@ -178,10 +180,11 @@ let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
178
180
|
color: 'primary',
|
|
179
181
|
shouldAnimateOnMount: false,
|
|
180
182
|
// default to showing `success` color on completion
|
|
181
|
-
meterColor:
|
|
182
|
-
valueNow,
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
meterColor: _ref2 => {
|
|
184
|
+
let valueNow = _ref2.valueNow,
|
|
185
|
+
valueMax = _ref2.valueMax;
|
|
186
|
+
return valueNow / valueMax >= 1 ? 'success' : 'brand';
|
|
187
|
+
}
|
|
185
188
|
}, _temp)) || _class) || _class);
|
|
186
189
|
export default ProgressCircle;
|
|
187
190
|
export { ProgressCircle };
|
|
@@ -24,63 +24,16 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* A label is required for accessibility
|
|
29
|
-
*/
|
|
30
27
|
screenReaderLabel: PropTypes.string.isRequired,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Control the size of the progress circle
|
|
34
|
-
*/
|
|
35
28
|
size: PropTypes.oneOf(['x-small', 'small', 'medium', 'large']),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Maximum value (defaults to 100)
|
|
39
|
-
*/
|
|
40
29
|
valueMax: PropTypes.number,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Receives the progress of the event
|
|
44
|
-
*/
|
|
45
30
|
valueNow: PropTypes.number,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* A function for formatting the text provided to screen readers via `aria-valuenow`
|
|
49
|
-
*/
|
|
50
|
-
formatScreenReaderValue: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* A function to format the displayed value. If null the value will not display.
|
|
54
|
-
* Takes `valueNow` and `valueMax` as parameters.
|
|
55
|
-
*/
|
|
31
|
+
formatScreenReaderValue: PropTypes.func,
|
|
56
32
|
renderValue: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Controls the overall color scheme of the component
|
|
60
|
-
*/
|
|
61
33
|
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Control the color of the progress meter. Defaults to showing theme success
|
|
65
|
-
* color on completion, based on `valueNow` and `valueMax`.
|
|
66
|
-
*/
|
|
67
34
|
meterColor: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOf(['info', 'warning', 'danger', 'alert', 'success', 'brand'])]),
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
71
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
72
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
73
|
-
*/
|
|
74
35
|
margin: ThemeablePropTypes.spacing,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Provides a reference to the component's root HTML element
|
|
78
|
-
*/
|
|
79
36
|
elementRef: PropTypes.func,
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Set the element type of the component's root
|
|
83
|
-
*/
|
|
84
37
|
as: PropTypes.elementType,
|
|
85
38
|
shouldAnimateOnMount: PropTypes.bool,
|
|
86
39
|
animationDelay: PropTypes.number
|
|
@@ -36,8 +36,10 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
36
36
|
const size = props.size,
|
|
37
37
|
color = props.color,
|
|
38
38
|
meterColor = props.meterColor,
|
|
39
|
-
valueNow = props.valueNow,
|
|
40
|
-
|
|
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;
|
|
41
43
|
const shouldAnimateOnMount = state.shouldAnimateOnMount;
|
|
42
44
|
const getMeterColorClassName = typeof meterColor === 'function' ? meterColor({
|
|
43
45
|
valueNow,
|
|
@@ -37,13 +37,13 @@ var _default = {
|
|
|
37
37
|
sectionProp: 'color',
|
|
38
38
|
propValues: {
|
|
39
39
|
valueNow: [0, 40, 80, 100],
|
|
40
|
-
renderValue: [null,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
valueMax
|
|
44
|
-
}
|
|
40
|
+
renderValue: [null, _ref => {
|
|
41
|
+
let valueNow = _ref.valueNow,
|
|
42
|
+
valueMax = _ref.valueMax;
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement("span", null, Math.round(valueNow / valueMax * 100));
|
|
44
|
+
}]
|
|
45
45
|
},
|
|
46
|
-
getComponentProps:
|
|
46
|
+
getComponentProps: () => {
|
|
47
47
|
return {
|
|
48
48
|
screenReaderLabel: 'Passing students',
|
|
49
49
|
valueMax
|
|
@@ -53,7 +53,6 @@ var _default = {
|
|
|
53
53
|
return {
|
|
54
54
|
background: props.color.includes('inverse') ? 'primary-inverse' : 'primary'
|
|
55
55
|
};
|
|
56
|
-
}
|
|
57
|
-
filter: props => {}
|
|
56
|
+
}
|
|
58
57
|
};
|
|
59
58
|
exports.default = _default;
|
package/lib/ProgressBar/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.default = exports.ProgressBar = void 0;
|
|
9
9
|
|
|
10
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
11
|
|
|
@@ -35,10 +35,11 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
35
35
|
---
|
|
36
36
|
category: components
|
|
37
37
|
---
|
|
38
|
+
@tsProps
|
|
38
39
|
**/
|
|
39
40
|
let ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class ProgressBar extends _react.Component {
|
|
40
|
-
constructor(
|
|
41
|
-
super(...
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
42
43
|
this.ref = null;
|
|
43
44
|
|
|
44
45
|
this.handleRef = el => {
|
|
@@ -75,10 +76,10 @@ let ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
75
76
|
meterColor = _this$props3.meterColor,
|
|
76
77
|
styles = _this$props3.styles,
|
|
77
78
|
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
78
|
-
const valueText = typeof formatScreenReaderValue === 'function'
|
|
79
|
-
valueNow,
|
|
80
|
-
valueMax
|
|
81
|
-
}); // consolidating the label and aria-valuetext to put in aria-label because
|
|
79
|
+
const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
|
|
80
|
+
valueNow: valueNow,
|
|
81
|
+
valueMax: valueMax
|
|
82
|
+
}) : void 0; // consolidating the label and aria-valuetext to put in aria-label because
|
|
82
83
|
// NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
|
|
83
84
|
// But leaving aria-valuetext because JAWS ignores aria-label
|
|
84
85
|
|
|
@@ -111,24 +112,25 @@ let ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
111
112
|
css: styles === null || styles === void 0 ? void 0 : styles.value,
|
|
112
113
|
"aria-hidden": "true"
|
|
113
114
|
}, value));
|
|
114
|
-
/* eslint-enable jsx-a11y/no-redundant-roles, jsx-a11y/no-noninteractive-element-to-interactive-role */
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
}, _class2.displayName = "ProgressBar", _class2.componentId = 'ProgressBar', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
118
|
-
formatScreenReaderValue:
|
|
119
|
-
valueNow,
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
formatScreenReaderValue: _ref => {
|
|
119
|
+
let valueNow = _ref.valueNow,
|
|
120
|
+
valueMax = _ref.valueMax;
|
|
121
|
+
return `${valueNow} / ${valueMax}`;
|
|
122
|
+
},
|
|
122
123
|
size: 'medium',
|
|
123
124
|
valueMax: 100,
|
|
124
125
|
valueNow: 0,
|
|
125
126
|
as: 'div',
|
|
126
127
|
color: 'primary',
|
|
127
128
|
// default to showing `success` color on completion
|
|
128
|
-
meterColor:
|
|
129
|
-
valueNow,
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
meterColor: _ref2 => {
|
|
130
|
+
let valueNow = _ref2.valueNow,
|
|
131
|
+
valueMax = _ref2.valueMax;
|
|
132
|
+
return valueNow / valueMax >= 1 ? 'success' : 'brand';
|
|
133
|
+
}
|
|
132
134
|
}, _temp)) || _class) || _class);
|
|
133
135
|
exports.ProgressBar = ProgressBar;
|
|
134
136
|
var _default = ProgressBar;
|
package/lib/ProgressBar/props.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -35,63 +35,16 @@ var _emotion = require("@instructure/emotion");
|
|
|
35
35
|
* SOFTWARE.
|
|
36
36
|
*/
|
|
37
37
|
const propTypes = {
|
|
38
|
-
/**
|
|
39
|
-
* A label is required for accessibility
|
|
40
|
-
*/
|
|
41
38
|
screenReaderLabel: _propTypes.default.string.isRequired,
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Control the height of the progress bar
|
|
45
|
-
*/
|
|
46
39
|
size: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']),
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Maximum value (defaults to 100)
|
|
50
|
-
*/
|
|
51
40
|
valueMax: _propTypes.default.number,
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Receives the progress of the event
|
|
55
|
-
*/
|
|
56
41
|
valueNow: _propTypes.default.number,
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A function for formatting the text provided to screen readers via `aria-valuenow`
|
|
60
|
-
*/
|
|
61
42
|
formatScreenReaderValue: _propTypes.default.func,
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* A function to format the displayed value. If null the value will not display.
|
|
65
|
-
* Takes `valueNow` and `valueMax` as parameters.
|
|
66
|
-
*/
|
|
67
43
|
renderValue: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Controls the overall color scheme of the component
|
|
71
|
-
*/
|
|
72
44
|
color: _propTypes.default.oneOf(['primary', 'primary-inverse']),
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Control the color of the progress meter. Defaults to showing theme success
|
|
76
|
-
* color on completion, based on `valueNow` and `valueMax`.
|
|
77
|
-
*/
|
|
78
45
|
meterColor: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.oneOf(['info', 'warning', 'danger', 'alert', 'success', 'brand'])]),
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
82
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
83
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
84
|
-
*/
|
|
85
46
|
margin: _emotion.ThemeablePropTypes.spacing,
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Provides a reference to the component's root HTML element
|
|
89
|
-
*/
|
|
90
47
|
elementRef: _propTypes.default.func,
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Set the element type of the component's root
|
|
94
|
-
*/
|
|
95
48
|
as: _propTypes.default.elementType
|
|
96
49
|
};
|
|
97
50
|
exports.propTypes = propTypes;
|
|
@@ -40,8 +40,10 @@ exports.default = void 0;
|
|
|
40
40
|
* @return {Object} The final style object, which will be used in the component
|
|
41
41
|
*/
|
|
42
42
|
const generateStyle = (componentTheme, props) => {
|
|
43
|
-
const valueNow = props.valueNow,
|
|
44
|
-
|
|
43
|
+
const _props$valueNow = props.valueNow,
|
|
44
|
+
valueNow = _props$valueNow === void 0 ? 0 : _props$valueNow,
|
|
45
|
+
_props$valueMax = props.valueMax,
|
|
46
|
+
valueMax = _props$valueMax === void 0 ? 100 : _props$valueMax,
|
|
45
47
|
size = props.size,
|
|
46
48
|
color = props.color,
|
|
47
49
|
meterColor = props.meterColor;
|
|
@@ -37,13 +37,13 @@ var _default = {
|
|
|
37
37
|
sectionProp: 'color',
|
|
38
38
|
propValues: {
|
|
39
39
|
valueNow: [0, 40, 80, 100],
|
|
40
|
-
renderValue: [null,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
valueMax
|
|
44
|
-
}
|
|
40
|
+
renderValue: [null, _ref => {
|
|
41
|
+
let valueNow = _ref.valueNow,
|
|
42
|
+
valueMax = _ref.valueMax;
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement("span", null, Math.round(valueNow / valueMax * 100));
|
|
44
|
+
}]
|
|
45
45
|
},
|
|
46
|
-
getComponentProps:
|
|
46
|
+
getComponentProps: () => {
|
|
47
47
|
return {
|
|
48
48
|
screenReaderLabel: 'Passing students',
|
|
49
49
|
valueMax
|
|
@@ -53,7 +53,6 @@ var _default = {
|
|
|
53
53
|
return {
|
|
54
54
|
background: props.color.includes('inverse') ? 'primary-inverse' : 'primary'
|
|
55
55
|
};
|
|
56
|
-
}
|
|
57
|
-
filter: props => {}
|
|
56
|
+
}
|
|
58
57
|
};
|
|
59
58
|
exports.default = _default;
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.default = exports.ProgressCircle = void 0;
|
|
9
9
|
|
|
10
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
11
|
|
|
@@ -37,6 +37,7 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
37
37
|
---
|
|
38
38
|
category: components
|
|
39
39
|
---
|
|
40
|
+
@tsProps
|
|
40
41
|
**/
|
|
41
42
|
let ProgressCircle = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class ProgressCircle extends _react.Component {
|
|
42
43
|
constructor(props) {
|
|
@@ -102,10 +103,10 @@ let ProgressCircle = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
102
103
|
size = _this$props3.size,
|
|
103
104
|
styles = _this$props3.styles,
|
|
104
105
|
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
105
|
-
const valueText = typeof formatScreenReaderValue === 'function'
|
|
106
|
-
valueNow,
|
|
107
|
-
valueMax
|
|
108
|
-
}); // consolidating the label and aria-valuetext to put in aria-label because
|
|
106
|
+
const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
|
|
107
|
+
valueNow: valueNow,
|
|
108
|
+
valueMax: valueMax
|
|
109
|
+
}) : void 0; // consolidating the label and aria-valuetext to put in aria-label because
|
|
109
110
|
// NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
|
|
110
111
|
// But leaving aria-valuetext because JAWS ignores aria-label
|
|
111
112
|
|
|
@@ -114,7 +115,7 @@ let ProgressCircle = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
114
115
|
valueNow,
|
|
115
116
|
valueMax
|
|
116
117
|
});
|
|
117
|
-
const style =
|
|
118
|
+
const style = {
|
|
118
119
|
strokeDashoffset: `${styles === null || styles === void 0 ? void 0 : styles.dashOffset}em`
|
|
119
120
|
};
|
|
120
121
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, (0, _passthroughProps.passthroughProps)(props), {
|
|
@@ -161,10 +162,11 @@ let ProgressCircle = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
}, _class2.displayName = "ProgressCircle", _class2.componentId = 'ProgressCircle', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
164
|
-
formatScreenReaderValue:
|
|
165
|
-
valueNow,
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
formatScreenReaderValue: _ref => {
|
|
166
|
+
let valueNow = _ref.valueNow,
|
|
167
|
+
valueMax = _ref.valueMax;
|
|
168
|
+
return `${valueNow} / ${valueMax}`;
|
|
169
|
+
},
|
|
168
170
|
size: 'medium',
|
|
169
171
|
valueMax: 100,
|
|
170
172
|
valueNow: 0,
|
|
@@ -172,10 +174,11 @@ let ProgressCircle = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
172
174
|
color: 'primary',
|
|
173
175
|
shouldAnimateOnMount: false,
|
|
174
176
|
// default to showing `success` color on completion
|
|
175
|
-
meterColor:
|
|
176
|
-
valueNow,
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
meterColor: _ref2 => {
|
|
178
|
+
let valueNow = _ref2.valueNow,
|
|
179
|
+
valueMax = _ref2.valueMax;
|
|
180
|
+
return valueNow / valueMax >= 1 ? 'success' : 'brand';
|
|
181
|
+
}
|
|
179
182
|
}, _temp)) || _class) || _class);
|
|
180
183
|
exports.ProgressCircle = ProgressCircle;
|
|
181
184
|
var _default = ProgressCircle;
|