@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,243 +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} sharedTokens Shared token object that stores common values for the theme.
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = (componentTheme, props, _sharedTokens) => {
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
- borderWidth: componentTheme.trackBottomBorderWidth,
96
- borderStyle: 'solid',
97
- borderColor: componentTheme.borderColor
98
- },
99
- trackBorder: {
100
- borderBottomColor: componentTheme.trackBottomBorderColor
101
- },
102
- value: {
103
- color: componentTheme.textColor
104
- },
105
- htmlProgress: {
106
- borderColor: componentTheme.borderColor
107
- }
108
- },
109
- 'primary-inverse': {
110
- trackLayout: {
111
- background: componentTheme.trackColorInverse,
112
- borderWidth: componentTheme.trackBottomBorderWidth,
113
- borderStyle: 'solid',
114
- borderColor: componentTheme.borderColorInverse
115
- },
116
- trackBorder: {
117
- borderBottomColor: componentTheme.trackBottomBorderColorInverse
118
- },
119
- value: {
120
- color: componentTheme.textColorInverse
121
- },
122
- htmlProgress: {
123
- borderColor: componentTheme.borderColorInverse
124
- }
125
- }
126
- };
127
- const trackBackgroundVariants = {
128
- primary: {
129
- brand: {
130
- background: componentTheme.meterColorBrand
131
- },
132
- info: {
133
- background: componentTheme.meterColorInfo
134
- },
135
- success: {
136
- background: componentTheme.meterColorSuccess
137
- },
138
- danger: {
139
- background: componentTheme.meterColorDanger
140
- },
141
- warning: {
142
- background: componentTheme.meterColorWarning
143
- },
144
- alert: {
145
- background: componentTheme.meterColorAlert
146
- }
147
- },
148
- 'primary-inverse': {
149
- brand: {
150
- background: componentTheme.meterColorBrandInverse
151
- },
152
- info: {
153
- background: componentTheme.meterColorInfoInverse
154
- },
155
- success: {
156
- background: componentTheme.meterColorSuccessInverse
157
- },
158
- danger: {
159
- background: componentTheme.meterColorDangerInverse
160
- },
161
- warning: {
162
- background: componentTheme.meterColorWarningInverse
163
- },
164
- alert: {
165
- background: componentTheme.meterColorAlertInverse
166
- }
167
- }
168
- };
169
- return {
170
- progressBar: {
171
- label: 'progressBar',
172
- display: 'flex',
173
- alignItems: 'center',
174
- fontFamily: componentTheme.fontFamily,
175
- fontWeight: componentTheme.fontWeight,
176
- lineHeight: componentTheme.lineHeight,
177
- fontSize: componentTheme.fontSize,
178
- borderRadius: componentTheme.borderRadius
179
- },
180
- trackLayout: {
181
- label: 'progressBar__trackLayout',
182
- position: 'relative',
183
- flex: 1,
184
- borderRadius: 'inherit',
185
- ...colorVariants[color].trackLayout
186
- },
187
- track: {
188
- label: 'progressBar__track',
189
- display: 'block',
190
- boxSizing: 'border-box',
191
- width: '100%',
192
- borderBottomWidth: componentTheme.trackBottomBorderWidth,
193
- borderBottomStyle: 'solid',
194
- background: 'transparent',
195
- // Inner border-radius must be smaller than outer to avoid geometric gaps with nested rounded borders
196
- // Formula: inner radius = outer radius - border width
197
- borderTopLeftRadius: `calc(${componentTheme.borderRadius} - ${componentTheme.trackBottomBorderWidth})`,
198
- borderBottomLeftRadius: `calc(${componentTheme.borderRadius} - ${componentTheme.trackBottomBorderWidth})`,
199
- // Negative margin pulls track down so trackLayout's full border overlaps and hides track's bottom border.
200
- // When trackLayout border is visible (light/dark themes), it creates a clean full border appearance.
201
- // When trackLayout border is transparent (legacy Canvas), track's bottom border remains visible.
202
- marginBottom: `calc(-1 * ${componentTheme.trackBottomBorderWidth})`,
203
- ...sizeVariants[size].track,
204
- ...colorVariants[color].trackBorder
205
- },
206
- trackValue: {
207
- label: 'progressBar__trackValue',
208
- display: 'block',
209
- boxSizing: 'border-box',
210
- height: '100%',
211
- width: currentValuePercent,
212
- maxWidth: '100%',
213
- borderRadius: 'inherit',
214
- ...(shouldAnimate && {
215
- transition: 'all 0.5s'
216
- }),
217
- ...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
218
- },
219
- value: {
220
- label: 'progressBar__value',
221
- lineHeight: 1,
222
- boxSizing: 'border-box',
223
- paddingInlineStart: componentTheme.valuePadding,
224
- flex: '0 0 5.625rem',
225
- ...sizeVariants[size].value,
226
- ...colorVariants[color].value
227
- },
228
- htmlProgress: {
229
- label: 'progressBar__htmlProgress',
230
- display: 'block',
231
- position: 'absolute',
232
- top: '0',
233
- left: '0',
234
- width: '100%',
235
- height: '100%',
236
- boxSizing: 'border-box',
237
- zIndex: -1,
238
- opacity: 0,
239
- ...colorVariants[color].htmlProgress
240
- }
241
- };
242
- };
243
- var _default = exports.default = generateStyle;
@@ -1,182 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.ProgressCircle = void 0;
8
- var _react = require("react");
9
- var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
10
- var _v11_ = require("@instructure/ui-view/v11_6");
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 _theme = _interopRequireDefault(require("./theme"));
16
- var _props = require("./props");
17
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
18
- var _dec, _class;
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 ProgressCircle = exports.ProgressCircle = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = class ProgressCircle extends _react.Component {
48
- static displayName = "ProgressCircle";
49
- static componentId = 'ProgressCircle';
50
- static allowedProps = _props.allowedProps;
51
- static defaultProps = {
52
- formatScreenReaderValue: ({
53
- valueNow,
54
- valueMax
55
- }) => `${valueNow} / ${valueMax}`,
56
- size: 'medium',
57
- valueMax: 100,
58
- valueNow: 0,
59
- as: 'div',
60
- color: 'primary',
61
- shouldAnimateOnMount: false,
62
- // default to showing `success` color on completion
63
- meterColor: ({
64
- valueNow,
65
- valueMax
66
- }) => valueNow / valueMax >= 1 ? 'success' : 'brand'
67
- };
68
- _timeouts = [];
69
- ref = null;
70
- constructor(props) {
71
- super(props);
72
- this.state = {
73
- shouldAnimateOnMount: props.shouldAnimateOnMount
74
- };
75
- }
76
- handleRef = el => {
77
- const {
78
- elementRef
79
- } = this.props;
80
- this.ref = el;
81
- if (typeof elementRef === 'function') {
82
- elementRef(el);
83
- }
84
- };
85
- get makeStylesVariables() {
86
- return {
87
- shouldAnimateOnMount: this.state.shouldAnimateOnMount
88
- };
89
- }
90
- componentDidMount() {
91
- if (this.state.shouldAnimateOnMount) {
92
- this._timeouts.push(setTimeout(() => {
93
- this.setState({
94
- shouldAnimateOnMount: false
95
- });
96
- }, this.props.animationDelay || 500));
97
- }
98
- this.props.makeStyles?.(this.makeStylesVariables);
99
- }
100
- componentDidUpdate() {
101
- this.props.makeStyles?.(this.makeStylesVariables);
102
- }
103
- componentWillUnmount() {
104
- this._timeouts.forEach(timeout => clearTimeout(timeout));
105
- }
106
- render() {
107
- const {
108
- color,
109
- renderValue,
110
- formatScreenReaderValue,
111
- meterColor,
112
- valueNow,
113
- valueMax,
114
- screenReaderLabel,
115
- size,
116
- styles,
117
- ...props
118
- } = this.props;
119
- const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
120
- valueNow: valueNow,
121
- valueMax: valueMax
122
- }) : undefined;
123
- // consolidating the label and aria-valuetext to put in aria-label because
124
- // NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
125
- // But leaving aria-valuetext because JAWS ignores aria-label
126
- const labelAndValueText = `${screenReaderLabel} ${valueText}`;
127
- const value = (0, _callRenderProp.callRenderProp)(renderValue, {
128
- valueNow: valueNow,
129
- valueMax: valueMax
130
- });
131
- const style = {
132
- strokeDashoffset: `${styles?.dashOffset}em`
133
- };
134
- return (0, _jsxRuntime.jsxs)(_v11_.View, {
135
- ...(0, _passthroughProps.passthroughProps)(props),
136
- as: this.props.as,
137
- elementRef: this.handleRef,
138
- css: styles?.progressCircle,
139
- margin: this.props.margin,
140
- "data-cid": "ProgressCircle",
141
- children: [(0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
142
- children: (0, _jsxRuntime.jsx)("progress", {
143
- max: valueMax,
144
- value: valueNow,
145
- "aria-valuetext": labelAndValueText
146
- })
147
- }), value && (0, _jsxRuntime.jsx)("span", {
148
- css: styles?.center,
149
- "aria-hidden": "true",
150
- children: (0, _jsxRuntime.jsx)("span", {
151
- css: styles?.value,
152
- children: value
153
- })
154
- }), (0, _jsxRuntime.jsxs)("svg", {
155
- css: styles?.circle,
156
- role: "presentation",
157
- focusable: "false",
158
- children: [(0, _jsxRuntime.jsx)("circle", {
159
- css: styles?.track,
160
- role: "presentation",
161
- cx: "50%",
162
- cy: "50%",
163
- r: styles?.radii?.radius
164
- }), (0, _jsxRuntime.jsx)("circle", {
165
- css: styles?.border,
166
- role: "presentation",
167
- cx: "50%",
168
- cy: "50%",
169
- r: styles?.radii?.borderOffsetRadius
170
- }), (0, _jsxRuntime.jsx)("circle", {
171
- css: styles?.meter,
172
- role: "presentation",
173
- style: style,
174
- cx: "50%",
175
- cy: "50%",
176
- r: styles?.radii?.radius
177
- })]
178
- })]
179
- });
180
- }
181
- }) || _class);
182
- var _default = exports.default = ProgressCircle;
@@ -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', 'margin', 'elementRef', 'as', 'shouldAnimateOnMount', 'animationDelay'];