@instructure/ui-rating 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/Rating/v1/index.js +36 -35
- package/es/Rating/v2/index.js +36 -35
- package/es/RatingIcon/v1/index.js +35 -32
- package/es/RatingIcon/v1/styles.js +6 -2
- package/es/RatingIcon/v1/theme.js +12 -11
- package/es/RatingIcon/v2/index.js +36 -34
- package/es/RatingIcon/v2/styles.js +3 -1
- package/lib/Rating/v1/index.js +36 -35
- package/lib/Rating/v2/index.js +36 -35
- package/lib/RatingIcon/v1/index.js +35 -32
- package/lib/RatingIcon/v1/styles.js +6 -2
- package/lib/RatingIcon/v1/theme.js +12 -11
- package/lib/RatingIcon/v2/index.js +36 -34
- package/lib/RatingIcon/v2/styles.js +3 -1
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [11.7.3-snapshot-
|
|
6
|
+
## [11.7.3-snapshot-26](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-26) (2026-05-05)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/Rating/v1/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -37,27 +37,34 @@ category: components
|
|
|
37
37
|
---
|
|
38
38
|
**/
|
|
39
39
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
40
|
-
let Rating = (_dec = withStyle(generateStyle, null), _dec(_class =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
40
|
+
let Rating = (_dec = withStyle(generateStyle, null), _dec(_class = class Rating extends Component {
|
|
41
|
+
static displayName = "Rating";
|
|
42
|
+
static componentId = 'Rating';
|
|
43
|
+
static allowedProps = allowedProps;
|
|
44
|
+
static defaultProps = {
|
|
45
|
+
animateFill: false,
|
|
46
|
+
formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
|
|
47
|
+
iconCount: 3,
|
|
48
|
+
size: 'medium',
|
|
49
|
+
valueNow: 0
|
|
50
|
+
};
|
|
51
|
+
static Icon = RatingIcon;
|
|
52
|
+
ref = null;
|
|
53
|
+
handleRef = el => {
|
|
54
|
+
this.ref = el;
|
|
55
|
+
};
|
|
48
56
|
componentDidMount() {
|
|
49
|
-
|
|
50
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
57
|
+
this.props.makeStyles?.();
|
|
51
58
|
}
|
|
52
59
|
componentDidUpdate() {
|
|
53
|
-
|
|
54
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
60
|
+
this.props.makeStyles?.();
|
|
55
61
|
}
|
|
56
62
|
get filled() {
|
|
57
|
-
const
|
|
58
|
-
valueNow
|
|
59
|
-
iconCount
|
|
60
|
-
valueMax
|
|
63
|
+
const {
|
|
64
|
+
valueNow,
|
|
65
|
+
iconCount,
|
|
66
|
+
valueMax
|
|
67
|
+
} = this.props;
|
|
61
68
|
|
|
62
69
|
// prevent divide by zero errors
|
|
63
70
|
const max = !!valueMax && valueMax > 0 ? valueMax : iconCount;
|
|
@@ -74,19 +81,19 @@ let Rating = (_dec = withStyle(generateStyle, null), _dec(_class = (_Rating = cl
|
|
|
74
81
|
return this.props.iconCount - this.filled;
|
|
75
82
|
}
|
|
76
83
|
render() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const valueText = label + ' ' +
|
|
84
|
+
const {
|
|
85
|
+
iconCount,
|
|
86
|
+
animateFill,
|
|
87
|
+
size,
|
|
88
|
+
margin,
|
|
89
|
+
label,
|
|
90
|
+
formatValueText
|
|
91
|
+
} = this.props;
|
|
92
|
+
const valueText = label + ' ' + formatValueText?.(this.filled, iconCount);
|
|
86
93
|
const passthroughProps = View.omitViewProps(omitProps(this.props, Rating.allowedProps), Rating);
|
|
87
94
|
return _jsxs(View, {
|
|
88
95
|
...passthroughProps,
|
|
89
|
-
css:
|
|
96
|
+
css: this.props.styles?.rating,
|
|
90
97
|
margin: margin,
|
|
91
98
|
display: "inline-block",
|
|
92
99
|
elementRef: this.handleRef,
|
|
@@ -96,19 +103,13 @@ let Rating = (_dec = withStyle(generateStyle, null), _dec(_class = (_Rating = cl
|
|
|
96
103
|
}), [...Array(this.filled)].map((_x, i) => _jsx(RatingIcon, {
|
|
97
104
|
filled: true,
|
|
98
105
|
animateFill: animateFill,
|
|
99
|
-
animationDelay: animateFill ? (i + 1) * 200 :
|
|
106
|
+
animationDelay: animateFill ? (i + 1) * 200 : undefined,
|
|
100
107
|
size: size
|
|
101
108
|
}, i + 1)), [...Array(this.empty)].map((_x, i) => _jsx(RatingIcon, {
|
|
102
109
|
size: size
|
|
103
110
|
}, i + 1))]
|
|
104
111
|
});
|
|
105
112
|
}
|
|
106
|
-
}
|
|
107
|
-
animateFill: false,
|
|
108
|
-
formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
|
|
109
|
-
iconCount: 3,
|
|
110
|
-
size: 'medium',
|
|
111
|
-
valueNow: 0
|
|
112
|
-
}, _Rating.Icon = RatingIcon, _Rating)) || _class);
|
|
113
|
+
}) || _class);
|
|
113
114
|
export default Rating;
|
|
114
115
|
export { Rating };
|
package/es/Rating/v2/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -37,27 +37,34 @@ category: components
|
|
|
37
37
|
---
|
|
38
38
|
**/
|
|
39
39
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
40
|
-
let Rating = (_dec = withStyle(generateStyle), _dec(_class =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
40
|
+
let Rating = (_dec = withStyle(generateStyle), _dec(_class = class Rating extends Component {
|
|
41
|
+
static displayName = "Rating";
|
|
42
|
+
static componentId = 'Rating';
|
|
43
|
+
static allowedProps = allowedProps;
|
|
44
|
+
static defaultProps = {
|
|
45
|
+
animateFill: false,
|
|
46
|
+
formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
|
|
47
|
+
iconCount: 3,
|
|
48
|
+
size: 'medium',
|
|
49
|
+
valueNow: 0
|
|
50
|
+
};
|
|
51
|
+
static Icon = RatingIcon;
|
|
52
|
+
ref = null;
|
|
53
|
+
handleRef = el => {
|
|
54
|
+
this.ref = el;
|
|
55
|
+
};
|
|
48
56
|
componentDidMount() {
|
|
49
|
-
|
|
50
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
57
|
+
this.props.makeStyles?.();
|
|
51
58
|
}
|
|
52
59
|
componentDidUpdate() {
|
|
53
|
-
|
|
54
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
60
|
+
this.props.makeStyles?.();
|
|
55
61
|
}
|
|
56
62
|
get filled() {
|
|
57
|
-
const
|
|
58
|
-
valueNow
|
|
59
|
-
iconCount
|
|
60
|
-
valueMax
|
|
63
|
+
const {
|
|
64
|
+
valueNow,
|
|
65
|
+
iconCount,
|
|
66
|
+
valueMax
|
|
67
|
+
} = this.props;
|
|
61
68
|
|
|
62
69
|
// prevent divide by zero errors
|
|
63
70
|
const max = !!valueMax && valueMax > 0 ? valueMax : iconCount;
|
|
@@ -74,19 +81,19 @@ let Rating = (_dec = withStyle(generateStyle), _dec(_class = (_Rating = class Ra
|
|
|
74
81
|
return this.props.iconCount - this.filled;
|
|
75
82
|
}
|
|
76
83
|
render() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const valueText = label + ' ' +
|
|
84
|
+
const {
|
|
85
|
+
iconCount,
|
|
86
|
+
animateFill,
|
|
87
|
+
size,
|
|
88
|
+
margin,
|
|
89
|
+
label,
|
|
90
|
+
formatValueText
|
|
91
|
+
} = this.props;
|
|
92
|
+
const valueText = label + ' ' + formatValueText?.(this.filled, iconCount);
|
|
86
93
|
const passthroughProps = View.omitViewProps(omitProps(this.props, Rating.allowedProps), Rating);
|
|
87
94
|
return _jsxs(View, {
|
|
88
95
|
...passthroughProps,
|
|
89
|
-
css:
|
|
96
|
+
css: this.props.styles?.rating,
|
|
90
97
|
margin: margin,
|
|
91
98
|
display: "inline-block",
|
|
92
99
|
elementRef: this.handleRef,
|
|
@@ -96,19 +103,13 @@ let Rating = (_dec = withStyle(generateStyle), _dec(_class = (_Rating = class Ra
|
|
|
96
103
|
}), [...Array(this.filled)].map((_x, i) => _jsx(RatingIcon, {
|
|
97
104
|
filled: true,
|
|
98
105
|
animateFill: animateFill,
|
|
99
|
-
animationDelay: animateFill ? (i + 1) * 200 :
|
|
106
|
+
animationDelay: animateFill ? (i + 1) * 200 : undefined,
|
|
100
107
|
size: size
|
|
101
108
|
}, i + 1)), [...Array(this.empty)].map((_x, i) => _jsx(RatingIcon, {
|
|
102
109
|
size: size
|
|
103
110
|
}, i + 1))]
|
|
104
111
|
});
|
|
105
112
|
}
|
|
106
|
-
}
|
|
107
|
-
animateFill: false,
|
|
108
|
-
formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
|
|
109
|
-
iconCount: 3,
|
|
110
|
-
size: 'medium',
|
|
111
|
-
valueNow: 0
|
|
112
|
-
}, _Rating.Icon = RatingIcon, _Rating)) || _class);
|
|
113
|
+
}) || _class);
|
|
113
114
|
export default Rating;
|
|
114
115
|
export { Rating };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -38,53 +38,61 @@ id: Rating.Icon
|
|
|
38
38
|
---
|
|
39
39
|
**/
|
|
40
40
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
41
|
-
let RatingIcon = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class =
|
|
41
|
+
let RatingIcon = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = class RatingIcon extends Component {
|
|
42
|
+
static displayName = "RatingIcon";
|
|
43
|
+
static componentId = 'Rating.Icon';
|
|
44
|
+
static allowedProps = allowedProps;
|
|
45
|
+
static defaultProps = {
|
|
46
|
+
animationDelay: 200,
|
|
47
|
+
animateFill: false,
|
|
48
|
+
filled: false,
|
|
49
|
+
size: 'medium'
|
|
50
|
+
};
|
|
51
|
+
ref = null;
|
|
42
52
|
constructor(props) {
|
|
43
53
|
super(props);
|
|
44
|
-
this.ref = null;
|
|
45
|
-
this._timeouts = [];
|
|
46
|
-
this._animation = void 0;
|
|
47
|
-
this.makeStyleProps = () => {
|
|
48
|
-
return {
|
|
49
|
-
filled: this.state.filled
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
this.fill = () => {
|
|
53
|
-
this._animation = requestAnimationFrame(() => {
|
|
54
|
-
this.setState({
|
|
55
|
-
filled: true
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
54
|
this.state = {
|
|
60
55
|
filled: props.filled && !props.animateFill
|
|
61
56
|
};
|
|
62
57
|
}
|
|
58
|
+
_timeouts = [];
|
|
59
|
+
_animation;
|
|
63
60
|
componentDidMount() {
|
|
64
|
-
|
|
65
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
|
|
61
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
66
62
|
if (this.props.animateFill) {
|
|
67
63
|
this._timeouts.push(setTimeout(this.fill, this.props.animationDelay));
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
componentDidUpdate(prevProps) {
|
|
71
|
-
var _this$props$makeStyle2, _this$props2;
|
|
72
67
|
if (this.props.animateFill && this.props.filled && this.props.filled !== prevProps.filled) {
|
|
73
68
|
this.fill();
|
|
74
69
|
}
|
|
75
|
-
|
|
70
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
76
71
|
}
|
|
77
72
|
componentWillUnmount() {
|
|
78
73
|
this._animation && this._animation.cancel();
|
|
79
74
|
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
80
75
|
}
|
|
76
|
+
makeStyleProps = () => {
|
|
77
|
+
return {
|
|
78
|
+
filled: this.state.filled
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
fill = () => {
|
|
82
|
+
this._animation = requestAnimationFrame(() => {
|
|
83
|
+
this.setState({
|
|
84
|
+
filled: true
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
81
88
|
render() {
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
const {
|
|
90
|
+
animateFill
|
|
91
|
+
} = this.props;
|
|
84
92
|
const Icon = this.state.filled ? IconStarSolid : IconStarLightSolid;
|
|
85
93
|
return _jsx("span", {
|
|
86
94
|
"aria-hidden": "true",
|
|
87
|
-
css:
|
|
95
|
+
css: this.props.styles?.ratingIcon,
|
|
88
96
|
ref: el => {
|
|
89
97
|
this.ref = el;
|
|
90
98
|
},
|
|
@@ -93,18 +101,13 @@ let RatingIcon = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(
|
|
|
93
101
|
transitionOnMount: true,
|
|
94
102
|
type: "scale",
|
|
95
103
|
children: _jsx(Icon, {
|
|
96
|
-
css:
|
|
104
|
+
css: this.props.styles?.icon
|
|
97
105
|
})
|
|
98
106
|
}) : _jsx(Icon, {
|
|
99
|
-
css:
|
|
107
|
+
css: this.props.styles?.icon
|
|
100
108
|
})
|
|
101
109
|
});
|
|
102
110
|
}
|
|
103
|
-
}
|
|
104
|
-
animationDelay: 200,
|
|
105
|
-
animateFill: false,
|
|
106
|
-
filled: false,
|
|
107
|
-
size: 'medium'
|
|
108
|
-
}, _RatingIcon)) || _class);
|
|
111
|
+
}) || _class);
|
|
109
112
|
export default RatingIcon;
|
|
110
113
|
export { RatingIcon };
|
|
@@ -33,8 +33,12 @@
|
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props, state) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
36
|
+
const {
|
|
37
|
+
size
|
|
38
|
+
} = props;
|
|
39
|
+
const {
|
|
40
|
+
filled
|
|
41
|
+
} = state;
|
|
38
42
|
const sizeVariants = {
|
|
39
43
|
small: {
|
|
40
44
|
fontSize: componentTheme.smallIconFontSize
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
typography
|
|
34
|
-
spacing
|
|
35
|
-
themeName
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
typography,
|
|
34
|
+
spacing,
|
|
35
|
+
key: themeName
|
|
36
|
+
} = theme;
|
|
36
37
|
const themeSpecificStyle = {
|
|
37
38
|
canvas: {
|
|
38
39
|
iconEmptyColor: theme['ic-brand-primary'],
|
|
@@ -40,12 +41,12 @@ const generateComponentTheme = theme => {
|
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
43
|
const componentVariables = {
|
|
43
|
-
iconMargin: spacing
|
|
44
|
-
iconEmptyColor: colors
|
|
45
|
-
iconFilledColor: colors
|
|
46
|
-
smallIconFontSize: typography
|
|
47
|
-
mediumIconFontSize: typography
|
|
48
|
-
largeIconFontSize: typography
|
|
44
|
+
iconMargin: spacing?.xxxSmall,
|
|
45
|
+
iconEmptyColor: colors?.contrasts?.blue4570,
|
|
46
|
+
iconFilledColor: colors?.contrasts?.blue4570,
|
|
47
|
+
smallIconFontSize: typography?.fontSizeMedium,
|
|
48
|
+
mediumIconFontSize: typography?.fontSizeLarge,
|
|
49
|
+
largeIconFontSize: typography?.fontSizeXXLarge
|
|
49
50
|
};
|
|
50
51
|
return {
|
|
51
52
|
...componentVariables,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -43,56 +43,63 @@ parent: Rating
|
|
|
43
43
|
id: Rating.Icon
|
|
44
44
|
---
|
|
45
45
|
**/
|
|
46
|
-
let RatingIcon = (_dec = withStyle(generateStyle), _dec(_class =
|
|
46
|
+
let RatingIcon = (_dec = withStyle(generateStyle), _dec(_class = class RatingIcon extends Component {
|
|
47
|
+
static displayName = "RatingIcon";
|
|
48
|
+
static componentId = 'Rating.Icon';
|
|
49
|
+
static allowedProps = allowedProps;
|
|
50
|
+
static defaultProps = {
|
|
51
|
+
animationDelay: 200,
|
|
52
|
+
animateFill: false,
|
|
53
|
+
filled: false,
|
|
54
|
+
size: 'medium'
|
|
55
|
+
};
|
|
56
|
+
ref = null;
|
|
47
57
|
constructor(props) {
|
|
48
58
|
super(props);
|
|
49
|
-
this.ref = null;
|
|
50
|
-
this._timeouts = [];
|
|
51
|
-
this._animation = void 0;
|
|
52
|
-
this.makeStyleProps = () => {
|
|
53
|
-
return {
|
|
54
|
-
filled: this.state.filled
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
this.fill = () => {
|
|
58
|
-
this._animation = requestAnimationFrame(() => {
|
|
59
|
-
this.setState({
|
|
60
|
-
filled: true
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
59
|
this.state = {
|
|
65
60
|
filled: props.filled && !props.animateFill
|
|
66
61
|
};
|
|
67
62
|
}
|
|
63
|
+
_timeouts = [];
|
|
64
|
+
_animation;
|
|
68
65
|
componentDidMount() {
|
|
69
|
-
|
|
70
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
|
|
66
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
71
67
|
if (this.props.animateFill) {
|
|
72
68
|
this._timeouts.push(setTimeout(this.fill, this.props.animationDelay));
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
71
|
componentDidUpdate(prevProps) {
|
|
76
|
-
var _this$props$makeStyle2, _this$props2;
|
|
77
72
|
if (this.props.animateFill && this.props.filled && this.props.filled !== prevProps.filled) {
|
|
78
73
|
this.fill();
|
|
79
74
|
}
|
|
80
|
-
|
|
75
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
81
76
|
}
|
|
82
77
|
componentWillUnmount() {
|
|
83
78
|
this._animation && this._animation.cancel();
|
|
84
79
|
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
85
80
|
}
|
|
81
|
+
makeStyleProps = () => {
|
|
82
|
+
return {
|
|
83
|
+
filled: this.state.filled
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
fill = () => {
|
|
87
|
+
this._animation = requestAnimationFrame(() => {
|
|
88
|
+
this.setState({
|
|
89
|
+
filled: true
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
86
93
|
render() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
const {
|
|
95
|
+
animateFill,
|
|
96
|
+
size
|
|
97
|
+
} = this.props;
|
|
91
98
|
const Icon = this.state.filled ? StarSolidInstUIIcon : StarInstUIIcon;
|
|
92
99
|
const iconSize = ratingIconSizeToIconSize[size];
|
|
93
100
|
return _jsx("span", {
|
|
94
101
|
"aria-hidden": "true",
|
|
95
|
-
css:
|
|
102
|
+
css: this.props.styles?.ratingIcon,
|
|
96
103
|
ref: el => {
|
|
97
104
|
this.ref = el;
|
|
98
105
|
},
|
|
@@ -101,24 +108,19 @@ let RatingIcon = (_dec = withStyle(generateStyle), _dec(_class = (_RatingIcon =
|
|
|
101
108
|
transitionOnMount: true,
|
|
102
109
|
type: "scale",
|
|
103
110
|
children: _jsx("span", {
|
|
104
|
-
css:
|
|
111
|
+
css: this.props.styles?.icon,
|
|
105
112
|
children: _jsx(Icon, {
|
|
106
113
|
size: iconSize
|
|
107
114
|
})
|
|
108
115
|
})
|
|
109
116
|
}) : _jsx("span", {
|
|
110
|
-
css:
|
|
117
|
+
css: this.props.styles?.icon,
|
|
111
118
|
children: _jsx(Icon, {
|
|
112
119
|
size: iconSize
|
|
113
120
|
})
|
|
114
121
|
})
|
|
115
122
|
});
|
|
116
123
|
}
|
|
117
|
-
}
|
|
118
|
-
animationDelay: 200,
|
|
119
|
-
animateFill: false,
|
|
120
|
-
filled: false,
|
|
121
|
-
size: 'medium'
|
|
122
|
-
}, _RatingIcon)) || _class);
|
|
124
|
+
}) || _class);
|
|
123
125
|
export default RatingIcon;
|
|
124
126
|
export { RatingIcon };
|
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, _props, state, _sharedTokens) => {
|
|
36
|
-
const
|
|
36
|
+
const {
|
|
37
|
+
filled
|
|
38
|
+
} = state;
|
|
37
39
|
return {
|
|
38
40
|
ratingIcon: {
|
|
39
41
|
label: 'ratingIcon',
|
package/lib/Rating/v1/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
14
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
15
15
|
var _props = require("./props");
|
|
16
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
|
-
var _dec, _class
|
|
17
|
+
var _dec, _class;
|
|
18
18
|
/*
|
|
19
19
|
* The MIT License (MIT)
|
|
20
20
|
*
|
|
@@ -43,27 +43,34 @@ var _dec, _class, _Rating;
|
|
|
43
43
|
category: components
|
|
44
44
|
---
|
|
45
45
|
**/
|
|
46
|
-
let Rating = exports.Rating = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, null), _dec(_class =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
46
|
+
let Rating = exports.Rating = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, null), _dec(_class = class Rating extends _react.Component {
|
|
47
|
+
static displayName = "Rating";
|
|
48
|
+
static componentId = 'Rating';
|
|
49
|
+
static allowedProps = _props.allowedProps;
|
|
50
|
+
static defaultProps = {
|
|
51
|
+
animateFill: false,
|
|
52
|
+
formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
|
|
53
|
+
iconCount: 3,
|
|
54
|
+
size: 'medium',
|
|
55
|
+
valueNow: 0
|
|
56
|
+
};
|
|
57
|
+
static Icon = _v.RatingIcon;
|
|
58
|
+
ref = null;
|
|
59
|
+
handleRef = el => {
|
|
60
|
+
this.ref = el;
|
|
61
|
+
};
|
|
54
62
|
componentDidMount() {
|
|
55
|
-
|
|
56
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
63
|
+
this.props.makeStyles?.();
|
|
57
64
|
}
|
|
58
65
|
componentDidUpdate() {
|
|
59
|
-
|
|
60
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
66
|
+
this.props.makeStyles?.();
|
|
61
67
|
}
|
|
62
68
|
get filled() {
|
|
63
|
-
const
|
|
64
|
-
valueNow
|
|
65
|
-
iconCount
|
|
66
|
-
valueMax
|
|
69
|
+
const {
|
|
70
|
+
valueNow,
|
|
71
|
+
iconCount,
|
|
72
|
+
valueMax
|
|
73
|
+
} = this.props;
|
|
67
74
|
|
|
68
75
|
// prevent divide by zero errors
|
|
69
76
|
const max = !!valueMax && valueMax > 0 ? valueMax : iconCount;
|
|
@@ -80,19 +87,19 @@ let Rating = exports.Rating = (_dec = (0, _emotion.withStyleLegacy)(_styles.defa
|
|
|
80
87
|
return this.props.iconCount - this.filled;
|
|
81
88
|
}
|
|
82
89
|
render() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const valueText = label + ' ' +
|
|
90
|
+
const {
|
|
91
|
+
iconCount,
|
|
92
|
+
animateFill,
|
|
93
|
+
size,
|
|
94
|
+
margin,
|
|
95
|
+
label,
|
|
96
|
+
formatValueText
|
|
97
|
+
} = this.props;
|
|
98
|
+
const valueText = label + ' ' + formatValueText?.(this.filled, iconCount);
|
|
92
99
|
const passthroughProps = _v11_.View.omitViewProps((0, _omitProps.omitProps)(this.props, Rating.allowedProps), Rating);
|
|
93
100
|
return (0, _jsxRuntime.jsxs)(_v11_.View, {
|
|
94
101
|
...passthroughProps,
|
|
95
|
-
css:
|
|
102
|
+
css: this.props.styles?.rating,
|
|
96
103
|
margin: margin,
|
|
97
104
|
display: "inline-block",
|
|
98
105
|
elementRef: this.handleRef,
|
|
@@ -102,18 +109,12 @@ let Rating = exports.Rating = (_dec = (0, _emotion.withStyleLegacy)(_styles.defa
|
|
|
102
109
|
}), [...Array(this.filled)].map((_x, i) => (0, _jsxRuntime.jsx)(_v.RatingIcon, {
|
|
103
110
|
filled: true,
|
|
104
111
|
animateFill: animateFill,
|
|
105
|
-
animationDelay: animateFill ? (i + 1) * 200 :
|
|
112
|
+
animationDelay: animateFill ? (i + 1) * 200 : undefined,
|
|
106
113
|
size: size
|
|
107
114
|
}, i + 1)), [...Array(this.empty)].map((_x, i) => (0, _jsxRuntime.jsx)(_v.RatingIcon, {
|
|
108
115
|
size: size
|
|
109
116
|
}, i + 1))]
|
|
110
117
|
});
|
|
111
118
|
}
|
|
112
|
-
}
|
|
113
|
-
animateFill: false,
|
|
114
|
-
formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
|
|
115
|
-
iconCount: 3,
|
|
116
|
-
size: 'medium',
|
|
117
|
-
valueNow: 0
|
|
118
|
-
}, _Rating.Icon = _v.RatingIcon, _Rating)) || _class);
|
|
119
|
+
}) || _class);
|
|
119
120
|
var _default = exports.default = Rating;
|