@amazon-devices/react-navigation__native 7.0.1759135970 → 8.0.9000000000
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.
- package/SystemBundles/0fc5c971c5cf41a0dab235bcc6d58e5c06d9aaff650fa9815b525f8b9bb70a03.bundle +9116 -0
- package/SystemBundles/0fc5c971c5cf41a0dab235bcc6d58e5c06d9aaff650fa9815b525f8b9bb70a03.map +3543 -0
- package/SystemModules/amzn__react-navigation__native-8.modules.txt +24 -0
- package/SystemModules/amzn__react-navigation__native-8.private.modules.txt +77 -0
- package/SystemModules/keplerscript-system-bundle-config.json +4 -4
- package/kepler-compatibility.json +2 -2
- package/lib/module/Link.js +31 -10
- package/lib/module/Link.js.map +1 -1
- package/lib/module/LinkingContext.js +7 -3
- package/lib/module/LinkingContext.js.map +1 -1
- package/lib/module/LocaleDirContext.js +6 -0
- package/lib/module/LocaleDirContext.js.map +1 -0
- package/lib/module/NavigationContainer.js +87 -59
- package/lib/module/NavigationContainer.js.map +1 -1
- package/lib/module/ServerContainer.js +20 -10
- package/lib/module/ServerContainer.js.map +1 -1
- package/lib/module/ServerContext.js +3 -2
- package/lib/module/ServerContext.js.map +1 -1
- package/lib/module/UnhandledLinkingContext.js +14 -0
- package/lib/module/UnhandledLinkingContext.js.map +1 -0
- package/lib/module/__stubs__/createStackNavigator.js +18 -0
- package/lib/module/__stubs__/createStackNavigator.js.map +1 -0
- package/lib/module/__stubs__/window.js +75 -0
- package/lib/module/__stubs__/window.js.map +1 -0
- package/lib/module/createMemoryHistory.js +19 -17
- package/lib/module/createMemoryHistory.js.map +1 -1
- package/lib/module/createStaticNavigation.js +54 -0
- package/lib/module/createStaticNavigation.js.map +1 -0
- package/lib/module/extractPathFromURL.js +6 -5
- package/lib/module/extractPathFromURL.js.map +1 -1
- package/lib/module/index.js +18 -13
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/theming/DarkTheme.js +6 -3
- package/lib/module/theming/DarkTheme.js.map +1 -1
- package/lib/module/theming/DefaultTheme.js +6 -3
- package/lib/module/theming/DefaultTheme.js.map +1 -1
- package/lib/module/theming/fonts.js +61 -0
- package/lib/module/theming/fonts.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/useBackButton.js +3 -1
- package/lib/module/useBackButton.js.map +1 -1
- package/lib/module/useBackButton.native.js +3 -1
- package/lib/module/useBackButton.native.js.map +1 -1
- package/lib/module/useDocumentTitle.js +6 -4
- package/lib/module/useDocumentTitle.js.map +1 -1
- package/lib/module/useDocumentTitle.native.js +4 -2
- package/lib/module/useDocumentTitle.native.js.map +1 -1
- package/lib/module/useLinkBuilder.js +71 -40
- package/lib/module/useLinkBuilder.js.map +1 -1
- package/lib/module/useLinkProps.js +41 -36
- package/lib/module/useLinkProps.js.map +1 -1
- package/lib/module/useLinkTo.js +18 -28
- package/lib/module/useLinkTo.js.map +1 -1
- package/lib/module/useLinking.js +47 -19
- package/lib/module/useLinking.js.map +1 -1
- package/lib/module/useLinking.native.js +33 -28
- package/lib/module/useLinking.native.js.map +1 -1
- package/lib/module/useLocale.js +18 -0
- package/lib/module/useLocale.js.map +1 -0
- package/lib/module/useRoutePath.js +30 -0
- package/lib/module/useRoutePath.js.map +1 -0
- package/lib/module/useScrollToTop.js +11 -7
- package/lib/module/useScrollToTop.js.map +1 -1
- package/lib/module/useThenable.js +4 -1
- package/lib/module/useThenable.js.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Link.d.ts +8 -10
- package/lib/typescript/src/Link.d.ts.map +1 -1
- package/lib/typescript/src/LinkingContext.d.ts +2 -3
- package/lib/typescript/src/LinkingContext.d.ts.map +1 -1
- package/lib/typescript/src/LocaleDirContext.d.ts +4 -0
- package/lib/typescript/src/LocaleDirContext.d.ts.map +1 -0
- package/lib/typescript/src/NavigationContainer.d.ts +36 -13
- package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/ServerContainer.d.ts +2 -3
- package/lib/typescript/src/ServerContainer.d.ts.map +1 -1
- package/lib/typescript/src/ServerContext.d.ts +1 -2
- package/lib/typescript/src/ServerContext.d.ts.map +1 -1
- package/lib/typescript/src/UnhandledLinkingContext.d.ts +6 -0
- package/lib/typescript/src/UnhandledLinkingContext.d.ts.map +1 -0
- package/lib/typescript/src/__stubs__/createStackNavigator.d.ts +13 -0
- package/lib/typescript/src/__stubs__/createStackNavigator.d.ts.map +1 -0
- package/lib/typescript/src/{__mocks__ → __stubs__}/window.d.ts +5 -6
- package/lib/typescript/src/__stubs__/window.d.ts.map +1 -0
- package/lib/typescript/src/createMemoryHistory.d.ts +1 -1
- package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -1
- package/lib/typescript/src/createStaticNavigation.d.ts +34 -0
- package/lib/typescript/src/createStaticNavigation.d.ts.map +1 -0
- package/lib/typescript/src/extractPathFromURL.d.ts +1 -1
- package/lib/typescript/src/extractPathFromURL.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +15 -12
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/theming/DarkTheme.d.ts +1 -2
- package/lib/typescript/src/theming/DarkTheme.d.ts.map +1 -1
- package/lib/typescript/src/theming/DefaultTheme.d.ts +1 -2
- package/lib/typescript/src/theming/DefaultTheme.d.ts.map +1 -1
- package/lib/typescript/src/theming/fonts.d.ts +53 -0
- package/lib/typescript/src/theming/fonts.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +35 -3
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useBackButton.d.ts +1 -2
- package/lib/typescript/src/useBackButton.d.ts.map +1 -1
- package/lib/typescript/src/useBackButton.native.d.ts +1 -1
- package/lib/typescript/src/useBackButton.native.d.ts.map +1 -1
- package/lib/typescript/src/useDocumentTitle.d.ts +1 -1
- package/lib/typescript/src/useDocumentTitle.d.ts.map +1 -1
- package/lib/typescript/src/useDocumentTitle.native.d.ts +1 -1
- package/lib/typescript/src/useDocumentTitle.native.d.ts.map +1 -1
- package/lib/typescript/src/useLinkBuilder.d.ts +97 -3
- package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useLinkProps.d.ts +23 -10
- package/lib/typescript/src/useLinkProps.d.ts.map +1 -1
- package/lib/typescript/src/useLinkTo.d.ts +6 -8
- package/lib/typescript/src/useLinkTo.d.ts.map +1 -1
- package/lib/typescript/src/useLinking.d.ts +5 -46
- package/lib/typescript/src/useLinking.d.ts.map +1 -1
- package/lib/typescript/src/useLinking.native.d.ts +11 -29
- package/lib/typescript/src/useLinking.native.d.ts.map +1 -1
- package/lib/typescript/src/useLocale.d.ts +7 -0
- package/lib/typescript/src/useLocale.d.ts.map +1 -0
- package/lib/typescript/src/useRoutePath.d.ts +7 -0
- package/lib/typescript/src/useRoutePath.d.ts.map +1 -0
- package/lib/typescript/src/useScrollToTop.d.ts +2 -2
- package/lib/typescript/src/useScrollToTop.d.ts.map +1 -1
- package/lib/typescript/src/useThenable.d.ts +1 -1
- package/lib/typescript/src/useThenable.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Link.tsx +36 -20
- package/src/LinkingContext.tsx +9 -5
- package/src/LocaleDirContext.tsx +7 -0
- package/src/NavigationContainer.tsx +128 -69
- package/src/ServerContainer.tsx +4 -3
- package/src/ServerContext.tsx +1 -3
- package/src/UnhandledLinkingContext.tsx +18 -0
- package/src/__stubs__/createStackNavigator.tsx +46 -0
- package/src/{__mocks__ → __stubs__}/window.tsx +8 -8
- package/src/createMemoryHistory.tsx +16 -11
- package/src/createStaticNavigation.tsx +109 -0
- package/src/extractPathFromURL.tsx +3 -3
- package/src/index.tsx +15 -12
- package/src/theming/DarkTheme.tsx +3 -3
- package/src/theming/DefaultTheme.tsx +3 -3
- package/src/theming/fonts.tsx +63 -0
- package/src/types.tsx +49 -3
- package/src/useBackButton.native.tsx +2 -2
- package/src/useBackButton.tsx +2 -2
- package/src/useDocumentTitle.native.tsx +2 -2
- package/src/useDocumentTitle.tsx +2 -2
- package/src/useLinkBuilder.tsx +100 -55
- package/src/useLinkProps.tsx +80 -50
- package/src/useLinkTo.tsx +13 -53
- package/src/useLinking.native.tsx +33 -31
- package/src/useLinking.tsx +70 -23
- package/src/useLocale.tsx +18 -0
- package/src/useRoutePath.tsx +34 -0
- package/src/useScrollToTop.tsx +16 -12
- package/src/useThenable.tsx +2 -1
- package/SystemBundles/8f36606502d3b658fa1ffc07fee4da0e39a8ce388742799c9ccdb66b39ef0362.bundle +0 -15196
- package/SystemBundles/8f36606502d3b658fa1ffc07fee4da0e39a8ce388742799c9ccdb66b39ef0362.map +0 -1
- package/SystemModules/amzn__react-navigation__native-7.modules.txt +0 -76
- package/SystemModules/amzn__react-navigation__native-7.private.modules.txt +0 -101
- package/THIRD_PARTY_NOTICES.txt +0 -24
- package/lib/commonjs/Link.js +0 -50
- package/lib/commonjs/Link.js.map +0 -1
- package/lib/commonjs/LinkingContext.js +0 -15
- package/lib/commonjs/LinkingContext.js.map +0 -1
- package/lib/commonjs/NavigationContainer.js +0 -109
- package/lib/commonjs/NavigationContainer.js.map +0 -1
- package/lib/commonjs/ServerContainer.js +0 -54
- package/lib/commonjs/ServerContainer.js.map +0 -1
- package/lib/commonjs/ServerContext.js +0 -12
- package/lib/commonjs/ServerContext.js.map +0 -1
- package/lib/commonjs/createMemoryHistory.js +0 -220
- package/lib/commonjs/createMemoryHistory.js.map +0 -1
- package/lib/commonjs/extractPathFromURL.js +0 -25
- package/lib/commonjs/extractPathFromURL.js.map +0 -1
- package/lib/commonjs/index.js +0 -129
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/theming/DarkTheme.js +0 -19
- package/lib/commonjs/theming/DarkTheme.js.map +0 -1
- package/lib/commonjs/theming/DefaultTheme.js +0 -19
- package/lib/commonjs/theming/DefaultTheme.js.map +0 -1
- package/lib/commonjs/theming/ThemeContext.js +0 -15
- package/lib/commonjs/theming/ThemeContext.js.map +0 -1
- package/lib/commonjs/theming/ThemeProvider.js +0 -20
- package/lib/commonjs/theming/ThemeProvider.js.map +0 -1
- package/lib/commonjs/theming/useTheme.js +0 -16
- package/lib/commonjs/theming/useTheme.js.map +0 -1
- package/lib/commonjs/types.js +0 -6
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/useBackButton.js +0 -11
- package/lib/commonjs/useBackButton.js.map +0 -1
- package/lib/commonjs/useBackButton.native.js +0 -27
- package/lib/commonjs/useBackButton.native.js.map +0 -1
- package/lib/commonjs/useDocumentTitle.js +0 -32
- package/lib/commonjs/useDocumentTitle.js.map +0 -1
- package/lib/commonjs/useDocumentTitle.native.js +0 -10
- package/lib/commonjs/useDocumentTitle.native.js.map +0 -1
- package/lib/commonjs/useLinkBuilder.js +0 -63
- package/lib/commonjs/useLinkBuilder.js.map +0 -1
- package/lib/commonjs/useLinkProps.js +0 -97
- package/lib/commonjs/useLinkProps.js.map +0 -1
- package/lib/commonjs/useLinkTo.js +0 -45
- package/lib/commonjs/useLinkTo.js.map +0 -1
- package/lib/commonjs/useLinking.js +0 -303
- package/lib/commonjs/useLinking.js.map +0 -1
- package/lib/commonjs/useLinking.native.js +0 -152
- package/lib/commonjs/useLinking.native.js.map +0 -1
- package/lib/commonjs/useScrollToTop.js +0 -95
- package/lib/commonjs/useScrollToTop.js.map +0 -1
- package/lib/commonjs/useThenable.js +0 -41
- package/lib/commonjs/useThenable.js.map +0 -1
- package/lib/module/theming/ThemeContext.js +0 -6
- package/lib/module/theming/ThemeContext.js.map +0 -1
- package/lib/module/theming/ThemeProvider.js +0 -11
- package/lib/module/theming/ThemeProvider.js.map +0 -1
- package/lib/module/theming/useTheme.js +0 -7
- package/lib/module/theming/useTheme.js.map +0 -1
- package/lib/typescript/src/__mocks__/window.d.ts.map +0 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts +0 -5
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +0 -1
- package/lib/typescript/src/theming/ThemeProvider.d.ts +0 -9
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +0 -1
- package/lib/typescript/src/theming/useTheme.d.ts +0 -2
- package/lib/typescript/src/theming/useTheme.d.ts.map +0 -1
- package/src/theming/ThemeContext.tsx +0 -10
- package/src/theming/ThemeProvider.tsx +0 -15
- package/src/theming/useTheme.tsx +0 -9
package/src/useScrollToTop.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
EventArg,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type EventArg,
|
|
3
|
+
NavigationContext,
|
|
4
|
+
type NavigationProp,
|
|
5
|
+
type ParamListBase,
|
|
5
6
|
useRoute,
|
|
6
7
|
} from '@amazon-devices/react-navigation__core';
|
|
7
8
|
import * as React from 'react';
|
|
@@ -12,7 +13,7 @@ type ScrollOptions = { x?: number; y?: number; animated?: boolean };
|
|
|
12
13
|
type ScrollableView =
|
|
13
14
|
| { scrollToTop(): void }
|
|
14
15
|
| { scrollTo(options: ScrollOptions): void }
|
|
15
|
-
| { scrollToOffset(options: { offset
|
|
16
|
+
| { scrollToOffset(options: { offset: number; animated?: boolean }): void }
|
|
16
17
|
| { scrollResponderScrollTo(options: ScrollOptions): void };
|
|
17
18
|
|
|
18
19
|
type ScrollableWrapper =
|
|
@@ -38,7 +39,7 @@ function getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {
|
|
|
38
39
|
// We need to use `getScrollResponder` to get access to the scroll responder
|
|
39
40
|
return ref.current.getScrollResponder();
|
|
40
41
|
} else if ('getNode' in ref.current) {
|
|
41
|
-
// When a `ScrollView` is
|
|
42
|
+
// When a `ScrollView` is wrapped in `Animated.createAnimatedComponent`
|
|
42
43
|
// we need to use `getNode` to get the ref to the actual scrollview.
|
|
43
44
|
// Note that `getNode` is deprecated in newer versions of react-native
|
|
44
45
|
// this is why we check if we already have a scrollable node above.
|
|
@@ -48,16 +49,19 @@ function getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
) {
|
|
54
|
-
const navigation = useNavigation();
|
|
52
|
+
export function useScrollToTop(ref: React.RefObject<ScrollableWrapper>) {
|
|
53
|
+
const navigation = React.useContext(NavigationContext);
|
|
55
54
|
const route = useRoute();
|
|
56
55
|
|
|
56
|
+
if (navigation === undefined) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"Couldn't find a navigation object. Is your component inside NavigationContainer?"
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
React.useEffect(() => {
|
|
58
|
-
|
|
63
|
+
const tabNavigations: NavigationProp<ParamListBase>[] = [];
|
|
59
64
|
let currentNavigation = navigation;
|
|
60
|
-
|
|
61
65
|
// If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
|
|
62
66
|
// So we need to find all the parent tab navigators and add the listeners there
|
|
63
67
|
while (currentNavigation) {
|
|
@@ -76,7 +80,7 @@ export default function useScrollToTop(
|
|
|
76
80
|
return tab.addListener(
|
|
77
81
|
// We don't wanna import tab types here to avoid extra deps
|
|
78
82
|
// in addition, there are multiple tab implementations
|
|
79
|
-
// @ts-expect-error
|
|
83
|
+
// @ts-expect-error the `tabPress` event is only available when navigation type is tab
|
|
80
84
|
'tabPress',
|
|
81
85
|
(e: EventArg<'tabPress', true>) => {
|
|
82
86
|
// We should scroll to top only when the screen is focused
|
package/src/useThenable.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export function useThenable<T>(create: () => PromiseLike<T>) {
|
|
4
4
|
const [promise] = React.useState(create);
|
|
5
5
|
|
|
6
6
|
let initialState: [boolean, T | undefined] = [false, undefined];
|
|
7
7
|
|
|
8
8
|
// Check if our thenable is synchronous
|
|
9
|
+
// eslint-disable-next-line promise/catch-or-return, promise/always-return
|
|
9
10
|
promise.then((result) => {
|
|
10
11
|
initialState = [true, result];
|
|
11
12
|
});
|