@react-native-ohos/react-native-keyboard-controller 1.12.8-rc.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 (248) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +19 -0
  4. package/harmony/keyboard_controller/BuildProfile.ets +17 -0
  5. package/harmony/keyboard_controller/Index.ets +9 -0
  6. package/harmony/keyboard_controller/ResourceTable.txt +9 -0
  7. package/harmony/keyboard_controller/build-profile.json5 +31 -0
  8. package/harmony/keyboard_controller/consumer-rules.txt +0 -0
  9. package/harmony/keyboard_controller/hvigorfile.ts +6 -0
  10. package/harmony/keyboard_controller/obfuscation-rules.txt +18 -0
  11. package/harmony/keyboard_controller/oh-package.json5 +11 -0
  12. package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -0
  13. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +96 -0
  14. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +90 -0
  15. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +77 -0
  16. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +158 -0
  17. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +74 -0
  18. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +43 -0
  19. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +64 -0
  20. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +89 -0
  21. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +63 -0
  22. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +39 -0
  23. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +25 -0
  24. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +27 -0
  25. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.cpp +43 -0
  26. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +56 -0
  27. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +24 -0
  28. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +28 -0
  29. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +43 -0
  30. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +56 -0
  31. package/harmony/keyboard_controller/src/main/ets/Logger.ts +46 -0
  32. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerPackage.ets +46 -0
  33. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +210 -0
  34. package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +98 -0
  35. package/harmony/keyboard_controller/src/main/ets/Type.ts +41 -0
  36. package/harmony/keyboard_controller/src/main/module.json +29 -0
  37. package/harmony/keyboard_controller/src/main/module.json5 +11 -0
  38. package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -0
  39. package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -0
  40. package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -0
  41. package/harmony/keyboard_controller/ts.ets +9 -0
  42. package/harmony/keyboard_controller.har +0 -0
  43. package/lib/commonjs/animated.js +174 -0
  44. package/lib/commonjs/animated.js.map +1 -0
  45. package/lib/commonjs/bindings.js +38 -0
  46. package/lib/commonjs/bindings.js.map +1 -0
  47. package/lib/commonjs/bindings.native.js +37 -0
  48. package/lib/commonjs/bindings.native.js.map +1 -0
  49. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +66 -0
  50. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -0
  51. package/lib/commonjs/components/KeyboardAvoidingView/index.js +102 -0
  52. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -0
  53. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +255 -0
  54. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
  55. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +110 -0
  56. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  57. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +37 -0
  58. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
  59. package/lib/commonjs/components/KeyboardStickyView/index.js +40 -0
  60. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -0
  61. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +76 -0
  62. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -0
  63. package/lib/commonjs/components/KeyboardToolbar/Button.js +70 -0
  64. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -0
  65. package/lib/commonjs/components/KeyboardToolbar/colors.js +21 -0
  66. package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -0
  67. package/lib/commonjs/components/KeyboardToolbar/colors.native.js +40 -0
  68. package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -0
  69. package/lib/commonjs/components/KeyboardToolbar/index.js +152 -0
  70. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -0
  71. package/lib/commonjs/components/KeyboardToolbar/types.js +6 -0
  72. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -0
  73. package/lib/commonjs/components/hooks/useColorScheme.js +10 -0
  74. package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -0
  75. package/lib/commonjs/components/index.js +42 -0
  76. package/lib/commonjs/components/index.js.map +1 -0
  77. package/lib/commonjs/constants.js +25 -0
  78. package/lib/commonjs/constants.js.map +1 -0
  79. package/lib/commonjs/context.js +42 -0
  80. package/lib/commonjs/context.js.map +1 -0
  81. package/lib/commonjs/hooks/index.js +104 -0
  82. package/lib/commonjs/hooks/index.js.map +1 -0
  83. package/lib/commonjs/hooks/useWindowDimensions/index.android.js +29 -0
  84. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -0
  85. package/lib/commonjs/hooks/useWindowDimensions/index.js +13 -0
  86. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -0
  87. package/lib/commonjs/index.js +116 -0
  88. package/lib/commonjs/index.js.map +1 -0
  89. package/lib/commonjs/internal.js +73 -0
  90. package/lib/commonjs/internal.js.map +1 -0
  91. package/lib/commonjs/monkey-patch.android.js +57 -0
  92. package/lib/commonjs/monkey-patch.android.js.map +1 -0
  93. package/lib/commonjs/monkey-patch.js +11 -0
  94. package/lib/commonjs/monkey-patch.js.map +1 -0
  95. package/lib/commonjs/reanimated.js +12 -0
  96. package/lib/commonjs/reanimated.js.map +1 -0
  97. package/lib/commonjs/reanimated.native.js +88 -0
  98. package/lib/commonjs/reanimated.native.js.map +1 -0
  99. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +10 -0
  100. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  101. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +12 -0
  102. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  103. package/lib/commonjs/specs/NativeKeyboardController.js +9 -0
  104. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -0
  105. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +9 -0
  106. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -0
  107. package/lib/commonjs/types.js +6 -0
  108. package/lib/commonjs/types.js.map +1 -0
  109. package/lib/commonjs/utils.js +9 -0
  110. package/lib/commonjs/utils.js.map +1 -0
  111. package/lib/module/animated.js +166 -0
  112. package/lib/module/animated.js.map +1 -0
  113. package/lib/module/bindings.js +32 -0
  114. package/lib/module/bindings.js.map +1 -0
  115. package/lib/module/bindings.native.js +31 -0
  116. package/lib/module/bindings.native.js.map +1 -0
  117. package/lib/module/components/KeyboardAvoidingView/hooks.js +59 -0
  118. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -0
  119. package/lib/module/components/KeyboardAvoidingView/index.js +95 -0
  120. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -0
  121. package/lib/module/components/KeyboardAwareScrollView/index.js +248 -0
  122. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
  123. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +103 -0
  124. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  125. package/lib/module/components/KeyboardAwareScrollView/utils.js +29 -0
  126. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
  127. package/lib/module/components/KeyboardStickyView/index.js +33 -0
  128. package/lib/module/components/KeyboardStickyView/index.js.map +1 -0
  129. package/lib/module/components/KeyboardToolbar/Arrow.js +68 -0
  130. package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -0
  131. package/lib/module/components/KeyboardToolbar/Button.js +62 -0
  132. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -0
  133. package/lib/module/components/KeyboardToolbar/colors.js +15 -0
  134. package/lib/module/components/KeyboardToolbar/colors.js.map +1 -0
  135. package/lib/module/components/KeyboardToolbar/colors.native.js +34 -0
  136. package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -0
  137. package/lib/module/components/KeyboardToolbar/index.js +140 -0
  138. package/lib/module/components/KeyboardToolbar/index.js.map +1 -0
  139. package/lib/module/components/KeyboardToolbar/types.js +2 -0
  140. package/lib/module/components/KeyboardToolbar/types.js.map +1 -0
  141. package/lib/module/components/hooks/useColorScheme.js +4 -0
  142. package/lib/module/components/hooks/useColorScheme.js.map +1 -0
  143. package/lib/module/components/index.js +5 -0
  144. package/lib/module/components/index.js.map +1 -0
  145. package/lib/module/constants.js +19 -0
  146. package/lib/module/constants.js.map +1 -0
  147. package/lib/module/context.js +35 -0
  148. package/lib/module/context.js.map +1 -0
  149. package/lib/module/hooks/index.js +68 -0
  150. package/lib/module/hooks/index.js.map +1 -0
  151. package/lib/module/hooks/useWindowDimensions/index.android.js +22 -0
  152. package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -0
  153. package/lib/module/hooks/useWindowDimensions/index.js +2 -0
  154. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -0
  155. package/lib/module/index.js +10 -0
  156. package/lib/module/index.js.map +1 -0
  157. package/lib/module/internal.js +66 -0
  158. package/lib/module/internal.js.map +1 -0
  159. package/lib/module/monkey-patch.android.js +47 -0
  160. package/lib/module/monkey-patch.android.js.map +1 -0
  161. package/lib/module/monkey-patch.js +5 -0
  162. package/lib/module/monkey-patch.js.map +1 -0
  163. package/lib/module/reanimated.js +6 -0
  164. package/lib/module/reanimated.js.map +1 -0
  165. package/lib/module/reanimated.native.js +78 -0
  166. package/lib/module/reanimated.native.js.map +1 -0
  167. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +3 -0
  168. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  169. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +5 -0
  170. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  171. package/lib/module/specs/NativeKeyboardController.js +3 -0
  172. package/lib/module/specs/NativeKeyboardController.js.map +1 -0
  173. package/lib/module/specs/NativeStatusBarManagerCompat.js +3 -0
  174. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -0
  175. package/lib/module/types.js +2 -0
  176. package/lib/module/types.js.map +1 -0
  177. package/lib/module/utils.js +2 -0
  178. package/lib/module/utils.js.map +1 -0
  179. package/lib/typescript/animated.d.ts +31 -0
  180. package/lib/typescript/bindings.d.ts +12 -0
  181. package/lib/typescript/bindings.native.d.ts +12 -0
  182. package/lib/typescript/components/KeyboardAvoidingView/hooks.d.ts +6 -0
  183. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +50 -0
  184. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +25 -0
  185. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
  186. package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +2 -0
  187. package/lib/typescript/components/KeyboardStickyView/index.d.ts +35 -0
  188. package/lib/typescript/components/KeyboardToolbar/Arrow.d.ts +9 -0
  189. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +15 -0
  190. package/lib/typescript/components/KeyboardToolbar/colors.d.ts +2 -0
  191. package/lib/typescript/components/KeyboardToolbar/colors.native.d.ts +2 -0
  192. package/lib/typescript/components/KeyboardToolbar/index.d.ts +50 -0
  193. package/lib/typescript/components/KeyboardToolbar/types.d.ts +18 -0
  194. package/lib/typescript/components/hooks/useColorScheme.d.ts +2 -0
  195. package/lib/typescript/components/index.d.ts +8 -0
  196. package/lib/typescript/constants.d.ts +16 -0
  197. package/lib/typescript/context.d.ts +23 -0
  198. package/lib/typescript/hooks/index.d.ts +17 -0
  199. package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +2 -0
  200. package/lib/typescript/hooks/useWindowDimensions/index.d.ts +1 -0
  201. package/lib/typescript/index.d.ts +8 -0
  202. package/lib/typescript/internal.d.ts +30 -0
  203. package/lib/typescript/monkey-patch.android.d.ts +2 -0
  204. package/lib/typescript/monkey-patch.d.ts +2 -0
  205. package/lib/typescript/reanimated.d.ts +5 -0
  206. package/lib/typescript/reanimated.native.d.ts +7 -0
  207. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +53 -0
  208. package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +10 -0
  209. package/lib/typescript/specs/NativeKeyboardController.d.ts +12 -0
  210. package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +10 -0
  211. package/lib/typescript/types.d.ts +133 -0
  212. package/lib/typescript/utils.d.ts +1 -0
  213. package/package.json +177 -0
  214. package/react-native-keyboard-controller.podspec +61 -0
  215. package/src/animated.tsx +246 -0
  216. package/src/bindings.native.ts +57 -0
  217. package/src/bindings.ts +38 -0
  218. package/src/components/KeyboardAvoidingView/hooks.ts +58 -0
  219. package/src/components/KeyboardAvoidingView/index.tsx +156 -0
  220. package/src/components/KeyboardAwareScrollView/index.tsx +373 -0
  221. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -0
  222. package/src/components/KeyboardAwareScrollView/utils.ts +41 -0
  223. package/src/components/KeyboardStickyView/index.tsx +57 -0
  224. package/src/components/KeyboardToolbar/Arrow.tsx +80 -0
  225. package/src/components/KeyboardToolbar/Button.tsx +98 -0
  226. package/src/components/KeyboardToolbar/colors.native.ts +37 -0
  227. package/src/components/KeyboardToolbar/colors.ts +16 -0
  228. package/src/components/KeyboardToolbar/index.tsx +211 -0
  229. package/src/components/KeyboardToolbar/types.ts +40 -0
  230. package/src/components/hooks/useColorScheme.ts +5 -0
  231. package/src/components/index.ts +11 -0
  232. package/src/constants.ts +19 -0
  233. package/src/context.ts +65 -0
  234. package/src/hooks/index.ts +90 -0
  235. package/src/hooks/useWindowDimensions/index.android.ts +33 -0
  236. package/src/hooks/useWindowDimensions/index.ts +1 -0
  237. package/src/index.ts +21 -0
  238. package/src/internal.ts +84 -0
  239. package/src/monkey-patch.android.ts +44 -0
  240. package/src/monkey-patch.ts +4 -0
  241. package/src/reanimated.native.ts +132 -0
  242. package/src/reanimated.ts +29 -0
  243. package/src/specs/KeyboardControllerViewNativeComponent.ts +70 -0
  244. package/src/specs/KeyboardGestureAreaNativeComponent.ts +15 -0
  245. package/src/specs/NativeKeyboardController.ts +19 -0
  246. package/src/specs/NativeStatusBarManagerCompat.ts +14 -0
  247. package/src/types.ts +211 -0
  248. package/src/utils.ts +1 -0
package/package.json ADDED
@@ -0,0 +1,177 @@
1
+ {
2
+ "name": "@react-native-ohos/react-native-keyboard-controller",
3
+ "version": "1.12.8-rc.1",
4
+ "description": "Keyboard manager which works in identical way on iOS and Android and harmony",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "harmony",
16
+ "cpp",
17
+ "react-native-keyboard-controller.podspec",
18
+ "jest",
19
+ "!lib/typescript/example",
20
+ "!android/build",
21
+ "!android/.gradle",
22
+ "!android/gradle",
23
+ "!android/gradlew",
24
+ "!android/gradlew.bat",
25
+ "!ios/build",
26
+ "!ios/KeyboardControllerNative",
27
+ "!**/__tests__",
28
+ "!**/__fixtures__",
29
+ "!**/__mocks__"
30
+ ],
31
+ "scripts": {
32
+ "format": "prettier '**/*' --ignore-unknown --write",
33
+ "test": "jest",
34
+ "typescript": "tsc --noEmit --project tsconfig.build.json",
35
+ "lint": "eslint --quiet \"**/*.{js,ts,tsx}\"",
36
+ "lint-clang": "find ios/ -iname *.h -o -iname *.m -o -iname *.mm | grep -v -e Pods -e build | xargs clang-format -i -n --Werror",
37
+ "prepare": "bob build",
38
+ "release": "release-it",
39
+ "example": "yarn --cwd example",
40
+ "pods": "cd example && pod-install --quiet",
41
+ "bootstrap": "yarn example && yarn && yarn pods"
42
+ },
43
+ "keywords": [
44
+ "react-native",
45
+ "keyboard",
46
+ "interactive",
47
+ "dismiss",
48
+ "animation",
49
+ "focused input",
50
+ "text changed",
51
+ "selection changed",
52
+ "avoiding view",
53
+ "avoid keyboard",
54
+ "sticky view",
55
+ "keyboard aware scroll view",
56
+ "keyboard toolbar",
57
+ "keyboard done button",
58
+ "keyboard next button",
59
+ "keyboard previous button",
60
+ "ios",
61
+ "android",
62
+ "harmony"
63
+ ],
64
+ "repository": "https://github.com/react-native-oh-library/react-native-keyboard-controller",
65
+ "author": "Kiryl Ziusko <zyusko.kirik@gmail.com> (https://github.com/kirillzyusko)",
66
+ "license": "MIT",
67
+ "bugs": {
68
+ "url": "https://github.com/react-native-oh-library/react-native-keyboard-controller/issues"
69
+ },
70
+ "homepage": "https://kirillzyusko.github.io/react-native-keyboard-controller/",
71
+ "publishConfig": {
72
+ "registry": "https://registry.npmjs.org/",
73
+ "access": "public"
74
+ },
75
+ "devDependencies": {
76
+ "@commitlint/config-conventional": "^11.0.0",
77
+ "@react-native/eslint-config": "^0.75.3",
78
+ "@release-it/conventional-changelog": "^2.0.0",
79
+ "@testing-library/react-hooks": "^8.0.1",
80
+ "@types/jest": "^29.2.1",
81
+ "@types/react": "^18.2.6",
82
+ "@typescript-eslint/eslint-plugin": "^6.7.4",
83
+ "@typescript-eslint/parser": "^6.7.4",
84
+ "clang-format": "^1.8.0",
85
+ "commitlint": "^11.0.0",
86
+ "eslint": "^8.19.0",
87
+ "eslint-config-prettier": "^8.5.0",
88
+ "eslint-import-resolver-typescript": "^3.6.1",
89
+ "eslint-plugin-eslint-comments": "^3.2.0",
90
+ "eslint-plugin-import": "^2.28.1",
91
+ "eslint-plugin-jest": "^26.5.3",
92
+ "eslint-plugin-prettier": "^4.2.1",
93
+ "eslint-plugin-react-compiler": "^0.0.0-experimental-0998c1e-20240625",
94
+ "eslint-plugin-react-perf": "^3.3.2",
95
+ "husky": "^6.0.0",
96
+ "jest": "^29.6.3",
97
+ "pod-install": "^0.1.0",
98
+ "prettier": "^2.8.8",
99
+ "react": "18.3.1",
100
+ "react-native": "0.75.3",
101
+ "react-native-builder-bob": "^0.18.0",
102
+ "react-native-reanimated": "3.15.0",
103
+ "react-test-renderer": "18.2.0",
104
+ "release-it": "^14.2.2",
105
+ "typescript": "5.0.4"
106
+ },
107
+ "peerDependencies": {
108
+ "react": "*",
109
+ "react-native": "*",
110
+ "react-native-reanimated": ">=3.0.0",
111
+ "react-native-keyboard-controller": "1.12.7"
112
+ },
113
+ "jest": {
114
+ "preset": "react-native",
115
+ "modulePathIgnorePatterns": [
116
+ "<rootDir>/example/node_modules",
117
+ "<rootDir>/lib/"
118
+ ]
119
+ },
120
+ "commitlint": {
121
+ "extends": [
122
+ "@commitlint/config-conventional"
123
+ ]
124
+ },
125
+ "release-it": {
126
+ "git": {
127
+ "commitMessage": "chore: release ${version}",
128
+ "tagName": "v${version}"
129
+ },
130
+ "npm": {
131
+ "publish": true
132
+ },
133
+ "github": {
134
+ "release": true
135
+ },
136
+ "plugins": {
137
+ "@release-it/conventional-changelog": {
138
+ "preset": "angular"
139
+ }
140
+ }
141
+ },
142
+ "prettier": {
143
+ "quoteProps": "consistent",
144
+ "trailingComma": "all"
145
+ },
146
+ "react-native-builder-bob": {
147
+ "source": "src",
148
+ "output": "lib",
149
+ "targets": [
150
+ "commonjs",
151
+ "module",
152
+ [
153
+ "typescript",
154
+ {
155
+ "project": "tsconfig.build.json"
156
+ }
157
+ ]
158
+ ]
159
+ },
160
+ "codegenConfig": {
161
+ "name": "reactnativekeyboardcontroller",
162
+ "type": "all",
163
+ "jsSrcsDir": "./src/specs",
164
+ "android": {
165
+ "javaPackageName": "com.reactnativekeyboardcontroller"
166
+ }
167
+ },
168
+ "harmony": {
169
+ "alias": "react-native-keyboard-controller",
170
+ "autolinking": {
171
+ "etsPackageClassName":"RNKeyboardControllerPackage",
172
+ "cppPackageClassName":"RNKeyboardControllerPackage",
173
+ "cmakeLibraryTargetName": "rnoh_keyboard_controller",
174
+ "ohPackageName": "@react-native-ohos/react-native-keyboard-controller"
175
+ }
176
+ }
177
+ }
@@ -0,0 +1,61 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6
+
7
+ new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
8
+
9
+ Pod::Spec.new do |s|
10
+ s.name = "react-native-keyboard-controller"
11
+ s.version = package["version"]
12
+ s.summary = package["description"]
13
+ s.homepage = package["homepage"]
14
+ s.license = package["license"]
15
+ s.authors = package["author"]
16
+
17
+ s.platforms = { :ios => "11.0" }
18
+ s.source = { :git => "https://github.com/kirillzyusko/react-native-keyboard-controller.git", :tag => "#{s.version}" }
19
+
20
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
21
+ s.exclude_files = "ios/KeyboardControllerNative/**/*"
22
+ s.public_header_files = "ios/**/*.h"
23
+
24
+ # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
25
+ if new_arch_enabled then
26
+ s.pod_target_xcconfig = {
27
+ # This is handy when we want to detect if new arch is enabled in Swift code
28
+ # and can be used like:
29
+ # #if KEYBOARD_CONTROLLER_NEW_ARCH_ENABLED
30
+ # // do sth when new arch is enabled
31
+ # #else
32
+ # // do sth when old arch is enabled
33
+ # #endif
34
+ "OTHER_SWIFT_FLAGS" => "-DKEYBOARD_CONTROLLER_NEW_ARCH_ENABLED"
35
+ }
36
+ end
37
+
38
+ # install_modules_dependencies has been defined since React Native 71
39
+ if defined?(install_modules_dependencies)
40
+ install_modules_dependencies(s)
41
+ else
42
+ s.dependency 'React-Core'
43
+
44
+ # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
45
+ if new_arch_enabled then
46
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
47
+ s.pod_target_xcconfig = s.pod_target_xcconfig | {
48
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
49
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
50
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
51
+ }
52
+
53
+ s.dependency "React-RCTFabric"
54
+ s.dependency "React-Codegen"
55
+ s.dependency "RCT-Folly"
56
+ s.dependency "RCTRequired"
57
+ s.dependency "RCTTypeSafety"
58
+ s.dependency "ReactCommon/turbomodule/core"
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,246 @@
1
+ import React, { useEffect, useMemo, useState } from "react";
2
+ import { Animated, Platform, StyleSheet } from "react-native";
3
+ import Reanimated, { useSharedValue } from "react-native-reanimated";
4
+
5
+ import { KeyboardControllerView } from "./bindings";
6
+ import { KeyboardContext } from "./context";
7
+ import { useAnimatedValue, useSharedHandlers } from "./internal";
8
+ import { applyMonkeyPatch, revertMonkeyPatch } from "./monkey-patch";
9
+ import {
10
+ useAnimatedKeyboardHandler,
11
+ useFocusedInputLayoutHandler,
12
+ useFocusedInputSelectionHandler,
13
+ useFocusedInputTextHandler,
14
+ } from "./reanimated";
15
+
16
+ import type { KeyboardAnimationContext } from "./context";
17
+ import type {
18
+ FocusedInputHandler,
19
+ FocusedInputLayoutChangedEvent,
20
+ KeyboardControllerProps,
21
+ KeyboardHandler,
22
+ NativeEvent,
23
+ } from "./types";
24
+ import type { ViewStyle } from "react-native";
25
+
26
+ const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(
27
+ Animated.createAnimatedComponent(
28
+ KeyboardControllerView,
29
+ ) as React.FC<KeyboardControllerProps>,
30
+ );
31
+
32
+ type Styles = {
33
+ container: ViewStyle;
34
+ hidden: ViewStyle;
35
+ };
36
+
37
+ const styles = StyleSheet.create<Styles>({
38
+ container: {
39
+ flex: 1,
40
+ },
41
+ hidden: {
42
+ display: "none",
43
+ position: "absolute",
44
+ },
45
+ });
46
+
47
+ type KeyboardProviderProps = {
48
+ children: React.ReactNode;
49
+ /**
50
+ * Set the value to `true`, if you use translucent status bar on Android.
51
+ * If you already control status bar translucency via `react-native-screens`
52
+ * or `StatusBar` component from `react-native`, you can ignore it.
53
+ * Defaults to `false`.
54
+ *
55
+ * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14
56
+ * @platform android
57
+ */
58
+ statusBarTranslucent?: boolean;
59
+ /**
60
+ * Set the value to `true`, if you use translucent navigation bar on Android.
61
+ * Defaults to `false`.
62
+ *
63
+ * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119
64
+ * @platform android
65
+ */
66
+ navigationBarTranslucent?: boolean;
67
+ /**
68
+ * A boolean prop indicating whether the module is enabled. It indicate only initial state,
69
+ * i. e. if you try to change this prop after component mount it will not have any effect.
70
+ * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.
71
+ * Defaults to `true`.
72
+ */
73
+ enabled?: boolean;
74
+ };
75
+
76
+ // capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package
77
+ // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details
78
+ const OS = Platform.OS;
79
+
80
+ export const KeyboardProvider = ({
81
+ children,
82
+ statusBarTranslucent,
83
+ navigationBarTranslucent,
84
+ enabled: initiallyEnabled = true,
85
+ }: KeyboardProviderProps) => {
86
+ // state
87
+ const [enabled, setEnabled] = useState(initiallyEnabled);
88
+ // animated values
89
+ const progress = useAnimatedValue(0);
90
+ const height = useAnimatedValue(0);
91
+ // shared values
92
+ const progressSV = useSharedValue(0);
93
+ const heightSV = useSharedValue(0);
94
+ const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);
95
+ const [setKeyboardHandlers, broadcastKeyboardEvents] =
96
+ useSharedHandlers<KeyboardHandler>();
97
+ const [setInputHandlers, broadcastInputEvents] =
98
+ useSharedHandlers<FocusedInputHandler>();
99
+ // memo
100
+ const context = useMemo<KeyboardAnimationContext>(
101
+ () => ({
102
+ enabled,
103
+ animated: { progress: progress, height: Animated.multiply(height,-1) },
104
+ reanimated: { progress: progressSV, height: heightSV },
105
+ layout,
106
+ setKeyboardHandlers,
107
+ setInputHandlers,
108
+ setEnabled,
109
+ }),
110
+ [enabled],
111
+ );
112
+ const style = useMemo(
113
+ () => [
114
+ styles.hidden,
115
+ { transform: [{ translateX: height }, { translateY: progress }] },
116
+ ],
117
+ [],
118
+ );
119
+ const onKeyboardMove = useMemo(
120
+ () =>
121
+ Animated.event(
122
+ [
123
+ {
124
+ nativeEvent: {
125
+ progress,
126
+ height,
127
+ },
128
+ },
129
+ ],
130
+ { useNativeDriver:Platform.OS as string=='harmony'?false:true },
131
+ ),
132
+ [],
133
+ );
134
+ // handlers
135
+ const updateSharedValues = (event: NativeEvent, platforms: string[]) => {
136
+ "worklet";
137
+
138
+ if (platforms.includes(OS)) {
139
+ // eslint-disable-next-line react-compiler/react-compiler
140
+ progressSV.value = event.progress;
141
+ heightSV.value = -event.height;
142
+ }
143
+ };
144
+ const keyboardHandler = useAnimatedKeyboardHandler(
145
+ {
146
+ onKeyboardMoveStart: (event: NativeEvent) => {
147
+ "worklet";
148
+
149
+ broadcastKeyboardEvents("onStart", event);
150
+ updateSharedValues(event, ["ios"]);
151
+ },
152
+ onKeyboardMove: (event: NativeEvent) => {
153
+ "worklet";
154
+
155
+ broadcastKeyboardEvents("onMove", event);
156
+ updateSharedValues(event, ["android"]);
157
+ },
158
+ onKeyboardMoveEnd: (event: NativeEvent) => {
159
+ "worklet";
160
+ broadcastKeyboardEvents("onEnd", event);
161
+ updateSharedValues(event, ['harmony']);
162
+ },
163
+ onKeyboardMoveInteractive: (event: NativeEvent) => {
164
+ "worklet";
165
+
166
+ updateSharedValues(event, ["android", "ios"]);
167
+ broadcastKeyboardEvents("onInteractive", event);
168
+ },
169
+ },
170
+ [],
171
+ );
172
+ const inputLayoutHandler = useFocusedInputLayoutHandler(
173
+ {
174
+ onFocusedInputLayoutChanged: (e) => {
175
+ "worklet";
176
+
177
+ if (e.target !== -1) {
178
+ layout.value = e;
179
+ } else {
180
+ layout.value = null;
181
+ }
182
+ },
183
+ },
184
+ [],
185
+ );
186
+ const inputTextHandler = useFocusedInputTextHandler(
187
+ {
188
+ onFocusedInputTextChanged: (e) => {
189
+ "worklet";
190
+
191
+ broadcastInputEvents("onChangeText", e);
192
+ },
193
+ },
194
+ [],
195
+ );
196
+ const inputSelectionHandler = useFocusedInputSelectionHandler(
197
+ {
198
+ onFocusedInputSelectionChanged: (e) => {
199
+ "worklet";
200
+ broadcastInputEvents("onSelectionChange", e);
201
+ },
202
+ },
203
+ [],
204
+ );
205
+ // effects
206
+ useEffect(() => {
207
+ if (enabled) {
208
+ applyMonkeyPatch();
209
+ } else {
210
+ revertMonkeyPatch();
211
+ }
212
+ }, [enabled]);
213
+
214
+ return (
215
+ <KeyboardContext.Provider value={context}>
216
+ <KeyboardControllerViewAnimated
217
+ enabled={enabled}
218
+ onKeyboardMoveReanimated={keyboardHandler}
219
+ onKeyboardMoveStart={OS === "ios" ? onKeyboardMove : undefined}
220
+ onKeyboardMove={OS === "android" ? onKeyboardMove : undefined}
221
+ onKeyboardMoveInteractive={onKeyboardMove}
222
+ onKeyboardMoveEnd={ OS as string === "harmony"?onKeyboardMove:undefined}
223
+ onFocusedInputLayoutChangedReanimated={inputLayoutHandler}
224
+ onFocusedInputTextChangedReanimated={inputTextHandler}
225
+ onFocusedInputSelectionChangedReanimated={inputSelectionHandler}
226
+ navigationBarTranslucent={navigationBarTranslucent}
227
+ statusBarTranslucent={statusBarTranslucent}
228
+ style={styles.container}
229
+ >
230
+ <Reanimated.View>{children}</Reanimated.View>
231
+ {/* {children} */}
232
+ </KeyboardControllerViewAnimated>
233
+ <Animated.View
234
+ // we are using this small hack, because if the component (where
235
+ // animated value has been used) is unmounted, then animation will
236
+ // stop receiving events (seems like it's react-native optimization).
237
+ // So we need to keep a reference to the animated value, to keep it's
238
+ // always mounted (keep a reference to an animated value).
239
+ //
240
+ // To test why it's needed, try to open screen which consumes Animated.Value
241
+ // then close it and open it again (for example 'Animated transition').
242
+ style={style}
243
+ />
244
+ </KeyboardContext.Provider>
245
+ );
246
+ };
@@ -0,0 +1,57 @@
1
+ import { NativeEventEmitter, Platform } from "react-native";
2
+
3
+ import type {
4
+ FocusedInputEventsModule,
5
+ KeyboardControllerModule,
6
+ KeyboardControllerProps,
7
+ KeyboardEventsModule,
8
+ KeyboardGestureAreaProps,
9
+ WindowDimensionsEventsModule,
10
+ } from "./types";
11
+
12
+ const LINKING_ERROR =
13
+ `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` +
14
+ Platform.select({ ios: "- You have run 'pod install'\n", default: "" }) +
15
+ "- You rebuilt the app after installing the package\n" +
16
+ "- You are not using Expo Go\n";
17
+
18
+ const RCTKeyboardController =
19
+ require("./specs/NativeKeyboardController").default;
20
+ export const KeyboardController = (
21
+ RCTKeyboardController
22
+ ? RCTKeyboardController
23
+ : new Proxy(
24
+ {},
25
+ {
26
+ get() {
27
+ throw new Error(LINKING_ERROR);
28
+ },
29
+ },
30
+ )
31
+ ) as KeyboardControllerModule;
32
+
33
+ const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
34
+ const eventEmitter = new NativeEventEmitter(KeyboardController);
35
+
36
+ export const KeyboardEvents: KeyboardEventsModule = {
37
+ addListener: (name, cb) =>
38
+ eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
39
+ };
40
+ /**
41
+ * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
42
+ * Use it with cautious.
43
+ */
44
+ export const FocusedInputEvents: FocusedInputEventsModule = {
45
+ addListener: (name, cb) =>
46
+ eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
47
+ };
48
+ export const WindowDimensionsEvents: WindowDimensionsEventsModule = {
49
+ addListener: (name, cb) =>
50
+ eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
51
+ };
52
+ export const KeyboardControllerView: React.FC<KeyboardControllerProps> =
53
+ require("./specs/KeyboardControllerViewNativeComponent").default;
54
+ export const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =
55
+ Platform.OS === "android" && Platform.Version >= 30
56
+ ? require("./specs/KeyboardGestureAreaNativeComponent").default
57
+ : ({ children }: KeyboardGestureAreaProps) => children;
@@ -0,0 +1,38 @@
1
+ import { View } from "react-native";
2
+
3
+ import type {
4
+ FocusedInputEventsModule,
5
+ KeyboardControllerModule,
6
+ KeyboardControllerProps,
7
+ KeyboardEventsModule,
8
+ KeyboardGestureAreaProps,
9
+ WindowDimensionsEventsModule,
10
+ } from "./types";
11
+ import type { EmitterSubscription } from "react-native";
12
+
13
+ const NOOP = () => {};
14
+ export const KeyboardController: KeyboardControllerModule = {
15
+ setDefaultMode: NOOP,
16
+ setInputMode: NOOP,
17
+ dismiss: NOOP,
18
+ setFocusTo: NOOP,
19
+ addListener: NOOP,
20
+ removeListeners: NOOP,
21
+ };
22
+ export const KeyboardEvents: KeyboardEventsModule = {
23
+ addListener: () => ({ remove: NOOP } as EmitterSubscription),
24
+ };
25
+ /**
26
+ * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
27
+ * Use it with cautious.
28
+ */
29
+ export const FocusedInputEvents: FocusedInputEventsModule = {
30
+ addListener: () => ({ remove: NOOP } as EmitterSubscription),
31
+ };
32
+ export const WindowDimensionsEvents: WindowDimensionsEventsModule = {
33
+ addListener: () => ({ remove: NOOP } as EmitterSubscription),
34
+ };
35
+ export const KeyboardControllerView =
36
+ View as unknown as React.FC<KeyboardControllerProps>;
37
+ export const KeyboardGestureArea =
38
+ View as unknown as React.FC<KeyboardGestureAreaProps>;
@@ -0,0 +1,58 @@
1
+ import { useSharedValue } from "react-native-reanimated";
2
+
3
+ import {useKeyboardHandler} from "../../hooks";
4
+ import {useKeyboardContext} from "../../context";
5
+ import { Platform } from "react-native";
6
+
7
+ export const useKeyboardAnimation = () => {
8
+ const { reanimated } = useKeyboardContext();
9
+ const heightWhenOpened = useSharedValue(-reanimated.height.value);
10
+ const height = useSharedValue(-reanimated.height.value);
11
+ const progress = useSharedValue(reanimated.progress.value);
12
+ const isClosed = useSharedValue(reanimated.progress.value === 0);
13
+
14
+ useKeyboardHandler(
15
+ {
16
+ onStart: (e) => {
17
+ "worklet";
18
+
19
+ if (e.height > 0) {
20
+ // eslint-disable-next-line react-compiler/react-compiler
21
+ isClosed.value = false;
22
+ heightWhenOpened.value = e.height;
23
+ }
24
+ },
25
+ onMove: (e) => {
26
+ "worklet";
27
+
28
+ progress.value = e.progress;
29
+ height.value = e.height;
30
+ },
31
+ onEnd: (e) => {
32
+ "worklet";
33
+ if(Platform.OS as string === 'harmony'){
34
+ heightWhenOpened.value = e.height;
35
+ }
36
+
37
+ isClosed.value = e.height === 0;
38
+
39
+ // `height` update happens in `onMove` handler
40
+ // in `onEnd` we need to update only if `onMove`
41
+ // wasn't called (i. e. duration === 0)
42
+ //
43
+ // we can not call this code without condition below
44
+ // because in some corner cases (iOS with `secureTextEntry`)
45
+ // `onEnd` can be emitted before `onMove` and in this case
46
+ // it may lead to choppy/glitchy/jumpy UI
47
+ // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327
48
+ if (e.duration === 0) {
49
+ progress.value = e.progress;
50
+ height.value = e.height;
51
+ }
52
+ },
53
+ },
54
+ [],
55
+ );
56
+
57
+ return { height, progress, heightWhenOpened, isClosed };
58
+ };