UNPKG

4.91 kBTypeScriptView Raw
1import * as React from 'react';
2import { Animated, ColorValue, GestureResponderEvent, StyleProp, TextInput, TextStyle, ViewStyle } from 'react-native';
3import type { IconSource } from './Icon';
4import type { ThemeProp } from '../types';
5interface Style {
6 marginRight: number;
7}
8export declare type Props = React.ComponentPropsWithRef<typeof TextInput> & {
9 /**
10 * Hint text shown when the input is empty.
11 */
12 placeholder?: string;
13 /**
14 * The value of the text input.
15 */
16 value: string;
17 /**
18 * Callback that is called when the text input's text changes.
19 */
20 onChangeText?: (query: string) => void;
21 /**
22 * @supported Available in v5.x with theme version 3
23 * Search layout mode, the default value is "bar".
24 */
25 mode?: 'bar' | 'view';
26 /**
27 * Icon name for the left icon button (see `onIconPress`).
28 */
29 icon?: IconSource;
30 /**
31 * Custom color for icon, default will be derived from theme
32 */
33 iconColor?: string;
34 /**
35 * Color of the ripple effect.
36 */
37 rippleColor?: ColorValue;
38 /**
39 * Callback to execute if we want the left icon to act as button.
40 */
41 onIconPress?: (e: GestureResponderEvent) => void;
42 /**
43 * Callback to execute if we want to add custom behaviour to close icon button.
44 */
45 onClearIconPress?: (e: GestureResponderEvent) => void;
46 /**
47 * Accessibility label for the button. This is read by the screen reader when the user taps the button.
48 */
49 searchAccessibilityLabel?: string;
50 /**
51 * Custom icon for clear button, default will be icon close. It's visible when `loading` is set to `false`.
52 * In v5.x with theme version 3, `clearIcon` is visible only `right` prop is not defined.
53 */
54 clearIcon?: IconSource;
55 /**
56 * Accessibility label for the button. This is read by the screen reader when the user taps the button.
57 */
58 clearAccessibilityLabel?: string;
59 /**
60 * @supported Available in v5.x with theme version 3
61 * Icon name for the right trailering icon button.
62 * Works only when `mode` is set to "bar". It won't be displayed if `loading` is set to `true`.
63 */
64 traileringIcon?: IconSource;
65 /**
66 * @supported Available in v5.x with theme version 3
67 * Custom color for the right trailering icon, default will be derived from theme
68 */
69 traileringIconColor?: string;
70 /**
71 * @supported Available in v5.x with theme version 3
72 * Color of the trailering icon ripple effect.
73 */
74 traileringRippleColor?: ColorValue;
75 /**
76 * @supported Available in v5.x with theme version 3
77 * Callback to execute on the right trailering icon button press.
78 */
79 onTraileringIconPress?: (e: GestureResponderEvent) => void;
80 /**
81 * Accessibility label for the right trailering icon button. This is read by the screen reader when the user taps the button.
82 */
83 traileringIconAccessibilityLabel?: string;
84 /**
85 * @supported Available in v5.x with theme version 3
86 * Callback which returns a React element to display on the right side.
87 * Works only when `mode` is set to "bar".
88 */
89 right?: (props: {
90 color: string;
91 style: Style;
92 testID: string;
93 }) => React.ReactNode;
94 /**
95 * @supported Available in v5.x with theme version 3
96 * Whether to show `Divider` at the bottom of the search.
97 * Works only when `mode` is set to "view". True by default.
98 */
99 showDivider?: boolean;
100 /**
101 * @supported Available in v5.x with theme version 3
102 * Changes Searchbar shadow and background on iOS and Android.
103 */
104 elevation?: 0 | 1 | 2 | 3 | 4 | 5 | Animated.Value;
105 /**
106 * Set style of the TextInput component inside the searchbar
107 */
108 inputStyle?: StyleProp<TextStyle>;
109 style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
110 /**
111 * Custom flag for replacing clear button with activity indicator.
112 */
113 loading?: Boolean;
114 /**
115 * TestID used for testing purposes
116 */
117 testID?: string;
118 /**
119 * @optional
120 */
121 theme?: ThemeProp;
122};
123declare type TextInputHandles = Pick<TextInput, 'setNativeProps' | 'isFocused' | 'clear' | 'blur' | 'focus'>;
124/**
125 * Searchbar is a simple input box where users can type search queries.
126 *
127 * ## Usage
128 * ```js
129 * import * as React from 'react';
130 * import { Searchbar } from 'react-native-paper';
131 *
132 * const MyComponent = () => {
133 * const [searchQuery, setSearchQuery] = React.useState('');
134 *
135 * return (
136 * <Searchbar
137 * placeholder="Search"
138 * onChangeText={setSearchQuery}
139 * value={searchQuery}
140 * />
141 * );
142 * };
143 *
144 * export default MyComponent;
145
146 * ```
147 */
148declare const Searchbar: import("../utils/forwardRef").ForwardRefComponent<TextInputHandles, Props>;
149export default Searchbar;
150//# sourceMappingURL=Searchbar.d.ts.map
\No newline at end of file