expo-router 6.0.0-beta.0 → 6.0.0-beta.2

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.
Files changed (69) hide show
  1. package/assets/native-tabs.module.css +109 -0
  2. package/build/ExpoRoot.d.ts.map +1 -1
  3. package/build/ExpoRoot.js +0 -2
  4. package/build/ExpoRoot.js.map +1 -1
  5. package/build/fork/NavigationContainer.d.ts.map +1 -1
  6. package/build/fork/NavigationContainer.js +2 -0
  7. package/build/fork/NavigationContainer.js.map +1 -1
  8. package/build/global-state/routing.d.ts +6 -5
  9. package/build/global-state/routing.d.ts.map +1 -1
  10. package/build/global-state/routing.js +8 -11
  11. package/build/global-state/routing.js.map +1 -1
  12. package/build/head/ExpoHead.android.d.ts +1 -3
  13. package/build/imperative-api.d.ts +3 -1
  14. package/build/imperative-api.d.ts.map +1 -1
  15. package/build/imperative-api.js +4 -4
  16. package/build/imperative-api.js.map +1 -1
  17. package/build/layouts/DrawerClient.d.ts +2 -12
  18. package/build/layouts/DrawerClient.d.ts.map +1 -1
  19. package/build/layouts/StackClient.d.ts +2 -12
  20. package/build/layouts/StackClient.d.ts.map +1 -1
  21. package/build/layouts/TabsClient.d.ts +3 -18
  22. package/build/layouts/TabsClient.d.ts.map +1 -1
  23. package/build/layouts/withLayoutContext.d.ts +5 -1
  24. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  25. package/build/layouts/withLayoutContext.js +19 -6
  26. package/build/layouts/withLayoutContext.js.map +1 -1
  27. package/build/link/LinkWithPreview.d.ts.map +1 -1
  28. package/build/link/LinkWithPreview.js +1 -1
  29. package/build/link/LinkWithPreview.js.map +1 -1
  30. package/build/link/elements.d.ts +1 -9
  31. package/build/link/elements.d.ts.map +1 -1
  32. package/build/link/elements.js.map +1 -1
  33. package/build/link/preview/native.d.ts.map +1 -1
  34. package/build/link/preview/native.js +1 -1
  35. package/build/link/preview/native.js.map +1 -1
  36. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.d.ts.map +1 -1
  37. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.js +17 -4
  38. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.js.map +1 -1
  39. package/build/native-tabs/NativeBottomTabs/NativeTabsView.d.ts.map +1 -1
  40. package/build/native-tabs/NativeBottomTabs/NativeTabsView.js +10 -19
  41. package/build/native-tabs/NativeBottomTabs/NativeTabsView.js.map +1 -1
  42. package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.d.ts +4 -0
  43. package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.d.ts.map +1 -0
  44. package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.js +128 -0
  45. package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.js.map +1 -0
  46. package/build/native-tabs/NativeBottomTabs/types.d.ts +28 -1
  47. package/build/native-tabs/NativeBottomTabs/types.d.ts.map +1 -1
  48. package/build/native-tabs/NativeBottomTabs/types.js.map +1 -1
  49. package/build/rsc/router/client.d.ts +1 -3
  50. package/build/rsc/router/client.d.ts.map +1 -1
  51. package/build/testing-library/index.d.ts +15 -4
  52. package/build/testing-library/index.d.ts.map +1 -1
  53. package/build/testing-library/index.js +31 -28
  54. package/build/testing-library/index.js.map +1 -1
  55. package/build/testing-library/mocks.js +0 -7
  56. package/build/testing-library/mocks.js.map +1 -1
  57. package/build/ui/TabContext.d.ts +11 -21
  58. package/build/ui/TabContext.d.ts.map +1 -1
  59. package/build/ui/TabRouter.d.ts +7 -0
  60. package/build/ui/TabRouter.d.ts.map +1 -1
  61. package/build/ui/Tabs.d.ts +14 -23
  62. package/build/ui/Tabs.d.ts.map +1 -1
  63. package/build/useScreens.d.ts +1 -1
  64. package/build/useScreens.d.ts.map +1 -1
  65. package/build/useScreens.js +6 -4
  66. package/build/useScreens.js.map +1 -1
  67. package/package.json +22 -24
  68. package/plugin/build/index.js +1 -1
  69. package/plugin/src/index.ts +1 -1
@@ -1 +1 @@
1
- {"version":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n enableFreeze,\n featureFlags,\n type BottomTabsScreenProps,\n} from 'react-native-screens';\n\nimport type { NativeTabOptions, NativeTabsViewProps } from './types';\nimport { shouldTabBeVisible } from './utils';\nimport { getPathFromState } from '../../link/linking';\n\n// We let native tabs to control the changes. This requires freeze to be disabled for tab bar.\n// Otherwise user may see glitches when switching between tabs.\nfeatureFlags.experiment.controlledBottomTabs = false;\n\n// TODO: ENG-16896: Enable freeze globally and disable only for NativeTabsView\nenableFreeze(false);\n\n// TODO: Add support for dynamic params inside a route\nexport function NativeTabsView(props: NativeTabsViewProps) {\n const { builder, style, minimizeBehavior, disableIndicator } = props;\n const { state, descriptors, navigation } = builder;\n const { routes } = state;\n\n let focusedIndex = state.index;\n const isAnyRouteFocused =\n routes[focusedIndex].key &&\n descriptors[routes[focusedIndex].key] &&\n shouldTabBeVisible(descriptors[routes[focusedIndex].key].options);\n\n if (!isAnyRouteFocused) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n `The focused tab in NativeTabsView cannot be displayed. Make sure path is correct and the route is not hidden. Path: \"${getPathFromState(state)}\"`\n );\n }\n // Set focusedIndex to the first visible tab\n focusedIndex = routes.findIndex((route) => shouldTabBeVisible(descriptors[route.key].options));\n }\n\n // This is flag that is set to true, when the transition is executed by native tab change\n // In this case we don't need to change the isFocused of the screens, because the transition will happen on native side\n const isDuringNativeTransition = useRef<boolean>(false);\n // This is the last index that was not part of a native transition, e.g navigation from link\n const lastNotNativeTransitionIndex = useRef<number>(focusedIndex);\n\n // If the flag was set in the onNativeFocusChange handler, it will be still true here\n // It is set to false, later in this function\n // Thus if it is false, we know that the transition was not triggered by a native tab change\n // and we need to reset the lastNotNativeTransitionIndex\n if (!isDuringNativeTransition.current) {\n lastNotNativeTransitionIndex.current = focusedIndex;\n }\n\n const children = routes\n .map((route, index) => ({ route, index }))\n .filter(({ route: { key } }) => shouldTabBeVisible(descriptors[key].options))\n .map(({ route, index }) => {\n const descriptor = descriptors[route.key];\n // In case of native transition we want to keep the last focused index\n // Otherwise the lastNotNativeTransitionIndex is set to focusedIndex in the if above this statement\n const isFocused = index === lastNotNativeTransitionIndex.current;\n const title = descriptor.options.title ?? route.name;\n\n return (\n <BottomTabsScreen\n key={route.key}\n {...descriptor.options}\n iconResourceName={descriptor.options.icon?.drawable}\n icon={convertOptionsIconToPropsIcon(descriptor.options.icon)}\n selectedIcon={convertOptionsIconToPropsIcon(descriptor.options.selectedIcon)}\n title={title}\n tabKey={route.key}\n isFocused={isFocused}>\n {descriptor.render()}\n </BottomTabsScreen>\n );\n });\n\n // The native render is over, we can reset the flag\n isDuringNativeTransition.current = false;\n\n return (\n <BottomTabs\n tabBarItemTitleFontColor={style?.color}\n tabBarItemTitleFontFamily={style?.fontFamily}\n tabBarItemTitleFontSize={style?.fontSize}\n tabBarItemTitleFontWeight={style?.fontWeight}\n tabBarItemTitleFontStyle={style?.fontStyle}\n tabBarBackgroundColor={style?.backgroundColor}\n tabBarBlurEffect={style?.blurEffect}\n tabBarTintColor={style?.tintColor}\n tabBarItemBadgeBackgroundColor={style?.badgeBackgroundColor}\n tabBarItemRippleColor={style?.rippleColor}\n tabBarItemLabelVisibilityMode={style?.labelVisibilityMode}\n tabBarItemIconColor={style?.iconColor}\n tabBarItemIconColorActive={style?.['&:active']?.iconColor ?? style?.tintColor}\n tabBarItemTitleFontColorActive={style?.['&:active']?.color ?? style?.tintColor}\n tabBarItemTitleFontSizeActive={style?.['&:active']?.fontSize}\n tabBarItemActiveIndicatorColor={style?.['&:active']?.indicatorColor}\n tabBarItemActiveIndicatorEnabled={!disableIndicator}\n tabBarMinimizeBehavior={minimizeBehavior}\n onNativeFocusChange={({ nativeEvent: { tabKey } }) => {\n const descriptor = descriptors[tabKey];\n const route = descriptor.route;\n navigation.dispatch({\n type: 'JUMP_TO',\n target: state.key,\n payload: {\n name: route.name,\n },\n });\n isDuringNativeTransition.current = true;\n }}>\n {children}\n </BottomTabs>\n );\n}\n\nfunction convertOptionsIconToPropsIcon(\n icon: NativeTabOptions['icon']\n): BottomTabsScreenProps['icon'] {\n if (!icon) {\n return undefined;\n }\n if ('sf' in icon && icon.sf) {\n return { sfSymbolName: icon.sf };\n } else if ('src' in icon && icon.src) {\n return { templateSource: icon.src };\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"NativeTabsView.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,wCA6FC;AA5GD,+CAAsC;AACtC,+DAK8B;AAG9B,mCAA6C;AAE7C,8FAA8F;AAC9F,+DAA+D;AAC/D,mCAAY,CAAC,UAAU,CAAC,oBAAoB,GAAG,KAAK,CAAC;AAErD,SAAgB,cAAc,CAAC,KAA0B;IACvD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IACnF,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACnD,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAEzB,yFAAyF;IACzF,uHAAuH;IACvH,MAAM,wBAAwB,GAAG,IAAA,cAAM,EAAU,KAAK,CAAC,CAAC;IACxD,4FAA4F;IAC5F,MAAM,4BAA4B,GAAG,IAAA,cAAM,EAAS,YAAY,CAAC,CAAC;IAElE,qFAAqF;IACrF,6CAA6C;IAC7C,4FAA4F;IAC5F,wDAAwD;IACxD,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC;QACtC,4BAA4B,CAAC,OAAO,GAAG,YAAY,CAAC;IACtD,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM;SACpB,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;SACzC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,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CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE;YACnD,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;YAC/B,UAAU,CAAC,QAAQ,CAAC;gBAClB,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,KAAK,CAAC,GAAG;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,KAAK,CAAC,IAAI;iBACjB;aACF,CAAC,CAAC;YACH,wBAAwB,CAAC,OAAO,GAAG,IAAI,CAAC;QAC1C,CAAC,CAAC,CACF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,iCAAU,CAAC,CACd,CAAC;AACJ,CAAC;AAED,SAAS,6BAA6B,CACpC,IAA8B;IAE9B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QAC5B,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IACnC,CAAC;SAAM,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACrC,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import React, { useRef } from 'react';\nimport {\n BottomTabs,\n BottomTabsScreen,\n featureFlags,\n type BottomTabsScreenProps,\n} from 'react-native-screens';\n\nimport type { NativeTabOptions, NativeTabsViewProps } from './types';\nimport { shouldTabBeVisible } from './utils';\n\n// We let native tabs to control the changes. This requires freeze to be disabled for tab bar.\n// Otherwise user may see glitches when switching between tabs.\nfeatureFlags.experiment.controlledBottomTabs = false;\n\nexport function NativeTabsView(props: NativeTabsViewProps) {\n const { builder, style, minimizeBehavior, disableIndicator, focusedIndex } = props;\n const { state, descriptors, navigation } = builder;\n const { routes } = state;\n\n // This is flag that is set to true, when the transition is executed by native tab change\n // In this case we don't need to change the isFocused of the screens, because the transition will happen on native side\n const isDuringNativeTransition = useRef<boolean>(false);\n // This is the last index that was not part of a native transition, e.g navigation from link\n const lastNotNativeTransitionIndex = useRef<number>(focusedIndex);\n\n // If the flag was set in the onNativeFocusChange handler, it will be still true here\n // It is set to false, later in this function\n // Thus if it is false, we know that the transition was not triggered by a native tab change\n // and we need to reset the lastNotNativeTransitionIndex\n if (!isDuringNativeTransition.current) {\n lastNotNativeTransitionIndex.current = focusedIndex;\n }\n\n const children = routes\n .map((route, index) => ({ route, index }))\n .filter(({ route: { key } }) => shouldTabBeVisible(descriptors[key].options))\n .map(({ route, index }) => {\n const descriptor = descriptors[route.key];\n // In case of native transition we want to keep the last focused index\n // Otherwise the lastNotNativeTransitionIndex is set to focusedIndex in the if above this statement\n const isFocused = index === focusedIndex;\n // TODO: Find a proper fix, that allows for proper JS navigation\n //lastNotNativeTransitionIndex.current;\n const title = descriptor.options.title ?? route.name;\n\n return (\n <BottomTabsScreen\n key={route.key}\n {...descriptor.options}\n tabBarItemBadgeBackgroundColor={style?.badgeBackgroundColor}\n tabBarItemBadgeTextColor={style?.badgeTextColor}\n tabBarItemTitlePositionAdjustment={style?.titlePositionAdjustment}\n iconResourceName={descriptor.options.icon?.drawable}\n icon={convertOptionsIconToPropsIcon(descriptor.options.icon)}\n selectedIcon={convertOptionsIconToPropsIcon(descriptor.options.selectedIcon)}\n title={title}\n freezeContents={false}\n tabKey={route.key}\n isFocused={isFocused}>\n {descriptor.render()}\n </BottomTabsScreen>\n );\n });\n\n // The native render is over, we can reset the flag\n isDuringNativeTransition.current = false;\n\n return (\n <BottomTabs\n tabBarItemTitleFontColor={style?.color}\n tabBarItemTitleFontFamily={style?.fontFamily}\n tabBarItemTitleFontSize={style?.fontSize}\n // Only string values are accepted by screens\n tabBarItemTitleFontWeight={\n style?.fontWeight\n ? (String(style.fontWeight) as `${NonNullable<(typeof style)['fontWeight']>}`)\n : undefined\n }\n tabBarItemTitleFontStyle={style?.fontStyle}\n tabBarBackgroundColor={style?.backgroundColor}\n tabBarBlurEffect={style?.blurEffect}\n tabBarTintColor={style?.tintColor}\n tabBarItemBadgeBackgroundColor={style?.badgeBackgroundColor}\n tabBarItemRippleColor={style?.rippleColor}\n tabBarItemLabelVisibilityMode={style?.labelVisibilityMode}\n tabBarItemIconColor={style?.iconColor}\n tabBarItemIconColorActive={style?.['&:active']?.iconColor ?? style?.tintColor}\n tabBarItemTitleFontColorActive={style?.['&:active']?.color ?? style?.tintColor}\n tabBarItemTitleFontSizeActive={style?.['&:active']?.fontSize}\n tabBarItemActiveIndicatorColor={style?.['&:active']?.indicatorColor}\n tabBarItemActiveIndicatorEnabled={!disableIndicator}\n tabBarMinimizeBehavior={minimizeBehavior}\n onNativeFocusChange={({ nativeEvent: { tabKey } }) => {\n const descriptor = descriptors[tabKey];\n const route = descriptor.route;\n navigation.dispatch({\n type: 'JUMP_TO',\n target: state.key,\n payload: {\n name: route.name,\n },\n });\n isDuringNativeTransition.current = true;\n }}>\n {children}\n </BottomTabs>\n );\n}\n\nfunction convertOptionsIconToPropsIcon(\n icon: NativeTabOptions['icon']\n): BottomTabsScreenProps['icon'] {\n if (!icon) {\n return undefined;\n }\n if ('sf' in icon && icon.sf) {\n return { sfSymbolName: icon.sf };\n } else if ('src' in icon && icon.src) {\n return { templateSource: icon.src };\n }\n return undefined;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { NativeTabsViewProps } from './types';
3
+ export declare function NativeTabsView(props: NativeTabsViewProps): React.JSX.Element;
4
+ //# sourceMappingURL=NativeTabsView.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeTabsView.web.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.web.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBAuDxD"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.NativeTabsView = NativeTabsView;
40
+ const react_tabs_1 = require("@radix-ui/react-tabs");
41
+ const react_1 = __importStar(require("react"));
42
+ const utils_1 = require("./utils");
43
+ const native_tabs_module_css_1 = __importDefault(require("../../../assets/native-tabs.module.css"));
44
+ function NativeTabsView(props) {
45
+ const { builder, focusedIndex } = props;
46
+ const { state, descriptors, navigation } = builder;
47
+ const { routes } = state;
48
+ const defaultTabName = (0, react_1.useMemo)(() => state.routes[focusedIndex]?.name ?? state.routes[0].name, []);
49
+ const value = state.routes[focusedIndex]?.name ?? state.routes[0].name;
50
+ const items = routes
51
+ .filter(({ key }) => (0, utils_1.shouldTabBeVisible)(descriptors[key].options))
52
+ .map((route) => (<TabItem key={route.key} route={route} title={descriptors[route.key].options.title ?? route.name} badgeValue={descriptors[route.key].options.badgeValue}/>));
53
+ const children = routes
54
+ .filter(({ key }) => (0, utils_1.shouldTabBeVisible)(descriptors[key].options))
55
+ .map((route) => {
56
+ return (<react_tabs_1.TabsContent key={route.name} value={route.name} className={native_tabs_module_css_1.default.tabContent} forceMount>
57
+ {descriptors[route.key].render()}
58
+ </react_tabs_1.TabsContent>);
59
+ });
60
+ return (<react_tabs_1.Tabs className={native_tabs_module_css_1.default.nativeTabsContainer} defaultValue={defaultTabName} value={value} onValueChange={(value) => {
61
+ navigation.dispatch({
62
+ type: 'JUMP_TO',
63
+ target: state.key,
64
+ payload: {
65
+ name: value,
66
+ },
67
+ });
68
+ }} style={convertNativeTabsPropsToStyleVars(props.style)}>
69
+ <react_tabs_1.TabsList aria-label="Main" className={native_tabs_module_css_1.default.navigationMenuRoot}>
70
+ {items}
71
+ </react_tabs_1.TabsList>
72
+ {children}
73
+ </react_tabs_1.Tabs>);
74
+ }
75
+ function TabItem(props) {
76
+ const { title, badgeValue, route } = props;
77
+ const isBadgeEmpty = badgeValue === ' ';
78
+ return (<react_tabs_1.TabsTrigger value={route.name} className={native_tabs_module_css_1.default.navigationMenuTrigger}>
79
+ <span className={native_tabs_module_css_1.default.tabText}>{title}</span>
80
+ {badgeValue && (<div className={`${native_tabs_module_css_1.default.tabBadge} ${isBadgeEmpty ? native_tabs_module_css_1.default.emptyTabBadge : ''}`}>
81
+ {badgeValue}
82
+ </div>)}
83
+ </react_tabs_1.TabsTrigger>);
84
+ }
85
+ function convertNativeTabsPropsToStyleVars(style) {
86
+ const vars = {};
87
+ if (!style) {
88
+ return vars;
89
+ }
90
+ if (style.fontFamily) {
91
+ vars['--expo-router-tabs-font-family'] = String(style.fontFamily);
92
+ }
93
+ if (style.fontSize) {
94
+ vars['--expo-router-tabs-font-size'] = String(style.fontSize);
95
+ }
96
+ if (style.fontWeight) {
97
+ vars['--expo-router-tabs-font-weight'] = String(style.fontWeight);
98
+ }
99
+ if (style.fontStyle) {
100
+ vars['--expo-router-tabs-font-style'] = String(style.fontStyle);
101
+ }
102
+ if (style.color) {
103
+ vars['--expo-router-tabs-text-color'] = String(style.color);
104
+ }
105
+ if (style['&:active']?.color) {
106
+ vars['--expo-router-tabs-active-text-color'] = String(style['&:active'].color);
107
+ }
108
+ else if (style.tintColor) {
109
+ vars['--expo-router-tabs-active-text-color'] = String(style.tintColor);
110
+ }
111
+ if (style['&:active']?.fontSize) {
112
+ vars['--expo-router-tabs-active-font-size'] = String(style['&:active'].fontSize);
113
+ }
114
+ if (style['&:active']?.indicatorColor) {
115
+ vars['--expo-router-tabs-active-background-color'] = String(style['&:active'].indicatorColor);
116
+ }
117
+ if (style.backgroundColor) {
118
+ vars['--expo-router-tabs-background-color'] = String(style.backgroundColor);
119
+ }
120
+ if (style.badgeBackgroundColor) {
121
+ vars['--expo-router-tabs-badge-background-color'] = String(style.badgeBackgroundColor);
122
+ }
123
+ if (style.badgeTextColor) {
124
+ vars['--expo-router-tabs-badge-text-color'] = String(style.badgeTextColor);
125
+ }
126
+ return vars;
127
+ }
128
+ //# sourceMappingURL=NativeTabsView.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeTabsView.web.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.web.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wCAuDC;AA9DD,qDAAgF;AAChF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, TabsList, TabsTrigger } from '@radix-ui/react-tabs';\nimport React, { useMemo } from 'react';\n\nimport type { NativeTabsViewProps } from './types';\nimport { shouldTabBeVisible } from './utils';\nimport nativeTabsStyles from '../../../assets/native-tabs.module.css';\n\nexport function NativeTabsView(props: NativeTabsViewProps) {\n const { builder, focusedIndex } = props;\n const { state, descriptors, navigation } = builder;\n const { routes } = state;\n const defaultTabName = useMemo(\n () => state.routes[focusedIndex]?.name ?? state.routes[0].name,\n []\n );\n const value = state.routes[focusedIndex]?.name ?? state.routes[0].name;\n\n const items = routes\n .filter(({ key }) => shouldTabBeVisible(descriptors[key].options))\n .map((route) => (\n <TabItem\n key={route.key}\n route={route}\n title={descriptors[route.key].options.title ?? route.name}\n badgeValue={descriptors[route.key].options.badgeValue}\n />\n ));\n const children = routes\n .filter(({ key }) => shouldTabBeVisible(descriptors[key].options))\n .map((route) => {\n return (\n <TabsContent\n key={route.name}\n value={route.name}\n className={nativeTabsStyles.tabContent}\n forceMount>\n {descriptors[route.key].render()}\n </TabsContent>\n );\n });\n\n return (\n <Tabs\n className={nativeTabsStyles.nativeTabsContainer}\n defaultValue={defaultTabName}\n value={value}\n onValueChange={(value) => {\n navigation.dispatch({\n type: 'JUMP_TO',\n target: state.key,\n payload: {\n name: value,\n },\n });\n }}\n style={convertNativeTabsPropsToStyleVars(props.style)}>\n <TabsList aria-label=\"Main\" className={nativeTabsStyles.navigationMenuRoot}>\n {items}\n </TabsList>\n {children}\n </Tabs>\n );\n}\n\ninterface TabItemProps {\n title: string;\n badgeValue?: string;\n route: { name: string };\n}\n\nfunction TabItem(props: TabItemProps) {\n const { title, badgeValue, route } = props;\n const isBadgeEmpty = badgeValue === ' ';\n\n return (\n <TabsTrigger value={route.name} className={nativeTabsStyles.navigationMenuTrigger}>\n <span className={nativeTabsStyles.tabText}>{title}</span>\n {badgeValue && (\n <div\n className={`${nativeTabsStyles.tabBadge} ${isBadgeEmpty ? nativeTabsStyles.emptyTabBadge : ''}`}>\n {badgeValue}\n </div>\n )}\n </TabsTrigger>\n );\n}\n\nfunction convertNativeTabsPropsToStyleVars(\n style: NativeTabsViewProps['style'] | undefined\n): Record<string, string | undefined> {\n const vars: Record<`--expo-router-tabs-${string}`, string | undefined> = {};\n if (!style) {\n return vars;\n }\n if (style.fontFamily) {\n vars['--expo-router-tabs-font-family'] = String(style.fontFamily);\n }\n if (style.fontSize) {\n vars['--expo-router-tabs-font-size'] = String(style.fontSize);\n }\n if (style.fontWeight) {\n vars['--expo-router-tabs-font-weight'] = String(style.fontWeight);\n }\n if (style.fontStyle) {\n vars['--expo-router-tabs-font-style'] = String(style.fontStyle);\n }\n if (style.color) {\n vars['--expo-router-tabs-text-color'] = String(style.color);\n }\n if (style['&:active']?.color) {\n vars['--expo-router-tabs-active-text-color'] = String(style['&:active'].color);\n } else if (style.tintColor) {\n vars['--expo-router-tabs-active-text-color'] = String(style.tintColor);\n }\n if (style['&:active']?.fontSize) {\n vars['--expo-router-tabs-active-font-size'] = String(style['&:active'].fontSize);\n }\n if (style['&:active']?.indicatorColor) {\n vars['--expo-router-tabs-active-background-color'] = String(style['&:active'].indicatorColor);\n }\n if (style.backgroundColor) {\n vars['--expo-router-tabs-background-color'] = String(style.backgroundColor);\n }\n if (style.badgeBackgroundColor) {\n vars['--expo-router-tabs-badge-background-color'] = String(style.badgeBackgroundColor);\n }\n if (style.badgeTextColor) {\n vars['--expo-router-tabs-badge-text-color'] = String(style.badgeTextColor);\n }\n return vars;\n}\n"]}
@@ -42,24 +42,45 @@ export interface ExtendedNativeTabOptions extends NativeTabOptions {
42
42
  hidden?: boolean;
43
43
  specialEffects?: BottomTabsScreenProps['specialEffects'];
44
44
  }
45
+ type NumericFontWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
45
46
  export interface NativeTabsStyleType {
46
47
  fontFamily?: TextStyle['fontFamily'];
47
48
  fontSize?: TextStyle['fontSize'];
48
- fontWeight?: TextStyle['fontWeight'];
49
+ fontWeight?: NumericFontWeight | `${NumericFontWeight}`;
49
50
  fontStyle?: TextStyle['fontStyle'];
50
51
  color?: TextStyle['color'];
51
52
  /**
52
53
  * @platform android
53
54
  * @platform iOS
55
+ * @platform tvOS
54
56
  */
55
57
  iconColor?: ColorValue;
56
58
  backgroundColor?: ColorValue;
59
+ /**
60
+ * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uitabbaritem/titlepositionadjustment)
61
+ *
62
+ * @platform iOS
63
+ */
64
+ titlePositionAdjustment?: {
65
+ horizontal?: number;
66
+ vertical?: number;
67
+ };
57
68
  /**
58
69
  * @platform iOS
59
70
  */
60
71
  blurEffect?: BottomTabsScreenProps['tabBarBlurEffect'];
72
+ /**
73
+ * @platform android
74
+ * @platform iOS
75
+ * @platform web
76
+ */
61
77
  tintColor?: ColorValue;
62
78
  badgeBackgroundColor?: ColorValue;
79
+ /**
80
+ * @platform android
81
+ * @platform web
82
+ */
83
+ badgeTextColor?: ColorValue;
63
84
  /**
64
85
  * @platform android
65
86
  */
@@ -70,16 +91,19 @@ export interface NativeTabsStyleType {
70
91
  labelVisibilityMode?: TabBarItemLabelVisibilityMode;
71
92
  /**
72
93
  * @platform android
94
+ * @platform web
73
95
  */
74
96
  '&:active'?: NativeTabsActiveStyleType;
75
97
  }
76
98
  export interface NativeTabsActiveStyleType {
77
99
  /**
78
100
  * @platform android
101
+ * @platform web
79
102
  */
80
103
  color?: ColorValue;
81
104
  /**
82
105
  * @platform android
106
+ * @platform web
83
107
  */
84
108
  fontSize?: TextStyle['fontSize'];
85
109
  /**
@@ -88,6 +112,7 @@ export interface NativeTabsActiveStyleType {
88
112
  iconColor?: ColorValue;
89
113
  /**
90
114
  * @platform android
115
+ * @platform web
91
116
  */
92
117
  indicatorColor?: ColorValue;
93
118
  }
@@ -121,6 +146,7 @@ export interface NativeTabsProps extends PropsWithChildren {
121
146
  backBehavior?: 'none' | 'initialRoute' | 'history';
122
147
  }
123
148
  export interface NativeTabsViewProps extends NativeTabsProps {
149
+ focusedIndex: number;
124
150
  builder: ReturnType<typeof useNavigationBuilder<TabNavigationState<ParamListBase>, TabRouterOptions, Record<string, (...args: any) => void>, NativeTabOptions, Record<string, any>>>;
125
151
  }
126
152
  export interface NativeTabTriggerProps {
@@ -163,4 +189,5 @@ export interface NativeTabTriggerProps {
163
189
  */
164
190
  children?: React.ReactNode;
165
191
  }
192
+ export {};
166
193
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,qBAAqB,EACnB,UAAU,GACV,aAAa,GACb,cAAc,GACd,aAAa,GACb,iBAAiB,GACjB,gBAAgB,GAChB,WAAW,GACX,QAAQ,GACR,MAAM,GACN,cAAc,GACd,kBAAkB,GAClB,gBAAgB,CACnB,GACC,oBAAoB,GAAG;IACrB;;;;OAIG;IACH,IAAI,CAAC,EAAE,qBAAqB,GAAG;QAC7B;;;WAGG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF;;;OAGG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,CAAC;AAEJ,MAAM,MAAM,qBAAqB,GAC7B;IACE;;;OAGG;IACH,EAAE,CAAC,EAAE,QAAQ,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AC1D,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,UAAU,CACjB,OAAO,oBAAoB,CACzB,kBAAkB,CAAC,aAAa,CAAC,EACjC,gBAAgB,EAChB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,EACtC,gBAAgB,EAChB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACpB,CACF,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DefaultRouterOptions,\n ParamListBase,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport type { PropsWithChildren } from 'react';\nimport type { ColorValue, ImageSourcePropType, TextStyle } from 'react-native';\nimport type {\n BottomTabsProps,\n BottomTabsScreenProps,\n TabBarItemLabelVisibilityMode,\n} from 'react-native-screens';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nexport type NativeTabOptions = Omit<\n BottomTabsScreenProps,\n | 'children'\n | 'placeholder'\n | 'onWillAppear'\n | 'onDidAppear'\n | 'onWillDisappear'\n | 'onDidDisappear'\n | 'isFocused'\n | 'tabKey'\n | 'icon'\n | 'selectedIcon'\n | 'iconResourceName'\n | 'specialEffects'\n> &\n DefaultRouterOptions & {\n /**\n * The icon to display in the tab bar.\n * @platform android\n * @platform iOS\n */\n icon?: SfSymbolOrImageSource & {\n /**\n * The name of the drawable resource to use as an icon.\n * @platform android\n */\n drawable?: string;\n };\n /**\n * The icon to display when the tab is selected.\n * @platform iOS\n */\n selectedIcon?: SfSymbolOrImageSource;\n };\n\nexport type SfSymbolOrImageSource =\n | {\n /**\n * The name of the SF Symbol to use as an icon.\n * @platform iOS\n */\n sf?: SFSymbol;\n }\n | {\n /**\n * The image source to use as an icon.\n * @platform iOS\n */\n src?: ImageSourcePropType;\n };\n\nexport interface ExtendedNativeTabOptions extends NativeTabOptions {\n /**\n * If true, the tab will be hidden from the tab bar.\n */\n hidden?: boolean;\n specialEffects?: BottomTabsScreenProps['specialEffects'];\n}\n\nexport interface NativeTabsStyleType {\n fontFamily?: TextStyle['fontFamily'];\n fontSize?: TextStyle['fontSize'];\n fontWeight?: TextStyle['fontWeight'];\n fontStyle?: TextStyle['fontStyle'];\n color?: TextStyle['color'];\n /**\n * @platform android\n * @platform iOS\n */\n iconColor?: ColorValue;\n backgroundColor?: ColorValue;\n /**\n * @platform iOS\n */\n blurEffect?: BottomTabsScreenProps['tabBarBlurEffect'];\n tintColor?: ColorValue;\n badgeBackgroundColor?: ColorValue;\n /**\n * @platform android\n */\n rippleColor?: ColorValue;\n /**\n * @platform android\n */\n labelVisibilityMode?: TabBarItemLabelVisibilityMode;\n /**\n * @platform android\n */\n '&:active'?: NativeTabsActiveStyleType;\n}\n\nexport interface NativeTabsActiveStyleType {\n /**\n * @platform android\n */\n color?: ColorValue;\n /**\n * @platform android\n */\n fontSize?: TextStyle['fontSize'];\n /**\n * @platform android\n */\n iconColor?: ColorValue;\n /**\n * @platform android\n */\n indicatorColor?: ColorValue;\n}\n\nexport interface NativeTabsProps extends PropsWithChildren {\n style?: NativeTabsStyleType;\n /**\n * https://developer.apple.com/documentation/uikit/uitabbarcontroller/tabbarminimizebehavior\n *\n * Supported values:\n * - `none` - The tab bar does not minimize.\n * - `onScrollUp` - The tab bar minimizes when scrolling up, and expands when scrolling back down. Recommended if the scroll view content is aligned to the bottom.\n * - `onScrollDown` - The tab bar minimizes when scrolling down, and expands when scrolling back up.\n * - `automatic` - Resolves to the system default minimize behavior.\n *\n * @default automatic\n *\n * @platform iOS 26\n */\n minimizeBehavior?: BottomTabsProps['tabBarMinimizeBehavior'];\n /**\n * Disables the active indicator for the tab bar.\n *\n * @platform android\n */\n disableIndicator?: boolean;\n /**\n * The behavior when navigating back with the back button.\n *\n * @platform android\n */\n backBehavior?: 'none' | 'initialRoute' | 'history';\n}\n\nexport interface NativeTabsViewProps extends NativeTabsProps {\n builder: ReturnType<\n typeof useNavigationBuilder<\n TabNavigationState<ParamListBase>,\n TabRouterOptions,\n Record<string, (...args: any) => void>,\n NativeTabOptions,\n Record<string, any>\n >\n >;\n}\n\nexport interface NativeTabTriggerProps {\n /**\n * The name of the route.\n *\n * This is required when used inside a Layout component.\n *\n * When used in a route it has no effect.\n */\n name?: string;\n /**\n * If true, the tab will be hidden from the tab bar.\n */\n hidden?: boolean;\n /**\n * The options for the trigger.\n *\n * Use `Icon`, `Label`, and `Badge` components as children to customize the tab, rather then raw options.\n */\n options?: NativeTabOptions;\n /**\n * If true, the tab will not pop stack to the root when selected again.\n * @default false\n *\n * @platform ios\n */\n disablePopToTop?: boolean;\n /**\n * If true, the tab will not scroll to the top when selected again.\n * @default false\n *\n * @platform ios\n */\n disableScrollToTop?: boolean;\n /**\n * The children of the trigger.\n *\n * Use `Icon`, `Label`, and `Badge` components to customize the tab.\n */\n children?: React.ReactNode;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DefaultRouterOptions,\n ParamListBase,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport type { PropsWithChildren } from 'react';\nimport type { ColorValue, ImageSourcePropType, TextStyle } from 'react-native';\nimport type {\n BottomTabsProps,\n BottomTabsScreenProps,\n TabBarItemLabelVisibilityMode,\n} from 'react-native-screens';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nexport type NativeTabOptions = Omit<\n BottomTabsScreenProps,\n | 'children'\n | 'placeholder'\n | 'onWillAppear'\n | 'onDidAppear'\n | 'onWillDisappear'\n | 'onDidDisappear'\n | 'isFocused'\n | 'tabKey'\n | 'icon'\n | 'selectedIcon'\n | 'iconResourceName'\n | 'specialEffects'\n> &\n DefaultRouterOptions & {\n /**\n * The icon to display in the tab bar.\n * @platform android\n * @platform iOS\n */\n icon?: SfSymbolOrImageSource & {\n /**\n * The name of the drawable resource to use as an icon.\n * @platform android\n */\n drawable?: string;\n };\n /**\n * The icon to display when the tab is selected.\n * @platform iOS\n */\n selectedIcon?: SfSymbolOrImageSource;\n };\n\nexport type SfSymbolOrImageSource =\n | {\n /**\n * The name of the SF Symbol to use as an icon.\n * @platform iOS\n */\n sf?: SFSymbol;\n }\n | {\n /**\n * The image source to use as an icon.\n * @platform iOS\n */\n src?: ImageSourcePropType;\n };\n\nexport interface ExtendedNativeTabOptions extends NativeTabOptions {\n /**\n * If true, the tab will be hidden from the tab bar.\n */\n hidden?: boolean;\n specialEffects?: BottomTabsScreenProps['specialEffects'];\n}\n\ntype NumericFontWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;\n\nexport interface NativeTabsStyleType {\n fontFamily?: TextStyle['fontFamily'];\n fontSize?: TextStyle['fontSize'];\n fontWeight?: NumericFontWeight | `${NumericFontWeight}`;\n fontStyle?: TextStyle['fontStyle'];\n color?: TextStyle['color'];\n /**\n * @platform android\n * @platform iOS\n * @platform tvOS\n */\n iconColor?: ColorValue;\n backgroundColor?: ColorValue;\n /**\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uitabbaritem/titlepositionadjustment)\n *\n * @platform iOS\n */\n titlePositionAdjustment?: {\n horizontal?: number;\n vertical?: number;\n };\n /**\n * @platform iOS\n */\n blurEffect?: BottomTabsScreenProps['tabBarBlurEffect'];\n /**\n * @platform android\n * @platform iOS\n * @platform web\n */\n tintColor?: ColorValue;\n badgeBackgroundColor?: ColorValue;\n /**\n * @platform android\n * @platform web\n */\n badgeTextColor?: ColorValue;\n /**\n * @platform android\n */\n rippleColor?: ColorValue;\n /**\n * @platform android\n */\n labelVisibilityMode?: TabBarItemLabelVisibilityMode;\n /**\n * @platform android\n * @platform web\n */\n '&:active'?: NativeTabsActiveStyleType;\n}\n\nexport interface NativeTabsActiveStyleType {\n /**\n * @platform android\n * @platform web\n */\n color?: ColorValue;\n /**\n * @platform android\n * @platform web\n */\n fontSize?: TextStyle['fontSize'];\n /**\n * @platform android\n */\n iconColor?: ColorValue;\n /**\n * @platform android\n * @platform web\n */\n indicatorColor?: ColorValue;\n}\n\nexport interface NativeTabsProps extends PropsWithChildren {\n style?: NativeTabsStyleType;\n /**\n * https://developer.apple.com/documentation/uikit/uitabbarcontroller/tabbarminimizebehavior\n *\n * Supported values:\n * - `none` - The tab bar does not minimize.\n * - `onScrollUp` - The tab bar minimizes when scrolling up, and expands when scrolling back down. Recommended if the scroll view content is aligned to the bottom.\n * - `onScrollDown` - The tab bar minimizes when scrolling down, and expands when scrolling back up.\n * - `automatic` - Resolves to the system default minimize behavior.\n *\n * @default automatic\n *\n * @platform iOS 26\n */\n minimizeBehavior?: BottomTabsProps['tabBarMinimizeBehavior'];\n /**\n * Disables the active indicator for the tab bar.\n *\n * @platform android\n */\n disableIndicator?: boolean;\n /**\n * The behavior when navigating back with the back button.\n *\n * @platform android\n */\n backBehavior?: 'none' | 'initialRoute' | 'history';\n}\n\nexport interface NativeTabsViewProps extends NativeTabsProps {\n focusedIndex: number;\n builder: ReturnType<\n typeof useNavigationBuilder<\n TabNavigationState<ParamListBase>,\n TabRouterOptions,\n Record<string, (...args: any) => void>,\n NativeTabOptions,\n Record<string, any>\n >\n >;\n}\n\nexport interface NativeTabTriggerProps {\n /**\n * The name of the route.\n *\n * This is required when used inside a Layout component.\n *\n * When used in a route it has no effect.\n */\n name?: string;\n /**\n * If true, the tab will be hidden from the tab bar.\n */\n hidden?: boolean;\n /**\n * The options for the trigger.\n *\n * Use `Icon`, `Label`, and `Badge` components as children to customize the tab, rather then raw options.\n */\n options?: NativeTabOptions;\n /**\n * If true, the tab will not pop stack to the root when selected again.\n * @default false\n *\n * @platform ios\n */\n disablePopToTop?: boolean;\n /**\n * If true, the tab will not scroll to the top when selected again.\n * @default false\n *\n * @platform ios\n */\n disableScrollToTop?: boolean;\n /**\n * The children of the trigger.\n *\n * Use `Icon`, `Label`, and `Badge` components to customize the tab.\n */\n children?: React.ReactNode;\n}\n"]}
@@ -55,9 +55,7 @@ export declare function Router({ routerData }: {
55
55
  export declare function ServerRouter({ children, route }: {
56
56
  children: ReactNode;
57
57
  route: RouteProps;
58
- }): import("react").FunctionComponentElement<{
59
- children?: ReactNode | undefined;
60
- }>;
58
+ }): import("react").FunctionComponentElement<import("react").FragmentProps>;
61
59
  export type LinkProps = ClassicLinkProps & {
62
60
  href: string;
63
61
  } & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/rsc/router/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,OAAO,KAAK,EAGV,SAAS,EAET,oBAAoB,EAGrB,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,IAAI,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGvF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA+O3C,wBAAgB,kBAAkB,IAAI,qBAAqB,GACzD,UAAU,GAAG;IACX,OAAO,EAAE,MAAM,IAAI,C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C;AA+O3C,wBAAgB,kBAAkB,IAAI,qBAAqB,GACzD,UAAU,GAAG;IACX,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CA4FF;AAoDD,KAAK,UAAU,GAAG,CAAC,SAAS;IAC1B,MAAM;IACN,SAAS;QACP,OAAO;QACP,MAAM,EAAE;KACT;CACF,CAAC,EAAE,CAAC;AAGL,KAAK,UAAU,GAAG;IAChB,UAAU,CAAC,EAAE,UAAU;IACvB,iBAAiB,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D,CAAC;AAIF,wBAAgB,MAAM,CAAC,EAAE,UAAgC,EAAE;;CAAA;;;;;;;;;;;;;;;;;;gBAU1D;AAKD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,2EAgB3F;AAED,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG;IACzC,IAAI,EAAE,MAAM,CAAC;CAMd,GAAG,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,CAAC;AAE1D,eAAO,MAAM,IAAI,EAA4C,aAAa,CAAC"}
@@ -1,15 +1,26 @@
1
1
  import './expect';
2
2
  import './mocks';
3
- import { render } from '@testing-library/react-native';
3
+ import React from 'react';
4
4
  import { MockContextConfig, getMockConfig, getMockContext } from './mock-config';
5
5
  import { ExpoLinkingOptions } from '../getLinkingConfig';
6
6
  import { ReactNavigationState } from '../global-state/router-store';
7
- export * from '@testing-library/react-native';
8
- export type RenderRouterOptions = Parameters<typeof render>[1] & {
7
+ declare const rnTestingLibrary: typeof import("@testing-library/react-native");
8
+ export type * from '@testing-library/react-native';
9
+ export declare const act: typeof React.act, cleanup: typeof import("@testing-library/react-native").cleanup, fireEvent: typeof import("@testing-library/react-native").fireEvent, waitFor: typeof import("@testing-library/react-native").waitFor, waitForElementToBeRemoved: typeof import("@testing-library/react-native").waitForElementToBeRemoved, within: typeof import("@testing-library/react-native").within, configure: typeof import("@testing-library/react-native").configure, resetToDefaults: typeof import("@testing-library/react-native").resetToDefaults, isHiddenFromAccessibility: typeof import("@testing-library/react-native").isHiddenFromAccessibility, isInaccessible: typeof import("@testing-library/react-native").isHiddenFromAccessibility, getDefaultNormalizer: typeof import("@testing-library/react-native").getDefaultNormalizer, renderHook: typeof import("@testing-library/react-native").renderHook, userEvent: {
10
+ setup: typeof import("@testing-library/react-native/build/user-event/setup").setup;
11
+ press: (element: import("react-test-renderer").ReactTestInstance) => Promise<void>;
12
+ longPress: (element: import("react-test-renderer").ReactTestInstance, options?: import("@testing-library/react-native/build/user-event/press").PressOptions) => Promise<void>;
13
+ type: (element: import("react-test-renderer").ReactTestInstance, text: string, options?: import("@testing-library/react-native/build/user-event/type").TypeOptions) => Promise<void>;
14
+ clear: (element: import("react-test-renderer").ReactTestInstance) => Promise<void>;
15
+ paste: (element: import("react-test-renderer").ReactTestInstance, text: string) => Promise<void>;
16
+ scrollTo: (element: import("react-test-renderer").ReactTestInstance, options: import("@testing-library/react-native/build/user-event/scroll").ScrollToOptions) => Promise<void>;
17
+ };
18
+ export declare let screen: typeof rnTestingLibrary.screen;
19
+ export type RenderRouterOptions = Parameters<typeof rnTestingLibrary.render>[1] & {
9
20
  initialUrl?: any;
10
21
  linking?: Partial<ExpoLinkingOptions>;
11
22
  };
12
- type Result = ReturnType<typeof render> & {
23
+ type Result = ReturnType<typeof rnTestingLibrary.render> & {
13
24
  getPathname(): string;
14
25
  getPathnameWithParams(): string;
15
26
  getSegments(): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,CAAC;AAClB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CAAC;CACpD,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAE5D,wBAAgB,YAAY,CAC1B,OAAO,GAAE,iBAA2B,EACpC,EAAE,UAAgB,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,GAAE,mBAAwB,GAClE,MAAM,CAmCR;AAED,eAAO,MAAM,UAAU;IACrB,yDAAyD;mBAC1C,MAAM;IAIrB,yDAAyD;eAC9C,MAAM;IAIjB,6DAA6D;kBAC/C,MAAM;IAIpB,oDAAoD;gBACxC,MAAM;IAOlB,qEAAqE;;IAIrE,wEAAwE;sBACtD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM;IAMvD,qEAAqE;;CAItE,CAAC"}
@@ -1,18 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
17
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
4
  };
@@ -21,7 +7,6 @@ exports.testRouter = exports.getMockContext = exports.getMockConfig = void 0;
21
7
  exports.renderRouter = renderRouter;
22
8
  require("./expect");
23
9
  require("./mocks");
24
- const react_native_1 = require("@testing-library/react-native");
25
10
  const react_1 = __importDefault(require("react"));
26
11
  const mock_config_1 = require("./mock-config");
27
12
  Object.defineProperty(exports, "getMockConfig", { enumerable: true, get: function () { return mock_config_1.getMockConfig; } });
@@ -29,14 +14,32 @@ Object.defineProperty(exports, "getMockContext", { enumerable: true, get: functi
29
14
  const ExpoRoot_1 = require("../ExpoRoot");
30
15
  const router_store_1 = require("../global-state/router-store");
31
16
  const imperative_api_1 = require("../imperative-api");
32
- // re-export everything
33
- __exportStar(require("@testing-library/react-native"), exports);
17
+ const rnTestingLibrary = (() => {
18
+ try {
19
+ return require('@testing-library/react-native');
20
+ }
21
+ catch (error) {
22
+ if ('code' in error && error.code === 'MODULE_NOT_FOUND') {
23
+ const newError = new Error(`[expo-router/testing-library] "@testing-library/react-native" failed to import. You need to install it to use expo-router's testing library.`);
24
+ newError.stack = error.stack;
25
+ newError.cause = error;
26
+ throw newError;
27
+ }
28
+ throw error;
29
+ }
30
+ })();
31
+ Object.assign(exports, rnTestingLibrary);
32
+ Object.defineProperty(exports, 'screen', {
33
+ get() {
34
+ return rnTestingLibrary.screen;
35
+ },
36
+ });
34
37
  function renderRouter(context = './app', { initialUrl = '/', linking, ...options } = {}) {
35
38
  jest.useFakeTimers();
36
39
  const mockContext = (0, mock_config_1.getMockContext)(context);
37
40
  // Force the render to be synchronous
38
41
  process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';
39
- const result = (0, react_native_1.render)(<ExpoRoot_1.ExpoRoot context={mockContext} location={initialUrl} linking={linking}/>, options);
42
+ const result = rnTestingLibrary.render(<ExpoRoot_1.ExpoRoot context={mockContext} location={initialUrl} linking={linking}/>, options);
40
43
  /**
41
44
  * This is a hack to ensure that React Navigation's state updates are processed before we run assertions.
42
45
  * Some updates are async and we need to wait for them to complete, otherwise will we get a false positive.
@@ -63,25 +66,25 @@ function renderRouter(context = './app', { initialUrl = '/', linking, ...options
63
66
  exports.testRouter = {
64
67
  /** Navigate to the provided pathname and the pathname */
65
68
  navigate(path) {
66
- (0, react_native_1.act)(() => imperative_api_1.router.navigate(path));
67
- expect(react_native_1.screen).toHavePathnameWithParams(path);
69
+ rnTestingLibrary.act(() => imperative_api_1.router.navigate(path));
70
+ expect(rnTestingLibrary.screen).toHavePathnameWithParams(path);
68
71
  },
69
72
  /** Push the provided pathname and assert the pathname */
70
73
  push(path) {
71
- (0, react_native_1.act)(() => imperative_api_1.router.push(path));
72
- expect(react_native_1.screen).toHavePathnameWithParams(path);
74
+ rnTestingLibrary.act(() => imperative_api_1.router.push(path));
75
+ expect(rnTestingLibrary.screen).toHavePathnameWithParams(path);
73
76
  },
74
77
  /** Replace with provided pathname and assert the pathname */
75
78
  replace(path) {
76
- (0, react_native_1.act)(() => imperative_api_1.router.replace(path));
77
- expect(react_native_1.screen).toHavePathnameWithParams(path);
79
+ rnTestingLibrary.act(() => imperative_api_1.router.replace(path));
80
+ expect(rnTestingLibrary.screen).toHavePathnameWithParams(path);
78
81
  },
79
82
  /** Go back in history and asset the new pathname */
80
83
  back(path) {
81
84
  expect(imperative_api_1.router.canGoBack()).toBe(true);
82
- (0, react_native_1.act)(() => imperative_api_1.router.back());
85
+ rnTestingLibrary.act(() => imperative_api_1.router.back());
83
86
  if (path) {
84
- expect(react_native_1.screen).toHavePathnameWithParams(path);
87
+ expect(rnTestingLibrary.screen).toHavePathnameWithParams(path);
85
88
  }
86
89
  },
87
90
  /** If there's history that supports invoking the `back` function. */
@@ -92,12 +95,12 @@ exports.testRouter = {
92
95
  setParams(params, path) {
93
96
  imperative_api_1.router.setParams(params);
94
97
  if (path) {
95
- expect(react_native_1.screen).toHavePathnameWithParams(path);
98
+ expect(exports.screen).toHavePathnameWithParams(path);
96
99
  }
97
100
  },
98
101
  /** If there's history that supports invoking the `back` function. */
99
102
  dismissAll() {
100
- (0, react_native_1.act)(() => imperative_api_1.router.dismissAll());
103
+ rnTestingLibrary.act(() => imperative_api_1.router.dismissAll());
101
104
  },
102
105
  };
103
106
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;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CAAC;IACH,CAAC;IACD,qEAAqE;IACrE,UAAU;QACR,IAAA,kBAAG,EAAC,GAAG,EAAE,CAAC,uBAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAC","sourcesContent":["import './expect';\nimport './mocks';\n\nimport { act, render, RenderResult, screen } from '@testing-library/react-native';\nimport React from 'react';\n\nimport { MockContextConfig, getMockConfig, getMockContext } from './mock-config';\nimport { ExpoRoot } from '../ExpoRoot';\nimport { ExpoLinkingOptions } from '../getLinkingConfig';\nimport { ReactNavigationState, store } from '../global-state/router-store';\nimport { router } from '../imperative-api';\n\n// re-export everything\nexport * from '@testing-library/react-native';\n\nexport type RenderRouterOptions = Parameters<typeof render>[1] & {\n initialUrl?: any;\n linking?: Partial<ExpoLinkingOptions>;\n};\n\ntype Result = ReturnType<typeof render> & {\n getPathname(): string;\n getPathnameWithParams(): string;\n getSegments(): string[];\n getSearchParams(): Record<string, string | string[]>;\n getRouterState(): ReactNavigationState | undefined;\n};\n\nexport { MockContextConfig, getMockConfig, getMockContext };\n\nexport function renderRouter(\n context: MockContextConfig = './app',\n { initialUrl = '/', linking, ...options }: RenderRouterOptions = {}\n): Result {\n jest.useFakeTimers();\n\n const mockContext = getMockContext(context);\n\n // Force the render to be synchronous\n process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';\n\n const result = render(\n <ExpoRoot context={mockContext} location={initialUrl} linking={linking} />,\n options\n );\n\n /**\n * This is a hack to ensure that React Navigation's state updates are processed before we run assertions.\n * Some updates are async and we need to wait for them to complete, otherwise will we get a false positive.\n * (that the app will briefly be in the right state, but then update to an invalid state)\n */\n return Object.assign(result, {\n getPathname(this: RenderResult): string {\n return store.getRouteInfo().pathname;\n },\n getSegments(this: RenderResult): string[] {\n return store.getRouteInfo().segments;\n },\n getSearchParams(this: RenderResult): Record<string, string | string[]> {\n return store.getRouteInfo().params;\n },\n getPathnameWithParams(this: RenderResult): string {\n return store.getRouteInfo().pathnameWithParams;\n },\n getRouterState(this: RenderResult) {\n return store.state;\n },\n });\n}\n\nexport const testRouter = {\n /** Navigate to the provided pathname and the pathname */\n navigate(path: string) {\n act(() => router.navigate(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Push the provided pathname and assert the pathname */\n push(path: string) {\n act(() => router.push(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Replace with provided pathname and assert the pathname */\n replace(path: string) {\n act(() => router.replace(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Go back in history and asset the new pathname */\n back(path?: string) {\n expect(router.canGoBack()).toBe(true);\n act(() => router.back());\n if (path) {\n expect(screen).toHavePathnameWithParams(path);\n }\n },\n /** If there's history that supports invoking the `back` function. */\n canGoBack() {\n return router.canGoBack();\n },\n /** Update the current route query params and assert the new pathname */\n setParams(params: Record<string, string>, path?: string) {\n router.setParams(params);\n if (path) {\n expect(screen).toHavePathnameWithParams(path);\n }\n },\n /** If there's history that supports invoking the `back` function. */\n dismissAll() {\n act(() => router.dismissAll());\n },\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":";;;;;;AAuEA,oCAsCC;AA7GD,oBAAkB;AAClB,mBAAiB;AAGjB,kDAA0B;AAE1B,+CAAiF;AA+DrD,8FA/DA,2BAAa,OA+DA;AAAE,+FA/DA,4BAAc,OA+DA;AA9DzD,0CAAuC;AAEvC,+DAA2E;AAC3E,sDAA2C;AAE3C,MAAM,gBAAgB,GAAG,CAAC,GAAmD,EAAE;IAC7E,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YACzD,MAAM,QAAQ,GAAG,IAAI,KAAK,CACxB,8IAA8I,CAC/I,CAAC;YACF,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC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AC;IACD,wEAAwE;IACxE,SAAS,CAAC,MAA8B,EAAE,IAAa;QACrD,uBAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,CAAC,cAAM,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IACD,qEAAqE;IACrE,UAAU;QACR,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,uBAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAClD,CAAC;CACF,CAAC","sourcesContent":["import './expect';\nimport './mocks';\n\nimport type { RenderResult } from '@testing-library/react-native';\nimport React from 'react';\n\nimport { MockContextConfig, getMockConfig, getMockContext } from './mock-config';\nimport { ExpoRoot } from '../ExpoRoot';\nimport { ExpoLinkingOptions } from '../getLinkingConfig';\nimport { ReactNavigationState, store } from '../global-state/router-store';\nimport { router } from '../imperative-api';\n\nconst rnTestingLibrary = ((): typeof import('@testing-library/react-native') => {\n try {\n return require('@testing-library/react-native');\n } catch (error: any) {\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n const newError = new Error(\n `[expo-router/testing-library] \"@testing-library/react-native\" failed to import. You need to install it to use expo-router's testing library.`\n );\n newError.stack = error.stack;\n newError.cause = error;\n throw newError;\n }\n throw error;\n }\n})();\n\nexport type * from '@testing-library/react-native';\n\n// TODO(@kitten): This is for backwards-compatibility. Consider removing this!\nexport declare const {\n act,\n cleanup,\n fireEvent,\n waitFor,\n waitForElementToBeRemoved,\n within,\n configure,\n resetToDefaults,\n isHiddenFromAccessibility,\n isInaccessible,\n getDefaultNormalizer,\n renderHook,\n userEvent,\n}: typeof rnTestingLibrary;\n\nexport declare let screen: typeof rnTestingLibrary.screen;\n\nObject.assign(exports, rnTestingLibrary);\nObject.defineProperty(exports, 'screen', {\n get() {\n return rnTestingLibrary.screen;\n },\n});\n\nexport type RenderRouterOptions = Parameters<typeof rnTestingLibrary.render>[1] & {\n initialUrl?: any;\n linking?: Partial<ExpoLinkingOptions>;\n};\n\ntype Result = ReturnType<typeof rnTestingLibrary.render> & {\n getPathname(): string;\n getPathnameWithParams(): string;\n getSegments(): string[];\n getSearchParams(): Record<string, string | string[]>;\n getRouterState(): ReactNavigationState | undefined;\n};\n\nexport { MockContextConfig, getMockConfig, getMockContext };\n\nexport function renderRouter(\n context: MockContextConfig = './app',\n { initialUrl = '/', linking, ...options }: RenderRouterOptions = {}\n): Result {\n jest.useFakeTimers();\n\n const mockContext = getMockContext(context);\n\n // Force the render to be synchronous\n process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';\n\n const result = rnTestingLibrary.render(\n <ExpoRoot context={mockContext} location={initialUrl} linking={linking} />,\n options\n );\n\n /**\n * This is a hack to ensure that React Navigation's state updates are processed before we run assertions.\n * Some updates are async and we need to wait for them to complete, otherwise will we get a false positive.\n * (that the app will briefly be in the right state, but then update to an invalid state)\n */\n return Object.assign(result, {\n getPathname(this: RenderResult): string {\n return store.getRouteInfo().pathname;\n },\n getSegments(this: RenderResult): string[] {\n return store.getRouteInfo().segments;\n },\n getSearchParams(this: RenderResult): Record<string, string | string[]> {\n return store.getRouteInfo().params;\n },\n getPathnameWithParams(this: RenderResult): string {\n return store.getRouteInfo().pathnameWithParams;\n },\n getRouterState(this: RenderResult) {\n return store.state;\n },\n });\n}\n\nexport const testRouter = {\n /** Navigate to the provided pathname and the pathname */\n navigate(path: string) {\n rnTestingLibrary.act(() => router.navigate(path));\n expect(rnTestingLibrary.screen).toHavePathnameWithParams(path);\n },\n /** Push the provided pathname and assert the pathname */\n push(path: string) {\n rnTestingLibrary.act(() => router.push(path));\n expect(rnTestingLibrary.screen).toHavePathnameWithParams(path);\n },\n /** Replace with provided pathname and assert the pathname */\n replace(path: string) {\n rnTestingLibrary.act(() => router.replace(path));\n expect(rnTestingLibrary.screen).toHavePathnameWithParams(path);\n },\n /** Go back in history and asset the new pathname */\n back(path?: string) {\n expect(router.canGoBack()).toBe(true);\n rnTestingLibrary.act(() => router.back());\n if (path) {\n expect(rnTestingLibrary.screen).toHavePathnameWithParams(path);\n }\n },\n /** If there's history that supports invoking the `back` function. */\n canGoBack() {\n return router.canGoBack();\n },\n /** Update the current route query params and assert the new pathname */\n setParams(params: Record<string, string>, path?: string) {\n router.setParams(params);\n if (path) {\n expect(screen).toHavePathnameWithParams(path);\n }\n },\n /** If there's history that supports invoking the `back` function. */\n dismissAll() {\n rnTestingLibrary.act(() => router.dismissAll());\n },\n};\n"]}
@@ -1,12 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /*
4
- * Optionally enable @testing-library/jest-native/extend-expect. We use this internally for the `toBeOnTheScreen` matcher()
5
- */
6
- try {
7
- require('@testing-library/jest-native/extend-expect');
8
- }
9
- catch { }
10
3
  try {
11
4
  require('react-native-gesture-handler/jestSetup');
12
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,IAAI,CAAC;IACH,OAAO,CAAC,4CAA4C,CAAC,CAAC;AACxD,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC;IACH,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACpD,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC;IACH,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACxC,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;YAC3D,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,yCAAyC;YAC7E,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAkC;QAC5C,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;QACrC,SAAS,CAAC,IAAY;YACpB,OAAO,eAAe,GAAG,IAAI,CAAC;QAChC,CAAC;QACD,aAAa;YACX,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,gBAAgB;YACd,OAAO,EAAE,MAAM,KAAI,CAAC,EAAS,CAAC;QAChC,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Optionally enable @testing-library/jest-native/extend-expect. We use this internally for the `toBeOnTheScreen` matcher()\n */\ntry {\n require('@testing-library/jest-native/extend-expect');\n} catch {}\n\ntry {\n require('react-native-gesture-handler/jestSetup');\n} catch {}\n\ntry {\n require('react-native-reanimated');\n jest.mock('react-native-reanimated', () => {\n try {\n const Reanimated = require('react-native-reanimated/mock');\n Reanimated.default.call = () => {}; // Override `call` with a no-op if needed\n return Reanimated;\n } catch {\n return {};\n }\n });\n} catch {}\n\njest.mock('expo-linking', () => {\n const module: typeof import('expo-linking') = {\n ...jest.requireActual('expo-linking'),\n createURL(path: string) {\n return 'yourscheme://' + path;\n },\n resolveScheme() {\n return 'yourscheme';\n },\n addEventListener() {\n return { remove() {} } as any;\n },\n };\n\n return module;\n});\n"]}
1
+ {"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":";;AAAA,IAAI,CAAC;IACH,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACpD,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC;IACH,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACxC,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;YAC3D,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,yCAAyC;YAC7E,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAEV,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAkC;QAC5C,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;QACrC,SAAS,CAAC,IAAY;YACpB,OAAO,eAAe,GAAG,IAAI,CAAC;QAChC,CAAC;QACD,aAAa;YACX,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,gBAAgB;YACd,OAAO,EAAE,MAAM,KAAI,CAAC,EAAS,CAAC;QAChC,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["try {\n require('react-native-gesture-handler/jestSetup');\n} catch {}\n\ntry {\n require('react-native-reanimated');\n jest.mock('react-native-reanimated', () => {\n try {\n const Reanimated = require('react-native-reanimated/mock');\n Reanimated.default.call = () => {}; // Override `call` with a no-op if needed\n return Reanimated;\n } catch {\n return {};\n }\n });\n} catch {}\n\njest.mock('expo-linking', () => {\n const module: typeof import('expo-linking') = {\n ...jest.requireActual('expo-linking'),\n createURL(path: string) {\n return 'yourscheme://' + path;\n },\n resolveScheme() {\n return 'yourscheme';\n },\n addEventListener() {\n return { remove() {} } as any;\n },\n };\n\n return module;\n});\n"]}