@react-navigation/stack 7.0.0-rc.18 → 7.0.0-rc.19

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 (245) hide show
  1. package/lib/commonjs/views/Stack/Card.js +402 -371
  2. package/lib/commonjs/views/Stack/Card.js.map +1 -1
  3. package/lib/commonjs/views/Stack/CardSheet.js +2 -0
  4. package/lib/commonjs/views/Stack/CardSheet.js.map +1 -1
  5. package/lib/commonjs/views/Stack/CardStack.js +349 -328
  6. package/lib/commonjs/views/Stack/CardStack.js.map +1 -1
  7. package/lib/commonjs/views/Stack/StackView.js +319 -295
  8. package/lib/commonjs/views/Stack/StackView.js.map +1 -1
  9. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +2 -0
  10. package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  11. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +2 -0
  12. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
  13. package/lib/module/TransitionConfigs/TransitionPresets.js +2 -0
  14. package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
  15. package/lib/module/TransitionConfigs/TransitionSpecs.js +2 -0
  16. package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -1
  17. package/lib/module/index.js +2 -0
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/navigators/createStackNavigator.js +2 -0
  20. package/lib/module/navigators/createStackNavigator.js.map +1 -1
  21. package/lib/module/types.js +2 -0
  22. package/lib/module/utils/CardAnimationContext.js +2 -0
  23. package/lib/module/utils/CardAnimationContext.js.map +1 -1
  24. package/lib/module/utils/GestureHandlerRefContext.js +2 -0
  25. package/lib/module/utils/GestureHandlerRefContext.js.map +1 -1
  26. package/lib/module/utils/ModalPresentationContext.js +2 -0
  27. package/lib/module/utils/ModalPresentationContext.js.map +1 -1
  28. package/lib/module/utils/conditional.js +2 -0
  29. package/lib/module/utils/conditional.js.map +1 -1
  30. package/lib/module/utils/findLastIndex.js +2 -0
  31. package/lib/module/utils/findLastIndex.js.map +1 -1
  32. package/lib/module/utils/getDistanceForDirection.js +2 -0
  33. package/lib/module/utils/getDistanceForDirection.js.map +1 -1
  34. package/lib/module/utils/getInvertedMultiplier.js +2 -0
  35. package/lib/module/utils/getInvertedMultiplier.js.map +1 -1
  36. package/lib/module/utils/getModalRoutesKeys.js +2 -0
  37. package/lib/module/utils/getModalRoutesKeys.js.map +1 -1
  38. package/lib/module/utils/memoize.js +2 -0
  39. package/lib/module/utils/memoize.js.map +1 -1
  40. package/lib/module/utils/throttle.js +2 -0
  41. package/lib/module/utils/throttle.js.map +1 -1
  42. package/lib/module/utils/useCardAnimation.js +2 -0
  43. package/lib/module/utils/useCardAnimation.js.map +1 -1
  44. package/lib/module/utils/useGestureHandlerRef.js +2 -0
  45. package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
  46. package/lib/module/utils/useKeyboardManager.js +2 -0
  47. package/lib/module/utils/useKeyboardManager.js.map +1 -1
  48. package/lib/module/views/GestureHandler.android.js +2 -0
  49. package/lib/module/views/GestureHandler.android.js.map +1 -1
  50. package/lib/module/views/GestureHandler.ios.js +2 -0
  51. package/lib/module/views/GestureHandler.ios.js.map +1 -1
  52. package/lib/module/views/GestureHandler.js +2 -0
  53. package/lib/module/views/GestureHandler.js.map +1 -1
  54. package/lib/module/views/GestureHandlerNative.js +2 -0
  55. package/lib/module/views/GestureHandlerNative.js.map +1 -1
  56. package/lib/module/views/Header/Header.js +2 -0
  57. package/lib/module/views/Header/Header.js.map +1 -1
  58. package/lib/module/views/Header/HeaderContainer.js +2 -0
  59. package/lib/module/views/Header/HeaderContainer.js.map +1 -1
  60. package/lib/module/views/Header/HeaderSegment.js +2 -0
  61. package/lib/module/views/Header/HeaderSegment.js.map +1 -1
  62. package/lib/module/views/Screens.js +2 -0
  63. package/lib/module/views/Screens.js.map +1 -1
  64. package/lib/module/views/Stack/Card.js +404 -370
  65. package/lib/module/views/Stack/Card.js.map +1 -1
  66. package/lib/module/views/Stack/CardContainer.js +2 -0
  67. package/lib/module/views/Stack/CardContainer.js.map +1 -1
  68. package/lib/module/views/Stack/CardSheet.js +4 -0
  69. package/lib/module/views/Stack/CardSheet.js.map +1 -1
  70. package/lib/module/views/Stack/CardStack.js +351 -327
  71. package/lib/module/views/Stack/CardStack.js.map +1 -1
  72. package/lib/module/views/Stack/StackView.js +321 -294
  73. package/lib/module/views/Stack/StackView.js.map +1 -1
  74. package/lib/typescript/commonjs/package.json +1 -0
  75. package/lib/typescript/commonjs/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -0
  77. package/lib/typescript/commonjs/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  80. package/lib/typescript/commonjs/src/navigators/createStackNavigator.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/src/utils/CardAnimationContext.d.ts.map +1 -0
  83. package/lib/typescript/commonjs/src/utils/GestureHandlerRefContext.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/src/utils/ModalPresentationContext.d.ts.map +1 -0
  85. package/lib/typescript/commonjs/src/utils/conditional.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/src/utils/findLastIndex.d.ts.map +1 -0
  87. package/lib/typescript/commonjs/src/utils/getDistanceForDirection.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/utils/getInvertedMultiplier.d.ts.map +1 -0
  89. package/lib/typescript/commonjs/src/utils/getModalRoutesKeys.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/utils/memoize.d.ts.map +1 -0
  91. package/lib/typescript/commonjs/src/utils/throttle.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/utils/useCardAnimation.d.ts.map +1 -0
  93. package/lib/typescript/commonjs/src/utils/useGestureHandlerRef.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/utils/useKeyboardManager.d.ts.map +1 -0
  95. package/lib/typescript/commonjs/src/views/GestureHandler.android.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/views/GestureHandler.d.ts.map +1 -0
  97. package/lib/typescript/commonjs/src/views/GestureHandler.ios.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/views/GestureHandlerNative.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/src/views/Header/Header.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/views/Header/HeaderContainer.d.ts.map +1 -0
  101. package/lib/typescript/commonjs/src/views/Header/HeaderSegment.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/views/Screens.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/src/views/Stack/Card.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/views/Stack/CardContainer.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/src/views/Stack/CardSheet.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/views/Stack/CardStack.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/src/views/Stack/StackView.d.ts.map +1 -0
  108. package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -0
  109. package/lib/typescript/module/package.json +1 -0
  110. package/lib/typescript/module/src/TransitionConfigs/CardStyleInterpolators.d.ts +43 -0
  111. package/lib/typescript/module/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +1 -0
  112. package/lib/typescript/module/src/TransitionConfigs/HeaderStyleInterpolators.d.ts +23 -0
  113. package/lib/typescript/module/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -0
  114. package/lib/typescript/module/src/TransitionConfigs/TransitionPresets.d.ts +50 -0
  115. package/lib/typescript/module/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -0
  116. package/lib/typescript/module/src/TransitionConfigs/TransitionSpecs.d.ts +46 -0
  117. package/lib/typescript/module/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -0
  118. package/lib/typescript/module/src/index.d.ts +29 -0
  119. package/lib/typescript/module/src/index.d.ts.map +1 -0
  120. package/lib/typescript/module/src/navigators/createStackNavigator.d.ts +17 -0
  121. package/lib/typescript/module/src/navigators/createStackNavigator.d.ts.map +1 -0
  122. package/lib/typescript/module/src/types.d.ts +536 -0
  123. package/lib/typescript/module/src/types.d.ts.map +1 -0
  124. package/lib/typescript/module/src/utils/CardAnimationContext.d.ts +4 -0
  125. package/lib/typescript/module/src/utils/CardAnimationContext.d.ts.map +1 -0
  126. package/lib/typescript/module/src/utils/GestureHandlerRefContext.d.ts +3 -0
  127. package/lib/typescript/module/src/utils/GestureHandlerRefContext.d.ts.map +1 -0
  128. package/lib/typescript/module/src/utils/ModalPresentationContext.d.ts +3 -0
  129. package/lib/typescript/module/src/utils/ModalPresentationContext.d.ts.map +1 -0
  130. package/lib/typescript/module/src/utils/conditional.d.ts +10 -0
  131. package/lib/typescript/module/src/utils/conditional.d.ts.map +1 -0
  132. package/lib/typescript/module/src/utils/findLastIndex.d.ts +2 -0
  133. package/lib/typescript/module/src/utils/findLastIndex.d.ts.map +1 -0
  134. package/lib/typescript/module/src/utils/getDistanceForDirection.d.ts +3 -0
  135. package/lib/typescript/module/src/utils/getDistanceForDirection.d.ts.map +1 -0
  136. package/lib/typescript/module/src/utils/getInvertedMultiplier.d.ts +3 -0
  137. package/lib/typescript/module/src/utils/getInvertedMultiplier.d.ts.map +1 -0
  138. package/lib/typescript/module/src/utils/getModalRoutesKeys.d.ts +4 -0
  139. package/lib/typescript/module/src/utils/getModalRoutesKeys.d.ts.map +1 -0
  140. package/lib/typescript/module/src/utils/memoize.d.ts +2 -0
  141. package/lib/typescript/module/src/utils/memoize.d.ts.map +1 -0
  142. package/lib/typescript/module/src/utils/throttle.d.ts +2 -0
  143. package/lib/typescript/module/src/utils/throttle.d.ts.map +1 -0
  144. package/lib/typescript/module/src/utils/useCardAnimation.d.ts +2 -0
  145. package/lib/typescript/module/src/utils/useCardAnimation.d.ts.map +1 -0
  146. package/lib/typescript/module/src/utils/useGestureHandlerRef.d.ts +3 -0
  147. package/lib/typescript/module/src/utils/useGestureHandlerRef.d.ts.map +1 -0
  148. package/lib/typescript/module/src/utils/useKeyboardManager.d.ts +6 -0
  149. package/lib/typescript/module/src/utils/useKeyboardManager.d.ts.map +1 -0
  150. package/lib/typescript/module/src/views/GestureHandler.android.d.ts +2 -0
  151. package/lib/typescript/module/src/views/GestureHandler.android.d.ts.map +1 -0
  152. package/lib/typescript/module/src/views/GestureHandler.d.ts +15 -0
  153. package/lib/typescript/module/src/views/GestureHandler.d.ts.map +1 -0
  154. package/lib/typescript/module/src/views/GestureHandler.ios.d.ts +2 -0
  155. package/lib/typescript/module/src/views/GestureHandler.ios.d.ts.map +1 -0
  156. package/lib/typescript/module/src/views/GestureHandlerNative.d.ts +5 -0
  157. package/lib/typescript/module/src/views/GestureHandlerNative.d.ts.map +1 -0
  158. package/lib/typescript/module/src/views/Header/Header.d.ts +4 -0
  159. package/lib/typescript/module/src/views/Header/Header.d.ts.map +1 -0
  160. package/lib/typescript/module/src/views/Header/HeaderContainer.d.ts +19 -0
  161. package/lib/typescript/module/src/views/Header/HeaderContainer.d.ts.map +1 -0
  162. package/lib/typescript/module/src/views/Header/HeaderSegment.d.ts +14 -0
  163. package/lib/typescript/module/src/views/Header/HeaderSegment.d.ts.map +1 -0
  164. package/lib/typescript/module/src/views/Screens.d.ts +14 -0
  165. package/lib/typescript/module/src/views/Screens.d.ts.map +1 -0
  166. package/lib/typescript/module/src/views/Stack/Card.d.ts +77 -0
  167. package/lib/typescript/module/src/views/Stack/Card.d.ts.map +1 -0
  168. package/lib/typescript/module/src/views/Stack/CardContainer.d.ts +60 -0
  169. package/lib/typescript/module/src/views/Stack/CardContainer.d.ts.map +1 -0
  170. package/lib/typescript/module/src/views/Stack/CardSheet.d.ts +14 -0
  171. package/lib/typescript/module/src/views/Stack/CardSheet.d.ts.map +1 -0
  172. package/lib/typescript/module/src/views/Stack/CardStack.d.ts +66 -0
  173. package/lib/typescript/module/src/views/Stack/CardStack.d.ts.map +1 -0
  174. package/lib/typescript/module/src/views/Stack/StackView.d.ts +51 -0
  175. package/lib/typescript/module/src/views/Stack/StackView.d.ts.map +1 -0
  176. package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -0
  177. package/package.json +18 -11
  178. package/src/views/Stack/CardSheet.tsx +1 -0
  179. package/src/views/Stack/CardStack.tsx +0 -3
  180. package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +0 -1
  181. package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +0 -1
  182. package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts.map +0 -1
  183. package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts.map +0 -1
  184. package/lib/typescript/src/index.d.ts.map +0 -1
  185. package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +0 -1
  186. package/lib/typescript/src/types.d.ts.map +0 -1
  187. package/lib/typescript/src/utils/CardAnimationContext.d.ts.map +0 -1
  188. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts.map +0 -1
  189. package/lib/typescript/src/utils/ModalPresentationContext.d.ts.map +0 -1
  190. package/lib/typescript/src/utils/conditional.d.ts.map +0 -1
  191. package/lib/typescript/src/utils/findLastIndex.d.ts.map +0 -1
  192. package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +0 -1
  193. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +0 -1
  194. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +0 -1
  195. package/lib/typescript/src/utils/memoize.d.ts.map +0 -1
  196. package/lib/typescript/src/utils/throttle.d.ts.map +0 -1
  197. package/lib/typescript/src/utils/useCardAnimation.d.ts.map +0 -1
  198. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts.map +0 -1
  199. package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +0 -1
  200. package/lib/typescript/src/views/GestureHandler.android.d.ts.map +0 -1
  201. package/lib/typescript/src/views/GestureHandler.d.ts.map +0 -1
  202. package/lib/typescript/src/views/GestureHandler.ios.d.ts.map +0 -1
  203. package/lib/typescript/src/views/GestureHandlerNative.d.ts.map +0 -1
  204. package/lib/typescript/src/views/Header/Header.d.ts.map +0 -1
  205. package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +0 -1
  206. package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +0 -1
  207. package/lib/typescript/src/views/Screens.d.ts.map +0 -1
  208. package/lib/typescript/src/views/Stack/Card.d.ts.map +0 -1
  209. package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +0 -1
  210. package/lib/typescript/src/views/Stack/CardSheet.d.ts.map +0 -1
  211. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +0 -1
  212. package/lib/typescript/src/views/Stack/StackView.d.ts.map +0 -1
  213. /package/lib/typescript/{src → commonjs/src}/TransitionConfigs/CardStyleInterpolators.d.ts +0 -0
  214. /package/lib/typescript/{src → commonjs/src}/TransitionConfigs/HeaderStyleInterpolators.d.ts +0 -0
  215. /package/lib/typescript/{src → commonjs/src}/TransitionConfigs/TransitionPresets.d.ts +0 -0
  216. /package/lib/typescript/{src → commonjs/src}/TransitionConfigs/TransitionSpecs.d.ts +0 -0
  217. /package/lib/typescript/{src → commonjs/src}/index.d.ts +0 -0
  218. /package/lib/typescript/{src → commonjs/src}/navigators/createStackNavigator.d.ts +0 -0
  219. /package/lib/typescript/{src → commonjs/src}/types.d.ts +0 -0
  220. /package/lib/typescript/{src → commonjs/src}/utils/CardAnimationContext.d.ts +0 -0
  221. /package/lib/typescript/{src → commonjs/src}/utils/GestureHandlerRefContext.d.ts +0 -0
  222. /package/lib/typescript/{src → commonjs/src}/utils/ModalPresentationContext.d.ts +0 -0
  223. /package/lib/typescript/{src → commonjs/src}/utils/conditional.d.ts +0 -0
  224. /package/lib/typescript/{src → commonjs/src}/utils/findLastIndex.d.ts +0 -0
  225. /package/lib/typescript/{src → commonjs/src}/utils/getDistanceForDirection.d.ts +0 -0
  226. /package/lib/typescript/{src → commonjs/src}/utils/getInvertedMultiplier.d.ts +0 -0
  227. /package/lib/typescript/{src → commonjs/src}/utils/getModalRoutesKeys.d.ts +0 -0
  228. /package/lib/typescript/{src → commonjs/src}/utils/memoize.d.ts +0 -0
  229. /package/lib/typescript/{src → commonjs/src}/utils/throttle.d.ts +0 -0
  230. /package/lib/typescript/{src → commonjs/src}/utils/useCardAnimation.d.ts +0 -0
  231. /package/lib/typescript/{src → commonjs/src}/utils/useGestureHandlerRef.d.ts +0 -0
  232. /package/lib/typescript/{src → commonjs/src}/utils/useKeyboardManager.d.ts +0 -0
  233. /package/lib/typescript/{src → commonjs/src}/views/GestureHandler.android.d.ts +0 -0
  234. /package/lib/typescript/{src → commonjs/src}/views/GestureHandler.d.ts +0 -0
  235. /package/lib/typescript/{src → commonjs/src}/views/GestureHandler.ios.d.ts +0 -0
  236. /package/lib/typescript/{src → commonjs/src}/views/GestureHandlerNative.d.ts +0 -0
  237. /package/lib/typescript/{src → commonjs/src}/views/Header/Header.d.ts +0 -0
  238. /package/lib/typescript/{src → commonjs/src}/views/Header/HeaderContainer.d.ts +0 -0
  239. /package/lib/typescript/{src → commonjs/src}/views/Header/HeaderSegment.d.ts +0 -0
  240. /package/lib/typescript/{src → commonjs/src}/views/Screens.d.ts +0 -0
  241. /package/lib/typescript/{src → commonjs/src}/views/Stack/Card.d.ts +0 -0
  242. /package/lib/typescript/{src → commonjs/src}/views/Stack/CardContainer.d.ts +0 -0
  243. /package/lib/typescript/{src → commonjs/src}/views/Stack/CardSheet.d.ts +0 -0
  244. /package/lib/typescript/{src → commonjs/src}/views/Stack/CardStack.d.ts +0 -0
  245. /package/lib/typescript/{src → commonjs/src}/views/Stack/StackView.d.ts +0 -0
@@ -17,6 +17,19 @@ var _CardContainer = require("./CardContainer.js");
17
17
  var _jsxRuntime = require("react/jsx-runtime");
18
18
  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); }
19
19
  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; }
20
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
21
+ 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); } }
22
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
23
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
24
+ 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); }
25
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
26
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
27
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
28
+ 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); }
29
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
30
+ 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; }
31
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
32
+ 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); }
20
33
  const NAMED_TRANSITIONS_PRESETS = {
21
34
  default: _TransitionPresets.DefaultTransition,
22
35
  fade: _TransitionPresets.ModalFadeTransition,
@@ -111,110 +124,79 @@ const getProgressFromGesture = (gesture, layout, descriptor, isRTL) => {
111
124
  outputRange: [0, 1]
112
125
  });
113
126
  };
114
- class CardStack extends React.Component {
115
- static getDerivedStateFromProps(props, state) {
116
- if (props.routes === state.routes && props.descriptors === state.descriptors) {
117
- return null;
118
- }
119
- const gestures = [...props.routes, ...props.state.preloadedRoutes].reduce((acc, curr) => {
120
- const descriptor = props.descriptors[curr.key] || props.preloadedDescriptors[curr.key];
127
+ let CardStack = exports.CardStack = /*#__PURE__*/function (_React$Component) {
128
+ function CardStack(_props) {
129
+ var _this;
130
+ _classCallCheck(this, CardStack);
131
+ _this = _callSuper(this, CardStack, [_props]);
132
+ _defineProperty(_this, "handleLayout", e => {
121
133
  const {
122
- animation
123
- } = descriptor?.options || {};
124
- acc[curr.key] = state.gestures[curr.key] || new _reactNative.Animated.Value(props.openingRouteKeys.includes(curr.key) && animation !== 'none' || props.state.preloadedRoutes.includes(curr) ? getDistanceFromOptions(state.layout, descriptor, props.direction === 'rtl') : 0);
125
- return acc;
126
- }, {});
127
- const modalRouteKeys = (0, _getModalRoutesKeys.getModalRouteKeys)([...props.routes, ...props.state.preloadedRoutes], {
128
- ...props.descriptors,
129
- ...props.preloadedDescriptors
134
+ height,
135
+ width
136
+ } = e.nativeEvent.layout;
137
+ const layout = {
138
+ width,
139
+ height
140
+ };
141
+ _this.setState((state, props) => {
142
+ if (height === state.layout.height && width === state.layout.width) {
143
+ return null;
144
+ }
145
+ return {
146
+ layout,
147
+ headerHeights: getHeaderHeights(state.scenes, props.insets, props.isParentHeaderShown, props.isParentModal, layout, state.headerHeights)
148
+ };
149
+ });
130
150
  });
131
- const scenes = [...props.routes, ...props.state.preloadedRoutes].map((route, index, self) => {
132
- // For preloaded screens, we don't care about the previous and the next screen
133
- const isPreloaded = props.state.preloadedRoutes.includes(route);
134
- const previousRoute = isPreloaded ? undefined : self[index - 1];
135
- const nextRoute = isPreloaded ? undefined : self[index + 1];
136
- const oldScene = state.scenes[index];
137
- const currentGesture = gestures[route.key];
138
- const previousGesture = previousRoute ? gestures[previousRoute.key] : undefined;
139
- const nextGesture = nextRoute ? gestures[nextRoute.key] : undefined;
140
- const descriptor = (isPreloaded ? props.preloadedDescriptors : props.descriptors)[route.key] || state.descriptors[route.key] || (oldScene ? oldScene.descriptor : FALLBACK_DESCRIPTOR);
141
- const nextDescriptor = nextRoute && (props.descriptors[nextRoute?.key] || state.descriptors[nextRoute?.key]);
142
- const previousDescriptor = previousRoute && (props.descriptors[previousRoute?.key] || state.descriptors[previousRoute?.key]);
143
-
144
- // When a screen is not the last, it should use next screen's transition config
145
- // Many transitions also animate the previous screen, so using 2 different transitions doesn't look right
146
- // For example combining a slide and a modal transition would look wrong otherwise
147
- // With this approach, combining different transition styles in the same navigator mostly looks right
148
- // This will still be broken when 2 transitions have different idle state (e.g. modal presentation),
149
- // but the majority of the transitions look alright
150
- const optionsForTransitionConfig = index !== self.length - 1 && nextDescriptor && nextDescriptor.options.presentation !== 'transparentModal' ? nextDescriptor.options : descriptor.options;
151
-
152
- // Assume modal if there are already modal screens in the stack
153
- // or current screen is a modal when no presentation is specified
154
- const isModal = modalRouteKeys.includes(route.key);
155
-
156
- // Disable screen transition animation by default on web, windows and macos to match the native behavior
157
- const excludedPlatforms = _reactNative.Platform.OS !== 'web' && _reactNative.Platform.OS !== 'windows' && _reactNative.Platform.OS !== 'macos';
158
- const animation = optionsForTransitionConfig.animation ?? (excludedPlatforms ? 'default' : 'none');
159
- const isAnimationEnabled = animation !== 'none';
160
- const transitionPreset = animation !== 'default' ? NAMED_TRANSITIONS_PRESETS[animation] : isModal || optionsForTransitionConfig.presentation === 'modal' ? _TransitionPresets.ModalTransition : optionsForTransitionConfig.presentation === 'transparentModal' ? _TransitionPresets.ModalFadeTransition : _TransitionPresets.DefaultTransition;
161
- const {
162
- gestureEnabled = _reactNative.Platform.OS === 'ios' && isAnimationEnabled,
163
- gestureDirection = transitionPreset.gestureDirection,
164
- transitionSpec = transitionPreset.transitionSpec,
165
- cardStyleInterpolator = isAnimationEnabled ? transitionPreset.cardStyleInterpolator : _CardStyleInterpolators.forNoAnimation,
166
- headerStyleInterpolator = transitionPreset.headerStyleInterpolator,
167
- cardOverlayEnabled = _reactNative.Platform.OS !== 'ios' && optionsForTransitionConfig.presentation !== 'transparentModal' || getIsModalPresentation(cardStyleInterpolator)
168
- } = optionsForTransitionConfig;
169
- const headerMode = descriptor.options.headerMode ?? (!(optionsForTransitionConfig.presentation === 'modal' || optionsForTransitionConfig.presentation === 'transparentModal' || nextDescriptor?.options.presentation === 'modal' || nextDescriptor?.options.presentation === 'transparentModal' || getIsModalPresentation(cardStyleInterpolator)) && _reactNative.Platform.OS === 'ios' && descriptor.options.header === undefined ? 'float' : 'screen');
170
- const isRTL = props.direction === 'rtl';
171
- const scene = {
172
- route,
173
- descriptor: {
174
- ...descriptor,
175
- options: {
176
- ...descriptor.options,
177
- animation,
178
- cardOverlayEnabled,
179
- cardStyleInterpolator,
180
- gestureDirection,
181
- gestureEnabled,
182
- headerStyleInterpolator,
183
- transitionSpec,
184
- headerMode
151
+ _defineProperty(_this, "handleHeaderLayout", ({
152
+ route,
153
+ height
154
+ }) => {
155
+ _this.setState(({
156
+ headerHeights
157
+ }) => {
158
+ const previousHeight = headerHeights[route.key];
159
+ if (previousHeight === height) {
160
+ return null;
161
+ }
162
+ return {
163
+ headerHeights: {
164
+ ...headerHeights,
165
+ [route.key]: height
185
166
  }
186
- },
187
- progress: {
188
- current: getProgressFromGesture(currentGesture, state.layout, descriptor, isRTL),
189
- next: nextGesture && nextDescriptor?.options.presentation !== 'transparentModal' ? getProgressFromGesture(nextGesture, state.layout, nextDescriptor, isRTL) : undefined,
190
- previous: previousGesture ? getProgressFromGesture(previousGesture, state.layout, previousDescriptor, isRTL) : undefined
191
- },
192
- __memo: [state.layout, descriptor, nextDescriptor, previousDescriptor, currentGesture, nextGesture, previousGesture]
193
- };
194
- if (oldScene && scene.__memo.every((it, i) => {
195
- // @ts-expect-error: we haven't added __memo to the annotation to prevent usage elsewhere
196
- return oldScene.__memo[i] === it;
197
- })) {
198
- return oldScene;
167
+ };
168
+ });
169
+ });
170
+ _defineProperty(_this, "getFocusedRoute", () => {
171
+ const {
172
+ state
173
+ } = _this.props;
174
+ return state.routes[state.index];
175
+ });
176
+ _defineProperty(_this, "getPreviousScene", ({
177
+ route
178
+ }) => {
179
+ const {
180
+ getPreviousRoute
181
+ } = _this.props;
182
+ const {
183
+ scenes
184
+ } = _this.state;
185
+ const previousRoute = getPreviousRoute({
186
+ route
187
+ });
188
+ if (previousRoute) {
189
+ const previousScene = scenes.find(scene => scene.descriptor.route.key === previousRoute.key);
190
+ return previousScene;
199
191
  }
200
- return scene;
192
+ return undefined;
201
193
  });
202
- return {
203
- routes: props.routes,
204
- scenes,
205
- gestures,
206
- descriptors: props.descriptors,
207
- headerHeights: getHeaderHeights(scenes, props.insets, props.isParentHeaderShown, props.isParentModal, state.layout, state.headerHeights)
208
- };
209
- }
210
- constructor(props) {
211
- super(props);
212
- this.state = {
194
+ _this.state = {
213
195
  routes: [],
214
196
  scenes: [],
215
197
  gestures: {},
216
198
  layout: _elements.SafeAreaProviderCompat.initialMetrics.frame,
217
- descriptors: this.props.descriptors,
199
+ descriptors: _this.props.descriptors,
218
200
  // Used when card's header is null and mode is float to make transition
219
201
  // between screens with headers and those without headers smooth.
220
202
  // This is not a great heuristic here. We don't know synchronously
@@ -222,247 +204,286 @@ class CardStack extends React.Component {
222
204
  // common cases here.
223
205
  headerHeights: {}
224
206
  };
207
+ return _this;
225
208
  }
226
- handleLayout = e => {
227
- const {
228
- height,
229
- width
230
- } = e.nativeEvent.layout;
231
- const layout = {
232
- width,
233
- height
234
- };
235
- this.setState((state, props) => {
236
- if (height === state.layout.height && width === state.layout.width) {
237
- return null;
238
- }
239
- return {
240
- layout,
241
- headerHeights: getHeaderHeights(state.scenes, props.insets, props.isParentHeaderShown, props.isParentModal, layout, state.headerHeights)
242
- };
243
- });
244
- };
245
- handleHeaderLayout = ({
246
- route,
247
- height
248
- }) => {
249
- this.setState(({
250
- headerHeights
251
- }) => {
252
- const previousHeight = headerHeights[route.key];
253
- if (previousHeight === height) {
254
- return null;
255
- }
256
- return {
257
- headerHeights: {
258
- ...headerHeights,
259
- [route.key]: height
260
- }
261
- };
262
- });
263
- };
264
- getFocusedRoute = () => {
265
- const {
266
- state
267
- } = this.props;
268
- return state.routes[state.index];
269
- };
270
- getPreviousScene = ({
271
- route
272
- }) => {
273
- const {
274
- getPreviousRoute
275
- } = this.props;
276
- const {
277
- scenes
278
- } = this.state;
279
- const previousRoute = getPreviousRoute({
280
- route
281
- });
282
- if (previousRoute) {
283
- const previousScene = scenes.find(scene => scene.descriptor.route.key === previousRoute.key);
284
- return previousScene;
285
- }
286
- return undefined;
287
- };
288
- render() {
289
- const {
290
- insets,
291
- state,
292
- routes,
293
- closingRouteKeys,
294
- onOpenRoute,
295
- onCloseRoute,
296
- renderHeader,
297
- isParentHeaderShown,
298
- isParentModal,
299
- onTransitionStart,
300
- onTransitionEnd,
301
- onGestureStart,
302
- onGestureEnd,
303
- onGestureCancel,
304
- detachInactiveScreens = _reactNative.Platform.OS === 'web' || _reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'ios'
305
- } = this.props;
306
- const {
307
- scenes,
308
- layout,
309
- gestures,
310
- headerHeights
311
- } = this.state;
312
- const focusedRoute = state.routes[state.index];
313
- const focusedHeaderHeight = headerHeights[focusedRoute.key];
314
- const isFloatHeaderAbsolute = this.state.scenes.slice(-2).some(scene => {
315
- const options = scene.descriptor.options ?? {};
209
+ _inherits(CardStack, _React$Component);
210
+ return _createClass(CardStack, [{
211
+ key: "render",
212
+ value: function render() {
316
213
  const {
317
- headerMode,
318
- headerTransparent,
319
- headerShown = true
320
- } = options;
321
- if (headerTransparent || headerShown === false || headerMode === 'screen') {
322
- return true;
323
- }
324
- return false;
325
- });
326
- let activeScreensLimit = 1;
327
- for (let i = scenes.length - 1; i >= 0; i--) {
214
+ insets,
215
+ state,
216
+ routes,
217
+ closingRouteKeys,
218
+ onOpenRoute,
219
+ onCloseRoute,
220
+ renderHeader,
221
+ isParentHeaderShown,
222
+ isParentModal,
223
+ onTransitionStart,
224
+ onTransitionEnd,
225
+ onGestureStart,
226
+ onGestureEnd,
227
+ onGestureCancel,
228
+ detachInactiveScreens = _reactNative.Platform.OS === 'web' || _reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'ios'
229
+ } = this.props;
328
230
  const {
329
- options
330
- } = scenes[i].descriptor;
331
- const {
332
- // By default, we don't want to detach the previous screen of the active one for modals
333
- detachPreviousScreen = options.presentation === 'transparentModal' ? false : getIsModalPresentation(options.cardStyleInterpolator) ? i !== (0, _findLastIndex.findLastIndex)(scenes, scene => {
334
- const {
335
- cardStyleInterpolator
336
- } = scene.descriptor.options;
337
- return cardStyleInterpolator === _CardStyleInterpolators.forModalPresentationIOS || cardStyleInterpolator?.name === 'forModalPresentationIOS';
338
- }) : true
339
- } = options;
340
- if (detachPreviousScreen === false) {
341
- activeScreensLimit++;
342
- } else {
343
- // Check at least last 2 screens before stopping
344
- // This will make sure that screen isn't detached when another screen is animating on top of the transparent one
345
- // For example, (Opaque -> Transparent -> Opaque)
346
- if (i <= scenes.length - 2) {
347
- break;
231
+ scenes,
232
+ layout,
233
+ gestures,
234
+ headerHeights
235
+ } = this.state;
236
+ const focusedRoute = state.routes[state.index];
237
+ const focusedHeaderHeight = headerHeights[focusedRoute.key];
238
+ const isFloatHeaderAbsolute = this.state.scenes.slice(-2).some(scene => {
239
+ const options = scene.descriptor.options ?? {};
240
+ const {
241
+ headerMode,
242
+ headerTransparent,
243
+ headerShown = true
244
+ } = options;
245
+ if (headerTransparent || headerShown === false || headerMode === 'screen') {
246
+ return true;
247
+ }
248
+ return false;
249
+ });
250
+ let activeScreensLimit = 1;
251
+ for (let i = scenes.length - 1; i >= 0; i--) {
252
+ const {
253
+ options
254
+ } = scenes[i].descriptor;
255
+ const {
256
+ // By default, we don't want to detach the previous screen of the active one for modals
257
+ detachPreviousScreen = options.presentation === 'transparentModal' ? false : getIsModalPresentation(options.cardStyleInterpolator) ? i !== (0, _findLastIndex.findLastIndex)(scenes, scene => {
258
+ const {
259
+ cardStyleInterpolator
260
+ } = scene.descriptor.options;
261
+ return cardStyleInterpolator === _CardStyleInterpolators.forModalPresentationIOS || cardStyleInterpolator?.name === 'forModalPresentationIOS';
262
+ }) : true
263
+ } = options;
264
+ if (detachPreviousScreen === false) {
265
+ activeScreensLimit++;
266
+ } else {
267
+ // Check at least last 2 screens before stopping
268
+ // This will make sure that screen isn't detached when another screen is animating on top of the transparent one
269
+ // For example, (Opaque -> Transparent -> Opaque)
270
+ if (i <= scenes.length - 2) {
271
+ break;
272
+ }
348
273
  }
349
274
  }
275
+ const floatingHeader = /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
276
+ children: renderHeader({
277
+ mode: 'float',
278
+ layout,
279
+ scenes,
280
+ getPreviousScene: this.getPreviousScene,
281
+ getFocusedRoute: this.getFocusedRoute,
282
+ onContentHeightChange: this.handleHeaderLayout,
283
+ style: [styles.floating, isFloatHeaderAbsolute && [
284
+ // Without this, the header buttons won't be touchable on Android when headerTransparent: true
285
+ {
286
+ height: focusedHeaderHeight
287
+ }, styles.absolute]]
288
+ })
289
+ }, "header");
290
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_elements.Background, {
291
+ children: [isFloatHeaderAbsolute ? null : floatingHeader, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Screens.MaybeScreenContainer, {
292
+ enabled: detachInactiveScreens,
293
+ style: styles.container,
294
+ onLayout: this.handleLayout,
295
+ children: [...routes, ...state.preloadedRoutes].map((route, index) => {
296
+ const focused = focusedRoute.key === route.key;
297
+ const gesture = gestures[route.key];
298
+ const scene = scenes[index];
299
+ // It is possible that for a short period the route appears in both arrays.
300
+ // Particularly, if the screen is removed with `retain`, then it needs a moment to execute the animation.
301
+ // However, due to the router action, it immediately populates the `preloadedRoutes` array.
302
+ // Practically, the logic below takes care that it is rendered only once.
303
+ const isPreloaded = state.preloadedRoutes.includes(route) && !routes.includes(route);
304
+ if (state.preloadedRoutes.includes(route) && routes.includes(route) && index >= routes.length) {
305
+ return null;
306
+ }
307
+
308
+ // For the screens that shouldn't be active, the value is 0
309
+ // For those that should be active, but are not the top screen, the value is 1
310
+ // For those on top of the stack and with interaction enabled, the value is 2
311
+ // For the old implementation, it stays the same it was
312
+ let isScreenActive = 1;
313
+ if (index < routes.length - activeScreensLimit - 1 || isPreloaded) {
314
+ // screen should be inactive because it is too deep in the stack
315
+ isScreenActive = STATE_INACTIVE;
316
+ } else {
317
+ const sceneForActivity = scenes[routes.length - 1];
318
+ const outputValue = index === routes.length - 1 ? STATE_ON_TOP // the screen is on top after the transition
319
+ : index >= routes.length - activeScreensLimit ? STATE_TRANSITIONING_OR_BELOW_TOP // the screen should stay active after the transition, it is not on top but is in activeLimit
320
+ : STATE_INACTIVE; // the screen should be active only during the transition, it is at the edge of activeLimit
321
+ isScreenActive = sceneForActivity ? sceneForActivity.progress.current.interpolate({
322
+ inputRange: [0, 1 - EPSILON, 1],
323
+ outputRange: [1, 1, outputValue],
324
+ extrapolate: 'clamp'
325
+ }) : STATE_TRANSITIONING_OR_BELOW_TOP;
326
+ }
327
+ const {
328
+ headerShown = true,
329
+ headerTransparent,
330
+ freezeOnBlur,
331
+ autoHideHomeIndicator
332
+ } = scene.descriptor.options;
333
+ const safeAreaInsetTop = insets.top;
334
+ const safeAreaInsetRight = insets.right;
335
+ const safeAreaInsetBottom = insets.bottom;
336
+ const safeAreaInsetLeft = insets.left;
337
+ const headerHeight = headerShown !== false ? headerHeights[route.key] : 0;
338
+
339
+ // Start from current card and count backwards the number of cards with same interpolation
340
+ const interpolationIndex = getInterpolationIndex(scenes, index);
341
+ const isModal = getIsModal(scene, interpolationIndex, isParentModal);
342
+ const isNextScreenTransparent = scenes[index + 1]?.descriptor.options.presentation === 'transparentModal';
343
+ const detachCurrentScreen = scenes[index + 1]?.descriptor.options.detachPreviousScreen !== false;
344
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Screens.MaybeScreen, {
345
+ style: [_reactNative.StyleSheet.absoluteFill],
346
+ enabled: detachInactiveScreens,
347
+ active: isScreenActive,
348
+ freezeOnBlur: freezeOnBlur,
349
+ homeIndicatorHidden: autoHideHomeIndicator,
350
+ pointerEvents: "box-none",
351
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardContainer.CardContainer, {
352
+ index: index,
353
+ interpolationIndex: interpolationIndex,
354
+ modal: isModal,
355
+ active: index === routes.length - 1,
356
+ focused: focused,
357
+ closing: closingRouteKeys.includes(route.key),
358
+ layout: layout,
359
+ gesture: gesture,
360
+ scene: scene,
361
+ safeAreaInsetTop: safeAreaInsetTop,
362
+ safeAreaInsetRight: safeAreaInsetRight,
363
+ safeAreaInsetBottom: safeAreaInsetBottom,
364
+ safeAreaInsetLeft: safeAreaInsetLeft,
365
+ onGestureStart: onGestureStart,
366
+ onGestureCancel: onGestureCancel,
367
+ onGestureEnd: onGestureEnd,
368
+ headerHeight: headerHeight,
369
+ isParentHeaderShown: isParentHeaderShown,
370
+ onHeaderHeightChange: this.handleHeaderLayout,
371
+ getPreviousScene: this.getPreviousScene,
372
+ getFocusedRoute: this.getFocusedRoute,
373
+ hasAbsoluteFloatHeader: isFloatHeaderAbsolute && !headerTransparent,
374
+ renderHeader: renderHeader,
375
+ onOpenRoute: onOpenRoute,
376
+ onCloseRoute: onCloseRoute,
377
+ onTransitionStart: onTransitionStart,
378
+ onTransitionEnd: onTransitionEnd,
379
+ isNextScreenTransparent: isNextScreenTransparent,
380
+ detachCurrentScreen: detachCurrentScreen,
381
+ preloaded: isPreloaded
382
+ })
383
+ }, route.key);
384
+ })
385
+ }), isFloatHeaderAbsolute ? floatingHeader : null]
386
+ });
350
387
  }
351
- const floatingHeader = /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
352
- children: renderHeader({
353
- mode: 'float',
354
- layout,
355
- scenes,
356
- getPreviousScene: this.getPreviousScene,
357
- getFocusedRoute: this.getFocusedRoute,
358
- onContentHeightChange: this.handleHeaderLayout,
359
- style: [styles.floating, isFloatHeaderAbsolute && [
360
- // Without this, the header buttons won't be touchable on Android when headerTransparent: true
361
- {
362
- height: focusedHeaderHeight
363
- }, styles.absolute]]
364
- })
365
- }, "header");
366
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_elements.Background, {
367
- children: [isFloatHeaderAbsolute ? null : floatingHeader, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Screens.MaybeScreenContainer, {
368
- enabled: detachInactiveScreens,
369
- style: styles.container,
370
- onLayout: this.handleLayout,
371
- children: [...routes, ...state.preloadedRoutes].map((route, index) => {
372
- const focused = focusedRoute.key === route.key;
373
- const gesture = gestures[route.key];
374
- const scene = scenes[index];
375
- // It is possible that for a short period the route appears in both arrays.
376
- // Particularly, if the screen is removed with `retain`, then it needs a moment to execute the animation.
377
- // However, due to the router action, it immediately populates the `preloadedRoutes` array.
378
- // Practically, the logic below takes care that it is rendered only once.
379
- const isPreloaded = state.preloadedRoutes.includes(route) && !routes.includes(route);
380
- if (state.preloadedRoutes.includes(route) && routes.includes(route) && index >= routes.length) {
381
- return null;
382
- }
388
+ }], [{
389
+ key: "getDerivedStateFromProps",
390
+ value: function getDerivedStateFromProps(props, state) {
391
+ if (props.routes === state.routes && props.descriptors === state.descriptors) {
392
+ return null;
393
+ }
394
+ const gestures = [...props.routes, ...props.state.preloadedRoutes].reduce((acc, curr) => {
395
+ const descriptor = props.descriptors[curr.key] || props.preloadedDescriptors[curr.key];
396
+ const {
397
+ animation
398
+ } = descriptor?.options || {};
399
+ acc[curr.key] = state.gestures[curr.key] || new _reactNative.Animated.Value(props.openingRouteKeys.includes(curr.key) && animation !== 'none' || props.state.preloadedRoutes.includes(curr) ? getDistanceFromOptions(state.layout, descriptor, props.direction === 'rtl') : 0);
400
+ return acc;
401
+ }, {});
402
+ const modalRouteKeys = (0, _getModalRoutesKeys.getModalRouteKeys)([...props.routes, ...props.state.preloadedRoutes], {
403
+ ...props.descriptors,
404
+ ...props.preloadedDescriptors
405
+ });
406
+ const scenes = [...props.routes, ...props.state.preloadedRoutes].map((route, index, self) => {
407
+ // For preloaded screens, we don't care about the previous and the next screen
408
+ const isPreloaded = props.state.preloadedRoutes.includes(route);
409
+ const previousRoute = isPreloaded ? undefined : self[index - 1];
410
+ const nextRoute = isPreloaded ? undefined : self[index + 1];
411
+ const oldScene = state.scenes[index];
412
+ const currentGesture = gestures[route.key];
413
+ const previousGesture = previousRoute ? gestures[previousRoute.key] : undefined;
414
+ const nextGesture = nextRoute ? gestures[nextRoute.key] : undefined;
415
+ const descriptor = (isPreloaded ? props.preloadedDescriptors : props.descriptors)[route.key] || state.descriptors[route.key] || (oldScene ? oldScene.descriptor : FALLBACK_DESCRIPTOR);
416
+ const nextDescriptor = nextRoute && (props.descriptors[nextRoute?.key] || state.descriptors[nextRoute?.key]);
417
+ const previousDescriptor = previousRoute && (props.descriptors[previousRoute?.key] || state.descriptors[previousRoute?.key]);
383
418
 
384
- // For the screens that shouldn't be active, the value is 0
385
- // For those that should be active, but are not the top screen, the value is 1
386
- // For those on top of the stack and with interaction enabled, the value is 2
387
- // For the old implementation, it stays the same it was
388
- let isScreenActive = 1;
389
- if (index < routes.length - activeScreensLimit - 1 || isPreloaded) {
390
- // screen should be inactive because it is too deep in the stack
391
- isScreenActive = STATE_INACTIVE;
392
- } else {
393
- const sceneForActivity = scenes[routes.length - 1];
394
- const outputValue = index === routes.length - 1 ? STATE_ON_TOP // the screen is on top after the transition
395
- : index >= routes.length - activeScreensLimit ? STATE_TRANSITIONING_OR_BELOW_TOP // the screen should stay active after the transition, it is not on top but is in activeLimit
396
- : STATE_INACTIVE; // the screen should be active only during the transition, it is at the edge of activeLimit
397
- isScreenActive = sceneForActivity ? sceneForActivity.progress.current.interpolate({
398
- inputRange: [0, 1 - EPSILON, 1],
399
- outputRange: [1, 1, outputValue],
400
- extrapolate: 'clamp'
401
- }) : STATE_TRANSITIONING_OR_BELOW_TOP;
402
- }
403
- const {
404
- headerShown = true,
405
- headerTransparent,
406
- freezeOnBlur,
407
- autoHideHomeIndicator
408
- } = scene.descriptor.options;
409
- const safeAreaInsetTop = insets.top;
410
- const safeAreaInsetRight = insets.right;
411
- const safeAreaInsetBottom = insets.bottom;
412
- const safeAreaInsetLeft = insets.left;
413
- const headerHeight = headerShown !== false ? headerHeights[route.key] : 0;
419
+ // When a screen is not the last, it should use next screen's transition config
420
+ // Many transitions also animate the previous screen, so using 2 different transitions doesn't look right
421
+ // For example combining a slide and a modal transition would look wrong otherwise
422
+ // With this approach, combining different transition styles in the same navigator mostly looks right
423
+ // This will still be broken when 2 transitions have different idle state (e.g. modal presentation),
424
+ // but the majority of the transitions look alright
425
+ const optionsForTransitionConfig = index !== self.length - 1 && nextDescriptor && nextDescriptor.options.presentation !== 'transparentModal' ? nextDescriptor.options : descriptor.options;
414
426
 
415
- // Start from current card and count backwards the number of cards with same interpolation
416
- const interpolationIndex = getInterpolationIndex(scenes, index);
417
- const isModal = getIsModal(scene, interpolationIndex, isParentModal);
418
- const isNextScreenTransparent = scenes[index + 1]?.descriptor.options.presentation === 'transparentModal';
419
- const detachCurrentScreen = scenes[index + 1]?.descriptor.options.detachPreviousScreen !== false;
420
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Screens.MaybeScreen, {
421
- style: [_reactNative.StyleSheet.absoluteFill],
422
- enabled: detachInactiveScreens,
423
- active: isScreenActive,
424
- freezeOnBlur: freezeOnBlur,
425
- homeIndicatorHidden: autoHideHomeIndicator,
426
- pointerEvents: "box-none",
427
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardContainer.CardContainer, {
428
- index: index,
429
- interpolationIndex: interpolationIndex,
430
- modal: isModal,
431
- active: index === routes.length - 1,
432
- focused: focused,
433
- closing: closingRouteKeys.includes(route.key),
434
- layout: layout,
435
- gesture: gesture,
436
- scene: scene,
437
- safeAreaInsetTop: safeAreaInsetTop,
438
- safeAreaInsetRight: safeAreaInsetRight,
439
- safeAreaInsetBottom: safeAreaInsetBottom,
440
- safeAreaInsetLeft: safeAreaInsetLeft,
441
- onGestureStart: onGestureStart,
442
- onGestureCancel: onGestureCancel,
443
- onGestureEnd: onGestureEnd,
444
- headerHeight: headerHeight,
445
- isParentHeaderShown: isParentHeaderShown,
446
- onHeaderHeightChange: this.handleHeaderLayout,
447
- getPreviousScene: this.getPreviousScene,
448
- getFocusedRoute: this.getFocusedRoute,
449
- hasAbsoluteFloatHeader: isFloatHeaderAbsolute && !headerTransparent,
450
- renderHeader: renderHeader,
451
- onOpenRoute: onOpenRoute,
452
- onCloseRoute: onCloseRoute,
453
- onTransitionStart: onTransitionStart,
454
- onTransitionEnd: onTransitionEnd,
455
- isNextScreenTransparent: isNextScreenTransparent,
456
- detachCurrentScreen: detachCurrentScreen,
457
- preloaded: isPreloaded
458
- })
459
- }, route.key);
460
- })
461
- }), isFloatHeaderAbsolute ? floatingHeader : null]
462
- });
463
- }
464
- }
465
- exports.CardStack = CardStack;
427
+ // Assume modal if there are already modal screens in the stack
428
+ // or current screen is a modal when no presentation is specified
429
+ const isModal = modalRouteKeys.includes(route.key);
430
+
431
+ // Disable screen transition animation by default on web, windows and macos to match the native behavior
432
+ const excludedPlatforms = _reactNative.Platform.OS !== 'web' && _reactNative.Platform.OS !== 'windows' && _reactNative.Platform.OS !== 'macos';
433
+ const animation = optionsForTransitionConfig.animation ?? (excludedPlatforms ? 'default' : 'none');
434
+ const isAnimationEnabled = animation !== 'none';
435
+ const transitionPreset = animation !== 'default' ? NAMED_TRANSITIONS_PRESETS[animation] : isModal || optionsForTransitionConfig.presentation === 'modal' ? _TransitionPresets.ModalTransition : optionsForTransitionConfig.presentation === 'transparentModal' ? _TransitionPresets.ModalFadeTransition : _TransitionPresets.DefaultTransition;
436
+ const {
437
+ gestureEnabled = _reactNative.Platform.OS === 'ios' && isAnimationEnabled,
438
+ gestureDirection = transitionPreset.gestureDirection,
439
+ transitionSpec = transitionPreset.transitionSpec,
440
+ cardStyleInterpolator = isAnimationEnabled ? transitionPreset.cardStyleInterpolator : _CardStyleInterpolators.forNoAnimation,
441
+ headerStyleInterpolator = transitionPreset.headerStyleInterpolator,
442
+ cardOverlayEnabled = _reactNative.Platform.OS !== 'ios' && optionsForTransitionConfig.presentation !== 'transparentModal' || getIsModalPresentation(cardStyleInterpolator)
443
+ } = optionsForTransitionConfig;
444
+ const headerMode = descriptor.options.headerMode ?? (!(optionsForTransitionConfig.presentation === 'modal' || optionsForTransitionConfig.presentation === 'transparentModal' || nextDescriptor?.options.presentation === 'modal' || nextDescriptor?.options.presentation === 'transparentModal' || getIsModalPresentation(cardStyleInterpolator)) && _reactNative.Platform.OS === 'ios' && descriptor.options.header === undefined ? 'float' : 'screen');
445
+ const isRTL = props.direction === 'rtl';
446
+ const scene = {
447
+ route,
448
+ descriptor: {
449
+ ...descriptor,
450
+ options: {
451
+ ...descriptor.options,
452
+ animation,
453
+ cardOverlayEnabled,
454
+ cardStyleInterpolator,
455
+ gestureDirection,
456
+ gestureEnabled,
457
+ headerStyleInterpolator,
458
+ transitionSpec,
459
+ headerMode
460
+ }
461
+ },
462
+ progress: {
463
+ current: getProgressFromGesture(currentGesture, state.layout, descriptor, isRTL),
464
+ next: nextGesture && nextDescriptor?.options.presentation !== 'transparentModal' ? getProgressFromGesture(nextGesture, state.layout, nextDescriptor, isRTL) : undefined,
465
+ previous: previousGesture ? getProgressFromGesture(previousGesture, state.layout, previousDescriptor, isRTL) : undefined
466
+ },
467
+ __memo: [state.layout, descriptor, nextDescriptor, previousDescriptor, currentGesture, nextGesture, previousGesture]
468
+ };
469
+ if (oldScene && scene.__memo.every((it, i) => {
470
+ // @ts-expect-error: we haven't added __memo to the annotation to prevent usage elsewhere
471
+ return oldScene.__memo[i] === it;
472
+ })) {
473
+ return oldScene;
474
+ }
475
+ return scene;
476
+ });
477
+ return {
478
+ routes: props.routes,
479
+ scenes,
480
+ gestures,
481
+ descriptors: props.descriptors,
482
+ headerHeights: getHeaderHeights(scenes, props.insets, props.isParentHeaderShown, props.isParentModal, state.layout, state.headerHeights)
483
+ };
484
+ }
485
+ }]);
486
+ }(React.Component);
466
487
  const styles = _reactNative.StyleSheet.create({
467
488
  container: {
468
489
  flex: 1