@hh.ru/magritte-ui-rating-review 1.0.2 → 1.0.4
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.d.ts +1 -28
- package/RatingReview.js +4 -4
- package/RatingReview.js.map +1 -1
- package/index.css +6 -6
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/index.mock.d.ts +2 -1
- package/index.mock.js +1 -7
- package/index.mock.js.map +1 -1
- package/normalizeRatingValue.d.ts +1 -0
- package/normalizeRatingValue.js +5 -0
- package/normalizeRatingValue.js.map +1 -0
- package/package.json +2 -2
package/RatingReview.d.ts
CHANGED
|
@@ -5,33 +5,6 @@ export interface RatingReviewProps {
|
|
|
5
5
|
value: number | null;
|
|
6
6
|
'aria-describedby'?: string;
|
|
7
7
|
/** Размер */
|
|
8
|
-
size
|
|
8
|
+
size?: RatingReviewSize;
|
|
9
9
|
}
|
|
10
|
-
export declare const ICON_BY_SIZE: {
|
|
11
|
-
readonly small: {
|
|
12
|
-
readonly filled: import("../../icon/src").IconWrapperComponentSize16<null> & {
|
|
13
|
-
Skeleton: import("../../icon/src").IconWrapperComponentSize16<{
|
|
14
|
-
loading?: boolean;
|
|
15
|
-
}>;
|
|
16
|
-
};
|
|
17
|
-
readonly outline: import("../../icon/src").IconWrapperComponentSize16<null> & {
|
|
18
|
-
Skeleton: import("../../icon/src").IconWrapperComponentSize16<{
|
|
19
|
-
loading?: boolean;
|
|
20
|
-
}>;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
readonly medium: {
|
|
24
|
-
readonly filled: import("../../icon/src").IconWrapperComponentSize24<null> & {
|
|
25
|
-
Skeleton: import("../../icon/src").IconWrapperComponentSize24<{
|
|
26
|
-
loading?: boolean;
|
|
27
|
-
}>;
|
|
28
|
-
};
|
|
29
|
-
readonly outline: import("../../icon/src").IconWrapperComponentSize24<null> & {
|
|
30
|
-
Skeleton: import("../../icon/src").IconWrapperComponentSize24<{
|
|
31
|
-
loading?: boolean;
|
|
32
|
-
}>;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export declare const normalizeRatingValue: (value: number | null) => number;
|
|
37
10
|
export declare const RatingReview: import("react").ForwardRefExoticComponent<RatingReviewProps & import("react").RefAttributes<HTMLElement>>;
|
package/RatingReview.js
CHANGED
|
@@ -4,9 +4,10 @@ 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';
|
|
7
8
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
8
9
|
|
|
9
|
-
var styles = {"rating-review":"magritte-rating-review___X1HDg_1-0-
|
|
10
|
+
var styles = {"rating-review":"magritte-rating-review___X1HDg_1-0-4","ratingReview":"magritte-rating-review___X1HDg_1-0-4","internal-container":"magritte-internal-container___Tutx7_1-0-4","internalContainer":"magritte-internal-container___Tutx7_1-0-4","size-medium":"magritte-size-medium___wVwww_1-0-4","sizeMedium":"magritte-size-medium___wVwww_1-0-4","disabled":"magritte-disabled___uGGmU_1-0-4","has-rating":"magritte-has-rating___BoybH_1-0-4","hasRating":"magritte-has-rating___BoybH_1-0-4"};
|
|
10
11
|
|
|
11
12
|
const ICON_BY_SIZE = {
|
|
12
13
|
small: {
|
|
@@ -18,7 +19,6 @@ const ICON_BY_SIZE = {
|
|
|
18
19
|
outline: StarOutlinedSize24,
|
|
19
20
|
},
|
|
20
21
|
};
|
|
21
|
-
const normalizeRatingValue = (value) => value ? Math.round(Math.min(Math.max(value, 0), 5) * 2) / 2 : 0;
|
|
22
22
|
const RatingReview = forwardRef(({ 'data-qa': dataQa, value, 'aria-describedby': describedBy, size = 'small' }, ref) => {
|
|
23
23
|
const normalizedValue = normalizeRatingValue(value);
|
|
24
24
|
const isDisabled = useDisabled();
|
|
@@ -28,12 +28,12 @@ const RatingReview = forwardRef(({ 'data-qa': dataQa, value, 'aria-describedby':
|
|
|
28
28
|
[styles.sizeMedium]: size === 'medium',
|
|
29
29
|
[styles.hasRating]: normalizedValue > 0,
|
|
30
30
|
[styles.disabled]: isDisabled,
|
|
31
|
-
}), children: jsxs("div", { className: styles.internalContainer, "aria-hidden": true, children: [jsx(Icon, {}), jsx(Text, { typography: size === 'small' ? 'subtitle-
|
|
31
|
+
}), children: jsxs("div", { className: styles.internalContainer, "aria-hidden": true, children: [jsx(Icon, {}), jsx(Text, { typography: size === 'small' ? 'subtitle-1-semibold' : 'title-4-semibold', children: normalizedValue.toLocaleString(undefined, {
|
|
32
32
|
maximumFractionDigits: fractionDigits,
|
|
33
33
|
minimumFractionDigits: fractionDigits,
|
|
34
34
|
}) })] }) }));
|
|
35
35
|
});
|
|
36
36
|
RatingReview.displayName = 'RatingReview';
|
|
37
37
|
|
|
38
|
-
export {
|
|
38
|
+
export { RatingReview };
|
|
39
39
|
//# 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
|
|
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","_js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AAA,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;;;;"}
|
package/index.css
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
--magritte-color-icon-state-tertiary-disabled-v21-4-6:#767676;
|
|
15
15
|
--magritte-color-icon-state-warning-disabled-v21-4-6:#eb8d057a;
|
|
16
16
|
}
|
|
17
|
-
.magritte-rating-review___X1HDg_1-0-
|
|
17
|
+
.magritte-rating-review___X1HDg_1-0-4{
|
|
18
18
|
display:inline-block;
|
|
19
19
|
--magritte-ui-icon-color-override:var(--magritte-color-icon-tertiary-v21-4-6);
|
|
20
20
|
--magritte-ui-text-color-override:var(--magritte-color-text-primary-v21-4-6);
|
|
21
21
|
}
|
|
22
|
-
.magritte-internal-container___Tutx7_1-0-
|
|
22
|
+
.magritte-internal-container___Tutx7_1-0-4{
|
|
23
23
|
display:inline-flex;
|
|
24
24
|
flex-wrap:nowrap;
|
|
25
25
|
gap:6px;
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
justify-content:center;
|
|
28
28
|
height:22px;
|
|
29
29
|
}
|
|
30
|
-
.magritte-size-medium___wVwww_1-0-
|
|
30
|
+
.magritte-size-medium___wVwww_1-0-4 .magritte-internal-container___Tutx7_1-0-4{
|
|
31
31
|
height:32px;
|
|
32
32
|
}
|
|
33
|
-
.magritte-disabled___uGGmU_1-0-
|
|
33
|
+
.magritte-disabled___uGGmU_1-0-4{
|
|
34
34
|
--magritte-ui-icon-color-override:var(--magritte-color-icon-state-tertiary-disabled-v21-4-6);
|
|
35
35
|
--magritte-ui-text-color-override:var(--magritte-color-text-state-primary-disabled-v21-4-6);
|
|
36
36
|
}
|
|
37
|
-
.magritte-disabled___uGGmU_1-0-
|
|
37
|
+
.magritte-disabled___uGGmU_1-0-4.magritte-has-rating___BoybH_1-0-4{
|
|
38
38
|
--magritte-ui-icon-color-override:var(--magritte-color-icon-state-warning-disabled-v21-4-6);
|
|
39
39
|
}
|
|
40
|
-
.magritte-has-rating___BoybH_1-0-
|
|
40
|
+
.magritte-has-rating___BoybH_1-0-4{
|
|
41
41
|
--magritte-ui-icon-color-override:var(--magritte-color-icon-warning-v21-4-6);
|
|
42
42
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
export * from '@hh.ru/magritte-ui-theme-provider';
|
|
3
|
-
export {
|
|
3
|
+
export { RatingReview } from './RatingReview.js';
|
|
4
|
+
export { normalizeRatingValue } from './normalizeRatingValue.js';
|
|
4
5
|
import 'react/jsx-runtime';
|
|
5
6
|
import 'react';
|
|
6
7
|
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,5 +1,6 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent } from 'react';
|
|
2
|
-
export { type RatingReviewProps, type RatingReviewSize
|
|
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';
|
|
3
4
|
declare const ThemeProvider: any;
|
|
4
5
|
export { ThemeProvider };
|
|
5
6
|
export declare const RatingReview: ForwardRefExoticComponent<Record<string, unknown>>;
|
package/index.mock.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { mockComponent } from '@hh.ru/magritte-ui-mock-component';
|
|
3
|
-
export { normalizeRatingValue } from './
|
|
4
|
-
import 'react/jsx-runtime';
|
|
5
|
-
import 'react';
|
|
6
|
-
import 'classnames';
|
|
7
|
-
import '@hh.ru/magritte-common-use-disabled';
|
|
8
|
-
import '@hh.ru/magritte-ui-icon/icon';
|
|
9
|
-
import '@hh.ru/magritte-ui-typography';
|
|
3
|
+
export { normalizeRatingValue } from './normalizeRatingValue.js';
|
|
10
4
|
|
|
11
5
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
12
6
|
const { ThemeProvider } = jest.requireActual('@hh.ru/magritte-ui-theme-provider/index');
|
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 {
|
|
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\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst { ThemeProvider } = jest.requireActual('@hh.ru/magritte-ui-theme-provider/index');\n\nexport { ThemeProvider };\n\nexport const RatingReview: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent('RatingReview');\n"],"names":[],"mappings":";;;AAOA;AACM,MAAA,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,yCAAyC,EAAE;MAI3E,YAAY,GAAuD,aAAa,CAAC,cAAc;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const normalizeRatingValue: (value: number | null) => number;
|
|
@@ -0,0 +1 @@
|
|
|
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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-rating-review",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"@hh.ru/magritte-ui-theme-provider": "1.1.48",
|
|
34
34
|
"@hh.ru/magritte-ui-typography": "3.0.44"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "9e5b72d62f11e774ad3273063f5bb099619fc7f0"
|
|
37
37
|
}
|