expo-router 5.2.0-canary-20250613-b29d676-2 → 5.2.0-canary-20250701-6a945c5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/build/ExpoRoot.d.ts.map +1 -1
  2. package/build/ExpoRoot.js +13 -7
  3. package/build/ExpoRoot.js.map +1 -1
  4. package/build/exports.d.ts +2 -0
  5. package/build/exports.d.ts.map +1 -1
  6. package/build/exports.js +5 -1
  7. package/build/exports.js.map +1 -1
  8. package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
  9. package/build/fork/getStateFromPath-forks.js +4 -1
  10. package/build/fork/getStateFromPath-forks.js.map +1 -1
  11. package/build/getRoutes.d.ts +1 -1
  12. package/build/getRoutes.d.ts.map +1 -1
  13. package/build/getRoutes.js +14 -6
  14. package/build/getRoutes.js.map +1 -1
  15. package/build/getRoutesCore.d.ts +7 -2
  16. package/build/getRoutesCore.d.ts.map +1 -1
  17. package/build/getRoutesCore.js +86 -58
  18. package/build/getRoutesCore.js.map +1 -1
  19. package/build/getRoutesRedirects.d.ts +2 -2
  20. package/build/getRoutesRedirects.d.ts.map +1 -1
  21. package/build/getRoutesRedirects.js +18 -24
  22. package/build/getRoutesRedirects.js.map +1 -1
  23. package/build/getRoutesSSR.d.ts +1 -1
  24. package/build/getRoutesSSR.d.ts.map +1 -1
  25. package/build/getRoutesSSR.js +2 -3
  26. package/build/getRoutesSSR.js.map +1 -1
  27. package/build/global-state/router-store.d.ts +52 -1
  28. package/build/global-state/router-store.d.ts.map +1 -1
  29. package/build/global-state/router-store.js +22 -1
  30. package/build/global-state/router-store.js.map +1 -1
  31. package/build/global-state/routing.d.ts +1 -0
  32. package/build/global-state/routing.d.ts.map +1 -1
  33. package/build/global-state/routing.js +3 -2
  34. package/build/global-state/routing.js.map +1 -1
  35. package/build/global-state/storeContext.d.ts +50 -0
  36. package/build/global-state/storeContext.d.ts.map +1 -1
  37. package/build/hooks.d.ts.map +1 -1
  38. package/build/hooks.js +33 -1
  39. package/build/hooks.js.map +1 -1
  40. package/build/layouts/StackClient.d.ts.map +1 -1
  41. package/build/layouts/StackClient.js +39 -2
  42. package/build/layouts/StackClient.js.map +1 -1
  43. package/build/link/BaseExpoRouterLink.d.ts +3 -0
  44. package/build/link/BaseExpoRouterLink.d.ts.map +1 -0
  45. package/build/link/BaseExpoRouterLink.js +63 -0
  46. package/build/link/BaseExpoRouterLink.js.map +1 -0
  47. package/build/link/ExpoLink.d.ts +3 -0
  48. package/build/link/ExpoLink.d.ts.map +1 -0
  49. package/build/link/ExpoLink.js +23 -0
  50. package/build/link/ExpoLink.js.map +1 -0
  51. package/build/link/Link.d.ts +63 -78
  52. package/build/link/Link.d.ts.map +1 -1
  53. package/build/link/Link.js +81 -99
  54. package/build/link/Link.js.map +1 -1
  55. package/build/link/LinkWithPreview.d.ts +36 -0
  56. package/build/link/LinkWithPreview.d.ts.map +1 -0
  57. package/build/link/LinkWithPreview.js +192 -0
  58. package/build/link/LinkWithPreview.js.map +1 -0
  59. package/build/link/Redirect.d.ts +58 -0
  60. package/build/link/Redirect.d.ts.map +1 -0
  61. package/build/link/Redirect.js +46 -0
  62. package/build/link/Redirect.js.map +1 -0
  63. package/build/link/preview/HrefPreview.d.ts +5 -0
  64. package/build/link/preview/HrefPreview.d.ts.map +1 -0
  65. package/build/link/preview/HrefPreview.js +99 -0
  66. package/build/link/preview/HrefPreview.js.map +1 -0
  67. package/build/link/preview/LinkPreviewContext.d.ts +7 -0
  68. package/build/link/preview/LinkPreviewContext.d.ts.map +1 -0
  69. package/build/link/preview/LinkPreviewContext.js +21 -0
  70. package/build/link/preview/LinkPreviewContext.js.map +1 -0
  71. package/build/link/preview/PreviewRouteContext.d.ts +22 -0
  72. package/build/link/preview/PreviewRouteContext.d.ts.map +1 -0
  73. package/build/link/preview/PreviewRouteContext.js +28 -0
  74. package/build/link/preview/PreviewRouteContext.js.map +1 -0
  75. package/build/link/preview/native.d.ts +31 -0
  76. package/build/link/preview/native.d.ts.map +1 -0
  77. package/build/link/preview/native.js +53 -0
  78. package/build/link/preview/native.js.map +1 -0
  79. package/build/link/preview/useNextScreenId.d.ts +3 -0
  80. package/build/link/preview/useNextScreenId.d.ts.map +1 -0
  81. package/build/link/preview/useNextScreenId.js +42 -0
  82. package/build/link/preview/useNextScreenId.js.map +1 -0
  83. package/build/link/useLinkHooks.d.ts +3 -2
  84. package/build/link/useLinkHooks.d.ts.map +1 -1
  85. package/build/link/useLinkHooks.js +1 -0
  86. package/build/link/useLinkHooks.js.map +1 -1
  87. package/build/modal/Modal.d.ts +82 -0
  88. package/build/modal/Modal.d.ts.map +1 -0
  89. package/build/modal/Modal.js +82 -0
  90. package/build/modal/Modal.js.map +1 -0
  91. package/build/modal/ModalComponent.d.ts +7 -0
  92. package/build/modal/ModalComponent.d.ts.map +1 -0
  93. package/build/modal/ModalComponent.js +10 -0
  94. package/build/modal/ModalComponent.js.map +1 -0
  95. package/build/modal/ModalContext.d.ts +22 -0
  96. package/build/modal/ModalContext.d.ts.map +1 -0
  97. package/build/modal/ModalContext.js +150 -0
  98. package/build/modal/ModalContext.js.map +1 -0
  99. package/build/typed-routes/generate.js +1 -1
  100. package/build/typed-routes/generate.js.map +1 -1
  101. package/build/useFocusEffect.d.ts.map +1 -1
  102. package/build/useFocusEffect.js +5 -3
  103. package/build/useFocusEffect.js.map +1 -1
  104. package/build/useScreens.js +1 -1
  105. package/build/useScreens.js.map +1 -1
  106. package/build/utils/stack.d.ts +5 -0
  107. package/build/utils/stack.d.ts.map +1 -0
  108. package/build/utils/stack.js +10 -0
  109. package/build/utils/stack.js.map +1 -0
  110. package/build/views/Screen.d.ts.map +1 -1
  111. package/build/views/Screen.js +13 -40
  112. package/build/views/Screen.js.map +1 -1
  113. package/build/views/Unmatched.d.ts.map +1 -1
  114. package/build/views/Unmatched.js +9 -3
  115. package/build/views/Unmatched.js.map +1 -1
  116. package/build/views/useSafeLayoutEffect.d.ts +3 -0
  117. package/build/views/useSafeLayoutEffect.d.ts.map +1 -0
  118. package/build/views/useSafeLayoutEffect.js +6 -0
  119. package/build/views/useSafeLayoutEffect.js.map +1 -0
  120. package/expo-module.config.json +1 -1
  121. package/ios/ExpoHead.podspec +1 -1
  122. package/ios/LinkPreview/LinkPreviewNativeActionView.swift +12 -0
  123. package/ios/LinkPreview/LinkPreviewNativeModule.swift +50 -0
  124. package/ios/LinkPreview/LinkPreviewNativeNavigation.h +18 -0
  125. package/ios/LinkPreview/LinkPreviewNativeNavigation.mm +108 -0
  126. package/ios/LinkPreview/LinkPreviewNativePreviewView.swift +15 -0
  127. package/ios/LinkPreview/LinkPreviewNativeTriggerView.swift +9 -0
  128. package/ios/LinkPreview/LinkPreviewNativeView.swift +193 -0
  129. package/package.json +6 -6
  130. package/plugin/options.json +29 -1
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.HrefPreview = HrefPreview;
5
+ const native_1 = require("@react-navigation/native");
6
+ const react_1 = require("react");
7
+ const PreviewRouteContext_1 = require("./PreviewRouteContext");
8
+ const router_store_1 = require("../../global-state/router-store");
9
+ const useNavigation_1 = require("../../useNavigation");
10
+ const useScreens_1 = require("../../useScreens");
11
+ const linking_1 = require("../linking");
12
+ const constants_1 = require("../../constants");
13
+ function HrefPreview({ href }) {
14
+ const navigation = (0, useNavigation_1.useNavigation)();
15
+ const { routeNode, params, state } = getParamsAndNodeFromHref(href);
16
+ const path = state ? (0, linking_1.getPathFromState)(state) : undefined;
17
+ const value = (0, react_1.useMemo)(() => ({
18
+ params,
19
+ pathname: href.toString(),
20
+ segments: path?.split('/').filter(Boolean) || [],
21
+ }), [params, href]);
22
+ // This can happen in a theoretical case where the state is not yet initialized or is incorrectly initialized.
23
+ // It also check ensures TypeScript type safety.
24
+ if (!routeNode) {
25
+ return null;
26
+ }
27
+ const Component = (0, useScreens_1.getQualifiedRouteComponent)(routeNode);
28
+ return (<PreviewRouteContext_1.PreviewRouteContext value={value}>
29
+ {/* Using NavigationContext to override useNavigation */}
30
+ <native_1.NavigationContext value={navigationPropWithWarnings}>
31
+ <Component navigation={navigation}/>
32
+ </native_1.NavigationContext>
33
+ </PreviewRouteContext_1.PreviewRouteContext>);
34
+ }
35
+ function getParamsAndNodeFromHref(href) {
36
+ const hrefState = router_store_1.store.getStateForHref(href);
37
+ if (hrefState?.routes[0] && hrefState.routes[0].name !== constants_1.INTERNAL_SLOT_NAME) {
38
+ const error = `Expo Router Error: Expected navigation state to begin with a ${constants_1.INTERNAL_SLOT_NAME} route`;
39
+ if (process.env.NODE_ENV !== 'production') {
40
+ throw new Error(error);
41
+ }
42
+ else {
43
+ console.warn(error);
44
+ }
45
+ }
46
+ // Assuming that root of the state is __root
47
+ const initialState = hrefState?.routes[0]?.state;
48
+ let state = initialState;
49
+ let routeNode = router_store_1.store.routeNode;
50
+ const params = {};
51
+ while (state && routeNode) {
52
+ const route = state.routes[state.index || state.routes.length - 1];
53
+ Object.assign(params, route.params);
54
+ state = route.state;
55
+ routeNode = routeNode.children.find((child) => child.route === route.name);
56
+ }
57
+ return { params, routeNode, state: initialState };
58
+ }
59
+ const displayWarningForProp = (prop) => {
60
+ if (process.env.NODE_ENV !== 'production') {
61
+ console.warn(`navigation.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`);
62
+ }
63
+ };
64
+ const createNOOPWithWarning = (prop) => () => displayWarningForProp(prop);
65
+ const navigationPropWithWarnings = {
66
+ setParams: createNOOPWithWarning('setParams'),
67
+ setOptions: createNOOPWithWarning('setOptions'),
68
+ addListener: (() => () => { }),
69
+ removeListener: () => { },
70
+ isFocused: () => true,
71
+ canGoBack: () => false,
72
+ dispatch: createNOOPWithWarning('dispatch'),
73
+ navigate: createNOOPWithWarning('navigate'),
74
+ goBack: createNOOPWithWarning('goBack'),
75
+ reset: createNOOPWithWarning('reset'),
76
+ push: createNOOPWithWarning('push'),
77
+ pop: createNOOPWithWarning('pop'),
78
+ popToTop: createNOOPWithWarning('popToTop'),
79
+ navigateDeprecated: createNOOPWithWarning('navigateDeprecated'),
80
+ preload: createNOOPWithWarning('preload'),
81
+ getId: () => {
82
+ displayWarningForProp('getId');
83
+ return '';
84
+ },
85
+ // @ts-expect-error
86
+ getParent: createNOOPWithWarning('getParent'),
87
+ getState: () => {
88
+ displayWarningForProp('getState');
89
+ return {
90
+ key: '',
91
+ index: 0,
92
+ routeNames: [],
93
+ routes: [],
94
+ type: 'stack',
95
+ stale: false,
96
+ };
97
+ },
98
+ };
99
+ //# sourceMappingURL=HrefPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HrefPreview.js","sourceRoot":"","sources":["../../../src/link/preview/HrefPreview.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAkBb,kCA+BC;AA/CD,qDAIkC;AAClC,iCAAgC;AAEhC,+DAA4D;AAE5D,kEAAwD;AAExD,uDAAoD;AACpD,iDAA8D;AAC9D,wCAA8C;AAC9C,+CAAqD;AAErD,SAAgB,WAAW,CAAC,EAAE,IAAI,EAAkB;IAClD,MAAM,UAAU,GAAG,IAAA,6BAAa,GAAE,CAAC;IACnC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAEpE,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAA,0BAAgB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEzD,MAAM,KAAK,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;QACzB,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;KACjD,CAAC,EACF,CAAC,MAAM,EAAE,IAAI,CAAC,CACf,CAAC;IAEF,8GAA8G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,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC;IACrC,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC;IACnC,GAAG,EAAE,qBAAqB,CAAC,KAAK,CAAC;IACjC,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;IAC3C,kBAAkB,EAAE,qBAAqB,CAAC,oBAAoB,CAAC;IAC/D,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC;IACzC,KAAK,EAAE,GAAG,EAAE;QACV,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,mBAAmB;IACnB,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC;IAC7C,QAAQ,EAAE,GAAG,EAAE;QACb,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO;YACL,GAAG,EAAE,EAAE;YACP,KAAK,EAAE,CAAC;YACR,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContext,\n type NavigationProp,\n type ParamListBase,\n} from '@react-navigation/native';\nimport { useMemo } from 'react';\n\nimport { PreviewRouteContext } from './PreviewRouteContext';\nimport { RouteNode } from '../../Route';\nimport { store } from '../../global-state/router-store';\nimport { Href, UnknownOutputParams } from '../../types';\nimport { useNavigation } from '../../useNavigation';\nimport { getQualifiedRouteComponent } from '../../useScreens';\nimport { getPathFromState } from '../linking';\nimport { INTERNAL_SLOT_NAME } from '../../constants';\n\nexport function HrefPreview({ href }: { href: Href }) {\n const navigation = useNavigation();\n const { routeNode, params, state } = getParamsAndNodeFromHref(href);\n\n const path = state ? getPathFromState(state) : undefined;\n\n const value = useMemo(\n () => ({\n params,\n pathname: href.toString(),\n segments: path?.split('/').filter(Boolean) || [],\n }),\n [params, href]\n );\n\n // This can happen in a theoretical case where the state is not yet initialized or is incorrectly initialized.\n // It also check ensures TypeScript type safety.\n if (!routeNode) {\n return null;\n }\n\n const Component = getQualifiedRouteComponent(routeNode);\n\n return (\n <PreviewRouteContext value={value}>\n {/* Using NavigationContext to override useNavigation */}\n <NavigationContext value={navigationPropWithWarnings}>\n <Component navigation={navigation} />\n </NavigationContext>\n </PreviewRouteContext>\n );\n}\n\nfunction getParamsAndNodeFromHref(href: Href) {\n const hrefState = store.getStateForHref(href as any);\n if (hrefState?.routes[0] && hrefState.routes[0].name !== INTERNAL_SLOT_NAME) {\n const error = `Expo Router Error: Expected navigation state to begin with a ${INTERNAL_SLOT_NAME} route`;\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(error);\n } else {\n console.warn(error);\n }\n }\n // Assuming that root of the state is __root\n const initialState = hrefState?.routes[0]?.state;\n let state = initialState;\n let routeNode: RouteNode | undefined | null = store.routeNode;\n\n const params: UnknownOutputParams = {};\n\n while (state && routeNode) {\n const route = state.routes[state.index || state.routes.length - 1];\n Object.assign(params, route.params);\n state = route.state;\n routeNode = routeNode.children.find((child) => child.route === route.name);\n }\n\n return { params, routeNode, state: initialState };\n}\n\nconst displayWarningForProp = (prop: string) => {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `navigation.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`\n );\n }\n};\n\nconst createNOOPWithWarning = (prop: string) => () => displayWarningForProp(prop);\n\nconst navigationPropWithWarnings: NavigationProp<ParamListBase> = {\n setParams: createNOOPWithWarning('setParams'),\n setOptions: createNOOPWithWarning('setOptions'),\n addListener: (() => () => {}) as NavigationProp<ParamListBase>['addListener'],\n removeListener: () => {},\n isFocused: () => true,\n canGoBack: () => false,\n dispatch: createNOOPWithWarning('dispatch'),\n navigate: createNOOPWithWarning('navigate'),\n goBack: createNOOPWithWarning('goBack'),\n reset: createNOOPWithWarning('reset'),\n push: createNOOPWithWarning('push'),\n pop: createNOOPWithWarning('pop'),\n popToTop: createNOOPWithWarning('popToTop'),\n navigateDeprecated: createNOOPWithWarning('navigateDeprecated'),\n preload: createNOOPWithWarning('preload'),\n getId: () => {\n displayWarningForProp('getId');\n return '';\n },\n // @ts-expect-error\n getParent: createNOOPWithWarning('getParent'),\n getState: () => {\n displayWarningForProp('getState');\n return {\n key: '',\n index: 0,\n routeNames: [],\n routes: [],\n type: 'stack',\n stale: false,\n };\n },\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare function LinkPreviewContextProvider({ children }: PropsWithChildren): import("react").JSX.Element;
3
+ export declare const useLinkPreviewContext: () => {
4
+ isPreviewOpen: boolean;
5
+ setIsPreviewOpen: (isOpen: boolean) => void;
6
+ };
7
+ //# sourceMappingURL=LinkPreviewContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkPreviewContext.d.ts","sourceRoot":"","sources":["../../../src/link/preview/LinkPreviewContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,iBAAiB,EAAiB,MAAM,OAAO,CAAC;AAUxE,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,+BAOzE;AAED,eAAO,MAAM,qBAAqB;mBAfb,OAAO;sBACJ,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI;CAsBhD,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLinkPreviewContext = void 0;
4
+ exports.LinkPreviewContextProvider = LinkPreviewContextProvider;
5
+ const react_1 = require("react");
6
+ const LinkPreviewContext = (0, react_1.createContext)(undefined);
7
+ function LinkPreviewContextProvider({ children }) {
8
+ const [isPreviewOpen, setIsPreviewOpen] = (0, react_1.useState)(false);
9
+ return (<LinkPreviewContext.Provider value={{ isPreviewOpen, setIsPreviewOpen }}>
10
+ {children}
11
+ </LinkPreviewContext.Provider>);
12
+ }
13
+ const useLinkPreviewContext = () => {
14
+ const context = (0, react_1.use)(LinkPreviewContext);
15
+ if (context == null) {
16
+ throw new Error('useLinkPreviewContext must be used within a LinkPreviewContextProvider. This is likely a bug in Expo Router.');
17
+ }
18
+ return context;
19
+ };
20
+ exports.useLinkPreviewContext = useLinkPreviewContext;
21
+ //# sourceMappingURL=LinkPreviewContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkPreviewContext.js","sourceRoot":"","sources":["../../../src/link/preview/LinkPreviewContext.tsx"],"names":[],"mappings":";;;AAUA,gEAOC;AAjBD,iCAAwE;AAExE,MAAM,kBAAkB,GAAG,IAAA,qBAAa,EAMtC,SAAS,CAAC,CAAC;AAEb,SAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAqB;IACxE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,CACL,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC,CACtE;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAC/B,CAAC;AACJ,CAAC;AAEM,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,MAAM,OAAO,GAAG,IAAA,WAAG,EAAC,kBAAkB,CAAC,CAAC;IACxC,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,8GAA8G,CAC/G,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,qBAAqB,yBAQhC","sourcesContent":["import { createContext, PropsWithChildren, use, useState } from 'react';\n\nconst LinkPreviewContext = createContext<\n | {\n isPreviewOpen: boolean;\n setIsPreviewOpen: (isOpen: boolean) => void;\n }\n | undefined\n>(undefined);\n\nexport function LinkPreviewContextProvider({ children }: PropsWithChildren) {\n const [isPreviewOpen, setIsPreviewOpen] = useState(false);\n return (\n <LinkPreviewContext.Provider value={{ isPreviewOpen, setIsPreviewOpen }}>\n {children}\n </LinkPreviewContext.Provider>\n );\n}\n\nexport const useLinkPreviewContext = () => {\n const context = use(LinkPreviewContext);\n if (context == null) {\n throw new Error(\n 'useLinkPreviewContext must be used within a LinkPreviewContextProvider. This is likely a bug in Expo Router.'\n );\n }\n return context;\n};\n"]}
@@ -0,0 +1,22 @@
1
+ import type { UnknownOutputParams } from '../../types';
2
+ export interface PreviewRouteContextType {
3
+ params: UnknownOutputParams;
4
+ pathname: string;
5
+ segments: string[];
6
+ }
7
+ export declare const PreviewRouteContext: import("react").Context<PreviewRouteContextType | undefined>;
8
+ type UsePreviewInfo = {
9
+ isPreview: boolean;
10
+ } & Partial<PreviewRouteContextType>;
11
+ /**
12
+ * Returns information about the current route if it is displayed in preview mode.
13
+ */
14
+ export declare function usePreviewInfo(): UsePreviewInfo;
15
+ /**
16
+ * Hook to determine if the current route is rendered inside a preview.
17
+ *
18
+ * @returns {boolean} - True if the current route is rendered inside a preview, false otherwise.
19
+ */
20
+ export declare function useIsPreview(): boolean;
21
+ export {};
22
+ //# sourceMappingURL=PreviewRouteContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewRouteContext.d.ts","sourceRoot":"","sources":["../../../src/link/preview/PreviewRouteContext.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,mBAAmB,8DAAgE,CAAC;AAEjG,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEhF;;GAEG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAM/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAGtC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PreviewRouteContext = void 0;
5
+ exports.usePreviewInfo = usePreviewInfo;
6
+ exports.useIsPreview = useIsPreview;
7
+ const react_1 = require("react");
8
+ exports.PreviewRouteContext = (0, react_1.createContext)(undefined);
9
+ /**
10
+ * Returns information about the current route if it is displayed in preview mode.
11
+ */
12
+ function usePreviewInfo() {
13
+ const paramsContext = (0, react_1.use)(exports.PreviewRouteContext);
14
+ return {
15
+ isPreview: !!paramsContext,
16
+ ...paramsContext,
17
+ };
18
+ }
19
+ /**
20
+ * Hook to determine if the current route is rendered inside a preview.
21
+ *
22
+ * @returns {boolean} - True if the current route is rendered inside a preview, false otherwise.
23
+ */
24
+ function useIsPreview() {
25
+ const { isPreview } = usePreviewInfo();
26
+ return isPreview;
27
+ }
28
+ //# sourceMappingURL=PreviewRouteContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewRouteContext.js","sourceRoot":"","sources":["../../../src/link/preview/PreviewRouteContext.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAmBb,wCAMC;AAOD,oCAGC;AAjCD,iCAA2C;AAU9B,QAAA,mBAAmB,GAAG,IAAA,qBAAa,EAAsC,SAAS,CAAC,CAAC;AAIjG;;GAEG;AACH,SAAgB,cAAc;IAC5B,MAAM,aAAa,GAAG,IAAA,WAAG,EAAC,2BAAmB,CAAC,CAAC;IAC/C,OAAO;QACL,SAAS,EAAE,CAAC,CAAC,aAAa;QAC1B,GAAG,aAAa;KACjB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY;IAC1B,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["'use client';\n\nimport { createContext, use } from 'react';\n\nimport type { UnknownOutputParams } from '../../types';\n\nexport interface PreviewRouteContextType {\n params: UnknownOutputParams;\n pathname: string;\n segments: string[];\n}\n\nexport const PreviewRouteContext = createContext<PreviewRouteContextType | undefined>(undefined);\n\ntype UsePreviewInfo = { isPreview: boolean } & Partial<PreviewRouteContextType>;\n\n/**\n * Returns information about the current route if it is displayed in preview mode.\n */\nexport function usePreviewInfo(): UsePreviewInfo {\n const paramsContext = use(PreviewRouteContext);\n return {\n isPreview: !!paramsContext,\n ...paramsContext,\n };\n}\n\n/**\n * Hook to determine if the current route is rendered inside a preview.\n *\n * @returns {boolean} - True if the current route is rendered inside a preview, false otherwise.\n */\nexport function useIsPreview(): boolean {\n const { isPreview } = usePreviewInfo();\n return isPreview;\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { type ViewProps } from 'react-native';
2
+ export interface NativeLinkPreviewActionProps {
3
+ title: string;
4
+ id: string;
5
+ }
6
+ export declare function NativeLinkPreviewAction(props: NativeLinkPreviewActionProps): import("react").JSX.Element | null;
7
+ export type NativeLinkPreviewTriggerProps = ViewProps;
8
+ export declare function NativeLinkPreviewTrigger(props: NativeLinkPreviewTriggerProps): import("react").JSX.Element | null;
9
+ export interface NativeLinkPreviewProps extends ViewProps {
10
+ nextScreenId: string | undefined;
11
+ onActionSelected?: (event: {
12
+ nativeEvent: {
13
+ id: string;
14
+ };
15
+ }) => void;
16
+ onWillPreviewOpen?: () => void;
17
+ onDidPreviewOpen?: () => void;
18
+ onPreviewWillClose?: () => void;
19
+ onPreviewDidClose?: () => void;
20
+ onPreviewTapped?: () => void;
21
+ children: React.ReactNode;
22
+ }
23
+ export declare function NativeLinkPreview(props: NativeLinkPreviewProps): import("react").JSX.Element | null;
24
+ export interface NativeLinkPreviewContentProps extends ViewProps {
25
+ preferredContentSize?: {
26
+ width: number;
27
+ height: number;
28
+ };
29
+ }
30
+ export declare function NativeLinkPreviewContent(props: NativeLinkPreviewContentProps): import("react").JSX.Element | null;
31
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/link/preview/native.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpE,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ;AAKD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,sCAK1E;AAID,MAAM,MAAM,6BAA6B,GAAG,SAAS,CAAC;AAKtD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,sCAK5E;AAID,MAAM,WAAW,sBAAuB,SAAQ,SAAS;IACvD,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI,CAAC;IACpE,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAKD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,sCAK9D;AAID,MAAM,WAAW,6BAA8B,SAAQ,SAAS;IAC9D,oBAAoB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D;AAMD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,sCAW5E"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.NativeLinkPreviewAction = NativeLinkPreviewAction;
5
+ exports.NativeLinkPreviewTrigger = NativeLinkPreviewTrigger;
6
+ exports.NativeLinkPreview = NativeLinkPreview;
7
+ exports.NativeLinkPreviewContent = NativeLinkPreviewContent;
8
+ const expo_1 = require("expo");
9
+ const react_native_1 = require("react-native");
10
+ const LinkPreviewNativeActionView = react_native_1.Platform.OS === 'ios'
11
+ ? (0, expo_1.requireNativeView)('ExpoRouterNativeLinkPreview', 'LinkPreviewNativeActionView')
12
+ : null;
13
+ function NativeLinkPreviewAction(props) {
14
+ if (!LinkPreviewNativeActionView) {
15
+ return null;
16
+ }
17
+ return <LinkPreviewNativeActionView {...props}/>;
18
+ }
19
+ const NativeLinkPreviewTriggerView = react_native_1.Platform.OS === 'ios'
20
+ ? (0, expo_1.requireNativeView)('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewTrigger')
21
+ : null;
22
+ function NativeLinkPreviewTrigger(props) {
23
+ if (!NativeLinkPreviewTriggerView) {
24
+ return null;
25
+ }
26
+ return <NativeLinkPreviewTriggerView {...props}/>;
27
+ }
28
+ const NativeLinkPreviewView = react_native_1.Platform.OS === 'ios'
29
+ ? (0, expo_1.requireNativeView)('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewView')
30
+ : null;
31
+ function NativeLinkPreview(props) {
32
+ if (!NativeLinkPreviewView) {
33
+ return null;
34
+ }
35
+ return <NativeLinkPreviewView {...props}/>;
36
+ }
37
+ const NativeLinkPreviewContentView = react_native_1.Platform.OS === 'ios'
38
+ ? (0, expo_1.requireNativeView)('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewContentView')
39
+ : null;
40
+ function NativeLinkPreviewContent(props) {
41
+ if (!NativeLinkPreviewContentView) {
42
+ return null;
43
+ }
44
+ const style = react_native_1.StyleSheet.flatten([
45
+ props.style,
46
+ {
47
+ position: 'absolute',
48
+ },
49
+ ]);
50
+ return <NativeLinkPreviewContentView {...props} style={style}/>;
51
+ }
52
+ // #endregion
53
+ //# sourceMappingURL=native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A4B,GAChC,uBAAQ,CAAC,EAAE,KAAK,KAAK;IACnB,CAAC,CAAC,IAAA,wBAAiB,EAAC,6BAA6B,EAAE,8BAA8B,CAAC;IAClF,CAAC,CAAC,IAAI,CAAC;AAEX,SAAgB,wBAAwB,CAAC,KAAoC;IAC3E,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,yBAAU,CAAC,OAAO,CAAC;QAC/B,KAAK,CAAC,KAAK;QACX;YACE,QAAQ,EAAE,UAAU;SACZ;KACX,CAAC,CAAC;IACH,OAAO,CAAC,4BAA4B,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAG,CAAC;AACnE,CAAC;AACD,aAAa","sourcesContent":["'use client';\n\nimport { requireNativeView } from 'expo';\nimport { Platform, StyleSheet, type ViewProps } from 'react-native';\n\n// #region Action View\nexport interface NativeLinkPreviewActionProps {\n title: string;\n id: string;\n}\nconst LinkPreviewNativeActionView: React.ComponentType<NativeLinkPreviewActionProps> | null =\n Platform.OS === 'ios'\n ? requireNativeView('ExpoRouterNativeLinkPreview', 'LinkPreviewNativeActionView')\n : null;\nexport function NativeLinkPreviewAction(props: NativeLinkPreviewActionProps) {\n if (!LinkPreviewNativeActionView) {\n return null;\n }\n return <LinkPreviewNativeActionView {...props} />;\n}\n// #endregion\n\n// #region Trigger View\nexport type NativeLinkPreviewTriggerProps = ViewProps;\nconst NativeLinkPreviewTriggerView: React.ComponentType<NativeLinkPreviewTriggerProps> | null =\n Platform.OS === 'ios'\n ? requireNativeView('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewTrigger')\n : null;\nexport function NativeLinkPreviewTrigger(props: NativeLinkPreviewTriggerProps) {\n if (!NativeLinkPreviewTriggerView) {\n return null;\n }\n return <NativeLinkPreviewTriggerView {...props} />;\n}\n// #endregion\n\n// #region Preview View\nexport interface NativeLinkPreviewProps extends ViewProps {\n nextScreenId: string | undefined;\n onActionSelected?: (event: { nativeEvent: { id: string } }) => void;\n onWillPreviewOpen?: () => void;\n onDidPreviewOpen?: () => void;\n onPreviewWillClose?: () => void;\n onPreviewDidClose?: () => void;\n onPreviewTapped?: () => void;\n children: React.ReactNode;\n}\nconst NativeLinkPreviewView: React.ComponentType<NativeLinkPreviewProps> | null =\n Platform.OS === 'ios'\n ? requireNativeView('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewView')\n : null;\nexport function NativeLinkPreview(props: NativeLinkPreviewProps) {\n if (!NativeLinkPreviewView) {\n return null;\n }\n return <NativeLinkPreviewView {...props} />;\n}\n// #endregion\n\n// #region Preview Content View\nexport interface NativeLinkPreviewContentProps extends ViewProps {\n preferredContentSize?: { width: number; height: number };\n}\nconst NativeLinkPreviewContentView: React.ComponentType<NativeLinkPreviewContentProps> | null =\n Platform.OS === 'ios'\n ? requireNativeView('ExpoRouterNativeLinkPreview', 'NativeLinkPreviewContentView')\n : null;\n\nexport function NativeLinkPreviewContent(props: NativeLinkPreviewContentProps) {\n if (!NativeLinkPreviewContentView) {\n return null;\n }\n const style = StyleSheet.flatten([\n props.style,\n {\n position: 'absolute',\n } as const,\n ]);\n return <NativeLinkPreviewContentView {...props} style={style} />;\n}\n// #endregion\n"]}
@@ -0,0 +1,3 @@
1
+ import { Href } from '../../types';
2
+ export declare function useNextScreenId(): [string | undefined, (href: Href) => void];
3
+ //# sourceMappingURL=useNextScreenId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNextScreenId.d.ts","sourceRoot":"","sources":["../../../src/link/preview/useNextScreenId.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,wBAAgB,eAAe,IAAI,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAQ5E"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useNextScreenId = useNextScreenId;
4
+ const react_1 = require("react");
5
+ const router_store_1 = require("../../global-state/router-store");
6
+ const href_1 = require("../href");
7
+ function useNextScreenId() {
8
+ const [internalNextScreenId, internalSetNextScreenId] = (0, react_1.useState)();
9
+ const setNextScreenId = (0, react_1.useCallback)((href) => {
10
+ const preloadedRoute = getPreloadedRouteFromRootStateByHref(href);
11
+ const routeKey = preloadedRoute?.key;
12
+ internalSetNextScreenId(routeKey);
13
+ }, []);
14
+ return [internalNextScreenId, setNextScreenId];
15
+ }
16
+ function getPreloadedRouteFromRootStateByHref(href) {
17
+ const rootState = router_store_1.store.state;
18
+ let hrefState = router_store_1.store.getStateForHref((0, href_1.resolveHref)(href));
19
+ let state = rootState;
20
+ while (hrefState && state) {
21
+ const currentHrefRoute = hrefState.routes[0];
22
+ const currentStateRoute = currentHrefRoute
23
+ ? state.routes.find((r) => r.name === currentHrefRoute.name)
24
+ : undefined;
25
+ if (!currentStateRoute) {
26
+ // Only checking stack, because it is the only native navigator.
27
+ if (state.type === 'stack') {
28
+ const stackState = state;
29
+ // Sometimes the route is stored inside params
30
+ const innerRoute = currentHrefRoute.state ? currentHrefRoute.state.routes[0] : undefined;
31
+ const preloadedRoute = stackState.preloadedRoutes.find((route) => route.name === currentHrefRoute.name &&
32
+ (!innerRoute ||
33
+ (route.params && 'screen' in route.params && route.params.screen === innerRoute.name)));
34
+ return preloadedRoute;
35
+ }
36
+ }
37
+ hrefState = currentHrefRoute?.state;
38
+ state = currentStateRoute?.state;
39
+ }
40
+ return undefined;
41
+ }
42
+ //# sourceMappingURL=useNextScreenId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNextScreenId.js","sourceRoot":"","sources":["../../../src/link/preview/useNextScreenId.ts"],"names":[],"mappings":";;AAWA,0CAQC;AAdD,iCAA8C;AAE9C,kEAAmF;AAEnF,kCAAsC;AAEtC,SAAgB,eAAe;IAC7B,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC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AAI,CACpD,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC,IAAI;oBACpC,CAAC,CAAC,UAAU;wBACV,CAAC,KAAK,CAAC,MAAM,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC,CAC3F,CAAC;gBACF,OAAO,cAAc,CAAC;YACxB,CAAC;QACH,CAAC;QACD,SAAS,GAAG,gBAAgB,EAAE,KAAK,CAAC;QACpC,KAAK,GAAG,iBAAiB,EAAE,KAAK,CAAC;IACnC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n ParamListBase,\n StackNavigationState,\n type NavigationRoute,\n} from '@react-navigation/native';\nimport { useCallback, useState } from 'react';\n\nimport { store, type ReactNavigationState } from '../../global-state/router-store';\nimport { Href } from '../../types';\nimport { resolveHref } from '../href';\n\nexport function useNextScreenId(): [string | undefined, (href: Href) => void] {\n const [internalNextScreenId, internalSetNextScreenId] = useState<string | undefined>();\n const setNextScreenId = useCallback((href: Href): void => {\n const preloadedRoute = getPreloadedRouteFromRootStateByHref(href);\n const routeKey = preloadedRoute?.key;\n internalSetNextScreenId(routeKey);\n }, []);\n return [internalNextScreenId, setNextScreenId];\n}\n\nfunction getPreloadedRouteFromRootStateByHref(\n href: Href\n): NavigationRoute<ParamListBase, string> | undefined {\n const rootState = store.state;\n let hrefState = store.getStateForHref(resolveHref(href));\n let state: ReactNavigationState | undefined = rootState;\n while (hrefState && state) {\n const currentHrefRoute = hrefState.routes[0];\n const currentStateRoute = currentHrefRoute\n ? state.routes.find((r) => r.name === currentHrefRoute.name)\n : undefined;\n\n if (!currentStateRoute) {\n // Only checking stack, because it is the only native navigator.\n if (state.type === 'stack') {\n const stackState = state as StackNavigationState<ParamListBase>;\n // Sometimes the route is stored inside params\n const innerRoute = currentHrefRoute.state ? currentHrefRoute.state.routes[0] : undefined;\n const preloadedRoute = stackState.preloadedRoutes.find(\n (route) =>\n route.name === currentHrefRoute.name &&\n (!innerRoute ||\n (route.params && 'screen' in route.params && route.params.screen === innerRoute.name))\n );\n return preloadedRoute;\n }\n }\n hrefState = currentHrefRoute?.state;\n state = currentStateRoute?.state;\n }\n return undefined;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { MouseEvent } from 'react';
2
- import { TextProps, GestureResponderEvent } from 'react-native';
1
+ import { MouseEvent, type Ref } from 'react';
2
+ import { TextProps, GestureResponderEvent, type Text } from 'react-native';
3
3
  import { Href } from '../types';
4
4
  import { SingularOptions } from '../useScreens';
5
5
  /**
@@ -206,6 +206,7 @@ export interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {
206
206
  * Prefetches the route when the component is rendered on a focused screen.
207
207
  */
208
208
  prefetch?: boolean;
209
+ ref?: Ref<Text>;
209
210
  }
210
211
  export declare function useInteropClassName(props: {
211
212
  style?: TextProps['style'];
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkHooks.d.ts","sourceRoot":"","sources":["../../src/link/useLinkHooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,UAAU,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAErE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC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ACH,mBAAmB,CAAC,EAAE,eAAe,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;CACjB;AAGD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;;;wBAoB5F;AAED,eAAO,MAAM,YAAY,UACf,OAAO,CAAC,SAAS,CAAC,KAAK;IAAE,SAAS,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,OAAO,CAAC,SAAS,CAoBtE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.useHrefAttrs = void 0;
4
5
  exports.useInteropClassName = useInteropClassName;
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkHooks.js","sourceRoot":"","sources":["../../src/link/useLinkHooks.ts"],"names":[],"mappings":";;;AAqOA,kDAoBC;AAzPD,wFAAwF;AACxF,mCAAmC;AACnC,iCAA4C;AAC5C,+CAA0E;AAiO1E,qDAAqD;AACrD,SAAgB,mBAAmB,CAAC,KAAyD;IAC3F,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,sDAAsD;IACtD,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,KAAK,CAAC;QACrB,CAAC;QACD,MAAM,QAAQ,GAAG;YACf,KAAK,EAAE,IAAI;YACX,qBAAqB,EAAE,KAAK,CAAC,SAAS;SACvC,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AACrC,CAAC;AAEY,QAAA,YAAY,GAAG,uBAAQ,CAAC,MAAM,CAEzC;IACA,GAAG,EAAE,SAAS,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAsB;QAC/E,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;YAClB,MAAM,SAAS,GAAG;gBAChB,GAAG;gBACH,MAAM;gBACN,QAAQ;aACT,CAAC;YACF,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO;gBACL,SAAS;aACV,CAAC;QACJ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,SAAS,YAAY;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { useMemo, MouseEvent } from 'react';\nimport { TextProps, GestureResponderEvent, Platform } from 'react-native';\n\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\n\n// docsMissing\n/**\n * @platform web\n */\nexport type WebAnchorProps = {\n /**\n * Specifies where to open the [`href`](#href).\n *\n * - **_self**: the current tab.\n * - **_blank**: opens in a new tab or window.\n * - **_parent**: opens in the parent browsing context. If no parent, defaults to **_self**.\n * - **_top**: opens in the highest browsing context ancestor. If no ancestors,\n * defaults to **_self**.\n *\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @default '_self'\n *\n * @example\n * ```jsx\n * <Link href=\"https://expo.dev\" target=\"_blank\">Go to Expo in new tab</Link>\n * ```\n */\n target?: '_self' | '_blank' | '_parent' | '_top' | (string & object);\n\n /**\n * Specifies the relationship between the [`href`](#href) and the current route.\n *\n * Common values:\n * - **nofollow**: Indicates to search engines that they should not follow the `href`.\n * This is often used for user-generated content or links that should not influence\n * search engine rankings.\n * - **noopener**: Suggests that the `href` should not have access to the opening\n * window's `window.opener` object, which is a security measure to prevent potentially\n * harmful behavior in cases of links that open new tabs or windows.\n * - **noreferrer**: Requests that the browser does not send the `Referer` HTTP header\n * when navigating to the `href`. This can enhance user privacy.\n *\n * The `rel` property is primarily used for informational and instructive purposes, helping browsers and web\n * crawlers make better decisions about how to handle and interpret the links on a web\n * page. It is important to use appropriate `rel` values to ensure that links behave as intended and adhere\n * to best practices for web development and SEO (Search Engine Optimization).\n *\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @example\n * ```jsx\n * <Link href=\"https://expo.dev\" rel=\"nofollow\">Go to Expo</Link>\n * ```\n */\n rel?: string;\n\n /**\n * Specifies that the [`href`](#href) should be downloaded when the user clicks on the\n * link, instead of navigating to it. It is typically used for links that point to\n * files that the user should download, such as PDFs, images, documents, and more.\n *\n * The value of the `download` property, which represents the filename for the\n * downloaded file. This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @example\n * ```jsx\n * <Link href=\"/image.jpg\" download=\"my-image.jpg\">Download image</Link>\n * ```\n */\n download?: string;\n};\n\n// @docsMissing\nexport interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {\n /**\n * The path of the route to navigate to. It can either be:\n * - **string**: A full path like `/profile/settings` or a relative path like `../settings`.\n * - **object**: An object with a `pathname` and optional `params`. The `pathname` can be\n * a full path like `/profile/settings` or a relative path like `../settings`. The\n * params can be an object of key-value pairs.\n *\n * @example\n * ```tsx Dynamic\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link href=\"/about\">About</Link>\n * <Link\n * href={{\n * pathname: '/user/[id]',\n * params: { id: 'bacon' }\n * }}>\n * View user\n * </Link>\n * </View>\n * );\n *}\n * ```\n */\n href: Href;\n\n // TODO(EvanBacon): This may need to be extracted for React Native style support.\n /**\n * Used to customize the `Link` component. It will forward all props to the\n * first child of the `Link`. Note that the child component must accept\n * `onPress` or `onClick` props. The `href` and `role` are also\n * passed to the child.\n *\n * @example\n * ```tsx\n * import { Link } from 'expo-router';\n * import { Pressable, Text } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link href=\"/home\" asChild>\n * <Pressable>\n * <Text>Home</Text>\n * </Pressable>\n * </Link>\n * </View>\n * );\n *}\n * ```\n */\n asChild?: boolean;\n\n /**\n * Removes the current route from the history and replace it with the\n * specified URL. This is useful for [redirects](/router/reference/redirects/).\n *\n * @example\n *```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link replace href=\"/feed\">Login</Link>\n * </View>\n * );\n *}\n * ```\n */\n replace?: boolean;\n /**\n * Always pushes a new route, and never pops or replaces to existing route.\n * You can push the current route multiple times or with new parameters.\n *\n * @example\n *```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link push href=\"/feed\">Login</Link>\n * </View>\n * );\n *}\n * ```\n */\n push?: boolean;\n /**\n * While in a stack, this will dismiss screens until the provided `href` is reached. If the href is not found,\n * it will instead replace the current screen with the provided `href`.\n *\n * @example\n *```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link dismissTo href=\"/feed\">Close modal</Link>\n * </View>\n * );\n *}\n * ```\n */\n dismissTo?: boolean;\n\n /**\n * On native, this can be used with CSS interop tools like Nativewind.\n * On web, this sets the HTML `class` directly.\n */\n className?: string;\n\n onPress?: (event: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => void;\n\n /**\n * Relative URL references are either relative to the directory or the document.\n * By default, relative paths are relative to the document.\n *\n * @see [Resolving relative references in Mozilla's documentation](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Replaces the initial screen with the current route.\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, if the target is valid then screens in the history that matches\n * the uniqueness constraint will be removed.\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n\n /**\n * Prefetches the route when the component is rendered on a focused screen.\n */\n prefetch?: boolean;\n}\n\n// Mutate the style prop to add the className on web.\nexport function useInteropClassName(props: { style?: TextProps['style']; className?: string }) {\n if (Platform.OS !== 'web') {\n return props.style;\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useMemo(() => {\n if (props.className == null) {\n return props.style;\n }\n const cssStyle = {\n $$css: true,\n __routerLinkClassName: props.className,\n };\n\n if (Array.isArray(props.style)) {\n return [...props.style, cssStyle];\n }\n return [props.style, cssStyle];\n }, [props.style, props.className]);\n}\n\nexport const useHrefAttrs = Platform.select<\n (props: Partial<LinkProps>) => { hrefAttrs?: any } & Partial<LinkProps>\n>({\n web: function useHrefAttrs({ asChild, rel, target, download }: Partial<LinkProps>) {\n return useMemo(() => {\n const hrefAttrs = {\n rel,\n target,\n download,\n };\n if (asChild) {\n return hrefAttrs;\n }\n return {\n hrefAttrs,\n };\n }, [asChild, rel, target, download]);\n },\n default: function useHrefAttrs() {\n return {};\n },\n});\n"]}
1
+ {"version":3,"file":"useLinkHooks.js","sourceRoot":"","sources":["../../src/link/useLinkHooks.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAwOb,kDAoBC;AA3PD,wFAAwF;AACxF,mCAAmC;AACnC,iCAAsD;AACtD,+CAAqF;AAmOrF,qDAAqD;AACrD,SAAgB,mBAAmB,CAAC,KAAyD;IAC3F,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,sDAAsD;IACtD,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,KAAK,CAAC;QACrB,CAAC;QACD,MAAM,QAAQ,GAAG;YACf,KAAK,EAAE,IAAI;YACX,qBAAqB,EAAE,KAAK,CAAC,SAAS;SACvC,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AACrC,CAAC;AAEY,QAAA,YAAY,GAAG,uBAAQ,CAAC,MAAM,CAEzC;IACA,GAAG,EAAE,SAAS,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAsB;QAC/E,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;YAClB,MAAM,SAAS,GAAG;gBAChB,GAAG;gBACH,MAAM;gBACN,QAAQ;aACT,CAAC;YACF,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO;gBACL,SAAS;aACV,CAAC;QACJ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,SAAS,YAAY;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC","sourcesContent":["'use client';\n// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { useMemo, MouseEvent, type Ref } from 'react';\nimport { TextProps, GestureResponderEvent, Platform, type Text } from 'react-native';\n\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\n\n// docsMissing\n/**\n * @platform web\n */\nexport type WebAnchorProps = {\n /**\n * Specifies where to open the [`href`](#href).\n *\n * - **_self**: the current tab.\n * - **_blank**: opens in a new tab or window.\n * - **_parent**: opens in the parent browsing context. If no parent, defaults to **_self**.\n * - **_top**: opens in the highest browsing context ancestor. If no ancestors,\n * defaults to **_self**.\n *\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @default '_self'\n *\n * @example\n * ```jsx\n * <Link href=\"https://expo.dev\" target=\"_blank\">Go to Expo in new tab</Link>\n * ```\n */\n target?: '_self' | '_blank' | '_parent' | '_top' | (string & object);\n\n /**\n * Specifies the relationship between the [`href`](#href) and the current route.\n *\n * Common values:\n * - **nofollow**: Indicates to search engines that they should not follow the `href`.\n * This is often used for user-generated content or links that should not influence\n * search engine rankings.\n * - **noopener**: Suggests that the `href` should not have access to the opening\n * window's `window.opener` object, which is a security measure to prevent potentially\n * harmful behavior in cases of links that open new tabs or windows.\n * - **noreferrer**: Requests that the browser does not send the `Referer` HTTP header\n * when navigating to the `href`. This can enhance user privacy.\n *\n * The `rel` property is primarily used for informational and instructive purposes, helping browsers and web\n * crawlers make better decisions about how to handle and interpret the links on a web\n * page. It is important to use appropriate `rel` values to ensure that links behave as intended and adhere\n * to best practices for web development and SEO (Search Engine Optimization).\n *\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @example\n * ```jsx\n * <Link href=\"https://expo.dev\" rel=\"nofollow\">Go to Expo</Link>\n * ```\n */\n rel?: string;\n\n /**\n * Specifies that the [`href`](#href) should be downloaded when the user clicks on the\n * link, instead of navigating to it. It is typically used for links that point to\n * files that the user should download, such as PDFs, images, documents, and more.\n *\n * The value of the `download` property, which represents the filename for the\n * downloaded file. This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @example\n * ```jsx\n * <Link href=\"/image.jpg\" download=\"my-image.jpg\">Download image</Link>\n * ```\n */\n download?: string;\n};\n\n// @docsMissing\nexport interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {\n /**\n * The path of the route to navigate to. It can either be:\n * - **string**: A full path like `/profile/settings` or a relative path like `../settings`.\n * - **object**: An object with a `pathname` and optional `params`. The `pathname` can be\n * a full path like `/profile/settings` or a relative path like `../settings`. The\n * params can be an object of key-value pairs.\n *\n * @example\n * ```tsx Dynamic\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link href=\"/about\">About</Link>\n * <Link\n * href={{\n * pathname: '/user/[id]',\n * params: { id: 'bacon' }\n * }}>\n * View user\n * </Link>\n * </View>\n * );\n *}\n * ```\n */\n href: Href;\n\n // TODO(EvanBacon): This may need to be extracted for React Native style support.\n /**\n * Used to customize the `Link` component. It will forward all props to the\n * first child of the `Link`. Note that the child component must accept\n * `onPress` or `onClick` props. The `href` and `role` are also\n * passed to the child.\n *\n * @example\n * ```tsx\n * import { Link } from 'expo-router';\n * import { Pressable, Text } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link href=\"/home\" asChild>\n * <Pressable>\n * <Text>Home</Text>\n * </Pressable>\n * </Link>\n * </View>\n * );\n *}\n * ```\n */\n asChild?: boolean;\n\n /**\n * Removes the current route from the history and replace it with the\n * specified URL. This is useful for [redirects](/router/reference/redirects/).\n *\n * @example\n *```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link replace href=\"/feed\">Login</Link>\n * </View>\n * );\n *}\n * ```\n */\n replace?: boolean;\n /**\n * Always pushes a new route, and never pops or replaces to existing route.\n * You can push the current route multiple times or with new parameters.\n *\n * @example\n *```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link push href=\"/feed\">Login</Link>\n * </View>\n * );\n *}\n * ```\n */\n push?: boolean;\n /**\n * While in a stack, this will dismiss screens until the provided `href` is reached. If the href is not found,\n * it will instead replace the current screen with the provided `href`.\n *\n * @example\n *```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link dismissTo href=\"/feed\">Close modal</Link>\n * </View>\n * );\n *}\n * ```\n */\n dismissTo?: boolean;\n\n /**\n * On native, this can be used with CSS interop tools like Nativewind.\n * On web, this sets the HTML `class` directly.\n */\n className?: string;\n\n onPress?: (event: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => void;\n\n /**\n * Relative URL references are either relative to the directory or the document.\n * By default, relative paths are relative to the document.\n *\n * @see [Resolving relative references in Mozilla's documentation](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Replaces the initial screen with the current route.\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, if the target is valid then screens in the history that matches\n * the uniqueness constraint will be removed.\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n\n /**\n * Prefetches the route when the component is rendered on a focused screen.\n */\n prefetch?: boolean;\n\n ref?: Ref<Text>;\n}\n\n// Mutate the style prop to add the className on web.\nexport function useInteropClassName(props: { style?: TextProps['style']; className?: string }) {\n if (Platform.OS !== 'web') {\n return props.style;\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useMemo(() => {\n if (props.className == null) {\n return props.style;\n }\n const cssStyle = {\n $$css: true,\n __routerLinkClassName: props.className,\n };\n\n if (Array.isArray(props.style)) {\n return [...props.style, cssStyle];\n }\n return [props.style, cssStyle];\n }, [props.style, props.className]);\n}\n\nexport const useHrefAttrs = Platform.select<\n (props: Partial<LinkProps>) => { hrefAttrs?: any } & Partial<LinkProps>\n>({\n web: function useHrefAttrs({ asChild, rel, target, download }: Partial<LinkProps>) {\n return useMemo(() => {\n const hrefAttrs = {\n rel,\n target,\n download,\n };\n if (asChild) {\n return hrefAttrs;\n }\n return {\n hrefAttrs,\n };\n }, [asChild, rel, target, download]);\n },\n default: function useHrefAttrs() {\n return {};\n },\n});\n"]}
@@ -0,0 +1,82 @@
1
+ import { ViewProps } from 'react-native';
2
+ import { type ModalConfig } from './ModalContext';
3
+ export interface ModalProps extends ViewProps {
4
+ /**
5
+ * The content of the modal.
6
+ */
7
+ children?: React.ReactNode;
8
+ /**
9
+ * Whether the modal is visible or not.
10
+ * When set to `true`, the modal will be opened.
11
+ * When set to `false`, the modal will be closed.
12
+ */
13
+ visible: boolean;
14
+ /**
15
+ * Callback that is called after modal is closed.
16
+ * This is called when the modal is dismissed by the user or programmatically.
17
+ */
18
+ onClose?: () => void;
19
+ /**
20
+ * Callback that is called after modal is shown.
21
+ */
22
+ onShow?: () => void;
23
+ /**
24
+ * The animation type for the modal.
25
+ * This can be one of 'none', 'slide', or 'fade'.
26
+ */
27
+ animationType?: ModalConfig['animationType'];
28
+ /**
29
+ * The presentation style for the modal.
30
+ * This can be one of 'fullScreen', 'pageSheet', 'formSheet', or 'overFullScreen'.
31
+ * - `fullScreen`: The modal covers the entire screen. When `transparent` is set to `true`, it will fallback to `overFullScreen`.
32
+ * - `pageSheet`: The modal is presented as a page sheet on iOS. Defaults to `fullScreen` on Android.
33
+ * - `formSheet`: The modal is presented as a form sheet.
34
+ * - `overFullScreen`: The modal is presented over the full screen, allowing interaction with the underlying content.
35
+ *
36
+ * @default 'fullScreen'
37
+ */
38
+ presentationStyle?: ModalConfig['presentationStyle'];
39
+ /**
40
+ * Whether the modal should be rendered as a transparent overlay.
41
+ * This will render the modal without a background, allowing the content behind it to be visible.
42
+ *
43
+ * On Android, this will fallback to `overFullScreen` presentation style.
44
+ */
45
+ transparent?: boolean;
46
+ /**
47
+ * See {@link ScreenProps["sheetAllowedDetents"]}.
48
+ *
49
+ * Describes heights where a sheet can rest.
50
+ * Works only when `presentation` is set to `formSheet`.
51
+ *
52
+ * Heights should be described as fraction (a number from `[0, 1]` interval) of screen height / maximum detent height.
53
+ * You can pass an array of ascending values each defining allowed sheet detent. iOS accepts any number of detents,
54
+ * while **Android is limited to three**.
55
+ */
56
+ detents?: ModalConfig['detents'];
57
+ }
58
+ /**
59
+ * A standalone modal component that can be used in Expo Router apps.
60
+ * It always renders on top of the application's content.
61
+ * Internally, the modal is rendered as a `Stack.Screen`, with the presentation style determined by the `presentationStyle` prop.
62
+ *
63
+ * This component is not linkable. If you need to link to a modal, use `<Stack.Screen options={{ presentationStyle: "modal" }} />` instead.
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * import { Modal } from 'expo-router';
68
+ *
69
+ * function Page() {
70
+ * const [modalVisible, setModalVisible] = useState(false);
71
+ * return (
72
+ * <Modal
73
+ * visible={modalVisible}
74
+ * onClose={() => setModalVisible(false)}
75
+ * >
76
+ * <Text>Hello World</Text>
77
+ * </Modal>
78
+ * );
79
+ * }
80
+ */
81
+ export declare function Modal(props: ModalProps): null;
82
+ //# sourceMappingURL=Modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/modal/Modal.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGnE,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAC7C;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAAC;IACrD;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,QA0DtC"}