react-native-international-phone-number 0.5.2 → 0.6.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 +113 -49
- package/lib/assets/fonts/TwemojiMozilla.ttf +0 -0
- package/lib/assets/images/custom-styles.png +0 -0
- package/lib/assets/images/preview.png +0 -0
- package/lib/index.js +52 -30
- package/lib/interfaces/modalStyles.ts +26 -0
- package/lib/interfaces/phoneInputProps.ts +7 -14
- package/lib/interfaces/phoneInputRef.ts +2 -0
- package/lib/interfaces/phoneInputStyles.ts +14 -0
- package/lib/styles.js +4 -0
- package/lib/utils/getStyles.js +48 -16
- package/package.json +1 -1
- package/images/custom-styles.png +0 -0
- package/images/preview.png +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<br>
|
|
2
2
|
|
|
3
3
|
<div align = "center">
|
|
4
|
-
<img src="
|
|
4
|
+
<img src="lib/assets/images/preview.png" alt="React Native International Phone Number Input Lib preview">
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<br>
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
<a href="https://github.com/AstrOOnauta/react-native-international-phone-number/pulls">
|
|
25
25
|
<img src="https://img.shields.io/github/issues-pr/AstrOOnauta/react-native-international-phone-number?style=flat-square&color=blue"/>
|
|
26
26
|
</a>
|
|
27
|
-
<a href="
|
|
27
|
+
<a href="LICENSE.md">
|
|
28
28
|
<img src="https://img.shields.io/:license-isc-yellow.svg?style=flat-square"/>
|
|
29
29
|
</a>
|
|
30
30
|
</p>
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
- [Old Versions](#old-versions)
|
|
47
47
|
- [Installation](#installation)
|
|
48
|
+
- [Additional Config to Web](#additional-config-to-web)
|
|
48
49
|
- [Features](#features)
|
|
49
50
|
- [Basic Usage](#basic-usage)
|
|
50
51
|
- [With Class Component](#class-component)
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
## Old Versions
|
|
77
78
|
|
|
78
79
|
- [Version 0.4.x](https://github.com/AstrOOnauta/react-native-international-phone-number/tree/v0.4.x)
|
|
80
|
+
- [Version 0.5.x](https://github.com/AstrOOnauta/react-native-international-phone-number/tree/v0.5.x)
|
|
79
81
|
|
|
80
82
|
<br>
|
|
81
83
|
|
|
@@ -91,18 +93,42 @@ OR
|
|
|
91
93
|
$ yarn add react-native-international-phone-number
|
|
92
94
|
```
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
## Additional config to `Web`
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
- Using React Native CLI:
|
|
99
|
+
|
|
100
|
+
create a `react-native.config.js` file at the root of your react-native project with:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
module.exports = {
|
|
104
|
+
project: {
|
|
105
|
+
ios: {},
|
|
106
|
+
android: {},
|
|
107
|
+
},
|
|
108
|
+
assets: [
|
|
109
|
+
'./node_modules/react-native-international-phone-number/assets/fonts',
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
- Using Expo:
|
|
115
|
+
|
|
116
|
+
1. Install [expo-fonts](https://docs.expo.dev/versions/latest/sdk/font/): `npx expo install expo-font`;
|
|
117
|
+
2. Initialize the `expo-font`:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
import { useFonts } from 'expo-font';
|
|
121
|
+
|
|
122
|
+
...
|
|
123
|
+
|
|
124
|
+
useFonts({
|
|
125
|
+
'TwemojiMozilla': require('./node_modules/react-native-international-phone-number/assets/fonts/TwemojiMozilla.ttf'),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
...
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> Observation: _you need to recompile your project after adding new fonts._
|
|
106
132
|
|
|
107
133
|
<br>
|
|
108
134
|
|
|
@@ -395,6 +421,8 @@ export default function App() {
|
|
|
395
421
|
|
|
396
422
|
## Customizing lib
|
|
397
423
|
|
|
424
|
+
<img src="lib/assets/images/custom-styles.png" alt="Custom lib styles">
|
|
425
|
+
|
|
398
426
|
- ### Dark Mode:
|
|
399
427
|
|
|
400
428
|
```jsx
|
|
@@ -408,33 +436,71 @@ export default function App() {
|
|
|
408
436
|
|
|
409
437
|
- ### Custom Lib Styles:
|
|
410
438
|
|
|
411
|
-
<div>
|
|
412
|
-
<img src="https://github.com/AstrOOnauta/react-native-international-phone-number/blob/master/images/custom-styles.png" alt="Lib with custom styles">
|
|
413
|
-
</div>
|
|
414
|
-
|
|
415
439
|
```jsx
|
|
416
440
|
...
|
|
417
441
|
<PhoneInput
|
|
418
442
|
...
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
flagTextStyle={{
|
|
443
|
+
phoneInputStyles={{
|
|
444
|
+
container: {
|
|
445
|
+
backgroundColor: '#575757',
|
|
446
|
+
borderWidth: 1,
|
|
447
|
+
borderStyle: 'solid',
|
|
448
|
+
borderColor: '#F3F3F3',
|
|
449
|
+
},
|
|
450
|
+
flagContainer: {
|
|
451
|
+
borderTopLeftRadius: 7,
|
|
452
|
+
borderBottomLeftRadius: 7,
|
|
453
|
+
backgroundColor: '#808080',
|
|
454
|
+
justifyContent: 'center',
|
|
455
|
+
},
|
|
456
|
+
flag: {}
|
|
457
|
+
callingCode: {
|
|
435
458
|
fontSize: 16,
|
|
436
459
|
fontWeight: 'bold',
|
|
437
460
|
color: '#F3F3F3',
|
|
461
|
+
},
|
|
462
|
+
input: {
|
|
463
|
+
color: '#F3F3F3',
|
|
464
|
+
},
|
|
465
|
+
}}
|
|
466
|
+
modalStyles={{
|
|
467
|
+
modal: {
|
|
468
|
+
backgroundColor: '#333333',
|
|
469
|
+
borderWidth: 1,
|
|
470
|
+
},
|
|
471
|
+
backdrop: {},
|
|
472
|
+
divider: {
|
|
473
|
+
backgroundColor: 'transparent',
|
|
474
|
+
},
|
|
475
|
+
countriesList: {},
|
|
476
|
+
searchInput: {
|
|
477
|
+
borderRadius: 8,
|
|
478
|
+
borderWidth: 1,
|
|
479
|
+
borderColor: '#F3F3F3',
|
|
480
|
+
color: '#F3F3F3',
|
|
481
|
+
backgroundColor: '#333333',
|
|
482
|
+
paddingHorizontal: 12,
|
|
483
|
+
height: 46,
|
|
484
|
+
},
|
|
485
|
+
countryButton: {
|
|
486
|
+
borderWidth: 1,
|
|
487
|
+
borderColor: '#F3F3F3',
|
|
488
|
+
backgroundColor: '#666666',
|
|
489
|
+
marginVertical: 4,
|
|
490
|
+
paddingVertical: 0,
|
|
491
|
+
},
|
|
492
|
+
noCountryText: {},
|
|
493
|
+
noCountryContainer: {},
|
|
494
|
+
flag: {
|
|
495
|
+
color: '#FFFFFF',
|
|
496
|
+
fontSize: 20,
|
|
497
|
+
},
|
|
498
|
+
callingCode: {
|
|
499
|
+
color: '#F3F3F3',
|
|
500
|
+
},
|
|
501
|
+
countryName: {
|
|
502
|
+
color: '#F3F3F3',
|
|
503
|
+
},
|
|
438
504
|
}}
|
|
439
505
|
/>
|
|
440
506
|
...
|
|
@@ -537,34 +603,32 @@ export default function App() {
|
|
|
537
603
|
|
|
538
604
|
</br>
|
|
539
605
|
|
|
540
|
-
## Component Props ([PhoneInputProps](
|
|
606
|
+
## Component Props ([PhoneInputProps](lib/interfaces/phoneInputProps.ts))
|
|
541
607
|
|
|
542
|
-
- `language?:` [ILanguage](
|
|
608
|
+
- `language?:` [ILanguage](lib/interfaces/language.ts);
|
|
543
609
|
- `customMask?:` string[];
|
|
544
610
|
- `defaultValue?:` string;
|
|
545
611
|
- `value?:` string;
|
|
546
612
|
- `onChangePhoneNumber?:` (phoneNumber: string) => void;
|
|
547
|
-
- `selectedCountry?:` [ICountry](
|
|
548
|
-
- `onChangeSelectedCountry?:` (country: [ICountry](
|
|
613
|
+
- `selectedCountry?:` [ICountry](lib/interfaces/country.ts);
|
|
614
|
+
- `onChangeSelectedCountry?:` (country: [ICountry](lib/interfaces/country.ts)) => void;
|
|
549
615
|
- `disabled?:` boolean;
|
|
550
616
|
- `modalDisabled?:` boolean;
|
|
551
617
|
- `modalHeight?:` number | string;
|
|
552
|
-
- `theme?:` [ITheme](
|
|
553
|
-
- `
|
|
554
|
-
- `
|
|
555
|
-
- `
|
|
556
|
-
- `inputStyle?:` [StyleProp](https://reactnative.dev/docs/style)<[TextStyle](https://reactnative.dev/docs/text-style-props)>;
|
|
557
|
-
- `ref?:` [Ref](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/663f439d11d78b65f1dfd38d120f3728ea2cc207/types/react/index.d.ts#L100)<[IPhoneInputRef](https://github.com/AstrOOnauta/react-native-international-phone-number/blob/master/lib/interfaces/phoneInputRef.ts)>
|
|
618
|
+
- `theme?:` [ITheme](lib/interfaces/theme.ts);
|
|
619
|
+
- `modalStyles?:` [IPhoneInputStyles](lib/interfaces/phoneInputStyles.ts);
|
|
620
|
+
- `modalStyles?:` [IModalStyles](lib/interfaces/modalStyles.ts);
|
|
621
|
+
- `ref?:` [Ref](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/663f439d11d78b65f1dfd38d120f3728ea2cc207/types/react/index.d.ts#L100)<[IPhoneInputRef](lib/interfaces/phoneInputRef.ts)>
|
|
558
622
|
|
|
559
623
|
<br>
|
|
560
624
|
|
|
561
625
|
## Functions
|
|
562
626
|
|
|
563
|
-
- `getAllCountries:` () => [ICountry](
|
|
564
|
-
- `getCountriesByCallingCode:` (callingCode: string) => [ICountry](
|
|
565
|
-
- `getCountryByCca2:` (cca2: string) => [ICountry](
|
|
566
|
-
- `getCountriesByName:` (name: string, language: [ILanguage](
|
|
567
|
-
- `getCountryByPhoneNumber:` (phoneNumber: string) => [ICountry](
|
|
627
|
+
- `getAllCountries:` () => [ICountry](lib/interfaces/country.ts)[];
|
|
628
|
+
- `getCountriesByCallingCode:` (callingCode: string) => [ICountry](lib/interfaces/country.ts)[] | undefined;
|
|
629
|
+
- `getCountryByCca2:` (cca2: string) => [ICountry](lib/interfaces/country.ts) | undefined;
|
|
630
|
+
- `getCountriesByName:` (name: string, language: [ILanguage](lib/interfaces/language.ts)) => [ICountry](lib/interfaces/country.ts)[] | undefined;
|
|
631
|
+
- `getCountryByPhoneNumber:` (phoneNumber: string) => [ICountry](lib/interfaces/country.ts) | undefined;
|
|
568
632
|
|
|
569
633
|
</br>
|
|
570
634
|
|
|
@@ -611,7 +675,7 @@ export default function App() {
|
|
|
611
675
|
|
|
612
676
|
## License
|
|
613
677
|
|
|
614
|
-
[ISC](
|
|
678
|
+
[ISC](LICENSE.md)
|
|
615
679
|
|
|
616
680
|
<br>
|
|
617
681
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/index.js
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from 'react-native';
|
|
13
13
|
import { CountryPicker } from 'react-native-country-codes-picker';
|
|
14
14
|
|
|
15
|
-
import styles from './styles';
|
|
16
15
|
import getInputMask from './utils/getInputMask';
|
|
17
16
|
import getAllCountries from './utils/getAllCountries';
|
|
18
17
|
import getCountriesByName from './utils/getCountriesByName';
|
|
@@ -28,6 +27,7 @@ import {
|
|
|
28
27
|
getContainerStyle,
|
|
29
28
|
getCountryPickerStyle,
|
|
30
29
|
getFlagContainerStyle,
|
|
30
|
+
getFlagStyle,
|
|
31
31
|
getFlagTextStyle,
|
|
32
32
|
getInputStyle,
|
|
33
33
|
} from './utils/getStyles';
|
|
@@ -40,10 +40,8 @@ const PhoneInput = forwardRef(
|
|
|
40
40
|
placeholder,
|
|
41
41
|
placeholderTextColor,
|
|
42
42
|
selectionColor,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
flagTextStyle,
|
|
46
|
-
inputStyle,
|
|
43
|
+
phoneInputStyle,
|
|
44
|
+
modalStyle,
|
|
47
45
|
disabled,
|
|
48
46
|
modalDisabled,
|
|
49
47
|
modalHeight,
|
|
@@ -70,6 +68,9 @@ const PhoneInput = forwardRef(
|
|
|
70
68
|
focus: textInputRef.current?.focus,
|
|
71
69
|
getValue: () => inputValue,
|
|
72
70
|
value: inputValue,
|
|
71
|
+
getFullPhoneNumber: () =>
|
|
72
|
+
`${countryValue?.callingCode} ${inputValue}`,
|
|
73
|
+
fullPhoneNumber: `${countryValue?.callingCode} ${inputValue}`,
|
|
73
74
|
getSelectedCountry: () => countryValue,
|
|
74
75
|
selectedCountry: countryValue,
|
|
75
76
|
props: {
|
|
@@ -78,10 +79,8 @@ const PhoneInput = forwardRef(
|
|
|
78
79
|
placeholder,
|
|
79
80
|
placeholderTextColor,
|
|
80
81
|
selectionColor,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
flagTextStyle,
|
|
84
|
-
inputStyle,
|
|
82
|
+
phoneInputStyle,
|
|
83
|
+
modalStyle,
|
|
85
84
|
disabled,
|
|
86
85
|
modalDisabled,
|
|
87
86
|
modalHeight,
|
|
@@ -101,6 +100,9 @@ const PhoneInput = forwardRef(
|
|
|
101
100
|
...refBase,
|
|
102
101
|
getValue: () => phoneNumber,
|
|
103
102
|
value: phoneNumber,
|
|
103
|
+
getFullPhoneNumber: () =>
|
|
104
|
+
`${country?.callingCode} ${phoneNumber}`,
|
|
105
|
+
fullPhoneNumber: `${country?.callingCode} ${phoneNumber}`,
|
|
104
106
|
getSelectedCountry: () => country,
|
|
105
107
|
selectedCountry: country,
|
|
106
108
|
props: {
|
|
@@ -154,6 +156,23 @@ const PhoneInput = forwardRef(
|
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
158
|
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (!countryValue && !defaultCountry) {
|
|
161
|
+
const defaultCountry = getCountryByCca2('BR');
|
|
162
|
+
|
|
163
|
+
if (ref) {
|
|
164
|
+
setCountryValue(defaultCountry);
|
|
165
|
+
updateRef('', defaultCountry);
|
|
166
|
+
} else {
|
|
167
|
+
onChangeSelectedCountry(defaultCountry);
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
if (ref) {
|
|
171
|
+
updateRef('', countryValue);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}, []);
|
|
175
|
+
|
|
157
176
|
useEffect(() => {
|
|
158
177
|
if (defaultCountry) {
|
|
159
178
|
if (ref) {
|
|
@@ -200,21 +219,6 @@ const PhoneInput = forwardRef(
|
|
|
200
219
|
"The default number provided (defaultValue) don't match with anyone country. Please, correct it to be shown in the input. For more information: https://github.com/AstrOOnauta/react-native-international-phone-number#intermediate-usage---typescript--default-phone-number-value"
|
|
201
220
|
);
|
|
202
221
|
}
|
|
203
|
-
} else {
|
|
204
|
-
if (!countryValue && !defaultCountry) {
|
|
205
|
-
const defaultCountry = getCountryByCca2('BR');
|
|
206
|
-
|
|
207
|
-
if (ref) {
|
|
208
|
-
setCountryValue(defaultCountry);
|
|
209
|
-
updateRef('', defaultCountry);
|
|
210
|
-
} else {
|
|
211
|
-
onChangeSelectedCountry(defaultCountry);
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
if (ref) {
|
|
215
|
-
updateRef('', countryValue);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
222
|
}
|
|
219
223
|
}, [defaultValue]);
|
|
220
224
|
|
|
@@ -286,22 +290,36 @@ const PhoneInput = forwardRef(
|
|
|
286
290
|
return (
|
|
287
291
|
<>
|
|
288
292
|
<View
|
|
289
|
-
style={getContainerStyle(
|
|
293
|
+
style={getContainerStyle(
|
|
294
|
+
theme,
|
|
295
|
+
phoneInputStyle?.container,
|
|
296
|
+
disabled
|
|
297
|
+
)}
|
|
290
298
|
>
|
|
291
299
|
<TouchableOpacity
|
|
292
300
|
activeOpacity={disabled || modalDisabled ? 1 : 0.6}
|
|
293
301
|
onPress={() =>
|
|
294
302
|
disabled || modalDisabled ? null : setShow(true)
|
|
295
303
|
}
|
|
296
|
-
style={getFlagContainerStyle(
|
|
304
|
+
style={getFlagContainerStyle(
|
|
305
|
+
theme,
|
|
306
|
+
phoneInputStyle?.flagContainer
|
|
307
|
+
)}
|
|
297
308
|
>
|
|
298
|
-
<Text style={
|
|
299
|
-
|
|
309
|
+
<Text style={getFlagStyle(phoneInputStyle?.flag)}>
|
|
310
|
+
{countryValue?.flag}
|
|
311
|
+
</Text>
|
|
312
|
+
<Text
|
|
313
|
+
style={getFlagTextStyle(
|
|
314
|
+
theme,
|
|
315
|
+
phoneInputStyle?.callingCode
|
|
316
|
+
)}
|
|
317
|
+
>
|
|
300
318
|
{countryValue?.callingCode}
|
|
301
319
|
</Text>
|
|
302
320
|
</TouchableOpacity>
|
|
303
321
|
<TextInput
|
|
304
|
-
style={getInputStyle(theme,
|
|
322
|
+
style={getInputStyle(theme, phoneInputStyle?.input)}
|
|
305
323
|
placeholder={
|
|
306
324
|
placeholder ||
|
|
307
325
|
getPhoneNumberInputPlaceholder(language || 'en')
|
|
@@ -335,7 +353,11 @@ const PhoneInput = forwardRef(
|
|
|
335
353
|
language || 'en'
|
|
336
354
|
)}
|
|
337
355
|
enableModalAvoiding
|
|
338
|
-
style={getCountryPickerStyle(
|
|
356
|
+
style={getCountryPickerStyle(
|
|
357
|
+
theme,
|
|
358
|
+
modalHeight,
|
|
359
|
+
modalStyle
|
|
360
|
+
)}
|
|
339
361
|
pickerButtonOnPress={onSelect}
|
|
340
362
|
onBackdropPress={() => setShow(false)}
|
|
341
363
|
/>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface IModalStyles {
|
|
4
|
+
// Styles for whole modal [View]
|
|
5
|
+
modal?: StyleProp<ViewStyle>;
|
|
6
|
+
// Styles for modal backdrop [View]
|
|
7
|
+
backdrop?: StyleProp<ViewStyle>;
|
|
8
|
+
// Styles for search input [TextInput]
|
|
9
|
+
searchInput?: StyleProp<TextStyle>;
|
|
10
|
+
// Styles for the divider between the input and the countries list [View]
|
|
11
|
+
divider?: StyleProp<ViewStyle>;
|
|
12
|
+
// Styles for countries list [FlatList]
|
|
13
|
+
countriesList?: StyleProp<ViewStyle>;
|
|
14
|
+
// Styles for country button [TouchableOpacity]
|
|
15
|
+
countryButton?: StyleProp<ViewStyle>;
|
|
16
|
+
// Styles for country not found message container [View]
|
|
17
|
+
noCountryContainer?: StyleProp<ViewStyle>;
|
|
18
|
+
// Styles for country not found message [Text]
|
|
19
|
+
noCountryText?: StyleProp<TextStyle>;
|
|
20
|
+
// Flag styles [Text]
|
|
21
|
+
flag?: StyleProp<TextStyle>;
|
|
22
|
+
// Calling/Dial code styles [Text]
|
|
23
|
+
callingCode?: StyleProp<TextStyle>;
|
|
24
|
+
// Country name styles [Text]
|
|
25
|
+
countryName?: StyleProp<TextStyle>;
|
|
26
|
+
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
StyleProp,
|
|
4
|
-
TextInputProps,
|
|
5
|
-
TextStyle,
|
|
6
|
-
ViewStyle,
|
|
7
|
-
} from 'react-native';
|
|
2
|
+
import { TextInputProps } from 'react-native';
|
|
8
3
|
|
|
9
4
|
import { ICountry } from './country';
|
|
10
5
|
import { ICountryCca2 } from './countryCca2';
|
|
11
6
|
import { ILanguage } from './language';
|
|
12
7
|
import { ITheme } from './theme';
|
|
8
|
+
import { IModalStyles } from './modalStyles';
|
|
9
|
+
import { IPhoneInputStyles } from './phoneInputStyles';
|
|
13
10
|
import { IPhoneInputRef } from './phoneInputRef';
|
|
14
11
|
|
|
15
12
|
interface IPhoneInputPropsWithoutRef extends TextInputProps {
|
|
@@ -17,10 +14,8 @@ interface IPhoneInputPropsWithoutRef extends TextInputProps {
|
|
|
17
14
|
placeholder?: string;
|
|
18
15
|
placeholderTextColor?: string;
|
|
19
16
|
selectionColor?: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
flagTextStyle?: StyleProp<TextStyle>;
|
|
23
|
-
inputStyle?: StyleProp<TextStyle>;
|
|
17
|
+
phoneInputStyle?: IPhoneInputStyles;
|
|
18
|
+
modalStyle?: IModalStyles;
|
|
24
19
|
theme?: ITheme;
|
|
25
20
|
disabled?: boolean;
|
|
26
21
|
modalDisabled?: boolean;
|
|
@@ -40,10 +35,8 @@ interface IPhoneInputPropsWithRef extends TextInputProps {
|
|
|
40
35
|
placeholder?: string;
|
|
41
36
|
placeholderTextColor?: string;
|
|
42
37
|
selectionColor?: string;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
flagTextStyle?: StyleProp<TextStyle>;
|
|
46
|
-
inputStyle?: StyleProp<TextStyle>;
|
|
38
|
+
phoneInputStyle?: IPhoneInputStyles;
|
|
39
|
+
modalStyle?: IModalStyles;
|
|
47
40
|
theme?: ITheme;
|
|
48
41
|
disabled?: boolean;
|
|
49
42
|
modalDisabled?: boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface IPhoneInputStyles {
|
|
4
|
+
// Styles for whole modal [View]
|
|
5
|
+
container?: StyleProp<ViewStyle>;
|
|
6
|
+
// Styles for modal backdrop [View]
|
|
7
|
+
flagContainer?: StyleProp<ViewStyle>;
|
|
8
|
+
// Flag styles [Text]
|
|
9
|
+
flag?: StyleProp<TextStyle>;
|
|
10
|
+
// Calling/Dial code styles [Text]
|
|
11
|
+
callingCode?: StyleProp<TextStyle>;
|
|
12
|
+
// Styles for search input [TextInput]
|
|
13
|
+
input?: StyleProp<TextStyle>;
|
|
14
|
+
}
|
package/lib/styles.js
CHANGED
|
@@ -56,6 +56,7 @@ const styles = StyleSheet.create({
|
|
|
56
56
|
color: '#FFFFFF',
|
|
57
57
|
fontSize: 20,
|
|
58
58
|
marginRight: 10,
|
|
59
|
+
fontFamily: 'TwemojiMozilla',
|
|
59
60
|
},
|
|
60
61
|
lightFlagText: {
|
|
61
62
|
...flagTextBase,
|
|
@@ -101,6 +102,8 @@ const styles = StyleSheet.create({
|
|
|
101
102
|
countryMessageContainer: {},
|
|
102
103
|
flag: {
|
|
103
104
|
color: '#FFFFFF',
|
|
105
|
+
fontSize: 20,
|
|
106
|
+
fontFamily: 'TwemojiMozilla',
|
|
104
107
|
},
|
|
105
108
|
dialCode: {},
|
|
106
109
|
countryName: {},
|
|
@@ -136,6 +139,7 @@ const styles = StyleSheet.create({
|
|
|
136
139
|
flag: {
|
|
137
140
|
color: '#FFFFFF',
|
|
138
141
|
fontSize: 20,
|
|
142
|
+
fontFamily: 'TwemojiMozilla',
|
|
139
143
|
},
|
|
140
144
|
dialCode: {
|
|
141
145
|
color: '#F3F3F3',
|
package/lib/utils/getStyles.js
CHANGED
|
@@ -26,6 +26,10 @@ export function getFlagContainerStyle(theme, flagContainerStyle) {
|
|
|
26
26
|
];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export function getFlagStyle(flagStyle) {
|
|
30
|
+
return [styles.flag, flagStyle ? flagStyle : {}];
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
export function getFlagTextStyle(theme, flagTextStyle) {
|
|
30
34
|
return [
|
|
31
35
|
theme === 'dark' ? styles.darkFlagText : styles.lightFlagText,
|
|
@@ -40,20 +44,48 @@ export function getInputStyle(theme, inputStyle) {
|
|
|
40
44
|
];
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
export function getCountryPickerStyle(theme, height) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
export function getCountryPickerStyle(theme, height, modalStyle) {
|
|
48
|
+
const themeStyle =
|
|
49
|
+
theme === 'dark'
|
|
50
|
+
? styles.darkCountryPicker
|
|
51
|
+
: styles.lightCountryPicker;
|
|
52
|
+
|
|
53
|
+
const countryPickerStyle = {
|
|
54
|
+
...themeStyle,
|
|
55
|
+
modal: {
|
|
56
|
+
...themeStyle.modal,
|
|
57
|
+
height: height || '50%',
|
|
58
|
+
...modalStyle?.modal,
|
|
59
|
+
},
|
|
60
|
+
backdrop: { ...themeStyle.backdrop, ...modalStyle?.backdrop },
|
|
61
|
+
textInput: {
|
|
62
|
+
...themeStyle.textInput,
|
|
63
|
+
...modalStyle?.searchInput,
|
|
64
|
+
},
|
|
65
|
+
line: { ...themeStyle.line, ...modalStyle?.divider },
|
|
66
|
+
itemsList: {
|
|
67
|
+
...themeStyle.itemsList,
|
|
68
|
+
...modalStyle?.countriesList,
|
|
69
|
+
},
|
|
70
|
+
countryButtonStyles: {
|
|
71
|
+
...themeStyle.countryButtonStyles,
|
|
72
|
+
...modalStyle?.countryButton,
|
|
73
|
+
},
|
|
74
|
+
countryMessageContainer: {
|
|
75
|
+
...themeStyle.countryMessageContainer,
|
|
76
|
+
...modalStyle?.noCountryContainer,
|
|
77
|
+
},
|
|
78
|
+
searchMessageText: {
|
|
79
|
+
...themeStyle.searchMessageText,
|
|
80
|
+
...modalStyle?.noCountryText,
|
|
81
|
+
},
|
|
82
|
+
flag: { ...themeStyle.flag, ...modalStyle?.flag },
|
|
83
|
+
dialCode: { ...themeStyle.dialCode, ...modalStyle?.callingCode },
|
|
84
|
+
countryName: {
|
|
85
|
+
...themeStyle.countryName,
|
|
86
|
+
...modalStyle?.countryName,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return countryPickerStyle;
|
|
59
91
|
}
|
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.
|
|
4
|
+
"version": "0.6.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",
|
package/images/custom-styles.png
DELETED
|
Binary file
|
package/images/preview.png
DELETED
|
Binary file
|