react-native-country-select 0.2.4 → 0.2.6
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 +28 -2
- package/lib/components/CountrySelect/index.tsx +79 -78
- package/lib/components/styles.js +23 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -246,7 +246,32 @@ export default function App() {
|
|
|
246
246
|
|
|
247
247
|
<br>
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
### Modal Styles ([modalStyles](https://github.com/AstrOOnauta/react-native-country-select/blob/main/lib/interface/countrySelectStyles.ts))
|
|
250
|
+
|
|
251
|
+
| Property | Type | Description |
|
|
252
|
+
| -------------------------- | --------- | ------------------------- |
|
|
253
|
+
| `backdrop` | ViewStyle | Modal background overlay |
|
|
254
|
+
| `container` | ViewStyle | Modal main container |
|
|
255
|
+
| `content` | ViewStyle | Modal content area |
|
|
256
|
+
| `dragHandleContainer` | ViewStyle | Drag Handle area |
|
|
257
|
+
| `dragHandleIndicator` | ViewStyle | Drag Handle Indicator |
|
|
258
|
+
| `searchContainer` | ViewStyle | Search input wrapper |
|
|
259
|
+
| `searchInput` | TextStyle | Search input field |
|
|
260
|
+
| `list` | ViewStyle | Countries list container |
|
|
261
|
+
| `countryItem` | ViewStyle | Individual country row |
|
|
262
|
+
| `flag` | TextStyle | Country flag in list |
|
|
263
|
+
| `countryInfo` | ViewStyle | Country details container |
|
|
264
|
+
| `callingCode` | TextStyle | Calling code in list |
|
|
265
|
+
| `countryName` | TextStyle | Country name in list |
|
|
266
|
+
| `sectionTitle` | TextStyle | Section headers |
|
|
267
|
+
| `closeButton` | ViewStyle | Close button container |
|
|
268
|
+
| `closeButtonText` | TextStyle | Close button text |
|
|
269
|
+
| `countryNotFoundContainer` | ViewStyle | No results container |
|
|
270
|
+
| `countryNotFoundMessage` | TextStyle | No results message |
|
|
271
|
+
|
|
272
|
+
<br>
|
|
273
|
+
|
|
274
|
+
## CountrySelect Props ([countrySelectProps](https://github.com/AstrOOnauta/react-native-country-select/blob/main/lib/interface/countrySelectProps.ts))
|
|
250
275
|
|
|
251
276
|
| Prop | Type | Required | Default | Description |
|
|
252
277
|
| ---------------------------- | ----------------------------------------------------------------------- | -------- | -------------------- | ---------------------------------------------------------------- |
|
|
@@ -330,7 +355,8 @@ The `language` prop supports the following values:
|
|
|
330
355
|
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.
|
|
331
356
|
|
|
332
357
|
```js
|
|
333
|
-
const
|
|
358
|
+
const countrySelectModalContainer = getByTestId('countrySelectContainer');
|
|
359
|
+
const countrySelectModalContent = getByTestId('countrySelectContent');
|
|
334
360
|
const countrySelectBackdrop = getByTestId('countrySelectBackdrop');
|
|
335
361
|
const countrySelectList = getByTestId('countrySelectList');
|
|
336
362
|
const countrySelectSearchInput = getByTestId('countrySelectSearchInput');
|
|
@@ -478,6 +478,7 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
478
478
|
getItemLayout={getItemLayout}
|
|
479
479
|
keyboardShouldPersistTaps="handled"
|
|
480
480
|
showsVerticalScrollIndicator={showsVerticalScrollIndicator || false}
|
|
481
|
+
style={[styles.list, countrySelectStyle?.list]}
|
|
481
482
|
/>
|
|
482
483
|
);
|
|
483
484
|
};
|
|
@@ -544,60 +545,62 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
544
545
|
onRequestClose={onClose}
|
|
545
546
|
statusBarTranslucent
|
|
546
547
|
{...props}>
|
|
547
|
-
<
|
|
548
|
-
testID="
|
|
549
|
-
accessibilityRole="button"
|
|
550
|
-
accessibilityLabel={
|
|
551
|
-
accessibilityLabelBackdrop ||
|
|
552
|
-
translations.accessibilityLabelBackdrop[language]
|
|
553
|
-
}
|
|
554
|
-
accessibilityHint={
|
|
555
|
-
accessibilityHintBackdrop ||
|
|
556
|
-
translations.accessibilityHintBackdrop[language]
|
|
557
|
-
}
|
|
558
|
-
disabled={disabledBackdropPress || removedBackdrop}
|
|
548
|
+
<View
|
|
549
|
+
testID="countrySelectContainer"
|
|
559
550
|
style={[
|
|
560
|
-
styles.
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
551
|
+
styles.container,
|
|
552
|
+
countrySelectStyle?.container,
|
|
553
|
+
isFullScreen && {
|
|
554
|
+
flex: 1,
|
|
555
|
+
width: '100%',
|
|
556
|
+
height: '100%',
|
|
557
|
+
},
|
|
558
|
+
]}>
|
|
559
|
+
<Pressable
|
|
560
|
+
testID="countrySelectBackdrop"
|
|
561
|
+
accessibilityRole="button"
|
|
562
|
+
accessibilityLabel={
|
|
563
|
+
accessibilityLabelBackdrop ||
|
|
564
|
+
translations.accessibilityLabelBackdrop[language]
|
|
565
|
+
}
|
|
566
|
+
accessibilityHint={
|
|
567
|
+
accessibilityHintBackdrop ||
|
|
568
|
+
translations.accessibilityHintBackdrop[language]
|
|
569
|
+
}
|
|
570
|
+
disabled={disabledBackdropPress || removedBackdrop}
|
|
571
|
+
style={[
|
|
572
|
+
styles.backdrop,
|
|
573
|
+
{alignItems: 'center', justifyContent: 'center'},
|
|
574
|
+
countrySelectStyle?.backdrop,
|
|
575
|
+
removedBackdrop && {backgroundColor: 'transparent'},
|
|
576
|
+
]}
|
|
577
|
+
onPress={onBackdropPress || onClose}
|
|
578
|
+
/>
|
|
566
579
|
<View
|
|
580
|
+
testID="countrySelectContent"
|
|
567
581
|
style={[
|
|
568
|
-
styles.
|
|
569
|
-
countrySelectStyle?.
|
|
582
|
+
styles.content,
|
|
583
|
+
countrySelectStyle?.content,
|
|
570
584
|
isFullScreen && {
|
|
571
|
-
|
|
585
|
+
borderRadius: 0,
|
|
572
586
|
width: '100%',
|
|
573
587
|
height: '100%',
|
|
574
588
|
},
|
|
575
|
-
]}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
isFullScreen &&
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
style={[
|
|
589
|
-
styles.searchContainer,
|
|
590
|
-
countrySelectStyle?.searchContainer,
|
|
591
|
-
]}>
|
|
592
|
-
{(isFullScreen || showCloseButton) && renderCloseButton()}
|
|
593
|
-
{showSearchInput && renderSearchInput()}
|
|
594
|
-
</View>
|
|
595
|
-
)}
|
|
596
|
-
|
|
597
|
-
{renderFlatList()}
|
|
598
|
-
</View>
|
|
589
|
+
]}>
|
|
590
|
+
{(isFullScreen || showSearchInput || showCloseButton) && (
|
|
591
|
+
<View
|
|
592
|
+
style={[
|
|
593
|
+
styles.searchContainer,
|
|
594
|
+
countrySelectStyle?.searchContainer,
|
|
595
|
+
]}>
|
|
596
|
+
{(isFullScreen || showCloseButton) && renderCloseButton()}
|
|
597
|
+
{showSearchInput && renderSearchInput()}
|
|
598
|
+
</View>
|
|
599
|
+
)}
|
|
600
|
+
|
|
601
|
+
{renderFlatList()}
|
|
599
602
|
</View>
|
|
600
|
-
</
|
|
603
|
+
</View>
|
|
601
604
|
</Modal>
|
|
602
605
|
);
|
|
603
606
|
}
|
|
@@ -611,11 +614,8 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
611
614
|
statusBarTranslucent
|
|
612
615
|
{...props}>
|
|
613
616
|
<View
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
countrySelectStyle?.backdrop,
|
|
617
|
-
removedBackdrop && {backgroundColor: 'transparent'},
|
|
618
|
-
]}
|
|
617
|
+
testID="countrySelectContainer"
|
|
618
|
+
style={[styles.container, countrySelectStyle?.container]}
|
|
619
619
|
onLayout={event => {
|
|
620
620
|
const {height} = event.nativeEvent.layout;
|
|
621
621
|
setModalHeight(height);
|
|
@@ -632,12 +632,24 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
632
632
|
translations.accessibilityHintBackdrop[language]
|
|
633
633
|
}
|
|
634
634
|
disabled={disabledBackdropPress || removedBackdrop}
|
|
635
|
-
style={
|
|
635
|
+
style={[
|
|
636
|
+
styles.backdrop,
|
|
637
|
+
countrySelectStyle?.backdrop,
|
|
638
|
+
removedBackdrop && {backgroundColor: 'transparent'},
|
|
639
|
+
]}
|
|
636
640
|
onPress={onBackdropPress || onClose}
|
|
637
641
|
/>
|
|
638
|
-
<View
|
|
639
|
-
|
|
640
|
-
|
|
642
|
+
<Animated.View
|
|
643
|
+
testID="countrySelectContent"
|
|
644
|
+
style={[
|
|
645
|
+
styles.content,
|
|
646
|
+
countrySelectStyle?.content,
|
|
647
|
+
{
|
|
648
|
+
height: sheetHeight,
|
|
649
|
+
minHeight: bottomSheetSize.minHeight,
|
|
650
|
+
maxHeight: bottomSheetSize.maxHeight,
|
|
651
|
+
},
|
|
652
|
+
]}>
|
|
641
653
|
<View
|
|
642
654
|
{...handlePanResponder.panHandlers}
|
|
643
655
|
style={[
|
|
@@ -655,30 +667,19 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
655
667
|
/>
|
|
656
668
|
)}
|
|
657
669
|
</View>
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
{(showSearchInput || showCloseButton) && (
|
|
669
|
-
<View
|
|
670
|
-
style={[
|
|
671
|
-
styles.searchContainer,
|
|
672
|
-
countrySelectStyle?.searchContainer,
|
|
673
|
-
]}>
|
|
674
|
-
{showCloseButton && renderCloseButton()}
|
|
675
|
-
{showSearchInput && renderSearchInput()}
|
|
676
|
-
</View>
|
|
677
|
-
)}
|
|
670
|
+
{(showSearchInput || showCloseButton) && (
|
|
671
|
+
<View
|
|
672
|
+
style={[
|
|
673
|
+
styles.searchContainer,
|
|
674
|
+
countrySelectStyle?.searchContainer,
|
|
675
|
+
]}>
|
|
676
|
+
{showCloseButton && renderCloseButton()}
|
|
677
|
+
{showSearchInput && renderSearchInput()}
|
|
678
|
+
</View>
|
|
679
|
+
)}
|
|
678
680
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
</View>
|
|
681
|
+
<Animated.View style={{flex: 1}}>{renderFlatList()}</Animated.View>
|
|
682
|
+
</Animated.View>
|
|
682
683
|
</View>
|
|
683
684
|
</Modal>
|
|
684
685
|
);
|
package/lib/components/styles.js
CHANGED
|
@@ -2,55 +2,48 @@ import {Platform, StatusBar, StyleSheet} from 'react-native';
|
|
|
2
2
|
|
|
3
3
|
export const createStyles = (theme, modalType, isFullScreen) =>
|
|
4
4
|
StyleSheet.create({
|
|
5
|
-
|
|
5
|
+
container: {
|
|
6
6
|
flex: 1,
|
|
7
|
+
width: '100%',
|
|
8
|
+
height: '100%',
|
|
9
|
+
backgroundColor: 'transparent',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent:
|
|
12
|
+
modalType === 'popup' || isFullScreen ? 'center' : 'flex-end',
|
|
13
|
+
},
|
|
14
|
+
backdrop: {
|
|
15
|
+
width: '100%',
|
|
16
|
+
height: '100%',
|
|
7
17
|
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
bottom: 0,
|
|
20
|
+
left: 0,
|
|
21
|
+
alignItems: 'center',
|
|
8
22
|
},
|
|
9
|
-
|
|
23
|
+
content:
|
|
10
24
|
modalType === 'popup' || isFullScreen
|
|
11
25
|
? {
|
|
12
26
|
marginTop: StatusBar.currentHeight,
|
|
13
27
|
width: '90%',
|
|
14
28
|
maxWidth: 600,
|
|
15
29
|
height: '60%',
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
justifyContent: 'center',
|
|
18
|
-
alignSelf: 'center',
|
|
19
|
-
}
|
|
20
|
-
: {
|
|
21
|
-
marginTop: StatusBar.currentHeight,
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
bottom: 0,
|
|
24
|
-
left: 0,
|
|
25
|
-
right: 0,
|
|
26
|
-
width: '100%',
|
|
27
|
-
alignItems: 'center',
|
|
28
|
-
},
|
|
29
|
-
content:
|
|
30
|
-
modalType === 'popup' || isFullScreen
|
|
31
|
-
? {
|
|
32
|
-
flex: 1,
|
|
33
|
-
width: '100%',
|
|
34
30
|
backgroundColor: theme === 'dark' ? '#202020' : '#FFFFFF',
|
|
35
31
|
borderRadius: 20,
|
|
36
|
-
|
|
37
|
-
padding: 16,
|
|
32
|
+
paddingVertical: 16,
|
|
38
33
|
}
|
|
39
34
|
: {
|
|
35
|
+
marginTop: StatusBar.currentHeight,
|
|
40
36
|
width: '100%',
|
|
37
|
+
borderRadius: 20,
|
|
41
38
|
backgroundColor: theme === 'dark' ? '#202020' : '#FFFFFF',
|
|
42
|
-
padding: 16,
|
|
43
|
-
paddingTop: 0,
|
|
44
39
|
},
|
|
45
40
|
dragHandleContainer: {
|
|
46
41
|
width: '100%',
|
|
47
42
|
height: 24,
|
|
48
43
|
justifyContent: 'center',
|
|
49
44
|
alignItems: 'center',
|
|
50
|
-
backgroundColor: theme === 'dark' ? '#202020' : '#FFFFFF',
|
|
51
45
|
borderTopLeftRadius: 20,
|
|
52
46
|
borderTopRightRadius: 20,
|
|
53
|
-
marginBottom: -1,
|
|
54
47
|
},
|
|
55
48
|
dragHandleIndicator: {
|
|
56
49
|
width: 40,
|
|
@@ -59,8 +52,8 @@ export const createStyles = (theme, modalType, isFullScreen) =>
|
|
|
59
52
|
borderRadius: 2,
|
|
60
53
|
},
|
|
61
54
|
searchContainer: {
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
paddingVertical: 8,
|
|
56
|
+
paddingHorizontal: 16,
|
|
64
57
|
flexDirection: 'row',
|
|
65
58
|
},
|
|
66
59
|
searchInput: {
|
|
@@ -75,6 +68,8 @@ export const createStyles = (theme, modalType, isFullScreen) =>
|
|
|
75
68
|
},
|
|
76
69
|
list: {
|
|
77
70
|
flex: 1,
|
|
71
|
+
padding: 16,
|
|
72
|
+
paddingTop: 0,
|
|
78
73
|
},
|
|
79
74
|
countryItem: {
|
|
80
75
|
flex: 1,
|
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.6",
|
|
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",
|