@office-iss/react-native-win32 0.73.1 → 0.74.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (478) hide show
  1. package/.eslintignore +1 -1
  2. package/.flowconfig +11 -3
  3. package/CHANGELOG.json +422 -44
  4. package/CHANGELOG.md +162 -26
  5. package/IntegrationTests/AccessibilityManagerTest.js +2 -2
  6. package/IntegrationTests/AppEventsTest.js +2 -2
  7. package/IntegrationTests/LayoutEventsTest.js +8 -10
  8. package/IntegrationTests/LoggingTestModule.js +1 -2
  9. package/IntegrationTests/websocket_integration_test_server.js +1 -1
  10. package/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts +6 -0
  11. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +6 -0
  12. package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +4 -45
  13. package/Libraries/Alert/NativeAlertManager.js +4 -26
  14. package/Libraries/Animated/Animated.js +2 -2
  15. package/Libraries/Animated/AnimatedPlatformConfig.js +1 -1
  16. package/Libraries/Animated/NativeAnimatedHelper.js +14 -11
  17. package/Libraries/Animated/NativeAnimatedHelper.win32.js +14 -11
  18. package/Libraries/Animated/NativeAnimatedModule.js +4 -68
  19. package/Libraries/Animated/NativeAnimatedTurboModule.js +4 -69
  20. package/Libraries/Animated/animations/Animation.js +6 -22
  21. package/Libraries/Animated/components/AnimatedFlatList.js +1 -16
  22. package/Libraries/Animated/components/AnimatedScrollView.js +36 -31
  23. package/Libraries/Animated/components/AnimatedSectionList.js +1 -20
  24. package/Libraries/Animated/createAnimatedComponent.js +45 -40
  25. package/Libraries/Animated/nodes/AnimatedStyle.js +1 -1
  26. package/Libraries/Animated/shouldUseTurboAnimatedModule.js +1 -1
  27. package/Libraries/Animated/useAnimatedProps.js +21 -1
  28. package/Libraries/AppState/NativeAppState.js +4 -24
  29. package/Libraries/BatchedBridge/NativeModules.js +1 -1
  30. package/Libraries/Blob/Blob.js +1 -4
  31. package/Libraries/Blob/BlobManager.js +6 -8
  32. package/Libraries/Blob/File.js +1 -1
  33. package/Libraries/Blob/NativeBlobModule.js +4 -50
  34. package/Libraries/Blob/NativeFileReaderModule.js +4 -13
  35. package/Libraries/BugReporting/NativeBugReporting.js +4 -12
  36. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +5 -1
  37. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +48 -7
  38. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js +3 -23
  39. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfoWin32.js +11 -0
  40. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js +4 -57
  41. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.android.js +3 -2
  42. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.win32.js +3 -2
  43. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +9 -40
  44. package/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +3 -43
  45. package/Libraries/Components/Button/ButtonWin32.Props.d.ts +36 -36
  46. package/Libraries/Components/Button/ButtonWin32.Props.js +2 -2
  47. package/Libraries/Components/Button/ButtonWin32.Props.js.map +1 -1
  48. package/Libraries/Components/Button/ButtonWin32.d.ts +19 -19
  49. package/Libraries/Components/Button/ButtonWin32.js +82 -82
  50. package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
  51. package/Libraries/Components/Button.js +103 -107
  52. package/Libraries/Components/Button.win32.js +297 -301
  53. package/Libraries/Components/Clipboard/NativeClipboard.js +3 -11
  54. package/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +3 -114
  55. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -5
  56. package/Libraries/Components/EnterString.win32.d.ts +12 -12
  57. package/Libraries/Components/EnterString.win32.js +81 -81
  58. package/Libraries/Components/EnterString.win32.js.map +1 -1
  59. package/Libraries/Components/Keyboard/NativeKeyboardObserver.js +3 -10
  60. package/Libraries/Components/PopupMenuAndroid/PopupMenuAndroid.android.js +69 -0
  61. package/Libraries/Components/PopupMenuAndroid/PopupMenuAndroid.d.ts +24 -0
  62. package/Libraries/Components/PopupMenuAndroid/PopupMenuAndroid.js +33 -0
  63. package/Libraries/Components/PopupMenuAndroid/PopupMenuAndroidNativeComponent.js +13 -0
  64. package/Libraries/Components/Pressable/Pressable.js +1 -1
  65. package/Libraries/Components/Pressable/Pressable.win32.js +1 -1
  66. package/Libraries/Components/Pressable/useAndroidRippleForView.js +5 -4
  67. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +4 -24
  68. package/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +3 -64
  69. package/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +3 -61
  70. package/Libraries/Components/RefreshControl/RefreshControl.js +1 -1
  71. package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +3 -15
  72. package/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +3 -16
  73. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +1 -1
  74. package/Libraries/Components/ScrollView/ScrollView.d.ts +5 -6
  75. package/Libraries/Components/ScrollView/ScrollView.js +12 -38
  76. package/Libraries/Components/ScrollView/ScrollView.win32.js +12 -38
  77. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -2
  78. package/Libraries/Components/Sound/NativeSoundManager.js +3 -12
  79. package/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +3 -58
  80. package/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +3 -79
  81. package/Libraries/Components/Switch/AndroidSwitchNativeComponent.js +4 -53
  82. package/Libraries/Components/Switch/Switch.js +0 -2
  83. package/Libraries/Components/Switch/SwitchNativeComponent.js +4 -52
  84. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +8 -0
  85. package/Libraries/Components/TextInput/InputAccessoryView.js +18 -20
  86. package/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js +4 -17
  87. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +3 -6
  88. package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +8 -8
  89. package/Libraries/Components/TextInput/Tests/TextInputTest.js +127 -127
  90. package/Libraries/Components/TextInput/Tests/TextInputTest.js.map +1 -1
  91. package/Libraries/Components/TextInput/TextInput.d.ts +16 -0
  92. package/Libraries/Components/TextInput/TextInput.flow.js +16 -0
  93. package/Libraries/Components/TextInput/TextInput.js +65 -32
  94. package/Libraries/Components/TextInput/TextInput.win32.js +70 -37
  95. package/Libraries/Components/ToastAndroid/NativeToastAndroid.js +3 -28
  96. package/Libraries/Components/Touchable/PooledClass.js +1 -1
  97. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +8 -8
  98. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +343 -344
  99. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  100. package/Libraries/Components/Touchable/Touchable.js +2 -3
  101. package/Libraries/Components/Touchable/Touchable.win32.js +2 -3
  102. package/Libraries/Components/Touchable/TouchableHighlight.js +4 -4
  103. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +2 -1
  104. package/Libraries/Components/Touchable/TouchableOpacity.js +5 -2
  105. package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +37 -37
  106. package/Libraries/Components/Touchable/TouchableWin32.Props.js +2 -2
  107. package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
  108. package/Libraries/Components/Touchable/TouchableWin32.Types.d.ts +114 -114
  109. package/Libraries/Components/Touchable/TouchableWin32.Types.js +2 -2
  110. package/Libraries/Components/Touchable/TouchableWin32.Types.js.map +1 -1
  111. package/Libraries/Components/Touchable/TouchableWin32.d.ts +91 -91
  112. package/Libraries/Components/Touchable/TouchableWin32.js +506 -506
  113. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  114. package/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +3 -16
  115. package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -1
  116. package/Libraries/Components/View/View.js +0 -11
  117. package/Libraries/Components/View/View.win32.js +18 -17
  118. package/Libraries/Components/View/ViewAccessibility.d.ts +33 -17
  119. package/Libraries/Components/View/ViewPropTypes.d.ts +28 -17
  120. package/Libraries/Components/View/ViewPropTypes.js +36 -36
  121. package/Libraries/Components/View/ViewPropTypes.win32.js +36 -36
  122. package/Libraries/Core/InitializeCore.js +1 -1
  123. package/Libraries/Core/NativeExceptionsManager.js +3 -93
  124. package/Libraries/Core/ReactNativeVersion.js +12 -6
  125. package/Libraries/Core/ReactNativeVersionCheck.js +6 -6
  126. package/Libraries/Core/ReactNativeVersionCheck.win32.js +6 -6
  127. package/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js +3 -18
  128. package/Libraries/Core/Timers/NativeTiming.js +3 -16
  129. package/Libraries/Core/registerCallableModule.js +42 -0
  130. package/Libraries/Core/setUpPerformance.js +2 -2
  131. package/Libraries/Core/setUpPerformanceObserver.js +3 -1
  132. package/Libraries/Debugging/DebuggingOverlay.js +111 -0
  133. package/Libraries/Debugging/DebuggingOverlayNativeComponent.js +13 -0
  134. package/Libraries/Debugging/DebuggingOverlayRegistry.js +513 -0
  135. package/Libraries/Debugging/useSubscribeToDebuggingOverlayRegistry.js +32 -0
  136. package/Libraries/DevToolsSettings/NativeDevToolsSettingsManager.js +3 -14
  137. package/Libraries/HeapCapture/NativeJSCHeapCapture.js +3 -9
  138. package/Libraries/Image/AssetSourceResolver.js +5 -5
  139. package/Libraries/Image/AssetUtils.js +4 -5
  140. package/Libraries/Image/Image.android.js +146 -174
  141. package/Libraries/Image/Image.d.ts +1 -1
  142. package/Libraries/Image/Image.ios.js +53 -79
  143. package/Libraries/Image/Image.win32.js +52 -74
  144. package/Libraries/Image/ImageBackground.js +2 -2
  145. package/Libraries/Image/ImageInjection.js +76 -18
  146. package/Libraries/Image/ImageTypes.d.ts +25 -25
  147. package/Libraries/Image/ImageTypes.flow.js +71 -0
  148. package/Libraries/Image/ImageTypes.js +7 -7
  149. package/Libraries/Image/ImageTypes.js.map +1 -1
  150. package/Libraries/Image/ImageUtils.js +1 -1
  151. package/Libraries/Image/ImageViewNativeComponent.js +18 -0
  152. package/Libraries/Image/NativeImageEditor.js +3 -42
  153. package/Libraries/Image/NativeImageLoaderAndroid.js +4 -28
  154. package/Libraries/Image/NativeImageLoaderIOS.js +4 -28
  155. package/Libraries/Image/NativeImageLoaderWin32.js +4 -36
  156. package/Libraries/Image/NativeImageStoreAndroid.js +3 -16
  157. package/Libraries/Image/NativeImageStoreIOS.js +3 -23
  158. package/Libraries/Image/Tests/ImageWin32Test.d.ts +8 -8
  159. package/Libraries/Image/Tests/ImageWin32Test.js +21 -21
  160. package/Libraries/Image/Tests/ImageWin32Test.js.map +1 -1
  161. package/Libraries/Image/resolveAssetSource.js +59 -26
  162. package/Libraries/Inspector/ElementProperties.js +26 -52
  163. package/Libraries/Inspector/Inspector.js +122 -186
  164. package/Libraries/Inspector/Inspector.win32.js +118 -185
  165. package/Libraries/Inspector/InspectorOverlay.js +21 -33
  166. package/Libraries/Inspector/InspectorOverlay.win32.js +22 -33
  167. package/Libraries/Inspector/InspectorPanel.js +3 -17
  168. package/Libraries/Inspector/ReactDevToolsOverlay.js +171 -0
  169. package/Libraries/Inspector/getInspectorDataForViewAtPoint.js +20 -8
  170. package/Libraries/Interaction/FrameRateLogger.js +8 -18
  171. package/Libraries/Interaction/NativeFrameRateLogger.js +4 -16
  172. package/Libraries/IntersectionObserver/IntersectionObserver.js +1 -1
  173. package/Libraries/IntersectionObserver/IntersectionObserverEntry.js +20 -19
  174. package/Libraries/IntersectionObserver/IntersectionObserverManager.js +84 -6
  175. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +3 -31
  176. package/Libraries/IntersectionObserver/__mocks__/NativeIntersectionObserver.js +12 -2
  177. package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -2
  178. package/Libraries/Linking/NativeIntentAndroid.js +3 -20
  179. package/Libraries/Linking/NativeLinkingManager.js +3 -17
  180. package/Libraries/Lists/FillRateHelper.js +1 -1
  181. package/Libraries/Lists/FlatList.d.ts +2 -2
  182. package/Libraries/Lists/FlatList.js +6 -1
  183. package/Libraries/Lists/SectionList.d.ts +6 -1
  184. package/Libraries/Lists/ViewabilityHelper.js +1 -1
  185. package/Libraries/Lists/VirtualizeUtils.js +1 -1
  186. package/Libraries/Lists/VirtualizedList.js +1 -1
  187. package/Libraries/Lists/VirtualizedListContext.js +1 -1
  188. package/Libraries/Lists/VirtualizedSectionList.js +1 -1
  189. package/Libraries/LogBox/LogBoxInspectorContainer.js +1 -1
  190. package/Libraries/Modal/Modal.js +43 -11
  191. package/Libraries/Modal/NativeModalManager.js +3 -11
  192. package/Libraries/Modal/RCTModalHostViewNativeComponent.js +3 -129
  193. package/Libraries/MutationObserver/MutationObserver.js +1 -1
  194. package/Libraries/MutationObserver/MutationObserverManager.js +2 -2
  195. package/Libraries/MutationObserver/MutationRecord.js +12 -10
  196. package/Libraries/MutationObserver/NativeMutationObserver.js +3 -48
  197. package/Libraries/MutationObserver/__mocks__/NativeMutationObserver.js +1 -1
  198. package/Libraries/NativeComponent/BaseViewConfig.android.js +1 -0
  199. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  200. package/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js +3 -10
  201. package/Libraries/NativeModules/specs/NativeDevMenu.js +3 -13
  202. package/Libraries/NativeModules/specs/NativeDevSettings.js +3 -23
  203. package/Libraries/NativeModules/specs/NativeDeviceEventManager.js +3 -9
  204. package/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js +3 -38
  205. package/Libraries/NativeModules/specs/NativeLogBox.js +3 -10
  206. package/Libraries/NativeModules/specs/NativeRedBox.js +4 -11
  207. package/Libraries/NativeModules/specs/NativeSourceCode.js +2 -25
  208. package/Libraries/Network/FormData.js +3 -1
  209. package/Libraries/Network/NativeNetworkingAndroid.js +4 -28
  210. package/Libraries/Network/NativeNetworkingIOS.js +4 -28
  211. package/Libraries/Performance/NativeJSCSamplingProfiler.js +3 -9
  212. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +4 -68
  213. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -3
  214. package/Libraries/PersonaCoin/PersonaCoin.d.ts +3 -3
  215. package/Libraries/PersonaCoin/PersonaCoin.js +14 -14
  216. package/Libraries/PersonaCoin/PersonaCoin.js.map +1 -1
  217. package/Libraries/PersonaCoin/PersonaCoinPropTypes.d.ts +2 -2
  218. package/Libraries/PersonaCoin/PersonaCoinPropTypes.js +19 -19
  219. package/Libraries/PersonaCoin/PersonaCoinPropTypes.js.map +1 -1
  220. package/Libraries/PersonaCoin/PersonaCoinTypes.d.ts +33 -33
  221. package/Libraries/PersonaCoin/PersonaCoinTypes.js +23 -23
  222. package/Libraries/PersonaCoin/PersonaCoinTypes.js.map +1 -1
  223. package/Libraries/Pressability/Pressability.js +12 -2
  224. package/Libraries/Pressability/Pressability.win32.js +12 -2
  225. package/Libraries/Pressability/usePressability.js +7 -0
  226. package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +4 -70
  227. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +45 -39
  228. package/Libraries/ReactNative/AppContainer-dev.js +192 -0
  229. package/Libraries/ReactNative/AppContainer-prod.js +53 -0
  230. package/Libraries/ReactNative/AppContainer.js +6 -149
  231. package/Libraries/ReactNative/AppRegistry.js +3 -1
  232. package/Libraries/ReactNative/BridgelessUIManager.js +375 -128
  233. package/Libraries/ReactNative/FabricUIManager.js +6 -0
  234. package/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js +3 -10
  235. package/Libraries/ReactNative/NativeI18nManager.js +3 -18
  236. package/Libraries/ReactNative/NativeUIManager.js +4 -112
  237. package/Libraries/ReactNative/PaperUIManager.js +8 -7
  238. package/Libraries/ReactNative/PaperUIManager.win32.js +26 -7
  239. package/Libraries/ReactNative/ReactFabricInternals.js +1 -1
  240. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +24 -5
  241. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -45
  242. package/Libraries/ReactNative/RendererImplementation.js +11 -0
  243. package/Libraries/ReactNative/UIManager.d.ts +11 -34
  244. package/Libraries/ReactNative/UIManager.js +2 -23
  245. package/Libraries/ReactNative/UIManagerProperties.js +0 -2
  246. package/Libraries/ReactNative/__mocks__/FabricUIManager.js +23 -1
  247. package/Libraries/ReactNative/getNativeComponentAttributes.js +5 -1
  248. package/Libraries/ReactNative/renderApplication.js +9 -6
  249. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +6 -1
  250. package/Libraries/Renderer/implementations/ReactFabric-dev.js +24771 -21123
  251. package/Libraries/Renderer/implementations/ReactFabric-prod.js +4160 -3109
  252. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4384 -3322
  253. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +25194 -21398
  254. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3763 -2636
  255. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4027 -2867
  256. package/Libraries/Renderer/shims/ReactNativeTypes.js +8 -9
  257. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +7 -12
  258. package/Libraries/Settings/NativeSettingsManager.js +4 -16
  259. package/Libraries/Share/NativeShareModule.js +3 -13
  260. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +1 -1
  261. package/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  262. package/Libraries/StyleSheet/PlatformColorValueTypesWin32.js +1 -1
  263. package/Libraries/StyleSheet/StyleSheet.d.ts +1 -20
  264. package/Libraries/StyleSheet/StyleSheet.js +5 -28
  265. package/Libraries/StyleSheet/StyleSheet.win32.js +5 -28
  266. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +47 -7
  267. package/Libraries/StyleSheet/StyleSheetTypes.js +16 -11
  268. package/Libraries/StyleSheet/flattenStyle.js +2 -2
  269. package/Libraries/StyleSheet/normalizeColor.js +1 -1
  270. package/Libraries/StyleSheet/processAspectRatio.js +1 -1
  271. package/Libraries/StyleSheet/processFontVariant.js +1 -1
  272. package/Libraries/Text/Text.d.ts +85 -0
  273. package/Libraries/Text/Text.js +0 -6
  274. package/Libraries/Text/Text.win32.js +0 -6
  275. package/Libraries/Text/TextAncestor.js +2 -3
  276. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +4 -41
  277. package/Libraries/Types/ReactDevToolsTypes.js +58 -0
  278. package/Libraries/Types/UIManagerJSInterface.js +16 -0
  279. package/Libraries/Utilities/DebugEnvironment.js +1 -4
  280. package/Libraries/Utilities/Dimensions.js +8 -16
  281. package/Libraries/Utilities/Dimensions.win32.js +8 -16
  282. package/Libraries/Utilities/FocusManager.win32.js +2 -0
  283. package/Libraries/Utilities/GlobalPerformanceLogger.js +1 -2
  284. package/Libraries/Utilities/NativeAppearance.js +3 -26
  285. package/Libraries/Utilities/NativeDevLoadingView.js +3 -14
  286. package/Libraries/Utilities/NativeDeviceInfo.js +2 -47
  287. package/Libraries/Utilities/NativePlatformConstantsAndroid.js +3 -34
  288. package/Libraries/Utilities/NativePlatformConstantsIOS.js +3 -26
  289. package/Libraries/Utilities/NativePlatformConstantsWin.js +3 -23
  290. package/Libraries/Utilities/PixelRatio.d.ts +4 -4
  291. package/Libraries/Utilities/Platform.android.js +4 -0
  292. package/Libraries/Utilities/Platform.d.ts +3 -0
  293. package/Libraries/Utilities/Platform.flow.js +7 -0
  294. package/Libraries/Utilities/Platform.flow.win32.js +18 -5
  295. package/Libraries/Utilities/Platform.ios.js +11 -0
  296. package/Libraries/Utilities/Platform.win32.js +9 -1
  297. package/Libraries/Utilities/binaryToBase64.js +1 -1
  298. package/Libraries/Utilities/codegenNativeComponent.js +4 -6
  299. package/Libraries/Utilities/createPerformanceLogger.js +2 -74
  300. package/Libraries/Utilities/useMergeRefs.js +5 -9
  301. package/Libraries/Vibration/NativeVibration.js +3 -14
  302. package/Libraries/WebSocket/NativeWebSocketModule.js +4 -25
  303. package/Libraries/YellowBox/YellowBoxDeprecated.js +1 -1
  304. package/Libraries/platform-types.d.ts +2 -3
  305. package/Libraries/vendor/emitter/EventEmitter.js +1 -0
  306. package/babel.config.js +1 -1
  307. package/flow/jest.js +1 -1
  308. package/flow/react.js +15 -0
  309. package/index.js +66 -99
  310. package/index.win32.js +60 -101
  311. package/jest/assetFileTransformer.js +1 -1
  312. package/jest/local-setup.js +0 -5
  313. package/jest/mockModal.js +2 -1
  314. package/jest/mockScrollView.js +1 -2
  315. package/jest/renderer.js +1 -1
  316. package/jest/setup.js +6 -3
  317. package/jest.config.js +2 -1
  318. package/overrides.json +157 -130
  319. package/package.json +26 -26
  320. package/{Libraries/Core → src/private/core}/setUpDOM.js +2 -2
  321. package/src/private/featureflags/NativeReactNativeFeatureFlags.js +42 -0
  322. package/src/private/featureflags/ReactNativeFeatureFlags.js +140 -0
  323. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +84 -0
  324. package/src/private/featureflags/__tests__/ReactNativeFeatureFlags-test.js +92 -0
  325. package/src/private/specs/components/ActivityIndicatorViewNativeComponent.js +53 -0
  326. package/src/private/specs/components/AndroidDrawerLayoutNativeComponent.js +124 -0
  327. package/src/private/specs/components/AndroidHorizontalScrollContentViewNativeComponent.js +26 -0
  328. package/src/private/specs/components/AndroidSwipeRefreshLayoutNativeComponent.js +74 -0
  329. package/src/private/specs/components/AndroidSwitchNativeComponent.js +62 -0
  330. package/src/private/specs/components/DebuggingOverlayNativeComponent.js +61 -0
  331. package/src/private/specs/components/PopupMenuAndroidNativeComponent.js +47 -0
  332. package/src/private/specs/components/ProgressBarAndroidNativeComponent.js +36 -0
  333. package/src/private/specs/components/PullToRefreshViewNativeComponent.js +71 -0
  334. package/src/private/specs/components/RCTInputAccessoryViewNativeComponent.js +26 -0
  335. package/src/private/specs/components/RCTModalHostViewNativeComponent.js +139 -0
  336. package/src/private/specs/components/RCTSafeAreaViewNativeComponent.js +25 -0
  337. package/src/private/specs/components/SwitchNativeComponent.js +61 -0
  338. package/src/private/specs/components/UnimplementedNativeViewNativeComponent.js +26 -0
  339. package/src/private/specs/modules/NativeAccessibilityInfo.js +33 -0
  340. package/src/private/specs/modules/NativeAccessibilityInfoWin32.js +39 -0
  341. package/src/private/specs/modules/NativeAccessibilityManager.js +66 -0
  342. package/src/private/specs/modules/NativeActionSheetManager.js +54 -0
  343. package/src/private/specs/modules/NativeAlertManager.js +35 -0
  344. package/src/private/specs/modules/NativeAnimatedModule.js +77 -0
  345. package/src/private/specs/modules/NativeAnimatedTurboModule.js +78 -0
  346. package/src/private/specs/modules/NativeAnimationsDebugModule.js +20 -0
  347. package/src/private/specs/modules/NativeAppState.js +33 -0
  348. package/src/private/specs/modules/NativeAppearance.js +36 -0
  349. package/src/private/specs/modules/NativeBlobModule.js +59 -0
  350. package/src/private/specs/modules/NativeBugReporting.js +20 -0
  351. package/src/private/specs/modules/NativeClipboard.js +21 -0
  352. package/src/private/specs/modules/NativeDevLoadingView.js +24 -0
  353. package/src/private/specs/modules/NativeDevMenu.js +23 -0
  354. package/src/private/specs/modules/NativeDevSettings.js +33 -0
  355. package/src/private/specs/modules/NativeDevToolsSettingsManager.js +24 -0
  356. package/src/private/specs/modules/NativeDeviceEventManager.js +19 -0
  357. package/src/private/specs/modules/NativeDeviceInfo.js +58 -0
  358. package/src/private/specs/modules/NativeDialogManagerAndroid.js +48 -0
  359. package/src/private/specs/modules/NativeExceptionsManager.js +103 -0
  360. package/src/private/specs/modules/NativeFileReaderModule.js +22 -0
  361. package/src/private/specs/modules/NativeFrameRateLogger.js +22 -0
  362. package/src/private/specs/modules/NativeHeadlessJsTaskSupport.js +20 -0
  363. package/src/private/specs/modules/NativeI18nManager.js +28 -0
  364. package/src/private/specs/modules/NativeImageEditor.js +52 -0
  365. package/src/private/specs/modules/NativeImageLoaderAndroid.js +30 -0
  366. package/src/private/specs/modules/NativeImageLoaderIOS.js +37 -0
  367. package/src/private/specs/modules/NativeImageLoaderWin32.js +45 -0
  368. package/src/private/specs/modules/NativeImageStoreAndroid.js +26 -0
  369. package/src/private/specs/modules/NativeImageStoreIOS.js +33 -0
  370. package/src/private/specs/modules/NativeIntentAndroid.js +30 -0
  371. package/src/private/specs/modules/NativeIntersectionObserver.js +41 -0
  372. package/src/private/specs/modules/NativeJSCHeapCapture.js +19 -0
  373. package/src/private/specs/modules/NativeJSCSamplingProfiler.js +19 -0
  374. package/src/private/specs/modules/NativeKeyboardObserver.js +20 -0
  375. package/src/private/specs/modules/NativeLinkingManager.js +27 -0
  376. package/src/private/specs/modules/NativeLogBox.js +20 -0
  377. package/src/private/specs/modules/NativeModalManager.js +21 -0
  378. package/src/private/specs/modules/NativeMutationObserver.js +58 -0
  379. package/src/private/specs/modules/NativeNetworkingAndroid.js +37 -0
  380. package/src/private/specs/modules/NativeNetworkingIOS.js +37 -0
  381. package/src/private/specs/modules/NativePermissionsAndroid.js +77 -0
  382. package/src/private/specs/modules/NativePlatformConstantsAndroid.js +44 -0
  383. package/src/private/specs/modules/NativePlatformConstantsIOS.js +37 -0
  384. package/src/private/specs/modules/NativePlatformConstantsWin.js +37 -0
  385. package/src/private/specs/modules/NativePushNotificationManagerIOS.js +107 -0
  386. package/src/private/specs/modules/NativeRedBox.js +20 -0
  387. package/src/private/specs/modules/NativeSampleTurboModule.js +53 -0
  388. package/src/private/specs/modules/NativeSegmentFetcher.js +28 -0
  389. package/src/private/specs/modules/NativeSettingsManager.js +25 -0
  390. package/src/private/specs/modules/NativeShareModule.js +23 -0
  391. package/src/private/specs/modules/NativeSoundManager.js +22 -0
  392. package/src/private/specs/modules/NativeSourceCode.js +36 -0
  393. package/src/private/specs/modules/NativeStatusBarManagerAndroid.js +68 -0
  394. package/src/private/specs/modules/NativeStatusBarManagerIOS.js +89 -0
  395. package/src/private/specs/modules/NativeTiming.js +26 -0
  396. package/src/private/specs/modules/NativeToastAndroid.js +38 -0
  397. package/src/private/specs/modules/NativeUIManager.js +118 -0
  398. package/src/private/specs/modules/NativeVibration.js +24 -0
  399. package/src/private/specs/modules/NativeWebSocketModule.js +34 -0
  400. package/{Libraries/DOM/Nodes → src/private/webapis/dom/nodes}/ReactNativeElement.js +6 -6
  401. package/{Libraries/DOM/Nodes → src/private/webapis/dom/nodes}/ReadOnlyCharacterData.js +2 -2
  402. package/{Libraries/DOM/Nodes → src/private/webapis/dom/nodes}/ReadOnlyElement.js +5 -5
  403. package/{Libraries/DOM/Nodes → src/private/webapis/dom/nodes}/ReadOnlyNode.js +19 -10
  404. package/{Libraries/DOM/OldStyleCollections → src/private/webapis/dom/oldstylecollections}/DOMRectList.js +1 -1
  405. package/src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js +85 -0
  406. package/src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js +80 -0
  407. package/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js +161 -0
  408. package/{Libraries/WebPerformance → src/private/webapis/performance}/NativePerformance.js +2 -2
  409. package/{Libraries/WebPerformance → src/private/webapis/performance}/NativePerformanceObserver.js +3 -2
  410. package/{Libraries/WebPerformance → src/private/webapis/performance}/Performance.js +2 -2
  411. package/{Libraries/WebPerformance → src/private/webapis/performance}/PerformanceEventTiming.js +1 -1
  412. package/{Libraries/WebPerformance → src/private/webapis/performance}/PerformanceObserver.js +21 -2
  413. package/{Libraries/WebPerformance → src/private/webapis/performance}/RawPerformanceEntry.js +1 -1
  414. package/{Libraries/WebPerformance → src/private/webapis/performance}/__mocks__/NativePerformanceObserver.js +9 -0
  415. package/src/private/webapis/performance/__tests__/EventCounts-test.js +116 -0
  416. package/src/private/webapis/performance/__tests__/NativePerformanceMock-test.js +82 -0
  417. package/src/private/webapis/performance/__tests__/NativePerformanceObserverMock-test.js +108 -0
  418. package/src/private/webapis/performance/__tests__/Performance-test.js +117 -0
  419. package/src/private/webapis/performance/__tests__/PerformanceObserver-test.js +208 -0
  420. package/src-win/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +161 -0
  421. package/{src → src-win}/Libraries/Components/Button/ButtonWin32.tsx +3 -3
  422. package/{src → src-win}/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +9 -10
  423. package/{src → src-win}/Libraries/Components/View/ViewAccessibility.d.ts +33 -17
  424. package/{src → src-win}/Libraries/Components/View/ViewPropTypes.d.ts +28 -17
  425. package/{src → src-win}/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  426. package/src-win/Libraries/Text/Text.d.ts +304 -0
  427. package/{src → src-win}/Libraries/platform-types.d.ts +2 -3
  428. package/types/modules/globals.d.ts +1 -0
  429. package/Libraries/Components/Button.flow.js +0 -265
  430. package/Libraries/Components/ScrollView/ScrollViewViewConfig.js +0 -85
  431. package/Libraries/Components/Text/TextWin32.Props.d.ts +0 -63
  432. package/Libraries/Components/Text/TextWin32.Props.js +0 -3
  433. package/Libraries/Components/Text/TextWin32.Props.js.map +0 -1
  434. package/Libraries/Components/Text/TextWin32.d.ts +0 -6
  435. package/Libraries/Components/Text/TextWin32.js +0 -18
  436. package/Libraries/Components/Text/TextWin32.js.map +0 -1
  437. package/Libraries/Components/Touchable/Touchable.flow.js +0 -284
  438. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +0 -189
  439. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlayNativeComponent.js +0 -43
  440. package/Libraries/Image/Image.flow.js +0 -64
  441. package/Libraries/Inspector/DevtoolsOverlay.js +0 -223
  442. package/Libraries/Performance/QuickPerformanceLogger.js +0 -142
  443. package/src/Libraries/Components/Text/TextWin32.Props.ts +0 -82
  444. package/src/Libraries/Components/Text/TextWin32.tsx +0 -25
  445. /package/{Libraries/DOM/Geometry → src/private/webapis/dom/geometry}/DOMRect.js +0 -0
  446. /package/{Libraries/DOM/Geometry → src/private/webapis/dom/geometry}/DOMRectReadOnly.js +0 -0
  447. /package/{Libraries/DOM/Nodes → src/private/webapis/dom/nodes}/ReadOnlyText.js +0 -0
  448. /package/{Libraries/DOM/Nodes/Utilities → src/private/webapis/dom/nodes/utilities}/Traversal.js +0 -0
  449. /package/{Libraries/DOM/OldStyleCollections → src/private/webapis/dom/oldstylecollections}/ArrayLikeUtils.js +0 -0
  450. /package/{Libraries/DOM/OldStyleCollections → src/private/webapis/dom/oldstylecollections}/HTMLCollection.js +0 -0
  451. /package/{Libraries/DOM/OldStyleCollections → src/private/webapis/dom/oldstylecollections}/NodeList.js +0 -0
  452. /package/{Libraries/WebPerformance → src/private/webapis/performance}/EventCounts.js +0 -0
  453. /package/{Libraries/WebPerformance → src/private/webapis/performance}/MemoryInfo.js +0 -0
  454. /package/{Libraries/WebPerformance → src/private/webapis/performance}/PerformanceEntry.js +0 -0
  455. /package/{Libraries/WebPerformance → src/private/webapis/performance}/ReactNativeStartupTiming.js +0 -0
  456. /package/{Libraries/WebPerformance → src/private/webapis/performance}/__mocks__/NativePerformance.js +0 -0
  457. /package/{src → src-win}/Libraries/Components/Button/ButtonWin32.Props.ts +0 -0
  458. /package/{src → src-win}/Libraries/Components/EnterString.win32.tsx +0 -0
  459. /package/{src → src-win}/Libraries/Components/TextInput/Tests/TextInputTest.tsx +0 -0
  460. /package/{src → src-win}/Libraries/Components/Touchable/TouchableNativeFeedback.d.ts +0 -0
  461. /package/{src → src-win}/Libraries/Components/Touchable/TouchableWin32.Props.tsx +0 -0
  462. /package/{src → src-win}/Libraries/Components/Touchable/TouchableWin32.Types.tsx +0 -0
  463. /package/{src → src-win}/Libraries/Components/Touchable/TouchableWin32.tsx +0 -0
  464. /package/{src → src-win}/Libraries/Components/View/ViewWin32.d.ts +0 -0
  465. /package/{src → src-win}/Libraries/Image/ImageTypes.ts +0 -0
  466. /package/{src → src-win}/Libraries/Image/Tests/ImageWin32Test.tsx +0 -0
  467. /package/{src → src-win}/Libraries/Image/Tests/img/dpitest.png +0 -0
  468. /package/{src → src-win}/Libraries/Image/Tests/img/dpitest@1.5x.png +0 -0
  469. /package/{src → src-win}/Libraries/Image/Tests/img/dpitest@2x.png +0 -0
  470. /package/{src → src-win}/Libraries/Image/Tests/img/dpitest@3x.png +0 -0
  471. /package/{src → src-win}/Libraries/Image/Tests/img/en-us/dpitest.png +0 -0
  472. /package/{src → src-win}/Libraries/Image/Tests/img/en-us/dpitest@1.5x.png +0 -0
  473. /package/{src → src-win}/Libraries/Image/Tests/img/en-us/dpitest@3x.png +0 -0
  474. /package/{src → src-win}/Libraries/PersonaCoin/PersonaCoin.tsx +0 -0
  475. /package/{src → src-win}/Libraries/PersonaCoin/PersonaCoinPropTypes.ts +0 -0
  476. /package/{src → src-win}/Libraries/PersonaCoin/PersonaCoinTypes.ts +0 -0
  477. /package/{src → src-win}/Libraries/Utilities/FocusManager.win32.d.ts +0 -0
  478. /package/{src → src-win}/Libraries/__tests__/__snapshots__/ButtonWin32-test.js.snap +0 -0
@@ -1,507 +1,507 @@
1
- /**
2
- * This is primarily a fork of React Native's Touchable Mixin.
3
- * It has been repurposed as it's own standalone control for win32,
4
- * as it needs to support a richer set of functionality on the desktop.
5
- * The touchable variants can be rewritten as wrappers around TouchableWin32
6
- * by passing the correct set of props down and managing state correctly.
7
- *
8
- * React Native's Touchable.js file (https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/Touchable.js)
9
- * provides an overview over how touchables work and interact with the gesture responder system.
10
- */
11
- 'use strict';
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.TouchableWin32 = void 0;
17
- const react_1 = __importDefault(require("react"));
18
- const react_native_1 = require("react-native");
19
- const BoundingDimensions = require('./BoundingDimensions');
20
- const Position = require('./Position');
21
- const { findNodeHandle } = require('../../Renderer/shims/ReactNative');
22
- /**
23
- * Extracts a single touch, generally this is the active touch or touch that
24
- * has just ended
25
- * @param e - a press event containing information about the native event
26
- */
27
- function extractSingleTouch(e) {
28
- const nativeEvent = e.nativeEvent;
29
- const touches = nativeEvent.touches;
30
- const changedTouches = nativeEvent.changedTouches;
31
- const hasTouches = touches && touches.length > 0;
32
- const hasChangedTouches = changedTouches && changedTouches.length > 0;
33
- return !hasTouches && hasChangedTouches ? changedTouches[0] : hasTouches ? touches[0] : nativeEvent;
34
- }
35
- /** Quick lookup maps for a variety of conditions */
36
- const baseStatesCondition = {
37
- NOT_RESPONDER: false,
38
- RESPONDER_INACTIVE_PRESS_IN: false,
39
- RESPONDER_INACTIVE_PRESS_OUT: false,
40
- RESPONDER_ACTIVE_PRESS_IN: false,
41
- RESPONDER_ACTIVE_PRESS_OUT: false,
42
- RESPONDER_ACTIVE_LONG_PRESS_IN: false,
43
- RESPONDER_ACTIVE_LONG_PRESS_OUT: false,
44
- ERROR: false,
45
- };
46
- const IsActive = {
47
- ...baseStatesCondition,
48
- RESPONDER_ACTIVE_PRESS_OUT: true,
49
- RESPONDER_ACTIVE_PRESS_IN: true,
50
- };
51
- const IsPressingIn = {
52
- ...baseStatesCondition,
53
- RESPONDER_INACTIVE_PRESS_IN: true,
54
- RESPONDER_ACTIVE_PRESS_IN: true,
55
- RESPONDER_ACTIVE_LONG_PRESS_IN: true,
56
- };
57
- const IsLongPressingIn = {
58
- ...baseStatesCondition,
59
- RESPONDER_ACTIVE_LONG_PRESS_IN: true,
60
- };
61
- const transitions = {
62
- NOT_RESPONDER: {
63
- DELAY: 'ERROR',
64
- RESPONDER_GRANT: 'RESPONDER_INACTIVE_PRESS_IN',
65
- RESPONDER_RELEASE: 'ERROR',
66
- RESPONDER_TERMINATED: 'ERROR',
67
- ENTER_PRESS_RECT: 'ERROR',
68
- LEAVE_PRESS_RECT: 'ERROR',
69
- LONG_PRESS_DETECTED: 'ERROR',
70
- },
71
- RESPONDER_INACTIVE_PRESS_IN: {
72
- DELAY: 'RESPONDER_ACTIVE_PRESS_IN',
73
- RESPONDER_GRANT: 'ERROR',
74
- RESPONDER_RELEASE: 'NOT_RESPONDER',
75
- RESPONDER_TERMINATED: 'NOT_RESPONDER',
76
- ENTER_PRESS_RECT: 'RESPONDER_INACTIVE_PRESS_IN',
77
- LEAVE_PRESS_RECT: 'RESPONDER_INACTIVE_PRESS_OUT',
78
- LONG_PRESS_DETECTED: 'ERROR',
79
- },
80
- RESPONDER_INACTIVE_PRESS_OUT: {
81
- DELAY: 'RESPONDER_ACTIVE_PRESS_OUT',
82
- RESPONDER_GRANT: 'ERROR',
83
- RESPONDER_RELEASE: 'NOT_RESPONDER',
84
- RESPONDER_TERMINATED: 'NOT_RESPONDER',
85
- ENTER_PRESS_RECT: 'RESPONDER_INACTIVE_PRESS_IN',
86
- LEAVE_PRESS_RECT: 'RESPONDER_INACTIVE_PRESS_OUT',
87
- LONG_PRESS_DETECTED: 'ERROR',
88
- },
89
- RESPONDER_ACTIVE_PRESS_IN: {
90
- DELAY: 'ERROR',
91
- RESPONDER_GRANT: 'ERROR',
92
- RESPONDER_RELEASE: 'NOT_RESPONDER',
93
- RESPONDER_TERMINATED: 'NOT_RESPONDER',
94
- ENTER_PRESS_RECT: 'RESPONDER_ACTIVE_PRESS_IN',
95
- LEAVE_PRESS_RECT: 'RESPONDER_ACTIVE_PRESS_OUT',
96
- LONG_PRESS_DETECTED: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
97
- },
98
- RESPONDER_ACTIVE_PRESS_OUT: {
99
- DELAY: 'ERROR',
100
- RESPONDER_GRANT: 'ERROR',
101
- RESPONDER_RELEASE: 'NOT_RESPONDER',
102
- RESPONDER_TERMINATED: 'NOT_RESPONDER',
103
- ENTER_PRESS_RECT: 'RESPONDER_ACTIVE_PRESS_IN',
104
- LEAVE_PRESS_RECT: 'RESPONDER_ACTIVE_PRESS_OUT',
105
- LONG_PRESS_DETECTED: 'ERROR',
106
- },
107
- RESPONDER_ACTIVE_LONG_PRESS_IN: {
108
- DELAY: 'ERROR',
109
- RESPONDER_GRANT: 'ERROR',
110
- RESPONDER_RELEASE: 'NOT_RESPONDER',
111
- RESPONDER_TERMINATED: 'NOT_RESPONDER',
112
- ENTER_PRESS_RECT: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
113
- LEAVE_PRESS_RECT: 'RESPONDER_ACTIVE_LONG_PRESS_OUT',
114
- LONG_PRESS_DETECTED: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
115
- },
116
- RESPONDER_ACTIVE_LONG_PRESS_OUT: {
117
- DELAY: 'ERROR',
118
- RESPONDER_GRANT: 'ERROR',
119
- RESPONDER_RELEASE: 'NOT_RESPONDER',
120
- RESPONDER_TERMINATED: 'NOT_RESPONDER',
121
- ENTER_PRESS_RECT: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
122
- LEAVE_PRESS_RECT: 'RESPONDER_ACTIVE_LONG_PRESS_OUT',
123
- LONG_PRESS_DETECTED: 'ERROR',
124
- },
125
- ERROR: {
126
- DELAY: 'NOT_RESPONDER',
127
- RESPONDER_GRANT: 'RESPONDER_INACTIVE_PRESS_IN',
128
- RESPONDER_RELEASE: 'NOT_RESPONDER',
129
- RESPONDER_TERMINATED: 'NOT_RESPONDER',
130
- ENTER_PRESS_RECT: 'NOT_RESPONDER',
131
- LEAVE_PRESS_RECT: 'NOT_RESPONDER',
132
- LONG_PRESS_DETECTED: 'NOT_RESPONDER',
133
- },
134
- };
135
- /** Constants for integrating into UI Components */
136
- const HIGHLIGHT_DELAY_MS = 130;
137
- const PRESS_EXPAND_DIPS = 20; // Subject to change for win32 and desktop
138
- const LONG_PRESS_THRESHOLD = 500;
139
- const LONG_PRESS_DELAY_MS = LONG_PRESS_THRESHOLD - HIGHLIGHT_DELAY_MS;
140
- const LONG_PRESS_ALLOWED_MOVEMENT = 10;
141
- /**
142
- * TouchableWin32 is a 'componentization' of the Touchable Mixin in React Native.
143
- * This means that instead of implementing components such as TouchableHighlight
144
- * via the mixin, they are merely implemented as wrappers around TouchableWin32,
145
- * forwarding the correct set of props. Additionally, TouchableWin32 supports hover
146
- * via onMouseEnter and onMouseLeave and focus/blur via onFocus/onBlur.
147
- * TouchableWin32 also allows for functions as child components (that use the internal
148
- * state of the touchable to conditionally render children) as well functions as styles
149
- * (that use internal state to conditionally calculate styles)
150
- */
151
- class TouchableWin32 extends react_1.default.Component {
152
- constructor(props) {
153
- super(props);
154
- this.focus = () => {
155
- this._internalRef.current.focus();
156
- };
157
- /**
158
- * The rejectResponderTermination prop provides a way to accept/reject termination requests
159
- */
160
- this._touchableHandleResponderTerminationRequest = () => {
161
- return !this.props.rejectResponderTermination;
162
- };
163
- /**
164
- * Only reject an opportunity to become the responder on bubble if disabled
165
- */
166
- this._touchableHandleStartShouldSetResponder = () => {
167
- return !this.props.disabled;
168
- };
169
- /** TODO: Long press cancel as a prop may be a good idea */
170
- this._touchableLongPressCancelsPress = () => {
171
- return true;
172
- };
173
- /**
174
- * On responder being granted, state and local data need to be set
175
- */
176
- this._touchableHandleResponderGrant = (e) => {
177
- const dispatchID = findNodeHandle(e.currentTarget);
178
- e.persist();
179
- this._pressOutDelayTimeout && clearTimeout(this._pressOutDelayTimeout);
180
- this._pressOutDelayTimeout = null;
181
- this._touchState = 'NOT_RESPONDER';
182
- this._responderID = dispatchID;
183
- this._receiveSignal('RESPONDER_GRANT', e);
184
- let delayMS = this.props.touchableGetHighlightDelayMS
185
- ? Math.max(this.props.touchableGetHighlightDelayMS(), 0)
186
- : HIGHLIGHT_DELAY_MS;
187
- delayMS = isNaN(delayMS) ? HIGHLIGHT_DELAY_MS : delayMS;
188
- if (delayMS !== 0) {
189
- this._touchableDelayTimeout = setTimeout(this._handleDelay.bind(this, e), delayMS);
190
- }
191
- else {
192
- this._handleDelay(e);
193
- }
194
- let longDelayMS = this.props.touchableGetLongPressDelayMS
195
- ? Math.max(this.props.touchableGetLongPressDelayMS(), 10)
196
- : LONG_PRESS_DELAY_MS;
197
- longDelayMS = isNaN(longDelayMS) ? LONG_PRESS_DELAY_MS : longDelayMS;
198
- this._longPressDelayTimeout = setTimeout(this._handleLongDelay.bind(this, e), longDelayMS + delayMS);
199
- };
200
- /**
201
- * Handle responder release
202
- */
203
- this._touchableHandleResponderRelease = (e) => {
204
- this._pressInLocation = null;
205
- this._receiveSignal('RESPONDER_RELEASE', e);
206
- };
207
- /**
208
- * Handle responder terminate
209
- */
210
- this._touchableHandleResponderTerminate = (e) => {
211
- this._pressInLocation = null;
212
- this._receiveSignal('RESPONDER_TERMINATED', e);
213
- };
214
- /**
215
- * Handles move events
216
- */
217
- this._touchableHandleResponderMove = (e) => {
218
- if (!this._positionOnActivate) {
219
- return;
220
- }
221
- const positionOnActivate = this._positionOnActivate;
222
- const dimensionsOnActivate = this._dimensionsOnActivate;
223
- const pressRectOffset = this.props.touchableGetPressRectOffset
224
- ? this.props.touchableGetPressRectOffset()
225
- : {
226
- left: PRESS_EXPAND_DIPS,
227
- right: PRESS_EXPAND_DIPS,
228
- top: PRESS_EXPAND_DIPS,
229
- bottom: PRESS_EXPAND_DIPS,
230
- };
231
- let pressExpandLeft = pressRectOffset.left;
232
- let pressExpandTop = pressRectOffset.top;
233
- let pressExpandRight = pressRectOffset.right;
234
- let pressExpandBottom = pressRectOffset.bottom;
235
- // TODO implement touchableGetHitSlop natively
236
- const hitSlop = this.props.touchableGetHitSlop ? this.props.touchableGetHitSlop() : null;
237
- if (hitSlop) {
238
- pressExpandLeft += hitSlop.left || 0;
239
- pressExpandTop += hitSlop.top || 0;
240
- pressExpandRight += hitSlop.right || 0;
241
- pressExpandBottom += hitSlop.bottom || 0;
242
- }
243
- const touch = extractSingleTouch(e);
244
- const pageX = touch && touch.pageX;
245
- const pageY = touch && touch.pageY;
246
- if (this._pressInLocation) {
247
- const movedDistance = this._getDistanceBetweenPoints(pageX, pageY, this._pressInLocation.pageX, this._pressInLocation.pageY);
248
- if (movedDistance > LONG_PRESS_ALLOWED_MOVEMENT) {
249
- this._cancelLongPressDelayTimeout();
250
- }
251
- }
252
- const isTouchWithinActive = pageX > positionOnActivate.left - pressExpandLeft &&
253
- pageY > positionOnActivate.top - pressExpandTop &&
254
- pageX < positionOnActivate.left + dimensionsOnActivate.width + pressExpandRight &&
255
- pageY < positionOnActivate.top + dimensionsOnActivate.height + pressExpandBottom;
256
- if (isTouchWithinActive) {
257
- const prevState = this._touchState;
258
- this._receiveSignal('ENTER_PRESS_RECT', e);
259
- const currState = this._touchState;
260
- if (currState === 'RESPONDER_INACTIVE_PRESS_IN' && prevState !== 'RESPONDER_INACTIVE_PRESS_IN') {
261
- this._cancelLongPressDelayTimeout();
262
- }
263
- }
264
- else {
265
- this._cancelLongPressDelayTimeout();
266
- this._receiveSignal('LEAVE_PRESS_RECT', e);
267
- }
268
- };
269
- /**
270
- * Used while performing side effects during state transitions,
271
- * to maintain proper bounding dimensions and positional information
272
- */
273
- this._remeasureMetricsOnActivation = () => {
274
- const tag = this._responderID;
275
- if (tag === null) {
276
- return;
277
- }
278
- react_native_1.UIManager.measure(tag, this._handleQueryLayout);
279
- };
280
- /**
281
- * Callback into measure, see _remeasureMetricsOnActivation
282
- */
283
- this._handleQueryLayout = (l, t, w, h, globalX, globalY) => {
284
- if (!l && !t && !w && !h && !globalX && !globalY) {
285
- return;
286
- }
287
- this._positionOnActivate = Position.getPooled(globalX, globalY);
288
- this._dimensionsOnActivate = BoundingDimensions.getPooled(w, h);
289
- };
290
- this._handleDelay = (e) => {
291
- this._touchableDelayTimeout = null;
292
- this._receiveSignal('DELAY', e);
293
- };
294
- this._handleLongDelay = (e) => {
295
- this._longPressDelayTimeout = null;
296
- const currState = this._touchState;
297
- if (currState !== 'RESPONDER_ACTIVE_PRESS_IN' && currState !== 'RESPONDER_ACTIVE_LONG_PRESS_IN') {
298
- const errorMessage = 'Attempted to transition from state ' +
299
- currState +
300
- ' to ' +
301
- 'RESPONDER_ACTIVE_LONG_PRESS_IN ' +
302
- 'which is not supported. This is most likely due to ' +
303
- 'Touchable.longPressDelayTimeout not being canceled.';
304
- console.error(errorMessage);
305
- }
306
- else {
307
- this._receiveSignal('LONG_PRESS_DETECTED', e);
308
- }
309
- };
310
- /**
311
- * Manages state transitions
312
- */
313
- this._receiveSignal = (signal, e) => {
314
- const responderID = this._responderID;
315
- const currState = this._touchState;
316
- const nextState = transitions[currState] ? transitions[currState][signal] : null;
317
- if (!nextState) {
318
- const errorMessage = 'Unrecognized signal ' + signal + ' or state ' + currState + ' for Touchable responder ' + responderID + '.';
319
- throw new Error(errorMessage);
320
- }
321
- if (nextState === 'ERROR') {
322
- const errorMessage = 'Touchable cannot transition from ' + currState + ' to ' + signal + ' for responder ' + responderID + '.';
323
- throw new Error(errorMessage);
324
- }
325
- if (currState !== nextState) {
326
- this._performSideEffectsForTransition(currState, nextState, signal, e);
327
- this._touchState = nextState;
328
- }
329
- };
330
- this._cancelLongPressDelayTimeout = () => {
331
- this._longPressDelayTimeout && clearTimeout(this._longPressDelayTimeout);
332
- this._longPressDelayTimeout = null;
333
- };
334
- this._isHighlight = (state) => {
335
- return state === 'RESPONDER_ACTIVE_PRESS_IN' || state === 'RESPONDER_ACTIVE_LONG_PRESS_IN';
336
- };
337
- this._savePressInLocation = (e) => {
338
- const touch = extractSingleTouch(e);
339
- const pageX = touch && touch.pageX;
340
- const pageY = touch && touch.pageY;
341
- const locationX = touch && touch.locationX;
342
- const locationY = touch && touch.locationY;
343
- this._pressInLocation = { pageX, pageY, locationX, locationY };
344
- };
345
- this._getDistanceBetweenPoints = (aX, aY, bX, bY) => {
346
- const deltaX = aX - bX;
347
- const deltaY = aY - bY;
348
- return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
349
- };
350
- /**
351
- * Any highlighting/visual effects is done here,
352
- * This is also where press callbacks are invoked from
353
- */
354
- // Existing high cyclomatic complexity
355
- this._performSideEffectsForTransition = (currState, nextState, signal, e) => {
356
- const currIsHighlight = this._isHighlight(currState);
357
- const newIsHighlight = this._isHighlight(nextState);
358
- const isFinalSignal = signal === 'RESPONDER_TERMINATED' || signal === 'RESPONDER_RELEASE';
359
- if (isFinalSignal) {
360
- this._cancelLongPressDelayTimeout();
361
- }
362
- const isInitialTransition = currState === 'NOT_RESPONDER' && nextState === 'RESPONDER_INACTIVE_PRESS_IN';
363
- const isActiveTransition = !IsActive[currState] && IsActive[nextState];
364
- if (isInitialTransition || isActiveTransition) {
365
- this._remeasureMetricsOnActivation();
366
- }
367
- if (IsPressingIn[currState] && signal === 'LONG_PRESS_DETECTED') {
368
- this.props.touchableHandleLongPress && this.props.touchableHandleLongPress(e);
369
- }
370
- if (newIsHighlight && !currIsHighlight) {
371
- this._startHighlight(e);
372
- }
373
- else if (!newIsHighlight && currIsHighlight) {
374
- this._endHighlight(e);
375
- }
376
- if (IsPressingIn[currState] && signal === 'RESPONDER_RELEASE') {
377
- const hasLongPressHandler = !!this.props.onLongPress;
378
- const pressIsLongButStillCallOnPress = IsLongPressingIn[currState] && (!hasLongPressHandler || this._touchableLongPressCancelsPress);
379
- const shouldInvokePress = !IsLongPressingIn[currState] || pressIsLongButStillCallOnPress;
380
- if (shouldInvokePress && this.props.touchableHandlePress) {
381
- if (!newIsHighlight && !currIsHighlight) {
382
- // we never highlighted because of delay, but we should highlight now
383
- this._startHighlight(e);
384
- this._endHighlight(e);
385
- }
386
- this.props.touchableHandlePress(e);
387
- }
388
- }
389
- this._touchableDelayTimeout && clearTimeout(this._touchableDelayTimeout);
390
- this._touchableDelayTimeout = null;
391
- };
392
- this._startHighlight = (e) => {
393
- this._savePressInLocation(e);
394
- this.setState({ isPressed: true });
395
- this.props.touchableHandleActivePressIn && this.props.touchableHandleActivePressIn(e);
396
- };
397
- this._endHighlight = (e) => {
398
- function _handler() {
399
- this.props.touchableHandleActivePressOut(e);
400
- }
401
- this.setState({ isPressed: false });
402
- if (this.props.touchableHandleActivePressOut) {
403
- if (this.props.touchableGetPressOutDelayMS && this.props.touchableGetPressOutDelayMS()) {
404
- this._pressOutDelayTimeout = setTimeout(_handler.bind(this), this.props.touchableGetPressOutDelayMS());
405
- }
406
- else {
407
- this.props.touchableHandleActivePressOut(e);
408
- }
409
- }
410
- };
411
- this._onMouseEnter = (mouseEvent) => {
412
- this.setState({ isHovered: true });
413
- this.props.onMouseEnter && this.props.onMouseEnter(mouseEvent);
414
- };
415
- this._onMouseLeave = (mouseEvent) => {
416
- this.setState({ isHovered: false });
417
- this.props.onMouseLeave && this.props.onMouseLeave(mouseEvent);
418
- };
419
- this._onFocus = (ev) => {
420
- this.setState({ isFocused: true });
421
- this.props.onFocus && this.props.onFocus(ev);
422
- };
423
- this._onBlur = (ev) => {
424
- this.setState({ isFocused: false });
425
- this.props.onBlur && this.props.onBlur(ev);
426
- };
427
- this._onKeyDown = (ev) => {
428
- if (this._filterOnKey(ev)) {
429
- this.setState({ isKeyPressed: true });
430
- this.props.touchableHandleKeyPressDown && this.props.touchableHandleKeyPressDown(ev);
431
- }
432
- this.props.onKeyDown && this.props.onKeyDown(ev);
433
- };
434
- this._onKeyUp = (ev) => {
435
- if (this._filterOnKey(ev)) {
436
- this.setState({ isKeyPressed: false });
437
- this.props.touchableHandleKeyPress && this.props.touchableHandleKeyPress(ev);
438
- }
439
- this.props.onKeyUp && this.props.onKeyUp(ev);
440
- };
441
- this._deriveStateFromInternalState = () => {
442
- return {
443
- isPressed: this.state.isPressed || this.state.isKeyPressed,
444
- isHovered: this.state.isHovered,
445
- isFocused: this.state.isFocused,
446
- };
447
- };
448
- this._filterOnKey = (ev) => {
449
- if (this.props.filterKeys) {
450
- return this.props.filterKeys(ev.nativeEvent.key);
451
- }
452
- // Otherwise fall back to handling space and enter only
453
- return ev.nativeEvent.key === ' ' || ev.nativeEvent.key === 'Enter';
454
- };
455
- this.state = {
456
- isKeyPressed: false,
457
- isPressed: false,
458
- isFocused: false,
459
- isHovered: false,
460
- };
461
- this._internalRef = react_1.default.createRef();
462
- }
463
- componentWillUnmount() {
464
- this._touchableDelayTimeout && clearTimeout(this._touchableDelayTimeout);
465
- this._longPressDelayTimeout && clearTimeout(this._longPressDelayTimeout);
466
- this._pressOutDelayTimeout && clearTimeout(this._pressOutDelayTimeout);
467
- }
468
- render() {
469
- const { children, style, renderStyle, ...rest } = this.props;
470
- // The React Native touchables generally clone the child component
471
- // to apply additional styles to it. This approach allows children
472
- // to be passed in as functions (to be invoked with the current state),
473
- // it is handy for manipulating children as a result of the interaction
474
- // state (e.g. text color). A similar approach is taken for style
475
- let child;
476
- if (children) {
477
- child = typeof children === 'function' ?
478
- children(this._deriveStateFromInternalState()) : children;
479
- // Continue to enforce single child constraint
480
- child = react_1.default.Children.only(child);
481
- }
482
- let computedStyle;
483
- if (renderStyle) {
484
- computedStyle = renderStyle(this._deriveStateFromInternalState());
485
- }
486
- else if (style) {
487
- computedStyle = style;
488
- }
489
- return (react_1.default.createElement(react_native_1.ViewWin32
490
- // Forward most of the props
491
- , { ...rest,
492
- // Hooks into Gesture Responder System
493
- onStartShouldSetResponder: this._touchableHandleStartShouldSetResponder, onResponderTerminationRequest: this._touchableHandleResponderTerminationRequest, onResponderGrant: this._touchableHandleResponderGrant, onResponderMove: this._touchableHandleResponderMove, onResponderRelease: this._touchableHandleResponderRelease, onResponderTerminate: this._touchableHandleResponderTerminate,
494
- // Hover
495
- onMouseEnter: this._onMouseEnter, onMouseLeave: this._onMouseLeave,
496
- // Focus
497
- onFocus: this._onFocus, onBlur: this._onBlur,
498
- // Key press interactions
499
- onKeyDown: this._onKeyDown, onKeyUp: this._onKeyUp,
500
- // Ref
501
- ref: this._internalRef,
502
- // Style
503
- style: computedStyle }, child));
504
- }
505
- }
506
- exports.TouchableWin32 = TouchableWin32;
1
+ /**
2
+ * This is primarily a fork of React Native's Touchable Mixin.
3
+ * It has been repurposed as it's own standalone control for win32,
4
+ * as it needs to support a richer set of functionality on the desktop.
5
+ * The touchable variants can be rewritten as wrappers around TouchableWin32
6
+ * by passing the correct set of props down and managing state correctly.
7
+ *
8
+ * React Native's Touchable.js file (https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/Touchable.js)
9
+ * provides an overview over how touchables work and interact with the gesture responder system.
10
+ */
11
+ 'use strict';
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TouchableWin32 = void 0;
17
+ const react_1 = __importDefault(require("react"));
18
+ const react_native_1 = require("react-native");
19
+ const BoundingDimensions = require('./BoundingDimensions');
20
+ const Position = require('./Position');
21
+ const { findNodeHandle } = require('../../Renderer/shims/ReactNative');
22
+ /**
23
+ * Extracts a single touch, generally this is the active touch or touch that
24
+ * has just ended
25
+ * @param e - a press event containing information about the native event
26
+ */
27
+ function extractSingleTouch(e) {
28
+ const nativeEvent = e.nativeEvent;
29
+ const touches = nativeEvent.touches;
30
+ const changedTouches = nativeEvent.changedTouches;
31
+ const hasTouches = touches && touches.length > 0;
32
+ const hasChangedTouches = changedTouches && changedTouches.length > 0;
33
+ return !hasTouches && hasChangedTouches ? changedTouches[0] : hasTouches ? touches[0] : nativeEvent;
34
+ }
35
+ /** Quick lookup maps for a variety of conditions */
36
+ const baseStatesCondition = {
37
+ NOT_RESPONDER: false,
38
+ RESPONDER_INACTIVE_PRESS_IN: false,
39
+ RESPONDER_INACTIVE_PRESS_OUT: false,
40
+ RESPONDER_ACTIVE_PRESS_IN: false,
41
+ RESPONDER_ACTIVE_PRESS_OUT: false,
42
+ RESPONDER_ACTIVE_LONG_PRESS_IN: false,
43
+ RESPONDER_ACTIVE_LONG_PRESS_OUT: false,
44
+ ERROR: false,
45
+ };
46
+ const IsActive = {
47
+ ...baseStatesCondition,
48
+ RESPONDER_ACTIVE_PRESS_OUT: true,
49
+ RESPONDER_ACTIVE_PRESS_IN: true,
50
+ };
51
+ const IsPressingIn = {
52
+ ...baseStatesCondition,
53
+ RESPONDER_INACTIVE_PRESS_IN: true,
54
+ RESPONDER_ACTIVE_PRESS_IN: true,
55
+ RESPONDER_ACTIVE_LONG_PRESS_IN: true,
56
+ };
57
+ const IsLongPressingIn = {
58
+ ...baseStatesCondition,
59
+ RESPONDER_ACTIVE_LONG_PRESS_IN: true,
60
+ };
61
+ const transitions = {
62
+ NOT_RESPONDER: {
63
+ DELAY: 'ERROR',
64
+ RESPONDER_GRANT: 'RESPONDER_INACTIVE_PRESS_IN',
65
+ RESPONDER_RELEASE: 'ERROR',
66
+ RESPONDER_TERMINATED: 'ERROR',
67
+ ENTER_PRESS_RECT: 'ERROR',
68
+ LEAVE_PRESS_RECT: 'ERROR',
69
+ LONG_PRESS_DETECTED: 'ERROR',
70
+ },
71
+ RESPONDER_INACTIVE_PRESS_IN: {
72
+ DELAY: 'RESPONDER_ACTIVE_PRESS_IN',
73
+ RESPONDER_GRANT: 'ERROR',
74
+ RESPONDER_RELEASE: 'NOT_RESPONDER',
75
+ RESPONDER_TERMINATED: 'NOT_RESPONDER',
76
+ ENTER_PRESS_RECT: 'RESPONDER_INACTIVE_PRESS_IN',
77
+ LEAVE_PRESS_RECT: 'RESPONDER_INACTIVE_PRESS_OUT',
78
+ LONG_PRESS_DETECTED: 'ERROR',
79
+ },
80
+ RESPONDER_INACTIVE_PRESS_OUT: {
81
+ DELAY: 'RESPONDER_ACTIVE_PRESS_OUT',
82
+ RESPONDER_GRANT: 'ERROR',
83
+ RESPONDER_RELEASE: 'NOT_RESPONDER',
84
+ RESPONDER_TERMINATED: 'NOT_RESPONDER',
85
+ ENTER_PRESS_RECT: 'RESPONDER_INACTIVE_PRESS_IN',
86
+ LEAVE_PRESS_RECT: 'RESPONDER_INACTIVE_PRESS_OUT',
87
+ LONG_PRESS_DETECTED: 'ERROR',
88
+ },
89
+ RESPONDER_ACTIVE_PRESS_IN: {
90
+ DELAY: 'ERROR',
91
+ RESPONDER_GRANT: 'ERROR',
92
+ RESPONDER_RELEASE: 'NOT_RESPONDER',
93
+ RESPONDER_TERMINATED: 'NOT_RESPONDER',
94
+ ENTER_PRESS_RECT: 'RESPONDER_ACTIVE_PRESS_IN',
95
+ LEAVE_PRESS_RECT: 'RESPONDER_ACTIVE_PRESS_OUT',
96
+ LONG_PRESS_DETECTED: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
97
+ },
98
+ RESPONDER_ACTIVE_PRESS_OUT: {
99
+ DELAY: 'ERROR',
100
+ RESPONDER_GRANT: 'ERROR',
101
+ RESPONDER_RELEASE: 'NOT_RESPONDER',
102
+ RESPONDER_TERMINATED: 'NOT_RESPONDER',
103
+ ENTER_PRESS_RECT: 'RESPONDER_ACTIVE_PRESS_IN',
104
+ LEAVE_PRESS_RECT: 'RESPONDER_ACTIVE_PRESS_OUT',
105
+ LONG_PRESS_DETECTED: 'ERROR',
106
+ },
107
+ RESPONDER_ACTIVE_LONG_PRESS_IN: {
108
+ DELAY: 'ERROR',
109
+ RESPONDER_GRANT: 'ERROR',
110
+ RESPONDER_RELEASE: 'NOT_RESPONDER',
111
+ RESPONDER_TERMINATED: 'NOT_RESPONDER',
112
+ ENTER_PRESS_RECT: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
113
+ LEAVE_PRESS_RECT: 'RESPONDER_ACTIVE_LONG_PRESS_OUT',
114
+ LONG_PRESS_DETECTED: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
115
+ },
116
+ RESPONDER_ACTIVE_LONG_PRESS_OUT: {
117
+ DELAY: 'ERROR',
118
+ RESPONDER_GRANT: 'ERROR',
119
+ RESPONDER_RELEASE: 'NOT_RESPONDER',
120
+ RESPONDER_TERMINATED: 'NOT_RESPONDER',
121
+ ENTER_PRESS_RECT: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
122
+ LEAVE_PRESS_RECT: 'RESPONDER_ACTIVE_LONG_PRESS_OUT',
123
+ LONG_PRESS_DETECTED: 'ERROR',
124
+ },
125
+ ERROR: {
126
+ DELAY: 'NOT_RESPONDER',
127
+ RESPONDER_GRANT: 'RESPONDER_INACTIVE_PRESS_IN',
128
+ RESPONDER_RELEASE: 'NOT_RESPONDER',
129
+ RESPONDER_TERMINATED: 'NOT_RESPONDER',
130
+ ENTER_PRESS_RECT: 'NOT_RESPONDER',
131
+ LEAVE_PRESS_RECT: 'NOT_RESPONDER',
132
+ LONG_PRESS_DETECTED: 'NOT_RESPONDER',
133
+ },
134
+ };
135
+ /** Constants for integrating into UI Components */
136
+ const HIGHLIGHT_DELAY_MS = 130;
137
+ const PRESS_EXPAND_DIPS = 20; // Subject to change for win32 and desktop
138
+ const LONG_PRESS_THRESHOLD = 500;
139
+ const LONG_PRESS_DELAY_MS = LONG_PRESS_THRESHOLD - HIGHLIGHT_DELAY_MS;
140
+ const LONG_PRESS_ALLOWED_MOVEMENT = 10;
141
+ /**
142
+ * TouchableWin32 is a 'componentization' of the Touchable Mixin in React Native.
143
+ * This means that instead of implementing components such as TouchableHighlight
144
+ * via the mixin, they are merely implemented as wrappers around TouchableWin32,
145
+ * forwarding the correct set of props. Additionally, TouchableWin32 supports hover
146
+ * via onMouseEnter and onMouseLeave and focus/blur via onFocus/onBlur.
147
+ * TouchableWin32 also allows for functions as child components (that use the internal
148
+ * state of the touchable to conditionally render children) as well functions as styles
149
+ * (that use internal state to conditionally calculate styles)
150
+ */
151
+ class TouchableWin32 extends react_1.default.Component {
152
+ constructor(props) {
153
+ super(props);
154
+ this.focus = () => {
155
+ this._internalRef.current.focus();
156
+ };
157
+ /**
158
+ * The rejectResponderTermination prop provides a way to accept/reject termination requests
159
+ */
160
+ this._touchableHandleResponderTerminationRequest = () => {
161
+ return !this.props.rejectResponderTermination;
162
+ };
163
+ /**
164
+ * Only reject an opportunity to become the responder on bubble if disabled
165
+ */
166
+ this._touchableHandleStartShouldSetResponder = () => {
167
+ return !this.props.disabled;
168
+ };
169
+ /** TODO: Long press cancel as a prop may be a good idea */
170
+ this._touchableLongPressCancelsPress = () => {
171
+ return true;
172
+ };
173
+ /**
174
+ * On responder being granted, state and local data need to be set
175
+ */
176
+ this._touchableHandleResponderGrant = (e) => {
177
+ const dispatchID = findNodeHandle(e.currentTarget);
178
+ e.persist();
179
+ this._pressOutDelayTimeout && clearTimeout(this._pressOutDelayTimeout);
180
+ this._pressOutDelayTimeout = null;
181
+ this._touchState = 'NOT_RESPONDER';
182
+ this._responderID = dispatchID;
183
+ this._receiveSignal('RESPONDER_GRANT', e);
184
+ let delayMS = this.props.touchableGetHighlightDelayMS
185
+ ? Math.max(this.props.touchableGetHighlightDelayMS(), 0)
186
+ : HIGHLIGHT_DELAY_MS;
187
+ delayMS = isNaN(delayMS) ? HIGHLIGHT_DELAY_MS : delayMS;
188
+ if (delayMS !== 0) {
189
+ this._touchableDelayTimeout = setTimeout(this._handleDelay.bind(this, e), delayMS);
190
+ }
191
+ else {
192
+ this._handleDelay(e);
193
+ }
194
+ let longDelayMS = this.props.touchableGetLongPressDelayMS
195
+ ? Math.max(this.props.touchableGetLongPressDelayMS(), 10)
196
+ : LONG_PRESS_DELAY_MS;
197
+ longDelayMS = isNaN(longDelayMS) ? LONG_PRESS_DELAY_MS : longDelayMS;
198
+ this._longPressDelayTimeout = setTimeout(this._handleLongDelay.bind(this, e), longDelayMS + delayMS);
199
+ };
200
+ /**
201
+ * Handle responder release
202
+ */
203
+ this._touchableHandleResponderRelease = (e) => {
204
+ this._pressInLocation = null;
205
+ this._receiveSignal('RESPONDER_RELEASE', e);
206
+ };
207
+ /**
208
+ * Handle responder terminate
209
+ */
210
+ this._touchableHandleResponderTerminate = (e) => {
211
+ this._pressInLocation = null;
212
+ this._receiveSignal('RESPONDER_TERMINATED', e);
213
+ };
214
+ /**
215
+ * Handles move events
216
+ */
217
+ this._touchableHandleResponderMove = (e) => {
218
+ if (!this._positionOnActivate) {
219
+ return;
220
+ }
221
+ const positionOnActivate = this._positionOnActivate;
222
+ const dimensionsOnActivate = this._dimensionsOnActivate;
223
+ const pressRectOffset = this.props.touchableGetPressRectOffset
224
+ ? this.props.touchableGetPressRectOffset()
225
+ : {
226
+ left: PRESS_EXPAND_DIPS,
227
+ right: PRESS_EXPAND_DIPS,
228
+ top: PRESS_EXPAND_DIPS,
229
+ bottom: PRESS_EXPAND_DIPS,
230
+ };
231
+ let pressExpandLeft = pressRectOffset.left;
232
+ let pressExpandTop = pressRectOffset.top;
233
+ let pressExpandRight = pressRectOffset.right;
234
+ let pressExpandBottom = pressRectOffset.bottom;
235
+ // TODO implement touchableGetHitSlop natively
236
+ const hitSlop = this.props.touchableGetHitSlop ? this.props.touchableGetHitSlop() : null;
237
+ if (hitSlop) {
238
+ pressExpandLeft += hitSlop.left || 0;
239
+ pressExpandTop += hitSlop.top || 0;
240
+ pressExpandRight += hitSlop.right || 0;
241
+ pressExpandBottom += hitSlop.bottom || 0;
242
+ }
243
+ const touch = extractSingleTouch(e);
244
+ const pageX = touch && touch.pageX;
245
+ const pageY = touch && touch.pageY;
246
+ if (this._pressInLocation) {
247
+ const movedDistance = this._getDistanceBetweenPoints(pageX, pageY, this._pressInLocation.pageX, this._pressInLocation.pageY);
248
+ if (movedDistance > LONG_PRESS_ALLOWED_MOVEMENT) {
249
+ this._cancelLongPressDelayTimeout();
250
+ }
251
+ }
252
+ const isTouchWithinActive = pageX > positionOnActivate.left - pressExpandLeft &&
253
+ pageY > positionOnActivate.top - pressExpandTop &&
254
+ pageX < positionOnActivate.left + dimensionsOnActivate.width + pressExpandRight &&
255
+ pageY < positionOnActivate.top + dimensionsOnActivate.height + pressExpandBottom;
256
+ if (isTouchWithinActive) {
257
+ const prevState = this._touchState;
258
+ this._receiveSignal('ENTER_PRESS_RECT', e);
259
+ const currState = this._touchState;
260
+ if (currState === 'RESPONDER_INACTIVE_PRESS_IN' && prevState !== 'RESPONDER_INACTIVE_PRESS_IN') {
261
+ this._cancelLongPressDelayTimeout();
262
+ }
263
+ }
264
+ else {
265
+ this._cancelLongPressDelayTimeout();
266
+ this._receiveSignal('LEAVE_PRESS_RECT', e);
267
+ }
268
+ };
269
+ /**
270
+ * Used while performing side effects during state transitions,
271
+ * to maintain proper bounding dimensions and positional information
272
+ */
273
+ this._remeasureMetricsOnActivation = () => {
274
+ const tag = this._responderID;
275
+ if (tag === null) {
276
+ return;
277
+ }
278
+ react_native_1.UIManager.measure(tag, this._handleQueryLayout);
279
+ };
280
+ /**
281
+ * Callback into measure, see _remeasureMetricsOnActivation
282
+ */
283
+ this._handleQueryLayout = (l, t, w, h, globalX, globalY) => {
284
+ if (!l && !t && !w && !h && !globalX && !globalY) {
285
+ return;
286
+ }
287
+ this._positionOnActivate = Position.getPooled(globalX, globalY);
288
+ this._dimensionsOnActivate = BoundingDimensions.getPooled(w, h);
289
+ };
290
+ this._handleDelay = (e) => {
291
+ this._touchableDelayTimeout = null;
292
+ this._receiveSignal('DELAY', e);
293
+ };
294
+ this._handleLongDelay = (e) => {
295
+ this._longPressDelayTimeout = null;
296
+ const currState = this._touchState;
297
+ if (currState !== 'RESPONDER_ACTIVE_PRESS_IN' && currState !== 'RESPONDER_ACTIVE_LONG_PRESS_IN') {
298
+ const errorMessage = 'Attempted to transition from state ' +
299
+ currState +
300
+ ' to ' +
301
+ 'RESPONDER_ACTIVE_LONG_PRESS_IN ' +
302
+ 'which is not supported. This is most likely due to ' +
303
+ 'Touchable.longPressDelayTimeout not being canceled.';
304
+ console.error(errorMessage);
305
+ }
306
+ else {
307
+ this._receiveSignal('LONG_PRESS_DETECTED', e);
308
+ }
309
+ };
310
+ /**
311
+ * Manages state transitions
312
+ */
313
+ this._receiveSignal = (signal, e) => {
314
+ const responderID = this._responderID;
315
+ const currState = this._touchState;
316
+ const nextState = transitions[currState] ? transitions[currState][signal] : null;
317
+ if (!nextState) {
318
+ const errorMessage = 'Unrecognized signal ' + signal + ' or state ' + currState + ' for Touchable responder ' + responderID + '.';
319
+ throw new Error(errorMessage);
320
+ }
321
+ if (nextState === 'ERROR') {
322
+ const errorMessage = 'Touchable cannot transition from ' + currState + ' to ' + signal + ' for responder ' + responderID + '.';
323
+ throw new Error(errorMessage);
324
+ }
325
+ if (currState !== nextState) {
326
+ this._performSideEffectsForTransition(currState, nextState, signal, e);
327
+ this._touchState = nextState;
328
+ }
329
+ };
330
+ this._cancelLongPressDelayTimeout = () => {
331
+ this._longPressDelayTimeout && clearTimeout(this._longPressDelayTimeout);
332
+ this._longPressDelayTimeout = null;
333
+ };
334
+ this._isHighlight = (state) => {
335
+ return state === 'RESPONDER_ACTIVE_PRESS_IN' || state === 'RESPONDER_ACTIVE_LONG_PRESS_IN';
336
+ };
337
+ this._savePressInLocation = (e) => {
338
+ const touch = extractSingleTouch(e);
339
+ const pageX = touch && touch.pageX;
340
+ const pageY = touch && touch.pageY;
341
+ const locationX = touch && touch.locationX;
342
+ const locationY = touch && touch.locationY;
343
+ this._pressInLocation = { pageX, pageY, locationX, locationY };
344
+ };
345
+ this._getDistanceBetweenPoints = (aX, aY, bX, bY) => {
346
+ const deltaX = aX - bX;
347
+ const deltaY = aY - bY;
348
+ return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
349
+ };
350
+ /**
351
+ * Any highlighting/visual effects is done here,
352
+ * This is also where press callbacks are invoked from
353
+ */
354
+ // Existing high cyclomatic complexity
355
+ this._performSideEffectsForTransition = (currState, nextState, signal, e) => {
356
+ const currIsHighlight = this._isHighlight(currState);
357
+ const newIsHighlight = this._isHighlight(nextState);
358
+ const isFinalSignal = signal === 'RESPONDER_TERMINATED' || signal === 'RESPONDER_RELEASE';
359
+ if (isFinalSignal) {
360
+ this._cancelLongPressDelayTimeout();
361
+ }
362
+ const isInitialTransition = currState === 'NOT_RESPONDER' && nextState === 'RESPONDER_INACTIVE_PRESS_IN';
363
+ const isActiveTransition = !IsActive[currState] && IsActive[nextState];
364
+ if (isInitialTransition || isActiveTransition) {
365
+ this._remeasureMetricsOnActivation();
366
+ }
367
+ if (IsPressingIn[currState] && signal === 'LONG_PRESS_DETECTED') {
368
+ this.props.touchableHandleLongPress && this.props.touchableHandleLongPress(e);
369
+ }
370
+ if (newIsHighlight && !currIsHighlight) {
371
+ this._startHighlight(e);
372
+ }
373
+ else if (!newIsHighlight && currIsHighlight) {
374
+ this._endHighlight(e);
375
+ }
376
+ if (IsPressingIn[currState] && signal === 'RESPONDER_RELEASE') {
377
+ const hasLongPressHandler = !!this.props.onLongPress;
378
+ const pressIsLongButStillCallOnPress = IsLongPressingIn[currState] && (!hasLongPressHandler || this._touchableLongPressCancelsPress);
379
+ const shouldInvokePress = !IsLongPressingIn[currState] || pressIsLongButStillCallOnPress;
380
+ if (shouldInvokePress && this.props.touchableHandlePress) {
381
+ if (!newIsHighlight && !currIsHighlight) {
382
+ // we never highlighted because of delay, but we should highlight now
383
+ this._startHighlight(e);
384
+ this._endHighlight(e);
385
+ }
386
+ this.props.touchableHandlePress(e);
387
+ }
388
+ }
389
+ this._touchableDelayTimeout && clearTimeout(this._touchableDelayTimeout);
390
+ this._touchableDelayTimeout = null;
391
+ };
392
+ this._startHighlight = (e) => {
393
+ this._savePressInLocation(e);
394
+ this.setState({ isPressed: true });
395
+ this.props.touchableHandleActivePressIn && this.props.touchableHandleActivePressIn(e);
396
+ };
397
+ this._endHighlight = (e) => {
398
+ function _handler() {
399
+ this.props.touchableHandleActivePressOut(e);
400
+ }
401
+ this.setState({ isPressed: false });
402
+ if (this.props.touchableHandleActivePressOut) {
403
+ if (this.props.touchableGetPressOutDelayMS && this.props.touchableGetPressOutDelayMS()) {
404
+ this._pressOutDelayTimeout = setTimeout(_handler.bind(this), this.props.touchableGetPressOutDelayMS());
405
+ }
406
+ else {
407
+ this.props.touchableHandleActivePressOut(e);
408
+ }
409
+ }
410
+ };
411
+ this._onMouseEnter = (mouseEvent) => {
412
+ this.setState({ isHovered: true });
413
+ this.props.onMouseEnter && this.props.onMouseEnter(mouseEvent);
414
+ };
415
+ this._onMouseLeave = (mouseEvent) => {
416
+ this.setState({ isHovered: false });
417
+ this.props.onMouseLeave && this.props.onMouseLeave(mouseEvent);
418
+ };
419
+ this._onFocus = (ev) => {
420
+ this.setState({ isFocused: true });
421
+ this.props.onFocus && this.props.onFocus(ev);
422
+ };
423
+ this._onBlur = (ev) => {
424
+ this.setState({ isFocused: false });
425
+ this.props.onBlur && this.props.onBlur(ev);
426
+ };
427
+ this._onKeyDown = (ev) => {
428
+ if (this._filterOnKey(ev)) {
429
+ this.setState({ isKeyPressed: true });
430
+ this.props.touchableHandleKeyPressDown && this.props.touchableHandleKeyPressDown(ev);
431
+ }
432
+ this.props.onKeyDown && this.props.onKeyDown(ev);
433
+ };
434
+ this._onKeyUp = (ev) => {
435
+ if (this._filterOnKey(ev)) {
436
+ this.setState({ isKeyPressed: false });
437
+ this.props.touchableHandleKeyPress && this.props.touchableHandleKeyPress(ev);
438
+ }
439
+ this.props.onKeyUp && this.props.onKeyUp(ev);
440
+ };
441
+ this._deriveStateFromInternalState = () => {
442
+ return {
443
+ isPressed: this.state.isPressed || this.state.isKeyPressed,
444
+ isHovered: this.state.isHovered,
445
+ isFocused: this.state.isFocused,
446
+ };
447
+ };
448
+ this._filterOnKey = (ev) => {
449
+ if (this.props.filterKeys) {
450
+ return this.props.filterKeys(ev.nativeEvent.key);
451
+ }
452
+ // Otherwise fall back to handling space and enter only
453
+ return ev.nativeEvent.key === ' ' || ev.nativeEvent.key === 'Enter';
454
+ };
455
+ this.state = {
456
+ isKeyPressed: false,
457
+ isPressed: false,
458
+ isFocused: false,
459
+ isHovered: false,
460
+ };
461
+ this._internalRef = react_1.default.createRef();
462
+ }
463
+ componentWillUnmount() {
464
+ this._touchableDelayTimeout && clearTimeout(this._touchableDelayTimeout);
465
+ this._longPressDelayTimeout && clearTimeout(this._longPressDelayTimeout);
466
+ this._pressOutDelayTimeout && clearTimeout(this._pressOutDelayTimeout);
467
+ }
468
+ render() {
469
+ const { children, style, renderStyle, ...rest } = this.props;
470
+ // The React Native touchables generally clone the child component
471
+ // to apply additional styles to it. This approach allows children
472
+ // to be passed in as functions (to be invoked with the current state),
473
+ // it is handy for manipulating children as a result of the interaction
474
+ // state (e.g. text color). A similar approach is taken for style
475
+ let child;
476
+ if (children) {
477
+ child = typeof children === 'function' ?
478
+ children(this._deriveStateFromInternalState()) : children;
479
+ // Continue to enforce single child constraint
480
+ child = react_1.default.Children.only(child);
481
+ }
482
+ let computedStyle;
483
+ if (renderStyle) {
484
+ computedStyle = renderStyle(this._deriveStateFromInternalState());
485
+ }
486
+ else if (style) {
487
+ computedStyle = style;
488
+ }
489
+ return (react_1.default.createElement(react_native_1.ViewWin32
490
+ // Forward most of the props
491
+ , { ...rest,
492
+ // Hooks into Gesture Responder System
493
+ onStartShouldSetResponder: this._touchableHandleStartShouldSetResponder, onResponderTerminationRequest: this._touchableHandleResponderTerminationRequest, onResponderGrant: this._touchableHandleResponderGrant, onResponderMove: this._touchableHandleResponderMove, onResponderRelease: this._touchableHandleResponderRelease, onResponderTerminate: this._touchableHandleResponderTerminate,
494
+ // Hover
495
+ onMouseEnter: this._onMouseEnter, onMouseLeave: this._onMouseLeave,
496
+ // Focus
497
+ onFocus: this._onFocus, onBlur: this._onBlur,
498
+ // Key press interactions
499
+ onKeyDown: this._onKeyDown, onKeyUp: this._onKeyUp,
500
+ // Ref
501
+ ref: this._internalRef,
502
+ // Style
503
+ style: computedStyle }, child));
504
+ }
505
+ }
506
+ exports.TouchableWin32 = TouchableWin32;
507
507
  //# sourceMappingURL=TouchableWin32.js.map