@alfalab/core-components-steps 1.5.1 → 1.6.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 (46) hide show
  1. package/Component.d.ts +10 -0
  2. package/Component.js +4 -11
  3. package/components/step/Component.d.ts +10 -0
  4. package/components/step/Component.js +10 -4
  5. package/components/step/index.css +38 -28
  6. package/components/step/index.js +0 -9
  7. package/components/step-indicator/Component.js +1 -1
  8. package/components/step-indicator/index.css +2 -2
  9. package/components/step-indicator/index.js +0 -3
  10. package/cssm/Component.d.ts +10 -0
  11. package/cssm/Component.js +3 -12
  12. package/cssm/components/step/Component.d.ts +10 -0
  13. package/cssm/components/step/Component.js +9 -4
  14. package/cssm/components/step/index.js +0 -11
  15. package/cssm/components/step/index.module.css +14 -4
  16. package/cssm/components/step-indicator/index.js +0 -4
  17. package/cssm/index.js +0 -13
  18. package/cssm/index.module.css +1 -1
  19. package/esm/Component.d.ts +10 -0
  20. package/esm/Component.js +4 -11
  21. package/esm/components/step/Component.d.ts +10 -0
  22. package/esm/components/step/Component.js +10 -4
  23. package/esm/components/step/index.css +38 -28
  24. package/esm/components/step/index.js +0 -9
  25. package/esm/components/step-indicator/Component.js +1 -1
  26. package/esm/components/step-indicator/index.css +2 -2
  27. package/esm/components/step-indicator/index.js +0 -3
  28. package/esm/index.css +4 -4
  29. package/esm/index.js +0 -10
  30. package/index.css +4 -4
  31. package/index.js +0 -10
  32. package/modern/Component.d.ts +10 -0
  33. package/modern/Component.js +3 -9
  34. package/modern/components/step/Component.d.ts +10 -0
  35. package/modern/components/step/Component.js +10 -4
  36. package/modern/components/step/index.css +38 -28
  37. package/modern/components/step/index.js +0 -8
  38. package/modern/components/step-indicator/Component.js +1 -1
  39. package/modern/components/step-indicator/index.css +2 -2
  40. package/modern/components/step-indicator/index.js +0 -3
  41. package/modern/index.css +4 -4
  42. package/modern/index.js +0 -9
  43. package/package.json +1 -1
  44. package/src/Component.tsx +16 -0
  45. package/src/components/step/Component.tsx +30 -4
  46. package/src/components/step/index.module.css +20 -0
package/modern/index.js CHANGED
@@ -1,10 +1 @@
1
1
  export { Steps } from './Component.js';
2
- import 'react';
3
- import 'classnames';
4
- import './components/step/Component.js';
5
- import '@alfalab/hooks';
6
- import '@alfalab/icons-glyph/CheckmarkCircleMIcon';
7
- import '@alfalab/icons-glyph/ClockMIcon';
8
- import '@alfalab/icons-glyph/ExclamationCircleMIcon';
9
- import './components/step-indicator/Component.js';
10
- import '@alfalab/core-components-badge/modern';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-steps",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
package/src/Component.tsx CHANGED
@@ -50,6 +50,18 @@ export type StepsProps = {
50
50
  */
51
51
  interactive?: boolean;
52
52
 
53
+ /**
54
+ * Растягивание шагов на всю ширину блока для вертикальной ориентации
55
+ * @default false
56
+ */
57
+ fullWidth?: boolean;
58
+
59
+ /**
60
+ * Минимальное расстояние между шагами
61
+ * @default 24
62
+ */
63
+ minSpaceBetweenSteps?: 8 | 16 | 24;
64
+
53
65
  /**
54
66
  * Кастомный метод для управления состоянием disabled шага и
55
67
  * возможностью перехода на этот шаг
@@ -114,6 +126,8 @@ export const Steps: React.FC<StepsProps> = ({
114
126
  isVerticalAlign = false,
115
127
  ordered = true,
116
128
  interactive = true,
129
+ fullWidth = false,
130
+ minSpaceBetweenSteps = 24,
117
131
  checkIsStepDisabled,
118
132
  checkIsStepError,
119
133
  checkIsStepWarning,
@@ -180,6 +194,8 @@ export const Steps: React.FC<StepsProps> = ({
180
194
  isVerticalAlign={isVerticalAlign}
181
195
  isNotLastStep={isNotLastStep}
182
196
  key={stepNumber}
197
+ fullWidth={fullWidth}
198
+ minSpaceBetweenSteps={minSpaceBetweenSteps}
183
199
  >
184
200
  {step}
185
201
  </Step>
@@ -82,6 +82,18 @@ export type StepProps = {
82
82
  */
83
83
  isNotLastStep?: boolean;
84
84
 
85
+ /**
86
+ * Маркер того, что шаг растягивается на всю ширину блока
87
+ * для вертикальной ориентации
88
+ */
89
+ fullWidth?: boolean;
90
+
91
+ /**
92
+ * Минимальное расстояние между шагами
93
+ * @default 24
94
+ */
95
+ minSpaceBetweenSteps?: 8 | 16 | 24;
96
+
85
97
  /**
86
98
  * Обработчик нажатия на текущей шаг
87
99
  * @param stepNumber - номер шага
@@ -89,6 +101,12 @@ export type StepProps = {
89
101
  onClick: (stepNumber: number) => void;
90
102
  };
91
103
 
104
+ const SIZE_TO_CLASSNAME_MAP = {
105
+ 8: 'size-8',
106
+ 16: 'size-16',
107
+ 24: 'size-24',
108
+ };
109
+
92
110
  export const Step: React.FC<StepProps> = ({
93
111
  children,
94
112
  stepNumber,
@@ -105,6 +123,8 @@ export const Step: React.FC<StepProps> = ({
105
123
  interactive,
106
124
  isVerticalAlign,
107
125
  isNotLastStep,
126
+ fullWidth,
127
+ minSpaceBetweenSteps = 24,
108
128
  }) => {
109
129
  const stepRef = useRef<HTMLDivElement>(null);
110
130
 
@@ -166,10 +186,14 @@ export const Step: React.FC<StepProps> = ({
166
186
 
167
187
  const renderDash = () => (
168
188
  <div
169
- className={cn(styles.dash, {
170
- [styles.vertical]: isVerticalAlign,
171
- [styles.completed]: isStepCompleted,
172
- })}
189
+ className={cn(
190
+ styles.dash,
191
+ {
192
+ [styles.vertical]: isVerticalAlign,
193
+ [styles.completed]: isStepCompleted,
194
+ },
195
+ styles[SIZE_TO_CLASSNAME_MAP[minSpaceBetweenSteps]],
196
+ )}
173
197
  />
174
198
  );
175
199
 
@@ -186,6 +210,7 @@ export const Step: React.FC<StepProps> = ({
186
210
  [styles.focused]: focused,
187
211
  [styles.vertical]: isVerticalAlign,
188
212
  [styles.interactive]: interactive,
213
+ [styles.fullWidth]: fullWidth && isVerticalAlign,
189
214
  })}
190
215
  onClick={handleButtonClick}
191
216
  onKeyDown={handleKeyDown}
@@ -211,6 +236,7 @@ export const Step: React.FC<StepProps> = ({
211
236
  <div
212
237
  className={cn(styles.text, {
213
238
  [styles.interactive]: interactive,
239
+ [styles.fullWidth]: fullWidth && isVerticalAlign,
214
240
  })}
215
241
  onClick={handleTextClick}
216
242
  >
@@ -65,6 +65,14 @@
65
65
  border-top: 2px solid var(--color-light-neutral-translucent-300);
66
66
  margin-right: var(--gap-xs);
67
67
 
68
+ &.size-16 {
69
+ min-width: 16px;
70
+ }
71
+
72
+ &.size-8 {
73
+ min-width: 8px;
74
+ }
75
+
68
76
  &.completed {
69
77
  border-top: var(--steps-dash-border);
70
78
  }
@@ -76,6 +84,14 @@
76
84
  margin-top: var(--gap-xs);
77
85
  border-left: 2px solid var(--color-light-neutral-translucent-300);
78
86
  border-top: none;
87
+
88
+ &.size-16 {
89
+ min-height: 16px;
90
+ }
91
+
92
+ &.size-8 {
93
+ min-height: 8px;
94
+ }
79
95
  }
80
96
 
81
97
  &.completed.vertical {
@@ -152,3 +168,7 @@
152
168
  color: var(--steps-option-svg-color);
153
169
  background-color: var(--steps-option-svg-color);
154
170
  }
171
+
172
+ .fullWidth {
173
+ width: 100%;
174
+ }