🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@cantoo/keyboard

Package Overview
Dependencies
Maintainers
6
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cantoo/keyboard - npm Package Compare versions

Comparing version
7.0.4
to
7.0.5
+2
-2
android/build.gradle

@@ -28,4 +28,4 @@ ext {

apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply from: file('../../scripts/android/publish-root.gradle')
apply from: file('../../scripts/android/publish-module.gradle')
apply from: file('../scripts/android/publish-root.gradle')
apply from: file('../scripts/android/publish-module.gradle')
}

@@ -32,0 +32,0 @@

@@ -15,2 +15,3 @@ package com.capacitorjs.plugins.keyboard;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;

@@ -79,4 +80,5 @@ import androidx.core.view.WindowInsetsAnimationCompat;

) {
boolean showingKeyboard = ViewCompat.getRootWindowInsets(rootView).isVisible(WindowInsetsCompat.Type.ime());
WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(rootView);
if (insets == null) return super.onStart(animation, bounds);
boolean showingKeyboard = insets.isVisible(WindowInsetsCompat.Type.ime());
int imeHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom;

@@ -86,6 +88,2 @@ DisplayMetrics dm = activity.getResources().getDisplayMetrics();

if (resizeOnFullScreen) {
possiblyResizeChildOfContent(showingKeyboard);
}
if (showingKeyboard) {

@@ -102,4 +100,5 @@ keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_SHOW, Math.round(imeHeight / density));

super.onEnd(animation);
boolean showingKeyboard = ViewCompat.getRootWindowInsets(rootView).isVisible(WindowInsetsCompat.Type.ime());
WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(rootView);
if (insets == null) return;
boolean showingKeyboard = insets.isVisible(WindowInsetsCompat.Type.ime());
int imeHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom;

@@ -120,2 +119,9 @@ DisplayMetrics dm = activity.getResources().getDisplayMetrics();

frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
if (resizeOnFullScreen) {
ViewCompat.setOnApplyWindowInsetsListener(content, (view, windowInsets) -> {
possiblyResizeChildOfContent(windowInsets.isVisible(WindowInsetsCompat.Type.ime()));
return ViewCompat.onApplyWindowInsets(view, windowInsets);
});
}
}

@@ -139,4 +145,18 @@

private void possiblyResizeChildOfContent(boolean keyboardShown) {
int usableHeightNow = keyboardShown ? computeUsableHeight() : -1;
if (usableHeightPrevious != usableHeightNow) {
if (isSystemBarsPluginPresent()) {
// SystemBars handles the inset sizing for visible keyboards
return;
}
if (!keyboardShown) {
if (frameLayoutParams.height != FrameLayout.LayoutParams.MATCH_PARENT) {
frameLayoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
mChildOfContent.requestLayout();
}
usableHeightPrevious = FrameLayout.LayoutParams.MATCH_PARENT;
return;
}
int usableHeightNow = computeUsableHeight();
if (usableHeightPrevious != usableHeightNow || frameLayoutParams.height != usableHeightNow) {
frameLayoutParams.height = usableHeightNow;

@@ -164,2 +184,11 @@ mChildOfContent.requestLayout();

private static boolean isSystemBarsPluginPresent() {
try {
Class.forName("com.getcapacitor.plugin.SystemBars");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
private boolean shouldApplyEdgeToEdgeAdjustments() {

@@ -166,0 +195,0 @@ var adjustMarginsForEdgeToEdge = this.bridge == null ? "auto" : this.bridge.getConfig().adjustMarginsForEdgeToEdge();

@@ -18,10 +18,8 @@ package com.capacitorjs.plugins.keyboard;

public void load() {
execute(
() -> {
boolean resizeOnFullScreen = getConfig().getBoolean("resizeOnFullScreen", false);
implementation = new Keyboard(getBridge(), resizeOnFullScreen);
execute(() -> {
boolean resizeOnFullScreen = getConfig().getBoolean("resizeOnFullScreen", false);
implementation = new Keyboard(getBridge(), resizeOnFullScreen);
implementation.setKeyboardEventListener(this::onKeyboardEvent);
}
);
implementation.setKeyboardEventListener(this::onKeyboardEvent);
});
}

@@ -31,12 +29,7 @@

public void show(final PluginCall call) {
execute(
() ->
new Handler(Looper.getMainLooper())
.postDelayed(
() -> {
implementation.show();
call.resolve();
},
350
)
execute(() ->
new Handler(Looper.getMainLooper()).postDelayed(() -> {
implementation.show();
call.resolve();
}, 350)
);

@@ -47,11 +40,9 @@ }

public void hide(final PluginCall call) {
execute(
() -> {
if (!implementation.hide()) {
call.reject("Can't close keyboard, not currently focused");
} else {
call.resolve();
}
execute(() -> {
if (!implementation.hide()) {
call.reject("Can't close keyboard, not currently focused");
} else {
call.resolve();
}
);
});
}

@@ -58,0 +49,0 @@

@@ -19,3 +19,3 @@ {

],
"docs": "Show the keyboard. This method is alpha and may have issues.\n\nThis method is only supported on Android.",
"docs": "Show the keyboard.\n\nThis method is only supported on Android.",
"complexTypes": [],

@@ -358,3 +358,3 @@ "slug": "show"

],
"docs": "Height of the heyboard.",
"docs": "Height of the keyboard.",
"complexTypes": [],

@@ -402,3 +402,3 @@ "type": "number"

],
"docs": "On iOS 13 and newer the keyboard style is based on the device appearance.\nIf the device is using Dark mode, the keyboard will be dark.\nIf the device is using Light mode, the keyboard will be light.\nOn iOS 12 the keyboard will be light."
"docs": "The keyboard style is based on the device appearance.\nIf the device is using Dark mode, the keyboard will be dark.\nIf the device is using Light mode, the keyboard will be light."
}

@@ -519,7 +519,27 @@ ]

"type": "boolean | undefined"
},
{
"name": "autoBackdropColor",
"tags": [
{
"text": "8.0.4",
"name": "since"
},
{
"text": "\"off\"",
"name": "default"
},
{
"text": "\"auto\"",
"name": "example"
}
],
"docs": "Controls how the keyboard backdrop color (the area visible behind the\nkeyboard) is set every time the keyboard is about to show.\n\n- `'off'` — Do not tint the backdrop.\n- `'auto'` — Use the `backgroundColor` set in the Capacitor config;\n otherwise derive the color from the web app's DOM body background.\n- `'dom'` — Always derive the color from the web app's DOM body\n background, ignoring the `backgroundColor` config. If the DOM\n has no resolvable background, the backdrop is left untouched.\n\nOnly available on iOS.",
"complexTypes": [],
"type": "'auto' | 'off' | 'dom' | undefined"
}
],
"docs": "On iOS, the keyboard can be configured with the following options:"
"docs": "The keyboard can be configured with the following options:"
}
]
}

@@ -5,3 +5,3 @@ import type { PluginListenerHandle } from '@capacitor/core';

/**
* On iOS, the keyboard can be configured with the following options:
* The keyboard can be configured with the following options:
*/

@@ -40,2 +40,20 @@ Keyboard?: {

resizeOnFullScreen?: boolean;
/**
* Controls how the keyboard backdrop color (the area visible behind the
* keyboard) is set every time the keyboard is about to show.
*
* - `'off'` — Do not tint the backdrop.
* - `'auto'` — Use the `backgroundColor` set in the Capacitor config;
* otherwise derive the color from the web app's DOM body background.
* - `'dom'` — Always derive the color from the web app's DOM body
* background, ignoring the `backgroundColor` config. If the DOM
* has no resolvable background, the backdrop is left untouched.
*
* Only available on iOS.
*
* @since 8.0.4
* @default "off"
* @example "auto"
*/
autoBackdropColor?: 'off' | 'auto' | 'dom';
};

@@ -46,3 +64,3 @@ }

/**
* Height of the heyboard.
* Height of the keyboard.
*

@@ -76,6 +94,5 @@ * @since 1.0.0

/**
* On iOS 13 and newer the keyboard style is based on the device appearance.
* The keyboard style is based on the device appearance.
* If the device is using Dark mode, the keyboard will be dark.
* If the device is using Light mode, the keyboard will be light.
* On iOS 12 the keyboard will be light.
*

@@ -125,3 +142,3 @@ * @since 1.0.0

/**
* Show the keyboard. This method is alpha and may have issues.
* Show the keyboard.
*

@@ -128,0 +145,0 @@ * This method is only supported on Android.

@@ -17,6 +17,5 @@ /// <reference types="@capacitor/cli" />

/**
* On iOS 13 and newer the keyboard style is based on the device appearance.
* The keyboard style is based on the device appearance.
* If the device is using Dark mode, the keyboard will be dark.
* If the device is using Light mode, the keyboard will be light.
* On iOS 12 the keyboard will be light.
*

@@ -23,0 +22,0 @@ * @since 1.0.0

@@ -1,1 +0,1 @@

{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAkExC,MAAM,CAAN,IAAY,aAwBX;AAxBD,WAAY,aAAa;IACvB;;;;OAIG;IACH,8BAAa,CAAA;IAEb;;;;OAIG;IACH,gCAAe,CAAA;IAEf;;;;;;;OAOG;IACH,oCAAmB,CAAA;AACrB,CAAC,EAxBW,aAAa,KAAb,aAAa,QAwBxB;AAWD,MAAM,CAAN,IAAY,cA+BX;AA/BD,WAAY,cAAc;IACxB;;;;;OAKG;IACH,+BAAa,CAAA;IAEb;;;;;OAKG;IACH,iCAAe,CAAA;IAEf;;;;;OAKG;IACH,mCAAiB,CAAA;IAEjB;;;;OAIG;IACH,+BAAa,CAAA;AACf,CAAC,EA/BW,cAAc,KAAd,cAAc,QA+BzB","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * On iOS, the keyboard can be configured with the following options:\n */\n Keyboard?: {\n /**\n * Configure the way the app is resized when the Keyboard appears.\n *\n * Only available on iOS.\n *\n * @since 1.0.0\n * @default native\n * @example \"body\"\n */\n resize?: KeyboardResize;\n\n /**\n * Override the keyboard style if your app doesn't support dark/light theme changes.\n * If not set, the keyboard style will depend on the device appearance.\n *\n * Only available on iOS.\n *\n * @since 1.0.0\n * @example \"DARK\"\n */\n style?: KeyboardStyle;\n\n /**\n * There is an Android bug that prevents the keyboard from resizing the WebView\n * when the app is in full screen (i.e. if StatusBar plugin is used to overlay the status bar).\n * This setting, if set to true, add a workaround that resizes the WebView even when the app is in full screen.\n *\n * Only available for Android\n *\n * @since 1.1.0\n * @example true\n */\n resizeOnFullScreen?: boolean;\n };\n }\n}\n\nexport interface KeyboardInfo {\n /**\n * Height of the heyboard.\n *\n * @since 1.0.0\n */\n keyboardHeight: number;\n}\n\nexport interface KeyboardStyleOptions {\n /**\n * Style of the keyboard.\n *\n * @since 1.0.0\n * @default KeyboardStyle.Default\n */\n style: KeyboardStyle;\n}\n\nexport enum KeyboardStyle {\n /**\n * Dark keyboard.\n *\n * @since 1.0.0\n */\n Dark = 'DARK',\n\n /**\n * Light keyboard.\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n\n /**\n * On iOS 13 and newer the keyboard style is based on the device appearance.\n * If the device is using Dark mode, the keyboard will be dark.\n * If the device is using Light mode, the keyboard will be light.\n * On iOS 12 the keyboard will be light.\n *\n * @since 1.0.0\n */\n Default = 'DEFAULT',\n}\n\nexport interface KeyboardResizeOptions {\n /**\n * Mode used to resize elements when the keyboard appears.\n *\n * @since 1.0.0\n */\n mode: KeyboardResize;\n}\n\nexport enum KeyboardResize {\n /**\n * Only the `body` HTML element will be resized.\n * Relative units are not affected, because the viewport does not change.\n *\n * @since 1.0.0\n */\n Body = 'body',\n\n /**\n * Only the `ion-app` HTML element will be resized.\n * Use it only for Ionic Framework apps.\n *\n * @since 1.0.0\n */\n Ionic = 'ionic',\n\n /**\n * The whole native Web View will be resized when the keyboard shows/hides.\n * This affects the `vh` relative unit.\n *\n * @since 1.0.0\n */\n Native = 'native',\n\n /**\n * Neither the app nor the Web View are resized.\n *\n * @since 1.0.0\n */\n None = 'none',\n}\n\nexport interface KeyboardPlugin {\n /**\n * Show the keyboard. This method is alpha and may have issues.\n *\n * This method is only supported on Android.\n *\n * @since 1.0.0\n */\n show(): Promise<void>;\n\n /**\n * Hide the keyboard.\n *\n * @since 1.0.0\n */\n hide(): Promise<void>;\n\n /**\n * Set whether the accessory bar should be visible on the keyboard. We recommend disabling\n * the accessory bar for short forms (login, signup, etc.) to provide a cleaner UI.\n *\n * This method is only supported on iPhone devices.\n *\n * @since 1.0.0\n */\n setAccessoryBarVisible(options: { isVisible: boolean }): Promise<void>;\n\n /**\n * Programmatically enable or disable the WebView scroll.\n *\n * This method is only supported on iOS.\n *\n * @since 1.0.0\n */\n setScroll(options: { isDisabled: boolean }): Promise<void>;\n\n /**\n * Programmatically set the keyboard style.\n *\n * This method is only supported on iOS.\n *\n * @since 1.0.0\n */\n setStyle(options: KeyboardStyleOptions): Promise<void>;\n\n /**\n * Programmatically set the resize mode.\n *\n * This method is only supported on iOS.\n *\n * @since 1.0.0\n */\n setResizeMode(options: KeyboardResizeOptions): Promise<void>;\n\n /**\n * Get the currently set resize mode.\n *\n * This method is only supported on iOS.\n *\n * @since 4.0.0\n */\n getResizeMode(): Promise<KeyboardResizeOptions>;\n\n /**\n * Listen for when the keyboard is about to be shown.\n *\n * On Android keyboardWillShow and keyboardDidShow fire almost at the same time.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'keyboardWillShow',\n listenerFunc: (info: KeyboardInfo) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for when the keyboard is shown.\n *\n * On Android keyboardWillShow and keyboardDidShow fire almost at the same time.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'keyboardDidShow',\n listenerFunc: (info: KeyboardInfo) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for when the keyboard is about to be hidden.\n *\n * On Android keyboardWillHide and keyboardDidHide fire almost at the same time.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'keyboardWillHide',\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for when the keyboard is hidden.\n *\n * On Android keyboardWillHide and keyboardDidHide fire almost at the same time.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'keyboardDidHide',\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all native listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n"]}
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAqFxC,MAAM,CAAN,IAAY,aAuBX;AAvBD,WAAY,aAAa;IACvB;;;;OAIG;IACH,8BAAa,CAAA;IAEb;;;;OAIG;IACH,gCAAe,CAAA;IAEf;;;;;;OAMG;IACH,oCAAmB,CAAA;AACrB,CAAC,EAvBW,aAAa,KAAb,aAAa,QAuBxB;AAWD,MAAM,CAAN,IAAY,cA+BX;AA/BD,WAAY,cAAc;IACxB;;;;;OAKG;IACH,+BAAa,CAAA;IAEb;;;;;OAKG;IACH,iCAAe,CAAA;IAEf;;;;;OAKG;IACH,mCAAiB,CAAA;IAEjB;;;;OAIG;IACH,+BAAa,CAAA;AACf,CAAC,EA/BW,cAAc,KAAd,cAAc,QA+BzB","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * The keyboard can be configured with the following options:\n */\n Keyboard?: {\n /**\n * Configure the way the app is resized when the Keyboard appears.\n *\n * Only available on iOS.\n *\n * @since 1.0.0\n * @default native\n * @example \"body\"\n */\n resize?: KeyboardResize;\n\n /**\n * Override the keyboard style if your app doesn't support dark/light theme changes.\n * If not set, the keyboard style will depend on the device appearance.\n *\n * Only available on iOS.\n *\n * @since 1.0.0\n * @example \"DARK\"\n */\n style?: KeyboardStyle;\n\n /**\n * There is an Android bug that prevents the keyboard from resizing the WebView\n * when the app is in full screen (i.e. if StatusBar plugin is used to overlay the status bar).\n * This setting, if set to true, add a workaround that resizes the WebView even when the app is in full screen.\n *\n * Only available for Android\n *\n * @since 1.1.0\n * @example true\n */\n resizeOnFullScreen?: boolean;\n\n /**\n * Controls how the keyboard backdrop color (the area visible behind the\n * keyboard) is set every time the keyboard is about to show.\n *\n * - `'off'` — Do not tint the backdrop.\n * - `'auto'` — Use the `backgroundColor` set in the Capacitor config;\n * otherwise derive the color from the web app's DOM body background.\n * - `'dom'` — Always derive the color from the web app's DOM body\n * background, ignoring the `backgroundColor` config. If the DOM\n * has no resolvable background, the backdrop is left untouched.\n *\n * Only available on iOS.\n *\n * @since 8.0.4\n * @default \"off\"\n * @example \"auto\"\n */\n autoBackdropColor?: 'off' | 'auto' | 'dom';\n };\n }\n}\n\nexport interface KeyboardInfo {\n /**\n * Height of the keyboard.\n *\n * @since 1.0.0\n */\n keyboardHeight: number;\n}\n\nexport interface KeyboardStyleOptions {\n /**\n * Style of the keyboard.\n *\n * @since 1.0.0\n * @default KeyboardStyle.Default\n */\n style: KeyboardStyle;\n}\n\nexport enum KeyboardStyle {\n /**\n * Dark keyboard.\n *\n * @since 1.0.0\n */\n Dark = 'DARK',\n\n /**\n * Light keyboard.\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n\n /**\n * The keyboard style is based on the device appearance.\n * If the device is using Dark mode, the keyboard will be dark.\n * If the device is using Light mode, the keyboard will be light.\n *\n * @since 1.0.0\n */\n Default = 'DEFAULT',\n}\n\nexport interface KeyboardResizeOptions {\n /**\n * Mode used to resize elements when the keyboard appears.\n *\n * @since 1.0.0\n */\n mode: KeyboardResize;\n}\n\nexport enum KeyboardResize {\n /**\n * Only the `body` HTML element will be resized.\n * Relative units are not affected, because the viewport does not change.\n *\n * @since 1.0.0\n */\n Body = 'body',\n\n /**\n * Only the `ion-app` HTML element will be resized.\n * Use it only for Ionic Framework apps.\n *\n * @since 1.0.0\n */\n Ionic = 'ionic',\n\n /**\n * The whole native Web View will be resized when the keyboard shows/hides.\n * This affects the `vh` relative unit.\n *\n * @since 1.0.0\n */\n Native = 'native',\n\n /**\n * Neither the app nor the Web View are resized.\n *\n * @since 1.0.0\n */\n None = 'none',\n}\n\nexport interface KeyboardPlugin {\n /**\n * Show the keyboard.\n *\n * This method is only supported on Android.\n *\n * @since 1.0.0\n */\n show(): Promise<void>;\n\n /**\n * Hide the keyboard.\n *\n * @since 1.0.0\n */\n hide(): Promise<void>;\n\n /**\n * Set whether the accessory bar should be visible on the keyboard. We recommend disabling\n * the accessory bar for short forms (login, signup, etc.) to provide a cleaner UI.\n *\n * This method is only supported on iPhone devices.\n *\n * @since 1.0.0\n */\n setAccessoryBarVisible(options: { isVisible: boolean }): Promise<void>;\n\n /**\n * Programmatically enable or disable the WebView scroll.\n *\n * This method is only supported on iOS.\n *\n * @since 1.0.0\n */\n setScroll(options: { isDisabled: boolean }): Promise<void>;\n\n /**\n * Programmatically set the keyboard style.\n *\n * This method is only supported on iOS.\n *\n * @since 1.0.0\n */\n setStyle(options: KeyboardStyleOptions): Promise<void>;\n\n /**\n * Programmatically set the resize mode.\n *\n * This method is only supported on iOS.\n *\n * @since 1.0.0\n */\n setResizeMode(options: KeyboardResizeOptions): Promise<void>;\n\n /**\n * Get the currently set resize mode.\n *\n * This method is only supported on iOS.\n *\n * @since 4.0.0\n */\n getResizeMode(): Promise<KeyboardResizeOptions>;\n\n /**\n * Listen for when the keyboard is about to be shown.\n *\n * On Android keyboardWillShow and keyboardDidShow fire almost at the same time.\n *\n * @since 1.0.0\n */\n addListener(eventName: 'keyboardWillShow', listenerFunc: (info: KeyboardInfo) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for when the keyboard is shown.\n *\n * On Android keyboardWillShow and keyboardDidShow fire almost at the same time.\n *\n * @since 1.0.0\n */\n addListener(eventName: 'keyboardDidShow', listenerFunc: (info: KeyboardInfo) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for when the keyboard is about to be hidden.\n *\n * On Android keyboardWillHide and keyboardDidHide fire almost at the same time.\n *\n * @since 1.0.0\n */\n addListener(eventName: 'keyboardWillHide', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for when the keyboard is hidden.\n *\n * On Android keyboardWillHide and keyboardDidHide fire almost at the same time.\n *\n * @since 1.0.0\n */\n addListener(eventName: 'keyboardDidHide', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Remove all native listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n"]}

@@ -21,6 +21,5 @@ 'use strict';

/**
* On iOS 13 and newer the keyboard style is based on the device appearance.
* The keyboard style is based on the device appearance.
* If the device is using Dark mode, the keyboard will be dark.
* If the device is using Light mode, the keyboard will be light.
* On iOS 12 the keyboard will be light.
*

@@ -27,0 +26,0 @@ * @since 1.0.0

@@ -1,1 +0,1 @@

{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\nexport var KeyboardStyle;\n(function (KeyboardStyle) {\n /**\n * Dark keyboard.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Dark\"] = \"DARK\";\n /**\n * Light keyboard.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Light\"] = \"LIGHT\";\n /**\n * On iOS 13 and newer the keyboard style is based on the device appearance.\n * If the device is using Dark mode, the keyboard will be dark.\n * If the device is using Light mode, the keyboard will be light.\n * On iOS 12 the keyboard will be light.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Default\"] = \"DEFAULT\";\n})(KeyboardStyle || (KeyboardStyle = {}));\nexport var KeyboardResize;\n(function (KeyboardResize) {\n /**\n * Only the `body` HTML element will be resized.\n * Relative units are not affected, because the viewport does not change.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Body\"] = \"body\";\n /**\n * Only the `ion-app` HTML element will be resized.\n * Use it only for Ionic Framework apps.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Ionic\"] = \"ionic\";\n /**\n * The whole native Web View will be resized when the keyboard shows/hides.\n * This affects the `vh` relative unit.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Native\"] = \"native\";\n /**\n * Neither the app nor the Web View are resized.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"None\"] = \"none\";\n})(KeyboardResize || (KeyboardResize = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst Keyboard = registerPlugin('Keyboard');\nexport * from './definitions';\nexport { Keyboard };\n//# sourceMappingURL=index.js.map"],"names":["KeyboardStyle","KeyboardResize","registerPlugin"],"mappings":";;;;AAAA;AACWA;AACX,CAAC,UAAU,aAAa,EAAE;AAC1B;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;AAClC;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS;AACxC,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;AAC9BC;AACX,CAAC,UAAU,cAAc,EAAE;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACvC;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;AACnC,CAAC,EAAEA,sBAAc,KAAKA,sBAAc,GAAG,EAAE,CAAC,CAAC;;ACrDtC,MAAC,QAAQ,GAAGC,mBAAc,CAAC,UAAU;;;;"}
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\nexport var KeyboardStyle;\n(function (KeyboardStyle) {\n /**\n * Dark keyboard.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Dark\"] = \"DARK\";\n /**\n * Light keyboard.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Light\"] = \"LIGHT\";\n /**\n * The keyboard style is based on the device appearance.\n * If the device is using Dark mode, the keyboard will be dark.\n * If the device is using Light mode, the keyboard will be light.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Default\"] = \"DEFAULT\";\n})(KeyboardStyle || (KeyboardStyle = {}));\nexport var KeyboardResize;\n(function (KeyboardResize) {\n /**\n * Only the `body` HTML element will be resized.\n * Relative units are not affected, because the viewport does not change.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Body\"] = \"body\";\n /**\n * Only the `ion-app` HTML element will be resized.\n * Use it only for Ionic Framework apps.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Ionic\"] = \"ionic\";\n /**\n * The whole native Web View will be resized when the keyboard shows/hides.\n * This affects the `vh` relative unit.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Native\"] = \"native\";\n /**\n * Neither the app nor the Web View are resized.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"None\"] = \"none\";\n})(KeyboardResize || (KeyboardResize = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst Keyboard = registerPlugin('Keyboard');\nexport * from './definitions';\nexport { Keyboard };\n//# sourceMappingURL=index.js.map"],"names":["KeyboardStyle","KeyboardResize","registerPlugin"],"mappings":";;;;AAAA;AACWA;AACX,CAAC,UAAU,aAAa,EAAE;AAC1B;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;AAClC;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS;AACxC,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;AAC9BC;AACX,CAAC,UAAU,cAAc,EAAE;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACvC;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;AACnC,CAAC,EAAEA,sBAAc,KAAKA,sBAAc,GAAG,EAAE,CAAC,CAAC;;ACpDtC,MAAC,QAAQ,GAAGC,mBAAc,CAAC,UAAU;;;;"}

@@ -20,6 +20,5 @@ var capacitorKeyboard = (function (exports, core) {

/**
* On iOS 13 and newer the keyboard style is based on the device appearance.
* The keyboard style is based on the device appearance.
* If the device is using Dark mode, the keyboard will be dark.
* If the device is using Light mode, the keyboard will be light.
* On iOS 12 the keyboard will be light.
*

@@ -26,0 +25,0 @@ * @since 1.0.0

@@ -1,1 +0,1 @@

{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\nexport var KeyboardStyle;\n(function (KeyboardStyle) {\n /**\n * Dark keyboard.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Dark\"] = \"DARK\";\n /**\n * Light keyboard.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Light\"] = \"LIGHT\";\n /**\n * On iOS 13 and newer the keyboard style is based on the device appearance.\n * If the device is using Dark mode, the keyboard will be dark.\n * If the device is using Light mode, the keyboard will be light.\n * On iOS 12 the keyboard will be light.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Default\"] = \"DEFAULT\";\n})(KeyboardStyle || (KeyboardStyle = {}));\nexport var KeyboardResize;\n(function (KeyboardResize) {\n /**\n * Only the `body` HTML element will be resized.\n * Relative units are not affected, because the viewport does not change.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Body\"] = \"body\";\n /**\n * Only the `ion-app` HTML element will be resized.\n * Use it only for Ionic Framework apps.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Ionic\"] = \"ionic\";\n /**\n * The whole native Web View will be resized when the keyboard shows/hides.\n * This affects the `vh` relative unit.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Native\"] = \"native\";\n /**\n * Neither the app nor the Web View are resized.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"None\"] = \"none\";\n})(KeyboardResize || (KeyboardResize = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst Keyboard = registerPlugin('Keyboard');\nexport * from './definitions';\nexport { Keyboard };\n//# sourceMappingURL=index.js.map"],"names":["KeyboardStyle","KeyboardResize","registerPlugin"],"mappings":";;;IAAA;AACWA;IACX,CAAC,UAAU,aAAa,EAAE;IAC1B;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;IAClC;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO;IACpC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS;IACxC,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;AAC9BC;IACX,CAAC,UAAU,cAAc,EAAE;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;IACnC;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO;IACrC;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,QAAQ;IACvC;IACA;IACA;IACA;IACA;IACA,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;IACnC,CAAC,EAAEA,sBAAc,KAAKA,sBAAc,GAAG,EAAE,CAAC,CAAC;;ACrDtC,UAAC,QAAQ,GAAGC,mBAAc,CAAC,UAAU;;;;;;;;;;"}
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\nexport var KeyboardStyle;\n(function (KeyboardStyle) {\n /**\n * Dark keyboard.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Dark\"] = \"DARK\";\n /**\n * Light keyboard.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Light\"] = \"LIGHT\";\n /**\n * The keyboard style is based on the device appearance.\n * If the device is using Dark mode, the keyboard will be dark.\n * If the device is using Light mode, the keyboard will be light.\n *\n * @since 1.0.0\n */\n KeyboardStyle[\"Default\"] = \"DEFAULT\";\n})(KeyboardStyle || (KeyboardStyle = {}));\nexport var KeyboardResize;\n(function (KeyboardResize) {\n /**\n * Only the `body` HTML element will be resized.\n * Relative units are not affected, because the viewport does not change.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Body\"] = \"body\";\n /**\n * Only the `ion-app` HTML element will be resized.\n * Use it only for Ionic Framework apps.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Ionic\"] = \"ionic\";\n /**\n * The whole native Web View will be resized when the keyboard shows/hides.\n * This affects the `vh` relative unit.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"Native\"] = \"native\";\n /**\n * Neither the app nor the Web View are resized.\n *\n * @since 1.0.0\n */\n KeyboardResize[\"None\"] = \"none\";\n})(KeyboardResize || (KeyboardResize = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst Keyboard = registerPlugin('Keyboard');\nexport * from './definitions';\nexport { Keyboard };\n//# sourceMappingURL=index.js.map"],"names":["KeyboardStyle","KeyboardResize","registerPlugin"],"mappings":";;;IAAA;AACWA;IACX,CAAC,UAAU,aAAa,EAAE;IAC1B;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;IAClC;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO;IACpC;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS;IACxC,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;AAC9BC;IACX,CAAC,UAAU,cAAc,EAAE;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;IACnC;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO;IACrC;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,QAAQ;IACvC;IACA;IACA;IACA;IACA;IACA,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;IACnC,CAAC,EAAEA,sBAAc,KAAKA,sBAAc,GAAG,EAAE,CAAC,CAAC;;ACpDtC,UAAC,QAAQ,GAAGC,mBAAc,CAAC,UAAU;;;;;;;;;;"}

@@ -21,2 +21,3 @@ /*

#import <objc/runtime.h>
#import <UIKit/UIKit.h>
#import <Capacitor/Capacitor.h>

@@ -57,4 +58,136 @@ #import <Capacitor/Capacitor-Swift.h>

NSString* UITraitsClassString;
double stageManagerOffset;
#pragma mark - Helpers
- (UIWindow *)currentKeyWindow {
UIWindow *window = nil;
if ([[[UIApplication sharedApplication] delegate] respondsToSelector:@selector(window)]) {
window = [[[UIApplication sharedApplication] delegate] window];
}
if (!window) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self isKindOfClass: %@", UIWindowScene.class];
UIScene *scene = [UIApplication.sharedApplication.connectedScenes.allObjects filteredArrayUsingPredicate:predicate].firstObject;
window = [[(UIWindowScene*)scene windows] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isKeyWindow == YES"]].firstObject;
}
return window;
}
- (void)forceBackdropColor:(UIColor *)color {
UIWindow *w = [self currentKeyWindow];
if (w) {
dispatch_async(dispatch_get_main_queue(), ^{
w.backgroundColor = color;
});
}
}
- (BOOL)isIPad {
return ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
}
- (BOOL)shouldIgnoreResizeForHeight:(double)height {
if (![self isIPad]) return NO;
if (height <= 0.0) return NO;
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
return (height / screenHeight) < 0.20;
}
- (BOOL)isFullKeyboardFrame:(CGRect)rect {
return ![self shouldIgnoreResizeForHeight:rect.size.height];
}
- (double)keyboardHeightFromFrame:(CGRect)rect {
if (![self isIPad]) {
return rect.size.height;
}
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
CGFloat keyboardTop = CGRectGetMinY(rect);
if (keyboardTop >= screenHeight) {
return 0;
}
double height;
if ([self isFullKeyboardFrame:rect]) {
height = screenHeight - keyboardTop;
} else {
height = rect.size.height;
}
return height < 0 ? 0 : height;
}
- (double)normalizedKeyboardHeightFromFrame:(CGRect)rect {
double height = [self keyboardHeightFromFrame:rect];
if ([self shouldIgnoreResizeForHeight:height]) {
return 0.0;
}
return height;
}
#pragma mark - Lifecycle
- (UIColor *)colorFromCssColorString:(NSString *)cssColor {
NSString *trimmed = [cssColor stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([trimmed isEqualToString:@"transparent"]) {
return [UIColor clearColor];
}
if ([trimmed hasPrefix:@"rgb"]) {
NSRange parenRange = [trimmed rangeOfString:@"("];
NSString *clean = parenRange.location != NSNotFound ? [trimmed substringFromIndex:parenRange.location + 1] : trimmed;
clean = [clean stringByReplacingOccurrencesOfString:@")" withString:@""];
NSArray *parts = [clean componentsSeparatedByString:@","];
if (parts.count >= 3) {
CGFloat r = [parts[0] floatValue] / 255.0;
CGFloat g = [parts[1] floatValue] / 255.0;
CGFloat b = [parts[2] floatValue] / 255.0;
CGFloat a = parts.count >= 4 ? [parts[3] floatValue] : 1.0;
return [UIColor colorWithRed:r green:g blue:b alpha:a];
}
}
if ([trimmed hasPrefix:@"#"]) {
unsigned rgbValue = 0;
NSScanner *scanner = [NSScanner scannerWithString:trimmed];
[scanner setScanLocation:1];
if ([scanner scanHexInt:&rgbValue]) {
CGFloat r = ((rgbValue & 0xFF0000) >> 16) / 255.0;
CGFloat g = ((rgbValue & 0x00FF00) >> 8) / 255.0;
CGFloat b = (rgbValue & 0x0000FF) / 255.0;
return [UIColor colorWithRed:r green:g blue:b alpha:1.0];
}
}
return [UIColor whiteColor]; // fallback
}
- (void)updateBackdropColor {
NSString *mode = [[self getConfig] getString:@"autoBackdropColor": @"off"];
if ([mode isEqualToString:@"auto"]) {
if (self.bridge.config.backgroundColor) {
[self forceBackdropColor:self.bridge.config.backgroundColor];
} else {
[self updateBackdropColorFromDOM];
}
} else if ([mode isEqualToString:@"dom"]) {
[self updateBackdropColorFromDOM];
}
}
- (void)updateBackdropColorFromDOM {
if (!self.webView) return;
[self.webView evaluateJavaScript:@"window.getComputedStyle(document.body).backgroundColor" completionHandler:^(id result, NSError *error) {
if (result && [result isKindOfClass:[NSString class]]) {
UIColor *color = [self colorFromCssColorString:(NSString *)result];
if (color) {
[self forceBackdropColor:color];
}
}
}];
}
- (void)load

@@ -105,5 +238,6 @@ {

[nc removeObserver:self.webView name:UIKeyboardDidChangeFrameNotification object:nil];
[self updateBackdropColor];
}
#pragma mark Keyboard events

@@ -133,32 +267,11 @@

}
// Force DOM color whenever keyboard shows
[self updateBackdropColor];
CGRect rect = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
double height = [self normalizedKeyboardHeightFromFrame:rect];
double height = rect.size.height;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
CGFloat keyboardTop = CGRectGetMinY(rect);
CGFloat keyboardBottom = CGRectGetMaxY(rect);
CGFloat keyboardFrameHeight = rect.size.height;
// Check if this is a full keyboard or just accessory bar
// Full keyboard is typically > 250px, accessory bar is < 200px
if (keyboardFrameHeight > 200) {
// Full keyboard - calculate from screen position
// This handles Stage Manager and different window positions correctly
height = screenHeight - keyboardTop;
} else {
// Accessory bar only - use the actual frame height
height = keyboardFrameHeight;
}
NSLog(@"KeyboardPlugin: onKeyboardWillShow - iPad mode, keyboardTop=%.1f, keyboardBottom=%.1f, keyboardFrameHeight=%.1f, screenHeight=%.1f, calculated height=%.1f", keyboardTop, keyboardBottom, keyboardFrameHeight, screenHeight, height);
if (height < 0) {
height = 0;
}
}
double duration = [[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]+0.2;
[self setKeyboardHeight:height delay:duration];
[self setKeyboardHeight:(int)height delay:duration];
[self resetScrollView];

@@ -175,20 +288,3 @@

CGRect rect = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
double height = rect.size.height;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
CGFloat keyboardTop = CGRectGetMinY(rect);
CGFloat keyboardFrameHeight = rect.size.height;
if (keyboardFrameHeight > 200) {
height = screenHeight - keyboardTop;
} else {
height = keyboardFrameHeight;
}
if (height < 0) {
height = 0;
}
}
double height = [self normalizedKeyboardHeightFromFrame:rect];

@@ -208,4 +304,2 @@ [self resetScrollView];

[self resetScrollView];
stageManagerOffset = 0;
}

@@ -215,53 +309,33 @@

{
CGRect rect = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
// Check if keyboard is actually on screen (not moving off-screen)
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
BOOL keyboardOnScreen = CGRectGetMinY(rect) < screenHeight;
CGFloat keyboardTop = CGRectGetMinY(rect);
CGFloat keyboardFrameHeight = rect.size.height;
// Detect full dismissal
if (keyboardTop >= screenHeight) {
self.lastFullDismissalTime = [[NSDate date] timeIntervalSince1970];
}
// Ignore accessory bar if it appears within 0.5s of full dismissal
NSTimeInterval timeSinceFullDismissal = [[NSDate date] timeIntervalSince1970] - self.lastFullDismissalTime;
if (keyboardFrameHeight < 200 && timeSinceFullDismissal < 0.5) {
return;
}
if (![self isIPad]) {
return;
}
double height = rect.size.height;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
CGFloat keyboardTop = CGRectGetMinY(rect);
CGFloat keyboardBottom = CGRectGetMaxY(rect);
CGFloat keyboardFrameHeight = rect.size.height;
// Distinguish between full keyboard and accessory bar by frame height
if (keyboardFrameHeight > 200) {
// Full keyboard - calculate from screen position for Stage Manager support
height = screenHeight - keyboardTop;
} else {
// Accessory bar only - during transitions, iOS reports incorrect sizes
// Skip WillChangeFrame for small keyboards, wait for DidShow with stable value
return;
}
if (height < 0) height = 0;
}
double duration = [[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
NSLog(@"KeyboardPlugin: onKeyboardWillChangeFrame - setting height=%d with duration=%.2f", (int)height, duration);
[self setKeyboardHeight:height delay:duration];
[self resetScrollView];
NSString *data = [NSString stringWithFormat:@"{ 'keyboardHeight': %d }", (int)height];
[self.bridge triggerWindowJSEventWithEventName:@"keyboardWillChangeFrame" data:data];
NSDictionary *kbData = @{@"keyboardHeight": [NSNumber numberWithDouble:height]};
[self notifyListeners:@"keyboardWillChangeFrame" data:kbData];
CGRect rect = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
CGFloat keyboardTop = CGRectGetMinY(rect);
if (keyboardTop >= screenHeight) {
self.lastFullDismissalTime = [[NSDate date] timeIntervalSince1970];
return;
}
NSTimeInterval timeSinceFullDismissal = [[NSDate date] timeIntervalSince1970] - self.lastFullDismissalTime;
if (![self isFullKeyboardFrame:rect] && timeSinceFullDismissal < 0.5) {
return;
}
if (![self isFullKeyboardFrame:rect]) {
return;
}
double height = [self normalizedKeyboardHeightFromFrame:rect];
double duration = [[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[self setKeyboardHeight:(int)height delay:duration];
[self resetScrollView];
NSString *data = [NSString stringWithFormat:@"{ 'keyboardHeight': %d }", (int)height];
[self.bridge triggerWindowJSEventWithEventName:@"keyboardWillChangeFrame" data:data];
NSDictionary *kbData = @{@"keyboardHeight": [NSNumber numberWithDouble:height]};
[self notifyListeners:@"keyboardWillChangeFrame" data:kbData];
}

@@ -271,24 +345,13 @@

{
CGRect rect = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
double height = rect.size.height;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
CGFloat keyboardTop = CGRectGetMinY(rect);
CGFloat keyboardFrameHeight = rect.size.height;
if (keyboardFrameHeight > 200) {
height = screenHeight - keyboardTop;
} else {
height = keyboardFrameHeight;
}
if (height < 0) height = 0;
}
NSString *data = [NSString stringWithFormat:@"{ 'keyboardHeight': %d }", (int)height];
[self.bridge triggerWindowJSEventWithEventName:@"keyboardDidChangeFrame" data:data];
NSDictionary *kbData = @{@"keyboardHeight": [NSNumber numberWithDouble:height]};
[self notifyListeners:@"keyboardDidChangeFrame" data:kbData];
if (![self isIPad]) {
return;
}
CGRect rect = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
double height = [self normalizedKeyboardHeightFromFrame:rect];
NSString *data = [NSString stringWithFormat:@"{ 'keyboardHeight': %d }", (int)height];
[self.bridge triggerWindowJSEventWithEventName:@"keyboardDidChangeFrame" data:data];
NSDictionary *kbData = @{@"keyboardHeight": [NSNumber numberWithDouble:height]};
[self notifyListeners:@"keyboardDidChangeFrame" data:kbData];
}

@@ -327,15 +390,4 @@

CGRect f, wf = CGRectZero;
UIWindow * window = nil;
if ([[[UIApplication sharedApplication] delegate] respondsToSelector:@selector(window)]) {
window = [[[UIApplication sharedApplication] delegate] window];
}
if (!window) {
if (@available(iOS 13.0, *)) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self isKindOfClass: %@", UIWindowScene.class];
UIScene *scene = [UIApplication.sharedApplication.connectedScenes.allObjects filteredArrayUsingPredicate:predicate].firstObject;
window = [[(UIWindowScene*)scene windows] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isKeyWindow == YES"]].firstObject;
}
}
UIWindow *window = [self currentKeyWindow];
if (window) {

@@ -342,0 +394,0 @@ f = [window bounds];

{
"name": "@cantoo/keyboard",
"version": "7.0.4",
"version": "7.0.5",
"description": "The Keyboard API provides keyboard display and visibility control, along with event tracking when the keyboard shows and hides.",

@@ -40,3 +40,3 @@ "main": "dist/plugin.cjs.js",

"eslint": "eslint . --ext ts",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
"swiftlint": "node-swiftlint",

@@ -54,14 +54,21 @@ "docgen": "docgen --api KeyboardPlugin --output-readme README.md --output-json dist/docs.json",

"@capacitor/core": "^7.0.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/docgen": "^0.3.0",
"@capacitor/ios": "^7.0.0",
"@ionic/eslint-config": "^0.4.0",
"@ionic/prettier-config": "~1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@ionic/prettier-config": "^4.0.0",
"@ionic/swiftlint-config": "^2.0.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^7.1.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^12.0.2",
"@semantic-release/npm": "^13.1.2",
"@types/node": "^24.10.1",
"eslint": "^8.57.0",
"prettier": "~2.3.0",
"prettier-plugin-java": "~1.0.2",
"rimraf": "^6.0.1",
"rollup": "^4.26.0",
"swiftlint": "^1.0.1",
"typescript": "~4.1.5"
"prettier": "^3.7.0",
"prettier-plugin-java": "^2.7.7",
"rimraf": "^6.1.2",
"rollup": "^4.53.3",
"semantic-release": "^25.0.2",
"swiftlint": "^2.0.0",
"typescript": "^5.9.3"
},

@@ -68,0 +75,0 @@ "peerDependencies": {

@@ -36,3 +36,3 @@ # @capacitor/keyboard

On iOS, the keyboard can be configured with the following options:
The keyboard can be configured with the following options:

@@ -44,2 +44,3 @@ | Prop | Type | Description | Default | Since |

| **`resizeOnFullScreen`** | <code>boolean</code> | There is an Android bug that prevents the keyboard from resizing the WebView when the app is in full screen (i.e. if StatusBar plugin is used to overlay the status bar). This setting, if set to true, add a workaround that resizes the WebView even when the app is in full screen. Only available for Android | | 1.1.0 |
| **`autoBackdropColor`** | <code>'off' \| 'auto' \| 'dom'</code> | Controls how the keyboard backdrop color (the area visible behind the keyboard) is set every time the keyboard is about to show. `'off'` — Do not tint the backdrop. `'auto'` — Use the `backgroundColor` set in the Capacitor config; otherwise derive the color from the web app's DOM body background. `'dom'` — Always derive the color from the web app's DOM body background, ignoring the `backgroundColor` config. If the DOM has no resolvable background, the backdrop is left untouched. Only available on iOS. | <code>"off"</code> | 8.0.4 |

@@ -56,3 +57,4 @@ ### Examples

"style": "DARK",
"resizeOnFullScreen": true
"resizeOnFullScreen": true,
"autoBackdropColor": "auto"
}

@@ -77,2 +79,3 @@ }

resizeOnFullScreen: true,
autoBackdropColor: 'auto'
},

@@ -126,3 +129,3 @@ },

Show the keyboard. This method is alpha and may have issues.
Show the keyboard.

@@ -372,3 +375,3 @@ This method is only supported on Android.

| -------------------- | ------------------- | ----------------------- | ----- |
| **`keyboardHeight`** | <code>number</code> | Height of the heyboard. | 1.0.0 |
| **`keyboardHeight`** | <code>number</code> | Height of the keyboard. | 1.0.0 |

@@ -381,7 +384,7 @@

| Members | Value | Description | Since |
| ------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`Dark`** | <code>'DARK'</code> | Dark keyboard. | 1.0.0 |
| **`Light`** | <code>'LIGHT'</code> | Light keyboard. | 1.0.0 |
| **`Default`** | <code>'DEFAULT'</code> | On iOS 13 and newer the keyboard style is based on the device appearance. If the device is using Dark mode, the keyboard will be dark. If the device is using Light mode, the keyboard will be light. On iOS 12 the keyboard will be light. | 1.0.0 |
| Members | Value | Description | Since |
| ------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`Dark`** | <code>'DARK'</code> | Dark keyboard. | 1.0.0 |
| **`Light`** | <code>'LIGHT'</code> | Light keyboard. | 1.0.0 |
| **`Default`** | <code>'DEFAULT'</code> | The keyboard style is based on the device appearance. If the device is using Dark mode, the keyboard will be dark. If the device is using Light mode, the keyboard will be light. | 1.0.0 |

@@ -388,0 +391,0 @@

Sorry, the diff of this file is not supported yet