react-native-country-select 0.1.1 โ†’ 0.1.2

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/LICENSE.md CHANGED
@@ -1,7 +1,7 @@
1
- ISC License
2
-
3
- Copyright 2025-present Willian Barbosa Lima do Nascimento
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ ISC License
2
+
3
+ Copyright 2025-present Willian Barbosa Lima do Nascimento
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,296 +1,307 @@
1
- <h1 align="center">React Native Country Select</h1>
2
-
3
- <p>
4
- ๐ŸŒ A lightweight and customizable country picker for React Native with modern UI, flags, search engine, and i18n support. Includes TypeScript types, offline support and no dependencies.
5
- </p>
6
-
7
- <br>
8
-
9
- <div align="center">
10
- <a href="https://www.npmjs.com/package/react-native-country-select">
11
- <img src="https://img.shields.io/npm/v/react-native-country-select.svg?style=flat-square">
12
- </a>
13
- <a href="https://www.npmjs.com/package/react-native-country-select">
14
- <img src="https://img.shields.io/npm/dt/react-native-country-select.svg?style=flat-square&color=success">
15
- </a>
16
- <a href="https://github.com/AstrOOnauta/react-native-country-select">
17
- <img src="https://img.shields.io/github/stars/AstrOOnauta/react-native-country-select?style=flat-square&color=success"/>
18
- </a>
19
- <a href="https://github.com/AstrOOnauta/react-native-country-select/issues">
20
- <img src="https://img.shields.io/github/issues/AstrOOnauta/react-native-country-select?style=flat-square&color=blue"/>
21
- </a>
22
- <a href="https://github.com/AstrOOnauta/react-native-country-select/pulls">
23
- <img src="https://img.shields.io/github/issues-pr/AstrOOnauta/react-native-country-select?style=flat-square&color=blue"/>
24
- </a>
25
- <a href="LICENSE.md">
26
- <img src="https://img.shields.io/:license-isc-yellow.svg?style=flat-square"/>
27
- </a>
28
- </div>
29
-
30
- <br>
31
-
32
- <div align="center">
33
- <a href="https://www.buymeacoffee.com/astroonauta" target="_blank">
34
- <img src="https://survivingmexico.files.wordpress.com/2018/07/button-gif.gif" alt="Buy Me A Coffee" style="height: auto !important;width: 60% !important;">
35
- </a>
36
- </div>
37
-
38
- <br>
39
-
40
- ## Features
41
-
42
- - ๐Ÿ“ฑ Cross-platform: works with iOS, Android and Expo;
43
- - ๐ŸŽจ Lib with custom and modern UI;
44
- - ๐Ÿ‘จโ€๐Ÿ’ป Functional and class component support;
45
- - ๐Ÿˆถ 32 languages supported;
46
- - โ™ฟ Accessibility.
47
-
48
- <br>
49
-
50
- ## Try it out
51
-
52
- - [Demo](https://snack.expo.dev/@astroonauta/react-native-country-select)
53
-
54
- <br>
55
-
56
- ## Installation
57
-
58
- ```sh
59
- npm install react-native-country-select
60
- # or
61
- yarn add react-native-country-select
62
- ```
63
-
64
- <br>
65
-
66
- ## Basic Usage
67
-
68
- - Class Component
69
-
70
- ```jsx
71
- import React, {Component} from 'react';
72
- import {Text, TouchableOpacity, View} from 'react-native';
73
- import CountrySelect from 'react-native-country-select';
74
-
75
- export default class App extends Component {
76
- countryRef = null;
77
-
78
- constructor(props) {
79
- super(props);
80
- this.state = {
81
- showPicker: false,
82
- country: null,
83
- };
84
- }
85
-
86
- handleCountrySelect = country => {
87
- this.setState({country});
88
- };
89
-
90
- render() {
91
- return (
92
- <View style={{flex: 1}}>
93
- <TouchableOpacity onPress={() => this.setState({showPicker: true})}>
94
- <Text>Select Country</Text>
95
- </TouchableOpacity>
96
- <Text>
97
- Country:{' '}
98
- {`${this.state.selectedCountry?.name?.common} (${this.state.selectedCountry?.cca2})`}
99
- </Text>
100
-
101
- <CountrySelect
102
- visible={this.state.showPicker}
103
- onClose={() => this.setState({showPicker: false})}
104
- onSelect={this.handleCountrySelect}
105
- />
106
- </View>
107
- );
108
- }
109
- }
110
- ```
111
-
112
- <br>
113
-
114
- - Function Component
115
-
116
- ```jsx
117
- import React, {useState} from 'react';
118
- import {Text, TouchableOpacity, View} from 'react-native';
119
-
120
- import CountrySelect from 'react-native-country-select';
121
-
122
- export default function App() {
123
- const [showPicker, setShowPicker] = useState(false);
124
- const [selectedCountry, setSelectedCountry] = useState(null);
125
-
126
- const handleCountrySelect = country => {
127
- setSelectedCountry(country);
128
- };
129
-
130
- return (
131
- <View
132
- style={{
133
- flex: 1,
134
- }}>
135
- <TouchableOpacity onPress={() => setShowPicker(true)}>
136
- <Text>Select Country</Text>
137
- </TouchableOpacity>
138
- <Text>
139
- Country: {`${selectedCountry?.name?.common} (${selectedCountry?.cca2})`}
140
- </Text>
141
-
142
- <CountrySelect
143
- visible={showPicker}
144
- onClose={() => setShowPicker(false)}
145
- onSelect={handleCountrySelect}
146
- />
147
- </View>
148
- );
149
- }
150
- ```
151
-
152
- <br>
153
-
154
- - Typescript
155
-
156
- ```tsx
157
- import React, {useState} from 'react';
158
- import {Text, TouchableOpacity, View} from 'react-native';
159
-
160
- import CountrySelect, {ICountry} from 'react-native-country-select';
161
-
162
- export default function App() {
163
- const [showPicker, setShowPicker] = useState<boolean>(false);
164
- const [selectedCountry, setSelectedCountry] = useState<ICountry | null>(null);
165
-
166
- const handleCountrySelect = (country: ICountry) => {
167
- setSelectedCountry(country);
168
- };
169
-
170
- return (
171
- <View
172
- style={{
173
- flex: 1,
174
- }}>
175
- <TouchableOpacity onPress={() => setShowPicker(true)}>
176
- <Text>Select Country</Text>
177
- </TouchableOpacity>
178
- <Text>
179
- Country: {`${selectedCountry?.name?.common} (${selectedCountry?.cca2})`}
180
- </Text>
181
-
182
- <CountrySelect
183
- visible={showPicker}
184
- onClose={() => setShowPicker(false)}
185
- onSelect={handleCountrySelect}
186
- />
187
- </View>
188
- );
189
- }
190
- ```
191
-
192
- <br>
193
-
194
- ## CountrySelect Props
195
-
196
- | Prop | Type | Required | Default | Description |
197
- | -------- | --------------------------- | -------- | ------- | ---------------------------------------------------------- |
198
- | visible | boolean | Yes | false | Controls the visibility of the country picker modal |
199
- | onClose | () => void | Yes | - | Callback function called when the modal is closed |
200
- | onSelect | (country: ICountry) => void | Yes | - | Callback function called when a country is selected |
201
- | theme | 'light' \| 'dark' | No | 'light' | Theme for the country picker |
202
- | language | ICountrySelectLanguages | No | 'eng' | Language for country names (see supported languages below) |
203
-
204
- <br>
205
-
206
- ### Supported Languages
207
-
208
- The `language` prop supports the following values:
209
-
210
- | Code | Language |
211
- | ---------- | ------------------- |
212
- | `ara` | Arabic |
213
- | `bel` | Belarusian |
214
- | `bre` | Breton |
215
- | `bul` | Bulgarian |
216
- | `ces` | Czech |
217
- | `deu` | German |
218
- | `ell` | Greek |
219
- | `eng` | English |
220
- | `est` | Estonian |
221
- | `fin` | Finnish |
222
- | `fra` | French |
223
- | `heb` | Hebrew |
224
- | `hrv` | Croatian |
225
- | `hun` | Hungarian |
226
- | `ita` | Italian |
227
- | `jpn` | Japanese |
228
- | `kor` | Korean |
229
- | `nld` | Dutch |
230
- | `per` | Persian |
231
- | `pol` | Polish |
232
- | `por` | Portuguese |
233
- | `ron` | Romanian |
234
- | `rus` | Russian |
235
- | `slk` | Slovak |
236
- | `spa` | Spanish |
237
- | `srp` | Serbian |
238
- | `swe` | Swedish |
239
- | `tur` | Turkish |
240
- | `ukr` | Ukrainian |
241
- | `urd` | Urdu |
242
- | `zho` | Chinese |
243
- | `zho-Hans` | Simplified Chinese |
244
- | `zho-Hant` | Traditional Chinese |
245
-
246
- <br>
247
-
248
- ## Testing
249
-
250
- When utilizing this package, you may need to target the CountrySelect component in your automated tests. To facilitate this, we provide a testID props for the CountrySelect component. The testID can be integrated with popular testing libraries such as @testing-library/react-native or Maestro. This enables you to efficiently locate and interact with CountrySelect elements within your tests, ensuring a robust and reliable testing experience.
251
-
252
- ```js
253
- const countrySelect = getByTestId('countrySelectSearchInput');
254
- const countrySelectList = getByTestId('countrySelectList');
255
- const countrySelectItem = getByTestId('countrySelectItem');
256
- ```
257
-
258
- <br>
259
-
260
- ## Accessibility
261
-
262
- Ensure your app is inclusive and usable by everyone by leveraging built-in React Native accessibility features. The accessibility props are covered by this package.
263
-
264
- <br>
265
-
266
- ## Contributing
267
-
268
- Thank you for considering contributing to **react-native-country-select**!
269
-
270
- - Fork or clone this repository
271
-
272
- ```bash
273
- $ git clone https://github.com/AstrOOnauta/react-native-country-select.git
274
- ```
275
-
276
- - Repair, Update and Enjoy ๐Ÿ› ๏ธ๐Ÿšงโš™๏ธ
277
-
278
- - Create a new PR to this repository
279
-
280
- <br>
281
-
282
- ## Credits
283
-
284
- @mledoze for the [countries data](https://github.com/mledoze/countries)
285
-
286
- ## License
287
-
288
- [ISC](LICENSE.md)
289
-
290
- <br>
291
-
292
- <div align = "center">
293
- <br>
294
- Thanks for stopping by! ๐Ÿ˜
295
- <br>
296
- </div>
1
+ <h1 align="center">React Native Country Select</h1>
2
+
3
+ <p>
4
+ ๐ŸŒ A lightweight and customizable country picker for React Native with modern UI, flags, search engine, and i18n support. Includes TypeScript types, offline support and no dependencies.
5
+ </p>
6
+
7
+ <br>
8
+
9
+ <div align="center">
10
+ <a href="https://www.npmjs.com/package/react-native-country-select">
11
+ <img src="https://img.shields.io/npm/v/react-native-country-select.svg?style=flat-square">
12
+ </a>
13
+ <a href="https://www.npmjs.com/package/react-native-country-select">
14
+ <img src="https://img.shields.io/npm/dt/react-native-country-select.svg?style=flat-square&color=success">
15
+ </a>
16
+ <a href="https://github.com/AstrOOnauta/react-native-country-select">
17
+ <img src="https://img.shields.io/github/stars/AstrOOnauta/react-native-country-select?style=flat-square&color=success"/>
18
+ </a>
19
+ <a href="https://github.com/AstrOOnauta/react-native-country-select/issues">
20
+ <img src="https://img.shields.io/github/issues/AstrOOnauta/react-native-country-select?style=flat-square&color=blue"/>
21
+ </a>
22
+ <a href="https://github.com/AstrOOnauta/react-native-country-select/pulls">
23
+ <img src="https://img.shields.io/github/issues-pr/AstrOOnauta/react-native-country-select?style=flat-square&color=blue"/>
24
+ </a>
25
+ <a href="LICENSE.md">
26
+ <img src="https://img.shields.io/:license-isc-yellow.svg?style=flat-square"/>
27
+ </a>
28
+ </div>
29
+
30
+ <br>
31
+
32
+ <div align="center">
33
+ <a href="https://www.buymeacoffee.com/astroonauta" target="_blank">
34
+ <img src="https://survivingmexico.files.wordpress.com/2018/07/button-gif.gif" alt="Buy Me A Coffee" style="height: auto !important;width: 60% !important;">
35
+ </a>
36
+ </div>
37
+
38
+ <br>
39
+
40
+ ## Features
41
+
42
+ - ๐Ÿ“ฑ Cross-platform: works with iOS, Android and Expo;
43
+ - ๐ŸŽจ Lib with custom and modern UI;
44
+ - ๐Ÿ‘จโ€๐Ÿ’ป Functional and class component support;
45
+ - ๐Ÿˆถ 32 languages supported;
46
+ - โ™ฟ Accessibility.
47
+
48
+ <br>
49
+
50
+ ## Try it out
51
+
52
+ - [Demo](https://snack.expo.dev/@astroonauta/react-native-country-select)
53
+
54
+ <br>
55
+
56
+ ## Installation
57
+
58
+ ```sh
59
+ npm install react-native-country-select
60
+ # or
61
+ yarn add react-native-country-select
62
+ ```
63
+
64
+ <br>
65
+
66
+ ## Basic Usage
67
+
68
+ - Class Component
69
+
70
+ ```jsx
71
+ import React, {Component} from 'react';
72
+ import {Text, TouchableOpacity, View} from 'react-native';
73
+ import CountrySelect from 'react-native-country-select';
74
+
75
+ export default class App extends Component {
76
+ countryRef = null;
77
+
78
+ constructor(props) {
79
+ super(props);
80
+ this.state = {
81
+ showPicker: false,
82
+ country: null,
83
+ };
84
+ }
85
+
86
+ handleCountrySelect = country => {
87
+ this.setState({country});
88
+ };
89
+
90
+ render() {
91
+ return (
92
+ <View style={{flex: 1}}>
93
+ <TouchableOpacity onPress={() => this.setState({showPicker: true})}>
94
+ <Text>Select Country</Text>
95
+ </TouchableOpacity>
96
+ <Text>
97
+ Country:{' '}
98
+ {`${this.state.selectedCountry?.name?.common} (${this.state.selectedCountry?.cca2})`}
99
+ </Text>
100
+
101
+ <CountrySelect
102
+ visible={this.state.showPicker}
103
+ onClose={() => this.setState({showPicker: false})}
104
+ onSelect={this.handleCountrySelect}
105
+ />
106
+ </View>
107
+ );
108
+ }
109
+ }
110
+ ```
111
+
112
+ <br>
113
+
114
+ - Function Component
115
+
116
+ ```jsx
117
+ import React, {useState} from 'react';
118
+ import {Text, TouchableOpacity, View} from 'react-native';
119
+
120
+ import CountrySelect from 'react-native-country-select';
121
+
122
+ export default function App() {
123
+ const [showPicker, setShowPicker] = useState(false);
124
+ const [selectedCountry, setSelectedCountry] = useState(null);
125
+
126
+ const handleCountrySelect = country => {
127
+ setSelectedCountry(country);
128
+ };
129
+
130
+ return (
131
+ <View
132
+ style={{
133
+ flex: 1,
134
+ }}>
135
+ <TouchableOpacity onPress={() => setShowPicker(true)}>
136
+ <Text>Select Country</Text>
137
+ </TouchableOpacity>
138
+ <Text>
139
+ Country: {`${selectedCountry?.name?.common} (${selectedCountry?.cca2})`}
140
+ </Text>
141
+
142
+ <CountrySelect
143
+ visible={showPicker}
144
+ onClose={() => setShowPicker(false)}
145
+ onSelect={handleCountrySelect}
146
+ />
147
+ </View>
148
+ );
149
+ }
150
+ ```
151
+
152
+ <br>
153
+
154
+ - Typescript
155
+
156
+ ```tsx
157
+ import React, {useState} from 'react';
158
+ import {Text, TouchableOpacity, View} from 'react-native';
159
+
160
+ import CountrySelect, {ICountry} from 'react-native-country-select';
161
+
162
+ export default function App() {
163
+ const [showPicker, setShowPicker] = useState<boolean>(false);
164
+ const [selectedCountry, setSelectedCountry] = useState<ICountry | null>(null);
165
+
166
+ const handleCountrySelect = (country: ICountry) => {
167
+ setSelectedCountry(country);
168
+ };
169
+
170
+ return (
171
+ <View
172
+ style={{
173
+ flex: 1,
174
+ }}>
175
+ <TouchableOpacity onPress={() => setShowPicker(true)}>
176
+ <Text>Select Country</Text>
177
+ </TouchableOpacity>
178
+ <Text>
179
+ Country: {`${selectedCountry?.name?.common} (${selectedCountry?.cca2})`}
180
+ </Text>
181
+
182
+ <CountrySelect
183
+ visible={showPicker}
184
+ onClose={() => setShowPicker(false)}
185
+ onSelect={handleCountrySelect}
186
+ />
187
+ </View>
188
+ );
189
+ }
190
+ ```
191
+
192
+ <br>
193
+
194
+ ## CountrySelect Props
195
+
196
+ | Prop | Type | Required | Default | Description |
197
+ | ---------------------------- | ------------------------------------- | -------- | ------------------- | ---------------------------------------------------------- |
198
+ | visible | boolean | Yes | false | Controls the visibility of the country picker modal |
199
+ | onClose | () => void | Yes | - | Callback function called when the modal is closed |
200
+ | onSelect | (country: ICountry) => void | Yes | - | Callback function called when a country is selected |
201
+ | popularCountries | string[] | No | [] | Array of country codes to show in popular section |
202
+ | visibleCountries | ICountryCca2[] | No | [] | Array of country codes to show (whitelist) |
203
+ | hiddenCountries | ICountryCca2[] | No | [] | Array of country codes to hide (blacklist) |
204
+ | theme | 'light' \| 'dark' | No | 'light' | Theme for the country picker |
205
+ | language | ICountrySelectLanguages | No | 'eng' | Language for country names (see supported languages below) |
206
+ | disabledBackdropPress | boolean | No | false | Whether to disable backdrop press to close |
207
+ | removedBackdrop | boolean | No | false | Whether to remove the backdrop completely |
208
+ | onBackdropPress | () => void | No | - | Custom callback for backdrop press |
209
+ | countryItemComponent | (item: ICountry) => ReactElement | No | - | Custom component for country items |
210
+ | sectionTitleComponent | (item: ISectionTitle) => ReactElement | No | - | Custom component for section titles |
211
+ | popularCountriesTitle | string | No | 'Popular Countries' | Popular Countries section title |
212
+ | allCountriesTitle | string | No | 'All Countries' | All Countries section title |
213
+ | showsVerticalScrollIndicator | boolean | No | false | displays a horizontal scroll indicator |
214
+
215
+ <br>
216
+
217
+ ### Supported Languages
218
+
219
+ The `language` prop supports the following values:
220
+
221
+ | Code | Language |
222
+ | ---------- | ------------------- |
223
+ | `ara` | Arabic |
224
+ | `bel` | Belarusian |
225
+ | `bre` | Breton |
226
+ | `bul` | Bulgarian |
227
+ | `ces` | Czech |
228
+ | `deu` | German |
229
+ | `ell` | Greek |
230
+ | `eng` | English |
231
+ | `est` | Estonian |
232
+ | `fin` | Finnish |
233
+ | `fra` | French |
234
+ | `heb` | Hebrew |
235
+ | `hrv` | Croatian |
236
+ | `hun` | Hungarian |
237
+ | `ita` | Italian |
238
+ | `jpn` | Japanese |
239
+ | `kor` | Korean |
240
+ | `nld` | Dutch |
241
+ | `per` | Persian |
242
+ | `pol` | Polish |
243
+ | `por` | Portuguese |
244
+ | `ron` | Romanian |
245
+ | `rus` | Russian |
246
+ | `slk` | Slovak |
247
+ | `spa` | Spanish |
248
+ | `srp` | Serbian |
249
+ | `swe` | Swedish |
250
+ | `tur` | Turkish |
251
+ | `ukr` | Ukrainian |
252
+ | `urd` | Urdu |
253
+ | `zho` | Chinese |
254
+ | `zho-Hans` | Simplified Chinese |
255
+ | `zho-Hant` | Traditional Chinese |
256
+
257
+ <br>
258
+
259
+ ## Testing
260
+
261
+ When utilizing this package, you may need to target the CountrySelect component in your automated tests. To facilitate this, we provide a testID props for the CountrySelect component. The testID can be integrated with popular testing libraries such as @testing-library/react-native or Maestro. This enables you to efficiently locate and interact with CountrySelect elements within your tests, ensuring a robust and reliable testing experience.
262
+
263
+ ```js
264
+ const countrySelect = getByTestId('countrySelectSearchInput');
265
+ const countrySelectList = getByTestId('countrySelectList');
266
+ const countrySelectItem = getByTestId('countrySelectItem');
267
+ ```
268
+
269
+ <br>
270
+
271
+ ## Accessibility
272
+
273
+ Ensure your app is inclusive and usable by everyone by leveraging built-in React Native accessibility features. The accessibility props are covered by this package.
274
+
275
+ <br>
276
+
277
+ ## Contributing
278
+
279
+ Thank you for considering contributing to **react-native-country-select**!
280
+
281
+ - Fork or clone this repository
282
+
283
+ ```bash
284
+ $ git clone https://github.com/AstrOOnauta/react-native-country-select.git
285
+ ```
286
+
287
+ - Repair, Update and Enjoy ๐Ÿ› ๏ธ๐Ÿšงโš™๏ธ
288
+
289
+ - Create a new PR to this repository
290
+
291
+ <br>
292
+
293
+ ## Credits
294
+
295
+ @mledoze for the [countries data](https://github.com/mledoze/countries)
296
+
297
+ ## License
298
+
299
+ [ISC](LICENSE.md)
300
+
301
+ <br>
302
+
303
+ <div align = "center">
304
+ <br>
305
+ Thanks for stopping by! ๐Ÿ˜
306
+ <br>
307
+ </div>