@granite-js/react-native 0.1.23-next.7 → 0.1.23-next.8
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @granite-js/react-native
|
|
2
2
|
|
|
3
|
+
## 0.1.23-next.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- router
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @granite-js/plugin-core@0.1.23-next.8
|
|
10
|
+
- @granite-js/style-utils@0.1.23-next.8
|
|
11
|
+
- @granite-js/lottie@0.1.23-next.8
|
|
12
|
+
- @granite-js/native@0.1.23-next.8
|
|
13
|
+
- @granite-js/image@0.1.23-next.8
|
|
14
|
+
- @granite-js/mpack@0.1.23-next.8
|
|
15
|
+
- @granite-js/jest@0.1.23-next.8
|
|
16
|
+
- @granite-js/cli@0.1.23-next.8
|
|
17
|
+
|
|
3
18
|
## 0.1.23-next.7
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/router/Router.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ interface StackNavigatorProps {
|
|
|
8
8
|
* @description
|
|
9
9
|
* You can create and pass a NavigationContainerRef from @react-navigation/native externally. This allows external control of the router.
|
|
10
10
|
*/
|
|
11
|
-
navigationContainerRef?: NavigationContainerRefWithCurrent<
|
|
11
|
+
navigationContainerRef?: NavigationContainerRefWithCurrent<never>;
|
|
12
12
|
/**
|
|
13
13
|
* @name defaultScreenOption
|
|
14
14
|
* @description
|
|
@@ -26,7 +26,6 @@ interface StackNavigatorProps {
|
|
|
26
26
|
screenContainer?: ComponentType<PropsWithChildren<any>>;
|
|
27
27
|
}
|
|
28
28
|
type NavigationContainerProps = Pick<ComponentProps<typeof NavigationContainer>, 'ref' | 'documentTitle' | 'fallback' | 'onReady' | 'onUnhandledAction' | 'onStateChange'>;
|
|
29
|
-
export declare const navigationRef: NavigationContainerRefWithCurrent<never>;
|
|
30
29
|
/**
|
|
31
30
|
* @category Components
|
|
32
31
|
* @kind function
|
|
@@ -38,7 +37,7 @@ export declare const navigationRef: NavigationContainerRefWithCurrent<never>;
|
|
|
38
37
|
*
|
|
39
38
|
* @param {string} prefix Prefix to use when the scheme is executed. For example, to enter 'scheme://my-service/intro', you need to set 'scheme://my-service' as the prefix.
|
|
40
39
|
* @param {RequireContext} context Object containing information about screens for file-based routing.
|
|
41
|
-
* @param {NavigationContainerRefWithCurrent<
|
|
40
|
+
* @param {NavigationContainerRefWithCurrent<never>} [navigationContainerRef] You can create and pass a NavigationContainerRef from @react-navigation/native externally. This allows external control of the router.
|
|
42
41
|
* @param {NativeStackNavigationOptions | ((props: { route: RouteProp<ParamListBase>; navigation: any }) => NativeStackNavigationOptions)} [defaultScreenOption] Default options for screens. You can set options to be applied commonly to screens, such as title or headerStyle.
|
|
43
42
|
* @param {boolean} [canGoBack=true] Whether navigation back is possible. Default is true, and when set to true, you can use the back gesture or back button from @react-navigation/native.
|
|
44
43
|
* @param {() => void} [onBack] Callback function called when the user presses the back button or uses the back gesture. For example, you can set it to log when the user presses the back button.
|
|
@@ -6,7 +6,7 @@ import { NavigationContainerRefWithCurrent } from '@granite-js/native/@react-nav
|
|
|
6
6
|
* @description
|
|
7
7
|
* A hook that provides a handler for handling back navigation actions. This can be used when you need to close a view directly when the back button is pressed in modals or independent screens where there's no navigation stack. This hook uses `NavigationContainerRef` from `@react-navigation/native` to navigate to the previous screen if there's a remaining navigation stack, or executes the user-defined `onClose` function if the stack is empty.
|
|
8
8
|
*
|
|
9
|
-
* @param {NavigationContainerRefWithCurrent<
|
|
9
|
+
* @param {NavigationContainerRefWithCurrent<never>} navigationContainerRef - A `NavigationContainerRef` that can reference the current navigation state. Used when executing back navigation actions.
|
|
10
10
|
* @param {() => void} [onClose] - A function to execute when the navigation stack is empty. For example, you can pass a function that closes a React Native View.
|
|
11
11
|
*
|
|
12
12
|
* @returns {{ handler: () => void }} A handler function that can be used in back buttons or similar components.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/react-native",
|
|
3
|
-
"version": "0.1.23-next.
|
|
3
|
+
"version": "0.1.23-next.8",
|
|
4
4
|
"description": "The Granite Framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"granite": "./bin/cli.js"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@babel/core": "^7.24.9",
|
|
87
87
|
"@babel/preset-env": "^7.24.8",
|
|
88
88
|
"@babel/preset-typescript": "^7.24.7",
|
|
89
|
-
"@granite-js/native": "0.1.23-next.
|
|
89
|
+
"@granite-js/native": "0.1.23-next.8",
|
|
90
90
|
"@testing-library/dom": "^10.4.0",
|
|
91
91
|
"@testing-library/react": "^16.1.0",
|
|
92
92
|
"@types/babel__core": "^7",
|
|
@@ -105,20 +105,20 @@
|
|
|
105
105
|
"vitest": "^2.1.8"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@granite-js/native": "0.1.23-next.
|
|
108
|
+
"@granite-js/native": "0.1.23-next.8",
|
|
109
109
|
"@types/react": "*",
|
|
110
110
|
"brick-module": "*",
|
|
111
111
|
"react": "*",
|
|
112
112
|
"react-native": "*"
|
|
113
113
|
},
|
|
114
114
|
"dependencies": {
|
|
115
|
-
"@granite-js/cli": "0.1.23-next.
|
|
116
|
-
"@granite-js/image": "0.1.23-next.
|
|
117
|
-
"@granite-js/jest": "0.1.23-next.
|
|
118
|
-
"@granite-js/lottie": "0.1.23-next.
|
|
119
|
-
"@granite-js/mpack": "0.1.23-next.
|
|
120
|
-
"@granite-js/plugin-core": "0.1.23-next.
|
|
121
|
-
"@granite-js/style-utils": "0.1.23-next.
|
|
115
|
+
"@granite-js/cli": "0.1.23-next.8",
|
|
116
|
+
"@granite-js/image": "0.1.23-next.8",
|
|
117
|
+
"@granite-js/jest": "0.1.23-next.8",
|
|
118
|
+
"@granite-js/lottie": "0.1.23-next.8",
|
|
119
|
+
"@granite-js/mpack": "0.1.23-next.8",
|
|
120
|
+
"@granite-js/plugin-core": "0.1.23-next.8",
|
|
121
|
+
"@granite-js/style-utils": "0.1.23-next.8",
|
|
122
122
|
"es-toolkit": "^1.39.8",
|
|
123
123
|
"react-native-url-polyfill": "1.3.0"
|
|
124
124
|
}
|
package/src/router/Router.tsx
CHANGED
|
@@ -7,7 +7,16 @@ import {
|
|
|
7
7
|
RouteProp,
|
|
8
8
|
} from '@granite-js/native/@react-navigation/native';
|
|
9
9
|
import { NativeStackNavigationOptions } from '@granite-js/native/@react-navigation/native-stack';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
ComponentProps,
|
|
12
|
+
ComponentType,
|
|
13
|
+
Fragment,
|
|
14
|
+
PropsWithChildren,
|
|
15
|
+
ReactElement,
|
|
16
|
+
useCallback,
|
|
17
|
+
useMemo,
|
|
18
|
+
useState,
|
|
19
|
+
} from 'react';
|
|
11
20
|
import { InitialProps } from '..';
|
|
12
21
|
import { closeView } from '../native-modules';
|
|
13
22
|
import { BackButton } from './components/BackButton';
|
|
@@ -67,7 +76,7 @@ interface StackNavigatorProps {
|
|
|
67
76
|
* @description
|
|
68
77
|
* You can create and pass a NavigationContainerRef from @react-navigation/native externally. This allows external control of the router.
|
|
69
78
|
*/
|
|
70
|
-
navigationContainerRef?: NavigationContainerRefWithCurrent<
|
|
79
|
+
navigationContainerRef?: NavigationContainerRefWithCurrent<never>;
|
|
71
80
|
/**
|
|
72
81
|
* @name defaultScreenOption
|
|
73
82
|
* @description
|
|
@@ -89,8 +98,6 @@ type NavigationContainerProps = Pick<
|
|
|
89
98
|
'ref' | 'documentTitle' | 'fallback' | 'onReady' | 'onUnhandledAction' | 'onStateChange'
|
|
90
99
|
>;
|
|
91
100
|
|
|
92
|
-
export const navigationRef = createNavigationContainerRef<never>();
|
|
93
|
-
|
|
94
101
|
/**
|
|
95
102
|
* @category Components
|
|
96
103
|
* @kind function
|
|
@@ -102,7 +109,7 @@ export const navigationRef = createNavigationContainerRef<never>();
|
|
|
102
109
|
*
|
|
103
110
|
* @param {string} prefix Prefix to use when the scheme is executed. For example, to enter 'scheme://my-service/intro', you need to set 'scheme://my-service' as the prefix.
|
|
104
111
|
* @param {RequireContext} context Object containing information about screens for file-based routing.
|
|
105
|
-
* @param {NavigationContainerRefWithCurrent<
|
|
112
|
+
* @param {NavigationContainerRefWithCurrent<never>} [navigationContainerRef] You can create and pass a NavigationContainerRef from @react-navigation/native externally. This allows external control of the router.
|
|
106
113
|
* @param {NativeStackNavigationOptions | ((props: { route: RouteProp<ParamListBase>; navigation: any }) => NativeStackNavigationOptions)} [defaultScreenOption] Default options for screens. You can set options to be applied commonly to screens, such as title or headerStyle.
|
|
107
114
|
* @param {boolean} [canGoBack=true] Whether navigation back is possible. Default is true, and when set to true, you can use the back gesture or back button from @react-navigation/native.
|
|
108
115
|
* @param {() => void} [onBack] Callback function called when the user presses the back button or uses the back gesture. For example, you can set it to log when the user presses the back button.
|
|
@@ -143,8 +150,10 @@ export function Router({
|
|
|
143
150
|
initialScheme,
|
|
144
151
|
});
|
|
145
152
|
|
|
153
|
+
const ref = useMemo(() => navigationContainerRef ?? createNavigationContainerRef<never>(), [navigationContainerRef]);
|
|
154
|
+
|
|
146
155
|
const { handler, canGoBack, onBack } = useInternalRouterBackHandler({
|
|
147
|
-
navigationContainerRef:
|
|
156
|
+
navigationContainerRef: ref,
|
|
148
157
|
onClose: closeView,
|
|
149
158
|
});
|
|
150
159
|
|
|
@@ -170,7 +179,7 @@ export function Router({
|
|
|
170
179
|
onStateChange={(state) => {
|
|
171
180
|
setIsInitialScreen(state ? state?.index === 0 : true);
|
|
172
181
|
}}
|
|
173
|
-
ref={
|
|
182
|
+
ref={ref}
|
|
174
183
|
{...navigationContainerProps}
|
|
175
184
|
linking={linkingOptions}
|
|
176
185
|
>
|
|
@@ -9,7 +9,7 @@ import { useBackEventContext } from '../../use-back-event';
|
|
|
9
9
|
* @description
|
|
10
10
|
* A hook that provides a handler for handling back navigation actions. This can be used when you need to close a view directly when the back button is pressed in modals or independent screens where there's no navigation stack. This hook uses `NavigationContainerRef` from `@react-navigation/native` to navigate to the previous screen if there's a remaining navigation stack, or executes the user-defined `onClose` function if the stack is empty.
|
|
11
11
|
*
|
|
12
|
-
* @param {NavigationContainerRefWithCurrent<
|
|
12
|
+
* @param {NavigationContainerRefWithCurrent<never>} navigationContainerRef - A `NavigationContainerRef` that can reference the current navigation state. Used when executing back navigation actions.
|
|
13
13
|
* @param {() => void} [onClose] - A function to execute when the navigation stack is empty. For example, you can pass a function that closes a React Native View.
|
|
14
14
|
*
|
|
15
15
|
* @returns {{ handler: () => void }} A handler function that can be used in back buttons or similar components.
|