@react-navigation/core 8.0.0-alpha.19 → 8.0.0-alpha.20

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 (144) hide show
  1. package/lib/module/BaseNavigationContainer.js +6 -2
  2. package/lib/module/BaseNavigationContainer.js.map +1 -1
  3. package/lib/module/StaticNavigation.js +72 -61
  4. package/lib/module/StaticNavigation.js.map +1 -1
  5. package/lib/module/findFocusedRoute.js +7 -4
  6. package/lib/module/findFocusedRoute.js.map +1 -1
  7. package/lib/module/getActionFromState.js +25 -12
  8. package/lib/module/getActionFromState.js.map +1 -1
  9. package/lib/module/getPathFromState.js +24 -9
  10. package/lib/module/getPathFromState.js.map +1 -1
  11. package/lib/module/getPatternParts.js +3 -0
  12. package/lib/module/getPatternParts.js.map +1 -1
  13. package/lib/module/getStateFromPath.js +164 -78
  14. package/lib/module/getStateFromPath.js.map +1 -1
  15. package/lib/module/index.js +1 -1
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/module/types.js +8 -0
  18. package/lib/module/types.js.map +1 -1
  19. package/lib/module/useDescriptors.js +13 -6
  20. package/lib/module/useDescriptors.js.map +1 -1
  21. package/lib/module/useFocusEvents.js +5 -1
  22. package/lib/module/useFocusEvents.js.map +1 -1
  23. package/lib/module/useNavigation.js.map +1 -1
  24. package/lib/module/useNavigationBuilder.js +18 -5
  25. package/lib/module/useNavigationBuilder.js.map +1 -1
  26. package/lib/module/useNavigationCache.js +1 -1
  27. package/lib/module/useNavigationCache.js.map +1 -1
  28. package/lib/module/useNavigationState.js.map +1 -1
  29. package/lib/module/useOnAction.js +1 -1
  30. package/lib/module/useOnAction.js.map +1 -1
  31. package/lib/module/useRoute.js.map +1 -1
  32. package/lib/module/validatePathConfig.js +2 -1
  33. package/lib/module/validatePathConfig.js.map +1 -1
  34. package/lib/typescript/src/BaseNavigationContainer.d.ts +2 -2
  35. package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
  36. package/lib/typescript/src/EnsureSingleNavigator.d.ts +1 -1
  37. package/lib/typescript/src/EnsureSingleNavigator.d.ts.map +1 -1
  38. package/lib/typescript/src/Group.d.ts +1 -1
  39. package/lib/typescript/src/Group.d.ts.map +1 -1
  40. package/lib/typescript/src/NavigationBuilderContext.d.ts +1 -1
  41. package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -1
  42. package/lib/typescript/src/NavigationContainerRefContext.d.ts +1 -1
  43. package/lib/typescript/src/NavigationContainerRefContext.d.ts.map +1 -1
  44. package/lib/typescript/src/NavigationHelpersContext.d.ts +1 -1
  45. package/lib/typescript/src/NavigationHelpersContext.d.ts.map +1 -1
  46. package/lib/typescript/src/NavigationIndependentTree.d.ts +1 -1
  47. package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
  48. package/lib/typescript/src/NavigationProvider.d.ts +6 -6
  49. package/lib/typescript/src/NavigationProvider.d.ts.map +1 -1
  50. package/lib/typescript/src/PreventRemoveProvider.d.ts +1 -1
  51. package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -1
  52. package/lib/typescript/src/SceneView.d.ts +3 -2
  53. package/lib/typescript/src/SceneView.d.ts.map +1 -1
  54. package/lib/typescript/src/Screen.d.ts +1 -1
  55. package/lib/typescript/src/Screen.d.ts.map +1 -1
  56. package/lib/typescript/src/StaticNavigation.d.ts +68 -73
  57. package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
  58. package/lib/typescript/src/createNavigationContainerRef.d.ts +1 -1
  59. package/lib/typescript/src/createNavigationContainerRef.d.ts.map +1 -1
  60. package/lib/typescript/src/createNavigatorFactory.d.ts +3 -3
  61. package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -1
  62. package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
  63. package/lib/typescript/src/getActionFromState.d.ts +1 -1
  64. package/lib/typescript/src/getActionFromState.d.ts.map +1 -1
  65. package/lib/typescript/src/getPathFromState.d.ts +1 -1
  66. package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
  67. package/lib/typescript/src/getPatternParts.d.ts +1 -0
  68. package/lib/typescript/src/getPatternParts.d.ts.map +1 -1
  69. package/lib/typescript/src/getStateFromPath.d.ts +2 -2
  70. package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
  71. package/lib/typescript/src/index.d.ts +34 -33
  72. package/lib/typescript/src/index.d.ts.map +1 -1
  73. package/lib/typescript/src/theming/ThemeContext.d.ts +1 -1
  74. package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -1
  75. package/lib/typescript/src/theming/ThemeProvider.d.ts +2 -2
  76. package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -1
  77. package/lib/typescript/src/theming/useTheme.d.ts +1 -1
  78. package/lib/typescript/src/theming/useTheme.d.ts.map +1 -1
  79. package/lib/typescript/src/types.d.ts +72 -37
  80. package/lib/typescript/src/types.d.ts.map +1 -1
  81. package/lib/typescript/src/useChildListeners.d.ts +3 -3
  82. package/lib/typescript/src/useChildListeners.d.ts.map +1 -1
  83. package/lib/typescript/src/useComponent.d.ts +1 -1
  84. package/lib/typescript/src/useComponent.d.ts.map +1 -1
  85. package/lib/typescript/src/useDescriptors.d.ts +5 -5
  86. package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
  87. package/lib/typescript/src/useEventEmitter.d.ts +1 -1
  88. package/lib/typescript/src/useEventEmitter.d.ts.map +1 -1
  89. package/lib/typescript/src/useFocusEvents.d.ts +2 -2
  90. package/lib/typescript/src/useFocusEvents.d.ts.map +1 -1
  91. package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +2 -2
  92. package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -1
  93. package/lib/typescript/src/useKeyedChildListeners.d.ts +3 -3
  94. package/lib/typescript/src/useKeyedChildListeners.d.ts.map +1 -1
  95. package/lib/typescript/src/useNavigation.d.ts +5 -3
  96. package/lib/typescript/src/useNavigation.d.ts.map +1 -1
  97. package/lib/typescript/src/useNavigationBuilder.d.ts +7 -7
  98. package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
  99. package/lib/typescript/src/useNavigationCache.d.ts +3 -3
  100. package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
  101. package/lib/typescript/src/useNavigationContainerRef.d.ts +1 -1
  102. package/lib/typescript/src/useNavigationContainerRef.d.ts.map +1 -1
  103. package/lib/typescript/src/useNavigationHelpers.d.ts +4 -4
  104. package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
  105. package/lib/typescript/src/useNavigationState.d.ts +2 -2
  106. package/lib/typescript/src/useNavigationState.d.ts.map +1 -1
  107. package/lib/typescript/src/useOnAction.d.ts +3 -3
  108. package/lib/typescript/src/useOnAction.d.ts.map +1 -1
  109. package/lib/typescript/src/useOnGetState.d.ts +1 -1
  110. package/lib/typescript/src/useOnGetState.d.ts.map +1 -1
  111. package/lib/typescript/src/useOnPreventRemove.d.ts +3 -3
  112. package/lib/typescript/src/useOnPreventRemove.d.ts.map +1 -1
  113. package/lib/typescript/src/useOptionsGetters.d.ts +1 -1
  114. package/lib/typescript/src/useOptionsGetters.d.ts.map +1 -1
  115. package/lib/typescript/src/usePreventRemoveContext.d.ts +1 -1
  116. package/lib/typescript/src/useRoute.d.ts +2 -2
  117. package/lib/typescript/src/useRoute.d.ts.map +1 -1
  118. package/lib/typescript/src/useRouteCache.d.ts +2 -2
  119. package/lib/typescript/src/useRouteCache.d.ts.map +1 -1
  120. package/lib/typescript/src/useStateForPath.d.ts +1 -1
  121. package/lib/typescript/src/useStateForPath.d.ts.map +1 -1
  122. package/lib/typescript/src/utilities.d.ts +4 -3
  123. package/lib/typescript/src/utilities.d.ts.map +1 -1
  124. package/lib/typescript/src/validatePathConfig.d.ts.map +1 -1
  125. package/package.json +18 -17
  126. package/src/BaseNavigationContainer.tsx +7 -2
  127. package/src/StaticNavigation.tsx +220 -248
  128. package/src/findFocusedRoute.tsx +10 -5
  129. package/src/getActionFromState.tsx +43 -30
  130. package/src/getPathFromState.tsx +40 -20
  131. package/src/getPatternParts.tsx +8 -0
  132. package/src/getStateFromPath.tsx +244 -67
  133. package/src/index.tsx +39 -1
  134. package/src/types.tsx +167 -122
  135. package/src/useDescriptors.tsx +22 -10
  136. package/src/useFocusEvents.tsx +7 -1
  137. package/src/useNavigation.tsx +8 -4
  138. package/src/useNavigationBuilder.tsx +22 -7
  139. package/src/useNavigationCache.tsx +4 -4
  140. package/src/useNavigationState.tsx +3 -3
  141. package/src/useOnAction.tsx +1 -1
  142. package/src/useRoute.tsx +4 -2
  143. package/src/utilities.tsx +17 -11
  144. package/src/validatePathConfig.tsx +1 -0
package/src/useRoute.tsx CHANGED
@@ -22,8 +22,10 @@ type AllRouteNames<ParamList extends {}> = RouteForName<
22
22
  */
23
23
  export function useRoute<
24
24
  const ParamList extends {} = RootParamList,
25
- const RouteName extends AllRouteNames<ParamList> = AllRouteNames<ParamList>,
26
- >(name: RouteName): RouteForName<ParamList, RouteName>;
25
+ const RouteName extends string = string,
26
+ >(
27
+ name: RouteName & AllRouteNames<ParamList>
28
+ ): RouteForName<ParamList, RouteName>;
27
29
  export function useRoute<
28
30
  const ParamList extends {} = RootParamList,
29
31
  >(): {} extends ParamList
package/src/utilities.tsx CHANGED
@@ -121,17 +121,23 @@ export type ExtractParamsType<Params, Parse> = {
121
121
  ? R
122
122
  : Params[K]
123
123
  : Params[K];
124
- } & {
125
- /**
126
- * Optional param types not in path pattern (for query params)
127
- */
128
- [K in QueryParamOptionalKeys<Params, Parse>]?: QueryParamValue<Parse[K]>;
129
- } & {
130
- /**
131
- * Required param types not in path pattern (for query params)
132
- */
133
- [K in QueryParamRequiredKeys<Params, Parse>]: QueryParamValue<Parse[K]>;
134
- };
124
+ } & // Query params are the parse keys not present in the path pattern. When there
125
+ // are none (the common case), skip building the query param mapped types.
126
+ ([Exclude<keyof Parse, keyof Params>] extends [never]
127
+ ? {}
128
+ : {
129
+ /**
130
+ * Optional param types not in path pattern (for query params)
131
+ */
132
+ [K in QueryParamOptionalKeys<Params, Parse>]?: QueryParamValue<
133
+ Parse[K]
134
+ >;
135
+ } & {
136
+ /**
137
+ * Required param types not in path pattern (for query params)
138
+ */
139
+ [K in QueryParamRequiredKeys<Params, Parse>]: QueryParamValue<Parse[K]>;
140
+ });
135
141
 
136
142
  type QueryParamValue<ParseValue> =
137
143
  ParseValue extends StandardSchemaV1<unknown, infer R>
@@ -15,6 +15,7 @@ export function validatePathConfig(config: unknown, root = true) {
15
15
  exact: 'boolean',
16
16
  stringify: 'object',
17
17
  parse: 'object',
18
+ shared: 'boolean',
18
19
  }),
19
20
  };
20
21