react-native-ui-lib 7.37.2-snapshot.6208 → 7.37.2-snapshot.6217
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 +1 -1
- package/searchInput.d.ts +2 -0
- package/searchInput.js +1 -0
- package/src/components/index.js +3 -0
- package/src/components/searchInput/index.d.ts +39 -0
- package/src/components/searchInput/index.js +238 -0
- package/src/components/searchInput/searchInput.api.json +60 -0
- package/src/components/searchInput/types.d.ts +70 -0
- package/src/components/searchInput/types.js +5 -0
- package/src/components/tabController/TabBar.js +1 -1
- package/src/components/tabController/TabBarItem.js +12 -3
- package/src/index.d.ts +1 -0
- package/src/index.js +35 -0
package/package.json
CHANGED
package/searchInput.d.ts
ADDED
package/searchInput.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./src/components/searchInput').default;
|
package/src/components/index.js
CHANGED
|
@@ -137,6 +137,9 @@ export default {
|
|
|
137
137
|
get ProgressiveImage() {
|
|
138
138
|
return require('./progressiveImage').default;
|
|
139
139
|
},
|
|
140
|
+
get SearchInput() {
|
|
141
|
+
return require('./searchInput').default;
|
|
142
|
+
},
|
|
140
143
|
get StateScreen() {
|
|
141
144
|
return require('./stateScreen').default;
|
|
142
145
|
},
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SearchInputPresets, SearchInputProps, SearchInputRef } from './types';
|
|
3
|
+
declare const SearchInput: React.ForwardRefExoticComponent<import("react-native").TextInputProps & {
|
|
4
|
+
onClear?: (() => void) | undefined;
|
|
5
|
+
onDismiss?: (() => void) | undefined;
|
|
6
|
+
schemeColor?: string | null | undefined;
|
|
7
|
+
title?: string | undefined;
|
|
8
|
+
showFilterIcon?: boolean | undefined;
|
|
9
|
+
showLoader?: boolean | undefined;
|
|
10
|
+
renderLoaderElement?: (() => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
|
|
11
|
+
invertColors?: boolean | undefined;
|
|
12
|
+
inaccessible?: boolean | undefined;
|
|
13
|
+
useSafeArea?: boolean | undefined;
|
|
14
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
15
|
+
containerStyle?: import("react-native").StyleProp<import("react-native").TextStyle | import("react-native").ViewStyle>;
|
|
16
|
+
preset?: "default" | "prominent" | SearchInputPresets | undefined;
|
|
17
|
+
cancelButtonProps?: import("../button").ButtonProps | undefined;
|
|
18
|
+
} & React.RefAttributes<any>>;
|
|
19
|
+
interface StaticMembers {
|
|
20
|
+
presets: typeof SearchInputPresets;
|
|
21
|
+
}
|
|
22
|
+
export { SearchInput, SearchInputProps, SearchInputRef, SearchInputPresets };
|
|
23
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-native").TextInputProps & {
|
|
24
|
+
onClear?: (() => void) | undefined;
|
|
25
|
+
onDismiss?: (() => void) | undefined;
|
|
26
|
+
schemeColor?: string | null | undefined;
|
|
27
|
+
title?: string | undefined;
|
|
28
|
+
showFilterIcon?: boolean | undefined;
|
|
29
|
+
showLoader?: boolean | undefined;
|
|
30
|
+
renderLoaderElement?: (() => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
|
|
31
|
+
invertColors?: boolean | undefined;
|
|
32
|
+
inaccessible?: boolean | undefined;
|
|
33
|
+
useSafeArea?: boolean | undefined;
|
|
34
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
35
|
+
containerStyle?: import("react-native").StyleProp<import("react-native").TextStyle | import("react-native").ViewStyle>;
|
|
36
|
+
preset?: "default" | "prominent" | SearchInputPresets | undefined;
|
|
37
|
+
cancelButtonProps?: import("../button").ButtonProps | undefined;
|
|
38
|
+
} & React.RefAttributes<any>> & StaticMembers;
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import _isEmpty from "lodash/isEmpty";
|
|
2
|
+
import React, { useImperativeHandle, forwardRef, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { StyleSheet, Animated, TextInput, ActivityIndicator } from 'react-native';
|
|
4
|
+
import { SearchInputPresets, SearchInputProps, SearchInputRef } from "./types";
|
|
5
|
+
import { Colors, BorderRadiuses, Spacings, Typography } from "../../style";
|
|
6
|
+
import { Constants, asBaseComponent } from "../../commons/new";
|
|
7
|
+
import Button from "../button";
|
|
8
|
+
import Icon from "../icon";
|
|
9
|
+
import View from "../view";
|
|
10
|
+
import Assets from "../../assets";
|
|
11
|
+
const ICON_SIZE = 24;
|
|
12
|
+
const INPUT_HEIGHT = 60;
|
|
13
|
+
const TOP_INPUT_HEIGHT = Constants.isIOS ? 40 : 56;
|
|
14
|
+
const PROMINENT_INPUT_HEIGHT = 48;
|
|
15
|
+
const INVERTED_TEXT_COLOR = Colors.$textDefaultLight;
|
|
16
|
+
const INVERTED_ICON_COLOR = Colors.$iconDefaultLight;
|
|
17
|
+
const HIT_SLOP_VALUE = 20;
|
|
18
|
+
const SearchInput = forwardRef((props, ref) => {
|
|
19
|
+
const {
|
|
20
|
+
preset = SearchInputPresets.DEFAULT,
|
|
21
|
+
onDismiss,
|
|
22
|
+
useSafeArea,
|
|
23
|
+
invertColors,
|
|
24
|
+
testID,
|
|
25
|
+
showLoader,
|
|
26
|
+
value: controlledValue,
|
|
27
|
+
onChangeText,
|
|
28
|
+
onClear,
|
|
29
|
+
containerStyle,
|
|
30
|
+
showFilterIcon,
|
|
31
|
+
// loaderProps,
|
|
32
|
+
style,
|
|
33
|
+
inaccessible
|
|
34
|
+
} = props;
|
|
35
|
+
const currentAnimatedValue = useRef();
|
|
36
|
+
const searchInputRef = useRef();
|
|
37
|
+
const [hasValue, setHasValue] = useState(Boolean(controlledValue));
|
|
38
|
+
const [value, setValue] = useState(controlledValue);
|
|
39
|
+
const [valueState] = useState(new Animated.Value(_isEmpty(controlledValue) ? 0 : 1));
|
|
40
|
+
const [isAnimatingClearButton, setIsAnimatingClearButton] = useState(!_isEmpty(controlledValue));
|
|
41
|
+
useImperativeHandle(ref, () => {
|
|
42
|
+
return {
|
|
43
|
+
blur: () => searchInputRef.current?.blur(),
|
|
44
|
+
focus: () => searchInputRef.current?.focus(),
|
|
45
|
+
clear: () => {
|
|
46
|
+
searchInputRef.current?.clear();
|
|
47
|
+
onChangeText?.('');
|
|
48
|
+
onClear?.();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (controlledValue !== value) {
|
|
54
|
+
setValue(controlledValue);
|
|
55
|
+
setHasValue(Boolean(controlledValue));
|
|
56
|
+
}
|
|
57
|
+
}, [controlledValue]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (hasValue) {
|
|
60
|
+
animatedValueState(1);
|
|
61
|
+
} else {
|
|
62
|
+
animatedValueState(0);
|
|
63
|
+
}
|
|
64
|
+
}, [hasValue]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
return () => {
|
|
67
|
+
currentAnimatedValue.current?.stop();
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
const animatedValueState = value => {
|
|
71
|
+
setIsAnimatingClearButton(true);
|
|
72
|
+
if (currentAnimatedValue.current) {
|
|
73
|
+
currentAnimatedValue.current.stop();
|
|
74
|
+
}
|
|
75
|
+
currentAnimatedValue.current = Animated.timing(valueState, {
|
|
76
|
+
toValue: value,
|
|
77
|
+
duration: 160,
|
|
78
|
+
useNativeDriver: true
|
|
79
|
+
});
|
|
80
|
+
currentAnimatedValue.current.start(() => {
|
|
81
|
+
if (!hasValue) {
|
|
82
|
+
setIsAnimatingClearButton(false);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const getHeight = () => {
|
|
87
|
+
const isProminent = preset === SearchInputPresets.PROMINENT;
|
|
88
|
+
if (isProminent) {
|
|
89
|
+
return PROMINENT_INPUT_HEIGHT;
|
|
90
|
+
}
|
|
91
|
+
return useSafeArea ? TOP_INPUT_HEIGHT : INPUT_HEIGHT;
|
|
92
|
+
};
|
|
93
|
+
const onChangeTextHandler = text => {
|
|
94
|
+
console.log(`onChangeTextHandler, text:`, text);
|
|
95
|
+
onChangeText?.(text);
|
|
96
|
+
setValue(text);
|
|
97
|
+
setHasValue(!_isEmpty(text));
|
|
98
|
+
};
|
|
99
|
+
const clearInput = () => {
|
|
100
|
+
searchInputRef?.current?.clear();
|
|
101
|
+
onChangeTextHandler('');
|
|
102
|
+
onClear?.();
|
|
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
|
+
const renderClearButton = () => {
|
|
126
|
+
const transform = [{
|
|
127
|
+
translateY: valueState.interpolate({
|
|
128
|
+
inputRange: [0, 1],
|
|
129
|
+
outputRange: [50, 1]
|
|
130
|
+
})
|
|
131
|
+
}];
|
|
132
|
+
const clearButtonStyle = !isDismissible() && isAnimatingClearButton && styles.clearButton;
|
|
133
|
+
const iconStyle = {
|
|
134
|
+
tintColor: invertColors ? INVERTED_ICON_COLOR : Colors.grey40
|
|
135
|
+
};
|
|
136
|
+
return <Animated.View style={[{
|
|
137
|
+
transform
|
|
138
|
+
}, clearButtonStyle]}>
|
|
139
|
+
<Button link grey10 text80 iconSource={Assets.icons.x} iconStyle={iconStyle} onPress={clearInput} hitSlop={HIT_SLOP_VALUE} accessible={Boolean(hasValue)} accessibilityLabel={'clear'} testID={`${testID}.clearButton`} />
|
|
140
|
+
</Animated.View>;
|
|
141
|
+
};
|
|
142
|
+
const renderCancelButton = () => {
|
|
143
|
+
const {
|
|
144
|
+
cancelButtonProps
|
|
145
|
+
} = props;
|
|
146
|
+
if (onDismiss) {
|
|
147
|
+
return <Button style={styles.cancelButton} link color={invertColors ? INVERTED_TEXT_COLOR : undefined} $textDefault text65M {...cancelButtonProps} onPress={onDismiss} testID={`${testID}.cancelButton`} />;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const renderTextInput = () => {
|
|
151
|
+
const {
|
|
152
|
+
placeholder
|
|
153
|
+
} = props;
|
|
154
|
+
const height = getHeight();
|
|
155
|
+
const placeholderTextColor = invertColors ? INVERTED_TEXT_COLOR : Colors.$textDefault;
|
|
156
|
+
const selectionColor = invertColors ? INVERTED_TEXT_COLOR : Colors.$textDefault;
|
|
157
|
+
return <View style={[styles.inputContainer, {
|
|
158
|
+
height
|
|
159
|
+
}]}>
|
|
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 && {
|
|
163
|
+
color: INVERTED_TEXT_COLOR
|
|
164
|
+
}, (!isDismissible() || isAnimatingClearButton) && styles.emptyInput]} onChangeText={onChangeTextHandler} testID={testID} />
|
|
165
|
+
{isAnimatingClearButton && renderClearButton()}
|
|
166
|
+
{isDismissible() && renderCancelButton()}
|
|
167
|
+
{!isDismissible() && showFilterIcon && renderIcon(Assets.icons.general.filter, true)}
|
|
168
|
+
</View>;
|
|
169
|
+
};
|
|
170
|
+
const isDismissible = () => {
|
|
171
|
+
return typeof onDismiss !== 'undefined';
|
|
172
|
+
};
|
|
173
|
+
const renderIcon = (icon, left = true) => {
|
|
174
|
+
const invertedColor = invertColors ? {
|
|
175
|
+
tintColor: INVERTED_ICON_COLOR
|
|
176
|
+
} : undefined;
|
|
177
|
+
return <View>
|
|
178
|
+
<Icon tintColor={invertedColor?.tintColor} style={[styles.icon, invertedColor, left && styles.leftIcon]} source={icon} size={ICON_SIZE} />
|
|
179
|
+
</View>;
|
|
180
|
+
};
|
|
181
|
+
const renderLoader = () => {
|
|
182
|
+
const {
|
|
183
|
+
renderLoaderElement
|
|
184
|
+
} = props;
|
|
185
|
+
return <View>
|
|
186
|
+
{renderLoaderElement ? renderLoaderElement() : <ActivityIndicator size={'small'} color={Colors.grey40} />}
|
|
187
|
+
</View>;
|
|
188
|
+
};
|
|
189
|
+
const topInputTopMargin = useSafeArea && {
|
|
190
|
+
marginTop: Constants.isIOS ? Constants.statusBarHeight : 0
|
|
191
|
+
};
|
|
192
|
+
const isProminent = preset === SearchInputPresets.PROMINENT;
|
|
193
|
+
return <View inaccessible={inaccessible} row centerV style={[style, isProminent && styles.prominentContainer, topInputTopMargin]} testID={`${testID}.searchBox`}>
|
|
194
|
+
{showLoader ? renderLoader() : renderIcon(Assets.icons.search)}
|
|
195
|
+
{renderTextInput()}
|
|
196
|
+
</View>;
|
|
197
|
+
});
|
|
198
|
+
const styles = StyleSheet.create({
|
|
199
|
+
inputContainer: {
|
|
200
|
+
height: INPUT_HEIGHT,
|
|
201
|
+
flex: 1,
|
|
202
|
+
flexDirection: 'row',
|
|
203
|
+
alignItems: 'center',
|
|
204
|
+
overflow: 'hidden'
|
|
205
|
+
},
|
|
206
|
+
prominentContainer: {
|
|
207
|
+
borderWidth: 1,
|
|
208
|
+
borderColor: Colors.$outlineDefault,
|
|
209
|
+
borderRadius: BorderRadiuses.br20,
|
|
210
|
+
marginHorizontal: Spacings.s5
|
|
211
|
+
},
|
|
212
|
+
input: {
|
|
213
|
+
flex: 1,
|
|
214
|
+
...Typography.body,
|
|
215
|
+
lineHeight: undefined,
|
|
216
|
+
color: Colors.$textDefault,
|
|
217
|
+
textAlign: Constants.isRTL ? 'right' : 'left'
|
|
218
|
+
},
|
|
219
|
+
emptyInput: {
|
|
220
|
+
marginRight: Spacings.s4
|
|
221
|
+
},
|
|
222
|
+
cancelButton: {
|
|
223
|
+
marginLeft: Spacings.s4,
|
|
224
|
+
marginRight: Spacings.s4
|
|
225
|
+
},
|
|
226
|
+
clearButton: {
|
|
227
|
+
marginRight: Spacings.s4
|
|
228
|
+
},
|
|
229
|
+
icon: {
|
|
230
|
+
marginRight: Spacings.s4
|
|
231
|
+
},
|
|
232
|
+
leftIcon: {
|
|
233
|
+
marginLeft: Spacings.s4
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
SearchInput.displayName = 'SearchInput';
|
|
237
|
+
export { SearchInput, SearchInputProps, SearchInputRef, SearchInputPresets };
|
|
238
|
+
export default asBaseComponent(SearchInput);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "SearchInput",
|
|
3
|
+
"category": "form",
|
|
4
|
+
"description": "Search input for filtering purpose",
|
|
5
|
+
"example": "https://github.com/wix-private/wix-react-native-ui-lib/blob/master/example/screens/components/SearchInputScreen.tsx",
|
|
6
|
+
"extends": ["TextInput"],
|
|
7
|
+
"extendsLink": "https://reactnative.dev/docs/textinput",
|
|
8
|
+
"props": [
|
|
9
|
+
{"name": "onDismiss", "type": "() => void", "description": "callback for dismiss action"},
|
|
10
|
+
{"name": "onClear", "type": "() => void", "description": "On clear button callback."},
|
|
11
|
+
{"name": "title", "type": "string", "description": "Title prop."},
|
|
12
|
+
{"name": "showFilterIcon", "type": "boolean", "description": "Pass true to add filter icon on the right."},
|
|
13
|
+
{
|
|
14
|
+
"name": "showLoader",
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"description": "Whether to show a loader instead of the left search icon."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "renderLoaderElement",
|
|
20
|
+
"type": " () => React.ReactElement",
|
|
21
|
+
"description": "custom loader element to render instead of the default loader"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "renderLoaderElement",
|
|
25
|
+
"type": " () => React.ReactElement",
|
|
26
|
+
"description": "custom loader element to render instead of the default loader"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "cancelButtonProps",
|
|
30
|
+
"type": "ButtonProps",
|
|
31
|
+
"description": "Props for the cancel button"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "schemeColor",
|
|
35
|
+
"type": "string | null",
|
|
36
|
+
"description": "The SearchInput colors (affects the search icon color, the filter icon color when 'showFilterIcon' is passed and the cancel button color)"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "inaccessible",
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"description": "Turn off accessibility for this view and its nested children"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "useSafeArea",
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "in case the SearchInput is rendered in a safe area (top of the screen)"
|
|
47
|
+
},
|
|
48
|
+
{"name": "containerStyle", "type": "ViewStyle", "description": "Override styles for the input"},
|
|
49
|
+
{"name": "style", "type": "ViewStyle", "description": "Override styles for container"}
|
|
50
|
+
],
|
|
51
|
+
"snippet": [
|
|
52
|
+
"<SearchInput",
|
|
53
|
+
" ref={searchInputRef$1}",
|
|
54
|
+
" testID={'searchInput'$2}",
|
|
55
|
+
" placeholder={'Search'$3}",
|
|
56
|
+
" onDismiss={onDismiss$4}",
|
|
57
|
+
" showFilterIcon={showFilterIcon$5}",
|
|
58
|
+
"/>"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextInputProps, StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
import { ButtonProps } from '../button';
|
|
4
|
+
export declare enum SearchInputPresets {
|
|
5
|
+
DEFAULT = "default",
|
|
6
|
+
PROMINENT = "prominent"
|
|
7
|
+
}
|
|
8
|
+
export interface SearchInputRef {
|
|
9
|
+
blur: () => void;
|
|
10
|
+
clear: () => void;
|
|
11
|
+
focus: () => void;
|
|
12
|
+
}
|
|
13
|
+
export type SearchInputProps = TextInputProps & {
|
|
14
|
+
/**
|
|
15
|
+
* On clear button callback.
|
|
16
|
+
*/
|
|
17
|
+
onClear?: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* callback for dismiss action
|
|
20
|
+
*/
|
|
21
|
+
onDismiss?: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* The SearchInput colors (affects the search icon color, the filter icon color when 'showFilterIcon' is passed and the cancel button color)
|
|
24
|
+
*/
|
|
25
|
+
schemeColor?: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Title prop
|
|
28
|
+
*/
|
|
29
|
+
title?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Pass true to add filter icon on the right
|
|
32
|
+
*/
|
|
33
|
+
showFilterIcon?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to show a loader instead of the left search icon
|
|
36
|
+
*/
|
|
37
|
+
showLoader?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* custom loader element
|
|
40
|
+
*/
|
|
41
|
+
renderLoaderElement?: () => React.ReactElement;
|
|
42
|
+
/**
|
|
43
|
+
* converts the colors of the search's input elements, icons and button to white
|
|
44
|
+
*/
|
|
45
|
+
invertColors?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Turn off accessibility for this view and its nested children
|
|
48
|
+
*/
|
|
49
|
+
inaccessible?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* in case the SearchInput is rendered in a safe area (top of the screen)
|
|
52
|
+
*/
|
|
53
|
+
useSafeArea?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Override styles for container
|
|
56
|
+
*/
|
|
57
|
+
style?: StyleProp<ViewStyle>;
|
|
58
|
+
/**
|
|
59
|
+
* Override styles for the input
|
|
60
|
+
*/
|
|
61
|
+
containerStyle?: StyleProp<ViewStyle | TextStyle>;
|
|
62
|
+
/**
|
|
63
|
+
* The preset for the search input: default or prominent
|
|
64
|
+
*/
|
|
65
|
+
preset?: SearchInputPresets | `${SearchInputPresets}`;
|
|
66
|
+
/**
|
|
67
|
+
* Props for the cancel button
|
|
68
|
+
*/
|
|
69
|
+
cancelButtonProps?: ButtonProps;
|
|
70
|
+
};
|
|
@@ -149,7 +149,7 @@ const TabBar = props => {
|
|
|
149
149
|
}, [labelColor, selectedLabelColor]);
|
|
150
150
|
return <View style={_containerStyle} key={key} bg-$backgroundElevated>
|
|
151
151
|
<FadedScrollView ref={tabBar} horizontal showsHorizontalScrollIndicator={false} showStartFader startFaderProps={faderProps} showEndFader endFaderProps={faderProps} contentContainerStyle={scrollViewContainerStyle} testID={testID} onContentSizeChange={onContentSizeChange} onLayout={onLayout}>
|
|
152
|
-
<View style={tabBarContainerStyle}>{tabBarItems}</View>
|
|
152
|
+
<View style={tabBarContainerStyle} accessibilityRole={Constants.isIOS ? 'tabbar' : 'tablist'}>{tabBarItems}</View>
|
|
153
153
|
{itemsCount > 1 && <Reanimated.View style={[styles.selectedIndicator, indicatorStyle, _indicatorTransitionStyle]} />}
|
|
154
154
|
</FadedScrollView>
|
|
155
155
|
</View>;
|
|
@@ -3,9 +3,9 @@ import _isEmpty from "lodash/isEmpty";
|
|
|
3
3
|
import _isUndefined from "lodash/isUndefined";
|
|
4
4
|
import _cloneDeep from "lodash/cloneDeep";
|
|
5
5
|
// TODO: support commented props
|
|
6
|
-
import React, { useCallback, useContext, useEffect, useRef, useMemo } from 'react';
|
|
6
|
+
import React, { useCallback, useContext, useEffect, useRef, useMemo, useState } from 'react';
|
|
7
7
|
import { StyleSheet } from 'react-native';
|
|
8
|
-
import Reanimated, { runOnJS, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
8
|
+
import Reanimated, { runOnJS, useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
9
9
|
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
10
10
|
import { Colors, Typography, Spacings } from "../../style";
|
|
11
11
|
import Badge from "../badge";
|
|
@@ -52,6 +52,7 @@ export default function TabBarItem({
|
|
|
52
52
|
// JSON.parse(JSON.stringify is due to an issue with reanimated
|
|
53
53
|
const sharedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(StyleSheet.flatten(labelStyle))));
|
|
54
54
|
const sharedSelectedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(StyleSheet.flatten(selectedLabelStyle))));
|
|
55
|
+
const [isSelected, setIsSelected] = useState(currentPage.value === index);
|
|
55
56
|
|
|
56
57
|
// NOTE: We clone these color values in refs because they might contain a PlatformColor value
|
|
57
58
|
// which throws an error (see https://github.com/software-mansion/react-native-reanimated/issues/3164)
|
|
@@ -71,6 +72,11 @@ export default function TabBarItem({
|
|
|
71
72
|
}, index);
|
|
72
73
|
}
|
|
73
74
|
}, []);
|
|
75
|
+
useAnimatedReaction(() => currentPage.value === index, (isSelected, prevIsSelected) => {
|
|
76
|
+
if (isSelected !== prevIsSelected) {
|
|
77
|
+
runOnJS(setIsSelected)(isSelected);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
74
80
|
const onLayout = useCallback(event => {
|
|
75
81
|
const {
|
|
76
82
|
width
|
|
@@ -120,6 +126,9 @@ export default function TabBarItem({
|
|
|
120
126
|
flex
|
|
121
127
|
}, style, constantWidthStyle, pressStyle];
|
|
122
128
|
}, [style, spreadItems]);
|
|
129
|
+
const accessibilityState = useMemo(() => ({
|
|
130
|
+
selected: isSelected
|
|
131
|
+
}), [isSelected]);
|
|
123
132
|
const gesture = Gesture.Tap().maxDuration(60000).onEnd(() => {
|
|
124
133
|
if (!ignore) {
|
|
125
134
|
setCurrentIndex(index);
|
|
@@ -133,7 +142,7 @@ export default function TabBarItem({
|
|
|
133
142
|
return <GestureDetector gesture={gesture}>
|
|
134
143
|
<View reanimated
|
|
135
144
|
// @ts-expect-error
|
|
136
|
-
ref={itemRef} style={_style} onLayout={onLayout} testID={testID}>
|
|
145
|
+
ref={itemRef} style={_style} onLayout={onLayout} testID={testID} accessible accessibilityRole="tab" accessibilityState={accessibilityState}>
|
|
137
146
|
{leadingAccessory}
|
|
138
147
|
{icon && <Reanimated.Image source={icon} style={[!_isUndefined(label) && styles.tabItemIconWithLabel, animatedIconStyle]} />}
|
|
139
148
|
{!_isEmpty(label) && <Reanimated.Text {...labelProps} fsTagName={'unmask'} style={[styles.tabItemLabel, labelStyle, animatedLabelStyle, animatedLabelColorStyle]}>
|
package/src/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export { default as RadioGroup, RadioGroupProps } from './components/radioGroup'
|
|
|
76
76
|
export type { RecorderProps } from './typings/recorderTypes';
|
|
77
77
|
export type { ComponentStatics } from './typings/common';
|
|
78
78
|
export { default as ScrollBar, ScrollBarProps } from './components/scrollBar';
|
|
79
|
+
export { default as SearchInput, SearchInputProps, SearchInputRef, SearchInputPresets } from './components/searchInput';
|
|
79
80
|
export { default as SectionsWheelPicker, SectionsWheelPickerProps } from './components/sectionsWheelPicker';
|
|
80
81
|
export { default as SegmentedControl, SegmentedControlProps, SegmentedControlItemProps, SegmentedControlPreset } from './components/segmentedControl';
|
|
81
82
|
export { default as SharedTransition } from './components/sharedTransition';
|
package/src/index.js
CHANGED
|
@@ -178,6 +178,10 @@ var _exportNames = {
|
|
|
178
178
|
RadioGroupProps: true,
|
|
179
179
|
ScrollBar: true,
|
|
180
180
|
ScrollBarProps: true,
|
|
181
|
+
SearchInput: true,
|
|
182
|
+
SearchInputProps: true,
|
|
183
|
+
SearchInputRef: true,
|
|
184
|
+
SearchInputPresets: true,
|
|
181
185
|
SectionsWheelPicker: true,
|
|
182
186
|
SectionsWheelPickerProps: true,
|
|
183
187
|
SegmentedControl: true,
|
|
@@ -1206,6 +1210,30 @@ Object.defineProperty(exports, "ScrollBarProps", {
|
|
|
1206
1210
|
return _scrollBar().ScrollBarProps;
|
|
1207
1211
|
}
|
|
1208
1212
|
});
|
|
1213
|
+
Object.defineProperty(exports, "SearchInput", {
|
|
1214
|
+
enumerable: true,
|
|
1215
|
+
get: function () {
|
|
1216
|
+
return _searchInput().default;
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
Object.defineProperty(exports, "SearchInputPresets", {
|
|
1220
|
+
enumerable: true,
|
|
1221
|
+
get: function () {
|
|
1222
|
+
return _searchInput().SearchInputPresets;
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
Object.defineProperty(exports, "SearchInputProps", {
|
|
1226
|
+
enumerable: true,
|
|
1227
|
+
get: function () {
|
|
1228
|
+
return _searchInput().SearchInputProps;
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
Object.defineProperty(exports, "SearchInputRef", {
|
|
1232
|
+
enumerable: true,
|
|
1233
|
+
get: function () {
|
|
1234
|
+
return _searchInput().SearchInputRef;
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1209
1237
|
Object.defineProperty(exports, "SectionsWheelPicker", {
|
|
1210
1238
|
enumerable: true,
|
|
1211
1239
|
get: function () {
|
|
@@ -2193,6 +2221,13 @@ function _scrollBar() {
|
|
|
2193
2221
|
};
|
|
2194
2222
|
return data;
|
|
2195
2223
|
}
|
|
2224
|
+
function _searchInput() {
|
|
2225
|
+
const data = _interopRequireWildcard(require("./components/searchInput"));
|
|
2226
|
+
_searchInput = function () {
|
|
2227
|
+
return data;
|
|
2228
|
+
};
|
|
2229
|
+
return data;
|
|
2230
|
+
}
|
|
2196
2231
|
function _sectionsWheelPicker() {
|
|
2197
2232
|
const data = _interopRequireWildcard(require("./components/sectionsWheelPicker"));
|
|
2198
2233
|
_sectionsWheelPicker = function () {
|