@rn-components-dropdown/dropdown 1.0.9 → 1.0.10
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 +8 -4
- package/dist/components/dropdown/components/chip/Chip.js +3 -3
- package/dist/components/dropdown/interface/DropdownInterface.d.ts +6 -4
- package/package.json +1 -1
- package/src/components/dropdown/Dropdown.tsx +17 -5
- package/src/components/dropdown/components/chip/Chip.tsx +3 -3
- package/src/components/dropdown/interface/DropdownInterface.ts +9 -7
|
@@ -45,11 +45,12 @@ const react_1 = __importStar(require("react"));
|
|
|
45
45
|
const useDropdown_1 = __importDefault(require("./hooks/useDropdown"));
|
|
46
46
|
const SvgButton_1 = __importDefault(require("../svgButton/SvgButton"));
|
|
47
47
|
const DropdownStyle_1 = require("./DropdownStyle");
|
|
48
|
+
const CheckIcon_1 = __importDefault(require("../../assets/svg/CheckIcon"));
|
|
48
49
|
const svg_1 = require("../../assets/svg");
|
|
49
50
|
const TextInput_1 = __importDefault(require("./components/input/TextInput"));
|
|
50
|
-
const CheckIcon_1 = __importDefault(require("../../assets/svg/CheckIcon"));
|
|
51
51
|
const DropdownComponent = (props) => {
|
|
52
|
-
const { label, testID, iconStyle, renderItem, style = {}, subfixIcon, labelField, valueField, onChangeText, itemTextStyle, flatListProps, minHeight = 0, containerStyle, search = false, renderLeftIcon, multiSelectIcon, itemTestIDField, maxHeight = 300, inverted = true, renderRightIcon, backgroundColor, placeholderStyle, inputSearchStyle, searchPlaceholder, selectedTextStyle, renderInputSearch, iconColor = 'gray', accessibilityLabel, itemContainerStyle, labelContainer = {}, labelTextStyle = {}, selectedTextProps = {}, selectionType = 'single', activeColor = 'lightGray', keyboardAvoiding = true, dropdownPosition = 'auto', placeholder = 'Select item', itemAccessibilityLabelField, showsVerticalScrollIndicator = true, } = props;
|
|
52
|
+
const { label, testID, iconStyle, renderItem, style = {}, subfixIcon, labelField, valueField, onChangeText, itemTextStyle, flatListProps, minHeight = 0, containerStyle, search = false, renderLeftIcon, multiSelectIcon, itemTestIDField, maxHeight = 300, inverted = true, renderRightIcon, backgroundColor, placeholderStyle, inputSearchStyle, searchPlaceholder, selectedTextStyle, renderInputSearch, chipContainerProps, iconColor = 'gray', accessibilityLabel, itemContainerStyle, labelContainer = {}, labelTextStyle = {}, selectedTextProps = {}, selectionType = 'single', activeColor = 'lightGray', keyboardAvoiding = true, dropdownPosition = 'auto', placeholder = 'Select item', itemAccessibilityLabelField, showsVerticalScrollIndicator = true, } = props;
|
|
53
|
+
const { chipColor, clearIcon, textColor, onClearPress: onClear, } = chipContainerProps;
|
|
53
54
|
const { styles, colors } = (0, DropdownStyle_1.useDropdownStyle)({});
|
|
54
55
|
const { ref, font, visible, refList, position, onSelect, listData, onSearch, onMeasure, searchText, showOrClose, scrollIndex, currentValue, onCheckPress, onClearPress, setSearchText, keyboardHeight, } = (0, useDropdown_1.default)({ ...props });
|
|
55
56
|
const renderRight = () => {
|
|
@@ -77,7 +78,10 @@ const DropdownComponent = (props) => {
|
|
|
77
78
|
</AppText_1.default>) : (<react_native_1.View style={styles.showMultiSelectContainer}>
|
|
78
79
|
<react_native_1.ScrollView showsVerticalScrollIndicator={false}>
|
|
79
80
|
<react_native_1.View style={styles.wraps}>
|
|
80
|
-
{currentValue?.map?.((i) => (<Chip_1.default chipColor={'red'} textColor={'white'} key={i?.[valueField]} label={i?.[labelField]} onClearPress={() =>
|
|
81
|
+
{currentValue?.map?.((i) => (<Chip_1.default chipColor={chipColor || 'red'} textColor={textColor || 'white'} clearIcon={clearIcon} key={i?.[valueField]} label={i?.[labelField]} onClearPress={() => {
|
|
82
|
+
onClear?.();
|
|
83
|
+
onClearPress?.(i);
|
|
84
|
+
}}/>))}
|
|
81
85
|
</react_native_1.View>
|
|
82
86
|
</react_native_1.ScrollView>
|
|
83
87
|
</react_native_1.View>)}
|
|
@@ -209,9 +213,9 @@ const DropdownComponent = (props) => {
|
|
|
209
213
|
</react_native_1.View>
|
|
210
214
|
</react_native_1.TouchableWithoutFeedback>);
|
|
211
215
|
}, [
|
|
212
|
-
inverted,
|
|
213
216
|
styles,
|
|
214
217
|
testID,
|
|
218
|
+
inverted,
|
|
215
219
|
listData,
|
|
216
220
|
scrollIndex,
|
|
217
221
|
renderSearch,
|
|
@@ -15,9 +15,9 @@ const Chip = (props) => {
|
|
|
15
15
|
<AppText_1.default size={12} fontFamily={'semiBold'} style={styles.chipText} color={textColor ? textColor : 'gray'}>
|
|
16
16
|
{label}
|
|
17
17
|
</AppText_1.default>
|
|
18
|
-
<react_native_1.View style={styles.clearContainer}>
|
|
19
|
-
<SvgButton_1.default icon={
|
|
20
|
-
</react_native_1.View>
|
|
18
|
+
{clearIcon ? clearIcon : <react_native_1.View style={styles.clearContainer}>
|
|
19
|
+
<SvgButton_1.default icon={<svg_1.ClearIcon size={14} color={textColor || colors.white}/>} onPress={onClearPress} style={styles.clearIcon}/>
|
|
20
|
+
</react_native_1.View>}
|
|
21
21
|
</react_native_1.View>);
|
|
22
22
|
};
|
|
23
23
|
exports.default = Chip;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { StyleProp, TextStyle, ViewStyle, TextProps, ImageStyle, FlatListProps } from 'react-native';
|
|
3
|
+
import { ChipInterface } from './ChipInterface';
|
|
3
4
|
import { ThemeColors } from '../../../interface/colors.interface';
|
|
4
5
|
export type IDropdownRef = {
|
|
5
6
|
open: () => void;
|
|
@@ -33,15 +34,15 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
33
34
|
confirmSelectItem?: boolean;
|
|
34
35
|
accessibilityLabel?: string;
|
|
35
36
|
style?: StyleProp<ViewStyle>;
|
|
37
|
+
selectedTextProps?: TextProps;
|
|
36
38
|
subfixIcon?: React.JSX.Element;
|
|
37
39
|
onClear?: (id?: number) => void;
|
|
40
|
+
activeColor?: keyof ThemeColors;
|
|
41
|
+
chipContainerProps: ChipInterface;
|
|
42
|
+
iconStyle?: StyleProp<ImageStyle>;
|
|
38
43
|
multiSelectIcon?: React.JSX.Element;
|
|
39
44
|
checkIconColor?: keyof ThemeColors;
|
|
40
45
|
radioIconColor?: keyof ThemeColors;
|
|
41
|
-
onChange?: (selecteValue?: keyof S, selectedList?: SelectionType extends 'single' | 'multi' ? S[] : S) => void;
|
|
42
|
-
selectedTextProps?: TextProps;
|
|
43
|
-
activeColor?: keyof ThemeColors;
|
|
44
|
-
iconStyle?: StyleProp<ImageStyle>;
|
|
45
46
|
mode?: 'default' | 'modal' | 'auto';
|
|
46
47
|
itemTextStyle?: StyleProp<TextStyle>;
|
|
47
48
|
itemAccessibilityLabelField?: string;
|
|
@@ -63,6 +64,7 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
63
64
|
renderRightIcon?: (visible?: boolean) => React.JSX.Element | null | undefined;
|
|
64
65
|
renderItem?: (item: S, selected?: boolean, labelField?: keyof S, valueField?: keyof S) => React.JSX.Element | null | undefined;
|
|
65
66
|
renderInputSearch?: (onSearch: (text: string) => void) => React.JSX.Element | null | undefined;
|
|
67
|
+
onChange?: (selecteValue?: keyof S, selectedList?: SelectionType extends 'single' | 'multi' ? S[] : S) => void;
|
|
66
68
|
};
|
|
67
69
|
export interface IUseDetectDevice {
|
|
68
70
|
isAndroid: boolean;
|
package/package.json
CHANGED
|
@@ -16,10 +16,10 @@ import React, { useCallback } from 'react';
|
|
|
16
16
|
import useDropdown from './hooks/useDropdown';
|
|
17
17
|
import SvgButton from '../svgButton/SvgButton';
|
|
18
18
|
import { useDropdownStyle } from './DropdownStyle';
|
|
19
|
+
import CheckIcon from '../../assets/svg/CheckIcon';
|
|
19
20
|
import { ArrowDown, ArrowUp } from '../../assets/svg';
|
|
20
21
|
import SearchInput from './components/input/TextInput';
|
|
21
22
|
import { DropdownProps } from './interface/DropdownInterface';
|
|
22
|
-
import CheckIcon from '../../assets/svg/CheckIcon';
|
|
23
23
|
|
|
24
24
|
const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
25
25
|
props: DropdownProps<T, Mode>,
|
|
@@ -51,6 +51,7 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
|
51
51
|
searchPlaceholder,
|
|
52
52
|
selectedTextStyle,
|
|
53
53
|
renderInputSearch,
|
|
54
|
+
chipContainerProps,
|
|
54
55
|
iconColor = 'gray',
|
|
55
56
|
accessibilityLabel,
|
|
56
57
|
itemContainerStyle,
|
|
@@ -66,6 +67,13 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
|
66
67
|
showsVerticalScrollIndicator = true,
|
|
67
68
|
} = props;
|
|
68
69
|
|
|
70
|
+
const {
|
|
71
|
+
chipColor,
|
|
72
|
+
clearIcon,
|
|
73
|
+
textColor,
|
|
74
|
+
onClearPress: onClear,
|
|
75
|
+
} = chipContainerProps;
|
|
76
|
+
|
|
69
77
|
const { styles, colors } = useDropdownStyle({});
|
|
70
78
|
const {
|
|
71
79
|
ref,
|
|
@@ -140,11 +148,15 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
|
140
148
|
<View style={styles.wraps}>
|
|
141
149
|
{currentValue?.map?.((i: any) => (
|
|
142
150
|
<Chip
|
|
143
|
-
chipColor={'red'}
|
|
144
|
-
textColor={'white'}
|
|
151
|
+
chipColor={chipColor || 'red'}
|
|
152
|
+
textColor={textColor || 'white'}
|
|
153
|
+
clearIcon={clearIcon}
|
|
145
154
|
key={i?.[valueField]}
|
|
146
155
|
label={i?.[labelField]}
|
|
147
|
-
onClearPress={() =>
|
|
156
|
+
onClearPress={() => {
|
|
157
|
+
onClear?.();
|
|
158
|
+
onClearPress?.(i);
|
|
159
|
+
}}
|
|
148
160
|
/>
|
|
149
161
|
))}
|
|
150
162
|
</View>
|
|
@@ -370,9 +382,9 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
|
370
382
|
);
|
|
371
383
|
},
|
|
372
384
|
[
|
|
373
|
-
inverted,
|
|
374
385
|
styles,
|
|
375
386
|
testID,
|
|
387
|
+
inverted,
|
|
376
388
|
listData,
|
|
377
389
|
scrollIndex,
|
|
378
390
|
renderSearch,
|
|
@@ -18,13 +18,13 @@ const Chip = (props: ChipInterface) => {
|
|
|
18
18
|
>
|
|
19
19
|
{label}
|
|
20
20
|
</AppText>
|
|
21
|
-
<View style={styles.clearContainer}>
|
|
21
|
+
{clearIcon ? clearIcon : <View style={styles.clearContainer}>
|
|
22
22
|
<SvgButton
|
|
23
|
-
icon={
|
|
23
|
+
icon={<ClearIcon size={14} color={textColor || colors.white}/> }
|
|
24
24
|
onPress={onClearPress}
|
|
25
25
|
style={styles.clearIcon}
|
|
26
26
|
/>
|
|
27
|
-
</View>
|
|
27
|
+
</View>}
|
|
28
28
|
</View>
|
|
29
29
|
);
|
|
30
30
|
};
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
ImageStyle,
|
|
8
8
|
FlatListProps,
|
|
9
9
|
} from 'react-native';
|
|
10
|
+
import { ChipInterface } from './ChipInterface';
|
|
10
11
|
import { ThemeColors } from '../../../interface/colors.interface';
|
|
11
12
|
|
|
12
13
|
export type IDropdownRef = {
|
|
@@ -43,18 +44,15 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
43
44
|
confirmSelectItem?: boolean;
|
|
44
45
|
accessibilityLabel?: string;
|
|
45
46
|
style?: StyleProp<ViewStyle>;
|
|
47
|
+
selectedTextProps?: TextProps;
|
|
46
48
|
subfixIcon?: React.JSX.Element;
|
|
47
49
|
onClear?: (id?: number) => void;
|
|
50
|
+
activeColor?: keyof ThemeColors;
|
|
51
|
+
chipContainerProps: ChipInterface;
|
|
52
|
+
iconStyle?: StyleProp<ImageStyle>;
|
|
48
53
|
multiSelectIcon?:React.JSX.Element;
|
|
49
54
|
checkIconColor?: keyof ThemeColors;
|
|
50
55
|
radioIconColor?: keyof ThemeColors;
|
|
51
|
-
onChange?: (
|
|
52
|
-
selecteValue?: keyof S,
|
|
53
|
-
selectedList?: SelectionType extends 'single' | 'multi' ? S[] : S,
|
|
54
|
-
) => void;
|
|
55
|
-
selectedTextProps?: TextProps;
|
|
56
|
-
activeColor?: keyof ThemeColors;
|
|
57
|
-
iconStyle?: StyleProp<ImageStyle>;
|
|
58
56
|
mode?: 'default' | 'modal' | 'auto';
|
|
59
57
|
itemTextStyle?: StyleProp<TextStyle>;
|
|
60
58
|
itemAccessibilityLabelField?: string;
|
|
@@ -83,6 +81,10 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
83
81
|
renderInputSearch?: (
|
|
84
82
|
onSearch: (text: string) => void,
|
|
85
83
|
) => React.JSX.Element | null | undefined;
|
|
84
|
+
onChange?: (
|
|
85
|
+
selecteValue?: keyof S,
|
|
86
|
+
selectedList?: SelectionType extends 'single' | 'multi' ? S[] : S,
|
|
87
|
+
) => void;
|
|
86
88
|
};
|
|
87
89
|
|
|
88
90
|
export interface IUseDetectDevice {
|