@atlaskit/rating 0.3.28 → 0.3.29

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.
@@ -1,9 +1,12 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- var _templateObject;
4
2
  /* eslint-disable @atlaskit/design-system/use-visually-hidden */
5
- /** @jsx jsx */
3
+ /**
4
+ * @jsxRuntime classic
5
+ * @jsx jsx
6
+ */
6
7
  import { Children, cloneElement, Fragment, useState } from 'react';
8
+
9
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
10
  import { css, jsx } from '@emotion/react';
8
11
  import VisuallyHidden from '@atlaskit/visually-hidden';
9
12
  export default function RatingGroup(_ref) {
@@ -35,8 +38,37 @@ export default function RatingGroup(_ref) {
35
38
  console.error("@atlaskit/rating\nDon't use \"defaultValue\" with \"value\" you're trying to mix uncontrolled and controlled modes.\nUse \"defaultValue\" or \"value\" happy days :-).\n");
36
39
  }
37
40
  return jsx("div", {
38
- "data-testid": testId && "".concat(testId, "--root"),
39
- css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n /* Because some children are inline-block we make the font-size zero to eliminate the implicit space between them. */\n font-size: 0;\n\n /* This implementation does some interesting tricks to keep it flowing LTR and ensuring accessibility. */\n /* Instead of it starting in an empty state - it starts filled - and then uses the CSS sibling select \"~\" */\n /* to then display the empty state for the star rating. */\n\n // By default, filled in icon is shown\n [data-rating-icon-checked] {\n display: inline-block;\n }\n\n // By default, empty icon is NOT shown\n [data-rating-icon] {\n display: none;\n }\n\n label:hover\n ~ label\n [data-rating-icon-checked][data-rating-icon-checked],\n [data-testid='input-container-checked']\n ~ label\n [data-rating-icon-checked] {\n display: none;\n }\n\n label:hover ~ label [data-rating-icon][data-rating-icon],\n [data-testid='input-container-checked'] ~ label [data-rating-icon] {\n display: inline-block;\n }\n\n /* When hovering reset all elements back to filled state. */\n &:hover [data-rating-icon-checked][data-rating-icon-checked] {\n display: inline-block;\n }\n\n &:hover [data-rating-icon][data-rating-icon] {\n display: none;\n }\n "])))
41
+ "data-testid": testId && "".concat(testId, "--root")
42
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
43
+ ,
44
+ css: css({
45
+ display: 'inline-flex',
46
+ fontSize: 0,
47
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
48
+ '[data-rating-icon-checked]': {
49
+ display: 'inline-block'
50
+ },
51
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
52
+ '[data-rating-icon]': {
53
+ display: 'none'
54
+ },
55
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
56
+ "label:hover ~ label [data-rating-icon-checked][data-rating-icon-checked], [data-testid='input-container-checked'] ~ label [data-rating-icon-checked]": {
57
+ display: 'none'
58
+ },
59
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
60
+ "label:hover ~ label [data-rating-icon][data-rating-icon], [data-testid='input-container-checked'] ~ label [data-rating-icon]": {
61
+ display: 'inline-block'
62
+ },
63
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
64
+ '&:hover [data-rating-icon-checked][data-rating-icon-checked]': {
65
+ display: 'inline-block'
66
+ },
67
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
68
+ '&:hover [data-rating-icon][data-rating-icon]': {
69
+ display: 'none'
70
+ }
71
+ })
40
72
  }, !firstSelectionMade && jsx(Fragment, null, jsx("label", {
41
73
  htmlFor: "".concat(groupName, "--empty")
42
74
  }), jsx(VisuallyHidden, {
@@ -2,8 +2,13 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["isChecked", "name", "testId", "label", "id", "value", "onChange", "render"];
4
4
  /* eslint-disable @atlaskit/design-system/use-visually-hidden */
5
- /** @jsx jsx */
5
+ /**
6
+ * @jsxRuntime classic
7
+ * @jsx jsx
8
+ */
6
9
  import { forwardRef, Fragment, useCallback } from 'react';
10
+
11
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
12
  import { jsx } from '@emotion/react';
8
13
  import { easeInOut, smallDurationMs } from '@atlaskit/motion';
9
14
  import Tooltip from '@atlaskit/tooltip';
@@ -7,44 +7,44 @@ export interface RatingGroupProps {
7
7
  */
8
8
  onChange?: (value?: string) => void;
9
9
  /**
10
- * Group name for all of the child rating items.
11
- * If you have **multiple ratings on the same page make sure to have a unique name** for each group.
12
-
13
- * Defaults to `"ak--rating-group"`.
14
- */
10
+ * Group name for all of the child rating items.
11
+ * If you have **multiple ratings on the same page make sure to have a unique name** for each group.
12
+
13
+ * Defaults to `"ak--rating-group"`.
14
+ */
15
15
  groupName?: string;
16
16
  /**
17
- * Will set the default checked value for a child radio rating item.
18
- * Use when wanting to use this in an [uncontrolled way](https://reactjs.org/docs/uncontrolled-components.html).
19
-
20
- * Do not use with `value`.
21
- */
17
+ * Will set the default checked value for a child radio rating item.
18
+ * Use when wanting to use this in an [uncontrolled way](https://reactjs.org/docs/uncontrolled-components.html).
19
+
20
+ * Do not use with `value`.
21
+ */
22
22
  defaultValue?: string;
23
23
  /**
24
- * Value that is used to check a child rating item.
25
- * Use when wanting to use this in a [controlled way](https://reactjs.org/docs/forms.html#controlled-components).
26
-
27
- * Do not use with `defaultValue`.
28
- */
24
+ * Value that is used to check a child rating item.
25
+ * Use when wanting to use this in a [controlled way](https://reactjs.org/docs/forms.html#controlled-components).
26
+
27
+ * Do not use with `defaultValue`.
28
+ */
29
29
  value?: string;
30
30
  /**
31
- A `testId` prop is provided for specified elements,
32
- which is a unique string that appears as a data attribute `data-testid` in the rendered code,
33
- serving as a hook for automated tests.
34
-
35
- Will set these elements:
36
-
37
- * The root container `"{testId}--root"`
38
- * The empty input `"{testId}--input-empty"` which is used to signify "nothing is selected yet".
39
- */
31
+ A `testId` prop is provided for specified elements,
32
+ which is a unique string that appears as a data attribute `data-testid` in the rendered code,
33
+ serving as a hook for automated tests.
34
+
35
+ Will set these elements:
36
+
37
+ * The root container `"{testId}--root"`
38
+ * The empty input `"{testId}--input-empty"` which is used to signify "nothing is selected yet".
39
+ */
40
40
  testId?: string;
41
41
  /**
42
- * Pass in child rating items.
43
- * This component expects the markup to be defined in a particular way,
44
- * so if you pass extra wrapping markup expect undefined behaviour.
45
-
46
- * You can have any amount of child rating items.
47
- */
42
+ * Pass in child rating items.
43
+ * This component expects the markup to be defined in a particular way,
44
+ * so if you pass extra wrapping markup expect undefined behaviour.
45
+
46
+ * You can have any amount of child rating items.
47
+ */
48
48
  children: JSX.Element | JSX.Element[];
49
49
  }
50
50
  export default function RatingGroup({ groupName, onChange, defaultValue, value, testId, children, }: RatingGroupProps): jsx.JSX.Element;
@@ -9,32 +9,32 @@ export interface RatingProps {
9
9
  */
10
10
  label: string;
11
11
  /**
12
- * This is passed to the radio button input.
13
-
14
- * When using this with the `<Rating />` component this is handled for you.
15
- */
12
+ * This is passed to the radio button input.
13
+
14
+ * When using this with the `<Rating />` component this is handled for you.
15
+ */
16
16
  name?: string;
17
17
  /**
18
- * Sets checked state on the rating item.
19
-
20
- * When using this with the `<Rating />` component this is handled for you.
21
- */
18
+ * Sets checked state on the rating item.
19
+
20
+ * When using this with the `<Rating />` component this is handled for you.
21
+ */
22
22
  isChecked?: boolean;
23
23
  /**
24
- A `testId` prop is provided for specified elements,
25
- which is a unique string that appears as a data attribute `data-testid` in the rendered code,
26
- serving as a hook for automated tests.
27
-
28
- Will set two elements:
29
-
30
- * The label as `"{testId}--label"`
31
- * The radio button as `"{testId}--input"`
32
- * The unchecked icon container `"{testId}--icon-container"`
33
- * The checked icon container `"{testId}--icon-checked-container"`
34
-
35
- When using this with the `<Rating />` component this will inherit its `testId` as `"{testId}--{index}--{element}"`,
36
- for example label would be `"{testId}--{index}--label"`.
37
- */
24
+ A `testId` prop is provided for specified elements,
25
+ which is a unique string that appears as a data attribute `data-testid` in the rendered code,
26
+ serving as a hook for automated tests.
27
+
28
+ Will set two elements:
29
+
30
+ * The label as `"{testId}--label"`
31
+ * The radio button as `"{testId}--input"`
32
+ * The unchecked icon container `"{testId}--icon-container"`
33
+ * The checked icon container `"{testId}--icon-checked-container"`
34
+
35
+ When using this with the `<Rating />` component this will inherit its `testId` as `"{testId}--{index}--{element}"`,
36
+ for example label would be `"{testId}--{index}--label"`.
37
+ */
38
38
  testId?: string;
39
39
  /**
40
40
  * Value of the rating item.
@@ -42,19 +42,19 @@ export interface RatingProps {
42
42
  */
43
43
  value: string;
44
44
  /**
45
- * Id that is passed to both the label and the radio button element.
46
- * This is needed to declare their relationship.
47
-
48
- * When using this with the `<Rating />` component this is handled for you.
49
- */
45
+ * Id that is passed to both the label and the radio button element.
46
+ * This is needed to declare their relationship.
47
+
48
+ * When using this with the `<Rating />` component this is handled for you.
49
+ */
50
50
  id?: string;
51
51
  /**
52
- * Handler that is called back whenever the radio button element changes its checked state.
53
- * When checked will be passed the `value` -
54
- * when unchecked will be passed `undefined`.
55
-
56
- * When using this with the `<Rating />` component this is handled for you.
57
- */
52
+ * Handler that is called back whenever the radio button element changes its checked state.
53
+ * When checked will be passed the `value` -
54
+ * when unchecked will be passed `undefined`.
55
+
56
+ * When using this with the `<Rating />` component this is handled for you.
57
+ */
58
58
  onChange?: (value?: string) => void;
59
59
  }
60
60
  export interface InternalRatingProps extends RatingProps {
@@ -1,18 +1,18 @@
1
1
  import React from 'react';
2
- import { RatingProps } from './rating';
2
+ import { type RatingProps } from './rating';
3
3
  export interface StarProps extends RatingProps {
4
4
  /**
5
- * Size of the star icon.
6
-
7
- * Defaults to `"large"`.
8
- */
5
+ * Size of the star icon.
6
+
7
+ * Defaults to `"large"`.
8
+ */
9
9
  size?: 'small' | 'medium' | 'large' | 'xlarge';
10
10
  /**
11
- * Color of the star icon,
12
- * when wanting to customize the color please ensure you use `colors` from `@atlaskit/theme`.
13
-
14
- * Defaults to `colors.Y200`.
15
- */
11
+ * Color of the star icon,
12
+ * when wanting to customize the color please ensure you use `colors` from `@atlaskit/theme`.
13
+
14
+ * Defaults to `colors.Y200`.
15
+ */
16
16
  color?: string;
17
17
  }
18
18
  declare const Star: React.ForwardRefExoticComponent<StarProps & React.RefAttributes<HTMLLabelElement>>;
@@ -1,4 +1,4 @@
1
- import { InternalRatingProps } from '../components/rating';
1
+ import { type InternalRatingProps } from '../components/rating';
2
2
  /**
3
3
  * This gets around extract-react-types not supporting forwardRef.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { StarProps } from '../components/star';
1
+ import { type StarProps } from '../components/star';
2
2
  /**
3
3
  * This gets around extract-react-types not supporting forwardRef.
4
4
  */
@@ -3,4 +3,4 @@ export type { RatingGroupProps } from './components/rating-group';
3
3
  export { default as Star } from './components/star';
4
4
  export type { StarProps } from './components/star';
5
5
  export { default as Rating } from './components/rating';
6
- export type { InternalRatingProps, RatingProps, RatingRender, } from './components/rating';
6
+ export type { InternalRatingProps, RatingProps, RatingRender } from './components/rating';
@@ -7,44 +7,44 @@ export interface RatingGroupProps {
7
7
  */
8
8
  onChange?: (value?: string) => void;
9
9
  /**
10
- * Group name for all of the child rating items.
11
- * If you have **multiple ratings on the same page make sure to have a unique name** for each group.
12
-
13
- * Defaults to `"ak--rating-group"`.
14
- */
10
+ * Group name for all of the child rating items.
11
+ * If you have **multiple ratings on the same page make sure to have a unique name** for each group.
12
+
13
+ * Defaults to `"ak--rating-group"`.
14
+ */
15
15
  groupName?: string;
16
16
  /**
17
- * Will set the default checked value for a child radio rating item.
18
- * Use when wanting to use this in an [uncontrolled way](https://reactjs.org/docs/uncontrolled-components.html).
19
-
20
- * Do not use with `value`.
21
- */
17
+ * Will set the default checked value for a child radio rating item.
18
+ * Use when wanting to use this in an [uncontrolled way](https://reactjs.org/docs/uncontrolled-components.html).
19
+
20
+ * Do not use with `value`.
21
+ */
22
22
  defaultValue?: string;
23
23
  /**
24
- * Value that is used to check a child rating item.
25
- * Use when wanting to use this in a [controlled way](https://reactjs.org/docs/forms.html#controlled-components).
26
-
27
- * Do not use with `defaultValue`.
28
- */
24
+ * Value that is used to check a child rating item.
25
+ * Use when wanting to use this in a [controlled way](https://reactjs.org/docs/forms.html#controlled-components).
26
+
27
+ * Do not use with `defaultValue`.
28
+ */
29
29
  value?: string;
30
30
  /**
31
- A `testId` prop is provided for specified elements,
32
- which is a unique string that appears as a data attribute `data-testid` in the rendered code,
33
- serving as a hook for automated tests.
34
-
35
- Will set these elements:
36
-
37
- * The root container `"{testId}--root"`
38
- * The empty input `"{testId}--input-empty"` which is used to signify "nothing is selected yet".
39
- */
31
+ A `testId` prop is provided for specified elements,
32
+ which is a unique string that appears as a data attribute `data-testid` in the rendered code,
33
+ serving as a hook for automated tests.
34
+
35
+ Will set these elements:
36
+
37
+ * The root container `"{testId}--root"`
38
+ * The empty input `"{testId}--input-empty"` which is used to signify "nothing is selected yet".
39
+ */
40
40
  testId?: string;
41
41
  /**
42
- * Pass in child rating items.
43
- * This component expects the markup to be defined in a particular way,
44
- * so if you pass extra wrapping markup expect undefined behaviour.
45
-
46
- * You can have any amount of child rating items.
47
- */
42
+ * Pass in child rating items.
43
+ * This component expects the markup to be defined in a particular way,
44
+ * so if you pass extra wrapping markup expect undefined behaviour.
45
+
46
+ * You can have any amount of child rating items.
47
+ */
48
48
  children: JSX.Element | JSX.Element[];
49
49
  }
50
50
  export default function RatingGroup({ groupName, onChange, defaultValue, value, testId, children, }: RatingGroupProps): jsx.JSX.Element;
@@ -9,32 +9,32 @@ export interface RatingProps {
9
9
  */
10
10
  label: string;
11
11
  /**
12
- * This is passed to the radio button input.
13
-
14
- * When using this with the `<Rating />` component this is handled for you.
15
- */
12
+ * This is passed to the radio button input.
13
+
14
+ * When using this with the `<Rating />` component this is handled for you.
15
+ */
16
16
  name?: string;
17
17
  /**
18
- * Sets checked state on the rating item.
19
-
20
- * When using this with the `<Rating />` component this is handled for you.
21
- */
18
+ * Sets checked state on the rating item.
19
+
20
+ * When using this with the `<Rating />` component this is handled for you.
21
+ */
22
22
  isChecked?: boolean;
23
23
  /**
24
- A `testId` prop is provided for specified elements,
25
- which is a unique string that appears as a data attribute `data-testid` in the rendered code,
26
- serving as a hook for automated tests.
27
-
28
- Will set two elements:
29
-
30
- * The label as `"{testId}--label"`
31
- * The radio button as `"{testId}--input"`
32
- * The unchecked icon container `"{testId}--icon-container"`
33
- * The checked icon container `"{testId}--icon-checked-container"`
34
-
35
- When using this with the `<Rating />` component this will inherit its `testId` as `"{testId}--{index}--{element}"`,
36
- for example label would be `"{testId}--{index}--label"`.
37
- */
24
+ A `testId` prop is provided for specified elements,
25
+ which is a unique string that appears as a data attribute `data-testid` in the rendered code,
26
+ serving as a hook for automated tests.
27
+
28
+ Will set two elements:
29
+
30
+ * The label as `"{testId}--label"`
31
+ * The radio button as `"{testId}--input"`
32
+ * The unchecked icon container `"{testId}--icon-container"`
33
+ * The checked icon container `"{testId}--icon-checked-container"`
34
+
35
+ When using this with the `<Rating />` component this will inherit its `testId` as `"{testId}--{index}--{element}"`,
36
+ for example label would be `"{testId}--{index}--label"`.
37
+ */
38
38
  testId?: string;
39
39
  /**
40
40
  * Value of the rating item.
@@ -42,19 +42,19 @@ export interface RatingProps {
42
42
  */
43
43
  value: string;
44
44
  /**
45
- * Id that is passed to both the label and the radio button element.
46
- * This is needed to declare their relationship.
47
-
48
- * When using this with the `<Rating />` component this is handled for you.
49
- */
45
+ * Id that is passed to both the label and the radio button element.
46
+ * This is needed to declare their relationship.
47
+
48
+ * When using this with the `<Rating />` component this is handled for you.
49
+ */
50
50
  id?: string;
51
51
  /**
52
- * Handler that is called back whenever the radio button element changes its checked state.
53
- * When checked will be passed the `value` -
54
- * when unchecked will be passed `undefined`.
55
-
56
- * When using this with the `<Rating />` component this is handled for you.
57
- */
52
+ * Handler that is called back whenever the radio button element changes its checked state.
53
+ * When checked will be passed the `value` -
54
+ * when unchecked will be passed `undefined`.
55
+
56
+ * When using this with the `<Rating />` component this is handled for you.
57
+ */
58
58
  onChange?: (value?: string) => void;
59
59
  }
60
60
  export interface InternalRatingProps extends RatingProps {
@@ -1,18 +1,18 @@
1
1
  import React from 'react';
2
- import { RatingProps } from './rating';
2
+ import { type RatingProps } from './rating';
3
3
  export interface StarProps extends RatingProps {
4
4
  /**
5
- * Size of the star icon.
6
-
7
- * Defaults to `"large"`.
8
- */
5
+ * Size of the star icon.
6
+
7
+ * Defaults to `"large"`.
8
+ */
9
9
  size?: 'small' | 'medium' | 'large' | 'xlarge';
10
10
  /**
11
- * Color of the star icon,
12
- * when wanting to customize the color please ensure you use `colors` from `@atlaskit/theme`.
13
-
14
- * Defaults to `colors.Y200`.
15
- */
11
+ * Color of the star icon,
12
+ * when wanting to customize the color please ensure you use `colors` from `@atlaskit/theme`.
13
+
14
+ * Defaults to `colors.Y200`.
15
+ */
16
16
  color?: string;
17
17
  }
18
18
  declare const Star: React.ForwardRefExoticComponent<StarProps & React.RefAttributes<HTMLLabelElement>>;
@@ -1,4 +1,4 @@
1
- import { InternalRatingProps } from '../components/rating';
1
+ import { type InternalRatingProps } from '../components/rating';
2
2
  /**
3
3
  * This gets around extract-react-types not supporting forwardRef.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { StarProps } from '../components/star';
1
+ import { type StarProps } from '../components/star';
2
2
  /**
3
3
  * This gets around extract-react-types not supporting forwardRef.
4
4
  */
@@ -3,4 +3,4 @@ export type { RatingGroupProps } from './components/rating-group';
3
3
  export { default as Star } from './components/star';
4
4
  export type { StarProps } from './components/star';
5
5
  export { default as Rating } from './components/rating';
6
- export type { InternalRatingProps, RatingProps, RatingRender, } from './components/rating';
6
+ export type { InternalRatingProps, RatingProps, RatingRender } from './components/rating';