@momo-kits/step 0.0.43-beta.26 → 0.0.43-beta.29
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.horizontal.js +290 -117
- package/Step.horizontal.web.js +298 -121
- package/Step.js +24 -4
- package/Step.vertical.js +268 -112
- package/Step.vertical.web.js +274 -112
- package/Step.web.js +25 -4
- package/package.json +1 -1
package/Step.vertical.web.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { View, StyleSheet, Image } from 'react-native';
|
|
2
|
+
import { View, StyleSheet, Image, ScrollView } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import Colors from '../../core/colors';
|
|
@@ -8,15 +8,6 @@ import { Icons as IconSource } from '../../core/icons';
|
|
|
8
8
|
|
|
9
9
|
const CIRCLE_SIZE = 24;
|
|
10
10
|
|
|
11
|
-
// this is layout of each item (flexdirection row)
|
|
12
|
-
// this is left container (flex 0.2, )
|
|
13
|
-
// this is value label
|
|
14
|
-
// this is image
|
|
15
|
-
// this is caption label
|
|
16
|
-
// this is desc label
|
|
17
|
-
// this is right container (flex 0.8)
|
|
18
|
-
// this is line (width flex = 1 or width 100 percent)
|
|
19
|
-
|
|
20
11
|
const styles = StyleSheet.create({
|
|
21
12
|
circle: {
|
|
22
13
|
width: CIRCLE_SIZE,
|
|
@@ -25,13 +16,12 @@ const styles = StyleSheet.create({
|
|
|
25
16
|
borderWidth: 2,
|
|
26
17
|
padding: 4,
|
|
27
18
|
},
|
|
28
|
-
|
|
29
|
-
width:
|
|
30
|
-
height:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
borderColor: Colors.pink_09,
|
|
19
|
+
iconImage: {
|
|
20
|
+
width: 16,
|
|
21
|
+
height: 16,
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
top: 2,
|
|
24
|
+
left: 2,
|
|
35
25
|
},
|
|
36
26
|
titleDefault: {
|
|
37
27
|
color: Colors.black_12,
|
|
@@ -43,8 +33,15 @@ const styles = StyleSheet.create({
|
|
|
43
33
|
fontSize: 14,
|
|
44
34
|
fontWeight: 'bold',
|
|
45
35
|
},
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
container: {
|
|
37
|
+
width: '100%',
|
|
38
|
+
paddingRight: 48,
|
|
39
|
+
marginTop: 4,
|
|
40
|
+
},
|
|
41
|
+
titleAndDate: {
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
justifyContent: 'space-between',
|
|
44
|
+
alignItems: 'center',
|
|
48
45
|
},
|
|
49
46
|
description: {
|
|
50
47
|
fontSize: 12,
|
|
@@ -93,113 +90,266 @@ export default class VerticalStep extends Component {
|
|
|
93
90
|
});
|
|
94
91
|
};
|
|
95
92
|
|
|
96
|
-
|
|
93
|
+
/* #region render cust */
|
|
94
|
+
_renderCircleImage = ({ icon = '', circleColor, circleBorderColor }) => {
|
|
97
95
|
return (
|
|
98
|
-
<View
|
|
99
|
-
<
|
|
96
|
+
<View>
|
|
97
|
+
<View
|
|
98
|
+
style={[
|
|
99
|
+
styles.circle,
|
|
100
|
+
{
|
|
101
|
+
backgroundColor: circleColor,
|
|
102
|
+
borderColor: circleBorderColor,
|
|
103
|
+
},
|
|
104
|
+
]}>
|
|
105
|
+
<Image
|
|
106
|
+
source={icon}
|
|
107
|
+
style={[styles.iconImage, { tintColor: '#ffffff' }]}
|
|
108
|
+
/>
|
|
109
|
+
</View>
|
|
110
|
+
</View>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
_renderCircleText = ({
|
|
115
|
+
circleColor = '',
|
|
116
|
+
circleBorderColor = '',
|
|
117
|
+
index = 0,
|
|
118
|
+
}) => {
|
|
119
|
+
return (
|
|
120
|
+
<View>
|
|
121
|
+
<View
|
|
122
|
+
style={[
|
|
123
|
+
styles.circle,
|
|
124
|
+
{
|
|
125
|
+
backgroundColor: circleColor,
|
|
126
|
+
borderColor: circleBorderColor,
|
|
127
|
+
},
|
|
128
|
+
]}>
|
|
129
|
+
<Text style={styles.number}>{index + 1}</Text>
|
|
130
|
+
</View>
|
|
131
|
+
</View>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
_renderCircle = ({
|
|
136
|
+
circleColor = '',
|
|
137
|
+
circleBorderColor = '',
|
|
138
|
+
isActiveState = false,
|
|
139
|
+
circleUnchecked = false,
|
|
140
|
+
iconActive,
|
|
141
|
+
iconUnchecked,
|
|
142
|
+
icon = {},
|
|
143
|
+
index = 0,
|
|
144
|
+
}) => {
|
|
145
|
+
let resultComponent = <></>;
|
|
146
|
+
if (!isActiveState) {
|
|
147
|
+
if (circleUnchecked) {
|
|
148
|
+
if (Object.keys(iconUnchecked).length === 0) {
|
|
149
|
+
resultComponent = this._renderCircleImage({
|
|
150
|
+
icon,
|
|
151
|
+
circleColor,
|
|
152
|
+
circleBorderColor,
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
resultComponent = this._renderCircleText({
|
|
156
|
+
circleColor,
|
|
157
|
+
circleBorderColor,
|
|
158
|
+
index,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
resultComponent = this._renderCircleImage({
|
|
163
|
+
icon,
|
|
164
|
+
circleColor,
|
|
165
|
+
circleBorderColor,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
// This is active case
|
|
170
|
+
// If icon diff "" & regex http or https url so will render image component
|
|
171
|
+
if (Object.keys(iconActive).length === 0) {
|
|
172
|
+
resultComponent = this._renderCircleImage({
|
|
173
|
+
icon,
|
|
174
|
+
circleColor,
|
|
175
|
+
circleBorderColor,
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
// Otherwise render index number in text component
|
|
179
|
+
resultComponent = resultComponent = this._renderCircleText({
|
|
180
|
+
circleColor,
|
|
181
|
+
circleBorderColor,
|
|
182
|
+
index,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return resultComponent;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
_renderLine = ({ titles = {}, index = 0, lineActive = '' }) => {
|
|
190
|
+
let resultComponent = <></>;
|
|
191
|
+
|
|
192
|
+
if (titles?.length - 1 !== index) {
|
|
193
|
+
resultComponent = (
|
|
194
|
+
<View
|
|
195
|
+
style={[
|
|
196
|
+
styles.lineVertical,
|
|
197
|
+
{
|
|
198
|
+
backgroundColor: lineActive,
|
|
199
|
+
},
|
|
200
|
+
]}
|
|
201
|
+
/>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return resultComponent;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
_renderTitle = ({ textFontStyle = {}, titleStyle = {}, value = {} }) => {
|
|
208
|
+
let resultComponent = (
|
|
209
|
+
<View>
|
|
210
|
+
<Text.Caption
|
|
211
|
+
style={[{ marginLeft: 10 }, textFontStyle, titleStyle]}>
|
|
212
|
+
{value}
|
|
213
|
+
</Text.Caption>
|
|
100
214
|
</View>
|
|
101
215
|
);
|
|
216
|
+
return resultComponent;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
_renderDateOrValue = ({
|
|
220
|
+
date = '',
|
|
221
|
+
isActiveState = false,
|
|
222
|
+
circleChecked = false,
|
|
223
|
+
dateStyle = {},
|
|
224
|
+
index = 0,
|
|
225
|
+
}) => {
|
|
226
|
+
// Init states in render function
|
|
227
|
+
let resultComponent = <></>;
|
|
228
|
+
if (!date) {
|
|
229
|
+
return resultComponent;
|
|
230
|
+
}
|
|
231
|
+
if (isActiveState || circleChecked) {
|
|
232
|
+
resultComponent = (
|
|
233
|
+
<Text style={[styles.date, dateStyle]}>{date[index]}</Text>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
return resultComponent;
|
|
102
237
|
};
|
|
103
238
|
|
|
239
|
+
_renderDescription = ({ items = {}, descriptionStyle = {}, index = 0 }) => {
|
|
240
|
+
let resultComponent = <></>;
|
|
241
|
+
|
|
242
|
+
if (items) {
|
|
243
|
+
resultComponent = (
|
|
244
|
+
<View>
|
|
245
|
+
{typeof items[index] == 'string' ? (
|
|
246
|
+
<Text style={[styles.description, descriptionStyle]}>
|
|
247
|
+
{items[index]}
|
|
248
|
+
</Text>
|
|
249
|
+
) : (
|
|
250
|
+
<View style={[styles.description]}>{items[index]}</View>
|
|
251
|
+
)}
|
|
252
|
+
</View>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return resultComponent;
|
|
256
|
+
};
|
|
257
|
+
/* #endregion */
|
|
258
|
+
|
|
104
259
|
circleColumn = (value, index) => {
|
|
105
260
|
const {
|
|
106
261
|
currentStep,
|
|
107
262
|
titles,
|
|
108
|
-
lineStyle,
|
|
109
263
|
iconActive,
|
|
110
|
-
|
|
264
|
+
iconChecked,
|
|
265
|
+
iconUnchecked,
|
|
266
|
+
circleColorActive,
|
|
267
|
+
circleColorChecked,
|
|
268
|
+
circleColorUnchecked,
|
|
269
|
+
circleBorderColorActive,
|
|
270
|
+
circleBorderColorChecked,
|
|
271
|
+
circleBorderColorUnchecked,
|
|
111
272
|
lineColorActive,
|
|
112
273
|
lineColorInActive,
|
|
113
274
|
items,
|
|
114
|
-
currentStepColor,
|
|
115
275
|
date,
|
|
116
|
-
|
|
276
|
+
titleStyle,
|
|
277
|
+
descriptionStyle,
|
|
278
|
+
dateStyle,
|
|
117
279
|
} = this.props;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
280
|
+
|
|
281
|
+
// Three circle states
|
|
282
|
+
const isActiveState = currentStep == index + 1;
|
|
283
|
+
const circleChecked = currentStep > index + 1;
|
|
284
|
+
const circleUnchecked = currentStep < index + 1;
|
|
285
|
+
|
|
286
|
+
// Default properties is inactive state
|
|
287
|
+
let icon = {};
|
|
288
|
+
let circleColor = circleColorUnchecked || Colors.black_06;
|
|
289
|
+
let circleBorderColor = circleBorderColorUnchecked || Colors.black_04;
|
|
290
|
+
let textFontStyle = styles.titleDefault;
|
|
291
|
+
let lineActive = lineColorInActive || Colors.black_04;
|
|
292
|
+
|
|
293
|
+
let tintColor = '#ffd6e7';
|
|
294
|
+
|
|
295
|
+
// This is all properties in active state
|
|
296
|
+
if (isActiveState) {
|
|
297
|
+
icon = iconActive || index + 1;
|
|
298
|
+
circleColor = circleColorActive || '#d82d8b';
|
|
299
|
+
circleBorderColor = circleBorderColorActive || Colors.pink_09;
|
|
300
|
+
textFontStyle = styles.titleActive;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (circleChecked) {
|
|
304
|
+
icon = iconChecked || IconSource.ic_check_24;
|
|
305
|
+
lineActive = lineColorActive || tintColor;
|
|
306
|
+
circleColor = circleColorChecked || '#ffadd2';
|
|
307
|
+
circleBorderColor = circleBorderColorChecked || Colors.pink_09;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (circleUnchecked) {
|
|
311
|
+
icon = iconUnchecked || index + 1;
|
|
312
|
+
}
|
|
313
|
+
|
|
136
314
|
return (
|
|
137
315
|
<View key={index} style={{ flexDirection: 'row' }}>
|
|
138
316
|
<View>
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
)
|
|
154
|
-
<View>
|
|
155
|
-
<Image
|
|
156
|
-
source={icon}
|
|
157
|
-
style={[
|
|
158
|
-
styles.checkedCircle,
|
|
159
|
-
{ tintColor: '#ffd6e7' },
|
|
160
|
-
]}
|
|
161
|
-
/>
|
|
162
|
-
</View>
|
|
163
|
-
)}
|
|
164
|
-
{titles?.length - 1 !== index && (
|
|
165
|
-
<View
|
|
166
|
-
style={[
|
|
167
|
-
styles.lineVertical,
|
|
168
|
-
{
|
|
169
|
-
backgroundColor: lineActive,
|
|
170
|
-
},
|
|
171
|
-
lineStyle,
|
|
172
|
-
]}
|
|
173
|
-
/>
|
|
174
|
-
)}
|
|
317
|
+
{this._renderCircle({
|
|
318
|
+
circleColor,
|
|
319
|
+
circleBorderColor,
|
|
320
|
+
isActiveState,
|
|
321
|
+
circleUnchecked,
|
|
322
|
+
iconActive,
|
|
323
|
+
iconUnchecked,
|
|
324
|
+
icon,
|
|
325
|
+
index,
|
|
326
|
+
})}
|
|
327
|
+
{this._renderLine({
|
|
328
|
+
titles,
|
|
329
|
+
index,
|
|
330
|
+
lineActive,
|
|
331
|
+
})}
|
|
175
332
|
</View>
|
|
176
|
-
<View
|
|
177
|
-
style={
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
)}
|
|
191
|
-
</View>
|
|
192
|
-
<View>
|
|
193
|
-
{typeof items[index] == 'string' ? (
|
|
194
|
-
<Text style={[styles.description]}>
|
|
195
|
-
{items[index]}
|
|
196
|
-
</Text>
|
|
197
|
-
) : (
|
|
198
|
-
<View style={[styles.description]}>
|
|
199
|
-
{items[index]}
|
|
200
|
-
</View>
|
|
201
|
-
)}
|
|
333
|
+
<View style={styles.container}>
|
|
334
|
+
<View style={styles.titleAndDate}>
|
|
335
|
+
{this._renderTitle({
|
|
336
|
+
textFontStyle,
|
|
337
|
+
titleStyle,
|
|
338
|
+
value,
|
|
339
|
+
})}
|
|
340
|
+
{this._renderDateOrValue({
|
|
341
|
+
date,
|
|
342
|
+
isActiveState,
|
|
343
|
+
circleChecked,
|
|
344
|
+
dateStyle,
|
|
345
|
+
index,
|
|
346
|
+
})}
|
|
202
347
|
</View>
|
|
348
|
+
{this._renderDescription({
|
|
349
|
+
items,
|
|
350
|
+
descriptionStyle,
|
|
351
|
+
index,
|
|
352
|
+
})}
|
|
203
353
|
</View>
|
|
204
354
|
</View>
|
|
205
355
|
);
|
|
@@ -212,9 +362,13 @@ export default class VerticalStep extends Component {
|
|
|
212
362
|
|
|
213
363
|
render() {
|
|
214
364
|
return (
|
|
215
|
-
<
|
|
216
|
-
<View
|
|
217
|
-
|
|
365
|
+
<ScrollView>
|
|
366
|
+
<View onLayout={this.onLayout}>
|
|
367
|
+
<View style={[styles.circleColumn]}>
|
|
368
|
+
{this.renderCircle()}
|
|
369
|
+
</View>
|
|
370
|
+
</View>
|
|
371
|
+
</ScrollView>
|
|
218
372
|
);
|
|
219
373
|
}
|
|
220
374
|
}
|
|
@@ -226,11 +380,19 @@ VerticalStep.propTypes = {
|
|
|
226
380
|
items: PropTypes.array,
|
|
227
381
|
isVertical: PropTypes.bool,
|
|
228
382
|
iconActive: PropTypes.any,
|
|
229
|
-
|
|
383
|
+
iconChecked: PropTypes.any,
|
|
384
|
+
iconUnchecked: PropTypes.any,
|
|
385
|
+
circleColorActive: PropTypes.string,
|
|
386
|
+
circleColorChecked: PropTypes.string,
|
|
387
|
+
circleColorUnchecked: PropTypes.string,
|
|
388
|
+
circleBorderColorActive: PropTypes.string,
|
|
389
|
+
circleBorderColorChecked: PropTypes.string,
|
|
390
|
+
circleBorderColorUnchecked: PropTypes.string,
|
|
230
391
|
lineColorActive: PropTypes.string,
|
|
231
392
|
lineColorInActive: PropTypes.string,
|
|
232
|
-
|
|
233
|
-
|
|
393
|
+
titleStyle: PropTypes.object,
|
|
394
|
+
descriptionStyle: PropTypes.object,
|
|
395
|
+
dateStyle: PropTypes.object,
|
|
234
396
|
};
|
|
235
397
|
|
|
236
398
|
VerticalStep.defaultProps = {
|
package/Step.web.js
CHANGED
|
@@ -3,6 +3,8 @@ import React, { Component } from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import HorizontalStep from './Step.horizontal.web.js';
|
|
5
5
|
import VerticalStep from './Step.vertical.web.js';
|
|
6
|
+
import Colors from '../../core/colors';
|
|
7
|
+
import { Icons as IconSource } from '../../core/icons';
|
|
6
8
|
|
|
7
9
|
export default class Step extends Component {
|
|
8
10
|
constructor(props) {
|
|
@@ -26,15 +28,34 @@ Step.propTypes = {
|
|
|
26
28
|
items: PropTypes.array,
|
|
27
29
|
isVertical: PropTypes.bool,
|
|
28
30
|
iconActive: PropTypes.any,
|
|
29
|
-
|
|
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,
|
|
30
39
|
lineColorActive: PropTypes.string,
|
|
31
40
|
lineColorInActive: PropTypes.string,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
titleStyle: PropTypes.object,
|
|
42
|
+
descriptionStyle: PropTypes.object,
|
|
43
|
+
dateStyle: PropTypes.object,
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
Step.defaultProps = {
|
|
38
47
|
titles: [],
|
|
39
48
|
currentStep: 0,
|
|
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,
|
|
40
61
|
};
|