@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,13 @@
1
+ import { getDataTestId } from '@alfalab/core-components-shared/esm';
2
+
3
+ function getCircularProgressBarTestIds(dataTestId) {
4
+ return {
5
+ progressBar: dataTestId,
6
+ title: getDataTestId(dataTestId, 'title'),
7
+ subtitle: getDataTestId(dataTestId, 'subtitle'),
8
+ circleProgressBar: getDataTestId(dataTestId, 'circle-progress-bar'),
9
+ circleProgressValue: getDataTestId(dataTestId, 'circle-progress-value'),
10
+ };
11
+ }
12
+
13
+ export { 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,7 @@
1
+ import { TYPOGRAPHY_COLOR } from '../consts.js';
2
+
3
+ var isTypographyColor = function (color) {
4
+ return TYPOGRAPHY_COLOR.includes(color);
5
+ };
6
+
7
+ export { isTypographyColor };
package/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/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./Component";
2
+ export * from "./types/typography-color";
@@ -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 };
@@ -1,15 +1,32 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import cn from 'classnames';
3
+ import { isObject, getDataTestId } from '@alfalab/core-components-shared/modern';
3
4
  import { Text, TitleMobile } from '@alfalab/core-components-typography/modern';
4
- import { STROKE, SIZES, TYPOGRAPHY_COLOR, SIZE_TO_CLASSNAME_MAP, VIEW_TITLE, VIEW_TEXT } from './consts.js';
5
+ import { isTypographyColor } from './utils/is-typography-color.js';
6
+ 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';
7
+ import { useTimer } from './use-timer.js';
5
8
 
6
- const 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"};
9
+ const 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"};
7
10
  require('./index.css')
8
11
 
12
+ /* eslint-disable complexity */
9
13
  /**
10
14
  * Компонент круглого прогресс бара.
11
15
  */
12
- const CircularProgressBar = ({ value, view = 'positive', size = 64, className, dataTestId, title = value ? value.toString() : '0', titleComplete, subtitle, contentColor = 'secondary', subtitleComplete, stroke = true, fillComplete, icon: Icon, iconComplete: IconComplete, completeTextColor, completeIconColor = 'tertiary', direction = 'clockwise', height, children, progressStrokeColor, circleColor, strokeColor, }) => {
16
+ const CircularProgressBar = ({ value: valueFromProps, view = 'positive', size = 64, className, dataTestId, title: titleFromProps = isObject(valueFromProps) ? null : `${valueFromProps}`, titleComplete, subtitle, contentColor = 'secondary', subtitleComplete, stroke = true, fillComplete, icon: Icon, iconComplete: IconComplete, completeTextColor, completeIconColor = 'tertiary', direction = 'clockwise', height, children, progressStrokeColor, circleColor, strokeColor, directionType = 'asc', titleColor, subtitleColor, }) => {
17
+ const isTimer = isObject(valueFromProps);
18
+ const [timerValue, timerTitle] = useTimer(isTimer ? Math.min(Math.max(valueFromProps.timer, MIN_TIMER_VALUE), MAX_TIMER_VALUE) : -1, isTimer, isTimer ? valueFromProps.counting ?? 'backward' : 'backward');
19
+ let value;
20
+ let title;
21
+ if (isTimer) {
22
+ value = timerValue;
23
+ title = timerTitle;
24
+ }
25
+ else {
26
+ value = valueFromProps;
27
+ title = titleFromProps;
28
+ }
29
+ value = directionType === 'desc' ? MAX_PROGRESS_VALUE - value : value;
13
30
  const memorized = useMemo(() => {
14
31
  const strokeWidth = STROKE[size];
15
32
  const maxProgress = 100;
@@ -30,7 +47,7 @@ const CircularProgressBar = ({ value, view = 'positive', size = 64, className, d
30
47
  strokeDasharray,
31
48
  strokeDashoffset,
32
49
  };
33
- }, [value, size]);
50
+ }, [size, value]);
34
51
  const isComplete = value === 100;
35
52
  const isCompleteTextColor = isComplete && completeTextColor;
36
53
  const titleContent = titleComplete && isComplete ? titleComplete : title;
@@ -39,14 +56,34 @@ const CircularProgressBar = ({ value, view = 'positive', size = 64, className, d
39
56
  const typographyContentColor = TYPOGRAPHY_COLOR.includes(contentColor)
40
57
  ? contentColor
41
58
  : undefined;
42
- const renderTitleString = () => 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: {
43
- ...(!typographyContentColor && { color: contentColor }),
44
- } }, titleContent)) : (React.createElement(Text, { className: styles.title, color: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', weight: 'bold', view: VIEW_TEXT[size], style: {
59
+ const getTextColor = (color) => {
60
+ if (isCompleteTextColor) {
61
+ return completeTextColor;
62
+ }
63
+ if (color) {
64
+ return isTypographyColor(color) ? color : undefined;
65
+ }
66
+ return typographyContentColor;
67
+ };
68
+ const getTextStyleColor = (color) => {
69
+ if (color) {
70
+ if (!isTypographyColor(color)) {
71
+ return { color };
72
+ }
73
+ return {};
74
+ }
75
+ return {
45
76
  ...(!typographyContentColor && { color: contentColor }),
46
- } }, titleContent));
77
+ };
78
+ };
79
+ const renderTitleString = () => SIZES[size] > 64 ? (React.createElement(TitleMobile, { className: cn(styles.typography, styles.title), color: getTextColor(titleColor), tag: 'div', font: 'system', view: VIEW_TITLE[size], style: {
80
+ ...getTextStyleColor(titleColor),
81
+ }, dataTestId: getDataTestId(dataTestId, 'title') }, titleContent)) : (React.createElement(Text, { className: styles.title, color: getTextColor(titleColor), tag: 'div', weight: 'bold', view: VIEW_TEXT[size], style: {
82
+ ...getTextStyleColor(titleColor),
83
+ }, dataTestId: getDataTestId(dataTestId, 'title') }, titleContent));
47
84
  const renderTitle = () => (typeof title === 'string' ? renderTitleString() : titleContent);
48
- const renderSubTitle = () => typeof subtitle === 'string' ? (React.createElement(Text, { tag: 'div', className: styles.subtitle, color: isCompleteTextColor ? completeTextColor : typographyContentColor, view: 'primary-small', style: {
49
- ...(!typographyContentColor && { color: contentColor }),
85
+ const renderSubTitle = () => typeof subtitle === 'string' ? (React.createElement(Text, { tag: 'div', className: styles.subtitle, color: getTextColor(subtitleColor), view: 'primary-small', dataTestId: getDataTestId(dataTestId, 'subtitle'), style: {
86
+ ...getTextStyleColor(subtitleColor),
50
87
  } }, subtitleContent)) : (subtitleContent);
51
88
  const renderIcon = () => (React.createElement("span", { className: cn(styles.iconWrapper, styles[SIZE_TO_CLASSNAME_MAP[size]], styles.tertiary, styles[`icon-${contentColor}`], {
52
89
  [styles[`icon-${completeIconColor}`]]: completeIconColor,
@@ -65,12 +102,12 @@ const CircularProgressBar = ({ value, view = 'positive', size = 64, className, d
65
102
  [styles.stroke]: !stroke,
66
103
  }), style: {
67
104
  ...(strokeColor && stroke && { stroke: strokeColor }),
68
- }, cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size] }),
105
+ }, cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], "data-test-id": getDataTestId(dataTestId, 'circle-progress-bar') }),
69
106
  React.createElement("circle", { className: cn(styles.progressCircle, styles[view], styles[SIZE_TO_CLASSNAME_MAP[size]]), style: {
70
107
  ...(progressStrokeColor && { stroke: progressStrokeColor }),
71
108
  }, cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
72
109
  ? -memorized.strokeDashoffset
73
- : memorized.strokeDashoffset, transform: `rotate(${-90} ${memorized.center} ${memorized.center})` })),
110
+ : memorized.strokeDashoffset, transform: `rotate(${-90} ${memorized.center} ${memorized.center})`, "data-test-id": getDataTestId(dataTestId, 'circle-progress-value') })),
74
111
  React.createElement("div", { className: cn(styles.labelWrapper, {
75
112
  [styles.label]: Icon || IconComplete,
76
113
  }) }, children || renderContent())));
@@ -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/modern/consts.js CHANGED
@@ -9,6 +9,7 @@ const 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 @@ const 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 @@ const 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 @@ const 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 @@ const 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
+ const MAX_PROGRESS_VALUE = 100;
78
+ const MIN_TIMER_VALUE = 0;
79
+ const 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 };