@rn-components-dropdown/dropdown 1.0.10 → 1.0.11
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/components/chip/Chip.js +3 -3
- package/dist/components/dropdown/components/chip/ChipStyle.d.ts +1 -1
- package/dist/components/dropdown/components/chip/ChipStyle.js +6 -6
- package/dist/components/dropdown/interface/DropdownInterface.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/dropdown/Dropdown.tsx +18 -4
- package/src/components/dropdown/components/chip/Chip.tsx +16 -7
- package/src/components/dropdown/components/chip/ChipStyle.ts +6 -6
- package/src/components/dropdown/interface/DropdownInterface.ts +2 -2
|
@@ -54,7 +54,7 @@ const DropdownComponent = (props) => {
|
|
|
54
54
|
const { styles, colors } = (0, DropdownStyle_1.useDropdownStyle)({});
|
|
55
55
|
const { ref, font, visible, refList, position, onSelect, listData, onSearch, onMeasure, searchText, showOrClose, scrollIndex, currentValue, onCheckPress, onClearPress, setSearchText, keyboardHeight, } = (0, useDropdown_1.default)({ ...props });
|
|
56
56
|
const renderRight = () => {
|
|
57
|
-
return renderRightIcon ? (renderRightIcon(visible)) : (<SvgButton_1.default icon={subfixIcon ? subfixIcon : visible ? <svg_1.ArrowUp color={iconColor}/> : <svg_1.ArrowDown color={iconColor}/>} onPress={showOrClose} style={react_native_1.StyleSheet.flatten([
|
|
57
|
+
return renderRightIcon ? (renderRightIcon(visible)) : (<SvgButton_1.default icon={subfixIcon ? (subfixIcon) : visible ? (<svg_1.ArrowUp color={iconColor}/>) : (<svg_1.ArrowDown color={iconColor}/>)} onPress={showOrClose} style={react_native_1.StyleSheet.flatten([
|
|
58
58
|
iconStyle,
|
|
59
59
|
styles.icon,
|
|
60
60
|
{ tintColor: iconColor },
|
|
@@ -95,11 +95,11 @@ const DropdownComponent = (props) => {
|
|
|
95
95
|
</react_native_1.View>);
|
|
96
96
|
}, [styles]);
|
|
97
97
|
const renderCheckItem = (0, react_1.useCallback)(({ item, index }) => {
|
|
98
|
-
const isSelected = lodash_1.default.some(currentValue, h => lodash_1.default.isEqual(lodash_1.default.get(h, valueField), lodash_1.default.get(item, valueField)));
|
|
98
|
+
const isSelected = lodash_1.default.some(currentValue, (h) => lodash_1.default.isEqual(lodash_1.default.get(h, valueField), lodash_1.default.get(item, valueField)));
|
|
99
99
|
return (<react_native_1.TouchableHighlight key={index.toString()} testID={lodash_1.default.get(item, itemTestIDField || labelField)} accessible={!!accessibilityLabel} accessibilityLabel={lodash_1.default.get(item, itemAccessibilityLabelField || labelField)} underlayColor={colors[activeColor]} onPress={() => onCheckPress(item)}>
|
|
100
100
|
<react_native_1.View style={react_native_1.StyleSheet.flatten([itemContainerStyle])}>
|
|
101
101
|
{renderItem ? (renderItem(item, isSelected, labelField, valueField)) : (<react_native_1.View style={styles.item}>
|
|
102
|
-
<SvgButton_1.default icon={multiSelectIcon ? multiSelectIcon : <CheckIcon_1.default color={colors.white}/>} onPress={() => onCheckPress(item)} style={[
|
|
102
|
+
<SvgButton_1.default icon={multiSelectIcon ? (multiSelectIcon) : (<CheckIcon_1.default color={colors.white}/>)} onPress={() => onCheckPress(item)} style={[
|
|
103
103
|
styles.checkContainer,
|
|
104
104
|
{
|
|
105
105
|
backgroundColor: isSelected ? colors.gray : colors.white,
|
|
@@ -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
|
-
{clearIcon ? clearIcon : <react_native_1.View style={styles.clearContainer}>
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
{clearIcon ? (clearIcon) : (<react_native_1.View style={styles.clearContainer}>
|
|
19
|
+
<SvgButton_1.default icon={<svg_1.ClearIcon size={8} color={textColor ? colors[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;
|
|
@@ -4,7 +4,7 @@ const react_1 = require("react");
|
|
|
4
4
|
const style_1 = require("../../../../style");
|
|
5
5
|
const react_native_1 = require("react-native");
|
|
6
6
|
const useChipStyle = (props) => {
|
|
7
|
-
const { chipColor } = props;
|
|
7
|
+
const { chipColor, textColor } = props;
|
|
8
8
|
const { ...colors } = style_1.LIGHT_COLORS;
|
|
9
9
|
const styles = (0, react_1.useMemo)(() => {
|
|
10
10
|
return react_native_1.StyleSheet.create({
|
|
@@ -17,7 +17,7 @@ const useChipStyle = (props) => {
|
|
|
17
17
|
},
|
|
18
18
|
ios: {
|
|
19
19
|
shadowRadius: 1.84,
|
|
20
|
-
shadowOpacity: 0.
|
|
20
|
+
shadowOpacity: 0.35,
|
|
21
21
|
shadowColor: colors.black,
|
|
22
22
|
shadowOffset: { width: 0, height: 2 },
|
|
23
23
|
},
|
|
@@ -37,23 +37,23 @@ const useChipStyle = (props) => {
|
|
|
37
37
|
clearContainer: {
|
|
38
38
|
width: 18,
|
|
39
39
|
height: 18,
|
|
40
|
-
borderWidth:
|
|
40
|
+
borderWidth: 2,
|
|
41
41
|
borderRadius: 100,
|
|
42
42
|
marginHorizontal: 4,
|
|
43
43
|
alignItems: 'center',
|
|
44
44
|
justifyContent: 'center',
|
|
45
|
-
borderColor: colors.white,
|
|
45
|
+
borderColor: textColor ? colors[textColor] : colors.white,
|
|
46
46
|
backgroundColor: chipColor ? colors[chipColor] : colors.lightGray,
|
|
47
47
|
},
|
|
48
48
|
clearIcon: {
|
|
49
|
-
height: 12,
|
|
50
49
|
width: 12,
|
|
50
|
+
height: 12,
|
|
51
51
|
borderRadius: 100,
|
|
52
52
|
alignItems: 'center',
|
|
53
53
|
justifyContent: 'center',
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
|
-
}, [chipColor, colors]);
|
|
56
|
+
}, [chipColor, colors, textColor]);
|
|
57
57
|
return {
|
|
58
58
|
styles,
|
|
59
59
|
colors,
|
|
@@ -38,11 +38,11 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
38
38
|
subfixIcon?: React.JSX.Element;
|
|
39
39
|
onClear?: (id?: number) => void;
|
|
40
40
|
activeColor?: keyof ThemeColors;
|
|
41
|
-
chipContainerProps: ChipInterface;
|
|
42
41
|
iconStyle?: StyleProp<ImageStyle>;
|
|
43
|
-
|
|
42
|
+
chipContainerProps: ChipInterface;
|
|
44
43
|
checkIconColor?: keyof ThemeColors;
|
|
45
44
|
radioIconColor?: keyof ThemeColors;
|
|
45
|
+
multiSelectIcon?: React.JSX.Element;
|
|
46
46
|
mode?: 'default' | 'modal' | 'auto';
|
|
47
47
|
itemTextStyle?: StyleProp<TextStyle>;
|
|
48
48
|
itemAccessibilityLabelField?: string;
|
package/package.json
CHANGED
|
@@ -100,7 +100,15 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
|
100
100
|
renderRightIcon(visible)
|
|
101
101
|
) : (
|
|
102
102
|
<SvgButton
|
|
103
|
-
icon={
|
|
103
|
+
icon={
|
|
104
|
+
subfixIcon ? (
|
|
105
|
+
subfixIcon
|
|
106
|
+
) : visible ? (
|
|
107
|
+
<ArrowUp color={iconColor} />
|
|
108
|
+
) : (
|
|
109
|
+
<ArrowDown color={iconColor} />
|
|
110
|
+
)
|
|
111
|
+
}
|
|
104
112
|
onPress={showOrClose}
|
|
105
113
|
style={StyleSheet.flatten([
|
|
106
114
|
iconStyle,
|
|
@@ -182,7 +190,7 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
|
182
190
|
|
|
183
191
|
const renderCheckItem = useCallback(
|
|
184
192
|
({ item, index }: { item: T; index: number }) => {
|
|
185
|
-
const isSelected = _.some(currentValue, h =>
|
|
193
|
+
const isSelected = _.some(currentValue, (h: any) =>
|
|
186
194
|
_.isEqual(_.get(h, valueField), _.get(item, valueField)),
|
|
187
195
|
);
|
|
188
196
|
return (
|
|
@@ -200,10 +208,16 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
|
|
|
200
208
|
<View style={StyleSheet.flatten([itemContainerStyle])}>
|
|
201
209
|
{renderItem ? (
|
|
202
210
|
renderItem(item, isSelected, labelField, valueField)
|
|
203
|
-
)
|
|
211
|
+
) : (
|
|
204
212
|
<View style={styles.item}>
|
|
205
213
|
<SvgButton
|
|
206
|
-
icon={
|
|
214
|
+
icon={
|
|
215
|
+
multiSelectIcon ? (
|
|
216
|
+
multiSelectIcon
|
|
217
|
+
) : (
|
|
218
|
+
<CheckIcon color={colors.white} />
|
|
219
|
+
)
|
|
220
|
+
}
|
|
207
221
|
onPress={() => onCheckPress(item)}
|
|
208
222
|
style={[
|
|
209
223
|
styles.checkContainer,
|
|
@@ -18,13 +18,22 @@ const Chip = (props: ChipInterface) => {
|
|
|
18
18
|
>
|
|
19
19
|
{label}
|
|
20
20
|
</AppText>
|
|
21
|
-
{clearIcon ?
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
{clearIcon ? (
|
|
22
|
+
clearIcon
|
|
23
|
+
) : (
|
|
24
|
+
<View style={styles.clearContainer}>
|
|
25
|
+
<SvgButton
|
|
26
|
+
icon={
|
|
27
|
+
<ClearIcon
|
|
28
|
+
size={8}
|
|
29
|
+
color={textColor ? colors[textColor] : colors.white}
|
|
30
|
+
/>
|
|
31
|
+
}
|
|
32
|
+
onPress={onClearPress}
|
|
33
|
+
style={styles.clearIcon}
|
|
34
|
+
/>
|
|
35
|
+
</View>
|
|
36
|
+
)}
|
|
28
37
|
</View>
|
|
29
38
|
);
|
|
30
39
|
};
|
|
@@ -4,7 +4,7 @@ import { Platform, StyleSheet } from 'react-native';
|
|
|
4
4
|
import { ChipInterface } from '../../interface/ChipInterface';
|
|
5
5
|
|
|
6
6
|
const useChipStyle = (props: ChipInterface) => {
|
|
7
|
-
const { chipColor } = props;
|
|
7
|
+
const { chipColor, textColor } = props;
|
|
8
8
|
const { ...colors } = LIGHT_COLORS;
|
|
9
9
|
const styles = useMemo(() => {
|
|
10
10
|
return StyleSheet.create({
|
|
@@ -17,7 +17,7 @@ const useChipStyle = (props: ChipInterface) => {
|
|
|
17
17
|
},
|
|
18
18
|
ios: {
|
|
19
19
|
shadowRadius: 1.84,
|
|
20
|
-
shadowOpacity: 0.
|
|
20
|
+
shadowOpacity: 0.35,
|
|
21
21
|
shadowColor: colors.black,
|
|
22
22
|
shadowOffset: { width: 0, height: 2 },
|
|
23
23
|
},
|
|
@@ -37,23 +37,23 @@ const useChipStyle = (props: ChipInterface) => {
|
|
|
37
37
|
clearContainer: {
|
|
38
38
|
width: 18,
|
|
39
39
|
height: 18,
|
|
40
|
-
borderWidth:
|
|
40
|
+
borderWidth: 2,
|
|
41
41
|
borderRadius: 100,
|
|
42
42
|
marginHorizontal: 4,
|
|
43
43
|
alignItems: 'center',
|
|
44
44
|
justifyContent: 'center',
|
|
45
|
-
borderColor: colors.white,
|
|
45
|
+
borderColor: textColor ? colors[textColor] : colors.white,
|
|
46
46
|
backgroundColor: chipColor ? colors[chipColor] : colors.lightGray,
|
|
47
47
|
},
|
|
48
48
|
clearIcon: {
|
|
49
|
-
height: 12,
|
|
50
49
|
width: 12,
|
|
50
|
+
height: 12,
|
|
51
51
|
borderRadius: 100,
|
|
52
52
|
alignItems: 'center',
|
|
53
53
|
justifyContent: 'center',
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
|
-
}, [chipColor, colors]);
|
|
56
|
+
}, [chipColor, colors, textColor]);
|
|
57
57
|
return {
|
|
58
58
|
styles,
|
|
59
59
|
colors,
|
|
@@ -48,11 +48,11 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
48
48
|
subfixIcon?: React.JSX.Element;
|
|
49
49
|
onClear?: (id?: number) => void;
|
|
50
50
|
activeColor?: keyof ThemeColors;
|
|
51
|
-
chipContainerProps: ChipInterface;
|
|
52
51
|
iconStyle?: StyleProp<ImageStyle>;
|
|
53
|
-
|
|
52
|
+
chipContainerProps: ChipInterface;
|
|
54
53
|
checkIconColor?: keyof ThemeColors;
|
|
55
54
|
radioIconColor?: keyof ThemeColors;
|
|
55
|
+
multiSelectIcon?: React.JSX.Element;
|
|
56
56
|
mode?: 'default' | 'modal' | 'auto';
|
|
57
57
|
itemTextStyle?: StyleProp<TextStyle>;
|
|
58
58
|
itemAccessibilityLabelField?: string;
|