expo-router 6.0.0-preview.14 → 6.0.0-preview.15

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.
@@ -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,qBA0H/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,qBAwH/D"}
@@ -85,7 +85,6 @@ function LinkWithPreview({ children, ...rest }) {
85
85
  }
86
86
  }
87
87
  const trigger = react_1.default.useMemo(() => triggerElement ?? <elements_1.LinkTrigger>{children}</elements_1.LinkTrigger>, [triggerElement, children]);
88
- const highlightBorderRadius = rest.style && 'borderRadius' in rest.style ? rest.style.borderRadius : undefined;
89
88
  const preview = react_1.default.useMemo(() => ((0, url_1.shouldLinkExternally)(String(rest.href)) || !previewElement ? null : previewElement), [previewElement, rest.href]);
90
89
  const isPreviewTapped = (0, react_1.useRef)(false);
91
90
  const tabPathValue = (0, react_1.useMemo)(() => ({
@@ -119,7 +118,7 @@ function LinkWithPreview({ children, ...rest }) {
119
118
  if (!isPad) {
120
119
  router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });
121
120
  }
122
- }} style={react_native_1.StyleSheet.flatten([{ display: 'contents', borderRadius: highlightBorderRadius }])} disableForceFlatten>
121
+ }} style={{ display: 'contents' }} disableForceFlatten>
123
122
  <InternalLinkPreviewContext_1.InternalLinkPreviewContext value={{ isVisible: isCurrentPreviewOpen, href: rest.href }}>
124
123
  <BaseExpoRouterLink_1.BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref}/>
125
124
  {preview}
@@ -1 +1 @@
1
- {"version":3,"file":"LinkWithPreview.js","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBb,0CA0HC;AAhJD,+CAOe;AACf,+CAAoD;AAEpD,oCAAqC;AACrC,6DAA0D;AAC1D,6EAA0E;AAC1E,yCAAgE;AAChE,qEAAqE;AACrE,6CAAqD;AACrD,+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,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEvE,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,oBAAoB,GAAG,IAAA,cAAM,EAAC,gBAAgB,CAAC,CAAC;IAEtD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE,CAAC;YACzB,IAAI,oBAAoB,CAAC,OAAO,KAAK,gBAAgB,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CACb,iKAAiK,CAClK,CAAC;YACJ,CAAC;QAC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AC,uDAA0B,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CACtF;QAAA,CAAC,uCAAkB,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC/D;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, StyleSheet } 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 } 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 style={StyleSheet.flatten([{ display: 'contents', borderRadius: highlightBorderRadius }])}\n disableForceFlatten>\n <InternalLinkPreviewContext value={{ isVisible: isCurrentPreviewOpen, href: rest.href }}>\n <BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref} />\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,0CAwHC;AA9ID,+CAOe;AACf,+CAAwC;AAExC,oCAAqC;AACrC,6DAA0D;AAC1D,6EAA0E;AAC1E,yCAAgE;AAChE,qEAAqE;AACrE,6CAAqD;AACrD,+DAA4D;AAE5D,sCAAoD;AAEpD,MAAM,KAAK,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,uBAAQ,CAAC,KAAK,CAAC;AAEtD,SAAgB,e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AAE,sBAAsB,EAAE,YAAY,EAAE,CAAC,CAAC;YACvE,CAAC;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,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAC/B,mBAAmB,CACnB;MAAA,CAAC,uDAA0B,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CACtF;QAAA,CAAC,uCAAkB,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC/D;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 } 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\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 style={{ display: 'contents' }}\n disableForceFlatten>\n <InternalLinkPreviewContext value={{ isVisible: isCurrentPreviewOpen, href: rest.href }}>\n <BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref} />\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,4 +1,5 @@
1
1
  import React, { type PropsWithChildren, type ReactElement } from 'react';
2
+ import type { ViewStyle } from 'react-native';
2
3
  import type { SFSymbol } from 'sf-symbols-typescript';
3
4
  export interface LinkMenuActionProps {
4
5
  /**
@@ -95,7 +96,7 @@ export interface LinkMenuProps {
95
96
  * @platform ios
96
97
  */
97
98
  export declare const LinkMenu: React.FC<LinkMenuProps>;
98
- export interface LinkPreviewProps {
99
+ export type LinkPreviewStyle = Omit<ViewStyle, 'position' | 'width' | 'height'> & {
99
100
  /**
100
101
  * Sets the preferred width of the preview.
101
102
  * If not set, full width of the screen will be used.
@@ -110,7 +111,15 @@ export interface LinkPreviewProps {
110
111
  * This is only **preferred** height, the actual height may be different
111
112
  */
112
113
  height?: number;
114
+ };
115
+ export interface LinkPreviewProps {
113
116
  children?: React.ReactNode;
117
+ /**
118
+ * Custom styles for the preview container.
119
+ *
120
+ * Note that some styles may not work, as they are limited or reset by the native view
121
+ */
122
+ style?: LinkPreviewStyle;
114
123
  }
115
124
  /**
116
125
  * A component used to render and customize the link preview.
@@ -1 +1 @@
1
- {"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAuB,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,4BAYxD;AAED,M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;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,4BAwBlD;AAED,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,mSAYlD"}
@@ -115,12 +115,13 @@ exports.LinkMenu = LinkMenu;
115
115
  * @platform ios
116
116
  */
117
117
  function LinkPreview(props) {
118
- const { width, height, children } = props;
118
+ const { children, style } = props;
119
119
  const internalPreviewContext = (0, react_1.use)(InternalLinkPreviewContext_1.InternalLinkPreviewContext);
120
120
  if ((0, PreviewRouteContext_1.useIsPreview)() || process.env.EXPO_OS !== 'ios' || !internalPreviewContext) {
121
121
  return null;
122
122
  }
123
123
  const { isVisible, href } = internalPreviewContext;
124
+ const { width, height, ...restOfStyle } = style ?? {};
124
125
  const contentSize = {
125
126
  width: width ?? 0,
126
127
  height: height ?? 0,
@@ -132,10 +133,7 @@ function LinkPreview(props) {
132
133
  else {
133
134
  content = isVisible ? <HrefPreview_1.HrefPreview href={href}/> : null;
134
135
  }
135
- return (<native_1.NativeLinkPreviewContent style={{
136
- /* Setting default background here, so that the preview is not transparent */
137
- backgroundColor: '#fff',
138
- }} preferredContentSize={contentSize}>
136
+ return (<native_1.NativeLinkPreviewContent style={restOfStyle} preferredContentSize={contentSize}>
139
137
  {content}
140
138
  </native_1.NativeLinkPreviewContent>);
141
139
  }
@@ -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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AAC,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
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDb,wCAYC;AA8HD,kCAwBC;AAuBD,kCAYC;AA5PD,+CAA8F;AAI9F,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;IAC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AClB,KAAK,EAAE,KAAK,IAAI,CAAC;QACjB,MAAM,EAAE,MAAM,IAAI,CAAC;KACpB,CAAC;IACF,IAAI,OAAwB,CAAC;IAC7B,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,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,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,CAAC,WAAW,CAAC,CAC9E;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 { ViewStyle } from 'react-native';\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 type LinkPreviewStyle = Omit<ViewStyle, 'position' | 'width' | 'height'> & {\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};\n\nexport interface LinkPreviewProps {\n children?: React.ReactNode;\n /**\n * Custom styles for the preview container.\n *\n * Note that some styles may not work, as they are limited or reset by the native view\n */\n style?: LinkPreviewStyle;\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 { children, style } = 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 { width, height, ...restOfStyle } = style ?? {};\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 style={restOfStyle} 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"]}
@@ -73,7 +73,13 @@ function PreviewForRootHrefState({ hrefState, href }) {
73
73
  }
74
74
  function PreviewForInternalRoutes() {
75
75
  const pathname = (0, hooks_1.usePathname)();
76
- return (<react_native_1.View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', gap: 8 }}>
76
+ return (<react_native_1.View style={{
77
+ flex: 1,
78
+ justifyContent: 'center',
79
+ alignItems: 'center',
80
+ gap: 8,
81
+ backgroundColor: 'white',
82
+ }}>
77
83
  <react_native_1.Text style={{ fontWeight: '600', fontSize: 24 }}>Invalid preview</react_native_1.Text>
78
84
  <react_native_1.Text style={{ fontWeight: '200', fontSize: 14 }}>{pathname}</react_native_1.Text>
79
85
  </react_native_1.View>);
@@ -1 +1 @@
1
- {"version":3,"file":"HrefPreview.js","sourceRoot":"","sources":["../../../src/link/preview/HrefPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAsBb,kCAyCC;AA7DD,qDAIkC;AAClC,iCAAgC;AAChC,+CAA0C;AAE1C,+DAA4D;AAE5D,+CAA+F;AAE/F,kEAAwD;AACxD,oDAAkE;AAClE,uCAA0C;AAE1C,uDAAoD;AACpD,iDAA8D;AAC9D,wCAA8C;AAE9C,SAAgB,WAAW,CAAC,EAAE,IAAI,EAAkB;IAClD,MAAM,SAAS,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,SAAS,EAAE,KAAK,IAAI,CAAC,CAAC;IAEpC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,KAAK,8BAAkB,EAAE,CAAC;QAC1D,IAAI,WAAW,GAAiC,SAAS,CAAC;QAC1D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AAC,WAAW,CAAC;IAC7C,UAAU,EAAE,qBAAqB,CAAC,YAAY,CAAC;IAC/C,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,CAAiD;IAC7E,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;IACrB,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK;IACtB,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;IAC3C,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;IAC3C,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC;IACvC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC;IACrC,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC;IACnC,GAAG,EAAE,qBAAqB,CAAC,KAAK,CAAC;IACjC,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;IAC3C,kBAAkB,EAAE,qBAAqB,CAAC,oBAAoB,CAAC;IAC/D,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC;IACzC,KAAK,EAAE,GAAG,EAAE;QACV,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,mBAAmB;IACnB,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC;IAC7C,QAAQ,EAAE,GAAG,EAAE;QACb,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO;YACL,GAAG,EAAE,EAAE;YACP,KAAK,EAAE,CAAC;YACR,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContext,\n type NavigationProp,\n type ParamListBase,\n} from '@react-navigation/native';\nimport { useMemo } from 'react';\nimport { Text, View } from 'react-native';\n\nimport { PreviewRouteContext } from './PreviewRouteContext';\nimport { RouteNode } from '../../Route';\nimport { INTERNAL_SLOT_NAME, NOT_FOUND_ROUTE_NAME, SITEMAP_ROUTE_NAME } from '../../constants';\nimport { type ResultState } from '../../exports';\nimport { store } from '../../global-state/router-store';\nimport { getRootStackRouteNames } from '../../global-state/utils';\nimport { usePathname } from '../../hooks';\nimport { Href, UnknownOutputParams } from '../../types';\nimport { useNavigation } from '../../useNavigation';\nimport { getQualifiedRouteComponent } from '../../useScreens';\nimport { getPathFromState } from '../linking';\n\nexport function HrefPreview({ href }: { href: Href }) {\n const hrefState = useMemo(() => getHrefState(href), [href]);\n const index = hrefState?.index ?? 0;\n\n let isProtected = false;\n if (hrefState?.routes[index]?.name === INTERNAL_SLOT_NAME) {\n let routerState: typeof hrefState | undefined = hrefState;\n let rnState = store.state;\n while (routerState && rnState) {\n const routerRoute: ResultState['routes'][number] = routerState.routes[0];\n // When the route we want to show is not present in react-navigation state\n // Then most likely it is a protected route\n if (rnState.stale === false && !rnState.routeNames?.includes(routerRoute.name)) {\n isProtected = true;\n break;\n }\n const rnIndex = rnState.routes.findIndex((route) => route.name === routerRoute.name);\n if (rnIndex === -1) {\n break;\n }\n routerState = routerRoute.state;\n rnState = rnState.routes[rnIndex]?.state;\n }\n if (!isProtected) {\n return <PreviewForRootHrefState hrefState={hrefState} href={href} />;\n }\n }\n\n const pathname = href.toString();\n const segments = pathname.split('/').filter(Boolean);\n\n return (\n <PreviewRouteContext.Provider\n value={{\n params: {},\n pathname,\n segments,\n }}>\n <PreviewForInternalRoutes />\n </PreviewRouteContext.Provider>\n );\n}\n\nfunction PreviewForRootHrefState({ hrefState, href }: { hrefState: ResultState; href: Href }) {\n const navigation = useNavigation();\n const { routeNode, params, state } = getParamsAndNodeFromHref(hrefState);\n\n const path = state ? getPathFromState(state) : undefined;\n\n const value = useMemo(\n () => ({\n params,\n pathname: href.toString(),\n segments: path?.split('/').filter(Boolean) || [],\n }),\n [params, href]\n );\n\n // This can happen in a theoretical case where the state is not yet initialized or is incorrectly initialized.\n // This check ensures TypeScript type safety as well.\n if (!routeNode) {\n return null;\n }\n\n const Component = getQualifiedRouteComponent(routeNode);\n\n return (\n <PreviewRouteContext value={value}>\n {/* Using NavigationContext to override useNavigation */}\n <NavigationContext value={navigationPropWithWarnings}>\n <Component navigation={navigation} />\n </NavigationContext>\n </PreviewRouteContext>\n );\n}\n\nfunction PreviewForInternalRoutes() {\n const pathname = usePathname();\n return (\n <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', gap: 8 }}>\n <Text style={{ fontWeight: '600', fontSize: 24 }}>Invalid preview</Text>\n <Text style={{ fontWeight: '200', fontSize: 14 }}>{pathname}</Text>\n </View>\n );\n}\n\nfunction getHrefState(href: Href) {\n const hrefState = store.getStateForHref(href as any);\n return hrefState;\n}\n\nfunction getParamsAndNodeFromHref(hrefState: ResultState) {\n const index = hrefState?.index ?? 0;\n if (hrefState?.routes[index] && hrefState.routes[index].name !== INTERNAL_SLOT_NAME) {\n const name = hrefState.routes[index].name;\n if (name === SITEMAP_ROUTE_NAME || name === NOT_FOUND_ROUTE_NAME) {\n console.log(store.routeNode);\n console.log(hrefState);\n }\n const error = `Expo Router Error: Expected navigation state to begin with one of [${getRootStackRouteNames().join(', ')}] routes`;\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(error);\n } else {\n console.warn(error);\n }\n }\n const initialState = hrefState?.routes[index]?.state;\n let state = initialState;\n let routeNode: RouteNode | undefined | null = store.routeNode;\n\n const params: UnknownOutputParams = {};\n\n while (state && routeNode) {\n const route = state.routes[state.index || state.routes.length - 1];\n Object.assign(params, route.params);\n state = route.state;\n routeNode = routeNode.children.find((child) => child.route === route.name);\n }\n\n return { params, routeNode, state: initialState };\n}\n\nconst displayWarningForProp = (prop: string) => {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `navigation.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`\n );\n }\n};\n\nconst createNOOPWithWarning = (prop: string) => () => displayWarningForProp(prop);\n\nconst navigationPropWithWarnings: NavigationProp<ParamListBase> = {\n setParams: createNOOPWithWarning('setParams'),\n setOptions: createNOOPWithWarning('setOptions'),\n addListener: (() => () => {}) as NavigationProp<ParamListBase>['addListener'],\n removeListener: () => {},\n isFocused: () => true,\n canGoBack: () => false,\n dispatch: createNOOPWithWarning('dispatch'),\n navigate: createNOOPWithWarning('navigate'),\n goBack: createNOOPWithWarning('goBack'),\n reset: createNOOPWithWarning('reset'),\n push: createNOOPWithWarning('push'),\n pop: createNOOPWithWarning('pop'),\n popToTop: createNOOPWithWarning('popToTop'),\n navigateDeprecated: createNOOPWithWarning('navigateDeprecated'),\n preload: createNOOPWithWarning('preload'),\n getId: () => {\n displayWarningForProp('getId');\n return '';\n },\n // @ts-expect-error\n getParent: createNOOPWithWarning('getParent'),\n getState: () => {\n displayWarningForProp('getState');\n return {\n key: '',\n index: 0,\n routeNames: [],\n routes: [],\n type: '',\n stale: false,\n };\n },\n};\n"]}
1
+ {"version":3,"file":"HrefPreview.js","sourceRoot":"","sources":["../../../src/link/preview/HrefPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAsBb,kCAyCC;AA7DD,qDAIkC;AAClC,iCAAgC;AAChC,+CAA0C;AAE1C,+DAA4D;AAE5D,+CAA+F;AAE/F,kEAAwD;AACxD,oDAAkE;AAClE,uCAA0C;AAE1C,uDAAoD;AACpD,iDAA8D;AAC9D,wCAA8C;AAE9C,SAAgB,WAAW,CAAC,EAAE,IAAI,EAAkB;IAClD,MAAM,SAAS,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,SAAS,EAAE,KAAK,IAAI,CAAC,CAAC;IAEpC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,KAA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ListBase,\n} from '@react-navigation/native';\nimport { useMemo } from 'react';\nimport { Text, View } from 'react-native';\n\nimport { PreviewRouteContext } from './PreviewRouteContext';\nimport { RouteNode } from '../../Route';\nimport { INTERNAL_SLOT_NAME, NOT_FOUND_ROUTE_NAME, SITEMAP_ROUTE_NAME } from '../../constants';\nimport { type ResultState } from '../../exports';\nimport { store } from '../../global-state/router-store';\nimport { getRootStackRouteNames } from '../../global-state/utils';\nimport { usePathname } from '../../hooks';\nimport { Href, UnknownOutputParams } from '../../types';\nimport { useNavigation } from '../../useNavigation';\nimport { getQualifiedRouteComponent } from '../../useScreens';\nimport { getPathFromState } from '../linking';\n\nexport function HrefPreview({ href }: { href: Href }) {\n const hrefState = useMemo(() => getHrefState(href), [href]);\n const index = hrefState?.index ?? 0;\n\n let isProtected = false;\n if (hrefState?.routes[index]?.name === INTERNAL_SLOT_NAME) {\n let routerState: typeof hrefState | undefined = hrefState;\n let rnState = store.state;\n while (routerState && rnState) {\n const routerRoute: ResultState['routes'][number] = routerState.routes[0];\n // When the route we want to show is not present in react-navigation state\n // Then most likely it is a protected route\n if (rnState.stale === false && !rnState.routeNames?.includes(routerRoute.name)) {\n isProtected = true;\n break;\n }\n const rnIndex = rnState.routes.findIndex((route) => route.name === routerRoute.name);\n if (rnIndex === -1) {\n break;\n }\n routerState = routerRoute.state;\n rnState = rnState.routes[rnIndex]?.state;\n }\n if (!isProtected) {\n return <PreviewForRootHrefState hrefState={hrefState} href={href} />;\n }\n }\n\n const pathname = href.toString();\n const segments = pathname.split('/').filter(Boolean);\n\n return (\n <PreviewRouteContext.Provider\n value={{\n params: {},\n pathname,\n segments,\n }}>\n <PreviewForInternalRoutes />\n </PreviewRouteContext.Provider>\n );\n}\n\nfunction PreviewForRootHrefState({ hrefState, href }: { hrefState: ResultState; href: Href }) {\n const navigation = useNavigation();\n const { routeNode, params, state } = getParamsAndNodeFromHref(hrefState);\n\n const path = state ? getPathFromState(state) : undefined;\n\n const value = useMemo(\n () => ({\n params,\n pathname: href.toString(),\n segments: path?.split('/').filter(Boolean) || [],\n }),\n [params, href]\n );\n\n // This can happen in a theoretical case where the state is not yet initialized or is incorrectly initialized.\n // This check ensures TypeScript type safety as well.\n if (!routeNode) {\n return null;\n }\n\n const Component = getQualifiedRouteComponent(routeNode);\n\n return (\n <PreviewRouteContext value={value}>\n {/* Using NavigationContext to override useNavigation */}\n <NavigationContext value={navigationPropWithWarnings}>\n <Component navigation={navigation} />\n </NavigationContext>\n </PreviewRouteContext>\n );\n}\n\nfunction PreviewForInternalRoutes() {\n const pathname = usePathname();\n return (\n <View\n style={{\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n gap: 8,\n backgroundColor: 'white',\n }}>\n <Text style={{ fontWeight: '600', fontSize: 24 }}>Invalid preview</Text>\n <Text style={{ fontWeight: '200', fontSize: 14 }}>{pathname}</Text>\n </View>\n );\n}\n\nfunction getHrefState(href: Href) {\n const hrefState = store.getStateForHref(href as any);\n return hrefState;\n}\n\nfunction getParamsAndNodeFromHref(hrefState: ResultState) {\n const index = hrefState?.index ?? 0;\n if (hrefState?.routes[index] && hrefState.routes[index].name !== INTERNAL_SLOT_NAME) {\n const name = hrefState.routes[index].name;\n if (name === SITEMAP_ROUTE_NAME || name === NOT_FOUND_ROUTE_NAME) {\n console.log(store.routeNode);\n console.log(hrefState);\n }\n const error = `Expo Router Error: Expected navigation state to begin with one of [${getRootStackRouteNames().join(', ')}] routes`;\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(error);\n } else {\n console.warn(error);\n }\n }\n const initialState = hrefState?.routes[index]?.state;\n let state = initialState;\n let routeNode: RouteNode | undefined | null = store.routeNode;\n\n const params: UnknownOutputParams = {};\n\n while (state && routeNode) {\n const route = state.routes[state.index || state.routes.length - 1];\n Object.assign(params, route.params);\n state = route.state;\n routeNode = routeNode.children.find((child) => child.route === route.name);\n }\n\n return { params, routeNode, state: initialState };\n}\n\nconst displayWarningForProp = (prop: string) => {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `navigation.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`\n );\n }\n};\n\nconst createNOOPWithWarning = (prop: string) => () => displayWarningForProp(prop);\n\nconst navigationPropWithWarnings: NavigationProp<ParamListBase> = {\n setParams: createNOOPWithWarning('setParams'),\n setOptions: createNOOPWithWarning('setOptions'),\n addListener: (() => () => {}) as NavigationProp<ParamListBase>['addListener'],\n removeListener: () => {},\n isFocused: () => true,\n canGoBack: () => false,\n dispatch: createNOOPWithWarning('dispatch'),\n navigate: createNOOPWithWarning('navigate'),\n goBack: createNOOPWithWarning('goBack'),\n reset: createNOOPWithWarning('reset'),\n push: createNOOPWithWarning('push'),\n pop: createNOOPWithWarning('pop'),\n popToTop: createNOOPWithWarning('popToTop'),\n navigateDeprecated: createNOOPWithWarning('navigateDeprecated'),\n preload: createNOOPWithWarning('preload'),\n getId: () => {\n displayWarningForProp('getId');\n return '';\n },\n // @ts-expect-error\n getParent: createNOOPWithWarning('getParent'),\n getState: () => {\n displayWarningForProp('getState');\n return {\n key: '',\n index: 0,\n routeNames: [],\n routes: [],\n type: '',\n stale: false,\n };\n },\n};\n"]}
@@ -13,12 +13,6 @@ public class LinkPreviewNativeModule: Module {
13
13
  view.tabPath = tabPath
14
14
  }
15
15
 
16
- Prop("borderRadius") { (view, borderRadius: Double?) in
17
- if let borderRadius = borderRadius {
18
- view.triggerBorderRadius = borderRadius
19
- }
20
- }
21
-
22
16
  Prop("disableForceFlatten") { (_: NativeLinkPreviewView, _: Bool) in
23
17
  // This prop is used in ExpoShadowNode in order to disable force flattening, when display: contents is used
24
18
  }
@@ -2,7 +2,6 @@ import ExpoModulesCore
2
2
 
3
3
  class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
4
4
  LinkPreviewModalDismissible, LinkPreviewMenuUpdatable {
5
- var triggerBorderRadius: Double = 0
6
5
  private var preview: NativeLinkPreviewContentView?
7
6
  private var interaction: UIContextMenuInteraction?
8
7
  private var directChild: UIView?
@@ -131,8 +130,6 @@ class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
131
130
 
132
131
  let parameters = UIPreviewParameters()
133
132
  parameters.backgroundColor = .clear
134
- parameters.shadowPath = UIBezierPath(
135
- roundedRect: directChild.bounds, cornerRadius: self.triggerBorderRadius)
136
133
 
137
134
  return UITargetedPreview(view: directChild, parameters: parameters, target: target)
138
135
  }
@@ -185,7 +182,6 @@ class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
185
182
  }
186
183
 
187
184
  let vc = PreviewViewController(linkPreviewNativePreview: preview)
188
- vc.view.addSubview(preview)
189
185
  let preferredSize = preview.preferredContentSize
190
186
  vc.preferredContentSize.width = preferredSize.width
191
187
  vc.preferredContentSize.height = preferredSize.height
@@ -218,6 +214,10 @@ class PreviewViewController: UIViewController {
218
214
  super.init(nibName: nil, bundle: nil)
219
215
  }
220
216
 
217
+ override func loadView() {
218
+ self.view = linkPreviewNativePreview
219
+ }
220
+
221
221
  @available(*, unavailable)
222
222
  required init?(coder: NSCoder) {
223
223
  fatalError("init(coder:) has not been implemented")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "6.0.0-preview.14",
3
+ "version": "6.0.0-preview.15",
4
4
  "description": "Expo Router is a file-based router for React Native and web applications.",
5
5
  "author": "650 Industries, Inc.",
6
6
  "license": "MIT",
@@ -151,5 +151,5 @@
151
151
  "use-latest-callback": "^0.2.1",
152
152
  "vaul": "^1.1.2"
153
153
  },
154
- "gitHead": "f97e6d1cae0cb14d5eed1b08fad6d12a7144af3a"
154
+ "gitHead": "8cafaff8076e443e6c80e8013ec809f4f290f24d"
155
155
  }