@alfalab/core-components-steps 1.6.3 → 1.7.1
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.js +1 -1
- package/components/step/Component.js +1 -1
- package/components/step/index.css +33 -32
- package/components/step-indicator/Component.js +1 -1
- package/components/step-indicator/index.css +23 -3
- package/cssm/components/step/index.module.css +2 -1
- package/cssm/components/step-indicator/index.module.css +22 -2
- package/esm/Component.js +1 -1
- package/esm/components/step/Component.js +1 -1
- package/esm/components/step/index.css +33 -32
- package/esm/components/step-indicator/Component.js +1 -1
- package/esm/components/step-indicator/index.css +23 -3
- package/esm/index.css +3 -3
- package/index.css +3 -3
- package/modern/Component.js +1 -1
- package/modern/components/step/Component.js +1 -1
- package/modern/components/step/index.css +33 -32
- package/modern/components/step-indicator/Component.js +1 -1
- package/modern/components/step-indicator/index.css +23 -3
- package/modern/index.css +3 -3
- package/moderncssm/Component.d.ts +99 -0
- package/moderncssm/Component.js +39 -0
- package/moderncssm/components/step/Component.d.ts +80 -0
- package/moderncssm/components/step/Component.js +89 -0
- package/moderncssm/components/step/index.d.ts +1 -0
- package/moderncssm/components/step/index.js +1 -0
- package/moderncssm/components/step/index.module.css +170 -0
- package/moderncssm/components/step-indicator/Component.d.ts +6 -0
- package/moderncssm/components/step-indicator/Component.js +8 -0
- package/moderncssm/components/step-indicator/index.d.ts +1 -0
- package/moderncssm/components/step-indicator/index.js +1 -0
- package/moderncssm/components/step-indicator/index.module.css +5 -0
- package/moderncssm/index.d.ts +1 -0
- package/moderncssm/index.js +1 -0
- package/moderncssm/index.module.css +12 -0
- package/package.json +4 -4
- package/src/components/step/index.module.css +2 -2
- package/src/components/step-indicator/index.module.css +3 -1
- package/src/index.module.css +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { StepIndicatorProps } from "../step-indicator/index";
|
|
5
|
+
type StepProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Название шага
|
|
8
|
+
*/
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Номер шага
|
|
12
|
+
*/
|
|
13
|
+
stepNumber: number;
|
|
14
|
+
/**
|
|
15
|
+
* Маркер того, что текущий шаг выбран
|
|
16
|
+
*/
|
|
17
|
+
isSelected: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Маркер того, что текущий шаг доступен для клика
|
|
20
|
+
*/
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Управление отображением номера шага
|
|
24
|
+
*/
|
|
25
|
+
ordered?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Включение / отключение интерактивности шагов
|
|
28
|
+
*/
|
|
29
|
+
interactive?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Маркер того, что текущий шаг находится в состоянии "Positive"
|
|
32
|
+
*/
|
|
33
|
+
isPositive: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Маркер того, что текущий шаг находится в состоянии "Error"
|
|
36
|
+
*/
|
|
37
|
+
isError: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Маркер того, что текущий шаг находится в состоянии "Warning"
|
|
40
|
+
*/
|
|
41
|
+
isWarning: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Маркер того, что текущий шаг находится в состоянии "Waiting"
|
|
44
|
+
*/
|
|
45
|
+
isWaiting: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Маркер того, что текущий шаг нужно пометить как завершенный
|
|
48
|
+
*/
|
|
49
|
+
isStepCompleted: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Свойства кастомного индикатора текущего шага
|
|
52
|
+
*/
|
|
53
|
+
customStepIndicator?: StepIndicatorProps | null;
|
|
54
|
+
/**
|
|
55
|
+
* Управление ориентацией компонента
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
isVerticalAlign?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Указывает, является ли текущий шаг последним в списке
|
|
61
|
+
*/
|
|
62
|
+
isNotLastStep?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Маркер того, что шаг растягивается на всю ширину блока
|
|
65
|
+
* для вертикальной ориентации
|
|
66
|
+
*/
|
|
67
|
+
fullWidth?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Минимальное расстояние между шагами
|
|
70
|
+
* @default 24
|
|
71
|
+
*/
|
|
72
|
+
minSpaceBetweenSteps?: 8 | 16 | 24;
|
|
73
|
+
/**
|
|
74
|
+
* Обработчик нажатия на текущей шаг
|
|
75
|
+
* @param stepNumber - номер шага
|
|
76
|
+
*/
|
|
77
|
+
onClick: (stepNumber: number) => void;
|
|
78
|
+
};
|
|
79
|
+
declare const Step: React.FC<StepProps>;
|
|
80
|
+
export { StepProps, Step };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { useFocus } from '@alfalab/hooks';
|
|
4
|
+
import { CheckmarkCircleMIcon } from '@alfalab/icons-glyph/CheckmarkCircleMIcon';
|
|
5
|
+
import { ClockMIcon } from '@alfalab/icons-glyph/ClockMIcon';
|
|
6
|
+
import { ExclamationCircleMIcon } from '@alfalab/icons-glyph/ExclamationCircleMIcon';
|
|
7
|
+
import { StepIndicator } from '../step-indicator/Component.js';
|
|
8
|
+
import styles from './index.module.css';
|
|
9
|
+
|
|
10
|
+
const SIZE_TO_CLASSNAME_MAP = {
|
|
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, }) => {
|
|
16
|
+
const stepRef = useRef(null);
|
|
17
|
+
const [focused] = useFocus(stepRef, 'keyboard');
|
|
18
|
+
const handleButtonClick = () => {
|
|
19
|
+
if (!disabled && interactive && onClick) {
|
|
20
|
+
onClick(stepNumber);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const handleTextClick = (e) => {
|
|
24
|
+
if (!interactive) {
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const handleKeyDown = (event) => {
|
|
29
|
+
if (event.key === 'Enter') {
|
|
30
|
+
handleButtonClick();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const getStepIndicator = () => {
|
|
34
|
+
if (customStepIndicator) {
|
|
35
|
+
return React.createElement(StepIndicator, { ...customStepIndicator });
|
|
36
|
+
}
|
|
37
|
+
if (isError) {
|
|
38
|
+
return React.createElement(StepIndicator, { iconColor: 'negative', content: React.createElement(ExclamationCircleMIcon, null) });
|
|
39
|
+
}
|
|
40
|
+
if (isWarning) {
|
|
41
|
+
return React.createElement(StepIndicator, { iconColor: 'attention', content: React.createElement(ExclamationCircleMIcon, null) });
|
|
42
|
+
}
|
|
43
|
+
if (isWaiting) {
|
|
44
|
+
return React.createElement(StepIndicator, { iconColor: 'secondary', content: React.createElement(ClockMIcon, null) });
|
|
45
|
+
}
|
|
46
|
+
if (isPositive) {
|
|
47
|
+
return React.createElement(StepIndicator, { iconColor: 'positive', content: React.createElement(CheckmarkCircleMIcon, null) });
|
|
48
|
+
}
|
|
49
|
+
if (isStepCompleted) {
|
|
50
|
+
return (React.createElement(StepIndicator, { iconColor: 'positive', content: React.createElement(CheckmarkCircleMIcon, null), className: styles.completedIndicator }));
|
|
51
|
+
}
|
|
52
|
+
if (!ordered) {
|
|
53
|
+
return (React.createElement("div", { className: styles.checkbox },
|
|
54
|
+
React.createElement("span", { className: styles.dot })));
|
|
55
|
+
}
|
|
56
|
+
return stepNumber;
|
|
57
|
+
};
|
|
58
|
+
const renderDash = () => (React.createElement("div", { className: cn(styles.dash, {
|
|
59
|
+
[styles.vertical]: isVerticalAlign,
|
|
60
|
+
[styles.completed]: isStepCompleted,
|
|
61
|
+
}, styles[SIZE_TO_CLASSNAME_MAP[minSpaceBetweenSteps]]) }));
|
|
62
|
+
return (React.createElement("div", { role: 'button', tabIndex: 0, ref: stepRef, className: cn(styles.step, {
|
|
63
|
+
[styles.completed]: isStepCompleted,
|
|
64
|
+
[styles.error]: isError,
|
|
65
|
+
[styles.selected]: isSelected,
|
|
66
|
+
[styles.disabled]: disabled,
|
|
67
|
+
[styles.focused]: focused,
|
|
68
|
+
[styles.vertical]: isVerticalAlign,
|
|
69
|
+
[styles.interactive]: interactive,
|
|
70
|
+
[styles.fullWidth]: fullWidth && isVerticalAlign,
|
|
71
|
+
}), onClick: handleButtonClick, onKeyDown: handleKeyDown },
|
|
72
|
+
React.createElement("div", { className: cn(styles.indicator, {
|
|
73
|
+
[styles.vertical]: isVerticalAlign,
|
|
74
|
+
[styles.interactive]: interactive,
|
|
75
|
+
}) },
|
|
76
|
+
React.createElement("div", { className: cn(styles.option, {
|
|
77
|
+
[styles.unordered]: !ordered,
|
|
78
|
+
[styles.vertical]: isVerticalAlign,
|
|
79
|
+
[styles.error]: isError,
|
|
80
|
+
}) }, getStepIndicator()),
|
|
81
|
+
isNotLastStep && isVerticalAlign && renderDash()),
|
|
82
|
+
React.createElement("div", { className: cn(styles.text, {
|
|
83
|
+
[styles.interactive]: interactive,
|
|
84
|
+
[styles.fullWidth]: fullWidth && isVerticalAlign,
|
|
85
|
+
}), onClick: handleTextClick }, children),
|
|
86
|
+
isNotLastStep && !isVerticalAlign && renderDash()));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { Step };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Step } from './Component.js';
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--steps-option-svg-color: var(--color-light-status-positive);
|
|
5
|
+
--steps-dash-border: 2px solid var(--color-light-status-positive);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.step {
|
|
9
|
+
display: flex;
|
|
10
|
+
outline: none
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.step:not(.vertical) {
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.step.interactive:not(.disabled):hover {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.step.disabled:hover .text {
|
|
22
|
+
background: unset;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.step.disabled .indicator {
|
|
26
|
+
cursor: unset;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.indicator {
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
margin-right: var(--gap-4)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.indicator.vertical {
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
margin-right: var(--gap-8);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.option {
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
line-height: 20px;
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
color: var(--color-light-text-primary);
|
|
50
|
+
background: var(--color-light-neutral-translucent-300);
|
|
51
|
+
min-width: 24px;
|
|
52
|
+
height: 24px;
|
|
53
|
+
border-radius: var(--border-radius-circle)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.option.vertical {
|
|
57
|
+
margin-top: var(--gap-8);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.dash {
|
|
61
|
+
flex: 1 1 auto;
|
|
62
|
+
min-width: 24px;
|
|
63
|
+
border-top: 2px solid var(--color-light-neutral-translucent-300);
|
|
64
|
+
margin-right: var(--gap-8)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.dash.size-16 {
|
|
68
|
+
min-width: 16px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.dash.size-8 {
|
|
72
|
+
min-width: 8px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.dash.completed {
|
|
76
|
+
border-top: var(--steps-dash-border);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.dash.vertical {
|
|
80
|
+
min-width: unset;
|
|
81
|
+
min-height: 24px;
|
|
82
|
+
margin-right: var(--gap-0);
|
|
83
|
+
margin-top: var(--gap-8);
|
|
84
|
+
border-left: 2px solid var(--color-light-neutral-translucent-300);
|
|
85
|
+
border-top: none
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dash.vertical.size-16 {
|
|
89
|
+
min-height: 16px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.dash.vertical.size-8 {
|
|
93
|
+
min-height: 8px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.dash.completed.vertical {
|
|
97
|
+
border-left: var(--steps-dash-border);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.text {
|
|
101
|
+
font-size: 16px;
|
|
102
|
+
line-height: 24px;
|
|
103
|
+
font-weight: 400;
|
|
104
|
+
|
|
105
|
+
transition: background 0.2s;
|
|
106
|
+
padding: var(--gap-8);
|
|
107
|
+
color: var(--color-light-text-primary);
|
|
108
|
+
border-radius: var(--gap-8);
|
|
109
|
+
height: min-content
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.text.interactive:not(.disabled):hover {
|
|
113
|
+
background: var(--color-light-transparent-default-hover);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.text.interactive:not(.disabled):active {
|
|
117
|
+
background: var(--color-light-transparent-default-press);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.focused {
|
|
121
|
+
outline: var(--gap-2) solid var(--focus-color);
|
|
122
|
+
outline-offset: var(--gap-2);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.selected .text {
|
|
126
|
+
color: var(--color-light-text-primary);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.selected .option {
|
|
130
|
+
color: var(--color-light-text-primary-inverted);
|
|
131
|
+
background: var(--color-light-neutral-translucent-1300);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.checkbox {
|
|
135
|
+
display: flex;
|
|
136
|
+
justify-content: center;
|
|
137
|
+
align-items: center;
|
|
138
|
+
border-radius: var(--border-radius-circle);
|
|
139
|
+
width: 20px;
|
|
140
|
+
height: 20px;
|
|
141
|
+
border: 2px solid var(--color-light-neutral-translucent-300);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.dot {
|
|
145
|
+
width: 10px;
|
|
146
|
+
height: 10px;
|
|
147
|
+
border-radius: var(--border-radius-circle);
|
|
148
|
+
background: var(--color-light-neutral-translucent-300);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.selected .checkbox {
|
|
152
|
+
border: 2px solid var(--color-light-neutral-translucent-1300)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.selected .checkbox .dot {
|
|
156
|
+
background: var(--color-light-neutral-translucent-1300);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.option:not(.error).unordered {
|
|
160
|
+
background: unset;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.completedIndicator > [class*='positive'] {
|
|
164
|
+
color: var(--steps-option-svg-color);
|
|
165
|
+
background-color: var(--steps-option-svg-color);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.fullWidth {
|
|
169
|
+
width: 100%;
|
|
170
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BadgeProps } from "@alfalab/core-components-badge";
|
|
4
|
+
type StepIndicatorProps = Pick<BadgeProps, 'content' | 'iconColor' | 'className'>;
|
|
5
|
+
declare const StepIndicator: React.FC<StepIndicatorProps>;
|
|
6
|
+
export { StepIndicatorProps, StepIndicator };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Badge } from '@alfalab/core-components-badge/moderncssm';
|
|
4
|
+
import styles from './index.module.css';
|
|
5
|
+
|
|
6
|
+
const StepIndicator = ({ content, iconColor, className }) => (React.createElement(Badge, { size: 'l', view: 'icon', iconColor: iconColor, className: cn(styles.component, className), content: content }));
|
|
7
|
+
|
|
8
|
+
export { StepIndicator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StepIndicator } from './Component.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Steps } from './Component.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-steps",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@alfalab/core-components-badge": "^5.
|
|
17
|
+
"@alfalab/core-components-badge": "^5.6.1",
|
|
18
18
|
"@alfalab/hooks": "^1.13.0",
|
|
19
19
|
"@alfalab/icons-glyph": "^2.139.0",
|
|
20
20
|
"classnames": "^2.3.1",
|
|
21
21
|
"tslib": "^2.4.0"
|
|
22
22
|
},
|
|
23
|
-
"themesVersion": "13.0
|
|
24
|
-
"varsVersion": "9.
|
|
23
|
+
"themesVersion": "13.2.0",
|
|
24
|
+
"varsVersion": "9.13.0"
|
|
25
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import '@alfalab/core-components-
|
|
1
|
+
@import '@alfalab/core-components-vars/src/index.css';
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
4
|
--steps-option-svg-color: var(--color-light-status-positive);
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
&.vertical {
|
|
81
81
|
min-width: unset;
|
|
82
82
|
min-height: 24px;
|
|
83
|
-
margin-right: 0;
|
|
83
|
+
margin-right: var(--gap-0);
|
|
84
84
|
margin-top: var(--gap-8);
|
|
85
85
|
border-left: 2px solid var(--color-light-neutral-translucent-300);
|
|
86
86
|
border-top: none;
|
package/src/index.module.css
CHANGED