@react-navigation/elements 1.1.2 → 1.3.1

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 (55) hide show
  1. package/lib/commonjs/Background.js +5 -4
  2. package/lib/commonjs/Background.js.map +1 -1
  3. package/lib/commonjs/Header/Header.js +8 -2
  4. package/lib/commonjs/Header/Header.js.map +1 -1
  5. package/lib/commonjs/Header/HeaderBackButton.js +20 -19
  6. package/lib/commonjs/Header/HeaderBackButton.js.map +1 -1
  7. package/lib/commonjs/Header/HeaderBackground.js +5 -4
  8. package/lib/commonjs/Header/HeaderBackground.js.map +1 -1
  9. package/lib/commonjs/Header/HeaderTitle.js +6 -5
  10. package/lib/commonjs/Header/HeaderTitle.js.map +1 -1
  11. package/lib/commonjs/Header/getDefaultHeaderHeight.js +1 -1
  12. package/lib/commonjs/Header/getDefaultHeaderHeight.js.map +1 -1
  13. package/lib/commonjs/MaskedView.js +4 -3
  14. package/lib/commonjs/MaskedView.js.map +1 -1
  15. package/lib/commonjs/MaskedViewNative.js +6 -4
  16. package/lib/commonjs/MaskedViewNative.js.map +1 -1
  17. package/lib/commonjs/MissingIcon.js +6 -5
  18. package/lib/commonjs/MissingIcon.js.map +1 -1
  19. package/lib/commonjs/PlatformPressable.js +10 -9
  20. package/lib/commonjs/PlatformPressable.js.map +1 -1
  21. package/lib/commonjs/ResourceSavingView.js +8 -6
  22. package/lib/commonjs/ResourceSavingView.js.map +1 -1
  23. package/lib/commonjs/SafeAreaProviderCompat.js +5 -4
  24. package/lib/commonjs/SafeAreaProviderCompat.js.map +1 -1
  25. package/lib/commonjs/index.js +19 -19
  26. package/lib/module/Background.js +5 -4
  27. package/lib/module/Background.js.map +1 -1
  28. package/lib/module/Header/Header.js +8 -2
  29. package/lib/module/Header/Header.js.map +1 -1
  30. package/lib/module/Header/HeaderBackButton.js +20 -19
  31. package/lib/module/Header/HeaderBackButton.js.map +1 -1
  32. package/lib/module/Header/HeaderBackground.js +5 -4
  33. package/lib/module/Header/HeaderBackground.js.map +1 -1
  34. package/lib/module/Header/HeaderTitle.js +6 -5
  35. package/lib/module/Header/HeaderTitle.js.map +1 -1
  36. package/lib/module/Header/getDefaultHeaderHeight.js +1 -1
  37. package/lib/module/Header/getDefaultHeaderHeight.js.map +1 -1
  38. package/lib/module/MaskedView.js +4 -3
  39. package/lib/module/MaskedView.js.map +1 -1
  40. package/lib/module/MaskedViewNative.js +6 -4
  41. package/lib/module/MaskedViewNative.js.map +1 -1
  42. package/lib/module/MissingIcon.js +6 -5
  43. package/lib/module/MissingIcon.js.map +1 -1
  44. package/lib/module/PlatformPressable.js +10 -9
  45. package/lib/module/PlatformPressable.js.map +1 -1
  46. package/lib/module/ResourceSavingView.js +8 -6
  47. package/lib/module/ResourceSavingView.js.map +1 -1
  48. package/lib/module/SafeAreaProviderCompat.js +5 -4
  49. package/lib/module/SafeAreaProviderCompat.js.map +1 -1
  50. package/lib/typescript/src/types.d.ts +35 -16
  51. package/package.json +5 -5
  52. package/src/Header/Header.tsx +12 -2
  53. package/src/Header/HeaderBackButton.tsx +3 -2
  54. package/src/Header/getDefaultHeaderHeight.tsx +1 -1
  55. package/src/types.tsx +36 -16
@@ -1 +1 @@
1
- {"version":3,"sources":["SafeAreaProviderCompat.tsx"],"names":["React","Dimensions","Platform","StyleSheet","View","initialWindowMetrics","SafeAreaInsetsContext","SafeAreaProvider","width","height","get","initialMetrics","OS","frame","x","y","insets","top","left","right","bottom","SafeAreaProviderCompat","children","style","styles","container","create","flex"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,UADF,EAEEC,QAFF,EAIEC,UAJF,EAKEC,IALF,QAOO,cAPP;AAQA,SACEC,oBADF,EAEEC,qBAFF,EAGEC,gBAHF,QAIO,gCAJP;AAWA,MAAM;AAAEC,EAAAA,KAAK,GAAG,CAAV;AAAaC,EAAAA,MAAM,GAAG;AAAtB,IAA4BR,UAAU,CAACS,GAAX,CAAe,QAAf,CAAlC,C,CAEA;AACA;AACA;;AACA,MAAMC,cAAc,GAClBT,QAAQ,CAACU,EAAT,KAAgB,KAAhB,IAAyBP,oBAAoB,IAAI,IAAjD,GACI;AACEQ,EAAAA,KAAK,EAAE;AAAEC,IAAAA,CAAC,EAAE,CAAL;AAAQC,IAAAA,CAAC,EAAE,CAAX;AAAcP,IAAAA,KAAd;AAAqBC,IAAAA;AAArB,GADT;AAEEO,EAAAA,MAAM,EAAE;AAAEC,IAAAA,GAAG,EAAE,CAAP;AAAUC,IAAAA,IAAI,EAAE,CAAhB;AAAmBC,IAAAA,KAAK,EAAE,CAA1B;AAA6BC,IAAAA,MAAM,EAAE;AAArC;AAFV,CADJ,GAKIf,oBANN;AAQA,eAAe,SAASgB,sBAAT,CAAgC;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAAhC,EAA4D;AACzE,sBACE,oBAAC,qBAAD,CAAuB,QAAvB,QACIP,MAAD,IAAY;AACX,QAAIA,MAAJ,EAAY;AACV;AACA;AACA;AACA,0BAAO,oBAAC,IAAD;AAAM,QAAA,KAAK,EAAE,CAACQ,MAAM,CAACC,SAAR,EAAmBF,KAAnB;AAAb,SAAyCD,QAAzC,CAAP;AACD;;AAED,wBACE,oBAAC,gBAAD;AAAkB,MAAA,cAAc,EAAEX,cAAlC;AAAkD,MAAA,KAAK,EAAEY;AAAzD,OACGD,QADH,CADF;AAKD,GAdH,CADF;AAkBD;AAEDD,sBAAsB,CAACV,cAAvB,GAAwCA,cAAxC;AAEA,MAAMa,MAAM,GAAGrB,UAAU,CAACuB,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AACTE,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n Dimensions,\n Platform,\n StyleProp,\n StyleSheet,\n View,\n ViewStyle,\n} from 'react-native';\nimport {\n initialWindowMetrics,\n SafeAreaInsetsContext,\n SafeAreaProvider,\n} from 'react-native-safe-area-context';\n\ntype Props = {\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n};\n\nconst { width = 0, height = 0 } = Dimensions.get('window');\n\n// To support SSR on web, we need to have empty insets for initial values\n// Otherwise there can be mismatch between SSR and client output\n// We also need to specify empty values to support tests environments\nconst initialMetrics =\n Platform.OS === 'web' || initialWindowMetrics == null\n ? {\n frame: { x: 0, y: 0, width, height },\n insets: { top: 0, left: 0, right: 0, bottom: 0 },\n }\n : initialWindowMetrics;\n\nexport default function SafeAreaProviderCompat({ children, style }: Props) {\n return (\n <SafeAreaInsetsContext.Consumer>\n {(insets) => {\n if (insets) {\n // If we already have insets, don't wrap the stack in another safe area provider\n // This avoids an issue with updates at the cost of potentially incorrect values\n // https://github.com/react-navigation/react-navigation/issues/174\n return <View style={[styles.container, style]}>{children}</View>;\n }\n\n return (\n <SafeAreaProvider initialMetrics={initialMetrics} style={style}>\n {children}\n </SafeAreaProvider>\n );\n }}\n </SafeAreaInsetsContext.Consumer>\n );\n}\n\nSafeAreaProviderCompat.initialMetrics = initialMetrics;\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
1
+ {"version":3,"sources":["SafeAreaProviderCompat.tsx"],"names":["React","Dimensions","Platform","StyleSheet","View","initialWindowMetrics","SafeAreaInsetsContext","SafeAreaProvider","width","height","get","initialMetrics","OS","frame","x","y","insets","top","left","right","bottom","SafeAreaProviderCompat","children","style","styles","container","create","flex"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,UADF,EAEEC,QAFF,EAIEC,UAJF,EAKEC,IALF,QAOO,cAPP;AAQA,SACEC,oBADF,EAEEC,qBAFF,EAGEC,gBAHF,QAIO,gCAJP;AAWA,MAAM;AAAEC,EAAAA,KAAK,GAAG,CAAV;AAAaC,EAAAA,MAAM,GAAG;AAAtB,IAA4BR,UAAU,CAACS,GAAX,CAAe,QAAf,CAAlC,C,CAEA;AACA;AACA;;AACA,MAAMC,cAAc,GAClBT,QAAQ,CAACU,EAAT,KAAgB,KAAhB,IAAyBP,oBAAoB,IAAI,IAAjD,GACI;AACEQ,EAAAA,KAAK,EAAE;AAAEC,IAAAA,CAAC,EAAE,CAAL;AAAQC,IAAAA,CAAC,EAAE,CAAX;AAAcP,IAAAA,KAAd;AAAqBC,IAAAA;AAArB,GADT;AAEEO,EAAAA,MAAM,EAAE;AAAEC,IAAAA,GAAG,EAAE,CAAP;AAAUC,IAAAA,IAAI,EAAE,CAAhB;AAAmBC,IAAAA,KAAK,EAAE,CAA1B;AAA6BC,IAAAA,MAAM,EAAE;AAArC;AAFV,CADJ,GAKIf,oBANN;AAQA,eAAe,SAASgB,sBAAT,OAA4D;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACzE,sBACE,oBAAC,qBAAD,CAAuB,QAAvB,QACIP,MAAD,IAAY;AACX,QAAIA,MAAJ,EAAY;AACV;AACA;AACA;AACA,0BAAO,oBAAC,IAAD;AAAM,QAAA,KAAK,EAAE,CAACQ,MAAM,CAACC,SAAR,EAAmBF,KAAnB;AAAb,SAAyCD,QAAzC,CAAP;AACD;;AAED,wBACE,oBAAC,gBAAD;AAAkB,MAAA,cAAc,EAAEX,cAAlC;AAAkD,MAAA,KAAK,EAAEY;AAAzD,OACGD,QADH,CADF;AAKD,GAdH,CADF;AAkBD;AAEDD,sBAAsB,CAACV,cAAvB,GAAwCA,cAAxC;AAEA,MAAMa,MAAM,GAAGrB,UAAU,CAACuB,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AACTE,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n Dimensions,\n Platform,\n StyleProp,\n StyleSheet,\n View,\n ViewStyle,\n} from 'react-native';\nimport {\n initialWindowMetrics,\n SafeAreaInsetsContext,\n SafeAreaProvider,\n} from 'react-native-safe-area-context';\n\ntype Props = {\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n};\n\nconst { width = 0, height = 0 } = Dimensions.get('window');\n\n// To support SSR on web, we need to have empty insets for initial values\n// Otherwise there can be mismatch between SSR and client output\n// We also need to specify empty values to support tests environments\nconst initialMetrics =\n Platform.OS === 'web' || initialWindowMetrics == null\n ? {\n frame: { x: 0, y: 0, width, height },\n insets: { top: 0, left: 0, right: 0, bottom: 0 },\n }\n : initialWindowMetrics;\n\nexport default function SafeAreaProviderCompat({ children, style }: Props) {\n return (\n <SafeAreaInsetsContext.Consumer>\n {(insets) => {\n if (insets) {\n // If we already have insets, don't wrap the stack in another safe area provider\n // This avoids an issue with updates at the cost of potentially incorrect values\n // https://github.com/react-navigation/react-navigation/issues/174\n return <View style={[styles.container, style]}>{children}</View>;\n }\n\n return (\n <SafeAreaProvider initialMetrics={initialMetrics} style={style}>\n {children}\n </SafeAreaProvider>\n );\n }}\n </SafeAreaInsetsContext.Consumer>\n );\n}\n\nSafeAreaProviderCompat.initialMetrics = initialMetrics;\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
@@ -73,7 +73,7 @@ export declare type HeaderOptions = {
73
73
  headerTintColor?: string;
74
74
  /**
75
75
  * Function which returns a React Element to render as the background of the header.
76
- * This is useful for using backgrounds such as an image or a gradient.
76
+ * This is useful for using backgrounds such as an image, a gradient, blur effect etc.
77
77
  * You can use this with `headerTransparent` to render a blur view, for example, to create a translucent header.
78
78
  */
79
79
  headerBackground?: (props: {
@@ -93,6 +93,23 @@ export declare type HeaderOptions = {
93
93
  * Style object for the header. You can specify a custom background color here, for example.
94
94
  */
95
95
  headerStyle?: StyleProp<ViewStyle>;
96
+ /**
97
+ * Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.
98
+ *
99
+ * This is a short-hand for the following styles:
100
+ *
101
+ * ```js
102
+ * {
103
+ * elevation: 0,
104
+ * shadowOpacity: 0,
105
+ * borderBottomWidth: 0,
106
+ * }
107
+ * ```
108
+ *
109
+ * If the above styles are specified in `headerStyle` along with `headerShadowVisible: false`,
110
+ * then `headerShadowVisible: false` will take precedence.
111
+ */
112
+ headerShadowVisible?: boolean;
96
113
  /**
97
114
  * Extra padding to add at the top of header to account for translucent status bar.
98
115
  * By default, it uses the top value from the safe area insets of the device.
@@ -122,15 +139,11 @@ export declare type HeaderTitleProps = {
122
139
  */
123
140
  style?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
124
141
  };
125
- export declare type HeaderBackButtonProps = {
142
+ export declare type HeaderButtonProps = {
126
143
  /**
127
- * Whether the button is disabled.
144
+ * Tint color for the header button.
128
145
  */
129
- disabled?: boolean;
130
- /**
131
- * Callback to call when the button is pressed.
132
- */
133
- onPress?: () => void;
146
+ tintColor?: string;
134
147
  /**
135
148
  * Color for material ripple (Android >= 5.0 only).
136
149
  */
@@ -139,16 +152,26 @@ export declare type HeaderBackButtonProps = {
139
152
  * Opacity when the button is pressed, used when ripple is not supported.
140
153
  */
141
154
  pressOpacity?: number;
155
+ /**
156
+ * Whether it's possible to navigate back in stack.
157
+ */
158
+ canGoBack?: boolean;
159
+ };
160
+ export declare type HeaderBackButtonProps = HeaderButtonProps & {
161
+ /**
162
+ * Whether the button is disabled.
163
+ */
164
+ disabled?: boolean;
165
+ /**
166
+ * Callback to call when the button is pressed.
167
+ */
168
+ onPress?: () => void;
142
169
  /**
143
170
  * Function which returns a React Element to display custom image in header's back button.
144
171
  */
145
172
  backImage?: (props: {
146
173
  tintColor: string;
147
174
  }) => React.ReactNode;
148
- /**
149
- * Tint color for the header.
150
- */
151
- tintColor?: string;
152
175
  /**
153
176
  * Label text for the button. Usually the title of the previous screen.
154
177
  * By default, this is only shown on iOS.
@@ -183,10 +206,6 @@ export declare type HeaderBackButtonProps = {
183
206
  * Layout of the title element in the header.
184
207
  */
185
208
  titleLayout?: Layout;
186
- /**
187
- * Whether it's possible to navigate back in stack.
188
- */
189
- canGoBack?: boolean;
190
209
  /**
191
210
  * Accessibility label for the button for screen readers.
192
211
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/elements",
3
3
  "description": "UI Components for React Navigation",
4
- "version": "1.1.2",
4
+ "version": "1.3.1",
5
5
  "keywords": [
6
6
  "react-native",
7
7
  "react-navigation",
@@ -38,13 +38,13 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@react-native-masked-view/masked-view": "^0.2.4",
41
- "@react-navigation/native": "^6.0.4",
41
+ "@react-navigation/native": "^6.0.8",
42
42
  "@testing-library/react-native": "^7.2.0",
43
43
  "@types/react": "^17.0.9",
44
44
  "@types/react-native": "~0.64.9",
45
45
  "del-cli": "^3.0.1",
46
- "react": "~16.13.1",
47
- "react-native": "~0.63.4",
46
+ "react": "17.0.1",
47
+ "react-native": "~0.64.3",
48
48
  "react-native-builder-bob": "^0.18.1",
49
49
  "typescript": "^4.3.2"
50
50
  },
@@ -68,5 +68,5 @@
68
68
  ]
69
69
  ]
70
70
  },
71
- "gitHead": "6a19be7dae997fc23ac9475040a17fb2db4ebd52"
71
+ "gitHead": "4cddbce150413c15db93897c76b813f436f5186d"
72
72
  }
@@ -70,6 +70,7 @@ export default function Header(props: Props) {
70
70
  headerTitleContainerStyle: titleContainerStyle,
71
71
  headerBackgroundContainerStyle: backgroundContainerStyle,
72
72
  headerStyle: customHeaderStyle,
73
+ headerShadowVisible,
73
74
  headerPressColor,
74
75
  headerPressOpacity,
75
76
  headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,
@@ -175,6 +176,15 @@ export default function Header(props: Props) {
175
176
  }
176
177
  }
177
178
 
179
+ const backgroundStyle = [
180
+ safeStyles,
181
+ headerShadowVisible === false && {
182
+ elevation: 0,
183
+ shadowOpacity: 0,
184
+ borderBottomWidth: 0,
185
+ },
186
+ ];
187
+
178
188
  const leftButton = headerLeft
179
189
  ? headerLeft({
180
190
  tintColor: headerTintColor,
@@ -210,9 +220,9 @@ export default function Header(props: Props) {
210
220
  ]}
211
221
  >
212
222
  {headerBackground ? (
213
- headerBackground({ style: safeStyles })
223
+ headerBackground({ style: backgroundStyle })
214
224
  ) : headerTransparent ? null : (
215
- <HeaderBackground style={safeStyles} />
225
+ <HeaderBackground style={backgroundStyle} />
216
226
  )}
217
227
  </Animated.View>
218
228
  <Animated.View
@@ -35,8 +35,9 @@ export default function HeaderBackButton({
35
35
  }: HeaderBackButtonProps) {
36
36
  const { colors } = useTheme();
37
37
 
38
- const [initialLabelWidth, setInitialLabelWidth] =
39
- React.useState<undefined | number>(undefined);
38
+ const [initialLabelWidth, setInitialLabelWidth] = React.useState<
39
+ undefined | number
40
+ >(undefined);
40
41
 
41
42
  const tintColor =
42
43
  customTintColor !== undefined
@@ -12,7 +12,7 @@ export default function getDefaultHeaderHeight(
12
12
  const isLandscape = layout.width > layout.height;
13
13
 
14
14
  if (Platform.OS === 'ios') {
15
- if (Platform.isPad) {
15
+ if (Platform.isPad || Platform.isTVOS) {
16
16
  if (modalPresentation) {
17
17
  headerHeight = 56;
18
18
  } else {
package/src/types.tsx CHANGED
@@ -77,7 +77,7 @@ export type HeaderOptions = {
77
77
  headerTintColor?: string;
78
78
  /**
79
79
  * Function which returns a React Element to render as the background of the header.
80
- * This is useful for using backgrounds such as an image or a gradient.
80
+ * This is useful for using backgrounds such as an image, a gradient, blur effect etc.
81
81
  * You can use this with `headerTransparent` to render a blur view, for example, to create a translucent header.
82
82
  */
83
83
  headerBackground?: (props: {
@@ -99,6 +99,23 @@ export type HeaderOptions = {
99
99
  * Style object for the header. You can specify a custom background color here, for example.
100
100
  */
101
101
  headerStyle?: StyleProp<ViewStyle>;
102
+ /**
103
+ * Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.
104
+ *
105
+ * This is a short-hand for the following styles:
106
+ *
107
+ * ```js
108
+ * {
109
+ * elevation: 0,
110
+ * shadowOpacity: 0,
111
+ * borderBottomWidth: 0,
112
+ * }
113
+ * ```
114
+ *
115
+ * If the above styles are specified in `headerStyle` along with `headerShadowVisible: false`,
116
+ * then `headerShadowVisible: false` will take precedence.
117
+ */
118
+ headerShadowVisible?: boolean;
102
119
  /**
103
120
  * Extra padding to add at the top of header to account for translucent status bar.
104
121
  * By default, it uses the top value from the safe area insets of the device.
@@ -130,15 +147,11 @@ export type HeaderTitleProps = {
130
147
  style?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
131
148
  };
132
149
 
133
- export type HeaderBackButtonProps = {
150
+ export type HeaderButtonProps = {
134
151
  /**
135
- * Whether the button is disabled.
152
+ * Tint color for the header button.
136
153
  */
137
- disabled?: boolean;
138
- /**
139
- * Callback to call when the button is pressed.
140
- */
141
- onPress?: () => void;
154
+ tintColor?: string;
142
155
  /**
143
156
  * Color for material ripple (Android >= 5.0 only).
144
157
  */
@@ -148,13 +161,24 @@ export type HeaderBackButtonProps = {
148
161
  */
149
162
  pressOpacity?: number;
150
163
  /**
151
- * Function which returns a React Element to display custom image in header's back button.
164
+ * Whether it's possible to navigate back in stack.
152
165
  */
153
- backImage?: (props: { tintColor: string }) => React.ReactNode;
166
+ canGoBack?: boolean;
167
+ };
168
+
169
+ export type HeaderBackButtonProps = HeaderButtonProps & {
154
170
  /**
155
- * Tint color for the header.
171
+ * Whether the button is disabled.
156
172
  */
157
- tintColor?: string;
173
+ disabled?: boolean;
174
+ /**
175
+ * Callback to call when the button is pressed.
176
+ */
177
+ onPress?: () => void;
178
+ /**
179
+ * Function which returns a React Element to display custom image in header's back button.
180
+ */
181
+ backImage?: (props: { tintColor: string }) => React.ReactNode;
158
182
  /**
159
183
  * Label text for the button. Usually the title of the previous screen.
160
184
  * By default, this is only shown on iOS.
@@ -189,10 +213,6 @@ export type HeaderBackButtonProps = {
189
213
  * Layout of the title element in the header.
190
214
  */
191
215
  titleLayout?: Layout;
192
- /**
193
- * Whether it's possible to navigate back in stack.
194
- */
195
- canGoBack?: boolean;
196
216
  /**
197
217
  * Accessibility label for the button for screen readers.
198
218
  */