@react-navigation/elements 2.0.0-rc.20 → 2.0.0-rc.21
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/lib/commonjs/Header/Header.js +95 -30
- package/lib/commonjs/Header/Header.js.map +1 -1
- package/lib/commonjs/Header/HeaderBackButton.js +7 -21
- package/lib/commonjs/Header/HeaderBackButton.js.map +1 -1
- package/lib/commonjs/Header/HeaderIcon.js +44 -0
- package/lib/commonjs/Header/HeaderIcon.js.map +1 -0
- package/lib/commonjs/Header/HeaderSearchBar.js +267 -0
- package/lib/commonjs/Header/HeaderSearchBar.js.map +1 -0
- package/lib/commonjs/PlatformPressable.js +4 -2
- package/lib/commonjs/PlatformPressable.js.map +1 -1
- package/lib/commonjs/Screen.js +16 -15
- package/lib/commonjs/Screen.js.map +1 -1
- package/lib/commonjs/assets/back-icon-mask.png +0 -0
- package/lib/commonjs/assets/back-icon@4x.ios.png +0 -0
- package/lib/commonjs/assets/clear-icon.png +0 -0
- package/lib/commonjs/assets/clear-icon@1x.png +0 -0
- package/lib/commonjs/assets/clear-icon@2x.png +0 -0
- package/lib/commonjs/assets/clear-icon@3x.png +0 -0
- package/lib/commonjs/assets/clear-icon@4x.png +0 -0
- package/lib/commonjs/assets/close-icon.png +0 -0
- package/lib/commonjs/assets/close-icon@1x.png +0 -0
- package/lib/commonjs/assets/close-icon@2x.png +0 -0
- package/lib/commonjs/assets/close-icon@3x.png +0 -0
- package/lib/commonjs/assets/close-icon@4x.png +0 -0
- package/lib/commonjs/assets/search-icon.png +0 -0
- package/lib/commonjs/assets/search-icon@1x.android.png +0 -0
- package/lib/commonjs/assets/search-icon@1x.ios.png +0 -0
- package/lib/commonjs/assets/search-icon@2x.android.png +0 -0
- package/lib/commonjs/assets/search-icon@2x.ios.png +0 -0
- package/lib/commonjs/assets/search-icon@3x.android.png +0 -0
- package/lib/commonjs/assets/search-icon@3x.ios.png +0 -0
- package/lib/commonjs/assets/search-icon@4x.android.png +0 -0
- package/lib/commonjs/assets/search-icon@4x.ios.png +0 -0
- package/lib/commonjs/index.js +4 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Header/Header.js +96 -32
- package/lib/module/Header/Header.js.map +1 -1
- package/lib/module/Header/HeaderBackButton.js +7 -21
- package/lib/module/Header/HeaderBackButton.js.map +1 -1
- package/lib/module/Header/HeaderIcon.js +39 -0
- package/lib/module/Header/HeaderIcon.js.map +1 -0
- package/lib/module/Header/HeaderSearchBar.js +260 -0
- package/lib/module/Header/HeaderSearchBar.js.map +1 -0
- package/lib/module/PlatformPressable.js +4 -2
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/Screen.js +16 -15
- package/lib/module/Screen.js.map +1 -1
- package/lib/module/assets/back-icon-mask.png +0 -0
- package/lib/module/assets/back-icon@4x.ios.png +0 -0
- package/lib/module/assets/clear-icon.png +0 -0
- package/lib/module/assets/clear-icon@1x.png +0 -0
- package/lib/module/assets/clear-icon@2x.png +0 -0
- package/lib/module/assets/clear-icon@3x.png +0 -0
- package/lib/module/assets/clear-icon@4x.png +0 -0
- package/lib/module/assets/close-icon.png +0 -0
- package/lib/module/assets/close-icon@1x.png +0 -0
- package/lib/module/assets/close-icon@2x.png +0 -0
- package/lib/module/assets/close-icon@3x.png +0 -0
- package/lib/module/assets/close-icon@4x.png +0 -0
- package/lib/module/assets/search-icon.png +0 -0
- package/lib/module/assets/search-icon@1x.android.png +0 -0
- package/lib/module/assets/search-icon@1x.ios.png +0 -0
- package/lib/module/assets/search-icon@2x.android.png +0 -0
- package/lib/module/assets/search-icon@2x.ios.png +0 -0
- package/lib/module/assets/search-icon@3x.android.png +0 -0
- package/lib/module/assets/search-icon@3x.ios.png +0 -0
- package/lib/module/assets/search-icon@4x.android.png +0 -0
- package/lib/module/assets/search-icon@4x.ios.png +0 -0
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/Header/Header.d.ts +13 -0
- package/lib/typescript/commonjs/src/Header/Header.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Header/HeaderBackButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Header/HeaderIcon.d.ts +5 -0
- package/lib/typescript/commonjs/src/Header/HeaderIcon.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderSearchBar.d.ts +10 -0
- package/lib/typescript/commonjs/src/Header/HeaderSearchBar.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Screen.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +63 -8
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/module/src/Header/Header.d.ts +13 -0
- package/lib/typescript/module/src/Header/Header.d.ts.map +1 -1
- package/lib/typescript/module/src/Header/HeaderBackButton.d.ts.map +1 -1
- package/lib/typescript/module/src/Header/HeaderIcon.d.ts +5 -0
- package/lib/typescript/module/src/Header/HeaderIcon.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderSearchBar.d.ts +10 -0
- package/lib/typescript/module/src/Header/HeaderSearchBar.d.ts.map +1 -0
- package/lib/typescript/module/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/module/src/Screen.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +63 -8
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Header/Header.tsx +142 -53
- package/src/Header/HeaderBackButton.tsx +4 -15
- package/src/Header/HeaderIcon.tsx +36 -0
- package/src/Header/HeaderSearchBar.tsx +283 -0
- package/src/PlatformPressable.tsx +6 -1
- package/src/Screen.tsx +18 -14
- package/src/assets/back-icon-mask.png +0 -0
- package/src/assets/back-icon@4x.ios.png +0 -0
- package/src/assets/clear-icon.png +0 -0
- package/src/assets/clear-icon@1x.png +0 -0
- package/src/assets/clear-icon@2x.png +0 -0
- package/src/assets/clear-icon@3x.png +0 -0
- package/src/assets/clear-icon@4x.png +0 -0
- package/src/assets/close-icon.png +0 -0
- package/src/assets/close-icon@1x.png +0 -0
- package/src/assets/close-icon@2x.png +0 -0
- package/src/assets/close-icon@3x.png +0 -0
- package/src/assets/close-icon@4x.png +0 -0
- package/src/assets/search-icon.png +0 -0
- package/src/assets/search-icon@1x.android.png +0 -0
- package/src/assets/search-icon@1x.ios.png +0 -0
- package/src/assets/search-icon@2x.android.png +0 -0
- package/src/assets/search-icon@2x.ios.png +0 -0
- package/src/assets/search-icon@3x.android.png +0 -0
- package/src/assets/search-icon@3x.ios.png +0 -0
- package/src/assets/search-icon@4x.android.png +0 -0
- package/src/assets/search-icon@4x.ios.png +0 -0
- package/src/index.tsx +10 -1
- package/src/types.tsx +66 -8
package/src/Screen.tsx
CHANGED
|
@@ -70,17 +70,6 @@ export function Screen(props: Props) {
|
|
|
70
70
|
// that we won't render unnecessary views due to the view flattening.
|
|
71
71
|
collapsable={false}
|
|
72
72
|
>
|
|
73
|
-
<View style={styles.content}>
|
|
74
|
-
<HeaderShownContext.Provider
|
|
75
|
-
value={isParentHeaderShown || headerShown !== false}
|
|
76
|
-
>
|
|
77
|
-
<HeaderHeightContext.Provider
|
|
78
|
-
value={headerShown ? headerHeight : parentHeaderHeight ?? 0}
|
|
79
|
-
>
|
|
80
|
-
{children}
|
|
81
|
-
</HeaderHeightContext.Provider>
|
|
82
|
-
</HeaderShownContext.Provider>
|
|
83
|
-
</View>
|
|
84
73
|
{headerShown ? (
|
|
85
74
|
<NavigationContext.Provider value={navigation}>
|
|
86
75
|
<NavigationRouteContext.Provider value={route}>
|
|
@@ -90,13 +79,27 @@ export function Screen(props: Props) {
|
|
|
90
79
|
|
|
91
80
|
setHeaderHeight(height);
|
|
92
81
|
}}
|
|
93
|
-
style={
|
|
82
|
+
style={[
|
|
83
|
+
styles.header,
|
|
84
|
+
headerTransparent ? styles.absolute : null,
|
|
85
|
+
]}
|
|
94
86
|
>
|
|
95
87
|
{header}
|
|
96
88
|
</View>
|
|
97
89
|
</NavigationRouteContext.Provider>
|
|
98
90
|
</NavigationContext.Provider>
|
|
99
91
|
) : null}
|
|
92
|
+
<View style={styles.content}>
|
|
93
|
+
<HeaderShownContext.Provider
|
|
94
|
+
value={isParentHeaderShown || headerShown !== false}
|
|
95
|
+
>
|
|
96
|
+
<HeaderHeightContext.Provider
|
|
97
|
+
value={headerShown ? headerHeight : parentHeaderHeight ?? 0}
|
|
98
|
+
>
|
|
99
|
+
{children}
|
|
100
|
+
</HeaderHeightContext.Provider>
|
|
101
|
+
</HeaderShownContext.Provider>
|
|
102
|
+
</View>
|
|
100
103
|
</Background>
|
|
101
104
|
);
|
|
102
105
|
}
|
|
@@ -104,12 +107,13 @@ export function Screen(props: Props) {
|
|
|
104
107
|
const styles = StyleSheet.create({
|
|
105
108
|
container: {
|
|
106
109
|
flex: 1,
|
|
107
|
-
flexDirection: 'column-reverse',
|
|
108
110
|
},
|
|
109
|
-
// This is necessary to avoid applying 'column-reverse' to screen content
|
|
110
111
|
content: {
|
|
111
112
|
flex: 1,
|
|
112
113
|
},
|
|
114
|
+
header: {
|
|
115
|
+
zIndex: 1,
|
|
116
|
+
},
|
|
113
117
|
absolute: {
|
|
114
118
|
position: 'absolute',
|
|
115
119
|
top: 0,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import backIcon from './assets/back-icon.png';
|
|
2
2
|
import backIconMask from './assets/back-icon-mask.png';
|
|
3
|
+
import clearIcon from './assets/clear-icon.png';
|
|
4
|
+
import closeIcon from './assets/close-icon.png';
|
|
5
|
+
import searchIcon from './assets/search-icon.png';
|
|
3
6
|
|
|
4
7
|
export { Background } from './Background';
|
|
5
8
|
export { Button } from './Button';
|
|
@@ -24,6 +27,12 @@ export { SafeAreaProviderCompat } from './SafeAreaProviderCompat';
|
|
|
24
27
|
export { Screen } from './Screen';
|
|
25
28
|
export { Text } from './Text';
|
|
26
29
|
|
|
27
|
-
export const Assets = [
|
|
30
|
+
export const Assets = [
|
|
31
|
+
backIcon,
|
|
32
|
+
backIconMask,
|
|
33
|
+
searchIcon,
|
|
34
|
+
closeIcon,
|
|
35
|
+
clearIcon,
|
|
36
|
+
];
|
|
28
37
|
|
|
29
38
|
export * from './types';
|
package/src/types.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
Animated,
|
|
3
3
|
LayoutChangeEvent,
|
|
4
4
|
StyleProp,
|
|
5
|
+
TextInputProps,
|
|
5
6
|
TextStyle,
|
|
6
7
|
ViewStyle,
|
|
7
8
|
} from 'react-native';
|
|
@@ -10,6 +11,48 @@ export type HeaderBackButtonDisplayMode = 'default' | 'generic' | 'minimal';
|
|
|
10
11
|
|
|
11
12
|
export type Layout = { width: number; height: number };
|
|
12
13
|
|
|
14
|
+
type HeaderSearchBarOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* The auto-capitalization behavior
|
|
17
|
+
*/
|
|
18
|
+
autoCapitalize?: 'none' | 'words' | 'sentences' | 'characters';
|
|
19
|
+
/**
|
|
20
|
+
* Automatically focuses search input on mount
|
|
21
|
+
*/
|
|
22
|
+
autoFocus?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The text to be used instead of default `Cancel` button text
|
|
25
|
+
*
|
|
26
|
+
* @platform ios
|
|
27
|
+
*/
|
|
28
|
+
cancelButtonText?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Sets type of the input. Defaults to `text`.
|
|
31
|
+
*/
|
|
32
|
+
inputType?: 'text' | 'phone' | 'number' | 'email';
|
|
33
|
+
/**
|
|
34
|
+
* A callback that gets called when search input has lost focus
|
|
35
|
+
*/
|
|
36
|
+
onBlur?: TextInputProps['onBlur'];
|
|
37
|
+
/**
|
|
38
|
+
* A callback that gets called when the text changes.
|
|
39
|
+
* It receives the current text value of the search input.
|
|
40
|
+
*/
|
|
41
|
+
onChangeText?: TextInputProps['onChange'];
|
|
42
|
+
/**
|
|
43
|
+
* A callback that gets called when search input is closed
|
|
44
|
+
*/
|
|
45
|
+
onClose?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* A callback that gets called when search input has received focus
|
|
48
|
+
*/
|
|
49
|
+
onFocus?: TextInputProps['onFocus'];
|
|
50
|
+
/**
|
|
51
|
+
* Text displayed when search field is empty
|
|
52
|
+
*/
|
|
53
|
+
placeholder?: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
13
56
|
export type HeaderOptions = {
|
|
14
57
|
/**
|
|
15
58
|
* String or a function that returns a React Element to be used by the header.
|
|
@@ -36,16 +79,21 @@ export type HeaderOptions = {
|
|
|
36
79
|
* Whether header title font should scale to respect Text Size accessibility settings. Defaults to `false`.
|
|
37
80
|
*/
|
|
38
81
|
headerTitleAllowFontScaling?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Options to render a search bar.
|
|
84
|
+
*/
|
|
85
|
+
headerSearchBarOptions?: HeaderSearchBarOptions;
|
|
39
86
|
/**
|
|
40
87
|
* Function which returns a React Element to display on the left side of the header.
|
|
41
88
|
*/
|
|
42
|
-
headerLeft?: (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
89
|
+
headerLeft?: (
|
|
90
|
+
props: HeaderBackButtonProps & {
|
|
91
|
+
/**
|
|
92
|
+
* Whether it's possible to navigate back.
|
|
93
|
+
*/
|
|
94
|
+
canGoBack?: boolean;
|
|
95
|
+
}
|
|
96
|
+
) => React.ReactNode;
|
|
49
97
|
/**
|
|
50
98
|
* How the back button displays icon and title.
|
|
51
99
|
*
|
|
@@ -54,9 +102,18 @@ export type HeaderOptions = {
|
|
|
54
102
|
* - "generic" – Displays one of the following depending on the available space: truncated title (e.g. 'Back') or no title (only icon).
|
|
55
103
|
* - "minimal" – Always displays only the icon without a title.
|
|
56
104
|
*
|
|
57
|
-
* Defaults to "default" on iOS, and "minimal" on
|
|
105
|
+
* Defaults to "default" on iOS, and "minimal" on other platforms.
|
|
58
106
|
*/
|
|
59
107
|
headerBackButtonDisplayMode?: HeaderBackButtonDisplayMode;
|
|
108
|
+
/**
|
|
109
|
+
* Style object for header back title. Supported properties:
|
|
110
|
+
* - fontFamily
|
|
111
|
+
* - fontSize
|
|
112
|
+
*/
|
|
113
|
+
headerBackTitleStyle?: StyleProp<{
|
|
114
|
+
fontFamily?: string;
|
|
115
|
+
fontSize?: number;
|
|
116
|
+
}>;
|
|
60
117
|
/**
|
|
61
118
|
* Style object for the container of the `headerLeft` element`.
|
|
62
119
|
*/
|
|
@@ -68,6 +125,7 @@ export type HeaderOptions = {
|
|
|
68
125
|
tintColor?: string;
|
|
69
126
|
pressColor?: string;
|
|
70
127
|
pressOpacity?: number;
|
|
128
|
+
canGoBack: boolean;
|
|
71
129
|
}) => React.ReactNode;
|
|
72
130
|
/**
|
|
73
131
|
* Style object for the container of the `headerRight` element.
|