@react-navigation/core 6.0.3 → 6.2.0
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 +13 -9
- package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
- package/lib/commonjs/CurrentRenderContext.js.map +1 -1
- package/lib/commonjs/EnsureSingleNavigator.js +5 -4
- package/lib/commonjs/EnsureSingleNavigator.js.map +1 -1
- package/lib/commonjs/NavigationContainerRefContext.js.map +1 -1
- package/lib/commonjs/NavigationContext.js.map +1 -1
- package/lib/commonjs/NavigationHelpersContext.js.map +1 -1
- package/lib/commonjs/NavigationRouteContext.js.map +1 -1
- package/lib/commonjs/SceneView.js +11 -10
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/UnhandledActionContext.js.map +1 -1
- package/lib/commonjs/createNavigationContainerRef.js +11 -6
- package/lib/commonjs/createNavigationContainerRef.js.map +1 -1
- package/lib/commonjs/fromEntries.js +3 -1
- package/lib/commonjs/fromEntries.js.map +1 -1
- package/lib/commonjs/getActionFromState.js +2 -1
- package/lib/commonjs/getActionFromState.js.map +1 -1
- package/lib/commonjs/getPathFromState.js +13 -3
- package/lib/commonjs/getPathFromState.js.map +1 -1
- package/lib/commonjs/getStateFromPath.js +12 -2
- package/lib/commonjs/getStateFromPath.js.map +1 -1
- package/lib/commonjs/index.js +24 -24
- package/lib/commonjs/isArrayEqual.js +9 -1
- package/lib/commonjs/isArrayEqual.js.map +1 -1
- package/lib/commonjs/isRecordEqual.js +25 -0
- package/lib/commonjs/isRecordEqual.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useChildListeners.js.map +1 -1
- package/lib/commonjs/useCurrentRender.js +6 -5
- package/lib/commonjs/useCurrentRender.js.map +1 -1
- package/lib/commonjs/useDescriptors.js +18 -17
- package/lib/commonjs/useDescriptors.js.map +1 -1
- package/lib/commonjs/useEventEmitter.js +7 -6
- package/lib/commonjs/useEventEmitter.js.map +1 -1
- package/lib/commonjs/useFocusEvents.js +5 -4
- package/lib/commonjs/useFocusEvents.js.map +1 -1
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js +5 -4
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/commonjs/useKeyedChildListeners.js.map +1 -1
- package/lib/commonjs/useNavigationBuilder.js +52 -20
- package/lib/commonjs/useNavigationBuilder.js.map +1 -1
- package/lib/commonjs/useNavigationCache.js +26 -10
- package/lib/commonjs/useNavigationCache.js.map +1 -1
- package/lib/commonjs/useNavigationHelpers.js +32 -10
- package/lib/commonjs/useNavigationHelpers.js.map +1 -1
- package/lib/commonjs/useOnAction.js +13 -11
- package/lib/commonjs/useOnAction.js.map +1 -1
- package/lib/commonjs/useOnGetState.js +5 -4
- package/lib/commonjs/useOnGetState.js.map +1 -1
- package/lib/commonjs/useOnPreventRemove.js +6 -5
- package/lib/commonjs/useOnPreventRemove.js.map +1 -1
- package/lib/commonjs/useOnRouteFocus.js +7 -6
- package/lib/commonjs/useOnRouteFocus.js.map +1 -1
- package/lib/commonjs/useOptionsGetters.js +6 -5
- package/lib/commonjs/useOptionsGetters.js.map +1 -1
- package/lib/commonjs/useRouteCache.js +1 -1
- package/lib/commonjs/useScheduleUpdate.js +1 -1
- package/lib/commonjs/validatePathConfig.js +5 -2
- package/lib/commonjs/validatePathConfig.js.map +1 -1
- package/lib/module/BaseNavigationContainer.js +13 -9
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/CurrentRenderContext.js.map +1 -1
- package/lib/module/EnsureSingleNavigator.js +4 -3
- package/lib/module/EnsureSingleNavigator.js.map +1 -1
- package/lib/module/NavigationContainerRefContext.js.map +1 -1
- package/lib/module/NavigationContext.js.map +1 -1
- package/lib/module/NavigationHelpersContext.js.map +1 -1
- package/lib/module/NavigationRouteContext.js.map +1 -1
- package/lib/module/SceneView.js +11 -10
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/UnhandledActionContext.js.map +1 -1
- package/lib/module/createNavigationContainerRef.js +10 -5
- package/lib/module/createNavigationContainerRef.js.map +1 -1
- package/lib/module/fromEntries.js +3 -1
- package/lib/module/fromEntries.js.map +1 -1
- package/lib/module/getActionFromState.js +2 -1
- package/lib/module/getActionFromState.js.map +1 -1
- package/lib/module/getPathFromState.js +13 -3
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getStateFromPath.js +12 -2
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/isArrayEqual.js +9 -1
- package/lib/module/isArrayEqual.js.map +1 -1
- package/lib/module/isRecordEqual.js +18 -0
- package/lib/module/isRecordEqual.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/useChildListeners.js.map +1 -1
- package/lib/module/useCurrentRender.js +6 -5
- package/lib/module/useCurrentRender.js.map +1 -1
- package/lib/module/useDescriptors.js +18 -17
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useEventEmitter.js +7 -6
- package/lib/module/useEventEmitter.js.map +1 -1
- package/lib/module/useFocusEvents.js +5 -4
- package/lib/module/useFocusEvents.js.map +1 -1
- package/lib/module/useFocusedListenersChildrenAdapter.js +5 -4
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/module/useKeyedChildListeners.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +51 -20
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +26 -10
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationHelpers.js +32 -10
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useOnAction.js +13 -11
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnGetState.js +5 -4
- package/lib/module/useOnGetState.js.map +1 -1
- package/lib/module/useOnPreventRemove.js +6 -5
- package/lib/module/useOnPreventRemove.js.map +1 -1
- package/lib/module/useOnRouteFocus.js +7 -6
- package/lib/module/useOnRouteFocus.js.map +1 -1
- package/lib/module/useOptionsGetters.js +6 -5
- package/lib/module/useOptionsGetters.js.map +1 -1
- package/lib/module/validatePathConfig.js +5 -2
- package/lib/module/validatePathConfig.js.map +1 -1
- package/lib/typescript/src/NavigationContext.d.ts +1 -1
- package/lib/typescript/src/SceneView.d.ts +1 -1
- package/lib/typescript/src/isRecordEqual.d.ts +4 -0
- package/lib/typescript/src/types.d.ts +50 -18
- package/lib/typescript/src/useDescriptors.d.ts +13 -10
- package/lib/typescript/src/useNavigationBuilder.d.ts +12 -73
- package/lib/typescript/src/useNavigationCache.d.ts +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +7 -69
- package/package.json +5 -5
- package/src/CurrentRenderContext.tsx +3 -2
- package/src/EnsureSingleNavigator.tsx +7 -8
- package/src/NavigationContainerRefContext.tsx +3 -4
- package/src/NavigationContext.tsx +3 -2
- package/src/NavigationHelpersContext.tsx +3 -2
- package/src/NavigationRouteContext.tsx +3 -2
- package/src/SceneView.tsx +7 -1
- package/src/UnhandledActionContext.tsx +3 -4
- package/src/createNavigationContainerRef.tsx +3 -1
- package/src/isArrayEqual.tsx +9 -1
- package/src/isRecordEqual.tsx +20 -0
- package/src/types.tsx +70 -21
- package/src/useChildListeners.tsx +3 -5
- package/src/useDescriptors.tsx +16 -8
- package/src/useKeyedChildListeners.tsx +6 -8
- package/src/useNavigationBuilder.tsx +90 -27
- package/src/useNavigationCache.tsx +17 -1
- package/src/useNavigationHelpers.tsx +39 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOnRouteFocus.tsx"],"names":["React","NavigationBuilderContext","useOnRouteFocus","router","getState","key","sourceRouteKey","setState","onRouteFocus","onRouteFocusParent","useContext","useCallback","state","result","getStateForRouteFocus","undefined"],"mappings":"AAKA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,wBAAP,MAAqC,4BAArC;;AASA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAT,
|
|
1
|
+
{"version":3,"sources":["useOnRouteFocus.tsx"],"names":["React","NavigationBuilderContext","useOnRouteFocus","router","getState","key","sourceRouteKey","setState","onRouteFocus","onRouteFocusParent","useContext","useCallback","state","result","getStateForRouteFocus","undefined"],"mappings":"AAKA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,wBAAP,MAAqC,4BAArC;;AASA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAT,OAKK;AAAA,MALqD;AACvEC,IAAAA,MADuE;AAEvEC,IAAAA,QAFuE;AAGvEC,IAAAA,GAAG,EAAEC,cAHkE;AAIvEC,IAAAA;AAJuE,GAKrD;AAClB,QAAM;AAAEC,IAAAA,YAAY,EAAEC;AAAhB,MAAuCT,KAAK,CAACU,UAAN,CAC3CT,wBAD2C,CAA7C;AAIA,SAAOD,KAAK,CAACW,WAAN,CACJN,GAAD,IAAiB;AACf,UAAMO,KAAK,GAAGR,QAAQ,EAAtB;AACA,UAAMS,MAAM,GAAGV,MAAM,CAACW,qBAAP,CAA6BF,KAA7B,EAAoCP,GAApC,CAAf;;AAEA,QAAIQ,MAAM,KAAKD,KAAf,EAAsB;AACpBL,MAAAA,QAAQ,CAACM,MAAD,CAAR;AACD;;AAED,QAAIJ,kBAAkB,KAAKM,SAAvB,IAAoCT,cAAc,KAAKS,SAA3D,EAAsE;AACpEN,MAAAA,kBAAkB,CAACH,cAAD,CAAlB;AACD;AACF,GAZI,EAaL,CAACF,QAAD,EAAWK,kBAAX,EAA+BN,MAA/B,EAAuCI,QAAvC,EAAiDD,cAAjD,CAbK,CAAP;AAeD","sourcesContent":["import type {\n NavigationAction,\n NavigationState,\n Router,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationBuilderContext from './NavigationBuilderContext';\n\ntype Options<Action extends NavigationAction> = {\n router: Router<NavigationState, Action>;\n getState: () => NavigationState;\n setState: (state: NavigationState) => void;\n key?: string;\n};\n\n/**\n * Hook to handle focus actions for a route.\n * Focus action needs to be treated specially, coz when a nested route is focused,\n * the parent navigators also needs to be focused.\n */\nexport default function useOnRouteFocus<Action extends NavigationAction>({\n router,\n getState,\n key: sourceRouteKey,\n setState,\n}: Options<Action>) {\n const { onRouteFocus: onRouteFocusParent } = React.useContext(\n NavigationBuilderContext\n );\n\n return React.useCallback(\n (key: string) => {\n const state = getState();\n const result = router.getStateForRouteFocus(state, key);\n\n if (result !== state) {\n setState(result);\n }\n\n if (onRouteFocusParent !== undefined && sourceRouteKey !== undefined) {\n onRouteFocusParent(sourceRouteKey);\n }\n },\n [getState, onRouteFocusParent, router, setState, sourceRouteKey]\n );\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import NavigationBuilderContext from './NavigationBuilderContext';
|
|
3
3
|
import NavigationStateContext from './NavigationStateContext';
|
|
4
|
-
export default function useOptionsGetters({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export default function useOptionsGetters(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
key,
|
|
7
|
+
options,
|
|
8
|
+
navigation
|
|
9
|
+
} = _ref;
|
|
9
10
|
const optionsRef = React.useRef(options);
|
|
10
11
|
const optionsGettersFromChildRef = React.useRef({});
|
|
11
12
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOptionsGetters.tsx"],"names":["React","NavigationBuilderContext","NavigationStateContext","useOptionsGetters","key","options","navigation","optionsRef","useRef","optionsGettersFromChildRef","onOptionsChange","useContext","addOptionsGetter","parentAddOptionsGetter","optionsChangeListener","useCallback","isFocused","hasChildren","Object","keys","current","length","useEffect","addListener","getOptionsFromListener","hasOwnProperty","result","getCurrentOptions","optionsFromListener","getter"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,wBAAP,MAAqC,4BAArC;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AASA,eAAe,SAASC,iBAAT,
|
|
1
|
+
{"version":3,"sources":["useOptionsGetters.tsx"],"names":["React","NavigationBuilderContext","NavigationStateContext","useOptionsGetters","key","options","navigation","optionsRef","useRef","optionsGettersFromChildRef","onOptionsChange","useContext","addOptionsGetter","parentAddOptionsGetter","optionsChangeListener","useCallback","isFocused","hasChildren","Object","keys","current","length","useEffect","addListener","getOptionsFromListener","hasOwnProperty","result","getCurrentOptions","optionsFromListener","getter"],"mappings":"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","sourcesContent":["import type { ParamListBase } from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationBuilderContext from './NavigationBuilderContext';\nimport NavigationStateContext from './NavigationStateContext';\nimport type { NavigationProp } from './types';\n\ntype Options = {\n key?: string;\n navigation?: NavigationProp<ParamListBase>;\n options?: object | undefined;\n};\n\nexport default function useOptionsGetters({\n key,\n options,\n navigation,\n}: Options) {\n const optionsRef = React.useRef<object | undefined>(options);\n const optionsGettersFromChildRef = React.useRef<\n Record<string, () => object | undefined | null>\n >({});\n\n const { onOptionsChange } = React.useContext(NavigationBuilderContext);\n const { addOptionsGetter: parentAddOptionsGetter } = React.useContext(\n NavigationStateContext\n );\n\n const optionsChangeListener = React.useCallback(() => {\n const isFocused = navigation?.isFocused() ?? true;\n const hasChildren = Object.keys(optionsGettersFromChildRef.current).length;\n\n if (isFocused && !hasChildren) {\n onOptionsChange(optionsRef.current ?? {});\n }\n }, [navigation, onOptionsChange]);\n\n React.useEffect(() => {\n optionsRef.current = options;\n optionsChangeListener();\n\n return navigation?.addListener('focus', optionsChangeListener);\n }, [navigation, options, optionsChangeListener]);\n\n const getOptionsFromListener = React.useCallback(() => {\n for (let key in optionsGettersFromChildRef.current) {\n if (optionsGettersFromChildRef.current.hasOwnProperty(key)) {\n const result = optionsGettersFromChildRef.current[key]?.();\n\n // null means unfocused route\n if (result !== null) {\n return result;\n }\n }\n }\n\n return null;\n }, []);\n\n const getCurrentOptions = React.useCallback(() => {\n const isFocused = navigation?.isFocused() ?? true;\n\n if (!isFocused) {\n return null;\n }\n\n const optionsFromListener = getOptionsFromListener();\n\n if (optionsFromListener !== null) {\n return optionsFromListener;\n }\n\n return optionsRef.current;\n }, [navigation, getOptionsFromListener]);\n\n React.useEffect(() => {\n return parentAddOptionsGetter?.(key!, getCurrentOptions);\n }, [getCurrentOptions, parentAddOptionsGetter, key]);\n\n const addOptionsGetter = React.useCallback(\n (key: string, getter: () => object | undefined | null) => {\n optionsGettersFromChildRef.current[key] = getter;\n optionsChangeListener();\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete optionsGettersFromChildRef.current[key];\n optionsChangeListener();\n };\n },\n [optionsChangeListener]\n );\n\n return {\n addOptionsGetter,\n getCurrentOptions,\n };\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const formatToList = items => items.map(key => `- ${key}`).join('\n');
|
|
2
2
|
|
|
3
|
-
export default function validatePathConfig(config
|
|
3
|
+
export default function validatePathConfig(config) {
|
|
4
|
+
let root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
4
5
|
const validKeys = ['initialRouteName', 'screens'];
|
|
5
6
|
|
|
6
7
|
if (!root) {
|
|
@@ -14,7 +15,9 @@ export default function validatePathConfig(config, root = true) {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
if (config.screens) {
|
|
17
|
-
Object.entries(config.screens).forEach(
|
|
18
|
+
Object.entries(config.screens).forEach(_ref => {
|
|
19
|
+
let [_, value] = _ref;
|
|
20
|
+
|
|
18
21
|
if (typeof value !== 'string') {
|
|
19
22
|
validatePathConfig(value, false);
|
|
20
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["validatePathConfig.tsx"],"names":["formatToList","items","map","key","join","validatePathConfig","config","root","validKeys","push","invalidKeys","Object","keys","filter","includes","length","Error","screens","entries","forEach","_","value"],"mappings":"AAAA,MAAMA,YAAY,GAAIC,KAAD,IACnBA,KAAK,CAACC,GAAN,CAAWC,GAAD,IAAU,KAAIA,GAAI,EAA5B,EAA+BC,IAA/B,CAAoC,IAApC,CADF;;AAGA,eAAe,SAASC,kBAAT,CAA4BC,MAA5B,
|
|
1
|
+
{"version":3,"sources":["validatePathConfig.tsx"],"names":["formatToList","items","map","key","join","validatePathConfig","config","root","validKeys","push","invalidKeys","Object","keys","filter","includes","length","Error","screens","entries","forEach","_","value"],"mappings":"AAAA,MAAMA,YAAY,GAAIC,KAAD,IACnBA,KAAK,CAACC,GAAN,CAAWC,GAAD,IAAU,KAAIA,GAAI,EAA5B,EAA+BC,IAA/B,CAAoC,IAApC,CADF;;AAGA,eAAe,SAASC,kBAAT,CAA4BC,MAA5B,EAAsD;AAAA,MAAbC,IAAa,uEAAN,IAAM;AACnE,QAAMC,SAAS,GAAG,CAAC,kBAAD,EAAqB,SAArB,CAAlB;;AAEA,MAAI,CAACD,IAAL,EAAW;AACTC,IAAAA,SAAS,CAACC,IAAV,CAAe,MAAf,EAAuB,OAAvB,EAAgC,WAAhC,EAA6C,OAA7C;AACD;;AAED,QAAMC,WAAW,GAAGC,MAAM,CAACC,IAAP,CAAYN,MAAZ,EAAoBO,MAApB,CACjBV,GAAD,IAAS,CAACK,SAAS,CAACM,QAAV,CAAmBX,GAAnB,CADQ,CAApB;;AAIA,MAAIO,WAAW,CAACK,MAAhB,EAAwB;AACtB,UAAM,IAAIC,KAAJ,CACH,mDAAkDhB,YAAY,CAC7DU,WAD6D,CAE7D,qHAAoHV,YAAY,CAChIQ,SADgI,CAEhI,wHALE,CAAN;AAOD;;AAED,MAAIF,MAAM,CAACW,OAAX,EAAoB;AAClBN,IAAAA,MAAM,CAACO,OAAP,CAAeZ,MAAM,CAACW,OAAtB,EAA+BE,OAA/B,CAAuC,QAAgB;AAAA,UAAf,CAACC,CAAD,EAAIC,KAAJ,CAAe;;AACrD,UAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC7BhB,QAAAA,kBAAkB,CAACgB,KAAD,EAAQ,KAAR,CAAlB;AACD;AACF,KAJD;AAKD;AACF","sourcesContent":["const formatToList = (items: string[]) =>\n items.map((key) => `- ${key}`).join('\\n');\n\nexport default function validatePathConfig(config: any, root = true) {\n const validKeys = ['initialRouteName', 'screens'];\n\n if (!root) {\n validKeys.push('path', 'exact', 'stringify', 'parse');\n }\n\n const invalidKeys = Object.keys(config).filter(\n (key) => !validKeys.includes(key)\n );\n\n if (invalidKeys.length) {\n throw new Error(\n `Found invalid properties in the configuration:\\n${formatToList(\n invalidKeys\n )}\\n\\nDid you forget to specify them under a 'screens' property?\\n\\nYou can only specify the following properties:\\n${formatToList(\n validKeys\n )}\\n\\nSee https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`\n );\n }\n\n if (config.screens) {\n Object.entries(config.screens).forEach(([_, value]) => {\n if (typeof value !== 'string') {\n validatePathConfig(value, false);\n }\n });\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import type { NavigationProp } from './types';
|
|
|
4
4
|
/**
|
|
5
5
|
* Context which holds the navigation prop for a screen.
|
|
6
6
|
*/
|
|
7
|
-
declare const NavigationContext: React.Context<NavigationProp<ParamListBase, string, Readonly<{
|
|
7
|
+
declare const NavigationContext: React.Context<NavigationProp<ParamListBase, string, undefined, Readonly<{
|
|
8
8
|
key: string;
|
|
9
9
|
index: number;
|
|
10
10
|
routeNames: string[];
|
|
@@ -5,7 +5,7 @@ declare type Props<State extends NavigationState, ScreenOptions extends {}> = {
|
|
|
5
5
|
screen: RouteConfigComponent<ParamListBase, string> & {
|
|
6
6
|
name: string;
|
|
7
7
|
};
|
|
8
|
-
navigation: NavigationProp<ParamListBase, string, State, ScreenOptions>;
|
|
8
|
+
navigation: NavigationProp<ParamListBase, string, string | undefined, State, ScreenOptions>;
|
|
9
9
|
route: Route<string>;
|
|
10
10
|
routeState: NavigationState | PartialState<NavigationState> | undefined;
|
|
11
11
|
getState: () => State;
|
|
@@ -8,6 +8,10 @@ declare global {
|
|
|
8
8
|
}
|
|
9
9
|
declare type Keyof<T extends {}> = Extract<keyof T, string>;
|
|
10
10
|
export declare type DefaultNavigatorOptions<ParamList extends ParamListBase, State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase> = DefaultRouterOptions<Keyof<ParamList>> & {
|
|
11
|
+
/**
|
|
12
|
+
* Optional ID for the navigator. Can be used with `navigation.getParent(id)` to refer to a parent.
|
|
13
|
+
*/
|
|
14
|
+
id?: string;
|
|
11
15
|
/**
|
|
12
16
|
* Children React Elements to extract the route configuration from.
|
|
13
17
|
* Only `Screen`, `Group` and `React.Fragment` are supported as children.
|
|
@@ -111,7 +115,7 @@ export declare type EventEmitter<EventMap extends EventMapBase> = {
|
|
|
111
115
|
data: EventMap[EventName]['data'];
|
|
112
116
|
})): EventArg<EventName, EventMap[EventName]['canPreventDefault'], EventMap[EventName]['data']>;
|
|
113
117
|
};
|
|
114
|
-
export declare class PrivateValueStore<
|
|
118
|
+
export declare class PrivateValueStore<T extends [any, any, any]> {
|
|
115
119
|
/**
|
|
116
120
|
* UGLY HACK! DO NOT USE THE TYPE!!!
|
|
117
121
|
*
|
|
@@ -122,11 +126,7 @@ export declare class PrivateValueStore<A, B, C> {
|
|
|
122
126
|
* Adding private keyword works, but the annotation is stripped away in declaration.
|
|
123
127
|
* Turns out if we use an empty string, it doesn't show up in intelliSense.
|
|
124
128
|
*/
|
|
125
|
-
protected ''?:
|
|
126
|
-
a: A;
|
|
127
|
-
b: B;
|
|
128
|
-
c: C;
|
|
129
|
-
};
|
|
129
|
+
protected ''?: T;
|
|
130
130
|
}
|
|
131
131
|
declare type NavigationHelpersCommon<ParamList extends ParamListBase, State extends NavigationState = NavigationState> = {
|
|
132
132
|
/**
|
|
@@ -181,15 +181,24 @@ declare type NavigationHelpersCommon<ParamList extends ParamListBase, State exte
|
|
|
181
181
|
*/
|
|
182
182
|
canGoBack(): boolean;
|
|
183
183
|
/**
|
|
184
|
-
* Returns the
|
|
184
|
+
* Returns the name of the navigator specified in the `name` prop.
|
|
185
|
+
* If no name is specified, returns `undefined`.
|
|
186
|
+
*/
|
|
187
|
+
getId(): string | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* Returns the navigation helpers from a parent navigator based on the ID.
|
|
190
|
+
* If an ID is provided, the navigation helper from the parent navigator with matching ID (including current) will be returned.
|
|
191
|
+
* If no ID is provided, the navigation helper from the immediate parent navigator will be returned.
|
|
192
|
+
*
|
|
193
|
+
* @param id Optional ID of a parent navigator.
|
|
185
194
|
*/
|
|
186
|
-
getParent<T =
|
|
195
|
+
getParent<T = NavigationHelpers<ParamListBase> | undefined>(id?: string): T;
|
|
187
196
|
/**
|
|
188
197
|
* Returns the navigator's state.
|
|
189
198
|
* Note that this method doesn't re-render screen when the result changes. So don't use it in `render`.
|
|
190
199
|
*/
|
|
191
200
|
getState(): State;
|
|
192
|
-
} & PrivateValueStore<ParamList,
|
|
201
|
+
} & PrivateValueStore<[ParamList, unknown, unknown]>;
|
|
193
202
|
export declare type NavigationHelpers<ParamList extends ParamListBase, EventMap extends EventMapBase = {}> = NavigationHelpersCommon<ParamList> & EventEmitter<EventMap> & {
|
|
194
203
|
/**
|
|
195
204
|
* Update the param object for the route.
|
|
@@ -223,7 +232,15 @@ export declare type NavigationContainerProps = {
|
|
|
223
232
|
*/
|
|
224
233
|
children: React.ReactNode;
|
|
225
234
|
};
|
|
226
|
-
export declare type NavigationProp<ParamList extends {}, RouteName extends keyof ParamList = Keyof<ParamList>, State extends NavigationState = NavigationState<ParamList>, ScreenOptions extends {} = {}, EventMap extends EventMapBase = {}> = NavigationHelpersCommon<ParamList, State> & {
|
|
235
|
+
export declare type NavigationProp<ParamList extends {}, RouteName extends keyof ParamList = Keyof<ParamList>, NavigatorID extends string | undefined = undefined, State extends NavigationState = NavigationState<ParamList>, ScreenOptions extends {} = {}, EventMap extends EventMapBase = {}> = Omit<NavigationHelpersCommon<ParamList, State>, 'getParent'> & {
|
|
236
|
+
/**
|
|
237
|
+
* Returns the navigation prop from a parent navigator based on the ID.
|
|
238
|
+
* If an ID is provided, the navigation prop from the parent navigator with matching ID (including current) will be returned.
|
|
239
|
+
* If no ID is provided, the navigation prop from the immediate parent navigator will be returned.
|
|
240
|
+
*
|
|
241
|
+
* @param id Optional ID of a parent navigator.
|
|
242
|
+
*/
|
|
243
|
+
getParent<T = NavigationProp<ParamListBase> | undefined>(id?: NavigatorID): T;
|
|
227
244
|
/**
|
|
228
245
|
* Update the param object for the route.
|
|
229
246
|
* The new params will be shallow merged with the old one.
|
|
@@ -238,9 +255,9 @@ export declare type NavigationProp<ParamList extends {}, RouteName extends keyof
|
|
|
238
255
|
* @param options Options object for the route.
|
|
239
256
|
*/
|
|
240
257
|
setOptions(options: Partial<ScreenOptions>): void;
|
|
241
|
-
} & EventConsumer<EventMap & EventMapCore<State>> & PrivateValueStore<ParamList, RouteName, EventMap>;
|
|
258
|
+
} & EventConsumer<EventMap & EventMapCore<State>> & PrivateValueStore<[ParamList, RouteName, EventMap]>;
|
|
242
259
|
export declare type RouteProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = Keyof<ParamList>> = Route<Extract<RouteName, string>, ParamList[RouteName]>;
|
|
243
|
-
export declare type CompositeNavigationProp<A extends NavigationProp<ParamListBase, string, any, any>, B extends NavigationHelpersCommon<ParamListBase, any>> = Omit<A & B, keyof NavigationProp<any>> & NavigationProp<
|
|
260
|
+
export declare type CompositeNavigationProp<A extends NavigationProp<ParamListBase, string, any, any, any>, B extends NavigationHelpersCommon<ParamListBase, any>> = Omit<A & B, keyof NavigationProp<any>> & NavigationProp<
|
|
244
261
|
/**
|
|
245
262
|
* Param list from both navigation objects needs to be combined
|
|
246
263
|
* For example, we should be able to navigate to screens in both A and B
|
|
@@ -251,30 +268,34 @@ export declare type CompositeNavigationProp<A extends NavigationProp<ParamListBa
|
|
|
251
268
|
* Ideally it should work for any of them, but it's not possible to infer that way
|
|
252
269
|
*/
|
|
253
270
|
A extends NavigationProp<any, infer R> ? R : string,
|
|
271
|
+
/**
|
|
272
|
+
* ID from both navigation objects needs to be combined for `getParent`
|
|
273
|
+
*/
|
|
274
|
+
(A extends NavigationProp<any, any, infer I> ? I : never) | (B extends NavigationProp<any, any, infer J> ? J : never),
|
|
254
275
|
/**
|
|
255
276
|
* The type of state should refer to the state specified in the first type
|
|
256
277
|
*/
|
|
257
|
-
A extends NavigationProp<any, any, infer S> ? S : NavigationState,
|
|
278
|
+
A extends NavigationProp<any, any, any, infer S> ? S : NavigationState,
|
|
258
279
|
/**
|
|
259
280
|
* Screen options from both navigation objects needs to be combined
|
|
260
281
|
* This allows typechecking `setOptions`
|
|
261
282
|
*/
|
|
262
|
-
(A extends NavigationProp<any, any, any, infer O> ? O : {}) & (B extends NavigationProp<any, any, any, infer P> ? P : {}),
|
|
283
|
+
(A extends NavigationProp<any, any, any, any, infer O> ? O : {}) & (B extends NavigationProp<any, any, any, any, infer P> ? P : {}),
|
|
263
284
|
/**
|
|
264
285
|
* Event consumer config should refer to the config specified in the first type
|
|
265
286
|
* This allows typechecking `addListener`/`removeListener`
|
|
266
287
|
*/
|
|
267
|
-
A extends NavigationProp<any, any, any, any, infer E> ? E : {}>;
|
|
288
|
+
A extends NavigationProp<any, any, any, any, any, infer E> ? E : {}>;
|
|
268
289
|
export declare type CompositeScreenProps<A extends {
|
|
269
|
-
navigation: NavigationProp<ParamListBase, string, any, any>;
|
|
290
|
+
navigation: NavigationProp<ParamListBase, string, string | undefined, any, any, any>;
|
|
270
291
|
route: RouteProp<ParamListBase>;
|
|
271
292
|
}, B extends {
|
|
272
|
-
navigation: NavigationHelpersCommon<
|
|
293
|
+
navigation: NavigationHelpersCommon<any, any>;
|
|
273
294
|
}> = {
|
|
274
295
|
navigation: CompositeNavigationProp<A['navigation'], B['navigation']>;
|
|
275
296
|
route: A['route'];
|
|
276
297
|
};
|
|
277
|
-
export declare type Descriptor<ScreenOptions extends {}, Navigation extends NavigationProp<any, any, any, any, any>, Route extends RouteProp<any, any>> = {
|
|
298
|
+
export declare type Descriptor<ScreenOptions extends {}, Navigation extends NavigationProp<any, any, any, any, any, any>, Route extends RouteProp<any, any>> = {
|
|
278
299
|
/**
|
|
279
300
|
* Render the component associated with this route.
|
|
280
301
|
*/
|
|
@@ -321,6 +342,12 @@ export declare type RouteConfigComponent<ParamList extends ParamListBase, RouteN
|
|
|
321
342
|
getComponent?: never;
|
|
322
343
|
};
|
|
323
344
|
export declare type RouteConfig<ParamList extends ParamListBase, RouteName extends keyof ParamList, State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase> = {
|
|
345
|
+
/**
|
|
346
|
+
* Optional key for this screen. This doesn't need to be unique.
|
|
347
|
+
* If the key changes, existing screens with this name will be removed or reset.
|
|
348
|
+
* Useful when we have some common screens and have conditional rendering.
|
|
349
|
+
*/
|
|
350
|
+
navigationKey?: string;
|
|
324
351
|
/**
|
|
325
352
|
* Route name of this screen.
|
|
326
353
|
*/
|
|
@@ -354,6 +381,11 @@ export declare type RouteConfig<ParamList extends ParamListBase, RouteName exten
|
|
|
354
381
|
initialParams?: Partial<ParamList[RouteName]>;
|
|
355
382
|
} & RouteConfigComponent<ParamList, RouteName>;
|
|
356
383
|
export declare type RouteGroupConfig<ParamList extends ParamListBase, ScreenOptions extends {}> = {
|
|
384
|
+
/**
|
|
385
|
+
* Optional key for the screens in this group.
|
|
386
|
+
* If the key changes, all existing screens in this group will be removed or reset.
|
|
387
|
+
*/
|
|
388
|
+
navigationKey?: string;
|
|
357
389
|
/**
|
|
358
390
|
* Navigator options for this screen.
|
|
359
391
|
*/
|
|
@@ -2,10 +2,11 @@ import type { NavigationAction, NavigationState, ParamListBase, Router } from '@
|
|
|
2
2
|
import { AddKeyedListener, AddListener } from './NavigationBuilderContext';
|
|
3
3
|
import type { Descriptor, EventMapBase, NavigationHelpers, NavigationProp, RouteConfig, RouteProp } from './types';
|
|
4
4
|
import type { NavigationEventEmitter } from './useEventEmitter';
|
|
5
|
-
export declare type ScreenConfigWithParent<State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase> =
|
|
6
|
-
(
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export declare type ScreenConfigWithParent<State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase> = {
|
|
6
|
+
keys: (string | undefined)[];
|
|
7
|
+
options: (ScreenOptionsOrCallback<ScreenOptions> | undefined)[] | undefined;
|
|
8
|
+
props: RouteConfig<ParamListBase, string, State, ScreenOptions, EventMap>;
|
|
9
|
+
};
|
|
9
10
|
declare type ScreenOptionsOrCallback<ScreenOptions extends {}> = ScreenOptions | ((props: {
|
|
10
11
|
route: RouteProp<ParamListBase, string>;
|
|
11
12
|
navigation: any;
|
|
@@ -37,7 +38,7 @@ declare type Options<State extends NavigationState, ScreenOptions extends {}, Ev
|
|
|
37
38
|
* - Options specified by the screen for the navigator
|
|
38
39
|
* - Navigation object intended for the route
|
|
39
40
|
*/
|
|
40
|
-
export default function useDescriptors<State extends NavigationState, ActionHelpers extends Record<string, () => void>, ScreenOptions extends {}, EventMap extends EventMapBase>({ state, screens, navigation, screenOptions, defaultScreenOptions, onAction, getState, setState, addListener, addKeyedListener, onRouteFocus, router, emitter, }: Options<State, ScreenOptions, EventMap>): Record<string, Descriptor<ScreenOptions, {
|
|
41
|
+
export default function useDescriptors<State extends NavigationState, ActionHelpers extends Record<string, () => void>, ScreenOptions extends {}, EventMap extends EventMapBase>({ state, screens, navigation, screenOptions, defaultScreenOptions, onAction, getState, setState, addListener, addKeyedListener, onRouteFocus, router, emitter, }: Options<State, ScreenOptions, EventMap>): Record<string, Descriptor<ScreenOptions, Omit<{
|
|
41
42
|
dispatch(action: Readonly<{
|
|
42
43
|
type: string;
|
|
43
44
|
payload?: object | undefined;
|
|
@@ -64,7 +65,11 @@ export default function useDescriptors<State extends NavigationState, ActionHelp
|
|
|
64
65
|
goBack(): void;
|
|
65
66
|
isFocused(): boolean;
|
|
66
67
|
canGoBack(): boolean;
|
|
67
|
-
|
|
68
|
+
getId(): string | undefined;
|
|
69
|
+
getParent<T = NavigationHelpers<ParamListBase, {}> | undefined>(id?: string | undefined): T;
|
|
70
|
+
getState(): State;
|
|
71
|
+
} & import("./types").PrivateValueStore<[ParamListBase, unknown, unknown]>, "getParent"> & {
|
|
72
|
+
getParent<T_1 = NavigationProp<ParamListBase, string, undefined, Readonly<{
|
|
68
73
|
key: string;
|
|
69
74
|
index: number;
|
|
70
75
|
routeNames: string[];
|
|
@@ -80,10 +85,8 @@ export default function useDescriptors<State extends NavigationState, ActionHelp
|
|
|
80
85
|
})[];
|
|
81
86
|
type: string;
|
|
82
87
|
stale: false;
|
|
83
|
-
}>, {}, {}> | undefined>():
|
|
84
|
-
getState(): State;
|
|
85
|
-
} & import("./types").PrivateValueStore<ParamListBase, string, {}> & {
|
|
88
|
+
}>, {}, {}> | undefined>(id?: string | undefined): T_1;
|
|
86
89
|
setParams(params: Partial<object | undefined>): void;
|
|
87
90
|
setOptions(options: Partial<ScreenOptions>): void;
|
|
88
|
-
} & import("./types").EventConsumer<EventMap & import("./types").EventMapCore<State>> & import("./types").PrivateValueStore<ParamListBase, string, EventMap> & ActionHelpers, RouteProp<ParamListBase, string>>>;
|
|
91
|
+
} & import("./types").EventConsumer<EventMap & import("./types").EventMapCore<State>> & import("./types").PrivateValueStore<[ParamListBase, string, EventMap]> & ActionHelpers, RouteProp<ParamListBase, string>>>;
|
|
89
92
|
export {};
|
|
@@ -85,23 +85,8 @@ export default function useNavigationBuilder<State extends NavigationState, Rout
|
|
|
85
85
|
goBack(): void;
|
|
86
86
|
isFocused(): boolean;
|
|
87
87
|
canGoBack(): boolean;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
index: number;
|
|
91
|
-
routeNames: string[];
|
|
92
|
-
history?: unknown[] | undefined;
|
|
93
|
-
routes: (Readonly<{
|
|
94
|
-
key: string;
|
|
95
|
-
name: string;
|
|
96
|
-
path?: string | undefined;
|
|
97
|
-
}> & Readonly<{
|
|
98
|
-
params?: Readonly<object | undefined>;
|
|
99
|
-
}> & {
|
|
100
|
-
state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
|
|
101
|
-
})[];
|
|
102
|
-
type: string;
|
|
103
|
-
stale: false;
|
|
104
|
-
}>, {}, {}> | undefined>(): T;
|
|
88
|
+
getId(): string | undefined;
|
|
89
|
+
getParent<T = import("./types").NavigationHelpers<ParamListBase, {}> | undefined>(id?: string | undefined): T;
|
|
105
90
|
getState(): Readonly<{
|
|
106
91
|
key: string;
|
|
107
92
|
index: number;
|
|
@@ -119,58 +104,10 @@ export default function useNavigationBuilder<State extends NavigationState, Rout
|
|
|
119
104
|
type: string;
|
|
120
105
|
stale: false;
|
|
121
106
|
}>;
|
|
122
|
-
} & PrivateValueStore<ParamListBase,
|
|
107
|
+
} & PrivateValueStore<[ParamListBase, unknown, unknown]> & import("./types").EventEmitter<EventMap> & {
|
|
123
108
|
setParams<RouteName_2 extends string>(params: Partial<object | undefined>): void;
|
|
124
|
-
} &
|
|
125
|
-
|
|
126
|
-
type: string;
|
|
127
|
-
payload?: object | undefined;
|
|
128
|
-
source?: string | undefined;
|
|
129
|
-
target?: string | undefined;
|
|
130
|
-
}> | ((state: any) => Readonly<{
|
|
131
|
-
type: string;
|
|
132
|
-
payload?: object | undefined;
|
|
133
|
-
source?: string | undefined;
|
|
134
|
-
target?: string | undefined;
|
|
135
|
-
}>)): void;
|
|
136
|
-
navigate<RouteName extends string>(...args: [screen: RouteName] | [screen: RouteName, params: object | undefined]): void;
|
|
137
|
-
navigate<RouteName_1 extends string>(options: {
|
|
138
|
-
key: string;
|
|
139
|
-
params?: object | undefined;
|
|
140
|
-
merge?: boolean | undefined;
|
|
141
|
-
} | {
|
|
142
|
-
name: RouteName_1;
|
|
143
|
-
key?: string | undefined;
|
|
144
|
-
params: object | undefined;
|
|
145
|
-
merge?: boolean | undefined;
|
|
146
|
-
}): void;
|
|
147
|
-
reset(state: any): void;
|
|
148
|
-
goBack(): void;
|
|
149
|
-
isFocused(): boolean;
|
|
150
|
-
canGoBack(): boolean;
|
|
151
|
-
getParent<T = import("./types").NavigationProp<ParamListBase, string, Readonly<{
|
|
152
|
-
key: string;
|
|
153
|
-
index: number;
|
|
154
|
-
routeNames: string[];
|
|
155
|
-
history?: unknown[] | undefined;
|
|
156
|
-
routes: (Readonly<{
|
|
157
|
-
key: string;
|
|
158
|
-
name: string;
|
|
159
|
-
path?: string | undefined;
|
|
160
|
-
}> & Readonly<{
|
|
161
|
-
params?: Readonly<object | undefined>;
|
|
162
|
-
}> & {
|
|
163
|
-
state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
|
|
164
|
-
})[];
|
|
165
|
-
type: string;
|
|
166
|
-
stale: false;
|
|
167
|
-
}>, {}, {}> | undefined>(): T;
|
|
168
|
-
getState(): any;
|
|
169
|
-
} & {
|
|
170
|
-
setParams(params: Partial<object | undefined>): void;
|
|
171
|
-
setOptions(options: Partial<any>): void;
|
|
172
|
-
} & import("./types").EventConsumer<any> & PrivateValueStore<ParamListBase, string, any> & ActionHelpers;
|
|
173
|
-
descriptors: Record<string, import("./types").Descriptor<ScreenOptions, {
|
|
109
|
+
} & ActionHelpers;
|
|
110
|
+
descriptors: Record<string, import("./types").Descriptor<ScreenOptions, Omit<{
|
|
174
111
|
dispatch(action: Readonly<{
|
|
175
112
|
type: string;
|
|
176
113
|
payload?: object | undefined;
|
|
@@ -197,7 +134,11 @@ export default function useNavigationBuilder<State extends NavigationState, Rout
|
|
|
197
134
|
goBack(): void;
|
|
198
135
|
isFocused(): boolean;
|
|
199
136
|
canGoBack(): boolean;
|
|
200
|
-
|
|
137
|
+
getId(): string | undefined;
|
|
138
|
+
getParent<T = import("./types").NavigationHelpers<ParamListBase, {}> | undefined>(id?: string | undefined): T;
|
|
139
|
+
getState(): State;
|
|
140
|
+
} & PrivateValueStore<[ParamListBase, unknown, unknown]>, "getParent"> & {
|
|
141
|
+
getParent<T_1 = import("./types").NavigationProp<ParamListBase, string, undefined, Readonly<{
|
|
201
142
|
key: string;
|
|
202
143
|
index: number;
|
|
203
144
|
routeNames: string[];
|
|
@@ -213,11 +154,9 @@ export default function useNavigationBuilder<State extends NavigationState, Rout
|
|
|
213
154
|
})[];
|
|
214
155
|
type: string;
|
|
215
156
|
stale: false;
|
|
216
|
-
}>, {}, {}> | undefined>():
|
|
217
|
-
getState(): State;
|
|
218
|
-
} & PrivateValueStore<ParamListBase, string, {}> & {
|
|
157
|
+
}>, {}, {}> | undefined>(id?: string | undefined): T_1;
|
|
219
158
|
setParams(params: Partial<object | undefined>): void;
|
|
220
159
|
setOptions(options: Partial<ScreenOptions>): void;
|
|
221
|
-
} & import("./types").EventConsumer<EventMap & EventMapCore<State>> & PrivateValueStore<ParamListBase, string, EventMap> & ActionHelpers, import("./types").RouteProp<ParamListBase, string>>>;
|
|
160
|
+
} & import("./types").EventConsumer<EventMap & EventMapCore<State>> & PrivateValueStore<[ParamListBase, string, EventMap]> & ActionHelpers, import("./types").RouteProp<ParamListBase, string>>>;
|
|
222
161
|
NavigationContent: (rest: Omit<React.ProviderProps<import("./types").NavigationHelpers<ParamListBase, {}> | undefined>, "value">) => JSX.Element;
|
|
223
162
|
};
|
|
@@ -9,7 +9,7 @@ declare type Options<State extends NavigationState, EventMap extends Record<stri
|
|
|
9
9
|
router: Router<State, NavigationAction>;
|
|
10
10
|
emitter: NavigationEventEmitter<EventMap>;
|
|
11
11
|
};
|
|
12
|
-
declare type NavigationCache<State extends NavigationState, ScreenOptions extends {}, EventMap extends Record<string, any>> = Record<string, NavigationProp<ParamListBase, string, State, ScreenOptions, EventMap>>;
|
|
12
|
+
declare type NavigationCache<State extends NavigationState, ScreenOptions extends {}, EventMap extends Record<string, any>> = Record<string, NavigationProp<ParamListBase, string, string | undefined, State, ScreenOptions, EventMap>>;
|
|
13
13
|
/**
|
|
14
14
|
* Hook to cache navigation objects for each screen in the navigator.
|
|
15
15
|
* It's important to cache them to make sure navigation objects don't change between renders.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NavigationAction, NavigationState, ParamListBase, Router } from '@react-navigation/routers';
|
|
2
|
-
import {
|
|
2
|
+
import { NavigationHelpers, PrivateValueStore } from './types';
|
|
3
3
|
import type { NavigationEventEmitter } from './useEventEmitter';
|
|
4
4
|
declare type Options<State extends NavigationState, Action extends NavigationAction> = {
|
|
5
|
+
id: string | undefined;
|
|
5
6
|
onAction: (action: NavigationAction) => boolean;
|
|
6
7
|
getState: () => State;
|
|
7
8
|
emitter: NavigationEventEmitter<any>;
|
|
@@ -11,7 +12,7 @@ declare type Options<State extends NavigationState, Action extends NavigationAct
|
|
|
11
12
|
* Navigation object with helper methods to be used by a navigator.
|
|
12
13
|
* This object includes methods for common actions as well as methods the parent screen's navigation object.
|
|
13
14
|
*/
|
|
14
|
-
export default function useNavigationHelpers<State extends NavigationState, ActionHelpers extends Record<string, () => void>, Action extends NavigationAction, EventMap extends Record<string, any>>({ onAction, getState, emitter, router }: Options<State, Action>): {
|
|
15
|
+
export default function useNavigationHelpers<State extends NavigationState, ActionHelpers extends Record<string, () => void>, Action extends NavigationAction, EventMap extends Record<string, any>>({ id: navigatorId, onAction, getState, emitter, router, }: Options<State, Action>): {
|
|
15
16
|
dispatch(action: Readonly<{
|
|
16
17
|
type: string;
|
|
17
18
|
payload?: object | undefined;
|
|
@@ -86,23 +87,8 @@ export default function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
86
87
|
goBack(): void;
|
|
87
88
|
isFocused(): boolean;
|
|
88
89
|
canGoBack(): boolean;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
index: number;
|
|
92
|
-
routeNames: string[];
|
|
93
|
-
history?: unknown[] | undefined;
|
|
94
|
-
routes: (Readonly<{
|
|
95
|
-
key: string;
|
|
96
|
-
name: string;
|
|
97
|
-
path?: string | undefined;
|
|
98
|
-
}> & Readonly<{
|
|
99
|
-
params?: Readonly<object | undefined>;
|
|
100
|
-
}> & {
|
|
101
|
-
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
102
|
-
})[];
|
|
103
|
-
type: string;
|
|
104
|
-
stale: false;
|
|
105
|
-
}>, {}, {}> | undefined>(): T;
|
|
90
|
+
getId(): string | undefined;
|
|
91
|
+
getParent<T = NavigationHelpers<ParamListBase, {}> | undefined>(id?: string | undefined): T;
|
|
106
92
|
getState(): Readonly<{
|
|
107
93
|
key: string;
|
|
108
94
|
index: number;
|
|
@@ -120,55 +106,7 @@ export default function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
120
106
|
type: string;
|
|
121
107
|
stale: false;
|
|
122
108
|
}>;
|
|
123
|
-
} & PrivateValueStore<ParamListBase,
|
|
109
|
+
} & PrivateValueStore<[ParamListBase, unknown, unknown]> & import("./types").EventEmitter<EventMap> & {
|
|
124
110
|
setParams<RouteName_2 extends string>(params: Partial<object | undefined>): void;
|
|
125
|
-
} &
|
|
126
|
-
dispatch(action: Readonly<{
|
|
127
|
-
type: string;
|
|
128
|
-
payload?: object | undefined;
|
|
129
|
-
source?: string | undefined;
|
|
130
|
-
target?: string | undefined;
|
|
131
|
-
}> | ((state: any) => Readonly<{
|
|
132
|
-
type: string;
|
|
133
|
-
payload?: object | undefined;
|
|
134
|
-
source?: string | undefined;
|
|
135
|
-
target?: string | undefined;
|
|
136
|
-
}>)): void;
|
|
137
|
-
navigate<RouteName extends string>(...args: [screen: RouteName] | [screen: RouteName, params: object | undefined]): void;
|
|
138
|
-
navigate<RouteName_1 extends string>(options: {
|
|
139
|
-
key: string;
|
|
140
|
-
params?: object | undefined;
|
|
141
|
-
merge?: boolean | undefined;
|
|
142
|
-
} | {
|
|
143
|
-
name: RouteName_1;
|
|
144
|
-
key?: string | undefined;
|
|
145
|
-
params: object | undefined;
|
|
146
|
-
merge?: boolean | undefined;
|
|
147
|
-
}): void;
|
|
148
|
-
reset(state: any): void;
|
|
149
|
-
goBack(): void;
|
|
150
|
-
isFocused(): boolean;
|
|
151
|
-
canGoBack(): boolean;
|
|
152
|
-
getParent<T = NavigationProp<ParamListBase, string, Readonly<{
|
|
153
|
-
key: string;
|
|
154
|
-
index: number;
|
|
155
|
-
routeNames: string[];
|
|
156
|
-
history?: unknown[] | undefined;
|
|
157
|
-
routes: (Readonly<{
|
|
158
|
-
key: string;
|
|
159
|
-
name: string;
|
|
160
|
-
path?: string | undefined;
|
|
161
|
-
}> & Readonly<{
|
|
162
|
-
params?: Readonly<object | undefined>;
|
|
163
|
-
}> & {
|
|
164
|
-
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
165
|
-
})[];
|
|
166
|
-
type: string;
|
|
167
|
-
stale: false;
|
|
168
|
-
}>, {}, {}> | undefined>(): T;
|
|
169
|
-
getState(): any;
|
|
170
|
-
} & {
|
|
171
|
-
setParams(params: Partial<object | undefined>): void;
|
|
172
|
-
setOptions(options: Partial<any>): void;
|
|
173
|
-
} & import("./types").EventConsumer<any> & PrivateValueStore<ParamListBase, string, any> & ActionHelpers;
|
|
111
|
+
} & ActionHelpers;
|
|
174
112
|
export {};
|
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": "6.0
|
|
4
|
+
"version": "6.2.0",
|
|
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": "^6.0
|
|
38
|
+
"@react-navigation/routers": "^6.1.0",
|
|
39
39
|
"escape-string-regexp": "^4.0.0",
|
|
40
40
|
"nanoid": "^3.1.23",
|
|
41
41
|
"query-string": "^7.0.0",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"@types/react-is": "^17.0.0",
|
|
48
48
|
"del-cli": "^3.0.1",
|
|
49
49
|
"immer": "^9.0.2",
|
|
50
|
-
"react": "
|
|
50
|
+
"react": "17.0.1",
|
|
51
51
|
"react-native-builder-bob": "^0.18.1",
|
|
52
|
-
"react-test-renderer": "
|
|
52
|
+
"react-test-renderer": "17.0.1",
|
|
53
53
|
"typescript": "^4.3.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
]
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "c5ef6b5e88426e658123ea8590da583314b9001e"
|
|
73
73
|
}
|
|
@@ -4,7 +4,8 @@ import * as React from 'react';
|
|
|
4
4
|
* Context which holds the values for the current navigation tree.
|
|
5
5
|
* Intended for use in SSR. This is not safe to use on the client.
|
|
6
6
|
*/
|
|
7
|
-
const CurrentRenderContext =
|
|
8
|
-
|
|
7
|
+
const CurrentRenderContext = React.createContext<
|
|
8
|
+
{ options?: object } | undefined
|
|
9
|
+
>(undefined);
|
|
9
10
|
|
|
10
11
|
export default CurrentRenderContext;
|
|
@@ -6,14 +6,13 @@ type Props = {
|
|
|
6
6
|
|
|
7
7
|
const MULTIPLE_NAVIGATOR_ERROR = `Another navigator is already registered for this container. You likely have multiple navigators under a single "NavigationContainer" or "Screen". Make sure each navigator is under a separate "Screen" container. See https://reactnavigation.org/docs/nesting-navigators for a guide on nesting.`;
|
|
8
8
|
|
|
9
|
-
export const SingleNavigatorContext =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
>(undefined);
|
|
9
|
+
export const SingleNavigatorContext = React.createContext<
|
|
10
|
+
| {
|
|
11
|
+
register(key: string): void;
|
|
12
|
+
unregister(key: string): void;
|
|
13
|
+
}
|
|
14
|
+
| undefined
|
|
15
|
+
>(undefined);
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Component which ensures that there's only one navigator nested under it.
|