@alfalab/core-components-circular-progress-bar 3.8.3 → 3.9.0-snapshot-1393ffa
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/Component.js +21 -22
- package/Component.js.map +1 -0
- package/consts.js +1 -0
- package/consts.js.map +1 -0
- package/cssm/Component.js +14 -13
- package/cssm/Component.js.map +1 -0
- package/cssm/consts.js +1 -0
- package/cssm/consts.js.map +1 -0
- package/cssm/index.js +1 -0
- package/cssm/index.js.map +1 -0
- package/cssm/index.module.css +4 -29
- package/cssm/shared/index.js +3 -2
- package/cssm/shared/index.js.map +1 -0
- package/{Component.d.ts → cssm/src/Component.d.ts} +9 -8
- package/{esm → cssm/src}/consts.d.ts +9 -10
- package/cssm/src/index.d.ts +2 -0
- package/cssm/src/shared/index.d.ts +1 -0
- package/cssm/src/types/component-size.d.ts +1 -0
- package/cssm/src/types/typography-color.d.ts +1 -0
- package/cssm/src/use-timer.d.ts +1 -0
- package/cssm/{utils → src/utils}/get-circular-progress-bar-test-ids.d.ts +1 -2
- package/cssm/src/utils/is-typography-color.d.ts +2 -0
- package/cssm/types/component-size.js +1 -0
- package/cssm/types/component-size.js.map +1 -0
- package/cssm/types/typography-color.js +1 -0
- package/cssm/types/typography-color.js.map +1 -0
- package/cssm/use-timer.js +8 -4
- package/cssm/use-timer.js.map +1 -0
- package/cssm/utils/get-circular-progress-bar-test-ids.js +6 -5
- package/cssm/utils/get-circular-progress-bar-test-ids.js.map +1 -0
- package/cssm/utils/is-typography-color.js +1 -0
- package/cssm/utils/is-typography-color.js.map +1 -0
- package/esm/Component.js +7 -8
- package/esm/Component.js.map +1 -0
- package/esm/consts.js +1 -0
- package/esm/consts.js.map +1 -0
- package/esm/index.css +56 -82
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -0
- package/esm/index.module.css.js +6 -0
- package/esm/index.module.css.js.map +1 -0
- package/esm/shared/index.js +1 -0
- package/esm/shared/index.js.map +1 -0
- package/esm/{Component.d.ts → src/Component.d.ts} +9 -8
- package/{consts.d.ts → esm/src/consts.d.ts} +9 -10
- package/esm/src/index.d.ts +2 -0
- package/esm/src/shared/index.d.ts +1 -0
- package/esm/src/types/component-size.d.ts +1 -0
- package/esm/src/types/typography-color.d.ts +1 -0
- package/esm/src/use-timer.d.ts +1 -0
- package/esm/{utils → src/utils}/get-circular-progress-bar-test-ids.d.ts +1 -2
- package/esm/src/utils/is-typography-color.d.ts +2 -0
- package/esm/types/component-size.js +1 -0
- package/esm/types/component-size.js.map +1 -0
- package/esm/types/typography-color.js +1 -0
- package/esm/types/typography-color.js.map +1 -0
- package/esm/use-timer.js +6 -2
- package/esm/use-timer.js.map +1 -0
- package/esm/utils/get-circular-progress-bar-test-ids.js +1 -0
- package/esm/utils/get-circular-progress-bar-test-ids.js.map +1 -0
- package/esm/utils/is-typography-color.js +1 -0
- package/esm/utils/is-typography-color.js.map +1 -0
- package/index.css +56 -82
- package/index.js +1 -0
- package/index.js.map +1 -0
- package/index.module.css.js +8 -0
- package/index.module.css.js.map +1 -0
- package/modern/Component.js +7 -8
- package/modern/Component.js.map +1 -0
- package/modern/consts.js +1 -0
- package/modern/consts.js.map +1 -0
- package/modern/index.css +56 -82
- package/modern/index.js +1 -0
- package/modern/index.js.map +1 -0
- package/modern/index.module.css.js +6 -0
- package/modern/index.module.css.js.map +1 -0
- package/modern/shared/index.js +1 -0
- package/modern/shared/index.js.map +1 -0
- package/{cssm → modern/src}/Component.d.ts +9 -8
- package/modern/{consts.d.ts → src/consts.d.ts} +9 -10
- package/modern/src/index.d.ts +2 -0
- package/modern/src/shared/index.d.ts +1 -0
- package/modern/src/types/component-size.d.ts +1 -0
- package/modern/src/types/typography-color.d.ts +1 -0
- package/modern/src/use-timer.d.ts +1 -0
- package/modern/{utils → src/utils}/get-circular-progress-bar-test-ids.d.ts +1 -2
- package/modern/src/utils/is-typography-color.d.ts +2 -0
- package/modern/types/component-size.js +1 -0
- package/modern/types/component-size.js.map +1 -0
- package/modern/types/typography-color.js +1 -0
- package/modern/types/typography-color.js.map +1 -0
- package/modern/use-timer.js +6 -2
- package/modern/use-timer.js.map +1 -0
- package/modern/utils/get-circular-progress-bar-test-ids.js +1 -0
- package/modern/utils/get-circular-progress-bar-test-ids.js.map +1 -0
- package/modern/utils/is-typography-color.js +1 -0
- package/modern/utils/is-typography-color.js.map +1 -0
- package/moderncssm/Component.js +6 -5
- package/moderncssm/Component.js.map +1 -0
- package/moderncssm/consts.js +1 -0
- package/moderncssm/consts.js.map +1 -0
- package/moderncssm/index.js +1 -0
- package/moderncssm/index.js.map +1 -0
- package/moderncssm/index.module.css +0 -9
- package/moderncssm/shared/index.js +1 -0
- package/moderncssm/shared/index.js.map +1 -0
- package/{modern → moderncssm/src}/Component.d.ts +9 -8
- package/{cssm → moderncssm/src}/consts.d.ts +9 -10
- package/moderncssm/src/index.d.ts +2 -0
- package/moderncssm/src/shared/index.d.ts +1 -0
- package/moderncssm/src/types/component-size.d.ts +1 -0
- package/moderncssm/src/types/typography-color.d.ts +1 -0
- package/moderncssm/src/use-timer.d.ts +1 -0
- package/moderncssm/{utils → src/utils}/get-circular-progress-bar-test-ids.d.ts +1 -2
- package/moderncssm/src/utils/is-typography-color.d.ts +2 -0
- package/moderncssm/types/component-size.js +1 -0
- package/moderncssm/types/component-size.js.map +1 -0
- package/moderncssm/types/typography-color.js +1 -0
- package/moderncssm/types/typography-color.js.map +1 -0
- package/moderncssm/use-timer.js +6 -2
- package/moderncssm/use-timer.js.map +1 -0
- package/moderncssm/utils/get-circular-progress-bar-test-ids.js +1 -0
- package/moderncssm/utils/get-circular-progress-bar-test-ids.js.map +1 -0
- package/moderncssm/utils/is-typography-color.js +1 -0
- package/moderncssm/utils/is-typography-color.js.map +1 -0
- package/package.json +5 -5
- package/shared/index.js +3 -2
- package/shared/index.js.map +1 -0
- package/src/Component.d.ts +143 -0
- package/src/Component.tsx +6 -1
- package/src/consts.d.ts +79 -0
- package/src/index.d.ts +2 -0
- package/src/shared/index.d.ts +1 -0
- package/src/types/component-size.d.ts +1 -0
- package/src/types/typography-color.d.ts +1 -0
- package/src/use-timer.d.ts +1 -0
- package/src/use-timer.ts +6 -1
- package/src/utils/get-circular-progress-bar-test-ids.d.ts +7 -0
- package/src/utils/is-typography-color.d.ts +2 -0
- package/types/component-size.js +1 -0
- package/types/component-size.js.map +1 -0
- package/types/typography-color.js +1 -0
- package/types/typography-color.js.map +1 -0
- package/use-timer.js +6 -2
- package/use-timer.js.map +1 -0
- package/utils/get-circular-progress-bar-test-ids.js +1 -0
- package/utils/get-circular-progress-bar-test-ids.js.map +1 -0
- package/utils/is-typography-color.js +1 -0
- package/utils/is-typography-color.js.map +1 -0
- package/cssm/index.d.ts +0 -2
- package/cssm/shared/index.d.ts +0 -1
- package/cssm/types/component-size.d.ts +0 -2
- package/cssm/types/typography-color.d.ts +0 -2
- package/cssm/use-timer.d.ts +0 -2
- package/cssm/utils/is-typography-color.d.ts +0 -3
- package/esm/index.d.ts +0 -2
- package/esm/shared/index.d.ts +0 -1
- package/esm/types/component-size.d.ts +0 -2
- package/esm/types/typography-color.d.ts +0 -2
- package/esm/use-timer.d.ts +0 -2
- package/esm/utils/is-typography-color.d.ts +0 -3
- package/index.d.ts +0 -2
- package/modern/index.d.ts +0 -2
- package/modern/shared/index.d.ts +0 -1
- package/modern/types/component-size.d.ts +0 -2
- package/modern/types/typography-color.d.ts +0 -2
- package/modern/use-timer.d.ts +0 -2
- package/modern/utils/is-typography-color.d.ts +0 -3
- package/moderncssm/Component.d.ts +0 -142
- package/moderncssm/consts.d.ts +0 -80
- package/moderncssm/index.d.ts +0 -2
- package/moderncssm/shared/index.d.ts +0 -1
- package/moderncssm/types/component-size.d.ts +0 -2
- package/moderncssm/types/typography-color.d.ts +0 -2
- package/moderncssm/use-timer.d.ts +0 -2
- package/moderncssm/utils/is-typography-color.d.ts +0 -3
- package/shared/index.d.ts +0 -1
- package/types/component-size.d.ts +0 -2
- package/types/typography-color.d.ts +0 -2
- package/use-timer.d.ts +0 -2
- package/utils/get-circular-progress-bar-test-ids.d.ts +0 -8
- package/utils/is-typography-color.d.ts +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sources":["../../src/consts.ts"],"sourcesContent":["export const SIZES = {\n xs: 24,\n s: 48,\n m: 64,\n l: 80,\n xl: 128,\n xxl: 144,\n 24: 24,\n 48: 48,\n 64: 64,\n 80: 80,\n 96: 96,\n 128: 128,\n 144: 144,\n};\n\nexport const STROKE = {\n xs: 4,\n s: 4,\n m: 6,\n l: 8,\n xl: 10,\n xxl: 12,\n 24: 4,\n 48: 4,\n 64: 6,\n 80: 8,\n 96: 8,\n 128: 10,\n 144: 12,\n};\n\nexport const VIEW_TITLE = {\n xs: 'small',\n s: 'small',\n m: 'small',\n l: 'xsmall',\n xl: 'medium',\n xxl: 'medium',\n 24: 'small',\n 48: 'small',\n 64: 'small',\n 80: 'xsmall',\n 96: 'xsmall',\n 128: 'medium',\n 144: 'medium',\n} as const;\n\nexport const VIEW_TEXT = {\n xs: 'secondary-small',\n s: 'secondary-small',\n m: 'secondary-large',\n l: 'secondary-large',\n xl: 'secondary-large',\n xxl: 'secondary-large',\n 24: 'secondary-small',\n 48: 'secondary-small',\n 64: 'secondary-large',\n 80: 'secondary-large',\n 96: 'secondary-large',\n 128: 'secondary-large',\n 144: 'secondary-large',\n} as const;\n\nexport const TYPOGRAPHY_COLOR = ['primary', 'secondary', 'tertiary', 'positive', 'negative'];\n\nexport const SIZE_TO_CLASSNAME_MAP = {\n xs: 'size-24',\n s: 'size-48',\n m: 'size-64',\n l: 'size-80',\n xl: 'size-128',\n xxl: 'size-144',\n 24: 'size-24',\n 48: 'size-48',\n 64: 'size-64',\n 80: 'size-80',\n 96: 'size-96',\n 128: 'size-128',\n 144: 'size-144',\n};\n\nexport const MAX_PROGRESS_VALUE = 100;\n\nexport const MIN_TIMER_VALUE = 0;\nexport const MAX_TIMER_VALUE = 3599;\n"],"names":[],"mapp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
|
--circular-progress-bar-stroke-color: var(--color-light-neutral-translucent-300);
|
|
6
|
-
|
|
7
|
-
/* positive */
|
|
8
3
|
--circular-progress-bar-positive-color: var(--color-light-status-positive);
|
|
9
|
-
|
|
10
|
-
/* negative */
|
|
11
4
|
--circular-progress-bar-negative-color: var(--color-light-status-negative);
|
|
12
|
-
|
|
13
|
-
/* theme */
|
|
14
5
|
--circular-progress-bar-font-family: var(--font-family-system);
|
|
15
6
|
--circular-progress-bar-font-weight: 600;
|
|
16
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { TypographyColor } from "./types/typography-color";
|
|
6
|
-
type CircularProgressBarProps = {
|
|
1
|
+
import React, { ElementType, ReactNode } from 'react';
|
|
2
|
+
import { ComponentSize } from './types/component-size';
|
|
3
|
+
import { TypographyColor } from './types/typography-color';
|
|
4
|
+
export declare type CircularProgressBarProps = {
|
|
7
5
|
/**
|
|
8
6
|
* Уровень прогресса, %
|
|
9
7
|
*/
|
|
@@ -21,6 +19,10 @@ type CircularProgressBarProps = {
|
|
|
21
19
|
* @default backward
|
|
22
20
|
*/
|
|
23
21
|
counting?: 'forward' | 'backward';
|
|
22
|
+
/**
|
|
23
|
+
* Обработчик завершения таймера
|
|
24
|
+
*/
|
|
25
|
+
onFinish?: () => void;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* Дополнительный класс
|
|
@@ -138,5 +140,4 @@ type CircularProgressBarProps = {
|
|
|
138
140
|
/**
|
|
139
141
|
* Компонент круглого прогресс бара.
|
|
140
142
|
*/
|
|
141
|
-
declare const CircularProgressBar: React.FC<CircularProgressBarProps>;
|
|
142
|
-
export { CircularProgressBarProps, CircularProgressBar };
|
|
143
|
+
export declare const CircularProgressBar: React.FC<CircularProgressBarProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const SIZES: {
|
|
1
|
+
export declare const SIZES: {
|
|
2
2
|
xs: number;
|
|
3
3
|
s: number;
|
|
4
4
|
m: number;
|
|
@@ -13,7 +13,7 @@ declare const SIZES: {
|
|
|
13
13
|
128: number;
|
|
14
14
|
144: number;
|
|
15
15
|
};
|
|
16
|
-
declare const STROKE: {
|
|
16
|
+
export declare const STROKE: {
|
|
17
17
|
xs: number;
|
|
18
18
|
s: number;
|
|
19
19
|
m: number;
|
|
@@ -28,7 +28,7 @@ declare const STROKE: {
|
|
|
28
28
|
128: number;
|
|
29
29
|
144: number;
|
|
30
30
|
};
|
|
31
|
-
declare const VIEW_TITLE: {
|
|
31
|
+
export declare const VIEW_TITLE: {
|
|
32
32
|
readonly xs: "small";
|
|
33
33
|
readonly s: "small";
|
|
34
34
|
readonly m: "small";
|
|
@@ -43,7 +43,7 @@ declare const VIEW_TITLE: {
|
|
|
43
43
|
readonly 128: "medium";
|
|
44
44
|
readonly 144: "medium";
|
|
45
45
|
};
|
|
46
|
-
declare const VIEW_TEXT: {
|
|
46
|
+
export declare const VIEW_TEXT: {
|
|
47
47
|
readonly xs: "secondary-small";
|
|
48
48
|
readonly s: "secondary-small";
|
|
49
49
|
readonly m: "secondary-large";
|
|
@@ -58,8 +58,8 @@ declare const VIEW_TEXT: {
|
|
|
58
58
|
readonly 128: "secondary-large";
|
|
59
59
|
readonly 144: "secondary-large";
|
|
60
60
|
};
|
|
61
|
-
declare const TYPOGRAPHY_COLOR: string[];
|
|
62
|
-
declare const SIZE_TO_CLASSNAME_MAP: {
|
|
61
|
+
export declare const TYPOGRAPHY_COLOR: string[];
|
|
62
|
+
export declare const SIZE_TO_CLASSNAME_MAP: {
|
|
63
63
|
xs: string;
|
|
64
64
|
s: string;
|
|
65
65
|
m: string;
|
|
@@ -74,7 +74,6 @@ declare const SIZE_TO_CLASSNAME_MAP: {
|
|
|
74
74
|
128: string;
|
|
75
75
|
144: string;
|
|
76
76
|
};
|
|
77
|
-
declare const MAX_PROGRESS_VALUE = 100;
|
|
78
|
-
declare const MIN_TIMER_VALUE = 0;
|
|
79
|
-
declare const MAX_TIMER_VALUE = 3599;
|
|
80
|
-
export { SIZES, STROKE, VIEW_TITLE, VIEW_TEXT, TYPOGRAPHY_COLOR, SIZE_TO_CLASSNAME_MAP, MAX_PROGRESS_VALUE, MIN_TIMER_VALUE, MAX_TIMER_VALUE };
|
|
77
|
+
export declare const MAX_PROGRESS_VALUE = 100;
|
|
78
|
+
export declare const MIN_TIMER_VALUE = 0;
|
|
79
|
+
export declare const MAX_TIMER_VALUE = 3599;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCircularProgressBarTestIds } from '../utils/get-circular-progress-bar-test-ids';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ComponentSize = 'xxl' | 'xl' | 'l' | 'm' | 's' | 'xs' | 24 | 48 | 64 | 80 | 128 | 144;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type TypographyColor = 'primary' | 'secondary' | 'tertiary' | 'positive' | 'negative';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useTimer(time: number, active: boolean | undefined, counting: 'forward' | 'backward', onFinish: () => void, interval?: number, step?: number): [value: number, title: string];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
declare function getCircularProgressBarTestIds(dataTestId: string): {
|
|
1
|
+
export declare function getCircularProgressBarTestIds(dataTestId: string): {
|
|
2
2
|
progressBar: string;
|
|
3
3
|
title: string;
|
|
4
4
|
subtitle: string;
|
|
5
5
|
circleProgressBar: string;
|
|
6
6
|
circleProgressValue: string;
|
|
7
7
|
};
|
|
8
|
-
export { getCircularProgressBarTestIds };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-size.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography-color.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/moderncssm/use-timer.js
CHANGED
|
@@ -5,20 +5,24 @@ const MAX_PERSENT_VALUE = 100;
|
|
|
5
5
|
function makeTitle(time) {
|
|
6
6
|
return `${Math.trunc(time / 60)}:${`${time % 60}`.padStart(2, '0')}`;
|
|
7
7
|
}
|
|
8
|
-
function useTimer(time, active = true, counting, interval = 1000, step = 1) {
|
|
8
|
+
function useTimer(time, active = true, counting, onFinish, interval = 1000, step = 1) {
|
|
9
9
|
const [passedTime, setPassedTime] = useState(0);
|
|
10
10
|
const isCompleted = passedTime === time;
|
|
11
11
|
const persentValue = Math.trunc((passedTime / time) * MAX_PERSENT_VALUE);
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
if (!active || isCompleted) {
|
|
14
|
+
if (isCompleted) {
|
|
15
|
+
onFinish();
|
|
16
|
+
}
|
|
14
17
|
return noop;
|
|
15
18
|
}
|
|
16
19
|
const timer = setInterval(() => {
|
|
17
20
|
setPassedTime((prevPassed) => prevPassed + step);
|
|
18
21
|
}, interval);
|
|
19
22
|
return () => clearInterval(timer);
|
|
20
|
-
}, [interval, isCompleted, active, step]);
|
|
23
|
+
}, [interval, isCompleted, active, step, onFinish]);
|
|
21
24
|
return [persentValue, makeTitle(counting === 'backward' ? time - passedTime : passedTime)];
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export { useTimer };
|
|
28
|
+
//# sourceMappingURL=use-timer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-timer.js","sources":["../../src/use-timer.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { noop } from '@alfalab/core-components-shared';\n\nconst MAX_PERSENT_VALUE = 100;\n\nfunction makeTitle(time: number) {\n return `${Math.trunc(time / 60)}:${`${time % 60}`.padStart(2, '0')}`;\n}\n\nexport function useTimer(\n time: number,\n active = true,\n counting: 'forward' | 'backward',\n onFinish: () => void,\n interval = 1000,\n step = 1,\n): [value: number, title: string] {\n const [passedTime, setPassedTime] = useState(0);\n const isCompleted = passedTime === time;\n const persentValue = Math.trunc((passedTime / time) * MAX_PERSENT_VALUE);\n\n useEffect(() => {\n if (!active || isCompleted) {\n if (isCompleted) {\n onFinish();\n }\n\n return noop;\n }\n\n const timer = setInterval(() => {\n setPassedTime((prevPassed) => prevPassed + step);\n }, interval);\n\n return () => clearInterval(timer);\n }, [interval, isCompleted, active, step, onFinish]);\n\n return [persentValue, makeTitle(counting === 'backward' ? time - passedTime : passedTime)];\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,iBAAiB,GAAG,GAAG;AAE7B,SAAS,SAAS,CAAC,IAAY,EAAA;IAC3B,OAAO,CAAA,EAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,CAAI,CAAA,EAAA,CAAA,EAAG,IAAI,GAAG,EAAE,CAAE,CAAA,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA,CAAE;AACxE;SAEgB,QAAQ,CACpB,IAAY,EACZ,MAAM,GAAG,IAAI,EACb,QAAgC,EAChC,QAAoB,EACpB,QAAQ,GAAG,IAAI,EACf,IAAI,GAAG,CAAC,EAAA;IAER,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAC/C,IAAA,MAAM,WAAW,GAAG,UAAU,KAAK,IAAI;AACvC,IAAA,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,IAAI,IAAI,iBAAiB,CAAC;IAExE,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,CAAC,MAAM,IAAI,WAAW,EAAE;AACxB,YAAA,IAAI,WAAW,EAAE;AACb,gBAAA,QAAQ,EAAE;AACb;AAED,YAAA,OAAO,IAAI;AACd;AAED,QAAA,MAAM,KAAK,GAAG,WAAW,CAAC,MAAK;YAC3B,aAAa,CAAC,CAAC,UAAU,KAAK,UAAU,GAAG,IAAI,CAAC;SACnD,EAAE,QAAQ,CAAC;AAEZ,QAAA,OAAO,MAAM,aAAa,CAAC,KAAK,CAAC;AACrC,KAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEnD,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,QAAQ,KAAK,UAAU,GAAG,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;AAC9F;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-circular-progress-bar-test-ids.js","sources":["../../../src/utils/get-circular-progress-bar-test-ids.ts"],"sourcesContent":["import { getDataTestId } from '@alfalab/core-components-shared';\n\nexport function getCircularProgressBarTestIds(dataTestId: string) {\n return {\n progressBar: dataTestId,\n title: getDataTestId(dataTestId, 'title'),\n subtitle: getDataTestId(dataTestId, 'subtitle'),\n circleProgressBar: getDataTestId(dataTestId, 'circle-progress-bar'),\n circleProgressValue: getDataTestId(dataTestId, 'circle-progress-value'),\n };\n}\n"],"names":[],"mappings":";;AAEM,SAAU,6BAA6B,CAAC,UAAkB,EAAA;IAC5D,OAAO;AACH,QAAA,WAAW,EAAE,UAAU;AACvB,QAAA,KAAK,EAAE,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC;AACzC,QAAA,QAAQ,EAAE,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC;AAC/C,QAAA,iBAAiB,EAAE,aAAa,CAAC,UAAU,EAAE,qBAAqB,CAAC;AACnE,QAAA,mBAAmB,EAAE,aAAa,CAAC,UAAU,EAAE,uBAAuB,CAAC;KAC1E;AACL;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-typography-color.js","sources":["../../../src/utils/is-typography-color.ts"],"sourcesContent":["import { TYPOGRAPHY_COLOR } from '../consts';\nimport { TypographyColor } from '../types/typography-color';\n\nexport const isTypographyColor = (color: TypographyColor | string): color is TypographyColor =>\n TYPOGRAPHY_COLOR.includes(color);\n"],"names":[],"mappings":";;AAGO,MAAM,iBAAiB,GAAG,CAAC,KAA+B,KAC7D,gBAAgB,CAAC,QAAQ,CAAC,KAAK;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-circular-progress-bar",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0-snapshot-1393ffa",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
},
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@alfalab/core-components-typography": "
|
|
16
|
-
"@alfalab/core-components-shared": "
|
|
15
|
+
"@alfalab/core-components-typography": "4.13.1-snapshot-1393ffa",
|
|
16
|
+
"@alfalab/core-components-shared": "0.16.1-snapshot-1393ffa",
|
|
17
17
|
"classnames": "^2.5.1",
|
|
18
18
|
"tslib": "^2.4.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
22
22
|
},
|
|
23
|
-
"themesVersion": "
|
|
24
|
-
"varsVersion": "9.20.
|
|
23
|
+
"themesVersion": "14.0.0-snapshot-1393ffa",
|
|
24
|
+
"varsVersion": "9.20.1-snapshot-1393ffa"
|
|
25
25
|
}
|
package/shared/index.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var getCircularProgressBarTestIds = require('../utils/get-circular-progress-bar-test-ids.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports.getCircularProgressBarTestIds =
|
|
9
|
+
exports.getCircularProgressBarTestIds = getCircularProgressBarTestIds.getCircularProgressBarTestIds;
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React, { ElementType, ReactNode } from 'react';
|
|
2
|
+
import { ComponentSize } from './types/component-size';
|
|
3
|
+
import { TypographyColor } from './types/typography-color';
|
|
4
|
+
export declare type CircularProgressBarProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Уровень прогресса, %
|
|
7
|
+
*/
|
|
8
|
+
value: number | {
|
|
9
|
+
/**
|
|
10
|
+
* Время таймера в секундах
|
|
11
|
+
* Минимальное значение 0
|
|
12
|
+
* Максимальное значение 3600
|
|
13
|
+
*/
|
|
14
|
+
timer: number;
|
|
15
|
+
/**
|
|
16
|
+
* Направлние отсчета таймера
|
|
17
|
+
* forward: считаем от 0 до указанного значения
|
|
18
|
+
* backward: считаем от указанного значения до 0
|
|
19
|
+
* @default backward
|
|
20
|
+
*/
|
|
21
|
+
counting?: 'forward' | 'backward';
|
|
22
|
+
/**
|
|
23
|
+
* Обработчик завершения таймера
|
|
24
|
+
*/
|
|
25
|
+
onFinish?: () => void;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Дополнительный класс
|
|
29
|
+
*/
|
|
30
|
+
className?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Основной текст
|
|
33
|
+
*/
|
|
34
|
+
title?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Цвет контента
|
|
37
|
+
*/
|
|
38
|
+
contentColor?: TypographyColor | string;
|
|
39
|
+
/**
|
|
40
|
+
* Цвет заголовка
|
|
41
|
+
* Приоритет выше чем у `contentColor`
|
|
42
|
+
*/
|
|
43
|
+
titleColor?: TypographyColor | string;
|
|
44
|
+
/**
|
|
45
|
+
* Цвет подзаголовка
|
|
46
|
+
* Приоритет выше чем у `contentColor`
|
|
47
|
+
*/
|
|
48
|
+
subtitleColor?: TypographyColor | string;
|
|
49
|
+
/**
|
|
50
|
+
* Дополнительный текст
|
|
51
|
+
*/
|
|
52
|
+
subtitle?: ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* Основной текст при 100%
|
|
55
|
+
*/
|
|
56
|
+
titleComplete?: ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Дополнительный текст при 100%
|
|
59
|
+
*/
|
|
60
|
+
subtitleComplete?: ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Цвет заполнения
|
|
63
|
+
*/
|
|
64
|
+
view?: 'positive' | 'negative';
|
|
65
|
+
/**
|
|
66
|
+
* Размер (xxl — 144×144px, xl — 128×128px, l — 80×80px, m — 64×64px, s — 48×48px, xs — 24×24px)
|
|
67
|
+
* @description xs, s, m, l, xl, xxl deprecated, используйте вместо них 24, 48, 64, 80, 128, 144 соответственно
|
|
68
|
+
* @default 64
|
|
69
|
+
*/
|
|
70
|
+
size?: ComponentSize;
|
|
71
|
+
/**
|
|
72
|
+
* Наличие желоба
|
|
73
|
+
*/
|
|
74
|
+
stroke?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Заливка при 100%
|
|
77
|
+
*/
|
|
78
|
+
fillComplete?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Цвет текста при 100%
|
|
81
|
+
*/
|
|
82
|
+
completeTextColor?: 'primary' | 'primary-inverted' | 'positive' | 'negative';
|
|
83
|
+
/**
|
|
84
|
+
* Цвет иконки при 100%
|
|
85
|
+
*/
|
|
86
|
+
completeIconColor?: 'primary-inverted' | 'positive' | 'negative' | 'tertiary';
|
|
87
|
+
/**
|
|
88
|
+
* Компонент иконки
|
|
89
|
+
*/
|
|
90
|
+
icon?: ElementType<{
|
|
91
|
+
className?: string;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Компонент иконки при 100%
|
|
95
|
+
*/
|
|
96
|
+
iconComplete?: ElementType<{
|
|
97
|
+
className?: string;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Направление прогресса (clockwise - по часовой стрелке, counter-clockwise - против часовой стрелки)
|
|
101
|
+
*/
|
|
102
|
+
direction?: 'clockwise' | 'counter-clockwise';
|
|
103
|
+
/**
|
|
104
|
+
* Высота компонента, min = 24; max = 144
|
|
105
|
+
* использовать совместно с size :
|
|
106
|
+
* xxl от 144
|
|
107
|
+
* xl от 128 до 143
|
|
108
|
+
* l от 80 до 127
|
|
109
|
+
* m от 64 до 79
|
|
110
|
+
* s от 48 до 63
|
|
111
|
+
* xs от 24 до 47
|
|
112
|
+
*/
|
|
113
|
+
height?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Id компонента для тестов
|
|
116
|
+
*/
|
|
117
|
+
dataTestId?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Дочерние элементы
|
|
120
|
+
*/
|
|
121
|
+
children?: ReactNode;
|
|
122
|
+
/**
|
|
123
|
+
* Цвет прогресса
|
|
124
|
+
*/
|
|
125
|
+
progressStrokeColor?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Цвет заливки внутри круга
|
|
128
|
+
*/
|
|
129
|
+
circleColor?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Цвет желоба
|
|
132
|
+
*/
|
|
133
|
+
strokeColor?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Направление заполнения круга
|
|
136
|
+
* @default desc
|
|
137
|
+
*/
|
|
138
|
+
directionType?: 'asc' | 'desc';
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Компонент круглого прогресс бара.
|
|
142
|
+
*/
|
|
143
|
+
export declare const CircularProgressBar: React.FC<CircularProgressBarProps>;
|
package/src/Component.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { ElementType, ReactNode, useMemo } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { getDataTestId, isObject } from '@alfalab/core-components-shared';
|
|
5
|
+
import { getDataTestId, isObject, noop } from '@alfalab/core-components-shared';
|
|
6
6
|
import { Text, TitleMobile } from '@alfalab/core-components-typography';
|
|
7
7
|
|
|
8
8
|
import { ComponentSize } from './types/component-size';
|
|
@@ -44,6 +44,10 @@ export type CircularProgressBarProps = {
|
|
|
44
44
|
* @default backward
|
|
45
45
|
*/
|
|
46
46
|
counting?: 'forward' | 'backward';
|
|
47
|
+
/**
|
|
48
|
+
* Обработчик завершения таймера
|
|
49
|
+
*/
|
|
50
|
+
onFinish?: () => void;
|
|
47
51
|
};
|
|
48
52
|
|
|
49
53
|
/**
|
|
@@ -214,6 +218,7 @@ export const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
214
218
|
isTimer ? Math.min(Math.max(valueFromProps.timer, MIN_TIMER_VALUE), MAX_TIMER_VALUE) : -1,
|
|
215
219
|
isTimer,
|
|
216
220
|
isTimer ? valueFromProps.counting ?? 'backward' : 'backward',
|
|
221
|
+
isTimer ? valueFromProps.onFinish ?? noop : noop,
|
|
217
222
|
);
|
|
218
223
|
let value: number;
|
|
219
224
|
let title: React.ReactNode;
|
package/src/consts.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare const SIZES: {
|
|
2
|
+
xs: number;
|
|
3
|
+
s: number;
|
|
4
|
+
m: number;
|
|
5
|
+
l: number;
|
|
6
|
+
xl: number;
|
|
7
|
+
xxl: number;
|
|
8
|
+
24: number;
|
|
9
|
+
48: number;
|
|
10
|
+
64: number;
|
|
11
|
+
80: number;
|
|
12
|
+
96: number;
|
|
13
|
+
128: number;
|
|
14
|
+
144: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const STROKE: {
|
|
17
|
+
xs: number;
|
|
18
|
+
s: number;
|
|
19
|
+
m: number;
|
|
20
|
+
l: number;
|
|
21
|
+
xl: number;
|
|
22
|
+
xxl: number;
|
|
23
|
+
24: number;
|
|
24
|
+
48: number;
|
|
25
|
+
64: number;
|
|
26
|
+
80: number;
|
|
27
|
+
96: number;
|
|
28
|
+
128: number;
|
|
29
|
+
144: number;
|
|
30
|
+
};
|
|
31
|
+
export declare const VIEW_TITLE: {
|
|
32
|
+
readonly xs: "small";
|
|
33
|
+
readonly s: "small";
|
|
34
|
+
readonly m: "small";
|
|
35
|
+
readonly l: "xsmall";
|
|
36
|
+
readonly xl: "medium";
|
|
37
|
+
readonly xxl: "medium";
|
|
38
|
+
readonly 24: "small";
|
|
39
|
+
readonly 48: "small";
|
|
40
|
+
readonly 64: "small";
|
|
41
|
+
readonly 80: "xsmall";
|
|
42
|
+
readonly 96: "xsmall";
|
|
43
|
+
readonly 128: "medium";
|
|
44
|
+
readonly 144: "medium";
|
|
45
|
+
};
|
|
46
|
+
export declare const VIEW_TEXT: {
|
|
47
|
+
readonly xs: "secondary-small";
|
|
48
|
+
readonly s: "secondary-small";
|
|
49
|
+
readonly m: "secondary-large";
|
|
50
|
+
readonly l: "secondary-large";
|
|
51
|
+
readonly xl: "secondary-large";
|
|
52
|
+
readonly xxl: "secondary-large";
|
|
53
|
+
readonly 24: "secondary-small";
|
|
54
|
+
readonly 48: "secondary-small";
|
|
55
|
+
readonly 64: "secondary-large";
|
|
56
|
+
readonly 80: "secondary-large";
|
|
57
|
+
readonly 96: "secondary-large";
|
|
58
|
+
readonly 128: "secondary-large";
|
|
59
|
+
readonly 144: "secondary-large";
|
|
60
|
+
};
|
|
61
|
+
export declare const TYPOGRAPHY_COLOR: string[];
|
|
62
|
+
export declare const SIZE_TO_CLASSNAME_MAP: {
|
|
63
|
+
xs: string;
|
|
64
|
+
s: string;
|
|
65
|
+
m: string;
|
|
66
|
+
l: string;
|
|
67
|
+
xl: string;
|
|
68
|
+
xxl: string;
|
|
69
|
+
24: string;
|
|
70
|
+
48: string;
|
|
71
|
+
64: string;
|
|
72
|
+
80: string;
|
|
73
|
+
96: string;
|
|
74
|
+
128: string;
|
|
75
|
+
144: string;
|
|
76
|
+
};
|
|
77
|
+
export declare const MAX_PROGRESS_VALUE = 100;
|
|
78
|
+
export declare const MIN_TIMER_VALUE = 0;
|
|
79
|
+
export declare const MAX_TIMER_VALUE = 3599;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCircularProgressBarTestIds } from '../utils/get-circular-progress-bar-test-ids';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ComponentSize = 'xxl' | 'xl' | 'l' | 'm' | 's' | 'xs' | 24 | 48 | 64 | 80 | 128 | 144;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type TypographyColor = 'primary' | 'secondary' | 'tertiary' | 'positive' | 'negative';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useTimer(time: number, active: boolean | undefined, counting: 'forward' | 'backward', onFinish: () => void, interval?: number, step?: number): [value: number, title: string];
|
package/src/use-timer.ts
CHANGED
|
@@ -12,6 +12,7 @@ export function useTimer(
|
|
|
12
12
|
time: number,
|
|
13
13
|
active = true,
|
|
14
14
|
counting: 'forward' | 'backward',
|
|
15
|
+
onFinish: () => void,
|
|
15
16
|
interval = 1000,
|
|
16
17
|
step = 1,
|
|
17
18
|
): [value: number, title: string] {
|
|
@@ -21,6 +22,10 @@ export function useTimer(
|
|
|
21
22
|
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
if (!active || isCompleted) {
|
|
25
|
+
if (isCompleted) {
|
|
26
|
+
onFinish();
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
return noop;
|
|
25
30
|
}
|
|
26
31
|
|
|
@@ -29,7 +34,7 @@ export function useTimer(
|
|
|
29
34
|
}, interval);
|
|
30
35
|
|
|
31
36
|
return () => clearInterval(timer);
|
|
32
|
-
}, [interval, isCompleted, active, step]);
|
|
37
|
+
}, [interval, isCompleted, active, step, onFinish]);
|
|
33
38
|
|
|
34
39
|
return [persentValue, makeTitle(counting === 'backward' ? time - passedTime : passedTime)];
|
|
35
40
|
}
|
package/types/component-size.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-size.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography-color.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/use-timer.js
CHANGED
|
@@ -9,7 +9,7 @@ var MAX_PERSENT_VALUE = 100;
|
|
|
9
9
|
function makeTitle(time) {
|
|
10
10
|
return "".concat(Math.trunc(time / 60), ":").concat("".concat(time % 60).padStart(2, '0'));
|
|
11
11
|
}
|
|
12
|
-
function useTimer(time, active, counting, interval, step) {
|
|
12
|
+
function useTimer(time, active, counting, onFinish, interval, step) {
|
|
13
13
|
if (active === void 0) { active = true; }
|
|
14
14
|
if (interval === void 0) { interval = 1000; }
|
|
15
15
|
if (step === void 0) { step = 1; }
|
|
@@ -18,14 +18,18 @@ function useTimer(time, active, counting, interval, step) {
|
|
|
18
18
|
var persentValue = Math.trunc((passedTime / time) * MAX_PERSENT_VALUE);
|
|
19
19
|
React.useEffect(function () {
|
|
20
20
|
if (!active || isCompleted) {
|
|
21
|
+
if (isCompleted) {
|
|
22
|
+
onFinish();
|
|
23
|
+
}
|
|
21
24
|
return coreComponentsShared.noop;
|
|
22
25
|
}
|
|
23
26
|
var timer = setInterval(function () {
|
|
24
27
|
setPassedTime(function (prevPassed) { return prevPassed + step; });
|
|
25
28
|
}, interval);
|
|
26
29
|
return function () { return clearInterval(timer); };
|
|
27
|
-
}, [interval, isCompleted, active, step]);
|
|
30
|
+
}, [interval, isCompleted, active, step, onFinish]);
|
|
28
31
|
return [persentValue, makeTitle(counting === 'backward' ? time - passedTime : passedTime)];
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
exports.useTimer = useTimer;
|
|
35
|
+
//# sourceMappingURL=use-timer.js.map
|
package/use-timer.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-timer.js","sources":["../src/use-timer.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { noop } from '@alfalab/core-components-shared';\n\nconst MAX_PERSENT_VALUE = 100;\n\nfunction makeTitle(time: number) {\n return `${Math.trunc(time / 60)}:${`${time % 60}`.padStart(2, '0')}`;\n}\n\nexport function useTimer(\n time: number,\n active = true,\n counting: 'forward' | 'backward',\n onFinish: () => void,\n interval = 1000,\n step = 1,\n): [value: number, title: string] {\n const [passedTime, setPassedTime] = useState(0);\n const isCompleted = passedTime === time;\n const persentValue = Math.trunc((passedTime / time) * MAX_PERSENT_VALUE);\n\n useEffect(() => {\n if (!active || isCompleted) {\n if (isCompleted) {\n onFinish();\n }\n\n return noop;\n }\n\n const timer = setInterval(() => {\n setPassedTime((prevPassed) => prevPassed + step);\n }, interval);\n\n return () => clearInterval(timer);\n }, [interval, isCompleted, active, step, onFinish]);\n\n return [persentValue, makeTitle(counting === 'backward' ? time - passedTime : passedTime)];\n}\n"],"names":["useState","useEffect","noop"],"mappings":";;;;;;;AAIA,IAAM,iBAAiB,GAAG,GAAG;AAE7B,SAAS,SAAS,CAAC,IAAY,EAAA;IAC3B,OAAO,EAAA,CAAA,MAAA,CAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,EAAI,GAAA,CAAA,CAAA,MAAA,CAAA,EAAA,CAAA,MAAA,CAAG,IAAI,GAAG,EAAE,CAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAE;AACxE;AAEgB,SAAA,QAAQ,CACpB,IAAY,EACZ,MAAa,EACb,QAAgC,EAChC,QAAoB,EACpB,QAAe,EACf,IAAQ,EAAA;AAJR,IAAA,IAAA,MAAA,KAAA,MAAA,EAAA,EAAA,MAAa,GAAA,IAAA,CAAA;AAGb,IAAA,IAAA,QAAA,KAAA,MAAA,EAAA,EAAA,QAAe,GAAA,IAAA,CAAA;AACf,IAAA,IAAA,IAAA,KAAA,MAAA,EAAA,EAAA,IAAQ,GAAA,CAAA,CAAA;IAEF,IAAA,EAAA,GAA8BA,cAAQ,CAAC,CAAC,CAAC,EAAxC,UAAU,GAAA,EAAA,C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