react-native-keyboard-controller 1.13.3 → 1.14.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 +1 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -3
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +19 -20
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +22 -12
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +40 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +7 -3
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +33 -27
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputLayoutChangedEvent.kt +16 -15
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputSelectionChangedEvent.kt +25 -24
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputTextChangedEvent.kt +4 -3
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/KeyboardTransitionEvent.kt +7 -6
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/Context.kt +38 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +82 -62
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ReactContext.kt +9 -4
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +12 -5
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +12 -10
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/KeyboardAnimationController.kt +65 -60
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/Interpolator.kt +6 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/IosInterpolator.kt +4 -2
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/LinearInterpolator.kt +1 -3
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +62 -58
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +52 -46
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/WindowDimensionListener.kt +13 -7
- package/android/src/main/java/com/reactnativekeyboardcontroller/log/Logger.kt +28 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +35 -24
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +21 -8
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/OverKeyboardViewManagerImpl.kt +27 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modal/ModalAttachedWatcher.kt +15 -13
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +8 -8
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/StatusBarManagerCompatModuleImpl.kt +10 -5
- package/android/src/main/java/com/reactnativekeyboardcontroller/traversal/FocusedInputHolder.kt +1 -3
- package/android/src/main/java/com/reactnativekeyboardcontroller/traversal/ViewHierarchyNavigator.kt +19 -13
- package/android/src/main/java/com/reactnativekeyboardcontroller/ui/FrameScheduler.kt +11 -8
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +24 -19
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +23 -14
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardHostShadowNode.kt +30 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +185 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +3 -1
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +19 -10
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +21 -8
- package/android/src/paper/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +33 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +7 -3
- package/android/src/test/java/com/reactnativekeyboardcontroller/traversal/ViewHierarchyNavigatorTest.kt +30 -21
- package/ios/KeyboardController-Bridging-Header.h +1 -0
- package/ios/extensions/UIResponder.swift +0 -3
- package/ios/extensions/UIWindow.swift +48 -0
- package/ios/views/OverKeyboardViewManager.h +29 -0
- package/ios/views/OverKeyboardViewManager.mm +220 -0
- package/jest/index.js +1 -0
- package/lib/commonjs/bindings.js +2 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +2 -1
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +2 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/index.js +5 -3
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/hooks/index.js +2 -4
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/index.js +9 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +24 -12
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js +10 -0
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/views/OverKeyboardView/index.js +43 -0
- package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -0
- package/lib/commonjs/views/index.js +14 -0
- package/lib/commonjs/views/index.js.map +1 -0
- package/lib/module/bindings.js +1 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +1 -0
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +2 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +5 -3
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/hooks/index.js +3 -4
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +24 -12
- package/lib/module/internal.js.map +1 -1
- package/lib/module/specs/OverKeyboardViewNativeComponent.js +3 -0
- package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/views/OverKeyboardView/index.js +35 -0
- package/lib/module/views/OverKeyboardView/index.js.map +1 -0
- package/lib/module/views/index.js +2 -0
- package/lib/module/views/index.js.map +1 -0
- package/lib/typescript/bindings.d.ts +2 -1
- package/lib/typescript/bindings.native.d.ts +2 -1
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -0
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +2 -2
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/specs/OverKeyboardViewNativeComponent.d.ts +7 -0
- package/lib/typescript/types.d.ts +4 -1
- package/lib/typescript/views/OverKeyboardView/index.d.ts +5 -0
- package/lib/typescript/views/index.d.ts +1 -0
- package/package.json +8 -3
- package/src/bindings.native.ts +3 -0
- package/src/bindings.ts +3 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +5 -2
- package/src/components/KeyboardToolbar/index.tsx +7 -3
- package/src/hooks/index.ts +3 -5
- package/src/index.ts +1 -0
- package/src/internal.ts +34 -15
- package/src/specs/OverKeyboardViewNativeComponent.ts +12 -0
- package/src/types.ts +4 -0
- package/src/views/OverKeyboardView/index.tsx +43 -0
- package/src/views/index.ts +1 -0
- package/ios/.clang-format +0 -90
- package/ios/.swiftformat +0 -5
- package/ios/.swiftlint.yml +0 -14
- package/lib/commonjs/hooks/useSyncEffect/index.js +0 -37
- package/lib/commonjs/hooks/useSyncEffect/index.js.map +0 -1
- package/lib/module/hooks/useSyncEffect/index.js +0 -31
- package/lib/module/hooks/useSyncEffect/index.js.map +0 -1
- package/lib/typescript/hooks/useSyncEffect/index.d.ts +0 -14
- package/src/hooks/useSyncEffect/index.ts +0 -36
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardToolbarProps,\n} from \"./components\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme","OverKeyboardView"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardToolbarProps,\n} from \"./components\";\nexport { OverKeyboardView } from \"./views\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc;AAOrB,SAASC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
|
package/lib/module/internal.js
CHANGED
|
@@ -3,19 +3,31 @@ import { Animated, findNodeHandle } from "react-native";
|
|
|
3
3
|
import { registerEventHandler, unregisterEventHandler } from "./event-handler";
|
|
4
4
|
export function useEventHandlerRegistration(map, viewTagRef) {
|
|
5
5
|
const onRegisterHandler = handler => {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return registerEventHandler(event => {
|
|
12
|
-
"worklet";
|
|
13
|
-
|
|
14
|
-
functionToCall === null || functionToCall === void 0 || functionToCall(event);
|
|
15
|
-
}, eventName, viewTag);
|
|
6
|
+
const ids = [];
|
|
7
|
+
const attachWorkletHandlers = () => {
|
|
8
|
+
const viewTag = findNodeHandle(viewTagRef.current);
|
|
9
|
+
if (__DEV__ && !viewTag) {
|
|
10
|
+
console.warn("Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.");
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
ids.push(...Object.keys(handler).map(handlerName => {
|
|
13
|
+
const eventName = map.get(handlerName);
|
|
14
|
+
const functionToCall = handler[handlerName];
|
|
15
|
+
if (eventName && viewTag) {
|
|
16
|
+
return registerEventHandler(event => {
|
|
17
|
+
"worklet";
|
|
18
|
+
|
|
19
|
+
functionToCall === null || functionToCall === void 0 || functionToCall(event);
|
|
20
|
+
}, eventName, viewTag);
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
if (viewTagRef.current) {
|
|
26
|
+
attachWorkletHandlers();
|
|
27
|
+
} else {
|
|
28
|
+
// view may not be mounted yet - defer registration to next event loop
|
|
29
|
+
setImmediate(attachWorkletHandlers);
|
|
30
|
+
}
|
|
19
31
|
return () => {
|
|
20
32
|
ids.forEach(id => id ? unregisterEventHandler(id) : null);
|
|
21
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","Animated","findNodeHandle","registerEventHandler","unregisterEventHandler","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","viewTag","current","
|
|
1
|
+
{"version":3,"names":["useRef","Animated","findNodeHandle","registerEventHandler","unregisterEventHandler","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","event","setImmediate","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 ids: (number | null)[] = [];\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n ids.push(\n ...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 };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration to next event loop\n setImmediate(attachWorkletHandlers);\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,GAAsB,GAAG,EAAE;IACjC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAGV,cAAc,CAACK,UAAU,CAACM,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACF,OAAO,EAAE;QACvBG,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAN,GAAG,CAACO,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACV,OAAO,CAAC,CAACH,GAAG,CAAEc,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGf,GAAG,CAACgB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGd,OAAO,CAACW,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIT,OAAO,EAAE;UACxB,OAAOT,oBAAoB,CACxBqB,KAA6C,IAAK;YACjD,SAAS;;YAETD,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGC,KAAK,CAAC;UACzB,CAAC,EACDH,SAAS,EACTT,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACM,OAAO,EAAE;MACtBF,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAc,YAAY,CAACd,qBAAqB,CAAC;IACrC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACgB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAGvB,sBAAsB,CAACuB,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOnB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASoB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG/B,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAI+B,GAAG,CAAClB,OAAO,KAAK,IAAI,EAAE;IACxBkB,GAAG,CAAClB,OAAO,GAAG,IAAIZ,QAAQ,CAAC+B,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAClB,OAAO;AACpB","ignoreList":[]}
|
|
@@ -0,0 +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>(\n \"OverKeyboardView\",\n) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAS5F,eAAeA,sBAAsB,CACnC,kBACF,CAAC","ignoreList":[]}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n EmitterSubscription,\n NativeSyntheticEvent,\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 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} & ViewProps;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: () => 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};\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
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type {\n EmitterSubscription,\n NativeSyntheticEvent,\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 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} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: () => 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};\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":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { Platform, StyleSheet, View } from "react-native";
|
|
3
|
+
import { RCTOverKeyboardView } from "../../bindings";
|
|
4
|
+
import { useWindowDimensions } from "../../hooks";
|
|
5
|
+
const OverKeyboardView = ({
|
|
6
|
+
children,
|
|
7
|
+
visible
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
height,
|
|
11
|
+
width
|
|
12
|
+
} = useWindowDimensions();
|
|
13
|
+
const inner = useMemo(() => ({
|
|
14
|
+
height,
|
|
15
|
+
width
|
|
16
|
+
}), [height, width]);
|
|
17
|
+
const style = useMemo(() => [styles.absolute,
|
|
18
|
+
// On iOS - stretch view to full window dimensions to make yoga work
|
|
19
|
+
// On Android Fabric we temporarily use the same approach
|
|
20
|
+
// @ts-expect-error `_IS_FABRIC` is injected by REA
|
|
21
|
+
Platform.OS === "ios" || global._IS_FABRIC ? inner : undefined], [inner]);
|
|
22
|
+
return /*#__PURE__*/React.createElement(RCTOverKeyboardView, {
|
|
23
|
+
visible: visible
|
|
24
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
25
|
+
collapsable: false,
|
|
26
|
+
style: style
|
|
27
|
+
}, children));
|
|
28
|
+
};
|
|
29
|
+
const styles = StyleSheet.create({
|
|
30
|
+
absolute: {
|
|
31
|
+
position: "absolute"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
export default OverKeyboardView;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","Platform","StyleSheet","View","RCTOverKeyboardView","useWindowDimensions","OverKeyboardView","children","visible","height","width","inner","style","styles","absolute","OS","global","_IS_FABRIC","undefined","createElement","collapsable","create","position"],"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 // On Android Fabric we temporarily use the same approach\n // @ts-expect-error `_IS_FABRIC` is injected by REA\n Platform.OS === \"ios\" || global._IS_FABRIC ? inner : 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 {children}\n </View>\n </RCTOverKeyboardView>\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: \"absolute\",\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;EACA;EACA;EACAb,QAAQ,CAACc,EAAE,KAAK,KAAK,IAAIC,MAAM,CAACC,UAAU,GAAGN,KAAK,GAAGO,SAAS,CAC/D,EACD,CAACP,KAAK,CACR,CAAC;EAED,oBACEZ,KAAA,CAAAoB,aAAA,CAACf,mBAAmB;IAACI,OAAO,EAAEA;EAAQ,gBAEpCT,KAAA,CAAAoB,aAAA,CAAChB,IAAI;IAACiB,WAAW,EAAE,KAAM;IAACR,KAAK,EAAEA;EAAM,GACpCL,QACG,CACa,CAAC;AAE1B,CAAC;AAED,MAAMM,MAAM,GAAGX,UAAU,CAACmB,MAAM,CAAC;EAC/BP,QAAQ,EAAE;IACRQ,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAEF,eAAehB,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","OverKeyboardView"],"sources":["index.ts"],"sourcesContent":["export { default as OverKeyboardView } from \"./OverKeyboardView\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,gBAAgB,QAAQ,oBAAoB","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, WindowDimensionsEventsModule } from "./types";
|
|
2
|
+
import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
3
3
|
export declare const KeyboardController: KeyboardControllerModule;
|
|
4
4
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
5
5
|
/**
|
|
@@ -10,3 +10,4 @@ export declare const FocusedInputEvents: FocusedInputEventsModule;
|
|
|
10
10
|
export declare const WindowDimensionsEvents: WindowDimensionsEventsModule;
|
|
11
11
|
export declare const KeyboardControllerView: import("react").FC<KeyboardControllerProps>;
|
|
12
12
|
export declare const KeyboardGestureArea: import("react").FC<KeyboardGestureAreaProps>;
|
|
13
|
+
export declare const RCTOverKeyboardView: import("react").FC<OverKeyboardViewProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, WindowDimensionsEventsModule } from "./types";
|
|
2
|
+
import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
3
3
|
export declare const KeyboardController: KeyboardControllerModule;
|
|
4
4
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
5
5
|
/**
|
|
@@ -10,3 +10,4 @@ export declare const FocusedInputEvents: FocusedInputEventsModule;
|
|
|
10
10
|
export declare const WindowDimensionsEvents: WindowDimensionsEventsModule;
|
|
11
11
|
export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
|
|
12
12
|
export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
|
|
13
|
+
export declare const RCTOverKeyboardView: React.FC<OverKeyboardViewProps>;
|
|
@@ -9,6 +9,8 @@ export type KeyboardAwareScrollViewProps = {
|
|
|
9
9
|
enabled?: boolean;
|
|
10
10
|
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
11
11
|
extraKeyboardSpace?: number;
|
|
12
|
+
/** Custom component for `ScrollView`. Default is `ScrollView` */
|
|
13
|
+
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
|
|
12
14
|
} & ScrollViewProps;
|
|
13
15
|
declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
|
|
14
16
|
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
|
|
@@ -19,6 +21,8 @@ declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
|
|
|
19
21
|
enabled?: boolean | undefined;
|
|
20
22
|
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
21
23
|
extraKeyboardSpace?: number | undefined;
|
|
24
|
+
/** Custom component for `ScrollView`. Default is `ScrollView` */
|
|
25
|
+
ScrollViewComponent?: React.ComponentType<ScrollViewProps> | undefined;
|
|
22
26
|
} & ScrollViewProps & {
|
|
23
27
|
children?: React.ReactNode;
|
|
24
28
|
} & React.RefAttributes<ScrollView>>;
|
|
@@ -4,8 +4,8 @@ import Button from "./Button";
|
|
|
4
4
|
import { colors } from "./colors";
|
|
5
5
|
import type { HEX, KeyboardToolbarTheme } from "./types";
|
|
6
6
|
import type { ReactNode } from "react";
|
|
7
|
-
import type { GestureResponderEvent } from "react-native";
|
|
8
|
-
export type KeyboardToolbarProps = {
|
|
7
|
+
import type { GestureResponderEvent, ViewProps } from "react-native";
|
|
8
|
+
export type KeyboardToolbarProps = Omit<ViewProps, "style" | "testID" | "children"> & {
|
|
9
9
|
/** An element that is shown in the middle of the toolbar. */
|
|
10
10
|
content?: JSX.Element | null;
|
|
11
11
|
/** A set of dark/light colors consumed by toolbar component. */
|
|
@@ -6,3 +6,4 @@ export * from "./constants";
|
|
|
6
6
|
export * from "./types";
|
|
7
7
|
export { KeyboardAvoidingView, KeyboardStickyView, KeyboardAwareScrollView, KeyboardToolbar, DefaultKeyboardToolbarTheme, } from "./components";
|
|
8
8
|
export type { KeyboardAvoidingViewProps, KeyboardStickyViewProps, KeyboardAwareScrollViewProps, KeyboardToolbarProps, } from "./components";
|
|
9
|
+
export { OverKeyboardView } from "./views";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HostComponent } from "react-native";
|
|
2
|
+
import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: HostComponent<NativeProps>;
|
|
7
|
+
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PropsWithChildren } from "react";
|
|
2
2
|
import type { EmitterSubscription, NativeSyntheticEvent, ViewProps } from "react-native";
|
|
3
3
|
export type NativeEvent = {
|
|
4
4
|
progress: number;
|
|
@@ -74,6 +74,9 @@ export type KeyboardGestureAreaProps = {
|
|
|
74
74
|
*/
|
|
75
75
|
offset?: number;
|
|
76
76
|
} & ViewProps;
|
|
77
|
+
export type OverKeyboardViewProps = PropsWithChildren<{
|
|
78
|
+
visible: boolean;
|
|
79
|
+
}>;
|
|
77
80
|
export type Direction = "next" | "prev" | "current";
|
|
78
81
|
export type KeyboardControllerModule = {
|
|
79
82
|
setDefaultMode: () => void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { OverKeyboardViewProps } from "../../types";
|
|
3
|
+
import type { PropsWithChildren } from "react";
|
|
4
|
+
declare const OverKeyboardView: ({ children, visible, }: PropsWithChildren<OverKeyboardViewProps>) => React.JSX.Element;
|
|
5
|
+
export default OverKeyboardView;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as OverKeyboardView } from "./OverKeyboardView";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-keyboard-controller",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.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",
|
|
@@ -21,8 +21,12 @@
|
|
|
21
21
|
"!android/gradle",
|
|
22
22
|
"!android/gradlew",
|
|
23
23
|
"!android/gradlew.bat",
|
|
24
|
+
"!android/.editorconfig",
|
|
24
25
|
"!ios/build",
|
|
25
26
|
"!ios/KeyboardControllerNative",
|
|
27
|
+
"!ios/.swiftlint.yml",
|
|
28
|
+
"!ios/.swiftformat",
|
|
29
|
+
"!ios/.clang-format",
|
|
26
30
|
"!**/__tests__",
|
|
27
31
|
"!**/__fixtures__",
|
|
28
32
|
"!**/__mocks__"
|
|
@@ -51,6 +55,7 @@
|
|
|
51
55
|
"avoiding view",
|
|
52
56
|
"avoid keyboard",
|
|
53
57
|
"sticky view",
|
|
58
|
+
"over keyboard view",
|
|
54
59
|
"keyboard aware scroll view",
|
|
55
60
|
"keyboard toolbar",
|
|
56
61
|
"keyboard done button",
|
|
@@ -71,7 +76,7 @@
|
|
|
71
76
|
},
|
|
72
77
|
"devDependencies": {
|
|
73
78
|
"@commitlint/config-conventional": "^11.0.0",
|
|
74
|
-
"@react-native/eslint-config": "^0.75.
|
|
79
|
+
"@react-native/eslint-config": "^0.75.3",
|
|
75
80
|
"@release-it/conventional-changelog": "^2.0.0",
|
|
76
81
|
"@testing-library/react-hooks": "^8.0.1",
|
|
77
82
|
"@types/jest": "^29.2.1",
|
|
@@ -94,7 +99,7 @@
|
|
|
94
99
|
"pod-install": "^0.1.0",
|
|
95
100
|
"prettier": "^2.8.8",
|
|
96
101
|
"react": "18.3.1",
|
|
97
|
-
"react-native": "0.75.
|
|
102
|
+
"react-native": "0.75.3",
|
|
98
103
|
"react-native-builder-bob": "^0.18.0",
|
|
99
104
|
"react-native-reanimated": "3.15.0",
|
|
100
105
|
"react-test-renderer": "18.2.0",
|
package/src/bindings.native.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
KeyboardControllerProps,
|
|
7
7
|
KeyboardEventsModule,
|
|
8
8
|
KeyboardGestureAreaProps,
|
|
9
|
+
OverKeyboardViewProps,
|
|
9
10
|
WindowDimensionsEventsModule,
|
|
10
11
|
} from "./types";
|
|
11
12
|
|
|
@@ -56,3 +57,5 @@ export const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =
|
|
|
56
57
|
Platform.OS === "android" && Platform.Version >= 30
|
|
57
58
|
? require("./specs/KeyboardGestureAreaNativeComponent").default
|
|
58
59
|
: ({ children }: KeyboardGestureAreaProps) => children;
|
|
60
|
+
export const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> =
|
|
61
|
+
require("./specs/OverKeyboardViewNativeComponent").default;
|
package/src/bindings.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
KeyboardControllerProps,
|
|
7
7
|
KeyboardEventsModule,
|
|
8
8
|
KeyboardGestureAreaProps,
|
|
9
|
+
OverKeyboardViewProps,
|
|
9
10
|
WindowDimensionsEventsModule,
|
|
10
11
|
} from "./types";
|
|
11
12
|
import type { EmitterSubscription } from "react-native";
|
|
@@ -37,3 +38,5 @@ export const KeyboardControllerView =
|
|
|
37
38
|
View as unknown as React.FC<KeyboardControllerProps>;
|
|
38
39
|
export const KeyboardGestureArea =
|
|
39
40
|
View as unknown as React.FC<KeyboardGestureAreaProps>;
|
|
41
|
+
export const RCTOverKeyboardView =
|
|
42
|
+
View as unknown as React.FC<OverKeyboardViewProps>;
|
|
@@ -38,6 +38,8 @@ export type KeyboardAwareScrollViewProps = {
|
|
|
38
38
|
enabled?: boolean;
|
|
39
39
|
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
40
40
|
extraKeyboardSpace?: number;
|
|
41
|
+
/** Custom component for `ScrollView`. Default is `ScrollView` */
|
|
42
|
+
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
|
|
41
43
|
} & ScrollViewProps;
|
|
42
44
|
|
|
43
45
|
/*
|
|
@@ -90,6 +92,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
90
92
|
disableScrollOnKeyboardHide = false,
|
|
91
93
|
enabled = true,
|
|
92
94
|
extraKeyboardSpace = 0,
|
|
95
|
+
ScrollViewComponent = Reanimated.ScrollView,
|
|
93
96
|
snapToOffsets,
|
|
94
97
|
...rest
|
|
95
98
|
},
|
|
@@ -362,7 +365,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
362
365
|
);
|
|
363
366
|
|
|
364
367
|
return (
|
|
365
|
-
<
|
|
368
|
+
<ScrollViewComponent
|
|
366
369
|
ref={onRef}
|
|
367
370
|
{...rest}
|
|
368
371
|
scrollEventThrottle={16}
|
|
@@ -370,7 +373,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
370
373
|
>
|
|
371
374
|
{children}
|
|
372
375
|
<Reanimated.View style={view} />
|
|
373
|
-
</
|
|
376
|
+
</ScrollViewComponent>
|
|
374
377
|
);
|
|
375
378
|
},
|
|
376
379
|
);
|
|
@@ -11,9 +11,12 @@ import { colors } from "./colors";
|
|
|
11
11
|
|
|
12
12
|
import type { HEX, KeyboardToolbarTheme } from "./types";
|
|
13
13
|
import type { ReactNode } from "react";
|
|
14
|
-
import type { GestureResponderEvent } from "react-native";
|
|
14
|
+
import type { GestureResponderEvent, ViewProps } from "react-native";
|
|
15
15
|
|
|
16
|
-
export type KeyboardToolbarProps =
|
|
16
|
+
export type KeyboardToolbarProps = Omit<
|
|
17
|
+
ViewProps,
|
|
18
|
+
"style" | "testID" | "children"
|
|
19
|
+
> & {
|
|
17
20
|
/** An element that is shown in the middle of the toolbar. */
|
|
18
21
|
content?: JSX.Element | null;
|
|
19
22
|
/** A set of dark/light colors consumed by toolbar component. */
|
|
@@ -81,6 +84,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
81
84
|
onDoneCallback,
|
|
82
85
|
blur = null,
|
|
83
86
|
opacity = DEFAULT_OPACITY,
|
|
87
|
+
...rest
|
|
84
88
|
}) => {
|
|
85
89
|
const colorScheme = useColorScheme();
|
|
86
90
|
const [inputs, setInputs] = useState({
|
|
@@ -146,7 +150,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
146
150
|
|
|
147
151
|
return (
|
|
148
152
|
<KeyboardStickyView offset={offset}>
|
|
149
|
-
<View style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>
|
|
153
|
+
<View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>
|
|
150
154
|
{blur}
|
|
151
155
|
{showArrows && (
|
|
152
156
|
<>
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
1
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
2
2
|
|
|
3
3
|
import { KeyboardController } from "../bindings";
|
|
4
4
|
import { AndroidSoftInputModes } from "../constants";
|
|
5
5
|
import { useKeyboardContext } from "../context";
|
|
6
6
|
|
|
7
|
-
import useSyncEffect from "./useSyncEffect";
|
|
8
|
-
|
|
9
7
|
import type { AnimatedContext, ReanimatedContext } from "../context";
|
|
10
8
|
import type { FocusedInputHandler, KeyboardHandler } from "../types";
|
|
11
9
|
import type { DependencyList } from "react";
|
|
@@ -40,7 +38,7 @@ export function useGenericKeyboardHandler(
|
|
|
40
38
|
) {
|
|
41
39
|
const context = useKeyboardContext();
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
useLayoutEffect(() => {
|
|
44
42
|
const cleanup = context.setKeyboardHandlers(handler);
|
|
45
43
|
|
|
46
44
|
return () => cleanup();
|
|
@@ -73,7 +71,7 @@ export function useFocusedInputHandler(
|
|
|
73
71
|
) {
|
|
74
72
|
const context = useKeyboardContext();
|
|
75
73
|
|
|
76
|
-
|
|
74
|
+
useLayoutEffect(() => {
|
|
77
75
|
const cleanup = context.setInputHandlers(handler);
|
|
78
76
|
|
|
79
77
|
return () => cleanup();
|
package/src/index.ts
CHANGED
package/src/internal.ts
CHANGED
|
@@ -13,25 +13,44 @@ export function useEventHandlerRegistration<
|
|
|
13
13
|
viewTagRef: React.MutableRefObject<ComponentOrHandle>,
|
|
14
14
|
) {
|
|
15
15
|
const onRegisterHandler = (handler: H) => {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const functionToCall = handler[handlerName as keyof H];
|
|
16
|
+
const ids: (number | null)[] = [];
|
|
17
|
+
const attachWorkletHandlers = () => {
|
|
18
|
+
const viewTag = findNodeHandle(viewTagRef.current);
|
|
20
19
|
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"worklet";
|
|
25
|
-
|
|
26
|
-
functionToCall?.(event);
|
|
27
|
-
},
|
|
28
|
-
eventName,
|
|
29
|
-
viewTag,
|
|
20
|
+
if (__DEV__ && !viewTag) {
|
|
21
|
+
console.warn(
|
|
22
|
+
"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.",
|
|
30
23
|
);
|
|
31
24
|
}
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
ids.push(
|
|
27
|
+
...Object.keys(handler).map((handlerName) => {
|
|
28
|
+
const eventName = map.get(handlerName as keyof H);
|
|
29
|
+
const functionToCall = handler[handlerName as keyof H];
|
|
30
|
+
|
|
31
|
+
if (eventName && viewTag) {
|
|
32
|
+
return registerEventHandler(
|
|
33
|
+
(event: Parameters<NonNullable<H[keyof H]>>[0]) => {
|
|
34
|
+
"worklet";
|
|
35
|
+
|
|
36
|
+
functionToCall?.(event);
|
|
37
|
+
},
|
|
38
|
+
eventName,
|
|
39
|
+
viewTag,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (viewTagRef.current) {
|
|
49
|
+
attachWorkletHandlers();
|
|
50
|
+
} else {
|
|
51
|
+
// view may not be mounted yet - defer registration to next event loop
|
|
52
|
+
setImmediate(attachWorkletHandlers);
|
|
53
|
+
}
|
|
35
54
|
|
|
36
55
|
return () => {
|
|
37
56
|
ids.forEach((id) => (id ? unregisterEventHandler(id) : null));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
+
|
|
3
|
+
import type { HostComponent } from "react-native";
|
|
4
|
+
import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
|
|
5
|
+
|
|
6
|
+
export interface NativeProps extends ViewProps {
|
|
7
|
+
visible?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default codegenNativeComponent<NativeProps>(
|
|
11
|
+
"OverKeyboardView",
|
|
12
|
+
) as HostComponent<NativeProps>;
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PropsWithChildren } from "react";
|
|
1
2
|
import type {
|
|
2
3
|
EmitterSubscription,
|
|
3
4
|
NativeSyntheticEvent,
|
|
@@ -108,6 +109,9 @@ export type KeyboardGestureAreaProps = {
|
|
|
108
109
|
*/
|
|
109
110
|
offset?: number;
|
|
110
111
|
} & ViewProps;
|
|
112
|
+
export type OverKeyboardViewProps = PropsWithChildren<{
|
|
113
|
+
visible: boolean;
|
|
114
|
+
}>;
|
|
111
115
|
|
|
112
116
|
export type Direction = "next" | "prev" | "current";
|
|
113
117
|
export type KeyboardControllerModule = {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { Platform, StyleSheet, View } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { RCTOverKeyboardView } from "../../bindings";
|
|
5
|
+
import { useWindowDimensions } from "../../hooks";
|
|
6
|
+
|
|
7
|
+
import type { OverKeyboardViewProps } from "../../types";
|
|
8
|
+
import type { PropsWithChildren } from "react";
|
|
9
|
+
|
|
10
|
+
const OverKeyboardView = ({
|
|
11
|
+
children,
|
|
12
|
+
visible,
|
|
13
|
+
}: PropsWithChildren<OverKeyboardViewProps>) => {
|
|
14
|
+
const { height, width } = useWindowDimensions();
|
|
15
|
+
const inner = useMemo(() => ({ height, width }), [height, width]);
|
|
16
|
+
const style = useMemo(
|
|
17
|
+
() => [
|
|
18
|
+
styles.absolute,
|
|
19
|
+
// On iOS - stretch view to full window dimensions to make yoga work
|
|
20
|
+
// On Android Fabric we temporarily use the same approach
|
|
21
|
+
// @ts-expect-error `_IS_FABRIC` is injected by REA
|
|
22
|
+
Platform.OS === "ios" || global._IS_FABRIC ? inner : undefined,
|
|
23
|
+
],
|
|
24
|
+
[inner],
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<RCTOverKeyboardView visible={visible}>
|
|
29
|
+
{/* `OverKeyboardView` should always have a single child */}
|
|
30
|
+
<View collapsable={false} style={style}>
|
|
31
|
+
{children}
|
|
32
|
+
</View>
|
|
33
|
+
</RCTOverKeyboardView>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const styles = StyleSheet.create({
|
|
38
|
+
absolute: {
|
|
39
|
+
position: "absolute",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export default OverKeyboardView;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as OverKeyboardView } from "./OverKeyboardView";
|