react-native-input-select 0.24.0 → 0.26.0
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 +9 -7
- package/lib/commonjs/components/CheckBox/index.js +6 -2
- package/lib/commonjs/components/CheckBox/index.js.map +1 -1
- package/lib/commonjs/components/CheckBox/types.js.map +1 -1
- package/lib/commonjs/components/Dropdown/Dropdown.js +3 -1
- package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownList.js +12 -3
- package/lib/commonjs/components/Dropdown/DropdownList.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownListItem.js +3 -2
- package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js +2 -1
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/commonjs/index.js +27 -22
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/styles/colors.js +2 -1
- package/lib/commonjs/styles/colors.js.map +1 -1
- package/lib/commonjs/types/index.types.js.map +1 -1
- package/lib/module/components/CheckBox/index.js +6 -2
- package/lib/module/components/CheckBox/index.js.map +1 -1
- package/lib/module/components/CheckBox/types.js.map +1 -1
- package/lib/module/components/Dropdown/Dropdown.js +3 -1
- package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownList.js +13 -3
- package/lib/module/components/Dropdown/DropdownList.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownListItem.js +3 -2
- package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js +2 -1
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/module/index.js +27 -22
- package/lib/module/index.js.map +1 -1
- package/lib/module/styles/colors.js +2 -1
- package/lib/module/styles/colors.js.map +1 -1
- package/lib/module/types/index.types.js.map +1 -1
- package/lib/typescript/components/CheckBox/index.d.ts +1 -1
- package/lib/typescript/components/CheckBox/types.d.ts +1 -0
- package/lib/typescript/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownList.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/types/index.types.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/CheckBox/index.tsx +8 -1
- package/src/components/CheckBox/types.ts +1 -0
- package/src/components/Dropdown/Dropdown.tsx +2 -0
- package/src/components/Dropdown/DropdownList.tsx +8 -0
- package/src/components/Dropdown/DropdownListItem.tsx +4 -1
- package/src/components/Dropdown/DropdownSelectedItemsView.tsx +2 -1
- package/src/index.tsx +34 -27
- package/src/styles/colors.ts +1 -0
- package/src/types/index.types.ts +1 -0
|
@@ -18,6 +18,7 @@ const Dropdown = ({
|
|
|
18
18
|
dropdownStyle,
|
|
19
19
|
dropdownContainerStyle,
|
|
20
20
|
selectedItemStyle,
|
|
21
|
+
placeholderStyle,
|
|
21
22
|
multipleSelectedItemStyle,
|
|
22
23
|
dropdownErrorStyle,
|
|
23
24
|
dropdownErrorTextStyle,
|
|
@@ -44,6 +45,7 @@ const Dropdown = ({
|
|
|
44
45
|
dropdownErrorStyle={dropdownErrorStyle}
|
|
45
46
|
primaryColor={primaryColor}
|
|
46
47
|
disabled={disabled}
|
|
48
|
+
placeholderStyle={placeholderStyle}
|
|
47
49
|
/>
|
|
48
50
|
|
|
49
51
|
{error && error !== '' && (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { View, FlatList, StyleSheet, Text } from 'react-native';
|
|
3
4
|
import DropdownListItem from './DropdownListItem';
|
|
@@ -8,6 +9,7 @@ const DropdownList = ({
|
|
|
8
9
|
optionLabel,
|
|
9
10
|
optionValue,
|
|
10
11
|
isMultiple,
|
|
12
|
+
isSearchable,
|
|
11
13
|
selectedItems,
|
|
12
14
|
selectedItem,
|
|
13
15
|
handleMultipleSelections,
|
|
@@ -16,6 +18,7 @@ const DropdownList = ({
|
|
|
16
18
|
checkboxSize,
|
|
17
19
|
checkboxStyle,
|
|
18
20
|
checkboxLabelStyle,
|
|
21
|
+
...rest
|
|
19
22
|
}: any) => {
|
|
20
23
|
return (
|
|
21
24
|
<FlatList
|
|
@@ -27,6 +30,9 @@ const DropdownList = ({
|
|
|
27
30
|
<Text>No options available</Text>
|
|
28
31
|
</View>
|
|
29
32
|
}
|
|
33
|
+
contentContainerStyle={[
|
|
34
|
+
isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,
|
|
35
|
+
]}
|
|
30
36
|
ItemSeparatorComponent={() => <View style={styles.itemSeparatorStyle} />}
|
|
31
37
|
renderItem={(item) =>
|
|
32
38
|
_renderItem(item, {
|
|
@@ -44,6 +50,7 @@ const DropdownList = ({
|
|
|
44
50
|
})
|
|
45
51
|
}
|
|
46
52
|
keyExtractor={(_item, index) => `Options${index}`}
|
|
53
|
+
{...rest}
|
|
47
54
|
/>
|
|
48
55
|
);
|
|
49
56
|
};
|
|
@@ -72,6 +79,7 @@ const styles = StyleSheet.create({
|
|
|
72
79
|
opacity: 0.15,
|
|
73
80
|
},
|
|
74
81
|
emptyListStyle: { alignItems: 'center', width: '100%', marginVertical: 20 },
|
|
82
|
+
contentContainerStyle: { paddingTop: 20 },
|
|
75
83
|
});
|
|
76
84
|
|
|
77
85
|
export default DropdownList;
|
|
@@ -18,7 +18,9 @@ const DropdownListItem = ({
|
|
|
18
18
|
return (
|
|
19
19
|
<TouchableOpacity
|
|
20
20
|
style={styles.dropdownModalOptions}
|
|
21
|
-
onPress={
|
|
21
|
+
onPress={
|
|
22
|
+
item.disabled ? () => {} : () => onChange(item[selectedOptionValue]) // intentionally didn't use the disable property
|
|
23
|
+
}
|
|
22
24
|
>
|
|
23
25
|
<CheckBox
|
|
24
26
|
value={
|
|
@@ -32,6 +34,7 @@ const DropdownListItem = ({
|
|
|
32
34
|
checkboxSize={checkboxSize}
|
|
33
35
|
checkboxStyle={checkboxStyle}
|
|
34
36
|
checkboxLabelStyle={checkboxLabelStyle}
|
|
37
|
+
disabled={item.disabled}
|
|
35
38
|
/>
|
|
36
39
|
</TouchableOpacity>
|
|
37
40
|
);
|
|
@@ -21,6 +21,7 @@ const DropdownSelectedItemsView = ({
|
|
|
21
21
|
selectedItems,
|
|
22
22
|
dropdownStyle,
|
|
23
23
|
selectedItemStyle,
|
|
24
|
+
placeholderStyle,
|
|
24
25
|
multipleSelectedItemStyle,
|
|
25
26
|
dropdownErrorStyle,
|
|
26
27
|
primaryColor,
|
|
@@ -85,7 +86,7 @@ const DropdownSelectedItemsView = ({
|
|
|
85
86
|
</View>
|
|
86
87
|
|
|
87
88
|
{!selectedItem && selectedItems?.length === 0 && (
|
|
88
|
-
<Text style={styles.blackText}>
|
|
89
|
+
<Text style={[styles.blackText, placeholderStyle]}>
|
|
89
90
|
{placeholder ?? 'Select an option'}
|
|
90
91
|
</Text>
|
|
91
92
|
)}
|
package/src/index.tsx
CHANGED
|
@@ -37,6 +37,7 @@ export const DropdownSelect = ({
|
|
|
37
37
|
checkboxSize,
|
|
38
38
|
checkboxStyle,
|
|
39
39
|
checkboxLabelStyle,
|
|
40
|
+
placeholderStyle,
|
|
40
41
|
...rest
|
|
41
42
|
}: DropdownProps) => {
|
|
42
43
|
const [newOptions, setNewOptions] = useState(options ? options : []);
|
|
@@ -76,7 +77,7 @@ export const DropdownSelect = ({
|
|
|
76
77
|
setSelectedItems(selectedValues);
|
|
77
78
|
onValueChange(selectedValues); //send value to parent
|
|
78
79
|
|
|
79
|
-
if (
|
|
80
|
+
if (options.length === selectedValues.length) {
|
|
80
81
|
setSelectAll(true);
|
|
81
82
|
} else {
|
|
82
83
|
setSelectAll(false);
|
|
@@ -86,10 +87,10 @@ export const DropdownSelect = ({
|
|
|
86
87
|
const handleSelectAll = () => {
|
|
87
88
|
setSelectAll((prevVal) => {
|
|
88
89
|
const selectedValues = [];
|
|
89
|
-
|
|
90
|
+
const filteredOptions = newOptions.filter((item) => !item.disabled); //don't select disabled items
|
|
90
91
|
if (!prevVal) {
|
|
91
|
-
for (let i = 0; i <
|
|
92
|
-
selectedValues.push(
|
|
92
|
+
for (let i = 0; i < filteredOptions.length; i++) {
|
|
93
|
+
selectedValues.push(filteredOptions[i][optionValue]);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -187,6 +188,7 @@ export const DropdownSelect = ({
|
|
|
187
188
|
isMultiple={isMultiple}
|
|
188
189
|
primaryColor={primary}
|
|
189
190
|
disabled={disabled}
|
|
191
|
+
placeholderStyle={placeholderStyle}
|
|
190
192
|
{...rest}
|
|
191
193
|
/>
|
|
192
194
|
<CustomModal
|
|
@@ -196,34 +198,39 @@ export const DropdownSelect = ({
|
|
|
196
198
|
modalOptionsContainer={modalOptionsContainer}
|
|
197
199
|
onRequestClose={() => {}}
|
|
198
200
|
>
|
|
199
|
-
{isSearchable && (
|
|
200
|
-
<Input
|
|
201
|
-
value={searchValue}
|
|
202
|
-
onChangeText={(text: string) => onSearch(text)}
|
|
203
|
-
style={searchInputStyle}
|
|
204
|
-
primaryColor={primary}
|
|
205
|
-
/>
|
|
206
|
-
)}
|
|
207
|
-
{isMultiple && newOptions.length > 1 && (
|
|
208
|
-
<View style={styles.optionsContainerStyle}>
|
|
209
|
-
<TouchableOpacity onPress={() => {}}>
|
|
210
|
-
<CheckBox
|
|
211
|
-
value={selectAll}
|
|
212
|
-
label={selectAll ? 'Clear all' : 'Select all'}
|
|
213
|
-
onChange={() => handleSelectAll()}
|
|
214
|
-
primaryColor={primary}
|
|
215
|
-
checkboxSize={checkboxSize}
|
|
216
|
-
checkboxStyle={checkboxStyle}
|
|
217
|
-
checkboxLabelStyle={checkboxLabelStyle}
|
|
218
|
-
/>
|
|
219
|
-
</TouchableOpacity>
|
|
220
|
-
</View>
|
|
221
|
-
)}
|
|
222
201
|
<DropdownList
|
|
202
|
+
ListHeaderComponent={
|
|
203
|
+
<>
|
|
204
|
+
{isSearchable && (
|
|
205
|
+
<Input
|
|
206
|
+
value={searchValue}
|
|
207
|
+
onChangeText={(text: string) => onSearch(text)}
|
|
208
|
+
style={searchInputStyle}
|
|
209
|
+
primaryColor={primary}
|
|
210
|
+
/>
|
|
211
|
+
)}
|
|
212
|
+
{isMultiple && newOptions.length > 1 && (
|
|
213
|
+
<View style={styles.optionsContainerStyle}>
|
|
214
|
+
<TouchableOpacity onPress={() => {}}>
|
|
215
|
+
<CheckBox
|
|
216
|
+
value={selectAll}
|
|
217
|
+
label={selectAll ? 'Clear all' : 'Select all'}
|
|
218
|
+
onChange={() => handleSelectAll()}
|
|
219
|
+
primaryColor={primary}
|
|
220
|
+
checkboxSize={checkboxSize}
|
|
221
|
+
checkboxStyle={checkboxStyle}
|
|
222
|
+
checkboxLabelStyle={checkboxLabelStyle}
|
|
223
|
+
/>
|
|
224
|
+
</TouchableOpacity>
|
|
225
|
+
</View>
|
|
226
|
+
)}
|
|
227
|
+
</>
|
|
228
|
+
}
|
|
223
229
|
options={newOptions}
|
|
224
230
|
optionLabel={optionLabel}
|
|
225
231
|
optionValue={optionValue}
|
|
226
232
|
isMultiple={isMultiple}
|
|
233
|
+
isSearchable={isSearchable}
|
|
227
234
|
selectedItems={selectedItems}
|
|
228
235
|
selectedItem={selectedItem}
|
|
229
236
|
handleMultipleSelections={handleMultipleSelections}
|
package/src/styles/colors.ts
CHANGED