react-native-input-select 0.35.0 → 1.1.1
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 +104 -32
- package/lib/commonjs/components/CheckBox/index.js +16 -13
- package/lib/commonjs/components/CheckBox/index.js.map +1 -1
- package/lib/commonjs/components/CheckBox/types.js.map +1 -1
- package/lib/commonjs/components/CustomModal/index.js +1 -9
- package/lib/commonjs/components/CustomModal/index.js.map +1 -1
- package/lib/commonjs/components/Dropdown/Dropdown.js +0 -9
- package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/commonjs/components/Dropdown/{DropdownList.js → DropdownFlatList.js} +22 -32
- package/lib/commonjs/components/Dropdown/DropdownFlatList.js.map +1 -0
- package/lib/commonjs/components/Dropdown/DropdownListItem.js +11 -22
- package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js +139 -0
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js.map +1 -0
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js +10 -22
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/commonjs/components/Input/index.js +4 -11
- package/lib/commonjs/components/Input/index.js.map +1 -1
- package/lib/commonjs/components/Others/index.js +93 -0
- package/lib/commonjs/components/Others/index.js.map +1 -0
- package/lib/commonjs/constants/index.js.map +1 -1
- package/lib/commonjs/index.js +73 -59
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/styles/colors.js.map +1 -1
- package/lib/commonjs/styles/input.js +0 -4
- package/lib/commonjs/styles/input.js.map +1 -1
- package/lib/commonjs/styles/typography.js +0 -3
- package/lib/commonjs/styles/typography.js.map +1 -1
- package/lib/commonjs/types/index.types.js.map +1 -1
- package/lib/commonjs/utils/index.js +26 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/components/CheckBox/index.js +14 -6
- package/lib/module/components/CheckBox/index.js.map +1 -1
- package/lib/module/components/CheckBox/types.js.map +1 -1
- package/lib/module/components/CustomModal/index.js +1 -4
- package/lib/module/components/CustomModal/index.js.map +1 -1
- package/lib/module/components/Dropdown/Dropdown.js +0 -2
- package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/module/components/Dropdown/{DropdownList.js → DropdownFlatList.js} +23 -27
- package/lib/module/components/Dropdown/DropdownFlatList.js.map +1 -0
- package/lib/module/components/Dropdown/DropdownListItem.js +11 -14
- package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSectionList.js +130 -0
- package/lib/module/components/Dropdown/DropdownSectionList.js.map +1 -0
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js +11 -17
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/module/components/Input/index.js +2 -2
- package/lib/module/components/Input/index.js.map +1 -1
- package/lib/module/components/Others/index.js +82 -0
- package/lib/module/components/Others/index.js.map +1 -0
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/index.js +72 -42
- package/lib/module/index.js.map +1 -1
- package/lib/module/styles/colors.js.map +1 -1
- package/lib/module/styles/input.js.map +1 -1
- package/lib/module/styles/typography.js.map +1 -1
- package/lib/module/types/index.types.js.map +1 -1
- package/lib/module/utils/index.js +18 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/components/CheckBox/index.d.ts +6 -1
- package/lib/typescript/components/CheckBox/types.d.ts +6 -1
- package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts +3 -0
- package/lib/typescript/components/Dropdown/DropdownListItem.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts +3 -0
- package/lib/typescript/components/Input/index.d.ts +1 -0
- package/lib/typescript/components/Others/index.d.ts +14 -0
- package/lib/typescript/types/index.types.d.ts +24 -5
- package/lib/typescript/utils/index.d.ts +6 -0
- package/package.json +3 -3
- package/src/components/CheckBox/index.tsx +32 -5
- package/src/components/CheckBox/types.ts +5 -0
- package/src/components/Dropdown/{DropdownList.tsx → DropdownFlatList.tsx} +22 -20
- package/src/components/Dropdown/DropdownListItem.tsx +13 -11
- package/src/components/Dropdown/DropdownSectionList.tsx +135 -0
- package/src/components/Dropdown/DropdownSelectedItemsView.tsx +16 -28
- package/src/components/Input/index.tsx +2 -0
- package/src/components/Others/index.tsx +91 -0
- package/src/index.tsx +114 -41
- package/src/types/index.types.ts +22 -4
- package/src/utils/index.ts +25 -0
- package/lib/commonjs/components/Dropdown/DropdownList.js.map +0 -1
- package/lib/module/components/Dropdown/DropdownList.js.map +0 -1
- package/lib/typescript/components/Dropdown/DropdownList.d.ts +0 -3
|
@@ -5,6 +5,12 @@ import { colors } from '../../styles/colors';
|
|
|
5
5
|
import { CHECKBOX_SIZE } from '../../constants';
|
|
6
6
|
import type { CheckboxProps } from './types';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*`checkboxSize`, `checkboxStyle`,`checkboxLabelStyle` Will be deleted in version 1.0.
|
|
11
|
+
* and replaced with `checkboxComponentStyles`
|
|
12
|
+
*/
|
|
13
|
+
|
|
8
14
|
const CheckBox = ({
|
|
9
15
|
label,
|
|
10
16
|
value,
|
|
@@ -13,17 +19,25 @@ const CheckBox = ({
|
|
|
13
19
|
checkboxSize,
|
|
14
20
|
checkboxStyle,
|
|
15
21
|
checkboxLabelStyle,
|
|
22
|
+
checkboxComponentStyles,
|
|
16
23
|
onChange,
|
|
17
24
|
}: CheckboxProps) => {
|
|
25
|
+
// const { checkboxSize, checkboxStyle, checkboxLabelStyle } =
|
|
26
|
+
// checkboxComponentStyles;
|
|
18
27
|
const fillColor = {
|
|
19
28
|
backgroundColor: disabled
|
|
20
29
|
? '#d3d3d3'
|
|
21
30
|
: value
|
|
22
|
-
? checkboxStyle?.backgroundColor ||
|
|
31
|
+
? checkboxComponentStyles?.checkboxStyle?.backgroundColor ||
|
|
32
|
+
checkboxStyle?.backgroundColor ||
|
|
33
|
+
primaryColor ||
|
|
34
|
+
'green'
|
|
23
35
|
: 'white',
|
|
24
36
|
borderColor: disabled
|
|
25
37
|
? colors.disabled
|
|
26
|
-
: checkboxStyle?.borderColor ||
|
|
38
|
+
: checkboxComponentStyles?.checkboxStyle?.borderColor ||
|
|
39
|
+
checkboxStyle?.borderColor ||
|
|
40
|
+
styles.checkbox.borderColor,
|
|
27
41
|
};
|
|
28
42
|
|
|
29
43
|
return (
|
|
@@ -37,14 +51,27 @@ const CheckBox = ({
|
|
|
37
51
|
source={require('../../asset/check.png')}
|
|
38
52
|
style={[
|
|
39
53
|
{
|
|
40
|
-
height:
|
|
41
|
-
|
|
54
|
+
height:
|
|
55
|
+
checkboxComponentStyles?.checkboxSize ||
|
|
56
|
+
checkboxSize ||
|
|
57
|
+
CHECKBOX_SIZE,
|
|
58
|
+
width:
|
|
59
|
+
checkboxComponentStyles?.checkboxSize ||
|
|
60
|
+
checkboxSize ||
|
|
61
|
+
CHECKBOX_SIZE,
|
|
42
62
|
},
|
|
43
63
|
]}
|
|
44
64
|
/>
|
|
45
65
|
</View>
|
|
46
66
|
{label && (
|
|
47
|
-
<Text
|
|
67
|
+
<Text
|
|
68
|
+
style={[
|
|
69
|
+
checkboxComponentStyles?.checkboxLabelStyle || checkboxLabelStyle,
|
|
70
|
+
styles.labelStyle,
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
{label}
|
|
74
|
+
</Text>
|
|
48
75
|
)}
|
|
49
76
|
</Pressable>
|
|
50
77
|
);
|
|
@@ -8,5 +8,10 @@ export type CheckboxProps = {
|
|
|
8
8
|
checkboxSize?: number;
|
|
9
9
|
checkboxStyle?: ViewStyle;
|
|
10
10
|
checkboxLabelStyle?: TextStyle;
|
|
11
|
+
checkboxComponentStyles?: {
|
|
12
|
+
checkboxSize?: number;
|
|
13
|
+
checkboxStyle?: ViewStyle;
|
|
14
|
+
checkboxLabelStyle?: TextStyle;
|
|
15
|
+
};
|
|
11
16
|
onChange?: (value: boolean | string | number) => void;
|
|
12
17
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable react-native/no-inline-styles */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { FlatList, StyleSheet } from 'react-native';
|
|
4
4
|
import DropdownListItem from './DropdownListItem';
|
|
5
|
-
import {
|
|
5
|
+
import { ItemSeparatorComponent, ListEmptyComponent } from '../Others';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const DropdownFlatList = ({
|
|
8
8
|
options,
|
|
9
9
|
optionLabel,
|
|
10
10
|
optionValue,
|
|
@@ -15,9 +15,11 @@ const DropdownList = ({
|
|
|
15
15
|
handleMultipleSelections,
|
|
16
16
|
handleSingleSelection,
|
|
17
17
|
primaryColor,
|
|
18
|
-
checkboxSize,
|
|
19
|
-
checkboxStyle,
|
|
20
|
-
checkboxLabelStyle,
|
|
18
|
+
checkboxSize, // kept for backwards compatibility to be removed in future release
|
|
19
|
+
checkboxStyle, // kept for backwards compatibility to be removed in future release
|
|
20
|
+
checkboxLabelStyle, // kept for backwards compatibility to be removed in future release
|
|
21
|
+
checkboxComponentStyles,
|
|
22
|
+
listComponentStyles,
|
|
21
23
|
...rest
|
|
22
24
|
}: any) => {
|
|
23
25
|
return (
|
|
@@ -26,14 +28,18 @@ const DropdownList = ({
|
|
|
26
28
|
extraData={isMultiple ? selectedItems : selectedItem}
|
|
27
29
|
initialNumToRender={5}
|
|
28
30
|
ListEmptyComponent={
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
<ListEmptyComponent
|
|
32
|
+
listEmptyComponentStyle={listComponentStyles?.listEmptyComponentStyle}
|
|
33
|
+
/>
|
|
32
34
|
}
|
|
33
35
|
contentContainerStyle={[
|
|
34
36
|
isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,
|
|
35
37
|
]}
|
|
36
|
-
ItemSeparatorComponent={() =>
|
|
38
|
+
ItemSeparatorComponent={() => (
|
|
39
|
+
<ItemSeparatorComponent
|
|
40
|
+
itemSeparatorStyle={listComponentStyles?.itemSeparatorStyle}
|
|
41
|
+
/>
|
|
42
|
+
)}
|
|
37
43
|
renderItem={(item) =>
|
|
38
44
|
_renderItem(item, {
|
|
39
45
|
optionLabel,
|
|
@@ -44,9 +50,10 @@ const DropdownList = ({
|
|
|
44
50
|
? handleMultipleSelections
|
|
45
51
|
: handleSingleSelection,
|
|
46
52
|
primaryColor,
|
|
47
|
-
checkboxSize,
|
|
48
|
-
checkboxStyle,
|
|
49
|
-
checkboxLabelStyle,
|
|
53
|
+
checkboxSize, // kept for backwards compatibility
|
|
54
|
+
checkboxStyle, // kept for backwards compatibility
|
|
55
|
+
checkboxLabelStyle, // kept for backwards compatibility
|
|
56
|
+
checkboxComponentStyles,
|
|
50
57
|
})
|
|
51
58
|
}
|
|
52
59
|
keyExtractor={(_item, index) => `Options${index}`}
|
|
@@ -68,18 +75,13 @@ const _renderItem = ({ item }: any, props: any) => {
|
|
|
68
75
|
checkboxSize={props.checkboxSize}
|
|
69
76
|
checkboxStyle={props.checkboxStyle}
|
|
70
77
|
checkboxLabelStyle={props.checkboxLabelStyle}
|
|
78
|
+
checkboxComponentStyles={props.checkboxComponentStyles}
|
|
71
79
|
/>
|
|
72
80
|
);
|
|
73
81
|
};
|
|
74
82
|
|
|
75
83
|
const styles = StyleSheet.create({
|
|
76
|
-
itemSeparatorStyle: {
|
|
77
|
-
backgroundColor: colors.gray,
|
|
78
|
-
height: 1,
|
|
79
|
-
opacity: 0.15,
|
|
80
|
-
},
|
|
81
|
-
emptyListStyle: { alignItems: 'center', width: '100%', marginVertical: 20 },
|
|
82
84
|
contentContainerStyle: { paddingTop: 20 },
|
|
83
85
|
});
|
|
84
86
|
|
|
85
|
-
export default
|
|
87
|
+
export default DropdownFlatList;
|
|
@@ -13,27 +13,29 @@ const DropdownListItem = ({
|
|
|
13
13
|
checkboxSize,
|
|
14
14
|
checkboxStyle,
|
|
15
15
|
checkboxLabelStyle,
|
|
16
|
+
checkboxComponentStyles,
|
|
16
17
|
}: any) => {
|
|
17
|
-
const selectedOptionValue = optionValue ?? 'value';
|
|
18
18
|
return (
|
|
19
19
|
<TouchableOpacity
|
|
20
|
-
style={styles.
|
|
20
|
+
style={styles.listItemContainerStyle}
|
|
21
21
|
onPress={
|
|
22
|
-
item.disabled ? () => {} : () => onChange(item[
|
|
22
|
+
item.disabled ? () => {} : () => onChange(item[optionValue]) // intentionally didn't use the disable property
|
|
23
23
|
}
|
|
24
24
|
>
|
|
25
25
|
<CheckBox
|
|
26
26
|
value={
|
|
27
27
|
isMultiple
|
|
28
|
-
? selectedOption.includes(item[
|
|
29
|
-
: [selectedOption].includes(item[
|
|
28
|
+
? selectedOption.includes(item[optionValue])
|
|
29
|
+
: [selectedOption].includes(item[optionValue])
|
|
30
30
|
}
|
|
31
|
-
label={item[optionLabel
|
|
32
|
-
onChange={() => onChange(item[
|
|
31
|
+
label={item[optionLabel]}
|
|
32
|
+
onChange={() => onChange(item[optionValue])}
|
|
33
33
|
primaryColor={primaryColor}
|
|
34
|
-
checkboxSize={checkboxSize}
|
|
35
|
-
checkboxStyle={checkboxStyle}
|
|
36
|
-
checkboxLabelStyle={
|
|
34
|
+
checkboxSize={checkboxComponentStyles?.checkboxSize || checkboxSize}
|
|
35
|
+
checkboxStyle={checkboxComponentStyles?.checkboxStyle || checkboxStyle}
|
|
36
|
+
checkboxLabelStyle={
|
|
37
|
+
checkboxComponentStyles?.checkboxLabelStyle || checkboxLabelStyle
|
|
38
|
+
}
|
|
37
39
|
disabled={item.disabled}
|
|
38
40
|
/>
|
|
39
41
|
</TouchableOpacity>
|
|
@@ -41,7 +43,7 @@ const DropdownListItem = ({
|
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
const styles = StyleSheet.create({
|
|
44
|
-
|
|
46
|
+
listItemContainerStyle: {
|
|
45
47
|
paddingHorizontal: 20,
|
|
46
48
|
paddingVertical: 10,
|
|
47
49
|
flexDirection: 'row',
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { SectionList, StyleSheet } from 'react-native';
|
|
4
|
+
import DropdownListItem from './DropdownListItem';
|
|
5
|
+
import {
|
|
6
|
+
ItemSeparatorComponent,
|
|
7
|
+
ListEmptyComponent,
|
|
8
|
+
SectionHeaderTitle,
|
|
9
|
+
} from '../Others';
|
|
10
|
+
import { extractPropertyFromArray } from '../../utils';
|
|
11
|
+
|
|
12
|
+
const DropdownSectionList = ({
|
|
13
|
+
options,
|
|
14
|
+
optionLabel,
|
|
15
|
+
optionValue,
|
|
16
|
+
isMultiple,
|
|
17
|
+
isSearchable,
|
|
18
|
+
selectedItems,
|
|
19
|
+
selectedItem,
|
|
20
|
+
handleMultipleSelections,
|
|
21
|
+
handleSingleSelection,
|
|
22
|
+
primaryColor,
|
|
23
|
+
checkboxSize,
|
|
24
|
+
checkboxStyle,
|
|
25
|
+
checkboxLabelStyle,
|
|
26
|
+
checkboxComponentStyles,
|
|
27
|
+
listComponentStyles,
|
|
28
|
+
...rest
|
|
29
|
+
}: any) => {
|
|
30
|
+
const [expandedSections, setExpandedSections] = useState(new Set());
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Expand all sections
|
|
34
|
+
*/
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
let initialState = new Set(extractPropertyFromArray(options, 'title'));
|
|
37
|
+
setExpandedSections(initialState);
|
|
38
|
+
}, [options]);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param title
|
|
42
|
+
*/
|
|
43
|
+
const handleToggleListExpansion = (title: string) => {
|
|
44
|
+
setExpandedSections((expandedSectionsState) => {
|
|
45
|
+
// Using Set here but you can use an array too
|
|
46
|
+
const next = new Set(expandedSectionsState);
|
|
47
|
+
if (next.has(title)) {
|
|
48
|
+
next.delete(title);
|
|
49
|
+
} else {
|
|
50
|
+
next.add(title);
|
|
51
|
+
}
|
|
52
|
+
return next;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<SectionList
|
|
58
|
+
sections={options}
|
|
59
|
+
extraData={isMultiple ? selectedItems : selectedItem}
|
|
60
|
+
initialNumToRender={5}
|
|
61
|
+
ListEmptyComponent={
|
|
62
|
+
<ListEmptyComponent
|
|
63
|
+
listEmptyComponentStyle={listComponentStyles?.listEmptyComponentStyle}
|
|
64
|
+
/>
|
|
65
|
+
}
|
|
66
|
+
contentContainerStyle={[
|
|
67
|
+
isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,
|
|
68
|
+
]}
|
|
69
|
+
ItemSeparatorComponent={() => (
|
|
70
|
+
<ItemSeparatorComponent
|
|
71
|
+
itemSeparatorStyle={listComponentStyles?.itemSeparatorStyle}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
renderItem={(item) =>
|
|
75
|
+
_renderItem(item, {
|
|
76
|
+
optionLabel,
|
|
77
|
+
optionValue,
|
|
78
|
+
isMultiple,
|
|
79
|
+
selectedOption: isMultiple ? selectedItems : selectedItem,
|
|
80
|
+
onChange: isMultiple
|
|
81
|
+
? handleMultipleSelections
|
|
82
|
+
: handleSingleSelection,
|
|
83
|
+
primaryColor,
|
|
84
|
+
checkboxSize, // kept for backwards compatibility
|
|
85
|
+
checkboxStyle, // kept for backwards compatibility
|
|
86
|
+
checkboxLabelStyle, // kept for backwards compatibility
|
|
87
|
+
checkboxComponentStyles,
|
|
88
|
+
expandedSections,
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
renderSectionHeader={({ section: { title, data } }) =>
|
|
92
|
+
data.length > 0 && (
|
|
93
|
+
<SectionHeaderTitle
|
|
94
|
+
title={title}
|
|
95
|
+
sectionHeaderStyle={listComponentStyles?.sectionHeaderStyle}
|
|
96
|
+
onPress={() => handleToggleListExpansion(title)}
|
|
97
|
+
isExpanded={expandedSections.has(title)}
|
|
98
|
+
/>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
keyExtractor={(_item, index) => `Options${index}`}
|
|
102
|
+
stickySectionHeadersEnabled={false}
|
|
103
|
+
{...rest}
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const _renderItem = ({ section: { title }, item }: any, props: any) => {
|
|
109
|
+
const isExpanded = props?.expandedSections.has(title);
|
|
110
|
+
|
|
111
|
+
//return null if it is not expanded
|
|
112
|
+
if (!isExpanded) return null;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<DropdownListItem
|
|
116
|
+
item={item}
|
|
117
|
+
optionLabel={props.optionLabel}
|
|
118
|
+
optionValue={props.optionValue}
|
|
119
|
+
isMultiple={props.isMultiple}
|
|
120
|
+
selectedOption={props.selectedOption}
|
|
121
|
+
onChange={props.onChange}
|
|
122
|
+
primaryColor={props.primaryColor}
|
|
123
|
+
checkboxSize={props.checkboxSize}
|
|
124
|
+
checkboxStyle={props.checkboxStyle}
|
|
125
|
+
checkboxLabelStyle={props.checkboxLabelStyle}
|
|
126
|
+
checkboxComponentStyles={props.checkboxComponentStyles}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const styles = StyleSheet.create({
|
|
132
|
+
contentContainerStyle: { paddingTop: 20 },
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export default DropdownSectionList;
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
ScrollView,
|
|
7
7
|
StyleSheet,
|
|
8
8
|
Image,
|
|
9
|
-
TouchableOpacity,
|
|
10
9
|
} from 'react-native';
|
|
11
10
|
import { colors } from '../../styles/colors';
|
|
12
11
|
import { inputStyles } from '../../styles/input';
|
|
@@ -59,39 +58,28 @@ const DropdownSelectedItemsView = ({
|
|
|
59
58
|
>
|
|
60
59
|
{isMultiple ? (
|
|
61
60
|
getSelectedItemsLabel()?.map((item: any, i: Number) => (
|
|
62
|
-
<
|
|
63
|
-
onPress={() => handleToggleModal()}
|
|
61
|
+
<Text
|
|
64
62
|
key={`react-native-input-select-${Math.random()}-${i}`}
|
|
65
|
-
|
|
63
|
+
style={[
|
|
64
|
+
styles.selectedItems,
|
|
65
|
+
{ backgroundColor: primaryColor },
|
|
66
|
+
multipleSelectedItemStyle,
|
|
67
|
+
]}
|
|
66
68
|
>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
styles.selectedItems,
|
|
70
|
-
{ backgroundColor: primaryColor },
|
|
71
|
-
multipleSelectedItemStyle,
|
|
72
|
-
]}
|
|
73
|
-
>
|
|
74
|
-
{item}
|
|
75
|
-
</Text>
|
|
76
|
-
</TouchableOpacity>
|
|
69
|
+
{item}
|
|
70
|
+
</Text>
|
|
77
71
|
))
|
|
78
72
|
) : (
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
</
|
|
73
|
+
<Text style={[styles.blackText, selectedItemStyle]}>
|
|
74
|
+
{getSelectedItemsLabel()}
|
|
75
|
+
</Text>
|
|
76
|
+
)}
|
|
77
|
+
{!selectedItem && selectedItems?.length === 0 && (
|
|
78
|
+
<Text style={[styles.blackText, placeholderStyle]}>
|
|
79
|
+
{placeholder ?? 'Select an option'}
|
|
80
|
+
</Text>
|
|
87
81
|
)}
|
|
88
82
|
</View>
|
|
89
|
-
|
|
90
|
-
{!selectedItem && selectedItems?.length === 0 && (
|
|
91
|
-
<Text style={[styles.blackText, placeholderStyle]}>
|
|
92
|
-
{placeholder ?? 'Select an option'}
|
|
93
|
-
</Text>
|
|
94
|
-
)}
|
|
95
83
|
</ScrollView>
|
|
96
84
|
<View style={[styles.iconStyle, dropdownIconStyle]}>
|
|
97
85
|
{dropdownIcon || (
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
TextStyle,
|
|
8
|
+
Image,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { colors } from '../../styles/colors';
|
|
12
|
+
|
|
13
|
+
export const ListEmptyComponent = ({ listEmptyComponentStyle }: any) => {
|
|
14
|
+
return (
|
|
15
|
+
<View style={styles.listEmptyComponentStyle}>
|
|
16
|
+
<Text style={listEmptyComponentStyle}>No options available</Text>
|
|
17
|
+
</View>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ItemSeparatorComponent = ({ itemSeparatorStyle }: any) => {
|
|
22
|
+
return <View style={[styles.itemSeparatorStyle, itemSeparatorStyle]} />;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const ListItemContainer = ({
|
|
26
|
+
children,
|
|
27
|
+
listItemContainerStyle,
|
|
28
|
+
}: {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
listItemContainerStyle: ViewStyle;
|
|
31
|
+
}) => {
|
|
32
|
+
return (
|
|
33
|
+
<View style={[styles.listItemContainerStyle, listItemContainerStyle]}>
|
|
34
|
+
{children}
|
|
35
|
+
</View>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const SectionHeaderTitle = ({
|
|
40
|
+
title,
|
|
41
|
+
sectionHeaderStyle,
|
|
42
|
+
onPress,
|
|
43
|
+
isExpanded,
|
|
44
|
+
}: {
|
|
45
|
+
title: string;
|
|
46
|
+
sectionHeaderStyle?: TextStyle;
|
|
47
|
+
onPress?: () => void;
|
|
48
|
+
isExpanded: Boolean;
|
|
49
|
+
}) => {
|
|
50
|
+
return (
|
|
51
|
+
<TouchableOpacity onPress={onPress}>
|
|
52
|
+
<ListItemContainer listItemContainerStyle={styles.accordionStyle}>
|
|
53
|
+
<Text style={[styles.sectionHeaderStyle, sectionHeaderStyle]}>
|
|
54
|
+
{title}
|
|
55
|
+
</Text>
|
|
56
|
+
<View style={isExpanded ? null : styles.rotatedIcon90}>
|
|
57
|
+
<Image source={require('../../asset/arrow-down.png')} />
|
|
58
|
+
</View>
|
|
59
|
+
</ListItemContainer>
|
|
60
|
+
</TouchableOpacity>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const styles = StyleSheet.create({
|
|
65
|
+
listEmptyComponentStyle: {
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
width: '100%',
|
|
68
|
+
marginVertical: 20,
|
|
69
|
+
},
|
|
70
|
+
itemSeparatorStyle: {
|
|
71
|
+
backgroundColor: colors.gray,
|
|
72
|
+
height: 1,
|
|
73
|
+
opacity: 0.15,
|
|
74
|
+
},
|
|
75
|
+
listItemContainerStyle: {
|
|
76
|
+
paddingHorizontal: 20,
|
|
77
|
+
paddingVertical: 10,
|
|
78
|
+
flexDirection: 'row',
|
|
79
|
+
alignItems: 'center',
|
|
80
|
+
},
|
|
81
|
+
sectionHeaderStyle: { fontWeight: '500' },
|
|
82
|
+
accordionStyle: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
flexWrap: 'nowrap',
|
|
85
|
+
justifyContent: 'space-between',
|
|
86
|
+
alignContent: 'center',
|
|
87
|
+
},
|
|
88
|
+
rotatedIcon90: {
|
|
89
|
+
transform: [{ rotate: '-90deg' }],
|
|
90
|
+
},
|
|
91
|
+
});
|