react-native-country-select 0.2.4 → 0.2.5
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 +78 -78
- package/lib/components/styles.js +17 -21
- 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');
|
|
@@ -544,60 +544,62 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
544
544
|
onRequestClose={onClose}
|
|
545
545
|
statusBarTranslucent
|
|
546
546
|
{...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}
|
|
547
|
+
<View
|
|
548
|
+
testID="countrySelectContainer"
|
|
559
549
|
style={[
|
|
560
|
-
styles.
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
550
|
+
styles.container,
|
|
551
|
+
countrySelectStyle?.container,
|
|
552
|
+
isFullScreen && {
|
|
553
|
+
flex: 1,
|
|
554
|
+
width: '100%',
|
|
555
|
+
height: '100%',
|
|
556
|
+
},
|
|
557
|
+
]}>
|
|
558
|
+
<Pressable
|
|
559
|
+
testID="countrySelectBackdrop"
|
|
560
|
+
accessibilityRole="button"
|
|
561
|
+
accessibilityLabel={
|
|
562
|
+
accessibilityLabelBackdrop ||
|
|
563
|
+
translations.accessibilityLabelBackdrop[language]
|
|
564
|
+
}
|
|
565
|
+
accessibilityHint={
|
|
566
|
+
accessibilityHintBackdrop ||
|
|
567
|
+
translations.accessibilityHintBackdrop[language]
|
|
568
|
+
}
|
|
569
|
+
disabled={disabledBackdropPress || removedBackdrop}
|
|
570
|
+
style={[
|
|
571
|
+
styles.backdrop,
|
|
572
|
+
{alignItems: 'center', justifyContent: 'center'},
|
|
573
|
+
countrySelectStyle?.backdrop,
|
|
574
|
+
removedBackdrop && {backgroundColor: 'transparent'},
|
|
575
|
+
]}
|
|
576
|
+
onPress={onBackdropPress || onClose}
|
|
577
|
+
/>
|
|
566
578
|
<View
|
|
579
|
+
testID="countrySelectContent"
|
|
567
580
|
style={[
|
|
568
|
-
styles.
|
|
569
|
-
countrySelectStyle?.
|
|
581
|
+
styles.content,
|
|
582
|
+
countrySelectStyle?.content,
|
|
570
583
|
isFullScreen && {
|
|
571
|
-
|
|
584
|
+
borderRadius: 0,
|
|
572
585
|
width: '100%',
|
|
573
586
|
height: '100%',
|
|
574
587
|
},
|
|
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>
|
|
588
|
+
]}>
|
|
589
|
+
{(isFullScreen || showSearchInput || showCloseButton) && (
|
|
590
|
+
<View
|
|
591
|
+
style={[
|
|
592
|
+
styles.searchContainer,
|
|
593
|
+
countrySelectStyle?.searchContainer,
|
|
594
|
+
]}>
|
|
595
|
+
{(isFullScreen || showCloseButton) && renderCloseButton()}
|
|
596
|
+
{showSearchInput && renderSearchInput()}
|
|
597
|
+
</View>
|
|
598
|
+
)}
|
|
599
|
+
|
|
600
|
+
{renderFlatList()}
|
|
599
601
|
</View>
|
|
600
|
-
</
|
|
602
|
+
</View>
|
|
601
603
|
</Modal>
|
|
602
604
|
);
|
|
603
605
|
}
|
|
@@ -611,11 +613,8 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
611
613
|
statusBarTranslucent
|
|
612
614
|
{...props}>
|
|
613
615
|
<View
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
countrySelectStyle?.backdrop,
|
|
617
|
-
removedBackdrop && {backgroundColor: 'transparent'},
|
|
618
|
-
]}
|
|
616
|
+
testID="countrySelectContainer"
|
|
617
|
+
style={[styles.container, countrySelectStyle?.container]}
|
|
619
618
|
onLayout={event => {
|
|
620
619
|
const {height} = event.nativeEvent.layout;
|
|
621
620
|
setModalHeight(height);
|
|
@@ -632,12 +631,24 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
632
631
|
translations.accessibilityHintBackdrop[language]
|
|
633
632
|
}
|
|
634
633
|
disabled={disabledBackdropPress || removedBackdrop}
|
|
635
|
-
style={
|
|
634
|
+
style={[
|
|
635
|
+
styles.backdrop,
|
|
636
|
+
countrySelectStyle?.backdrop,
|
|
637
|
+
removedBackdrop && {backgroundColor: 'transparent'},
|
|
638
|
+
]}
|
|
636
639
|
onPress={onBackdropPress || onClose}
|
|
637
640
|
/>
|
|
638
|
-
<View
|
|
639
|
-
|
|
640
|
-
|
|
641
|
+
<Animated.View
|
|
642
|
+
testID="countrySelectContent"
|
|
643
|
+
style={[
|
|
644
|
+
styles.content,
|
|
645
|
+
countrySelectStyle?.content,
|
|
646
|
+
{
|
|
647
|
+
height: sheetHeight,
|
|
648
|
+
minHeight: bottomSheetSize.minHeight,
|
|
649
|
+
maxHeight: bottomSheetSize.maxHeight,
|
|
650
|
+
},
|
|
651
|
+
]}>
|
|
641
652
|
<View
|
|
642
653
|
{...handlePanResponder.panHandlers}
|
|
643
654
|
style={[
|
|
@@ -655,30 +666,19 @@ export const CountrySelect: React.FC<ICountrySelectProps> = ({
|
|
|
655
666
|
/>
|
|
656
667
|
)}
|
|
657
668
|
</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
|
-
)}
|
|
669
|
+
{(showSearchInput || showCloseButton) && (
|
|
670
|
+
<View
|
|
671
|
+
style={[
|
|
672
|
+
styles.searchContainer,
|
|
673
|
+
countrySelectStyle?.searchContainer,
|
|
674
|
+
]}>
|
|
675
|
+
{showCloseButton && renderCloseButton()}
|
|
676
|
+
{showSearchInput && renderSearchInput()}
|
|
677
|
+
</View>
|
|
678
|
+
)}
|
|
678
679
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
</View>
|
|
680
|
+
<Animated.View style={{flex: 1}}>{renderFlatList()}</Animated.View>
|
|
681
|
+
</Animated.View>
|
|
682
682
|
</View>
|
|
683
683
|
</Modal>
|
|
684
684
|
);
|
package/lib/components/styles.js
CHANGED
|
@@ -2,41 +2,37 @@ 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
|
-
alignSelf: 'center',
|
|
37
32
|
padding: 16,
|
|
38
33
|
}
|
|
39
34
|
: {
|
|
35
|
+
marginTop: StatusBar.currentHeight,
|
|
40
36
|
width: '100%',
|
|
41
37
|
backgroundColor: theme === 'dark' ? '#202020' : '#FFFFFF',
|
|
42
38
|
padding: 16,
|
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.5",
|
|
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",
|