@momo-kits/step 0.0.34-beta → 0.0.34

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.js CHANGED
@@ -1 +1,308 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _propTypes=_interopRequireDefault(require("prop-types"));var _NewAppScreen=require("react-native/Libraries/NewAppScreen");var _jsxFileName="/Users/trinh.ho2/momo-folk/kits/src/libs/step/dist/Step.js";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2.default)(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2.default)(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2.default)(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var CIRCLE_SIZE=18;var styles=_reactNative.StyleSheet.create({circle:{width:CIRCLE_SIZE,height:CIRCLE_SIZE,borderWidth:1,borderColor:_NewAppScreen.Colors.sepia_05,borderRadius:9,backgroundColor:'white'},line:{height:1,backgroundColor:'white',borderWidth:1,borderRadius:1,borderStyle:'dashed',zIndex:0,marginTop:9},topRight:{position:'absolute',right:-1,top:-1,width:1,height:'100%',backgroundColor:'white',zIndex:1},topLeft:{position:'absolute',left:-1,top:-1,width:'100%',height:1,backgroundColor:'white',zIndex:1},topLeftWidth:{position:'absolute',left:-1,top:-1,width:1,height:'100%',backgroundColor:'white',zIndex:1},circleRow:{position:'absolute',justifyContent:'space-between',flexDirection:'row'},titleDefault:{color:_NewAppScreen.Colors.black_12},titleActive:{color:_NewAppScreen.Colors.black_17,fontWeight:'bold'},containerStyle:{minHeight:CIRCLE_SIZE+20+CIRCLE_SIZE}});var Step=function(_Component){(0,_inherits2.default)(Step,_Component);var _super=_createSuper(Step);function Step(props){var _this;(0,_classCallCheck2.default)(this,Step);_this=_super.call(this,props);_this.onLayout=function(e){_this.setState({width:e.nativeEvent.layout.width});};_this.renderLine=function(){var lineColor=_this.props.lineColor;return _react.default.createElement(_reactNative.View,{style:[styles.line,{borderColor:lineColor}],__source:{fileName:_jsxFileName,lineNumber:86,columnNumber:13}},_react.default.createElement(_reactNative.View,{style:styles.topLeft,__source:{fileName:_jsxFileName,lineNumber:87,columnNumber:17}}),_react.default.createElement(_reactNative.View,{style:styles.topLeftWidth,__source:{fileName:_jsxFileName,lineNumber:88,columnNumber:17}}),_react.default.createElement(_reactNative.View,{style:styles.topRight,__source:{fileName:_jsxFileName,lineNumber:89,columnNumber:17}}));};_this.circle=function(value,index){var _this$props=_this.props,currentStep=_this$props.currentStep,tintColor=_this$props.tintColor,data=_this$props.data;var width=_this.state.width;var icon=currentStep>=index+1?_NewAppScreen.IconSource.ic_step_active:_NewAppScreen.IconSource.ic_step_coming;var textFontStyle=currentStep>=index+1?styles.titleActive:styles.titleDefault;var itemWidth=(width-CIRCLE_SIZE)/(data==null?void 0:data.length);var left=0;var textAlignStyle={textAlign:'center'};if(index===0){left=0;textAlignStyle={textAlign:'left'};}else if(index===(data==null?void 0:data.length)-1){left=-itemWidth+CIRCLE_SIZE;textAlignStyle={textAlign:'right'};}else{left=-itemWidth/2+CIRCLE_SIZE/2;}var textStyle=[textAlignStyle,textFontStyle];return _react.default.createElement(_reactNative.View,{__source:{fileName:_jsxFileName,lineNumber:121,columnNumber:13}},_react.default.createElement(_NewAppScreen.Image,{source:icon,style:[styles.circle,{tintColor:tintColor}],__source:{fileName:_jsxFileName,lineNumber:122,columnNumber:17}}),_react.default.createElement(_reactNative.View,{style:{position:'absolute',width:itemWidth,left:left,top:CIRCLE_SIZE+CIRCLE_SIZE/2},__source:{fileName:_jsxFileName,lineNumber:123,columnNumber:17}},_react.default.createElement(_NewAppScreen.Text.Title,{style:textStyle,__source:{fileName:_jsxFileName,lineNumber:130,columnNumber:21}},value)));};_this.renderCircle=function(){var _this$props$data=_this.props.data,data=_this$props$data===void 0?[]:_this$props$data;var views=data.map(_this.circle);return views;};_this.state={width:0};return _this;}(0,_createClass2.default)(Step,[{key:"render",value:function render(){var width=this.state.width;var style=this.props.style;return _react.default.createElement(_reactNative.View,{style:[styles.containerStyle,style],onLayout:this.onLayout,__source:{fileName:_jsxFileName,lineNumber:146,columnNumber:13}},this.renderLine(),_react.default.createElement(_reactNative.View,{style:[styles.circleRow,{width:width}],__source:{fileName:_jsxFileName,lineNumber:148,columnNumber:17}},this.renderCircle()));}}]);return Step;}(_react.Component);exports.default=Step;Step.propTypes={lineColor:_propTypes.default.string,data:_propTypes.default.arrayOf(_propTypes.default.string),currentStep:_propTypes.default.number,tintColor:_propTypes.default.string,style:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array])};Step.defaultProps={data:[],lineColor:_NewAppScreen.Colors.sepia_05,currentStep:0,tintColor:_NewAppScreen.Colors.sepia_05};
1
+ import React, { Component } from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+
4
+ import PropTypes from 'prop-types';
5
+ import {
6
+ Colors, Text, IconSource, Image
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
+ });
76
+
77
+ export default class Step extends Component {
78
+ constructor(props) {
79
+ 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
+ }
262
+
263
+ render() {
264
+ const { width, height } = this.state;
265
+ const { style, isVertical } = this.props;
266
+ return (
267
+ <View style={[styles.containerStyle, style]} onLayout={this.onLayout}>
268
+ {/* {this.renderLine()} */}
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
+ );
283
+ }
284
+ }
285
+
286
+ Step.propTypes = {
287
+ data: PropTypes.arrayOf(PropTypes.string),
288
+ currentStep: PropTypes.number,
289
+ tintColor: PropTypes.string,
290
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
291
+ isNumber: PropTypes.bool,
292
+ isVertical: PropTypes.bool,
293
+ iconActive: PropTypes.any,
294
+ iconInActive: PropTypes.any,
295
+ lineColorActive: PropTypes.string,
296
+ lineColorInActive: PropTypes.string,
297
+ bodyStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
298
+ checkedPreviousStep: PropTypes.bool,
299
+ borderColorActive: PropTypes.string,
300
+ borderColorInActive: PropTypes.string,
301
+ };
302
+
303
+ Step.defaultProps = {
304
+ data: [],
305
+ currentStep: 0,
306
+ tintColor: Colors.sepia_05,
307
+ checkedPreviousStep: false,
308
+ };
package/Step.web.js CHANGED
@@ -1 +1,306 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _propTypes=_interopRequireDefault(require("prop-types"));var _colorCore=require("../../colors/colorCore");var _typography=_interopRequireDefault(require("../typography"));var _icons=require("../../icons");var _jsxFileName="/Users/trinh.ho2/momo-folk/kits/src/libs/step/dist/Step.web.js";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2.default)(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2.default)(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2.default)(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var CIRCLE_SIZE=18;var styles=_reactNative.StyleSheet.create({circle:{width:CIRCLE_SIZE,height:CIRCLE_SIZE,borderWidth:1,borderColor:_colorCore.ColorCore.sepia_05,borderRadius:9,backgroundColor:'white'},line:{height:1,backgroundColor:'white',borderWidth:1,borderRadius:1,borderStyle:'dashed',zIndex:0,marginTop:9},topRight:{position:'absolute',right:-1,top:-1,width:1,height:'100%',backgroundColor:'white',zIndex:1},topLeft:{position:'absolute',left:-1,top:-1,width:'100%',height:1,backgroundColor:'white',zIndex:1},topLeftWidth:{position:'absolute',left:-1,top:-1,width:1,height:'100%',backgroundColor:'white',zIndex:1},circleRow:{position:'absolute',justifyContent:'space-between',flexDirection:'row'},titleDefault:{color:_colorCore.ColorCore.black_12},titleActive:{color:_colorCore.ColorCore.black_17,fontWeight:'bold'},containerStyle:{minHeight:CIRCLE_SIZE+20+CIRCLE_SIZE}});var Step=function(_Component){(0,_inherits2.default)(Step,_Component);var _super=_createSuper(Step);function Step(props){var _this;(0,_classCallCheck2.default)(this,Step);_this=_super.call(this,props);_this.onLayout=function(e){_this.setState({width:e.nativeEvent.layout.width});};_this.renderLine=function(){var lineColor=_this.props.lineColor;return _react.default.createElement(_reactNative.View,{style:[styles.line,{borderColor:lineColor}],__source:{fileName:_jsxFileName,lineNumber:87,columnNumber:13}},_react.default.createElement(_reactNative.View,{style:styles.topLeft,__source:{fileName:_jsxFileName,lineNumber:88,columnNumber:17}}),_react.default.createElement(_reactNative.View,{style:styles.topLeftWidth,__source:{fileName:_jsxFileName,lineNumber:89,columnNumber:17}}),_react.default.createElement(_reactNative.View,{style:styles.topRight,__source:{fileName:_jsxFileName,lineNumber:90,columnNumber:17}}));};_this.circle=function(value,index){var _this$props=_this.props,currentStep=_this$props.currentStep,tintColor=_this$props.tintColor,data=_this$props.data;var width=_this.state.width;var icon=currentStep>=index+1?_icons.Icons.ic_step_active:_icons.Icons.ic_step_coming;var textFontStyle=currentStep>=index+1?styles.titleActive:styles.titleDefault;var itemWidth=(width-CIRCLE_SIZE)/(data==null?void 0:data.length);var left=0;var textAlignStyle={textAlign:'center'};if(index===0){left=0;textAlignStyle={textAlign:'left'};}else if(index===(data==null?void 0:data.length)-1){left=-itemWidth+CIRCLE_SIZE;textAlignStyle={textAlign:'right'};}else{left=-itemWidth/2+CIRCLE_SIZE/2;}var textStyle=[textAlignStyle,textFontStyle];return _react.default.createElement(_reactNative.View,{__source:{fileName:_jsxFileName,lineNumber:122,columnNumber:13}},_react.default.createElement(_reactNative.Image,{source:icon,style:[styles.circle,{tintColor:tintColor}],__source:{fileName:_jsxFileName,lineNumber:123,columnNumber:17}}),_react.default.createElement(_reactNative.View,{style:{position:'absolute',width:itemWidth,left:left,top:CIRCLE_SIZE+CIRCLE_SIZE/2},__source:{fileName:_jsxFileName,lineNumber:124,columnNumber:17}},_react.default.createElement(_typography.default.Title,{style:textStyle,__source:{fileName:_jsxFileName,lineNumber:131,columnNumber:21}},value)));};_this.renderCircle=function(){var _this$props$data=_this.props.data,data=_this$props$data===void 0?[]:_this$props$data;var views=data.map(_this.circle);return views;};_this.state={width:0};return _this;}(0,_createClass2.default)(Step,[{key:"render",value:function render(){var width=this.state.width;var style=this.props.style;return _react.default.createElement(_reactNative.View,{style:[styles.containerStyle,style],onLayout:this.onLayout,__source:{fileName:_jsxFileName,lineNumber:147,columnNumber:13}},this.renderLine(),_react.default.createElement(_reactNative.View,{style:[styles.circleRow,{width:width}],__source:{fileName:_jsxFileName,lineNumber:149,columnNumber:17}},this.renderCircle()));}}]);return Step;}(_react.Component);exports.default=Step;Step.propTypes={lineColor:_propTypes.default.string,data:_propTypes.default.arrayOf(_propTypes.default.string),currentStep:_propTypes.default.number,tintColor:_propTypes.default.string,style:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array])};Step.defaultProps={data:[],lineColor:'#fa541c',currentStep:0,tintColor:'#fa541c'};
1
+ import React, { Component } from 'react';
2
+ import { View, StyleSheet, Image } from 'react-native';
3
+ import PropTypes from 'prop-types';
4
+ import { ColorCore as Colors } from '../../core/colors/colorCore';
5
+ import Text from '../../core/components/typography';
6
+ import { Icons as IconSource } from '../../core/icons';
7
+
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
+ export default class Step extends Component {
77
+ constructor(props) {
78
+ 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
+ }
261
+
262
+ render() {
263
+ const { width, height } = this.state;
264
+ const { style, isVertical } = this.props;
265
+ return (
266
+ <View style={[styles.containerStyle, style]} onLayout={this.onLayout}>
267
+ {/* {this.renderLine()} */}
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
+ );
282
+ }
283
+ }
284
+
285
+ Step.propTypes = {
286
+ data: PropTypes.arrayOf(PropTypes.string),
287
+ currentStep: PropTypes.number,
288
+ tintColor: PropTypes.string,
289
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
290
+ isNumber: PropTypes.bool,
291
+ isVertical: PropTypes.bool,
292
+ iconActive: PropTypes.any,
293
+ iconInActive: PropTypes.any,
294
+ lineColorActive: PropTypes.string,
295
+ lineColorInActive: PropTypes.string,
296
+ bodyStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
297
+ checkedPreviousStep: PropTypes.bool,
298
+ borderColorActive: PropTypes.string,
299
+ borderColorInActive: PropTypes.string,
300
+ };
301
+
302
+ Step.defaultProps = {
303
+ data: [],
304
+ currentStep: 0,
305
+ tintColor: Colors.sepia_05
306
+ };
package/index.js CHANGED
@@ -1 +1,3 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _Slider=_interopRequireDefault(require("./Slider"));var _default=_Slider.default;exports.default=_default;
1
+ import Step from './Step';
2
+
3
+ export default Step;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/step",
3
- "version": "0.0.34-beta",
3
+ "version": "0.0.34",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {},
@@ -10,13 +10,6 @@
10
10
  "react": "16.9.0",
11
11
  "@momo-kits/core": ">=0.0.5-beta"
12
12
  },
13
- "devDependencies": {
14
- "metro-react-native-babel-preset": "^0.64.0",
15
- "@babel/core": "^7.12.9",
16
- "@babel/runtime": "^7.12.5"
17
- },
18
- "license": "MoMo",
19
- "jest": {
20
- "preset": "react-native"
21
- }
13
+ "devDependencies": {},
14
+ "license": "MoMo"
22
15
  }
package/publish.sh CHANGED
@@ -12,7 +12,7 @@ echo VERSION: $VERSION
12
12
  rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
13
13
 
14
14
  # #babel component to dist
15
- babel ./dist -d dist --copy-files
15
+ #babel ./dist -d dist --copy-files
16
16
 
17
17
  #copy option
18
18
  #cp -r ./src/ dist
@@ -26,4 +26,4 @@ cd ..
26
26
  rm -rf dist
27
27
 
28
28
 
29
- echo '{"text": "@momo-kits/step new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/step"}'
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"}'
package/babel.config.js DELETED
@@ -1 +0,0 @@
1
- module.exports={presets:['module:metro-react-native-babel-preset']};