react-native-external-keyboard 0.9.1 → 0.11.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 (369) hide show
  1. package/README.md +95 -600
  2. package/android/build.gradle +0 -18
  3. package/android/src/main/java/com/externalkeyboard/events/EventHelper.java +10 -13
  4. package/android/src/main/java/com/externalkeyboard/helper/FocusHelper.java +1 -2
  5. package/android/src/main/java/com/externalkeyboard/services/FocusMemoryService.java +64 -0
  6. package/android/src/main/java/com/externalkeyboard/services/KeyboardFocusService.java +41 -0
  7. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardView/ExternalKeyboardView.java +2 -8
  8. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardView/ExternalKeyboardViewManager.java +20 -13
  9. package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapper.java +99 -21
  10. package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapperManager.java +11 -0
  11. package/android/src/main/java/com/externalkeyboard/views/base/FocusHighlightBase.java +11 -5
  12. package/android/src/main/java/com/externalkeyboard/views/base/FocusableBase.java +54 -0
  13. package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewFocusChangeBase.java +2 -3
  14. package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewFocusRequestBase.java +10 -61
  15. package/android/src/newarch/ExternalKeyboardLockViewManagerInterface.java +11 -0
  16. package/android/src/newarch/ExternalKeyboardLockViewManagerSpec.java +0 -1
  17. package/android/src/newarch/ExternalKeyboardViewManagerInterface.java +42 -0
  18. package/android/src/newarch/ExternalKeyboardViewManagerSpec.java +0 -1
  19. package/android/src/newarch/KeyboardFocusGroupManagerInterface.java +12 -0
  20. package/android/src/newarch/KeyboardFocusGroupManagerSpec.java +0 -1
  21. package/android/src/newarch/TextInputFocusWrapperManagerInterface.java +34 -0
  22. package/android/src/newarch/TextInputFocusWrapperManagerSpec.java +0 -7
  23. package/android/src/newarch/helper/ReactNativeEventDispatcher.java +28 -0
  24. package/android/src/oldarch/ExternalKeyboardViewManagerSpec.java +6 -4
  25. package/android/src/oldarch/TextInputFocusWrapperManagerSpec.java +4 -0
  26. package/android/src/oldarch/helper/ReactNativeEventDispatcher.java +15 -0
  27. package/ios/Delegates/RNCEKVFocusDelegate/RNCEKVFocusDelegate.mm +1 -1
  28. package/ios/Delegates/RNCEKVFocusDelegate/RNCEKVFocusProtocol.h +1 -1
  29. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloDelegate.h +2 -1
  30. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloDelegate.mm +41 -5
  31. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloProtocol.h +1 -0
  32. package/ios/Extensions/RCTCustomScrollView+RNCEKVExternalKeyboard.mm +5 -6
  33. package/ios/Extensions/RCTEnhancedScrollView+RNCEKVExternalKeyboard.mm +8 -9
  34. package/ios/Extensions/RCTTextInputComponentView+RNCEKVExternalKeyboard.mm +1 -1
  35. package/ios/Extensions/RCTViewComponentView+RNCEKVExternalKeyboard.h +0 -1
  36. package/ios/Extensions/RCTViewComponentView+RNCEKVExternalKeyboard.mm +16 -4
  37. package/ios/Extensions/UIViewController+RNCEKVExternalKeyboard.mm +7 -10
  38. package/ios/Helpers/RNCEKVNativeProps/RNCEKVNativeProps.h +4 -4
  39. package/ios/Helpers/RNCEKVSwizzleInstanceMethod/RNCEKVSwizzleInstanceMethod.h +19 -0
  40. package/ios/Protocols/RNCEKVCustomFocusEffectProtocol.h +1 -1
  41. package/ios/Services/RNCEKVFocusMemoryService.h +39 -0
  42. package/ios/Services/RNCEKVFocusMemoryService.mm +42 -0
  43. package/ios/Services/RNCEKVKeyboardFocusService.h +28 -0
  44. package/ios/Services/RNCEKVKeyboardFocusService.mm +54 -0
  45. package/ios/Views/Base/FocusChange/RNCEKVViewFocusChangeBase.h +2 -0
  46. package/ios/Views/Base/FocusChange/RNCEKVViewFocusChangeBase.mm +12 -10
  47. package/ios/Views/Base/FocusRequest/RNCEKVViewFocusRequestBase.h +1 -1
  48. package/ios/Views/Base/FocusRequest/RNCEKVViewFocusRequestBase.mm +6 -17
  49. package/ios/Views/Base/KeyboardHallo/RNCEKVExternalKeyboardHalloBase.h +1 -0
  50. package/ios/Views/Base/KeyboardHallo/RNCEKVExternalKeyboardHalloBase.mm +146 -6
  51. package/ios/Views/Base/ViewGroup/RNCEKVViewGroupBase.h +2 -0
  52. package/ios/Views/Base/ViewGroup/RNCEKVViewGroupBase.mm +4 -0
  53. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardView.h +1 -1
  54. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardView.mm +8 -4
  55. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardViewManager.mm +22 -11
  56. package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapper.mm +17 -0
  57. package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapperManager.mm +12 -0
  58. package/lib/commonjs/components/BaseKeyboardView/BaseKeyboardView.js +67 -65
  59. package/lib/commonjs/components/BaseKeyboardView/BaseKeyboardView.js.map +1 -1
  60. package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.js +49 -97
  61. package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.js.map +1 -1
  62. package/lib/commonjs/components/KeyboardFocusGroup/KeyboardFocusGroup.android.js.map +1 -1
  63. package/lib/commonjs/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.js.map +1 -1
  64. package/lib/commonjs/components/KeyboardFocusGroup/KeyboardFocusGroup.js.map +1 -1
  65. package/lib/commonjs/components/{KeyboardExtendedInput/KeyboardExtendedInput.types.js → KeyboardFocusGroup/KeyboardFocusGroup.types.js} +1 -1
  66. package/lib/commonjs/components/KeyboardFocusGroup/KeyboardFocusGroup.types.js.map +1 -0
  67. package/lib/commonjs/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.js +2 -1
  68. package/lib/commonjs/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.js.map +1 -1
  69. package/lib/commonjs/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.js +2 -1
  70. package/lib/commonjs/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.js.map +1 -1
  71. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js +2 -1
  72. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js.map +1 -1
  73. package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js +14 -51
  74. package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
  75. package/lib/commonjs/components/index.js +47 -0
  76. package/lib/commonjs/components/index.js.map +1 -1
  77. package/lib/commonjs/index.js +37 -19
  78. package/lib/commonjs/index.js.map +1 -1
  79. package/lib/commonjs/nativeSpec/ExternalKeyboardViewNativeComponent.ts +6 -4
  80. package/lib/commonjs/nativeSpec/TextInputFocusWrapperNativeComponent.ts +2 -0
  81. package/lib/commonjs/types/KeyboardFocusLock.types.js +13 -0
  82. package/lib/commonjs/types/KeyboardFocusLock.types.js.map +1 -1
  83. package/lib/commonjs/types/baseKeyboardView.types.js +6 -0
  84. package/lib/commonjs/types/baseKeyboardView.types.js.map +1 -0
  85. package/lib/commonjs/types/{FocusStyle.js → focus.types.js} +1 -1
  86. package/lib/commonjs/types/{FocusStyle.js.map → focus.types.js.map} +1 -1
  87. package/lib/commonjs/types/focusOrder.types.js +33 -0
  88. package/lib/commonjs/types/focusOrder.types.js.map +1 -0
  89. package/lib/commonjs/types/{WithKeyboardFocus.js → focusStyle.types.js} +1 -1
  90. package/lib/commonjs/types/{WithKeyboardFocus.js.map → focusStyle.types.js.map} +1 -1
  91. package/lib/commonjs/types/index.js +18 -0
  92. package/lib/commonjs/types/index.js.map +1 -1
  93. package/lib/commonjs/types/keyPress.types.js +6 -0
  94. package/lib/{module/types/WithKeyboardFocus.js.map → commonjs/types/keyPress.types.js.map} +1 -1
  95. package/lib/commonjs/types/keyboardInput.types.js +6 -0
  96. package/lib/commonjs/types/keyboardInput.types.js.map +1 -0
  97. package/lib/commonjs/types/withKeyboardFocus.types.js +6 -0
  98. package/lib/commonjs/types/withKeyboardFocus.types.js.map +1 -0
  99. package/lib/commonjs/utils/mapLockFocus.js +37 -0
  100. package/lib/commonjs/utils/mapLockFocus.js.map +1 -0
  101. package/lib/commonjs/utils/useFocusStyle.js +4 -21
  102. package/lib/commonjs/utils/useFocusStyle.js.map +1 -1
  103. package/lib/commonjs/utils/useKeyboardFocusContainer.js +79 -0
  104. package/lib/commonjs/utils/useKeyboardFocusContainer.js.map +1 -0
  105. package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.android.js +4 -7
  106. package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.android.js.map +1 -1
  107. package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.ios.js +3 -6
  108. package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.ios.js.map +1 -1
  109. package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.js +9 -7
  110. package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.js.map +1 -1
  111. package/lib/commonjs/utils/useKeyboardPressState.js +65 -0
  112. package/lib/commonjs/utils/useKeyboardPressState.js.map +1 -0
  113. package/lib/commonjs/utils/useOnFocusChange.js +1 -1
  114. package/lib/commonjs/utils/useOnFocusChange.js.map +1 -1
  115. package/lib/commonjs/utils/useOrderValidation.js +35 -0
  116. package/lib/commonjs/utils/useOrderValidation.js.map +1 -0
  117. package/lib/commonjs/utils/useRenderedChildren.js +34 -0
  118. package/lib/commonjs/utils/useRenderedChildren.js.map +1 -0
  119. package/lib/commonjs/utils/useWrappedOrderProps.js +35 -0
  120. package/lib/commonjs/utils/useWrappedOrderProps.js.map +1 -0
  121. package/lib/commonjs/utils/withKeyboardFocus.js +81 -96
  122. package/lib/commonjs/utils/withKeyboardFocus.js.map +1 -1
  123. package/lib/module/components/BaseKeyboardView/BaseKeyboardView.js +57 -55
  124. package/lib/module/components/BaseKeyboardView/BaseKeyboardView.js.map +1 -1
  125. package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.js +51 -99
  126. package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.js.map +1 -1
  127. package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.android.js.map +1 -1
  128. package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.js.map +1 -1
  129. package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.js.map +1 -1
  130. package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.types.js +4 -0
  131. package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.types.js.map +1 -0
  132. package/lib/module/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.js +2 -1
  133. package/lib/module/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.js.map +1 -1
  134. package/lib/module/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.js +2 -1
  135. package/lib/module/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.js.map +1 -1
  136. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js +2 -1
  137. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js.map +1 -1
  138. package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js +16 -53
  139. package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
  140. package/lib/module/components/index.js +5 -0
  141. package/lib/module/components/index.js.map +1 -1
  142. package/lib/module/index.js +20 -7
  143. package/lib/module/index.js.map +1 -1
  144. package/lib/module/nativeSpec/ExternalKeyboardViewNativeComponent.ts +6 -4
  145. package/lib/module/nativeSpec/TextInputFocusWrapperNativeComponent.ts +2 -0
  146. package/lib/module/types/KeyboardFocusLock.types.js +12 -1
  147. package/lib/module/types/KeyboardFocusLock.types.js.map +1 -1
  148. package/lib/module/types/baseKeyboardView.types.js +4 -0
  149. package/lib/module/types/baseKeyboardView.types.js.map +1 -0
  150. package/lib/module/types/focus.types.js +4 -0
  151. package/lib/module/types/{FocusStyle.js.map → focus.types.js.map} +1 -1
  152. package/lib/module/types/focusOrder.types.js +31 -0
  153. package/lib/module/types/focusOrder.types.js.map +1 -0
  154. package/lib/module/types/focusStyle.types.js +4 -0
  155. package/lib/module/types/focusStyle.types.js.map +1 -0
  156. package/lib/module/types/index.js +3 -0
  157. package/lib/module/types/index.js.map +1 -1
  158. package/lib/module/types/keyPress.types.js +4 -0
  159. package/lib/module/types/keyPress.types.js.map +1 -0
  160. package/lib/module/types/keyboardInput.types.js +4 -0
  161. package/lib/module/types/keyboardInput.types.js.map +1 -0
  162. package/lib/module/types/withKeyboardFocus.types.js +4 -0
  163. package/lib/module/types/withKeyboardFocus.types.js.map +1 -0
  164. package/lib/module/utils/mapLockFocus.js +32 -0
  165. package/lib/module/utils/mapLockFocus.js.map +1 -0
  166. package/lib/module/utils/useFocusStyle.js +4 -21
  167. package/lib/module/utils/useFocusStyle.js.map +1 -1
  168. package/lib/module/utils/useKeyboardFocusContainer.js +74 -0
  169. package/lib/module/utils/useKeyboardFocusContainer.js.map +1 -0
  170. package/lib/module/utils/useKeyboardPress/useKeyboardPress.android.js +4 -7
  171. package/lib/module/utils/useKeyboardPress/useKeyboardPress.android.js.map +1 -1
  172. package/lib/module/utils/useKeyboardPress/useKeyboardPress.ios.js +3 -6
  173. package/lib/module/utils/useKeyboardPress/useKeyboardPress.ios.js.map +1 -1
  174. package/lib/module/utils/useKeyboardPress/useKeyboardPress.js +9 -7
  175. package/lib/module/utils/useKeyboardPress/useKeyboardPress.js.map +1 -1
  176. package/lib/module/utils/useKeyboardPressState.js +60 -0
  177. package/lib/module/utils/useKeyboardPressState.js.map +1 -0
  178. package/lib/module/utils/useOnFocusChange.js +1 -1
  179. package/lib/module/utils/useOnFocusChange.js.map +1 -1
  180. package/lib/module/utils/useOrderValidation.js +30 -0
  181. package/lib/module/utils/useOrderValidation.js.map +1 -0
  182. package/lib/module/utils/useRenderedChildren.js +29 -0
  183. package/lib/module/utils/useRenderedChildren.js.map +1 -0
  184. package/lib/module/utils/useWrappedOrderProps.js +30 -0
  185. package/lib/module/utils/useWrappedOrderProps.js.map +1 -0
  186. package/lib/module/utils/withKeyboardFocus.js +84 -99
  187. package/lib/module/utils/withKeyboardFocus.js.map +1 -1
  188. package/lib/typescript/src/components/BaseKeyboardView/BaseKeyboardView.d.ts +19 -125
  189. package/lib/typescript/src/components/BaseKeyboardView/BaseKeyboardView.d.ts.map +1 -1
  190. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.d.ts +13 -204
  191. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.d.ts.map +1 -1
  192. package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.android.d.ts +4 -146
  193. package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.android.d.ts.map +1 -1
  194. package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.d.ts +2 -12
  195. package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.d.ts.map +1 -1
  196. package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.d.ts +4 -146
  197. package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.d.ts.map +1 -1
  198. package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.types.d.ts +13 -0
  199. package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.types.d.ts.map +1 -0
  200. package/lib/typescript/src/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.d.ts +1 -1
  201. package/lib/typescript/src/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.d.ts.map +1 -1
  202. package/lib/typescript/src/components/KeyboardFocusLock/FocusFrame/FocusFrame.d.ts +1 -1
  203. package/lib/typescript/src/components/KeyboardFocusLock/FocusFrame/FocusFrame.d.ts.map +1 -1
  204. package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.d.ts +1 -1
  205. package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.d.ts.map +1 -1
  206. package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.d.ts +2 -2
  207. package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.d.ts.map +1 -1
  208. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.d.ts +1 -1
  209. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.d.ts.map +1 -1
  210. package/lib/typescript/src/components/KeyboardFocusView/KeyboardFocusView.d.ts +20 -133
  211. package/lib/typescript/src/components/KeyboardFocusView/KeyboardFocusView.d.ts.map +1 -1
  212. package/lib/typescript/src/components/Touchable/Pressable.d.ts +3 -160
  213. package/lib/typescript/src/components/Touchable/Pressable.d.ts.map +1 -1
  214. package/lib/typescript/src/components/index.d.ts +5 -0
  215. package/lib/typescript/src/components/index.d.ts.map +1 -1
  216. package/lib/typescript/src/context/OrderFocusContext.d.ts +1 -1
  217. package/lib/typescript/src/context/OrderFocusContext.d.ts.map +1 -1
  218. package/lib/typescript/src/index.d.ts +48 -10
  219. package/lib/typescript/src/index.d.ts.map +1 -1
  220. package/lib/typescript/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.d.ts +1 -3
  221. package/lib/typescript/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.d.ts.map +1 -1
  222. package/lib/typescript/src/nativeSpec/ExternalKeyboardViewNativeComponent.d.ts +5 -6
  223. package/lib/typescript/src/nativeSpec/ExternalKeyboardViewNativeComponent.d.ts.map +1 -1
  224. package/lib/typescript/src/nativeSpec/KeyboardFocusGroupNativeComponent.d.ts +1 -3
  225. package/lib/typescript/src/nativeSpec/KeyboardFocusGroupNativeComponent.d.ts.map +1 -1
  226. package/lib/typescript/src/nativeSpec/NativeExternalKeyboardModule.d.ts +1 -1
  227. package/lib/typescript/src/nativeSpec/TextInputFocusWrapperNativeComponent.d.ts +3 -3
  228. package/lib/typescript/src/nativeSpec/TextInputFocusWrapperNativeComponent.d.ts.map +1 -1
  229. package/lib/typescript/src/types/KeyboardFocusLock.types.d.ts +15 -1
  230. package/lib/typescript/src/types/KeyboardFocusLock.types.d.ts.map +1 -1
  231. package/lib/typescript/src/types/KeyboardFocusView.types.d.ts +16 -14
  232. package/lib/typescript/src/types/KeyboardFocusView.types.d.ts.map +1 -1
  233. package/lib/typescript/src/types/baseKeyboardView.types.d.ts +119 -0
  234. package/lib/typescript/src/types/baseKeyboardView.types.d.ts.map +1 -0
  235. package/lib/typescript/src/types/focus.types.d.ts +44 -0
  236. package/lib/typescript/src/types/focus.types.d.ts.map +1 -0
  237. package/lib/typescript/src/types/focusOrder.types.d.ts +57 -0
  238. package/lib/typescript/src/types/focusOrder.types.d.ts.map +1 -0
  239. package/lib/typescript/src/types/focusStyle.types.d.ts +11 -0
  240. package/lib/typescript/src/types/focusStyle.types.d.ts.map +1 -0
  241. package/lib/typescript/src/types/index.d.ts +11 -2
  242. package/lib/typescript/src/types/index.d.ts.map +1 -1
  243. package/lib/typescript/src/types/keyPress.types.d.ts +7 -0
  244. package/lib/typescript/src/types/keyPress.types.d.ts.map +1 -0
  245. package/lib/typescript/src/types/keyboardInput.types.d.ts +53 -0
  246. package/lib/typescript/src/types/keyboardInput.types.d.ts.map +1 -0
  247. package/lib/typescript/src/types/withKeyboardFocus.types.d.ts +109 -0
  248. package/lib/typescript/src/types/withKeyboardFocus.types.d.ts.map +1 -0
  249. package/lib/typescript/src/utils/mapLockFocus.d.ts +3 -0
  250. package/lib/typescript/src/utils/mapLockFocus.d.ts.map +1 -0
  251. package/lib/typescript/src/utils/useFocusStyle.d.ts +7 -1017
  252. package/lib/typescript/src/utils/useFocusStyle.d.ts.map +1 -1
  253. package/lib/typescript/src/utils/useKeyboardFocusContainer.d.ts +34 -0
  254. package/lib/typescript/src/utils/useKeyboardFocusContainer.d.ts.map +1 -0
  255. package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.android.d.ts +2 -2
  256. package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.android.d.ts.map +1 -1
  257. package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.d.ts +4 -3
  258. package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.d.ts.map +1 -1
  259. package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.ios.d.ts +3 -3
  260. package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.ios.d.ts.map +1 -1
  261. package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.types.d.ts +1 -2
  262. package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.types.d.ts.map +1 -1
  263. package/lib/typescript/src/utils/useKeyboardPressState.d.ts +29 -0
  264. package/lib/typescript/src/utils/useKeyboardPressState.d.ts.map +1 -0
  265. package/lib/typescript/src/utils/useOnFocusChange.d.ts +3 -3
  266. package/lib/typescript/src/utils/useOnFocusChange.d.ts.map +1 -1
  267. package/lib/typescript/src/utils/useOrderValidation.d.ts +8 -0
  268. package/lib/typescript/src/utils/useOrderValidation.d.ts.map +1 -0
  269. package/lib/typescript/src/utils/useRenderedChildren.d.ts +18 -0
  270. package/lib/typescript/src/utils/useRenderedChildren.d.ts.map +1 -0
  271. package/lib/typescript/src/utils/useWrappedOrderProps.d.ts +13 -0
  272. package/lib/typescript/src/utils/useWrappedOrderProps.d.ts.map +1 -0
  273. package/lib/typescript/src/utils/withKeyboardFocus.d.ts +3 -8
  274. package/lib/typescript/src/utils/withKeyboardFocus.d.ts.map +1 -1
  275. package/package.json +10 -5
  276. package/src/components/BaseKeyboardView/BaseKeyboardView.tsx +74 -94
  277. package/src/components/KeyboardExtendedInput/KeyboardExtendedInput.tsx +49 -149
  278. package/src/components/KeyboardFocusGroup/KeyboardFocusGroup.android.tsx +23 -32
  279. package/src/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.tsx +32 -41
  280. package/src/components/KeyboardFocusGroup/KeyboardFocusGroup.tsx +3 -14
  281. package/src/components/KeyboardFocusGroup/KeyboardFocusGroup.types.ts +15 -0
  282. package/src/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.tsx +2 -2
  283. package/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.tsx +2 -2
  284. package/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.tsx +1 -1
  285. package/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.tsx +2 -2
  286. package/src/components/KeyboardFocusView/KeyboardFocusView.tsx +29 -68
  287. package/src/components/Touchable/Pressable.tsx +2 -2
  288. package/src/components/index.ts +12 -0
  289. package/src/index.tsx +44 -32
  290. package/src/nativeSpec/ExternalKeyboardViewNativeComponent.ts +6 -4
  291. package/src/nativeSpec/TextInputFocusWrapperNativeComponent.ts +2 -0
  292. package/src/types/KeyboardFocusLock.types.ts +16 -1
  293. package/src/types/KeyboardFocusView.types.ts +17 -18
  294. package/src/types/baseKeyboardView.types.ts +122 -0
  295. package/src/types/focus.types.ts +49 -0
  296. package/src/types/focusOrder.types.ts +59 -0
  297. package/src/types/{FocusStyle.ts → focusStyle.types.ts} +5 -0
  298. package/src/types/index.ts +32 -2
  299. package/src/types/keyPress.types.ts +8 -0
  300. package/src/types/keyboardInput.types.ts +81 -0
  301. package/src/types/withKeyboardFocus.types.ts +178 -0
  302. package/src/utils/mapLockFocus.ts +31 -0
  303. package/src/utils/useFocusStyle.tsx +13 -41
  304. package/src/utils/useKeyboardFocusContainer.ts +102 -0
  305. package/src/utils/useKeyboardPress/useKeyboardPress.android.ts +4 -7
  306. package/src/utils/useKeyboardPress/useKeyboardPress.ios.ts +3 -6
  307. package/src/utils/useKeyboardPress/useKeyboardPress.ts +9 -7
  308. package/src/utils/useKeyboardPress/useKeyboardPress.types.ts +1 -2
  309. package/src/utils/useKeyboardPressState.ts +81 -0
  310. package/src/utils/useOnFocusChange.ts +4 -7
  311. package/src/utils/useOrderValidation.ts +74 -0
  312. package/src/utils/useRenderedChildren.ts +42 -0
  313. package/src/utils/useWrappedOrderProps.ts +48 -0
  314. package/src/utils/withKeyboardFocus.tsx +105 -125
  315. package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.types.js.map +0 -1
  316. package/lib/commonjs/components/KeyboardFocusView/hooks/index.js +0 -13
  317. package/lib/commonjs/components/KeyboardFocusView/hooks/index.js.map +0 -1
  318. package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/index.js +0 -13
  319. package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/index.js.map +0 -1
  320. package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.js +0 -33
  321. package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.js.map +0 -1
  322. package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.js +0 -39
  323. package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.js.map +0 -1
  324. package/lib/commonjs/components/RenderPropComponent/RenderPropComponent.js +0 -23
  325. package/lib/commonjs/components/RenderPropComponent/RenderPropComponent.js.map +0 -1
  326. package/lib/commonjs/types/BaseKeyboardView.js +0 -18
  327. package/lib/commonjs/types/BaseKeyboardView.js.map +0 -1
  328. package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.types.js +0 -4
  329. package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.types.js.map +0 -1
  330. package/lib/module/components/KeyboardFocusView/hooks/index.js +0 -4
  331. package/lib/module/components/KeyboardFocusView/hooks/index.js.map +0 -1
  332. package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/index.js +0 -4
  333. package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/index.js.map +0 -1
  334. package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.js +0 -28
  335. package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.js.map +0 -1
  336. package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.js +0 -34
  337. package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.js.map +0 -1
  338. package/lib/module/components/RenderPropComponent/RenderPropComponent.js +0 -17
  339. package/lib/module/components/RenderPropComponent/RenderPropComponent.js.map +0 -1
  340. package/lib/module/types/BaseKeyboardView.js +0 -14
  341. package/lib/module/types/BaseKeyboardView.js.map +0 -1
  342. package/lib/module/types/FocusStyle.js +0 -4
  343. package/lib/module/types/WithKeyboardFocus.js +0 -4
  344. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.d.ts +0 -45
  345. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.d.ts.map +0 -1
  346. package/lib/typescript/src/components/KeyboardFocusView/hooks/index.d.ts +0 -2
  347. package/lib/typescript/src/components/KeyboardFocusView/hooks/index.d.ts.map +0 -1
  348. package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/index.d.ts +0 -2
  349. package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/index.d.ts.map +0 -1
  350. package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.d.ts +0 -175
  351. package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.d.ts.map +0 -1
  352. package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.d.ts +0 -181
  353. package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.d.ts.map +0 -1
  354. package/lib/typescript/src/components/RenderPropComponent/RenderPropComponent.d.ts +0 -6
  355. package/lib/typescript/src/components/RenderPropComponent/RenderPropComponent.d.ts.map +0 -1
  356. package/lib/typescript/src/types/BaseKeyboardView.d.ts +0 -70
  357. package/lib/typescript/src/types/BaseKeyboardView.d.ts.map +0 -1
  358. package/lib/typescript/src/types/FocusStyle.d.ts +0 -6
  359. package/lib/typescript/src/types/FocusStyle.d.ts.map +0 -1
  360. package/lib/typescript/src/types/WithKeyboardFocus.d.ts +0 -47
  361. package/lib/typescript/src/types/WithKeyboardFocus.d.ts.map +0 -1
  362. package/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.ts +0 -73
  363. package/src/components/KeyboardFocusView/hooks/index.ts +0 -1
  364. package/src/components/KeyboardFocusView/hooks/useFocusStyle/index.ts +0 -1
  365. package/src/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.ts +0 -34
  366. package/src/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.ts +0 -41
  367. package/src/components/RenderPropComponent/RenderPropComponent.tsx +0 -18
  368. package/src/types/BaseKeyboardView.ts +0 -74
  369. package/src/types/WithKeyboardFocus.ts +0 -115
@@ -1,4 +1,4 @@
1
- import type { OnKeyPressFn } from '../../types/BaseKeyboardView';
1
+ import type { OnKeyPressFn } from '../../types';
2
2
 
3
3
  export type UseKeyboardPressProps<T, K> = {
4
4
  triggerCodes?: number[];
@@ -8,5 +8,4 @@ export type UseKeyboardPressProps<T, K> = {
8
8
  onPress?: T;
9
9
  onPressIn?: K;
10
10
  onPressOut?: K;
11
- disabled?: boolean;
12
11
  };
@@ -0,0 +1,81 @@
1
+ import { useCallback, useState } from 'react';
2
+ import { Platform } from 'react-native';
3
+
4
+ type AnyPressHandler = (event?: any) => void;
5
+ type PressableStyleFn = (state: { pressed: boolean }) => unknown;
6
+
7
+ type UseKeyboardPressStateParams = {
8
+ enabled?: boolean;
9
+ onPressIn?: AnyPressHandler;
10
+ onPressOut?: AnyPressHandler;
11
+ onFocusChange?: (isFocused: boolean) => void;
12
+ };
13
+
14
+ /**
15
+ * Android only. Physical-keyboard activation (Enter / Space / DPad-center) never
16
+ * reaches the touch responder, so a wrapped component's `pressed` stays false.
17
+ * This derives a press state from the key down/up events and returns composable
18
+ * pieces to thread it through focus, press handlers, and function styles.
19
+ *
20
+ * Everything is a no-op unless `enabled` and running on Android, so callers can
21
+ * always wire the returned values unconditionally.
22
+ */
23
+ export const useKeyboardPressState = ({
24
+ enabled = false,
25
+ onPressIn,
26
+ onPressOut,
27
+ onFocusChange,
28
+ }: UseKeyboardPressStateParams) => {
29
+ const active = enabled && Platform.OS === 'android';
30
+ const [pressed, setPressed] = useState(false);
31
+
32
+ const handlePressIn = useCallback(
33
+ (e?: any) => {
34
+ setPressed(true);
35
+ onPressIn?.(e);
36
+ },
37
+ [onPressIn]
38
+ );
39
+
40
+ const handlePressOut = useCallback(
41
+ (e?: any) => {
42
+ setPressed(false);
43
+ onPressOut?.(e);
44
+ },
45
+ [onPressOut]
46
+ );
47
+
48
+ const handleFocusChange = useCallback(
49
+ (isFocused: boolean) => {
50
+ // Drop a stuck press if focus leaves before the key-up arrives.
51
+ if (!isFocused && active) setPressed(false);
52
+ onFocusChange?.(isFocused);
53
+ },
54
+ [onFocusChange, active]
55
+ );
56
+
57
+ // Fold the keyboard press into a `style({ pressed })` function so visual
58
+ // press feedback (`withPressedStyle`, function styles) reacts to the keyboard.
59
+ // Non-function styles and the inactive case are returned untouched.
60
+ const applyPressedStyle = useCallback(
61
+ <S>(style: S): S => {
62
+ if (!active || typeof style !== 'function') return style;
63
+ const styleFn = style as PressableStyleFn;
64
+ return (({ pressed: touchPressed }: { pressed: boolean }) =>
65
+ styleFn({ pressed: touchPressed || pressed })) as S;
66
+ },
67
+ [active, pressed]
68
+ );
69
+
70
+ return {
71
+ /** A keyboard-driven press is currently held. */
72
+ pressed: active && pressed,
73
+ /** Pass to the keyboard press hook; the original handlers when inactive. */
74
+ onPressIn: active ? handlePressIn : onPressIn,
75
+ onPressOut: active ? handlePressOut : onPressOut,
76
+ /** Wrap `onFocusChange` to clear a stuck press on blur. */
77
+ onFocusChange: handleFocusChange,
78
+ /** Fold the keyboard press into a function style. */
79
+ applyPressedStyle,
80
+ };
81
+ };
@@ -1,8 +1,8 @@
1
1
  import { useCallback } from 'react';
2
- import type { OnFocusChangeFn } from '../types';
2
+ import type { OnFocusChangeFn, NativeFocusChangeHandler } from '../types';
3
3
 
4
4
  type UseFocusChange = {
5
- onFocusChange?: (f: boolean, tag?: number) => void;
5
+ onFocusChange?: OnFocusChangeFn;
6
6
  onFocus?: () => void;
7
7
  onBlur?: () => void;
8
8
  };
@@ -12,12 +12,9 @@ export const useOnFocusChange = ({
12
12
  onFocus,
13
13
  onBlur,
14
14
  }: UseFocusChange) =>
15
- useCallback<OnFocusChangeFn>(
15
+ useCallback<NativeFocusChangeHandler>(
16
16
  (e) => {
17
- onFocusChange?.(
18
- e.nativeEvent.isFocused,
19
- (e?.nativeEvent as unknown as { target?: number })?.target
20
- );
17
+ onFocusChange?.(e.nativeEvent.isFocused, e.nativeEvent.target);
21
18
  if (e.nativeEvent.isFocused) {
22
19
  onFocus?.();
23
20
  } else {
@@ -0,0 +1,74 @@
1
+ import { useEffect } from 'react';
2
+ import type { FocusOrderProps } from '../types';
3
+
4
+ type UseOrderValidationProps = Pick<
5
+ FocusOrderProps,
6
+ | 'orderIndex'
7
+ | 'orderId'
8
+ | 'orderForward'
9
+ | 'orderBackward'
10
+ | 'orderFirst'
11
+ | 'orderLast'
12
+ | 'orderLeft'
13
+ | 'orderRight'
14
+ | 'orderUp'
15
+ | 'orderDown'
16
+ > & {
17
+ groupId?: string;
18
+ orderPrefix: string;
19
+ };
20
+
21
+ export const useOrderValidation = ({
22
+ groupId,
23
+ orderIndex,
24
+ orderPrefix,
25
+ orderId,
26
+ orderForward,
27
+ orderBackward,
28
+ orderFirst,
29
+ orderLast,
30
+ orderLeft,
31
+ orderRight,
32
+ orderUp,
33
+ orderDown,
34
+ }: UseOrderValidationProps) => {
35
+ useEffect(() => {
36
+ if (!__DEV__) return;
37
+ if (orderIndex !== undefined && !groupId)
38
+ console.warn(
39
+ '`orderIndex` must be declared alongside `orderGroup` for proper functionality. Ensure components are wrapped with `KeyboardOrderFocusGroup` or provide `orderGroup` directly.'
40
+ );
41
+ }, [groupId, orderIndex]);
42
+
43
+ useEffect(() => {
44
+ if (!__DEV__) return;
45
+ const hasOrderLinkProp =
46
+ orderId !== undefined ||
47
+ orderForward !== undefined ||
48
+ orderBackward !== undefined ||
49
+ orderFirst !== undefined ||
50
+ orderLast !== undefined ||
51
+ orderLeft !== undefined ||
52
+ orderRight !== undefined ||
53
+ orderUp !== undefined ||
54
+ orderDown !== undefined;
55
+ if (hasOrderLinkProp && orderPrefix === '') {
56
+ console.warn(
57
+ '[react-native-external-keyboard] orderId, orderForward, orderBackward, orderFirst, orderLast, ' +
58
+ 'orderLeft, orderRight, orderUp, and orderDown are global IDs. ' +
59
+ 'Wrap the component in <KeyboardOrderFocusGroup> or pass orderPrefix to avoid ID collisions across screens.'
60
+ );
61
+ }
62
+ }, [
63
+ orderId,
64
+ orderForward,
65
+ orderBackward,
66
+ orderFirst,
67
+ orderLast,
68
+ orderLeft,
69
+ orderRight,
70
+ orderUp,
71
+ orderDown,
72
+ orderPrefix,
73
+ ]);
74
+ };
@@ -0,0 +1,42 @@
1
+ import { useMemo } from 'react';
2
+
3
+ type UseRenderedChildrenProps = {
4
+ focused: boolean;
5
+ keyboardPressed?: boolean;
6
+ renderContent?: (state: Record<string, unknown>) => React.ReactNode;
7
+ renderFocusable?: (state: { focused: boolean }) => React.ReactNode;
8
+ };
9
+
10
+ /**
11
+ * Resolves the `children` override for the wrapped component.
12
+ * - `renderContent` stays a function so the component can call it with its own state + `focused`
13
+ * (keyboard activation forces `pressed` when `keyboardPressed` is set)
14
+ * - `renderFocusable` is evaluated immediately and returned as a static node
15
+ * Returns `undefined` when neither prop is provided.
16
+ */
17
+ export const useRenderedChildren = ({
18
+ focused,
19
+ keyboardPressed = false,
20
+ renderContent,
21
+ renderFocusable,
22
+ }: UseRenderedChildrenProps) => {
23
+ const contentChildren = useMemo(
24
+ () =>
25
+ renderContent
26
+ ? (state: Record<string, unknown>) =>
27
+ renderContent({
28
+ ...state,
29
+ ...(keyboardPressed ? { pressed: true } : null),
30
+ focused,
31
+ })
32
+ : undefined,
33
+ [renderContent, focused, keyboardPressed]
34
+ );
35
+
36
+ const focusableChildren = useMemo(
37
+ () => renderFocusable?.({ focused }),
38
+ [renderFocusable, focused]
39
+ );
40
+
41
+ return contentChildren ?? focusableChildren;
42
+ };
@@ -0,0 +1,48 @@
1
+ import { useMemo } from 'react';
2
+ import type { FocusOrderProps } from '../types';
3
+ import { wrapOrderPrefix } from './wrapOrderPrefix';
4
+
5
+ export const useWrappedOrderProps = ({
6
+ orderPrefix = '',
7
+ orderId,
8
+ orderForward,
9
+ orderBackward,
10
+ orderFirst,
11
+ orderLast,
12
+ orderLeft,
13
+ orderRight,
14
+ orderUp,
15
+ orderDown,
16
+ }: FocusOrderProps) => {
17
+ const wrapPrefix = useMemo(() => wrapOrderPrefix(orderPrefix), [orderPrefix]);
18
+
19
+ return useMemo(
20
+ () => ({
21
+ orderId: wrapPrefix(orderId),
22
+ orderForward: wrapPrefix(orderForward),
23
+ orderBackward: wrapPrefix(orderBackward),
24
+ orderLeft: wrapPrefix(orderLeft),
25
+ orderRight: wrapPrefix(orderRight),
26
+ orderUp: wrapPrefix(orderUp),
27
+ orderDown: wrapPrefix(orderDown),
28
+ orderFirst: wrapPrefix(
29
+ orderFirst === null ? undefined : orderFirst ?? orderForward
30
+ ),
31
+ orderLast: wrapPrefix(
32
+ orderLast === null ? undefined : orderLast ?? orderBackward
33
+ ),
34
+ }),
35
+ [
36
+ wrapPrefix,
37
+ orderId,
38
+ orderForward,
39
+ orderBackward,
40
+ orderFirst,
41
+ orderLast,
42
+ orderLeft,
43
+ orderRight,
44
+ orderUp,
45
+ orderDown,
46
+ ]
47
+ );
48
+ };
@@ -1,64 +1,63 @@
1
- import React, { useCallback, useMemo, type RefObject } from 'react';
2
- import { View, StyleSheet, type ViewProps } from 'react-native';
1
+ import React, { type RefObject, useMemo } from 'react';
2
+ import { Pressable as RNPressable, View, type ViewProps } from 'react-native';
3
3
  import { BaseKeyboardView } from '../components';
4
- import type { KeyboardFocus, OnKeyPress } from '../types/BaseKeyboardView';
5
- import { useFocusStyle } from './useFocusStyle';
6
4
  import type {
5
+ BaseKeyboardViewType,
7
6
  KeyboardPressType,
8
- WithKeyboardFocus,
9
- WithKeyboardFocusComponent,
10
- } from '../types/WithKeyboardFocus';
11
- import { RenderPropComponent } from '../components/RenderPropComponent/RenderPropComponent';
12
- import { useKeyboardPress } from './useKeyboardPress/useKeyboardPress';
7
+ OnKeyPress,
8
+ WithKeyboardFocusProps,
9
+ KeyboardFocusableComponent,
10
+ } from '../types';
11
+ import { useKeyboardFocusContainer } from './useKeyboardFocusContainer';
12
+ import { useRenderedChildren } from './useRenderedChildren';
13
13
  import { IsViewFocusedContext } from '../context/IsViewFocusedContext';
14
- import type { FocusViewProps } from '../types/KeyboardFocusView.types';
15
14
 
16
15
  export const withKeyboardFocus = <
17
16
  ComponentProps extends object,
18
17
  ViewStyleType,
19
18
  ViewType = View
20
19
  >(
21
- Component: WithKeyboardFocusComponent<ComponentProps>
20
+ Component: KeyboardFocusableComponent<ComponentProps>
22
21
  ) => {
23
22
  const WithKeyboardFocus = React.memo(
24
23
  React.forwardRef<
25
- View | KeyboardFocus,
26
- WithKeyboardFocus<ComponentProps, ViewStyleType, ViewType>
24
+ BaseKeyboardViewType | View,
25
+ WithKeyboardFocusProps<ComponentProps, ViewStyleType, ViewType>
27
26
  >((allProps, ref) => {
28
27
  const {
29
- tintType = 'default',
30
- autoFocus,
28
+ // Style
31
29
  focusStyle,
32
30
  style,
33
31
  containerStyle,
34
- onFocusChange,
32
+ containerFocusStyle,
33
+ withPressedStyle = false,
34
+ // Press handlers
35
35
  onPress,
36
36
  onLongPress,
37
37
  onKeyUpPress,
38
38
  onKeyDownPress,
39
39
  onPressIn,
40
40
  onPressOut,
41
- group = false,
41
+ triggerCodes,
42
+ // Focus config
43
+ autoFocus,
44
+ focusableWrapper = true,
42
45
  haloEffect = true,
43
- canBeFocused = true,
44
46
  focusable = true,
45
47
  tintColor,
46
48
  onFocus,
47
49
  onBlur,
48
- containerFocusStyle,
49
- FocusHoverComponent,
50
- viewRef,
51
- componentRef,
50
+ onFocusChange,
51
+ groupIdentifier,
52
52
  haloCornerRadius,
53
53
  haloExpendX,
54
54
  haloExpendY,
55
- groupIdentifier,
56
- withPressedStyle = false,
57
- triggerCodes,
58
- exposeMethods,
59
- enableA11yFocus,
60
55
  screenAutoA11yFocus,
61
- screenAutoA11yFocusDelay = 300, // ToDo align with BaseKeyboardView
56
+ screenAutoA11yFocusDelay,
57
+ lockFocus,
58
+ defaultFocusHighlightEnabled,
59
+ androidKeyboardPressState,
60
+ // Order
62
61
  orderIndex,
63
62
  orderGroup,
64
63
  orderId,
@@ -70,123 +69,118 @@ export const withKeyboardFocus = <
70
69
  orderBackward,
71
70
  orderFirst,
72
71
  orderLast,
73
- lockFocus,
72
+ // Refs & render
73
+ componentRef,
74
74
  onComponentFocus,
75
75
  onComponentBlur,
76
76
  renderContent,
77
77
  renderFocusable,
78
- defaultFocusHighlightEnabled,
78
+ roundedHaloFix,
79
+ tintType,
80
+ // Deprecated no-ops: discard so they never reach the wrapped component.
81
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
82
+ enableA11yFocus: _enableA11yFocus,
83
+ children: userChildren,
79
84
  ...props
80
- } = allProps as WithKeyboardFocus<ComponentProps, ViewStyleType>;
85
+ } = allProps as WithKeyboardFocusProps<ComponentProps, ViewStyleType> & {
86
+ children?: React.ReactNode;
87
+ };
81
88
 
82
89
  const {
83
90
  focused,
91
+ keyboardPressed,
84
92
  containerFocusedStyle,
85
93
  componentStyleViewStyle,
86
94
  onFocusChangeHandler,
87
- hoverColor,
88
- } = useFocusStyle({
95
+ onKeyUpPressHandler,
96
+ onKeyDownPressHandler,
97
+ onPressHandler,
98
+ onContextMenuHandler,
99
+ enableContextMenu,
100
+ } = useKeyboardFocusContainer({
89
101
  onFocusChange,
90
- tintColor,
91
102
  focusStyle,
92
103
  containerFocusStyle,
93
- tintType,
94
104
  style,
95
- withPressedStyle,
96
- Component,
105
+ pressedStyleSignature:
106
+ withPressedStyle ||
107
+ (Component as unknown) === (RNPressable as unknown),
108
+ onKeyUpPress,
109
+ onKeyDownPress,
110
+ onPress: onPress as (e?: OnKeyPress) => void,
111
+ onLongPress: onLongPress as (e?: OnKeyPress) => void,
112
+ onPressIn: onPressIn as (e?: OnKeyPress) => void,
113
+ onPressOut: onPressOut as (e?: OnKeyPress) => void,
114
+ triggerCodes,
115
+ androidKeyboardPressState,
97
116
  });
98
117
 
99
- const withHaloEffect = tintType === 'default' && haloEffect;
100
-
101
- const { onKeyUpPressHandler, onKeyDownPressHandler, onPressHandler } =
102
- useKeyboardPress({
103
- onKeyUpPress,
104
- onKeyDownPress,
105
- onPress: onPress as (e?: OnKeyPress) => void,
106
- onLongPress: onLongPress as (e?: OnKeyPress) => void,
107
- onPressIn: onPressIn as (e?: OnKeyPress) => void,
108
- onPressOut: onPressOut as (e?: OnKeyPress) => void,
109
- triggerCodes,
110
- disabled: (props as { disabled?: boolean })?.disabled,
111
- });
112
-
113
- const contentChildrenProp = useMemo(
114
- () =>
115
- renderContent
116
- ? (state: Record<string, unknown>) =>
117
- (
118
- renderContent as unknown as (
119
- s: Record<string, unknown>
120
- ) => React.ReactNode
121
- )({ ...state, focused })
122
- : undefined,
123
- [renderContent, focused]
124
- );
125
-
126
- const focusableChildrenProp = useMemo(
127
- () => (renderFocusable ? renderFocusable({ focused }) : undefined),
128
- [renderFocusable, focused]
129
- );
130
-
131
- const hoverContent = useMemo(() => {
132
- if (FocusHoverComponent) return FocusHoverComponent;
133
- if (tintType === 'hover') {
134
- return <View style={[hoverColor, styles.absolute, styles.opacity]} />;
118
+ const renderedChildren = useRenderedChildren({
119
+ focused,
120
+ keyboardPressed,
121
+ renderContent: renderContent as unknown as (
122
+ state: Record<string, unknown>
123
+ ) => React.ReactNode,
124
+ renderFocusable,
125
+ });
126
+ // `renderContent`/`renderFocusable` are handled above; for a plain
127
+ // children render prop, fold the keyboard press into its `pressed` too so
128
+ // it stays consistent. A no-op unless `keyboardPressed` is active.
129
+ const childContent = useMemo(() => {
130
+ if (renderedChildren !== undefined) return renderedChildren;
131
+ if (keyboardPressed && typeof userChildren === 'function') {
132
+ const childrenFn = userChildren as (
133
+ state: Record<string, unknown>
134
+ ) => React.ReactNode;
135
+ return (state: Record<string, unknown>) =>
136
+ childrenFn({ ...state, pressed: true });
135
137
  }
136
- return undefined;
137
- }, [FocusHoverComponent, hoverColor, tintType]);
138
-
139
- const focusOrderProps = {
140
- orderIndex,
141
- orderGroup,
142
- orderId,
143
- orderLeft,
144
- orderRight,
145
- orderUp,
146
- orderDown,
147
- orderForward,
148
- orderBackward,
149
- orderFirst,
150
- orderLast,
151
- };
138
+ return userChildren;
139
+ }, [renderedChildren, userChildren, keyboardPressed]);
152
140
 
153
- const onContextMenuHandler = useCallback(() => {
154
- (onLongPress as (e?: OnKeyPress) => void)?.();
155
- }, [onLongPress]);
141
+ const containerStyleArr = useMemo(
142
+ () => [containerStyle as ViewProps['style'], containerFocusedStyle],
143
+ [containerStyle, containerFocusedStyle]
144
+ );
156
145
 
157
146
  return (
158
147
  <IsViewFocusedContext.Provider value={focused}>
159
148
  <BaseKeyboardView
160
- style={[
161
- containerStyle as ViewProps['style'],
162
- containerFocusedStyle,
163
- ]}
149
+ style={containerStyleArr}
164
150
  defaultFocusHighlightEnabled={defaultFocusHighlightEnabled}
165
- ref={ref as RefObject<KeyboardFocus>}
166
- viewRef={viewRef}
151
+ ref={ref as RefObject<BaseKeyboardViewType | View>}
167
152
  onKeyUpPress={onKeyUpPressHandler}
168
153
  onKeyDownPress={onKeyDownPressHandler}
169
- onFocus={onFocus as FocusViewProps['onFocus']}
170
- onBlur={onBlur as FocusViewProps['onBlur']}
154
+ onFocus={onFocus ?? undefined}
155
+ onBlur={onBlur ?? undefined}
171
156
  onFocusChange={onFocusChangeHandler}
172
157
  onContextMenuPress={onContextMenuHandler}
173
- enableContextMenu={Boolean(onLongPress)}
174
- haloEffect={withHaloEffect}
158
+ enableContextMenu={enableContextMenu}
159
+ haloEffect={haloEffect}
160
+ tintType={tintType}
175
161
  haloCornerRadius={haloCornerRadius}
176
162
  haloExpendX={haloExpendX}
177
163
  haloExpendY={haloExpendY}
178
164
  autoFocus={autoFocus}
179
- canBeFocused={canBeFocused}
180
165
  focusable={focusable}
181
166
  tintColor={tintColor}
182
- group={group}
167
+ focusableWrapper={focusableWrapper}
183
168
  groupIdentifier={groupIdentifier}
184
- exposeMethods={exposeMethods}
185
- enableA11yFocus={enableA11yFocus}
186
169
  screenAutoA11yFocus={screenAutoA11yFocus}
187
170
  screenAutoA11yFocusDelay={screenAutoA11yFocusDelay}
188
171
  lockFocus={lockFocus}
189
- {...focusOrderProps}
172
+ roundedHaloFix={roundedHaloFix}
173
+ orderIndex={orderIndex}
174
+ orderGroup={orderGroup}
175
+ orderId={orderId}
176
+ orderLeft={orderLeft}
177
+ orderRight={orderRight}
178
+ orderUp={orderUp}
179
+ orderDown={orderDown}
180
+ orderForward={orderForward}
181
+ orderBackward={orderBackward}
182
+ orderFirst={orderFirst}
183
+ orderLast={orderLast}
190
184
  >
191
185
  <Component
192
186
  ref={componentRef}
@@ -205,15 +199,14 @@ export const withKeyboardFocus = <
205
199
  }
206
200
  onFocus={onComponentFocus}
207
201
  onBlur={onComponentBlur}
202
+ // forwarded to the child so Pressable-like components disable press handling when false
203
+ focusable={focusable}
208
204
  {...(props as unknown as ComponentProps)}
209
- {...((contentChildrenProp || focusableChildrenProp) &&
205
+ {...(childContent !== undefined &&
210
206
  ({
211
- children: contentChildrenProp ?? focusableChildrenProp,
207
+ children: childContent,
212
208
  } as unknown as Partial<ComponentProps>))}
213
209
  />
214
- {focused && hoverContent && (
215
- <RenderPropComponent render={hoverContent} />
216
- )}
217
210
  </BaseKeyboardView>
218
211
  </IsViewFocusedContext.Provider>
219
212
  );
@@ -226,16 +219,3 @@ export const withKeyboardFocus = <
226
219
 
227
220
  return WithKeyboardFocus;
228
221
  };
229
-
230
- const styles = StyleSheet.create({
231
- absolute: {
232
- position: 'absolute',
233
- top: 0,
234
- left: 0,
235
- right: 0,
236
- bottom: 0,
237
- },
238
- opacity: {
239
- opacity: 0.3,
240
- },
241
- });
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/KeyboardExtendedInput/KeyboardExtendedInput.types.ts"],"mappings":"","ignoreList":[]}
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "useFocusStyle", {
7
- enumerable: true,
8
- get: function () {
9
- return _useFocusStyle.useFocusStyle;
10
- }
11
- });
12
- var _useFocusStyle = require("./useFocusStyle");
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_useFocusStyle","require"],"sourceRoot":"../../../../../src","sources":["components/KeyboardFocusView/hooks/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA","ignoreList":[]}
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "useFocusStyle", {
7
- enumerable: true,
8
- get: function () {
9
- return _useFocusStyle.useFocusStyle;
10
- }
11
- });
12
- var _useFocusStyle = require("./useFocusStyle");
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_useFocusStyle","require"],"sourceRoot":"../../../../../../src","sources":["components/KeyboardFocusView/hooks/useFocusStyle/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA","ignoreList":[]}