@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.
- package/CHANGELOG.md +37 -294
- package/es/ProgressBar/{index.js → v1/index.js} +2 -2
- package/es/ProgressBar/v2/index.js +130 -0
- package/{src/index.ts → es/ProgressBar/v2/props.js} +2 -5
- package/es/ProgressBar/v2/styles.js +237 -0
- package/es/ProgressCircle/{index.js → v1/index.js} +2 -2
- package/es/ProgressCircle/v2/index.js +173 -0
- package/es/ProgressCircle/v2/props.js +26 -0
- package/es/ProgressCircle/v2/styles.js +349 -0
- package/es/{index.js → exports/a.js} +2 -2
- package/es/exports/b.js +25 -0
- package/lib/ProgressBar/{index.js → v1/index.js} +3 -3
- package/lib/ProgressBar/v2/index.js +136 -0
- package/lib/ProgressBar/v2/props.js +31 -0
- package/lib/ProgressBar/v2/styles.js +243 -0
- package/lib/ProgressCircle/{index.js → v1/index.js} +3 -3
- package/lib/ProgressCircle/v2/index.js +179 -0
- package/lib/ProgressCircle/v2/props.js +31 -0
- package/lib/ProgressCircle/v2/styles.js +355 -0
- package/lib/{index.js → exports/a.js} +4 -4
- package/lib/exports/b.js +19 -0
- package/package.json +40 -18
- package/src/ProgressBar/{index.tsx → v1/index.tsx} +2 -2
- package/src/ProgressBar/v2/README.md +384 -0
- package/src/ProgressBar/v2/index.tsx +142 -0
- package/src/ProgressBar/v2/props.ts +155 -0
- package/src/ProgressBar/v2/styles.ts +221 -0
- package/src/ProgressCircle/{index.tsx → v1/index.tsx} +2 -2
- package/src/ProgressCircle/v2/README.md +219 -0
- package/src/ProgressCircle/v2/index.tsx +196 -0
- package/src/ProgressCircle/v2/props.ts +141 -0
- package/src/ProgressCircle/v2/styles.ts +343 -0
- package/src/exports/a.ts +29 -0
- package/src/exports/b.ts +29 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ProgressBar/v1/index.d.ts.map +1 -0
- package/types/ProgressBar/v1/props.d.ts.map +1 -0
- package/types/ProgressBar/v1/styles.d.ts.map +1 -0
- package/types/ProgressBar/v1/theme.d.ts.map +1 -0
- package/types/ProgressBar/v2/index.d.ts +43 -0
- package/types/ProgressBar/v2/index.d.ts.map +1 -0
- package/types/ProgressBar/v2/props.d.ts +77 -0
- package/types/ProgressBar/v2/props.d.ts.map +1 -0
- package/types/ProgressBar/v2/styles.d.ts +15 -0
- package/types/ProgressBar/v2/styles.d.ts.map +1 -0
- package/types/ProgressCircle/v1/index.d.ts.map +1 -0
- package/types/ProgressCircle/v1/props.d.ts.map +1 -0
- package/types/ProgressCircle/v1/styles.d.ts.map +1 -0
- package/types/ProgressCircle/v1/theme.d.ts.map +1 -0
- package/types/ProgressCircle/v2/index.d.ts +49 -0
- package/types/ProgressCircle/v2/index.d.ts.map +1 -0
- package/types/ProgressCircle/v2/props.d.ts +75 -0
- package/types/ProgressCircle/v2/props.d.ts.map +1 -0
- package/types/ProgressCircle/v2/styles.d.ts +15 -0
- package/types/ProgressCircle/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +5 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +5 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/ProgressBar/index.d.ts.map +0 -1
- package/types/ProgressBar/props.d.ts.map +0 -1
- package/types/ProgressBar/styles.d.ts.map +0 -1
- package/types/ProgressBar/theme.d.ts.map +0 -1
- package/types/ProgressCircle/index.d.ts.map +0 -1
- package/types/ProgressCircle/props.d.ts.map +0 -1
- package/types/ProgressCircle/styles.d.ts.map +0 -1
- package/types/ProgressCircle/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.d.ts.map +0 -1
- /package/es/ProgressBar/{props.js → v1/props.js} +0 -0
- /package/es/ProgressBar/{styles.js → v1/styles.js} +0 -0
- /package/es/ProgressBar/{theme.js → v1/theme.js} +0 -0
- /package/es/ProgressCircle/{props.js → v1/props.js} +0 -0
- /package/es/ProgressCircle/{styles.js → v1/styles.js} +0 -0
- /package/es/ProgressCircle/{theme.js → v1/theme.js} +0 -0
- /package/lib/ProgressBar/{props.js → v1/props.js} +0 -0
- /package/lib/ProgressBar/{styles.js → v1/styles.js} +0 -0
- /package/lib/ProgressBar/{theme.js → v1/theme.js} +0 -0
- /package/lib/ProgressCircle/{props.js → v1/props.js} +0 -0
- /package/lib/ProgressCircle/{styles.js → v1/styles.js} +0 -0
- /package/lib/ProgressCircle/{theme.js → v1/theme.js} +0 -0
- /package/src/ProgressBar/{README.md → v1/README.md} +0 -0
- /package/src/ProgressBar/{props.ts → v1/props.ts} +0 -0
- /package/src/ProgressBar/{styles.ts → v1/styles.ts} +0 -0
- /package/src/ProgressBar/{theme.ts → v1/theme.ts} +0 -0
- /package/src/ProgressCircle/{README.md → v1/README.md} +0 -0
- /package/src/ProgressCircle/{props.ts → v1/props.ts} +0 -0
- /package/src/ProgressCircle/{styles.ts → v1/styles.ts} +0 -0
- /package/src/ProgressCircle/{theme.ts → v1/theme.ts} +0 -0
- /package/types/ProgressBar/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/ProgressBar/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/ProgressBar/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/ProgressBar/{theme.d.ts → v1/theme.d.ts} +0 -0
- /package/types/ProgressCircle/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/ProgressCircle/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/ProgressCircle/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/ProgressCircle/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["renderValue", "formatScreenReaderValue", "valueNow", "valueMax", "screenReaderLabel", "size", "color", "meterColor", "renderValueInside", "styles"];
|
|
3
|
+
var _dec, _class, _ProgressBar;
|
|
4
|
+
/*
|
|
5
|
+
* The MIT License (MIT)
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { Component } from 'react';
|
|
29
|
+
import { View } from '@instructure/ui-view/latest';
|
|
30
|
+
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils';
|
|
31
|
+
import { withStyle } from '@instructure/emotion';
|
|
32
|
+
import generateStyle from "./styles.js";
|
|
33
|
+
import { allowedProps } from "./props.js";
|
|
34
|
+
/**
|
|
35
|
+
---
|
|
36
|
+
category: components
|
|
37
|
+
---
|
|
38
|
+
**/
|
|
39
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
40
|
+
let ProgressBar = (_dec = withStyle(generateStyle), _dec(_class = (_ProgressBar = class ProgressBar extends Component {
|
|
41
|
+
constructor(...args) {
|
|
42
|
+
super(...args);
|
|
43
|
+
this.ref = null;
|
|
44
|
+
this.handleRef = el => {
|
|
45
|
+
const elementRef = this.props.elementRef;
|
|
46
|
+
this.ref = el;
|
|
47
|
+
if (typeof elementRef === 'function') {
|
|
48
|
+
elementRef(el);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
componentDidMount() {
|
|
53
|
+
var _this$props$makeStyle, _this$props;
|
|
54
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
55
|
+
}
|
|
56
|
+
componentDidUpdate() {
|
|
57
|
+
var _this$props$makeStyle2, _this$props2;
|
|
58
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
59
|
+
}
|
|
60
|
+
render() {
|
|
61
|
+
const _this$props3 = this.props,
|
|
62
|
+
renderValue = _this$props3.renderValue,
|
|
63
|
+
formatScreenReaderValue = _this$props3.formatScreenReaderValue,
|
|
64
|
+
valueNow = _this$props3.valueNow,
|
|
65
|
+
valueMax = _this$props3.valueMax,
|
|
66
|
+
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
67
|
+
size = _this$props3.size,
|
|
68
|
+
color = _this$props3.color,
|
|
69
|
+
meterColor = _this$props3.meterColor,
|
|
70
|
+
renderValueInside = _this$props3.renderValueInside,
|
|
71
|
+
styles = _this$props3.styles,
|
|
72
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
73
|
+
const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
|
|
74
|
+
valueNow: valueNow,
|
|
75
|
+
valueMax: valueMax
|
|
76
|
+
}) : void 0;
|
|
77
|
+
const value = callRenderProp(renderValue, {
|
|
78
|
+
valueNow: valueNow,
|
|
79
|
+
valueMax: valueMax
|
|
80
|
+
});
|
|
81
|
+
return _jsxs(View, {
|
|
82
|
+
...passthroughProps(props),
|
|
83
|
+
as: this.props.as,
|
|
84
|
+
css: styles === null || styles === void 0 ? void 0 : styles.progressBar,
|
|
85
|
+
margin: this.props.margin,
|
|
86
|
+
elementRef: this.handleRef,
|
|
87
|
+
"data-cid": "ProgressBar",
|
|
88
|
+
children: [_jsxs("span", {
|
|
89
|
+
css: styles === null || styles === void 0 ? void 0 : styles.trackLayout,
|
|
90
|
+
children: [_jsx("progress", {
|
|
91
|
+
css: styles === null || styles === void 0 ? void 0 : styles.htmlProgress,
|
|
92
|
+
max: valueMax,
|
|
93
|
+
value: valueNow,
|
|
94
|
+
"aria-valuetext": valueText,
|
|
95
|
+
"aria-label": screenReaderLabel
|
|
96
|
+
}), _jsx("span", {
|
|
97
|
+
css: styles === null || styles === void 0 ? void 0 : styles.track,
|
|
98
|
+
role: "presentation",
|
|
99
|
+
"aria-hidden": "true",
|
|
100
|
+
children: _jsx("span", {
|
|
101
|
+
css: styles === null || styles === void 0 ? void 0 : styles.trackValue,
|
|
102
|
+
children: renderValueInside && value
|
|
103
|
+
})
|
|
104
|
+
})]
|
|
105
|
+
}), value && !renderValueInside && _jsx("span", {
|
|
106
|
+
css: styles === null || styles === void 0 ? void 0 : styles.value,
|
|
107
|
+
"aria-hidden": "true",
|
|
108
|
+
children: value
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}, _ProgressBar.displayName = "ProgressBar", _ProgressBar.componentId = 'ProgressBar', _ProgressBar.allowedProps = allowedProps, _ProgressBar.defaultProps = {
|
|
113
|
+
formatScreenReaderValue: ({
|
|
114
|
+
valueNow,
|
|
115
|
+
valueMax
|
|
116
|
+
}) => `${valueNow} / ${valueMax}`,
|
|
117
|
+
size: 'medium',
|
|
118
|
+
valueMax: 100,
|
|
119
|
+
valueNow: 0,
|
|
120
|
+
as: 'div',
|
|
121
|
+
color: 'primary',
|
|
122
|
+
shouldAnimate: false,
|
|
123
|
+
// default to showing `success` color on completion
|
|
124
|
+
meterColor: ({
|
|
125
|
+
valueNow,
|
|
126
|
+
valueMax
|
|
127
|
+
}) => valueNow / valueMax >= 1 ? 'success' : 'brand'
|
|
128
|
+
}, _ProgressBar)) || _class);
|
|
129
|
+
export default ProgressBar;
|
|
130
|
+
export { ProgressBar };
|
|
@@ -22,8 +22,5 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
|
|
28
|
-
export type { ProgressBarProps } from './ProgressBar/props'
|
|
29
|
-
export type { ProgressCircleProps } from './ProgressCircle/props'
|
|
25
|
+
const allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'shouldAnimate', 'margin', 'elementRef', 'as'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,237 @@
|
|
|
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} sharedTokens Shared token object that stores common values for the theme.
|
|
33
|
+
* @return {Object} The final style object, which will be used in the component
|
|
34
|
+
*/
|
|
35
|
+
const generateStyle = (componentTheme, props, _sharedTokens) => {
|
|
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,
|
|
40
|
+
size = props.size,
|
|
41
|
+
color = props.color,
|
|
42
|
+
meterColor = props.meterColor,
|
|
43
|
+
shouldAnimate = props.shouldAnimate;
|
|
44
|
+
const meterColorClassName = typeof meterColor === 'function' ? meterColor({
|
|
45
|
+
valueNow,
|
|
46
|
+
valueMax
|
|
47
|
+
}) : meterColor;
|
|
48
|
+
const currentValue = valueNow > valueMax ? valueMax : valueNow < 0 ? 0 : valueNow;
|
|
49
|
+
const currentValuePercent = `${currentValue / valueMax * 100}%`;
|
|
50
|
+
const sizeVariants = {
|
|
51
|
+
'x-small': {
|
|
52
|
+
track: {
|
|
53
|
+
height: componentTheme.xSmallHeight
|
|
54
|
+
},
|
|
55
|
+
value: {
|
|
56
|
+
fontSize: componentTheme.xSmallValueFontSize
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
small: {
|
|
60
|
+
track: {
|
|
61
|
+
height: componentTheme.smallHeight
|
|
62
|
+
},
|
|
63
|
+
// product design wants = 18px
|
|
64
|
+
value: {
|
|
65
|
+
fontSize: componentTheme.smallValueFontSize
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
medium: {
|
|
69
|
+
track: {
|
|
70
|
+
height: componentTheme.mediumHeight
|
|
71
|
+
},
|
|
72
|
+
value: {
|
|
73
|
+
fontSize: componentTheme.mediumValueFontSize
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
large: {
|
|
77
|
+
track: {
|
|
78
|
+
height: componentTheme.largeHeight
|
|
79
|
+
},
|
|
80
|
+
value: {
|
|
81
|
+
fontSize: componentTheme.largeValueFontSize
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const colorVariants = {
|
|
86
|
+
primary: {
|
|
87
|
+
trackLayout: {
|
|
88
|
+
background: componentTheme.trackColor,
|
|
89
|
+
borderWidth: componentTheme.trackBottomBorderWidth,
|
|
90
|
+
borderStyle: 'solid',
|
|
91
|
+
borderColor: componentTheme.borderColor
|
|
92
|
+
},
|
|
93
|
+
trackBorder: {
|
|
94
|
+
borderBottomColor: componentTheme.trackBottomBorderColor
|
|
95
|
+
},
|
|
96
|
+
value: {
|
|
97
|
+
color: componentTheme.textColor
|
|
98
|
+
},
|
|
99
|
+
htmlProgress: {
|
|
100
|
+
borderColor: componentTheme.borderColor
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
'primary-inverse': {
|
|
104
|
+
trackLayout: {
|
|
105
|
+
background: componentTheme.trackColorInverse,
|
|
106
|
+
borderWidth: componentTheme.trackBottomBorderWidth,
|
|
107
|
+
borderStyle: 'solid',
|
|
108
|
+
borderColor: componentTheme.borderColorInverse
|
|
109
|
+
},
|
|
110
|
+
trackBorder: {
|
|
111
|
+
borderBottomColor: componentTheme.trackBottomBorderColorInverse
|
|
112
|
+
},
|
|
113
|
+
value: {
|
|
114
|
+
color: componentTheme.textColorInverse
|
|
115
|
+
},
|
|
116
|
+
htmlProgress: {
|
|
117
|
+
borderColor: componentTheme.borderColorInverse
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const trackBackgroundVariants = {
|
|
122
|
+
primary: {
|
|
123
|
+
brand: {
|
|
124
|
+
background: componentTheme.meterColorBrand
|
|
125
|
+
},
|
|
126
|
+
info: {
|
|
127
|
+
background: componentTheme.meterColorInfo
|
|
128
|
+
},
|
|
129
|
+
success: {
|
|
130
|
+
background: componentTheme.meterColorSuccess
|
|
131
|
+
},
|
|
132
|
+
danger: {
|
|
133
|
+
background: componentTheme.meterColorDanger
|
|
134
|
+
},
|
|
135
|
+
warning: {
|
|
136
|
+
background: componentTheme.meterColorWarning
|
|
137
|
+
},
|
|
138
|
+
alert: {
|
|
139
|
+
background: componentTheme.meterColorAlert
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
'primary-inverse': {
|
|
143
|
+
brand: {
|
|
144
|
+
background: componentTheme.meterColorBrandInverse
|
|
145
|
+
},
|
|
146
|
+
info: {
|
|
147
|
+
background: componentTheme.meterColorInfoInverse
|
|
148
|
+
},
|
|
149
|
+
success: {
|
|
150
|
+
background: componentTheme.meterColorSuccessInverse
|
|
151
|
+
},
|
|
152
|
+
danger: {
|
|
153
|
+
background: componentTheme.meterColorDangerInverse
|
|
154
|
+
},
|
|
155
|
+
warning: {
|
|
156
|
+
background: componentTheme.meterColorWarningInverse
|
|
157
|
+
},
|
|
158
|
+
alert: {
|
|
159
|
+
background: componentTheme.meterColorAlertInverse
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return {
|
|
164
|
+
progressBar: {
|
|
165
|
+
label: 'progressBar',
|
|
166
|
+
display: 'flex',
|
|
167
|
+
alignItems: 'center',
|
|
168
|
+
fontFamily: componentTheme.fontFamily,
|
|
169
|
+
fontWeight: componentTheme.fontWeight,
|
|
170
|
+
lineHeight: componentTheme.lineHeight,
|
|
171
|
+
fontSize: componentTheme.fontSize,
|
|
172
|
+
borderRadius: componentTheme.borderRadius
|
|
173
|
+
},
|
|
174
|
+
trackLayout: {
|
|
175
|
+
label: 'progressBar__trackLayout',
|
|
176
|
+
position: 'relative',
|
|
177
|
+
flex: 1,
|
|
178
|
+
borderRadius: 'inherit',
|
|
179
|
+
...colorVariants[color].trackLayout
|
|
180
|
+
},
|
|
181
|
+
track: {
|
|
182
|
+
label: 'progressBar__track',
|
|
183
|
+
display: 'block',
|
|
184
|
+
boxSizing: 'border-box',
|
|
185
|
+
width: '100%',
|
|
186
|
+
borderBottomWidth: componentTheme.trackBottomBorderWidth,
|
|
187
|
+
borderBottomStyle: 'solid',
|
|
188
|
+
background: 'transparent',
|
|
189
|
+
// Inner border-radius must be smaller than outer to avoid geometric gaps with nested rounded borders
|
|
190
|
+
// Formula: inner radius = outer radius - border width
|
|
191
|
+
borderTopLeftRadius: `calc(${componentTheme.borderRadius} - ${componentTheme.trackBottomBorderWidth})`,
|
|
192
|
+
borderBottomLeftRadius: `calc(${componentTheme.borderRadius} - ${componentTheme.trackBottomBorderWidth})`,
|
|
193
|
+
// Negative margin pulls track down so trackLayout's full border overlaps and hides track's bottom border.
|
|
194
|
+
// When trackLayout border is visible (light/dark themes), it creates a clean full border appearance.
|
|
195
|
+
// When trackLayout border is transparent (legacy Canvas), track's bottom border remains visible.
|
|
196
|
+
marginBottom: `calc(-1 * ${componentTheme.trackBottomBorderWidth})`,
|
|
197
|
+
...sizeVariants[size].track,
|
|
198
|
+
...colorVariants[color].trackBorder
|
|
199
|
+
},
|
|
200
|
+
trackValue: {
|
|
201
|
+
label: 'progressBar__trackValue',
|
|
202
|
+
display: 'block',
|
|
203
|
+
boxSizing: 'border-box',
|
|
204
|
+
height: '100%',
|
|
205
|
+
width: currentValuePercent,
|
|
206
|
+
maxWidth: '100%',
|
|
207
|
+
borderRadius: 'inherit',
|
|
208
|
+
...(shouldAnimate && {
|
|
209
|
+
transition: 'all 0.5s'
|
|
210
|
+
}),
|
|
211
|
+
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
212
|
+
},
|
|
213
|
+
value: {
|
|
214
|
+
label: 'progressBar__value',
|
|
215
|
+
lineHeight: 1,
|
|
216
|
+
boxSizing: 'border-box',
|
|
217
|
+
paddingInlineStart: componentTheme.valuePadding,
|
|
218
|
+
flex: '0 0 5.625rem',
|
|
219
|
+
...sizeVariants[size].value,
|
|
220
|
+
...colorVariants[color].value
|
|
221
|
+
},
|
|
222
|
+
htmlProgress: {
|
|
223
|
+
label: 'progressBar__htmlProgress',
|
|
224
|
+
display: 'block',
|
|
225
|
+
position: 'absolute',
|
|
226
|
+
top: '0',
|
|
227
|
+
left: '0',
|
|
228
|
+
width: '100%',
|
|
229
|
+
height: '100%',
|
|
230
|
+
boxSizing: 'border-box',
|
|
231
|
+
zIndex: -1,
|
|
232
|
+
opacity: 0,
|
|
233
|
+
...colorVariants[color].htmlProgress
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
export default generateStyle;
|
|
@@ -27,9 +27,9 @@ var _dec, _class, _ProgressCircle;
|
|
|
27
27
|
|
|
28
28
|
import { Component } from 'react';
|
|
29
29
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
30
|
-
import { View } from '@instructure/ui-view';
|
|
30
|
+
import { View } from '@instructure/ui-view/v11_6';
|
|
31
31
|
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils';
|
|
32
|
-
import { withStyle } from '@instructure/emotion';
|
|
32
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion';
|
|
33
33
|
import generateStyle from "./styles.js";
|
|
34
34
|
import generateComponentTheme from "./theme.js";
|
|
35
35
|
import { allowedProps } from "./props.js";
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["color", "renderValue", "formatScreenReaderValue", "meterColor", "valueNow", "valueMax", "screenReaderLabel", "size", "styles"];
|
|
3
|
+
var _dec, _class, _ProgressCircle;
|
|
4
|
+
/*
|
|
5
|
+
* The MIT License (MIT)
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { Component } from 'react';
|
|
29
|
+
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
30
|
+
import { View } from '@instructure/ui-view/latest';
|
|
31
|
+
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils';
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
33
|
+
import generateStyle from "./styles.js";
|
|
34
|
+
import { allowedProps } from "./props.js";
|
|
35
|
+
/**
|
|
36
|
+
---
|
|
37
|
+
category: components
|
|
38
|
+
---
|
|
39
|
+
**/
|
|
40
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
41
|
+
let ProgressCircle = (_dec = withStyle(generateStyle), _dec(_class = (_ProgressCircle = class ProgressCircle extends Component {
|
|
42
|
+
constructor(props) {
|
|
43
|
+
super(props);
|
|
44
|
+
this._timeouts = [];
|
|
45
|
+
this.ref = null;
|
|
46
|
+
this.handleRef = el => {
|
|
47
|
+
const elementRef = this.props.elementRef;
|
|
48
|
+
this.ref = el;
|
|
49
|
+
if (typeof elementRef === 'function') {
|
|
50
|
+
elementRef(el);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this.state = {
|
|
54
|
+
shouldAnimateOnMount: props.shouldAnimateOnMount
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
get makeStylesVariables() {
|
|
58
|
+
return {
|
|
59
|
+
shouldAnimateOnMount: this.state.shouldAnimateOnMount
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
componentDidMount() {
|
|
63
|
+
var _this$props$makeStyle, _this$props;
|
|
64
|
+
if (this.state.shouldAnimateOnMount) {
|
|
65
|
+
this._timeouts.push(setTimeout(() => {
|
|
66
|
+
this.setState({
|
|
67
|
+
shouldAnimateOnMount: false
|
|
68
|
+
});
|
|
69
|
+
}, this.props.animationDelay || 500));
|
|
70
|
+
}
|
|
71
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStylesVariables);
|
|
72
|
+
}
|
|
73
|
+
componentDidUpdate() {
|
|
74
|
+
var _this$props$makeStyle2, _this$props2;
|
|
75
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStylesVariables);
|
|
76
|
+
}
|
|
77
|
+
componentWillUnmount() {
|
|
78
|
+
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
79
|
+
}
|
|
80
|
+
render() {
|
|
81
|
+
var _styles$radii, _styles$radii2, _styles$radii3;
|
|
82
|
+
const _this$props3 = this.props,
|
|
83
|
+
color = _this$props3.color,
|
|
84
|
+
renderValue = _this$props3.renderValue,
|
|
85
|
+
formatScreenReaderValue = _this$props3.formatScreenReaderValue,
|
|
86
|
+
meterColor = _this$props3.meterColor,
|
|
87
|
+
valueNow = _this$props3.valueNow,
|
|
88
|
+
valueMax = _this$props3.valueMax,
|
|
89
|
+
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
90
|
+
size = _this$props3.size,
|
|
91
|
+
styles = _this$props3.styles,
|
|
92
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
93
|
+
const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
|
|
94
|
+
valueNow: valueNow,
|
|
95
|
+
valueMax: valueMax
|
|
96
|
+
}) : void 0;
|
|
97
|
+
// consolidating the label and aria-valuetext to put in aria-label because
|
|
98
|
+
// NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
|
|
99
|
+
// But leaving aria-valuetext because JAWS ignores aria-label
|
|
100
|
+
const labelAndValueText = `${screenReaderLabel} ${valueText}`;
|
|
101
|
+
const value = callRenderProp(renderValue, {
|
|
102
|
+
valueNow: valueNow,
|
|
103
|
+
valueMax: valueMax
|
|
104
|
+
});
|
|
105
|
+
const style = {
|
|
106
|
+
strokeDashoffset: `${styles === null || styles === void 0 ? void 0 : styles.dashOffset}em`
|
|
107
|
+
};
|
|
108
|
+
return _jsxs(View, {
|
|
109
|
+
...passthroughProps(props),
|
|
110
|
+
as: this.props.as,
|
|
111
|
+
elementRef: this.handleRef,
|
|
112
|
+
css: styles === null || styles === void 0 ? void 0 : styles.progressCircle,
|
|
113
|
+
margin: this.props.margin,
|
|
114
|
+
"data-cid": "ProgressCircle",
|
|
115
|
+
children: [_jsx(ScreenReaderContent, {
|
|
116
|
+
children: _jsx("progress", {
|
|
117
|
+
max: valueMax,
|
|
118
|
+
value: valueNow,
|
|
119
|
+
"aria-valuetext": labelAndValueText
|
|
120
|
+
})
|
|
121
|
+
}), value && _jsx("span", {
|
|
122
|
+
css: styles === null || styles === void 0 ? void 0 : styles.center,
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
children: _jsx("span", {
|
|
125
|
+
css: styles === null || styles === void 0 ? void 0 : styles.value,
|
|
126
|
+
children: value
|
|
127
|
+
})
|
|
128
|
+
}), _jsxs("svg", {
|
|
129
|
+
css: styles === null || styles === void 0 ? void 0 : styles.circle,
|
|
130
|
+
role: "presentation",
|
|
131
|
+
focusable: "false",
|
|
132
|
+
children: [_jsx("circle", {
|
|
133
|
+
css: styles === null || styles === void 0 ? void 0 : styles.track,
|
|
134
|
+
role: "presentation",
|
|
135
|
+
cx: "50%",
|
|
136
|
+
cy: "50%",
|
|
137
|
+
r: styles === null || styles === void 0 ? void 0 : (_styles$radii = styles.radii) === null || _styles$radii === void 0 ? void 0 : _styles$radii.radius
|
|
138
|
+
}), _jsx("circle", {
|
|
139
|
+
css: styles === null || styles === void 0 ? void 0 : styles.border,
|
|
140
|
+
role: "presentation",
|
|
141
|
+
cx: "50%",
|
|
142
|
+
cy: "50%",
|
|
143
|
+
r: styles === null || styles === void 0 ? void 0 : (_styles$radii2 = styles.radii) === null || _styles$radii2 === void 0 ? void 0 : _styles$radii2.borderOffsetRadius
|
|
144
|
+
}), _jsx("circle", {
|
|
145
|
+
css: styles === null || styles === void 0 ? void 0 : styles.meter,
|
|
146
|
+
role: "presentation",
|
|
147
|
+
style: style,
|
|
148
|
+
cx: "50%",
|
|
149
|
+
cy: "50%",
|
|
150
|
+
r: styles === null || styles === void 0 ? void 0 : (_styles$radii3 = styles.radii) === null || _styles$radii3 === void 0 ? void 0 : _styles$radii3.radius
|
|
151
|
+
})]
|
|
152
|
+
})]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, _ProgressCircle.displayName = "ProgressCircle", _ProgressCircle.componentId = 'ProgressCircle', _ProgressCircle.allowedProps = allowedProps, _ProgressCircle.defaultProps = {
|
|
156
|
+
formatScreenReaderValue: ({
|
|
157
|
+
valueNow,
|
|
158
|
+
valueMax
|
|
159
|
+
}) => `${valueNow} / ${valueMax}`,
|
|
160
|
+
size: 'medium',
|
|
161
|
+
valueMax: 100,
|
|
162
|
+
valueNow: 0,
|
|
163
|
+
as: 'div',
|
|
164
|
+
color: 'primary',
|
|
165
|
+
shouldAnimateOnMount: false,
|
|
166
|
+
// default to showing `success` color on completion
|
|
167
|
+
meterColor: ({
|
|
168
|
+
valueNow,
|
|
169
|
+
valueMax
|
|
170
|
+
}) => valueNow / valueMax >= 1 ? 'success' : 'brand'
|
|
171
|
+
}, _ProgressCircle)) || _class);
|
|
172
|
+
export default ProgressCircle;
|
|
173
|
+
export { ProgressCircle };
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
const allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'margin', 'elementRef', 'as', 'shouldAnimateOnMount', 'animationDelay'];
|
|
26
|
+
export { allowedProps };
|