@react-native-ohos/react-native-custom-keyboard 1.0.4-rc.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.
Files changed (43) hide show
  1. package/LICENSE +8 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +13 -0
  4. package/harmony/custom_keyboard/BuildProfile.ets +23 -0
  5. package/harmony/custom_keyboard/Index.ets +7 -0
  6. package/harmony/custom_keyboard/build-profile.json5 +28 -0
  7. package/harmony/custom_keyboard/gitignore +6 -0
  8. package/harmony/custom_keyboard/hvigorfile.ts +12 -0
  9. package/harmony/custom_keyboard/obfuscation-rule.txt +18 -0
  10. package/harmony/custom_keyboard/oh-package.json5 +11 -0
  11. package/harmony/custom_keyboard/src/main/cpp/CMakeLists.txt +9 -0
  12. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardPackage.cpp +25 -0
  13. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardPackage.h +18 -0
  14. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardTurboModuleSpec.cpp +366 -0
  15. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardTurboModuleSpec.h +46 -0
  16. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/RNOH/generated/BaseReactNativeOhTplReactNativeCustomKeyboardPackage.h +75 -0
  17. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/RNOH/generated/turbo_modules/CustomKeyboardNativeModule.cpp +28 -0
  18. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/RNOH/generated/turbo_modules/CustomKeyboardNativeModule.h +21 -0
  19. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/ComponentDescriptors.h +24 -0
  20. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/EventEmitters.cpp +16 -0
  21. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/EventEmitters.h +17 -0
  22. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/Props.cpp +19 -0
  23. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/Props.h +18 -0
  24. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/ShadowNodes.cpp +17 -0
  25. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/ShadowNodes.h +23 -0
  26. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/States.cpp +16 -0
  27. package/harmony/custom_keyboard/src/main/cpp/generated/custom_keyboard/react/renderer/components/custom_keyboard/States.h +19 -0
  28. package/harmony/custom_keyboard/src/main/ets/Logger.ts +64 -0
  29. package/harmony/custom_keyboard/src/main/ets/RNCustomKeyboardPackage.ts +47 -0
  30. package/harmony/custom_keyboard/src/main/ets/RNCustomKeyboardTurboModule.ts +64 -0
  31. package/harmony/custom_keyboard/src/main/ets/generated/components/ts.ts +5 -0
  32. package/harmony/custom_keyboard/src/main/ets/generated/index.ets +8 -0
  33. package/harmony/custom_keyboard/src/main/ets/generated/ts.ts +9 -0
  34. package/harmony/custom_keyboard/src/main/ets/generated/turboModules/CustomKeyboardNativeModule.ts +32 -0
  35. package/harmony/custom_keyboard/src/main/ets/generated/turboModules/ts.ts +8 -0
  36. package/harmony/custom_keyboard/src/main/module.json5 +11 -0
  37. package/harmony/custom_keyboard/ts.ts +8 -0
  38. package/harmony/custom_keyboard.har +0 -0
  39. package/img/rntpc_react-native-custom-keyboard.png +0 -0
  40. package/index.d.ts +17 -0
  41. package/index.js +66 -0
  42. package/package.json +44 -0
  43. package/src/specs/v2/NativeCustomKeyboard.ts +21 -0
@@ -0,0 +1,75 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "RNOH/Package.h"
11
+ #include "RNOH/ArkTSTurboModule.h"
12
+ #include "RNOH/generated/turbo_modules/CustomKeyboardNativeModule.h"
13
+
14
+ namespace rnoh {
15
+
16
+ class BaseReactNativeOhosReactNativeCustomKeyboardPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
17
+ public:
18
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
19
+ if (name == "CustomKeyboardNativeModule") {
20
+ return std::make_shared<CustomKeyboardNativeModule>(ctx, name);
21
+ }
22
+ return nullptr;
23
+ };
24
+ };
25
+
26
+ class BaseReactNativeOhosReactNativeCustomKeyboardPackageEventEmitRequestHandler : public EventEmitRequestHandler {
27
+ public:
28
+ void handleEvent(Context const &ctx) override {
29
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
30
+ auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
31
+
32
+ if (eventEmitter == nullptr) {
33
+ return;
34
+ }
35
+
36
+ std::vector<std::string> supportedComponentNames = {
37
+ };
38
+
39
+ std::vector<std::string> supportedEventNames = {
40
+ };
41
+
42
+ if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
43
+ std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
44
+ eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
45
+ }
46
+ }
47
+ };
48
+
49
+
50
+ class BaseReactNativeOhosReactNativeCustomKeyboardPackage : public Package {
51
+ public:
52
+ BaseReactNativeOhosReactNativeCustomKeyboardPackage(Package::Context ctx) : Package(ctx){};
53
+
54
+ std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
55
+ return std::make_unique<BaseReactNativeOhosReactNativeCustomKeyboardPackageTurboModuleFactoryDelegate>();
56
+ }
57
+
58
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
59
+ return {
60
+ };
61
+ }
62
+
63
+ ComponentJSIBinderByString createComponentJSIBinderByName() override {
64
+ return {
65
+ };
66
+ };
67
+
68
+ EventEmitRequestHandlers createEventEmitRequestHandlers() override {
69
+ return {
70
+ std::make_shared<BaseReactNativeOhosReactNativeCustomKeyboardPackageEventEmitRequestHandler>(),
71
+ };
72
+ }
73
+ };
74
+
75
+ } // namespace rnoh
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ *
7
+ * @generatorVersion: 2
8
+ */
9
+
10
+ #include "CustomKeyboardNativeModule.h"
11
+
12
+ namespace rnoh {
13
+ using namespace facebook;
14
+
15
+ CustomKeyboardNativeModule::CustomKeyboardNativeModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
16
+ methodMap_ = {
17
+ ARK_METHOD_METADATA(install, 2),
18
+ ARK_METHOD_METADATA(uninstall, 1),
19
+ ARK_METHOD_METADATA(insertText, 2),
20
+ ARK_METHOD_METADATA(backSpace, 1),
21
+ ARK_METHOD_METADATA(doDelete, 1),
22
+ ARK_METHOD_METADATA(moveLeft, 1),
23
+ ARK_METHOD_METADATA(moveRight, 1),
24
+ ARK_METHOD_METADATA(switchSystemKeyboard, 1),
25
+ };
26
+ }
27
+
28
+ } // namespace rnoh
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ *
7
+ * @generatorVersion: 2
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include "RNOH/ArkTSTurboModule.h"
13
+
14
+ namespace rnoh {
15
+
16
+ class JSI_EXPORT CustomKeyboardNativeModule : public ArkTSTurboModule {
17
+ public:
18
+ CustomKeyboardNativeModule(const ArkTSTurboModule::Context ctx, const std::string name);
19
+ };
20
+
21
+ } // namespace rnoh
@@ -0,0 +1,24 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "ShadowNodes.h"
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
16
+
17
+ namespace facebook::react {
18
+
19
+
20
+
21
+ void _react_native_ohos_react_native_custom_keyboard_registerComponentDescriptorsFromCodegen(
22
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
23
+
24
+ } // namespace facebook::react
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterCpp.js
9
+ */
10
+
11
+ #include "EventEmitters.h"
12
+
13
+
14
+ namespace facebook::react {
15
+
16
+ } // namespace facebook::react
@@ -0,0 +1,17 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterH.js
9
+ */
10
+ #pragma once
11
+
12
+ #include <react/renderer/components/view/ViewEventEmitter.h>
13
+
14
+
15
+ namespace facebook::react {
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,19 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsCpp.js
9
+ */
10
+
11
+ #include "Props.h"
12
+ #include <react/renderer/core/PropsParserContext.h>
13
+ #include <react/renderer/core/propsConversions.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+
19
+ } // namespace facebook::react
@@ -0,0 +1,18 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsH.js
9
+ */
10
+ #pragma once
11
+
12
+
13
+
14
+ namespace facebook::react {
15
+
16
+
17
+
18
+ } // namespace facebook::react
@@ -0,0 +1,17 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateShadowNodeCpp.js
9
+ */
10
+
11
+ #include "ShadowNodes.h"
12
+
13
+ namespace facebook::react {
14
+
15
+
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,23 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateShadowNodeH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "EventEmitters.h"
14
+ #include "Props.h"
15
+ #include "States.h"
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <jsi/jsi.h>
18
+
19
+ namespace facebook::react {
20
+
21
+
22
+
23
+ } // namespace facebook::react
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateStateCpp.js
9
+ */
10
+ #include "States.h"
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+ } // namespace facebook::react
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateStateH.js
8
+ */
9
+ #pragma once
10
+
11
+ #ifdef ANDROID
12
+ #include <folly/dynamic.h>
13
+ #endif
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+
19
+ } // namespace facebook::react
@@ -0,0 +1,64 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import hilog from '@ohos.hilog';
26
+
27
+ class Logger {
28
+ private domain: number;
29
+ private prefix: string;
30
+ private format: string = '%{public}s, %{public}s';
31
+ private isDebug: boolean;
32
+
33
+ /**
34
+ * constructor.
35
+ *
36
+ * @param Prefix Identifies the log tag.
37
+ * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
38
+ */
39
+ constructor(prefix: string = 'RNCustomKeyboardTurboModule', domain: number = 0xFF00, isDebug = true) {
40
+ this.prefix = prefix;
41
+ this.domain = domain;
42
+ this.isDebug = isDebug;
43
+ }
44
+
45
+ debug(...args: string[]): void {
46
+ if (this.isDebug) {
47
+ hilog.debug(this.domain, this.prefix, this.format, args);
48
+ }
49
+ }
50
+
51
+ info(...args: string[]): void {
52
+ hilog.info(this.domain, this.prefix, this.format, args);
53
+ }
54
+
55
+ warn(...args: string[]): void {
56
+ hilog.warn(this.domain, this.prefix, this.format, args);
57
+ }
58
+
59
+ error(...args: string[]): void {
60
+ hilog.error(this.domain, this.prefix, this.format, args);
61
+ }
62
+ }
63
+
64
+ export default new Logger('RNCustomKeyboardTurboModule', 0xFF00, true)
@@ -0,0 +1,47 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
26
+ import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
27
+ import { TM } from './generated/ts'
28
+ import { RNCustomKeyboardTurboModule } from './RNCustomKeyboardTurboModule';
29
+
30
+ class RNCustomKeyboardTurboModuleFactory extends TurboModulesFactory {
31
+ createTurboModule(name: string): TurboModule | null {
32
+ if (this.hasTurboModule(name)) {
33
+ return new RNCustomKeyboardTurboModule(this.ctx);
34
+ }
35
+ return null;
36
+ }
37
+
38
+ hasTurboModule(name: string): boolean {
39
+ return name === TM.CustomKeyboardNativeModule.NAME;
40
+ }
41
+ }
42
+
43
+ export class RNCustomKeyboardPackage extends RNPackage {
44
+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
45
+ return new RNCustomKeyboardTurboModuleFactory(ctx);
46
+ }
47
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { TurboModule } from '@rnoh/react-native-openharmony/ts';
26
+ import { TM } from './generated/ts';
27
+
28
+ export class RNCustomKeyboardTurboModule extends TurboModule implements TM.CustomKeyboardNativeModule.Spec {
29
+ constructor(ctx) {
30
+ super(ctx);
31
+ }
32
+ install(tag: number, type: string)
33
+ {
34
+ console.log("install");
35
+ }
36
+ uninstall(tag: number)
37
+ {
38
+ console.log("uninstall");
39
+ }
40
+ insertText(tag: number, text: string | number)
41
+ {
42
+ console.log("insertText");
43
+ }
44
+ backSpace(tag: number)
45
+ {
46
+ console.log("backSpace");
47
+ }
48
+ doDelete(tag: number)
49
+ {
50
+ console.log("doDelete");
51
+ }
52
+ moveLeft(tag: number)
53
+ {
54
+ console.log("moveLeft");
55
+ }
56
+ moveRight(tag: number)
57
+ {
58
+ console.log("moveRight");
59
+ }
60
+ switchSystemKeyboard(tag: number)
61
+ {
62
+ console.log("switchSystemKeyboard");
63
+ }
64
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ */
7
+
8
+ export * from "./ts"
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ */
7
+
8
+ export * as RNC from "./components/ts"
9
+ export * as TM from "./turboModules/ts"
@@ -0,0 +1,32 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ *
7
+ * @generatorVersion: 2
8
+ */
9
+
10
+
11
+ export namespace CustomKeyboardNativeModule {
12
+ export const NAME = 'CustomKeyboardNativeModule' as const
13
+
14
+ export interface Spec {
15
+ install(tag: number, type: string): void;
16
+
17
+ uninstall(tag: number): void;
18
+
19
+ insertText(tag: number, text: string): void;
20
+
21
+ backSpace(tag: number): void;
22
+
23
+ doDelete(tag: number): void;
24
+
25
+ moveLeft(tag: number): void;
26
+
27
+ moveRight(tag: number): void;
28
+
29
+ switchSystemKeyboard(tag: number): void;
30
+
31
+ }
32
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ */
7
+
8
+ export * from "./CustomKeyboardNativeModule"
@@ -0,0 +1,11 @@
1
+ {
2
+ "module": {
3
+ "name": "custom_keyboard",
4
+ "type": "har",
5
+ "deviceTypes": [
6
+ "phone",
7
+ "tablet",
8
+ "2in1"
9
+ ],
10
+ }
11
+ }
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ export * from './src/main/ets/RNCustomKeyboardPackage';
8
+ export * from "./src/main/ets/RNCustomKeyboardTurboModule";
Binary file
package/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ declare namespace RNCustomKeyboard {
8
+ function install: (tag: number, type: string) => void;
9
+ function uninstall: (tag: number) => void;
10
+ function insertText: (tag: number, text: string) => void;
11
+ function backSpace: (tag: number) => void;
12
+ function doDelete: (tag: number) => void;
13
+ function moveLeft: (tag: number) => void;
14
+ function moveRight: (tag: number) => void;
15
+ function switchSystemKeyboard: (tag: number) => void;
16
+ }
17
+ export = RNCustomKeyboard;
package/index.js ADDED
@@ -0,0 +1,66 @@
1
+
2
+ 'use strict'
3
+ import React, { Component } from 'react';
4
+ import { PropTypes } from 'prop-types';
5
+ import CustomKeyboardManager from './src/specs/v2/NativeCustomKeyboard';
6
+ import {
7
+ TextInput,
8
+ findNodeHandle,
9
+ AppRegistry, } from 'react-native';
10
+
11
+ const {
12
+ install, uninstall,
13
+ insertText, backSpace, doDelete,
14
+ moveLeft, moveRight,
15
+ switchSystemKeyboard,
16
+ } = CustomKeyboardManager;
17
+
18
+ export {
19
+ install, uninstall,
20
+ insertText, backSpace, doDelete,
21
+ moveLeft, moveRight,
22
+ switchSystemKeyboard,
23
+ };
24
+
25
+ const keyboardTypeRegistry = {};
26
+
27
+ export function register(type, factory) {
28
+ keyboardTypeRegistry[type] = factory;
29
+ }
30
+
31
+ class CustomKeyboardContainer extends Component {
32
+ render() {
33
+ const { tag, type } = this.props;
34
+ const factory = keyboardTypeRegistry[type];
35
+ if (!factory) {
36
+ console.warn(`Custom keyboard type ${type} not registered.`);
37
+ return null;
38
+ }
39
+ const Comp = factory();
40
+ return <Comp tag={tag} />;
41
+ }
42
+ }
43
+
44
+ AppRegistry.registerComponent("CustomKeyboard", () => CustomKeyboardContainer);
45
+
46
+ export class CustomTextInput extends Component {
47
+ static propTypes = {
48
+ ...TextInput.propTypes,
49
+ customKeyboardType: PropTypes.string,
50
+ };
51
+ handleLayout = () => {
52
+ install(findNodeHandle(this.input), this.props.customKeyboardType);
53
+ };
54
+ componentDidUpdate(newProps) {
55
+ if (newProps.customKeyboardType !== this.props.customKeyboardType) {
56
+ install(findNodeHandle(this.input), newProps.customKeyboardType);
57
+ }
58
+ }
59
+ onRef = ref => {
60
+ this.input = ref;
61
+ };
62
+ render() {
63
+ const { customKeyboardType, ...others } = this.props;
64
+ return <TextInput {...others} ref={this.onRef} onLayout={this.handleLayout}/>;
65
+ }
66
+ }