@instructure/ui-rating 8.33.1 → 8.33.2
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/Rating/RatingLocator.js +3 -1
- package/es/Rating/__examples__/Rating.examples.js +1 -0
- package/es/Rating/index.js +13 -22
- package/es/Rating/styles.js +0 -1
- package/es/RatingIcon/index.js +1 -16
- package/es/RatingIcon/styles.js +0 -1
- package/es/RatingIcon/theme.js +5 -5
- package/lib/Rating/RatingLocator.js +1 -3
- package/lib/Rating/__examples__/Rating.examples.js +0 -1
- package/lib/Rating/index.js +12 -34
- package/lib/Rating/locator.js +0 -2
- package/lib/Rating/props.js +1 -4
- package/lib/Rating/styles.js +0 -2
- package/lib/RatingIcon/index.js +0 -26
- package/lib/RatingIcon/props.js +1 -3
- package/lib/RatingIcon/styles.js +0 -2
- package/lib/RatingIcon/theme.js +5 -6
- package/lib/index.js +0 -1
- package/package.json +15 -15
- package/tsconfig.build.tsbuildinfo +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.33.2](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2) (2023-01-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-rating
|
|
9
|
+
|
|
6
10
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-rating
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { Rating } from './index';
|
|
26
|
+
import { Rating } from './index';
|
|
26
27
|
|
|
28
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
27
29
|
export const RatingLocator = locator(Rating.selector);
|
package/es/Rating/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -34,65 +33,58 @@ import { RatingIcon } from '../RatingIcon';
|
|
|
34
33
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
35
34
|
import generateStyle from './styles';
|
|
36
35
|
import { allowedProps, propTypes } from './props';
|
|
36
|
+
|
|
37
37
|
/**
|
|
38
38
|
---
|
|
39
39
|
category: components
|
|
40
40
|
---
|
|
41
41
|
@tsProps
|
|
42
42
|
**/
|
|
43
|
-
|
|
44
43
|
let Rating = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class Rating extends Component {
|
|
45
44
|
constructor() {
|
|
46
45
|
super(...arguments);
|
|
47
46
|
this.ref = null;
|
|
48
|
-
|
|
49
47
|
this.handleRef = el => {
|
|
50
48
|
this.ref = el;
|
|
51
49
|
};
|
|
52
50
|
}
|
|
53
|
-
|
|
54
51
|
componentDidMount() {
|
|
55
52
|
var _this$props$makeStyle, _this$props;
|
|
56
|
-
|
|
57
53
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
58
54
|
}
|
|
59
|
-
|
|
60
55
|
componentDidUpdate() {
|
|
61
56
|
var _this$props$makeStyle2, _this$props2;
|
|
62
|
-
|
|
63
57
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
get filled() {
|
|
67
60
|
const _this$props3 = this.props,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
valueNow = _this$props3.valueNow,
|
|
62
|
+
iconCount = _this$props3.iconCount,
|
|
63
|
+
valueMax = _this$props3.valueMax;
|
|
71
64
|
|
|
65
|
+
// prevent divide by zero errors
|
|
72
66
|
const max = !!valueMax && valueMax > 0 ? valueMax : iconCount;
|
|
73
|
-
const filledIcons = Math.round(valueNow * iconCount / max);
|
|
67
|
+
const filledIcons = Math.round(valueNow * iconCount / max);
|
|
74
68
|
|
|
69
|
+
// Handle edge case where valueNow is greater than valueMax
|
|
75
70
|
if (filledIcons > iconCount) {
|
|
76
71
|
return iconCount;
|
|
77
72
|
} else {
|
|
78
73
|
return filledIcons;
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
|
-
|
|
82
76
|
get empty() {
|
|
83
77
|
return this.props.iconCount - this.filled;
|
|
84
78
|
}
|
|
85
|
-
|
|
86
79
|
render() {
|
|
87
80
|
var _this$props$styles;
|
|
88
|
-
|
|
89
81
|
const _this$props4 = this.props,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
iconCount = _this$props4.iconCount,
|
|
83
|
+
animateFill = _this$props4.animateFill,
|
|
84
|
+
size = _this$props4.size,
|
|
85
|
+
margin = _this$props4.margin,
|
|
86
|
+
label = _this$props4.label,
|
|
87
|
+
formatValueText = _this$props4.formatValueText;
|
|
96
88
|
const valueText = label + ' ' + (formatValueText === null || formatValueText === void 0 ? void 0 : formatValueText(this.filled, iconCount));
|
|
97
89
|
const passthroughProps = View.omitViewProps(omitProps(this.props, Rating.allowedProps), Rating);
|
|
98
90
|
return jsx(View, Object.assign({}, passthroughProps, {
|
|
@@ -111,7 +103,6 @@ let Rating = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(_c
|
|
|
111
103
|
size: size
|
|
112
104
|
})));
|
|
113
105
|
}
|
|
114
|
-
|
|
115
106
|
}, _class2.displayName = "Rating", _class2.componentId = 'Rating', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
116
107
|
animateFill: false,
|
|
117
108
|
formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
|
package/es/Rating/styles.js
CHANGED
package/es/RatingIcon/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -33,6 +32,7 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
33
32
|
import generateStyle from './styles';
|
|
34
33
|
import generateComponentTheme from './theme';
|
|
35
34
|
import { allowedProps, propTypes } from './props';
|
|
35
|
+
|
|
36
36
|
/**
|
|
37
37
|
---
|
|
38
38
|
parent: Rating
|
|
@@ -40,20 +40,17 @@ id: Rating.Icon
|
|
|
40
40
|
---
|
|
41
41
|
@tsProps
|
|
42
42
|
**/
|
|
43
|
-
|
|
44
43
|
let RatingIcon = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_class2 = class RatingIcon extends Component {
|
|
45
44
|
constructor(props) {
|
|
46
45
|
super(props);
|
|
47
46
|
this.ref = null;
|
|
48
47
|
this._timeouts = [];
|
|
49
48
|
this._animation = void 0;
|
|
50
|
-
|
|
51
49
|
this.makeStyleProps = () => {
|
|
52
50
|
return {
|
|
53
51
|
filled: this.state.filled
|
|
54
52
|
};
|
|
55
53
|
};
|
|
56
|
-
|
|
57
54
|
this.fill = () => {
|
|
58
55
|
this._animation = requestAnimationFrame(() => {
|
|
59
56
|
this.setState({
|
|
@@ -61,41 +58,30 @@ let RatingIcon = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(
|
|
|
61
58
|
});
|
|
62
59
|
});
|
|
63
60
|
};
|
|
64
|
-
|
|
65
61
|
this.state = {
|
|
66
62
|
filled: props.filled && !props.animateFill
|
|
67
63
|
};
|
|
68
64
|
}
|
|
69
|
-
|
|
70
65
|
componentDidMount() {
|
|
71
66
|
var _this$props$makeStyle, _this$props;
|
|
72
|
-
|
|
73
67
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
|
|
74
|
-
|
|
75
68
|
if (this.props.animateFill) {
|
|
76
69
|
this._timeouts.push(setTimeout(this.fill, this.props.animationDelay));
|
|
77
70
|
}
|
|
78
71
|
}
|
|
79
|
-
|
|
80
72
|
componentDidUpdate(prevProps) {
|
|
81
73
|
var _this$props$makeStyle2, _this$props2;
|
|
82
|
-
|
|
83
74
|
if (this.props.animateFill && this.props.filled && this.props.filled !== prevProps.filled) {
|
|
84
75
|
this.fill();
|
|
85
76
|
}
|
|
86
|
-
|
|
87
77
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
|
|
88
78
|
}
|
|
89
|
-
|
|
90
79
|
componentWillUnmount() {
|
|
91
80
|
this._animation && this._animation.cancel();
|
|
92
|
-
|
|
93
81
|
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
94
82
|
}
|
|
95
|
-
|
|
96
83
|
render() {
|
|
97
84
|
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
98
|
-
|
|
99
85
|
const animateFill = this.props.animateFill;
|
|
100
86
|
const Icon = this.state.filled ? IconStarSolid : IconStarLightSolid;
|
|
101
87
|
return jsx("span", {
|
|
@@ -113,7 +99,6 @@ let RatingIcon = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(
|
|
|
113
99
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.icon
|
|
114
100
|
})));
|
|
115
101
|
}
|
|
116
|
-
|
|
117
102
|
}, _class2.displayName = "RatingIcon", _class2.componentId = 'Rating.Icon', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
118
103
|
animationDelay: 200,
|
|
119
104
|
animateFill: false,
|
package/es/RatingIcon/styles.js
CHANGED
package/es/RatingIcon/theme.js
CHANGED
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
typography = theme.typography,
|
|
33
|
+
spacing = theme.spacing,
|
|
34
|
+
themeName = theme.key;
|
|
35
35
|
const themeSpecificStyle = {
|
|
36
36
|
canvas: {
|
|
37
37
|
iconEmptyColor: theme['ic-brand-primary'],
|
|
@@ -46,9 +46,9 @@ const generateComponentTheme = theme => {
|
|
|
46
46
|
mediumIconFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
|
|
47
47
|
largeIconFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeXXLarge
|
|
48
48
|
};
|
|
49
|
-
return {
|
|
49
|
+
return {
|
|
50
|
+
...componentVariables,
|
|
50
51
|
...themeSpecificStyle[themeName]
|
|
51
52
|
};
|
|
52
53
|
};
|
|
53
|
-
|
|
54
54
|
export default generateComponentTheme;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.RatingLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
var _index = require("./index");
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _index = require("./index");
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
36
34
|
const RatingLocator = (0, _locator.locator)(_index.Rating.selector);
|
|
37
35
|
exports.RatingLocator = RatingLocator;
|
package/lib/Rating/index.js
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.Rating = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _View = require("@instructure/ui-view/lib/View");
|
|
13
|
-
|
|
14
10
|
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
15
|
-
|
|
16
11
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
17
|
-
|
|
18
12
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
19
|
-
|
|
20
13
|
var _RatingIcon = require("../RatingIcon");
|
|
21
|
-
|
|
22
14
|
var _emotion = require("@instructure/emotion");
|
|
23
|
-
|
|
24
15
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
25
|
-
|
|
26
16
|
var _props = require("./props");
|
|
27
|
-
|
|
28
17
|
var _dec, _dec2, _class, _class2;
|
|
29
|
-
|
|
30
18
|
/**
|
|
31
19
|
---
|
|
32
20
|
category: components
|
|
@@ -37,58 +25,49 @@ let Rating = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (0,
|
|
|
37
25
|
constructor() {
|
|
38
26
|
super(...arguments);
|
|
39
27
|
this.ref = null;
|
|
40
|
-
|
|
41
28
|
this.handleRef = el => {
|
|
42
29
|
this.ref = el;
|
|
43
30
|
};
|
|
44
31
|
}
|
|
45
|
-
|
|
46
32
|
componentDidMount() {
|
|
47
33
|
var _this$props$makeStyle, _this$props;
|
|
48
|
-
|
|
49
34
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
50
35
|
}
|
|
51
|
-
|
|
52
36
|
componentDidUpdate() {
|
|
53
37
|
var _this$props$makeStyle2, _this$props2;
|
|
54
|
-
|
|
55
38
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
56
39
|
}
|
|
57
|
-
|
|
58
40
|
get filled() {
|
|
59
41
|
const _this$props3 = this.props,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
valueNow = _this$props3.valueNow,
|
|
43
|
+
iconCount = _this$props3.iconCount,
|
|
44
|
+
valueMax = _this$props3.valueMax;
|
|
63
45
|
|
|
46
|
+
// prevent divide by zero errors
|
|
64
47
|
const max = !!valueMax && valueMax > 0 ? valueMax : iconCount;
|
|
65
|
-
const filledIcons = Math.round(valueNow * iconCount / max);
|
|
48
|
+
const filledIcons = Math.round(valueNow * iconCount / max);
|
|
66
49
|
|
|
50
|
+
// Handle edge case where valueNow is greater than valueMax
|
|
67
51
|
if (filledIcons > iconCount) {
|
|
68
52
|
return iconCount;
|
|
69
53
|
} else {
|
|
70
54
|
return filledIcons;
|
|
71
55
|
}
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
get empty() {
|
|
75
58
|
return this.props.iconCount - this.filled;
|
|
76
59
|
}
|
|
77
|
-
|
|
78
60
|
render() {
|
|
79
61
|
var _this$props$styles;
|
|
80
|
-
|
|
81
62
|
const _this$props4 = this.props,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
63
|
+
iconCount = _this$props4.iconCount,
|
|
64
|
+
animateFill = _this$props4.animateFill,
|
|
65
|
+
size = _this$props4.size,
|
|
66
|
+
margin = _this$props4.margin,
|
|
67
|
+
label = _this$props4.label,
|
|
68
|
+
formatValueText = _this$props4.formatValueText;
|
|
88
69
|
const valueText = label + ' ' + (formatValueText === null || formatValueText === void 0 ? void 0 : formatValueText(this.filled, iconCount));
|
|
89
|
-
|
|
90
70
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Rating.allowedProps), Rating);
|
|
91
|
-
|
|
92
71
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, passthroughProps, {
|
|
93
72
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.rating,
|
|
94
73
|
margin: margin,
|
|
@@ -105,7 +84,6 @@ let Rating = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (0,
|
|
|
105
84
|
size: size
|
|
106
85
|
})));
|
|
107
86
|
}
|
|
108
|
-
|
|
109
87
|
}, _class2.displayName = "Rating", _class2.componentId = 'Rating', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
110
88
|
animateFill: false,
|
|
111
89
|
formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
|
package/lib/Rating/locator.js
CHANGED
package/lib/Rating/props.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _emotion = require("@instructure/emotion");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,6 +30,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
const propTypes = {
|
|
38
35
|
label: _propTypes.default.string.isRequired,
|
|
39
36
|
formatValueText: _propTypes.default.func,
|
package/lib/Rating/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -47,6 +46,5 @@ const generateStyle = () => {
|
|
|
47
46
|
}
|
|
48
47
|
};
|
|
49
48
|
};
|
|
50
|
-
|
|
51
49
|
var _default = generateStyle;
|
|
52
50
|
exports.default = _default;
|
package/lib/RatingIcon/index.js
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.RatingIcon = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _IconStarSolid = require("@instructure/ui-icons/lib/IconStarSolid.js");
|
|
13
|
-
|
|
14
10
|
var _IconStarLightSolid = require("@instructure/ui-icons/lib/IconStarLightSolid.js");
|
|
15
|
-
|
|
16
11
|
var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
|
|
17
|
-
|
|
18
12
|
var _Transition = require("@instructure/ui-motion/lib/Transition");
|
|
19
|
-
|
|
20
13
|
var _emotion = require("@instructure/emotion");
|
|
21
|
-
|
|
22
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
23
|
-
|
|
24
15
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
25
|
-
|
|
26
16
|
var _props = require("./props");
|
|
27
|
-
|
|
28
17
|
var _dec, _class, _class2;
|
|
29
|
-
|
|
30
18
|
/**
|
|
31
19
|
---
|
|
32
20
|
parent: Rating
|
|
@@ -40,13 +28,11 @@ let RatingIcon = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
40
28
|
this.ref = null;
|
|
41
29
|
this._timeouts = [];
|
|
42
30
|
this._animation = void 0;
|
|
43
|
-
|
|
44
31
|
this.makeStyleProps = () => {
|
|
45
32
|
return {
|
|
46
33
|
filled: this.state.filled
|
|
47
34
|
};
|
|
48
35
|
};
|
|
49
|
-
|
|
50
36
|
this.fill = () => {
|
|
51
37
|
this._animation = (0, _requestAnimationFrame.requestAnimationFrame)(() => {
|
|
52
38
|
this.setState({
|
|
@@ -54,41 +40,30 @@ let RatingIcon = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
54
40
|
});
|
|
55
41
|
});
|
|
56
42
|
};
|
|
57
|
-
|
|
58
43
|
this.state = {
|
|
59
44
|
filled: props.filled && !props.animateFill
|
|
60
45
|
};
|
|
61
46
|
}
|
|
62
|
-
|
|
63
47
|
componentDidMount() {
|
|
64
48
|
var _this$props$makeStyle, _this$props;
|
|
65
|
-
|
|
66
49
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
|
|
67
|
-
|
|
68
50
|
if (this.props.animateFill) {
|
|
69
51
|
this._timeouts.push(setTimeout(this.fill, this.props.animationDelay));
|
|
70
52
|
}
|
|
71
53
|
}
|
|
72
|
-
|
|
73
54
|
componentDidUpdate(prevProps) {
|
|
74
55
|
var _this$props$makeStyle2, _this$props2;
|
|
75
|
-
|
|
76
56
|
if (this.props.animateFill && this.props.filled && this.props.filled !== prevProps.filled) {
|
|
77
57
|
this.fill();
|
|
78
58
|
}
|
|
79
|
-
|
|
80
59
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
|
|
81
60
|
}
|
|
82
|
-
|
|
83
61
|
componentWillUnmount() {
|
|
84
62
|
this._animation && this._animation.cancel();
|
|
85
|
-
|
|
86
63
|
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
87
64
|
}
|
|
88
|
-
|
|
89
65
|
render() {
|
|
90
66
|
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
91
|
-
|
|
92
67
|
const animateFill = this.props.animateFill;
|
|
93
68
|
const Icon = this.state.filled ? _IconStarSolid.IconStarSolid : _IconStarLightSolid.IconStarLightSolid;
|
|
94
69
|
return (0, _emotion.jsx)("span", {
|
|
@@ -106,7 +81,6 @@ let RatingIcon = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
106
81
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.icon
|
|
107
82
|
})));
|
|
108
83
|
}
|
|
109
|
-
|
|
110
84
|
}, _class2.displayName = "RatingIcon", _class2.componentId = 'Rating.Icon', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
111
85
|
animationDelay: 200,
|
|
112
86
|
animateFill: false,
|
package/lib/RatingIcon/props.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
const propTypes = {
|
|
36
34
|
animationDelay: _propTypes.default.number,
|
|
37
35
|
animateFill: _propTypes.default.bool,
|
package/lib/RatingIcon/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -76,6 +75,5 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
76
75
|
}
|
|
77
76
|
};
|
|
78
77
|
};
|
|
79
|
-
|
|
80
78
|
var _default = generateStyle;
|
|
81
79
|
exports.default = _default;
|
package/lib/RatingIcon/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,9 +35,9 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
typography = theme.typography,
|
|
39
|
+
spacing = theme.spacing,
|
|
40
|
+
themeName = theme.key;
|
|
42
41
|
const themeSpecificStyle = {
|
|
43
42
|
canvas: {
|
|
44
43
|
iconEmptyColor: theme['ic-brand-primary'],
|
|
@@ -53,10 +52,10 @@ const generateComponentTheme = theme => {
|
|
|
53
52
|
mediumIconFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
|
|
54
53
|
largeIconFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeXXLarge
|
|
55
54
|
};
|
|
56
|
-
return {
|
|
55
|
+
return {
|
|
56
|
+
...componentVariables,
|
|
57
57
|
...themeSpecificStyle[themeName]
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
-
|
|
61
60
|
var _default = generateComponentTheme;
|
|
62
61
|
exports.default = _default;
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-rating",
|
|
3
|
-
"version": "8.33.
|
|
3
|
+
"version": "8.33.2",
|
|
4
4
|
"description": "A static rating component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,23 +24,23 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.13.10",
|
|
27
|
-
"@instructure/console": "8.33.
|
|
28
|
-
"@instructure/emotion": "8.33.
|
|
29
|
-
"@instructure/shared-types": "8.33.
|
|
30
|
-
"@instructure/ui-a11y-content": "8.33.
|
|
31
|
-
"@instructure/ui-dom-utils": "8.33.
|
|
32
|
-
"@instructure/ui-icons": "8.33.
|
|
33
|
-
"@instructure/ui-motion": "8.33.
|
|
34
|
-
"@instructure/ui-react-utils": "8.33.
|
|
35
|
-
"@instructure/ui-testable": "8.33.
|
|
36
|
-
"@instructure/ui-view": "8.33.
|
|
27
|
+
"@instructure/console": "8.33.2",
|
|
28
|
+
"@instructure/emotion": "8.33.2",
|
|
29
|
+
"@instructure/shared-types": "8.33.2",
|
|
30
|
+
"@instructure/ui-a11y-content": "8.33.2",
|
|
31
|
+
"@instructure/ui-dom-utils": "8.33.2",
|
|
32
|
+
"@instructure/ui-icons": "8.33.2",
|
|
33
|
+
"@instructure/ui-motion": "8.33.2",
|
|
34
|
+
"@instructure/ui-react-utils": "8.33.2",
|
|
35
|
+
"@instructure/ui-testable": "8.33.2",
|
|
36
|
+
"@instructure/ui-view": "8.33.2",
|
|
37
37
|
"prop-types": "^15"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@instructure/ui-babel-preset": "8.33.
|
|
41
|
-
"@instructure/ui-test-locator": "8.33.
|
|
42
|
-
"@instructure/ui-test-utils": "8.33.
|
|
43
|
-
"@instructure/ui-themes": "8.33.
|
|
40
|
+
"@instructure/ui-babel-preset": "8.33.2",
|
|
41
|
+
"@instructure/ui-test-locator": "8.33.2",
|
|
42
|
+
"@instructure/ui-test-utils": "8.33.2",
|
|
43
|
+
"@instructure/ui-themes": "8.33.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=16.8 <=18"
|