@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.horizontal.web.js
CHANGED
|
@@ -17,13 +17,12 @@ const styles = StyleSheet.create({
|
|
|
17
17
|
borderWidth: 2,
|
|
18
18
|
padding: 4,
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
borderColor: Colors.pink_09,
|
|
20
|
+
iconImage: {
|
|
21
|
+
width: 16,
|
|
22
|
+
height: 16,
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
top: 2,
|
|
25
|
+
left: 2,
|
|
27
26
|
},
|
|
28
27
|
titleDefault: {
|
|
29
28
|
fontSize: 14,
|
|
@@ -78,12 +77,195 @@ export default class HorizontalStep extends Component {
|
|
|
78
77
|
});
|
|
79
78
|
};
|
|
80
79
|
|
|
81
|
-
|
|
80
|
+
_renderCircleImage = ({
|
|
81
|
+
icon = '',
|
|
82
|
+
circleColor = '',
|
|
83
|
+
circleBorderColor = '',
|
|
84
|
+
}) => {
|
|
85
|
+
return (
|
|
86
|
+
<View>
|
|
87
|
+
<View
|
|
88
|
+
style={[
|
|
89
|
+
styles.circle,
|
|
90
|
+
{
|
|
91
|
+
backgroundColor: circleColor,
|
|
92
|
+
borderColor: circleBorderColor,
|
|
93
|
+
},
|
|
94
|
+
]}>
|
|
95
|
+
<Image
|
|
96
|
+
source={icon}
|
|
97
|
+
style={[styles.iconImage, { tintColor: '#ffffff' }]}
|
|
98
|
+
/>
|
|
99
|
+
</View>
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
_renderCircleText = ({
|
|
105
|
+
circleColor = '',
|
|
106
|
+
circleBorderColor = '',
|
|
107
|
+
index = 0,
|
|
108
|
+
}) => {
|
|
82
109
|
return (
|
|
83
|
-
<View
|
|
84
|
-
<
|
|
110
|
+
<View>
|
|
111
|
+
<View
|
|
112
|
+
style={[
|
|
113
|
+
styles.circle,
|
|
114
|
+
{
|
|
115
|
+
backgroundColor: circleColor,
|
|
116
|
+
borderColor: circleBorderColor,
|
|
117
|
+
},
|
|
118
|
+
]}>
|
|
119
|
+
<Text style={styles.number}>{index + 1}</Text>
|
|
120
|
+
</View>
|
|
121
|
+
</View>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
_renderDateOrValue = ({
|
|
126
|
+
date = '',
|
|
127
|
+
isActiveState = false,
|
|
128
|
+
circleChecked = false,
|
|
129
|
+
minHeight = 0,
|
|
130
|
+
dateStyle = {},
|
|
131
|
+
index = 0,
|
|
132
|
+
}) => {
|
|
133
|
+
// Init states in render function
|
|
134
|
+
let resultComponent = <></>;
|
|
135
|
+
if (!date) {
|
|
136
|
+
return resultComponent;
|
|
137
|
+
}
|
|
138
|
+
if (isActiveState || circleChecked) {
|
|
139
|
+
resultComponent = (
|
|
140
|
+
<Text
|
|
141
|
+
style={[
|
|
142
|
+
styles.date,
|
|
143
|
+
dateStyle,
|
|
144
|
+
{ minHeight: 12, marginBottom: 4 },
|
|
145
|
+
]}>
|
|
146
|
+
{date[index]}
|
|
147
|
+
</Text>
|
|
148
|
+
);
|
|
149
|
+
} else {
|
|
150
|
+
resultComponent = <View style={minHeight}></View>;
|
|
151
|
+
}
|
|
152
|
+
return resultComponent;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
_renderCircle = ({
|
|
156
|
+
circleColor = '',
|
|
157
|
+
circleBorderColor = '',
|
|
158
|
+
isActiveState = false,
|
|
159
|
+
circleUnchecked = false,
|
|
160
|
+
iconActive = {},
|
|
161
|
+
iconUnchecked = {},
|
|
162
|
+
icon = {},
|
|
163
|
+
index = 0,
|
|
164
|
+
}) => {
|
|
165
|
+
let resultComponent = <></>;
|
|
166
|
+
if (!isActiveState) {
|
|
167
|
+
if (circleUnchecked) {
|
|
168
|
+
if (Object.keys(iconUnchecked).length === 0) {
|
|
169
|
+
resultComponent = this._renderCircleImage({
|
|
170
|
+
icon,
|
|
171
|
+
circleColor,
|
|
172
|
+
circleBorderColor,
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
resultComponent = this._renderCircleText({
|
|
176
|
+
circleColor,
|
|
177
|
+
circleBorderColor,
|
|
178
|
+
index,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
resultComponent = this._renderCircleImage({
|
|
183
|
+
icon,
|
|
184
|
+
circleColor,
|
|
185
|
+
circleBorderColor,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
// This is active case
|
|
190
|
+
// If icon diff "" & regex http or https url so will render image component
|
|
191
|
+
if (Object.keys(iconActive).length === 0) {
|
|
192
|
+
resultComponent = this._renderCircleImage({
|
|
193
|
+
icon,
|
|
194
|
+
circleColor,
|
|
195
|
+
circleBorderColor,
|
|
196
|
+
});
|
|
197
|
+
} else {
|
|
198
|
+
// Otherwise render index number in text component
|
|
199
|
+
resultComponent = resultComponent = this._renderCircleText({
|
|
200
|
+
circleColor,
|
|
201
|
+
circleBorderColor,
|
|
202
|
+
index,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return resultComponent;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
_renderTitle = ({ textFontStyle = {}, titleStyle = {}, value = {} }) => {
|
|
210
|
+
let resultComponent = (
|
|
211
|
+
<View>
|
|
212
|
+
<Text.Caption
|
|
213
|
+
style={[{ marginTop: 4 }, textFontStyle, titleStyle]}>
|
|
214
|
+
{value}
|
|
215
|
+
</Text.Caption>
|
|
85
216
|
</View>
|
|
86
217
|
);
|
|
218
|
+
return resultComponent;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
_renderDescription = ({ items = {}, descriptionStyle = {}, index = 0 }) => {
|
|
222
|
+
let resultComponent = <></>;
|
|
223
|
+
|
|
224
|
+
if (items) {
|
|
225
|
+
resultComponent = (
|
|
226
|
+
<View>
|
|
227
|
+
<Text style={[{ fontSize: 10 }, descriptionStyle]}>
|
|
228
|
+
{items[index]}
|
|
229
|
+
</Text>
|
|
230
|
+
</View>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
return resultComponent;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
_renderLine = ({
|
|
237
|
+
titles = {},
|
|
238
|
+
index = 0,
|
|
239
|
+
lineRight = 0,
|
|
240
|
+
lineWidth = 0,
|
|
241
|
+
lineActive = '',
|
|
242
|
+
date = {},
|
|
243
|
+
}) => {
|
|
244
|
+
let resultComponent = <></>;
|
|
245
|
+
|
|
246
|
+
if (titles?.length - 1 !== index) {
|
|
247
|
+
resultComponent = (
|
|
248
|
+
<View
|
|
249
|
+
style={{
|
|
250
|
+
position: 'absolute',
|
|
251
|
+
right: lineRight,
|
|
252
|
+
width: lineWidth,
|
|
253
|
+
zIndex: -1,
|
|
254
|
+
}}>
|
|
255
|
+
<View
|
|
256
|
+
style={[
|
|
257
|
+
styles.lineHorizontal,
|
|
258
|
+
{
|
|
259
|
+
backgroundColor: lineActive,
|
|
260
|
+
},
|
|
261
|
+
date ? { marginTop: 27 } : { marginTop: 27 - 16 },
|
|
262
|
+
/* subtracting spacing from date */
|
|
263
|
+
]}
|
|
264
|
+
/>
|
|
265
|
+
</View>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
return resultComponent;
|
|
87
269
|
};
|
|
88
270
|
|
|
89
271
|
circleColumn = (value, index) => {
|
|
@@ -91,40 +273,63 @@ export default class HorizontalStep extends Component {
|
|
|
91
273
|
currentStep,
|
|
92
274
|
titles,
|
|
93
275
|
iconActive,
|
|
94
|
-
|
|
276
|
+
iconChecked,
|
|
277
|
+
iconUnchecked,
|
|
278
|
+
circleColorActive,
|
|
279
|
+
circleColorChecked,
|
|
280
|
+
circleColorUnchecked,
|
|
281
|
+
circleBorderColorActive,
|
|
282
|
+
circleBorderColorChecked,
|
|
283
|
+
circleBorderColorUnchecked,
|
|
95
284
|
lineColorActive,
|
|
96
285
|
lineColorInActive,
|
|
97
286
|
items,
|
|
98
|
-
currentStepColor,
|
|
99
287
|
date,
|
|
100
288
|
isVertical,
|
|
101
289
|
titleStyle,
|
|
102
290
|
descriptionStyle,
|
|
103
291
|
dateStyle,
|
|
104
292
|
} = this.props;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
293
|
+
|
|
294
|
+
// Three circle states
|
|
295
|
+
const isActiveState = currentStep == index + 1;
|
|
296
|
+
const circleChecked = currentStep > index + 1;
|
|
297
|
+
const circleUnchecked = currentStep < index + 1;
|
|
298
|
+
|
|
299
|
+
// Default properties is inactive state
|
|
300
|
+
let icon = {};
|
|
301
|
+
let circleColor = circleColorUnchecked || Colors.black_06;
|
|
302
|
+
let circleBorderColor = circleBorderColorUnchecked || Colors.black_04;
|
|
303
|
+
let textFontStyle = styles.titleDefault;
|
|
304
|
+
let lineActive = lineColorInActive || Colors.black_04;
|
|
305
|
+
let minHeight = !isVertical && styles.minHeight;
|
|
306
|
+
|
|
307
|
+
let tintColor = '#ffd6e7';
|
|
308
|
+
|
|
309
|
+
// This is all properties in active state
|
|
310
|
+
if (isActiveState) {
|
|
311
|
+
icon = iconActive || index + 1;
|
|
312
|
+
circleColor = circleColorActive || '#d82d8b';
|
|
313
|
+
circleBorderColor = circleBorderColorActive || Colors.pink_09;
|
|
314
|
+
textFontStyle = styles.titleActive;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (circleChecked) {
|
|
318
|
+
icon = iconChecked || IconSource.ic_check_24;
|
|
319
|
+
lineActive = lineColorActive || tintColor;
|
|
320
|
+
circleColor = circleColorChecked || '#ffadd2';
|
|
321
|
+
circleBorderColor = circleBorderColorChecked || Colors.pink_09;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (circleUnchecked) {
|
|
325
|
+
icon = iconUnchecked || index + 1;
|
|
326
|
+
}
|
|
327
|
+
|
|
124
328
|
const lineWidth = Math.round(
|
|
125
329
|
(SCREEN_WIDTH - 10 - CIRCLE_SIZE - 4) / titles.length,
|
|
126
330
|
);
|
|
127
331
|
const lineRight = parseInt(`-${lineWidth / 2}`);
|
|
332
|
+
|
|
128
333
|
return (
|
|
129
334
|
<View
|
|
130
335
|
key={index}
|
|
@@ -138,85 +343,43 @@ export default class HorizontalStep extends Component {
|
|
|
138
343
|
flexDirection: 'column',
|
|
139
344
|
alignItems: 'center',
|
|
140
345
|
}}>
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
)
|
|
169
|
-
<View>
|
|
170
|
-
<Image
|
|
171
|
-
source={icon}
|
|
172
|
-
style={[
|
|
173
|
-
styles.checkedCircle,
|
|
174
|
-
{ tintColor: '#ffd6e7' },
|
|
175
|
-
]}
|
|
176
|
-
/>
|
|
177
|
-
</View>
|
|
178
|
-
)}
|
|
179
|
-
<View>
|
|
180
|
-
<Text.Caption
|
|
181
|
-
style={[
|
|
182
|
-
{ marginTop: 4 },
|
|
183
|
-
textFontStyle,
|
|
184
|
-
titleStyle,
|
|
185
|
-
]}>
|
|
186
|
-
{value}
|
|
187
|
-
</Text.Caption>
|
|
188
|
-
</View>
|
|
189
|
-
|
|
190
|
-
{items && (
|
|
191
|
-
<View>
|
|
192
|
-
<Text style={[{ fontSize: 10 }, descriptionStyle]}>
|
|
193
|
-
{items[index]}
|
|
194
|
-
</Text>
|
|
195
|
-
</View>
|
|
196
|
-
)}
|
|
346
|
+
{this._renderDateOrValue({
|
|
347
|
+
date,
|
|
348
|
+
isActiveState,
|
|
349
|
+
circleChecked,
|
|
350
|
+
minHeight,
|
|
351
|
+
dateStyle,
|
|
352
|
+
index,
|
|
353
|
+
})}
|
|
354
|
+
{this._renderCircle({
|
|
355
|
+
circleColor,
|
|
356
|
+
circleBorderColor,
|
|
357
|
+
isActiveState,
|
|
358
|
+
circleUnchecked,
|
|
359
|
+
iconActive,
|
|
360
|
+
iconUnchecked,
|
|
361
|
+
icon,
|
|
362
|
+
index,
|
|
363
|
+
})}
|
|
364
|
+
{this._renderTitle({
|
|
365
|
+
textFontStyle,
|
|
366
|
+
titleStyle,
|
|
367
|
+
value,
|
|
368
|
+
})}
|
|
369
|
+
{this._renderDescription({
|
|
370
|
+
items,
|
|
371
|
+
descriptionStyle,
|
|
372
|
+
index,
|
|
373
|
+
})}
|
|
197
374
|
</View>
|
|
198
|
-
{
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
<View
|
|
207
|
-
style={[
|
|
208
|
-
styles.lineHorizontal,
|
|
209
|
-
{
|
|
210
|
-
backgroundColor: lineActive,
|
|
211
|
-
},
|
|
212
|
-
date
|
|
213
|
-
? { marginTop: 27 }
|
|
214
|
-
: { marginTop: 27 - 16 },
|
|
215
|
-
/* subtracting spacing from date */
|
|
216
|
-
]}
|
|
217
|
-
/>
|
|
218
|
-
</View>
|
|
219
|
-
)}
|
|
375
|
+
{this._renderLine({
|
|
376
|
+
titles,
|
|
377
|
+
index,
|
|
378
|
+
lineRight,
|
|
379
|
+
lineWidth,
|
|
380
|
+
lineActive,
|
|
381
|
+
date,
|
|
382
|
+
})}
|
|
220
383
|
</View>
|
|
221
384
|
);
|
|
222
385
|
};
|
|
@@ -250,11 +413,16 @@ HorizontalStep.propTypes = {
|
|
|
250
413
|
items: PropTypes.array,
|
|
251
414
|
isVertical: PropTypes.bool,
|
|
252
415
|
iconActive: PropTypes.any,
|
|
253
|
-
|
|
416
|
+
iconChecked: PropTypes.any,
|
|
417
|
+
iconUnchecked: PropTypes.any,
|
|
418
|
+
circleColorActive: PropTypes.string,
|
|
419
|
+
circleColorChecked: PropTypes.string,
|
|
420
|
+
circleColorUnchecked: PropTypes.string,
|
|
421
|
+
circleBorderColorActive: PropTypes.string,
|
|
422
|
+
circleBorderColorChecked: PropTypes.string,
|
|
423
|
+
circleBorderColorUnchecked: PropTypes.string,
|
|
254
424
|
lineColorActive: PropTypes.string,
|
|
255
425
|
lineColorInActive: PropTypes.string,
|
|
256
|
-
borderColorActive: PropTypes.string,
|
|
257
|
-
borderColorInActive: PropTypes.string,
|
|
258
426
|
titleStyle: PropTypes.object,
|
|
259
427
|
descriptionStyle: PropTypes.object,
|
|
260
428
|
dateStyle: PropTypes.object,
|
package/Step.js
CHANGED
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import HorizontalStep from './Step.horizontal';
|
|
4
4
|
import VerticalStep from './Step.vertical';
|
|
5
5
|
|
|
6
|
+
import { Colors, IconSource } from '@momo-kits/core';
|
|
6
7
|
export default class Step extends Component {
|
|
7
8
|
constructor(props) {
|
|
8
9
|
super(props);
|
|
@@ -25,11 +26,16 @@ Step.propTypes = {
|
|
|
25
26
|
items: PropTypes.array,
|
|
26
27
|
isVertical: PropTypes.bool,
|
|
27
28
|
iconActive: PropTypes.any,
|
|
28
|
-
|
|
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,
|
|
29
37
|
lineColorActive: PropTypes.string,
|
|
30
38
|
lineColorInActive: PropTypes.string,
|
|
31
|
-
borderColorActive: PropTypes.string,
|
|
32
|
-
borderColorInActive: PropTypes.string,
|
|
33
39
|
titleStyle: PropTypes.object,
|
|
34
40
|
descriptionStyle: PropTypes.object,
|
|
35
41
|
dateStyle: PropTypes.object,
|
|
@@ -38,4 +44,16 @@ Step.propTypes = {
|
|
|
38
44
|
Step.defaultProps = {
|
|
39
45
|
titles: [],
|
|
40
46
|
currentStep: 0,
|
|
47
|
+
isVertical: false,
|
|
48
|
+
iconActive: 'index + 1',
|
|
49
|
+
iconChecked: IconSource.ic_check_24,
|
|
50
|
+
iconUnchecked: 'index + 1',
|
|
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,
|
|
41
59
|
};
|