From 7b3e321939b16e3fba3c103b4374a3c277e22c65 Mon Sep 17 00:00:00 2001
From: tangshutong
Date: Fri, 12 Dec 2025 10:44:29 +0800
Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=E8=BF=81=E7=A7=BB?=
=?UTF-8?q?=E5=A3=B0=E6=98=8E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: tangshutong
---
README.md | 141 ++------------------
doc/en.md | 360 ++++++++++++++++++++++++++++++++++++++++++++++++++
doc/zh-cn.md | 363 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 733 insertions(+), 131 deletions(-)
create mode 100644 doc/en.md
create mode 100644 doc/zh-cn.md
diff --git a/README.md b/README.md
index 932cfd5..ed265f1 100644
--- a/README.md
+++ b/README.md
@@ -1,134 +1,13 @@
-# react-native-text-input-mask
-Text input mask for React Native on iOS and Android.
+# 迁移声明
-
-
-
-
-
-
+- 本仓库已迁移至 GitCode:[OpenHarmony-SIG/rntpc_react-native-text-input-mask](https://gitcode.com/openharmony-sig/rntpc_react-native-text-input-mask)。
+- 包名已更改为 `@react-native-ohos/react-native-text-input-mask`,支持直接从 npm 下载。
+- 更多详情请查阅新仓库的 README 文件。
+- 本仓库旧版本的文档已归档:[链接](/doc/zh-cn.md)
-## Examples
+# Migration Announcement
-
-
-
-## Setup
-
-```bash
-npm install --save react-native-text-input-mask
-
-# --- or ---
-
-yarn add react-native-text-input-mask
-```
-
-# Installation
-
-
- For RN >= 0.60
-
-#### iOS
-1. Configure pods (static or dynamic linking)
-
- Static Library ( Podfile has no use_frameworks! )
-Add following lines to your target in `Podfile`. Linking is not required in React Native 0.60 and above.
-
-```ruby
-pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text', :modular_headers => true
-```
-
-
- Dynamic Framework ( Podfile has use_frameworks! )
-Add following lines to your target in `Podfile` if it doesnt exist. Linking is not required in React Native 0.60 and above.
-
-```
-use_frameworks!
-```
-
-
-2. Run `pod install` in the `ios` directory.
-
-#### Android
-
-No need to do anything.
-
-
-
-For RN < 0.60
-
-### WARNING! This is no longer officially supported, these instructions are out of date and may no longer work, we recommend upgrading to a newer version of React Native.
-
-### Link
-```bash
-react-native link react-native-text-input-mask
-```
-
-**iOS only:** you have to drag and drop `InputMask.framework` to `Embedded Binaries` in General tab of Target
-
-
-
-### Manual installation
-
-#### iOS
-
-1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
-2. Go to `node_modules` ➜ `react-native-text-input-mask` and add `RNTextInputMask.xcodeproj`
-3. In XCode, in the project navigator, select your project. Add `libRNTextInputMask.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
-4. Run your project (`Cmd+R`)
-
-#### Android
-
-1. Open up `android/app/src/main/java/[...]/MainActivity.java`
- - Add `import com.RNTextInputMask.RNTextInputMaskPackage;` to the imports at the top of the file
- - Add `new RNTextInputMaskPackage()` to the list returned by the `getPackages()` method
-2. Append the following lines to `android/settings.gradle`:
- ```
- include ':react-native-text-input-mask'
- project(':react-native-text-input-mask').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-text-input-mask/android')
- ```
-3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
- ```
- compile project(':react-native-text-input-mask')
- ```
-
-
-## Usage
-
-```javascript
-import TextInputMask from 'react-native-text-input-mask';
-...
- {
- console.log(formatted) // +1 (123) 456-78-90
- console.log(extracted) // 1234567890
- }}
- mask={"+1 ([000]) [000] [00] [00]"}
-/>
-...
-```
-
-## Testing
-
-### Jest
-
-Make sure to [mock](https://jestjs.io/docs/en/manual-mocks#mocking-node-modules) the following to `jest.setup.js`:
-```javascript
-jest.mock('react-native-text-input-mask', () => ({
- default: jest.fn(),
-}))
-```
-
-## More info
-
-[RedMadRobot Input Mask Android](https://github.com/RedMadRobot/input-mask-android)
-
-[RedMadRobot Input Mask IOS](https://github.com/RedMadRobot/input-mask-ios)
-
-## Versioning
-
-This project uses semantic versioning: MAJOR.MINOR.PATCH.
-This means that releases within the same MAJOR version are always backwards compatible. For more info see [semver.org](http://semver.org/).
-
-## Local Development and testing
-To use a local copy with your project, it's highly recommended to use https://github.com/wix/wml
+- This repository has been migrated to GitCode:[OpenHarmony-SIG/rntpc_react-native-text-input-mask](https://gitcode.com/openharmony-sig/rntpc_react-native-text-input-mask)
+- The package name has been changed to `@react-native-ohos/react-native-text-input-mask` and is now available for direct download from npm.
+- For more details, please refer to the README in the new repository.
+- Archived documentation for versions in this repository can be found here: [Link](/doc/en.md)
diff --git a/doc/en.md b/doc/en.md
new file mode 100644
index 0000000..eeeb28f
--- /dev/null
+++ b/doc/en.md
@@ -0,0 +1,360 @@
+> Template version: v0.2.2
+
+
+
react-native-text-input-mask
+
+
+
+
+
+
+
+
+
+
+> [!TIP] [GitHub address](https://github.com/react-native-oh-library/react-native-text-input-mask)
+
+## Installation and Usage
+
+Find the matching version information in the release address of a third-party library:[@react-native-oh-tpl/react-native-text-input-mask Releases](https://github.com/react-native-oh-library/react-native-text-input-mask/releases).For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package.
+
+Go to the project directory and execute the following instruction:
+
+
+
+#### **npm**
+
+```bash
+npm install @react-native-oh-tpl/react-native-text-input-mask
+```
+
+#### **yarn**
+
+```bash
+yarn add @react-native-oh-tpl/react-native-text-input-mask
+```
+
+
+
+The following code shows the basic use scenario of the repository:
+
+> [!WARNING] The name of the imported repository remains unchanged.
+
+```tsx
+import React, { useState, useRef } from "react";
+import {
+ StyleSheet,
+ Text,
+ View,
+ ScrollView,
+ Button,
+ TextInput,
+} from "react-native";
+import TextInputMask, {
+ mask,
+ unmask,
+ setMask,
+} from "react-native-text-input-mask";
+import { Colors } from "react-native/Libraries/NewAppScreen";
+export const TextInputTest = () => {
+ const [maskTest, maskValue] = useState("");
+ const maskDemo = () => {
+ mask("+1 ([000]) [000] [00] [00]", "13343469915", true)
+ .then((res) => {
+ maskValue(res);
+ })
+ .catch((err) => {
+ console.log("error", err);
+ });
+ };
+
+ const [unmaskTest, unmaskValue] = useState("");
+ const unmaskDemo = () => {
+ unmask("+1 ([000]) [000] [00] [00]", "13343469915", true)
+ .then((res) => {
+ unmaskValue(res);
+ })
+ .catch((err) => {
+ console.log("error", err);
+ });
+ };
+ const customNotations = [
+ { character: "s", characterSet: "$€", isOptional: true },
+ ];
+ const [onChangeTextTest_formatted, setonChangeTextValue_formatted] =
+ useState("");
+ const [onChangeTextTest_extracted, setonChangeTextValue_extracted] =
+ useState("");
+ const componentDemo = (formatted: string, extracted: string | undefined) => {
+ console.log("formatted", formatted);
+ setonChangeTextValue_formatted(formatted);
+ console.log("extracted", extracted);
+ if (extracted) {
+ setonChangeTextValue_extracted(extracted);
+ }
+ };
+ return (
+
+
+
+ {onChangeTextTest_formatted}
+ {onChangeTextTest_extracted}
+
+
+ Phone Number:
+
+ {maskTest}
+
+
+ Phone Number:
+
+ {unmaskTest}
+
+
+ );
+};
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ justifyContent: "center",
+ padding: 16,
+ },
+ label: {
+ color: Colors.white,
+ fontSize: 16,
+ marginBottom: 8,
+ },
+ input: {
+ height: 40,
+ color: Colors.white,
+ borderColor: "#ccc",
+ borderWidth: 1,
+ paddingHorizontal: 8,
+ },
+});
+```
+
+## Link
+
+Currently, HarmonyOS does not support AutoLink. Therefore, you need to manually configure the linking.
+
+Open the `harmony` directory of the HarmonyOS project in DevEco Studio.
+
+### 1.Adding the overrides Field to oh-package.json5 File in the Root Directory of the Project
+
+```json
+{
+ ...
+ "overrides": {
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
+ }
+}
+```
+
+### 2.Introducing Native Code
+
+Currently, two methods are available:
+
+Method 1 (recommended): Use the HAR file.
+
+> [!TIP] The HAR file is stored in the `harmony` directory in the installation path of the third-party library.
+
+Open `entry/oh-package.json5` file and add the following dependencies:
+
+```json
+ "dependencies": {
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
+ "@react-native-oh-tpl/react-native-text-input-mask": "file:../../node_modules/@react-native-oh-tpl/react-native-text-input-mask/harmony/text_input_mask.har"
+ }
+```
+
+Click the `sync` button in the upper right corner.
+
+Alternatively, run the following instruction on the terminal:
+
+```bash
+cd entry
+ohpm install
+```
+
+Method 2: Directly link to the source code.
+
+> [!TIP] For details, see [Directly Linking Source Code](/en/link-source-code.md).
+
+### 3. Configuring CMakeLists and Introducing RNTextInputMaskPackage
+
+Open `entry/src/main/cpp/CMakeLists.txt` and add the following code:
+
+```diff
+project(rnapp)
+cmake_minimum_required(VERSION 3.4.1)
+set(CMAKE_SKIP_BUILD_RPATH TRUE)
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(RNOH_CPP_DIR "${OH_MODULE_DIR}/@rnoh/react-native-openharmony/src/main/cpp")
+set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
+
+file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp")
+
+set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
+set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
+add_compile_definitions(WITH_HITRACE_SYSTRACE)
+set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-text-input-mask/src/main/cpp" ./RNTextInputMask)
+
+add_library(rnoh_app SHARED
+ ${GENERATED_CPP_FILES}
+ "./PackageProvider.cpp"
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
+)
+
+
+target_link_libraries(rnoh_app PUBLIC rnoh)
++ target_link_libraries(rnoh_app PUBLIC text_input_mask)
+```
+
+Open `entry/src/main/cpp/PackageProvider.cpp` and add the following code:
+
+```diff
+#include "RNOH/PackageProvider.h"
+#include "generated/RNOHGeneratedPackage.h"
++ #include "RNTextInputMaskPackage.h"
+ using namespace rnoh;
+
+ std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {std::make_shared(ctx),
++ std::make_shared(ctx)
+ };
+ }
+```
+
+### 4. Introducing RNTextInputMaskPackage to ArkTS
+
+Open the `entry/src/main/ets/RNPackagesFactory.ts` file and add the following code:
+
+```diff
+ ...
++ import { RNTextInputMaskPackage } from '@react-native-oh-tpl/react-native-text-input-mask/ts'
+
+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
+ return [
+ new SamplePackage(ctx),
++ new RNTextInputMaskPackage(ctx)
+ ];
+}
+```
+
+### 5.Running
+
+Click the `sync` button in the upper right corner.
+
+Alternatively, run the following instruction on the terminal:
+
+```bash
+cd entry
+ohpm install
+```
+
+Then build and run the code.
+
+## Constraints
+
+### Compatibility
+
+To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone.
+
+Check the release version information in the release address of the third-party library: [@react-native-oh-tpl/react-native-text-input-mask Releases](https://github.com/react-native-oh-library/react-native-text-input-mask/releases)
+
+## API
+
+> [!TIP] The **Platform** column indicates the platform where the properties are supported in the original third-party library.
+
+> [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
+
+| Name | Description | Type | Platform | HarmonyOS Support |
+| ------------- | ------------------------------------------------------------------------------------------------------------------------- | --------- | ----------- | ----------------- |
+| mask | Format a string,Return the formatted string | function | Android/iOS | yes |
+| unmask | Restore the formatted string,Return the restored string | function | Android/iOS | yes |
+| setMask | Set a listener for a component,Format the input content of a text box,Use in conjunction with the TextInput component | function | Android/iOS | yes |
+| TextInputMask | Text input component | component | Android/iOS | yes |
+
+#### mask
+
+```js
+mask(mask: string, value: string, autocomplete: boolean) : Promise
+```
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------------ | ------------------------------ | ------- | -------- | ----------- | ----------------- |
+| mask | Format for string formatting | string | yes | iOS/Android | yes |
+| value | Characters to be formatted | string | yes | iOS/Android | yes |
+| autocomplete | Automatic character completion | boolean | no | iOS/Android | yes |
+
+#### unmask
+
+```json
+unmask(mask: string, value: string, autocomplete: boolean) : Promise
+```
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------------ | ------------------------------ | ------- | -------- | ----------- | ----------------- |
+| mask | Format for string formatting | string | yes | iOS/Android | yes |
+| value | Characters to be restored | string | yes | iOS/Android | yes |
+| autocomplete | Automatic character completion | boolean | no | iOS/Android | yes |
+
+#### setMask
+
+```
+setMask (reactNode: number, primaryFormat: string, options?: MaskOptions) : void
+```
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| :------------ | ----------------------------- | ----------- | -------- | ----------- | ----------------- |
+| reactNode | Component ID | string | yes | iOS/Android | yes |
+| primaryFormat | Formatting format | string | yes | iOS/Android | yes |
+| options | Formatting-related properties | MaskOptions | no | iOS/Android | yes |
+
+##### MaskOptions
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| --------------------------- | ------------------------------------ | -------------------------------- | -------- | ----------- | ----------------- |
+| affineFormats | Alternate format | string[] | no | iOS/Android | yes |
+| customNotations | Custom escape characters | Natation[] | no | iOS/Android | yes |
+| affinityCalculationStrategy | Affinity calculation strategy | AffinityCalculationStrategy 枚举 | no | iOS/Android | yes |
+| autocomplete | Whether to automatically complete | boolean | no | iOS/Android | yes |
+| autoskip | Whether to automatically skip | boolean | no | iOS/Android | yes |
+| rightToLeft | Whether to format from right to left | boolean | no | iOS/Android | yes |
+
+##### Natation
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------------ | -------------------------------------------------------- | ------- | -------- | ----------- | ----------------- |
+| character | Symbols in the format string | string | yes | iOS/Android | yes |
+| characterSet | Associated character set for acceptable input characters | string | yes | iOS/Android | yes |
+| isOptional | Whether the symbol is optional or mandatory | boolean | yes | iOS/Android | yes |
+
+##### AffinityCalculationStrategy
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- | ----------- | ----------------- |
+| WHOLE_STRING | Default calculation strategy | string | no | iOS/Android | yes |
+| PREFIX | Find the longest common prefix between the original text and the identical text | string | no | iOS/Android | yes |
+| CAPACITY | Affinity is the tolerance between the length of the input and the total amount of text that the current mask can accommodate. | string | no | iOS/Android | yes |
+| EXTRACTED_VALUE_CAPACITY | Affinity is the tolerance between the length of the extracted value and the total length of extracted values that the current mask can accommodate. | string | no | iOS/Android | yes |
+
+## Others
+
+## License
+
+This project is licensed under[The MIT License(MIT)](https://github.com/react-native-text-input-mask/react-native-text-input-mask/blob/master/LICENSE).
\ No newline at end of file
diff --git a/doc/zh-cn.md b/doc/zh-cn.md
new file mode 100644
index 0000000..771f09d
--- /dev/null
+++ b/doc/zh-cn.md
@@ -0,0 +1,363 @@
+> 模板版本:v0.2.2
+
+
+
react-native-text-input-mask
+
+
+
+
+
+
+
+
+
+
+
+
+> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-text-input-mask)
+
+## 安装与使用
+
+请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-text-input-mask Releases](https://github.com/react-native-oh-library/react-native-text-input-mask/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。
+
+进入到工程目录并输入以下命令:
+
+
+
+#### **npm**
+
+```bash
+npm install @react-native-oh-tpl/react-native-text-input-mask
+```
+
+#### **yarn**
+
+```bash
+yarn add @react-native-oh-tpl/react-native-text-input-mask
+```
+
+
+
+下面的代码展示了这个库的基本使用场景:
+
+> [!WARNING] 使用时 import 的库名不变。
+
+```tsx
+import React, { useState, useRef } from "react";
+import { StyleSheet, Text, View, ScrollView, Button, TextInput } from "react-native";
+import TextInputMask, { mask, unmask, setMask } from 'react-native-text-input-mask'
+import { Colors } from "react-native/Libraries/NewAppScreen";
+export const TextInputTest = () => {
+ const [maskTest, maskValue] = useState('');
+ const maskDemo = () => {
+ mask("+1 ([000]) [000] [00] [00]", "13343469915", true).then(res => {
+ maskValue(res)
+ }).catch(err => {
+ console.log('error', err)
+ })
+ }
+
+ const [unmaskTest, unmaskValue] = useState('');
+ const unmaskDemo = () => {
+ unmask("+1 ([000]) [000] [00] [00]", "13343469915", true).then(res => {
+ unmaskValue(res)
+ }).catch(err => {
+ console.log('error', err)
+ })
+ }
+ const customNotations = [{ "character": 's', "characterSet": "$€", "isOptional": true }]
+ const [onChangeTextTest_formatted, setonChangeTextValue_formatted] = useState('');
+ const [onChangeTextTest_extracted, setonChangeTextValue_extracted] = useState('');
+ const componentDemo = (formatted: string, extracted: string | undefined) => {
+ console.log("formatted", formatted)
+ setonChangeTextValue_formatted(formatted)
+ console.log("extracted", extracted)
+ if (extracted) {
+ setonChangeTextValue_extracted(extracted)
+ }
+ }
+ return (
+
+
+
+ {onChangeTextTest_formatted}
+ {onChangeTextTest_extracted}
+
+
+ Phone Number:
+
+
+ {maskTest}
+
+
+
+ Phone Number:
+
+
+ {unmaskTest}
+
+
+
+ );
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ justifyContent: 'center',
+ padding: 16,
+ },
+ label: {
+ color: Colors.white,
+ fontSize: 16,
+ marginBottom: 8,
+ },
+ input: {
+ height: 40,
+ color: Colors.white,
+ borderColor: '#ccc',
+ borderWidth: 1,
+ paddingHorizontal: 8,
+ },
+});
+
+```
+
+
+## Link
+
+目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。
+
+首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`
+
+### 1.在工程根目录的 `oh-package.json` 添加 overrides 字段
+
+```json
+{
+ ...
+ "overrides": {
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
+ }
+}
+```
+
+### 2.引入原生端代码
+
+目前有两种方法:
+
+1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
+2. 直接链接源码。
+
+方法一:通过 har 包引入(推荐)
+
+> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
+
+打开 `entry/oh-package.json5`,添加以下依赖
+
+```json
+ "dependencies": {
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
+ "@react-native-oh-tpl/react-native-text-input-mask": "file:../../node_modules/@react-native-oh-tpl/react-native-text-input-mask/harmony/text_input_mask.har"
+ }
+```
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+方法二:直接链接源码
+
+> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md)
+
+### 3.配置 CMakeLists 和引入 RNTextInputMaskPackage
+
+打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
+
+ ``` diff
+project(rnapp)
+cmake_minimum_required(VERSION 3.4.1)
+set(CMAKE_SKIP_BUILD_RPATH TRUE)
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(RNOH_CPP_DIR "${OH_MODULE_DIR}/@rnoh/react-native-openharmony/src/main/cpp")
+set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
+
+file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp")
+
+set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
+set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
+add_compile_definitions(WITH_HITRACE_SYSTRACE)
+set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-text-input-mask/src/main/cpp" ./RNTextInputMask)
+
+add_library(rnoh_app SHARED
+ ${GENERATED_CPP_FILES}
+ "./PackageProvider.cpp"
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
+)
+
+
+target_link_libraries(rnoh_app PUBLIC rnoh)
++ target_link_libraries(rnoh_app PUBLIC text_input_mask)
+ ```
+
+打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
+
+``` diff
+#include "RNOH/PackageProvider.h"
+#include "generated/RNOHGeneratedPackage.h"
++ #include "RNTextInputMaskPackage.h"
+ using namespace rnoh;
+
+ std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {std::make_shared(ctx),
++ std::make_shared(ctx)
+ };
+ }
+```
+
+### 4.在 ArkTs 侧引入 RNTextInputMaskPackage
+
+打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
+
+```diff
+ ...
++ import { RNTextInputMaskPackage } from '@react-native-oh-tpl/react-native-text-input-mask/ts'
+
+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
+ return [
+ new SamplePackage(ctx),
++ new RNTextInputMaskPackage(ctx)
+ ];
+}
+```
+
+### 5.运行
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+然后编译、运行即可。
+
+## 约束与限制
+
+### 兼容性
+
+要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
+
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-text-input-mask Releases](https://github.com/react-native-oh-library/react-native-text-input-mask/releases)
+
+
+
+
+## API
+
+> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
+
+> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
+
+| Name | Description | Type | Platform | HarmonyOS Support |
+| ------- | ---------------------- | -------- | ----------- | ----------------- |
+| mask | 字符串格式化,返回格式化后的字符串 | function | Android/iOS | yes |
+| unmask | 将格式化后的字符串还原,返回还原后的字符串 | function | Android/iOS | yes |
+| setMask | 给组件设置监听,对输入框内容进行格式化,配合TextInput组件使用 | function | Android/iOS | yes |
+| TextInputMask | 输入框组件 | component | Android/iOS | yes |
+
+#### mask参数说明
+
+```js
+mask(mask: string, value: string, autocomplete: boolean) : Promise
+```
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ----------- | ----------------------- | ------ | -------- | ----------- | ----------------- |
+| mask | 字符串格式化的格式 | string | yes | iOS/Android | yes |
+| value | 需要格式化的字符 | string | yes | iOS/Android | yes |
+| autocomplete | 字符自动补全 | boolean | no | iOS/Android | yes |
+
+#### unmask参数说明
+
+```json
+unmask(mask: string, value: string, autocomplete: boolean) : Promise
+```
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| --------- | ---------------------------------------------- | ------ | -------- | ----------- | ----------------- |
+| mask | 字符串格式化的格式 | string | yes | iOS/Android | yes |
+| value | 需要还原的字符 | string | yes | iOS/Android | yes |
+| autocomplete | 字符自动补全 | boolean | no | iOS/Android | yes |
+
+#### setMask参数说明
+
+```
+setMask (reactNode: number, primaryFormat: string, options?: MaskOptions) : void
+```
+
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| :-------- | ---------------------------------------------- | ------ | -------- | ----------- | ----------------- |
+| reactNode | 组件id | string | yes | iOS/Android | yes |
+| primaryFormat | 格式化的格式 | string | yes | iOS/Android | yes |
+| options | 格式化相关属性 | MaskOptions | no | iOS/Android | yes |
+
+##### MaskOptions
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| --------- | ---------------------------------------------- | ------ | -------- | ----------- | ----------------- |
+| affineFormats | 备用格式 | string[] | no | iOS/Android | yes |
+| customNotations | 自定义转义字符 | Natation[] | no | iOS/Android | yes |
+| affinityCalculationStrategy | 亲和度计算策略 | AffinityCalculationStrategy 枚举 | no | iOS/Android | yes |
+| autocomplete | 是否自动补全 | boolean | no | iOS/Android | yes |
+| autoskip | 是否自动跳过 | boolean | no | iOS/Android | yes |
+| rightToLeft | 是否从右到左格式化 | boolean | no | iOS/Android | yes |
+
+##### Natation
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| --------- | ---------------------------------------------- | ------ | -------- | ----------- | ----------------- |
+| character | 格式字符串中的符号。 | string | yes | iOS/Android | yes |
+| characterSet | 可接受输入字符的关联字符集。 | string | yes | iOS/Android | yes |
+| isOptional |是可选符号还是必选符号 | boolean | yes | iOS/Android | yes |
+
+##### AffinityCalculationStrategy
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| --------- | ---------------------------------------------- | ------ | -------- | ----------- | ----------------- |
+| WHOLE_STRING | 默认的计算策略 | string | no | iOS/Android | yes |
+| PREFIX | 查找原始文本和相同文本之间的最长公共前缀 | string | no | iOS/Android | yes |
+| CAPACITY | 亲和性是输入的长度和当前掩码可以容纳的文本总量之间的容差。 | string | no | iOS/Android | yes |
+| EXTRACTED_VALUE_CAPACITY | 亲和性是提取值的长度与当前掩码可以容纳的总提取值长度之间的容差。 | string | no | iOS/Android | yes |
+
+## 其他
+
+## 开源协议
+
+本项目基于[The MIT License(MIT)](https://github.com/react-native-text-input-mask/react-native-text-input-mask/blob/master/LICENSE) ,请自由地享受和参与开源。
+
+