@instructure/ui-rating 8.8.1-snapshot.3 → 8.9.0

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.
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.allowedProps = exports.propTypes = void 0;
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _emotion = require("@instructure/emotion");
13
+
14
+ /*
15
+ * The MIT License (MIT)
16
+ *
17
+ * Copyright (c) 2015 - present Instructure, Inc.
18
+ *
19
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ * of this software and associated documentation files (the "Software"), to deal
21
+ * in the Software without restriction, including without limitation the rights
22
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ * copies of the Software, and to permit persons to whom the Software is
24
+ * furnished to do so, subject to the following conditions:
25
+ *
26
+ * The above copyright notice and this permission notice shall be included in all
27
+ * copies or substantial portions of the Software.
28
+ *
29
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ * SOFTWARE.
36
+ */
37
+ const propTypes = {
38
+ /**
39
+ * A label is required for accessibility
40
+ */
41
+ label: _propTypes.default.string.isRequired,
42
+
43
+ /**
44
+ * A function that returns the current value formatted for screen readers
45
+ */
46
+ formatValueText: _propTypes.default.func,
47
+
48
+ /**
49
+ * Choose from a 0-3 or 0-5 rating system
50
+ */
51
+ iconCount: _propTypes.default.oneOf([3, 5]),
52
+
53
+ /**
54
+ * Choose from different rating icon sizes
55
+ */
56
+ size: _propTypes.default.oneOf(['small', 'medium', 'large']),
57
+
58
+ /**
59
+ * The maximum rating (defaults to iconCount)
60
+ */
61
+ valueMax: _propTypes.default.number,
62
+
63
+ /**
64
+ * The current rating
65
+ */
66
+ valueNow: _propTypes.default.number,
67
+
68
+ /**
69
+ * Set to make the icons animate when they become filled
70
+ */
71
+ animateFill: _propTypes.default.bool,
72
+
73
+ /**
74
+ * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
75
+ * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
76
+ * familiar CSS-like shorthand. For example: `margin="small auto large"`.
77
+ */
78
+ margin: _emotion.ThemeablePropTypes.spacing
79
+ };
80
+ exports.propTypes = propTypes;
81
+ const allowedProps = ['label', 'formatValueText', 'iconCount', 'size', 'valueMax', 'valueNow', 'animateFill', 'margin'];
82
+ exports.allowedProps = allowedProps;
@@ -9,8 +9,6 @@ exports.RatingIcon = exports.default = void 0;
9
9
 
10
10
  var _react = require("react");
11
11
 
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
12
  var _IconStarSolid = require("@instructure/ui-icons/lib/IconStarSolid.js");
15
13
 
16
14
  var _IconStarLightSolid = require("@instructure/ui-icons/lib/IconStarLightSolid.js");
@@ -25,6 +23,8 @@ var _styles = _interopRequireDefault(require("./styles"));
25
23
 
26
24
  var _theme = _interopRequireDefault(require("./theme"));
27
25
 
26
+ var _props = require("./props");
27
+
28
28
  var _dec, _class, _class2, _temp;
29
29
 
30
30
  /**
@@ -59,19 +59,23 @@ let RatingIcon = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
59
59
  }
60
60
 
61
61
  componentDidMount() {
62
- this.props.makeStyles(this.makeStyleProps());
62
+ var _this$props$makeStyle, _this$props;
63
+
64
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
63
65
 
64
66
  if (this.props.animateFill) {
65
67
  this._timeouts.push(setTimeout(this.fill, this.props.animationDelay));
66
68
  }
67
69
  }
68
70
 
69
- componentDidUpdate(prevProps, prevState, snapshot) {
71
+ componentDidUpdate(prevProps) {
72
+ var _this$props$makeStyle2, _this$props2;
73
+
70
74
  if (this.props.animateFill && this.props.filled && this.props.filled !== prevProps.filled) {
71
75
  this.fill();
72
76
  }
73
77
 
74
- this.props.makeStyles(this.makeStyleProps());
78
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
75
79
  }
76
80
 
77
81
  componentWillUnmount() {
@@ -81,31 +85,24 @@ let RatingIcon = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
81
85
  }
82
86
 
83
87
  render() {
88
+ var _this$props$styles, _this$props$styles2, _this$props$styles3;
89
+
84
90
  const animateFill = this.props.animateFill;
85
91
  const Icon = this.state.filled ? _IconStarSolid.IconStarSolid : _IconStarLightSolid.IconStarLightSolid;
86
92
  return (0, _emotion.jsx)("span", {
87
- css: this.props.styles.ratingIcon
93
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.ratingIcon
88
94
  }, (0, _emotion.jsx)("span", null, this.state.filled && animateFill ? (0, _emotion.jsx)(_Transition.Transition, {
89
95
  in: true,
90
96
  transitionOnMount: true,
91
97
  type: "scale"
92
98
  }, (0, _emotion.jsx)(Icon, {
93
- css: this.props.styles.icon
99
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.icon
94
100
  })) : (0, _emotion.jsx)(Icon, {
95
- css: this.props.styles.icon
101
+ css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.icon
96
102
  })));
97
103
  }
98
104
 
99
- }, _class2.displayName = "RatingIcon", _class2.componentId = 'Rating.Icon', _class2.propTypes = {
100
- animationDelay: _propTypes.default.number,
101
- animateFill: _propTypes.default.bool,
102
- filled: _propTypes.default.bool,
103
- size: _propTypes.default.oneOf(['small', 'medium', 'large']),
104
- // eslint-disable-next-line react/require-default-props
105
- makeStyles: _propTypes.default.func,
106
- // eslint-disable-next-line react/require-default-props
107
- styles: _propTypes.default.object
108
- }, _class2.defaultProps = {
105
+ }, _class2.displayName = "RatingIcon", _class2.componentId = 'Rating.Icon', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
109
106
  animationDelay: 200,
110
107
  animateFill: false,
111
108
  filled: false,
@@ -1,3 +1,14 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.allowedProps = exports.propTypes = void 0;
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
1
12
  /*
2
13
  * The MIT License (MIT)
3
14
  *
@@ -21,18 +32,12 @@
21
32
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
33
  * SOFTWARE.
23
34
  */
24
-
25
- import type { Spacing } from '@instructure/emotion'
26
-
27
- export type RatingProps = {
28
- label: string
29
- formatValueText?: (...args: any[]) => any
30
- iconCount?: 3 | 5
31
- size?: 'small' | 'medium' | 'large'
32
- valueMax?: number
33
- valueNow?: number
34
- animateFill?: boolean
35
- margin?: Spacing
36
- makeStyles?: (...args: any[]) => any
37
- styles?: any
38
- }
35
+ const propTypes = {
36
+ animationDelay: _propTypes.default.number,
37
+ animateFill: _propTypes.default.bool,
38
+ filled: _propTypes.default.bool,
39
+ size: _propTypes.default.oneOf(['small', 'medium', 'large'])
40
+ };
41
+ exports.propTypes = propTypes;
42
+ const allowedProps = ['animationDelay', 'animateFill', 'filled', 'size'];
43
+ exports.allowedProps = allowedProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-rating",
3
- "version": "8.8.1-snapshot.3+d5d6d4cd8",
3
+ "version": "8.9.0",
4
4
  "description": "A static rating component",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,23 +25,23 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/console": "8.8.1-snapshot.3+d5d6d4cd8",
29
- "@instructure/emotion": "8.8.1-snapshot.3+d5d6d4cd8",
30
- "@instructure/ui-a11y-content": "8.8.1-snapshot.3+d5d6d4cd8",
31
- "@instructure/ui-dom-utils": "8.8.1-snapshot.3+d5d6d4cd8",
32
- "@instructure/ui-icons": "8.8.1-snapshot.3+d5d6d4cd8",
33
- "@instructure/ui-motion": "8.8.1-snapshot.3+d5d6d4cd8",
34
- "@instructure/ui-react-utils": "8.8.1-snapshot.3+d5d6d4cd8",
35
- "@instructure/ui-testable": "8.8.1-snapshot.3+d5d6d4cd8",
36
- "@instructure/ui-view": "8.8.1-snapshot.3+d5d6d4cd8",
28
+ "@instructure/console": "8.9.0",
29
+ "@instructure/emotion": "8.9.0",
30
+ "@instructure/shared-types": "8.9.0",
31
+ "@instructure/ui-a11y-content": "8.9.0",
32
+ "@instructure/ui-dom-utils": "8.9.0",
33
+ "@instructure/ui-icons": "8.9.0",
34
+ "@instructure/ui-motion": "8.9.0",
35
+ "@instructure/ui-react-utils": "8.9.0",
36
+ "@instructure/ui-testable": "8.9.0",
37
+ "@instructure/ui-view": "8.9.0",
37
38
  "prop-types": "^15"
38
39
  },
39
40
  "devDependencies": {
40
- "@instructure/shared-types": "8.8.1-snapshot.3+d5d6d4cd8",
41
- "@instructure/ui-babel-preset": "8.8.1-snapshot.3+d5d6d4cd8",
42
- "@instructure/ui-test-locator": "8.8.1-snapshot.3+d5d6d4cd8",
43
- "@instructure/ui-test-utils": "8.8.1-snapshot.3+d5d6d4cd8",
44
- "@instructure/ui-themes": "8.8.1-snapshot.3+d5d6d4cd8"
41
+ "@instructure/ui-babel-preset": "8.9.0",
42
+ "@instructure/ui-test-locator": "8.9.0",
43
+ "@instructure/ui-test-utils": "8.9.0",
44
+ "@instructure/ui-themes": "8.9.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=16.8 <=17"
@@ -49,6 +49,5 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "sideEffects": false,
53
- "gitHead": "d5d6d4cd8f300e8635c69248f5d794c002269e08"
52
+ "sideEffects": false
54
53
  }
@@ -24,16 +24,16 @@
24
24
 
25
25
  /** @jsx jsx */
26
26
  import { Component } from 'react'
27
- import PropTypes from 'prop-types'
28
27
 
29
28
  import { View } from '@instructure/ui-view'
30
29
  import { ScreenReaderContent } from '@instructure/ui-a11y-content'
31
30
  import { omitProps } from '@instructure/ui-react-utils'
32
31
  import { testable } from '@instructure/ui-testable'
33
32
  import { RatingIcon } from '../RatingIcon'
34
- import { withStyle, jsx, ThemeablePropTypes } from '@instructure/emotion'
33
+ import { withStyle, jsx } from '@instructure/emotion'
35
34
  import generateStyle from './styles'
36
- import { RatingProps } from './types'
35
+ import type { RatingProps } from './props'
36
+ import { allowedProps, propTypes } from './props'
37
37
 
38
38
  /**
39
39
  ---
@@ -45,47 +45,8 @@ category: components
45
45
  class Rating extends Component<RatingProps> {
46
46
  static readonly componentId = 'Rating'
47
47
 
48
- static propTypes = {
49
- /**
50
- * A label is required for accessibility
51
- */
52
- label: PropTypes.string.isRequired,
53
- /**
54
- * A function that returns the current value formatted for screen readers
55
- */
56
- formatValueText: PropTypes.func,
57
- /**
58
- * Choose from a 0-3 or 0-5 rating system
59
- */
60
- iconCount: PropTypes.oneOf([3, 5]),
61
- /**
62
- * Choose from different rating icon sizes
63
- */
64
- size: PropTypes.oneOf(['small', 'medium', 'large']),
65
- /**
66
- * The maximum rating (defaults to iconCount)
67
- */
68
- valueMax: PropTypes.number,
69
- /**
70
- * The current rating
71
- */
72
- valueNow: PropTypes.number,
73
- /**
74
- * Set to make the icons animate when they become filled
75
- */
76
- animateFill: PropTypes.bool,
77
- /**
78
- * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
79
- * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
80
- * familiar CSS-like shorthand. For example: `margin="small auto large"`.
81
- */
82
- margin: ThemeablePropTypes.spacing,
83
-
84
- // eslint-disable-next-line react/require-default-props
85
- makeStyles: PropTypes.func,
86
- // eslint-disable-next-line react/require-default-props
87
- styles: PropTypes.object
88
- }
48
+ static allowedProps = allowedProps
49
+ static propTypes = propTypes
89
50
 
90
51
  static defaultProps = {
91
52
  animateFill: false,
@@ -93,22 +54,17 @@ class Rating extends Component<RatingProps> {
93
54
  formatValueText: (filled, iconCount) => `${filled} / ${iconCount}`,
94
55
  iconCount: 3,
95
56
  size: 'medium',
96
- valueNow: 0,
97
- margin: undefined,
98
- valueMax: undefined
57
+ valueNow: 0
99
58
  }
100
59
 
101
60
  static Icon = RatingIcon
102
61
 
103
62
  componentDidMount() {
104
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
105
- this.props.makeStyles()
63
+ this.props.makeStyles?.()
106
64
  }
107
65
 
108
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
109
- componentDidUpdate(prevProps, prevState, snapshot) {
110
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
111
- this.props.makeStyles()
66
+ componentDidUpdate() {
67
+ this.props.makeStyles?.()
112
68
  }
113
69
 
114
70
  get filled() {
@@ -156,7 +112,7 @@ class Rating extends Component<RatingProps> {
156
112
  return (
157
113
  <View
158
114
  {...passthroughProps}
159
- css={this.props.styles.rating}
115
+ css={this.props.styles?.rating}
160
116
  margin={margin}
161
117
  display="inline-block"
162
118
  >
@@ -0,0 +1,97 @@
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
+ import PropTypes from 'prop-types'
25
+
26
+ import { ThemeablePropTypes } from '@instructure/emotion'
27
+
28
+ import type { Spacing, WithStyleProps } from '@instructure/emotion'
29
+ import type { PropValidators } from '@instructure/shared-types'
30
+
31
+ type RatingOwnProps = {
32
+ label: string
33
+ formatValueText?: (...args: any[]) => any
34
+ iconCount?: 3 | 5
35
+ size?: 'small' | 'medium' | 'large'
36
+ valueMax?: number
37
+ valueNow?: number
38
+ animateFill?: boolean
39
+ margin?: Spacing
40
+ }
41
+
42
+ type PropKeys = keyof RatingOwnProps
43
+
44
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
45
+
46
+ type RatingProps = RatingOwnProps & WithStyleProps
47
+
48
+ const propTypes: PropValidators<PropKeys> = {
49
+ /**
50
+ * A label is required for accessibility
51
+ */
52
+ label: PropTypes.string.isRequired,
53
+ /**
54
+ * A function that returns the current value formatted for screen readers
55
+ */
56
+ formatValueText: PropTypes.func,
57
+ /**
58
+ * Choose from a 0-3 or 0-5 rating system
59
+ */
60
+ iconCount: PropTypes.oneOf([3, 5]),
61
+ /**
62
+ * Choose from different rating icon sizes
63
+ */
64
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
65
+ /**
66
+ * The maximum rating (defaults to iconCount)
67
+ */
68
+ valueMax: PropTypes.number,
69
+ /**
70
+ * The current rating
71
+ */
72
+ valueNow: PropTypes.number,
73
+ /**
74
+ * Set to make the icons animate when they become filled
75
+ */
76
+ animateFill: PropTypes.bool,
77
+ /**
78
+ * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
79
+ * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
80
+ * familiar CSS-like shorthand. For example: `margin="small auto large"`.
81
+ */
82
+ margin: ThemeablePropTypes.spacing
83
+ }
84
+
85
+ const allowedProps: AllowedPropKeys = [
86
+ 'label',
87
+ 'formatValueText',
88
+ 'iconCount',
89
+ 'size',
90
+ 'valueMax',
91
+ 'valueNow',
92
+ 'animateFill',
93
+ 'margin'
94
+ ]
95
+
96
+ export type { RatingProps }
97
+ export { propTypes, allowedProps }