expo-router 55.0.0-beta.0 → 55.0.0-beta.1
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/android/build.gradle +2 -2
- package/build/exports.d.ts +5 -2
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +5 -3
- package/build/exports.js.map +1 -1
- package/build/index.d.ts +0 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +0 -5
- package/build/index.js.map +1 -1
- package/build/layouts/DrawerClient.d.ts +2 -2
- package/build/layouts/StackClient.d.ts +12 -4
- package/build/layouts/StackClient.d.ts.map +1 -1
- package/build/layouts/StackClient.js +5 -0
- package/build/layouts/StackClient.js.map +1 -1
- package/build/layouts/TabsClient.d.ts +8 -3
- package/build/layouts/TabsClient.d.ts.map +1 -1
- package/build/layouts/TabsClient.js +5 -0
- package/build/layouts/TabsClient.js.map +1 -1
- package/build/layouts/stack-utils/StackScreen.d.ts +44 -5
- package/build/layouts/stack-utils/StackScreen.d.ts.map +1 -1
- package/build/layouts/stack-utils/StackScreen.js +50 -9
- package/build/layouts/stack-utils/StackScreen.js.map +1 -1
- package/build/layouts/stack-utils/toolbar/StackToolbarMenu.js +3 -3
- package/build/layouts/stack-utils/toolbar/StackToolbarMenu.js.map +1 -1
- package/build/link/Link.d.ts +1 -1
- package/build/link/elements.d.ts +2 -10
- package/build/link/elements.d.ts.map +1 -1
- package/build/link/elements.js +1 -9
- package/build/link/elements.js.map +1 -1
- package/build/link/zoom/link-apple-zoom-target.d.ts +24 -2
- package/build/link/zoom/link-apple-zoom-target.d.ts.map +1 -1
- package/build/link/zoom/link-apple-zoom-target.js +20 -0
- package/build/link/zoom/link-apple-zoom-target.js.map +1 -1
- package/build/link/zoom/link-apple-zoom.d.ts +1 -2
- package/build/link/zoom/link-apple-zoom.d.ts.map +1 -1
- package/build/link/zoom/link-apple-zoom.js.map +1 -1
- package/build/native-tabs/NativeTabTrigger.d.ts +2 -6
- package/build/native-tabs/NativeTabTrigger.d.ts.map +1 -1
- package/build/native-tabs/NativeTabTrigger.js +2 -6
- package/build/native-tabs/NativeTabTrigger.js.map +1 -1
- package/build/native-tabs/NativeTabs.d.ts +1 -2
- package/build/native-tabs/NativeTabs.d.ts.map +1 -1
- package/build/native-tabs/NativeTabs.js +1 -2
- package/build/native-tabs/NativeTabs.js.map +1 -1
- package/build/native-tabs/index.d.ts +1 -1
- package/build/native-tabs/index.d.ts.map +1 -1
- package/build/native-tabs/index.js +0 -15
- package/build/native-tabs/index.js.map +1 -1
- package/build/primitives/elements.d.ts +4 -2
- package/build/primitives/elements.d.ts.map +1 -1
- package/build/primitives/elements.js +4 -2
- package/build/primitives/elements.js.map +1 -1
- package/build/primitives/index.d.ts +0 -1
- package/build/primitives/index.d.ts.map +1 -1
- package/build/primitives/index.js +1 -4
- package/build/primitives/index.js.map +1 -1
- package/build/primitives/menu.d.ts +0 -2
- package/build/primitives/menu.d.ts.map +1 -1
- package/build/primitives/menu.js +0 -2
- package/build/primitives/menu.js.map +1 -1
- package/build/primitives/types.d.ts +2 -0
- package/build/primitives/types.d.ts.map +1 -1
- package/build/primitives/types.js.map +1 -1
- package/build/ui/TabContext.d.ts +1 -1
- package/build/ui/TabContext.d.ts.map +1 -1
- package/build/ui/TabRouter.d.ts +2 -2
- package/build/ui/Tabs.d.ts +2 -2
- package/build/ui/Tabs.d.ts.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.module → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.module} +7 -7
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.module.md5 +1 -0
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.pom → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.pom} +1 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.pom.sha512 +1 -0
- package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml +4 -4
- package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha512 +1 -1
- package/package.json +6 -6
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.module.md5 +0 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.pom.sha512 +0 -1
- package/plugin/tsconfig.tsbuildinfo +0 -1
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0-sources.jar → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1-sources.jar} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0-sources.jar.md5 → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1-sources.jar.md5} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0-sources.jar.sha1 → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1-sources.jar.sha1} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0-sources.jar.sha256 → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1-sources.jar.sha256} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0-sources.jar.sha512 → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1-sources.jar.sha512} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.aar → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.aar} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.aar.md5 → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.aar.md5} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.aar.sha1 → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.aar.sha1} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.aar.sha256 → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.aar.sha256} +0 -0
- /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.0-beta.0/expo.modules.router-55.0.0-beta.0.aar.sha512 → 55.0.0-beta.1/expo.modules.router-55.0.0-beta.1.aar.sha512} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.StackScreen =
|
|
4
|
+
exports.StackScreen = void 0;
|
|
5
5
|
exports.appendScreenStackPropsToOptions = appendScreenStackPropsToOptions;
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const StackHeaderComponent_1 = require("./StackHeaderComponent");
|
|
@@ -12,20 +12,61 @@ const Screen_1 = require("../../views/Screen");
|
|
|
12
12
|
function extractBottomToolbars(children) {
|
|
13
13
|
return ((0, children_1.getAllChildrenOfType)(children, toolbar_1.StackToolbar).filter((child) => child.props.placement === 'bottom' || child.props.placement === undefined) ?? []);
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Component used to define a screen in a native stack navigator.
|
|
17
|
+
*
|
|
18
|
+
* Can be used in the `_layout.tsx` files, or directly in page components.
|
|
19
|
+
*
|
|
20
|
+
* When configuring header inside page components, prefer using `Stack.Toolbar`, `Stack.Header` and `Stack.Screen.*` components.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx app/_layout.tsx
|
|
24
|
+
* import { Stack } from 'expo-router';
|
|
25
|
+
*
|
|
26
|
+
* export default function Layout() {
|
|
27
|
+
* return (
|
|
28
|
+
* <Stack>
|
|
29
|
+
* <Stack.Screen
|
|
30
|
+
* name="home"
|
|
31
|
+
* options={{ title: 'Home' }}
|
|
32
|
+
* />
|
|
33
|
+
* </Stack>
|
|
34
|
+
* );
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx app/home.tsx
|
|
40
|
+
* import { Stack } from 'expo-router';
|
|
41
|
+
*
|
|
42
|
+
* export default function HomePage() {
|
|
43
|
+
* return (
|
|
44
|
+
* <>
|
|
45
|
+
* <Stack.Screen
|
|
46
|
+
* options={{ headerTransparent: true }}
|
|
47
|
+
* />
|
|
48
|
+
* <Stack.Screen.Title>Welcome Home</Stack.Screen.Title>
|
|
49
|
+
* // Page content
|
|
50
|
+
* </>
|
|
51
|
+
* );
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
exports.StackScreen = Object.assign(function StackScreen({ children, options, ...rest }) {
|
|
16
56
|
// This component will only render when used inside a page.
|
|
17
57
|
const updatedOptions = (0, react_1.useMemo)(() => appendScreenStackPropsToOptions(options ?? {}, {
|
|
18
58
|
children,
|
|
19
59
|
}), [options, children]);
|
|
20
60
|
const bottomToolbars = (0, react_1.useMemo)(() => extractBottomToolbars(children), [children]);
|
|
21
61
|
return (<>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
62
|
+
<Screen_1.Screen {...rest} options={updatedOptions}/>
|
|
63
|
+
{/* Bottom toolbar is a native component rendered separately */}
|
|
64
|
+
{bottomToolbars}
|
|
65
|
+
</>);
|
|
66
|
+
}, {
|
|
67
|
+
Title: screen_1.StackScreenTitle,
|
|
68
|
+
BackButton: screen_1.StackScreenBackButton,
|
|
69
|
+
});
|
|
29
70
|
function appendScreenStackPropsToOptions(options, props) {
|
|
30
71
|
let updatedOptions = { ...options, ...props.options };
|
|
31
72
|
function appendChildOptions(child, opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackScreen.js","sourceRoot":"","sources":["../../../src/layouts/stack-utils/StackScreen.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"StackScreen.js","sourceRoot":"","sources":["../../../src/layouts/stack-utils/StackScreen.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AA+Fb,0EA8CC;AA3ID,iCAAkG;AAElG,iEAA+F;AAC/F,qCAKkB;AAClB,uCAAmG;AACnG,mDAA2E;AAC3E,+CAA4C;AAO5C,SAAS,qBAAqB,CAAC,QAAmB;IAChD,OAAO,CACL,IAAA,+BAAoB,EAAC,QAAQ,EAAE,sBAAY,CAAC,CAAC,MAAM,CACjD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CACrF,IAAI,EAAE,CACR,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACU,QAAA,WAAW,GAAG,MAAM,CAAC,MAAM,CACtC,SAAS,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAoB;IACnE,2DAA2D;IAC3D,MAAM,cAAc,GAAG,IAAA,eAAO,EAC5B,GAAG,EAAE,CACH,+BAA+B,CAAC,OAAO,IAAI,EAAE,EAAE;QAC7C,QAAQ;KACT,CAAC,EACJ,CAAC,OAAO,EAAE,QAAQ,CAAC,CACpB,CAAC;IAEF,MAAM,cAAc,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAElF,OAAO,CACL,EACE;QAAA,CAAC,eAAM,CAAC,IAAI,IAAI,CAAC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AAC,IAAI,KAAK,UAAU;YAC9B,CAAC,CAAE,KAAK,CAAC,IAA0B,CAAC,IAAI,IAAI,SAAS;YACrD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,iDAAiD,QAAQ,EAAE,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;QACzC,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,cAAc,GAAG,kBAAkB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["'use client';\nimport { NativeStackNavigationOptions } from '@react-navigation/native-stack';\nimport { Children, isValidElement, useMemo, type PropsWithChildren, type ReactNode } from 'react';\n\nimport { StackHeaderComponent, appendStackHeaderPropsToOptions } from './StackHeaderComponent';\nimport {\n StackScreenTitle,\n appendStackScreenTitlePropsToOptions,\n StackScreenBackButton,\n appendStackScreenBackButtonPropsToOptions,\n} from './screen';\nimport { StackToolbar, appendStackToolbarPropsToOptions, type StackToolbarProps } from './toolbar';\nimport { getAllChildrenOfType, isChildOfType } from '../../utils/children';\nimport { Screen } from '../../views/Screen';\n\nexport interface StackScreenProps extends PropsWithChildren {\n name?: string;\n options?: NativeStackNavigationOptions;\n}\n\nfunction extractBottomToolbars(children: ReactNode): React.ReactElement<StackToolbarProps>[] {\n return (\n getAllChildrenOfType(children, StackToolbar).filter(\n (child) => child.props.placement === 'bottom' || child.props.placement === undefined\n ) ?? []\n );\n}\n\n/**\n * Component used to define a screen in a native stack navigator.\n *\n * Can be used in the `_layout.tsx` files, or directly in page components.\n *\n * When configuring header inside page components, prefer using `Stack.Toolbar`, `Stack.Header` and `Stack.Screen.*` components.\n *\n * @example\n * ```tsx app/_layout.tsx\n * import { Stack } from 'expo-router';\n *\n * export default function Layout() {\n * return (\n * <Stack>\n * <Stack.Screen\n * name=\"home\"\n * options={{ title: 'Home' }}\n * />\n * </Stack>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx app/home.tsx\n * import { Stack } from 'expo-router';\n *\n * export default function HomePage() {\n * return (\n * <>\n * <Stack.Screen\n * options={{ headerTransparent: true }}\n * />\n * <Stack.Screen.Title>Welcome Home</Stack.Screen.Title>\n * // Page content\n * </>\n * );\n * }\n * ```\n */\nexport const StackScreen = Object.assign(\n function StackScreen({ children, options, ...rest }: StackScreenProps) {\n // This component will only render when used inside a page.\n const updatedOptions = useMemo(\n () =>\n appendScreenStackPropsToOptions(options ?? {}, {\n children,\n }),\n [options, children]\n );\n\n const bottomToolbars = useMemo(() => extractBottomToolbars(children), [children]);\n\n return (\n <>\n <Screen {...rest} options={updatedOptions} />\n {/* Bottom toolbar is a native component rendered separately */}\n {bottomToolbars}\n </>\n );\n },\n {\n Title: StackScreenTitle,\n BackButton: StackScreenBackButton,\n }\n);\n\nexport function appendScreenStackPropsToOptions(\n options: NativeStackNavigationOptions,\n props: StackScreenProps\n): NativeStackNavigationOptions {\n let updatedOptions = { ...options, ...props.options };\n\n function appendChildOptions(child: React.ReactElement, opts: NativeStackNavigationOptions) {\n if (isChildOfType(child, StackHeaderComponent)) {\n return appendStackHeaderPropsToOptions(opts, child.props);\n }\n\n if (isChildOfType(child, StackScreenTitle)) {\n return appendStackScreenTitlePropsToOptions(opts, child.props);\n }\n\n if (isChildOfType(child, StackScreenBackButton)) {\n return appendStackScreenBackButtonPropsToOptions(opts, child.props);\n }\n\n if (isChildOfType(child, StackToolbar)) {\n const placement = child.props.placement ?? 'bottom';\n\n if (placement === 'bottom') {\n throw new Error(\n `Stack.Toolbar with placement=\"bottom\" cannot be used inside Stack.Screen in _layout.tsx. Please move it to the page component.`\n );\n }\n\n return appendStackToolbarPropsToOptions(opts, child.props);\n }\n\n const typeName =\n typeof child.type === 'function'\n ? (child.type as { name?: string }).name || 'Unknown'\n : String(child.type);\n console.warn(`Unknown child element passed to Stack.Screen: ${typeName}`);\n return opts;\n }\n\n Children.forEach(props.children, (child) => {\n if (isValidElement(child)) {\n updatedOptions = appendChildOptions(child, updatedOptions);\n }\n });\n\n return updatedOptions;\n}\n"]}
|
|
@@ -7,7 +7,7 @@ exports.convertStackToolbarMenuActionPropsToRNHeaderItem = convertStackToolbarMe
|
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const bottom_toolbar_native_elements_1 = require("./bottom-toolbar-native-elements");
|
|
9
9
|
const context_1 = require("./context");
|
|
10
|
-
const
|
|
10
|
+
const menu_1 = require("../../../primitives/menu");
|
|
11
11
|
const children_1 = require("../../../utils/children");
|
|
12
12
|
const shared_1 = require("../shared");
|
|
13
13
|
/**
|
|
@@ -57,7 +57,7 @@ const StackToolbarMenu = ({ children, ...props }) => {
|
|
|
57
57
|
// TODO(@ubax): Handle image loading using useImage in a follow-up PR.
|
|
58
58
|
return <bottom_toolbar_native_elements_1.NativeToolbarMenu {...props} image={props.image} children={validChildren}/>;
|
|
59
59
|
}
|
|
60
|
-
return <
|
|
60
|
+
return <menu_1.Menu {...props} children={validChildren}/>;
|
|
61
61
|
};
|
|
62
62
|
exports.StackToolbarMenu = StackToolbarMenu;
|
|
63
63
|
function convertStackToolbarMenuPropsToRNHeaderItem(props) {
|
|
@@ -159,7 +159,7 @@ const StackToolbarMenuAction = (props) => {
|
|
|
159
159
|
const icon = typeof props.icon === 'string' ? props.icon : undefined;
|
|
160
160
|
return <bottom_toolbar_native_elements_1.NativeToolbarMenuAction {...props} icon={icon} image={props.image}/>;
|
|
161
161
|
}
|
|
162
|
-
return <
|
|
162
|
+
return <menu_1.MenuAction {...props}/>;
|
|
163
163
|
};
|
|
164
164
|
exports.StackToolbarMenuAction = StackToolbarMenuAction;
|
|
165
165
|
function convertStackToolbarMenuActionPropsToRNHeaderItem(props) {
|
|
@@ -1 +1 @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,KAAK,CAAC;IACxE,MAAM,WAAW,GAAG,IAAA,0DAAiD,EAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAoC;QAC5C,GAAG,IAAI;QACP,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,WAAW,CAAC,KAAK;QACxB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QAC1B,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;KACrC,CAAC;IACF,IAAI,sBAAsB,KAAK,SAAS,EAAE,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,sBAAsB,CAAC;IACnD,CAAC;IACD,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;QACrB,iDAAiD;QACjD,oEAAoE;QACpE,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACzC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CACV,qIAAqI,CACtI,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["'use client';\nimport type {\n NativeStackHeaderItemMenu,\n NativeStackHeaderItemMenuAction,\n NativeStackHeaderItemMenuSubmenu,\n} from '@react-navigation/native-stack';\nimport type { ImageRef } from 'expo-image';\nimport { Children, useMemo, type ReactNode } from 'react';\nimport type { ImageSourcePropType } from 'react-native';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport { NativeToolbarMenu, NativeToolbarMenuAction } from './bottom-toolbar-native-elements';\nimport { useToolbarPlacement } from './context';\nimport { Menu, MenuAction } from '../../../primitives';\nimport { filterAllowedChildrenElements, isChildOfType } from '../../../utils/children';\nimport {\n convertStackHeaderSharedPropsToRNSharedHeaderItem,\n type StackHeaderItemSharedProps,\n} from '../shared';\n\nexport interface StackToolbarMenuProps {\n accessibilityLabel?: string;\n accessibilityHint?: string;\n /**\n * Menu content - can include icons, labels, badges and menu actions.\n *\n * @example\n * ```tsx\n * <Stack.Toolbar.Menu>\n * <Stack.Toolbar.Icon sfSymbol=\"ellipsis.circle\" />\n * <Stack.Toolbar.Label>Options</Stack.Toolbar.Label>\n * <Stack.Toolbar.MenuAction onPress={() => {}}>Action 1</Stack.Toolbar.MenuAction>\n * </Stack.Toolbar.Menu>\n * ```\n */\n children?: ReactNode;\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 disabled?: boolean;\n // TODO(@ubax): Add useImage support in a follow-up PR.\n /**\n * Image to display for the menu item.\n *\n * > **Note**: This prop is only supported in toolbar with `placement=\"bottom\"`.\n */\n image?: ImageRef;\n /**\n * Whether to hide the shared background.\n *\n * @see [Official Apple documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitem/hidessharedbackground) for more information.\n *\n * @platform iOS 26+\n */\n hidesSharedBackground?: boolean;\n /**\n * Whether the menu should be hidden.\n *\n * @default false\n */\n hidden?: boolean;\n /**\n * Icon for the menu item.\n *\n * Can be an SF Symbol name or an image source.\n *\n * > **Note**: When used in `placement=\"bottom\"`, only string SFSymbols are supported. Use the `image` prop to provide custom images.\n */\n icon?: StackHeaderItemSharedProps['icon'];\n /**\n * If `true`, the menu will be displayed inline.\n * This means that the menu will not be collapsed\n *\n * > **Note**: Inline menus are only supported in submenus.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayinline) for more information.\n */\n inline?: boolean;\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 * > **Note**: Palette menus are only supported in submenus.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette) for more information.\n */\n palette?: boolean;\n /**\n * Whether to separate the background of this item from other header items.\n *\n * @default false\n */\n separateBackground?: boolean;\n /**\n * Style for the label of the header item.\n */\n style?: StackHeaderItemSharedProps['style'];\n /**\n * The tint color to apply to the button item\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitem/tintcolor) for more information.\n */\n tintColor?: StackHeaderItemSharedProps['tintColor'];\n /**\n * Optional title to show on top of the menu.\n */\n title?: string;\n /**\n * @default 'plain'\n */\n variant?: StackHeaderItemSharedProps['variant'];\n // TODO(@ubax): Add elementSize support in react-native-screens for header menus.\n /**\n * The preferred size of the menu elements.\n *\n * > **Note**: This prop is only supported in `Stack.Toolbar.Bottom`.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/preferredelementsize) for more information.\n *\n * @platform iOS 16.0+\n */\n elementSize?: 'auto' | 'small' | 'medium' | 'large';\n}\n\n/**\n * Use as `Stack.Toolbar.Menu` to provide menus in iOS toolbar.\n * It accepts `Stack.Toolbar.MenuAction` and nested `Stack.Toolbar.Menu`\n * elements. Menu can be configured using both component props and child\n * elements.\n *\n * @example\n * ```tsx\n * import { Stack } from 'expo-router';\n * import { Alert } from 'react-native';\n *\n * export default function Page() {\n * return (\n * <>\n * <Stack.Toolbar placement=\"right\">\n * <Stack.Toolbar.Menu icon=\"ellipsis.circle\">\n * <Stack.Toolbar.MenuAction onPress={() => Alert.alert('Action pressed!')}>\n * Action 1\n * </Stack.Toolbar.MenuAction>\n * </Stack.Toolbar.Menu>\n * </Stack.Toolbar>\n * <ScreenContent />\n * </>\n * );\n * }\n * ```\n *\n * @see [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/menus) for more information about menus on iOS.\n *\n * @platform ios\n */\nexport const StackToolbarMenu: React.FC<StackToolbarMenuProps> = ({ children, ...props }) => {\n const placement = useToolbarPlacement();\n\n const allowedChildren = useMemo(\n () =>\n placement === 'bottom'\n ? [StackToolbarMenu, StackToolbarMenuAction, NativeToolbarMenu, NativeToolbarMenuAction]\n : [StackToolbarMenu, StackToolbarMenuAction],\n [placement]\n );\n\n const validChildren = useMemo(\n () => filterAllowedChildrenElements(children, allowedChildren),\n [children, allowedChildren]\n );\n\n if (process.env.NODE_ENV !== 'production') {\n const allChildren = Children.toArray(children);\n if (allChildren.length !== validChildren.length) {\n throw new Error(\n `Stack.Toolbar.Menu only accepts Stack.Toolbar.Menu and Stack.Toolbar.MenuAction as its children.`\n );\n }\n }\n\n if (placement === 'bottom') {\n // TODO(@ubax): Handle image loading using useImage in a follow-up PR.\n return <NativeToolbarMenu {...props} image={props.image} children={validChildren} />;\n }\n\n return <Menu {...props} children={validChildren} />;\n};\n\nexport function convertStackToolbarMenuPropsToRNHeaderItem(\n props: StackToolbarMenuProps\n): NativeStackHeaderItemMenu | undefined {\n if (props.hidden) {\n return undefined;\n }\n const { title, ...rest } = props;\n const actions = Children.toArray(props.children).filter(\n (child) =>\n isChildOfType(child, StackToolbarMenuAction) || isChildOfType(child, StackToolbarMenu)\n );\n const item: NativeStackHeaderItemMenu = {\n ...convertStackHeaderSharedPropsToRNSharedHeaderItem(rest),\n type: 'menu',\n menu: {\n multiselectable: true,\n items: actions\n .map((action) => {\n if (isChildOfType(action, StackToolbarMenu)) {\n return convertStackToolbarSubmenuMenuPropsToRNHeaderItem(action.props);\n }\n return convertStackToolbarMenuActionPropsToRNHeaderItem(action.props);\n })\n .filter((i) => !!i),\n },\n };\n if (title) {\n item.menu.title = title;\n }\n\n return item;\n}\n\nfunction convertStackToolbarSubmenuMenuPropsToRNHeaderItem(\n props: StackToolbarMenuProps\n): NativeStackHeaderItemMenuSubmenu | undefined {\n if (props.hidden) {\n return undefined;\n }\n const sharedProps = convertStackHeaderSharedPropsToRNSharedHeaderItem(props);\n const actions = Children.toArray(props.children).filter(\n (child) =>\n isChildOfType(child, StackToolbarMenuAction) || isChildOfType(child, StackToolbarMenu)\n );\n\n const item: NativeStackHeaderItemMenuSubmenu = {\n type: 'submenu',\n items: actions\n .map((action) => {\n if (isChildOfType(action, StackToolbarMenu)) {\n return convertStackToolbarSubmenuMenuPropsToRNHeaderItem(action.props);\n }\n return convertStackToolbarMenuActionPropsToRNHeaderItem(action.props);\n })\n .filter((i) => !!i),\n label: sharedProps.label || props.title || '',\n multiselectable: true,\n };\n\n if (props.inline !== undefined) {\n item.inline = props.inline;\n }\n if (props.palette !== undefined) {\n item.layout = props.palette ? 'palette' : 'default';\n }\n if (props.destructive !== undefined) {\n item.destructive = props.destructive;\n }\n // TODO: Add elementSize to react-native-screens\n\n if (sharedProps.icon) {\n // Only SF Symbols are supported in submenu icons\n // TODO(@ubax): Add support for other images in react-native-screens\n if (sharedProps.icon.type === 'sfSymbol') {\n item.icon = sharedProps.icon;\n } else {\n console.warn(\n 'When Icon is used inside Stack.Toolbar.Menu used as a submenu, only sfSymbol icons are supported. This is a limitation of React Native Screens.'\n );\n }\n }\n\n return item;\n}\n\nexport interface StackToolbarMenuActionProps {\n /**\n * Can be an Icon, Label or string title.\n */\n children?: ReactNode;\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 icon?: SFSymbol | ImageSourcePropType;\n // TODO(@ubax): Add useImage support in a follow-up PR.\n /**\n * Image to display for the menu action.\n *\n * > **Note**: This prop is only supported in `Stack.Toolbar.Bottom`.\n */\n image?: ImageRef;\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 * An elaborated title that explains the purpose of the action.\n */\n discoverabilityLabel?: string;\n /**\n * An optional subtitle for the menu item.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/subtitle) for more information.\n */\n subtitle?: string;\n hidden?: boolean;\n}\n\n/**\n * An action item for a `Stack.Toolbar.Menu`.\n *\n * @example\n * ```tsx\n * import { Stack } from 'expo-router';\n *\n * export default function Page() {\n * return (\n * <>\n * <Stack.Toolbar placement=\"right\">\n * <Stack.Toolbar.Menu icon=\"ellipsis.circle\">\n * <Stack.Toolbar.MenuAction onPress={() => alert('Action pressed!')}>\n * Action 1\n * </Stack.Toolbar.MenuAction>\n * </Stack.Toolbar.Menu>\n * </Stack.Toolbar>\n * <ScreenContent />\n * </>\n * );\n * }\n * ```\n *\n * @platform ios\n */\nexport const StackToolbarMenuAction: React.FC<StackToolbarMenuActionProps> = (props) => {\n const placement = useToolbarPlacement();\n\n if (placement === 'bottom') {\n // TODO(@ubax): Handle image loading using useImage in a follow-up PR.\n const icon = typeof props.icon === 'string' ? props.icon : undefined;\n return <NativeToolbarMenuAction {...props} icon={icon} image={props.image} />;\n }\n\n return <MenuAction {...props} />;\n};\n\nexport function convertStackToolbarMenuActionPropsToRNHeaderItem(\n props: StackToolbarMenuActionProps\n): NativeStackHeaderItemMenuAction {\n const { children, isOn, unstable_keepPresented, icon, ...rest } = props;\n const sharedProps = convertStackHeaderSharedPropsToRNSharedHeaderItem(props);\n const item: NativeStackHeaderItemMenuAction = {\n ...rest,\n type: 'action',\n label: sharedProps.label,\n state: isOn ? 'on' : 'off',\n onPress: props.onPress ?? (() => {}),\n };\n if (unstable_keepPresented !== undefined) {\n item.keepsMenuPresented = unstable_keepPresented;\n }\n if (sharedProps.icon) {\n // Only SF Symbols are supported in submenu icons\n // TODO(@ubax): Add support for other images in react-native-screens\n if (sharedProps.icon.type === 'sfSymbol') {\n item.icon = sharedProps.icon;\n } else {\n console.warn(\n 'When Icon is used inside Stack.Toolbar.MenuAction, only sfSymbol icons are supported. This is a limitation of React Native Screens.'\n );\n }\n }\n return item;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StackToolbarMenu.js","sourceRoot":"","sources":["../../../../src/layouts/stack-utils/toolbar/StackToolbarMenu.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AA+Lb,gGA+BC;AA+ID,4GA2BC;AAjYD,iCAA0D;AAI1D,qFAA8F;AAC9F,uCAAgD;AAChD,mDAA4D;AAC5D,sDAAuF;AACvF,sCAGmB;AA6GnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACI,MAAM,gBAAgB,GAAoC,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAC1F,MAAM,SAAS,GAAG,IAAA,6BAAmB,GAAE,CAAC;IAExC,MAAM,eAAe,GAAG,IAAA,eAAO,EAC7B,GAAG,EAAE,CACH,SAAS,KAAK,QAAQ;QACpB,CAAC,CAAC,CAAC,wBAAgB,EAAE,8BAAsB,EAAE,kDAAiB,EAAE,wDAAuB,CAAC;QACxF,CAAC,CAAC,CAAC,wBAAgB,EAAE,8BAAsB,CAAC,EAChD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,MAAM,aAAa,GAAG,IAAA,eAAO,EAC3B,GAAG,EAAE,CAAC,IAAA,wCAA6B,EAAC,QAAQ,EAAE,eAAe,CAAC,EAC9D,CAAC,QAAQ,EAAE,eAAe,CAAC,CAC5B,CAAC;IAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC1C,MAAM,WAAW,GAAG,gBAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,WAAW,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CACb,kGAAkG,CACnG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC3B,sEAAsE;QACtE,OA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IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACxE,MAAM,WAAW,GAAG,IAAA,0DAAiD,EAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAoC;QAC5C,GAAG,IAAI;QACP,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,WAAW,CAAC,KAAK;QACxB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QAC1B,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;KACrC,CAAC;IACF,IAAI,sBAAsB,KAAK,SAAS,EAAE,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,sBAAsB,CAAC;IACnD,CAAC;IACD,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;QACrB,iDAAiD;QACjD,oEAAoE;QACpE,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACzC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CACV,qIAAqI,CACtI,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["'use client';\nimport type {\n NativeStackHeaderItemMenu,\n NativeStackHeaderItemMenuAction,\n NativeStackHeaderItemMenuSubmenu,\n} from '@react-navigation/native-stack';\nimport type { ImageRef } from 'expo-image';\nimport { Children, useMemo, type ReactNode } from 'react';\nimport type { ImageSourcePropType } from 'react-native';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport { NativeToolbarMenu, NativeToolbarMenuAction } from './bottom-toolbar-native-elements';\nimport { useToolbarPlacement } from './context';\nimport { Menu, MenuAction } from '../../../primitives/menu';\nimport { filterAllowedChildrenElements, isChildOfType } from '../../../utils/children';\nimport {\n convertStackHeaderSharedPropsToRNSharedHeaderItem,\n type StackHeaderItemSharedProps,\n} from '../shared';\n\nexport interface StackToolbarMenuProps {\n accessibilityLabel?: string;\n accessibilityHint?: string;\n /**\n * Menu content - can include icons, labels, badges and menu actions.\n *\n * @example\n * ```tsx\n * <Stack.Toolbar.Menu>\n * <Stack.Toolbar.Icon sfSymbol=\"ellipsis.circle\" />\n * <Stack.Toolbar.Label>Options</Stack.Toolbar.Label>\n * <Stack.Toolbar.MenuAction onPress={() => {}}>Action 1</Stack.Toolbar.MenuAction>\n * </Stack.Toolbar.Menu>\n * ```\n */\n children?: ReactNode;\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 disabled?: boolean;\n // TODO(@ubax): Add useImage support in a follow-up PR.\n /**\n * Image to display for the menu item.\n *\n * > **Note**: This prop is only supported in toolbar with `placement=\"bottom\"`.\n */\n image?: ImageRef;\n /**\n * Whether to hide the shared background.\n *\n * @see [Official Apple documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitem/hidessharedbackground) for more information.\n *\n * @platform iOS 26+\n */\n hidesSharedBackground?: boolean;\n /**\n * Whether the menu should be hidden.\n *\n * @default false\n */\n hidden?: boolean;\n /**\n * Icon for the menu item.\n *\n * Can be an SF Symbol name or an image source.\n *\n * > **Note**: When used in `placement=\"bottom\"`, only string SFSymbols are supported. Use the `image` prop to provide custom images.\n */\n icon?: StackHeaderItemSharedProps['icon'];\n /**\n * If `true`, the menu will be displayed inline.\n * This means that the menu will not be collapsed\n *\n * > **Note**: Inline menus are only supported in submenus.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayinline) for more information.\n */\n inline?: boolean;\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 * > **Note**: Palette menus are only supported in submenus.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette) for more information.\n */\n palette?: boolean;\n /**\n * Whether to separate the background of this item from other header items.\n *\n * @default false\n */\n separateBackground?: boolean;\n /**\n * Style for the label of the header item.\n */\n style?: StackHeaderItemSharedProps['style'];\n /**\n * The tint color to apply to the button item\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitem/tintcolor) for more information.\n */\n tintColor?: StackHeaderItemSharedProps['tintColor'];\n /**\n * Optional title to show on top of the menu.\n */\n title?: string;\n /**\n * @default 'plain'\n */\n variant?: StackHeaderItemSharedProps['variant'];\n // TODO(@ubax): Add elementSize support in react-native-screens for header menus.\n /**\n * The preferred size of the menu elements.\n *\n * > **Note**: This prop is only supported in `Stack.Toolbar.Bottom`.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/preferredelementsize) for more information.\n *\n * @platform iOS 16.0+\n */\n elementSize?: 'auto' | 'small' | 'medium' | 'large';\n}\n\n/**\n * Use as `Stack.Toolbar.Menu` to provide menus in iOS toolbar.\n * It accepts `Stack.Toolbar.MenuAction` and nested `Stack.Toolbar.Menu`\n * elements. Menu can be configured using both component props and child\n * elements.\n *\n * @example\n * ```tsx\n * import { Stack } from 'expo-router';\n * import { Alert } from 'react-native';\n *\n * export default function Page() {\n * return (\n * <>\n * <Stack.Toolbar placement=\"right\">\n * <Stack.Toolbar.Menu icon=\"ellipsis.circle\">\n * <Stack.Toolbar.MenuAction onPress={() => Alert.alert('Action pressed!')}>\n * Action 1\n * </Stack.Toolbar.MenuAction>\n * </Stack.Toolbar.Menu>\n * </Stack.Toolbar>\n * <ScreenContent />\n * </>\n * );\n * }\n * ```\n *\n * @see [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/menus) for more information about menus on iOS.\n *\n * @platform ios\n */\nexport const StackToolbarMenu: React.FC<StackToolbarMenuProps> = ({ children, ...props }) => {\n const placement = useToolbarPlacement();\n\n const allowedChildren = useMemo(\n () =>\n placement === 'bottom'\n ? [StackToolbarMenu, StackToolbarMenuAction, NativeToolbarMenu, NativeToolbarMenuAction]\n : [StackToolbarMenu, StackToolbarMenuAction],\n [placement]\n );\n\n const validChildren = useMemo(\n () => filterAllowedChildrenElements(children, allowedChildren),\n [children, allowedChildren]\n );\n\n if (process.env.NODE_ENV !== 'production') {\n const allChildren = Children.toArray(children);\n if (allChildren.length !== validChildren.length) {\n throw new Error(\n `Stack.Toolbar.Menu only accepts Stack.Toolbar.Menu and Stack.Toolbar.MenuAction as its children.`\n );\n }\n }\n\n if (placement === 'bottom') {\n // TODO(@ubax): Handle image loading using useImage in a follow-up PR.\n return <NativeToolbarMenu {...props} image={props.image} children={validChildren} />;\n }\n\n return <Menu {...props} children={validChildren} />;\n};\n\nexport function convertStackToolbarMenuPropsToRNHeaderItem(\n props: StackToolbarMenuProps\n): NativeStackHeaderItemMenu | undefined {\n if (props.hidden) {\n return undefined;\n }\n const { title, ...rest } = props;\n const actions = Children.toArray(props.children).filter(\n (child) =>\n isChildOfType(child, StackToolbarMenuAction) || isChildOfType(child, StackToolbarMenu)\n );\n const item: NativeStackHeaderItemMenu = {\n ...convertStackHeaderSharedPropsToRNSharedHeaderItem(rest),\n type: 'menu',\n menu: {\n multiselectable: true,\n items: actions\n .map((action) => {\n if (isChildOfType(action, StackToolbarMenu)) {\n return convertStackToolbarSubmenuMenuPropsToRNHeaderItem(action.props);\n }\n return convertStackToolbarMenuActionPropsToRNHeaderItem(action.props);\n })\n .filter((i) => !!i),\n },\n };\n if (title) {\n item.menu.title = title;\n }\n\n return item;\n}\n\nfunction convertStackToolbarSubmenuMenuPropsToRNHeaderItem(\n props: StackToolbarMenuProps\n): NativeStackHeaderItemMenuSubmenu | undefined {\n if (props.hidden) {\n return undefined;\n }\n const sharedProps = convertStackHeaderSharedPropsToRNSharedHeaderItem(props);\n const actions = Children.toArray(props.children).filter(\n (child) =>\n isChildOfType(child, StackToolbarMenuAction) || isChildOfType(child, StackToolbarMenu)\n );\n\n const item: NativeStackHeaderItemMenuSubmenu = {\n type: 'submenu',\n items: actions\n .map((action) => {\n if (isChildOfType(action, StackToolbarMenu)) {\n return convertStackToolbarSubmenuMenuPropsToRNHeaderItem(action.props);\n }\n return convertStackToolbarMenuActionPropsToRNHeaderItem(action.props);\n })\n .filter((i) => !!i),\n label: sharedProps.label || props.title || '',\n multiselectable: true,\n };\n\n if (props.inline !== undefined) {\n item.inline = props.inline;\n }\n if (props.palette !== undefined) {\n item.layout = props.palette ? 'palette' : 'default';\n }\n if (props.destructive !== undefined) {\n item.destructive = props.destructive;\n }\n // TODO: Add elementSize to react-native-screens\n\n if (sharedProps.icon) {\n // Only SF Symbols are supported in submenu icons\n // TODO(@ubax): Add support for other images in react-native-screens\n if (sharedProps.icon.type === 'sfSymbol') {\n item.icon = sharedProps.icon;\n } else {\n console.warn(\n 'When Icon is used inside Stack.Toolbar.Menu used as a submenu, only sfSymbol icons are supported. This is a limitation of React Native Screens.'\n );\n }\n }\n\n return item;\n}\n\nexport interface StackToolbarMenuActionProps {\n /**\n * Can be an Icon, Label or string title.\n */\n children?: ReactNode;\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 icon?: SFSymbol | ImageSourcePropType;\n // TODO(@ubax): Add useImage support in a follow-up PR.\n /**\n * Image to display for the menu action.\n *\n * > **Note**: This prop is only supported in `Stack.Toolbar.Bottom`.\n */\n image?: ImageRef;\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 * An elaborated title that explains the purpose of the action.\n */\n discoverabilityLabel?: string;\n /**\n * An optional subtitle for the menu item.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/subtitle) for more information.\n */\n subtitle?: string;\n hidden?: boolean;\n}\n\n/**\n * An action item for a `Stack.Toolbar.Menu`.\n *\n * @example\n * ```tsx\n * import { Stack } from 'expo-router';\n *\n * export default function Page() {\n * return (\n * <>\n * <Stack.Toolbar placement=\"right\">\n * <Stack.Toolbar.Menu icon=\"ellipsis.circle\">\n * <Stack.Toolbar.MenuAction onPress={() => alert('Action pressed!')}>\n * Action 1\n * </Stack.Toolbar.MenuAction>\n * </Stack.Toolbar.Menu>\n * </Stack.Toolbar>\n * <ScreenContent />\n * </>\n * );\n * }\n * ```\n *\n * @platform ios\n */\nexport const StackToolbarMenuAction: React.FC<StackToolbarMenuActionProps> = (props) => {\n const placement = useToolbarPlacement();\n\n if (placement === 'bottom') {\n // TODO(@ubax): Handle image loading using useImage in a follow-up PR.\n const icon = typeof props.icon === 'string' ? props.icon : undefined;\n return <NativeToolbarMenuAction {...props} icon={icon} image={props.image} />;\n }\n\n return <MenuAction {...props} />;\n};\n\nexport function convertStackToolbarMenuActionPropsToRNHeaderItem(\n props: StackToolbarMenuActionProps\n): NativeStackHeaderItemMenuAction {\n const { children, isOn, unstable_keepPresented, icon, ...rest } = props;\n const sharedProps = convertStackHeaderSharedPropsToRNSharedHeaderItem(props);\n const item: NativeStackHeaderItemMenuAction = {\n ...rest,\n type: 'action',\n label: sharedProps.label,\n state: isOn ? 'on' : 'off',\n onPress: props.onPress ?? (() => {}),\n };\n if (unstable_keepPresented !== undefined) {\n item.keepsMenuPresented = unstable_keepPresented;\n }\n if (sharedProps.icon) {\n // Only SF Symbols are supported in submenu icons\n // TODO(@ubax): Add support for other images in react-native-screens\n if (sharedProps.icon.type === 'sfSymbol') {\n item.icon = sharedProps.icon;\n } else {\n console.warn(\n 'When Icon is used inside Stack.Toolbar.MenuAction, only sfSymbol icons are supported. This is a limitation of React Native Screens.'\n );\n }\n }\n return item;\n}\n"]}
|
package/build/link/Link.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { LinkAppleZoom } from './zoom/link-apple-zoom';
|
|
|
4
4
|
import { LinkAppleZoomTarget } from './zoom/link-apple-zoom-target';
|
|
5
5
|
export declare const Link: ((props: LinkProps) => import("react").JSX.Element) & {
|
|
6
6
|
resolveHref: (href: import("..").Href) => string;
|
|
7
|
-
Menu: import("
|
|
7
|
+
Menu: (props: import("./elements").LinkMenuProps) => import("react").JSX.Element | null;
|
|
8
8
|
Trigger: typeof LinkTrigger;
|
|
9
9
|
Preview: typeof LinkPreview;
|
|
10
10
|
MenuAction: typeof LinkMenuAction;
|
package/build/link/elements.d.ts
CHANGED
|
@@ -85,8 +85,6 @@ export interface LinkMenuActionProps {
|
|
|
85
85
|
* This component renders a context menu action for a link.
|
|
86
86
|
* It should only be used as a child of `Link.Menu` or `LinkMenu`.
|
|
87
87
|
*
|
|
88
|
-
* > **Note**: You can use the alias `Link.MenuAction` for this component.
|
|
89
|
-
*
|
|
90
88
|
* @platform ios
|
|
91
89
|
*/
|
|
92
90
|
export declare function LinkMenuAction(props: LinkMenuActionProps): React.JSX.Element | null;
|
|
@@ -171,7 +169,7 @@ export interface LinkMenuProps {
|
|
|
171
169
|
* Groups context menu actions for a link.
|
|
172
170
|
*
|
|
173
171
|
* If multiple `Link.Menu` components are used within a single `Link`, only the first will be rendered.
|
|
174
|
-
* Only `Link.MenuAction` and `
|
|
172
|
+
* Only `Link.MenuAction` and `Link.Menu` components are allowed as children.
|
|
175
173
|
*
|
|
176
174
|
* @example
|
|
177
175
|
* ```tsx
|
|
@@ -181,11 +179,9 @@ export interface LinkMenuProps {
|
|
|
181
179
|
* </Link.Menu>
|
|
182
180
|
* ```
|
|
183
181
|
*
|
|
184
|
-
* > **Note**: You can use the alias `Link.Menu` for this component.
|
|
185
|
-
*
|
|
186
182
|
* @platform ios
|
|
187
183
|
*/
|
|
188
|
-
export declare const LinkMenu: React.
|
|
184
|
+
export declare const LinkMenu: (props: LinkMenuProps) => React.JSX.Element | null;
|
|
189
185
|
export type LinkPreviewStyle = Omit<ViewStyle, 'position' | 'width' | 'height'> & {
|
|
190
186
|
/**
|
|
191
187
|
* Sets the preferred width of the preview.
|
|
@@ -236,8 +232,6 @@ export interface LinkPreviewProps {
|
|
|
236
232
|
* </Link>
|
|
237
233
|
* ```
|
|
238
234
|
*
|
|
239
|
-
* > **Note**: You can use the alias `Link.Preview` for this component.
|
|
240
|
-
*
|
|
241
235
|
* @platform ios
|
|
242
236
|
*/
|
|
243
237
|
export declare function LinkPreview(props: LinkPreviewProps): React.JSX.Element | null;
|
|
@@ -268,8 +262,6 @@ export interface LinkTriggerProps extends PropsWithChildren {
|
|
|
268
262
|
* </Link>
|
|
269
263
|
* ```
|
|
270
264
|
*
|
|
271
|
-
* > **Note**: You can use the alias `Link.Trigger` for this component.
|
|
272
|
-
*
|
|
273
265
|
* @platform ios
|
|
274
266
|
*/
|
|
275
267
|
export declare function LinkTrigger({ withAppleZoom, ...props }: LinkTriggerProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,EAA8B,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAYtD,MAAM,WAAW,mB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,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG;IAChF;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,4BAwBlD;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,EAAE,aAAa,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,mSAgBxE"}
|
package/build/link/elements.js
CHANGED
|
@@ -52,8 +52,6 @@ const children_1 = require("../utils/children");
|
|
|
52
52
|
* This component renders a context menu action for a link.
|
|
53
53
|
* It should only be used as a child of `Link.Menu` or `LinkMenu`.
|
|
54
54
|
*
|
|
55
|
-
* > **Note**: You can use the alias `Link.MenuAction` for this component.
|
|
56
|
-
*
|
|
57
55
|
* @platform ios
|
|
58
56
|
*/
|
|
59
57
|
function LinkMenuAction(props) {
|
|
@@ -76,7 +74,7 @@ function LinkMenuAction(props) {
|
|
|
76
74
|
* Groups context menu actions for a link.
|
|
77
75
|
*
|
|
78
76
|
* If multiple `Link.Menu` components are used within a single `Link`, only the first will be rendered.
|
|
79
|
-
* Only `Link.MenuAction` and `
|
|
77
|
+
* Only `Link.MenuAction` and `Link.Menu` components are allowed as children.
|
|
80
78
|
*
|
|
81
79
|
* @example
|
|
82
80
|
* ```tsx
|
|
@@ -86,8 +84,6 @@ function LinkMenuAction(props) {
|
|
|
86
84
|
* </Link.Menu>
|
|
87
85
|
* ```
|
|
88
86
|
*
|
|
89
|
-
* > **Note**: You can use the alias `Link.Menu` for this component.
|
|
90
|
-
*
|
|
91
87
|
* @platform ios
|
|
92
88
|
*/
|
|
93
89
|
const LinkMenu = (props) => {
|
|
@@ -126,8 +122,6 @@ exports.LinkMenu = LinkMenu;
|
|
|
126
122
|
* </Link>
|
|
127
123
|
* ```
|
|
128
124
|
*
|
|
129
|
-
* > **Note**: You can use the alias `Link.Preview` for this component.
|
|
130
|
-
*
|
|
131
125
|
* @platform ios
|
|
132
126
|
*/
|
|
133
127
|
function LinkPreview(props) {
|
|
@@ -168,8 +162,6 @@ function LinkPreview(props) {
|
|
|
168
162
|
* </Link>
|
|
169
163
|
* ```
|
|
170
164
|
*
|
|
171
|
-
* > **Note**: You can use the alias `Link.Trigger` for this component.
|
|
172
|
-
*
|
|
173
165
|
* @platform ios
|
|
174
166
|
*/
|
|
175
167
|
function LinkTrigger({ withAppleZoom, ...props }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Gb,wCA0BC;AAmLD,kCAwBC;AAkCD,kCAgBC;AA9XD,+CAAkG;AAIlG,6EAA0E;AAC1E,2DAAwD;AACxD,8CAA4C;AAC5C,uDAAoD;AACpD,uEAA6D;AAC7D,6CAAqF;AACrF,qCAAkC;AAClC,4DAAuD;AACvD,gDAAwD;AAmFxD;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,KAA0B;IACvD,MAAM,UAAU,GAAG,IAAA,aAAK,GAAE,CAAC;IAC3B,IAAI,IAAA,kCAAY,GAAE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK,IAAI,CAAC,IAAA,WAAG,E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AAqG;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,MAAM,OAAO,GAAG,CAAC,WAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;IACpC,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,CAAC,+BAAa,CAAC,CAAC,OAAO,CAAC,EAAE,+BAAa,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["'use client';\n\nimport type { ImageRef } from 'expo-image';\nimport React, { isValidElement, use, useId, type PropsWithChildren, type ReactNode } from 'react';\nimport type { ViewStyle } from 'react-native';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { NativeMenuContext } from './NativeMenuContext';\nimport { Icon, Label } from '../primitives';\nimport { HrefPreview } from './preview/HrefPreview';\nimport { useIsPreview } from './preview/PreviewRouteContext';\nimport { NativeLinkPreviewAction, NativeLinkPreviewContent } from './preview/native';\nimport { Slot } from '../ui/Slot';\nimport { LinkAppleZoom } from './zoom/link-apple-zoom';\nimport { getFirstChildOfType } from '../utils/children';\n\nexport interface LinkMenuActionProps {\n /**\n * The title of the menu item.\n */\n children?: ReactNode;\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 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 * An elaborated title that explains the purpose of the action.\n */\n discoverabilityLabel?: string;\n /**\n * Whether the menu element should be hidden.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/hidden) for more information.\n *\n * @default false\n */\n hidden?: boolean;\n // TODO: support ImageSourcePropType icons in addition to SFSymbols\n /**\n * SF Symbol displayed alongside the menu item.\n */\n icon?: SFSymbol;\n /**\n * Custom image loaded using `useImage()` hook from `expo-image`.\n * Takes priority over `icon` (SF Symbol) when both are provided.\n *\n * @example\n * ```tsx\n * import { useImage } from 'expo-image';\n * import { Link } from 'expo-router';\n *\n * const customIcon = useImage('https://simpleicons.org/icons/expo.svg', {\n * maxWidth: 24,\n * maxHeight: 24,\n * });\n *\n * <Link.Menu title=\"Menu\">\n * <Link.MenuAction image={customIcon} title=\"Action\" onPress={() => {}} />\n * </Link.Menu>\n * ```\n */\n image?: ImageRef | null;\n /**\n * If `true`, the menu item will be displayed as selected.\n */\n isOn?: boolean;\n onPress?: () => void;\n /**\n * An optional subtitle for the menu item.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/subtitle) for more information.\n */\n subtitle?: string;\n /**\n * The title of the menu item.\n * @deprecated Use `children` prop instead.\n */\n title?: string;\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\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 const identifier = useId();\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(NativeMenuContext)) {\n return null;\n }\n const { unstable_keepPresented, onPress, children, title, ...rest } = props;\n const areChildrenString = typeof children === 'string';\n const label = areChildrenString\n ? (children as string)\n : getFirstChildOfType(children, Label)?.props.children;\n const iconComponent =\n !props.icon && !areChildrenString ? getFirstChildOfType(children, Icon) : undefined;\n const icon =\n props.icon ??\n (iconComponent?.props && 'sf' in iconComponent.props ? iconComponent.props.sf : undefined);\n const sf = typeof icon === 'string' ? icon : undefined;\n return (\n <NativeLinkPreviewAction\n {...rest}\n identifier={identifier}\n icon={sf}\n title={label ?? title ?? ''}\n keepPresented={unstable_keepPresented}\n onSelected={() => onPress?.()}\n />\n );\n}\n\nexport interface LinkMenuProps {\n /**\n * The title of the menu item\n */\n title?: string;\n /**\n * An optional subtitle for the submenu. Does not appear on `inline` menus.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/subtitle) for more information.\n */\n subtitle?: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: SFSymbol;\n /**\n * Custom image loaded using `useImage()` hook from `expo-image`.\n * Takes priority over `icon` (SF Symbol) when both are provided.\n *\n * @example\n * ```tsx\n * import { useImage } from 'expo-image';\n * import { Link } from 'expo-router';\n *\n * const customIcon = useImage('https://simpleicons.org/icons/expo.svg', {\n * maxWidth: 24,\n * maxHeight: 24,\n * });\n *\n * <Link.Menu image={customIcon} title=\"Menu\">\n * <Link.MenuAction title=\"Action\" onPress={() => {}} />\n * </Link.Menu>\n * ```\n */\n image?: ImageRef | null;\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 * The `elementSize` property is ignored when palette is used, all items will be `elementSize=\"small\"`. Use `elementSize=\"medium\"` instead of `palette` to display actions with titles horizontally.\n *\n * > **Note**: Palette menus are only supported in submenus.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette) for more information.\n */\n palette?: boolean;\n /**\n * @deprecated Use `palette` prop instead.\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 inline?: boolean;\n /**\n * @deprecated Use `inline` prop instead.\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 /**\n * The preferred size of the menu elements.\n * `elementSize` property is ignored when `palette` is used.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/preferredelementsize) for more information.\n *\n * @platform iOS 16.0+\n */\n elementSize?: 'small' | 'medium' | 'large' | 'auto';\n children?: React.ReactNode;\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 const identifier = useId();\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(NativeMenuContext)) {\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 const displayAsPalette = props.palette ?? props.displayAsPalette;\n const displayInline = props.inline ?? props.displayInline;\n return (\n <NativeLinkPreviewAction\n {...props}\n displayAsPalette={displayAsPalette}\n displayInline={displayInline}\n preferredElementSize={props.elementSize}\n title={props.title ?? ''}\n onSelected={() => {}}\n children={children}\n identifier={identifier}\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 interface LinkTriggerProps extends PropsWithChildren {\n /**\n * A shorthand for enabling the Apple Zoom Transition on this link trigger.\n *\n * When set to `true`, the trigger will be wrapped with `Link.AppleZoom`.\n * If another `Link.AppleZoom` is already used inside `Link.Trigger`, an error\n * will be thrown.\n *\n * @platform ios 18+\n */\n withAppleZoom?: boolean;\n}\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({ withAppleZoom, ...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 const content = <Slot {...props} />;\n if (withAppleZoom) {\n return <LinkAppleZoom>{content}</LinkAppleZoom>;\n }\n return content;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/link/elements.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGb,wCA0BC;AA+KD,kCAwBC;AAgCD,kCAgBC;AAtXD,+CAAkG;AAIlG,6EAA0E;AAC1E,2DAAwD;AACxD,8CAA4C;AAC5C,uDAAoD;AACpD,uEAA6D;AAC7D,6CAAqF;AACrF,qCAAkC;AAClC,4DAAuD;AACvD,gDAAwD;AAmFxD;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,KAA0B;IACvD,MAAM,UAAU,GAAG,IAAA,aAAK,GAAE,CAAC;IAC3B,IAAI,IAAA,kCAAY,GAAE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK,IAAI,CAAC,IAAA,WAAG,EAAC,qCAAiB,CAAC,EAAE,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC5E,MAAM,iBAAiB,GAAG,OAAO,QAAQ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GAAG,CAAC,WAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;IACpC,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,CAAC,+BAAa,CAAC,CAAC,OAAO,CAAC,EAAE,+BAAa,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["'use client';\n\nimport type { ImageRef } from 'expo-image';\nimport React, { isValidElement, use, useId, type PropsWithChildren, type ReactNode } from 'react';\nimport type { ViewStyle } from 'react-native';\nimport type { SFSymbol } from 'sf-symbols-typescript';\n\nimport { InternalLinkPreviewContext } from './InternalLinkPreviewContext';\nimport { NativeMenuContext } from './NativeMenuContext';\nimport { Icon, Label } from '../primitives';\nimport { HrefPreview } from './preview/HrefPreview';\nimport { useIsPreview } from './preview/PreviewRouteContext';\nimport { NativeLinkPreviewAction, NativeLinkPreviewContent } from './preview/native';\nimport { Slot } from '../ui/Slot';\nimport { LinkAppleZoom } from './zoom/link-apple-zoom';\nimport { getFirstChildOfType } from '../utils/children';\n\nexport interface LinkMenuActionProps {\n /**\n * The title of the menu item.\n */\n children?: ReactNode;\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 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 * An elaborated title that explains the purpose of the action.\n */\n discoverabilityLabel?: string;\n /**\n * Whether the menu element should be hidden.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/attributes/hidden) for more information.\n *\n * @default false\n */\n hidden?: boolean;\n // TODO: support ImageSourcePropType icons in addition to SFSymbols\n /**\n * SF Symbol displayed alongside the menu item.\n */\n icon?: SFSymbol;\n /**\n * Custom image loaded using `useImage()` hook from `expo-image`.\n * Takes priority over `icon` (SF Symbol) when both are provided.\n *\n * @example\n * ```tsx\n * import { useImage } from 'expo-image';\n * import { Link } from 'expo-router';\n *\n * const customIcon = useImage('https://simpleicons.org/icons/expo.svg', {\n * maxWidth: 24,\n * maxHeight: 24,\n * });\n *\n * <Link.Menu title=\"Menu\">\n * <Link.MenuAction image={customIcon} title=\"Action\" onPress={() => {}} />\n * </Link.Menu>\n * ```\n */\n image?: ImageRef | null;\n /**\n * If `true`, the menu item will be displayed as selected.\n */\n isOn?: boolean;\n onPress?: () => void;\n /**\n * An optional subtitle for the menu item.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/subtitle) for more information.\n */\n subtitle?: string;\n /**\n * The title of the menu item.\n * @deprecated Use `children` prop instead.\n */\n title?: string;\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\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 * @platform ios\n */\nexport function LinkMenuAction(props: LinkMenuActionProps) {\n const identifier = useId();\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(NativeMenuContext)) {\n return null;\n }\n const { unstable_keepPresented, onPress, children, title, ...rest } = props;\n const areChildrenString = typeof children === 'string';\n const label = areChildrenString\n ? (children as string)\n : getFirstChildOfType(children, Label)?.props.children;\n const iconComponent =\n !props.icon && !areChildrenString ? getFirstChildOfType(children, Icon) : undefined;\n const icon =\n props.icon ??\n (iconComponent?.props && 'sf' in iconComponent.props ? iconComponent.props.sf : undefined);\n const sf = typeof icon === 'string' ? icon : undefined;\n return (\n <NativeLinkPreviewAction\n {...rest}\n identifier={identifier}\n icon={sf}\n title={label ?? title ?? ''}\n keepPresented={unstable_keepPresented}\n onSelected={() => onPress?.()}\n />\n );\n}\n\nexport interface LinkMenuProps {\n /**\n * The title of the menu item\n */\n title?: string;\n /**\n * An optional subtitle for the submenu. Does not appear on `inline` menus.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenuelement/subtitle) for more information.\n */\n subtitle?: string;\n /**\n * Optional SF Symbol displayed alongside the menu item.\n */\n icon?: SFSymbol;\n /**\n * Custom image loaded using `useImage()` hook from `expo-image`.\n * Takes priority over `icon` (SF Symbol) when both are provided.\n *\n * @example\n * ```tsx\n * import { useImage } from 'expo-image';\n * import { Link } from 'expo-router';\n *\n * const customIcon = useImage('https://simpleicons.org/icons/expo.svg', {\n * maxWidth: 24,\n * maxHeight: 24,\n * });\n *\n * <Link.Menu image={customIcon} title=\"Menu\">\n * <Link.MenuAction title=\"Action\" onPress={() => {}} />\n * </Link.Menu>\n * ```\n */\n image?: ImageRef | null;\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 * The `elementSize` property is ignored when palette is used, all items will be `elementSize=\"small\"`. Use `elementSize=\"medium\"` instead of `palette` to display actions with titles horizontally.\n *\n * > **Note**: Palette menus are only supported in submenus.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/options-swift.struct/displayaspalette) for more information.\n */\n palette?: boolean;\n /**\n * @deprecated Use `palette` prop instead.\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 inline?: boolean;\n /**\n * @deprecated Use `inline` prop instead.\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 /**\n * The preferred size of the menu elements.\n * `elementSize` property is ignored when `palette` is used.\n *\n * @see [Apple documentation](https://developer.apple.com/documentation/uikit/uimenu/preferredelementsize) for more information.\n *\n * @platform iOS 16.0+\n */\n elementSize?: 'small' | 'medium' | 'large' | 'auto';\n children?: React.ReactNode;\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 `Link.Menu` 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 * @platform ios\n */\nexport const LinkMenu = (props: LinkMenuProps) => {\n const identifier = useId();\n if (useIsPreview() || process.env.EXPO_OS !== 'ios' || !use(NativeMenuContext)) {\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 const displayAsPalette = props.palette ?? props.displayAsPalette;\n const displayInline = props.inline ?? props.displayInline;\n return (\n <NativeLinkPreviewAction\n {...props}\n displayAsPalette={displayAsPalette}\n displayInline={displayInline}\n preferredElementSize={props.elementSize}\n title={props.title ?? ''}\n onSelected={() => {}}\n children={children}\n identifier={identifier}\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 * @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 interface LinkTriggerProps extends PropsWithChildren {\n /**\n * A shorthand for enabling the Apple Zoom Transition on this link trigger.\n *\n * When set to `true`, the trigger will be wrapped with `Link.AppleZoom`.\n * If another `Link.AppleZoom` is already used inside `Link.Trigger`, an error\n * will be thrown.\n *\n * @platform ios 18+\n */\n withAppleZoom?: boolean;\n}\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 * @platform ios\n */\nexport function LinkTrigger({ withAppleZoom, ...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 const content = <Slot {...props} />;\n if (withAppleZoom) {\n return <LinkAppleZoom>{content}</LinkAppleZoom>;\n }\n return content;\n}\n"]}
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Defines the target for an Apple zoom transition.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* import { Link } from 'expo-router';
|
|
8
|
+
*
|
|
9
|
+
* export default function Screen() {
|
|
10
|
+
* return (
|
|
11
|
+
* <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
12
|
+
* <Link.AppleZoomTarget>
|
|
13
|
+
* <Image source={require('../assets/image.png')} style={{ width: 200, height: 200 }} />
|
|
14
|
+
* </Link.AppleZoomTarget>
|
|
15
|
+
* </View>
|
|
16
|
+
* );
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @platform ios 18+
|
|
21
|
+
*/
|
|
22
|
+
export declare function LinkAppleZoomTarget({ children }: {
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
3
25
|
//# sourceMappingURL=link-apple-zoom-target.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-apple-zoom-target.d.ts","sourceRoot":"","sources":["../../../src/link/zoom/link-apple-zoom-target.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,
|
|
1
|
+
{"version":3,"file":"link-apple-zoom-target.d.ts","sourceRoot":"","sources":["../../../src/link/zoom/link-apple-zoom-target.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,+TAgBzE"}
|
|
@@ -4,6 +4,26 @@ exports.LinkAppleZoomTarget = LinkAppleZoomTarget;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const zoom_transition_context_1 = require("./zoom-transition-context");
|
|
6
6
|
const native_1 = require("../preview/native");
|
|
7
|
+
/**
|
|
8
|
+
* Defines the target for an Apple zoom transition.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { Link } from 'expo-router';
|
|
13
|
+
*
|
|
14
|
+
* export default function Screen() {
|
|
15
|
+
* return (
|
|
16
|
+
* <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
17
|
+
* <Link.AppleZoomTarget>
|
|
18
|
+
* <Image source={require('../assets/image.png')} style={{ width: 200, height: 200 }} />
|
|
19
|
+
* </Link.AppleZoomTarget>
|
|
20
|
+
* </View>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @platform ios 18+
|
|
26
|
+
*/
|
|
7
27
|
function LinkAppleZoomTarget({ children }) {
|
|
8
28
|
if (react_1.Children.count(children) > 1) {
|
|
9
29
|
console.warn('[expo-router] Link.AppleZoomTarget only accepts a single child component. Please wrap multiple children in a View or another container component.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-apple-zoom-target.js","sourceRoot":"","sources":["../../../src/link/zoom/link-apple-zoom-target.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"link-apple-zoom-target.js","sourceRoot":"","sources":["../../../src/link/zoom/link-apple-zoom-target.tsx"],"names":[],"mappings":";;AAyBA,kDAgBC;AAzCD,iCAAsD;AAEtD,uEAAwE;AACxE,8CAA4E;AAE5E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAA4B;IACxE,IAAI,gBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CACV,mJAAmJ,CACpJ,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,WAAG,EAAC,qDAA2B,CAAC,CAAC;IACxD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,CACL,CAAC,gDAAuC,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAC9D;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,gDAAuC,CAAC,CAC3C,CAAC;AACJ,CAAC","sourcesContent":["import { Children, use, type ReactNode } from 'react';\n\nimport { ZoomTransitionTargetContext } from './zoom-transition-context';\nimport { LinkZoomTransitionAlignmentRectDetector } from '../preview/native';\n\n/**\n * Defines the target for an Apple zoom transition.\n *\n * @example\n * ```tsx\n * import { Link } from 'expo-router';\n *\n * export default function Screen() {\n * return (\n * <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>\n * <Link.AppleZoomTarget>\n * <Image source={require('../assets/image.png')} style={{ width: 200, height: 200 }} />\n * </Link.AppleZoomTarget>\n * </View>\n * );\n * }\n * ```\n *\n * @platform ios 18+\n */\nexport function LinkAppleZoomTarget({ children }: { children?: ReactNode }) {\n if (Children.count(children) > 1) {\n console.warn(\n '[expo-router] Link.AppleZoomTarget only accepts a single child component. Please wrap multiple children in a View or another container component.'\n );\n return null;\n }\n const { identifier } = use(ZoomTransitionTargetContext);\n if (!identifier) {\n return children;\n }\n return (\n <LinkZoomTransitionAlignmentRectDetector identifier={identifier}>\n {children}\n </LinkZoomTransitionAlignmentRectDetector>\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PropsWithChildren } from 'react';
|
|
2
|
-
interface LinkAppleZoomProps extends PropsWithChildren {
|
|
2
|
+
export interface LinkAppleZoomProps extends PropsWithChildren {
|
|
3
3
|
/**
|
|
4
4
|
* Defines the rectangle used for the zoom transition's alignment. This rectangle is specified in the zoomed screen's coordinate space.
|
|
5
5
|
*
|
|
@@ -19,5 +19,4 @@ interface LinkAppleZoomProps extends PropsWithChildren {
|
|
|
19
19
|
* @platform ios 18+
|
|
20
20
|
*/
|
|
21
21
|
export declare function LinkAppleZoom(props: LinkAppleZoomProps): import("react").JSX.Element;
|
|
22
|
-
export {};
|
|
23
22
|
//# sourceMappingURL=link-apple-zoom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-apple-zoom.d.ts","sourceRoot":"","sources":["../../../src/link/zoom/link-apple-zoom.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAOzE,
|
|
1
|
+
{"version":3,"file":"link-apple-zoom.d.ts","sourceRoot":"","sources":["../../../src/link/zoom/link-apple-zoom.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAOzE,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D;;;;OAIG;IACH,aAAa,CAAC,EAAE;QACd,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAKtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-apple-zoom.js","sourceRoot":"","sources":["../../../src/link/zoom/link-apple-zoom.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AA6Bb,sCAKC;AAhCD,iC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,CAAC,CAAC,aAAa,CAAC;IACzB,+GAA+G;IAC/G,wBAAwB,CACxB;MAAA,CAAC,WAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,WAAI,CAClC;IAAA,EAAE,iCAAwB,CAAC,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { Children, use, useEffect, type PropsWithChildren } from 'react';\n\nimport { isZoomTransitionEnabled } from './ZoomTransitionEnabler.ios';\nimport { ZoomTransitionSourceContext } from './zoom-transition-context';\nimport { Slot } from '../../ui/Slot';\nimport { LinkZoomTransitionSource } from '../preview/native';\n\
|
|
1
|
+
{"version":3,"file":"link-apple-zoom.js","sourceRoot":"","sources":["../../../src/link/zoom/link-apple-zoom.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AA6Bb,sCAKC;AAhCD,iCAAyE;AAEzE,2EAAsE;AACtE,uEAAwE;AACxE,wCAAqC;AACrC,8CAA6D;AAgB7D;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,KAAyB;IACrD,IAAI,CAAC,IAAA,mDAAuB,GAAE,EAAE,CAAC;QAC/B,OAAO,CAAC,WAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC1C,CAAC;AAMD,SAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI,EAA0B;IACrF,MAAM,KAAK,GAAG,IAAA,WAAG,EAAC,qDAA2B,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAEtD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,SAAS,EAAE,CAAC;QACZ,OAAO,YAAY,CAAC;IACtB,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAE9B,MAAM,kBAAkB,GAAG,gBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAExD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,kBAAkB,EAAE,CAAC;YAChE,OAAO,CAAC,IAAI,CACV,wJAAwJ,CACzJ,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAEzB,IAAI,kBAAkB,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,CAAC,iCAAwB,CACvB,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,SAAS,CAAC,CAAC,aAAa,CAAC;IACzB,+GAA+G;IAC/G,wBAAwB,CACxB;MAAA,CAAC,WAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,WAAI,CAClC;IAAA,EAAE,iCAAwB,CAAC,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { Children, use, useEffect, type PropsWithChildren } from 'react';\n\nimport { isZoomTransitionEnabled } from './ZoomTransitionEnabler.ios';\nimport { ZoomTransitionSourceContext } from './zoom-transition-context';\nimport { Slot } from '../../ui/Slot';\nimport { LinkZoomTransitionSource } from '../preview/native';\n\nexport interface LinkAppleZoomProps extends PropsWithChildren {\n /**\n * Defines the rectangle used for the zoom transition's alignment. This rectangle is specified in the zoomed screen's coordinate space.\n *\n * @platform ios 18+\n */\n alignmentRect?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n}\n\n/**\n * When this component is used inside a Link, [zoom transition](https://developer.apple.com/documentation/uikit/enhancing-your-app-with-fluid-transitions?language=objc)\n * will be used when navigating to the link's href.\n *\n * @platform ios 18+\n */\nexport function LinkAppleZoom(props: LinkAppleZoomProps) {\n if (!isZoomTransitionEnabled()) {\n return <Slot {...props} />;\n }\n return <LinkAppleZoomImpl {...props} />;\n}\n\ntype LinkAppleZoomImplProps = LinkAppleZoomProps & {\n onPress?: () => void;\n};\n\nfunction LinkAppleZoomImpl({ children, alignmentRect, ...rest }: LinkAppleZoomImplProps) {\n const value = use(ZoomTransitionSourceContext);\n if (!value) {\n throw new Error('[expo-router] Link.ZoomTransitionSource must be used within a Link');\n }\n const { identifier, addSource, removeSource } = value;\n\n useEffect(() => {\n addSource();\n return removeSource;\n }, [addSource, removeSource]);\n\n const hasTooManyChildren = Children.count(children) > 1;\n\n useEffect(() => {\n if (process.env.NODE_ENV !== 'production' && hasTooManyChildren) {\n console.warn(\n '[expo-router] Link.ZoomTransitionSource only accepts a single child component. Please wrap multiple children in a View or another container component.'\n );\n }\n }, [hasTooManyChildren]);\n\n if (hasTooManyChildren) {\n return null;\n }\n\n return (\n <LinkZoomTransitionSource\n identifier={identifier}\n alignment={alignmentRect}\n // Note(@ubax): Even though we always set this to true, I want to keep the prop here for easier future changes.\n animateAspectRatioChange>\n <Slot {...rest}>{children}</Slot>\n </LinkZoomTransitionSource>\n );\n}\n"]}
|
|
@@ -8,8 +8,7 @@ import type { NativeTabOptions, NativeTabTriggerProps } from './types';
|
|
|
8
8
|
* When used in the tab screen, the `name` prop takes no effect.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* // In _layout file
|
|
11
|
+
* ```tsx app/_layout.tsx
|
|
13
12
|
* import { NativeTabs } from 'expo-router/unstable-native-tabs';
|
|
14
13
|
*
|
|
15
14
|
* export default function Layout() {
|
|
@@ -23,8 +22,7 @@ import type { NativeTabOptions, NativeTabTriggerProps } from './types';
|
|
|
23
22
|
* ```
|
|
24
23
|
*
|
|
25
24
|
* @example
|
|
26
|
-
* ```tsx
|
|
27
|
-
* // In a tab screen
|
|
25
|
+
* ```tsx app/home.tsx
|
|
28
26
|
* import { NativeTabs } from 'expo-router/unstable-native-tabs';
|
|
29
27
|
*
|
|
30
28
|
* export default function HomeScreen() {
|
|
@@ -38,8 +36,6 @@ import type { NativeTabOptions, NativeTabTriggerProps } from './types';
|
|
|
38
36
|
* );
|
|
39
37
|
* }
|
|
40
38
|
* ```
|
|
41
|
-
*
|
|
42
|
-
* > **Note:** You can use the alias `NativeTabs.Trigger` for this component.
|
|
43
39
|
*/
|
|
44
40
|
declare function NativeTabTriggerImpl(props: NativeTabTriggerProps): null;
|
|
45
41
|
export declare const NativeTabTrigger: typeof NativeTabTriggerImpl & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabTrigger.d.ts","sourceRoot":"","sources":["../../src/native-tabs/NativeTabTrigger.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvF,OAAO,EAKL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAEhC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAOvE
|
|
1
|
+
{"version":3,"file":"NativeTabTrigger.d.ts","sourceRoot":"","sources":["../../src/native-tabs/NativeTabTrigger.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvF,OAAO,EAKL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAEhC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAOvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,iBAAS,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,QAuBzD;AAED,eAAO,MAAM,gBAAgB;;;;;CAK3B,CAAC;AAEH,wBAAgB,wBAAwB,CACtC,EACE,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,EAC7B,YAAY,GACb,EAAE,qBAAqB,EACxB,SAAS,GAAE,OAAe,oBAqC3B;AAyBD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,0BAA0B,QA8C7F;AAsCD,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"}
|
|
@@ -21,8 +21,7 @@ const materialIconConverter_1 = require("./utils/materialIconConverter");
|
|
|
21
21
|
* When used in the tab screen, the `name` prop takes no effect.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* ```tsx
|
|
25
|
-
* // In _layout file
|
|
24
|
+
* ```tsx app/_layout.tsx
|
|
26
25
|
* import { NativeTabs } from 'expo-router/unstable-native-tabs';
|
|
27
26
|
*
|
|
28
27
|
* export default function Layout() {
|
|
@@ -36,8 +35,7 @@ const materialIconConverter_1 = require("./utils/materialIconConverter");
|
|
|
36
35
|
* ```
|
|
37
36
|
*
|
|
38
37
|
* @example
|
|
39
|
-
* ```tsx
|
|
40
|
-
* // In a tab screen
|
|
38
|
+
* ```tsx app/home.tsx
|
|
41
39
|
* import { NativeTabs } from 'expo-router/unstable-native-tabs';
|
|
42
40
|
*
|
|
43
41
|
* export default function HomeScreen() {
|
|
@@ -51,8 +49,6 @@ const materialIconConverter_1 = require("./utils/materialIconConverter");
|
|
|
51
49
|
* );
|
|
52
50
|
* }
|
|
53
51
|
* ```
|
|
54
|
-
*
|
|
55
|
-
* > **Note:** You can use the alias `NativeTabs.Trigger` for this component.
|
|
56
52
|
*/
|
|
57
53
|
function NativeTabTriggerImpl(props) {
|
|
58
54
|
const route = (0, native_1.useRoute)();
|