@react-native-ohos/react-native-keyboard-controller 1.16.6-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 (269) 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 +7 -0
  6. package/harmony/keyboard_controller/ResourceTable.txt +1 -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 +73 -0
  16. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +172 -0
  17. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +76 -0
  18. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +44 -0
  19. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +58 -0
  20. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +87 -0
  21. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +62 -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/RNStatusBarManagerCompat.cpp +24 -0
  26. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +28 -0
  27. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +43 -0
  28. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +56 -0
  29. package/harmony/keyboard_controller/src/main/ets/Logger.ts +46 -0
  30. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerPackage.ts +45 -0
  31. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +238 -0
  32. package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +98 -0
  33. package/harmony/keyboard_controller/src/main/ets/Type.ts +41 -0
  34. package/harmony/keyboard_controller/src/main/module.json5 +11 -0
  35. package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -0
  36. package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -0
  37. package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -0
  38. package/harmony/keyboard_controller/ts.ts +9 -0
  39. package/harmony/keyboard_controller.har +0 -0
  40. package/lib/commonjs/animated.js +176 -0
  41. package/lib/commonjs/animated.js.map +1 -0
  42. package/lib/commonjs/bindings.js +39 -0
  43. package/lib/commonjs/bindings.js.map +1 -0
  44. package/lib/commonjs/bindings.native.js +39 -0
  45. package/lib/commonjs/bindings.native.js.map +1 -0
  46. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +126 -0
  47. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -0
  48. package/lib/commonjs/components/KeyboardAvoidingView/index.js +120 -0
  49. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -0
  50. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +262 -0
  51. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
  52. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +110 -0
  53. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  54. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +37 -0
  55. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
  56. package/lib/commonjs/components/KeyboardStickyView/index.js +41 -0
  57. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -0
  58. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +76 -0
  59. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -0
  60. package/lib/commonjs/components/KeyboardToolbar/Button.js +70 -0
  61. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -0
  62. package/lib/commonjs/components/KeyboardToolbar/colors.js +21 -0
  63. package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -0
  64. package/lib/commonjs/components/KeyboardToolbar/colors.native.js +40 -0
  65. package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -0
  66. package/lib/commonjs/components/KeyboardToolbar/index.js +161 -0
  67. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -0
  68. package/lib/commonjs/components/KeyboardToolbar/types.js +6 -0
  69. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -0
  70. package/lib/commonjs/components/hooks/useColorScheme.js +10 -0
  71. package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -0
  72. package/lib/commonjs/components/index.js +42 -0
  73. package/lib/commonjs/components/index.js.map +1 -0
  74. package/lib/commonjs/constants.js +27 -0
  75. package/lib/commonjs/constants.js.map +1 -0
  76. package/lib/commonjs/context.js +45 -0
  77. package/lib/commonjs/context.js.map +1 -0
  78. package/lib/commonjs/hooks/index.js +104 -0
  79. package/lib/commonjs/hooks/index.js.map +1 -0
  80. package/lib/commonjs/hooks/useWindowDimensions/index.android.js +34 -0
  81. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -0
  82. package/lib/commonjs/hooks/useWindowDimensions/index.js +13 -0
  83. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -0
  84. package/lib/commonjs/index.js +136 -0
  85. package/lib/commonjs/index.js.map +1 -0
  86. package/lib/commonjs/internal.js +73 -0
  87. package/lib/commonjs/internal.js.map +1 -0
  88. package/lib/commonjs/module.js +47 -0
  89. package/lib/commonjs/module.js.map +1 -0
  90. package/lib/commonjs/monkey-patch.android.js +57 -0
  91. package/lib/commonjs/monkey-patch.android.js.map +1 -0
  92. package/lib/commonjs/monkey-patch.js +11 -0
  93. package/lib/commonjs/monkey-patch.js.map +1 -0
  94. package/lib/commonjs/reanimated.js +12 -0
  95. package/lib/commonjs/reanimated.js.map +1 -0
  96. package/lib/commonjs/reanimated.native.js +88 -0
  97. package/lib/commonjs/reanimated.native.js.map +1 -0
  98. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +10 -0
  99. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  100. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +12 -0
  101. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  102. package/lib/commonjs/specs/NativeKeyboardController.js +9 -0
  103. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -0
  104. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +9 -0
  105. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -0
  106. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js +10 -0
  107. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -0
  108. package/lib/commonjs/types.js +6 -0
  109. package/lib/commonjs/types.js.map +1 -0
  110. package/lib/commonjs/utils.js +9 -0
  111. package/lib/commonjs/utils.js.map +1 -0
  112. package/lib/commonjs/views/OverKeyboardView/index.js +42 -0
  113. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -0
  114. package/lib/commonjs/views/index.js +14 -0
  115. package/lib/commonjs/views/index.js.map +1 -0
  116. package/lib/module/animated.js +168 -0
  117. package/lib/module/animated.js.map +1 -0
  118. package/lib/module/bindings.js +33 -0
  119. package/lib/module/bindings.js.map +1 -0
  120. package/lib/module/bindings.native.js +33 -0
  121. package/lib/module/bindings.native.js.map +1 -0
  122. package/lib/module/components/KeyboardAvoidingView/hooks.js +118 -0
  123. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -0
  124. package/lib/module/components/KeyboardAvoidingView/index.js +113 -0
  125. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -0
  126. package/lib/module/components/KeyboardAwareScrollView/index.js +255 -0
  127. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
  128. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +103 -0
  129. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  130. package/lib/module/components/KeyboardAwareScrollView/utils.js +29 -0
  131. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
  132. package/lib/module/components/KeyboardStickyView/index.js +34 -0
  133. package/lib/module/components/KeyboardStickyView/index.js.map +1 -0
  134. package/lib/module/components/KeyboardToolbar/Arrow.js +68 -0
  135. package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -0
  136. package/lib/module/components/KeyboardToolbar/Button.js +62 -0
  137. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -0
  138. package/lib/module/components/KeyboardToolbar/colors.js +15 -0
  139. package/lib/module/components/KeyboardToolbar/colors.js.map +1 -0
  140. package/lib/module/components/KeyboardToolbar/colors.native.js +34 -0
  141. package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -0
  142. package/lib/module/components/KeyboardToolbar/index.js +149 -0
  143. package/lib/module/components/KeyboardToolbar/index.js.map +1 -0
  144. package/lib/module/components/KeyboardToolbar/types.js +2 -0
  145. package/lib/module/components/KeyboardToolbar/types.js.map +1 -0
  146. package/lib/module/components/hooks/useColorScheme.js +4 -0
  147. package/lib/module/components/hooks/useColorScheme.js.map +1 -0
  148. package/lib/module/components/index.js +5 -0
  149. package/lib/module/components/index.js.map +1 -0
  150. package/lib/module/constants.js +21 -0
  151. package/lib/module/constants.js.map +1 -0
  152. package/lib/module/context.js +38 -0
  153. package/lib/module/context.js.map +1 -0
  154. package/lib/module/hooks/index.js +68 -0
  155. package/lib/module/hooks/index.js.map +1 -0
  156. package/lib/module/hooks/useWindowDimensions/index.android.js +27 -0
  157. package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -0
  158. package/lib/module/hooks/useWindowDimensions/index.js +2 -0
  159. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -0
  160. package/lib/module/index.js +12 -0
  161. package/lib/module/index.js.map +1 -0
  162. package/lib/module/internal.js +66 -0
  163. package/lib/module/internal.js.map +1 -0
  164. package/lib/module/module.js +41 -0
  165. package/lib/module/module.js.map +1 -0
  166. package/lib/module/monkey-patch.android.js +47 -0
  167. package/lib/module/monkey-patch.android.js.map +1 -0
  168. package/lib/module/monkey-patch.js +5 -0
  169. package/lib/module/monkey-patch.js.map +1 -0
  170. package/lib/module/reanimated.js +6 -0
  171. package/lib/module/reanimated.js.map +1 -0
  172. package/lib/module/reanimated.native.js +78 -0
  173. package/lib/module/reanimated.native.js.map +1 -0
  174. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +3 -0
  175. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  176. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +5 -0
  177. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  178. package/lib/module/specs/NativeKeyboardController.js +3 -0
  179. package/lib/module/specs/NativeKeyboardController.js.map +1 -0
  180. package/lib/module/specs/NativeStatusBarManagerCompat.js +3 -0
  181. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -0
  182. package/lib/module/specs/OverKeyboardViewNativeComponent.js +3 -0
  183. package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -0
  184. package/lib/module/types.js +2 -0
  185. package/lib/module/types.js.map +1 -0
  186. package/lib/module/utils.js +2 -0
  187. package/lib/module/utils.js.map +1 -0
  188. package/lib/module/views/OverKeyboardView/index.js +35 -0
  189. package/lib/module/views/OverKeyboardView/index.js.map +1 -0
  190. package/lib/module/views/index.js +2 -0
  191. package/lib/module/views/index.js.map +1 -0
  192. package/lib/typescript/animated.d.ts +39 -0
  193. package/lib/typescript/bindings.d.ts +12 -0
  194. package/lib/typescript/bindings.native.d.ts +12 -0
  195. package/lib/typescript/components/KeyboardAvoidingView/hooks.d.ts +10 -0
  196. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +40 -0
  197. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +29 -0
  198. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
  199. package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +2 -0
  200. package/lib/typescript/components/KeyboardStickyView/index.d.ts +39 -0
  201. package/lib/typescript/components/KeyboardToolbar/Arrow.d.ts +9 -0
  202. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +16 -0
  203. package/lib/typescript/components/KeyboardToolbar/colors.d.ts +2 -0
  204. package/lib/typescript/components/KeyboardToolbar/colors.native.d.ts +2 -0
  205. package/lib/typescript/components/KeyboardToolbar/index.d.ts +52 -0
  206. package/lib/typescript/components/KeyboardToolbar/types.d.ts +18 -0
  207. package/lib/typescript/components/hooks/useColorScheme.d.ts +2 -0
  208. package/lib/typescript/components/index.d.ts +8 -0
  209. package/lib/typescript/constants.d.ts +16 -0
  210. package/lib/typescript/context.d.ts +23 -0
  211. package/lib/typescript/hooks/index.d.ts +17 -0
  212. package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +2 -0
  213. package/lib/typescript/hooks/useWindowDimensions/index.d.ts +1 -0
  214. package/lib/typescript/index.d.ts +10 -0
  215. package/lib/typescript/internal.d.ts +30 -0
  216. package/lib/typescript/module.d.ts +2 -0
  217. package/lib/typescript/monkey-patch.android.d.ts +2 -0
  218. package/lib/typescript/monkey-patch.d.ts +2 -0
  219. package/lib/typescript/reanimated.d.ts +5 -0
  220. package/lib/typescript/reanimated.native.d.ts +7 -0
  221. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +54 -0
  222. package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +12 -0
  223. package/lib/typescript/specs/NativeKeyboardController.d.ts +12 -0
  224. package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +10 -0
  225. package/lib/typescript/specs/OverKeyboardViewNativeComponent.d.ts +7 -0
  226. package/lib/typescript/types.d.ts +161 -0
  227. package/lib/typescript/utils.d.ts +1 -0
  228. package/lib/typescript/views/OverKeyboardView/index.d.ts +5 -0
  229. package/lib/typescript/views/index.d.ts +1 -0
  230. package/package.json +173 -0
  231. package/react-native-keyboard-controller.podspec +61 -0
  232. package/src/animated.tsx +256 -0
  233. package/src/bindings.native.ts +62 -0
  234. package/src/bindings.ts +42 -0
  235. package/src/components/KeyboardAvoidingView/hooks.ts +123 -0
  236. package/src/components/KeyboardAvoidingView/index.tsx +188 -0
  237. package/src/components/KeyboardAwareScrollView/index.tsx +389 -0
  238. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -0
  239. package/src/components/KeyboardAwareScrollView/utils.ts +41 -0
  240. package/src/components/KeyboardStickyView/index.tsx +66 -0
  241. package/src/components/KeyboardToolbar/Arrow.tsx +80 -0
  242. package/src/components/KeyboardToolbar/Button.tsx +98 -0
  243. package/src/components/KeyboardToolbar/colors.native.ts +37 -0
  244. package/src/components/KeyboardToolbar/colors.ts +16 -0
  245. package/src/components/KeyboardToolbar/index.tsx +223 -0
  246. package/src/components/KeyboardToolbar/types.ts +40 -0
  247. package/src/components/hooks/useColorScheme.ts +5 -0
  248. package/src/components/index.ts +11 -0
  249. package/src/constants.ts +19 -0
  250. package/src/context.ts +68 -0
  251. package/src/hooks/index.ts +90 -0
  252. package/src/hooks/useWindowDimensions/index.android.ts +38 -0
  253. package/src/hooks/useWindowDimensions/index.ts +1 -0
  254. package/src/index.ts +23 -0
  255. package/src/internal.ts +84 -0
  256. package/src/module.ts +52 -0
  257. package/src/monkey-patch.android.ts +44 -0
  258. package/src/monkey-patch.ts +4 -0
  259. package/src/reanimated.native.ts +132 -0
  260. package/src/reanimated.ts +29 -0
  261. package/src/specs/KeyboardControllerViewNativeComponent.ts +71 -0
  262. package/src/specs/KeyboardGestureAreaNativeComponent.ts +20 -0
  263. package/src/specs/NativeKeyboardController.ts +19 -0
  264. package/src/specs/NativeStatusBarManagerCompat.ts +14 -0
  265. package/src/specs/OverKeyboardViewNativeComponent.ts +12 -0
  266. package/src/types.ts +243 -0
  267. package/src/utils.ts +1 -0
  268. package/src/views/OverKeyboardView/index.tsx +43 -0
  269. package/src/views/index.ts +1 -0
@@ -0,0 +1,62 @@
1
+ import React, { useMemo } from "react";
2
+ import { Platform, TouchableNativeFeedback, TouchableOpacity, View } from "react-native";
3
+ import useColorScheme from "../hooks/useColorScheme";
4
+ const ButtonIOS = ({
5
+ children,
6
+ onPress,
7
+ disabled,
8
+ accessibilityLabel,
9
+ accessibilityHint,
10
+ testID,
11
+ style
12
+ }) => {
13
+ // immediately switch to plain view to avoid animation flickering
14
+ // when fade out animation happens and view becomes disabled
15
+ const Container = disabled ? View : TouchableOpacity;
16
+ const accessibilityState = useMemo(() => ({
17
+ disabled
18
+ }), [disabled]);
19
+ return /*#__PURE__*/React.createElement(Container, {
20
+ accessibilityState: accessibilityState,
21
+ accessibilityRole: "button",
22
+ accessibilityLabel: accessibilityLabel,
23
+ accessibilityHint: accessibilityHint,
24
+ onPress: onPress,
25
+ style: style,
26
+ testID: testID
27
+ }, children);
28
+ };
29
+ const ButtonAndroid = ({
30
+ children,
31
+ onPress,
32
+ disabled,
33
+ accessibilityLabel,
34
+ accessibilityHint,
35
+ testID,
36
+ rippleRadius = 18,
37
+ style,
38
+ theme
39
+ }) => {
40
+ const colorScheme = useColorScheme();
41
+ const accessibilityState = useMemo(() => ({
42
+ disabled
43
+ }), [disabled]);
44
+ const ripple = useMemo(() => TouchableNativeFeedback.Ripple(theme[colorScheme].ripple, true, rippleRadius), [colorScheme, rippleRadius, theme]);
45
+ return /*#__PURE__*/React.createElement(TouchableNativeFeedback, {
46
+ accessibilityState: accessibilityState,
47
+ accessibilityRole: "button",
48
+ accessibilityLabel: accessibilityLabel,
49
+ accessibilityHint: accessibilityHint,
50
+ onPress: onPress,
51
+ background: ripple,
52
+ testID: testID,
53
+ style: style
54
+ }, /*#__PURE__*/React.createElement(View, {
55
+ style: style
56
+ }, children));
57
+ };
58
+ export default Platform.select({
59
+ android: ButtonAndroid,
60
+ default: ButtonIOS
61
+ });
62
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useMemo","Platform","TouchableNativeFeedback","TouchableOpacity","View","useColorScheme","ButtonIOS","children","onPress","disabled","accessibilityLabel","accessibilityHint","testID","style","Container","accessibilityState","createElement","accessibilityRole","ButtonAndroid","rippleRadius","theme","colorScheme","ripple","Ripple","background","select","android","default"],"sources":["Button.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport {\n Platform,\n TouchableNativeFeedback,\n TouchableOpacity,\n View,\n} from \"react-native\";\n\nimport useColorScheme from \"../hooks/useColorScheme\";\n\nimport type { KeyboardToolbarTheme } from \"./types\";\nimport type { PropsWithChildren } from \"react\";\nimport type { ViewStyle } from \"react-native\";\n\ntype ButtonProps = {\n disabled?: boolean;\n onPress: () => void;\n accessibilityLabel: string;\n accessibilityHint: string;\n testID: string;\n rippleRadius?: number;\n style?: ViewStyle;\n theme: KeyboardToolbarTheme;\n};\n\nconst ButtonIOS = ({\n children,\n onPress,\n disabled,\n accessibilityLabel,\n accessibilityHint,\n testID,\n style,\n}: PropsWithChildren<ButtonProps>) => {\n // immediately switch to plain view to avoid animation flickering\n // when fade out animation happens and view becomes disabled\n const Container = disabled\n ? (View as unknown as typeof TouchableOpacity)\n : TouchableOpacity;\n const accessibilityState = useMemo(() => ({ disabled }), [disabled]);\n\n return (\n <Container\n accessibilityState={accessibilityState}\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n onPress={onPress}\n style={style}\n testID={testID}\n >\n {children}\n </Container>\n );\n};\nconst ButtonAndroid = ({\n children,\n onPress,\n disabled,\n accessibilityLabel,\n accessibilityHint,\n testID,\n rippleRadius = 18,\n style,\n theme,\n}: PropsWithChildren<ButtonProps>) => {\n const colorScheme = useColorScheme();\n const accessibilityState = useMemo(() => ({ disabled }), [disabled]);\n const ripple = useMemo(\n () =>\n TouchableNativeFeedback.Ripple(\n theme[colorScheme].ripple,\n true,\n rippleRadius,\n ),\n [colorScheme, rippleRadius, theme],\n );\n\n return (\n <TouchableNativeFeedback\n accessibilityState={accessibilityState}\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n onPress={onPress}\n background={ripple}\n testID={testID}\n style={style}\n >\n <View style={style}>{children}</View>\n </TouchableNativeFeedback>\n );\n};\n\nexport default Platform.select({\n android: ButtonAndroid,\n default: ButtonIOS,\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SACEC,QAAQ,EACRC,uBAAuB,EACvBC,gBAAgB,EAChBC,IAAI,QACC,cAAc;AAErB,OAAOC,cAAc,MAAM,yBAAyB;AAiBpD,MAAMC,SAAS,GAAGA,CAAC;EACjBC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,kBAAkB;EAClBC,iBAAiB;EACjBC,MAAM;EACNC;AAC8B,CAAC,KAAK;EACpC;EACA;EACA,MAAMC,SAAS,GAAGL,QAAQ,GACrBL,IAAI,GACLD,gBAAgB;EACpB,MAAMY,kBAAkB,GAAGf,OAAO,CAAC,OAAO;IAAES;EAAS,CAAC,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEpE,oBACEV,KAAA,CAAAiB,aAAA,CAACF,SAAS;IACRC,kBAAkB,EAAEA,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@ -0,0 +1,15 @@
1
+ export const colors = {
2
+ light: {
3
+ primary: "#2c2c2c",
4
+ disabled: "#B0BEC5",
5
+ background: "#f3f3f4",
6
+ ripple: "#bcbcbcbc"
7
+ },
8
+ dark: {
9
+ primary: "#fafafa",
10
+ disabled: "#707070",
11
+ background: "#2C2C2E",
12
+ ripple: "#F8F8F888"
13
+ }
14
+ };
15
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["colors","light","primary","disabled","background","ripple","dark"],"sources":["colors.ts"],"sourcesContent":["import type { KeyboardToolbarTheme } from \"./types\";\n\nexport const colors: KeyboardToolbarTheme = {\n light: {\n primary: \"#2c2c2c\",\n disabled: \"#B0BEC5\",\n background: \"#f3f3f4\",\n ripple: \"#bcbcbcbc\",\n },\n dark: {\n primary: \"#fafafa\",\n disabled: \"#707070\",\n background: \"#2C2C2E\",\n ripple: \"#F8F8F888\",\n },\n};\n"],"mappings":"AAEA,OAAO,MAAMA,MAA4B,GAAG;EAC1CC,KAAK,EAAE;IACLC,OAAO,EAAE,SAAS;IAClBC,QAAQ,EAAE,SAAS;IACnBC,UAAU,EAAE,SAAS;IACrBC,MAAM,EAAE;EACV,CAAC;EACDC,IAAI,EAAE;IACJJ,OAAO,EAAE,SAAS;IAClBC,QAAQ,EAAE,SAAS;IACnBC,UAAU,EAAE,SAAS;IACrBC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ import { Platform, PlatformColor } from "react-native";
2
+ export const colors = {
3
+ light: {
4
+ primary: Platform.select({
5
+ ios: PlatformColor("link"),
6
+ default: "#2c2c2c"
7
+ }),
8
+ disabled: Platform.select({
9
+ ios: PlatformColor("systemGray4"),
10
+ default: "#B0BEC5"
11
+ }),
12
+ background: Platform.select({
13
+ ios: "#F8F8F8",
14
+ default: "#f3f3f4"
15
+ }),
16
+ ripple: "#bcbcbcbc"
17
+ },
18
+ dark: {
19
+ primary: Platform.select({
20
+ ios: PlatformColor("label"),
21
+ default: "#fafafa"
22
+ }),
23
+ disabled: Platform.select({
24
+ ios: PlatformColor("systemGray"),
25
+ default: "#707070"
26
+ }),
27
+ background: Platform.select({
28
+ ios: "#555756",
29
+ default: "#2C2C2E"
30
+ }),
31
+ ripple: "#F8F8F888"
32
+ }
33
+ };
34
+ //# sourceMappingURL=colors.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","PlatformColor","colors","light","primary","select","ios","default","disabled","background","ripple","dark"],"sources":["colors.native.ts"],"sourcesContent":["import { Platform, PlatformColor } from \"react-native\";\n\nimport type { KeyboardToolbarTheme } from \"./types\";\nimport type { ColorValue } from \"react-native\";\n\nexport const colors: KeyboardToolbarTheme = {\n light: {\n primary: Platform.select<ColorValue>({\n ios: PlatformColor(\"link\"),\n default: \"#2c2c2c\",\n }),\n disabled: Platform.select<ColorValue>({\n ios: PlatformColor(\"systemGray4\"),\n default: \"#B0BEC5\",\n }),\n background: Platform.select({\n ios: \"#F8F8F8\",\n default: \"#f3f3f4\",\n }),\n ripple: \"#bcbcbcbc\",\n },\n dark: {\n primary: Platform.select<ColorValue>({\n ios: PlatformColor(\"label\"),\n default: \"#fafafa\",\n }),\n disabled: Platform.select<ColorValue>({\n ios: PlatformColor(\"systemGray\"),\n default: \"#707070\",\n }),\n background: Platform.select({\n ios: \"#555756\",\n default: \"#2C2C2E\",\n }),\n ripple: \"#F8F8F888\",\n },\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,aAAa,QAAQ,cAAc;AAKtD,OAAO,MAAMC,MAA4B,GAAG;EAC1CC,KAAK,EAAE;IACLC,OAAO,EAAEJ,QAAQ,CAACK,MAAM,CAAa;MACnCC,GAAG,EAAEL,aAAa,CAAC,MAAM,CAAC;MAC1BM,OAAO,EAAE;IACX,CAAC,CAAC;IACFC,QAAQ,EAAER,QAAQ,CAACK,MAAM,CAAa;MACpCC,GAAG,EAAEL,aAAa,CAAC,aAAa,CAAC;MACjCM,OAAO,EAAE;IACX,CAAC,CAAC;IACFE,UAAU,EAAET,QAAQ,CAACK,MAAM,CAAC;MAC1BC,GAAG,EAAE,SAAS;MACdC,OAAO,EAAE;IACX,CAAC,CAAC;IACFG,MAAM,EAAE;EACV,CAAC;EACDC,IAAI,EAAE;IACJP,OAAO,EAAEJ,QAAQ,CAACK,MAAM,CAAa;MACnCC,GAAG,EAAEL,aAAa,CAAC,OAAO,CAAC;MAC3BM,OAAO,EAAE;IACX,CAAC,CAAC;IACFC,QAAQ,EAAER,QAAQ,CAACK,MAAM,CAAa;MACpCC,GAAG,EAAEL,aAAa,CAAC,YAAY,CAAC;MAChCM,OAAO,EAAE;IACX,CAAC,CAAC;IACFE,UAAU,EAAET,QAAQ,CAACK,MAAM,CAAC;MAC1BC,GAAG,EAAE,SAAS;MACdC,OAAO,EAAE;IACX,CAAC,CAAC;IACFG,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,149 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
3
+ import { StyleSheet, Text, View } from "react-native";
4
+ import { FocusedInputEvents } from "../../bindings";
5
+ import KeyboardStickyView from "../KeyboardStickyView";
6
+ import { KeyboardControllerNative } from "../../bindings";
7
+ import useColorScheme from "../hooks/useColorScheme";
8
+ import Arrow from "./Arrow";
9
+ import Button from "./Button";
10
+ import { colors } from "./colors";
11
+ const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
12
+ const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;
13
+ const TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;
14
+ const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;
15
+ const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
16
+ const KEYBOARD_TOOLBAR_HEIGHT = 42;
17
+ const DEFAULT_OPACITY = "FF";
18
+ const dismissKeyboard = () => KeyboardControllerNative.dismiss(false);
19
+ const goToNextField = () => KeyboardControllerNative.setFocusTo("next");
20
+ const goToPrevField = () => KeyboardControllerNative.setFocusTo("prev");
21
+
22
+ /**
23
+ * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
24
+ * `Done` buttons.
25
+ */
26
+ const KeyboardToolbar = ({
27
+ content,
28
+ theme = colors,
29
+ doneText,
30
+ button,
31
+ icon,
32
+ showArrows = true,
33
+ onNextCallback,
34
+ onPrevCallback,
35
+ onDoneCallback,
36
+ blur = null,
37
+ opacity = DEFAULT_OPACITY,
38
+ offset: {
39
+ closed = 0,
40
+ opened = 0
41
+ } = {},
42
+ enabled = true,
43
+ ...rest
44
+ }) => {
45
+ const colorScheme = useColorScheme();
46
+ const [inputs, setInputs] = useState({
47
+ current: 0,
48
+ count: 0
49
+ });
50
+ const isPrevDisabled = inputs.current === 0;
51
+ const isNextDisabled = inputs.current === inputs.count - 1;
52
+ useEffect(() => {
53
+ const subscription = FocusedInputEvents.addListener("focusDidSet", e => {
54
+ setInputs(e);
55
+ });
56
+ return subscription.remove;
57
+ }, []);
58
+ const doneStyle = useMemo(() => [styles.doneButton, {
59
+ color: theme[colorScheme].primary
60
+ }], [colorScheme, theme]);
61
+ const toolbarStyle = useMemo(() => [styles.toolbar, {
62
+ backgroundColor: `${theme[colorScheme].background}${opacity}`
63
+ }], [colorScheme, opacity, theme]);
64
+ const offset = useMemo(() => ({
65
+ closed: closed + KEYBOARD_TOOLBAR_HEIGHT,
66
+ opened
67
+ }), [closed, opened]);
68
+ const ButtonContainer = button || Button;
69
+ const IconContainer = icon || Arrow;
70
+ const onPressNext = useCallback(() => {
71
+ goToNextField();
72
+ onNextCallback === null || onNextCallback === void 0 || onNextCallback();
73
+ }, [onNextCallback]);
74
+ const onPressPrev = useCallback(() => {
75
+ goToPrevField();
76
+ onPrevCallback === null || onPrevCallback === void 0 || onPrevCallback();
77
+ }, [onPrevCallback]);
78
+ const onPressDone = useCallback(() => {
79
+ dismissKeyboard();
80
+ onDoneCallback === null || onDoneCallback === void 0 || onDoneCallback();
81
+ }, [onDoneCallback]);
82
+ return /*#__PURE__*/React.createElement(KeyboardStickyView, {
83
+ enabled: enabled,
84
+ offset: offset
85
+ }, /*#__PURE__*/React.createElement(View, _extends({}, rest, {
86
+ style: toolbarStyle,
87
+ testID: TEST_ID_KEYBOARD_TOOLBAR
88
+ }), blur, showArrows && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ButtonContainer, {
89
+ accessibilityLabel: "Previous",
90
+ accessibilityHint: "Will move focus to previous field",
91
+ disabled: isPrevDisabled,
92
+ onPress: onPressPrev,
93
+ testID: TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,
94
+ theme: theme
95
+ }, /*#__PURE__*/React.createElement(IconContainer, {
96
+ disabled: isPrevDisabled,
97
+ type: "prev",
98
+ theme: theme
99
+ })), /*#__PURE__*/React.createElement(ButtonContainer, {
100
+ accessibilityLabel: "Next",
101
+ accessibilityHint: "Will move focus to next field",
102
+ disabled: isNextDisabled,
103
+ onPress: onPressNext,
104
+ testID: TEST_ID_KEYBOARD_TOOLBAR_NEXT,
105
+ theme: theme
106
+ }, /*#__PURE__*/React.createElement(IconContainer, {
107
+ disabled: isNextDisabled,
108
+ type: "next",
109
+ theme: theme
110
+ }))), /*#__PURE__*/React.createElement(View, {
111
+ style: styles.flex,
112
+ testID: TEST_ID_KEYBOARD_TOOLBAR_CONTENT
113
+ }, content), /*#__PURE__*/React.createElement(ButtonContainer, {
114
+ accessibilityLabel: "Done",
115
+ accessibilityHint: "Will close the keyboard",
116
+ onPress: onPressDone,
117
+ testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
118
+ rippleRadius: 28,
119
+ style: styles.doneButtonContainer,
120
+ theme: theme
121
+ }, /*#__PURE__*/React.createElement(Text, {
122
+ style: doneStyle,
123
+ maxFontSizeMultiplier: 1.3
124
+ }, doneText || "Done"))));
125
+ };
126
+ const styles = StyleSheet.create({
127
+ flex: {
128
+ flex: 1
129
+ },
130
+ toolbar: {
131
+ position: "absolute",
132
+ bottom: 0,
133
+ alignItems: "center",
134
+ width: "100%",
135
+ flexDirection: "row",
136
+ height: KEYBOARD_TOOLBAR_HEIGHT,
137
+ paddingHorizontal: 8
138
+ },
139
+ doneButton: {
140
+ fontWeight: "600",
141
+ fontSize: 15
142
+ },
143
+ doneButtonContainer: {
144
+ marginRight: 8
145
+ }
146
+ });
147
+ export { colors as DefaultKeyboardToolbarTheme };
148
+ export default KeyboardToolbar;
149
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardStickyView","KeyboardControllerNative","useColorScheme","Arrow","Button","colors","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","dismissKeyboard","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","rest","colorScheme","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","IconContainer","onPressNext","onPressPrev","onPressDone","createElement","_extends","style","testID","Fragment","accessibilityLabel","accessibilityHint","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport {\n FocusedInputEvents,\n} from \"../../bindings\";\nimport KeyboardStickyView from \"../KeyboardStickyView\"\nimport { KeyboardControllerNative } from \"../../bindings\";\nimport useColorScheme from \"../hooks/useColorScheme\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: () => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: () => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: () => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\n\nconst dismissKeyboard = () => KeyboardControllerNative.dismiss(false);\nconst goToNextField = () => KeyboardControllerNative.setFocusTo(\"next\");\nconst goToPrevField = () => KeyboardControllerNative.setFocusTo(\"prev\");\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText,\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n offset: { closed = 0, opened = 0 } = {},\n enabled = true,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const offset = useMemo(\n () => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),\n [closed, opened],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(() => {\n goToNextField();\n onNextCallback?.();\n }, [onNextCallback]);\n const onPressPrev = useCallback(() => {\n goToPrevField();\n onPrevCallback?.();\n }, [onPrevCallback]);\n const onPressDone = useCallback(() => {\n dismissKeyboard();\n onDoneCallback?.();\n }, [onDoneCallback]);\n\n return (\n <KeyboardStickyView enabled={enabled} offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityLabel=\"Previous\"\n accessibilityHint=\"Will move focus to previous field\"\n disabled={isPrevDisabled}\n onPress={onPressPrev}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n >\n <IconContainer\n disabled={isPrevDisabled}\n type=\"prev\"\n theme={theme}\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityLabel=\"Next\"\n accessibilityHint=\"Will move focus to next field\"\n disabled={isNextDisabled}\n onPress={onPressNext}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n >\n <IconContainer\n disabled={isNextDisabled}\n type=\"next\"\n theme={theme}\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityLabel=\"Done\"\n accessibilityHint=\"Will close the keyboard\"\n onPress={onPressDone}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n rippleRadius={28}\n style={styles.doneButtonContainer}\n theme={theme}\n >\n <Text style={doneStyle} maxFontSizeMultiplier={1.3}>\n {doneText || \"Done\"}\n </Text>\n </ButtonContainer>\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n paddingHorizontal: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACxE,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAErD,SACEC,kBAAkB,QACb,gBAAgB;AACvB,OAAOC,kBAAkB,MAAM,uBAAuB;AACtD,SAASC,wBAAwB,QAAQ,gBAAgB;AACzD,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AAgDjC,MAAMC,wBAAwB,GAAG,kBAAkB;AACnD,MAAMC,iCAAiC,GAAG,GAAGD,wBAAwB,WAAW;AAChF,MAAME,6BAA6B,GAAG,GAAGF,wBAAwB,OAAO;AACxE,MAAMG,gCAAgC,GAAG,GAAGH,wBAAwB,UAAU;AAC9E,MAAMI,6BAA6B,GAAG,GAAGJ,wBAAwB,OAAO;AAExE,MAAMK,uBAAuB,GAAG,EAAE;AAClC,MAAMC,eAAoB,GAAG,IAAI;AAEjC,MAAMC,eAAe,GAAGA,CAAA,KAAMZ,wBAAwB,CAACa,OAAO,CAAC,KAAK,CAAC;AACrE,MAAMC,aAAa,GAAGA,CAAA,KAAMd,wBAAwB,CAACe,UAAU,CAAC,MAAM,CAAC;AACvE,MAAMC,aAAa,GAAGA,CAAA,KAAMhB,wBAAwB,CAACe,UAAU,CAAC,MAAM,CAAC;;AAEvE;AACA;AACA;AACA;AACA,MAAME,eAA+C,GAAGA,CAAC;EACvDC,OAA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R,CAAC;EACDlB,OAAO,EAAE;IACPuB,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAErE,uBAAuB;IAC/BsE,iBAAiB,EAAE;EACrB,CAAC;EACDjC,UAAU,EAAE;IACVkC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDX,mBAAmB,EAAE;IACnBY,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,SAAS/E,MAAM,IAAIgF,2BAA2B;AAC9C,eAAenE,eAAe","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ColorValue } from \"react-native\";\n\ntype Theme = {\n /** Color for arrow when it's enabled */\n primary: ColorValue;\n /** Color for arrow when it's disabled */\n disabled: ColorValue;\n /** Keyboard toolbar background color */\n background: string;\n /** Color for ripple effect (on button touch) on Android */\n ripple: ColorValue;\n};\nexport type KeyboardToolbarTheme = {\n light: Theme;\n dark: Theme;\n};\ntype HexSymbol =\n | \"0\"\n | \"1\"\n | \"2\"\n | \"3\"\n | \"4\"\n | \"5\"\n | \"6\"\n | \"7\"\n | \"8\"\n | \"9\"\n | \"A\"\n | \"B\"\n | \"C\"\n | \"D\"\n | \"E\"\n | \"F\"\n | \"a\"\n | \"b\"\n | \"c\"\n | \"d\"\n | \"e\"\n | \"f\";\nexport type HEX = `${HexSymbol}${HexSymbol}`;\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { useColorScheme as useColorSchemeRN } from "react-native";
2
+ const useColorScheme = () => useColorSchemeRN() || "light";
3
+ export default useColorScheme;
4
+ //# sourceMappingURL=useColorScheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useColorScheme","useColorSchemeRN"],"sources":["useColorScheme.ts"],"sourcesContent":["import { useColorScheme as useColorSchemeRN } from \"react-native\";\n\nconst useColorScheme = () => useColorSchemeRN() || \"light\";\n\nexport default useColorScheme;\n"],"mappings":"AAAA,SAASA,cAAc,IAAIC,gBAAgB,QAAQ,cAAc;AAEjE,MAAMD,cAAc,GAAGA,CAAA,KAAMC,gBAAgB,CAAC,CAAC,IAAI,OAAO;AAE1D,eAAeD,cAAc","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export { default as KeyboardAvoidingView } from "./KeyboardAvoidingView";
2
+ export { default as KeyboardStickyView } from "./KeyboardStickyView";
3
+ export { default as KeyboardAwareScrollView } from "./KeyboardAwareScrollView";
4
+ export { default as KeyboardToolbar, DefaultKeyboardToolbarTheme } from "./KeyboardToolbar";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme"],"sources":["index.ts"],"sourcesContent":["export { default as KeyboardAvoidingView } from \"./KeyboardAvoidingView\";\nexport { default as KeyboardStickyView } from \"./KeyboardStickyView\";\nexport { default as KeyboardAwareScrollView } from \"./KeyboardAwareScrollView\";\nexport {\n default as KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./KeyboardToolbar\";\nexport type { KeyboardAvoidingViewProps } from \"./KeyboardAvoidingView\";\nexport type { KeyboardStickyViewProps } from \"./KeyboardStickyView\";\nexport type { KeyboardAwareScrollViewProps } from \"./KeyboardAwareScrollView\";\nexport type { KeyboardToolbarProps } from \"./KeyboardToolbar\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,oBAAoB,QAAQ,wBAAwB;AACxE,SAASD,OAAO,IAAIE,kBAAkB,QAAQ,sBAAsB;AACpE,SAASF,OAAO,IAAIG,uBAAuB,QAAQ,2BAA2B;AAC9E,SACEH,OAAO,IAAII,eAAe,EAC1BC,2BAA2B,QACtB,mBAAmB","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ // copied from `android.view.WindowManager.LayoutParams`
2
+ export let AndroidSoftInputModes = /*#__PURE__*/function (AndroidSoftInputModes) {
3
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_NOTHING"] = 48] = "SOFT_INPUT_ADJUST_NOTHING";
4
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_PAN"] = 32] = "SOFT_INPUT_ADJUST_PAN";
5
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_RESIZE"] = 16] = "SOFT_INPUT_ADJUST_RESIZE";
6
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_UNSPECIFIED"] = 0] = "SOFT_INPUT_ADJUST_UNSPECIFIED";
7
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_IS_FORWARD_NAVIGATION"] = 256] = "SOFT_INPUT_IS_FORWARD_NAVIGATION";
8
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_ADJUST"] = 240] = "SOFT_INPUT_MASK_ADJUST";
9
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_STATE"] = 15] = "SOFT_INPUT_MASK_STATE";
10
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MODE_CHANGED"] = 512] = "SOFT_INPUT_MODE_CHANGED";
11
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_HIDDEN"] = 3] = "SOFT_INPUT_STATE_ALWAYS_HIDDEN";
12
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_VISIBLE"] = 5] = "SOFT_INPUT_STATE_ALWAYS_VISIBLE";
13
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_HIDDEN"] = 2] = "SOFT_INPUT_STATE_HIDDEN";
14
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNCHANGED"] = 1] = "SOFT_INPUT_STATE_UNCHANGED";
15
+ // temporarily disable this rule to avoid breaking changes.
16
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
17
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNSPECIFIED"] = 0] = "SOFT_INPUT_STATE_UNSPECIFIED";
18
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_VISIBLE"] = 4] = "SOFT_INPUT_STATE_VISIBLE";
19
+ return AndroidSoftInputModes;
20
+ }({});
21
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AndroidSoftInputModes"],"sources":["constants.ts"],"sourcesContent":["// copied from `android.view.WindowManager.LayoutParams`\nexport enum AndroidSoftInputModes {\n SOFT_INPUT_ADJUST_NOTHING = 48,\n SOFT_INPUT_ADJUST_PAN = 32,\n SOFT_INPUT_ADJUST_RESIZE = 16,\n SOFT_INPUT_ADJUST_UNSPECIFIED = 0,\n SOFT_INPUT_IS_FORWARD_NAVIGATION = 256,\n SOFT_INPUT_MASK_ADJUST = 240,\n SOFT_INPUT_MASK_STATE = 15,\n SOFT_INPUT_MODE_CHANGED = 512,\n SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3,\n SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5,\n SOFT_INPUT_STATE_HIDDEN = 2,\n SOFT_INPUT_STATE_UNCHANGED = 1,\n // temporarily disable this rule to avoid breaking changes.\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n SOFT_INPUT_STATE_UNSPECIFIED = 0,\n SOFT_INPUT_STATE_VISIBLE = 4,\n}\n"],"mappings":"AAAA;AACA,WAAYA,qBAAqB,0BAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAa/B;EACA;EAdUA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ import { createContext, useContext } from "react";
2
+ import { Animated } from "react-native";
3
+ const NOOP = () => {};
4
+ const NESTED_NOOP = () => NOOP;
5
+ const withSharedValue = value => ({
6
+ value,
7
+ addListener: NOOP,
8
+ removeListener: NOOP,
9
+ modify: NOOP,
10
+ get: () => value,
11
+ set: NOOP
12
+ });
13
+ const DEFAULT_SHARED_VALUE = withSharedValue(0);
14
+ const DEFAULT_LAYOUT = withSharedValue(null);
15
+ const defaultContext = {
16
+ enabled: true,
17
+ animated: {
18
+ progress: new Animated.Value(0),
19
+ height: new Animated.Value(0)
20
+ },
21
+ reanimated: {
22
+ progress: DEFAULT_SHARED_VALUE,
23
+ height: DEFAULT_SHARED_VALUE
24
+ },
25
+ layout: DEFAULT_LAYOUT,
26
+ setKeyboardHandlers: NESTED_NOOP,
27
+ setInputHandlers: NESTED_NOOP,
28
+ setEnabled: NOOP
29
+ };
30
+ export const KeyboardContext = /*#__PURE__*/createContext(defaultContext);
31
+ export const useKeyboardContext = () => {
32
+ const context = useContext(KeyboardContext);
33
+ if (__DEV__ && context === defaultContext) {
34
+ console.warn("Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.");
35
+ }
36
+ return context;
37
+ };
38
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","useContext","Animated","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","get","set","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","useKeyboardContext","context","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type {\n FocusedInputHandlers,\n FocusedInputLayoutChangedEvent,\n KeyboardHandlers,\n} from \"./types\";\nimport type React from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n enabled: boolean;\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n setKeyboardHandlers: (handlers: KeyboardHandlers) => void;\n setInputHandlers: (handlers: FocusedInputHandlers) => void;\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst NESTED_NOOP = () => NOOP;\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n get: () => value,\n set: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null,\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setKeyboardHandlers: NESTED_NOOP,\n setInputHandlers: NESTED_NOOP,\n setEnabled: NOOP,\n};\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\",\n );\n }\n\n return context;\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,QAAQ,QAAQ,cAAc;AA2BvC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,WAAW,GAAGA,CAAA,KAAMD,IAAI;AAC9B,MAAME,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEJ,IAAI;EACjBK,cAAc,EAAEL,IAAI;EACpBM,MAAM,EAAEN,IAAI;EACZO,GAAG,EAAEA,CAAA,KAAMJ,KAAK;EAChBK,GAAG,EAAER;AACP,CAAC,CAAC;AACF,MAAMS,oBAAoB,GAAGP,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMQ,cAAc,GAAGR,eAAe,CACpC,IACF,CAAC;AACD,MAAMS,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIf,QAAQ,CAACgB,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIjB,QAAQ,CAACgB,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVH,QAAQ,EAAEL,oBAAoB;IAC9BO,MAAM,EAAEP;EACV,CAAC;EACDS,MAAM,EAAER,cAAc;EACtBS,mBAAmB,EAAElB,WAAW;EAChCmB,gBAAgB,EAAEnB,WAAW;EAC7BoB,UAAU,EAAErB;AACd,CAAC;AACD,OAAO,MAAMsB,eAAe,gBAAGzB,aAAa,CAACc,cAAc,CAAC;AAC5D,OAAO,MAAMY,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAG1B,UAAU,CAACwB,eAAe,CAAC;EAC3C,IAAIG,OAAO,IAAID,OAAO,KAAKb,cAAc,EAAE;IACzCe,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ import { useEffect } from "react";
2
+ import { AndroidSoftInputModes } from "../constants";
3
+ import { useKeyboardContext } from "../context";
4
+ import { uuid } from "../utils";
5
+ import { KeyboardController } from "../module";
6
+ export const useResizeMode = () => {
7
+ useEffect(() => {
8
+ KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
9
+ return () => KeyboardController.setDefaultMode();
10
+ }, []);
11
+ };
12
+ export const useKeyboardAnimation = () => {
13
+ useResizeMode();
14
+ const context = useKeyboardContext();
15
+ return context.animated;
16
+ };
17
+ export const useReanimatedKeyboardAnimation = () => {
18
+ useResizeMode();
19
+ const context = useKeyboardContext();
20
+ return context.reanimated;
21
+ };
22
+ export function useGenericKeyboardHandler(handler, deps) {
23
+ const context = useKeyboardContext();
24
+ useEffect(() => {
25
+ const key = uuid();
26
+ context.setKeyboardHandlers({
27
+ [key]: handler
28
+ });
29
+ return () => {
30
+ context.setKeyboardHandlers({
31
+ [key]: undefined
32
+ });
33
+ };
34
+ }, deps);
35
+ }
36
+ export function useKeyboardHandler(handler, deps) {
37
+ useResizeMode();
38
+ useGenericKeyboardHandler(handler, deps);
39
+ }
40
+ export function useKeyboardController() {
41
+ const context = useKeyboardContext();
42
+ return {
43
+ setEnabled: context.setEnabled,
44
+ enabled: context.enabled
45
+ };
46
+ }
47
+ export function useReanimatedFocusedInput() {
48
+ const context = useKeyboardContext();
49
+ return {
50
+ input: context.layout
51
+ };
52
+ }
53
+ export function useFocusedInputHandler(handler, deps) {
54
+ const context = useKeyboardContext();
55
+ useEffect(() => {
56
+ const key = uuid();
57
+ context.setInputHandlers({
58
+ [key]: handler
59
+ });
60
+ return () => {
61
+ context.setInputHandlers({
62
+ [key]: undefined
63
+ });
64
+ };
65
+ }, deps);
66
+ }
67
+ export * from "./useWindowDimensions";
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","AndroidSoftInputModes","useKeyboardContext","uuid","KeyboardController","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","setKeyboardHandlers","undefined","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\nimport { uuid } from \"../utils\";\nimport { KeyboardController } from \"../module\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"../context\";\nimport type { FocusedInputHandler, KeyboardHandler } from \"../types\";\nimport type { DependencyList } from \"react\";\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE,\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useEffect(() => {\n const key = uuid();\n\n context.setKeyboardHandlers({ [key]: handler });\n\n return () => {\n context.setKeyboardHandlers({ [key]: undefined });\n };\n }, deps);\n}\n\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n\nexport function useFocusedInputHandler(\n handler?: FocusedInputHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useEffect(() => {\n const key = uuid();\n\n context.setInputHandlers({ [key]: handler });\n\n return () => {\n context.setInputHandlers({ [key]: undefined });\n };\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,IAAI,QAAQ,UAAU;AAC/B,SAASC,kBAAkB,QAAQ,WAAW;AAM9C,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdI,kBAAkB,CAACE,YAAY,CAC7BL,qBAAqB,CAACM,wBACxB,CAAC;IAED,OAAO,MAAMH,kBAAkB,CAACI,cAAc,CAAC,CAAC;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAuB;EACzDJ,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGR,kBAAkB,CAAC,CAAC;EAEpC,OAAOQ,OAAO,CAACC,QAAQ;AACzB,CAAC;AAED,OAAO,MAAMC,8BAA8B,GAAGA,CAAA,KAAyB;EACrEP,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGR,kBAAkB,CAAC,CAAC;EAEpC,OAAOQ,OAAO,CAACG,UAAU;AAC3B,CAAC;AAED,OAAO,SAASC,yBAAyBA,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGR,kBAAkB,CAAC,CAAC;EAEpCF,SAAS,CAAC,MAAM;IACd,MAAMiB,GAAG,GAAGd,IAAI,CAAC,CAAC;IAElBO,OAAO,CAACQ,mBAAmB,CAAC;MAAE,CAACD,GAAG,GAAGF;IAAQ,CAAC,CAAC;IAE/C,OAAO,MAAM;MACXL,OAAO,CAACQ,mBAAmB,CAAC;QAAE,CAACD,GAAG,GAAGE;MAAU,CAAC,CAAC;IACnD,CAAC;EACH,CAAC,EAAEH,IAAI,CAAC;AACV;AAEA,OAAO,SAASI,kBAAkBA,CAChCL,OAAwB,EACxBC,IAAqB,EACrB;EACAX,aAAa,CAAC,CAAC;EACfS,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;AAEA,OAAO,SAASK,qBAAqBA,CAAA,EAAG;EACtC,MAAMX,OAAO,GAAGR,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEoB,UAAU,EAAEZ,OAAO,CAACY,UAAU;IAAEC,OAAO,EAAEb,OAAO,CAACa;EAAQ,CAAC;AACrE;AAEA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMd,OAAO,GAAGR,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEuB,KAAK,EAAEf,OAAO,CAACgB;EAAO,CAAC;AAClC;AAEA,OAAO,SAASC,sBAAsBA,CACpCZ,OAA6B,EAC7BC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGR,kBAAkB,CAAC,CAAC;EAEpCF,SAAS,CAAC,MAAM;IACd,MAAMiB,GAAG,GAAGd,IAAI,CAAC,CAAC;IAElBO,OAAO,CAACkB,gBAAgB,CAAC;MAAE,CAACX,GAAG,GAAGF;IAAQ,CAAC,CAAC;IAE5C,OAAO,MAAM;MACXL,OAAO,CAACkB,gBAAgB,CAAC;QAAE,CAACX,GAAG,GAAGE;MAAU,CAAC,CAAC;IAChD,CAAC;EACH,CAAC,EAAEH,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ import { useEffect, useState } from "react";
2
+ import { WindowDimensionsEvents } from "../../bindings";
3
+ let initialDimensions = {
4
+ width: 0,
5
+ height: 0
6
+ };
7
+ WindowDimensionsEvents.addListener("windowDidResize", e => {
8
+ initialDimensions = e;
9
+ });
10
+ export const useWindowDimensions = () => {
11
+ const [dimensions, setDimensions] = useState(initialDimensions);
12
+ useEffect(() => {
13
+ const subscription = WindowDimensionsEvents.addListener("windowDidResize", e => {
14
+ setDimensions(e);
15
+ });
16
+
17
+ // we might have missed an update between reading a value in render and
18
+ // `addListener` in this handler, so we set it here. If there was
19
+ // no change, React will filter out this update as a no-op.
20
+ setDimensions(initialDimensions);
21
+ return () => {
22
+ subscription.remove();
23
+ };
24
+ }, []);
25
+ return dimensions;
26
+ };
27
+ //# sourceMappingURL=index.android.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","WindowDimensionsEvents","initialDimensions","width","height","addListener","e","useWindowDimensions","dimensions","setDimensions","subscription","remove"],"sources":["index.android.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { WindowDimensionsEvents } from \"../../bindings\";\n\nimport type { WindowDimensionsEventData } from \"../../types\";\n\nlet initialDimensions: WindowDimensionsEventData = {\n width: 0,\n height: 0,\n};\n\nWindowDimensionsEvents.addListener(\"windowDidResize\", (e) => {\n initialDimensions = e;\n});\n\nexport const useWindowDimensions = () => {\n const [dimensions, setDimensions] = useState(initialDimensions);\n\n useEffect(() => {\n const subscription = WindowDimensionsEvents.addListener(\n \"windowDidResize\",\n (e) => {\n setDimensions(e);\n },\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setDimensions(initialDimensions);\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return dimensions;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,sBAAsB,QAAQ,gBAAgB;AAIvD,IAAIC,iBAA4C,GAAG;EACjDC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACV,CAAC;AAEDH,sBAAsB,CAACI,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EAC3DJ,iBAAiB,GAAGI,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGT,QAAQ,CAACE,iBAAiB,CAAC;EAE/DH,SAAS,CAAC,MAAM;IACd,MAAMW,YAAY,GAAGT,sBAAsB,CAACI,WAAW,CACrD,iBAAiB,EAChBC,CAAC,IAAK;MACLG,aAAa,CAACH,CAAC,CAAC;IAClB,CACF,CAAC;;IAED;IACA;IACA;IACAG,aAAa,CAACP,iBAAiB,CAAC;IAEhC,OAAO,MAAM;MACXQ,YAAY,CAACC,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOH,UAAU;AACnB,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export { useWindowDimensions } from "react-native";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useWindowDimensions"],"sources":["index.ts"],"sourcesContent":["export { useWindowDimensions } from \"react-native\";\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ export * from "./bindings";
2
+ export * from "./animated";
3
+ export * from "./context";
4
+ export * from "./hooks";
5
+ export * from "./constants";
6
+ export * from "./module";
7
+ export * from "./types";
8
+ export { KeyboardAvoidingView, KeyboardStickyView, KeyboardAwareScrollView,
9
+ // keyboard toolbar
10
+ KeyboardToolbar, DefaultKeyboardToolbarTheme } from "./components";
11
+ export { OverKeyboardView } from "./views";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme","OverKeyboardView"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./module\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardToolbarProps,\n} from \"./components\";\nexport { OverKeyboardView } from \"./views\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc;AAOrB,SAASC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
@@ -0,0 +1,66 @@
1
+ import { useCallback, useRef } from "react";
2
+ import { Animated } from "react-native";
3
+ import { useSharedValue } from "react-native-reanimated";
4
+ /**
5
+ * Hook for storing worklet handlers (objects with keys, where values are worklets).
6
+ * Returns methods for setting handlers and broadcasting events in them.
7
+ *
8
+ * T is a generic that looks like:
9
+ * @example
10
+ * {
11
+ * onEvent: () => {},
12
+ * onEvent2: () => {},
13
+ * }
14
+ */
15
+ export function useSharedHandlers() {
16
+ const handlers = useSharedValue({});
17
+ const jsHandlers = useRef({});
18
+
19
+ // since js -> worklet -> js call is asynchronous, we can not write handlers
20
+ // straight into shared variable (using current shared value as a previous result),
21
+ // since there may be a race condition in a call, and closure may have out-of-dated
22
+ // values. As a result, some of handlers may be not written to "all handlers" object.
23
+ // Below we are writing all handlers to `ref` and afterwards synchronize them with
24
+ // shared value (since `refs` are not referring to actual value in worklets).
25
+ // This approach allow us to update synchronously handlers in js thread (and it assures,
26
+ // that it will have all of them) and then update them in worklet thread (calls are
27
+ // happening in FIFO order, so we will always have actual value).
28
+ const updateSharedHandlers = () => {
29
+ // eslint-disable-next-line react-compiler/react-compiler
30
+ handlers.value = jsHandlers.current;
31
+ };
32
+ const setHandlers = useCallback(handler => {
33
+ jsHandlers.current = {
34
+ ...jsHandlers.current,
35
+ ...handler
36
+ };
37
+ updateSharedHandlers();
38
+ }, []);
39
+ const broadcast = (type, event) => {
40
+ "worklet";
41
+
42
+ Object.keys(handlers.value).forEach(key => {
43
+ var _handlers$value$key, _handlers$value$key$t;
44
+ (_handlers$value$key = handlers.value[key]) === null || _handlers$value$key === void 0 || (_handlers$value$key$t = _handlers$value$key[type]) === null || _handlers$value$key$t === void 0 || _handlers$value$key$t.call(_handlers$value$key, event);
45
+ });
46
+ };
47
+ return [setHandlers, broadcast];
48
+ }
49
+
50
+ /**
51
+ * TS variant of `useAnimatedValue` hook which is added in RN 0.71
52
+ * A better alternative of storing animated values in refs, since
53
+ * it doesn't recreate a new `Animated.Value` object on every re-render
54
+ * and therefore consumes less memory. We can not use a variant from
55
+ * RN, since this library supports earlier versions of RN.
56
+ *
57
+ * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937
58
+ */
59
+ export function useAnimatedValue(initialValue, config) {
60
+ const ref = useRef(null);
61
+ if (ref.current == null) {
62
+ ref.current = new Animated.Value(initialValue, config);
63
+ }
64
+ return ref.current;
65
+ }
66
+ //# sourceMappingURL=internal.js.map