@react-navigation/native-stack 7.0.0-rc.27 → 7.0.0-rc.29

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 (85) hide show
  1. package/lib/commonjs/navigators/createNativeStackNavigator.js +3 -1
  2. package/lib/commonjs/navigators/createNativeStackNavigator.js.map +1 -1
  3. package/lib/commonjs/views/DebugContainer.native.js +8 -10
  4. package/lib/commonjs/views/DebugContainer.native.js.map +1 -1
  5. package/lib/commonjs/views/FooterComponent.js +19 -0
  6. package/lib/commonjs/views/FooterComponent.js.map +1 -0
  7. package/lib/commonjs/views/NativeStackView.js +11 -8
  8. package/lib/commonjs/views/NativeStackView.js.map +1 -1
  9. package/lib/commonjs/views/NativeStackView.native.js +84 -95
  10. package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
  11. package/lib/commonjs/views/ScreenStackContent.js +70 -0
  12. package/lib/commonjs/views/ScreenStackContent.js.map +1 -0
  13. package/lib/commonjs/views/{HeaderConfig.js → useHeaderConfigProps.js} +59 -48
  14. package/lib/commonjs/views/useHeaderConfigProps.js.map +1 -0
  15. package/lib/module/navigators/createNativeStackNavigator.js +3 -1
  16. package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
  17. package/lib/module/views/DebugContainer.native.js +9 -11
  18. package/lib/module/views/DebugContainer.native.js.map +1 -1
  19. package/lib/module/views/FooterComponent.js +14 -0
  20. package/lib/module/views/FooterComponent.js.map +1 -0
  21. package/lib/module/views/NativeStackView.js +11 -8
  22. package/lib/module/views/NativeStackView.js.map +1 -1
  23. package/lib/module/views/NativeStackView.native.js +85 -95
  24. package/lib/module/views/NativeStackView.native.js.map +1 -1
  25. package/lib/module/views/ScreenStackContent.js +63 -0
  26. package/lib/module/views/ScreenStackContent.js.map +1 -0
  27. package/lib/module/views/{HeaderConfig.js → useHeaderConfigProps.js} +59 -48
  28. package/lib/module/views/useHeaderConfigProps.js.map +1 -0
  29. package/lib/typescript/commonjs/src/index.d.ts +1 -1
  30. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/src/types.d.ts +80 -18
  33. package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/src/views/DebugContainer.d.ts +1 -1
  35. package/lib/typescript/commonjs/src/views/DebugContainer.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/src/views/DebugContainer.native.d.ts +1 -1
  37. package/lib/typescript/commonjs/src/views/DebugContainer.native.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/src/views/FooterComponent.d.ts +7 -0
  39. package/lib/typescript/commonjs/src/views/FooterComponent.d.ts.map +1 -0
  40. package/lib/typescript/commonjs/src/views/NativeStackView.d.ts +4 -3
  41. package/lib/typescript/commonjs/src/views/NativeStackView.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/src/views/NativeStackView.native.d.ts +4 -3
  43. package/lib/typescript/commonjs/src/views/NativeStackView.native.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/src/views/ScreenStackContent.d.ts +9 -0
  45. package/lib/typescript/commonjs/src/views/ScreenStackContent.d.ts.map +1 -0
  46. package/lib/typescript/commonjs/src/views/useHeaderConfigProps.d.ts +41 -0
  47. package/lib/typescript/commonjs/src/views/useHeaderConfigProps.d.ts.map +1 -0
  48. package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
  49. package/lib/typescript/module/src/index.d.ts +1 -1
  50. package/lib/typescript/module/src/index.d.ts.map +1 -1
  51. package/lib/typescript/module/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
  52. package/lib/typescript/module/src/types.d.ts +80 -18
  53. package/lib/typescript/module/src/types.d.ts.map +1 -1
  54. package/lib/typescript/module/src/views/DebugContainer.d.ts +1 -1
  55. package/lib/typescript/module/src/views/DebugContainer.d.ts.map +1 -1
  56. package/lib/typescript/module/src/views/DebugContainer.native.d.ts +1 -1
  57. package/lib/typescript/module/src/views/DebugContainer.native.d.ts.map +1 -1
  58. package/lib/typescript/module/src/views/FooterComponent.d.ts +7 -0
  59. package/lib/typescript/module/src/views/FooterComponent.d.ts.map +1 -0
  60. package/lib/typescript/module/src/views/NativeStackView.d.ts +4 -3
  61. package/lib/typescript/module/src/views/NativeStackView.d.ts.map +1 -1
  62. package/lib/typescript/module/src/views/NativeStackView.native.d.ts +4 -3
  63. package/lib/typescript/module/src/views/NativeStackView.native.d.ts.map +1 -1
  64. package/lib/typescript/module/src/views/ScreenStackContent.d.ts +9 -0
  65. package/lib/typescript/module/src/views/ScreenStackContent.d.ts.map +1 -0
  66. package/lib/typescript/module/src/views/useHeaderConfigProps.d.ts +41 -0
  67. package/lib/typescript/module/src/views/useHeaderConfigProps.d.ts.map +1 -0
  68. package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
  69. package/package.json +9 -9
  70. package/src/index.tsx +2 -0
  71. package/src/navigators/createNativeStackNavigator.tsx +2 -1
  72. package/src/types.tsx +74 -18
  73. package/src/views/DebugContainer.native.tsx +13 -6
  74. package/src/views/DebugContainer.tsx +1 -1
  75. package/src/views/FooterComponent.tsx +10 -0
  76. package/src/views/NativeStackView.native.tsx +111 -151
  77. package/src/views/NativeStackView.tsx +24 -12
  78. package/src/views/ScreenStackContent.tsx +121 -0
  79. package/src/views/{HeaderConfig.tsx → useHeaderConfigProps.tsx} +67 -71
  80. package/lib/commonjs/views/HeaderConfig.js.map +0 -1
  81. package/lib/module/views/HeaderConfig.js.map +0 -1
  82. package/lib/typescript/commonjs/src/views/HeaderConfig.d.ts +0 -11
  83. package/lib/typescript/commonjs/src/views/HeaderConfig.d.ts.map +0 -1
  84. package/lib/typescript/module/src/views/HeaderConfig.d.ts +0 -11
  85. package/lib/typescript/module/src/views/HeaderConfig.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/native-stack",
3
3
  "description": "Native stack navigator using react-native-screens",
4
- "version": "7.0.0-rc.27",
4
+ "version": "7.0.0-rc.29",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -52,27 +52,27 @@
52
52
  "clean": "del lib"
53
53
  },
54
54
  "dependencies": {
55
- "@react-navigation/elements": "^2.0.0-rc.24",
55
+ "@react-navigation/elements": "^2.0.0-rc.26",
56
56
  "warn-once": "^0.1.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@jest/globals": "^29.7.0",
60
- "@react-navigation/native": "^7.0.0-rc.19",
60
+ "@react-navigation/native": "^7.0.0-rc.21",
61
61
  "@testing-library/react-native": "^12.4.3",
62
62
  "@types/react": "~18.2.79",
63
63
  "del-cli": "^5.1.0",
64
64
  "react": "18.2.0",
65
- "react-native": "0.74.2",
65
+ "react-native": "0.74.5",
66
66
  "react-native-builder-bob": "^0.29.0",
67
- "react-native-screens": "3.32.0",
67
+ "react-native-screens": "4.0.0-beta.9",
68
68
  "typescript": "^5.5.2"
69
69
  },
70
70
  "peerDependencies": {
71
- "@react-navigation/native": "^7.0.0-rc.19",
71
+ "@react-navigation/native": "^7.0.0-rc.21",
72
72
  "react": ">= 18.2.0",
73
- "react-native": ">= 0.72.0",
73
+ "react-native": "*",
74
74
  "react-native-safe-area-context": ">= 4.0.0",
75
- "react-native-screens": ">= 3.21.0"
75
+ "react-native-screens": ">= 4.0.0"
76
76
  },
77
77
  "react-native-builder-bob": {
78
78
  "source": "src",
@@ -99,5 +99,5 @@
99
99
  ]
100
100
  ]
101
101
  },
102
- "gitHead": "cfebf105844ac1674eee28ec1ff4ccd30e7895ee"
102
+ "gitHead": "458dac172e46ee9dd6c6e27ae23417d0d371e0d6"
103
103
  }
package/src/index.tsx CHANGED
@@ -17,7 +17,9 @@ export { useAnimatedHeaderHeight } from './utils/useAnimatedHeaderHeight';
17
17
  * Types
18
18
  */
19
19
  export type {
20
+ NativeStackHeaderLeftProps,
20
21
  NativeStackHeaderProps,
22
+ NativeStackHeaderRightProps,
21
23
  NativeStackNavigationEventMap,
22
24
  NativeStackNavigationOptions,
23
25
  NativeStackNavigationProp,
@@ -33,7 +33,7 @@ function NativeStackNavigator({
33
33
  UNSTABLE_getStateForRouteNamesChange,
34
34
  ...rest
35
35
  }: NativeStackNavigatorProps) {
36
- const { state, descriptors, navigation, NavigationContent } =
36
+ const { state, describe, descriptors, navigation, NavigationContent } =
37
37
  useNavigationBuilder<
38
38
  StackNavigationState<ParamListBase>,
39
39
  StackRouterOptions,
@@ -84,6 +84,7 @@ function NativeStackNavigator({
84
84
  state={state}
85
85
  navigation={navigation}
86
86
  descriptors={descriptors}
87
+ describe={describe}
87
88
  />
88
89
  </NavigationContent>
89
90
  );
package/src/types.tsx CHANGED
@@ -21,7 +21,6 @@ import type {
21
21
  ScreenProps,
22
22
  ScreenStackHeaderConfigProps,
23
23
  SearchBarProps,
24
- SheetDetentTypes,
25
24
  } from 'react-native-screens';
26
25
 
27
26
  export type NativeStackNavigationEventMap = {
@@ -37,6 +36,15 @@ export type NativeStackNavigationEventMap = {
37
36
  * Event which fires when a swipe back is canceled on iOS.
38
37
  */
39
38
  gestureCancel: { data: undefined };
39
+ /**
40
+ * Event which fires when screen is in sheet presentation & it's detent changes.
41
+ *
42
+ * In payload it caries two fields:
43
+ *
44
+ * * `index` - current detent index in the `sheetAllowedDetents` array,
45
+ * * `stable` - on Android `false` value means that the user is dragging the sheet or it is settling; on iOS it is always `true`.
46
+ */
47
+ sheetDetentChange: { data: { index: number; stable: boolean } };
40
48
  };
41
49
 
42
50
  export type NativeStackNavigationProp<
@@ -439,6 +447,13 @@ export type NativeStackNavigationOptions = {
439
447
  * Style object for the scene content.
440
448
  */
441
449
  contentStyle?: StyleProp<ViewStyle>;
450
+ /**
451
+ * Style object for the screen native component. This might help to workaround
452
+ * some issues when using `formSheet` presentation.
453
+ *
454
+ * Only `backgroundColor` is accepted.
455
+ */
456
+ unstable_screenStyle?: ScreenProps['unstable_screenStyle'];
442
457
  /**
443
458
  * Whether the gesture to dismiss should use animation provided to `animation` prop. Defaults to `false`.
444
459
  *
@@ -497,11 +512,14 @@ export type NativeStackNavigationOptions = {
497
512
  * Supported values:
498
513
  * - "default": use the platform default animation
499
514
  * - "fade": fade screen in or out
515
+ * - "fade_from_bottom" – performs a fade from bottom animation
500
516
  * - "flip": flip the screen, requires presentation: "modal" (iOS only)
501
517
  * - "simple_push": use the platform default animation, but without shadow and native header transition (iOS only)
502
518
  * - "slide_from_bottom": slide in the new screen from bottom
503
519
  * - "slide_from_right": slide in the new screen from right (Android only, uses default animation on iOS)
504
520
  * - "slide_from_left": slide in the new screen from left (Android only, uses default animation on iOS)
521
+ * - "ios_from_right" - iOS like slide in animation. pushes in the new screen from right to left (Android only, resolves to default transition on iOS)
522
+ * - "ios_from_left" - iOS like slide in animation. pushes in the new screen from left to right (Android only, resolves to default transition on iOS)
505
523
  * - "none": don't animate the screen
506
524
  *
507
525
  * Only supported on iOS and Android.
@@ -532,17 +550,32 @@ export type NativeStackNavigationOptions = {
532
550
  /**
533
551
  * Describes heights where a sheet can rest.
534
552
  * Works only when `presentation` is set to `formSheet`.
535
- * Defaults to `large`.
536
553
  *
537
- * Available values:
554
+ * Heights should be described as fraction (a number from `[0, 1]` interval) of screen height / maximum detent height.
555
+ * You can pass an array of ascending values each defining allowed sheet detent. iOS accepts any number of detents,
556
+ * while **Android is limited to three**.
538
557
  *
539
- * - `large` - only large detent level will be allowed
540
- * - `medium` - only medium detent level will be allowed
541
- * - `all` - all detent levels will be allowed
558
+ * There is also possibility to specify `fitToContents` literal, which intents to set the sheet height
559
+ * to the height of its contents.
542
560
  *
543
- * @platform ios
561
+ * Please note that the array **must** be sorted in ascending order. This invariant is verified only in developement mode,
562
+ * where violation results in error.
563
+ *
564
+ * **Android is limited to up 3 values in the array** -- any surplus values, beside first three are ignored.
565
+ *
566
+ * Defaults to `[1.0]`.
567
+ */
568
+ sheetAllowedDetents?: number[] | 'fitToContents';
569
+ /**
570
+ * Integer value describing elevation of the sheet, impacting shadow on the top edge of the sheet.
571
+ *
572
+ * Not dynamic - changing it after the component is rendered won't have an effect.
573
+ *
574
+ * Defaults to `24`.
575
+ *
576
+ * @platform Android
544
577
  */
545
- sheetAllowedDetents?: SheetDetentTypes;
578
+ sheetElevation?: number;
546
579
  /**
547
580
  * Whether the sheet should expand to larger detent when scrolling.
548
581
  * Works only when `presentation` is set to `formSheet`.
@@ -558,10 +591,20 @@ export type NativeStackNavigationOptions = {
558
591
  * If set to non-negative value it will try to render sheet with provided radius, else it will apply system default.
559
592
  *
560
593
  * If left unset system default is used.
561
- *
562
- * @platform ios
563
594
  */
564
595
  sheetCornerRadius?: number;
596
+ /**
597
+ * Index of the detent the sheet should expand to after being opened.
598
+ * Works only when `stackPresentation` is set to `formSheet`.
599
+ *
600
+ * If the specified index is out of bounds of `sheetAllowedDetents` array, in dev environment more error will be thrown,
601
+ * in production the value will be reset to default value.
602
+ *
603
+ * Additionaly there is `last` value available, when set the sheet will expand initially to last (largest) detent.
604
+ *
605
+ * Defaults to `0` - which represents first detent in the detents array.
606
+ */
607
+ sheetInitialDetentIndex?: number | 'last';
565
608
  /**
566
609
  * Boolean indicating whether the sheet shows a grabber at the top.
567
610
  * Works only when `presentation` is set to `formSheet`.
@@ -572,19 +615,19 @@ export type NativeStackNavigationOptions = {
572
615
  sheetGrabberVisible?: boolean;
573
616
  /**
574
617
  * The largest sheet detent for which a view underneath won't be dimmed.
575
- * Works only when `presentation` is se tto `formSheet`.
618
+ * Works only when `presentation` is set to `formSheet`.
576
619
  *
577
- * If this prop is set to:
620
+ * This prop can be set to an number, which indicates index of detent in `sheetAllowedDetents` array for which
621
+ * there won't be a dimming view beneath the sheet.
578
622
  *
579
- * - `large` - the view underneath won't be dimmed at any detent level
580
- * - `medium` - the view underneath will be dimmed only when detent level is `large`
581
- * - `all` - the view underneath will be dimmed for any detent level
623
+ * Additionaly there are following options available:
582
624
  *
583
- * Defaults to `all`.
625
+ * * `none` - there will be dimming view for all detents levels,
626
+ * * `last` - there won't be a dimming view for any detent level.
584
627
  *
585
- * @platform ios
628
+ * Defaults to `none`, indicating that the dimming view should be always present.
586
629
  */
587
- sheetLargestUndimmedDetent?: SheetDetentTypes;
630
+ sheetLargestUndimmedDetentIndex?: number | 'none' | 'last';
588
631
  /**
589
632
  * The display orientation to use for the screen.
590
633
  *
@@ -609,6 +652,19 @@ export type NativeStackNavigationOptions = {
609
652
  * Only supported on iOS and Android.
610
653
  */
611
654
  freezeOnBlur?: boolean;
655
+ /**
656
+ * Footer component that can be used alongside formSheet stack presentation style.
657
+ *
658
+ * This option is provided, because due to implementation details it might be problematic
659
+ * to implement such layout with JS-only code.
660
+ *
661
+ * Please note that this prop is marked as unstable and might be subject of breaking changes,
662
+ * including removal, in particular when we find solution that will make implementing it with JS
663
+ * straightforward.
664
+ *
665
+ * @platform android
666
+ */
667
+ unstable_sheetFooter?: () => React.ReactNode;
612
668
  };
613
669
 
614
670
  export type NativeStackNavigatorProps = DefaultNavigatorOptions<
@@ -1,8 +1,11 @@
1
1
  import * as React from 'react';
2
- import { Platform, View, type ViewProps } from 'react-native';
2
+ import { Platform, type ViewProps } from 'react-native';
3
3
  // @ts-expect-error Getting private component
4
4
  import AppContainer from 'react-native/Libraries/ReactNative/AppContainer';
5
- import type { StackPresentationTypes } from 'react-native-screens';
5
+ import {
6
+ ScreenContentWrapper,
7
+ type StackPresentationTypes,
8
+ } from 'react-native-screens';
6
9
 
7
10
  type ContainerProps = ViewProps & {
8
11
  stackPresentation: StackPresentationTypes;
@@ -15,22 +18,26 @@ type ContainerProps = ViewProps & {
15
18
  * for detailed explanation.
16
19
  */
17
20
  export let DebugContainer = (props: ContainerProps) => {
18
- return <View {...props} collapsable={false} />;
21
+ return <ScreenContentWrapper {...props} />;
19
22
  };
20
23
 
21
24
  if (process.env.NODE_ENV !== 'production') {
22
25
  DebugContainer = (props: ContainerProps) => {
23
26
  const { stackPresentation, ...rest } = props;
24
27
 
25
- if (Platform.OS === 'ios' && stackPresentation !== 'push') {
28
+ if (
29
+ Platform.OS === 'ios' &&
30
+ stackPresentation !== 'push' &&
31
+ stackPresentation !== 'formSheet'
32
+ ) {
26
33
  // This is necessary for LogBox
27
34
  return (
28
35
  <AppContainer>
29
- <View {...rest} collapsable={false} />
36
+ <ScreenContentWrapper {...rest} />
30
37
  </AppContainer>
31
38
  );
32
39
  }
33
40
 
34
- return <View {...rest} collapsable={false} />;
41
+ return <ScreenContentWrapper {...rest} />;
35
42
  };
36
43
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { View, type ViewProps } from 'react-native';
3
- import type { StackPresentationTypes } from 'react-native-screens';
3
+ import { type StackPresentationTypes } from 'react-native-screens';
4
4
 
5
5
  type ContainerProps = ViewProps & {
6
6
  stackPresentation: StackPresentationTypes;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ScreenFooter } from 'react-native-screens';
3
+
4
+ type FooterProps = {
5
+ children?: React.ReactNode;
6
+ };
7
+
8
+ export function FooterComponent({ children }: FooterProps) {
9
+ return <ScreenFooter collapsable={false}>{children}</ScreenFooter>;
10
+ }