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

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 (44) hide show
  1. package/build/fork/getPathFromState.d.ts.map +1 -1
  2. package/build/fork/getPathFromState.js +2 -0
  3. package/build/fork/getPathFromState.js.map +1 -1
  4. package/build/global-state/routing.d.ts.map +1 -1
  5. package/build/global-state/routing.js +7 -3
  6. package/build/global-state/routing.js.map +1 -1
  7. package/build/layouts/StackClient.d.ts +7 -7
  8. package/build/layouts/StackClient.d.ts.map +1 -1
  9. package/build/layouts/StackClient.js +27 -25
  10. package/build/layouts/StackClient.js.map +1 -1
  11. package/build/link/ExpoLink.d.ts.map +1 -1
  12. package/build/link/ExpoLink.js +4 -1
  13. package/build/link/ExpoLink.js.map +1 -1
  14. package/build/link/LinkWithPreview.d.ts.map +1 -1
  15. package/build/link/LinkWithPreview.js +16 -19
  16. package/build/link/LinkWithPreview.js.map +1 -1
  17. package/build/link/elements.d.ts +1 -1
  18. package/build/link/elements.js +1 -1
  19. package/build/link/elements.js.map +1 -1
  20. package/build/link/preview/utils.d.ts.map +1 -1
  21. package/build/link/preview/utils.js +4 -2
  22. package/build/link/preview/utils.js.map +1 -1
  23. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.d.ts +1 -0
  24. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.d.ts.map +1 -1
  25. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.js +42 -6
  26. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.js.map +1 -1
  27. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.d.ts.map +1 -1
  28. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.js +6 -27
  29. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.js.map +1 -1
  30. package/build/navigationParams.d.ts +9 -0
  31. package/build/navigationParams.d.ts.map +1 -0
  32. package/build/navigationParams.js +67 -0
  33. package/build/navigationParams.js.map +1 -0
  34. package/build/ui/Slot.d.ts +5 -1
  35. package/build/ui/Slot.d.ts.map +1 -1
  36. package/build/ui/Slot.js.map +1 -1
  37. package/build/ui/Tabs.d.ts.map +1 -1
  38. package/build/ui/Tabs.js +1 -1
  39. package/build/ui/Tabs.js.map +1 -1
  40. package/build/ui/common.d.ts +2 -3
  41. package/build/ui/common.d.ts.map +1 -1
  42. package/build/ui/common.js +1 -3
  43. package/build/ui/common.js.map +1 -1
  44. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoLink.d.ts","sourceRoot":"","sources":["../../src/link/ExpoLink.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmC,MAAM,OAAO,CAAC;AAMxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,qBAmBxC"}
1
+ {"version":3,"file":"ExpoLink.d.ts","sourceRoot":"","sources":["../../src/link/ExpoLink.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmC,MAAM,OAAO,CAAC;AAMxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,qBAmBxC"}
@@ -44,6 +44,7 @@ const BaseExpoRouterLink_1 = require("./BaseExpoRouterLink");
44
44
  const LinkWithPreview_1 = require("./LinkWithPreview");
45
45
  const elements_1 = require("./elements");
46
46
  const PreviewRouteContext_1 = require("./preview/PreviewRouteContext");
47
+ const url_1 = require("../utils/url");
47
48
  function ExpoLink(props) {
48
49
  const isPreview = (0, PreviewRouteContext_1.useIsPreview)();
49
50
  if (process.env.EXPO_OS === 'ios' &&
@@ -60,6 +61,8 @@ function ExpoLink(props) {
60
61
  return <BaseExpoRouterLink_1.BaseExpoRouterLink {...props} children={children}/>;
61
62
  }
62
63
  function isLinkWithPreview(props) {
63
- return react_1.Children.toArray(props.children).some((child) => (0, react_1.isValidElement)(child) && (child.type === elements_1.LinkPreview || child.type === elements_1.LinkMenu));
64
+ const isExternal = (0, url_1.shouldLinkExternally)(String(props.href));
65
+ return react_1.Children.toArray(props.children).some((child) => (0, react_1.isValidElement)(child) &&
66
+ ((!isExternal && child.type === elements_1.LinkPreview) || child.type === elements_1.LinkMenu));
64
67
  }
65
68
  //# sourceMappingURL=ExpoLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoLink.js","sourceRoot":"","sources":["../../src/link/ExpoLink.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWb,4BAmBC;AA5BD,oEAAuC;AACvC,+CAAwD;AAExD,6DAA0D;AAC1D,uDAAoD;AACpD,yCAAmD;AACnD,uEAA6D;AAG7D,SAAgB,QAAQ,CAAC,KAAgB;IACvC,MAAM,SAAS,GAAG,IAAA,kCAAY,GAAE,CAAC;IACjC,IACE,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK;QAC7B,iBAAiB,CAAC,KAAK,CAAC;QACxB,CAAC,SAAS;QACV,wBAAS,EAAE,UAAU,EAAE,cAAc,KAAK,KAAK,EAC/C,CAAC;QACD,OAAO,CAAC,iCAAe,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;IACxC,CAAC;IACD,IAAI,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC9B,IAAI,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CACjE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAW,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAQ,CAAC,CAC7F,CAAC;QACF,QAAQ,GAAG,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC5E,CAAC;IAED,OAAO,CAAC,uCAAkB,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAG,CAAC;AAC/D,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAgB;IACzC,OAAO,gBAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC1C,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAW,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAQ,CAAC,CAC5F,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport Constants from 'expo-constants';\nimport React, { Children, isValidElement } from 'react';\n\nimport { BaseExpoRouterLink } from './BaseExpoRouterLink';\nimport { LinkWithPreview } from './LinkWithPreview';\nimport { LinkMenu, LinkPreview } from './elements';\nimport { useIsPreview } from './preview/PreviewRouteContext';\nimport { LinkProps } from './useLinkHooks';\n\nexport function ExpoLink(props: LinkProps) {\n const isPreview = useIsPreview();\n if (\n process.env.EXPO_OS === 'ios' &&\n isLinkWithPreview(props) &&\n !isPreview &&\n Constants?.expoConfig?.newArchEnabled !== false\n ) {\n return <LinkWithPreview {...props} />;\n }\n let children = props.children;\n if (React.Children.count(props.children) > 1) {\n const arrayChildren = React.Children.toArray(props.children).filter(\n (child) => !isValidElement(child) || (child.type !== LinkPreview && child.type !== LinkMenu)\n );\n children = arrayChildren.length === 1 ? arrayChildren[0] : props.children;\n }\n\n return <BaseExpoRouterLink {...props} children={children} />;\n}\n\nfunction isLinkWithPreview(props: LinkProps): boolean {\n return Children.toArray(props.children).some(\n (child) => isValidElement(child) && (child.type === LinkPreview || child.type === LinkMenu)\n );\n}\n"]}
1
+ {"version":3,"file":"ExpoLink.js","sourceRoot":"","sources":["../../src/link/ExpoLink.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYb,4BAmBC;AA7BD,oEAAuC;AACvC,+CAAwD;AAExD,6DAA0D;AAC1D,uDAAoD;AACpD,yCAAmD;AACnD,uEAA6D;AAE7D,sCAAoD;AAEpD,SAAgB,QAAQ,CAAC,KAAgB;IACvC,MAAM,SAAS,GAAG,IAAA,kCAAY,GAAE,CAAC;IACjC,IACE,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK;QAC7B,iBAAiB,CAAC,KAAK,CAAC;QACxB,CAAC,SAAS;QACV,wBAAS,EAAE,UAAU,EAAE,cAAc,KAAK,KAAK,EAC/C,CAAC;QACD,OAAO,CAAC,iCAAe,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;IACxC,CAAC;IACD,IAAI,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC9B,IAAI,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CACjE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAW,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAQ,CAAC,CAC7F,CAAC;QACF,QAAQ,GAAG,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC5E,CAAC;IAED,OAAO,CAAC,uCAAkB,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAG,CAAC;AAC/D,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAgB;IACzC,MAAM,UAAU,GAAG,IAAA,0BAAoB,EAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,OAAO,gBAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC1C,CAAC,KAAK,EAAE,EAAE,CACR,IAAA,sBAAc,EAAC,KAAK,CAAC;QACrB,CAAC,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAW,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAQ,CAAC,CAC3E,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport Constants from 'expo-constants';\nimport React, { Children, isValidElement } from 'react';\n\nimport { BaseExpoRouterLink } from './BaseExpoRouterLink';\nimport { LinkWithPreview } from './LinkWithPreview';\nimport { LinkMenu, LinkPreview } from './elements';\nimport { useIsPreview } from './preview/PreviewRouteContext';\nimport { LinkProps } from './useLinkHooks';\nimport { shouldLinkExternally } from '../utils/url';\n\nexport function ExpoLink(props: LinkProps) {\n const isPreview = useIsPreview();\n if (\n process.env.EXPO_OS === 'ios' &&\n isLinkWithPreview(props) &&\n !isPreview &&\n Constants?.expoConfig?.newArchEnabled !== false\n ) {\n return <LinkWithPreview {...props} />;\n }\n let children = props.children;\n if (React.Children.count(props.children) > 1) {\n const arrayChildren = React.Children.toArray(props.children).filter(\n (child) => !isValidElement(child) || (child.type !== LinkPreview && child.type !== LinkMenu)\n );\n children = arrayChildren.length === 1 ? arrayChildren[0] : props.children;\n }\n\n return <BaseExpoRouterLink {...props} children={children} />;\n}\n\nfunction isLinkWithPreview(props: LinkProps): boolean {\n const isExternal = shouldLinkExternally(String(props.href));\n return Children.toArray(props.children).some(\n (child) =>\n isValidElement(child) &&\n ((!isExternal && child.type === LinkPreview) || child.type === LinkMenu)\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"LinkWithPreview.d.ts","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,qBAwH/D"}
1
+ {"version":3,"file":"LinkWithPreview.d.ts","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,qBA0H/D"}
@@ -64,14 +64,6 @@ function LinkWithPreview({ children, ...rest }) {
64
64
  }, [hrefWithoutQuery]);
65
65
  const [{ nextScreenId, tabPath }, prefetch] = (0, useNextScreenId_1.useNextScreenId)();
66
66
  (0, react_1.useEffect)(() => {
67
- if ((0, url_1.shouldLinkExternally)(String(rest.href))) {
68
- if (process.env.NODE_ENV !== 'production') {
69
- throw new Error('External links previews are not supported');
70
- }
71
- else {
72
- console.warn('External links previews are not supported');
73
- }
74
- }
75
67
  if (rest.replace) {
76
68
  if (process.env.NODE_ENV !== 'production') {
77
69
  throw new Error('Using replace links with preview is not supported');
@@ -94,27 +86,32 @@ function LinkWithPreview({ children, ...rest }) {
94
86
  }
95
87
  const trigger = react_1.default.useMemo(() => triggerElement ?? <elements_1.LinkTrigger>{children}</elements_1.LinkTrigger>, [triggerElement, children]);
96
88
  const highlightBorderRadius = rest.style && 'borderRadius' in rest.style ? rest.style.borderRadius : undefined;
97
- const preview = react_1.default.useMemo(() => previewElement ?? null, [previewElement, rest.href]);
89
+ const preview = react_1.default.useMemo(() => ((0, url_1.shouldLinkExternally)(String(rest.href)) || !previewElement ? null : previewElement), [previewElement, rest.href]);
98
90
  const isPreviewTapped = (0, react_1.useRef)(false);
99
91
  const tabPathValue = (0, react_1.useMemo)(() => ({
100
92
  path: tabPath,
101
93
  }), [tabPath]);
102
- if ((0, url_1.shouldLinkExternally)(String(rest.href)) || rest.replace) {
94
+ const hasPreview = !!previewElement;
95
+ if (rest.replace) {
103
96
  return <BaseExpoRouterLink_1.BaseExpoRouterLink children={children} {...rest}/>;
104
97
  }
105
98
  return (<native_1.NativeLinkPreview nextScreenId={isPad ? undefined : nextScreenId} tabPath={isPad ? undefined : tabPathValue} onWillPreviewOpen={() => {
106
- isPreviewTapped.current = false;
107
- prefetch(rest.href);
108
- setIsCurrenPreviewOpen(true);
99
+ if (hasPreview) {
100
+ isPreviewTapped.current = false;
101
+ prefetch(rest.href);
102
+ setIsCurrenPreviewOpen(true);
103
+ }
109
104
  }} onPreviewWillClose={() => {
110
- setIsCurrenPreviewOpen(false);
111
- // When preview was not tapped, then we need to enable the screen stack animation
112
- // Otherwise this will happen in StackNavigator, when new screen is opened
113
- if (!isPreviewTapped.current || isPad) {
114
- setOpenPreviewKey(undefined);
105
+ if (hasPreview) {
106
+ setIsCurrenPreviewOpen(false);
107
+ // When preview was not tapped, then we need to enable the screen stack animation
108
+ // Otherwise this will happen in StackNavigator, when new screen is opened
109
+ if (!isPreviewTapped.current || isPad) {
110
+ setOpenPreviewKey(undefined);
111
+ }
115
112
  }
116
113
  }} onPreviewDidClose={() => {
117
- if (isPreviewTapped.current && isPad) {
114
+ if (hasPreview && isPreviewTapped.current && isPad) {
118
115
  router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });
119
116
  }
120
117
  }} onPreviewTapped={() => {
@@ -1 +1 @@
1
- {"version":3,"file":"LinkWithPreview.js","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,CAAC,OAAO,CACR;QAAA,CAAC,WAAW,CACd;MAAA,EAAE,uDAA0B,CAC9B;IAAA,EAAE,0BAAiB,CAAC,CACrB,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,QAA6C,EAC7C,IAAgC;IAEhC,OAAO,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC1C,CAAC,KAAK,EAAiC,EAAE,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CACvF,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport React, {\n isValidElement,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport { Platform } from 'react-native';\n\nimport { useRouter } from '../hooks';\nimport { BaseExpoRouterLink } from './BaseExpoRouterLink';\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { LinkMenu, LinkPreview, LinkTrigger } from './elements';\nimport { useLinkPreviewContext } from './preview/LinkPreviewContext';\nimport { NativeLinkPreview, NativeLinkPreviewTrigger } from './preview/native';\nimport { useNextScreenId } from './preview/useNextScreenId';\nimport { LinkProps } from './useLinkHooks';\nimport { shouldLinkExternally } from '../utils/url';\n\nconst isPad = Platform.OS === 'ios' && Platform.isPad;\n\nexport function LinkWithPreview({ children, ...rest }: LinkProps) {\n const router = useRouter();\n const { setOpenPreviewKey } = useLinkPreviewContext();\n const [isCurrentPreviewOpen, setIsCurrenPreviewOpen] = useState(false);\n\n const hrefWithoutQuery = String(rest.href).split('?')[0];\n const prevHrefWithoutQuery = useRef(hrefWithoutQuery);\n\n useEffect(() => {\n if (isCurrentPreviewOpen) {\n if (prevHrefWithoutQuery.current !== hrefWithoutQuery) {\n throw new Error(\n 'Link does not support changing the href prop after the preview has been opened. Please ensure that the href prop is stable and does not change between renders.'\n );\n }\n } else {\n prevHrefWithoutQuery.current = hrefWithoutQuery;\n }\n }, [hrefWithoutQuery]);\n\n const [{ nextScreenId, tabPath }, prefetch] = useNextScreenId();\n\n useEffect(() => {\n if (shouldLinkExternally(String(rest.href))) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('External links previews are not supported');\n } else {\n console.warn('External links previews are not supported');\n }\n }\n if (rest.replace) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('Using replace links with preview is not supported');\n } else {\n console.warn('Using replace links with preview is not supported');\n }\n }\n }, [rest.href, rest.replace]);\n\n const triggerElement = React.useMemo(\n () => getFirstChildOfType(children, LinkTrigger),\n [children]\n );\n const menuElement = React.useMemo(() => getFirstChildOfType(children, LinkMenu), [children]);\n const previewElement = React.useMemo(\n () => getFirstChildOfType(children, LinkPreview),\n [children]\n );\n\n if ((previewElement || menuElement) && !triggerElement) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'When you use Link.Preview, you must use Link.Trigger to specify the trigger element.'\n );\n } else {\n console.warn(\n 'When you use Link.Preview, you must use Link.Trigger to specify the trigger element.'\n );\n }\n }\n\n const trigger = React.useMemo(\n () => triggerElement ?? <LinkTrigger>{children}</LinkTrigger>,\n [triggerElement, children]\n );\n const highlightBorderRadius =\n rest.style && 'borderRadius' in rest.style ? rest.style.borderRadius : undefined;\n\n const preview = React.useMemo(() => previewElement ?? null, [previewElement, rest.href]);\n\n const isPreviewTapped = useRef(false);\n\n const tabPathValue = useMemo(\n () => ({\n path: tabPath,\n }),\n [tabPath]\n );\n\n if (shouldLinkExternally(String(rest.href)) || rest.replace) {\n return <BaseExpoRouterLink children={children} {...rest} />;\n }\n\n return (\n <NativeLinkPreview\n nextScreenId={isPad ? undefined : nextScreenId}\n tabPath={isPad ? undefined : tabPathValue}\n onWillPreviewOpen={() => {\n isPreviewTapped.current = false;\n prefetch(rest.href);\n setIsCurrenPreviewOpen(true);\n }}\n onPreviewWillClose={() => {\n setIsCurrenPreviewOpen(false);\n // When preview was not tapped, then we need to enable the screen stack animation\n // Otherwise this will happen in StackNavigator, when new screen is opened\n if (!isPreviewTapped.current || isPad) {\n setOpenPreviewKey(undefined);\n }\n }}\n onPreviewDidClose={() => {\n if (isPreviewTapped.current && isPad) {\n router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });\n }\n }}\n onPreviewTapped={() => {\n isPreviewTapped.current = true;\n if (!isPad) {\n router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });\n }\n }}>\n <InternalLinkPreviewContext value={{ isVisible: isCurrentPreviewOpen, href: rest.href }}>\n <NativeLinkPreviewTrigger style={{ borderRadius: highlightBorderRadius }}>\n <BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref} />\n </NativeLinkPreviewTrigger>\n {preview}\n {menuElement}\n </InternalLinkPreviewContext>\n </NativeLinkPreview>\n );\n}\n\nfunction getFirstChildOfType<PropsT>(\n children: React.ReactNode | React.ReactNode[],\n type: (props: PropsT) => unknown\n) {\n return React.Children.toArray(children).find(\n (child): child is ReactElement<PropsT> => isValidElement(child) && child.type === type\n );\n}\n"]}
1
+ {"version":3,"file":"LinkWithPreview.js","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBb,0CA0HC;AAhJD,+CAOe;AACf,+CAAwC;AAExC,oCAAqC;AACrC,6DAA0D;AAC1D,6EAA0E;AAC1E,yCAAgE;AAChE,qEAAqE;AACrE,6CAA+E;AAC/E,+DAA4D;AAE5D,sCAAoD;AAEpD,MAAM,KAAK,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,uBAAQ,CAAC,KAAK,CAAC;AAEtD,SAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAa;IAC9D,MAAM,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC3B,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAA,0CAAqB,GAAE,CAAC;IACtD,MAAM,CAAC,oBAAoB,EAAE,sBAAsB,CAA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AAC;QACH,CAAC,CAAC,CACF,eAAe,CAAC,CAAC,GAAG,EAAE;YACpB,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;YAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,sBAAsB,EAAE,YAAY,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC,CAAC,CACF;MAAA,CAAC,uDAA0B,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CACtF;QAAA,CAAC,iCAAwB,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,qBAAqB,EAAE,CAAC,CACvE;UAAA,CAAC,uCAAkB,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACjE;QAAA,EAAE,iCAAwB,CAC1B;QAAA,CAAC,OAAO,CACR;QAAA,CAAC,WAAW,CACd;MAAA,EAAE,uDAA0B,CAC9B;IAAA,EAAE,0BAAiB,CAAC,CACrB,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,QAA6C,EAC7C,IAAgC;IAEhC,OAAO,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC1C,CAAC,KAAK,EAAiC,EAAE,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CACvF,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport React, {\n isValidElement,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport { Platform } from 'react-native';\n\nimport { useRouter } from '../hooks';\nimport { BaseExpoRouterLink } from './BaseExpoRouterLink';\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { LinkMenu, LinkPreview, LinkTrigger } from './elements';\nimport { useLinkPreviewContext } from './preview/LinkPreviewContext';\nimport { NativeLinkPreview, NativeLinkPreviewTrigger } from './preview/native';\nimport { useNextScreenId } from './preview/useNextScreenId';\nimport { LinkProps } from './useLinkHooks';\nimport { shouldLinkExternally } from '../utils/url';\n\nconst isPad = Platform.OS === 'ios' && Platform.isPad;\n\nexport function LinkWithPreview({ children, ...rest }: LinkProps) {\n const router = useRouter();\n const { setOpenPreviewKey } = useLinkPreviewContext();\n const [isCurrentPreviewOpen, setIsCurrenPreviewOpen] = useState(false);\n\n const hrefWithoutQuery = String(rest.href).split('?')[0];\n const prevHrefWithoutQuery = useRef(hrefWithoutQuery);\n\n useEffect(() => {\n if (isCurrentPreviewOpen) {\n if (prevHrefWithoutQuery.current !== hrefWithoutQuery) {\n throw new Error(\n 'Link does not support changing the href prop after the preview has been opened. Please ensure that the href prop is stable and does not change between renders.'\n );\n }\n } else {\n prevHrefWithoutQuery.current = hrefWithoutQuery;\n }\n }, [hrefWithoutQuery]);\n\n const [{ nextScreenId, tabPath }, prefetch] = useNextScreenId();\n\n useEffect(() => {\n if (rest.replace) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('Using replace links with preview is not supported');\n } else {\n console.warn('Using replace links with preview is not supported');\n }\n }\n }, [rest.href, rest.replace]);\n\n const triggerElement = React.useMemo(\n () => getFirstChildOfType(children, LinkTrigger),\n [children]\n );\n const menuElement = React.useMemo(() => getFirstChildOfType(children, LinkMenu), [children]);\n const previewElement = React.useMemo(\n () => getFirstChildOfType(children, LinkPreview),\n [children]\n );\n\n if ((previewElement || menuElement) && !triggerElement) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'When you use Link.Preview, you must use Link.Trigger to specify the trigger element.'\n );\n } else {\n console.warn(\n 'When you use Link.Preview, you must use Link.Trigger to specify the trigger element.'\n );\n }\n }\n\n const trigger = React.useMemo(\n () => triggerElement ?? <LinkTrigger>{children}</LinkTrigger>,\n [triggerElement, children]\n );\n const highlightBorderRadius =\n rest.style && 'borderRadius' in rest.style ? rest.style.borderRadius : undefined;\n\n const preview = React.useMemo(\n () => (shouldLinkExternally(String(rest.href)) || !previewElement ? null : previewElement),\n [previewElement, rest.href]\n );\n\n const isPreviewTapped = useRef(false);\n\n const tabPathValue = useMemo(\n () => ({\n path: tabPath,\n }),\n [tabPath]\n );\n\n const hasPreview = !!previewElement;\n\n if (rest.replace) {\n return <BaseExpoRouterLink children={children} {...rest} />;\n }\n\n return (\n <NativeLinkPreview\n nextScreenId={isPad ? undefined : nextScreenId}\n tabPath={isPad ? undefined : tabPathValue}\n onWillPreviewOpen={() => {\n if (hasPreview) {\n isPreviewTapped.current = false;\n prefetch(rest.href);\n setIsCurrenPreviewOpen(true);\n }\n }}\n onPreviewWillClose={() => {\n if (hasPreview) {\n setIsCurrenPreviewOpen(false);\n // When preview was not tapped, then we need to enable the screen stack animation\n // Otherwise this will happen in StackNavigator, when new screen is opened\n if (!isPreviewTapped.current || isPad) {\n setOpenPreviewKey(undefined);\n }\n }\n }}\n onPreviewDidClose={() => {\n if (hasPreview && isPreviewTapped.current && isPad) {\n router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });\n }\n }}\n onPreviewTapped={() => {\n isPreviewTapped.current = true;\n if (!isPad) {\n router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });\n }\n }}>\n <InternalLinkPreviewContext value={{ isVisible: isCurrentPreviewOpen, href: rest.href }}>\n <NativeLinkPreviewTrigger style={{ borderRadius: highlightBorderRadius }}>\n <BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref} />\n </NativeLinkPreviewTrigger>\n {preview}\n {menuElement}\n </InternalLinkPreviewContext>\n </NativeLinkPreview>\n );\n}\n\nfunction getFirstChildOfType<PropsT>(\n children: React.ReactNode | React.ReactNode[],\n type: (props: PropsT) => unknown\n) {\n return React.Children.toArray(children).find(\n (child): child is ReactElement<PropsT> => isValidElement(child) && child.type === type\n );\n}\n"]}
@@ -126,7 +126,7 @@ export interface LinkPreviewProps {
126
126
  * <Link href="/about">
127
127
  * <Link.Preview>
128
128
  * <Text>Custom Preview Content</Text>
129
- * </Link.Trigger>
129
+ * </Link.Preview>
130
130
  * </Link>
131
131
  * ```
132
132
  *
@@ -99,7 +99,7 @@ exports.LinkMenu = LinkMenu;
99
99
  * <Link href="/about">
100
100
  * <Link.Preview>
101
101
  * <Text>Custom Preview Content</Text>
102
- * </Link.Trigger>
102
+ * </Link.Preview>
103
103
  * </Link>
104
104
  * ```
105
105
  *
@@ -1 +1 @@
1
- {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDb,wCAYC;AAqHD,kCA4BC;AAuBD,kCAYC;AAtPD,+CAA8F;AAG9F,6EAA0E;AAC1E,uDAAoD;AACpD,uEAA6D;AAC7D,6CAAqF;AACrF,qCAAkC;AAuClC;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,KAA0B;IACvD,IAAI,IAAA,kCAAY,GAAE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK,IAAI,CAAC,IAAA,WAAG,EAAC,uDAA0B,CAAC,EAAE,CAAC;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC3D,OAAO,CACL,CAAC,gCAAuB,CACtB,IAAI,IAAI,CAAC,CACT,UAAU,CAAC,CAAC,OAAO,CAAC,CACpB,aAAa,CAAC,CAAC,sBAAsB,CAAC,EACtC,CACH,CAAC;AACJ,CAAC;AAkCD;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,QAAQ,GAA4B,CAAC,KAAK,EAAE,EAAE;IACzD,IAAI,IAAA,kCAAY,GAAE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,K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,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,CAAC;IAED,OAAO,CACL,CAAC,iCAAwB,CACvB,KAAK,CAAC,CAAC;YACL,6EAA6E;YAC7E,eAAe,EAAE,MAAM;SACxB,CAAC,CACF,oBAAoB,CAAC,CAAC,WAAW,CAAC,CAClC;MAAA,CAAC,OAAO,CACV;IAAA,EAAE,iCAAwB,CAAC,CAC5B,CAAC;AACJ,CAAC;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,IAAI,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChF,6EAA6E;QAC7E,qGAAqG;QACrG,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IACD,OAAO,CAAC,WAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7B,CAAC","sourcesContent":["'use client';\n\nimport React, { isValidElement, use, type PropsWithChildren, type ReactElement } from 'react';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { HrefPreview } from './preview/HrefPreview';\nimport { useIsPreview } from './preview/PreviewRouteContext';\nimport { NativeLinkPreviewAction, NativeLinkPreviewContent } from './preview/native';\nimport { Slot } from '../ui/Slot';\n\nexport interface LinkMenuActionProps {\n /**\n * The title of the menu item.\n */\n title: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: SFSymbol;\n /**\n * If `true`, the menu item will be disabled and not selectable.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/disabled) for more information.\n */\n disabled?: boolean;\n /**\n * If `true`, the menu item will be displayed as destructive.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/destructive) for more information.\n */\n destructive?: boolean;\n /**\n * If `true`, the menu will be kept presented after the action is selected.\n *\n * This is marked as unstable, because when action is selected it will recreate the menu,\n * which will close all opened submenus and reset the scroll position.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/keepsmenupresented) for more information.\n */\n unstable_keepPresented?: boolean;\n /**\n * If `true`, the menu item will be displayed as selected.\n */\n isOn?: boolean;\n onPress: () => void;\n}\n\n/**\n * This component renders a context menu action for a link.\n * It should only be used as a child of `Link.Menu` or `LinkMenu`.\n *\n * > **Note**: You can use the alias `Link.MenuAction` for this component.\n *\n * @platform ios\n */\nexport function LinkMenuAction(props: LinkMenuActionProps) {\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(InternalLinkPreviewContext)) {\n return null;\n }\n const { unstable_keepPresented, onPress, ...rest } = props;\n return (\n <NativeLinkPreviewAction\n {...rest}\n onSelected={onPress}\n keepPresented={unstable_keepPresented}\n />\n );\n}\n\nexport interface LinkMenuProps {\n /**\n * The title of the menu item\n */\n title?: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: string;\n /**\n * If `true`, the menu will be displayed as a palette.\n * This means that the menu will be displayed as one row\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette) for more information.\n */\n displayAsPalette?: boolean;\n /**\n * If `true`, the menu will be displayed inline.\n * This means that the menu will not be collapsed\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayinline) for more information.\n */\n displayInline?: boolean;\n /**\n * If `true`, the menu item will be displayed as destructive.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/destructive) for more information.\n */\n destructive?: boolean;\n children: ReactElement<LinkMenuActionProps> | ReactElement<LinkMenuActionProps>[];\n}\n\n/**\n * Groups context menu actions for a link.\n *\n * If multiple `Link.Menu` components are used within a single `Link`, only the first will be rendered.\n * Only `Link.MenuAction` and `LinkMenuAction` components are allowed as children.\n *\n * @example\n * ```tsx\n * <Link.Menu>\n * <Link.MenuAction title=\"Action 1\" onPress={() => {}} />\n * <Link.MenuAction title=\"Action 2\" onPress={() => {}} />\n * </Link.Menu>\n * ```\n *\n * > **Note**: You can use the alias `Link.Menu` for this component.\n *\n * @platform ios\n */\nexport const LinkMenu: React.FC<LinkMenuProps> = (props) => {\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(InternalLinkPreviewContext)) {\n return null;\n }\n const children = React.Children.toArray(props.children).filter(\n (child) => isValidElement(child) && (child.type === LinkMenuAction || child.type === LinkMenu)\n );\n return (\n <NativeLinkPreviewAction\n {...props}\n title={props.title ?? ''}\n onSelected={() => {}}\n children={children}\n />\n );\n};\n\nexport interface LinkPreviewProps {\n /**\n * Sets the preferred width of the preview.\n * If not set, full width of the screen will be used.\n *\n * This is only **preferred** width, the actual width may be different\n */\n width?: number;\n\n /**\n * Sets the preferred height of the preview.\n * If not set, full height of the screen will be used.\n *\n * This is only **preferred** height, the actual height may be different\n */\n height?: number;\n children?: React.ReactNode;\n}\n\n/**\n * A component used to render and customize the link preview.\n *\n * If `Link.Preview` is used without any props, it will render a preview of the `href` passed to the `Link`.\n *\n * If multiple `Link.Preview` components are used within a single `Link`, only the first one will be rendered.\n *\n * To customize the preview, you can pass custom content as children.\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Preview>\n * <Text>Custom Preview Content</Text>\n * </Link.Trigger>\n * </Link>\n * ```\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Preview />\n * </Link>\n * ```\n *\n * > **Note**: You can use the alias `Link.Preview` for this component.\n *\n * @platform ios\n */\nexport function LinkPreview(props: LinkPreviewProps) {\n const { width, height, children } = props;\n const internalPreviewContext = use(InternalLinkPreviewContext);\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !internalPreviewContext) {\n return null;\n }\n const { isVisible, href } = internalPreviewContext;\n const contentSize = {\n width: width ?? 0,\n height: height ?? 0,\n };\n let content: React.ReactNode;\n if (children) {\n content = isVisible ? children : null;\n } else {\n content = isVisible ? <HrefPreview href={href} /> : null;\n }\n\n return (\n <NativeLinkPreviewContent\n style={{\n /* Setting default background here, so that the preview is not transparent */\n backgroundColor: '#fff',\n }}\n preferredContentSize={contentSize}>\n {content}\n </NativeLinkPreviewContent>\n );\n}\n\nexport type LinkTriggerProps = PropsWithChildren;\n\n/**\n * Serves as the trigger for a link.\n * The content inside this component will be rendered as part of the base link.\n *\n * If multiple `Link.Trigger` components are used within a single `Link`, only the first will be rendered.\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Trigger>\n * Trigger\n * </Link.Trigger>\n * </Link>\n * ```\n *\n * > **Note**: You can use the alias `Link.Trigger` for this component.\n *\n * @platform ios\n */\nexport function LinkTrigger(props: LinkTriggerProps) {\n if (React.Children.count(props.children) > 1 || !isValidElement(props.children)) {\n // If onPress is passed, this means that Link passed props to this component.\n // We can assume that asChild is used, so we throw an error, because link will not work in this case.\n if (props && typeof props === 'object' && 'onPress' in props) {\n throw new Error(\n 'When using Link.Trigger in an asChild Link, you must pass a single child element that will emit onPress event.'\n );\n }\n return props.children;\n }\n return <Slot {...props} />;\n}\n"]}
1
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDb,wCAYC;AAqHD,kC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AW,CAAC,KAAuB;IACjD,IAAI,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChF,6EAA6E;QAC7E,qGAAqG;QACrG,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IACD,OAAO,CAAC,WAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7B,CAAC","sourcesContent":["'use client';\n\nimport React, { isValidElement, use, type PropsWithChildren, type ReactElement } from 'react';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { HrefPreview } from './preview/HrefPreview';\nimport { useIsPreview } from './preview/PreviewRouteContext';\nimport { NativeLinkPreviewAction, NativeLinkPreviewContent } from './preview/native';\nimport { Slot } from '../ui/Slot';\n\nexport interface LinkMenuActionProps {\n /**\n * The title of the menu item.\n */\n title: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: SFSymbol;\n /**\n * If `true`, the menu item will be disabled and not selectable.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/disabled) for more information.\n */\n disabled?: boolean;\n /**\n * If `true`, the menu item will be displayed as destructive.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/destructive) for more information.\n */\n destructive?: boolean;\n /**\n * If `true`, the menu will be kept presented after the action is selected.\n *\n * This is marked as unstable, because when action is selected it will recreate the menu,\n * which will close all opened submenus and reset the scroll position.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/keepsmenupresented) for more information.\n */\n unstable_keepPresented?: boolean;\n /**\n * If `true`, the menu item will be displayed as selected.\n */\n isOn?: boolean;\n onPress: () => void;\n}\n\n/**\n * This component renders a context menu action for a link.\n * It should only be used as a child of `Link.Menu` or `LinkMenu`.\n *\n * > **Note**: You can use the alias `Link.MenuAction` for this component.\n *\n * @platform ios\n */\nexport function LinkMenuAction(props: LinkMenuActionProps) {\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(InternalLinkPreviewContext)) {\n return null;\n }\n const { unstable_keepPresented, onPress, ...rest } = props;\n return (\n <NativeLinkPreviewAction\n {...rest}\n onSelected={onPress}\n keepPresented={unstable_keepPresented}\n />\n );\n}\n\nexport interface LinkMenuProps {\n /**\n * The title of the menu item\n */\n title?: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: string;\n /**\n * If `true`, the menu will be displayed as a palette.\n * This means that the menu will be displayed as one row\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette) for more information.\n */\n displayAsPalette?: boolean;\n /**\n * If `true`, the menu will be displayed inline.\n * This means that the menu will not be collapsed\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayinline) for more information.\n */\n displayInline?: boolean;\n /**\n * If `true`, the menu item will be displayed as destructive.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/destructive) for more information.\n */\n destructive?: boolean;\n children: ReactElement<LinkMenuActionProps> | ReactElement<LinkMenuActionProps>[];\n}\n\n/**\n * Groups context menu actions for a link.\n *\n * If multiple `Link.Menu` components are used within a single `Link`, only the first will be rendered.\n * Only `Link.MenuAction` and `LinkMenuAction` components are allowed as children.\n *\n * @example\n * ```tsx\n * <Link.Menu>\n * <Link.MenuAction title=\"Action 1\" onPress={() => {}} />\n * <Link.MenuAction title=\"Action 2\" onPress={() => {}} />\n * </Link.Menu>\n * ```\n *\n * > **Note**: You can use the alias `Link.Menu` for this component.\n *\n * @platform ios\n */\nexport const LinkMenu: React.FC<LinkMenuProps> = (props) => {\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(InternalLinkPreviewContext)) {\n return null;\n }\n const children = React.Children.toArray(props.children).filter(\n (child) => isValidElement(child) && (child.type === LinkMenuAction || child.type === LinkMenu)\n );\n return (\n <NativeLinkPreviewAction\n {...props}\n title={props.title ?? ''}\n onSelected={() => {}}\n children={children}\n />\n );\n};\n\nexport interface LinkPreviewProps {\n /**\n * Sets the preferred width of the preview.\n * If not set, full width of the screen will be used.\n *\n * This is only **preferred** width, the actual width may be different\n */\n width?: number;\n\n /**\n * Sets the preferred height of the preview.\n * If not set, full height of the screen will be used.\n *\n * This is only **preferred** height, the actual height may be different\n */\n height?: number;\n children?: React.ReactNode;\n}\n\n/**\n * A component used to render and customize the link preview.\n *\n * If `Link.Preview` is used without any props, it will render a preview of the `href` passed to the `Link`.\n *\n * If multiple `Link.Preview` components are used within a single `Link`, only the first one will be rendered.\n *\n * To customize the preview, you can pass custom content as children.\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Preview>\n * <Text>Custom Preview Content</Text>\n * </Link.Preview>\n * </Link>\n * ```\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Preview />\n * </Link>\n * ```\n *\n * > **Note**: You can use the alias `Link.Preview` for this component.\n *\n * @platform ios\n */\nexport function LinkPreview(props: LinkPreviewProps) {\n const { width, height, children } = props;\n const internalPreviewContext = use(InternalLinkPreviewContext);\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !internalPreviewContext) {\n return null;\n }\n const { isVisible, href } = internalPreviewContext;\n const contentSize = {\n width: width ?? 0,\n height: height ?? 0,\n };\n let content: React.ReactNode;\n if (children) {\n content = isVisible ? children : null;\n } else {\n content = isVisible ? <HrefPreview href={href} /> : null;\n }\n\n return (\n <NativeLinkPreviewContent\n style={{\n /* Setting default background here, so that the preview is not transparent */\n backgroundColor: '#fff',\n }}\n preferredContentSize={contentSize}>\n {content}\n </NativeLinkPreviewContent>\n );\n}\n\nexport type LinkTriggerProps = PropsWithChildren;\n\n/**\n * Serves as the trigger for a link.\n * The content inside this component will be rendered as part of the base link.\n *\n * If multiple `Link.Trigger` components are used within a single `Link`, only the first will be rendered.\n *\n * @example\n * ```tsx\n * <Link href=\"/about\">\n * <Link.Trigger>\n * Trigger\n * </Link.Trigger>\n * </Link>\n * ```\n *\n * > **Note**: You can use the alias `Link.Trigger` for this component.\n *\n * @platform ios\n */\nexport function LinkTrigger(props: LinkTriggerProps) {\n if (React.Children.count(props.children) > 1 || !isValidElement(props.children)) {\n // If onPress is passed, this means that Link passed props to this component.\n // We can assume that asChild is used, so we throw an error, because link will not work in this case.\n if (props && typeof props === 'object' && 'onPress' in props) {\n throw new Error(\n 'When using Link.Trigger in an asChild Link, you must pass a single child element that will emit onPress event.'\n );\n }\n return props.children;\n }\n return <Slot {...props} />;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/link/preview/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,KAAK,eAAe,EAGrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAS,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEnF,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,oBAAoB,GAC9B,OAAO,EAAE,CA4BX;AAED,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,oBAAoB,GAC9B,eAAe,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,SAAS,CA4BpD;AAED,wBAAgB,SAAS,CACvB,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,EACrC,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,GACpC,OAAO,CAYT"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/link/preview/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,KAAK,eAAe,EAGrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAS,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEnF,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,oBAAoB,GAC9B,OAAO,EAAE,CA4BX;AAED,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,oBAAoB,GAC9B,eAAe,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,SAAS,CAiCpD;AAED,wBAAgB,SAAS,CACvB,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,EACrC,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,GACpC,OAAO,CAYT"}
@@ -6,6 +6,7 @@ exports.deepEqual = deepEqual;
6
6
  const router_store_1 = require("../../global-state/router-store");
7
7
  const routing_1 = require("../../global-state/routing");
8
8
  const href_1 = require("../href");
9
+ const navigationParams_1 = require("../../navigationParams");
9
10
  function getTabPathFromRootStateByHref(href, rootState) {
10
11
  const hrefState = router_store_1.store.getStateForHref((0, href_1.resolveHref)(href));
11
12
  const state = rootState;
@@ -45,7 +46,8 @@ function getPreloadedRouteFromRootStateByHref(href, rootState) {
45
46
  if (navigationState.type === 'stack') {
46
47
  const stackState = navigationState;
47
48
  const payload = (0, routing_1.getPayloadFromStateRoute)(actionStateRoute);
48
- const preloadedRoute = stackState.preloadedRoutes.find((route) => route.name === actionStateRoute.name && deepEqual(route.params, payload.params));
49
+ const preloadedRoute = stackState.preloadedRoutes.find((route) => route.name === actionStateRoute.name &&
50
+ deepEqual((0, navigationParams_1.removeInternalExpoRouterParams)(route.params), (0, navigationParams_1.removeInternalExpoRouterParams)(payload.params)));
49
51
  return preloadedRoute;
50
52
  }
51
53
  return undefined;
@@ -60,7 +62,7 @@ function deepEqual(a, b) {
60
62
  if (typeof a !== 'object' || typeof b !== 'object') {
61
63
  return false;
62
64
  }
63
- const keys = Object.keys(a).filter((key) => key !== '__internal__expoRouterIsPreviewNavigation');
65
+ const keys = Object.keys(a);
64
66
  return keys.length === Object.keys(b).length && keys.every((key) => deepEqual(a[key], b[key]));
65
67
  }
66
68
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/link/preview/utils.ts"],"names":[],"mappings":";;AAcA,sEA+BC;AAED,oFA+BC;AAED,8BAeC;AAvFD,kEAAmF;AACnF,wDAA0F;AAE1F,kCAAsC;AAGtC,SAAgB,6BAA6B,CAC3C,IAAU,EACV,SAA+B;IAE/B,MAAM,SAAS,GAAG,oBAAK,CAAC,eAAe,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAqC,SAAS,CAAC;IAC1D,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,sCAAsC;IACtC,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,4BAAkB,EAAC,SAAS,EAAE,KAAwB,EAAE,IAAI,CAAC,CAAC;IAE3F,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,gBAAgB,CAAC,OA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,OAAO,GAAG,IAAA,kCAAwB,EAAC,gBAAgB,CAAC,CAAC;QAE3D,MAAM,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,CACpD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC,IAAI,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAC3F,CAAC;QACF,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,SAAS,CACvB,CAAqC,EACrC,CAAqC;IAErC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,2CAA2C,CAAC,CAAC;IACjG,OAAO,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjG,CAAC","sourcesContent":["import {\n ParamListBase,\n StackNavigationState,\n type NavigationRoute,\n type NavigationState,\n type TabNavigationState,\n} from '@react-navigation/native';\n\nimport { store, type ReactNavigationState } from '../../global-state/router-store';\nimport { findDivergentState, getPayloadFromStateRoute } from '../../global-state/routing';\nimport { Href } from '../../types';\nimport { resolveHref } from '../href';\nimport { TabPath } from './native';\n\nexport function getTabPathFromRootStateByHref(\n href: Href,\n rootState: ReactNavigationState\n): TabPath[] {\n const hrefState = store.getStateForHref(resolveHref(href));\n const state: ReactNavigationState | undefined = rootState;\n if (!hrefState || !state) {\n return [];\n }\n // Replicating the logic from `linkTo`\n const { navigationRoutes } = findDivergentState(hrefState, state as NavigationState, true);\n\n if (!navigationRoutes.length) {\n return [];\n }\n\n const tabPath: TabPath[] = [];\n navigationRoutes.forEach((route, i, arr) => {\n if (route.state?.type === 'tab') {\n const tabState = route.state as TabNavigationState<ParamListBase>;\n const oldTabKey = tabState.routes[tabState.index].key;\n if (!arr[i + 1]) {\n throw new Error(\n `New tab route is missing for ${route.key}. This is likely an internal Expo Router bug.`\n );\n }\n const newTabKey = arr[i + 1].key;\n tabPath.push({ oldTabKey, newTabKey });\n }\n });\n return tabPath;\n}\n\nexport function getPreloadedRouteFromRootStateByHref(\n href: Href,\n rootState: ReactNavigationState\n): NavigationRoute<ParamListBase, string> | undefined {\n const hrefState = store.getStateForHref(resolveHref(href));\n const state: ReactNavigationState | undefined = rootState;\n if (!hrefState || !state) {\n return undefined;\n }\n // Replicating the logic from `linkTo`\n const { navigationState, actionStateRoute } = findDivergentState(\n hrefState,\n state as NavigationState,\n true\n );\n\n if (!navigationState || !actionStateRoute) {\n return undefined;\n }\n\n if (navigationState.type === 'stack') {\n const stackState = navigationState as StackNavigationState<ParamListBase>;\n const payload = getPayloadFromStateRoute(actionStateRoute);\n\n const preloadedRoute = stackState.preloadedRoutes.find(\n (route) => route.name === actionStateRoute.name && deepEqual(route.params, payload.params)\n );\n return preloadedRoute;\n }\n\n return undefined;\n}\n\nexport function deepEqual(\n a: { [key: string]: any } | undefined,\n b: { [key: string]: any } | undefined\n): boolean {\n if (a === b) {\n return true;\n }\n if (a == null || b == null) {\n return false;\n }\n if (typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n const keys = Object.keys(a).filter((key) => key !== '__internal__expoRouterIsPreviewNavigation');\n return keys.length === Object.keys(b).length && keys.every((key) => deepEqual(a[key], b[key]));\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/link/preview/utils.ts"],"names":[],"mappings":";;AAeA,sEA+BC;AAED,oFAoCC;AAED,8BAeC;AA7FD,kEAAmF;AACnF,wDAA0F;AAE1F,kCAAsC;AAEtC,6DAAwE;AAExE,SAAgB,6BAA6B,CAC3C,IAAU,EACV,SAA+B;IAE/B,MAAM,SAAS,GAAG,oBAAK,CAAC,eAAe,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAqC,SAAS,CAAC;IAC1D,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,sCAAsC;IACtC,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,4BAAkB,EAAC,SAAS,EAAE,KAAwB,EAAE,IAAI,CAAC,CAAC;IAE3F,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;QACzC,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,KAAK,KAAK,EAAE,CAAC;YAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAA0C,CAAC;YAClE,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;YACtD,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CACb,gCAAgC,KAAK,CAAC,GAAG,+CAA+C,CACzF,CAAC;YACJ,CAAC;YACD,MAAM,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C;IAErC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjG,CAAC","sourcesContent":["import {\n ParamListBase,\n StackNavigationState,\n type NavigationRoute,\n type NavigationState,\n type TabNavigationState,\n} from '@react-navigation/native';\n\nimport { store, type ReactNavigationState } from '../../global-state/router-store';\nimport { findDivergentState, getPayloadFromStateRoute } from '../../global-state/routing';\nimport { Href } from '../../types';\nimport { resolveHref } from '../href';\nimport { TabPath } from './native';\nimport { removeInternalExpoRouterParams } from '../../navigationParams';\n\nexport function getTabPathFromRootStateByHref(\n href: Href,\n rootState: ReactNavigationState\n): TabPath[] {\n const hrefState = store.getStateForHref(resolveHref(href));\n const state: ReactNavigationState | undefined = rootState;\n if (!hrefState || !state) {\n return [];\n }\n // Replicating the logic from `linkTo`\n const { navigationRoutes } = findDivergentState(hrefState, state as NavigationState, true);\n\n if (!navigationRoutes.length) {\n return [];\n }\n\n const tabPath: TabPath[] = [];\n navigationRoutes.forEach((route, i, arr) => {\n if (route.state?.type === 'tab') {\n const tabState = route.state as TabNavigationState<ParamListBase>;\n const oldTabKey = tabState.routes[tabState.index].key;\n if (!arr[i + 1]) {\n throw new Error(\n `New tab route is missing for ${route.key}. This is likely an internal Expo Router bug.`\n );\n }\n const newTabKey = arr[i + 1].key;\n tabPath.push({ oldTabKey, newTabKey });\n }\n });\n return tabPath;\n}\n\nexport function getPreloadedRouteFromRootStateByHref(\n href: Href,\n rootState: ReactNavigationState\n): NavigationRoute<ParamListBase, string> | undefined {\n const hrefState = store.getStateForHref(resolveHref(href));\n const state: ReactNavigationState | undefined = rootState;\n if (!hrefState || !state) {\n return undefined;\n }\n // Replicating the logic from `linkTo`\n const { navigationState, actionStateRoute } = findDivergentState(\n hrefState,\n state as NavigationState,\n true\n );\n\n if (!navigationState || !actionStateRoute) {\n return undefined;\n }\n\n if (navigationState.type === 'stack') {\n const stackState = navigationState as StackNavigationState<ParamListBase>;\n const payload = getPayloadFromStateRoute(actionStateRoute);\n\n const preloadedRoute = stackState.preloadedRoutes.find(\n (route) =>\n route.name === actionStateRoute.name &&\n deepEqual(\n removeInternalExpoRouterParams(route.params),\n removeInternalExpoRouterParams(payload.params)\n )\n );\n return preloadedRoute;\n }\n\n return undefined;\n}\n\nexport function deepEqual(\n a: { [key: string]: any } | undefined,\n b: { [key: string]: any } | undefined\n): boolean {\n if (a === b) {\n return true;\n }\n if (a == null || b == null) {\n return false;\n }\n if (typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n const keys = Object.keys(a);\n return keys.length === Object.keys(b).length && keys.every((key) => deepEqual(a[key], b[key]));\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { ParamListBase, type EventMapBase } from '@react-navigation/native';
2
2
  import React from 'react';
3
3
  import type { NativeTabOptions, NativeTabsProps } from './types';
4
+ export declare const NativeTabsContext: React.Context<boolean>;
4
5
  export declare function NativeTabsNavigator({ children, backBehavior, ...rest }: NativeTabsProps): React.JSX.Element;
5
6
  export declare const NativeTabsNavigatorWithContext: React.ForwardRefExoticComponent<Omit<NativeTabsProps, "children"> & Partial<Pick<NativeTabsProps, "children">> & React.RefAttributes<unknown>> & {
6
7
  Screen: (props: import("../..").ScreenProps<NativeTabOptions, Readonly<{
@@ -1 +1 @@
1
- {"version":3,"file":"NativeBottomTabsNavigator.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,aAAa,EAIb,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAOjE,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,YAAkC,EAClC,GAAG,IAAI,EACR,EAAE,eAAe,qBA+BjB;AAID,eAAO,MAAM,8BAA8B;;;;;;;;;;;CAKa,CAAC"}
1
+ {"version":3,"file":"NativeBottomTabsNavigator.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,aAAa,EAIb,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAc,MAAM,OAAO,CAAC;AAKnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAMjE,eAAO,MAAM,iBAAiB,wBAAsC,CAAC;AAErE,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,YAAkC,EAClC,GAAG,IAAI,EACR,EAAE,eAAe,qBAwCjB;AAID,eAAO,MAAM,8BAA8B;;;;;;;;;;;CAKa,CAAC"}
@@ -1,13 +1,43 @@
1
1
  "use strict";
2
2
  'use client';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
6
36
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.NativeTabsNavigatorWithContext = void 0;
37
+ exports.NativeTabsNavigatorWithContext = exports.NativeTabsContext = void 0;
8
38
  exports.NativeTabsNavigator = NativeTabsNavigator;
9
39
  const native_1 = require("@react-navigation/native");
10
- const react_1 = __importDefault(require("react"));
40
+ const react_1 = __importStar(require("react"));
11
41
  const NativeBottomTabsRouter_1 = require("./NativeBottomTabsRouter");
12
42
  const NativeTabsView_1 = require("./NativeTabsView");
13
43
  const __1 = require("../..");
@@ -15,7 +45,11 @@ const utils_1 = require("./utils");
15
45
  const linking_1 = require("../../link/linking");
16
46
  // In Jetpack Compose, the default back behavior is to go back to the initial route.
17
47
  const defaultBackBehavior = 'initialRoute';
48
+ exports.NativeTabsContext = react_1.default.createContext(false);
18
49
  function NativeTabsNavigator({ children, backBehavior = defaultBackBehavior, ...rest }) {
50
+ if ((0, react_1.use)(exports.NativeTabsContext)) {
51
+ throw new Error('Nesting Native Tabs inside each other is not supported natively. Use JS tabs for nesting instead.');
52
+ }
19
53
  const builder = (0, native_1.useNavigationBuilder)(NativeBottomTabsRouter_1.NativeBottomTabsRouter, {
20
54
  children,
21
55
  backBehavior,
@@ -33,7 +67,9 @@ function NativeTabsNavigator({ children, backBehavior = defaultBackBehavior, ...
33
67
  // Set focusedIndex to the first visible tab
34
68
  focusedIndex = routes.findIndex((route) => (0, utils_1.shouldTabBeVisible)(descriptors[route.key].options));
35
69
  }
36
- return <NativeTabsView_1.NativeTabsView builder={builder} {...rest} focusedIndex={focusedIndex}/>;
70
+ return (<exports.NativeTabsContext value>
71
+ <NativeTabsView_1.NativeTabsView builder={builder} {...rest} focusedIndex={focusedIndex}/>
72
+ </exports.NativeTabsContext>);
37
73
  }
38
74
  const createNativeTabNavigator = (0, native_1.createNavigatorFactory)(NativeTabsNavigator);
39
75
  exports.NativeTabsNavigatorWithContext = (0, __1.withLayoutContext)(createNativeTabNavigator().Navigator, undefined, true);
@@ -1 +1 @@
1
- {"version":3,"file":"NativeBottomTabsNavigator.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AAuBb,kDAmCC;AAxDD,qDAQkC;AAClC,kDAA0B;AAE1B,qEAAkE;AAClE,qDAAkD;AAClD,6BAA0C;AAE1C,mCAA6C;AAC7C,gDAAsD;AAEtD,oFAAoF;AACpF,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAE3C,SAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,YAAY,GAAG,mBAAmB,EAClC,GAAG,IAAI,EACS;IAChB,MAAM,OAAO,GAAG,IAAA,6BAAoB,EAMlC,+CAAsB,EAAE;QACxB,QAAQ;QACR,YAAY;KACb,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACzB,IAAI,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC;IAC/B,MAAM,iBAAiB,GACrB,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG;QACxB,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC;QACrC,IAAA,0BAAkB,EAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;IAEpE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CACb,wHAAwH,IAAA,0BAAgB,EAAC,KAAK,CAAC,GAAG,CACnJ,CAAC;QACJ,CAAC;QACD,4CAA4C;QAC5C,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,0BAAkB,EAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,CAAC,+BAAc,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,EAAG,CAAC;AACpF,CAAC;AAED,MAAM,wBAAwB,GAAG,IAAA,+BAAsB,EAAC,mBAAmB,CAAC,CAAC;AAEhE,QAAA,8BAA8B,GAAG,IAAA,qBAAiB,EAK7D,wBAAwB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC","sourcesContent":["'use client';\n\nimport {\n createNavigatorFactory,\n NavigationState,\n ParamListBase,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n type EventMapBase,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { NativeBottomTabsRouter } from './NativeBottomTabsRouter';\nimport { NativeTabsView } from './NativeTabsView';\nimport { withLayoutContext } from '../..';\nimport type { NativeTabOptions, NativeTabsProps } from './types';\nimport { shouldTabBeVisible } from './utils';\nimport { getPathFromState } from '../../link/linking';\n\n// In Jetpack Compose, the default back behavior is to go back to the initial route.\nconst defaultBackBehavior = 'initialRoute';\n\nexport function NativeTabsNavigator({\n children,\n backBehavior = defaultBackBehavior,\n ...rest\n}: NativeTabsProps) {\n const builder = useNavigationBuilder<\n TabNavigationState<ParamListBase>,\n TabRouterOptions,\n Record<string, (...args: any) => void>,\n NativeTabOptions,\n Record<string, any>\n >(NativeBottomTabsRouter, {\n children,\n backBehavior,\n });\n\n const { state, descriptors } = builder;\n const { routes } = state;\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 return <NativeTabsView builder={builder} {...rest} focusedIndex={focusedIndex} />;\n}\n\nconst createNativeTabNavigator = createNavigatorFactory(NativeTabsNavigator);\n\nexport const NativeTabsNavigatorWithContext = withLayoutContext<\n NativeTabOptions,\n typeof NativeTabsNavigator,\n NavigationState,\n EventMapBase\n>(createNativeTabNavigator().Navigator, undefined, true);\n"]}
1
+ {"version":3,"file":"NativeBottomTabsNavigator.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBb,kDA4CC;AAlED,qDAQkC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AAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,CACL,CAAC,yBAAiB,CAAC,KAAK,CACtB;MAAA,CAAC,+BAAc,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,EACzE;IAAA,EAAE,yBAAiB,CAAC,CACrB,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB,GAAG,IAAA,+BAAsB,EAAC,mBAAmB,CAAC,CAAC;AAEhE,QAAA,8BAA8B,GAAG,IAAA,qBAAiB,EAK7D,wBAAwB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC","sourcesContent":["'use client';\n\nimport {\n createNavigatorFactory,\n NavigationState,\n ParamListBase,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n type EventMapBase,\n} from '@react-navigation/native';\nimport React, { use } from 'react';\n\nimport { NativeBottomTabsRouter } from './NativeBottomTabsRouter';\nimport { NativeTabsView } from './NativeTabsView';\nimport { withLayoutContext } from '../..';\nimport type { NativeTabOptions, NativeTabsProps } from './types';\nimport { shouldTabBeVisible } from './utils';\nimport { getPathFromState } from '../../link/linking';\n\n// In Jetpack Compose, the default back behavior is to go back to the initial route.\nconst defaultBackBehavior = 'initialRoute';\nexport const NativeTabsContext = React.createContext<boolean>(false);\n\nexport function NativeTabsNavigator({\n children,\n backBehavior = defaultBackBehavior,\n ...rest\n}: NativeTabsProps) {\n if (use(NativeTabsContext)) {\n throw new Error(\n 'Nesting Native Tabs inside each other is not supported natively. Use JS tabs for nesting instead.'\n );\n }\n const builder = useNavigationBuilder<\n TabNavigationState<ParamListBase>,\n TabRouterOptions,\n Record<string, (...args: any) => void>,\n NativeTabOptions,\n Record<string, any>\n >(NativeBottomTabsRouter, {\n children,\n backBehavior,\n });\n\n const { state, descriptors } = builder;\n const { routes } = state;\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 return (\n <NativeTabsContext value>\n <NativeTabsView builder={builder} {...rest} focusedIndex={focusedIndex} />\n </NativeTabsContext>\n );\n}\n\nconst createNativeTabNavigator = createNavigatorFactory(NativeTabsNavigator);\n\nexport const NativeTabsNavigatorWithContext = withLayoutContext<\n NativeTabOptions,\n typeof NativeTabsNavigator,\n NavigationState,\n EventMapBase\n>(createNativeTabNavigator().Navigator, undefined, true);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"NativeBottomTabsRouter.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,MAAM,EACN,aAAa,EACb,kBAAkB,EAElB,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,0IAuE/D"}
1
+ {"version":3,"file":"NativeBottomTabsRouter.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,MAAM,EACN,aAAa,EACb,kBAAkB,EAElB,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAQlC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,0IAiD/D"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NativeBottomTabsRouter = NativeBottomTabsRouter;
4
4
  const native_1 = require("@react-navigation/native");
5
+ const navigationParams_1 = require("../../navigationParams");
5
6
  function NativeBottomTabsRouter(options) {
6
7
  const tabRouter = (0, native_1.TabRouter)({ ...options });
7
8
  const nativeTabRouter = {
@@ -21,33 +22,11 @@ function NativeBottomTabsRouter(options) {
21
22
  if (route.name !== action.payload.name) {
22
23
  return route;
23
24
  }
24
- const nestedParams = route.params &&
25
- 'params' in route.params &&
26
- typeof route.params.params === 'object' &&
27
- route.params.params
28
- ? route.params.params
29
- : {};
30
- const isPreviewNavigation = action.payload.params &&
31
- '__internal__expoRouterIsPreviewNavigation' in action.payload.params
32
- ? action.payload.params.__internal__expoRouterIsPreviewNavigation
33
- : undefined;
34
- const previewKeyParams = isPreviewNavigation
35
- ? {
36
- __internal__expoRouterIsPreviewNavigation: isPreviewNavigation,
37
- }
38
- : {};
39
- const params = {
40
- ...(route.params || {}),
41
- ...previewKeyParams,
42
- // This is a workaround for the issue with the preview key not being passed to the params
43
- // https://github.com/Ubax/react-navigation/blob/main/packages/core/src/useNavigationBuilder.tsx#L573
44
- // Another solution would be to propagate the preview key in the useNavigationBuilder,
45
- // but that would require us to fork the @react-navigation/core package.
46
- params: {
47
- ...nestedParams,
48
- ...previewKeyParams,
49
- },
50
- };
25
+ const expoParams = (0, navigationParams_1.getInternalExpoRouterParams)(action.payload.params);
26
+ if (route.params && 'screen' in route.params) {
27
+ expoParams['__internal_expo_router_no_animation'] = true;
28
+ }
29
+ const params = (0, navigationParams_1.appendInternalExpoRouterParams)(route.params, expoParams);
51
30
  return {
52
31
  ...route,
53
32
  params,
@@ -1 +1 @@
1
- {"version":3,"file":"NativeBottomTabsRouter.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.tsx"],"names":[],"mappings":";;AAUA,wDAuEC;AAjFD,qDAQkC;AAElC,SAAgB,sBAAsB,CAAC,OAAyB;IAC9D,MAAM,SAAS,GAAG,IAAA,kBAAS,EAAC,E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AAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,yCAAyC;gCACjE,CAAC,CAAC,SAAS,CAAC;4BAChB,MAAM,gBAAgB,GAAG,mBAAmB;gCAC1C,CAAC,CAAC;oCACE,yCAAyC,EAAE,mBAAmB;iCAC/D;gCACH,CAAC,CAAC,EAAE,CAAC;4BAEP,MAAM,MAAM,GAAG;gCACb,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;gCACvB,GAAG,gBAAgB;gCACnB,yFAAyF;gCACzF,qGAAqG;gCACrG,sFAAsF;gCACtF,wEAAwE;gCACxE,MAAM,EAAE;oCACN,GAAG,YAAY;oCACf,GAAG,gBAAgB;iCACpB;6BACF,CAAC;4BACF,OAAO;gCACL,GAAG,KAAK;gCACR,MAAM;6BACP,CAAC;wBACJ,CAAC,CAAC;qBACH,CAAC;oBACF,OAAO,QAAQ,CAAC;gBAClB,CAAC;YACH,CAAC;YACD,OAAO,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import {\n CommonNavigationAction,\n ParamListBase,\n Router,\n TabActionType,\n TabNavigationState,\n TabRouter,\n type TabRouterOptions,\n} from '@react-navigation/native';\n\nexport function NativeBottomTabsRouter(options: TabRouterOptions) {\n const tabRouter = TabRouter({ ...options });\n\n const nativeTabRouter: Router<\n TabNavigationState<ParamListBase>,\n TabActionType | CommonNavigationAction\n > = {\n ...tabRouter,\n // @ts-expect-error TODO: For some reason this is not typed correctly\n getStateForAction: (state, action: TabActionType | CommonNavigationAction, options) => {\n switch (action.type) {\n case 'NAVIGATE': {\n const newStateFromNavigation = tabRouter.getStateForAction(state, action, options);\n const index = state.routes.findIndex((route) => route.name === action.payload.name);\n\n if (index === -1 || !newStateFromNavigation) {\n return newStateFromNavigation;\n }\n\n const newState = {\n ...newStateFromNavigation,\n routes: newStateFromNavigation.routes.map((route) => {\n if (route.name !== action.payload.name) {\n return route;\n }\n\n const nestedParams =\n route.params &&\n 'params' in route.params &&\n typeof route.params.params === 'object' &&\n route.params.params\n ? route.params.params\n : {};\n\n const isPreviewNavigation =\n action.payload.params &&\n '__internal__expoRouterIsPreviewNavigation' in action.payload.params\n ? action.payload.params.__internal__expoRouterIsPreviewNavigation\n : undefined;\n const previewKeyParams = isPreviewNavigation\n ? {\n __internal__expoRouterIsPreviewNavigation: isPreviewNavigation,\n }\n : {};\n\n const params = {\n ...(route.params || {}),\n ...previewKeyParams,\n // This is a workaround for the issue with the preview key not being passed to the params\n // https://github.com/Ubax/react-navigation/blob/main/packages/core/src/useNavigationBuilder.tsx#L573\n // Another solution would be to propagate the preview key in the useNavigationBuilder,\n // but that would require us to fork the @react-navigation/core package.\n params: {\n ...nestedParams,\n ...previewKeyParams,\n },\n };\n return {\n ...route,\n params,\n };\n }),\n };\n return newState;\n }\n }\n return tabRouter.getStateForAction(state, action, options);\n },\n };\n\n return nativeTabRouter;\n}\n"]}
1
+ {"version":3,"file":"NativeBottomTabsRouter.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.tsx"],"names":[],"mappings":";;AAgBA,wDAiDC;AAjED,qDAQkC;AAElC,6DAIgC;AAEhC,SAAgB,sBAAsB,CAAC,OAAyB;IAC9D,MAAM,SAAS,GAAG,IAAA,kBAAS,EAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAE5C,MAAM,eAAe,GAGjB;QACF,GAAG,SAAS;QACZ,qEAAqE;QACrE,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAA8C,EAAE,OAAO,EAAE,EAAE;YACpF,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;gBACpB,KAAK,UAAU,CAAC,CAAC,CAAC;oBAChB,MAAM,sBAAsB,GAAG,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;oBACnF,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBAEpF,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC;wBAC5C,OAAO,sBAAsB,CAAC;oBAChC,CAAC;oBAED,MAAM,QAAQ,GAAG;wBACf,GAAG,sBAAsB;wBACzB,MAAM,EAAE,sBAAsB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;4BAClD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gCACvC,OAAO,KAAK,CAAC;4BACf,CAAC;4BAED,MAAM,UAAU,GAA6B,IAAA,8CAA2B,EACtE,MAAM,CAAC,OAAO,CAAC,MAAM,CACtB,CAAC;4BAEF,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gCAC7C,UAAU,CAAC,qCAAqC,CAAC,GAAG,IAAI,CAAC;4BAC3D,CAAC;4BAED,MAAM,MAAM,GAAG,IAAA,iDAA8B,EAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;4BACxE,OAAO;gCACL,GAAG,KAAK;gCACR,MAAM;6BACP,CAAC;wBACJ,CAAC,CAAC;qBACH,CAAC;oBACF,OAAO,QAAQ,CAAC;gBAClB,CAAC;YACH,CAAC;YACD,OAAO,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import {\n CommonNavigationAction,\n ParamListBase,\n Router,\n TabActionType,\n TabNavigationState,\n TabRouter,\n type TabRouterOptions,\n} from '@react-navigation/native';\n\nimport {\n appendInternalExpoRouterParams,\n getInternalExpoRouterParams,\n type InternalExpoRouterParams,\n} from '../../navigationParams';\n\nexport function NativeBottomTabsRouter(options: TabRouterOptions) {\n const tabRouter = TabRouter({ ...options });\n\n const nativeTabRouter: Router<\n TabNavigationState<ParamListBase>,\n TabActionType | CommonNavigationAction\n > = {\n ...tabRouter,\n // @ts-expect-error TODO: For some reason this is not typed correctly\n getStateForAction: (state, action: TabActionType | CommonNavigationAction, options) => {\n switch (action.type) {\n case 'NAVIGATE': {\n const newStateFromNavigation = tabRouter.getStateForAction(state, action, options);\n const index = state.routes.findIndex((route) => route.name === action.payload.name);\n\n if (index === -1 || !newStateFromNavigation) {\n return newStateFromNavigation;\n }\n\n const newState = {\n ...newStateFromNavigation,\n routes: newStateFromNavigation.routes.map((route) => {\n if (route.name !== action.payload.name) {\n return route;\n }\n\n const expoParams: InternalExpoRouterParams = getInternalExpoRouterParams(\n action.payload.params\n );\n\n if (route.params && 'screen' in route.params) {\n expoParams['__internal_expo_router_no_animation'] = true;\n }\n\n const params = appendInternalExpoRouterParams(route.params, expoParams);\n return {\n ...route,\n params,\n };\n }),\n };\n return newState;\n }\n }\n return tabRouter.getStateForAction(state, action, options);\n },\n };\n\n return nativeTabRouter;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ declare const internalExpoRouterParamNames: readonly ["__internal_expo_router_no_animation", "__internal__expo_router_is_preview_navigation"];
2
+ export type InternalExpoRouterParamName = (typeof internalExpoRouterParamNames)[number];
3
+ export type InternalExpoRouterParams = Partial<Record<InternalExpoRouterParamName, unknown>>;
4
+ export declare function appendInternalExpoRouterParams(params: Record<string, unknown> | object | undefined, expoParams: InternalExpoRouterParams): Record<string, unknown> | undefined;
5
+ export declare function getInternalExpoRouterParams(_params: Record<string, unknown> | object | undefined): InternalExpoRouterParams;
6
+ export declare function removeInternalExpoRouterParams(params: Record<string, unknown> | object): Record<string, unknown> | object;
7
+ export declare function removeInternalExpoRouterParams(params: Record<string, unknown> | object | undefined): Record<string, unknown> | object | undefined;
8
+ export {};
9
+ //# sourceMappingURL=navigationParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationParams.d.ts","sourceRoot":"","sources":["../src/navigationParams.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,4BAA4B,mGAGxB,CAAC;AAEX,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC;AACxF,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC,CAAC;AAE7F,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,EACpD,UAAU,EAAE,wBAAwB,uCAyBrC;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,GACpD,wBAAwB,CAiB1B;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;AACpC,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,GACnD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appendInternalExpoRouterParams = appendInternalExpoRouterParams;
4
+ exports.getInternalExpoRouterParams = getInternalExpoRouterParams;
5
+ exports.removeInternalExpoRouterParams = removeInternalExpoRouterParams;
6
+ const INTERNAL_EXPO_ROUTER_NO_ANIMATION_PARAM_NAME = '__internal_expo_router_no_animation';
7
+ const INTERNAL_EXPO_ROUTER_IS_PREVIEW_NAVIGATION_PARAM_NAME = '__internal__expo_router_is_preview_navigation';
8
+ const internalExpoRouterParamNames = [
9
+ INTERNAL_EXPO_ROUTER_NO_ANIMATION_PARAM_NAME,
10
+ INTERNAL_EXPO_ROUTER_IS_PREVIEW_NAVIGATION_PARAM_NAME,
11
+ ];
12
+ function appendInternalExpoRouterParams(params, expoParams) {
13
+ let newParams = {};
14
+ // Using nested params is a workaround for the issue with the preview key not being passed to the params
15
+ // https://github.com/Ubax/react-navigation/blob/main/packages/core/src/useNavigationBuilder.tsx#L573
16
+ // Another solution would be to propagate the preview key in the useNavigationBuilder,
17
+ // but that would require us to fork the @react-navigation/core package.
18
+ let nestedParams = {};
19
+ if (params) {
20
+ newParams = { ...params };
21
+ if ('params' in params) {
22
+ if (typeof params.params === 'object' && params.params) {
23
+ nestedParams = params.params;
24
+ }
25
+ }
26
+ }
27
+ nestedParams = { ...nestedParams, ...expoParams };
28
+ newParams = { ...newParams, ...expoParams };
29
+ if (Object.keys(nestedParams).length > 0) {
30
+ newParams.params = nestedParams;
31
+ }
32
+ if (Object.keys(newParams).length === 0 && params === undefined) {
33
+ return undefined;
34
+ }
35
+ return newParams;
36
+ }
37
+ function getInternalExpoRouterParams(_params) {
38
+ const expoParams = {};
39
+ const params = _params ? _params : {};
40
+ const nestedParams = 'params' in params && typeof params.params === 'object' && params.params
41
+ ? params.params
42
+ : {};
43
+ for (const key of internalExpoRouterParamNames) {
44
+ if (key in params) {
45
+ expoParams[key] = params[key];
46
+ }
47
+ else if (key in nestedParams) {
48
+ expoParams[key] = nestedParams[key];
49
+ }
50
+ }
51
+ return expoParams;
52
+ }
53
+ function removeInternalExpoRouterParams(params) {
54
+ if (!params) {
55
+ return undefined;
56
+ }
57
+ const newNestedParams = 'params' in params && typeof params.params === 'object' && params.params
58
+ ? Object.fromEntries(Object.entries(params.params).filter(([key]) => !internalExpoRouterParamNames.includes(key)))
59
+ : {};
60
+ const newParams = Object.fromEntries(Object.entries(params).filter(([key]) => !internalExpoRouterParamNames.includes(key) &&
61
+ key !== 'params'));
62
+ if (Object.keys(newNestedParams).length > 0) {
63
+ return { ...newParams, params: newNestedParams };
64
+ }
65
+ return newParams;
66
+ }
67
+ //# sourceMappingURL=navigationParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationParams.js","sourceRoot":"","sources":["../src/navigationParams.ts"],"names":[],"mappings":";;AAYA,wEA2BC;AAED,kEAmBC;AAQD,wEAyBC;AA7FD,MAAM,4CAA4C,GAAG,qCAAqC,CAAC;AAC3F,MAAM,qDAAqD,GACzD,+CAA+C,CAAC;AAElD,MAAM,4BAA4B,GAAG;IACnC,4CAA4C;IAC5C,qDAAqD;CAC7C,CAAC;AAKX,SAAgB,8BAA8B,CAC5C,MAAoD,EACpD,UAAoC;IAEpC,IAAI,SAAS,GAA4B,EAAE,CAAC;IAC5C,wGAAwG;IACxG,qGAAqG;IACrG,sFAAsF;IACtF,wEAAwE;IACxE,IAAI,YAAY,GAA4B,EAAE,CAAC;IAC/C,IAAI,MAAM,EAAE,CAAC;QACX,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;QAC1B,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;YACvB,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACvD,YAAY,GAAG,MAAM,CAAC,MAAiC,CAAC;YAC1D,CAAC;QACH,CAAC;IACH,CAAC;IACD,YAAY,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,UAAU,EAAE,CAAC;IAClD,SAAS,GAAG,EAAE,GAAG,SAAS,EAAE,GAAG,UAAU,EAAE,CAAC;IAC5C,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,SAAS,CAAC,MAAM,GAAG,YAAY,CAAC;IAClC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,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AC,CACtF,CACF;QACH,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAClC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAC3B,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CACR,CAAC,4BAA4B,CAAC,QAAQ,CAAC,GAAkC,CAAC;QAC1E,GAAG,KAAK,QAAQ,CACnB,CACF,CAAC;IACF,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,OAAO,EAAE,GAAG,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACnD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["const INTERNAL_EXPO_ROUTER_NO_ANIMATION_PARAM_NAME = '__internal_expo_router_no_animation';\nconst INTERNAL_EXPO_ROUTER_IS_PREVIEW_NAVIGATION_PARAM_NAME =\n '__internal__expo_router_is_preview_navigation';\n\nconst internalExpoRouterParamNames = [\n INTERNAL_EXPO_ROUTER_NO_ANIMATION_PARAM_NAME,\n INTERNAL_EXPO_ROUTER_IS_PREVIEW_NAVIGATION_PARAM_NAME,\n] as const;\n\nexport type InternalExpoRouterParamName = (typeof internalExpoRouterParamNames)[number];\nexport type InternalExpoRouterParams = Partial<Record<InternalExpoRouterParamName, unknown>>;\n\nexport function appendInternalExpoRouterParams(\n params: Record<string, unknown> | object | undefined,\n expoParams: InternalExpoRouterParams\n) {\n let newParams: Record<string, unknown> = {};\n // Using nested params is a workaround for the issue with the preview key not being passed to the params\n // https://github.com/Ubax/react-navigation/blob/main/packages/core/src/useNavigationBuilder.tsx#L573\n // Another solution would be to propagate the preview key in the useNavigationBuilder,\n // but that would require us to fork the @react-navigation/core package.\n let nestedParams: Record<string, unknown> = {};\n if (params) {\n newParams = { ...params };\n if ('params' in params) {\n if (typeof params.params === 'object' && params.params) {\n nestedParams = params.params as Record<string, unknown>;\n }\n }\n }\n nestedParams = { ...nestedParams, ...expoParams };\n newParams = { ...newParams, ...expoParams };\n if (Object.keys(nestedParams).length > 0) {\n newParams.params = nestedParams;\n }\n if (Object.keys(newParams).length === 0 && params === undefined) {\n return undefined;\n }\n return newParams;\n}\n\nexport function getInternalExpoRouterParams(\n _params: Record<string, unknown> | object | undefined\n): InternalExpoRouterParams {\n const expoParams: InternalExpoRouterParams = {};\n const params: Record<string, unknown> = _params ? (_params as Record<string, unknown>) : {};\n const nestedParams: Record<string, unknown> =\n 'params' in params && typeof params.params === 'object' && params.params\n ? (params.params as Record<string, unknown>)\n : {};\n\n for (const key of internalExpoRouterParamNames) {\n if (key in params) {\n expoParams[key] = params[key];\n } else if (key in nestedParams) {\n expoParams[key] = nestedParams[key];\n }\n }\n\n return expoParams;\n}\n\nexport function removeInternalExpoRouterParams(\n params: Record<string, unknown> | object\n): Record<string, unknown> | object;\nexport function removeInternalExpoRouterParams(\n params: Record<string, unknown> | object | undefined\n): Record<string, unknown> | object | undefined;\nexport function removeInternalExpoRouterParams(\n params: Record<string, unknown> | object | undefined\n): Record<string, unknown> | object | undefined {\n if (!params) {\n return undefined;\n }\n const newNestedParams =\n 'params' in params && typeof params.params === 'object' && params.params\n ? Object.fromEntries(\n Object.entries(params.params).filter(\n ([key]) => !internalExpoRouterParamNames.includes(key as InternalExpoRouterParamName)\n )\n )\n : {};\n const newParams = Object.fromEntries(\n Object.entries(params).filter(\n ([key]) =>\n !internalExpoRouterParamNames.includes(key as InternalExpoRouterParamName) &&\n key !== 'params'\n )\n );\n if (Object.keys(newNestedParams).length > 0) {\n return { ...newParams, params: newNestedParams };\n }\n return newParams;\n}\n"]}
@@ -1,2 +1,6 @@
1
- export declare const Slot: import("react").ForwardRefExoticComponent<import("@radix-ui/react-slot").SlotProps & import("react").RefAttributes<HTMLElement>>;
1
+ import { type ForwardRefExoticComponent, type Component, type RefAttributes } from 'react';
2
+ import { type ViewProps } from 'react-native';
3
+ export interface Slot<Props = ViewProps, Ref = Component<ViewProps>> extends ForwardRefExoticComponent<Props & RefAttributes<Ref>> {
4
+ }
5
+ export declare const Slot: Slot;
2
6
  //# sourceMappingURL=Slot.d.ts.map