react-simple-phone-input 5.1.4 → 5.1.6
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 +147 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Country Data Codes
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
A node js package to get country data including country name, code, currency information, emoji etc.
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
A simple but useful functional node packages with all country data. It includes all useful country data gives several function to complete your project.
|
|
8
|
+
|
|
9
|
+
## Countries
|
|
10
|
+
|
|
11
|
+
The data currently provided for each country is:
|
|
12
|
+
|
|
13
|
+
* `id` The unique id number for the array
|
|
14
|
+
* `name` The english name for the country
|
|
15
|
+
* `isoAlpha2` The [ISO 3166-1 alpha 2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code
|
|
16
|
+
* `isoAlpha3` The [ISO 3166-1 alpha 3](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) code
|
|
17
|
+
* `isoNumeric` The [ISO 3166-1 numeric](https://en.wikipedia.org/wiki/ISO_3166-1_numeric)
|
|
18
|
+
* `currency` An object with currency info.
|
|
19
|
+
|
|
20
|
+
- `code` The [ISO 4217 currency codes](http://en.wikipedia.org/wiki/ISO_4217)
|
|
21
|
+
- `name` The currency name
|
|
22
|
+
- `symbol` The currency symbol
|
|
23
|
+
|
|
24
|
+
* `flag` Country flag base64 data
|
|
25
|
+
* `languages` An array of [ISO 639-2](http://en.wikipedia.org/wiki/ISO_639-2) codes for languages.
|
|
26
|
+
* `countryCallingCodes` The international call prefixes for this country.
|
|
27
|
+
* `emoji` The emoji of country's flag.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
$ npm i country-data-codes
|
|
33
|
+
```
|
|
34
|
+
```bash
|
|
35
|
+
import { getCountryList } from "country-data-codes";
|
|
36
|
+
or
|
|
37
|
+
const { getCountryList } = require("country-data-codes")
|
|
38
|
+
```
|
|
39
|
+
Example
|
|
40
|
+
```bash
|
|
41
|
+
console.log(getCountryList()); //Returns all country list
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Methods
|
|
45
|
+
### getCurrency(countryCode)
|
|
46
|
+
Returns the country's currency info by providing country code.
|
|
47
|
+
|
|
48
|
+
Example
|
|
49
|
+
```bash
|
|
50
|
+
import { getCurrency, GetCurrencyTypes } from "country-data-codes";
|
|
51
|
+
|
|
52
|
+
const currencyInfo: GetCurrencyTypes = getCurrency("BD"); // Here country code can be isoAlpha2 or isoAlpha3
|
|
53
|
+
|
|
54
|
+
console.log(currencyInfo)
|
|
55
|
+
```
|
|
56
|
+
Return values-
|
|
57
|
+
* `name` currency name
|
|
58
|
+
* `code` currency code
|
|
59
|
+
* `symbol` currency symbol
|
|
60
|
+
|
|
61
|
+
### getCallingCode(countryCode)
|
|
62
|
+
Returns the country's calling code. It returns an array of string.
|
|
63
|
+
|
|
64
|
+
Example
|
|
65
|
+
```bash
|
|
66
|
+
import { getCallingCode, GetCallingCodeTypes } from "country-data-codes";
|
|
67
|
+
|
|
68
|
+
const dialingCode: GetCallingCodeTypes = getCallingCode("BD")
|
|
69
|
+
|
|
70
|
+
console.log(dialingCode) // Give the country code(isoAlpha2 or isoAlpha3)
|
|
71
|
+
//{
|
|
72
|
+
code: "880",
|
|
73
|
+
format: "+880",
|
|
74
|
+
flag: "" //Base64 flash data
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
### getLanguages(countryCode)
|
|
78
|
+
Returns the country's languages. It returns an array of string;
|
|
79
|
+
|
|
80
|
+
Example
|
|
81
|
+
```bash
|
|
82
|
+
import { getLanguages } from "country-data-codes";
|
|
83
|
+
|
|
84
|
+
console.log(getLanguages("BD")) // Give the country code(isoAlpha2 or isoAlpha3)
|
|
85
|
+
//["ben"]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### getFlagBase64(countryCode)
|
|
89
|
+
Returns the country's flag image as base64 data
|
|
90
|
+
|
|
91
|
+
Example
|
|
92
|
+
```bash
|
|
93
|
+
import { getFlagBase64 } from "country-data-codes";
|
|
94
|
+
|
|
95
|
+
const flag = getFlagBase64("BD") // Give the country code(isoAlpha2 or isoAlpha3)
|
|
96
|
+
|
|
97
|
+
//<img src=`data:image/png;base64, ${flag}`/>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### lookup(query)
|
|
101
|
+
You can search and find any country's data by any parameter, like-
|
|
102
|
+
* by `name`: You can search and find data by country name
|
|
103
|
+
* by `countryCode`: You can search and find data by country code
|
|
104
|
+
* by `callingCode`: You can search and find data by country calling code
|
|
105
|
+
* by `currencyName`: You can search and find data by country currency name
|
|
106
|
+
* by `currencyCode`: You can search and find data by country currency code
|
|
107
|
+
* by `currencySymbol`: You can search and find data by country currency symbol
|
|
108
|
+
* by `isoNumeric`: You can search and find data by country iso numeric
|
|
109
|
+
|
|
110
|
+
Example
|
|
111
|
+
```bash
|
|
112
|
+
import { lookup, CountryDataTypes } from "country-data-codes";
|
|
113
|
+
|
|
114
|
+
const data: CountryDataTypes = lookup({name: "Bangladesh"})
|
|
115
|
+
const data: CountryDataTypes = lookup({countryCode: "BD"})
|
|
116
|
+
const data: CountryDataTypes = lookup({callingCode: "+880"})
|
|
117
|
+
const data: CountryDataTypes = lookup({currencyName: "taka"})
|
|
118
|
+
const data: CountryDataTypes = lookup({currencyCode: "BDT"})
|
|
119
|
+
const data: CountryDataTypes = lookup({currencySymbol: "৳"})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### removeDialCode()
|
|
123
|
+
You can remove dial code from a phone number and get a string value.
|
|
124
|
+
|
|
125
|
+
Example
|
|
126
|
+
```bash
|
|
127
|
+
import { removeDialCode } from "country-data-codes";
|
|
128
|
+
|
|
129
|
+
const phone = removeDialCode("+8801611994404")
|
|
130
|
+
|
|
131
|
+
//undefined or
|
|
132
|
+
//01611994403
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Issues or correction
|
|
136
|
+
If you face any issues to any function or see any wrong information about country, please let me know.
|
|
137
|
+
|
|
138
|
+
## Stay in touch
|
|
139
|
+
|
|
140
|
+
- Author - [Siam Ahnaf](https://www.siamahnaf.com/)
|
|
141
|
+
- Website - [https://www.siamahnaf.com/](https://www.siamahnaf.com/)
|
|
142
|
+
- Twitter - [https://twitter.com/siamahnaf198](https://twitter.com/siamahnaf198)
|
|
143
|
+
- Github - [https://github.com/siamahnaf](https://github.com/siamahnaf)
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
[](LICENSE)
|