react-native-international-phone-number 0.2.9 → 0.3.0

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/README.md CHANGED
@@ -157,7 +157,7 @@ interface FormProps extends FieldValues {
157
157
  export default function App() {
158
158
  const [selectedCountry, setSelectedCountry] = useState<undefined | Country>(undefined);
159
159
 
160
- const { control, handleSubmit, resetField } = useForm();
160
+ const { control, handleSubmit, resetField } = useForm<FormProps>();
161
161
 
162
162
  function onSubmit(form: FormProps) {
163
163
  Alert.alert(
@@ -215,7 +215,11 @@ export default function App() {
215
215
  />
216
216
  ```
217
217
 
218
- ### containerStyle + inputStyle:
218
+ ### Custom Lib Styles:
219
+
220
+ <div>
221
+ <img src="https://github.com/AstrOOnauta/react-native-international-phone-number/blob/master/images/custom-styles.png">
222
+ </div>
219
223
 
220
224
  ```jsx
221
225
  <PhoneInput
@@ -230,6 +234,12 @@ export default function App() {
230
234
  borderColor: '#F3F3F3',
231
235
  marginVertical: 16,
232
236
  }}
237
+ flagContainerStyle={{
238
+ borderTopLeftRadius: 7,
239
+ borderBottomLeftRadius: 7,
240
+ backgroundColor: '#808080',
241
+ justifyContent: 'center',
242
+ }}
233
243
  />
234
244
  ```
235
245
 
@@ -238,7 +248,8 @@ export default function App() {
238
248
  - `value?`: string
239
249
  - `onChangeText?`: (text: string) => void
240
250
  - `containerStyle?`: StyleProp<ViewStyle>
241
- - `inputStyle?`: StyleProp<ViewStyle>
251
+ - `flagContainerStyle?`: StyleProp<ViewStyle>
252
+ - `inputStyle?`: StyleProp<InputStyle>
242
253
  - `withDarkTheme?`: boolean
243
254
  - `disabled?`: boolean
244
255
  - `placeholder?`: string
Binary file
package/lib/index.d.ts CHANGED
@@ -11,6 +11,7 @@ interface PhoneInputProps extends TextInputProps {
11
11
  placeholder?: string;
12
12
  placeholderTextColor?: string;
13
13
  containerStyle?: StyleProp<ViewStyle>;
14
+ flagContainerStyle?: StyleProp<ViewStyle>;
14
15
  inputStyle?: StyleProp<TextStyle>;
15
16
  withDarkTheme?: boolean;
16
17
  disabled?: boolean;
package/lib/index.js CHANGED
@@ -1,8 +1,7 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import {
3
3
  StyleSheet,
4
4
  Dimensions,
5
- Platform,
6
5
  View,
7
6
  TextInput,
8
7
  } from 'react-native';
@@ -18,6 +17,7 @@ function PhoneInput({
18
17
  placeholderTextColor,
19
18
  selectionColor,
20
19
  containerStyle,
20
+ flagContainerStyle,
21
21
  inputStyle,
22
22
  withDarkTheme,
23
23
  disabled,
@@ -25,6 +25,10 @@ function PhoneInput({
25
25
  setSelectedCountry,
26
26
  ...rest
27
27
  }) {
28
+ const [containerWidth, setContainerWidth] = useState(
29
+ Dimensions.get('window').width
30
+ );
31
+
28
32
  const onSelect = (country) => {
29
33
  if (setSelectedCountry) {
30
34
  setSelectedCountry({
@@ -52,13 +56,17 @@ function PhoneInput({
52
56
  withDarkTheme ? styles.darkContainer : styles.lightContainer,
53
57
  containerStyle ? containerStyle : {},
54
58
  ]}
59
+ onLayout={(e) => setContainerWidth(e.nativeEvent.layout.width)}
55
60
  >
56
61
  <CountryPicker
57
- containerButtonStyle={{
58
- paddingLeft: 20,
59
- }}
62
+ containerButtonStyle={[
63
+ flagContainerBase,
64
+ flagContainerStyle ? flagContainerStyle : {},
65
+ ]}
60
66
  onSelect={onSelect}
61
67
  withFilter
68
+ withAlphaFilter
69
+ withCallingCode
62
70
  withCallingCodeButton
63
71
  theme={withDarkTheme ? DARK_THEME : DEFAULT_THEME}
64
72
  countryCode={selectedCountry ? selectedCountry.cca2 : 'BR'}
@@ -66,6 +74,7 @@ function PhoneInput({
66
74
  <TextInput
67
75
  style={[
68
76
  withDarkTheme ? styles.darkInput : styles.lightInput,
77
+ { width: containerWidth - 100 },
69
78
  inputStyle ? inputStyle : {},
70
79
  ]}
71
80
  placeholder={
@@ -96,14 +105,24 @@ function PhoneInput({
96
105
  const containerBase = {
97
106
  flexDirection: 'row',
98
107
  alignItems: 'center',
108
+ justifyContent: 'space-between',
99
109
  borderWidth: 1,
100
110
  borderStyle: 'solid',
101
111
  borderRadius: 8,
112
+ width: '100%',
113
+ height: 45,
114
+ };
115
+
116
+ const flagContainerBase = {
117
+ width: 100,
118
+ height: '99%',
119
+ alignItems: 'center',
120
+ justifyContent: 'center',
102
121
  };
103
122
 
104
123
  const inputBase = {
105
- width: Dimensions.get('window').width - 100,
106
- paddingVertical: Platform.OS === 'ios' ? 16 : 8,
124
+ width: Dimensions.get('window').width - 140,
125
+ paddingVertical: 8,
107
126
  paddingHorizontal: 16,
108
127
  fontSize: 16,
109
128
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-international-phone-number",
3
3
  "author": "AstrOOnauta (https://github.com/AstrOOnauta)",
4
- "version": "0.2.9",
4
+ "version": "0.3.0",
5
5
  "description": "International mobile phone input component with mask for React Native",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -9,7 +9,12 @@
9
9
  "test": "echo \"Error: no test specified\" && exit 1"
10
10
  },
11
11
  "keywords": [
12
+ "mobile",
13
+ "ios",
14
+ "android",
12
15
  "react-native",
16
+ "expo",
17
+ "components",
13
18
  "typescript",
14
19
  "react-hook-form",
15
20
  "mask-input",