@bigbinary/neetoui-rn 0.0.87 → 0.0.88
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.OtpInputs=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _propTypes=_interopRequireDefault(require("prop-types"));var _theme=require("../theme");var _=require("./");var _this=this,_jsxFileName="/Users/runner/work/neeto-ui-rn/neeto-ui-rn/src/components/OtpInputs.js";var styles={inputStyles:{fontSize:0,backgroundColor:"transparent",color:"transparent",width:"100%",height:"100%",position:"absolute"},defaultContainerStyles:{margin:2,borderRadius:6,borderWidth:1,borderColor:_theme.theme.colors.background.secondary,backgroundColor:_theme.theme.colors.background.white,justifyContent:"center",alignItems:"center",minHeight:45,minWidth:45},defaultTextStyles:{fontSize:_theme.theme.fontSizes.xl,fontFamily:_theme.theme.fonts.inter700}};var OtpInputs=function OtpInputs(_ref){var _ref$handleChange=_ref.handleChange,handleChange=_ref$handleChange===void 0?function(){}:_ref$handleChange,_ref$numberOfInputs=_ref.numberOfInputs,numberOfInputs=_ref$numberOfInputs===void 0?4:_ref$numberOfInputs,_ref$error=_ref.error,error=_ref$error===void 0?false:_ref$error,_ref$code=_ref.code,code=_ref$code===void 0?"":_ref$code,containerStyles=_ref.containerStyles,textStyles=_ref.textStyles;var inputRef=_react.default.useRef();return _react.default.createElement(_.Container,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:71,columnNumber:5}},_react.default.createElement(_.Touchable,{onPress:function onPress(){inputRef&&inputRef.current.focus();},__self:_this,__source:{fileName:_jsxFileName,lineNumber:72,columnNumber:7}},_react.default.createElement(_.Container,{flexDirection:"row",alignItems:"center",justifyContent:"center",__self:_this,__source:{fileName:_jsxFileName,lineNumber:77,columnNumber:9}},Array(numberOfInputs).fill().map(function(number,index){return _react.default.createElement(_.Container,(0,_extends2.default)({key:index},styles.defaultContainerStyles,containerStyles,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:86,columnNumber:17}}),_react.default.createElement(_.Typography,(0,_extends2.default)({accessibilityLabel:"otp",color:error?_theme.theme.colors.font.danger:_theme.theme.colors.font.secondary},styles.defaultTextStyles,textStyles,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:91,columnNumber:19}}),code[index]||""));}),_react.default.createElement(_.Input,(0,_extends2.default)({keyboardType:"phone-pad",selectionColor:"transparent",onChangeText:function onChangeText(value){if(!isNaN(value)){if(value.length<=numberOfInputs){handleChange&&handleChange(value);}if(value.length>=numberOfInputs){return _reactNative.Keyboard.dismiss();}}},ref:inputRef,value:code||""},styles.inputStyles,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:106,columnNumber:11}})))));};exports.OtpInputs=OtpInputs;OtpInputs.defaultProps={containerStyles:{},textStyles:{}};OtpInputs.propTypes={code:_propTypes.default.string.isRequired,numberOfInputs:_propTypes.default.number.isRequired,handleChange:_propTypes.default.func.isRequired,error:_propTypes.default.bool,containerStyles:_propTypes.default.object,textStyles:_propTypes.default.object};
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Keyboard
|
|
3
|
-
import { theme } from "../theme";
|
|
2
|
+
import { Keyboard } from "react-native";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
import { theme } from "../theme";
|
|
6
|
+
import { Container, Touchable, Typography, Input } from "@components";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
@@ -30,48 +31,79 @@ import { Container, Touchable } from "@components";
|
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
33
|
|
|
34
|
+
const styles = {
|
|
35
|
+
inputStyles: {
|
|
36
|
+
fontSize: 0,
|
|
37
|
+
backgroundColor: "transparent",
|
|
38
|
+
color: "transparent",
|
|
39
|
+
width: "100%",
|
|
40
|
+
height: "100%",
|
|
41
|
+
position: "absolute",
|
|
42
|
+
},
|
|
43
|
+
defaultContainerStyles: {
|
|
44
|
+
margin: 2,
|
|
45
|
+
borderRadius: 6,
|
|
46
|
+
borderWidth: 1,
|
|
47
|
+
borderColor: theme.colors.background.secondary,
|
|
48
|
+
backgroundColor: theme.colors.background.white,
|
|
49
|
+
justifyContent: "center",
|
|
50
|
+
alignItems: "center",
|
|
51
|
+
minHeight: 45,
|
|
52
|
+
minWidth: 45,
|
|
53
|
+
},
|
|
54
|
+
defaultTextStyles: {
|
|
55
|
+
fontSize: theme.fontSizes.xl,
|
|
56
|
+
fontFamily: theme.fonts.inter700,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
33
60
|
export const OtpInputs = ({
|
|
34
61
|
handleChange = () => {},
|
|
35
62
|
numberOfInputs = 4,
|
|
36
63
|
error = false,
|
|
37
64
|
code = "",
|
|
38
|
-
|
|
39
|
-
|
|
65
|
+
containerStyles,
|
|
66
|
+
textStyles,
|
|
40
67
|
}) => {
|
|
41
68
|
const inputRef = React.useRef();
|
|
42
69
|
|
|
43
70
|
return (
|
|
44
|
-
<Container
|
|
71
|
+
<Container>
|
|
45
72
|
<Touchable
|
|
46
73
|
onPress={() => {
|
|
47
|
-
Keyboard.dismiss();
|
|
48
74
|
inputRef && inputRef.current.focus();
|
|
49
75
|
}}
|
|
50
76
|
>
|
|
51
|
-
<Container
|
|
77
|
+
<Container
|
|
78
|
+
flexDirection="row"
|
|
79
|
+
alignItems="center"
|
|
80
|
+
justifyContent="center"
|
|
81
|
+
>
|
|
52
82
|
{Array(numberOfInputs)
|
|
53
83
|
.fill()
|
|
54
84
|
.map((number, index) => {
|
|
55
85
|
return (
|
|
56
86
|
<Container
|
|
57
87
|
key={index}
|
|
58
|
-
|
|
88
|
+
{...styles.defaultContainerStyles}
|
|
89
|
+
{...containerStyles}
|
|
59
90
|
>
|
|
60
|
-
<
|
|
61
|
-
testID="otp"
|
|
91
|
+
<Typography
|
|
62
92
|
accessibilityLabel="otp"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
93
|
+
color={
|
|
94
|
+
error
|
|
95
|
+
? theme.colors.font.danger
|
|
96
|
+
: theme.colors.font.secondary
|
|
97
|
+
}
|
|
98
|
+
{...styles.defaultTextStyles}
|
|
99
|
+
{...textStyles}
|
|
68
100
|
>
|
|
69
101
|
{code[index] || ""}
|
|
70
|
-
</
|
|
102
|
+
</Typography>
|
|
71
103
|
</Container>
|
|
72
104
|
);
|
|
73
105
|
})}
|
|
74
|
-
<
|
|
106
|
+
<Input
|
|
75
107
|
keyboardType="phone-pad"
|
|
76
108
|
selectionColor="transparent"
|
|
77
109
|
onChangeText={value => {
|
|
@@ -85,8 +117,8 @@ export const OtpInputs = ({
|
|
|
85
117
|
}
|
|
86
118
|
}}
|
|
87
119
|
ref={inputRef}
|
|
88
|
-
style={styles.emptyViewStyle}
|
|
89
120
|
value={code || ""}
|
|
121
|
+
{...styles.inputStyles}
|
|
90
122
|
/>
|
|
91
123
|
</Container>
|
|
92
124
|
</Touchable>
|
|
@@ -94,6 +126,11 @@ export const OtpInputs = ({
|
|
|
94
126
|
);
|
|
95
127
|
};
|
|
96
128
|
|
|
129
|
+
OtpInputs.defaultProps = {
|
|
130
|
+
containerStyles: {},
|
|
131
|
+
textStyles: {},
|
|
132
|
+
};
|
|
133
|
+
|
|
97
134
|
OtpInputs.propTypes = {
|
|
98
135
|
/**
|
|
99
136
|
* This would be OTP code.
|
|
@@ -114,53 +151,9 @@ OtpInputs.propTypes = {
|
|
|
114
151
|
/**
|
|
115
152
|
* To change the styles of main container.
|
|
116
153
|
*/
|
|
117
|
-
|
|
154
|
+
containerStyles: PropTypes.object,
|
|
118
155
|
/**
|
|
119
156
|
* To change the styles of OTP text.
|
|
120
157
|
*/
|
|
121
|
-
|
|
158
|
+
textStyles: PropTypes.object,
|
|
122
159
|
};
|
|
123
|
-
|
|
124
|
-
export const styles = StyleSheet.create({
|
|
125
|
-
container: {
|
|
126
|
-
marginTop: 5,
|
|
127
|
-
marginBottom: 5,
|
|
128
|
-
},
|
|
129
|
-
otpInput: {
|
|
130
|
-
color: theme.colors.font.secondary,
|
|
131
|
-
fontSize: theme.fontSizes.xl,
|
|
132
|
-
fontFamily: theme.fonts.inter700,
|
|
133
|
-
textAlign: "center",
|
|
134
|
-
minHeight: 40,
|
|
135
|
-
minWidth: 40,
|
|
136
|
-
textAlignVertical: "center",
|
|
137
|
-
alignItems: "center",
|
|
138
|
-
...Platform.select({
|
|
139
|
-
ios: {
|
|
140
|
-
paddingTop: 5,
|
|
141
|
-
},
|
|
142
|
-
android: {},
|
|
143
|
-
}),
|
|
144
|
-
backgroundColor: "transparent",
|
|
145
|
-
},
|
|
146
|
-
textContainer: {
|
|
147
|
-
margin: 5,
|
|
148
|
-
borderRadius: 6,
|
|
149
|
-
borderWidth: 1,
|
|
150
|
-
borderColor: theme.colors.background.secondary,
|
|
151
|
-
backgroundColor: theme.colors.background.white,
|
|
152
|
-
},
|
|
153
|
-
inputsContainer: {
|
|
154
|
-
flexDirection: "row",
|
|
155
|
-
alignItems: "center",
|
|
156
|
-
justifyContent: "center",
|
|
157
|
-
},
|
|
158
|
-
emptyViewStyle: {
|
|
159
|
-
fontSize: 0,
|
|
160
|
-
backgroundColor: "transparent",
|
|
161
|
-
color: "transparent",
|
|
162
|
-
width: "100%",
|
|
163
|
-
height: "100%",
|
|
164
|
-
position: "absolute",
|
|
165
|
-
},
|
|
166
|
-
});
|