@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.
Files changed (104) hide show
  1. package/@alfalab/core-components-shared/package.json +26 -0
  2. package/Component.d.ts +36 -5
  3. package/Component.js +42 -7
  4. package/consts.d.ts +9 -1
  5. package/consts.js +11 -0
  6. package/cssm/Component.d.ts +36 -5
  7. package/cssm/Component.js +41 -6
  8. package/cssm/consts.d.ts +9 -1
  9. package/cssm/consts.js +11 -0
  10. package/cssm/index.d.ts +1 -0
  11. package/cssm/index.module.css +14 -1
  12. package/cssm/shared/index.d.ts +1 -0
  13. package/cssm/shared/index.js +9 -0
  14. package/cssm/types/component-size.d.ts +2 -0
  15. package/cssm/types/component-size.js +2 -0
  16. package/cssm/types/typography-color.d.ts +2 -0
  17. package/cssm/types/typography-color.js +2 -0
  18. package/cssm/use-timer.d.ts +2 -0
  19. package/cssm/use-timer.js +31 -0
  20. package/cssm/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
  21. package/cssm/utils/get-circular-progress-bar-test-ids.js +17 -0
  22. package/cssm/utils/is-typography-color.d.ts +3 -0
  23. package/cssm/utils/is-typography-color.js +11 -0
  24. package/esm/Component.d.ts +36 -5
  25. package/esm/Component.js +43 -8
  26. package/esm/consts.d.ts +9 -1
  27. package/esm/consts.js +9 -1
  28. package/esm/index.css +63 -50
  29. package/esm/index.d.ts +1 -0
  30. package/esm/shared/index.d.ts +1 -0
  31. package/esm/shared/index.js +1 -0
  32. package/esm/types/component-size.d.ts +2 -0
  33. package/esm/types/component-size.js +1 -0
  34. package/esm/types/typography-color.d.ts +2 -0
  35. package/esm/types/typography-color.js +1 -0
  36. package/esm/use-timer.d.ts +2 -0
  37. package/esm/use-timer.js +27 -0
  38. package/esm/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
  39. package/esm/utils/get-circular-progress-bar-test-ids.js +13 -0
  40. package/esm/utils/is-typography-color.d.ts +3 -0
  41. package/esm/utils/is-typography-color.js +7 -0
  42. package/index.css +63 -50
  43. package/index.d.ts +1 -0
  44. package/modern/Component.d.ts +36 -5
  45. package/modern/Component.js +49 -12
  46. package/modern/consts.d.ts +9 -1
  47. package/modern/consts.js +9 -1
  48. package/modern/index.css +63 -50
  49. package/modern/index.d.ts +1 -0
  50. package/modern/shared/index.d.ts +1 -0
  51. package/modern/shared/index.js +1 -0
  52. package/modern/types/component-size.d.ts +2 -0
  53. package/modern/types/component-size.js +1 -0
  54. package/modern/types/typography-color.d.ts +2 -0
  55. package/modern/types/typography-color.js +1 -0
  56. package/modern/use-timer.d.ts +2 -0
  57. package/modern/use-timer.js +24 -0
  58. package/modern/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
  59. package/modern/utils/get-circular-progress-bar-test-ids.js +13 -0
  60. package/modern/utils/is-typography-color.d.ts +3 -0
  61. package/modern/utils/is-typography-color.js +5 -0
  62. package/moderncssm/Component.d.ts +36 -5
  63. package/moderncssm/Component.js +48 -11
  64. package/moderncssm/consts.d.ts +9 -1
  65. package/moderncssm/consts.js +9 -1
  66. package/moderncssm/index.d.ts +1 -0
  67. package/moderncssm/index.module.css +18 -0
  68. package/moderncssm/shared/index.d.ts +1 -0
  69. package/moderncssm/shared/index.js +1 -0
  70. package/moderncssm/types/component-size.d.ts +2 -0
  71. package/moderncssm/types/component-size.js +1 -0
  72. package/moderncssm/types/typography-color.d.ts +2 -0
  73. package/moderncssm/types/typography-color.js +1 -0
  74. package/moderncssm/use-timer.d.ts +2 -0
  75. package/moderncssm/use-timer.js +24 -0
  76. package/moderncssm/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
  77. package/moderncssm/utils/get-circular-progress-bar-test-ids.js +13 -0
  78. package/moderncssm/utils/is-typography-color.d.ts +3 -0
  79. package/moderncssm/utils/is-typography-color.js +5 -0
  80. package/package.json +5 -4
  81. package/shared/index.d.ts +1 -0
  82. package/shared/index.js +9 -0
  83. package/shared/package.json +3 -0
  84. package/src/Component.tsx +111 -14
  85. package/src/consts.ts +10 -0
  86. package/src/index.module.css +18 -0
  87. package/src/index.ts +1 -0
  88. package/src/shared/index.ts +1 -0
  89. package/src/shared/package.json +3 -0
  90. package/src/types/component-size.ts +1 -0
  91. package/src/types/typography-color.ts +1 -0
  92. package/src/use-timer.ts +35 -0
  93. package/src/utils/get-circular-progress-bar-test-ids.ts +11 -0
  94. package/src/utils/is-typography-color.ts +5 -0
  95. package/types/component-size.d.ts +2 -0
  96. package/types/component-size.js +2 -0
  97. package/types/typography-color.d.ts +2 -0
  98. package/types/typography-color.js +2 -0
  99. package/use-timer.d.ts +2 -0
  100. package/use-timer.js +31 -0
  101. package/utils/get-circular-progress-bar-test-ids.d.ts +8 -0
  102. package/utils/get-circular-progress-bar-test-ids.js +17 -0
  103. package/utils/is-typography-color.d.ts +3 -0
  104. 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,8 @@
1
+ declare function getCircularProgressBarTestIds(dataTestId: string): {
2
+ progressBar: string;
3
+ title: string;
4
+ subtitle: string;
5
+ circleProgressBar: string;
6
+ circleProgressValue: string;
7
+ };
8
+ export { getCircularProgressBarTestIds };
@@ -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,3 @@
1
+ import { TypographyColor } from "../types/typography-color";
2
+ declare const isTypographyColor: (color: TypographyColor | string) => color is TypographyColor;
3
+ export { isTypographyColor };
@@ -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;
@@ -1,12 +1,27 @@
1
1
  /// <reference types="react" />
2
2
  import React from 'react';
3
3
  import { ElementType, ReactNode } from "react";
4
- type TypographyColor = 'primary' | 'secondary' | 'tertiary' | 'positive' | 'negative';
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 , 80, 128, 144 соответственно
65
+ * @description xs, s, m, l, xl, xxl deprecated, используйте вместо них 24, 48, 64, 80, 128, 144 соответственно
66
+ * @default 64
41
67
  */
42
- size?: 'xxl' | 'xl' | 'l' | 'm' | 's' | 'xs' | 24 | 48 | 64 | 80 | 128 | 144;
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 { TypographyColor, CircularProgressBarProps, CircularProgressBar };
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 { STROKE, SIZES, TYPOGRAPHY_COLOR, SIZE_TO_CLASSNAME_MAP, VIEW_TITLE, VIEW_TEXT } from './consts.js';
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-bar__component_5bj3o","bg-positive":"circular-progress-bar__bg-positive_5bj3o","bg-negative":"circular-progress-bar__bg-negative_5bj3o","svg":"circular-progress-bar__svg_5bj3o","title":"circular-progress-bar__title_5bj3o","subtitle":"circular-progress-bar__subtitle_5bj3o","labelWrapper":"circular-progress-bar__labelWrapper_5bj3o","label":"circular-progress-bar__label_5bj3o","typography":"circular-progress-bar__typography_5bj3o","size-144":"circular-progress-bar__size-144_5bj3o","size-128":"circular-progress-bar__size-128_5bj3o","size-80":"circular-progress-bar__size-80_5bj3o","size-64":"circular-progress-bar__size-64_5bj3o","size-48":"circular-progress-bar__size-48_5bj3o","size-24":"circular-progress-bar__size-24_5bj3o","backgroundCircle":"circular-progress-bar__backgroundCircle_5bj3o","progressCircle":"circular-progress-bar__progressCircle_5bj3o","positive":"circular-progress-bar__positive_5bj3o","negative":"circular-progress-bar__negative_5bj3o","stroke":"circular-progress-bar__stroke_5bj3o","iconWrapper":"circular-progress-bar__iconWrapper_5bj3o","icon-tertiary":"circular-progress-bar__icon-tertiary_5bj3o","icon-positive":"circular-progress-bar__icon-positive_5bj3o","icon-negative":"circular-progress-bar__icon-negative_5bj3o","icon-primary-inverted":"circular-progress-bar__icon-primary-inverted_5bj3o","icon-primary":"circular-progress-bar__icon-primary_5bj3o","icon-secondary":"circular-progress-bar__icon-secondary_5bj3o","icon":"circular-progress-bar__icon_5bj3o"};
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 value = _a.value, _e = _a.view, view = _e === void 0 ? 'positive' : _e, _f = _a.size, size = _f === void 0 ? 64 : _f, className = _a.className, dataTestId = _a.dataTestId, _g = _a.title, title = _g === void 0 ? value ? value.toString() : '0' : _g, titleComplete = _a.titleComplete, subtitle = _a.subtitle, _h = _a.contentColor, contentColor = _h === void 0 ? 'secondary' : _h, subtitleComplete = _a.subtitleComplete, _j = _a.stroke, stroke = _j === void 0 ? true : _j, fillComplete = _a.fillComplete, Icon = _a.icon, IconComplete = _a.iconComplete, completeTextColor = _a.completeTextColor, _k = _a.completeIconColor, completeIconColor = _k === void 0 ? 'tertiary' : _k, _l = _a.direction, direction = _l === void 0 ? 'clockwise' : _l, height = _a.height, children = _a.children, progressStrokeColor = _a.progressStrokeColor, circleColor = _a.circleColor, strokeColor = _a.strokeColor;
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
- }, [value, size]);
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: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', font: 'system', view: VIEW_TITLE[size], style: __assign({}, (!typographyContentColor && { color: contentColor })) }, titleContent)) : (React.createElement(Text, { className: styles.title, color: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', weight: 'bold', view: VIEW_TEXT[size], style: __assign({}, (!typographyContentColor && { color: contentColor })) }, titleContent));
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: isCompleteTextColor ? completeTextColor : typographyContentColor, view: 'primary-small', style: __assign({}, (!typographyContentColor && { color: contentColor })) }, subtitleContent)) : (subtitleContent);
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
- export { SIZES, STROKE, VIEW_TITLE, VIEW_TEXT, TYPOGRAPHY_COLOR, SIZE_TO_CLASSNAME_MAP };
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: 1h4pu */
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
- --gap-0: 0;
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-bar__component_5bj3o {
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-bar__component_5bj3o.circular-progress-bar__bg-positive_5bj3o {
54
+ } .circular-progress-bar__component_1cf8i.circular-progress-bar__bg-positive_1cf8i {
52
55
  background: var(--circular-progress-bar-positive-color);
53
- } .circular-progress-bar__component_5bj3o.circular-progress-bar__bg-negative_5bj3o {
56
+ } .circular-progress-bar__component_1cf8i.circular-progress-bar__bg-negative_1cf8i {
54
57
  background: var(--circular-progress-bar-negative-color);
55
- } .circular-progress-bar__svg_5bj3o {
58
+ } .circular-progress-bar__svg_1cf8i {
56
59
  display: block;
57
60
  width: 100%;
58
- } .circular-progress-bar__title_5bj3o,
59
- .circular-progress-bar__subtitle_5bj3o {
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-bar__subtitle_5bj3o {
68
+ } .circular-progress-bar__subtitle_1cf8i {
66
69
  max-height: 40px;
67
- } .circular-progress-bar__labelWrapper_5bj3o {
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-bar__labelWrapper_5bj3o.circular-progress-bar__label_5bj3o {
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-bar__typography_5bj3o {
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-144_5bj3o {
85
+ } .circular-progress-bar__size-144_1cf8i {
83
86
  width: 144px;
84
87
  height: 144px
85
- } .circular-progress-bar__size-144_5bj3o .circular-progress-bar__labelWrapper_5bj3o {
88
+ } .circular-progress-bar__size-144_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
86
89
  max-width: 128px;
87
- } .circular-progress-bar__size-144_5bj3o .circular-progress-bar__title_5bj3o {
90
+ } .circular-progress-bar__size-144_1cf8i .circular-progress-bar__title_1cf8i {
88
91
  max-height: 32px;
89
- } .circular-progress-bar__size-128_5bj3o {
92
+ } .circular-progress-bar__size-128_1cf8i {
90
93
  width: 128px;
91
94
  height: 128px
92
- } .circular-progress-bar__size-128_5bj3o .circular-progress-bar__labelWrapper_5bj3o {
95
+ } .circular-progress-bar__size-128_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
93
96
  max-width: 108px;
94
- } .circular-progress-bar__size-128_5bj3o .circular-progress-bar__title_5bj3o {
97
+ } .circular-progress-bar__size-128_1cf8i .circular-progress-bar__title_1cf8i {
95
98
  max-height: 32px;
96
- } .circular-progress-bar__size-80_5bj3o {
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-80_5bj3o .circular-progress-bar__labelWrapper_5bj3o {
109
+ } .circular-progress-bar__size-80_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
100
110
  max-width: 64px;
101
- } .circular-progress-bar__size-80_5bj3o .circular-progress-bar__title_5bj3o {
111
+ } .circular-progress-bar__size-80_1cf8i .circular-progress-bar__title_1cf8i {
102
112
  max-height: 24px;
103
- } .circular-progress-bar__size-64_5bj3o {
113
+ } .circular-progress-bar__size-64_1cf8i {
104
114
  width: 64px;
105
115
  height: 64px
106
- } .circular-progress-bar__size-64_5bj3o .circular-progress-bar__labelWrapper_5bj3o {
116
+ } .circular-progress-bar__size-64_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
107
117
  max-width: 48px;
108
- } .circular-progress-bar__size-64_5bj3o .circular-progress-bar__title_5bj3o {
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-48_5bj3o {
121
+ } .circular-progress-bar__size-48_1cf8i {
112
122
  width: 48px;
113
123
  height: 48px
114
- } .circular-progress-bar__size-48_5bj3o .circular-progress-bar__labelWrapper_5bj3o {
124
+ } .circular-progress-bar__size-48_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
115
125
  max-width: 40px;
116
- } .circular-progress-bar__size-48_5bj3o .circular-progress-bar__title_5bj3o {
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-24_5bj3o {
129
+ } .circular-progress-bar__size-24_1cf8i {
120
130
  width: 24px;
121
131
  height: 24px
122
- } .circular-progress-bar__size-24_5bj3o .circular-progress-bar__labelWrapper_5bj3o {
132
+ } .circular-progress-bar__size-24_1cf8i .circular-progress-bar__labelWrapper_1cf8i {
123
133
  max-width: 24px;
124
- } .circular-progress-bar__backgroundCircle_5bj3o,
125
- .circular-progress-bar__progressCircle_5bj3o {
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-bar__positive_5bj3o {
139
+ } .circular-progress-bar__positive_1cf8i {
130
140
  stroke: var(--circular-progress-bar-positive-color);
131
- } .circular-progress-bar__negative_5bj3o {
141
+ } .circular-progress-bar__negative_1cf8i {
132
142
  stroke: var(--circular-progress-bar-negative-color);
133
- } .circular-progress-bar__backgroundCircle_5bj3o {
143
+ } .circular-progress-bar__backgroundCircle_1cf8i {
134
144
  stroke: var(--circular-progress-bar-stroke-color)
135
- } .circular-progress-bar__backgroundCircle_5bj3o.circular-progress-bar__stroke_5bj3o {
145
+ } .circular-progress-bar__backgroundCircle_1cf8i.circular-progress-bar__stroke_1cf8i {
136
146
  stroke: transparent;
137
- } .circular-progress-bar__progressCircle_5bj3o {
147
+ } .circular-progress-bar__progressCircle_1cf8i {
138
148
  stroke-linecap: round;
139
- } .circular-progress-bar__iconWrapper_5bj3o {
149
+ } .circular-progress-bar__iconWrapper_1cf8i {
140
150
  display: flex;
141
151
  align-items: center;
142
152
  justify-content: center
143
- } .circular-progress-bar__iconWrapper_5bj3o.circular-progress-bar__size-144_5bj3o {
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-bar__iconWrapper_5bj3o.circular-progress-bar__size-128_5bj3o {
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-bar__iconWrapper_5bj3o.circular-progress-bar__size-80_5bj3o {
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-bar__iconWrapper_5bj3o.circular-progress-bar__size-64_5bj3o {
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-bar__iconWrapper_5bj3o.circular-progress-bar__size-48_5bj3o {
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-bar__iconWrapper_5bj3o.circular-progress-bar__size-24_5bj3o {
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-bar__iconWrapper_5bj3o.circular-progress-bar__icon-tertiary_5bj3o {
174
+ } .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-tertiary_1cf8i {
162
175
  color: var(--color-light-neutral-500);
163
- } .circular-progress-bar__iconWrapper_5bj3o.circular-progress-bar__icon-positive_5bj3o {
176
+ } .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-positive_1cf8i {
164
177
  color: var(--color-light-status-positive);
165
- } .circular-progress-bar__iconWrapper_5bj3o.circular-progress-bar__icon-negative_5bj3o {
178
+ } .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-negative_1cf8i {
166
179
  color: var(--color-light-status-negative);
167
- } .circular-progress-bar__iconWrapper_5bj3o.circular-progress-bar__icon-primary-inverted_5bj3o {
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-bar__iconWrapper_5bj3o.circular-progress-bar__icon-primary_5bj3o {
182
+ } .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-primary_1cf8i {
170
183
  color: var(--color-light-neutral-translucent-1300);
171
- } .circular-progress-bar__iconWrapper_5bj3o.circular-progress-bar__icon-secondary_5bj3o {
184
+ } .circular-progress-bar__iconWrapper_1cf8i.circular-progress-bar__icon-secondary_1cf8i {
172
185
  color: var(--color-light-neutral-700);
173
- } .circular-progress-bar__icon_5bj3o {
186
+ } .circular-progress-bar__icon_1cf8i {
174
187
  width: 100%;
175
188
  height: 100%;
176
189
  }
package/esm/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./Component";
2
+ export * from "./types/typography-color";
@@ -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,2 @@
1
+ type ComponentSize = 'xxl' | 'xl' | 'l' | 'm' | 's' | 'xs' | 24 | 48 | 64 | 80 | 128 | 144;
2
+ export { ComponentSize };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ type TypographyColor = 'primary' | 'secondary' | 'tertiary' | 'positive' | 'negative';
2
+ export { TypographyColor };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ declare function useTimer(time: number, active: boolean | undefined, counting: 'forward' | 'backward', interval?: number, step?: number): [value: number, title: string];
2
+ export { useTimer };
@@ -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 };
@@ -0,0 +1,8 @@
1
+ declare function getCircularProgressBarTestIds(dataTestId: string): {
2
+ progressBar: string;
3
+ title: string;
4
+ subtitle: string;
5
+ circleProgressBar: string;
6
+ circleProgressValue: string;
7
+ };
8
+ export { getCircularProgressBarTestIds };