@rn-components-dropdown/dropdown 1.0.13 → 1.0.15

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.
Files changed (37) hide show
  1. package/dist/assets/svg/ArrowDown.d.ts +2 -4
  2. package/dist/components/dropdown/Dropdown.js +4 -4
  3. package/dist/components/dropdown/DropdownStyle.d.ts +6 -6
  4. package/dist/components/dropdown/DropdownStyle.js +1 -1
  5. package/dist/components/dropdown/component/chip/Chip.d.ts +3 -0
  6. package/dist/components/dropdown/component/chip/Chip.js +23 -0
  7. package/dist/components/dropdown/component/chip/ChipStyle.d.ts +83 -0
  8. package/dist/components/dropdown/component/chip/ChipStyle.js +62 -0
  9. package/dist/components/dropdown/component/input/TextInput.d.ts +3 -0
  10. package/dist/components/dropdown/component/input/TextInput.js +61 -0
  11. package/dist/components/dropdown/component/input/TextInputStyle.d.ts +32 -0
  12. package/dist/components/dropdown/component/input/TextInputStyle.js +33 -0
  13. package/dist/components/dropdown/interface/ChipInterface.d.ts +3 -3
  14. package/dist/components/dropdown/interface/DropdownInterface.d.ts +6 -7
  15. package/dist/components/text/AppText.d.ts +2 -3
  16. package/dist/components/text/AppText.js +1 -1
  17. package/dist/components/text/AppTextStyle.d.ts +18 -19
  18. package/dist/components/text/AppTextStyle.js +1 -5
  19. package/dist/controller/dropDownController/DropdownController.js +4 -4
  20. package/dist/interface/svg.interface.d.ts +2 -1
  21. package/dist/style/index.d.ts +0 -2
  22. package/dist/style/index.js +1 -7
  23. package/package.json +1 -1
  24. package/src/assets/svg/ArrowDown.tsx +2 -1
  25. package/src/components/dropdown/Dropdown.tsx +4 -4
  26. package/src/components/dropdown/DropdownStyle.ts +7 -8
  27. package/src/components/dropdown/{components → component}/chip/Chip.tsx +1 -1
  28. package/src/components/dropdown/{components → component}/chip/ChipStyle.ts +3 -3
  29. package/src/components/dropdown/interface/ChipInterface.ts +3 -3
  30. package/src/components/dropdown/interface/DropdownInterface.ts +6 -6
  31. package/src/components/text/AppText.tsx +2 -3
  32. package/src/components/text/AppTextStyle.ts +3 -9
  33. package/src/controller/dropDownController/DropdownController.tsx +3 -4
  34. package/src/interface/svg.interface.ts +3 -1
  35. package/src/style/index.ts +1 -8
  36. /package/src/components/dropdown/{components → component}/input/TextInput.tsx +0 -0
  37. /package/src/components/dropdown/{components → component}/input/TextInputStyle.ts +0 -0
@@ -1,6 +1,4 @@
1
1
  import React from "react";
2
- declare const ArrowDown: ({ size, color }: {
3
- size?: number | undefined;
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;
@@ -40,14 +40,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  const react_native_1 = require("react-native");
41
41
  const lodash_1 = __importDefault(require("lodash"));
42
42
  const AppText_1 = __importDefault(require("../text/AppText"));
43
- const Chip_1 = __importDefault(require("./components/chip/Chip"));
43
+ const Chip_1 = __importDefault(require("./component/chip/Chip"));
44
44
  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
48
  const CheckIcon_1 = __importDefault(require("../../assets/svg/CheckIcon"));
49
49
  const svg_1 = require("../../assets/svg");
50
- const TextInput_1 = __importDefault(require("./components/input/TextInput"));
50
+ const TextInput_1 = __importDefault(require("./component/input/TextInput"));
51
51
  const DropdownComponent = (props) => {
52
52
  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, backgroundColor, 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;
53
53
  const { chipColor, clearIcon, textColor, onClearPress: onClear, } = chipContainerProps;
@@ -99,7 +99,7 @@ const DropdownComponent = (props) => {
99
99
  }, [styles]);
100
100
  const renderCheckItem = (0, react_1.useCallback)(({ item, index }) => {
101
101
  const isSelected = lodash_1.default.some(currentValue, (h) => lodash_1.default.isEqual(lodash_1.default.get(h, valueField), lodash_1.default.get(item, valueField)));
102
- 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)}>
102
+ 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={activeColor} onPress={() => onCheckPress(item)}>
103
103
  <react_native_1.View style={react_native_1.StyleSheet.flatten([itemContainerStyle])}>
104
104
  {renderItem ? (renderItem(item, isSelected, labelField, valueField)) : (<react_native_1.View style={styles.item}>
105
105
  <SvgButton_1.default icon={multiSelectIcon ? (multiSelectIcon) : (<CheckIcon_1.default color={colors.white}/>)} onPress={() => onCheckPress(item)} style={[
@@ -141,7 +141,7 @@ const DropdownComponent = (props) => {
141
141
  const isSelected = currentValue && lodash_1.default.get(currentValue, valueField);
142
142
  const selected = lodash_1.default.isEqual(lodash_1.default.get(item, valueField), isSelected);
143
143
  lodash_1.default.assign(item, { _index: index });
144
- 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={() => onSelect(item)}>
144
+ 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={activeColor} onPress={() => onSelect(item)}>
145
145
  <react_native_1.View style={react_native_1.StyleSheet.flatten([itemContainerStyle])}>
146
146
  {renderItem ? (renderItem(item, selected, labelField, valueField)) : (<react_native_1.View style={styles.item}>
147
147
  {renderRadio(selected)}
@@ -1,8 +1,8 @@
1
- import { ThemeColors } from '../../interface/colors.interface';
1
+ import { ColorValue } from 'react-native';
2
2
  interface Props {
3
3
  size?: number;
4
- radioIconColor?: keyof ThemeColors;
5
- checkIconColor?: keyof ThemeColors;
4
+ radioIconColor?: ColorValue;
5
+ checkIconColor?: ColorValue;
6
6
  }
7
7
  export declare const useDropdownStyle: (props: Props) => {
8
8
  styles: {
@@ -98,13 +98,13 @@ export declare const useDropdownStyle: (props: Props) => {
98
98
  alignItems: "center";
99
99
  justifyContent: "center";
100
100
  padding: number;
101
- borderColor: string;
101
+ borderColor: ColorValue;
102
102
  };
103
103
  iconSubContainer: {
104
104
  width: "100%";
105
105
  height: "100%";
106
106
  borderRadius: number;
107
- backgroundColor: string;
107
+ backgroundColor: ColorValue;
108
108
  };
109
109
  styleHorizontal: {
110
110
  width: number | "100%";
@@ -122,7 +122,7 @@ export declare const useDropdownStyle: (props: Props) => {
122
122
  height: number;
123
123
  alignItems: "center";
124
124
  justifyContent: "center";
125
- borderColor: string;
125
+ borderColor: ColorValue;
126
126
  };
127
127
  showMultiSelectContainer: {
128
128
  width: "90%";
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDropdownStyle = void 0;
4
+ const style_1 = require("../../style");
4
5
  const react_1 = require("react");
5
6
  const react_native_1 = require("react-native");
6
7
  const useOrientation_1 = require("./hooks/useOrientation");
7
- const style_1 = require("../../style");
8
8
  const useDropdownStyle = (props) => {
9
9
  const { ...colors } = style_1.LIGHT_COLORS;
10
10
  const orientation = (0, useOrientation_1.useDeviceOrientation)();
@@ -0,0 +1,3 @@
1
+ import { ChipInterface } from '../../interface/ChipInterface';
2
+ declare const Chip: (props: ChipInterface) => import("react").JSX.Element;
3
+ export default Chip;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_native_1 = require("react-native");
7
+ const ChipStyle_1 = __importDefault(require("./ChipStyle"));
8
+ const AppText_1 = __importDefault(require("../../../text/AppText"));
9
+ const svg_1 = require("../../../../assets/svg");
10
+ const SvgButton_1 = __importDefault(require("../../../svgButton/SvgButton"));
11
+ const Chip = (props) => {
12
+ const { styles, colors } = (0, ChipStyle_1.default)({ ...props });
13
+ const { label, onClearPress, textColor, clearIcon } = props;
14
+ return (<react_native_1.View style={styles.box}>
15
+ <AppText_1.default size={12} fontFamily={'semiBold'} style={styles.chipText} color={textColor ? textColor : 'gray'}>
16
+ {label}
17
+ </AppText_1.default>
18
+ {clearIcon ? (clearIcon) : (<react_native_1.View style={styles.clearContainer}>
19
+ <SvgButton_1.default icon={<svg_1.ClearIcon size={8} color={textColor ? textColor : colors.white}/>} onPress={onClearPress} style={styles.clearIcon}/>
20
+ </react_native_1.View>)}
21
+ </react_native_1.View>);
22
+ };
23
+ exports.default = Chip;
@@ -0,0 +1,83 @@
1
+ import { ChipInterface } from '../../interface/ChipInterface';
2
+ declare const useChipStyle: (props: ChipInterface) => {
3
+ styles: {
4
+ box: {
5
+ elevation: number;
6
+ width: "auto";
7
+ borderRadius: number;
8
+ flexDirection: "row";
9
+ alignItems: "center";
10
+ justifyContent: "center";
11
+ backgroundColor: import("react-native").ColorValue;
12
+ margin: number;
13
+ height: number;
14
+ } | {
15
+ elevation: number;
16
+ width: "auto";
17
+ borderRadius: number;
18
+ flexDirection: "row";
19
+ alignItems: "center";
20
+ justifyContent: "center";
21
+ backgroundColor: import("react-native").ColorValue;
22
+ shadowRadius?: undefined;
23
+ shadowOpacity?: undefined;
24
+ shadowColor?: undefined;
25
+ shadowOffset?: undefined;
26
+ margin: number;
27
+ height: number;
28
+ } | {
29
+ elevation: number;
30
+ width: "auto";
31
+ borderRadius: number;
32
+ flexDirection: "row";
33
+ alignItems: "center";
34
+ justifyContent: "center";
35
+ backgroundColor: import("react-native").ColorValue;
36
+ shadowRadius: number;
37
+ shadowOpacity: number;
38
+ shadowColor: string;
39
+ shadowOffset: {
40
+ width: number;
41
+ height: number;
42
+ };
43
+ margin: number;
44
+ height: number;
45
+ };
46
+ chipText: {
47
+ paddingLeft: number;
48
+ fontWeight: "600";
49
+ };
50
+ clearContainer: {
51
+ width: number;
52
+ height: number;
53
+ borderWidth: number;
54
+ borderRadius: number;
55
+ marginHorizontal: number;
56
+ alignItems: "center";
57
+ justifyContent: "center";
58
+ borderColor: import("react-native").ColorValue;
59
+ backgroundColor: import("react-native").ColorValue;
60
+ };
61
+ clearIcon: {
62
+ width: number;
63
+ height: number;
64
+ borderRadius: number;
65
+ alignItems: "center";
66
+ justifyContent: "center";
67
+ };
68
+ };
69
+ colors: {
70
+ blue: string;
71
+ gray: string;
72
+ error: string;
73
+ green: string;
74
+ white: string;
75
+ black: string;
76
+ primary: string;
77
+ lightGray: string;
78
+ grayishBlue: string;
79
+ red: string;
80
+ border: string;
81
+ };
82
+ };
83
+ export default useChipStyle;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ const style_1 = require("../../../../style");
5
+ const react_native_1 = require("react-native");
6
+ const useChipStyle = (props) => {
7
+ const { chipColor, textColor } = props;
8
+ const { ...colors } = style_1.LIGHT_COLORS;
9
+ const styles = (0, react_1.useMemo)(() => {
10
+ return react_native_1.StyleSheet.create({
11
+ box: {
12
+ margin: 4,
13
+ height: 26,
14
+ ...react_native_1.Platform.select({
15
+ android: {
16
+ elevation: 5,
17
+ },
18
+ ios: {
19
+ shadowRadius: 1.84,
20
+ shadowOpacity: 0.35,
21
+ shadowColor: colors.black,
22
+ shadowOffset: { width: 0, height: 2 },
23
+ },
24
+ }),
25
+ elevation: 5,
26
+ width: 'auto',
27
+ borderRadius: 30,
28
+ flexDirection: 'row',
29
+ alignItems: 'center',
30
+ justifyContent: 'center',
31
+ backgroundColor: chipColor ? chipColor : colors.lightGray,
32
+ },
33
+ chipText: {
34
+ paddingLeft: 10,
35
+ fontWeight: '600',
36
+ },
37
+ clearContainer: {
38
+ width: 18,
39
+ height: 18,
40
+ borderWidth: 2,
41
+ borderRadius: 100,
42
+ marginHorizontal: 4,
43
+ alignItems: 'center',
44
+ justifyContent: 'center',
45
+ borderColor: textColor ? textColor : colors.white,
46
+ backgroundColor: chipColor ? chipColor : colors.lightGray,
47
+ },
48
+ clearIcon: {
49
+ width: 12,
50
+ height: 12,
51
+ borderRadius: 100,
52
+ alignItems: 'center',
53
+ justifyContent: 'center',
54
+ },
55
+ });
56
+ }, [chipColor, colors, textColor]);
57
+ return {
58
+ styles,
59
+ colors,
60
+ };
61
+ };
62
+ exports.default = useChipStyle;
@@ -0,0 +1,3 @@
1
+ import type { CTextInput } from '../../interface/InputProps';
2
+ declare const TextInputComponent: CTextInput;
3
+ export default TextInputComponent;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const TextInputStyle_1 = require("./TextInputStyle");
40
+ const react_1 = __importStar(require("react"));
41
+ const svg_1 = require("../../../../assets/svg");
42
+ const react_native_1 = require("react-native");
43
+ const AppTextInput_1 = __importDefault(require("../../../textInput/AppTextInput"));
44
+ const TextInputComponent = props => {
45
+ const { value, placeholder = '', placeholderTextColor = '#000', onChangeText = (_value) => { }, searchIcon, } = props;
46
+ const [searchtext, setSearchText] = (0, react_1.useState)('');
47
+ const { styles } = (0, TextInputStyle_1.useTextStyle)();
48
+ (0, react_1.useEffect)(() => {
49
+ if (value) {
50
+ setSearchText(value);
51
+ }
52
+ }, [value]);
53
+ const onChange = (text) => {
54
+ setSearchText(text);
55
+ onChangeText(text);
56
+ };
57
+ return (<react_native_1.TouchableWithoutFeedback>
58
+ <AppTextInput_1.default {...props} value={searchtext} style={styles.input} onChangeText={onChange} placeholder={placeholder} textStyle={styles.inputContainer} placeholderTextColor={placeholderTextColor} icon={searchIcon ? searchIcon : <svg_1.SearchIcon />}/>
59
+ </react_native_1.TouchableWithoutFeedback>);
60
+ };
61
+ exports.default = TextInputComponent;
@@ -0,0 +1,32 @@
1
+ export declare const useTextStyle: () => {
2
+ styles: {
3
+ input: {
4
+ height: number;
5
+ width: "95%";
6
+ fontSize: number;
7
+ borderWidth: number;
8
+ borderRadius: number;
9
+ marginVertical: number;
10
+ marginHorizontal: number;
11
+ borderColor: string;
12
+ };
13
+ inputContainer: {
14
+ width: "90%";
15
+ fontSize: number;
16
+ color: string;
17
+ };
18
+ };
19
+ colors: {
20
+ blue: string;
21
+ gray: string;
22
+ error: string;
23
+ green: string;
24
+ white: string;
25
+ black: string;
26
+ primary: string;
27
+ lightGray: string;
28
+ grayishBlue: string;
29
+ red: string;
30
+ border: string;
31
+ };
32
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTextStyle = void 0;
4
+ const react_1 = require("react");
5
+ const react_native_1 = require("react-native");
6
+ const style_1 = require("../../../../style");
7
+ const useTextStyle = () => {
8
+ const { ...colors } = style_1.LIGHT_COLORS;
9
+ const styles = (0, react_1.useMemo)(() => {
10
+ return react_native_1.StyleSheet.create({
11
+ input: {
12
+ height: 40,
13
+ width: '95%',
14
+ fontSize: 16,
15
+ borderWidth: 1,
16
+ borderRadius: 3,
17
+ marginVertical: 10,
18
+ marginHorizontal: 8,
19
+ borderColor: colors.border,
20
+ },
21
+ inputContainer: {
22
+ width: '90%',
23
+ fontSize: 14,
24
+ color: colors.gray,
25
+ },
26
+ });
27
+ }, [colors]);
28
+ return {
29
+ styles,
30
+ colors,
31
+ };
32
+ };
33
+ exports.useTextStyle = useTextStyle;
@@ -1,8 +1,8 @@
1
- import { ThemeColors } from '../../../interface/colors.interface';
1
+ import { ColorValue } from "react-native";
2
2
  export interface ChipInterface {
3
3
  label?: string;
4
+ chipColor?: ColorValue;
5
+ textColor?: ColorValue;
4
6
  onClearPress?: () => void;
5
- chipColor?: keyof ThemeColors;
6
- textColor?: keyof ThemeColors;
7
7
  clearIcon?: React.JSX.Element;
8
8
  }
@@ -1,7 +1,6 @@
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
- import { ThemeColors } from '../../../interface/colors.interface';
5
4
  export type IDropdownRef = {
6
5
  open: () => void;
7
6
  close: () => void;
@@ -14,7 +13,6 @@ export type DropdownProps<S, T extends SelectionType> = {
14
13
  disable?: boolean;
15
14
  selectionType?: T;
16
15
  maxHeight?: number;
17
- iconColor?: string;
18
16
  minHeight?: number;
19
17
  inverted?: boolean;
20
18
  fontFamily?: string;
@@ -25,23 +23,24 @@ export type DropdownProps<S, T extends SelectionType> = {
25
23
  onFocus?: () => void;
26
24
  autoScroll?: boolean;
27
25
  searchField?: keyof S;
26
+ iconColor?: ColorValue;
28
27
  value?: S[] | undefined;
28
+ activeColor?: ColorValue;
29
29
  itemTestIDField?: string;
30
- backgroundColor?: string;
31
30
  keyboardAvoiding?: boolean;
32
31
  searchPlaceholder?: string;
33
32
  label?: string | undefined;
33
+ checkIconColor?: ColorValue;
34
+ radioIconColor?: ColorValue;
34
35
  confirmSelectItem?: boolean;
35
36
  accessibilityLabel?: string;
37
+ backgroundColor?: ColorValue;
36
38
  style?: StyleProp<ViewStyle>;
37
39
  selectedTextProps?: TextProps;
38
40
  subfixIcon?: React.JSX.Element;
39
41
  onClear?: (id?: number) => void;
40
- activeColor?: keyof ThemeColors;
41
42
  iconStyle?: StyleProp<ImageStyle>;
42
43
  chipContainerProps?: ChipInterface;
43
- checkIconColor?: keyof ThemeColors;
44
- radioIconColor?: keyof ThemeColors;
45
44
  multiSelectIcon?: React.JSX.Element;
46
45
  mode?: 'default' | 'modal' | 'auto';
47
46
  itemTextStyle?: StyleProp<TextStyle>;
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
- import { TextProps } from 'react-native';
3
- import { ThemeColors } from '../../interface/colors.interface';
2
+ import { ColorValue, TextProps } from 'react-native';
4
3
  interface props extends TextProps {
5
4
  size?: number;
6
5
  fontFamily?: any;
7
6
  required?: boolean;
8
- color?: keyof ThemeColors;
7
+ color?: ColorValue;
9
8
  type?: 'error' | 'normal';
10
9
  }
11
10
  declare const AppText: ({ size, style, color, children, type, fontFamily, required, ...props }: props) => React.JSX.Element;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const react_native_1 = require("react-native");
8
7
  const AppTextStyle_1 = require("./AppTextStyle");
8
+ const react_native_1 = require("react-native");
9
9
  const AppText = ({ size, style, color, children, type = 'normal', fontFamily = 'regular', required, ...props }) => {
10
10
  const family = fontFamily;
11
11
  const styles = (0, AppTextStyle_1.useAppTextStyle)({
@@ -1,14 +1,13 @@
1
- import { TextStyle } from 'react-native';
2
- import { ThemeColors } from '../../interface/colors.interface';
1
+ import { ColorValue, TextStyle } from 'react-native';
3
2
  interface props {
4
3
  size?: number;
5
4
  style?: TextStyle;
6
- color?: keyof ThemeColors;
5
+ color?: ColorValue;
7
6
  type?: 'error' | 'normal';
8
7
  }
9
8
  export declare const useAppTextStyle: ({ size, style, color, type, }: props) => {
10
9
  container: {
11
- color: import("react-native").ColorValue;
10
+ color: ColorValue;
12
11
  fontFamily?: string | undefined;
13
12
  fontSize: number;
14
13
  fontStyle?: "normal" | "italic" | undefined;
@@ -18,8 +17,8 @@ export declare const useAppTextStyle: ({ size, style, color, type, }: props) =>
18
17
  textAlign?: "auto" | "left" | "right" | "center" | "justify" | undefined;
19
18
  textDecorationLine?: "none" | "underline" | "line-through" | "underline line-through" | undefined;
20
19
  textDecorationStyle?: "solid" | "double" | "dotted" | "dashed" | undefined;
21
- textDecorationColor?: import("react-native").ColorValue | undefined;
22
- textShadowColor?: import("react-native").ColorValue | undefined;
20
+ textDecorationColor?: ColorValue | undefined;
21
+ textShadowColor?: ColorValue | undefined;
23
22
  textShadowOffset?: {
24
23
  width: number;
25
24
  height: number;
@@ -30,33 +29,33 @@ export declare const useAppTextStyle: ({ size, style, color, type, }: props) =>
30
29
  fontVariant?: import("react-native").FontVariant[] | undefined;
31
30
  writingDirection?: "auto" | "ltr" | "rtl" | undefined;
32
31
  backfaceVisibility?: "visible" | "hidden" | undefined;
33
- backgroundColor?: import("react-native").ColorValue | undefined;
34
- borderBlockColor?: import("react-native").ColorValue | undefined;
35
- borderBlockEndColor?: import("react-native").ColorValue | undefined;
36
- borderBlockStartColor?: import("react-native").ColorValue | undefined;
37
- borderBottomColor?: import("react-native").ColorValue | undefined;
32
+ backgroundColor?: ColorValue | undefined;
33
+ borderBlockColor?: ColorValue | undefined;
34
+ borderBlockEndColor?: ColorValue | undefined;
35
+ borderBlockStartColor?: ColorValue | undefined;
36
+ borderBottomColor?: ColorValue | undefined;
38
37
  borderBottomEndRadius?: import("react-native").AnimatableNumericValue | string | undefined;
39
38
  borderBottomLeftRadius?: import("react-native").AnimatableNumericValue | string | undefined;
40
39
  borderBottomRightRadius?: import("react-native").AnimatableNumericValue | string | undefined;
41
40
  borderBottomStartRadius?: import("react-native").AnimatableNumericValue | string | undefined;
42
- borderColor?: import("react-native").ColorValue | undefined;
41
+ borderColor?: ColorValue | undefined;
43
42
  borderCurve?: "circular" | "continuous" | undefined;
44
- borderEndColor?: import("react-native").ColorValue | undefined;
43
+ borderEndColor?: ColorValue | undefined;
45
44
  borderEndEndRadius?: import("react-native").AnimatableNumericValue | string | undefined;
46
45
  borderEndStartRadius?: import("react-native").AnimatableNumericValue | string | undefined;
47
- borderLeftColor?: import("react-native").ColorValue | undefined;
46
+ borderLeftColor?: ColorValue | undefined;
48
47
  borderRadius?: import("react-native").AnimatableNumericValue | string | undefined;
49
- borderRightColor?: import("react-native").ColorValue | undefined;
50
- borderStartColor?: import("react-native").ColorValue | undefined;
48
+ borderRightColor?: ColorValue | undefined;
49
+ borderStartColor?: ColorValue | undefined;
51
50
  borderStartEndRadius?: import("react-native").AnimatableNumericValue | string | undefined;
52
51
  borderStartStartRadius?: import("react-native").AnimatableNumericValue | string | undefined;
53
52
  borderStyle?: "solid" | "dotted" | "dashed" | undefined;
54
- borderTopColor?: import("react-native").ColorValue | undefined;
53
+ borderTopColor?: ColorValue | undefined;
55
54
  borderTopEndRadius?: import("react-native").AnimatableNumericValue | string | undefined;
56
55
  borderTopLeftRadius?: import("react-native").AnimatableNumericValue | string | undefined;
57
56
  borderTopRightRadius?: import("react-native").AnimatableNumericValue | string | undefined;
58
57
  borderTopStartRadius?: import("react-native").AnimatableNumericValue | string | undefined;
59
- outlineColor?: import("react-native").ColorValue | undefined;
58
+ outlineColor?: ColorValue | undefined;
60
59
  outlineOffset?: import("react-native").AnimatableNumericValue | undefined;
61
60
  outlineStyle?: "solid" | "dotted" | "dashed" | undefined;
62
61
  outlineWidth?: import("react-native").AnimatableNumericValue | undefined;
@@ -145,7 +144,7 @@ export declare const useAppTextStyle: ({ size, style, color, type, }: props) =>
145
144
  paddingInline?: import("react-native").DimensionValue | undefined;
146
145
  paddingInlineEnd?: import("react-native").DimensionValue | undefined;
147
146
  paddingInlineStart?: import("react-native").DimensionValue | undefined;
148
- shadowColor?: import("react-native").ColorValue | undefined;
147
+ shadowColor?: ColorValue | undefined;
149
148
  shadowOffset?: Readonly<{
150
149
  width: number;
151
150
  height: number;
@@ -10,11 +10,7 @@ const useAppTextStyle = ({ size, style, color, type = 'normal', }) => {
10
10
  return react_native_1.StyleSheet.create({
11
11
  container: {
12
12
  fontSize: size || 14,
13
- color: type === 'error'
14
- ? colors.error
15
- : color
16
- ? colors[color]
17
- : colors.primary,
13
+ color: type === 'error' ? colors.error : color ? color : colors.primary,
18
14
  ...style,
19
15
  },
20
16
  require: {
@@ -14,11 +14,11 @@ 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 === 'single') {
18
- return onChange(selectValue);
17
+ if (selectionType === 'multi') {
18
+ return onChange(selectedItem);
19
19
  }
20
- return onChange(selectedItem);
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}/>
20
+ return onChange(selectValue);
21
+ }} labelField={labelField} valueField={valueField} placeholder={placeholder} 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>)}/>);
24
24
  };
@@ -1,4 +1,5 @@
1
+ import { ColorValue } from "react-native";
1
2
  export interface SvgInterface {
2
3
  size?: number;
3
- color?: string;
4
+ color?: ColorValue;
4
5
  }
@@ -1,7 +1,5 @@
1
1
  export * from './colors';
2
2
  export * from './spacing';
3
3
  export * from './shadow';
4
- export declare const addAlphaToHex: (color: string, opacity: number) => string;
5
4
  export declare const SCREEN_WIDTH: number;
6
5
  export declare const SCREEN_HEIGHT: number;
7
- export declare const MIN_DEVICE_WIDTH: number;
@@ -14,16 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MIN_DEVICE_WIDTH = exports.SCREEN_HEIGHT = exports.SCREEN_WIDTH = exports.addAlphaToHex = void 0;
17
+ exports.SCREEN_HEIGHT = exports.SCREEN_WIDTH = void 0;
18
18
  __exportStar(require("./colors"), exports);
19
19
  __exportStar(require("./spacing"), exports);
20
20
  __exportStar(require("./shadow"), exports);
21
21
  const react_native_1 = require("react-native");
22
- const addAlphaToHex = (color, opacity) => {
23
- const _opacity = Math.round(Math.min(Math.max(opacity || 1, 0), 1) * 255);
24
- return color + _opacity.toString(16).toUpperCase();
25
- };
26
- exports.addAlphaToHex = addAlphaToHex;
27
22
  exports.SCREEN_WIDTH = react_native_1.Dimensions.get('window').width;
28
23
  exports.SCREEN_HEIGHT = react_native_1.Dimensions.get('window').height;
29
- exports.MIN_DEVICE_WIDTH = react_native_1.Platform.OS === 'ios' ? 390 : 360;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rn-components-dropdown/dropdown",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -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"
@@ -11,14 +11,14 @@ import {
11
11
  } from 'react-native';
12
12
  import _ from 'lodash';
13
13
  import AppText from '../text/AppText';
14
- import Chip from './components/chip/Chip';
14
+ import Chip from './component/chip/Chip';
15
15
  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
19
  import CheckIcon from '../../assets/svg/CheckIcon';
20
20
  import { ArrowDown, ArrowUp } from '../../assets/svg';
21
- import SearchInput from './components/input/TextInput';
21
+ import SearchInput from './component/input/TextInput';
22
22
  import { DropdownProps } from './interface/DropdownInterface';
23
23
 
24
24
  const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
@@ -207,7 +207,7 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
207
207
  item,
208
208
  itemAccessibilityLabelField || labelField,
209
209
  )}
210
- underlayColor={colors[activeColor]}
210
+ underlayColor={activeColor}
211
211
  onPress={() => onCheckPress(item)}
212
212
  >
213
213
  <View style={StyleSheet.flatten([itemContainerStyle])}>
@@ -281,7 +281,7 @@ const DropdownComponent = <T, Mode extends 'single' | 'multi'>(
281
281
  item,
282
282
  itemAccessibilityLabelField || labelField,
283
283
  )}
284
- underlayColor={colors[activeColor]}
284
+ underlayColor={activeColor}
285
285
  onPress={() => onSelect(item)}
286
286
  >
287
287
  <View style={StyleSheet.flatten([itemContainerStyle])}>
@@ -1,18 +1,17 @@
1
- import { useMemo } from 'react';
2
- import { I18nManager, StyleSheet } from 'react-native';
3
- import { useDeviceOrientation } from './hooks/useOrientation';
4
- import { ThemeColors } from '../../interface/colors.interface';
5
1
  import {
6
- DEFAULT_COLORS,
7
- SCREEN_WIDTH,
8
2
  SPACING,
9
3
  LIGHT_COLORS,
4
+ SCREEN_WIDTH,
5
+ DEFAULT_COLORS,
10
6
  } from '../../style';
7
+ import { useMemo } from 'react';
8
+ import { ColorValue, I18nManager, StyleSheet } from 'react-native';
9
+ import { useDeviceOrientation } from './hooks/useOrientation';
11
10
 
12
11
  interface Props {
13
12
  size?: number;
14
- radioIconColor?: keyof ThemeColors;
15
- checkIconColor?: keyof ThemeColors;
13
+ radioIconColor?: ColorValue;
14
+ checkIconColor?: ColorValue;
16
15
  }
17
16
 
18
17
  export const useDropdownStyle = (props: Props) => {
@@ -26,7 +26,7 @@ const Chip = (props: ChipInterface) => {
26
26
  icon={
27
27
  <ClearIcon
28
28
  size={8}
29
- color={textColor ? colors[textColor] : colors.white}
29
+ color={textColor ? textColor : colors.white}
30
30
  />
31
31
  }
32
32
  onPress={onClearPress}
@@ -28,7 +28,7 @@ const useChipStyle = (props: ChipInterface) => {
28
28
  flexDirection: 'row',
29
29
  alignItems: 'center',
30
30
  justifyContent: 'center',
31
- backgroundColor: chipColor ? colors[chipColor] : colors.lightGray,
31
+ backgroundColor: chipColor ? chipColor : colors.lightGray,
32
32
  },
33
33
  chipText: {
34
34
  paddingLeft: 10,
@@ -42,8 +42,8 @@ const useChipStyle = (props: ChipInterface) => {
42
42
  marginHorizontal: 4,
43
43
  alignItems: 'center',
44
44
  justifyContent: 'center',
45
- borderColor: textColor ? colors[textColor] : colors.white,
46
- backgroundColor: chipColor ? colors[chipColor] : colors.lightGray,
45
+ borderColor: textColor ? textColor : colors.white,
46
+ backgroundColor: chipColor ? chipColor : colors.lightGray,
47
47
  },
48
48
  clearIcon: {
49
49
  width: 12,
@@ -1,9 +1,9 @@
1
- import { ThemeColors } from '../../../interface/colors.interface';
1
+ import { ColorValue } from "react-native";
2
2
 
3
3
  export interface ChipInterface {
4
4
  label?: string;
5
+ chipColor?: ColorValue;
6
+ textColor?: ColorValue;
5
7
  onClearPress?: () => void;
6
- chipColor?: keyof ThemeColors;
7
- textColor?: keyof ThemeColors;
8
8
  clearIcon?: React.JSX.Element;
9
9
  }
@@ -6,9 +6,9 @@ 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
- import { ThemeColors } from '../../../interface/colors.interface';
12
12
 
13
13
  export type IDropdownRef = {
14
14
  open: () => void;
@@ -24,7 +24,6 @@ export type DropdownProps<S, T extends SelectionType> = {
24
24
  disable?: boolean;
25
25
  selectionType?: T;
26
26
  maxHeight?: number;
27
- iconColor?: string;
28
27
  minHeight?: number;
29
28
  inverted?: boolean;
30
29
  fontFamily?: string;
@@ -35,23 +34,24 @@ export type DropdownProps<S, T extends SelectionType> = {
35
34
  onFocus?: () => void;
36
35
  autoScroll?: boolean;
37
36
  searchField?: keyof S;
37
+ iconColor?: ColorValue;
38
38
  value?: S[] | undefined;
39
+ activeColor?: ColorValue;
39
40
  itemTestIDField?: string;
40
- backgroundColor?: string;
41
41
  keyboardAvoiding?: boolean;
42
42
  searchPlaceholder?: string;
43
43
  label?: string | undefined;
44
+ checkIconColor?: ColorValue;
45
+ radioIconColor?: ColorValue;
44
46
  confirmSelectItem?: boolean;
45
47
  accessibilityLabel?: string;
48
+ backgroundColor?: ColorValue;
46
49
  style?: StyleProp<ViewStyle>;
47
50
  selectedTextProps?: TextProps;
48
51
  subfixIcon?: React.JSX.Element;
49
52
  onClear?: (id?: number) => void;
50
- activeColor?: keyof ThemeColors;
51
53
  iconStyle?: StyleProp<ImageStyle>;
52
54
  chipContainerProps?: ChipInterface;
53
- checkIconColor?: keyof ThemeColors;
54
- radioIconColor?: keyof ThemeColors;
55
55
  multiSelectIcon?: React.JSX.Element;
56
56
  mode?: 'default' | 'modal' | 'auto';
57
57
  itemTextStyle?: StyleProp<TextStyle>;
@@ -1,13 +1,12 @@
1
1
  import React from 'react';
2
- import { Text, TextProps } from 'react-native';
3
2
  import { useAppTextStyle } from './AppTextStyle';
4
- import { ThemeColors } from '../../interface/colors.interface';
3
+ import { ColorValue, Text, TextProps } from 'react-native';
5
4
 
6
5
  interface props extends TextProps {
7
6
  size?: number;
8
7
  fontFamily?: any;
9
8
  required?: boolean;
10
- color?: keyof ThemeColors;
9
+ color?: ColorValue;
11
10
  type?: 'error' | 'normal';
12
11
  }
13
12
 
@@ -1,12 +1,11 @@
1
1
  import { useMemo } from 'react';
2
2
  import { LIGHT_COLORS } from '../../style';
3
- import { StyleSheet, TextStyle } from 'react-native';
4
- import { ThemeColors } from '../../interface/colors.interface';
3
+ import { ColorValue, StyleSheet, TextStyle } from 'react-native';
5
4
 
6
5
  interface props {
7
6
  size?: number;
8
7
  style?: TextStyle;
9
- color?: keyof ThemeColors;
8
+ color?: ColorValue;
10
9
  type?: 'error' | 'normal';
11
10
  }
12
11
 
@@ -22,12 +21,7 @@ export const useAppTextStyle = ({
22
21
  return StyleSheet.create({
23
22
  container: {
24
23
  fontSize: size || 14,
25
- color:
26
- type === 'error'
27
- ? colors.error
28
- : color
29
- ? colors[color]
30
- : colors.primary,
24
+ color: type === 'error' ? colors.error : color ? color : colors.primary,
31
25
  ...style,
32
26
  },
33
27
  require: {
@@ -54,15 +54,14 @@ const AppDropdownController = <
54
54
  label={label}
55
55
  onBlur={onBlur}
56
56
  onChange={(selectValue: any, selectedItem: any) => {
57
- if (selectionType === 'single') {
58
- return onChange(selectValue);
57
+ if (selectionType === 'multi') {
58
+ return onChange(selectedItem);
59
59
  }
60
- return onChange(selectedItem);
60
+ return onChange(selectValue);
61
61
  }}
62
62
  labelField={labelField}
63
63
  valueField={valueField}
64
64
  placeholder={placeholder}
65
- selectionType={selectionType}
66
65
  containerStyle={containerStyle}
67
66
  labelTextStyle={styles.labelText}
68
67
  itemTextStyle={styles.dropdownText}
@@ -1,4 +1,6 @@
1
+ import { ColorValue } from "react-native";
2
+
1
3
  export interface SvgInterface {
2
4
  size?: number;
3
- color?: string;
5
+ color?: ColorValue;
4
6
  }
@@ -1,14 +1,7 @@
1
1
  export * from './colors';
2
2
  export * from './spacing';
3
3
  export * from './shadow';
4
- import { Dimensions, Platform } from 'react-native';
5
-
6
- export const addAlphaToHex = (color: string, opacity: number) => {
7
- const _opacity = Math.round(Math.min(Math.max(opacity || 1, 0), 1) * 255);
8
- return color + _opacity.toString(16).toUpperCase();
9
- };
4
+ import { Dimensions } from 'react-native';
10
5
 
11
6
  export const SCREEN_WIDTH = Dimensions.get('window').width;
12
7
  export const SCREEN_HEIGHT = Dimensions.get('window').height;
13
- export const MIN_DEVICE_WIDTH = Platform.OS === 'ios' ? 390 : 360;
14
-