@momo-kits/step 0.0.43-beta.9 → 0.0.44-beta.2
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/Step.constants.js +1 -0
- package/Step.horizontal.js +432 -0
- package/Step.horizontal.web.js +434 -0
- package/Step.js +36 -285
- package/Step.vertical.js +399 -0
- package/Step.vertical.web.js +401 -0
- package/Step.web.js +37 -282
- package/package.json +1 -1
- package/publish.sh +2 -2
package/Step.js
CHANGED
|
@@ -1,308 +1,59 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { View, StyleSheet } from 'react-native';
|
|
3
|
-
|
|
4
2
|
import PropTypes from 'prop-types';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
} from '@momo-kits/core';
|
|
8
|
-
|
|
9
|
-
const CIRCLE_SIZE = 24;
|
|
10
|
-
|
|
11
|
-
const styles = StyleSheet.create({
|
|
12
|
-
circle: {
|
|
13
|
-
width: CIRCLE_SIZE,
|
|
14
|
-
height: CIRCLE_SIZE,
|
|
15
|
-
// borderWidth: 1,
|
|
16
|
-
// borderColor: Colors.sepia_05,
|
|
17
|
-
borderRadius: CIRCLE_SIZE / 2,
|
|
18
|
-
backgroundColor: 'white'
|
|
19
|
-
},
|
|
20
|
-
line: {
|
|
21
|
-
height: 4,
|
|
22
|
-
backgroundColor: 'white',
|
|
23
|
-
// borderWidth: 1,
|
|
24
|
-
// borderRadius: 1,
|
|
25
|
-
// borderStyle: 'dashed',
|
|
26
|
-
zIndex: 0,
|
|
27
|
-
// marginTop: 8
|
|
28
|
-
},
|
|
29
|
-
topRight: {
|
|
30
|
-
position: 'absolute',
|
|
31
|
-
right: -1,
|
|
32
|
-
top: -1,
|
|
33
|
-
width: 1,
|
|
34
|
-
height: '100%',
|
|
35
|
-
backgroundColor: 'white',
|
|
36
|
-
zIndex: 1
|
|
37
|
-
},
|
|
38
|
-
topLeft: {
|
|
39
|
-
position: 'absolute',
|
|
40
|
-
left: -1,
|
|
41
|
-
top: -1,
|
|
42
|
-
width: '100%',
|
|
43
|
-
height: 1,
|
|
44
|
-
backgroundColor: 'white',
|
|
45
|
-
zIndex: 1
|
|
46
|
-
},
|
|
47
|
-
topLeftWidth: {
|
|
48
|
-
position: 'absolute',
|
|
49
|
-
left: -1,
|
|
50
|
-
top: -1,
|
|
51
|
-
width: 1,
|
|
52
|
-
height: '100%',
|
|
53
|
-
backgroundColor: 'white',
|
|
54
|
-
zIndex: 1
|
|
55
|
-
},
|
|
56
|
-
circleRow: {
|
|
57
|
-
position: 'absolute',
|
|
58
|
-
justifyContent: 'space-between',
|
|
59
|
-
flexDirection: 'row',
|
|
60
|
-
},
|
|
61
|
-
circleColumn: {
|
|
62
|
-
// position: 'absolute',
|
|
63
|
-
justifyContent: 'space-between',
|
|
64
|
-
},
|
|
65
|
-
titleDefault: {
|
|
66
|
-
color: Colors.black_12
|
|
67
|
-
},
|
|
68
|
-
titleActive: {
|
|
69
|
-
color: Colors.black_17,
|
|
70
|
-
fontWeight: 'bold'
|
|
71
|
-
},
|
|
72
|
-
containerStyle: {
|
|
73
|
-
minHeight: CIRCLE_SIZE + 20 + CIRCLE_SIZE
|
|
74
|
-
}
|
|
75
|
-
});
|
|
3
|
+
import HorizontalStep from './Step.horizontal';
|
|
4
|
+
import VerticalStep from './Step.vertical';
|
|
76
5
|
|
|
6
|
+
import { Colors, IconSource } from '@momo-kits/core';
|
|
77
7
|
export default class Step extends Component {
|
|
78
8
|
constructor(props) {
|
|
79
9
|
super(props);
|
|
80
|
-
this.state = {
|
|
81
|
-
width: 0,
|
|
82
|
-
height: 0
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
onLayout = (e) => {
|
|
87
|
-
this.setState({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
renderLine = () => {
|
|
91
|
-
const {
|
|
92
|
-
lineColor, lineStyle, currentStep, data
|
|
93
|
-
} = this.props;
|
|
94
|
-
return (
|
|
95
|
-
<View style={[styles.line, { borderColor: lineColor }, lineStyle]}>
|
|
96
|
-
{/* <View style={styles.topLeft} />
|
|
97
|
-
<View style={styles.topLeftWidth} />
|
|
98
|
-
<View style={styles.topRight} /> */}
|
|
99
|
-
</View>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
circle = (value, index) => {
|
|
104
|
-
const {
|
|
105
|
-
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
106
|
-
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle, checkedPreviousStep, borderColorActive, borderColorInActive,
|
|
107
|
-
} = this.props;
|
|
108
|
-
const { width } = this.state;
|
|
109
|
-
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
110
|
-
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
111
|
-
const itemWidth = (width - CIRCLE_SIZE) / data?.length;
|
|
112
|
-
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? lineColorActive || Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
|
|
113
|
-
const lineWidth = (width - CIRCLE_SIZE) / (data.length - 1);
|
|
114
|
-
const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
|
|
115
|
-
const borderColor = currentStep >= (index + 1) ? borderColorActive || Colors.pink_09 : borderColorInActive || Colors.pink_09;
|
|
116
|
-
let left = 0;
|
|
117
|
-
let textAlignStyle = { textAlign: 'center' };
|
|
118
|
-
/**
|
|
119
|
-
* item lefr
|
|
120
|
-
*/
|
|
121
|
-
if (index === 0) {
|
|
122
|
-
left = 0;
|
|
123
|
-
textAlignStyle = { textAlign: 'left' };
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* item right
|
|
127
|
-
*/
|
|
128
|
-
} else if (index === data?.length - 1) {
|
|
129
|
-
left = -itemWidth + CIRCLE_SIZE;
|
|
130
|
-
textAlignStyle = { textAlign: 'right' };
|
|
131
|
-
/**
|
|
132
|
-
* center item
|
|
133
|
-
*/
|
|
134
|
-
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
135
|
-
const textStyle = [textAlignStyle, textFontStyle];
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<View key={index}>
|
|
139
|
-
{
|
|
140
|
-
data?.length - 1 !== index && (
|
|
141
|
-
<View style={[styles.line, {
|
|
142
|
-
position: 'absolute',
|
|
143
|
-
top: 10,
|
|
144
|
-
backgroundColor: lineActive,
|
|
145
|
-
width: lineWidth,
|
|
146
|
-
height: 4,
|
|
147
|
-
marginTop: 0
|
|
148
|
-
}, lineStyle]}
|
|
149
|
-
/>
|
|
150
|
-
)
|
|
151
|
-
}
|
|
152
|
-
{
|
|
153
|
-
(isNumber && !checkedPreviousStep) || (isNumber && checkedPreviousStep && index >= currentStep -1 ) ? (
|
|
154
|
-
<View style={{
|
|
155
|
-
width: CIRCLE_SIZE,
|
|
156
|
-
height: CIRCLE_SIZE,
|
|
157
|
-
borderRadius: CIRCLE_SIZE / 2,
|
|
158
|
-
backgroundColor: backgroundActive,
|
|
159
|
-
borderColor: borderColor,
|
|
160
|
-
borderWidth: 2,
|
|
161
|
-
alignItems: 'center',
|
|
162
|
-
justifyContent: 'center'
|
|
163
|
-
}}
|
|
164
|
-
>
|
|
165
|
-
<Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
|
|
166
|
-
</View>
|
|
167
|
-
) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
<View style={{
|
|
171
|
-
position: 'absolute',
|
|
172
|
-
width: itemWidth,
|
|
173
|
-
left,
|
|
174
|
-
top: CIRCLE_SIZE + CIRCLE_SIZE / 4
|
|
175
|
-
}}
|
|
176
|
-
>
|
|
177
|
-
<Text.Caption style={[textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
178
|
-
</View>
|
|
179
|
-
</View>
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
circleColumn = (value, index) => {
|
|
184
|
-
const {
|
|
185
|
-
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
186
|
-
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
|
|
187
|
-
} = this.props;
|
|
188
|
-
const { height } = this.state;
|
|
189
|
-
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
190
|
-
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
191
|
-
const itemWidth = (height - CIRCLE_SIZE) / data?.length;
|
|
192
|
-
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
|
|
193
|
-
const lineWidth = (height - CIRCLE_SIZE) / (data.length - 1);
|
|
194
|
-
const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
|
|
195
|
-
let left = 0;
|
|
196
|
-
let textAlignStyle = { textAlign: 'center' };
|
|
197
|
-
/**
|
|
198
|
-
* item lefr
|
|
199
|
-
*/
|
|
200
|
-
if (index === 0) {
|
|
201
|
-
left = 0;
|
|
202
|
-
textAlignStyle = { textAlign: 'left' };
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* item right
|
|
206
|
-
*/
|
|
207
|
-
} else if (index === data?.length - 1) {
|
|
208
|
-
left = -itemWidth + CIRCLE_SIZE;
|
|
209
|
-
textAlignStyle = { textAlign: 'right' };
|
|
210
|
-
/**
|
|
211
|
-
* center item
|
|
212
|
-
*/
|
|
213
|
-
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
214
|
-
const textStyle = [textAlignStyle, textFontStyle];
|
|
215
|
-
|
|
216
|
-
return (
|
|
217
|
-
<View key={index}>
|
|
218
|
-
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
219
|
-
{
|
|
220
|
-
isNumber ? (
|
|
221
|
-
<View style={{
|
|
222
|
-
width: CIRCLE_SIZE,
|
|
223
|
-
height: CIRCLE_SIZE,
|
|
224
|
-
borderRadius: CIRCLE_SIZE / 2,
|
|
225
|
-
backgroundColor: backgroundActive,
|
|
226
|
-
borderColor: Colors.pink_09,
|
|
227
|
-
borderWidth: 1,
|
|
228
|
-
alignItems: 'center',
|
|
229
|
-
justifyContent: 'center'
|
|
230
|
-
}}
|
|
231
|
-
>
|
|
232
|
-
{
|
|
233
|
-
iconActive ? <Image source={iconActive} style={[styles.circle, { tintColor }, iconStyle]} /> : <Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
|
|
234
|
-
}
|
|
235
|
-
</View>
|
|
236
|
-
) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
|
|
237
|
-
}
|
|
238
|
-
<Text.Caption style={[{ marginLeft: 10 }, textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
239
|
-
</View>
|
|
240
|
-
|
|
241
|
-
{
|
|
242
|
-
data?.length - 1 !== index && (
|
|
243
|
-
<View style={[styles.line, {
|
|
244
|
-
left: 10,
|
|
245
|
-
backgroundColor: lineActive,
|
|
246
|
-
width: 4,
|
|
247
|
-
height: lineWidth,
|
|
248
|
-
marginTop: 0,
|
|
249
|
-
}, lineStyle]}
|
|
250
|
-
/>
|
|
251
|
-
)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
</View>
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
renderCircle = () => {
|
|
259
|
-
const { data = [], isVertical } = this.props;
|
|
260
|
-
return data.map(isVertical ? this.circleColumn : this.circle);
|
|
261
10
|
}
|
|
262
11
|
|
|
263
12
|
render() {
|
|
264
|
-
const {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
isVertical ? (
|
|
271
|
-
<View style={[styles.circleColumn, { height }]}>
|
|
272
|
-
{this.renderCircle()}
|
|
273
|
-
</View>
|
|
274
|
-
) : (
|
|
275
|
-
<View style={[styles.circleRow, { width }]}>
|
|
276
|
-
{this.renderCircle()}
|
|
277
|
-
</View>
|
|
278
|
-
)
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
</View>
|
|
282
|
-
);
|
|
13
|
+
const { isVertical } = this.props;
|
|
14
|
+
let DefaultComponent = HorizontalStep;
|
|
15
|
+
if (isVertical) {
|
|
16
|
+
DefaultComponent = VerticalStep;
|
|
17
|
+
}
|
|
18
|
+
return <DefaultComponent {...this.props} />;
|
|
283
19
|
}
|
|
284
20
|
}
|
|
285
21
|
|
|
286
22
|
Step.propTypes = {
|
|
287
|
-
|
|
23
|
+
titles: PropTypes.array,
|
|
288
24
|
currentStep: PropTypes.number,
|
|
289
|
-
tintColor: PropTypes.string,
|
|
290
25
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
291
|
-
|
|
26
|
+
items: PropTypes.array,
|
|
292
27
|
isVertical: PropTypes.bool,
|
|
293
28
|
iconActive: PropTypes.any,
|
|
294
|
-
|
|
29
|
+
iconChecked: PropTypes.any,
|
|
30
|
+
iconUnchecked: PropTypes.any,
|
|
31
|
+
circleColorActive: PropTypes.string,
|
|
32
|
+
circleColorChecked: PropTypes.string,
|
|
33
|
+
circleColorUnchecked: PropTypes.string,
|
|
34
|
+
circleBorderColorActive: PropTypes.string,
|
|
35
|
+
circleBorderColorChecked: PropTypes.string,
|
|
36
|
+
circleBorderColorUnchecked: PropTypes.string,
|
|
295
37
|
lineColorActive: PropTypes.string,
|
|
296
38
|
lineColorInActive: PropTypes.string,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
borderColorInActive: PropTypes.string,
|
|
39
|
+
titleStyle: PropTypes.object,
|
|
40
|
+
descriptionStyle: PropTypes.object,
|
|
41
|
+
dateStyle: PropTypes.object,
|
|
301
42
|
};
|
|
302
43
|
|
|
303
44
|
Step.defaultProps = {
|
|
304
|
-
|
|
45
|
+
titles: [],
|
|
305
46
|
currentStep: 0,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
47
|
+
isVertical: false,
|
|
48
|
+
iconActive: IconSource.ic_check_24,
|
|
49
|
+
iconChecked: IconSource.ic_check_24,
|
|
50
|
+
iconUnchecked: IconSource.ic_check_24,
|
|
51
|
+
circleColorActive: '#d82d8b',
|
|
52
|
+
circleColorChecked: '#ffadd2',
|
|
53
|
+
circleColorUnchecked: Colors.black_06,
|
|
54
|
+
circleBorderColorActive: Colors.pink_09,
|
|
55
|
+
circleBorderColorChecked: Colors.pink_09,
|
|
56
|
+
circleBorderColorUnchecked: Colors.black_04,
|
|
57
|
+
lineColorActive: '#ffd6e7',
|
|
58
|
+
lineColorInActive: Colors.black_04,
|
|
59
|
+
};
|