Skip to content

Commit f155658

Browse files
CaptainHaideronmotion
authored andcommitted
On Submit Functionality Added
1 parent a61752a commit f155658

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

src/RightButton.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export const RightButton = memo(
1515
loading,
1616
buttonsContainerStyle,
1717
ChevronIconComponent,
18-
ClearIconComponent
18+
ClearIconComponent,
19+
RightIconComponent,
20+
onSubmit,
1921
}) => {
2022
const isOpenedAnimationValue = useRef(new Animated.Value(0)).current
2123

@@ -46,6 +48,9 @@ export const RightButton = memo(
4648
</TouchableOpacity>
4749
)}
4850
{loading && <ActivityIndicator color="#999" />}
51+
{RightIconComponent && <TouchableOpacity onPress={onSubmit} style={styles.chevronButton}>
52+
{RightIconComponent}
53+
</TouchableOpacity>}
4954
{showChevron && (
5055
<Animated.View style={{ transform: [{ rotate: chevronSpin }] }}>
5156
<TouchableOpacity onPress={onChevronPress} style={styles.chevronButton}>

src/index.d.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import React, { FC } from 'react';
2-
import { StyleProp, TextInputProps, TextStyle, ViewStyle, FlatListProps } from 'react-native';
1+
import React, { FC } from "react";
2+
import {
3+
StyleProp,
4+
TextInputProps,
5+
TextStyle,
6+
ViewStyle,
7+
FlatListProps,
8+
} from "react-native";
39

410
export type TAutocompleteDropdownItem = {
511
id: string;
@@ -35,35 +41,36 @@ interface AutocompleteDropdownProps {
3541
closeOnSubmit?: boolean;
3642
clearOnFocus?: boolean;
3743
debounce?: number;
38-
direction?: 'down' | 'up';
39-
position?: 'absolute' | 'relative';
44+
direction?: "down" | "up";
45+
position?: "absolute" | "relative";
4046
bottomOffset?: number;
4147
textInputProps?: TextInputProps;
4248
onChangeText?: (text: string) => void;
4349
onSelectItem?: (item: TAutocompleteDropdownItem) => void;
4450
renderItem?: (
4551
item: TAutocompleteDropdownItem,
46-
searchText: string,
52+
searchText: string
4753
) => JSX.Element;
4854
onOpenSuggestionsList?: (isOpened: boolean) => void;
4955
onClear?: () => void;
5056
onChevronPress?: () => void;
51-
onSubmit?: TextInputProps['onSubmitEditing'];
52-
onBlur?: TextInputProps['onBlur'];
53-
onFocus?: TextInputProps['onFocus'];
57+
onSubmit?: TextInputProps["onSubmitEditing"];
58+
onBlur?: TextInputProps["onBlur"];
59+
onFocus?: TextInputProps["onFocus"];
5460
controller?: (controller: AutocompleteDropdownRef) => void;
5561
containerStyle?: StyleProp<ViewStyle>;
5662
inputContainerStyle?: StyleProp<ViewStyle>;
5763
rightButtonsContainerStyle?: StyleProp<ViewStyle>;
5864
suggestionsListContainerStyle?: StyleProp<ViewStyle>;
5965
suggestionsListTextStyle?: StyleProp<TextStyle>;
6066
ChevronIconComponent?: JSX.Element;
67+
RightIconComponent?: JSX.Element;
6168
ClearIconComponent?: JSX.Element;
6269
InputComponent?: React.ComponentType;
6370
ItemSeparatorComponent?: JSX.Element;
6471
EmptyResultComponent?: JSX.Element;
6572
emptyResultText?: string;
66-
flatListProps?: FlatListProps<any>
73+
flatListProps?: FlatListProps<any>;
6774
}
6875

6976
export const AutocompleteDropdown: FC<AutocompleteDropdownProps>;

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ export const AutocompleteDropdown = memo(
299299
buttonsContainerStyle={props.rightButtonsContainerStyle}
300300
ChevronIconComponent={props.ChevronIconComponent}
301301
ClearIconComponent={props.ClearIconComponent}
302+
RightIconComponent={props.RightIconComponent}
303+
onSubmit={onSubmit}
302304
/>
303305
</View>
304306
{isOpened && Array.isArray(dataSet) && (
@@ -349,6 +351,7 @@ AutocompleteDropdown.propTypes = {
349351
suggestionsListContainerStyle: PropTypes.object,
350352
suggestionsListTextStyle: PropTypes.object,
351353
ChevronIconComponent: PropTypes.element,
354+
RightIconComponent: PropTypes.element,
352355
ClearIconComponent: PropTypes.element,
353356
ScrollViewComponent: PropTypes.elementType,
354357
EmptyResultComponent: PropTypes.element,

0 commit comments

Comments
 (0)