rn-searchable-textinput 0.1.0 → 2.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 (42) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +110 -29
  3. package/lib/module/components/Dropdown.js +67 -0
  4. package/lib/module/components/Dropdown.js.map +1 -0
  5. package/lib/module/components/SearchableTextInput.js +113 -0
  6. package/lib/module/components/SearchableTextInput.js.map +1 -0
  7. package/lib/module/hooks/useDebounce.js +16 -0
  8. package/lib/module/hooks/useDebounce.js.map +1 -0
  9. package/lib/module/hooks/useDropdownLayout.js +28 -0
  10. package/lib/module/hooks/useDropdownLayout.js.map +1 -0
  11. package/lib/module/index.js +4 -0
  12. package/lib/module/index.js.map +1 -0
  13. package/lib/module/package.json +1 -0
  14. package/lib/module/styles/defaultStyles.js +68 -0
  15. package/lib/module/styles/defaultStyles.js.map +1 -0
  16. package/lib/module/types/index.js +4 -0
  17. package/lib/module/types/index.js.map +1 -0
  18. package/lib/typescript/package.json +1 -0
  19. package/lib/typescript/src/components/Dropdown.d.ts +20 -0
  20. package/lib/typescript/src/components/Dropdown.d.ts.map +1 -0
  21. package/lib/typescript/src/components/SearchableTextInput.d.ts +3 -0
  22. package/lib/typescript/src/components/SearchableTextInput.d.ts.map +1 -0
  23. package/lib/typescript/src/hooks/useDebounce.d.ts +2 -0
  24. package/lib/typescript/src/hooks/useDebounce.d.ts.map +1 -0
  25. package/lib/typescript/src/hooks/useDropdownLayout.d.ts +10 -0
  26. package/lib/typescript/src/hooks/useDropdownLayout.d.ts.map +1 -0
  27. package/lib/typescript/src/index.d.ts +3 -0
  28. package/lib/typescript/src/index.d.ts.map +1 -0
  29. package/lib/typescript/src/styles/defaultStyles.d.ts +63 -0
  30. package/lib/typescript/src/styles/defaultStyles.d.ts.map +1 -0
  31. package/lib/typescript/src/types/index.d.ts +27 -0
  32. package/lib/typescript/src/types/index.d.ts.map +1 -0
  33. package/package.json +166 -13
  34. package/src/components/Dropdown.tsx +99 -0
  35. package/src/components/SearchableTextInput.tsx +130 -0
  36. package/src/hooks/useDebounce.ts +17 -0
  37. package/src/hooks/useDropdownLayout.ts +27 -0
  38. package/src/index.tsx +2 -0
  39. package/src/styles/defaultStyles.ts +63 -0
  40. package/src/types/index.ts +36 -0
  41. package/components/searchable-text-input.js +0 -113
  42. package/index.js +0 -2
@@ -1,113 +0,0 @@
1
- import React, { useState } from "react";
2
- import {
3
- FlatList,
4
- View,
5
- TextInput,
6
- Text,
7
- StyleSheet,
8
- TouchableOpacity,
9
- Platform,
10
- SafeAreaView,
11
- } from "react-native";
12
- const SearchableTextInput = (props) => {
13
- const [changedText, onChangeText] = useState("");
14
- const [filteredCompany, setFilteredCompany] = useState([]);
15
-
16
- //NOTE: code for text input with search
17
- const findCompany = (query) => {
18
- let filterdTextInput = query.replace(
19
- /[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,
20
- ""
21
- );
22
- onChangeText(filterdTextInput);
23
- if (filterdTextInput.length) {
24
- const regex = new RegExp(`${filterdTextInput.trim()}`, "i");
25
- setFilteredCompany(
26
- props.arrayWithSetOfValue.filter(
27
- (companyName) => companyName.search(regex) >= 0
28
- )
29
- );
30
- } else {
31
- setFilteredCompany([]);
32
- }
33
- };
34
-
35
- const handleOnChangeText = (changedTextValue) => {
36
- return props.handleOnChangeText(changedTextValue);
37
- };
38
- const listSeparator = () => {
39
- return <View style={[styles.listSeparator, props.listSeparatorStyle]} />;
40
- };
41
- return (
42
- <SafeAreaView style={styles.safeAreaView}>
43
- <View style={styles.mainView}>
44
- <View>
45
- <TextInput
46
- placeholder={props.placeholder}
47
- onChangeText={(text) => findCompany(text)}
48
- value={(handleOnChangeText(changedText), changedText)}
49
- autoFocus={true}
50
- style={[styles.autoCompleteResultText, props.textInputStyle]}
51
- />
52
- </View>
53
- <FlatList
54
- data={filteredCompany.slice(0, 5)}
55
- ItemSeparatorComponent={listSeparator}
56
- style={styles.flatList}
57
- keyExtractor={(item) => item}
58
- maxToRenderPerBatch={1}
59
- onEndThreshold={0}
60
- renderItem={({ item }) => (
61
- <TouchableOpacity
62
- onPress={() => {
63
- onChangeText(item);
64
- setFilteredCompany([]);
65
- }}
66
- >
67
- <View style={styles.flatListView}>
68
- <Text style={[props.searchTextStyle]}>{item}</Text>
69
- <Text>-</Text>
70
- </View>
71
- </TouchableOpacity>
72
- )}
73
- />
74
- </View>
75
- </SafeAreaView>
76
- );
77
- };
78
-
79
- const styles = StyleSheet.create({
80
- autoCompleteResultText: {
81
- borderColor: "#798777",
82
- borderWidth: 1,
83
- borderRadius: 16,
84
- height: 50,
85
- width: 300,
86
- padding: 10,
87
- },
88
- listSeparator: {
89
- borderWidth: 0.3,
90
- borderColor: "#DEDDE3",
91
- height: 1,
92
- borderRadius: 8,
93
- },
94
- flatList: {
95
- position: "absolute",
96
- top: 50,
97
- left: 0,
98
- right: 0,
99
- },
100
- flatListView: {
101
- flexDirection: "row",
102
- padding: 10,
103
- justifyContent: "space-between",
104
- },
105
- mainView: {
106
- justifyContent: "center",
107
- },
108
- safeAreaView: {
109
- alignContent: "center",
110
- },
111
- });
112
-
113
- export default SearchableTextInput;
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- import SearchableTextInput from "./components/searchable-text-input";
2
- export default SearchableTextInput;