@alfalab/core-components-steps 1.7.5 → 1.8.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 +8 -33
- package/Component.js +6 -3
- package/components/step/Component.d.ts +9 -33
- package/components/step/Component.js +26 -14
- package/components/step/index.css +44 -39
- package/components/step-indicator/Component.js +1 -1
- package/components/step-indicator/index.css +6 -3
- package/cssm/Component.d.ts +8 -33
- package/cssm/Component.js +5 -2
- package/cssm/components/step/Component.d.ts +9 -33
- package/cssm/components/step/Component.js +25 -13
- package/cssm/components/step/index.module.css +21 -16
- package/cssm/components/step-indicator/index.module.css +4 -1
- package/cssm/index.module.css +3 -0
- package/cssm/shared/index.d.ts +1 -0
- package/cssm/shared/index.js +9 -0
- package/cssm/types/common-props.d.ts +41 -0
- package/cssm/types/common-props.js +2 -0
- package/cssm/utils/getStepsTestIds.d.ts +5 -0
- package/cssm/utils/getStepsTestIds.js +14 -0
- package/esm/Component.d.ts +8 -33
- package/esm/Component.js +6 -3
- package/esm/components/step/Component.d.ts +9 -33
- package/esm/components/step/Component.js +26 -14
- package/esm/components/step/index.css +44 -39
- package/esm/components/step-indicator/Component.js +1 -1
- package/esm/components/step-indicator/index.css +6 -3
- package/esm/index.css +6 -3
- package/esm/shared/index.d.ts +1 -0
- package/esm/shared/index.js +1 -0
- package/esm/types/common-props.d.ts +41 -0
- package/esm/types/common-props.js +1 -0
- package/esm/utils/getStepsTestIds.d.ts +5 -0
- package/esm/utils/getStepsTestIds.js +10 -0
- package/index.css +6 -3
- package/modern/Component.d.ts +8 -33
- package/modern/Component.js +6 -3
- package/modern/components/step/Component.d.ts +9 -33
- package/modern/components/step/Component.js +27 -13
- package/modern/components/step/index.css +44 -39
- package/modern/components/step-indicator/Component.js +1 -1
- package/modern/components/step-indicator/index.css +6 -3
- package/modern/index.css +6 -3
- package/modern/shared/index.d.ts +1 -0
- package/modern/shared/index.js +1 -0
- package/modern/types/common-props.d.ts +41 -0
- package/modern/types/common-props.js +1 -0
- package/modern/utils/getStepsTestIds.d.ts +5 -0
- package/modern/utils/getStepsTestIds.js +10 -0
- package/moderncssm/Component.d.ts +8 -33
- package/moderncssm/Component.js +5 -2
- package/moderncssm/components/step/Component.d.ts +9 -33
- package/moderncssm/components/step/Component.js +26 -12
- package/moderncssm/components/step/index.module.css +18 -18
- package/moderncssm/shared/index.d.ts +1 -0
- package/moderncssm/shared/index.js +1 -0
- package/moderncssm/types/common-props.d.ts +41 -0
- package/moderncssm/types/common-props.js +1 -0
- package/moderncssm/utils/getStepsTestIds.d.ts +5 -0
- package/moderncssm/utils/getStepsTestIds.js +10 -0
- package/package.json +4 -3
- package/shared/index.d.ts +1 -0
- package/shared/index.js +9 -0
- package/shared/package.json +3 -0
- package/src/Component.tsx +18 -40
- package/src/components/step/Component.tsx +49 -57
- package/src/components/step/index.module.css +19 -17
- package/src/shared/index.ts +1 -0
- package/src/shared/package.json +3 -0
- package/src/types/common-props.ts +48 -0
- package/src/utils/getStepsTestIds.ts +8 -0
- package/types/common-props.d.ts +41 -0
- package/types/common-props.js +2 -0
- package/utils/getStepsTestIds.d.ts +5 -0
- package/utils/getStepsTestIds.js +14 -0
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
|
+
import { getDataTestId } from '@alfalab/core-components-shared/moderncssm';
|
|
3
4
|
import { useFocus } from '@alfalab/hooks';
|
|
4
5
|
import { CheckmarkCircleMIcon } from '@alfalab/icons-glyph/CheckmarkCircleMIcon';
|
|
5
6
|
import { ClockMIcon } from '@alfalab/icons-glyph/ClockMIcon';
|
|
7
|
+
import { CrossCompactMIcon } from '@alfalab/icons-glyph/CrossCompactMIcon';
|
|
6
8
|
import { ExclamationCircleMIcon } from '@alfalab/icons-glyph/ExclamationCircleMIcon';
|
|
7
9
|
import { StepIndicator } from '../step-indicator/Component.js';
|
|
8
10
|
import styles from './index.module.css';
|
|
9
11
|
|
|
10
|
-
const
|
|
11
|
-
8: 'size-8',
|
|
12
|
-
16: 'size-16',
|
|
13
|
-
24: 'size-24',
|
|
14
|
-
};
|
|
15
|
-
const Step = ({ children, stepNumber, isSelected, disabled, ordered, isPositive, isError, isWarning, isWaiting, customStepIndicator, isStepCompleted, onClick, interactive, isVerticalAlign, isNotLastStep, fullWidth, minSpaceBetweenSteps = 24, }) => {
|
|
12
|
+
const Step = ({ children, stepNumber, isSelected, disabled, ordered, isPositive, isError, isCriticalError, isWarning, isWaiting, customStepIndicator, isStepCompleted, onClick, interactive, isVerticalAlign, isNotLastStep, fullWidth, minSpaceBetweenSteps = 24, completedDashColor, dataTestId, }) => {
|
|
16
13
|
const stepRef = useRef(null);
|
|
17
14
|
const [focused] = useFocus(stepRef, 'keyboard');
|
|
18
15
|
const handleButtonClick = () => {
|
|
@@ -34,6 +31,9 @@ const Step = ({ children, stepNumber, isSelected, disabled, ordered, isPositive,
|
|
|
34
31
|
if (customStepIndicator) {
|
|
35
32
|
return React.createElement(StepIndicator, { ...customStepIndicator });
|
|
36
33
|
}
|
|
34
|
+
if (isCriticalError) {
|
|
35
|
+
return React.createElement(StepIndicator, { iconColor: 'negative', content: React.createElement(CrossCompactMIcon, null) });
|
|
36
|
+
}
|
|
37
37
|
if (isError) {
|
|
38
38
|
return React.createElement(StepIndicator, { iconColor: 'negative', content: React.createElement(ExclamationCircleMIcon, null) });
|
|
39
39
|
}
|
|
@@ -55,11 +55,21 @@ const Step = ({ children, stepNumber, isSelected, disabled, ordered, isPositive,
|
|
|
55
55
|
}
|
|
56
56
|
return stepNumber;
|
|
57
57
|
};
|
|
58
|
+
const getCustomDashColor = () => {
|
|
59
|
+
if (isStepCompleted && completedDashColor) {
|
|
60
|
+
return {
|
|
61
|
+
borderColor: completedDashColor,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {};
|
|
65
|
+
};
|
|
58
66
|
const renderDash = () => (React.createElement("div", { className: cn(styles.dash, {
|
|
59
67
|
[styles.vertical]: isVerticalAlign,
|
|
60
68
|
[styles.completed]: isStepCompleted,
|
|
61
|
-
},
|
|
62
|
-
|
|
69
|
+
}), style: {
|
|
70
|
+
...getCustomDashColor(),
|
|
71
|
+
} }));
|
|
72
|
+
return (React.createElement("div", { "data-test-id": getDataTestId(dataTestId, 'step'), role: 'button', tabIndex: 0, ref: stepRef, className: cn(styles.step, {
|
|
63
73
|
[styles.completed]: isStepCompleted,
|
|
64
74
|
[styles.error]: isError,
|
|
65
75
|
[styles.selected]: isSelected,
|
|
@@ -68,6 +78,7 @@ const Step = ({ children, stepNumber, isSelected, disabled, ordered, isPositive,
|
|
|
68
78
|
[styles.vertical]: isVerticalAlign,
|
|
69
79
|
[styles.interactive]: interactive,
|
|
70
80
|
[styles.fullWidth]: fullWidth && isVerticalAlign,
|
|
81
|
+
[styles.horizontal]: !isVerticalAlign,
|
|
71
82
|
}), onClick: handleButtonClick, onKeyDown: handleKeyDown },
|
|
72
83
|
React.createElement("div", { className: cn(styles.indicator, {
|
|
73
84
|
[styles.vertical]: isVerticalAlign,
|
|
@@ -79,10 +90,13 @@ const Step = ({ children, stepNumber, isSelected, disabled, ordered, isPositive,
|
|
|
79
90
|
[styles.error]: isError,
|
|
80
91
|
}) }, getStepIndicator()),
|
|
81
92
|
isNotLastStep && isVerticalAlign && renderDash()),
|
|
82
|
-
React.createElement("div", { className: cn(styles.
|
|
83
|
-
[styles.
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
React.createElement("div", { className: cn(styles.textWrapper, styles[`gap-${minSpaceBetweenSteps}`], {
|
|
94
|
+
[styles.vertical]: isVerticalAlign,
|
|
95
|
+
}) },
|
|
96
|
+
React.createElement("div", { className: cn(styles.text, {
|
|
97
|
+
[styles.interactive]: interactive,
|
|
98
|
+
[styles.fullWidth]: fullWidth && isVerticalAlign,
|
|
99
|
+
}), onClick: handleTextClick }, children)),
|
|
86
100
|
isNotLastStep && !isVerticalAlign && renderDash()));
|
|
87
101
|
};
|
|
88
102
|
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
outline: none
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.step.horizontal {
|
|
14
|
+
flex-grow: 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
.step:not(.vertical) {
|
|
14
18
|
align-items: center;
|
|
15
19
|
}
|
|
@@ -64,39 +68,35 @@
|
|
|
64
68
|
margin-right: var(--gap-8)
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
.dash.size-16 {
|
|
68
|
-
min-width: 16px;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.dash.size-8 {
|
|
72
|
-
min-width: 8px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
71
|
.dash.completed {
|
|
76
72
|
border-top: var(--steps-dash-border);
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
.dash.vertical {
|
|
80
76
|
min-width: unset;
|
|
81
|
-
min-height:
|
|
77
|
+
min-height: 8px;
|
|
82
78
|
margin-right: var(--gap-0);
|
|
83
79
|
margin-top: var(--gap-8);
|
|
84
80
|
border-left: 2px solid var(--color-light-neutral-translucent-300);
|
|
85
|
-
border-top: none
|
|
81
|
+
border-top: none;
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
.dash.vertical.size-16 {
|
|
89
|
-
min-height: 16px;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.dash.vertical.size-8 {
|
|
93
|
-
min-height: 8px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
84
|
.dash.completed.vertical {
|
|
97
85
|
border-left: var(--steps-dash-border);
|
|
98
86
|
}
|
|
99
87
|
|
|
88
|
+
.textWrapper.vertical {
|
|
89
|
+
min-height: 48px
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.textWrapper.vertical.gap-24 {
|
|
93
|
+
margin-bottom: var(--gap-8);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.textWrapper.vertical.gap-32 {
|
|
97
|
+
margin-bottom: var(--gap-16);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
100
|
.text {
|
|
101
101
|
font-size: 16px;
|
|
102
102
|
line-height: 24px;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getStepsTestIds } from "../utils/getStepsTestIds";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getStepsTestIds } from '../utils/getStepsTestIds.js';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** Обобщенный набор типов который подходит для Steps, но также прокинут в дочерний Step */
|
|
3
|
+
type CommonProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
6
|
+
*/
|
|
7
|
+
dataTestId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Дочерние элементы
|
|
10
|
+
*/
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Управление ориентацией компонента
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
isVerticalAlign?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Управление отображением номера шага
|
|
19
|
+
*/
|
|
20
|
+
ordered?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Включение / отключение интерактивности шагов
|
|
23
|
+
*/
|
|
24
|
+
interactive?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Растягивание шагов на всю ширину блока для вертикальной ориентации
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
fullWidth?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Минимальное расстояние между шагами для горизонтального расположения компонента
|
|
32
|
+
* @default 24
|
|
33
|
+
* @description Значение 8 устарело и будет удалено в будущих версиях. Используйте 16, 24 или 32.
|
|
34
|
+
*/
|
|
35
|
+
minSpaceBetweenSteps?: 8 | 16 | 24 | 32;
|
|
36
|
+
/**
|
|
37
|
+
* Цвет тире выполненного шага
|
|
38
|
+
*/
|
|
39
|
+
completedDashColor?: string;
|
|
40
|
+
};
|
|
41
|
+
export { CommonProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-steps",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@alfalab/core-components-badge": "^5.6.4",
|
|
19
|
+
"@alfalab/core-components-shared": "^0.16.0",
|
|
19
20
|
"@alfalab/hooks": "^1.13.1",
|
|
20
21
|
"@alfalab/icons-glyph": "^2.210.0",
|
|
21
22
|
"classnames": "^2.5.1",
|
|
22
23
|
"tslib": "^2.4.0"
|
|
23
24
|
},
|
|
24
|
-
"themesVersion": "13.7.
|
|
25
|
-
"varsVersion": "9.
|
|
25
|
+
"themesVersion": "13.7.1",
|
|
26
|
+
"varsVersion": "9.18.0"
|
|
26
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getStepsTestIds } from "../utils/getStepsTestIds";
|
package/shared/index.js
ADDED
package/src/Component.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
4
|
import { Step } from './components/step';
|
|
5
5
|
import { StepIndicatorProps } from './components/step-indicator';
|
|
6
|
+
import { CommonProps } from './types/common-props';
|
|
6
7
|
|
|
7
8
|
import styles from './index.module.css';
|
|
8
9
|
|
|
@@ -12,11 +13,6 @@ export type StepsProps = {
|
|
|
12
13
|
*/
|
|
13
14
|
className?: string;
|
|
14
15
|
|
|
15
|
-
/**
|
|
16
|
-
* Дочерние элементы
|
|
17
|
-
*/
|
|
18
|
-
children: ReactNode;
|
|
19
|
-
|
|
20
16
|
/**
|
|
21
17
|
* Активный шаг, указанный по умолчанию
|
|
22
18
|
* @default 1
|
|
@@ -34,34 +30,6 @@ export type StepsProps = {
|
|
|
34
30
|
*/
|
|
35
31
|
isMarkCompletedSteps?: boolean;
|
|
36
32
|
|
|
37
|
-
/**
|
|
38
|
-
* Управление ориентацией компонента
|
|
39
|
-
* @default false
|
|
40
|
-
*/
|
|
41
|
-
isVerticalAlign?: boolean;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Управление отображением номера шага
|
|
45
|
-
*/
|
|
46
|
-
ordered?: boolean;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Включение / отключение интерактивности шагов
|
|
50
|
-
*/
|
|
51
|
-
interactive?: boolean;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Растягивание шагов на всю ширину блока для вертикальной ориентации
|
|
55
|
-
* @default false
|
|
56
|
-
*/
|
|
57
|
-
fullWidth?: boolean;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Минимальное расстояние между шагами
|
|
61
|
-
* @default 24
|
|
62
|
-
*/
|
|
63
|
-
minSpaceBetweenSteps?: 8 | 16 | 24;
|
|
64
|
-
|
|
65
33
|
/**
|
|
66
34
|
* Кастомный метод для управления состоянием disabled шага и
|
|
67
35
|
* возможностью перехода на этот шаг
|
|
@@ -77,6 +45,13 @@ export type StepsProps = {
|
|
|
77
45
|
*/
|
|
78
46
|
checkIsStepError?: (stepNumber: number) => boolean;
|
|
79
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Кастомный метод для управления состоянием шага criticalError
|
|
50
|
+
* @param stepNumber - номер шага
|
|
51
|
+
* @return Флаг состояния error
|
|
52
|
+
*/
|
|
53
|
+
checkIsStepCriticalError?: (stepNumber: number) => boolean;
|
|
54
|
+
|
|
80
55
|
/**
|
|
81
56
|
* Кастомный метод для управления состоянием шага warning
|
|
82
57
|
* @param stepNumber - номер шага
|
|
@@ -110,12 +85,7 @@ export type StepsProps = {
|
|
|
110
85
|
* @param stepNumber - номер активного шага
|
|
111
86
|
*/
|
|
112
87
|
onChange?: (stepNumber: number) => void;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Идентификатор для систем автоматизированного тестирования
|
|
116
|
-
*/
|
|
117
|
-
dataTestId?: string;
|
|
118
|
-
};
|
|
88
|
+
} & CommonProps;
|
|
119
89
|
|
|
120
90
|
export const Steps: React.FC<StepsProps> = ({
|
|
121
91
|
className,
|
|
@@ -130,12 +100,14 @@ export const Steps: React.FC<StepsProps> = ({
|
|
|
130
100
|
minSpaceBetweenSteps = 24,
|
|
131
101
|
checkIsStepDisabled,
|
|
132
102
|
checkIsStepError,
|
|
103
|
+
checkIsStepCriticalError,
|
|
133
104
|
checkIsStepWarning,
|
|
134
105
|
checkIsStepWaiting,
|
|
135
106
|
checkIsStepPositive,
|
|
136
107
|
checkIsStepCustom,
|
|
137
108
|
onChange,
|
|
138
109
|
dataTestId,
|
|
110
|
+
completedDashColor,
|
|
139
111
|
}) => {
|
|
140
112
|
const uncontrolled = activeStepProp === undefined;
|
|
141
113
|
const [activeStep, setActiveStep] = useState(defaultActiveStep);
|
|
@@ -170,6 +142,9 @@ export const Steps: React.FC<StepsProps> = ({
|
|
|
170
142
|
const disabled = checkIsStepDisabled ? checkIsStepDisabled(stepNumber) : false;
|
|
171
143
|
const isPositive = checkIsStepPositive ? checkIsStepPositive(stepNumber) : false;
|
|
172
144
|
const isError = checkIsStepError ? checkIsStepError(stepNumber) : false;
|
|
145
|
+
const isCriticalError = checkIsStepCriticalError
|
|
146
|
+
? checkIsStepCriticalError(stepNumber)
|
|
147
|
+
: false;
|
|
173
148
|
const isWarning = checkIsStepWarning ? checkIsStepWarning(stepNumber) : false;
|
|
174
149
|
const isWaiting = checkIsStepWaiting ? checkIsStepWaiting(stepNumber) : false;
|
|
175
150
|
const customStepIndicator = checkIsStepCustom && checkIsStepCustom(stepNumber);
|
|
@@ -184,6 +159,7 @@ export const Steps: React.FC<StepsProps> = ({
|
|
|
184
159
|
disabled={disabled}
|
|
185
160
|
isPositive={isPositive}
|
|
186
161
|
isError={isError}
|
|
162
|
+
isCriticalError={isCriticalError}
|
|
187
163
|
isWarning={isWarning}
|
|
188
164
|
isWaiting={isWaiting}
|
|
189
165
|
customStepIndicator={customStepIndicator}
|
|
@@ -195,6 +171,8 @@ export const Steps: React.FC<StepsProps> = ({
|
|
|
195
171
|
key={stepNumber}
|
|
196
172
|
fullWidth={fullWidth}
|
|
197
173
|
minSpaceBetweenSteps={minSpaceBetweenSteps}
|
|
174
|
+
completedDashColor={completedDashColor}
|
|
175
|
+
dataTestId={dataTestId}
|
|
198
176
|
>
|
|
199
177
|
{step}
|
|
200
178
|
</Step>
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { FC, useRef } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
|
+
import { getDataTestId } from '@alfalab/core-components-shared';
|
|
4
5
|
import { useFocus } from '@alfalab/hooks';
|
|
5
6
|
import { CheckmarkCircleMIcon } from '@alfalab/icons-glyph/CheckmarkCircleMIcon';
|
|
6
7
|
import { ClockMIcon } from '@alfalab/icons-glyph/ClockMIcon';
|
|
8
|
+
import { CrossCompactMIcon } from '@alfalab/icons-glyph/CrossCompactMIcon';
|
|
7
9
|
import { ExclamationCircleMIcon } from '@alfalab/icons-glyph/ExclamationCircleMIcon';
|
|
8
10
|
|
|
11
|
+
import { CommonProps } from '../../types/common-props';
|
|
9
12
|
import { StepIndicator, StepIndicatorProps } from '../step-indicator';
|
|
10
13
|
|
|
11
14
|
import styles from './index.module.css';
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Название шага
|
|
16
|
-
*/
|
|
17
|
-
children: ReactNode;
|
|
18
|
-
|
|
16
|
+
type StepProps = {
|
|
19
17
|
/**
|
|
20
18
|
* Номер шага
|
|
21
19
|
*/
|
|
@@ -31,16 +29,6 @@ export type StepProps = {
|
|
|
31
29
|
*/
|
|
32
30
|
disabled: boolean;
|
|
33
31
|
|
|
34
|
-
/**
|
|
35
|
-
* Управление отображением номера шага
|
|
36
|
-
*/
|
|
37
|
-
ordered?: boolean;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Включение / отключение интерактивности шагов
|
|
41
|
-
*/
|
|
42
|
-
interactive?: boolean;
|
|
43
|
-
|
|
44
32
|
/**
|
|
45
33
|
* Маркер того, что текущий шаг находится в состоянии "Positive"
|
|
46
34
|
*/
|
|
@@ -51,6 +39,11 @@ export type StepProps = {
|
|
|
51
39
|
*/
|
|
52
40
|
isError: boolean;
|
|
53
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Маркер того, что текущий шаг находится в состоянии "isCriticalError"
|
|
44
|
+
*/
|
|
45
|
+
isCriticalError: boolean;
|
|
46
|
+
|
|
54
47
|
/**
|
|
55
48
|
* Маркер того, что текущий шаг находится в состоянии "Warning"
|
|
56
49
|
*/
|
|
@@ -71,43 +64,19 @@ export type StepProps = {
|
|
|
71
64
|
*/
|
|
72
65
|
customStepIndicator?: StepIndicatorProps | null;
|
|
73
66
|
|
|
74
|
-
/**
|
|
75
|
-
* Управление ориентацией компонента
|
|
76
|
-
* @default false
|
|
77
|
-
*/
|
|
78
|
-
isVerticalAlign?: boolean;
|
|
79
|
-
|
|
80
67
|
/**
|
|
81
68
|
* Указывает, является ли текущий шаг последним в списке
|
|
82
69
|
*/
|
|
83
70
|
isNotLastStep?: boolean;
|
|
84
71
|
|
|
85
|
-
/**
|
|
86
|
-
* Маркер того, что шаг растягивается на всю ширину блока
|
|
87
|
-
* для вертикальной ориентации
|
|
88
|
-
*/
|
|
89
|
-
fullWidth?: boolean;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Минимальное расстояние между шагами
|
|
93
|
-
* @default 24
|
|
94
|
-
*/
|
|
95
|
-
minSpaceBetweenSteps?: 8 | 16 | 24;
|
|
96
|
-
|
|
97
72
|
/**
|
|
98
73
|
* Обработчик нажатия на текущей шаг
|
|
99
74
|
* @param stepNumber - номер шага
|
|
100
75
|
*/
|
|
101
76
|
onClick: (stepNumber: number) => void;
|
|
102
|
-
};
|
|
77
|
+
} & CommonProps;
|
|
103
78
|
|
|
104
|
-
const
|
|
105
|
-
8: 'size-8',
|
|
106
|
-
16: 'size-16',
|
|
107
|
-
24: 'size-24',
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export const Step: React.FC<StepProps> = ({
|
|
79
|
+
export const Step: FC<StepProps> = ({
|
|
111
80
|
children,
|
|
112
81
|
stepNumber,
|
|
113
82
|
isSelected,
|
|
@@ -115,6 +84,7 @@ export const Step: React.FC<StepProps> = ({
|
|
|
115
84
|
ordered,
|
|
116
85
|
isPositive,
|
|
117
86
|
isError,
|
|
87
|
+
isCriticalError,
|
|
118
88
|
isWarning,
|
|
119
89
|
isWaiting,
|
|
120
90
|
customStepIndicator,
|
|
@@ -125,6 +95,8 @@ export const Step: React.FC<StepProps> = ({
|
|
|
125
95
|
isNotLastStep,
|
|
126
96
|
fullWidth,
|
|
127
97
|
minSpaceBetweenSteps = 24,
|
|
98
|
+
completedDashColor,
|
|
99
|
+
dataTestId,
|
|
128
100
|
}) => {
|
|
129
101
|
const stepRef = useRef<HTMLDivElement>(null);
|
|
130
102
|
|
|
@@ -152,6 +124,9 @@ export const Step: React.FC<StepProps> = ({
|
|
|
152
124
|
if (customStepIndicator) {
|
|
153
125
|
return <StepIndicator {...customStepIndicator} />;
|
|
154
126
|
}
|
|
127
|
+
if (isCriticalError) {
|
|
128
|
+
return <StepIndicator iconColor='negative' content={<CrossCompactMIcon />} />;
|
|
129
|
+
}
|
|
155
130
|
if (isError) {
|
|
156
131
|
return <StepIndicator iconColor='negative' content={<ExclamationCircleMIcon />} />;
|
|
157
132
|
}
|
|
@@ -184,21 +159,31 @@ export const Step: React.FC<StepProps> = ({
|
|
|
184
159
|
return stepNumber;
|
|
185
160
|
};
|
|
186
161
|
|
|
162
|
+
const getCustomDashColor = () => {
|
|
163
|
+
if (isStepCompleted && completedDashColor) {
|
|
164
|
+
return {
|
|
165
|
+
borderColor: completedDashColor,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return {};
|
|
170
|
+
};
|
|
171
|
+
|
|
187
172
|
const renderDash = () => (
|
|
188
173
|
<div
|
|
189
|
-
className={cn(
|
|
190
|
-
styles.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
)}
|
|
174
|
+
className={cn(styles.dash, {
|
|
175
|
+
[styles.vertical]: isVerticalAlign,
|
|
176
|
+
[styles.completed]: isStepCompleted,
|
|
177
|
+
})}
|
|
178
|
+
style={{
|
|
179
|
+
...getCustomDashColor(),
|
|
180
|
+
}}
|
|
197
181
|
/>
|
|
198
182
|
);
|
|
199
183
|
|
|
200
184
|
return (
|
|
201
185
|
<div
|
|
186
|
+
data-test-id={getDataTestId(dataTestId, 'step')}
|
|
202
187
|
role='button'
|
|
203
188
|
tabIndex={0}
|
|
204
189
|
ref={stepRef}
|
|
@@ -211,6 +196,7 @@ export const Step: React.FC<StepProps> = ({
|
|
|
211
196
|
[styles.vertical]: isVerticalAlign,
|
|
212
197
|
[styles.interactive]: interactive,
|
|
213
198
|
[styles.fullWidth]: fullWidth && isVerticalAlign,
|
|
199
|
+
[styles.horizontal]: !isVerticalAlign,
|
|
214
200
|
})}
|
|
215
201
|
onClick={handleButtonClick}
|
|
216
202
|
onKeyDown={handleKeyDown}
|
|
@@ -232,15 +218,21 @@ export const Step: React.FC<StepProps> = ({
|
|
|
232
218
|
</div>
|
|
233
219
|
{isNotLastStep && isVerticalAlign && renderDash()}
|
|
234
220
|
</div>
|
|
235
|
-
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
|
|
236
221
|
<div
|
|
237
|
-
className={cn(styles.
|
|
238
|
-
[styles.
|
|
239
|
-
[styles.fullWidth]: fullWidth && isVerticalAlign,
|
|
222
|
+
className={cn(styles.textWrapper, styles[`gap-${minSpaceBetweenSteps}`], {
|
|
223
|
+
[styles.vertical]: isVerticalAlign,
|
|
240
224
|
})}
|
|
241
|
-
onClick={handleTextClick}
|
|
242
225
|
>
|
|
243
|
-
{
|
|
226
|
+
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
|
|
227
|
+
<div
|
|
228
|
+
className={cn(styles.text, {
|
|
229
|
+
[styles.interactive]: interactive,
|
|
230
|
+
[styles.fullWidth]: fullWidth && isVerticalAlign,
|
|
231
|
+
})}
|
|
232
|
+
onClick={handleTextClick}
|
|
233
|
+
>
|
|
234
|
+
{children}
|
|
235
|
+
</div>
|
|
244
236
|
</div>
|
|
245
237
|
{isNotLastStep && !isVerticalAlign && renderDash()}
|
|
246
238
|
</div>
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
display: flex;
|
|
10
10
|
outline: none;
|
|
11
11
|
|
|
12
|
+
&.horizontal {
|
|
13
|
+
flex-grow: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
&:not(.vertical) {
|
|
13
17
|
align-items: center;
|
|
14
18
|
}
|
|
@@ -65,33 +69,17 @@
|
|
|
65
69
|
border-top: 2px solid var(--color-light-neutral-translucent-300);
|
|
66
70
|
margin-right: var(--gap-8);
|
|
67
71
|
|
|
68
|
-
&.size-16 {
|
|
69
|
-
min-width: 16px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
&.size-8 {
|
|
73
|
-
min-width: 8px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
72
|
&.completed {
|
|
77
73
|
border-top: var(--steps-dash-border);
|
|
78
74
|
}
|
|
79
75
|
|
|
80
76
|
&.vertical {
|
|
81
77
|
min-width: unset;
|
|
82
|
-
min-height:
|
|
78
|
+
min-height: 8px;
|
|
83
79
|
margin-right: var(--gap-0);
|
|
84
80
|
margin-top: var(--gap-8);
|
|
85
81
|
border-left: 2px solid var(--color-light-neutral-translucent-300);
|
|
86
82
|
border-top: none;
|
|
87
|
-
|
|
88
|
-
&.size-16 {
|
|
89
|
-
min-height: 16px;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&.size-8 {
|
|
93
|
-
min-height: 8px;
|
|
94
|
-
}
|
|
95
83
|
}
|
|
96
84
|
|
|
97
85
|
&.completed.vertical {
|
|
@@ -99,6 +87,20 @@
|
|
|
99
87
|
}
|
|
100
88
|
}
|
|
101
89
|
|
|
90
|
+
.textWrapper {
|
|
91
|
+
&.vertical {
|
|
92
|
+
min-height: 48px;
|
|
93
|
+
|
|
94
|
+
&.gap-24 {
|
|
95
|
+
margin-bottom: var(--gap-8);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&.gap-32 {
|
|
99
|
+
margin-bottom: var(--gap-16);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
102
104
|
.text {
|
|
103
105
|
@mixin paragraph_primary_medium;
|
|
104
106
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getStepsTestIds } from '../utils/getStepsTestIds';
|