@ionic/core
Version:
Base components for Ionic
82 lines (77 loc) • 2.48 kB
JavaScript
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/
;
const capacitor = require('./capacitor-c04564bf.js');
var ExceptionCode;
(function (ExceptionCode) {
/**
* API is not implemented.
*
* This usually means the API can't be used because it is not implemented for
* the current platform.
*/
ExceptionCode["Unimplemented"] = "UNIMPLEMENTED";
/**
* API is not available.
*
* This means the API can't be used right now because:
* - it is currently missing a prerequisite, such as network connectivity
* - it requires a particular platform or browser version
*/
ExceptionCode["Unavailable"] = "UNAVAILABLE";
})(ExceptionCode || (ExceptionCode = {}));
exports.KeyboardResize = void 0;
(function (KeyboardResize) {
/**
* Only the `body` HTML element will be resized.
* Relative units are not affected, because the viewport does not change.
*
* @since 1.0.0
*/
KeyboardResize["Body"] = "body";
/**
* Only the `ion-app` HTML element will be resized.
* Use it only for Ionic Framework apps.
*
* @since 1.0.0
*/
KeyboardResize["Ionic"] = "ionic";
/**
* The whole native Web View will be resized when the keyboard shows/hides.
* This affects the `vh` relative unit.
*
* @since 1.0.0
*/
KeyboardResize["Native"] = "native";
/**
* Neither the app nor the Web View are resized.
*
* @since 1.0.0
*/
KeyboardResize["None"] = "none";
})(exports.KeyboardResize || (exports.KeyboardResize = {}));
const Keyboard = {
getEngine() {
const capacitor$1 = capacitor.getCapacitor();
if (capacitor$1 === null || capacitor$1 === void 0 ? void 0 : capacitor$1.isPluginAvailable('Keyboard')) {
return capacitor$1.Plugins.Keyboard;
}
return undefined;
},
getResizeMode() {
const engine = this.getEngine();
if (!(engine === null || engine === void 0 ? void 0 : engine.getResizeMode)) {
return Promise.resolve(undefined);
}
return engine.getResizeMode().catch((e) => {
if (e.code === ExceptionCode.Unimplemented) {
// If the native implementation is not available
// we treat it the same as if the plugin is not available.
return undefined;
}
throw e;
});
},
};
exports.Keyboard = Keyboard;