@react-native-gpui/keyboard-controller 0.0.0-stage → 1.23.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@react-native-gpui/keyboard-controller` are listed here. Each version's section becomes the notes of its GitHub release.
4
+
5
+ ## 1.23.0-alpha.1 - 2026-11-27
6
+
7
+ - First release, for `react-native-keyboard-controller` 1.23.x: a desktop has no soft keyboard, so the keyboard views pass their children through and the keyboard never shows.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Streetwriters
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # @react-native-gpui/keyboard-controller
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Adapter for [`react-native-keyboard-controller`](https://github.com/kirillzyusko/react-native-keyboard-controller) (MIT): a desktop has no soft keyboard, so the keyboard views pass their children through and the keyboard never shows.
4
+
5
+ ## About
6
+
7
+ This package is the desktop adapter for [`react-native-keyboard-controller`](https://github.com/kirillzyusko/react-native-keyboard-controller) 1.23. Install the original library next to it; its JavaScript runs unchanged on desktop, and this package provides the native side. The upstream library is licensed under the MIT license.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install react-native-keyboard-controller @react-native-gpui/keyboard-controller
13
+ ```
14
+
15
+ The module is autolinked on desktop.
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ import {
21
+ KeyboardAvoidingView,
22
+ KeyboardProvider,
23
+ } from 'react-native-keyboard-controller';
24
+
25
+ <KeyboardProvider>
26
+ <KeyboardAvoidingView behavior="padding" style={{ flex: 1 }}>
27
+ {children}
28
+ </KeyboardAvoidingView>
29
+ </KeyboardProvider>;
30
+ ```
31
+
32
+ ## Platforms
33
+
34
+ macOS is tested. Windows and Linux are not tested yet.
35
+
36
+ ## Limitations
37
+
38
+ The keyboard height is always 0 and no keyboard events fire. `KeyboardController.dismiss()` blurs the focused TextInput, unless `keepFocus` is set. `setFocusTo('next' | 'prev')` moves focus through the focused window's tab order, as Tab and Shift+Tab do, so it reaches every focusable view, not only TextInputs; `current` is a no-op. It needs `@react-native-gpui/core` 0.87.0-alpha.4 or later. `setInputMode`, `setDefaultMode`, `preload` and `setTranslucent` do nothing. The keyboard controller module is provided in JavaScript, not in Rust.
39
+
40
+ ## License
41
+
42
+ MIT. See [LICENSE](LICENSE). The upstream library, [`react-native-keyboard-controller`](https://github.com/kirillzyusko/react-native-keyboard-controller), is MIT licensed.
@@ -0,0 +1,14 @@
1
+ [package]
2
+ name = "rn-gpui-keyboard-controller"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
7
+ react-native-gpui = "0.1"
8
+ # Only for DEP_RN_GPUI_CORE_RPATHS, which build.rs puts on the test binary rpath.
9
+ rn-gpui-sys = "0.1"
10
+ rn-gpui-module = "0.1"
11
+ gpui = "0.2"
12
+
13
+ [build-dependencies]
14
+ rn-gpui-module-build = "0.1"
@@ -0,0 +1,25 @@
1
+ fn main() {
2
+ rn_gpui_module_build::generate(&[
3
+ "../src/KeyboardControllerViewNativeComponent.ts",
4
+ "../src/OverKeyboardViewNativeComponent.ts",
5
+ "../src/KeyboardBackgroundViewNativeComponent.ts",
6
+ "../src/ClippingScrollViewDecoratorViewNativeComponent.ts",
7
+ "../src/KeyboardToolbarGroupViewNativeComponent.ts",
8
+ ]);
9
+ test_rpaths();
10
+ }
11
+
12
+ /// Core's runtime is shared libraries (`libjsi.dylib`, ...). Core puts their
13
+ /// directories on the app's rpath only, so this crate's test binary gets them here.
14
+ fn test_rpaths() {
15
+ println!("cargo:rerun-if-env-changed=DEP_RN_GPUI_CORE_RPATHS");
16
+ if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
17
+ return;
18
+ }
19
+ let Ok(dirs) = std::env::var("DEP_RN_GPUI_CORE_RPATHS") else {
20
+ return;
21
+ };
22
+ for dir in dirs.split('|').filter(|dir| !dir.is_empty()) {
23
+ println!("cargo:rustc-link-arg=-Wl,-rpath,{dir}");
24
+ }
25
+ }
@@ -0,0 +1,71 @@
1
+ rn_gpui_module::include_specs!();
2
+
3
+ use gpui::{div, prelude::*, AnyElement, Window};
4
+
5
+ macro_rules! passthrough_containers {
6
+ ($($component:ident => ($spec:ident, $props:ident, $context:ident, $changed:ident, $register:ident);)*) => {
7
+ $(
8
+ pub struct $component;
9
+
10
+ impl $spec for $component {
11
+ fn create(_props: &$props, _cx: &mut $context) -> Self {
12
+ Self
13
+ }
14
+
15
+ fn update(&mut self, _props: &$props, _changed: $changed, _cx: &mut $context) {}
16
+
17
+ fn render(&mut self, _props: &$props, _window: &mut Window, _cx: &mut $context) -> AnyElement {
18
+ div().into_any_element()
19
+ }
20
+ }
21
+ )*
22
+
23
+ fn register_passthrough_containers() {
24
+ $(
25
+ react_native_gpui::host_component::register_component($register::<$component>());
26
+ )*
27
+ }
28
+ };
29
+ }
30
+
31
+ passthrough_containers! {
32
+ OverKeyboardViewHost => (OverKeyboardViewSpec, OverKeyboardViewProps, OverKeyboardViewContext, OverKeyboardViewChanged, over_keyboard_view_component);
33
+ KeyboardBackgroundViewHost => (KeyboardBackgroundViewSpec, KeyboardBackgroundViewProps, KeyboardBackgroundViewContext, KeyboardBackgroundViewChanged, keyboard_background_view_component);
34
+ ClippingScrollViewDecoratorViewHost => (ClippingScrollViewDecoratorViewSpec, ClippingScrollViewDecoratorViewProps, ClippingScrollViewDecoratorViewContext, ClippingScrollViewDecoratorViewChanged, clipping_scroll_view_decorator_view_component);
35
+ KeyboardToolbarGroupViewHost => (KeyboardToolbarGroupViewSpec, KeyboardToolbarGroupViewProps, KeyboardToolbarGroupViewContext, KeyboardToolbarGroupViewChanged, keyboard_toolbar_group_view_component);
36
+ }
37
+
38
+ /// The keyboard view has no keyboard to synchronize with on desktop.
39
+ pub struct KeyboardControllerViewHost;
40
+
41
+ impl KeyboardControllerViewSpec for KeyboardControllerViewHost {
42
+ fn create(_props: &KeyboardControllerViewProps, _cx: &mut KeyboardControllerViewContext) -> Self {
43
+ Self
44
+ }
45
+
46
+ fn update(
47
+ &mut self,
48
+ _props: &KeyboardControllerViewProps,
49
+ _changed: KeyboardControllerViewChanged,
50
+ _cx: &mut KeyboardControllerViewContext,
51
+ ) {
52
+ }
53
+
54
+ fn render(
55
+ &mut self,
56
+ _props: &KeyboardControllerViewProps,
57
+ _window: &mut Window,
58
+ _cx: &mut KeyboardControllerViewContext,
59
+ ) -> AnyElement {
60
+ div().into_any_element()
61
+ }
62
+
63
+ fn synchronize_focused_input_layout(&mut self, _cx: &mut KeyboardControllerViewContext) {}
64
+ }
65
+
66
+ pub fn rn_gpui_register() {
67
+ react_native_gpui::host_component::register_component(
68
+ keyboard_controller_view_component::<KeyboardControllerViewHost>(),
69
+ );
70
+ register_passthrough_containers();
71
+ }
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@react-native-gpui/keyboard-controller",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.23.0-alpha.1",
4
+ "description": "Adapter for react-native-keyboard-controller (MIT): a desktop has no soft keyboard, so the keyboard views pass their children through",
5
+ "license": "MIT",
6
+ "main": "src/index.ts",
7
+ "files": [
8
+ "src",
9
+ "desktop",
10
+ "react-native.config.js",
11
+ "README.md",
12
+ "CHANGELOG.md",
13
+ "LICENSE"
14
+ ],
15
+ "codegenConfig": {
16
+ "name": "RNGpuiKeyboardControllerSpec",
17
+ "type": "all",
18
+ "jsSrcsDir": "src"
19
+ },
20
+ "peerDependencies": {
21
+ "react-native": "0.87.x",
22
+ "@react-native-gpui/core": ">=0.87.0-alpha.4 <0.88.0",
23
+ "react-native-keyboard-controller": "1.23.x"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/streetwriters/react-native-gpui-modules.git",
28
+ "directory": "modules/keyboard-controller"
29
+ },
30
+ "homepage": "https://github.com/streetwriters/react-native-gpui-modules/tree/main/modules/keyboard-controller#readme",
31
+ "bugs": {
32
+ "url": "https://github.com/streetwriters/react-native-gpui-modules/issues"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "tag": "latest"
37
+ }
38
+ }
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ desktop: {
5
+ crate: 'rn-gpui-keyboard-controller',
6
+ hostComponents: [
7
+ { name: 'KeyboardControllerView', container: true },
8
+ { name: 'OverKeyboardView', container: true },
9
+ { name: 'KeyboardBackgroundView', container: true },
10
+ { name: 'ClippingScrollViewDecoratorView', container: true },
11
+ { name: 'KeyboardToolbarGroupView', container: true },
12
+ ],
13
+ sourceOverrides: {
14
+ 'react-native-keyboard-controller/src/specs/NativeKeyboardController.ts':
15
+ './src/NativeKeyboardController.desktop.js',
16
+ },
17
+ },
18
+ },
19
+ },
20
+ };
@@ -0,0 +1,18 @@
1
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
+
3
+ import type { HostComponent } from 'react-native';
4
+ import type { ViewProps } from 'react-native';
5
+ import type { CodegenTypes } from 'react-native';
6
+
7
+ export interface NativeProps extends ViewProps {
8
+ contentInsetBottom: CodegenTypes.Double;
9
+ contentInsetTop: CodegenTypes.Double;
10
+ applyWorkaroundForContentInsetHitTestBug?: boolean;
11
+ }
12
+
13
+ export default codegenNativeComponent<NativeProps>(
14
+ 'ClippingScrollViewDecoratorView',
15
+ {
16
+ interfaceOnly: true,
17
+ },
18
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,10 @@
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
+
8
+ export default codegenNativeComponent<NativeProps>('KeyboardBackgroundView', {
9
+ interfaceOnly: true,
10
+ }) as HostComponent<NativeProps>;
@@ -0,0 +1,80 @@
1
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
2
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
+
4
+ import type { HostComponent } from 'react-native';
5
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
6
+ import type { CodegenTypes } from 'react-native';
7
+
8
+ type KeyboardMoveEvent = Readonly<{
9
+ height: CodegenTypes.Double;
10
+ progress: CodegenTypes.Double;
11
+ duration: CodegenTypes.Int32;
12
+ target: CodegenTypes.Int32;
13
+ }>;
14
+
15
+ type FocusedInputLayoutChangedEvent = Readonly<{
16
+ target: CodegenTypes.Int32;
17
+ parentScrollViewTarget: CodegenTypes.Int32;
18
+ layout: {
19
+ x: CodegenTypes.Double;
20
+ y: CodegenTypes.Double;
21
+ width: CodegenTypes.Double;
22
+ height: CodegenTypes.Double;
23
+ absoluteX: CodegenTypes.Double;
24
+ absoluteY: CodegenTypes.Double;
25
+ contentX: CodegenTypes.Double;
26
+ contentY: CodegenTypes.Double;
27
+ };
28
+ }>;
29
+
30
+ type FocusedInputTextChangedEvent = Readonly<{
31
+ text: string;
32
+ }>;
33
+
34
+ type FocusedInputSelectionChangedEvent = Readonly<{
35
+ target: CodegenTypes.Int32;
36
+ selection: {
37
+ start: {
38
+ x: CodegenTypes.Double;
39
+ y: CodegenTypes.Double;
40
+ position: CodegenTypes.Int32;
41
+ };
42
+ end: {
43
+ x: CodegenTypes.Double;
44
+ y: CodegenTypes.Double;
45
+ position: CodegenTypes.Int32;
46
+ };
47
+ };
48
+ }>;
49
+
50
+ export interface NativeProps extends ViewProps {
51
+ // props
52
+ enabled?: boolean;
53
+ statusBarTranslucent?: boolean;
54
+ navigationBarTranslucent?: boolean;
55
+ preserveEdgeToEdge?: boolean;
56
+ // callbacks
57
+ /// keyboard
58
+ onKeyboardMoveStart?: CodegenTypes.DirectEventHandler<KeyboardMoveEvent>;
59
+ onKeyboardMove?: CodegenTypes.DirectEventHandler<KeyboardMoveEvent>;
60
+ onKeyboardMoveEnd?: CodegenTypes.DirectEventHandler<KeyboardMoveEvent>;
61
+ onKeyboardMoveInteractive?: CodegenTypes.DirectEventHandler<KeyboardMoveEvent>;
62
+ /// focused input
63
+ onFocusedInputLayoutChanged?: CodegenTypes.DirectEventHandler<FocusedInputLayoutChangedEvent>;
64
+ onFocusedInputTextChanged?: CodegenTypes.DirectEventHandler<FocusedInputTextChangedEvent>;
65
+ onFocusedInputSelectionChanged?: CodegenTypes.DirectEventHandler<FocusedInputSelectionChangedEvent>;
66
+ }
67
+
68
+ interface NativeCommands {
69
+ synchronizeFocusedInputLayout: (
70
+ viewRef: React.ElementRef<HostComponent<NativeProps>>,
71
+ ) => void;
72
+ }
73
+
74
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
75
+ supportedCommands: ['synchronizeFocusedInputLayout'],
76
+ });
77
+
78
+ export default codegenNativeComponent<NativeProps>('KeyboardControllerView', {
79
+ interfaceOnly: true,
80
+ }) as HostComponent<NativeProps>;
@@ -0,0 +1,10 @@
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
+
8
+ export default codegenNativeComponent<NativeProps>('KeyboardToolbarGroupView', {
9
+ interfaceOnly: true,
10
+ }) as HostComponent<NativeProps>;
@@ -0,0 +1,37 @@
1
+ import TextInputState from 'react-native/Libraries/Components/TextInput/TextInputState';
2
+ import { DesktopWindow, MAIN_WINDOW_ID } from '@react-native-gpui/core/desktop';
3
+
4
+ async function focusedWindow() {
5
+ const windows = await DesktopWindow.all();
6
+ for (const window of windows) {
7
+ if ((await window.getState()).isFocused) return window;
8
+ }
9
+ return windows.find(window => window.id === MAIN_WINDOW_ID) ?? windows[0];
10
+ }
11
+
12
+ const NativeKeyboardController = {
13
+ getConstants: () => ({ keyboardBorderRadius: 0 }),
14
+ setInputMode: () => {},
15
+ setDefaultMode: () => {},
16
+ preload: () => {},
17
+ setTranslucent: () => {},
18
+ dismiss: keepFocus => {
19
+ if (keepFocus) return;
20
+ const input = TextInputState.currentlyFocusedInput();
21
+ if (input) TextInputState.blurTextInput(input);
22
+ },
23
+ setFocusTo: direction => {
24
+ if (direction !== 'next' && direction !== 'prev') return;
25
+ focusedWindow()
26
+ .then(window =>
27
+ direction === 'next' ? window?.focusNext() : window?.focusPrevious(),
28
+ )
29
+ .catch(() => {});
30
+ },
31
+ viewPositionInWindow: () =>
32
+ Promise.resolve({ x: 0, y: 0, width: 0, height: 0 }),
33
+ addListener: () => {},
34
+ removeListeners: () => {},
35
+ };
36
+
37
+ export default NativeKeyboardController;
@@ -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>('OverKeyboardView', {
11
+ interfaceOnly: true,
12
+ }) as HostComponent<NativeProps>;
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export {};