@salutejs/plasma-new-hope 0.159.0-canary.1443.11131308290.0 → 0.159.0-canary.1443.11139400186.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/cjs/components/Steps/Steps.css +11 -11
  2. package/cjs/components/Steps/Steps.js +19 -26
  3. package/cjs/components/Steps/Steps.js.map +1 -1
  4. package/cjs/components/Steps/Steps.styles.js +1 -1
  5. package/cjs/components/Steps/Steps.styles.js.map +1 -1
  6. package/cjs/components/Steps/{Steps.styles_o055q.css → Steps.styles_vv31r6.css} +1 -1
  7. package/cjs/components/Steps/Steps.tokens.js +1 -0
  8. package/cjs/components/Steps/Steps.tokens.js.map +1 -1
  9. package/cjs/components/Steps/ui/StepItem/StepItem.css +9 -9
  10. package/cjs/components/Steps/ui/StepItem/StepItem.js +6 -9
  11. package/cjs/components/Steps/ui/StepItem/StepItem.js.map +1 -1
  12. package/cjs/components/Steps/ui/StepItem/StepItem.styles.js +14 -4
  13. package/cjs/components/Steps/ui/StepItem/StepItem.styles.js.map +1 -1
  14. package/{es/components/Steps/ui/StepItem/StepItem.styles_urheiv.css → cjs/components/Steps/ui/StepItem/StepItem.styles_1y1xj5d.css} +3 -3
  15. package/cjs/components/Steps/utils/getItemStatus.js +27 -0
  16. package/cjs/components/Steps/utils/getItemStatus.js.map +1 -0
  17. package/cjs/index.css +11 -11
  18. package/emotion/cjs/components/Steps/Steps.js +19 -26
  19. package/emotion/cjs/components/Steps/Steps.styles.js +1 -1
  20. package/emotion/cjs/components/Steps/Steps.tokens.js +1 -0
  21. package/emotion/cjs/components/Steps/ui/StepItem/StepItem.js +6 -9
  22. package/emotion/cjs/components/Steps/ui/StepItem/StepItem.styles.js +20 -11
  23. package/emotion/cjs/components/Steps/utils/getItemStatus.js +26 -0
  24. package/emotion/cjs/examples/plasma_b2c/components/Steps/Steps.config.js +6 -6
  25. package/emotion/cjs/examples/plasma_b2c/components/Steps/Steps.js +0 -2
  26. package/emotion/cjs/examples/plasma_b2c/components/Steps/Steps.stories.tsx +21 -2
  27. package/emotion/cjs/examples/plasma_web/components/Steps/Steps.config.js +6 -6
  28. package/emotion/cjs/examples/plasma_web/components/Steps/Steps.js +0 -2
  29. package/emotion/cjs/examples/plasma_web/components/Steps/Steps.stories.tsx +21 -2
  30. package/emotion/es/components/Steps/Steps.js +19 -26
  31. package/emotion/es/components/Steps/Steps.styles.js +1 -1
  32. package/emotion/es/components/Steps/Steps.tokens.js +1 -0
  33. package/emotion/es/components/Steps/ui/StepItem/StepItem.js +7 -9
  34. package/emotion/es/components/Steps/ui/StepItem/StepItem.styles.js +20 -11
  35. package/emotion/es/components/Steps/utils/getItemStatus.js +20 -0
  36. package/emotion/es/examples/plasma_b2c/components/Steps/Steps.config.js +6 -6
  37. package/emotion/es/examples/plasma_b2c/components/Steps/Steps.js +0 -3
  38. package/emotion/es/examples/plasma_b2c/components/Steps/Steps.stories.tsx +21 -2
  39. package/emotion/es/examples/plasma_web/components/Steps/Steps.config.js +6 -6
  40. package/emotion/es/examples/plasma_web/components/Steps/Steps.js +0 -3
  41. package/emotion/es/examples/plasma_web/components/Steps/Steps.stories.tsx +21 -2
  42. package/es/components/Steps/Steps.css +11 -11
  43. package/es/components/Steps/Steps.js +19 -26
  44. package/es/components/Steps/Steps.js.map +1 -1
  45. package/es/components/Steps/Steps.styles.js +1 -1
  46. package/es/components/Steps/Steps.styles.js.map +1 -1
  47. package/es/components/Steps/{Steps.styles_o055q.css → Steps.styles_vv31r6.css} +1 -1
  48. package/es/components/Steps/Steps.tokens.js +1 -0
  49. package/es/components/Steps/Steps.tokens.js.map +1 -1
  50. package/es/components/Steps/ui/StepItem/StepItem.css +9 -9
  51. package/es/components/Steps/ui/StepItem/StepItem.js +6 -9
  52. package/es/components/Steps/ui/StepItem/StepItem.js.map +1 -1
  53. package/es/components/Steps/ui/StepItem/StepItem.styles.js +14 -4
  54. package/es/components/Steps/ui/StepItem/StepItem.styles.js.map +1 -1
  55. package/{cjs/components/Steps/ui/StepItem/StepItem.styles_urheiv.css → es/components/Steps/ui/StepItem/StepItem.styles_1y1xj5d.css} +3 -3
  56. package/es/components/Steps/utils/getItemStatus.js +23 -0
  57. package/es/components/Steps/utils/getItemStatus.js.map +1 -0
  58. package/es/index.css +11 -11
  59. package/package.json +3 -2
  60. package/styled-components/cjs/components/Steps/Steps.js +19 -26
  61. package/styled-components/cjs/components/Steps/Steps.styles.js +1 -1
  62. package/styled-components/cjs/components/Steps/Steps.tokens.js +1 -0
  63. package/styled-components/cjs/components/Steps/ui/StepItem/StepItem.js +6 -9
  64. package/styled-components/cjs/components/Steps/ui/StepItem/StepItem.styles.js +14 -5
  65. package/styled-components/cjs/components/Steps/utils/getItemStatus.js +26 -0
  66. package/styled-components/cjs/examples/plasma_b2c/components/Steps/Steps.config.js +2 -2
  67. package/styled-components/cjs/examples/plasma_b2c/components/Steps/Steps.js +0 -2
  68. package/styled-components/cjs/examples/plasma_b2c/components/Steps/Steps.stories.tsx +21 -2
  69. package/styled-components/cjs/examples/plasma_web/components/Steps/Steps.config.js +2 -2
  70. package/styled-components/cjs/examples/plasma_web/components/Steps/Steps.js +0 -2
  71. package/styled-components/cjs/examples/plasma_web/components/Steps/Steps.stories.tsx +21 -2
  72. package/styled-components/es/components/Steps/Steps.js +19 -26
  73. package/styled-components/es/components/Steps/Steps.styles.js +1 -1
  74. package/styled-components/es/components/Steps/Steps.tokens.js +1 -0
  75. package/styled-components/es/components/Steps/ui/StepItem/StepItem.js +7 -9
  76. package/styled-components/es/components/Steps/ui/StepItem/StepItem.styles.js +14 -5
  77. package/styled-components/es/components/Steps/utils/getItemStatus.js +20 -0
  78. package/styled-components/es/examples/plasma_b2c/components/Steps/Steps.config.js +2 -2
  79. package/styled-components/es/examples/plasma_b2c/components/Steps/Steps.js +0 -3
  80. package/styled-components/es/examples/plasma_b2c/components/Steps/Steps.stories.tsx +21 -2
  81. package/styled-components/es/examples/plasma_web/components/Steps/Steps.config.js +2 -2
  82. package/styled-components/es/examples/plasma_web/components/Steps/Steps.js +0 -3
  83. package/styled-components/es/examples/plasma_web/components/Steps/Steps.stories.tsx +21 -2
  84. package/types/components/Steps/Steps.d.ts +5 -3
  85. package/types/components/Steps/Steps.d.ts.map +1 -1
  86. package/types/components/Steps/Steps.tokens.d.ts +1 -0
  87. package/types/components/Steps/Steps.tokens.d.ts.map +1 -1
  88. package/types/components/Steps/index.d.ts +1 -1
  89. package/types/components/Steps/index.d.ts.map +1 -1
  90. package/types/components/Steps/ui/StepItem/StepItem.d.ts.map +1 -1
  91. package/types/components/Steps/ui/StepItem/StepItem.styles.d.ts +16 -4
  92. package/types/components/Steps/ui/StepItem/StepItem.styles.d.ts.map +1 -1
  93. package/types/components/Steps/utils/getItemStatus.d.ts +9 -0
  94. package/types/components/Steps/utils/getItemStatus.d.ts.map +1 -0
  95. package/types/examples/plasma_b2c/components/Steps/Steps.d.ts +2 -2
  96. package/types/examples/plasma_b2c/components/Steps/Steps.d.ts.map +1 -1
  97. package/types/examples/plasma_web/components/Steps/Steps.d.ts +2 -2
  98. package/types/examples/plasma_web/components/Steps/Steps.d.ts.map +1 -1
  99. package/emotion/cjs/components/Steps/Steps.review-doc.mdx +0 -304
  100. package/emotion/es/components/Steps/Steps.review-doc.mdx +0 -304
  101. package/styled-components/cjs/components/Steps/Steps.review-doc.mdx +0 -304
  102. package/styled-components/es/components/Steps/Steps.review-doc.mdx +0 -304
@@ -1,304 +0,0 @@
1
- ---
2
- id: steps
3
- title: Steps
4
- ---
5
-
6
- # Steps
7
- Шаги могут отображаться в нескольких размерах, в упрощенном виде и в горизонтальной/вертикальной ориентации
8
-
9
- ```tsx live
10
- import { ReactNode } from 'react';
11
-
12
- export type StepStatus = 'active' | 'inactive' | 'completed';
13
-
14
- export interface StepItemProps {
15
- /**
16
- * Заголовок
17
- */
18
- title?: string;
19
- /**
20
- * Контент, может быть как React компонентом, так и функцией
21
- */
22
- content?: string | ReactNode | ((status: StepStatus, index: number, items: StepItemProps[]) => ReactNode);
23
- /**
24
- * Индикатор шага, может быть как React компонентом, так и функцией
25
- */
26
- indicator?: number | string | ReactNode | ((status: StepStatus, item: StepItemProps) => ReactNode | null);
27
- /**
28
- * Статус шага: активный, инактивный, завершенный
29
- * @description
30
- * active - активный шаг
31
- * inactive - не пройденный шаг
32
- * completed - пройденный шаг
33
- */
34
- status?: StepStatus;
35
- /**
36
- * Отключенный шаг
37
- * @default false
38
- */
39
- disabled?: boolean;
40
- }
41
-
42
- interface BaseSteps {
43
- /**
44
- * Ориентация компонента
45
- * @default 'horizontal'
46
- */
47
- orientation?: 'horizontal' | 'vertical';
48
- /**
49
- * Выравнивание контента в шагах
50
- * @default 'left'
51
- */
52
- contentAlign?: 'left' | 'center';
53
- /**
54
- * Включает разделительную линию
55
- * @default true
56
- */
57
- hasLine?: boolean;
58
- /**
59
- * Индекс текущего шага, для uncontrolled компонента
60
- */
61
- current?: number;
62
- /**
63
- * Статус текущего шага, имеет приоритет над item.status
64
- */
65
- status?: StepStatus;
66
- /**
67
- * Обработчик изменения шага, делает индикаторы и заголовки шагов кликабельными
68
- */
69
- onChange?: (item: StepItemProps, index: number, prevIndex?: number) => void;
70
- /**
71
- * Массив шагов
72
- */
73
- items: StepItemProps[];
74
- }
75
-
76
- type IndicatorSizeSimple = 8 | 16;
77
- type IndicatorSize = 24 | 36;
78
-
79
- export type Steps = BaseSteps & {
80
- /**
81
- * Размер шага
82
- */
83
- size: 'xs' | 's';
84
- indicatorSize: never;
85
- } & {
86
- /**
87
- * Размер шага
88
- */
89
- size: 'm' | 'l';
90
- /**
91
- * Размер индикатора
92
- */
93
- indicatorSize: IndicatorSize | IndicatorSizeSimple;
94
- };
95
-
96
- ```
97
-
98
- примеры использования https://codesandbox.io/p/devbox/crzql2?file=%2Fsrc%2FDemo.tsx%3A23%2C1
99
-
100
- ```
101
- import React, { useState } from 'react';
102
- import { fullItems } from './App.data.tsx';
103
- import { Steps } from './Steps/Steps.tsx';
104
- import { StepItemProps, StepStatus } from './Steps/Steps.types';
105
-
106
- const DemoContent: React.FC<{ onClick: () => void; status: string; index?: number; current?: number }> = ({
107
- onClick,
108
- status,
109
- index,
110
- current = 0,
111
- children,
112
- }) => {
113
- return (
114
- <>
115
- <div>Content</div>
116
- <button onClick={onClick} disabled={index !== (current || 0)}>
117
- {children}
118
- </button>
119
- </>
120
- );
121
- };
122
-
123
- export const DemoWithExternalControl = () => {
124
- const items = [
125
- {
126
- title: 'Title',
127
- indicator: '1',
128
- content: 'Content',
129
- },
130
- {
131
- title: 'Title',
132
- indicator: '2',
133
- content: 'Content',
134
- },
135
- {
136
- title: 'Title',
137
- indicator: '3',
138
- content: 'Content',
139
- },
140
- {
141
- title: 'Title',
142
- indicator: '4',
143
- content: 'Content',
144
- },
145
- ];
146
-
147
- const [current, setCurrent] = useState(1);
148
- const [status, setStatus] = useState('active');
149
-
150
- const isLast = current === items.length - 1;
151
-
152
- const onClick = () => {
153
- if (isLast) {
154
- setStatus('completed');
155
- } else {
156
- setCurrent(current + 1);
157
- }
158
- };
159
-
160
- return (
161
- <>
162
- <Steps style={{ width: '1000px' }} current={current} status={status} items={items} />
163
- <br />
164
- <div>
165
- External control:{' '}
166
- <button onClick={onClick} style={{ width: '5rem' }}>
167
- {isLast ? 'complete' : 'next'}
168
- </button>
169
- </div>
170
- <hr />
171
- </>
172
- );
173
- };
174
-
175
- export const DemoWithInternalControls = () => {
176
- const [current, setCurrent] = useState(undefined);
177
- const [status, setStatus] = useState<StepStatus | undefined>();
178
-
179
- const renderContent = (status, index, items) => {
180
- const isFirst = index === 0 && current === undefined;
181
- const isLast = index === items.length - 1;
182
-
183
- const onNext = () => setCurrent((current) => (current === undefined ? 0 : current + 1));
184
- const onComplete = () => {
185
- setStatus('completed');
186
- };
187
-
188
- return (
189
- <DemoContent onClick={isLast ? onComplete : onNext} index={index} status={status} current={current}>
190
- {isFirst && 'go'}
191
- {isLast && 'complete'}
192
- {!isFirst && !isLast && 'next'}
193
- </DemoContent>
194
- );
195
- };
196
-
197
- return (
198
- <Steps
199
- current={current}
200
- status={status}
201
- items={[
202
- {
203
- title: 'Title',
204
- indicator: '1',
205
- content: renderContent,
206
- },
207
- {
208
- title: 'Title',
209
- indicator: '2',
210
- content: renderContent,
211
- },
212
- {
213
- title: 'Title',
214
- indicator: '3',
215
- content: renderContent,
216
- },
217
- {
218
- title: 'Title',
219
- indicator: '4',
220
- content: renderContent,
221
- },
222
- ]}
223
- />
224
- );
225
- };
226
-
227
- export const DemoWithControlledUsage = () => {
228
- const [exampleItems, setExampleItems] = useState<StepItemProps[]>(() =>
229
- fullItems.map((item) => ({ ...item, status: 'inactive' }))
230
- );
231
-
232
- return (
233
- <Steps
234
- style={{ width: '1000px' }}
235
- onChange={(item, index) => {
236
- setExampleItems(
237
- exampleItems.map((item, itemIndex) => {
238
- if (index > itemIndex) {
239
- return { ...item, status: 'completed' };
240
- }
241
-
242
- if (index === itemIndex) {
243
- return { ...item, status: 'active' };
244
- }
245
-
246
- return { ...item, status: 'inactive' };
247
- })
248
- );
249
- }}
250
- items={exampleItems}
251
- />
252
- );
253
- };
254
-
255
- export const DemoWithControlledFreeUsage = () => {
256
- const [items, setItems] = useState<StepItemProps[]>(() => fullItems.map((item) => ({ ...item, status: 'inactive' })));
257
-
258
- return (
259
- <Steps
260
- style={{ width: '1000px' }}
261
- onChange={(item, index, prevIndex) => {
262
- console.log('!!! onChange', index, prevIndex);
263
-
264
- const newItems = [...items];
265
- if (prevIndex !== undefined) {
266
- newItems[prevIndex].status = 'completed';
267
- }
268
- newItems[index].status = 'active';
269
-
270
- setItems(newItems);
271
- }}
272
- items={items}
273
- />
274
- );
275
- };
276
-
277
- export const DemoControlledWithStatus = () => {
278
- const [items, setItems] = useState<StepItemProps[]>(() => fullItems.map(({ status, ...item }) => ({ ...item })));
279
- return (
280
- <Steps
281
- style={{ width: '1000px' }}
282
- current={2}
283
- status="active"
284
- onClick={(item, index) => {
285
- setItems(
286
- items.map((item, itemIndex) => {
287
- if (index > itemIndex) {
288
- return { ...item, status: 'completed' };
289
- }
290
-
291
- if (index === itemIndex) {
292
- return { ...item, status: 'active' };
293
- }
294
-
295
- return { ...item, status: 'inactive' };
296
- })
297
- );
298
- }}
299
- items={items}
300
- />
301
- );
302
- };
303
-
304
- ```
@@ -1,304 +0,0 @@
1
- ---
2
- id: steps
3
- title: Steps
4
- ---
5
-
6
- # Steps
7
- Шаги могут отображаться в нескольких размерах, в упрощенном виде и в горизонтальной/вертикальной ориентации
8
-
9
- ```tsx live
10
- import { ReactNode } from 'react';
11
-
12
- export type StepStatus = 'active' | 'inactive' | 'completed';
13
-
14
- export interface StepItemProps {
15
- /**
16
- * Заголовок
17
- */
18
- title?: string;
19
- /**
20
- * Контент, может быть как React компонентом, так и функцией
21
- */
22
- content?: string | ReactNode | ((status: StepStatus, index: number, items: StepItemProps[]) => ReactNode);
23
- /**
24
- * Индикатор шага, может быть как React компонентом, так и функцией
25
- */
26
- indicator?: number | string | ReactNode | ((status: StepStatus, item: StepItemProps) => ReactNode | null);
27
- /**
28
- * Статус шага: активный, инактивный, завершенный
29
- * @description
30
- * active - активный шаг
31
- * inactive - не пройденный шаг
32
- * completed - пройденный шаг
33
- */
34
- status?: StepStatus;
35
- /**
36
- * Отключенный шаг
37
- * @default false
38
- */
39
- disabled?: boolean;
40
- }
41
-
42
- interface BaseSteps {
43
- /**
44
- * Ориентация компонента
45
- * @default 'horizontal'
46
- */
47
- orientation?: 'horizontal' | 'vertical';
48
- /**
49
- * Выравнивание контента в шагах
50
- * @default 'left'
51
- */
52
- contentAlign?: 'left' | 'center';
53
- /**
54
- * Включает разделительную линию
55
- * @default true
56
- */
57
- hasLine?: boolean;
58
- /**
59
- * Индекс текущего шага, для uncontrolled компонента
60
- */
61
- current?: number;
62
- /**
63
- * Статус текущего шага, имеет приоритет над item.status
64
- */
65
- status?: StepStatus;
66
- /**
67
- * Обработчик изменения шага, делает индикаторы и заголовки шагов кликабельными
68
- */
69
- onChange?: (item: StepItemProps, index: number, prevIndex?: number) => void;
70
- /**
71
- * Массив шагов
72
- */
73
- items: StepItemProps[];
74
- }
75
-
76
- type IndicatorSizeSimple = 8 | 16;
77
- type IndicatorSize = 24 | 36;
78
-
79
- export type Steps = BaseSteps & {
80
- /**
81
- * Размер шага
82
- */
83
- size: 'xs' | 's';
84
- indicatorSize: never;
85
- } & {
86
- /**
87
- * Размер шага
88
- */
89
- size: 'm' | 'l';
90
- /**
91
- * Размер индикатора
92
- */
93
- indicatorSize: IndicatorSize | IndicatorSizeSimple;
94
- };
95
-
96
- ```
97
-
98
- примеры использования https://codesandbox.io/p/devbox/crzql2?file=%2Fsrc%2FDemo.tsx%3A23%2C1
99
-
100
- ```
101
- import React, { useState } from 'react';
102
- import { fullItems } from './App.data.tsx';
103
- import { Steps } from './Steps/Steps.tsx';
104
- import { StepItemProps, StepStatus } from './Steps/Steps.types';
105
-
106
- const DemoContent: React.FC<{ onClick: () => void; status: string; index?: number; current?: number }> = ({
107
- onClick,
108
- status,
109
- index,
110
- current = 0,
111
- children,
112
- }) => {
113
- return (
114
- <>
115
- <div>Content</div>
116
- <button onClick={onClick} disabled={index !== (current || 0)}>
117
- {children}
118
- </button>
119
- </>
120
- );
121
- };
122
-
123
- export const DemoWithExternalControl = () => {
124
- const items = [
125
- {
126
- title: 'Title',
127
- indicator: '1',
128
- content: 'Content',
129
- },
130
- {
131
- title: 'Title',
132
- indicator: '2',
133
- content: 'Content',
134
- },
135
- {
136
- title: 'Title',
137
- indicator: '3',
138
- content: 'Content',
139
- },
140
- {
141
- title: 'Title',
142
- indicator: '4',
143
- content: 'Content',
144
- },
145
- ];
146
-
147
- const [current, setCurrent] = useState(1);
148
- const [status, setStatus] = useState('active');
149
-
150
- const isLast = current === items.length - 1;
151
-
152
- const onClick = () => {
153
- if (isLast) {
154
- setStatus('completed');
155
- } else {
156
- setCurrent(current + 1);
157
- }
158
- };
159
-
160
- return (
161
- <>
162
- <Steps style={{ width: '1000px' }} current={current} status={status} items={items} />
163
- <br />
164
- <div>
165
- External control:{' '}
166
- <button onClick={onClick} style={{ width: '5rem' }}>
167
- {isLast ? 'complete' : 'next'}
168
- </button>
169
- </div>
170
- <hr />
171
- </>
172
- );
173
- };
174
-
175
- export const DemoWithInternalControls = () => {
176
- const [current, setCurrent] = useState(undefined);
177
- const [status, setStatus] = useState<StepStatus | undefined>();
178
-
179
- const renderContent = (status, index, items) => {
180
- const isFirst = index === 0 && current === undefined;
181
- const isLast = index === items.length - 1;
182
-
183
- const onNext = () => setCurrent((current) => (current === undefined ? 0 : current + 1));
184
- const onComplete = () => {
185
- setStatus('completed');
186
- };
187
-
188
- return (
189
- <DemoContent onClick={isLast ? onComplete : onNext} index={index} status={status} current={current}>
190
- {isFirst && 'go'}
191
- {isLast && 'complete'}
192
- {!isFirst && !isLast && 'next'}
193
- </DemoContent>
194
- );
195
- };
196
-
197
- return (
198
- <Steps
199
- current={current}
200
- status={status}
201
- items={[
202
- {
203
- title: 'Title',
204
- indicator: '1',
205
- content: renderContent,
206
- },
207
- {
208
- title: 'Title',
209
- indicator: '2',
210
- content: renderContent,
211
- },
212
- {
213
- title: 'Title',
214
- indicator: '3',
215
- content: renderContent,
216
- },
217
- {
218
- title: 'Title',
219
- indicator: '4',
220
- content: renderContent,
221
- },
222
- ]}
223
- />
224
- );
225
- };
226
-
227
- export const DemoWithControlledUsage = () => {
228
- const [exampleItems, setExampleItems] = useState<StepItemProps[]>(() =>
229
- fullItems.map((item) => ({ ...item, status: 'inactive' }))
230
- );
231
-
232
- return (
233
- <Steps
234
- style={{ width: '1000px' }}
235
- onChange={(item, index) => {
236
- setExampleItems(
237
- exampleItems.map((item, itemIndex) => {
238
- if (index > itemIndex) {
239
- return { ...item, status: 'completed' };
240
- }
241
-
242
- if (index === itemIndex) {
243
- return { ...item, status: 'active' };
244
- }
245
-
246
- return { ...item, status: 'inactive' };
247
- })
248
- );
249
- }}
250
- items={exampleItems}
251
- />
252
- );
253
- };
254
-
255
- export const DemoWithControlledFreeUsage = () => {
256
- const [items, setItems] = useState<StepItemProps[]>(() => fullItems.map((item) => ({ ...item, status: 'inactive' })));
257
-
258
- return (
259
- <Steps
260
- style={{ width: '1000px' }}
261
- onChange={(item, index, prevIndex) => {
262
- console.log('!!! onChange', index, prevIndex);
263
-
264
- const newItems = [...items];
265
- if (prevIndex !== undefined) {
266
- newItems[prevIndex].status = 'completed';
267
- }
268
- newItems[index].status = 'active';
269
-
270
- setItems(newItems);
271
- }}
272
- items={items}
273
- />
274
- );
275
- };
276
-
277
- export const DemoControlledWithStatus = () => {
278
- const [items, setItems] = useState<StepItemProps[]>(() => fullItems.map(({ status, ...item }) => ({ ...item })));
279
- return (
280
- <Steps
281
- style={{ width: '1000px' }}
282
- current={2}
283
- status="active"
284
- onClick={(item, index) => {
285
- setItems(
286
- items.map((item, itemIndex) => {
287
- if (index > itemIndex) {
288
- return { ...item, status: 'completed' };
289
- }
290
-
291
- if (index === itemIndex) {
292
- return { ...item, status: 'active' };
293
- }
294
-
295
- return { ...item, status: 'inactive' };
296
- })
297
- );
298
- }}
299
- items={items}
300
- />
301
- );
302
- };
303
-
304
- ```