react-simple-phone-input 5.1.2 → 5.1.3

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.
Files changed (2) hide show
  1. package/README.md +124 -178
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,201 +1,147 @@
1
- React Simple Phone Input
1
+ Country Data Codes
2
2
  ==========
3
3
 
4
- A simple and customizable react phone number dropdown component. It can mixed up with your designed theme and give a fluent vibeable dropdown area in your next project.
4
+ A node js package to get country data including country name, code, currency information, emoji etc.
5
5
 
6
- [![npm version](https://cdn.jsdelivr.net/gh/siamahnaf198/react-simple-phone-input@main/assets/npm-version.svg)](https://www.npmjs.com/package/react-simple-phone-input)
7
- [![npm downloads](https://cdn.jsdelivr.net/gh/siamahnaf198/react-simple-phone-input@main/assets/downloads.svg)](https://www.npmjs.com/package/react-simple-phone-input)
8
- [![PRs Welcome](https://cdn.jsdelivr.net/gh/siamahnaf198/react-simple-phone-input@main/assets/prs-welcome.svg)](https://github.com/siamahnaf198/react-simple-phone-input)
9
- [![MIT licensed](https://cdn.jsdelivr.net/gh/siamahnaf198/react-simple-phone-input@main/assets/license.svg)](https://github.com/siamahnaf198/react-simple-phone-input/blob/main/LICENSE)
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.
10
8
 
11
- - SSR Fiendly
12
- - Customizable
13
- - Multi Design
14
- - Search country
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.
15
28
 
16
29
  ## Installation
17
30
 
18
- ```shell-script
19
- $ npm i react-simple-phone-input --save
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
20
42
  ```
21
43
 
22
- ## Installation
44
+ ## Methods
45
+ ### getCurrency(countryCode)
46
+ Returns the country's currency info by providing country code.
23
47
 
24
- ```jsx
25
- import { PhoneInput } from "react-simple-phone-input";
26
- import "react-simple-phone-input/dist/style.css";
48
+ Example
49
+ ```bash
50
+ import { getCurrency, GetCurrencyTypes } from "country-data-codes";
27
51
 
28
- <PhoneInput
29
- country="US"
30
- placeholder="Add your phone"
31
- onChange={(data) => console.log(data)}
32
- />
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
33
133
  ```
34
- #### [See Demo](https://react-simple-phone-input.vercel.app/)
35
-
36
- ## Options
37
- <table width="100%">
38
- <tr>
39
- <th> Name </th>
40
- <th> Type </th>
41
- <th width="30%"> Description </th>
42
- <th> Is Required </th>
43
- <th> Example </th>
44
- </tr>
45
- <tr>
46
- <td> country </td>
47
- <td> string </td>
48
- <td> initial country </td>
49
- <td> required </td>
50
- <td> "BD" </td>
51
- </tr>
52
- <tr>
53
- <td> placeholder </td>
54
- <td> string </td>
55
- <td> Input Field Placeholder Text </td>
56
- <td> required </td>
57
- <td> <code>Type your phone number</code> </td>
58
- </tr>
59
- <tr>
60
- <td> value </td>
61
- <td> string </td>
62
- <td> Input field state value or default value </td>
63
- <td> optional </td>
64
- <td></td>
65
- </tr>
66
-
67
- <tr>
68
- <td> iconComponent </td>
69
- <td> ReactNode </td>
70
- <td> Dropdown Icon component for changing default icon </td>
71
- <td> optional </td>
72
- <td><code> &lt;Icon icon=&quot;icon-name&quot; /&gt; </cpde></td>
73
- </tr>
74
-
75
- <tr>
76
- <td> inputProps </td>
77
- <td> InputHTMLAttributes </td>
78
- <td> Props to pass into the input field </td>
79
- <td> optional </td>
80
- <td> </td>
81
- </tr>
82
-
83
- <tr>
84
- <td> onlyCountries </td>
85
- <td> array </td>
86
- <td> Show only country in dropdown menu with Country Codes </td>
87
- <td> optional </td>
88
- <td> ["BD", "US", "AF", "AL"] </td>
89
- </tr>
90
-
91
- <tr>
92
- <td> excludeCountries </td>
93
- <td> array </td>
94
- <td> If you want to remove some country to the list. If you give <code>excludeCountries</code> then <code>onlyCountries</code> not works </td>
95
- <td> optional </td>
96
- <td> ["AF", "AL"] </td>
97
- </tr>
98
-
99
- <tr>
100
- <td> preferredCountries </td>
101
- <td> array </td>
102
- <td> Country codes to show on the top of the dropdown menu </td>
103
- <td> optional </td>
104
- <td> ["BD", "US"] </td>
105
- </tr>
106
-
107
- <tr>
108
- <td> searchPlaceholder </td>
109
- <td> string </td>
110
- <td> Search input field placeholder </td>
111
- <td>optional</td>
112
- <td></td>
113
- </tr>
114
-
115
- <tr>
116
- <td> searchIconComponent </td>
117
- <td> ReactNode </td>
118
- <td> If <code>search</code> enabled, custom search icon to show on search bar </td>
119
- <td> optional </td>
120
- <td><code> &lt;Icon icon=&quot;icon-name&quot; /&gt; </cpde></td>
121
- </tr>
122
-
123
- <tr>
124
- <td> searchProps </td>
125
- <td> InputHTMLAttributes </td>
126
- <td> Props to pass into the search input field </td>
127
- <td> optional </td>
128
- <td> </td>
129
- </tr>
130
-
131
- <tr>
132
- <td> searchNotFound </td>
133
- <td> string </td>
134
- <td> Error message when search result is empty! </td>
135
- <td> optional </td>
136
- <td> </td>
137
- </tr>
138
- </table>
139
-
140
- ## Other Options
141
-
142
- <table>
143
- <tr>
144
- <th> Name </th>
145
- <th> Default </th>
146
- <th> Description </th>
147
- </tr>
148
- <tr>
149
- <td> showDropdownIcon </td>
150
- <td> true </td>
151
- <td> Show or Hide dropdown icon </td>
152
- </tr>
153
- <tr>
154
- <td> dialCodeInputField </td>
155
- <td> false </td>
156
- <td> Show calling code into into field or show beside country flag. For more, see <a href="https://react-simple-phone-input.vercel.app/">example</a> </td>
157
- </tr>
158
- <tr>
159
- <td> search </td>
160
- <td> true </td>
161
- <td> Show or Hide search input field </td>
162
- </tr>
163
- <tr>
164
- <td> showSearchIcon </td>
165
- <td> true </td>
166
- <td> Show or Hide search icon </td>
167
- </tr>
168
- </table>
169
-
170
- ## Event
171
-
172
- <table>
173
- <tr>
174
- <th> Event Name </th>
175
- <th> Description </th>
176
- <th> Example </th>
177
- </tr>
178
- <tr>
179
- <td> onChange </td>
180
- <td> To get the value from component </td>
181
- <td> <code>onChange={(data: string) => console.log(data)}</code> </td>
182
- </tr>
183
- </table>
184
-
185
- ## Contributing
186
- - Code style changes not allowed
187
- - Do not create issues about incorrect or missing country data
188
134
 
189
135
  ## Issues or correction
190
- If you face any issues, missing data or wrong data about country, you are welcome to create an issue.
136
+ If you face any issues to any function or see any wrong information about country, please let me know.
191
137
 
192
138
  ## Stay in touch
193
139
 
194
140
  - Author - [Siam Ahnaf](https://www.siamahnaf.com/)
195
141
  - Website - [https://www.siamahnaf.com/](https://www.siamahnaf.com/)
196
142
  - Twitter - [https://twitter.com/siamahnaf198](https://twitter.com/siamahnaf198)
197
- - Github - [https://github.com/siamahnaf198](https://github.com/siamahnaf198)
143
+ - Github - [https://github.com/siamahnaf](https://github.com/siamahnaf)
198
144
 
199
145
  ## License
200
146
 
201
- [![MIT licensed](https://cdn.jsdelivr.net/gh/siamahnaf198/react-simple-phone-input@main/assets/license.svg)](LICENSE)
147
+ country-data-codes [MIT licensed](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-phone-input",
3
- "version": "5.1.2",
3
+ "version": "5.1.3",
4
4
  "description": "A simple react phone input component with calling code dropdown🤷",
5
5
  "homepage": "https://react-simple-phone-input.vercel.app",
6
6
  "main": "dist/cjs/index.js",