@rn-components-dropdown/dropdown 1.0.14 → 1.0.16
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 +7 -0
- package/dist/assets/svg/ArrowDown.d.ts +2 -4
- package/dist/components/dropdown/DropdownStyle.d.ts +6 -5
- package/dist/components/dropdown/interface/ChipInterface.d.ts +1 -1
- package/dist/components/dropdown/interface/DropdownInterface.d.ts +6 -6
- package/dist/controller/dropDownController/DropdownController.js +3 -3
- package/package.json +6 -4
- package/src/assets/images/multi_select.png +0 -0
- package/src/assets/images/single_select.png +0 -0
- package/src/assets/svg/ArrowDown.tsx +2 -1
- package/src/components/dropdown/DropdownStyle.ts +3 -3
- package/src/components/dropdown/interface/ChipInterface.ts +1 -2
- package/src/components/dropdown/interface/DropdownInterface.ts +6 -5
- package/src/controller/dropDownController/DropdownController.tsx +3 -3
- package/src/style/index.ts +1 -1
package/README.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
A lightweight, customizable, and fully typed **Dropdown** and **DropdownController** component for **React Native**.
|
|
4
4
|
Supports **single** & **multiple selection**, custom icons, styling, and easy integration with **React Hook Form**.
|
|
5
5
|
|
|
6
|
+
---
|
|
7
|
+
# Example
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
---
|
|
7
14
|
|
|
8
15
|
## 📦 Installation
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
color?: string | undefined;
|
|
5
|
-
}) => React.JSX.Element;
|
|
2
|
+
import { SvgInterface } from "../../interface/svg.interface";
|
|
3
|
+
declare const ArrowDown: ({ size, color }: SvgInterface) => React.JSX.Element;
|
|
6
4
|
export default ArrowDown;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ColorValue } from 'react-native';
|
|
1
2
|
interface Props {
|
|
2
3
|
size?: number;
|
|
3
|
-
radioIconColor?:
|
|
4
|
-
checkIconColor?:
|
|
4
|
+
radioIconColor?: ColorValue;
|
|
5
|
+
checkIconColor?: ColorValue;
|
|
5
6
|
}
|
|
6
7
|
export declare const useDropdownStyle: (props: Props) => {
|
|
7
8
|
styles: {
|
|
@@ -97,13 +98,13 @@ export declare const useDropdownStyle: (props: Props) => {
|
|
|
97
98
|
alignItems: "center";
|
|
98
99
|
justifyContent: "center";
|
|
99
100
|
padding: number;
|
|
100
|
-
borderColor:
|
|
101
|
+
borderColor: ColorValue;
|
|
101
102
|
};
|
|
102
103
|
iconSubContainer: {
|
|
103
104
|
width: "100%";
|
|
104
105
|
height: "100%";
|
|
105
106
|
borderRadius: number;
|
|
106
|
-
backgroundColor:
|
|
107
|
+
backgroundColor: ColorValue;
|
|
107
108
|
};
|
|
108
109
|
styleHorizontal: {
|
|
109
110
|
width: number | "100%";
|
|
@@ -121,7 +122,7 @@ export declare const useDropdownStyle: (props: Props) => {
|
|
|
121
122
|
height: number;
|
|
122
123
|
alignItems: "center";
|
|
123
124
|
justifyContent: "center";
|
|
124
|
-
borderColor:
|
|
125
|
+
borderColor: ColorValue;
|
|
125
126
|
};
|
|
126
127
|
showMultiSelectContainer: {
|
|
127
128
|
width: "90%";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { StyleProp, TextStyle, ViewStyle, TextProps, ImageStyle, FlatListProps } from 'react-native';
|
|
2
|
+
import type { StyleProp, TextStyle, ViewStyle, TextProps, ImageStyle, FlatListProps, ColorValue } from 'react-native';
|
|
3
3
|
import { ChipInterface } from './ChipInterface';
|
|
4
4
|
export type IDropdownRef = {
|
|
5
5
|
open: () => void;
|
|
@@ -13,7 +13,6 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
13
13
|
disable?: boolean;
|
|
14
14
|
selectionType?: T;
|
|
15
15
|
maxHeight?: number;
|
|
16
|
-
iconColor?: string;
|
|
17
16
|
minHeight?: number;
|
|
18
17
|
inverted?: boolean;
|
|
19
18
|
fontFamily?: string;
|
|
@@ -23,18 +22,19 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
23
22
|
placeholder?: string;
|
|
24
23
|
onFocus?: () => void;
|
|
25
24
|
autoScroll?: boolean;
|
|
26
|
-
activeColor?: string;
|
|
27
25
|
searchField?: keyof S;
|
|
26
|
+
iconColor?: ColorValue;
|
|
28
27
|
value?: S[] | undefined;
|
|
29
|
-
|
|
30
|
-
radioIconColor?: string;
|
|
28
|
+
activeColor?: ColorValue;
|
|
31
29
|
itemTestIDField?: string;
|
|
32
|
-
backgroundColor?: string;
|
|
33
30
|
keyboardAvoiding?: boolean;
|
|
34
31
|
searchPlaceholder?: string;
|
|
35
32
|
label?: string | undefined;
|
|
33
|
+
checkIconColor?: ColorValue;
|
|
34
|
+
radioIconColor?: ColorValue;
|
|
36
35
|
confirmSelectItem?: boolean;
|
|
37
36
|
accessibilityLabel?: string;
|
|
37
|
+
backgroundColor?: ColorValue;
|
|
38
38
|
style?: StyleProp<ViewStyle>;
|
|
39
39
|
selectedTextProps?: TextProps;
|
|
40
40
|
subfixIcon?: React.JSX.Element;
|
|
@@ -14,10 +14,10 @@ const AppDropdownController = (props) => {
|
|
|
14
14
|
const { styles } = (0, DropdownControllerStyle_1.useDropdownControllerStyle)();
|
|
15
15
|
return (<react_hook_form_1.Controller control={control} name={controller} render={({ fieldState: { error }, field: { onBlur, onChange, value }, }) => (<react_native_1.View style={styles.mainContainer}>
|
|
16
16
|
<Dropdown_1.default data={data} value={value} label={label} onBlur={onBlur} onChange={(selectValue, selectedItem) => {
|
|
17
|
-
if (selectionType === '
|
|
18
|
-
return onChange(
|
|
17
|
+
if (selectionType === 'multi') {
|
|
18
|
+
return onChange(selectedItem);
|
|
19
19
|
}
|
|
20
|
-
return onChange(
|
|
20
|
+
return onChange(selectValue);
|
|
21
21
|
}} labelField={labelField} valueField={valueField} placeholder={placeholder} selectionType={selectionType} containerStyle={containerStyle} labelTextStyle={styles.labelText} itemTextStyle={styles.dropdownText} placeholderStyle={styles.itemContainer} selectedTextStyle={styles.selectionText} style={[styles.dropdownContainer, error && styles.errorWrapper]} {...rest}/>
|
|
22
22
|
{error && <AppText_1.default style={styles.error}>{error?.message}</AppText_1.default>}
|
|
23
23
|
</react_native_1.View>)}/>);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rn-components-dropdown/dropdown",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -15,12 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"react",
|
|
18
|
+
"dropdown",
|
|
18
19
|
"react-native",
|
|
20
|
+
"rn-components",
|
|
19
21
|
"react-components"
|
|
20
22
|
],
|
|
21
|
-
"author": "",
|
|
22
|
-
"license": "
|
|
23
|
-
"description": "",
|
|
23
|
+
"author": "Himmat Suthar",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"description": "Package use for dropdown for single and multi selection with radio and checkbox",
|
|
24
26
|
"devDependencies": {
|
|
25
27
|
"@types/lodash": "^4.17.20",
|
|
26
28
|
"@types/react": "^19.2.2",
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Svg, { Path, Mask, Rect, G } from "react-native-svg";
|
|
3
|
+
import { SvgInterface } from "../../interface/svg.interface";
|
|
3
4
|
|
|
4
|
-
const ArrowDown = ({ size = 16, color = "black" }) => (
|
|
5
|
+
const ArrowDown = ({ size = 16, color = "black" }: SvgInterface) => (
|
|
5
6
|
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
6
7
|
<Mask
|
|
7
8
|
id="mask0_2371_2505"
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
DEFAULT_COLORS,
|
|
6
6
|
} from '../../style';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
|
-
import { I18nManager, StyleSheet } from 'react-native';
|
|
8
|
+
import { ColorValue, I18nManager, StyleSheet } from 'react-native';
|
|
9
9
|
import { useDeviceOrientation } from './hooks/useOrientation';
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
size?: number;
|
|
13
|
-
radioIconColor?:
|
|
14
|
-
checkIconColor?:
|
|
13
|
+
radioIconColor?: ColorValue;
|
|
14
|
+
checkIconColor?: ColorValue;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const useDropdownStyle = (props: Props) => {
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
TextProps,
|
|
7
7
|
ImageStyle,
|
|
8
8
|
FlatListProps,
|
|
9
|
+
ColorValue,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import { ChipInterface } from './ChipInterface';
|
|
11
12
|
|
|
@@ -23,7 +24,6 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
23
24
|
disable?: boolean;
|
|
24
25
|
selectionType?: T;
|
|
25
26
|
maxHeight?: number;
|
|
26
|
-
iconColor?: string;
|
|
27
27
|
minHeight?: number;
|
|
28
28
|
inverted?: boolean;
|
|
29
29
|
fontFamily?: string;
|
|
@@ -33,18 +33,19 @@ export type DropdownProps<S, T extends SelectionType> = {
|
|
|
33
33
|
placeholder?: string;
|
|
34
34
|
onFocus?: () => void;
|
|
35
35
|
autoScroll?: boolean;
|
|
36
|
-
activeColor?: string;
|
|
37
36
|
searchField?: keyof S;
|
|
37
|
+
iconColor?: ColorValue;
|
|
38
38
|
value?: S[] | undefined;
|
|
39
|
-
|
|
40
|
-
radioIconColor?: string;
|
|
39
|
+
activeColor?: ColorValue;
|
|
41
40
|
itemTestIDField?: string;
|
|
42
|
-
backgroundColor?: string;
|
|
43
41
|
keyboardAvoiding?: boolean;
|
|
44
42
|
searchPlaceholder?: string;
|
|
45
43
|
label?: string | undefined;
|
|
44
|
+
checkIconColor?: ColorValue;
|
|
45
|
+
radioIconColor?: ColorValue;
|
|
46
46
|
confirmSelectItem?: boolean;
|
|
47
47
|
accessibilityLabel?: string;
|
|
48
|
+
backgroundColor?: ColorValue;
|
|
48
49
|
style?: StyleProp<ViewStyle>;
|
|
49
50
|
selectedTextProps?: TextProps;
|
|
50
51
|
subfixIcon?: React.JSX.Element;
|
|
@@ -54,10 +54,10 @@ const AppDropdownController = <
|
|
|
54
54
|
label={label}
|
|
55
55
|
onBlur={onBlur}
|
|
56
56
|
onChange={(selectValue: any, selectedItem: any) => {
|
|
57
|
-
if (selectionType === '
|
|
58
|
-
return onChange(
|
|
57
|
+
if (selectionType === 'multi') {
|
|
58
|
+
return onChange(selectedItem);
|
|
59
59
|
}
|
|
60
|
-
return onChange(
|
|
60
|
+
return onChange(selectValue);
|
|
61
61
|
}}
|
|
62
62
|
labelField={labelField}
|
|
63
63
|
valueField={valueField}
|
package/src/style/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './colors';
|
|
2
2
|
export * from './spacing';
|
|
3
3
|
export * from './shadow';
|
|
4
|
-
import { Dimensions
|
|
4
|
+
import { Dimensions } from 'react-native';
|
|
5
5
|
|
|
6
6
|
export const SCREEN_WIDTH = Dimensions.get('window').width;
|
|
7
7
|
export const SCREEN_HEIGHT = Dimensions.get('window').height;
|