@react-navigation/native-stack 7.10.1 → 8.0.0-alpha.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 (37) hide show
  1. package/lib/module/index.js +1 -1
  2. package/lib/module/index.js.map +1 -1
  3. package/lib/module/navigators/createNativeStackNavigator.js +7 -6
  4. package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
  5. package/lib/module/views/NativeStackView.js +4 -4
  6. package/lib/module/views/NativeStackView.js.map +1 -1
  7. package/lib/module/views/NativeStackView.native.js +123 -172
  8. package/lib/module/views/NativeStackView.native.js.map +1 -1
  9. package/lib/module/views/useHeaderConfigProps.js +15 -14
  10. package/lib/module/views/useHeaderConfigProps.js.map +1 -1
  11. package/lib/typescript/src/index.d.ts +1 -1
  12. package/lib/typescript/src/index.d.ts.map +1 -1
  13. package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts +10 -6
  14. package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
  15. package/lib/typescript/src/types.d.ts +34 -83
  16. package/lib/typescript/src/types.d.ts.map +1 -1
  17. package/lib/typescript/src/views/NativeStackView.d.ts.map +1 -1
  18. package/lib/typescript/src/views/NativeStackView.native.d.ts.map +1 -1
  19. package/lib/typescript/src/views/useHeaderConfigProps.d.ts +1 -1
  20. package/lib/typescript/src/views/useHeaderConfigProps.d.ts.map +1 -1
  21. package/package.json +12 -13
  22. package/src/index.tsx +4 -1
  23. package/src/navigators/createNativeStackNavigator.tsx +48 -25
  24. package/src/types.tsx +34 -88
  25. package/src/views/NativeStackView.native.tsx +138 -215
  26. package/src/views/NativeStackView.tsx +6 -9
  27. package/src/views/useHeaderConfigProps.tsx +21 -27
  28. package/lib/module/views/FontProcessor.js +0 -6
  29. package/lib/module/views/FontProcessor.js.map +0 -1
  30. package/lib/module/views/FontProcessor.native.js +0 -12
  31. package/lib/module/views/FontProcessor.native.js.map +0 -1
  32. package/lib/typescript/src/views/FontProcessor.d.ts +0 -2
  33. package/lib/typescript/src/views/FontProcessor.d.ts.map +0 -1
  34. package/lib/typescript/src/views/FontProcessor.native.d.ts +0 -2
  35. package/lib/typescript/src/views/FontProcessor.native.d.ts.map +0 -1
  36. package/src/views/FontProcessor.native.tsx +0 -12
  37. package/src/views/FontProcessor.tsx +0 -5
package/src/index.tsx CHANGED
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * Navigators
3
3
  */
4
- export { createNativeStackNavigator } from './navigators/createNativeStackNavigator';
4
+ export {
5
+ createNativeStackNavigator,
6
+ createNativeStackScreen,
7
+ } from './navigators/createNativeStackNavigator';
5
8
 
6
9
  /**
7
10
  * Views
@@ -2,7 +2,6 @@ import {
2
2
  createNavigatorFactory,
3
3
  type EventArg,
4
4
  NavigationMetaContext,
5
- type NavigatorTypeBagBase,
6
5
  type ParamListBase,
7
6
  type StackActionHelpers,
8
7
  StackActions,
@@ -10,6 +9,10 @@ import {
10
9
  StackRouter,
11
10
  type StackRouterOptions,
12
11
  type StaticConfig,
12
+ type StaticParamList,
13
+ type StaticScreenConfig,
14
+ type StaticScreenConfigLinking,
15
+ type StaticScreenConfigScreen,
13
16
  type TypedNavigator,
14
17
  useNavigationBuilder,
15
18
  } from '@react-navigation/native';
@@ -24,15 +27,14 @@ import type {
24
27
  import { NativeStackView } from '../views/NativeStackView';
25
28
 
26
29
  function NativeStackNavigator({
27
- id,
28
30
  initialRouteName,
29
- UNSTABLE_routeNamesChangeBehavior,
31
+ routeNamesChangeBehavior,
30
32
  children,
31
33
  layout,
32
34
  screenListeners,
33
35
  screenOptions,
34
36
  screenLayout,
35
- UNSTABLE_router,
37
+ router,
36
38
  ...rest
37
39
  }: NativeStackNavigatorProps) {
38
40
  const { state, describe, descriptors, navigation, NavigationContent } =
@@ -43,15 +45,14 @@ function NativeStackNavigator({
43
45
  NativeStackNavigationOptions,
44
46
  NativeStackNavigationEventMap
45
47
  >(StackRouter, {
46
- id,
47
48
  initialRouteName,
48
- UNSTABLE_routeNamesChangeBehavior,
49
+ routeNamesChangeBehavior,
49
50
  children,
50
51
  layout,
51
52
  screenListeners,
52
53
  screenOptions,
53
54
  screenLayout,
54
- UNSTABLE_router,
55
+ router,
55
56
  });
56
57
 
57
58
  const meta = React.useContext(NavigationMetaContext);
@@ -99,25 +100,47 @@ function NativeStackNavigator({
99
100
  );
100
101
  }
101
102
 
103
+ type NativeStackTypeBag<ParamList extends {}> = {
104
+ ParamList: ParamList;
105
+ State: StackNavigationState<ParamList>;
106
+ ScreenOptions: NativeStackNavigationOptions;
107
+ EventMap: NativeStackNavigationEventMap;
108
+ NavigationList: {
109
+ [RouteName in keyof ParamList]: NativeStackNavigationProp<
110
+ ParamList,
111
+ RouteName
112
+ >;
113
+ };
114
+ Navigator: typeof NativeStackNavigator;
115
+ };
116
+
102
117
  export function createNativeStackNavigator<
103
118
  const ParamList extends ParamListBase,
104
- const NavigatorID extends string | undefined = string | undefined,
105
- const TypeBag extends NavigatorTypeBagBase = {
106
- ParamList: ParamList;
107
- NavigatorID: NavigatorID;
108
- State: StackNavigationState<ParamList>;
109
- ScreenOptions: NativeStackNavigationOptions;
110
- EventMap: NativeStackNavigationEventMap;
111
- NavigationList: {
112
- [RouteName in keyof ParamList]: NativeStackNavigationProp<
113
- ParamList,
114
- RouteName,
115
- NavigatorID
116
- >;
117
- };
118
- Navigator: typeof NativeStackNavigator;
119
- },
120
- const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
121
- >(config?: Config): TypedNavigator<TypeBag, Config> {
119
+ >(): TypedNavigator<NativeStackTypeBag<ParamList>, undefined>;
120
+ export function createNativeStackNavigator<
121
+ const Config extends StaticConfig<NativeStackTypeBag<ParamListBase>>,
122
+ >(
123
+ config: Config
124
+ ): TypedNavigator<
125
+ NativeStackTypeBag<StaticParamList<{ config: Config }>>,
126
+ Config
127
+ >;
128
+ export function createNativeStackNavigator(config?: unknown) {
122
129
  return createNavigatorFactory(NativeStackNavigator)(config);
123
130
  }
131
+
132
+ export function createNativeStackScreen<
133
+ const Linking extends StaticScreenConfigLinking,
134
+ const Screen extends StaticScreenConfigScreen,
135
+ >(
136
+ config: StaticScreenConfig<
137
+ Linking,
138
+ Screen,
139
+ StackNavigationState<ParamListBase>,
140
+ NativeStackNavigationOptions,
141
+ NativeStackNavigationEventMap,
142
+ NativeStackNavigationProp<ParamListBase>
143
+ >
144
+ ) {
145
+ return config;
146
+ }
package/src/types.tsx CHANGED
@@ -53,31 +53,27 @@ export type NativeStackNavigationEventMap = {
53
53
  export type NativeStackNavigationProp<
54
54
  ParamList extends ParamListBase,
55
55
  RouteName extends keyof ParamList = string,
56
- NavigatorID extends string | undefined = undefined,
57
56
  > = NavigationProp<
58
57
  ParamList,
59
58
  RouteName,
60
- NavigatorID,
61
59
  StackNavigationState<ParamList>,
62
60
  NativeStackNavigationOptions,
63
- NativeStackNavigationEventMap
64
- > &
65
- StackActionHelpers<ParamList>;
61
+ NativeStackNavigationEventMap,
62
+ StackActionHelpers<ParamList>
63
+ >;
66
64
 
67
65
  export type NativeStackScreenProps<
68
66
  ParamList extends ParamListBase,
69
67
  RouteName extends keyof ParamList = string,
70
- NavigatorID extends string | undefined = undefined,
71
68
  > = {
72
- navigation: NativeStackNavigationProp<ParamList, RouteName, NavigatorID>;
69
+ navigation: NativeStackNavigationProp<ParamList, RouteName>;
73
70
  route: RouteProp<ParamList, RouteName>;
74
71
  };
75
72
 
76
73
  export type NativeStackOptionsArgs<
77
74
  ParamList extends ParamListBase,
78
75
  RouteName extends keyof ParamList = keyof ParamList,
79
- NavigatorID extends string | undefined = undefined,
80
- > = NativeStackScreenProps<ParamList, RouteName, NavigatorID> & {
76
+ > = NativeStackScreenProps<ParamList, RouteName> & {
81
77
  theme: Theme;
82
78
  };
83
79
 
@@ -121,7 +117,7 @@ export type NativeStackHeaderItemProps = {
121
117
  /**
122
118
  * Tint color for the header.
123
119
  */
124
- tintColor?: string;
120
+ tintColor?: ColorValue;
125
121
  /**
126
122
  * Whether it's possible to navigate back in stack.
127
123
  */
@@ -193,7 +189,6 @@ export type NativeStackNavigationOptions = {
193
189
  }>;
194
190
  /**
195
191
  * Icon to display in the header as the icon in the back button.
196
- *
197
192
  * Defaults to back icon image for the platform
198
193
  * - A chevron on iOS
199
194
  * - An arrow on Android
@@ -210,15 +205,9 @@ export type NativeStackNavigationOptions = {
210
205
  type: 'image';
211
206
  source: ImageSourcePropType;
212
207
  };
213
- /**
214
- * Image to display in the header as the icon in the back button.
215
- *
216
- * @deprecated Use `headerBackIcon` instead.
217
- */
218
- headerBackImageSource?: ImageSourcePropType;
219
208
  /**
220
209
  * Style of the header when a large title is shown.
221
- * The large title is shown if `headerLargeTitle` is `true` and
210
+ * The large title is shown if `headerLargeTitleEnabled` is `true` and
222
211
  * the edge of any scrollable content reaches the matching edge of the header.
223
212
  *
224
213
  * Supported properties:
@@ -229,7 +218,7 @@ export type NativeStackNavigationOptions = {
229
218
  * @platform ios
230
219
  */
231
220
  headerLargeStyle?: StyleProp<{
232
- backgroundColor?: string;
221
+ backgroundColor?: ColorValue;
233
222
  }>;
234
223
  /**
235
224
  * Whether to enable header with large title which collapses to regular header on scroll.
@@ -243,12 +232,6 @@ export type NativeStackNavigationOptions = {
243
232
  * @platform ios
244
233
  */
245
234
  headerLargeTitleEnabled?: boolean;
246
- /**
247
- * Whether to enable header with large title which collapses to regular header on scroll.
248
- *
249
- * @deprecated Use `headerLargeTitleEnabled` instead.
250
- */
251
- headerLargeTitle?: boolean;
252
235
  /**
253
236
  * Whether drop shadow of header is visible when a large title is shown.
254
237
  *
@@ -272,7 +255,7 @@ export type NativeStackNavigationOptions = {
272
255
  fontFamily?: string;
273
256
  fontSize?: number;
274
257
  fontWeight?: string;
275
- color?: string;
258
+ color?: ColorValue;
276
259
  }>;
277
260
  /**
278
261
  * Whether to show the header. The header is shown by default.
@@ -284,7 +267,7 @@ export type NativeStackNavigationOptions = {
284
267
  * - backgroundColor
285
268
  */
286
269
  headerStyle?: StyleProp<{
287
- backgroundColor?: string;
270
+ backgroundColor?: ColorValue;
288
271
  }>;
289
272
  /**
290
273
  * Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.
@@ -310,7 +293,7 @@ export type NativeStackNavigationOptions = {
310
293
  /**
311
294
  * Tint color for the header. Changes the color of back button and title.
312
295
  */
313
- headerTintColor?: string;
296
+ headerTintColor?: ColorValue;
314
297
  /**
315
298
  * Function which returns a React Element to render as the background of the header.
316
299
  * This is useful for using backgrounds such as an image, a gradient, blur effect etc.
@@ -323,11 +306,29 @@ export type NativeStackNavigationOptions = {
323
306
  * Will be overriden by `headerLeftItems` on iOS.
324
307
  */
325
308
  headerLeft?: (props: NativeStackHeaderBackProps) => React.ReactNode;
309
+ /**
310
+ * Whether the liquid glass background is visible for the item.
311
+ *
312
+ * Only supported on iOS 26.0 and later.
313
+ * Older versions of iOS and other platforms never show the background.
314
+ *
315
+ * Defaults to `true`.
316
+ */
317
+ headerLeftBackgroundVisible?: boolean;
326
318
  /**
327
319
  * Function which returns a React Element to display on the right side of the header.
328
320
  * Will be overriden by `headerRightItems` on iOS.
329
321
  */
330
322
  headerRight?: (props: NativeStackHeaderItemProps) => React.ReactNode;
323
+ /**
324
+ * Whether the liquid glass background is visible for the item.
325
+ *
326
+ * Only supported on iOS 26.0 and later.
327
+ * Older versions of iOS and other platforms never show the background.
328
+ *
329
+ * Defaults to `true`.
330
+ */
331
+ headerRightBackgroundVisible?: boolean;
331
332
  /**
332
333
  * Function which returns an array of items to display as on the left side of the header.
333
334
  * Overrides `headerLeft`.
@@ -369,7 +370,7 @@ export type NativeStackNavigationOptions = {
369
370
  /**
370
371
  * Tint color for the header.
371
372
  */
372
- tintColor?: string;
373
+ tintColor?: ColorValue;
373
374
  }) => React.ReactNode);
374
375
  /**
375
376
  * How to align the the header title.
@@ -387,7 +388,7 @@ export type NativeStackNavigationOptions = {
387
388
  */
388
389
  headerTitleStyle?: StyleProp<
389
390
  Pick<TextStyle, 'fontFamily' | 'fontSize' | 'fontWeight'> & {
390
- color?: string;
391
+ color?: ColorValue;
391
392
  }
392
393
  >;
393
394
  /**
@@ -395,7 +396,9 @@ export type NativeStackNavigationOptions = {
395
396
  * You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
396
397
  * If you don't have a `ScrollView`, specify `headerTransparent: false`.
397
398
  */
398
- headerSearchBarOptions?: SearchBarProps;
399
+ headerSearchBarOptions?: Omit<SearchBarProps, 'onChangeText'> & {
400
+ onChange?: SearchBarProps['onChangeText'];
401
+ };
399
402
  /**
400
403
  * Boolean indicating whether to show the menu on longPress of iOS >= 14 back button. Defaults to `true`.
401
404
  * Requires `react-native-screens` version >=3.3.0.
@@ -439,26 +442,6 @@ export type NativeStackNavigationOptions = {
439
442
  * @platform ios
440
443
  */
441
444
  keyboardHandlingEnabled?: boolean;
442
- /**
443
- * Sets the navigation bar color. Defaults to initial navigation bar color.
444
- *
445
- * @deprecated For all apps targeting Android SDK 35 or above edge-to-edge is enabled by default.
446
- * This prop is subject to removal in the future.
447
- * See: https://developer.android.com/about/versions/15/behavior-changes-15#ux.
448
- *
449
- * @platform android
450
- */
451
- navigationBarColor?: string;
452
- /**
453
- * Boolean indicating whether the content should be visible behind the navigation bar. Defaults to `false`.
454
- *
455
- * @deprecated For all apps targeting Android SDK 35 or above edge-to-edge is enabled by default.
456
- * This prop is subject to removal in the future.
457
- * See: https://developer.android.com/about/versions/15/behavior-changes-15#ux.
458
- *
459
- * @platform android
460
- */
461
- navigationBarTranslucent?: boolean;
462
445
  /**
463
446
  * Sets the visibility of the navigation bar. Defaults to `false`.
464
447
  *
@@ -477,16 +460,6 @@ export type NativeStackNavigationOptions = {
477
460
  * @platform android, ios
478
461
  */
479
462
  statusBarAnimation?: ScreenProps['statusBarAnimation'];
480
- /**
481
- * Sets the status bar color (similar to the `StatusBar` component). Defaults to initial status bar color.
482
- *
483
- * @deprecated For all apps targeting Android SDK 35 or above edge-to-edge is enabled by default.
484
- * This prop is subject to removal in the future.
485
- * See: https://developer.android.com/about/versions/15/behavior-changes-15#ux.
486
- *
487
- * @platform android
488
- */
489
- statusBarBackgroundColor?: string;
490
463
  /**
491
464
  * Whether the status bar should be hidden on this screen.
492
465
  * Requires setting `View controller-based status bar appearance -> YES` in your Info.plist file.
@@ -508,16 +481,6 @@ export type NativeStackNavigationOptions = {
508
481
  * @platform android, ios
509
482
  */
510
483
  statusBarStyle?: ScreenProps['statusBarStyle'];
511
- /**
512
- * Sets the translucency of the status bar. Defaults to `false`.
513
- *
514
- * @deprecated For all apps targeting Android SDK 35 or above edge-to-edge is enabled by default.
515
- * This prop is subject to removal in the future.
516
- * See: https://developer.android.com/about/versions/15/behavior-changes-15#ux.
517
- *
518
- * @platform android
519
- */
520
- statusBarTranslucent?: boolean;
521
484
  /**
522
485
  * Sets the direction in which you should swipe to dismiss the screen.
523
486
  * When using `vertical` option, options `fullScreenGestureEnabled: true`, `animationMatchesGesture: true` and `animation: 'slide_from_bottom'` are set by default.
@@ -724,22 +687,6 @@ export type NativeStackNavigationOptions = {
724
687
  * Defaults to `none`, indicating that the dimming view should be always present.
725
688
  */
726
689
  sheetLargestUndimmedDetentIndex?: number | 'none' | 'last';
727
- /**
728
- * Whether the sheet content should be rendered behind the Status Bar or display cutouts.
729
- *
730
- * When set to `true`, the sheet will extend to the physical edges of the stack,
731
- * allowing content to be visible behind the status bar or display cutouts.
732
- * Detent ratios in sheetAllowedDetents will be measured relative to the full stack height.
733
- *
734
- * When set to `false`, the sheet's layout will be constrained by the inset from the top
735
- * and the detent ratios will then be measured relative to the adjusted height (excluding the top inset).
736
- * This means that sheetAllowedDetents will result in different sheet heights depending on this prop.
737
- *
738
- * Defaults to `false`.
739
- *
740
- * @platform android
741
- */
742
- sheetShouldOverflowTopInset?: boolean;
743
690
  /**
744
691
  * The display orientation to use for the screen.
745
692
  *
@@ -1149,7 +1096,6 @@ export type NativeStackHeaderItem =
1149
1096
 
1150
1097
  export type NativeStackNavigatorProps = DefaultNavigatorOptions<
1151
1098
  ParamListBase,
1152
- string | undefined,
1153
1099
  StackNavigationState<ParamListBase>,
1154
1100
  NativeStackNavigationOptions,
1155
1101
  NativeStackNavigationEventMap,