@amazon-devices/react-navigation__stack 7.0.9000000000 → 8.0.9000000000-rn-83

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 (275) hide show
  1. package/SystemBundles/03e0ad8b8bcf16e659904adab730cbe9c1832c4a36017809f129fea7fb07b4fc.bundle +13453 -0
  2. package/SystemBundles/03e0ad8b8bcf16e659904adab730cbe9c1832c4a36017809f129fea7fb07b4fc.map +4627 -0
  3. package/SystemModules/amzn__react-navigation__stack-8.modules.txt +32 -0
  4. package/SystemModules/amzn__react-navigation__stack-8.private.modules.txt +91 -0
  5. package/SystemModules/keplerscript-system-bundle-config.json +4 -4
  6. package/kepler-compatibility.json +2 -2
  7. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +57 -1
  8. package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  9. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +30 -16
  10. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
  11. package/lib/module/TransitionConfigs/TransitionPresets.js +32 -4
  12. package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
  13. package/lib/module/TransitionConfigs/TransitionSpecs.js +32 -2
  14. package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -1
  15. package/lib/module/index.js +13 -11
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/module/navigators/createStackNavigator.js +46 -48
  18. package/lib/module/navigators/createStackNavigator.js.map +1 -1
  19. package/lib/module/package.json +1 -0
  20. package/lib/module/types.js +2 -0
  21. package/lib/module/types.js.map +1 -1
  22. package/lib/module/utils/CardAnimationContext.js +3 -1
  23. package/lib/module/utils/CardAnimationContext.js.map +1 -1
  24. package/lib/module/utils/GestureHandlerRefContext.js +3 -1
  25. package/lib/module/utils/GestureHandlerRefContext.js.map +1 -1
  26. package/lib/module/utils/ModalPresentationContext.js +3 -2
  27. package/lib/module/utils/ModalPresentationContext.js.map +1 -1
  28. package/lib/module/utils/conditional.js +3 -1
  29. package/lib/module/utils/conditional.js.map +1 -1
  30. package/lib/module/utils/findLastIndex.js +4 -2
  31. package/lib/module/utils/findLastIndex.js.map +1 -1
  32. package/lib/module/utils/gestureActivationCriteria.js +60 -0
  33. package/lib/module/utils/gestureActivationCriteria.js.map +1 -0
  34. package/lib/module/utils/getDistanceForDirection.js +5 -3
  35. package/lib/module/utils/getDistanceForDirection.js.map +1 -1
  36. package/lib/module/utils/getInvertedMultiplier.js +5 -4
  37. package/lib/module/utils/getInvertedMultiplier.js.map +1 -1
  38. package/lib/module/utils/getModalRoutesKeys.js +12 -0
  39. package/lib/module/utils/getModalRoutesKeys.js.map +1 -0
  40. package/lib/module/utils/getShadowStyle.js +24 -0
  41. package/lib/module/utils/getShadowStyle.js.map +1 -0
  42. package/lib/module/utils/{debounce.js → throttle.js} +5 -4
  43. package/lib/module/utils/throttle.js.map +1 -0
  44. package/lib/module/utils/useCardAnimation.js +4 -2
  45. package/lib/module/utils/useCardAnimation.js.map +1 -1
  46. package/lib/module/utils/useGestureHandlerRef.js +5 -3
  47. package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
  48. package/lib/module/utils/useKeyboardManager.js +8 -6
  49. package/lib/module/utils/useKeyboardManager.js.map +1 -1
  50. package/lib/module/views/GestureHandler.android.js +3 -1
  51. package/lib/module/views/GestureHandler.android.js.map +1 -1
  52. package/lib/module/views/GestureHandler.ios.js +3 -1
  53. package/lib/module/views/GestureHandler.ios.js.map +1 -1
  54. package/lib/module/views/GestureHandler.js +6 -1
  55. package/lib/module/views/GestureHandler.js.map +1 -1
  56. package/lib/module/views/GestureHandler.kepler.js +4 -0
  57. package/lib/module/views/GestureHandler.kepler.js.map +1 -0
  58. package/lib/module/views/GestureHandlerNative.js +13 -9
  59. package/lib/module/views/GestureHandlerNative.js.map +1 -1
  60. package/lib/module/views/Header/Header.js +12 -8
  61. package/lib/module/views/Header/Header.js.map +1 -1
  62. package/lib/module/views/Header/HeaderContainer.js +103 -93
  63. package/lib/module/views/Header/HeaderContainer.js.map +1 -1
  64. package/lib/module/views/Header/HeaderSegment.js +43 -31
  65. package/lib/module/views/Header/HeaderSegment.js.map +1 -1
  66. package/lib/module/views/Screens.js +17 -9
  67. package/lib/module/views/Screens.js.map +1 -1
  68. package/lib/module/views/Stack/Card.js +313 -338
  69. package/lib/module/views/Stack/Card.js.map +1 -1
  70. package/lib/module/views/Stack/CardA11yWrapper.js +43 -0
  71. package/lib/module/views/Stack/CardA11yWrapper.js.map +1 -0
  72. package/lib/module/views/Stack/CardContainer.js +116 -90
  73. package/lib/module/views/Stack/CardContainer.js.map +1 -1
  74. package/lib/module/views/Stack/CardContent.js +74 -0
  75. package/lib/module/views/Stack/CardContent.js.map +1 -0
  76. package/lib/module/views/Stack/CardStack.js +246 -181
  77. package/lib/module/views/Stack/CardStack.js.map +1 -1
  78. package/lib/module/views/Stack/StackView.js +80 -64
  79. package/lib/module/views/Stack/StackView.js.map +1 -1
  80. package/lib/typescript/package.json +1 -0
  81. package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts +8 -0
  82. package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +1 -1
  83. package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts +3 -3
  84. package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -1
  85. package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts +8 -0
  86. package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -1
  87. package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts +10 -0
  88. package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -1
  89. package/lib/typescript/src/index.d.ts +8 -8
  90. package/lib/typescript/src/index.d.ts.map +1 -1
  91. package/lib/typescript/src/navigators/createStackNavigator.d.ts +15 -7
  92. package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
  93. package/lib/typescript/src/types.d.ts +84 -24
  94. package/lib/typescript/src/types.d.ts.map +1 -1
  95. package/lib/typescript/src/utils/CardAnimationContext.d.ts +1 -2
  96. package/lib/typescript/src/utils/CardAnimationContext.d.ts.map +1 -1
  97. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts +1 -2
  98. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts.map +1 -1
  99. package/lib/typescript/src/utils/ModalPresentationContext.d.ts +1 -2
  100. package/lib/typescript/src/utils/ModalPresentationContext.d.ts.map +1 -1
  101. package/lib/typescript/src/utils/conditional.d.ts +1 -1
  102. package/lib/typescript/src/utils/conditional.d.ts.map +1 -1
  103. package/lib/typescript/src/utils/findLastIndex.d.ts +1 -1
  104. package/lib/typescript/src/utils/findLastIndex.d.ts.map +1 -1
  105. package/lib/typescript/src/utils/gestureActivationCriteria.d.ts +57 -0
  106. package/lib/typescript/src/utils/gestureActivationCriteria.d.ts.map +1 -0
  107. package/lib/typescript/src/utils/getDistanceForDirection.d.ts +1 -1
  108. package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +1 -1
  109. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts +1 -1
  110. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +1 -1
  111. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts +4 -0
  112. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +1 -0
  113. package/lib/typescript/src/utils/getShadowStyle.d.ts +27 -0
  114. package/lib/typescript/src/utils/getShadowStyle.d.ts.map +1 -0
  115. package/lib/typescript/src/utils/throttle.d.ts +2 -0
  116. package/lib/typescript/src/utils/throttle.d.ts.map +1 -0
  117. package/lib/typescript/src/utils/useCardAnimation.d.ts +1 -1
  118. package/lib/typescript/src/utils/useCardAnimation.d.ts.map +1 -1
  119. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts +1 -1
  120. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts.map +1 -1
  121. package/lib/typescript/src/utils/useKeyboardManager.d.ts +1 -1
  122. package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +1 -1
  123. package/lib/typescript/src/views/GestureHandler.d.ts +3 -2
  124. package/lib/typescript/src/views/GestureHandler.d.ts.map +1 -1
  125. package/lib/typescript/src/views/GestureHandler.kepler.d.ts +2 -0
  126. package/lib/typescript/src/views/GestureHandler.kepler.d.ts.map +1 -0
  127. package/lib/typescript/src/views/GestureHandlerNative.d.ts +4 -5
  128. package/lib/typescript/src/views/GestureHandlerNative.d.ts.map +1 -1
  129. package/lib/typescript/src/views/Header/Header.d.ts +1 -2
  130. package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
  131. package/lib/typescript/src/views/Header/HeaderContainer.d.ts +4 -5
  132. package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
  133. package/lib/typescript/src/views/Header/HeaderSegment.d.ts +2 -2
  134. package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
  135. package/lib/typescript/src/views/Screens.d.ts +7 -5
  136. package/lib/typescript/src/views/Screens.d.ts.map +1 -1
  137. package/lib/typescript/src/views/Stack/Card.d.ts +14 -42
  138. package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
  139. package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts +15 -0
  140. package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts.map +1 -0
  141. package/lib/typescript/src/views/Stack/CardContainer.d.ts +6 -8
  142. package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
  143. package/lib/typescript/src/views/Stack/CardContent.d.ts +13 -0
  144. package/lib/typescript/src/views/Stack/CardContent.d.ts.map +1 -0
  145. package/lib/typescript/src/views/Stack/CardStack.d.ts +8 -7
  146. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
  147. package/lib/typescript/src/views/Stack/StackView.d.ts +10 -81
  148. package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
  149. package/oss-attribution/attribution.txt +76 -0
  150. package/oss-attribution/licenseInfos.json +27 -0
  151. package/package.json +105 -1
  152. package/src/TransitionConfigs/CardStyleInterpolators.tsx +72 -6
  153. package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +43 -25
  154. package/src/TransitionConfigs/TransitionPresets.tsx +35 -5
  155. package/src/TransitionConfigs/TransitionSpecs.tsx +30 -2
  156. package/src/index.tsx +12 -7
  157. package/src/navigators/createStackNavigator.tsx +47 -63
  158. package/src/types.tsx +116 -24
  159. package/src/utils/CardAnimationContext.tsx +3 -3
  160. package/src/utils/GestureHandlerRefContext.tsx +2 -2
  161. package/src/utils/ModalPresentationContext.tsx +1 -3
  162. package/src/utils/conditional.tsx +1 -1
  163. package/src/utils/findLastIndex.tsx +2 -5
  164. package/src/utils/gestureActivationCriteria.tsx +70 -0
  165. package/src/utils/getDistanceForDirection.tsx +5 -4
  166. package/src/utils/getInvertedMultiplier.tsx +5 -6
  167. package/src/utils/getModalRoutesKeys.ts +21 -0
  168. package/src/utils/getShadowStyle.tsx +37 -0
  169. package/src/utils/throttle.tsx +16 -0
  170. package/src/utils/useCardAnimation.tsx +2 -2
  171. package/src/utils/useGestureHandlerRef.tsx +3 -3
  172. package/src/utils/useKeyboardManager.tsx +5 -7
  173. package/src/views/GestureHandler.kepler.tsx +1 -0
  174. package/src/views/GestureHandler.tsx +2 -2
  175. package/src/views/GestureHandlerNative.tsx +5 -5
  176. package/src/views/Header/Header.tsx +8 -7
  177. package/src/views/Header/HeaderContainer.tsx +23 -18
  178. package/src/views/Header/HeaderSegment.tsx +41 -43
  179. package/src/views/Screens.tsx +4 -2
  180. package/src/views/Stack/Card.tsx +480 -462
  181. package/src/views/Stack/CardA11yWrapper.tsx +67 -0
  182. package/src/views/Stack/CardContainer.tsx +127 -108
  183. package/src/views/Stack/CardContent.tsx +92 -0
  184. package/src/views/Stack/CardStack.tsx +375 -243
  185. package/src/views/Stack/StackView.tsx +73 -62
  186. package/SystemBundles/c55a41e7975f46f901d6afe3b0331d043bdbf1f54f96209de0215cf6f6fd5377.bundle +0 -28130
  187. package/SystemBundles/c55a41e7975f46f901d6afe3b0331d043bdbf1f54f96209de0215cf6f6fd5377.map +0 -8489
  188. package/SystemModules/amzn__react-navigation__stack-7.modules.txt +0 -95
  189. package/SystemModules/amzn__react-navigation__stack-7.private.modules.txt +0 -191
  190. package/THIRD_PARTY_NOTICES.txt +0 -24
  191. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js +0 -353
  192. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js.map +0 -1
  193. package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js +0 -259
  194. package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js.map +0 -1
  195. package/lib/commonjs/TransitionConfigs/TransitionPresets.js +0 -134
  196. package/lib/commonjs/TransitionConfigs/TransitionPresets.js.map +0 -1
  197. package/lib/commonjs/TransitionConfigs/TransitionSpecs.js +0 -100
  198. package/lib/commonjs/TransitionConfigs/TransitionSpecs.js.map +0 -1
  199. package/lib/commonjs/index.js +0 -69
  200. package/lib/commonjs/index.js.map +0 -1
  201. package/lib/commonjs/navigators/createStackNavigator.js +0 -82
  202. package/lib/commonjs/navigators/createStackNavigator.js.map +0 -1
  203. package/lib/commonjs/types.js +0 -6
  204. package/lib/commonjs/types.js.map +0 -1
  205. package/lib/commonjs/utils/CardAnimationContext.js +0 -11
  206. package/lib/commonjs/utils/CardAnimationContext.js.map +0 -1
  207. package/lib/commonjs/utils/GestureHandlerRefContext.js +0 -11
  208. package/lib/commonjs/utils/GestureHandlerRefContext.js.map +0 -1
  209. package/lib/commonjs/utils/ModalPresentationContext.js +0 -12
  210. package/lib/commonjs/utils/ModalPresentationContext.js.map +0 -1
  211. package/lib/commonjs/utils/conditional.js +0 -32
  212. package/lib/commonjs/utils/conditional.js.map +0 -1
  213. package/lib/commonjs/utils/debounce.js +0 -19
  214. package/lib/commonjs/utils/debounce.js.map +0 -1
  215. package/lib/commonjs/utils/findLastIndex.js +0 -15
  216. package/lib/commonjs/utils/findLastIndex.js.map +0 -1
  217. package/lib/commonjs/utils/getDistanceForDirection.js +0 -20
  218. package/lib/commonjs/utils/getDistanceForDirection.js.map +0 -1
  219. package/lib/commonjs/utils/getInvertedMultiplier.js +0 -20
  220. package/lib/commonjs/utils/getInvertedMultiplier.js.map +0 -1
  221. package/lib/commonjs/utils/memoize.js +0 -33
  222. package/lib/commonjs/utils/memoize.js.map +0 -1
  223. package/lib/commonjs/utils/useCardAnimation.js +0 -19
  224. package/lib/commonjs/utils/useCardAnimation.js.map +0 -1
  225. package/lib/commonjs/utils/useGestureHandlerRef.js +0 -19
  226. package/lib/commonjs/utils/useGestureHandlerRef.js.map +0 -1
  227. package/lib/commonjs/utils/useKeyboardManager.js +0 -96
  228. package/lib/commonjs/utils/useKeyboardManager.js.map +0 -1
  229. package/lib/commonjs/views/GestureHandler.android.js +0 -17
  230. package/lib/commonjs/views/GestureHandler.android.js.map +0 -1
  231. package/lib/commonjs/views/GestureHandler.ios.js +0 -17
  232. package/lib/commonjs/views/GestureHandler.ios.js.map +0 -1
  233. package/lib/commonjs/views/GestureHandler.js +0 -24
  234. package/lib/commonjs/views/GestureHandler.js.map +0 -1
  235. package/lib/commonjs/views/GestureHandlerNative.js +0 -34
  236. package/lib/commonjs/views/GestureHandlerNative.js.map +0 -1
  237. package/lib/commonjs/views/Header/Header.js +0 -61
  238. package/lib/commonjs/views/Header/Header.js.map +0 -1
  239. package/lib/commonjs/views/Header/HeaderContainer.js +0 -127
  240. package/lib/commonjs/views/Header/HeaderContainer.js.map +0 -1
  241. package/lib/commonjs/views/Header/HeaderSegment.js +0 -139
  242. package/lib/commonjs/views/Header/HeaderSegment.js.map +0 -1
  243. package/lib/commonjs/views/ModalStatusBarManager.js +0 -42
  244. package/lib/commonjs/views/ModalStatusBarManager.js.map +0 -1
  245. package/lib/commonjs/views/Screens.js +0 -44
  246. package/lib/commonjs/views/Screens.js.map +0 -1
  247. package/lib/commonjs/views/Stack/Card.js +0 -469
  248. package/lib/commonjs/views/Stack/Card.js.map +0 -1
  249. package/lib/commonjs/views/Stack/CardContainer.js +0 -259
  250. package/lib/commonjs/views/Stack/CardContainer.js.map +0 -1
  251. package/lib/commonjs/views/Stack/CardSheet.js +0 -54
  252. package/lib/commonjs/views/Stack/CardSheet.js.map +0 -1
  253. package/lib/commonjs/views/Stack/CardStack.js +0 -443
  254. package/lib/commonjs/views/Stack/CardStack.js.map +0 -1
  255. package/lib/commonjs/views/Stack/StackView.js +0 -333
  256. package/lib/commonjs/views/Stack/StackView.js.map +0 -1
  257. package/lib/module/utils/debounce.js.map +0 -1
  258. package/lib/module/utils/memoize.js +0 -27
  259. package/lib/module/utils/memoize.js.map +0 -1
  260. package/lib/module/views/ModalStatusBarManager.js +0 -34
  261. package/lib/module/views/ModalStatusBarManager.js.map +0 -1
  262. package/lib/module/views/Stack/CardSheet.js +0 -46
  263. package/lib/module/views/Stack/CardSheet.js.map +0 -1
  264. package/lib/typescript/src/utils/debounce.d.ts +0 -2
  265. package/lib/typescript/src/utils/debounce.d.ts.map +0 -1
  266. package/lib/typescript/src/utils/memoize.d.ts +0 -2
  267. package/lib/typescript/src/utils/memoize.d.ts.map +0 -1
  268. package/lib/typescript/src/views/ModalStatusBarManager.d.ts +0 -12
  269. package/lib/typescript/src/views/ModalStatusBarManager.d.ts.map +0 -1
  270. package/lib/typescript/src/views/Stack/CardSheet.d.ts +0 -15
  271. package/lib/typescript/src/views/Stack/CardSheet.d.ts.map +0 -1
  272. package/src/utils/debounce.tsx +0 -17
  273. package/src/utils/memoize.tsx +0 -33
  274. package/src/views/ModalStatusBarManager.tsx +0 -50
  275. package/src/views/Stack/CardSheet.tsx +0 -61
@@ -1,80 +1,43 @@
1
1
  import {
2
2
  createNavigatorFactory,
3
- DefaultNavigatorOptions,
4
- EventArg,
5
- ParamListBase,
6
- StackActionHelpers,
3
+ type EventArg,
4
+ type NavigatorTypeBagBase,
5
+ type ParamListBase,
6
+ type StackActionHelpers,
7
7
  StackActions,
8
- StackNavigationState,
8
+ type StackNavigationState,
9
9
  StackRouter,
10
- StackRouterOptions,
10
+ type StackRouterOptions,
11
+ type StaticConfig,
12
+ type TypedNavigator,
13
+ useLocale,
11
14
  useNavigationBuilder,
12
15
  } from '@amazon-devices/react-navigation__native';
13
16
  import * as React from 'react';
14
- import warnOnce from 'warn-once';
15
17
 
16
18
  import type {
17
- StackHeaderMode,
18
- StackNavigationConfig,
19
19
  StackNavigationEventMap,
20
20
  StackNavigationOptions,
21
+ StackNavigationProp,
22
+ StackNavigatorProps,
21
23
  } from '../types';
22
- import StackView from '../views/Stack/StackView';
23
-
24
- type Props = DefaultNavigatorOptions<
25
- ParamListBase,
26
- StackNavigationState<ParamListBase>,
27
- StackNavigationOptions,
28
- StackNavigationEventMap
29
- > &
30
- StackRouterOptions &
31
- StackNavigationConfig;
24
+ import { StackView } from '../views/Stack/StackView';
32
25
 
33
26
  function StackNavigator({
34
27
  id,
35
28
  initialRouteName,
29
+ UNSTABLE_routeNamesChangeBehavior,
36
30
  children,
31
+ layout,
37
32
  screenListeners,
38
33
  screenOptions,
34
+ screenLayout,
35
+ UNSTABLE_router,
39
36
  ...rest
40
- }: Props) {
41
- // @ts-expect-error: mode is deprecated
42
- const mode = rest.mode as 'card' | 'modal' | undefined;
43
-
44
- warnOnce(
45
- mode != null,
46
- `Stack Navigator: 'mode="${mode}"' is deprecated. Use 'presentation: "${mode}"' in 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/stack-navigator#presentation for more details.`
47
- );
48
-
49
- // @ts-expect-error: headerMode='none' is deprecated
50
- const headerMode = rest.headerMode as StackHeaderMode | 'none' | undefined;
51
-
52
- warnOnce(
53
- headerMode === 'none',
54
- `Stack Navigator: 'headerMode="none"' is deprecated. Use 'headerShown: false' in 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/stack-navigator/#headershown for more details.`
55
- );
56
-
57
- warnOnce(
58
- headerMode != null && headerMode !== 'none',
59
- `Stack Navigator: 'headerMode' is moved to 'options'. Moved it to 'screenOptions' to keep current behavior.\n\nSee https://reactnavigation.org/docs/stack-navigator/#headermode for more details.`
60
- );
61
-
62
- // @ts-expect-error: headerMode='none' is deprecated
63
- const keyboardHandlingEnabled = rest.keyboardHandlingEnabled;
64
-
65
- warnOnce(
66
- keyboardHandlingEnabled !== undefined,
67
- `Stack Navigator: 'keyboardHandlingEnabled' is moved to 'options'. Moved it to 'screenOptions' to keep current behavior.\n\nSee https://reactnavigation.org/docs/stack-navigator/#keyboardhandlingenabled for more details.`
68
- );
37
+ }: StackNavigatorProps) {
38
+ const { direction } = useLocale();
69
39
 
70
- const defaultScreenOptions: StackNavigationOptions = {
71
- presentation: mode,
72
- headerShown: headerMode ? headerMode !== 'none' : true,
73
- headerMode: headerMode && headerMode !== 'none' ? headerMode : undefined,
74
- keyboardHandlingEnabled,
75
- };
76
-
77
- const { state, descriptors, navigation, NavigationContent } =
40
+ const { state, describe, descriptors, navigation, NavigationContent } =
78
41
  useNavigationBuilder<
79
42
  StackNavigationState<ParamListBase>,
80
43
  StackRouterOptions,
@@ -84,10 +47,13 @@ function StackNavigator({
84
47
  >(StackRouter, {
85
48
  id,
86
49
  initialRouteName,
50
+ UNSTABLE_routeNamesChangeBehavior,
87
51
  children,
52
+ layout,
88
53
  screenListeners,
89
54
  screenOptions,
90
- defaultScreenOptions,
55
+ screenLayout,
56
+ UNSTABLE_router,
91
57
  });
92
58
 
93
59
  React.useEffect(
@@ -120,7 +86,9 @@ function StackNavigator({
120
86
  <NavigationContent>
121
87
  <StackView
122
88
  {...rest}
89
+ direction={direction}
123
90
  state={state}
91
+ describe={describe}
124
92
  descriptors={descriptors}
125
93
  navigation={navigation}
126
94
  />
@@ -128,9 +96,25 @@ function StackNavigator({
128
96
  );
129
97
  }
130
98
 
131
- export default createNavigatorFactory<
132
- StackNavigationState<ParamListBase>,
133
- StackNavigationOptions,
134
- StackNavigationEventMap,
135
- typeof StackNavigator
136
- >(StackNavigator);
99
+ export function createStackNavigator<
100
+ const ParamList extends ParamListBase,
101
+ const NavigatorID extends string | undefined = string | undefined,
102
+ const TypeBag extends NavigatorTypeBagBase = {
103
+ ParamList: ParamList;
104
+ NavigatorID: NavigatorID;
105
+ State: StackNavigationState<ParamList>;
106
+ ScreenOptions: StackNavigationOptions;
107
+ EventMap: StackNavigationEventMap;
108
+ NavigationList: {
109
+ [RouteName in keyof ParamList]: StackNavigationProp<
110
+ ParamList,
111
+ RouteName,
112
+ NavigatorID
113
+ >;
114
+ };
115
+ Navigator: typeof StackNavigator;
116
+ },
117
+ const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
118
+ >(config?: Config): TypedNavigator<TypeBag, Config> {
119
+ return createNavigatorFactory(StackNavigator)(config);
120
+ }
package/src/types.tsx CHANGED
@@ -1,12 +1,14 @@
1
1
  import type {
2
2
  HeaderBackButton,
3
+ HeaderBackButtonDisplayMode,
3
4
  HeaderBackButtonProps,
4
- HeaderButtonProps,
5
5
  HeaderOptions,
6
6
  HeaderTitleProps,
7
7
  } from '@amazon-devices/react-navigation__elements';
8
8
  import type {
9
+ DefaultNavigatorOptions,
9
10
  Descriptor,
11
+ LocaleDirection,
10
12
  NavigationHelpers,
11
13
  NavigationProp,
12
14
  ParamListBase,
@@ -14,6 +16,8 @@ import type {
14
16
  RouteProp,
15
17
  StackActionHelpers,
16
18
  StackNavigationState,
19
+ StackRouterOptions,
20
+ Theme,
17
21
  } from '@amazon-devices/react-navigation__native';
18
22
  import type * as React from 'react';
19
23
  import type { Animated, StyleProp, TextStyle, ViewStyle } from 'react-native';
@@ -50,7 +54,7 @@ export type StackNavigationHelpers = NavigationHelpers<
50
54
  export type StackNavigationProp<
51
55
  ParamList extends ParamListBase,
52
56
  RouteName extends keyof ParamList = keyof ParamList,
53
- NavigatorID extends string | undefined = undefined
57
+ NavigatorID extends string | undefined = undefined,
54
58
  > = NavigationProp<
55
59
  ParamList,
56
60
  RouteName,
@@ -64,12 +68,20 @@ export type StackNavigationProp<
64
68
  export type StackScreenProps<
65
69
  ParamList extends ParamListBase,
66
70
  RouteName extends keyof ParamList = keyof ParamList,
67
- NavigatorID extends string | undefined = undefined
71
+ NavigatorID extends string | undefined = undefined,
68
72
  > = {
69
73
  navigation: StackNavigationProp<ParamList, RouteName, NavigatorID>;
70
74
  route: RouteProp<ParamList, RouteName>;
71
75
  };
72
76
 
77
+ export type StackOptionsArgs<
78
+ ParamList extends ParamListBase,
79
+ RouteName extends keyof ParamList = keyof ParamList,
80
+ NavigatorID extends string | undefined = undefined,
81
+ > = StackScreenProps<ParamList, RouteName, NavigatorID> & {
82
+ theme: Theme;
83
+ };
84
+
73
85
  export type Layout = { width: number; height: number };
74
86
 
75
87
  export type GestureDirection =
@@ -78,8 +90,20 @@ export type GestureDirection =
78
90
  | 'vertical'
79
91
  | 'vertical-inverted';
80
92
 
93
+ export type StackAnimationName =
94
+ | 'default'
95
+ | 'fade'
96
+ | 'fade_from_bottom'
97
+ | 'fade_from_right'
98
+ | 'none'
99
+ | 'reveal_from_bottom'
100
+ | 'scale_from_center'
101
+ | 'slide_from_bottom'
102
+ | 'slide_from_right'
103
+ | 'slide_from_left';
104
+
81
105
  type SceneOptionsDefaults = TransitionPreset & {
82
- animationEnabled: boolean;
106
+ animation: StackAnimationName;
83
107
  gestureEnabled: boolean;
84
108
  cardOverlayEnabled: boolean;
85
109
  headerMode: StackHeaderMode;
@@ -139,11 +163,11 @@ export type StackHeaderOptions = Omit<
139
163
  /**
140
164
  * Function which returns a React Element to display on the left side of the header.
141
165
  */
142
- headerLeft?: (props: HeaderBackButtonProps) => React.ReactNode;
166
+ headerLeft?: (props: StackHeaderLeftProps) => React.ReactNode;
143
167
  /**
144
168
  * Function which returns a React Element to display on the right side of the header.
145
169
  */
146
- headerRight?: (props: HeaderButtonProps) => React.ReactNode;
170
+ headerRight?: (props: StackHeaderRightProps) => React.ReactNode;
147
171
  /**
148
172
  * Whether back button title font should scale to respect Text Size accessibility settings. Defaults to `false`.
149
173
  */
@@ -159,23 +183,31 @@ export type StackHeaderOptions = Omit<
159
183
  /**
160
184
  * Title string used by the back button on iOS.
161
185
  * Defaults to the previous screen's title, or "Back" if there's not enough space.
162
- * Use `headerBackTitleVisible: false` to hide it.
186
+ * Use `headerBackButtonDisplayMode` to customize the behavior.
163
187
  */
164
188
  headerBackTitle?: string;
165
189
  /**
166
- * Whether the back button title should be visible or not.
190
+ * Title string used by the back button when `headerBackTitle` doesn't fit on the screen.
191
+ * Use `headerBackButtonDisplayMode` to customize the behavior.
167
192
  *
168
- * Defaults to `true` on iOS, `false` on Android.
193
+ * Defaults to "Back".
169
194
  */
170
- headerBackTitleVisible?: boolean;
195
+ headerBackTruncatedTitle?: string;
171
196
  /**
172
- * Style object for the back title.
197
+ * How the back button displays icon and title.
198
+ *
199
+ * Supported values:
200
+ * - "default" - Displays one of the following depending on the available space: previous screen's title, truncated title (e.g. 'Back') or no title (only icon).
201
+ * - "generic" – Displays one of the following depending on the available space: truncated title (e.g. 'Back') or no title (only icon).
202
+ * - "minimal" – Always displays only the icon without a title.
203
+ *
204
+ * Defaults to "default" on iOS, and "minimal" on other platforms.
173
205
  */
174
- headerBackTitleStyle?: StyleProp<TextStyle>;
206
+ headerBackButtonDisplayMode?: HeaderBackButtonDisplayMode;
175
207
  /**
176
- * Title string used by the back button when `headerBackTitle` doesn't fit on the screen. `"Back"` by default.
208
+ * Style object for the back title.
177
209
  */
178
- headerTruncatedBackTitle?: string;
210
+ headerBackTitleStyle?: StyleProp<TextStyle>;
179
211
  /**
180
212
  * Function which returns a React Element to display custom image in header's back button.
181
213
  * It receives the `tintColor` in in the options object as an argument. object.
@@ -196,7 +228,11 @@ export type StackHeaderProps = {
196
228
  /**
197
229
  * Title of the previous screen.
198
230
  */
199
- title: string;
231
+ title: string | undefined;
232
+ /**
233
+ * The `href` to use for the anchor tag on web
234
+ */
235
+ href: string | undefined;
200
236
  };
201
237
  /**
202
238
  * Animated nodes representing the progress of the animation.
@@ -220,6 +256,32 @@ export type StackHeaderProps = {
220
256
  styleInterpolator: StackHeaderStyleInterpolator;
221
257
  };
222
258
 
259
+ export type StackHeaderRightProps = {
260
+ /**
261
+ * Tint color for the header button.
262
+ */
263
+ tintColor?: string;
264
+ /**
265
+ * Color for material ripple (Android >= 5.0 only).
266
+ */
267
+ pressColor?: string;
268
+ /**
269
+ * Opacity when the button is pressed, used when ripple is not supported.
270
+ */
271
+ pressOpacity?: number;
272
+ /**
273
+ * Whether it's possible to navigate back in stack.
274
+ */
275
+ canGoBack?: boolean;
276
+ };
277
+
278
+ export type StackHeaderLeftProps = HeaderBackButtonProps & {
279
+ /**
280
+ * Whether it's possible to navigate back in stack.
281
+ */
282
+ canGoBack?: boolean;
283
+ };
284
+
223
285
  export type StackDescriptor = Descriptor<
224
286
  StackNavigationOptions,
225
287
  StackNavigationProp<ParamListBase>,
@@ -296,11 +358,20 @@ export type StackNavigationOptions = StackHeaderOptions &
296
358
  */
297
359
  presentation?: 'card' | 'modal' | 'transparentModal';
298
360
  /**
299
- * Whether transition animation should be enabled the screen.
300
- * If you set it to `false`, the screen won't animate when pushing or popping.
301
- * Defaults to `true` on Android and iOS, `false` on Web.
361
+ * How the screen should animate when pushed or popped.
362
+ *
363
+ * Supported values:
364
+ * - 'none': don't animate the screen
365
+ * - 'default': use the platform default animation
366
+ * - 'fade': fade screen in or out
367
+ * - 'fade_from_bottom': fade screen in or out from bottom
368
+ * - 'slide_from_bottom': slide in the new screen from bottom
369
+ * - 'slide_from_right': slide in the new screen from right
370
+ * - 'slide_from_left': slide in the new screen from left
371
+ * - 'reveal_from_bottom': reveal screen in from bottom to top
372
+ * - 'scale_from_center': scale screen in from center
302
373
  */
303
- animationEnabled?: boolean;
374
+ animation?: StackAnimationName;
304
375
  /**
305
376
  * The type of animation to use when this screen replaces another screen. Defaults to `push`.
306
377
  * When `pop` is used, the `pop` animation is applied to the screen being replaced.
@@ -341,6 +412,12 @@ export type StackNavigationOptions = StackHeaderOptions &
341
412
  * Only supported on iOS and Android.
342
413
  */
343
414
  freezeOnBlur?: boolean;
415
+ /**
416
+ * Whether the home indicator should prefer to stay hidden on this screen. Defaults to `false`.
417
+ *
418
+ * @platform ios
419
+ */
420
+ autoHideHomeIndicator?: boolean;
344
421
  };
345
422
 
346
423
  export type StackNavigationConfig = {
@@ -404,7 +481,7 @@ export type StackCardInterpolationProps = {
404
481
  /**
405
482
  * Animated node representing multiplier when direction is inverted (-1 - inverted, 1 - normal).
406
483
  */
407
- inverted: Animated.AnimatedInterpolation<-1 | 1>;
484
+ inverted: Animated.AnimatedInterpolation<1 | -1>;
408
485
  /**
409
486
  * Layout measurements for various items we use for animation.
410
487
  */
@@ -429,19 +506,19 @@ export type StackCardInterpolatedStyle = {
429
506
  /**
430
507
  * Interpolated style for the container view wrapping the card.
431
508
  */
432
- containerStyle?: any;
509
+ containerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
433
510
  /**
434
511
  * Interpolated style for the view representing the card.
435
512
  */
436
- cardStyle?: any;
513
+ cardStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
437
514
  /**
438
515
  * Interpolated style for the view representing the semi-transparent overlay below the card.
439
516
  */
440
- overlayStyle?: any;
517
+ overlayStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
441
518
  /**
442
519
  * Interpolated style representing the card shadow.
443
520
  */
444
- shadowStyle?: any;
521
+ shadowStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
445
522
  };
446
523
 
447
524
  export type StackCardStyleInterpolator = (
@@ -468,6 +545,10 @@ export type StackHeaderInterpolationProps = {
468
545
  */
469
546
  progress: Animated.AnimatedInterpolation<number>;
470
547
  };
548
+ /**
549
+ * Writing direction of the layout.
550
+ */
551
+ direction: LocaleDirection;
471
552
  /**
472
553
  * Layout measurements for various items we use for animation.
473
554
  */
@@ -545,3 +626,14 @@ export type TransitionPreset = {
545
626
  */
546
627
  headerStyleInterpolator: StackHeaderStyleInterpolator;
547
628
  };
629
+
630
+ export type StackNavigatorProps = DefaultNavigatorOptions<
631
+ ParamListBase,
632
+ string | undefined,
633
+ StackNavigationState<ParamListBase>,
634
+ StackNavigationOptions,
635
+ StackNavigationEventMap,
636
+ StackNavigationProp<ParamListBase>
637
+ > &
638
+ StackRouterOptions &
639
+ StackNavigationConfig;
@@ -2,6 +2,6 @@ import * as React from 'react';
2
2
 
3
3
  import type { StackCardInterpolationProps } from '../types';
4
4
 
5
- export default React.createContext<StackCardInterpolationProps | undefined>(
6
- undefined
7
- );
5
+ export const CardAnimationContext = React.createContext<
6
+ StackCardInterpolationProps | undefined
7
+ >(undefined);
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
2
 
3
- export default React.createContext<React.Ref<
4
- import('react-native-gesture-handler').PanGestureHandler
3
+ export const GestureHandlerRefContext = React.createContext<React.Ref<
4
+ import('@amazon-devices/react-native-gesture-handler').PanGestureHandler
5
5
  > | null>(null);
@@ -1,5 +1,3 @@
1
1
  import * as React from 'react';
2
2
 
3
- const ModalPresentationContext = React.createContext(false);
4
-
5
- export default ModalPresentationContext;
3
+ export const ModalPresentationContext = React.createContext(false);
@@ -9,7 +9,7 @@ const { add, multiply } = Animated;
9
9
  * @param main Animated Node to use if the condition is `true`
10
10
  * @param fallback Animated Node to use if the condition is `false`
11
11
  */
12
- export default function conditional(
12
+ export function conditional(
13
13
  condition: Animated.AnimatedInterpolation<0 | 1>,
14
14
  main: Animated.AnimatedInterpolation<number>,
15
15
  fallback: Animated.AnimatedInterpolation<number>
@@ -1,8 +1,5 @@
1
- export default function findLastIndex<T>(
2
- array: T[],
3
- callback: (value: T) => boolean
4
- ) {
5
- for (var i = array.length - 1; i >= 0; i--) {
1
+ export function findLastIndex<T>(array: T[], callback: (value: T) => boolean) {
2
+ for (let i = array.length - 1; i >= 0; i--) {
6
3
  if (callback(array[i])) {
7
4
  return i;
8
5
  }
@@ -0,0 +1,70 @@
1
+ import type { LocaleDirection } from '@amazon-devices/react-navigation__native';
2
+
3
+ import type { GestureDirection, Layout } from '../types';
4
+ import { getInvertedMultiplier } from './getInvertedMultiplier';
5
+
6
+ /**
7
+ * The distance of touch start from the edge of the screen where the gesture will be recognized
8
+ */
9
+ const GESTURE_RESPONSE_DISTANCE_HORIZONTAL = 50;
10
+ const GESTURE_RESPONSE_DISTANCE_VERTICAL = 135;
11
+
12
+ export const gestureActivationCriteria = ({
13
+ direction,
14
+ gestureDirection,
15
+ gestureResponseDistance,
16
+ layout,
17
+ }: {
18
+ direction: LocaleDirection;
19
+ gestureDirection: GestureDirection;
20
+ gestureResponseDistance?: number;
21
+ layout: Layout;
22
+ }) => {
23
+ const enableTrackpadTwoFingerGesture = true;
24
+
25
+ const distance =
26
+ gestureResponseDistance !== undefined
27
+ ? gestureResponseDistance
28
+ : gestureDirection === 'vertical' ||
29
+ gestureDirection === 'vertical-inverted'
30
+ ? GESTURE_RESPONSE_DISTANCE_VERTICAL
31
+ : GESTURE_RESPONSE_DISTANCE_HORIZONTAL;
32
+
33
+ if (gestureDirection === 'vertical') {
34
+ return {
35
+ maxDeltaX: 15,
36
+ minOffsetY: 5,
37
+ hitSlop: { bottom: -layout.height + distance },
38
+ enableTrackpadTwoFingerGesture,
39
+ };
40
+ } else if (gestureDirection === 'vertical-inverted') {
41
+ return {
42
+ maxDeltaX: 15,
43
+ minOffsetY: -5,
44
+ hitSlop: { top: -layout.height + distance },
45
+ enableTrackpadTwoFingerGesture,
46
+ };
47
+ } else {
48
+ const hitSlop = -layout.width + distance;
49
+ const invertedMultiplier = getInvertedMultiplier(
50
+ gestureDirection,
51
+ direction === 'rtl'
52
+ );
53
+
54
+ if (invertedMultiplier === 1) {
55
+ return {
56
+ minOffsetX: 5,
57
+ maxDeltaY: 20,
58
+ hitSlop: { right: hitSlop },
59
+ enableTrackpadTwoFingerGesture,
60
+ };
61
+ } else {
62
+ return {
63
+ minOffsetX: -5,
64
+ maxDeltaY: 20,
65
+ hitSlop: { left: hitSlop },
66
+ enableTrackpadTwoFingerGesture,
67
+ };
68
+ }
69
+ }
70
+ };
@@ -1,11 +1,12 @@
1
1
  import type { GestureDirection, Layout } from '../types';
2
- import getInvertedMultiplier from './getInvertedMultiplier';
2
+ import { getInvertedMultiplier } from './getInvertedMultiplier';
3
3
 
4
- export default function getDistanceForDirection(
4
+ export function getDistanceForDirection(
5
5
  layout: Layout,
6
- gestureDirection: GestureDirection
6
+ gestureDirection: GestureDirection,
7
+ isRTL: boolean
7
8
  ): number {
8
- const multiplier = getInvertedMultiplier(gestureDirection);
9
+ const multiplier = getInvertedMultiplier(gestureDirection, isRTL);
9
10
 
10
11
  switch (gestureDirection) {
11
12
  case 'vertical':
@@ -1,9 +1,8 @@
1
- import { I18nManager } from 'react-native';
2
-
3
1
  import type { GestureDirection } from '../types';
4
2
 
5
- export default function getInvertedMultiplier(
6
- gestureDirection: GestureDirection
3
+ export function getInvertedMultiplier(
4
+ gestureDirection: GestureDirection,
5
+ isRTL: boolean
7
6
  ): 1 | -1 {
8
7
  switch (gestureDirection) {
9
8
  case 'vertical':
@@ -11,8 +10,8 @@ export default function getInvertedMultiplier(
11
10
  case 'vertical-inverted':
12
11
  return -1;
13
12
  case 'horizontal':
14
- return I18nManager.getConstants().isRTL ? -1 : 1;
13
+ return isRTL ? -1 : 1;
15
14
  case 'horizontal-inverted':
16
- return I18nManager.getConstants().isRTL ? 1 : -1;
15
+ return isRTL ? 1 : -1;
17
16
  }
18
17
  }
@@ -0,0 +1,21 @@
1
+ import type { Route } from '@amazon-devices/react-navigation__native';
2
+
3
+ import type { StackDescriptorMap } from '../types';
4
+
5
+ export const getModalRouteKeys = (
6
+ routes: Route<string>[],
7
+ descriptors: StackDescriptorMap
8
+ ) =>
9
+ routes.reduce<string[]>((acc, route) => {
10
+ const { presentation } = descriptors[route.key]?.options ?? {};
11
+
12
+ if (
13
+ (acc.length && !presentation) ||
14
+ presentation === 'modal' ||
15
+ presentation === 'transparentModal'
16
+ ) {
17
+ acc.push(route.key);
18
+ }
19
+
20
+ return acc;
21
+ }, []);
@@ -0,0 +1,37 @@
1
+ import Color from 'color';
2
+ import { Platform } from 'react-native';
3
+
4
+ type ShadowConfig = {
5
+ offset: {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ radius: number;
10
+ opacity: number;
11
+ color?: string;
12
+ };
13
+
14
+ export function getShadowStyle({
15
+ offset,
16
+ radius,
17
+ opacity,
18
+ color = '#000',
19
+ }: ShadowConfig) {
20
+ const result = Platform.select({
21
+ web: {
22
+ boxShadow: `${offset.width}px ${offset.height}px ${radius}px ${Color(
23
+ color
24
+ )
25
+ .alpha(opacity)
26
+ .toString()}`,
27
+ },
28
+ default: {
29
+ shadowOffset: offset,
30
+ shadowRadius: radius,
31
+ shadowColor: color,
32
+ shadowOpacity: opacity,
33
+ },
34
+ });
35
+
36
+ return result;
37
+ }
@@ -0,0 +1,16 @@
1
+ export function throttle<T extends (...args: any[]) => void>(
2
+ func: T,
3
+ duration: number
4
+ ): T {
5
+ let timeout: ReturnType<typeof setTimeout> | undefined;
6
+
7
+ return function (this: unknown, ...args) {
8
+ if (timeout == null) {
9
+ func.apply(this, args);
10
+
11
+ timeout = setTimeout(() => {
12
+ timeout = undefined;
13
+ }, duration);
14
+ }
15
+ } as T;
16
+ }
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
 
3
- import CardAnimationContext from './CardAnimationContext';
3
+ import { CardAnimationContext } from './CardAnimationContext';
4
4
 
5
- export default function useCardAnimation() {
5
+ export function useCardAnimation() {
6
6
  const animation = React.useContext(CardAnimationContext);
7
7
 
8
8
  if (animation === undefined) {