@react-navigation/native 7.0.0-alpha.4 → 7.0.0-alpha.5

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 (157) hide show
  1. package/lib/commonjs/Link.js +13 -5
  2. package/lib/commonjs/Link.js.map +1 -1
  3. package/lib/commonjs/LinkingContext.js +7 -5
  4. package/lib/commonjs/LinkingContext.js.map +1 -1
  5. package/lib/commonjs/LocaleDirContext.js +3 -4
  6. package/lib/commonjs/LocaleDirContext.js.map +1 -1
  7. package/lib/commonjs/NavigationContainer.js +48 -14
  8. package/lib/commonjs/NavigationContainer.js.map +1 -1
  9. package/lib/commonjs/ServerContainer.js +3 -4
  10. package/lib/commonjs/ServerContainer.js.map +1 -1
  11. package/lib/commonjs/ServerContext.js +3 -4
  12. package/lib/commonjs/ServerContext.js.map +1 -1
  13. package/lib/commonjs/UnhandledLinkingContext.js +20 -0
  14. package/lib/commonjs/UnhandledLinkingContext.js.map +1 -0
  15. package/lib/commonjs/__stubs__/createStackNavigator.js +19 -0
  16. package/lib/commonjs/__stubs__/createStackNavigator.js.map +1 -0
  17. package/lib/commonjs/__stubs__/window.js +79 -0
  18. package/lib/commonjs/__stubs__/window.js.map +1 -0
  19. package/lib/commonjs/createMemoryHistory.js +4 -7
  20. package/lib/commonjs/createMemoryHistory.js.map +1 -1
  21. package/lib/commonjs/createStaticNavigation.js +2 -2
  22. package/lib/commonjs/createStaticNavigation.js.map +1 -1
  23. package/lib/commonjs/extractPathFromURL.js +1 -2
  24. package/lib/commonjs/extractPathFromURL.js.map +1 -1
  25. package/lib/commonjs/index.js +9 -1
  26. package/lib/commonjs/index.js.map +1 -1
  27. package/lib/commonjs/theming/DarkTheme.js +1 -2
  28. package/lib/commonjs/theming/DarkTheme.js.map +1 -1
  29. package/lib/commonjs/theming/DefaultTheme.js +1 -2
  30. package/lib/commonjs/theming/DefaultTheme.js.map +1 -1
  31. package/lib/commonjs/theming/ThemeContext.js +3 -4
  32. package/lib/commonjs/theming/ThemeContext.js.map +1 -1
  33. package/lib/commonjs/theming/ThemeProvider.js +2 -2
  34. package/lib/commonjs/theming/ThemeProvider.js.map +1 -1
  35. package/lib/commonjs/theming/fonts.js +1 -2
  36. package/lib/commonjs/theming/fonts.js.map +1 -1
  37. package/lib/commonjs/theming/useTheme.js +2 -2
  38. package/lib/commonjs/theming/useTheme.js.map +1 -1
  39. package/lib/commonjs/types.js.map +1 -1
  40. package/lib/commonjs/useBackButton.js.map +1 -1
  41. package/lib/commonjs/useBackButton.native.js +2 -2
  42. package/lib/commonjs/useBackButton.native.js.map +1 -1
  43. package/lib/commonjs/useDocumentTitle.js +5 -5
  44. package/lib/commonjs/useDocumentTitle.js.map +1 -1
  45. package/lib/commonjs/useDocumentTitle.native.js.map +1 -1
  46. package/lib/commonjs/useLinkProps.js +20 -23
  47. package/lib/commonjs/useLinkProps.js.map +1 -1
  48. package/lib/commonjs/useLinkTools.js +6 -6
  49. package/lib/commonjs/useLinkTools.js.map +1 -1
  50. package/lib/commonjs/useLinking.js +26 -13
  51. package/lib/commonjs/useLinking.js.map +1 -1
  52. package/lib/commonjs/useLinking.native.js +30 -23
  53. package/lib/commonjs/useLinking.native.js.map +1 -1
  54. package/lib/commonjs/useLocale.js +2 -2
  55. package/lib/commonjs/useLocale.js.map +1 -1
  56. package/lib/commonjs/useScrollToTop.js +4 -4
  57. package/lib/commonjs/useScrollToTop.js.map +1 -1
  58. package/lib/commonjs/useThenable.js +3 -2
  59. package/lib/commonjs/useThenable.js.map +1 -1
  60. package/lib/commonjs/useUnhandledLinking.js +74 -0
  61. package/lib/commonjs/useUnhandledLinking.js.map +1 -0
  62. package/lib/module/Link.js +11 -3
  63. package/lib/module/Link.js.map +1 -1
  64. package/lib/module/LinkingContext.js +4 -1
  65. package/lib/module/LinkingContext.js.map +1 -1
  66. package/lib/module/LocaleDirContext.js.map +1 -1
  67. package/lib/module/NavigationContainer.js +44 -10
  68. package/lib/module/NavigationContainer.js.map +1 -1
  69. package/lib/module/ServerContainer.js.map +1 -1
  70. package/lib/module/ServerContext.js.map +1 -1
  71. package/lib/module/UnhandledLinkingContext.js +12 -0
  72. package/lib/module/UnhandledLinkingContext.js.map +1 -0
  73. package/lib/module/__stubs__/createStackNavigator.js +11 -0
  74. package/lib/module/__stubs__/createStackNavigator.js.map +1 -0
  75. package/lib/module/__stubs__/window.js +73 -0
  76. package/lib/module/__stubs__/window.js.map +1 -0
  77. package/lib/module/createMemoryHistory.js +4 -7
  78. package/lib/module/createMemoryHistory.js.map +1 -1
  79. package/lib/module/createStaticNavigation.js.map +1 -1
  80. package/lib/module/extractPathFromURL.js +1 -2
  81. package/lib/module/extractPathFromURL.js.map +1 -1
  82. package/lib/module/index.js +1 -0
  83. package/lib/module/index.js.map +1 -1
  84. package/lib/module/theming/DarkTheme.js.map +1 -1
  85. package/lib/module/theming/DefaultTheme.js.map +1 -1
  86. package/lib/module/theming/ThemeContext.js.map +1 -1
  87. package/lib/module/theming/ThemeProvider.js.map +1 -1
  88. package/lib/module/theming/fonts.js.map +1 -1
  89. package/lib/module/theming/useTheme.js.map +1 -1
  90. package/lib/module/types.js.map +1 -1
  91. package/lib/module/useBackButton.js.map +1 -1
  92. package/lib/module/useBackButton.native.js.map +1 -1
  93. package/lib/module/useDocumentTitle.js +3 -3
  94. package/lib/module/useDocumentTitle.js.map +1 -1
  95. package/lib/module/useDocumentTitle.native.js.map +1 -1
  96. package/lib/module/useLinkProps.js +18 -21
  97. package/lib/module/useLinkProps.js.map +1 -1
  98. package/lib/module/useLinkTools.js +4 -4
  99. package/lib/module/useLinkTools.js.map +1 -1
  100. package/lib/module/useLinking.js +24 -11
  101. package/lib/module/useLinking.js.map +1 -1
  102. package/lib/module/useLinking.native.js +28 -21
  103. package/lib/module/useLinking.native.js.map +1 -1
  104. package/lib/module/useLocale.js.map +1 -1
  105. package/lib/module/useScrollToTop.js +2 -2
  106. package/lib/module/useScrollToTop.js.map +1 -1
  107. package/lib/module/useThenable.js +1 -0
  108. package/lib/module/useThenable.js.map +1 -1
  109. package/lib/module/useUnhandledLinking.js +67 -0
  110. package/lib/module/useUnhandledLinking.js.map +1 -0
  111. package/lib/typescript/src/Link.d.ts +3 -3
  112. package/lib/typescript/src/Link.d.ts.map +1 -1
  113. package/lib/typescript/src/LinkingContext.d.ts +2 -2
  114. package/lib/typescript/src/LinkingContext.d.ts.map +1 -1
  115. package/lib/typescript/src/NavigationContainer.d.ts +1 -1
  116. package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
  117. package/lib/typescript/src/ServerContainer.d.ts +1 -1
  118. package/lib/typescript/src/ServerContainer.d.ts.map +1 -1
  119. package/lib/typescript/src/UnhandledLinkingContext.d.ts +6 -0
  120. package/lib/typescript/src/UnhandledLinkingContext.d.ts.map +1 -0
  121. package/lib/typescript/src/{__mocks__ → __stubs__}/createStackNavigator.d.ts +5 -4
  122. package/lib/typescript/src/__stubs__/createStackNavigator.d.ts.map +1 -0
  123. package/lib/typescript/src/{__mocks__ → __stubs__}/window.d.ts +1 -1
  124. package/lib/typescript/src/{__mocks__ → __stubs__}/window.d.ts.map +1 -1
  125. package/lib/typescript/src/createStaticNavigation.d.ts +2 -2
  126. package/lib/typescript/src/createStaticNavigation.d.ts.map +1 -1
  127. package/lib/typescript/src/index.d.ts +1 -0
  128. package/lib/typescript/src/index.d.ts.map +1 -1
  129. package/lib/typescript/src/theming/ThemeProvider.d.ts +1 -1
  130. package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -1
  131. package/lib/typescript/src/useLinkProps.d.ts +2 -2
  132. package/lib/typescript/src/useLinkProps.d.ts.map +1 -1
  133. package/lib/typescript/src/useLinking.d.ts +2 -2
  134. package/lib/typescript/src/useLinking.d.ts.map +1 -1
  135. package/lib/typescript/src/useLinking.native.d.ts +2 -2
  136. package/lib/typescript/src/useLinking.native.d.ts.map +1 -1
  137. package/lib/typescript/src/useThenable.d.ts.map +1 -1
  138. package/lib/typescript/src/useUnhandledLinking.d.ts +7 -0
  139. package/lib/typescript/src/useUnhandledLinking.d.ts.map +1 -0
  140. package/package.json +12 -12
  141. package/src/Link.tsx +11 -2
  142. package/src/LinkingContext.tsx +8 -3
  143. package/src/NavigationContainer.tsx +68 -20
  144. package/src/ServerContainer.tsx +1 -1
  145. package/src/UnhandledLinkingContext.tsx +18 -0
  146. package/src/{__mocks__ → __stubs__}/window.tsx +7 -5
  147. package/src/createStaticNavigation.tsx +2 -2
  148. package/src/index.tsx +1 -0
  149. package/src/useLinkProps.tsx +20 -19
  150. package/src/useLinkTools.tsx +3 -3
  151. package/src/useLinking.native.tsx +26 -20
  152. package/src/useLinking.tsx +33 -12
  153. package/src/useScrollToTop.tsx +4 -4
  154. package/src/useThenable.tsx +1 -0
  155. package/src/useUnhandledLinking.tsx +90 -0
  156. package/lib/typescript/src/__mocks__/createStackNavigator.d.ts.map +0 -1
  157. /package/src/{__mocks__ → __stubs__}/createStackNavigator.tsx +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../../../src/__mocks__/window.tsx"],"names":[],"mappings":"AAiEA,eAAO,MAAM,MAAM;;;;;;;yBApDA,GAAG,KAAK,MAAM,QAAQ,MAAM;4BASzB,GAAG,KAAK,MAAM,QAAQ,MAAM;cAO1C,MAAM;;;;6BAwBkB,UAAU,YAAY,MAAM,IAAI;gCAM7B,UAAU,YAAY,MAAM,IAAI;;CAelE,CAAC"}
1
+ {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../../../src/__stubs__/window.tsx"],"names":[],"mappings":"AAiEA,eAAO,MAAM,MAAM;;;;;;;yBApDA,GAAG,KAAK,MAAM,QAAQ,MAAM;4BASzB,GAAG,KAAK,MAAM,QAAQ,MAAM;cAO1C,MAAM;;;;6BAwBkB,UAAU,YAAY,MAAM,IAAI;gCAM7B,UAAU,YAAY,MAAM,IAAI;;CAiBlE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ParamListBase, StaticNavigation } from '@react-navigation/core';
1
+ import { type ParamListBase, type StaticNavigation } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
3
  import { NavigationContainer } from './NavigationContainer';
4
4
  import type { LinkingOptions } from './types';
@@ -15,6 +15,6 @@ type Props = Omit<React.ComponentProps<typeof NavigationContainer>, 'linking' |
15
15
  * @param tree Static navigation config.
16
16
  * @returns Navigation component to use in your app.
17
17
  */
18
- export declare function createStaticNavigation(tree: StaticNavigation<any, any, any>): ({ linking, ...rest }: Props) => JSX.Element;
18
+ export declare function createStaticNavigation(tree: StaticNavigation<any, any, any>): ({ linking, ...rest }: Props) => React.JSX.Element;
19
19
  export {};
20
20
  //# sourceMappingURL=createStaticNavigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createStaticNavigation.d.ts","sourceRoot":"","sources":["../../../src/createStaticNavigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,KAAK,KAAK,GAAG,IAAI,CACf,KAAK,CAAC,cAAc,CAAC,OAAO,mBAAmB,CAAC,EAChD,SAAS,GAAG,UAAU,CACvB,GAAG;IACF;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,0BAQzB,KAAK,iBAUvD"}
1
+ {"version":3,"file":"createStaticNavigation.d.ts","sourceRoot":"","sources":["../../../src/createStaticNavigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,KAAK,KAAK,GAAG,IAAI,CACf,KAAK,CAAC,cAAc,CAAC,OAAO,mBAAmB,CAAC,EAChD,SAAS,GAAG,UAAU,CACvB,GAAG;IACF;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,0BAQzB,KAAK,uBAUvD"}
@@ -12,5 +12,6 @@ export { useLinkProps } from './useLinkProps';
12
12
  export { useLinkTools } from './useLinkTools';
13
13
  export { useLocale } from './useLocale';
14
14
  export { useScrollToTop } from './useScrollToTop';
15
+ export { useUnhandledLinking } from './useUnhandledLinking';
15
16
  export * from '@react-navigation/core';
16
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,wBAAwB,CAAC"}
@@ -4,6 +4,6 @@ type Props = {
4
4
  value: Theme;
5
5
  children: React.ReactNode;
6
6
  };
7
- export declare function ThemeProvider({ value, children }: Props): JSX.Element;
7
+ export declare function ThemeProvider({ value, children }: Props): React.JSX.Element;
8
8
  export {};
9
9
  //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/theming/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGtC,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,eAIvD"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/theming/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGtC,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,qBAIvD"}
@@ -1,6 +1,6 @@
1
- import { NavigationAction } from '@react-navigation/core';
1
+ import { type NavigationAction } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
- import { GestureResponderEvent } from 'react-native';
3
+ import { type GestureResponderEvent } from 'react-native';
4
4
  export type Props<ParamList extends ReactNavigation.RootParamList, RouteName extends keyof ParamList = keyof ParamList> = ({
5
5
  screen: Extract<RouteName, string>;
6
6
  href?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkProps.d.ts","sourceRoot":"","sources":["../../../src/useLinkProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAKjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAI/D,MAAM,MAAM,KAAK,CACf,SAAS,SAAS,eAAe,CAAC,aAAa,EAC/C,SAAS,SAAS,MAAM,SAAS,GAAG,MAAM,SAAS,IAEjD,CAAC;IACC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,GAAG,CAAC,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GACvC;IAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,CAAC,CAAC,GACtC;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AA+BN;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,SAAS,SAAS,eAAe,CAAC,aAAa,EAAE,EAC5E,MAAM,EACN,MAAM,EACN,IAAI,EACJ,MAAM,GACP,EAAE,KAAK,CAAC,SAAS,CAAC;;;kBAMX,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB;EA6D9E"}
1
+ {"version":3,"file":"useLinkProps.d.ts","sourceRoot":"","sources":["../../../src/useLinkProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EAKtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAIpE,MAAM,MAAM,KAAK,CACf,SAAS,SAAS,eAAe,CAAC,aAAa,EAC/C,SAAS,SAAS,MAAM,SAAS,GAAG,MAAM,SAAS,IAEjD,CAAC;IACC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,GAAG,CAAC,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GACvC;IAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,CAAC,CAAC,GACtC;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AA+BN;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,SAAS,SAAS,eAAe,CAAC,aAAa,EAAE,EAC5E,MAAM,EACN,MAAM,EACN,IAAI,EACJ,MAAM,GACP,EAAE,KAAK,CAAC,SAAS,CAAC;;;kBAMX,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB;EA8D9E"}
@@ -1,4 +1,4 @@
1
- import { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
1
+ import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
3
  import type { LinkingOptions } from './types';
4
4
  /**
@@ -6,7 +6,7 @@ import type { LinkingOptions } from './types';
6
6
  */
7
7
  export declare const series: (cb: () => Promise<void>) => () => void;
8
8
  type Options = LinkingOptions<ParamListBase>;
9
- export declare function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, config, getStateFromPath, getPathFromState, getActionFromState, }: Options): {
9
+ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, config, getStateFromPath, getPathFromState, getActionFromState, }: Options, onUnhandledLinking: (lastUnhandledLining: string | undefined) => void): {
10
10
  getInitialState: () => PromiseLike<(Partial<Omit<Readonly<{
11
11
  key: string;
12
12
  index: number;
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../../src/useLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,sBAAsB,EAEtB,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA4C9C;;GAEG;AACH,eAAO,MAAM,MAAM,OAAQ,MAAM,QAAQ,IAAI,CAAC,eAM7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwTX"}
1
+ {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../../src/useLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA4C9C;;GAEG;AACH,eAAO,MAAM,MAAM,OAAQ,MAAM,QAAQ,IAAI,CAAC,eAO7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2UtE"}
@@ -1,8 +1,8 @@
1
- import { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
1
+ import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
3
  import type { LinkingOptions } from './types';
4
4
  type Options = LinkingOptions<ParamListBase>;
5
- export declare function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, prefixes, filter, config, getInitialURL, subscribe, getStateFromPath, getActionFromState, }: Options): {
5
+ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, prefixes, filter, config, getInitialURL, subscribe, getStateFromPath, getActionFromState, }: Options, onUnhandledLinking: (lastUnhandledLining: string | undefined) => void): {
6
6
  getInitialState: () => PromiseLike<(Partial<Omit<Readonly<{
7
7
  key: string;
8
8
  index: number;
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../../src/useLinking.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACtB,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6JX"}
1
+ {"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../../src/useLinking.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkKtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"useThenable.d.ts","sourceRoot":"","sources":["../../../src/useThenable.tsx"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,4BAsC1D"}
1
+ {"version":3,"file":"useThenable.d.ts","sourceRoot":"","sources":["../../../src/useThenable.tsx"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,4BAuC1D"}
@@ -0,0 +1,7 @@
1
+ import { type NavigationState, type PartialState } from '@react-navigation/core';
2
+ export declare function useUnhandledLinking(): {
3
+ lastUnhandledLink: string | undefined;
4
+ getStateForRouteNamesChange: (currentState: NavigationState) => PartialState<NavigationState> | undefined;
5
+ clearUnhandledLink: () => void;
6
+ };
7
+ //# sourceMappingURL=useUnhandledLinking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUnhandledLinking.d.ts","sourceRoot":"","sources":["../../../src/useUnhandledLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AA0BhC,wBAAgB,mBAAmB;;gDAUjB,eAAe,KAC5B,aAAa,eAAe,CAAC,GAAG,SAAS;;EA+C7C"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/native",
3
3
  "description": "React Native integration for React Navigation",
4
- "version": "7.0.0-alpha.4",
4
+ "version": "7.0.0-alpha.5",
5
5
  "keywords": [
6
6
  "react-native",
7
7
  "react-navigation",
@@ -37,26 +37,26 @@
37
37
  "clean": "del lib"
38
38
  },
39
39
  "dependencies": {
40
- "@react-navigation/core": "^7.0.0-alpha.4",
40
+ "@react-navigation/core": "^7.0.0-alpha.5",
41
41
  "escape-string-regexp": "^4.0.0",
42
42
  "fast-deep-equal": "^3.1.3",
43
- "nanoid": "^3.1.23"
43
+ "nanoid": "3.3.6",
44
+ "use-latest-callback": "^0.1.9"
44
45
  },
45
46
  "devDependencies": {
46
- "@testing-library/react-native": "^11.5.0",
47
- "@types/react": "~18.0.27",
47
+ "@testing-library/react-native": "^12.3.1",
48
+ "@types/react": "~18.2.33",
48
49
  "@types/react-dom": "~18.0.10",
49
- "@types/react-native": "~0.70.8",
50
- "del-cli": "^5.0.0",
50
+ "del-cli": "^5.1.0",
51
51
  "react": "18.2.0",
52
52
  "react-dom": "18.2.0",
53
- "react-native": "0.71.8",
54
- "react-native-builder-bob": "^0.21.0",
55
- "typescript": "^4.9.4"
53
+ "react-native": "0.72.6",
54
+ "react-native-builder-bob": "^0.23.1",
55
+ "typescript": "^5.2.2"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "react": "*",
59
- "react-native": "*"
59
+ "react-native": "0.72.6"
60
60
  },
61
61
  "react-native-builder-bob": {
62
62
  "source": "src",
@@ -72,5 +72,5 @@
72
72
  ]
73
73
  ]
74
74
  },
75
- "gitHead": "ae0a70c2d94f77cd8ca8b8d3028f684a63f81b92"
75
+ "gitHead": "858a8746a5c007a623206c920f70d55935ed39b4"
76
76
  }
package/src/Link.tsx CHANGED
@@ -1,7 +1,13 @@
1
1
  import * as React from 'react';
2
- import { GestureResponderEvent, Platform, Text, TextProps } from 'react-native';
2
+ import {
3
+ type GestureResponderEvent,
4
+ Platform,
5
+ Text,
6
+ type TextProps,
7
+ } from 'react-native';
3
8
 
4
- import { Props as LinkProps, useLinkProps } from './useLinkProps';
9
+ import { useTheme } from './theming/useTheme';
10
+ import { type Props as LinkProps, useLinkProps } from './useLinkProps';
5
11
 
6
12
  type Props<ParamList extends ReactNavigation.RootParamList> =
7
13
  LinkProps<ParamList> &
@@ -31,8 +37,10 @@ export function Link<ParamList extends ReactNavigation.RootParamList>({
31
37
  params,
32
38
  action,
33
39
  href,
40
+ style,
34
41
  ...rest
35
42
  }: Props<ParamList>) {
43
+ const { colors, fonts } = useTheme();
36
44
  // @ts-expect-error: This is already type-checked by the prop types
37
45
  const props = useLinkProps<ParamList>({ screen, params, action, href });
38
46
 
@@ -56,5 +64,6 @@ export function Link<ParamList extends ReactNavigation.RootParamList>({
56
64
  web: { onClick: onPress } as any,
57
65
  default: { onPress },
58
66
  }),
67
+ style: [{ color: colors.primary }, fonts.regular, style],
59
68
  });
60
69
  }
@@ -1,10 +1,15 @@
1
1
  import type { ParamListBase } from '@react-navigation/core';
2
+ import type { LinkingOptions } from '@react-navigation/native/src/types';
2
3
  import * as React from 'react';
3
4
 
4
- import type { LinkingOptions } from './types';
5
+ const MISSING_CONTEXT_ERROR = "Couldn't find a LinkingContext context.";
5
6
 
6
7
  export const LinkingContext = React.createContext<{
7
- options: LinkingOptions<ParamListBase> | undefined;
8
- }>({ options: undefined });
8
+ options?: LinkingOptions<ParamListBase>;
9
+ }>({
10
+ get options(): any {
11
+ throw new Error(MISSING_CONTEXT_ERROR);
12
+ },
13
+ });
9
14
 
10
15
  LinkingContext.displayName = 'LinkingContext';
@@ -3,13 +3,15 @@ import {
3
3
  getActionFromState,
4
4
  getPathFromState,
5
5
  getStateFromPath,
6
- NavigationContainerProps,
7
- NavigationContainerRef,
8
- ParamListBase,
6
+ type NavigationContainerProps,
7
+ type NavigationContainerRef,
8
+ type NavigationState,
9
+ type ParamListBase,
9
10
  validatePathConfig,
10
11
  } from '@react-navigation/core';
11
12
  import * as React from 'react';
12
13
  import { I18nManager } from 'react-native';
14
+ import useLatestCallback from 'use-latest-callback';
13
15
 
14
16
  import { LinkingContext } from './LinkingContext';
15
17
  import { LocaleDirContext } from './LocaleDirContext';
@@ -21,12 +23,14 @@ import type {
21
23
  LocaleDirection,
22
24
  Theme,
23
25
  } from './types';
26
+ import { UnhandledLinkingContext } from './UnhandledLinkingContext';
24
27
  import { useBackButton } from './useBackButton';
25
28
  import { useDocumentTitle } from './useDocumentTitle';
26
29
  import { useLinking } from './useLinking';
27
30
  import { useThenable } from './useThenable';
28
31
 
29
32
  declare global {
33
+ // eslint-disable-next-line no-var
30
34
  var REACT_NAVIGATION_DEVTOOLS: WeakMap<
31
35
  NavigationContainerRef<any>,
32
36
  { readonly linking: LinkingOptions<any> }
@@ -66,6 +70,8 @@ function NavigationContainerInner(
66
70
  linking,
67
71
  fallback = null,
68
72
  documentTitle,
73
+ onReady,
74
+ onStateChange,
69
75
  ...rest
70
76
  }: Props<ParamListBase>,
71
77
  ref?: React.Ref<NavigationContainerRef<ParamListBase> | null>
@@ -82,12 +88,52 @@ function NavigationContainerInner(
82
88
  useBackButton(refContainer);
83
89
  useDocumentTitle(refContainer, documentTitle);
84
90
 
85
- const { getInitialState } = useLinking(refContainer, {
86
- enabled: isLinkingEnabled,
87
- prefixes: [],
88
- ...linking,
91
+ const [lastUnhandledLink, setLastUnhandledLink] = React.useState<
92
+ string | undefined
93
+ >();
94
+
95
+ const { getInitialState } = useLinking(
96
+ refContainer,
97
+ {
98
+ enabled: isLinkingEnabled,
99
+ prefixes: [],
100
+ ...linking,
101
+ },
102
+ setLastUnhandledLink
103
+ );
104
+
105
+ const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);
106
+
107
+ const unhandledLinkingContext = React.useMemo(
108
+ () => ({ lastUnhandledLink, setLastUnhandledLink }),
109
+ [lastUnhandledLink, setLastUnhandledLink]
110
+ );
111
+
112
+ const onReadyForLinkingHandling = useLatestCallback(() => {
113
+ // If the screen path matches lastUnhandledLink, we do not track it
114
+ const path = refContainer.current?.getCurrentRoute()?.path;
115
+ setLastUnhandledLink((previousLastUnhandledLink) => {
116
+ if (previousLastUnhandledLink === path) {
117
+ return undefined;
118
+ }
119
+ return previousLastUnhandledLink;
120
+ });
121
+ onReady?.();
89
122
  });
90
123
 
124
+ const onStateChangeForLinkingHandling = useLatestCallback(
125
+ (state: Readonly<NavigationState> | undefined) => {
126
+ // If the screen path matches lastUnhandledLink, we do not track it
127
+ const path = refContainer.current?.getCurrentRoute()?.path;
128
+ setLastUnhandledLink((previousLastUnhandledLink) => {
129
+ if (previousLastUnhandledLink === path) {
130
+ return undefined;
131
+ }
132
+ return previousLastUnhandledLink;
133
+ });
134
+ onStateChange?.(state);
135
+ }
136
+ );
91
137
  // Add additional linking related info to the ref
92
138
  // This will be used by the devtools
93
139
  React.useEffect(() => {
@@ -112,8 +158,6 @@ function NavigationContainerInner(
112
158
 
113
159
  React.useImperativeHandle(ref, () => refContainer.current);
114
160
 
115
- const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);
116
-
117
161
  const isLinkingReady =
118
162
  rest.initialState != null || !isLinkingEnabled || isResolved;
119
163
 
@@ -125,17 +169,21 @@ function NavigationContainerInner(
125
169
 
126
170
  return (
127
171
  <LocaleDirContext.Provider value={direction}>
128
- <LinkingContext.Provider value={linkingContext}>
129
- <ThemeProvider value={theme}>
130
- <BaseNavigationContainer
131
- {...rest}
132
- initialState={
133
- rest.initialState == null ? initialState : rest.initialState
134
- }
135
- ref={refContainer}
136
- />
137
- </ThemeProvider>
138
- </LinkingContext.Provider>
172
+ <UnhandledLinkingContext.Provider value={unhandledLinkingContext}>
173
+ <LinkingContext.Provider value={linkingContext}>
174
+ <ThemeProvider value={theme}>
175
+ <BaseNavigationContainer
176
+ {...rest}
177
+ onReady={onReadyForLinkingHandling}
178
+ onStateChange={onStateChangeForLinkingHandling}
179
+ initialState={
180
+ rest.initialState == null ? initialState : rest.initialState
181
+ }
182
+ ref={refContainer}
183
+ />
184
+ </ThemeProvider>
185
+ </LinkingContext.Provider>
186
+ </UnhandledLinkingContext.Provider>
139
187
  </LocaleDirContext.Provider>
140
188
  );
141
189
  }
@@ -1,7 +1,7 @@
1
1
  import { CurrentRenderContext } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
3
 
4
- import { ServerContext, ServerContextType } from './ServerContext';
4
+ import { ServerContext, type ServerContextType } from './ServerContext';
5
5
  import type { ServerContainerRef } from './types';
6
6
 
7
7
  type Props = ServerContextType & {
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ const MISSING_CONTEXT_ERROR =
4
+ "Couldn't find an UnhandledLinkingContext context.";
5
+
6
+ export const UnhandledLinkingContext = React.createContext<{
7
+ lastUnhandledLink: string | undefined;
8
+ setLastUnhandledLink: (lastUnhandledUrl: string | undefined) => void;
9
+ }>({
10
+ get lastUnhandledLink(): any {
11
+ throw new Error(MISSING_CONTEXT_ERROR);
12
+ },
13
+ get setLastUnhandledLink(): any {
14
+ throw new Error(MISSING_CONTEXT_ERROR);
15
+ },
16
+ });
17
+
18
+ UnhandledLinkingContext.displayName = 'UnhandledLinkingContext';
@@ -1,4 +1,4 @@
1
- const location = new URL('', 'http://example.com');
1
+ let location = new URL('', 'http://example.com');
2
2
 
3
3
  let listeners: (() => void)[] = [];
4
4
  let entries = [{ state: null, href: location.href }];
@@ -12,7 +12,7 @@ const history = {
12
12
  },
13
13
 
14
14
  pushState(state: any, _: string, path: string) {
15
- Object.assign(location, new URL(path, location.origin));
15
+ location = new URL(path, location.origin);
16
16
 
17
17
  currentState = state;
18
18
  entries = entries.slice(0, index + 1);
@@ -21,7 +21,7 @@ const history = {
21
21
  },
22
22
 
23
23
  replaceState(state: any, _: string, path: string) {
24
- Object.assign(location, new URL(path, location.origin));
24
+ location = new URL(path, location.origin);
25
25
 
26
26
  currentState = state;
27
27
  entries[index] = { state, href: location.href };
@@ -35,7 +35,7 @@ const history = {
35
35
  ) {
36
36
  index += n;
37
37
  const entry = entries[index];
38
- Object.assign(location, new URL(entry.href));
38
+ location = new URL(entry.href);
39
39
  currentState = entry.state;
40
40
  listeners.forEach((cb) => cb());
41
41
  }
@@ -65,7 +65,9 @@ const removeEventListener = (type: 'popstate', listener: () => void) => {
65
65
 
66
66
  export const window = {
67
67
  document: { title: '' },
68
- location,
68
+ get location() {
69
+ return location;
70
+ },
69
71
  history,
70
72
  addEventListener,
71
73
  removeEventListener,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createComponentForStaticNavigation,
3
3
  createPathConfigForStaticNavigation,
4
- ParamListBase,
5
- StaticNavigation,
4
+ type ParamListBase,
5
+ type StaticNavigation,
6
6
  } from '@react-navigation/core';
7
7
  import * as React from 'react';
8
8
 
package/src/index.tsx CHANGED
@@ -12,4 +12,5 @@ export { useLinkProps } from './useLinkProps';
12
12
  export { useLinkTools } from './useLinkTools';
13
13
  export { useLocale } from './useLocale';
14
14
  export { useScrollToTop } from './useScrollToTop';
15
+ export { useUnhandledLinking } from './useUnhandledLinking';
15
16
  export * from '@react-navigation/core';
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  getPathFromState,
3
- NavigationAction,
3
+ type NavigationAction,
4
4
  NavigationContainerRefContext,
5
5
  NavigationHelpersContext,
6
- NavigatorScreenParams,
7
- ParamListBase,
6
+ type NavigatorScreenParams,
7
+ type ParamListBase,
8
8
  } from '@react-navigation/core';
9
9
  import type { NavigationState, PartialState } from '@react-navigation/routers';
10
10
  import * as React from 'react';
11
- import { GestureResponderEvent, Platform } from 'react-native';
11
+ import { type GestureResponderEvent, Platform } from 'react-native';
12
12
 
13
13
  import { LinkingContext } from './LinkingContext';
14
14
 
15
15
  export type Props<
16
16
  ParamList extends ReactNavigation.RootParamList,
17
- RouteName extends keyof ParamList = keyof ParamList
17
+ RouteName extends keyof ParamList = keyof ParamList,
18
18
  > =
19
19
  | ({
20
20
  screen: Extract<RouteName, string>;
@@ -43,7 +43,7 @@ const getStateFromParams = (
43
43
  {
44
44
  name: params.screen,
45
45
  params: params.params,
46
- // @ts-expect-error
46
+ // @ts-expect-error this is fine 🔥
47
47
  state: params.screen
48
48
  ? getStateFromParams(
49
49
  params.params as
@@ -80,19 +80,20 @@ export function useLinkProps<ParamList extends ReactNavigation.RootParamList>({
80
80
  const onPress = (
81
81
  e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent
82
82
  ) => {
83
+ // @ts-expect-error: these properties exist on web, but not in React Native
84
+ const hasModifierKey = e.metaKey || e.altKey || e.ctrlKey || e.shiftKey; // ignore clicks with modifier keys
85
+ // @ts-expect-error: these properties exist on web, but not in React Native
86
+ const isLeftClick = e.button == null || e.button === 0; // only handle left clicks
87
+ const isSelfTarget = [undefined, null, '', 'self'].includes(
88
+ // @ts-expect-error: these properties exist on web, but not in React Native
89
+ e.currentTarget?.target
90
+ ); // let browser handle "target=_blank" etc.
91
+
83
92
  let shouldHandle = false;
84
93
 
85
94
  if (Platform.OS !== 'web' || !e) {
86
- shouldHandle = e ? !e.defaultPrevented : true;
87
- } else if (
88
- !e.defaultPrevented && // onPress prevented default
89
- // @ts-expect-error: these properties exist on web, but not in React Native
90
- !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys
91
- // @ts-expect-error: these properties exist on web, but not in React Native
92
- (e.button == null || e.button === 0) && // ignore everything but left clicks
93
- // @ts-expect-error: these properties exist on web, but not in React Native
94
- [undefined, null, '', 'self'].includes(e.currentTarget?.target) // let browser handle "target=_blank" etc.
95
- ) {
95
+ shouldHandle = true;
96
+ } else if (!hasModifierKey && isLeftClick && isSelfTarget) {
96
97
  e.preventDefault();
97
98
  shouldHandle = true;
98
99
  }
@@ -109,7 +110,7 @@ export function useLinkProps<ParamList extends ReactNavigation.RootParamList>({
109
110
  );
110
111
  }
111
112
  } else {
112
- // @ts-expect-error: This is already type-checked by the prop types
113
+ // @ts-expect-error This is already type-checked by the prop types
113
114
  navigation?.navigate(screen, params);
114
115
  }
115
116
  }
@@ -126,9 +127,9 @@ export function useLinkProps<ParamList extends ReactNavigation.RootParamList>({
126
127
  routes: [
127
128
  {
128
129
  name: screen,
129
- // @ts-expect-error
130
+ // @ts-expect-error this is fine 🔥
130
131
  params: params,
131
- // @ts-expect-error
132
+ // @ts-expect-error this is fine 🔥
132
133
  state: getStateFromParams(params),
133
134
  },
134
135
  ],
@@ -3,10 +3,10 @@ import {
3
3
  getActionFromState,
4
4
  getPathFromState,
5
5
  getStateFromPath,
6
- NavigationHelpers,
6
+ type NavigationHelpers,
7
7
  NavigationHelpersContext,
8
- NavigationProp,
9
- ParamListBase,
8
+ type NavigationProp,
9
+ type ParamListBase,
10
10
  } from '@react-navigation/core';
11
11
  import * as React from 'react';
12
12