react-simple-phone-input 5.1.5 → 5.1.7
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 +321 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,2 +1,322 @@
|
|
|
1
1
|
React Simple Phone Input
|
|
2
|
-
==========
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
A simple and customizable react phone number dropdown component. It can mix up with your designed theme and give a fluent vibe able dropdown area in your next project.
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/react-simple-phone-input)
|
|
7
|
+
[](https://www.npmjs.com/package/react-simple-phone-input)
|
|
8
|
+
[](https://github.com/siamahnaf198/react-simple-phone-input)
|
|
9
|
+
[](https://github.com/siamahnaf198/react-simple-phone-input/blob/main/LICENSE)
|
|
10
|
+
|
|
11
|
+
- SSR Friendly
|
|
12
|
+
- Customizable
|
|
13
|
+
- Multi Design
|
|
14
|
+
- Search Country
|
|
15
|
+
- Smallest Bundle Size (About 98kb)
|
|
16
|
+
- Typescript support
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```shell-script
|
|
21
|
+
$ npm i react-simple-phone-input --save
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```jsx
|
|
27
|
+
import { PhoneInput, PhoneInputResponseType } from "react-simple-phone-input";
|
|
28
|
+
import "react-simple-phone-input/dist/style.css";
|
|
29
|
+
|
|
30
|
+
<PhoneInput
|
|
31
|
+
country="US"
|
|
32
|
+
placeholder="Add your phone"
|
|
33
|
+
onChange={(data: PhoneInputResponseType) => console.log(data)}
|
|
34
|
+
/>
|
|
35
|
+
```
|
|
36
|
+
#### [See Demo](https://react-simple-phone-input.vercel.app/)
|
|
37
|
+
|
|
38
|
+
## Options
|
|
39
|
+
<table width="100%">
|
|
40
|
+
<tr>
|
|
41
|
+
<th> Name </th>
|
|
42
|
+
<th> Type </th>
|
|
43
|
+
<th width="30%"> Description </th>
|
|
44
|
+
<th> Is Required </th>
|
|
45
|
+
<th> Example </th>
|
|
46
|
+
</tr>
|
|
47
|
+
<tr>
|
|
48
|
+
<td> country </td>
|
|
49
|
+
<td> string </td>
|
|
50
|
+
<td> initial country </td>
|
|
51
|
+
<td> required </td>
|
|
52
|
+
<td> "BD" </td>
|
|
53
|
+
</tr>
|
|
54
|
+
<tr>
|
|
55
|
+
<td> placeholder </td>
|
|
56
|
+
<td> string </td>
|
|
57
|
+
<td> Input Field Placeholder Text </td>
|
|
58
|
+
<td> required </td>
|
|
59
|
+
<td> <code>Type your phone number</code> </td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td> value </td>
|
|
63
|
+
<td> string </td>
|
|
64
|
+
<td> Input field state value or default value </td>
|
|
65
|
+
<td> optional </td>
|
|
66
|
+
<td></td>
|
|
67
|
+
</tr>
|
|
68
|
+
|
|
69
|
+
<tr>
|
|
70
|
+
<td> iconComponent </td>
|
|
71
|
+
<td> ReactNode </td>
|
|
72
|
+
<td> Dropdown Icon component for changing default icon </td>
|
|
73
|
+
<td> optional </td>
|
|
74
|
+
<td><code> <Icon icon="icon-name" /> </code></td>
|
|
75
|
+
</tr>
|
|
76
|
+
|
|
77
|
+
<tr>
|
|
78
|
+
<td> inputProps </td>
|
|
79
|
+
<td> InputHTMLAttributes </td>
|
|
80
|
+
<td> Props to pass into the input field </td>
|
|
81
|
+
<td> optional </td>
|
|
82
|
+
<td> </td>
|
|
83
|
+
</tr>
|
|
84
|
+
|
|
85
|
+
<tr>
|
|
86
|
+
<td> onlyCountries </td>
|
|
87
|
+
<td> array </td>
|
|
88
|
+
<td> Show only country in dropdown menu with Country Codes </td>
|
|
89
|
+
<td> optional </td>
|
|
90
|
+
<td> ["BD", "US", "AF", "AL"] </td>
|
|
91
|
+
</tr>
|
|
92
|
+
|
|
93
|
+
<tr>
|
|
94
|
+
<td> excludeCountries </td>
|
|
95
|
+
<td> array </td>
|
|
96
|
+
<td> If you want to remove some country to the list. If you give <code>excludeCountries</code> then <code>onlyCountries</code> not works </td>
|
|
97
|
+
<td> optional </td>
|
|
98
|
+
<td> ["AF", "AL"] </td>
|
|
99
|
+
</tr>
|
|
100
|
+
|
|
101
|
+
<tr>
|
|
102
|
+
<td> preferredCountries </td>
|
|
103
|
+
<td> array </td>
|
|
104
|
+
<td> Country codes to show on the top of the dropdown menu </td>
|
|
105
|
+
<td> optional </td>
|
|
106
|
+
<td> ["BD", "US"] </td>
|
|
107
|
+
</tr>
|
|
108
|
+
|
|
109
|
+
<tr>
|
|
110
|
+
<td> searchPlaceholder </td>
|
|
111
|
+
<td> string </td>
|
|
112
|
+
<td> Search input field placeholder </td>
|
|
113
|
+
<td>optional</td>
|
|
114
|
+
<td></td>
|
|
115
|
+
</tr>
|
|
116
|
+
|
|
117
|
+
<tr>
|
|
118
|
+
<td> searchIconComponent </td>
|
|
119
|
+
<td> ReactNode </td>
|
|
120
|
+
<td> If <code>search</code> enabled, custom search icon to show on search bar </td>
|
|
121
|
+
<td> optional </td>
|
|
122
|
+
<td><code> <Icon icon="icon-name" /> </code></td>
|
|
123
|
+
</tr>
|
|
124
|
+
|
|
125
|
+
<tr>
|
|
126
|
+
<td> searchProps </td>
|
|
127
|
+
<td> InputHTMLAttributes </td>
|
|
128
|
+
<td> Props to pass into the search input field </td>
|
|
129
|
+
<td> optional </td>
|
|
130
|
+
<td> </td>
|
|
131
|
+
</tr>
|
|
132
|
+
|
|
133
|
+
<tr>
|
|
134
|
+
<td> searchNotFound </td>
|
|
135
|
+
<td> string </td>
|
|
136
|
+
<td> Error message when search result is empty! </td>
|
|
137
|
+
<td> optional </td>
|
|
138
|
+
<td> </td>
|
|
139
|
+
</tr>
|
|
140
|
+
</table>
|
|
141
|
+
|
|
142
|
+
## Other Options
|
|
143
|
+
|
|
144
|
+
<table>
|
|
145
|
+
<tr>
|
|
146
|
+
<th> Name </th>
|
|
147
|
+
<th> Default </th>
|
|
148
|
+
<th> Description </th>
|
|
149
|
+
</tr>
|
|
150
|
+
<tr>
|
|
151
|
+
<td> showDropdownIcon </td>
|
|
152
|
+
<td> true </td>
|
|
153
|
+
<td> Show or Hide dropdown icon </td>
|
|
154
|
+
</tr>
|
|
155
|
+
<tr>
|
|
156
|
+
<td> dialCodeInputField </td>
|
|
157
|
+
<td> false </td>
|
|
158
|
+
<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>
|
|
159
|
+
</tr>
|
|
160
|
+
<tr>
|
|
161
|
+
<td> search </td>
|
|
162
|
+
<td> true </td>
|
|
163
|
+
<td> Show or Hide search input field </td>
|
|
164
|
+
</tr>
|
|
165
|
+
<tr>
|
|
166
|
+
<td> showSearchIcon </td>
|
|
167
|
+
<td> true </td>
|
|
168
|
+
<td> Show or Hide search icon </td>
|
|
169
|
+
</tr>
|
|
170
|
+
<tr>
|
|
171
|
+
<td> disableDropdownOnly </td>
|
|
172
|
+
<td> false </td>
|
|
173
|
+
<td> Disable dropdown menu list </td>
|
|
174
|
+
</tr>
|
|
175
|
+
<tr>
|
|
176
|
+
<td> disableInput </td>
|
|
177
|
+
<td> false </td>
|
|
178
|
+
<td> Disable input field </td>
|
|
179
|
+
</tr>
|
|
180
|
+
</table>
|
|
181
|
+
|
|
182
|
+
## Event
|
|
183
|
+
|
|
184
|
+
<table>
|
|
185
|
+
<tr>
|
|
186
|
+
<th> Event Name </th>
|
|
187
|
+
<th> Description </th>
|
|
188
|
+
<th> Example </th>
|
|
189
|
+
</tr>
|
|
190
|
+
<tr>
|
|
191
|
+
<td> onChange </td>
|
|
192
|
+
<td> To get the value from component. You get following field
|
|
193
|
+
<ul>
|
|
194
|
+
<li><code>country</code></li>
|
|
195
|
+
<li><code>code</code></li>
|
|
196
|
+
<li><code>dialCode</code></li>
|
|
197
|
+
<li><code>value</code></li>
|
|
198
|
+
<li><code>valueWithoutPlus</code></li>
|
|
199
|
+
</ul>
|
|
200
|
+
</td>
|
|
201
|
+
<td> <code>onChange={(data: PhoneInputResponseType) => console.log(data)}</code> </td>
|
|
202
|
+
</tr>
|
|
203
|
+
</table>
|
|
204
|
+
|
|
205
|
+
## ClassName
|
|
206
|
+
|
|
207
|
+
<table>
|
|
208
|
+
<tr>
|
|
209
|
+
<th> Name </th>
|
|
210
|
+
<th> Type </th>
|
|
211
|
+
<th> Description </th>
|
|
212
|
+
</tr>
|
|
213
|
+
<tr>
|
|
214
|
+
<td> containerClass </td>
|
|
215
|
+
<td> string </td>
|
|
216
|
+
<td> class name for container </td>
|
|
217
|
+
</tr>
|
|
218
|
+
<tr>
|
|
219
|
+
<td> buttonClass </td>
|
|
220
|
+
<td> string </td>
|
|
221
|
+
<td> class name for dropdown button </td>
|
|
222
|
+
</tr>
|
|
223
|
+
<tr>
|
|
224
|
+
<td> dropdownClass </td>
|
|
225
|
+
<td> string </td>
|
|
226
|
+
<td> class name for dropdown area/menu </td>
|
|
227
|
+
</tr>
|
|
228
|
+
<tr>
|
|
229
|
+
<td> dropdownListClass </td>
|
|
230
|
+
<td> string </td>
|
|
231
|
+
<td> class name for dropdown list </td>
|
|
232
|
+
</tr>
|
|
233
|
+
<tr>
|
|
234
|
+
<td> dropdownIconClass </td>
|
|
235
|
+
<td> string </td>
|
|
236
|
+
<td> class name for dropdown icon </td>
|
|
237
|
+
</tr><tr>
|
|
238
|
+
<td> searchContainerClass </td>
|
|
239
|
+
<td> string </td>
|
|
240
|
+
<td> class name for search bar container </td>
|
|
241
|
+
</tr>
|
|
242
|
+
<tr>
|
|
243
|
+
<td> searchInputClass </td>
|
|
244
|
+
<td> string </td>
|
|
245
|
+
<td> class name for search input field </td>
|
|
246
|
+
</tr>
|
|
247
|
+
<tr>
|
|
248
|
+
<td> searchIconClass </td>
|
|
249
|
+
<td> string </td>
|
|
250
|
+
<td> class name for search icon </td>
|
|
251
|
+
</tr>
|
|
252
|
+
<tr>
|
|
253
|
+
<td> inputClass </td>
|
|
254
|
+
<td> string </td>
|
|
255
|
+
<td> class name for search icon </td>
|
|
256
|
+
</tr>
|
|
257
|
+
</table>
|
|
258
|
+
|
|
259
|
+
## Customize styles
|
|
260
|
+
|
|
261
|
+
<table>
|
|
262
|
+
<tr>
|
|
263
|
+
<th> Name </th>
|
|
264
|
+
<th> Description </th>
|
|
265
|
+
</tr>
|
|
266
|
+
<tr>
|
|
267
|
+
<td> containerStyle </td>
|
|
268
|
+
<td> phone Input Container style </td>
|
|
269
|
+
</tr>
|
|
270
|
+
<tr>
|
|
271
|
+
<td> buttonStyle </td>
|
|
272
|
+
<td> style for dropdown button </td>
|
|
273
|
+
</tr>
|
|
274
|
+
<tr>
|
|
275
|
+
<td> dropdownStyle </td>
|
|
276
|
+
<td> style for dropdown menu/area </td>
|
|
277
|
+
</tr>
|
|
278
|
+
<tr>
|
|
279
|
+
<td> dropdownListStyle </td>
|
|
280
|
+
<td> style for dropdown list </td>
|
|
281
|
+
</tr>
|
|
282
|
+
<tr>
|
|
283
|
+
<td> dropdownIconStyle </td>
|
|
284
|
+
<td> style for dropdown icon </td>
|
|
285
|
+
</tr>
|
|
286
|
+
<tr>
|
|
287
|
+
<td> searchContainerStyle </td>
|
|
288
|
+
<td> search container style </td>
|
|
289
|
+
</tr>
|
|
290
|
+
<tr>
|
|
291
|
+
<td> searchInputStyle </td>
|
|
292
|
+
<td> search input field style </td>
|
|
293
|
+
</tr>
|
|
294
|
+
<tr>
|
|
295
|
+
<td> searchIconStyle </td>
|
|
296
|
+
<td> search icon style </td>
|
|
297
|
+
</tr>
|
|
298
|
+
<tr>
|
|
299
|
+
<td> inputStyle </td>
|
|
300
|
+
<td> input field style </td>
|
|
301
|
+
</tr>
|
|
302
|
+
</table>
|
|
303
|
+
|
|
304
|
+
`note:` version 5 released. see the [changelogs](https://github.com/siamahnaf198/react-simple-phone-input/releases/tag/v5.0.0)
|
|
305
|
+
|
|
306
|
+
## Contributing
|
|
307
|
+
- Code style changes not allowed
|
|
308
|
+
- Do not create issues about incorrect or missing country data
|
|
309
|
+
|
|
310
|
+
## Issues or correction
|
|
311
|
+
If you face any issues, missing data or wrong data about country, you are welcome to create an issue.
|
|
312
|
+
|
|
313
|
+
## Stay in touch
|
|
314
|
+
|
|
315
|
+
- Author - [Siam Ahnaf](https://www.siamahnaf.com/)
|
|
316
|
+
- Website - [https://www.siamahnaf.com/](https://www.siamahnaf.com/)
|
|
317
|
+
- Twitter - [https://twitter.com/siamahnaf198](https://twitter.com/siamahnaf198)
|
|
318
|
+
- Github - [https://github.com/siamahnaf](https://github.com/siamahnaf)
|
|
319
|
+
|
|
320
|
+
## License
|
|
321
|
+
|
|
322
|
+
[](LICENSE)
|