@hh.ru/magritte-ui-rating-review 2.0.15 → 3.0.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.
package/RatingReview.js CHANGED
@@ -4,10 +4,9 @@ import { forwardRef } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import { useDisabled } from '@hh.ru/magritte-common-use-disabled';
6
6
  import { StarFilledSize16, StarOutlinedSize16, StarFilledSize24, StarOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';
7
- import { normalizeRatingValue } from './normalizeRatingValue.js';
8
7
  import { Text } from '@hh.ru/magritte-ui-typography';
9
8
 
10
- var styles = {"rating-review":"magritte-rating-review___X1HDg_2-0-15","ratingReview":"magritte-rating-review___X1HDg_2-0-15","internal-container":"magritte-internal-container___Tutx7_2-0-15","internalContainer":"magritte-internal-container___Tutx7_2-0-15","size-medium":"magritte-size-medium___wVwww_2-0-15","sizeMedium":"magritte-size-medium___wVwww_2-0-15","disabled":"magritte-disabled___uGGmU_2-0-15","has-rating":"magritte-has-rating___BoybH_2-0-15","hasRating":"magritte-has-rating___BoybH_2-0-15"};
9
+ var styles = {"rating-review":"magritte-rating-review___X1HDg_3-0-0","ratingReview":"magritte-rating-review___X1HDg_3-0-0","internal-container":"magritte-internal-container___Tutx7_3-0-0","internalContainer":"magritte-internal-container___Tutx7_3-0-0","size-medium":"magritte-size-medium___wVwww_3-0-0","sizeMedium":"magritte-size-medium___wVwww_3-0-0","disabled":"magritte-disabled___uGGmU_3-0-0","has-rating":"magritte-has-rating___BoybH_3-0-0","hasRating":"magritte-has-rating___BoybH_3-0-0"};
11
10
 
12
11
  const ICON_BY_SIZE = {
13
12
  small: {
@@ -20,7 +19,7 @@ const ICON_BY_SIZE = {
20
19
  },
21
20
  };
22
21
  const RatingReview = forwardRef(({ 'data-qa': dataQa, value, 'aria-describedby': describedBy, size = 'small' }, ref) => {
23
- const normalizedValue = normalizeRatingValue(value);
22
+ const normalizedValue = Math.round(Math.max(Math.min(value ?? 0, 5), 0) * 10) / 10;
24
23
  const isDisabled = useDisabled();
25
24
  const fractionDigits = normalizedValue === 0 ? 0 : 1;
26
25
  const Icon = ICON_BY_SIZE[size][normalizedValue > 0 ? 'filled' : 'outline'];
@@ -1 +1 @@
1
- {"version":3,"file":"RatingReview.js","sources":["../src/RatingReview.tsx"],"sourcesContent":["import { forwardRef, type LegacyRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport {\n StarFilledSize16,\n StarOutlinedSize16,\n StarFilledSize24,\n StarOutlinedSize24,\n} from '@hh.ru/magritte-ui-icon/icon';\nimport { normalizeRatingValue } from '@hh.ru/magritte-ui-rating-review/normalizeRatingValue';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './rating-review.less';\n\nexport type RatingReviewSize = 'small' | 'medium';\n\nexport interface RatingReviewProps {\n 'data-qa'?: string;\n /** Значение */\n value: number | null;\n 'aria-describedby'?: string;\n /** Размер */\n size?: RatingReviewSize;\n}\n\nconst ICON_BY_SIZE = {\n small: {\n filled: StarFilledSize16,\n outline: StarOutlinedSize16,\n },\n medium: {\n filled: StarFilledSize24,\n outline: StarOutlinedSize24,\n },\n} as const;\n\nexport const RatingReview = forwardRef<HTMLElement, RatingReviewProps>(\n ({ 'data-qa': dataQa, value, 'aria-describedby': describedBy, size = 'small' }, ref) => {\n const normalizedValue = normalizeRatingValue(value);\n const isDisabled = useDisabled();\n const fractionDigits = normalizedValue === 0 ? 0 : 1;\n const Icon = ICON_BY_SIZE[size][normalizedValue > 0 ? 'filled' : 'outline'];\n\n return (\n <div\n role=\"img\"\n aria-label={normalizedValue.toLocaleString()}\n data-qa={dataQa}\n aria-describedby={describedBy}\n ref={ref as LegacyRef<HTMLDivElement>}\n className={classnames(styles.ratingReview, {\n [styles.sizeMedium]: size === 'medium',\n [styles.hasRating]: normalizedValue > 0,\n [styles.disabled]: isDisabled,\n })}\n >\n <div className={styles.internalContainer} aria-hidden>\n <Icon />\n <Text typography={size === 'small' ? 'subtitle-1-semibold' : 'title-4-semibold'}>\n {normalizedValue.toLocaleString(undefined, {\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits,\n })}\n </Text>\n </div>\n </div>\n );\n }\n);\n\nRatingReview.displayName = 'RatingReview';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AA0BA,MAAM,YAAY,GAAG;AACjB,IAAA,KAAK,EAAE;AACH,QAAA,MAAM,EAAE,gBAAgB;AACxB,QAAA,OAAO,EAAE,kBAAkB;AAC9B,KAAA;AACD,IAAA,MAAM,EAAE;AACJ,QAAA,MAAM,EAAE,gBAAgB;AACxB,QAAA,OAAO,EAAE,kBAAkB;AAC9B,KAAA;CACK,CAAC;AAEE,MAAA,YAAY,GAAG,UAAU,CAClC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,IAAI,GAAG,OAAO,EAAE,EAAE,GAAG,KAAI;AACnF,IAAA,MAAM,eAAe,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACpD,IAAA,MAAM,UAAU,GAAG,WAAW,EAAE,CAAC;AACjC,IAAA,MAAM,cAAc,GAAG,eAAe,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrD,IAAA,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,eAAe,GAAG,CAAC,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;IAE5E,QACIA,GACI,CAAA,KAAA,EAAA,EAAA,IAAI,EAAC,KAAK,EACE,YAAA,EAAA,eAAe,CAAC,cAAc,EAAE,EAAA,SAAA,EACnC,MAAM,EAAA,kBAAA,EACG,WAAW,EAC7B,GAAG,EAAE,GAAgC,EACrC,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE;AACvC,YAAA,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,KAAK,QAAQ;AACtC,YAAA,CAAC,MAAM,CAAC,SAAS,GAAG,eAAe,GAAG,CAAC;AACvC,YAAA,CAAC,MAAM,CAAC,QAAQ,GAAG,UAAU;AAChC,SAAA,CAAC,EAEF,QAAA,EAAAC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,iBAAiB,EACpC,aAAA,EAAA,IAAA,EAAA,QAAA,EAAA,CAAAD,GAAA,CAAC,IAAI,EAAG,EAAA,CAAA,EACRA,GAAC,CAAA,IAAI,IAAC,UAAU,EAAE,IAAI,KAAK,OAAO,GAAG,qBAAqB,GAAG,kBAAkB,YAC1E,eAAe,CAAC,cAAc,CAAC,SAAS,EAAE;AACvC,wBAAA,qBAAqB,EAAE,cAAc;AACrC,wBAAA,qBAAqB,EAAE,cAAc;AACxC,qBAAA,CAAC,EACC,CAAA,CAAA,EAAA,CACL,EACJ,CAAA,EACR;AACN,CAAC,EACH;AAEF,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
1
+ {"version":3,"file":"RatingReview.js","sources":["../src/RatingReview.tsx"],"sourcesContent":["import { forwardRef, type LegacyRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport {\n StarFilledSize16,\n StarOutlinedSize16,\n StarFilledSize24,\n StarOutlinedSize24,\n} from '@hh.ru/magritte-ui-icon/icon';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './rating-review.less';\n\nexport type RatingReviewSize = 'small' | 'medium';\n\nexport interface RatingReviewProps {\n 'data-qa'?: string;\n /** Значение */\n value: number | null;\n 'aria-describedby'?: string;\n /** Размер */\n size?: RatingReviewSize;\n}\n\nconst ICON_BY_SIZE = {\n small: {\n filled: StarFilledSize16,\n outline: StarOutlinedSize16,\n },\n medium: {\n filled: StarFilledSize24,\n outline: StarOutlinedSize24,\n },\n} as const;\n\nexport const RatingReview = forwardRef<HTMLElement, RatingReviewProps>(\n ({ 'data-qa': dataQa, value, 'aria-describedby': describedBy, size = 'small' }, ref) => {\n const normalizedValue = Math.round(Math.max(Math.min(value ?? 0, 5), 0) * 10) / 10;\n const isDisabled = useDisabled();\n const fractionDigits = normalizedValue === 0 ? 0 : 1;\n const Icon = ICON_BY_SIZE[size][normalizedValue > 0 ? 'filled' : 'outline'];\n\n return (\n <div\n role=\"img\"\n aria-label={normalizedValue.toLocaleString()}\n data-qa={dataQa}\n aria-describedby={describedBy}\n ref={ref as LegacyRef<HTMLDivElement>}\n className={classnames(styles.ratingReview, {\n [styles.sizeMedium]: size === 'medium',\n [styles.hasRating]: normalizedValue > 0,\n [styles.disabled]: isDisabled,\n })}\n >\n <div className={styles.internalContainer} aria-hidden>\n <Icon />\n <Text typography={size === 'small' ? 'subtitle-1-semibold' : 'title-4-semibold'}>\n {normalizedValue.toLocaleString(undefined, {\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits,\n })}\n </Text>\n </div>\n </div>\n );\n }\n);\n\nRatingReview.displayName = 'RatingReview';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;AAyBA,MAAM,YAAY,GAAG;AACjB,IAAA,KAAK,EAAE;AACH,QAAA,MAAM,EAAE,gBAAgB;AACxB,QAAA,OAAO,EAAE,kBAAkB;AAC9B,KAAA;AACD,IAAA,MAAM,EAAE;AACJ,QAAA,MAAM,EAAE,gBAAgB;AACxB,QAAA,OAAO,EAAE,kBAAkB;AAC9B,KAAA;CACK,CAAC;AAEE,MAAA,YAAY,GAAG,UAAU,CAClC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,IAAI,GAAG,OAAO,EAAE,EAAE,GAAG,KAAI;AACnF,IAAA,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAA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led-v23-2-3:#767676;
16
16
  --magritte-color-icon-state-warning-disabled-v23-2-3:#eb8d057a;
17
17
  }
18
- .magritte-rating-review___X1HDg_2-0-15{
18
+ .magritte-rating-review___X1HDg_3-0-0{
19
19
  display:inline-block;
20
20
  --magritte-ui-icon-color-override:var(--magritte-color-icon-tertiary-v23-2-3);
21
21
  --magritte-ui-text-color-override:var(--magritte-color-text-primary-v23-2-3);
22
22
  }
23
- .magritte-internal-container___Tutx7_2-0-15{
23
+ .magritte-internal-container___Tutx7_3-0-0{
24
24
  display:inline-flex;
25
25
  flex-wrap:nowrap;
26
26
  gap:6px;
@@ -28,16 +28,16 @@
28
28
  justify-content:center;
29
29
  height:22px;
30
30
  }
31
- .magritte-size-medium___wVwww_2-0-15 .magritte-internal-container___Tutx7_2-0-15{
31
+ .magritte-size-medium___wVwww_3-0-0 .magritte-internal-container___Tutx7_3-0-0{
32
32
  height:32px;
33
33
  }
34
- .magritte-disabled___uGGmU_2-0-15{
34
+ .magritte-disabled___uGGmU_3-0-0{
35
35
  --magritte-ui-icon-color-override:var(--magritte-color-icon-state-tertiary-disabled-v23-2-3);
36
36
  --magritte-ui-text-color-override:var(--magritte-color-text-state-primary-disabled-v23-2-3);
37
37
  }
38
- .magritte-disabled___uGGmU_2-0-15.magritte-has-rating___BoybH_2-0-15{
38
+ .magritte-disabled___uGGmU_3-0-0.magritte-has-rating___BoybH_3-0-0{
39
39
  --magritte-ui-icon-color-override:var(--magritte-color-icon-state-warning-disabled-v23-2-3);
40
40
  }
41
- .magritte-has-rating___BoybH_2-0-15{
41
+ .magritte-has-rating___BoybH_3-0-0{
42
42
  --magritte-ui-icon-color-override:var(--magritte-color-icon-warning-v23-2-3);
43
43
  }
package/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from '@hh.ru/magritte-ui-rating-review/RatingReview';
2
- export * from '@hh.ru/magritte-ui-rating-review/normalizeRatingValue';
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import './index.css';
2
2
  export { RatingReview } from './RatingReview.js';
3
- export { normalizeRatingValue } from './normalizeRatingValue.js';
4
3
  import 'react/jsx-runtime';
5
4
  import 'react';
6
5
  import 'classnames';
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
package/index.mock.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { ForwardRefExoticComponent } from 'react';
2
2
  export { type RatingReviewProps, type RatingReviewSize } from '@hh.ru/magritte-ui-rating-review/RatingReview';
3
- export { normalizeRatingValue } from '@hh.ru/magritte-ui-rating-review/normalizeRatingValue';
4
3
  export declare const RatingReview: ForwardRefExoticComponent<Record<string, unknown>>;
package/index.mock.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import './index.css';
2
2
  import { mockComponent } from '@hh.ru/magritte-ui-mock-component';
3
- export { normalizeRatingValue } from './normalizeRatingValue.js';
4
3
 
5
4
  const RatingReview = mockComponent('RatingReview');
6
5
 
package/index.mock.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mock.js","sources":["../src/index.mock.ts"],"sourcesContent":["import { ForwardRefExoticComponent } from 'react';\n\nimport { mockComponent } from '@hh.ru/magritte-ui-mock-component';\n\nexport { type RatingReviewProps, type RatingReviewSize } from '@hh.ru/magritte-ui-rating-review/RatingReview';\nexport { normalizeRatingValue } from '@hh.ru/magritte-ui-rating-review/normalizeRatingValue';\n\nexport const RatingReview: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent('RatingReview');\n"],"names":[],"mappings":";;;MAOa,YAAY,GAAuD,aAAa,CAAC,cAAc;;;;"}
1
+ {"version":3,"file":"index.mock.js","sources":["../src/index.mock.ts"],"sourcesContent":["import { ForwardRefExoticComponent } from 'react';\n\nimport { mockComponent } from '@hh.ru/magritte-ui-mock-component';\n\nexport { type RatingReviewProps, type RatingReviewSize } from '@hh.ru/magritte-ui-rating-review/RatingReview';\n\nexport const RatingReview: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent('RatingReview');\n"],"names":[],"mappings":";;MAMa,YAAY,GAAuD,aAAa,CAAC,cAAc;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hh.ru/magritte-ui-rating-review",
3
- "version": "2.0.15",
3
+ "version": "3.0.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -32,5 +32,5 @@
32
32
  "@hh.ru/magritte-ui-mock-component": "1.1.5",
33
33
  "@hh.ru/magritte-ui-typography": "4.2.6"
34
34
  },
35
- "gitHead": "90a91eaf0ef55ef0ae534be060b7bf4c27736f36"
35
+ "gitHead": "b20ca79252fa840d3d5fafb398e47efdfe3a00a9"
36
36
  }
@@ -1 +0,0 @@
1
- export declare const normalizeRatingValue: (value: number | null) => number;
@@ -1,5 +0,0 @@
1
- import './index.css';
2
- const normalizeRatingValue = (value) => value ? Math.round(Math.min(Math.max(value, 0), 5) * 2) / 2 : 0;
3
-
4
- export { normalizeRatingValue };
5
- //# sourceMappingURL=normalizeRatingValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeRatingValue.js","sources":["../src/normalizeRatingValue.ts"],"sourcesContent":["export const normalizeRatingValue = (value: number | null): number =>\n value ? Math.round(Math.min(Math.max(value, 0), 5) * 2) / 2 : 0;\n"],"names":[],"mappings":"AAAa,MAAA,oBAAoB,GAAG,CAAC,KAAoB,KACrD,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG;;;;"}