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.
- package/LICENSE +20 -0
- package/README.md +110 -29
- package/lib/module/components/Dropdown.js +67 -0
- package/lib/module/components/Dropdown.js.map +1 -0
- package/lib/module/components/SearchableTextInput.js +113 -0
- package/lib/module/components/SearchableTextInput.js.map +1 -0
- package/lib/module/hooks/useDebounce.js +16 -0
- package/lib/module/hooks/useDebounce.js.map +1 -0
- package/lib/module/hooks/useDropdownLayout.js +28 -0
- package/lib/module/hooks/useDropdownLayout.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/styles/defaultStyles.js +68 -0
- package/lib/module/styles/defaultStyles.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/Dropdown.d.ts +20 -0
- package/lib/typescript/src/components/Dropdown.d.ts.map +1 -0
- package/lib/typescript/src/components/SearchableTextInput.d.ts +3 -0
- package/lib/typescript/src/components/SearchableTextInput.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useDebounce.d.ts +2 -0
- package/lib/typescript/src/hooks/useDebounce.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useDropdownLayout.d.ts +10 -0
- package/lib/typescript/src/hooks/useDropdownLayout.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/styles/defaultStyles.d.ts +63 -0
- package/lib/typescript/src/styles/defaultStyles.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +27 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/package.json +166 -13
- package/src/components/Dropdown.tsx +99 -0
- package/src/components/SearchableTextInput.tsx +130 -0
- package/src/hooks/useDebounce.ts +17 -0
- package/src/hooks/useDropdownLayout.ts +27 -0
- package/src/index.tsx +2 -0
- package/src/styles/defaultStyles.ts +63 -0
- package/src/types/index.ts +36 -0
- package/components/searchable-text-input.js +0 -113
- package/index.js +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pratik
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,41 +1,122 @@
|
|
|
1
|
-
#
|
|
1
|
+
# rn-searchable-textinput 🚀
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
For users who wants to show multiple search result to the user.
|
|
5
|
-
e.g Search for the near by restrurents.
|
|
3
|
+
A lightning-fast, highly customizable, and strictly typed searchable dropdown for React Native.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
**Version 2.0 is a complete architectural rewrite!** It fixes standard dropdown issues like Android clipping, typing lag on huge lists, and rigid styling, while adding first-class async search support.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
3. Getting Started
|
|
7
|
+
[](https://www.npmjs.com/package/rn-searchable-textinput)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
12
9
|
|
|
13
|
-
|
|
10
|
+
## 🎥 Demo
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
For users who wants to show multiple search result to the user.
|
|
17
|
-
e.g Search for the near by restrurents.
|
|
12
|
+
> **[Click here to watch the Video Demo / See it in action!]** _(Replace this with your YouTube/Loom/Twitter link or a .gif of the UI)_
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
## ✨ Why this library?
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
- **Android Safe:** Bypasses Android's notorious `overflow: hidden` clipping bugs using smart absolute positioning and elevation.
|
|
17
|
+
- **Smart Flip Layout:** Automatically flips the dropdown above the input if it detects the keyboard or screen edge blocking the view.
|
|
18
|
+
- **60fps Performance:** Built-in debouncing (`useDebounce`) and memoization means zero typing lag, even with 5,000+ items.
|
|
19
|
+
- **Async & API Ready:** First-class support for loading spinners and empty states.
|
|
20
|
+
- **Type Safe:** Fully written in TypeScript with generic support. Autocomplete your custom data models directly in your IDE.
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
2. You can change the look of the **search results**.
|
|
25
|
-
3. Pass the **array of the strings to filter** from.
|
|
22
|
+
## 📦 Installation
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
```bash
|
|
25
|
+
npm install rn-searchable-textinput
|
|
26
|
+
# or
|
|
27
|
+
yarn add rn-searchable-textinput
|
|
28
|
+
```
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
## 🛠️ Quick Start
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
```tsx
|
|
33
|
+
import React, { useState } from 'react';
|
|
34
|
+
import { SearchableTextInput } from 'rn-searchable-textinput';
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const data = [
|
|
37
|
+
{ id: 1, name: 'Apple' },
|
|
38
|
+
{ id: 2, name: 'Banana' },
|
|
39
|
+
{ id: 3, name: 'Cherry' },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export default function App() {
|
|
43
|
+
const [value, setValue] = useState('');
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<SearchableTextInput
|
|
47
|
+
data={data}
|
|
48
|
+
searchKey="name"
|
|
49
|
+
value={value}
|
|
50
|
+
placeholder="Search fruits..."
|
|
51
|
+
onSelect={(item) => setValue(item.name)}
|
|
52
|
+
showClearButton={true}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 🚀 Advanced Usage (Custom Rendering & Async)
|
|
59
|
+
|
|
60
|
+
You can completely customize how items are rendered and handle asynchronous API data effortlessly.
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<SearchableTextInput<Employee>
|
|
64
|
+
data={teamMembers}
|
|
65
|
+
searchKey="fullName"
|
|
66
|
+
value={selectedUser}
|
|
67
|
+
placeholder="Assign to..."
|
|
68
|
+
onSelect={(item) => setSelectedUser(item.fullName)}
|
|
69
|
+
showClearButton={true}
|
|
70
|
+
isLoading={isFetchingAPI}
|
|
71
|
+
ListEmptyComponent={
|
|
72
|
+
<View style={{ padding: 20 }}>
|
|
73
|
+
<Text>No team members found.</Text>
|
|
74
|
+
</View>
|
|
75
|
+
}
|
|
76
|
+
renderItem={(item) => (
|
|
77
|
+
<View style={styles.customRow}>
|
|
78
|
+
<View style={styles.avatar}>
|
|
79
|
+
<Text>{item.fullName.charAt(0)}</Text>
|
|
80
|
+
</View>
|
|
81
|
+
<View>
|
|
82
|
+
<Text style={styles.name}>{item.fullName}</Text>
|
|
83
|
+
<Text style={styles.role}>{item.role}</Text>
|
|
84
|
+
</View>
|
|
85
|
+
</View>
|
|
86
|
+
)}
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## ⚙️ Props
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Default | Description |
|
|
93
|
+
| -------------------- | --------------------- | ------------ | -------------------------------------------------------------- |
|
|
94
|
+
| `data` | `T[]` | **Required** | The array of objects to search through. |
|
|
95
|
+
| `searchKey` | `keyof T \| Function` | **Required** | The object key to filter by, or a function `(item) => string`. |
|
|
96
|
+
| `value` | `string` | **Required** | The current controlled value of the text input. |
|
|
97
|
+
| `onSelect` | `(item: T) => void` | **Required** | Callback fired when an item is tapped. |
|
|
98
|
+
| `showClearButton` | `boolean` | `false` | Shows an 'X' button to instantly clear the input. |
|
|
99
|
+
| `onClear` | `() => void` | `undefined` | Callback fired when the clear button is pressed. |
|
|
100
|
+
| `isLoading` | `boolean` | `false` | Shows an `ActivityIndicator` instead of the list. |
|
|
101
|
+
| `ListEmptyComponent` | `ReactElement` | `null` | Renders when the filtered array is empty. |
|
|
102
|
+
| `debounceDelay` | `number` | `200` | Delay in ms before filtering triggers. Great for performance. |
|
|
103
|
+
| `maxDropdownHeight` | `number` | `250` | The maximum height of the dropdown list. |
|
|
104
|
+
| `renderItem` | `Function` | `undefined` | Completely override the UI of the list items. |
|
|
105
|
+
|
|
106
|
+
_(Also accepts all standard `TextInput` props like `placeholder`, `autoCapitalize`, etc., and multiple style overrides: `containerStyle`, `inputStyle`, `dropdownStyle`, `itemStyle`, `itemTextStyle`)_
|
|
107
|
+
|
|
108
|
+
## 🚨 Migration from v1.x to v2.0
|
|
109
|
+
|
|
110
|
+
v2.0 is a complete architectural overhaul. If you are upgrading from v1:
|
|
111
|
+
|
|
112
|
+
- `data` now accepts arrays of objects, requiring you to specify `searchKey` to tell the component which field to filter by.
|
|
113
|
+
- Plain string arrays are no longer supported directly; map them to objects (e.g., `[{ name: 'Apple' }]`).
|
|
114
|
+
- The component no longer relies on heavy external layout lifecycles, ensuring better stability.
|
|
115
|
+
|
|
116
|
+
## 🤝 Contributing
|
|
117
|
+
|
|
118
|
+
Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/dev-pratik-sanap/rn-searchable-textinput/issues) on GitHub.
|
|
119
|
+
|
|
120
|
+
## 📄 License
|
|
121
|
+
|
|
122
|
+
This project is [MIT](https://opensource.org/licenses/MIT) licensed.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View, FlatList, TouchableOpacity, Text, ActivityIndicator } from 'react-native';
|
|
5
|
+
import { styles } from "../styles/defaultStyles.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export function Dropdown({
|
|
8
|
+
visible,
|
|
9
|
+
data,
|
|
10
|
+
metrics,
|
|
11
|
+
maxHeight,
|
|
12
|
+
onSelect,
|
|
13
|
+
getLabel,
|
|
14
|
+
dropdownStyle,
|
|
15
|
+
itemStyle,
|
|
16
|
+
itemTextStyle,
|
|
17
|
+
renderItem,
|
|
18
|
+
keyExtractor,
|
|
19
|
+
isLoading,
|
|
20
|
+
ListEmptyComponent
|
|
21
|
+
}) {
|
|
22
|
+
if (!visible || !metrics || !isLoading && data.length === 0 && !ListEmptyComponent) return null;
|
|
23
|
+
const dynamicStyle = metrics.position === 'bottom' ? {
|
|
24
|
+
top: metrics.inputHeight + 4
|
|
25
|
+
} : {
|
|
26
|
+
bottom: metrics.inputHeight + 4
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/_jsx(View, {
|
|
29
|
+
style: [styles.dropdown, dynamicStyle, dropdownStyle, {
|
|
30
|
+
maxHeight,
|
|
31
|
+
width: metrics.width
|
|
32
|
+
}],
|
|
33
|
+
children: isLoading ? /*#__PURE__*/_jsx(View, {
|
|
34
|
+
style: styles.loader,
|
|
35
|
+
children: /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
36
|
+
size: "small",
|
|
37
|
+
color: "#6b7280"
|
|
38
|
+
})
|
|
39
|
+
}) : /*#__PURE__*/_jsx(FlatList, {
|
|
40
|
+
data: data,
|
|
41
|
+
keyExtractor: keyExtractor || ((_, index) => index.toString()),
|
|
42
|
+
keyboardShouldPersistTaps: "handled",
|
|
43
|
+
showsVerticalScrollIndicator: false,
|
|
44
|
+
nestedScrollEnabled: true,
|
|
45
|
+
ListEmptyComponent: ListEmptyComponent,
|
|
46
|
+
renderItem: ({
|
|
47
|
+
item
|
|
48
|
+
}) => {
|
|
49
|
+
if (renderItem) {
|
|
50
|
+
return /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
51
|
+
onPress: () => onSelect(item),
|
|
52
|
+
children: renderItem(item, false)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
56
|
+
style: [styles.item, itemStyle],
|
|
57
|
+
onPress: () => onSelect(item),
|
|
58
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
59
|
+
style: [styles.itemText, itemTextStyle],
|
|
60
|
+
children: getLabel(item)
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","View","FlatList","TouchableOpacity","Text","ActivityIndicator","styles","jsx","_jsx","Dropdown","visible","data","metrics","maxHeight","onSelect","getLabel","dropdownStyle","itemStyle","itemTextStyle","renderItem","keyExtractor","isLoading","ListEmptyComponent","length","dynamicStyle","position","top","inputHeight","bottom","style","dropdown","width","children","loader","size","color","_","index","toString","keyboardShouldPersistTaps","showsVerticalScrollIndicator","nestedScrollEnabled","item","onPress","itemText"],"sour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,CAAC,EAAEC,KAAK,KAAKA,KAAK,CAACC,QAAQ,CAAC,CAAC,CAAE;MAC/DC,yBAAyB,EAAC,SAAS;MACnCC,4BAA4B,EAAE,KAAM;MACpCC,mBAAmB,EAAE,IAAK;MAC1BnB,kBAAkB,EAAEA,kBAAmB;MACvCH,UAAU,EAAEA,CAAC;QAAEuB;MAAK,CAAC,KAAK;QACxB,IAAIvB,UAAU,EAAE;UACd,oBACEX,IAAA,CAACL,gBAAgB;YAACwC,OAAO,EAAEA,CAAA,KAAM7B,QAAQ,CAAC4B,IAAI,CAAE;YAAAV,QAAA,EAC7Cb,UAAU,CAACuB,IAAI,EAAE,KAAK;UAAC,CACR,CAAC;QAEvB;QACA,oBACElC,IAAA,CAACL,gBAAgB;UACf0B,KAAK,EAAE,CAACvB,MAAM,CAACoC,IAAI,EAAEzB,SAAS,CAAE;UAChC0B,OAAO,EAAEA,CAAA,KAAM7B,QAAQ,CAAC4B,IAAI,CAAE;UAAAV,QAAA,eAE9BxB,IAAA,CAACJ,IAAI;YAACyB,KAAK,EAAE,CAACvB,MAAM,CAACsC,QAAQ,EAAE1B,aAAa,CAAE;YAAAc,QAAA,EAC3CjB,QAAQ,CAAC2B,IAAI;UAAC,CACX;QAAC,CACS,CAAC;MAEvB;IAAE,CACH;EACF,CACG,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState, useRef, useMemo, useCallback, useEffect } from 'react';
|
|
4
|
+
import { View, TextInput, TouchableOpacity, Text } from 'react-native';
|
|
5
|
+
import { Dropdown } from "./Dropdown.js";
|
|
6
|
+
import { useDebounce } from "../hooks/useDebounce.js";
|
|
7
|
+
import { useDropdownLayout } from "../hooks/useDropdownLayout.js";
|
|
8
|
+
import { styles } from "../styles/defaultStyles.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
export function SearchableTextInput(props) {
|
|
11
|
+
const {
|
|
12
|
+
data,
|
|
13
|
+
searchKey,
|
|
14
|
+
value,
|
|
15
|
+
onSelect,
|
|
16
|
+
placeholder = 'Search...',
|
|
17
|
+
debounceDelay = 200,
|
|
18
|
+
maxDropdownHeight = 250,
|
|
19
|
+
containerStyle,
|
|
20
|
+
inputStyle,
|
|
21
|
+
isLoading,
|
|
22
|
+
ListEmptyComponent,
|
|
23
|
+
showClearButton,
|
|
24
|
+
onClear,
|
|
25
|
+
...rest
|
|
26
|
+
} = props;
|
|
27
|
+
const inputRef = useRef(null);
|
|
28
|
+
const [searchText, setSearchText] = useState(value);
|
|
29
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
30
|
+
const searchKeyRef = useRef(searchKey);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
searchKeyRef.current = searchKey;
|
|
33
|
+
}, [searchKey]);
|
|
34
|
+
const debouncedSearchText = useDebounce(searchText, debounceDelay);
|
|
35
|
+
const {
|
|
36
|
+
metrics,
|
|
37
|
+
measureLayout,
|
|
38
|
+
setMetrics
|
|
39
|
+
} = useDropdownLayout(inputRef, maxDropdownHeight);
|
|
40
|
+
useEffect(() => setSearchText(value), [value]);
|
|
41
|
+
const getLabel = useCallback(item => {
|
|
42
|
+
if (typeof searchKeyRef.current === 'function') return searchKeyRef.current(item);
|
|
43
|
+
return String(item[searchKeyRef.current] || '');
|
|
44
|
+
}, []);
|
|
45
|
+
const filteredData = useMemo(() => {
|
|
46
|
+
if (!debouncedSearchText) return data;
|
|
47
|
+
const lowerSearch = debouncedSearchText.toLowerCase();
|
|
48
|
+
return data.filter(item => getLabel(item).toLowerCase().includes(lowerSearch));
|
|
49
|
+
}, [data, debouncedSearchText, getLabel]);
|
|
50
|
+
const handleFocus = () => {
|
|
51
|
+
measureLayout();
|
|
52
|
+
setIsFocused(true);
|
|
53
|
+
};
|
|
54
|
+
const handleBlur = () => {
|
|
55
|
+
// Allows tap events on the list to register before unmounting
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
setIsFocused(false);
|
|
58
|
+
setMetrics(null);
|
|
59
|
+
}, 200);
|
|
60
|
+
};
|
|
61
|
+
const handleSelect = item => {
|
|
62
|
+
setSearchText(getLabel(item));
|
|
63
|
+
setIsFocused(false);
|
|
64
|
+
onSelect(item);
|
|
65
|
+
};
|
|
66
|
+
const handleClear = () => {
|
|
67
|
+
setSearchText('');
|
|
68
|
+
if (onClear) onClear();
|
|
69
|
+
};
|
|
70
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
71
|
+
style: [styles.container, containerStyle],
|
|
72
|
+
ref: inputRef,
|
|
73
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
74
|
+
style: styles.inputWrapper,
|
|
75
|
+
children: [/*#__PURE__*/_jsx(TextInput, {
|
|
76
|
+
style: [styles.input, inputStyle, showClearButton && {
|
|
77
|
+
paddingRight: 40
|
|
78
|
+
}],
|
|
79
|
+
value: searchText,
|
|
80
|
+
onChangeText: text => {
|
|
81
|
+
setSearchText(text);
|
|
82
|
+
if (!isFocused) setIsFocused(true);
|
|
83
|
+
},
|
|
84
|
+
onFocus: handleFocus,
|
|
85
|
+
onBlur: handleBlur,
|
|
86
|
+
placeholder: placeholder,
|
|
87
|
+
placeholderTextColor: "#9ca3af"
|
|
88
|
+
}), showClearButton && searchText.length > 0 && /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
89
|
+
style: styles.clearButton,
|
|
90
|
+
onPress: handleClear,
|
|
91
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
92
|
+
style: styles.clearIcon,
|
|
93
|
+
children: "\u2715"
|
|
94
|
+
})
|
|
95
|
+
})]
|
|
96
|
+
}), /*#__PURE__*/_jsx(Dropdown, {
|
|
97
|
+
visible: isFocused && (searchText.length > 0 && debouncedSearchText.length > 0 || isLoading === true),
|
|
98
|
+
data: filteredData,
|
|
99
|
+
metrics: metrics,
|
|
100
|
+
maxHeight: maxDropdownHeight,
|
|
101
|
+
onSelect: handleSelect,
|
|
102
|
+
getLabel: getLabel,
|
|
103
|
+
dropdownStyle: rest.dropdownStyle,
|
|
104
|
+
itemStyle: rest.itemStyle,
|
|
105
|
+
itemTextStyle: rest.itemTextStyle,
|
|
106
|
+
renderItem: rest.renderItem,
|
|
107
|
+
keyExtractor: rest.keyExtractor,
|
|
108
|
+
isLoading: isLoading,
|
|
109
|
+
ListEmptyComponent: ListEmptyComponent
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=SearchableTextInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useRef","useMemo","useCallback","useEffect","View","TextInput","TouchableOpacity","Text","Dropdown","useDebounce","useDropdownLayout","styles","jsx","_jsx","jsxs","_jsxs","SearchableTextInput","props","data","searchKey","value","onSelect","placeholder","debounceDelay","maxDropdownHeight","containerStyle","inputStyle","isLoading","ListEmptyComponent","showClearButton","onClear","rest","inputRef","searchText","setSearchText","isFocused","setIsFocused","searchKeyRef","current","debouncedSearchText","metrics","measureLayout","setMetrics","getLabel","item","String","filteredData","lowerSearch","toLowerCase","filter","includes","handleFocus","handleBlur","setTimeout","handleSelect","handleClear","style","container","ref","children","inputWrapper","input","paddingRight","onChangeText","text","onFocus","onBlur","placeholderTextColor","length","clearButton","onPress","clearIcon","visible","maxHeight","dropdownStyle","itemStyle","itemTextStyle","renderItem","keyExtractor"],"sourceRoot":"../../../src","sources":["components/SearchableTextInput.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,WAAW,EAAEC,SAAS,QAAQ,OAAO;AACzE,SAASC,IAAI,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,cAAc;AACtE,SAASC,QAAQ,QAAQ,eAAY;AACrC,SAASC,WAAW,QAAQ,yBAAsB;AAClD,SAASC,iBAAiB,QAAQ,+BAA4B;AAC9D,SAASC,MAAM,QAAQ,4BAAyB;AAAC,SAAAC,GAA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MACrBC,kBAAkB,EAAEA;IAAmB,CACxC,CAAC;EAAA,CACE,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
export function useDebounce(value, delay) {
|
|
5
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handler = setTimeout(() => {
|
|
8
|
+
setDebouncedValue(value);
|
|
9
|
+
}, delay);
|
|
10
|
+
return () => {
|
|
11
|
+
clearTimeout(handler);
|
|
12
|
+
};
|
|
13
|
+
}, [value, delay]);
|
|
14
|
+
return debouncedValue;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=useDebounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useEffect","useDebounce","value","delay","debouncedValue","setDebouncedValue","handler","setTimeout","clearTimeout"],"sourceRoot":"../../../src","sources":["hooks/useDebounce.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAE3C,OAAO,SAASC,WAAWA,CAAIC,KAAQ,EAAEC,KAAa,EAAK;EACzD,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGN,QAAQ,CAAIG,KAAK,CAAC;EAE9DF,SAAS,CAAC,MAAM;IACd,MAAMM,OAAO,GAAGC,UAAU,CAAC,MAAM;MAC/BF,iBAAiB,CAACH,KAAK,CAAC;IAC1B,CAAC,EAAEC,KAAK,CAAC;IAET,OAAO,MAAM;MACXK,YAAY,CAACF,OAAO,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,CAACJ,KAAK,EAAEC,KAAK,CAAC,CAAC;EAElB,OAAOC,cAAc;AACvB","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback } from 'react';
|
|
4
|
+
import { useWindowDimensions } from 'react-native';
|
|
5
|
+
export const useDropdownLayout = (inputRef, maxDropdownHeight) => {
|
|
6
|
+
const [metrics, setMetrics] = useState(null);
|
|
7
|
+
const {
|
|
8
|
+
height: screenHeight
|
|
9
|
+
} = useWindowDimensions();
|
|
10
|
+
const measureLayout = useCallback(() => {
|
|
11
|
+
inputRef.current?.measure((_fx, _fy, width, height, _px, py) => {
|
|
12
|
+
const spaceBelow = screenHeight - (py + height);
|
|
13
|
+
const spaceAbove = py;
|
|
14
|
+
const position = spaceBelow < maxDropdownHeight && spaceAbove > spaceBelow ? 'top' : 'bottom';
|
|
15
|
+
setMetrics({
|
|
16
|
+
position,
|
|
17
|
+
width,
|
|
18
|
+
inputHeight: height
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}, [inputRef, screenHeight, maxDropdownHeight]);
|
|
22
|
+
return {
|
|
23
|
+
metrics,
|
|
24
|
+
measureLayout,
|
|
25
|
+
setMetrics
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=useDropdownLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useCallback","useWindowDimensions","useDropdownLayout","inputRef","maxDropdownHeight","metrics","setMetrics","height","screenHeight","measureLayout","current","measure","_fx","_fy","width","_px","py","spaceBelow","spaceAbove","position","inputHeight"],"sourceRoot":"../../../src","sources":["hooks/useDropdownLayout.ts"],"mappings":";;AAAA,SAAgBA,QAAQ,EAAEC,WAAW,QAAwB,OAAO;AACpE,SAAeC,mBAAmB,QAAQ,cAAc;AAGxD,OAAO,MAAMC,iBAAiB,GAAGA,CAC/BC,QAAkD,EAClDC,iBAAyB,KACtB;EACH,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGP,QAAQ,CAA+B,IAAI,CAAC;EAC1E,MAAM;IAAEQ,MAAM,EAAEC;EAAa,CAAC,GAAGP,mBAAmB,CAAC,CAAC;EAEtD,MAAMQ,aAAa,GAAGT,WAAW,CAAC,MAAM;IACtCG,QAAQ,CAACO,OAAO,EAAEC,OAAO,CAAC,CAACC,GAAG,EAAEC,GAAG,EAAEC,KAAK,EAAEP,MAAM,EAAEQ,GAAG,EAAEC,EAAE,KAAK;MAC9D,MAAMC,UAAU,GAAGT,YAAY,IAAIQ,EAAE,GAAGT,MAAM,CAAC;MAC/C,MAAMW,UAAU,GAAGF,EAAE;MAErB,MAAMG,QAAQ,GACZF,UAAU,GAAGb,iBAAiB,IAAIc,UAAU,GAAGD,UAAU,GACrD,KAAK,GACL,QAAQ;MAEdX,UAAU,CAAC;QAAEa,QAAQ;QAAEL,KAAK;QAAEM,WAAW,EAAEb;MAAO,CAAC,CAAC;IACtD,CAAC,CAAC;EACJ,CAAC,EAAE,CAACJ,QAAQ,EAAEK,YAAY,EAAEJ,iBAAiB,CAAC,CAAC;EAE/C,OAAO;IAAEC,OAAO;IAAEI,aAAa;IAAEH;EAAW,CAAC;AAC/C,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SearchableTextInput"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,qCAAkC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
export const styles = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
position: 'relative',
|
|
7
|
+
zIndex: 1000,
|
|
8
|
+
elevation: 1000,
|
|
9
|
+
width: '100%'
|
|
10
|
+
},
|
|
11
|
+
inputWrapper: {
|
|
12
|
+
justifyContent: 'center'
|
|
13
|
+
},
|
|
14
|
+
input: {
|
|
15
|
+
borderWidth: 1,
|
|
16
|
+
borderColor: '#d1d5db',
|
|
17
|
+
borderRadius: 8,
|
|
18
|
+
paddingHorizontal: 16,
|
|
19
|
+
paddingVertical: 14,
|
|
20
|
+
fontSize: 16,
|
|
21
|
+
backgroundColor: '#ffffff',
|
|
22
|
+
color: '#1f2937'
|
|
23
|
+
},
|
|
24
|
+
clearButton: {
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
right: 12,
|
|
27
|
+
padding: 6
|
|
28
|
+
},
|
|
29
|
+
clearIcon: {
|
|
30
|
+
fontSize: 16,
|
|
31
|
+
color: '#9ca3af',
|
|
32
|
+
fontWeight: '600'
|
|
33
|
+
},
|
|
34
|
+
dropdown: {
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
backgroundColor: '#ffffff',
|
|
37
|
+
borderRadius: 8,
|
|
38
|
+
borderWidth: 1,
|
|
39
|
+
borderColor: '#e5e7eb',
|
|
40
|
+
// iOS Shadow
|
|
41
|
+
shadowColor: '#000',
|
|
42
|
+
shadowOffset: {
|
|
43
|
+
width: 0,
|
|
44
|
+
height: 4
|
|
45
|
+
},
|
|
46
|
+
shadowOpacity: 0.1,
|
|
47
|
+
shadowRadius: 12,
|
|
48
|
+
// Android Shadow
|
|
49
|
+
elevation: 5,
|
|
50
|
+
overflow: 'hidden'
|
|
51
|
+
},
|
|
52
|
+
item: {
|
|
53
|
+
paddingHorizontal: 16,
|
|
54
|
+
paddingVertical: 14,
|
|
55
|
+
borderBottomWidth: 1,
|
|
56
|
+
borderBottomColor: '#f3f4f6'
|
|
57
|
+
},
|
|
58
|
+
itemText: {
|
|
59
|
+
fontSize: 16,
|
|
60
|
+
color: '#374151'
|
|
61
|
+
},
|
|
62
|
+
loader: {
|
|
63
|
+
padding: 20,
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center'
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=defaultStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyleSheet","styles","create","container","position","zIndex","elevation","width","inputWrapper","justifyContent","input","borderWidth","borderColor","borderRadius","paddingHorizontal","paddingVertical","fontSize","backgroundColor","color","clearButton","right","padding","clearIcon","fontWeight","dropdown","shadowColor","shadowOffset","height","shadowOpacity","shadowRadius","overflow","item","borderBottomWidth","borderBottomColor","itemText","loader","alignItems"],"sourceRoot":"../../../src","sources":["styles/defaultStyles.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,OAAO,MAAMC,MAAM,GAAGD,UAAU,CAACE,MAAM,CAAC;EACtCC,SAAS,EAAE;IACTC,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,IAAI;IACZC,SAAS,EAAE,IAAI;IACfC,KAAK,EAAE;EACT,CAAC;EACDC,YAAY,EAAE;IACZC,cAAc,EAAE;EAClB,CAAC;EACDC,KAAK,EAAE;IACLC,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE,SAAS;IACtBC,YAAY,EAAE,CAAC;IACfC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,QAAQ,EAAE,EAAE;IACZC,eAAe,EAAE,SAAS;IAC1BC,KAAK,EAAE;EACT,CAAC;EACDC,WAAW,EAAE;IACXf,QAAQ,EAAE,UAAU;IACpBgB,KAAK,EAAE,EAAE;IACTC,OAAO,EAAE;EACX,CAAC;EACDC,SAAS,EAAE;IACTN,QAAQ,EAAE,EAAE;IACZE,KAAK,EAAE,SAAS;IAChBK,UAAU,EAAE;EACd,CAAC;EACDC,QAAQ,EAAE;IACRpB,QAAQ,EAAE,UAAU;IACpBa,eAAe,EAAE,SAAS;IAC1BJ,YAAY,EAAE,CAAC;IACfF,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE,SAAS;IACtB;IACAa,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE;MAAEnB,KAAK,EAAE,CAAC;MAAEoB,MAAM,EAAE;IAAE,CAAC;IACrCC,aAAa,EAAE,GAAG;IAClBC,YAAY,EAAE,EAAE;IAChB;IACAvB,SAAS,EAAE,CAAC;IACZwB,QAAQ,EAAE;EACZ,CAAC;EACDC,IAAI,EAAE;IACJjB,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBiB,iBAAiB,EAAE,CAAC;IACpBC,iBAAiB,EAAE;EACrB,CAAC;EACDC,QAAQ,EAAE;IACRlB,QAAQ,EAAE,EAAE;IACZE,KAAK,EAAE;EACT,CAAC;EACDiB,MAAM,EAAE;IACNd,OAAO,EAAE,EAAE;IACXe,UAAU,EAAE,QAAQ;IACpB3B,cAAc,EAAE;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DropdownLayoutMetrics } from '../types/index.js';
|
|
3
|
+
interface DropdownProps<T> {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
data: T[];
|
|
6
|
+
metrics: DropdownLayoutMetrics | null;
|
|
7
|
+
maxHeight: number;
|
|
8
|
+
onSelect: (item: T) => void;
|
|
9
|
+
getLabel: (item: T) => string;
|
|
10
|
+
dropdownStyle?: any;
|
|
11
|
+
itemStyle?: any;
|
|
12
|
+
itemTextStyle?: any;
|
|
13
|
+
renderItem?: (item: T, isSelected: boolean) => React.ReactElement;
|
|
14
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
15
|
+
isLoading?: boolean;
|
|
16
|
+
ListEmptyComponent?: React.ReactElement;
|
|
17
|
+
}
|
|
18
|
+
export declare function Dropdown<T>({ visible, data, metrics, maxHeight, onSelect, getLabel, dropdownStyle, itemStyle, itemTextStyle, renderItem, keyExtractor, isLoading, ListEmptyComponent, }: DropdownProps<T>): React.JSX.Element | null;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=Dropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAU,CAAC;AAEtD,UAAU,aAAa,CAAC,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,KAAK,KAAK,CAAC,YAAY,CAAC;IAClE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAClD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;CACzC;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAC1B,OAAO,EACP,IAAI,EACJ,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,SAAS,EACT,aAAa,EACb,UAAU,EACV,YAAY,EACZ,SAAS,EACT,kBAAkB,GACnB,EAAE,aAAa,CAAC,CAAC,CAAC,4BAyDlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchableTextInput.d.ts","sourceRoot":"","sources":["../../../../src/components/SearchableTextInput.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAU,CAAC;AAEzD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,+BAyHxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDebounce.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAczD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { type RefObject } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import type { DropdownLayoutMetrics } from '../types/index.js';
|
|
4
|
+
export declare const useDropdownLayout: (inputRef: RefObject<React.ElementRef<typeof View>>, // 👈 Fix is here
|
|
5
|
+
maxDropdownHeight: number) => {
|
|
6
|
+
metrics: DropdownLayoutMetrics | null;
|
|
7
|
+
measureLayout: () => void;
|
|
8
|
+
setMetrics: React.Dispatch<React.SetStateAction<DropdownLayoutMetrics | null>>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useDropdownLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDropdownLayout.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDropdownLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,IAAI,EAAuB,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAU,CAAC;AAEtD,eAAO,MAAM,iBAAiB,GAC5B,UAAU,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,iBAAiB;AACrE,mBAAmB,MAAM;;;;CAoB1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAkC,CAAC;AACvE,YAAY,EAAE,wBAAwB,EAAE,MAAM,kBAAS,CAAC"}
|