@react-navigation/native-stack 8.0.0-alpha.5 → 8.0.0-alpha.51

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 (43) hide show
  1. package/lib/module/index.js.map +1 -1
  2. package/lib/module/navigators/createNativeStackNavigator.js +16 -13
  3. package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
  4. package/lib/module/utils/useAnimatedHeaderHeight.js +1 -1
  5. package/lib/module/utils/useAnimatedHeaderHeight.js.map +1 -1
  6. package/lib/module/utils/useInvalidPreventRemoveError.js +1 -1
  7. package/lib/module/utils/useInvalidPreventRemoveError.js.map +1 -1
  8. package/lib/module/views/FooterComponent.js +1 -1
  9. package/lib/module/views/FooterComponent.js.map +1 -1
  10. package/lib/module/views/NativeStackView.js +42 -25
  11. package/lib/module/views/NativeStackView.js.map +1 -1
  12. package/lib/module/views/NativeStackView.native.js +124 -76
  13. package/lib/module/views/NativeStackView.native.js.map +1 -1
  14. package/lib/module/views/useHeaderConfigProps.js +76 -23
  15. package/lib/module/views/useHeaderConfigProps.js.map +1 -1
  16. package/lib/typescript/src/index.d.ts +3 -3
  17. package/lib/typescript/src/index.d.ts.map +1 -1
  18. package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts +10 -15
  19. package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
  20. package/lib/typescript/src/types.d.ts +164 -156
  21. package/lib/typescript/src/types.d.ts.map +1 -1
  22. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts +1 -1
  23. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +1 -1
  24. package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts +1 -1
  25. package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts.map +1 -1
  26. package/lib/typescript/src/views/FooterComponent.d.ts +2 -2
  27. package/lib/typescript/src/views/FooterComponent.d.ts.map +1 -1
  28. package/lib/typescript/src/views/NativeStackView.d.ts +3 -2
  29. package/lib/typescript/src/views/NativeStackView.d.ts.map +1 -1
  30. package/lib/typescript/src/views/NativeStackView.native.d.ts +3 -2
  31. package/lib/typescript/src/views/NativeStackView.native.d.ts.map +1 -1
  32. package/lib/typescript/src/views/useHeaderConfigProps.d.ts +2 -3
  33. package/lib/typescript/src/views/useHeaderConfigProps.d.ts.map +1 -1
  34. package/package.json +22 -19
  35. package/src/index.tsx +1 -2
  36. package/src/navigators/createNativeStackNavigator.tsx +27 -52
  37. package/src/types.tsx +225 -196
  38. package/src/utils/useAnimatedHeaderHeight.tsx +1 -1
  39. package/src/utils/useInvalidPreventRemoveError.tsx +2 -1
  40. package/src/views/FooterComponent.tsx +1 -1
  41. package/src/views/NativeStackView.native.tsx +184 -97
  42. package/src/views/NativeStackView.tsx +70 -41
  43. package/src/views/useHeaderConfigProps.tsx +109 -39
package/src/types.tsx CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Icon } from '@react-navigation/elements';
1
2
  import type {
2
3
  DefaultNavigatorOptions,
3
4
  Descriptor,
@@ -11,20 +12,14 @@ import type {
11
12
  StackRouterOptions,
12
13
  Theme,
13
14
  } from '@react-navigation/native';
14
- import type {
15
- ColorValue,
16
- ImageSourcePropType,
17
- StyleProp,
18
- TextStyle,
19
- ViewStyle,
20
- } from 'react-native';
15
+ import * as React from 'react';
16
+ import type { ColorValue, StyleProp, TextStyle, ViewStyle } from 'react-native';
21
17
  import type {
22
18
  ScreenProps,
23
19
  ScreenStackHeaderConfigProps,
24
20
  ScrollEdgeEffect,
25
21
  SearchBarProps,
26
22
  } from 'react-native-screens';
27
- import type { SFSymbol } from 'sf-symbols-typescript';
28
23
 
29
24
  export type NativeStackNavigationEventMap = {
30
25
  /**
@@ -89,16 +84,18 @@ export type NativeStackHeaderProps = {
89
84
  /**
90
85
  * Options for the back button.
91
86
  */
92
- back?: {
93
- /**
94
- * Title of the previous screen.
95
- */
96
- title: string | undefined;
97
- /**
98
- * The `href` to use for the anchor tag on web
99
- */
100
- href: string | undefined;
101
- };
87
+ back?:
88
+ | {
89
+ /**
90
+ * Title of the previous screen.
91
+ */
92
+ title: string | undefined;
93
+ /**
94
+ * The `href` to use for the anchor tag on web
95
+ */
96
+ href: string | undefined;
97
+ }
98
+ | undefined;
102
99
  /**
103
100
  * Options for the current screen.
104
101
  */
@@ -117,11 +114,11 @@ export type NativeStackHeaderItemProps = {
117
114
  /**
118
115
  * Tint color for the header.
119
116
  */
120
- tintColor?: ColorValue;
117
+ tintColor?: ColorValue | undefined;
121
118
  /**
122
119
  * Whether it's possible to navigate back in stack.
123
120
  */
124
- canGoBack?: boolean;
121
+ canGoBack?: boolean | undefined;
125
122
  };
126
123
 
127
124
  export type NativeStackHeaderBackProps = NativeStackHeaderItemProps & {
@@ -129,39 +126,29 @@ export type NativeStackHeaderBackProps = NativeStackHeaderItemProps & {
129
126
  * Label text for the button. Usually the title of the previous screen.
130
127
  * By default, this is only shown on iOS 18.
131
128
  */
132
- label?: string;
129
+ label?: string | undefined;
133
130
  /**
134
131
  * The `href` to use for the anchor tag on web
135
132
  */
136
- href?: string;
133
+ href?: string | undefined;
137
134
  };
138
135
 
139
- /**
140
- * @deprecated Use `NativeStackHeaderBackProps` instead.
141
- */
142
- export type NativeStackHeaderLeftProps = NativeStackHeaderBackProps;
143
-
144
- /**
145
- * @deprecated Use `NativeStackHeaderItemProps` instead.
146
- */
147
- export type NativeStackHeaderRightProps = NativeStackHeaderItemProps;
148
-
149
136
  export type NativeStackNavigationOptions = {
150
137
  /**
151
138
  * String that can be displayed in the header as a fallback for `headerTitle`.
152
139
  */
153
- title?: string;
140
+ title?: string | undefined;
154
141
  /**
155
142
  * Function that given `HeaderProps` returns a React Element to display as a header.
156
143
  */
157
- header?: (props: NativeStackHeaderProps) => React.ReactNode;
144
+ header?: ((props: NativeStackHeaderProps) => React.ReactNode) | undefined;
158
145
  /**
159
146
  * Whether the back button is visible in the header.
160
147
  * You can use it to show a back button alongside `headerLeft` if you have specified it.
161
148
  *
162
149
  * This will have no effect on the first screen in the stack.
163
150
  */
164
- headerBackVisible?: boolean;
151
+ headerBackVisible?: boolean | undefined;
165
152
  /**
166
153
  * Title string used by the back button on iOS.
167
154
  * Defaults to the previous scene's title.
@@ -173,7 +160,7 @@ export type NativeStackNavigationOptions = {
173
160
  *
174
161
  * @platform ios, web
175
162
  */
176
- headerBackTitle?: string;
163
+ headerBackTitle?: string | undefined;
177
164
  /**
178
165
  * Style object for header back title. Supported properties:
179
166
  * - fontFamily
@@ -183,12 +170,20 @@ export type NativeStackNavigationOptions = {
183
170
  *
184
171
  * @platform ios, web
185
172
  */
186
- headerBackTitleStyle?: StyleProp<{
187
- fontFamily?: string;
188
- fontSize?: number;
189
- }>;
173
+ headerBackTitleStyle?:
174
+ | StyleProp<{
175
+ fontFamily?: string | undefined;
176
+ fontSize?: number | undefined;
177
+ }>
178
+ | undefined;
190
179
  /**
191
- * Icon to display in the header as the icon in the back button.
180
+ * Icon to display in the header in the back button.
181
+ *
182
+ * Supported types:
183
+ * - image: custom image source
184
+ * - sfSymbol: SF Symbol icon (iOS only - when using custom header)
185
+ * - materialSymbol: material symbol icon (Android only)
186
+ *
192
187
  * Defaults to back icon image for the platform
193
188
  * - A chevron on iOS
194
189
  * - An arrow on Android
@@ -201,10 +196,7 @@ export type NativeStackNavigationOptions = {
201
196
  * }
202
197
  * ```
203
198
  */
204
- headerBackIcon?: {
205
- type: 'image';
206
- source: ImageSourcePropType;
207
- };
199
+ headerBackIcon?: Icon | undefined;
208
200
  /**
209
201
  * Style of the header when a large title is shown.
210
202
  * The large title is shown if `headerLargeTitleEnabled` is `true` and
@@ -217,9 +209,11 @@ export type NativeStackNavigationOptions = {
217
209
  *
218
210
  * @platform ios
219
211
  */
220
- headerLargeStyle?: StyleProp<{
221
- backgroundColor?: ColorValue;
222
- }>;
212
+ headerLargeStyle?:
213
+ | StyleProp<{
214
+ backgroundColor?: ColorValue | undefined;
215
+ }>
216
+ | undefined;
223
217
  /**
224
218
  * Whether to enable header with large title which collapses to regular header on scroll.
225
219
  *
@@ -231,7 +225,7 @@ export type NativeStackNavigationOptions = {
231
225
  *
232
226
  * @platform ios
233
227
  */
234
- headerLargeTitleEnabled?: boolean;
228
+ headerLargeTitleEnabled?: boolean | undefined;
235
229
  /**
236
230
  * Whether drop shadow of header is visible when a large title is shown.
237
231
  *
@@ -239,7 +233,7 @@ export type NativeStackNavigationOptions = {
239
233
  *
240
234
  * @platform ios
241
235
  */
242
- headerLargeTitleShadowVisible?: boolean;
236
+ headerLargeTitleShadowVisible?: boolean | undefined;
243
237
  /**
244
238
  * Style object for large title in header. Supported properties:
245
239
  * - fontFamily
@@ -251,34 +245,38 @@ export type NativeStackNavigationOptions = {
251
245
  *
252
246
  * @platform ios
253
247
  */
254
- headerLargeTitleStyle?: StyleProp<{
255
- fontFamily?: string;
256
- fontSize?: number;
257
- fontWeight?: string;
258
- color?: ColorValue;
259
- }>;
248
+ headerLargeTitleStyle?:
249
+ | StyleProp<{
250
+ fontFamily?: string | undefined;
251
+ fontSize?: number | undefined;
252
+ fontWeight?: string | undefined;
253
+ color?: ColorValue | undefined;
254
+ }>
255
+ | undefined;
260
256
  /**
261
257
  * Whether to show the header. The header is shown by default.
262
258
  * Setting this to `false` hides the header.
263
259
  */
264
- headerShown?: boolean;
260
+ headerShown?: boolean | undefined;
265
261
  /**
266
262
  * Style object for header. Supported properties:
267
263
  * - backgroundColor
268
264
  */
269
- headerStyle?: StyleProp<{
270
- backgroundColor?: ColorValue;
271
- }>;
265
+ headerStyle?:
266
+ | StyleProp<{
267
+ backgroundColor?: ColorValue | undefined;
268
+ }>
269
+ | undefined;
272
270
  /**
273
271
  * Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.
274
272
  */
275
- headerShadowVisible?: boolean;
273
+ headerShadowVisible?: boolean | undefined;
276
274
  /**
277
275
  * Boolean indicating whether the navigation bar is translucent.
278
276
  * Setting this to `true` makes the header absolutely positioned,
279
277
  * and changes the background color to `transparent` unless specified in `headerStyle`.
280
278
  */
281
- headerTransparent?: boolean;
279
+ headerTransparent?: boolean | undefined;
282
280
  /**
283
281
  * Blur effect for the translucent header.
284
282
  * The `headerTransparent` option needs to be set to `true` for this to work.
@@ -289,23 +287,25 @@ export type NativeStackNavigationOptions = {
289
287
  *
290
288
  * @platform ios
291
289
  */
292
- headerBlurEffect?: ScreenStackHeaderConfigProps['blurEffect'];
290
+ headerBlurEffect?: ScreenStackHeaderConfigProps['blurEffect'] | undefined;
293
291
  /**
294
292
  * Tint color for the header. Changes the color of back button and title.
295
293
  */
296
- headerTintColor?: ColorValue;
294
+ headerTintColor?: ColorValue | undefined;
297
295
  /**
298
296
  * Function which returns a React Element to render as the background of the header.
299
297
  * This is useful for using backgrounds such as an image, a gradient, blur effect etc.
300
298
  * You can use this with `headerTransparent` to render content underneath a translucent header.
301
299
  */
302
- headerBackground?: () => React.ReactNode;
300
+ headerBackground?: (() => React.ReactNode) | undefined;
303
301
  /**
304
302
  * Function which returns a React Element to display on the left side of the header.
305
303
  * This replaces the back button. See `headerBackVisible` to show the back button along side left element.
306
304
  * Will be overriden by `headerLeftItems` on iOS.
307
305
  */
308
- headerLeft?: (props: NativeStackHeaderBackProps) => React.ReactNode;
306
+ headerLeft?:
307
+ | ((props: NativeStackHeaderBackProps) => React.ReactNode)
308
+ | undefined;
309
309
  /**
310
310
  * Whether the liquid glass background is visible for the item.
311
311
  *
@@ -314,12 +314,14 @@ export type NativeStackNavigationOptions = {
314
314
  *
315
315
  * Defaults to `true`.
316
316
  */
317
- headerLeftBackgroundVisible?: boolean;
317
+ headerLeftBackgroundVisible?: boolean | undefined;
318
318
  /**
319
319
  * Function which returns a React Element to display on the right side of the header.
320
320
  * Will be overriden by `headerRightItems` on iOS.
321
321
  */
322
- headerRight?: (props: NativeStackHeaderItemProps) => React.ReactNode;
322
+ headerRight?:
323
+ | ((props: NativeStackHeaderItemProps) => React.ReactNode)
324
+ | undefined;
323
325
  /**
324
326
  * Whether the liquid glass background is visible for the item.
325
327
  *
@@ -328,7 +330,7 @@ export type NativeStackNavigationOptions = {
328
330
  *
329
331
  * Defaults to `true`.
330
332
  */
331
- headerRightBackgroundVisible?: boolean;
333
+ headerRightBackgroundVisible?: boolean | undefined;
332
334
  /**
333
335
  * Function which returns an array of items to display as on the left side of the header.
334
336
  * Overrides `headerLeft`.
@@ -337,9 +339,9 @@ export type NativeStackNavigationOptions = {
337
339
  *
338
340
  * @platform ios
339
341
  */
340
- unstable_headerLeftItems?: (
341
- props: NativeStackHeaderItemProps
342
- ) => NativeStackHeaderItem[];
342
+ unstable_headerLeftItems?:
343
+ | ((props: NativeStackHeaderItemProps) => NativeStackHeaderItem[])
344
+ | undefined;
343
345
  /**
344
346
  * Function which returns an array of items to display as on the right side of the header.
345
347
  * Overrides `headerRight`.
@@ -348,9 +350,9 @@ export type NativeStackNavigationOptions = {
348
350
  *
349
351
  * @platform ios
350
352
  */
351
- unstable_headerRightItems?: (
352
- props: NativeStackHeaderItemProps
353
- ) => NativeStackHeaderItem[];
353
+ unstable_headerRightItems?:
354
+ | ((props: NativeStackHeaderItemProps) => NativeStackHeaderItem[])
355
+ | undefined;
354
356
  /**
355
357
  * String or a function that returns a React Element to be used by the header.
356
358
  * Defaults to screen `title` or route name.
@@ -370,15 +372,16 @@ export type NativeStackNavigationOptions = {
370
372
  /**
371
373
  * Tint color for the header.
372
374
  */
373
- tintColor?: ColorValue;
374
- }) => React.ReactNode);
375
+ tintColor?: ColorValue | undefined;
376
+ }) => React.ReactNode)
377
+ | undefined;
375
378
  /**
376
379
  * How to align the the header title.
377
380
  * Defaults to `left` on platforms other than iOS.
378
381
  *
379
382
  * Not supported on iOS. It's always `center` on iOS and cannot be changed.
380
383
  */
381
- headerTitleAlign?: 'left' | 'center';
384
+ headerTitleAlign?: 'left' | 'center' | undefined;
382
385
  /**
383
386
  * Style object for header title. Supported properties:
384
387
  * - fontFamily
@@ -386,19 +389,23 @@ export type NativeStackNavigationOptions = {
386
389
  * - fontWeight
387
390
  * - color
388
391
  */
389
- headerTitleStyle?: StyleProp<
390
- Pick<TextStyle, 'fontFamily' | 'fontSize' | 'fontWeight'> & {
391
- color?: ColorValue;
392
- }
393
- >;
392
+ headerTitleStyle?:
393
+ | StyleProp<
394
+ Pick<TextStyle, 'fontFamily' | 'fontSize' | 'fontWeight'> & {
395
+ color?: ColorValue | undefined;
396
+ }
397
+ >
398
+ | undefined;
394
399
  /**
395
400
  * Options to render a native search bar.
396
401
  * You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
397
402
  * If you don't have a `ScrollView`, specify `headerTransparent: false`.
398
403
  */
399
- headerSearchBarOptions?: Omit<SearchBarProps, 'onChangeText'> & {
400
- onChange?: SearchBarProps['onChangeText'];
401
- };
404
+ headerSearchBarOptions?:
405
+ | (Omit<SearchBarProps, 'onChangeText'> & {
406
+ onChange?: SearchBarProps['onChangeText'] | undefined;
407
+ })
408
+ | undefined;
402
409
  /**
403
410
  * Boolean indicating whether to show the menu on longPress of iOS >= 14 back button. Defaults to `true`.
404
411
  * Requires `react-native-screens` version >=3.3.0.
@@ -407,7 +414,7 @@ export type NativeStackNavigationOptions = {
407
414
  *
408
415
  * @platform ios
409
416
  */
410
- headerBackButtonMenuEnabled?: boolean;
417
+ headerBackButtonMenuEnabled?: boolean | undefined;
411
418
  /**
412
419
  * How the back button displays icon and title.
413
420
  *
@@ -429,25 +436,46 @@ export type NativeStackNavigationOptions = {
429
436
  *
430
437
  * @platform ios, web
431
438
  */
432
- headerBackButtonDisplayMode?: ScreenStackHeaderConfigProps['backButtonDisplayMode'];
439
+ headerBackButtonDisplayMode?:
440
+ | ScreenStackHeaderConfigProps['backButtonDisplayMode']
441
+ | undefined;
442
+ /**
443
+ * Option to control which edges of the native header should apply window insets.
444
+ *
445
+ * By default, the native header applies window insets to all edges.
446
+ * Setting an edge to `false` disables its inset for this header and any nested headers.
447
+ *
448
+ * A nested header cannot re-enable an inset disabled by a parent,
449
+ * even by setting the edge to `true`.
450
+ *
451
+ * This is an unstable API and might change in the future.
452
+ *
453
+ * @platform android
454
+ */
455
+ unstable_headerInsets?: {
456
+ top?: boolean;
457
+ left?: boolean;
458
+ right?: boolean;
459
+ bottom?: boolean;
460
+ };
433
461
  /**
434
462
  * Whether the home indicator should prefer to stay hidden on this screen. Defaults to `false`.
435
463
  *
436
464
  * @platform ios
437
465
  */
438
- autoHideHomeIndicator?: boolean;
466
+ autoHideHomeIndicator?: boolean | undefined;
439
467
  /**
440
468
  * Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.
441
469
  *
442
470
  * @platform ios
443
471
  */
444
- keyboardHandlingEnabled?: boolean;
472
+ keyboardHandlingEnabled?: boolean | undefined;
445
473
  /**
446
474
  * Sets the visibility of the navigation bar. Defaults to `false`.
447
475
  *
448
476
  * @platform android
449
477
  */
450
- navigationBarHidden?: boolean;
478
+ navigationBarHidden?: boolean | undefined;
451
479
  /**
452
480
  * Sets the status bar animation (similar to the `StatusBar` component).
453
481
  * On Android, setting either `fade` or `slide` will set the transition of status bar color. On iOS, this option applies to appereance animation of the status bar.
@@ -459,7 +487,7 @@ export type NativeStackNavigationOptions = {
459
487
  *
460
488
  * @platform android, ios
461
489
  */
462
- statusBarAnimation?: ScreenProps['statusBarAnimation'];
490
+ statusBarAnimation?: ScreenProps['statusBarAnimation'] | undefined;
463
491
  /**
464
492
  * Whether the status bar should be hidden on this screen.
465
493
  * Requires setting `View controller-based status bar appearance -> YES` in your Info.plist file.
@@ -468,7 +496,7 @@ export type NativeStackNavigationOptions = {
468
496
  *
469
497
  * @platform android, ios
470
498
  */
471
- statusBarHidden?: boolean;
499
+ statusBarHidden?: boolean | undefined;
472
500
  /**
473
501
  * Sets the status bar color (similar to the `StatusBar` component).
474
502
  * Requires setting `View controller-based status bar appearance -> YES` (or removing the config) in your `Info.plist` file.
@@ -480,7 +508,7 @@ export type NativeStackNavigationOptions = {
480
508
  *
481
509
  * @platform android, ios
482
510
  */
483
- statusBarStyle?: ScreenProps['statusBarStyle'];
511
+ statusBarStyle?: ScreenProps['statusBarStyle'] | undefined;
484
512
  /**
485
513
  * Sets the direction in which you should swipe to dismiss the screen.
486
514
  * When using `vertical` option, options `fullScreenGestureEnabled: true`, `animationMatchesGesture: true` and `animation: 'slide_from_bottom'` are set by default.
@@ -491,11 +519,11 @@ export type NativeStackNavigationOptions = {
491
519
  *
492
520
  * @platform ios
493
521
  */
494
- gestureDirection?: ScreenProps['swipeDirection'];
522
+ gestureDirection?: ScreenProps['swipeDirection'] | undefined;
495
523
  /**
496
524
  * Style object for the scene content.
497
525
  */
498
- contentStyle?: StyleProp<ViewStyle>;
526
+ contentStyle?: StyleProp<ViewStyle> | undefined;
499
527
  /**
500
528
  * Whether the gesture to dismiss should use animation provided to `animation` prop. Defaults to `false`.
501
529
  *
@@ -503,7 +531,7 @@ export type NativeStackNavigationOptions = {
503
531
  *
504
532
  * @platform ios
505
533
  */
506
- animationMatchesGesture?: boolean;
534
+ animationMatchesGesture?: boolean | undefined;
507
535
  /**
508
536
  * Whether the gesture to dismiss should work on the whole screen. The behavior depends on iOS version.
509
537
  *
@@ -518,7 +546,7 @@ export type NativeStackNavigationOptions = {
518
546
  *
519
547
  * @platform ios
520
548
  */
521
- fullScreenGestureEnabled?: boolean;
549
+ fullScreenGestureEnabled?: boolean | undefined;
522
550
  /**
523
551
  * iOS 18 and below. Controls whether the full screen dismiss gesture has shadow under view during transition.
524
552
  * The gesture uses custom transition and thus doesn't have a shadow by default. When enabled, a custom shadow view
@@ -530,7 +558,7 @@ export type NativeStackNavigationOptions = {
530
558
  *
531
559
  * @platform ios
532
560
  */
533
- fullScreenGestureShadowEnabled?: boolean;
561
+ fullScreenGestureShadowEnabled?: boolean | undefined;
534
562
  /**
535
563
  * Whether you can use gestures to dismiss this screen. Defaults to `true`.
536
564
  *
@@ -538,13 +566,13 @@ export type NativeStackNavigationOptions = {
538
566
  *
539
567
  * @platform ios
540
568
  */
541
- gestureEnabled?: boolean;
569
+ gestureEnabled?: boolean | undefined;
542
570
  /**
543
571
  * Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenGestureEnabled`.
544
572
  *
545
573
  * @platform ios
546
574
  */
547
- gestureResponseDistance?: ScreenProps['gestureResponseDistance'];
575
+ gestureResponseDistance?: ScreenProps['gestureResponseDistance'] | undefined;
548
576
  /**
549
577
  * The type of animation to use when this screen replaces another screen. Defaults to `pop`.
550
578
  *
@@ -554,7 +582,7 @@ export type NativeStackNavigationOptions = {
554
582
  *
555
583
  * Only supported on iOS and Android.
556
584
  */
557
- animationTypeForReplace?: ScreenProps['replaceAnimation'];
585
+ animationTypeForReplace?: ScreenProps['replaceAnimation'] | undefined;
558
586
  /**
559
587
  * How the screen should animate when pushed or popped.
560
588
  *
@@ -573,7 +601,7 @@ export type NativeStackNavigationOptions = {
573
601
  *
574
602
  * Only supported on iOS and Android.
575
603
  */
576
- animation?: ScreenProps['stackAnimation'];
604
+ animation?: ScreenProps['stackAnimation'] | undefined;
577
605
  /**
578
606
  * Duration (in milliseconds) for the following transition animations on iOS:
579
607
  * - `slide_from_bottom`
@@ -589,7 +617,7 @@ export type NativeStackNavigationOptions = {
589
617
  *
590
618
  * @platform ios
591
619
  */
592
- animationDuration?: number;
620
+ animationDuration?: number | undefined;
593
621
  /**
594
622
  * How should the screen be presented.
595
623
  *
@@ -605,7 +633,10 @@ export type NativeStackNavigationOptions = {
605
633
  *
606
634
  * Only supported on iOS and Android.
607
635
  */
608
- presentation?: Exclude<ScreenProps['stackPresentation'], 'push'> | 'card';
636
+ presentation?:
637
+ | Exclude<ScreenProps['stackPresentation'], 'push'>
638
+ | 'card'
639
+ | undefined;
609
640
  /**
610
641
  * Describes heights where a sheet can rest.
611
642
  * Works only when `presentation` is set to `formSheet`.
@@ -624,7 +655,7 @@ export type NativeStackNavigationOptions = {
624
655
  *
625
656
  * Defaults to `[1.0]`.
626
657
  */
627
- sheetAllowedDetents?: number[] | 'fitToContents';
658
+ sheetAllowedDetents?: number[] | 'fitToContents' | undefined;
628
659
  /**
629
660
  * Integer value describing elevation of the sheet, impacting shadow on the top edge of the sheet.
630
661
  *
@@ -634,7 +665,7 @@ export type NativeStackNavigationOptions = {
634
665
  *
635
666
  * @platform Android
636
667
  */
637
- sheetElevation?: number;
668
+ sheetElevation?: number | undefined;
638
669
  /**
639
670
  * Whether the sheet should expand to larger detent when scrolling.
640
671
  * Works only when `presentation` is set to `formSheet`.
@@ -642,7 +673,7 @@ export type NativeStackNavigationOptions = {
642
673
  *
643
674
  * @platform ios
644
675
  */
645
- sheetExpandsWhenScrolledToEdge?: boolean;
676
+ sheetExpandsWhenScrolledToEdge?: boolean | undefined;
646
677
  /**
647
678
  * The corner radius that the sheet will try to render with.
648
679
  * Works only when `presentation` is set to `formSheet`.
@@ -651,7 +682,7 @@ export type NativeStackNavigationOptions = {
651
682
  *
652
683
  * If left unset system default is used.
653
684
  */
654
- sheetCornerRadius?: number;
685
+ sheetCornerRadius?: number | undefined;
655
686
  /**
656
687
  * Index of the detent the sheet should expand to after being opened.
657
688
  * Works only when `stackPresentation` is set to `formSheet`.
@@ -663,7 +694,7 @@ export type NativeStackNavigationOptions = {
663
694
  *
664
695
  * Defaults to `0` - which represents first detent in the detents array.
665
696
  */
666
- sheetInitialDetentIndex?: number | 'last';
697
+ sheetInitialDetentIndex?: number | 'last' | undefined;
667
698
  /**
668
699
  * Boolean indicating whether the sheet shows a grabber at the top.
669
700
  * Works only when `presentation` is set to `formSheet`.
@@ -671,7 +702,7 @@ export type NativeStackNavigationOptions = {
671
702
  *
672
703
  * @platform ios
673
704
  */
674
- sheetGrabberVisible?: boolean;
705
+ sheetGrabberVisible?: boolean | undefined;
675
706
  /**
676
707
  * The largest sheet detent for which a view underneath won't be dimmed.
677
708
  * Works only when `presentation` is set to `formSheet`.
@@ -691,7 +722,7 @@ export type NativeStackNavigationOptions = {
691
722
  *
692
723
  * Defaults to `none`, indicating that the dimming view should be always present.
693
724
  */
694
- sheetLargestUndimmedDetentIndex?: number | 'none' | 'last';
725
+ sheetLargestUndimmedDetentIndex?: number | 'none' | 'last' | undefined;
695
726
  /**
696
727
  * Whether the sheet content should be rendered behind the Status Bar or display cutouts.
697
728
  *
@@ -707,7 +738,7 @@ export type NativeStackNavigationOptions = {
707
738
  *
708
739
  * @platform android
709
740
  */
710
- sheetShouldOverflowTopInset?: boolean;
741
+ sheetShouldOverflowTopInset?: boolean | undefined;
711
742
  /**
712
743
  * Whether the default native animation should be used when the sheet's with
713
744
  * `fitToContents` content size changes.
@@ -724,7 +755,7 @@ export type NativeStackNavigationOptions = {
724
755
  *
725
756
  * @platform android
726
757
  */
727
- sheetResizeAnimationEnabled?: boolean;
758
+ sheetResizeAnimationEnabled?: boolean | undefined;
728
759
  /**
729
760
  * The display orientation to use for the screen.
730
761
  *
@@ -740,15 +771,7 @@ export type NativeStackNavigationOptions = {
740
771
  *
741
772
  * Only supported on iOS and Android.
742
773
  */
743
- orientation?: ScreenProps['screenOrientation'];
744
- /**
745
- * Whether inactive screens should be suspended from re-rendering. Defaults to `false`.
746
- * Defaults to `true` when `enableFreeze()` is run at the top of the application.
747
- * Requires `react-native-screens` version >=3.16.0.
748
- *
749
- * Only supported on iOS and Android.
750
- */
751
- freezeOnBlur?: boolean;
774
+ orientation?: ScreenProps['screenOrientation'] | undefined;
752
775
  /**
753
776
  * Configures the scroll edge effect for the _content ScrollView_ (the ScrollView that is present in first descendants chain of the Screen).
754
777
  * Depending on values set, it will blur the scrolling content below certain UI elements (header items, search bar)
@@ -772,12 +795,14 @@ export type NativeStackNavigationOptions = {
772
795
  *
773
796
  * @supported iOS 26 or higher
774
797
  */
775
- scrollEdgeEffects?: {
776
- bottom?: ScrollEdgeEffect;
777
- left?: ScrollEdgeEffect;
778
- right?: ScrollEdgeEffect;
779
- top?: ScrollEdgeEffect;
780
- };
798
+ scrollEdgeEffects?:
799
+ | {
800
+ bottom?: ScrollEdgeEffect | undefined;
801
+ left?: ScrollEdgeEffect | undefined;
802
+ right?: ScrollEdgeEffect | undefined;
803
+ top?: ScrollEdgeEffect | undefined;
804
+ }
805
+ | undefined;
781
806
  /**
782
807
  * Footer component that can be used alongside formSheet stack presentation style.
783
808
  *
@@ -790,27 +815,25 @@ export type NativeStackNavigationOptions = {
790
815
  *
791
816
  * @platform android
792
817
  */
793
- unstable_sheetFooter?: () => React.ReactNode;
794
- };
818
+ unstable_sheetFooter?: (() => React.ReactNode) | undefined;
795
819
 
796
- type PlatformIconShared = {
797
- type: 'image';
798
- source: ImageSourcePropType;
799
820
  /**
800
- * Whether to apply tint color to the icon.
801
- * Defaults to `true`.
821
+ * What should happen when screens become inactive.
822
+ * - `pause`: Effects are cleaned up.
823
+ * - `unmount`: Screen is unmounted
824
+ * - `none`: Screen renders normally
802
825
  *
803
- * @platform ios
826
+ * Defaults to `pause`.
827
+ *
828
+ * Preloaded screens won't be paused until after navigated to.
829
+ * This makes sure that effects are run to initialize the screen.
830
+ *
831
+ * Screens with nested navigators and last 2 screens won't be unmounted.
804
832
  */
805
- tinted?: boolean;
833
+ inactiveBehavior?: 'pause' | 'unmount' | 'none' | undefined;
806
834
  };
807
835
 
808
- type PlatformIconIOSSfSymbol = {
809
- type: 'sfSymbol';
810
- name: SFSymbol;
811
- };
812
-
813
- type PlatformIconIOS = PlatformIconIOSSfSymbol | PlatformIconShared;
836
+ type IconIOS = Extract<Icon, { type: 'image' | 'sfSymbol' }>;
814
837
 
815
838
  type SharedHeaderItem = {
816
839
  /**
@@ -820,90 +843,96 @@ type SharedHeaderItem = {
820
843
  /**
821
844
  * Style for the item label.
822
845
  */
823
- labelStyle?: {
824
- fontFamily?: string;
825
- fontSize?: number;
826
- fontWeight?: string;
827
- color?: ColorValue;
828
- };
846
+ labelStyle?:
847
+ | {
848
+ fontFamily?: string | undefined;
849
+ fontSize?: number | undefined;
850
+ fontWeight?: string | undefined;
851
+ color?: ColorValue | undefined;
852
+ }
853
+ | undefined;
829
854
  /**
830
855
  * Icon for the item
831
856
  */
832
- icon?: PlatformIconIOS;
857
+ icon?: IconIOS | undefined;
833
858
  /**
834
859
  * The variant of the item.
835
860
  * "prominent" only available from iOS 26.0 and later.
836
861
  *
837
862
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/style-swift.property
838
863
  */
839
- variant?: 'plain' | 'done' | 'prominent';
864
+ variant?: 'plain' | 'done' | 'prominent' | undefined;
840
865
  /**
841
866
  * The tint color to apply to the item.
842
867
  *
843
868
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/tintcolor
844
869
  */
845
- tintColor?: ColorValue;
870
+ tintColor?: ColorValue | undefined;
846
871
  /**
847
872
  * Whether the item is in a disabled state.
848
873
  */
849
- disabled?: boolean;
874
+ disabled?: boolean | undefined;
850
875
  /**
851
876
  * The width of the item.
852
877
  *
853
878
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/width
854
879
  */
855
- width?: number;
880
+ width?: number | undefined;
856
881
  /**
857
882
  * Whether the background this item may share with other items in the bar should be hidden.
858
883
  * Only available from iOS 26.0 and later.
859
884
  *
860
885
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/hidessharedbackground
861
886
  */
862
- hidesSharedBackground?: boolean;
887
+ hidesSharedBackground?: boolean | undefined;
863
888
  /**
864
889
  * Whether this item can share a background with other items.
865
890
  * Only available from iOS 26.0 and later.
866
891
  *
867
892
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/sharesbackground
868
893
  */
869
- sharesBackground?: boolean;
894
+ sharesBackground?: boolean | undefined;
870
895
  /**
871
896
  * An identifier used to match items across transitions.
872
897
  * Only available from iOS 26.0 and later.
873
898
  *
874
899
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/identifier
875
900
  */
876
- identifier?: string;
901
+ identifier?: string | undefined;
877
902
  /**
878
903
  * A badge to display on a item.
879
904
  * Only available from iOS 26.0 and later.
880
905
  *
881
906
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitembadge
882
907
  */
883
- badge?: {
884
- /**
885
- * The text to display in the badge.
886
- */
887
- value: number | string;
888
- /**
889
- * Style of the badge.
890
- */
891
- style?: {
892
- color?: ColorValue;
893
- backgroundColor?: ColorValue;
894
- fontFamily?: string;
895
- fontSize?: number;
896
- fontWeight?: string;
897
- };
898
- };
908
+ badge?:
909
+ | {
910
+ /**
911
+ * The text to display in the badge.
912
+ */
913
+ value: number | string;
914
+ /**
915
+ * Style of the badge.
916
+ */
917
+ style?:
918
+ | {
919
+ color?: ColorValue | undefined;
920
+ backgroundColor?: ColorValue | undefined;
921
+ fontFamily?: string | undefined;
922
+ fontSize?: number | undefined;
923
+ fontWeight?: string | undefined;
924
+ }
925
+ | undefined;
926
+ }
927
+ | undefined;
899
928
  /**
900
929
  * Accessibility label for the item.
901
930
  */
902
- accessibilityLabel?: string;
931
+ accessibilityLabel?: string | undefined;
903
932
  /**
904
933
  * Accessibility hint for the item.
905
934
  */
906
- accessibilityHint?: string;
935
+ accessibilityHint?: string | undefined;
907
936
  };
908
937
 
909
938
  /**
@@ -923,7 +952,7 @@ export type NativeStackHeaderItemButton = SharedHeaderItem & {
923
952
  *
924
953
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/isselected
925
954
  */
926
- selected?: boolean;
955
+ selected?: boolean | undefined;
927
956
  };
928
957
 
929
958
  /**
@@ -938,11 +967,11 @@ export type NativeStackHeaderItemMenuAction = {
938
967
  /**
939
968
  * The secondary text displayed alongside the label of the menu item.
940
969
  */
941
- description?: string;
970
+ description?: string | undefined;
942
971
  /**
943
972
  * Icon for the menu item.
944
973
  */
945
- icon?: PlatformIconIOSSfSymbol;
974
+ icon?: IconIOS | undefined;
946
975
  /**
947
976
  * Function to call when the menu item is pressed.
948
977
  */
@@ -952,31 +981,31 @@ export type NativeStackHeaderItemMenuAction = {
952
981
  *
953
982
  * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/state
954
983
  */
955
- state?: 'on' | 'off' | 'mixed';
984
+ state?: 'on' | 'off' | 'mixed' | undefined;
956
985
  /**
957
986
  * Whether to apply disabled style to the item.
958
987
  *
959
988
  * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/disabled
960
989
  */
961
- disabled?: boolean;
990
+ disabled?: boolean | undefined;
962
991
  /**
963
992
  * Whether to apply destructive style to the item.
964
993
  *
965
994
  * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/destructive
966
995
  */
967
- destructive?: boolean;
996
+ destructive?: boolean | undefined;
968
997
  /**
969
998
  * Whether to apply hidden style to the item.
970
999
  *
971
1000
  * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/hidden
972
1001
  */
973
- hidden?: boolean;
1002
+ hidden?: boolean | undefined;
974
1003
  /**
975
- * Whether to keep the menu presented after firing the element’s action.
1004
+ * Whether to keep the menu presented after firing the element's action.
976
1005
  *
977
1006
  * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/keepsmenupresented
978
1007
  */
979
- keepsMenuPresented?: boolean;
1008
+ keepsMenuPresented?: boolean | undefined;
980
1009
  /**
981
1010
  * An elaborated title that explains the purpose of the action.
982
1011
  *
@@ -985,7 +1014,7 @@ export type NativeStackHeaderItemMenuAction = {
985
1014
  *
986
1015
  * Read more: https://developer.apple.com/documentation/uikit/uiaction/discoverabilitytitle
987
1016
  */
988
- discoverabilityLabel?: string;
1017
+ discoverabilityLabel?: string | undefined;
989
1018
  };
990
1019
 
991
1020
  /**
@@ -1000,7 +1029,7 @@ export type NativeStackHeaderItemMenuSubmenu = {
1000
1029
  /**
1001
1030
  * Icon for the submenu item.
1002
1031
  */
1003
- icon?: PlatformIconIOSSfSymbol;
1032
+ icon?: IconIOS | undefined;
1004
1033
  /**
1005
1034
  * Whether the menu is displayed inline with the parent menu.
1006
1035
  * By default, submenus are displayed after expanding the parent menu item.
@@ -1010,7 +1039,7 @@ export type NativeStackHeaderItemMenuSubmenu = {
1010
1039
  *
1011
1040
  * Read more: https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayinline
1012
1041
  */
1013
- inline?: boolean;
1042
+ inline?: boolean | undefined;
1014
1043
  /**
1015
1044
  * How the submenu items are displayed.
1016
1045
  * - `default`: menu items are displayed normally.
@@ -1020,13 +1049,13 @@ export type NativeStackHeaderItemMenuSubmenu = {
1020
1049
  *
1021
1050
  * Read more: https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette
1022
1051
  */
1023
- layout?: 'default' | 'palette';
1052
+ layout?: 'default' | 'palette' | undefined;
1024
1053
  /**
1025
1054
  * Whether to apply destructive style to the menu item.
1026
1055
  *
1027
1056
  * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/destructive
1028
1057
  */
1029
- destructive?: boolean;
1058
+ destructive?: boolean | undefined;
1030
1059
  /**
1031
1060
  * Whether multiple items in the submenu can be selected, i.e. in "on" state.
1032
1061
  *
@@ -1034,7 +1063,7 @@ export type NativeStackHeaderItemMenuSubmenu = {
1034
1063
  *
1035
1064
  * Read more: https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/singleselection
1036
1065
  */
1037
- multiselectable?: boolean;
1066
+ multiselectable?: boolean | undefined;
1038
1067
  /**
1039
1068
  * Array of menu items (actions or submenus).
1040
1069
  */
@@ -1052,7 +1081,7 @@ export type NativeStackHeaderItemMenu = SharedHeaderItem & {
1052
1081
  *
1053
1082
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/changesselectionasprimaryaction
1054
1083
  */
1055
- changesSelectionAsPrimaryAction?: boolean;
1084
+ changesSelectionAsPrimaryAction?: boolean | undefined;
1056
1085
  /**
1057
1086
  * Menu for the item.
1058
1087
  */
@@ -1060,7 +1089,7 @@ export type NativeStackHeaderItemMenu = SharedHeaderItem & {
1060
1089
  /**
1061
1090
  * Optional title to show on top of the menu.
1062
1091
  */
1063
- title?: string;
1092
+ title?: string | undefined;
1064
1093
  /**
1065
1094
  * Whether multiple items in the submenu can be selected, i.e. in "on" state.
1066
1095
  *
@@ -1068,7 +1097,7 @@ export type NativeStackHeaderItemMenu = SharedHeaderItem & {
1068
1097
  *
1069
1098
  * Read more: https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/singleselection
1070
1099
  */
1071
- multiselectable?: boolean;
1100
+ multiselectable?: boolean | undefined;
1072
1101
  /**
1073
1102
  * How the submenu items are displayed.
1074
1103
  * - `default`: menu items are displayed normally.
@@ -1078,7 +1107,7 @@ export type NativeStackHeaderItemMenu = SharedHeaderItem & {
1078
1107
  *
1079
1108
  * Read more: https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette
1080
1109
  */
1081
- layout?: 'default' | 'palette';
1110
+ layout?: 'default' | 'palette' | undefined;
1082
1111
  /**
1083
1112
  * Array of menu items (actions or submenus).
1084
1113
  */
@@ -1115,7 +1144,7 @@ export type NativeStackHeaderItemCustom = {
1115
1144
  *
1116
1145
  * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/hidessharedbackground
1117
1146
  */
1118
- hidesSharedBackground?: boolean;
1147
+ hidesSharedBackground?: boolean | undefined;
1119
1148
  };
1120
1149
 
1121
1150
  /**