Skip to content

Commit fe138a0

Browse files
add prop initial to Steps
1 parent fd76264 commit fe138a0

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ online example: http://react-component.github.io/steps/examples/
6262
<td>0</td>
6363
<td>index of current step</td>
6464
</tr>
65+
<tr>
66+
<td>initial</td>
67+
<td>number</td>
68+
<td>0</td>
69+
<td>index initial</td>
70+
</tr>
6571
<tr>
6672
<td>size</td>
6773
<td>string</td>

src/Steps.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ export default class Steps extends Component {
2121
PropTypes.func,
2222
]),
2323
style: PropTypes.object,
24+
initial: PropTypes.number,
2425
current: PropTypes.number,
2526
};
2627
static defaultProps = {
2728
prefixCls: 'rc-steps',
2829
iconPrefix: 'rc',
2930
direction: 'horizontal',
3031
labelPlacement: 'horizontal',
32+
initial: 0,
3133
current: 0,
3234
status: 'process',
3335
size: '',
@@ -75,7 +77,7 @@ export default class Steps extends Component {
7577
const lastStepOffsetWidth = (domNode.lastChild.offsetWidth || 0) + 1;
7678
// Reduce shake bug
7779
if (this.state.lastStepOffsetWidth === lastStepOffsetWidth ||
78-
Math.abs(this.state.lastStepOffsetWidth - lastStepOffsetWidth) <= 3) {
80+
Math.abs(this.state.lastStepOffsetWidth - lastStepOffsetWidth) <= 3) {
7981
return;
8082
}
8183
this.setState({ lastStepOffsetWidth });
@@ -85,7 +87,7 @@ export default class Steps extends Component {
8587
render() {
8688
const {
8789
prefixCls, style = {}, className, children, direction,
88-
labelPlacement, iconPrefix, status, size, current, progressDot,
90+
labelPlacement, iconPrefix, status, size, current, progressDot, initial,
8991
...restProps,
9092
} = this.props;
9193
const { lastStepOffsetWidth, flexSupported } = this.state;
@@ -105,8 +107,9 @@ export default class Steps extends Component {
105107
if (!child) {
106108
return null;
107109
}
110+
const stepNumber = initial ? initial + index : index + 1;
108111
const childProps = {
109-
stepNumber: `${index + 1}`,
112+
stepNumber,
110113
prefixCls,
111114
iconPrefix,
112115
wrapperStyle: style,
@@ -122,9 +125,9 @@ export default class Steps extends Component {
122125
childProps.className = `${prefixCls}-next-error`;
123126
}
124127
if (!child.props.status) {
125-
if (index === current) {
128+
if (stepNumber === current) {
126129
childProps.status = status;
127-
} else if (index < current) {
130+
} else if (stepNumber < current) {
128131
childProps.status = 'finish';
129132
} else {
130133
childProps.status = 'wait';

0 commit comments

Comments
 (0)