@react-navigation/core 7.0.0-alpha.5 → 7.0.0-alpha.7
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/BaseNavigationContainer.js +6 -1
- package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
- package/lib/commonjs/index.js +27 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/theming/ThemeContext.js +12 -0
- package/lib/commonjs/theming/ThemeContext.js.map +1 -0
- package/lib/commonjs/theming/ThemeProvider.js +20 -0
- package/lib/commonjs/theming/ThemeProvider.js.map +1 -0
- package/lib/commonjs/theming/useTheme.js +18 -0
- package/lib/commonjs/theming/useTheme.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useDescriptors.js +79 -16
- package/lib/commonjs/useDescriptors.js.map +1 -1
- package/lib/commonjs/useNavigationBuilder.js +10 -3
- package/lib/commonjs/useNavigationBuilder.js.map +1 -1
- package/lib/commonjs/useNavigationCache.js +55 -14
- package/lib/commonjs/useNavigationCache.js.map +1 -1
- package/lib/commonjs/useOnAction.js +3 -1
- package/lib/commonjs/useOnAction.js.map +1 -1
- package/lib/commonjs/usePreventRemove.js +2 -2
- package/lib/commonjs/usePreventRemove.js.map +1 -1
- package/lib/module/BaseNavigationContainer.js +6 -1
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/theming/ThemeContext.js +4 -0
- package/lib/module/theming/ThemeContext.js.map +1 -0
- package/lib/module/theming/ThemeProvider.js +12 -0
- package/lib/module/theming/ThemeProvider.js.map +1 -0
- package/lib/module/theming/useTheme.js +10 -0
- package/lib/module/theming/useTheme.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/useDescriptors.js +79 -16
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +10 -3
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +55 -14
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useOnAction.js +3 -1
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/usePreventRemove.js +1 -1
- package/lib/module/usePreventRemove.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts +1 -0
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/NavigationStateContext.d.ts +2 -18
- package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
- package/lib/typescript/src/findFocusedRoute.d.ts +1 -9
- package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts +3 -0
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -0
- package/lib/typescript/src/theming/ThemeProvider.d.ts +8 -0
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/src/theming/useTheme.d.ts +2 -0
- package/lib/typescript/src/theming/useTheme.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +47 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts +106 -54
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +57 -64
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts +52 -2
- package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +8 -55
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useOnAction.d.ts.map +1 -1
- package/lib/typescript/src/usePreventRemove.d.ts +1 -1
- package/lib/typescript/src/usePreventRemove.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/BaseNavigationContainer.tsx +6 -1
- package/src/index.tsx +4 -1
- package/src/theming/ThemeContext.tsx +7 -0
- package/src/theming/ThemeProvider.tsx +14 -0
- package/src/theming/useTheme.tsx +15 -0
- package/src/types.tsx +66 -1
- package/src/useDescriptors.tsx +148 -34
- package/src/useNavigationBuilder.tsx +18 -4
- package/src/useNavigationCache.tsx +84 -23
- package/src/useOnAction.tsx +6 -1
- package/src/usePreventRemove.tsx +1 -1
|
@@ -9,12 +9,62 @@ type Options<State extends NavigationState, ScreenOptions extends {}, EventMap e
|
|
|
9
9
|
router: Router<State, NavigationAction>;
|
|
10
10
|
emitter: NavigationEventEmitter<EventMap>;
|
|
11
11
|
};
|
|
12
|
-
type
|
|
12
|
+
type NavigationItem<State extends NavigationState, ScreenOptions extends {}, EventMap extends Record<string, any>> = NavigationProp<ParamListBase, string, string | undefined, State, ScreenOptions, EventMap>;
|
|
13
|
+
type NavigationCache<State extends NavigationState, ScreenOptions extends {}, EventMap extends Record<string, any>> = Record<string, NavigationItem<State, ScreenOptions, EventMap>>;
|
|
13
14
|
/**
|
|
14
15
|
* Hook to cache navigation objects for each screen in the navigator.
|
|
15
16
|
* It's important to cache them to make sure navigation objects don't change between renders.
|
|
16
17
|
* This lets us apply optimizations like `React.memo` to minimize re-rendering screens.
|
|
17
18
|
*/
|
|
18
|
-
export declare function useNavigationCache<State extends NavigationState, ScreenOptions extends {}, EventMap extends Record<string, any>>({ state, getState, navigation, setOptions, router, emitter, }: Options<State, ScreenOptions, EventMap>):
|
|
19
|
+
export declare function useNavigationCache<State extends NavigationState, ScreenOptions extends {}, EventMap extends Record<string, any>, ActionHelpers extends Record<string, () => void>>({ state, getState, navigation, setOptions, router, emitter, }: Options<State, ScreenOptions, EventMap>): {
|
|
20
|
+
base: Omit<{
|
|
21
|
+
dispatch(action: Readonly<{
|
|
22
|
+
type: string;
|
|
23
|
+
payload?: object | undefined;
|
|
24
|
+
source?: string | undefined;
|
|
25
|
+
target?: string | undefined;
|
|
26
|
+
}> | ((state: Readonly<State>) => Readonly<{
|
|
27
|
+
type: string;
|
|
28
|
+
payload?: object | undefined;
|
|
29
|
+
source?: string | undefined;
|
|
30
|
+
target?: string | undefined;
|
|
31
|
+
}>)): void;
|
|
32
|
+
navigate<RouteName extends string>(...args: RouteName extends unknown ? [screen: RouteName] | [screen: RouteName, params: object | undefined] : never): void;
|
|
33
|
+
navigate<RouteName_1 extends string>(options: RouteName_1 extends unknown ? {
|
|
34
|
+
name: RouteName_1;
|
|
35
|
+
params: object | undefined;
|
|
36
|
+
path?: string | undefined;
|
|
37
|
+
merge?: boolean | undefined;
|
|
38
|
+
} : never): void;
|
|
39
|
+
navigateDeprecated<RouteName_2 extends string>(...args: RouteName_2 extends unknown ? [screen: RouteName_2] | [screen: RouteName_2, params: object | undefined] : never): void;
|
|
40
|
+
navigateDeprecated<RouteName_3 extends string>(options: RouteName_3 extends unknown ? {
|
|
41
|
+
name: RouteName_3;
|
|
42
|
+
params: object | undefined;
|
|
43
|
+
merge?: boolean | undefined;
|
|
44
|
+
} : never): void;
|
|
45
|
+
preload<RouteName_4 extends string>(...args: RouteName_4 extends unknown ? [screen: RouteName_4] | [screen: RouteName_4, params: object | undefined] : never): void;
|
|
46
|
+
reset(state: State | import("@react-navigation/routers").PartialState<State>): void;
|
|
47
|
+
goBack(): void;
|
|
48
|
+
isFocused(): boolean;
|
|
49
|
+
canGoBack(): boolean;
|
|
50
|
+
getId(): string | undefined;
|
|
51
|
+
getParent<T = NavigationHelpers<ParamListBase, {}> | undefined>(id?: string | undefined): T;
|
|
52
|
+
getState(): State;
|
|
53
|
+
setStateForNextRouteNamesChange(state: State | import("@react-navigation/routers").PartialState<State>): void;
|
|
54
|
+
} & import("./types").PrivateValueStore<[ParamListBase, unknown, unknown]>, "getParent"> & {
|
|
55
|
+
getParent<T_1 = NavigationProp<ParamListBase, string, undefined, Readonly<{
|
|
56
|
+
key: string;
|
|
57
|
+
index: number;
|
|
58
|
+
routeNames: string[];
|
|
59
|
+
history?: unknown[] | undefined;
|
|
60
|
+
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
61
|
+
type: string;
|
|
62
|
+
stale: false;
|
|
63
|
+
}>, {}, {}> | undefined>(id?: string | undefined): T_1;
|
|
64
|
+
setParams(params: Partial<object | undefined>): void;
|
|
65
|
+
setOptions(options: Partial<ScreenOptions>): void;
|
|
66
|
+
} & import("./types").EventConsumer<EventMap & import("./types").EventMapCore<State>> & import("./types").PrivateValueStore<[ParamListBase, string, EventMap]> & ActionHelpers;
|
|
67
|
+
navigations: NavigationCache<State, ScreenOptions, EventMap>;
|
|
68
|
+
};
|
|
19
69
|
export {};
|
|
20
70
|
//# sourceMappingURL=useNavigationCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigationCache.d.ts","sourceRoot":"","sources":["../../../src/useNavigationCache.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,KAAK,OAAO,CACV,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,EAAE,EACxB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAClC;IACF,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,KAAK,CAAC;IACtB,UAAU,EAAE,iBAAiB,CAAC,aAAa,CAAC,GAC1C,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAChE,UAAU,EAAE,CACV,EAAE,EAAE,CACF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KACnC,MAAM,CAAC,MAAM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AAE,GAAG,CAAC,IAClC,cAAc,CAChB,aAAa,EACb,MAAM,EACN,MAAM,GAAG,SAAS,EAClB,KAAK,EACL,aAAa,EACb,QAAQ,CACT,CAAC;AAEF,KAAK,eAAe,CAClB,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,EAAE,EACxB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAClC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,EAAE,EACxB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,EAChD,EACA,KAAK,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,EACN,OAAO,GACR,EAAE,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4KzC"}
|
|
@@ -23,15 +23,7 @@ export declare function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
23
23
|
index: number;
|
|
24
24
|
routeNames: string[];
|
|
25
25
|
history?: unknown[] | undefined;
|
|
26
|
-
routes: (
|
|
27
|
-
key: string;
|
|
28
|
-
name: string;
|
|
29
|
-
path?: string | undefined;
|
|
30
|
-
}> & Readonly<{
|
|
31
|
-
params?: Readonly<object | undefined>;
|
|
32
|
-
}> & {
|
|
33
|
-
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
34
|
-
})[];
|
|
26
|
+
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
35
27
|
type: string;
|
|
36
28
|
stale: false;
|
|
37
29
|
}>>) => Readonly<{
|
|
@@ -53,20 +45,13 @@ export declare function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
53
45
|
params: object | undefined;
|
|
54
46
|
merge?: boolean | undefined;
|
|
55
47
|
} : never): void;
|
|
48
|
+
preload<RouteName_4 extends string>(...args: RouteName_4 extends unknown ? [screen: RouteName_4] | [screen: RouteName_4, params: object | undefined] : never): void;
|
|
56
49
|
reset(state: Readonly<{
|
|
57
50
|
key: string;
|
|
58
51
|
index: number;
|
|
59
52
|
routeNames: string[];
|
|
60
53
|
history?: unknown[] | undefined;
|
|
61
|
-
routes: (
|
|
62
|
-
key: string;
|
|
63
|
-
name: string;
|
|
64
|
-
path?: string | undefined;
|
|
65
|
-
}> & Readonly<{
|
|
66
|
-
params?: Readonly<object | undefined>;
|
|
67
|
-
}> & {
|
|
68
|
-
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
69
|
-
})[];
|
|
54
|
+
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
70
55
|
type: string;
|
|
71
56
|
stale: false;
|
|
72
57
|
}> | import("@react-navigation/routers").PartialState<Readonly<{
|
|
@@ -74,15 +59,7 @@ export declare function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
74
59
|
index: number;
|
|
75
60
|
routeNames: string[];
|
|
76
61
|
history?: unknown[] | undefined;
|
|
77
|
-
routes: (
|
|
78
|
-
key: string;
|
|
79
|
-
name: string;
|
|
80
|
-
path?: string | undefined;
|
|
81
|
-
}> & Readonly<{
|
|
82
|
-
params?: Readonly<object | undefined>;
|
|
83
|
-
}> & {
|
|
84
|
-
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
85
|
-
})[];
|
|
62
|
+
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
86
63
|
type: string;
|
|
87
64
|
stale: false;
|
|
88
65
|
}>>): void;
|
|
@@ -96,15 +73,7 @@ export declare function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
96
73
|
index: number;
|
|
97
74
|
routeNames: string[];
|
|
98
75
|
history?: unknown[] | undefined;
|
|
99
|
-
routes: (
|
|
100
|
-
key: string;
|
|
101
|
-
name: string;
|
|
102
|
-
path?: string | undefined;
|
|
103
|
-
}> & Readonly<{
|
|
104
|
-
params?: Readonly<object | undefined>;
|
|
105
|
-
}> & {
|
|
106
|
-
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
107
|
-
})[];
|
|
76
|
+
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
108
77
|
type: string;
|
|
109
78
|
stale: false;
|
|
110
79
|
}>;
|
|
@@ -113,15 +82,7 @@ export declare function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
113
82
|
index: number;
|
|
114
83
|
routeNames: string[];
|
|
115
84
|
history?: unknown[] | undefined;
|
|
116
|
-
routes: (
|
|
117
|
-
key: string;
|
|
118
|
-
name: string;
|
|
119
|
-
path?: string | undefined;
|
|
120
|
-
}> & Readonly<{
|
|
121
|
-
params?: Readonly<object | undefined>;
|
|
122
|
-
}> & {
|
|
123
|
-
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
124
|
-
})[];
|
|
85
|
+
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
125
86
|
type: string;
|
|
126
87
|
stale: false;
|
|
127
88
|
}> | import("@react-navigation/routers").PartialState<Readonly<{
|
|
@@ -129,20 +90,12 @@ export declare function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
129
90
|
index: number;
|
|
130
91
|
routeNames: string[];
|
|
131
92
|
history?: unknown[] | undefined;
|
|
132
|
-
routes: (
|
|
133
|
-
key: string;
|
|
134
|
-
name: string;
|
|
135
|
-
path?: string | undefined;
|
|
136
|
-
}> & Readonly<{
|
|
137
|
-
params?: Readonly<object | undefined>;
|
|
138
|
-
}> & {
|
|
139
|
-
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
140
|
-
})[];
|
|
93
|
+
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
141
94
|
type: string;
|
|
142
95
|
stale: false;
|
|
143
96
|
}>>): void;
|
|
144
97
|
} & PrivateValueStore<[ParamListBase, unknown, unknown]> & import("./types").EventEmitter<EventMap> & {
|
|
145
|
-
setParams<
|
|
98
|
+
setParams<RouteName_5 extends string>(params: Partial<object | undefined>): void;
|
|
146
99
|
} & ActionHelpers;
|
|
147
100
|
export {};
|
|
148
101
|
//# sourceMappingURL=useNavigationHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigationHelpers.d.ts","sourceRoot":"","sources":["../../../src/useNavigationHelpers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,KAAK,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAKhE,KAAK,OAAO,CAAC,KAAK,SAAS,eAAe,EAAE,MAAM,SAAS,gBAAgB,IAAI;IAC7E,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC;IAChD,QAAQ,EAAE,MAAM,KAAK,CAAC;IACtB,OAAO,EAAE,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,EAChD,MAAM,SAAS,gBAAgB,EAC/B,QAAQ,SAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0ExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnAction.d.ts","sourceRoot":"","sources":["../../../src/useOnAction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,MAAM,EACN,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAGhE,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,eAAe,CAAC;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAC3E,eAAe,EAAE,mBAAmB,EAAE,CAAC;IACvC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,GAAG,SAAS,CAAC,CAAC;IAC7E,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,OAAO,GACR,EAAE,OAAO,YAoBI,gBAAgB,sBACL,IAAI,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"useOnAction.d.ts","sourceRoot":"","sources":["../../../src/useOnAction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,MAAM,EACN,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAGhE,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,eAAe,CAAC;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAC3E,eAAe,EAAE,mBAAmB,EAAE,CAAC;IACvC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,GAAG,SAAS,CAAC,CAAC;IAC7E,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,OAAO,GACR,EAAE,OAAO,YAoBI,gBAAgB,sBACL,IAAI,MAAM,CAAC,aA8GnC"}
|
|
@@ -5,7 +5,7 @@ import type { NavigationAction } from '@react-navigation/routers';
|
|
|
5
5
|
* @param preventRemove Boolean indicating whether to prevent screen from being removed.
|
|
6
6
|
* @param callback Function which is executed when screen was prevented from being removed.
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function usePreventRemove(preventRemove: boolean, callback: (options: {
|
|
9
9
|
data: {
|
|
10
10
|
action: NavigationAction;
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreventRemove.d.ts","sourceRoot":"","sources":["../../../src/usePreventRemove.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUlE;;;;;GAKG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"usePreventRemove.d.ts","sourceRoot":"","sources":["../../../src/usePreventRemove.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUlE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,OAAO,EACtB,QAAQ,EAAE,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE;QAAE,MAAM,EAAE,gBAAgB,CAAA;KAAE,CAAA;CAAE,KAAK,IAAI,QAgCpE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/core",
|
|
3
3
|
"description": "Core utilities for building navigators",
|
|
4
|
-
"version": "7.0.0-alpha.
|
|
4
|
+
"version": "7.0.0-alpha.7",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
7
7
|
"react-native",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"clean": "del lib"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@react-navigation/routers": "^7.0.0-alpha.
|
|
38
|
+
"@react-navigation/routers": "^7.0.0-alpha.5",
|
|
39
39
|
"escape-string-regexp": "^4.0.0",
|
|
40
40
|
"nanoid": "3.3.6",
|
|
41
41
|
"query-string": "^7.1.3",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
]
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "d0e6a2cd79d2c6aff0cf54e46e31edc407c3c46b"
|
|
74
74
|
}
|
|
@@ -20,6 +20,7 @@ import { NavigationBuilderContext } from './NavigationBuilderContext';
|
|
|
20
20
|
import { NavigationContainerRefContext } from './NavigationContainerRefContext';
|
|
21
21
|
import { NavigationIndependentTreeContext } from './NavigationIndependentTreeContext';
|
|
22
22
|
import { NavigationStateContext } from './NavigationStateContext';
|
|
23
|
+
import { ThemeProvider } from './theming/ThemeProvider';
|
|
23
24
|
import type {
|
|
24
25
|
NavigationContainerEventMap,
|
|
25
26
|
NavigationContainerProps,
|
|
@@ -76,6 +77,7 @@ const getPartialState = (
|
|
|
76
77
|
* @param props.onReady Callback which is called after the navigation tree mounts.
|
|
77
78
|
* @param props.onStateChange Callback which is called with the latest navigation state when it changes.
|
|
78
79
|
* @param props.onUnhandledAction Callback which is called when an action is not handled.
|
|
80
|
+
* @param props.theme Theme object for the UI elements.
|
|
79
81
|
* @param props.children Child elements to render the content.
|
|
80
82
|
* @param props.ref Ref object which refers to the navigation object containing helper methods.
|
|
81
83
|
*/
|
|
@@ -87,6 +89,7 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
87
89
|
onReady,
|
|
88
90
|
onUnhandledAction,
|
|
89
91
|
navigationInChildEnabled = false,
|
|
92
|
+
theme,
|
|
90
93
|
children,
|
|
91
94
|
}: NavigationContainerProps,
|
|
92
95
|
ref?: React.Ref<NavigationContainerRef<ParamListBase>>
|
|
@@ -434,7 +437,9 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
434
437
|
<DeprecatedNavigationInChildContext.Provider
|
|
435
438
|
value={navigationInChildEnabled}
|
|
436
439
|
>
|
|
437
|
-
<EnsureSingleNavigator>
|
|
440
|
+
<EnsureSingleNavigator>
|
|
441
|
+
<ThemeProvider value={theme}>{children}</ThemeProvider>
|
|
442
|
+
</EnsureSingleNavigator>
|
|
438
443
|
</DeprecatedNavigationInChildContext.Provider>
|
|
439
444
|
</UnhandledActionContext.Provider>
|
|
440
445
|
</NavigationStateContext.Provider>
|
package/src/index.tsx
CHANGED
|
@@ -21,6 +21,9 @@ export {
|
|
|
21
21
|
type StaticParamList,
|
|
22
22
|
type StaticScreenProps,
|
|
23
23
|
} from './StaticNavigation';
|
|
24
|
+
export { ThemeContext } from './theming/ThemeContext';
|
|
25
|
+
export { ThemeProvider } from './theming/ThemeProvider';
|
|
26
|
+
export { useTheme } from './theming/useTheme';
|
|
24
27
|
export * from './types';
|
|
25
28
|
export { useFocusEffect } from './useFocusEffect';
|
|
26
29
|
export { useIsFocused } from './useIsFocused';
|
|
@@ -29,7 +32,7 @@ export { useNavigationBuilder } from './useNavigationBuilder';
|
|
|
29
32
|
export { useNavigationContainerRef } from './useNavigationContainerRef';
|
|
30
33
|
export { useNavigationIndependentTree } from './useNavigationIndependentTree';
|
|
31
34
|
export { useNavigationState } from './useNavigationState';
|
|
32
|
-
export {
|
|
35
|
+
export { usePreventRemove } from './usePreventRemove';
|
|
33
36
|
export { usePreventRemoveContext } from './usePreventRemoveContext';
|
|
34
37
|
export { useRoute } from './useRoute';
|
|
35
38
|
export { validatePathConfig } from './validatePathConfig';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { ThemeContext } from './ThemeContext';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
value: ReactNavigation.Theme | undefined;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function ThemeProvider({ value, children }: Props) {
|
|
11
|
+
return (
|
|
12
|
+
<ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { ThemeContext } from './ThemeContext';
|
|
4
|
+
|
|
5
|
+
export function useTheme() {
|
|
6
|
+
const theme = React.useContext(ThemeContext);
|
|
7
|
+
|
|
8
|
+
if (theme == null) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
"Couldn't find a theme. Is your component inside NavigationContainer or does it have a theme?"
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return theme;
|
|
15
|
+
}
|
package/src/types.tsx
CHANGED
|
@@ -14,6 +14,9 @@ declare global {
|
|
|
14
14
|
namespace ReactNavigation {
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
16
16
|
interface RootParamList {}
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
19
|
+
interface Theme {}
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -29,13 +32,15 @@ export type DefaultNavigatorOptions<
|
|
|
29
32
|
* Optional ID for the navigator. Can be used with `navigation.getParent(id)` to refer to a parent.
|
|
30
33
|
*/
|
|
31
34
|
id?: string;
|
|
35
|
+
|
|
32
36
|
/**
|
|
33
37
|
* Children React Elements to extract the route configuration from.
|
|
34
38
|
* Only `Screen`, `Group` and `React.Fragment` are supported as children.
|
|
35
39
|
*/
|
|
36
40
|
children: React.ReactNode;
|
|
41
|
+
|
|
37
42
|
/**
|
|
38
|
-
* Layout
|
|
43
|
+
* Layout for the navigator.
|
|
39
44
|
* Useful for wrapping with a component with access to navigator's state and options.
|
|
40
45
|
*/
|
|
41
46
|
layout?: (props: {
|
|
@@ -58,6 +63,7 @@ export type DefaultNavigatorOptions<
|
|
|
58
63
|
>;
|
|
59
64
|
children: React.ReactNode;
|
|
60
65
|
}) => React.ReactElement;
|
|
66
|
+
|
|
61
67
|
/**
|
|
62
68
|
* Event listeners for all the screens in the navigator.
|
|
63
69
|
*/
|
|
@@ -67,6 +73,7 @@ export type DefaultNavigatorOptions<
|
|
|
67
73
|
route: RouteProp<ParamList>;
|
|
68
74
|
navigation: any;
|
|
69
75
|
}) => ScreenListeners<State, EventMap>);
|
|
76
|
+
|
|
70
77
|
/**
|
|
71
78
|
* Default options for all screens under this navigator.
|
|
72
79
|
*/
|
|
@@ -75,7 +82,19 @@ export type DefaultNavigatorOptions<
|
|
|
75
82
|
| ((props: {
|
|
76
83
|
route: RouteProp<ParamList>;
|
|
77
84
|
navigation: any;
|
|
85
|
+
theme: ReactNavigation.Theme;
|
|
78
86
|
}) => ScreenOptions);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Layout for all screens under this navigator.
|
|
90
|
+
*/
|
|
91
|
+
screenLayout?: (props: {
|
|
92
|
+
route: RouteProp<ParamList, keyof ParamList>;
|
|
93
|
+
navigation: any;
|
|
94
|
+
theme: ReactNavigation.Theme;
|
|
95
|
+
children: React.ReactElement;
|
|
96
|
+
}) => React.ReactElement;
|
|
97
|
+
|
|
79
98
|
/**
|
|
80
99
|
A function returning a state, which may be set after modifying the routes name.
|
|
81
100
|
*/
|
|
@@ -281,6 +300,22 @@ type NavigationHelpersCommon<
|
|
|
281
300
|
: never
|
|
282
301
|
): void;
|
|
283
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Preloads the route in current navigation tree.
|
|
305
|
+
*
|
|
306
|
+
* @param name Name of the route to navigate to.
|
|
307
|
+
* @param [params] Params object for the route.
|
|
308
|
+
*/
|
|
309
|
+
preload<RouteName extends keyof ParamList>(
|
|
310
|
+
...args: RouteName extends unknown
|
|
311
|
+
? undefined extends ParamList[RouteName]
|
|
312
|
+
?
|
|
313
|
+
| [screen: RouteName]
|
|
314
|
+
| [screen: RouteName, params: ParamList[RouteName]]
|
|
315
|
+
: [screen: RouteName, params: ParamList[RouteName]]
|
|
316
|
+
: never
|
|
317
|
+
): void;
|
|
318
|
+
|
|
284
319
|
/**
|
|
285
320
|
* Reset the navigation state to the provided state.
|
|
286
321
|
*
|
|
@@ -379,6 +414,10 @@ export type NavigationContainerProps = {
|
|
|
379
414
|
* @deprecated Use nested navigation API instead
|
|
380
415
|
*/
|
|
381
416
|
navigationInChildEnabled?: boolean;
|
|
417
|
+
/**
|
|
418
|
+
* Theme object for the UI elements.
|
|
419
|
+
*/
|
|
420
|
+
theme?: ReactNavigation.Theme;
|
|
382
421
|
/**
|
|
383
422
|
* Children elements to render.
|
|
384
423
|
*/
|
|
@@ -590,6 +629,7 @@ export type RouteConfig<
|
|
|
590
629
|
| ((props: {
|
|
591
630
|
route: RouteProp<ParamList, RouteName>;
|
|
592
631
|
navigation: any;
|
|
632
|
+
theme: ReactNavigation.Theme;
|
|
593
633
|
}) => ScreenOptions);
|
|
594
634
|
|
|
595
635
|
/**
|
|
@@ -602,6 +642,18 @@ export type RouteConfig<
|
|
|
602
642
|
navigation: any;
|
|
603
643
|
}) => ScreenListeners<State, EventMap>);
|
|
604
644
|
|
|
645
|
+
/**
|
|
646
|
+
* Layout for this screen.
|
|
647
|
+
* Useful for wrapping the screen with custom containers.
|
|
648
|
+
* e.g. for styling, error boundaries, suspense, etc.
|
|
649
|
+
*/
|
|
650
|
+
layout?: (props: {
|
|
651
|
+
route: RouteProp<ParamList, keyof ParamList>;
|
|
652
|
+
navigation: any;
|
|
653
|
+
theme: ReactNavigation.Theme;
|
|
654
|
+
children: React.ReactElement;
|
|
655
|
+
}) => React.ReactElement;
|
|
656
|
+
|
|
605
657
|
/**
|
|
606
658
|
* Function to return an unique ID for this screen.
|
|
607
659
|
* Receives an object with the route params.
|
|
@@ -638,7 +690,20 @@ export type RouteGroupConfig<
|
|
|
638
690
|
| ((props: {
|
|
639
691
|
route: RouteProp<ParamList, keyof ParamList>;
|
|
640
692
|
navigation: any;
|
|
693
|
+
theme: ReactNavigation.Theme;
|
|
641
694
|
}) => ScreenOptions);
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Layout for the screens inside the group.
|
|
698
|
+
* This will override the `screenLayout` of parent group or navigator.
|
|
699
|
+
*/
|
|
700
|
+
screenLayout?: (props: {
|
|
701
|
+
route: RouteProp<ParamList, keyof ParamList>;
|
|
702
|
+
navigation: any;
|
|
703
|
+
theme: ReactNavigation.Theme;
|
|
704
|
+
children: React.ReactElement;
|
|
705
|
+
}) => React.ReactElement;
|
|
706
|
+
|
|
642
707
|
/**
|
|
643
708
|
* Children React Elements to extract the route configuration from.
|
|
644
709
|
* Only `Screen`, `Group` and `React.Fragment` are supported as children.
|