@rn-components-dropdown/dropdown 1.0.0

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 (86) hide show
  1. package/dist/components/dropdown/Dropdown.d.ts +4 -0
  2. package/dist/components/dropdown/Dropdown.js +313 -0
  3. package/dist/components/dropdown/DropdownStyle.d.ts +151 -0
  4. package/dist/components/dropdown/DropdownStyle.js +148 -0
  5. package/dist/components/dropdown/components/chip/Chip.d.ts +3 -0
  6. package/dist/components/dropdown/components/chip/Chip.js +22 -0
  7. package/dist/components/dropdown/components/chip/ChipStyle.d.ts +84 -0
  8. package/dist/components/dropdown/components/chip/ChipStyle.js +63 -0
  9. package/dist/components/dropdown/components/input/TextInput.d.ts +3 -0
  10. package/dist/components/dropdown/components/input/TextInput.js +60 -0
  11. package/dist/components/dropdown/components/input/TextInputStyle.d.ts +32 -0
  12. package/dist/components/dropdown/components/input/TextInputStyle.js +33 -0
  13. package/dist/components/dropdown/hooks/useDetectDevice.d.ts +3 -0
  14. package/dist/components/dropdown/hooks/useDetectDevice.js +22 -0
  15. package/dist/components/dropdown/hooks/useDropdown.d.ts +26 -0
  16. package/dist/components/dropdown/hooks/useDropdown.js +263 -0
  17. package/dist/components/dropdown/hooks/useOrientation.d.ts +1 -0
  18. package/dist/components/dropdown/hooks/useOrientation.js +30 -0
  19. package/dist/components/dropdown/interface/ChipInterface.d.ts +8 -0
  20. package/dist/components/dropdown/interface/ChipInterface.js +2 -0
  21. package/dist/components/dropdown/interface/DropdownInterface.d.ts +71 -0
  22. package/dist/components/dropdown/interface/DropdownInterface.js +2 -0
  23. package/dist/components/dropdown/interface/InputProps.d.ts +8 -0
  24. package/dist/components/dropdown/interface/InputProps.js +2 -0
  25. package/dist/components/svgButton/SvgButton.d.ts +11 -0
  26. package/dist/components/svgButton/SvgButton.js +16 -0
  27. package/dist/components/svgButton/SvgButtonStyle.d.ts +28 -0
  28. package/dist/components/svgButton/SvgButtonStyle.js +29 -0
  29. package/dist/components/text/AppText.d.ts +12 -0
  30. package/dist/components/text/AppText.js +24 -0
  31. package/dist/components/text/AppTextStyle.d.ts +171 -0
  32. package/dist/components/text/AppTextStyle.js +27 -0
  33. package/dist/components/textInput/AppTextInput.d.ts +20 -0
  34. package/dist/components/textInput/AppTextInput.js +89 -0
  35. package/dist/components/textInput/AppTextInputStyle.d.ts +79 -0
  36. package/dist/components/textInput/AppTextInputStyle.js +61 -0
  37. package/dist/controller/dropDownController/DropdownController.d.ts +10 -0
  38. package/dist/controller/dropDownController/DropdownController.js +25 -0
  39. package/dist/controller/dropDownController/DropdownControllerStyle.d.ts +50 -0
  40. package/dist/controller/dropDownController/DropdownControllerStyle.js +48 -0
  41. package/dist/controller/textInputController/AppTextInputController.d.ts +13 -0
  42. package/dist/controller/textInputController/AppTextInputController.js +14 -0
  43. package/dist/controller/textInputController/InputControllerStyle.d.ts +31 -0
  44. package/dist/controller/textInputController/InputControllerStyle.js +29 -0
  45. package/dist/index.d.ts +5 -0
  46. package/dist/index.js +16 -0
  47. package/dist/interface/colors.interface.d.ts +20 -0
  48. package/dist/interface/colors.interface.js +2 -0
  49. package/dist/style/colors.d.ts +33 -0
  50. package/dist/style/colors.js +44 -0
  51. package/dist/style/index.d.ts +7 -0
  52. package/dist/style/index.js +29 -0
  53. package/dist/style/shadow.d.ts +161 -0
  54. package/dist/style/shadow.js +158 -0
  55. package/dist/style/spacing.d.ts +23 -0
  56. package/dist/style/spacing.js +26 -0
  57. package/package.json +33 -0
  58. package/src/components/dropdown/Dropdown.tsx +512 -0
  59. package/src/components/dropdown/DropdownStyle.ts +154 -0
  60. package/src/components/dropdown/components/chip/Chip.tsx +31 -0
  61. package/src/components/dropdown/components/chip/ChipStyle.ts +64 -0
  62. package/src/components/dropdown/components/input/TextInput.tsx +46 -0
  63. package/src/components/dropdown/components/input/TextInputStyle.ts +32 -0
  64. package/src/components/dropdown/hooks/useDetectDevice.ts +25 -0
  65. package/src/components/dropdown/hooks/useDropdown.ts +356 -0
  66. package/src/components/dropdown/hooks/useOrientation.ts +36 -0
  67. package/src/components/dropdown/interface/ChipInterface.ts +9 -0
  68. package/src/components/dropdown/interface/DropdownInterface.ts +90 -0
  69. package/src/components/dropdown/interface/InputProps.ts +9 -0
  70. package/src/components/svgButton/SvgButton.tsx +37 -0
  71. package/src/components/svgButton/SvgButtonStyle.ts +27 -0
  72. package/src/components/text/AppText.tsx +41 -0
  73. package/src/components/text/AppTextStyle.ts +40 -0
  74. package/src/components/textInput/AppTextInput.tsx +148 -0
  75. package/src/components/textInput/AppTextInputStyle.ts +72 -0
  76. package/src/controller/dropDownController/DropdownController.tsx +81 -0
  77. package/src/controller/dropDownController/DropdownControllerStyle.ts +47 -0
  78. package/src/controller/textInputController/AppTextInputController.tsx +50 -0
  79. package/src/controller/textInputController/InputControllerStyle.ts +28 -0
  80. package/src/index.ts +5 -0
  81. package/src/interface/colors.interface.ts +22 -0
  82. package/src/style/colors.ts +46 -0
  83. package/src/style/index.ts +14 -0
  84. package/src/style/shadow.ts +155 -0
  85. package/src/style/spacing.ts +23 -0
  86. package/tsconfig.json +13 -0
@@ -0,0 +1,84 @@
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: string;
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: string;
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: string;
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: string;
59
+ backgroundColor: string;
60
+ };
61
+ clearIcon: {
62
+ height: number;
63
+ width: number;
64
+ borderRadius: number;
65
+ alignItems: "center";
66
+ justifyContent: "center";
67
+ backgroundColor: string;
68
+ };
69
+ };
70
+ colors: {
71
+ blue: string;
72
+ gray: string;
73
+ error: string;
74
+ green: string;
75
+ white: string;
76
+ black: string;
77
+ primary: string;
78
+ lightGray: string;
79
+ grayishBlue: string;
80
+ red: string;
81
+ border: string;
82
+ };
83
+ };
84
+ export default useChipStyle;
@@ -0,0 +1,63 @@
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 } = 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.25,
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 ? colors[chipColor] : colors.lightGray,
32
+ },
33
+ chipText: {
34
+ paddingLeft: 10,
35
+ fontWeight: '600',
36
+ },
37
+ clearContainer: {
38
+ width: 18,
39
+ height: 18,
40
+ borderWidth: 1,
41
+ borderRadius: 100,
42
+ marginHorizontal: 4,
43
+ alignItems: 'center',
44
+ justifyContent: 'center',
45
+ borderColor: colors.white,
46
+ backgroundColor: chipColor ? colors[chipColor] : colors.lightGray,
47
+ },
48
+ clearIcon: {
49
+ height: 12,
50
+ width: 12,
51
+ borderRadius: 100,
52
+ alignItems: 'center',
53
+ justifyContent: 'center',
54
+ backgroundColor: colors.white,
55
+ },
56
+ });
57
+ }, [chipColor, colors]);
58
+ return {
59
+ styles,
60
+ colors,
61
+ };
62
+ };
63
+ 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,60 @@
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 react_native_1 = require("react-native");
42
+ const AppTextInput_1 = __importDefault(require("../../../textInput/AppTextInput"));
43
+ const TextInputComponent = props => {
44
+ const { value, placeholder = '', placeholderTextColor = '#000', onChangeText = (_value) => { }, searchIcon, } = props;
45
+ const [searchtext, setSearchText] = (0, react_1.useState)('');
46
+ const { styles } = (0, TextInputStyle_1.useTextStyle)();
47
+ (0, react_1.useEffect)(() => {
48
+ if (value) {
49
+ setSearchText(value);
50
+ }
51
+ }, [value]);
52
+ const onChange = (text) => {
53
+ setSearchText(text);
54
+ onChangeText(text);
55
+ };
56
+ return (<react_native_1.TouchableWithoutFeedback>
57
+ <AppTextInput_1.default {...props} value={searchtext} icon={searchIcon} style={styles.input} onChangeText={onChange} placeholder={placeholder} textStyle={styles.inputContainer} placeholderTextColor={placeholderTextColor}/>
58
+ </react_native_1.TouchableWithoutFeedback>);
59
+ };
60
+ 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;
@@ -0,0 +1,3 @@
1
+ import type { IUseDetectDevice } from '../interface/DropdownInterface';
2
+ declare const useDetectDevice: IUseDetectDevice;
3
+ export { useDetectDevice };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDetectDevice = void 0;
4
+ const react_native_1 = require("react-native");
5
+ const { width, height } = react_native_1.Dimensions.get('window');
6
+ const isTablet = () => {
7
+ let pixelDensity = react_native_1.PixelRatio.get();
8
+ const adjustedWidth = width * pixelDensity;
9
+ const adjustedHeight = height * pixelDensity;
10
+ if (pixelDensity < 2 && (adjustedWidth >= 1000 || adjustedHeight >= 1000)) {
11
+ return true;
12
+ }
13
+ else {
14
+ return (pixelDensity === 2 && (adjustedWidth >= 1824 || adjustedHeight >= 1824));
15
+ }
16
+ };
17
+ const useDetectDevice = {
18
+ isAndroid: react_native_1.Platform.OS === 'android',
19
+ isIOS: react_native_1.Platform.OS === 'ios',
20
+ isTablet: isTablet(),
21
+ };
22
+ exports.useDetectDevice = useDetectDevice;
@@ -0,0 +1,26 @@
1
+ import { View, FlatList } from 'react-native';
2
+ import { DropdownProps } from '../interface/DropdownInterface';
3
+ declare const useDropdown: <T, Mode extends "single" | "multi">(props: DropdownProps<T, Mode>) => {
4
+ ref: import("react").RefObject<View | null>;
5
+ font: () => {
6
+ fontFamily: string;
7
+ } | {
8
+ fontFamily?: undefined;
9
+ };
10
+ refList: import("react").RefObject<FlatList<any> | null>;
11
+ visible: boolean;
12
+ position: any;
13
+ onSelect: (item: any) => void;
14
+ onSearch: (text: string) => void;
15
+ listData: any[];
16
+ onMeasure: () => void;
17
+ searchText: string;
18
+ showOrClose: () => void;
19
+ scrollIndex: () => void;
20
+ currentValue: any;
21
+ onCheckPress: (item: any) => void;
22
+ onClearPress: (item: T) => void;
23
+ setSearchText: import("react").Dispatch<import("react").SetStateAction<string>>;
24
+ keyboardHeight: number;
25
+ };
26
+ export default useDropdown;
@@ -0,0 +1,263 @@
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
+ /* eslint-disable react-hooks/exhaustive-deps */
7
+ const react_1 = require("react");
8
+ const react_native_1 = require("react-native");
9
+ const lodash_1 = __importDefault(require("lodash"));
10
+ const useDetectDevice_1 = require("./useDetectDevice");
11
+ const useOrientation_1 = require("./useOrientation");
12
+ const style_1 = require("../../../style");
13
+ const useDropdown = (props) => {
14
+ const { value, onBlur, onFocus, onChange, data = [], labelField, valueField, fontFamily, searchQuery, searchField, onChangeText, disable = false, ref: currentRef, mode = 'default', autoScroll = true, confirmSelectItem, onConfirmSelectItem, selectionType = 'single', } = props;
15
+ const ref = (0, react_1.useRef)(null);
16
+ const { isTablet } = useDetectDevice_1.useDetectDevice;
17
+ const refList = (0, react_1.useRef)(null);
18
+ const orientation = (0, useOrientation_1.useDeviceOrientation)();
19
+ const [position, setPosition] = (0, react_1.useState)();
20
+ const [searchText, setSearchText] = (0, react_1.useState)('');
21
+ const [listData, setListData] = (0, react_1.useState)(data);
22
+ const [visible, setVisible] = (0, react_1.useState)(false);
23
+ const [currentValue, setCurrentValue] = (0, react_1.useState)(null);
24
+ const statusBarHeight = react_native_1.StatusBar.currentHeight || 0;
25
+ const [keyboardHeight, setKeyboardHeight] = (0, react_1.useState)(0);
26
+ (0, react_1.useImperativeHandle)(currentRef, () => {
27
+ return { open: eventOpen, close: eventClose };
28
+ });
29
+ (0, react_1.useEffect)(() => eventClose, []);
30
+ (0, react_1.useEffect)(() => {
31
+ setListData([...data]);
32
+ if (searchText) {
33
+ onSearch(searchText);
34
+ }
35
+ }, [data, searchText]);
36
+ const eventOpen = () => {
37
+ if (!disable) {
38
+ setVisible(true);
39
+ if (onFocus) {
40
+ onFocus();
41
+ }
42
+ if (searchText.length > 0) {
43
+ onSearch(searchText);
44
+ }
45
+ scrollIndex();
46
+ }
47
+ };
48
+ const eventClose = (0, react_1.useCallback)(() => {
49
+ if (!disable) {
50
+ setVisible(false);
51
+ if (onBlur) {
52
+ onBlur();
53
+ }
54
+ }
55
+ }, [disable, onBlur]);
56
+ const font = (0, react_1.useCallback)(() => {
57
+ if (fontFamily) {
58
+ return {
59
+ fontFamily: fontFamily,
60
+ };
61
+ }
62
+ else {
63
+ return {};
64
+ }
65
+ }, [fontFamily]);
66
+ const onMeasure = (0, react_1.useCallback)(() => {
67
+ if (ref && ref?.current) {
68
+ ref.current.measureInWindow((pageX, pageY, width, height) => {
69
+ let isFull = isTablet
70
+ ? false
71
+ : mode === 'modal' || orientation === 'LANDSCAPE';
72
+ if (mode === 'auto') {
73
+ isFull = false;
74
+ }
75
+ const top = isFull ? 20 : height + pageY + 2;
76
+ const bottom = style_1.SCREEN_HEIGHT - top + height;
77
+ const left = react_native_1.I18nManager.isRTL ? style_1.SCREEN_WIDTH - width - pageX : pageX;
78
+ setPosition({
79
+ isFull,
80
+ left: Math.floor(left),
81
+ width: Math.floor(width),
82
+ height: Math.floor(height),
83
+ top: Math.floor(top + statusBarHeight),
84
+ bottom: Math.floor(bottom - statusBarHeight),
85
+ });
86
+ });
87
+ }
88
+ }, [isTablet, mode, orientation, statusBarHeight]);
89
+ const onKeyboardDidShow = (0, react_1.useCallback)((e) => {
90
+ onMeasure();
91
+ setKeyboardHeight(e.endCoordinates.height);
92
+ }, [onMeasure]);
93
+ const onKeyboardDidHide = (0, react_1.useCallback)(() => {
94
+ setKeyboardHeight(0);
95
+ onMeasure();
96
+ }, [onMeasure]);
97
+ (0, react_1.useEffect)(() => {
98
+ const susbcriptionKeyboardDidShow = react_native_1.Keyboard.addListener('keyboardDidShow', onKeyboardDidShow);
99
+ const susbcriptionKeyboardDidHide = react_native_1.Keyboard.addListener('keyboardDidHide', onKeyboardDidHide);
100
+ return () => {
101
+ if (typeof susbcriptionKeyboardDidShow?.remove === 'function') {
102
+ susbcriptionKeyboardDidShow.remove();
103
+ }
104
+ if (typeof susbcriptionKeyboardDidHide?.remove === 'function') {
105
+ susbcriptionKeyboardDidHide.remove();
106
+ }
107
+ };
108
+ }, [onKeyboardDidHide, onKeyboardDidShow]);
109
+ const getValue = (0, react_1.useCallback)(() => {
110
+ if (selectionType === 'multi') {
111
+ if (!valueField)
112
+ return;
113
+ const v = data?.filter(i => value?.includes(i[valueField]));
114
+ setCurrentValue(v);
115
+ return;
116
+ }
117
+ else {
118
+ const defaultValue = typeof value === 'object' ? lodash_1.default.get(value, valueField) : value;
119
+ const getItem = data.filter(e => lodash_1.default.isEqual(defaultValue, lodash_1.default.get(e, valueField)));
120
+ if (getItem.length > 0) {
121
+ setCurrentValue(getItem[0]);
122
+ }
123
+ else {
124
+ setCurrentValue(null);
125
+ }
126
+ }
127
+ }, [data, value, valueField, selectionType]);
128
+ (0, react_1.useEffect)(() => getValue(), [value, data, getValue]);
129
+ const scrollIndex = (0, react_1.useCallback)(() => {
130
+ if (autoScroll && data.length > 0 && listData.length === data.length) {
131
+ setTimeout(() => {
132
+ if (refList && refList?.current) {
133
+ const defaultValue = typeof value === 'object' ? lodash_1.default.get(value, valueField) : value;
134
+ const index = lodash_1.default.findIndex(listData, (e) => lodash_1.default.isEqual(defaultValue, lodash_1.default.get(e, valueField)));
135
+ if (index > -1 && index <= listData.length - 1) {
136
+ refList?.current?.scrollToIndex({
137
+ index: index,
138
+ animated: false,
139
+ });
140
+ }
141
+ }
142
+ }, 200);
143
+ }
144
+ }, [autoScroll, data.length, listData, value, valueField]);
145
+ const showOrClose = (0, react_1.useCallback)(() => {
146
+ if (!disable) {
147
+ if (keyboardHeight > 0 && visible) {
148
+ return react_native_1.Keyboard.dismiss();
149
+ }
150
+ onMeasure();
151
+ setVisible(!visible);
152
+ setListData(data);
153
+ if (!visible) {
154
+ if (onFocus) {
155
+ onFocus();
156
+ }
157
+ }
158
+ else {
159
+ if (onBlur) {
160
+ onBlur();
161
+ }
162
+ }
163
+ if (searchText?.length > 0) {
164
+ onSearch(searchText);
165
+ }
166
+ scrollIndex();
167
+ }
168
+ }, [
169
+ data,
170
+ onBlur,
171
+ visible,
172
+ disable,
173
+ onFocus,
174
+ onMeasure,
175
+ searchText,
176
+ scrollIndex,
177
+ keyboardHeight,
178
+ ]);
179
+ const onSearch = (0, react_1.useCallback)((text) => {
180
+ if (text.length > 0) {
181
+ const defaultFilterFunction = (e) => {
182
+ const item = lodash_1.default.get(e, searchField || labelField)
183
+ ?.toLowerCase()
184
+ .replace(' ', '')
185
+ .normalize('NFD')
186
+ .replace(/[\u0300-\u036f]/g, '');
187
+ const key = text
188
+ .toLowerCase()
189
+ .replace(' ', '')
190
+ .normalize('NFD')
191
+ .replace(/[\u0300-\u036f]/g, '');
192
+ return item.indexOf(key) >= 0;
193
+ };
194
+ const propSearchFunction = (e) => {
195
+ const labelText = lodash_1.default.get(e, searchField || labelField);
196
+ return searchQuery?.(text, labelText);
197
+ };
198
+ const dataSearch = data.filter(searchQuery ? propSearchFunction : defaultFilterFunction);
199
+ setListData(dataSearch);
200
+ }
201
+ else {
202
+ setListData(data);
203
+ }
204
+ }, [data, searchField, labelField, searchQuery]);
205
+ const onSelect = (0, react_1.useCallback)((item) => {
206
+ if (confirmSelectItem && onConfirmSelectItem) {
207
+ return onConfirmSelectItem(item);
208
+ }
209
+ if (onChangeText) {
210
+ setSearchText('');
211
+ onChangeText('');
212
+ }
213
+ onSearch('');
214
+ setCurrentValue(item);
215
+ onChange?.(item[valueField]);
216
+ eventClose();
217
+ }, [
218
+ onChange,
219
+ onSearch,
220
+ eventClose,
221
+ onChangeText,
222
+ confirmSelectItem,
223
+ onConfirmSelectItem,
224
+ ]);
225
+ const onCheckPress = (0, react_1.useCallback)((item) => {
226
+ setCurrentValue?.((prev) => {
227
+ const exists = prev?.some?.((i) => i[valueField] === item[valueField]);
228
+ const va = exists
229
+ ? lodash_1.default.filter(prev, i => i?.[valueField] !== item?.[valueField])
230
+ : [...prev, item];
231
+ const v = va?.map(i => i[valueField]);
232
+ onChange?.(item[valueField], selectionType === 'multi' ? v : item[valueField]);
233
+ return va;
234
+ });
235
+ }, [setCurrentValue, valueField, onChange, currentValue]);
236
+ const onClearPress = (0, react_1.useCallback)((item) => {
237
+ const clone = lodash_1.default.clone(currentValue);
238
+ const rem = lodash_1.default.remove(clone, i => i?.[valueField] !== item[valueField]);
239
+ const val = rem?.map(i => i?.[valueField]);
240
+ setCurrentValue(rem);
241
+ onChange?.(item[valueField], val);
242
+ }, [onChange]);
243
+ return {
244
+ ref,
245
+ font,
246
+ refList,
247
+ visible,
248
+ position,
249
+ onSelect,
250
+ onSearch,
251
+ listData,
252
+ onMeasure,
253
+ searchText,
254
+ showOrClose,
255
+ scrollIndex,
256
+ currentValue,
257
+ onCheckPress,
258
+ onClearPress,
259
+ setSearchText,
260
+ keyboardHeight,
261
+ };
262
+ };
263
+ exports.default = useDropdown;
@@ -0,0 +1 @@
1
+ export declare function useDeviceOrientation(): "PORTRAIT" | "LANDSCAPE";
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDeviceOrientation = useDeviceOrientation;
4
+ const react_1 = require("react");
5
+ const react_native_1 = require("react-native");
6
+ const isOrientationPortrait = ({ width, height }) => height >= width;
7
+ const isOrientationLandscape = ({ width, height }) => width >= height;
8
+ function useDeviceOrientation() {
9
+ const screen = react_native_1.Dimensions.get('screen');
10
+ const initialState = {
11
+ portrait: isOrientationPortrait(screen),
12
+ landscape: isOrientationLandscape(screen),
13
+ };
14
+ const [orientation, setOrientation] = (0, react_1.useState)(initialState);
15
+ (0, react_1.useEffect)(() => {
16
+ const onChange = ({ screen: screens }) => {
17
+ setOrientation({
18
+ portrait: isOrientationPortrait(screens),
19
+ landscape: isOrientationLandscape(screens),
20
+ });
21
+ };
22
+ const subscription = react_native_1.Dimensions.addEventListener('change', onChange);
23
+ return () => {
24
+ if (typeof subscription?.remove === 'function') {
25
+ subscription.remove();
26
+ }
27
+ };
28
+ }, []);
29
+ return orientation.portrait ? 'PORTRAIT' : 'LANDSCAPE';
30
+ }
@@ -0,0 +1,8 @@
1
+ import { ThemeColors } from '../../../interface/colors.interface';
2
+ export interface ChipInterface {
3
+ label?: string;
4
+ onClearPress?: () => void;
5
+ chipColor?: keyof ThemeColors;
6
+ textColor?: keyof ThemeColors;
7
+ clearIcon?: React.JSX.Element;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });