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