@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.
Files changed (126) hide show
  1. package/lib/commonjs/Header/Header.js +95 -30
  2. package/lib/commonjs/Header/Header.js.map +1 -1
  3. package/lib/commonjs/Header/HeaderBackButton.js +7 -21
  4. package/lib/commonjs/Header/HeaderBackButton.js.map +1 -1
  5. package/lib/commonjs/Header/HeaderIcon.js +44 -0
  6. package/lib/commonjs/Header/HeaderIcon.js.map +1 -0
  7. package/lib/commonjs/Header/HeaderSearchBar.js +267 -0
  8. package/lib/commonjs/Header/HeaderSearchBar.js.map +1 -0
  9. package/lib/commonjs/PlatformPressable.js +4 -2
  10. package/lib/commonjs/PlatformPressable.js.map +1 -1
  11. package/lib/commonjs/Screen.js +16 -15
  12. package/lib/commonjs/Screen.js.map +1 -1
  13. package/lib/commonjs/assets/back-icon-mask.png +0 -0
  14. package/lib/commonjs/assets/back-icon@4x.ios.png +0 -0
  15. package/lib/commonjs/assets/clear-icon.png +0 -0
  16. package/lib/commonjs/assets/clear-icon@1x.png +0 -0
  17. package/lib/commonjs/assets/clear-icon@2x.png +0 -0
  18. package/lib/commonjs/assets/clear-icon@3x.png +0 -0
  19. package/lib/commonjs/assets/clear-icon@4x.png +0 -0
  20. package/lib/commonjs/assets/close-icon.png +0 -0
  21. package/lib/commonjs/assets/close-icon@1x.png +0 -0
  22. package/lib/commonjs/assets/close-icon@2x.png +0 -0
  23. package/lib/commonjs/assets/close-icon@3x.png +0 -0
  24. package/lib/commonjs/assets/close-icon@4x.png +0 -0
  25. package/lib/commonjs/assets/search-icon.png +0 -0
  26. package/lib/commonjs/assets/search-icon@1x.android.png +0 -0
  27. package/lib/commonjs/assets/search-icon@1x.ios.png +0 -0
  28. package/lib/commonjs/assets/search-icon@2x.android.png +0 -0
  29. package/lib/commonjs/assets/search-icon@2x.ios.png +0 -0
  30. package/lib/commonjs/assets/search-icon@3x.android.png +0 -0
  31. package/lib/commonjs/assets/search-icon@3x.ios.png +0 -0
  32. package/lib/commonjs/assets/search-icon@4x.android.png +0 -0
  33. package/lib/commonjs/assets/search-icon@4x.ios.png +0 -0
  34. package/lib/commonjs/index.js +4 -1
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/module/Header/Header.js +96 -32
  37. package/lib/module/Header/Header.js.map +1 -1
  38. package/lib/module/Header/HeaderBackButton.js +7 -21
  39. package/lib/module/Header/HeaderBackButton.js.map +1 -1
  40. package/lib/module/Header/HeaderIcon.js +39 -0
  41. package/lib/module/Header/HeaderIcon.js.map +1 -0
  42. package/lib/module/Header/HeaderSearchBar.js +260 -0
  43. package/lib/module/Header/HeaderSearchBar.js.map +1 -0
  44. package/lib/module/PlatformPressable.js +4 -2
  45. package/lib/module/PlatformPressable.js.map +1 -1
  46. package/lib/module/Screen.js +16 -15
  47. package/lib/module/Screen.js.map +1 -1
  48. package/lib/module/assets/back-icon-mask.png +0 -0
  49. package/lib/module/assets/back-icon@4x.ios.png +0 -0
  50. package/lib/module/assets/clear-icon.png +0 -0
  51. package/lib/module/assets/clear-icon@1x.png +0 -0
  52. package/lib/module/assets/clear-icon@2x.png +0 -0
  53. package/lib/module/assets/clear-icon@3x.png +0 -0
  54. package/lib/module/assets/clear-icon@4x.png +0 -0
  55. package/lib/module/assets/close-icon.png +0 -0
  56. package/lib/module/assets/close-icon@1x.png +0 -0
  57. package/lib/module/assets/close-icon@2x.png +0 -0
  58. package/lib/module/assets/close-icon@3x.png +0 -0
  59. package/lib/module/assets/close-icon@4x.png +0 -0
  60. package/lib/module/assets/search-icon.png +0 -0
  61. package/lib/module/assets/search-icon@1x.android.png +0 -0
  62. package/lib/module/assets/search-icon@1x.ios.png +0 -0
  63. package/lib/module/assets/search-icon@2x.android.png +0 -0
  64. package/lib/module/assets/search-icon@2x.ios.png +0 -0
  65. package/lib/module/assets/search-icon@3x.android.png +0 -0
  66. package/lib/module/assets/search-icon@3x.ios.png +0 -0
  67. package/lib/module/assets/search-icon@4x.android.png +0 -0
  68. package/lib/module/assets/search-icon@4x.ios.png +0 -0
  69. package/lib/module/index.js +4 -1
  70. package/lib/module/index.js.map +1 -1
  71. package/lib/typescript/commonjs/src/Header/Header.d.ts +13 -0
  72. package/lib/typescript/commonjs/src/Header/Header.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/src/Header/HeaderBackButton.d.ts.map +1 -1
  74. package/lib/typescript/commonjs/src/Header/HeaderIcon.d.ts +5 -0
  75. package/lib/typescript/commonjs/src/Header/HeaderIcon.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/src/Header/HeaderSearchBar.d.ts +10 -0
  77. package/lib/typescript/commonjs/src/Header/HeaderSearchBar.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/src/PlatformPressable.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/src/Screen.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/src/types.d.ts +63 -8
  82. package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
  84. package/lib/typescript/module/src/Header/Header.d.ts +13 -0
  85. package/lib/typescript/module/src/Header/Header.d.ts.map +1 -1
  86. package/lib/typescript/module/src/Header/HeaderBackButton.d.ts.map +1 -1
  87. package/lib/typescript/module/src/Header/HeaderIcon.d.ts +5 -0
  88. package/lib/typescript/module/src/Header/HeaderIcon.d.ts.map +1 -0
  89. package/lib/typescript/module/src/Header/HeaderSearchBar.d.ts +10 -0
  90. package/lib/typescript/module/src/Header/HeaderSearchBar.d.ts.map +1 -0
  91. package/lib/typescript/module/src/PlatformPressable.d.ts.map +1 -1
  92. package/lib/typescript/module/src/Screen.d.ts.map +1 -1
  93. package/lib/typescript/module/src/index.d.ts.map +1 -1
  94. package/lib/typescript/module/src/types.d.ts +63 -8
  95. package/lib/typescript/module/src/types.d.ts.map +1 -1
  96. package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
  97. package/package.json +2 -2
  98. package/src/Header/Header.tsx +142 -53
  99. package/src/Header/HeaderBackButton.tsx +4 -15
  100. package/src/Header/HeaderIcon.tsx +36 -0
  101. package/src/Header/HeaderSearchBar.tsx +283 -0
  102. package/src/PlatformPressable.tsx +6 -1
  103. package/src/Screen.tsx +18 -14
  104. package/src/assets/back-icon-mask.png +0 -0
  105. package/src/assets/back-icon@4x.ios.png +0 -0
  106. package/src/assets/clear-icon.png +0 -0
  107. package/src/assets/clear-icon@1x.png +0 -0
  108. package/src/assets/clear-icon@2x.png +0 -0
  109. package/src/assets/clear-icon@3x.png +0 -0
  110. package/src/assets/clear-icon@4x.png +0 -0
  111. package/src/assets/close-icon.png +0 -0
  112. package/src/assets/close-icon@1x.png +0 -0
  113. package/src/assets/close-icon@2x.png +0 -0
  114. package/src/assets/close-icon@3x.png +0 -0
  115. package/src/assets/close-icon@4x.png +0 -0
  116. package/src/assets/search-icon.png +0 -0
  117. package/src/assets/search-icon@1x.android.png +0 -0
  118. package/src/assets/search-icon@1x.ios.png +0 -0
  119. package/src/assets/search-icon@2x.android.png +0 -0
  120. package/src/assets/search-icon@2x.ios.png +0 -0
  121. package/src/assets/search-icon@3x.android.png +0 -0
  122. package/src/assets/search-icon@3x.ios.png +0 -0
  123. package/src/assets/search-icon@4x.android.png +0 -0
  124. package/src/assets/search-icon@4x.ios.png +0 -0
  125. package/src/index.tsx +10 -1
  126. 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={headerTransparent ? styles.absolute : null}
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
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 = [backIcon, backIconMask];
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?: (props: {
43
- tintColor?: string;
44
- pressColor?: string;
45
- pressOpacity?: number;
46
- displayMode?: HeaderBackButtonDisplayMode;
47
- href?: undefined;
48
- }) => React.ReactNode;
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 Android.
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.