react-native-screen-transitions 2.0.2 → 2.0.4

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 (77) hide show
  1. package/lib/commonjs/utils/bounds/constants.js +3 -3
  2. package/lib/commonjs/utils/bounds/constants.js.map +1 -1
  3. package/lib/commonjs/utils/bounds/get-bounds.js +3 -3
  4. package/lib/commonjs/utils/bounds/get-bounds.js.map +1 -1
  5. package/lib/module/utils/bounds/constants.js +3 -3
  6. package/lib/module/utils/bounds/constants.js.map +1 -1
  7. package/lib/module/utils/bounds/get-bounds.js +3 -3
  8. package/lib/module/utils/bounds/get-bounds.js.map +1 -1
  9. package/lib/typescript/utils/bounds/_types/get-bounds.d.ts +2 -2
  10. package/lib/typescript/utils/bounds/_types/get-bounds.d.ts.map +1 -1
  11. package/lib/typescript/utils/bounds/constants.d.ts +4 -4
  12. package/lib/typescript/utils/bounds/constants.d.ts.map +1 -1
  13. package/lib/typescript/utils/bounds/get-bounds.d.ts +2 -2
  14. package/lib/typescript/utils/bounds/get-bounds.d.ts.map +1 -1
  15. package/lib/typescript/utils/bounds/index.d.ts +1 -1
  16. package/lib/typescript/utils/bounds/index.d.ts.map +1 -1
  17. package/package.json +4 -2
  18. package/src/__tests__/geometry.test.ts +127 -0
  19. package/src/components/bounds-activator.tsx +29 -0
  20. package/src/components/controllers/screen-lifecycle.tsx +72 -0
  21. package/src/components/create-transition-aware-component.tsx +99 -0
  22. package/src/components/root-transition-aware.tsx +56 -0
  23. package/src/configs/index.ts +2 -0
  24. package/src/configs/presets.ts +227 -0
  25. package/src/configs/specs.ts +9 -0
  26. package/src/hooks/animation/use-associated-style.tsx +28 -0
  27. package/src/hooks/animation/use-screen-animation.tsx +142 -0
  28. package/src/hooks/bounds/use-bound-measurer.tsx +71 -0
  29. package/src/hooks/gestures/use-build-gestures.tsx +369 -0
  30. package/src/hooks/gestures/use-scroll-progress.tsx +60 -0
  31. package/src/hooks/use-stable-callback.tsx +15 -0
  32. package/src/index.ts +32 -0
  33. package/src/integrations/native-stack/navigators/createNativeStackNavigator.tsx +112 -0
  34. package/src/integrations/native-stack/utils/debounce.tsx +14 -0
  35. package/src/integrations/native-stack/utils/getModalRoutesKeys.ts +21 -0
  36. package/src/integrations/native-stack/utils/useAnimatedHeaderHeight.tsx +18 -0
  37. package/src/integrations/native-stack/utils/useDismissedRouteError.tsx +30 -0
  38. package/src/integrations/native-stack/utils/useInvalidPreventRemoveError.tsx +31 -0
  39. package/src/integrations/native-stack/views/FontProcessor.native.tsx +12 -0
  40. package/src/integrations/native-stack/views/FontProcessor.tsx +5 -0
  41. package/src/integrations/native-stack/views/FooterComponent.tsx +10 -0
  42. package/src/integrations/native-stack/views/NativeStackView.native.tsx +657 -0
  43. package/src/integrations/native-stack/views/NativeStackView.tsx +214 -0
  44. package/src/integrations/native-stack/views/useHeaderConfigProps.tsx +295 -0
  45. package/src/providers/gestures.tsx +89 -0
  46. package/src/providers/keys.tsx +38 -0
  47. package/src/stores/animations.ts +45 -0
  48. package/src/stores/bounds.ts +71 -0
  49. package/src/stores/gestures.ts +55 -0
  50. package/src/stores/navigator-dismiss-state.ts +17 -0
  51. package/src/stores/utils/reset-stores-for-screen.ts +14 -0
  52. package/src/types/animation.ts +76 -0
  53. package/src/types/bounds.ts +82 -0
  54. package/src/types/core.ts +50 -0
  55. package/src/types/gesture.ts +33 -0
  56. package/src/types/navigator.ts +744 -0
  57. package/src/types/utils.ts +3 -0
  58. package/src/utils/animation/animate.ts +28 -0
  59. package/src/utils/animation/run-transition.ts +49 -0
  60. package/src/utils/bounds/_types/builder.ts +35 -0
  61. package/src/utils/bounds/_types/geometry.ts +17 -0
  62. package/src/utils/bounds/_types/get-bounds.ts +10 -0
  63. package/src/utils/bounds/build-bound-styles.ts +184 -0
  64. package/src/utils/bounds/constants.ts +25 -0
  65. package/src/utils/bounds/flatten-styles.ts +21 -0
  66. package/src/utils/bounds/geometry.ts +113 -0
  67. package/src/utils/bounds/get-bounds.ts +56 -0
  68. package/src/utils/bounds/index.ts +46 -0
  69. package/src/utils/bounds/style-composers.ts +172 -0
  70. package/src/utils/gesture/apply-gesture-activation-criteria.ts +109 -0
  71. package/src/utils/gesture/map-gesture-to-progress.ts +11 -0
  72. package/src/utils/gesture/normalize-gesture-translation.ts +20 -0
  73. package/src/utils/index.ts +1 -0
  74. package/lib/commonjs/__tests__ /geometry.test.js +0 -178
  75. package/lib/commonjs/__tests__ /geometry.test.js.map +0 -1
  76. package/lib/module/__tests__ /geometry.test.js +0 -178
  77. package/lib/module/__tests__ /geometry.test.js.map +0 -1
@@ -0,0 +1,31 @@
1
+ import { usePreventRemoveContext } from "@react-navigation/native";
2
+ import * as React from "react";
3
+
4
+ import type { NativeStackDescriptorMap } from "../../../types/navigator";
5
+
6
+ export function useInvalidPreventRemoveError(
7
+ descriptors: NativeStackDescriptorMap,
8
+ ) {
9
+ const { preventedRoutes } = usePreventRemoveContext();
10
+ const preventedRouteKey = Object.keys(preventedRoutes)[0];
11
+ const preventedDescriptor = descriptors[preventedRouteKey];
12
+ const isHeaderBackButtonMenuEnabledOnPreventedScreen =
13
+ preventedDescriptor?.options?.headerBackButtonMenuEnabled;
14
+ const preventedRouteName = preventedDescriptor?.route?.name;
15
+
16
+ React.useEffect(() => {
17
+ if (
18
+ preventedRouteKey != null &&
19
+ isHeaderBackButtonMenuEnabledOnPreventedScreen
20
+ ) {
21
+ const message =
22
+ `The screen ${preventedRouteName} uses 'usePreventRemove' hook alongside 'headerBackButtonMenuEnabled: true', which is not supported. \n\n` +
23
+ `Consider removing 'headerBackButtonMenuEnabled: true' from ${preventedRouteName} screen to get rid of this error.`;
24
+ console.error(message);
25
+ }
26
+ }, [
27
+ preventedRouteKey,
28
+ isHeaderBackButtonMenuEnabledOnPreventedScreen,
29
+ preventedRouteName,
30
+ ]);
31
+ }
@@ -0,0 +1,12 @@
1
+ // @ts-expect-error importing private module
2
+ import ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
3
+
4
+ export function processFonts(
5
+ fontFamilies: (string | undefined)[]
6
+ ): (string | undefined)[] {
7
+ const fontFamilyProcessor = ReactNativeStyleAttributes.fontFamily?.process;
8
+ if (typeof fontFamilyProcessor === 'function') {
9
+ return fontFamilies.map(fontFamilyProcessor);
10
+ }
11
+ return fontFamilies;
12
+ }
@@ -0,0 +1,5 @@
1
+ export function processFonts(
2
+ _: (string | undefined)[]
3
+ ): (string | undefined)[] {
4
+ throw new Error('Not supported on Web');
5
+ }
@@ -0,0 +1,10 @@
1
+ import type React from "react";
2
+ import { ScreenFooter } from "react-native-screens";
3
+
4
+ type FooterProps = {
5
+ children?: React.ReactNode;
6
+ };
7
+
8
+ export function FooterComponent({ children }: FooterProps) {
9
+ return <ScreenFooter collapsable={false}>{children}</ScreenFooter>;
10
+ }