@react-navigation/stack 7.0.0-rc.2 → 7.0.0-rc.21

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 (278) hide show
  1. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js +1 -1
  2. package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js +2 -1
  3. package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
  4. package/lib/commonjs/TransitionConfigs/TransitionPresets.js +3 -3
  5. package/lib/commonjs/index.js +11 -11
  6. package/lib/commonjs/navigators/createStackNavigator.js +12 -9
  7. package/lib/commonjs/navigators/createStackNavigator.js.map +1 -1
  8. package/lib/commonjs/package.json +1 -0
  9. package/lib/commonjs/utils/getDistanceForDirection.js +1 -1
  10. package/lib/commonjs/utils/useCardAnimation.js +1 -1
  11. package/lib/commonjs/utils/useGestureHandlerRef.js +1 -1
  12. package/lib/commonjs/views/GestureHandler.android.js +1 -1
  13. package/lib/commonjs/views/GestureHandler.ios.js +1 -1
  14. package/lib/commonjs/views/GestureHandler.js +4 -1
  15. package/lib/commonjs/views/GestureHandler.js.map +1 -1
  16. package/lib/commonjs/views/GestureHandlerNative.js +9 -7
  17. package/lib/commonjs/views/GestureHandlerNative.js.map +1 -1
  18. package/lib/commonjs/views/Header/Header.js +7 -6
  19. package/lib/commonjs/views/Header/Header.js.map +1 -1
  20. package/lib/commonjs/views/Header/HeaderContainer.js +94 -88
  21. package/lib/commonjs/views/Header/HeaderContainer.js.map +1 -1
  22. package/lib/commonjs/views/Header/HeaderSegment.js +16 -12
  23. package/lib/commonjs/views/Header/HeaderSegment.js.map +1 -1
  24. package/lib/commonjs/views/Screens.js +15 -9
  25. package/lib/commonjs/views/Screens.js.map +1 -1
  26. package/lib/commonjs/views/Stack/Card.js +410 -370
  27. package/lib/commonjs/views/Stack/Card.js.map +1 -1
  28. package/lib/commonjs/views/Stack/CardContainer.js +33 -25
  29. package/lib/commonjs/views/Stack/CardContainer.js.map +1 -1
  30. package/lib/commonjs/views/Stack/CardSheet.js +17 -13
  31. package/lib/commonjs/views/Stack/CardSheet.js.map +1 -1
  32. package/lib/commonjs/views/Stack/CardStack.js +355 -330
  33. package/lib/commonjs/views/Stack/CardStack.js.map +1 -1
  34. package/lib/commonjs/views/Stack/StackView.js +323 -287
  35. package/lib/commonjs/views/Stack/StackView.js.map +1 -1
  36. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +3 -1
  37. package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  38. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +4 -1
  39. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
  40. package/lib/module/TransitionConfigs/TransitionPresets.js +5 -3
  41. package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
  42. package/lib/module/TransitionConfigs/TransitionSpecs.js +2 -0
  43. package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -1
  44. package/lib/module/index.js +13 -11
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/navigators/createStackNavigator.js +14 -9
  47. package/lib/module/navigators/createStackNavigator.js.map +1 -1
  48. package/lib/module/package.json +1 -0
  49. package/lib/module/types.js +2 -0
  50. package/lib/module/utils/CardAnimationContext.js +2 -0
  51. package/lib/module/utils/CardAnimationContext.js.map +1 -1
  52. package/lib/module/utils/GestureHandlerRefContext.js +2 -0
  53. package/lib/module/utils/GestureHandlerRefContext.js.map +1 -1
  54. package/lib/module/utils/ModalPresentationContext.js +2 -0
  55. package/lib/module/utils/ModalPresentationContext.js.map +1 -1
  56. package/lib/module/utils/conditional.js +2 -0
  57. package/lib/module/utils/conditional.js.map +1 -1
  58. package/lib/module/utils/findLastIndex.js +2 -0
  59. package/lib/module/utils/findLastIndex.js.map +1 -1
  60. package/lib/module/utils/getDistanceForDirection.js +3 -1
  61. package/lib/module/utils/getDistanceForDirection.js.map +1 -1
  62. package/lib/module/utils/getInvertedMultiplier.js +2 -0
  63. package/lib/module/utils/getInvertedMultiplier.js.map +1 -1
  64. package/lib/module/utils/getModalRoutesKeys.js +2 -0
  65. package/lib/module/utils/getModalRoutesKeys.js.map +1 -1
  66. package/lib/module/utils/memoize.js +2 -0
  67. package/lib/module/utils/memoize.js.map +1 -1
  68. package/lib/module/utils/throttle.js +2 -0
  69. package/lib/module/utils/throttle.js.map +1 -1
  70. package/lib/module/utils/useCardAnimation.js +3 -1
  71. package/lib/module/utils/useCardAnimation.js.map +1 -1
  72. package/lib/module/utils/useGestureHandlerRef.js +3 -1
  73. package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
  74. package/lib/module/utils/useKeyboardManager.js +2 -0
  75. package/lib/module/utils/useKeyboardManager.js.map +1 -1
  76. package/lib/module/views/GestureHandler.android.js +3 -1
  77. package/lib/module/views/GestureHandler.android.js.map +1 -1
  78. package/lib/module/views/GestureHandler.ios.js +3 -1
  79. package/lib/module/views/GestureHandler.ios.js.map +1 -1
  80. package/lib/module/views/GestureHandler.js +6 -1
  81. package/lib/module/views/GestureHandler.js.map +1 -1
  82. package/lib/module/views/GestureHandlerNative.js +11 -7
  83. package/lib/module/views/GestureHandlerNative.js.map +1 -1
  84. package/lib/module/views/Header/Header.js +9 -6
  85. package/lib/module/views/Header/Header.js.map +1 -1
  86. package/lib/module/views/Header/HeaderContainer.js +96 -88
  87. package/lib/module/views/Header/HeaderContainer.js.map +1 -1
  88. package/lib/module/views/Header/HeaderSegment.js +18 -12
  89. package/lib/module/views/Header/HeaderSegment.js.map +1 -1
  90. package/lib/module/views/Screens.js +17 -9
  91. package/lib/module/views/Screens.js.map +1 -1
  92. package/lib/module/views/Stack/Card.js +412 -369
  93. package/lib/module/views/Stack/Card.js.map +1 -1
  94. package/lib/module/views/Stack/CardContainer.js +35 -25
  95. package/lib/module/views/Stack/CardContainer.js.map +1 -1
  96. package/lib/module/views/Stack/CardSheet.js +19 -13
  97. package/lib/module/views/Stack/CardSheet.js.map +1 -1
  98. package/lib/module/views/Stack/CardStack.js +357 -329
  99. package/lib/module/views/Stack/CardStack.js.map +1 -1
  100. package/lib/module/views/Stack/StackView.js +325 -286
  101. package/lib/module/views/Stack/StackView.js.map +1 -1
  102. package/lib/typescript/commonjs/package.json +1 -0
  103. package/lib/typescript/commonjs/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  108. package/lib/typescript/{src → commonjs/src}/navigators/createStackNavigator.d.ts +3 -4
  109. package/lib/typescript/commonjs/src/navigators/createStackNavigator.d.ts.map +1 -0
  110. package/lib/typescript/{src → commonjs/src}/types.d.ts +17 -9
  111. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  112. package/lib/typescript/commonjs/src/utils/CardAnimationContext.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/utils/GestureHandlerRefContext.d.ts.map +1 -0
  114. package/lib/typescript/commonjs/src/utils/ModalPresentationContext.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/src/utils/conditional.d.ts.map +1 -0
  116. package/lib/typescript/commonjs/src/utils/findLastIndex.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/src/utils/getDistanceForDirection.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/src/utils/getInvertedMultiplier.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/src/utils/getModalRoutesKeys.d.ts.map +1 -0
  120. package/lib/typescript/commonjs/src/utils/memoize.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/src/utils/throttle.d.ts.map +1 -0
  122. package/lib/typescript/commonjs/src/utils/useCardAnimation.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/src/utils/useGestureHandlerRef.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/src/utils/useKeyboardManager.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/src/views/GestureHandler.android.d.ts.map +1 -0
  126. package/lib/typescript/commonjs/src/views/GestureHandler.d.ts.map +1 -0
  127. package/lib/typescript/commonjs/src/views/GestureHandler.ios.d.ts.map +1 -0
  128. package/lib/typescript/{src → commonjs/src}/views/GestureHandlerNative.d.ts +1 -2
  129. package/lib/typescript/commonjs/src/views/GestureHandlerNative.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/src/views/Header/Header.d.ts.map +1 -0
  131. package/lib/typescript/{src → commonjs/src}/views/Header/HeaderContainer.d.ts +1 -2
  132. package/lib/typescript/commonjs/src/views/Header/HeaderContainer.d.ts.map +1 -0
  133. package/lib/typescript/{src → commonjs/src}/views/Header/HeaderSegment.d.ts +1 -2
  134. package/lib/typescript/commonjs/src/views/Header/HeaderSegment.d.ts.map +1 -0
  135. package/lib/typescript/{src → commonjs/src}/views/Screens.d.ts +2 -2
  136. package/lib/typescript/commonjs/src/views/Screens.d.ts.map +1 -0
  137. package/lib/typescript/{src → commonjs/src}/views/Stack/Card.d.ts +2 -2
  138. package/lib/typescript/commonjs/src/views/Stack/Card.d.ts.map +1 -0
  139. package/lib/typescript/{src → commonjs/src}/views/Stack/CardContainer.d.ts +1 -1
  140. package/lib/typescript/commonjs/src/views/Stack/CardContainer.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/src/views/Stack/CardSheet.d.ts.map +1 -0
  142. package/lib/typescript/{src → commonjs/src}/views/Stack/CardStack.d.ts +1 -1
  143. package/lib/typescript/commonjs/src/views/Stack/CardStack.d.ts.map +1 -0
  144. package/lib/typescript/{src → commonjs/src}/views/Stack/StackView.d.ts +1 -1
  145. package/lib/typescript/commonjs/src/views/Stack/StackView.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -0
  147. package/lib/typescript/module/package.json +1 -0
  148. package/lib/typescript/module/src/TransitionConfigs/CardStyleInterpolators.d.ts +43 -0
  149. package/lib/typescript/module/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +1 -0
  150. package/lib/typescript/module/src/TransitionConfigs/HeaderStyleInterpolators.d.ts +23 -0
  151. package/lib/typescript/module/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -0
  152. package/lib/typescript/module/src/TransitionConfigs/TransitionPresets.d.ts +50 -0
  153. package/lib/typescript/module/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -0
  154. package/lib/typescript/module/src/TransitionConfigs/TransitionSpecs.d.ts +46 -0
  155. package/lib/typescript/module/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -0
  156. package/lib/typescript/module/src/index.d.ts +29 -0
  157. package/lib/typescript/module/src/index.d.ts.map +1 -0
  158. package/lib/typescript/module/src/navigators/createStackNavigator.d.ts +17 -0
  159. package/lib/typescript/module/src/navigators/createStackNavigator.d.ts.map +1 -0
  160. package/lib/typescript/module/src/types.d.ts +544 -0
  161. package/lib/typescript/module/src/types.d.ts.map +1 -0
  162. package/lib/typescript/module/src/utils/CardAnimationContext.d.ts +4 -0
  163. package/lib/typescript/module/src/utils/CardAnimationContext.d.ts.map +1 -0
  164. package/lib/typescript/module/src/utils/GestureHandlerRefContext.d.ts +3 -0
  165. package/lib/typescript/module/src/utils/GestureHandlerRefContext.d.ts.map +1 -0
  166. package/lib/typescript/module/src/utils/ModalPresentationContext.d.ts +3 -0
  167. package/lib/typescript/module/src/utils/ModalPresentationContext.d.ts.map +1 -0
  168. package/lib/typescript/module/src/utils/conditional.d.ts +10 -0
  169. package/lib/typescript/module/src/utils/conditional.d.ts.map +1 -0
  170. package/lib/typescript/module/src/utils/findLastIndex.d.ts +2 -0
  171. package/lib/typescript/module/src/utils/findLastIndex.d.ts.map +1 -0
  172. package/lib/typescript/module/src/utils/getDistanceForDirection.d.ts +3 -0
  173. package/lib/typescript/module/src/utils/getDistanceForDirection.d.ts.map +1 -0
  174. package/lib/typescript/module/src/utils/getInvertedMultiplier.d.ts +3 -0
  175. package/lib/typescript/module/src/utils/getInvertedMultiplier.d.ts.map +1 -0
  176. package/lib/typescript/module/src/utils/getModalRoutesKeys.d.ts +4 -0
  177. package/lib/typescript/module/src/utils/getModalRoutesKeys.d.ts.map +1 -0
  178. package/lib/typescript/module/src/utils/memoize.d.ts +2 -0
  179. package/lib/typescript/module/src/utils/memoize.d.ts.map +1 -0
  180. package/lib/typescript/module/src/utils/throttle.d.ts +2 -0
  181. package/lib/typescript/module/src/utils/throttle.d.ts.map +1 -0
  182. package/lib/typescript/module/src/utils/useCardAnimation.d.ts +2 -0
  183. package/lib/typescript/module/src/utils/useCardAnimation.d.ts.map +1 -0
  184. package/lib/typescript/module/src/utils/useGestureHandlerRef.d.ts +3 -0
  185. package/lib/typescript/module/src/utils/useGestureHandlerRef.d.ts.map +1 -0
  186. package/lib/typescript/module/src/utils/useKeyboardManager.d.ts +6 -0
  187. package/lib/typescript/module/src/utils/useKeyboardManager.d.ts.map +1 -0
  188. package/lib/typescript/module/src/views/GestureHandler.android.d.ts +2 -0
  189. package/lib/typescript/module/src/views/GestureHandler.android.d.ts.map +1 -0
  190. package/lib/typescript/module/src/views/GestureHandler.d.ts +15 -0
  191. package/lib/typescript/module/src/views/GestureHandler.d.ts.map +1 -0
  192. package/lib/typescript/module/src/views/GestureHandler.ios.d.ts +2 -0
  193. package/lib/typescript/module/src/views/GestureHandler.ios.d.ts.map +1 -0
  194. package/lib/typescript/module/src/views/GestureHandlerNative.d.ts +5 -0
  195. package/lib/typescript/module/src/views/GestureHandlerNative.d.ts.map +1 -0
  196. package/lib/typescript/module/src/views/Header/Header.d.ts +4 -0
  197. package/lib/typescript/module/src/views/Header/Header.d.ts.map +1 -0
  198. package/lib/typescript/module/src/views/Header/HeaderContainer.d.ts +19 -0
  199. package/lib/typescript/module/src/views/Header/HeaderContainer.d.ts.map +1 -0
  200. package/lib/typescript/module/src/views/Header/HeaderSegment.d.ts +14 -0
  201. package/lib/typescript/module/src/views/Header/HeaderSegment.d.ts.map +1 -0
  202. package/lib/typescript/module/src/views/Screens.d.ts +14 -0
  203. package/lib/typescript/module/src/views/Screens.d.ts.map +1 -0
  204. package/lib/typescript/module/src/views/Stack/Card.d.ts +77 -0
  205. package/lib/typescript/module/src/views/Stack/Card.d.ts.map +1 -0
  206. package/lib/typescript/module/src/views/Stack/CardContainer.d.ts +60 -0
  207. package/lib/typescript/module/src/views/Stack/CardContainer.d.ts.map +1 -0
  208. package/lib/typescript/module/src/views/Stack/CardSheet.d.ts +14 -0
  209. package/lib/typescript/module/src/views/Stack/CardSheet.d.ts.map +1 -0
  210. package/lib/typescript/module/src/views/Stack/CardStack.d.ts +66 -0
  211. package/lib/typescript/module/src/views/Stack/CardStack.d.ts.map +1 -0
  212. package/lib/typescript/module/src/views/Stack/StackView.d.ts +51 -0
  213. package/lib/typescript/module/src/views/Stack/StackView.d.ts.map +1 -0
  214. package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -0
  215. package/package.json +39 -16
  216. package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +4 -1
  217. package/src/navigators/createStackNavigator.tsx +4 -6
  218. package/src/types.tsx +17 -8
  219. package/src/views/Header/HeaderSegment.tsx +4 -4
  220. package/src/views/Stack/CardContainer.tsx +5 -1
  221. package/src/views/Stack/CardSheet.tsx +19 -13
  222. package/src/views/Stack/CardStack.tsx +0 -3
  223. package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +0 -1
  224. package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +0 -1
  225. package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts.map +0 -1
  226. package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts.map +0 -1
  227. package/lib/typescript/src/index.d.ts.map +0 -1
  228. package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +0 -1
  229. package/lib/typescript/src/types.d.ts.map +0 -1
  230. package/lib/typescript/src/utils/CardAnimationContext.d.ts.map +0 -1
  231. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts.map +0 -1
  232. package/lib/typescript/src/utils/ModalPresentationContext.d.ts.map +0 -1
  233. package/lib/typescript/src/utils/conditional.d.ts.map +0 -1
  234. package/lib/typescript/src/utils/findLastIndex.d.ts.map +0 -1
  235. package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +0 -1
  236. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +0 -1
  237. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +0 -1
  238. package/lib/typescript/src/utils/memoize.d.ts.map +0 -1
  239. package/lib/typescript/src/utils/throttle.d.ts.map +0 -1
  240. package/lib/typescript/src/utils/useCardAnimation.d.ts.map +0 -1
  241. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts.map +0 -1
  242. package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +0 -1
  243. package/lib/typescript/src/views/GestureHandler.android.d.ts.map +0 -1
  244. package/lib/typescript/src/views/GestureHandler.d.ts.map +0 -1
  245. package/lib/typescript/src/views/GestureHandler.ios.d.ts.map +0 -1
  246. package/lib/typescript/src/views/GestureHandlerNative.d.ts.map +0 -1
  247. package/lib/typescript/src/views/Header/Header.d.ts.map +0 -1
  248. package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +0 -1
  249. package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +0 -1
  250. package/lib/typescript/src/views/Screens.d.ts.map +0 -1
  251. package/lib/typescript/src/views/Stack/Card.d.ts.map +0 -1
  252. package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +0 -1
  253. package/lib/typescript/src/views/Stack/CardSheet.d.ts.map +0 -1
  254. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +0 -1
  255. package/lib/typescript/src/views/Stack/StackView.d.ts.map +0 -1
  256. /package/lib/typescript/{src → commonjs/src}/TransitionConfigs/CardStyleInterpolators.d.ts +0 -0
  257. /package/lib/typescript/{src → commonjs/src}/TransitionConfigs/HeaderStyleInterpolators.d.ts +0 -0
  258. /package/lib/typescript/{src → commonjs/src}/TransitionConfigs/TransitionPresets.d.ts +0 -0
  259. /package/lib/typescript/{src → commonjs/src}/TransitionConfigs/TransitionSpecs.d.ts +0 -0
  260. /package/lib/typescript/{src → commonjs/src}/index.d.ts +0 -0
  261. /package/lib/typescript/{src → commonjs/src}/utils/CardAnimationContext.d.ts +0 -0
  262. /package/lib/typescript/{src → commonjs/src}/utils/GestureHandlerRefContext.d.ts +0 -0
  263. /package/lib/typescript/{src → commonjs/src}/utils/ModalPresentationContext.d.ts +0 -0
  264. /package/lib/typescript/{src → commonjs/src}/utils/conditional.d.ts +0 -0
  265. /package/lib/typescript/{src → commonjs/src}/utils/findLastIndex.d.ts +0 -0
  266. /package/lib/typescript/{src → commonjs/src}/utils/getDistanceForDirection.d.ts +0 -0
  267. /package/lib/typescript/{src → commonjs/src}/utils/getInvertedMultiplier.d.ts +0 -0
  268. /package/lib/typescript/{src → commonjs/src}/utils/getModalRoutesKeys.d.ts +0 -0
  269. /package/lib/typescript/{src → commonjs/src}/utils/memoize.d.ts +0 -0
  270. /package/lib/typescript/{src → commonjs/src}/utils/throttle.d.ts +0 -0
  271. /package/lib/typescript/{src → commonjs/src}/utils/useCardAnimation.d.ts +0 -0
  272. /package/lib/typescript/{src → commonjs/src}/utils/useGestureHandlerRef.d.ts +0 -0
  273. /package/lib/typescript/{src → commonjs/src}/utils/useKeyboardManager.d.ts +0 -0
  274. /package/lib/typescript/{src → commonjs/src}/views/GestureHandler.android.d.ts +0 -0
  275. /package/lib/typescript/{src → commonjs/src}/views/GestureHandler.d.ts +0 -0
  276. /package/lib/typescript/{src → commonjs/src}/views/GestureHandler.ios.d.ts +0 -0
  277. /package/lib/typescript/{src → commonjs/src}/views/Header/Header.d.ts +0 -0
  278. /package/lib/typescript/{src → commonjs/src}/views/Stack/CardSheet.d.ts +0 -0
@@ -1,13 +1,28 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
1
+ "use strict";
2
+
3
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
4
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
5
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
6
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
8
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
9
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
10
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
11
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
12
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
13
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
15
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2
16
  import { HeaderShownContext, SafeAreaProviderCompat } from '@react-navigation/elements';
3
17
  import { CommonActions, StackActions } from '@react-navigation/native';
4
18
  import * as React from 'react';
5
19
  import { StyleSheet, View } from 'react-native';
6
20
  import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
7
- import { ModalPresentationContext } from '../../utils/ModalPresentationContext';
21
+ import { ModalPresentationContext } from "../../utils/ModalPresentationContext.js";
8
22
  import { GestureHandlerRootView } from '../GestureHandler';
9
- import { HeaderContainer } from '../Header/HeaderContainer';
10
- import { CardStack } from './CardStack';
23
+ import { HeaderContainer } from "../Header/HeaderContainer.js";
24
+ import { CardStack } from "./CardStack.js";
25
+ import { jsx as _jsx } from "react/jsx-runtime";
11
26
  const GestureHandlerWrapper = GestureHandlerRootView ?? View;
12
27
 
13
28
  /**
@@ -15,310 +30,334 @@ const GestureHandlerWrapper = GestureHandlerRootView ?? View;
15
30
  * We need to make sure that both values and order match.
16
31
  */
17
32
  const isArrayEqual = (a, b) => a.length === b.length && a.every((it, index) => it === b[index]);
18
- export class StackView extends React.Component {
19
- static getDerivedStateFromProps(props, state) {
20
- // If there was no change in routes, we don't need to compute anything
21
- if ((props.state.routes === state.previousRoutes || isArrayEqual(props.state.routes.map(r => r.key), state.previousRoutes.map(r => r.key))) && state.routes.length) {
22
- let routes = state.routes;
23
- let previousRoutes = state.previousRoutes;
24
- let descriptors = props.descriptors;
25
- let previousDescriptors = state.previousDescriptors;
26
- if (props.descriptors !== state.previousDescriptors) {
27
- descriptors = state.routes.reduce((acc, route) => {
28
- acc[route.key] = props.descriptors[route.key] || state.descriptors[route.key];
29
- return acc;
30
- }, {});
31
- previousDescriptors = props.descriptors;
33
+ export let StackView = /*#__PURE__*/function (_React$Component) {
34
+ function StackView(...args) {
35
+ var _this;
36
+ _classCallCheck(this, StackView);
37
+ _this = _callSuper(this, StackView, [...args]);
38
+ _defineProperty(_this, "state", {
39
+ routes: [],
40
+ previousRoutes: [],
41
+ previousDescriptors: {},
42
+ openingRouteKeys: [],
43
+ closingRouteKeys: [],
44
+ replacingRouteKeys: [],
45
+ descriptors: {}
46
+ });
47
+ _defineProperty(_this, "getPreviousRoute", ({
48
+ route
49
+ }) => {
50
+ const {
51
+ closingRouteKeys,
52
+ replacingRouteKeys
53
+ } = _this.state;
54
+ const routes = _this.state.routes.filter(r => r.key === route.key || !closingRouteKeys.includes(r.key) && !replacingRouteKeys.includes(r.key));
55
+ const index = routes.findIndex(r => r.key === route.key);
56
+ return routes[index - 1];
57
+ });
58
+ _defineProperty(_this, "renderHeader", props => {
59
+ return /*#__PURE__*/_jsx(HeaderContainer, {
60
+ ...props
61
+ });
62
+ });
63
+ _defineProperty(_this, "handleOpenRoute", ({
64
+ route
65
+ }) => {
66
+ const {
67
+ state,
68
+ navigation
69
+ } = _this.props;
70
+ const {
71
+ closingRouteKeys,
72
+ replacingRouteKeys
73
+ } = _this.state;
74
+ if (closingRouteKeys.some(key => key === route.key) && replacingRouteKeys.every(key => key !== route.key) && state.routeNames.includes(route.name) && !state.routes.some(r => r.key === route.key)) {
75
+ // If route isn't present in current state, but was closing, assume that a close animation was cancelled
76
+ // So we need to add this route back to the state
77
+ navigation.dispatch(state => {
78
+ const routes = [...state.routes.filter(r => r.key !== route.key), route];
79
+ return CommonActions.reset({
80
+ ...state,
81
+ routes,
82
+ index: routes.length - 1
83
+ });
84
+ });
85
+ } else {
86
+ _this.setState(state => ({
87
+ routes: state.replacingRouteKeys.length ? state.routes.filter(r => !state.replacingRouteKeys.includes(r.key)) : state.routes,
88
+ openingRouteKeys: state.openingRouteKeys.filter(key => key !== route.key),
89
+ closingRouteKeys: state.closingRouteKeys.filter(key => key !== route.key),
90
+ replacingRouteKeys: []
91
+ }));
32
92
  }
33
- if (props.state.routes !== state.previousRoutes) {
34
- // if any route objects have changed, we should update them
35
- const map = props.state.routes.reduce((acc, route) => {
36
- acc[route.key] = route;
37
- return acc;
38
- }, {});
39
- routes = state.routes.map(route => map[route.key] || route);
40
- previousRoutes = props.state.routes;
93
+ });
94
+ _defineProperty(_this, "handleCloseRoute", ({
95
+ route
96
+ }) => {
97
+ const {
98
+ state,
99
+ navigation
100
+ } = _this.props;
101
+ if (state.routes.some(r => r.key === route.key)) {
102
+ // If a route exists in state, trigger a pop
103
+ // This will happen in when the route was closed from the card component
104
+ // e.g. When the close animation triggered from a gesture ends
105
+ navigation.dispatch({
106
+ ...StackActions.pop(),
107
+ source: route.key,
108
+ target: state.key
109
+ });
110
+ } else {
111
+ // We need to clean up any state tracking the route and pop it immediately
112
+ _this.setState(state => ({
113
+ routes: state.routes.filter(r => r.key !== route.key),
114
+ openingRouteKeys: state.openingRouteKeys.filter(key => key !== route.key),
115
+ closingRouteKeys: state.closingRouteKeys.filter(key => key !== route.key)
116
+ }));
41
117
  }
42
- return {
118
+ });
119
+ _defineProperty(_this, "handleTransitionStart", ({
120
+ route
121
+ }, closing) => _this.props.navigation.emit({
122
+ type: 'transitionStart',
123
+ data: {
124
+ closing
125
+ },
126
+ target: route.key
127
+ }));
128
+ _defineProperty(_this, "handleTransitionEnd", ({
129
+ route
130
+ }, closing) => _this.props.navigation.emit({
131
+ type: 'transitionEnd',
132
+ data: {
133
+ closing
134
+ },
135
+ target: route.key
136
+ }));
137
+ _defineProperty(_this, "handleGestureStart", ({
138
+ route
139
+ }) => {
140
+ _this.props.navigation.emit({
141
+ type: 'gestureStart',
142
+ target: route.key
143
+ });
144
+ });
145
+ _defineProperty(_this, "handleGestureEnd", ({
146
+ route
147
+ }) => {
148
+ _this.props.navigation.emit({
149
+ type: 'gestureEnd',
150
+ target: route.key
151
+ });
152
+ });
153
+ _defineProperty(_this, "handleGestureCancel", ({
154
+ route
155
+ }) => {
156
+ _this.props.navigation.emit({
157
+ type: 'gestureCancel',
158
+ target: route.key
159
+ });
160
+ });
161
+ return _this;
162
+ }
163
+ _inherits(StackView, _React$Component);
164
+ return _createClass(StackView, [{
165
+ key: "render",
166
+ value: function render() {
167
+ const {
168
+ state,
169
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
170
+ descriptors: _,
171
+ ...rest
172
+ } = this.props;
173
+ const {
43
174
  routes,
44
- previousRoutes,
45
175
  descriptors,
46
- previousDescriptors
47
- };
176
+ openingRouteKeys,
177
+ closingRouteKeys
178
+ } = this.state;
179
+ const preloadedDescriptors = state.preloadedRoutes.reduce((acc, route) => {
180
+ acc[route.key] = acc[route.key] || this.props.describe(route, true);
181
+ return acc;
182
+ }, {});
183
+ return /*#__PURE__*/_jsx(GestureHandlerWrapper, {
184
+ style: styles.container,
185
+ children: /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
186
+ children: /*#__PURE__*/_jsx(SafeAreaInsetsContext.Consumer, {
187
+ children: insets => /*#__PURE__*/_jsx(ModalPresentationContext.Consumer, {
188
+ children: isParentModal => /*#__PURE__*/_jsx(HeaderShownContext.Consumer, {
189
+ children: isParentHeaderShown => /*#__PURE__*/_jsx(CardStack, {
190
+ insets: insets,
191
+ isParentHeaderShown: isParentHeaderShown,
192
+ isParentModal: isParentModal,
193
+ getPreviousRoute: this.getPreviousRoute,
194
+ routes: routes,
195
+ openingRouteKeys: openingRouteKeys,
196
+ closingRouteKeys: closingRouteKeys,
197
+ onOpenRoute: this.handleOpenRoute,
198
+ onCloseRoute: this.handleCloseRoute,
199
+ onTransitionStart: this.handleTransitionStart,
200
+ onTransitionEnd: this.handleTransitionEnd,
201
+ renderHeader: this.renderHeader,
202
+ state: state,
203
+ descriptors: descriptors,
204
+ onGestureStart: this.handleGestureStart,
205
+ onGestureEnd: this.handleGestureEnd,
206
+ onGestureCancel: this.handleGestureCancel,
207
+ preloadedDescriptors: preloadedDescriptors,
208
+ ...rest
209
+ })
210
+ })
211
+ })
212
+ })
213
+ })
214
+ });
48
215
  }
216
+ }], [{
217
+ key: "getDerivedStateFromProps",
218
+ value: function getDerivedStateFromProps(props, state) {
219
+ // If there was no change in routes, we don't need to compute anything
220
+ if ((props.state.routes === state.previousRoutes || isArrayEqual(props.state.routes.map(r => r.key), state.previousRoutes.map(r => r.key))) && state.routes.length) {
221
+ let routes = state.routes;
222
+ let previousRoutes = state.previousRoutes;
223
+ let descriptors = props.descriptors;
224
+ let previousDescriptors = state.previousDescriptors;
225
+ if (props.descriptors !== state.previousDescriptors) {
226
+ descriptors = state.routes.reduce((acc, route) => {
227
+ acc[route.key] = props.descriptors[route.key] || state.descriptors[route.key];
228
+ return acc;
229
+ }, {});
230
+ previousDescriptors = props.descriptors;
231
+ }
232
+ if (props.state.routes !== state.previousRoutes) {
233
+ // if any route objects have changed, we should update them
234
+ const map = props.state.routes.reduce((acc, route) => {
235
+ acc[route.key] = route;
236
+ return acc;
237
+ }, {});
238
+ routes = state.routes.map(route => map[route.key] || route);
239
+ previousRoutes = props.state.routes;
240
+ }
241
+ return {
242
+ routes,
243
+ previousRoutes,
244
+ descriptors,
245
+ previousDescriptors
246
+ };
247
+ }
49
248
 
50
- // Here we determine which routes were added or removed to animate them
51
- // We keep a copy of the route being removed in local state to be able to animate it
249
+ // Here we determine which routes were added or removed to animate them
250
+ // We keep a copy of the route being removed in local state to be able to animate it
52
251
 
53
- let routes = props.state.index < props.state.routes.length - 1 ?
54
- // Remove any extra routes from the state
55
- // The last visible route should be the focused route, i.e. at current index
56
- props.state.routes.slice(0, props.state.index + 1) : props.state.routes;
252
+ let routes = props.state.index < props.state.routes.length - 1 ?
253
+ // Remove any extra routes from the state
254
+ // The last visible route should be the focused route, i.e. at current index
255
+ props.state.routes.slice(0, props.state.index + 1) : props.state.routes;
57
256
 
58
- // Now we need to determine which routes were added and removed
59
- const {
60
- previousRoutes
61
- } = state;
62
- let {
63
- openingRouteKeys,
64
- closingRouteKeys,
65
- replacingRouteKeys
66
- } = state;
67
- const previousFocusedRoute = previousRoutes[previousRoutes.length - 1];
68
- const nextFocusedRoute = routes[routes.length - 1];
69
- const isAnimationEnabled = key => {
70
- const descriptor = props.descriptors[key] || state.descriptors[key];
71
- return descriptor ? descriptor.options.animation !== 'none' : true;
72
- };
73
- const getAnimationTypeForReplace = key => {
74
- const descriptor = props.descriptors[key] || state.descriptors[key];
75
- return descriptor.options.animationTypeForReplace ?? 'push';
76
- };
77
- if (previousFocusedRoute && previousFocusedRoute.key !== nextFocusedRoute.key) {
78
- // We only need to animate routes if the focused route changed
79
- // Animating previous routes won't be visible coz the focused route is on top of everything
257
+ // Now we need to determine which routes were added and removed
258
+ const {
259
+ previousRoutes
260
+ } = state;
261
+ let {
262
+ openingRouteKeys,
263
+ closingRouteKeys,
264
+ replacingRouteKeys
265
+ } = state;
266
+ const previousFocusedRoute = previousRoutes[previousRoutes.length - 1];
267
+ const nextFocusedRoute = routes[routes.length - 1];
268
+ const isAnimationEnabled = key => {
269
+ const descriptor = props.descriptors[key] || state.descriptors[key];
270
+ return descriptor ? descriptor.options.animation !== 'none' : true;
271
+ };
272
+ const getAnimationTypeForReplace = key => {
273
+ const descriptor = props.descriptors[key] || state.descriptors[key];
274
+ return descriptor.options.animationTypeForReplace ?? 'push';
275
+ };
276
+ if (previousFocusedRoute && previousFocusedRoute.key !== nextFocusedRoute.key) {
277
+ // We only need to animate routes if the focused route changed
278
+ // Animating previous routes won't be visible coz the focused route is on top of everything
80
279
 
81
- if (!previousRoutes.some(r => r.key === nextFocusedRoute.key)) {
82
- // A new route has come to the focus, we treat this as a push
83
- // A replace can also trigger this, the animation should look like push
280
+ if (!previousRoutes.some(r => r.key === nextFocusedRoute.key)) {
281
+ // A new route has come to the focus, we treat this as a push
282
+ // A replace can also trigger this, the animation should look like push
84
283
 
85
- if (isAnimationEnabled(nextFocusedRoute.key) && !openingRouteKeys.includes(nextFocusedRoute.key)) {
86
- // In this case, we need to animate pushing the focused route
87
- // We don't care about animating any other added routes because they won't be visible
88
- openingRouteKeys = [...openingRouteKeys, nextFocusedRoute.key];
89
- closingRouteKeys = closingRouteKeys.filter(key => key !== nextFocusedRoute.key);
90
- replacingRouteKeys = replacingRouteKeys.filter(key => key !== nextFocusedRoute.key);
91
- if (!routes.some(r => r.key === previousFocusedRoute.key)) {
92
- // The previous focused route isn't present in state, we treat this as a replace
284
+ if (isAnimationEnabled(nextFocusedRoute.key) && !openingRouteKeys.includes(nextFocusedRoute.key)) {
285
+ // In this case, we need to animate pushing the focused route
286
+ // We don't care about animating any other added routes because they won't be visible
287
+ openingRouteKeys = [...openingRouteKeys, nextFocusedRoute.key];
288
+ closingRouteKeys = closingRouteKeys.filter(key => key !== nextFocusedRoute.key);
289
+ replacingRouteKeys = replacingRouteKeys.filter(key => key !== nextFocusedRoute.key);
290
+ if (!routes.some(r => r.key === previousFocusedRoute.key)) {
291
+ // The previous focused route isn't present in state, we treat this as a replace
93
292
 
94
- openingRouteKeys = openingRouteKeys.filter(key => key !== previousFocusedRoute.key);
95
- if (getAnimationTypeForReplace(nextFocusedRoute.key) === 'pop') {
96
- closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];
293
+ openingRouteKeys = openingRouteKeys.filter(key => key !== previousFocusedRoute.key);
294
+ if (getAnimationTypeForReplace(nextFocusedRoute.key) === 'pop') {
295
+ closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];
97
296
 
98
- // By default, new routes have a push animation, so we add it to `openingRouteKeys` before
99
- // But since user configured it to animate the old screen like a pop, we need to add this without animation
100
- // So remove it from `openingRouteKeys` which will remove the animation
101
- openingRouteKeys = openingRouteKeys.filter(key => key !== nextFocusedRoute.key);
297
+ // By default, new routes have a push animation, so we add it to `openingRouteKeys` before
298
+ // But since user configured it to animate the old screen like a pop, we need to add this without animation
299
+ // So remove it from `openingRouteKeys` which will remove the animation
300
+ openingRouteKeys = openingRouteKeys.filter(key => key !== nextFocusedRoute.key);
102
301
 
103
- // Keep the route being removed at the end to animate it out
104
- routes = [...routes, previousFocusedRoute];
105
- } else {
106
- replacingRouteKeys = [...replacingRouteKeys, previousFocusedRoute.key];
107
- closingRouteKeys = closingRouteKeys.filter(key => key !== previousFocusedRoute.key);
302
+ // Keep the route being removed at the end to animate it out
303
+ routes = [...routes, previousFocusedRoute];
304
+ } else {
305
+ replacingRouteKeys = [...replacingRouteKeys, previousFocusedRoute.key];
306
+ closingRouteKeys = closingRouteKeys.filter(key => key !== previousFocusedRoute.key);
108
307
 
109
- // Keep the old route in the state because it's visible under the new route, and removing it will feel abrupt
110
- // We need to insert it just before the focused one (the route being pushed)
111
- // After the push animation is completed, routes being replaced will be removed completely
112
- routes = routes.slice();
113
- routes.splice(routes.length - 1, 0, previousFocusedRoute);
308
+ // Keep the old route in the state because it's visible under the new route, and removing it will feel abrupt
309
+ // We need to insert it just before the focused one (the route being pushed)
310
+ // After the push animation is completed, routes being replaced will be removed completely
311
+ routes = routes.slice();
312
+ routes.splice(routes.length - 1, 0, previousFocusedRoute);
313
+ }
114
314
  }
115
315
  }
116
- }
117
- } else if (!routes.some(r => r.key === previousFocusedRoute.key)) {
118
- // The previously focused route was removed, we treat this as a pop
316
+ } else if (!routes.some(r => r.key === previousFocusedRoute.key)) {
317
+ // The previously focused route was removed, we treat this as a pop
119
318
 
120
- if (isAnimationEnabled(previousFocusedRoute.key) && !closingRouteKeys.includes(previousFocusedRoute.key)) {
121
- closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];
319
+ if (isAnimationEnabled(previousFocusedRoute.key) && !closingRouteKeys.includes(previousFocusedRoute.key)) {
320
+ closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];
122
321
 
123
- // Sometimes a route can be closed before the opening animation finishes
124
- // So we also need to remove it from the opening list
125
- openingRouteKeys = openingRouteKeys.filter(key => key !== previousFocusedRoute.key);
126
- replacingRouteKeys = replacingRouteKeys.filter(key => key !== previousFocusedRoute.key);
322
+ // Sometimes a route can be closed before the opening animation finishes
323
+ // So we also need to remove it from the opening list
324
+ openingRouteKeys = openingRouteKeys.filter(key => key !== previousFocusedRoute.key);
325
+ replacingRouteKeys = replacingRouteKeys.filter(key => key !== previousFocusedRoute.key);
127
326
 
128
- // Keep a copy of route being removed in the state to be able to animate it
129
- routes = [...routes, previousFocusedRoute];
327
+ // Keep a copy of route being removed in the state to be able to animate it
328
+ routes = [...routes, previousFocusedRoute];
329
+ }
330
+ } else {
331
+ // Looks like some routes were re-arranged and no focused routes were added/removed
332
+ // i.e. the currently focused route already existed and the previously focused route still exists
333
+ // We don't know how to animate this
130
334
  }
131
- } else {
132
- // Looks like some routes were re-arranged and no focused routes were added/removed
133
- // i.e. the currently focused route already existed and the previously focused route still exists
134
- // We don't know how to animate this
335
+ } else if (replacingRouteKeys.length || closingRouteKeys.length) {
336
+ // Keep the routes we are closing or replacing if animation is enabled for them
337
+ routes = routes.slice();
338
+ routes.splice(routes.length - 1, 0, ...state.routes.filter(({
339
+ key
340
+ }) => isAnimationEnabled(key) ? replacingRouteKeys.includes(key) || closingRouteKeys.includes(key) : false));
135
341
  }
136
- } else if (replacingRouteKeys.length || closingRouteKeys.length) {
137
- // Keep the routes we are closing or replacing if animation is enabled for them
138
- routes = routes.slice();
139
- routes.splice(routes.length - 1, 0, ...state.routes.filter(({
140
- key
141
- }) => isAnimationEnabled(key) ? replacingRouteKeys.includes(key) || closingRouteKeys.includes(key) : false));
142
- }
143
- if (!routes.length) {
144
- throw new Error('There should always be at least one route in the navigation state.');
145
- }
146
- const descriptors = routes.reduce((acc, route) => {
147
- acc[route.key] = props.descriptors[route.key] || state.descriptors[route.key];
148
- return acc;
149
- }, {});
150
- return {
151
- routes,
152
- previousRoutes: props.state.routes,
153
- previousDescriptors: props.descriptors,
154
- openingRouteKeys,
155
- closingRouteKeys,
156
- replacingRouteKeys,
157
- descriptors
158
- };
159
- }
160
- state = {
161
- routes: [],
162
- previousRoutes: [],
163
- previousDescriptors: {},
164
- openingRouteKeys: [],
165
- closingRouteKeys: [],
166
- replacingRouteKeys: [],
167
- descriptors: {}
168
- };
169
- getPreviousRoute = ({
170
- route
171
- }) => {
172
- const {
173
- closingRouteKeys,
174
- replacingRouteKeys
175
- } = this.state;
176
- const routes = this.state.routes.filter(r => r.key === route.key || !closingRouteKeys.includes(r.key) && !replacingRouteKeys.includes(r.key));
177
- const index = routes.findIndex(r => r.key === route.key);
178
- return routes[index - 1];
179
- };
180
- renderHeader = props => {
181
- return /*#__PURE__*/React.createElement(HeaderContainer, props);
182
- };
183
- handleOpenRoute = ({
184
- route
185
- }) => {
186
- const {
187
- state,
188
- navigation
189
- } = this.props;
190
- const {
191
- closingRouteKeys,
192
- replacingRouteKeys
193
- } = this.state;
194
- if (closingRouteKeys.some(key => key === route.key) && replacingRouteKeys.every(key => key !== route.key) && state.routeNames.includes(route.name) && !state.routes.some(r => r.key === route.key)) {
195
- // If route isn't present in current state, but was closing, assume that a close animation was cancelled
196
- // So we need to add this route back to the state
197
- navigation.dispatch(state => {
198
- const routes = [...state.routes.filter(r => r.key !== route.key), route];
199
- return CommonActions.reset({
200
- ...state,
201
- routes,
202
- index: routes.length - 1
203
- });
204
- });
205
- } else {
206
- this.setState(state => ({
207
- routes: state.replacingRouteKeys.length ? state.routes.filter(r => !state.replacingRouteKeys.includes(r.key)) : state.routes,
208
- openingRouteKeys: state.openingRouteKeys.filter(key => key !== route.key),
209
- closingRouteKeys: state.closingRouteKeys.filter(key => key !== route.key),
210
- replacingRouteKeys: []
211
- }));
212
- }
213
- };
214
- handleCloseRoute = ({
215
- route
216
- }) => {
217
- const {
218
- state,
219
- navigation
220
- } = this.props;
221
- if (state.routes.some(r => r.key === route.key)) {
222
- // If a route exists in state, trigger a pop
223
- // This will happen in when the route was closed from the card component
224
- // e.g. When the close animation triggered from a gesture ends
225
- navigation.dispatch({
226
- ...StackActions.pop(),
227
- source: route.key,
228
- target: state.key
229
- });
230
- } else {
231
- // We need to clean up any state tracking the route and pop it immediately
232
- this.setState(state => ({
233
- routes: state.routes.filter(r => r.key !== route.key),
234
- openingRouteKeys: state.openingRouteKeys.filter(key => key !== route.key),
235
- closingRouteKeys: state.closingRouteKeys.filter(key => key !== route.key)
236
- }));
342
+ if (!routes.length) {
343
+ throw new Error('There should always be at least one route in the navigation state.');
344
+ }
345
+ const descriptors = routes.reduce((acc, route) => {
346
+ acc[route.key] = props.descriptors[route.key] || state.descriptors[route.key];
347
+ return acc;
348
+ }, {});
349
+ return {
350
+ routes,
351
+ previousRoutes: props.state.routes,
352
+ previousDescriptors: props.descriptors,
353
+ openingRouteKeys,
354
+ closingRouteKeys,
355
+ replacingRouteKeys,
356
+ descriptors
357
+ };
237
358
  }
238
- };
239
- handleTransitionStart = ({
240
- route
241
- }, closing) => this.props.navigation.emit({
242
- type: 'transitionStart',
243
- data: {
244
- closing
245
- },
246
- target: route.key
247
- });
248
- handleTransitionEnd = ({
249
- route
250
- }, closing) => this.props.navigation.emit({
251
- type: 'transitionEnd',
252
- data: {
253
- closing
254
- },
255
- target: route.key
256
- });
257
- handleGestureStart = ({
258
- route
259
- }) => {
260
- this.props.navigation.emit({
261
- type: 'gestureStart',
262
- target: route.key
263
- });
264
- };
265
- handleGestureEnd = ({
266
- route
267
- }) => {
268
- this.props.navigation.emit({
269
- type: 'gestureEnd',
270
- target: route.key
271
- });
272
- };
273
- handleGestureCancel = ({
274
- route
275
- }) => {
276
- this.props.navigation.emit({
277
- type: 'gestureCancel',
278
- target: route.key
279
- });
280
- };
281
- render() {
282
- const {
283
- state,
284
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
285
- descriptors: _,
286
- ...rest
287
- } = this.props;
288
- const {
289
- routes,
290
- descriptors,
291
- openingRouteKeys,
292
- closingRouteKeys
293
- } = this.state;
294
- const preloadedDescriptors = state.preloadedRoutes.reduce((acc, route) => {
295
- acc[route.key] = acc[route.key] || this.props.describe(route, true);
296
- return acc;
297
- }, {});
298
- return /*#__PURE__*/React.createElement(GestureHandlerWrapper, {
299
- style: styles.container
300
- }, /*#__PURE__*/React.createElement(SafeAreaProviderCompat, null, /*#__PURE__*/React.createElement(SafeAreaInsetsContext.Consumer, null, insets => /*#__PURE__*/React.createElement(ModalPresentationContext.Consumer, null, isParentModal => /*#__PURE__*/React.createElement(HeaderShownContext.Consumer, null, isParentHeaderShown => /*#__PURE__*/React.createElement(CardStack, _extends({
301
- insets: insets,
302
- isParentHeaderShown: isParentHeaderShown,
303
- isParentModal: isParentModal,
304
- getPreviousRoute: this.getPreviousRoute,
305
- routes: routes,
306
- openingRouteKeys: openingRouteKeys,
307
- closingRouteKeys: closingRouteKeys,
308
- onOpenRoute: this.handleOpenRoute,
309
- onCloseRoute: this.handleCloseRoute,
310
- onTransitionStart: this.handleTransitionStart,
311
- onTransitionEnd: this.handleTransitionEnd,
312
- renderHeader: this.renderHeader,
313
- state: state,
314
- descriptors: descriptors,
315
- onGestureStart: this.handleGestureStart,
316
- onGestureEnd: this.handleGestureEnd,
317
- onGestureCancel: this.handleGestureCancel,
318
- preloadedDescriptors: preloadedDescriptors
319
- }, rest)))))));
320
- }
321
- }
359
+ }]);
360
+ }(React.Component);
322
361
  const styles = StyleSheet.create({
323
362
  container: {
324
363
  flex: 1