react-native-international-phone-number 0.8.2 → 0.8.4
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 +37 -29
- package/lib/constants/countries.js +41 -9
- package/lib/index.js +22 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,16 +37,32 @@
|
|
|
37
37
|
</a>
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
|
+
<br>
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- 📱 Works with iOS, Android (Cross-platform), Expo and Web;
|
|
45
|
+
- 🎨 Lib with UI customizable;
|
|
46
|
+
- 🌎 Phone Input Mask according with the selected country;
|
|
47
|
+
- 👨💻 Functional and class component support;
|
|
48
|
+
- 🈶 22 languages supported.
|
|
49
|
+
|
|
50
|
+
<br>
|
|
51
|
+
|
|
40
52
|
## Try it out
|
|
41
53
|
|
|
42
54
|
- [Demo](https://snack.expo.dev/@astroonauta/react-native-international-phone-number)
|
|
43
55
|
|
|
56
|
+
<br>
|
|
57
|
+
|
|
44
58
|
## List of Contents
|
|
45
59
|
|
|
46
60
|
- [Old Versions](#old-versions)
|
|
47
61
|
- [Installation](#installation)
|
|
48
|
-
- [Additional Config
|
|
49
|
-
- [
|
|
62
|
+
- [Additional Config](#additional-config)
|
|
63
|
+
- [React Native CLI](#using-react-native-cli)
|
|
64
|
+
- [Expo](#using-expo)
|
|
65
|
+
- [Web](#using-web)
|
|
50
66
|
- [Basic Usage](#basic-usage)
|
|
51
67
|
- [With Class Component](#class-component)
|
|
52
68
|
- [With Function Component](#function-component)
|
|
@@ -102,11 +118,11 @@ OR
|
|
|
102
118
|
$ yarn add react-native-international-phone-number
|
|
103
119
|
```
|
|
104
120
|
|
|
105
|
-
## Additional config
|
|
121
|
+
## Additional config
|
|
106
122
|
|
|
107
|
-
- Using React Native CLI:
|
|
123
|
+
- ### Using React Native CLI:
|
|
108
124
|
|
|
109
|
-
|
|
125
|
+
Create a `react-native.config.js` file at the root of your react-native project with:
|
|
110
126
|
|
|
111
127
|
```bash
|
|
112
128
|
module.exports = {
|
|
@@ -126,23 +142,10 @@ Then link the font to your native projects with:
|
|
|
126
142
|
npx react-native-asset
|
|
127
143
|
```
|
|
128
144
|
|
|
129
|
-
- Using Expo:
|
|
145
|
+
- ### Using Expo:
|
|
130
146
|
|
|
131
|
-
1.
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
...
|
|
135
|
-
|
|
136
|
-
"web": {
|
|
137
|
-
...
|
|
138
|
-
"output": "single",
|
|
139
|
-
...
|
|
140
|
-
},
|
|
141
|
-
...
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
2. Install [expo-fonts](https://docs.expo.dev/versions/latest/sdk/font/): `npx expo install expo-font`;
|
|
145
|
-
3. Initialize the `expo-font`:
|
|
147
|
+
1. Install [expo-fonts](https://docs.expo.dev/versions/latest/sdk/font/): `npx expo install expo-font`;
|
|
148
|
+
2. Initialize the `expo-font`:
|
|
146
149
|
|
|
147
150
|
```bash
|
|
148
151
|
import { useFonts } from 'expo-font';
|
|
@@ -156,17 +159,22 @@ npx react-native-asset
|
|
|
156
159
|
...
|
|
157
160
|
```
|
|
158
161
|
|
|
159
|
-
> Observation:
|
|
162
|
+
> Observation: you need to recompile your project after adding new fonts.
|
|
160
163
|
|
|
161
|
-
|
|
164
|
+
- ### Using Web:
|
|
162
165
|
|
|
163
|
-
|
|
166
|
+
Change the `app.json` file to:
|
|
164
167
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
```bash
|
|
169
|
+
...
|
|
170
|
+
|
|
171
|
+
"web": {
|
|
172
|
+
...
|
|
173
|
+
"output": "single",
|
|
174
|
+
...
|
|
175
|
+
},
|
|
176
|
+
...
|
|
177
|
+
```
|
|
170
178
|
|
|
171
179
|
<br>
|
|
172
180
|
|
|
@@ -423,12 +423,7 @@ export const countries = [
|
|
|
423
423
|
zh: '澳大利亞',
|
|
424
424
|
tr: 'Avustralya',
|
|
425
425
|
},
|
|
426
|
-
phoneMasks: [
|
|
427
|
-
'2 #### ####',
|
|
428
|
-
'3 #### ####',
|
|
429
|
-
'4## ### ###',
|
|
430
|
-
'7 #### ####',
|
|
431
|
-
],
|
|
426
|
+
phoneMasks: ['### ### ###'],
|
|
432
427
|
},
|
|
433
428
|
{
|
|
434
429
|
callingCode: '+297',
|
|
@@ -788,7 +783,7 @@ export const countries = [
|
|
|
788
783
|
zh: '貝寧',
|
|
789
784
|
tr: 'Benin',
|
|
790
785
|
},
|
|
791
|
-
phoneMasks: ['## ##
|
|
786
|
+
phoneMasks: ['# ## ## ## ##'],
|
|
792
787
|
},
|
|
793
788
|
{
|
|
794
789
|
callingCode: '+590',
|
|
@@ -2287,17 +2282,52 @@ export const countries = [
|
|
|
2287
2282
|
tr: 'Birleşik Krallık',
|
|
2288
2283
|
},
|
|
2289
2284
|
phoneMasks: [
|
|
2285
|
+
'999',
|
|
2286
|
+
'112',
|
|
2287
|
+
'100',
|
|
2288
|
+
'101',
|
|
2289
|
+
'105',
|
|
2290
|
+
'111',
|
|
2291
|
+
'119',
|
|
2292
|
+
'123',
|
|
2293
|
+
'141',
|
|
2294
|
+
'155',
|
|
2295
|
+
'159',
|
|
2296
|
+
'1470',
|
|
2297
|
+
'1471',
|
|
2298
|
+
'1472',
|
|
2299
|
+
'1474',
|
|
2300
|
+
'1475',
|
|
2301
|
+
'1476',
|
|
2302
|
+
'1477',
|
|
2303
|
+
'1478',
|
|
2304
|
+
'1479',
|
|
2305
|
+
'1571',
|
|
2306
|
+
'1572',
|
|
2307
|
+
'17070',
|
|
2308
|
+
'116 ###',
|
|
2309
|
+
'118 ###',
|
|
2310
|
+
'800 ## ##',
|
|
2311
|
+
'845 ## ##',
|
|
2290
2312
|
'160## ####',
|
|
2291
2313
|
'169## ####',
|
|
2292
2314
|
'160## #####',
|
|
2293
2315
|
'169## #####',
|
|
2316
|
+
'1## ## ####',
|
|
2317
|
+
'800 ### ###',
|
|
2294
2318
|
'2# #### ####',
|
|
2319
|
+
'55 #### ####',
|
|
2320
|
+
'56 #### ####',
|
|
2321
|
+
'7# #### ####',
|
|
2295
2322
|
'11# ### ####',
|
|
2296
2323
|
'12# ### ####',
|
|
2297
2324
|
'13# ### ####',
|
|
2298
2325
|
'141 ### ####',
|
|
2299
2326
|
'151 ### ####',
|
|
2300
2327
|
'161 ### ####',
|
|
2328
|
+
'3## ### ####',
|
|
2329
|
+
'8## ### ####',
|
|
2330
|
+
'9## ### ####',
|
|
2301
2331
|
'12## ## ####',
|
|
2302
2332
|
'13## ## ####',
|
|
2303
2333
|
'1642 ## ####',
|
|
@@ -3637,7 +3667,7 @@ export const countries = [
|
|
|
3637
3667
|
zh: '韓國',
|
|
3638
3668
|
tr: 'Kore Cumhuriyeti',
|
|
3639
3669
|
},
|
|
3640
|
-
phoneMasks: ['### #### ####'],
|
|
3670
|
+
phoneMasks: ['## ### ####', '## #### ####'],
|
|
3641
3671
|
},
|
|
3642
3672
|
{
|
|
3643
3673
|
callingCode: '+965',
|
|
@@ -5182,7 +5212,9 @@ export const countries = [
|
|
|
5182
5212
|
zh: '巴拿馬',
|
|
5183
5213
|
tr: 'Panama',
|
|
5184
5214
|
},
|
|
5185
|
-
|
|
5215
|
+
// https://en.wikipedia.org/wiki/Telephone_numbers_in_Panama
|
|
5216
|
+
// Mobile numbers in Panama always start with 6 and are eight digits.
|
|
5217
|
+
phoneMasks: ['### ####', '6### ####'],
|
|
5186
5218
|
},
|
|
5187
5219
|
{
|
|
5188
5220
|
callingCode: '+51',
|
package/lib/index.js
CHANGED
|
@@ -331,27 +331,30 @@ const PhoneInput = forwardRef(
|
|
|
331
331
|
} else {
|
|
332
332
|
// Create a separate constant for each part of the component
|
|
333
333
|
const touchableStart = (
|
|
334
|
-
|
|
335
|
-
{
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
<View style={phoneInputStyles?.caret}>
|
|
341
|
-
<View
|
|
342
|
-
style={{
|
|
343
|
-
flexDirection: 'row',
|
|
344
|
-
justifyContent: 'center',
|
|
345
|
-
paddingTop: 4,
|
|
346
|
-
}}
|
|
347
|
-
>
|
|
334
|
+
<>
|
|
335
|
+
<Text style={getFlagStyle(phoneInputStyles?.flag)}>
|
|
336
|
+
{countryValue?.flag}
|
|
337
|
+
</Text>
|
|
338
|
+
{customCaret || (
|
|
339
|
+
<View style={phoneInputStyles?.caret}>
|
|
348
340
|
<View
|
|
349
|
-
style={
|
|
350
|
-
|
|
341
|
+
style={{
|
|
342
|
+
flexDirection: 'row',
|
|
343
|
+
justifyContent: 'center',
|
|
344
|
+
paddingTop: 4,
|
|
345
|
+
}}
|
|
346
|
+
>
|
|
347
|
+
<View
|
|
348
|
+
style={getCaretStyle(
|
|
349
|
+
theme,
|
|
350
|
+
phoneInputStyles?.caret
|
|
351
|
+
)}
|
|
352
|
+
/>
|
|
353
|
+
</View>
|
|
351
354
|
</View>
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
+
)}
|
|
356
|
+
</>
|
|
357
|
+
);
|
|
355
358
|
|
|
356
359
|
const touchableMiddle = (
|
|
357
360
|
<View
|
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.8.
|
|
4
|
+
"version": "0.8.4",
|
|
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",
|