expo-router 4.0.18-canary-20250305-0af9ad2 → 4.0.18
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/build/Route.d.ts +10 -10
- package/build/Route.d.ts.map +1 -1
- package/build/Route.js +27 -4
- package/build/Route.js.map +1 -1
- package/build/exports.d.ts +0 -1
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +1 -3
- package/build/exports.js.map +1 -1
- package/build/fork/getStateFromPath-forks.d.ts +1 -1
- package/build/fork/useLinking.d.ts +0 -1
- package/build/fork/useLinking.d.ts.map +1 -1
- package/build/fork/useLinking.js +1 -5
- package/build/fork/useLinking.js.map +1 -1
- package/build/fork/useLinking.native.d.ts +0 -1
- package/build/fork/useLinking.native.d.ts.map +1 -1
- package/build/fork/useLinking.native.js +9 -21
- package/build/fork/useLinking.native.js.map +1 -1
- package/build/getRoutesCore.js +19 -23
- package/build/getRoutesCore.js.map +1 -1
- package/build/global-state/routing.d.ts +1 -1
- package/build/global-state/routing.js.map +1 -1
- package/build/hooks.d.ts +8 -23
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +4 -4
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.d.ts +2 -2
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/withLayoutContext.d.ts +0 -26
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +0 -26
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +1 -1
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js.map +1 -1
- package/build/link/linking.d.ts.map +1 -1
- package/build/link/linking.js +17 -19
- package/build/link/linking.js.map +1 -1
- package/build/link/useLinkHooks.d.ts +1 -1
- package/build/link/useLinkHooks.js.map +1 -1
- package/build/link/useLinkToPathProps.d.ts.map +1 -1
- package/build/link/useLinkToPathProps.js +2 -2
- package/build/link/useLinkToPathProps.js.map +1 -1
- package/build/rsc/router/host.d.ts.map +1 -1
- package/build/rsc/router/host.js +1 -15
- package/build/rsc/router/host.js.map +1 -1
- package/build/typed-routes/types.d.ts +16 -40
- package/build/typed-routes/types.d.ts.map +1 -1
- package/build/typed-routes/types.js.map +1 -1
- package/build/ui/TabContext.d.ts +8 -2
- package/build/ui/TabContext.d.ts.map +1 -1
- package/build/ui/TabContext.js.map +1 -1
- package/build/ui/TabRouter.d.ts +1 -1
- package/build/ui/TabRouter.d.ts.map +1 -1
- package/build/ui/TabRouter.js.map +1 -1
- package/build/ui/TabSlot.d.ts +6 -5
- package/build/ui/TabSlot.d.ts.map +1 -1
- package/build/ui/TabSlot.js +7 -4
- package/build/ui/TabSlot.js.map +1 -1
- package/build/ui/Tabs.d.ts +8 -13
- package/build/ui/Tabs.d.ts.map +1 -1
- package/build/ui/Tabs.js +2 -5
- package/build/ui/Tabs.js.map +1 -1
- package/build/useNavigation.d.ts +2 -2
- package/build/useNavigation.js +2 -2
- package/build/useNavigation.js.map +1 -1
- package/build/useScreens.d.ts +5 -5
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +8 -14
- package/build/useScreens.js.map +1 -1
- package/expo-module.config.json +3 -2
- package/package.json +8 -8
- package/plugin/build/index.js +4 -0
- package/plugin/src/index.ts +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabContext.d.ts","sourceRoot":"","sources":["../../src/ui/TabContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAErD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,qBAA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MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAExD,eAAO,MAAM,UAAU,yDAAqC,CAAC;AAC7D;;GAEG;AACH,eAAO,MAAM,oBAAoB,qCAAgC,CAAC;AAClE;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uWAAqD,CAAC;AACzF;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAA6D,CAAC;AAC/F;;GAEG;AACH,eAAO,MAAM,gBAAgB,kDAS3B,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AACxE,MAAM,MAAM,cAAc,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabContext.js","sourceRoot":"","sources":["../../src/ui/TabContext.tsx"],"names":[],"mappings":";;;AAWA,iCAAsC;
|
|
1
|
+
{"version":3,"file":"TabContext.js","sourceRoot":"","sources":["../../src/ui/TabContext.tsx"],"names":[],"mappings":";;;AAWA,iCAAsC;AAiFzB,QAAA,UAAU,GAAG,IAAA,qBAAa,EAAkB,EAAE,CAAC,CAAC;AAC7D;;GAEG;AACU,QAAA,oBAAoB,GAAG,IAAA,qBAAa,EAAa,EAAE,CAAC,CAAC;AAClE;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAA,qBAAa,EAAkC,EAAE,CAAC,CAAC;AACzF;;GAEG;AACU,QAAA,oBAAoB,GAAG,IAAA,qBAAa,EAAwC,IAAI,CAAC,CAAC;AAC/F;;GAEG;AACU,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAA4B;IACvE,IAAI,EAAE,KAAK;IACX,kBAAkB,EAAE,EAAE;IACtB,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,CAAC,CAAC;IACT,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,EAAE;CACX,CAAC,CAAC","sourcesContent":["import { BottomTabNavigationOptions } from '@react-navigation/bottom-tabs';\nimport {\n DefaultNavigatorOptions,\n NavigationAction,\n NavigationProp,\n ParamListBase,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport { createContext } from 'react';\n\nimport { TriggerMap } from './common';\n\nexport type ExpoTabsProps = ExpoTabsNavigatorOptions;\n\nexport type ExpoTabsNavigatorScreenOptions = {\n detachInactiveScreens?: boolean;\n unmountOnBlur?: boolean;\n freezeOnBlur?: boolean;\n lazy?: boolean;\n};\n\nexport type ExpoTabsNavigatorOptions = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n TabNavigationState<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n ExpoTabsNavigationProp<ParamListBase>\n> &\n // Should be set through `unstable_settings`\n Omit<TabRouterOptions, 'initialRouteName'> &\n ExpoTabsNavigatorScreenOptions;\n\nexport type ExpoTabsNavigationProp<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = NavigationProp<\n ParamList,\n RouteName,\n NavigatorID,\n TabNavigationState<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap\n>;\n\n/**\n * @hidden\n */\nexport type ExpoTabsScreenOptions = Pick<\n BottomTabNavigationOptions,\n 'title' | 'lazy' | 'freezeOnBlur'\n> & {\n params?: object;\n title: string;\n action: NavigationAction;\n};\n\n/**\n * @hidden\n */\nexport type TabNavigationEventMap = {\n /**\n * Event which fires on tapping on the tab in the tab bar.\n */\n tabPress: { data: undefined; canPreventDefault: true };\n /**\n * Event which fires on long press on the tab in the tab bar.\n */\n tabLongPress: { data: undefined };\n};\n\n/**\n * The React Navigation custom navigator.\n *\n * @see [`useNavigationBuilder`](https://reactnavigation.org/docs/custom-navigators/#usenavigationbuilder) hook from React Navigation for more information.\n */\nexport type TabsContextValue = ReturnType<\n typeof useNavigationBuilder<\n TabNavigationState<any>,\n TabRouterOptions,\n TabActionHelpers<ParamListBase>,\n ExpoTabsNavigatorScreenOptions,\n TabNavigationEventMap\n >\n>;\n\nexport type TabContextValue = TabsDescriptor['options'];\n\nexport const TabContext = createContext<TabContextValue>({});\n/**\n * @hidden\n */\nexport const TabTriggerMapContext = createContext<TriggerMap>({});\n/**\n * @hidden\n */\nexport const TabsDescriptorsContext = createContext<TabsContextValue['descriptors']>({});\n/**\n * @hidden\n */\nexport const TabsNavigatorContext = createContext<TabsContextValue['navigation'] | null>(null);\n/**\n * @hidden\n */\nexport const TabsStateContext = createContext<TabsContextValue['state']>({\n type: 'tab',\n preloadedRouteKeys: [],\n history: [],\n index: -1,\n key: '',\n stale: false,\n routeNames: [],\n routes: [],\n});\n\nexport type Route = TabNavigationState<ParamListBase>['routes'][number];\nexport type TabsDescriptor = TabsContextValue['descriptors'][number];\n"]}
|
package/build/ui/TabRouter.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type ExpoTabActionType = RNTabActionType | CommonNavigationAction | {
|
|
|
11
11
|
payload: {
|
|
12
12
|
name: string;
|
|
13
13
|
reset?: ExpoTabsResetValue;
|
|
14
|
-
params?: object;
|
|
14
|
+
params?: object | undefined;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
export declare function ExpoTabRouter({ triggerMap, ...options }: ExpoTabRouterOptions): Router<TabNavigationState<ParamListBase>, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabRouter.d.ts","sourceRoot":"","sources":["../../src/ui/TabRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,aAAa,EAEb,MAAM,E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AM;gBACL,OAAO,WAAW,CAAC,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;aAC5D;QACH,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AApED,sCAoEC","sourcesContent":["import {\n CommonNavigationAction,\n ParamListBase,\n TabRouter as RNTabRouter,\n Router,\n TabActionType as RNTabActionType,\n TabNavigationState,\n TabRouterOptions as RNTabRouterOptions,\n} from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport { TriggerMap } from './common';\n\nexport type ExpoTabRouterOptions = RNTabRouterOptions & {\n triggerMap: TriggerMap;\n};\n\nexport type ExpoTabsResetValue = 'always' | 'onFocus' | 'never';\n\nexport type ExpoTabActionType =\n | RNTabActionType\n | CommonNavigationAction\n | {\n type: 'JUMP_TO';\n source?: string;\n target?: string;\n payload: {\n name: string;\n reset?: ExpoTabsResetValue;\n params?: object;\n };\n };\n\nexport function ExpoTabRouter({ triggerMap, ...options }: ExpoTabRouterOptions) {\n const rnTabRouter = RNTabRouter(options);\n\n const router: Router<\n TabNavigationState<ParamListBase>,\n ExpoTabActionType | CommonNavigationAction\n > = {\n ...rnTabRouter,\n getStateForAction(state, action, options) {\n if (action.type !== 'JUMP_TO') {\n return rnTabRouter.getStateForAction(state, action, options);\n }\n\n const name = action.payload.name;\n const trigger = triggerMap[name];\n\n if (!trigger) {\n // This is probably for a different navigator\n return null;\n } else if (trigger.type === 'external') {\n Linking.openURL(trigger.href);\n return state;\n }\n\n const route = state.routes.find((route) => route.name === trigger.routeNode.route);\n\n if (!route) {\n // This shouldn't occur, but lets just hand it off to the next navigator in case.\n return null;\n }\n\n // We should reset if this is the first time visiting the route\n let shouldReset = !state.history.some((item) => item.key === route?.key) && !route.state;\n\n if (!shouldReset && 'reset' in action.payload && action.payload.reset) {\n switch (action.payload.reset) {\n case 'never': {\n shouldReset = false;\n break;\n }\n case 'always': {\n shouldReset = true;\n break;\n }\n case 'onFocus': {\n shouldReset = state.routes[state.index].key === route.key;\n break;\n }\n default: {\n // TypeScript trick to ensure all use-cases are accounted for\n action.payload.reset satisfies never;\n }\n }\n }\n\n if (shouldReset) {\n options.routeParamList[route.name] = {\n ...options.routeParamList[route.name],\n ...trigger.action.payload.params,\n };\n return rnTabRouter.getStateForAction(state, trigger.action, options);\n } else {\n return rnTabRouter.getStateForRouteFocus(state, route.key);\n }\n },\n };\n\n return router;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TabRouter.js","sourceRoot":"","sources":["../../src/ui/TabRouter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAQkC;AAClC,sDAAwC;AAwBxC,SAAgB,aAAa,CAAC,EAAE,UAAU,EAAE,GAAG,OAAO,EAAwB;IAC5E,MAAM,WAAW,GAAG,IAAA,kBAAW,EAAC,OAAO,CAAC,CAAC;IAEzC,MAAM,MAAM,GAGR;QACF,GAAG,WAAW;QACd,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO;YACtC,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE;gBAC7B,OAAO,WAAW,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;aAC9D;YAED,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;YACjC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YAEjC,IAAI,CAAC,OAAO,EAAE;gBACZ,6CAA6C;gBAC7C,OAAO,IAAI,CAAC;aACb;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE;gBACtC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC9B,OAAO,KAAK,CAAC;aACd;YAED,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,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AAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;aAC5D;QACH,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AApED,sCAoEC","sourcesContent":["import {\n CommonNavigationAction,\n ParamListBase,\n TabRouter as RNTabRouter,\n Router,\n TabActionType as RNTabActionType,\n TabNavigationState,\n TabRouterOptions as RNTabRouterOptions,\n} from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport { TriggerMap } from './common';\n\nexport type ExpoTabRouterOptions = RNTabRouterOptions & {\n triggerMap: TriggerMap;\n};\n\nexport type ExpoTabsResetValue = 'always' | 'onFocus' | 'never';\n\nexport type ExpoTabActionType =\n | RNTabActionType\n | CommonNavigationAction\n | {\n type: 'JUMP_TO';\n source?: string;\n target?: string;\n payload: {\n name: string;\n reset?: ExpoTabsResetValue;\n params?: object | undefined;\n };\n };\n\nexport function ExpoTabRouter({ triggerMap, ...options }: ExpoTabRouterOptions) {\n const rnTabRouter = RNTabRouter(options);\n\n const router: Router<\n TabNavigationState<ParamListBase>,\n ExpoTabActionType | CommonNavigationAction\n > = {\n ...rnTabRouter,\n getStateForAction(state, action, options) {\n if (action.type !== 'JUMP_TO') {\n return rnTabRouter.getStateForAction(state, action, options);\n }\n\n const name = action.payload.name;\n const trigger = triggerMap[name];\n\n if (!trigger) {\n // This is probably for a different navigator\n return null;\n } else if (trigger.type === 'external') {\n Linking.openURL(trigger.href);\n return state;\n }\n\n const route = state.routes.find((route) => route.name === trigger.routeNode.route);\n\n if (!route) {\n // This shouldn't occur, but lets just hand it off to the next navigator in case.\n return null;\n }\n\n // We should reset if this is the first time visiting the route\n let shouldReset = !state.history.some((item) => item.key === route?.key) && !route.state;\n\n if (!shouldReset && 'reset' in action.payload && action.payload.reset) {\n switch (action.payload.reset) {\n case 'never': {\n shouldReset = false;\n break;\n }\n case 'always': {\n shouldReset = true;\n break;\n }\n case 'onFocus': {\n shouldReset = state.routes[state.index].key === route.key;\n break;\n }\n default: {\n // TypeScript trick to ensure all use-cases are accounted for\n action.payload.reset satisfies never;\n }\n }\n }\n\n if (shouldReset) {\n options.routeParamList[route.name] = {\n ...options.routeParamList[route.name],\n ...trigger.action.payload.params,\n };\n return rnTabRouter.getStateForAction(state, trigger.action, options);\n } else {\n return rnTabRouter.getStateForRouteFocus(state, route.key);\n }\n },\n };\n\n return router;\n}\n"]}
|
package/build/ui/TabSlot.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ComponentProps, ReactElement } from 'react';
|
|
|
2
2
|
import { ScreenContainer } from 'react-native-screens';
|
|
3
3
|
import { TabsDescriptor } from './TabContext';
|
|
4
4
|
import { TabListProps } from './TabList';
|
|
5
|
-
export type
|
|
5
|
+
export type UseTabSlotOptions = ComponentProps<typeof ScreenContainer> & {
|
|
6
6
|
/**
|
|
7
7
|
* Remove inactive screens.
|
|
8
8
|
*/
|
|
@@ -34,8 +34,11 @@ export type TabsSlotRenderOptions = {
|
|
|
34
34
|
detachInactiveScreens: boolean;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
+
*
|
|
37
38
|
* Returns a `ReactElement` of the current tab.
|
|
38
39
|
*
|
|
40
|
+
* @see [`useTabSlot`](#usetabslotoptions).
|
|
41
|
+
*
|
|
39
42
|
* @example
|
|
40
43
|
* ```tsx
|
|
41
44
|
* function MyTabSlot() {
|
|
@@ -45,7 +48,8 @@ export type TabsSlotRenderOptions = {
|
|
|
45
48
|
* }
|
|
46
49
|
* ```
|
|
47
50
|
*/
|
|
48
|
-
export declare function useTabSlot(
|
|
51
|
+
export declare function useTabSlot(options?: UseTabSlotOptions): import("react").JSX.Element;
|
|
52
|
+
export type TabSlotProps = UseTabSlotOptions;
|
|
49
53
|
/**
|
|
50
54
|
* Renders the current tab.
|
|
51
55
|
*
|
|
@@ -62,9 +66,6 @@ export declare function useTabSlot({ detachInactiveScreens, style, renderFn, }?:
|
|
|
62
66
|
* ```
|
|
63
67
|
*/
|
|
64
68
|
export declare function TabSlot(props: TabSlotProps): import("react").JSX.Element;
|
|
65
|
-
/**
|
|
66
|
-
* @hidden
|
|
67
|
-
*/
|
|
68
69
|
export declare function defaultTabsSlotRender(descriptor: TabsDescriptor, { isFocused, loaded, detachInactiveScreens }: TabsSlotRenderOptions): import("react").JSX.Element | null;
|
|
69
70
|
/**
|
|
70
71
|
* @hidden
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabSlot.d.ts","sourceRoot":"","sources":["../../src/ui/TabSlot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAU,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAc,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"TabSlot.d.ts","sourceRoot":"","sources":["../../src/ui/TabSlot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAU,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAc,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,eAAe,CAAC,GAAG;IACvE;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,qBAAqB,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,+BAsCzD;AAED,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,+BAE1C;AAED,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,cAAc,EAC1B,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,EAAE,qBAAqB,sCAuBpE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,YAAY,CAAC,YAAY,CAAC,CAEvF"}
|
package/build/ui/TabSlot.js
CHANGED
|
@@ -7,8 +7,11 @@ const react_native_screens_1 = require("react-native-screens");
|
|
|
7
7
|
const TabContext_1 = require("./TabContext");
|
|
8
8
|
const Navigator_1 = require("../views/Navigator");
|
|
9
9
|
/**
|
|
10
|
+
*
|
|
10
11
|
* Returns a `ReactElement` of the current tab.
|
|
11
12
|
*
|
|
13
|
+
* @see [`useTabSlot`](#usetabslotoptions).
|
|
14
|
+
*
|
|
12
15
|
* @example
|
|
13
16
|
* ```tsx
|
|
14
17
|
* function MyTabSlot() {
|
|
@@ -18,7 +21,10 @@ const Navigator_1 = require("../views/Navigator");
|
|
|
18
21
|
* }
|
|
19
22
|
* ```
|
|
20
23
|
*/
|
|
21
|
-
function useTabSlot(
|
|
24
|
+
function useTabSlot(options = {}) {
|
|
25
|
+
const { detachInactiveScreens = react_native_1.Platform.OS === 'web' ||
|
|
26
|
+
react_native_1.Platform.OS === 'android' ||
|
|
27
|
+
react_native_1.Platform.OS === 'ios', style, renderFn = defaultTabsSlotRender, } = options;
|
|
22
28
|
const { state, descriptors } = (0, Navigator_1.useNavigatorContext)();
|
|
23
29
|
const focusedRouteKey = state.routes[state.index].key;
|
|
24
30
|
const [loaded, setLoaded] = (0, react_1.useState)({ [focusedRouteKey]: true });
|
|
@@ -59,9 +65,6 @@ function TabSlot(props) {
|
|
|
59
65
|
return useTabSlot(props);
|
|
60
66
|
}
|
|
61
67
|
exports.TabSlot = TabSlot;
|
|
62
|
-
/**
|
|
63
|
-
* @hidden
|
|
64
|
-
*/
|
|
65
68
|
function defaultTabsSlotRender(descriptor, { isFocused, loaded, detachInactiveScreens }) {
|
|
66
69
|
const { lazy = true, unmountOnBlur, freezeOnBlur } = descriptor.options;
|
|
67
70
|
if (unmountOnBlur && !isFocused) {
|
package/build/ui/TabSlot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabSlot.js","sourceRoot":"","sources":["../../src/ui/TabSlot.tsx"],"names":[],"mappings":";;;AAAA,iCAA+D;AAC/D,+CAAoD;AACpD,+DAA+D;AAE/D,6CAA0D;AAE1D,kDAAyD;AAmCzD
|
|
1
|
+
{"version":3,"file":"TabSlot.js","sourceRoot":"","sources":["../../src/ui/TabSlot.tsx"],"names":[],"mappings":";;;AAAA,iCAA+D;AAC/D,+CAAoD;AACpD,+DAA+D;AAE/D,6CAA0D;AAE1D,kDAAyD;AAmCzD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,UAA6B,EAAE;IACxD,MAAM,EACJ,qBAAqB,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK;QAC3C,uBAAQ,CAAC,EAAE,KAAK,SAAS;QACzB,uBAAQ,CAAC,EAAE,KAAK,KAAK,EACvB,KAAK,EACL,QAAQ,GAAG,qBAAqB,GACjC,GAAG,OAAO,CAAC;IAEZ,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,IAAA,+BAAmB,GAAE,CAAC;IACrD,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;IACtD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,G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SAAS,EAAE;QACT,MAAM,EAAE,CAAC,CAAC;QACV,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;CACF,CAAC,CAAC","sourcesContent":["import { ComponentProps, ReactElement, useState } from 'react';\nimport { Platform, StyleSheet } from 'react-native';\nimport { ScreenContainer, Screen } from 'react-native-screens';\n\nimport { TabContext, TabsDescriptor } from './TabContext';\nimport { TabListProps } from './TabList';\nimport { useNavigatorContext } from '../views/Navigator';\n\nexport type UseTabSlotOptions = ComponentProps<typeof ScreenContainer> & {\n /**\n * Remove inactive screens.\n */\n detachInactiveScreens?: boolean;\n /**\n * Override how the `Screen` component is rendered.\n */\n renderFn?: typeof defaultTabsSlotRender;\n};\n\n/**\n * Options provided to the `UseTabSlotOptions`.\n */\nexport type TabsSlotRenderOptions = {\n /**\n * Index of screen.\n */\n index: number;\n /**\n * Whether the screen is focused.\n */\n isFocused: boolean;\n /**\n * Whether the screen has been loaded.\n */\n loaded: boolean;\n /**\n * Should the screen be unloaded when inactive.\n */\n detachInactiveScreens: boolean;\n};\n\n/**\n *\n * Returns a `ReactElement` of the current tab.\n *\n * @see [`useTabSlot`](#usetabslotoptions).\n *\n * @example\n * ```tsx\n * function MyTabSlot() {\n * const slot = useTabSlot();\n *\n * return slot;\n * }\n * ```\n */\nexport function useTabSlot(options: UseTabSlotOptions = {}) {\n const {\n detachInactiveScreens = Platform.OS === 'web' ||\n Platform.OS === 'android' ||\n Platform.OS === 'ios',\n style,\n renderFn = defaultTabsSlotRender,\n } = options;\n\n const { state, descriptors } = useNavigatorContext();\n const focusedRouteKey = state.routes[state.index].key;\n const [loaded, setLoaded] = useState({ [focusedRouteKey]: true });\n\n if (!loaded[focusedRouteKey]) {\n setLoaded({ ...loaded, [focusedRouteKey]: true });\n }\n\n return (\n <ScreenContainer\n enabled={detachInactiveScreens}\n hasTwoStates\n style={[styles.screenContainer, style]}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key] as unknown as TabsDescriptor;\n\n return (\n <TabContext.Provider key={descriptor.route.key} value={descriptor.options}>\n {renderFn(descriptor, {\n index,\n isFocused: state.index === index,\n loaded: loaded[route.key],\n detachInactiveScreens,\n })}\n </TabContext.Provider>\n );\n })}\n </ScreenContainer>\n );\n}\n\nexport type TabSlotProps = UseTabSlotOptions;\n\n/**\n * Renders the current tab.\n *\n * @see [`useTabSlot`](#usetabslot) for a hook version of this component.\n *\n * @example\n * ```tsx\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function TabSlot(props: TabSlotProps) {\n return useTabSlot(props);\n}\n\nexport function defaultTabsSlotRender(\n descriptor: TabsDescriptor,\n { isFocused, loaded, detachInactiveScreens }: TabsSlotRenderOptions\n) {\n const { lazy = true, unmountOnBlur, freezeOnBlur } = descriptor.options;\n\n if (unmountOnBlur && !isFocused) {\n return null;\n }\n\n if (lazy && !loaded && !isFocused) {\n // Don't render a lazy screen if we've never navigated to it\n return null;\n }\n\n return (\n <Screen\n key={descriptor.route.key}\n enabled={detachInactiveScreens}\n activityState={isFocused ? 2 : 0}\n freezeOnBlur={freezeOnBlur}\n style={[styles.screen, isFocused ? styles.focused : styles.unfocused]}>\n {descriptor.render()}\n </Screen>\n );\n}\n\n/**\n * @hidden\n */\nexport function isTabSlot(child: ReactElement<any>): child is ReactElement<TabListProps> {\n return child.type === TabSlot;\n}\n\nconst styles = StyleSheet.create({\n screen: {\n flex: 1,\n position: 'relative',\n height: '100%',\n },\n screenContainer: {\n flexShrink: 0,\n flexGrow: 1,\n },\n focused: {\n zIndex: 1,\n display: 'flex',\n flexShrink: 0,\n flexGrow: 1,\n },\n unfocused: {\n zIndex: -1,\n display: 'none',\n flexShrink: 1,\n flexGrow: 0,\n },\n});\n"]}
|
package/build/ui/Tabs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DefaultNavigatorOptions, ParamListBase, TabActionHelpers, TabNavigationState, TabRouterOptions } from '@react-navigation/native';
|
|
2
|
-
import { ReactNode
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
import { ViewProps } from 'react-native';
|
|
4
4
|
import { ExpoTabsScreenOptions, TabNavigationEventMap, TabsContextValue } from './TabContext';
|
|
5
5
|
import { ScreenTrigger } from './common';
|
|
@@ -7,7 +7,6 @@ export * from './TabContext';
|
|
|
7
7
|
export * from './TabList';
|
|
8
8
|
export * from './TabSlot';
|
|
9
9
|
export * from './TabTrigger';
|
|
10
|
-
export { ExpoTabsResetValue } from './TabRouter';
|
|
11
10
|
/**
|
|
12
11
|
* Options to provide to the Tab Router.
|
|
13
12
|
*/
|
|
@@ -34,16 +33,15 @@ export type TabsProps = ViewProps & {
|
|
|
34
33
|
* ```
|
|
35
34
|
*/
|
|
36
35
|
export declare function Tabs(props: TabsProps): import("react").JSX.Element;
|
|
37
|
-
export type UseTabsWithChildrenOptions =
|
|
36
|
+
export type UseTabsWithChildrenOptions = UseTabsOptions & {
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
};
|
|
38
39
|
export type UseTabsWithTriggersOptions = UseTabsOptions & {
|
|
39
40
|
triggers: ScreenTrigger[];
|
|
40
41
|
};
|
|
41
42
|
/**
|
|
42
43
|
* Hook version of `Tabs`. The returned NavigationContent component
|
|
43
|
-
* should be rendered.
|
|
44
|
-
* and `<TabTrigger />` components exported from Expo Router.
|
|
45
|
-
*
|
|
46
|
-
* The `useTabsWithTriggers()` hook can be used for custom components.
|
|
44
|
+
* should be rendered.
|
|
47
45
|
*
|
|
48
46
|
* @see [`Tabs`](#tabs) for the component version of this hook.
|
|
49
47
|
* @example
|
|
@@ -66,9 +64,6 @@ export declare function useTabsWithChildren(options: UseTabsWithChildrenOptions)
|
|
|
66
64
|
}> | ((state: Readonly<Readonly<{
|
|
67
65
|
key: string;
|
|
68
66
|
index: number;
|
|
69
|
-
/**
|
|
70
|
-
* Options to provide to the Tab Router.
|
|
71
|
-
*/
|
|
72
67
|
routeNames: string[];
|
|
73
68
|
history?: unknown[] | undefined;
|
|
74
69
|
routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
|
|
@@ -80,7 +75,7 @@ export declare function useTabsWithChildren(options: UseTabsWithChildrenOptions)
|
|
|
80
75
|
source?: string | undefined;
|
|
81
76
|
target?: string | undefined;
|
|
82
77
|
}>)): void;
|
|
83
|
-
navigate<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]
|
|
78
|
+
navigate<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void;
|
|
84
79
|
navigate<RouteName_1 extends string>(options: {
|
|
85
80
|
name: string;
|
|
86
81
|
params: object | undefined;
|
|
@@ -157,7 +152,7 @@ export declare function useTabsWithChildren(options: UseTabsWithChildrenOptions)
|
|
|
157
152
|
source?: string | undefined;
|
|
158
153
|
target?: string | undefined;
|
|
159
154
|
}>)): void;
|
|
160
|
-
navigate<RouteName_6 extends string>(...args: [screen: string] | [screen: string, params: object | undefined]
|
|
155
|
+
navigate<RouteName_6 extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void;
|
|
161
156
|
navigate<RouteName_7 extends string>(options: {
|
|
162
157
|
name: string;
|
|
163
158
|
params: object | undefined;
|
|
@@ -204,7 +199,7 @@ export declare function useTabsWithChildren(options: UseTabsWithChildrenOptions)
|
|
|
204
199
|
source?: string | undefined;
|
|
205
200
|
target?: string | undefined;
|
|
206
201
|
}>)): void;
|
|
207
|
-
navigate<RouteName_11 extends string>(...args: [screen: string] | [screen: string, params: object | undefined]
|
|
202
|
+
navigate<RouteName_11 extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void;
|
|
208
203
|
navigate<RouteName_12 extends string>(options: {
|
|
209
204
|
name: string;
|
|
210
205
|
params: object | undefined;
|
package/build/ui/Tabs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/ui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CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,cAAc,GAAG;IACxD,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,gBAAgB,CAiEzF"}
|
package/build/ui/Tabs.js
CHANGED
|
@@ -63,10 +63,7 @@ function Tabs(props) {
|
|
|
63
63
|
exports.Tabs = Tabs;
|
|
64
64
|
/**
|
|
65
65
|
* Hook version of `Tabs`. The returned NavigationContent component
|
|
66
|
-
* should be rendered.
|
|
67
|
-
* and `<TabTrigger />` components exported from Expo Router.
|
|
68
|
-
*
|
|
69
|
-
* The `useTabsWithTriggers()` hook can be used for custom components.
|
|
66
|
+
* should be rendered.
|
|
70
67
|
*
|
|
71
68
|
* @see [`Tabs`](#tabs) for the component version of this hook.
|
|
72
69
|
* @example
|
|
@@ -154,7 +151,7 @@ function parseTriggersFromChildren(children, screenTriggers = [], isInTabList =
|
|
|
154
151
|
const { href, name } = child.props;
|
|
155
152
|
if (!href) {
|
|
156
153
|
if (process.env.NODE_ENV === 'development') {
|
|
157
|
-
console.warn(`<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have
|
|
154
|
+
console.warn(`<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have a href.`);
|
|
158
155
|
}
|
|
159
156
|
return;
|
|
160
157
|
}
|
package/build/ui/Tabs.js.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AAI,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAS,UAAU,CACjB,KAAwB;IAExB,OAAO,KAAK,CAAC,IAAI,KAAK,gBAAQ,CAAC;AACjC,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,QAAQ,EAAE;QACR,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC","sourcesContent":["import {\n DefaultNavigatorOptions,\n LinkingContext,\n ParamListBase,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport {\n Children,\n ComponentProps,\n Fragment,\n ReactElement,\n ReactNode,\n isValidElement,\n useContext,\n useMemo,\n PropsWithChildren,\n} from 'react';\nimport { StyleSheet, ViewProps, View } from 'react-native';\n\nimport {\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n TabTriggerMapContext,\n TabsContextValue,\n} from './TabContext';\nimport { isTabList } from './TabList';\nimport { ExpoTabRouter, ExpoTabRouterOptions } from './TabRouter';\nimport { isTabSlot } from './TabSlot';\nimport { isTabTrigger } from './TabTrigger';\nimport { SafeAreaViewSlot, ScreenTrigger, triggersToScreens } from './common';\nimport { useComponent } from './useComponent';\nimport { useRouteNode, useContextKey } from '../Route';\nimport { useRouteInfo } from '../hooks';\nimport { resolveHref } from '../link/href';\nimport { shouldLinkExternally } from '../utils/url';\nimport { NavigatorContext, NavigatorContextValue } from '../views/Navigator';\n\nexport * from './TabContext';\nexport * from './TabList';\nexport * from './TabSlot';\nexport * from './TabTrigger';\nexport { ExpoTabsResetValue } from './TabRouter';\n\n/**\n * Options to provide to the Tab Router.\n */\nexport type UseTabsOptions = Omit<\n DefaultNavigatorOptions<\n ParamListBase,\n any,\n TabNavigationState<any>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n any\n >,\n 'children'\n> & {\n backBehavior?: TabRouterOptions['backBehavior'];\n};\n\nexport type TabsProps = ViewProps & {\n /** Forward props to child component and removes the extra `<View>`. Useful for custom wrappers. */\n asChild?: boolean;\n options?: UseTabsOptions;\n};\n\n/**\n * Root component for the headless tabs.\n *\n * @see [`useTabsWithChildren`](#usetabswithchildrenoptions) for a hook version of this component.\n * @example\n * ```tsx\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function Tabs(props: TabsProps) {\n const { children, asChild, options, ...rest } = props;\n const Comp = asChild ? SafeAreaViewSlot : View;\n\n const { NavigationContent } = useTabsWithChildren({\n // asChild adds an extra layer, so we need to process the child's children\n children: asChild && isValidElement(children) ? children.props.children : children,\n ...options,\n });\n\n return (\n <Comp style={styles.tabsRoot} {...rest}>\n <NavigationContent>{children}</NavigationContent>\n </Comp>\n );\n}\n\n// @docsMissing\nexport type UseTabsWithChildrenOptions = PropsWithChildren<UseTabsOptions>;\n\n// @docsMissing\nexport type UseTabsWithTriggersOptions = UseTabsOptions & {\n triggers: ScreenTrigger[];\n};\n\n/**\n * Hook version of `Tabs`. The returned NavigationContent component\n * should be rendered. Using the hook requires using the `<TabList />`\n * and `<TabTrigger />` components exported from Expo Router.\n *\n * The `useTabsWithTriggers()` hook can be used for custom components.\n *\n * @see [`Tabs`](#tabs) for the component version of this hook.\n * @example\n * ```tsx\n * export function MyTabs({ children }) {\n * const { NavigationContent } = useTabsWithChildren({ children })\n *\n * return <NavigationContent />\n * }\n * ```\n */\nexport function useTabsWithChildren(options: UseTabsWithChildrenOptions) {\n const { children, ...rest } = options;\n return useTabsWithTriggers({ triggers: parseTriggersFromChildren(children), ...rest });\n}\n\n/**\n * Alternative hook version of `Tabs` that uses explicit triggers\n * instead of `children`.\n *\n * @see [`Tabs`](#tabs) for the component version of this hook.\n * @example\n * ```tsx\n * export function MyTabs({ children }) {\n * const { NavigationContent } = useTabsWithChildren({ triggers: [] })\n *\n * return <NavigationContent />\n * }\n * ```\n */\nexport function useTabsWithTriggers(options: UseTabsWithTriggersOptions): TabsContextValue {\n const { triggers, ...rest } = options;\n // Ensure we extend the parent triggers, so we can trigger them as well\n const parentTriggerMap = useContext(TabTriggerMapContext);\n const routeNode = useRouteNode();\n const contextKey = useContextKey();\n const linking = useContext(LinkingContext).options;\n const routeInfo = useRouteInfo();\n\n if (!routeNode || !linking) {\n throw new Error('No RouteNode. This is likely a bug in expo-router.');\n }\n\n const initialRouteName = routeNode.initialRouteName;\n\n const { children, triggerMap } = triggersToScreens(\n triggers,\n routeNode,\n linking,\n initialRouteName,\n parentTriggerMap,\n routeInfo,\n contextKey\n );\n\n const navigatorContext = useNavigationBuilder<\n TabNavigationState<any>,\n ExpoTabRouterOptions,\n TabActionHelpers<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap\n >(ExpoTabRouter, {\n children,\n ...rest,\n triggerMap,\n id: contextKey,\n initialRouteName,\n });\n\n const {\n state,\n descriptors,\n navigation,\n describe,\n NavigationContent: RNNavigationContent,\n } = navigatorContext;\n\n const navigatorContextValue = useMemo<NavigatorContextValue>(\n () => ({\n ...(navigatorContext as unknown as ReturnType<typeof useNavigationBuilder>),\n contextKey,\n router: ExpoTabRouter,\n }),\n [navigatorContext, contextKey, ExpoTabRouter]\n );\n\n const NavigationContent = useComponent((children: React.ReactNode) => (\n <TabTriggerMapContext.Provider value={triggerMap}>\n <NavigatorContext.Provider value={navigatorContextValue}>\n <RNNavigationContent>{children}</RNNavigationContent>\n </NavigatorContext.Provider>\n </TabTriggerMapContext.Provider>\n )) as TabsContextValue['NavigationContent'];\n\n return { state, descriptors, navigation, NavigationContent, describe };\n}\n\nfunction parseTriggersFromChildren(\n children: ReactNode,\n screenTriggers: ScreenTrigger[] = [],\n isInTabList = false\n) {\n Children.forEach(children, (child) => {\n if (!child || !isValidElement(child) || isTabSlot(child)) {\n return;\n }\n\n if (isFragment(child) && typeof child.props.children !== 'function') {\n return parseTriggersFromChildren(\n child.props.children,\n screenTriggers,\n isInTabList || isTabList(child)\n );\n }\n\n if (isTabList(child) && typeof child.props.children !== 'function') {\n let children = child.props.children;\n\n // <TabList asChild /> adds an extra layer. We need to parse the child's children\n if (child.props.asChild && isValidElement(children)) {\n children = children.props.children;\n }\n\n return parseTriggersFromChildren(children, screenTriggers, isInTabList || isTabList(child));\n }\n\n // We should only process TabTriggers within the TabList. All other components will be ignored\n if (!isInTabList || !isTabTrigger(child)) {\n return;\n }\n\n const { href, name } = child.props;\n\n if (!href) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have an href.`\n );\n }\n return;\n }\n\n const resolvedHref = resolveHref(href);\n\n if (shouldLinkExternally(resolvedHref)) {\n return screenTriggers.push({\n type: 'external',\n name,\n href: resolvedHref,\n });\n }\n\n if (!name) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<TabTrigger> does not have a 'name' prop. TabTriggers within a <TabList /> are required to have a name.`\n );\n }\n return;\n }\n\n return screenTriggers.push({ type: 'internal', href: resolvedHref, name });\n });\n\n return screenTriggers;\n}\n\nfunction isFragment(\n child: ReactElement<any>\n): child is ReactElement<ComponentProps<typeof Fragment>> {\n return child.type === Fragment;\n}\n\nconst styles = StyleSheet.create({\n tabsRoot: {\n flex: 1,\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/ui/Tabs.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAQkC;AAClC,iCASe;AACf,+CAA2D;AAE3D,6CAKsB;AACtB,uCAAsC;AACtC,2CAAkE;AAClE,uCAAsC;AACtC,6CAA4C;AAC5C,qCAA8E;AAC9E,iDAA8C;AAC9C,oCAAuD;AACvD,oCAAwC;AACxC,uCAA2C;AAC3C,sCAAoD;AACpD,kDAA6E;AAE7E,+CAA6B;AAC7B,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B;AAyB7B;;;;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AI,CAAC,IAAA,yBAAY,EAAC,KAAK,CAAC,EAAE;YACxC,OAAO;SACR;QAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;QAEnC,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;gBAC1C,OAAO,CAAC,IAAI,CACV,qBAAqB,IAAI,+FAA+F,CACzH,CAAC;aACH;YACD,OAAO;SACR;QAED,MAAM,YAAY,GAAG,IAAA,kBAAW,EAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,IAAA,0BAAoB,EAAC,YAAY,CAAC,EAAE;YACtC,OAAO,cAAc,CAAC,IAAI,CAAC;gBACzB,IAAI,EAAE,UAAU;gBAChB,IAAI;gBACJ,IAAI,EAAE,YAAY;aACnB,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;gBAC1C,OAAO,CAAC,IAAI,CACV,yGAAyG,CAC1G,CAAC;aACH;YACD,OAAO;SACR;QAED,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAS,UAAU,CACjB,KAAwB;IAExB,OAAO,KAAK,CAAC,IAAI,KAAK,gBAAQ,CAAC;AACjC,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,QAAQ,EAAE;QACR,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC","sourcesContent":["import {\n DefaultNavigatorOptions,\n LinkingContext,\n ParamListBase,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport {\n Children,\n ComponentProps,\n Fragment,\n ReactElement,\n ReactNode,\n isValidElement,\n useContext,\n useMemo,\n} from 'react';\nimport { StyleSheet, ViewProps, View } from 'react-native';\n\nimport {\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n TabTriggerMapContext,\n TabsContextValue,\n} from './TabContext';\nimport { isTabList } from './TabList';\nimport { ExpoTabRouter, ExpoTabRouterOptions } from './TabRouter';\nimport { isTabSlot } from './TabSlot';\nimport { isTabTrigger } from './TabTrigger';\nimport { SafeAreaViewSlot, ScreenTrigger, triggersToScreens } from './common';\nimport { useComponent } from './useComponent';\nimport { useRouteNode, useContextKey } from '../Route';\nimport { useRouteInfo } from '../hooks';\nimport { resolveHref } from '../link/href';\nimport { shouldLinkExternally } from '../utils/url';\nimport { NavigatorContext, NavigatorContextValue } from '../views/Navigator';\n\nexport * from './TabContext';\nexport * from './TabList';\nexport * from './TabSlot';\nexport * from './TabTrigger';\n\n/**\n * Options to provide to the Tab Router.\n */\nexport type UseTabsOptions = Omit<\n DefaultNavigatorOptions<\n ParamListBase,\n any,\n TabNavigationState<any>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n any\n >,\n 'children'\n> & {\n backBehavior?: TabRouterOptions['backBehavior'];\n};\n\nexport type TabsProps = ViewProps & {\n /** Forward props to child component and removes the extra `<View>`. Useful for custom wrappers. */\n asChild?: boolean;\n options?: UseTabsOptions;\n};\n\n/**\n * Root component for the headless tabs.\n *\n * @see [`useTabsWithChildren`](#usetabswithchildrenoptions) for a hook version of this component.\n * @example\n * ```tsx\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function Tabs(props: TabsProps) {\n const { children, asChild, options, ...rest } = props;\n const Comp = asChild ? SafeAreaViewSlot : View;\n\n const { NavigationContent } = useTabsWithChildren({\n // asChild adds an extra layer, so we need to process the child's children\n children: asChild && isValidElement(children) ? children.props.children : children,\n ...options,\n });\n\n return (\n <Comp style={styles.tabsRoot} {...rest}>\n <NavigationContent>{children}</NavigationContent>\n </Comp>\n );\n}\n\nexport type UseTabsWithChildrenOptions = UseTabsOptions & {\n children: ReactNode;\n};\n\nexport type UseTabsWithTriggersOptions = UseTabsOptions & {\n triggers: ScreenTrigger[];\n};\n\n/**\n * Hook version of `Tabs`. The returned NavigationContent component\n * should be rendered.\n *\n * @see [`Tabs`](#tabs) for the component version of this hook.\n * @example\n * ```tsx\n * export function MyTabs({ children }) {\n * const { NavigationContent } = useTabsWithChildren({ children })\n *\n * return <NavigationContent />\n * }\n * ```\n */\nexport function useTabsWithChildren(options: UseTabsWithChildrenOptions) {\n const { children, ...rest } = options;\n return useTabsWithTriggers({ triggers: parseTriggersFromChildren(children), ...rest });\n}\n\n/**\n * Alternative hook version of `Tabs` that uses explicit triggers\n * instead of `children`.\n *\n * @see [`Tabs`](#tabs) for the component version of this hook.\n * @example\n * ```tsx\n * export function MyTabs({ children }) {\n * const { NavigationContent } = useTabsWithChildren({ triggers: [] })\n *\n * return <NavigationContent />\n * }\n * ```\n */\nexport function useTabsWithTriggers(options: UseTabsWithTriggersOptions): TabsContextValue {\n const { triggers, ...rest } = options;\n // Ensure we extend the parent triggers, so we can trigger them as well\n const parentTriggerMap = useContext(TabTriggerMapContext);\n const routeNode = useRouteNode();\n const contextKey = useContextKey();\n const linking = useContext(LinkingContext).options;\n const routeInfo = useRouteInfo();\n\n if (!routeNode || !linking) {\n throw new Error('No RouteNode. This is likely a bug in expo-router.');\n }\n\n const initialRouteName = routeNode.initialRouteName;\n\n const { children, triggerMap } = triggersToScreens(\n triggers,\n routeNode,\n linking,\n initialRouteName,\n parentTriggerMap,\n routeInfo,\n contextKey\n );\n\n const navigatorContext = useNavigationBuilder<\n TabNavigationState<any>,\n ExpoTabRouterOptions,\n TabActionHelpers<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap\n >(ExpoTabRouter, {\n children,\n ...rest,\n triggerMap,\n id: contextKey,\n initialRouteName,\n });\n\n const {\n state,\n descriptors,\n navigation,\n describe,\n NavigationContent: RNNavigationContent,\n } = navigatorContext;\n\n const navigatorContextValue = useMemo<NavigatorContextValue>(\n () => ({\n ...(navigatorContext as unknown as ReturnType<typeof useNavigationBuilder>),\n contextKey,\n router: ExpoTabRouter,\n }),\n [navigatorContext, contextKey, ExpoTabRouter]\n );\n\n const NavigationContent = useComponent((children: React.ReactNode) => (\n <TabTriggerMapContext.Provider value={triggerMap}>\n <NavigatorContext.Provider value={navigatorContextValue}>\n <RNNavigationContent>{children}</RNNavigationContent>\n </NavigatorContext.Provider>\n </TabTriggerMapContext.Provider>\n )) as TabsContextValue['NavigationContent'];\n\n return { state, descriptors, navigation, NavigationContent, describe };\n}\n\nfunction parseTriggersFromChildren(\n children: ReactNode,\n screenTriggers: ScreenTrigger[] = [],\n isInTabList = false\n) {\n Children.forEach(children, (child) => {\n if (!child || !isValidElement(child) || isTabSlot(child)) {\n return;\n }\n\n if (isFragment(child) && typeof child.props.children !== 'function') {\n return parseTriggersFromChildren(\n child.props.children,\n screenTriggers,\n isInTabList || isTabList(child)\n );\n }\n\n if (isTabList(child) && typeof child.props.children !== 'function') {\n let children = child.props.children;\n\n // <TabList asChild /> adds an extra layer. We need to parse the child's children\n if (child.props.asChild && isValidElement(children)) {\n children = children.props.children;\n }\n\n return parseTriggersFromChildren(children, screenTriggers, isInTabList || isTabList(child));\n }\n\n // We should only process TabTriggers within the TabList. All other components will be ignored\n if (!isInTabList || !isTabTrigger(child)) {\n return;\n }\n\n const { href, name } = child.props;\n\n if (!href) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have a href.`\n );\n }\n return;\n }\n\n const resolvedHref = resolveHref(href);\n\n if (shouldLinkExternally(resolvedHref)) {\n return screenTriggers.push({\n type: 'external',\n name,\n href: resolvedHref,\n });\n }\n\n if (!name) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<TabTrigger> does not have a 'name' prop. TabTriggers within a <TabList /> are required to have a name.`\n );\n }\n return;\n }\n\n return screenTriggers.push({ type: 'internal', href: resolvedHref, name });\n });\n\n return screenTriggers;\n}\n\nfunction isFragment(\n child: ReactElement<any>\n): child is ReactElement<ComponentProps<typeof Fragment>> {\n return child.type === Fragment;\n}\n\nconst styles = StyleSheet.create({\n tabsRoot: {\n flex: 1,\n },\n});\n"]}
|
package/build/useNavigation.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NavigationProp, NavigationState } from '@react-navigation/native';
|
|
2
2
|
import { Href } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Returns the underlying React Navigation [`navigation`
|
|
4
|
+
* Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)
|
|
5
5
|
* to imperatively access layout-specific functionality like `navigation.openDrawer()` in a
|
|
6
6
|
* [Drawer](/router/advanced/drawer/) layout.
|
|
7
7
|
*
|
|
@@ -49,7 +49,7 @@ import { Href } from './types';
|
|
|
49
49
|
* @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.
|
|
50
50
|
* @returns The navigation object for the current route.
|
|
51
51
|
*
|
|
52
|
-
* @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-
|
|
52
|
+
* @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)
|
|
53
53
|
* for more information.
|
|
54
54
|
*/
|
|
55
55
|
export declare function useNavigation<T = Omit<NavigationProp<ReactNavigation.RootParamList>, 'getState'> & {
|
package/build/useNavigation.js
CHANGED
|
@@ -11,7 +11,7 @@ const router_store_1 = require("./global-state/router-store");
|
|
|
11
11
|
const hooks_1 = require("./hooks");
|
|
12
12
|
const href_1 = require("./link/href");
|
|
13
13
|
/**
|
|
14
|
-
* Returns the underlying React Navigation [`navigation`
|
|
14
|
+
* Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)
|
|
15
15
|
* to imperatively access layout-specific functionality like `navigation.openDrawer()` in a
|
|
16
16
|
* [Drawer](/router/advanced/drawer/) layout.
|
|
17
17
|
*
|
|
@@ -59,7 +59,7 @@ const href_1 = require("./link/href");
|
|
|
59
59
|
* @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.
|
|
60
60
|
* @returns The navigation object for the current route.
|
|
61
61
|
*
|
|
62
|
-
* @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-
|
|
62
|
+
* @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)
|
|
63
63
|
* for more information.
|
|
64
64
|
*/
|
|
65
65
|
function useNavigation(parent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AACb,qDAIkC;AAClC,kDAA0B;AAE1B,8DAAoD;AACpD,mCAAsC;AACtC,sCAA0C;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,SAAgB,aAAa,CAI3B,MAAsB;IACtB,IAAI,UAAU,GAAG,IAAA,sBAAqB,GAAO,CAAC;IAC9C,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAA,mBAAW,GAAE,CAAC;IAE/B,MAAM,yBAAyB,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACnD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,MAAM,GAAG,IAAA,kBAAW,EAAC,MAAM,CAAC,CAAC;SAC9B;QAED,IAAI,MAAM,KAAK,GAAG,EAAE;YAClB,OAAO,EAAE,CAAC;SACX;QAED,IAAI,KAAK,GAAG,oBAAK,CAAC,gBA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EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvB,IAAI,yBAAyB,KAAK,SAAS,EAAE;QAC3C,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,yBAAgC,CAAC,CAAC;KACrE;IAED,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,GAAG,GAA2B,EAAE,CAAC;QAEvC,UAAU,GAAG,iBAAiB,CAAC;QAE/B,OAAO,UAAU,EAAE;YACjB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC;YACpC,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;SACrC;QAED,MAAM,IAAI,KAAK,CACb,gDAAgD,MAAM,6BAA6B,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CACvG,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AArFD,sCAqFC","sourcesContent":["'use client';\nimport {\n useNavigation as useUpstreamNavigation,\n NavigationProp,\n NavigationState,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { store } from './global-state/router-store';\nimport { useSegments } from './hooks';\nimport { resolveHref } from './link/href';\nimport { Href } from './types';\n\n/**\n * Returns the underlying React Navigation [`navigation`
|
|
1
|
+
{"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AACb,qDAIkC;AAClC,kDAA0B;AAE1B,8DAAoD;AACpD,mCAAsC;AACtC,sCAA0C;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,SAAgB,aAAa,CAI3B,MAAsB;IACtB,IAAI,UAAU,GAAG,IAAA,sBAAqB,GAAO,CAAC;IAC9C,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAA,mBAAW,GAAE,CAAC;IAE/B,MAAM,yBAAyB,GAAG,eAA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AAK,CAAC,GAAG,EAAE,CAAC;iBACb;qBAAM;oBACL,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;iBACH;aACF;YAED,UAAU,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;QAED,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvB,IAAI,yBAAyB,KAAK,SAAS,EAAE;QAC3C,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,yBAAgC,CAAC,CAAC;KACrE;IAED,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,GAAG,GAA2B,EAAE,CAAC;QAEvC,UAAU,GAAG,iBAAiB,CAAC;QAE/B,OAAO,UAAU,EAAE;YACjB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC;YACpC,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;SACrC;QAED,MAAM,IAAI,KAAK,CACb,gDAAgD,MAAM,6BAA6B,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CACvG,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AArFD,sCAqFC","sourcesContent":["'use client';\nimport {\n useNavigation as useUpstreamNavigation,\n NavigationProp,\n NavigationState,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { store } from './global-state/router-store';\nimport { useSegments } from './hooks';\nimport { resolveHref } from './link/href';\nimport { Href } from './types';\n\n/**\n * Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)\n * to imperatively access layout-specific functionality like `navigation.openDrawer()` in a\n * [Drawer](/router/advanced/drawer/) layout.\n *\n * @example\n * ```tsx app/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function Route() {\n * // Access the current navigation object for the current route.\n * const navigation = useNavigation();\n *\n * return (\n * <View>\n * <Text onPress={() => {\n * // Open the drawer view.\n * navigation.openDrawer();\n * }}>\n * Open Drawer\n * </Text>\n * </View>\n * );\n * }\n * ```\n *\n * When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.\n * For example, `/menu/_layout.tsx` is nested inside `/app/orders/`, you can use `useNavigation('/orders/menu/')`.\n *\n * @example\n * ```tsx app/orders/menu/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function MenuRoute() {\n * const rootLayout = useNavigation('/');\n * const ordersLayout = useNavigation('/orders');\n *\n * // Same as the default results of `useNavigation()` when invoked in this route.\n * const parentLayout = useNavigation('/orders/menu');\n * }\n * ```\n *\n * If you attempt to access a layout that doesn't exist, an error such as\n * `Could not find parent navigation with route \"/non-existent\"` is thrown.\n *\n *\n * @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.\n * @returns The navigation object for the current route.\n *\n * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)\n * for more information.\n */\nexport function useNavigation<\n T = Omit<NavigationProp<ReactNavigation.RootParamList>, 'getState'> & {\n getState(): NavigationState | undefined;\n },\n>(parent?: string | Href): T {\n let navigation = useUpstreamNavigation<any>();\n const initialNavigation = navigation;\n const segments = useSegments();\n\n const targetNavigatorContextKey = React.useMemo(() => {\n if (!parent) {\n return;\n }\n\n if (typeof parent === 'object') {\n parent = resolveHref(parent);\n }\n\n if (parent === '/') {\n return '';\n }\n\n let state = store.getStateFromPath(parent.startsWith('../') ? segments.join('/') : parent);\n\n // Reconstruct the context key from the state\n let contextKey = '';\n const names: string[] = [];\n\n while (state) {\n const routes = state.routes;\n const route = routes[state.index ?? routes.length - 1];\n\n if (route.state) {\n contextKey = `${contextKey}/${route.name}`;\n names.push(route.name);\n\n if (parent === contextKey) {\n break;\n }\n\n state = route.state;\n } else {\n break;\n }\n }\n\n if (parent.startsWith('../')) {\n const parentSegments = parent.split('/').filter(Boolean);\n\n for (const segment of parentSegments) {\n if (segment === '..') {\n names.pop();\n } else {\n throw new Error(\n \"Relative parent paths may only contain '..' and cannot contain other segments\"\n );\n }\n }\n\n contextKey = names.length > 0 ? `/${names.join('/')}` : '';\n }\n\n return contextKey;\n }, [segments, parent]);\n\n if (targetNavigatorContextKey !== undefined) {\n navigation = navigation.getParent(targetNavigatorContextKey as any);\n }\n\n if (!navigation) {\n const ids: (string | undefined)[] = [];\n\n navigation = initialNavigation;\n\n while (navigation) {\n ids.push(navigation.getId() || '/');\n navigation = navigation.getParent();\n }\n\n throw new Error(\n `Could not find parent navigation with route \"${parent}\". Available routes are: '${ids.join(\"', '\")}'`\n );\n }\n\n return navigation;\n}\n"]}
|
package/build/useScreens.d.ts
CHANGED
|
@@ -28,10 +28,10 @@ export type ScreenProps<TOptions extends Record<string, any> = Record<string, an
|
|
|
28
28
|
export declare function useSortedScreens(order: ScreenProps[]): React.ReactNode[];
|
|
29
29
|
/** Wrap the component with various enhancements and add access to child routes. */
|
|
30
30
|
export declare function getQualifiedRouteComponent(value: RouteNode): React.ComponentType<any> | React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
/** @returns a function which provides a screen id that matches the dynamic route name in params. */
|
|
32
|
+
export declare function createGetIdForRoute(route: Pick<RouteNode, 'dynamic' | 'route' | 'contextKey' | 'children'>): ({ params }?: {
|
|
33
|
+
params?: Record<string, any> | undefined;
|
|
34
|
+
}) => any;
|
|
35
35
|
export declare function screenOptionsFactory(route: RouteNode, options?: ScreenProps['options']): RouteConfig<any, any, any, any, any, any>['options'];
|
|
36
|
-
export declare function routeToScreen(route: RouteNode, { options,
|
|
36
|
+
export declare function routeToScreen(route: RouteNode, { options, ...props }?: Partial<ScreenProps>): React.JSX.Element;
|
|
37
37
|
//# sourceMappingURL=useScreens.d.ts.map
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,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAE9C,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,KAAK,MAAM,GAAG,SAAS,CAAC;CAC9E,CAAC;AA2DF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAUxE;AAuCD,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,+GAgE1D;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,CAAC;;UAoCxE;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAC/B,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,CAqBtD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,GAAE,OAAO,CAAC,WAAW,CAAM,qBAY/F"}
|
package/build/useScreens.js
CHANGED
|
@@ -138,27 +138,19 @@ function getQualifiedRouteComponent(value) {
|
|
|
138
138
|
return QualifiedRoute;
|
|
139
139
|
}
|
|
140
140
|
exports.getQualifiedRouteComponent = getQualifiedRouteComponent;
|
|
141
|
-
/**
|
|
142
|
-
|
|
143
|
-
* @returns a function which provides a screen id that matches the dynamic route name in params. */
|
|
144
|
-
function createGetIdForRoute(route, getId) {
|
|
141
|
+
/** @returns a function which provides a screen id that matches the dynamic route name in params. */
|
|
142
|
+
function createGetIdForRoute(route) {
|
|
145
143
|
const include = new Map();
|
|
146
144
|
if (route.dynamic) {
|
|
147
145
|
for (const segment of route.dynamic) {
|
|
148
146
|
include.set(segment.name, segment);
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
|
-
return (
|
|
152
|
-
const { params = {} } = options;
|
|
149
|
+
return ({ params = {} } = {}) => {
|
|
153
150
|
if (params.__EXPO_ROUTER_key) {
|
|
154
151
|
const key = params.__EXPO_ROUTER_key;
|
|
155
152
|
delete params.__EXPO_ROUTER_key;
|
|
156
|
-
|
|
157
|
-
return key;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (getId != null) {
|
|
161
|
-
return getId(options);
|
|
153
|
+
return key;
|
|
162
154
|
}
|
|
163
155
|
const segments = [];
|
|
164
156
|
for (const dynamic of include.values()) {
|
|
@@ -203,8 +195,10 @@ function screenOptionsFactory(route, options) {
|
|
|
203
195
|
};
|
|
204
196
|
}
|
|
205
197
|
exports.screenOptionsFactory = screenOptionsFactory;
|
|
206
|
-
function routeToScreen(route, { options,
|
|
207
|
-
return (<primitives_1.Screen
|
|
198
|
+
function routeToScreen(route, { options, ...props } = {}) {
|
|
199
|
+
return (<primitives_1.Screen
|
|
200
|
+
// Users can override the screen getId function.
|
|
201
|
+
getId={createGetIdForRoute(route)} {...props} name={route.route} key={route.route} options={screenOptionsFactory(route, options)} getComponent={() => getQualifiedRouteComponent(route)}/>);
|
|
208
202
|
}
|
|
209
203
|
exports.routeToScreen = routeToScreen;
|
|
210
204
|
//# sourceMappingURL=useScreens.js.map
|