@react-navigation/native 6.0.16 → 6.1.1
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/lib/commonjs/Link.js +2 -12
- package/lib/commonjs/Link.js.map +1 -1
- package/lib/commonjs/LinkingContext.js +0 -4
- package/lib/commonjs/LinkingContext.js.map +1 -1
- package/lib/commonjs/NavigationContainer.js +9 -31
- package/lib/commonjs/NavigationContainer.js.map +1 -1
- package/lib/commonjs/ServerContainer.js +2 -12
- package/lib/commonjs/ServerContainer.js.map +1 -1
- package/lib/commonjs/ServerContext.js +0 -4
- package/lib/commonjs/ServerContext.js.map +1 -1
- package/lib/commonjs/createMemoryHistory.js +36 -53
- package/lib/commonjs/createMemoryHistory.js.map +1 -1
- package/lib/commonjs/extractPathFromURL.js +2 -8
- package/lib/commonjs/extractPathFromURL.js.map +1 -1
- package/lib/commonjs/index.js +0 -17
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/theming/DarkTheme.js.map +1 -1
- package/lib/commonjs/theming/DefaultTheme.js.map +1 -1
- package/lib/commonjs/theming/ThemeContext.js +0 -6
- package/lib/commonjs/theming/ThemeContext.js.map +1 -1
- package/lib/commonjs/theming/ThemeProvider.js +0 -6
- package/lib/commonjs/theming/ThemeProvider.js.map +1 -1
- package/lib/commonjs/theming/useTheme.js +0 -6
- package/lib/commonjs/theming/useTheme.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useBackButton.js +0 -9
- package/lib/commonjs/useBackButton.js.map +1 -1
- package/lib/commonjs/useDocumentTitle.js +1 -12
- package/lib/commonjs/useDocumentTitle.js.map +1 -1
- package/lib/commonjs/useDocumentTitle.native.js +2 -2
- package/lib/commonjs/useDocumentTitle.native.js.map +1 -1
- package/lib/commonjs/useLinkBuilder.js +5 -15
- package/lib/commonjs/useLinkBuilder.js.map +1 -1
- package/lib/commonjs/useLinkProps.js +8 -24
- package/lib/commonjs/useLinkProps.js.map +1 -1
- package/lib/commonjs/useLinkTo.js +0 -12
- package/lib/commonjs/useLinkTo.js.map +1 -1
- package/lib/commonjs/useLinking.js +35 -79
- package/lib/commonjs/useLinking.js.map +1 -1
- package/lib/commonjs/useLinking.native.js +9 -36
- package/lib/commonjs/useLinking.native.js.map +1 -1
- package/lib/commonjs/useScrollToTop.js +48 -47
- package/lib/commonjs/useScrollToTop.js.map +1 -1
- package/lib/commonjs/useThenable.js +2 -9
- package/lib/commonjs/useThenable.js.map +1 -1
- package/lib/module/Link.js +2 -6
- package/lib/module/Link.js.map +1 -1
- package/lib/module/LinkingContext.js.map +1 -1
- package/lib/module/NavigationContainer.js +9 -18
- package/lib/module/NavigationContainer.js.map +1 -1
- package/lib/module/ServerContainer.js +2 -5
- package/lib/module/ServerContainer.js.map +1 -1
- package/lib/module/ServerContext.js.map +1 -1
- package/lib/module/createMemoryHistory.js +36 -51
- package/lib/module/createMemoryHistory.js.map +1 -1
- package/lib/module/extractPathFromURL.js +2 -5
- package/lib/module/extractPathFromURL.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/theming/DarkTheme.js.map +1 -1
- package/lib/module/theming/DefaultTheme.js.map +1 -1
- package/lib/module/theming/ThemeContext.js.map +1 -1
- package/lib/module/theming/ThemeProvider.js.map +1 -1
- package/lib/module/theming/useTheme.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useBackButton.js +0 -3
- package/lib/module/useBackButton.js.map +1 -1
- package/lib/module/useDocumentTitle.js +1 -9
- package/lib/module/useDocumentTitle.js.map +1 -1
- package/lib/module/useDocumentTitle.native.js +2 -1
- package/lib/module/useDocumentTitle.native.js.map +1 -1
- package/lib/module/useLinkBuilder.js +5 -9
- package/lib/module/useLinkBuilder.js.map +1 -1
- package/lib/module/useLinkProps.js +8 -16
- package/lib/module/useLinkProps.js.map +1 -1
- package/lib/module/useLinkTo.js +0 -5
- package/lib/module/useLinkTo.js.map +1 -1
- package/lib/module/useLinking.js +35 -70
- package/lib/module/useLinking.js.map +1 -1
- package/lib/module/useLinking.native.js +9 -26
- package/lib/module/useLinking.native.js.map +1 -1
- package/lib/module/useScrollToTop.js +48 -43
- package/lib/module/useScrollToTop.js.map +1 -1
- package/lib/module/useThenable.js +2 -5
- package/lib/module/useThenable.js.map +1 -1
- package/lib/typescript/src/Link.d.ts +1 -0
- package/lib/typescript/src/Link.d.ts.map +1 -0
- package/lib/typescript/src/LinkingContext.d.ts +1 -0
- package/lib/typescript/src/LinkingContext.d.ts.map +1 -0
- package/lib/typescript/src/NavigationContainer.d.ts +1 -0
- package/lib/typescript/src/NavigationContainer.d.ts.map +1 -0
- package/lib/typescript/src/ServerContainer.d.ts +1 -0
- package/lib/typescript/src/ServerContainer.d.ts.map +1 -0
- package/lib/typescript/src/ServerContext.d.ts +1 -0
- package/lib/typescript/src/ServerContext.d.ts.map +1 -0
- package/lib/typescript/src/__mocks__/window.d.ts +1 -0
- package/lib/typescript/src/__mocks__/window.d.ts.map +1 -0
- package/lib/typescript/src/createMemoryHistory.d.ts +1 -0
- package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -0
- package/lib/typescript/src/extractPathFromURL.d.ts +1 -0
- package/lib/typescript/src/extractPathFromURL.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/theming/DarkTheme.d.ts +1 -0
- package/lib/typescript/src/theming/DarkTheme.d.ts.map +1 -0
- package/lib/typescript/src/theming/DefaultTheme.d.ts +1 -0
- package/lib/typescript/src/theming/DefaultTheme.d.ts.map +1 -0
- package/lib/typescript/src/theming/ThemeContext.d.ts +1 -0
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -0
- package/lib/typescript/src/theming/ThemeProvider.d.ts +1 -0
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/src/theming/useTheme.d.ts +1 -0
- package/lib/typescript/src/theming/useTheme.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +1 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/useBackButton.d.ts +1 -0
- package/lib/typescript/src/useBackButton.d.ts.map +1 -0
- package/lib/typescript/src/useDocumentTitle.d.ts +1 -0
- package/lib/typescript/src/useDocumentTitle.d.ts.map +1 -0
- package/lib/typescript/src/useDocumentTitle.native.d.ts +1 -0
- package/lib/typescript/src/useDocumentTitle.native.d.ts.map +1 -0
- package/lib/typescript/src/useLinkBuilder.d.ts +1 -0
- package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -0
- package/lib/typescript/src/useLinkProps.d.ts +1 -0
- package/lib/typescript/src/useLinkProps.d.ts.map +1 -0
- package/lib/typescript/src/useLinkTo.d.ts +1 -0
- package/lib/typescript/src/useLinkTo.d.ts.map +1 -0
- package/lib/typescript/src/useLinking.d.ts +1 -0
- package/lib/typescript/src/useLinking.d.ts.map +1 -0
- package/lib/typescript/src/useLinking.native.d.ts +1 -0
- package/lib/typescript/src/useLinking.native.d.ts.map +1 -0
- package/lib/typescript/src/useScrollToTop.d.ts +1 -0
- package/lib/typescript/src/useScrollToTop.d.ts.map +1 -0
- package/lib/typescript/src/useThenable.d.ts +1 -0
- package/lib/typescript/src/useThenable.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/createMemoryHistory.tsx +10 -2
- package/src/useScrollToTop.tsx +52 -38
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../../src/useLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,sBAAsB,EAEtB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAiF9C,aAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,GAAG;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,WAAW,EACX,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuTX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../../src/useLinking.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACtB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,aAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,GAAG;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAIF,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,WAAW,EACX,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAkBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4JX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollToTop.d.ts","sourceRoot":"","sources":["../../../src/useScrollToTop.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,aAAK,aAAa,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpE,aAAK,cAAc,GACf;IAAE,WAAW,IAAI,IAAI,CAAA;CAAE,GACvB;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,GAC1C;IAAE,cAAc,CAAC,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC1E;IAAE,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC;AAE9D,aAAK,iBAAiB,GAClB;IAAE,kBAAkB,IAAI,KAAK,CAAC,SAAS,CAAA;CAAE,GACzC;IAAE,OAAO,IAAI,cAAc,CAAA;CAAE,GAC7B,cAAc,CAAC;AA8BnB,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,QAgExC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThenable.d.ts","sourceRoot":"","sources":["../../../src/useThenable.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,4BAsClE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/native",
|
|
3
3
|
"description": "React Native integration for React Navigation",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.1.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
7
7
|
"react-navigation",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"clean": "del lib"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@react-navigation/core": "^6.4.
|
|
40
|
+
"@react-navigation/core": "^6.4.5",
|
|
41
41
|
"escape-string-regexp": "^4.0.0",
|
|
42
42
|
"fast-deep-equal": "^3.1.3",
|
|
43
43
|
"nanoid": "^3.1.23"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react": "18.0.0",
|
|
52
52
|
"react-dom": "18.0.0",
|
|
53
53
|
"react-native": "0.69.5",
|
|
54
|
-
"react-native-builder-bob": "^0.
|
|
54
|
+
"react-native-builder-bob": "^0.20.3",
|
|
55
55
|
"typescript": "^4.7.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
]
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "2b22d3ea9ca99bc298f4fb48ae9808b65aa25620"
|
|
76
76
|
}
|
|
@@ -84,6 +84,10 @@ export default function createMemoryHistory() {
|
|
|
84
84
|
|
|
85
85
|
const id = window.history.state?.id ?? nanoid();
|
|
86
86
|
|
|
87
|
+
// Need to keep the hash part of the path if there was no previous history entry
|
|
88
|
+
// or the previous history entry had the same path
|
|
89
|
+
let pathWithHash = path;
|
|
90
|
+
|
|
87
91
|
if (!items.length || items.findIndex((item) => item.id === id) < 0) {
|
|
88
92
|
// There are two scenarios for creating an array with only one history record:
|
|
89
93
|
// - When loaded id not found in the items array, this function by default will replace
|
|
@@ -91,13 +95,17 @@ export default function createMemoryHistory() {
|
|
|
91
95
|
// the page when navigating forward in history.
|
|
92
96
|
// - This is the first time any state modifications are done
|
|
93
97
|
// So we need to push the entry as there's nothing to replace
|
|
94
|
-
|
|
98
|
+
pathWithHash = pathWithHash + location.hash;
|
|
99
|
+
items = [{ path: pathWithHash, state, id }];
|
|
95
100
|
index = 0;
|
|
96
101
|
} else {
|
|
102
|
+
if (items[index].path === path) {
|
|
103
|
+
pathWithHash = pathWithHash + location.hash;
|
|
104
|
+
}
|
|
97
105
|
items[index] = { path, state, id };
|
|
98
106
|
}
|
|
99
107
|
|
|
100
|
-
window.history.replaceState({ id }, '',
|
|
108
|
+
window.history.replaceState({ id }, '', pathWithHash);
|
|
101
109
|
},
|
|
102
110
|
|
|
103
111
|
// `history.go(n)` is asynchronous, there are couple of things to keep in mind:
|
package/src/useScrollToTop.tsx
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EventArg,
|
|
3
|
+
NavigationProp,
|
|
4
|
+
useNavigation,
|
|
5
|
+
useRoute,
|
|
6
|
+
} from '@react-navigation/core';
|
|
2
7
|
import * as React from 'react';
|
|
3
8
|
|
|
4
9
|
type ScrollOptions = { x?: number; y?: number; animated?: boolean };
|
|
@@ -49,53 +54,62 @@ export default function useScrollToTop(
|
|
|
49
54
|
const route = useRoute();
|
|
50
55
|
|
|
51
56
|
React.useEffect(() => {
|
|
52
|
-
let
|
|
57
|
+
let tabNavigations: NavigationProp<ReactNavigation.RootParamList>[] = [];
|
|
58
|
+
let currentNavigation = navigation;
|
|
53
59
|
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
while (
|
|
57
|
-
|
|
60
|
+
// If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
|
|
61
|
+
// So we need to find all the parent tab navigators and add the listeners there
|
|
62
|
+
while (currentNavigation) {
|
|
63
|
+
if (currentNavigation.getState().type === 'tab') {
|
|
64
|
+
tabNavigations.push(currentNavigation);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
currentNavigation = currentNavigation.getParent();
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
if (
|
|
70
|
+
if (tabNavigations.length === 0) {
|
|
61
71
|
return;
|
|
62
72
|
}
|
|
63
73
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
const unsubscribers = tabNavigations.map((tab) => {
|
|
75
|
+
return tab.addListener(
|
|
76
|
+
// We don't wanna import tab types here to avoid extra deps
|
|
77
|
+
// in addition, there are multiple tab implementations
|
|
78
|
+
// @ts-expect-error
|
|
79
|
+
'tabPress',
|
|
80
|
+
(e: EventArg<'tabPress', true>) => {
|
|
81
|
+
// We should scroll to top only when the screen is focused
|
|
82
|
+
const isFocused = navigation.isFocused();
|
|
72
83
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
// In a nested stack navigator, tab press resets the stack to first screen
|
|
85
|
+
// So we should scroll to top only when we are on first screen
|
|
86
|
+
const isFirst =
|
|
87
|
+
tabNavigations.includes(navigation) ||
|
|
88
|
+
navigation.getState().routes[0].key === route.key;
|
|
78
89
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
// Run the operation in the next frame so we're sure all listeners have been run
|
|
91
|
+
// This is necessary to know if preventDefault() has been called
|
|
92
|
+
requestAnimationFrame(() => {
|
|
93
|
+
const scrollable = getScrollableNode(ref) as ScrollableWrapper;
|
|
83
94
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
|
|
96
|
+
if ('scrollToTop' in scrollable) {
|
|
97
|
+
scrollable.scrollToTop();
|
|
98
|
+
} else if ('scrollTo' in scrollable) {
|
|
99
|
+
scrollable.scrollTo({ y: 0, animated: true });
|
|
100
|
+
} else if ('scrollToOffset' in scrollable) {
|
|
101
|
+
scrollable.scrollToOffset({ offset: 0, animated: true });
|
|
102
|
+
} else if ('scrollResponderScrollTo' in scrollable) {
|
|
103
|
+
scrollable.scrollResponderScrollTo({ y: 0, animated: true });
|
|
104
|
+
}
|
|
93
105
|
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
});
|
|
98
110
|
|
|
99
|
-
return
|
|
111
|
+
return () => {
|
|
112
|
+
unsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
113
|
+
};
|
|
100
114
|
}, [navigation, ref, route.key]);
|
|
101
115
|
}
|