@alfalab/core-components-circular-progress-bar 3.1.1 → 3.3.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/Component.d.ts +16 -3
- package/Component.js +20 -48
- package/consts.d.ts +34 -0
- package/consts.js +43 -0
- package/cssm/Component.d.ts +16 -3
- package/cssm/Component.js +19 -47
- package/cssm/consts.d.ts +34 -0
- package/cssm/consts.js +43 -0
- package/cssm/index.js +1 -0
- package/cssm/index.module.css +9 -7
- package/esm/Component.d.ts +16 -3
- package/esm/Component.js +15 -43
- package/esm/consts.d.ts +34 -0
- package/esm/consts.js +35 -0
- package/esm/index.css +54 -52
- package/esm/index.js +1 -0
- package/index.css +54 -52
- package/index.js +1 -0
- package/modern/Component.d.ts +16 -3
- package/modern/Component.js +24 -41
- package/modern/consts.d.ts +34 -0
- package/modern/consts.js +35 -0
- package/modern/index.css +54 -52
- package/modern/index.js +1 -0
- package/package.json +1 -1
- package/src/Component.tsx +49 -44
- package/src/consts.ts +37 -0
- package/src/index.module.css +9 -8
package/Component.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
5
|
type CircularProgressBarProps = {
|
|
5
6
|
/**
|
|
6
7
|
* Уровень прогресса, %
|
|
@@ -17,7 +18,7 @@ type CircularProgressBarProps = {
|
|
|
17
18
|
/**
|
|
18
19
|
* Цвет контента
|
|
19
20
|
*/
|
|
20
|
-
contentColor?:
|
|
21
|
+
contentColor?: TypographyColor | string;
|
|
21
22
|
/**
|
|
22
23
|
* Дополнительный текст
|
|
23
24
|
*/
|
|
@@ -86,12 +87,24 @@ type CircularProgressBarProps = {
|
|
|
86
87
|
*/
|
|
87
88
|
dataTestId?: string;
|
|
88
89
|
/**
|
|
89
|
-
* Дочерние
|
|
90
|
+
* Дочерние элементы
|
|
90
91
|
*/
|
|
91
92
|
children?: ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Цвет прогресса
|
|
95
|
+
*/
|
|
96
|
+
progressStrokeColor?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Цвет заливки внутри круга
|
|
99
|
+
*/
|
|
100
|
+
circleColor?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Цвет желоба
|
|
103
|
+
*/
|
|
104
|
+
strokeColor?: string;
|
|
92
105
|
};
|
|
93
106
|
/**
|
|
94
107
|
* Компонент круглого прогресс бара.
|
|
95
108
|
*/
|
|
96
109
|
declare const CircularProgressBar: React.FC<CircularProgressBarProps>;
|
|
97
|
-
export { CircularProgressBarProps, CircularProgressBar };
|
|
110
|
+
export { TypographyColor, CircularProgressBarProps, CircularProgressBar };
|
package/Component.js
CHANGED
|
@@ -6,59 +6,28 @@ var tslib = require('tslib');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var cn = require('classnames');
|
|
8
8
|
var coreComponentsTypography = require('@alfalab/core-components-typography');
|
|
9
|
+
var consts = require('./consts.js');
|
|
9
10
|
|
|
10
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
12
|
|
|
12
13
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
13
14
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
14
15
|
|
|
15
|
-
var styles = {"component":"circular-progress-
|
|
16
|
+
var styles = {"component":"circular-progress-bar__component_5iq0y","bg-positive":"circular-progress-bar__bg-positive_5iq0y","bg-negative":"circular-progress-bar__bg-negative_5iq0y","svg":"circular-progress-bar__svg_5iq0y","title":"circular-progress-bar__title_5iq0y","subtitle":"circular-progress-bar__subtitle_5iq0y","labelWrapper":"circular-progress-bar__labelWrapper_5iq0y","label":"circular-progress-bar__label_5iq0y","typography":"circular-progress-bar__typography_5iq0y","xxl":"circular-progress-bar__xxl_5iq0y","xl":"circular-progress-bar__xl_5iq0y","l":"circular-progress-bar__l_5iq0y","m":"circular-progress-bar__m_5iq0y","s":"circular-progress-bar__s_5iq0y","xs":"circular-progress-bar__xs_5iq0y","backgroundCircle":"circular-progress-bar__backgroundCircle_5iq0y","progressCircle":"circular-progress-bar__progressCircle_5iq0y","positive":"circular-progress-bar__positive_5iq0y","negative":"circular-progress-bar__negative_5iq0y","stroke":"circular-progress-bar__stroke_5iq0y","iconWrapper":"circular-progress-bar__iconWrapper_5iq0y","icon-tertiary":"circular-progress-bar__icon-tertiary_5iq0y","icon-positive":"circular-progress-bar__icon-positive_5iq0y","icon-negative":"circular-progress-bar__icon-negative_5iq0y","icon-primary-inverted":"circular-progress-bar__icon-primary-inverted_5iq0y","icon-primary":"circular-progress-bar__icon-primary_5iq0y","icon-secondary":"circular-progress-bar__icon-secondary_5iq0y","icon":"circular-progress-bar__icon_5iq0y"};
|
|
16
17
|
require('./index.css')
|
|
17
18
|
|
|
18
|
-
var SIZES = {
|
|
19
|
-
xs: 24,
|
|
20
|
-
s: 48,
|
|
21
|
-
m: 64,
|
|
22
|
-
l: 80,
|
|
23
|
-
xl: 128,
|
|
24
|
-
xxl: 144,
|
|
25
|
-
};
|
|
26
|
-
var STROKE = {
|
|
27
|
-
xs: 4,
|
|
28
|
-
s: 4,
|
|
29
|
-
m: 6,
|
|
30
|
-
l: 8,
|
|
31
|
-
xl: 10,
|
|
32
|
-
xxl: 12,
|
|
33
|
-
};
|
|
34
|
-
var VIEW_TITLE = {
|
|
35
|
-
xs: 'small',
|
|
36
|
-
s: 'small',
|
|
37
|
-
m: 'small',
|
|
38
|
-
l: 'xsmall',
|
|
39
|
-
xl: 'medium',
|
|
40
|
-
xxl: 'medium',
|
|
41
|
-
};
|
|
42
|
-
var VIEW_TEXT = {
|
|
43
|
-
xs: 'secondary-small',
|
|
44
|
-
s: 'secondary-small',
|
|
45
|
-
m: 'secondary-large',
|
|
46
|
-
l: 'secondary-large',
|
|
47
|
-
xl: 'secondary-large',
|
|
48
|
-
xxl: 'secondary-large',
|
|
49
|
-
};
|
|
50
19
|
/**
|
|
51
20
|
* Компонент круглого прогресс бара.
|
|
52
21
|
*/
|
|
53
22
|
var CircularProgressBar = function (_a) {
|
|
54
23
|
var _b, _c, _d;
|
|
55
|
-
var value = _a.value, _e = _a.view, view = _e === void 0 ? 'positive' : _e, _f = _a.size, size = _f === void 0 ? 'm' : _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;
|
|
24
|
+
var value = _a.value, _e = _a.view, view = _e === void 0 ? 'positive' : _e, _f = _a.size, size = _f === void 0 ? 'm' : _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;
|
|
56
25
|
var memorized = React.useMemo(function () {
|
|
57
|
-
var strokeWidth = STROKE[size];
|
|
26
|
+
var strokeWidth = consts.STROKE[size];
|
|
58
27
|
var maxProgress = 100;
|
|
59
28
|
var minProgress = 0;
|
|
60
|
-
var widthSVG = SIZES[size];
|
|
61
|
-
var heightSVG = SIZES[size];
|
|
29
|
+
var widthSVG = consts.SIZES[size];
|
|
30
|
+
var heightSVG = consts.SIZES[size];
|
|
62
31
|
var center = widthSVG / 2;
|
|
63
32
|
var radius = center - strokeWidth / 2;
|
|
64
33
|
var circumference = Math.PI * radius * 2;
|
|
@@ -79,12 +48,15 @@ var CircularProgressBar = function (_a) {
|
|
|
79
48
|
var titleContent = titleComplete && isComplete ? titleComplete : title;
|
|
80
49
|
var subtitleContent = subtitleComplete && isComplete ? subtitleComplete : subtitle;
|
|
81
50
|
var IconComponent = IconComplete && isComplete ? IconComplete : Icon;
|
|
51
|
+
var typographyContentColor = consts.TYPOGRAPHY_COLOR.includes(contentColor)
|
|
52
|
+
? contentColor
|
|
53
|
+
: undefined;
|
|
82
54
|
var renderTitleString = function () {
|
|
83
|
-
return SIZES[size] > 64 ? (React__default.default.createElement(coreComponentsTypography.Typography.TitleMobile, { className: cn__default.default(styles.typography, styles.title), color: isCompleteTextColor ? completeTextColor :
|
|
55
|
+
return consts.SIZES[size] > 64 ? (React__default.default.createElement(coreComponentsTypography.Typography.TitleMobile, { className: cn__default.default(styles.typography, styles.title), color: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', font: 'system', view: consts.VIEW_TITLE[size], style: tslib.__assign({}, (!typographyContentColor && { color: contentColor })) }, titleContent)) : (React__default.default.createElement(coreComponentsTypography.Typography.Text, { className: styles.title, color: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', weight: 'bold', view: consts.VIEW_TEXT[size], style: tslib.__assign({}, (!typographyContentColor && { color: contentColor })) }, titleContent));
|
|
84
56
|
};
|
|
85
57
|
var renderTitle = function () { return (typeof title === 'string' ? renderTitleString() : titleContent); };
|
|
86
58
|
var renderSubTitle = function () {
|
|
87
|
-
return typeof subtitle === 'string' ? (React__default.default.createElement(coreComponentsTypography.Typography.Text, { tag: 'div', className: styles.subtitle, color: isCompleteTextColor ? completeTextColor :
|
|
59
|
+
return typeof subtitle === 'string' ? (React__default.default.createElement(coreComponentsTypography.Typography.Text, { tag: 'div', className: styles.subtitle, color: isCompleteTextColor ? completeTextColor : typographyContentColor, view: 'primary-small', style: tslib.__assign({}, (!typographyContentColor && { color: contentColor })) }, subtitleContent)) : (subtitleContent);
|
|
88
60
|
};
|
|
89
61
|
var renderIcon = function () {
|
|
90
62
|
var _a;
|
|
@@ -94,17 +66,17 @@ var CircularProgressBar = function (_a) {
|
|
|
94
66
|
};
|
|
95
67
|
var renderContent = function () {
|
|
96
68
|
return Icon || (IconComplete && isComplete) ? (renderIcon()) : (React__default.default.createElement(React__default.default.Fragment, null,
|
|
97
|
-
SIZES[size] > 24 && renderTitle(),
|
|
98
|
-
SIZES[size] > 64 && renderSubTitle()));
|
|
69
|
+
consts.SIZES[size] > 24 && renderTitle(),
|
|
70
|
+
consts.SIZES[size] > 64 && renderSubTitle()));
|
|
99
71
|
};
|
|
100
|
-
return (React__default.default.createElement("div", { className: cn__default.default(styles.component, styles[size], className
|
|
72
|
+
return (React__default.default.createElement("div", { className: cn__default.default(styles.component, styles[size], className, (_b = {},
|
|
73
|
+
_b[styles["bg-".concat(view)]] = fillComplete && isComplete,
|
|
74
|
+
_b)), style: tslib.__assign(tslib.__assign({}, (height && { height: height, width: height })), (circleColor && { backgroundColor: circleColor })), "data-test-id": dataTestId },
|
|
101
75
|
React__default.default.createElement("svg", { viewBox: "0 0 ".concat(memorized.widthSVG, " ").concat(memorized.heightSVG), className: styles.svg, xmlns: 'http://www.w3.org/2000/svg' },
|
|
102
|
-
React__default.default.createElement("circle", { className: cn__default.default(styles.backgroundCircle, styles[size], (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
React__default.default.createElement("circle", { className: cn__default.default(styles.progressCircle, styles[view], styles[size], (
|
|
106
|
-
_c[styles["bg-".concat(view)]] = fillComplete && isComplete,
|
|
107
|
-
_c)), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
|
|
76
|
+
React__default.default.createElement("circle", { className: cn__default.default(styles.backgroundCircle, styles[size], (_c = {},
|
|
77
|
+
_c[styles.stroke] = !stroke,
|
|
78
|
+
_c)), style: tslib.__assign({}, (strokeColor && stroke && { stroke: strokeColor })), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: consts.STROKE[size] }),
|
|
79
|
+
React__default.default.createElement("circle", { className: cn__default.default(styles.progressCircle, styles[view], styles[size]), style: tslib.__assign({}, (progressStrokeColor && { stroke: progressStrokeColor })), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: consts.STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
|
|
108
80
|
? -memorized.strokeDashoffset
|
|
109
81
|
: memorized.strokeDashoffset, transform: "rotate(".concat(-90, " ").concat(memorized.center, " ").concat(memorized.center, ")") })),
|
|
110
82
|
React__default.default.createElement("div", { className: cn__default.default(styles.labelWrapper, (_d = {},
|
package/consts.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const SIZES: {
|
|
2
|
+
xs: number;
|
|
3
|
+
s: number;
|
|
4
|
+
m: number;
|
|
5
|
+
l: number;
|
|
6
|
+
xl: number;
|
|
7
|
+
xxl: number;
|
|
8
|
+
};
|
|
9
|
+
declare const STROKE: {
|
|
10
|
+
xs: number;
|
|
11
|
+
s: number;
|
|
12
|
+
m: number;
|
|
13
|
+
l: number;
|
|
14
|
+
xl: number;
|
|
15
|
+
xxl: number;
|
|
16
|
+
};
|
|
17
|
+
declare const VIEW_TITLE: {
|
|
18
|
+
readonly xs: "small";
|
|
19
|
+
readonly s: "small";
|
|
20
|
+
readonly m: "small";
|
|
21
|
+
readonly l: "xsmall";
|
|
22
|
+
readonly xl: "medium";
|
|
23
|
+
readonly xxl: "medium";
|
|
24
|
+
};
|
|
25
|
+
declare const VIEW_TEXT: {
|
|
26
|
+
readonly xs: "secondary-small";
|
|
27
|
+
readonly s: "secondary-small";
|
|
28
|
+
readonly m: "secondary-large";
|
|
29
|
+
readonly l: "secondary-large";
|
|
30
|
+
readonly xl: "secondary-large";
|
|
31
|
+
readonly xxl: "secondary-large";
|
|
32
|
+
};
|
|
33
|
+
declare const TYPOGRAPHY_COLOR: string[];
|
|
34
|
+
export { SIZES, STROKE, VIEW_TITLE, VIEW_TEXT, TYPOGRAPHY_COLOR };
|
package/consts.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var SIZES = {
|
|
6
|
+
xs: 24,
|
|
7
|
+
s: 48,
|
|
8
|
+
m: 64,
|
|
9
|
+
l: 80,
|
|
10
|
+
xl: 128,
|
|
11
|
+
xxl: 144,
|
|
12
|
+
};
|
|
13
|
+
var STROKE = {
|
|
14
|
+
xs: 4,
|
|
15
|
+
s: 4,
|
|
16
|
+
m: 6,
|
|
17
|
+
l: 8,
|
|
18
|
+
xl: 10,
|
|
19
|
+
xxl: 12,
|
|
20
|
+
};
|
|
21
|
+
var VIEW_TITLE = {
|
|
22
|
+
xs: 'small',
|
|
23
|
+
s: 'small',
|
|
24
|
+
m: 'small',
|
|
25
|
+
l: 'xsmall',
|
|
26
|
+
xl: 'medium',
|
|
27
|
+
xxl: 'medium',
|
|
28
|
+
};
|
|
29
|
+
var VIEW_TEXT = {
|
|
30
|
+
xs: 'secondary-small',
|
|
31
|
+
s: 'secondary-small',
|
|
32
|
+
m: 'secondary-large',
|
|
33
|
+
l: 'secondary-large',
|
|
34
|
+
xl: 'secondary-large',
|
|
35
|
+
xxl: 'secondary-large',
|
|
36
|
+
};
|
|
37
|
+
var TYPOGRAPHY_COLOR = ['primary', 'secondary', 'tertiary', 'positive', 'negative'];
|
|
38
|
+
|
|
39
|
+
exports.SIZES = SIZES;
|
|
40
|
+
exports.STROKE = STROKE;
|
|
41
|
+
exports.TYPOGRAPHY_COLOR = TYPOGRAPHY_COLOR;
|
|
42
|
+
exports.VIEW_TEXT = VIEW_TEXT;
|
|
43
|
+
exports.VIEW_TITLE = VIEW_TITLE;
|
package/cssm/Component.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
5
|
type CircularProgressBarProps = {
|
|
5
6
|
/**
|
|
6
7
|
* Уровень прогресса, %
|
|
@@ -17,7 +18,7 @@ type CircularProgressBarProps = {
|
|
|
17
18
|
/**
|
|
18
19
|
* Цвет контента
|
|
19
20
|
*/
|
|
20
|
-
contentColor?:
|
|
21
|
+
contentColor?: TypographyColor | string;
|
|
21
22
|
/**
|
|
22
23
|
* Дополнительный текст
|
|
23
24
|
*/
|
|
@@ -86,12 +87,24 @@ type CircularProgressBarProps = {
|
|
|
86
87
|
*/
|
|
87
88
|
dataTestId?: string;
|
|
88
89
|
/**
|
|
89
|
-
* Дочерние
|
|
90
|
+
* Дочерние элементы
|
|
90
91
|
*/
|
|
91
92
|
children?: ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Цвет прогресса
|
|
95
|
+
*/
|
|
96
|
+
progressStrokeColor?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Цвет заливки внутри круга
|
|
99
|
+
*/
|
|
100
|
+
circleColor?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Цвет желоба
|
|
103
|
+
*/
|
|
104
|
+
strokeColor?: string;
|
|
92
105
|
};
|
|
93
106
|
/**
|
|
94
107
|
* Компонент круглого прогресс бара.
|
|
95
108
|
*/
|
|
96
109
|
declare const CircularProgressBar: React.FC<CircularProgressBarProps>;
|
|
97
|
-
export { CircularProgressBarProps, CircularProgressBar };
|
|
110
|
+
export { TypographyColor, CircularProgressBarProps, CircularProgressBar };
|
package/cssm/Component.js
CHANGED
|
@@ -6,6 +6,7 @@ var tslib = require('tslib');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var cn = require('classnames');
|
|
8
8
|
var coreComponentsTypography = require('@alfalab/core-components-typography/cssm');
|
|
9
|
+
var consts = require('./consts.js');
|
|
9
10
|
var styles = require('./index.module.css');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -14,50 +15,18 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
14
15
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
15
16
|
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
16
17
|
|
|
17
|
-
var SIZES = {
|
|
18
|
-
xs: 24,
|
|
19
|
-
s: 48,
|
|
20
|
-
m: 64,
|
|
21
|
-
l: 80,
|
|
22
|
-
xl: 128,
|
|
23
|
-
xxl: 144,
|
|
24
|
-
};
|
|
25
|
-
var STROKE = {
|
|
26
|
-
xs: 4,
|
|
27
|
-
s: 4,
|
|
28
|
-
m: 6,
|
|
29
|
-
l: 8,
|
|
30
|
-
xl: 10,
|
|
31
|
-
xxl: 12,
|
|
32
|
-
};
|
|
33
|
-
var VIEW_TITLE = {
|
|
34
|
-
xs: 'small',
|
|
35
|
-
s: 'small',
|
|
36
|
-
m: 'small',
|
|
37
|
-
l: 'xsmall',
|
|
38
|
-
xl: 'medium',
|
|
39
|
-
xxl: 'medium',
|
|
40
|
-
};
|
|
41
|
-
var VIEW_TEXT = {
|
|
42
|
-
xs: 'secondary-small',
|
|
43
|
-
s: 'secondary-small',
|
|
44
|
-
m: 'secondary-large',
|
|
45
|
-
l: 'secondary-large',
|
|
46
|
-
xl: 'secondary-large',
|
|
47
|
-
xxl: 'secondary-large',
|
|
48
|
-
};
|
|
49
18
|
/**
|
|
50
19
|
* Компонент круглого прогресс бара.
|
|
51
20
|
*/
|
|
52
21
|
var CircularProgressBar = function (_a) {
|
|
53
22
|
var _b, _c, _d;
|
|
54
|
-
var value = _a.value, _e = _a.view, view = _e === void 0 ? 'positive' : _e, _f = _a.size, size = _f === void 0 ? 'm' : _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;
|
|
23
|
+
var value = _a.value, _e = _a.view, view = _e === void 0 ? 'positive' : _e, _f = _a.size, size = _f === void 0 ? 'm' : _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;
|
|
55
24
|
var memorized = React.useMemo(function () {
|
|
56
|
-
var strokeWidth = STROKE[size];
|
|
25
|
+
var strokeWidth = consts.STROKE[size];
|
|
57
26
|
var maxProgress = 100;
|
|
58
27
|
var minProgress = 0;
|
|
59
|
-
var widthSVG = SIZES[size];
|
|
60
|
-
var heightSVG = SIZES[size];
|
|
28
|
+
var widthSVG = consts.SIZES[size];
|
|
29
|
+
var heightSVG = consts.SIZES[size];
|
|
61
30
|
var center = widthSVG / 2;
|
|
62
31
|
var radius = center - strokeWidth / 2;
|
|
63
32
|
var circumference = Math.PI * radius * 2;
|
|
@@ -78,12 +47,15 @@ var CircularProgressBar = function (_a) {
|
|
|
78
47
|
var titleContent = titleComplete && isComplete ? titleComplete : title;
|
|
79
48
|
var subtitleContent = subtitleComplete && isComplete ? subtitleComplete : subtitle;
|
|
80
49
|
var IconComponent = IconComplete && isComplete ? IconComplete : Icon;
|
|
50
|
+
var typographyContentColor = consts.TYPOGRAPHY_COLOR.includes(contentColor)
|
|
51
|
+
? contentColor
|
|
52
|
+
: undefined;
|
|
81
53
|
var renderTitleString = function () {
|
|
82
|
-
return SIZES[size] > 64 ? (React__default.default.createElement(coreComponentsTypography.Typography.TitleMobile, { className: cn__default.default(styles__default.default.typography, styles__default.default.title), color: isCompleteTextColor ? completeTextColor :
|
|
54
|
+
return consts.SIZES[size] > 64 ? (React__default.default.createElement(coreComponentsTypography.Typography.TitleMobile, { className: cn__default.default(styles__default.default.typography, styles__default.default.title), color: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', font: 'system', view: consts.VIEW_TITLE[size], style: tslib.__assign({}, (!typographyContentColor && { color: contentColor })) }, titleContent)) : (React__default.default.createElement(coreComponentsTypography.Typography.Text, { className: styles__default.default.title, color: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', weight: 'bold', view: consts.VIEW_TEXT[size], style: tslib.__assign({}, (!typographyContentColor && { color: contentColor })) }, titleContent));
|
|
83
55
|
};
|
|
84
56
|
var renderTitle = function () { return (typeof title === 'string' ? renderTitleString() : titleContent); };
|
|
85
57
|
var renderSubTitle = function () {
|
|
86
|
-
return typeof subtitle === 'string' ? (React__default.default.createElement(coreComponentsTypography.Typography.Text, { tag: 'div', className: styles__default.default.subtitle, color: isCompleteTextColor ? completeTextColor :
|
|
58
|
+
return typeof subtitle === 'string' ? (React__default.default.createElement(coreComponentsTypography.Typography.Text, { tag: 'div', className: styles__default.default.subtitle, color: isCompleteTextColor ? completeTextColor : typographyContentColor, view: 'primary-small', style: tslib.__assign({}, (!typographyContentColor && { color: contentColor })) }, subtitleContent)) : (subtitleContent);
|
|
87
59
|
};
|
|
88
60
|
var renderIcon = function () {
|
|
89
61
|
var _a;
|
|
@@ -93,17 +65,17 @@ var CircularProgressBar = function (_a) {
|
|
|
93
65
|
};
|
|
94
66
|
var renderContent = function () {
|
|
95
67
|
return Icon || (IconComplete && isComplete) ? (renderIcon()) : (React__default.default.createElement(React__default.default.Fragment, null,
|
|
96
|
-
SIZES[size] > 24 && renderTitle(),
|
|
97
|
-
SIZES[size] > 64 && renderSubTitle()));
|
|
68
|
+
consts.SIZES[size] > 24 && renderTitle(),
|
|
69
|
+
consts.SIZES[size] > 64 && renderSubTitle()));
|
|
98
70
|
};
|
|
99
|
-
return (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.component, styles__default.default[size], className
|
|
71
|
+
return (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.component, styles__default.default[size], className, (_b = {},
|
|
72
|
+
_b[styles__default.default["bg-".concat(view)]] = fillComplete && isComplete,
|
|
73
|
+
_b)), style: tslib.__assign(tslib.__assign({}, (height && { height: height, width: height })), (circleColor && { backgroundColor: circleColor })), "data-test-id": dataTestId },
|
|
100
74
|
React__default.default.createElement("svg", { viewBox: "0 0 ".concat(memorized.widthSVG, " ").concat(memorized.heightSVG), className: styles__default.default.svg, xmlns: 'http://www.w3.org/2000/svg' },
|
|
101
|
-
React__default.default.createElement("circle", { className: cn__default.default(styles__default.default.backgroundCircle, styles__default.default[size], (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
React__default.default.createElement("circle", { className: cn__default.default(styles__default.default.progressCircle, styles__default.default[view], styles__default.default[size], (
|
|
105
|
-
_c[styles__default.default["bg-".concat(view)]] = fillComplete && isComplete,
|
|
106
|
-
_c)), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
|
|
75
|
+
React__default.default.createElement("circle", { className: cn__default.default(styles__default.default.backgroundCircle, styles__default.default[size], (_c = {},
|
|
76
|
+
_c[styles__default.default.stroke] = !stroke,
|
|
77
|
+
_c)), style: tslib.__assign({}, (strokeColor && stroke && { stroke: strokeColor })), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: consts.STROKE[size] }),
|
|
78
|
+
React__default.default.createElement("circle", { className: cn__default.default(styles__default.default.progressCircle, styles__default.default[view], styles__default.default[size]), style: tslib.__assign({}, (progressStrokeColor && { stroke: progressStrokeColor })), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: consts.STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
|
|
107
79
|
? -memorized.strokeDashoffset
|
|
108
80
|
: memorized.strokeDashoffset, transform: "rotate(".concat(-90, " ").concat(memorized.center, " ").concat(memorized.center, ")") })),
|
|
109
81
|
React__default.default.createElement("div", { className: cn__default.default(styles__default.default.labelWrapper, (_d = {},
|
package/cssm/consts.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const SIZES: {
|
|
2
|
+
xs: number;
|
|
3
|
+
s: number;
|
|
4
|
+
m: number;
|
|
5
|
+
l: number;
|
|
6
|
+
xl: number;
|
|
7
|
+
xxl: number;
|
|
8
|
+
};
|
|
9
|
+
declare const STROKE: {
|
|
10
|
+
xs: number;
|
|
11
|
+
s: number;
|
|
12
|
+
m: number;
|
|
13
|
+
l: number;
|
|
14
|
+
xl: number;
|
|
15
|
+
xxl: number;
|
|
16
|
+
};
|
|
17
|
+
declare const VIEW_TITLE: {
|
|
18
|
+
readonly xs: "small";
|
|
19
|
+
readonly s: "small";
|
|
20
|
+
readonly m: "small";
|
|
21
|
+
readonly l: "xsmall";
|
|
22
|
+
readonly xl: "medium";
|
|
23
|
+
readonly xxl: "medium";
|
|
24
|
+
};
|
|
25
|
+
declare const VIEW_TEXT: {
|
|
26
|
+
readonly xs: "secondary-small";
|
|
27
|
+
readonly s: "secondary-small";
|
|
28
|
+
readonly m: "secondary-large";
|
|
29
|
+
readonly l: "secondary-large";
|
|
30
|
+
readonly xl: "secondary-large";
|
|
31
|
+
readonly xxl: "secondary-large";
|
|
32
|
+
};
|
|
33
|
+
declare const TYPOGRAPHY_COLOR: string[];
|
|
34
|
+
export { SIZES, STROKE, VIEW_TITLE, VIEW_TEXT, TYPOGRAPHY_COLOR };
|
package/cssm/consts.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var SIZES = {
|
|
6
|
+
xs: 24,
|
|
7
|
+
s: 48,
|
|
8
|
+
m: 64,
|
|
9
|
+
l: 80,
|
|
10
|
+
xl: 128,
|
|
11
|
+
xxl: 144,
|
|
12
|
+
};
|
|
13
|
+
var STROKE = {
|
|
14
|
+
xs: 4,
|
|
15
|
+
s: 4,
|
|
16
|
+
m: 6,
|
|
17
|
+
l: 8,
|
|
18
|
+
xl: 10,
|
|
19
|
+
xxl: 12,
|
|
20
|
+
};
|
|
21
|
+
var VIEW_TITLE = {
|
|
22
|
+
xs: 'small',
|
|
23
|
+
s: 'small',
|
|
24
|
+
m: 'small',
|
|
25
|
+
l: 'xsmall',
|
|
26
|
+
xl: 'medium',
|
|
27
|
+
xxl: 'medium',
|
|
28
|
+
};
|
|
29
|
+
var VIEW_TEXT = {
|
|
30
|
+
xs: 'secondary-small',
|
|
31
|
+
s: 'secondary-small',
|
|
32
|
+
m: 'secondary-large',
|
|
33
|
+
l: 'secondary-large',
|
|
34
|
+
xl: 'secondary-large',
|
|
35
|
+
xxl: 'secondary-large',
|
|
36
|
+
};
|
|
37
|
+
var TYPOGRAPHY_COLOR = ['primary', 'secondary', 'tertiary', 'positive', 'negative'];
|
|
38
|
+
|
|
39
|
+
exports.SIZES = SIZES;
|
|
40
|
+
exports.STROKE = STROKE;
|
|
41
|
+
exports.TYPOGRAPHY_COLOR = TYPOGRAPHY_COLOR;
|
|
42
|
+
exports.VIEW_TEXT = VIEW_TEXT;
|
|
43
|
+
exports.VIEW_TITLE = VIEW_TITLE;
|
package/cssm/index.js
CHANGED
package/cssm/index.module.css
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
/* Hard up */
|
|
19
19
|
} :root {
|
|
20
|
+
--border-radius-pill: 99px;
|
|
20
21
|
} :root {
|
|
21
22
|
} :root {
|
|
22
23
|
--font-family-system: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica,
|
|
@@ -40,7 +41,12 @@
|
|
|
40
41
|
display: flex;
|
|
41
42
|
justify-content: center;
|
|
42
43
|
align-items: center;
|
|
43
|
-
|
|
44
|
+
border-radius: var(--border-radius-pill)
|
|
45
|
+
} .component.bg-positive {
|
|
46
|
+
background: var(--circular-progress-bar-positive-color);
|
|
47
|
+
} .component.bg-negative {
|
|
48
|
+
background: var(--circular-progress-bar-negative-color);
|
|
49
|
+
} .svg {
|
|
44
50
|
display: block;
|
|
45
51
|
width: 100%;
|
|
46
52
|
} .title,
|
|
@@ -123,12 +129,8 @@
|
|
|
123
129
|
} .backgroundCircle.stroke {
|
|
124
130
|
stroke: transparent;
|
|
125
131
|
} .progressCircle {
|
|
126
|
-
stroke-linecap: round
|
|
127
|
-
} .
|
|
128
|
-
fill: var(--circular-progress-bar-positive-color);
|
|
129
|
-
} .progressCircle.bg-negative {
|
|
130
|
-
fill: var(--circular-progress-bar-negative-color);
|
|
131
|
-
} .iconWrapper {
|
|
132
|
+
stroke-linecap: round;
|
|
133
|
+
} .iconWrapper {
|
|
132
134
|
display: flex;
|
|
133
135
|
align-items: center;
|
|
134
136
|
justify-content: center
|
package/esm/Component.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
5
|
type CircularProgressBarProps = {
|
|
5
6
|
/**
|
|
6
7
|
* Уровень прогресса, %
|
|
@@ -17,7 +18,7 @@ type CircularProgressBarProps = {
|
|
|
17
18
|
/**
|
|
18
19
|
* Цвет контента
|
|
19
20
|
*/
|
|
20
|
-
contentColor?:
|
|
21
|
+
contentColor?: TypographyColor | string;
|
|
21
22
|
/**
|
|
22
23
|
* Дополнительный текст
|
|
23
24
|
*/
|
|
@@ -86,12 +87,24 @@ type CircularProgressBarProps = {
|
|
|
86
87
|
*/
|
|
87
88
|
dataTestId?: string;
|
|
88
89
|
/**
|
|
89
|
-
* Дочерние
|
|
90
|
+
* Дочерние элементы
|
|
90
91
|
*/
|
|
91
92
|
children?: ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Цвет прогресса
|
|
95
|
+
*/
|
|
96
|
+
progressStrokeColor?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Цвет заливки внутри круга
|
|
99
|
+
*/
|
|
100
|
+
circleColor?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Цвет желоба
|
|
103
|
+
*/
|
|
104
|
+
strokeColor?: string;
|
|
92
105
|
};
|
|
93
106
|
/**
|
|
94
107
|
* Компонент круглого прогресс бара.
|
|
95
108
|
*/
|
|
96
109
|
declare const CircularProgressBar: React.FC<CircularProgressBarProps>;
|
|
97
|
-
export { CircularProgressBarProps, CircularProgressBar };
|
|
110
|
+
export { TypographyColor, CircularProgressBarProps, CircularProgressBar };
|