@hh.ru/magritte-ui-rating-review 3.1.43 → 3.1.44
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 +37 -21
- package/RatingReview.js.map +1 -1
- package/index.css +25 -25
- package/index.d.ts +1 -1
- package/index.mock.d.ts +1 -1
- package/index.mock.js +1 -1
- package/index.mock.js.map +1 -1
- package/package.json +5 -5
package/RatingReview.js
CHANGED
|
@@ -6,33 +6,49 @@ import { useDisabled } from '@hh.ru/magritte-common-use-disabled';
|
|
|
6
6
|
import { StarFilledSize16, StarOutlinedSize16, StarFilledSize24, StarOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';
|
|
7
7
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
8
8
|
|
|
9
|
-
var styles = {"rating-review":"magritte-rating-review___X1HDg_3-1-
|
|
9
|
+
var styles = {"rating-review":"magritte-rating-review___X1HDg_3-1-44","ratingReview":"magritte-rating-review___X1HDg_3-1-44","internal-container":"magritte-internal-container___Tutx7_3-1-44","internalContainer":"magritte-internal-container___Tutx7_3-1-44","size-medium":"magritte-size-medium___wVwww_3-1-44","sizeMedium":"magritte-size-medium___wVwww_3-1-44","disabled":"magritte-disabled___uGGmU_3-1-44","has-rating":"magritte-has-rating___BoybH_3-1-44","hasRating":"magritte-has-rating___BoybH_3-1-44"};
|
|
10
10
|
|
|
11
11
|
const ICON_BY_SIZE = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
small: {
|
|
13
|
+
filled: StarFilledSize16,
|
|
14
|
+
outline: StarOutlinedSize16
|
|
15
|
+
},
|
|
16
|
+
medium: {
|
|
17
|
+
filled: StarFilledSize24,
|
|
18
|
+
outline: StarOutlinedSize24
|
|
19
|
+
}
|
|
20
20
|
};
|
|
21
|
-
const RatingReview = forwardRef(
|
|
21
|
+
const RatingReview = forwardRef(
|
|
22
|
+
({ "data-qa": dataQa, value, "aria-describedby": describedBy, size = "small" }, ref) => {
|
|
22
23
|
const normalizedValue = Math.round(Math.max(Math.min(value ?? 0, 5), 0) * 10) / 10;
|
|
23
24
|
const isDisabled = useDisabled();
|
|
24
25
|
const fractionDigits = normalizedValue === 0 ? 0 : 1;
|
|
25
|
-
const Icon = ICON_BY_SIZE[size][normalizedValue > 0 ?
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
const Icon = ICON_BY_SIZE[size][normalizedValue > 0 ? "filled" : "outline"];
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
role: "img",
|
|
31
|
+
"aria-label": normalizedValue.toLocaleString(),
|
|
32
|
+
"data-qa": dataQa,
|
|
33
|
+
"aria-describedby": describedBy,
|
|
34
|
+
ref,
|
|
35
|
+
className: classnames(styles.ratingReview, {
|
|
36
|
+
[styles.sizeMedium]: size === "medium",
|
|
37
|
+
[styles.hasRating]: normalizedValue > 0,
|
|
38
|
+
[styles.disabled]: isDisabled
|
|
39
|
+
}),
|
|
40
|
+
children: /* @__PURE__ */ jsxs("div", { className: styles.internalContainer, "aria-hidden": true, children: [
|
|
41
|
+
/* @__PURE__ */ jsx(Icon, {}),
|
|
42
|
+
/* @__PURE__ */ jsx(Text, { typography: size === "small" ? "subtitle-1-semibold" : "title-4-semibold", children: normalizedValue.toLocaleString(void 0, {
|
|
43
|
+
maximumFractionDigits: fractionDigits,
|
|
44
|
+
minimumFractionDigits: fractionDigits
|
|
45
|
+
}) })
|
|
46
|
+
] })
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
RatingReview.displayName = "RatingReview";
|
|
36
52
|
|
|
37
53
|
export { RatingReview };
|
|
38
54
|
//# sourceMappingURL=RatingReview.js.map
|
package/RatingReview.js.map
CHANGED
|
@@ -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 { 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":[
|
|
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":[],"mappings":";;;;;;;;;AAyBA,MAAM,YAAe,GAAA;AAAA,EACjB,KAAO,EAAA;AAAA,IACH,MAAQ,EAAA,gBAAA;AAAA,IACR,OAAS,EAAA,kBAAA;AAAA,GACb;AAAA,EACA,MAAQ,EAAA;AAAA,IACJ,MAAQ,EAAA,gBAAA;AAAA,IACR,OAAS,EAAA,kBAAA;AAAA,GACb;AACJ,CAAA,CAAA;AAEO,MAAM,YAAe,GAAA,UAAA;AAAA,EACxB,CAAC,EAAE,SAAA,EAAW,MAAQ,EAAA,KAAA,EAAO,oBAAoB,WAAa,EAAA,IAAA,GAAO,OAAQ,EAAA,EAAG,GAAQ,KAAA;AACpF,IAAA,MAAM,eAAkB,GAAA,IAAA,CAAK,KAAM,CAAA,IAAA,CAAK,IAAI,IAAK,CAAA,GAAA,CAAI,KAAS,IAAA,CAAA,EAAG,CAAC,CAAA,EAAG,CAAC,CAAA,GAAI,EAAE,CAAI,GAAA,EAAA,CAAA;AAChF,IAAA,MAAM,aAAa,WAAY,EAAA,CAAA;AAC/B,IAAM,MAAA,cAAA,GAAiB,eAAoB,KAAA,CAAA,GAAI,CAAI,GAAA,CAAA,CAAA;AACnD,IAAA,MAAM,OAAO,YAAa,CAAA,IAAI,EAAE,eAAkB,GAAA,CAAA,GAAI,WAAW,SAAS,CAAA,CAAA;AAE1E,IACI,uBAAA,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACG,IAAK,EAAA,KAAA;AAAA,QACL,YAAA,EAAY,gBAAgB,cAAe,EAAA;AAAA,QAC3C,SAAS,EAAA,MAAA;AAAA,QACT,kBAAkB,EAAA,WAAA;AAAA,QAClB,GAAA;AAAA,QACA,SAAA,EAAW,UAAW,CAAA,MAAA,CAAO,YAAc,EAAA;AAAA,UACvC,CAAC,MAAA,CAAO,UAAU,GAAG,IAAS,KAAA,QAAA;AAAA,UAC9B,CAAC,MAAA,CAAO,SAAS,GAAG,eAAkB,GAAA,CAAA;AAAA,UACtC,CAAC,MAAO,CAAA,QAAQ,GAAG,UAAA;AAAA,SACtB,CAAA;AAAA,QAED,+BAAC,KAAI,EAAA,EAAA,SAAA,EAAW,MAAO,CAAA,iBAAA,EAAmB,eAAW,IACjD,EAAA,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,IAAK,EAAA,EAAA,CAAA;AAAA,0BACN,GAAA,CAAC,QAAK,UAAY,EAAA,IAAA,KAAS,UAAU,qBAAwB,GAAA,kBAAA,EACxD,QAAgB,EAAA,eAAA,CAAA,cAAA,CAAe,KAAW,CAAA,EAAA;AAAA,YACvC,qBAAuB,EAAA,cAAA;AAAA,YACvB,qBAAuB,EAAA,cAAA;AAAA,WAC1B,CACL,EAAA,CAAA;AAAA,SACJ,EAAA,CAAA;AAAA,OAAA;AAAA,KACJ,CAAA;AAAA,GAER;AACJ,EAAA;AAEA,YAAA,CAAa,WAAc,GAAA,cAAA;;;;"}
|
package/index.css
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
:root{
|
|
2
|
-
--magritte-color-text-primary-v26-0-
|
|
3
|
-
--magritte-color-text-state-primary-disabled-v26-0-
|
|
4
|
-
--magritte-color-icon-tertiary-v26-0-
|
|
5
|
-
--magritte-color-icon-warning-v26-0-
|
|
6
|
-
--magritte-color-icon-state-tertiary-disabled-v26-0-
|
|
7
|
-
--magritte-color-icon-state-warning-disabled-v26-0-
|
|
2
|
+
--magritte-color-text-primary-v26-0-1:#000000;
|
|
3
|
+
--magritte-color-text-state-primary-disabled-v26-0-1:#0000007a;
|
|
4
|
+
--magritte-color-icon-tertiary-v26-0-1:#AABBCA;
|
|
5
|
+
--magritte-color-icon-warning-v26-0-1:#ff9900;
|
|
6
|
+
--magritte-color-icon-state-tertiary-disabled-v26-0-1:#aabbca7a;
|
|
7
|
+
--magritte-color-icon-state-warning-disabled-v26-0-1:#ff99007a;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.magritte-night-theme{
|
|
11
|
-
--magritte-color-text-primary-v26-0-
|
|
12
|
-
--magritte-color-text-state-primary-disabled-v26-0-
|
|
13
|
-
--magritte-color-icon-tertiary-v26-0-
|
|
14
|
-
--magritte-color-icon-warning-v26-0-
|
|
15
|
-
--magritte-color-icon-state-tertiary-disabled-v26-0-
|
|
16
|
-
--magritte-color-icon-state-warning-disabled-v26-0-
|
|
17
|
-
}
|
|
18
|
-
.magritte-rating-review___X1HDg_3-1-
|
|
11
|
+
--magritte-color-text-primary-v26-0-1:#ffffff;
|
|
12
|
+
--magritte-color-text-state-primary-disabled-v26-0-1:#ababab7a;
|
|
13
|
+
--magritte-color-icon-tertiary-v26-0-1:#767676;
|
|
14
|
+
--magritte-color-icon-warning-v26-0-1:#EB8D05;
|
|
15
|
+
--magritte-color-icon-state-tertiary-disabled-v26-0-1:#767676;
|
|
16
|
+
--magritte-color-icon-state-warning-disabled-v26-0-1:#eb8d057a;
|
|
17
|
+
}
|
|
18
|
+
.magritte-rating-review___X1HDg_3-1-44{
|
|
19
19
|
display:inline-block;
|
|
20
|
-
--magritte-ui-icon-color-override:var(--magritte-color-icon-tertiary-v26-0-
|
|
21
|
-
--magritte-ui-text-color-override:var(--magritte-color-text-primary-v26-0-
|
|
20
|
+
--magritte-ui-icon-color-override:var(--magritte-color-icon-tertiary-v26-0-1);
|
|
21
|
+
--magritte-ui-text-color-override:var(--magritte-color-text-primary-v26-0-1);
|
|
22
22
|
}
|
|
23
|
-
.magritte-internal-container___Tutx7_3-1-
|
|
23
|
+
.magritte-internal-container___Tutx7_3-1-44{
|
|
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_3-1-
|
|
31
|
+
.magritte-size-medium___wVwww_3-1-44 .magritte-internal-container___Tutx7_3-1-44{
|
|
32
32
|
height:32px;
|
|
33
33
|
}
|
|
34
|
-
.magritte-disabled___uGGmU_3-1-
|
|
35
|
-
--magritte-ui-icon-color-override:var(--magritte-color-icon-state-tertiary-disabled-v26-0-
|
|
36
|
-
--magritte-ui-text-color-override:var(--magritte-color-text-state-primary-disabled-v26-0-
|
|
34
|
+
.magritte-disabled___uGGmU_3-1-44{
|
|
35
|
+
--magritte-ui-icon-color-override:var(--magritte-color-icon-state-tertiary-disabled-v26-0-1);
|
|
36
|
+
--magritte-ui-text-color-override:var(--magritte-color-text-state-primary-disabled-v26-0-1);
|
|
37
37
|
}
|
|
38
|
-
.magritte-disabled___uGGmU_3-1-
|
|
39
|
-
--magritte-ui-icon-color-override:var(--magritte-color-icon-state-warning-disabled-v26-0-
|
|
38
|
+
.magritte-disabled___uGGmU_3-1-44.magritte-has-rating___BoybH_3-1-44{
|
|
39
|
+
--magritte-ui-icon-color-override:var(--magritte-color-icon-state-warning-disabled-v26-0-1);
|
|
40
40
|
}
|
|
41
|
-
.magritte-has-rating___BoybH_3-1-
|
|
42
|
-
--magritte-ui-icon-color-override:var(--magritte-color-icon-warning-v26-0-
|
|
41
|
+
.magritte-has-rating___BoybH_3-1-44{
|
|
42
|
+
--magritte-ui-icon-color-override:var(--magritte-color-icon-warning-v26-0-1);
|
|
43
43
|
}
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from './RatingReview';
|
package/index.mock.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent } from 'react';
|
|
2
|
-
export { type RatingReviewProps, type RatingReviewSize } from '
|
|
2
|
+
export { type RatingReviewProps, type RatingReviewSize } from './RatingReview';
|
|
3
3
|
export declare const RatingReview: ForwardRefExoticComponent<Record<string, unknown>>;
|
package/index.mock.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { mockComponent } from '@hh.ru/magritte-ui-mock-component';
|
|
3
3
|
|
|
4
|
-
const RatingReview = mockComponent(
|
|
4
|
+
const RatingReview = mockComponent("RatingReview");
|
|
5
5
|
|
|
6
6
|
export { RatingReview };
|
|
7
7
|
//# sourceMappingURL=index.mock.js.map
|
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';\n\nexport const RatingReview: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent('RatingReview');\n"],"names":[],"mappings":";;
|
|
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":";;AAMa,MAAA,YAAA,GAAmE,cAAc,cAAc;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-rating-review",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.44",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@hh.ru/magritte-common-use-disabled": "1.0.16",
|
|
30
|
-
"@hh.ru/magritte-design-tokens": "26.0.
|
|
31
|
-
"@hh.ru/magritte-ui-icon": "15.1.
|
|
30
|
+
"@hh.ru/magritte-design-tokens": "26.0.1",
|
|
31
|
+
"@hh.ru/magritte-ui-icon": "15.1.5",
|
|
32
32
|
"@hh.ru/magritte-ui-mock-component": "1.1.8",
|
|
33
|
-
"@hh.ru/magritte-ui-typography": "5.3.
|
|
33
|
+
"@hh.ru/magritte-ui-typography": "5.3.16"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "f6539d7a0e7cd42dd851458db1de04a748bbee03"
|
|
36
36
|
}
|