react-native-country-select 0.3.6 → 0.3.8
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 +11 -7
- package/lib/components/BottomSheetModal/index.tsx +11 -2
- package/lib/components/CountrySelect/index.tsx +32 -5
- package/lib/components/FullscreenModal/index.tsx +11 -2
- package/lib/components/PopupModal/index.tsx +11 -2
- package/lib/interface/countrySelectProps.ts +1 -1
- package/package.json +1 -9
- package/scripts/install-react-native-safe-area-context.js +0 -84
package/README.md
CHANGED
|
@@ -65,12 +65,16 @@
|
|
|
65
65
|
|
|
66
66
|
## Installation
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
To use this library, make sure you have **react-native-country-select** installed along with its required dependency **react-native-safe-area-context**:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm install react-native-country-select react-native-safe-area-context
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Since **react-native-safe-area-context** includes native code, you’ll need to install the iOS pods on macOS to complete the linking:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx pod-install ios
|
|
74
78
|
```
|
|
75
79
|
|
|
76
80
|
<br>
|
|
@@ -357,7 +361,7 @@ export default function App() {
|
|
|
357
361
|
| initialBottomsheetHeight | number \| string | No | 50% | Initial height for bottom sheet modal |
|
|
358
362
|
| disabledBackdropPress | boolean | No | false | Whether to disable backdrop press to close |
|
|
359
363
|
| removedBackdrop | boolean | No | false | Whether to remove the backdrop completely |
|
|
360
|
-
| onBackdropPress | () => void
|
|
364
|
+
| onBackdropPress | (closeModal: () => void) => void | No | - | Custom callback for backdrop press |
|
|
361
365
|
| dragHandleIndicatorComponent | () => ReactElement | - | - | Custom component for drag handle indicator on bottom sheet |
|
|
362
366
|
| countryItemComponent | (item: [ICountry](lib/interfaces/country.ts)) => ReactElement | No | - | Custom component for country items |
|
|
363
367
|
| sectionTitleComponent | (item: [ISectionTitle](lib/interfaces/sectionTitle.ts)) => ReactElement | No | - | Custom component for section titles |
|
|
@@ -24,7 +24,7 @@ interface BottomSheetModalProps extends ModalProps {
|
|
|
24
24
|
statusBarTranslucent?: boolean;
|
|
25
25
|
removedBackdrop?: boolean;
|
|
26
26
|
disabledBackdropPress?: boolean;
|
|
27
|
-
onBackdropPress?: () => void;
|
|
27
|
+
onBackdropPress?: (closeModal: () => void) => void;
|
|
28
28
|
accessibilityLabelBackdrop?: string;
|
|
29
29
|
accessibilityHintBackdrop?: string;
|
|
30
30
|
styles: ICountrySelectStyle;
|
|
@@ -203,7 +203,16 @@ export const BottomSheetModal: React.FC<BottomSheetModalProps> = ({
|
|
|
203
203
|
countrySelectStyle?.backdrop,
|
|
204
204
|
removedBackdrop && { backgroundColor: 'transparent' },
|
|
205
205
|
]}
|
|
206
|
-
onPress={
|
|
206
|
+
onPress={
|
|
207
|
+
onBackdropPress
|
|
208
|
+
? () =>
|
|
209
|
+
onBackdropPress(() =>
|
|
210
|
+
onRequestClose(
|
|
211
|
+
{} as NativeSyntheticEvent<any>
|
|
212
|
+
)
|
|
213
|
+
)
|
|
214
|
+
: onRequestClose
|
|
215
|
+
}
|
|
207
216
|
/>
|
|
208
217
|
<Animated.View
|
|
209
218
|
testID="countrySelectContent"
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
/* eslint-disable react-native/no-inline-styles */
|
|
2
2
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
3
|
import React, { useCallback, useMemo, useState, useRef } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
View,
|
|
6
|
+
FlatList,
|
|
7
|
+
ListRenderItem,
|
|
8
|
+
Text,
|
|
9
|
+
TouchableOpacity,
|
|
10
|
+
NativeSyntheticEvent,
|
|
11
|
+
} from 'react-native';
|
|
5
12
|
|
|
6
13
|
import { PopupModal } from '../PopupModal';
|
|
7
14
|
import { CountryItem } from '../CountryItem';
|
|
@@ -47,6 +54,7 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
47
54
|
disabledBackdropPress,
|
|
48
55
|
removedBackdrop,
|
|
49
56
|
onBackdropPress,
|
|
57
|
+
onRequestClose,
|
|
50
58
|
dragHandleIndicatorComponent,
|
|
51
59
|
sectionTitleComponent,
|
|
52
60
|
countryItemComponent,
|
|
@@ -213,7 +221,11 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
213
221
|
|
|
214
222
|
const renderCloseButton = () => {
|
|
215
223
|
if (closeButtonComponent) {
|
|
216
|
-
return
|
|
224
|
+
return (
|
|
225
|
+
<TouchableOpacity onPress={handleCloseModal}>
|
|
226
|
+
{closeButtonComponent()}
|
|
227
|
+
</TouchableOpacity>
|
|
228
|
+
);
|
|
217
229
|
}
|
|
218
230
|
return (
|
|
219
231
|
<CloseButton
|
|
@@ -452,7 +464,12 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
452
464
|
return (
|
|
453
465
|
<FullscreenModal
|
|
454
466
|
visible={visible}
|
|
455
|
-
onRequestClose={
|
|
467
|
+
onRequestClose={() => {
|
|
468
|
+
handleCloseModal();
|
|
469
|
+
if (onRequestClose) {
|
|
470
|
+
onRequestClose({} as NativeSyntheticEvent<any>);
|
|
471
|
+
}
|
|
472
|
+
}}
|
|
456
473
|
statusBarTranslucent
|
|
457
474
|
removedBackdrop={removedBackdrop}
|
|
458
475
|
disabledBackdropPress={disabledBackdropPress}
|
|
@@ -478,7 +495,12 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
478
495
|
return (
|
|
479
496
|
<PopupModal
|
|
480
497
|
visible={visible}
|
|
481
|
-
onRequestClose={
|
|
498
|
+
onRequestClose={() => {
|
|
499
|
+
handleCloseModal();
|
|
500
|
+
if (onRequestClose) {
|
|
501
|
+
onRequestClose({} as NativeSyntheticEvent<any>);
|
|
502
|
+
}
|
|
503
|
+
}}
|
|
482
504
|
statusBarTranslucent
|
|
483
505
|
removedBackdrop={removedBackdrop}
|
|
484
506
|
disabledBackdropPress={disabledBackdropPress}
|
|
@@ -504,7 +526,12 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
504
526
|
return (
|
|
505
527
|
<BottomSheetModal
|
|
506
528
|
visible={visible}
|
|
507
|
-
onRequestClose={
|
|
529
|
+
onRequestClose={() => {
|
|
530
|
+
handleCloseModal();
|
|
531
|
+
if (onRequestClose) {
|
|
532
|
+
onRequestClose({} as NativeSyntheticEvent<any>);
|
|
533
|
+
}
|
|
534
|
+
}}
|
|
508
535
|
statusBarTranslucent
|
|
509
536
|
removedBackdrop={removedBackdrop}
|
|
510
537
|
disabledBackdropPress={disabledBackdropPress}
|
|
@@ -20,7 +20,7 @@ interface FullscreenModalProps extends ModalProps {
|
|
|
20
20
|
statusBarTranslucent?: boolean;
|
|
21
21
|
removedBackdrop?: boolean;
|
|
22
22
|
disabledBackdropPress?: boolean;
|
|
23
|
-
onBackdropPress?: () => void;
|
|
23
|
+
onBackdropPress?: (closeModal: () => void) => void;
|
|
24
24
|
accessibilityLabelBackdrop?: string;
|
|
25
25
|
accessibilityHintBackdrop?: string;
|
|
26
26
|
styles: ICountrySelectStyle;
|
|
@@ -75,7 +75,16 @@ export const FullscreenModal: React.FC<FullscreenModalProps> = ({
|
|
|
75
75
|
countrySelectStyle?.backdrop,
|
|
76
76
|
removedBackdrop && { backgroundColor: 'transparent' },
|
|
77
77
|
]}
|
|
78
|
-
onPress={
|
|
78
|
+
onPress={
|
|
79
|
+
onBackdropPress
|
|
80
|
+
? () =>
|
|
81
|
+
onBackdropPress(() =>
|
|
82
|
+
onRequestClose(
|
|
83
|
+
{} as NativeSyntheticEvent<any>
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
: onRequestClose
|
|
87
|
+
}
|
|
79
88
|
/>
|
|
80
89
|
<View
|
|
81
90
|
testID="countrySelectContent"
|
|
@@ -20,7 +20,7 @@ interface PopupModalProps extends ModalProps {
|
|
|
20
20
|
statusBarTranslucent?: boolean;
|
|
21
21
|
removedBackdrop?: boolean;
|
|
22
22
|
disabledBackdropPress?: boolean;
|
|
23
|
-
onBackdropPress?: () => void;
|
|
23
|
+
onBackdropPress?: (closeModal: () => void) => void;
|
|
24
24
|
accessibilityLabelBackdrop?: string;
|
|
25
25
|
accessibilityHintBackdrop?: string;
|
|
26
26
|
styles: ICountrySelectStyle;
|
|
@@ -71,7 +71,16 @@ export const PopupModal: React.FC<PopupModalProps> = ({
|
|
|
71
71
|
countrySelectStyle?.backdrop,
|
|
72
72
|
removedBackdrop && { backgroundColor: 'transparent' },
|
|
73
73
|
]}
|
|
74
|
-
onPress={
|
|
74
|
+
onPress={
|
|
75
|
+
onBackdropPress
|
|
76
|
+
? () =>
|
|
77
|
+
onBackdropPress(() =>
|
|
78
|
+
onRequestClose(
|
|
79
|
+
{} as NativeSyntheticEvent<any>
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
: onRequestClose
|
|
83
|
+
}
|
|
75
84
|
/>
|
|
76
85
|
<View
|
|
77
86
|
testID="countrySelectContent"
|
|
@@ -29,7 +29,7 @@ interface ICountrySelectBaseProps extends ModalProps, IThemeProps {
|
|
|
29
29
|
initialBottomsheetHeight?: number | string;
|
|
30
30
|
disabledBackdropPress?: boolean;
|
|
31
31
|
removedBackdrop?: boolean;
|
|
32
|
-
onBackdropPress?: () => void;
|
|
32
|
+
onBackdropPress?: (closeModal: () => void) => void;
|
|
33
33
|
dragHandleIndicatorComponent?: () => React.ReactElement;
|
|
34
34
|
countryItemComponent?: (item: ICountry) => React.ReactElement;
|
|
35
35
|
sectionTitleComponent?: (item: ISectionTitle) => React.ReactElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-country-select",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "🌍 React Native country picker with flags, search, TypeScript, i18n, and offline support. Lightweight, customizable, and designed with a modern UI.",
|
|
5
5
|
"main": "lib/index.tsx",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -26,9 +26,6 @@
|
|
|
26
26
|
"react native country picker",
|
|
27
27
|
"react native country select"
|
|
28
28
|
],
|
|
29
|
-
"scripts": {
|
|
30
|
-
"postinstall": "node scripts/install-react-native-safe-area-context.js"
|
|
31
|
-
},
|
|
32
29
|
"repository": {
|
|
33
30
|
"type": "git",
|
|
34
31
|
"url": "git+https://github.com/AstrOOnauta/react-native-country-select.git"
|
|
@@ -46,10 +43,5 @@
|
|
|
46
43
|
"react": "*",
|
|
47
44
|
"react-native": "*",
|
|
48
45
|
"react-native-safe-area-context": ">=4.0.0"
|
|
49
|
-
},
|
|
50
|
-
"peerDependenciesMeta": {
|
|
51
|
-
"react-native-safe-area-context": {
|
|
52
|
-
"optional": false
|
|
53
|
-
}
|
|
54
46
|
}
|
|
55
47
|
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
const { execSync } = require('child_process');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
// Navigate to the project root directory (outside node_modules)
|
|
6
|
-
function findProjectRoot() {
|
|
7
|
-
let current = process.cwd();
|
|
8
|
-
|
|
9
|
-
// If we're inside node_modules, go up until we're out
|
|
10
|
-
while (current.includes('node_modules')) {
|
|
11
|
-
current = path.dirname(current);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Look for the project's package.json
|
|
15
|
-
while (!fs.existsSync(path.join(current, 'package.json'))) {
|
|
16
|
-
const next = path.dirname(current);
|
|
17
|
-
if (next === current) break;
|
|
18
|
-
current = next;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return current;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const root = findProjectRoot();
|
|
25
|
-
process.chdir(root);
|
|
26
|
-
|
|
27
|
-
// Check if react-native-safe-area-context is already installed
|
|
28
|
-
function isPackageInstalled() {
|
|
29
|
-
const packagePath = path.join(
|
|
30
|
-
root,
|
|
31
|
-
'node_modules',
|
|
32
|
-
'react-native-safe-area-context'
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
if (fs.existsSync(packagePath)) {
|
|
36
|
-
console.log(
|
|
37
|
-
'✅ react-native-safe-area-context is already installed!\n'
|
|
38
|
-
);
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// If already installed, do nothing
|
|
46
|
-
if (isPackageInstalled()) {
|
|
47
|
-
process.exit(0);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function detectPackageManager() {
|
|
51
|
-
if (fs.existsSync(path.join(root, 'bun.lockb'))) return 'bun';
|
|
52
|
-
if (fs.existsSync(path.join(root, 'pnpm-lock.yaml'))) return 'pnpm';
|
|
53
|
-
if (fs.existsSync(path.join(root, 'yarn.lock'))) return 'yarn';
|
|
54
|
-
return 'npm';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const pm = detectPackageManager();
|
|
58
|
-
|
|
59
|
-
const commands = {
|
|
60
|
-
npm: 'npm install react-native-safe-area-context@latest --save',
|
|
61
|
-
yarn: 'yarn add react-native-safe-area-context@latest',
|
|
62
|
-
pnpm: 'pnpm add react-native-safe-area-context@latest',
|
|
63
|
-
bun: 'bun add react-native-safe-area-context@latest',
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const command = commands[pm] || commands.npm;
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
console.log(`\n🔧 Detected package manager: ${pm}`);
|
|
70
|
-
console.log(`📦 Installing react-native-safe-area-context using:`);
|
|
71
|
-
console.log(`➡️ ${command}\n`);
|
|
72
|
-
|
|
73
|
-
execSync(command, { stdio: 'inherit' });
|
|
74
|
-
|
|
75
|
-
console.log(
|
|
76
|
-
`\n✅ react-native-safe-area-context installed successfully!\n`
|
|
77
|
-
);
|
|
78
|
-
} catch (err) {
|
|
79
|
-
console.error(
|
|
80
|
-
'\n⚠️ Could not automatically install react-native-safe-area-context'
|
|
81
|
-
);
|
|
82
|
-
console.error('Please install it manually by running:\n');
|
|
83
|
-
console.error(` ${command}\n`);
|
|
84
|
-
}
|