@rn-components-dropdown/dropdown 1.0.32 → 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.d.ts +2 -2
- package/dist/components/dropdown/Dropdown.js +4 -4
- package/dist/components/dropdown/hooks/useDropdown.js +1 -1
- package/dist/components/dropdown/interface/ChipInterface.d.ts +2 -2
- package/dist/controller/dropDownController/DropdownController.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/dropdown/Dropdown.tsx +6 -10
- package/src/components/dropdown/hooks/useDropdown.ts +1 -1
- package/src/components/dropdown/interface/ChipInterface.ts +2 -2
- package/src/controller/dropDownController/DropdownController.tsx +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DropdownProps } from './interface/DropdownInterface';
|
|
3
|
-
declare const DropdownComponent: <T, Mode extends
|
|
2
|
+
import { DropdownProps, SELECTIONS_TYPE } from './interface/DropdownInterface';
|
|
3
|
+
declare const DropdownComponent: <T, Mode extends SELECTIONS_TYPE>(props: DropdownProps<T, Mode>) => React.JSX.Element;
|
|
4
4
|
export default DropdownComponent;
|
|
@@ -6,11 +6,11 @@ import React, { useCallback } from 'react';
|
|
|
6
6
|
import useDropdown from './hooks/useDropdown';
|
|
7
7
|
import SvgButton from '../svgButton/SvgButton';
|
|
8
8
|
import { useDropdownStyle } from './DropdownStyle';
|
|
9
|
-
import { ArrowDown, ArrowUp, CheckIcon } from '../../assets/svg';
|
|
10
9
|
import SearchInput from './component/input/TextInput';
|
|
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
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DropdownProps, SELECTIONS_TYPE } from '../../components/dropdown/interface/DropdownInterface';
|
|
3
3
|
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
4
|
-
interface DropControllerProps<U extends FieldValues, S, T extends SELECTIONS_TYPE
|
|
4
|
+
interface DropControllerProps<U extends FieldValues, S, T extends SELECTIONS_TYPE> extends DropdownProps<S, T> {
|
|
5
5
|
control: Control<U>;
|
|
6
6
|
controller: Path<U>;
|
|
7
7
|
}
|
|
8
|
-
declare const AppDropdownController: <U extends FieldValues, S, T extends SELECTIONS_TYPE
|
|
8
|
+
declare const AppDropdownController: <U extends FieldValues, S, T extends SELECTIONS_TYPE>(props: DropControllerProps<U, S, T>) => React.JSX.Element;
|
|
9
9
|
export default AppDropdownController;
|
package/package.json
CHANGED
|
@@ -15,11 +15,11 @@ import React, { useCallback } from 'react';
|
|
|
15
15
|
import useDropdown from './hooks/useDropdown';
|
|
16
16
|
import SvgButton from '../svgButton/SvgButton';
|
|
17
17
|
import { useDropdownStyle } from './DropdownStyle';
|
|
18
|
-
import { ArrowDown, ArrowUp, CheckIcon } from '../../assets/svg';
|
|
19
18
|
import SearchInput from './component/input/TextInput';
|
|
20
|
-
import {
|
|
19
|
+
import { ArrowDown, ArrowUp, CheckIcon } from '../../assets/svg';
|
|
20
|
+
import { DropdownProps, SELECTIONS_TYPE } from './interface/DropdownInterface';
|
|
21
21
|
|
|
22
|
-
const DropdownComponent = <T, Mode extends
|
|
22
|
+
const DropdownComponent = <T, Mode extends SELECTIONS_TYPE>(
|
|
23
23
|
props: DropdownProps<T, Mode>,
|
|
24
24
|
) => {
|
|
25
25
|
const {
|
|
@@ -59,6 +59,7 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
|
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 'single' | 'multi'>(
|
|
|
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 'single' | 'multi'>(
|
|
|
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
|
}
|
|
@@ -12,7 +12,7 @@ import { Control, Controller, FieldValues, Path } from 'react-hook-form';
|
|
|
12
12
|
interface DropControllerProps<
|
|
13
13
|
U extends FieldValues,
|
|
14
14
|
S,
|
|
15
|
-
T extends SELECTIONS_TYPE
|
|
15
|
+
T extends SELECTIONS_TYPE,
|
|
16
16
|
> extends DropdownProps<S, T> {
|
|
17
17
|
control: Control<U>;
|
|
18
18
|
controller: Path<U>;
|
|
@@ -21,7 +21,7 @@ interface DropControllerProps<
|
|
|
21
21
|
const AppDropdownController = <
|
|
22
22
|
U extends FieldValues,
|
|
23
23
|
S,
|
|
24
|
-
T extends SELECTIONS_TYPE
|
|
24
|
+
T extends SELECTIONS_TYPE,
|
|
25
25
|
>(
|
|
26
26
|
props: DropControllerProps<U, S, T>,
|
|
27
27
|
) => {
|