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