@@ -16,16 +16,17 @@ npm install react-phone-input-2 --save
16
16
## Usage
17
17
``` jsx
18
18
import PhoneInput from ' react-phone-input-2'
19
- import ' react-phone-input-2/dist /style.css'
19
+ import ' react-phone-input-2/lib /style.css'
20
20
21
- < PhoneInput country= {' us' } value= {this .state .phone } onChange= {handleOnChange} / >
21
+ < PhoneInput
22
+ country= {' us' }
23
+ value= {this .state .phone }
24
+ onChange= {phone => this .setState ({ phone })}
25
+ / >
22
26
```
23
27
24
- ``` jsx
25
- handleOnChange (value ) {
26
- this .setState ({ phone: value })
27
- }
28
- ```
28
+ ### [ Demo 1] ( https://bl00mber.github.io/react-phone-input-2.html ) - [ Demo 2] ( https://bl00mber.github.io/react-phone-input-2-css.html )
29
+ ** available styles** - style • high-res • material • bootstrap • semantic-ui • plain
29
30
30
31
## Options
31
32
<table >
@@ -78,7 +79,7 @@ handleOnChange(value) {
78
79
</tr >
79
80
80
81
<tr >
81
- <td> inputExtraProps </td>
82
+ <td> inputProps </td>
82
83
<td> object </td>
83
84
<td colspan="2"> props to pass into the input </td>
84
85
</tr >
@@ -126,7 +127,7 @@ handleOnChange(value) {
126
127
<td> </td>
127
128
</tr >
128
129
<tr >
129
- <td> enableSearchField </td>
130
+ <td> enableSearch </td>
130
131
<td> false </td>
131
132
<td> enable search in the dropdown </td>
132
133
</tr >
@@ -139,7 +140,7 @@ handleOnChange(value) {
139
140
140
141
``` jsx
141
142
< PhoneInput
142
- inputExtraProps = {{
143
+ inputProps = {{
143
144
name: ' phone' ,
144
145
required: true ,
145
146
autoFocus: true
@@ -153,9 +154,9 @@ handleOnChange(value) {
153
154
- [ Regions] ( #regions )
154
155
- [ Localization] ( #predefined-localization )
155
156
- [ Local area codes] ( #local-area-codes )
156
- - [ Other props] ( #other-props )
157
- - [ Custom area codes] ( #custom-area-codes )
158
157
- [ Custom masks] ( #custom-masks )
158
+ - [ Custom area codes] ( #custom-area-codes )
159
+ - [ Other props] ( #other-props )
159
160
- [ Custom localization] ( #custom-localization )
160
161
- [ Guides] ( #guides )
161
162
- [ Phone without dialCode] ( #phone-without-dialcode )
@@ -260,7 +261,7 @@ Country data object not returns from onKeyDown event
260
261
<tr >
261
262
<td> regions </td>
262
263
<td> array/string </td>
263
- <td> to only show codes from selected regions </td>
264
+ <td> to show countries only from specified regions </td>
264
265
</tr >
265
266
</table >
266
267
@@ -279,18 +280,14 @@ Country data object not returns from onKeyDown event
279
280
</tr >
280
281
</table >
281
282
282
- Regions selected: {'europe'}
283
283
``` jsx
284
284
< PhoneInput
285
- country= ' it '
285
+ country= ' de '
286
286
regions= {' europe' }
287
287
/ >
288
- ```
289
288
290
- Regions selected: {[ 'north-america', 'carribean'] }
291
- ``` jsx
292
289
< PhoneInput
293
- country= ' ca '
290
+ country= ' us '
294
291
regions= {[' north-america' , ' carribean' ]}
295
292
/ >
296
293
```
@@ -316,15 +313,31 @@ import es from 'react-phone-input-2/lang/es.json'
316
313
/ >
317
314
```
318
315
316
+ ### Custom masks
317
+ ``` jsx
318
+ < PhoneInput
319
+ onlyCountries= {[' fr' , ' at' ]}
320
+ masks= {{fr: ' +.. (...) ..-..-..' , at: ' +.. (....) ...-....' }}
321
+ / >
322
+ ```
323
+
324
+ ### Custom area codes
325
+ ``` jsx
326
+ < PhoneInput
327
+ onlyCountries= {[' gr' , ' fr' , ' us' ]}
328
+ areaCodes= {{gr: [' 2694' , ' 2647' ], fr: [' 369' , ' 463' ], us: [' 300' ]}}
329
+ / >
330
+ ```
331
+
319
332
### Other props
320
333
<table >
321
334
<tr >
322
335
<td> defaultMask </td>
323
- <td> ' ...... ...... ..' </td>
336
+ <td> ...... ...... .. </td>
324
337
</tr >
325
338
<tr >
326
- <td> predecessor </td>
327
- <td> '+' </td>
339
+ <td> prefix </td>
340
+ <td> + </td>
328
341
</tr >
329
342
<tr >
330
343
<td> copyNumbersOnly </td>
@@ -344,44 +357,6 @@ import es from 'react-phone-input-2/lang/es.json'
344
357
</tr >
345
358
</table >
346
359
347
- ### Custom area codes
348
- <table >
349
- <tr >
350
- <th> Name </th>
351
- <th> Type </th>
352
- </tr >
353
- <tr >
354
- <td> areaCodes </td>
355
- <td> object </td>
356
- </tr >
357
- </table >
358
-
359
- ``` jsx
360
- < PhoneInput
361
- onlyCountries= {[' gr' , ' fr' , ' us' ]}
362
- areaCodes= {{gr: [' 2694' , ' 2647' ], fr: [' 369' , ' 463' ], us: [' 300' ]}}
363
- / >
364
- ```
365
-
366
- ### Custom masks
367
- <table >
368
- <tr >
369
- <th> Name </th>
370
- <th> Type </th>
371
- </tr >
372
- <tr >
373
- <td> masks </td>
374
- <td> object </td>
375
- </tr >
376
- </table >
377
-
378
- ``` jsx
379
- < PhoneInput
380
- onlyCountries= {[' fr' , ' at' ]}
381
- masks= {{fr: ' +.. (...) ..-..-..' , at: ' +.. (....) ...-....' }}
382
- / >
383
- ```
384
-
385
360
### Custom localization
386
361
``` jsx
387
362
< PhoneInput
@@ -396,17 +371,6 @@ import es from 'react-phone-input-2/lang/es.json'
396
371
```
397
372
398
373
### Preserve countries order
399
- <table >
400
- <tr >
401
- <th> Name </th>
402
- <th> Type </th>
403
- </tr >
404
- <tr >
405
- <td> preserveOrder </td>
406
- <td> array </td>
407
- </tr >
408
- </table >
409
-
410
374
``` jsx
411
375
< PhoneInput
412
376
onlyCountries= {[' fr' , ' at' ]}
0 commit comments