react-native-keyboard-controller 1.16.8 → 1.17.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.
- package/README.md +2 -8
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +11 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +17 -0
- package/android/src/main/jni/CMakeLists.txt +85 -0
- package/android/src/main/jni/reactnativekeyboardcontroller.h +23 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewComponentDescriptor.h +21 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewShadowNode.cpp +7 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewShadowNode.h +23 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewState.h +21 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaComponentDescriptor.h +20 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaShadowNode.cpp +7 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaShadowNode.h +23 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaState.h +21 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewComponentDescriptor.h +31 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewShadowNode.cpp +7 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewShadowNode.h +23 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewState.cpp +12 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewState.h +43 -0
- package/ios/KeyboardController-Bridging-Header.h +0 -1
- package/ios/objc/{RCTUITextView+DelegateManager.h → UITextView+DelegateManager.h} +2 -4
- package/ios/objc/{RCTUITextView+DelegateManager.m → UITextView+DelegateManager.m} +3 -3
- package/ios/observers/FocusedInputObserver.swift +2 -2
- package/ios/views/KeyboardControllerView.mm +1 -1
- package/ios/views/KeyboardGestureAreaManager.mm +1 -1
- package/ios/views/OverKeyboardViewManager.mm +1 -1
- package/jest/index.js +14 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +2 -2
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardStickyView/index.js +12 -12
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/hooks/index.js +12 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js +34 -0
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/commonjs/module.js +11 -4
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +3 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +3 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js +3 -1
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/views/OverKeyboardView/index.js +10 -4
- package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +2 -2
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardStickyView/index.js +13 -13
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js +27 -0
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/module/module.js +11 -4
- package/lib/module/module.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +3 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +3 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/specs/OverKeyboardViewNativeComponent.js +3 -1
- package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/views/OverKeyboardView/index.js +10 -4
- package/lib/module/views/OverKeyboardView/index.js.map +1 -1
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +2 -0
- package/lib/typescript/types.d.ts +4 -1
- package/package.json +4 -1
- package/react-native-keyboard-controller.podspec +8 -0
- package/react-native.config.js +14 -0
- package/src/components/KeyboardAvoidingView/index.tsx +14 -7
- package/src/components/KeyboardStickyView/index.tsx +18 -17
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useKeyboardState/index.ts +38 -0
- package/src/module.ts +11 -4
- package/src/specs/KeyboardControllerViewNativeComponent.ts +3 -3
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +3 -3
- package/src/specs/OverKeyboardViewNativeComponent.ts +3 -3
- package/src/types.ts +4 -1
- package/src/views/OverKeyboardView/index.tsx +11 -4
- package/lib/commonjs/architecture.js +0 -8
- package/lib/commonjs/architecture.js.map +0 -1
- package/lib/module/architecture.js +0 -2
- package/lib/module/architecture.js.map +0 -1
- package/lib/typescript/architecture.d.ts +0 -1
- package/src/architecture.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","AndroidSoftInputModes","useKeyboardContext","KeyboardController","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, useLayoutEffect } from \"react\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\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 useLayoutEffect(() => {\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 useLayoutEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAElD,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,kBAAkB,QAAQ,WAAW;AAM9C,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdI,kBAAkB,CAACE,YAAY,CAC7BJ,qBAAqB,CAACK,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,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACC,QAAQ;AACzB,CAAC;AAED,OAAO,MAAMC,8BAA8B,GAAGA,CAAA,KAAyB;EACrEP,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACG,UAAU;AAC3B,CAAC;AAED,OAAO,SAASC,yBAAyBA,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACQ,mBAAmB,CAACH,OAAO,CAAC;IAEpD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,OAAO,SAASG,kBAAkBA,CAChCJ,OAAwB,EACxBC,IAAqB,EACrB;EACAX,aAAa,CAAC,CAAC;EACfS,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;AAEA,OAAO,SAASI,qBAAqBA,CAAA,EAAG;EACtC,MAAMV,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEkB,UAAU,EAAEX,OAAO,CAACW,UAAU;IAAEC,OAAO,EAAEZ,OAAO,CAACY;EAAQ,CAAC;AACrE;AAEA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMb,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEqB,KAAK,EAAEd,OAAO,CAACe;EAAO,CAAC;AAClC;AAEA,OAAO,SAASC,sBAAsBA,CACpCX,OAA4B,EAC5BC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACiB,gBAAgB,CAACZ,OAAO,CAAC;IAEjD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","AndroidSoftInputModes","useKeyboardContext","KeyboardController","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, useLayoutEffect } from \"react\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\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 useLayoutEffect(() => {\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 useLayoutEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\nexport * from \"./useKeyboardState\";\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAElD,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,kBAAkB,QAAQ,WAAW;AAM9C,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdI,kBAAkB,CAACE,YAAY,CAC7BJ,qBAAqB,CAACK,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,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACC,QAAQ;AACzB,CAAC;AAED,OAAO,MAAMC,8BAA8B,GAAGA,CAAA,KAAyB;EACrEP,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACG,UAAU;AAC3B,CAAC;AAED,OAAO,SAASC,yBAAyBA,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACQ,mBAAmB,CAACH,OAAO,CAAC;IAEpD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,OAAO,SAASG,kBAAkBA,CAChCJ,OAAwB,EACxBC,IAAqB,EACrB;EACAX,aAAa,CAAC,CAAC;EACfS,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;AAEA,OAAO,SAASI,qBAAqBA,CAAA,EAAG;EACtC,MAAMV,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEkB,UAAU,EAAEX,OAAO,CAACW,UAAU;IAAEC,OAAO,EAAEZ,OAAO,CAACY;EAAQ,CAAC;AACrE;AAEA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMb,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEqB,KAAK,EAAEd,OAAO,CAACe;EAAO,CAAC;AAClC;AAEA,OAAO,SAASC,sBAAsBA,CACpCX,OAA4B,EAC5BC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACiB,gBAAgB,CAACZ,OAAO,CAAC;IAEjD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB;AACrC,cAAc,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { KeyboardEvents } from "../../bindings";
|
|
3
|
+
import { KeyboardController } from "../../module";
|
|
4
|
+
const EVENTS = ["keyboardDidShow", "keyboardDidHide"];
|
|
5
|
+
const getLatestState = () => ({
|
|
6
|
+
...KeyboardController.state(),
|
|
7
|
+
isVisible: KeyboardController.isVisible()
|
|
8
|
+
});
|
|
9
|
+
export const useKeyboardState = () => {
|
|
10
|
+
const [state, setState] = useState(getLatestState);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const subscriptions = EVENTS.map(event => KeyboardEvents.addListener(event, () =>
|
|
13
|
+
// state will be updated by global listener first,
|
|
14
|
+
// so we simply read it and don't derive data from the event
|
|
15
|
+
setState(getLatestState)));
|
|
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
|
+
setState(getLatestState);
|
|
21
|
+
return () => {
|
|
22
|
+
subscriptions.forEach(subscription => subscription.remove());
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
return state;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useState","KeyboardEvents","KeyboardController","EVENTS","getLatestState","state","isVisible","useKeyboardState","setState","subscriptions","map","event","addListener","forEach","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { KeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\nexport const useKeyboardState = (): KeyboardState => {\n const [state, setState] = useState(getLatestState);\n\n useEffect(() => {\n const subscriptions = EVENTS.map((event) =>\n KeyboardEvents.addListener(event, () =>\n // state will be updated by global listener first,\n // so we simply read it and don't derive data from the event\n setState(getLatestState),\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 setState(getLatestState);\n\n return () => {\n subscriptions.forEach((subscription) => subscription.remove());\n };\n }, []);\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,kBAAkB,QAAQ,cAAc;AAIjD,MAAMC,MAAM,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAU;AAE9D,MAAMC,cAAc,GAAGA,CAAA,MAAO;EAC5B,GAAGF,kBAAkB,CAACG,KAAK,CAAC,CAAC;EAC7BC,SAAS,EAAEJ,kBAAkB,CAACI,SAAS,CAAC;AAC1C,CAAC,CAAC;AAEF,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAqB;EACnD,MAAM,CAACF,KAAK,EAAEG,QAAQ,CAAC,GAAGR,QAAQ,CAACI,cAAc,CAAC;EAElDL,SAAS,CAAC,MAAM;IACd,MAAMU,aAAa,GAAGN,MAAM,CAACO,GAAG,CAAEC,KAAK,IACrCV,cAAc,CAACW,WAAW,CAACD,KAAK,EAAE;IAChC;IACA;IACAH,QAAQ,CAACJ,cAAc,CACzB,CACF,CAAC;;IAED;IACA;IACA;IACAI,QAAQ,CAACJ,cAAc,CAAC;IAExB,OAAO,MAAM;MACXK,aAAa,CAACI,OAAO,CAAEC,YAAY,IAAKA,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOV,KAAK;AACd,CAAC","ignoreList":[]}
|
package/lib/module/module.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { KeyboardControllerNative, KeyboardEvents } from "./bindings";
|
|
2
2
|
let isClosed = true;
|
|
3
|
-
let
|
|
3
|
+
let lastState = {
|
|
4
|
+
height: 0,
|
|
5
|
+
duration: 0,
|
|
6
|
+
timestamp: new Date().getTime(),
|
|
7
|
+
target: -1,
|
|
8
|
+
type: "default",
|
|
9
|
+
appearance: "default"
|
|
10
|
+
};
|
|
4
11
|
KeyboardEvents.addListener("keyboardDidHide", e => {
|
|
5
12
|
isClosed = true;
|
|
6
|
-
|
|
13
|
+
lastState = e;
|
|
7
14
|
});
|
|
8
15
|
KeyboardEvents.addListener("keyboardDidShow", e => {
|
|
9
16
|
isClosed = false;
|
|
10
|
-
|
|
17
|
+
lastState = e;
|
|
11
18
|
});
|
|
12
19
|
const dismiss = async options => {
|
|
13
20
|
const keepFocus = (options === null || options === void 0 ? void 0 : options.keepFocus) ?? false;
|
|
@@ -24,7 +31,7 @@ const dismiss = async options => {
|
|
|
24
31
|
});
|
|
25
32
|
};
|
|
26
33
|
const isVisible = () => !isClosed;
|
|
27
|
-
const state = () =>
|
|
34
|
+
const state = () => lastState;
|
|
28
35
|
export const KeyboardController = {
|
|
29
36
|
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
30
37
|
setInputMode: KeyboardControllerNative.setInputMode,
|
package/lib/module/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","
|
|
1
|
+
{"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed = true;\nlet lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"default\",\n};\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastState = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastState = e;\n});\n\nconst dismiss = async (options?: DismissOptions): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n\n return new Promise((resolve) => {\n if (isClosed) {\n resolve();\n\n return;\n }\n\n const subscription = KeyboardEvents.addListener(\"keyboardDidHide\", () => {\n resolve(undefined);\n subscription.remove();\n });\n\n KeyboardControllerNative.dismiss(keepFocus);\n });\n};\nconst isVisible = () => !isClosed;\nconst state = () => lastState;\n\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,cAAc,QAAQ,YAAY;AAQrE,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAA4B,GAAG;EACjCC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC/BC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE;AACd,CAAC;AAEDV,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEFZ,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAwB,IAAoB;EACjE,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAE7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIhB,QAAQ,EAAE;MACZgB,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGlB,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFrB,wBAAwB,CAACc,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMM,SAAS,GAAGA,CAAA,KAAM,CAACpB,QAAQ;AACjC,MAAMqB,KAAK,GAAGA,CAAA,KAAMpB,SAAS;AAE7B,OAAO,MAAMqB,kBAA4C,GAAG;EAC1DC,cAAc,EAAEzB,wBAAwB,CAACyB,cAAc;EACvDC,YAAY,EAAE1B,wBAAwB,CAAC0B,YAAY;EACnDC,UAAU,EAAE3B,wBAAwB,CAAC2B,UAAU;EAC/Cb,OAAO;EACPQ,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
-
export default codegenNativeComponent("KeyboardControllerView"
|
|
2
|
+
export default codegenNativeComponent("KeyboardControllerView", {
|
|
3
|
+
interfaceOnly: true
|
|
4
|
+
});
|
|
3
5
|
//# sourceMappingURL=KeyboardControllerViewNativeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.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 DirectEventHandler,\n Double,\n Int32,\n} from \"react-native/Libraries/Types/CodegenTypes\";\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\ntype FocusedInputLayoutChangedEvent = Readonly<{\n target: Int32;\n parentScrollViewTarget: Int32;\n layout: {\n x: Double;\n y: Double;\n width: Double;\n height: Double;\n absoluteX: Double;\n absoluteY: Double;\n };\n}>;\n\ntype FocusedInputTextChangedEvent = Readonly<{\n text: string;\n}>;\n\ntype FocusedInputSelectionChangedEvent = Readonly<{\n target: Int32;\n selection: {\n start: {\n x: Double;\n y: Double;\n position: Int32;\n };\n end: {\n x: Double;\n y: Double;\n position: Int32;\n };\n };\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n enabled?: boolean;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n preserveEdgeToEdge?: boolean;\n // callbacks\n /// keyboard\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n /// focused input\n onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;\n onFocusedInputTextChanged?: DirectEventHandler<FocusedInputTextChangedEvent>;\n onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent","interfaceOnly"],"sources":["KeyboardControllerViewNativeComponent.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 DirectEventHandler,\n Double,\n Int32,\n} from \"react-native/Libraries/Types/CodegenTypes\";\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\ntype FocusedInputLayoutChangedEvent = Readonly<{\n target: Int32;\n parentScrollViewTarget: Int32;\n layout: {\n x: Double;\n y: Double;\n width: Double;\n height: Double;\n absoluteX: Double;\n absoluteY: Double;\n };\n}>;\n\ntype FocusedInputTextChangedEvent = Readonly<{\n text: string;\n}>;\n\ntype FocusedInputSelectionChangedEvent = Readonly<{\n target: Int32;\n selection: {\n start: {\n x: Double;\n y: Double;\n position: Int32;\n };\n end: {\n x: Double;\n y: Double;\n position: Int32;\n };\n };\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n enabled?: boolean;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n preserveEdgeToEdge?: boolean;\n // callbacks\n /// keyboard\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n /// focused input\n onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;\n onFocusedInputTextChanged?: DirectEventHandler<FocusedInputTextChangedEvent>;\n onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardControllerView\", {\n interfaceOnly: true,\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAoE5F,eAAeA,sBAAsB,CAAc,wBAAwB,EAAE;EAC3EC,aAAa,EAAE;AACjB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
-
export default codegenNativeComponent("KeyboardGestureArea"
|
|
2
|
+
export default codegenNativeComponent("KeyboardGestureArea", {
|
|
3
|
+
interfaceOnly: true
|
|
4
|
+
});
|
|
3
5
|
//# sourceMappingURL=KeyboardGestureAreaNativeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"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 textInputNativeID?: string;\n}\n\nexport default codegenNativeComponent<NativeProps>(\
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent","interfaceOnly"],"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 textInputNativeID?: string;\n}\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardGestureArea\", {\n interfaceOnly: true,\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAiB5F,eAAeA,sBAAsB,CAAc,qBAAqB,EAAE;EACxEC,aAAa,EAAE;AACjB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
-
export default codegenNativeComponent("OverKeyboardView"
|
|
2
|
+
export default codegenNativeComponent("OverKeyboardView", {
|
|
3
|
+
interfaceOnly: true
|
|
4
|
+
});
|
|
3
5
|
//# sourceMappingURL=OverKeyboardViewNativeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["OverKeyboardViewNativeComponent.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\";\n\nexport interface NativeProps extends ViewProps {\n visible?: boolean;\n}\n\nexport default codegenNativeComponent<NativeProps>(\
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent","interfaceOnly"],"sources":["OverKeyboardViewNativeComponent.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\";\n\nexport interface NativeProps extends ViewProps {\n visible?: boolean;\n}\n\nexport default codegenNativeComponent<NativeProps>(\"OverKeyboardView\", {\n interfaceOnly: true,\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAS5F,eAAeA,sBAAsB,CAAc,kBAAkB,EAAE;EACrEC,aAAa,EAAE;AACjB,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type {\n EmitterSubscription,\n NativeSyntheticEvent,\n TextInputProps,\n ViewProps,\n} from \"react-native\";\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n progress: number;\n height: number;\n duration: number;\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n target: number;\n parentScrollViewTarget: number;\n layout: {\n x: number;\n y: number;\n width: number;\n height: number;\n absoluteX: number;\n absoluteY: number;\n };\n};\nexport type FocusedInputTextChangedEvent = {\n text: string;\n};\nexport type FocusedInputSelectionChangedEvent = {\n target: number;\n selection: {\n start: {\n x: number;\n y: number;\n position: number;\n };\n end: {\n x: number;\n y: number;\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n //ref prop\n ref?: React.Ref<React.Component<KeyboardControllerProps>>;\n // callback props\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // fake props used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n preserveEdgeToEdge?: boolean;\n enabled?: boolean;\n} & ViewProps;\n\nexport type KeyboardGestureAreaProps = {\n interpolator?: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n */\n enableSwipeToDismiss?: boolean;\n /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n /**\n * A corresponding `nativeID` value from the corresponding `TextInput`.\n */\n textInputNativeID?: string;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n keepFocus: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: (options?: DismissOptions) => Promise<void>;\n setFocusTo: (direction: Direction) => void;\n isVisible: () => boolean;\n state: () => KeyboardEventData
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type {\n EmitterSubscription,\n NativeSyntheticEvent,\n TextInputProps,\n ViewProps,\n} from \"react-native\";\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n progress: number;\n height: number;\n duration: number;\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n target: number;\n parentScrollViewTarget: number;\n layout: {\n x: number;\n y: number;\n width: number;\n height: number;\n absoluteX: number;\n absoluteY: number;\n };\n};\nexport type FocusedInputTextChangedEvent = {\n text: string;\n};\nexport type FocusedInputSelectionChangedEvent = {\n target: number;\n selection: {\n start: {\n x: number;\n y: number;\n position: number;\n };\n end: {\n x: number;\n y: number;\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n //ref prop\n ref?: React.Ref<React.Component<KeyboardControllerProps>>;\n // callback props\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // fake props used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n preserveEdgeToEdge?: boolean;\n enabled?: boolean;\n} & ViewProps;\n\nexport type KeyboardGestureAreaProps = {\n interpolator?: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n */\n enableSwipeToDismiss?: boolean;\n /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n /**\n * A corresponding `nativeID` value from the corresponding `TextInput`.\n */\n textInputNativeID?: string;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n keepFocus: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: (options?: DismissOptions) => Promise<void>;\n setFocusTo: (direction: Direction) => void;\n isVisible: () => boolean;\n state: () => KeyboardEventData;\n};\nexport type KeyboardControllerNativeModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: (keepFocus: boolean) => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n height: number;\n duration: number;\n timestamp: number;\n target: number;\n type: NonNullable<TextInputProps[\"keyboardType\"]>;\n appearance: NonNullable<TextInputProps[\"keyboardAppearance\"]>;\n};\nexport type KeyboardState = {\n isVisible: boolean;\n} & KeyboardEventData;\nexport type KeyboardEventsModule = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type FocusedInputAvailableEvents = \"focusDidSet\";\nexport type FocusedInputEventData = {\n current: number;\n count: number;\n};\nexport type FocusedInputEventsModule = {\n addListener: (\n name: FocusedInputAvailableEvents,\n cb: (e: FocusedInputEventData) => void,\n ) => EmitterSubscription;\n};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => void,\n ) => EmitterSubscription;\n};\n\n// reanimated hook declaration\nexport type KeyboardHandlerHook<TContext, Event> = (\n handlers: {\n onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputLayoutHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputLayoutChanged?: (\n e: FocusedInputLayoutChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputTextHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputTextChanged?: (\n e: FocusedInputTextChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputSelectionHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputSelectionChanged?: (\n e: FocusedInputSelectionChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\n\n// package types\nexport type Handlers<T> = Record<string, T | undefined>;\nexport type KeyboardHandler = Partial<{\n onStart: (e: NativeEvent) => void;\n onMove: (e: NativeEvent) => void;\n onEnd: (e: NativeEvent) => void;\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\nexport type FocusedInputHandler = Partial<{\n onChangeText: (e: FocusedInputTextChangedEvent) => void;\n onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import { Platform, StyleSheet, View } from "react-native";
|
|
3
|
-
import { IS_FABRIC } from "../../architecture";
|
|
4
3
|
import { RCTOverKeyboardView } from "../../bindings";
|
|
5
4
|
import { useWindowDimensions } from "../../hooks";
|
|
6
5
|
const OverKeyboardView = ({
|
|
@@ -17,18 +16,25 @@ const OverKeyboardView = ({
|
|
|
17
16
|
}), [height, width]);
|
|
18
17
|
const style = useMemo(() => [styles.absolute,
|
|
19
18
|
// On iOS - stretch view to full window dimensions to make yoga work
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
Platform.OS === "ios" ? inner : undefined,
|
|
20
|
+
// On Android - we are laid out by ShadowNode, so just stretch to full container
|
|
21
|
+
Platform.OS === "android" ? styles.stretch : undefined], [inner]);
|
|
22
22
|
return /*#__PURE__*/React.createElement(RCTOverKeyboardView, {
|
|
23
23
|
visible: visible
|
|
24
24
|
}, /*#__PURE__*/React.createElement(View, {
|
|
25
25
|
collapsable: false,
|
|
26
26
|
style: style
|
|
27
|
-
}, children));
|
|
27
|
+
}, visible && children));
|
|
28
28
|
};
|
|
29
29
|
const styles = StyleSheet.create({
|
|
30
30
|
absolute: {
|
|
31
31
|
position: "absolute"
|
|
32
|
+
},
|
|
33
|
+
stretch: {
|
|
34
|
+
top: 0,
|
|
35
|
+
bottom: 0,
|
|
36
|
+
left: 0,
|
|
37
|
+
right: 0
|
|
32
38
|
}
|
|
33
39
|
});
|
|
34
40
|
export default OverKeyboardView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","Platform","StyleSheet","View","
|
|
1
|
+
{"version":3,"names":["React","useMemo","Platform","StyleSheet","View","RCTOverKeyboardView","useWindowDimensions","OverKeyboardView","children","visible","height","width","inner","style","styles","absolute","OS","undefined","stretch","createElement","collapsable","create","position","top","bottom","left","right"],"sources":["index.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Platform, StyleSheet, View } from \"react-native\";\n\nimport { RCTOverKeyboardView } from \"../../bindings\";\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport type { OverKeyboardViewProps } from \"../../types\";\nimport type { PropsWithChildren } from \"react\";\n\nconst OverKeyboardView = ({\n children,\n visible,\n}: PropsWithChildren<OverKeyboardViewProps>) => {\n const { height, width } = useWindowDimensions();\n const inner = useMemo(() => ({ height, width }), [height, width]);\n const style = useMemo(\n () => [\n styles.absolute,\n // On iOS - stretch view to full window dimensions to make yoga work\n Platform.OS === \"ios\" ? inner : undefined,\n // On Android - we are laid out by ShadowNode, so just stretch to full container\n Platform.OS === \"android\" ? styles.stretch : undefined,\n ],\n [inner],\n );\n\n return (\n <RCTOverKeyboardView visible={visible}>\n {/* `OverKeyboardView` should always have a single child */}\n <View collapsable={false} style={style}>\n {/* Match RN behavior and trigger mount/unmount when visibility changes */}\n {visible && children}\n </View>\n </RCTOverKeyboardView>\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: \"absolute\",\n },\n stretch: {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n});\n\nexport default OverKeyboardView;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAEzD,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,mBAAmB,QAAQ,aAAa;AAKjD,MAAMC,gBAAgB,GAAGA,CAAC;EACxBC,QAAQ;EACRC;AACwC,CAAC,KAAK;EAC9C,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGL,mBAAmB,CAAC,CAAC;EAC/C,MAAMM,KAAK,GAAGX,OAAO,CAAC,OAAO;IAAES,MAAM;IAAEC;EAAM,CAAC,CAAC,EAAE,CAACD,MAAM,EAAEC,KAAK,CAAC,CAAC;EACjE,MAAME,KAAK,GAAGZ,OAAO,CACnB,MAAM,CACJa,MAAM,CAACC,QAAQ;EACf;EACAb,QAAQ,CAACc,EAAE,KAAK,KAAK,GAAGJ,KAAK,GAAGK,SAAS;EACzC;EACAf,QAAQ,CAACc,EAAE,KAAK,SAAS,GAAGF,MAAM,CAACI,OAAO,GAAGD,SAAS,CACvD,EACD,CAACL,KAAK,CACR,CAAC;EAED,oBACEZ,KAAA,CAAAmB,aAAA,CAACd,mBAAmB;IAACI,OAAO,EAAEA;EAAQ,gBAEpCT,KAAA,CAAAmB,aAAA,CAACf,IAAI;IAACgB,WAAW,EAAE,KAAM;IAACP,KAAK,EAAEA;EAAM,GAEpCJ,OAAO,IAAID,QACR,CACa,CAAC;AAE1B,CAAC;AAED,MAAMM,MAAM,GAAGX,UAAU,CAACkB,MAAM,CAAC;EAC/BN,QAAQ,EAAE;IACRO,QAAQ,EAAE;EACZ,CAAC;EACDJ,OAAO,EAAE;IACPK,GAAG,EAAE,CAAC;IACNC,MAAM,EAAE,CAAC;IACTC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE;EACT;AACF,CAAC,CAAC;AAEF,eAAenB,gBAAgB","ignoreList":[]}
|
|
@@ -92,7 +92,7 @@ export type KeyboardControllerModule = {
|
|
|
92
92
|
dismiss: (options?: DismissOptions) => Promise<void>;
|
|
93
93
|
setFocusTo: (direction: Direction) => void;
|
|
94
94
|
isVisible: () => boolean;
|
|
95
|
-
state: () => KeyboardEventData
|
|
95
|
+
state: () => KeyboardEventData;
|
|
96
96
|
};
|
|
97
97
|
export type KeyboardControllerNativeModule = {
|
|
98
98
|
setDefaultMode: () => void;
|
|
@@ -111,6 +111,9 @@ export type KeyboardEventData = {
|
|
|
111
111
|
type: NonNullable<TextInputProps["keyboardType"]>;
|
|
112
112
|
appearance: NonNullable<TextInputProps["keyboardAppearance"]>;
|
|
113
113
|
};
|
|
114
|
+
export type KeyboardState = {
|
|
115
|
+
isVisible: boolean;
|
|
116
|
+
} & KeyboardEventData;
|
|
114
117
|
export type KeyboardEventsModule = {
|
|
115
118
|
addListener: (name: KeyboardControllerEvents, cb: (e: KeyboardEventData) => void) => EmitterSubscription;
|
|
116
119
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-keyboard-controller",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Keyboard manager which works in identical way on both iOS and Android",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -12,10 +12,13 @@
|
|
|
12
12
|
"lib",
|
|
13
13
|
"android",
|
|
14
14
|
"ios",
|
|
15
|
+
"common",
|
|
15
16
|
"cpp",
|
|
16
17
|
"react-native-keyboard-controller.podspec",
|
|
18
|
+
"react-native.config.js",
|
|
17
19
|
"jest",
|
|
18
20
|
"!lib/typescript/example",
|
|
21
|
+
"!android/detekt.yml",
|
|
19
22
|
"!android/build",
|
|
20
23
|
"!android/src/test",
|
|
21
24
|
"!android/.gradle",
|
|
@@ -58,4 +58,12 @@ Pod::Spec.new do |s|
|
|
|
58
58
|
s.dependency "ReactCommon/turbomodule/core"
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
|
+
if new_arch_enabled
|
|
62
|
+
s.subspec "common" do |ss|
|
|
63
|
+
ss.source_files = ["common/cpp/**/*.{cpp,h}"]
|
|
64
|
+
ss.header_dir = "react/renderer/components/reactnativekeyboardcontroller"
|
|
65
|
+
ss.private_header_files = "common/cpp/**/*.{h}"
|
|
66
|
+
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
61
69
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dependency: {
|
|
3
|
+
platforms: {
|
|
4
|
+
android: {
|
|
5
|
+
componentDescriptors: [
|
|
6
|
+
"KeyboardControllerViewComponentDescriptor",
|
|
7
|
+
"KeyboardGestureAreaComponentDescriptor",
|
|
8
|
+
"OverKeyboardViewComponentDescriptor",
|
|
9
|
+
],
|
|
10
|
+
cmakeListsPath: "../android/src/main/jni/CMakeLists.txt",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -106,14 +106,21 @@ const KeyboardAvoidingView = forwardRef<
|
|
|
106
106
|
[relativeKeyboardHeight],
|
|
107
107
|
);
|
|
108
108
|
|
|
109
|
-
const onLayoutWorklet = useCallback(
|
|
110
|
-
|
|
109
|
+
const onLayoutWorklet = useCallback(
|
|
110
|
+
(layout: LayoutRectangle) => {
|
|
111
|
+
"worklet";
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
if (
|
|
114
|
+
keyboard.isClosed.value ||
|
|
115
|
+
initialFrame.value === null ||
|
|
116
|
+
behavior !== "height"
|
|
117
|
+
) {
|
|
118
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
119
|
+
initialFrame.value = layout;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
[behavior],
|
|
123
|
+
);
|
|
117
124
|
const onLayout = useCallback<NonNullable<ViewProps["onLayout"]>>(
|
|
118
125
|
(e) => {
|
|
119
126
|
runOnUI(onLayoutWorklet)(e.nativeEvent.layout);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, useMemo } from "react";
|
|
2
|
-
import
|
|
3
|
-
interpolate,
|
|
4
|
-
useAnimatedStyle,
|
|
5
|
-
} from "react-native-reanimated";
|
|
2
|
+
import { Animated } from "react-native";
|
|
6
3
|
|
|
7
|
-
import {
|
|
4
|
+
import { useKeyboardAnimation } from "../../hooks";
|
|
8
5
|
|
|
9
6
|
import type { View, ViewProps } from "react-native";
|
|
10
7
|
|
|
@@ -41,25 +38,29 @@ const KeyboardStickyView = forwardRef<
|
|
|
41
38
|
},
|
|
42
39
|
ref,
|
|
43
40
|
) => {
|
|
44
|
-
const { height, progress } =
|
|
41
|
+
const { height, progress } = useKeyboardAnimation();
|
|
45
42
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
transform: [{ translateY: enabled ? height.value + offset : closed }],
|
|
51
|
-
};
|
|
52
|
-
}, [closed, opened, enabled]);
|
|
43
|
+
const offset = progress.interpolate({
|
|
44
|
+
inputRange: [0, 1],
|
|
45
|
+
outputRange: [closed, opened],
|
|
46
|
+
});
|
|
53
47
|
|
|
54
48
|
const styles = useMemo(
|
|
55
|
-
() => [
|
|
56
|
-
|
|
49
|
+
() => [
|
|
50
|
+
{
|
|
51
|
+
transform: [
|
|
52
|
+
{ translateY: enabled ? Animated.add(height, offset) : closed },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
style,
|
|
56
|
+
],
|
|
57
|
+
[closed, enabled, height, offset, style],
|
|
57
58
|
);
|
|
58
59
|
|
|
59
60
|
return (
|
|
60
|
-
<
|
|
61
|
+
<Animated.View ref={ref} style={styles} {...props}>
|
|
61
62
|
{children}
|
|
62
|
-
</
|
|
63
|
+
</Animated.View>
|
|
63
64
|
);
|
|
64
65
|
},
|
|
65
66
|
);
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { KeyboardEvents } from "../../bindings";
|
|
4
|
+
import { KeyboardController } from "../../module";
|
|
5
|
+
|
|
6
|
+
import type { KeyboardState } from "../../types";
|
|
7
|
+
|
|
8
|
+
const EVENTS = ["keyboardDidShow", "keyboardDidHide"] as const;
|
|
9
|
+
|
|
10
|
+
const getLatestState = () => ({
|
|
11
|
+
...KeyboardController.state(),
|
|
12
|
+
isVisible: KeyboardController.isVisible(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const useKeyboardState = (): KeyboardState => {
|
|
16
|
+
const [state, setState] = useState(getLatestState);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const subscriptions = EVENTS.map((event) =>
|
|
20
|
+
KeyboardEvents.addListener(event, () =>
|
|
21
|
+
// state will be updated by global listener first,
|
|
22
|
+
// so we simply read it and don't derive data from the event
|
|
23
|
+
setState(getLatestState),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// we might have missed an update between reading a value in render and
|
|
28
|
+
// `addListener` in this handler, so we set it here. If there was
|
|
29
|
+
// no change, React will filter out this update as a no-op.
|
|
30
|
+
setState(getLatestState);
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
subscriptions.forEach((subscription) => subscription.remove());
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
return state;
|
|
38
|
+
};
|
package/src/module.ts
CHANGED
|
@@ -7,16 +7,23 @@ import type {
|
|
|
7
7
|
} from "./types";
|
|
8
8
|
|
|
9
9
|
let isClosed = true;
|
|
10
|
-
let
|
|
10
|
+
let lastState: KeyboardEventData = {
|
|
11
|
+
height: 0,
|
|
12
|
+
duration: 0,
|
|
13
|
+
timestamp: new Date().getTime(),
|
|
14
|
+
target: -1,
|
|
15
|
+
type: "default",
|
|
16
|
+
appearance: "default",
|
|
17
|
+
};
|
|
11
18
|
|
|
12
19
|
KeyboardEvents.addListener("keyboardDidHide", (e) => {
|
|
13
20
|
isClosed = true;
|
|
14
|
-
|
|
21
|
+
lastState = e;
|
|
15
22
|
});
|
|
16
23
|
|
|
17
24
|
KeyboardEvents.addListener("keyboardDidShow", (e) => {
|
|
18
25
|
isClosed = false;
|
|
19
|
-
|
|
26
|
+
lastState = e;
|
|
20
27
|
});
|
|
21
28
|
|
|
22
29
|
const dismiss = async (options?: DismissOptions): Promise<void> => {
|
|
@@ -38,7 +45,7 @@ const dismiss = async (options?: DismissOptions): Promise<void> => {
|
|
|
38
45
|
});
|
|
39
46
|
};
|
|
40
47
|
const isVisible = () => !isClosed;
|
|
41
|
-
const state = () =>
|
|
48
|
+
const state = () => lastState;
|
|
42
49
|
|
|
43
50
|
export const KeyboardController: KeyboardControllerModule = {
|
|
44
51
|
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
@@ -66,6 +66,6 @@ export interface NativeProps extends ViewProps {
|
|
|
66
66
|
onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export default codegenNativeComponent<NativeProps>(
|
|
70
|
-
|
|
71
|
-
) as HostComponent<NativeProps>;
|
|
69
|
+
export default codegenNativeComponent<NativeProps>("KeyboardControllerView", {
|
|
70
|
+
interfaceOnly: true,
|
|
71
|
+
}) as HostComponent<NativeProps>;
|
|
@@ -15,6 +15,6 @@ export interface NativeProps extends ViewProps {
|
|
|
15
15
|
textInputNativeID?: string;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export default codegenNativeComponent<NativeProps>(
|
|
19
|
-
|
|
20
|
-
) as HostComponent<NativeProps>;
|
|
18
|
+
export default codegenNativeComponent<NativeProps>("KeyboardGestureArea", {
|
|
19
|
+
interfaceOnly: true,
|
|
20
|
+
}) as HostComponent<NativeProps>;
|
|
@@ -7,6 +7,6 @@ export interface NativeProps extends ViewProps {
|
|
|
7
7
|
visible?: boolean;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export default codegenNativeComponent<NativeProps>(
|
|
11
|
-
|
|
12
|
-
) as HostComponent<NativeProps>;
|
|
10
|
+
export default codegenNativeComponent<NativeProps>("OverKeyboardView", {
|
|
11
|
+
interfaceOnly: true,
|
|
12
|
+
}) as HostComponent<NativeProps>;
|
package/src/types.ts
CHANGED
|
@@ -131,7 +131,7 @@ export type KeyboardControllerModule = {
|
|
|
131
131
|
dismiss: (options?: DismissOptions) => Promise<void>;
|
|
132
132
|
setFocusTo: (direction: Direction) => void;
|
|
133
133
|
isVisible: () => boolean;
|
|
134
|
-
state: () => KeyboardEventData
|
|
134
|
+
state: () => KeyboardEventData;
|
|
135
135
|
};
|
|
136
136
|
export type KeyboardControllerNativeModule = {
|
|
137
137
|
// android only
|
|
@@ -159,6 +159,9 @@ export type KeyboardEventData = {
|
|
|
159
159
|
type: NonNullable<TextInputProps["keyboardType"]>;
|
|
160
160
|
appearance: NonNullable<TextInputProps["keyboardAppearance"]>;
|
|
161
161
|
};
|
|
162
|
+
export type KeyboardState = {
|
|
163
|
+
isVisible: boolean;
|
|
164
|
+
} & KeyboardEventData;
|
|
162
165
|
export type KeyboardEventsModule = {
|
|
163
166
|
addListener: (
|
|
164
167
|
name: KeyboardControllerEvents,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import { Platform, StyleSheet, View } from "react-native";
|
|
3
3
|
|
|
4
|
-
import { IS_FABRIC } from "../../architecture";
|
|
5
4
|
import { RCTOverKeyboardView } from "../../bindings";
|
|
6
5
|
import { useWindowDimensions } from "../../hooks";
|
|
7
6
|
|
|
@@ -18,8 +17,9 @@ const OverKeyboardView = ({
|
|
|
18
17
|
() => [
|
|
19
18
|
styles.absolute,
|
|
20
19
|
// On iOS - stretch view to full window dimensions to make yoga work
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
Platform.OS === "ios" ? inner : undefined,
|
|
21
|
+
// On Android - we are laid out by ShadowNode, so just stretch to full container
|
|
22
|
+
Platform.OS === "android" ? styles.stretch : undefined,
|
|
23
23
|
],
|
|
24
24
|
[inner],
|
|
25
25
|
);
|
|
@@ -28,7 +28,8 @@ const OverKeyboardView = ({
|
|
|
28
28
|
<RCTOverKeyboardView visible={visible}>
|
|
29
29
|
{/* `OverKeyboardView` should always have a single child */}
|
|
30
30
|
<View collapsable={false} style={style}>
|
|
31
|
-
{
|
|
31
|
+
{/* Match RN behavior and trigger mount/unmount when visibility changes */}
|
|
32
|
+
{visible && children}
|
|
32
33
|
</View>
|
|
33
34
|
</RCTOverKeyboardView>
|
|
34
35
|
);
|
|
@@ -38,6 +39,12 @@ const styles = StyleSheet.create({
|
|
|
38
39
|
absolute: {
|
|
39
40
|
position: "absolute",
|
|
40
41
|
},
|
|
42
|
+
stretch: {
|
|
43
|
+
top: 0,
|
|
44
|
+
bottom: 0,
|
|
45
|
+
left: 0,
|
|
46
|
+
right: 0,
|
|
47
|
+
},
|
|
41
48
|
});
|
|
42
49
|
|
|
43
50
|
export default OverKeyboardView;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["IS_FABRIC","exports","global"],"sources":["architecture.ts"],"sourcesContent":["export const IS_FABRIC = \"nativeFabricUIManager\" in global;\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,uBAAuB,IAAIE,MAAM","ignoreList":[]}
|