@momo-kits/step 0.0.43-beta.27 → 0.0.43-beta.28
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 +280 -112
- package/Step.horizontal.web.js +280 -112
- package/Step.js +21 -3
- package/Step.vertical.js +261 -111
- package/Step.vertical.web.js +261 -111
- package/Step.web.js +22 -3
- package/package.json +1 -1
package/Step.vertical.web.js
CHANGED
|
@@ -16,13 +16,12 @@ const styles = StyleSheet.create({
|
|
|
16
16
|
borderWidth: 2,
|
|
17
17
|
padding: 4,
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
width:
|
|
21
|
-
height:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
borderColor: Colors.pink_09,
|
|
19
|
+
iconImage: {
|
|
20
|
+
width: 16,
|
|
21
|
+
height: 16,
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
top: 2,
|
|
24
|
+
left: 2,
|
|
26
25
|
},
|
|
27
26
|
titleDefault: {
|
|
28
27
|
color: Colors.black_12,
|
|
@@ -34,8 +33,15 @@ const styles = StyleSheet.create({
|
|
|
34
33
|
fontSize: 14,
|
|
35
34
|
fontWeight: 'bold',
|
|
36
35
|
},
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
container: {
|
|
37
|
+
width: '100%',
|
|
38
|
+
paddingRight: 48,
|
|
39
|
+
marginTop: 4,
|
|
40
|
+
},
|
|
41
|
+
titleAndDate: {
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
justifyContent: 'space-between',
|
|
44
|
+
alignItems: 'center',
|
|
39
45
|
},
|
|
40
46
|
description: {
|
|
41
47
|
fontSize: 12,
|
|
@@ -84,127 +90,266 @@ export default class VerticalStep extends Component {
|
|
|
84
90
|
});
|
|
85
91
|
};
|
|
86
92
|
|
|
87
|
-
|
|
93
|
+
/* #region render cust */
|
|
94
|
+
_renderCircleImage = ({ icon = '', circleColor, circleBorderColor }) => {
|
|
88
95
|
return (
|
|
89
|
-
<View
|
|
90
|
-
<
|
|
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>
|
|
91
214
|
</View>
|
|
92
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;
|
|
237
|
+
};
|
|
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;
|
|
93
256
|
};
|
|
257
|
+
/* #endregion */
|
|
94
258
|
|
|
95
259
|
circleColumn = (value, index) => {
|
|
96
260
|
const {
|
|
97
261
|
currentStep,
|
|
98
262
|
titles,
|
|
99
|
-
lineStyle,
|
|
100
263
|
iconActive,
|
|
101
|
-
|
|
264
|
+
iconChecked,
|
|
265
|
+
iconUnchecked,
|
|
266
|
+
circleColorActive,
|
|
267
|
+
circleColorChecked,
|
|
268
|
+
circleColorUnchecked,
|
|
269
|
+
circleBorderColorActive,
|
|
270
|
+
circleBorderColorChecked,
|
|
271
|
+
circleBorderColorUnchecked,
|
|
102
272
|
lineColorActive,
|
|
103
273
|
lineColorInActive,
|
|
104
274
|
items,
|
|
105
|
-
currentStepColor,
|
|
106
275
|
date,
|
|
107
276
|
titleStyle,
|
|
108
277
|
descriptionStyle,
|
|
109
278
|
dateStyle,
|
|
110
279
|
} = this.props;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
+
|
|
129
314
|
return (
|
|
130
315
|
<View key={index} style={{ flexDirection: 'row' }}>
|
|
131
316
|
<View>
|
|
132
|
-
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
)
|
|
147
|
-
<View>
|
|
148
|
-
<Image
|
|
149
|
-
source={icon}
|
|
150
|
-
style={[
|
|
151
|
-
styles.checkedCircle,
|
|
152
|
-
{ tintColor: '#ffd6e7' },
|
|
153
|
-
]}
|
|
154
|
-
/>
|
|
155
|
-
</View>
|
|
156
|
-
)}
|
|
157
|
-
{titles?.length - 1 !== index && (
|
|
158
|
-
<View
|
|
159
|
-
style={[
|
|
160
|
-
styles.lineVertical,
|
|
161
|
-
{
|
|
162
|
-
backgroundColor: lineActive,
|
|
163
|
-
},
|
|
164
|
-
lineStyle,
|
|
165
|
-
]}
|
|
166
|
-
/>
|
|
167
|
-
)}
|
|
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
|
+
})}
|
|
168
332
|
</View>
|
|
169
|
-
<View
|
|
170
|
-
style={
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
{value}
|
|
184
|
-
</Text.Caption>
|
|
185
|
-
{date && currentStep >= index + 1 && (
|
|
186
|
-
<Text style={[styles.date, dateStyle]}>
|
|
187
|
-
{date[index]}
|
|
188
|
-
</Text>
|
|
189
|
-
)}
|
|
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
|
+
})}
|
|
190
347
|
</View>
|
|
191
|
-
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
styles.description,
|
|
197
|
-
descriptionStyle,
|
|
198
|
-
]}>
|
|
199
|
-
{items[index]}
|
|
200
|
-
</Text>
|
|
201
|
-
) : (
|
|
202
|
-
<View style={[styles.description]}>
|
|
203
|
-
{items[index]}
|
|
204
|
-
</View>
|
|
205
|
-
)}
|
|
206
|
-
</View>
|
|
207
|
-
)}
|
|
348
|
+
{this._renderDescription({
|
|
349
|
+
items,
|
|
350
|
+
descriptionStyle,
|
|
351
|
+
index,
|
|
352
|
+
})}
|
|
208
353
|
</View>
|
|
209
354
|
</View>
|
|
210
355
|
);
|
|
@@ -218,7 +363,7 @@ export default class VerticalStep extends Component {
|
|
|
218
363
|
render() {
|
|
219
364
|
return (
|
|
220
365
|
<ScrollView>
|
|
221
|
-
<View
|
|
366
|
+
<View onLayout={this.onLayout}>
|
|
222
367
|
<View style={[styles.circleColumn]}>
|
|
223
368
|
{this.renderCircle()}
|
|
224
369
|
</View>
|
|
@@ -235,11 +380,16 @@ VerticalStep.propTypes = {
|
|
|
235
380
|
items: PropTypes.array,
|
|
236
381
|
isVertical: PropTypes.bool,
|
|
237
382
|
iconActive: PropTypes.any,
|
|
238
|
-
|
|
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,
|
|
239
391
|
lineColorActive: PropTypes.string,
|
|
240
392
|
lineColorInActive: PropTypes.string,
|
|
241
|
-
borderColorActive: PropTypes.string,
|
|
242
|
-
borderColorInActive: PropTypes.string,
|
|
243
393
|
titleStyle: PropTypes.object,
|
|
244
394
|
descriptionStyle: PropTypes.object,
|
|
245
395
|
dateStyle: PropTypes.object,
|
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,11 +28,16 @@ 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
|
-
borderColorActive: PropTypes.string,
|
|
33
|
-
borderColorInActive: PropTypes.string,
|
|
34
41
|
titleStyle: PropTypes.object,
|
|
35
42
|
descriptionStyle: PropTypes.object,
|
|
36
43
|
dateStyle: PropTypes.object,
|
|
@@ -39,4 +46,16 @@ Step.propTypes = {
|
|
|
39
46
|
Step.defaultProps = {
|
|
40
47
|
titles: [],
|
|
41
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,
|
|
42
61
|
};
|