expo-router 6.0.0-beta.7 → 6.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/link/LinkWithPreview.d.ts.map +1 -1
- package/build/link/LinkWithPreview.js +2 -4
- package/build/link/LinkWithPreview.js.map +1 -1
- package/build/link/preview/native.d.ts +0 -2
- package/build/link/preview/native.d.ts.map +1 -1
- package/build/link/preview/native.js +0 -10
- package/build/link/preview/native.js.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.d.ts.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.js +4 -2
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.js.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.d.ts.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.js +7 -25
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.js.map +1 -1
- package/build/typed-routes/generate.d.ts +2 -1
- package/build/typed-routes/generate.d.ts.map +1 -1
- package/build/typed-routes/generate.js +3 -1
- package/build/typed-routes/generate.js.map +1 -1
- package/ios/LinkPreview/LinkPreviewNativeModule.swift +6 -8
- package/ios/LinkPreview/LinkPreviewNativeView.swift +13 -28
- package/package.json +4 -4
- package/ios/LinkPreview/LinkPreviewNativeTriggerView.swift +0 -9
- package/plugin/tsconfig.tsbuildinfo +0 -1
|
@@ -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,
|
|
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,qBAyH/D"}
|
|
@@ -119,11 +119,9 @@ function LinkWithPreview({ children, ...rest }) {
|
|
|
119
119
|
if (!isPad) {
|
|
120
120
|
router.navigate(rest.href, { __internal__PreviewKey: nextScreenId });
|
|
121
121
|
}
|
|
122
|
-
}}>
|
|
122
|
+
}} style={{ borderRadius: highlightBorderRadius }}>
|
|
123
123
|
<InternalLinkPreviewContext_1.InternalLinkPreviewContext value={{ isVisible: isCurrentPreviewOpen, href: rest.href }}>
|
|
124
|
-
<
|
|
125
|
-
<BaseExpoRouterLink_1.BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref}/>
|
|
126
|
-
</native_1.NativeLinkPreviewTrigger>
|
|
124
|
+
<BaseExpoRouterLink_1.BaseExpoRouterLink {...rest} children={trigger} ref={rest.ref}/>
|
|
127
125
|
{preview}
|
|
128
126
|
{menuElement}
|
|
129
127
|
</InternalLinkPreviewContext_1.InternalLinkPreviewContext>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkWithPreview.js","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBb,
|
|
1
|
+
{"version":3,"file":"LinkWithPreview.js","sourceRoot":"","sources":["../../src/link/LinkWithPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBb,0CAyHC;AA/ID,+CAOe;AACf,+CAAwC;AAExC,oCAAqC;AACrC,6DAA0D;AAC1D,6EAA0E;AAC1E,yCAAgE;AAChE,qEAAqE;AACrE,6CAAqD;AACrD,+DAA4D;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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 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={{ borderRadius: highlightBorderRadius }}>\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"]}
|
|
@@ -12,8 +12,6 @@ export interface NativeLinkPreviewActionProps {
|
|
|
12
12
|
onSelected: () => void;
|
|
13
13
|
}
|
|
14
14
|
export declare function NativeLinkPreviewAction(props: NativeLinkPreviewActionProps): import("react").JSX.Element | null;
|
|
15
|
-
export type NativeLinkPreviewTriggerProps = ViewProps;
|
|
16
|
-
export declare function NativeLinkPreviewTrigger(props: NativeLinkPreviewTriggerProps): import("react").JSX.Element | null;
|
|
17
15
|
export interface TabPath {
|
|
18
16
|
oldTabKey: string;
|
|
19
17
|
newTabKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/link/preview/native.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAMpE,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IAKf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAKD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,sCAK1E;AAID,MAAM,
|
|
1
|
+
{"version":3,"file":"native.d.ts","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C9D,oBAAoB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D;AAMD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,sCAW5E"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.NativeLinkPreviewAction = NativeLinkPreviewAction;
|
|
5
|
-
exports.NativeLinkPreviewTrigger = NativeLinkPreviewTrigger;
|
|
6
5
|
exports.NativeLinkPreview = NativeLinkPreview;
|
|
7
6
|
exports.NativeLinkPreviewContent = NativeLinkPreviewContent;
|
|
8
7
|
const expo_1 = require("expo");
|
|
@@ -17,15 +16,6 @@ function NativeLinkPreviewAction(props) {
|
|
|
17
16
|
}
|
|
18
17
|
return <LinkPreviewNativeActionView {...props}/>;
|
|
19
18
|
}
|
|
20
|
-
const NativeLinkPreviewTriggerView = areNativeViewsAvailable
|
|
21
|
-
? (0, expo_1.requireNativeView)('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewTrigger')
|
|
22
|
-
: null;
|
|
23
|
-
function NativeLinkPreviewTrigger(props) {
|
|
24
|
-
if (!NativeLinkPreviewTriggerView) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return <NativeLinkPreviewTriggerView {...props}/>;
|
|
28
|
-
}
|
|
29
19
|
const NativeLinkPreviewView = areNativeViewsAvailable
|
|
30
20
|
? (0, expo_1.requireNativeView)('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewView')
|
|
31
21
|
: null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../../src/link/preview/native.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAgCb,0DAKC;
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../../src/link/preview/native.tsx"],"names":[],"mappings":";AAAA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C;IACH,OAAO,CAAC,4BAA4B,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAG,CAAC;AACnE,CAAC;AACD,aAAa","sourcesContent":["'use client';\n\nimport { requireNativeView } from 'expo';\nimport { Platform, StyleSheet, type ViewProps } from 'react-native';\n\nconst areNativeViewsAvailable =\n process.env.EXPO_OS === 'ios' && !Platform.isTV && global.RN$Bridgeless === true;\n\n// #region Action View\nexport interface NativeLinkPreviewActionProps {\n title: string;\n icon?: string;\n children?: React.ReactNode;\n disabled?: boolean;\n destructive?: boolean;\n // This may lead to race conditions, when two menu actions are on at the same time.\n // The logic should be enforced in the JS code, rather than in the native code.\n // singleSelection?: boolean;\n displayAsPalette?: boolean;\n displayInline?: boolean;\n isOn?: boolean;\n // There are issues with menu state updates when keep presented is set to true.\n // When updating the context menu state, it will either not update or it will recreate the menu. The latter is a problem,\n // because it will close all opened submenus and reset the scroll position.\n // TODO: (@ubax) find a way to fix this.\n keepPresented?: boolean;\n onSelected: () => void;\n}\nconst LinkPreviewNativeActionView: React.ComponentType<NativeLinkPreviewActionProps> | null =\n areNativeViewsAvailable\n ? requireNativeView('ExpoRouterNativeLinkPreview', 'LinkPreviewNativeActionView')\n : null;\nexport function NativeLinkPreviewAction(props: NativeLinkPreviewActionProps) {\n if (!LinkPreviewNativeActionView) {\n return null;\n }\n return <LinkPreviewNativeActionView {...props} />;\n}\n// #endregion\n\n// #region Preview View\nexport interface TabPath {\n oldTabKey: string;\n newTabKey: string;\n}\nexport interface NativeLinkPreviewProps extends ViewProps {\n nextScreenId: string | undefined;\n tabPath:\n | {\n path: TabPath[];\n }\n | undefined;\n onWillPreviewOpen?: () => void;\n onDidPreviewOpen?: () => void;\n onPreviewWillClose?: () => void;\n onPreviewDidClose?: () => void;\n onPreviewTapped?: () => void;\n onPreviewTappedAnimationCompleted?: () => void;\n children: React.ReactNode;\n}\nconst NativeLinkPreviewView: React.ComponentType<NativeLinkPreviewProps> | null =\n areNativeViewsAvailable\n ? requireNativeView('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewView')\n : null;\nexport function NativeLinkPreview(props: NativeLinkPreviewProps) {\n if (!NativeLinkPreviewView) {\n return null;\n }\n return <NativeLinkPreviewView {...props} />;\n}\n// #endregion\n\n// #region Preview Content View\nexport interface NativeLinkPreviewContentProps extends ViewProps {\n preferredContentSize?: { width: number; height: number };\n}\nconst NativeLinkPreviewContentView: React.ComponentType<NativeLinkPreviewContentProps> | null =\n areNativeViewsAvailable\n ? requireNativeView('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewContentView')\n : null;\n\nexport function NativeLinkPreviewContent(props: NativeLinkPreviewContentProps) {\n if (!NativeLinkPreviewContentView) {\n return null;\n }\n const style = StyleSheet.flatten([\n props.style,\n {\n position: 'absolute',\n } as const,\n ]);\n return <NativeLinkPreviewContentView {...props} style={style} />;\n}\n// #endregion\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabTrigger.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabTrigger.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EACV,wBAAwB,EAGxB,qBAAqB,EACtB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeTabTrigger.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabTrigger.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EACV,wBAAwB,EAGxB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAIjB,OAAO,EAKL,KAAK,SAAS,EAKf,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,iBAAS,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,QAsBzD;AAED,eAAO,MAAM,gBAAgB;;CAE3B,CAAC;AAEH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,eAAe,EACf,kBAAkB,GACnB,EAAE,qBAAqB,4BAiCvB;AAuBD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,KAAK,EAAE,SAAS,QA8BpF;AAiFD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,KAAK,IAAI,YAAY,CAAC,qBAAqB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA6BjE"}
|
|
@@ -9,6 +9,7 @@ const native_1 = require("@react-navigation/native");
|
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const NativeTabsTriggerTabBar_1 = require("./NativeTabsTriggerTabBar");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const PreviewRouteContext_1 = require("../../link/preview/PreviewRouteContext");
|
|
12
13
|
const useSafeLayoutEffect_1 = require("../../views/useSafeLayoutEffect");
|
|
13
14
|
const elements_1 = require("../common/elements");
|
|
14
15
|
/**
|
|
@@ -55,18 +56,19 @@ function NativeTabTriggerImpl(props) {
|
|
|
55
56
|
const route = (0, native_1.useRoute)();
|
|
56
57
|
const navigation = (0, native_1.useNavigation)();
|
|
57
58
|
const isFocused = navigation.isFocused();
|
|
59
|
+
const isInPreview = (0, PreviewRouteContext_1.useIsPreview)();
|
|
58
60
|
(0, useSafeLayoutEffect_1.useSafeLayoutEffect)(() => {
|
|
59
61
|
// This will cause the tab to update only when it is focused.
|
|
60
62
|
// As long as all tabs are loaded at the start, we don't need this check.
|
|
61
63
|
// It is here to ensure similar behavior to stack
|
|
62
|
-
if (isFocused) {
|
|
64
|
+
if (isFocused && !isInPreview) {
|
|
63
65
|
if (navigation.getState()?.type !== 'tab') {
|
|
64
66
|
throw new Error(`Trigger component can only be used in the tab screen. Current route: ${route.name}`);
|
|
65
67
|
}
|
|
66
68
|
const options = convertTabPropsToOptions(props);
|
|
67
69
|
navigation.setOptions(options);
|
|
68
70
|
}
|
|
69
|
-
}, [isFocused, props]);
|
|
71
|
+
}, [isFocused, props, isInPreview]);
|
|
70
72
|
return null;
|
|
71
73
|
}
|
|
72
74
|
exports.NativeTabTrigger = Object.assign(NativeTabTriggerImpl, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabTrigger.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabTrigger.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AA8Fb,4DAwCC;AAuBD,8CA8BC;AAiFD,gDAgCC;AA1SD,qDAAmE;AACnE,iCAA0E;AAG1E,uEAAoE;AAOpE,mCAAuE;AACvE,yEAAsE;AACtE,iDAU4B;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAS,oBAAoB,CAAC,KAA4B;IACxD,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;IACzB,MAAM,UAAU,GAAG,IAAA,sBAAa,GAAE,CAAC;IACnC,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IAEzC,IAAA,yCAAmB,EAAC,GAAG,EAAE;QACvB,6DAA6D;QAC7D,yEAAyE;QACzE,iDAAiD;QACjD,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,UAAU,CAAC,QAAQ,EAAE,EAAE,IAAI,KAAK,KAAK,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CACb,wEAAwE,KAAK,CAAC,IAAI,EAAE,CACrF,CAAC;YACJ,CAAC;YACD,MAAM,OAAO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,EAAE,CAAC;YAC1C,IACE,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,IAAI,CAChC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,GAAG,IAAI,KAAK,CAAC,KAAK,CAC9E,EACD,CAAC;gBACD,MAAM,IAAI,KAAK,CACb,uDAAuD,UAAU,0GAA0G,CAC5K,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["'use client';\n\nimport { useNavigation, useRoute } from '@react-navigation/native';\nimport { isValidElement, type ReactElement, type ReactNode } from 'react';\nimport type { ImageSourcePropType } from 'react-native';\n\nimport { NativeTabsTriggerTabBar } from './NativeTabsTriggerTabBar';\nimport type {\n ExtendedNativeTabOptions,\n NativeTabOptions,\n NativeTabsTriggerTabBarProps,\n NativeTabTriggerProps,\n} from './types';\nimport { filterAllowedChildrenElements, isChildOfType } from './utils';\nimport { useSafeLayoutEffect } from '../../views/useSafeLayoutEffect';\nimport {\n Icon,\n Badge,\n Label,\n type LabelProps,\n type IconProps,\n type BadgeProps,\n type SourceIconCombination,\n VectorIcon,\n type VectorIconProps,\n} from '../common/elements';\n\n/**\n * The component used to customize the native tab options both in the _layout file and from the tab screen.\n *\n * When used in the _layout file, you need to provide a `name` prop.\n * When used in the tab screen, the `name` prop takes no effect.\n *\n * @example\n * ```tsx\n * // In _layout file\n * import { NativeTabs } from 'expo-router/unstable-native-tabs';\n *\n * export default function Layout() {\n * return (\n * <NativeTabs>\n * <NativeTabs.Trigger name=\"home\" />\n * <NativeTabs.Trigger name=\"settings\" />\n * </NativeTabs>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // In a tab screen\n * import { NativeTabs } from 'expo-router/unstable-native-tabs';\n *\n * export default function HomeScreen() {\n * return (\n * <View>\n * <NativeTabs.Trigger>\n * <Label>Home</Label>\n * </NativeTabs.Trigger>\n * <Text>This is home screen!</Text>\n * </View>\n * );\n * }\n * ```\n *\n * > **Note:** You can use the alias `NativeTabs.Trigger` for this component.\n */\nfunction NativeTabTriggerImpl(props: NativeTabTriggerProps) {\n const route = useRoute();\n const navigation = useNavigation();\n const isFocused = navigation.isFocused();\n\n useSafeLayoutEffect(() => {\n // This will cause the tab to update only when it is focused.\n // As long as all tabs are loaded at the start, we don't need this check.\n // It is here to ensure similar behavior to stack\n if (isFocused) {\n if (navigation.getState()?.type !== 'tab') {\n throw new Error(\n `Trigger component can only be used in the tab screen. Current route: ${route.name}`\n );\n }\n const options = convertTabPropsToOptions(props);\n navigation.setOptions(options);\n }\n }, [isFocused, props]);\n\n return null;\n}\n\nexport const NativeTabTrigger = Object.assign(NativeTabTriggerImpl, {\n TabBar: NativeTabsTriggerTabBar,\n});\n\nexport function convertTabPropsToOptions({\n options,\n hidden,\n children,\n role,\n disablePopToTop,\n disableScrollToTop,\n}: NativeTabTriggerProps) {\n const initialOptions: ExtendedNativeTabOptions = {\n ...options,\n hidden: !!hidden,\n specialEffects: {\n repeatedTabSelection: {\n popToRoot: !disablePopToTop,\n scrollToTop: !disableScrollToTop,\n },\n },\n role: role ?? options?.role,\n };\n const allowedChildren = filterAllowedChildrenElements(children, [\n Badge,\n Label,\n Icon,\n NativeTabsTriggerTabBar,\n ]);\n return allowedChildren.reduce<ExtendedNativeTabOptions>(\n (acc, child) => {\n if (isChildOfType(child, Badge)) {\n appendBadgeOptions(acc, child.props);\n } else if (isChildOfType(child, Label)) {\n appendLabelOptions(acc, child.props);\n } else if (isChildOfType(child, Icon)) {\n appendIconOptions(acc, child.props);\n } else if (isChildOfType(child, NativeTabsTriggerTabBar)) {\n appendTabBarOptions(acc, child.props);\n }\n return acc;\n },\n { ...initialOptions }\n );\n}\n\nfunction appendBadgeOptions(options: ExtendedNativeTabOptions, props: BadgeProps) {\n if (props.children) {\n options.badgeValue = String(props.children);\n options.selectedBadgeBackgroundColor = props.selectedBackgroundColor;\n } else if (!props.hidden) {\n // If no value is provided, we set it to a space to show the badge\n // Otherwise, the `react-native-screens` will interpret it as a hidden badge\n // https://github.com/software-mansion/react-native-screens/blob/b4358fd95dd0736fc54df6bb97f210dc89edf24c/ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm#L172\n options.badgeValue = ' ';\n }\n}\n\nfunction appendLabelOptions(options: ExtendedNativeTabOptions, props: LabelProps) {\n if (props.hidden) {\n options.title = '';\n } else {\n options.title = props.children;\n options.selectedLabelStyle = props.selectedStyle;\n }\n}\n\nexport function appendIconOptions(options: ExtendedNativeTabOptions, props: IconProps) {\n if ('src' in props && props.src) {\n const icon = convertIconSrcToIconOption(props);\n options.icon = icon?.icon;\n options.selectedIcon = icon?.selectedIcon;\n } else if ('sf' in props && process.env.EXPO_OS === 'ios') {\n if (typeof props.sf === 'string') {\n options.icon = props.sf\n ? {\n sf: props.sf,\n }\n : undefined;\n options.selectedIcon = undefined;\n } else if (props.sf) {\n options.icon = props.sf.default\n ? {\n sf: props.sf.default,\n }\n : undefined;\n options.selectedIcon = props.sf.selected\n ? {\n sf: props.sf.selected,\n }\n : undefined;\n }\n } else if ('drawable' in props && process.env.EXPO_OS === 'android') {\n options.icon = { drawable: props.drawable };\n options.selectedIcon = undefined;\n }\n options.selectedIconColor = props.selectedColor;\n}\n\nfunction convertIconSrcToIconOption(\n icon: SourceIconCombination | undefined\n): Pick<NativeTabOptions, 'icon' | 'selectedIcon'> | undefined {\n if (icon && icon.src) {\n const { defaultIcon, selected } =\n typeof icon.src === 'object' && 'selected' in icon.src\n ? { defaultIcon: icon.src.default, selected: icon.src.selected }\n : { defaultIcon: icon.src };\n\n const options: Pick<NativeTabOptions, 'icon' | 'selectedIcon'> = {};\n options.icon = convertSrcOrComponentToSrc(defaultIcon);\n options.selectedIcon = convertSrcOrComponentToSrc(selected);\n return options;\n }\n\n return undefined;\n}\n\nfunction convertSrcOrComponentToSrc(src: ImageSourcePropType | ReactElement | undefined) {\n if (src) {\n if (isValidElement(src)) {\n if (src.type === VectorIcon) {\n const props = src.props as VectorIconProps<string>;\n return { src: props.family.getImageSource(props.name, 24, 'white') };\n } else {\n console.warn('Only VectorIcon is supported as a React element in Icon.src');\n }\n } else {\n return { src };\n }\n }\n return undefined;\n}\n\nfunction appendTabBarOptions(\n options: ExtendedNativeTabOptions,\n props: NativeTabsTriggerTabBarProps\n) {\n const {\n backgroundColor,\n blurEffect,\n iconColor,\n disableTransparentOnScrollEdge,\n badgeBackgroundColor,\n badgeTextColor,\n indicatorColor,\n labelStyle,\n } = props;\n\n if (backgroundColor) {\n options.backgroundColor = backgroundColor;\n }\n // We need better native integration of this on Android\n // Simulating from JS side creates ugly transitions\n if (process.env.EXPO_OS !== 'android') {\n if (blurEffect) {\n options.blurEffect = blurEffect;\n }\n if (iconColor) {\n options.iconColor = iconColor;\n }\n if (disableTransparentOnScrollEdge !== undefined) {\n options.disableTransparentOnScrollEdge = disableTransparentOnScrollEdge;\n }\n if (badgeBackgroundColor) {\n options.badgeBackgroundColor = badgeBackgroundColor;\n }\n if (badgeTextColor) {\n options.badgeTextColor = badgeTextColor;\n }\n if (indicatorColor) {\n options.indicatorColor = indicatorColor;\n }\n if (labelStyle) {\n options.labelStyle = labelStyle;\n }\n }\n}\n\nexport function isNativeTabTrigger(\n child: ReactNode,\n contextKey?: string\n): child is ReactElement<NativeTabTriggerProps & { name: string }> {\n if (isValidElement(child) && child && child.type === NativeTabTrigger) {\n if (\n typeof child.props === 'object' &&\n child.props &&\n 'name' in child.props &&\n !child.props.name\n ) {\n throw new Error(\n `<Trigger /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must have a \\`name\\` prop when used as a child of a Layout Route.`\n );\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (\n ['component', 'getComponent'].some(\n (key) => child.props && typeof child.props === 'object' && key in child.props\n )\n ) {\n throw new Error(\n `<Trigger /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must not have a \\`component\\` or \\`getComponent\\` prop when used as a child of a Layout Route`\n );\n }\n }\n\n return true;\n }\n\n return false;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NativeTabTrigger.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabTrigger.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAgGb,4DAwCC;AAuBD,8CA8BC;AAiFD,gDAgCC;AA5SD,qDAAmE;AACnE,iCAA0E;AAG1E,uEAAoE;AAOpE,mCAAuE;AACvE,gFAAsE;AACtE,yEAAsE;AACtE,iDAU4B;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAS,oBAAoB,CAAC,KAA4B;IACxD,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;IACzB,MAAM,UAAU,GAAG,IAAA,sBAAa,GAAE,CAAC;IACnC,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IACzC,MAAM,WAAW,GAAG,IAAA,kCAAY,GAAE,CAAC;IAEnC,IAAA,yCAAmB,EAAC,GAAG,EAAE;QACvB,6DAA6D;QAC7D,yEAAyE;QACzE,iDAAiD;QACjD,IAAI,SAAS,IAAI,CAAC,WAAW,EAAE,CAAC;YAC9B,IAAI,UAAU,CAAC,QAAQ,EAAE,EAAE,IAAI,KAAK,KAAK,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CACb,wEAAwE,KAAK,CAAC,IAAI,EAAE,CACrF,CAAC;YACJ,CAAC;YACD,MAAM,OAAO,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;YAChD,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAEpC,OAAO,IAAI,CAAC;AACd,CAAC;AAEY,QAAA,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE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AU,0GAA0G,CAC5K,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["'use client';\n\nimport { useNavigation, useRoute } from '@react-navigation/native';\nimport { isValidElement, type ReactElement, type ReactNode } from 'react';\nimport type { ImageSourcePropType } from 'react-native';\n\nimport { NativeTabsTriggerTabBar } from './NativeTabsTriggerTabBar';\nimport type {\n ExtendedNativeTabOptions,\n NativeTabOptions,\n NativeTabsTriggerTabBarProps,\n NativeTabTriggerProps,\n} from './types';\nimport { filterAllowedChildrenElements, isChildOfType } from './utils';\nimport { useIsPreview } from '../../link/preview/PreviewRouteContext';\nimport { useSafeLayoutEffect } from '../../views/useSafeLayoutEffect';\nimport {\n Icon,\n Badge,\n Label,\n type LabelProps,\n type IconProps,\n type BadgeProps,\n type SourceIconCombination,\n VectorIcon,\n type VectorIconProps,\n} from '../common/elements';\n\n/**\n * The component used to customize the native tab options both in the _layout file and from the tab screen.\n *\n * When used in the _layout file, you need to provide a `name` prop.\n * When used in the tab screen, the `name` prop takes no effect.\n *\n * @example\n * ```tsx\n * // In _layout file\n * import { NativeTabs } from 'expo-router/unstable-native-tabs';\n *\n * export default function Layout() {\n * return (\n * <NativeTabs>\n * <NativeTabs.Trigger name=\"home\" />\n * <NativeTabs.Trigger name=\"settings\" />\n * </NativeTabs>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // In a tab screen\n * import { NativeTabs } from 'expo-router/unstable-native-tabs';\n *\n * export default function HomeScreen() {\n * return (\n * <View>\n * <NativeTabs.Trigger>\n * <Label>Home</Label>\n * </NativeTabs.Trigger>\n * <Text>This is home screen!</Text>\n * </View>\n * );\n * }\n * ```\n *\n * > **Note:** You can use the alias `NativeTabs.Trigger` for this component.\n */\nfunction NativeTabTriggerImpl(props: NativeTabTriggerProps) {\n const route = useRoute();\n const navigation = useNavigation();\n const isFocused = navigation.isFocused();\n const isInPreview = useIsPreview();\n\n useSafeLayoutEffect(() => {\n // This will cause the tab to update only when it is focused.\n // As long as all tabs are loaded at the start, we don't need this check.\n // It is here to ensure similar behavior to stack\n if (isFocused && !isInPreview) {\n if (navigation.getState()?.type !== 'tab') {\n throw new Error(\n `Trigger component can only be used in the tab screen. Current route: ${route.name}`\n );\n }\n const options = convertTabPropsToOptions(props);\n navigation.setOptions(options);\n }\n }, [isFocused, props, isInPreview]);\n\n return null;\n}\n\nexport const NativeTabTrigger = Object.assign(NativeTabTriggerImpl, {\n TabBar: NativeTabsTriggerTabBar,\n});\n\nexport function convertTabPropsToOptions({\n options,\n hidden,\n children,\n role,\n disablePopToTop,\n disableScrollToTop,\n}: NativeTabTriggerProps) {\n const initialOptions: ExtendedNativeTabOptions = {\n ...options,\n hidden: !!hidden,\n specialEffects: {\n repeatedTabSelection: {\n popToRoot: !disablePopToTop,\n scrollToTop: !disableScrollToTop,\n },\n },\n role: role ?? options?.role,\n };\n const allowedChildren = filterAllowedChildrenElements(children, [\n Badge,\n Label,\n Icon,\n NativeTabsTriggerTabBar,\n ]);\n return allowedChildren.reduce<ExtendedNativeTabOptions>(\n (acc, child) => {\n if (isChildOfType(child, Badge)) {\n appendBadgeOptions(acc, child.props);\n } else if (isChildOfType(child, Label)) {\n appendLabelOptions(acc, child.props);\n } else if (isChildOfType(child, Icon)) {\n appendIconOptions(acc, child.props);\n } else if (isChildOfType(child, NativeTabsTriggerTabBar)) {\n appendTabBarOptions(acc, child.props);\n }\n return acc;\n },\n { ...initialOptions }\n );\n}\n\nfunction appendBadgeOptions(options: ExtendedNativeTabOptions, props: BadgeProps) {\n if (props.children) {\n options.badgeValue = String(props.children);\n options.selectedBadgeBackgroundColor = props.selectedBackgroundColor;\n } else if (!props.hidden) {\n // If no value is provided, we set it to a space to show the badge\n // Otherwise, the `react-native-screens` will interpret it as a hidden badge\n // https://github.com/software-mansion/react-native-screens/blob/b4358fd95dd0736fc54df6bb97f210dc89edf24c/ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm#L172\n options.badgeValue = ' ';\n }\n}\n\nfunction appendLabelOptions(options: ExtendedNativeTabOptions, props: LabelProps) {\n if (props.hidden) {\n options.title = '';\n } else {\n options.title = props.children;\n options.selectedLabelStyle = props.selectedStyle;\n }\n}\n\nexport function appendIconOptions(options: ExtendedNativeTabOptions, props: IconProps) {\n if ('src' in props && props.src) {\n const icon = convertIconSrcToIconOption(props);\n options.icon = icon?.icon;\n options.selectedIcon = icon?.selectedIcon;\n } else if ('sf' in props && process.env.EXPO_OS === 'ios') {\n if (typeof props.sf === 'string') {\n options.icon = props.sf\n ? {\n sf: props.sf,\n }\n : undefined;\n options.selectedIcon = undefined;\n } else if (props.sf) {\n options.icon = props.sf.default\n ? {\n sf: props.sf.default,\n }\n : undefined;\n options.selectedIcon = props.sf.selected\n ? {\n sf: props.sf.selected,\n }\n : undefined;\n }\n } else if ('drawable' in props && process.env.EXPO_OS === 'android') {\n options.icon = { drawable: props.drawable };\n options.selectedIcon = undefined;\n }\n options.selectedIconColor = props.selectedColor;\n}\n\nfunction convertIconSrcToIconOption(\n icon: SourceIconCombination | undefined\n): Pick<NativeTabOptions, 'icon' | 'selectedIcon'> | undefined {\n if (icon && icon.src) {\n const { defaultIcon, selected } =\n typeof icon.src === 'object' && 'selected' in icon.src\n ? { defaultIcon: icon.src.default, selected: icon.src.selected }\n : { defaultIcon: icon.src };\n\n const options: Pick<NativeTabOptions, 'icon' | 'selectedIcon'> = {};\n options.icon = convertSrcOrComponentToSrc(defaultIcon);\n options.selectedIcon = convertSrcOrComponentToSrc(selected);\n return options;\n }\n\n return undefined;\n}\n\nfunction convertSrcOrComponentToSrc(src: ImageSourcePropType | ReactElement | undefined) {\n if (src) {\n if (isValidElement(src)) {\n if (src.type === VectorIcon) {\n const props = src.props as VectorIconProps<string>;\n return { src: props.family.getImageSource(props.name, 24, 'white') };\n } else {\n console.warn('Only VectorIcon is supported as a React element in Icon.src');\n }\n } else {\n return { src };\n }\n }\n return undefined;\n}\n\nfunction appendTabBarOptions(\n options: ExtendedNativeTabOptions,\n props: NativeTabsTriggerTabBarProps\n) {\n const {\n backgroundColor,\n blurEffect,\n iconColor,\n disableTransparentOnScrollEdge,\n badgeBackgroundColor,\n badgeTextColor,\n indicatorColor,\n labelStyle,\n } = props;\n\n if (backgroundColor) {\n options.backgroundColor = backgroundColor;\n }\n // We need better native integration of this on Android\n // Simulating from JS side creates ugly transitions\n if (process.env.EXPO_OS !== 'android') {\n if (blurEffect) {\n options.blurEffect = blurEffect;\n }\n if (iconColor) {\n options.iconColor = iconColor;\n }\n if (disableTransparentOnScrollEdge !== undefined) {\n options.disableTransparentOnScrollEdge = disableTransparentOnScrollEdge;\n }\n if (badgeBackgroundColor) {\n options.badgeBackgroundColor = badgeBackgroundColor;\n }\n if (badgeTextColor) {\n options.badgeTextColor = badgeTextColor;\n }\n if (indicatorColor) {\n options.indicatorColor = indicatorColor;\n }\n if (labelStyle) {\n options.labelStyle = labelStyle;\n }\n }\n}\n\nexport function isNativeTabTrigger(\n child: ReactNode,\n contextKey?: string\n): child is ReactElement<NativeTabTriggerProps & { name: string }> {\n if (isValidElement(child) && child && child.type === NativeTabTrigger) {\n if (\n typeof child.props === 'object' &&\n child.props &&\n 'name' in child.props &&\n !child.props.name\n ) {\n throw new Error(\n `<Trigger /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must have a \\`name\\` prop when used as a child of a Layout Route.`\n );\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (\n ['component', 'getComponent'].some(\n (key) => child.props && typeof child.props === 'object' && key in child.props\n )\n ) {\n throw new Error(\n `<Trigger /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must not have a \\`component\\` or \\`getComponent\\` prop when used as a child of a Layout Route`\n );\n }\n }\n\n return true;\n }\n\n return false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabsView.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAkB9E,OAAO,
|
|
1
|
+
{"version":3,"file":"NativeTabsView.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAkB9E,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,SAAS,CAAC;AAOjB,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBAwIxD"}
|
|
@@ -110,34 +110,16 @@ function NativeTabsView(props) {
|
|
|
110
110
|
{children}
|
|
111
111
|
</BottomTabsWrapper>);
|
|
112
112
|
}
|
|
113
|
-
// TODO: remove after fix is merged in screens
|
|
114
|
-
const rolesIcons = {
|
|
115
|
-
bookmarks: 'book.fill',
|
|
116
|
-
contacts: 'person.crop.circle.fill',
|
|
117
|
-
downloads: 'square.and.arrow.down.fill',
|
|
118
|
-
favorites: 'star.fill',
|
|
119
|
-
featured: 'star.fill',
|
|
120
|
-
history: 'clock.fill',
|
|
121
|
-
more: 'ellipsis',
|
|
122
|
-
mostRecent: 'clock.fill',
|
|
123
|
-
mostViewed: 'list.number',
|
|
124
|
-
recents: 'clock.fill',
|
|
125
|
-
search: 'magnifyingglass',
|
|
126
|
-
topRated: 'star.fill',
|
|
127
|
-
};
|
|
128
113
|
function Screen(props) {
|
|
129
114
|
const { routeKey, name, descriptor, isFocused, standardAppearance, scrollEdgeAppearance, badgeTextColor, } = props;
|
|
115
|
+
const role = descriptor.options.role;
|
|
116
|
+
// To align with apple documentation and prevent untested cases,
|
|
117
|
+
// title and icon cannot be changed when role is defined
|
|
118
|
+
const shouldResetTitleAndIcon = !!role && process.env.EXPO_OS === 'ios';
|
|
130
119
|
const title = descriptor.options.title ?? name;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (descriptor.options.role) {
|
|
135
|
-
if (descriptor.options.role && descriptor.options.role in rolesIcons) {
|
|
136
|
-
icon = { sf: rolesIcons[descriptor.options.role] };
|
|
137
|
-
selectedIcon = icon;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return (<react_native_screens_1.BottomTabsScreen {...descriptor.options} tabBarItemBadgeBackgroundColor={standardAppearance.stacked?.normal?.tabBarItemBadgeBackgroundColor} tabBarItemBadgeTextColor={badgeTextColor} standardAppearance={standardAppearance} scrollEdgeAppearance={scrollEdgeAppearance} iconResourceName={getAndroidIconResourceName(icon)} iconResource={getAndroidIconResource(icon)} icon={convertOptionsIconToPropsIcon(icon)} selectedIcon={convertOptionsIconToPropsIcon(selectedIcon)} title={title} freezeContents={false} tabKey={routeKey} systemItem={descriptor.options.role} isFocused={isFocused}>
|
|
120
|
+
const icon = useAwaitedScreensIcon(descriptor.options.icon);
|
|
121
|
+
const selectedIcon = useAwaitedScreensIcon(descriptor.options.selectedIcon);
|
|
122
|
+
return (<react_native_screens_1.BottomTabsScreen {...descriptor.options} tabBarItemBadgeBackgroundColor={standardAppearance.stacked?.normal?.tabBarItemBadgeBackgroundColor} tabBarItemBadgeTextColor={badgeTextColor} standardAppearance={standardAppearance} scrollEdgeAppearance={scrollEdgeAppearance} iconResourceName={getAndroidIconResourceName(icon)} iconResource={getAndroidIconResource(icon)} icon={shouldResetTitleAndIcon ? undefined : convertOptionsIconToPropsIcon(icon)} selectedIcon={shouldResetTitleAndIcon ? undefined : convertOptionsIconToPropsIcon(selectedIcon)} title={shouldResetTitleAndIcon ? undefined : title} freezeContents={false} tabKey={routeKey} systemItem={descriptor.options.role} isFocused={isFocused}>
|
|
141
123
|
{descriptor.render()}
|
|
142
124
|
</react_native_screens_1.BottomTabsScreen>);
|
|
143
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabsView.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAC9C,CAAC;AAEF,SAAS,iBAAiB,CAAC,KAAsB;IAC/C,IAAI,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC/E,IAAI,sBAAsB,IAAI,CAAC,mCAAmC,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC/F,OAAO,CAAC,IAAI,CACV,iCAAiC,sBAAsB,2BAA2B,4CAAoC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvK,CAAC;QACF,sBAAsB,GAAG,SAAS,CAAC;IACrC,CAAC;IACD,IACE,6BAA6B;QAC7B,CAAC,0CAA0C,CAAC,GAAG,CAAC,6BAA6B,CAAC,EAC9E,CAAC;QACD,OAAO,CAAC,IAAI,CACV,oCAAoC,6BAA6B,2BAA2B,qDAA6C,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClL,CAAC;QACF,6BAA6B,GAAG,SAAS,CAAC;IAC5C,CAAC;IAED,OAAO,CACL,CAAC,iCAAU,CACT,6BAA6B,CAAC,CAAC,6BAA6B,CAAC,CAC7D,sBAAsB,CAAC,CAAC,sBAAsB,CAAC,CAC/C,IAAI,IAAI,CAAC,EACT,CACH,CAAC;AACJ,CAAC","sourcesContent":["import React, { useDeferredValue, useEffect, useMemo, useState } from 'react';\nimport type { ColorValue, ImageSourcePropType } from 'react-native';\nimport {\n BottomTabs,\n BottomTabsScreen,\n featureFlags,\n type BottomTabsProps,\n type BottomTabsScreenAppearance,\n type BottomTabsScreenProps,\n} from 'react-native-screens';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport {\n appendSelectedStyleToAppearance,\n convertStyleToAppearance,\n createScrollEdgeAppearanceFromOptions,\n createStandardAppearanceFromOptions,\n} from './appearance';\nimport {\n SUPPORTED_TAB_BAR_ITEM_LABEL_VISIBILITY_MODES,\n SUPPORTED_TAB_BAR_MINIMIZE_BEHAVIORS,\n type NativeTabOptions,\n type NativeTabsTabBarItemRole,\n type NativeTabsViewProps,\n} from './types';\nimport { shouldTabBeVisible } from './utils';\n\n// We let native tabs to control the changes. This requires freeze to be disabled for tab bar.\n// Otherwise user may see glitches when switching between tabs.\nfeatureFlags.experiment.controlledBottomTabs = false;\n\nexport function NativeTabsView(props: NativeTabsViewProps) {\n const {\n builder,\n minimizeBehavior,\n disableIndicator,\n focusedIndex,\n disableTransparentOnScrollEdge,\n } = props;\n const { state, descriptors, navigation } = builder;\n const { routes } = state;\n\n const deferredFocusedIndex = useDeferredValue(focusedIndex);\n let standardAppearance = convertStyleToAppearance({\n ...props.labelStyle,\n iconColor: props.iconColor,\n blurEffect: props.blurEffect,\n backgroundColor: props.backgroundColor,\n badgeBackgroundColor: props.badgeBackgroundColor,\n });\n if (props.tintColor) {\n standardAppearance = appendSelectedStyleToAppearance(\n { iconColor: props.tintColor, color: props.tintColor },\n standardAppearance\n );\n }\n const scrollEdgeAppearance = convertStyleToAppearance({\n ...props.labelStyle,\n iconColor: props.iconColor,\n blurEffect: disableTransparentOnScrollEdge ? props.blurEffect : 'none',\n backgroundColor: disableTransparentOnScrollEdge ? props.backgroundColor : null,\n badgeBackgroundColor: props.badgeBackgroundColor,\n });\n\n const appearances = routes.map((route) => ({\n standardAppearance: createStandardAppearanceFromOptions(\n descriptors[route.key].options,\n standardAppearance\n ),\n scrollEdgeAppearance: createScrollEdgeAppearanceFromOptions(\n descriptors[route.key].options,\n scrollEdgeAppearance\n ),\n }));\n\n const options = routes.map((route) => descriptors[route.key].options);\n\n const children = routes\n .map((route, index) => ({ route, index }))\n .filter(({ route: { key } }) => shouldTabBeVisible(descriptors[key].options))\n .map(({ route, index }) => {\n const descriptor = descriptors[route.key];\n const isFocused = index === deferredFocusedIndex;\n\n return (\n <Screen\n key={route.key}\n routeKey={route.key}\n name={route.name}\n descriptor={descriptor}\n isFocused={isFocused}\n standardAppearance={appearances[index].standardAppearance}\n scrollEdgeAppearance={appearances[index].scrollEdgeAppearance}\n badgeTextColor={props.badgeTextColor}\n />\n );\n });\n\n return (\n <BottomTabsWrapper\n // #region android props\n tabBarItemTitleFontColor={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontColor\n }\n tabBarItemTitleFontFamily={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontFamily\n }\n tabBarItemTitleFontSize={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontSize\n }\n tabBarItemTitleFontSizeActive={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontSize\n }\n tabBarItemTitleFontWeight={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontWeight\n }\n tabBarItemTitleFontStyle={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontStyle\n }\n tabBarItemIconColor={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal?.tabBarItemIconColor\n }\n tabBarBackgroundColor={\n appearances[deferredFocusedIndex].standardAppearance.tabBarBackgroundColor ??\n props.backgroundColor ??\n undefined\n }\n tabBarItemRippleColor={props.rippleColor}\n tabBarItemLabelVisibilityMode={props.labelVisibilityMode}\n tabBarItemIconColorActive={\n appearances[deferredFocusedIndex].standardAppearance?.stacked?.selected\n ?.tabBarItemIconColor ?? props?.tintColor\n }\n tabBarItemTitleFontColorActive={\n appearances[deferredFocusedIndex].standardAppearance?.stacked?.selected\n ?.tabBarItemTitleFontColor ?? props?.tintColor\n }\n // tabBarItemTitleFontSizeActive={activeStyle?.fontSize}\n tabBarItemActiveIndicatorColor={\n options[deferredFocusedIndex]?.indicatorColor ?? props?.indicatorColor\n }\n tabBarItemActiveIndicatorEnabled={!disableIndicator}\n // #endregion\n // #region iOS props\n tabBarTintColor={props?.tintColor}\n tabBarMinimizeBehavior={minimizeBehavior}\n // #endregion\n onNativeFocusChange={({ nativeEvent: { tabKey } }) => {\n const descriptor = descriptors[tabKey];\n const route = descriptor.route;\n navigation.dispatch({\n type: 'JUMP_TO',\n target: state.key,\n payload: {\n name: route.name,\n },\n });\n }}>\n {children}\n </BottomTabsWrapper>\n );\n}\n\n// TODO: remove after fix is merged in screens\nconst rolesIcons: Record<NativeTabsTabBarItemRole, SFSymbol> = {\n bookmarks: 'book.fill',\n contacts: 'person.crop.circle.fill',\n downloads: 'square.and.arrow.down.fill',\n favorites: 'star.fill',\n featured: 'star.fill',\n history: 'clock.fill',\n more: 'ellipsis',\n mostRecent: 'clock.fill',\n mostViewed: 'list.number',\n recents: 'clock.fill',\n search: 'magnifyingglass',\n topRated: 'star.fill',\n};\n\nfunction Screen(props: {\n routeKey: string;\n name: string;\n descriptor: NativeTabsViewProps['builder']['descriptors'][string];\n isFocused: boolean;\n standardAppearance: BottomTabsScreenAppearance;\n scrollEdgeAppearance: BottomTabsScreenAppearance;\n badgeTextColor: ColorValue | undefined;\n}) {\n const {\n routeKey,\n name,\n descriptor,\n isFocused,\n standardAppearance,\n scrollEdgeAppearance,\n badgeTextColor,\n } = props;\n const title = descriptor.options.title ?? name;\n\n let icon = useAwaitedScreensIcon(descriptor.options.icon);\n let selectedIcon = useAwaitedScreensIcon(descriptor.options.selectedIcon);\n\n // Fix for an issue in screens\n if (descriptor.options.role) {\n if (descriptor.options.role && descriptor.options.role in rolesIcons) {\n icon = { sf: rolesIcons[descriptor.options.role] };\n selectedIcon = icon;\n }\n }\n\n return (\n <BottomTabsScreen\n {...descriptor.options}\n tabBarItemBadgeBackgroundColor={\n standardAppearance.stacked?.normal?.tabBarItemBadgeBackgroundColor\n }\n tabBarItemBadgeTextColor={badgeTextColor}\n standardAppearance={standardAppearance}\n scrollEdgeAppearance={scrollEdgeAppearance}\n iconResourceName={getAndroidIconResourceName(icon)}\n iconResource={getAndroidIconResource(icon)}\n icon={convertOptionsIconToPropsIcon(icon)}\n selectedIcon={convertOptionsIconToPropsIcon(selectedIcon)}\n title={title}\n freezeContents={false}\n tabKey={routeKey}\n systemItem={descriptor.options.role}\n isFocused={isFocused}>\n {descriptor.render()}\n </BottomTabsScreen>\n );\n}\n\ntype AwaitedIcon =\n | {\n sf?: SFSymbol;\n drawable?: string;\n }\n | {\n src?: ImageSourcePropType;\n };\n\nfunction useAwaitedScreensIcon(icon: NativeTabOptions['icon']) {\n const src = icon && typeof icon === 'object' && 'src' in icon ? icon.src : undefined;\n const [awaitedIcon, setAwaitedIcon] = useState<AwaitedIcon | undefined>(undefined);\n\n useEffect(() => {\n const loadIcon = async () => {\n if (src && src instanceof Promise) {\n const currentAwaitedIcon = { src: await src };\n setAwaitedIcon(currentAwaitedIcon);\n }\n };\n loadIcon();\n // Checking `src` rather then icon here, to avoid unnecessary re-renders\n // The icon object can be recreated, while src should stay the same\n // In this case as we control `VectorIcon`, it will only change if `family` or `name` props change\n // So we should be safe with promise resolving\n }, [src]);\n\n return useMemo(() => (isAwaitedIcon(icon) ? icon : awaitedIcon), [awaitedIcon, icon]);\n}\n\nfunction isAwaitedIcon(icon: NativeTabOptions['icon']): icon is AwaitedIcon {\n return !icon || !('src' in icon && icon.src instanceof Promise);\n}\n\nfunction convertOptionsIconToPropsIcon(\n icon: AwaitedIcon | undefined\n): BottomTabsScreenProps['icon'] {\n if (!icon) {\n return undefined;\n }\n if ('sf' in icon && icon.sf) {\n return { sfSymbolName: icon.sf };\n } else if ('src' in icon && icon.src) {\n return { templateSource: icon.src };\n }\n return undefined;\n}\n\nfunction getAndroidIconResource(\n icon: AwaitedIcon | undefined\n): BottomTabsScreenProps['iconResource'] {\n if (icon && 'src' in icon && icon.src) {\n return icon.src;\n }\n return undefined;\n}\n\nfunction getAndroidIconResourceName(\n icon: AwaitedIcon | undefined\n): BottomTabsScreenProps['iconResourceName'] {\n if (icon && 'drawable' in icon && icon.drawable) {\n return icon.drawable;\n }\n return undefined;\n}\n\nconst supportedTabBarMinimizeBehaviorsSet = new Set<string>(SUPPORTED_TAB_BAR_MINIMIZE_BEHAVIORS);\nconst supportedTabBarItemLabelVisibilityModesSet = new Set<string>(\n SUPPORTED_TAB_BAR_ITEM_LABEL_VISIBILITY_MODES\n);\n\nfunction BottomTabsWrapper(props: BottomTabsProps) {\n let { tabBarMinimizeBehavior, tabBarItemLabelVisibilityMode, ...rest } = props;\n if (tabBarMinimizeBehavior && !supportedTabBarMinimizeBehaviorsSet.has(tabBarMinimizeBehavior)) {\n console.warn(\n `Unsupported minimizeBehavior: ${tabBarMinimizeBehavior}. Supported values are: ${SUPPORTED_TAB_BAR_MINIMIZE_BEHAVIORS.map((behavior) => `\"${behavior}\"`).join(', ')}`\n );\n tabBarMinimizeBehavior = undefined;\n }\n if (\n tabBarItemLabelVisibilityMode &&\n !supportedTabBarItemLabelVisibilityModesSet.has(tabBarItemLabelVisibilityMode)\n ) {\n console.warn(\n `Unsupported labelVisibilityMode: ${tabBarItemLabelVisibilityMode}. Supported values are: ${SUPPORTED_TAB_BAR_ITEM_LABEL_VISIBILITY_MODES.map((mode) => `\"${mode}\"`).join(', ')}`\n );\n tabBarItemLabelVisibilityMode = undefined;\n }\n\n return (\n <BottomTabs\n tabBarItemLabelVisibilityMode={tabBarItemLabelVisibilityMode}\n tabBarMinimizeBehavior={tabBarMinimizeBehavior}\n {...rest}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NativeTabsView.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,wCAwIC;AAtKD,+CAA8E;AAE9E,+DAO8B;AAG9B,6CAKsB;AACtB,mCAKiB;AACjB,mCAA6C;AAE7C,8FAA8F;AAC9F,+DAA+D;AAC/D,mCAAY,CAAC,UAAU,CAAC,oBAAoB,G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,6BAA6B,CAAC,EAC9E,CAAC;QACD,OAAO,CAAC,IAAI,CACV,oCAAoC,6BAA6B,2BAA2B,qDAA6C,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClL,CAAC;QACF,6BAA6B,GAAG,SAAS,CAAC;IAC5C,CAAC;IAED,OAAO,CACL,CAAC,iCAAU,CACT,6BAA6B,CAAC,CAAC,6BAA6B,CAAC,CAC7D,sBAAsB,CAAC,CAAC,sBAAsB,CAAC,CAC/C,IAAI,IAAI,CAAC,EACT,CACH,CAAC;AACJ,CAAC","sourcesContent":["import React, { useDeferredValue, useEffect, useMemo, useState } from 'react';\nimport type { ColorValue, ImageSourcePropType } from 'react-native';\nimport {\n BottomTabs,\n BottomTabsScreen,\n featureFlags,\n type BottomTabsProps,\n type BottomTabsScreenAppearance,\n type BottomTabsScreenProps,\n} from 'react-native-screens';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport {\n appendSelectedStyleToAppearance,\n convertStyleToAppearance,\n createScrollEdgeAppearanceFromOptions,\n createStandardAppearanceFromOptions,\n} from './appearance';\nimport {\n SUPPORTED_TAB_BAR_ITEM_LABEL_VISIBILITY_MODES,\n SUPPORTED_TAB_BAR_MINIMIZE_BEHAVIORS,\n type NativeTabOptions,\n type NativeTabsViewProps,\n} from './types';\nimport { shouldTabBeVisible } from './utils';\n\n// We let native tabs to control the changes. This requires freeze to be disabled for tab bar.\n// Otherwise user may see glitches when switching between tabs.\nfeatureFlags.experiment.controlledBottomTabs = false;\n\nexport function NativeTabsView(props: NativeTabsViewProps) {\n const {\n builder,\n minimizeBehavior,\n disableIndicator,\n focusedIndex,\n disableTransparentOnScrollEdge,\n } = props;\n const { state, descriptors, navigation } = builder;\n const { routes } = state;\n\n const deferredFocusedIndex = useDeferredValue(focusedIndex);\n let standardAppearance = convertStyleToAppearance({\n ...props.labelStyle,\n iconColor: props.iconColor,\n blurEffect: props.blurEffect,\n backgroundColor: props.backgroundColor,\n badgeBackgroundColor: props.badgeBackgroundColor,\n });\n if (props.tintColor) {\n standardAppearance = appendSelectedStyleToAppearance(\n { iconColor: props.tintColor, color: props.tintColor },\n standardAppearance\n );\n }\n const scrollEdgeAppearance = convertStyleToAppearance({\n ...props.labelStyle,\n iconColor: props.iconColor,\n blurEffect: disableTransparentOnScrollEdge ? props.blurEffect : 'none',\n backgroundColor: disableTransparentOnScrollEdge ? props.backgroundColor : null,\n badgeBackgroundColor: props.badgeBackgroundColor,\n });\n\n const appearances = routes.map((route) => ({\n standardAppearance: createStandardAppearanceFromOptions(\n descriptors[route.key].options,\n standardAppearance\n ),\n scrollEdgeAppearance: createScrollEdgeAppearanceFromOptions(\n descriptors[route.key].options,\n scrollEdgeAppearance\n ),\n }));\n\n const options = routes.map((route) => descriptors[route.key].options);\n\n const children = routes\n .map((route, index) => ({ route, index }))\n .filter(({ route: { key } }) => shouldTabBeVisible(descriptors[key].options))\n .map(({ route, index }) => {\n const descriptor = descriptors[route.key];\n const isFocused = index === deferredFocusedIndex;\n\n return (\n <Screen\n key={route.key}\n routeKey={route.key}\n name={route.name}\n descriptor={descriptor}\n isFocused={isFocused}\n standardAppearance={appearances[index].standardAppearance}\n scrollEdgeAppearance={appearances[index].scrollEdgeAppearance}\n badgeTextColor={props.badgeTextColor}\n />\n );\n });\n\n return (\n <BottomTabsWrapper\n // #region android props\n tabBarItemTitleFontColor={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontColor\n }\n tabBarItemTitleFontFamily={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontFamily\n }\n tabBarItemTitleFontSize={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontSize\n }\n tabBarItemTitleFontSizeActive={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontSize\n }\n tabBarItemTitleFontWeight={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontWeight\n }\n tabBarItemTitleFontStyle={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal\n ?.tabBarItemTitleFontStyle\n }\n tabBarItemIconColor={\n appearances[deferredFocusedIndex].standardAppearance.stacked?.normal?.tabBarItemIconColor\n }\n tabBarBackgroundColor={\n appearances[deferredFocusedIndex].standardAppearance.tabBarBackgroundColor ??\n props.backgroundColor ??\n undefined\n }\n tabBarItemRippleColor={props.rippleColor}\n tabBarItemLabelVisibilityMode={props.labelVisibilityMode}\n tabBarItemIconColorActive={\n appearances[deferredFocusedIndex].standardAppearance?.stacked?.selected\n ?.tabBarItemIconColor ?? props?.tintColor\n }\n tabBarItemTitleFontColorActive={\n appearances[deferredFocusedIndex].standardAppearance?.stacked?.selected\n ?.tabBarItemTitleFontColor ?? props?.tintColor\n }\n // tabBarItemTitleFontSizeActive={activeStyle?.fontSize}\n tabBarItemActiveIndicatorColor={\n options[deferredFocusedIndex]?.indicatorColor ?? props?.indicatorColor\n }\n tabBarItemActiveIndicatorEnabled={!disableIndicator}\n // #endregion\n // #region iOS props\n tabBarTintColor={props?.tintColor}\n tabBarMinimizeBehavior={minimizeBehavior}\n // #endregion\n onNativeFocusChange={({ nativeEvent: { tabKey } }) => {\n const descriptor = descriptors[tabKey];\n const route = descriptor.route;\n navigation.dispatch({\n type: 'JUMP_TO',\n target: state.key,\n payload: {\n name: route.name,\n },\n });\n }}>\n {children}\n </BottomTabsWrapper>\n );\n}\n\nfunction Screen(props: {\n routeKey: string;\n name: string;\n descriptor: NativeTabsViewProps['builder']['descriptors'][string];\n isFocused: boolean;\n standardAppearance: BottomTabsScreenAppearance;\n scrollEdgeAppearance: BottomTabsScreenAppearance;\n badgeTextColor: ColorValue | undefined;\n}) {\n const {\n routeKey,\n name,\n descriptor,\n isFocused,\n standardAppearance,\n scrollEdgeAppearance,\n badgeTextColor,\n } = props;\n const role = descriptor.options.role;\n // To align with apple documentation and prevent untested cases,\n // title and icon cannot be changed when role is defined\n const shouldResetTitleAndIcon = !!role && process.env.EXPO_OS === 'ios';\n\n const title = descriptor.options.title ?? name;\n\n const icon = useAwaitedScreensIcon(descriptor.options.icon);\n const selectedIcon = useAwaitedScreensIcon(descriptor.options.selectedIcon);\n\n return (\n <BottomTabsScreen\n {...descriptor.options}\n tabBarItemBadgeBackgroundColor={\n standardAppearance.stacked?.normal?.tabBarItemBadgeBackgroundColor\n }\n tabBarItemBadgeTextColor={badgeTextColor}\n standardAppearance={standardAppearance}\n scrollEdgeAppearance={scrollEdgeAppearance}\n iconResourceName={getAndroidIconResourceName(icon)}\n iconResource={getAndroidIconResource(icon)}\n icon={shouldResetTitleAndIcon ? undefined : convertOptionsIconToPropsIcon(icon)}\n selectedIcon={\n shouldResetTitleAndIcon ? undefined : convertOptionsIconToPropsIcon(selectedIcon)\n }\n title={shouldResetTitleAndIcon ? undefined : title}\n freezeContents={false}\n tabKey={routeKey}\n systemItem={descriptor.options.role}\n isFocused={isFocused}>\n {descriptor.render()}\n </BottomTabsScreen>\n );\n}\n\ntype AwaitedIcon =\n | {\n sf?: SFSymbol;\n drawable?: string;\n }\n | {\n src?: ImageSourcePropType;\n };\n\nfunction useAwaitedScreensIcon(icon: NativeTabOptions['icon']) {\n const src = icon && typeof icon === 'object' && 'src' in icon ? icon.src : undefined;\n const [awaitedIcon, setAwaitedIcon] = useState<AwaitedIcon | undefined>(undefined);\n\n useEffect(() => {\n const loadIcon = async () => {\n if (src && src instanceof Promise) {\n const currentAwaitedIcon = { src: await src };\n setAwaitedIcon(currentAwaitedIcon);\n }\n };\n loadIcon();\n // Checking `src` rather then icon here, to avoid unnecessary re-renders\n // The icon object can be recreated, while src should stay the same\n // In this case as we control `VectorIcon`, it will only change if `family` or `name` props change\n // So we should be safe with promise resolving\n }, [src]);\n\n return useMemo(() => (isAwaitedIcon(icon) ? icon : awaitedIcon), [awaitedIcon, icon]);\n}\n\nfunction isAwaitedIcon(icon: NativeTabOptions['icon']): icon is AwaitedIcon {\n return !icon || !('src' in icon && icon.src instanceof Promise);\n}\n\nfunction convertOptionsIconToPropsIcon(\n icon: AwaitedIcon | undefined\n): BottomTabsScreenProps['icon'] {\n if (!icon) {\n return undefined;\n }\n if ('sf' in icon && icon.sf) {\n return { sfSymbolName: icon.sf };\n } else if ('src' in icon && icon.src) {\n return { templateSource: icon.src };\n }\n return undefined;\n}\n\nfunction getAndroidIconResource(\n icon: AwaitedIcon | undefined\n): BottomTabsScreenProps['iconResource'] {\n if (icon && 'src' in icon && icon.src) {\n return icon.src;\n }\n return undefined;\n}\n\nfunction getAndroidIconResourceName(\n icon: AwaitedIcon | undefined\n): BottomTabsScreenProps['iconResourceName'] {\n if (icon && 'drawable' in icon && icon.drawable) {\n return icon.drawable;\n }\n return undefined;\n}\n\nconst supportedTabBarMinimizeBehaviorsSet = new Set<string>(SUPPORTED_TAB_BAR_MINIMIZE_BEHAVIORS);\nconst supportedTabBarItemLabelVisibilityModesSet = new Set<string>(\n SUPPORTED_TAB_BAR_ITEM_LABEL_VISIBILITY_MODES\n);\n\nfunction BottomTabsWrapper(props: BottomTabsProps) {\n let { tabBarMinimizeBehavior, tabBarItemLabelVisibilityMode, ...rest } = props;\n if (tabBarMinimizeBehavior && !supportedTabBarMinimizeBehaviorsSet.has(tabBarMinimizeBehavior)) {\n console.warn(\n `Unsupported minimizeBehavior: ${tabBarMinimizeBehavior}. Supported values are: ${SUPPORTED_TAB_BAR_MINIMIZE_BEHAVIORS.map((behavior) => `\"${behavior}\"`).join(', ')}`\n );\n tabBarMinimizeBehavior = undefined;\n }\n if (\n tabBarItemLabelVisibilityMode &&\n !supportedTabBarItemLabelVisibilityModesSet.has(tabBarItemLabelVisibilityMode)\n ) {\n console.warn(\n `Unsupported labelVisibilityMode: ${tabBarItemLabelVisibilityMode}. Supported values are: ${SUPPORTED_TAB_BAR_ITEM_LABEL_VISIBILITY_MODES.map((mode) => `\"${mode}\"`).join(', ')}`\n );\n tabBarItemLabelVisibilityMode = undefined;\n }\n\n return (\n <BottomTabs\n tabBarItemLabelVisibilityMode={tabBarItemLabelVisibilityMode}\n tabBarMinimizeBehavior={tabBarMinimizeBehavior}\n {...rest}\n />\n );\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { RequireContext } from '../types';
|
|
|
2
2
|
export type GetTypedRoutesDeclarationFileOptions = {
|
|
3
3
|
partialTypedGroups?: boolean;
|
|
4
4
|
testIgnoreComments?: boolean;
|
|
5
|
+
unstable_useServerMiddleware?: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare function getTypedRoutesDeclarationFile(ctx: RequireContext, { partialTypedGroups, testIgnoreComments, }?: GetTypedRoutesDeclarationFileOptions): string;
|
|
7
|
+
export declare function getTypedRoutesDeclarationFile(ctx: RequireContext, { partialTypedGroups, testIgnoreComments, unstable_useServerMiddleware, }?: GetTypedRoutesDeclarationFileOptions): string;
|
|
7
8
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAW1C,MAAM,MAAM,oCAAoC,GAAG;IACjD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAW1C,MAAM,MAAM,oCAAoC,GAAG;IACjD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,cAAc,EACnB,EACE,kBAA0B,EAC1B,kBAA0B,EAC1B,4BAAoC,GACrC,GAAE,oCAAyC,UA4G7C"}
|
|
@@ -10,7 +10,7 @@ const SLUG = /\[.+?\]/g;
|
|
|
10
10
|
// /(group)/path/(group2)/route - Match [(group), (group2)]
|
|
11
11
|
const GROUP = /(?:^|\/)\(.*?\)/g;
|
|
12
12
|
const urlParams = "${`?${string}` | `#${string}` | ''}";
|
|
13
|
-
function getTypedRoutesDeclarationFile(ctx, { partialTypedGroups = false, testIgnoreComments = false, } = {}) {
|
|
13
|
+
function getTypedRoutesDeclarationFile(ctx, { partialTypedGroups = false, testIgnoreComments = false, unstable_useServerMiddleware = false, } = {}) {
|
|
14
14
|
let routeNode = null;
|
|
15
15
|
try {
|
|
16
16
|
routeNode = (0, getRoutes_1.getRoutes)(ctx, {
|
|
@@ -20,6 +20,8 @@ function getTypedRoutesDeclarationFile(ctx, { partialTypedGroups = false, testIg
|
|
|
20
20
|
ignoreEntryPoints: true,
|
|
21
21
|
ignoreRequireErrors: true,
|
|
22
22
|
importMode: 'async', // Don't load the file
|
|
23
|
+
// NOTE(@hassankhan): We should ensure that getRoutes() doesn't have optional options in the future
|
|
24
|
+
unstable_useServerMiddleware,
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":";;AAmBA,sEA+GC;AAjID,4CAAyC;AACzC,0CAAwD;AAGxD,oCAAoC;AACpC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,6BAA6B;AAC7B,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,2DAA2D;AAC3D,MAAM,KAAK,GAAG,kBAAkB,CAAC;AAEjC,MAAM,SAAS,GAAG,qCAAqC,CAAC;AAOxD,SAAgB,6BAA6B,CAC3C,GAAmB,EACnB,EACE,kBAAkB,GAAG,KAAK,EAC1B,kBAAkB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AAC,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IAEhE;;;;OAIG;IACH,IAAI,iBAAiB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,KAAK,cAAc,UAAU,iBAAiB,IAAI,CAAC;AAC5D,CAAC","sourcesContent":["import { RouteNode } from '../Route';\nimport { getRoutes } from '../getRoutes';\nimport { removeSupportedExtensions } from '../matchers';\nimport { RequireContext } from '../types';\n\n// /[...param1]/ - Match [...param1]\nconst CATCH_ALL = /\\[\\.\\.\\..+?\\]/g;\n// /[param1] - Match [param1]\nconst SLUG = /\\[.+?\\]/g;\n// /(group)/path/(group2)/route - Match [(group), (group2)]\nconst GROUP = /(?:^|\\/)\\(.*?\\)/g;\n\nconst urlParams = \"${`?${string}` | `#${string}` | ''}\";\n\nexport type GetTypedRoutesDeclarationFileOptions = {\n partialTypedGroups?: boolean;\n testIgnoreComments?: boolean;\n};\n\nexport function getTypedRoutesDeclarationFile(\n ctx: RequireContext,\n {\n partialTypedGroups = false,\n testIgnoreComments = false,\n }: GetTypedRoutesDeclarationFileOptions = {}\n) {\n let routeNode: RouteNode | null = null;\n\n try {\n routeNode = getRoutes(ctx, {\n ignore: [/_layout\\.[tj]sx?$/], // Skip layout files\n platformRoutes: false, // We don't need to generate platform specific routes\n notFound: false, // We don't need +not-found routes either\n ignoreEntryPoints: true,\n ignoreRequireErrors: true,\n importMode: 'async', // Don't load the file\n });\n } catch {\n // Ignore errors from `getRoutes`. This is also called inside the app, which has\n // a nicer UX for showing error messages\n }\n\n const groupedNodes = groupRouteNodes(routeNode);\n const staticRoutesStrings: string[] = ['Router.RelativePathString', 'Router.ExternalPathString'];\n const staticRouteInputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownInputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownInputParams }',\n ];\n const staticRouteOutputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownOutputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams }',\n ];\n\n for (const type of groupedNodes.static) {\n staticRoutesStrings.push(contextKeyToType(type + urlParams, partialTypedGroups));\n staticRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownInputParams; }`\n );\n staticRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownOutputParams; }`\n );\n }\n\n const dynamicRouteStrings: string[] = [];\n const dynamicRouteInputObjects: string[] = [];\n const dynamicRouteOutputObjects: string[] = [];\n\n for (const [dynamicRouteTemplate, paramsNames] of groupedNodes.dynamic) {\n const inputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? '(string | number)[]' : 'string | number';\n return `${contextKeyToProperty(key)}: ${value};`;\n })\n .join('');\n\n const outputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? 'string[]' : 'string';\n return `${contextKeyToProperty(key)}: ${value};`;\n })\n .join('');\n\n dynamicRouteStrings.push(\n contextKeyToType(\n dynamicRouteTemplate\n .replaceAll(CATCH_ALL, '${string}')\n .replaceAll(SLUG, '${Router.SingleRoutePart<T>}') + urlParams,\n partialTypedGroups\n )\n );\n\n dynamicRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownInputParams & { ${inputParams} } }`\n );\n dynamicRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownOutputParams & { ${outputParams} } }`\n );\n }\n\n const href = [\n ...staticRoutesStrings,\n ...staticRouteInputObjects,\n ...dynamicRouteStrings,\n ...dynamicRouteInputObjects,\n ].join(' | ');\n\n const hrefInputParams = [...staticRouteInputObjects, ...dynamicRouteInputObjects].join(' | ');\n const hrefOutputParams = [...staticRouteOutputObjects, ...dynamicRouteOutputObjects].join(' | ');\n\n const tsExpectError = testIgnoreComments\n ? '// @ts-ignore-error -- During tests we need to ignore the \"duplicate\" declaration error, as multiple fixture declare types \\n '\n : '';\n\n return `/* eslint-disable */\nimport * as Router from 'expo-router';\n\nexport * from 'expo-router';\n\ndeclare module 'expo-router' {\n export namespace ExpoRouter {\n export interface __routes<T extends string | object = string> {\n ${tsExpectError}hrefInputParams: ${hrefInputParams};\n ${tsExpectError}hrefOutputParams: ${hrefOutputParams};\n ${tsExpectError}href: ${href};\n }\n }\n}\n`;\n}\n\nfunction groupRouteNodes(\n routeNode: RouteNode | null,\n groupedContextKeys = {\n static: new Set<string>(),\n dynamic: new Map<string, string[]>(),\n }\n) {\n if (!routeNode) {\n return groupedContextKeys;\n }\n\n // Skip non-route files\n if (routeNode.type !== 'route') {\n // Except the root layout\n if (routeNode.route === '') {\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n return groupedContextKeys;\n }\n\n return groupedContextKeys;\n }\n\n let routeKey: string;\n\n if (routeNode.generated) {\n // Some routes like the root _layout, _sitemap, +not-found are generated.\n // We cannot use the contextKey, as their context key does not specify a route\n routeKey = routeNode.route;\n } else {\n routeKey = removeSupportedExtensions(routeNode.contextKey)\n .replace(/\\/index$/, '') // Remove any trailing /index\n .replace(/^\\./, ''); // Remove any leading .\n }\n\n routeKey ||= '/'; // A routeKey may be empty for contextKey '' or './index.js'\n\n if (!routeKey.startsWith('/')) {\n // Not all generated files will have the `/` prefix\n routeKey = `/${routeKey}`;\n }\n\n routeKey = routeKey.replace(/\\\\/g, '/');\n\n if (routeNode.dynamic) {\n groupedContextKeys.dynamic.set(\n routeKey,\n routeKey\n .split('/')\n .filter((segment) => {\n return segment.startsWith('[') && segment.endsWith(']');\n })\n .map((segment) => {\n return segment.slice(1, -1);\n })\n );\n } else {\n groupedContextKeys.static.add(routeKey);\n }\n\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n\n return groupedContextKeys;\n}\n\nfunction contextKeyToProperty(contextKey: string) {\n return !/^(?!\\d)[\\w$]+$/.test(contextKey) ? JSON.stringify(contextKey) : contextKey;\n}\n\nfunction contextKeyToType(contextKey: string, partialTypedGroups: boolean) {\n if (contextKey.match(GROUP) === null) {\n return `\\`${contextKey}\\``;\n }\n\n // If the route has groups, turn them into template strings\n const typeWithGroups = contextKey.replaceAll(GROUP, (match) => {\n const groups = match.slice(2, -1); // Remove the leading ( and the trailing )\n // When `partialRoutes` is enabled, we always change a group to a template\n if (groups.length > 1 || partialTypedGroups) {\n // Ensure each group has the trailing slash\n const groupsAsType = groups.split(',').map((group) => `'/(${group})'`);\n // `partialRoutes` allow you to skip a group\n if (partialTypedGroups) {\n groupsAsType.push(\"''\");\n }\n // Combine together into a union\n return `\\${${groupsAsType.join(' | ')}}`;\n } else {\n return match;\n }\n });\n\n let typeWithoutGroups = contextKey.replaceAll(GROUP, '') || '/';\n\n /**\n * When getting the static routes, they include a urlParams string at the end.\n * If we have a route like `/(group)/(group2)`, this would normally be collapsed to `/`.\n * But because of the urlParams, it becomes `${urlParams}` and we need to add a `/` to the start.\n */\n if (typeWithoutGroups.startsWith(urlParams)) {\n typeWithoutGroups = `/${typeWithoutGroups}`;\n }\n\n return `\\`${typeWithGroups}\\` | \\`${typeWithoutGroups}\\``;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":";;AAoBA,sEAkHC;AArID,4CAAyC;AACzC,0CAAwD;AAGxD,oCAAoC;AACpC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,6BAA6B;AAC7B,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,2DAA2D;AAC3D,MAAM,KAAK,GAAG,kBAAkB,CAAC;AAEjC,MAAM,SAAS,GAAG,qCAAqC,CAAC;AAQxD,SAAgB,6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AG,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,iBAAiB,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IAEhE;;;;OAIG;IACH,IAAI,iBAAiB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,KAAK,cAAc,UAAU,iBAAiB,IAAI,CAAC;AAC5D,CAAC","sourcesContent":["import { RouteNode } from '../Route';\nimport { getRoutes } from '../getRoutes';\nimport { removeSupportedExtensions } from '../matchers';\nimport { RequireContext } from '../types';\n\n// /[...param1]/ - Match [...param1]\nconst CATCH_ALL = /\\[\\.\\.\\..+?\\]/g;\n// /[param1] - Match [param1]\nconst SLUG = /\\[.+?\\]/g;\n// /(group)/path/(group2)/route - Match [(group), (group2)]\nconst GROUP = /(?:^|\\/)\\(.*?\\)/g;\n\nconst urlParams = \"${`?${string}` | `#${string}` | ''}\";\n\nexport type GetTypedRoutesDeclarationFileOptions = {\n partialTypedGroups?: boolean;\n testIgnoreComments?: boolean;\n unstable_useServerMiddleware?: boolean;\n};\n\nexport function getTypedRoutesDeclarationFile(\n ctx: RequireContext,\n {\n partialTypedGroups = false,\n testIgnoreComments = false,\n unstable_useServerMiddleware = false,\n }: GetTypedRoutesDeclarationFileOptions = {}\n) {\n let routeNode: RouteNode | null = null;\n\n try {\n routeNode = getRoutes(ctx, {\n ignore: [/_layout\\.[tj]sx?$/], // Skip layout files\n platformRoutes: false, // We don't need to generate platform specific routes\n notFound: false, // We don't need +not-found routes either\n ignoreEntryPoints: true,\n ignoreRequireErrors: true,\n importMode: 'async', // Don't load the file\n // NOTE(@hassankhan): We should ensure that getRoutes() doesn't have optional options in the future\n unstable_useServerMiddleware,\n });\n } catch {\n // Ignore errors from `getRoutes`. This is also called inside the app, which has\n // a nicer UX for showing error messages\n }\n\n const groupedNodes = groupRouteNodes(routeNode);\n const staticRoutesStrings: string[] = ['Router.RelativePathString', 'Router.ExternalPathString'];\n const staticRouteInputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownInputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownInputParams }',\n ];\n const staticRouteOutputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownOutputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams }',\n ];\n\n for (const type of groupedNodes.static) {\n staticRoutesStrings.push(contextKeyToType(type + urlParams, partialTypedGroups));\n staticRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownInputParams; }`\n );\n staticRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownOutputParams; }`\n );\n }\n\n const dynamicRouteStrings: string[] = [];\n const dynamicRouteInputObjects: string[] = [];\n const dynamicRouteOutputObjects: string[] = [];\n\n for (const [dynamicRouteTemplate, paramsNames] of groupedNodes.dynamic) {\n const inputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? '(string | number)[]' : 'string | number';\n return `${contextKeyToProperty(key)}: ${value};`;\n })\n .join('');\n\n const outputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? 'string[]' : 'string';\n return `${contextKeyToProperty(key)}: ${value};`;\n })\n .join('');\n\n dynamicRouteStrings.push(\n contextKeyToType(\n dynamicRouteTemplate\n .replaceAll(CATCH_ALL, '${string}')\n .replaceAll(SLUG, '${Router.SingleRoutePart<T>}') + urlParams,\n partialTypedGroups\n )\n );\n\n dynamicRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownInputParams & { ${inputParams} } }`\n );\n dynamicRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownOutputParams & { ${outputParams} } }`\n );\n }\n\n const href = [\n ...staticRoutesStrings,\n ...staticRouteInputObjects,\n ...dynamicRouteStrings,\n ...dynamicRouteInputObjects,\n ].join(' | ');\n\n const hrefInputParams = [...staticRouteInputObjects, ...dynamicRouteInputObjects].join(' | ');\n const hrefOutputParams = [...staticRouteOutputObjects, ...dynamicRouteOutputObjects].join(' | ');\n\n const tsExpectError = testIgnoreComments\n ? '// @ts-ignore-error -- During tests we need to ignore the \"duplicate\" declaration error, as multiple fixture declare types \\n '\n : '';\n\n return `/* eslint-disable */\nimport * as Router from 'expo-router';\n\nexport * from 'expo-router';\n\ndeclare module 'expo-router' {\n export namespace ExpoRouter {\n export interface __routes<T extends string | object = string> {\n ${tsExpectError}hrefInputParams: ${hrefInputParams};\n ${tsExpectError}hrefOutputParams: ${hrefOutputParams};\n ${tsExpectError}href: ${href};\n }\n }\n}\n`;\n}\n\nfunction groupRouteNodes(\n routeNode: RouteNode | null,\n groupedContextKeys = {\n static: new Set<string>(),\n dynamic: new Map<string, string[]>(),\n }\n) {\n if (!routeNode) {\n return groupedContextKeys;\n }\n\n // Skip non-route files\n if (routeNode.type !== 'route') {\n // Except the root layout\n if (routeNode.route === '') {\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n return groupedContextKeys;\n }\n\n return groupedContextKeys;\n }\n\n let routeKey: string;\n\n if (routeNode.generated) {\n // Some routes like the root _layout, _sitemap, +not-found are generated.\n // We cannot use the contextKey, as their context key does not specify a route\n routeKey = routeNode.route;\n } else {\n routeKey = removeSupportedExtensions(routeNode.contextKey)\n .replace(/\\/index$/, '') // Remove any trailing /index\n .replace(/^\\./, ''); // Remove any leading .\n }\n\n routeKey ||= '/'; // A routeKey may be empty for contextKey '' or './index.js'\n\n if (!routeKey.startsWith('/')) {\n // Not all generated files will have the `/` prefix\n routeKey = `/${routeKey}`;\n }\n\n routeKey = routeKey.replace(/\\\\/g, '/');\n\n if (routeNode.dynamic) {\n groupedContextKeys.dynamic.set(\n routeKey,\n routeKey\n .split('/')\n .filter((segment) => {\n return segment.startsWith('[') && segment.endsWith(']');\n })\n .map((segment) => {\n return segment.slice(1, -1);\n })\n );\n } else {\n groupedContextKeys.static.add(routeKey);\n }\n\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n\n return groupedContextKeys;\n}\n\nfunction contextKeyToProperty(contextKey: string) {\n return !/^(?!\\d)[\\w$]+$/.test(contextKey) ? JSON.stringify(contextKey) : contextKey;\n}\n\nfunction contextKeyToType(contextKey: string, partialTypedGroups: boolean) {\n if (contextKey.match(GROUP) === null) {\n return `\\`${contextKey}\\``;\n }\n\n // If the route has groups, turn them into template strings\n const typeWithGroups = contextKey.replaceAll(GROUP, (match) => {\n const groups = match.slice(2, -1); // Remove the leading ( and the trailing )\n // When `partialRoutes` is enabled, we always change a group to a template\n if (groups.length > 1 || partialTypedGroups) {\n // Ensure each group has the trailing slash\n const groupsAsType = groups.split(',').map((group) => `'/(${group})'`);\n // `partialRoutes` allow you to skip a group\n if (partialTypedGroups) {\n groupsAsType.push(\"''\");\n }\n // Combine together into a union\n return `\\${${groupsAsType.join(' | ')}}`;\n } else {\n return match;\n }\n });\n\n let typeWithoutGroups = contextKey.replaceAll(GROUP, '') || '/';\n\n /**\n * When getting the static routes, they include a urlParams string at the end.\n * If we have a route like `/(group)/(group2)`, this would normally be collapsed to `/`.\n * But because of the urlParams, it becomes `${urlParams}` and we need to add a `/` to the start.\n */\n if (typeWithoutGroups.startsWith(urlParams)) {\n typeWithoutGroups = `/${typeWithoutGroups}`;\n }\n\n return `\\`${typeWithGroups}\\` | \\`${typeWithoutGroups}\\``;\n}\n"]}
|
|
@@ -13,6 +13,12 @@ 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
|
+
|
|
16
22
|
Events(
|
|
17
23
|
"onPreviewTapped",
|
|
18
24
|
"onPreviewTappedAnimationCompleted",
|
|
@@ -71,14 +77,6 @@ public class LinkPreviewNativeModule: Module {
|
|
|
71
77
|
|
|
72
78
|
Events("onSelected")
|
|
73
79
|
}
|
|
74
|
-
|
|
75
|
-
View(NativeLinkPreviewTrigger.self) {
|
|
76
|
-
Prop("borderRadius") { (view, borderRadius: Double?) in
|
|
77
|
-
if let borderRadius = borderRadius {
|
|
78
|
-
view.triggerBorderRadius = borderRadius
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
|
|
@@ -2,7 +2,7 @@ import ExpoModulesCore
|
|
|
2
2
|
|
|
3
3
|
class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
|
|
4
4
|
LinkPreviewModalDismissible, LinkPreviewMenuUpdatable {
|
|
5
|
-
|
|
5
|
+
var triggerBorderRadius: Double = 0
|
|
6
6
|
private var preview: NativeLinkPreviewContentView?
|
|
7
7
|
private var interaction: UIContextMenuInteraction?
|
|
8
8
|
var nextScreenId: String? {
|
|
@@ -52,47 +52,31 @@ class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
|
|
|
52
52
|
// MARK: - Children
|
|
53
53
|
#if RCT_NEW_ARCH_ENABLED
|
|
54
54
|
override func mountChildComponentView(_ childComponentView: UIView, index: Int) {
|
|
55
|
-
if let
|
|
56
|
-
trigger = triggerView
|
|
57
|
-
if let interaction = self.interaction {
|
|
58
|
-
triggerView.addInteraction(interaction)
|
|
59
|
-
}
|
|
60
|
-
super.mountChildComponentView(childComponentView, index: index)
|
|
61
|
-
} else if let previewView = childComponentView as? NativeLinkPreviewContentView {
|
|
55
|
+
if let previewView = childComponentView as? NativeLinkPreviewContentView {
|
|
62
56
|
preview = previewView
|
|
63
|
-
if let interaction = self.interaction
|
|
64
|
-
|
|
57
|
+
if let interaction = self.interaction {
|
|
58
|
+
self.addInteraction(interaction)
|
|
65
59
|
}
|
|
66
60
|
} else if let actionView = childComponentView as? LinkPreviewNativeActionView {
|
|
67
61
|
actionView.parentMenuUpdatable = self
|
|
68
62
|
actions.append(actionView)
|
|
69
63
|
} else {
|
|
70
|
-
|
|
71
|
-
"ExpoRouter: Unknown child component view (\(childComponentView)) mounted to NativeLinkPreviewView"
|
|
72
|
-
)
|
|
64
|
+
super.mountChildComponentView(childComponentView, index: index)
|
|
73
65
|
}
|
|
74
66
|
}
|
|
75
67
|
|
|
76
68
|
override func unmountChildComponentView(_ child: UIView, index: Int) {
|
|
77
|
-
if child is
|
|
78
|
-
if let interaction = self.interaction {
|
|
79
|
-
trigger?.removeInteraction(interaction)
|
|
80
|
-
}
|
|
81
|
-
trigger = nil
|
|
82
|
-
super.unmountChildComponentView(child, index: index)
|
|
83
|
-
} else if child is NativeLinkPreviewContentView {
|
|
69
|
+
if child is NativeLinkPreviewContentView {
|
|
84
70
|
preview = nil
|
|
85
71
|
if let interaction = self.interaction {
|
|
86
|
-
|
|
72
|
+
self.removeInteraction(interaction)
|
|
87
73
|
}
|
|
88
74
|
} else if let actionView = child as? LinkPreviewNativeActionView {
|
|
89
75
|
actions.removeAll(where: {
|
|
90
76
|
$0 == actionView
|
|
91
77
|
})
|
|
92
78
|
} else {
|
|
93
|
-
|
|
94
|
-
"ExpoRouter: Unknown child component view (\(child)) unmounted from NativeLinkPreviewView"
|
|
95
|
-
)
|
|
79
|
+
super.unmountChildComponentView(child, index: index)
|
|
96
80
|
}
|
|
97
81
|
}
|
|
98
82
|
#endif
|
|
@@ -119,14 +103,15 @@ class NativeLinkPreviewView: ExpoView, UIContextMenuInteractionDelegate,
|
|
|
119
103
|
configuration: UIContextMenuConfiguration,
|
|
120
104
|
highlightPreviewForItemWithIdentifier identifier: any NSCopying
|
|
121
105
|
) -> UITargetedPreview? {
|
|
122
|
-
if let
|
|
123
|
-
let target = UIPreviewTarget(container:
|
|
106
|
+
if let superview = self.superview {
|
|
107
|
+
let target = UIPreviewTarget(container: superview, center: self.center)
|
|
124
108
|
|
|
125
109
|
let parameters = UIPreviewParameters()
|
|
126
110
|
parameters.backgroundColor = .clear
|
|
127
|
-
|
|
111
|
+
parameters.shadowPath = UIBezierPath(
|
|
112
|
+
roundedRect: self.bounds, cornerRadius: self.triggerBorderRadius)
|
|
128
113
|
|
|
129
|
-
return UITargetedPreview(view:
|
|
114
|
+
return UITargetedPreview(view: self, parameters: parameters, target: target)
|
|
130
115
|
}
|
|
131
116
|
return nil
|
|
132
117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.8",
|
|
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",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@testing-library/react-native": ">= 12.0.0",
|
|
82
82
|
"expo": "*",
|
|
83
83
|
"expo-constants": "^18.0.4",
|
|
84
|
-
"expo-linking": "^8.0.
|
|
84
|
+
"expo-linking": "^8.0.4",
|
|
85
85
|
"react": "*",
|
|
86
86
|
"react-dom": "*",
|
|
87
87
|
"react-native": "*",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"tsd": "^0.28.1"
|
|
128
128
|
},
|
|
129
129
|
"dependencies": {
|
|
130
|
-
"@expo/metro-runtime": "6.1.
|
|
130
|
+
"@expo/metro-runtime": "6.1.1",
|
|
131
131
|
"@expo/schema-utils": "^0.1.3",
|
|
132
132
|
"@expo/server": "^0.7.2",
|
|
133
133
|
"@radix-ui/react-slot": "1.2.0",
|
|
@@ -151,5 +151,5 @@
|
|
|
151
151
|
"use-latest-callback": "^0.2.1",
|
|
152
152
|
"vaul": "^1.1.2"
|
|
153
153
|
},
|
|
154
|
-
"gitHead": "
|
|
154
|
+
"gitHead": "d44e41c9c0714a838b1652556d27bcb506fabbdf"
|
|
155
155
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/index.ts"],"version":"5.8.3"}
|