expo-router 4.0.18-canary-20250306-d9d3e02 → 4.0.19
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/NavigationContainer.js.map +1 -1
- package/build/fork/getStateFromPath-forks.d.ts +1 -1
- package/build/fork/useBackButton.d.ts +1 -1
- package/build/fork/useBackButton.d.ts.map +1 -1
- package/build/fork/useBackButton.js.map +1 -1
- package/build/fork/useDocumentTitle.d.ts +1 -1
- package/build/fork/useDocumentTitle.d.ts.map +1 -1
- package/build/fork/useDocumentTitle.js.map +1 -1
- package/build/fork/useLinking.d.ts +1 -2
- 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/head/ExpoHead.ios.d.ts.map +1 -1
- package/build/head/ExpoHead.ios.js +3 -18
- package/build/head/ExpoHead.ios.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/DrawerClient.d.ts +6 -6
- package/build/layouts/StackClient.d.ts +6 -6
- package/build/layouts/TabsClient.d.ts +6 -6
- package/build/layouts/withLayoutContext.d.ts +2 -28
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +4 -34
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +2 -2
- 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/client.js +1 -1
- package/build/rsc/router/client.js.map +1 -1
- package/build/rsc/router/host.d.ts +5 -5
- 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 +4 -17
- package/build/ui/Tabs.js.map +1 -1
- package/build/ui/useComponent.d.ts +1 -1
- package/build/ui/useComponent.d.ts.map +1 -1
- package/build/ui/useComponent.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/build/views/Navigator.d.ts +1 -1
- package/build/views/Navigator.d.ts.map +1 -1
- package/build/views/Try.d.ts +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
|
@@ -8,30 +8,6 @@ export declare namespace ExpoRouter {
|
|
|
8
8
|
interface __routes {
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
export type HrefObject = {
|
|
12
|
-
/** The path of the route. */
|
|
13
|
-
pathname: string;
|
|
14
|
-
/** Optional parameters for the route. */
|
|
15
|
-
params?: UnknownInputParams;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* @hidden
|
|
19
|
-
*/
|
|
20
|
-
export type HrefInputParamsObject = {
|
|
21
|
-
/** The path of the route. */
|
|
22
|
-
pathname: string;
|
|
23
|
-
/** Optional input parameters for the route. */
|
|
24
|
-
params?: UnknownInputParams;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* @hidden
|
|
28
|
-
*/
|
|
29
|
-
export type HrefOutputParamsObject = {
|
|
30
|
-
/** The path of the route */
|
|
31
|
-
pathname: string;
|
|
32
|
-
/** Optional output parameters for the route */
|
|
33
|
-
params?: UnknownOutputParams;
|
|
34
|
-
};
|
|
35
11
|
export type RelativePathString = `./${string}` | `../${string}` | '..';
|
|
36
12
|
export type SearchOrHash = `?${string}` | `#${string}`;
|
|
37
13
|
export type ExternalPathString = `${string}:${string}` | `//${string}`;
|
|
@@ -46,36 +22,36 @@ RelativePathString | ExternalPathString>;
|
|
|
46
22
|
* a full path like `/profile/settings` or a relative path like `../settings`.
|
|
47
23
|
* The params can be an object of key-value pairs.
|
|
48
24
|
*
|
|
49
|
-
*
|
|
25
|
+
* A Href can either be a string or an object.
|
|
50
26
|
*/
|
|
51
|
-
export type Href
|
|
27
|
+
export type Href = ExpoRouter.__routes extends {
|
|
52
28
|
href: any;
|
|
53
|
-
} ?
|
|
54
|
-
|
|
29
|
+
} ? ExpoRouter.__routes['href'] : string | {
|
|
30
|
+
pathname: string;
|
|
31
|
+
params?: UnknownInputParams;
|
|
32
|
+
};
|
|
33
|
+
export type HrefInputParams = ExpoRouter.__routes extends {
|
|
55
34
|
hrefInputParams: any;
|
|
56
|
-
} ?
|
|
57
|
-
|
|
35
|
+
} ? ExpoRouter.__routes['hrefInputParams'] : {
|
|
36
|
+
pathname: string;
|
|
37
|
+
params?: UnknownInputParams;
|
|
38
|
+
};
|
|
39
|
+
export type HrefOutputParams = ExpoRouter.__routes extends {
|
|
58
40
|
hrefOutputParams: any;
|
|
59
|
-
} ?
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
41
|
+
} ? ExpoRouter.__routes['hrefOutputParams'] : {
|
|
42
|
+
pathname: string;
|
|
43
|
+
params?: UnknownOutputParams;
|
|
44
|
+
};
|
|
63
45
|
export type RouteInputParams<T extends Route> = Extract<Href, {
|
|
64
46
|
pathname: T;
|
|
65
47
|
}> extends never ? HrefInputParams extends infer H ? H extends Record<'pathname' | 'params', any> ? T extends H['pathname'] ? H['params'] : never : never : never : Extract<HrefInputParams, {
|
|
66
48
|
pathname: T;
|
|
67
49
|
}>['params'];
|
|
68
|
-
/**
|
|
69
|
-
* @hidden
|
|
70
|
-
*/
|
|
71
50
|
export type RouteOutputParams<T extends Route> = Extract<HrefOutputParams, {
|
|
72
51
|
pathname: T;
|
|
73
52
|
}> extends never ? HrefOutputParams extends infer H ? H extends Record<'pathname' | 'params', any> ? T extends H['pathname'] ? H['params'] : never : never : never : Extract<HrefOutputParams, {
|
|
74
53
|
pathname: T;
|
|
75
54
|
}>['params'];
|
|
76
|
-
/**
|
|
77
|
-
* @hidden
|
|
78
|
-
*/
|
|
79
55
|
export type RouteParams<T extends Route> = RouteOutputParams<T>;
|
|
80
56
|
/**
|
|
81
57
|
* Routes can have known inputs (e.g query params).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/typed-routes/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,yBAAiB,UAAU,CAAC;IAE1B,UAAiB,QAAQ;KAAG;CAC7B;AAED,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/typed-routes/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,yBAAiB,UAAU,CAAC;IAE1B,UAAiB,QAAQ;KAAG;CAC7B;AAED,MAAM,MAAM,kBAAkB,GAAG,KAAK,MAAM,EAAE,GAAG,MAAM,MAAM,EAAE,GAAG,IAAI,CAAC;AACvE,MAAM,MAAM,YAAY,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,CAAC;AACvD,MAAM,MAAM,kBAAkB,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,GAAG,KAAK,MAAM,EAAE,CAAC;AACvE,MAAM,MAAM,KAAK,GAAG,OAAO,CACzB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,EAAE,sDAAsD;AACzF,AADmC,sDAAsD;AACzF,kBAAkB,GAAG,kBAAkB,CACxC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,SAAS;IAAE,IAAI,EAAE,GAAG,CAAA;CAAE,GACxD,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,GAC3B,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,QAAQ,SAAS;IAAE,eAAe,EAAE,GAAG,CAAA;CAAE,GAC9E,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GACtC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC;AA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AAI,MAAM,KAAK,EAAE,GACpD,CAAC,KAAK,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,GAChC,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/typed-routes/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The main routing type for Expo Router.\n *\n * @internal\n * @hidden\n */\nexport namespace ExpoRouter {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-object-type\n export interface __routes {}\n}\n\nexport type
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/typed-routes/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The main routing type for Expo Router.\n *\n * @internal\n * @hidden\n */\nexport namespace ExpoRouter {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-object-type\n export interface __routes {}\n}\n\nexport type RelativePathString = `./${string}` | `../${string}` | '..';\nexport type SearchOrHash = `?${string}` | `#${string}`;\nexport type ExternalPathString = `${string}:${string}` | `//${string}`;\nexport type Route = Exclude<\n Extract<Href, object>['pathname'], // Use the HrefObject, as it doesn't have query params\n RelativePathString | ExternalPathString\n>;\n\n/**\n * The main routing type for Expo Router. It includes all available routes with strongly\n * typed parameters. It can either be:\n * - **string**: A full path like `/profile/settings` or a relative path like `../settings`.\n * - **object**: An object with a `pathname` and optional `params`. The `pathname` can be\n * a full path like `/profile/settings` or a relative path like `../settings`.\n * The params can be an object of key-value pairs.\n *\n * A Href can either be a string or an object.\n */\nexport type Href = ExpoRouter.__routes extends { href: any }\n ? ExpoRouter.__routes['href']\n : string | { pathname: string; params?: UnknownInputParams };\n\nexport type HrefInputParams = ExpoRouter.__routes extends { hrefInputParams: any }\n ? ExpoRouter.__routes['hrefInputParams']\n : { pathname: string; params?: UnknownInputParams };\n\nexport type HrefOutputParams = ExpoRouter.__routes extends { hrefOutputParams: any }\n ? ExpoRouter.__routes['hrefOutputParams']\n : { pathname: string; params?: UnknownOutputParams };\n\nexport type RouteInputParams<T extends Route> =\n Extract<Href, { pathname: T }> extends never\n ? HrefInputParams extends infer H\n ? H extends Record<'pathname' | 'params', any>\n ? T extends H['pathname']\n ? H['params']\n : never\n : never\n : never\n : Extract<HrefInputParams, { pathname: T }>['params'];\n\nexport type RouteOutputParams<T extends Route> =\n Extract<HrefOutputParams, { pathname: T }> extends never\n ? HrefOutputParams extends infer H\n ? H extends Record<'pathname' | 'params', any>\n ? T extends H['pathname']\n ? H['params']\n : never\n : never\n : never\n : Extract<HrefOutputParams, { pathname: T }>['params'];\n\nexport type RouteParams<T extends Route> = RouteOutputParams<T>;\n\n/**\n * Routes can have known inputs (e.g query params).\n * Unlike outputs, inputs can be `undefined` or `null`.\n *\n * @hidden\n */\nexport type UnknownInputParams = Record<\n string,\n string | number | undefined | null | (string | number)[]\n>;\n\n/**\n * Routes can have unknown outputs (e.g query params).\n * Unlike inputs, outputs can't be undefined or null.\n *\n * @hidden\n */\nexport type UnknownOutputParams = Record<string, string | string[]>;\n\n/**\n * Return only the RoutePart of a string. If the string has multiple parts return never\n *\n * string | type\n *| ---------|------|\n *| 123 | 123 |\n *| /123/abc | never |\n *| 123?abc | never |\n *| ./123 | never |\n *| /123 | never |\n *| 123/../ | never |\n *\n * @hidden\n */\nexport type SingleRoutePart<S extends string | object> = S extends object\n ? never\n : S extends `${string}/${string}`\n ? never\n : S extends `${string}${SearchOrHash}`\n ? never\n : S extends ''\n ? never\n : S extends `(${string})`\n ? never\n : S extends `[${string}]`\n ? never\n : S;\n\n/**\n * @deprecated Use `RouteParams` or `StrictRouteParams` instead.\n *\n * @hidden\n */\nexport type SearchParams<T extends string = never> = RouteParams<T>;\n\n/**\n * @hidden\n */\nexport type RouteSegments<HrefOrSegments extends Route | string[]> = HrefOrSegments extends string[]\n ? HrefOrSegments\n : HrefOrSegments extends `.${string}`\n ? never\n : HrefOrSegments extends ``\n ? never\n : HrefOrSegments extends `/${infer PartA}`\n ? RouteSegments<PartA>\n : HrefOrSegments extends `${infer PartA}?${string}`\n ? RouteSegments<PartA>\n : HrefOrSegments extends `${infer PartA}#${string}`\n ? RouteSegments<PartA>\n : HrefOrSegments extends `${infer PartA}/${infer PartB}`\n ? [PartA, ...RouteSegments<PartB>]\n : [HrefOrSegments];\n"]}
|
package/build/ui/TabContext.d.ts
CHANGED
|
@@ -11,11 +11,17 @@ export type ExpoTabsNavigatorScreenOptions = {
|
|
|
11
11
|
};
|
|
12
12
|
export type ExpoTabsNavigatorOptions = DefaultNavigatorOptions<ParamListBase, string | undefined, TabNavigationState<ParamListBase>, ExpoTabsScreenOptions, TabNavigationEventMap, ExpoTabsNavigationProp<ParamListBase>> & Omit<TabRouterOptions, 'initialRouteName'> & ExpoTabsNavigatorScreenOptions;
|
|
13
13
|
export type ExpoTabsNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = NavigationProp<ParamList, RouteName, NavigatorID, TabNavigationState<ParamListBase>, ExpoTabsScreenOptions, TabNavigationEventMap>;
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
14
17
|
export type ExpoTabsScreenOptions = Pick<BottomTabNavigationOptions, 'title' | 'lazy' | 'freezeOnBlur'> & {
|
|
15
18
|
params?: object;
|
|
16
19
|
title: string;
|
|
17
20
|
action: NavigationAction;
|
|
18
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* @hidden
|
|
24
|
+
*/
|
|
19
25
|
export type TabNavigationEventMap = {
|
|
20
26
|
/**
|
|
21
27
|
* Event which fires on tapping on the tab in the tab bar.
|
|
@@ -58,7 +64,7 @@ export declare const TabsDescriptorsContext: import("react").Context<Record<stri
|
|
|
58
64
|
source?: string | undefined;
|
|
59
65
|
target?: string | undefined;
|
|
60
66
|
}>)): void;
|
|
61
|
-
navigate<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]
|
|
67
|
+
navigate<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void;
|
|
62
68
|
navigate<RouteName_1 extends string>(options: {
|
|
63
69
|
name: string;
|
|
64
70
|
params: object | undefined;
|
|
@@ -116,7 +122,7 @@ export declare const TabsNavigatorContext: import("react").Context<({
|
|
|
116
122
|
source?: string | undefined;
|
|
117
123
|
target?: string | undefined;
|
|
118
124
|
}>)): void;
|
|
119
|
-
navigate<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]
|
|
125
|
+
navigate<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void;
|
|
120
126
|
navigate<RouteName_1 extends string>(options: {
|
|
121
127
|
name: string;
|
|
122
128
|
params: object | undefined;
|
|
@@ -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,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,uBAAuB,CAC5D,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,kBAAkB,CAAC,aAAa,CAAC,EACjC,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,CAAC,aAAa,CAAC,CACtC,GAEC,IAAI,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EACN,aAAa,IAAI,eAAe,EAChC,kBAAkB,EAClB,gBAAgB,IAAI,kBAAkB,EACvC,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,GAAG;IACtD,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GACzB,eAA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YAEzF,IAAI,CAAC,WAAW,IAAI,OAAO,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE;gBACrE,QAAQ,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE;oBAC5B,KAAK,OAAO,CAAC,CAAC;wBACZ,WAAW,GAAG,KAAK,CAAC;wBACpB,MAAM;qBACP;oBACD,KAAK,QAAQ,CAAC,CAAC;wBACb,WAAW,GAAG,IAAI,CAAC;wBACnB,MAAM;qBACP;oBACD,KAAK,SAAS,CAAC,CAAC;wBACd,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC;wBAC1D,MAAM;qBACP;oBACD,OAAO,CAAC,CAAC;wBACP,6DAA6D;wBAC7D,MAAM,CAAC,OAAO,CAAC,KAAqB,CAAC;qBACtC;iBACF;aACF;YAED,IAAI,WAAW,EAAE;gBACf,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG;oBACnC,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC;oBACrC,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM;iBACjC,CAAC;gBACF,OAAO,WAAW,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;aACtE;iBAAM;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.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IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE;gBACrE,QAAQ,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE;oBAC5B,KAAK,OAAO,CAAC,CAAC;wBACZ,WAAW,GAAG,KAAK,CAAC;wBACpB,MAAM;qBACP;oBACD,KAAK,QAAQ,CAAC,CAAC;wBACb,WAAW,GAAG,IAAI,CAAC;wBACnB,MAAM;qBACP;oBACD,KAAK,SAAS,CAAC,CAAC;wBACd,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC;wBAC1D,MAAM;qBACP;oBACD,OAAO,CAAC,CAAC;wBACP,6DAA6D;wBAC7D,MAAM,CAAC,OAAO,CAAC,KAAqB,CAAC;qBACtC;iBACF;aACF;YAED,IAAI,WAAW,EAAE;gBACf,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG;oBACnC,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC;oBACrC,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM;iBACjC,CAAC;gBACF,OAAO,WAAW,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;aACtE;iBAAM;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 | 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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,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,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAElE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE;QAC5B,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACnD;IAED,OAAO,CACL,CAAC,sCAAe,CACd,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAC/B,YAAY,CACZ,KAAK,CAAC,CAAC,CAAC,MAA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,KAAK,CAAC,GAAG,CAAC,CAC1B,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAC/B,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACjC,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CACtE;MAAA,CAAC,UAAU,CAAC,MAAM,EAAE,CACtB;IAAA,EAAE,6BAAM,CAAC,CACV,CAAC;AACJ,CAAC;AAzBD,sDAyBC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAwB;IAChD,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC;AAChC,CAAC;AAFD,8BAEC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE;QACN,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,MAAM;KACf;IACD,eAAe,EAAE;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;IACD,OAAO,EAAE;QACP,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;IACD,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/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAKL,SAAS,
|
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/ui/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,gBAAgB,CAiEzF"}
|
package/build/ui/Tabs.js
CHANGED
|
@@ -53,13 +53,7 @@ function Tabs(props) {
|
|
|
53
53
|
const Comp = asChild ? common_1.SafeAreaViewSlot : react_native_1.View;
|
|
54
54
|
const { NavigationContent } = useTabsWithChildren({
|
|
55
55
|
// asChild adds an extra layer, so we need to process the child's children
|
|
56
|
-
children: asChild &&
|
|
57
|
-
(0, react_1.isValidElement)(children) &&
|
|
58
|
-
children.props &&
|
|
59
|
-
typeof children.props === 'object' &&
|
|
60
|
-
'children' in children.props
|
|
61
|
-
? children.props.children
|
|
62
|
-
: children,
|
|
56
|
+
children: asChild && (0, react_1.isValidElement)(children) ? children.props.children : children,
|
|
63
57
|
...options,
|
|
64
58
|
});
|
|
65
59
|
return (<Comp style={styles.tabsRoot} {...rest}>
|
|
@@ -69,10 +63,7 @@ function Tabs(props) {
|
|
|
69
63
|
exports.Tabs = Tabs;
|
|
70
64
|
/**
|
|
71
65
|
* Hook version of `Tabs`. The returned NavigationContent component
|
|
72
|
-
* should be rendered.
|
|
73
|
-
* and `<TabTrigger />` components exported from Expo Router.
|
|
74
|
-
*
|
|
75
|
-
* The `useTabsWithTriggers()` hook can be used for custom components.
|
|
66
|
+
* should be rendered.
|
|
76
67
|
*
|
|
77
68
|
* @see [`Tabs`](#tabs) for the component version of this hook.
|
|
78
69
|
* @example
|
|
@@ -148,11 +139,7 @@ function parseTriggersFromChildren(children, screenTriggers = [], isInTabList =
|
|
|
148
139
|
if ((0, TabList_1.isTabList)(child) && typeof child.props.children !== 'function') {
|
|
149
140
|
let children = child.props.children;
|
|
150
141
|
// <TabList asChild /> adds an extra layer. We need to parse the child's children
|
|
151
|
-
if (child.props.asChild &&
|
|
152
|
-
(0, react_1.isValidElement)(children) &&
|
|
153
|
-
children.props &&
|
|
154
|
-
typeof children.props === 'object' &&
|
|
155
|
-
'children' in children.props) {
|
|
142
|
+
if (child.props.asChild && (0, react_1.isValidElement)(children)) {
|
|
156
143
|
children = children.props.children;
|
|
157
144
|
}
|
|
158
145
|
return parseTriggersFromChildren(children, screenTriggers, isInTabList || (0, TabList_1.isTabList)(child));
|
|
@@ -164,7 +151,7 @@ function parseTriggersFromChildren(children, screenTriggers = [], isInTabList =
|
|
|
164
151
|
const { href, name } = child.props;
|
|
165
152
|
if (!href) {
|
|
166
153
|
if (process.env.NODE_ENV === 'development') {
|
|
167
|
-
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.`);
|
|
168
155
|
}
|
|
169
156
|
return;
|
|
170
157
|
}
|
package/build/ui/Tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/ui/Tabs.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAQkC;AAClC,iCAUe;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;AA0B7B;;;;;;;;;;;;;GAaG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,yBAAgB,CAAC,CAAC,CAAC,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AW,IAAI,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,gGAAgG,CAC1H,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 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:\n asChild &&\n isValidElement(children) &&\n children.props &&\n typeof children.props === 'object' &&\n 'children' in children.props\n ? (children.props.children as ReactNode)\n : 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 (\n child.props.asChild &&\n isValidElement(children) &&\n children.props &&\n typeof children.props === 'object' &&\n 'children' in children.props\n ) {\n children = children.props.children as ReactNode;\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;;;;;;;;;;;;;GAaG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,yBAAgB,CAAC,CAAC,CAAC,mBAAI,CAAC;IAE/C,MAAM,EAAE,iBAAiB,EAAE,GAAG,mBAAmB,CAAC;QAChD,0EAA0E;QAC1E,Q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AO;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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComponent.d.ts","sourceRoot":"","sources":["../../src/ui/useComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useComponent.d.ts","sourceRoot":"","sources":["../../src/ui/useComponent.tsx"],"names":[],"mappings":";AAEA;;GAEG;AACH,KAAK,MAAM,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAWzD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;cAaD,MAAM,SAAS;4CAYxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComponent.js","sourceRoot":"","sources":["../../src/ui/useComponent.tsx"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"useComponent.js","sourceRoot":"","sources":["../../src/ui/useComponent.tsx"],"names":[],"mappings":";;;AAAA,iCAAsD;AAYtD,MAAM,iBAAiB,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAS,EAAE,EAAE;IACxD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,SAAgB,YAAY,CAAC,MAAc;IACzC,MAAM,SAAS,GAAG,IAAA,cAAM,EAAgB,MAAM,CAAC,CAAC;IAEhD,+CAA+C;IAC/C,mDAAmD;IACnD,yCAAyC;IACzC,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAE3B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,cAAM,EACX,IAAA,kBAAU,EAAC,CAAC,EAAE,QAAQ,EAAiC,EAAE,IAAI,EAAE,EAAE;QAC/D,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QAEjC,IAAI,MAAM,KAAK,IAAI,EAAE;YACnB,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;SACH;QAED,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,CAAC;IAC3E,CAAC,CAAC,CACH,CAAC,OAAO,CAAC;AACZ,CAAC;AAzBD,oCAyBC","sourcesContent":["import { useRef, forwardRef, useEffect } from 'react';\n\n/**\n * Copied from @react-navigation/core\n */\ntype Render = (children: React.ReactNode) => JSX.Element;\n\ntype Props = {\n render: Render;\n children: React.ReactNode;\n};\n\nconst NavigationContent = ({ render, children }: Props) => {\n return render(children);\n};\n\nexport function useComponent(render: Render) {\n const renderRef = useRef<Render | null>(render);\n\n // Normally refs shouldn't be mutated in render\n // But we return a component which will be rendered\n // So it's just for immediate consumption\n renderRef.current = render;\n\n useEffect(() => {\n renderRef.current = null;\n });\n\n return useRef(\n forwardRef(({ children }: { children: React.ReactNode }, _ref) => {\n const render = renderRef.current;\n\n if (render === null) {\n throw new Error(\n 'The returned component must be rendered in the same render phase as the hook.'\n );\n }\n\n return <NavigationContent render={render}>{children}</NavigationContent>;\n })\n ).current;\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'> & {
|