@rn-components-dropdown/dropdown 1.0.33 → 1.0.34
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/dist/components/dropdown/Dropdown.js +3 -3
- package/dist/components/dropdown/hooks/useDropdown.js +1 -1
- package/dist/components/dropdown/interface/ChipInterface.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/dropdown/Dropdown.tsx +3 -7
- package/src/components/dropdown/hooks/useDropdown.ts +1 -1
- package/src/components/dropdown/interface/ChipInterface.ts +2 -2
|
@@ -9,8 +9,8 @@ import { useDropdownStyle } from './DropdownStyle';
|
|
|
9
9
|
import SearchInput from './component/input/TextInput';
|
|
10
10
|
import { ArrowDown, ArrowUp, CheckIcon } from '../../assets/svg';
|
|
11
11
|
const DropdownComponent = (props) => {
|
|
12
|
-
const { label, testID, iconStyle, renderItem, style = {}, subfixIcon, labelField, valueField, onChangeText, itemTextStyle, flatListProps, minHeight = 0, containerStyle, search = false, renderLeftIcon, checkIconColor, radioIconColor, multiSelectIcon, itemTestIDField, maxHeight = 300, inverted = true, renderRightIcon, placeholderStyle, inputSearchStyle, searchPlaceholder, selectedTextStyle, renderInputSearch, iconColor = 'gray', accessibilityLabel, itemContainerStyle, labelContainer = {}, labelTextStyle = {}, selectedTextProps = {}, chipContainerProps = {}, keyboardAvoiding = true, selectionType = 'single', activeColor = 'lightGray', dropdownPosition = 'auto', itemAccessibilityLabelField, placeholder = 'Please select', showsVerticalScrollIndicator = true, } = props;
|
|
13
|
-
const { chipColor, clearIcon, textColor
|
|
12
|
+
const { label, testID, iconStyle, renderItem, style = {}, subfixIcon, labelField, valueField, onChangeText, itemTextStyle, flatListProps, minHeight = 0, containerStyle, search = false, renderLeftIcon, checkIconColor, radioIconColor, multiSelectIcon, itemTestIDField, maxHeight = 300, inverted = true, renderRightIcon, placeholderStyle, inputSearchStyle, searchPlaceholder, selectedTextStyle, renderInputSearch, iconColor = 'gray', accessibilityLabel, itemContainerStyle, labelContainer = {}, labelTextStyle = {}, selectedTextProps = {}, chipContainerProps = {}, keyboardAvoiding = true, selectionType = 'single', onClear: onChipClearPress, activeColor = 'lightGray', dropdownPosition = 'auto', itemAccessibilityLabelField, placeholder = 'Please select', showsVerticalScrollIndicator = true, } = props;
|
|
13
|
+
const { chipColor, clearIcon, textColor } = chipContainerProps;
|
|
14
14
|
const { styles, colors } = useDropdownStyle({
|
|
15
15
|
checkIconColor: checkIconColor,
|
|
16
16
|
radioIconColor: radioIconColor,
|
|
@@ -42,8 +42,8 @@ const DropdownComponent = (props) => {
|
|
|
42
42
|
<ScrollView showsVerticalScrollIndicator={false}>
|
|
43
43
|
<View style={styles.wraps}>
|
|
44
44
|
{currentValue?.map?.((i) => (<Chip chipColor={chipColor || 'red'} textColor={textColor || 'white'} clearIcon={clearIcon} key={i?.[valueField]} label={i?.[labelField]} onClearPress={() => {
|
|
45
|
-
onClear?.();
|
|
46
45
|
onClearPress?.(i);
|
|
46
|
+
onChipClearPress?.(i?.[valueField]);
|
|
47
47
|
}}/>))}
|
|
48
48
|
</View>
|
|
49
49
|
</ScrollView>
|
|
@@ -230,7 +230,7 @@ const useDropdown = (props) => {
|
|
|
230
230
|
}, [setCurrentValue, valueField, onChange, currentValue]);
|
|
231
231
|
const onClearPress = useCallback((item) => {
|
|
232
232
|
const updated = currentValue.filter((i) => i[valueField] !== item[valueField]);
|
|
233
|
-
const val =
|
|
233
|
+
const val = updated.map((i) => i[valueField]);
|
|
234
234
|
setCurrentValue(updated);
|
|
235
235
|
onChange?.(item[valueField], val);
|
|
236
236
|
}, [currentValue, valueField, onChange, setCurrentValue]);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ColorValue } from
|
|
1
|
+
import { ColorValue } from 'react-native';
|
|
2
2
|
export interface ChipInterface {
|
|
3
3
|
label?: string;
|
|
4
4
|
chipColor?: ColorValue;
|
|
5
5
|
textColor?: ColorValue;
|
|
6
|
-
onClearPress?: () => void;
|
|
7
6
|
clearIcon?: React.JSX.Element;
|
|
7
|
+
onClearPress?: (item?: any) => void;
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -59,6 +59,7 @@ const DropdownComponent = <T, Mode extends SELECTIONS_TYPE>(
|
|
|
59
59
|
chipContainerProps = {},
|
|
60
60
|
keyboardAvoiding = true,
|
|
61
61
|
selectionType = 'single',
|
|
62
|
+
onClear: onChipClearPress,
|
|
62
63
|
activeColor = 'lightGray',
|
|
63
64
|
dropdownPosition = 'auto',
|
|
64
65
|
itemAccessibilityLabelField,
|
|
@@ -66,12 +67,7 @@ const DropdownComponent = <T, Mode extends SELECTIONS_TYPE>(
|
|
|
66
67
|
showsVerticalScrollIndicator = true,
|
|
67
68
|
} = props;
|
|
68
69
|
|
|
69
|
-
const {
|
|
70
|
-
chipColor,
|
|
71
|
-
clearIcon,
|
|
72
|
-
textColor,
|
|
73
|
-
onClearPress: onClear,
|
|
74
|
-
} = chipContainerProps;
|
|
70
|
+
const { chipColor, clearIcon, textColor } = chipContainerProps;
|
|
75
71
|
|
|
76
72
|
const { styles, colors } = useDropdownStyle({
|
|
77
73
|
checkIconColor: checkIconColor,
|
|
@@ -164,8 +160,8 @@ const DropdownComponent = <T, Mode extends SELECTIONS_TYPE>(
|
|
|
164
160
|
key={i?.[valueField]}
|
|
165
161
|
label={i?.[labelField]}
|
|
166
162
|
onClearPress={() => {
|
|
167
|
-
onClear?.();
|
|
168
163
|
onClearPress?.(i);
|
|
164
|
+
onChipClearPress?.(i?.[valueField]);
|
|
169
165
|
}}
|
|
170
166
|
/>
|
|
171
167
|
))}
|
|
@@ -337,7 +337,7 @@ const useDropdown = <T, Mode extends SELECTIONS_TYPE>(
|
|
|
337
337
|
const updated = currentValue.filter(
|
|
338
338
|
(i: any) => i[valueField] !== item[valueField],
|
|
339
339
|
);
|
|
340
|
-
const val =
|
|
340
|
+
const val = updated.map((i: any) => i[valueField]);
|
|
341
341
|
setCurrentValue(updated);
|
|
342
342
|
onChange?.(item[valueField] as keyof T, val);
|
|
343
343
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ColorValue } from
|
|
1
|
+
import { ColorValue } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export interface ChipInterface {
|
|
4
4
|
label?: string;
|
|
5
5
|
chipColor?: ColorValue;
|
|
6
6
|
textColor?: ColorValue;
|
|
7
|
-
onClearPress?: () => void;
|
|
8
7
|
clearIcon?: React.JSX.Element;
|
|
8
|
+
onClearPress?: (item?: any) => void;
|
|
9
9
|
}
|