@alfalab/core-components-steps 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/Component.d.ts +89 -0
  2. package/Component.js +59 -0
  3. package/components/step/Component.d.ts +70 -0
  4. package/components/step/Component.js +126 -0
  5. package/components/step/index.css +151 -0
  6. package/components/step/index.d.ts +1 -0
  7. package/components/step/index.js +17 -0
  8. package/components/step-indicator/Component.d.ts +6 -0
  9. package/components/step-indicator/Component.js +22 -0
  10. package/components/step-indicator/index.css +4 -0
  11. package/components/step-indicator/index.d.ts +1 -0
  12. package/components/step-indicator/index.js +12 -0
  13. package/cssm/Component.d.ts +89 -0
  14. package/cssm/Component.js +60 -0
  15. package/cssm/components/step/Component.d.ts +70 -0
  16. package/cssm/components/step/Component.js +126 -0
  17. package/cssm/components/step/index.d.ts +1 -0
  18. package/cssm/components/step/index.js +19 -0
  19. package/cssm/components/step/index.module.css +150 -0
  20. package/cssm/components/step-indicator/Component.d.ts +6 -0
  21. package/cssm/components/step-indicator/Component.js +21 -0
  22. package/cssm/components/step-indicator/index.d.ts +1 -0
  23. package/cssm/components/step-indicator/index.js +13 -0
  24. package/cssm/components/step-indicator/index.module.css +3 -0
  25. package/cssm/index.d.ts +1 -0
  26. package/cssm/index.js +21 -0
  27. package/cssm/index.module.css +17 -0
  28. package/esm/Component.d.ts +89 -0
  29. package/esm/Component.js +50 -0
  30. package/esm/components/step/Component.d.ts +70 -0
  31. package/esm/components/step/Component.js +117 -0
  32. package/esm/components/step/index.css +151 -0
  33. package/esm/components/step/index.d.ts +1 -0
  34. package/esm/components/step/index.js +9 -0
  35. package/esm/components/step-indicator/Component.d.ts +6 -0
  36. package/esm/components/step-indicator/Component.js +13 -0
  37. package/esm/components/step-indicator/index.css +4 -0
  38. package/esm/components/step-indicator/index.d.ts +1 -0
  39. package/esm/components/step-indicator/index.js +4 -0
  40. package/esm/index.css +18 -0
  41. package/esm/index.d.ts +1 -0
  42. package/esm/index.js +10 -0
  43. package/index.css +18 -0
  44. package/index.d.ts +1 -0
  45. package/index.js +18 -0
  46. package/modern/Component.d.ts +89 -0
  47. package/modern/Component.js +48 -0
  48. package/modern/components/step/Component.d.ts +70 -0
  49. package/modern/components/step/Component.js +85 -0
  50. package/modern/components/step/index.css +151 -0
  51. package/modern/components/step/index.d.ts +1 -0
  52. package/modern/components/step/index.js +9 -0
  53. package/modern/components/step-indicator/Component.d.ts +6 -0
  54. package/modern/components/step-indicator/Component.js +12 -0
  55. package/modern/components/step-indicator/index.css +4 -0
  56. package/modern/components/step-indicator/index.d.ts +1 -0
  57. package/modern/components/step-indicator/index.js +4 -0
  58. package/modern/index.css +18 -0
  59. package/modern/index.d.ts +1 -0
  60. package/modern/index.js +10 -0
  61. package/package.json +25 -0
  62. package/send-stats.js +82 -0
@@ -0,0 +1,70 @@
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;
54
+ /**
55
+ * Управление ориентацией компонента
56
+ * @default false
57
+ */
58
+ isVerticalAlign?: boolean;
59
+ /**
60
+ * Указывает, является ли текущий шаг последним в списке
61
+ */
62
+ isNotLastStep?: boolean;
63
+ /**
64
+ * Обработчик нажатия на текущей шаг
65
+ * @param stepNumber - номер шага
66
+ */
67
+ onClick: (stepNumber: number) => void;
68
+ };
69
+ declare const Step: React.FC<StepProps>;
70
+ export { StepProps, Step };
@@ -0,0 +1,117 @@
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 { ExclamationCircleMIcon } from '@alfalab/icons-glyph/ExclamationCircleMIcon';
6
+ import { ClockMIcon } from '@alfalab/icons-glyph/ClockMIcon';
7
+ import '@alfalab/core-components-badge/esm';
8
+ import { StepIndicator } from '../step-indicator/Component.js';
9
+
10
+ /*! *****************************************************************************
11
+ Copyright (c) Microsoft Corporation.
12
+
13
+ Permission to use, copy, modify, and/or distribute this software for any
14
+ purpose with or without fee is hereby granted.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
17
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
19
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
+ PERFORMANCE OF THIS SOFTWARE.
23
+ ***************************************************************************** */
24
+ var __assign = function () {
25
+ __assign = Object.assign || function __assign(t) {
26
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
27
+ s = arguments[i];
28
+ for (var p in s)
29
+ if (Object.prototype.hasOwnProperty.call(s, p))
30
+ t[p] = s[p];
31
+ }
32
+ return t;
33
+ };
34
+ return __assign.apply(this, arguments);
35
+ };
36
+
37
+ var styles = {"step":"steps__step_xhvt7","vertical":"steps__vertical_xhvt7","interactive":"steps__interactive_xhvt7","disabled":"steps__disabled_xhvt7","text":"steps__text_xhvt7","indicator":"steps__indicator_xhvt7","option":"steps__option_xhvt7","dash":"steps__dash_xhvt7","completed":"steps__completed_xhvt7","focused":"steps__focused_xhvt7","selected":"steps__selected_xhvt7","checkbox":"steps__checkbox_xhvt7","dot":"steps__dot_xhvt7","error":"steps__error_xhvt7","unordered":"steps__unordered_xhvt7","completedIndicator":"steps__completedIndicator_xhvt7"};
38
+ require('./index.css')
39
+
40
+ var Step = function (_a) {
41
+ var _b, _c, _d, _e;
42
+ 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;
43
+ var stepRef = useRef(null);
44
+ var focused = useFocus(stepRef, 'keyboard')[0];
45
+ var handleButtonClick = function () {
46
+ if (!disabled && onClick) {
47
+ onClick(stepNumber);
48
+ }
49
+ };
50
+ var handleTextClick = function (e) {
51
+ if (!interactive) {
52
+ e.stopPropagation();
53
+ }
54
+ };
55
+ var handleKeyDown = function (event) {
56
+ if (event.key === 'Enter') {
57
+ handleButtonClick();
58
+ }
59
+ };
60
+ var getStepIndicator = function () {
61
+ if (customStepIndicator) {
62
+ return React.createElement(StepIndicator, __assign({}, customStepIndicator));
63
+ }
64
+ if (isError) {
65
+ return React.createElement(StepIndicator, { iconColor: 'negative', content: React.createElement(ExclamationCircleMIcon, null) });
66
+ }
67
+ if (isWarning) {
68
+ return React.createElement(StepIndicator, { iconColor: 'attention', content: React.createElement(ExclamationCircleMIcon, null) });
69
+ }
70
+ if (isWaiting) {
71
+ return React.createElement(StepIndicator, { iconColor: 'secondary', content: React.createElement(ClockMIcon, null) });
72
+ }
73
+ if (isPositive) {
74
+ return React.createElement(StepIndicator, { iconColor: 'positive', content: React.createElement(CheckmarkCircleMIcon, null) });
75
+ }
76
+ if (isStepCompleted) {
77
+ return React.createElement(StepIndicator, { iconColor: 'positive', content: React.createElement(CheckmarkCircleMIcon, null), className: styles.completedIndicator });
78
+ }
79
+ if (!ordered) {
80
+ return (React.createElement("div", { className: styles.checkbox },
81
+ React.createElement("span", { className: styles.dot })));
82
+ }
83
+ return stepNumber;
84
+ };
85
+ var renderDash = function () {
86
+ var _a;
87
+ return (React.createElement("div", { className: cn(styles.dash, (_a = {},
88
+ _a[styles.vertical] = isVerticalAlign,
89
+ _a[styles.completed] = isStepCompleted,
90
+ _a)) }));
91
+ };
92
+ return (React.createElement("div", { role: 'button', tabIndex: 0, ref: stepRef, className: cn(styles.step, (_b = {},
93
+ _b[styles.completed] = isStepCompleted,
94
+ _b[styles.error] = isError,
95
+ _b[styles.selected] = isSelected,
96
+ _b[styles.disabled] = disabled,
97
+ _b[styles.focused] = focused,
98
+ _b[styles.vertical] = isVerticalAlign,
99
+ _b[styles.interactive] = interactive,
100
+ _b)), onClick: handleButtonClick, onKeyDown: handleKeyDown },
101
+ React.createElement("div", { className: cn(styles.indicator, (_c = {},
102
+ _c[styles.vertical] = isVerticalAlign,
103
+ _c[styles.interactive] = interactive,
104
+ _c)) },
105
+ React.createElement("div", { className: cn(styles.option, (_d = {},
106
+ _d[styles.unordered] = !ordered,
107
+ _d[styles.vertical] = isVerticalAlign,
108
+ _d[styles.error] = isError,
109
+ _d)) }, getStepIndicator()),
110
+ isNotLastStep && isVerticalAlign && renderDash()),
111
+ React.createElement("div", { className: cn(styles.text, (_e = {},
112
+ _e[styles.interactive] = interactive,
113
+ _e)), onClick: handleTextClick }, children),
114
+ isNotLastStep && !isVerticalAlign && renderDash()));
115
+ };
116
+
117
+ export { Step };
@@ -0,0 +1,151 @@
1
+ /* hash: j46l8 */
2
+ :root {
3
+ --color-light-border-link: #007aff;
4
+ --color-light-border-primary: #dbdee1;
5
+ --color-light-graphic-positive: #2fc26e;
6
+ --color-light-graphic-primary: #0b1f35;
7
+ --color-light-graphic-primary-inverted: #fff;
8
+ --color-light-graphic-quaternary: #dbdee1;
9
+ --color-light-text-primary: #0b1f35;
10
+ --color-light-bg-primary-inverted-alpha-7: rgba(11, 31, 53, 0.07);
11
+ --color-light-bg-primary-inverted-alpha-15: rgba(11, 31, 53, 0.15);
12
+ }
13
+ :root {
14
+
15
+ /* Hard */
16
+
17
+ /* Up */
18
+
19
+ /* Hard up */
20
+ }
21
+ :root {
22
+ --gap-3xs: 2px;
23
+ --gap-2xs: 4px;
24
+ --gap-xs: 8px;
25
+ }
26
+ :root {
27
+ --focus-color: var(--color-light-border-link);
28
+ }
29
+ :root {
30
+ --steps-option-svg-color: var(--color-light-graphic-positive);
31
+ --steps-dash-border: 2px solid var(--color-light-graphic-positive);
32
+ }
33
+ .steps__step_xhvt7 {
34
+ display: flex;
35
+ outline: none
36
+ }
37
+ .steps__step_xhvt7:not(.steps__vertical_xhvt7) {
38
+ align-items: center;
39
+ }
40
+ .steps__step_xhvt7.steps__interactive_xhvt7:not(.steps__disabled_xhvt7):hover {
41
+ cursor: pointer;
42
+ }
43
+ .steps__step_xhvt7.steps__disabled_xhvt7:hover .steps__text_xhvt7 {
44
+ background: unset;
45
+ }
46
+ .steps__step_xhvt7.steps__disabled_xhvt7 .steps__indicator_xhvt7 {
47
+ cursor: unset;
48
+ }
49
+ .steps__indicator_xhvt7 {
50
+ cursor: pointer;
51
+ display: flex;
52
+ align-items: center;
53
+ margin-right: var(--gap-2xs)
54
+ }
55
+ .steps__indicator_xhvt7.steps__vertical_xhvt7 {
56
+ flex-direction: column;
57
+ margin-right: var(--gap-xs);
58
+ }
59
+ .steps__option_xhvt7 {
60
+ font-size: 14px;
61
+ line-height: 20px;
62
+ font-weight: 700;
63
+
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: center;
67
+ color: var(--color-light-graphic-primary);
68
+ background: var(--color-light-graphic-quaternary);
69
+ min-width: 24px;
70
+ height: 24px;
71
+ border-radius: 50%
72
+ }
73
+ .steps__option_xhvt7.steps__vertical_xhvt7 {
74
+ margin-top: var(--gap-xs);
75
+ }
76
+ .steps__dash_xhvt7 {
77
+ flex: 1 1 auto;
78
+ min-width: 24px;
79
+ border-top: 2px solid var(--color-light-border-primary);
80
+ margin-right: var(--gap-xs)
81
+ }
82
+ .steps__dash_xhvt7.steps__completed_xhvt7 {
83
+ border-top: var(--steps-dash-border);
84
+ }
85
+ .steps__dash_xhvt7.steps__vertical_xhvt7 {
86
+ min-width: unset;
87
+ min-height: 24px;
88
+ margin-right: 0;
89
+ margin-top: var(--gap-xs);
90
+ border-left: 2px solid var(--color-light-border-primary);
91
+ border-top: none;
92
+ }
93
+ .steps__dash_xhvt7.steps__completed_xhvt7.steps__vertical_xhvt7 {
94
+ border-left: var(--steps-dash-border);
95
+ }
96
+ .steps__text_xhvt7 {
97
+ font-size: 16px;
98
+ line-height: 24px;
99
+ font-weight: 400;
100
+
101
+ transition: background 0.2s;
102
+ padding: var(--gap-xs);
103
+ color: var(--color-light-text-primary);
104
+ border-radius: var(--gap-xs);
105
+ height: min-content
106
+ }
107
+ .steps__text_xhvt7.steps__interactive_xhvt7:not(.steps__disabled_xhvt7):hover {
108
+ background: var(--color-light-bg-primary-inverted-alpha-7);
109
+ }
110
+ .steps__text_xhvt7.steps__interactive_xhvt7:not(.steps__disabled_xhvt7):active {
111
+ background: var(--color-light-bg-primary-inverted-alpha-15);
112
+ }
113
+ .steps__focused_xhvt7 {
114
+ outline: var(--gap-3xs) solid var(--focus-color);
115
+ outline-offset: var(--gap-3xs);
116
+ }
117
+ .steps__selected_xhvt7 .steps__text_xhvt7 {
118
+ color: var(--color-light-graphic-primary);
119
+ }
120
+ .steps__selected_xhvt7 .steps__option_xhvt7 {
121
+ color: var(--color-light-graphic-primary-inverted);
122
+ background: var(--color-light-graphic-primary);
123
+ }
124
+ .steps__checkbox_xhvt7 {
125
+ display: flex;
126
+ justify-content: center;
127
+ align-items: center;
128
+ border-radius: 50%;
129
+ width: 20px;
130
+ height: 20px;
131
+ border: 2px solid var(--color-light-graphic-quaternary);
132
+ }
133
+ .steps__dot_xhvt7 {
134
+ width: 10px;
135
+ height: 10px;
136
+ border-radius: 50%;
137
+ background: var(--color-light-graphic-quaternary);
138
+ }
139
+ .steps__selected_xhvt7 .steps__checkbox_xhvt7 {
140
+ border: 2px solid var(--color-light-graphic-primary)
141
+ }
142
+ .steps__selected_xhvt7 .steps__checkbox_xhvt7 .steps__dot_xhvt7 {
143
+ background: var(--color-light-graphic-primary);
144
+ }
145
+ .steps__option_xhvt7:not(.steps__error_xhvt7).steps__unordered_xhvt7 {
146
+ background: unset;
147
+ }
148
+ .steps__completedIndicator_xhvt7 > [class*='positive'] {
149
+ color: var(--steps-option-svg-color);
150
+ background-color: var(--steps-option-svg-color);
151
+ }
@@ -0,0 +1 @@
1
+ export * from "./Component";
@@ -0,0 +1,9 @@
1
+ import 'react';
2
+ import 'classnames';
3
+ export { Step } from './Component.js';
4
+ import '@alfalab/hooks';
5
+ import '@alfalab/icons-glyph/CheckmarkCircleMIcon';
6
+ import '@alfalab/icons-glyph/ExclamationCircleMIcon';
7
+ import '@alfalab/icons-glyph/ClockMIcon';
8
+ import '@alfalab/core-components-badge/esm';
9
+ import '../step-indicator/Component.js';
@@ -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,13 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { Badge } from '@alfalab/core-components-badge/esm';
4
+
5
+ var styles = {"component":"steps__component_19vei"};
6
+ require('./index.css')
7
+
8
+ var StepIndicator = function (_a) {
9
+ var content = _a.content, iconColor = _a.iconColor, className = _a.className;
10
+ return (React.createElement(Badge, { size: 'l', view: 'icon', iconColor: iconColor, className: cn(styles.component, className), content: content }));
11
+ };
12
+
13
+ export { StepIndicator };
@@ -0,0 +1,4 @@
1
+ /* hash: crmt3 */
2
+ .steps__component_19vei {
3
+ padding: 0;
4
+ }
@@ -0,0 +1 @@
1
+ export * from "./Component";
@@ -0,0 +1,4 @@
1
+ import 'react';
2
+ import 'classnames';
3
+ import '@alfalab/core-components-badge/esm';
4
+ export { StepIndicator } from './Component.js';
package/esm/index.css ADDED
@@ -0,0 +1,18 @@
1
+ /* hash: hx0e0 */
2
+ :root {
3
+
4
+ /* Hard */
5
+
6
+ /* Up */
7
+
8
+ /* Hard up */
9
+ }
10
+ .steps__component_rm960 {
11
+ display: flex;
12
+ align-items: center;
13
+ flex-direction: row
14
+ }
15
+ .steps__component_rm960.steps__vertical_rm960 {
16
+ flex-direction: column;
17
+ align-items: flex-start;
18
+ }
package/esm/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./Component";
package/esm/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import 'react';
2
+ import 'classnames';
3
+ import './components/step/Component.js';
4
+ import '@alfalab/hooks';
5
+ import '@alfalab/icons-glyph/CheckmarkCircleMIcon';
6
+ import '@alfalab/icons-glyph/ExclamationCircleMIcon';
7
+ import '@alfalab/icons-glyph/ClockMIcon';
8
+ import '@alfalab/core-components-badge/esm';
9
+ import './components/step-indicator/Component.js';
10
+ export { Steps } from './Component.js';
package/index.css ADDED
@@ -0,0 +1,18 @@
1
+ /* hash: hx0e0 */
2
+ :root {
3
+
4
+ /* Hard */
5
+
6
+ /* Up */
7
+
8
+ /* Hard up */
9
+ }
10
+ .steps__component_rm960 {
11
+ display: flex;
12
+ align-items: center;
13
+ flex-direction: row
14
+ }
15
+ .steps__component_rm960.steps__vertical_rm960 {
16
+ flex-direction: column;
17
+ align-items: flex-start;
18
+ }
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./Component";
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('react');
6
+ require('classnames');
7
+ require('./components/step/Component.js');
8
+ require('@alfalab/hooks');
9
+ require('@alfalab/icons-glyph/CheckmarkCircleMIcon');
10
+ require('@alfalab/icons-glyph/ExclamationCircleMIcon');
11
+ require('@alfalab/icons-glyph/ClockMIcon');
12
+ require('@alfalab/core-components-badge');
13
+ require('./components/step-indicator/Component.js');
14
+ var Component = require('./Component.js');
15
+
16
+
17
+
18
+ exports.Steps = Component.Steps;
@@ -0,0 +1,89 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { ReactNode } from "react";
4
+ import { StepIndicatorProps } from "./components/step-indicator/index";
5
+ type StepsProps = {
6
+ /**
7
+ * Дополнительный класс
8
+ */
9
+ className?: string;
10
+ /**
11
+ * Дочерние элементы
12
+ */
13
+ children: ReactNode;
14
+ /**
15
+ * Активный шаг, указанный по умолчанию
16
+ * @default 1
17
+ */
18
+ defaultActiveStep?: number;
19
+ /**
20
+ * Активный шаг
21
+ */
22
+ activeStep?: number;
23
+ /**
24
+ * Управление возможностью отключения пометки пройденного шага
25
+ * @default true
26
+ */
27
+ 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
+ * Кастомный метод для управления состоянием disabled шага и
43
+ * возможностью перехода на этот шаг
44
+ * @param stepNumber - номер шага
45
+ * @return Флаг состояния disabled
46
+ */
47
+ checkIsStepDisabled?: (stepNumber: number) => boolean;
48
+ /**
49
+ * Кастомный метод для управления состоянием шага error
50
+ * @param stepNumber - номер шага
51
+ * @return Флаг состояния error
52
+ */
53
+ checkIsStepError?: (stepNumber: number) => boolean;
54
+ /**
55
+ * Кастомный метод для управления состоянием шага warning
56
+ * @param stepNumber - номер шага
57
+ * @return Флаг состояния warning
58
+ */
59
+ checkIsStepWarning?: (stepNumber: number) => boolean;
60
+ /**
61
+ * Кастомный метод для управления состоянием шага waiting
62
+ * @param stepNumber - номер шага
63
+ * @return Флаг состояния waiting
64
+ */
65
+ checkIsStepWaiting?: (stepNumber: number) => boolean;
66
+ /**
67
+ * Кастомный метод для управления состоянием шага positive
68
+ * @param stepNumber - номер шага
69
+ * @return Флаг состояния positive
70
+ */
71
+ checkIsStepPositive?: (stepNumber: number) => boolean;
72
+ /**
73
+ * Кастомный метод для установки кастомного индикатора шага
74
+ * @param stepNumber - номер шага
75
+ * @return Объект StepIndicatorProps { className, content, iconColor }
76
+ */
77
+ checkIsStepCustom?: (stepNumber: number) => StepIndicatorProps;
78
+ /**
79
+ * Обработчик клика на шаг
80
+ * @param stepNumber - номер активного шага
81
+ */
82
+ onChange?: (stepNumber: number) => void;
83
+ /**
84
+ * Идентификатор для систем автоматизированного тестирования
85
+ */
86
+ dataTestId?: string;
87
+ };
88
+ declare const Steps: React.FC<StepsProps>;
89
+ export { StepsProps, Steps };
@@ -0,0 +1,48 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import cn from 'classnames';
3
+ import '@alfalab/hooks';
4
+ import '@alfalab/icons-glyph/CheckmarkCircleMIcon';
5
+ import '@alfalab/icons-glyph/ExclamationCircleMIcon';
6
+ import '@alfalab/icons-glyph/ClockMIcon';
7
+ import '@alfalab/core-components-badge/modern';
8
+ import './components/step-indicator/Component.js';
9
+ import { Step } from './components/step/Component.js';
10
+
11
+ var styles = {"component":"steps__component_rm960","vertical":"steps__vertical_rm960"};
12
+ require('./index.css')
13
+
14
+ const Steps = ({ className, children, defaultActiveStep = 1, activeStep: activeStepProp, isMarkCompletedSteps = true, isVerticalAlign = false, ordered = true, interactive = true, checkIsStepDisabled, checkIsStepError, checkIsStepWarning, checkIsStepWaiting, checkIsStepPositive, checkIsStepCustom, onChange, dataTestId, }) => {
15
+ const [activeStep, setActiveStep] = useState(activeStepProp || defaultActiveStep);
16
+ const stepsLength = React.Children.count(children);
17
+ useEffect(() => {
18
+ if (activeStepProp) {
19
+ setActiveStep(activeStepProp);
20
+ }
21
+ }, [activeStepProp]);
22
+ const handleStepClick = (stepNumber) => {
23
+ setActiveStep(stepNumber);
24
+ if (onChange) {
25
+ onChange(stepNumber);
26
+ }
27
+ };
28
+ if (!stepsLength)
29
+ return null;
30
+ return (React.createElement("div", { className: cn(className, styles.component, {
31
+ [styles.vertical]: isVerticalAlign,
32
+ }), "data-test-id": dataTestId }, React.Children.map(children, (step, index) => {
33
+ const stepNumber = index + 1;
34
+ const isSelected = stepNumber === activeStep;
35
+ const isStepCompleted = isMarkCompletedSteps && stepNumber < activeStep;
36
+ const disabled = checkIsStepDisabled ? checkIsStepDisabled(stepNumber) : false;
37
+ const isPositive = checkIsStepPositive ? checkIsStepPositive(stepNumber) : false;
38
+ const isError = checkIsStepError ? checkIsStepError(stepNumber) : false;
39
+ const isWarning = checkIsStepWarning ? checkIsStepWarning(stepNumber) : false;
40
+ const isWaiting = checkIsStepWaiting ? checkIsStepWaiting(stepNumber) : false;
41
+ const customStepIndicator = checkIsStepCustom && checkIsStepCustom(stepNumber);
42
+ const isNotLastStep = stepsLength !== stepNumber;
43
+ const isInteractive = !disabled && interactive;
44
+ 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 }, step));
45
+ })));
46
+ };
47
+
48
+ export { Steps };
@@ -0,0 +1,70 @@
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;
54
+ /**
55
+ * Управление ориентацией компонента
56
+ * @default false
57
+ */
58
+ isVerticalAlign?: boolean;
59
+ /**
60
+ * Указывает, является ли текущий шаг последним в списке
61
+ */
62
+ isNotLastStep?: boolean;
63
+ /**
64
+ * Обработчик нажатия на текущей шаг
65
+ * @param stepNumber - номер шага
66
+ */
67
+ onClick: (stepNumber: number) => void;
68
+ };
69
+ declare const Step: React.FC<StepProps>;
70
+ export { StepProps, Step };