react-native-country-select 0.3.7 → 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 CHANGED
@@ -361,7 +361,7 @@ export default function App() {
361
361
  | initialBottomsheetHeight | number \| string | No | 50% | Initial height for bottom sheet modal |
362
362
  | disabledBackdropPress | boolean | No | false | Whether to disable backdrop press to close |
363
363
  | removedBackdrop | boolean | No | false | Whether to remove the backdrop completely |
364
- | onBackdropPress | () => void | No | - | Custom callback for backdrop press |
364
+ | onBackdropPress | (closeModal: () => void) => void | No | - | Custom callback for backdrop press |
365
365
  | dragHandleIndicatorComponent | () => ReactElement | - | - | Custom component for drag handle indicator on bottom sheet |
366
366
  | countryItemComponent | (item: [ICountry](lib/interfaces/country.ts)) => ReactElement | No | - | Custom component for country items |
367
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={onBackdropPress || onRequestClose}
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 { View, FlatList, ListRenderItem, Text } from 'react-native';
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 closeButtonComponent();
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={handleCloseModal}
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={handleCloseModal}
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={handleCloseModal}
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={onBackdropPress || onRequestClose}
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={onBackdropPress || onRequestClose}
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.7",
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",