react-native-ui-lib 7.37.2-snapshot.6217 → 7.38.0-snapshot.6221
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/package.json
CHANGED
|
@@ -3,10 +3,11 @@ import { SearchInputPresets, SearchInputProps, SearchInputRef } from './types';
|
|
|
3
3
|
declare const SearchInput: React.ForwardRefExoticComponent<import("react-native").TextInputProps & {
|
|
4
4
|
onClear?: (() => void) | undefined;
|
|
5
5
|
onDismiss?: (() => void) | undefined;
|
|
6
|
-
|
|
6
|
+
cancelButtonProps?: import("../button").ButtonProps | undefined;
|
|
7
|
+
renderCustomRightElement?: (() => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
|
|
7
8
|
title?: string | undefined;
|
|
8
|
-
showFilterIcon?: boolean | undefined;
|
|
9
9
|
showLoader?: boolean | undefined;
|
|
10
|
+
loaderProps?: import("react-native").ActivityIndicatorProps | undefined;
|
|
10
11
|
renderLoaderElement?: (() => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
|
|
11
12
|
invertColors?: boolean | undefined;
|
|
12
13
|
inaccessible?: boolean | undefined;
|
|
@@ -14,7 +15,6 @@ declare const SearchInput: React.ForwardRefExoticComponent<import("react-native"
|
|
|
14
15
|
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
15
16
|
containerStyle?: import("react-native").StyleProp<import("react-native").TextStyle | import("react-native").ViewStyle>;
|
|
16
17
|
preset?: "default" | "prominent" | SearchInputPresets | undefined;
|
|
17
|
-
cancelButtonProps?: import("../button").ButtonProps | undefined;
|
|
18
18
|
} & React.RefAttributes<any>>;
|
|
19
19
|
interface StaticMembers {
|
|
20
20
|
presets: typeof SearchInputPresets;
|
|
@@ -23,10 +23,11 @@ export { SearchInput, SearchInputProps, SearchInputRef, SearchInputPresets };
|
|
|
23
23
|
declare const _default: React.ForwardRefExoticComponent<import("react-native").TextInputProps & {
|
|
24
24
|
onClear?: (() => void) | undefined;
|
|
25
25
|
onDismiss?: (() => void) | undefined;
|
|
26
|
-
|
|
26
|
+
cancelButtonProps?: import("../button").ButtonProps | undefined;
|
|
27
|
+
renderCustomRightElement?: (() => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
|
|
27
28
|
title?: string | undefined;
|
|
28
|
-
showFilterIcon?: boolean | undefined;
|
|
29
29
|
showLoader?: boolean | undefined;
|
|
30
|
+
loaderProps?: import("react-native").ActivityIndicatorProps | undefined;
|
|
30
31
|
renderLoaderElement?: (() => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
|
|
31
32
|
invertColors?: boolean | undefined;
|
|
32
33
|
inaccessible?: boolean | undefined;
|
|
@@ -34,6 +35,5 @@ declare const _default: React.ForwardRefExoticComponent<import("react-native").T
|
|
|
34
35
|
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
35
36
|
containerStyle?: import("react-native").StyleProp<import("react-native").TextStyle | import("react-native").ViewStyle>;
|
|
36
37
|
preset?: "default" | "prominent" | SearchInputPresets | undefined;
|
|
37
|
-
cancelButtonProps?: import("../button").ButtonProps | undefined;
|
|
38
38
|
} & React.RefAttributes<any>> & StaticMembers;
|
|
39
39
|
export default _default;
|
|
@@ -23,17 +23,17 @@ const SearchInput = forwardRef((props, ref) => {
|
|
|
23
23
|
invertColors,
|
|
24
24
|
testID,
|
|
25
25
|
showLoader,
|
|
26
|
+
loaderProps,
|
|
26
27
|
value: controlledValue,
|
|
27
28
|
onChangeText,
|
|
28
29
|
onClear,
|
|
29
30
|
containerStyle,
|
|
30
|
-
|
|
31
|
-
// loaderProps,
|
|
31
|
+
renderCustomRightElement,
|
|
32
32
|
style,
|
|
33
33
|
inaccessible
|
|
34
34
|
} = props;
|
|
35
35
|
const currentAnimatedValue = useRef();
|
|
36
|
-
const searchInputRef = useRef();
|
|
36
|
+
const searchInputRef = useRef(null);
|
|
37
37
|
const [hasValue, setHasValue] = useState(Boolean(controlledValue));
|
|
38
38
|
const [value, setValue] = useState(controlledValue);
|
|
39
39
|
const [valueState] = useState(new Animated.Value(_isEmpty(controlledValue) ? 0 : 1));
|
|
@@ -101,27 +101,6 @@ const SearchInput = forwardRef((props, ref) => {
|
|
|
101
101
|
onChangeTextHandler('');
|
|
102
102
|
onClear?.();
|
|
103
103
|
};
|
|
104
|
-
|
|
105
|
-
// const blur = () => {
|
|
106
|
-
// if (searchInputRef.current) {
|
|
107
|
-
// searchInputRef.current.blur();
|
|
108
|
-
// }
|
|
109
|
-
// };
|
|
110
|
-
|
|
111
|
-
// const focus = () => {
|
|
112
|
-
// if (searchInputRef.current) {
|
|
113
|
-
// searchInputRef.current.focus();
|
|
114
|
-
// }
|
|
115
|
-
// };
|
|
116
|
-
|
|
117
|
-
// const clear = () => {
|
|
118
|
-
// if (searchInputRef.current) {
|
|
119
|
-
// searchInputRef.current.clear();
|
|
120
|
-
// onChangeText?.('');
|
|
121
|
-
// onClear?.();
|
|
122
|
-
// }
|
|
123
|
-
// };
|
|
124
|
-
|
|
125
104
|
const renderClearButton = () => {
|
|
126
105
|
const transform = [{
|
|
127
106
|
translateY: valueState.interpolate({
|
|
@@ -131,7 +110,9 @@ const SearchInput = forwardRef((props, ref) => {
|
|
|
131
110
|
}];
|
|
132
111
|
const clearButtonStyle = !isDismissible() && isAnimatingClearButton && styles.clearButton;
|
|
133
112
|
const iconStyle = {
|
|
134
|
-
tintColor: invertColors ? INVERTED_ICON_COLOR : Colors.grey40
|
|
113
|
+
tintColor: invertColors ? INVERTED_ICON_COLOR : Colors.grey40,
|
|
114
|
+
width: 12,
|
|
115
|
+
height: 12
|
|
135
116
|
};
|
|
136
117
|
return <Animated.View style={[{
|
|
137
118
|
transform
|
|
@@ -157,14 +138,12 @@ const SearchInput = forwardRef((props, ref) => {
|
|
|
157
138
|
return <View style={[styles.inputContainer, {
|
|
158
139
|
height
|
|
159
140
|
}]}>
|
|
160
|
-
<TextInput accessibilityRole={'search'} placeholder={placeholder} placeholderTextColor={placeholderTextColor} underlineColorAndroid="transparent" selectionColor={selectionColor}
|
|
161
|
-
//@ts-ignore
|
|
162
|
-
ref={searchInputRef?.current} value={value} allowFontScaling={false} style={[styles.input, containerStyle, invertColors && {
|
|
141
|
+
<TextInput accessibilityRole={'search'} placeholder={placeholder} placeholderTextColor={placeholderTextColor} underlineColorAndroid="transparent" selectionColor={selectionColor} ref={searchInputRef} value={value} allowFontScaling={false} style={[styles.input, containerStyle, invertColors && {
|
|
163
142
|
color: INVERTED_TEXT_COLOR
|
|
164
143
|
}, (!isDismissible() || isAnimatingClearButton) && styles.emptyInput]} onChangeText={onChangeTextHandler} testID={testID} />
|
|
165
144
|
{isAnimatingClearButton && renderClearButton()}
|
|
166
145
|
{isDismissible() && renderCancelButton()}
|
|
167
|
-
{!isDismissible() &&
|
|
146
|
+
{!isDismissible() && renderCustomRightElement && renderCustomRightElement()}
|
|
168
147
|
</View>;
|
|
169
148
|
};
|
|
170
149
|
const isDismissible = () => {
|
|
@@ -183,7 +162,7 @@ const SearchInput = forwardRef((props, ref) => {
|
|
|
183
162
|
renderLoaderElement
|
|
184
163
|
} = props;
|
|
185
164
|
return <View>
|
|
186
|
-
{renderLoaderElement ? renderLoaderElement() : <ActivityIndicator
|
|
165
|
+
{renderLoaderElement ? renderLoaderElement() : <ActivityIndicator style={styles.loader} {...loaderProps} />}
|
|
187
166
|
</View>;
|
|
188
167
|
};
|
|
189
168
|
const topInputTopMargin = useSafeArea && {
|
|
@@ -231,6 +210,9 @@ const styles = StyleSheet.create({
|
|
|
231
210
|
},
|
|
232
211
|
leftIcon: {
|
|
233
212
|
marginLeft: Spacings.s4
|
|
213
|
+
},
|
|
214
|
+
loader: {
|
|
215
|
+
marginHorizontal: Spacings.s4
|
|
234
216
|
}
|
|
235
217
|
});
|
|
236
218
|
SearchInput.displayName = 'SearchInput';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { TextInputProps, StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
import { TextInputProps, StyleProp, ViewStyle, TextStyle, ActivityIndicatorProps } from 'react-native';
|
|
3
3
|
import { ButtonProps } from '../button';
|
|
4
4
|
export declare enum SearchInputPresets {
|
|
5
5
|
DEFAULT = "default",
|
|
@@ -20,21 +20,25 @@ export type SearchInputProps = TextInputProps & {
|
|
|
20
20
|
*/
|
|
21
21
|
onDismiss?: () => void;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Props for the cancel button
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
cancelButtonProps?: ButtonProps;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Custom right element
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
renderCustomRightElement?: () => React.ReactElement;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Title prop
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
title?: string;
|
|
34
34
|
/**
|
|
35
35
|
* Whether to show a loader instead of the left search icon
|
|
36
36
|
*/
|
|
37
37
|
showLoader?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Loader props
|
|
40
|
+
*/
|
|
41
|
+
loaderProps?: ActivityIndicatorProps;
|
|
38
42
|
/**
|
|
39
43
|
* custom loader element
|
|
40
44
|
*/
|
|
@@ -63,8 +67,4 @@ export type SearchInputProps = TextInputProps & {
|
|
|
63
67
|
* The preset for the search input: default or prominent
|
|
64
68
|
*/
|
|
65
69
|
preset?: SearchInputPresets | `${SearchInputPresets}`;
|
|
66
|
-
/**
|
|
67
|
-
* Props for the cancel button
|
|
68
|
-
*/
|
|
69
|
-
cancelButtonProps?: ButtonProps;
|
|
70
70
|
};
|