@alfalab/core-components-circular-progress-bar 3.6.7 → 3.7.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/@alfalab/core-components-shared/package.json +26 -0
- package/Component.d.ts +36 -5
- package/Component.js +42 -7
- package/consts.d.ts +9 -1
- package/consts.js +11 -0
- package/cssm/Component.d.ts +36 -5
- package/cssm/Component.js +41 -6
- package/cssm/consts.d.ts +9 -1
- package/cssm/consts.js +11 -0
- package/cssm/index.d.ts +1 -0
- package/cssm/index.module.css +14 -1
- package/cssm/shared/index.d.ts +1 -0
- package/cssm/shared/index.js +9 -0
- package/cssm/types/component-size.d.ts +2 -0
- package/cssm/types/component-size.js +2 -0
- package/cssm/types/typography-color.d.ts +2 -0
- package/cssm/types/typography-color.js +2 -0
- package/cssm/use-timer.d.ts +2 -0
- package/cssm/use-timer.js +31 -0
- package/cssm/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
- package/cssm/utils/get-circular-progress-bar-test-ids.js +17 -0
- package/cssm/utils/is-typography-color.d.ts +3 -0
- package/cssm/utils/is-typography-color.js +11 -0
- package/esm/Component.d.ts +36 -5
- package/esm/Component.js +43 -8
- package/esm/consts.d.ts +9 -1
- package/esm/consts.js +9 -1
- package/esm/index.css +63 -50
- package/esm/index.d.ts +1 -0
- package/esm/shared/index.d.ts +1 -0
- package/esm/shared/index.js +1 -0
- package/esm/types/component-size.d.ts +2 -0
- package/esm/types/component-size.js +1 -0
- package/esm/types/typography-color.d.ts +2 -0
- package/esm/types/typography-color.js +1 -0
- package/esm/use-timer.d.ts +2 -0
- package/esm/use-timer.js +27 -0
- package/esm/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
- package/esm/utils/get-circular-progress-bar-test-ids.js +13 -0
- package/esm/utils/is-typography-color.d.ts +3 -0
- package/esm/utils/is-typography-color.js +7 -0
- package/index.css +63 -50
- package/index.d.ts +1 -0
- package/modern/Component.d.ts +36 -5
- package/modern/Component.js +49 -12
- package/modern/consts.d.ts +9 -1
- package/modern/consts.js +9 -1
- package/modern/index.css +63 -50
- package/modern/index.d.ts +1 -0
- package/modern/shared/index.d.ts +1 -0
- package/modern/shared/index.js +1 -0
- package/modern/types/component-size.d.ts +2 -0
- package/modern/types/component-size.js +1 -0
- package/modern/types/typography-color.d.ts +2 -0
- package/modern/types/typography-color.js +1 -0
- package/modern/use-timer.d.ts +2 -0
- package/modern/use-timer.js +24 -0
- package/modern/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
- package/modern/utils/get-circular-progress-bar-test-ids.js +13 -0
- package/modern/utils/is-typography-color.d.ts +3 -0
- package/modern/utils/is-typography-color.js +5 -0
- package/moderncssm/Component.d.ts +36 -5
- package/moderncssm/Component.js +48 -11
- package/moderncssm/consts.d.ts +9 -1
- package/moderncssm/consts.js +9 -1
- package/moderncssm/index.d.ts +1 -0
- package/moderncssm/index.module.css +18 -0
- package/moderncssm/shared/index.d.ts +1 -0
- package/moderncssm/shared/index.js +1 -0
- package/moderncssm/types/component-size.d.ts +2 -0
- package/moderncssm/types/component-size.js +1 -0
- package/moderncssm/types/typography-color.d.ts +2 -0
- package/moderncssm/types/typography-color.js +1 -0
- package/moderncssm/use-timer.d.ts +2 -0
- package/moderncssm/use-timer.js +24 -0
- package/moderncssm/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
- package/moderncssm/utils/get-circular-progress-bar-test-ids.js +13 -0
- package/moderncssm/utils/is-typography-color.d.ts +3 -0
- package/moderncssm/utils/is-typography-color.js +5 -0
- package/package.json +5 -4
- package/shared/index.d.ts +1 -0
- package/shared/index.js +9 -0
- package/shared/package.json +3 -0
- package/src/Component.tsx +111 -14
- package/src/consts.ts +10 -0
- package/src/index.module.css +18 -0
- package/src/index.ts +1 -0
- package/src/shared/index.ts +1 -0
- package/src/shared/package.json +3 -0
- package/src/types/component-size.ts +1 -0
- package/src/types/typography-color.ts +1 -0
- package/src/use-timer.ts +35 -0
- package/src/utils/get-circular-progress-bar-test-ids.ts +11 -0
- package/src/utils/is-typography-color.ts +5 -0
- package/types/component-size.d.ts +2 -0
- package/types/component-size.js +2 -0
- package/types/typography-color.d.ts +2 -0
- package/types/typography-color.js +2 -0
- package/use-timer.d.ts +2 -0
- package/use-timer.js +31 -0
- package/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
- package/utils/get-circular-progress-bar-test-ids.js +17 -0
- package/utils/is-typography-color.d.ts +3 -0
- package/utils/is-typography-color.js +11 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var coreComponentsShared = require('@alfalab/core-components-shared/cssm');
|
|
7
|
+
|
|
8
|
+
var MAX_PERSENT_VALUE = 100;
|
|
9
|
+
function makeTitle(time) {
|
|
10
|
+
return "".concat(Math.trunc(time / 60), ":").concat("".concat(time % 60).padStart(2, '0'));
|
|
11
|
+
}
|
|
12
|
+
function useTimer(time, active, counting, interval, step) {
|
|
13
|
+
if (active === void 0) { active = true; }
|
|
14
|
+
if (interval === void 0) { interval = 1000; }
|
|
15
|
+
if (step === void 0) { step = 1; }
|
|
16
|
+
var _a = React.useState(0), passedTime = _a[0], setPassedTime = _a[1];
|
|
17
|
+
var isCompleted = passedTime === time;
|
|
18
|
+
var persentValue = Math.trunc((passedTime / time) * MAX_PERSENT_VALUE);
|
|
19
|
+
React.useEffect(function () {
|
|
20
|
+
if (!active || isCompleted) {
|
|
21
|
+
return coreComponentsShared.noop;
|
|
22
|
+
}
|
|
23
|
+
var timer = setInterval(function () {
|
|
24
|
+
setPassedTime(function (prevPassed) { return prevPassed + step; });
|
|
25
|
+
}, interval);
|
|
26
|
+
return function () { return clearInterval(timer); };
|
|
27
|
+
}, [interval, isCompleted, active, step]);
|
|
28
|
+
return [persentValue, makeTitle(counting === 'backward' ? time - passedTime : passedTime)];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.useTimer = useTimer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var coreComponentsShared = require('@alfalab/core-components-shared/cssm');
|
|
6
|
+
|
|
7
|
+
function getCircularProgressBarTestIds(dataTestId) {
|
|
8
|
+
return {
|
|
9
|
+
progressBar: dataTestId,
|
|
10
|
+
title: coreComponentsShared.getDataTestId(dataTestId, 'title'),
|
|
11
|
+
subtitle: coreComponentsShared.getDataTestId(dataTestId, 'subtitle'),
|
|
12
|
+
circleProgressBar: coreComponentsShared.getDataTestId(dataTestId, 'circle-progress-bar'),
|
|
13
|
+
circleProgressValue: coreComponentsShared.getDataTestId(dataTestId, 'circle-progress-value'),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.getCircularProgressBarTestIds = getCircularProgressBarTestIds;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var consts = require('../consts.js');
|
|
6
|
+
|
|
7
|
+
var isTypographyColor = function (color) {
|
|
8
|
+
return consts.TYPOGRAPHY_COLOR.includes(color);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.isTypographyColor = isTypographyColor;
|
package/esm/Component.d.ts
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ElementType, ReactNode } from "react";
|
|
4
|
-
|
|
4
|
+
import { ComponentSize } from "./types/component-size";
|
|
5
|
+
import { TypographyColor } from "./types/typography-color";
|
|
5
6
|
type CircularProgressBarProps = {
|
|
6
7
|
/**
|
|
7
8
|
* Уровень прогресса, %
|
|
8
9
|
*/
|
|
9
|
-
value: number
|
|
10
|
+
value: number | {
|
|
11
|
+
/**
|
|
12
|
+
* Время таймера в секундах
|
|
13
|
+
* Минимальное значение 0
|
|
14
|
+
* Максимальное значение 3600
|
|
15
|
+
*/
|
|
16
|
+
timer: number;
|
|
17
|
+
/**
|
|
18
|
+
* Направлние отсчета таймера
|
|
19
|
+
* forward: считаем от 0 до указанного значения
|
|
20
|
+
* backward: считаем от указанного значения до 0
|
|
21
|
+
* @default backward
|
|
22
|
+
*/
|
|
23
|
+
counting?: 'forward' | 'backward';
|
|
24
|
+
};
|
|
10
25
|
/**
|
|
11
26
|
* Дополнительный класс
|
|
12
27
|
*/
|
|
@@ -19,6 +34,16 @@ type CircularProgressBarProps = {
|
|
|
19
34
|
* Цвет контента
|
|
20
35
|
*/
|
|
21
36
|
contentColor?: TypographyColor | string;
|
|
37
|
+
/**
|
|
38
|
+
* Цвет заголовка
|
|
39
|
+
* Приоритет выше чем у `contentColor`
|
|
40
|
+
*/
|
|
41
|
+
titleColor?: TypographyColor | string;
|
|
42
|
+
/**
|
|
43
|
+
* Цвет подзаголовка
|
|
44
|
+
* Приоритет выше чем у `contentColor`
|
|
45
|
+
*/
|
|
46
|
+
subtitleColor?: TypographyColor | string;
|
|
22
47
|
/**
|
|
23
48
|
* Дополнительный текст
|
|
24
49
|
*/
|
|
@@ -37,9 +62,10 @@ type CircularProgressBarProps = {
|
|
|
37
62
|
view?: 'positive' | 'negative';
|
|
38
63
|
/**
|
|
39
64
|
* Размер (xxl — 144×144px, xl — 128×128px, l — 80×80px, m — 64×64px, s — 48×48px, xs — 24×24px)
|
|
40
|
-
* @description xs, s, m, l, xl, xxl deprecated, используйте вместо них 24, 48, 64
|
|
65
|
+
* @description xs, s, m, l, xl, xxl deprecated, используйте вместо них 24, 48, 64, 80, 128, 144 соответственно
|
|
66
|
+
* @default 64
|
|
41
67
|
*/
|
|
42
|
-
size?:
|
|
68
|
+
size?: ComponentSize;
|
|
43
69
|
/**
|
|
44
70
|
* Наличие желоба
|
|
45
71
|
*/
|
|
@@ -103,9 +129,14 @@ type CircularProgressBarProps = {
|
|
|
103
129
|
* Цвет желоба
|
|
104
130
|
*/
|
|
105
131
|
strokeColor?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Направление заполнения круга
|
|
134
|
+
* @default desc
|
|
135
|
+
*/
|
|
136
|
+
directionType?: 'asc' | 'desc';
|
|
106
137
|
};
|
|
107
138
|
/**
|
|
108
139
|
* Компонент круглого прогресс бара.
|
|
109
140
|
*/
|
|
110
141
|
declare const CircularProgressBar: React.FC<CircularProgressBarProps>;
|
|
111
|
-
export {
|
|
142
|
+
export { CircularProgressBarProps, CircularProgressBar };
|
package/esm/Component.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { __assign } from 'tslib';
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
|
+
import { isObject, getDataTestId } from '@alfalab/core-components-shared/esm';
|
|
4
5
|
import { Text, TitleMobile } from '@alfalab/core-components-typography/esm';
|
|
5
|
-
import {
|
|
6
|
+
import { isTypographyColor } from './utils/is-typography-color.js';
|
|
7
|
+
import { MIN_TIMER_VALUE, MAX_TIMER_VALUE, STROKE, SIZES, TYPOGRAPHY_COLOR, SIZE_TO_CLASSNAME_MAP, MAX_PROGRESS_VALUE, VIEW_TITLE, VIEW_TEXT } from './consts.js';
|
|
8
|
+
import { useTimer } from './use-timer.js';
|
|
6
9
|
|
|
7
|
-
var styles = {"component":"circular-progress-
|
|
10
|
+
var styles = {"component":"circular-progress-bar__component_1cf8i","bg-positive":"circular-progress-bar__bg-positive_1cf8i","bg-negative":"circular-progress-bar__bg-negative_1cf8i","svg":"circular-progress-bar__svg_1cf8i","title":"circular-progress-bar__title_1cf8i","subtitle":"circular-progress-bar__subtitle_1cf8i","labelWrapper":"circular-progress-bar__labelWrapper_1cf8i","label":"circular-progress-bar__label_1cf8i","typography":"circular-progress-bar__typography_1cf8i","size-144":"circular-progress-bar__size-144_1cf8i","size-128":"circular-progress-bar__size-128_1cf8i","size-96":"circular-progress-bar__size-96_1cf8i","size-80":"circular-progress-bar__size-80_1cf8i","size-64":"circular-progress-bar__size-64_1cf8i","size-48":"circular-progress-bar__size-48_1cf8i","size-24":"circular-progress-bar__size-24_1cf8i","backgroundCircle":"circular-progress-bar__backgroundCircle_1cf8i","progressCircle":"circular-progress-bar__progressCircle_1cf8i","positive":"circular-progress-bar__positive_1cf8i","negative":"circular-progress-bar__negative_1cf8i","stroke":"circular-progress-bar__stroke_1cf8i","iconWrapper":"circular-progress-bar__iconWrapper_1cf8i","icon-tertiary":"circular-progress-bar__icon-tertiary_1cf8i","icon-positive":"circular-progress-bar__icon-positive_1cf8i","icon-negative":"circular-progress-bar__icon-negative_1cf8i","icon-primary-inverted":"circular-progress-bar__icon-primary-inverted_1cf8i","icon-primary":"circular-progress-bar__icon-primary_1cf8i","icon-secondary":"circular-progress-bar__icon-secondary_1cf8i","icon":"circular-progress-bar__icon_1cf8i"};
|
|
8
11
|
require('./index.css')
|
|
9
12
|
|
|
10
13
|
/**
|
|
@@ -12,7 +15,21 @@ require('./index.css')
|
|
|
12
15
|
*/
|
|
13
16
|
var CircularProgressBar = function (_a) {
|
|
14
17
|
var _b, _c, _d;
|
|
15
|
-
var
|
|
18
|
+
var _e;
|
|
19
|
+
var valueFromProps = _a.value, _f = _a.view, view = _f === void 0 ? 'positive' : _f, _g = _a.size, size = _g === void 0 ? 64 : _g, className = _a.className, dataTestId = _a.dataTestId, _h = _a.title, titleFromProps = _h === void 0 ? isObject(valueFromProps) ? null : "".concat(valueFromProps) : _h, titleComplete = _a.titleComplete, subtitle = _a.subtitle, _j = _a.contentColor, contentColor = _j === void 0 ? 'secondary' : _j, subtitleComplete = _a.subtitleComplete, _k = _a.stroke, stroke = _k === void 0 ? true : _k, fillComplete = _a.fillComplete, Icon = _a.icon, IconComplete = _a.iconComplete, completeTextColor = _a.completeTextColor, _l = _a.completeIconColor, completeIconColor = _l === void 0 ? 'tertiary' : _l, _m = _a.direction, direction = _m === void 0 ? 'clockwise' : _m, height = _a.height, children = _a.children, progressStrokeColor = _a.progressStrokeColor, circleColor = _a.circleColor, strokeColor = _a.strokeColor, _o = _a.directionType, directionType = _o === void 0 ? 'asc' : _o, titleColor = _a.titleColor, subtitleColor = _a.subtitleColor;
|
|
20
|
+
var isTimer = isObject(valueFromProps);
|
|
21
|
+
var _p = useTimer(isTimer ? Math.min(Math.max(valueFromProps.timer, MIN_TIMER_VALUE), MAX_TIMER_VALUE) : -1, isTimer, isTimer ? (_e = valueFromProps.counting) !== null && _e !== void 0 ? _e : 'backward' : 'backward'), timerValue = _p[0], timerTitle = _p[1];
|
|
22
|
+
var value;
|
|
23
|
+
var title;
|
|
24
|
+
if (isTimer) {
|
|
25
|
+
value = timerValue;
|
|
26
|
+
title = timerTitle;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
value = valueFromProps;
|
|
30
|
+
title = titleFromProps;
|
|
31
|
+
}
|
|
32
|
+
value = directionType === 'desc' ? MAX_PROGRESS_VALUE - value : value;
|
|
16
33
|
var memorized = useMemo(function () {
|
|
17
34
|
var strokeWidth = STROKE[size];
|
|
18
35
|
var maxProgress = 100;
|
|
@@ -33,7 +50,7 @@ var CircularProgressBar = function (_a) {
|
|
|
33
50
|
strokeDasharray: strokeDasharray,
|
|
34
51
|
strokeDashoffset: strokeDashoffset,
|
|
35
52
|
};
|
|
36
|
-
}, [
|
|
53
|
+
}, [size, value]);
|
|
37
54
|
var isComplete = value === 100;
|
|
38
55
|
var isCompleteTextColor = isComplete && completeTextColor;
|
|
39
56
|
var titleContent = titleComplete && isComplete ? titleComplete : title;
|
|
@@ -42,12 +59,30 @@ var CircularProgressBar = function (_a) {
|
|
|
42
59
|
var typographyContentColor = TYPOGRAPHY_COLOR.includes(contentColor)
|
|
43
60
|
? contentColor
|
|
44
61
|
: undefined;
|
|
62
|
+
var getTextColor = function (color) {
|
|
63
|
+
if (isCompleteTextColor) {
|
|
64
|
+
return completeTextColor;
|
|
65
|
+
}
|
|
66
|
+
if (color) {
|
|
67
|
+
return isTypographyColor(color) ? color : undefined;
|
|
68
|
+
}
|
|
69
|
+
return typographyContentColor;
|
|
70
|
+
};
|
|
71
|
+
var getTextStyleColor = function (color) {
|
|
72
|
+
if (color) {
|
|
73
|
+
if (!isTypographyColor(color)) {
|
|
74
|
+
return { color: color };
|
|
75
|
+
}
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
return __assign({}, (!typographyContentColor && { color: contentColor }));
|
|
79
|
+
};
|
|
45
80
|
var renderTitleString = function () {
|
|
46
|
-
return SIZES[size] > 64 ? (React.createElement(TitleMobile, { className: cn(styles.typography, styles.title), color:
|
|
81
|
+
return SIZES[size] > 64 ? (React.createElement(TitleMobile, { className: cn(styles.typography, styles.title), color: getTextColor(titleColor), tag: 'div', font: 'system', view: VIEW_TITLE[size], style: __assign({}, getTextStyleColor(titleColor)), dataTestId: getDataTestId(dataTestId, 'title') }, titleContent)) : (React.createElement(Text, { className: styles.title, color: getTextColor(titleColor), tag: 'div', weight: 'bold', view: VIEW_TEXT[size], style: __assign({}, getTextStyleColor(titleColor)), dataTestId: getDataTestId(dataTestId, 'title') }, titleContent));
|
|
47
82
|
};
|
|
48
83
|
var renderTitle = function () { return (typeof title === 'string' ? renderTitleString() : titleContent); };
|
|
49
84
|
var renderSubTitle = function () {
|
|
50
|
-
return typeof subtitle === 'string' ? (React.createElement(Text, { tag: 'div', className: styles.subtitle, color:
|
|
85
|
+
return typeof subtitle === 'string' ? (React.createElement(Text, { tag: 'div', className: styles.subtitle, color: getTextColor(subtitleColor), view: 'primary-small', dataTestId: getDataTestId(dataTestId, 'subtitle'), style: __assign({}, getTextStyleColor(subtitleColor)) }, subtitleContent)) : (subtitleContent);
|
|
51
86
|
};
|
|
52
87
|
var renderIcon = function () {
|
|
53
88
|
var _a;
|
|
@@ -66,10 +101,10 @@ var CircularProgressBar = function (_a) {
|
|
|
66
101
|
React.createElement("svg", { viewBox: "0 0 ".concat(memorized.widthSVG, " ").concat(memorized.heightSVG), className: styles.svg, xmlns: 'http://www.w3.org/2000/svg' },
|
|
67
102
|
React.createElement("circle", { className: cn(styles.backgroundCircle, styles[SIZE_TO_CLASSNAME_MAP[size]], (_c = {},
|
|
68
103
|
_c[styles.stroke] = !stroke,
|
|
69
|
-
_c)), style: __assign({}, (strokeColor && stroke && { stroke: strokeColor })), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size] }),
|
|
104
|
+
_c)), style: __assign({}, (strokeColor && stroke && { stroke: strokeColor })), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], "data-test-id": getDataTestId(dataTestId, 'circle-progress-bar') }),
|
|
70
105
|
React.createElement("circle", { className: cn(styles.progressCircle, styles[view], styles[SIZE_TO_CLASSNAME_MAP[size]]), style: __assign({}, (progressStrokeColor && { stroke: progressStrokeColor })), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
|
|
71
106
|
? -memorized.strokeDashoffset
|
|
72
|
-
: memorized.strokeDashoffset, transform: "rotate(".concat(-90, " ").concat(memorized.center, " ").concat(memorized.center, ")") })),
|
|
107
|
+
: memorized.strokeDashoffset, transform: "rotate(".concat(-90, " ").concat(memorized.center, " ").concat(memorized.center, ")"), "data-test-id": getDataTestId(dataTestId, 'circle-progress-value') })),
|
|
73
108
|
React.createElement("div", { className: cn(styles.labelWrapper, (_d = {},
|
|
74
109
|
_d[styles.label] = Icon || IconComplete,
|
|
75
110
|
_d)) }, children || renderContent())));
|
package/esm/consts.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ declare const SIZES: {
|
|
|
9
9
|
48: number;
|
|
10
10
|
64: number;
|
|
11
11
|
80: number;
|
|
12
|
+
96: number;
|
|
12
13
|
128: number;
|
|
13
14
|
144: number;
|
|
14
15
|
};
|
|
@@ -23,6 +24,7 @@ declare const STROKE: {
|
|
|
23
24
|
48: number;
|
|
24
25
|
64: number;
|
|
25
26
|
80: number;
|
|
27
|
+
96: number;
|
|
26
28
|
128: number;
|
|
27
29
|
144: number;
|
|
28
30
|
};
|
|
@@ -37,6 +39,7 @@ declare const VIEW_TITLE: {
|
|
|
37
39
|
readonly 48: "small";
|
|
38
40
|
readonly 64: "small";
|
|
39
41
|
readonly 80: "xsmall";
|
|
42
|
+
readonly 96: "xsmall";
|
|
40
43
|
readonly 128: "medium";
|
|
41
44
|
readonly 144: "medium";
|
|
42
45
|
};
|
|
@@ -51,6 +54,7 @@ declare const VIEW_TEXT: {
|
|
|
51
54
|
readonly 48: "secondary-small";
|
|
52
55
|
readonly 64: "secondary-large";
|
|
53
56
|
readonly 80: "secondary-large";
|
|
57
|
+
readonly 96: "secondary-large";
|
|
54
58
|
readonly 128: "secondary-large";
|
|
55
59
|
readonly 144: "secondary-large";
|
|
56
60
|
};
|
|
@@ -66,7 +70,11 @@ declare const SIZE_TO_CLASSNAME_MAP: {
|
|
|
66
70
|
48: string;
|
|
67
71
|
64: string;
|
|
68
72
|
80: string;
|
|
73
|
+
96: string;
|
|
69
74
|
128: string;
|
|
70
75
|
144: string;
|
|
71
76
|
};
|
|
72
|
-
|
|
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 };
|
package/esm/consts.js
CHANGED
|
@@ -9,6 +9,7 @@ var SIZES = {
|
|
|
9
9
|
48: 48,
|
|
10
10
|
64: 64,
|
|
11
11
|
80: 80,
|
|
12
|
+
96: 96,
|
|
12
13
|
128: 128,
|
|
13
14
|
144: 144,
|
|
14
15
|
};
|
|
@@ -23,6 +24,7 @@ var STROKE = {
|
|
|
23
24
|
48: 4,
|
|
24
25
|
64: 6,
|
|
25
26
|
80: 8,
|
|
27
|
+
96: 8,
|
|
26
28
|
128: 10,
|
|
27
29
|
144: 12,
|
|
28
30
|
};
|
|
@@ -37,6 +39,7 @@ var VIEW_TITLE = {
|
|
|
37
39
|
48: 'small',
|
|
38
40
|
64: 'small',
|
|
39
41
|
80: 'xsmall',
|
|
42
|
+
96: 'xsmall',
|
|
40
43
|
128: 'medium',
|
|
41
44
|
144: 'medium',
|
|
42
45
|
};
|
|
@@ -51,6 +54,7 @@ var VIEW_TEXT = {
|
|
|
51
54
|
48: 'secondary-small',
|
|
52
55
|
64: 'secondary-large',
|
|
53
56
|
80: 'secondary-large',
|
|
57
|
+
96: 'secondary-large',
|
|
54
58
|
128: 'secondary-large',
|
|
55
59
|
144: 'secondary-large',
|
|
56
60
|
};
|
|
@@ -66,8 +70,12 @@ var SIZE_TO_CLASSNAME_MAP = {
|
|
|
66
70
|
48: 'size-48',
|
|
67
71
|
64: 'size-64',
|
|
68
72
|
80: 'size-80',
|
|
73
|
+
96: 'size-96',
|
|
69
74
|
128: 'size-128',
|
|
70
75
|
144: 'size-144',
|
|
71
76
|
};
|
|
77
|
+
var MAX_PROGRESS_VALUE = 100;
|
|
78
|
+
var MIN_TIMER_VALUE = 0;
|
|
79
|
+
var MAX_TIMER_VALUE = 3599;
|
|
72
80
|
|
|
73
|
-
export { SIZES, SIZE_TO_CLASSNAME_MAP, STROKE, TYPOGRAPHY_COLOR, VIEW_TEXT, VIEW_TITLE };
|
|
81
|
+
export { MAX_PROGRESS_VALUE, MAX_TIMER_VALUE, MIN_TIMER_VALUE, SIZES, SIZE_TO_CLASSNAME_MAP, STROKE, TYPOGRAPHY_COLOR, VIEW_TEXT, VIEW_TITLE };
|
package/esm/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 14q8x */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-neutral-500: #babbc2;
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
25
25
|
|
|
26
26
|
/* новые значения, используйте их */
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
/* no-unit может приводить к проблемам в calc (#1559) */
|
|
29
|
+
/* stylelint-disable-next-line length-zero-no-unit */
|
|
30
|
+
--gap-0: 0px;
|
|
28
31
|
} :root {
|
|
29
32
|
--font-family-system: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica,
|
|
30
33
|
sans-serif;
|
|
@@ -42,135 +45,145 @@
|
|
|
42
45
|
/* theme */
|
|
43
46
|
--circular-progress-bar-font-family: var(--font-family-system);
|
|
44
47
|
--circular-progress-bar-font-weight: 600;
|
|
45
|
-
} .circular-progress-
|
|
48
|
+
} .circular-progress-bar__component_1cf8i {
|
|
46
49
|
position: relative;
|
|
47
50
|
display: flex;
|
|
48
51
|
justify-content: center;
|
|
49
52
|
align-items: center;
|
|
50
53
|
border-radius: var(--border-radius-pill)
|
|
51
|
-
} .circular-progress-
|
|
54
|
+
} .circular-progress-bar__component_1cf8i.circular-progress-bar__bg-positive_1cf8i {
|
|
52
55
|
background: var(--circular-progress-bar-positive-color);
|
|
53
|
-
} .circular-progress-
|
|
56
|
+
} .circular-progress-bar__component_1cf8i.circular-progress-bar__bg-negative_1cf8i {
|
|
54
57
|
background: var(--circular-progress-bar-negative-color);
|
|
55
|
-
} .circular-progress-
|
|
58
|
+
} .circular-progress-bar__svg_1cf8i {
|
|
56
59
|
display: block;
|
|
57
60
|
width: 100%;
|
|
58
|
-
} .circular-progress-
|
|
59
|
-
.circular-progress-
|
|
61
|
+
} .circular-progress-bar__title_1cf8i,
|
|
62
|
+
.circular-progress-bar__subtitle_1cf8i {
|
|
60
63
|
overflow: hidden;
|
|
61
64
|
word-break: break-word;
|
|
62
65
|
white-space: nowrap;
|
|
63
66
|
text-overflow: ellipsis;
|
|
64
67
|
margin: var(--gap-0) 6px;
|
|
65
|
-
} .circular-progress-
|
|
68
|
+
} .circular-progress-bar__subtitle_1cf8i {
|
|
66
69
|
max-height: 40px;
|
|
67
|
-
} .circular-progress-
|
|
70
|
+
} .circular-progress-bar__labelWrapper_1cf8i {
|
|
68
71
|
text-align: center;
|
|
69
72
|
position: absolute;
|
|
70
73
|
top: 50%;
|
|
71
74
|
left: 50%;
|
|
72
75
|
width: 100%;
|
|
73
76
|
transform: translate(-50%, -50%)
|
|
74
|
-
} .circular-progress-
|
|
77
|
+
} .circular-progress-bar__labelWrapper_1cf8i.circular-progress-bar__label_1cf8i {
|
|
75
78
|
display: flex;
|
|
76
79
|
align-items: center;
|
|
77
80
|
justify-content: center;
|
|
78
|
-
} .circular-progress-
|
|
81
|
+
} .circular-progress-bar__typography_1cf8i {
|
|
79
82
|
font-feature-settings: 'ss01';
|
|
80
83
|
font-weight: var(--circular-progress-bar-font-weight);
|
|
81
84
|
font-family: var(--circular-progress-bar-font-family);
|
|
82
|
-
} .circular-progress-bar__size-
|
|
85
|
+
} .circular-progress-bar__size-144_1cf8i {
|
|
83
86
|
width: 144px;
|
|
84
87
|
height: 144px
|
|
85
|
-
} .circular-progress-bar__size-
|
|
88
|
+
} .circular-progress-bar__size-144_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
|
|
86
89
|
max-width: 128px;
|
|
87
|
-
} .circular-progress-bar__size-
|
|
90
|
+
} .circular-progress-bar__size-144_1cf8i .circular-progress-bar__title_1cf8i {
|
|
88
91
|
max-height: 32px;
|
|
89
|
-
} .circular-progress-bar__size-
|
|
92
|
+
} .circular-progress-bar__size-128_1cf8i {
|
|
90
93
|
width: 128px;
|
|
91
94
|
height: 128px
|
|
92
|
-
} .circular-progress-bar__size-
|
|
95
|
+
} .circular-progress-bar__size-128_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
|
|
93
96
|
max-width: 108px;
|
|
94
|
-
} .circular-progress-bar__size-
|
|
97
|
+
} .circular-progress-bar__size-128_1cf8i .circular-progress-bar__title_1cf8i {
|
|
95
98
|
max-height: 32px;
|
|
96
|
-
} .circular-progress-bar__size-
|
|
99
|
+
} .circular-progress-bar__size-96_1cf8i {
|
|
100
|
+
width: 96px;
|
|
101
|
+
height: 96px
|
|
102
|
+
} .circular-progress-bar__size-96_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
|
|
103
|
+
max-width: 64px;
|
|
104
|
+
} .circular-progress-bar__size-96_1cf8i .circular-progress-bar__title_1cf8i {
|
|
105
|
+
max-height: 20px;
|
|
106
|
+
} .circular-progress-bar__size-80_1cf8i {
|
|
97
107
|
width: 80px;
|
|
98
108
|
height: 80px
|
|
99
|
-
} .circular-progress-bar__size-
|
|
109
|
+
} .circular-progress-bar__size-80_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
|
|
100
110
|
max-width: 64px;
|
|
101
|
-
} .circular-progress-bar__size-
|
|
111
|
+
} .circular-progress-bar__size-80_1cf8i .circular-progress-bar__title_1cf8i {
|
|
102
112
|
max-height: 24px;
|
|
103
|
-
} .circular-progress-bar__size-
|
|
113
|
+
} .circular-progress-bar__size-64_1cf8i {
|
|
104
114
|
width: 64px;
|
|
105
115
|
height: 64px
|
|
106
|
-
} .circular-progress-bar__size-
|
|
116
|
+
} .circular-progress-bar__size-64_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
|
|
107
117
|
max-width: 48px;
|
|
108
|
-
} .circular-progress-bar__size-
|
|
118
|
+
} .circular-progress-bar__size-64_1cf8i .circular-progress-bar__title_1cf8i {
|
|
109
119
|
max-height: 16px;
|
|
110
120
|
margin: var(--gap-0);
|
|
111
|
-
} .circular-progress-bar__size-
|
|
121
|
+
} .circular-progress-bar__size-48_1cf8i {
|
|
112
122
|
width: 48px;
|
|
113
123
|
height: 48px
|
|
114
|
-
} .circular-progress-bar__size-
|
|
124
|
+
} .circular-progress-bar__size-48_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
|
|
115
125
|
max-width: 40px;
|
|
116
|
-
} .circular-progress-bar__size-
|
|
126
|
+
} .circular-progress-bar__size-48_1cf8i .circular-progress-bar__title_1cf8i {
|
|
117
127
|
max-height: 16px;
|
|
118
128
|
margin: var(--gap-0);
|
|
119
|
-
} .circular-progress-bar__size-
|
|
129
|
+
} .circular-progress-bar__size-24_1cf8i {
|
|
120
130
|
width: 24px;
|
|
121
131
|
height: 24px
|
|
122
|
-
} .circular-progress-bar__size-
|
|
132
|
+
} .circular-progress-bar__size-24_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
|
|
123
133
|
max-width: 24px;
|
|
124
|
-
} .circular-progress-
|
|
125
|
-
.circular-progress-
|
|
134
|
+
} .circular-progress-bar__backgroundCircle_1cf8i,
|
|
135
|
+
.circular-progress-bar__progressCircle_1cf8i {
|
|
126
136
|
width: 100%;
|
|
127
137
|
height: 100%;
|
|
128
138
|
fill: transparent;
|
|
129
|
-
} .circular-progress-
|
|
139
|
+
} .circular-progress-bar__positive_1cf8i {
|
|
130
140
|
stroke: var(--circular-progress-bar-positive-color);
|
|
131
|
-
} .circular-progress-
|
|
141
|
+
} .circular-progress-bar__negative_1cf8i {
|
|
132
142
|
stroke: var(--circular-progress-bar-negative-color);
|
|
133
|
-
} .circular-progress-
|
|
143
|
+
} .circular-progress-bar__backgroundCircle_1cf8i {
|
|
134
144
|
stroke: var(--circular-progress-bar-stroke-color)
|
|
135
|
-
} .circular-progress-
|
|
145
|
+
} .circular-progress-bar__backgroundCircle_1cf8i.circular-progress-bar__stroke_1cf8i {
|
|
136
146
|
stroke: transparent;
|
|
137
|
-
} .circular-progress-
|
|
147
|
+
} .circular-progress-bar__progressCircle_1cf8i {
|
|
138
148
|
stroke-linecap: round;
|
|
139
|
-
} .circular-progress-
|
|
149
|
+
} .circular-progress-bar__iconWrapper_1cf8i {
|
|
140
150
|
display: flex;
|
|
141
151
|
align-items: center;
|
|
142
152
|
justify-content: center
|
|
143
|
-
} .circular-progress-
|
|
153
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__size-144_1cf8i {
|
|
144
154
|
max-width: 64px;
|
|
145
155
|
max-height: 64px;
|
|
146
|
-
} .circular-progress-
|
|
156
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__size-128_1cf8i {
|
|
147
157
|
max-width: 64px;
|
|
148
158
|
max-height: 64px;
|
|
149
|
-
} .circular-progress-
|
|
159
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__size-96_1cf8i {
|
|
160
|
+
max-width: 48px;
|
|
161
|
+
max-height: 48px;
|
|
162
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__size-80_1cf8i {
|
|
150
163
|
max-width: 48px;
|
|
151
164
|
max-height: 48px;
|
|
152
|
-
} .circular-progress-
|
|
165
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__size-64_1cf8i {
|
|
153
166
|
max-width: 36px;
|
|
154
167
|
max-height: 36px;
|
|
155
|
-
} .circular-progress-
|
|
168
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__size-48_1cf8i {
|
|
156
169
|
max-width: 24px;
|
|
157
170
|
max-height: 24px;
|
|
158
|
-
} .circular-progress-
|
|
171
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__size-24_1cf8i {
|
|
159
172
|
max-width: 16px;
|
|
160
173
|
max-height: 16px;
|
|
161
|
-
} .circular-progress-
|
|
174
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-tertiary_1cf8i {
|
|
162
175
|
color: var(--color-light-neutral-500);
|
|
163
|
-
} .circular-progress-
|
|
176
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-positive_1cf8i {
|
|
164
177
|
color: var(--color-light-status-positive);
|
|
165
|
-
} .circular-progress-
|
|
178
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-negative_1cf8i {
|
|
166
179
|
color: var(--color-light-status-negative);
|
|
167
|
-
} .circular-progress-
|
|
180
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-primary-inverted_1cf8i {
|
|
168
181
|
color: var(--color-light-neutral-translucent-1300-inverted);
|
|
169
|
-
} .circular-progress-
|
|
182
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-primary_1cf8i {
|
|
170
183
|
color: var(--color-light-neutral-translucent-1300);
|
|
171
|
-
} .circular-progress-
|
|
184
|
+
} .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-secondary_1cf8i {
|
|
172
185
|
color: var(--color-light-neutral-700);
|
|
173
|
-
} .circular-progress-
|
|
186
|
+
} .circular-progress-bar__icon_1cf8i {
|
|
174
187
|
width: 100%;
|
|
175
188
|
height: 100%;
|
|
176
189
|
}
|
package/esm/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCircularProgressBarTestIds } from "../utils/get-circular-progress-bar-test-ids";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCircularProgressBarTestIds } from '../utils/get-circular-progress-bar-test-ids.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/esm/use-timer.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { noop } from '@alfalab/core-components-shared/esm';
|
|
3
|
+
|
|
4
|
+
var MAX_PERSENT_VALUE = 100;
|
|
5
|
+
function makeTitle(time) {
|
|
6
|
+
return "".concat(Math.trunc(time / 60), ":").concat("".concat(time % 60).padStart(2, '0'));
|
|
7
|
+
}
|
|
8
|
+
function useTimer(time, active, counting, interval, step) {
|
|
9
|
+
if (active === void 0) { active = true; }
|
|
10
|
+
if (interval === void 0) { interval = 1000; }
|
|
11
|
+
if (step === void 0) { step = 1; }
|
|
12
|
+
var _a = useState(0), passedTime = _a[0], setPassedTime = _a[1];
|
|
13
|
+
var isCompleted = passedTime === time;
|
|
14
|
+
var persentValue = Math.trunc((passedTime / time) * MAX_PERSENT_VALUE);
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
if (!active || isCompleted) {
|
|
17
|
+
return noop;
|
|
18
|
+
}
|
|
19
|
+
var timer = setInterval(function () {
|
|
20
|
+
setPassedTime(function (prevPassed) { return prevPassed + step; });
|
|
21
|
+
}, interval);
|
|
22
|
+
return function () { return clearInterval(timer); };
|
|
23
|
+
}, [interval, isCompleted, active, step]);
|
|
24
|
+
return [persentValue, makeTitle(counting === 'backward' ? time - passedTime : passedTime)];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useTimer };
|