react-native-country-select 0.2.2 → 0.2.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.
package/README.md
CHANGED
|
@@ -271,6 +271,7 @@ export default function App() {
|
|
|
271
271
|
| disabledBackdropPress | boolean | No | false | Whether to disable backdrop press to close |
|
|
272
272
|
| removedBackdrop | boolean | No | false | Whether to remove the backdrop completely |
|
|
273
273
|
| onBackdropPress | () => void | No | - | Custom callback for backdrop press |
|
|
274
|
+
| dragHandleIndicatorComponent | () => ReactElement | - | - | Custom component for drag handle indicator on bottom sheet |
|
|
274
275
|
| countryItemComponent | (item: [ICountry](lib/interfaces/country.ts)) => ReactElement | No | - | Custom component for country items |
|
|
275
276
|
| sectionTitleComponent | (item: [ISectionTitle](lib/interfaces/sectionTitle.ts)) => ReactElement | No | - | Custom component for section titles |
|
|
276
277
|
| closeButtonComponent | () => ReactElement | No | - | Custom component for closeButton |
|
|
@@ -61,6 +61,7 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
61
61
|
disabledBackdropPress,
|
|
62
62
|
removedBackdrop,
|
|
63
63
|
onBackdropPress,
|
|
64
|
+
dragHandleIndicatorComponent,
|
|
64
65
|
sectionTitleComponent,
|
|
65
66
|
countryItemComponent,
|
|
66
67
|
closeButtonComponent,
|
|
@@ -70,15 +71,15 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
70
71
|
countryNotFoundMessage,
|
|
71
72
|
...props
|
|
72
73
|
}) => {
|
|
73
|
-
const
|
|
74
|
+
const [modalHeight, setModalHeight] = useState(useWindowDimensions().height);
|
|
74
75
|
const styles = createStyles(theme, modalType, isFullScreen);
|
|
75
76
|
|
|
76
77
|
const [searchQuery, setSearchQuery] = useState('');
|
|
77
78
|
const [isKeyboardVisible, setIsKeyboardVisible] = useState(false);
|
|
78
79
|
const [bottomSheetSize, setBottomSheetSize] = useState({
|
|
79
|
-
minHeight: MIN_HEIGHT_PERCENTAGE *
|
|
80
|
-
maxHeight: MAX_HEIGHT_PERCENTAGE *
|
|
81
|
-
initialHeight: INITIAL_HEIGHT_PERCENTAGE *
|
|
80
|
+
minHeight: MIN_HEIGHT_PERCENTAGE * modalHeight,
|
|
81
|
+
maxHeight: MAX_HEIGHT_PERCENTAGE * modalHeight,
|
|
82
|
+
initialHeight: INITIAL_HEIGHT_PERCENTAGE * modalHeight,
|
|
82
83
|
});
|
|
83
84
|
|
|
84
85
|
const sheetHeight = useRef(
|
|
@@ -93,7 +94,7 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
const DRAG_HANDLE_HEIGHT = 20;
|
|
96
|
-
const availableHeight =
|
|
97
|
+
const availableHeight = modalHeight - DRAG_HANDLE_HEIGHT;
|
|
97
98
|
|
|
98
99
|
const parsedMinHeight = parseHeight(minBottomsheetHeight, availableHeight);
|
|
99
100
|
const parsedMaxHeight = parseHeight(maxBottomsheetHeight, availableHeight);
|
|
@@ -112,7 +113,7 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
112
113
|
minBottomsheetHeight,
|
|
113
114
|
maxBottomsheetHeight,
|
|
114
115
|
initialBottomsheetHeight,
|
|
115
|
-
|
|
116
|
+
modalHeight,
|
|
116
117
|
modalType,
|
|
117
118
|
]);
|
|
118
119
|
|
|
@@ -134,12 +135,10 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
if (isKeyboardVisible) {
|
|
137
|
-
sheetHeight.setValue(
|
|
138
|
-
parseHeight(bottomSheetSize.maxHeight, windowHeight),
|
|
139
|
-
);
|
|
138
|
+
sheetHeight.setValue(parseHeight(bottomSheetSize.maxHeight, modalHeight));
|
|
140
139
|
lastHeight.current = bottomSheetSize.maxHeight;
|
|
141
140
|
} else {
|
|
142
|
-
sheetHeight.setValue(parseHeight(lastHeight.current,
|
|
141
|
+
sheetHeight.setValue(parseHeight(lastHeight.current, modalHeight));
|
|
143
142
|
}
|
|
144
143
|
}, [isKeyboardVisible, modalType]);
|
|
145
144
|
|
|
@@ -572,7 +571,11 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
572
571
|
styles.backdrop,
|
|
573
572
|
countrySelectStyle?.backdrop,
|
|
574
573
|
removedBackdrop && {backgroundColor: 'transparent'},
|
|
575
|
-
]}
|
|
574
|
+
]}
|
|
575
|
+
onLayout={event => {
|
|
576
|
+
const {height} = event.nativeEvent.layout;
|
|
577
|
+
setModalHeight(height);
|
|
578
|
+
}}>
|
|
576
579
|
<Pressable
|
|
577
580
|
testID="countrySelectBackdrop"
|
|
578
581
|
accessibilityRole="button"
|
|
@@ -585,8 +588,22 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
585
588
|
<View
|
|
586
589
|
style={[styles.container, countrySelectStyle?.container]}
|
|
587
590
|
pointerEvents="auto">
|
|
588
|
-
<View
|
|
589
|
-
|
|
591
|
+
<View
|
|
592
|
+
{...handlePanResponder.panHandlers}
|
|
593
|
+
style={[
|
|
594
|
+
styles.dragHandleContainer,
|
|
595
|
+
countrySelectStyle?.dragHandleContainer,
|
|
596
|
+
]}>
|
|
597
|
+
{dragHandleIndicatorComponent ? (
|
|
598
|
+
dragHandleIndicatorComponent()
|
|
599
|
+
) : (
|
|
600
|
+
<View
|
|
601
|
+
style={[
|
|
602
|
+
styles.dragHandleIndicator,
|
|
603
|
+
countrySelectStyle?.dragHandleIndicator,
|
|
604
|
+
]}
|
|
605
|
+
/>
|
|
606
|
+
)}
|
|
590
607
|
</View>
|
|
591
608
|
<Animated.View
|
|
592
609
|
style={[
|
package/lib/components/styles.js
CHANGED
|
@@ -42,7 +42,7 @@ export const createStyles = (theme, modalType, isFullScreen) =>
|
|
|
42
42
|
padding: 16,
|
|
43
43
|
paddingTop: 0,
|
|
44
44
|
},
|
|
45
|
-
|
|
45
|
+
dragHandleContainer: {
|
|
46
46
|
width: '100%',
|
|
47
47
|
height: 24,
|
|
48
48
|
justifyContent: 'center',
|
|
@@ -52,7 +52,7 @@ export const createStyles = (theme, modalType, isFullScreen) =>
|
|
|
52
52
|
borderTopRightRadius: 20,
|
|
53
53
|
marginBottom: -1,
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
dragHandleIndicator: {
|
|
56
56
|
width: 40,
|
|
57
57
|
height: 4,
|
|
58
58
|
backgroundColor: theme === 'dark' ? '#FFFFFF40' : '#00000040',
|
|
@@ -29,6 +29,7 @@ export interface ICountrySelectProps extends ModalProps {
|
|
|
29
29
|
disabledBackdropPress?: boolean;
|
|
30
30
|
removedBackdrop?: boolean;
|
|
31
31
|
onBackdropPress?: () => void;
|
|
32
|
+
dragHandleIndicatorComponent?: () => React.ReactElement;
|
|
32
33
|
countryItemComponent?: (item: ICountry) => React.ReactElement;
|
|
33
34
|
sectionTitleComponent?: (item: ISectionTitle) => React.ReactElement;
|
|
34
35
|
closeButtonComponent?: () => React.ReactElement;
|
|
@@ -4,6 +4,8 @@ export interface ICountrySelectStyle {
|
|
|
4
4
|
backdrop?: StyleProp<ViewStyle>;
|
|
5
5
|
container?: StyleProp<ViewStyle>;
|
|
6
6
|
content?: StyleProp<ViewStyle>;
|
|
7
|
+
dragHandleContainer?: StyleProp<ViewStyle>;
|
|
8
|
+
dragHandleIndicator?: StyleProp<ViewStyle>;
|
|
7
9
|
closeButton?: StyleProp<ViewStyle>;
|
|
8
10
|
closeButtonText?: StyleProp<TextStyle>;
|
|
9
11
|
searchContainer?: StyleProp<ViewStyle>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-country-select",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "🌍 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
5
|
"main": "lib/index.tsx",
|
|
6
6
|
"types": "lib/index.d.ts",
|