@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,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CommonProps } from "../../types/common-props";
|
|
4
3
|
import { StepIndicatorProps } from "../step-indicator/index";
|
|
5
4
|
type StepProps = {
|
|
6
|
-
/**
|
|
7
|
-
* Название шага
|
|
8
|
-
*/
|
|
9
|
-
children: ReactNode;
|
|
10
5
|
/**
|
|
11
6
|
* Номер шага
|
|
12
7
|
*/
|
|
@@ -19,14 +14,6 @@ type StepProps = {
|
|
|
19
14
|
* Маркер того, что текущий шаг доступен для клика
|
|
20
15
|
*/
|
|
21
16
|
disabled: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Управление отображением номера шага
|
|
24
|
-
*/
|
|
25
|
-
ordered?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Включение / отключение интерактивности шагов
|
|
28
|
-
*/
|
|
29
|
-
interactive?: boolean;
|
|
30
17
|
/**
|
|
31
18
|
* Маркер того, что текущий шаг находится в состоянии "Positive"
|
|
32
19
|
*/
|
|
@@ -35,6 +22,10 @@ type StepProps = {
|
|
|
35
22
|
* Маркер того, что текущий шаг находится в состоянии "Error"
|
|
36
23
|
*/
|
|
37
24
|
isError: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Маркер того, что текущий шаг находится в состоянии "isCriticalError"
|
|
27
|
+
*/
|
|
28
|
+
isCriticalError: boolean;
|
|
38
29
|
/**
|
|
39
30
|
* Маркер того, что текущий шаг находится в состоянии "Warning"
|
|
40
31
|
*/
|
|
@@ -51,30 +42,15 @@ type StepProps = {
|
|
|
51
42
|
* Свойства кастомного индикатора текущего шага
|
|
52
43
|
*/
|
|
53
44
|
customStepIndicator?: StepIndicatorProps | null;
|
|
54
|
-
/**
|
|
55
|
-
* Управление ориентацией компонента
|
|
56
|
-
* @default false
|
|
57
|
-
*/
|
|
58
|
-
isVerticalAlign?: boolean;
|
|
59
45
|
/**
|
|
60
46
|
* Указывает, является ли текущий шаг последним в списке
|
|
61
47
|
*/
|
|
62
48
|
isNotLastStep?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Маркер того, что шаг растягивается на всю ширину блока
|
|
65
|
-
* для вертикальной ориентации
|
|
66
|
-
*/
|
|
67
|
-
fullWidth?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Минимальное расстояние между шагами
|
|
70
|
-
* @default 24
|
|
71
|
-
*/
|
|
72
|
-
minSpaceBetweenSteps?: 8 | 16 | 24;
|
|
73
49
|
/**
|
|
74
50
|
* Обработчик нажатия на текущей шаг
|
|
75
51
|
* @param stepNumber - номер шага
|
|
76
52
|
*/
|
|
77
53
|
onClick: (stepNumber: number) => void;
|
|
78
|
-
};
|
|
79
|
-
declare const Step:
|
|
80
|
-
export {
|
|
54
|
+
} & CommonProps;
|
|
55
|
+
declare const Step: FC<StepProps>;
|
|
56
|
+
export { Step };
|
|
@@ -5,9 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var cn = require('classnames');
|
|
8
|
+
var coreComponentsShared = require('@alfalab/core-components-shared/cssm');
|
|
8
9
|
var hooks = require('@alfalab/hooks');
|
|
9
10
|
var CheckmarkCircleMIcon = require('@alfalab/icons-glyph/CheckmarkCircleMIcon');
|
|
10
11
|
var ClockMIcon = require('@alfalab/icons-glyph/ClockMIcon');
|
|
12
|
+
var CrossCompactMIcon = require('@alfalab/icons-glyph/CrossCompactMIcon');
|
|
11
13
|
var ExclamationCircleMIcon = require('@alfalab/icons-glyph/ExclamationCircleMIcon');
|
|
12
14
|
var components_stepIndicator_Component = require('../step-indicator/Component.js');
|
|
13
15
|
var styles = require('./index.module.css');
|
|
@@ -18,14 +20,9 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
18
20
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
19
21
|
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
20
22
|
|
|
21
|
-
var SIZE_TO_CLASSNAME_MAP = {
|
|
22
|
-
8: 'size-8',
|
|
23
|
-
16: 'size-16',
|
|
24
|
-
24: 'size-24',
|
|
25
|
-
};
|
|
26
23
|
var Step = function (_a) {
|
|
27
|
-
var _b, _c, _d, _e;
|
|
28
|
-
var children = _a.children, stepNumber = _a.stepNumber, isSelected = _a.isSelected, disabled = _a.disabled, ordered = _a.ordered, isPositive = _a.isPositive, isError = _a.isError, isWarning = _a.isWarning, isWaiting = _a.isWaiting, customStepIndicator = _a.customStepIndicator, isStepCompleted = _a.isStepCompleted, onClick = _a.onClick, interactive = _a.interactive, isVerticalAlign = _a.isVerticalAlign, isNotLastStep = _a.isNotLastStep, fullWidth = _a.fullWidth,
|
|
24
|
+
var _b, _c, _d, _e, _f;
|
|
25
|
+
var children = _a.children, stepNumber = _a.stepNumber, isSelected = _a.isSelected, disabled = _a.disabled, ordered = _a.ordered, isPositive = _a.isPositive, isError = _a.isError, isCriticalError = _a.isCriticalError, isWarning = _a.isWarning, isWaiting = _a.isWaiting, customStepIndicator = _a.customStepIndicator, isStepCompleted = _a.isStepCompleted, onClick = _a.onClick, interactive = _a.interactive, isVerticalAlign = _a.isVerticalAlign, isNotLastStep = _a.isNotLastStep, fullWidth = _a.fullWidth, _g = _a.minSpaceBetweenSteps, minSpaceBetweenSteps = _g === void 0 ? 24 : _g, completedDashColor = _a.completedDashColor, dataTestId = _a.dataTestId;
|
|
29
26
|
var stepRef = React.useRef(null);
|
|
30
27
|
var focused = hooks.useFocus(stepRef, 'keyboard')[0];
|
|
31
28
|
var handleButtonClick = function () {
|
|
@@ -47,6 +44,9 @@ var Step = function (_a) {
|
|
|
47
44
|
if (customStepIndicator) {
|
|
48
45
|
return React__default.default.createElement(components_stepIndicator_Component.StepIndicator, tslib.__assign({}, customStepIndicator));
|
|
49
46
|
}
|
|
47
|
+
if (isCriticalError) {
|
|
48
|
+
return React__default.default.createElement(components_stepIndicator_Component.StepIndicator, { iconColor: 'negative', content: React__default.default.createElement(CrossCompactMIcon.CrossCompactMIcon, null) });
|
|
49
|
+
}
|
|
50
50
|
if (isError) {
|
|
51
51
|
return React__default.default.createElement(components_stepIndicator_Component.StepIndicator, { iconColor: 'negative', content: React__default.default.createElement(ExclamationCircleMIcon.ExclamationCircleMIcon, null) });
|
|
52
52
|
}
|
|
@@ -68,14 +68,22 @@ var Step = function (_a) {
|
|
|
68
68
|
}
|
|
69
69
|
return stepNumber;
|
|
70
70
|
};
|
|
71
|
+
var getCustomDashColor = function () {
|
|
72
|
+
if (isStepCompleted && completedDashColor) {
|
|
73
|
+
return {
|
|
74
|
+
borderColor: completedDashColor,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {};
|
|
78
|
+
};
|
|
71
79
|
var renderDash = function () {
|
|
72
80
|
var _a;
|
|
73
81
|
return (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.dash, (_a = {},
|
|
74
82
|
_a[styles__default.default.vertical] = isVerticalAlign,
|
|
75
83
|
_a[styles__default.default.completed] = isStepCompleted,
|
|
76
|
-
_a),
|
|
84
|
+
_a)), style: tslib.__assign({}, getCustomDashColor()) }));
|
|
77
85
|
};
|
|
78
|
-
return (React__default.default.createElement("div", { role: 'button', tabIndex: 0, ref: stepRef, className: cn__default.default(styles__default.default.step, (_b = {},
|
|
86
|
+
return (React__default.default.createElement("div", { "data-test-id": coreComponentsShared.getDataTestId(dataTestId, 'step'), role: 'button', tabIndex: 0, ref: stepRef, className: cn__default.default(styles__default.default.step, (_b = {},
|
|
79
87
|
_b[styles__default.default.completed] = isStepCompleted,
|
|
80
88
|
_b[styles__default.default.error] = isError,
|
|
81
89
|
_b[styles__default.default.selected] = isSelected,
|
|
@@ -84,6 +92,7 @@ var Step = function (_a) {
|
|
|
84
92
|
_b[styles__default.default.vertical] = isVerticalAlign,
|
|
85
93
|
_b[styles__default.default.interactive] = interactive,
|
|
86
94
|
_b[styles__default.default.fullWidth] = fullWidth && isVerticalAlign,
|
|
95
|
+
_b[styles__default.default.horizontal] = !isVerticalAlign,
|
|
87
96
|
_b)), onClick: handleButtonClick, onKeyDown: handleKeyDown },
|
|
88
97
|
React__default.default.createElement("div", { className: cn__default.default(styles__default.default.indicator, (_c = {},
|
|
89
98
|
_c[styles__default.default.vertical] = isVerticalAlign,
|
|
@@ -95,10 +104,13 @@ var Step = function (_a) {
|
|
|
95
104
|
_d[styles__default.default.error] = isError,
|
|
96
105
|
_d)) }, getStepIndicator()),
|
|
97
106
|
isNotLastStep && isVerticalAlign && renderDash()),
|
|
98
|
-
React__default.default.createElement("div", { className: cn__default.default(styles__default.default.
|
|
99
|
-
_e[styles__default.default.
|
|
100
|
-
_e
|
|
101
|
-
|
|
107
|
+
React__default.default.createElement("div", { className: cn__default.default(styles__default.default.textWrapper, styles__default.default["gap-".concat(minSpaceBetweenSteps)], (_e = {},
|
|
108
|
+
_e[styles__default.default.vertical] = isVerticalAlign,
|
|
109
|
+
_e)) },
|
|
110
|
+
React__default.default.createElement("div", { className: cn__default.default(styles__default.default.text, (_f = {},
|
|
111
|
+
_f[styles__default.default.interactive] = interactive,
|
|
112
|
+
_f[styles__default.default.fullWidth] = fullWidth && isVerticalAlign,
|
|
113
|
+
_f)), onClick: handleTextClick }, children)),
|
|
102
114
|
isNotLastStep && !isVerticalAlign && renderDash()));
|
|
103
115
|
};
|
|
104
116
|
|
|
@@ -24,13 +24,18 @@
|
|
|
24
24
|
} :root {
|
|
25
25
|
--gap-3xs: 2px; /* deprecated */
|
|
26
26
|
--gap-2xs: 4px; /* deprecated */
|
|
27
|
-
--gap-xs: 8px; /* deprecated */ /* deprecated */ /* deprecated */
|
|
27
|
+
--gap-xs: 8px; /* deprecated */ /* deprecated */ /* deprecated */
|
|
28
|
+
--gap-m: 16px; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
28
29
|
|
|
29
30
|
/* новые значения, используйте их */
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
/* no-unit может приводить к проблемам в calc (#1559) */
|
|
33
|
+
/* stylelint-disable-next-line length-zero-no-unit */
|
|
34
|
+
--gap-0: 0px;
|
|
31
35
|
--gap-2: var(--gap-3xs);
|
|
32
36
|
--gap-4: var(--gap-2xs);
|
|
33
37
|
--gap-8: var(--gap-xs);
|
|
38
|
+
--gap-16: var(--gap-m);
|
|
34
39
|
} :root {
|
|
35
40
|
} :root {
|
|
36
41
|
--focus-color: var(--color-light-status-info);
|
|
@@ -40,7 +45,9 @@
|
|
|
40
45
|
} .step {
|
|
41
46
|
display: flex;
|
|
42
47
|
outline: none
|
|
43
|
-
} .step
|
|
48
|
+
} .step.horizontal {
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
} .step:not(.vertical) {
|
|
44
51
|
align-items: center;
|
|
45
52
|
} .step.interactive:not(.disabled):hover {
|
|
46
53
|
cursor: pointer;
|
|
@@ -76,26 +83,24 @@
|
|
|
76
83
|
min-width: 24px;
|
|
77
84
|
border-top: 2px solid var(--color-light-neutral-translucent-300);
|
|
78
85
|
margin-right: var(--gap-8)
|
|
79
|
-
} .dash.
|
|
80
|
-
min-width: 16px;
|
|
81
|
-
} .dash.size-8 {
|
|
82
|
-
min-width: 8px;
|
|
83
|
-
} .dash.completed {
|
|
86
|
+
} .dash.completed {
|
|
84
87
|
border-top: var(--steps-dash-border);
|
|
85
88
|
} .dash.vertical {
|
|
86
89
|
min-width: unset;
|
|
87
|
-
min-height:
|
|
90
|
+
min-height: 8px;
|
|
88
91
|
margin-right: var(--gap-0);
|
|
89
92
|
margin-top: var(--gap-8);
|
|
90
93
|
border-left: 2px solid var(--color-light-neutral-translucent-300);
|
|
91
|
-
border-top: none
|
|
92
|
-
} .dash.vertical
|
|
93
|
-
min-height: 16px;
|
|
94
|
-
} .dash.vertical.size-8 {
|
|
95
|
-
min-height: 8px;
|
|
96
|
-
} .dash.completed.vertical {
|
|
94
|
+
border-top: none;
|
|
95
|
+
} .dash.completed.vertical {
|
|
97
96
|
border-left: var(--steps-dash-border);
|
|
98
|
-
} .
|
|
97
|
+
} .textWrapper.vertical {
|
|
98
|
+
min-height: 48px
|
|
99
|
+
} .textWrapper.vertical.gap-24 {
|
|
100
|
+
margin-bottom: var(--gap-8);
|
|
101
|
+
} .textWrapper.vertical.gap-32 {
|
|
102
|
+
margin-bottom: var(--gap-16);
|
|
103
|
+
} .text {
|
|
99
104
|
font-size: 16px;
|
|
100
105
|
line-height: 24px;
|
|
101
106
|
font-weight: 400;
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
} :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 */
|
|
16
16
|
|
|
17
17
|
/* новые значения, используйте их */
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
/* no-unit может приводить к проблемам в calc (#1559) */
|
|
20
|
+
/* stylelint-disable-next-line length-zero-no-unit */
|
|
21
|
+
--gap-0: 0px;
|
|
19
22
|
} :root {
|
|
20
23
|
} :root {
|
|
21
24
|
} /* сбрасывает синюю подсветку при нажатии */ .component.component {
|
package/cssm/index.module.css
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
} :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 */
|
|
16
16
|
|
|
17
17
|
/* новые значения, используйте их */
|
|
18
|
+
|
|
19
|
+
/* no-unit может приводить к проблемам в calc (#1559) */
|
|
20
|
+
/* stylelint-disable-next-line length-zero-no-unit */
|
|
18
21
|
} :root {
|
|
19
22
|
} :root {
|
|
20
23
|
} /* сбрасывает синюю подсветку при нажатии */ .component {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getStepsTestIds } from "../utils/getStepsTestIds";
|
|
@@ -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,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var coreComponentsShared = require('@alfalab/core-components-shared/cssm');
|
|
6
|
+
|
|
7
|
+
function getStepsTestIds(dataTestId) {
|
|
8
|
+
return {
|
|
9
|
+
steps: dataTestId,
|
|
10
|
+
step: coreComponentsShared.getDataTestId(dataTestId, 'step'),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.getStepsTestIds = getStepsTestIds;
|
package/esm/Component.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
3
|
import { StepIndicatorProps } from "./components/step-indicator/index";
|
|
4
|
+
import { CommonProps } from "./types/common-props";
|
|
5
5
|
type StepsProps = {
|
|
6
6
|
/**
|
|
7
7
|
* Дополнительный класс
|
|
8
8
|
*/
|
|
9
9
|
className?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Дочерние элементы
|
|
12
|
-
*/
|
|
13
|
-
children: ReactNode;
|
|
14
10
|
/**
|
|
15
11
|
* Активный шаг, указанный по умолчанию
|
|
16
12
|
* @default 1
|
|
@@ -25,29 +21,6 @@ type StepsProps = {
|
|
|
25
21
|
* @default true
|
|
26
22
|
*/
|
|
27
23
|
isMarkCompletedSteps?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Управление ориентацией компонента
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
isVerticalAlign?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Управление отображением номера шага
|
|
35
|
-
*/
|
|
36
|
-
ordered?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Включение / отключение интерактивности шагов
|
|
39
|
-
*/
|
|
40
|
-
interactive?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Растягивание шагов на всю ширину блока для вертикальной ориентации
|
|
43
|
-
* @default false
|
|
44
|
-
*/
|
|
45
|
-
fullWidth?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Минимальное расстояние между шагами
|
|
48
|
-
* @default 24
|
|
49
|
-
*/
|
|
50
|
-
minSpaceBetweenSteps?: 8 | 16 | 24;
|
|
51
24
|
/**
|
|
52
25
|
* Кастомный метод для управления состоянием disabled шага и
|
|
53
26
|
* возможностью перехода на этот шаг
|
|
@@ -61,6 +34,12 @@ type StepsProps = {
|
|
|
61
34
|
* @return Флаг состояния error
|
|
62
35
|
*/
|
|
63
36
|
checkIsStepError?: (stepNumber: number) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Кастомный метод для управления состоянием шага criticalError
|
|
39
|
+
* @param stepNumber - номер шага
|
|
40
|
+
* @return Флаг состояния error
|
|
41
|
+
*/
|
|
42
|
+
checkIsStepCriticalError?: (stepNumber: number) => boolean;
|
|
64
43
|
/**
|
|
65
44
|
* Кастомный метод для управления состоянием шага warning
|
|
66
45
|
* @param stepNumber - номер шага
|
|
@@ -90,10 +69,6 @@ type StepsProps = {
|
|
|
90
69
|
* @param stepNumber - номер активного шага
|
|
91
70
|
*/
|
|
92
71
|
onChange?: (stepNumber: number) => void;
|
|
93
|
-
|
|
94
|
-
* Идентификатор для систем автоматизированного тестирования
|
|
95
|
-
*/
|
|
96
|
-
dataTestId?: string;
|
|
97
|
-
};
|
|
72
|
+
} & CommonProps;
|
|
98
73
|
declare const Steps: React.FC<StepsProps>;
|
|
99
74
|
export { StepsProps, Steps };
|
package/esm/Component.js
CHANGED
|
@@ -2,12 +2,12 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { Step } from './components/step/Component.js';
|
|
4
4
|
|
|
5
|
-
var styles = {"component":"
|
|
5
|
+
var styles = {"component":"steps__component_4vqw7","vertical":"steps__vertical_4vqw7"};
|
|
6
6
|
require('./index.css')
|
|
7
7
|
|
|
8
8
|
var Steps = function (_a) {
|
|
9
9
|
var _b;
|
|
10
|
-
var className = _a.className, children = _a.children, _c = _a.defaultActiveStep, defaultActiveStep = _c === void 0 ? 1 : _c, activeStepProp = _a.activeStep, _d = _a.isMarkCompletedSteps, isMarkCompletedSteps = _d === void 0 ? true : _d, _e = _a.isVerticalAlign, isVerticalAlign = _e === void 0 ? false : _e, _f = _a.ordered, ordered = _f === void 0 ? true : _f, _g = _a.interactive, interactive = _g === void 0 ? true : _g, _h = _a.fullWidth, fullWidth = _h === void 0 ? false : _h, _j = _a.minSpaceBetweenSteps, minSpaceBetweenSteps = _j === void 0 ? 24 : _j, checkIsStepDisabled = _a.checkIsStepDisabled, checkIsStepError = _a.checkIsStepError, checkIsStepWarning = _a.checkIsStepWarning, checkIsStepWaiting = _a.checkIsStepWaiting, checkIsStepPositive = _a.checkIsStepPositive, checkIsStepCustom = _a.checkIsStepCustom, onChange = _a.onChange, dataTestId = _a.dataTestId;
|
|
10
|
+
var className = _a.className, children = _a.children, _c = _a.defaultActiveStep, defaultActiveStep = _c === void 0 ? 1 : _c, activeStepProp = _a.activeStep, _d = _a.isMarkCompletedSteps, isMarkCompletedSteps = _d === void 0 ? true : _d, _e = _a.isVerticalAlign, isVerticalAlign = _e === void 0 ? false : _e, _f = _a.ordered, ordered = _f === void 0 ? true : _f, _g = _a.interactive, interactive = _g === void 0 ? true : _g, _h = _a.fullWidth, fullWidth = _h === void 0 ? false : _h, _j = _a.minSpaceBetweenSteps, minSpaceBetweenSteps = _j === void 0 ? 24 : _j, checkIsStepDisabled = _a.checkIsStepDisabled, checkIsStepError = _a.checkIsStepError, checkIsStepCriticalError = _a.checkIsStepCriticalError, checkIsStepWarning = _a.checkIsStepWarning, checkIsStepWaiting = _a.checkIsStepWaiting, checkIsStepPositive = _a.checkIsStepPositive, checkIsStepCustom = _a.checkIsStepCustom, onChange = _a.onChange, dataTestId = _a.dataTestId, completedDashColor = _a.completedDashColor;
|
|
11
11
|
var uncontrolled = activeStepProp === undefined;
|
|
12
12
|
var _k = useState(defaultActiveStep), activeStep = _k[0], setActiveStep = _k[1];
|
|
13
13
|
var stepsLength = React.Children.count(children);
|
|
@@ -31,12 +31,15 @@ var Steps = function (_a) {
|
|
|
31
31
|
var disabled = checkIsStepDisabled ? checkIsStepDisabled(stepNumber) : false;
|
|
32
32
|
var isPositive = checkIsStepPositive ? checkIsStepPositive(stepNumber) : false;
|
|
33
33
|
var isError = checkIsStepError ? checkIsStepError(stepNumber) : false;
|
|
34
|
+
var isCriticalError = checkIsStepCriticalError
|
|
35
|
+
? checkIsStepCriticalError(stepNumber)
|
|
36
|
+
: false;
|
|
34
37
|
var isWarning = checkIsStepWarning ? checkIsStepWarning(stepNumber) : false;
|
|
35
38
|
var isWaiting = checkIsStepWaiting ? checkIsStepWaiting(stepNumber) : false;
|
|
36
39
|
var customStepIndicator = checkIsStepCustom && checkIsStepCustom(stepNumber);
|
|
37
40
|
var isNotLastStep = stepsLength !== stepNumber;
|
|
38
41
|
var isInteractive = !disabled && interactive;
|
|
39
|
-
return (React.createElement(Step, { stepNumber: stepNumber, isSelected: isSelected, isStepCompleted: isStepCompleted, disabled: disabled, isPositive: isPositive, isError: isError, isWarning: isWarning, isWaiting: isWaiting, customStepIndicator: customStepIndicator, onClick: handleStepClick, ordered: ordered, interactive: isInteractive, isVerticalAlign: isVerticalAlign, isNotLastStep: isNotLastStep, key: stepNumber, fullWidth: fullWidth, minSpaceBetweenSteps: minSpaceBetweenSteps }, step));
|
|
42
|
+
return (React.createElement(Step, { stepNumber: stepNumber, isSelected: isSelected, isStepCompleted: isStepCompleted, disabled: disabled, isPositive: isPositive, isError: isError, isCriticalError: isCriticalError, isWarning: isWarning, isWaiting: isWaiting, customStepIndicator: customStepIndicator, onClick: handleStepClick, ordered: ordered, interactive: isInteractive, isVerticalAlign: isVerticalAlign, isNotLastStep: isNotLastStep, key: stepNumber, fullWidth: fullWidth, minSpaceBetweenSteps: minSpaceBetweenSteps, completedDashColor: completedDashColor, dataTestId: dataTestId }, step));
|
|
40
43
|
})));
|
|
41
44
|
};
|
|
42
45
|
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CommonProps } from "../../types/common-props";
|
|
4
3
|
import { StepIndicatorProps } from "../step-indicator/index";
|
|
5
4
|
type StepProps = {
|
|
6
|
-
/**
|
|
7
|
-
* Название шага
|
|
8
|
-
*/
|
|
9
|
-
children: ReactNode;
|
|
10
5
|
/**
|
|
11
6
|
* Номер шага
|
|
12
7
|
*/
|
|
@@ -19,14 +14,6 @@ type StepProps = {
|
|
|
19
14
|
* Маркер того, что текущий шаг доступен для клика
|
|
20
15
|
*/
|
|
21
16
|
disabled: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Управление отображением номера шага
|
|
24
|
-
*/
|
|
25
|
-
ordered?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Включение / отключение интерактивности шагов
|
|
28
|
-
*/
|
|
29
|
-
interactive?: boolean;
|
|
30
17
|
/**
|
|
31
18
|
* Маркер того, что текущий шаг находится в состоянии "Positive"
|
|
32
19
|
*/
|
|
@@ -35,6 +22,10 @@ type StepProps = {
|
|
|
35
22
|
* Маркер того, что текущий шаг находится в состоянии "Error"
|
|
36
23
|
*/
|
|
37
24
|
isError: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Маркер того, что текущий шаг находится в состоянии "isCriticalError"
|
|
27
|
+
*/
|
|
28
|
+
isCriticalError: boolean;
|
|
38
29
|
/**
|
|
39
30
|
* Маркер того, что текущий шаг находится в состоянии "Warning"
|
|
40
31
|
*/
|
|
@@ -51,30 +42,15 @@ type StepProps = {
|
|
|
51
42
|
* Свойства кастомного индикатора текущего шага
|
|
52
43
|
*/
|
|
53
44
|
customStepIndicator?: StepIndicatorProps | null;
|
|
54
|
-
/**
|
|
55
|
-
* Управление ориентацией компонента
|
|
56
|
-
* @default false
|
|
57
|
-
*/
|
|
58
|
-
isVerticalAlign?: boolean;
|
|
59
45
|
/**
|
|
60
46
|
* Указывает, является ли текущий шаг последним в списке
|
|
61
47
|
*/
|
|
62
48
|
isNotLastStep?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Маркер того, что шаг растягивается на всю ширину блока
|
|
65
|
-
* для вертикальной ориентации
|
|
66
|
-
*/
|
|
67
|
-
fullWidth?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Минимальное расстояние между шагами
|
|
70
|
-
* @default 24
|
|
71
|
-
*/
|
|
72
|
-
minSpaceBetweenSteps?: 8 | 16 | 24;
|
|
73
49
|
/**
|
|
74
50
|
* Обработчик нажатия на текущей шаг
|
|
75
51
|
* @param stepNumber - номер шага
|
|
76
52
|
*/
|
|
77
53
|
onClick: (stepNumber: number) => void;
|
|
78
|
-
};
|
|
79
|
-
declare const Step:
|
|
80
|
-
export {
|
|
54
|
+
} & CommonProps;
|
|
55
|
+
declare const Step: FC<StepProps>;
|
|
56
|
+
export { Step };
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { __assign } from 'tslib';
|
|
2
2
|
import React, { useRef } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
|
+
import { getDataTestId } from '@alfalab/core-components-shared/esm';
|
|
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
|
import { StepIndicator } from '../step-indicator/Component.js';
|
|
9
11
|
|
|
10
|
-
var styles = {"step":"
|
|
12
|
+
var styles = {"step":"steps__step_1aema","horizontal":"steps__horizontal_1aema","vertical":"steps__vertical_1aema","interactive":"steps__interactive_1aema","disabled":"steps__disabled_1aema","text":"steps__text_1aema","indicator":"steps__indicator_1aema","option":"steps__option_1aema","dash":"steps__dash_1aema","completed":"steps__completed_1aema","textWrapper":"steps__textWrapper_1aema","gap-24":"steps__gap-24_1aema","gap-32":"steps__gap-32_1aema","focused":"steps__focused_1aema","selected":"steps__selected_1aema","checkbox":"steps__checkbox_1aema","dot":"steps__dot_1aema","error":"steps__error_1aema","unordered":"steps__unordered_1aema","completedIndicator":"steps__completedIndicator_1aema","fullWidth":"steps__fullWidth_1aema"};
|
|
11
13
|
require('./index.css')
|
|
12
14
|
|
|
13
|
-
var SIZE_TO_CLASSNAME_MAP = {
|
|
14
|
-
8: 'size-8',
|
|
15
|
-
16: 'size-16',
|
|
16
|
-
24: 'size-24',
|
|
17
|
-
};
|
|
18
15
|
var Step = function (_a) {
|
|
19
|
-
var _b, _c, _d, _e;
|
|
20
|
-
var children = _a.children, stepNumber = _a.stepNumber, isSelected = _a.isSelected, disabled = _a.disabled, ordered = _a.ordered, isPositive = _a.isPositive, isError = _a.isError, isWarning = _a.isWarning, isWaiting = _a.isWaiting, customStepIndicator = _a.customStepIndicator, isStepCompleted = _a.isStepCompleted, onClick = _a.onClick, interactive = _a.interactive, isVerticalAlign = _a.isVerticalAlign, isNotLastStep = _a.isNotLastStep, fullWidth = _a.fullWidth,
|
|
16
|
+
var _b, _c, _d, _e, _f;
|
|
17
|
+
var children = _a.children, stepNumber = _a.stepNumber, isSelected = _a.isSelected, disabled = _a.disabled, ordered = _a.ordered, isPositive = _a.isPositive, isError = _a.isError, isCriticalError = _a.isCriticalError, isWarning = _a.isWarning, isWaiting = _a.isWaiting, customStepIndicator = _a.customStepIndicator, isStepCompleted = _a.isStepCompleted, onClick = _a.onClick, interactive = _a.interactive, isVerticalAlign = _a.isVerticalAlign, isNotLastStep = _a.isNotLastStep, fullWidth = _a.fullWidth, _g = _a.minSpaceBetweenSteps, minSpaceBetweenSteps = _g === void 0 ? 24 : _g, completedDashColor = _a.completedDashColor, dataTestId = _a.dataTestId;
|
|
21
18
|
var stepRef = useRef(null);
|
|
22
19
|
var focused = useFocus(stepRef, 'keyboard')[0];
|
|
23
20
|
var handleButtonClick = function () {
|
|
@@ -39,6 +36,9 @@ var Step = function (_a) {
|
|
|
39
36
|
if (customStepIndicator) {
|
|
40
37
|
return React.createElement(StepIndicator, __assign({}, customStepIndicator));
|
|
41
38
|
}
|
|
39
|
+
if (isCriticalError) {
|
|
40
|
+
return React.createElement(StepIndicator, { iconColor: 'negative', content: React.createElement(CrossCompactMIcon, null) });
|
|
41
|
+
}
|
|
42
42
|
if (isError) {
|
|
43
43
|
return React.createElement(StepIndicator, { iconColor: 'negative', content: React.createElement(ExclamationCircleMIcon, null) });
|
|
44
44
|
}
|
|
@@ -60,14 +60,22 @@ var Step = function (_a) {
|
|
|
60
60
|
}
|
|
61
61
|
return stepNumber;
|
|
62
62
|
};
|
|
63
|
+
var getCustomDashColor = function () {
|
|
64
|
+
if (isStepCompleted && completedDashColor) {
|
|
65
|
+
return {
|
|
66
|
+
borderColor: completedDashColor,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {};
|
|
70
|
+
};
|
|
63
71
|
var renderDash = function () {
|
|
64
72
|
var _a;
|
|
65
73
|
return (React.createElement("div", { className: cn(styles.dash, (_a = {},
|
|
66
74
|
_a[styles.vertical] = isVerticalAlign,
|
|
67
75
|
_a[styles.completed] = isStepCompleted,
|
|
68
|
-
_a),
|
|
76
|
+
_a)), style: __assign({}, getCustomDashColor()) }));
|
|
69
77
|
};
|
|
70
|
-
return (React.createElement("div", { role: 'button', tabIndex: 0, ref: stepRef, className: cn(styles.step, (_b = {},
|
|
78
|
+
return (React.createElement("div", { "data-test-id": getDataTestId(dataTestId, 'step'), role: 'button', tabIndex: 0, ref: stepRef, className: cn(styles.step, (_b = {},
|
|
71
79
|
_b[styles.completed] = isStepCompleted,
|
|
72
80
|
_b[styles.error] = isError,
|
|
73
81
|
_b[styles.selected] = isSelected,
|
|
@@ -76,6 +84,7 @@ var Step = function (_a) {
|
|
|
76
84
|
_b[styles.vertical] = isVerticalAlign,
|
|
77
85
|
_b[styles.interactive] = interactive,
|
|
78
86
|
_b[styles.fullWidth] = fullWidth && isVerticalAlign,
|
|
87
|
+
_b[styles.horizontal] = !isVerticalAlign,
|
|
79
88
|
_b)), onClick: handleButtonClick, onKeyDown: handleKeyDown },
|
|
80
89
|
React.createElement("div", { className: cn(styles.indicator, (_c = {},
|
|
81
90
|
_c[styles.vertical] = isVerticalAlign,
|
|
@@ -87,10 +96,13 @@ var Step = function (_a) {
|
|
|
87
96
|
_d[styles.error] = isError,
|
|
88
97
|
_d)) }, getStepIndicator()),
|
|
89
98
|
isNotLastStep && isVerticalAlign && renderDash()),
|
|
90
|
-
React.createElement("div", { className: cn(styles.
|
|
91
|
-
_e[styles.
|
|
92
|
-
_e
|
|
93
|
-
|
|
99
|
+
React.createElement("div", { className: cn(styles.textWrapper, styles["gap-".concat(minSpaceBetweenSteps)], (_e = {},
|
|
100
|
+
_e[styles.vertical] = isVerticalAlign,
|
|
101
|
+
_e)) },
|
|
102
|
+
React.createElement("div", { className: cn(styles.text, (_f = {},
|
|
103
|
+
_f[styles.interactive] = interactive,
|
|
104
|
+
_f[styles.fullWidth] = fullWidth && isVerticalAlign,
|
|
105
|
+
_f)), onClick: handleTextClick }, children)),
|
|
94
106
|
isNotLastStep && !isVerticalAlign && renderDash()));
|
|
95
107
|
};
|
|
96
108
|
|