react-native-keyboard-controller 1.12.7 → 1.13.0

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 (145) hide show
  1. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +5 -0
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ReactContext.kt +13 -0
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +0 -10
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/Interpolator.kt +2 -1
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/IosInterpolator.kt +2 -1
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/LinearInterpolator.kt +1 -0
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +13 -8
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +71 -59
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +4 -0
  10. package/android/src/main/java/com/reactnativekeyboardcontroller/modal/ModalAttachedWatcher.kt +80 -0
  11. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/StatusBarManagerCompatModuleImpl.kt +6 -12
  12. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +31 -4
  13. package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +7 -0
  14. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +5 -0
  15. package/ios/extensions/UIView.swift +10 -0
  16. package/ios/observers/KeyboardMovementObserver.swift +7 -5
  17. package/ios/views/KeyboardControllerView.mm +30 -39
  18. package/lib/commonjs/animated.js +15 -30
  19. package/lib/commonjs/animated.js.map +1 -1
  20. package/lib/commonjs/bindings.js.map +1 -1
  21. package/lib/commonjs/bindings.native.js.map +1 -1
  22. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +2 -14
  23. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
  24. package/lib/commonjs/components/KeyboardAvoidingView/index.js +4 -4
  25. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  26. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +7 -6
  27. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  28. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  29. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
  30. package/lib/commonjs/components/KeyboardStickyView/index.js +2 -2
  31. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  32. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -2
  33. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
  34. package/lib/commonjs/components/KeyboardToolbar/Button.js +12 -12
  35. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
  36. package/lib/commonjs/components/KeyboardToolbar/index.js +33 -27
  37. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  38. package/lib/commonjs/components/index.js +2 -2
  39. package/lib/commonjs/components/index.js.map +1 -1
  40. package/lib/commonjs/context.js +3 -2
  41. package/lib/commonjs/context.js.map +1 -1
  42. package/lib/commonjs/event-handler.js +19 -0
  43. package/lib/commonjs/event-handler.js.map +1 -0
  44. package/lib/commonjs/event-handler.web.js +10 -0
  45. package/lib/commonjs/event-handler.web.js.map +1 -0
  46. package/lib/commonjs/event-mappings.js +9 -0
  47. package/lib/commonjs/event-mappings.js.map +1 -0
  48. package/lib/commonjs/hooks/index.js +8 -21
  49. package/lib/commonjs/hooks/index.js.map +1 -1
  50. package/lib/commonjs/hooks/useSyncEffect/index.js +37 -0
  51. package/lib/commonjs/hooks/useSyncEffect/index.js.map +1 -0
  52. package/lib/commonjs/internal.js +20 -44
  53. package/lib/commonjs/internal.js.map +1 -1
  54. package/lib/commonjs/monkey-patch.android.js +1 -1
  55. package/lib/commonjs/monkey-patch.android.js.map +1 -1
  56. package/lib/commonjs/monkey-patch.js.map +1 -1
  57. package/lib/commonjs/reanimated.js +1 -3
  58. package/lib/commonjs/reanimated.js.map +1 -1
  59. package/lib/commonjs/reanimated.native.js +1 -35
  60. package/lib/commonjs/reanimated.native.js.map +1 -1
  61. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +1 -1
  62. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  63. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +1 -1
  64. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  65. package/lib/commonjs/types.js.map +1 -1
  66. package/lib/module/animated.js +16 -32
  67. package/lib/module/animated.js.map +1 -1
  68. package/lib/module/bindings.js.map +1 -1
  69. package/lib/module/bindings.native.js.map +1 -1
  70. package/lib/module/components/KeyboardAvoidingView/hooks.js +2 -14
  71. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
  72. package/lib/module/components/KeyboardAvoidingView/index.js +3 -3
  73. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  74. package/lib/module/components/KeyboardAwareScrollView/index.js +6 -5
  75. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  76. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  77. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
  78. package/lib/module/components/KeyboardStickyView/index.js +1 -1
  79. package/lib/module/components/KeyboardToolbar/Button.js +10 -10
  80. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
  81. package/lib/module/components/KeyboardToolbar/index.js +31 -25
  82. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  83. package/lib/module/context.js +3 -2
  84. package/lib/module/context.js.map +1 -1
  85. package/lib/module/event-handler.js +13 -0
  86. package/lib/module/event-handler.js.map +1 -0
  87. package/lib/module/event-handler.web.js +5 -0
  88. package/lib/module/event-handler.web.js.map +1 -0
  89. package/lib/module/event-mappings.js +3 -0
  90. package/lib/module/event-mappings.js.map +1 -0
  91. package/lib/module/hooks/index.js +7 -21
  92. package/lib/module/hooks/index.js.map +1 -1
  93. package/lib/module/hooks/useSyncEffect/index.js +31 -0
  94. package/lib/module/hooks/useSyncEffect/index.js.map +1 -0
  95. package/lib/module/internal.js +21 -45
  96. package/lib/module/internal.js.map +1 -1
  97. package/lib/module/monkey-patch.js.map +1 -1
  98. package/lib/module/reanimated.js +0 -2
  99. package/lib/module/reanimated.js.map +1 -1
  100. package/lib/module/reanimated.native.js +0 -32
  101. package/lib/module/reanimated.native.js.map +1 -1
  102. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  103. package/lib/module/types.js.map +1 -1
  104. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
  105. package/lib/typescript/components/KeyboardToolbar/index.d.ts +4 -3
  106. package/lib/typescript/context.d.ts +3 -3
  107. package/lib/typescript/event-handler.d.ts +3 -0
  108. package/lib/typescript/event-mappings.d.ts +2 -0
  109. package/lib/typescript/hooks/index.d.ts +1 -1
  110. package/lib/typescript/hooks/useSyncEffect/index.d.ts +14 -0
  111. package/lib/typescript/internal.d.ts +5 -19
  112. package/lib/typescript/reanimated.d.ts +1 -3
  113. package/lib/typescript/reanimated.native.d.ts +1 -3
  114. package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +2 -1
  115. package/lib/typescript/types.d.ts +6 -0
  116. package/package.json +11 -7
  117. package/src/animated.tsx +20 -43
  118. package/src/bindings.native.ts +1 -0
  119. package/src/bindings.ts +1 -0
  120. package/src/components/KeyboardAvoidingView/hooks.ts +2 -13
  121. package/src/components/KeyboardAvoidingView/index.tsx +1 -1
  122. package/src/components/KeyboardAwareScrollView/index.tsx +8 -3
  123. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +1 -0
  124. package/src/components/KeyboardAwareScrollView/utils.ts +1 -0
  125. package/src/components/KeyboardToolbar/Button.tsx +11 -11
  126. package/src/components/KeyboardToolbar/index.tsx +45 -25
  127. package/src/context.ts +8 -6
  128. package/src/event-handler.js +15 -0
  129. package/src/event-handler.ts +8 -0
  130. package/src/event-handler.web.js +5 -0
  131. package/src/event-mappings.ts +14 -0
  132. package/src/hooks/index.ts +9 -16
  133. package/src/hooks/useSyncEffect/index.ts +36 -0
  134. package/src/internal.ts +34 -54
  135. package/src/monkey-patch.ts +1 -0
  136. package/src/reanimated.native.ts +0 -50
  137. package/src/reanimated.ts +1 -12
  138. package/src/specs/KeyboardGestureAreaNativeComponent.ts +5 -1
  139. package/src/types.ts +6 -0
  140. package/lib/commonjs/utils.js +0 -9
  141. package/lib/commonjs/utils.js.map +0 -1
  142. package/lib/module/utils.js +0 -2
  143. package/lib/module/utils.js.map +0 -1
  144. package/lib/typescript/utils.d.ts +0 -1
  145. package/src/utils.ts +0 -1
@@ -1 +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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,CAAAiB,aAAA,CAACZ,IAAI;IAACS,KAAK,EAAEA;EAAM,GAAEN,QAAe,CACb,CAAC;AAE9B,CAAC;AAED,eAAeN,QAAQ,CAACwB,MAAM,CAAC;EAC7BC,OAAO,EAAER,aAAa;EACtBS,OAAO,EAAErB;AACX,CAAC,CAAC","ignoreList":[]}
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 { GestureResponderEvent, ViewStyle } from \"react-native\";\n\ntype ButtonProps = {\n disabled?: boolean;\n onPress: (event: GestureResponderEvent) => 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 accessibilityHint={accessibilityHint}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"button\"\n accessibilityState={accessibilityState}\n style={style}\n testID={testID}\n onPress={onPress}\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 accessibilityHint={accessibilityHint}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"button\"\n accessibilityState={accessibilityState}\n background={ripple}\n style={style}\n testID={testID}\n onPress={onPress}\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;IACRH,iBAAiB,EAAEA,iBAAkB;IACrCD,kBAAkB,EAAEA,kBAAmB;IACvCO,iBAAiB,EAAC,QAAQ;IAC1BF,kBAAkB,EAAEA,kBAAmB;IACvCF,KAAK,EAAEA,KAAM;IACbD,MAAM,EAAEA,MAAO;IACfJ,OAAO,EAAEA;EAAQ,GAEhBD,QACQ,CAAC;AAEhB,CAAC;AACD,MAAMW,aAAa,GAAGA,CAAC;EACrBX,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,kBAAkB;EAClBC,iBAAiB;EACjBC,MAAM;EACNO,YAAY,GAAG,EAAE;EACjBN,KAAK;EACLO;AAC8B,CAAC,KAAK;EACpC,MAAMC,WAAW,GAAGhB,cAAc,CAAC,CAAC;EACpC,MAAMU,kBAAkB,GAAGf,OAAO,CAAC,OAAO;IAAES;EAAS,CAAC,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EACpE,MAAMa,MAAM,GAAGtB,OAAO,CACpB,MACEE,uBAAuB,CAACqB,MAAM,CAC5BH,KAAK,CAACC,WAAW,CAAC,CAACC,MAAM,EACzB,IAAI,EACJH,YACF,CAAC,EACH,CAACE,WAAW,EAAEF,YAAY,EAAEC,KAAK,CACnC,CAAC;EAED,oBACErB,KAAA,CAAAiB,aAAA,CAACd,uBAAuB;IACtBS,iBAAiB,EAAEA,iBAAkB;IACrCD,kBAAkB,EAAEA,kBAAmB;IACvCO,iBAAiB,EAAC,QAAQ;IAC1BF,kBAAkB,EAAEA,kBAAmB;IACvCS,UAAU,EAAEF,MAAO;IACnBT,KAAK,EAAEA,KAAM;IACbD,MAAM,EAAEA,MAAO;IACfJ,OAAO,EAAEA;EAAQ,gBAEjBT,KAAA,CAAAiB,aAAA,CAACZ,IAAI;IAACS,KAAK,EAAEA;EAAM,GAAEN,QAAe,CACb,CAAC;AAE9B,CAAC;AAED,eAAeN,QAAQ,CAACwB,MAAM,CAAC;EAC7BC,OAAO,EAAER,aAAa;EACtBS,OAAO,EAAErB;AACX,CAAC,CAAC","ignoreList":[]}
@@ -58,17 +58,23 @@ const KeyboardToolbar = ({
58
58
  }], [colorScheme, opacity, theme]);
59
59
  const ButtonContainer = button || Button;
60
60
  const IconContainer = icon || Arrow;
61
- const onPressNext = useCallback(() => {
62
- goToNextField();
63
- onNextCallback === null || onNextCallback === void 0 || onNextCallback();
61
+ const onPressNext = useCallback(event => {
62
+ onNextCallback === null || onNextCallback === void 0 || onNextCallback(event);
63
+ if (!event.isDefaultPrevented()) {
64
+ goToNextField();
65
+ }
64
66
  }, [onNextCallback]);
65
- const onPressPrev = useCallback(() => {
66
- goToPrevField();
67
- onPrevCallback === null || onPrevCallback === void 0 || onPrevCallback();
67
+ const onPressPrev = useCallback(event => {
68
+ onPrevCallback === null || onPrevCallback === void 0 || onPrevCallback(event);
69
+ if (!event.isDefaultPrevented()) {
70
+ goToPrevField();
71
+ }
68
72
  }, [onPrevCallback]);
69
- const onPressDone = useCallback(() => {
70
- dismissKeyboard();
71
- onDoneCallback === null || onDoneCallback === void 0 || onDoneCallback();
73
+ const onPressDone = useCallback(event => {
74
+ onDoneCallback === null || onDoneCallback === void 0 || onDoneCallback(event);
75
+ if (!event.isDefaultPrevented()) {
76
+ dismissKeyboard();
77
+ }
72
78
  }, [onDoneCallback]);
73
79
  return /*#__PURE__*/React.createElement(KeyboardStickyView, {
74
80
  offset: offset
@@ -76,41 +82,41 @@ const KeyboardToolbar = ({
76
82
  style: toolbarStyle,
77
83
  testID: TEST_ID_KEYBOARD_TOOLBAR
78
84
  }, blur, showArrows && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ButtonContainer, {
85
+ accessibilityHint: "Moves focus to the previous field",
79
86
  accessibilityLabel: "Previous",
80
- accessibilityHint: "Will move focus to previous field",
81
87
  disabled: isPrevDisabled,
82
- onPress: onPressPrev,
83
88
  testID: TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,
84
- theme: theme
89
+ theme: theme,
90
+ onPress: onPressPrev
85
91
  }, /*#__PURE__*/React.createElement(IconContainer, {
86
92
  disabled: isPrevDisabled,
87
- type: "prev",
88
- theme: theme
93
+ theme: theme,
94
+ type: "prev"
89
95
  })), /*#__PURE__*/React.createElement(ButtonContainer, {
96
+ accessibilityHint: "Moves focus to the next field",
90
97
  accessibilityLabel: "Next",
91
- accessibilityHint: "Will move focus to next field",
92
98
  disabled: isNextDisabled,
93
- onPress: onPressNext,
94
99
  testID: TEST_ID_KEYBOARD_TOOLBAR_NEXT,
95
- theme: theme
100
+ theme: theme,
101
+ onPress: onPressNext
96
102
  }, /*#__PURE__*/React.createElement(IconContainer, {
97
103
  disabled: isNextDisabled,
98
- type: "next",
99
- theme: theme
104
+ theme: theme,
105
+ type: "next"
100
106
  }))), /*#__PURE__*/React.createElement(View, {
101
107
  style: styles.flex,
102
108
  testID: TEST_ID_KEYBOARD_TOOLBAR_CONTENT
103
109
  }, content), /*#__PURE__*/React.createElement(ButtonContainer, {
110
+ accessibilityHint: "Closes the keyboard",
104
111
  accessibilityLabel: "Done",
105
- accessibilityHint: "Will close the keyboard",
106
- onPress: onPressDone,
107
- testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
108
112
  rippleRadius: 28,
109
113
  style: styles.doneButtonContainer,
110
- theme: theme
114
+ testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
115
+ theme: theme,
116
+ onPress: onPressDone
111
117
  }, /*#__PURE__*/React.createElement(Text, {
112
- style: doneStyle,
113
- maxFontSizeMultiplier: 1.3
118
+ maxFontSizeMultiplier: 1.3,
119
+ style: doneStyle
114
120
  }, doneText || "Done"))));
115
121
  };
116
122
  const styles = StyleSheet.create({
@@ -1 +1 @@
1
- {"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardStickyView","KeyboardController","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","offset","closed","dismissKeyboard","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","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","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 KeyboardStickyView,\n} from \"react-native-keyboard-controller\";\n\nimport { KeyboardController } 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 { ReactNode } from \"react\";\n\nexport type KeyboardToolbarProps = {\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};\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\";\nconst offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };\n\nconst dismissKeyboard = () => KeyboardController.dismiss();\nconst goToNextField = () => KeyboardController.setFocusTo(\"next\");\nconst goToPrevField = () => KeyboardController.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}) => {\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 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 offset={offset}>\n <View 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,EAClBC,kBAAkB,QACb,kCAAkC;AAEzC,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AA0CjC,MAAMC,wBAAwB,GAAG,kBAAkB;AACnD,MAAMC,iCAAiC,GAAI,GAAED,wBAAyB,WAAU;AAChF,MAAME,6BAA6B,GAAI,GAAEF,wBAAyB,OAAM;AACxE,MAAMG,gCAAgC,GAAI,GAAEH,wBAAyB,UAAS;AAC9E,MAAMI,6BAA6B,GAAI,GAAEJ,wBAAyB,OAAM;AAExE,MAAMK,uBAAuB,GAAG,EAAE;AAClC,MAAMC,eAAoB,GAAG,IAAI;AACjC,MAAMC,MAAM,GAAG;EAAEC,MAAM,EAAEH;AAAwB,CAAC;AAElD,MAAMI,eAAe,GAAGA,CAAA,KAAMd,kBAAkB,CAACe,OAAO,CAAC,CAAC;AAC1D,MAAMC,aAAa,GAAGA,CAAA,KAAMhB,kBAAkB,CAACiB,UAAU,CAAC,MAAM,CAAC;AACjE,MAAMC,aAAa,GAAGA,CAAA,KAAMlB,kBAAkB,CAACiB,UAAU,CAAC,MAAM,CAAC;;AAEjE;AACA;AACA;AACA;AACA,MAAME,eAA+C,GAAGA,CAAC;EACvDC,OAAO;EACPC,KAAK,GAAGjB,MAAM;EACdkB,QAAQ;EACRC,MAAM;E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AAe","ignoreList":[]}
1
+ {"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardStickyView","KeyboardController","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","offset","closed","dismissKeyboard","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","colorScheme","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","IconContainer","onPressNext","event","isDefaultPrevented","onPressPrev","onPressDone","createElement","style","testID","Fragment","accessibilityHint","accessibilityLabel","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 KeyboardStickyView,\n} from \"react-native-keyboard-controller\";\n\nimport { KeyboardController } 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 { ReactNode } from \"react\";\nimport type { GestureResponderEvent } from \"react-native\";\n\nexport type KeyboardToolbarProps = {\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?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => 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};\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\";\nconst offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };\n\nconst dismissKeyboard = () => KeyboardController.dismiss();\nconst goToNextField = () => KeyboardController.setFocusTo(\"next\");\nconst goToPrevField = () => KeyboardController.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}) => {\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 ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n goToNextField();\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n goToPrevField();\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n dismissKeyboard();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView offset={offset}>\n <View style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\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,EAClBC,kBAAkB,QACb,kCAAkC;AAEzC,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AA4CjC,MAAMC,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,EAAEpD;EAAiC,GAChEY,OACG,CAAC,eACP9B,KAAA,CAAAoE,aAAA,CAACP,eAAe;IACdW,iBAAiB,EAAC,qBAAqB;IACvCC,kBAAkB,EAAC,MAAM;IACzBK,YAAY,EAAE,EAAG;IACjBT,KAAK,EAAEhB,MAAM,CAAC0B,mBAAoB;IAClCT,MAAM,EAAEnD,6BAA8B;IACtCY,KAAK,EAAEA,KAAM;IACb4C,OAAO,EAAER;EAAY,gBAErBnE,KAAA,CAAAoE,aAAA,CAAC9D,IAAI;IAAC0E,qBAAqB,EAAE,GAAI;IAACX,KAAK,EAAEjB;EAAU,GAChDpB,QAAQ,IAAI,MACT,CACS,CACb,CACY,CAAC;AAEzB,CAAC;AAED,MAAMqB,MAAM,GAAGhD,UAAU,CAAC4E,MAAM,CAAC;EAC/BJ,IAAI,EAAE;IACJA,IAAI,EAAE;EACR,CAAC;EACDnB,OAAO,EAAE;IACPwB,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAEnE,uBAAuB;IAC/BoE,iBAAiB,EAAE;EACrB,CAAC;EACDlC,UAAU,EAAE;IACVmC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDX,mBAAmB,EAAE;IACnBY,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,SAAS7E,MAAM,IAAI8E,2BAA2B;AAC9C,eAAe/D,eAAe","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import { createContext, useContext } from "react";
2
2
  import { Animated } from "react-native";
3
3
  const NOOP = () => {};
4
+ const NESTED_NOOP = () => NOOP;
4
5
  const withSharedValue = value => ({
5
6
  value,
6
7
  addListener: NOOP,
@@ -20,8 +21,8 @@ const defaultContext = {
20
21
  height: DEFAULT_SHARED_VALUE
21
22
  },
22
23
  layout: DEFAULT_LAYOUT,
23
- setKeyboardHandlers: NOOP,
24
- setInputHandlers: NOOP,
24
+ setKeyboardHandlers: NESTED_NOOP,
25
+ setInputHandlers: NESTED_NOOP,
25
26
  setEnabled: NOOP
26
27
  };
27
28
  export const KeyboardContext = /*#__PURE__*/createContext(defaultContext);
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","useContext","Animated","NOOP","withSharedValue","value","addListener","removeListener","modify","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 withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: 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: NOOP,\n setInputHandlers: NOOP,\n setEnabled: NOOP,\n};\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\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,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEH,IAAI;EACjBI,cAAc,EAAEJ,IAAI;EACpBK,MAAM,EAAEL;AACV,CAAC,CAAC;AACF,MAAMM,oBAAoB,GAAGL,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMM,cAAc,GAAGN,eAAe,CACpC,IACF,CAAC;AACD,MAAMO,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIZ,QAAQ,CAACa,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAId,QAAQ,CAACa,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVH,QAAQ,EAAEL,oBAAoB;IAC9BO,MAAM,EAAEP;EACV,CAAC;EACDS,MAAM,EAAER,cAAc;EACtBS,mBAAmB,EAAEhB,IAAI;EACzBiB,gBAAgB,EAAEjB,IAAI;EACtBkB,UAAU,EAAElB;AACd,CAAC;AACD,OAAO,MAAMmB,eAAe,gBAAGtB,aAAa,CAACW,cAAc,CAAC;AAC5D,OAAO,MAAMY,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAGvB,UAAU,CAACqB,eAAe,CAAC;EAE3C,IAAIG,OAAO,IAAID,OAAO,KAAKb,cAAc,EAAE;IACzCe,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createContext","useContext","Animated","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","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 FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardHandler,\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: KeyboardHandler) => () => void;\n setInputHandlers: (handlers: FocusedInputHandler) => () => 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});\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};\n\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\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;AACV,CAAC,CAAC;AACF,MAAMO,oBAAoB,GAAGL,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMM,cAAc,GAAGN,eAAe,CACpC,IACF,CAAC;AACD,MAAMO,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIb,QAAQ,CAACc,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIf,QAAQ,CAACc,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVH,QAAQ,EAAEL,oBAAoB;IAC9BO,MAAM,EAAEP;EACV,CAAC;EACDS,MAAM,EAAER,cAAc;EACtBS,mBAAmB,EAAEhB,WAAW;EAChCiB,gBAAgB,EAAEjB,WAAW;EAC7BkB,UAAU,EAAEnB;AACd,CAAC;AAED,OAAO,MAAMoB,eAAe,gBAAGvB,aAAa,CAACY,cAAc,CAAC;AAC5D,OAAO,MAAMY,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAGxB,UAAU,CAACsB,eAAe,CAAC;EAE3C,IAAIG,OAAO,IAAID,OAAO,KAAKb,cAAc,EAAE;IACzCe,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ export {};
2
+ //# sourceMappingURL=event-handler.js.map-native-reanimated/src/core");
3
+ } catch (e1) {
4
+ try {
5
+ REACore = require("react-native-reanimated/src/reanimated2/core");
6
+ } catch (e2) {
7
+ console.warn("Failed to load REACore from both paths");
8
+ }
9
+ }
10
+ const registerEventHandler = REACore.registerEventHandler;
11
+ const unregisterEventHandler = REACore.unregisterEventHandler;
12
+ export { registerEventHandler, unregisterEventHandler };
13
+ //# sourceMappingURL=event-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["event-handler.ts"],"sourcesContent":["declare function registerEventHandler(\n handler: (event: never) => void,\n eventName: string,\n viewTag: number,\n): number;\ndeclare function unregisterEventHandler(id: number): void;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ const NOOP = () => {};
2
+ const registerEventHandler = NOOP;
3
+ const unregisterEventHandler = NOOP;
4
+ export { registerEventHandler, unregisterEventHandler };
5
+ //# sourceMappingURL=event-handler.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NOOP","registerEventHandler","unregisterEventHandler"],"sources":["event-handler.web.js"],"sourcesContent":["const NOOP = () => {};\nconst registerEventHandler = NOOP;\nconst unregisterEventHandler = NOOP;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":"AAAA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,oBAAoB,GAAGD,IAAI;AACjC,MAAME,sBAAsB,GAAGF,IAAI;AAEnC,SAASC,oBAAoB,EAAEC,sBAAsB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export const keyboardEventsMap = new Map([["onStart", "onKeyboardMoveStart"], ["onMove", "onKeyboardMove"], ["onEnd", "onKeyboardMoveEnd"], ["onInteractive", "onKeyboardMoveInteractive"]]);
2
+ export const focusedInputEventsMap = new Map([["onChangeText", "onFocusedInputTextChanged"], ["onSelectionChange", "onFocusedInputSelectionChanged"]]);
3
+ //# sourceMappingURL=event-mappings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["keyboardEventsMap","Map","focusedInputEventsMap"],"sources":["event-mappings.ts"],"sourcesContent":["import type { FocusedInputHandler, KeyboardHandler } from \"./types\";\n\nexport const keyboardEventsMap = new Map<keyof KeyboardHandler, string>([\n [\"onStart\", \"onKeyboardMoveStart\"],\n [\"onMove\", \"onKeyboardMove\"],\n [\"onEnd\", \"onKeyboardMoveEnd\"],\n [\"onInteractive\", \"onKeyboardMoveInteractive\"],\n]);\nexport const focusedInputEventsMap = new Map<keyof FocusedInputHandler, string>(\n [\n [\"onChangeText\", \"onFocusedInputTextChanged\"],\n [\"onSelectionChange\", \"onFocusedInputSelectionChanged\"],\n ],\n);\n"],"mappings":"AAEA,OAAO,MAAMA,iBAAiB,GAAG,IAAIC,GAAG,CAAgC,CACtE,CAAC,SAAS,EAAE,qBAAqB,CAAC,EAClC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,EAC5B,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAC9B,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAC/C,CAAC;AACF,OAAO,MAAMC,qBAAqB,GAAG,IAAID,GAAG,CAC1C,CACE,CAAC,cAAc,EAAE,2BAA2B,CAAC,EAC7C,CAAC,mBAAmB,EAAE,gCAAgC,CAAC,CAE3D,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { useEffect } from "react";
2
2
  import { KeyboardController } from "../bindings";
3
3
  import { AndroidSoftInputModes } from "../constants";
4
4
  import { useKeyboardContext } from "../context";
5
- import { uuid } from "../utils";
5
+ import useSyncEffect from "./useSyncEffect";
6
6
  export const useResizeMode = () => {
7
7
  useEffect(() => {
8
8
  KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
@@ -21,16 +21,9 @@ export const useReanimatedKeyboardAnimation = () => {
21
21
  };
22
22
  export function useGenericKeyboardHandler(handler, deps) {
23
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
- };
24
+ useSyncEffect(() => {
25
+ const cleanup = context.setKeyboardHandlers(handler);
26
+ return () => cleanup();
34
27
  }, deps);
35
28
  }
36
29
  export function useKeyboardHandler(handler, deps) {
@@ -52,16 +45,9 @@ export function useReanimatedFocusedInput() {
52
45
  }
53
46
  export function useFocusedInputHandler(handler, deps) {
54
47
  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
- };
48
+ useSyncEffect(() => {
49
+ const cleanup = context.setInputHandlers(handler);
50
+ return () => cleanup();
65
51
  }, deps);
66
52
  }
67
53
  export * from "./useWindowDimensions";
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","KeyboardController","AndroidSoftInputModes","useKeyboardContext","uuid","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 { KeyboardController } from \"../bindings\";\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\nimport { uuid } from \"../utils\";\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,kBAAkB,QAAQ,aAAa;AAChD,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,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U,EAAEZ,OAAO,CAACY,UAAU;IAAEC,OAAO,EAAEb,OAAO,CAACa;EAAQ,CAAC;AACrE;AAEA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMd,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEsB,KAAK,EAAEf,OAAO,CAACgB;EAAO,CAAC;AAClC;AAEA,OAAO,SAASC,sBAAsBA,CACpCZ,OAA6B,EAC7BC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCH,SAAS,CAAC,MAAM;IACd,MAAMiB,GAAG,GAAGb,IAAI,CAAC,CAAC;IAElBM,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":[]}
1
+ {"version":3,"names":["useEffect","KeyboardController","AndroidSoftInputModes","useKeyboardContext","useSyncEffect","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","cleanup","setKeyboardHandlers","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { KeyboardController } from \"../bindings\";\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\n\nimport useSyncEffect from \"./useSyncEffect\";\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 useSyncEffect(() => {\n const cleanup = context.setKeyboardHandlers(handler);\n\n return () => cleanup();\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 useSyncEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,kBAAkB,QAAQ,aAAa;AAChD,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAE/C,OAAOC,aAAa,MAAM,iBAAiB;AAM3C,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdC,kBAAkB,CAACK,YAAY,CAC7BJ,qBAAqB,CAACK,wBACxB,CAAC;IAED,OAAO,MAAMN,kBAAkB,CAACO,cAAc,CAAC,CAAC;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,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B,MAAMa,OAAO,GAAGP,OAAO,CAACiB,gBAAgB,CAACZ,OAAO,CAAC;IAEjD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ import { useEffect, useRef } from "react";
2
+ /**
3
+ * @description
4
+ * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.
5
+ *
6
+ * @param {effect} - imperative function
7
+ * @param {deps} - if present, effect will only activate if the values in the list change
8
+ *
9
+ * @author Kiryl Ziusko
10
+ * @since 1.13.0
11
+ * @version 1.0.0
12
+ */
13
+ const useSyncEffect = (effect, deps) => {
14
+ const cachedDeps = useRef(null);
15
+ const areDepsEqual = deps === null || deps === void 0 ? void 0 : deps.every((el, index) => cachedDeps.current && el === cachedDeps.current[index]);
16
+ const cleanupRef = useRef();
17
+ if (!areDepsEqual || !cachedDeps.current) {
18
+ var _cleanupRef$current;
19
+ (_cleanupRef$current = cleanupRef.current) === null || _cleanupRef$current === void 0 || _cleanupRef$current.call(cleanupRef);
20
+ cleanupRef.current = effect();
21
+ cachedDeps.current = deps;
22
+ }
23
+ useEffect(() => {
24
+ return () => {
25
+ var _cleanupRef$current2;
26
+ (_cleanupRef$current2 = cleanupRef.current) === null || _cleanupRef$current2 === void 0 || _cleanupRef$current2.call(cleanupRef);
27
+ };
28
+ }, []);
29
+ };
30
+ export default useSyncEffect;
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","useSyncEffect","effect","deps","cachedDeps","areDepsEqual","every","el","index","current","cleanupRef","_cleanupRef$current","call","_cleanupRef$current2"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nimport type { DependencyList } from \"react\";\n\n/**\n * @description\n * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.\n *\n * @param {effect} - imperative function\n * @param {deps} - if present, effect will only activate if the values in the list change\n *\n * @author Kiryl Ziusko\n * @since 1.13.0\n * @version 1.0.0\n */\nconst useSyncEffect: typeof useEffect = (effect, deps) => {\n const cachedDeps = useRef<DependencyList | undefined | null>(null);\n const areDepsEqual = deps?.every(\n (el, index) => cachedDeps.current && el === cachedDeps.current[index],\n );\n const cleanupRef = useRef<(() => void) | void>();\n\n if (!areDepsEqual || !cachedDeps.current) {\n cleanupRef.current?.();\n cleanupRef.current = effect();\n cachedDeps.current = deps;\n }\n\n useEffect(() => {\n return () => {\n cleanupRef.current?.();\n };\n }, []);\n};\n\nexport default useSyncEffect;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAIzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAA+B,GAAGA,CAACC,MAAM,EAAEC,IAAI,KAAK;EACxD,MAAMC,UAAU,GAAGJ,MAAM,CAAoC,IAAI,CAAC;EAClE,MAAMK,YAAY,GAAGF,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,KAAK,CAC9B,CAACC,EAAE,EAAEC,KAAK,KAAKJ,UAAU,CAACK,OAAO,IAAIF,EAAE,KAAKH,UAAU,CAACK,OAAO,CAACD,KAAK,CACtE,CAAC;EACD,MAAME,UAAU,GAAGV,MAAM,CAAsB,CAAC;EAEhD,IAAI,CAACK,YAAY,IAAI,CAACD,UAAU,CAACK,OAAO,EAAE;IAAA,IAAAE,mBAAA;IACxC,CAAAA,mBAAA,GAAAD,UAAU,CAACD,OAAO,cAAAE,mBAAA,eAAlBA,mBAAA,CAAAC,IAAA,CAAAF,UAAqB,CAAC;IACtBA,UAAU,CAACD,OAAO,GAAGP,MAAM,CAAC,CAAC;IAC7BE,UAAU,CAACK,OAAO,GAAGN,IAAI;EAC3B;EAEAJ,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MAAA,IAAAc,oBAAA;MACX,CAAAA,oBAAA,GAAAH,UAAU,CAACD,OAAO,cAAAI,oBAAA,eAAlBA,oBAAA,CAAAD,IAAA,CAAAF,UAAqB,CAAC;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAED,eAAeT,aAAa","ignoreList":[]}
@@ -1,50 +1,26 @@
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({});
1
+ import { useRef } from "react";
2
+ import { Animated, findNodeHandle } from "react-native";
3
+ import { registerEventHandler, unregisterEventHandler } from "./event-handler";
4
+ export function useEventHandlerRegistration(map, viewTagRef) {
5
+ const onRegisterHandler = handler => {
6
+ const viewTag = findNodeHandle(viewTagRef.current);
7
+ const ids = Object.keys(handler).map(handlerName => {
8
+ const eventName = map.get(handlerName);
9
+ const functionToCall = handler[handlerName];
10
+ if (eventName && viewTag) {
11
+ return registerEventHandler(event => {
12
+ "worklet";
18
13
 
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);
14
+ functionToCall === null || functionToCall === void 0 || functionToCall(event);
15
+ }, eventName, viewTag);
16
+ }
17
+ return null;
45
18
  });
19
+ return () => {
20
+ ids.forEach(id => id ? unregisterEventHandler(id) : null);
21
+ };
46
22
  };
47
- return [setHandlers, broadcast];
23
+ return onRegisterHandler;
48
24
  }
49
25
 
50
26
  /**
@@ -58,7 +34,7 @@ export function useSharedHandlers() {
58
34
  */
59
35
  export function useAnimatedValue(initialValue, config) {
60
36
  const ref = useRef(null);
61
- if (ref.current == null) {
37
+ if (ref.current === null) {
62
38
  ref.current = new Animated.Value(initialValue, config);
63
39
  }
64
40
  return ref.current;
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useRef","Animated","useSharedValue","useSharedHandlers","handlers","jsHandlers","updateSharedHandlers","value","current","setHandlers","handler","broadcast","type","event","Object","keys","forEach","key","_handlers$value$key","_handlers$value$key$t","call","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\nimport { Animated } from \"react-native\";\nimport { useSharedValue } from \"react-native-reanimated\";\n\nimport type { Handlers } from \"./types\";\n\ntype UntypedHandler = Record<string, (event: never) => void>;\ntype SharedHandlersReturnType<T extends UntypedHandler> = [\n (handler: Handlers<T>) => void,\n <K extends keyof T>(type: K, event: Parameters<T[K]>[0]) => void,\n];\n\n/**\n * Hook for storing worklet handlers (objects with keys, where values are worklets).\n * Returns methods for setting handlers and broadcasting events in them.\n *\n * T is a generic that looks like:\n * @example\n * {\n * onEvent: () => {},\n * onEvent2: () => {},\n * }\n */\nexport function useSharedHandlers<\n T extends UntypedHandler,\n>(): SharedHandlersReturnType<T> {\n const handlers = useSharedValue<Handlers<T>>({});\n const jsHandlers = useRef<Handlers<T>>({});\n\n // since js -> worklet -> js call is asynchronous, we can not write handlers\n // straight into shared variable (using current shared value as a previous result),\n // since there may be a race condition in a call, and closure may have out-of-dated\n // values. As a result, some of handlers may be not written to \"all handlers\" object.\n // Below we are writing all handlers to `ref` and afterwards synchronize them with\n // shared value (since `refs` are not referring to actual value in worklets).\n // This approach allow us to update synchronously handlers in js thread (and it assures,\n // that it will have all of them) and then update them in worklet thread (calls are\n // happening in FIFO order, so we will always have actual value).\n const updateSharedHandlers = () => {\n // eslint-disable-next-line react-compiler/react-compiler\n handlers.value = jsHandlers.current;\n };\n const setHandlers = useCallback((handler: Handlers<T>) => {\n jsHandlers.current = {\n ...jsHandlers.current,\n ...handler,\n };\n updateSharedHandlers();\n }, []);\n const broadcast = <K extends keyof T>(\n type: K,\n event: Parameters<T[K]>[0],\n ) => {\n \"worklet\";\n\n Object.keys(handlers.value).forEach((key) => {\n handlers.value[key]?.[type]?.(event);\n });\n };\n\n return [setHandlers, broadcast];\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current == null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,cAAc,QAAQ,yBAAyB;AAUxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AG,IAAIP,QAAQ,CAACwB,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAChB,OAAO;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["useRef","Animated","findNodeHandle","registerEventHandler","unregisterEventHandler","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","viewTag","current","ids","Object","keys","handlerName","eventName","get","functionToCall","event","forEach","id","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated, findNodeHandle } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\nexport function useEventHandlerRegistration<\n H extends Partial<Record<string, EventHandler>>,\n>(\n map: Map<keyof H, string>,\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: H) => {\n const viewTag = findNodeHandle(viewTagRef.current);\n const ids = Object.keys(handler).map((handlerName) => {\n const eventName = map.get(handlerName as keyof H);\n const functionToCall = handler[handlerName as keyof H];\n\n if (eventName && viewTag) {\n return registerEventHandler(\n (event: Parameters<NonNullable<H[keyof H]>>[0]) => {\n \"worklet\";\n\n functionToCall?.(event);\n },\n eventName,\n viewTag,\n );\n }\n\n return null;\n });\n\n return () => {\n ids.forEach((id) => (id ? unregisterEventHandler(id) : null));\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,QAAQ,EAAEC,cAAc,QAAQ,cAAc;AAEvD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAQ,iBAAiB;AAK9E,OAAO,SAASC,2BAA2BA,CAGzCC,GAAyB,EACzBC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAAU,IAAK;IACxC,MAAMC,OAAO,GAAGR,cAAc,CAACK,UAAU,CAACI,OAAO,CAAC;IAClD,MAAMC,GAAG,GAAGC,MAAM,CAACC,IAAI,CAACL,OAAO,CAAC,CAACH,GAAG,CAAES,WAAW,IAAK;MACpD,MAAMC,SAAS,GAAGV,GAAG,CAACW,GAAG,CAACF,WAAsB,CAAC;MACjD,MAAMG,cAAc,GAAGT,OAAO,CAACM,WAAW,CAAY;MAEtD,IAAIC,SAAS,IAAIN,OAAO,EAAE;QACxB,OAAOP,oBAAoB,CACxBgB,KAA6C,IAAK;UACjD,SAAS;;UAETD,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGC,KAAK,CAAC;QACzB,CAAC,EACDH,SAAS,EACTN,OACF,CAAC;MACH;MAEA,OAAO,IAAI;IACb,CAAC,CAAC;IAEF,OAAO,MAAM;MACXE,GAAG,CAACQ,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAGjB,sBAAsB,CAACiB,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOb,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASc,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAGzB,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAIyB,GAAG,CAACd,OAAO,KAAK,IAAI,EAAE;IACxBc,GAAG,CAACd,OAAO,GAAG,IAAIV,QAAQ,CAACyB,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACd,OAAO;AACpB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["NOOP","applyMonkeyPatch","revertMonkeyPatch"],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\nconst NOOP = () => {};\nexport const applyMonkeyPatch = NOOP;\nexport const revertMonkeyPatch = NOOP;\n"],"mappings":"AAAA;AACA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,OAAO,MAAMC,gBAAgB,GAAGD,IAAI;AACpC,OAAO,MAAME,iBAAiB,GAAGF,IAAI","ignoreList":[]}
1
+ {"version":3,"names":["NOOP","applyMonkeyPatch","revertMonkeyPatch"],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\nconst NOOP = () => {};\n\nexport const applyMonkeyPatch = NOOP;\nexport const revertMonkeyPatch = NOOP;\n"],"mappings":"AAAA;AACA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,MAAMC,gBAAgB,GAAGD,IAAI;AACpC,OAAO,MAAME,iBAAiB,GAAGF,IAAI","ignoreList":[]}
@@ -1,6 +1,4 @@
1
1
  const NOOP = () => () => {};
2
2
  export const useAnimatedKeyboardHandler = NOOP;
3
3
  export const useFocusedInputLayoutHandler = NOOP;
4
- export const useFocusedInputTextHandler = NOOP;
5
- export const useFocusedInputSelectionHandler = NOOP;
6
4
  //# sourceMappingURL=reanimated.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NOOP","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","useFocusedInputTextHandler","useFocusedInputSelectionHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type {\n EventWithName,\n FocusedInputLayoutChangedEvent,\n FocusedInputLayoutHandlerHook,\n FocusedInputSelectionChangedEvent,\n FocusedInputSelectionHandlerHook,\n FocusedInputTextChangedEvent,\n FocusedInputTextHandlerHook,\n KeyboardHandlerHook,\n NativeEvent,\n} from \"./types\";\n\nconst NOOP = () => () => {};\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = NOOP;\nexport const useFocusedInputLayoutHandler: FocusedInputLayoutHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = NOOP;\nexport const useFocusedInputTextHandler: FocusedInputTextHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputTextChangedEvent>\n> = NOOP;\nexport const useFocusedInputSelectionHandler: FocusedInputSelectionHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputSelectionChangedEvent>\n> = NOOP;\n"],"mappings":"AAYA,MAAMA,IAAI,GAAGA,CAAA,KAAM,MAAM,CAAC,CAAC;AAC3B,OAAO,MAAMC,0BAGZ,GAAGD,IAAI;AACR,OAAO,MAAME,4BAGZ,GAAGF,IAAI;AACR,OAAO,MAAMG,0BAGZ,GAAGH,IAAI;AACR,OAAO,MAAMI,+BAGZ,GAAGJ,IAAI","ignoreList":[]}
1
+ {"version":3,"names":["NOOP","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type {\n EventWithName,\n FocusedInputLayoutChangedEvent,\n FocusedInputLayoutHandlerHook,\n KeyboardHandlerHook,\n NativeEvent,\n} from \"./types\";\n\nconst NOOP = () => () => {};\n\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = NOOP;\nexport const useFocusedInputLayoutHandler: FocusedInputLayoutHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = NOOP;\n"],"mappings":"AAQA,MAAMA,IAAI,GAAGA,CAAA,KAAM,MAAM,CAAC,CAAC;AAE3B,OAAO,MAAMC,0BAGZ,GAAGD,IAAI;AACR,OAAO,MAAME,4BAGZ,GAAGF,IAAI","ignoreList":[]}
@@ -43,36 +43,4 @@ export const useFocusedInputLayoutHandler = (handlers, dependencies) => {
43
43
  }
44
44
  }, ["onFocusedInputLayoutChanged"], doDependenciesDiffer);
45
45
  };
46
- export const useFocusedInputTextHandler = (handlers, dependencies) => {
47
- const {
48
- context,
49
- doDependenciesDiffer
50
- } = useHandler(handlers, dependencies);
51
- return useEvent(event => {
52
- "worklet";
53
-
54
- const {
55
- onFocusedInputTextChanged
56
- } = handlers;
57
- if (onFocusedInputTextChanged && event.eventName.endsWith("onFocusedInputTextChanged")) {
58
- onFocusedInputTextChanged(event, context);
59
- }
60
- }, ["onFocusedInputTextChanged"], doDependenciesDiffer);
61
- };
62
- export const useFocusedInputSelectionHandler = (handlers, dependencies) => {
63
- const {
64
- context,
65
- doDependenciesDiffer
66
- } = useHandler(handlers, dependencies);
67
- return useEvent(event => {
68
- "worklet";
69
-
70
- const {
71
- onFocusedInputSelectionChanged
72
- } = handlers;
73
- if (onFocusedInputSelectionChanged && event.eventName.endsWith("onFocusedInputSelectionChanged")) {
74
- onFocusedInputSelectionChanged(event, context);
75
- }
76
- }, ["onFocusedInputSelectionChanged"], doDependenciesDiffer);
77
- };
78
46
  //# sourceMappingURL=reanimated.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","onKeyboardMoveInteractive","eventName","endsWith","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","useFocusedInputTextHandler","onFocusedInputTextChanged","useFocusedInputSelectionHandler","onFocusedInputSelectionChanged"],"sources":["reanimated.native.ts"],"sourcesContent":["import { useEvent, useHandler } from \"react-native-reanimated\";\n\nimport type {\n EventWithName,\n FocusedInputLayoutChangedEvent,\n FocusedInputLayoutHandlerHook,\n FocusedInputSelectionChangedEvent,\n FocusedInputSelectionHandlerHook,\n FocusedInputTextChangedEvent,\n FocusedInputTextHandlerHook,\n KeyboardHandlerHook,\n NativeEvent,\n} from \"./types\";\n\ntype EventContext = Record<string, unknown>;\n\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n EventContext,\n EventWithName<NativeEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n \"worklet\";\n const {\n onKeyboardMoveStart,\n onKeyboardMove,\n onKeyboardMoveEnd,\n onKeyboardMoveInteractive,\n } = handlers;\n\n if (\n onKeyboardMoveStart &&\n event.eventName.endsWith(\"onKeyboardMoveStart\")\n ) {\n onKeyboardMoveStart(event, context);\n }\n\n if (onKeyboardMove && event.eventName.endsWith(\"onKeyboardMove\")) {\n onKeyboardMove(event, context);\n }\n\n if (onKeyboardMoveEnd && event.eventName.endsWith(\"onKeyboardMoveEnd\")) {\n onKeyboardMoveEnd(event, context);\n }\n\n if (\n onKeyboardMoveInteractive &&\n event.eventName.endsWith(\"onKeyboardMoveInteractive\")\n ) {\n onKeyboardMoveInteractive(event, context);\n }\n },\n [\n \"onKeyboardMoveStart\",\n \"onKeyboardMove\",\n \"onKeyboardMoveEnd\",\n \"onKeyboardMoveInteractive\",\n ],\n doDependenciesDiffer,\n );\n};\n\nexport const useFocusedInputLayoutHandler: FocusedInputLayoutHandlerHook<\n EventContext,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n \"worklet\";\n const { onFocusedInputLayoutChanged } = handlers;\n\n if (\n onFocusedInputLayoutChanged &&\n event.eventName.endsWith(\"onFocusedInputLayoutChanged\")\n ) {\n onFocusedInputLayoutChanged(event, context);\n }\n },\n [\"onFocusedInputLayoutChanged\"],\n doDependenciesDiffer,\n );\n};\n\nexport const useFocusedInputTextHandler: FocusedInputTextHandlerHook<\n EventContext,\n EventWithName<FocusedInputTextChangedEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n \"worklet\";\n const { onFocusedInputTextChanged } = handlers;\n\n if (\n onFocusedInputTextChanged &&\n event.eventName.endsWith(\"onFocusedInputTextChanged\")\n ) {\n onFocusedInputTextChanged(event, context);\n }\n },\n [\"onFocusedInputTextChanged\"],\n doDependenciesDiffer,\n );\n};\n\nexport const useFocusedInputSelectionHandler: FocusedInputSelectionHandlerHook<\n EventContext,\n EventWithName<FocusedInputSelectionChangedEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n \"worklet\";\n const { onFocusedInputSelectionChanged } = handlers;\n\n if (\n onFocusedInputSelectionChanged &&\n event.eventName.endsWith(\"onFocusedInputSelectionChanged\")\n ) {\n onFocusedInputSelectionChanged(event, context);\n }\n },\n [\"onFocusedInputSelectionChanged\"],\n doDependenciesDiffer,\n );\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,UAAU,QAAQ,yBAAyB;AAgB9D,OAAO,MAAMC,0BAGZ,GAAGA,CAACC,QAAQ,EAAEC,YAAY,KAAK;EAC9B,MAAM;IAAEC,OAAO;IAAEC;EAAqB,CAAC,GAAGL,UAAU,CAACE,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAOJ,QAAQ,CACZO,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MACJC,mBAAmB;MACnBC,cAAc;MACdC,iBAAiB;MACjBC;IACF,CAAC,GAAGR,QAAQ;IAEZ,IACEK,mBAAmB,IACnBD,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,qBAAqB,CAAC,EAC/C;MACAL,mBAAmB,CAACD,KAAK,EAAEF,OAAO,CAAC;IACrC;IAEA,IAAII,cAAc,IAAIF,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;MAChEJ,cAAc,CAACF,KAAK,EAAEF,OAAO,CAAC;IAChC;IAEA,IAAIK,iBAA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C3C;EACF,CAAC,EACD,CAAC,2BAA2B,CAAC,EAC7BC,oBACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMY,+BAGZ,GAAGA,CAACf,QAAQ,EAAEC,YAAY,KAAK;EAC9B,MAAM;IAAEC,OAAO;IAAEC;EAAqB,CAAC,GAAGL,UAAU,CAACE,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAOJ,QAAQ,CACZO,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MAAEY;IAA+B,CAAC,GAAGhB,QAAQ;IAEnD,IACEgB,8BAA8B,IAC9BZ,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,gCAAgC,CAAC,EAC1D;MACAM,8BAA8B,CAACZ,KAAK,EAAEF,OAAO,CAAC;IAChD;EACF,CAAC,EACD,CAAC,gCAAgC,CAAC,EAClCC,oBACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","onKeyboardMoveInteractive","eventName","endsWith","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged"],"sources":["reanimated.native.ts"],"sourcesContent":["import { useEvent, useHandler } from \"react-native-reanimated\";\n\nimport type {\n EventWithName,\n FocusedInputLayoutChangedEvent,\n FocusedInputLayoutHandlerHook,\n KeyboardHandlerHook,\n NativeEvent,\n} from \"./types\";\n\ntype EventContext = Record<string, unknown>;\n\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n EventContext,\n EventWithName<NativeEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n \"worklet\";\n const {\n onKeyboardMoveStart,\n onKeyboardMove,\n onKeyboardMoveEnd,\n onKeyboardMoveInteractive,\n } = handlers;\n\n if (\n onKeyboardMoveStart &&\n event.eventName.endsWith(\"onKeyboardMoveStart\")\n ) {\n onKeyboardMoveStart(event, context);\n }\n\n if (onKeyboardMove && event.eventName.endsWith(\"onKeyboardMove\")) {\n onKeyboardMove(event, context);\n }\n\n if (onKeyboardMoveEnd && event.eventName.endsWith(\"onKeyboardMoveEnd\")) {\n onKeyboardMoveEnd(event, context);\n }\n\n if (\n onKeyboardMoveInteractive &&\n event.eventName.endsWith(\"onKeyboardMoveInteractive\")\n ) {\n onKeyboardMoveInteractive(event, context);\n }\n },\n [\n \"onKeyboardMoveStart\",\n \"onKeyboardMove\",\n \"onKeyboardMoveEnd\",\n \"onKeyboardMoveInteractive\",\n ],\n doDependenciesDiffer,\n );\n};\n\nexport const useFocusedInputLayoutHandler: FocusedInputLayoutHandlerHook<\n EventContext,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n \"worklet\";\n const { onFocusedInputLayoutChanged } = handlers;\n\n if (\n onFocusedInputLayoutChanged &&\n event.eventName.endsWith(\"onFocusedInputLayoutChanged\")\n ) {\n onFocusedInputLayoutChanged(event, context);\n }\n },\n [\"onFocusedInputLayoutChanged\"],\n doDependenciesDiffer,\n );\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,UAAU,QAAQ,yBAAyB;AAY9D,OAAO,MAAMC,0BAGZ,GAAGA,CAACC,QAAQ,EAAEC,YAAY,KAAK;EAC9B,MAAM;IAAEC,OAAO;IAAEC;EAAqB,CAAC,GAAGL,UAAU,CAACE,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAOJ,QAAQ,CACZO,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MACJC,mBAAmB;MACnBC,cAAc;MACdC,iBAAiB;MACjBC;IACF,CAAC,GAAGR,QAAQ;IAEZ,IACEK,mBAAmB,IACnBD,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,qBAAqB,CAAC,EAC/C;MACAL,mBAAmB,CAACD,KAAK,EAAEF,OAAO,CAAC;IACrC;IAEA,IAAII,cAAc,IAAIF,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;MAChEJ,cAAc,CAACF,KAAK,EAAEF,OAAO,CAAC;IAChC;IAEA,IAAIK,iBAAiB,IAAIH,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;MACtEH,iBAAiB,CAACH,KAAK,EAAEF,OAAO,CAAC;IACnC;IAEA,IACEM,yBAAyB,IACzBJ,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,2BAA2B,CAAC,EACrD;MACAF,yBAAyB,CAACJ,KAAK,EAAEF,OAAO,CAAC;IAC3C;EACF,CAAC,EACD,CACE,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,2BAA2B,CAC5B,EACDC,oBACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMQ,4BAGZ,GAAGA,CAACX,QAAQ,EAAEC,YAAY,KAAK;EAC9B,MAAM;IAAEC,OAAO;IAAEC;EAAqB,CAAC,GAAGL,UAAU,CAACE,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAOJ,QAAQ,CACZO,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MAAEQ;IAA4B,CAAC,GAAGZ,QAAQ;IAEhD,IACEY,2BAA2B,IAC3BR,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,6BAA6B,CAAC,EACvD;MACAE,2BAA2B,CAACR,KAAK,EAAEF,OAAO,CAAC;IAC7C;EACF,CAAC,EACD,CAAC,6BAA6B,CAAC,EAC/BC,oBACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["codegenNativeComponent","excludedPlatforms"],"sources":["KeyboardGestureAreaNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\nimport type { WithDefault } from \"react-native/Libraries/Types/CodegenTypes\";\n\nexport interface NativeProps extends ViewProps {\n interpolator?: WithDefault<\"linear\" | \"ios\", \"linear\">;\n showOnSwipeUp?: boolean;\n enableSwipeToDismiss?: boolean;\n}\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardGestureArea\", {\n excludedPlatforms: [\"iOS\"],\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAY5F,eAAeA,sBAAsB,CAAc,qBAAqB,EAAE;EACxEC,iBAAiB,EAAE,CAAC,KAAK;AAC3B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["codegenNativeComponent","excludedPlatforms"],"sources":["KeyboardGestureAreaNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\nimport type {\n Double,\n WithDefault,\n} from \"react-native/Libraries/Types/CodegenTypes\";\n\nexport interface NativeProps extends ViewProps {\n interpolator?: WithDefault<\"linear\" | \"ios\", \"linear\">;\n showOnSwipeUp?: boolean;\n enableSwipeToDismiss?: boolean;\n offset?: Double;\n}\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardGestureArea\", {\n excludedPlatforms: [\"iOS\"],\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAgB5F,eAAeA,sBAAsB,CAAc,qBAAqB,EAAE;EACxEC,iBAAiB,EAAE,CAAC,KAAK;AAC3B,CAAC,CAAC","ignoreList":[]}